@n8n/engine 0.22.1 → 0.23.1

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.
Files changed (67) hide show
  1. package/dist/build.tsbuildinfo +1 -1
  2. package/dist/database/entities/workflow-execution.entity.d.ts +2 -0
  3. package/dist/database/entities/workflow-execution.entity.js +5 -0
  4. package/dist/database/entities/workflow-execution.entity.js.map +1 -1
  5. package/dist/database/migrations/1778529600000-CreateWorkflowExecution.js +5 -0
  6. package/dist/database/migrations/1778529600000-CreateWorkflowExecution.js.map +1 -1
  7. package/dist/database/typeorm-execution-store.d.ts +6 -1
  8. package/dist/database/typeorm-execution-store.js +10 -2
  9. package/dist/database/typeorm-execution-store.js.map +1 -1
  10. package/dist/database/typeorm-step-store.d.ts +1 -0
  11. package/dist/database/typeorm-step-store.js +3 -0
  12. package/dist/database/typeorm-step-store.js.map +1 -1
  13. package/dist/dependencies/external-dependencies.d.ts +8 -1
  14. package/dist/dependencies/index.d.ts +1 -1
  15. package/dist/execution/cancel-execution.service.d.ts +17 -0
  16. package/dist/execution/cancel-execution.service.js +40 -0
  17. package/dist/execution/cancel-execution.service.js.map +1 -0
  18. package/dist/execution/execution-file-cleanup.d.ts +8 -0
  19. package/dist/execution/execution-file-cleanup.js +30 -0
  20. package/dist/execution/execution-file-cleanup.js.map +1 -0
  21. package/dist/execution/execution-store.d.ts +11 -2
  22. package/dist/execution/execution-store.js.map +1 -1
  23. package/dist/execution/index.d.ts +3 -0
  24. package/dist/execution/index.js +5 -1
  25. package/dist/execution/index.js.map +1 -1
  26. package/dist/execution/start-execution.service.d.ts +2 -0
  27. package/dist/execution/start-execution.service.js +1 -0
  28. package/dist/execution/start-execution.service.js.map +1 -1
  29. package/dist/execution/step-ready-handler.d.ts +1 -1
  30. package/dist/execution/step-ready-handler.js +4 -1
  31. package/dist/execution/step-ready-handler.js.map +1 -1
  32. package/dist/execution/step-settled-handler.js +6 -3
  33. package/dist/execution/step-settled-handler.js.map +1 -1
  34. package/dist/execution/step-store.d.ts +1 -0
  35. package/dist/index.d.ts +4 -4
  36. package/dist/index.js +4 -1
  37. package/dist/index.js.map +1 -1
  38. package/dist/lifecycle-events/lifecycle-event.schema.d.ts +40 -0
  39. package/dist/lifecycle-events/lifecycle-event.schema.js +1 -0
  40. package/dist/lifecycle-events/lifecycle-event.schema.js.map +1 -1
  41. package/dist/response-channel/create-response-emitter.d.ts +6 -0
  42. package/dist/response-channel/create-response-emitter.js +22 -0
  43. package/dist/response-channel/create-response-emitter.js.map +1 -0
  44. package/dist/response-channel/execution-response-sender.d.ts +1 -2
  45. package/dist/response-channel/execution-response-sender.js +0 -2
  46. package/dist/response-channel/execution-response-sender.js.map +1 -1
  47. package/dist/response-channel/execution-response.schema.d.ts +88 -8
  48. package/dist/response-channel/execution-response.schema.js +31 -6
  49. package/dist/response-channel/execution-response.schema.js.map +1 -1
  50. package/dist/response-channel/execution-response.types.d.ts +9 -2
  51. package/dist/response-channel/execution-response.types.js +1 -0
  52. package/dist/response-channel/execution-response.types.js.map +1 -1
  53. package/dist/response-channel/index.d.ts +3 -2
  54. package/dist/response-channel/index.js +5 -1
  55. package/dist/response-channel/index.js.map +1 -1
  56. package/dist/runtime/create-engine-runtime.js +1 -0
  57. package/dist/runtime/create-engine-runtime.js.map +1 -1
  58. package/dist/server/api.types.d.ts +5 -0
  59. package/dist/server/create-engine-server.d.ts +2 -1
  60. package/dist/server/create-engine-server.js.map +1 -1
  61. package/dist/server/index.d.ts +1 -1
  62. package/dist/server/routes/workflow-executions.handlers.d.ts +2 -1
  63. package/dist/server/routes/workflow-executions.handlers.js +33 -0
  64. package/dist/server/routes/workflow-executions.handlers.js.map +1 -1
  65. package/dist/server/routes/workflow-executions.js +3 -0
  66. package/dist/server/routes/workflow-executions.js.map +1 -1
  67. package/package.json +14 -10
package/dist/index.d.ts CHANGED
@@ -3,17 +3,17 @@ export type { EngineRuntime, EngineRuntimeOptions } from './runtime';
3
3
  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
- export type { EngineErrorResponse, ExecutionSnapshot, StepDetail } from './server';
6
+ export type { CancelExecutionResponse, EngineErrorResponse, ExecutionSnapshot, StepDetail, } from './server';
7
7
  export type { SearchExecutionsRequest, SearchExecutionsResponse, ExecutionListItem, } from './server';
8
8
  export { MAX_LIFECYCLE_EVENTS_PER_BATCH, lifecycleEventBatchSchema, lifecycleEventSchema, } from './lifecycle-events';
9
9
  export type { LifecycleEventCallback, LifecycleEvent, LifecycleEventBatch, } from './lifecycle-events';
