(function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define(["require", "exports"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createRunExecutionData = createRunExecutionData; exports.createEmptyRunExecutionData = createEmptyRunExecutionData; exports.createErrorExecutionData = createErrorExecutionData; /** * Creates a complete IRunExecutionData object with all properties initialized. * You can pass `executionData: null` and `resultData.runData: null` if you * don't want them initialized. */ function createRunExecutionData(options = {}) { return { version: 1, startData: options.startData ?? {}, resultData: { error: options.resultData?.error, // @ts-expect-error CAT-752 runData: options.resultData?.runData === null ? undefined : (options.resultData?.runData ?? {}), pinData: options.resultData?.pinData, lastNodeExecuted: options.resultData?.lastNodeExecuted, metadata: options.resultData?.metadata, }, executionData: options.executionData === null ? undefined : { contextData: options.executionData?.contextData ?? {}, nodeExecutionStack: options.executionData?.nodeExecutionStack ?? [], metadata: options.executionData?.metadata ?? {}, waitingExecution: options.executionData?.waitingExecution ?? {}, waitingExecutionSource: options.executionData?.waitingExecutionSource ?? {}, runtimeData: options.executionData?.runtimeData, }, parentExecution: options.parentExecution, validateSignature: options.validateSignature, waitTill: options.waitTill, manualData: options.manualData, pushRef: options.pushRef, }; // NOTE: we cast to unknown to avoid manual construction of branded type. } /** * Creates a minimal IRunExecutionData object. It only contains an empty * `runData` field. Used when we are not actually executing a workflow, but * need the run data. E.g. in expression evaluations. */ function createEmptyRunExecutionData() { return { version: 1, resultData: { runData: {}, }, }; // NOTE: we cast to unknown to avoid manual construction of branded type. } /** * Creates an IRunExecutionData object for error execution scenarios. * Used when creating execution records for failed nodes with specific * error data and execution context. * * @param node - The node that failed. * @param error - The error that occurred. */ function createErrorExecutionData(node, error) { return { version: 1, startData: { destinationNode: { nodeName: node.name, mode: 'inclusive', }, runNodeFilter: [node.name], }, executionData: { contextData: {}, metadata: {}, nodeExecutionStack: [ { node, data: { main: [ [ { json: {}, pairedItem: { item: 0, }, }, ], ], }, source: null, }, ], waitingExecution: {}, waitingExecutionSource: {}, }, resultData: { runData: { [node.name]: [ { startTime: 0, executionIndex: 0, executionTime: 0, error, source: [], }, ], }, error, lastNodeExecuted: node.name, }, }; // NOTE: we cast to unknown to avoid manual construction of branded type. } }); //# sourceMappingURL=run-execution-data-factory.js.map