mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix: Make sure errors are transferred correctly from js task runner (no-changelog) (#11214)
This commit is contained in:
@@ -21,6 +21,7 @@ import type { NodeOperationError } from './errors/node-operation.error';
|
||||
import type { WorkflowActivationError } from './errors/workflow-activation.error';
|
||||
import type { WorkflowOperationError } from './errors/workflow-operation.error';
|
||||
import type { ExecutionStatus } from './ExecutionStatus';
|
||||
import type { Result } from './result';
|
||||
import type { Workflow } from './Workflow';
|
||||
import type { EnvProviderState } from './WorkflowDataProxyEnvProvider';
|
||||
import type { WorkflowHooks } from './WorkflowHooks';
|
||||
@@ -997,7 +998,11 @@ export type IExecuteFunctions = ExecuteFunctions.GetNodeParameterFn &
|
||||
|
||||
getParentCallbackManager(): CallbackManager | undefined;
|
||||
|
||||
startJob<T = unknown>(jobType: string, settings: unknown, itemIndex: number): Promise<T>;
|
||||
startJob<T = unknown, E = unknown>(
|
||||
jobType: string,
|
||||
settings: unknown,
|
||||
itemIndex: number,
|
||||
): Promise<Result<T, E>>;
|
||||
};
|
||||
|
||||
export interface IExecuteSingleFunctions extends BaseExecutionFunctions {
|
||||
@@ -2285,7 +2290,7 @@ export interface IWorkflowExecuteAdditionalData {
|
||||
secretsHelpers: SecretsHelpersBase;
|
||||
logAiEvent: (eventName: AiEvent, payload: AiEventPayload) => void;
|
||||
parentCallbackManager?: CallbackManager;
|
||||
startAgentJob<T>(
|
||||
startAgentJob<T, E = unknown>(
|
||||
additionalData: IWorkflowExecuteAdditionalData,
|
||||
jobType: string,
|
||||
settings: unknown,
|
||||
@@ -2305,7 +2310,7 @@ export interface IWorkflowExecuteAdditionalData {
|
||||
defaultReturnRunIndex?: number,
|
||||
selfData?: IDataObject,
|
||||
contextNodeName?: string,
|
||||
): Promise<T>;
|
||||
): Promise<Result<T, E>>;
|
||||
}
|
||||
|
||||
export type WorkflowExecuteMode =
|
||||
@@ -2752,8 +2757,6 @@ export type BannerName =
|
||||
|
||||
export type Functionality = 'regular' | 'configuration-node' | 'pairedItem';
|
||||
|
||||
export type Result<T, E> = { ok: true; result: T } | { ok: false; error: E };
|
||||
|
||||
export type CallbackManager = CallbackManagerLC;
|
||||
|
||||
export type IPersonalizationSurveyAnswersV4 = {
|
||||
|
||||
@@ -7,10 +7,10 @@ import type {
|
||||
FilterOptionsValue,
|
||||
FilterValue,
|
||||
INodeProperties,
|
||||
Result,
|
||||
ValidationResult,
|
||||
} from '../Interfaces';
|
||||
import * as LoggerProxy from '../LoggerProxy';
|
||||
import type { Result } from '../result';
|
||||
import { validateFieldType } from '../TypeValidation';
|
||||
|
||||
type FilterConditionMetadata = {
|
||||
|
||||
@@ -22,6 +22,7 @@ export * from './WorkflowDataProxyEnvProvider';
|
||||
export * from './WorkflowHooks';
|
||||
export * from './VersionedNodeType';
|
||||
export * from './TypeValidation';
|
||||
export * from './result';
|
||||
export { LoggerProxy, NodeHelpers, ObservableObject, TelemetryHelpers };
|
||||
export {
|
||||
isObjectEmpty,
|
||||
|
||||
13
packages/workflow/src/result.ts
Normal file
13
packages/workflow/src/result.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export type ResultOk<T> = { ok: true; result: T };
|
||||
export type ResultError<E> = { ok: false; error: E };
|
||||
export type Result<T, E> = ResultOk<T> | ResultError<E>;
|
||||
|
||||
export const createResultOk = <T>(data: T): ResultOk<T> => ({
|
||||
ok: true,
|
||||
result: data,
|
||||
});
|
||||
|
||||
export const createResultError = <E = unknown>(error: E): ResultError<E> => ({
|
||||
ok: false,
|
||||
error,
|
||||
});
|
||||
Reference in New Issue
Block a user