@fluidgrids/workflows 2026.1027.1 → 2026.1028.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 (166) hide show
  1. package/README.md +144 -13
  2. package/dist/activation-BBh1p82z.d.cts +57 -0
  3. package/dist/activation-DnhG7SmF.d.ts +57 -0
  4. package/dist/assemble-BLqQ8lSu.d.cts +39 -0
  5. package/dist/assemble-DWgaXHd-.d.ts +39 -0
  6. package/dist/chunk-2DP2Y6EU.cjs +832 -0
  7. package/dist/chunk-2J6TF7YI.cjs +86 -0
  8. package/dist/chunk-3FOTFQ3J.js +1622 -0
  9. package/dist/chunk-4LYSEANA.js +199 -0
  10. package/dist/{chunk-TQF7MYEN.cjs → chunk-57MSZ24T.cjs} +134 -96
  11. package/dist/{chunk-EEAIM35V.js → chunk-5HDSBTBX.js} +64 -23
  12. package/dist/chunk-623FVQSN.cjs +251 -0
  13. package/dist/{chunk-W32BSO3M.js → chunk-6FSHT5IL.js} +2 -2
  14. package/dist/{chunk-E3APHA6O.cjs → chunk-7AAZGVKD.js} +1 -64
  15. package/dist/chunk-7NQ37GZU.js +73 -0
  16. package/dist/chunk-ABFZWYHT.js +612 -0
  17. package/dist/{chunk-6U446SKY.js → chunk-BD7ZPG53.js} +2 -2
  18. package/dist/chunk-BO6OVILK.js +79 -0
  19. package/dist/chunk-C5OLWZ42.js +245 -0
  20. package/dist/chunk-CBL5JSCC.cjs +75 -0
  21. package/dist/{chunk-OSPTJCDI.cjs → chunk-CPDK3K5N.cjs} +6 -6
  22. package/dist/chunk-CSNWNFKU.cjs +1635 -0
  23. package/dist/chunk-DJYMDLV5.js +227 -0
  24. package/dist/{chunk-IHKXLG6I.js → chunk-E2VK7J2C.js} +1 -1
  25. package/dist/chunk-FMSW2HDF.cjs +267 -0
  26. package/dist/chunk-FQIHX7YI.cjs +80 -0
  27. package/dist/chunk-FR7KYWRO.cjs +41 -0
  28. package/dist/{chunk-7YR7DI7B.cjs → chunk-GBQ33SIZ.cjs} +44 -44
  29. package/dist/{chunk-6AIAC2FP.cjs → chunk-GVTZMA5C.cjs} +4 -4
  30. package/dist/chunk-H7KEVW2M.js +816 -0
  31. package/dist/{chunk-3M34AUIY.cjs → chunk-HR3BN4C4.cjs} +3 -3
  32. package/dist/chunk-IISBRUWJ.js +13 -0
  33. package/dist/chunk-JD2VQIDZ.cjs +15 -0
  34. package/dist/{chunk-UB2BHU2M.js → chunk-JZ4TOOLN.js} +1 -1
  35. package/dist/chunk-L24YIZY7.cjs +207 -0
  36. package/dist/chunk-LNUQE6D6.js +39 -0
  37. package/dist/{chunk-TWOYB4Y7.cjs → chunk-NEIUQASE.cjs} +13 -13
  38. package/dist/chunk-P6TA5EZT.cjs +634 -0
  39. package/dist/chunk-PDHLTDZB.js +72 -0
  40. package/dist/chunk-PMCM2OH4.js +46 -0
  41. package/dist/chunk-PZCVF76Q.cjs +868 -0
  42. package/dist/{chunk-6BEW4QD6.js → chunk-QAN5MZEM.js} +1 -1
  43. package/dist/{chunk-CSYBNN3V.cjs → chunk-QKZL3ONM.cjs} +2 -2
  44. package/dist/chunk-SAENRNBJ.cjs +52 -0
  45. package/dist/{chunk-XBIID5DY.js → chunk-SMCANK3F.js} +5 -4
  46. package/dist/{chunk-UWQWD7BP.cjs → chunk-SX2PNKKT.cjs} +18 -17
  47. package/dist/{chunk-UJNHTS6D.js → chunk-TBDXTV22.cjs} +8 -45
  48. package/dist/chunk-VOKMAAJP.js +848 -0
  49. package/dist/{chunk-5AW745OG.js → chunk-XB53G2DK.js} +1 -1
  50. package/dist/chunk-Z2Y65YOY.cjs +7 -0
  51. package/dist/codegen/index.cjs +9 -7
  52. package/dist/codegen/index.d.cts +2 -2
  53. package/dist/codegen/index.d.ts +2 -2
  54. package/dist/codegen/index.js +6 -5
  55. package/dist/file-BOoHZgoQ.d.cts +1557 -0
  56. package/dist/file-yuPCFU5b.d.ts +1557 -0
  57. package/dist/history/index.cjs +287 -0
  58. package/dist/history/index.d.cts +157 -0
  59. package/dist/history/index.d.ts +157 -0
  60. package/dist/history/index.js +5 -0
  61. package/dist/index.cjs +134 -36
  62. package/dist/index.d.cts +137 -9
  63. package/dist/index.d.ts +137 -9
  64. package/dist/index.js +8 -3
  65. package/dist/ir/index.cjs +152 -158
  66. package/dist/ir/index.d.cts +14 -4
  67. package/dist/ir/index.d.ts +14 -4
  68. package/dist/ir/index.js +41 -50
  69. package/dist/lower-BuSvAFqi.d.cts +129 -0
  70. package/dist/lower-C_Qv_34S.d.ts +129 -0
  71. package/dist/lower-types-nofRXw9c.d.cts +15 -0
  72. package/dist/lower-types-nofRXw9c.d.ts +15 -0
  73. package/dist/{manifest-Duf-gHdO.d.cts → manifest-0OLw0i7k.d.cts} +1 -1
  74. package/dist/{manifest-Bp9ZJlav.d.ts → manifest-C8N6HDYl.d.ts} +1 -1
  75. package/dist/node-evaluator-CJNP4GHX.js +12 -0
  76. package/dist/node-evaluator-DMKPKUWA.cjs +22 -0
  77. package/dist/quickjs/index.cjs +236 -12
  78. package/dist/quickjs/index.d.cts +46 -5
  79. package/dist/quickjs/index.d.ts +46 -5
  80. package/dist/quickjs/index.js +230 -9
  81. package/dist/roundtrip/index.cjs +333 -131
  82. package/dist/roundtrip/index.d.cts +39 -7
  83. package/dist/roundtrip/index.d.ts +39 -7
  84. package/dist/roundtrip/index.js +185 -13
  85. package/dist/runtime/index.cjs +90 -0
  86. package/dist/runtime/index.d.cts +297 -0
  87. package/dist/runtime/index.d.ts +297 -0
  88. package/dist/runtime/index.js +8 -0
  89. package/dist/testing/index.cjs +1057 -0
  90. package/dist/testing/index.d.cts +305 -0
  91. package/dist/testing/index.d.ts +305 -0
  92. package/dist/testing/index.js +1037 -0
  93. package/dist/{types-Dr2Fn1Ax.d.ts → types-BGoPzgcl.d.cts} +1 -1
  94. package/dist/{types-Dr2Fn1Ax.d.cts → types-BGoPzgcl.d.ts} +1 -1
  95. package/dist/types-CpBBjaGX.d.cts +380 -0
  96. package/dist/types-DV-HX_Gt.d.ts +380 -0
  97. package/dist/{assemble-CrpUyd_3.d.ts → workflow-Bpr3vnA_.d.ts} +40 -160
  98. package/dist/workflow-C2a05WUJ.d.ts +444 -0
  99. package/dist/{assemble-DEf3znGD.d.cts → workflow-FXUkpIBc.d.cts} +40 -160
  100. package/dist/workflow-J-yYixny.d.cts +444 -0
  101. package/fixtures/README.md +128 -0
  102. package/fixtures/histories/activity-failure-fails-run.history.json +163 -0
  103. package/fixtures/histories/activity-retry-then-success.history.json +147 -0
  104. package/fixtures/histories/cancel-activity-abandon.history.json +126 -0
  105. package/fixtures/histories/cancel-activity-compensate.history.json +307 -0
  106. package/fixtures/histories/cancel-concurrent-non-cancellable.history.json +234 -0
  107. package/fixtures/histories/cancel-concurrent-scope-timeout.history.json +184 -0
  108. package/fixtures/histories/cancel-condition-after-cancel.history.json +200 -0
  109. package/fixtures/histories/cancel-during-timer.history.json +123 -0
  110. package/fixtures/histories/cancel-saga-compensations.history.json +325 -0
  111. package/fixtures/histories/cancel-scope-timeout.history.json +148 -0
  112. package/fixtures/histories/child-abandon-outlives-parent.history.json +191 -0
  113. package/fixtures/histories/child-cancel-default.history.json +234 -0
  114. package/fixtures/histories/child-cancel-request.history.json +206 -0
  115. package/fixtures/histories/child-durable-child-side.history.json +124 -0
  116. package/fixtures/histories/child-durable-result.history.json +163 -0
  117. package/fixtures/histories/child-failure-caught.history.json +166 -0
  118. package/fixtures/histories/child-graph-by-key.history.json +138 -0
  119. package/fixtures/histories/child-terminated-by-parent-close.history.json +85 -0
  120. package/fixtures/histories/continue-as-new-first-run.history.json +146 -0
  121. package/fixtures/histories/continue-as-new-history-limit.history.json +489 -0
  122. package/fixtures/histories/continue-as-new-last-run.history.json +147 -0
  123. package/fixtures/histories/continue-as-new-suggested.history.json +352 -0
  124. package/fixtures/histories/details-and-context.history.json +176 -0
  125. package/fixtures/histories/deterministic-values.history.json +128 -0
  126. package/fixtures/histories/engine-builtins.history.json +172 -0
  127. package/fixtures/histories/gather-activities.history.json +291 -0
  128. package/fixtures/histories/gather-all-settled.history.json +219 -0
  129. package/fixtures/histories/gather-mixed.history.json +281 -0
  130. package/fixtures/histories/input-during-running-task.history.json +111 -0
  131. package/fixtures/histories/nondeterminism-reordered.history.json +218 -0
  132. package/fixtures/histories/patched-deprecated.history.json +271 -0
  133. package/fixtures/histories/patched-new-run.history.json +270 -0
  134. package/fixtures/histories/patched-old-history.history.json +190 -0
  135. package/fixtures/histories/race-activity-wins.history.json +152 -0
  136. package/fixtures/histories/race-signal-beats-child.history.json +161 -0
  137. package/fixtures/histories/race-timeout-wins.history.json +118 -0
  138. package/fixtures/histories/side-effect-recorded.history.json +153 -0
  139. package/fixtures/histories/signal-buffered-at-start.history.json +157 -0
  140. package/fixtures/histories/signal-default-handler.history.json +187 -0
  141. package/fixtures/histories/signal-handler.history.json +191 -0
  142. package/fixtures/histories/signal-parent-child-side.history.json +132 -0
  143. package/fixtures/histories/signal-parent.history.json +202 -0
  144. package/fixtures/histories/signal-run-delivered.history.json +128 -0
  145. package/fixtures/histories/signal-run-undelivered.history.json +134 -0
  146. package/fixtures/histories/signal-wait.history.json +111 -0
  147. package/fixtures/histories/task-failure-code-error.history.json +137 -0
  148. package/fixtures/histories/task-failure-then-transient-attempt.history.json +140 -0
  149. package/fixtures/histories/timer-condition-met.history.json +201 -0
  150. package/fixtures/histories/timer-condition-timeout.history.json +118 -0
  151. package/fixtures/histories/timer-sleep-once.history.json +118 -0
  152. package/fixtures/histories/timer-sleep-sequence.history.json +210 -0
  153. package/fixtures/histories/update-accepted-completed.history.json +149 -0
  154. package/fixtures/histories/update-with-start-rejected-validation.history.json +91 -0
  155. package/package.json +44 -5
  156. package/schema/history-file.schema.json +2544 -0
  157. package/schema/ir-v2.schema.json +16 -0
  158. package/schema/run-event.schema.json +2374 -0
  159. package/schema/workflow-command.schema.json +1095 -0
  160. package/schema/workflow-task.schema.json +3560 -0
  161. package/dist/chunk-MBBKGD7K.js +0 -440
  162. package/dist/chunk-Y7NWR3WH.cjs +0 -450
  163. package/dist/lower-CXggJTIo.d.ts +0 -67
  164. package/dist/lower-DAzvsJCo.d.cts +0 -67
  165. package/dist/node-evaluator-CH3XCJND.cjs +0 -17
  166. package/dist/node-evaluator-TULXA3WE.js +0 -8
