@temelj/workflow 0.0.0-alpha.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 (393) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +38 -0
  3. package/dist/attributes.d.mts +15 -0
  4. package/dist/attributes.mjs +30 -0
  5. package/dist/client/create.d.mts +31 -0
  6. package/dist/client/create.mjs +67 -0
  7. package/dist/client/facades.d.mts +21 -0
  8. package/dist/client/facades.mjs +142 -0
  9. package/dist/client/mod.d.mts +2 -0
  10. package/dist/client/mod.mjs +2 -0
  11. package/dist/client/run-handle.d.mts +66 -0
  12. package/dist/client/run-handle.mjs +156 -0
  13. package/dist/client/worker-options.d.mts +17 -0
  14. package/dist/client/worker-options.mjs +25 -0
  15. package/dist/collection.d.mts +15 -0
  16. package/dist/collection.mjs +33 -0
  17. package/dist/compiled-function.d.mts +27 -0
  18. package/dist/compiled-function.mjs +54 -0
  19. package/dist/definition.d.mts +37 -0
  20. package/dist/definition.mjs +83 -0
  21. package/dist/engine/child-workflow.d.mts +10 -0
  22. package/dist/engine/child-workflow.mjs +333 -0
  23. package/dist/engine/command-identity.d.mts +9 -0
  24. package/dist/engine/command-identity.mjs +14 -0
  25. package/dist/engine/create.d.mts +106 -0
  26. package/dist/engine/create.mjs +402 -0
  27. package/dist/engine/deterministic.d.mts +12 -0
  28. package/dist/engine/deterministic.mjs +102 -0
  29. package/dist/engine/durable-command.d.mts +10 -0
  30. package/dist/engine/durable-command.mjs +17 -0
  31. package/dist/engine/execution-api.d.mts +29 -0
  32. package/dist/engine/execution-api.mjs +33 -0
  33. package/dist/engine/execution-service.d.mts +41 -0
  34. package/dist/engine/execution-service.mjs +288 -0
  35. package/dist/engine/hooks.d.mts +56 -0
  36. package/dist/engine/hooks.mjs +237 -0
  37. package/dist/engine/inspection-api.d.mts +34 -0
  38. package/dist/engine/inspection-api.mjs +77 -0
  39. package/dist/engine/inspection.d.mts +18 -0
  40. package/dist/engine/inspection.mjs +149 -0
  41. package/dist/engine/lifecycle.d.mts +18 -0
  42. package/dist/engine/lifecycle.mjs +38 -0
  43. package/dist/engine/lock-replay.d.mts +30 -0
  44. package/dist/engine/lock-replay.mjs +38 -0
  45. package/dist/engine/lock.d.mts +21 -0
  46. package/dist/engine/lock.mjs +197 -0
  47. package/dist/engine/message.d.mts +47 -0
  48. package/dist/engine/message.mjs +357 -0
  49. package/dist/engine/mod.d.mts +4 -0
  50. package/dist/engine/mod.mjs +2 -0
  51. package/dist/engine/observation.d.mts +35 -0
  52. package/dist/engine/observation.mjs +201 -0
  53. package/dist/engine/recovery.d.mts +26 -0
  54. package/dist/engine/recovery.mjs +92 -0
  55. package/dist/engine/replay.d.mts +41 -0
  56. package/dist/engine/replay.mjs +122 -0
  57. package/dist/engine/retry-policy.d.mts +4 -0
  58. package/dist/engine/retry-policy.mjs +4 -0
  59. package/dist/engine/retry.d.mts +23 -0
  60. package/dist/engine/retry.mjs +75 -0
  61. package/dist/engine/run-data.d.mts +9 -0
  62. package/dist/engine/run-data.mjs +74 -0
  63. package/dist/engine/run-service.d.mts +38 -0
  64. package/dist/engine/run-service.mjs +133 -0
  65. package/dist/engine/run-utils.d.mts +16 -0
  66. package/dist/engine/run-utils.mjs +83 -0
  67. package/dist/engine/schedule.d.mts +25 -0
  68. package/dist/engine/schedule.mjs +207 -0
  69. package/dist/engine/serialization.d.mts +9 -0
  70. package/dist/engine/serialization.mjs +85 -0
  71. package/dist/engine/start-api.d.mts +30 -0
  72. package/dist/engine/start-api.mjs +98 -0
  73. package/dist/engine/state.d.mts +77 -0
  74. package/dist/engine/state.mjs +464 -0
  75. package/dist/engine/step-api.d.mts +9 -0
  76. package/dist/engine/step-api.mjs +25 -0
  77. package/dist/engine/stream.d.mts +55 -0
  78. package/dist/engine/stream.mjs +333 -0
  79. package/dist/engine/summary/active-events.d.mts +34 -0
  80. package/dist/engine/summary/active-events.mjs +69 -0
  81. package/dist/engine/summary/child-workflow-runs.d.mts +24 -0
  82. package/dist/engine/summary/child-workflow-runs.mjs +138 -0
  83. package/dist/engine/summary/child-workflow-waits.d.mts +21 -0
  84. package/dist/engine/summary/child-workflow-waits.mjs +67 -0
  85. package/dist/engine/summary/recovery-child-workflow-waits.d.mts +11 -0
  86. package/dist/engine/summary/recovery-child-workflow-waits.mjs +89 -0
  87. package/dist/engine/summary/recovery-due-runs.d.mts +16 -0
  88. package/dist/engine/summary/recovery-due-runs.mjs +52 -0
  89. package/dist/engine/summary/recovery-failed-runs.d.mts +14 -0
  90. package/dist/engine/summary/recovery-failed-runs.mjs +33 -0
  91. package/dist/engine/summary/recovery-lease-runs.d.mts +16 -0
  92. package/dist/engine/summary/recovery-lease-runs.mjs +69 -0
  93. package/dist/engine/summary/recovery-locks.d.mts +18 -0
  94. package/dist/engine/summary/recovery-locks.mjs +100 -0
  95. package/dist/engine/summary/recovery-message-waits.d.mts +11 -0
  96. package/dist/engine/summary/recovery-message-waits.mjs +74 -0
  97. package/dist/engine/summary/recovery-retry-runs.d.mts +17 -0
  98. package/dist/engine/summary/recovery-retry-runs.mjs +65 -0
  99. package/dist/engine/summary/recovery-run-timestamps.d.mts +13 -0
  100. package/dist/engine/summary/recovery-run-timestamps.mjs +18 -0
  101. package/dist/engine/summary/recovery-runs.d.mts +23 -0
  102. package/dist/engine/summary/recovery-runs.mjs +54 -0
  103. package/dist/engine/summary/recovery-schedules.d.mts +10 -0
  104. package/dist/engine/summary/recovery-schedules.mjs +46 -0
  105. package/dist/engine/summary/recovery-sleep-waits.d.mts +10 -0
  106. package/dist/engine/summary/recovery-sleep-waits.mjs +53 -0
  107. package/dist/engine/summary/recovery-waits.d.mts +21 -0
  108. package/dist/engine/summary/recovery-waits.mjs +29 -0
  109. package/dist/engine/summary/run-availability.d.mts +13 -0
  110. package/dist/engine/summary/run-availability.mjs +37 -0
  111. package/dist/engine/summary/run-cleanup.d.mts +14 -0
  112. package/dist/engine/summary/run-cleanup.mjs +44 -0
  113. package/dist/engine/summary/run-failure.d.mts +14 -0
  114. package/dist/engine/summary/run-failure.mjs +62 -0
  115. package/dist/engine/summary/run-hooks.d.mts +14 -0
  116. package/dist/engine/summary/run-hooks.mjs +63 -0
  117. package/dist/engine/summary/run-lease.d.mts +11 -0
  118. package/dist/engine/summary/run-lease.mjs +64 -0
  119. package/dist/engine/summary/run-message-waits.d.mts +15 -0
  120. package/dist/engine/summary/run-message-waits.mjs +62 -0
  121. package/dist/engine/summary/run-metrics.d.mts +31 -0
  122. package/dist/engine/summary/run-metrics.mjs +93 -0
  123. package/dist/engine/summary/run-retry.d.mts +9 -0
  124. package/dist/engine/summary/run-retry.mjs +69 -0
  125. package/dist/engine/summary/run-sleeps.d.mts +15 -0
  126. package/dist/engine/summary/run-sleeps.mjs +61 -0
  127. package/dist/engine/summary/run-state.d.mts +26 -0
  128. package/dist/engine/summary/run-state.mjs +48 -0
  129. package/dist/engine/summary/run-status.d.mts +16 -0
  130. package/dist/engine/summary/run-status.mjs +35 -0
  131. package/dist/engine/summary/run-streams.d.mts +14 -0
  132. package/dist/engine/summary/run-streams.mjs +46 -0
  133. package/dist/engine/summary/run-transition.d.mts +9 -0
  134. package/dist/engine/summary/run-transition.mjs +39 -0
  135. package/dist/engine/summary/run-workflow.d.mts +9 -0
  136. package/dist/engine/summary/run-workflow.mjs +47 -0
  137. package/dist/engine/summary/step-attempt-active-child-workflows.d.mts +13 -0
  138. package/dist/engine/summary/step-attempt-active-child-workflows.mjs +55 -0
  139. package/dist/engine/summary/step-attempt-active-fields.d.mts +23 -0
  140. package/dist/engine/summary/step-attempt-active-fields.mjs +14 -0
  141. package/dist/engine/summary/step-attempt-active-message-waits.d.mts +12 -0
  142. package/dist/engine/summary/step-attempt-active-message-waits.mjs +47 -0
  143. package/dist/engine/summary/step-attempt-active-sleeps.d.mts +19 -0
  144. package/dist/engine/summary/step-attempt-active-sleeps.mjs +44 -0
  145. package/dist/engine/summary/step-attempt-buckets.d.mts +22 -0
  146. package/dist/engine/summary/step-attempt-buckets.mjs +152 -0
  147. package/dist/engine/summary/step-attempt-failure.d.mts +12 -0
  148. package/dist/engine/summary/step-attempt-failure.mjs +61 -0
  149. package/dist/engine/summary/step-attempt-lifecycle.d.mts +13 -0
  150. package/dist/engine/summary/step-attempt-lifecycle.mjs +19 -0
  151. package/dist/engine/summary/step-attempts.d.mts +11 -0
  152. package/dist/engine/summary/step-attempts.mjs +43 -0
  153. package/dist/engine/summary.d.mts +32 -0
  154. package/dist/engine/summary.mjs +37 -0
  155. package/dist/engine/task.d.mts +6 -0
  156. package/dist/engine/task.mjs +207 -0
  157. package/dist/errors/base.d.mts +99 -0
  158. package/dist/errors/base.mjs +426 -0
  159. package/dist/errors/capability.d.mts +11 -0
  160. package/dist/errors/capability.mjs +23 -0
  161. package/dist/errors/definition.d.mts +21 -0
  162. package/dist/errors/definition.mjs +51 -0
  163. package/dist/errors/details.d.mts +13 -0
  164. package/dist/errors/details.mjs +65 -0
  165. package/dist/errors/failures.d.mts +81 -0
  166. package/dist/errors/failures.mjs +168 -0
  167. package/dist/errors/hook.d.mts +14 -0
  168. package/dist/errors/hook.mjs +30 -0
  169. package/dist/errors/implementation.d.mts +11 -0
  170. package/dist/errors/implementation.mjs +25 -0
  171. package/dist/errors/lock.d.mts +28 -0
  172. package/dist/errors/lock.mjs +70 -0
  173. package/dist/errors/message.d.mts +106 -0
  174. package/dist/errors/message.mjs +122 -0
  175. package/dist/errors/mod.d.mts +17 -0
  176. package/dist/errors/mod.mjs +17 -0
  177. package/dist/errors/record-view.d.mts +11 -0
  178. package/dist/errors/record-view.mjs +24 -0
  179. package/dist/errors/records.d.mts +7 -0
  180. package/dist/errors/records.mjs +280 -0
  181. package/dist/errors/run.d.mts +116 -0
  182. package/dist/errors/run.mjs +232 -0
  183. package/dist/errors/runtime.d.mts +12 -0
  184. package/dist/errors/runtime.mjs +24 -0
  185. package/dist/errors/schedule.d.mts +27 -0
  186. package/dist/errors/schedule.mjs +65 -0
  187. package/dist/errors/step.d.mts +76 -0
  188. package/dist/errors/step.mjs +113 -0
  189. package/dist/errors/stream.d.mts +24 -0
  190. package/dist/errors/stream.mjs +64 -0
  191. package/dist/esbuild.d.mts +7 -0
  192. package/dist/esbuild.mjs +6 -0
  193. package/dist/events/descriptors.d.mts +245 -0
  194. package/dist/events/descriptors.mjs +405 -0
  195. package/dist/events/mod.d.mts +3 -0
  196. package/dist/events/mod.mjs +2 -0
  197. package/dist/history/attempt-key.d.mts +6 -0
  198. package/dist/history/attempt-key.mjs +7 -0
  199. package/dist/history/mod.d.mts +71 -0
  200. package/dist/history/mod.mjs +195 -0
  201. package/dist/history/projection.d.mts +8 -0
  202. package/dist/history/projection.mjs +259 -0
  203. package/dist/history/replay-projection.d.mts +88 -0
  204. package/dist/history/replay-projection.mjs +369 -0
  205. package/dist/history/sequencer.d.mts +16 -0
  206. package/dist/history/sequencer.mjs +78 -0
  207. package/dist/history/step-attempts.d.mts +9 -0
  208. package/dist/history/step-attempts.mjs +50 -0
  209. package/dist/history/timeline.d.mts +16 -0
  210. package/dist/history/timeline.mjs +272 -0
  211. package/dist/history/validator.d.mts +9 -0
  212. package/dist/history/validator.mjs +110 -0
  213. package/dist/inspection/mod.d.mts +5 -0
  214. package/dist/inspection/mod.mjs +3 -0
  215. package/dist/message-options.d.mts +8 -0
  216. package/dist/message-options.mjs +25 -0
  217. package/dist/mod.d.mts +52 -0
  218. package/dist/mod.mjs +26 -0
  219. package/dist/otel/support.d.mts +18 -0
  220. package/dist/otel/support.mjs +102 -0
  221. package/dist/otel.d.mts +30 -0
  222. package/dist/otel.mjs +588 -0
  223. package/dist/pagination.d.mts +25 -0
  224. package/dist/pagination.mjs +73 -0
  225. package/dist/registry.d.mts +20 -0
  226. package/dist/registry.mjs +48 -0
  227. package/dist/rolldown.d.mts +7 -0
  228. package/dist/rolldown.mjs +6 -0
  229. package/dist/rollup.d.mts +7 -0
  230. package/dist/rollup.mjs +6 -0
  231. package/dist/rspack.d.mts +7 -0
  232. package/dist/rspack.mjs +6 -0
  233. package/dist/runtime.d.mts +34 -0
  234. package/dist/runtime.mjs +194 -0
  235. package/dist/step-definition.d.mts +10 -0
  236. package/dist/step-definition.mjs +15 -0
  237. package/dist/store/append-projection.d.mts +15 -0
  238. package/dist/store/append-projection.mjs +26 -0
  239. package/dist/store/capabilities.d.mts +14 -0
  240. package/dist/store/capabilities.mjs +42 -0
  241. package/dist/store/cleanup.d.mts +18 -0
  242. package/dist/store/cleanup.mjs +338 -0
  243. package/dist/store/compaction.d.mts +5 -0
  244. package/dist/store/compaction.mjs +8 -0
  245. package/dist/store/create.d.mts +52 -0
  246. package/dist/store/create.mjs +159 -0
  247. package/dist/store/event-append-project.d.mts +15 -0
  248. package/dist/store/event-append-project.mjs +77 -0
  249. package/dist/store/event-append.d.mts +37 -0
  250. package/dist/store/event-append.mjs +80 -0
  251. package/dist/store/event-history.d.mts +22 -0
  252. package/dist/store/event-history.mjs +75 -0
  253. package/dist/store/event.d.mts +10 -0
  254. package/dist/store/event.mjs +28 -0
  255. package/dist/store/idempotency.d.mts +10 -0
  256. package/dist/store/idempotency.mjs +167 -0
  257. package/dist/store/instrumentation.d.mts +7 -0
  258. package/dist/store/instrumentation.mjs +123 -0
  259. package/dist/store/lock.d.mts +8 -0
  260. package/dist/store/lock.mjs +28 -0
  261. package/dist/store/materialization.d.mts +30 -0
  262. package/dist/store/materialization.mjs +127 -0
  263. package/dist/store/message-index.d.mts +21 -0
  264. package/dist/store/message-index.mjs +121 -0
  265. package/dist/store/mod.d.mts +5 -0
  266. package/dist/store/mod.mjs +4 -0
  267. package/dist/store/query.d.mts +24 -0
  268. package/dist/store/query.mjs +82 -0
  269. package/dist/store/revision.d.mts +4 -0
  270. package/dist/store/revision.mjs +7 -0
  271. package/dist/store/run.d.mts +49 -0
  272. package/dist/store/run.mjs +236 -0
  273. package/dist/store/schedule.d.mts +12 -0
  274. package/dist/store/schedule.mjs +41 -0
  275. package/dist/store/schema.d.mts +14 -0
  276. package/dist/store/schema.mjs +17 -0
  277. package/dist/store/step-attempt.d.mts +14 -0
  278. package/dist/store/step-attempt.mjs +23 -0
  279. package/dist/store/storage-value.d.mts +5 -0
  280. package/dist/store/storage-value.mjs +6 -0
  281. package/dist/store/validation.d.mts +35 -0
  282. package/dist/store/validation.mjs +77 -0
  283. package/dist/store-keys.d.mts +49 -0
  284. package/dist/store-keys.mjs +63 -0
  285. package/dist/telemetry.d.mts +132 -0
  286. package/dist/telemetry.mjs +172 -0
  287. package/dist/temporal.d.mts +23 -0
  288. package/dist/temporal.mjs +59 -0
  289. package/dist/timer.d.mts +12 -0
  290. package/dist/timer.mjs +28 -0
  291. package/dist/types/cleanup.d.mts +112 -0
  292. package/dist/types/cleanup.mjs +22 -0
  293. package/dist/types/client.d.mts +270 -0
  294. package/dist/types/client.mjs +1 -0
  295. package/dist/types/common.d.mts +19 -0
  296. package/dist/types/common.mjs +15 -0
  297. package/dist/types/definition.d.mts +92 -0
  298. package/dist/types/definition.mjs +1 -0
  299. package/dist/types/engine-options.d.mts +76 -0
  300. package/dist/types/engine-options.mjs +1 -0
  301. package/dist/types/engine.d.mts +309 -0
  302. package/dist/types/engine.mjs +1 -0
  303. package/dist/types/error-code.d.mts +256 -0
  304. package/dist/types/error-code.mjs +131 -0
  305. package/dist/types/error.d.mts +236 -0
  306. package/dist/types/error.mjs +48 -0
  307. package/dist/types/events.d.mts +2869 -0
  308. package/dist/types/events.mjs +283 -0
  309. package/dist/types/hook.d.mts +149 -0
  310. package/dist/types/hook.mjs +66 -0
  311. package/dist/types/lock.d.mts +63 -0
  312. package/dist/types/lock.mjs +18 -0
  313. package/dist/types/message-id.d.mts +7 -0
  314. package/dist/types/message-id.mjs +5 -0
  315. package/dist/types/message.d.mts +87 -0
  316. package/dist/types/message.mjs +1 -0
  317. package/dist/types/observation.d.mts +146 -0
  318. package/dist/types/observation.mjs +1 -0
  319. package/dist/types/pagination.d.mts +32 -0
  320. package/dist/types/pagination.mjs +13 -0
  321. package/dist/types/result.d.mts +62 -0
  322. package/dist/types/result.mjs +1 -0
  323. package/dist/types/retry.d.mts +48 -0
  324. package/dist/types/retry.mjs +1 -0
  325. package/dist/types/run-id.d.mts +7 -0
  326. package/dist/types/run-id.mjs +5 -0
  327. package/dist/types/run-list.d.mts +43 -0
  328. package/dist/types/run-list.mjs +1 -0
  329. package/dist/types/run-options.d.mts +86 -0
  330. package/dist/types/run-options.mjs +1 -0
  331. package/dist/types/run.d.mts +355 -0
  332. package/dist/types/run.mjs +207 -0
  333. package/dist/types/runtime.d.mts +143 -0
  334. package/dist/types/runtime.mjs +21 -0
  335. package/dist/types/schedule.d.mts +127 -0
  336. package/dist/types/schedule.mjs +48 -0
  337. package/dist/types/step-attempts.d.mts +326 -0
  338. package/dist/types/step-attempts.mjs +43 -0
  339. package/dist/types/step-id.d.mts +7 -0
  340. package/dist/types/step-id.mjs +5 -0
  341. package/dist/types/step.d.mts +183 -0
  342. package/dist/types/step.mjs +5 -0
  343. package/dist/types/store.d.mts +254 -0
  344. package/dist/types/store.mjs +1 -0
  345. package/dist/types/stream-id.d.mts +7 -0
  346. package/dist/types/stream-id.mjs +5 -0
  347. package/dist/types/stream.d.mts +126 -0
  348. package/dist/types/stream.mjs +1 -0
  349. package/dist/types/summary.d.mts +318 -0
  350. package/dist/types/summary.mjs +1 -0
  351. package/dist/types/telemetry.d.mts +74 -0
  352. package/dist/types/telemetry.mjs +9 -0
  353. package/dist/types/timeline.d.mts +237 -0
  354. package/dist/types/timeline.mjs +1 -0
  355. package/dist/types/vite.d.mts +65 -0
  356. package/dist/types/vite.mjs +1 -0
  357. package/dist/types/worker-id.d.mts +7 -0
  358. package/dist/types/worker-id.mjs +5 -0
  359. package/dist/types/worker.d.mts +94 -0
  360. package/dist/types/worker.mjs +1 -0
  361. package/dist/utility.d.mts +49 -0
  362. package/dist/utility.mjs +122 -0
  363. package/dist/vite/ast.d.mts +23 -0
  364. package/dist/vite/ast.mjs +73 -0
  365. package/dist/vite/error.d.mts +19 -0
  366. package/dist/vite/error.mjs +47 -0
  367. package/dist/vite/generated-name.d.mts +7 -0
  368. package/dist/vite/generated-name.mjs +9 -0
  369. package/dist/vite/manifest.d.mts +7 -0
  370. package/dist/vite/manifest.mjs +106 -0
  371. package/dist/vite/plugin.d.mts +7 -0
  372. package/dist/vite/plugin.mjs +190 -0
  373. package/dist/vite/safety.d.mts +12 -0
  374. package/dist/vite/safety.mjs +96 -0
  375. package/dist/vite/source-edit.d.mts +12 -0
  376. package/dist/vite/source-edit.mjs +44 -0
  377. package/dist/vite/source-map.d.mts +11 -0
  378. package/dist/vite/source-map.mjs +53 -0
  379. package/dist/vite/source.d.mts +7 -0
  380. package/dist/vite/source.mjs +14 -0
  381. package/dist/vite/transform.d.mts +7 -0
  382. package/dist/vite/transform.mjs +405 -0
  383. package/dist/vite.d.mts +6 -0
  384. package/dist/vite.mjs +5 -0
  385. package/dist/webhook.d.mts +16 -0
  386. package/dist/webhook.mjs +17 -0
  387. package/dist/webpack.d.mts +7 -0
  388. package/dist/webpack.mjs +6 -0
  389. package/dist/worker/error.d.mts +11 -0
  390. package/dist/worker/error.mjs +40 -0
  391. package/dist/worker.d.mts +18 -0
  392. package/dist/worker.mjs +427 -0
  393. package/package.json +144 -0
