@dudousxd/nestjs-durable-core 0.27.0 → 0.28.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.
Files changed (113) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.cjs +3923 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +2044 -0
  5. package/dist/index.d.ts +2044 -20
  6. package/dist/index.js +3857 -38
  7. package/dist/index.js.map +1 -1
  8. package/package.json +19 -5
  9. package/dist/backoff.d.ts +0 -5
  10. package/dist/backoff.d.ts.map +0 -1
  11. package/dist/backoff.js +0 -14
  12. package/dist/backoff.js.map +0 -1
  13. package/dist/checkpoints.d.ts +0 -17
  14. package/dist/checkpoints.d.ts.map +0 -1
  15. package/dist/checkpoints.js +0 -28
  16. package/dist/checkpoints.js.map +0 -1
  17. package/dist/codec-state-store.d.ts +0 -57
  18. package/dist/codec-state-store.d.ts.map +0 -1
  19. package/dist/codec-state-store.js +0 -111
  20. package/dist/codec-state-store.js.map +0 -1
  21. package/dist/completion.d.ts +0 -15
  22. package/dist/completion.d.ts.map +0 -1
  23. package/dist/completion.js +0 -13
  24. package/dist/completion.js.map +0 -1
  25. package/dist/duration.d.ts +0 -6
  26. package/dist/duration.d.ts.map +0 -1
  27. package/dist/duration.js +0 -42
  28. package/dist/duration.js.map +0 -1
  29. package/dist/engine.d.ts +0 -525
  30. package/dist/engine.d.ts.map +0 -1
  31. package/dist/engine.js +0 -1773
  32. package/dist/engine.js.map +0 -1
  33. package/dist/entities.d.ts +0 -44
  34. package/dist/entities.d.ts.map +0 -1
  35. package/dist/entities.js +0 -68
  36. package/dist/entities.js.map +0 -1
  37. package/dist/errors.d.ts +0 -56
  38. package/dist/errors.d.ts.map +0 -1
  39. package/dist/errors.js +0 -93
  40. package/dist/errors.js.map +0 -1
  41. package/dist/event-accumulators.d.ts +0 -39
  42. package/dist/event-accumulators.d.ts.map +0 -1
  43. package/dist/event-accumulators.js +0 -74
  44. package/dist/event-accumulators.js.map +0 -1
  45. package/dist/events.d.ts +0 -9
  46. package/dist/events.d.ts.map +0 -1
  47. package/dist/events.js +0 -41
  48. package/dist/events.js.map +0 -1
  49. package/dist/index.d.ts.map +0 -1
  50. package/dist/interfaces.d.ts +0 -830
  51. package/dist/interfaces.d.ts.map +0 -1
  52. package/dist/interfaces.js +0 -3
  53. package/dist/interfaces.js.map +0 -1
  54. package/dist/metrics.d.ts +0 -44
  55. package/dist/metrics.d.ts.map +0 -1
  56. package/dist/metrics.js +0 -76
  57. package/dist/metrics.js.map +0 -1
  58. package/dist/protocol.d.ts +0 -17
  59. package/dist/protocol.d.ts.map +0 -1
  60. package/dist/protocol.js +0 -53
  61. package/dist/protocol.js.map +0 -1
  62. package/dist/queue.d.ts +0 -48
  63. package/dist/queue.d.ts.map +0 -1
  64. package/dist/queue.js +0 -45
  65. package/dist/queue.js.map +0 -1
  66. package/dist/remote-step-factory.d.ts +0 -15
  67. package/dist/remote-step-factory.d.ts.map +0 -1
  68. package/dist/remote-step-factory.js +0 -15
  69. package/dist/remote-step-factory.js.map +0 -1
  70. package/dist/remote-workflow-executor.d.ts +0 -24
  71. package/dist/remote-workflow-executor.d.ts.map +0 -1
  72. package/dist/remote-workflow-executor.js +0 -73
  73. package/dist/remote-workflow-executor.js.map +0 -1
  74. package/dist/scheduler.d.ts +0 -42
  75. package/dist/scheduler.d.ts.map +0 -1
  76. package/dist/scheduler.js +0 -70
  77. package/dist/scheduler.js.map +0 -1
  78. package/dist/search-attributes.d.ts +0 -17
  79. package/dist/search-attributes.d.ts.map +0 -1
  80. package/dist/search-attributes.js +0 -47
  81. package/dist/search-attributes.js.map +0 -1
  82. package/dist/step-logger.d.ts +0 -9
  83. package/dist/step-logger.d.ts.map +0 -1
  84. package/dist/step-logger.js +0 -92
  85. package/dist/step-logger.js.map +0 -1
  86. package/dist/test-helpers.d.ts +0 -11
  87. package/dist/test-helpers.d.ts.map +0 -1
  88. package/dist/test-helpers.js +0 -15
  89. package/dist/test-helpers.js.map +0 -1
  90. package/dist/testing/in-memory-state-store.d.ts +0 -37
  91. package/dist/testing/in-memory-state-store.d.ts.map +0 -1
  92. package/dist/testing/in-memory-state-store.js +0 -134
  93. package/dist/testing/in-memory-state-store.js.map +0 -1
  94. package/dist/testing/in-memory-transport.d.ts +0 -25
  95. package/dist/testing/in-memory-transport.d.ts.map +0 -1
  96. package/dist/testing/in-memory-transport.js +0 -53
  97. package/dist/testing/in-memory-transport.js.map +0 -1
  98. package/dist/tokens.d.ts +0 -8
  99. package/dist/tokens.d.ts.map +0 -1
  100. package/dist/tokens.js +0 -11
  101. package/dist/tokens.js.map +0 -1
  102. package/dist/transport-pool.d.ts +0 -30
  103. package/dist/transport-pool.d.ts.map +0 -1
  104. package/dist/transport-pool.js +0 -86
  105. package/dist/transport-pool.js.map +0 -1
  106. package/dist/workflow-ctx.d.ts +0 -52
  107. package/dist/workflow-ctx.d.ts.map +0 -1
  108. package/dist/workflow-ctx.js +0 -432
  109. package/dist/workflow-ctx.js.map +0 -1
  110. package/dist/workflow-ref.d.ts +0 -34
  111. package/dist/workflow-ref.d.ts.map +0 -1
  112. package/dist/workflow-ref.js +0 -32
  113. package/dist/workflow-ref.js.map +0 -1
