@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
@@ -0,0 +1,293 @@
1
+ import { durationMs } from './chunk-LNUQE6D6.js';
2
+ import { explicitRunRetryPolicy, explicitRetryPolicy, ACTIVITY_NAME_PATTERN, TASK_QUEUE_NAME_PATTERN } from './chunk-5HIVIV53.js';
3
+
4
+ // src/durable/durations.ts
5
+ function toMs(value, what = "duration") {
6
+ const ms = durationMs(value, "ms");
7
+ if (ms === void 0) throw new TypeError(`${what} "${String(value)}" is not a duration`);
8
+ return Math.round(ms);
9
+ }
10
+ function optionalMs(value, what) {
11
+ return value === void 0 ? void 0 : toMs(value, what);
12
+ }
13
+
14
+ // src/durable/workflow.ts
15
+ var DURABLE_MARKER = "fluidgrids.durable-workflow";
16
+ var MAX_WORKFLOW_TASK_TIMEOUT_MS = 12e4;
17
+ function checkRunOptions(name, options) {
18
+ const where = `workflow("${name}")`;
19
+ for (const key of ["executionTimeout", "runTimeout", "workflowTaskTimeout"]) {
20
+ const value = options[key];
21
+ if (value !== void 0) toMs(value, `${where} ${key}`);
22
+ }
23
+ if (options.workflowTaskTimeout !== void 0 && toMs(options.workflowTaskTimeout) > MAX_WORKFLOW_TASK_TIMEOUT_MS)
24
+ throw new TypeError(`${where}: workflowTaskTimeout may be at most 120 s`);
25
+ if (options.versioningBehavior !== void 0 && options.versioningBehavior !== "PINNED" && options.versioningBehavior !== "AUTO_UPGRADE")
26
+ throw new TypeError(`${where}: versioningBehavior must be PINNED or AUTO_UPGRADE`);
27
+ const retry = options.retry;
28
+ if (retry !== void 0) {
29
+ checkRunRetryKeys(retry, `${where} retry`);
30
+ if (retry.maxAttempts !== void 0 && (!Number.isInteger(retry.maxAttempts) || retry.maxAttempts < 1))
31
+ throw new TypeError(`${where}: retry.maxAttempts must be a positive integer`);
32
+ if (retry.initialDelay !== void 0) toMs(retry.initialDelay, `${where} retry.initialDelay`);
33
+ if (retry.maxDelay !== void 0) toMs(retry.maxDelay, `${where} retry.maxDelay`);
34
+ if (retry.backoffMultiplier !== void 0 && !(Number.isFinite(retry.backoffMultiplier) && retry.backoffMultiplier >= 1))
35
+ throw new TypeError(`${where}: retry.backoffMultiplier must be at least 1`);
36
+ }
37
+ }
38
+ var KEY = /^[a-z0-9][a-z0-9_-]{0,127}$/;
39
+ function workflow(name, optionsOrFn, maybeFn) {
40
+ if (typeof name !== "string" || !KEY.test(name))
41
+ throw new TypeError(
42
+ `workflow() needs a key of lowercase letters, digits, "-" and "_" (got "${String(name)}")`
43
+ );
44
+ const fn = typeof optionsOrFn === "function" ? optionsOrFn : maybeFn;
45
+ const options = typeof optionsOrFn === "function" ? {} : optionsOrFn ?? {};
46
+ if (typeof fn !== "function") throw new TypeError(`workflow("${name}") needs a function`);
47
+ checkRunOptions(name, options);
48
+ return Object.freeze({ __fluidgrids: DURABLE_MARKER, name, options, fn });
49
+ }
50
+ function dynamicWorkflow(name, optionsOrFn, maybeFn) {
51
+ const fn = typeof optionsOrFn === "function" ? optionsOrFn : maybeFn;
52
+ const options = typeof optionsOrFn === "function" ? {} : optionsOrFn ?? {};
53
+ if (typeof fn !== "function") throw new TypeError(`dynamicWorkflow("${name}") needs a function`);
54
+ const declared = workflow(
55
+ name,
56
+ options,
57
+ (ctx, input) => fn(ctx, ctx.info.workflowFn, input)
58
+ );
59
+ return Object.freeze({ ...declared, dynamic: true });
60
+ }
61
+ function isDurableWorkflow(value) {
62
+ return typeof value === "object" && value !== null && value.__fluidgrids === DURABLE_MARKER && typeof value.fn === "function";
63
+ }
64
+ function isJsonValue(value, depth = 0) {
65
+ if (depth > 64) return false;
66
+ if (value === null || typeof value === "string" || typeof value === "boolean") return true;
67
+ if (typeof value === "number") return Number.isFinite(value);
68
+ if (Array.isArray(value)) return value.every((item) => isJsonValue(item, depth + 1));
69
+ if (typeof value === "object") {
70
+ if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null)
71
+ return false;
72
+ return Object.values(value).every((item) => isJsonValue(item, depth + 1));
73
+ }
74
+ return false;
75
+ }
76
+ function jsonSchemaOf(schema) {
77
+ if (schema === void 0) return void 0;
78
+ const method = schema.toJSONSchema;
79
+ if (typeof method === "function") {
80
+ const produced = method.call(schema);
81
+ return isJsonValue(produced) && typeof produced === "object" && !Array.isArray(produced) && produced !== null ? produced : void 0;
82
+ }
83
+ return isJsonValue(schema) && !Array.isArray(schema) && schema !== null && typeof schema === "object" ? schema : void 0;
84
+ }
85
+ function interfaceOf(definition) {
86
+ const out = {};
87
+ const input = jsonSchemaOf(definition.options.input);
88
+ const output = jsonSchemaOf(definition.options.output);
89
+ if (input) out.input = input;
90
+ if (output) out.output = output;
91
+ const signals = definition.options.signals ?? [];
92
+ if (signals.length > 0) {
93
+ out.signals = {};
94
+ for (const signal of signals) {
95
+ const entry = {};
96
+ const payload = jsonSchemaOf(signal.schema);
97
+ if (payload) entry.payload = payload;
98
+ if (signal.description !== void 0) entry.description = signal.description;
99
+ out.signals[signal.name] = entry;
100
+ }
101
+ }
102
+ const queries = definition.options.queries ?? [];
103
+ if (queries.length > 0) {
104
+ out.queries = {};
105
+ for (const query of queries)
106
+ out.queries[query.name] = query.description !== void 0 ? { description: query.description } : {};
107
+ }
108
+ const updates = definition.options.updates ?? [];
109
+ if (updates.length > 0) {
110
+ out.updates = {};
111
+ for (const update of updates)
112
+ out.updates[update.name] = update.description !== void 0 ? { description: update.description } : {};
113
+ }
114
+ const open = definition.options.open;
115
+ if (open !== void 0) {
116
+ const flags = {};
117
+ if (open.signals === true) flags.signals = true;
118
+ if (open.queries === true) flags.queries = true;
119
+ if (open.updates === true) flags.updates = true;
120
+ if (Object.keys(flags).length > 0) out.open = flags;
121
+ }
122
+ return out;
123
+ }
124
+ var RUN_RETRY_OPTION_KEYS = /* @__PURE__ */ new Set([
125
+ "maxAttempts",
126
+ "initialDelay",
127
+ "backoffMultiplier",
128
+ "maxDelay",
129
+ "nonRetryableErrorTypes"
130
+ ]);
131
+ var ACTIVITY_RETRY_ONLY_KEYS = /* @__PURE__ */ new Set([
132
+ "retryDelay",
133
+ "maxRetries",
134
+ "retryOnErrorTypes"
135
+ ]);
136
+ function checkRunRetryKeys(retry, where) {
137
+ if (typeof retry !== "object" || retry === null || Array.isArray(retry))
138
+ throw new TypeError(`${where} must be an object`);
139
+ for (const key of Object.keys(retry)) {
140
+ if (RUN_RETRY_OPTION_KEYS.has(key)) continue;
141
+ const hint = ACTIVITY_RETRY_ONLY_KEYS.has(key) ? " (that is the activity retry shape; a run-level retry takes maxAttempts, initialDelay, backoffMultiplier, maxDelay and nonRetryableErrorTypes)" : "";
142
+ throw new TypeError(`${where} has an unknown option "${key}"${hint}`);
143
+ }
144
+ }
145
+ function runRetryPolicyOf(retry) {
146
+ checkRunRetryKeys(retry, "retry");
147
+ const policy = {};
148
+ if (retry.maxAttempts !== void 0) policy.maxAttempts = retry.maxAttempts;
149
+ if (retry.initialDelay !== void 0)
150
+ policy.initialDelayMs = toMs(retry.initialDelay, "retry.initialDelay");
151
+ if (retry.backoffMultiplier !== void 0) policy.backoffMultiplier = retry.backoffMultiplier;
152
+ if (retry.maxDelay !== void 0) policy.maxDelayMs = toMs(retry.maxDelay, "retry.maxDelay");
153
+ if (retry.nonRetryableErrorTypes !== void 0)
154
+ policy.nonRetryableErrorTypes = [...retry.nonRetryableErrorTypes];
155
+ return explicitRunRetryPolicy(policy);
156
+ }
157
+ function continueAsNewRetryOf(retry) {
158
+ if (typeof retry !== "object" || retry === null || Array.isArray(retry))
159
+ throw new TypeError("continueAsNew retry must be an object");
160
+ const keys = Object.keys(retry);
161
+ const legacy = keys.some((key) => ACTIVITY_RETRY_ONLY_KEYS.has(key));
162
+ if (!legacy) return runRetryPolicyOf(retry);
163
+ if (keys.includes("maxAttempts") || keys.includes("initialDelay"))
164
+ throw new TypeError(
165
+ "continueAsNew retry mixes the activity retry shape (retryDelay, maxRetries) with the run-level one (maxAttempts, initialDelay); use the run-level keys"
166
+ );
167
+ return explicitRetryPolicy(retry);
168
+ }
169
+
170
+ // src/generated/version.ts
171
+ var SDK_VERSION = "2026.1030.1";
172
+
173
+ // src/durable/interceptors.ts
174
+ var INTERCEPTORS_MARKER = "fluidgrids.workflow-interceptors";
175
+ function workflowInterceptors(factory) {
176
+ if (typeof factory !== "function")
177
+ throw new TypeError("workflowInterceptors() needs a factory function");
178
+ return Object.freeze({ __fluidgrids: INTERCEPTORS_MARKER, factory });
179
+ }
180
+ function interceptorsFactoryOf(value) {
181
+ if (typeof value === "function") {
182
+ return value;
183
+ }
184
+ if (typeof value === "object" && value !== null && value.__fluidgrids === INTERCEPTORS_MARKER && typeof value.factory === "function")
185
+ return value.factory;
186
+ return void 0;
187
+ }
188
+ function resolveWorkflowInterceptors(factories) {
189
+ const inbound = [];
190
+ const outbound = [];
191
+ for (const factory of factories) {
192
+ const made = factory();
193
+ if (typeof made !== "object" || made === null)
194
+ throw new TypeError("An interceptors factory must return { inbound?, outbound? }");
195
+ const lists = made;
196
+ if (lists.inbound !== void 0) {
197
+ if (!Array.isArray(lists.inbound))
198
+ throw new TypeError("interceptors.inbound must be an array");
199
+ inbound.push(...lists.inbound);
200
+ }
201
+ if (lists.outbound !== void 0) {
202
+ if (!Array.isArray(lists.outbound))
203
+ throw new TypeError("interceptors.outbound must be an array");
204
+ outbound.push(...lists.outbound);
205
+ }
206
+ }
207
+ return { inbound, outbound };
208
+ }
209
+ function compose(interceptors, method, terminal) {
210
+ let next = terminal;
211
+ for (let index = interceptors.length - 1; index >= 0; index--) {
212
+ const interceptor = interceptors[index];
213
+ const fn = interceptor?.[method];
214
+ if (typeof fn !== "function") continue;
215
+ const inner = next;
216
+ const call = fn;
217
+ next = (input) => call.call(interceptor, input, inner);
218
+ }
219
+ return next;
220
+ }
221
+
222
+ // src/durable/activities.ts
223
+ var ACTIVITY_MARKER = "fluidgrids.activity";
224
+ var ACTIVITY_IMPL_MARKER = "fluidgrids.activity-impl";
225
+ var ACTIVITY_NAME = new RegExp(ACTIVITY_NAME_PATTERN);
226
+ var TASK_QUEUE_NAME = new RegExp(TASK_QUEUE_NAME_PATTERN);
227
+ var DYNAMIC_ACTIVITY_NAME = "*";
228
+ function checkActivityName(name) {
229
+ if (typeof name !== "string" || !ACTIVITY_NAME.test(name))
230
+ throw new TypeError(
231
+ `An activity name must match ${ACTIVITY_NAME_PATTERN} (got "${String(name)}")`
232
+ );
233
+ }
234
+ function checkTaskQueueName(queue, what = "taskQueue") {
235
+ if (typeof queue !== "string" || !TASK_QUEUE_NAME.test(queue))
236
+ throw new TypeError(`${what} must match ${TASK_QUEUE_NAME_PATTERN} (got "${String(queue)}")`);
237
+ }
238
+ function declareActivity(name, options = {}) {
239
+ checkActivityName(name);
240
+ if (options.taskQueue !== void 0) checkTaskQueueName(options.taskQueue);
241
+ return Object.freeze({ __fluidgrids: ACTIVITY_MARKER, name, options: { ...options } });
242
+ }
243
+ function implementActivity(definition, fn) {
244
+ if (!isActivityDefinition(definition))
245
+ throw new TypeError("implementActivity() needs a declareActivity() value");
246
+ if (typeof fn !== "function") throw new TypeError("implementActivity() needs a function");
247
+ return Object.freeze({
248
+ __fluidgrids: ACTIVITY_MARKER,
249
+ name: definition.name,
250
+ options: definition.options,
251
+ implementation: ACTIVITY_IMPL_MARKER,
252
+ fn,
253
+ dynamic: false
254
+ });
255
+ }
256
+ function defineActivity(name, optionsOrFn, maybeFn) {
257
+ const fn = typeof optionsOrFn === "function" ? optionsOrFn : maybeFn;
258
+ const options = typeof optionsOrFn === "function" ? {} : optionsOrFn;
259
+ if (typeof fn !== "function") throw new TypeError(`defineActivity("${name}") needs a function`);
260
+ return implementActivity(declareActivity(name, options), fn);
261
+ }
262
+ function dynamicActivity(fn, options = {}) {
263
+ if (typeof fn !== "function") throw new TypeError("dynamicActivity() needs a function");
264
+ if (options.taskQueue !== void 0) checkTaskQueueName(options.taskQueue);
265
+ return Object.freeze({
266
+ __fluidgrids: ACTIVITY_MARKER,
267
+ name: DYNAMIC_ACTIVITY_NAME,
268
+ options: { ...options },
269
+ implementation: ACTIVITY_IMPL_MARKER,
270
+ fn,
271
+ dynamic: true
272
+ });
273
+ }
274
+ function isActivityDefinition(value) {
275
+ return typeof value === "object" && value !== null && value.__fluidgrids === ACTIVITY_MARKER && typeof value.name === "string";
276
+ }
277
+ function isActivityImplementation(value) {
278
+ return isActivityDefinition(value) && value.implementation === ACTIVITY_IMPL_MARKER && typeof value.fn === "function";
279
+ }
280
+ function findActivityImplementation(implementations, name) {
281
+ return implementations.find((impl) => !impl.dynamic && impl.name === name) ?? implementations.find((impl) => impl.dynamic);
282
+ }
283
+ function executeActivity(implementation, ctx, args, interceptors = []) {
284
+ const fn = implementation.fn;
285
+ const run = compose(
286
+ interceptors,
287
+ "execute",
288
+ async (input) => fn(ctx, input.args)
289
+ );
290
+ return run({ args, headers: ctx.info.headers, info: ctx.info });
291
+ }
292
+
293
+ export { ACTIVITY_IMPL_MARKER, ACTIVITY_MARKER, DURABLE_MARKER, DYNAMIC_ACTIVITY_NAME, INTERCEPTORS_MARKER, MAX_WORKFLOW_TASK_TIMEOUT_MS, SDK_VERSION, checkActivityName, checkTaskQueueName, compose, continueAsNewRetryOf, declareActivity, defineActivity, dynamicActivity, dynamicWorkflow, executeActivity, findActivityImplementation, implementActivity, interceptorsFactoryOf, interfaceOf, isActivityDefinition, isActivityImplementation, isDurableWorkflow, jsonSchemaOf, optionalMs, resolveWorkflowInterceptors, runRetryPolicyOf, toMs, workflow, workflowInterceptors };
@@ -1,4 +1,4 @@
1
- import { HISTORY_PROTOCOL } from './chunk-DJYMDLV5.js';
1
+ import { HISTORY_PROTOCOL } from './chunk-5HIVIV53.js';
2
2
 
3
3
  function failedTaskResult(cause, message) {
4
4
  return {