refactor: Format nodes-base package (A-F) (#3800)

* 🔨 prettier formated nodes - A

* 🔨 prettier formated nodes - B

*  prettier formated nodes - C

*  prettier formated nodes - D

*  prettier formated nodes - E-F

* 🎨 Adjust nodes-base formatting command (#3805)

* Format additional files in nodes A-F (#3811)

*  fixes

* 🎨 Add Mindee to ignored dirs

Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
Michael Kret
2022-08-01 23:47:55 +03:00
committed by GitHub
parent 2c17e6f3ca
commit 0ecbb4a19d
411 changed files with 12906 additions and 20148 deletions

View File

@@ -1,12 +1,6 @@
import {
OptionsWithUri,
} from 'request';
import { OptionsWithUri } from 'request';
import {
IExecuteFunctions,
IHookFunctions,
ILoadOptionsFunctions,
} from 'n8n-core';
import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core';
import {
ICredentialDataDecryptedObject,
@@ -16,15 +10,21 @@ import {
NodeApiError,
} from 'n8n-workflow';
import {
upperFirst,
} from 'lodash';
import { upperFirst } from 'lodash';
import {
createHash,
} from 'crypto';
import { createHash } from 'crypto';
export async function webexApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
export async function webexApiRequest(
this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions,
method: string,
resource: string,
// tslint:disable-next-line:no-any
body: any = {},
qs: IDataObject = {},
uri?: string,
option: IDataObject = {},
// tslint:disable-next-line:no-any
): Promise<any> {
let options: OptionsWithUri = {
method,
body,
@@ -43,21 +43,35 @@ export async function webexApiRequest(this: IExecuteFunctions | ILoadOptionsFunc
delete options.qs;
}
//@ts-ignore
return await this.helpers.requestOAuth2.call(this, 'ciscoWebexOAuth2Api', options, { tokenType: 'Bearer' });
return await this.helpers.requestOAuth2.call(this, 'ciscoWebexOAuth2Api', options, {
tokenType: 'Bearer',
});
} catch (error) {
throw new NodeApiError(this.getNode(), error);
}
}
export async function webexApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, options: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
export async function webexApiRequestAllItems(
this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions,
propertyName: string,
method: string,
endpoint: string,
// tslint:disable-next-line:no-any
body: any = {},
query: IDataObject = {},
options: IDataObject = {},
// tslint:disable-next-line:no-any
): Promise<any> {
const returnData: IDataObject[] = [];
let responseData;
let uri: string | undefined;
query.max = 100;
do {
responseData = await webexApiRequest.call(this, method, endpoint, body, query, uri, { resolveWithFullResponse: true, ...options });
responseData = await webexApiRequest.call(this, method, endpoint, body, query, uri, {
resolveWithFullResponse: true,
...options,
});
if (responseData.headers.link) {
uri = responseData.headers['link'].split(';')[0].replace('<', '').replace('>', '');
}
@@ -71,13 +85,13 @@ export async function webexApiRequestAllItems(this: IExecuteFunctions | ILoadOpt
export function getEvents() {
const resourceEvents: { [key: string]: string[] } = {
'attachmentAction': ['created', 'deleted', 'updated', '*'],
'membership': ['created', 'deleted', 'updated', '*'],
'message': ['created', 'deleted', 'updated', '*'],
'room': ['created', 'deleted', 'updated', '*'],
'meeting': ['created', 'deleted', 'updated', 'started', 'ended', '*'],
'recording': ['created', 'deleted', 'updated', '*'],
'telephonyCall': ['created', 'deleted', 'updated'],
attachmentAction: ['created', 'deleted', 'updated', '*'],
membership: ['created', 'deleted', 'updated', '*'],
message: ['created', 'deleted', 'updated', '*'],
room: ['created', 'deleted', 'updated', '*'],
meeting: ['created', 'deleted', 'updated', 'started', 'ended', '*'],
recording: ['created', 'deleted', 'updated', '*'],
telephonyCall: ['created', 'deleted', 'updated'],
'*': ['created', 'updated', 'deleted', '*'],
};
@@ -90,12 +104,13 @@ export function getEvents() {
type: 'options',
displayOptions: {
show: {
resource: [
(resource === '*') ? 'all' : resource,
],
resource: [resource === '*' ? 'all' : resource],
},
},
options: resourceEvents[resource].map((event) => ({ value: (event === '*' ? 'all' : event), name: upperFirst(event) })),
options: resourceEvents[resource].map((event) => ({
value: event === '*' ? 'all' : event,
name: upperFirst(event),
})),
default: '',
required: true,
});
@@ -104,16 +119,18 @@ export function getEvents() {
}
export function mapResource(event: string) {
return ({
'attachmentAction': 'attachmentActions',
'membership': 'memberships',
'message': 'messages',
'room': 'rooms',
'meeting': 'meetings',
'recording': 'recordings',
'telephonyCall': 'telephony_calls',
'all': 'all',
} as { [key: string]: string })[event];
return (
{
attachmentAction: 'attachmentActions',
membership: 'memberships',
message: 'messages',
room: 'rooms',
meeting: 'meetings',
recording: 'recordings',
telephonyCall: 'telephony_calls',
all: 'all',
} as { [key: string]: string }
)[event];
}
export function getAttachemnts(attachements: IDataObject[]) {
@@ -121,18 +138,23 @@ export function getAttachemnts(attachements: IDataObject[]) {
for (const attachment of attachements) {
const body: IDataObject[] = [];
const actions: IDataObject[] = [];
for (const element of (attachment?.elementsUi as IDataObject).elementValues as IDataObject[] || []) {
for (const element of ((attachment?.elementsUi as IDataObject)
.elementValues as IDataObject[]) || []) {
// tslint:disable-next-line: no-any
const { type, ...rest } = element as { type: string, [key: string]: any };
const { type, ...rest } = element as { type: string; [key: string]: any };
if (type.startsWith('input')) {
body.push({ type: `Input.${upperFirst(type.replace('input', ''))}`, ...removeEmptyProperties(rest) });
body.push({
type: `Input.${upperFirst(type.replace('input', ''))}`,
...removeEmptyProperties(rest),
});
} else {
body.push({ type: upperFirst(type), ...removeEmptyProperties(rest) });
}
}
for (const action of (attachment?.actionsUi as IDataObject).actionValues as IDataObject[] || []) {
for (const action of ((attachment?.actionsUi as IDataObject).actionValues as IDataObject[]) ||
[]) {
// tslint:disable-next-line: no-any
const { type, ...rest } = action as { type: string, [key: string]: any };
const { type, ...rest } = action as { type: string; [key: string]: any };
actions.push({ type: `Action.${upperFirst(type)}`, ...removeEmptyProperties(rest) });
}
_attachments.push({
@@ -164,7 +186,8 @@ export function getActionInheritedProperties(): INodeProperties[] {
name: 'iconUrl',
type: 'string',
default: '',
description: 'Optional icon to be shown on the action in conjunction with the title. Supports data URI in version 1.2+.',
description:
'Optional icon to be shown on the action in conjunction with the title. Supports data URI in version 1.2+.',
},
{
displayName: 'Style',
@@ -185,7 +208,8 @@ export function getActionInheritedProperties(): INodeProperties[] {
},
],
default: 'default',
description: 'Controls the style of an Action, which influences how the action is displayed, spoken, etc',
description:
'Controls the style of an Action, which influences how the action is displayed, spoken, etc',
},
];
}
@@ -199,13 +223,12 @@ export function getTextBlockProperties(): INodeProperties[] {
default: '',
displayOptions: {
show: {
type: [
'textBlock',
],
type: ['textBlock'],
},
},
required: true,
description: 'Text to display. A subset of markdown is supported (https://aka.ms/ACTextFeatures).',
description:
'Text to display. A subset of markdown is supported (https://aka.ms/ACTextFeatures).',
},
{
displayName: 'Color',
@@ -213,9 +236,7 @@ export function getTextBlockProperties(): INodeProperties[] {
type: 'options',
displayOptions: {
show: {
type: [
'textBlock',
],
type: ['textBlock'],
},
},
options: [
@@ -257,9 +278,7 @@ export function getTextBlockProperties(): INodeProperties[] {
type: 'options',
displayOptions: {
show: {
type: [
'textBlock',
],
type: ['textBlock'],
},
},
options: [
@@ -281,9 +300,7 @@ export function getTextBlockProperties(): INodeProperties[] {
type: 'options',
displayOptions: {
show: {
type: [
'textBlock',
],
type: ['textBlock'],
},
},
options: [
@@ -309,9 +326,7 @@ export function getTextBlockProperties(): INodeProperties[] {
type: 'boolean',
displayOptions: {
show: {
type: [
'textBlock',
],
type: ['textBlock'],
},
},
default: false,
@@ -323,9 +338,7 @@ export function getTextBlockProperties(): INodeProperties[] {
type: 'number',
displayOptions: {
show: {
type: [
'textBlock',
],
type: ['textBlock'],
},
},
default: 1,
@@ -337,9 +350,7 @@ export function getTextBlockProperties(): INodeProperties[] {
type: 'options',
displayOptions: {
show: {
type: [
'textBlock',
],
type: ['textBlock'],
},
},
options: [
@@ -373,9 +384,7 @@ export function getTextBlockProperties(): INodeProperties[] {
type: 'options',
displayOptions: {
show: {
type: [
'textBlock',
],
type: ['textBlock'],
},
},
options: [
@@ -401,9 +410,7 @@ export function getTextBlockProperties(): INodeProperties[] {
type: 'boolean',
displayOptions: {
show: {
type: [
'textBlock',
],
type: ['textBlock'],
},
},
default: true,
@@ -415,9 +422,7 @@ export function getTextBlockProperties(): INodeProperties[] {
type: 'options',
displayOptions: {
show: {
type: [
'textBlock',
],
type: ['textBlock'],
},
},
options: [
@@ -440,9 +445,7 @@ export function getTextBlockProperties(): INodeProperties[] {
default: false,
displayOptions: {
show: {
type: [
'textBlock',
],
type: ['textBlock'],
},
},
description: 'Whether to draw a separating line at the top of the element',
@@ -453,9 +456,7 @@ export function getTextBlockProperties(): INodeProperties[] {
type: 'options',
displayOptions: {
show: {
type: [
'textBlock',
],
type: ['textBlock'],
},
},
options: [
@@ -497,9 +498,7 @@ export function getTextBlockProperties(): INodeProperties[] {
type: 'string',
displayOptions: {
show: {
type: [
'textBlock',
],
type: ['textBlock'],
},
},
default: '',
@@ -511,9 +510,7 @@ export function getTextBlockProperties(): INodeProperties[] {
type: 'boolean',
displayOptions: {
show: {
type: [
'textBlock',
],
type: ['textBlock'],
},
},
default: true,
@@ -531,13 +528,12 @@ export function getInputTextProperties(): INodeProperties[] {
required: true,
displayOptions: {
show: {
type: [
'inputText',
],
type: ['inputText'],
},
},
default: '',
description: 'Unique identifier for the value. Used to identify collected input when the Submit action is performed.',
description:
'Unique identifier for the value. Used to identify collected input when the Submit action is performed.',
},
{
displayName: 'Is Multiline',
@@ -545,9 +541,7 @@ export function getInputTextProperties(): INodeProperties[] {
type: 'boolean',
displayOptions: {
show: {
type: [
'inputText',
],
type: ['inputText'],
},
},
default: false,
@@ -559,9 +553,7 @@ export function getInputTextProperties(): INodeProperties[] {
type: 'number',
displayOptions: {
show: {
type: [
'inputText',
],
type: ['inputText'],
},
},
default: 1,
@@ -573,9 +565,7 @@ export function getInputTextProperties(): INodeProperties[] {
type: 'string',
displayOptions: {
show: {
type: [
'inputText',
],
type: ['inputText'],
},
},
default: '',
@@ -587,9 +577,7 @@ export function getInputTextProperties(): INodeProperties[] {
type: 'string',
displayOptions: {
show: {
type: [
'inputText',
],
type: ['inputText'],
},
},
default: '',
@@ -601,9 +589,7 @@ export function getInputTextProperties(): INodeProperties[] {
type: 'options',
displayOptions: {
show: {
type: [
'inputText',
],
type: ['inputText'],
},
},
options: [
@@ -633,9 +619,7 @@ export function getInputTextProperties(): INodeProperties[] {
type: 'string',
displayOptions: {
show: {
type: [
'inputText',
],
type: ['inputText'],
},
},
default: '',