@n8n/engine 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.tsbuildinfo +1 -1
- package/dist/database/typeorm-execution-view-store.d.ts +4 -1
- package/dist/database/typeorm-execution-view-store.js +46 -0
- package/dist/database/typeorm-execution-view-store.js.map +1 -1
- package/dist/execution/execution-query.service.d.ts +9 -1
- package/dist/execution/execution-query.service.js +14 -0
- package/dist/execution/execution-query.service.js.map +1 -1
- package/dist/execution/execution-view-store.d.ts +28 -0
- package/dist/execution/execution.types.d.ts +5 -3
- package/dist/execution/execution.types.js +5 -2
- package/dist/execution/execution.types.js.map +1 -1
- package/dist/execution/step-settled-handler.d.ts +4 -1
- package/dist/execution/step-settled-handler.js +29 -7
- package/dist/execution/step-settled-handler.js.map +1 -1
- package/dist/execution/step-store.d.ts +1 -0
- package/dist/execution/step-store.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/response-channel/execution-response-channel.d.ts +12 -0
- package/dist/response-channel/execution-response-channel.js +53 -0
- package/dist/response-channel/execution-response-channel.js.map +1 -0
- package/dist/response-channel/execution-response.schema.d.ts +71 -0
- package/dist/response-channel/execution-response.schema.js +22 -0
- package/dist/response-channel/execution-response.schema.js.map +1 -0
- package/dist/response-channel/execution-response.types.d.ts +6 -0
- package/dist/response-channel/execution-response.types.js +3 -0
- package/dist/response-channel/execution-response.types.js.map +1 -0
- package/dist/response-channel/in-memory-transport.d.ts +7 -0
- package/dist/response-channel/in-memory-transport.js +19 -0
- package/dist/response-channel/in-memory-transport.js.map +1 -0
- package/dist/response-channel/index.d.ts +6 -0
- package/dist/response-channel/index.js +12 -0
- package/dist/response-channel/index.js.map +1 -0
- package/dist/response-channel/response-transport.d.ts +7 -0
- package/dist/response-channel/response-transport.js +9 -0
- package/dist/response-channel/response-transport.js.map +1 -0
- package/dist/runtime/create-engine-runtime.d.ts +3 -1
- package/dist/runtime/create-engine-runtime.js +2 -2
- package/dist/runtime/create-engine-runtime.js.map +1 -1
- package/dist/serve.js +2 -0
- package/dist/serve.js.map +1 -1
- package/dist/server/api.types.d.ts +13 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/routes/workflow-executions.handlers.d.ts +1 -0
- package/dist/server/routes/workflow-executions.handlers.js +37 -0
- package/dist/server/routes/workflow-executions.handlers.js.map +1 -1
- package/dist/server/routes/workflow-executions.js +1 -0
- package/dist/server/routes/workflow-executions.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { Repository } from '@n8n/typeorm';
|
|
2
2
|
import type { WorkflowExecution, WorkflowStepExecution } from './entities';
|
|
3
|
-
import type { ExecutionViewStore, ExecutionView, ExecutionWithStepsView } from '../execution/execution-view-store';
|
|
3
|
+
import type { ExecutionViewStore, ExecutionView, ExecutionWithStepsView, ExecutionListQuery, ExecutionListItemView } from '../execution/execution-view-store';
|
|
4
4
|
export declare class TypeOrmExecutionViewStore implements ExecutionViewStore {
|
|
5
5
|
private readonly executions;
|
|
6
6
|
private readonly steps;
|
|
7
7
|
constructor(executions: Repository<WorkflowExecution>, steps: Repository<WorkflowStepExecution>);
|
|
8
|
+
listExecutionViews(query: ExecutionListQuery): Promise<ExecutionListItemView[]>;
|
|
9
|
+
countExecutionViews(query: ExecutionListQuery): Promise<number>;
|
|
10
|
+
private buildListQuery;
|
|
8
11
|
loadExecutionView(id: string): Promise<ExecutionView>;
|
|
9
12
|
loadExecutionWithStepsView(id: string): Promise<ExecutionWithStepsView>;
|
|
10
13
|
private selectExecution;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypeOrmExecutionViewStore = void 0;
|
|
4
|
+
const common_1 = require("../common");
|
|
4
5
|
const execution_store_1 = require("../execution/execution-store");
|
|
6
|
+
function assertPageableOrder(query) {
|
|
7
|
+
if (query.before && query.order?.top) {
|
|
8
|
+
throw new common_1.UnexpectedError('An execution cursor cannot page a status-first sort');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
5
11
|
class TypeOrmExecutionViewStore {
|
|
6
12
|
executions;
|
|
7
13
|
steps;
|
|
@@ -9,6 +15,46 @@ class TypeOrmExecutionViewStore {
|
|
|
9
15
|
this.executions = executions;
|
|
10
16
|
this.steps = steps;
|
|
11
17
|
}
|
|
18
|
+
async listExecutionViews(query) {
|
|
19
|
+
assertPageableOrder(query);
|
|
20
|
+
const qb = this.buildListQuery(query)
|
|
21
|
+
.select('execution.id', 'id')
|
|
22
|
+
.addSelect('execution.workflow_id', 'workflowId')
|
|
23
|
+
.addSelect('execution.status', 'status')
|
|
24
|
+
.addSelect('execution.mode', 'mode')
|
|
25
|
+
.addSelect('execution.created_at', 'createdAt')
|
|
26
|
+
.addSelect('execution.updated_at', 'updatedAt')
|
|
27
|
+
.addSelect('execution.finished_at', 'finishedAt');
|
|
28
|
+
if (query.before) {
|
|
29
|
+
qb.andWhere('(execution.created_at, execution.id) < (:createdAt, :id)', query.before);
|
|
30
|
+
}
|
|
31
|
+
if (query.order?.top) {
|
|
32
|
+
qb.orderBy(`(CASE WHEN execution.status = '${query.order.top}' THEN 0 ELSE 1 END)`);
|
|
33
|
+
}
|
|
34
|
+
return await qb
|
|
35
|
+
.addOrderBy('execution.created_at', 'DESC')
|
|
36
|
+
.addOrderBy('execution.id', 'DESC')
|
|
37
|
+
.limit(query.limit)
|
|
38
|
+
.getRawMany();
|
|
39
|
+
}
|
|
40
|
+
async countExecutionViews(query) {
|
|
41
|
+
return await this.buildListQuery(query).getCount();
|
|
42
|
+
}
|
|
43
|
+
buildListQuery(query) {
|
|
44
|
+
const qb = this.executions.createQueryBuilder('execution');
|
|
45
|
+
if (query.workflowIds !== 'all') {
|
|
46
|
+
qb.andWhere('execution.workflow_id = ANY(:workflowIds)', { workflowIds: query.workflowIds });
|
|
47
|
+
}
|
|
48
|
+
if (query.status)
|
|
49
|
+
qb.andWhere('execution.status = ANY(:statuses)', { statuses: query.status });
|
|
50
|
+
if (query.mode)
|
|
51
|
+
qb.andWhere('execution.mode = :mode', { mode: query.mode });
|
|
52
|
+
if (query.createdAfter)
|
|
53
|
+
qb.andWhere('execution.created_at >= :createdAfter', { createdAfter: query.createdAfter });
|
|
54
|
+
if (query.createdBefore)
|
|
55
|
+
qb.andWhere('execution.created_at <= :createdBefore', { createdBefore: query.createdBefore });
|
|
56
|
+
return qb;
|
|
57
|
+
}
|
|
12
58
|
async loadExecutionView(id) {
|
|
13
59
|
const row = await this.selectExecution(id).getRawOne();
|
|
14
60
|
if (!row)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeorm-execution-view-store.js","sourceRoot":"","sources":["../../src/database/typeorm-execution-view-store.ts"],"names":[],"mappings":";;;AAGA,kEAAsE;
|
|
1
|
+
{"version":3,"file":"typeorm-execution-view-store.js","sourceRoot":"","sources":["../../src/database/typeorm-execution-view-store.ts"],"names":[],"mappings":";;;AAGA,sCAA4C;AAC5C,kEAAsE;AAoBtE,SAAS,mBAAmB,CAAC,KAAyB;IACrD,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC;QACtC,MAAM,IAAI,wBAAe,CAAC,qDAAqD,CAAC,CAAC;IAClF,CAAC;AACF,CAAC;AAUD;IAEmB,UAAU;IACV,KAAK;IAFvB,YACkB,UAAyC,EACzC,KAAwC;0BADxC,UAAU;qBACV,KAAK;IACpB,CAAC;IAEJ,KAAK,CAAC,kBAAkB,CAAC,KAAyB;QACjD,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAE3B,MAAM,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC;aACnC,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC;aAC5B,SAAS,CAAC,uBAAuB,EAAE,YAAY,C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AC;aAC5B,SAAS,CAAC,uBAAuB,EAAE,YAAY,CAAC;aAChD,SAAS,CAAC,kBAAkB,EAAE,QAAQ,CAAC;aACvC,SAAS,CAAC,gBAAgB,EAAE,MAAM,CAAC;aACnC,SAAS,CAAC,iBAAiB,EAAE,OAAO,CAAC;aACrC,SAAS,CAAC,oBAAoB,EAAE,UAAU,CAAC;aAC3C,SAAS,CAAC,sBAAsB,EAAE,WAAW,CAAC;aAC9C,SAAS,CAAC,sBAAsB,EAAE,WAAW,CAAC;aAC9C,SAAS,CAAC,uBAAuB,EAAE,YAAY,CAAC;aAChD,KAAK,CAAC,oBAAoB,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACvC,CAAC;CACD"}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import type { ExecutionViewStore, ExecutionView, ExecutionWithStepsView } from './execution-view-store';
|
|
1
|
+
import type { ExecutionViewStore, ExecutionView, ExecutionWithStepsView, ExecutionListQuery } from './execution-view-store';
|
|
2
2
|
export declare class ExecutionQueryService {
|
|
3
3
|
private readonly viewStore;
|
|
4
4
|
constructor(viewStore: ExecutionViewStore);
|
|
5
|
+
searchExecutions(query: ExecutionListQuery): Promise<{
|
|
6
|
+
items: import("./execution-view-store").ExecutionListItemView[];
|
|
7
|
+
nextCursor: {
|
|
8
|
+
createdAt: Date;
|
|
9
|
+
id: string;
|
|
10
|
+
} | null;
|
|
11
|
+
total?: number | undefined;
|
|
12
|
+
}>;
|
|
5
13
|
getExecution(id: string): Promise<ExecutionView>;
|
|
6
14
|
getExecutionWithSteps(id: string): Promise<ExecutionWithStepsView>;
|
|
7
15
|
}
|
|
@@ -6,6 +6,20 @@ class ExecutionQueryService {
|
|
|
6
6
|
constructor(viewStore) {
|
|
7
7
|
this.viewStore = viewStore;
|
|
8
8
|
}
|
|
9
|
+
async searchExecutions(query) {
|
|
10
|
+
const { limit } = query;
|
|
11
|
+
const [rows, total] = await Promise.all([
|
|
12
|
+
this.viewStore.listExecutionViews({ ...query, limit: limit + 1 }),
|
|
13
|
+
query.includeTotal ? this.viewStore.countExecutionViews(query) : undefined,
|
|
14
|
+
]);
|
|
15
|
+
const items = rows.slice(0, limit);
|
|
16
|
+
const last = items.at(-1);
|
|
17
|
+
return {
|
|
18
|
+
items,
|
|
19
|
+
nextCursor: rows.length > limit && last ? { createdAt: last.createdAt, id: last.id } : null,
|
|
20
|
+
...(total !== undefined ? { total } : {}),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
9
23
|
async getExecution(id) {
|
|
10
24
|
return await this.viewStore.loadExecutionView(id);
|
|
11
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-query.service.js","sourceRoot":"","sources":["../../src/execution/execution-query.service.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"execution-query.service.js","sourceRoot":"","sources":["../../src/execution/execution-query.service.ts"],"names":[],"mappings":";;;AAYA;IAC8B,SAAS;IAAtC,YAA6B,SAA6B;yBAA7B,SAAS;IAAuB,CAAC;IAO9D,KAAK,CAAC,gBAAgB,CAAC,KAAyB;QAC/C,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;QACxB,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACvC,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC;YACjE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;SAC1E,CAAC,CAAC;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QACnC,MAAM,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1B,OAAO;YACN,KAAK;YACL,UAAU,EAAE,IAAI,CAAC,MAAM,GAAG,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI;YAC3F,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACzC,CAAC;IACH,CAAC;IAGD,KAAK,CAAC,YAAY,CAAC,EAAU;QAC5B,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;IAQD,KAAK,CAAC,qBAAqB,CAAC,EAAU;QACrC,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,0BAA0B,CAAC,EAAE,CAAC,CAAC;IAC5D,CAAC;CACD"}
|
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
import type { WorkflowGraph } from '../graph';
|
|
2
2
|
import type { ExecutionMode, ExecutionStatus, StepError, StepSlots, StepStatus, WorkflowDocument } from './execution.types';
|
|
3
|
+
export interface ExecutionListItemView {
|
|
4
|
+
id: string;
|
|
5
|
+
workflowId: string;
|
|
6
|
+
status: ExecutionStatus;
|
|
7
|
+
mode: ExecutionMode;
|
|
8
|
+
createdAt: Date;
|
|
9
|
+
updatedAt: Date;
|
|
10
|
+
finishedAt: Date | null;
|
|
11
|
+
}
|
|
12
|
+
export interface ExecutionListQuery {
|
|
13
|
+
workflowIds: readonly string[] | 'all';
|
|
14
|
+
status?: ExecutionStatus[];
|
|
15
|
+
mode?: string;
|
|
16
|
+
createdAfter?: string;
|
|
17
|
+
createdBefore?: string;
|
|
18
|
+
before?: {
|
|
19
|
+
createdAt: string;
|
|
20
|
+
id: string;
|
|
21
|
+
};
|
|
22
|
+
limit: number;
|
|
23
|
+
includeTotal?: boolean;
|
|
24
|
+
order?: {
|
|
25
|
+
top?: ExecutionStatus;
|
|
26
|
+
startedAt?: 'DESC';
|
|
27
|
+
};
|
|
28
|
+
}
|
|
3
29
|
export interface ExecutionView {
|
|
4
30
|
id: string;
|
|
5
31
|
workflowId: string;
|
|
@@ -25,6 +51,8 @@ export interface ExecutionWithStepsView extends ExecutionView {
|
|
|
25
51
|
steps: StepView[];
|
|
26
52
|
}
|
|
27
53
|
export interface ExecutionViewStore {
|
|
54
|
+
listExecutionViews(query: ExecutionListQuery): Promise<ExecutionListItemView[]>;
|
|
55
|
+
countExecutionViews(query: ExecutionListQuery): Promise<number>;
|
|
28
56
|
loadExecutionView(id: string): Promise<ExecutionView>;
|
|
29
57
|
loadExecutionWithStepsView(id: string): Promise<ExecutionWithStepsView>;
|
|
30
58
|
}
|
|
@@ -6,9 +6,11 @@ export interface CallerContext {
|
|
|
6
6
|
projectId?: string;
|
|
7
7
|
hostMode?: string;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export declare
|
|
9
|
+
export declare const STEP_STATUSES: readonly ['queued', 'running', 'completed', 'failed', 'skipped', 'cancelled'];
|
|
10
|
+
export type StepStatus = (typeof STEP_STATUSES)[number];
|
|
11
|
+
export declare const SETTLED_STEP_STATUSES: readonly ['completed', 'failed', 'skipped', 'cancelled'];
|
|
12
|
+
export type SettledStepStatus = (typeof SETTLED_STEP_STATUSES)[number];
|
|
13
|
+
export declare function isSettledStatus(status: StepStatus): status is SettledStepStatus;
|
|
12
14
|
export type StepSlots = JsonValue[];
|
|
13
15
|
export type TriggerOutputs = StepSlots;
|
|
14
16
|
export type WorkflowDocument = JsonObject;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_TRIGGER_OUTPUTS = exports.SETTLED_STEP_STATUSES = void 0;
|
|
3
|
+
exports.DEFAULT_TRIGGER_OUTPUTS = exports.SETTLED_STEP_STATUSES = exports.STEP_STATUSES = void 0;
|
|
4
4
|
exports.isSettledStatus = isSettledStatus;
|
|
5
5
|
exports.stepKeyId = stepKeyId;
|
|
6
|
-
exports.
|
|
6
|
+
exports.STEP_STATUSES = [
|
|
7
|
+
'queued',
|
|
8
|
+
'running',
|
|
7
9
|
'completed',
|
|
8
10
|
'failed',
|
|
9
11
|
'skipped',
|
|
10
12
|
'cancelled',
|
|
11
13
|
];
|
|
14
|
+
exports.SETTLED_STEP_STATUSES = ['completed', 'failed', 'skipped', 'cancelled'];
|
|
12
15
|
function isSettledStatus(status) {
|
|
13
16
|
return exports.SETTLED_STEP_STATUSES.includes(status);
|
|
14
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.types.js","sourceRoot":"","sources":["../../src/execution/execution.types.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"execution.types.js","sourceRoot":"","sources":["../../src/execution/execution.types.ts"],"names":[],"mappings":";;;;;AAmCa,QAAA,aAAa,GAAG;IAC5B,QAAQ;IACR,SAAS;IACT,WAAW;IACX,QAAQ;IACR,SAAS;IACT,WAAW;CACF,CAAC;AASE,QAAA,qBAAqB,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAU,CAAC;AAI9F,yBAAgC,MAAkB;IACjD,OAAQ,QAAA,qBAA+C,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC1E,CAAC;AA8BY,QAAA,uBAAuB,GAAmB,EAAE,CAAC;AA0B1D,mBAA0B,EAAE,MAAM,EAAE,SAAS,EAAW;IACvD,OAAO,GAAG,MAAM,IAAI,SAAS,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { LifecycleEventPublisher } from '../lifecycle-events';
|
|
2
|
+
import type { ExecutionResponseChannel } from '../response-channel';
|
|
2
3
|
import type { OrchestrationMessage, StepMessage, StepSettledEvent, WorkQueue } from '../queue';
|
|
3
4
|
import type { ExecutionStore } from './execution-store';
|
|
4
5
|
import type { StepStore } from './step-store';
|
|
@@ -8,11 +9,13 @@ export declare class StepSettledHandler {
|
|
|
8
9
|
private readonly stepQueue;
|
|
9
10
|
private readonly orchestrationQueue;
|
|
10
11
|
private readonly lifecycleEventPublisher;
|
|
11
|
-
|
|
12
|
+
private readonly responseChannel;
|
|
13
|
+
constructor(executionStore: ExecutionStore, stepStore: StepStore, stepQueue: WorkQueue<StepMessage>, orchestrationQueue: WorkQueue<OrchestrationMessage>, lifecycleEventPublisher: LifecycleEventPublisher, responseChannel: ExecutionResponseChannel);
|
|
12
14
|
handle(event: StepSettledEvent): Promise<void>;
|
|
13
15
|
private failExecution;
|
|
14
16
|
private planSuccessors;
|
|
15
17
|
private announceCreatedSteps;
|
|
16
18
|
private finishExecutionIfDone;
|
|
19
|
+
private announceEnd;
|
|
17
20
|
private reachableNodeIds;
|
|
18
21
|
}
|
|
@@ -14,21 +14,23 @@ class StepSettledHandler {
|
|
|
14
14
|
stepQueue;
|
|
15
15
|
orchestrationQueue;
|
|
16
16
|
lifecycleEventPublisher;
|
|
17
|
-
|
|
17
|
+
responseChannel;
|
|
18
|
+
constructor(executionStore, stepStore, stepQueue, orchestrationQueue, lifecycleEventPublisher, responseChannel) {
|
|
18
19
|
this.executionStore = executionStore;
|
|
19
20
|
this.stepStore = stepStore;
|
|
20
21
|
this.stepQueue = stepQueue;
|
|
21
22
|
this.orchestrationQueue = orchestrationQueue;
|
|
22
23
|
this.lifecycleEventPublisher = lifecycleEventPublisher;
|
|
24
|
+
this.responseChannel = responseChannel;
|
|
23
25
|
}
|
|
24
26
|
async handle(event) {
|
|
25
27
|
const [step, execution] = await Promise.all([
|
|
26
28
|
this.stepStore.loadStep(event.stepId),
|
|
27
29
|
this.executionStore.loadExecution(event.executionId),
|
|
28
30
|
]);
|
|
29
|
-
(0, validate_step_context_1.validateStepContext)(step, execution);
|
|
31
|
+
const node = (0, validate_step_context_1.validateStepContext)(step, execution);
|
|
30
32
|
if (step.status === 'failed') {
|
|
31
|
-
await this.failExecution(execution);
|
|
33
|
+
await this.failExecution(execution, step, node);
|
|
32
34
|
return;
|
|
33
35
|
}
|
|
34
36
|
if (execution.status !== 'running')
|
|
@@ -36,16 +38,16 @@ class StepSettledHandler {
|
|
|
36
38
|
let queued = 0;
|
|
37
39
|
if (step.status === 'completed' || step.status === 'skipped') {
|
|
38
40
|
if (await this.stepStore.hasFailedSteps(execution.id)) {
|
|
39
|
-
await this.failExecution(execution);
|
|
41
|
+
await this.failExecution(execution, step, node);
|
|
40
42
|
return;
|
|
41
43
|
}
|
|
42
44
|
queued = await this.planSuccessors(execution, step);
|
|
43
45
|
}
|
|
44
46
|
if (queued > 0)
|
|
45
47
|
return;
|
|
46
|
-
await this.finishExecutionIfDone(execution);
|
|
48
|
+
await this.finishExecutionIfDone(execution, step, node);
|
|
47
49
|
}
|
|
48
|
-
async failExecution(execution) {
|
|
50
|
+
async failExecution(execution, step, node) {
|
|
49
51
|
const finished = await this.executionStore.finishExecution(execution.id, 'failed');
|
|
50
52
|
if (finished) {
|
|
51
53
|
this.lifecycleEventPublisher.publish({
|
|
@@ -54,6 +56,7 @@ class StepSettledHandler {
|
|
|
54
56
|
workflowId: execution.workflowId,
|
|
55
57
|
at: new Date().toISOString(),
|
|
56
58
|
});
|
|
59
|
+
this.announceEnd(execution, step, node, 'failed');
|
|
57
60
|
}
|
|
58
61
|
await this.stepStore.cancelQueuedSteps(execution.id);
|
|
59
62
|
}
|
|
@@ -84,7 +87,7 @@ class StepSettledHandler {
|
|
|
84
87
|
}
|
|
85
88
|
return queued;
|
|
86
89
|
}
|
|
87
|
-
async finishExecutionIfDone(execution) {
|
|
90
|
+
async finishExecutionIfDone(execution, step, node) {
|
|
88
91
|
const reachable = this.reachableNodeIds(execution);
|
|
89
92
|
const loops = (0, graph_1.deriveLoops)(execution.graph);
|
|
90
93
|
const terminalIterations = await (0, loop_ledger_1.loadTerminalIterations)(this.stepStore, execution.id, loops
|
|
@@ -105,8 +108,27 @@ class StepSettledHandler {
|
|
|
105
108
|
workflowId: execution.workflowId,
|
|
106
109
|
at: new Date().toISOString(),
|
|
107
110
|
});
|
|
111
|
+
this.announceEnd(execution, step, node, failed ? 'failed' : 'completed');
|
|
108
112
|
}
|
|
109
113
|
}
|
|
114
|
+
announceEnd(execution, step, node, status) {
|
|
115
|
+
if (!(0, execution_types_1.isSettledStatus)(step.status)) {
|
|
116
|
+
throw new common_1.UnexpectedError(`Step ${step.nodeId} announced its end from status '${step.status}'`);
|
|
117
|
+
}
|
|
118
|
+
this.responseChannel.publish({
|
|
119
|
+
type: 'ended',
|
|
120
|
+
executionId: execution.id,
|
|
121
|
+
workflowId: execution.workflowId,
|
|
122
|
+
status,
|
|
123
|
+
lastStep: {
|
|
124
|
+
nodeId: step.nodeId,
|
|
125
|
+
nodeName: node.name,
|
|
126
|
+
status: step.status,
|
|
127
|
+
outputs: step.outputs,
|
|
128
|
+
error: step.error ? { name: step.error.name, message: step.error.message } : undefined,
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
}
|
|
110
132
|
reachableNodeIds(execution) {
|
|
111
133
|
const trigger = (0, graph_1.findTriggerNode)(execution.graph);
|
|
112
134
|
if (!trigger) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-settled-handler.js","sourceRoot":"","sources":["../../src/execution/step-settled-handler.ts"],"names":[],"mappings":";;;AAAA,sCAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"step-settled-handler.js","sourceRoot":"","sources":["../../src/execution/step-settled-handler.ts"],"names":[],"mappings":";;;AAAA,sCAA4C;AAC5C,oCAMkB;AAIlB,6CAAyD;AAEzD,uDAA6F;AAC7F,+CAAwE;AACxE,6CAA8D;AAE9D,mEAA8D;AAc9D;IAEmB,cAAc;IACd,SAAS;IACT,SAAS;IACT,kBAAkB;IAClB,uBAAuB;IACvB,eAAe;IANjC,YACkB,cAA8B,EAC9B,SAAoB,EACpB,SAAiC,EACjC,kBAAmD,EACnD,uBA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AG,IAAA,uBAAe,EAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACjD,IAAI,CAAC,OAAO,EAAE,CAAC;YAGd,MAAM,IAAI,wBAAe,CAAC,aAAa,SAAS,CAAC,EAAE,mCAAmC,CAAC,CAAC;QACzF,CAAC;QACD,OAAO,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,IAAA,4BAAoB,EAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACpF,CAAC;CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-store.js","sourceRoot":"","sources":["../../src/execution/step-store.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"step-store.js","sourceRoot":"","sources":["../../src/execution/step-store.ts"],"names":[],"mappings":";;;AAgDA,uBAA+B,SAAQ,KAAK;IACtB,MAAM;IAA3B,YAAqB,MAAc;QAClC,KAAK,CAAC,mBAAmB,MAAM,EAAE,CAAC,CAAC;sBADf,MAAM;QAE1B,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IACjC,CAAC;CACD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,11 @@ export type { EngineLogger } from './logging';
|
|
|
4
4
|
export { ACTION_TOKEN, IDENTITY_TOKEN, InvalidActionTokenError, InvalidIdentityTokenError, mintActionToken, mintIdentityToken, SharedSecretIdentityVerifier, verifyActionToken, } from './auth';
|
|
5
5
|
export type { AuthenticatedCaller, ActionScope, IdentityVerifier } from './auth';
|
|
6
6
|
export type { EngineErrorResponse, ExecutionSnapshot, StepDetail } from './server';
|
|
7
|
+
export type { SearchExecutionsRequest, SearchExecutionsResponse, ExecutionListItem, } from './server';
|
|
7
8
|
export { MAX_LIFECYCLE_EVENTS_PER_BATCH, lifecycleEventBatchSchema, lifecycleEventSchema, } from './lifecycle-events';
|
|
8
9
|
export type { LifecycleEventCallback, LifecycleEvent, LifecycleEventBatch, } from './lifecycle-events';
|
|
10
|
+
export { ExecutionResponseChannel, executionResponseSchema, InMemoryResponseTransport, noopResponseTransport, } from './response-channel';
|
|
11
|
+
export type { EndedMessage, ExecutionResponse, ResponseTransport, Unsubscribe, } from './response-channel';
|
|
9
12
|
export { UnimplementedError } from './common';
|
|
10
13
|
export type { JsonObject, JsonValue } from './common';
|
|
11
14
|
export { deriveLoops, isBatchStepConfig } from './graph';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WorkflowStepExecution = exports.WorkflowExecution = exports.createDataSource = exports.StepNotFoundError = exports.ExecutionNotFoundError = exports.AdmittanceRejectedError = exports.AllowAllAdmittance = exports.isBatchStepConfig = exports.deriveLoops = exports.UnimplementedError = exports.lifecycleEventSchema = exports.lifecycleEventBatchSchema = exports.MAX_LIFECYCLE_EVENTS_PER_BATCH = exports.verifyActionToken = exports.SharedSecretIdentityVerifier = exports.mintIdentityToken = exports.mintActionToken = exports.InvalidIdentityTokenError = exports.InvalidActionTokenError = exports.IDENTITY_TOKEN = exports.ACTION_TOKEN = exports.createEngineRuntime = void 0;
|
|
3
|
+
exports.WorkflowStepExecution = exports.WorkflowExecution = exports.createDataSource = exports.StepNotFoundError = exports.ExecutionNotFoundError = exports.AdmittanceRejectedError = exports.AllowAllAdmittance = exports.isBatchStepConfig = exports.deriveLoops = exports.UnimplementedError = exports.noopResponseTransport = exports.InMemoryResponseTransport = exports.executionResponseSchema = exports.ExecutionResponseChannel = exports.lifecycleEventSchema = exports.lifecycleEventBatchSchema = exports.MAX_LIFECYCLE_EVENTS_PER_BATCH = exports.verifyActionToken = exports.SharedSecretIdentityVerifier = exports.mintIdentityToken = exports.mintActionToken = exports.InvalidIdentityTokenError = exports.InvalidActionTokenError = exports.IDENTITY_TOKEN = exports.ACTION_TOKEN = exports.createEngineRuntime = void 0;
|
|
4
4
|
var runtime_1 = require("./runtime");
|
|
5
5
|
Object.defineProperty(exports, "createEngineRuntime", { enumerable: true, get: function () { return runtime_1.createEngineRuntime; } });
|
|
6
6
|
var auth_1 = require("./auth");
|
|
@@ -16,6 +16,11 @@ var lifecycle_events_1 = require("./lifecycle-events");
|
|
|
16
16
|
Object.defineProperty(exports, "MAX_LIFECYCLE_EVENTS_PER_BATCH", { enumerable: true, get: function () { return lifecycle_events_1.MAX_LIFECYCLE_EVENTS_PER_BATCH; } });
|
|
17
17
|
Object.defineProperty(exports, "lifecycleEventBatchSchema", { enumerable: true, get: function () { return lifecycle_events_1.lifecycleEventBatchSchema; } });
|
|
18
18
|
Object.defineProperty(exports, "lifecycleEventSchema", { enumerable: true, get: function () { return lifecycle_events_1.lifecycleEventSchema; } });
|
|
19
|
+
var response_channel_1 = require("./response-channel");
|
|
20
|
+
Object.defineProperty(exports, "ExecutionResponseChannel", { enumerable: true, get: function () { return response_channel_1.ExecutionResponseChannel; } });
|
|
21
|
+
Object.defineProperty(exports, "executionResponseSchema", { enumerable: true, get: function () { return response_channel_1.executionResponseSchema; } });
|
|
22
|
+
Object.defineProperty(exports, "InMemoryResponseTransport", { enumerable: true, get: function () { return response_channel_1.InMemoryResponseTransport; } });
|
|
23
|
+
Object.defineProperty(exports, "noopResponseTransport", { enumerable: true, get: function () { return response_channel_1.noopResponseTransport; } });
|
|
19
24
|
var common_1 = require("./common");
|
|
20
25
|
Object.defineProperty(exports, "UnimplementedError", { enumerable: true, get: function () { return common_1.UnimplementedError; } });
|
|
21
26
|
var graph_1 = require("./graph");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qCAAgD;AAAvC,8GAAA,mBAAmB,OAAA;AAK5B,+BASgB;AARf,oGAAA,YAAY,OAAA;AACZ,sGAAA,cAAc,OAAA;AACd,+GAAA,uBAAuB,OAAA;AACvB,iHAAA,yBAAyB,OAAA;AACzB,uGAAA,eAAe,OAAA;AACf,yGAAA,iBAAiB,OAAA;AACjB,oHAAA,4BAA4B,OAAA;AAC5B,yGAAA,iBAAiB,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qCAAgD;AAAvC,8GAAA,mBAAmB,OAAA;AAK5B,+BASgB;AARf,oGAAA,YAAY,OAAA;AACZ,sGAAA,cAAc,OAAA;AACd,+GAAA,uBAAuB,OAAA;AACvB,iHAAA,yBAAyB,OAAA;AACzB,uGAAA,eAAe,OAAA;AACf,yGAAA,iBAAiB,OAAA;AACjB,oHAAA,4BAA4B,OAAA;AAC5B,yGAAA,iBAAiB,OAAA;AAYlB,uDAI4B;AAH3B,kIAAA,8BAA8B,OAAA;AAC9B,6HAAA,yBAAyB,OAAA;AACzB,wHAAA,oBAAoB,OAAA;AAQrB,uDAK4B;AAJ3B,4HAAA,wBAAwB,OAAA;AACxB,2HAAA,uBAAuB,OAAA;AACvB,6HAAA,yBAAyB,OAAA;AACzB,yHAAA,qBAAqB,OAAA;AAStB,mCAA8C;AAArC,4GAAA,kBAAkB,OAAA;AAG3B,iCAAyD;AAAhD,oGAAA,WAAW,OAAA;AAAE,0GAAA,iBAAiB,OAAA;AAmBvC,2CAA2E;AAAlE,gHAAA,kBAAkB,OAAA;AAAE,qHAAA,uBAAuB,OAAA;AAgBpD,yCAAwE;AAA/D,mHAAA,sBAAsB,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AAyBlD,uCAAwF;AAA/E,4GAAA,gBAAgB,OAAA;AAAE,6GAAA,iBAAiB,OAAA;AAAE,iHAAA,qBAAqB,OAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EngineLogger } from '../logging';
|
|
2
|
+
import type { ExecutionResponse } from './execution-response.types';
|
|
3
|
+
import type { ResponseTransport, Unsubscribe } from './response-transport';
|
|
4
|
+
export declare class ExecutionResponseChannel {
|
|
5
|
+
private readonly transport;
|
|
6
|
+
private readonly logger;
|
|
7
|
+
constructor(transport: ResponseTransport, logger: EngineLogger);
|
|
8
|
+
publish(response: ExecutionResponse): void;
|
|
9
|
+
subscribe(executionId: string, handler: (response: ExecutionResponse) => void): Unsubscribe;
|
|
10
|
+
stop(): Promise<void>;
|
|
11
|
+
private fromFrame;
|
|
12
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExecutionResponseChannel = void 0;
|
|
4
|
+
const execution_response_schema_1 = require("./execution-response.schema");
|
|
5
|
+
class ExecutionResponseChannel {
|
|
6
|
+
transport;
|
|
7
|
+
logger;
|
|
8
|
+
constructor(transport, logger) {
|
|
9
|
+
this.transport = transport;
|
|
10
|
+
this.logger = logger;
|
|
11
|
+
}
|
|
12
|
+
publish(response) {
|
|
13
|
+
this.transport.publish(response.executionId, JSON.stringify(response));
|
|
14
|
+
}
|
|
15
|
+
subscribe(executionId, handler) {
|
|
16
|
+
return this.transport.subscribe(executionId, (frame) => {
|
|
17
|
+
const response = this.fromFrame(frame);
|
|
18
|
+
if (response === undefined)
|
|
19
|
+
return;
|
|
20
|
+
try {
|
|
21
|
+
handler(response);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
this.logger.error('a response subscriber threw', {
|
|
25
|
+
executionId: response.executionId,
|
|
26
|
+
type: response.type,
|
|
27
|
+
error,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async stop() {
|
|
33
|
+
await this.transport.stop();
|
|
34
|
+
}
|
|
35
|
+
fromFrame(frame) {
|
|
36
|
+
try {
|
|
37
|
+
const parsed = execution_response_schema_1.executionResponseSchema.safeParse(JSON.parse(frame));
|
|
38
|
+
if (!parsed.success) {
|
|
39
|
+
this.logger.error('discarding a malformed response', {
|
|
40
|
+
details: parsed.error.flatten(),
|
|
41
|
+
});
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
return parsed.data;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
this.logger.error('discarding an unreadable response frame', { error });
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.ExecutionResponseChannel = ExecutionResponseChannel;
|
|
53
|
+
//# sourceMappingURL=execution-response-channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-response-channel.js","sourceRoot":"","sources":["../../src/response-channel/execution-response-channel.ts"],"names":[],"mappings":";;;AACA,2EAAsE;AAatE;IAEmB,SAAS;IACT,MAAM;IAFxB,YACkB,SAA4B,EAC5B,MAAoB;yBADpB,SAAS;sBACT,MAAM;IACrB,CAAC;IAEJ,OAAO,CAAC,QAA2B;QAClC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxE,CAAC;IAGD,SAAS,CAAC,WAAmB,EAAE,OAA8C;QAC5E,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;YACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YACvC,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAO;YAEnC,IAAI,CAAC;gBACJ,OAAO,CAAC,QAAQ,CAAC,CAAC;YACnB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAEhB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,6BAA6B,EAAE;oBAChD,WAAW,EAAE,QAAQ,CAAC,WAAW;oBACjC,IAAI,EAAE,QAAQ,CAAC,IAAI;oBACnB,KAAK;iBACL,CAAC,CAAC;YACJ,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI;QACT,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC;IAEO,SAAS,CAAC,KAAa;QAC9B,IAAI,CAAC;YACJ,MAAM,MAAM,GAAG,mDAAuB,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;YACpE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACrB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE;oBACpD,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE;iBAC/B,CAAC,CAAC;gBACH,OAAO,SAAS,CAAC;YAClB,CAAC;YAED,OAAO,MAAM,CAAC,IAAI,CAAC;QACpB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yCAAyC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YACxE,OAAO,SAAS,CAAC;QAClB,CAAC;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const executionResponseSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
3
|
+
type: z.ZodLiteral<"ended">;
|
|
4
|
+
executionId: z.ZodString;
|
|
5
|
+
workflowId: z.ZodString;
|
|
6
|
+
status: z.ZodEnum<["completed", "failed"]>;
|
|
7
|
+
lastStep: z.ZodObject<{
|
|
8
|
+
nodeId: z.ZodString;
|
|
9
|
+
nodeName: z.ZodString;
|
|
10
|
+
status: z.ZodEnum<["completed", "failed", "skipped", "cancelled"]>;
|
|
11
|
+
outputs: z.ZodNullable<z.ZodArray<z.ZodType<import("../common").JsonValue, z.ZodTypeDef, import("../common").JsonValue>, "many">>;
|
|
12
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
13
|
+
name: z.ZodString;
|
|
14
|
+
message: z.ZodString;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
name: string;
|
|
17
|
+
message: string;
|
|
18
|
+
}, {
|
|
19
|
+
name: string;
|
|
20
|
+
message: string;
|
|
21
|
+
}>>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
nodeId: string;
|
|
24
|
+
nodeName: string;
|
|
25
|
+
status: "cancelled" | "completed" | "failed" | "skipped";
|
|
26
|
+
outputs: import("../common").JsonValue[] | null;
|
|
27
|
+
error?: {
|
|
28
|
+
name: string;
|
|
29
|
+
message: string;
|
|
30
|
+
} | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
nodeId: string;
|
|
33
|
+
nodeName: string;
|
|
34
|
+
status: "cancelled" | "completed" | "failed" | "skipped";
|
|
35
|
+
outputs: import("../common").JsonValue[] | null;
|
|
36
|
+
error?: {
|
|
37
|
+
name: string;
|
|
38
|
+
message: string;
|
|
39
|
+
} | undefined;
|
|
40
|
+
}>;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
type: "ended";
|
|
43
|
+
executionId: string;
|
|
44
|
+
workflowId: string;
|
|
45
|
+
status: "completed" | "failed";
|
|
46
|
+
lastStep: {
|
|
47
|
+
nodeId: string;
|
|
48
|
+
nodeName: string;
|
|
49
|
+
status: "cancelled" | "completed" | "failed" | "skipped";
|
|
50
|
+
outputs: import("../common").JsonValue[] | null;
|
|
51
|
+
error?: {
|
|
52
|
+
name: string;
|
|
53
|
+
message: string;
|
|
54
|
+
} | undefined;
|
|
55
|
+
};
|
|
56
|
+
}, {
|
|
57
|
+
type: "ended";
|
|
58
|
+
executionId: string;
|
|
59
|
+
workflowId: string;
|
|
60
|
+
status: "completed" | "failed";
|
|
61
|
+
lastStep: {
|
|
62
|
+
nodeId: string;
|
|
63
|
+
nodeName: string;
|
|
64
|
+
status: "cancelled" | "completed" | "failed" | "skipped";
|
|
65
|
+
outputs: import("../common").JsonValue[] | null;
|
|
66
|
+
error?: {
|
|
67
|
+
name: string;
|
|
68
|
+
message: string;
|
|
69
|
+
} | undefined;
|
|
70
|
+
};
|
|
71
|
+
}>]>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executionResponseSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_1 = require("../common");
|
|
6
|
+
const execution_types_1 = require("../execution/execution.types");
|
|
7
|
+
exports.executionResponseSchema = zod_1.z.discriminatedUnion('type', [
|
|
8
|
+
zod_1.z.object({
|
|
9
|
+
type: zod_1.z.literal('ended'),
|
|
10
|
+
executionId: zod_1.z.string().min(1),
|
|
11
|
+
workflowId: zod_1.z.string().min(1),
|
|
12
|
+
status: zod_1.z.enum(['completed', 'failed']),
|
|
13
|
+
lastStep: zod_1.z.object({
|
|
14
|
+
nodeId: zod_1.z.string().min(1),
|
|
15
|
+
nodeName: zod_1.z.string().min(1),
|
|
16
|
+
status: zod_1.z.enum(execution_types_1.SETTLED_STEP_STATUSES),
|
|
17
|
+
outputs: zod_1.z.array(common_1.jsonValueSchema).nullable(),
|
|
18
|
+
error: zod_1.z.object({ name: zod_1.z.string(), message: zod_1.z.string() }).optional(),
|
|
19
|
+
}),
|
|
20
|
+
}),
|
|
21
|
+
]);
|
|
22
|
+
//# sourceMappingURL=execution-response.schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-response.schema.js","sourceRoot":"","sources":["../../src/response-channel/execution-response.schema.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,sCAA4C;AAG5C,kEAAqE;AAOxD,QAAA,uBAAuB,GAAG,OAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IACnE,OAAC,CAAC,MAAM,CAAC;QACR,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,OAAO,CAAC;QACxB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9B,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC7B,MAAM,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QACvC,QAAQ,EAAE,OAAC,CAAC,MAAM,CAAC;YAClB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;YACzB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;YAC3B,MAAM,EAAE,OAAC,CAAC,IAAI,CAAC,uCAAqB,CAAC;YACrC,OAAO,EAAE,OAAC,CAAC,KAAK,CAAC,wBAAe,CAAC,CAAC,QAAQ,EAAE;YAC5C,KAAK,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE;SACrE,CAAC;KACF,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-response.types.js","sourceRoot":"","sources":["../../src/response-channel/execution-response.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ResponseTransport, Unsubscribe } from './response-transport';
|
|
2
|
+
export declare class InMemoryResponseTransport implements ResponseTransport {
|
|
3
|
+
private readonly executions;
|
|
4
|
+
publish(executionId: string, frame: string): void;
|
|
5
|
+
subscribe(executionId: string, handler: (frame: string) => void): Unsubscribe;
|
|
6
|
+
stop(): Promise<void>;
|
|
7
|
+
}
|