From f958e6ffab1daa42b2cf62258d6b6b7f10739df5 Mon Sep 17 00:00:00 2001 From: Michael Kret <88898367+michael-radency@users.noreply.github.com> Date: Mon, 18 Jul 2022 11:15:03 +0300 Subject: [PATCH] refactor: Change Google nodes to use OAuth2 as default (#3713) * upstream merge * :zap: oAuth2 by default for Google nodes * :zap: lockfile fix --- .../Google/BigQuery/GoogleBigQuery.node.ts | 8 ++--- .../nodes/Google/Books/GoogleBooks.node.ts | 32 ++++++++++++++++++- .../nodes/Google/Docs/GoogleDocs.node.ts | 32 ++++++++++++++++++- .../nodes/Google/Drive/GoogleDrive.node.ts | 30 +++++++++++++++++ .../Google/Drive/GoogleDriveTrigger.node.ts | 8 ++--- .../nodes/Google/Gmail/Gmail.node.ts | 8 ++--- .../nodes/Google/Sheet/GoogleSheets.node.ts | 32 ++++++++++++++++++- .../nodes/Google/Slides/GoogleSlides.node.ts | 32 ++++++++++++++++++- .../Google/Translate/GoogleTranslate.node.ts | 32 ++++++++++++++++++- 9 files changed, 197 insertions(+), 17 deletions(-) diff --git a/packages/nodes-base/nodes/Google/BigQuery/GoogleBigQuery.node.ts b/packages/nodes-base/nodes/Google/BigQuery/GoogleBigQuery.node.ts index 847c33a2ee..58034e0dc7 100644 --- a/packages/nodes-base/nodes/Google/BigQuery/GoogleBigQuery.node.ts +++ b/packages/nodes-base/nodes/Google/BigQuery/GoogleBigQuery.node.ts @@ -71,12 +71,12 @@ export class GoogleBigQuery implements INodeType { noDataExpression: true, options: [ { - name: 'Service Account', - value: 'serviceAccount', + name: 'OAuth2 (Recommended)', + value: 'oAuth2', }, { - name: 'OAuth2', - value: 'oAuth2', + name: 'Service Account', + value: 'serviceAccount', }, ], default: 'oAuth2', diff --git a/packages/nodes-base/nodes/Google/Books/GoogleBooks.node.ts b/packages/nodes-base/nodes/Google/Books/GoogleBooks.node.ts index 0c7353ec27..0fd41d4433 100644 --- a/packages/nodes-base/nodes/Google/Books/GoogleBooks.node.ts +++ b/packages/nodes-base/nodes/Google/Books/GoogleBooks.node.ts @@ -26,7 +26,7 @@ export class GoogleBooks implements INodeType { name: 'googleBooks', icon: 'file:googlebooks.svg', group: ['input', 'output'], - version: 1, + version: [1, 2], description: 'Read data from Google Books', subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', defaults: { @@ -74,6 +74,36 @@ export class GoogleBooks implements INodeType { }, ], default: 'serviceAccount', + displayOptions: { + show: { + '@version': [ + 1, + ], + } + }, + }, + { + displayName: 'Authentication', + name: 'authentication', + type: 'options', + options: [ + { + name: 'OAuth2 (Recommended)', + value: 'oAuth2', + }, + { + name: 'Service Account', + value: 'serviceAccount', + }, + ], + default: 'oAuth2', + displayOptions: { + show: { + '@version': [ + 2, + ], + } + }, }, { displayName: 'Resource', diff --git a/packages/nodes-base/nodes/Google/Docs/GoogleDocs.node.ts b/packages/nodes-base/nodes/Google/Docs/GoogleDocs.node.ts index 69a15f963f..557e5d97f5 100644 --- a/packages/nodes-base/nodes/Google/Docs/GoogleDocs.node.ts +++ b/packages/nodes-base/nodes/Google/Docs/GoogleDocs.node.ts @@ -36,7 +36,7 @@ export class GoogleDocs implements INodeType { name: 'googleDocs', icon: 'file:googleDocs.svg', group: ['input'], - version: 1, + version: [1, 2], subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', description: 'Consume Google Docs API.', defaults: { @@ -84,6 +84,36 @@ export class GoogleDocs implements INodeType { }, ], default: 'serviceAccount', + displayOptions: { + show: { + '@version': [ + 1, + ], + } + }, + }, + { + displayName: 'Authentication', + name: 'authentication', + type: 'options', + options: [ + { + name: 'OAuth2 (Recommended)', + value: 'oAuth2', + }, + { + name: 'Service Account', + value: 'serviceAccount', + }, + ], + default: 'oAuth2', + displayOptions: { + show: { + '@version': [ + 2, + ], + } + }, }, { displayName: 'Resource', diff --git a/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts b/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts index a98da36cf6..f4aa3cd90e 100644 --- a/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts +++ b/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts @@ -69,6 +69,36 @@ export class GoogleDrive implements INodeType { }, ], default: 'serviceAccount', + displayOptions: { + show: { + '@version': [ + 1, + ], + } + }, + }, + { + displayName: 'Authentication', + name: 'authentication', + type: 'options', + options: [ + { + name: 'OAuth2 (Recommended)', + value: 'oAuth2', + }, + { + name: 'Service Account', + value: 'serviceAccount', + }, + ], + default: 'oAuth2', + displayOptions: { + show: { + '@version': [ + 2, + ], + } + }, }, { displayName: 'Resource', diff --git a/packages/nodes-base/nodes/Google/Drive/GoogleDriveTrigger.node.ts b/packages/nodes-base/nodes/Google/Drive/GoogleDriveTrigger.node.ts index 342acabbc1..b1ce9a606d 100644 --- a/packages/nodes-base/nodes/Google/Drive/GoogleDriveTrigger.node.ts +++ b/packages/nodes-base/nodes/Google/Drive/GoogleDriveTrigger.node.ts @@ -66,12 +66,12 @@ export class GoogleDriveTrigger implements INodeType { type: 'options', options: [ { - name: 'Service Account', - value: 'serviceAccount', + name: 'OAuth2 (Recommended)', + value: 'oAuth2', }, { - name: 'OAuth2', - value: 'oAuth2', + name: 'Service Account', + value: 'serviceAccount', }, ], default: 'oAuth2', diff --git a/packages/nodes-base/nodes/Google/Gmail/Gmail.node.ts b/packages/nodes-base/nodes/Google/Gmail/Gmail.node.ts index 9bb2e36fc0..1d36209cfb 100644 --- a/packages/nodes-base/nodes/Google/Gmail/Gmail.node.ts +++ b/packages/nodes-base/nodes/Google/Gmail/Gmail.node.ts @@ -108,12 +108,12 @@ export class Gmail implements INodeType { type: 'options', options: [ { - name: 'Service Account', - value: 'serviceAccount', + name: 'OAuth2 (Recommended)', + value: 'oAuth2', }, { - name: 'OAuth2', - value: 'oAuth2', + name: 'Service Account', + value: 'serviceAccount', }, ], default: 'oAuth2', diff --git a/packages/nodes-base/nodes/Google/Sheet/GoogleSheets.node.ts b/packages/nodes-base/nodes/Google/Sheet/GoogleSheets.node.ts index c1ba0a9d31..4b85707167 100644 --- a/packages/nodes-base/nodes/Google/Sheet/GoogleSheets.node.ts +++ b/packages/nodes-base/nodes/Google/Sheet/GoogleSheets.node.ts @@ -38,7 +38,7 @@ export class GoogleSheets implements INodeType { name: 'googleSheets', icon: 'file:googleSheets.svg', group: ['input', 'output'], - version: 1, + version: [1, 2], subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', description: 'Read, update and write data to Google Sheets', defaults: { @@ -87,6 +87,36 @@ export class GoogleSheets implements INodeType { }, ], default: 'serviceAccount', + displayOptions: { + show: { + '@version': [ + 1, + ], + } + }, + }, + { + displayName: 'Authentication', + name: 'authentication', + type: 'options', + options: [ + { + name: 'OAuth2 (Recommended)', + value: 'oAuth2', + }, + { + name: 'Service Account', + value: 'serviceAccount', + }, + ], + default: 'oAuth2', + displayOptions: { + show: { + '@version': [ + 2, + ], + } + }, }, { displayName: 'Resource', diff --git a/packages/nodes-base/nodes/Google/Slides/GoogleSlides.node.ts b/packages/nodes-base/nodes/Google/Slides/GoogleSlides.node.ts index a4293e2a48..adcb10dd46 100644 --- a/packages/nodes-base/nodes/Google/Slides/GoogleSlides.node.ts +++ b/packages/nodes-base/nodes/Google/Slides/GoogleSlides.node.ts @@ -21,7 +21,7 @@ export class GoogleSlides implements INodeType { name: 'googleSlides', icon: 'file:googleslides.svg', group: ['input', 'output'], - version: 1, + version: [1, 2], subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', description: 'Consume the Google Slides API', defaults: { @@ -69,6 +69,36 @@ export class GoogleSlides implements INodeType { }, ], default: 'serviceAccount', + displayOptions: { + show: { + '@version': [ + 1, + ], + } + }, + }, + { + displayName: 'Authentication', + name: 'authentication', + type: 'options', + options: [ + { + name: 'OAuth2 (Recommended)', + value: 'oAuth2', + }, + { + name: 'Service Account', + value: 'serviceAccount', + }, + ], + default: 'oAuth2', + displayOptions: { + show: { + '@version': [ + 2, + ], + } + }, }, { displayName: 'Resource', diff --git a/packages/nodes-base/nodes/Google/Translate/GoogleTranslate.node.ts b/packages/nodes-base/nodes/Google/Translate/GoogleTranslate.node.ts index c53e27bec8..51e8edfa9d 100644 --- a/packages/nodes-base/nodes/Google/Translate/GoogleTranslate.node.ts +++ b/packages/nodes-base/nodes/Google/Translate/GoogleTranslate.node.ts @@ -27,7 +27,7 @@ export class GoogleTranslate implements INodeType { // eslint-disable-next-line n8n-nodes-base/node-class-description-icon-not-svg icon: 'file:googletranslate.png', group: ['input', 'output'], - version: 1, + version: [1, 2], description: 'Translate data using Google Translate', subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', defaults: { @@ -75,6 +75,36 @@ export class GoogleTranslate implements INodeType { }, ], default: 'serviceAccount', + displayOptions: { + show: { + '@version': [ + 1, + ], + } + }, + }, + { + displayName: 'Authentication', + name: 'authentication', + type: 'options', + options: [ + { + name: 'OAuth2 (Recommended)', + value: 'oAuth2', + }, + { + name: 'Service Account', + value: 'serviceAccount', + }, + ], + default: 'oAuth2', + displayOptions: { + show: { + '@version': [ + 2, + ], + } + }, }, { displayName: 'Resource',