From 25dffd990493826c4bda5ce3e98bb198e4875a61 Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Sun, 21 Feb 2021 16:04:00 -0500 Subject: [PATCH] :sparkles: Add rrule parameter to Google Calendar Node (#1460) --- .../nodes/Google/Calendar/EventDescription.ts | 16 ++- .../nodes/Google/Calendar/EventInterface.ts | 2 +- .../nodes/Google/Calendar/GenericFunctions.ts | 4 +- .../Google/Calendar/GoogleCalendar.node.ts | 110 ++++++++++-------- .../nodes/Google/Calendar/googleCalendar.png | Bin 1843 -> 0 bytes .../nodes/Google/Calendar/googleCalendar.svg | 1 + 6 files changed, 78 insertions(+), 55 deletions(-) delete mode 100644 packages/nodes-base/nodes/Google/Calendar/googleCalendar.png create mode 100644 packages/nodes-base/nodes/Google/Calendar/googleCalendar.svg diff --git a/packages/nodes-base/nodes/Google/Calendar/EventDescription.ts b/packages/nodes-base/nodes/Google/Calendar/EventDescription.ts index 035e8f0787..b1ed3e50cd 100644 --- a/packages/nodes-base/nodes/Google/Calendar/EventDescription.ts +++ b/packages/nodes-base/nodes/Google/Calendar/EventDescription.ts @@ -48,7 +48,7 @@ export const eventOperations = [ export const eventFields = [ /* -------------------------------------------------------------------------- */ - /* event:ALL */ + /* event:getAll */ /* -------------------------------------------------------------------------- */ { displayName: 'Calendar ID', @@ -300,6 +300,13 @@ export const eventFields = [ }, default: 1, }, + { + displayName: 'RRULE', + name: 'rrule', + type: 'string', + default: '', + description: 'Recurrence rule. When set, the parameters Repeat Frecuency, Repeat How Many Times and Repeat Until are ignored.', + }, { displayName: 'Send Updates', name: 'sendUpdates', @@ -920,6 +927,13 @@ export const eventFields = [ }, default: 1, }, + { + displayName: 'RRULE', + name: 'rrule', + type: 'string', + default: '', + description: 'Recurrence rule. When set, the parameters Repeat Frecuency, Repeat How Many Times and Repeat Until are ignored.', + }, { displayName: 'Start', name: 'start', diff --git a/packages/nodes-base/nodes/Google/Calendar/EventInterface.ts b/packages/nodes-base/nodes/Google/Calendar/EventInterface.ts index 2800333a1c..53471ca18f 100644 --- a/packages/nodes-base/nodes/Google/Calendar/EventInterface.ts +++ b/packages/nodes-base/nodes/Google/Calendar/EventInterface.ts @@ -1,6 +1,6 @@ import { IDataObject, - } from 'n8n-workflow'; +} from 'n8n-workflow'; export interface IReminder { useDefault?: boolean; diff --git a/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts index a2eed8ea96..edc841710c 100644 --- a/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts @@ -1,6 +1,6 @@ import { OptionsWithUri, - } from 'request'; +} from 'request'; import { IExecuteFunctions, @@ -47,7 +47,7 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF } } -export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any const returnData: IDataObject[] = []; diff --git a/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts b/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts index 803446de98..e66f718ecb 100644 --- a/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts +++ b/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts @@ -38,7 +38,7 @@ export class GoogleCalendar implements INodeType { description: INodeTypeDescription = { displayName: 'Google Calendar', name: 'googleCalendar', - icon: 'file:googleCalendar.png', + icon: 'file:googleCalendar.svg', group: ['input'], version: 1, subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', @@ -321,33 +321,37 @@ export class GoogleCalendar implements INodeType { //exampel: RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=10;UNTIL=20110701T170000Z //https://icalendar.org/iCalendar-RFC-5545/3-8-5-3-recurrence-rule.html body.recurrence = []; - if ( - additionalFields.repeatHowManyTimes && - additionalFields.repeatUntil - ) { - throw new Error( - `You can set either 'Repeat How Many Times' or 'Repeat Until' but not both`, - ); - } - if (additionalFields.repeatFrecuency) { - body.recurrence?.push( - `FREQ=${(additionalFields.repeatFrecuency as string).toUpperCase()};`, - ); - } - if (additionalFields.repeatHowManyTimes) { - body.recurrence?.push( - `COUNT=${additionalFields.repeatHowManyTimes};`, - ); - } - if (additionalFields.repeatUntil) { - body.recurrence?.push( - `UNTIL=${moment(additionalFields.repeatUntil as string) - .utc() - .format('YYYYMMDDTHHmmss')}Z`, - ); - } - if (body.recurrence.length !== 0) { - body.recurrence = [`RRULE:${body.recurrence.join('')}`]; + if (additionalFields.rrule) { + body.recurrence = [`RRULE:${additionalFields.rrule}`]; + } else { + if ( + additionalFields.repeatHowManyTimes && + additionalFields.repeatUntil + ) { + throw new Error( + `You can set either 'Repeat How Many Times' or 'Repeat Until' but not both`, + ); + } + if (additionalFields.repeatFrecuency) { + body.recurrence?.push( + `FREQ=${(additionalFields.repeatFrecuency as string).toUpperCase()};`, + ); + } + if (additionalFields.repeatHowManyTimes) { + body.recurrence?.push( + `COUNT=${additionalFields.repeatHowManyTimes};`, + ); + } + if (additionalFields.repeatUntil) { + body.recurrence?.push( + `UNTIL=${moment(additionalFields.repeatUntil as string) + .utc() + .format('YYYYMMDDTHHmmss')}Z`, + ); + } + if (body.recurrence.length !== 0) { + body.recurrence = [`RRULE:${body.recurrence.join('')}`]; + } } if (additionalFields.conferenceDataUi) { @@ -565,30 +569,34 @@ export class GoogleCalendar implements INodeType { //exampel: RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=10;UNTIL=20110701T170000Z //https://icalendar.org/iCalendar-RFC-5545/3-8-5-3-recurrence-rule.html body.recurrence = []; - if (updateFields.repeatHowManyTimes && updateFields.repeatUntil) { - throw new Error( - `You can set either 'Repeat How Many Times' or 'Repeat Until' but not both`, - ); - } - if (updateFields.repeatFrecuency) { - body.recurrence?.push( - `FREQ=${(updateFields.repeatFrecuency as string).toUpperCase()};`, - ); - } - if (updateFields.repeatHowManyTimes) { - body.recurrence?.push(`COUNT=${updateFields.repeatHowManyTimes};`); - } - if (updateFields.repeatUntil) { - body.recurrence?.push( - `UNTIL=${moment(updateFields.repeatUntil as string) - .utc() - .format('YYYYMMDDTHHmmss')}Z`, - ); - } - if (body.recurrence.length !== 0) { - body.recurrence = [`RRULE:${body.recurrence.join('')}`]; + if (updateFields.rrule) { + body.recurrence = [`RRULE:${updateFields.rrule}`]; } else { - delete body.recurrence; + if (updateFields.repeatHowManyTimes && updateFields.repeatUntil) { + throw new Error( + `You can set either 'Repeat How Many Times' or 'Repeat Until' but not both`, + ); + } + if (updateFields.repeatFrecuency) { + body.recurrence?.push( + `FREQ=${(updateFields.repeatFrecuency as string).toUpperCase()};`, + ); + } + if (updateFields.repeatHowManyTimes) { + body.recurrence?.push(`COUNT=${updateFields.repeatHowManyTimes};`); + } + if (updateFields.repeatUntil) { + body.recurrence?.push( + `UNTIL=${moment(updateFields.repeatUntil as string) + .utc() + .format('YYYYMMDDTHHmmss')}Z`, + ); + } + if (body.recurrence.length !== 0) { + body.recurrence = [`RRULE:${body.recurrence.join('')}`]; + } else { + delete body.recurrence; + } } responseData = await googleApiRequest.call( this, diff --git a/packages/nodes-base/nodes/Google/Calendar/googleCalendar.png b/packages/nodes-base/nodes/Google/Calendar/googleCalendar.png deleted file mode 100644 index 31e365fdbd6944d92c8d335d8715f99f67258e70..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1843 zcmV-32h8}1P)S(8I&SMuqW2d*e!S&@W)nOmxvOVbCjG&@o@mNs9Hz*6&4u>qC9#M1ABt zZrU+m(8k5Xy1c-Pu<$~G?LU9*M1SaZk3q^X}N-?&<36t;6h?wd{DI>xZlANrLJ&b?EKq-00-n zGH2G@+0(+u(y_eKkfhRWi_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#QY6X#tUu hxvNA+<(J>T=@;apTA+xJPu~Cl002ovPDHLkV1fao=4t={ diff --git a/packages/nodes-base/nodes/Google/Calendar/googleCalendar.svg b/packages/nodes-base/nodes/Google/Calendar/googleCalendar.svg new file mode 100644 index 0000000000..c139a747d2 --- /dev/null +++ b/packages/nodes-base/nodes/Google/Calendar/googleCalendar.svg @@ -0,0 +1 @@ + \ No newline at end of file