@fluidgrids/workflows 2026.1028.2 → 2026.1030.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 (154) hide show
  1. package/README.md +181 -11
  2. package/dist/{activation-BBh1p82z.d.cts → activation-DqUfpHzk.d.cts} +1 -1
  3. package/dist/{activation-DnhG7SmF.d.ts → activation-xpx1oWuo.d.ts} +1 -1
  4. package/dist/{chunk-VRHHBPT6.js → chunk-2D3MYIIF.js} +1212 -128
  5. package/dist/chunk-3U2NU7YC.cjs +124 -0
  6. package/dist/{chunk-NEIUQASE.cjs → chunk-4QKB4ARC.cjs} +3 -3
  7. package/dist/{chunk-GBQ33SIZ.cjs → chunk-54FLQNUM.cjs} +12 -1
  8. package/dist/chunk-5HIVIV53.js +330 -0
  9. package/dist/chunk-5MFVJM76.js +1222 -0
  10. package/dist/{chunk-JD2VQIDZ.cjs → chunk-672KMMBK.cjs} +2 -2
  11. package/dist/{chunk-C5OLWZ42.js → chunk-6A2FGSUS.js} +22 -14
  12. package/dist/{chunk-XKJA7KX3.js → chunk-6OLN6BMB.js} +52 -3
  13. package/dist/{chunk-6FSHT5IL.js → chunk-7EZIANC7.js} +1 -1
  14. package/dist/{chunk-2J6TF7YI.cjs → chunk-A5SXCA62.cjs} +10 -3
  15. package/dist/{chunk-BO6OVILK.js → chunk-AC6ZEXVR.js} +10 -4
  16. package/dist/{chunk-ABFZWYHT.js → chunk-AE5Q6ZAJ.js} +315 -50
  17. package/dist/chunk-C4F5KJTI.js +293 -0
  18. package/dist/{chunk-IISBRUWJ.js → chunk-G5H32GIG.js} +1 -1
  19. package/dist/chunk-GEQDGUGB.cjs +2719 -0
  20. package/dist/{chunk-XHXIDVEC.js → chunk-HCM7ZC7Q.js} +1 -1
  21. package/dist/chunk-HMZUGSMU.cjs +1554 -0
  22. package/dist/{chunk-SAOBPYYJ.cjs → chunk-IQPXHQQQ.cjs} +8 -4
  23. package/dist/{chunk-P6TA5EZT.cjs → chunk-ISOIA7NV.cjs} +335 -58
  24. package/dist/chunk-JSC75O5C.cjs +167 -0
  25. package/dist/chunk-M272AHEX.js +25 -0
  26. package/dist/{chunk-BD7ZPG53.js → chunk-NWQ5WRLE.js} +10 -2
  27. package/dist/chunk-ODZ2IAR2.cjs +1247 -0
  28. package/dist/chunk-Q4MWQNJK.cjs +28 -0
  29. package/dist/{chunk-HWJZVOG7.js → chunk-SR7TR5KX.js} +6 -2
  30. package/dist/{chunk-FEW3JBYA.cjs → chunk-TCTE7DX5.cjs} +3 -3
  31. package/dist/{chunk-623FVQSN.cjs → chunk-TYF56RGB.cjs} +123 -0
  32. package/dist/chunk-VA4OFR72.cjs +324 -0
  33. package/dist/chunk-VU5S5A7V.js +150 -0
  34. package/dist/chunk-YEHR4NNE.js +1522 -0
  35. package/dist/{chunk-FMSW2HDF.cjs → chunk-ZCGKGDCL.cjs} +23 -15
  36. package/dist/codegen/index.d.cts +2 -2
  37. package/dist/codegen/index.d.ts +2 -2
  38. package/dist/collect-6NIEufHd.d.ts +103 -0
  39. package/dist/collect-CcTCKqx6.d.cts +103 -0
  40. package/dist/{file-BOoHZgoQ.d.cts → file-BxYpwjRQ.d.cts} +1007 -21
  41. package/dist/{file-yuPCFU5b.d.ts → file-CFdPQJI9.d.ts} +1007 -21
  42. package/dist/history/index.cjs +375 -86
  43. package/dist/history/index.d.cts +590 -12
  44. package/dist/history/index.d.ts +590 -12
  45. package/dist/history/index.js +50 -4
  46. package/dist/index.cjs +156 -50
  47. package/dist/index.d.cts +38 -58
  48. package/dist/index.d.ts +38 -58
  49. package/dist/index.js +6 -4
  50. package/dist/interceptors-CNcr2dlk.d.ts +159 -0
  51. package/dist/interceptors-CqkNZVfI.d.cts +159 -0
  52. package/dist/ir/index.cjs +362 -38
  53. package/dist/ir/index.d.cts +282 -7
  54. package/dist/ir/index.d.ts +282 -7
  55. package/dist/ir/index.js +329 -23
  56. package/dist/{lower-BzmUz0sq.d.cts → lower-BtRfIW2A.d.cts} +56 -8
  57. package/dist/{lower-_-iT4HYs.d.ts → lower-CpsMFOFX.d.ts} +56 -8
  58. package/dist/{manifest-C8N6HDYl.d.ts → manifest-D-I_twys.d.ts} +1 -1
  59. package/dist/{manifest-0OLw0i7k.d.cts → manifest-DahBQVM8.d.cts} +1 -1
  60. package/dist/node-evaluator-DGQDPSPI.cjs +24 -0
  61. package/dist/node-evaluator-LEEVD7H7.js +14 -0
  62. package/dist/payload-fields-BVRQn2yH.d.cts +122 -0
  63. package/dist/payload-fields-oOBWxDiG.d.ts +122 -0
  64. package/dist/quickjs/index.cjs +28 -27
  65. package/dist/quickjs/index.d.cts +6 -6
  66. package/dist/quickjs/index.d.ts +6 -6
  67. package/dist/quickjs/index.js +10 -9
  68. package/dist/roundtrip/index.cjs +259 -51
  69. package/dist/roundtrip/index.d.cts +100 -9
  70. package/dist/roundtrip/index.d.ts +100 -9
  71. package/dist/roundtrip/index.js +177 -11
  72. package/dist/runtime/index.cjs +21 -20
  73. package/dist/runtime/index.d.cts +184 -15
  74. package/dist/runtime/index.d.ts +184 -15
  75. package/dist/runtime/index.js +8 -7
  76. package/dist/testing/index.cjs +1122 -115
  77. package/dist/testing/index.d.cts +294 -13
  78. package/dist/testing/index.d.ts +294 -13
  79. package/dist/testing/index.js +1086 -84
  80. package/dist/{types-DV-HX_Gt.d.ts → types-Bv2i4cBX.d.cts} +244 -33
  81. package/dist/{types-CpBBjaGX.d.cts → types-DGx-b9eq.d.ts} +244 -33
  82. package/dist/{types-BGoPzgcl.d.ts → types-V7jEEUaL.d.cts} +20 -1
  83. package/dist/{types-BGoPzgcl.d.cts → types-V7jEEUaL.d.ts} +20 -1
  84. package/dist/{workflow-Bpr3vnA_.d.ts → workflow-B18OeF7g.d.ts} +2 -2
  85. package/dist/workflow-BGnv8SS6.d.ts +803 -0
  86. package/dist/{workflow-FXUkpIBc.d.cts → workflow-BJPFv3cp.d.cts} +2 -2
  87. package/dist/workflow-DS32Gtws.d.cts +803 -0
  88. package/fixtures/histories/activity-options-updated.history.json +159 -0
  89. package/fixtures/histories/activity-paused-unpaused.history.json +160 -0
  90. package/fixtures/histories/auto-upgrade-patched.history.json +276 -0
  91. package/fixtures/histories/benign-failure.history.json +146 -0
  92. package/fixtures/histories/cancel-activity-try-cancel.history.json +150 -0
  93. package/fixtures/histories/child-cancel-wait-requested.history.json +217 -0
  94. package/fixtures/histories/child-options-roundtrip.history.json +192 -0
  95. package/fixtures/histories/codec-opaque.history.json +229 -0
  96. package/fixtures/histories/continue-as-new-last-result.history.json +86 -0
  97. package/fixtures/histories/continue-as-new-options.history.json +99 -0
  98. package/fixtures/histories/continue-as-new-r1-long-task-queue.history.json +78 -0
  99. package/fixtures/histories/continue-as-new-r1-retry-options.history.json +83 -0
  100. package/fixtures/histories/dynamic-workflow.history.json +150 -0
  101. package/fixtures/histories/execution-timeout-chain.history.json +98 -0
  102. package/fixtures/histories/external-cancel-resolved.history.json +123 -0
  103. package/fixtures/histories/external-cancel-unknown-target.history.json +127 -0
  104. package/fixtures/histories/failure-error-types-fails-run.history.json +144 -0
  105. package/fixtures/histories/handler-drain-warn.history.json +222 -0
  106. package/fixtures/histories/heartbeat-details-on-retry.history.json +145 -0
  107. package/fixtures/histories/interceptor-headers.history.json +339 -0
  108. package/fixtures/histories/local-activity-abandoned-at-completion.history.json +73 -0
  109. package/fixtures/histories/local-activity-cancelled-in-scope.history.json +118 -0
  110. package/fixtures/histories/local-activity-completed.history.json +157 -0
  111. package/fixtures/histories/local-activity-failed.history.json +93 -0
  112. package/fixtures/histories/local-activity-retry-in-task.history.json +88 -0
  113. package/fixtures/histories/query-custom.history.json +213 -0
  114. package/fixtures/histories/query-default-handler.history.json +120 -0
  115. package/fixtures/histories/reset-forked-reapplied-signals.history.json +239 -0
  116. package/fixtures/histories/reset-reapplied-update-admitted.history.json +228 -0
  117. package/fixtures/histories/run-retry-last-failure.history.json +90 -0
  118. package/fixtures/histories/run-timeout.history.json +159 -0
  119. package/fixtures/histories/schedule-to-start-timeout.history.json +132 -0
  120. package/fixtures/histories/search-attributes-upserted.history.json +177 -0
  121. package/fixtures/histories/start-delay-signal-ends-delay.history.json +155 -0
  122. package/fixtures/histories/typeerror-task-retry-100.history.json +137 -0
  123. package/fixtures/histories/update-accepted-completed.history.json +45 -30
  124. package/fixtures/histories/update-default-handler.history.json +246 -0
  125. package/fixtures/histories/update-handler-awaits-activity.history.json +196 -0
  126. package/fixtures/histories/update-not-handled.history.json +138 -0
  127. package/fixtures/histories/update-rejected-no-event.history.json +190 -0
  128. package/fixtures/histories/update-with-start-admitted.history.json +150 -0
  129. package/fixtures/histories/user-activity-cancel.history.json +149 -0
  130. package/fixtures/histories/user-activity-retry.history.json +143 -0
  131. package/fixtures/histories/user-activity.history.json +149 -0
  132. package/package.json +1 -1
  133. package/schema/bridge-v2.schema.json +1062 -0
  134. package/schema/history-file.schema.json +538 -83
  135. package/schema/ir-v2.schema.json +290 -0
  136. package/schema/payload-fields.json +162 -0
  137. package/schema/run-event.schema.json +503 -82
  138. package/schema/workflow-command.schema.json +372 -69
  139. package/schema/workflow-task.schema.json +924 -171
  140. package/dist/assemble-BLqQ8lSu.d.cts +0 -39
  141. package/dist/assemble-DWgaXHd-.d.ts +0 -39
  142. package/dist/chunk-DHTLALBL.cjs +0 -80
  143. package/dist/chunk-DJYMDLV5.js +0 -227
  144. package/dist/chunk-I5LR3D2K.js +0 -869
  145. package/dist/chunk-M4BBAERY.cjs +0 -1635
  146. package/dist/chunk-N23SKIG4.js +0 -73
  147. package/dist/chunk-PZCVF76Q.cjs +0 -868
  148. package/dist/chunk-QQ6ULXHI.cjs +0 -885
  149. package/dist/chunk-UK3WM7YZ.cjs +0 -75
  150. package/dist/chunk-VOKMAAJP.js +0 -848
  151. package/dist/node-evaluator-4MSDKWOG.cjs +0 -22
  152. package/dist/node-evaluator-SX4LEYQC.js +0 -12
  153. package/dist/workflow-C2a05WUJ.d.ts +0 -444
  154. package/dist/workflow-J-yYixny.d.cts +0 -444
