2023-01-27 03:22:44 -08:00
|
|
|
|
import type { INodeProperties } from 'n8n-workflow';
|
2022-11-29 08:11:49 -08:00
|
|
|
|
import { TIMEZONE_VALIDATION_REGEX } from './GenericFunctions';
|
2020-10-30 01:31:27 -07:00
|
|
|
|
|
2021-12-03 00:44:16 -08:00
|
|
|
|
export const calendarOperations: INodeProperties[] = [
|
2020-10-30 01:31:27 -07:00
|
|
|
|
{
|
|
|
|
|
displayName: 'Operation',
|
|
|
|
|
name: 'operation',
|
|
|
|
|
type: 'options',
|
2022-05-14 01:44:19 -07:00
|
|
|
|
noDataExpression: true,
|
2020-10-30 01:31:27 -07:00
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
|
resource: ['calendar'],
|
2020-10-30 01:31:27 -07:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
options: [
|
|
|
|
|
{
|
2020-10-30 01:32:35 -07:00
|
|
|
|
name: 'Availability',
|
|
|
|
|
value: 'availability',
|
|
|
|
|
description: 'If a time-slot is available in a calendar',
|
2022-07-10 13:50:51 -07:00
|
|
|
|
action: 'Get availability in a calendar',
|
2020-10-30 01:31:27 -07:00
|
|
|
|
},
|
|
|
|
|
],
|
2020-10-30 01:32:35 -07:00
|
|
|
|
default: 'availability',
|
2020-10-30 01:31:27 -07:00
|
|
|
|
},
|
2021-12-03 00:44:16 -08:00
|
|
|
|
];
|
2020-10-30 01:31:27 -07:00
|
|
|
|
|
2021-12-03 00:44:16 -08:00
|
|
|
|
export const calendarFields: INodeProperties[] = [
|
2020-10-30 01:32:35 -07:00
|
|
|
|
/* -------------------------------------------------------------------------- */
|
2022-03-13 04:00:12 -07:00
|
|
|
|
/* calendar:availability */
|
2020-10-30 01:32:35 -07:00
|
|
|
|
/* -------------------------------------------------------------------------- */
|
2020-10-30 01:31:27 -07:00
|
|
|
|
{
|
2022-11-29 08:11:49 -08:00
|
|
|
|
displayName: 'Calendar',
|
2020-10-30 01:32:35 -07:00
|
|
|
|
name: 'calendar',
|
2022-11-29 08:11:49 -08:00
|
|
|
|
type: 'resourceLocator',
|
|
|
|
|
default: { mode: 'list', value: '' },
|
2020-10-30 01:31:27 -07:00
|
|
|
|
required: true,
|
2022-11-29 08:11:49 -08:00
|
|
|
|
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',
|
|
|
|
|
},
|
|
|
|
|
],
|
2020-10-30 01:31:27 -07:00
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
|
resource: ['calendar'],
|
2020-10-30 01:31:27 -07:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
2020-10-30 01:32:35 -07:00
|
|
|
|
displayName: 'Start Time',
|
2020-10-30 01:31:27 -07:00
|
|
|
|
name: 'timeMin',
|
|
|
|
|
type: 'dateTime',
|
|
|
|
|
required: true,
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
|
operation: ['availability'],
|
|
|
|
|
resource: ['calendar'],
|
2020-10-30 01:31:27 -07:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
default: '',
|
|
|
|
|
description: 'Start of the interval',
|
|
|
|
|
},
|
|
|
|
|
{
|
2020-10-30 01:32:35 -07:00
|
|
|
|
displayName: 'End Time',
|
2020-10-30 01:31:27 -07:00
|
|
|
|
name: 'timeMax',
|
|
|
|
|
type: 'dateTime',
|
|
|
|
|
required: true,
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
|
operation: ['availability'],
|
|
|
|
|
resource: ['calendar'],
|
2020-10-30 01:31:27 -07:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
default: '',
|
|
|
|
|
description: 'End of the interval',
|
|
|
|
|
},
|
|
|
|
|
{
|
2020-10-30 01:32:35 -07:00
|
|
|
|
displayName: 'Options',
|
|
|
|
|
name: 'options',
|
2020-10-30 01:31:27 -07:00
|
|
|
|
type: 'collection',
|
2020-10-30 01:32:35 -07:00
|
|
|
|
placeholder: 'Add Options',
|
2020-10-30 01:31:27 -07:00
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
|
operation: ['availability'],
|
|
|
|
|
resource: ['calendar'],
|
2020-10-30 01:31:27 -07:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
default: {},
|
|
|
|
|
options: [
|
2020-10-30 01:32:35 -07:00
|
|
|
|
{
|
|
|
|
|
displayName: 'Output Format',
|
|
|
|
|
name: 'outputFormat',
|
|
|
|
|
type: 'options',
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
name: 'Availability',
|
|
|
|
|
value: 'availability',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'Returns if there are any events in the given time or not',
|
2020-10-30 01:32:35 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Booked Slots',
|
|
|
|
|
value: 'bookedSlots',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'Returns the booked slots',
|
2020-10-30 01:32:35 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'RAW',
|
|
|
|
|
value: 'raw',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'Returns the RAW data from the API',
|
2020-10-30 01:32:35 -07:00
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
default: 'availability',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The format to return the data in',
|
2020-10-30 01:32:35 -07:00
|
|
|
|
},
|
2020-10-30 01:31:27 -07:00
|
|
|
|
{
|
2022-11-29 08:11:49 -08:00
|
|
|
|
displayName: 'Timezone',
|
2020-10-30 01:31:27 -07:00
|
|
|
|
name: 'timezone',
|
2022-11-29 08:11:49 -08:00
|
|
|
|
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',
|
|
|
|
|
},
|
|
|
|
|
],
|
2020-10-30 01:31:27 -07:00
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
2021-12-03 00:44:16 -08:00
|
|
|
|
];
|