@@ -0,0 +1,227 @@
1
+ // src/history/types.ts
2
+ var HISTORY_PROTOCOL = 1;
3
+ var EVENT_TYPES = [
4
+ "WORKFLOW_STARTED",
5
+ "WORKFLOW_TASK_SCHEDULED",
6
+ "WORKFLOW_TASK_STARTED",
7
+ "WORKFLOW_TASK_COMPLETED",
8
+ "WORKFLOW_TASK_FAILED",
9
+ "WORKFLOW_TASK_TIMED_OUT",
10
+ "ACTIVITY_SCHEDULED",
11
+ "ACTIVITY_STARTED",
12
+ "ACTIVITY_HEARTBEAT",
13
+ "ACTIVITY_COMPLETED",
14
+ "ACTIVITY_FAILED",
15
+ "ACTIVITY_TIMED_OUT",
16
+ "ACTIVITY_CANCEL_REQUESTED",
17
+ "ACTIVITY_CANCELLED",
18
+ "ACTIVITY_PAUSED",
19
+ "ACTIVITY_UNPAUSED",
20
+ "ACTIVITY_RESET",
21
+ "ACTIVITY_OPTIONS_UPDATED",
22
+ "TIMER_STARTED",
23
+ "TIMER_FIRED",
24
+ "TIMER_CANCELLED",
25
+ "SIGNAL_RECEIVED",
26
+ "UPDATE_ADMITTED",
27
+ "UPDATE_ACCEPTED",
28
+ "UPDATE_COMPLETED",
29
+ "CHILD_RUN_INITIATED",
30
+ "CHILD_RUN_STARTED",
31
+ "CHILD_RUN_COMPLETED",
32
+ "CHILD_RUN_FAILED",
33
+ "CHILD_RUN_CANCELLED",
34
+ "CHILD_RUN_TERMINATED",
35
+ "CHILD_RUN_TIMED_OUT",
36
+ "EXTERNAL_RUN_CANCEL_REQUESTED",
37
+ "EXTERNAL_RUN_CANCEL_RESOLVED",
38
+ "EXTERNAL_RUN_SIGNALED",
39
+ "SIDE_EFFECT_RECORDED",
40
+ "LOCAL_ACTIVITY_COMPLETED",
41
+ "LOCAL_ACTIVITY_FAILED",
42
+ "SEARCH_ATTRIBUTES_UPSERTED",
43
+ "CONTEXT_UPSERTED",
44
+ "MARKER_RECORDED",
45
+ "WORKFLOW_CANCEL_REQUESTED",
46
+ "WORKFLOW_RESET",
47
+ "VERSIONING_OVERRIDE_SET",
48
+ "WORKFLOW_COMPLETED",
49
+ "WORKFLOW_FAILED",
50
+ "WORKFLOW_CANCELLED",
51
+ "WORKFLOW_TERMINATED",
52
+ "WORKFLOW_TIMED_OUT",
53
+ "WORKFLOW_CONTINUED_AS_NEW"
54
+ ];
55
+ var COMMAND_TYPES = [
56
+ "SCHEDULE_ACTIVITY",
57
+ "REQUEST_CANCEL_ACTIVITY",
58
+ "START_TIMER",
59
+ "CANCEL_TIMER",
60
+ "START_CHILD_RUN",
61
+ "SIGNAL_RUN",
62
+ "RECORD_SIDE_EFFECT",
63
+ "RECORD_MARKER",
64
+ "COMPLETE_WORKFLOW",
65
+ "FAIL_WORKFLOW",
66
+ "CANCEL_WORKFLOW",
67
+ "UPSERT_CONTEXT",
68
+ "RECORD_LOCAL_ACTIVITY",
69
+ "CONTINUE_AS_NEW",
70
+ "REQUEST_CANCEL_EXTERNAL_RUN",
71
+ "UPSERT_SEARCH_ATTRIBUTES",
72
+ "ACCEPT_UPDATE",
73
+ "REJECT_UPDATE",
74
+ "COMPLETE_UPDATE"
75
+ ];
76
+ var PHASE_B_CORE_COMMANDS = /* @__PURE__ */ new Set([
77
+ "SCHEDULE_ACTIVITY",
78
+ "REQUEST_CANCEL_ACTIVITY",
79
+ "START_TIMER",
80
+ "CANCEL_TIMER",
81
+ "START_CHILD_RUN",
82
+ "SIGNAL_RUN",
83
+ "RECORD_SIDE_EFFECT",
84
+ "RECORD_MARKER",
85
+ "COMPLETE_WORKFLOW",
86
+ "FAIL_WORKFLOW",
87
+ "CANCEL_WORKFLOW"
88
+ ]);
89
+ var PHASE_B_PARITY_COMMANDS = /* @__PURE__ */ new Set([
90
+ "UPSERT_CONTEXT",
91
+ "RECORD_LOCAL_ACTIVITY",
92
+ "CONTINUE_AS_NEW",
93
+ "REQUEST_CANCEL_EXTERNAL_RUN"
94
+ ]);
95
+ var PHASE_C_COMMANDS = /* @__PURE__ */ new Set([
96
+ "UPSERT_SEARCH_ATTRIBUTES",
97
+ "ACCEPT_UPDATE",
98
+ "REJECT_UPDATE",
99
+ "COMPLETE_UPDATE"
100
+ ]);
101
+ var TERMINAL_COMMANDS = /* @__PURE__ */ new Set([
102
+ "COMPLETE_WORKFLOW",
103
+ "FAIL_WORKFLOW",
104
+ "CANCEL_WORKFLOW",
105
+ "CONTINUE_AS_NEW"
106
+ ]);
107
+ var TASK_FAILURE_CAUSES = [
108
+ "NON_DETERMINISM",
109
+ "TASK_TIMEOUT",
110
+ "ISOLATE_MEMORY",
111
+ "PROTOCOL_MISMATCH",
112
+ "BUNDLE_UNAVAILABLE",
113
+ "BUNDLE_INTEGRITY",
114
+ "WORKFLOW_CODE_ERROR",
115
+ "HISTORY_LIMIT",
116
+ "UNSUPPORTED_COMMAND",
117
+ "INVALID_REQUEST",
118
+ "INTERNAL"
119
+ ];
120
+ var ERROR_TYPES = [
121
+ "TIMEOUT",
122
+ "TRANSIENT",
123
+ "DEPENDENCY",
124
+ "AUTHORIZATION",
125
+ "VALIDATION",
126
+ "PERMANENT",
127
+ "UNKNOWN"
128
+ ];
129
+ var EXECUTION_KINDS = ["GRAPH", "DURABLE_FN"];
130
+ var PARENT_CLOSE_POLICIES = ["TERMINATE", "ABANDON", "REQUEST_CANCEL"];
131
+ var ACTIVITY_CANCELLATION_TYPES = [
132
+ "WAIT_CANCELLATION_COMPLETED",
133
+ "TRY_CANCEL",
134
+ "ABANDON"
135
+ ];
136
+ var CHILD_CANCELLATION_TYPES = [
137
+ "WAIT_CANCELLATION_COMPLETED",
138
+ "WAIT_CANCELLATION_REQUESTED",
139
+ "TRY_CANCEL",
140
+ "ABANDON"
141
+ ];
142
+ var DEFAULT_HISTORY_LIMIT = { events: 1e4, bytes: 16 * 1024 * 1024 };
143
+ var CONTINUE_AS_NEW_SUGGESTED_RATIO = 0.8;
144
+ var HISTORY_LIMIT_EXCEEDED_RATIO = 0.95;
145
+ var BUILT_IN_QUERIES = [
146
+ "__stack_trace",
147
+ "__enhanced_stack_trace",
148
+ "__metadata"
149
+ ];
150
+ var COMMAND_EVENT_TYPES = {
151
+ SCHEDULE_ACTIVITY: "ACTIVITY_SCHEDULED",
152
+ REQUEST_CANCEL_ACTIVITY: "ACTIVITY_CANCEL_REQUESTED",
153
+ START_TIMER: "TIMER_STARTED",
154
+ CANCEL_TIMER: "TIMER_CANCELLED",
155
+ START_CHILD_RUN: "CHILD_RUN_INITIATED",
156
+ SIGNAL_RUN: "EXTERNAL_RUN_SIGNALED",
157
+ RECORD_SIDE_EFFECT: "SIDE_EFFECT_RECORDED",
158
+ RECORD_MARKER: "MARKER_RECORDED",
159
+ COMPLETE_WORKFLOW: "WORKFLOW_COMPLETED",
160
+ FAIL_WORKFLOW: "WORKFLOW_FAILED",
161
+ CANCEL_WORKFLOW: "WORKFLOW_CANCELLED",
162
+ UPSERT_CONTEXT: "CONTEXT_UPSERTED",
163
+ RECORD_LOCAL_ACTIVITY: "LOCAL_ACTIVITY_COMPLETED",
164
+ CONTINUE_AS_NEW: "WORKFLOW_CONTINUED_AS_NEW",
165
+ REQUEST_CANCEL_EXTERNAL_RUN: "EXTERNAL_RUN_CANCEL_REQUESTED",
166
+ UPSERT_SEARCH_ATTRIBUTES: "SEARCH_ATTRIBUTES_UPSERTED",
167
+ ACCEPT_UPDATE: "UPDATE_ACCEPTED",
168
+ REJECT_UPDATE: null,
169
+ COMPLETE_UPDATE: "UPDATE_COMPLETED"
170
+ };
171
+ var COMMAND_EVENTS = /* @__PURE__ */ new Set([
172
+ "ACTIVITY_SCHEDULED",
173
+ "ACTIVITY_CANCEL_REQUESTED",
174
+ "TIMER_STARTED",
175
+ "TIMER_CANCELLED",
176
+ "CHILD_RUN_INITIATED",
177
+ "EXTERNAL_RUN_SIGNALED",
178
+ "SIDE_EFFECT_RECORDED",
179
+ "MARKER_RECORDED",
180
+ "WORKFLOW_COMPLETED",
181
+ "WORKFLOW_FAILED",
182
+ "WORKFLOW_CANCELLED",
183
+ "CONTEXT_UPSERTED",
184
+ "LOCAL_ACTIVITY_COMPLETED",
185
+ "LOCAL_ACTIVITY_FAILED",
186
+ "WORKFLOW_CONTINUED_AS_NEW",
187
+ "EXTERNAL_RUN_CANCEL_REQUESTED",
188
+ "SEARCH_ATTRIBUTES_UPSERTED",
189
+ "UPDATE_ACCEPTED",
190
+ "UPDATE_COMPLETED"
191
+ ]);
192
+ var INPUT_EVENTS = /* @__PURE__ */ new Set([
193
+ "WORKFLOW_STARTED",
194
+ "ACTIVITY_COMPLETED",
195
+ "ACTIVITY_FAILED",
196
+ "ACTIVITY_TIMED_OUT",
197
+ "ACTIVITY_CANCELLED",
198
+ "TIMER_FIRED",
199
+ "SIGNAL_RECEIVED",
200
+ "UPDATE_ADMITTED",
201
+ "CHILD_RUN_STARTED",
202
+ "CHILD_RUN_COMPLETED",
203
+ "CHILD_RUN_FAILED",
204
+ "CHILD_RUN_CANCELLED",
205
+ "CHILD_RUN_TERMINATED",
206
+ "CHILD_RUN_TIMED_OUT",
207
+ "EXTERNAL_RUN_CANCEL_RESOLVED",
208
+ "WORKFLOW_CANCEL_REQUESTED"
209
+ ]);
210
+ var TERMINAL_EVENTS = /* @__PURE__ */ new Set([
211
+ "WORKFLOW_COMPLETED",
212
+ "WORKFLOW_FAILED",
213
+ "WORKFLOW_CANCELLED",
214
+ "WORKFLOW_TERMINATED",
215
+ "WORKFLOW_TIMED_OUT",
216
+ "WORKFLOW_CONTINUED_AS_NEW"
217
+ ]);
218
+ function isInputEvent(event) {
219
+ if (event.type === "EXTERNAL_RUN_SIGNALED") return event.payload["resolved"] === true;
220
+ return INPUT_EVENTS.has(event.type);
221
+ }
222
+ function isCommandEvent(event) {
223
+ if (event.type === "EXTERNAL_RUN_SIGNALED") return event.payload["resolved"] !== true;
224
+ return COMMAND_EVENTS.has(event.type);
225
+ }
226
+
227
+ export { ACTIVITY_CANCELLATION_TYPES, BUILT_IN_QUERIES, CHILD_CANCELLATION_TYPES, COMMAND_EVENTS, COMMAND_EVENT_TYPES, COMMAND_TYPES, CONTINUE_AS_NEW_SUGGESTED_RATIO, DEFAULT_HISTORY_LIMIT, ERROR_TYPES, EVENT_TYPES, EXECUTION_KINDS, HISTORY_LIMIT_EXCEEDED_RATIO, HISTORY_PROTOCOL, INPUT_EVENTS, PARENT_CLOSE_POLICIES, PHASE_B_CORE_COMMANDS, PHASE_B_PARITY_COMMANDS, PHASE_C_COMMANDS, TASK_FAILURE_CAUSES, TERMINAL_COMMANDS, TERMINAL_EVENTS, isCommandEvent, isInputEvent };
@@ -1,4 +1,4 @@
1
- import { setOwn } from './chunk-UJNHTS6D.js';
1
+ import { setOwn } from './chunk-PMCM2OH4.js';
2
2
 