10
- export { executionResponseSchema, noopExecutionResponseSender, noopResponseEmitter, } from './response-channel';
11
- export type { EndedMessage, ExecutionResponse, ExecutionResponseSender, ResponseEmitter, ResponseMessage, UndeliverableMessage, } from './response-channel';
10
+ export { createResponseEmitter, executionResponseSchema, noopExecutionResponseSender, noopResponseEmitter, RESPONSE_EXPECTATION_KINDS, responseExpectationSchema, } from './response-channel';
11
+ export type { ChunkMessage, EndedMessage, ExecutionResponse, ExecutionResponseSender, ResponseEmitter, ResponseExpectation, ResponseExpectationKind, ResponseMessage, UndeliverableMessage, } from './response-channel';
12
12
  export { UnimplementedError } from './common';
13
13
  export type { JsonObject, JsonValue } from './common';
14
14
  export { deriveLoops, isBatchStepConfig } from './graph';
15
15
  export type { BatchStepConfig, GraphEdge, GraphNode, StepConfig, StepType, WorkflowGraph, WorkflowLoop, } from './graph';
16
- export type { ExternalDependencies, IStepExecutor, StepExecutionContext, StepExecutionRequest, StepExecutionResult, } from './dependencies';
16
+ export type { ExecutionFilesDeleter, ExecutionLocation, ExternalDependencies, IStepExecutor, StepExecutionContext, StepExecutionRequest, StepExecutionResult, } from './dependencies';
17
17
  export { AllowAllAdmittance, AdmittanceRejectedError } from './admittance';
18
18
  export type { AdmittanceDecision, AdmittanceRequest, AdmittanceService, } from './admittance';
