feat(Webhook Node): Overhaul (#8889)

Co-authored-by: Giulio Andreini <andreini@netseven.it>
This commit is contained in:
Michael Kret
2024-03-28 10:46:39 +02:00
committed by GitHub
parent 519f945547
commit e84c27c0ce
17 changed files with 780 additions and 43 deletions

View File

@@ -813,6 +813,12 @@ export interface RequestHelperFunctions {
): Promise<any>;
}
export type NodeTypeAndVersion = {
name: string;
type: string;
typeVersion: number;
};
export interface FunctionsBase {
logger: Logger;
getCredentials(type: string, itemIndex?: number): Promise<ICredentialDataDecryptedObject>;
@@ -824,7 +830,8 @@ export interface FunctionsBase {
getRestApiUrl(): string;
getInstanceBaseUrl(): string;
getInstanceId(): string;
getChildNodes(nodeName: string): NodeTypeAndVersion[];
getParentNodes(nodeName: string): NodeTypeAndVersion[];
getMode?: () => WorkflowExecuteMode;
getActivationMode?: () => WorkflowActivateMode;

View File

@@ -264,7 +264,8 @@ const commonCORSParameters: INodeProperties[] = [
name: 'allowedOrigins',
type: 'string',
default: '*',
description: 'The origin(s) to allow cross-origin non-preflight requests from in a browser',
description:
'Comma-separated list of URLs allowed for cross-origin non-preflight requests. Use * (default) to allow all origins.',
},
];
@@ -278,7 +279,11 @@ export function applySpecialNodeParameters(nodeType: INodeType): void {
}
if (nodeType.webhook && supportsCORS) {
const optionsProperty = properties.find(({ name }) => name === 'options');
if (optionsProperty) optionsProperty.options!.push(...commonCORSParameters);
if (optionsProperty)
optionsProperty.options = [
...commonCORSParameters,
...(optionsProperty.options as INodePropertyOptions[]),
];
else properties.push(...commonCORSParameters);
}
}
@@ -533,7 +538,7 @@ export function getParameterResolveOrder(
parameterDependencies: IParameterDependencies,
): number[] {
const executionOrder: number[] = [];
const indexToResolve = Array.from({ length: nodePropertiesArray.length }, (v, k) => k);
const indexToResolve = Array.from({ length: nodePropertiesArray.length }, (_, k) => k);
const resolvedParameters: string[] = [];
let index: number;

View File

@@ -1332,6 +1332,12 @@ export class Workflow {
// The node did already fail. So throw an error here that it displays and logs it correctly.
// Does get used by webhook and trigger nodes in case they throw an error that it is possible
// to log the error and display in Editor-UI.
if (
runExecutionData.resultData.error.name === 'NodeOperationError' ||
runExecutionData.resultData.error.name === 'NodeApiError'
) {
throw runExecutionData.resultData.error;
}
const error = new Error(runExecutionData.resultData.error.message);
error.stack = runExecutionData.resultData.error.stack;