mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
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:
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
OptionsWithUrl,
|
||||
} from 'request';
|
||||
import { OptionsWithUrl } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
@@ -9,9 +7,7 @@ import {
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject, NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, NodeApiError } from 'n8n-workflow';
|
||||
|
||||
interface IContact {
|
||||
tags: [];
|
||||
@@ -23,7 +19,6 @@ const fieldCache: {
|
||||
[key: string]: IDataObject[];
|
||||
} = {};
|
||||
|
||||
|
||||
export async function getFields(this: IExecuteFunctions, listId: string) {
|
||||
if (fieldCache[listId]) {
|
||||
return fieldCache[listId];
|
||||
@@ -32,15 +27,22 @@ export async function getFields(this: IExecuteFunctions, listId: string) {
|
||||
return fieldCache[listId];
|
||||
}
|
||||
|
||||
|
||||
export async function egoiApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, qs: IDataObject = {}, headers?: object): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
export async function egoiApiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
qs: IDataObject = {},
|
||||
headers?: object,
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const credentials = await this.getCredentials('egoiApi');
|
||||
|
||||
const options: OptionsWithUrl = {
|
||||
headers: {
|
||||
'accept': 'application/json',
|
||||
'Apikey': `${credentials.apiKey}`,
|
||||
accept: 'application/json',
|
||||
Apikey: `${credentials.apiKey}`,
|
||||
},
|
||||
method,
|
||||
qs,
|
||||
@@ -54,16 +56,22 @@ export async function egoiApiRequest(this: IHookFunctions | IExecuteFunctions |
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
return await this.helpers.request!(options);
|
||||
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function egoiApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
export async function egoiApiRequestAllItems(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
@@ -75,14 +83,11 @@ export async function egoiApiRequestAllItems(this: IExecuteFunctions | ILoadOpti
|
||||
responseData = await egoiApiRequest.call(this, method, endpoint, body, query);
|
||||
returnData.push.apply(returnData, responseData[propertyName]);
|
||||
query.offset += query.count;
|
||||
} while (
|
||||
responseData[propertyName] && responseData[propertyName].length !== 0
|
||||
);
|
||||
} while (responseData[propertyName] && responseData[propertyName].length !== 0);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
|
||||
export async function simplify(this: IExecuteFunctions, contacts: IContact[], listId: string) {
|
||||
let fields = await getFields.call(this, listId);
|
||||
|
||||
@@ -96,7 +101,8 @@ export async function simplify(this: IExecuteFunctions, contacts: IContact[], li
|
||||
|
||||
for (const contact of contacts) {
|
||||
const extras = contact.extra.reduce(
|
||||
(acumulator: IDataObject, currentValue: IDataObject): any => { // tslint:disable-line:no-any
|
||||
// tslint:disable-next-line:no-any
|
||||
(acumulator: IDataObject, currentValue: IDataObject): any => {
|
||||
const key = fieldsKeyValue[currentValue.field_id as string] as string;
|
||||
return { [key]: currentValue.value, ...acumulator };
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user