19
19
  export type { ExecutionEnqueuedEvent, OrchestrationMessage, StepSettledEvent, StepMessage, StepReadyEvent, WorkQueue, } from './queue';
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.noopResponseEmitter = exports.noopExecutionResponseSender = exports.executionResponseSchema = 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.responseExpectationSchema = exports.RESPONSE_EXPECTATION_KINDS = exports.noopResponseEmitter = exports.noopExecutionResponseSender = exports.executionResponseSchema = exports.createResponseEmitter = 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");
@@ -17,9 +17,12 @@ Object.defineProperty(exports, "MAX_LIFECYCLE_EVENTS_PER_BATCH", { enumerable: t
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
19
  var response_channel_1 = require("./response-channel");
20
+ Object.defineProperty(exports, "createResponseEmitter", { enumerable: true, get: function () { return response_channel_1.createResponseEmitter; } });
20
21
  Object.defineProperty(exports, "executionResponseSchema", { enumerable: true, get: function () { return response_channel_1.executionResponseSchema; } });
21
22
  Object.defineProperty(exports, "noopExecutionResponseSender", { enumerable: true, get: function () { return response_channel_1.noopExecutionResponseSender; } });
22
23
  Object.defineProperty(exports, "noopResponseEmitter", { enumerable: true, get: function () { return response_channel_1.noopResponseEmitter; } });
24
+ Object.defineProperty(exports, "RESPONSE_EXPECTATION_KINDS", { enumerable: true, get: function () { return response_channel_1.RESPONSE_EXPECTATION_KINDS; } });
25
+ Object.defineProperty(exports, "responseExpectationSchema", { enumerable: true, get: function () { return response_channel_1.responseExpectationSchema; } });
23
26
  var common_1 = require("./common");
24
27
  Object.defineProperty(exports, "UnimplementedError", { enumerable: true, get: function () { return common_1.UnimplementedError; } });
25
28
  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,iBAA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,OAAA;AAG3B,iCAAyD;AAAhD,oGAAA,WAAW,OAAA;AAAE,0GAAA,iBAAiB,OAAA;AAqBvC,2CAA2E;AAAlE,gHAAA,kBAAkB,OAAA;AAAE,qHAAA,uBAAuB,OAAA;AAgBpD,yCAAwE;AAA/D,mHAAA,sBAAsB,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AA4BlD,uCAAwF;AAA/E,4GAAA,gBAAgB,OAAA;AAAE,6GAAA,iBAAiB,OAAA;AAAE,iHAAA,qBAAqB,OAAA"}
@@ -51,6 +51,21 @@ export declare const lifecycleEventSchema: z.ZodDiscriminatedUnion<"type", [z.Zo
51
51
  workflowId: string;
52
52
  at: string;
53
53
  type: "execution:failed";
54
+ }>, z.ZodObject<{
55
+ executionId: z.ZodString;
56
+ workflowId: z.ZodString;
57
+ at: z.ZodString;
58
+ type: z.ZodLiteral<"execution:cancelled">;
59
+ }, "strip", z.ZodTypeAny, {
60
+ executionId: string;
61
+ workflowId: string;
62
+ at: string;
63
+ type: "execution:cancelled";
64
+ }, {
65
+ executionId: string;
66
+ workflowId: string;
67
+ at: string;
68
+ type: "execution:cancelled";
54
69
  }>, z.ZodObject<{
55
70
  executionId: z.ZodString;
56
71
  stepId: z.ZodString;
@@ -179,6 +194,21 @@ export declare const lifecycleEventBatchSchema: z.ZodObject<{
179
194
  workflowId: string;
180
195
  at: string;
181
196
  type: "execution:failed";
197
+ }>, z.ZodObject<{
198
+ executionId: z.ZodString;
199
+ workflowId: z.ZodString;
200
+ at: z.ZodString;
201
+ type: z.ZodLiteral<"execution:cancelled">;
202
+ }, "strip", z.ZodTypeAny, {
203
+ executionId: string;
204
+ workflowId: string;
205
+ at: string;
206
+ type: "execution:cancelled";
207
+ }, {
208
+ executionId: string;
209
+ workflowId: string;
210
+ at: string;
211
+ type: "execution:cancelled";
182
212
  }>, z.ZodObject<{
183
213
  executionId: z.ZodString;
184
214
  stepId: z.ZodString;
@@ -273,6 +303,11 @@ export declare const lifecycleEventBatchSchema: z.ZodObject<{
273
303
  workflowId: string;
274
304
  at: string;
275
305
  type: "execution:failed";
306
+ } | {
307
+ executionId: string;
308
+ workflowId: string;
309
+ at: string;
310
+ type: "execution:cancelled";
276
311
  } | {
277
312
  executionId: string;
278
313
  stepId: string;
@@ -317,6 +352,11 @@ export declare const lifecycleEventBatchSchema: z.ZodObject<{
317
352
  workflowId: string;
318
353
  at: string;
319
354
  type: "execution:failed";
355
+ } | {
356
+ executionId: string;
357
+ workflowId: string;
358
+ at: string;
359
+ type: "execution:cancelled";
320
360
  } | {
321
361
  executionId: string;
322
362
  stepId: string;
@@ -26,6 +26,7 @@ exports.lifecycleEventSchema = zod_1.z.discriminatedUnion('type', [
26
26
  }),
27
27
  zod_1.z.object({ type: zod_1.z.literal('execution:completed'), ...executionFields }),
28
28
  zod_1.z.object({ type: zod_1.z.literal('execution:failed'), ...executionFields }),
29
+ zod_1.z.object({ type: zod_1.z.literal('execution:cancelled'), ...executionFields }),
29
30
  zod_1.z.object({ type: zod_1.z.literal('step:started'), ...stepFields }),
30
31
  zod_1.z.object({
31
32
  type: zod_1.z.literal('step:completed'),
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle-event.schema.js","sourceRoot":"","sources":["../../src/lifecycle-events/lifecycle-event.schema.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,sCAA4C;AAG/B,QAAA,8BAA8B,GAAG,GAAG,CAAC;AAElD,MAAM,eAAe,GAAG;IACvB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAE9B,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAE7B,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACzB,CAAC;AAEF,MAAM,UAAU,GAAG;IAClB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,MAAM,EAAE,OA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,CAAC;CAChF,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { ExecutionResponseSender } from './execution-response-sender';
2
+ import { type ResponseEmitter, type ResponseExpectation } from './execution-response.types';
3
+ export declare function createResponseEmitter(sender: ExecutionResponseSender, execution: {
4
+ id: string;
5
+ responseExpectation: ResponseExpectation;
6
+ }): ResponseEmitter;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createResponseEmitter = createResponseEmitter;
4
+ const execution_response_types_1 = require("./execution-response.types");
5
+ function createResponseEmitter(sender, execution) {
6
+ const executionId = execution.id;
7
+ switch (execution.responseExpectation.kind) {
8
+ case 'stepResponse':
9
+ return {
10
+ send: (build) => sender.send({ type: 'response', executionId, payload: build() }),
11
+ chunk: execution_response_types_1.noopResponseEmitter.chunk,
12
+ };
13
+ case 'stream':
14
+ return {
15
+ send: execution_response_types_1.noopResponseEmitter.send,
16
+ chunk: (build) => sender.send({ type: 'chunk', executionId, payload: build() }),
17
+ };
18
+ default:
19
+ return execution_response_types_1.noopResponseEmitter;
20
+ }
21
+ }
22
+ //# sourceMappingURL=create-response-emitter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-response-emitter.js","sourceRoot":"","sources":["../../src/response-channel/create-response-emitter.ts"],"names":[],"mappings":";;;AACA,yEAIoC;AAUpC,+BACC,MAA+B,EAC/B,SAAmE;IAEnE,MAAM,WAAW,GAAG,SAAS,CAAC,EAAE,CAAC;IAEjC,QAAQ,SAAS,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAC;QAC5C,KAAK,cAAc;YAClB,OAAO;gBACN,IAAI,EAAE,CAAC,KAAsB,EAAE,EAAE,CAChC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC;gBACjE,KAAK,EAAE,8CAAmB,CAAC,KAAK;aAChC,CAAC;QACH,KAAK,QAAQ;YACZ,OAAO;gBACN,IAAI,EAAE,8CAAmB,CAAC,IAAI;gBAC9B,KAAK,EAAE,CAAC,KAAsB,EAAE,EAAE,CACjC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC;aAC9D,CAAC;QACH;YACC,OAAO,8CAAmB,CAAC;IAC7B,CAAC;AACF,CAAC"}
@@ -1,8 +1,7 @@
1
1
  import { type Result } from '@n8n/utils/result';
2
- import { type ExecutionResponse, type ResponseEmitter } from './execution-response.types';
2
+ import type { ExecutionResponse } from './execution-response.types';
3
3
  export interface ExecutionResponseSender {
4
4
  send(response: ExecutionResponse): Result<void, Error>;
5
- emitterFor(executionId: string): ResponseEmitter;
6
5
  stop(): Promise<void>;
7
6
  }
8
7
  export declare const noopExecutionResponseSender: ExecutionResponseSender;
@@ -2,10 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.noopExecutionResponseSender = void 0;
4
4
  const result_1 = require("@n8n/utils/result");
5
- const execution_response_types_1 = require("./execution-response.types");
6
5
  exports.noopExecutionResponseSender = Object.freeze({
7
6
  send: () => (0, result_1.createResultOk)(undefined),
8
- emitterFor: (_executionId) => execution_response_types_1.noopResponseEmitter,
9
7
  stop: async () => { },
10
8
  });
11
9
  //# sourceMappingURL=execution-response-sender.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"execution-response-sender.js","sourceRoot":"","sources":["../../src/response-channel/execution-response-sender.ts"],"names":[],"mappings":";;;AAAA,8CAAgE;AAEhE,yEAIoC;AAUvB,QAAA,2BAA2B,GAA4B,MAAM,CAAC,MAAM,CAAC;IACjF,IAAI,EAAE,GAAG,EAAE,CAAC,IAAA,uBAAc,EAAC,SAAS,CAAC;IACrC,UAAU,EAAE,CAAC,YAAoB,EAAE,EAAE,CAAC,8CAAmB;IACzD,IAAI,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;CACpB,CAAC,CAAC"}
1
+ {"version":3,"file":"execution-response-sender.js","sourceRoot":"","sources":["../../src/response-channel/execution-response-sender.ts"],"names":[],"mappings":";;;AAAA,8CAAgE;AAWnD,QAAA,2BAA2B,GAA4B,MAAM,CAAC,MAAM,CAAC;IACjF,IAAI,EAAE,GAAG,EAAE,CAAC,IAAA,uBAAc,EAAC,SAAS,CAAC;IACrC,IAAI,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;CACpB,CAAC,CAAC"}
@@ -1,5 +1,13 @@
1
1
  import { z } from 'zod';
2
- export declare const executionResponseSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
2
+ export declare const RESPONSE_EXPECTATION_KINDS: readonly ['none', 'runEnd', 'stepResponse', 'stream'];
3
+ export declare const responseExpectationSchema: z.ZodObject<{
4
+ kind: z.ZodEnum<["none", "runEnd", "stepResponse", "stream"]>;
5
+ }, "strict", z.ZodTypeAny, {
6
+ kind: "none" | "runEnd" | "stepResponse" | "stream";
7
+ }, {
8
+ kind: "none" | "runEnd" | "stepResponse" | "stream";
9
+ }>;
10
+ export declare const executionResponseSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
3
11
  type: z.ZodLiteral<"undeliverable">;
4
12
  executionId: z.ZodString;
5
13
  error: z.ZodObject<{
@@ -38,12 +46,24 @@ export declare const executionResponseSchema: z.ZodDiscriminatedUnion<"type", [z
38
46
  type: "response";
39
47
  executionId: string;
40
48
  payload?: import("../common").JsonValue | undefined;
49
+ }>, z.ZodObject<{
50
+ type: z.ZodLiteral<"chunk">;
51
+ executionId: z.ZodString;
52
+ payload: z.ZodType<import("../common").JsonValue, z.ZodTypeDef, import("../common").JsonValue>;
53
+ }, "strip", z.ZodTypeAny, {
54
+ type: "chunk";
55
+ executionId: string;
56
+ payload: import("../common").JsonValue;
57
+ }, {
58
+ type: "chunk";
59
+ executionId: string;
60
+ payload: import("../common").JsonValue;
41
61
  }>, z.ZodObject<{
42
62
  type: z.ZodLiteral<"ended">;
43
63
  executionId: z.ZodString;
44
64
  workflowId: z.ZodString;
45
- status: z.ZodEnum<["completed", "failed"]>;
46
- lastStep: z.ZodObject<{
65
+ status: z.ZodEnum<["completed", "failed", "cancelled"]>;
66
+ lastStep: z.ZodNullable<z.ZodObject<{
47
67
  nodeId: z.ZodString;
48
68
  nodeName: z.ZodString;
49
69
  status: z.ZodEnum<["completed", "failed", "skipped", "cancelled"]>;
@@ -76,12 +96,12 @@ export declare const executionResponseSchema: z.ZodDiscriminatedUnion<"type", [z
76
96
  name: string;
77
97
  message: string;
78
98
  } | undefined;
79
- }>;
99
+ }>>;
80
100
  }, "strip", z.ZodTypeAny, {
81
101
  type: "ended";
82
102
  executionId: string;
83
103
  workflowId: string;
84
- status: "completed" | "failed";
104
+ status: "cancelled" | "completed" | "failed";
85
105
  lastStep: {
86
106
  nodeId: string;
87
107
  nodeName: string;
@@ -91,12 +111,12 @@ export declare const executionResponseSchema: z.ZodDiscriminatedUnion<"type", [z
91
111
  name: string;
92
112
  message: string;
93
113
  } | undefined;
94
- };
114
+ } | null;
95
115
  }, {
96
116
  type: "ended";
97
117
  executionId: string;
98
118
  workflowId: string;
99
- status: "completed" | "failed";
119
+ status: "cancelled" | "completed" | "failed";
100
120
  lastStep: {
101
121
  nodeId: string;
102
122
  nodeName: string;
@@ -106,5 +126,65 @@ export declare const executionResponseSchema: z.ZodDiscriminatedUnion<"type", [z
106
126
  name: string;
107
127
  message: string;
108
128
  } | undefined;
129
+ } | null;
130
+ }>]>, {
131
+ type: "undeliverable";
132
+ executionId: string;
133
+ error: {
134
+ code: string;
135
+ message: string;
109
136
  };
110
- }>]>;
137
+ } | {
138
+ type: "response";
139
+ executionId: string;
140
+ payload?: import("../common").JsonValue | undefined;
141
+ } | {
142
+ type: "chunk";
143
+ executionId: string;
144
+ payload: import("../common").JsonValue;
145
+ } | {
146
+ type: "ended";
147
+ executionId: string;
148
+ workflowId: string;
149
+ status: "cancelled" | "completed" | "failed";
150
+ lastStep: {
151
+ nodeId: string;
152
+ nodeName: string;
153
+ status: "cancelled" | "completed" | "failed" | "skipped";
154
+ outputs: import("../common").JsonValue[] | null;
155
+ error?: {
156
+ name: string;
157
+ message: string;
158
+ } | undefined;
159
+ } | null;
160
+ }, {
161
+ type: "undeliverable";
162
+ executionId: string;
163
+ error: {
164
+ code: string;
165
+ message: string;
166
+ };
167
+ } | {
168
+ type: "response";
169
+ executionId: string;
170
+ payload?: import("../common").JsonValue | undefined;
171
+ } | {
172
+ type: "chunk";
173
+ executionId: string;
174
+ payload: import("../common").JsonValue;
175
+ } | {
176
+ type: "ended";
177
+ executionId: string;
178
+ workflowId: string;
179
+ status: "cancelled" | "completed" | "failed";
180
+ lastStep: {
181
+ nodeId: string;
182
+ nodeName: string;
183
+ status: "cancelled" | "completed" | "failed" | "skipped";
184
+ outputs: import("../common").JsonValue[] | null;
185
+ error?: {
186
+ name: string;
187
+ message: string;
188
+ } | undefined;
189
+ } | null;
190
+ }>;
@@ -1,10 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executionResponseSchema = void 0;
3
+ exports.executionResponseSchema = exports.responseExpectationSchema = exports.RESPONSE_EXPECTATION_KINDS = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const common_1 = require("../common");
6
6
  const execution_types_1 = require("../execution/execution.types");
7
- exports.executionResponseSchema = zod_1.z.discriminatedUnion('type', [
7
+ exports.RESPONSE_EXPECTATION_KINDS = ['none', 'runEnd', 'stepResponse', 'stream'];
8
+ exports.responseExpectationSchema = zod_1.z
9
+ .object({
10
+ kind: zod_1.z.enum(exports.RESPONSE_EXPECTATION_KINDS),
11
+ })
12
+ .strict();
13
+ exports.executionResponseSchema = zod_1.z
14
+ .discriminatedUnion('type', [
8
15
  zod_1.z.object({
9
16
  type: zod_1.z.literal('undeliverable'),
10
17
  executionId: zod_1.z.string().min(1),
@@ -18,18 +25,36 @@ exports.executionResponseSchema = zod_1.z.discriminatedUnion('type', [
18
25
  executionId: zod_1.z.string().min(1),
19
26
  payload: common_1.jsonValueSchema.optional(),
20
27
  }),
28
+ zod_1.z.object({
29
+ type: zod_1.z.literal('chunk'),
30
+ executionId: zod_1.z.string().min(1),
31
+ payload: common_1.jsonValueSchema,
32
+ }),
21
33
  zod_1.z.object({
22
34
  type: zod_1.z.literal('ended'),
23
35
  executionId: zod_1.z.string().min(1),
24
36
  workflowId: zod_1.z.string().min(1),
25
- status: zod_1.z.enum(['completed', 'failed']),
26
- lastStep: zod_1.z.object({
37
+ status: zod_1.z.enum(['completed', 'failed', 'cancelled']),
38
+ lastStep: zod_1.z
39
+ .object({
27
40
  nodeId: zod_1.z.string().min(1),
28
41
  nodeName: zod_1.z.string().min(1),
29
42
  status: zod_1.z.enum(execution_types_1.SETTLED_STEP_STATUSES),
30
43
  outputs: zod_1.z.array(common_1.jsonValueSchema).nullable(),
31
44
  error: zod_1.z.object({ name: zod_1.z.string(), message: zod_1.z.string() }).optional(),
32
- }),
45
+ })
46
+ .nullable(),
33
47
  }),
34
- ]);
48
+ ])
49
+ .superRefine((response, ctx) => {
50
+ if (response.type !== 'ended')
51
+ return;
52
+ if ((response.status === 'cancelled') === (response.lastStep === null))
53
+ return;
54
+ ctx.addIssue({
55
+ code: zod_1.z.ZodIssueCode.custom,
56
+ path: ['lastStep'],
57
+ message: 'lastStep is null exactly when the run was cancelled',
58
+ });
59
+ });
35
60
  //# sourceMappingURL=execution-response.schema.js.map
@@ -1 +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;AAMxD,QAAA,uBAAuB,GAAG,OAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IACnE,OAAC,CAAC,MAAM,CAAC;QACR,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,eAAe,CAAC;QAChC,WAAW,EAAE,OAAC,CAAC,MAAM,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C,QAAQ,EAAE;SACrE,CAAC;KACF,CAAC;CACF,CAAC,CAAC"}
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;AAGxD,QAAA,0BAA0B,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,CAAU,CAAC;AAMnF,QAAA,yBAAyB,GAAG,OAAC;KACxC,MAAM,CAAC;IACP,IAAI,EAAE,OAAC,CAAC,IAAI,CAAC,QAAA,0BAA0B,CAAC;CACxC,CAAC;KACD,MAAM,EAAE,CAAC;AAME,QAAA,uBAAuB,GAAG,OAAC;KACtC,kBAAkB,CAAC,MAAM,EAAE;IAC3B,OAAC,CAAC,MAAM,CAAC;QACR,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,eAAe,CAAC;QAChC,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9B,KAAK,EAAE,OAAC,CAAC,MAAM,CAAC;YACf,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;YACvB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;SAC1B,CAAC;KACF,CAAC;IACF,OAAC,CAAC,MAAM,CAAC;QACR,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,UAAU,CAAC;QAC3B,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAE9B,OAAO,EAAE,wBAAe,CAAC,QAAQ,EAAE;KACnC,CAAC;IACF,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,O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ClB,OAAO,EAAE,qDAAqD;KAC9D,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { type Result } from '@n8n/utils/result';
2
2
  import type { z } from 'zod';
3
- import type { executionResponseSchema } from './execution-response.schema';
3
+ import type { JsonValue } from '../common';
4
+ import type { executionResponseSchema, responseExpectationSchema } from './execution-response.schema';
4
5
  export type ExecutionResponse = z.infer<typeof executionResponseSchema>;
5
6
  export type UndeliverableMessage = Extract<ExecutionResponse, {
6
7
  type: 'undeliverable';
@@ -11,7 +12,13 @@ export type EndedMessage = Extract<ExecutionResponse, {
11
12
  export type ResponseMessage = Extract<ExecutionResponse, {
12
13
  type: 'response';
13
14
  }>;
15
+ export type ChunkMessage = Extract<ExecutionResponse, {
16
+ type: 'chunk';
17
+ }>;
18
+ export type ResponseExpectation = z.infer<typeof responseExpectationSchema>;
19
+ export type ResponseExpectationKind = ResponseExpectation['kind'];
14
20
  export interface ResponseEmitter {
15
- send(payload: unknown): Result<void, Error>;
21
+ send(build: () => JsonValue): Result<void, Error>;
22
+ chunk(build: () => JsonValue): Result<void, Error>;
16
23
  }
17
24
  export declare const noopResponseEmitter: ResponseEmitter;
@@ -4,5 +4,6 @@ exports.noopResponseEmitter = void 0;
4
4
  const result_1 = require("@n8n/utils/result");
5
5
  exports.noopResponseEmitter = Object.freeze({
6
6
  send: () => (0, result_1.createResultOk)(undefined),
7
+ chunk: () => (0, result_1.createResultOk)(undefined),
7
8
  });
8
9
  //# sourceMappingURL=execution-response.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"execution-response.types.js","sourceRoot":"","sources":["../../src/response-channel/execution-response.types.ts"],"names":[],"mappings":";;;AAAA,8CAAgE;AAyCnD,QAAA,mBAAmB,GAAoB,MAAM,CAAC,MAAM,CAAC;IACjE,IAAI,EAAE,GAAG,EAAE,CAAC,IAAA,uBAAc,EAAC,SAAS,CAAC;CACrC,CAAC,CAAC"}
1
+ {"version":3,"file":"execution-response.types.js","sourceRoot":"","sources":["../../src/response-channel/execution-response.types.ts"],"names":[],"mappings":";;;AAAA,8CAAgE;AA2EnD,QAAA,mBAAmB,GAAoB,MAAM,CAAC,MAAM,CAAC;IACjE,IAAI,EAAE,GAAG,EAAE,CAAC,IAAA,uBAAc,EAAC,SAAS,CAAC;IACrC,KAAK,EAAE,GAAG,EAAE,CAAC,IAAA,uBAAc,EAAC,SAAS,CAAC;CACtC,CAAC,CAAC"}
@@ -1,5 +1,6 @@
1
+ export { createResponseEmitter } from './create-response-emitter';
1
2
  export { noopExecutionResponseSender } from './execution-response-sender';
2
3
  export type { ExecutionResponseSender } from './execution-response-sender';
3
- export { executionResponseSchema } from './execution-response.schema';
4
+ export { executionResponseSchema, RESPONSE_EXPECTATION_KINDS, responseExpectationSchema, } from './execution-response.schema';
4
5
  export { noopResponseEmitter } from './execution-response.types';
5
- export type { EndedMessage, ExecutionResponse, ResponseEmitter, ResponseMessage, UndeliverableMessage, } from './execution-response.types';
6
+ export type { ChunkMessage, EndedMessage, ExecutionResponse, ResponseEmitter, ResponseExpectation, ResponseExpectationKind, ResponseMessage, UndeliverableMessage, } from './execution-response.types';
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noopResponseEmitter = exports.executionResponseSchema = exports.noopExecutionResponseSender = void 0;
3
+ exports.noopResponseEmitter = exports.responseExpectationSchema = exports.RESPONSE_EXPECTATION_KINDS = exports.executionResponseSchema = exports.noopExecutionResponseSender = exports.createResponseEmitter = void 0;
4
+ var create_response_emitter_1 = require("./create-response-emitter");
5
+ Object.defineProperty(exports, "createResponseEmitter", { enumerable: true, get: function () { return create_response_emitter_1.createResponseEmitter; } });
4
6
  var execution_response_sender_1 = require("./execution-response-sender");
5
7
  Object.defineProperty(exports, "noopExecutionResponseSender", { enumerable: true, get: function () { return execution_response_sender_1.noopExecutionResponseSender; } });
6
8
  var execution_response_schema_1 = require("./execution-response.schema");
7
9
  Object.defineProperty(exports, "executionResponseSchema", { enumerable: true, get: function () { return execution_response_schema_1.executionResponseSchema; } });
10
+ Object.defineProperty(exports, "RESPONSE_EXPECTATION_KINDS", { enumerable: true, get: function () { return execution_response_schema_1.RESPONSE_EXPECTATION_KINDS; } });
11
+ Object.defineProperty(exports, "responseExpectationSchema", { enumerable: true, get: function () { return execution_response_schema_1.responseExpectationSchema; } });
8
12
  var execution_response_types_1 = require("./execution-response.types");
9
13
  Object.defineProperty(exports, "noopResponseEmitter", { enumerable: true, get: function () { return execution_response_types_1.noopResponseEmitter; } });
10
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/response-channel/index.ts"],"names":[],"mappings":";;;AAAA,yEAA0E;AAAjE,wIAAA,2BAA2B,OAAA;AAEpC,yEAAsE;AAA7D,oIAAA,uBAAuB,OAAA;AAChC,uEAAiE;AAAxD,+HAAA,mBAAmB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/response-channel/index.ts"],"names":[],"mappings":";;;AAAA,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA;AAC9B,yEAA0E;AAAjE,wIAAA,2BAA2B,OAAA;AAEpC,yEAIqC;AAHpC,oIAAA,uBAAuB,OAAA;AACvB,uIAAA,0BAA0B,OAAA;AAC1B,sIAAA,yBAAyB,OAAA;AAE1B,uEAAiE;AAAxD,+HAAA,mBAAmB,OAAA"}
@@ -20,6 +20,7 @@ function createEngineRuntime({ dataSource, admittance, identityVerifier, logger
20
20
  const stepWorker = new execution_1.StepWorker(stepQueue, new execution_1.StepReadyHandler(executionStore, stepStore, orchestrationQueue, dependencies, lifecycleEventPublisher, responseSender, () => waitSweeper.noteSuspended()));
21
21
  const { app } = (0, server_1.createEngineServer)({
22
22
  startExecution: new execution_1.StartExecutionService(admittance, executionStore, orchestrationQueue),
23
+ cancelExecution: new execution_1.CancelExecutionService(executionStore, stepStore, lifecycleEventPublisher, responseSender),
23
24
  executionQuery: new execution_1.ExecutionQueryService(executionViewStore),
24
25
  identityVerifier,
25
26
  logger,
@@ -1 +1 @@
1
- {"version":3,"file":"create-engine-runtime.js","sourceRoot":"","sources":["../../src/runtime/create-engine-runtime.ts"],"names":[],"mappings":";;;AAKA,0CAA2C;AAG3C,4CASsB;AACtB,0DAAmG;AAEnG,wCAAoE;AACpE,oCAA6C;AAG7C,sCAA+C;AA+C/C,6BAAoC,EACnC,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,MAAM,GAAG,IAAA,6BAAmB,GAAE,EAC9B,cAAc,EACd,oBAAoB,EACpB,mBAAmB,GACG;IACtB,MAAM,kBAAkB,GAAG,IAAI,yBAAiB,CAAuB,MAAM,CAAC,CAAC;IAC/E,MAAM,SAAS,GAAG,IAAI,yBAAiB,CAAc,MAAM,CAAC,CAAC;IAC7D,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,kBAAkB,EAAE,GAAG,IAAA,uBAAY,EAAC,UAAU,CAAC,CAAC;IAEnF,MAAM,YAAY,GACjB,oBAAoB,EAAE,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC,IAAI,EAAE,CAAC;IACjF,MAAM,uBAAuB,GAA4B,YAAY,CAAC,sBAAsB;QAC3F,CAAC,CAAC,IAAI,kDAA+B,CAAC,YAAY,CAAC,sBAAsB,CAAC;QAC1E,CAAC,CAAC,8CAA2B,CAAC;IAE/B,MAAM,mBAAmB,GAAG,IAAI,+BAAmB,CAClD,kBAAkB,EAClB,IAAI,iCAAqB,CACxB,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,uBAAuB,CACvB,EACD,IAAI,8BAAkB,CACrB,cAAc,EACd,SAAS,EACT,SAAS,EACT,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,CACd,CACD,CAAC;IACF,MAAM,WAAW,GAAG,IAAI,uBAAW,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACvF,MAAM,UAAU,GAAG,IAAI,sBAAU,CAChC,SAAS,EACT,IAAI,4BAAgB,CACnB,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,uBAAuB,EACvB,cAAc,EAEd,GAAG,EAAE,CAAC,WAAW,CAAC,aAAa,EAAE,CACjC,CACD,CAAC;IAEF,MAAM,EAAE,GAAG,EAAE,GAAG,IAAA,2BAAkB,EAAC;QAClC,cAAc,EAAE,IAAI,iCAAqB,CAAC,UAAU,EAAE,cAAc,EAAE,kBAAkB,CAAC;QACzF,cAAc,EAAE,IAAI,iCAAqB,CAAC,kBAAkB,CAAC;QAC7D,gBAAgB;QAChB,MAAM;KACN,CAAC,CAAC;IAEH,OAAO;QACN,GAAG;QAEH,KAAK,EAAE,GAAG,EAAE;YACX,mBAAmB,CAAC,KAAK,EAAE,CAAC;YAC5B,UAAU,CAAC,KAAK,EAAE,CAAC;YACnB,WAAW,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC;QAED,IAAI,EAAE,KAAK,IAAI,EAAE;YAOhB,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC;YACzB,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,mBAAmB,CAAC,IAAI,EAAE,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;YAEnE,MAAM,uBAAuB,CAAC,IAAI,EAAE,CAAC;QACtC,CAAC;KACD,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"create-engine-runtime.js","sourceRoot":"","sources":["../../src/runtime/create-engine-runtime.ts"],"names":[],"mappings":";;;AAKA,0CAA2C;AAG3C,4CAUsB;AACtB,0DAAmG;AAEnG,wCAAoE;AACpE,oCAA6C;AAG7C,sCAA+C;AA+C/C,6BAAoC,EACnC,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,MAAM,GAAG,IAAA,6BAAmB,GAAE,EAC9B,cAAc,EACd,oBAAoB,EACpB,mBAAmB,GACG;IACtB,MAAM,kBAAkB,GAAG,IAAI,yB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cAAc,EAAE,IAAI,iCAAqB,CAAC,kBAAkB,CAAC;QAC7D,gBAAgB;QAChB,MAAM;KACN,CAAC,CAAC;IAEH,OAAO;QACN,GAAG;QAEH,KAAK,EAAE,GAAG,EAAE;YACX,mBAAmB,CAAC,KAAK,EAAE,CAAC;YAC5B,UAAU,CAAC,KAAK,EAAE,CAAC;YACnB,WAAW,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC;QAED,IAAI,EAAE,KAAK,IAAI,EAAE;YAOhB,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC;YACzB,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,mBAAmB,CAAC,IAAI,EAAE,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;YAEnE,MAAM,uBAAuB,CAAC,IAAI,EAAE,CAAC;QACtC,CAAC;KACD,CAAC;AACH,CAAC"}
@@ -2,6 +2,11 @@ import type { ExecutionMode, ExecutionStatus, StepError, StepSlots, StepStatus,
2
2
  import type { ExecutionListQuery } from '../execution/execution-view-store';
3
3
  import type { WorkflowGraph } from '../graph';
4
4
  export type SearchExecutionsRequest = ExecutionListQuery;
5
+ export interface CancelExecutionResponse {
6
+ executionId: string;
7
+ status: 'cancelled';
8
+ finishedAt: string;
9
+ }
5
10
  type Without<T, K extends keyof T> = Omit<T, K>;
6
11
  export type ExecutionListItem = Without<ExecutionSnapshot, 'graph' | 'workflow' | 'steps'>;
7
12
  export interface SearchExecutionsResponse {
@@ -1,10 +1,11 @@
1
1
  import { type Application } from 'express';
2
2
  import type { IdentityVerifier } from '../auth/identity.types';
3
- import type { ExecutionQueryService } from '../execution';
3
+ import type { CancelExecutionService, ExecutionQueryService } from '../execution';
4
4
  import type { StartExecutionService } from '../execution/start-execution.service';
5
5
  import type { EngineLogger } from '../logging';
6
6
  export interface EngineServerDeps {
7
7
  startExecution: StartExecutionService;
8
+ cancelExecution: CancelExecutionService;
8
9
  executionQuery: ExecutionQueryService;
9
10
  identityVerifier: IdentityVerifier;
10
11
  logger?: EngineLogger;
@@ -1 +1 @@
1
- {"version":3,"file":"create-engine-server.js","sourceRoot":"","sources":["../../src/server/create-engine-server.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAoD;AAEpD,uDAAsE;AAKtE,sEAA8E;AAO9E,MAAM,aAAa,GAAG,MAAM,CAAC;AAY7B,4BAAmC,IAAsB;IACxD,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;IAGtB,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;QACjC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAGH,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,IAAA,6CAA8B,EAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACpF,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,iBAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC;IACxD,GAAG,CAAC,GAAG,CAAC,0BAA0B,EAAE,IAAA,oDAA8B,EAAC,IAAI,CAAC,CAAC,CAAC;IAE1E,OAAO,EAAE,GAAG,EAAE,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"create-engine-server.js","sourceRoot":"","sources":["../../src/server/create-engine-server.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAoD;AAEpD,uDAAsE;AAKtE,sEAA8E;AAO9E,MAAM,aAAa,GAAG,MAAM,CAAC;AAa7B,4BAAmC,IAAsB;IACxD,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;IAGtB,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;QACjC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAGH,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,IAAA,6CAA8B,EAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACpF,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,iBAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC;IACxD,GAAG,CAAC,GAAG,CAAC,0BAA0B,EAAE,IAAA,oDAA8B,EAAC,IAAI,CAAC,CAAC,CAAC;IAE1E,OAAO,EAAE,GAAG,EAAE,CAAC;AAChB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  export { createEngineServer } from './create-engine-server';
2
2
  export type { EngineServerDeps } from './create-engine-server';
3
- export type { ExecutionSnapshot, StepDetail } from './api.types';
3
+ export type { CancelExecutionResponse, ExecutionSnapshot, StepDetail } from './api.types';
4
4
  export type { SearchExecutionsRequest, SearchExecutionsResponse, ExecutionListItem, } from './api.types';
5
5
  export { fail } from './error-response';
6
6
  export type { EngineErrorResponse } from './error-response';
@@ -1,4 +1,5 @@
1
1
  import type { RequestHandler } from 'express';
2
- import { type ExecutionQueryService } from '../../execution';
2
+ import { type CancelExecutionService, type ExecutionQueryService } from '../../execution';
3
3
  export declare function createSearchExecutionsHandler(executionQuery: ExecutionQueryService): RequestHandler;
4
4
  export declare function createGetExecutionHandler(executionQuery: ExecutionQueryService): RequestHandler;
5
+ export declare function createCancelExecutionHandler(cancelExecution: CancelExecutionService): RequestHandler;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createSearchExecutionsHandler = createSearchExecutionsHandler;
4
4
  exports.createGetExecutionHandler = createGetExecutionHandler;
5
+ exports.createCancelExecutionHandler = createCancelExecutionHandler;
5
6
  const zod_1 = require("zod");
6
7
  const execution_1 = require("../../execution");
7
8
  const error_response_1 = require("../error-response");
@@ -111,4 +112,36 @@ function createGetExecutionHandler(executionQuery) {
111
112
  res.status(200).json(toExecutionSnapshot(execution));
112
113
  };
113
114
  }
115
+ function createCancelExecutionHandler(cancelExecution) {
116
+ return async (req, res) => {
117
+ const id = parseExecutionId(req, res);
118
+ if (id === null)
119
+ return;
120
+ let result;
121
+ try {
122
+ result = await cancelExecution.cancel(id);
123
+ }
124
+ catch (error) {
125
+ if (error instanceof execution_1.ExecutionNotFoundError) {
126
+ (0, error_response_1.fail)(res, 404, { error: 'not_found' });
127
+ return;
128
+ }
129
+ throw error;
130
+ }
131
+ if (result.status !== 'cancelled' || result.finishedAt === null) {
132
+ (0, error_response_1.fail)(res, 409, {
133
+ error: 'not_cancellable',
134
+ reason: `The execution has already ${result.status}`,
135
+ details: { status: result.status },
136
+ });
137
+ return;
138
+ }
139
+ const body = {
140
+ executionId: id,
141
+ status: result.status,
142
+ finishedAt: result.finishedAt.toISOString(),
143
+ };
144
+ res.status(200).json(body);
145
+ };
146
+ }
114
147
  //# sourceMappingURL=workflow-executions.handlers.js.map