@temelj/workflow 0.0.0-alpha.3 → 0.0.0-alpha.4

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 (461) hide show
  1. package/README.md +394 -2
  2. package/dist/attributes.d.mts +11 -9
  3. package/dist/attributes.mjs +23 -5
  4. package/dist/bundle.d.mts +5 -23
  5. package/dist/bundle.mjs +2 -18
  6. package/dist/client/create.d.mts +26 -23
  7. package/dist/client/create.mjs +26 -32
  8. package/dist/client/facades.d.mts +12 -18
  9. package/dist/client/facades.mjs +102 -93
  10. package/dist/client/mod.mjs +1 -2
  11. package/dist/client/run-handle.d.mts +17 -54
  12. package/dist/client/run-handle.mjs +35 -105
  13. package/dist/client/worker-options.d.mts +8 -8
  14. package/dist/client/worker-options.mjs +11 -11
  15. package/dist/cloudflare/cloudflare.d.mts +4 -5
  16. package/dist/cloudflare/codec.d.mts +28 -13
  17. package/dist/cloudflare/codec.mjs +40 -17
  18. package/dist/cloudflare/entrypoint.d.mts +3 -4
  19. package/dist/cloudflare/entrypoint.mjs +4 -3
  20. package/dist/cloudflare/execution.d.mts +3 -4
  21. package/dist/cloudflare/execution.mjs +20 -13
  22. package/dist/cloudflare/host.d.mts +6 -7
  23. package/dist/cloudflare/host.mjs +7 -6
  24. package/dist/cloudflare/mod.d.mts +4 -4
  25. package/dist/cloudflare/mod.mjs +2 -2
  26. package/dist/cloudflare/name.d.mts +3 -4
  27. package/dist/cloudflare/name.mjs +3 -3
  28. package/dist/cloudflare/registry.d.mts +3 -23
  29. package/dist/cloudflare/registry.mjs +2 -20
  30. package/dist/cloudflare/runtime.d.mts +11 -18
  31. package/dist/cloudflare/runtime.mjs +52 -73
  32. package/dist/cloudflare/step.d.mts +6 -6
  33. package/dist/cloudflare/step.mjs +69 -57
  34. package/dist/cloudflare/types.d.mts +17 -36
  35. package/dist/collection.d.mts +8 -11
  36. package/dist/collection.mjs +10 -14
  37. package/dist/compiled-function.d.mts +14 -19
  38. package/dist/compiled-function.mjs +12 -24
  39. package/dist/compiled.d.mts +4 -0
  40. package/dist/compiled.mjs +4 -0
  41. package/dist/compiler/ast.d.mts +26 -0
  42. package/dist/{vite → compiler}/ast.mjs +24 -16
  43. package/dist/{vite → compiler}/error.d.mts +4 -6
  44. package/dist/{vite → compiler}/error.mjs +14 -16
  45. package/dist/compiler/manifest.d.mts +6 -0
  46. package/dist/{vite → compiler}/manifest.mjs +9 -7
  47. package/dist/compiler/plugin.d.mts +7 -0
  48. package/dist/{vite → compiler}/plugin.mjs +45 -46
  49. package/dist/compiler/safety.d.mts +12 -0
  50. package/dist/{vite → compiler}/safety.mjs +5 -11
  51. package/dist/{vite → compiler}/source-edit.d.mts +3 -4
  52. package/dist/{vite → compiler}/source-edit.mjs +1 -1
  53. package/dist/{vite → compiler}/source-map.d.mts +4 -3
  54. package/dist/{vite → compiler}/source-map.mjs +3 -3
  55. package/dist/compiler/source.d.mts +7 -0
  56. package/dist/{vite → compiler}/source.mjs +1 -1
  57. package/dist/compiler/transform.d.mts +12 -0
  58. package/dist/{vite → compiler}/transform.mjs +37 -38
  59. package/dist/definition.d.mts +17 -25
  60. package/dist/definition.mjs +19 -35
  61. package/dist/engine/child-workflow.d.mts +5 -9
  62. package/dist/engine/child-workflow.mjs +46 -67
  63. package/dist/engine/command-identity.d.mts +5 -6
  64. package/dist/engine/command-identity.mjs +9 -5
  65. package/dist/engine/context.d.mts +17 -0
  66. package/dist/engine/create.d.mts +36 -94
  67. package/dist/engine/create.mjs +55 -260
  68. package/dist/engine/deterministic.d.mts +6 -11
  69. package/dist/engine/deterministic.mjs +47 -68
  70. package/dist/engine/durable-command.d.mts +5 -5
  71. package/dist/engine/durable-command.mjs +2 -2
  72. package/dist/engine/execution-service.d.mts +20 -24
  73. package/dist/engine/execution-service.mjs +54 -52
  74. package/dist/engine/hooks.d.mts +17 -39
  75. package/dist/engine/hooks.mjs +73 -94
  76. package/dist/engine/inspection.d.mts +23 -15
  77. package/dist/engine/inspection.mjs +55 -29
  78. package/dist/engine/lifecycle.d.mts +6 -12
  79. package/dist/engine/lifecycle.mjs +5 -5
  80. package/dist/engine/lock-replay.d.mts +8 -15
  81. package/dist/engine/lock-replay.mjs +12 -25
  82. package/dist/engine/lock.d.mts +10 -15
  83. package/dist/engine/lock.mjs +65 -51
  84. package/dist/engine/message.d.mts +14 -34
  85. package/dist/engine/message.mjs +94 -127
  86. package/dist/engine/observation.d.mts +9 -11
  87. package/dist/engine/observation.mjs +18 -27
  88. package/dist/engine/replay.d.mts +18 -19
  89. package/dist/engine/replay.mjs +32 -56
  90. package/dist/engine/resume.d.mts +16 -0
  91. package/dist/engine/resume.mjs +24 -0
  92. package/dist/engine/retry.d.mts +15 -19
  93. package/dist/engine/retry.mjs +17 -17
  94. package/dist/engine/run-data.d.mts +4 -8
  95. package/dist/engine/run-data.mjs +24 -22
  96. package/dist/engine/run-service.d.mts +24 -33
  97. package/dist/engine/run-service.mjs +125 -93
  98. package/dist/engine/run-utils.d.mts +11 -13
  99. package/dist/engine/run-utils.mjs +23 -46
  100. package/dist/engine/schedule.d.mts +8 -22
  101. package/dist/engine/schedule.mjs +37 -34
  102. package/dist/engine/serialization.d.mts +9 -6
  103. package/dist/engine/serialization.mjs +30 -21
  104. package/dist/engine/signals.d.mts +23 -0
  105. package/dist/engine/signals.mjs +41 -0
  106. package/dist/engine/start.d.mts +18 -0
  107. package/dist/engine/start.mjs +88 -0
  108. package/dist/engine/state.d.mts +37 -67
  109. package/dist/engine/state.mjs +119 -280
  110. package/dist/engine/step-api.d.mts +5 -8
  111. package/dist/engine/step-api.mjs +16 -16
  112. package/dist/engine/stream-reader.d.mts +12 -0
  113. package/dist/engine/stream-reader.mjs +154 -0
  114. package/dist/engine/stream.d.mts +9 -54
  115. package/dist/engine/stream.mjs +54 -196
  116. package/dist/engine/summary/recovery.d.mts +35 -0
  117. package/dist/engine/summary/recovery.mjs +363 -0
  118. package/dist/engine/summary/runs.d.mts +43 -0
  119. package/dist/engine/summary/runs.mjs +294 -0
  120. package/dist/engine/summary/step-attempts.d.mts +5 -10
  121. package/dist/engine/summary/step-attempts.mjs +157 -36
  122. package/dist/engine/summary/tally.d.mts +44 -0
  123. package/dist/engine/summary/tally.mjs +142 -0
  124. package/dist/engine/task.d.mts +4 -5
  125. package/dist/engine/task.mjs +40 -48
  126. package/dist/errors/base.d.mts +17 -77
  127. package/dist/errors/base.mjs +26 -327
  128. package/dist/errors/capability.d.mts +3 -6
  129. package/dist/errors/capability.mjs +4 -8
  130. package/dist/errors/codes.d.mts +116 -0
  131. package/dist/{types/error-code.mjs → errors/codes.mjs} +2 -17
  132. package/dist/errors/definition.d.mts +3 -17
  133. package/dist/errors/definition.mjs +5 -42
  134. package/dist/errors/failures.d.mts +17 -51
  135. package/dist/errors/failures.mjs +35 -102
  136. package/dist/errors/hook.d.mts +5 -9
  137. package/dist/errors/hook.mjs +4 -16
  138. package/dist/errors/implementation.d.mts +3 -6
  139. package/dist/errors/implementation.mjs +7 -12
  140. package/dist/errors/lock.d.mts +7 -20
  141. package/dist/errors/lock.mjs +8 -44
  142. package/dist/errors/message.d.mts +14 -59
  143. package/dist/errors/message.mjs +13 -39
  144. package/dist/errors/mod.d.mts +4 -5
  145. package/dist/errors/mod.mjs +5 -7
  146. package/dist/errors/records.d.mts +10 -4
  147. package/dist/errors/records.mjs +256 -256
  148. package/dist/errors/run.d.mts +27 -68
  149. package/dist/errors/run.mjs +31 -85
  150. package/dist/errors/schedule.d.mts +7 -18
  151. package/dist/errors/schedule.mjs +7 -39
  152. package/dist/errors/step.d.mts +12 -45
  153. package/dist/errors/step.mjs +13 -34
  154. package/dist/errors/stream.d.mts +8 -16
  155. package/dist/errors/stream.mjs +7 -41
  156. package/dist/esbuild.d.mts +6 -4
  157. package/dist/esbuild.mjs +2 -1
  158. package/dist/events/descriptors.d.mts +12 -241
  159. package/dist/events/descriptors.mjs +12 -5
  160. package/dist/history/projection.d.mts +4 -6
  161. package/dist/history/projection.mjs +22 -26
  162. package/dist/history/replay-projection.d.mts +44 -48
  163. package/dist/history/replay-projection.mjs +41 -50
  164. package/dist/history/{mod.d.mts → replay.d.mts} +16 -21
  165. package/dist/history/{mod.mjs → replay.mjs} +21 -25
  166. package/dist/history/sequencer.d.mts +10 -11
  167. package/dist/history/sequencer.mjs +11 -7
  168. package/dist/history/step-attempts.d.mts +4 -7
  169. package/dist/history/step-attempts.mjs +8 -9
  170. package/dist/history/timeline.d.mts +4 -13
  171. package/dist/history/timeline.mjs +46 -265
  172. package/dist/history/validator.d.mts +5 -7
  173. package/dist/history/validator.mjs +9 -24
  174. package/dist/hook-token.d.mts +7 -0
  175. package/dist/hook-token.mjs +32 -0
  176. package/dist/ids.d.mts +8 -0
  177. package/dist/ids.mjs +21 -0
  178. package/dist/message-options.d.mts +11 -5
  179. package/dist/message-options.mjs +9 -7
  180. package/dist/mod.d.mts +32 -36
  181. package/dist/mod.mjs +9 -13
  182. package/dist/otel/metrics.d.mts +31 -0
  183. package/dist/otel/metrics.mjs +60 -0
  184. package/dist/otel/mod.d.mts +3 -0
  185. package/dist/otel/mod.mjs +3 -0
  186. package/dist/otel/spans.d.mts +24 -0
  187. package/dist/otel/spans.mjs +218 -0
  188. package/dist/otel/support.d.mts +15 -8
  189. package/dist/otel/support.mjs +18 -40
  190. package/dist/{otel.d.mts → otel/telemetry.d.mts} +5 -6
  191. package/dist/otel/telemetry.mjs +305 -0
  192. package/dist/pagination.d.mts +6 -12
  193. package/dist/pagination.mjs +10 -14
  194. package/dist/registry.d.mts +8 -5
  195. package/dist/registry.mjs +19 -10
  196. package/dist/rolldown.d.mts +6 -4
  197. package/dist/rolldown.mjs +2 -1
  198. package/dist/rollup.d.mts +6 -4
  199. package/dist/rollup.mjs +2 -1
  200. package/dist/rspack.d.mts +6 -4
  201. package/dist/rspack.mjs +2 -1
  202. package/dist/run-status.d.mts +29 -0
  203. package/dist/run-status.mjs +42 -0
  204. package/dist/schema/common.d.mts +22 -0
  205. package/dist/schema/common.mjs +54 -0
  206. package/dist/schema/error.d.mts +17 -0
  207. package/dist/schema/error.mjs +39 -0
  208. package/dist/schema/events.d.mts +446 -0
  209. package/dist/schema/events.mjs +235 -0
  210. package/dist/schema/pagination.d.mts +5 -0
  211. package/dist/schema/pagination.mjs +11 -0
  212. package/dist/schema/persisted-value.d.mts +8 -0
  213. package/dist/schema/persisted-value.mjs +94 -0
  214. package/dist/schema/run.d.mts +51 -0
  215. package/dist/schema/run.mjs +88 -0
  216. package/dist/schema/store.d.mts +94 -0
  217. package/dist/schema/store.mjs +116 -0
  218. package/dist/step-definition.d.mts +4 -9
  219. package/dist/step-definition.mjs +2 -2
  220. package/dist/store/capabilities.d.mts +8 -9
  221. package/dist/store/capabilities.mjs +7 -7
  222. package/dist/store/cleanup.d.mts +9 -14
  223. package/dist/store/cleanup.mjs +86 -85
  224. package/dist/store/create.d.mts +28 -29
  225. package/dist/store/create.mjs +10 -11
  226. package/dist/store/events.d.mts +48 -0
  227. package/dist/store/events.mjs +263 -0
  228. package/dist/store/indexes.d.mts +25 -0
  229. package/dist/store/indexes.mjs +282 -0
  230. package/dist/store/instrumentation.d.mts +2 -3
  231. package/dist/store/instrumentation.mjs +30 -30
  232. package/dist/store/lock.d.mts +4 -5
  233. package/dist/store/lock.mjs +5 -7
  234. package/dist/store/materialization.d.mts +10 -17
  235. package/dist/store/materialization.mjs +39 -33
  236. package/dist/store/mod.d.mts +3 -3
  237. package/dist/store/mod.mjs +2 -2
  238. package/dist/store/query.d.mts +13 -17
  239. package/dist/store/query.mjs +13 -13
  240. package/dist/store/run.d.mts +25 -34
  241. package/dist/store/run.mjs +67 -108
  242. package/dist/store/schedule.d.mts +6 -8
  243. package/dist/store/schedule.mjs +11 -11
  244. package/dist/store/step-attempt.d.mts +9 -12
  245. package/dist/store/step-attempt.mjs +9 -9
  246. package/dist/store/storage-value.d.mts +3 -3
  247. package/dist/store/storage-value.mjs +17 -1
  248. package/dist/store/validation.d.mts +17 -20
  249. package/dist/store/validation.mjs +30 -33
  250. package/dist/store-keys.d.mts +35 -47
  251. package/dist/store-keys.mjs +9 -17
  252. package/dist/telemetry.d.mts +16 -16
  253. package/dist/telemetry.mjs +3 -3
  254. package/dist/temporal.d.mts +11 -16
  255. package/dist/temporal.mjs +8 -9
  256. package/dist/timer.d.mts +12 -10
  257. package/dist/timer.mjs +11 -3
  258. package/dist/types/cleanup.d.mts +13 -50
  259. package/dist/types/cleanup.mjs +1 -22
  260. package/dist/types/client.d.mts +101 -162
  261. package/dist/types/{vite.d.mts → compiler.d.mts} +17 -24
  262. package/dist/types/compiler.mjs +1 -0
  263. package/dist/types/definition.d.mts +22 -34
  264. package/dist/types/engine-options.d.mts +10 -17
  265. package/dist/types/engine.d.mts +15 -274
  266. package/dist/types/error.d.mts +15 -217
  267. package/dist/types/error.mjs +1 -48
  268. package/dist/types/events.d.mts +59 -2730
  269. package/dist/types/events.mjs +1 -283
  270. package/dist/types/hook.d.mts +27 -85
  271. package/dist/types/hook.mjs +1 -66
  272. package/dist/types/ids.d.mts +9 -0
  273. package/dist/types/ids.mjs +1 -0
  274. package/dist/types/lock.d.mts +8 -26
  275. package/dist/types/lock.mjs +1 -18
  276. package/dist/types/message.d.mts +29 -43
  277. package/dist/types/observation.d.mts +43 -58
  278. package/dist/types/pagination.d.mts +6 -22
  279. package/dist/types/pagination.mjs +1 -13
  280. package/dist/types/result.d.mts +11 -43
  281. package/dist/types/retry.d.mts +7 -14
  282. package/dist/types/run-list.d.mts +9 -11
  283. package/dist/types/run-options.d.mts +25 -32
  284. package/dist/types/run.d.mts +35 -315
  285. package/dist/types/run.mjs +1 -207
  286. package/dist/types/runtime.d.mts +33 -145
  287. package/dist/types/runtime.mjs +1 -21
  288. package/dist/types/schedule.d.mts +13 -72
  289. package/dist/types/schedule.mjs +1 -48
  290. package/dist/types/step-attempts.d.mts +65 -261
  291. package/dist/types/step-attempts.mjs +1 -43
  292. package/dist/types/step.d.mts +66 -77
  293. package/dist/types/step.mjs +1 -5
  294. package/dist/types/store.d.mts +50 -182
  295. package/dist/types/stream.d.mts +19 -40
  296. package/dist/types/summary.d.mts +174 -278
  297. package/dist/types/telemetry.d.mts +23 -28
  298. package/dist/types/telemetry.mjs +1 -9
  299. package/dist/types/timeline.d.mts +46 -233
  300. package/dist/types/worker.d.mts +22 -29
  301. package/dist/values.d.mts +15 -0
  302. package/dist/values.mjs +57 -0
  303. package/dist/vite.d.mts +5 -6
  304. package/dist/vite.mjs +3 -4
  305. package/dist/webpack.d.mts +6 -4
  306. package/dist/webpack.mjs +2 -1
  307. package/dist/worker/error.d.mts +2 -9
  308. package/dist/worker/error.mjs +20 -32
  309. package/dist/worker/missing-implementation.d.mts +19 -0
  310. package/dist/worker/missing-implementation.mjs +62 -0
  311. package/dist/worker/worker.d.mts +18 -0
  312. package/dist/{worker.mjs → worker/worker.mjs} +64 -118
  313. package/package.json +28 -47
  314. package/dist/engine/execution-api.d.mts +0 -29
  315. package/dist/engine/execution-api.mjs +0 -33
  316. package/dist/engine/inspection-api.d.mts +0 -34
  317. package/dist/engine/inspection-api.mjs +0 -78
  318. package/dist/engine/mod.d.mts +0 -4
  319. package/dist/engine/mod.mjs +0 -2
  320. package/dist/engine/recovery.d.mts +0 -26
  321. package/dist/engine/recovery.mjs +0 -92
  322. package/dist/engine/retry-policy.d.mts +0 -4
  323. package/dist/engine/retry-policy.mjs +0 -4
  324. package/dist/engine/start-api.d.mts +0 -30
  325. package/dist/engine/start-api.mjs +0 -99
  326. package/dist/engine/summary/active-events.d.mts +0 -34
  327. package/dist/engine/summary/active-events.mjs +0 -69
  328. package/dist/engine/summary/child-workflow-runs.d.mts +0 -24
  329. package/dist/engine/summary/child-workflow-runs.mjs +0 -138
  330. package/dist/engine/summary/child-workflow-waits.d.mts +0 -21
  331. package/dist/engine/summary/child-workflow-waits.mjs +0 -67
  332. package/dist/engine/summary/recovery-child-workflow-waits.d.mts +0 -11
  333. package/dist/engine/summary/recovery-child-workflow-waits.mjs +0 -89
  334. package/dist/engine/summary/recovery-due-runs.d.mts +0 -16
  335. package/dist/engine/summary/recovery-due-runs.mjs +0 -52
  336. package/dist/engine/summary/recovery-failed-runs.d.mts +0 -14
  337. package/dist/engine/summary/recovery-failed-runs.mjs +0 -33
  338. package/dist/engine/summary/recovery-lease-runs.d.mts +0 -16
  339. package/dist/engine/summary/recovery-lease-runs.mjs +0 -69
  340. package/dist/engine/summary/recovery-locks.d.mts +0 -18
  341. package/dist/engine/summary/recovery-locks.mjs +0 -100
  342. package/dist/engine/summary/recovery-message-waits.d.mts +0 -11
  343. package/dist/engine/summary/recovery-message-waits.mjs +0 -74
  344. package/dist/engine/summary/recovery-retry-runs.d.mts +0 -17
  345. package/dist/engine/summary/recovery-retry-runs.mjs +0 -65
  346. package/dist/engine/summary/recovery-run-timestamps.d.mts +0 -13
  347. package/dist/engine/summary/recovery-run-timestamps.mjs +0 -18
  348. package/dist/engine/summary/recovery-runs.d.mts +0 -23
  349. package/dist/engine/summary/recovery-runs.mjs +0 -54
  350. package/dist/engine/summary/recovery-schedules.d.mts +0 -10
  351. package/dist/engine/summary/recovery-schedules.mjs +0 -46
  352. package/dist/engine/summary/recovery-sleep-waits.d.mts +0 -10
  353. package/dist/engine/summary/recovery-sleep-waits.mjs +0 -53
  354. package/dist/engine/summary/recovery-waits.d.mts +0 -21
  355. package/dist/engine/summary/recovery-waits.mjs +0 -29
  356. package/dist/engine/summary/run-availability.d.mts +0 -13
  357. package/dist/engine/summary/run-availability.mjs +0 -37
  358. package/dist/engine/summary/run-cleanup.d.mts +0 -14
  359. package/dist/engine/summary/run-cleanup.mjs +0 -44
  360. package/dist/engine/summary/run-failure.d.mts +0 -14
  361. package/dist/engine/summary/run-failure.mjs +0 -62
  362. package/dist/engine/summary/run-hooks.d.mts +0 -14
  363. package/dist/engine/summary/run-hooks.mjs +0 -63
  364. package/dist/engine/summary/run-lease.d.mts +0 -11
  365. package/dist/engine/summary/run-lease.mjs +0 -64
  366. package/dist/engine/summary/run-message-waits.d.mts +0 -15
  367. package/dist/engine/summary/run-message-waits.mjs +0 -62
  368. package/dist/engine/summary/run-metrics.d.mts +0 -31
  369. package/dist/engine/summary/run-metrics.mjs +0 -93
  370. package/dist/engine/summary/run-retry.d.mts +0 -9
  371. package/dist/engine/summary/run-retry.mjs +0 -69
  372. package/dist/engine/summary/run-sleeps.d.mts +0 -15
  373. package/dist/engine/summary/run-sleeps.mjs +0 -61
  374. package/dist/engine/summary/run-state.d.mts +0 -26
  375. package/dist/engine/summary/run-state.mjs +0 -48
  376. package/dist/engine/summary/run-status.d.mts +0 -16
  377. package/dist/engine/summary/run-status.mjs +0 -35
  378. package/dist/engine/summary/run-streams.d.mts +0 -14
  379. package/dist/engine/summary/run-streams.mjs +0 -46
  380. package/dist/engine/summary/run-transition.d.mts +0 -9
  381. package/dist/engine/summary/run-transition.mjs +0 -39
  382. package/dist/engine/summary/run-workflow.d.mts +0 -9
  383. package/dist/engine/summary/run-workflow.mjs +0 -47
  384. package/dist/engine/summary/step-attempt-active-child-workflows.d.mts +0 -13
  385. package/dist/engine/summary/step-attempt-active-child-workflows.mjs +0 -55
  386. package/dist/engine/summary/step-attempt-active-fields.d.mts +0 -23
  387. package/dist/engine/summary/step-attempt-active-fields.mjs +0 -14
  388. package/dist/engine/summary/step-attempt-active-message-waits.d.mts +0 -12
  389. package/dist/engine/summary/step-attempt-active-message-waits.mjs +0 -47
  390. package/dist/engine/summary/step-attempt-active-sleeps.d.mts +0 -19
  391. package/dist/engine/summary/step-attempt-active-sleeps.mjs +0 -44
  392. package/dist/engine/summary/step-attempt-buckets.d.mts +0 -22
  393. package/dist/engine/summary/step-attempt-buckets.mjs +0 -152
  394. package/dist/engine/summary/step-attempt-failure.d.mts +0 -12
  395. package/dist/engine/summary/step-attempt-failure.mjs +0 -61
  396. package/dist/engine/summary/step-attempt-lifecycle.d.mts +0 -13
  397. package/dist/engine/summary/step-attempt-lifecycle.mjs +0 -19
  398. package/dist/engine/summary.d.mts +0 -32
  399. package/dist/engine/summary.mjs +0 -37
  400. package/dist/errors/details.d.mts +0 -13
  401. package/dist/errors/details.mjs +0 -66
  402. package/dist/errors/record-view.d.mts +0 -11
  403. package/dist/errors/record-view.mjs +0 -24
  404. package/dist/errors/runtime.d.mts +0 -12
  405. package/dist/errors/runtime.mjs +0 -24
  406. package/dist/events/mod.d.mts +0 -3
  407. package/dist/events/mod.mjs +0 -2
  408. package/dist/history/attempt-key.d.mts +0 -6
  409. package/dist/history/attempt-key.mjs +0 -7
  410. package/dist/inspection/mod.d.mts +0 -5
  411. package/dist/inspection/mod.mjs +0 -3
  412. package/dist/otel.mjs +0 -590
  413. package/dist/runtime.d.mts +0 -35
  414. package/dist/runtime.mjs +0 -198
  415. package/dist/store/append-projection.d.mts +0 -15
  416. package/dist/store/append-projection.mjs +0 -26
  417. package/dist/store/compaction.d.mts +0 -5
  418. package/dist/store/compaction.mjs +0 -8
  419. package/dist/store/event-append-project.d.mts +0 -15
  420. package/dist/store/event-append-project.mjs +0 -77
  421. package/dist/store/event-append.d.mts +0 -37
  422. package/dist/store/event-append.mjs +0 -80
  423. package/dist/store/event-history.d.mts +0 -22
  424. package/dist/store/event-history.mjs +0 -75
  425. package/dist/store/event.d.mts +0 -10
  426. package/dist/store/event.mjs +0 -28
  427. package/dist/store/idempotency.d.mts +0 -10
  428. package/dist/store/idempotency.mjs +0 -167
  429. package/dist/store/message-index.d.mts +0 -21
  430. package/dist/store/message-index.mjs +0 -122
  431. package/dist/store/revision.d.mts +0 -4
  432. package/dist/store/revision.mjs +0 -7
  433. package/dist/store/schema.d.mts +0 -14
  434. package/dist/store/schema.mjs +0 -17
  435. package/dist/types/common.d.mts +0 -20
  436. package/dist/types/common.mjs +0 -16
  437. package/dist/types/error-code.d.mts +0 -256
  438. package/dist/types/message-id.d.mts +0 -7
  439. package/dist/types/message-id.mjs +0 -5
  440. package/dist/types/run-id.d.mts +0 -7
  441. package/dist/types/run-id.mjs +0 -5
  442. package/dist/types/step-id.d.mts +0 -7
  443. package/dist/types/step-id.mjs +0 -5
  444. package/dist/types/stream-id.d.mts +0 -7
  445. package/dist/types/stream-id.mjs +0 -5
  446. package/dist/types/worker-id.d.mts +0 -7
  447. package/dist/types/worker-id.mjs +0 -5
  448. package/dist/utility.d.mts +0 -49
  449. package/dist/utility.mjs +0 -122
  450. package/dist/vite/ast.d.mts +0 -23
  451. package/dist/vite/generated-name.d.mts +0 -7
  452. package/dist/vite/generated-name.mjs +0 -9
  453. package/dist/vite/manifest.d.mts +0 -7
  454. package/dist/vite/plugin.d.mts +0 -7
  455. package/dist/vite/safety.d.mts +0 -12
  456. package/dist/vite/source.d.mts +0 -7
  457. package/dist/vite/transform.d.mts +0 -7
  458. package/dist/webhook.d.mts +0 -16
  459. package/dist/webhook.mjs +0 -17
  460. package/dist/worker.d.mts +0 -19
  461. /package/dist/{types/vite.mjs → engine/context.mjs} +0 -0