@@ -0,0 +1,270 @@
1
+ import { RunId } from "./run-id.mjs";
2
+ import { CleanupMarkerRecord, CleanupRunsOptions, CleanupRunsResult, RetentionPolicyOptions } from "./cleanup.mjs";
3
+ import { PageOptions, WorkflowPage } from "./pagination.mjs";
4
+ import { ListSchedulesOptions, ListSchedulesPageOptions, ScheduleConfig, ScheduleId, ScheduleRecord, TickSchedulesOptions, TickSchedulesResult } from "./schedule.mjs";
5
+ import { WorkflowMissingImplementationRetryConfig } from "./retry.mjs";
6
+ import { WorkflowDefinition, WorkflowHandler, WorkflowImplementation, WorkflowStartTarget } from "./definition.mjs";
7
+ import { HookInspection, ResumeHookOptions, ResumeWebhookOptions } from "./hook.mjs";
8
+ import { AcquireLockOptions, LockRecord, ReleaseLockOptions, ReleaseStaleLockOptions } from "./lock.mjs";
9
+ import { WorkflowListRunsOptions, WorkflowListRunsPageOptions, WorkflowListStepAttemptsPageOptions } from "./run-list.mjs";
10
+ import { BroadcastMessageChannelOptions, BroadcastMessageInput, BroadcastMessageResult, MessageChannel, SendMessageChannelOptions, SendMessageInput } from "./message.mjs";
11
+ import { StreamIdOrName } from "./stream-id.mjs";
12
+ import { FollowStreamOptions, ReadStreamOptions, ReadStreamPageOptions, StreamChunk, StreamInfo, StreamPage, StreamState, StreamUpdate, WaitStreamOptions } from "./stream.mjs";
13
+ import { WorkflowRecoverySummary, WorkflowRecoverySummaryOptions, WorkflowRunSummary, WorkflowRunSummaryOptions } from "./summary.mjs";
14
+ import { WorkflowListStepAttemptsOptions, WorkflowStepAttemptRecord, WorkflowStepAttemptSummary } from "./step-attempts.mjs";
15
+ import { WorkerId } from "./worker-id.mjs";
16
+ import { Timeline } from "./timeline.mjs";
17
+ import { ResultOptions } from "./result.mjs";
18
+ import { WorkflowAttributePatch, WorkflowRunRecord, WorkflowRunStatus } from "./run.mjs";
19
+ import { EventRecord } from "./events.mjs";
20
+ import { ScheduleNextOptions, WorkflowBatchStartItem, WorkflowMarkRunPermanentlyFailedOptions, WorkflowReleaseStaleLeaseOptions, WorkflowRerunOptions, WorkflowRescheduleRunOptions, WorkflowRetryFailedRunOptions, WorkflowRunArguments, WorkflowStartOptions } from "./run-options.mjs";
21
+ import { WorkflowWakeDueRunsOptions, WorkflowWorker, WorkflowWorkerRunFilterOptions, WorkflowWorkerRunResult } from "./worker.mjs";
22
+ //#region src/types/client.d.ts
23
+ /** Function shape emitted by the directive compiler for workflow and step functions. */
24
+ type CompiledWorkflowFunction<TArgs extends readonly unknown[], TOutput> = (...args: TArgs) => Promise<TOutput> | TOutput;
25
+ /** Client-level handle for awaiting output and inspecting a workflow run. */
26
+ interface WorkflowRunHandle<TOutput = unknown> {
27
+ /** ID of the workflow run represented by this handle. */
28
+ readonly runId: RunId;
29
+ /** Workflow definition name stored on the run. */
30
+ readonly workflowName: string;
31
+ /** Workflow version stored on the run, when one was resolved. */
32
+ readonly workflowVersion?: string;
33
+ /** Returns the latest run record. */
34
+ getRun(): Promise<WorkflowRunRecord>;
35
+ /** Returns the latest run status. */
36
+ status(): Promise<WorkflowRunStatus>;
37
+ /** Returns all durable events recorded for the run. */
38
+ events(): Promise<readonly EventRecord[]>;
39
+ /** Returns a timeline projection of the run's event history. */
40
+ timeline(): Promise<Timeline>;
41
+ /** Waits for and returns the completed workflow output. */
42
+ result(options?: ResultOptions): Promise<TOutput>;
43
+ /** Returns metadata for a durable stream on this run. */
44
+ getStreamInfo(streamIdOrName: StreamIdOrName): Promise<StreamInfo>;
45
+ /** Follows durable stream updates from this run. */
46
+ followStream<TChunk = unknown>(streamIdOrName: StreamIdOrName, options?: FollowStreamOptions): AsyncIterable<StreamUpdate<TChunk>>;
47
+ /** Waits until a durable stream exists on this run. */
48
+ waitForStream(streamIdOrName: StreamIdOrName, options?: WaitStreamOptions): Promise<StreamInfo | undefined>;
49
+ /** Waits for the next durable stream chunk after an index. */
50
+ waitForStreamChunk<TChunk = unknown>(streamIdOrName: StreamIdOrName, afterIndex: number, options?: WaitStreamOptions): Promise<StreamChunk<TChunk> | undefined>;
51
+ /** Waits until a durable stream is closed or failed. */
52
+ waitForStreamTerminal(streamIdOrName: StreamIdOrName, options?: WaitStreamOptions): Promise<StreamInfo | undefined>;
53
+ /** Reads all currently stored chunks for a durable stream. */
54
+ readStream<TChunk = unknown>(streamIdOrName: StreamIdOrName, options?: ReadStreamOptions): Promise<StreamState<TChunk>>;
55
+ /** Reads one page of currently stored chunks for a durable stream. */
56
+ readStreamPage<TChunk = unknown>(streamIdOrName: StreamIdOrName, options?: ReadStreamPageOptions): Promise<StreamPage<TChunk>>;
57
+ /** Moves the run back to pending at an optional new availability time. */
58
+ reschedule(options?: WorkflowRescheduleRunOptions): Promise<WorkflowRunRecord>;
59
+ /** Releases this run's worker lease when it is stale. */
60
+ releaseStaleLease(options?: WorkflowReleaseStaleLeaseOptions): Promise<WorkflowRunRecord>;
61
+ /** Retries this failed run. */
62
+ retryFailed(options?: WorkflowRetryFailedRunOptions): Promise<WorkflowRunRecord>;
63
+ /** Marks this run as permanently failed with an operator reason. */
64
+ markPermanentlyFailed(options: WorkflowMarkRunPermanentlyFailedOptions): Promise<WorkflowRunRecord>;
65
+ /** Replaces this run's metadata value. */
66
+ setMetadata(metadata: unknown): Promise<WorkflowRunRecord>;
67
+ /** Applies an attribute patch to this run. */
68
+ setAttributes(attributes: WorkflowAttributePatch): Promise<WorkflowRunRecord>;
69
+ /** Cancels this run if it has not already reached a terminal status. */
70
+ cancel(): Promise<WorkflowRunRecord>;
71
+ }
72
+ /** Runnable wrapper that starts a workflow definition through a bound client. */
73
+ interface WorkflowRunnable<TInput = unknown, TOutput = unknown, TRawInput = TInput> {
74
+ /** Workflow definition that will be started by run. */
75
+ readonly definition: WorkflowDefinition<TInput, TOutput, TRawInput>;
76
+ /** Starts the workflow through the bound client and returns a run handle. */
77
+ run(...args: WorkflowRunArguments<TRawInput, WorkflowStartOptions>): Promise<WorkflowRunHandle<TOutput>>;
78
+ }
79
+ /** Describes the workflow client contract. */
80
+ interface WorkflowClient {
81
+ /** Grouped run inspection and history operations. */
82
+ readonly runs: WorkflowClientRunsApi;
83
+ /** Grouped administrative run maintenance operations. */
84
+ readonly admin: WorkflowClientAdminApi;
85
+ /** Grouped schedule management operations. */
86
+ readonly schedules: WorkflowClientSchedulesApi;
87
+ /** Grouped workflow lock operations. */
88
+ readonly locks: WorkflowClientLocksApi;
89
+ /** Grouped external resume hook operations. */
90
+ readonly hooks: WorkflowClientHooksApi;
91
+ /** Grouped durable stream read operations. */
92
+ readonly streams: WorkflowClientStreamsApi;
93
+ /** Grouped message send operations. */
94
+ readonly messages: WorkflowClientMessagesApi;
95
+ /** Grouped worker creation and wake operations. */
96
+ readonly workers: WorkflowClientWorkersApi;
97
+ /** Flushes resources owned by the underlying engine when it supports explicit shutdown. */
98
+ close(): Promise<void>;
99
+ /** Registers a workflow implementation in the client's registry. */
100
+ implementWorkflow<TInput, TOutput, TRawInput = TInput>(definition: WorkflowDefinition<TInput, TOutput, TRawInput>, handler: WorkflowHandler<TInput, TOutput>): WorkflowImplementation<TInput, TOutput, TRawInput>;
101
+ /** Registers an existing workflow implementation in the client's registry. */
102
+ register<TInput, TOutput, TRawInput = TInput>(implementation: WorkflowImplementation<TInput, TOutput, TRawInput>): void;
103
+ /** Registers a workflow implementation and returns a client-bound runnable. */
104
+ workflow<TInput, TOutput, TRawInput = TInput>(definition: WorkflowDefinition<TInput, TOutput, TRawInput>, handler: WorkflowHandler<TInput, TOutput>): WorkflowRunnable<TInput, TOutput, TRawInput>;
105
+ }
106
+ /** Describes the workflow client runs API contract. */
107
+ interface WorkflowClientRunsApi {
108
+ /** Starts one workflow run and returns a typed handle. */
109
+ start<TInput, TOutput, TRawInput = TInput>(workflow: WorkflowStartTarget<TInput, TOutput, TRawInput>, ...args: WorkflowRunArguments<TRawInput, WorkflowStartOptions>): Promise<WorkflowRunHandle<TOutput>>;
110
+ /** Starts multiple workflow runs for the same definition. */
111
+ startBatch<TInput, TOutput, TRawInput = TInput>(workflow: WorkflowStartTarget<TInput, TOutput, TRawInput>, items: readonly WorkflowBatchStartItem<TRawInput>[]): Promise<readonly WorkflowRunHandle<TOutput>[]>;
112
+ /** Returns a workflow run by ID, if it exists. */
113
+ get(runId: RunId): Promise<WorkflowRunRecord | undefined>;
114
+ /** Returns all durable events recorded for a run. */
115
+ events(runId: RunId): Promise<readonly EventRecord[]>;
116
+ /** Lists one page of durable events recorded for a run. */
117
+ eventsPage(runId: RunId, options?: PageOptions): Promise<WorkflowPage<EventRecord>>;
118
+ /** Lists workflow runs matching optional filters. */
119
+ list(options?: WorkflowListRunsOptions): Promise<readonly WorkflowRunRecord[]>;
120
+ /** Lists one page of workflow runs matching optional filters. */
121
+ page(options?: WorkflowListRunsPageOptions): Promise<WorkflowPage<WorkflowRunRecord>>;
122
+ /** Counts workflow runs matching optional filters. */
123
+ count(options?: WorkflowListRunsOptions): Promise<number>;
124
+ /** Returns aggregate run metrics for runs matching optional filters. */
125
+ summary(options?: WorkflowRunSummaryOptions): Promise<WorkflowRunSummary>;
126
+ /** Returns recovery-oriented aggregate metrics for runs matching optional filters. */
127
+ recovery(options?: WorkflowRecoverySummaryOptions): Promise<WorkflowRecoverySummary>;
128
+ /** Returns a timeline projection for one run. */
129
+ timeline(runId: RunId): Promise<Timeline>;
130
+ /** Lists materialized step attempts for a run. */
131
+ listStepAttempts(runId: RunId, options?: WorkflowListStepAttemptsOptions): Promise<readonly WorkflowStepAttemptRecord[]>;
132
+ /** Lists one page of materialized step attempts for a run. */
133
+ listStepAttemptsPage(runId: RunId, options?: WorkflowListStepAttemptsPageOptions): Promise<WorkflowPage<WorkflowStepAttemptRecord>>;
134
+ /** Counts materialized step attempts for a run. */
135
+ countStepAttempts(runId: RunId, options?: WorkflowListStepAttemptsOptions): Promise<number>;
136
+ /** Returns aggregate step-attempt metrics for a run. */
137
+ stepAttemptSummary(runId: RunId, options?: WorkflowListStepAttemptsOptions): Promise<WorkflowStepAttemptSummary>;
138
+ }
139
+ /** Describes the workflow client admin API contract. */
140
+ interface WorkflowClientAdminApi {
141
+ /** Deletes terminal run data according to cleanup options. */
142
+ cleanup(options: CleanupRunsOptions): Promise<CleanupRunsResult>;
143
+ /** Lists cleanup marker records. */
144
+ cleanupMarkers(): Promise<readonly CleanupMarkerRecord[]>;
145
+ /** Deletes terminal run data according to a retention policy. */
146
+ applyRetentionPolicy(options: RetentionPolicyOptions): Promise<CleanupRunsResult>;
147
+ /** Creates a new run from an existing run record and returns its handle. */
148
+ rerun(runId: RunId, options?: WorkflowRerunOptions): Promise<WorkflowRunHandle<unknown>>;
149
+ /** Moves a run back to pending at an optional new availability time. */
150
+ reschedule(runId: RunId, options?: WorkflowRescheduleRunOptions): Promise<WorkflowRunRecord>;
151
+ /** Releases a run's worker lease when it is stale. */
152
+ releaseStaleLease(runId: RunId, options?: WorkflowReleaseStaleLeaseOptions): Promise<WorkflowRunRecord>;
153
+ /** Retries a failed workflow run. */
154
+ retryFailed(runId: RunId, options?: WorkflowRetryFailedRunOptions): Promise<WorkflowRunRecord>;
155
+ /** Marks a workflow run as permanently failed with an operator reason. */
156
+ markPermanentlyFailed(runId: RunId, options: WorkflowMarkRunPermanentlyFailedOptions): Promise<WorkflowRunRecord>;
157
+ /** Replaces a workflow run's metadata value. */
158
+ updateMetadata(runId: RunId, metadata: unknown): Promise<WorkflowRunRecord>;
159
+ /** Applies an attribute patch to a workflow run. */
160
+ setAttributes(runId: RunId, attributes: WorkflowAttributePatch): Promise<WorkflowRunRecord>;
161
+ /** Cancels a workflow run if it has not already reached a terminal status. */
162
+ cancel(runId: RunId): Promise<WorkflowRunRecord>;
163
+ }
164
+ /** Describes the workflow client schedules API contract. */
165
+ interface WorkflowClientSchedulesApi {
166
+ /** Schedules one workflow run at the next interval boundary. */
167
+ next<TInput, TOutput, TRawInput = TInput>(workflow: WorkflowStartTarget<TInput, TOutput, TRawInput>, input: TRawInput, options: ScheduleNextOptions): Promise<WorkflowRunHandle<TOutput>>;
168
+ /** Creates a recurring workflow schedule. */
169
+ create<TInput, TOutput, TRawInput = TInput>(workflow: WorkflowStartTarget<TInput, TOutput, TRawInput>, options: ScheduleConfig<TInput, TRawInput>): Promise<ScheduleRecord<TInput>>;
170
+ /** Creates or updates a recurring workflow schedule. */
171
+ upsert<TInput, TOutput, TRawInput = TInput>(workflow: WorkflowStartTarget<TInput, TOutput, TRawInput>, options: ScheduleConfig<TInput, TRawInput>): Promise<ScheduleRecord<TInput>>;
172
+ /** Returns a schedule by ID, if it exists. */
173
+ get(scheduleId: ScheduleId): Promise<ScheduleRecord | undefined>;
174
+ /** Lists schedules matching optional filters. */
175
+ list(options?: ListSchedulesOptions): Promise<readonly ScheduleRecord[]>;
176
+ /** Lists one page of schedules matching optional filters. */
177
+ page(options?: ListSchedulesPageOptions): Promise<WorkflowPage<ScheduleRecord>>;
178
+ /** Pauses an active schedule. */
179
+ pause(scheduleId: ScheduleId): Promise<ScheduleRecord>;
180
+ /** Resumes a paused or archived schedule. */
181
+ resume(scheduleId: ScheduleId): Promise<ScheduleRecord>;
182
+ /** Archives a schedule without deleting its record. */
183
+ archive(scheduleId: ScheduleId): Promise<ScheduleRecord>;
184
+ /** Marks a schedule as deleted. */
185
+ delete(scheduleId: ScheduleId): Promise<ScheduleRecord>;
186
+ /** Starts runs for schedules that are due. */
187
+ tick(options?: TickSchedulesOptions): Promise<TickSchedulesResult>;
188
+ }
189
+ /** Describes the workflow client locks API contract. */
190
+ interface WorkflowClientLocksApi {
191
+ /** Acquires a workflow lock. */
192
+ acquire(key: string, options: AcquireLockOptions): Promise<LockRecord>;
193
+ /** Returns a workflow lock by key, if it exists. */
194
+ get(key: string): Promise<LockRecord | undefined>;
195
+ /** Lists workflow locks. */
196
+ list(): Promise<readonly LockRecord[]>;
197
+ /** Releases a workflow lock held by the supplied holder. */
198
+ release(key: string, options: ReleaseLockOptions): Promise<LockRecord>;
199
+ /** Releases a workflow lock only when its lease is stale. */
200
+ releaseStale(key: string, options?: ReleaseStaleLockOptions): Promise<LockRecord>;
201
+ }
202
+ /** Describes the workflow client external hook API contract. */
203
+ interface WorkflowClientHooksApi {
204
+ /** Completes a pending message-backed external resume hook. */
205
+ resume(token: string, options?: ResumeHookOptions): Promise<void>;
206
+ /** Completes a pending webhook-labeled external resume hook. */
207
+ resumeWebhook(token: string, options?: ResumeWebhookOptions): Promise<void>;
208
+ /** Disposes a pending message-backed external resume hook. */
209
+ dispose(token: string): Promise<HookInspection>;
210
+ /** Disposes a pending webhook-labeled external resume hook. */
211
+ disposeWebhook(token: string): Promise<HookInspection>;
212
+ /** Returns inspection data for an external resume hook token. */
213
+ getByToken(token: string): Promise<HookInspection>;
214
+ }
215
+ /** Describes the workflow client streams API contract. */
216
+ interface WorkflowClientStreamsApi {
217
+ /** Returns metadata for a durable stream on a run. */
218
+ getInfo(runId: RunId, streamIdOrName: StreamIdOrName): Promise<StreamInfo>;
219
+ /** Follows durable stream updates from a run. */
220
+ follow<TChunk = unknown>(runId: RunId, streamIdOrName: StreamIdOrName, options?: FollowStreamOptions): AsyncIterable<StreamUpdate<TChunk>>;
221
+ /** Waits until a durable stream exists on a run. */
222
+ wait(runId: RunId, streamIdOrName: StreamIdOrName, options?: WaitStreamOptions): Promise<StreamInfo | undefined>;
223
+ /** Waits for the next durable stream chunk after an index. */
224
+ waitForChunk<TChunk = unknown>(runId: RunId, streamIdOrName: StreamIdOrName, afterIndex: number, options?: WaitStreamOptions): Promise<StreamChunk<TChunk> | undefined>;
225
+ /** Waits until a durable stream is closed or failed. */
226
+ waitForTerminal(runId: RunId, streamIdOrName: StreamIdOrName, options?: WaitStreamOptions): Promise<StreamInfo | undefined>;
227
+ /** Reads all currently stored chunks for a durable stream. */
228
+ read<TChunk = unknown>(runId: RunId, streamIdOrName: StreamIdOrName, options?: ReadStreamOptions): Promise<StreamState<TChunk>>;
229
+ /** Reads one page of currently stored chunks for a durable stream. */
230
+ readPage<TChunk = unknown>(runId: RunId, streamIdOrName: StreamIdOrName, options?: ReadStreamPageOptions): Promise<StreamPage<TChunk>>;
231
+ }
232
+ /** Describes the workflow client messages API contract. */
233
+ interface WorkflowClientMessagesApi {
234
+ /** Sends a named message to a workflow run. */
235
+ send(runId: RunId, options: SendMessageInput): Promise<void>;
236
+ /** Sends a typed message channel payload to a workflow run. */
237
+ send<TPayload, TKey = void>(runId: RunId, channel: MessageChannel<TPayload, TKey>, options?: SendMessageChannelOptions<TPayload, TKey>): Promise<void>;
238
+ /** Broadcasts a named message to runs matching the target options. */
239
+ broadcast(options: BroadcastMessageInput): Promise<BroadcastMessageResult>;
240
+ /** Broadcasts a typed message channel payload to runs matching the target options. */
241
+ broadcast<TPayload, TKey = void>(channel: MessageChannel<TPayload, TKey>, options?: BroadcastMessageChannelOptions<TPayload, TKey>): Promise<BroadcastMessageResult>;
242
+ }
243
+ /** Describes the workflow client worker API contract. */
244
+ interface WorkflowClientWorkersApi {
245
+ /** Creates a worker bound to this client engine and registry. */
246
+ create(options?: WorkflowClientWorkerOptions): WorkflowWorker;
247
+ /** Processes a specific run once by ID. */
248
+ processRun(runId: RunId, options?: WorkflowClientProcessRunOptions): Promise<void>;
249
+ /** Processes currently due runs matching optional filters. */
250
+ wakeDueRuns(options?: WorkflowWakeDueRunsOptions): Promise<WorkflowWorkerRunResult>;
251
+ }
252
+ /** Options for creating a worker from the grouped client worker API. */
253
+ interface WorkflowClientWorkerOptions {
254
+ readonly workerId?: WorkerId;
255
+ readonly leaseDuration?: Temporal.Duration;
256
+ readonly pollInterval?: Temporal.Duration;
257
+ readonly heartbeatInterval?: Temporal.Duration;
258
+ readonly stopDrainTimeout?: Temporal.Duration;
259
+ readonly missingImplementationRetry?: WorkflowMissingImplementationRetryConfig;
260
+ }
261
+ /** Options for processing one run through a client worker facet. */
262
+ interface WorkflowClientProcessRunOptions extends WorkflowWorkerRunFilterOptions {
263
+ readonly workerId?: string;
264
+ readonly leaseDuration?: Temporal.Duration;
265
+ readonly heartbeatInterval?: Temporal.Duration;
266
+ readonly missingImplementationRetry?: WorkflowMissingImplementationRetryConfig;
267
+ readonly signal?: AbortSignal;
268
+ }
269
+ //#endregion
270
+ export { CompiledWorkflowFunction, WorkflowClient, WorkflowClientAdminApi, WorkflowClientHooksApi, WorkflowClientLocksApi, WorkflowClientMessagesApi, WorkflowClientProcessRunOptions, WorkflowClientRunsApi, WorkflowClientSchedulesApi, WorkflowClientStreamsApi, WorkflowClientWorkerOptions, WorkflowClientWorkersApi, WorkflowRunHandle, WorkflowRunnable };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ import { z } from "zod";
2
+ //#region src/types/common.d.ts
3
+ declare const temporalInstantSchema: z.ZodCustom<Temporal.Instant, Temporal.Instant>;
4
+ declare const temporalDurationSchema: z.ZodCustom<Temporal.Duration, Temporal.Duration>;
5
+ declare const temporalPositiveDurationSchema: z.ZodCustom<Temporal.Duration, Temporal.Duration>;
6
+ declare const temporalPositiveSafeDurationSchema: z.ZodCustom<Temporal.Duration, Temporal.Duration>;
7
+ declare const temporalNonNegativeDurationSchema: z.ZodCustom<Temporal.Duration, Temporal.Duration>;
8
+ declare const temporalNonNegativeSafeDurationSchema: z.ZodCustom<Temporal.Duration, Temporal.Duration>;
9
+ declare const nonBlankStringSchema: z.ZodString;
10
+ declare const nonBlankStringListSchema: z.ZodReadonly<z.ZodArray<z.ZodString>>;
11
+ declare const positiveSafeIntegerSchema: z.ZodNumber;
12
+ declare const nonNegativeSafeIntegerSchema: z.ZodNumber;
13
+ /** Timer delay after validation and runtime clamping. */
14
+ interface TimerDelay {
15
+ readonly duration: Temporal.Duration;
16
+ readonly clampedDelay: number;
17
+ }
18
+ //#endregion
19
+ export { TimerDelay, nonBlankStringListSchema, nonBlankStringSchema, nonNegativeSafeIntegerSchema, positiveSafeIntegerSchema, temporalDurationSchema, temporalInstantSchema, temporalNonNegativeDurationSchema, temporalNonNegativeSafeDurationSchema, temporalPositiveDurationSchema, temporalPositiveSafeDurationSchema };
@@ -0,0 +1,15 @@
1
+ import { durationTotal } from "../utility.mjs";
2
+ import { z } from "zod";
3
+ //#region src/types/common.ts
4
+ const temporalInstantSchema = z.instanceof(Temporal.Instant, { error: "Expected a Temporal.Instant" });
5
+ const temporalDurationSchema = z.instanceof(Temporal.Duration, { error: "Expected a Temporal.Duration" });
6
+ const temporalPositiveDurationSchema = temporalDurationSchema.refine((value) => durationTotal(value) > 0, { error: "Expected a positive duration" });
7
+ const temporalPositiveSafeDurationSchema = temporalPositiveDurationSchema.refine((value) => Number.isSafeInteger(durationTotal(value)), { error: "Expected a positive safe duration" });
8
+ const temporalNonNegativeDurationSchema = temporalDurationSchema.refine((value) => durationTotal(value) >= 0, { error: "Expected a non-negative duration" });
9
+ const temporalNonNegativeSafeDurationSchema = temporalNonNegativeDurationSchema.refine((value) => Number.isSafeInteger(durationTotal(value)), { error: "Expected a non-negative safe duration" });
10
+ const nonBlankStringSchema = z.string().refine((value) => value.trim().length > 0, "Expected a non-blank string");
11
+ const nonBlankStringListSchema = z.array(nonBlankStringSchema).readonly();
12
+ const positiveSafeIntegerSchema = z.number().int().positive();
13
+ const nonNegativeSafeIntegerSchema = z.number().int().nonnegative();
14
+ //#endregion
15
+ export { nonBlankStringListSchema, nonBlankStringSchema, nonNegativeSafeIntegerSchema, positiveSafeIntegerSchema, temporalDurationSchema, temporalInstantSchema, temporalNonNegativeDurationSchema, temporalNonNegativeSafeDurationSchema, temporalPositiveDurationSchema, temporalPositiveSafeDurationSchema };
@@ -0,0 +1,92 @@
1
+ import { WorkflowRetryConfig } from "./retry.mjs";
2
+ import { WorkflowDeterministicApi, WorkflowStepApi } from "./step.mjs";
3
+ import { Schema, SchemaOutput } from "@temelj/standard-schema";
4
+ import { Logger } from "@temelj/log";
5
+ //#region src/types/definition.d.ts
6
+ /** Configuration used to name, version, validate, and retry a workflow definition. */
7
+ interface WorkflowDefinitionConfig<TSchema extends Schema | undefined = undefined> {
8
+ readonly name: string;
9
+ readonly version?: string;
10
+ readonly schema?: TSchema;
11
+ readonly retry?: WorkflowRetryConfig;
12
+ }
13
+ /** Infers the parsed workflow input type from a schema, falling back when no schema is present. */
14
+ type WorkflowInputFromSchema<TSchema extends Schema | undefined, TFallback> = TSchema extends Schema ? SchemaOutput<TSchema> : TFallback;
15
+ /** Infers the raw workflow input accepted before schema parsing, falling back when no schema is present. */
16
+ type WorkflowRawInputFromSchema<TSchema extends Schema | undefined, TFallback> = TSchema extends Schema<infer TInput, unknown> ? TInput : TFallback;
17
+ /** Durable workflow contract identified by name, optional version, and typed input/output markers. */
18
+ interface WorkflowDefinition<TInput = unknown, TOutput = unknown, TRawInput = TInput> {
19
+ readonly kind: "definition";
20
+ readonly config: WorkflowDefinitionConfig<Schema | undefined>;
21
+ readonly name: string;
22
+ readonly version?: string;
23
+ readonly types?: WorkflowDefinitionTypes<TInput, TOutput, TRawInput>;
24
+ }
25
+ /** Compile-time type markers carried by workflow definitions without affecting runtime behavior. */
26
+ interface WorkflowDefinitionTypes<TInput, TOutput, TRawInput> {
27
+ /** Parsed input type received by the workflow handler. */
28
+ readonly input: TInput;
29
+ /** Output type returned by the workflow handler. */
30
+ readonly output: TOutput;
31
+ /** Raw input type accepted before schema validation. */
32
+ readonly rawInput: TRawInput;
33
+ }
34
+ /** Executable workflow implementation that binds a durable definition to a handler. */
35
+ interface WorkflowImplementation<TInput = unknown, TOutput = unknown, TRawInput = TInput> {
36
+ readonly kind: "implementation";
37
+ readonly definition: WorkflowDefinition<TInput, TOutput, TRawInput>;
38
+ readonly config: WorkflowDefinitionConfig<Schema | undefined>;
39
+ readonly name: string;
40
+ readonly version?: string;
41
+ readonly handler: WorkflowHandler<TInput, TOutput>;
42
+ }
43
+ /** Function that runs workflow logic with a replay-safe workflow context. */
44
+ type WorkflowHandler<TInput, TOutput> = (context: WorkflowContext<TInput>) => Promise<TOutput> | TOutput;
45
+ /** Context passed to a workflow handler during execution and replay. */
46
+ interface WorkflowContext<TInput> {
47
+ /** Parsed workflow input for the current run. */
48
+ readonly input: TInput;
49
+ /** Durable command API for workflow code. */
50
+ readonly step: WorkflowStepApi;
51
+ /** Replay-safe time, random, ID, and byte sources for workflow orchestration code. */
52
+ readonly deterministic: WorkflowDeterministicApi;
53
+ /** Scoped operational logger for workflow orchestration code. */
54
+ readonly log: Logger;
55
+ /** Stable identity and creation metadata for the current run. */
56
+ readonly run: WorkflowRunContext;
57
+ /** Abort signal for workflow cancellation. */
58
+ readonly signal: AbortSignal;
59
+ /** Workflow version stored on the current run, if any. */
60
+ readonly version: string | undefined;
61
+ }
62
+ /** Stable identity and creation metadata for the currently executing run. */
63
+ interface WorkflowRunContext {
64
+ readonly id: string;
65
+ readonly workflowName: string;
66
+ readonly workflowVersion?: string;
67
+ readonly createdAt: Temporal.Instant;
68
+ }
69
+ /** Workflow target accepted by start and schedule APIs. */
70
+ type WorkflowStartTarget<TInput = unknown, TOutput = unknown, TRawInput = TInput> = WorkflowDefinition<TInput, TOutput, TRawInput> | WorkflowImplementation<TInput, TOutput, TRawInput>;
71
+ /** Registry surface required by clients, workers, and runtimes. */
72
+ interface RegistryLike {
73
+ /** Creates and registers a workflow implementation. */
74
+ implementWorkflow<TInput, TOutput, TRawInput = TInput>(definition: WorkflowDefinition<TInput, TOutput, TRawInput>, handler: WorkflowHandler<TInput, TOutput>): WorkflowImplementation<TInput, TOutput, TRawInput>;
75
+ /** Registers an existing workflow implementation. */
76
+ register<TInput, TOutput, TRawInput = TInput>(implementation: WorkflowImplementation<TInput, TOutput, TRawInput>): void;
77
+ /** Returns the implementation registered for a definition, if present. */
78
+ get<TInput, TOutput, TRawInput = TInput>(definition: WorkflowDefinition<TInput, TOutput, TRawInput>): WorkflowImplementation<TInput, TOutput, TRawInput> | undefined;
79
+ /** Returns the implementation registered for a workflow name and optional version. */
80
+ getByName(name: string, version?: string): WorkflowImplementation<unknown, unknown> | undefined;
81
+ /** Returns the latest registered implementation for a workflow name. */
82
+ latest(name: string): WorkflowImplementation<unknown, unknown> | undefined;
83
+ }
84
+ /** In-memory workflow registry contract. */
85
+ interface Registry extends RegistryLike {
86
+ /** Returns all registered workflow implementations. */
87
+ entries(): readonly WorkflowImplementation<unknown, unknown>[];
88
+ /** Returns the latest registered implementation for a workflow name. */
89
+ latest(name: string): WorkflowImplementation<unknown, unknown> | undefined;
90
+ }
91
+ //#endregion
92
+ export { Registry, RegistryLike, WorkflowContext, WorkflowDefinition, WorkflowDefinitionConfig, WorkflowDefinitionTypes, WorkflowHandler, WorkflowImplementation, WorkflowInputFromSchema, WorkflowRawInputFromSchema, WorkflowRunContext, WorkflowStartTarget };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,76 @@
1
+ import { RunId } from "./run-id.mjs";
2
+ import { Telemetry } from "./telemetry.mjs";
3
+ import { WorkflowLifecycleCallback } from "./run.mjs";
4
+ import { WorkflowStorage, WorkflowStore } from "./store.mjs";
5
+ import { Logger } from "@temelj/log";
6
+ //#region src/types/engine-options.d.ts
7
+ /** Options for creating the storage-backed workflow engine. */
8
+ interface CreateWorkflowEngineOptions extends WorkflowExecutionLimits {
9
+ readonly storage?: WorkflowStorage;
10
+ readonly store?: WorkflowStore;
11
+ /**
12
+ * Clock used for workflow timestamps and the first value recorded by
13
+ * deterministic time commands.
14
+ *
15
+ * Hosts that patch `Date.now()` during workflow execution should route
16
+ * patched calls through the same durable recording path.
17
+ */
18
+ readonly now?: () => Temporal.Instant;
19
+ readonly createRunId?: () => string;
20
+ readonly createRecordedId?: (context: WorkflowRecordedIdContext) => string;
21
+ /**
22
+ * Creates the first value recorded by deterministic random commands.
23
+ *
24
+ * Hosts that patch `Math.random()` during workflow execution should route
25
+ * patched calls through the same durable recording path.
26
+ */
27
+ readonly createDeterministicRandom?: (context: WorkflowDeterministicValueContext) => number;
28
+ /**
29
+ * Creates the first value recorded by deterministic UUID commands.
30
+ *
31
+ * Hosts that patch `crypto.randomUUID()` during workflow execution should
32
+ * route patched calls through the same durable recording path.
33
+ */
34
+ readonly createDeterministicUuid?: (context: WorkflowDeterministicValueContext) => string;
35
+ /**
36
+ * Creates the first value recorded by deterministic byte commands.
37
+ *
38
+ * Hosts that patch `crypto.getRandomValues()` during workflow execution
39
+ * should route patched calls through the same durable recording path.
40
+ */
41
+ readonly createDeterministicBytes?: (context: WorkflowDeterministicBytesContext) => Uint8Array;
42
+ readonly onLifecycleEvent?: WorkflowLifecycleCallback;
43
+ readonly onRunCompleted?: WorkflowLifecycleCallback;
44
+ readonly onRunFailed?: WorkflowLifecycleCallback;
45
+ readonly onRunCanceled?: WorkflowLifecycleCallback;
46
+ readonly onRunWaiting?: WorkflowLifecycleCallback;
47
+ readonly onRunRetry?: WorkflowLifecycleCallback;
48
+ readonly maximumStepAttemptsPerRun?: number;
49
+ readonly telemetry?: Telemetry | false;
50
+ readonly logger?: Logger | false;
51
+ }
52
+ /** Runtime limits applied while executing workflows. */
53
+ interface WorkflowExecutionLimits {
54
+ readonly maximumPersistedValueBytes?: number;
55
+ readonly maximumEventHistoryEvents?: number;
56
+ readonly maximumStreamChunks?: number;
57
+ }
58
+ /** Runtime limits that affect persisted value serialization. */
59
+ interface WorkflowEngineSerializationLimits {
60
+ readonly maximumPersistedValueBytes?: number;
61
+ }
62
+ /** Context passed to custom deterministic ID generators. */
63
+ interface WorkflowRecordedIdContext {
64
+ readonly runId: RunId;
65
+ readonly commandId: string;
66
+ readonly commandName: string;
67
+ readonly commandCount: number;
68
+ }
69
+ /** Context passed to custom deterministic first-run value generators. */
70
+ type WorkflowDeterministicValueContext = WorkflowRecordedIdContext;
71
+ /** Context passed to custom deterministic byte generators. */
72
+ interface WorkflowDeterministicBytesContext extends WorkflowDeterministicValueContext {
73
+ readonly length: number;
74
+ }
75
+ //#endregion
76
+ export { CreateWorkflowEngineOptions, WorkflowDeterministicBytesContext, WorkflowDeterministicValueContext, WorkflowEngineSerializationLimits, WorkflowExecutionLimits, WorkflowRecordedIdContext };
@@ -0,0 +1 @@
1
+ export {};