@logixjs/core 0.0.1 → 0.0.2

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 (300) hide show
  1. package/LICENSE +201 -0
  2. package/dist/{Bound-BN1DQ_lM.d.ts → Bound-CEa1ihvH.d.ts} +2 -2
  3. package/dist/{Bound-BPIfH9SS.d.cts → Bound-CNLNkC7c.d.cts} +2 -2
  4. package/dist/Bound.cjs +620 -163
  5. package/dist/Bound.cjs.map +1 -1
  6. package/dist/Bound.d.cts +3 -3
  7. package/dist/Bound.d.ts +3 -3
  8. package/dist/Bound.js +14 -14
  9. package/dist/{Debug-Bq8Sqjcr.d.cts → Debug-BhMYr-1i.d.cts} +3 -3
  10. package/dist/{Debug-B5q5Bkzx.d.ts → Debug-ByM7m4Ft.d.ts} +3 -3
  11. package/dist/Debug.cjs +553 -32
  12. package/dist/Debug.cjs.map +1 -1
  13. package/dist/Debug.d.cts +10 -8
  14. package/dist/Debug.d.ts +10 -8
  15. package/dist/Debug.js +12 -10
  16. package/dist/EffectOp.cjs.map +1 -1
  17. package/dist/EffectOp.js +2 -3
  18. package/dist/EffectOp.js.map +1 -1
  19. package/dist/Env.cjs +664 -6
  20. package/dist/Env.cjs.map +1 -1
  21. package/dist/Env.js +5 -2
  22. package/dist/ExternalStore-BAz83PVq.d.cts +60 -0
  23. package/dist/ExternalStore-BYWPbYs8.d.ts +60 -0
  24. package/dist/ExternalStore.cjs +746 -0
  25. package/dist/ExternalStore.cjs.map +1 -0
  26. package/dist/ExternalStore.d.cts +4 -0
  27. package/dist/ExternalStore.d.ts +4 -0
  28. package/dist/ExternalStore.js +19 -0
  29. package/dist/ExternalStore.js.map +1 -0
  30. package/dist/{Flow-1fZT8MpX.d.cts → Flow-BlSoMmhV.d.cts} +2 -2
  31. package/dist/{Flow-BhpjE22E.d.ts → Flow-CQSGve5c.d.ts} +2 -2
  32. package/dist/Flow.cjs +2 -2
  33. package/dist/Flow.cjs.map +1 -1
  34. package/dist/Flow.d.cts +4 -4
  35. package/dist/Flow.d.ts +4 -4
  36. package/dist/Flow.js +7 -8
  37. package/dist/{Handle-D_cLW1Z3.d.ts → Handle-B7PSmsrY.d.ts} +1 -1
  38. package/dist/{Handle-D8D1zPb_.d.cts → Handle-ByovhL-c.d.cts} +1 -1
  39. package/dist/Handle.d.cts +3 -3
  40. package/dist/Handle.d.ts +3 -3
  41. package/dist/{Kernel-CnGE1Fyk.d.ts → Kernel-DGSpS4GM.d.ts} +2 -2
  42. package/dist/{Kernel-8kC-jOda.d.cts → Kernel-DZAk-Mrn.d.cts} +2 -2
  43. package/dist/Kernel.cjs +680 -22
  44. package/dist/Kernel.cjs.map +1 -1
  45. package/dist/Kernel.d.cts +10 -8
  46. package/dist/Kernel.d.ts +10 -8
  47. package/dist/Kernel.js +7 -4
  48. package/dist/{Link-Db7975nU.d.ts → Link-Cm4eR9n0.d.ts} +10 -3
  49. package/dist/{Link-fX8x1eCK.d.cts → Link-DF8i8iWR.d.cts} +10 -3
  50. package/dist/Link.cjs +1128 -86
  51. package/dist/Link.cjs.map +1 -1
  52. package/dist/Link.d.cts +3 -3
  53. package/dist/Link.d.ts +3 -3
  54. package/dist/Link.js +30 -25
  55. package/dist/{Logic-DRh4sDZj.d.cts → Logic-BcQA0AvE.d.cts} +1 -1
  56. package/dist/{Logic-BRjEMr-W.d.ts → Logic-OotSE1xw.d.ts} +1 -1
  57. package/dist/Logic.d.cts +3 -3
  58. package/dist/Logic.d.ts +3 -3
  59. package/dist/{MatchBuilder-CJk5oCkR.d.cts → MatchBuilder-BNDJ8waF.d.ts} +1 -1
  60. package/dist/{MatchBuilder-0QOc-nlU.d.ts → MatchBuilder-CvZ5WY1B.d.cts} +1 -1
  61. package/dist/MatchBuilder.d.cts +4 -4
  62. package/dist/MatchBuilder.d.ts +4 -4
  63. package/dist/Middleware-D8tUDLv_.d.cts +100 -0
  64. package/dist/Middleware-DS7CbTTN.d.ts +100 -0
  65. package/dist/Middleware.cjs +461 -13
  66. package/dist/Middleware.cjs.map +1 -1
  67. package/dist/Middleware.d.cts +2 -86
  68. package/dist/Middleware.d.ts +2 -86
  69. package/dist/Middleware.js +13 -11
  70. package/dist/{Module-DnzluX2J.d.ts → Module-CFj0I2yE.d.ts} +45 -18
  71. package/dist/{Module-B_0xRDMR.d.cts → Module-DpXPW9EQ.d.cts} +45 -18
  72. package/dist/Module.cjs +8583 -5741
  73. package/dist/Module.cjs.map +1 -1
  74. package/dist/Module.d.cts +5 -4
  75. package/dist/Module.d.ts +5 -4
  76. package/dist/Module.js +32 -27
  77. package/dist/ModuleTag-BcVF6z7B.d.ts +113 -0
  78. package/dist/ModuleTag-DuZXo_NS.d.cts +113 -0
  79. package/dist/ModuleTag.cjs +2609 -1232
  80. package/dist/ModuleTag.cjs.map +1 -1
  81. package/dist/ModuleTag.d.cts +4 -4
  82. package/dist/ModuleTag.d.ts +4 -4
  83. package/dist/ModuleTag.js +28 -25
  84. package/dist/{Observability-cY4kLn0S.d.ts → Observability-D-ZWeEVb.d.ts} +22 -15
  85. package/dist/{Observability-COqEvp2C.d.cts → Observability-V7sRMYTh.d.cts} +22 -15
  86. package/dist/Observability.cjs +1938 -640
  87. package/dist/Observability.cjs.map +1 -1
  88. package/dist/Observability.d.cts +4 -4
  89. package/dist/Observability.d.ts +4 -4
  90. package/dist/Observability.js +21 -19
  91. package/dist/{Process-mL8fHDSB.d.cts → Process-B55aJMFk.d.cts} +29 -4
  92. package/dist/{Process-CM9xbMdP.d.ts → Process-DvhFEwUS.d.ts} +29 -4
  93. package/dist/Process.cjs +1122 -85
  94. package/dist/Process.cjs.map +1 -1
  95. package/dist/Process.d.cts +4 -3
  96. package/dist/Process.d.ts +4 -3
  97. package/dist/Process.js +27 -22
  98. package/dist/{ReadQuery-BlMwhe-F.d.ts → ReadQuery-C4vZ8Prc.d.ts} +2 -2
  99. package/dist/{ReadQuery-SinbStGF.d.ts → ReadQuery-CafjlJQo.d.cts} +1 -1
  100. package/dist/{ReadQuery-SinbStGF.d.cts → ReadQuery-CafjlJQo.d.ts} +1 -1
  101. package/dist/{ReadQuery-CL5XlXts.d.cts → ReadQuery-mc0NgrFV.d.cts} +2 -2
  102. package/dist/ReadQuery.cjs +3 -3
  103. package/dist/ReadQuery.cjs.map +1 -1
  104. package/dist/ReadQuery.d.cts +2 -2
  105. package/dist/ReadQuery.d.ts +2 -2
  106. package/dist/ReadQuery.js +3 -3
  107. package/dist/{Reflection-CQnKwPXj.d.ts → Reflection-C8xZ267q.d.ts} +88 -7
  108. package/dist/{Reflection-Kabo1mlU.d.cts → Reflection-DP7Vsv3f.d.cts} +88 -7
  109. package/dist/Reflection.cjs +2934 -1553
  110. package/dist/Reflection.cjs.map +1 -1
  111. package/dist/Reflection.d.cts +14 -11
  112. package/dist/Reflection.d.ts +14 -11
  113. package/dist/Reflection.js +26 -21
  114. package/dist/Resource.cjs +670 -12
  115. package/dist/Resource.cjs.map +1 -1
  116. package/dist/Resource.js +6 -3
  117. package/dist/Root.cjs +675 -17
  118. package/dist/Root.cjs.map +1 -1
  119. package/dist/Root.js +7 -3
  120. package/dist/{Runtime-CtyzZG4i.d.ts → Runtime-BWc9YfUB.d.ts} +37 -7
  121. package/dist/{Runtime-B-aL-f29.d.cts → Runtime-PShIC4DW.d.cts} +37 -7
  122. package/dist/Runtime.cjs +1899 -809
  123. package/dist/Runtime.cjs.map +1 -1
  124. package/dist/Runtime.d.cts +14 -11
  125. package/dist/Runtime.d.ts +14 -11
  126. package/dist/Runtime.js +33 -28
  127. package/dist/ScopeRegistry.cjs +668 -10
  128. package/dist/ScopeRegistry.cjs.map +1 -1
  129. package/dist/ScopeRegistry.js +6 -3
  130. package/dist/{StateTrait-OWhbj12c.d.cts → StateTrait-CQsDlXJm.d.cts} +23 -6
  131. package/dist/{StateTrait-BGsZghTz.d.ts → StateTrait-YvJzVDKl.d.ts} +23 -6
  132. package/dist/StateTrait.cjs +1475 -370
  133. package/dist/StateTrait.cjs.map +1 -1
  134. package/dist/StateTrait.d.cts +7 -5
  135. package/dist/StateTrait.d.ts +7 -5
  136. package/dist/StateTrait.js +17 -14
  137. package/dist/{TraitLifecycle-LdIWmKlg.d.ts → TraitLifecycle-CjIBICAA.d.ts} +2 -2
  138. package/dist/{TraitLifecycle-CwV5WPFX.d.cts → TraitLifecycle-NmqGiXPC.d.cts} +2 -2
  139. package/dist/TraitLifecycle.cjs +489 -32
  140. package/dist/TraitLifecycle.cjs.map +1 -1
  141. package/dist/TraitLifecycle.d.cts +4 -4
  142. package/dist/TraitLifecycle.d.ts +4 -4
  143. package/dist/TraitLifecycle.js +7 -7
  144. package/dist/Workflow-BlFG_20_.d.cts +414 -0
  145. package/dist/Workflow-CW9S_aAP.d.ts +414 -0
  146. package/dist/Workflow.cjs +2977 -0
  147. package/dist/Workflow.cjs.map +1 -0
  148. package/dist/Workflow.d.cts +7 -0
  149. package/dist/Workflow.d.ts +7 -0
  150. package/dist/Workflow.js +55 -0
  151. package/dist/Workflow.js.map +1 -0
  152. package/dist/{chunk-G5ZBFPNU.js → chunk-2A4UKO2D.js} +2 -2
  153. package/dist/chunk-2DE6D42I.js +248 -0
  154. package/dist/chunk-2DE6D42I.js.map +1 -0
  155. package/dist/{chunk-ANLBCBDC.js → chunk-2DVLMSOE.js} +6 -6
  156. package/dist/{chunk-BE3HW4FY.js → chunk-34CF6OGE.js} +14 -16
  157. package/dist/chunk-34CF6OGE.js.map +1 -0
  158. package/dist/{chunk-ZFY7U2FR.js → chunk-3LPIXG56.js} +43 -3
  159. package/dist/chunk-3LPIXG56.js.map +1 -0
  160. package/dist/chunk-3VZYDNXZ.js +10 -0
  161. package/dist/chunk-3VZYDNXZ.js.map +1 -0
  162. package/dist/{chunk-3TMODYZV.js → chunk-3XO4HR6V.js} +2 -2
  163. package/dist/chunk-46FGVWRF.js +817 -0
  164. package/dist/chunk-46FGVWRF.js.map +1 -0
  165. package/dist/chunk-4LODUXFI.js +288 -0
  166. package/dist/chunk-4LODUXFI.js.map +1 -0
  167. package/dist/{chunk-GMPEOUP2.js → chunk-4MZ7BT3R.js} +2 -2
  168. package/dist/chunk-4MZ7BT3R.js.map +1 -0
  169. package/dist/{chunk-TKZ7MEIA.js → chunk-53GVPGSM.js} +2 -2
  170. package/dist/{chunk-KP7MUZNX.js → chunk-5W2V2NVJ.js} +2 -2
  171. package/dist/chunk-5W2V2NVJ.js.map +1 -0
  172. package/dist/chunk-6DACKW3D.js +613 -0
  173. package/dist/chunk-6DACKW3D.js.map +1 -0
  174. package/dist/chunk-AQ7L2QZ5.js +1395 -0
  175. package/dist/chunk-AQ7L2QZ5.js.map +1 -0
  176. package/dist/{chunk-NZJKFF45.js → chunk-C2UZZQ76.js} +2 -2
  177. package/dist/chunk-CCKP5Z6F.js +701 -0
  178. package/dist/chunk-CCKP5Z6F.js.map +1 -0
  179. package/dist/chunk-CUKM2XUW.js +27 -0
  180. package/dist/{chunk-QCHIQWAJ.js.map → chunk-CUKM2XUW.js.map} +1 -1
  181. package/dist/{chunk-M2RGJPXX.js → chunk-DBD6Q6JH.js} +3 -3
  182. package/dist/{chunk-ZGDVUPTM.js → chunk-EB4RGQO3.js} +2 -2
  183. package/dist/{chunk-PAYXCY6A.js → chunk-G7ESIQTI.js} +12 -14
  184. package/dist/chunk-G7ESIQTI.js.map +1 -0
  185. package/dist/chunk-GPBAZQ23.js +348 -0
  186. package/dist/chunk-GPBAZQ23.js.map +1 -0
  187. package/dist/{chunk-OFADUJWJ.js → chunk-I4LCE5OY.js} +3 -5
  188. package/dist/{chunk-OFADUJWJ.js.map → chunk-I4LCE5OY.js.map} +1 -1
  189. package/dist/{chunk-DFNM3WX2.js → chunk-IMCC6TBN.js} +158 -39
  190. package/dist/chunk-IMCC6TBN.js.map +1 -0
  191. package/dist/{chunk-76WT3HOR.js → chunk-IROZNQAF.js} +22 -21
  192. package/dist/chunk-IROZNQAF.js.map +1 -0
  193. package/dist/{chunk-TAAPQVZN.js → chunk-ISKNULNH.js} +2 -2
  194. package/dist/chunk-J3CWXIPV.js +242 -0
  195. package/dist/chunk-J3CWXIPV.js.map +1 -0
  196. package/dist/{chunk-PYOE4VSI.js → chunk-JBKYRTCS.js} +224 -161
  197. package/dist/chunk-JBKYRTCS.js.map +1 -0
  198. package/dist/{chunk-66ALHVEX.js → chunk-KKIAYH4X.js} +3 -3
  199. package/dist/{chunk-3RMKLXHX.js → chunk-KLDVG3SY.js} +2 -2
  200. package/dist/{chunk-BABLDP24.js → chunk-KSZQYSEH.js} +3 -3
  201. package/dist/chunk-KSZQYSEH.js.map +1 -0
  202. package/dist/{chunk-CW6T36TN.js → chunk-M3M7JFAH.js} +4 -4
  203. package/dist/chunk-M3M7JFAH.js.map +1 -0
  204. package/dist/{chunk-THATMZXD.js → chunk-MLB253V2.js} +2 -2
  205. package/dist/{chunk-THATMZXD.js.map → chunk-MLB253V2.js.map} +1 -1
  206. package/dist/{chunk-JGIWG6SR.js → chunk-MS77U77X.js} +664 -550
  207. package/dist/chunk-MS77U77X.js.map +1 -0
  208. package/dist/chunk-MW4FA3MW.js +23 -0
  209. package/dist/chunk-MW4FA3MW.js.map +1 -0
  210. package/dist/chunk-MYKNINNN.js +228 -0
  211. package/dist/chunk-MYKNINNN.js.map +1 -0
  212. package/dist/{chunk-4CQAV7YB.js → chunk-O6TTQXTY.js} +2 -2
  213. package/dist/{chunk-NBD3KUOZ.js → chunk-OJDJ4VDQ.js} +35 -24
  214. package/dist/chunk-OJDJ4VDQ.js.map +1 -0
  215. package/dist/{chunk-NQZ2OSGR.js → chunk-PVZEMNJY.js} +9 -9
  216. package/dist/chunk-PVZEMNJY.js.map +1 -0
  217. package/dist/chunk-RN26DV2M.js +271 -0
  218. package/dist/chunk-RN26DV2M.js.map +1 -0
  219. package/dist/{chunk-JCXGZRMU.js → chunk-RQQW3IQC.js} +3 -3
  220. package/dist/chunk-RQQW3IQC.js.map +1 -0
  221. package/dist/{chunk-24VULZ7A.js → chunk-TKOGZDD6.js} +3 -3
  222. package/dist/{chunk-EGK3KN7B.js → chunk-TQYLVXGY.js} +70 -39
  223. package/dist/chunk-TQYLVXGY.js.map +1 -0
  224. package/dist/{chunk-QMM6O4CD.js → chunk-UACD2CL2.js} +15 -3
  225. package/dist/{chunk-QMM6O4CD.js.map → chunk-UACD2CL2.js.map} +1 -1
  226. package/dist/{chunk-M3WTHJHJ.js → chunk-VH575UTV.js} +30 -34
  227. package/dist/chunk-VH575UTV.js.map +1 -0
  228. package/dist/{chunk-AUIR5O6W.js → chunk-WWBMC24F.js} +9 -15
  229. package/dist/chunk-WWBMC24F.js.map +1 -0
  230. package/dist/{chunk-JWOYLO27.js → chunk-WYJUJV4L.js} +80 -7
  231. package/dist/chunk-WYJUJV4L.js.map +1 -0
  232. package/dist/{chunk-EY4NZKDR.js → chunk-XFMMPYNU.js} +2 -2
  233. package/dist/chunk-Y4VRBIS6.js +35 -0
  234. package/dist/chunk-Y4VRBIS6.js.map +1 -0
  235. package/dist/{chunk-DMBALCE2.js → chunk-ZC7MSQ5U.js} +77 -4
  236. package/dist/chunk-ZC7MSQ5U.js.map +1 -0
  237. package/dist/{chunk-OGWBVHB3.js → chunk-ZCK6SCOE.js} +67 -8
  238. package/dist/chunk-ZCK6SCOE.js.map +1 -0
  239. package/dist/{chunk-IHVBV5C2.js → chunk-ZTFTABXV.js} +2 -1
  240. package/dist/chunk-ZTFTABXV.js.map +1 -0
  241. package/dist/index.cjs +9532 -5017
  242. package/dist/index.cjs.map +1 -1
  243. package/dist/index.d.cts +163 -27
  244. package/dist/index.d.ts +163 -27
  245. package/dist/index.js +119 -56
  246. package/dist/index.js.map +1 -1
  247. package/dist/{ir-BMP7yxJJ.d.cts → ir-C-Zm_GlZ.d.cts} +1 -1
  248. package/dist/{ir-DUOz6H-5.d.ts → ir-DGyGiwVe.d.ts} +1 -1
  249. package/dist/{module-k7m3txak.d.ts → module-DqQ1U-Me.d.ts} +129 -100
  250. package/dist/{module-B8CBqIZ_.d.cts → module-doenaCsZ.d.cts} +129 -100
  251. package/package.json +12 -1
  252. package/dist/ModuleTag-C8FHY_sY.d.ts +0 -93
  253. package/dist/ModuleTag-EGbgBMpZ.d.cts +0 -93
  254. package/dist/chunk-3QMIVH35.js +0 -43
  255. package/dist/chunk-3QMIVH35.js.map +0 -1
  256. package/dist/chunk-76WT3HOR.js.map +0 -1
  257. package/dist/chunk-AUIR5O6W.js.map +0 -1
  258. package/dist/chunk-BABLDP24.js.map +0 -1
  259. package/dist/chunk-BE3HW4FY.js.map +0 -1
  260. package/dist/chunk-CW6T36TN.js.map +0 -1
  261. package/dist/chunk-DFNM3WX2.js.map +0 -1
  262. package/dist/chunk-DMBALCE2.js.map +0 -1
  263. package/dist/chunk-EGK3KN7B.js.map +0 -1
  264. package/dist/chunk-GMPEOUP2.js.map +0 -1
  265. package/dist/chunk-IHVBV5C2.js.map +0 -1
  266. package/dist/chunk-JCXGZRMU.js.map +0 -1
  267. package/dist/chunk-JGIWG6SR.js.map +0 -1
  268. package/dist/chunk-JWOYLO27.js.map +0 -1
  269. package/dist/chunk-KIXAU3GM.js +0 -137
  270. package/dist/chunk-KIXAU3GM.js.map +0 -1
  271. package/dist/chunk-KP7MUZNX.js.map +0 -1
  272. package/dist/chunk-M3WTHJHJ.js.map +0 -1
  273. package/dist/chunk-M7IYCTJV.js +0 -79
  274. package/dist/chunk-M7IYCTJV.js.map +0 -1
  275. package/dist/chunk-NBD3KUOZ.js.map +0 -1
  276. package/dist/chunk-NQZ2OSGR.js.map +0 -1
  277. package/dist/chunk-OGWBVHB3.js.map +0 -1
  278. package/dist/chunk-PAYXCY6A.js.map +0 -1
  279. package/dist/chunk-PYOE4VSI.js.map +0 -1
  280. package/dist/chunk-QCHIQWAJ.js +0 -21
  281. package/dist/chunk-VZB726PE.js +0 -93
  282. package/dist/chunk-VZB726PE.js.map +0 -1
  283. package/dist/chunk-W3TEWHLO.js +0 -568
  284. package/dist/chunk-W3TEWHLO.js.map +0 -1
  285. package/dist/chunk-ZFLHVFUC.js +0 -192
  286. package/dist/chunk-ZFLHVFUC.js.map +0 -1
  287. package/dist/chunk-ZFY7U2FR.js.map +0 -1
  288. /package/dist/{chunk-G5ZBFPNU.js.map → chunk-2A4UKO2D.js.map} +0 -0
  289. /package/dist/{chunk-ANLBCBDC.js.map → chunk-2DVLMSOE.js.map} +0 -0
  290. /package/dist/{chunk-3TMODYZV.js.map → chunk-3XO4HR6V.js.map} +0 -0
  291. /package/dist/{chunk-TKZ7MEIA.js.map → chunk-53GVPGSM.js.map} +0 -0
  292. /package/dist/{chunk-NZJKFF45.js.map → chunk-C2UZZQ76.js.map} +0 -0
  293. /package/dist/{chunk-M2RGJPXX.js.map → chunk-DBD6Q6JH.js.map} +0 -0
  294. /package/dist/{chunk-ZGDVUPTM.js.map → chunk-EB4RGQO3.js.map} +0 -0
  295. /package/dist/{chunk-TAAPQVZN.js.map → chunk-ISKNULNH.js.map} +0 -0
  296. /package/dist/{chunk-66ALHVEX.js.map → chunk-KKIAYH4X.js.map} +0 -0
  297. /package/dist/{chunk-3RMKLXHX.js.map → chunk-KLDVG3SY.js.map} +0 -0
  298. /package/dist/{chunk-4CQAV7YB.js.map → chunk-O6TTQXTY.js.map} +0 -0
  299. /package/dist/{chunk-24VULZ7A.js.map → chunk-TKOGZDD6.js.map} +0 -0
  300. /package/dist/{chunk-EY4NZKDR.js.map → chunk-XFMMPYNU.js.map} +0 -0
