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 {
OptionsWithUri,
} from 'request';
import { OptionsWithUri } from 'request';
import {
IExecuteFunctions,
@@ -9,12 +7,19 @@ import {
IWebhookFunctions,
} from 'n8n-core';
import {
IDataObject, NodeApiError,
} from 'n8n-workflow';
export async function strapiApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
import { IDataObject, NodeApiError } from 'n8n-workflow';
export async function strapiApiRequest(
this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions,
method: string,
resource: string,
// tslint:disable-next-line:no-any
body: any = {},
qs: IDataObject = {},
uri?: string,
headers: IDataObject = {},
// tslint:disable-next-line:no-any
): Promise<any> {
const credentials = await this.getCredentials('strapiApi');
try {
@@ -23,7 +28,10 @@ export async function strapiApiRequest(this: IExecuteFunctions | ILoadOptionsFun
method,
body,
qs,
uri: uri || credentials.apiVersion === 'v4' ? `${credentials.url}/api${resource}` : `${credentials.url}${resource}`,
uri:
uri || credentials.apiVersion === 'v4'
? `${credentials.url}/api${resource}`
: `${credentials.url}${resource}`,
json: true,
qsStringifyOptions: {
arrayFormat: 'indice',
@@ -43,56 +51,82 @@ export async function strapiApiRequest(this: IExecuteFunctions | ILoadOptionsFun
}
}
export async function getToken(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions): Promise<any> { // tslint:disable-line:no-any
export async function getToken(
this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions,
// tslint:disable-next-line:no-any
): Promise<any> {
const credentials = await this.getCredentials('strapiApi');
let options = {} as OptionsWithUri;
options = {
headers: {
'content-type': 'application/json',
},
method: 'POST',
body: {
identifier: credentials.email,
password: credentials.password,
},
uri: credentials.apiVersion === 'v4' ? `${credentials.url}/api/auth/local`:`${credentials.url}/auth/local`,
json: true,
};
options = {
headers: {
'content-type': 'application/json',
},
method: 'POST',
body: {
identifier: credentials.email,
password: credentials.password,
},
uri:
credentials.apiVersion === 'v4'
? `${credentials.url}/api/auth/local`
: `${credentials.url}/auth/local`,
json: true,
};
return this.helpers.request!(options);
}
export async function strapiApiRequestAllItems(this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, headers: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
export async function strapiApiRequestAllItems(
this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions,
method: string,
resource: string,
// tslint:disable-next-line:no-any
body: any = {},
query: IDataObject = {},
headers: IDataObject = {},
// tslint:disable-next-line:no-any
): Promise<any> {
const returnData: IDataObject[] = [];
const {apiVersion} = await this.getCredentials('strapiApi');
const { apiVersion } = await this.getCredentials('strapiApi');
let responseData;
if (apiVersion === 'v4') {
query['pagination[pageSize]'] = 20;
query['pagination[page]'] = 0;
do {
({data:responseData} = await strapiApiRequest.call(this, method, resource, body, query, undefined, headers));
({ data: responseData } = await strapiApiRequest.call(
this,
method,
resource,
body,
query,
undefined,
headers,
));
query['pagination[page]'] += query['pagination[pageSize]'];
returnData.push.apply(returnData, responseData);
} while (
responseData.length !== 0
);
} while (responseData.length !== 0);
} else {
query._limit = 20;
query._start = 0;
do {
responseData = await strapiApiRequest.call(this, method, resource, body, query, undefined, headers);
responseData = await strapiApiRequest.call(
this,
method,
resource,
body,
query,
undefined,
headers,
);
query._start += query._limit;
returnData.push.apply(returnData, responseData);
} while (
responseData.length !== 0
);
} while (responseData.length !== 0);
}
return returnData;
}
export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any
// tslint:disable-next-line:no-any
export function validateJSON(json: string | undefined): any {
let result;
try {
result = JSON.parse(json!);