mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor: Consolidate redundant code in workflow execution-functions (no-changelog) (#4884)
* refactor: Consolidate redundant code in workflow interfaces (no-changelog) * consolidate all execution-functions interfaces code * move rawBody definition back * address PR comments
This commit is contained in:
committed by
GitHub
parent
2b1eb94906
commit
5cf70e1007
@@ -1,293 +1,41 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
import {
|
import {
|
||||||
IAdditionalCredentialOptions,
|
IPollResponse,
|
||||||
IAllExecuteFunctions,
|
ITriggerResponse,
|
||||||
IBinaryData,
|
IWorkflowSettings as IWorkflowSettingsWorkflow,
|
||||||
ICredentialTestFunctions as ICredentialTestFunctionsBase,
|
|
||||||
IDataObject,
|
|
||||||
IExecuteFunctions as IExecuteFunctionsBase,
|
IExecuteFunctions as IExecuteFunctionsBase,
|
||||||
IExecuteSingleFunctions as IExecuteSingleFunctionsBase,
|
IExecuteSingleFunctions as IExecuteSingleFunctionsBase,
|
||||||
IHookFunctions as IHookFunctionsBase,
|
IHookFunctions as IHookFunctionsBase,
|
||||||
IHttpRequestOptions,
|
|
||||||
ILoadOptionsFunctions as ILoadOptionsFunctionsBase,
|
ILoadOptionsFunctions as ILoadOptionsFunctionsBase,
|
||||||
INodeExecutionData,
|
|
||||||
IOAuth2Options,
|
|
||||||
IPairedItemData,
|
|
||||||
IPollFunctions as IPollFunctionsBase,
|
IPollFunctions as IPollFunctionsBase,
|
||||||
IPollResponse,
|
|
||||||
ITriggerFunctions as ITriggerFunctionsBase,
|
ITriggerFunctions as ITriggerFunctionsBase,
|
||||||
ITriggerResponse,
|
|
||||||
IWebhookFunctions as IWebhookFunctionsBase,
|
IWebhookFunctions as IWebhookFunctionsBase,
|
||||||
IWorkflowSettings as IWorkflowSettingsWorkflow,
|
|
||||||
NodeExecutionWithMetadata,
|
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
import type { OptionsWithUri, OptionsWithUrl } from 'request';
|
// TODO: remove these after removing `n8n-core` dependency from `nodes-bases`
|
||||||
import type { RequestPromiseAPI, RequestPromiseOptions } from 'request-promise-native';
|
export type IExecuteFunctions = IExecuteFunctionsBase;
|
||||||
|
export type IExecuteSingleFunctions = IExecuteSingleFunctionsBase;
|
||||||
|
export type IHookFunctions = IHookFunctionsBase;
|
||||||
|
export type ILoadOptionsFunctions = ILoadOptionsFunctionsBase;
|
||||||
|
export type IPollFunctions = IPollFunctionsBase;
|
||||||
|
export type ITriggerFunctions = ITriggerFunctionsBase;
|
||||||
|
export type IWebhookFunctions = IWebhookFunctionsBase;
|
||||||
|
|
||||||
export interface IProcessMessage {
|
export interface IProcessMessage {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
data?: any;
|
data?: any;
|
||||||
type: string;
|
type: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IExecuteFunctions extends IExecuteFunctionsBase {
|
|
||||||
helpers: {
|
|
||||||
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>;
|
|
||||||
prepareBinaryData(
|
|
||||||
binaryData: Buffer,
|
|
||||||
filePath?: string,
|
|
||||||
mimeType?: string,
|
|
||||||
): Promise<IBinaryData>;
|
|
||||||
getBinaryDataBuffer(itemIndex: number, propertyName: string): Promise<Buffer>;
|
|
||||||
setBinaryDataBuffer(data: IBinaryData, binaryData: Buffer): Promise<IBinaryData>;
|
|
||||||
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>;
|
|
||||||
requestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUri | RequestPromiseOptions,
|
|
||||||
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
requestOAuth2(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUri | RequestPromiseOptions,
|
|
||||||
oAuth2Options?: IOAuth2Options,
|
|
||||||
): Promise<any>;
|
|
||||||
requestOAuth1(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUrl | RequestPromiseOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExecutionData[];
|
|
||||||
normalizeItems(items: INodeExecutionData | INodeExecutionData[]): INodeExecutionData[];
|
|
||||||
httpRequestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
constructExecutionMetaData(
|
|
||||||
inputData: INodeExecutionData[],
|
|
||||||
options: { itemData: IPairedItemData | IPairedItemData[] },
|
|
||||||
): NodeExecutionWithMetadata[];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IExecuteSingleFunctions extends IExecuteSingleFunctionsBase {
|
|
||||||
helpers: {
|
|
||||||
getBinaryDataBuffer(propertyName: string, inputIndex?: number): Promise<Buffer>;
|
|
||||||
setBinaryDataBuffer(data: IBinaryData, binaryData: Buffer): Promise<IBinaryData>;
|
|
||||||
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>;
|
|
||||||
prepareBinaryData(
|
|
||||||
binaryData: Buffer,
|
|
||||||
filePath?: string,
|
|
||||||
mimeType?: string,
|
|
||||||
): Promise<IBinaryData>;
|
|
||||||
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>;
|
|
||||||
requestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUri | RequestPromiseOptions,
|
|
||||||
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
requestOAuth2(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUri | RequestPromiseOptions,
|
|
||||||
oAuth2Options?: IOAuth2Options,
|
|
||||||
): Promise<any>;
|
|
||||||
requestOAuth1(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUrl | RequestPromiseOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
httpRequestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IPollFunctions extends IPollFunctionsBase {
|
|
||||||
helpers: {
|
|
||||||
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>;
|
|
||||||
prepareBinaryData(
|
|
||||||
binaryData: Buffer,
|
|
||||||
filePath?: string,
|
|
||||||
mimeType?: string,
|
|
||||||
): Promise<IBinaryData>;
|
|
||||||
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>;
|
|
||||||
requestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUri | RequestPromiseOptions,
|
|
||||||
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
requestOAuth2(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUri | RequestPromiseOptions,
|
|
||||||
oAuth2Options?: IOAuth2Options,
|
|
||||||
): Promise<any>;
|
|
||||||
requestOAuth1(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUrl | RequestPromiseOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExecutionData[];
|
|
||||||
httpRequestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IResponseError extends Error {
|
export interface IResponseError extends Error {
|
||||||
statusCode?: number;
|
statusCode?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITriggerFunctions extends ITriggerFunctionsBase {
|
|
||||||
helpers: {
|
|
||||||
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>;
|
|
||||||
prepareBinaryData(
|
|
||||||
binaryData: Buffer,
|
|
||||||
filePath?: string,
|
|
||||||
mimeType?: string,
|
|
||||||
): Promise<IBinaryData>;
|
|
||||||
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>;
|
|
||||||
requestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUri | RequestPromiseOptions,
|
|
||||||
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
requestOAuth2(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUri | RequestPromiseOptions,
|
|
||||||
oAuth2Options?: IOAuth2Options,
|
|
||||||
): Promise<any>;
|
|
||||||
requestOAuth1(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUrl | RequestPromiseOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExecutionData[];
|
|
||||||
httpRequestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IUserSettings {
|
export interface IUserSettings {
|
||||||
encryptionKey?: string;
|
encryptionKey?: string;
|
||||||
tunnelSubdomain?: string;
|
tunnelSubdomain?: string;
|
||||||
instanceId?: string;
|
instanceId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ILoadOptionsFunctions extends ILoadOptionsFunctionsBase {
|
|
||||||
helpers: {
|
|
||||||
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>;
|
|
||||||
request?: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>;
|
|
||||||
requestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUri | RequestPromiseOptions,
|
|
||||||
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
requestOAuth2?: (
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUri | RequestPromiseOptions,
|
|
||||||
oAuth2Options?: IOAuth2Options,
|
|
||||||
) => Promise<any>;
|
|
||||||
requestOAuth1?(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUrl | RequestPromiseOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
httpRequestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ICredentialTestFunctions extends ICredentialTestFunctionsBase {
|
|
||||||
helpers: {
|
|
||||||
request: RequestPromiseAPI;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IHookFunctions extends IHookFunctionsBase {
|
|
||||||
helpers: {
|
|
||||||
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>;
|
|
||||||
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>;
|
|
||||||
requestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUri | RequestPromiseOptions,
|
|
||||||
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
requestOAuth2(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUri | RequestPromiseOptions,
|
|
||||||
oAuth2Options?: IOAuth2Options,
|
|
||||||
): Promise<any>;
|
|
||||||
requestOAuth1(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUrl | RequestPromiseOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
httpRequestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IWebhookFunctions extends IWebhookFunctionsBase {
|
|
||||||
helpers: {
|
|
||||||
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>;
|
|
||||||
prepareBinaryData(
|
|
||||||
binaryData: Buffer,
|
|
||||||
filePath?: string,
|
|
||||||
mimeType?: string,
|
|
||||||
): Promise<IBinaryData>;
|
|
||||||
copyBinaryFile(filePath: string, fileName: string, mimeType?: string): Promise<IBinaryData>;
|
|
||||||
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>;
|
|
||||||
requestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUri | RequestPromiseOptions,
|
|
||||||
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
requestOAuth2(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUri | RequestPromiseOptions,
|
|
||||||
oAuth2Options?: IOAuth2Options,
|
|
||||||
): Promise<any>;
|
|
||||||
requestOAuth1(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: OptionsWithUrl | RequestPromiseOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExecutionData[];
|
|
||||||
httpRequestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IWorkflowSettings extends IWorkflowSettingsWorkflow {
|
export interface IWorkflowSettings extends IWorkflowSettingsWorkflow {
|
||||||
errorWorkflow?: string;
|
errorWorkflow?: string;
|
||||||
timezone?: string;
|
timezone?: string;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -154,7 +154,6 @@ export class AwsSnsTrigger implements INodeType {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
//@ts-expect-error because of webhook
|
|
||||||
webhookMethods = {
|
webhookMethods = {
|
||||||
default: {
|
default: {
|
||||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ export const questionsOperations: INodeProperties[] = [
|
|||||||
items[i].binary!.data = await this.helpers.prepareBinaryData(
|
items[i].binary!.data = await this.helpers.prepareBinaryData(
|
||||||
response.body as Buffer,
|
response.body as Buffer,
|
||||||
'data',
|
'data',
|
||||||
response.headers['content-type'],
|
response.headers['content-type'] as string,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
result.push(items[i]);
|
result.push(items[i]);
|
||||||
|
|||||||
@@ -78,9 +78,9 @@ export namespace SendInBlueNode {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bufferFromIncomingData = (await this.helpers.getBinaryDataBuffer(
|
const bufferFromIncomingData = await this.helpers.getBinaryDataBuffer(
|
||||||
binaryPropertyAttachmentName,
|
binaryPropertyAttachmentName,
|
||||||
)) as Buffer;
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: content,
|
data: content,
|
||||||
@@ -93,8 +93,8 @@ export namespace SendInBlueNode {
|
|||||||
const name = getFileName(
|
const name = getFileName(
|
||||||
itemIndex,
|
itemIndex,
|
||||||
mimeType,
|
mimeType,
|
||||||
fileExtension,
|
fileExtension!,
|
||||||
fileName || item.binary!.data.fileName,
|
fileName || item.binary!.data.fileName!,
|
||||||
);
|
);
|
||||||
|
|
||||||
attachment.push({ content, name });
|
attachment.push({ content, name });
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export async function splunkApiRequest(
|
|||||||
endpoint: string,
|
endpoint: string,
|
||||||
body: IDataObject = {},
|
body: IDataObject = {},
|
||||||
qs: IDataObject = {},
|
qs: IDataObject = {},
|
||||||
) {
|
): Promise<any> {
|
||||||
const { authToken, baseUrl, allowUnauthorizedCerts } = (await this.getCredentials(
|
const { authToken, baseUrl, allowUnauthorizedCerts } = (await this.getCredentials(
|
||||||
'splunkApi',
|
'splunkApi',
|
||||||
)) as SplunkCredentials;
|
)) as SplunkCredentials;
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import type * as express from 'express';
|
|||||||
import type * as FormData from 'form-data';
|
import type * as FormData from 'form-data';
|
||||||
import type { IncomingHttpHeaders } from 'http';
|
import type { IncomingHttpHeaders } from 'http';
|
||||||
import type { URLSearchParams } from 'url';
|
import type { URLSearchParams } from 'url';
|
||||||
|
import type { OptionsWithUri, OptionsWithUrl } from 'request';
|
||||||
|
import type { RequestPromiseOptions, RequestPromiseAPI } from 'request-promise-native';
|
||||||
|
|
||||||
import type { IDeferredPromise } from './DeferredPromise';
|
import type { IDeferredPromise } from './DeferredPromise';
|
||||||
import type { Workflow } from './Workflow';
|
import type { Workflow } from './Workflow';
|
||||||
import type { WorkflowHooks } from './WorkflowHooks';
|
import type { WorkflowHooks } from './WorkflowHooks';
|
||||||
@@ -609,87 +612,6 @@ namespace ExecuteFunctions {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export type IExecuteFunctions = ExecuteFunctions.GetNodeParameterFn & {
|
|
||||||
continueOnFail(): boolean;
|
|
||||||
evaluateExpression(expression: string, itemIndex: number): NodeParameterValueType;
|
|
||||||
executeWorkflow(
|
|
||||||
workflowInfo: IExecuteWorkflowInfo,
|
|
||||||
inputData?: INodeExecutionData[],
|
|
||||||
): Promise<any>;
|
|
||||||
getContext(type: string): IContextObject;
|
|
||||||
getCredentials(type: string, itemIndex?: number): Promise<ICredentialDataDecryptedObject>;
|
|
||||||
getInputData(inputIndex?: number, inputName?: string): INodeExecutionData[];
|
|
||||||
getInputSourceData(inputIndex?: number, inputName?: string): ISourceData;
|
|
||||||
getMode(): WorkflowExecuteMode;
|
|
||||||
getNode(): INode;
|
|
||||||
getWorkflowDataProxy(itemIndex: number): IWorkflowDataProxyData;
|
|
||||||
getWorkflowStaticData(type: string): IDataObject;
|
|
||||||
getRestApiUrl(): string;
|
|
||||||
getTimezone(): string;
|
|
||||||
getExecuteData(): IExecuteData;
|
|
||||||
getWorkflow(): IWorkflowMetadata;
|
|
||||||
prepareOutputData(
|
|
||||||
outputData: INodeExecutionData[],
|
|
||||||
outputIndex?: number,
|
|
||||||
): Promise<INodeExecutionData[][]>;
|
|
||||||
putExecutionToWait(waitTill: Date): Promise<void>;
|
|
||||||
sendMessageToUI(message: any): void;
|
|
||||||
sendResponse(response: IExecuteResponsePromiseData): void;
|
|
||||||
helpers: {
|
|
||||||
httpRequest(
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
|
|
||||||
httpRequestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
||||||
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
|
|
||||||
[key: string]: (...args: any[]) => any;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface IExecuteSingleFunctions {
|
|
||||||
continueOnFail(): boolean;
|
|
||||||
evaluateExpression(expression: string, itemIndex: number | undefined): NodeParameterValueType;
|
|
||||||
getContext(type: string): IContextObject;
|
|
||||||
getCredentials(type: string): Promise<ICredentialDataDecryptedObject>;
|
|
||||||
getInputData(inputIndex?: number, inputName?: string): INodeExecutionData;
|
|
||||||
getInputSourceData(inputIndex?: number, inputName?: string): ISourceData;
|
|
||||||
getItemIndex(): number;
|
|
||||||
getMode(): WorkflowExecuteMode;
|
|
||||||
getNode(): INode;
|
|
||||||
getNodeParameter(
|
|
||||||
parameterName: string,
|
|
||||||
fallbackValue?: any,
|
|
||||||
options?: IGetNodeParameterOptions,
|
|
||||||
): NodeParameterValueType | object;
|
|
||||||
getRestApiUrl(): string;
|
|
||||||
getTimezone(): string;
|
|
||||||
getExecuteData(): IExecuteData;
|
|
||||||
getWorkflow(): IWorkflowMetadata;
|
|
||||||
getWorkflowDataProxy(): IWorkflowDataProxyData;
|
|
||||||
getWorkflowStaticData(type: string): IDataObject;
|
|
||||||
helpers: {
|
|
||||||
httpRequest(
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
|
|
||||||
httpRequestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
||||||
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
|
|
||||||
[key: string]: (...args: any[]) => any;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IExecutePaginationFunctions extends IExecuteSingleFunctions {
|
|
||||||
makeRoutingRequest(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
requestOptions: DeclarativeRestApiSettings.ResultOptions,
|
|
||||||
): Promise<INodeExecutionData[]>;
|
|
||||||
}
|
|
||||||
export interface IExecuteWorkflowInfo {
|
export interface IExecuteWorkflowInfo {
|
||||||
code?: IWorkflowBase;
|
code?: IWorkflowBase;
|
||||||
id?: string;
|
id?: string;
|
||||||
@@ -702,13 +624,126 @@ export type ICredentialTestFunction = (
|
|||||||
|
|
||||||
export interface ICredentialTestFunctions {
|
export interface ICredentialTestFunctions {
|
||||||
helpers: {
|
helpers: {
|
||||||
[key: string]: (...args: any[]) => any;
|
request: RequestPromiseAPI;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ILoadOptionsFunctions {
|
export interface JsonHelperFunctions {
|
||||||
getCredentials(type: string): Promise<ICredentialDataDecryptedObject>;
|
returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExecutionData[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BinaryHelperFunctions {
|
||||||
|
prepareBinaryData(binaryData: Buffer, filePath?: string, mimeType?: string): Promise<IBinaryData>;
|
||||||
|
setBinaryDataBuffer(data: IBinaryData, binaryData: Buffer): Promise<IBinaryData>;
|
||||||
|
copyBinaryFile(filePath: string, fileName: string, mimeType?: string): Promise<IBinaryData>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RequestHelperFunctions {
|
||||||
|
request(uriOrObject: string | IDataObject | any, options?: IDataObject): Promise<any>;
|
||||||
|
requestWithAuthentication(
|
||||||
|
this: IAllExecuteFunctions,
|
||||||
|
credentialsType: string,
|
||||||
|
requestOptions: OptionsWithUri | RequestPromiseOptions,
|
||||||
|
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
||||||
|
): Promise<any>;
|
||||||
|
|
||||||
|
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>;
|
||||||
|
httpRequestWithAuthentication(
|
||||||
|
this: IAllExecuteFunctions,
|
||||||
|
credentialsType: string,
|
||||||
|
requestOptions: IHttpRequestOptions,
|
||||||
|
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
||||||
|
): Promise<any>;
|
||||||
|
|
||||||
|
requestOAuth1(
|
||||||
|
this: IAllExecuteFunctions,
|
||||||
|
credentialsType: string,
|
||||||
|
requestOptions: OptionsWithUrl | RequestPromiseOptions,
|
||||||
|
): Promise<any>;
|
||||||
|
requestOAuth2(
|
||||||
|
this: IAllExecuteFunctions,
|
||||||
|
credentialsType: string,
|
||||||
|
requestOptions: OptionsWithUri | RequestPromiseOptions,
|
||||||
|
oAuth2Options?: IOAuth2Options,
|
||||||
|
): Promise<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FunctionsBase {
|
||||||
|
getCredentials(type: string, itemIndex?: number): Promise<ICredentialDataDecryptedObject>;
|
||||||
getNode(): INode;
|
getNode(): INode;
|
||||||
|
getWorkflow(): IWorkflowMetadata;
|
||||||
|
getWorkflowStaticData(type: string): IDataObject;
|
||||||
|
getTimezone(): string;
|
||||||
|
getRestApiUrl(): string;
|
||||||
|
|
||||||
|
getMode?: () => WorkflowExecuteMode;
|
||||||
|
getActivationMode?: () => WorkflowActivateMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
type FunctionsBaseWithRequiredKeys<Keys extends keyof FunctionsBase> = FunctionsBase & {
|
||||||
|
[K in Keys]: NonNullable<FunctionsBase[K]>;
|
||||||
|
};
|
||||||
|
|
||||||
|
type BaseExecutionFunctions = FunctionsBaseWithRequiredKeys<'getMode'> & {
|
||||||
|
continueOnFail(): boolean;
|
||||||
|
evaluateExpression(expression: string, itemIndex: number): NodeParameterValueType;
|
||||||
|
getContext(type: string): IContextObject;
|
||||||
|
getExecuteData(): IExecuteData;
|
||||||
|
getWorkflowDataProxy(itemIndex: number): IWorkflowDataProxyData;
|
||||||
|
getInputSourceData(inputIndex?: number, inputName?: string): ISourceData;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IExecuteFunctions = ExecuteFunctions.GetNodeParameterFn &
|
||||||
|
BaseExecutionFunctions & {
|
||||||
|
executeWorkflow(
|
||||||
|
workflowInfo: IExecuteWorkflowInfo,
|
||||||
|
inputData?: INodeExecutionData[],
|
||||||
|
): Promise<any>;
|
||||||
|
getInputData(inputIndex?: number, inputName?: string): INodeExecutionData[];
|
||||||
|
prepareOutputData(
|
||||||
|
outputData: INodeExecutionData[],
|
||||||
|
outputIndex?: number,
|
||||||
|
): Promise<INodeExecutionData[][]>;
|
||||||
|
putExecutionToWait(waitTill: Date): Promise<void>;
|
||||||
|
sendMessageToUI(message: any): void;
|
||||||
|
sendResponse(response: IExecuteResponsePromiseData): void;
|
||||||
|
|
||||||
|
helpers: RequestHelperFunctions &
|
||||||
|
BinaryHelperFunctions &
|
||||||
|
JsonHelperFunctions & {
|
||||||
|
normalizeItems(items: INodeExecutionData | INodeExecutionData[]): INodeExecutionData[];
|
||||||
|
constructExecutionMetaData(
|
||||||
|
inputData: INodeExecutionData[],
|
||||||
|
options: { itemData: IPairedItemData | IPairedItemData[] },
|
||||||
|
): NodeExecutionWithMetadata[];
|
||||||
|
|
||||||
|
getBinaryDataBuffer(itemIndex: number, propertyName: string): Promise<Buffer>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface IExecuteSingleFunctions extends BaseExecutionFunctions {
|
||||||
|
getInputData(inputIndex?: number, inputName?: string): INodeExecutionData;
|
||||||
|
getItemIndex(): number;
|
||||||
|
getNodeParameter(
|
||||||
|
parameterName: string,
|
||||||
|
fallbackValue?: any,
|
||||||
|
options?: IGetNodeParameterOptions,
|
||||||
|
): NodeParameterValueType | object;
|
||||||
|
|
||||||
|
helpers: RequestHelperFunctions &
|
||||||
|
BinaryHelperFunctions & {
|
||||||
|
getBinaryDataBuffer(propertyName: string, inputIndex?: number): Promise<Buffer>;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IExecutePaginationFunctions extends IExecuteSingleFunctions {
|
||||||
|
makeRoutingRequest(
|
||||||
|
this: IAllExecuteFunctions,
|
||||||
|
requestOptions: DeclarativeRestApiSettings.ResultOptions,
|
||||||
|
): Promise<INodeExecutionData[]>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ILoadOptionsFunctions extends FunctionsBase {
|
||||||
getNodeParameter(
|
getNodeParameter(
|
||||||
parameterName: string,
|
parameterName: string,
|
||||||
fallbackValue?: any,
|
fallbackValue?: any,
|
||||||
@@ -719,134 +754,57 @@ export interface ILoadOptionsFunctions {
|
|||||||
options?: IGetNodeParameterOptions,
|
options?: IGetNodeParameterOptions,
|
||||||
): NodeParameterValueType | object | undefined;
|
): NodeParameterValueType | object | undefined;
|
||||||
getCurrentNodeParameters(): INodeParameters | undefined;
|
getCurrentNodeParameters(): INodeParameters | undefined;
|
||||||
getTimezone(): string;
|
helpers: RequestHelperFunctions;
|
||||||
getRestApiUrl(): string;
|
|
||||||
helpers: {
|
|
||||||
httpRequest(
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
|
|
||||||
// TODO: Remove from here. Add it only now to LoadOptions as many nodes do import
|
|
||||||
// from n8n-workflow instead of n8n-core
|
|
||||||
requestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: any,
|
|
||||||
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
||||||
): Promise<any>;
|
|
||||||
httpRequestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
||||||
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
|
|
||||||
[key: string]: ((...args: any[]) => any) | undefined;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IHookFunctions {
|
export interface IPollFunctions
|
||||||
getCredentials(type: string): Promise<ICredentialDataDecryptedObject>;
|
extends FunctionsBaseWithRequiredKeys<'getMode' | 'getActivationMode'> {
|
||||||
getMode(): WorkflowExecuteMode;
|
|
||||||
getActivationMode(): WorkflowActivateMode;
|
|
||||||
getNode(): INode;
|
|
||||||
getNodeWebhookUrl: (name: string) => string | undefined;
|
|
||||||
getNodeParameter(
|
|
||||||
parameterName: string,
|
|
||||||
fallbackValue?: any,
|
|
||||||
options?: IGetNodeParameterOptions,
|
|
||||||
): NodeParameterValueType | object;
|
|
||||||
getTimezone(): string;
|
|
||||||
getWebhookDescription(name: string): IWebhookDescription | undefined;
|
|
||||||
getWebhookName(): string;
|
|
||||||
getWorkflow(): IWorkflowMetadata;
|
|
||||||
getWorkflowStaticData(type: string): IDataObject;
|
|
||||||
helpers: {
|
|
||||||
httpRequest(
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
|
|
||||||
httpRequestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
||||||
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
|
|
||||||
[key: string]: (...args: any[]) => any;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IPollFunctions {
|
|
||||||
__emit(
|
__emit(
|
||||||
data: INodeExecutionData[][],
|
data: INodeExecutionData[][],
|
||||||
responsePromise?: IDeferredPromise<IExecuteResponsePromiseData>,
|
responsePromise?: IDeferredPromise<IExecuteResponsePromiseData>,
|
||||||
donePromise?: IDeferredPromise<IRun>,
|
donePromise?: IDeferredPromise<IRun>,
|
||||||
): void;
|
): void;
|
||||||
__emitError(error: Error, responsePromise?: IDeferredPromise<IExecuteResponsePromiseData>): void;
|
__emitError(error: Error, responsePromise?: IDeferredPromise<IExecuteResponsePromiseData>): void;
|
||||||
getCredentials(type: string): Promise<ICredentialDataDecryptedObject>;
|
|
||||||
getMode(): WorkflowExecuteMode;
|
|
||||||
getActivationMode(): WorkflowActivateMode;
|
|
||||||
getNode(): INode;
|
|
||||||
getNodeParameter(
|
getNodeParameter(
|
||||||
parameterName: string,
|
parameterName: string,
|
||||||
fallbackValue?: any,
|
fallbackValue?: any,
|
||||||
options?: IGetNodeParameterOptions,
|
options?: IGetNodeParameterOptions,
|
||||||
): NodeParameterValueType | object;
|
): NodeParameterValueType | object;
|
||||||
getRestApiUrl(): string;
|
helpers: RequestHelperFunctions & BinaryHelperFunctions & JsonHelperFunctions;
|
||||||
getTimezone(): string;
|
|
||||||
getWorkflow(): IWorkflowMetadata;
|
|
||||||
getWorkflowStaticData(type: string): IDataObject;
|
|
||||||
helpers: {
|
|
||||||
httpRequest(
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
|
|
||||||
httpRequestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
||||||
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
|
|
||||||
[key: string]: (...args: any[]) => any;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITriggerFunctions {
|
export interface ITriggerFunctions
|
||||||
|
extends FunctionsBaseWithRequiredKeys<'getMode' | 'getActivationMode'> {
|
||||||
emit(
|
emit(
|
||||||
data: INodeExecutionData[][],
|
data: INodeExecutionData[][],
|
||||||
responsePromise?: IDeferredPromise<IExecuteResponsePromiseData>,
|
responsePromise?: IDeferredPromise<IExecuteResponsePromiseData>,
|
||||||
donePromise?: IDeferredPromise<IRun>,
|
donePromise?: IDeferredPromise<IRun>,
|
||||||
): void;
|
): void;
|
||||||
emitError(error: Error, responsePromise?: IDeferredPromise<IExecuteResponsePromiseData>): void;
|
emitError(error: Error, responsePromise?: IDeferredPromise<IExecuteResponsePromiseData>): void;
|
||||||
getCredentials(type: string): Promise<ICredentialDataDecryptedObject>;
|
|
||||||
getMode(): WorkflowExecuteMode;
|
|
||||||
getActivationMode(): WorkflowActivateMode;
|
|
||||||
getNode(): INode;
|
|
||||||
getNodeParameter(
|
getNodeParameter(
|
||||||
parameterName: string,
|
parameterName: string,
|
||||||
fallbackValue?: any,
|
fallbackValue?: any,
|
||||||
options?: IGetNodeParameterOptions,
|
options?: IGetNodeParameterOptions,
|
||||||
): NodeParameterValueType | object;
|
): NodeParameterValueType | object;
|
||||||
getRestApiUrl(): string;
|
helpers: RequestHelperFunctions & BinaryHelperFunctions & JsonHelperFunctions;
|
||||||
getTimezone(): string;
|
|
||||||
getWorkflow(): IWorkflowMetadata;
|
|
||||||
getWorkflowStaticData(type: string): IDataObject;
|
|
||||||
helpers: {
|
|
||||||
httpRequest(
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
|
|
||||||
httpRequestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
||||||
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
|
|
||||||
[key: string]: (...args: any[]) => any;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IWebhookFunctions {
|
export interface IHookFunctions
|
||||||
|
extends FunctionsBaseWithRequiredKeys<'getMode' | 'getActivationMode'> {
|
||||||
|
getWebhookName(): string;
|
||||||
|
getWebhookDescription(name: string): IWebhookDescription | undefined;
|
||||||
|
getNodeWebhookUrl: (name: string) => string | undefined;
|
||||||
|
getNodeParameter(
|
||||||
|
parameterName: string,
|
||||||
|
fallbackValue?: any,
|
||||||
|
options?: IGetNodeParameterOptions,
|
||||||
|
): NodeParameterValueType | object;
|
||||||
|
helpers: RequestHelperFunctions;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IWebhookFunctions extends FunctionsBaseWithRequiredKeys<'getMode'> {
|
||||||
getBodyData(): IDataObject;
|
getBodyData(): IDataObject;
|
||||||
getCredentials(type: string): Promise<ICredentialDataDecryptedObject>;
|
|
||||||
getHeaderData(): IncomingHttpHeaders;
|
getHeaderData(): IncomingHttpHeaders;
|
||||||
getMode(): WorkflowExecuteMode;
|
|
||||||
getNode(): INode;
|
|
||||||
getNodeParameter(
|
getNodeParameter(
|
||||||
parameterName: string,
|
parameterName: string,
|
||||||
fallbackValue?: any,
|
fallbackValue?: any,
|
||||||
@@ -857,26 +815,12 @@ export interface IWebhookFunctions {
|
|||||||
getQueryData(): object;
|
getQueryData(): object;
|
||||||
getRequestObject(): express.Request;
|
getRequestObject(): express.Request;
|
||||||
getResponseObject(): express.Response;
|
getResponseObject(): express.Response;
|
||||||
getTimezone(): string;
|
|
||||||
getWebhookName(): string;
|
getWebhookName(): string;
|
||||||
getWorkflowStaticData(type: string): IDataObject;
|
|
||||||
getWorkflow(): IWorkflowMetadata;
|
|
||||||
prepareOutputData(
|
prepareOutputData(
|
||||||
outputData: INodeExecutionData[],
|
outputData: INodeExecutionData[],
|
||||||
outputIndex?: number,
|
outputIndex?: number,
|
||||||
): Promise<INodeExecutionData[][]>;
|
): Promise<INodeExecutionData[][]>;
|
||||||
helpers: {
|
helpers: RequestHelperFunctions & BinaryHelperFunctions & JsonHelperFunctions;
|
||||||
httpRequest(
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
|
|
||||||
httpRequestWithAuthentication(
|
|
||||||
this: IAllExecuteFunctions,
|
|
||||||
credentialsType: string,
|
|
||||||
requestOptions: IHttpRequestOptions,
|
|
||||||
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
||||||
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
|
|
||||||
[key: string]: (...args: any[]) => any;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface INodeCredentialsDetails {
|
export interface INodeCredentialsDetails {
|
||||||
|
|||||||
@@ -391,7 +391,7 @@ export class RoutingNode {
|
|||||||
return returnData;
|
return returnData;
|
||||||
}
|
}
|
||||||
if (action.type === 'binaryData') {
|
if (action.type === 'binaryData') {
|
||||||
responseData.body = Buffer.from(responseData.body as string);
|
const body = (responseData.body = Buffer.from(responseData.body as string));
|
||||||
let { destinationProperty } = action.properties;
|
let { destinationProperty } = action.properties;
|
||||||
|
|
||||||
destinationProperty = this.getParameterValue(
|
destinationProperty = this.getParameterValue(
|
||||||
@@ -403,7 +403,7 @@ export class RoutingNode {
|
|||||||
false,
|
false,
|
||||||
) as string;
|
) as string;
|
||||||
|
|
||||||
const binaryData = await executeSingleFunctions.helpers.prepareBinaryData(responseData.body);
|
const binaryData = await executeSingleFunctions.helpers.prepareBinaryData(body);
|
||||||
|
|
||||||
return inputData.map((item) => {
|
return inputData.map((item) => {
|
||||||
if (typeof item.json === 'string') {
|
if (typeof item.json === 'string') {
|
||||||
|
|||||||
Reference in New Issue
Block a user