n8n-3867-progressively-apply-prettier-to-all (#3873)

* 🔨 formatting nodes with prettier
This commit is contained in:
Michael Kret
2022-08-17 18:50:24 +03:00
committed by GitHub
parent f2d326c7f0
commit 91d7e16c81
1072 changed files with 42357 additions and 59109 deletions

View File

@@ -1,6 +1,4 @@
import {
IExecuteFunctions,
} from 'n8n-core';
import { IExecuteFunctions } from 'n8n-core';
import {
IDataObject,
@@ -11,9 +9,7 @@ import {
INodeTypeDescription,
} from 'n8n-workflow';
import {
googleApiRequest,
} from './GenericFunctions';
import { googleApiRequest } from './GenericFunctions';
export class GoogleSlides implements INodeType {
description: INodeTypeDescription = {
@@ -35,9 +31,7 @@ export class GoogleSlides implements INodeType {
required: true,
displayOptions: {
show: {
authentication: [
'serviceAccount',
],
authentication: ['serviceAccount'],
},
},
},
@@ -46,9 +40,7 @@ export class GoogleSlides implements INodeType {
required: true,
displayOptions: {
show: {
authentication: [
'oAuth2',
],
authentication: ['oAuth2'],
},
},
},
@@ -71,9 +63,7 @@ export class GoogleSlides implements INodeType {
default: 'serviceAccount',
displayOptions: {
show: {
'@version': [
1,
],
'@version': [1],
},
},
},
@@ -94,9 +84,7 @@ export class GoogleSlides implements INodeType {
default: 'oAuth2',
displayOptions: {
show: {
'@version': [
2,
],
'@version': [2],
},
},
},
@@ -150,9 +138,7 @@ export class GoogleSlides implements INodeType {
],
displayOptions: {
show: {
resource: [
'presentation',
],
resource: ['presentation'],
},
},
default: 'create',
@@ -178,9 +164,7 @@ export class GoogleSlides implements INodeType {
],
displayOptions: {
show: {
resource: [
'page',
],
resource: ['page'],
},
},
default: 'get',
@@ -194,35 +178,24 @@ export class GoogleSlides implements INodeType {
required: true,
displayOptions: {
show: {
resource: [
'presentation',
],
operation: [
'create',
],
resource: ['presentation'],
operation: ['create'],
},
},
},
{
displayName: 'Presentation ID',
name: 'presentationId',
description: 'ID of the presentation to retrieve. Found in the presentation URL: <code>https://docs.google.com/presentation/d/PRESENTATION_ID/edit</code>',
description:
'ID of the presentation to retrieve. Found in the presentation URL: <code>https://docs.google.com/presentation/d/PRESENTATION_ID/edit</code>',
placeholder: '1wZtNFZ8MO-WKrxhYrOLMvyiqSgFwdSz5vn8_l_7eNqw',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
resource: [
'presentation',
'page',
],
operation: [
'get',
'getThumbnail',
'getSlides',
'replaceText',
],
resource: ['presentation', 'page'],
operation: ['get', 'getThumbnail', 'getSlides', 'replaceText'],
},
},
},
@@ -232,12 +205,8 @@ export class GoogleSlides implements INodeType {
type: 'boolean',
displayOptions: {
show: {
operation: [
'getSlides',
],
resource: [
'presentation',
],
operation: ['getSlides'],
resource: ['presentation'],
},
},
default: false,
@@ -249,15 +218,9 @@ export class GoogleSlides implements INodeType {
type: 'number',
displayOptions: {
show: {
operation: [
'getSlides',
],
resource: [
'presentation',
],
returnAll: [
false,
],
operation: ['getSlides'],
resource: ['presentation'],
returnAll: [false],
},
},
typeOptions: {
@@ -276,13 +239,8 @@ export class GoogleSlides implements INodeType {
required: true,
displayOptions: {
show: {
resource: [
'page',
],
operation: [
'get',
'getThumbnail',
],
resource: ['page'],
operation: ['get', 'getThumbnail'],
},
},
},
@@ -296,12 +254,8 @@ export class GoogleSlides implements INodeType {
},
displayOptions: {
show: {
resource: [
'presentation',
],
operation: [
'replaceText',
],
resource: ['presentation'],
operation: ['replaceText'],
},
},
default: {},
@@ -315,7 +269,8 @@ export class GoogleSlides implements INodeType {
name: 'matchCase',
type: 'boolean',
default: false,
description: 'Whether the search should respect case. True : the search is case sensitive. False : the search is case insensitive.',
description:
'Whether the search should respect case. True : the search is case sensitive. False : the search is case insensitive.',
},
{
displayName: 'Page Names or IDs',
@@ -324,11 +279,10 @@ export class GoogleSlides implements INodeType {
default: [],
typeOptions: {
loadOptionsMethod: 'getPages',
loadOptionsDependsOn: [
'presentationId',
],
loadOptionsDependsOn: ['presentationId'],
},
description: 'If non-empty, limits the matches to page elements only on the given pages. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'If non-empty, limits the matches to page elements only on the given pages. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
{
displayName: 'Replace Text',
@@ -355,12 +309,8 @@ export class GoogleSlides implements INodeType {
placeholder: 'Add Option',
displayOptions: {
show: {
operation: [
'replaceText',
],
resource: [
'presentation',
],
operation: ['replaceText'],
resource: ['presentation'],
},
},
default: {},
@@ -370,7 +320,8 @@ export class GoogleSlides implements INodeType {
name: 'revisionId',
type: 'string',
default: '',
description: 'The revision ID of the presentation required for the write request. If specified and the requiredRevisionId doesn\'t exactly match the presentation\'s current revisionId, the request will not be processed and will return a 400 bad request error.',
description:
"The revision ID of the presentation required for the write request. If specified and the requiredRevisionId doesn't exactly match the presentation's current revisionId, the request will not be processed and will return a 400 bad request error.",
},
],
},
@@ -382,12 +333,8 @@ export class GoogleSlides implements INodeType {
default: false,
displayOptions: {
show: {
resource: [
'page',
],
operation: [
'getThumbnail',
],
resource: ['page'],
operation: ['getThumbnail'],
},
},
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
@@ -402,15 +349,9 @@ export class GoogleSlides implements INodeType {
description: 'Name of the binary property to which to write to',
displayOptions: {
show: {
resource: [
'page',
],
operation: [
'getThumbnail',
],
download: [
true,
],
resource: ['page'],
operation: ['getThumbnail'],
download: [true],
},
},
},
@@ -421,12 +362,16 @@ export class GoogleSlides implements INodeType {
loadOptions: {
// Get all the pages to display them to user so that he can
// select them easily
async getPages(
this: ILoadOptionsFunctions,
): Promise<INodePropertyOptions[]> {
async getPages(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const presentationId = this.getCurrentNodeParameter('presentationId') as string;
const { slides } = await googleApiRequest.call(this, 'GET', `/presentations/${presentationId}`, {}, { fields: 'slides' });
const { slides } = await googleApiRequest.call(
this,
'GET',
`/presentations/${presentationId}`,
{},
{ fields: 'slides' },
);
for (const slide of slides) {
returnData.push({
name: slide.objectId,
@@ -438,7 +383,6 @@ export class GoogleSlides implements INodeType {
},
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
@@ -449,35 +393,37 @@ export class GoogleSlides implements INodeType {
const returnData: INodeExecutionData[] = [];
for (let i = 0; i < items.length; i++) {
try {
if (resource === 'page') {
// *********************************************************************
// page
// *********************************************************************
if (operation === 'get') {
// ----------------------------------
// page: get
// ----------------------------------
const presentationId = this.getNodeParameter('presentationId', i) as string;
const pageObjectId = this.getNodeParameter('pageObjectId', i) as string;
responseData = await googleApiRequest.call(this, 'GET', `/presentations/${presentationId}/pages/${pageObjectId}`);
responseData = await googleApiRequest.call(
this,
'GET',
`/presentations/${presentationId}/pages/${pageObjectId}`,
);
returnData.push({ json: responseData });
} else if (operation === 'getThumbnail') {
// ----------------------------------
// page: getThumbnail
// ----------------------------------
const presentationId = this.getNodeParameter('presentationId', i) as string;
const pageObjectId = this.getNodeParameter('pageObjectId', i) as string;
responseData = await googleApiRequest.call(this, 'GET', `/presentations/${presentationId}/pages/${pageObjectId}/thumbnail`);
responseData = await googleApiRequest.call(
this,
'GET',
`/presentations/${presentationId}/pages/${pageObjectId}/thumbnail`,
);
const download = this.getNodeParameter('download', 0) as boolean;
if (download === true) {
@@ -502,15 +448,12 @@ export class GoogleSlides implements INodeType {
returnData.push({ json: responseData });
}
}
} else if (resource === 'presentation') {
// *********************************************************************
// presentation
// *********************************************************************
if (operation === 'create') {
// ----------------------------------
// presentation: create
// ----------------------------------
@@ -521,41 +464,45 @@ export class GoogleSlides implements INodeType {
responseData = await googleApiRequest.call(this, 'POST', '/presentations', body);
returnData.push({ json: responseData });
} else if (operation === 'get') {
// ----------------------------------
// presentation: get
// ----------------------------------
const presentationId = this.getNodeParameter('presentationId', i) as string;
responseData = await googleApiRequest.call(this, 'GET', `/presentations/${presentationId}`);
responseData = await googleApiRequest.call(
this,
'GET',
`/presentations/${presentationId}`,
);
returnData.push({ json: responseData });
} else if (operation === 'getSlides') {
// ----------------------------------
// presentation: getSlides
// ----------------------------------
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
const presentationId = this.getNodeParameter('presentationId', i) as string;
responseData = await googleApiRequest.call(this, 'GET', `/presentations/${presentationId}`, {}, { fields: 'slides' });
responseData = await googleApiRequest.call(
this,
'GET',
`/presentations/${presentationId}`,
{},
{ fields: 'slides' },
);
responseData = responseData.slides;
if (returnAll === false) {
const limit = this.getNodeParameter('limit', i) as number;
responseData = responseData.slice(0, limit);
}
returnData.push(...this.helpers.returnJsonArray(responseData));
} else if (operation === 'replaceText') {
// ----------------------------------
// presentation: replaceText
// ----------------------------------
const presentationId = this.getNodeParameter('presentationId', i) as string;
const texts = this.getNodeParameter('textUi.textValues', i, []) as IDataObject[];
const options = this.getNodeParameter('options', i) as IDataObject;
const requests = texts.map((text => {
const requests = texts.map((text) => {
return {
replaceAllText: {
replaceText: text.replaceText,
@@ -566,7 +513,7 @@ export class GoogleSlides implements INodeType {
},
},
};
}));
});
const body: IDataObject = {
requests,
@@ -578,15 +525,18 @@ export class GoogleSlides implements INodeType {
};
}
responseData = await googleApiRequest.call(this, 'POST', `/presentations/${presentationId}:batchUpdate`, { requests });
responseData = await googleApiRequest.call(
this,
'POST',
`/presentations/${presentationId}:batchUpdate`,
{ requests },
);
returnData.push({ json: responseData });
}
}
} catch (error) {
if (this.continueOnFail()) {
returnData.push({json:{ error: error.message }});
returnData.push({ json: { error: error.message } });
continue;
}
throw error;