Merge remote-tracking branch 'origin/master' into release/1.0.1

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-07-05 20:01:24 +02:00
193 changed files with 16701 additions and 4702 deletions

View File

@@ -14,3 +14,7 @@ export const NODES_WITH_RENAMABLE_CONTENT = new Set([
'n8n-nodes-base.function',
'n8n-nodes-base.functionItem',
]);
// Arbitrary value to represent an empty credential value
export const CREDENTIAL_EMPTY_VALUE =
'__n8n_EMPTY_VALUE_7b1af746-3729-4c60-9b9b-e08eb29e58da' as const;

View File

@@ -1257,6 +1257,16 @@ export interface INodeType {
};
}
/**
* This class serves as the base for all nodes using the new context API
* having this as a class enables us to identify these instances at runtime
*/
export abstract class Node {
abstract description: INodeTypeDescription;
execute?(context: IExecuteFunctions): Promise<INodeExecutionData[][]>;
webhook?(context: IWebhookFunctions): Promise<IWebhookResponseData>;
}
export interface IVersionedNodeType {
nodeVersions: {
[key: number]: INodeType;

View File

@@ -49,6 +49,7 @@ import type {
IRunNodeResponse,
NodeParameterValueType,
} from './Interfaces';
import { Node } from './Interfaces';
import type { IDeferredPromise } from './DeferredPromise';
import * as NodeHelpers from './NodeHelpers';
@@ -1137,14 +1138,14 @@ export class Workflow {
throw new Error(`The node "${node.name}" does not have any webhooks defined.`);
}
const thisArgs = nodeExecuteFunctions.getExecuteWebhookFunctions(
const context = nodeExecuteFunctions.getExecuteWebhookFunctions(
this,
node,
additionalData,
mode,
webhookData,
);
return nodeType.webhook.call(thisArgs);
return nodeType instanceof Node ? nodeType.webhook(context) : nodeType.webhook.call(context);
}
/**
@@ -1235,7 +1236,7 @@ export class Workflow {
}
if (nodeType.execute) {
const thisArgs = nodeExecuteFunctions.getExecuteFunctions(
const context = nodeExecuteFunctions.getExecuteFunctions(
this,
runExecutionData,
runIndex,
@@ -1246,7 +1247,11 @@ export class Workflow {
executionData,
mode,
);
return { data: await nodeType.execute.call(thisArgs) };
const data =
nodeType instanceof Node
? await nodeType.execute(context)
: await nodeType.execute.call(context);
return { data };
} else if (nodeType.poll) {
if (mode === 'manual') {
// In manual mode run the poll function