@dudousxd/nestjs-durable-core 0.28.2 → 0.29.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/index.d.cts CHANGED
@@ -472,8 +472,9 @@ type WorkflowCommand =
472
472
  interface WorkflowDecision {
473
473
  taskId: string;
474
474
  runId: string;
475
- /** `continue` = produced `commands` and is blocked on an await; otherwise the run settles. */
476
- status: 'continue' | 'completed' | 'failed';
475
+ /** `continue` = produced `commands` and is blocked on an await; otherwise the run settles.
476
+ * `cancelled` = the worker bailed at an op boundary because the run was cancelled mid-turn. */
477
+ status: 'continue' | 'completed' | 'failed' | 'cancelled';
477
478
  /** New durable ops the replay produced this turn (status === 'continue'), ordered by seq. */
478
479
  commands: WorkflowCommand[];
479
480
  /** Final workflow output (status === 'completed'). */
package/dist/index.d.ts CHANGED
@@ -472,8 +472,9 @@ type WorkflowCommand =
472
472
  interface WorkflowDecision {
473
473
  taskId: string;
474
474
  runId: string;
475
- /** `continue` = produced `commands` and is blocked on an await; otherwise the run settles. */
476
- status: 'continue' | 'completed' | 'failed';
475
+ /** `continue` = produced `commands` and is blocked on an await; otherwise the run settles.
476
+ * `cancelled` = the worker bailed at an op boundary because the run was cancelled mid-turn. */
477
+ status: 'continue' | 'completed' | 'failed' | 'cancelled';
477
478
  /** New durable ops the replay produced this turn (status === 'continue'), ordered by seq. */
478
479
  commands: WorkflowCommand[];
479
480
  /** Final workflow output (status === 'completed'). */
package/dist/index.js CHANGED
@@ -2422,6 +2422,17 @@ var WorkflowEngine = class {
2422
2422
  error
2423
2423
  };
2424
2424
  }
2425
+ if (decision.status === "cancelled") {
2426
+ await this.applyCommands(run, decision.commands);
2427
+ await this.store.updateRun(run.id, {
2428
+ status: "cancelled",
2429
+ updatedAt: /* @__PURE__ */ new Date()
2430
+ });
2431
+ return {
2432
+ runId: run.id,
2433
+ status: "cancelled"
2434
+ };
2435
+ }
2425
2436
  const wakeAt = await this.applyCommands(run, decision.commands);
2426
2437
  await this.store.updateRun(run.id, {
2427
2438
  status: "suspended",