n8n/packages/nodes-base/nodes/Google/Calendar/CalendarDescription.ts
Marcus b319671fd0
feat(Google Calendar Node): Use resource locator component for calendar parameters (#4410)
* use calendar RLC for event resource
* use calendar RLC for calendar resource
* listSearch getCalendars support query filter
* improve RLC parameter descriptions to match standards
* stricter google calendar id email regex with optional trailing whitespace
* calendarId RLC for Google Calendar Trigger node
* Event -> Get : Timezone RLC option
* Event -> Get Many : Timezone RLC option
* Calendar -> Availability : Timezone RLC option
* Removed unused loadOptions getTimezones; Removed unused imports
* fix prettier linting errors
2022-11-29 17:11:49 +01:00

183 lines
4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { INodeProperties } from 'n8n-workflow';
import { TIMEZONE_VALIDATION_REGEX } from './GenericFunctions';
export const calendarOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['calendar'],
},
},
options: [
{
name: 'Availability',
value: 'availability',
description: 'If a time-slot is available in a calendar',
action: 'Get availability in a calendar',
},
],
default: 'availability',
},
];
export const calendarFields: INodeProperties[] = [
/* -------------------------------------------------------------------------- */
/* calendar:availability */
/* -------------------------------------------------------------------------- */
{
displayName: 'Calendar',
name: 'calendar',
type: 'resourceLocator',
default: { mode: 'list', value: '' },
required: true,
description: 'Google Calendar to operate on',
modes: [
{
displayName: 'Calendar',
name: 'list',
type: 'list',
placeholder: 'Select a Calendar...',
typeOptions: {
searchListMethod: 'getCalendars',
searchable: true,
},
},
{
displayName: 'ID',
name: 'id',
type: 'string',
validation: [
{
type: 'regex',
properties: {
// calendar ids are emails. W3C email regex with optional trailing whitespace.
regex:
'(^[a-zA-Z0-9.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*(?:[ \t]+)*$)',
errorMessage: 'Not a valid Google Calendar ID',
},
},
],
extractValue: {
type: 'regex',
regex: '(^[a-zA-Z0-9.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*)',
},
placeholder: 'name@google.com',
},
],
displayOptions: {
show: {
resource: ['calendar'],
},
},
},
{
displayName: 'Start Time',
name: 'timeMin',
type: 'dateTime',
required: true,
displayOptions: {
show: {
operation: ['availability'],
resource: ['calendar'],
},
},
default: '',
description: 'Start of the interval',
},
{
displayName: 'End Time',
name: 'timeMax',
type: 'dateTime',
required: true,
displayOptions: {
show: {
operation: ['availability'],
resource: ['calendar'],
},
},
default: '',
description: 'End of the interval',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Options',
displayOptions: {
show: {
operation: ['availability'],
resource: ['calendar'],
},
},
default: {},
options: [
{
displayName: 'Output Format',
name: 'outputFormat',
type: 'options',
options: [
{
name: 'Availability',
value: 'availability',
description: 'Returns if there are any events in the given time or not',
},
{
name: 'Booked Slots',
value: 'bookedSlots',
description: 'Returns the booked slots',
},
{
name: 'RAW',
value: 'raw',
description: 'Returns the RAW data from the API',
},
],
default: 'availability',
description: 'The format to return the data in',
},
{
displayName: 'Timezone',
name: 'timezone',
type: 'resourceLocator',
default: { mode: 'list', value: '' },
description: 'Time zone used in the response. By default n8n timezone is used.',
modes: [
{
displayName: 'Timezone',
name: 'list',
type: 'list',
placeholder: 'Select a Timezone...',
typeOptions: {
searchListMethod: 'getTimezones',
searchable: true,
},
},
{
displayName: 'ID',
name: 'id',
type: 'string',
validation: [
{
type: 'regex',
properties: {
regex: TIMEZONE_VALIDATION_REGEX,
errorMessage: 'Not a valid Timezone',
},
},
],
extractValue: {
type: 'regex',
regex: '([-+/_a-zA-Z0-9]*)',
},
placeholder: 'Europe/Berlin',
},
],
},
],
},
];