3
3
  // src/ir/canonical-json.ts
4
4
  var CanonicalJsonError = class extends Error {
@@ -0,0 +1,267 @@
1
+ 'use strict';
2
+
3
+ var chunkFR7KYWRO_cjs = require('./chunk-FR7KYWRO.cjs');
4
+
5
+ // src/durable/definitions.ts
6
+ function checkName(name, what) {
7
+ if (typeof name !== "string" || name === "" || name.startsWith("__"))
8
+ throw new TypeError(`${what} needs a name that does not start with "__"`);
9
+ }
10
+ function defineSignal(name, options = {}) {
11
+ checkName(name, "defineSignal");
12
+ return {
13
+ kind: "signal",
14
+ name,
15
+ ...options.description !== void 0 ? { description: options.description } : {},
16
+ ...options.schema !== void 0 ? { schema: options.schema } : {}
17
+ };
18
+ }
19
+ function defineQuery(name, options = {}) {
20
+ checkName(name, "defineQuery");
21
+ return {
22
+ kind: "query",
23
+ name,
24
+ ...options.description !== void 0 ? { description: options.description } : {}
25
+ };
26
+ }
27
+ function defineUpdate(name, options = {}) {
28
+ checkName(name, "defineUpdate");
29
+ return {
30
+ kind: "update",
31
+ name,
32
+ ...options.description !== void 0 ? { description: options.description } : {}
33
+ };
34
+ }
35
+ function signalName(signal) {
36
+ return typeof signal === "string" ? signal : signal.name;
37
+ }
38
+
39
+ // src/durable/errors.ts
40
+ var ERROR_TYPE_VALUES = /* @__PURE__ */ new Set([
41
+ "TIMEOUT",
42
+ "TRANSIENT",
43
+ "DEPENDENCY",
44
+ "AUTHORIZATION",
45
+ "VALIDATION",
46
+ "PERMANENT",
47
+ "UNKNOWN"
48
+ ]);
49
+ function isErrorType(value) {
50
+ return typeof value === "string" && ERROR_TYPE_VALUES.has(value);
51
+ }
52
+ var WorkflowFailure = class extends Error {
53
+ /** The shared error type the engine classifies this failure as. */
54
+ errorType;
55
+ constructor(message, errorType, options = {}) {
56
+ super(message);
57
+ this.name = "WorkflowFailure";
58
+ this.errorType = errorType;
59
+ if (options.cause !== void 0)
60
+ Object.defineProperty(this, "cause", {
61
+ value: options.cause,
62
+ enumerable: false,
63
+ writable: true,
64
+ configurable: true
65
+ });
66
+ }
67
+ };
68
+ var ApplicationError = class extends WorkflowFailure {
69
+ type;
70
+ nonRetryable;
71
+ details;
72
+ nextRetryDelayMs;
73
+ category;
74
+ constructor(message, options = {}) {
75
+ super(
76
+ message,
77
+ options.errorType ?? (isErrorType(options.type) ? options.type : "UNKNOWN"),
78
+ options.cause !== void 0 ? { cause: options.cause } : {}
79
+ );
80
+ this.name = "ApplicationError";
81
+ this.type = options.type;
82
+ this.nonRetryable = options.nonRetryable === true;
83
+ this.details = options.details;
84
+ this.nextRetryDelayMs = options.nextRetryDelay;
85
+ this.category = options.category;
86
+ }
87
+ };
88
+ var ActivityFailure = class extends WorkflowFailure {
89
+ constructor(message, activityId, nodeType, operation, cause) {
90
+ super(message, cause instanceof WorkflowFailure ? cause.errorType : "UNKNOWN", { cause });
91
+ this.activityId = activityId;
92
+ this.nodeType = nodeType;
93
+ this.operation = operation;
94
+ this.name = "ActivityFailure";
95
+ }
96
+ activityId;
97
+ nodeType;
98
+ operation;
99
+ };
100
+ var ChildRunFailure = class extends WorkflowFailure {
101
+ constructor(message, childId, childRunId, cause) {
102
+ super(message, cause instanceof WorkflowFailure ? cause.errorType : "UNKNOWN", { cause });
103
+ this.childId = childId;
104
+ this.childRunId = childRunId;
105
+ this.name = "ChildRunFailure";
106
+ }
107
+ childId;
108
+ childRunId;
109
+ };
110
+ var TerminatedFailure = class extends WorkflowFailure {
111
+ constructor(message = "Terminated") {
112
+ super(message, "PERMANENT");
113
+ this.name = "TerminatedFailure";
114
+ }
115
+ };
116
+ var ServerFailure = class extends WorkflowFailure {
117
+ constructor(message, nonRetryable = false, errorType = "DEPENDENCY") {
118
+ super(message, errorType);
119
+ this.nonRetryable = nonRetryable;
120
+ this.name = "ServerFailure";
121
+ }
122
+ nonRetryable;
123
+ };
124
+ var CancelledFailure = class extends WorkflowFailure {
125
+ constructor(message = "Cancelled") {
126
+ super(message, "PERMANENT");
127
+ this.name = "CancelledFailure";
128
+ }
129
+ };
130
+ var TimeoutFailure = class extends WorkflowFailure {
131
+ constructor(message, timeoutType) {
132
+ super(message, "TIMEOUT");
133
+ this.timeoutType = timeoutType;
134
+ this.name = "TimeoutFailure";
135
+ }
136
+ timeoutType;
137
+ };
138
+ var DeterminismViolation = class extends Error {
139
+ constructor(message) {
140
+ super(message);
141
+ this.name = "DeterminismViolation";
142
+ }
143
+ };
144
+ var HistoryLimitExceeded = class extends Error {
145
+ constructor(message) {
146
+ super(message);
147
+ this.name = "HistoryLimitExceeded";
148
+ }
149
+ };
150
+ var PhaseCFeatureError = class extends Error {
151
+ code = "durable.phaseC";
152
+ constructor(feature) {
153
+ super(
154
+ `${feature} is not available yet (Phase C); durable functions in this release cannot use it`
155
+ );
156
+ this.name = "PhaseCFeatureError";
157
+ }
158
+ };
159
+ function isCancellation(error) {
160
+ let current = error;
161
+ for (let depth = 0; depth < 16 && current instanceof Error; depth++) {
162
+ if (current instanceof CancelledFailure || current.name === "CancelledFailure") return true;
163
+ if (!(current instanceof ActivityFailure || current instanceof ChildRunFailure)) return false;
164
+ current = current.cause;
165
+ }
166
+ return false;
167
+ }
168
+ function isRunFailure(error) {
169
+ return error instanceof WorkflowFailure;
170
+ }
171
+ function stackOf(error) {
172
+ return typeof error.stack === "string" && error.stack !== "" ? error.stack : void 0;
173
+ }
174
+ function errorToFailure(error, source = "sdk-ts", depth = 0) {
175
+ if (!(error instanceof Error)) return { errorType: "UNKNOWN", message: String(error), source };
176
+ const failure = {
177
+ errorType: error instanceof WorkflowFailure ? error.errorType : "UNKNOWN",
178
+ message: error.message,
179
+ type: error instanceof ApplicationError && error.type !== void 0 ? error.type : error.name,
180
+ source
181
+ };
182
+ const stack = stackOf(error);
183
+ if (stack !== void 0) failure.stackTrace = stack;
184
+ if (error instanceof ApplicationError) {
185
+ if (error.nonRetryable) failure.nonRetryable = true;
186
+ if (error.details !== void 0) failure.details = error.details;
187
+ if (error.nextRetryDelayMs !== void 0) failure.nextRetryDelayMs = error.nextRetryDelayMs;
188
+ if (error.category !== void 0) failure.category = error.category;
189
+ }
190
+ if (error instanceof TimeoutFailure) failure.timeoutType = error.timeoutType;
191
+ if (error instanceof ServerFailure && error.nonRetryable) failure.nonRetryable = true;
192
+ const cause = error.cause;
193
+ if (cause !== void 0 && depth < 16) failure.cause = errorToFailure(cause, source, depth + 1);
194
+ return failure;
195
+ }
196
+ function failureToError(failure, depth = 0) {
197
+ const cause = failure.cause && depth < 16 ? failureToError(failure.cause, depth + 1) : void 0;
198
+ let error;
199
+ switch (failure.type) {
200
+ case "CancelledFailure":
201
+ error = new CancelledFailure(failure.message);
202
+ break;
203
+ case "TerminatedFailure":
204
+ error = new TerminatedFailure(failure.message);
205
+ break;
206
+ case "TimeoutFailure":
207
+ error = new TimeoutFailure(failure.message, failure.timeoutType ?? "UNKNOWN");
208
+ break;
209
+ case "ServerFailure":
210
+ error = new ServerFailure(failure.message, failure.nonRetryable === true, failure.errorType);
211
+ break;
212
+ default:
213
+ if (failure.timeoutType !== void 0 && failure.errorType === "TIMEOUT" && !failure.type)
214
+ error = new TimeoutFailure(failure.message, failure.timeoutType);
215
+ else
216
+ error = new ApplicationError(failure.message, {
217
+ errorType: failure.errorType,
218
+ ...failure.type !== void 0 ? { type: failure.type } : {},
219
+ ...failure.nonRetryable !== void 0 ? { nonRetryable: failure.nonRetryable } : {},
220
+ ...failure.details !== void 0 ? { details: failure.details } : {},
221
+ ...failure.nextRetryDelayMs !== void 0 ? { nextRetryDelay: failure.nextRetryDelayMs } : {},
222
+ ...failure.category !== void 0 ? { category: failure.category } : {},
223
+ ...cause !== void 0 ? { cause } : {}
224
+ });
225
+ }
226
+ if (cause !== void 0 && !(error instanceof ApplicationError))
227
+ Object.defineProperty(error, "cause", {
228
+ value: cause,
229
+ enumerable: false,
230
+ writable: true,
231
+ configurable: true
232
+ });
233
+ if (failure.stackTrace !== void 0) error.stack = failure.stackTrace;
234
+ return error;
235
+ }
236
+
237
+ // src/durable/durations.ts
238
+ function toMs(value, what = "duration") {
239
+ const ms = chunkFR7KYWRO_cjs.durationMs(value, "ms");
240
+ if (ms === void 0) throw new TypeError(`${what} "${String(value)}" is not a duration`);
241
+ return Math.round(ms);
242
+ }
243
+ function optionalMs(value, what) {
244
+ return value === void 0 ? void 0 : toMs(value, what);
245
+ }
246
+
247
+ exports.ActivityFailure = ActivityFailure;
248
+ exports.ApplicationError = ApplicationError;
249
+ exports.CancelledFailure = CancelledFailure;
250
+ exports.ChildRunFailure = ChildRunFailure;
251
+ exports.DeterminismViolation = DeterminismViolation;
252
+ exports.HistoryLimitExceeded = HistoryLimitExceeded;
253
+ exports.PhaseCFeatureError = PhaseCFeatureError;
254
+ exports.ServerFailure = ServerFailure;
255
+ exports.TerminatedFailure = TerminatedFailure;
256
+ exports.TimeoutFailure = TimeoutFailure;
257
+ exports.WorkflowFailure = WorkflowFailure;
258
+ exports.defineQuery = defineQuery;
259
+ exports.defineSignal = defineSignal;
260
+ exports.defineUpdate = defineUpdate;
261
+ exports.errorToFailure = errorToFailure;
262
+ exports.failureToError = failureToError;
263
+ exports.isCancellation = isCancellation;
264
+ exports.isRunFailure = isRunFailure;
265
+ exports.optionalMs = optionalMs;
266
+ exports.signalName = signalName;
267
+ exports.toMs = toMs;
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+
3
+ // src/durable/workflow.ts
4
+ var DURABLE_MARKER = "fluidgrids.durable-workflow";
5
+ var KEY = /^[a-z0-9][a-z0-9_-]{0,127}$/;
6
+ function workflow(name, optionsOrFn, maybeFn) {
7
+ if (typeof name !== "string" || !KEY.test(name))
8
+ throw new TypeError(
9
+ `workflow() needs a key of lowercase letters, digits, "-" and "_" (got "${String(name)}")`
10
+ );
11
+ const fn = typeof optionsOrFn === "function" ? optionsOrFn : maybeFn;
12
+ const options = typeof optionsOrFn === "function" ? {} : optionsOrFn ?? {};
13
+ if (typeof fn !== "function") throw new TypeError(`workflow("${name}") needs a function`);
14
+ return Object.freeze({ __fluidgrids: DURABLE_MARKER, name, options, fn });
15
+ }
16
+ function isDurableWorkflow(value) {
17
+ return typeof value === "object" && value !== null && value.__fluidgrids === DURABLE_MARKER && typeof value.fn === "function";
18
+ }
19
+ function isJsonValue(value, depth = 0) {
20
+ if (depth > 64) return false;
21
+ if (value === null || typeof value === "string" || typeof value === "boolean") return true;
22
+ if (typeof value === "number") return Number.isFinite(value);
23
+ if (Array.isArray(value)) return value.every((item) => isJsonValue(item, depth + 1));
24
+ if (typeof value === "object") {
25
+ if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null)
26
+ return false;
27
+ return Object.values(value).every((item) => isJsonValue(item, depth + 1));
28
+ }
29
+ return false;
30
+ }
31
+ function jsonSchemaOf(schema) {
32
+ if (schema === void 0) return void 0;
33
+ const method = schema.toJSONSchema;
34
+ if (typeof method === "function") {
35
+ const produced = method.call(schema);
36
+ return isJsonValue(produced) && typeof produced === "object" && !Array.isArray(produced) && produced !== null ? produced : void 0;
37
+ }
38
+ return isJsonValue(schema) && !Array.isArray(schema) && schema !== null && typeof schema === "object" ? schema : void 0;
39
+ }
40
+ function interfaceOf(definition) {
41
+ const out = {};
42
+ const input = jsonSchemaOf(definition.options.input);
43
+ const output = jsonSchemaOf(definition.options.output);
44
+ if (input) out.input = input;
45
+ if (output) out.output = output;
46
+ const signals = definition.options.signals ?? [];
47
+ if (signals.length > 0) {
48
+ out.signals = {};
49
+ for (const signal of signals) {
50
+ const entry = {};
51
+ const payload = jsonSchemaOf(signal.schema);
52
+ if (payload) entry.payload = payload;
53
+ if (signal.description !== void 0) entry.description = signal.description;
54
+ out.signals[signal.name] = entry;
55
+ }
56
+ }
57
+ const queries = definition.options.queries ?? [];
58
+ if (queries.length > 0) {
59
+ out.queries = {};
60
+ for (const query of queries)
61
+ out.queries[query.name] = query.description !== void 0 ? { description: query.description } : {};
62
+ }
63
+ const updates = definition.options.updates ?? [];
64
+ if (updates.length > 0) {
65
+ out.updates = {};
66
+ for (const update of updates)
67
+ out.updates[update.name] = update.description !== void 0 ? { description: update.description } : {};
68
+ }
69
+ return out;
70
+ }
71
+
72
+ // src/generated/version.ts
73
+ var SDK_VERSION = "2026.1028.1";
74
+
75
+ exports.DURABLE_MARKER = DURABLE_MARKER;
76
+ exports.SDK_VERSION = SDK_VERSION;
77
+ exports.interfaceOf = interfaceOf;
78
+ exports.isDurableWorkflow = isDurableWorkflow;
79
+ exports.jsonSchemaOf = jsonSchemaOf;
80
+ exports.workflow = workflow;
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+
3
+ // src/ir/duration.ts
4
+ var SHORT = /^(\d+(?:\.\d+)?)(ms|s|m|h|d|w)$/;
5
+ var ISO = /^P(?:(\d+(?:\.\d+)?)W)?(?:(\d+(?:\.\d+)?)D)?(?:T(?:(\d+(?:\.\d+)?)H)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)S)?)?$/;
6
+ var SECOND_MS = 1e3;
7
+ var MINUTE_MS = 60 * SECOND_MS;
8
+ var HOUR_MS = 60 * MINUTE_MS;
9
+ var DAY_MS = 24 * HOUR_MS;
10
+ var WEEK_MS = 7 * DAY_MS;
11
+ var UNIT_MS = {
12
+ ms: 1,
13
+ s: SECOND_MS,
14
+ m: MINUTE_MS,
15
+ h: HOUR_MS,
16
+ d: DAY_MS,
17
+ w: WEEK_MS
18
+ };
19
+ function durationMs(value, numberUnit) {
20
+ if (typeof value === "number") {
21
+ if (!Number.isFinite(value) || value < 0) return void 0;
22
+ return numberUnit === "s" ? value * 1e3 : value;
23
+ }
24
+ if (typeof value !== "string") return void 0;
25
+ const text = value.trim();
26
+ const short = SHORT.exec(text);
27
+ if (short?.[1] !== void 0 && short[2] !== void 0) {
28
+ const unit = UNIT_MS[short[2]];
29
+ return unit === void 0 ? void 0 : Number(short[1]) * unit;
30
+ }
31
+ const iso = ISO.exec(text);
32
+ if (iso && text !== "P" && text !== "PT") {
33
+ const [, weeks, days, hours, minutes, seconds] = iso;
34
+ const parts = [weeks, days, hours, minutes, seconds];
35
+ if (parts.every((part) => part === void 0)) return void 0;
36
+ return Number(weeks ?? 0) * WEEK_MS + Number(days ?? 0) * DAY_MS + Number(hours ?? 0) * HOUR_MS + Number(minutes ?? 0) * MINUTE_MS + Number(seconds ?? 0) * SECOND_MS;
37
+ }
38
+ return void 0;
39
+ }
40
+
41
+ exports.durationMs = durationMs;