@@ -0,0 +1,701 @@
1
+ import {
2
+ isJsonValue,
3
+ projectJsonValue
4
+ } from "./chunk-WYJUJV4L.js";
5
+ import {
6
+ fnv1a32,
7
+ stableStringify
8
+ } from "./chunk-4MZ7BT3R.js";
9
+
10
+ // src/internal/workflow/errors.ts
11
+ var toJsonValue = (detail) => {
12
+ if (isJsonValue(detail)) return detail;
13
+ return projectJsonValue(detail).value;
14
+ };
15
+ var makeWorkflowError = (args) => {
16
+ const detailJson = args.detail !== void 0 ? toJsonValue(args.detail) : void 0;
17
+ const msg = args.detail !== void 0 ? `${args.message}
18
+ (detail=${stableStringify(detailJson)})` : args.message;
19
+ return Object.assign(new Error(msg), {
20
+ _tag: "WorkflowError",
21
+ code: args.code,
22
+ programId: args.programId,
23
+ source: args.source,
24
+ detail: detailJson
25
+ });
26
+ };
27
+
28
+ // src/internal/workflow/inputExpr.ts
29
+ var decodePointerToken = (raw) => raw.replace(/~1/g, "/").replace(/~0/g, "~");
30
+ var isIndexToken = (token) => token === "0" || !token.startsWith("0") && /^\d+$/.test(token);
31
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
32
+ var parseJsonPointer = (pointer) => {
33
+ if (pointer === "") return [];
34
+ if (!pointer.startsWith("/")) {
35
+ throw makeWorkflowError({
36
+ code: "WORKFLOW_INVALID_JSON_POINTER",
37
+ message: 'Invalid JSON Pointer (must be "" or start with "/").',
38
+ detail: { pointer }
39
+ });
40
+ }
41
+ const raw = pointer.split("/").slice(1);
42
+ const out = [];
43
+ for (const part of raw) {
44
+ const decoded = decodePointerToken(part);
45
+ out.push(isIndexToken(decoded) ? Number(decoded) : decoded);
46
+ }
47
+ return out;
48
+ };
49
+ var compileInputExpr = (expr, pathForError) => {
50
+ switch (expr.kind) {
51
+ case "payload":
52
+ return { kind: "payload" };
53
+ case "payload.path": {
54
+ const pointer = expr.pointer;
55
+ if (typeof pointer !== "string") {
56
+ throw makeWorkflowError({
57
+ code: "WORKFLOW_INVALID_INPUT_EXPR",
58
+ message: "InputExpr.payload.path.pointer must be a string.",
59
+ source: { stepKey: pathForError?.stepKey },
60
+ detail: { pointer }
61
+ });
62
+ }
63
+ return { kind: "payload.path", pointer, tokens: parseJsonPointer(pointer) };
64
+ }
65
+ case "const": {
66
+ const value = expr.value;
67
+ if (!isJsonValue(value)) {
68
+ throw makeWorkflowError({
69
+ code: "WORKFLOW_INVALID_INPUT_EXPR",
70
+ message: "InputExpr.const.value must be JSON-serializable.",
71
+ source: { stepKey: pathForError?.stepKey },
72
+ detail: { value }
73
+ });
74
+ }
75
+ return { kind: "const", value };
76
+ }
77
+ case "object": {
78
+ const fields = expr.fields;
79
+ if (!fields || typeof fields !== "object" || Array.isArray(fields)) {
80
+ throw makeWorkflowError({
81
+ code: "WORKFLOW_INVALID_INPUT_EXPR",
82
+ message: "InputExpr.object.fields must be a record.",
83
+ source: { stepKey: pathForError?.stepKey }
84
+ });
85
+ }
86
+ const entries = Object.entries(fields).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
87
+ return {
88
+ kind: "object",
89
+ fields: entries.map(([k, v]) => [k, compileInputExpr(v, pathForError)])
90
+ };
91
+ }
92
+ case "merge": {
93
+ const items = expr.items;
94
+ if (!Array.isArray(items)) {
95
+ throw makeWorkflowError({
96
+ code: "WORKFLOW_INVALID_INPUT_EXPR",
97
+ message: "InputExpr.merge.items must be an array.",
98
+ source: { stepKey: pathForError?.stepKey }
99
+ });
100
+ }
101
+ for (const item of items) {
102
+ const kind = isRecord(item) ? item.kind : void 0;
103
+ if (kind !== "object") {
104
+ throw makeWorkflowError({
105
+ code: "WORKFLOW_INVALID_MERGE_ITEMS",
106
+ message: "InputExpr.merge.items must all be InputExpr.object.",
107
+ source: { stepKey: pathForError?.stepKey },
108
+ detail: { kind }
109
+ });
110
+ }
111
+ }
112
+ return {
113
+ kind: "merge",
114
+ items: items.map((i) => compileInputExpr(i, pathForError))
115
+ };
116
+ }
117
+ }
118
+ };
119
+ var isPlainRecord = (value) => {
120
+ if (typeof value !== "object" || value === null) return false;
121
+ if (Array.isArray(value)) return false;
122
+ const proto = Object.getPrototypeOf(value);
123
+ return proto === Object.prototype || proto === null;
124
+ };
125
+ var evalPointer = (root, tokens) => {
126
+ let current = root;
127
+ for (const token of tokens) {
128
+ if (current == null) return void 0;
129
+ if (Array.isArray(current) && typeof token === "number") {
130
+ current = current[token];
131
+ continue;
132
+ }
133
+ if (typeof current !== "object") return void 0;
134
+ const key = typeof token === "number" ? String(token) : token;
135
+ current = current[key];
136
+ }
137
+ return current;
138
+ };
139
+ var evalInputExpr = (expr, payload) => {
140
+ switch (expr.kind) {
141
+ case "payload":
142
+ return payload;
143
+ case "payload.path":
144
+ return evalPointer(payload, expr.tokens);
145
+ case "const":
146
+ return expr.value;
147
+ case "object": {
148
+ const out = {};
149
+ for (const [k, v] of expr.fields) {
150
+ out[k] = evalInputExpr(v, payload);
151
+ }
152
+ return out;
153
+ }
154
+ case "merge": {
155
+ const out = {};
156
+ for (const item of expr.items) {
157
+ const value = evalInputExpr(item, payload);
158
+ if (isPlainRecord(value)) {
159
+ for (const [k, v] of Object.entries(value)) {
160
+ out[k] = v;
161
+ }
162
+ }
163
+ }
164
+ return out;
165
+ }
166
+ }
167
+ };
168
+
169
+ // src/internal/workflow/compiler.ts
170
+ var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
171
+ var asNonEmptyString = (value) => typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
172
+ var asNonNegInt = (value) => {
173
+ if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
174
+ const n = Math.floor(value);
175
+ return n >= 0 ? n : void 0;
176
+ };
177
+ var asPosInt = (value) => {
178
+ if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
179
+ const n = Math.floor(value);
180
+ return n > 0 ? n : void 0;
181
+ };
182
+ var normalizeWorkflowDefV1 = (input) => {
183
+ const normalizeStep = (step) => {
184
+ if (!isRecord2(step)) return step;
185
+ if (step.kind !== "call") return step;
186
+ const raw = step;
187
+ const onSuccessRaw = Array.isArray(raw.onSuccess) ? raw.onSuccess : [];
188
+ const onFailureRaw = Array.isArray(raw.onFailure) ? raw.onFailure : [];
189
+ return {
190
+ ...step,
191
+ onSuccess: onSuccessRaw.map(normalizeStep),
192
+ onFailure: onFailureRaw.map(normalizeStep)
193
+ };
194
+ };
195
+ const normalizeSteps = (steps) => steps.map(normalizeStep);
196
+ return {
197
+ ...input,
198
+ steps: normalizeSteps(input.steps)
199
+ };
200
+ };
201
+ function validateWorkflowDefV1(def, options) {
202
+ if (!isRecord2(def)) {
203
+ throw makeWorkflowError({
204
+ code: "WORKFLOW_INVALID_DEF",
205
+ message: "WorkflowDef must be an object.",
206
+ detail: { def }
207
+ });
208
+ }
209
+ if (def.astVersion !== 1) {
210
+ throw makeWorkflowError({
211
+ code: "WORKFLOW_UNSUPPORTED_VERSION",
212
+ message: "Unsupported workflow astVersion.",
213
+ detail: { astVersion: def.astVersion }
214
+ });
215
+ }
216
+ if (!asNonEmptyString(def.localId)) {
217
+ throw makeWorkflowError({
218
+ code: "WORKFLOW_INVALID_DEF",
219
+ message: "WorkflowDef.localId must be a non-empty string.",
220
+ detail: { localId: def.localId }
221
+ });
222
+ }
223
+ const trigger = def.trigger;
224
+ if (!isRecord2(trigger)) {
225
+ throw makeWorkflowError({
226
+ code: "WORKFLOW_INVALID_TRIGGER",
227
+ message: "Workflow trigger must be an object.",
228
+ detail: { trigger }
229
+ });
230
+ }
231
+ if (trigger.kind === "action") {
232
+ if (!asNonEmptyString(trigger.actionTag)) {
233
+ throw makeWorkflowError({
234
+ code: "WORKFLOW_INVALID_TRIGGER",
235
+ message: "Workflow trigger.actionTag must be a non-empty string.",
236
+ detail: { trigger }
237
+ });
238
+ }
239
+ } else if (trigger.kind === "lifecycle") {
240
+ const phase = trigger.phase;
241
+ if (phase !== "onStart" && phase !== "onInit") {
242
+ throw makeWorkflowError({
243
+ code: "WORKFLOW_INVALID_TRIGGER",
244
+ message: 'Workflow trigger.phase must be "onStart" or "onInit".',
245
+ detail: { trigger }
246
+ });
247
+ }
248
+ } else {
249
+ throw makeWorkflowError({
250
+ code: "WORKFLOW_INVALID_TRIGGER",
251
+ message: 'Workflow trigger.kind must be "action" or "lifecycle".',
252
+ detail: { trigger }
253
+ });
254
+ }
255
+ if (!Array.isArray(def.steps)) {
256
+ throw makeWorkflowError({
257
+ code: "WORKFLOW_INVALID_DEF",
258
+ message: "WorkflowDef.steps must be an array.",
259
+ detail: { steps: def.steps }
260
+ });
261
+ }
262
+ const seenKeys = /* @__PURE__ */ new Set();
263
+ const visit = (step, fragmentId) => {
264
+ if (!isRecord2(step)) {
265
+ throw makeWorkflowError({
266
+ code: "WORKFLOW_INVALID_STEP",
267
+ message: "Workflow step must be an object.",
268
+ detail: { step },
269
+ source: fragmentId ? { fragmentId } : void 0
270
+ });
271
+ }
272
+ const key = asNonEmptyString(step.key);
273
+ if (!key) {
274
+ throw makeWorkflowError({
275
+ code: "WORKFLOW_INVALID_STEP",
276
+ message: "Workflow step.key must be a non-empty string.",
277
+ detail: { stepKey: step.key, kind: step.kind },
278
+ source: fragmentId ? { fragmentId } : void 0
279
+ });
280
+ }
281
+ if (seenKeys.has(key)) {
282
+ throw makeWorkflowError({
283
+ code: "WORKFLOW_DUPLICATE_STEP_KEY",
284
+ message: `Duplicate stepKey "${key}" detected.`,
285
+ detail: { duplicateKey: key },
286
+ source: { stepKey: key, ...fragmentId ? { fragmentId } : null }
287
+ });
288
+ }
289
+ seenKeys.add(key);
290
+ if (step.kind === "dispatch") {
291
+ if (!asNonEmptyString(step.actionTag)) {
292
+ throw makeWorkflowError({
293
+ code: "WORKFLOW_INVALID_STEP",
294
+ message: "dispatch.actionTag must be a non-empty string.",
295
+ source: { stepKey: key, ...fragmentId ? { fragmentId } : null },
296
+ detail: { actionTag: step.actionTag }
297
+ });
298
+ }
299
+ const payload = step.payload;
300
+ if (payload !== void 0) {
301
+ validateInputExpr(payload, { stepKey: key });
302
+ }
303
+ return;
304
+ }
305
+ if (step.kind === "delay") {
306
+ const ms = asNonNegInt(step.ms);
307
+ if (ms === void 0) {
308
+ throw makeWorkflowError({
309
+ code: "WORKFLOW_INVALID_STEP",
310
+ message: "delay.ms must be a non-negative integer.",
311
+ source: { stepKey: key, ...fragmentId ? { fragmentId } : null },
312
+ detail: { ms: step.ms }
313
+ });
314
+ }
315
+ return;
316
+ }
317
+ if (step.kind === "call") {
318
+ if (!asNonEmptyString(step.serviceId)) {
319
+ throw makeWorkflowError({
320
+ code: "WORKFLOW_INVALID_SERVICE_ID",
321
+ message: "call.serviceId must be a non-empty string.",
322
+ source: { stepKey: key, ...fragmentId ? { fragmentId } : null },
323
+ detail: { serviceId: step.serviceId }
324
+ });
325
+ }
326
+ const inputExpr = step.input;
327
+ if (inputExpr !== void 0) {
328
+ validateInputExpr(inputExpr, { stepKey: key });
329
+ }
330
+ const timeoutMsRaw = step.timeoutMs;
331
+ if (timeoutMsRaw !== void 0 && asPosInt(timeoutMsRaw) === void 0) {
332
+ throw makeWorkflowError({
333
+ code: "WORKFLOW_INVALID_STEP",
334
+ message: "call.timeoutMs must be a positive integer (milliseconds).",
335
+ source: { stepKey: key, ...fragmentId ? { fragmentId } : null },
336
+ detail: { timeoutMs: timeoutMsRaw }
337
+ });
338
+ }
339
+ const retryRaw = step.retry;
340
+ if (retryRaw !== void 0) {
341
+ const times = isRecord2(retryRaw) ? asPosInt(retryRaw.times) : void 0;
342
+ if (times === void 0) {
343
+ throw makeWorkflowError({
344
+ code: "WORKFLOW_INVALID_STEP",
345
+ message: "call.retry.times must be a positive integer.",
346
+ source: { stepKey: key, ...fragmentId ? { fragmentId } : null },
347
+ detail: { retry: retryRaw }
348
+ });
349
+ }
350
+ }
351
+ const onSuccess = Array.isArray(step.onSuccess) ? step.onSuccess : [];
352
+ const onFailure = Array.isArray(step.onFailure) ? step.onFailure : [];
353
+ for (const inner of onSuccess) visit(inner, fragmentId);
354
+ for (const inner of onFailure) visit(inner, fragmentId);
355
+ return;
356
+ }
357
+ throw makeWorkflowError({
358
+ code: "WORKFLOW_INVALID_STEP",
359
+ message: "Unknown step kind.",
360
+ source: { stepKey: key, ...fragmentId ? { fragmentId } : null },
361
+ detail: { kind: step.kind }
362
+ });
363
+ };
364
+ const sources = def.sources;
365
+ const fragmentByStepKey = /* @__PURE__ */ new Map();
366
+ if (sources && typeof sources === "object") {
367
+ for (const [k, v] of Object.entries(sources)) {
368
+ fragmentByStepKey.set(k, isRecord2(v) ? asNonEmptyString(v.fragmentId) : void 0);
369
+ }
370
+ }
371
+ for (const step of def.steps) {
372
+ const key = isRecord2(step) ? asNonEmptyString(step.key) : void 0;
373
+ const fragmentId = key ? fragmentByStepKey.get(key) : void 0;
374
+ visit(step, fragmentId);
375
+ }
376
+ const generator = isRecord2(def.meta) ? def.meta.generator : void 0;
377
+ if (generator !== void 0 && !isJsonValue(generator)) {
378
+ throw makeWorkflowError({
379
+ code: "WORKFLOW_INVALID_DEF",
380
+ message: "WorkflowDef.meta.generator must be JSON-serializable.",
381
+ detail: { generator }
382
+ });
383
+ }
384
+ const policy = isRecord2(def.policy) ? def.policy : void 0;
385
+ if (policy) {
386
+ const concurrency = policy.concurrency;
387
+ if (concurrency !== void 0 && concurrency !== "latest" && concurrency !== "exhaust" && concurrency !== "parallel") {
388
+ throw makeWorkflowError({
389
+ code: "WORKFLOW_INVALID_DEF",
390
+ message: "policy.concurrency must be latest|exhaust|parallel.",
391
+ detail: { concurrency }
392
+ });
393
+ }
394
+ const priority = policy.priority;
395
+ if (priority !== void 0 && priority !== "urgent" && priority !== "nonUrgent") {
396
+ throw makeWorkflowError({
397
+ code: "WORKFLOW_INVALID_DEF",
398
+ message: "policy.priority must be urgent|nonUrgent.",
399
+ detail: { priority }
400
+ });
401
+ }
402
+ }
403
+ void options?.moduleId;
404
+ }
405
+ var validateInputExpr = (expr, options) => {
406
+ const visit = (e) => {
407
+ if (!isRecord2(e)) {
408
+ throw makeWorkflowError({
409
+ code: "WORKFLOW_INVALID_INPUT_EXPR",
410
+ message: "InputExpr must be an object.",
411
+ source: { stepKey: options?.stepKey },
412
+ detail: { expr: e }
413
+ });
414
+ }
415
+ const kind = e.kind;
416
+ switch (kind) {
417
+ case "payload":
418
+ return;
419
+ case "payload.path": {
420
+ const pointer = e.pointer;
421
+ if (typeof pointer !== "string") {
422
+ throw makeWorkflowError({
423
+ code: "WORKFLOW_INVALID_INPUT_EXPR",
424
+ message: "InputExpr.payload.path.pointer must be a string.",
425
+ source: { stepKey: options?.stepKey },
426
+ detail: { pointer }
427
+ });
428
+ }
429
+ return;
430
+ }
431
+ case "const": {
432
+ const value = e.value;
433
+ if (!isJsonValue(value)) {
434
+ throw makeWorkflowError({
435
+ code: "WORKFLOW_INVALID_INPUT_EXPR",
436
+ message: "InputExpr.const.value must be JSON-serializable.",
437
+ source: { stepKey: options?.stepKey }
438
+ });
439
+ }
440
+ return;
441
+ }
442
+ case "object": {
443
+ const fields = e.fields;
444
+ if (!isRecord2(fields)) {
445
+ throw makeWorkflowError({
446
+ code: "WORKFLOW_INVALID_INPUT_EXPR",
447
+ message: "InputExpr.object.fields must be a record.",
448
+ source: { stepKey: options?.stepKey }
449
+ });
450
+ }
451
+ for (const v of Object.values(fields)) {
452
+ visit(v);
453
+ }
454
+ return;
455
+ }
456
+ case "merge": {
457
+ const items = e.items;
458
+ if (!Array.isArray(items)) {
459
+ throw makeWorkflowError({
460
+ code: "WORKFLOW_INVALID_INPUT_EXPR",
461
+ message: "InputExpr.merge.items must be an array.",
462
+ source: { stepKey: options?.stepKey }
463
+ });
464
+ }
465
+ for (const item of items) {
466
+ visit(item);
467
+ }
468
+ return;
469
+ }
470
+ default:
471
+ throw makeWorkflowError({
472
+ code: "WORKFLOW_INVALID_INPUT_EXPR",
473
+ message: "Unknown InputExpr kind.",
474
+ source: { stepKey: options?.stepKey },
475
+ detail: { kind }
476
+ });
477
+ }
478
+ };
479
+ visit(expr);
480
+ };
481
+ var makeDigest = (prefix, value) => `${prefix}:${fnv1a32(stableStringify(value))}`;
482
+ var makeTriggerNodeId = (programId) => `wf_trigger_v1:${fnv1a32(programId)}`;
483
+ var makeStepNodeId = (programId, stepKey, kind) => `wf_node_v1:${fnv1a32(`${programId}\0${stepKey}\0${kind}`)}`;
484
+ var budgetJsonValue = (value) => projectJsonValue(value).value;
485
+ var budgetInputExpr = (expr) => {
486
+ switch (expr.kind) {
487
+ case "payload":
488
+ case "payload.path":
489
+ return expr;
490
+ case "const": {
491
+ const value = expr.value;
492
+ if (!isJsonValue(value)) return expr;
493
+ return { ...expr, value: budgetJsonValue(expr.value) };
494
+ }
495
+ case "object": {
496
+ const out = {};
497
+ for (const k of Object.keys(expr.fields).sort()) {
498
+ out[k] = budgetInputExpr(expr.fields[k]);
499
+ }
500
+ return { ...expr, fields: out };
501
+ }
502
+ case "merge":
503
+ return { ...expr, items: expr.items.map(budgetInputExpr) };
504
+ }
505
+ };
506
+ var toStaticStep = (step) => {
507
+ switch (step.kind) {
508
+ case "dispatch":
509
+ return {
510
+ kind: "dispatch",
511
+ actionTag: step.actionTag,
512
+ ...step.payload ? { payload: budgetInputExpr(step.payload) } : null
513
+ };
514
+ case "delay":
515
+ return { kind: "delay", ms: step.ms };
516
+ case "call": {
517
+ const policy = step.timeoutMs !== void 0 || step.retry !== void 0 ? {
518
+ ...step.timeoutMs !== void 0 ? { timeoutMs: step.timeoutMs } : null,
519
+ ...step.retry !== void 0 ? { retry: { times: step.retry.times } } : null
520
+ } : void 0;
521
+ return {
522
+ kind: "call",
523
+ serviceId: step.serviceId,
524
+ ...step.input ? { input: budgetInputExpr(step.input) } : null,
525
+ ...policy ? { policy } : null
526
+ };
527
+ }
528
+ }
529
+ };
530
+ var compileWorkflowStaticIrV1 = (args) => {
531
+ const normalized = normalizeWorkflowDefV1(args.def);
532
+ validateWorkflowDefV1(normalized, { moduleId: args.moduleId });
533
+ const programId = `${args.moduleId}.${normalized.localId}`;
534
+ const triggerNodeId = makeTriggerNodeId(programId);
535
+ const fragmentByStepKey = /* @__PURE__ */ new Map();
536
+ if (normalized.sources && typeof normalized.sources === "object") {
537
+ for (const [k, v] of Object.entries(normalized.sources)) {
538
+ fragmentByStepKey.set(k, isRecord2(v) ? asNonEmptyString(v.fragmentId) : void 0);
539
+ }
540
+ }
541
+ const nodesByKey = /* @__PURE__ */ new Map();
542
+ const collectNodes = (steps) => {
543
+ for (const step of steps) {
544
+ const id = makeStepNodeId(programId, step.key, step.kind);
545
+ nodesByKey.set(step.key, id);
546
+ if (step.kind === "call") {
547
+ collectNodes(step.onSuccess);
548
+ collectNodes(step.onFailure);
549
+ }
550
+ }
551
+ };
552
+ collectNodes(normalized.steps);
553
+ const nodes = [
554
+ {
555
+ id: triggerNodeId,
556
+ kind: "trigger",
557
+ trigger: normalized.trigger
558
+ }
559
+ ];
560
+ const addStepNodes = (steps) => {
561
+ for (const step of steps) {
562
+ const id = nodesByKey.get(step.key);
563
+ if (!id) continue;
564
+ const fragmentId = fragmentByStepKey.get(step.key);
565
+ nodes.push({
566
+ id,
567
+ kind: "step",
568
+ step: toStaticStep(step),
569
+ source: {
570
+ stepKey: step.key,
571
+ ...fragmentId ? { fragmentId } : null
572
+ }
573
+ });
574
+ if (step.kind === "call") {
575
+ addStepNodes(step.onSuccess);
576
+ addStepNodes(step.onFailure);
577
+ }
578
+ }
579
+ };
580
+ addStepNodes(normalized.steps);
581
+ const edges = [];
582
+ const pushEdge = (from, to, kind) => {
583
+ edges.push({ from, to, kind });
584
+ };
585
+ const compileBlock = (args2) => {
586
+ if (args2.steps.length === 0) {
587
+ if (args2.continuation) {
588
+ for (const from of args2.entryFrom) {
589
+ pushEdge(from, args2.continuation, args2.entryKind);
590
+ }
591
+ }
592
+ return;
593
+ }
594
+ const first = args2.steps[0];
595
+ const firstId = nodesByKey.get(first.key);
596
+ if (!firstId) {
597
+ throw makeWorkflowError({
598
+ code: "WORKFLOW_INVALID_STEP",
599
+ message: "Internal error: missing node id for stepKey.",
600
+ programId,
601
+ source: { stepKey: first.key }
602
+ });
603
+ }
604
+ for (const from of args2.entryFrom) {
605
+ pushEdge(from, firstId, args2.entryKind);
606
+ }
607
+ const compileStepAndTail = (step, tail, continuation) => {
608
+ const stepId = nodesByKey.get(step.key);
609
+ if (!stepId) return;
610
+ if (step.kind !== "call") {
611
+ compileBlock({ steps: tail, entryFrom: [stepId], entryKind: "next", continuation });
612
+ return;
613
+ }
614
+ const cont = tail.length > 0 ? nodesByKey.get(tail[0].key) : continuation;
615
+ compileBlock({
616
+ steps: step.onSuccess,
617
+ entryFrom: [stepId],
618
+ entryKind: "success",
619
+ continuation: cont
620
+ });
621
+ compileBlock({
622
+ steps: step.onFailure,
623
+ entryFrom: [stepId],
624
+ entryKind: "failure",
625
+ continuation: cont
626
+ });
627
+ compileBlock({ steps: tail, entryFrom: [], entryKind: "next", continuation });
628
+ };
629
+ compileStepAndTail(first, args2.steps.slice(1), args2.continuation);
630
+ };
631
+ compileBlock({ steps: normalized.steps, entryFrom: [triggerNodeId], entryKind: "next", continuation: void 0 });
632
+ nodes.sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
633
+ edges.sort((a, b) => {
634
+ if (a.from !== b.from) return a.from < b.from ? -1 : 1;
635
+ if (a.to !== b.to) return a.to < b.to ? -1 : 1;
636
+ const ak = String(a.kind ?? "");
637
+ const bk = String(b.kind ?? "");
638
+ if (ak !== bk) return ak < bk ? -1 : 1;
639
+ return 0;
640
+ });
641
+ const meta = (() => {
642
+ const generator = normalized.meta?.generator;
643
+ if (generator === void 0) return void 0;
644
+ return { generator: budgetJsonValue(generator) };
645
+ })();
646
+ const irNoDigest = {
647
+ version: 1,
648
+ programId,
649
+ nodes,
650
+ edges,
651
+ policy: normalized.policy,
652
+ meta
653
+ };
654
+ const digest = makeDigest("workflow_ir_v1", irNoDigest);
655
+ return {
656
+ ...irNoDigest,
657
+ digest
658
+ };
659
+ };
660
+ var compileWorkflowRuntimeStepsV1 = (args) => {
661
+ const normalized = normalizeWorkflowDefV1(args.def);
662
+ validateWorkflowDefV1(normalized);
663
+ const compileStep = (step) => {
664
+ const stepKey = step.key;
665
+ switch (step.kind) {
666
+ case "dispatch":
667
+ return {
668
+ kind: "dispatch",
669
+ key: step.key,
670
+ actionTag: step.actionTag,
671
+ ...step.payload ? { payload: compileInputExpr(step.payload, { stepKey }) } : null
672
+ };
673
+ case "delay":
674
+ return { kind: "delay", key: step.key, ms: step.ms };
675
+ case "call": {
676
+ const retryTimes = step.retry?.times;
677
+ return {
678
+ kind: "call",
679
+ key: step.key,
680
+ serviceId: step.serviceId,
681
+ ...step.input ? { input: compileInputExpr(step.input, { stepKey }) } : null,
682
+ ...step.timeoutMs !== void 0 ? { timeoutMs: step.timeoutMs } : null,
683
+ ...retryTimes !== void 0 ? { retryTimes } : null,
684
+ onSuccess: step.onSuccess.map(compileStep),
685
+ onFailure: step.onFailure.map(compileStep)
686
+ };
687
+ }
688
+ }
689
+ };
690
+ return normalized.steps.map(compileStep);
691
+ };
692
+
693
+ export {
694
+ makeWorkflowError,
695
+ evalInputExpr,
696
+ normalizeWorkflowDefV1,
697
+ validateWorkflowDefV1,
698
+ compileWorkflowStaticIrV1,
699
+ compileWorkflowRuntimeStepsV1
700
+ };
701
+ //# sourceMappingURL=chunk-CCKP5Z6F.js.map