@@ -1,444 +0,0 @@
1
- import { a as Json, J as JsonObject, W as WorkflowInterface } from './types-BGoPzgcl.cjs';
2
- import { a6 as WorkflowInfoSnapshot, R as RetryPolicy, c as ActivityCancellationType, w as Headers, P as ParentClosePolicy, C as ChildCancellationType } from './types-CpBBjaGX.cjs';
3
-
4
- /**
5
- * Node operation descriptors: what a builder call needs to know about the node
6
- * it emits. Generated clients (`.fluidgrids/nodes.ts`) are lists of these;
7
- * the built-in internal nodes and triggers ship here so `nodes.internal.*` and
8
- * `triggers.*` work without a registry.
9
- */
10
-
11
- /** A file reference in node inputs and outputs. */
12
- interface FileRef {
13
- fileId: string;
14
- name?: string;
15
- mimeType?: string;
16
- size?: number;
17
- }
18
- declare const OPERATION_TYPES: unique symbol;
19
- /** One node operation. `In` and `Out` type the arguments and the output. */
20
- interface Operation<In = Record<string, Json>, Out = Json> {
21
- readonly kind: 'operation';
22
- readonly nodeType: string;
23
- /** Written as the node's `version` unless the call overrides it. */
24
- readonly version?: string;
25
- /** Written as the node's `operation_name` unless the call overrides it. */
26
- readonly operation?: string;
27
- readonly role?: 'trigger';
28
- /** Type-level only; never present at run time. */
29
- readonly [OPERATION_TYPES]?: {
30
- input: In;
31
- output: Out;
32
- };
33
- }
34
- /** A trigger operation. */
35
- type TriggerOperation<In = Record<string, Json>, Out = Json> = Operation<In, Out> & {
36
- readonly role: 'trigger';
37
- };
38
- /** Describe a node operation (generated clients call this). */
39
- declare function op<In = Record<string, Json>, Out = Json>(nodeType: string, version?: string, operation?: string): Operation<In, Out>;
40
- /** Describe a trigger operation (generated clients call this). */
41
- declare function trigger<In = Record<string, Json>, Out = Json>(nodeType: string, version?: string, operation?: string): TriggerOperation<In, Out>;
42
- /** True for a value made by {@link op} or {@link trigger}. */
43
- declare function isOperation(value: unknown): value is Operation<unknown, unknown>;
44
- /** Built-in trigger nodes (`wspace-workflow-svc` `triggers/manifests`). */
45
- declare const triggers: {
46
- readonly api: TriggerOperation<Record<string, Json>, Json>;
47
- readonly manual: TriggerOperation<Record<string, Json>, Json>;
48
- readonly schedule: TriggerOperation<Record<string, Json>, Json>;
49
- readonly webhook: TriggerOperation<Record<string, Json>, Json>;
50
- readonly form: TriggerOperation<Record<string, Json>, Json>;
51
- readonly errorTrigger: TriggerOperation<Record<string, Json>, Json>;
52
- readonly workflowCall: TriggerOperation<Record<string, Json>, Json>;
53
- readonly rssFeed: TriggerOperation<Record<string, Json>, Json>;
54
- readonly httpPoll: TriggerOperation<Record<string, Json>, Json>;
55
- readonly databasePoll: TriggerOperation<Record<string, Json>, Json>;
56
- readonly emailImap: TriggerOperation<Record<string, Json>, Json>;
57
- readonly fileUpload: TriggerOperation<Record<string, Json>, Json>;
58
- readonly recordChange: TriggerOperation<Record<string, Json>, Json>;
59
- readonly stateChange: TriggerOperation<Record<string, Json>, Json>;
60
- };
61
- /** Built-in internal nodes (`wspace-workflow-svc` `internalnodes/manifests`, plus the two IR v2 nodes). */
62
- declare const internalNodes: {
63
- readonly merge: Operation<Record<string, Json>, Json>;
64
- readonly if: Operation<Record<string, Json>, Json>;
65
- readonly switch: Operation<Record<string, Json>, Json>;
66
- readonly loop: Operation<Record<string, Json>, Json>;
67
- readonly set: Operation<Record<string, Json>, Json>;
68
- readonly filter: Operation<Record<string, Json>, Json>;
69
- readonly aggregate: Operation<Record<string, Json>, Json>;
70
- readonly wait: Operation<Record<string, Json>, Json>;
71
- readonly noop: Operation<Record<string, Json>, Json>;
72
- readonly code: Operation<Record<string, Json>, Json>;
73
- readonly http: Operation<Record<string, Json>, Json>;
74
- readonly transform: Operation<Record<string, Json>, Json>;
75
- readonly validate: Operation<Record<string, Json>, Json>;
76
- readonly log: Operation<Record<string, Json>, Json>;
77
- readonly error: Operation<Record<string, Json>, Json>;
78
- readonly subworkflow: Operation<Record<string, Json>, Json>;
79
- readonly compareDatasets: Operation<Record<string, Json>, Json>;
80
- readonly splitOut: Operation<Record<string, Json>, Json>;
81
- readonly limit: Operation<Record<string, Json>, Json>;
82
- readonly dedupe: Operation<Record<string, Json>, Json>;
83
- readonly sort: Operation<Record<string, Json>, Json>;
84
- readonly dataTable: Operation<Record<string, Json>, Json>;
85
- readonly respondToWebhook: Operation<Record<string, Json>, Json>;
86
- readonly sendAndWait: Operation<Record<string, Json>, Json>;
87
- readonly codeWorkflow: Operation<Record<string, Json>, Json>;
88
- readonly waitForSignal: Operation<Record<string, Json>, Json>;
89
- };
90
- /** Node clients that need no registry: the internal nodes and `custom()`. */
91
- declare const nodes: {
92
- readonly internal: {
93
- readonly merge: Operation<Record<string, Json>, Json>;
94
- readonly if: Operation<Record<string, Json>, Json>;
95
- readonly switch: Operation<Record<string, Json>, Json>;
96
- readonly loop: Operation<Record<string, Json>, Json>;
97
- readonly set: Operation<Record<string, Json>, Json>;
98
- readonly filter: Operation<Record<string, Json>, Json>;
99
- readonly aggregate: Operation<Record<string, Json>, Json>;
100
- readonly wait: Operation<Record<string, Json>, Json>;
101
- readonly noop: Operation<Record<string, Json>, Json>;
102
- readonly code: Operation<Record<string, Json>, Json>;
103
- readonly http: Operation<Record<string, Json>, Json>;
104
- readonly transform: Operation<Record<string, Json>, Json>;
105
- readonly validate: Operation<Record<string, Json>, Json>;
106
- readonly log: Operation<Record<string, Json>, Json>;
107
- readonly error: Operation<Record<string, Json>, Json>;
108
- readonly subworkflow: Operation<Record<string, Json>, Json>;
109
- readonly compareDatasets: Operation<Record<string, Json>, Json>;
110
- readonly splitOut: Operation<Record<string, Json>, Json>;
111
- readonly limit: Operation<Record<string, Json>, Json>;
112
- readonly dedupe: Operation<Record<string, Json>, Json>;
113
- readonly sort: Operation<Record<string, Json>, Json>;
114
- readonly dataTable: Operation<Record<string, Json>, Json>;
115
- readonly respondToWebhook: Operation<Record<string, Json>, Json>;
116
- readonly sendAndWait: Operation<Record<string, Json>, Json>;
117
- readonly codeWorkflow: Operation<Record<string, Json>, Json>;
118
- readonly waitForSignal: Operation<Record<string, Json>, Json>;
119
- };
120
- /**
121
- * Any node type, including ones the registry snapshot does not know. Typed
122
- * as JSON in and out.
123
- */
124
- readonly custom: (nodeType: string, operation?: string, version?: string) => Operation<Record<string, Json>, Json>;
125
- };
126
-
127
- /**
128
- * Signal, query and update definitions (spec 02 §4, 05). Signals work in Phase
129
- * B; queries and updates can be declared (they appear in the interface) but
130
- * custom handlers are Phase C.
131
- */
132
- declare const PAYLOAD: unique symbol;
133
- interface SignalDefinition<Payload = unknown> {
134
- readonly kind: 'signal';
135
- readonly name: string;
136
- readonly description?: string;
137
- /** JSON Schema of the payload, written into the workflow interface. */
138
- readonly schema?: Record<string, unknown>;
139
- /** Type-level only. */
140
- readonly [PAYLOAD]?: Payload;
141
- }
142
- interface QueryDefinition<Result = unknown, Args = unknown> {
143
- readonly kind: 'query';
144
- readonly name: string;
145
- readonly description?: string;
146
- readonly [PAYLOAD]?: {
147
- result: Result;
148
- args: Args;
149
- };
150
- }
151
- interface UpdateDefinition<Args = unknown, Result = unknown> {
152
- readonly kind: 'update';
153
- readonly name: string;
154
- readonly description?: string;
155
- readonly [PAYLOAD]?: {
156
- result: Result;
157
- args: Args;
158
- };
159
- }
160
- interface DefinitionOptions {
161
- description?: string;
162
- schema?: Record<string, unknown>;
163
- }
164
- /** Declare a signal. */
165
- declare function defineSignal<Payload = unknown>(name: string, options?: DefinitionOptions): SignalDefinition<Payload>;
166
- /** Declare a query. Handlers are Phase C; the declaration appears in the interface. */
167
- declare function defineQuery<Result = unknown, Args = unknown>(name: string, options?: {
168
- description?: string;
169
- }): QueryDefinition<Result, Args>;
170
- /** Declare an update. Handlers are Phase C; the declaration appears in the interface. */
171
- declare function defineUpdate<Args = unknown, Result = unknown>(name: string, options?: {
172
- description?: string;
173
- }): UpdateDefinition<Args, Result>;
174
-
175
- /** A duration: milliseconds, or a string such as `'30s'` or `'PT2H'`. */
176
- type Duration = number | string;
177
- /** Milliseconds of `value`; throws a `TypeError` naming `what` when it is not a duration. */
178
- declare function toMs(value: Duration, what?: string): number;
179
-
180
- /**
181
- * The `WorkflowContext` a tier-2 workflow function receives (spec 02 §4). The
182
- * runtime (`src/runtime/`) implements it; this module is types only.
183
- */
184
-
185
- /** Options of `ctx.run`. */
186
- interface RunOptions<In> {
187
- args: In;
188
- /** Connection name, resolved by the service at `SCHEDULE_ACTIVITY`. */
189
- connection?: string;
190
- /** Default: 1 s, x2, at most 100 s, unlimited attempts (Temporal's policy). */
191
- retry?: Partial<RetryPolicy>;
192
- startToCloseTimeout?: Duration;
193
- scheduleToCloseTimeout?: Duration;
194
- scheduleToStartTimeout?: Duration;
195
- heartbeatTimeout?: Duration;
196
- cancellationType?: ActivityCancellationType;
197
- /** 1 (highest) to 5; default 3. */
198
- priority?: number;
199
- /** Label in the History tab (at most 200 characters). */
200
- summary?: string;
201
- runOn?: string;
202
- /** Overrides the operation name the descriptor carries. */
203
- operation?: string;
204
- /** Overrides the node version the descriptor carries. */
205
- nodeVersion?: string;
206
- headers?: Headers;
207
- }
208
- /** Options of `ctx.child` and `ctx.startChild` (11 §2.35). */
209
- interface ChildOptions {
210
- input?: unknown;
211
- /** `active` (default), `vN` or `@alias`. */
212
- version?: string;
213
- taskQueue?: string;
214
- /** Default `TERMINATE` for `ctx.child`, `ABANDON` for `ctx.startChild` (DB13). */
215
- parentClosePolicy?: ParentClosePolicy;
216
- /**
217
- * How the awaitable reacts when its scope is cancelled. Unset, it rejects at
218
- * once and the child is left to the parent-close policy; set, the SDK sends
219
- * a cancel request to the child (`REQUEST_CANCEL_EXTERNAL_RUN`, a parity
220
- * command).
221
- */
222
- cancellationType?: ChildCancellationType;
223
- workflowId?: string;
224
- priority?: number;
225
- summary?: string;
226
- details?: string;
227
- context?: JsonObject;
228
- startDelay?: Duration;
229
- executionTimeout?: Duration;
230
- runTimeout?: Duration;
231
- workflowTaskTimeout?: Duration;
232
- headers?: Headers;
233
- }
234
- /** A started child run. */
235
- interface ChildHandle<Out = Json> {
236
- readonly childId: string;
237
- readonly runId: string;
238
- result(): Promise<Out>;
239
- signal<P>(signal: SignalDefinition<P> | string, payload?: P): Promise<void>;
240
- /** Request cancellation of the child (parity command `REQUEST_CANCEL_EXTERNAL_RUN`). */
241
- cancel(): Promise<void>;
242
- }
243
- /** A handle to another run of the workspace (11 §2.24). */
244
- interface ExternalRunHandle {
245
- readonly runId: string;
246
- signal<P>(signal: SignalDefinition<P> | string, payload?: P): Promise<void>;
247
- /** Resolves when the cancel request was delivered, not when the run ends. */
248
- cancel(): Promise<void>;
249
- }
250
- /** A cancellation scope (11 §2.24). */
251
- interface CancellationScope {
252
- /** Rejects with `CancelledFailure` when the scope is cancelled. */
253
- readonly cancelRequested: Promise<never>;
254
- readonly consideredCancelled: boolean;
255
- cancel(): void;
256
- }
257
- interface CancellationScopeOptions {
258
- /** A durable timer that cancels the scope when it fires. */
259
- timeout?: Duration;
260
- nonCancellable?: boolean;
261
- }
262
- /** `ctx.cancellationScope(fn, options)` and `ctx.cancellationScope.current()`. */
263
- interface CancellationScopeFunction {
264
- <T>(fn: (ctx: WorkflowContext) => Promise<T>, options?: CancellationScopeOptions): Promise<T>;
265
- current(): CancellationScope;
266
- }
267
- /** What workflow code knows about its run. */
268
- interface WorkflowInfo extends WorkflowInfoSnapshot {
269
- readonly workflowFn: string;
270
- /** Events in the history when the current workflow task started. */
271
- readonly historyLength: number;
272
- /** UTF-8 bytes of their payloads. */
273
- readonly historyBytes: number;
274
- /** True from 80 % of the history cap; continue as new soon. */
275
- readonly continueAsNewSuggested: boolean;
276
- readonly isReplaying: boolean;
277
- }
278
- /** Logging from workflow code; lines are emitted once, never during replay. */
279
- interface WorkflowLogger {
280
- debug(message: string, data?: Json): void;
281
- info(message: string, data?: Json): void;
282
- warn(message: string, data?: Json): void;
283
- error(message: string, data?: Json): void;
284
- }
285
- /**
286
- * Compensations run in reverse order, each in its own non-cancellable scope,
287
- * so they still run after a cancel request. A compensation receives that
288
- * scope's `ctx`; use it for every call after the compensation's first await.
289
- */
290
- interface Saga {
291
- add(compensation: (ctx: WorkflowContext) => unknown): void;
292
- compensate(): Promise<void>;
293
- }
294
- interface ContinueAsNewOptions {
295
- taskQueue?: string;
296
- retry?: Partial<RetryPolicy>;
297
- workflowTaskTimeout?: Duration;
298
- context?: JsonObject;
299
- versioningBehavior?: 'PINNED' | 'AUTO_UPGRADE';
300
- }
301
- /** A child target: a workflow key (graph or durable) or a tier-2 function of the same bundle. */
302
- type ChildTarget<Out> = string | DurableWorkflow<never, Out> | DurableWorkflow<Json, Out>;
303
- /** The context of a tier-2 workflow function. */
304
- interface WorkflowContext {
305
- readonly info: WorkflowInfo;
306
- readonly log: WorkflowLogger;
307
- /** Run a canvas node operation as a durable activity (`SCHEDULE_ACTIVITY`, kind `node`). */
308
- run<In, Out>(operation: Operation<In, Out>, options: RunOptions<In>): Promise<Out>;
309
- /** A durable timer. */
310
- sleep(duration: Duration, options?: {
311
- summary?: string;
312
- }): Promise<void>;
313
- /** Resolves `true` once `predicate` holds after an event, or `false` when `timeout` passes first. */
314
- condition(predicate: () => boolean, timeout?: Duration): Promise<boolean>;
315
- /** The next signal of this name (buffered signals first). */
316
- signalReceived<P>(signal: SignalDefinition<P> | string): Promise<P>;
317
- /** Handle every signal of this name, buffered ones first. */
318
- onSignal<P>(signal: SignalDefinition<P> | string, handler: (payload: P) => unknown): void;
319
- /** Handle signals no other handler or waiter takes. */
320
- setDefaultSignalHandler(handler: (name: string, payload: unknown) => unknown): void;
321
- /** Start a child run and wait for its result. */
322
- child<Out = Json>(target: ChildTarget<Out>, options?: ChildOptions): Promise<Out>;
323
- /** Start a child run; resolves once it has started. */
324
- startChild<Out = Json>(target: ChildTarget<Out>, options?: ChildOptions): Promise<ChildHandle<Out>>;
325
- /** Signal another run of the workspace; resolves on delivery. */
326
- signalRun<P>(runId: string, signal: SignalDefinition<P> | string, payload?: P): Promise<void>;
327
- /** Signal the parent run. */
328
- signalParent<P>(signal: SignalDefinition<P> | string, payload?: P): Promise<void>;
329
- getRunHandle(runId: string): ExternalRunHandle;
330
- /** Shorthand for `getRunHandle(runId).cancel()`. */
331
- cancelRun(runId: string): Promise<void>;
332
- /** The workflow clock (the task's start time), in epoch milliseconds. */
333
- now(): number;
334
- /** A deterministic random number in [0, 1), seeded per run. */
335
- random(): number;
336
- /** A deterministic version-4 UUID. */
337
- uuid(): string;
338
- /** Record a value once (`RECORD_SIDE_EFFECT`); replays return the recorded value. */
339
- sideEffect<T extends Json>(fn: () => T): T;
340
- /** In-place versioning (spec 06 §4). */
341
- patched(patchId: string): boolean;
342
- deprecatePatch(patchId: string): void;
343
- /** Live Markdown status for the run page and `__metadata` (at most 20 KiB). */
344
- setCurrentDetails(markdown: string): void;
345
- /** Merge keys into the run's context (parity command `UPSERT_CONTEXT`). */
346
- upsertContext(entries: JsonObject): void;
347
- /** End this run and start a fresh history (parity command `CONTINUE_AS_NEW`). */
348
- continueAsNew(input: unknown, options?: ContinueAsNewOptions): Promise<never>;
349
- /**
350
- * Run `fn` in a new cancellation scope. `fn` gets a `ctx` bound to the
351
- * scope: use it inside `fn`. This outer `ctx` joins the scope only while
352
- * `fn` runs synchronously; after an await it is back in its own scope, so
353
- * concurrent branches never share a scope by accident.
354
- */
355
- readonly cancellationScope: CancellationScopeFunction;
356
- /** `cancellationScope(fn, { nonCancellable: true })`; the same `ctx` rule applies. */
357
- nonCancellable<T>(fn: (ctx: WorkflowContext) => Promise<T>): Promise<T>;
358
- /**
359
- * Run `fn` when the current scope is cancelled. An error thrown by `fn` is
360
- * handled like an error thrown by the workflow; the other handlers still run.
361
- */
362
- onCancel(fn: () => void): void;
363
- isCancellation(error: unknown): boolean;
364
- saga(): Saga;
365
- /** Resolves when no asynchronous signal handler is running; cancellation does not interrupt the wait. */
366
- allHandlersFinished(): Promise<void>;
367
- /** Phase C: user activities. Throws `PhaseCFeatureError`. */
368
- activity(...args: unknown[]): Promise<never>;
369
- /** Phase B parity: local activities. Throws `PhaseCFeatureError` in this release. */
370
- localActivity(...args: unknown[]): Promise<never>;
371
- /** Phase C: custom queries. Throws `PhaseCFeatureError`. */
372
- handleQuery(...args: unknown[]): void;
373
- /** Phase C: updates. Throws `PhaseCFeatureError`. */
374
- handleUpdate(...args: unknown[]): void;
375
- /** Phase C: search attributes. Throws `PhaseCFeatureError`. */
376
- upsertSearchAttributes(...args: unknown[]): void;
377
- }
378
-
379
- /**
380
- * `workflow()`: declare a tier-2 durable workflow function (spec 02 §4).
381
- *
382
- * The value is inert data plus the function: nothing runs at module load.
383
- * `lower()` reads it to report `code.exports.workflows[exportName]`, and the
384
- * runtime (`src/runtime/`) calls the function by export name inside a
385
- * workflow task.
386
- */
387
-
388
- declare const DURABLE_MARKER = "fluidgrids.durable-workflow";
389
- /**
390
- * A payload schema: a JSON Schema object, or a schema library value with a
391
- * `toJSONSchema()` method. Anything else (a zod schema without one, for
392
- * example) types the code but leaves the interface without that schema.
393
- */
394
- type SchemaLike = Record<string, unknown> | {
395
- toJSONSchema(): unknown;
396
- };
397
- /** How a standalone tier-2 workflow starts (lowered to its trigger node). */
398
- type TriggerSpec = Operation<never, unknown> | Operation<Record<string, Json>, Json> | {
399
- operation: Operation<never, unknown> | Operation<Record<string, Json>, Json>;
400
- args?: JsonObject;
401
- id?: string;
402
- };
403
- interface DurableWorkflowOptions {
404
- /** Display name of the standalone workflow. */
405
- title?: string;
406
- description?: string;
407
- input?: SchemaLike;
408
- output?: SchemaLike;
409
- signals?: ReadonlyArray<SignalDefinition<never> | SignalDefinition<unknown>>;
410
- /** Declared only; handlers are Phase C. */
411
- queries?: ReadonlyArray<QueryDefinition<unknown, unknown>>;
412
- /** Declared only; handlers are Phase C. */
413
- updates?: ReadonlyArray<UpdateDefinition<unknown, unknown>>;
414
- /** Default `managed`. */
415
- taskQueue?: string;
416
- /** Lowers to the trigger node of the standalone workflow (default `internal:api`). */
417
- trigger?: TriggerSpec;
418
- /**
419
- * Whether the function is a workflow of its own (07 §4): by default, when it
420
- * declares a trigger or nothing in the project embeds it with `wf.codeWorkflow`.
421
- */
422
- standalone?: boolean;
423
- /** Error classes that fail the run instead of the workflow task (11 §2.25). */
424
- failureErrorTypes?: ReadonlyArray<abstract new (...args: never[]) => Error>;
425
- }
426
- /** A declared tier-2 workflow. */
427
- interface DurableWorkflow<In = Json, Out = Json> {
428
- readonly __fluidgrids: typeof DURABLE_MARKER;
429
- /** The workflow key it gets when it is standalone. */
430
- readonly name: string;
431
- readonly options: DurableWorkflowOptions;
432
- readonly fn: (ctx: WorkflowContext, input: In) => Promise<Out>;
433
- }
434
- /** Declare a tier-2 workflow. `name` is its workflow key when it is standalone. */
435
- declare function workflow<In = Json, Out = Json>(name: string, options: DurableWorkflowOptions, fn: (ctx: WorkflowContext, input: In) => Promise<Out>): DurableWorkflow<In, Out>;
436
- declare function workflow<In = Json, Out = Json>(name: string, fn: (ctx: WorkflowContext, input: In) => Promise<Out>): DurableWorkflow<In, Out>;
437
- /** True for a value made by {@link workflow}. */
438
- declare function isDurableWorkflow(value: unknown): value is DurableWorkflow<never, unknown>;
439
- /** The JSON Schema of a {@link SchemaLike}, or undefined when it has none. */
440
- declare function jsonSchemaOf(schema: SchemaLike | undefined): JsonObject | undefined;
441
- /** The workflow `interface` (spec 01 §4) a tier-2 declaration describes. */
442
- declare function interfaceOf(definition: DurableWorkflow<never, unknown>): WorkflowInterface;
443
-
444
- export { trigger as A, triggers as B, type CancellationScope as C, DURABLE_MARKER as D, type ExternalRunHandle as E, type FileRef as F, workflow as G, type Operation as O, type QueryDefinition as Q, type RunOptions as R, type Saga as S, type TriggerOperation as T, type UpdateDefinition as U, type WorkflowContext as W, type CancellationScopeFunction as a, type CancellationScopeOptions as b, type ChildHandle as c, type ChildOptions as d, type ChildTarget as e, type ContinueAsNewOptions as f, type DefinitionOptions as g, type DurableWorkflow as h, type DurableWorkflowOptions as i, type Duration as j, type SchemaLike as k, type SignalDefinition as l, type TriggerSpec as m, type WorkflowInfo as n, type WorkflowLogger as o, defineQuery as p, defineSignal as q, defineUpdate as r, interfaceOf as s, internalNodes as t, isDurableWorkflow as u, isOperation as v, jsonSchemaOf as w, nodes as x, op as y, toMs as z };