@@ -1,60 +1,56 @@
1
- import { WorkflowResolvedStepRetryConfig } from "./retry.mjs";
2
- import { WorkflowStepMetadata } from "./step.mjs";
3
- import { WorkflowRunSummary, WorkflowRunSummaryOptions } from "./summary.mjs";
4
- import { ObservationEventMap } from "./observation.mjs";
1
+ import { ResolvedRetryConfig } from "./retry.mjs";
2
+ import { ListRunsOptions } from "./run-list.mjs";
3
+ import { StepMetadata } from "./step.mjs";
4
+ import { RunSummary } from "./summary.mjs";
5
+ import { ObservationEventArgs } from "./observation.mjs";
5
6
  import { ExecutionResult } from "./result.mjs";
6
- import { WorkflowRunRecord } from "./run.mjs";
7
- import { z } from "zod";
7
+ import { RunRecord } from "./run.mjs";
8
8
  //#region src/types/telemetry.d.ts
9
- declare const workflowTelemetryContextSchema: z.ZodObject<{
10
- traceparent: z.ZodOptional<z.ZodString>;
11
- tracestate: z.ZodOptional<z.ZodString>;
12
- }, z.core.$strip>;
13
9
  /** Persisted W3C trace context captured when a workflow run is created. */
14
- interface TelemetryContext {
10
+ export interface TelemetryContext {
15
11
  readonly traceparent?: string;
16
12
  readonly tracestate?: string;
17
13
  }
18
14
  /** Context passed to telemetry adapters around workflow run execution. */
19
- interface RunTelemetryContext {
20
- readonly run: WorkflowRunRecord;
15
+ export interface RunTelemetryContext {
16
+ readonly run: RunRecord;
21
17
  readonly traceContext?: TelemetryContext;
22
18
  }
23
19
  /** Context passed to telemetry adapters after workflow run execution finishes. */
24
- interface RunTelemetryResultContext<TOutput = unknown> extends RunTelemetryContext {
20
+ export interface RunTelemetryResultContext<TOutput = unknown> extends RunTelemetryContext {
25
21
  readonly result?: ExecutionResult<TOutput>;
26
22
  readonly error?: unknown;
27
23
  }
28
24
  /** Context passed to telemetry adapters around durable task callback execution. */
29
- interface StepTelemetryContext {
30
- readonly run: WorkflowRunRecord;
31
- readonly step: WorkflowStepMetadata;
25
+ export interface StepTelemetryContext {
26
+ readonly run: RunRecord;
27
+ readonly step: StepMetadata;
32
28
  readonly attempt: number;
33
- readonly retry: WorkflowResolvedStepRetryConfig;
29
+ readonly retry: ResolvedRetryConfig;
34
30
  readonly timeoutAt?: Temporal.Instant;
35
31
  }
36
32
  /** Context passed to telemetry adapters after durable task callback execution finishes. */
37
- interface StepTelemetryResultContext extends StepTelemetryContext {
33
+ export interface StepTelemetryResultContext extends StepTelemetryContext {
38
34
  readonly error?: unknown;
39
35
  }
40
36
  /** Storage/backend operation names observed by the default workflow store. */
41
- type StorageTelemetryOperation = "get" | "tryGet" | "set" | "trySet" | "compareAndSet" | "tryCompareAndSet" | "compareAndSetMany" | "tryCompareAndSetMany" | "has" | "tryHas" | "delete" | "tryDelete" | "getMany" | "tryGetMany" | "setMany" | "trySetMany" | "deleteMany" | "tryDeleteMany" | "keys" | "tryKeys" | "entries" | "tryEntries" | "clear" | "tryClear" | "watch" | "unwatch" | "dispose" | "tryDispose";
37
+ export type StorageTelemetryOperation = "get" | "tryGet" | "set" | "trySet" | "compareAndSet" | "tryCompareAndSet" | "compareAndSetMany" | "tryCompareAndSetMany" | "has" | "tryHas" | "delete" | "tryDelete" | "getMany" | "tryGetMany" | "setMany" | "trySetMany" | "deleteMany" | "tryDeleteMany" | "keys" | "tryKeys" | "entries" | "tryEntries" | "clear" | "tryClear" | "watch" | "unwatch" | "dispose" | "tryDispose";
42
38
  /** Context passed to telemetry adapters around workflow storage/backend operations. */
43
- interface StorageTelemetryContext {
39
+ export interface StorageTelemetryContext {
44
40
  readonly operation: StorageTelemetryOperation;
45
41
  readonly backend: string;
46
42
  }
47
43
  /** Minimal engine read model exposed to telemetry adapters after engine creation. */
48
- interface TelemetryEngine {
44
+ export interface TelemetryEngine {
49
45
  /** Returns aggregate run metrics for runs matching optional filters. */
50
- getRunSummary(options?: WorkflowRunSummaryOptions): Promise<WorkflowRunSummary>;
46
+ getRunSummary(options?: ListRunsOptions): Promise<RunSummary>;
51
47
  }
52
48
  /** Optional telemetry hooks used to observe running workflow behavior. */
53
- interface Telemetry {
49
+ export interface Telemetry {
54
50
  /** Captures ambient trace context for a newly-created workflow run. */
55
51
  captureContext?(): TelemetryContext | undefined;
56
52
  /** Runs a workflow execution callback with telemetry context. */
57
- withRunExecution?<T>(context: RunTelemetryContext, callback: () => Promise<T>): Promise<T>;
53
+ withRunExecution?<T extends ExecutionResult>(context: RunTelemetryContext, callback: () => Promise<T>): Promise<T>;
58
54
  /** Runs a durable task callback with telemetry context. */
59
55
  withStepExecution?<T>(context: StepTelemetryContext, callback: () => Promise<T>): Promise<T>;
60
56
  /** Runs a workflow storage/backend operation callback with telemetry context. */
@@ -64,11 +60,10 @@ interface Telemetry {
64
60
  /** Observes the final outcome of a durable task callback. */
65
61
  recordStepExecution?(context: StepTelemetryResultContext): void;
66
62
  /** Observes committed workflow observation events. */
67
- observe?<Key extends keyof ObservationEventMap>(name: Key, payload: ObservationEventMap[Key]): void;
63
+ observe?(...event: ObservationEventArgs): void;
68
64
  /** Binds the telemetry adapter to an engine after engine creation. */
69
65
  bindEngine?(engine: TelemetryEngine): void;
70
66
  /** Releases telemetry resources owned by the adapter. */
71
67
  shutdown?(): Promise<void> | void;
72
68
  }
73
- //#endregion
74
- export { RunTelemetryContext, RunTelemetryResultContext, StepTelemetryContext, StepTelemetryResultContext, StorageTelemetryContext, StorageTelemetryOperation, Telemetry, TelemetryContext, TelemetryEngine, workflowTelemetryContextSchema };
69
+ //#endregion
@@ -1,9 +1 @@
1
- import { nonBlankStringSchema } from "./common.mjs";
2
- import { z } from "zod";
3
- //#region src/types/telemetry.ts
4
- const workflowTelemetryContextSchema = z.object({
5
- traceparent: nonBlankStringSchema.optional(),
6
- tracestate: nonBlankStringSchema.optional()
7
- });
8
- //#endregion
9
- export { workflowTelemetryContextSchema };
1
+ export {};
@@ -1,237 +1,50 @@
1
- import { MessageId } from "./message-id.mjs";
2
- import { RunId } from "./run-id.mjs";
3
- import { StepId } from "./step-id.mjs";
4
- import { StreamId } from "./stream-id.mjs";
5
- import { WorkflowAttributePatch, WorkflowRunRecord } from "./run.mjs";
6
- import { WorkflowErrorRecord } from "./error.mjs";
7
- import { AttributesSetEvent, ChildWorkflowCompletedEvent, ChildWorkflowFailedEvent, ChildWorkflowStartedEvent, DeterministicValueRecordedEvent, EventRecord, MessageSendCompletedEvent, MessageSendFailedEvent, MessageSendStartedEvent, MessageSentEvent, MessageWaitCompletedEvent, MessageWaitFailedEvent, MessageWaitStartedEvent, MetadataSetEvent, SleepCompletedEvent, SleepStartedEvent, StreamChunkEvent, StreamClosedEvent, StreamFailedEvent, StreamStartedEvent, WorkflowStepCompletedEvent, WorkflowStepFailedEvent, WorkflowStepStartedEvent } from "./events.mjs";
8
- import { StorageValue } from "@temelj/storage";
1
+ import { AttributePatch, RunRecord } from "./run.mjs";
2
+ import { EventKind, EventRecord } from "./events.mjs";
9
3
  //#region src/types/timeline.d.ts
10
- type WorkflowStartedEvent = Extract<EventRecord, {
11
- readonly kind: "workflow_started";
12
- }>;
13
- type WorkflowCompletedEvent = Extract<EventRecord, {
14
- readonly kind: "workflow_completed";
15
- }>;
16
- type WorkflowFailedEvent = Extract<EventRecord, {
17
- readonly kind: "workflow_failed";
18
- }>;
19
- /** Describes the workflow timeline contract. */
20
- interface Timeline {
21
- readonly run: WorkflowRunRecord;
22
- readonly entries: readonly TimelineEntryRecord[];
4
+ export interface Timeline {
5
+ readonly run: RunRecord;
6
+ readonly entries: readonly TimelineEntry[];
23
7
  }
24
- /** Kind values for workflow timeline entries. */
25
- type TimelineEntryKind = "workflow" | "step" | "sleep" | "child_workflow" | "message" | "stream" | "deterministic" | "metadata" | "attributes";
26
- /** Status values for workflow-level timeline entries. */
27
- type TimelineWorkflowStatus = "started" | "completed" | "failed";
28
- /** Status values for durable task timeline entries. */
29
- type TimelineStepStatus = "started" | "completed" | "failed";
30
- /** Status values for sleep timeline entries. */
31
- type TimelineSleepStatus = "started" | "completed";
32
- /** Status values for child workflow timeline entries. */
33
- type TimelineChildWorkflowStatus = "started" | "completed" | "failed";
34
- /** Status values for messageId timeline entries. */
35
- type TimelineMessageStatus = "send_started" | "send_completed" | "send_failed" | "sent" | "waiting" | "received" | "failed";
36
- /** Status values for stream timeline entries. */
37
- type TimelineStreamStatus = "started" | "chunk" | "closed" | "failed";
38
- /** Status value for metadata and attribute timeline entries. */
39
- type TimelineSetStatus = "set";
40
- /** Status value for deterministic-value timeline entries. */
41
- type TimelineRecordedStatus = "recorded";
42
- /** Base contract for workflow timeline entries. */
43
- interface TimelineEntry {
44
- readonly kind: TimelineEntryKind;
8
+ /** What each durable event kind means on a timeline: the thing it belongs to and what happened. */
9
+ export interface TimelineClassification {
10
+ readonly workflow_started: readonly ["workflow", "started"];
11
+ readonly workflow_completed: readonly ["workflow", "completed"];
12
+ readonly workflow_failed: readonly ["workflow", "failed"];
13
+ readonly step_started: readonly ["step", "started"];
14
+ readonly step_completed: readonly ["step", "completed"];
15
+ readonly step_failed: readonly ["step", "failed"];
16
+ readonly metadata_set: readonly ["metadata", "set"];
17
+ readonly attributes_set: readonly ["attributes", "set"];
18
+ readonly deterministic_value_recorded: readonly ["deterministic", "recorded"];
19
+ readonly sleep_started: readonly ["sleep", "started"];
20
+ readonly sleep_completed: readonly ["sleep", "completed"];
21
+ readonly child_workflow_started: readonly ["child_workflow", "started"];
22
+ readonly child_workflow_completed: readonly ["child_workflow", "completed"];
23
+ readonly child_workflow_failed: readonly ["child_workflow", "failed"];
24
+ readonly message_send_started: readonly ["message", "send_started"];
25
+ readonly message_send_completed: readonly ["message", "send_completed"];
26
+ readonly message_send_failed: readonly ["message", "send_failed"];
27
+ readonly message_sent: readonly ["message", "sent"];
28
+ readonly message_wait_started: readonly ["message", "waiting"];
29
+ readonly message_wait_completed: readonly ["message", "received"];
30
+ readonly message_wait_failed: readonly ["message", "failed"];
31
+ readonly stream_started: readonly ["stream", "started"];
32
+ readonly stream_chunk: readonly ["stream", "chunk"];
33
+ readonly stream_closed: readonly ["stream", "closed"];
34
+ readonly stream_failed: readonly ["stream", "failed"];
45
35
  }
46
- type WorkflowTimelineStepFields = {
36
+ /**
37
+ * One durable event on a run's timeline, classified by `kind` and `status`. The event itself holds
38
+ * the details; attribute entries also carry the patch the event applied.
39
+ */
40
+ export type TimelineEntry = { readonly [Kind in EventKind]: {
41
+ readonly kind: TimelineClassification[Kind][0];
42
+ readonly status: TimelineClassification[Kind][1];
47
43
  readonly timestamp: Temporal.Instant;
48
- readonly stepId: StepId;
49
- readonly stepName: string;
50
- };
51
- type WorkflowTimelineCountField = {
52
- readonly count?: number;
53
- };
54
- type WorkflowTimelineOptionalMessageFields = {
55
- readonly stepId?: StepId;
56
- readonly stepName?: string;
57
- readonly count?: number;
58
- readonly targetRunId?: RunId;
59
- readonly timeoutAt?: Temporal.Instant;
60
- readonly payload?: StorageValue;
61
- readonly error?: WorkflowErrorRecord;
62
- readonly messageTimestamp?: Temporal.Instant;
63
- readonly waiterStepIds?: readonly string[];
64
- };
65
- /** Describes the workflow timeline workflow entry contract. */
66
- type TimelineWorkflowEntry = {
67
- readonly kind: "workflow";
68
- readonly status: "started";
69
- readonly timestamp: Temporal.Instant;
70
- readonly event: WorkflowStartedEvent;
71
- } | {
72
- readonly kind: "workflow";
73
- readonly status: "completed";
74
- readonly timestamp: Temporal.Instant;
75
- readonly event: WorkflowCompletedEvent;
76
- } | {
77
- readonly kind: "workflow";
78
- readonly status: "failed";
79
- readonly timestamp: Temporal.Instant;
80
- readonly event: WorkflowFailedEvent;
81
- };
82
- /** Describes the workflow timeline step entry contract. */
83
- type TimelineStepEntry = (WorkflowTimelineStepFields & WorkflowTimelineCountField & {
84
- readonly kind: "step";
85
- readonly status: "started";
86
- readonly attempt: number;
87
- readonly event: WorkflowStepStartedEvent;
88
- }) | (WorkflowTimelineStepFields & {
89
- readonly kind: "step";
90
- readonly status: "completed";
91
- readonly attempt: number;
92
- readonly result?: StorageValue;
93
- readonly event: WorkflowStepCompletedEvent;
94
- }) | (WorkflowTimelineStepFields & {
95
- readonly kind: "step";
96
- readonly status: "failed";
97
- readonly attempt: number;
98
- readonly error?: WorkflowErrorRecord;
99
- readonly event: WorkflowStepFailedEvent;
100
- });
101
- /** Describes the workflow timeline sleep entry contract. */
102
- type TimelineSleepEntry = (WorkflowTimelineStepFields & WorkflowTimelineCountField & {
103
- readonly kind: "sleep";
104
- readonly status: "started";
105
- readonly until?: Temporal.Instant;
106
- readonly duration?: Temporal.Duration;
107
- readonly event: SleepStartedEvent;
108
- }) | (WorkflowTimelineStepFields & {
109
- readonly kind: "sleep";
110
- readonly status: "completed";
111
- readonly event: SleepCompletedEvent;
112
- });
113
- /** Describes the workflow timeline child workflow entry contract. */
114
- type TimelineChildWorkflowEntry = (WorkflowTimelineStepFields & WorkflowTimelineCountField & {
115
- readonly kind: "child_workflow";
116
- readonly status: "started";
117
- readonly childRunId: RunId;
118
- readonly workflowName?: string;
119
- readonly workflowVersion?: string;
120
- readonly input?: StorageValue;
121
- readonly timeoutAt?: Temporal.Instant;
122
- readonly event: ChildWorkflowStartedEvent;
123
- }) | (WorkflowTimelineStepFields & {
124
- readonly kind: "child_workflow";
125
- readonly status: "completed";
126
- readonly childRunId: RunId;
127
- readonly result?: StorageValue;
128
- readonly event: ChildWorkflowCompletedEvent;
129
- }) | (WorkflowTimelineStepFields & {
130
- readonly kind: "child_workflow";
131
- readonly status: "failed";
132
- readonly childRunId: RunId;
133
- readonly error?: WorkflowErrorRecord;
134
- readonly event: ChildWorkflowFailedEvent;
135
- });
136
- /** Describes the workflow timeline messageId entry contract. */
137
- type TimelineMessageEntry = (WorkflowTimelineOptionalMessageFields & WorkflowTimelineStepFields & WorkflowTimelineCountField & {
138
- readonly kind: "message";
139
- readonly status: "send_started";
140
- readonly targetRunId: RunId;
141
- readonly messageId: MessageId;
142
- readonly event: MessageSendStartedEvent;
143
- }) | (WorkflowTimelineOptionalMessageFields & WorkflowTimelineStepFields & {
144
- readonly kind: "message";
145
- readonly status: "send_completed";
146
- readonly targetRunId: RunId;
147
- readonly messageId: MessageId;
148
- readonly event: MessageSendCompletedEvent;
149
- }) | (WorkflowTimelineOptionalMessageFields & WorkflowTimelineStepFields & {
150
- readonly kind: "message";
151
- readonly status: "send_failed";
152
- readonly targetRunId: RunId;
153
- readonly messageId: MessageId;
154
- readonly error?: WorkflowErrorRecord;
155
- readonly event: MessageSendFailedEvent;
156
- }) | (WorkflowTimelineOptionalMessageFields & {
157
- readonly kind: "message";
158
- readonly status: "sent";
159
- readonly timestamp: Temporal.Instant;
160
- readonly messageId: MessageId;
161
- readonly payload?: StorageValue;
162
- readonly event: MessageSentEvent;
163
- }) | (WorkflowTimelineOptionalMessageFields & WorkflowTimelineStepFields & WorkflowTimelineCountField & {
164
- readonly kind: "message";
165
- readonly status: "waiting";
166
- readonly messageId: MessageId;
167
- readonly timeoutAt?: Temporal.Instant;
168
- readonly event: MessageWaitStartedEvent;
169
- }) | (WorkflowTimelineOptionalMessageFields & WorkflowTimelineStepFields & {
170
- readonly kind: "message";
171
- readonly status: "received";
172
- readonly messageId: MessageId;
173
- readonly payload?: StorageValue;
174
- readonly messageTimestamp?: Temporal.Instant;
175
- readonly event: MessageWaitCompletedEvent;
176
- }) | (WorkflowTimelineOptionalMessageFields & WorkflowTimelineStepFields & {
177
- readonly kind: "message";
178
- readonly status: "failed";
179
- readonly messageId: MessageId;
180
- readonly error?: WorkflowErrorRecord;
181
- readonly event: MessageWaitFailedEvent;
182
- });
183
- /** Describes the workflow timeline metadata entry contract. */
184
- type TimelineMetadataEntry = WorkflowTimelineStepFields & {
185
- readonly kind: "metadata";
186
- readonly status: TimelineSetStatus;
187
- readonly count: number;
188
- readonly metadata: StorageValue;
189
- readonly event: MetadataSetEvent;
190
- };
191
- /** Describes the workflow timeline attributes entry contract. */
192
- type TimelineAttributesEntry = WorkflowTimelineStepFields & {
193
- readonly kind: "attributes";
194
- readonly status: TimelineSetStatus;
195
- readonly count: number;
196
- readonly attributes: WorkflowAttributePatch;
197
- readonly event: AttributesSetEvent;
198
- };
199
- /** Describes the workflow timeline stream entry contract. */
200
- type TimelineStreamEntry = (WorkflowTimelineStepFields & WorkflowTimelineCountField & {
201
- readonly kind: "stream";
202
- readonly status: "started";
203
- readonly streamId: StreamId;
204
- readonly contentType?: string;
205
- readonly metadata?: StorageValue;
206
- readonly event: StreamStartedEvent;
207
- }) | (WorkflowTimelineStepFields & {
208
- readonly kind: "stream";
209
- readonly status: "chunk";
210
- readonly streamId: StreamId;
211
- readonly index: number;
212
- readonly chunk?: StorageValue;
213
- readonly event: StreamChunkEvent;
214
- }) | (WorkflowTimelineStepFields & {
215
- readonly kind: "stream";
216
- readonly status: "closed";
217
- readonly streamId: StreamId;
218
- readonly event: StreamClosedEvent;
219
- }) | (WorkflowTimelineStepFields & {
220
- readonly kind: "stream";
221
- readonly status: "failed";
222
- readonly streamId: StreamId;
223
- readonly error?: WorkflowErrorRecord;
224
- readonly event: StreamFailedEvent;
225
- });
226
- /** Describes the workflow timeline deterministic entry contract. */
227
- type TimelineDeterministicEntry = WorkflowTimelineStepFields & {
228
- readonly kind: "deterministic";
229
- readonly status: TimelineRecordedStatus;
230
- readonly count: number;
231
- readonly value: StorageValue;
232
- readonly event: DeterministicValueRecordedEvent;
233
- };
234
- /** Type used for workflow timeline entry values. */
235
- type TimelineEntryRecord = TimelineWorkflowEntry | TimelineStepEntry | TimelineSleepEntry | TimelineChildWorkflowEntry | TimelineMessageEntry | TimelineStreamEntry | TimelineDeterministicEntry | TimelineMetadataEntry | TimelineAttributesEntry;
236
- //#endregion
237
- export { Timeline, TimelineAttributesEntry, TimelineChildWorkflowEntry, TimelineChildWorkflowStatus, TimelineDeterministicEntry, TimelineEntry, TimelineEntryKind, TimelineEntryRecord, TimelineMessageEntry, TimelineMessageStatus, TimelineMetadataEntry, TimelineRecordedStatus, TimelineSetStatus, TimelineSleepEntry, TimelineSleepStatus, TimelineStepEntry, TimelineStepStatus, TimelineStreamEntry, TimelineStreamStatus, TimelineWorkflowEntry, TimelineWorkflowStatus };
44
+ readonly event: Extract<EventRecord, {
45
+ readonly kind: Kind;
46
+ }>;
47
+ } & (Kind extends "attributes_set" ? {
48
+ readonly attributes: AttributePatch;
49
+ } : unknown); }[EventKind];
50
+ //#endregion
@@ -1,45 +1,42 @@
1
- import { RunId } from "./run-id.mjs";
2
- import { WorkflowMissingImplementationRetryConfig } from "./retry.mjs";
1
+ import { RunId, WorkerId } from "./ids.mjs";
2
+ import { MissingImplementationRetryConfig } from "./retry.mjs";
3
3
  import { RegistryLike } from "./definition.mjs";
4
- import { WorkerId } from "./worker-id.mjs";
5
4
  import { ExecutionResult } from "./result.mjs";
6
- import { WorkflowAttributeValue, WorkflowRunRecord, WorkflowRunRetryReason, WorkflowRunStatus, WorkflowRunTransitionReason } from "./run.mjs";
7
- import { WorkflowWorkerEngine } from "./engine.mjs";
5
+ import { RunRecord, RunRetryReason, RunStatus, RunTransitionReason, WorkflowAttributeValue } from "./run.mjs";
6
+ import { WorkflowEngine } from "../engine/create.mjs";
8
7
  //#region src/types/worker.d.ts
9
8
  /** Options for creating a direct workflow worker host. */
10
- interface CreateWorkflowWorkerOptions {
11
- readonly engine: WorkflowWorkerEngine;
9
+ export interface CreateWorkflowWorkerOptions {
10
+ readonly engine: WorkflowEngine;
12
11
  readonly registry: RegistryLike;
13
12
  readonly workerId?: WorkerId;
14
13
  readonly leaseDuration?: Temporal.Duration;
15
14
  readonly pollInterval?: Temporal.Duration;
16
15
  readonly heartbeatInterval?: Temporal.Duration;
17
16
  readonly stopDrainTimeout?: Temporal.Duration;
18
- readonly missingImplementationRetry?: WorkflowMissingImplementationRetryConfig;
17
+ readonly missingImplementationRetry?: MissingImplementationRetryConfig;
19
18
  readonly now?: () => Temporal.Instant;
20
19
  }
21
- /** Describes the workflow worker contract. */
22
- interface WorkflowWorker {
20
+ export interface WorkflowWorker {
23
21
  /** Claims and processes a specific run by ID. */
24
22
  processRun(runId: RunId): Promise<ExecutionResult<unknown>>;
25
23
  /** Claims and processes the next available run matching the optional filters. */
26
- processNextRun(options?: WorkflowWorkerRunFilterOptions): Promise<ExecutionResult<unknown> | undefined>;
24
+ processNextRun(options?: WorkerRunFilterOptions): Promise<ExecutionResult<unknown> | undefined>;
27
25
  /** Extends the worker lease for a claimed run. */
28
- extendLease(runId: RunId, options?: WorkflowWorkerLeaseOptions): Promise<WorkflowRunRecord | undefined>;
26
+ extendLease(runId: RunId, options?: WorkerLeaseOptions): Promise<RunRecord | undefined>;
29
27
  /** Releases the worker lease for a claimed run. */
30
- releaseLease(runId: RunId, options?: WorkflowWorkerLeaseOptions): Promise<WorkflowRunRecord | undefined>;
28
+ releaseLease(runId: RunId, options?: WorkerLeaseOptions): Promise<RunRecord | undefined>;
31
29
  /** Runs the worker polling loop until stopped, aborted, or maxRuns is reached. */
32
- run(options?: WorkflowWorkerRunOptions): Promise<WorkflowWorkerRunResult>;
30
+ run(options?: WorkerRunOptions): Promise<WorkerRunResult>;
33
31
  /** Stops the worker polling loop and waits for active work to settle. */
34
32
  stop(): Promise<void>;
35
33
  }
36
- /** Options for workflow worker lease. */
37
- interface WorkflowWorkerLeaseOptions {
34
+ export interface WorkerLeaseOptions {
38
35
  readonly attempts?: number;
39
36
  }
40
37
  /** Run filters accepted by workers; worker identity is supplied by the worker itself. */
41
- interface WorkflowWorkerRunFilterOptions {
42
- readonly status?: WorkflowRunStatus | readonly WorkflowRunStatus[];
38
+ export interface WorkerRunFilterOptions {
39
+ readonly status?: RunStatus | readonly RunStatus[];
43
40
  readonly workflowName?: string;
44
41
  readonly workflowVersion?: string;
45
42
  readonly idempotencyKey?: string;
@@ -47,7 +44,7 @@ interface WorkflowWorkerRunFilterOptions {
47
44
  readonly parentStepId?: string;
48
45
  readonly parentStepName?: string;
49
46
  readonly parentStepAttempt?: number;
50
- readonly lastTransitionReason?: WorkflowRunTransitionReason | readonly WorkflowRunTransitionReason[];
47
+ readonly lastTransitionReason?: RunTransitionReason | readonly RunTransitionReason[];
51
48
  readonly createdAtFrom?: Temporal.Instant;
52
49
  readonly createdAtTo?: Temporal.Instant;
53
50
  readonly updatedAtFrom?: Temporal.Instant;
@@ -60,7 +57,7 @@ interface WorkflowWorkerRunFilterOptions {
60
57
  readonly availableAtTo?: Temporal.Instant;
61
58
  readonly leaseExpiresAtFrom?: Temporal.Instant;
62
59
  readonly leaseExpiresAtTo?: Temporal.Instant;
63
- readonly retryReason?: WorkflowRunRetryReason | readonly WorkflowRunRetryReason[];
60
+ readonly retryReason?: RunRetryReason | readonly RunRetryReason[];
64
61
  readonly retryAtFrom?: Temporal.Instant;
65
62
  readonly retryAtTo?: Temporal.Instant;
66
63
  readonly cleanupFinishedAtBefore?: Temporal.Instant;
@@ -69,26 +66,22 @@ interface WorkflowWorkerRunFilterOptions {
69
66
  readonly attributeMissing?: string | readonly string[];
70
67
  readonly limit?: number;
71
68
  }
72
- /** Options for workflow worker run. */
73
- interface WorkflowWorkerRunOptions extends WorkflowWorkerRunFilterOptions {
69
+ export interface WorkerRunOptions extends WorkerRunFilterOptions {
74
70
  readonly signal?: AbortSignal;
75
71
  readonly maxRuns?: number;
76
72
  readonly concurrency?: number;
77
73
  readonly pollInterval?: Temporal.Duration;
78
74
  readonly tickSchedules?: boolean;
79
75
  }
80
- /** Result returned by workflow worker run. */
81
- interface WorkflowWorkerRunResult {
76
+ export interface WorkerRunResult {
82
77
  readonly processedRuns: number;
83
78
  }
84
- /** Options for workflow wake due runs. */
85
- interface WorkflowWakeDueRunsOptions extends WorkflowWorkerRunFilterOptions {
79
+ export interface WakeDueRunsOptions extends WorkerRunFilterOptions {
86
80
  readonly workerId?: string;
87
81
  readonly leaseDuration?: Temporal.Duration;
88
82
  readonly heartbeatInterval?: Temporal.Duration;
89
- readonly missingImplementationRetry?: WorkflowMissingImplementationRetryConfig;
83
+ readonly missingImplementationRetry?: MissingImplementationRetryConfig;
90
84
  readonly signal?: AbortSignal;
91
85
  readonly maxRuns?: number;
92
86
  }
93
- //#endregion
94
- export { CreateWorkflowWorkerOptions, WorkflowWakeDueRunsOptions, WorkflowWorker, WorkflowWorkerLeaseOptions, WorkflowWorkerRunFilterOptions, WorkflowWorkerRunOptions, WorkflowWorkerRunResult };
87
+ //#endregion
@@ -0,0 +1,15 @@
1
+ //#region src/values.d.ts
2
+ /** Returns the greatest positive safe integer from two optional values. */
3
+ export declare function greatestOptionalNumber(current: number | undefined, next: number | undefined): number | undefined;
4
+ export declare function isPositiveSafeInteger(value: number): boolean;
5
+ export declare function isNonNegativeSafeInteger(value: number): boolean;
6
+ /** Returns the next positive safe integer, or undefined when the input cannot be advanced. */
7
+ export declare function nextPositiveSafeInteger(value: number): number | undefined;
8
+ export declare function isAbortError(cause: unknown): boolean;
9
+ export declare function positiveSafeInteger(value: number, label: string): number;
10
+ export declare function resolvePositiveSafeIntegerOption(value: number | undefined, label: string): number | undefined;
11
+ export declare function safeDuration(value: number, label: string): number;
12
+ export declare function durationAmount(value: Temporal.Duration, label: string): number;
13
+ /** Returns a retry delay in milliseconds and reports invalid numbers as duration errors. */
14
+ export declare function resolveSafeRetryDelay(value: number | undefined, label: string): number | undefined;
15
+ //#endregion
@@ -0,0 +1,57 @@
1
+ import { WorkflowErrorCode } from "./errors/codes.mjs";
2
+ import { WorkflowOptionsError } from "./errors/base.mjs";
3
+ import { WorkflowDurationError } from "./errors/failures.mjs";
4
+ //#region src/values.ts
5
+ /** Returns the greatest positive safe integer from two optional values. */
6
+ function greatestOptionalNumber(current, next) {
7
+ if (next === void 0 || !isPositiveSafeInteger(next)) return current;
8
+ if (current === void 0) return next;
9
+ return Math.max(current, next);
10
+ }
11
+ function isPositiveSafeInteger(value) {
12
+ return Number.isSafeInteger(value) && value > 0;
13
+ }
14
+ function isNonNegativeSafeInteger(value) {
15
+ return Number.isSafeInteger(value) && value >= 0;
16
+ }
17
+ /** Returns the next positive safe integer, or undefined when the input cannot be advanced. */
18
+ function nextPositiveSafeInteger(value) {
19
+ return isPositiveSafeInteger(value) && value < Number.MAX_SAFE_INTEGER ? value + 1 : void 0;
20
+ }
21
+ function isAbortError(cause) {
22
+ return cause instanceof Error && cause.name === "AbortError" || cause instanceof DOMException && cause.name === "AbortError";
23
+ }
24
+ function positiveSafeInteger(value, label) {
25
+ if (!isPositiveSafeInteger(value)) throw new WorkflowDurationError(`${label} must be a positive safe integer`);
26
+ return value;
27
+ }
28
+ function resolvePositiveSafeIntegerOption(value, label) {
29
+ if (value === void 0) return;
30
+ if (!isPositiveSafeInteger(value)) WorkflowOptionsError.positiveSafeInteger(label);
31
+ return value;
32
+ }
33
+ function safeDuration(value, label) {
34
+ try {
35
+ resolveSafeRetryDelay(value, label);
36
+ } catch (error) {
37
+ if (!(error instanceof WorkflowOptionsError)) throw error;
38
+ throw new WorkflowDurationError(`${label} must be a timer-safe duration`);
39
+ }
40
+ return value;
41
+ }
42
+ function durationAmount(value, label) {
43
+ if (!(value instanceof Temporal.Duration)) throw new WorkflowDurationError(`${label} must be a Temporal.Duration`);
44
+ const amount = value.total({ unit: "millisecond" });
45
+ if (!Number.isFinite(amount)) throw new WorkflowDurationError(`${label} must be finite`);
46
+ return amount;
47
+ }
48
+ /** Returns a retry delay in milliseconds and reports invalid numbers as duration errors. */
49
+ function resolveSafeRetryDelay(value, label) {
50
+ if (value !== void 0 && !Number.isSafeInteger(value)) throw new WorkflowOptionsError(`${label} must be a timer-safe duration`, {
51
+ code: WorkflowErrorCode.OPTIONS_EXPECTED_TIMER_SAFE_DURATION,
52
+ details: { label }
53
+ });
54
+ return value;
55
+ }
56
+ //#endregion
57
+ export { durationAmount, greatestOptionalNumber, isAbortError, isNonNegativeSafeInteger, isPositiveSafeInteger, nextPositiveSafeInteger, positiveSafeInteger, resolvePositiveSafeIntegerOption, resolveSafeRetryDelay, safeDuration };
package/dist/vite.d.mts CHANGED
@@ -1,6 +1,5 @@
1
- import { DirectiveKind, TransformManifest, TransformManifestFunction, TransformManifestImportEdge, TransformMetadata, TransformMetadataEntry, TransformOptions, TransformResult, VitePluginOptions, WorkflowPluginOptions } from "./types/vite.mjs";
2
- import { workflow, workflowPlugin } from "./vite/plugin.mjs";
3
- import { GENERATED_PREFIX, makeGeneratedName } from "./vite/generated-name.mjs";
4
- import { WorkflowTransformError } from "./vite/error.mjs";
5
- import { transformWorkflowSource } from "./vite/transform.mjs";
6
- export { type DirectiveKind, GENERATED_PREFIX, type TransformManifest, type TransformManifestFunction, type TransformManifestImportEdge, type TransformMetadata, type TransformMetadataEntry, type TransformOptions, type TransformResult, type VitePluginOptions, type WorkflowPluginOptions, WorkflowTransformError, makeGeneratedName, transformWorkflowSource, workflow, workflowPlugin };
1
+ import { WorkflowTransformError } from "./compiler/error.mjs";
2
+ import { DirectiveKind, PluginOptions, TransformManifest, TransformManifestFunction, TransformManifestImportEdge, TransformMetadata, TransformMetadataEntry, TransformOptions, TransformResult } from "./types/compiler.mjs";
3
+ import { workflow, workflowPlugin } from "./compiler/plugin.mjs";
4
+ import { GENERATED_PREFIX, makeGeneratedName, transformWorkflowSource } from "./compiler/transform.mjs";
5
+ export { type DirectiveKind, GENERATED_PREFIX, type PluginOptions, type TransformManifest, type TransformManifestFunction, type TransformManifestImportEdge, type TransformMetadata, type TransformMetadataEntry, type TransformOptions, type TransformResult, WorkflowTransformError, makeGeneratedName, transformWorkflowSource, workflow, workflowPlugin };
package/dist/vite.mjs CHANGED
@@ -1,5 +1,4 @@
1
- import { WorkflowTransformError } from "./vite/error.mjs";
2
- import { GENERATED_PREFIX, makeGeneratedName } from "./vite/generated-name.mjs";
3
- import { transformWorkflowSource } from "./vite/transform.mjs";
4
- import { workflow, workflowPlugin } from "./vite/plugin.mjs";
1
+ import { WorkflowTransformError } from "./compiler/error.mjs";
2
+ import { GENERATED_PREFIX, makeGeneratedName, transformWorkflowSource } from "./compiler/transform.mjs";
3
+ import { workflow, workflowPlugin } from "./compiler/plugin.mjs";
5
4
  export { GENERATED_PREFIX, WorkflowTransformError, makeGeneratedName, transformWorkflowSource, workflow, workflowPlugin };
@@ -1,7 +1,9 @@
1
- import { WorkflowPluginOptions } from "./types/vite.mjs";
2
- import { workflowPlugin } from "./vite/plugin.mjs";
1
+ import { PluginOptions } from "./types/compiler.mjs";
2
+ import { workflowPlugin } from "./compiler/plugin.mjs";
3
+ import "./esbuild.mjs";
4
+ import "temporal-polyfill/global";
3
5
  //#region src/webpack.d.ts
4
6
  /** Creates the webpack plugin that compiles workflow and step directives. */
5
- declare const workflow: (options?: WorkflowPluginOptions | undefined) => import("webpack").WebpackPluginInstance;
7
+ export declare const workflow: (options?: PluginOptions | undefined) => import("webpack").WebpackPluginInstance;
6
8
  //#endregion
7
- export { type WorkflowPluginOptions, workflow, workflowPlugin };
9
+ export { type PluginOptions, workflowPlugin };
package/dist/webpack.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import { workflowPlugin } from "./vite/plugin.mjs";
1
+ import { workflowPlugin } from "./compiler/plugin.mjs";
2
+ import "temporal-polyfill/global";
2
3
  //#region src/webpack.ts
3
4
  /** Creates the webpack plugin that compiles workflow and step directives. */
4
5
  const workflow = workflowPlugin.webpack;