@@ -1,86 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TransportPool = void 0;
4
- /**
5
- * An ordered pool of named transports. The engine dispatches on the first and fails over to the
6
- * next on a dispatch error; a step can pin one by id. Pure transport plumbing — no run lifecycle —
7
- * so it lives apart from the engine.
8
- */
9
- class TransportPool {
10
- transports;
11
- constructor(transports) {
12
- this.transports = transports;
13
- }
14
- get size() {
15
- return this.transports.length;
16
- }
17
- /** Register the engine's result/heartbeat/step-event handlers on EVERY transport — a result can come
18
- * back on whichever one delivered the task, so failover stays symmetric. `onStepEvent` is wired only
19
- * on transports that carry streamed workflow step lifecycle (BullMQ); others simply skip it. */
20
- bind(onResult, onHeartbeat, onStepEvent) {
21
- for (const { transport } of this.transports) {
22
- transport.onResult(onResult);
23
- transport.onHeartbeat(onHeartbeat);
24
- if (onStepEvent && transport.onStepEvent) {
25
- transport.onStepEvent(onStepEvent);
26
- }
27
- }
28
- }
29
- /**
30
- * Dispatch `task` over the pool: try the preferred (or first) transport, fail over to the next on
31
- * a dispatch error, and stamp the task with the id of the transport that accepted it (so a worker
32
- * replies on the matching one). Throws if every transport fails.
33
- */
34
- async dispatch(task, preferId) {
35
- let lastErr;
36
- for (const { id, transport } of this.ordered(preferId)) {
37
- try {
38
- await transport.dispatch({ ...task, transport: id });
39
- return;
40
- }
41
- catch (err) {
42
- lastErr = err;
43
- }
44
- }
45
- throw lastErr ?? new Error('no transport accepted the dispatch');
46
- }
47
- /** Worker-health for `group`, merged across every transport that can report it (a group's queue
48
- * and its workers may live on any pinned transport). Undefined when no transport implements
49
- * `groupHealth` (e.g. a pure in-process transport — nothing to introspect). */
50
- async groupHealth(group) {
51
- const reports = [];
52
- for (const { transport } of this.transports) {
53
- if (transport.groupHealth)
54
- reports.push(await transport.groupHealth(group));
55
- }
56
- if (reports.length === 0)
57
- return undefined;
58
- return {
59
- group,
60
- depth: reports.reduce((sum, r) => sum + r.depth, 0),
61
- liveWorkers: reports.flatMap((r) => r.liveWorkers),
62
- };
63
- }
64
- /** Distinct worker groups with a live heartbeat, merged across every transport that can report it. */
65
- async listWorkerGroups() {
66
- const groups = new Set();
67
- for (const { transport } of this.transports) {
68
- if (transport.listWorkerGroups) {
69
- for (const g of await transport.listWorkerGroups())
70
- groups.add(g);
71
- }
72
- }
73
- return [...groups];
74
- }
75
- /** Pinned `preferId` first, then the rest (failover order). */
76
- ordered(preferId) {
77
- if (!preferId)
78
- return this.transports;
79
- const pref = this.transports.filter((t) => t.id === preferId);
80
- if (pref.length === 0)
81
- throw new Error(`transport "${preferId}" is not registered`);
82
- return [...pref, ...this.transports.filter((t) => t.id !== preferId)];
83
- }
84
- }
85
- exports.TransportPool = TransportPool;
86
- //# sourceMappingURL=transport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,IAAI,KAAK,CAAC,cAAc,QAAQ,qBAAqB,CAAC,CAAC;QACpF,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC;IACxE,CAAC;CACF;AA5ED,sCA4EC"}
@@ -1,52 +0,0 @@
1
- import type { RemoteStepDef, StateStore, StepError, StepEvent, StepInvocation, StepKind, WorkflowCtx } from './interfaces';
2
- /** A saga undo registered by a completed step, kept with its step name for visibility on failure. */
3
- export interface Compensation {
4
- name: string;
5
- fn: () => Promise<void>;
6
- }
7
- /** A finished local step the host should checkpoint and announce (completed or failed). */
8
- export interface StepRecord {
9
- runId: string;
10
- seq: number;
11
- name: string;
12
- kind: StepKind;
13
- input?: unknown;
14
- events?: StepEvent[];
15
- attempts: number;
16
- enqueuedAt: Date;
17
- startedAt: Date;
18
- workerGroup?: string;
19
- }
20
- /**
21
- * The narrow surface {@link createWorkflowCtx} needs from the engine — the seam between the
22
- * authoring API (this module) and the orchestrator (the engine owns lifecycle: emitting events,
23
- * suspending/resuming runs, dispatching remote steps).
24
- */
25
- export interface CtxHost {
26
- readonly store: StateStore;
27
- clock(): number;
28
- webhookUrl?: (token: string) => string;
29
- /** Mark a local step's body as started — emits `step.started` and (optionally) a `running` checkpoint. */
30
- startStep(step: StepRecord): Promise<void>;
31
- completeStep(step: StepRecord & {
32
- output: unknown;
33
- }): Promise<void>;
34
- failStep(step: StepRecord & {
35
- error: StepError;
36
- }): Promise<void>;
37
- callRemote<TInput, TOutput>(runId: string, seq: number, step: RemoteStepDef<TInput, TOutput>, input: TInput, queue?: string, transport?: string): Promise<TOutput>;
38
- /** Start a child run once, deferred so it can't reentrantly resume a still-running parent. */
39
- startChild(workflow: string, input: unknown, id: string): void;
40
- /** Deliver an op to a durable entity (deferred), optionally with a `reply` token for the result. */
41
- signalEntity?(name: string, key: string, op: string, arg: unknown, reply?: string): void;
42
- /** Run a local step body through the registered step interceptors (identity if none). */
43
- interceptStep?<T>(invocation: StepInvocation, body: () => Promise<T>): Promise<T>;
44
- }
45
- /**
46
- * Build the {@link WorkflowCtx} handed to a workflow body. Every primitive is a closure over the
47
- * position counter (the per-run logical position) and the saga `compensations` stack, so `task`/
48
- * `child` compose `step`/`waitForSignal` directly. All durability goes through {@link CtxHost}, so
49
- * the workflow body stays deterministic.
50
- */
51
- export declare function createWorkflowCtx(host: CtxHost, runId: string, compensations: Compensation[], workflow?: string): WorkflowCtx;
52
- //# sourceMappingURL=workflow-ctx.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow-ctx.d.ts","sourceRoot":"","sources":["../src/workflow-ctx.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAEV,aAAa,EACb,UAAU,EACV,SAAS,EACT,SAAS,EACT,cAAc,EACd,QAAQ,EAGR,WAAW,EACZ,MAAM,cAAc,CAAC;AAKtB,qGAAqG;AACrG,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAED,2FAA2F;AAC3F,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,IAAI,CAAC;IACjB,SAAS,EAAE,IAAI,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,KAAK,IAAI,MAAM,CAAC;IAChB,UAAU,CAAC,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}
@@ -1,432 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createWorkflowCtx = createWorkflowCtx;
4
- const backoff_1 = require("./backoff");
5
- const checkpoints_1 = require("./checkpoints");
6
- const completion_1 = require("./completion");
7
- const duration_1 = require("./duration");
8
- const errors_1 = require("./errors");
9
- const events_1 = require("./events");
10
- const protocol_1 = require("./protocol");
11
- const step_logger_1 = require("./step-logger");
12
- const workflow_ref_1 = require("./workflow-ref");
13
- /** The per-run logical position counter. `rewind()` gives a position back (see `ctx.patched`). */
14
- class Position {
15
- seq = -1;
16
- next() {
17
- this.seq += 1;
18
- return this.seq;
19
- }
20
- rewind() {
21
- this.seq -= 1;
22
- }
23
- }
24
- /**
25
- * Build the {@link WorkflowCtx} handed to a workflow body. Every primitive is a closure over the
26
- * position counter (the per-run logical position) and the saga `compensations` stack, so `task`/
27
- * `child` compose `step`/`waitForSignal` directly. All durability goes through {@link CtxHost}, so
28
- * the workflow body stays deterministic.
29
- */
30
- function createWorkflowCtx(host, runId, compensations, workflow = '') {
31
- const { store } = host;
32
- const pos = new Position();
33
- const step = async (name, fn, options) => {
34
- const current = pos.next();
35
- const existing = await store.getCheckpoint(runId, current);
36
- if (existing && existing.name !== name) {
37
- throw new errors_1.NonDeterminismError(runId, current, name, existing.name);
38
- }
39
- if (existing && existing.status === 'completed') {
40
- // Register the compensation on replay too, so a saga undoes ALL completed steps — even
41
- // those done in an earlier (since-suspended) pass — not just the ones run this pass.
42
- if (options?.compensate)
43
- compensations.push({ name, fn: options.compensate });
44
- return existing.output;
45
- }
46
- const maxAttempts = Math.max(1, options?.retries ?? 1);
47
- const startedAt = new Date();
48
- // Announce the body has begun (and, when enabled, checkpoint it `running`) so the step is
49
- // visible in flight — not only once it settles. Skipped on replay: a completed step returns
50
- // above before reaching here, so this fires once, when the body actually first runs.
51
- await host.startStep({
52
- runId,
53
- seq: current,
54
- name,
55
- kind: 'local',
56
- attempts: 1,
57
- enqueuedAt: startedAt,
58
- startedAt,
59
- });
60
- for (let attempt = 1;; attempt += 1) {
61
- // Events are scoped per attempt — a retry starts a clean log, so the checkpoint reflects
62
- // only the attempt that actually completed (or the final failing one).
63
- const events = [];
64
- try {
65
- const invocation = {
66
- runId,
67
- workflow,
68
- stepName: name,
69
- seq: current,
70
- attempt,
71
- };
72
- const body = () => fn((0, step_logger_1.createStepLogger)(events, host.clock));
73
- const output = host.interceptStep
74
- ? await host.interceptStep(invocation, body)
75
- : await body();
76
- await host.completeStep({
77
- runId,
78
- seq: current,
79
- name,
80
- kind: 'local',
81
- output,
82
- events,
83
- attempts: attempt,
84
- enqueuedAt: startedAt,
85
- startedAt,
86
- });
87
- if (options?.compensate)
88
- compensations.push({ name, fn: options.compensate });
89
- return output;
90
- }
91
- catch (err) {
92
- if (err instanceof errors_1.FatalError || attempt >= maxAttempts) {
93
- await host.failStep({
94
- runId,
95
- seq: current,
96
- name,
97
- kind: 'local',
98
- error: {
99
- message: err instanceof Error ? err.message : String(err),
100
- stack: err instanceof Error ? err.stack : undefined,
101
- },
102
- events,
103
- attempts: attempt,
104
- enqueuedAt: startedAt,
105
- startedAt,
106
- });
107
- throw err;
108
- }
109
- // Wait out the backoff before the next attempt (no-op when backoffMs is unset).
110
- const wait = (0, backoff_1.backoffDelay)(attempt, options);
111
- if (wait > 0)
112
- await new Promise((resolve) => setTimeout(resolve, wait));
113
- }
114
- }
115
- };
116
- // Exactly-once DB step: run the body and write the step checkpoint in ONE store transaction, so the
117
- // business write commits atomically with the "done" marker (a plain step checkpoints AFTER the body,
118
- // so a crash in between re-runs it). Replay returns the recorded output without re-running.
119
- const transaction = async (name, fn) => {
120
- if (!store.transaction) {
121
- throw new Error('ctx.transaction needs a store that supports transactions (the SQL adapters do). Use ctx.step for non-transactional work.');
122
- }
123
- const current = pos.next();
124
- const existing = await store.getCheckpoint(runId, current);
125
- if (existing && existing.name !== name) {
126
- throw new errors_1.NonDeterminismError(runId, current, name, existing.name);
127
- }
128
- if (existing && existing.status === 'completed')
129
- return existing.output;
130
- return store.transaction(async (tx) => {
131
- const output = await fn(tx.raw);
132
- await tx.saveCheckpoint((0, checkpoints_1.instantCheckpoint)({ runId, seq: current, name, kind: 'local', output }));
133
- return output;
134
- });
135
- };
136
- // Shared by sleep / sleepUntil: record a durable timer at this position and suspend until `wakeAt`
137
- // (epoch ms). The wakeAt is computed by the caller — but only used on the first run; on replay the
138
- // recorded checkpoint's wakeAt wins, so a clock change can't shift an already-scheduled timer.
139
- const suspendUntil = async (wakeAt) => {
140
- const current = pos.next();
141
- const now = host.clock();
142
- const existing = await store.getCheckpoint(runId, current);
143
- if (existing) {
144
- // Timer already recorded: resume if due, otherwise re-suspend cheaply.
145
- if (now >= (existing.wakeAt ?? 0))
146
- return;
147
- throw new errors_1.WorkflowSuspended(existing.wakeAt ?? now);
148
- }
149
- const at = wakeAt();
150
- await store.saveCheckpoint((0, checkpoints_1.instantCheckpoint)({ runId, seq: current, name: 'sleep', kind: 'sleep', wakeAt: at }));
151
- throw new errors_1.WorkflowSuspended(at);
152
- };
153
- const sleep = (duration) => suspendUntil(() => host.clock() + (0, duration_1.parseDuration)(duration));
154
- const sleepUntil = (when) => suspendUntil(() => (typeof when === 'number' ? when : when.getTime()));
155
- // End this run and hand off to a fresh execution (clean history) with the new input. Terminal —
156
- // it always throws, so any code after it in the workflow is unreachable.
157
- const continueAsNew = (input) => {
158
- throw new errors_1.ContinueAsNew(input);
159
- };
160
- // NOTE (determinism): a bounded wait consumes TWO logical positions (deadline + wait), an
161
- // unbounded one consumes ONE. So adding or removing `{ timeoutMs }` on an existing `waitForSignal`
162
- // shifts the seq of every later step — treat it as a workflow-version change for in-flight runs.
163
- // Consume a buffered signal (one delivered before this run was waiting), recording it as the
164
- // signal checkpoint at `seq` so it resumes immediately instead of suspending. Replay-safe: the
165
- // checkpoint makes the consumption deterministic.
166
- const consumeBuffered = async (token, seq) => {
167
- const buffered = await store.takeBufferedSignal(token);
168
- if (!buffered)
169
- return null;
170
- await store.saveCheckpoint((0, checkpoints_1.instantCheckpoint)({
171
- runId,
172
- seq,
173
- name: `signal:${token}`,
174
- kind: 'signal',
175
- output: buffered.payload,
176
- }));
177
- return { value: buffered.payload };
178
- };
179
- const waitForSignal = async (token, opts) => {
180
- if (opts?.timeoutMs == null) {
181
- const current = pos.next();
182
- const existing = await store.getCheckpoint(runId, current);
183
- if (existing && existing.status === 'completed')
184
- return existing.output;
185
- const buffered = await consumeBuffered(token, current);
186
- if (buffered)
187
- return buffered.value;
188
- await store.putSignalWaiter({ token, runId, seq: current });
189
- throw new errors_1.WorkflowSuspended();
190
- }
191
- const timeoutMs = opts.timeoutMs;
192
- const deadlineSeq = pos.next();
193
- const waitSeq = pos.next();
194
- // The deadline is recorded durably as a timer checkpoint so replay knows it; the run also gets a
195
- // run-level wakeAt (via WorkflowSuspended) so the timer poller resumes it at the deadline.
196
- const recorded = await store.getCheckpoint(runId, deadlineSeq);
197
- const deadline = recorded?.wakeAt ?? host.clock() + timeoutMs;
198
- if (!recorded) {
199
- await store.saveCheckpoint((0, checkpoints_1.instantCheckpoint)({
200
- runId,
201
- seq: deadlineSeq,
202
- name: `timeout:${token}`,
203
- kind: 'sleep',
204
- wakeAt: deadline,
205
- }));
206
- }
207
- const waited = await store.getCheckpoint(runId, waitSeq);
208
- if (waited && waited.status === 'completed')
209
- return waited.output;
210
- const buffered = await consumeBuffered(token, waitSeq);
211
- if (buffered)
212
- return buffered.value;
213
- if (host.clock() >= deadline) {
214
- await store.takeSignalWaiter(token).catch(() => undefined);
215
- throw new errors_1.SignalTimeoutError(token, timeoutMs);
216
- }
217
- await store.putSignalWaiter({ token, runId, seq: waitSeq });
218
- throw new errors_1.WorkflowSuspended(deadline);
219
- };
220
- // Wait for a named event delivered by engine.publishEvent(name, payload). Like waitForSignal, but
221
- // name-based pub/sub with optional `match` filtering — the token embeds name + match (see events.ts),
222
- // so a publish fans out to the runs whose match the payload satisfies.
223
- const waitForEvent = async (name, opts) => {
224
- if (opts?.timeoutMs == null) {
225
- const current = pos.next();
226
- const token = (0, events_1.eventToken)(name, opts?.match, runId, current);
227
- const existing = await store.getCheckpoint(runId, current);
228
- if (existing && existing.status === 'completed')
229
- return existing.output;
230
- await store.putSignalWaiter({ token, runId, seq: current });
231
- throw new errors_1.WorkflowSuspended();
232
- }
233
- const timeoutMs = opts.timeoutMs;
234
- const deadlineSeq = pos.next();
235
- const waitSeq = pos.next();
236
- const token = (0, events_1.eventToken)(name, opts.match, runId, waitSeq);
237
- const recorded = await store.getCheckpoint(runId, deadlineSeq);
238
- const deadline = recorded?.wakeAt ?? host.clock() + timeoutMs;
239
- if (!recorded) {
240
- await store.saveCheckpoint((0, checkpoints_1.instantCheckpoint)({
241
- runId,
242
- seq: deadlineSeq,
243
- name: `timeout:event:${name}`,
244
- kind: 'sleep',
245
- wakeAt: deadline,
246
- }));
247
- }
248
- const waited = await store.getCheckpoint(runId, waitSeq);
249
- if (waited && waited.status === 'completed')
250
- return waited.output;
251
- if (host.clock() >= deadline) {
252
- await store.takeSignalWaiter(token).catch(() => undefined);
253
- throw new errors_1.SignalTimeoutError(`event:${name}`, timeoutMs);
254
- }
255
- await store.putSignalWaiter({ token, runId, seq: waitSeq });
256
- throw new errors_1.WorkflowSuspended(deadline);
257
- };
258
- // An external task = a checkpointed dispatch + a wait for its async-completion `Completion`
259
- // (delivered by engine.completeTask/failTask). The whole "fire at a foreign system, suspend,
260
- // resume when it reports back" pattern as one call.
261
- const task = async (name, dispatch, options) => {
262
- await step(`task:dispatch:${name}`, dispatch, options);
263
- return (0, completion_1.unwrapCompletion)(await waitForSignal(`task:${runId}:${name}`), `task "${name}"`);
264
- };
265
- // Child workflow (await result): start it once, then suspend on a `child:<id>` waiter the child
266
- // signals on its terminal state (see engine.notifyParent).
267
- const child = async (workflow, input, childId) => {
268
- const current = pos.next();
269
- const id = childId ?? `${runId}.child.${current}`;
270
- const existing = await store.getCheckpoint(runId, current);
271
- if (existing && existing.status === 'completed') {
272
- return (0, completion_1.unwrapCompletion)(existing.output, `child "${id}"`);
273
- }
274
- await store.putSignalWaiter({ token: `child:${id}`, runId, seq: current });
275
- if (!(await store.getRun(id)))
276
- host.startChild((0, workflow_ref_1.workflowName)(workflow), input, id);
277
- // Make the awaited child visible in the parent's timeline WHILE it runs: a `running` placeholder
278
- // at this seq with the same `signal:child:<id>` name the signal resolution later overwrites as
279
- // `completed`. So the dashboard shows the child node (and can inline-expand it) live, instead of
280
- // it appearing only when it finishes. Written once (skipped on replay, where `existing` is set);
281
- // `running` is ignored by replay history, so it never short-circuits determinism.
282
- if (!existing) {
283
- await store.saveCheckpoint((0, checkpoints_1.instantCheckpoint)({
284
- runId,
285
- seq: current,
286
- name: `signal:child:${id}`,
287
- kind: 'signal',
288
- status: 'running',
289
- }));
290
- }
291
- throw new errors_1.WorkflowSuspended();
292
- };
293
- // Child workflow (fire-and-forget): dispatch it once and return its id WITHOUT suspending. The
294
- // start is checkpointed at this position so replay returns the same id without re-dispatching, and
295
- // is idempotent by id, so `child(..., sameId)` later joins the same run rather than starting a new
296
- // one (start + join scatter-gather).
297
- const startChild = async (workflow, input, childId) => {
298
- const current = pos.next();
299
- const id = childId ?? `${runId}.child.${current}`;
300
- const existing = await store.getCheckpoint(runId, current);
301
- if (existing && existing.status === 'completed')
302
- return existing.output;
303
- if (!(await store.getRun(id)))
304
- host.startChild((0, workflow_ref_1.workflowName)(workflow), input, id);
305
- await store.saveCheckpoint((0, checkpoints_1.instantCheckpoint)({ runId, seq: current, name: `spawn:${id}`, kind: 'local', output: id }));
306
- return id;
307
- };
308
- // Call a durable entity op and await its result: register a reply waiter at this position, dispatch
309
- // the op with the reply token, and suspend until the entity signals the result back (checkpointed,
310
- // so replay returns it without re-dispatching).
311
- const callEntity = async (name, key, op, arg) => {
312
- const current = pos.next();
313
- const existing = await store.getCheckpoint(runId, current);
314
- if (existing && existing.status === 'completed')
315
- return existing.output;
316
- const reply = `entityreply:${runId}:${current}`;
317
- await store.putSignalWaiter({ token: reply, runId, seq: current });
318
- host.signalEntity?.(name, key, op, arg, reply);
319
- throw new errors_1.WorkflowSuspended();
320
- };
321
- // Send a durable entity op without awaiting a result — dispatched once (checkpointed, replay-safe).
322
- const signalEntity = async (name, key, op, arg) => {
323
- const current = pos.next();
324
- const existing = await store.getCheckpoint(runId, current);
325
- if (existing && existing.status === 'completed')
326
- return;
327
- host.signalEntity?.(name, key, op, arg);
328
- await store.saveCheckpoint((0, checkpoints_1.instantCheckpoint)({ runId, seq: current, name: `entitysig:${name}:${key}`, kind: 'local' }));
329
- };
330
- // A breakpoint = a visible `pending` checkpoint + a signal waiter the dashboard resumes via
331
- // `engine.continue`. Reuses the signal machinery, so resume overwrites the pending checkpoint
332
- // with a completed one and the run replays past it.
333
- const breakpoint = async (label) => {
334
- const current = pos.next();
335
- const existing = await store.getCheckpoint(runId, current);
336
- if (existing && existing.status === 'completed')
337
- return;
338
- if (!existing) {
339
- await store.saveCheckpoint((0, checkpoints_1.instantCheckpoint)({
340
- runId,
341
- seq: current,
342
- name: label ? `breakpoint:${label}` : 'breakpoint',
343
- kind: 'signal',
344
- status: 'pending',
345
- }));
346
- await store.putSignalWaiter({ token: (0, protocol_1.breakpointToken)(runId, current), runId, seq: current });
347
- }
348
- throw new errors_1.WorkflowSuspended();
349
- };
350
- // Guard an in-place change: a fresh run records a `patch:<id>` marker here and takes the new
351
- // branch; a run recorded under the OLD code finds a real step at this position instead, so we
352
- // rewind the logical position (the marker is transparent to it) and return false — its replay
353
- // reads that old step next and follows the old branch. No position shift → no corruption.
354
- const patched = async (id) => {
355
- const marker = `patch:${id}`;
356
- const current = pos.next();
357
- const existing = await store.getCheckpoint(runId, current);
358
- if (existing) {
359
- if (existing.name === marker)
360
- return true;
361
- if (existing.name.startsWith('patch:')) {
362
- throw new errors_1.NonDeterminismError(runId, current, marker, existing.name);
363
- }
364
- pos.rewind(); // not a marker: an old run's step lives here — give the position back to it
365
- return false;
366
- }
367
- await store.saveCheckpoint((0, checkpoints_1.instantCheckpoint)({ runId, seq: current, name: marker, kind: 'local', output: true }));
368
- return true;
369
- };
370
- // An update point: suspend on a run-scoped `update:<runId>:<name>` token that engine.update
371
- // delivers to (after its validator passes). Reuses the signal machinery; run-scoped like task/child.
372
- const onUpdate = (name, opts) => waitForSignal(`update:${runId}:${name}`, opts);
373
- // A queryable named value: a checkpoint whose `name` is `event:<key>`, so the latest value for a
374
- // key is just the highest-seq such checkpoint (read by engine.getEvent). Replay-idempotent.
375
- const setEvent = async (key, value) => {
376
- const current = pos.next();
377
- const name = `event:${key}`;
378
- const existing = await store.getCheckpoint(runId, current);
379
- if (existing && existing.name !== name) {
380
- throw new errors_1.NonDeterminismError(runId, current, name, existing.name);
381
- }
382
- if (existing && existing.status === 'completed')
383
- return; // replay: already published
384
- await store.saveCheckpoint((0, checkpoints_1.instantCheckpoint)({ runId, seq: current, name, kind: 'local', output: value }));
385
- };
386
- // A durable webhook reserves a logical position NOW to mint a stable token, so the url can be
387
- // handed to a third party before `wait()` suspends. `wait()` then parks on that same position
388
- // until the callback lands as engine.signal(token, body) — single position, replay-safe.
389
- const webhook = () => {
390
- const current = pos.next();
391
- const token = `wh:${runId}:${current}`;
392
- const wait = async () => {
393
- const existing = await store.getCheckpoint(runId, current);
394
- if (existing && existing.status === 'completed')
395
- return existing.output;
396
- await store.putSignalWaiter({ token, runId, seq: current });
397
- throw new errors_1.WorkflowSuspended();
398
- };
399
- return { token, url: host.webhookUrl?.(token), wait };
400
- };
401
- // Deterministic non-deterministic sources: each is a checkpointed local step, so the value is
402
- // captured on the first run and replayed verbatim (a raw Date.now()/Math.random() inside a
403
- // workflow would differ across replays and corrupt the run).
404
- const now = () => step('now', async () => host.clock());
405
- const random = () => step('random', async () => Math.random());
406
- const uuid = () => step('uuid', async () => globalThis.crypto.randomUUID());
407
- return {
408
- runId,
409
- step,
410
- transaction,
411
- callEntity,
412
- signalEntity,
413
- sleep,
414
- sleepUntil,
415
- continueAsNew,
416
- waitForSignal,
417
- waitForEvent,
418
- task,
419
- child,
420
- startChild,
421
- breakpoint,
422
- webhook,
423
- setEvent,
424
- onUpdate,
425
- patched,
426
- now,
427
- random,
428
- uuid,
429
- call: (remote, input, opts) => host.callRemote(runId, pos.next(), remote, input, opts?.queue, opts?.transport),
430
- };
431
- }
432
- //# sourceMappingURL=workflow-ctx.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow-ctx.js","sourceRoot":"","sources":["../src/workflow-ctx.ts"],"names":[],"mappings":";;AA+FA,8CA0cC;AAziBD,uCAAyC;AACzC,+CAAkD;AAClD,6CAAgD;AAChD,yCAA2C;AAC3C,qCAMkB;AAClB,qCAAsC;AAatC,yCAA6C;AAC7C,+CAAiD;AACjD,iDAAgE;AAmDhE,kGAAkG;AAClG,MAAM,QAAQ;IACJ,GAAG,GAAG,CAAC,CAAC,CAAC;IACjB,IAAI;QACF,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QACd,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IACD,MAAM;QACJ,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IAChB,CAAC;CACF;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,IAAa,EACb,KAAa,EACb,aAA6B,EAC7B,QAAQ,GAAG,EAAE;IAEb,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IACvB,MAAM,GAAG,GAAG,IAAI,QAAQ,EAAE,CAAC;IAE3B,MAAM,IAAI,GAAG,KAAK,EAChB,IAAY,EACZ,EAAmC,EACnC,OAAqB,EACT,EAAE;QACd,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC3D,IAAI,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;YACvC,MAAM,IAAI,4BAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,E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AE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC;KAClF,CAAC;AACJ,CAAC"}
@@ -1,34 +0,0 @@
1
- /**
2
- * A **workflow reference** is how one workflow names another to call it: either a registered workflow
3
- * **name** (a string — the only option across runtimes, e.g. a Python workflow) or, for a same-runtime
4
- * TypeScript workflow, its **class**. The class carries the input/output types through the call, so
5
- * `ctx.child(ShippingWorkflow, input)` type-checks the input and returns a typed result — while a
6
- * string stays available for the cross-runtime case.
7
- */
8
- /**
9
- * The symbol the `@Workflow` decorator stamps a workflow's registered name onto, so a class ref can
10
- * be resolved back to its name. A global-registry symbol (`Symbol.for`) so it survives duplicate
11
- * copies of this package in a dependency tree.
12
- */
13
- export declare const WORKFLOW_NAME_KEY: unique symbol;
14
- /** Structural shape of a `@Workflow` class — its `run(ctx, input)` carries the input/output types. */
15
- export type WorkflowClass<TInput = unknown, TOutput = unknown> = abstract new (...args: never[]) => {
16
- run(ctx: never, input: TInput): Promise<TOutput> | TOutput;
17
- };
18
- /** A workflow reference: a registered name (cross-runtime) or a workflow class (typed, same-runtime). */
19
- export type WorkflowRef<TInput = unknown, TOutput = unknown> = string | WorkflowClass<TInput, TOutput>;
20
- /** The input type a workflow class's `run` accepts. */
21
- export type WorkflowInputOf<C> = C extends abstract new (...args: never[]) => {
22
- run(ctx: never, input: infer I): unknown;
23
- } ? I : unknown;
24
- /** The output type a workflow class's `run` resolves to (Promise unwrapped). */
25
- export type WorkflowOutputOf<C> = C extends abstract new (...args: never[]) => {
26
- run(ctx: never, input: never): infer R;
27
- } ? Awaited<R> : unknown;
28
- /**
29
- * Resolve a {@link WorkflowRef} to its registered workflow name: a string is returned as-is; a
30
- * `@Workflow` class is resolved via the name the decorator stamped on it. Throws if a class was
31
- * never decorated (so it carries no registered name).
32
- */
33
- export declare function workflowName(ref: WorkflowRef): string;
34
- //# sourceMappingURL=workflow-ref.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow-ref.d.ts","sourceRoot":"","sources":["../src/workflow-ref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,OAAO,MAAmD,CAAC;AAE3F,sGAAsG;AACtG,MAAM,MAAM,aAAa,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,QAAQ,MACvE,GAAG,IAAI,EAAE,KAAK,EAAE,KACb;IACH,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CAC5D,CAAC;AAEF,yGAAyG;AACzG,MAAM,MAAM,WAAW,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,IACvD,MAAM,GACN,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEnC,uDAAuD;AACvD,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,SAAS,QAAQ,MACjD,GAAG,IAAI,EAAE,KAAK,EAAE,KACb;IACH,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC;CAC1C,GACG,CAAC,GACD,OAAO,CAAC;AAEZ,gFAAgF;AAChF,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,SAAS,QAAQ,MAClD,GAAG,IAAI,EAAE,KAAK,EAAE,KACb;IACH,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC,CAAC;CACxC,GACG,OAAO,CAAC,CAAC,CAAC,GACV,OAAO,CAAC;AAEZ;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CASrD"}