@powerhousedao/workflow 6.2.3-dev.100

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 (859) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +143 -0
  3. package/dist/browser/BlockSelector-CEdYUqjx.js +3371 -0
  4. package/dist/browser/BlockSelector-CEdYUqjx.js.map +1 -0
  5. package/dist/browser/PieceMarkdown-DSdZd-Jc.js +92 -0
  6. package/dist/browser/PieceMarkdown-DSdZd-Jc.js.map +1 -0
  7. package/dist/browser/connection-form-Biksq2jW.js +1524 -0
  8. package/dist/browser/connection-form-Biksq2jW.js.map +1 -0
  9. package/dist/browser/connection-ilYFCRUK.js +90 -0
  10. package/dist/browser/connection-ilYFCRUK.js.map +1 -0
  11. package/dist/browser/data-tree-Cq-s6bJp.js +76 -0
  12. package/dist/browser/data-tree-Cq-s6bJp.js.map +1 -0
  13. package/dist/browser/document-models/connection/index.js +3 -0
  14. package/dist/browser/document-models/index.js +4 -0
  15. package/dist/browser/document-models/workflow/index.js +3 -0
  16. package/dist/browser/document-models-C2SAP1SX.js +164 -0
  17. package/dist/browser/document-models-C2SAP1SX.js.map +1 -0
  18. package/dist/browser/editor-CIqKi7XK.js +3219 -0
  19. package/dist/browser/editor-CIqKi7XK.js.map +1 -0
  20. package/dist/browser/editor-DYjoPfta.js +4669 -0
  21. package/dist/browser/editor-DYjoPfta.js.map +1 -0
  22. package/dist/browser/editor-GeRXGdie.js +373 -0
  23. package/dist/browser/editor-GeRXGdie.js.map +1 -0
  24. package/dist/browser/editors/connection-editor/module.js +15 -0
  25. package/dist/browser/editors/connection-editor/module.js.map +1 -0
  26. package/dist/browser/editors/index.js +4 -0
  27. package/dist/browser/editors/runtime/index.js +2 -0
  28. package/dist/browser/editors/workflow-editor/module.js +15 -0
  29. package/dist/browser/editors/workflow-editor/module.js.map +1 -0
  30. package/dist/browser/editors/workflow-studio/module.js +15 -0
  31. package/dist/browser/editors/workflow-studio/module.js.map +1 -0
  32. package/dist/browser/index.js +463 -0
  33. package/dist/browser/index.js.map +1 -0
  34. package/dist/browser/module-DJz6oTX0.js +690 -0
  35. package/dist/browser/module-DJz6oTX0.js.map +1 -0
  36. package/dist/browser/module-mFCt9WHJ.js +1799 -0
  37. package/dist/browser/module-mFCt9WHJ.js.map +1 -0
  38. package/dist/browser/piece-auth-63iuNFTs.js +154 -0
  39. package/dist/browser/piece-auth-63iuNFTs.js.map +1 -0
  40. package/dist/browser/reactor/index.js +8 -0
  41. package/dist/browser/reactor/index.js.map +1 -0
  42. package/dist/browser/rolldown-runtime-D7D4PA-g.js +13 -0
  43. package/dist/browser/runtime-queries-FmEzElOY.js +993 -0
  44. package/dist/browser/runtime-queries-FmEzElOY.js.map +1 -0
  45. package/dist/browser/style.css +667 -0
  46. package/dist/browser/trigger-text-DH6HIeoa.js +3210 -0
  47. package/dist/browser/trigger-text-DH6HIeoa.js.map +1 -0
  48. package/dist/browser/upgrade-manifests-C2Qa6myy.js +8 -0
  49. package/dist/browser/upgrade-manifests-C2Qa6myy.js.map +1 -0
  50. package/dist/browser/workflow-2gR2JXUS.js +109 -0
  51. package/dist/browser/workflow-2gR2JXUS.js.map +1 -0
  52. package/dist/node/document-models/connection/index.mjs +67 -0
  53. package/dist/node/document-models/connection/index.mjs.map +1 -0
  54. package/dist/node/document-models/index.mjs +4 -0
  55. package/dist/node/document-models/workflow/index.mjs +86 -0
  56. package/dist/node/document-models/workflow/index.mjs.map +1 -0
  57. package/dist/node/editors/index.mjs +6 -0
  58. package/dist/node/editors/index.mjs.map +1 -0
  59. package/dist/node/index.mjs +174 -0
  60. package/dist/node/index.mjs.map +1 -0
  61. package/dist/node/module-BXKUB58R.mjs +1804 -0
  62. package/dist/node/module-BXKUB58R.mjs.map +1 -0
  63. package/dist/node/module-CaBtkQmd.mjs +690 -0
  64. package/dist/node/module-CaBtkQmd.mjs.map +1 -0
  65. package/dist/node/pieces/ai/descriptor.json +857 -0
  66. package/dist/node/pieces/ai/index.mjs +624 -0
  67. package/dist/node/pieces/ai/package.json +9 -0
  68. package/dist/node/pieces/index.mjs +12 -0
  69. package/dist/node/pieces/index.mjs.map +1 -0
  70. package/dist/node/pieces/reactor/descriptor.json +648 -0
  71. package/dist/node/pieces/reactor/index.mjs +59 -0
  72. package/dist/node/pieces/reactor/package.json +9 -0
  73. package/dist/node/rolldown-runtime-D7D4PA-g.mjs +13 -0
  74. package/dist/node/upgrade-manifests-BCCpSD1J.mjs +8 -0
  75. package/dist/node/upgrade-manifests-BCCpSD1J.mjs.map +1 -0
  76. package/dist/powerhouse.manifest.json +175 -0
  77. package/dist/style.css +670 -0
  78. package/dist/types/ai/runtime.d.ts +13 -0
  79. package/dist/types/ai/runtime.d.ts.map +1 -0
  80. package/dist/types/ai/tools.d.ts +65 -0
  81. package/dist/types/ai/tools.d.ts.map +1 -0
  82. package/dist/types/ai/tools.test.d.ts +2 -0
  83. package/dist/types/ai/tools.test.d.ts.map +1 -0
  84. package/dist/types/ai/workflow-tools.d.ts +9 -0
  85. package/dist/types/ai/workflow-tools.d.ts.map +1 -0
  86. package/dist/types/ai/workflow-tools.live.test.d.ts +2 -0
  87. package/dist/types/ai/workflow-tools.live.test.d.ts.map +1 -0
  88. package/dist/types/ai/workflow-tools.test.d.ts +2 -0
  89. package/dist/types/ai/workflow-tools.test.d.ts.map +1 -0
  90. package/dist/types/build.d.ts +2 -0
  91. package/dist/types/build.d.ts.map +1 -0
  92. package/dist/types/document-models/connection/index.d.ts +3 -0
  93. package/dist/types/document-models/connection/index.d.ts.map +1 -0
  94. package/dist/types/document-models/connection/upgrades/index.d.ts +3 -0
  95. package/dist/types/document-models/connection/upgrades/index.d.ts.map +1 -0
  96. package/dist/types/document-models/connection/upgrades/upgrade-manifest.d.ts +8 -0
  97. package/dist/types/document-models/connection/upgrades/upgrade-manifest.d.ts.map +1 -0
  98. package/dist/types/document-models/connection/upgrades/versions.d.ts +3 -0
  99. package/dist/types/document-models/connection/upgrades/versions.d.ts.map +1 -0
  100. package/dist/types/document-models/connection/v1/actions.d.ts +19 -0
  101. package/dist/types/document-models/connection/v1/actions.d.ts.map +1 -0
  102. package/dist/types/document-models/connection/v1/gen/actions.d.ts +12 -0
  103. package/dist/types/document-models/connection/v1/gen/actions.d.ts.map +1 -0
  104. package/dist/types/document-models/connection/v1/gen/config/actions.d.ts +28 -0
  105. package/dist/types/document-models/connection/v1/gen/config/actions.d.ts.map +1 -0
  106. package/dist/types/document-models/connection/v1/gen/config/creators.d.ts +8 -0
  107. package/dist/types/document-models/connection/v1/gen/config/creators.d.ts.map +1 -0
  108. package/dist/types/document-models/connection/v1/gen/config/error.d.ts +42 -0
  109. package/dist/types/document-models/connection/v1/gen/config/error.d.ts.map +1 -0
  110. package/dist/types/document-models/connection/v1/gen/config/operations.d.ts +15 -0
  111. package/dist/types/document-models/connection/v1/gen/config/operations.d.ts.map +1 -0
  112. package/dist/types/document-models/connection/v1/gen/connection/actions.d.ts +20 -0
  113. package/dist/types/document-models/connection/v1/gen/connection/actions.d.ts.map +1 -0
  114. package/dist/types/document-models/connection/v1/gen/connection/creators.d.ts +6 -0
  115. package/dist/types/document-models/connection/v1/gen/connection/creators.d.ts.map +1 -0
  116. package/dist/types/document-models/connection/v1/gen/connection/error.d.ts +14 -0
  117. package/dist/types/document-models/connection/v1/gen/connection/error.d.ts.map +1 -0
  118. package/dist/types/document-models/connection/v1/gen/connection/operations.d.ts +13 -0
  119. package/dist/types/document-models/connection/v1/gen/connection/operations.d.ts.map +1 -0
  120. package/dist/types/document-models/connection/v1/gen/controller.d.ts +8 -0
  121. package/dist/types/document-models/connection/v1/gen/controller.d.ts.map +1 -0
  122. package/dist/types/document-models/connection/v1/gen/creators.d.ts +11 -0
  123. package/dist/types/document-models/connection/v1/gen/creators.d.ts.map +1 -0
  124. package/dist/types/document-models/connection/v1/gen/document-model.d.ts +3 -0
  125. package/dist/types/document-models/connection/v1/gen/document-model.d.ts.map +1 -0
  126. package/dist/types/document-models/connection/v1/gen/document-schema.d.ts +68 -0
  127. package/dist/types/document-models/connection/v1/gen/document-schema.d.ts.map +1 -0
  128. package/dist/types/document-models/connection/v1/gen/document-type.d.ts +6 -0
  129. package/dist/types/document-models/connection/v1/gen/document-type.d.ts.map +1 -0
  130. package/dist/types/document-models/connection/v1/gen/health/actions.d.ts +12 -0
  131. package/dist/types/document-models/connection/v1/gen/health/actions.d.ts.map +1 -0
  132. package/dist/types/document-models/connection/v1/gen/health/creators.d.ts +4 -0
  133. package/dist/types/document-models/connection/v1/gen/health/creators.d.ts.map +1 -0
  134. package/dist/types/document-models/connection/v1/gen/health/error.d.ts +2 -0
  135. package/dist/types/document-models/connection/v1/gen/health/error.d.ts.map +1 -0
  136. package/dist/types/document-models/connection/v1/gen/health/operations.d.ts +11 -0
  137. package/dist/types/document-models/connection/v1/gen/health/operations.d.ts.map +1 -0
  138. package/dist/types/document-models/connection/v1/gen/index.d.ts +19 -0
  139. package/dist/types/document-models/connection/v1/gen/index.d.ts.map +1 -0
  140. package/dist/types/document-models/connection/v1/gen/ph-factories.d.ts +25 -0
  141. package/dist/types/document-models/connection/v1/gen/ph-factories.d.ts.map +1 -0
  142. package/dist/types/document-models/connection/v1/gen/reducer.d.ts +4 -0
  143. package/dist/types/document-models/connection/v1/gen/reducer.d.ts.map +1 -0
  144. package/dist/types/document-models/connection/v1/gen/schema/index.d.ts +7 -0
  145. package/dist/types/document-models/connection/v1/gen/schema/index.d.ts.map +1 -0
  146. package/dist/types/document-models/connection/v1/gen/schema/types.d.ts +216 -0
  147. package/dist/types/document-models/connection/v1/gen/schema/types.d.ts.map +1 -0
  148. package/dist/types/document-models/connection/v1/gen/schema/zod.d.ts +37 -0
  149. package/dist/types/document-models/connection/v1/gen/schema/zod.d.ts.map +1 -0
  150. package/dist/types/document-models/connection/v1/gen/types.d.ts +16 -0
  151. package/dist/types/document-models/connection/v1/gen/types.d.ts.map +1 -0
  152. package/dist/types/document-models/connection/v1/gen/utils.d.ts +10 -0
  153. package/dist/types/document-models/connection/v1/gen/utils.d.ts.map +1 -0
  154. package/dist/types/document-models/connection/v1/hooks.d.ts +18 -0
  155. package/dist/types/document-models/connection/v1/hooks.d.ts.map +1 -0
  156. package/dist/types/document-models/connection/v1/index.d.ts +11 -0
  157. package/dist/types/document-models/connection/v1/index.d.ts.map +1 -0
  158. package/dist/types/document-models/connection/v1/module.d.ts +26 -0
  159. package/dist/types/document-models/connection/v1/module.d.ts.map +1 -0
  160. package/dist/types/document-models/connection/v1/src/index.d.ts +6 -0
  161. package/dist/types/document-models/connection/v1/src/index.d.ts.map +1 -0
  162. package/dist/types/document-models/connection/v1/src/reactor-connection.d.ts +17 -0
  163. package/dist/types/document-models/connection/v1/src/reactor-connection.d.ts.map +1 -0
  164. package/dist/types/document-models/connection/v1/src/reducers/config.d.ts +3 -0
  165. package/dist/types/document-models/connection/v1/src/reducers/config.d.ts.map +1 -0
  166. package/dist/types/document-models/connection/v1/src/reducers/connection.d.ts +3 -0
  167. package/dist/types/document-models/connection/v1/src/reducers/connection.d.ts.map +1 -0
  168. package/dist/types/document-models/connection/v1/src/reducers/health.d.ts +3 -0
  169. package/dist/types/document-models/connection/v1/src/reducers/health.d.ts.map +1 -0
  170. package/dist/types/document-models/connection/v1/src/utils.d.ts +2 -0
  171. package/dist/types/document-models/connection/v1/src/utils.d.ts.map +1 -0
  172. package/dist/types/document-models/connection/v1/tests/config-values.test.d.ts +2 -0
  173. package/dist/types/document-models/connection/v1/tests/config-values.test.d.ts.map +1 -0
  174. package/dist/types/document-models/connection/v1/tests/connection-scenarios.test.d.ts +2 -0
  175. package/dist/types/document-models/connection/v1/tests/connection-scenarios.test.d.ts.map +1 -0
  176. package/dist/types/document-models/connection/v1/tests/document-model.test.d.ts +2 -0
  177. package/dist/types/document-models/connection/v1/tests/document-model.test.d.ts.map +1 -0
  178. package/dist/types/document-models/connection/v1/tests/reactor-connection.test.d.ts +2 -0
  179. package/dist/types/document-models/connection/v1/tests/reactor-connection.test.d.ts.map +1 -0
  180. package/dist/types/document-models/connection/v1/utils.d.ts +9 -0
  181. package/dist/types/document-models/connection/v1/utils.d.ts.map +1 -0
  182. package/dist/types/document-models/document-models.d.ts +63 -0
  183. package/dist/types/document-models/document-models.d.ts.map +1 -0
  184. package/dist/types/document-models/index.d.ts +4 -0
  185. package/dist/types/document-models/index.d.ts.map +1 -0
  186. package/dist/types/document-models/upgrade-manifests.d.ts +7 -0
  187. package/dist/types/document-models/upgrade-manifests.d.ts.map +1 -0
  188. package/dist/types/document-models/workflow/index.d.ts +3 -0
  189. package/dist/types/document-models/workflow/index.d.ts.map +1 -0
  190. package/dist/types/document-models/workflow/upgrades/index.d.ts +3 -0
  191. package/dist/types/document-models/workflow/upgrades/index.d.ts.map +1 -0
  192. package/dist/types/document-models/workflow/upgrades/upgrade-manifest.d.ts +8 -0
  193. package/dist/types/document-models/workflow/upgrades/upgrade-manifest.d.ts.map +1 -0
  194. package/dist/types/document-models/workflow/upgrades/versions.d.ts +3 -0
  195. package/dist/types/document-models/workflow/upgrades/versions.d.ts.map +1 -0
  196. package/dist/types/document-models/workflow/v1/actions.d.ts +32 -0
  197. package/dist/types/document-models/workflow/v1/actions.d.ts.map +1 -0
  198. package/dist/types/document-models/workflow/v1/gen/actions.d.ts +22 -0
  199. package/dist/types/document-models/workflow/v1/gen/actions.d.ts.map +1 -0
  200. package/dist/types/document-models/workflow/v1/gen/controller.d.ts +8 -0
  201. package/dist/types/document-models/workflow/v1/gen/controller.d.ts.map +1 -0
  202. package/dist/types/document-models/workflow/v1/gen/creators.d.ts +21 -0
  203. package/dist/types/document-models/workflow/v1/gen/creators.d.ts.map +1 -0
  204. package/dist/types/document-models/workflow/v1/gen/document-model.d.ts +3 -0
  205. package/dist/types/document-models/workflow/v1/gen/document-model.d.ts.map +1 -0
  206. package/dist/types/document-models/workflow/v1/gen/document-schema.d.ts +80 -0
  207. package/dist/types/document-models/workflow/v1/gen/document-schema.d.ts.map +1 -0
  208. package/dist/types/document-models/workflow/v1/gen/document-type.d.ts +6 -0
  209. package/dist/types/document-models/workflow/v1/gen/document-type.d.ts.map +1 -0
  210. package/dist/types/document-models/workflow/v1/gen/edges/actions.d.ts +16 -0
  211. package/dist/types/document-models/workflow/v1/gen/edges/actions.d.ts.map +1 -0
  212. package/dist/types/document-models/workflow/v1/gen/edges/creators.d.ts +5 -0
  213. package/dist/types/document-models/workflow/v1/gen/edges/creators.d.ts.map +1 -0
  214. package/dist/types/document-models/workflow/v1/gen/edges/error.d.ts +36 -0
  215. package/dist/types/document-models/workflow/v1/gen/edges/error.d.ts.map +1 -0
  216. package/dist/types/document-models/workflow/v1/gen/edges/operations.d.ts +12 -0
  217. package/dist/types/document-models/workflow/v1/gen/edges/operations.d.ts.map +1 -0
  218. package/dist/types/document-models/workflow/v1/gen/index.d.ts +24 -0
  219. package/dist/types/document-models/workflow/v1/gen/index.d.ts.map +1 -0
  220. package/dist/types/document-models/workflow/v1/gen/ph-factories.d.ts +25 -0
  221. package/dist/types/document-models/workflow/v1/gen/ph-factories.d.ts.map +1 -0
  222. package/dist/types/document-models/workflow/v1/gen/policy/actions.d.ts +12 -0
  223. package/dist/types/document-models/workflow/v1/gen/policy/actions.d.ts.map +1 -0
  224. package/dist/types/document-models/workflow/v1/gen/policy/creators.d.ts +4 -0
  225. package/dist/types/document-models/workflow/v1/gen/policy/creators.d.ts.map +1 -0
  226. package/dist/types/document-models/workflow/v1/gen/policy/error.d.ts +2 -0
  227. package/dist/types/document-models/workflow/v1/gen/policy/error.d.ts.map +1 -0
  228. package/dist/types/document-models/workflow/v1/gen/policy/operations.d.ts +11 -0
  229. package/dist/types/document-models/workflow/v1/gen/policy/operations.d.ts.map +1 -0
  230. package/dist/types/document-models/workflow/v1/gen/publishing/actions.d.ts +16 -0
  231. package/dist/types/document-models/workflow/v1/gen/publishing/actions.d.ts.map +1 -0
  232. package/dist/types/document-models/workflow/v1/gen/publishing/creators.d.ts +5 -0
  233. package/dist/types/document-models/workflow/v1/gen/publishing/creators.d.ts.map +1 -0
  234. package/dist/types/document-models/workflow/v1/gen/publishing/error.d.ts +14 -0
  235. package/dist/types/document-models/workflow/v1/gen/publishing/error.d.ts.map +1 -0
  236. package/dist/types/document-models/workflow/v1/gen/publishing/operations.d.ts +12 -0
  237. package/dist/types/document-models/workflow/v1/gen/publishing/operations.d.ts.map +1 -0
  238. package/dist/types/document-models/workflow/v1/gen/reducer.d.ts +4 -0
  239. package/dist/types/document-models/workflow/v1/gen/reducer.d.ts.map +1 -0
  240. package/dist/types/document-models/workflow/v1/gen/runtime/actions.d.ts +16 -0
  241. package/dist/types/document-models/workflow/v1/gen/runtime/actions.d.ts.map +1 -0
  242. package/dist/types/document-models/workflow/v1/gen/runtime/creators.d.ts +5 -0
  243. package/dist/types/document-models/workflow/v1/gen/runtime/creators.d.ts.map +1 -0
  244. package/dist/types/document-models/workflow/v1/gen/runtime/error.d.ts +14 -0
  245. package/dist/types/document-models/workflow/v1/gen/runtime/error.d.ts.map +1 -0
  246. package/dist/types/document-models/workflow/v1/gen/runtime/operations.d.ts +12 -0
  247. package/dist/types/document-models/workflow/v1/gen/runtime/operations.d.ts.map +1 -0
  248. package/dist/types/document-models/workflow/v1/gen/schema/index.d.ts +7 -0
  249. package/dist/types/document-models/workflow/v1/gen/schema/index.d.ts.map +1 -0
  250. package/dist/types/document-models/workflow/v1/gen/schema/types.d.ts +488 -0
  251. package/dist/types/document-models/workflow/v1/gen/schema/types.d.ts.map +1 -0
  252. package/dist/types/document-models/workflow/v1/gen/schema/zod.d.ts +93 -0
  253. package/dist/types/document-models/workflow/v1/gen/schema/zod.d.ts.map +1 -0
  254. package/dist/types/document-models/workflow/v1/gen/steps/actions.d.ts +24 -0
  255. package/dist/types/document-models/workflow/v1/gen/steps/actions.d.ts.map +1 -0
  256. package/dist/types/document-models/workflow/v1/gen/steps/creators.d.ts +7 -0
  257. package/dist/types/document-models/workflow/v1/gen/steps/creators.d.ts.map +1 -0
  258. package/dist/types/document-models/workflow/v1/gen/steps/error.d.ts +70 -0
  259. package/dist/types/document-models/workflow/v1/gen/steps/error.d.ts.map +1 -0
  260. package/dist/types/document-models/workflow/v1/gen/steps/operations.d.ts +14 -0
  261. package/dist/types/document-models/workflow/v1/gen/steps/operations.d.ts.map +1 -0
  262. package/dist/types/document-models/workflow/v1/gen/trigger/actions.d.ts +28 -0
  263. package/dist/types/document-models/workflow/v1/gen/trigger/actions.d.ts.map +1 -0
  264. package/dist/types/document-models/workflow/v1/gen/trigger/creators.d.ts +8 -0
  265. package/dist/types/document-models/workflow/v1/gen/trigger/creators.d.ts.map +1 -0
  266. package/dist/types/document-models/workflow/v1/gen/trigger/error.d.ts +57 -0
  267. package/dist/types/document-models/workflow/v1/gen/trigger/error.d.ts.map +1 -0
  268. package/dist/types/document-models/workflow/v1/gen/trigger/operations.d.ts +15 -0
  269. package/dist/types/document-models/workflow/v1/gen/trigger/operations.d.ts.map +1 -0
  270. package/dist/types/document-models/workflow/v1/gen/types.d.ts +16 -0
  271. package/dist/types/document-models/workflow/v1/gen/types.d.ts.map +1 -0
  272. package/dist/types/document-models/workflow/v1/gen/utils.d.ts +10 -0
  273. package/dist/types/document-models/workflow/v1/gen/utils.d.ts.map +1 -0
  274. package/dist/types/document-models/workflow/v1/gen/variables/actions.d.ts +16 -0
  275. package/dist/types/document-models/workflow/v1/gen/variables/actions.d.ts.map +1 -0
  276. package/dist/types/document-models/workflow/v1/gen/variables/creators.d.ts +5 -0
  277. package/dist/types/document-models/workflow/v1/gen/variables/creators.d.ts.map +1 -0
  278. package/dist/types/document-models/workflow/v1/gen/variables/error.d.ts +26 -0
  279. package/dist/types/document-models/workflow/v1/gen/variables/error.d.ts.map +1 -0
  280. package/dist/types/document-models/workflow/v1/gen/variables/operations.d.ts +12 -0
  281. package/dist/types/document-models/workflow/v1/gen/variables/operations.d.ts.map +1 -0
  282. package/dist/types/document-models/workflow/v1/gen/workflow/actions.d.ts +24 -0
  283. package/dist/types/document-models/workflow/v1/gen/workflow/actions.d.ts.map +1 -0
  284. package/dist/types/document-models/workflow/v1/gen/workflow/creators.d.ts +7 -0
  285. package/dist/types/document-models/workflow/v1/gen/workflow/creators.d.ts.map +1 -0
  286. package/dist/types/document-models/workflow/v1/gen/workflow/error.d.ts +14 -0
  287. package/dist/types/document-models/workflow/v1/gen/workflow/error.d.ts.map +1 -0
  288. package/dist/types/document-models/workflow/v1/gen/workflow/operations.d.ts +14 -0
  289. package/dist/types/document-models/workflow/v1/gen/workflow/operations.d.ts.map +1 -0
  290. package/dist/types/document-models/workflow/v1/hooks.d.ts +18 -0
  291. package/dist/types/document-models/workflow/v1/hooks.d.ts.map +1 -0
  292. package/dist/types/document-models/workflow/v1/index.d.ts +11 -0
  293. package/dist/types/document-models/workflow/v1/index.d.ts.map +1 -0
  294. package/dist/types/document-models/workflow/v1/module.d.ts +39 -0
  295. package/dist/types/document-models/workflow/v1/module.d.ts.map +1 -0
  296. package/dist/types/document-models/workflow/v1/src/helpers.d.ts +15 -0
  297. package/dist/types/document-models/workflow/v1/src/helpers.d.ts.map +1 -0
  298. package/dist/types/document-models/workflow/v1/src/index.d.ts +6 -0
  299. package/dist/types/document-models/workflow/v1/src/index.d.ts.map +1 -0
  300. package/dist/types/document-models/workflow/v1/src/reducers/edges.d.ts +3 -0
  301. package/dist/types/document-models/workflow/v1/src/reducers/edges.d.ts.map +1 -0
  302. package/dist/types/document-models/workflow/v1/src/reducers/policy.d.ts +3 -0
  303. package/dist/types/document-models/workflow/v1/src/reducers/policy.d.ts.map +1 -0
  304. package/dist/types/document-models/workflow/v1/src/reducers/publishing.d.ts +3 -0
  305. package/dist/types/document-models/workflow/v1/src/reducers/publishing.d.ts.map +1 -0
  306. package/dist/types/document-models/workflow/v1/src/reducers/runtime.d.ts +3 -0
  307. package/dist/types/document-models/workflow/v1/src/reducers/runtime.d.ts.map +1 -0
  308. package/dist/types/document-models/workflow/v1/src/reducers/steps.d.ts +3 -0
  309. package/dist/types/document-models/workflow/v1/src/reducers/steps.d.ts.map +1 -0
  310. package/dist/types/document-models/workflow/v1/src/reducers/trigger.d.ts +3 -0
  311. package/dist/types/document-models/workflow/v1/src/reducers/trigger.d.ts.map +1 -0
  312. package/dist/types/document-models/workflow/v1/src/reducers/variables.d.ts +3 -0
  313. package/dist/types/document-models/workflow/v1/src/reducers/variables.d.ts.map +1 -0
  314. package/dist/types/document-models/workflow/v1/src/reducers/workflow.d.ts +3 -0
  315. package/dist/types/document-models/workflow/v1/src/reducers/workflow.d.ts.map +1 -0
  316. package/dist/types/document-models/workflow/v1/src/utils.d.ts +2 -0
  317. package/dist/types/document-models/workflow/v1/src/utils.d.ts.map +1 -0
  318. package/dist/types/document-models/workflow/v1/tests/block-validation-and-enable.test.d.ts +2 -0
  319. package/dist/types/document-models/workflow/v1/tests/block-validation-and-enable.test.d.ts.map +1 -0
  320. package/dist/types/document-models/workflow/v1/tests/config-and-variables.test.d.ts +2 -0
  321. package/dist/types/document-models/workflow/v1/tests/config-and-variables.test.d.ts.map +1 -0
  322. package/dist/types/document-models/workflow/v1/tests/document-model.test.d.ts +2 -0
  323. package/dist/types/document-models/workflow/v1/tests/document-model.test.d.ts.map +1 -0
  324. package/dist/types/document-models/workflow/v1/tests/draft-and-publish.test.d.ts +2 -0
  325. package/dist/types/document-models/workflow/v1/tests/draft-and-publish.test.d.ts.map +1 -0
  326. package/dist/types/document-models/workflow/v1/tests/managed-by.test.d.ts +2 -0
  327. package/dist/types/document-models/workflow/v1/tests/managed-by.test.d.ts.map +1 -0
  328. package/dist/types/document-models/workflow/v1/tests/reactor-connection.test.d.ts +2 -0
  329. package/dist/types/document-models/workflow/v1/tests/reactor-connection.test.d.ts.map +1 -0
  330. package/dist/types/document-models/workflow/v1/tests/trigger-fields.test.d.ts +2 -0
  331. package/dist/types/document-models/workflow/v1/tests/trigger-fields.test.d.ts.map +1 -0
  332. package/dist/types/document-models/workflow/v1/tests/updated-at.test.d.ts +2 -0
  333. package/dist/types/document-models/workflow/v1/tests/updated-at.test.d.ts.map +1 -0
  334. package/dist/types/document-models/workflow/v1/tests/workflow-scenarios.test.d.ts +2 -0
  335. package/dist/types/document-models/workflow/v1/tests/workflow-scenarios.test.d.ts.map +1 -0
  336. package/dist/types/document-models/workflow/v1/utils.d.ts +9 -0
  337. package/dist/types/document-models/workflow/v1/utils.d.ts.map +1 -0
  338. package/dist/types/editors/connection-editor/ConnectionToolbar.d.ts +10 -0
  339. package/dist/types/editors/connection-editor/ConnectionToolbar.d.ts.map +1 -0
  340. package/dist/types/editors/connection-editor/ReactorBindings.d.ts +6 -0
  341. package/dist/types/editors/connection-editor/ReactorBindings.d.ts.map +1 -0
  342. package/dist/types/editors/connection-editor/ReactorConnectionSettings.d.ts +7 -0
  343. package/dist/types/editors/connection-editor/ReactorConnectionSettings.d.ts.map +1 -0
  344. package/dist/types/editors/connection-editor/UsedBy.d.ts +6 -0
  345. package/dist/types/editors/connection-editor/UsedBy.d.ts.map +1 -0
  346. package/dist/types/editors/connection-editor/connection-callbacks.d.ts +5 -0
  347. package/dist/types/editors/connection-editor/connection-callbacks.d.ts.map +1 -0
  348. package/dist/types/editors/connection-editor/connection-callbacks.test.d.ts +2 -0
  349. package/dist/types/editors/connection-editor/connection-callbacks.test.d.ts.map +1 -0
  350. package/dist/types/editors/connection-editor/connection-form.d.ts +23 -0
  351. package/dist/types/editors/connection-editor/connection-form.d.ts.map +1 -0
  352. package/dist/types/editors/connection-editor/connection-usage.d.ts +35 -0
  353. package/dist/types/editors/connection-editor/connection-usage.d.ts.map +1 -0
  354. package/dist/types/editors/connection-editor/connection-usage.test.d.ts +2 -0
  355. package/dist/types/editors/connection-editor/connection-usage.test.d.ts.map +1 -0
  356. package/dist/types/editors/connection-editor/editor.d.ts +4 -0
  357. package/dist/types/editors/connection-editor/editor.d.ts.map +1 -0
  358. package/dist/types/editors/connection-editor/module.d.ts +9 -0
  359. package/dist/types/editors/connection-editor/module.d.ts.map +1 -0
  360. package/dist/types/editors/connection-editor/piece-auth.d.ts +39 -0
  361. package/dist/types/editors/connection-editor/piece-auth.d.ts.map +1 -0
  362. package/dist/types/editors/connection-editor/piece-auth.test.d.ts +2 -0
  363. package/dist/types/editors/connection-editor/piece-auth.test.d.ts.map +1 -0
  364. package/dist/types/editors/connection-editor/status.d.ts +6 -0
  365. package/dist/types/editors/connection-editor/status.d.ts.map +1 -0
  366. package/dist/types/editors/editors.d.ts +7 -0
  367. package/dist/types/editors/editors.d.ts.map +1 -0
  368. package/dist/types/editors/index.d.ts +4 -0
  369. package/dist/types/editors/index.d.ts.map +1 -0
  370. package/dist/types/editors/runtime/index.d.ts +21 -0
  371. package/dist/types/editors/runtime/index.d.ts.map +1 -0
  372. package/dist/types/editors/runtime/runtime-export.test.d.ts +2 -0
  373. package/dist/types/editors/runtime/runtime-export.test.d.ts.map +1 -0
  374. package/dist/types/editors/shared/DocumentErrorBoundary.d.ts +35 -0
  375. package/dist/types/editors/shared/DocumentErrorBoundary.d.ts.map +1 -0
  376. package/dist/types/editors/shared/controls.d.ts +123 -0
  377. package/dist/types/editors/shared/controls.d.ts.map +1 -0
  378. package/dist/types/editors/shared/data-tree.d.ts +5 -0
  379. package/dist/types/editors/shared/data-tree.d.ts.map +1 -0
  380. package/dist/types/editors/shared/data-viewer.d.ts +7 -0
  381. package/dist/types/editors/shared/data-viewer.d.ts.map +1 -0
  382. package/dist/types/editors/shared/document-ref.d.ts +5 -0
  383. package/dist/types/editors/shared/document-ref.d.ts.map +1 -0
  384. package/dist/types/editors/shared/editor-chrome.d.ts +14 -0
  385. package/dist/types/editors/shared/editor-chrome.d.ts.map +1 -0
  386. package/dist/types/editors/shared/editor-chrome.test.d.ts +2 -0
  387. package/dist/types/editors/shared/editor-chrome.test.d.ts.map +1 -0
  388. package/dist/types/editors/shared/icons.d.ts +45 -0
  389. package/dist/types/editors/shared/icons.d.ts.map +1 -0
  390. package/dist/types/editors/shared/pending-echo.d.ts +9 -0
  391. package/dist/types/editors/shared/pending-echo.d.ts.map +1 -0
  392. package/dist/types/editors/shared/undo-plan.d.ts +27 -0
  393. package/dist/types/editors/shared/undo-plan.d.ts.map +1 -0
  394. package/dist/types/editors/shared/undo-plan.test.d.ts +2 -0
  395. package/dist/types/editors/shared/undo-plan.test.d.ts.map +1 -0
  396. package/dist/types/editors/shared/url-param.d.ts +14 -0
  397. package/dist/types/editors/shared/url-param.d.ts.map +1 -0
  398. package/dist/types/editors/shared/url-param.test.d.ts +2 -0
  399. package/dist/types/editors/shared/url-param.test.d.ts.map +1 -0
  400. package/dist/types/editors/workflow-editor/document/useWorkflowModel.d.ts +6 -0
  401. package/dist/types/editors/workflow-editor/document/useWorkflowModel.d.ts.map +1 -0
  402. package/dist/types/editors/workflow-editor/editor.d.ts +6 -0
  403. package/dist/types/editors/workflow-editor/editor.d.ts.map +1 -0
  404. package/dist/types/editors/workflow-editor/module.d.ts +9 -0
  405. package/dist/types/editors/workflow-editor/module.d.ts.map +1 -0
  406. package/dist/types/editors/workflow-editor/reactor-hooks.d.ts +25 -0
  407. package/dist/types/editors/workflow-editor/reactor-hooks.d.ts.map +1 -0
  408. package/dist/types/editors/workflow-editor/run-kinds.d.ts +5 -0
  409. package/dist/types/editors/workflow-editor/run-kinds.d.ts.map +1 -0
  410. package/dist/types/editors/workflow-editor/runtime-api.d.ts +16 -0
  411. package/dist/types/editors/workflow-editor/runtime-api.d.ts.map +1 -0
  412. package/dist/types/editors/workflow-editor/runtime-client.d.ts +347 -0
  413. package/dist/types/editors/workflow-editor/runtime-client.d.ts.map +1 -0
  414. package/dist/types/editors/workflow-editor/runtime-client.test.d.ts +2 -0
  415. package/dist/types/editors/workflow-editor/runtime-client.test.d.ts.map +1 -0
  416. package/dist/types/editors/workflow-editor/runtime-context.d.ts +54 -0
  417. package/dist/types/editors/workflow-editor/runtime-context.d.ts.map +1 -0
  418. package/dist/types/editors/workflow-editor/runtime-contract.test.d.ts +2 -0
  419. package/dist/types/editors/workflow-editor/runtime-contract.test.d.ts.map +1 -0
  420. package/dist/types/editors/workflow-editor/runtime-persist.d.ts +23 -0
  421. package/dist/types/editors/workflow-editor/runtime-persist.d.ts.map +1 -0
  422. package/dist/types/editors/workflow-editor/runtime-persist.test.d.ts +2 -0
  423. package/dist/types/editors/workflow-editor/runtime-persist.test.d.ts.map +1 -0
  424. package/dist/types/editors/workflow-editor/runtime-queries.d.ts +148 -0
  425. package/dist/types/editors/workflow-editor/runtime-queries.d.ts.map +1 -0
  426. package/dist/types/editors/workflow-editor/ui/BlockSelector.d.ts +40 -0
  427. package/dist/types/editors/workflow-editor/ui/BlockSelector.d.ts.map +1 -0
  428. package/dist/types/editors/workflow-editor/ui/CanvasContextMenu.d.ts +15 -0
  429. package/dist/types/editors/workflow-editor/ui/CanvasContextMenu.d.ts.map +1 -0
  430. package/dist/types/editors/workflow-editor/ui/ConnectionField.d.ts +7 -0
  431. package/dist/types/editors/workflow-editor/ui/ConnectionField.d.ts.map +1 -0
  432. package/dist/types/editors/workflow-editor/ui/ConnectionName.d.ts +8 -0
  433. package/dist/types/editors/workflow-editor/ui/ConnectionName.d.ts.map +1 -0
  434. package/dist/types/editors/workflow-editor/ui/CreateConnectionModal.d.ts +7 -0
  435. package/dist/types/editors/workflow-editor/ui/CreateConnectionModal.d.ts.map +1 -0
  436. package/dist/types/editors/workflow-editor/ui/ExpressionPicker.d.ts +51 -0
  437. package/dist/types/editors/workflow-editor/ui/ExpressionPicker.d.ts.map +1 -0
  438. package/dist/types/editors/workflow-editor/ui/PanelResizer.d.ts +12 -0
  439. package/dist/types/editors/workflow-editor/ui/PanelResizer.d.ts.map +1 -0
  440. package/dist/types/editors/workflow-editor/ui/PickerPopover.d.ts +12 -0
  441. package/dist/types/editors/workflow-editor/ui/PickerPopover.d.ts.map +1 -0
  442. package/dist/types/editors/workflow-editor/ui/PieceMarkdown.d.ts +5 -0
  443. package/dist/types/editors/workflow-editor/ui/PieceMarkdown.d.ts.map +1 -0
  444. package/dist/types/editors/workflow-editor/ui/PropertyForm.d.ts +37 -0
  445. package/dist/types/editors/workflow-editor/ui/PropertyForm.d.ts.map +1 -0
  446. package/dist/types/editors/workflow-editor/ui/PublishControls.d.ts +51 -0
  447. package/dist/types/editors/workflow-editor/ui/PublishControls.d.ts.map +1 -0
  448. package/dist/types/editors/workflow-editor/ui/ReactorConnectionField.d.ts +9 -0
  449. package/dist/types/editors/workflow-editor/ui/ReactorConnectionField.d.ts.map +1 -0
  450. package/dist/types/editors/workflow-editor/ui/ScheduleBuilder.d.ts +5 -0
  451. package/dist/types/editors/workflow-editor/ui/ScheduleBuilder.d.ts.map +1 -0
  452. package/dist/types/editors/workflow-editor/ui/SignInPrompt.d.ts +6 -0
  453. package/dist/types/editors/workflow-editor/ui/SignInPrompt.d.ts.map +1 -0
  454. package/dist/types/editors/workflow-editor/ui/StepError.d.ts +4 -0
  455. package/dist/types/editors/workflow-editor/ui/StepError.d.ts.map +1 -0
  456. package/dist/types/editors/workflow-editor/ui/StepPanel.d.ts +17 -0
  457. package/dist/types/editors/workflow-editor/ui/StepPanel.d.ts.map +1 -0
  458. package/dist/types/editors/workflow-editor/ui/StepTest.d.ts +11 -0
  459. package/dist/types/editors/workflow-editor/ui/StepTest.d.ts.map +1 -0
  460. package/dist/types/editors/workflow-editor/ui/SwitchboardGrants.d.ts +2 -0
  461. package/dist/types/editors/workflow-editor/ui/SwitchboardGrants.d.ts.map +1 -0
  462. package/dist/types/editors/workflow-editor/ui/VariablesEditor.d.ts +7 -0
  463. package/dist/types/editors/workflow-editor/ui/VariablesEditor.d.ts.map +1 -0
  464. package/dist/types/editors/workflow-editor/ui/VirtualList.d.ts +14 -0
  465. package/dist/types/editors/workflow-editor/ui/VirtualList.d.ts.map +1 -0
  466. package/dist/types/editors/workflow-editor/ui/WorkflowCanvas.d.ts +9 -0
  467. package/dist/types/editors/workflow-editor/ui/WorkflowCanvas.d.ts.map +1 -0
  468. package/dist/types/editors/workflow-editor/ui/WorkflowEditorApp.d.ts +9 -0
  469. package/dist/types/editors/workflow-editor/ui/WorkflowEditorApp.d.ts.map +1 -0
  470. package/dist/types/editors/workflow-editor/ui/add-follow-up.d.ts +31 -0
  471. package/dist/types/editors/workflow-editor/ui/add-follow-up.d.ts.map +1 -0
  472. package/dist/types/editors/workflow-editor/ui/add-follow-up.test.d.ts +2 -0
  473. package/dist/types/editors/workflow-editor/ui/add-follow-up.test.d.ts.map +1 -0
  474. package/dist/types/editors/workflow-editor/ui/ap-edge.d.ts +9 -0
  475. package/dist/types/editors/workflow-editor/ui/ap-edge.d.ts.map +1 -0
  476. package/dist/types/editors/workflow-editor/ui/ap-layout.d.ts +20 -0
  477. package/dist/types/editors/workflow-editor/ui/ap-layout.d.ts.map +1 -0
  478. package/dist/types/editors/workflow-editor/ui/ap-layout.test.d.ts +2 -0
  479. package/dist/types/editors/workflow-editor/ui/ap-layout.test.d.ts.map +1 -0
  480. package/dist/types/editors/workflow-editor/ui/ap-nodes.d.ts +41 -0
  481. package/dist/types/editors/workflow-editor/ui/ap-nodes.d.ts.map +1 -0
  482. package/dist/types/editors/workflow-editor/ui/block-meta.d.ts +31 -0
  483. package/dist/types/editors/workflow-editor/ui/block-meta.d.ts.map +1 -0
  484. package/dist/types/editors/workflow-editor/ui/block-meta.test.d.ts +2 -0
  485. package/dist/types/editors/workflow-editor/ui/block-meta.test.d.ts.map +1 -0
  486. package/dist/types/editors/workflow-editor/ui/block-picker-layout.test.d.ts +2 -0
  487. package/dist/types/editors/workflow-editor/ui/block-picker-layout.test.d.ts.map +1 -0
  488. package/dist/types/editors/workflow-editor/ui/block-selector-chips.test.d.ts +2 -0
  489. package/dist/types/editors/workflow-editor/ui/block-selector-chips.test.d.ts.map +1 -0
  490. package/dist/types/editors/workflow-editor/ui/blocks.d.ts +65 -0
  491. package/dist/types/editors/workflow-editor/ui/blocks.d.ts.map +1 -0
  492. package/dist/types/editors/workflow-editor/ui/blocks.test.d.ts +2 -0
  493. package/dist/types/editors/workflow-editor/ui/blocks.test.d.ts.map +1 -0
  494. package/dist/types/editors/workflow-editor/ui/canvas-menu.d.ts +35 -0
  495. package/dist/types/editors/workflow-editor/ui/canvas-menu.d.ts.map +1 -0
  496. package/dist/types/editors/workflow-editor/ui/canvas-menu.test.d.ts +2 -0
  497. package/dist/types/editors/workflow-editor/ui/canvas-menu.test.d.ts.map +1 -0
  498. package/dist/types/editors/workflow-editor/ui/connection-create.d.ts +18 -0
  499. package/dist/types/editors/workflow-editor/ui/connection-create.d.ts.map +1 -0
  500. package/dist/types/editors/workflow-editor/ui/connection-create.test.d.ts +2 -0
  501. package/dist/types/editors/workflow-editor/ui/connection-create.test.d.ts.map +1 -0
  502. package/dist/types/editors/workflow-editor/ui/design-time.d.ts +93 -0
  503. package/dist/types/editors/workflow-editor/ui/design-time.d.ts.map +1 -0
  504. package/dist/types/editors/workflow-editor/ui/design-time.test.d.ts +2 -0
  505. package/dist/types/editors/workflow-editor/ui/design-time.test.d.ts.map +1 -0
  506. package/dist/types/editors/workflow-editor/ui/document-options.d.ts +24 -0
  507. package/dist/types/editors/workflow-editor/ui/document-options.d.ts.map +1 -0
  508. package/dist/types/editors/workflow-editor/ui/document-options.test.d.ts +2 -0
  509. package/dist/types/editors/workflow-editor/ui/document-options.test.d.ts.map +1 -0
  510. package/dist/types/editors/workflow-editor/ui/document-shape.d.ts +8 -0
  511. package/dist/types/editors/workflow-editor/ui/document-shape.d.ts.map +1 -0
  512. package/dist/types/editors/workflow-editor/ui/document-shape.test.d.ts +2 -0
  513. package/dist/types/editors/workflow-editor/ui/document-shape.test.d.ts.map +1 -0
  514. package/dist/types/editors/workflow-editor/ui/expression-scope.d.ts +39 -0
  515. package/dist/types/editors/workflow-editor/ui/expression-scope.d.ts.map +1 -0
  516. package/dist/types/editors/workflow-editor/ui/expression-scope.test.d.ts +2 -0
  517. package/dist/types/editors/workflow-editor/ui/expression-scope.test.d.ts.map +1 -0
  518. package/dist/types/editors/workflow-editor/ui/expression-tokens.d.ts +18 -0
  519. package/dist/types/editors/workflow-editor/ui/expression-tokens.d.ts.map +1 -0
  520. package/dist/types/editors/workflow-editor/ui/expression-tokens.test.d.ts +2 -0
  521. package/dist/types/editors/workflow-editor/ui/expression-tokens.test.d.ts.map +1 -0
  522. package/dist/types/editors/workflow-editor/ui/flow-control.test.d.ts +2 -0
  523. package/dist/types/editors/workflow-editor/ui/flow-control.test.d.ts.map +1 -0
  524. package/dist/types/editors/workflow-editor/ui/forms.d.ts +160 -0
  525. package/dist/types/editors/workflow-editor/ui/forms.d.ts.map +1 -0
  526. package/dist/types/editors/workflow-editor/ui/item-summary.test.d.ts +2 -0
  527. package/dist/types/editors/workflow-editor/ui/item-summary.test.d.ts.map +1 -0
  528. package/dist/types/editors/workflow-editor/ui/manual-inputs.d.ts +7 -0
  529. package/dist/types/editors/workflow-editor/ui/manual-inputs.d.ts.map +1 -0
  530. package/dist/types/editors/workflow-editor/ui/manual-inputs.test.d.ts +2 -0
  531. package/dist/types/editors/workflow-editor/ui/manual-inputs.test.d.ts.map +1 -0
  532. package/dist/types/editors/workflow-editor/ui/model.d.ts +187 -0
  533. package/dist/types/editors/workflow-editor/ui/model.d.ts.map +1 -0
  534. package/dist/types/editors/workflow-editor/ui/model.test.d.ts +2 -0
  535. package/dist/types/editors/workflow-editor/ui/model.test.d.ts.map +1 -0
  536. package/dist/types/editors/workflow-editor/ui/picker-placement.d.ts +19 -0
  537. package/dist/types/editors/workflow-editor/ui/picker-placement.d.ts.map +1 -0
  538. package/dist/types/editors/workflow-editor/ui/picker-recent.d.ts +4 -0
  539. package/dist/types/editors/workflow-editor/ui/picker-recent.d.ts.map +1 -0
  540. package/dist/types/editors/workflow-editor/ui/piece-placeholders.test.d.ts +2 -0
  541. package/dist/types/editors/workflow-editor/ui/piece-placeholders.test.d.ts.map +1 -0
  542. package/dist/types/editors/workflow-editor/ui/piece-source.d.ts +82 -0
  543. package/dist/types/editors/workflow-editor/ui/piece-source.d.ts.map +1 -0
  544. package/dist/types/editors/workflow-editor/ui/prop-controls.d.ts +66 -0
  545. package/dist/types/editors/workflow-editor/ui/prop-controls.d.ts.map +1 -0
  546. package/dist/types/editors/workflow-editor/ui/prop-controls.test.d.ts +2 -0
  547. package/dist/types/editors/workflow-editor/ui/prop-controls.test.d.ts.map +1 -0
  548. package/dist/types/editors/workflow-editor/ui/prop-defaults.d.ts +4 -0
  549. package/dist/types/editors/workflow-editor/ui/prop-defaults.d.ts.map +1 -0
  550. package/dist/types/editors/workflow-editor/ui/prop-defaults.test.d.ts +2 -0
  551. package/dist/types/editors/workflow-editor/ui/prop-defaults.test.d.ts.map +1 -0
  552. package/dist/types/editors/workflow-editor/ui/prop-layout.d.ts +13 -0
  553. package/dist/types/editors/workflow-editor/ui/prop-layout.d.ts.map +1 -0
  554. package/dist/types/editors/workflow-editor/ui/prop-layout.test.d.ts +2 -0
  555. package/dist/types/editors/workflow-editor/ui/prop-layout.test.d.ts.map +1 -0
  556. package/dist/types/editors/workflow-editor/ui/query-keys.d.ts +66 -0
  557. package/dist/types/editors/workflow-editor/ui/query-keys.d.ts.map +1 -0
  558. package/dist/types/editors/workflow-editor/ui/reactor-access.d.ts +43 -0
  559. package/dist/types/editors/workflow-editor/ui/reactor-access.d.ts.map +1 -0
  560. package/dist/types/editors/workflow-editor/ui/reactor-access.test.d.ts +2 -0
  561. package/dist/types/editors/workflow-editor/ui/reactor-access.test.d.ts.map +1 -0
  562. package/dist/types/editors/workflow-editor/ui/reactor-connection-create.d.ts +2 -0
  563. package/dist/types/editors/workflow-editor/ui/reactor-connection-create.d.ts.map +1 -0
  564. package/dist/types/editors/workflow-editor/ui/reactor-connection-create.test.d.ts +2 -0
  565. package/dist/types/editors/workflow-editor/ui/reactor-connection-create.test.d.ts.map +1 -0
  566. package/dist/types/editors/workflow-editor/ui/reactor-view.d.ts +25 -0
  567. package/dist/types/editors/workflow-editor/ui/reactor-view.d.ts.map +1 -0
  568. package/dist/types/editors/workflow-editor/ui/reactor-view.test.d.ts +2 -0
  569. package/dist/types/editors/workflow-editor/ui/reactor-view.test.d.ts.map +1 -0
  570. package/dist/types/editors/workflow-editor/ui/retry-policy.d.ts +8 -0
  571. package/dist/types/editors/workflow-editor/ui/retry-policy.d.ts.map +1 -0
  572. package/dist/types/editors/workflow-editor/ui/retry-policy.test.d.ts +2 -0
  573. package/dist/types/editors/workflow-editor/ui/retry-policy.test.d.ts.map +1 -0
  574. package/dist/types/editors/workflow-editor/ui/schedule-draft.d.ts +30 -0
  575. package/dist/types/editors/workflow-editor/ui/schedule-draft.d.ts.map +1 -0
  576. package/dist/types/editors/workflow-editor/ui/schedule-draft.test.d.ts +2 -0
  577. package/dist/types/editors/workflow-editor/ui/schedule-draft.test.d.ts.map +1 -0
  578. package/dist/types/editors/workflow-editor/ui/secret-ref.d.ts +18 -0
  579. package/dist/types/editors/workflow-editor/ui/secret-ref.d.ts.map +1 -0
  580. package/dist/types/editors/workflow-editor/ui/step-drag.d.ts +13 -0
  581. package/dist/types/editors/workflow-editor/ui/step-drag.d.ts.map +1 -0
  582. package/dist/types/editors/workflow-editor/ui/step-drag.test.d.ts +2 -0
  583. package/dist/types/editors/workflow-editor/ui/step-drag.test.d.ts.map +1 -0
  584. package/dist/types/editors/workflow-editor/ui/step-test.d.ts +16 -0
  585. package/dist/types/editors/workflow-editor/ui/step-test.d.ts.map +1 -0
  586. package/dist/types/editors/workflow-editor/ui/step-test.test.d.ts +2 -0
  587. package/dist/types/editors/workflow-editor/ui/step-test.test.d.ts.map +1 -0
  588. package/dist/types/editors/workflow-editor/ui/test-state.d.ts +7 -0
  589. package/dist/types/editors/workflow-editor/ui/test-state.d.ts.map +1 -0
  590. package/dist/types/editors/workflow-editor/ui/trigger-strategy.test.d.ts +2 -0
  591. package/dist/types/editors/workflow-editor/ui/trigger-strategy.test.d.ts.map +1 -0
  592. package/dist/types/editors/workflow-editor/ui/trigger-text.d.ts +12 -0
  593. package/dist/types/editors/workflow-editor/ui/trigger-text.d.ts.map +1 -0
  594. package/dist/types/editors/workflow-editor/ui/trigger-text.test.d.ts +2 -0
  595. package/dist/types/editors/workflow-editor/ui/trigger-text.test.d.ts.map +1 -0
  596. package/dist/types/editors/workflow-editor/ui/use-selected-block.d.ts +4 -0
  597. package/dist/types/editors/workflow-editor/ui/use-selected-block.d.ts.map +1 -0
  598. package/dist/types/editors/workflow-editor/ui/use-selected-block.test.d.ts +2 -0
  599. package/dist/types/editors/workflow-editor/ui/use-selected-block.test.d.ts.map +1 -0
  600. package/dist/types/editors/workflow-editor/ui/use-validity.d.ts +29 -0
  601. package/dist/types/editors/workflow-editor/ui/use-validity.d.ts.map +1 -0
  602. package/dist/types/editors/workflow-editor/ui/validation.d.ts +43 -0
  603. package/dist/types/editors/workflow-editor/ui/validation.d.ts.map +1 -0
  604. package/dist/types/editors/workflow-editor/ui/validation.test.d.ts +2 -0
  605. package/dist/types/editors/workflow-editor/ui/validation.test.d.ts.map +1 -0
  606. package/dist/types/editors/workflow-editor/ui/variable-types.d.ts +14 -0
  607. package/dist/types/editors/workflow-editor/ui/variable-types.d.ts.map +1 -0
  608. package/dist/types/editors/workflow-editor/ui/variable-types.test.d.ts +2 -0
  609. package/dist/types/editors/workflow-editor/ui/variable-types.test.d.ts.map +1 -0
  610. package/dist/types/editors/workflow-editor/ui/version-badge.d.ts +33 -0
  611. package/dist/types/editors/workflow-editor/ui/version-badge.d.ts.map +1 -0
  612. package/dist/types/editors/workflow-editor/ui/version-badge.test.d.ts +2 -0
  613. package/dist/types/editors/workflow-editor/ui/version-badge.test.d.ts.map +1 -0
  614. package/dist/types/editors/workflow-editor/undo-policy.d.ts +3 -0
  615. package/dist/types/editors/workflow-editor/undo-policy.d.ts.map +1 -0
  616. package/dist/types/editors/workflow-editor/undo-policy.test.d.ts +2 -0
  617. package/dist/types/editors/workflow-editor/undo-policy.test.d.ts.map +1 -0
  618. package/dist/types/editors/workflow-editor/use-workflow-runtime.d.ts +13 -0
  619. package/dist/types/editors/workflow-editor/use-workflow-runtime.d.ts.map +1 -0
  620. package/dist/types/editors/workflow-editor/use-workflow-runtime.test.d.ts +2 -0
  621. package/dist/types/editors/workflow-editor/use-workflow-runtime.test.d.ts.map +1 -0
  622. package/dist/types/editors/workflow-studio/components/RunDialog.d.ts +7 -0
  623. package/dist/types/editors/workflow-studio/components/RunDialog.d.ts.map +1 -0
  624. package/dist/types/editors/workflow-studio/components/RunsTable.d.ts +19 -0
  625. package/dist/types/editors/workflow-studio/components/RunsTable.d.ts.map +1 -0
  626. package/dist/types/editors/workflow-studio/components/RunsTable.test.d.ts +2 -0
  627. package/dist/types/editors/workflow-studio/components/RunsTable.test.d.ts.map +1 -0
  628. package/dist/types/editors/workflow-studio/components/RunsView.d.ts +15 -0
  629. package/dist/types/editors/workflow-studio/components/RunsView.d.ts.map +1 -0
  630. package/dist/types/editors/workflow-studio/components/ScrollFade.d.ts +7 -0
  631. package/dist/types/editors/workflow-studio/components/ScrollFade.d.ts.map +1 -0
  632. package/dist/types/editors/workflow-studio/components/Sidebar.d.ts +20 -0
  633. package/dist/types/editors/workflow-studio/components/Sidebar.d.ts.map +1 -0
  634. package/dist/types/editors/workflow-studio/components/Waitpoints.d.ts +57 -0
  635. package/dist/types/editors/workflow-studio/components/Waitpoints.d.ts.map +1 -0
  636. package/dist/types/editors/workflow-studio/components/WorkflowBoard.d.ts +12 -0
  637. package/dist/types/editors/workflow-studio/components/WorkflowBoard.d.ts.map +1 -0
  638. package/dist/types/editors/workflow-studio/components/WorkflowGraph.d.ts +41 -0
  639. package/dist/types/editors/workflow-studio/components/WorkflowGraph.d.ts.map +1 -0
  640. package/dist/types/editors/workflow-studio/components/WorkflowHeader.d.ts +9 -0
  641. package/dist/types/editors/workflow-studio/components/WorkflowHeader.d.ts.map +1 -0
  642. package/dist/types/editors/workflow-studio/components/WorkflowMenu.d.ts +15 -0
  643. package/dist/types/editors/workflow-studio/components/WorkflowMenu.d.ts.map +1 -0
  644. package/dist/types/editors/workflow-studio/components/WorkflowSteps.d.ts +8 -0
  645. package/dist/types/editors/workflow-studio/components/WorkflowSteps.d.ts.map +1 -0
  646. package/dist/types/editors/workflow-studio/components/WorkflowStudio.d.ts +5 -0
  647. package/dist/types/editors/workflow-studio/components/WorkflowStudio.d.ts.map +1 -0
  648. package/dist/types/editors/workflow-studio/components/chain.d.ts +26 -0
  649. package/dist/types/editors/workflow-studio/components/chain.d.ts.map +1 -0
  650. package/dist/types/editors/workflow-studio/components/fit-geometry.test.d.ts +2 -0
  651. package/dist/types/editors/workflow-studio/components/fit-geometry.test.d.ts.map +1 -0
  652. package/dist/types/editors/workflow-studio/components/graph-layout.d.ts +30 -0
  653. package/dist/types/editors/workflow-studio/components/graph-layout.d.ts.map +1 -0
  654. package/dist/types/editors/workflow-studio/components/graph-layout.test.d.ts +2 -0
  655. package/dist/types/editors/workflow-studio/components/graph-layout.test.d.ts.map +1 -0
  656. package/dist/types/editors/workflow-studio/components/run-dialog.test.d.ts +2 -0
  657. package/dist/types/editors/workflow-studio/components/run-dialog.test.d.ts.map +1 -0
  658. package/dist/types/editors/workflow-studio/components/run-format.d.ts +60 -0
  659. package/dist/types/editors/workflow-studio/components/run-format.d.ts.map +1 -0
  660. package/dist/types/editors/workflow-studio/components/run-format.test.d.ts +2 -0
  661. package/dist/types/editors/workflow-studio/components/run-format.test.d.ts.map +1 -0
  662. package/dist/types/editors/workflow-studio/components/run-timeline.test.d.ts +2 -0
  663. package/dist/types/editors/workflow-studio/components/run-timeline.test.d.ts.map +1 -0
  664. package/dist/types/editors/workflow-studio/components/step-outline.d.ts +27 -0
  665. package/dist/types/editors/workflow-studio/components/step-outline.d.ts.map +1 -0
  666. package/dist/types/editors/workflow-studio/components/step-outline.test.d.ts +2 -0
  667. package/dist/types/editors/workflow-studio/components/step-outline.test.d.ts.map +1 -0
  668. package/dist/types/editors/workflow-studio/components/tips.d.ts +23 -0
  669. package/dist/types/editors/workflow-studio/components/tips.d.ts.map +1 -0
  670. package/dist/types/editors/workflow-studio/components/ui.d.ts +22 -0
  671. package/dist/types/editors/workflow-studio/components/ui.d.ts.map +1 -0
  672. package/dist/types/editors/workflow-studio/components/use-collapsed.d.ts +5 -0
  673. package/dist/types/editors/workflow-studio/components/use-collapsed.d.ts.map +1 -0
  674. package/dist/types/editors/workflow-studio/components/use-item-selection.d.ts +10 -0
  675. package/dist/types/editors/workflow-studio/components/use-item-selection.d.ts.map +1 -0
  676. package/dist/types/editors/workflow-studio/components/use-item-selection.test.d.ts +2 -0
  677. package/dist/types/editors/workflow-studio/components/use-item-selection.test.d.ts.map +1 -0
  678. package/dist/types/editors/workflow-studio/components/useRuns.d.ts +11 -0
  679. package/dist/types/editors/workflow-studio/components/useRuns.d.ts.map +1 -0
  680. package/dist/types/editors/workflow-studio/components/waitpoints-view.test.d.ts +2 -0
  681. package/dist/types/editors/workflow-studio/components/waitpoints-view.test.d.ts.map +1 -0
  682. package/dist/types/editors/workflow-studio/components/waitpoints.test.d.ts +2 -0
  683. package/dist/types/editors/workflow-studio/components/waitpoints.test.d.ts.map +1 -0
  684. package/dist/types/editors/workflow-studio/components/workflow-order.d.ts +19 -0
  685. package/dist/types/editors/workflow-studio/components/workflow-order.d.ts.map +1 -0
  686. package/dist/types/editors/workflow-studio/components/workflow-order.test.d.ts +2 -0
  687. package/dist/types/editors/workflow-studio/components/workflow-order.test.d.ts.map +1 -0
  688. package/dist/types/editors/workflow-studio/config.d.ts +3 -0
  689. package/dist/types/editors/workflow-studio/config.d.ts.map +1 -0
  690. package/dist/types/editors/workflow-studio/editor.d.ts +4 -0
  691. package/dist/types/editors/workflow-studio/editor.d.ts.map +1 -0
  692. package/dist/types/editors/workflow-studio/module.d.ts +8 -0
  693. package/dist/types/editors/workflow-studio/module.d.ts.map +1 -0
  694. package/dist/types/index.d.ts +7 -0
  695. package/dist/types/index.d.ts.map +1 -0
  696. package/dist/types/pieces/ai/ai-actions.test.d.ts +2 -0
  697. package/dist/types/pieces/ai/ai-actions.test.d.ts.map +1 -0
  698. package/dist/types/pieces/ai/ai-documents.test.d.ts +2 -0
  699. package/dist/types/pieces/ai/ai-documents.test.d.ts.map +1 -0
  700. package/dist/types/pieces/ai/ai.test.d.ts +2 -0
  701. package/dist/types/pieces/ai/ai.test.d.ts.map +1 -0
  702. package/dist/types/pieces/ai/index.d.ts +7 -0
  703. package/dist/types/pieces/ai/index.d.ts.map +1 -0
  704. package/dist/types/pieces/ai/lib/action-schema.d.ts +11 -0
  705. package/dist/types/pieces/ai/lib/action-schema.d.ts.map +1 -0
  706. package/dist/types/pieces/ai/lib/actions/ask-ai.d.ts +38 -0
  707. package/dist/types/pieces/ai/lib/actions/ask-ai.d.ts.map +1 -0
  708. package/dist/types/pieces/ai/lib/actions/decide-on-documents.d.ts +45 -0
  709. package/dist/types/pieces/ai/lib/actions/decide-on-documents.d.ts.map +1 -0
  710. package/dist/types/pieces/ai/lib/actions/decide.d.ts +39 -0
  711. package/dist/types/pieces/ai/lib/actions/decide.d.ts.map +1 -0
  712. package/dist/types/pieces/ai/lib/actions/extract.d.ts +41 -0
  713. package/dist/types/pieces/ai/lib/actions/extract.d.ts.map +1 -0
  714. package/dist/types/pieces/ai/lib/actions/propose-actions.d.ts +55 -0
  715. package/dist/types/pieces/ai/lib/actions/propose-actions.d.ts.map +1 -0
  716. package/dist/types/pieces/ai/lib/actions/summarize.d.ts +38 -0
  717. package/dist/types/pieces/ai/lib/actions/summarize.d.ts.map +1 -0
  718. package/dist/types/pieces/ai/lib/auth.d.ts +16 -0
  719. package/dist/types/pieces/ai/lib/auth.d.ts.map +1 -0
  720. package/dist/types/pieces/ai/lib/decision-model.d.ts +17 -0
  721. package/dist/types/pieces/ai/lib/decision-model.d.ts.map +1 -0
  722. package/dist/types/pieces/ai/lib/documents.d.ts +11 -0
  723. package/dist/types/pieces/ai/lib/documents.d.ts.map +1 -0
  724. package/dist/types/pieces/ai/lib/model-list.d.ts +8 -0
  725. package/dist/types/pieces/ai/lib/model-list.d.ts.map +1 -0
  726. package/dist/types/pieces/ai/lib/models.d.ts +19 -0
  727. package/dist/types/pieces/ai/lib/models.d.ts.map +1 -0
  728. package/dist/types/pieces/ai/lib/props.d.ts +16 -0
  729. package/dist/types/pieces/ai/lib/props.d.ts.map +1 -0
  730. package/dist/types/pieces/ai/lib/providers.d.ts +9 -0
  731. package/dist/types/pieces/ai/lib/providers.d.ts.map +1 -0
  732. package/dist/types/pieces/ai/lib/questions.d.ts +7 -0
  733. package/dist/types/pieces/ai/lib/questions.d.ts.map +1 -0
  734. package/dist/types/pieces/index.d.ts +4 -0
  735. package/dist/types/pieces/index.d.ts.map +1 -0
  736. package/dist/types/pieces/reactor/index.d.ts +3 -0
  737. package/dist/types/pieces/reactor/index.d.ts.map +1 -0
  738. package/dist/types/pieces/reactor/lib/actions/action-list-prop.test.d.ts +2 -0
  739. package/dist/types/pieces/reactor/lib/actions/action-list-prop.test.d.ts.map +1 -0
  740. package/dist/types/pieces/reactor/lib/actions/document-create.d.ts +27 -0
  741. package/dist/types/pieces/reactor/lib/actions/document-create.d.ts.map +1 -0
  742. package/dist/types/pieces/reactor/lib/actions/document-dispatch.d.ts +25 -0
  743. package/dist/types/pieces/reactor/lib/actions/document-dispatch.d.ts.map +1 -0
  744. package/dist/types/pieces/reactor/lib/actions/document-find.d.ts +13 -0
  745. package/dist/types/pieces/reactor/lib/actions/document-find.d.ts.map +1 -0
  746. package/dist/types/pieces/reactor/lib/actions/document-get.d.ts +8 -0
  747. package/dist/types/pieces/reactor/lib/actions/document-get.d.ts.map +1 -0
  748. package/dist/types/pieces/reactor/lib/actions/document-schema.d.ts +9 -0
  749. package/dist/types/pieces/reactor/lib/actions/document-schema.d.ts.map +1 -0
  750. package/dist/types/pieces/reactor/lib/actions/document-types.d.ts +4 -0
  751. package/dist/types/pieces/reactor/lib/actions/document-types.d.ts.map +1 -0
  752. package/dist/types/pieces/reactor/lib/actions/index-query.d.ts +14 -0
  753. package/dist/types/pieces/reactor/lib/actions/index-query.d.ts.map +1 -0
  754. package/dist/types/pieces/reactor/lib/documents.d.ts +33 -0
  755. package/dist/types/pieces/reactor/lib/documents.d.ts.map +1 -0
  756. package/dist/types/pieces/reactor/lib/documents.test.d.ts +2 -0
  757. package/dist/types/pieces/reactor/lib/documents.test.d.ts.map +1 -0
  758. package/dist/types/pieces/reactor/lib/input-props.d.ts +5 -0
  759. package/dist/types/pieces/reactor/lib/input-props.d.ts.map +1 -0
  760. package/dist/types/pieces/reactor/lib/input-props.test.d.ts +2 -0
  761. package/dist/types/pieces/reactor/lib/input-props.test.d.ts.map +1 -0
  762. package/dist/types/pieces/reactor/lib/input-schema.d.ts +31 -0
  763. package/dist/types/pieces/reactor/lib/input-schema.d.ts.map +1 -0
  764. package/dist/types/pieces/reactor/lib/input-schema.test.d.ts +2 -0
  765. package/dist/types/pieces/reactor/lib/input-schema.test.d.ts.map +1 -0
  766. package/dist/types/pieces/reactor/lib/logo.d.ts +2 -0
  767. package/dist/types/pieces/reactor/lib/logo.d.ts.map +1 -0
  768. package/dist/types/pieces/reactor/lib/parse.d.ts +40 -0
  769. package/dist/types/pieces/reactor/lib/parse.d.ts.map +1 -0
  770. package/dist/types/pieces/reactor/lib/parse.test.d.ts +2 -0
  771. package/dist/types/pieces/reactor/lib/parse.test.d.ts.map +1 -0
  772. package/dist/types/pieces/reactor/lib/reactor.d.ts +55 -0
  773. package/dist/types/pieces/reactor/lib/reactor.d.ts.map +1 -0
  774. package/dist/types/pieces/reactor/lib/schema-text.d.ts +7 -0
  775. package/dist/types/pieces/reactor/lib/schema-text.d.ts.map +1 -0
  776. package/dist/types/pieces/reactor/lib/schema-text.test.d.ts +2 -0
  777. package/dist/types/pieces/reactor/lib/schema-text.test.d.ts.map +1 -0
  778. package/dist/types/pieces/reactor/lib/triggers/document-event.d.ts +45 -0
  779. package/dist/types/pieces/reactor/lib/triggers/document-event.d.ts.map +1 -0
  780. package/dist/types/pieces/reactor/lib/writes.d.ts +7 -0
  781. package/dist/types/pieces/reactor/lib/writes.d.ts.map +1 -0
  782. package/dist/types/pieces/reactor/reactor.test.d.ts +2 -0
  783. package/dist/types/pieces/reactor/reactor.test.d.ts.map +1 -0
  784. package/dist/types/pieces/reactor/test-signer.d.ts +3 -0
  785. package/dist/types/pieces/reactor/test-signer.d.ts.map +1 -0
  786. package/dist/types/playwright.config.d.ts +3 -0
  787. package/dist/types/playwright.config.d.ts.map +1 -0
  788. package/dist/types/reactor/index.d.ts +5 -0
  789. package/dist/types/reactor/index.d.ts.map +1 -0
  790. package/dist/types/scripts/ui-shots.d.ts +2 -0
  791. package/dist/types/scripts/ui-shots.d.ts.map +1 -0
  792. package/dist/types/scripts/ui-stack.d.ts +217 -0
  793. package/dist/types/scripts/ui-stack.d.ts.map +1 -0
  794. package/dist/types/test/graphql-server.d.ts +9 -0
  795. package/dist/types/test/graphql-server.d.ts.map +1 -0
  796. package/dist/types/test/runtime-schema.d.ts +17 -0
  797. package/dist/types/test/runtime-schema.d.ts.map +1 -0
  798. package/dist/types/test/switchboards.d.ts +20 -0
  799. package/dist/types/test/switchboards.d.ts.map +1 -0
  800. package/dist/types/test/ui/block-picker.spec.d.ts +2 -0
  801. package/dist/types/test/ui/block-picker.spec.d.ts.map +1 -0
  802. package/dist/types/test/ui/branch.spec.d.ts +2 -0
  803. package/dist/types/test/ui/branch.spec.d.ts.map +1 -0
  804. package/dist/types/test/ui/canvas-logos.spec.d.ts +2 -0
  805. package/dist/types/test/ui/canvas-logos.spec.d.ts.map +1 -0
  806. package/dist/types/test/ui/connection-editor.spec.d.ts +2 -0
  807. package/dist/types/test/ui/connection-editor.spec.d.ts.map +1 -0
  808. package/dist/types/test/ui/data-viewer.spec.d.ts +2 -0
  809. package/dist/types/test/ui/data-viewer.spec.d.ts.map +1 -0
  810. package/dist/types/test/ui/fixtures.d.ts +14 -0
  811. package/dist/types/test/ui/fixtures.d.ts.map +1 -0
  812. package/dist/types/test/ui/flow-control.spec.d.ts +2 -0
  813. package/dist/types/test/ui/flow-control.spec.d.ts.map +1 -0
  814. package/dist/types/test/ui/global-setup.d.ts +2 -0
  815. package/dist/types/test/ui/global-setup.d.ts.map +1 -0
  816. package/dist/types/test/ui/harness/prop-controls.d.ts +6 -0
  817. package/dist/types/test/ui/harness/prop-controls.d.ts.map +1 -0
  818. package/dist/types/test/ui/harness/property-form-echo.d.ts +12 -0
  819. package/dist/types/test/ui/harness/property-form-echo.d.ts.map +1 -0
  820. package/dist/types/test/ui/harness/schedule-builder.d.ts +8 -0
  821. package/dist/types/test/ui/harness/schedule-builder.d.ts.map +1 -0
  822. package/dist/types/test/ui/manual-inputs.spec.d.ts +2 -0
  823. package/dist/types/test/ui/manual-inputs.spec.d.ts.map +1 -0
  824. package/dist/types/test/ui/piece-version.spec.d.ts +2 -0
  825. package/dist/types/test/ui/piece-version.spec.d.ts.map +1 -0
  826. package/dist/types/test/ui/pieces.spec.d.ts +2 -0
  827. package/dist/types/test/ui/pieces.spec.d.ts.map +1 -0
  828. package/dist/types/test/ui/ports.spec.d.ts +2 -0
  829. package/dist/types/test/ui/ports.spec.d.ts.map +1 -0
  830. package/dist/types/test/ui/prop-controls.spec.d.ts +2 -0
  831. package/dist/types/test/ui/prop-controls.spec.d.ts.map +1 -0
  832. package/dist/types/test/ui/property-form-echo.spec.d.ts +2 -0
  833. package/dist/types/test/ui/property-form-echo.spec.d.ts.map +1 -0
  834. package/dist/types/test/ui/publish.spec.d.ts +2 -0
  835. package/dist/types/test/ui/publish.spec.d.ts.map +1 -0
  836. package/dist/types/test/ui/reactor-connection.spec.d.ts +2 -0
  837. package/dist/types/test/ui/reactor-connection.spec.d.ts.map +1 -0
  838. package/dist/types/test/ui/reactor-steps.spec.d.ts +2 -0
  839. package/dist/types/test/ui/reactor-steps.spec.d.ts.map +1 -0
  840. package/dist/types/test/ui/schedule-builder.spec.d.ts +2 -0
  841. package/dist/types/test/ui/schedule-builder.spec.d.ts.map +1 -0
  842. package/dist/types/test/ui/step-panel.spec.d.ts +2 -0
  843. package/dist/types/test/ui/step-panel.spec.d.ts.map +1 -0
  844. package/dist/types/test/ui/step-test.spec.d.ts +2 -0
  845. package/dist/types/test/ui/step-test.spec.d.ts.map +1 -0
  846. package/dist/types/test/ui/studio.spec.d.ts +2 -0
  847. package/dist/types/test/ui/studio.spec.d.ts.map +1 -0
  848. package/dist/types/test/ui/variables.spec.d.ts +2 -0
  849. package/dist/types/test/ui/variables.spec.d.ts.map +1 -0
  850. package/dist/types/test/ui/webhook.spec.d.ts +2 -0
  851. package/dist/types/test/ui/webhook.spec.d.ts.map +1 -0
  852. package/dist/types/test/ui/workflow-menu.spec.d.ts +2 -0
  853. package/dist/types/test/ui/workflow-menu.spec.d.ts.map +1 -0
  854. package/dist/types/test/waitpoint-record.d.ts +3 -0
  855. package/dist/types/test/waitpoint-record.d.ts.map +1 -0
  856. package/dist/types/vitest.config.d.ts +3 -0
  857. package/dist/types/vitest.config.d.ts.map +1 -0
  858. package/dist/workflow.css +68 -0
  859. package/package.json +146 -0
@@ -0,0 +1,4669 @@
1
+ import { h as REACTOR_CONNECTOR_ID, x as actions } from "./module-DJz6oTX0.js";
2
+ import { t as useConnectionDocumentById } from "./connection-ilYFCRUK.js";
3
+ import { i as connectorIdForPiece, l as planFromAuth, s as packageFromConnectorId } from "./piece-auth-63iuNFTs.js";
4
+ import { $ as triggerFields, Q as triggerBlock, V as STEP_PRESETS, W as TRIGGER_PRESETS, X as stepBlock, Y as sameBlock, Z as stepFields, b as realRuns, f as stepOutputTreeQuery, g as blockRefKey, i as outputTreeQuery, j as CALLABLE_FLOW_TRIGGER$1, n as catalogQuery, q as isCoreBlock, u as runsQuery, y as TEST_TRIGGER_KIND } from "./runtime-queries-FmEzElOY.js";
5
+ import { _ as reducer, y as actions$1 } from "./module-mFCt9WHJ.js";
6
+ import { t as useSelectedWorkflowDocument } from "./workflow-2gR2JXUS.js";
7
+ import { At as Button, B as DesignTimeProvider, C as TONE_DOT, Ct as useRuntime, D as formatAbsolute, Ft as Segmented, G as useBlockResolutions, H as useBlockFormLoader, Ht as textAreaClass, It as Select, J as useDesignTime, K as useCachedBlockForm, Kt as DocumentErrorBoundary, Lt as Switch, M as formatWhen, Mt as FieldLabel, Nt as Hint, O as formatDuration, Ot as useSearchParam, Pt as IconButton, Q as useLatestRun, R as toneOf, Rt as Tabs, St as useRunsQuery, U as useBlockForms, Ut as textInputClass, V as useBlockForm, W as useBlockPorts, Wt as Icon, X as useDynamicLookup, Z as useDynamicPrefetch, _ as useBlockMeta, a as BlockResolutionsProvider, at as blockMissing, c as runsDifferentVersion, d as versionBadge, dt as storedSchema, g as stepSubtitle, gt as WorkflowRuntimeProvider, h as pieceLogo, ht as workflowReadiness, i as PickerPopover, it as useWebhookEndpoint, jt as FieldError, l as updateVersion, lt as resolverInputFor, m as pieceDisplayName, n as BlockSelector, nt as useTestStepRunner, o as VersionSummary, p as namedByCoreTab, pt as undeclaredPortIssues, q as useConnectionList, r as PICKER_SIZE, rt as useTestTrigger, s as resolutionText, st as isPropVisible, t as BlockLogo, tt as useRunById, u as useResolution, ut as settingFor, v as usePieceLogos, w as TONE_TEXT, wt as useRuntimeActions, x as RUN_TONE } from "./BlockSelector-CEdYUqjx.js";
8
+ import { _ as newUndoGroup, a as useSignInGate, f as connectionCallbacks, g as groupedAction, h as documentCapabilities, i as useReactorAccessDenial, l as reactorConnections, m as UndoRedo, n as SignInPrompt, o as missingInPublished, p as BackButton, r as usePublisher, s as runsAsText, t as ConnectionForm } from "./connection-form-Biksq2jW.js";
9
+ import { A as ExpressionTargetProvider, B as documentShape, C as PropertyForm, D as ExpressionPickerButton, E as useSecretRef, F as VARIABLE_TYPES, G as usePendingEcho, H as contextMenuItems, I as VARIABLE_TYPE_LABEL, L as convertVariableValue, M as useExpressionField, N as EMPTY_SCOPE, O as ExpressionPickerPopup, P as buildExpressionScope, R as parseTypedValue, S as PiecePlaceholderContext, T as withPropDefaults, U as menuHeight, V as stateFieldsFromSdl, W as menuPosition, _ as STEP_PARAM, a as StepError, b as uniqueStepKey, d as PublishButton, f as PublishState, g as usePublish, h as StatusToggle, i as DataViewer, j as ExpressionTokenLine, k as ExpressionScopeSourceProvider, l as DraftBanner, m as ReactorDenialNote, n as describeSchedule, p as PublishedMissingNote, r as describeTrigger, s as graphLayout, t as describeCron, u as ManagedBanner, v as VARIABLES_VIEW, w as lacksDefaults, x as AvailableSoon, y as hasDraftChanges, z as valueMismatch } from "./trigger-text-DH6HIeoa.js";
10
+ import { generateId } from "document-model";
11
+ import { addDocument, dispatchActions, useDocumentModelModules, useDocumentSafe, useFileNodesInSelectedDrive, useSelectedDriveId } from "@powerhousedao/reactor-browser";
12
+ import { DEFAULT_TIMEZONE, flowPorts, knownPorts, parseScheduleConfig, scheduleConfigIssue, stepPortLabel, stepPorts } from "@powerhousedao/pieces-framework/workflow";
13
+ import { createContext, useCallback, useContext, useEffect, useId, useMemo, useRef, useState, useSyncExternalStore } from "react";
14
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
15
+ import { Modal } from "@powerhousedao/design-system/connect";
16
+ import { Background, BaseEdge, Controls, EdgeLabelRenderer, Handle, MiniMap, Position, ReactFlow, getSmoothStepPath } from "@xyflow/react";
17
+ //#region editors/workflow-editor/undo-policy.ts
18
+ function placesBlock(edit, id) {
19
+ if (edit.type !== "ADD_STEP" && edit.type !== "SET_TRIGGER") return false;
20
+ return edit.input?.id === id;
21
+ }
22
+ const WORKFLOW_UNDO = {
23
+ skip: /* @__PURE__ */ new Set(["SET_LAST_TEST", "SET_LAST_RUN"]),
24
+ replay: (action, undone) => {
25
+ if (action.type === "SET_LAST_TEST") {
26
+ const input = action.input;
27
+ return undone.some((edit) => placesBlock(edit, input.id)) ? void 0 : actions$1.setLastTest(input);
28
+ }
29
+ if (action.type === "SET_LAST_RUN") return actions$1.setLastRun(action.input);
30
+ }
31
+ };
32
+ //#endregion
33
+ //#region editors/workflow-editor/ui/add-follow-up.ts
34
+ function followUpConfig(form, config) {
35
+ return lacksDefaults(form.props, config) ? withPropDefaults(form.props, config) : null;
36
+ }
37
+ function planFollowUp(added, current, edges, form) {
38
+ if (!current || !sameBlock(current.block, added.block)) return null;
39
+ const config = followUpConfig(form, current.config);
40
+ const port = form.ports ? flowPorts(form.ports)[0] : void 0;
41
+ const edge = added.continuation ? edges.find((entry) => entry.id === added.continuation.edgeId) : void 0;
42
+ const repoint = edge && port && edge.port !== port && edge.port === added.continuation.port ? {
43
+ edge,
44
+ port
45
+ } : void 0;
46
+ if (!config && !repoint) return null;
47
+ return {
48
+ ...config ? { config } : {},
49
+ ...repoint ? { repoint } : {}
50
+ };
51
+ }
52
+ //#endregion
53
+ //#region editors/workflow-editor/document/useWorkflowModel.ts
54
+ const FOLLOW_UP_ATTEMPTS = 20;
55
+ const FOLLOW_UP_WAIT_MS = 50;
56
+ function blockState(block) {
57
+ return {
58
+ propertySettings: block.propertySettings?.map((setting) => ({
59
+ prop: setting.prop,
60
+ mode: setting.mode,
61
+ schema: setting.schema ?? null
62
+ })),
63
+ lastTest: block.lastTest ? {
64
+ runId: block.lastTest.runId,
65
+ testedAt: block.lastTest.testedAt
66
+ } : null,
67
+ updatedAt: block.updatedAt ?? null
68
+ };
69
+ }
70
+ function settingsInput(settings) {
71
+ return settings.map((setting) => ({
72
+ prop: setting.prop,
73
+ mode: setting.mode,
74
+ schema: setting.schema ?? null
75
+ }));
76
+ }
77
+ function toModel(state) {
78
+ return {
79
+ name: state.name,
80
+ description: state.description ?? null,
81
+ status: state.status,
82
+ version: state.version,
83
+ defaultRetryAttempts: state.policy.defaultRetry.maxAttempts,
84
+ published: state.published ? {
85
+ version: state.published.version,
86
+ publishedAt: state.published.publishedAt,
87
+ blocks: [...state.published.trigger ? [{
88
+ id: state.published.trigger.id,
89
+ label: "Trigger",
90
+ pieceName: state.published.trigger.pieceName,
91
+ pieceVersion: state.published.trigger.pieceVersion,
92
+ kind: "trigger",
93
+ name: state.published.trigger.triggerName,
94
+ reactorConnectionId: state.published.trigger.reactorConnectionId ?? null
95
+ }] : [], ...state.published.steps.map((step) => ({
96
+ id: step.id,
97
+ label: step.name || step.key,
98
+ pieceName: step.pieceName,
99
+ pieceVersion: step.pieceVersion,
100
+ kind: "action",
101
+ name: step.actionName,
102
+ reactorConnectionId: step.reactorConnectionId ?? null
103
+ }))]
104
+ } : null,
105
+ readOnly: Boolean(state.managedBy),
106
+ managedBy: state.managedBy ?? null,
107
+ trigger: state.trigger ? {
108
+ id: state.trigger.id,
109
+ pieceName: state.trigger.pieceName,
110
+ pieceVersion: state.trigger.pieceVersion,
111
+ triggerName: state.trigger.triggerName,
112
+ config: state.trigger.config,
113
+ connectionId: state.trigger.connectionId ?? null,
114
+ reactorConnectionId: state.trigger.reactorConnectionId ?? null,
115
+ ...blockState(state.trigger)
116
+ } : null,
117
+ steps: state.steps.map((step) => ({
118
+ id: step.id,
119
+ key: step.key,
120
+ name: step.name,
121
+ pieceName: step.pieceName,
122
+ pieceVersion: step.pieceVersion,
123
+ actionName: step.actionName,
124
+ connectionId: step.connectionId ?? null,
125
+ reactorConnectionId: step.reactorConnectionId ?? null,
126
+ config: step.config,
127
+ retry: step.retry ? {
128
+ maxAttempts: step.retry.maxAttempts,
129
+ backoff: step.retry.backoff,
130
+ initialDelaySeconds: step.retry.initialDelaySeconds,
131
+ maxDelaySeconds: step.retry.maxDelaySeconds,
132
+ retryOn: [...step.retry.retryOn]
133
+ } : null,
134
+ timeoutSeconds: step.timeoutSeconds ?? null,
135
+ idempotencyKeyExpression: step.idempotencyKeyExpression ?? null,
136
+ position: step.position ? {
137
+ x: step.position.x,
138
+ y: step.position.y
139
+ } : null,
140
+ skip: step.skip === true,
141
+ ...blockState(step)
142
+ })),
143
+ edges: state.edges.map((edge) => ({
144
+ id: edge.id,
145
+ from: edge.from,
146
+ to: edge.to,
147
+ port: edge.port,
148
+ condition: edge.condition ?? null
149
+ })),
150
+ variables: state.variables.map((variable) => ({
151
+ id: variable.id,
152
+ key: variable.key,
153
+ value: variable.value ?? null,
154
+ description: variable.description ?? null,
155
+ type: variable.type ?? null
156
+ }))
157
+ };
158
+ }
159
+ function useWorkflowModel() {
160
+ const [document, write] = useSelectedWorkflowDocument();
161
+ const state = document.state.global;
162
+ const caps = documentCapabilities(document.header, document.operations.document?.[0]);
163
+ const managed = Boolean(state.managedBy);
164
+ const dispatch = useMemo(() => managed ? (() => void 0) : write, [managed, write]);
165
+ const latest = useRef(state);
166
+ latest.current = state;
167
+ return {
168
+ model: useMemo(() => toModel(state), [state]),
169
+ callbacks: useMemo(() => ({
170
+ setName: (name) => {
171
+ dispatch(actions$1.setWorkflowName({ name }));
172
+ dispatch(actions$1.setName(name));
173
+ },
174
+ setDescription: (description) => dispatch(actions$1.setWorkflowDescription({ description })),
175
+ setStatus: (status) => dispatch(actions$1.setWorkflowStatus({ status })),
176
+ setTrigger: (input) => {
177
+ const id = state.trigger?.id ?? generateId();
178
+ const group = newUndoGroup(caps);
179
+ dispatch(groupedAction(actions$1.setTrigger({
180
+ id,
181
+ pieceName: input.pieceName,
182
+ pieceVersion: input.pieceVersion,
183
+ triggerName: input.triggerName,
184
+ config: input.config,
185
+ connectionId: input.connectionId,
186
+ reactorConnectionId: input.reactorConnectionId,
187
+ ...input.propertySettings ? { propertySettings: settingsInput(input.propertySettings) } : {}
188
+ }), group, caps));
189
+ return {
190
+ id,
191
+ group,
192
+ block: triggerBlock(input)
193
+ };
194
+ },
195
+ setTriggerConfig: (config, extras) => dispatch(actions$1.setTriggerConfig({
196
+ config,
197
+ ...extras?.propertySettings ? { propertySettings: settingsInput(extras.propertySettings) } : {}
198
+ })),
199
+ setTriggerConnection: (input) => dispatch(actions$1.setTriggerConnection(input)),
200
+ setTriggerPieceVersion: (pieceVersion) => dispatch(actions$1.setTriggerPieceVersion({ pieceVersion })),
201
+ clearTrigger: () => dispatch(actions$1.clearTrigger({})),
202
+ addStep: (input) => {
203
+ const id = generateId();
204
+ const group = newUndoGroup(caps);
205
+ dispatch(groupedAction(actions$1.addStep({
206
+ id,
207
+ key: input.key,
208
+ name: input.name,
209
+ pieceName: input.pieceName,
210
+ pieceVersion: input.pieceVersion,
211
+ actionName: input.actionName,
212
+ config: input.config,
213
+ position: input.position
214
+ }), group, caps));
215
+ return {
216
+ id,
217
+ group,
218
+ block: stepBlock(input)
219
+ };
220
+ },
221
+ updateStep: (input) => dispatch(actions$1.updateStep(input)),
222
+ setStepConfig: (id, config, extras) => dispatch(actions$1.setStepConfig({
223
+ id,
224
+ config,
225
+ ...extras?.propertySettings ? { propertySettings: settingsInput(extras.propertySettings) } : {}
226
+ })),
227
+ publish: () => new Promise((resolve, reject) => {
228
+ const publish = actions$1.publishWorkflow({ publishedAt: (/* @__PURE__ */ new Date()).toISOString() });
229
+ const batch = state.status === "ENABLED" ? [publish] : [publish, actions$1.setWorkflowStatus({ status: "ENABLED" })];
230
+ dispatch(batch, (errors) => reject(errors[0]), () => resolve());
231
+ }),
232
+ discardChanges: () => dispatch(actions$1.revertToPublished({})),
233
+ removeStep: (id) => dispatch(actions$1.removeStep({ id })),
234
+ addEdge: (input) => dispatch(actions$1.addEdge({
235
+ id: generateId(),
236
+ from: input.from,
237
+ to: input.to,
238
+ port: input.port,
239
+ condition: input.condition
240
+ })),
241
+ removeEdge: (id) => dispatch(actions$1.removeEdge({ id })),
242
+ moveStep: (move) => {
243
+ for (const edge of state.edges.filter((entry) => entry.to === move.stepId)) dispatch(actions$1.removeEdge({ id: edge.id }));
244
+ dispatch(actions$1.addEdge({
245
+ id: generateId(),
246
+ from: move.toParentId,
247
+ to: move.stepId,
248
+ port: move.port
249
+ }));
250
+ },
251
+ setVariable: (input) => dispatch(actions$1.setVariable({
252
+ id: input.id ?? generateId(),
253
+ key: input.key,
254
+ value: input.value,
255
+ description: input.description,
256
+ ...input.type !== void 0 ? { type: input.type } : {}
257
+ })),
258
+ removeVariable: (id) => dispatch(actions$1.removeVariable({ id })),
259
+ insertStepOnEdge: (edgeId, input, port) => {
260
+ const edge = state.edges.find((entry) => entry.id === edgeId);
261
+ if (!edge) return void 0;
262
+ const stepId = generateId();
263
+ const continuing = generateId();
264
+ const group = newUndoGroup(caps);
265
+ dispatch([
266
+ actions$1.addStep({
267
+ id: stepId,
268
+ key: input.key,
269
+ name: input.name,
270
+ pieceName: input.pieceName,
271
+ pieceVersion: input.pieceVersion,
272
+ actionName: input.actionName,
273
+ config: input.config
274
+ }),
275
+ actions$1.removeEdge({ id: edgeId }),
276
+ actions$1.addEdge({
277
+ id: generateId(),
278
+ from: edge.from,
279
+ to: stepId,
280
+ port: edge.port,
281
+ condition: edge.condition
282
+ }),
283
+ actions$1.addEdge({
284
+ id: continuing,
285
+ from: stepId,
286
+ to: edge.to,
287
+ port
288
+ })
289
+ ].map((action) => groupedAction(action, group, caps)));
290
+ return {
291
+ id: stepId,
292
+ group,
293
+ block: stepBlock(input),
294
+ continuation: {
295
+ edgeId: continuing,
296
+ port
297
+ }
298
+ };
299
+ },
300
+ duplicateStep: (id) => {
301
+ const step = state.steps.find((entry) => entry.id === id);
302
+ if (!step) return;
303
+ dispatch(actions$1.addStep({
304
+ id: generateId(),
305
+ key: uniqueStepKey(state.steps.map((entry) => entry.key), step.key),
306
+ name: step.name,
307
+ pieceName: step.pieceName,
308
+ pieceVersion: step.pieceVersion,
309
+ actionName: step.actionName,
310
+ connectionId: step.connectionId,
311
+ reactorConnectionId: step.reactorConnectionId,
312
+ config: step.config,
313
+ retry: step.retry,
314
+ timeoutSeconds: step.timeoutSeconds,
315
+ idempotencyKeyExpression: step.idempotencyKeyExpression,
316
+ position: step.position,
317
+ propertySettings: step.propertySettings
318
+ }));
319
+ },
320
+ appendStep: (fromId, port, input) => {
321
+ const stepId = generateId();
322
+ const group = newUndoGroup(caps);
323
+ dispatch([actions$1.addStep({
324
+ id: stepId,
325
+ key: input.key,
326
+ name: input.name,
327
+ pieceName: input.pieceName,
328
+ pieceVersion: input.pieceVersion,
329
+ actionName: input.actionName,
330
+ config: input.config
331
+ }), actions$1.addEdge({
332
+ id: generateId(),
333
+ from: fromId,
334
+ to: stepId,
335
+ port
336
+ })].map((action) => groupedAction(action, group, caps)));
337
+ return {
338
+ id: stepId,
339
+ group,
340
+ block: stepBlock(input)
341
+ };
342
+ },
343
+ completeBlock: (added, form) => {
344
+ let attempts = 0;
345
+ const attempt = () => {
346
+ const current = latest.current;
347
+ const found = findBlock(current, added);
348
+ if (!found && attempts++ < FOLLOW_UP_ATTEMPTS) {
349
+ setTimeout(attempt, FOLLOW_UP_WAIT_MS);
350
+ return;
351
+ }
352
+ const plan = planFollowUp(added, found, current.edges, form);
353
+ if (!plan) return;
354
+ const trigger = current.trigger;
355
+ const followUps = [...plan.config && trigger?.id === added.id ? [actions$1.setTriggerConfig({ config: plan.config })] : plan.config ? [actions$1.setStepConfig({
356
+ id: added.id,
357
+ config: plan.config
358
+ })] : [], ...plan.repoint ? [actions$1.removeEdge({ id: plan.repoint.edge.id }), actions$1.addEdge({
359
+ id: generateId(),
360
+ from: plan.repoint.edge.from,
361
+ to: plan.repoint.edge.to,
362
+ port: plan.repoint.port,
363
+ condition: plan.repoint.edge.condition
364
+ })] : []];
365
+ dispatch(followUps.map((action) => groupedAction(action, added.group, caps)));
366
+ };
367
+ attempt();
368
+ }
369
+ }), [
370
+ dispatch,
371
+ state,
372
+ caps
373
+ ])
374
+ };
375
+ }
376
+ function findBlock(state, added) {
377
+ if (state.trigger?.id === added.id) return {
378
+ block: triggerBlock(state.trigger),
379
+ config: state.trigger.config
380
+ };
381
+ const step = state.steps.find((entry) => entry.id === added.id);
382
+ return step ? {
383
+ block: stepBlock(step),
384
+ config: step.config
385
+ } : void 0;
386
+ }
387
+ const PANEL_DEFAULT_WIDTH = 416;
388
+ const PANEL_MAX_SHARE = .7;
389
+ const KEY_STEP = 16;
390
+ const STORAGE_KEY = "workflow-editor:panel-width";
391
+ function clampWidth(width) {
392
+ const max = Math.max(352, Math.floor(window.innerWidth * PANEL_MAX_SHARE));
393
+ return Math.min(max, Math.max(352, Math.round(width)));
394
+ }
395
+ function storedWidth() {
396
+ try {
397
+ const stored = Number(window.localStorage.getItem(STORAGE_KEY));
398
+ return stored > 0 ? clampWidth(stored) : PANEL_DEFAULT_WIDTH;
399
+ } catch {
400
+ return PANEL_DEFAULT_WIDTH;
401
+ }
402
+ }
403
+ function storeWidth(width) {
404
+ try {
405
+ window.localStorage.setItem(STORAGE_KEY, String(width));
406
+ } catch {}
407
+ }
408
+ /** The side panel's width, remembered per browser. */
409
+ function usePanelWidth() {
410
+ const [width, setWidth] = useState(storedWidth);
411
+ const resize = (next, persist) => {
412
+ const clamped = clampWidth(next);
413
+ setWidth(clamped);
414
+ if (persist) storeWidth(clamped);
415
+ };
416
+ return {
417
+ width,
418
+ resize
419
+ };
420
+ }
421
+ /** A drag handle on the panel's left edge; arrow keys resize it too. */
422
+ function PanelResizer(props) {
423
+ const [dragging, setDragging] = useState(false);
424
+ const onPointerDown = (event) => {
425
+ if (event.button !== 0) return;
426
+ event.preventDefault();
427
+ const handle = event.currentTarget;
428
+ handle.setPointerCapture(event.pointerId);
429
+ const startX = event.clientX;
430
+ const startWidth = props.width;
431
+ const widthAt = (x) => startWidth + (startX - x);
432
+ const move = (e) => props.onResize(widthAt(e.clientX), false);
433
+ const up = (e) => {
434
+ props.onResize(widthAt(e.clientX), true);
435
+ setDragging(false);
436
+ handle.removeEventListener("pointermove", move);
437
+ handle.removeEventListener("pointerup", up);
438
+ handle.removeEventListener("pointercancel", up);
439
+ };
440
+ setDragging(true);
441
+ handle.addEventListener("pointermove", move);
442
+ handle.addEventListener("pointerup", up);
443
+ handle.addEventListener("pointercancel", up);
444
+ };
445
+ const onKeyDown = (event) => {
446
+ const delta = event.key === "ArrowLeft" ? KEY_STEP : event.key === "ArrowRight" ? -16 : 0;
447
+ if (!delta) return;
448
+ event.preventDefault();
449
+ props.onResize(props.width + delta, true);
450
+ };
451
+ return /* @__PURE__ */ jsx("div", {
452
+ role: "separator",
453
+ "aria-orientation": "vertical",
454
+ "aria-label": "Resize panel",
455
+ "aria-valuenow": props.width,
456
+ "aria-valuemin": 352,
457
+ tabIndex: 0,
458
+ onPointerDown,
459
+ onKeyDown,
460
+ onDoubleClick: () => props.onResize(PANEL_DEFAULT_WIDTH, true),
461
+ className: `absolute inset-y-0 -left-1 z-20 w-2 cursor-col-resize touch-none outline-none after:absolute after:inset-y-0 after:left-[3px] after:w-0.5 after:transition-colors hover:after:bg-ring/60 focus-visible:after:bg-ring ${dragging ? "after:bg-ring" : ""}`
462
+ });
463
+ }
464
+ //#endregion
465
+ //#region editors/workflow-editor/ui/ap-layout.ts
466
+ function reachableFrom(start, edges) {
467
+ const outgoing = /* @__PURE__ */ new Map();
468
+ for (const edge of edges) {
469
+ const list = outgoing.get(edge.from) ?? [];
470
+ list.push(edge.to);
471
+ outgoing.set(edge.from, list);
472
+ }
473
+ const seen = /* @__PURE__ */ new Set([start]);
474
+ const queue = [start];
475
+ while (queue.length > 0) for (const next of outgoing.get(queue.pop()) ?? []) if (!seen.has(next)) {
476
+ seen.add(next);
477
+ queue.push(next);
478
+ }
479
+ return seen;
480
+ }
481
+ function acyclicTargets(model, fromId) {
482
+ return model.steps.filter((step) => step.id !== fromId && !reachableFrom(step.id, model.edges).has(fromId));
483
+ }
484
+ function attachableSteps(model, fromId) {
485
+ if (!model.trigger) return [];
486
+ const attached = reachableFrom(model.trigger.id, model.edges);
487
+ return model.steps.filter((step) => !attached.has(step.id) && step.id !== fromId && !reachableFrom(step.id, model.edges).has(fromId));
488
+ }
489
+ const PORT_ORDER = [
490
+ "each",
491
+ "next",
492
+ "true",
493
+ "false"
494
+ ];
495
+ function portRank(port) {
496
+ const index = PORT_ORDER.indexOf(port);
497
+ if (index !== -1) return index;
498
+ const branch = /^branch_(\d+)$/.exec(port);
499
+ if (branch) return PORT_ORDER.length + 1 - 1 / Number(branch[1]);
500
+ if (port === "otherwise") return PORT_ORDER.length + 1;
501
+ if (port === "error") return PORT_ORDER.length + 2;
502
+ return PORT_ORDER.length + 3;
503
+ }
504
+ function layoutWorkflow(model, portsOf = () => void 0) {
505
+ const nodes = [];
506
+ const edges = [];
507
+ if (!model.trigger) {
508
+ nodes.push({
509
+ id: "__big-add",
510
+ type: "apBigButton",
511
+ position: {
512
+ x: -25,
513
+ y: 0
514
+ },
515
+ data: {},
516
+ draggable: false,
517
+ selectable: false
518
+ });
519
+ return {
520
+ nodes,
521
+ edges
522
+ };
523
+ }
524
+ const stepIds = new Set(model.steps.map((step) => step.id));
525
+ const outgoing = /* @__PURE__ */ new Map();
526
+ for (const edge of model.edges) {
527
+ if (!stepIds.has(edge.to)) continue;
528
+ const list = outgoing.get(edge.from) ?? [];
529
+ list.push(edge);
530
+ outgoing.set(edge.from, list);
531
+ }
532
+ for (const list of outgoing.values()) list.sort((a, b) => portRank(a.port) - portRank(b.port));
533
+ const stepById = new Map(model.steps.map((step) => [step.id, step]));
534
+ const declared = (id) => {
535
+ const step = stepById.get(id);
536
+ if (id === model.trigger?.id) return portsOf(triggerBlock(model.trigger));
537
+ const wired = (outgoing.get(id) ?? []).map((edge) => edge.port);
538
+ return step ? stepPorts(stepBlock(step), step.config, portsOf, wired) : void 0;
539
+ };
540
+ const labelOf = (id, port) => {
541
+ const step = stepById.get(id);
542
+ return step ? stepPortLabel(stepBlock(step), step.config, port) : void 0;
543
+ };
544
+ const outPorts = (id) => {
545
+ const ports = declared(id);
546
+ return ports ? flowPorts(ports) : [];
547
+ };
548
+ const branchPorts = (id) => {
549
+ const ports = outPorts(id);
550
+ return ports.length > 1 ? ports : [];
551
+ };
552
+ const reachable = reachableFrom(model.trigger.id, model.edges);
553
+ const via = /* @__PURE__ */ new Map();
554
+ for (const node of graphLayout({
555
+ triggerId: model.trigger.id,
556
+ steps: model.steps,
557
+ edges: model.edges
558
+ }).nodes) if (node.via) via.set(node.step.id, node.via);
559
+ const pending = /* @__PURE__ */ new Map();
560
+ for (const list of outgoing.values()) for (const edge of list) {
561
+ if (!reachable.has(edge.from)) continue;
562
+ pending.set(edge.to, (pending.get(edge.to) ?? 0) + 1);
563
+ }
564
+ const owner = /* @__PURE__ */ new Map();
565
+ const row = /* @__PURE__ */ new Map();
566
+ const visited = /* @__PURE__ */ new Set();
567
+ const visit = (id, gated) => {
568
+ visited.add(id);
569
+ for (const edge of outgoing.get(id) ?? []) {
570
+ if (visited.has(edge.to)) continue;
571
+ const below = row.get(id) + 1;
572
+ row.set(edge.to, gated ? Math.max(row.get(edge.to) ?? 0, below) : below);
573
+ if (gated) {
574
+ const left = pending.get(edge.to) - 1;
575
+ pending.set(edge.to, left);
576
+ if (left > 0) continue;
577
+ }
578
+ const parent = gated ? via.get(edge.to) : void 0;
579
+ const wired = parent && outgoing.get(parent.from)?.includes(parent);
580
+ owner.set(edge.to, wired ? parent : edge);
581
+ visit(edge.to, gated);
582
+ }
583
+ };
584
+ row.set(model.trigger.id, 0);
585
+ visit(model.trigger.id, true);
586
+ const roots = [];
587
+ for (const step of model.steps) {
588
+ if (visited.has(step.id)) continue;
589
+ roots.push(step.id);
590
+ row.set(step.id, 0);
591
+ visit(step.id, false);
592
+ }
593
+ const owns = (edge) => owner.get(edge.to) === edge;
594
+ const outletsOf = (id) => {
595
+ const edges = outgoing.get(id) ?? [];
596
+ const ports = branchPorts(id);
597
+ if (ports.length === 0) return edges.map((edge) => ({
598
+ port: edge.port,
599
+ edge
600
+ }));
601
+ const wired = new Set(edges.map((edge) => edge.port));
602
+ return [...edges.map((edge) => ({
603
+ port: edge.port,
604
+ edge
605
+ })), ...ports.filter((port) => !wired.has(port)).map((port) => ({ port }))].sort((a, b) => portRank(a.port) - portRank(b.port));
606
+ };
607
+ const subtreeWidth = (id) => {
608
+ const outlets = outletsOf(id);
609
+ if (outlets.length === 0) return 232;
610
+ const total = outlets.map((outlet) => outlet.edge && owns(outlet.edge) ? subtreeWidth(outlet.edge.to) : 232).reduce((sum, width) => sum + width, 0);
611
+ return Math.max(232, total + (outlets.length - 1) * 80);
612
+ };
613
+ const placeholders = /* @__PURE__ */ new Map();
614
+ const lanes = /* @__PURE__ */ new Map();
615
+ const ROW = 120;
616
+ const place = (id, centerX, top) => {
617
+ const step = stepById.get(id);
618
+ const isTrigger = id === model.trigger?.id;
619
+ const y = top + row.get(id) * ROW;
620
+ nodes.push({
621
+ id,
622
+ type: "apStep",
623
+ position: {
624
+ x: centerX - 116,
625
+ y
626
+ },
627
+ data: {
628
+ ...isTrigger ? {
629
+ kind: "trigger",
630
+ trigger: model.trigger
631
+ } : {
632
+ kind: "step",
633
+ step
634
+ },
635
+ outgoingPorts: model.edges.filter((edge) => edge.from === id).map((edge) => edge.port)
636
+ },
637
+ draggable: false
638
+ });
639
+ const outlets = outletsOf(id);
640
+ const widths = outlets.map((outlet) => outlet.edge && owns(outlet.edge) ? subtreeWidth(outlet.edge.to) : 232);
641
+ let cursor = centerX - (widths.reduce((sum, width) => sum + width, 0) + Math.max(outlets.length - 1, 0) * 80) / 2;
642
+ outlets.forEach((outlet, index) => {
643
+ const slotCenter = cursor + widths[index] / 2;
644
+ if (outlet.edge) {
645
+ lanes.set(outlet.edge.id, slotCenter);
646
+ if (owns(outlet.edge)) place(outlet.edge.to, slotCenter, top);
647
+ } else placeholders.set(`${id}:${outlet.port}`, {
648
+ x: slotCenter,
649
+ y: y + ROW
650
+ });
651
+ cursor += widths[index] + 80;
652
+ });
653
+ };
654
+ place(model.trigger.id, 0, 0);
655
+ const mainWidth = subtreeWidth(model.trigger.id);
656
+ let orphanY = 0;
657
+ for (const root of roots) {
658
+ const before = nodes.length;
659
+ place(root, mainWidth / 2 + 80 + 116, orphanY);
660
+ orphanY = Math.max(...nodes.slice(before).map((node) => node.position.y)) + ROW;
661
+ }
662
+ const nodeById = new Map(nodes.map((node) => [node.id, node]));
663
+ for (const edge of model.edges) {
664
+ if (!nodeById.has(edge.from) || !nodeById.has(edge.to)) continue;
665
+ edges.push({
666
+ id: edge.id,
667
+ type: "apEdge",
668
+ source: edge.from,
669
+ target: edge.to,
670
+ data: {
671
+ edgeId: edge.id,
672
+ port: edge.port,
673
+ portLabel: labelOf(edge.from, edge.port),
674
+ lane: lanes.get(edge.id),
675
+ condition: edge.condition,
676
+ fromSkipped: stepById.get(edge.from)?.skip === true,
677
+ dead: declared(edge.from)?.includes(edge.port) === false
678
+ },
679
+ selectable: true
680
+ });
681
+ }
682
+ const candidatePorts = outPorts;
683
+ const appendPorts = (id) => {
684
+ const used = new Set((outgoing.get(id) ?? []).map((edge) => edge.port));
685
+ return candidatePorts(id).filter((port) => !used.has(port));
686
+ };
687
+ for (const node of [...nodes]) {
688
+ if (node.type !== "apStep") continue;
689
+ appendPorts(node.id).forEach((port) => {
690
+ const slot = placeholders.get(`${node.id}:${port}`);
691
+ const buttonId = `__append:${node.id}:${port}`;
692
+ nodes.push({
693
+ id: buttonId,
694
+ type: "apAppend",
695
+ position: slot ? {
696
+ x: slot.x - 116,
697
+ y: slot.y
698
+ } : {
699
+ x: node.position.x + 116 - 10,
700
+ y: node.position.y + 60 + 30 - 10
701
+ },
702
+ data: {
703
+ parentId: node.id,
704
+ port,
705
+ portLabel: labelOf(node.id, port),
706
+ card: Boolean(slot),
707
+ ...model.steps.length === 0 ? { hint: true } : {}
708
+ },
709
+ draggable: false,
710
+ selectable: false
711
+ });
712
+ edges.push({
713
+ id: `${buttonId}:line`,
714
+ type: "apLink",
715
+ source: node.id,
716
+ target: buttonId,
717
+ data: { port },
718
+ selectable: false
719
+ });
720
+ });
721
+ }
722
+ const LOOP_PAD = 16;
723
+ const sizeOf = (node) => node.type === "apAppend" && !node.data.card ? {
724
+ width: 20,
725
+ height: 20
726
+ } : {
727
+ width: 232,
728
+ height: 60
729
+ };
730
+ const frames = [];
731
+ for (const edge of model.edges) {
732
+ if (edge.port !== "each" || !owns(edge)) continue;
733
+ const body = /* @__PURE__ */ new Set();
734
+ const collect = (id) => {
735
+ body.add(id);
736
+ for (const next of outgoing.get(id) ?? []) if (owns(next)) collect(next.to);
737
+ };
738
+ collect(edge.to);
739
+ const members = nodes.filter((node) => node.type === "apStep" ? body.has(node.id) : body.has(node.data.parentId ?? ""));
740
+ const left = Math.min(...members.map((node) => node.position.x));
741
+ const top = Math.min(...members.map((node) => node.position.y));
742
+ const right = Math.max(...members.map((node) => node.position.x + sizeOf(node).width));
743
+ const bottom = Math.max(...members.map((node) => node.position.y + sizeOf(node).height));
744
+ frames.push({
745
+ id: `__loop:${edge.from}`,
746
+ type: "apLoopFrame",
747
+ position: {
748
+ x: left - LOOP_PAD,
749
+ y: top - LOOP_PAD
750
+ },
751
+ data: {
752
+ width: right - left + 32,
753
+ height: bottom - top + 32
754
+ },
755
+ draggable: false,
756
+ selectable: false,
757
+ focusable: false,
758
+ zIndex: -1,
759
+ style: { pointerEvents: "none" }
760
+ });
761
+ }
762
+ return {
763
+ nodes: [...frames, ...nodes],
764
+ edges
765
+ };
766
+ }
767
+ function flowOrder(model) {
768
+ const stepIds = new Set(model.steps.map((step) => step.id));
769
+ const seen = /* @__PURE__ */ new Set();
770
+ const order = [];
771
+ const visit = (from) => {
772
+ const next = model.edges.filter((edge) => edge.from === from && stepIds.has(edge.to)).sort((a, b) => portRank(a.port) - portRank(b.port));
773
+ for (const edge of next) {
774
+ if (seen.has(edge.to)) continue;
775
+ seen.add(edge.to);
776
+ order.push(edge.to);
777
+ visit(edge.to);
778
+ }
779
+ };
780
+ if (model.trigger) visit(model.trigger.id);
781
+ for (const step of model.steps) if (!seen.has(step.id)) order.push(step.id);
782
+ return order;
783
+ }
784
+ //#endregion
785
+ //#region editors/workflow-editor/ui/connection-create.ts
786
+ const CONNECTION_TYPE = "powerhouse/connection";
787
+ function compatibleConnections(connections, block) {
788
+ return connections.filter((connection) => packageFromConnectorId(connection.connectorId) === block.pieceName);
789
+ }
790
+ function looksLikeDocumentId(value) {
791
+ const trimmed = value.trim();
792
+ return trimmed.length >= 8 && !/\s/.test(trimmed);
793
+ }
794
+ function connectionNameFor(piecePackage, displayName) {
795
+ if (displayName) return `${displayName} connection`;
796
+ return `${(piecePackage.split("/").pop()?.replace(/^piece-/, "") ?? piecePackage).split(/[-_]/).filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ") || piecePackage} connection`;
797
+ }
798
+ function connectionDraftFor(input) {
799
+ if (input.authMode === "none" || input.authMode === "loading") return null;
800
+ if (input.matchingCount > 0) return null;
801
+ if (isCoreBlock(input.block)) return null;
802
+ const piecePackage = input.block.pieceName;
803
+ return {
804
+ piecePackage,
805
+ connectorId: connectorIdForPiece(piecePackage),
806
+ name: connectionNameFor(piecePackage, pieceDisplayName(piecePackage))
807
+ };
808
+ }
809
+ //#endregion
810
+ //#region editors/workflow-editor/ui/ConnectionName.tsx
811
+ function useConnectionName(id) {
812
+ const { status, data } = useDocumentSafe(id || null);
813
+ if (!id || status === "pending") return { invalid: false };
814
+ const document = data;
815
+ if (!document) return {
816
+ name: id,
817
+ invalid: true
818
+ };
819
+ return {
820
+ name: document.state.global.name || document.header.name || id,
821
+ invalid: document.header.documentType !== CONNECTION_TYPE
822
+ };
823
+ }
824
+ function ConnectionName(props) {
825
+ if (props.name === void 0) return /* @__PURE__ */ jsx("span", {
826
+ "aria-label": "Loading connection",
827
+ className: "inline-block h-3.5 w-28 animate-pulse rounded bg-foreground/10 align-middle"
828
+ });
829
+ return /* @__PURE__ */ jsx(Fragment$1, { children: props.name });
830
+ }
831
+ //#endregion
832
+ //#region editors/workflow-editor/ui/CreateConnectionModal.tsx
833
+ function CreateConnectionModal(props) {
834
+ const [document, dispatch] = useConnectionDocumentById(props.connectionId);
835
+ const [prefilled, setPrefilled] = useState(false);
836
+ const { client, queryClient } = useRuntime();
837
+ const state = document?.state.global;
838
+ useEffect(() => {
839
+ if (!dispatch || prefilled || state === void 0) return;
840
+ if (state.connectorId) return;
841
+ setPrefilled(true);
842
+ dispatch(actions.setConnectionName({ name: props.draft.name }));
843
+ dispatch(actions.setName(props.draft.name));
844
+ const setConnector = (auth) => {
845
+ const { authType } = planFromAuth(auth);
846
+ if (authType === "UNKNOWN") return;
847
+ dispatch(actions.setConnector({
848
+ connectorId: props.draft.connectorId,
849
+ authType
850
+ }));
851
+ };
852
+ queryClient.fetchQuery(catalogQuery(client)).then((pieces) => {
853
+ const piece = pieces.find((entry) => entry.name === props.draft.piecePackage);
854
+ setConnector(piece?.auth);
855
+ const name = connectionNameFor(props.draft.piecePackage, piece?.displayName);
856
+ if (name !== props.draft.name) {
857
+ dispatch(actions.setConnectionName({ name }));
858
+ dispatch(actions.setName(name));
859
+ }
860
+ }, () => setConnector(null));
861
+ }, [
862
+ dispatch,
863
+ prefilled,
864
+ props.draft,
865
+ state,
866
+ client,
867
+ queryClient
868
+ ]);
869
+ const callbacks = state && dispatch ? connectionCallbacks(state, dispatch) : null;
870
+ return /* @__PURE__ */ jsx(Modal, {
871
+ open: true,
872
+ title: "New connection",
873
+ onOpenChange: (open) => {
874
+ if (!open) props.onDone(props.connectionId);
875
+ },
876
+ contentProps: { className: "max-h-[85vh] w-[36rem] max-w-[92vw] overflow-y-auto" },
877
+ children: /* @__PURE__ */ jsxs("div", {
878
+ className: "flex flex-col gap-4 p-6",
879
+ children: [/* @__PURE__ */ jsxs("div", {
880
+ className: "flex items-center gap-2",
881
+ children: [/* @__PURE__ */ jsx("input", {
882
+ className: "min-w-0 flex-1 rounded border border-transparent px-1 py-0.5 text-sm font-semibold text-foreground hover:border-foreground/10 focus:border-foreground/15 focus:outline-none",
883
+ defaultValue: state?.name ?? props.draft.name,
884
+ placeholder: "Untitled connection",
885
+ spellCheck: false,
886
+ "aria-label": "Connection name",
887
+ onKeyDown: (event) => {
888
+ if (event.key === "Enter") event.currentTarget.blur();
889
+ },
890
+ onBlur: (event) => {
891
+ const name = event.target.value.trim();
892
+ if (name && name !== state?.name) callbacks?.setName(name);
893
+ }
894
+ }, state?.name), /* @__PURE__ */ jsx("button", {
895
+ type: "button",
896
+ className: "shrink-0 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground",
897
+ onClick: () => props.onDone(props.connectionId),
898
+ children: "Use this connection"
899
+ })]
900
+ }), state && callbacks ? /* @__PURE__ */ jsx(ConnectionForm, {
901
+ state,
902
+ callbacks,
903
+ connectionId: props.connectionId,
904
+ offerReactor: false
905
+ }) : /* @__PURE__ */ jsx("p", {
906
+ className: "text-xs text-muted-foreground/80",
907
+ children: "Loading the new connection document…"
908
+ })]
909
+ })
910
+ });
911
+ }
912
+ //#endregion
913
+ //#region editors/workflow-editor/ui/ConnectionField.tsx
914
+ const STATUS_DOT = {
915
+ OK: "bg-wf-ok",
916
+ UNCONFIGURED: "bg-wf-warn",
917
+ ERROR: "bg-wf-fail",
918
+ REVOKED: "bg-wf-fail"
919
+ };
920
+ function ConnectorIcon(props) {
921
+ usePieceLogos();
922
+ const [broken, setBroken] = useState(false);
923
+ const piecePackage = packageFromConnectorId(props.connectorId);
924
+ const src = broken ? void 0 : pieceLogo(piecePackage);
925
+ if (!src) {
926
+ const short = piecePackage.split("/").pop()?.replace(/^piece-/, "") ?? "";
927
+ return /* @__PURE__ */ jsx("span", {
928
+ className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-sm border border-solid border-foreground/10 bg-muted/50 text-[9px] text-muted-foreground",
929
+ children: short.slice(0, 1).toUpperCase() || "?"
930
+ });
931
+ }
932
+ return /* @__PURE__ */ jsx("img", {
933
+ src,
934
+ alt: "",
935
+ className: "h-4 w-4 shrink-0 object-contain",
936
+ onError: () => setBroken(true)
937
+ });
938
+ }
939
+ function ConnectionRow(props) {
940
+ const { connection } = props;
941
+ return /* @__PURE__ */ jsxs("button", {
942
+ type: "button",
943
+ className: "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] hover:bg-accent",
944
+ onMouseDown: (event) => {
945
+ event.preventDefault();
946
+ props.onPick(connection);
947
+ },
948
+ children: [
949
+ /* @__PURE__ */ jsx(ConnectorIcon, { connectorId: connection.connectorId }),
950
+ /* @__PURE__ */ jsxs("span", {
951
+ className: "min-w-0 flex-1 truncate font-medium text-foreground",
952
+ children: [connection.name, connection.accountLabel ? /* @__PURE__ */ jsx("span", {
953
+ className: "ml-1.5 font-normal text-muted-foreground",
954
+ children: connection.accountLabel
955
+ }) : null]
956
+ }),
957
+ /* @__PURE__ */ jsx("span", {
958
+ className: `h-2 w-2 shrink-0 rounded-full ${STATUS_DOT[connection.status] ?? "bg-muted-foreground/40"}`,
959
+ title: connection.status
960
+ })
961
+ ]
962
+ });
963
+ }
964
+ function CreateRow(props) {
965
+ return /* @__PURE__ */ jsxs("button", {
966
+ type: "button",
967
+ className: "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] hover:bg-accent disabled:opacity-50",
968
+ disabled: props.busy,
969
+ onMouseDown: (event) => {
970
+ event.preventDefault();
971
+ props.onCreate();
972
+ },
973
+ children: [/* @__PURE__ */ jsx("span", {
974
+ className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-sm border border-solid border-foreground/15 text-[10px] text-muted-foreground",
975
+ children: "+"
976
+ }), /* @__PURE__ */ jsx("span", {
977
+ className: "min-w-0 flex-1 truncate font-medium text-foreground",
978
+ children: props.busy ? "Creating connection…" : "Create connection"
979
+ })]
980
+ });
981
+ }
982
+ const LINK_ATTEMPTS$1 = 30;
983
+ const LINK_INTERVAL_MS$1 = 500;
984
+ function ConnectionField(props) {
985
+ const { form } = useBlockForm(props.block);
986
+ const { connections, refetch, invalidate, fetchNow } = useConnectionList();
987
+ const [open, setOpen] = useState(false);
988
+ const [query, setQuery] = useState("");
989
+ const [creating, setCreating] = useState(false);
990
+ const [createError, setCreateError] = useState(null);
991
+ const [draftId, setDraftId] = useState(null);
992
+ const [linking, setLinking] = useState(false);
993
+ const containerRef = useRef(null);
994
+ const driveId = useSelectedDriveId();
995
+ const openField = () => {
996
+ refetch();
997
+ setOpen(true);
998
+ };
999
+ useEffect(() => {
1000
+ if (!open) return;
1001
+ const handler = (event) => {
1002
+ if (!containerRef.current?.contains(event.target)) setOpen(false);
1003
+ };
1004
+ window.addEventListener("mousedown", handler);
1005
+ return () => window.removeEventListener("mousedown", handler);
1006
+ }, [open]);
1007
+ const selected = connections.find((connection) => connection.id === props.value);
1008
+ const bound = useConnectionName(selected ? null : props.value);
1009
+ const authMode = form === "loading" ? "loading" : form?.auth ?? "optional";
1010
+ if ((authMode === "none" || authMode === "loading") && !props.value) return null;
1011
+ const compatible = compatibleConnections(connections, props.block);
1012
+ const needle = query.trim().toLowerCase();
1013
+ const visible = needle ? compatible.filter((connection) => [connection.name, connection.accountLabel ?? ""].some((candidate) => candidate.toLowerCase().includes(needle))) : compatible;
1014
+ const draft = driveId ? connectionDraftFor({
1015
+ block: props.block,
1016
+ authMode,
1017
+ matchingCount: compatible.length
1018
+ }) : null;
1019
+ const create = (pending) => {
1020
+ if (!driveId || creating) return;
1021
+ setCreating(true);
1022
+ setCreateError(null);
1023
+ addDocument(driveId, pending.name, CONNECTION_TYPE).then((node) => {
1024
+ invalidate();
1025
+ setDraftId(node.id);
1026
+ }).catch((error) => {
1027
+ setCreateError(error instanceof Error ? error.message : String(error));
1028
+ }).finally(() => setCreating(false));
1029
+ };
1030
+ const pick = (connectionId) => {
1031
+ setQuery("");
1032
+ setOpen(false);
1033
+ if (connectionId !== props.value) props.onChange(connectionId);
1034
+ };
1035
+ const clear = () => {
1036
+ setQuery("");
1037
+ setOpen(false);
1038
+ if (props.value) props.onChange(null);
1039
+ };
1040
+ const finishCreate = (connectionId) => {
1041
+ setDraftId(null);
1042
+ setLinking(true);
1043
+ const poll = (attempt) => {
1044
+ const done = () => {
1045
+ setLinking(false);
1046
+ pick(connectionId);
1047
+ };
1048
+ fetchNow().then((result) => {
1049
+ if (result.some((connection) => connection.id === connectionId && packageFromConnectorId(connection.connectorId) === props.block.pieceName) || attempt >= LINK_ATTEMPTS$1) done();
1050
+ else setTimeout(() => poll(attempt + 1), LINK_INTERVAL_MS$1);
1051
+ }, () => done());
1052
+ };
1053
+ poll(0);
1054
+ };
1055
+ return /* @__PURE__ */ jsxs("div", {
1056
+ ref: containerRef,
1057
+ className: "relative",
1058
+ children: [
1059
+ /* @__PURE__ */ jsx(FieldLabel, {
1060
+ label: "Connection",
1061
+ optional: authMode === "optional",
1062
+ needsValue: !props.value && authMode === "required",
1063
+ action: props.value && !open ? /* @__PURE__ */ jsx("button", {
1064
+ type: "button",
1065
+ className: "rounded px-1 text-xs text-muted-foreground hover:text-foreground",
1066
+ onClick: clear,
1067
+ children: "Clear"
1068
+ }) : void 0
1069
+ }),
1070
+ open ? /* @__PURE__ */ jsx("input", {
1071
+ autoFocus: true,
1072
+ "aria-label": "Search connections",
1073
+ className: `${textInputClass} border-ring ring-2 ring-ring/25`,
1074
+ value: query,
1075
+ placeholder: "Search connections or paste a document id",
1076
+ onChange: (event) => setQuery(event.target.value),
1077
+ onKeyDown: (event) => {
1078
+ if (event.key === "Escape") {
1079
+ setQuery("");
1080
+ setOpen(false);
1081
+ }
1082
+ }
1083
+ }) : /* @__PURE__ */ jsxs("button", {
1084
+ type: "button",
1085
+ className: `${textInputClass} flex items-center gap-2 text-left ${!props.value && authMode === "required" ? "border-wf-warn/70 hover:border-wf-warn" : ""}`,
1086
+ onClick: openField,
1087
+ children: [selected ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
1088
+ /* @__PURE__ */ jsx(ConnectorIcon, { connectorId: selected.connectorId }),
1089
+ /* @__PURE__ */ jsxs("span", {
1090
+ className: "min-w-0 flex-1 truncate text-foreground",
1091
+ children: [selected.name, selected.accountLabel ? /* @__PURE__ */ jsx("span", {
1092
+ className: "ml-1.5 text-muted-foreground",
1093
+ children: selected.accountLabel
1094
+ }) : null]
1095
+ }),
1096
+ /* @__PURE__ */ jsx("span", {
1097
+ className: `h-2 w-2 shrink-0 rounded-full ${STATUS_DOT[selected.status] ?? "bg-muted-foreground/40"}`,
1098
+ title: selected.status
1099
+ })
1100
+ ] }) : /* @__PURE__ */ jsx("span", {
1101
+ className: "flex-1 truncate text-muted-foreground/70",
1102
+ children: props.value ? /* @__PURE__ */ jsx(ConnectionName, { name: bound.name }) : "Choose a connection"
1103
+ }), /* @__PURE__ */ jsx(Icon, {
1104
+ name: "chevronDown",
1105
+ className: "h-3.5 w-3.5 text-muted-foreground"
1106
+ })]
1107
+ }),
1108
+ props.value && !selected && bound.invalid ? /* @__PURE__ */ jsx(Hint, { children: "Not a known connection document." }) : null,
1109
+ selected && packageFromConnectorId(selected.connectorId) !== props.block.pieceName ? /* @__PURE__ */ jsxs("p", {
1110
+ className: "mt-1.5 text-xs text-wf-warn",
1111
+ children: [
1112
+ "Configures ",
1113
+ selected.connectorId,
1114
+ ", not this block's piece."
1115
+ ]
1116
+ }) : null,
1117
+ !props.value && authMode === "required" ? /* @__PURE__ */ jsx(Hint, { children: "This block signs in to its service through a connection." }) : null,
1118
+ linking ? /* @__PURE__ */ jsx(Hint, { children: "Linking the new connection…" }) : null,
1119
+ createError ? /* @__PURE__ */ jsx("p", {
1120
+ className: "mt-1.5 text-xs font-medium text-wf-fail",
1121
+ children: createError
1122
+ }) : null,
1123
+ open ? /* @__PURE__ */ jsxs("div", {
1124
+ className: "absolute left-0 right-0 top-full z-50 mt-1 max-h-64 overflow-y-auto rounded-lg border border-solid border-foreground/10 bg-popover p-1 shadow-lg",
1125
+ children: [
1126
+ visible.map((connection) => /* @__PURE__ */ jsx(ConnectionRow, {
1127
+ connection,
1128
+ onPick: (picked) => pick(picked.id)
1129
+ }, connection.id)),
1130
+ draft && !needle ? /* @__PURE__ */ jsx(CreateRow, {
1131
+ draft,
1132
+ busy: creating,
1133
+ onCreate: () => create(draft)
1134
+ }) : null,
1135
+ visible.length === 0 && looksLikeDocumentId(query) ? /* @__PURE__ */ jsx("button", {
1136
+ type: "button",
1137
+ className: "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] hover:bg-accent",
1138
+ onMouseDown: (event) => {
1139
+ event.preventDefault();
1140
+ pick(query.trim());
1141
+ },
1142
+ children: /* @__PURE__ */ jsxs("span", {
1143
+ className: "min-w-0 flex-1 truncate text-xs text-foreground",
1144
+ children: [
1145
+ "Use document id",
1146
+ " ",
1147
+ /* @__PURE__ */ jsx("span", {
1148
+ className: "font-mono text-muted-foreground",
1149
+ children: query.trim()
1150
+ })
1151
+ ]
1152
+ })
1153
+ }) : null,
1154
+ visible.length === 0 && !draft && !looksLikeDocumentId(query) ? /* @__PURE__ */ jsx("p", {
1155
+ className: "px-2 py-1.5 text-xs text-muted-foreground/80",
1156
+ children: needle ? "No matching connection." : "No connection for this piece yet."
1157
+ }) : null
1158
+ ]
1159
+ }) : null,
1160
+ draftId && draft ? /* @__PURE__ */ jsx(CreateConnectionModal, {
1161
+ connectionId: draftId,
1162
+ draft,
1163
+ onDone: finishCreate
1164
+ }) : null
1165
+ ]
1166
+ });
1167
+ }
1168
+ //#endregion
1169
+ //#region editors/workflow-editor/ui/reactor-connection-create.ts
1170
+ function newReactorConnectionActions(name, requireReactor) {
1171
+ return [
1172
+ actions.setConnectionName({ name }),
1173
+ actions.setName(name),
1174
+ actions.setConnector({
1175
+ connectorId: REACTOR_CONNECTOR_ID,
1176
+ authType: "REACTOR"
1177
+ }),
1178
+ actions.setConfig({ config: requireReactor === "read" ? {
1179
+ endpoint: "local",
1180
+ access: "read"
1181
+ } : { endpoint: "local" } }),
1182
+ actions.recordCheckResult({
1183
+ status: "OK",
1184
+ checkedAt: (/* @__PURE__ */ new Date()).toISOString()
1185
+ })
1186
+ ];
1187
+ }
1188
+ //#endregion
1189
+ //#region editors/workflow-editor/ui/ReactorConnectionField.tsx
1190
+ const LINK_ATTEMPTS = 30;
1191
+ const LINK_INTERVAL_MS = 500;
1192
+ const DECLARED = {
1193
+ read: "Reads documents only",
1194
+ write: "Reads and writes documents"
1195
+ };
1196
+ function ReactorConnectionField(props) {
1197
+ const { form } = useBlockForm(props.block);
1198
+ const { connections, refetch, invalidate } = useConnectionList();
1199
+ const driveId = useSelectedDriveId();
1200
+ const gate = useSignInGate();
1201
+ const { publisher, loading } = usePublisher(props.workflowId, props.publishedVersion);
1202
+ const runsAs = runsAsText(publisher, loading, gate.access?.reactorIdentity?.address);
1203
+ const [creating, setCreating] = useState(false);
1204
+ const refetchRef = useRef(refetch);
1205
+ useEffect(() => {
1206
+ refetchRef.current = refetch;
1207
+ });
1208
+ const [error, setError] = useState(null);
1209
+ const linking = props.value || null;
1210
+ const listing = connections.find((connection) => connection.id === linking);
1211
+ const listed = Boolean(listing);
1212
+ const bound = useConnectionName(listed ? null : props.value);
1213
+ useEffect(() => {
1214
+ if (!linking || listed) return;
1215
+ let attempts = 0;
1216
+ const timer = setInterval(() => {
1217
+ if (++attempts > LINK_ATTEMPTS) clearInterval(timer);
1218
+ else refetchRef.current();
1219
+ }, LINK_INTERVAL_MS);
1220
+ return () => clearInterval(timer);
1221
+ }, [linking, listed]);
1222
+ const declared = form && form !== "loading" ? form.requireReactor : void 0;
1223
+ if (!declared && !props.value) return null;
1224
+ const options = reactorConnections(connections).map((connection) => ({
1225
+ value: connection.id,
1226
+ label: connection.name || connection.id,
1227
+ description: connection.status === "REVOKED" ? "Revoked" : void 0
1228
+ }));
1229
+ const create = () => {
1230
+ if (!driveId || creating) return;
1231
+ setCreating(true);
1232
+ setError(null);
1233
+ const name = "Reactor access";
1234
+ addDocument(driveId, name, CONNECTION_TYPE).then(async (node) => {
1235
+ let failure;
1236
+ await dispatchActions(newReactorConnectionActions(name, declared ?? "write"), node.id, (errors) => {
1237
+ failure = errors[0]?.message;
1238
+ });
1239
+ if (failure) throw new Error(failure);
1240
+ invalidate();
1241
+ setCreating(false);
1242
+ props.onChange(node.id);
1243
+ }).catch((cause) => {
1244
+ setCreating(false);
1245
+ setError(cause instanceof Error ? cause.message : String(cause));
1246
+ });
1247
+ };
1248
+ const known = options.some((option) => option.value === props.value);
1249
+ return /* @__PURE__ */ jsxs("div", {
1250
+ className: "flex flex-col gap-3",
1251
+ children: [/* @__PURE__ */ jsxs("div", { children: [
1252
+ /* @__PURE__ */ jsx(FieldLabel, {
1253
+ label: "Reactor connection",
1254
+ needsValue: Boolean(declared) && !props.value,
1255
+ action: props.value ? /* @__PURE__ */ jsx("button", {
1256
+ type: "button",
1257
+ className: "rounded px-1 text-xs text-muted-foreground hover:text-foreground",
1258
+ onClick: () => props.onChange(null),
1259
+ children: "Clear"
1260
+ }) : void 0
1261
+ }),
1262
+ /* @__PURE__ */ jsx("div", {
1263
+ onPointerDown: refetch,
1264
+ children: /* @__PURE__ */ jsx(Select, {
1265
+ ariaLabel: "Reactor connection",
1266
+ value: props.value,
1267
+ options,
1268
+ valueLabel: props.value ? /* @__PURE__ */ jsx(ConnectionName, { name: listing ? listing.name || listing.id : bound.name }) : void 0,
1269
+ invalid: Boolean(declared) && !props.value,
1270
+ placeholder: creating ? "Creating connection…" : "Choose a reactor connection",
1271
+ emptyText: "No reactor connection in this drive yet.",
1272
+ disabled: creating,
1273
+ onChange: (id) => props.onChange(id || null),
1274
+ actions: driveId && declared ? [{
1275
+ label: "New reactor connection",
1276
+ icon: "plus",
1277
+ onSelect: create
1278
+ }] : void 0
1279
+ })
1280
+ }),
1281
+ declared ? /* @__PURE__ */ jsxs(Hint, { children: [
1282
+ DECLARED[declared],
1283
+ ", within what the connection allows.",
1284
+ runsAs ? /* @__PURE__ */ jsx("span", {
1285
+ className: "block",
1286
+ "aria-label": "Runs as",
1287
+ children: runsAs
1288
+ }) : null
1289
+ ] }) : /* @__PURE__ */ jsx(Hint, { children: "This block takes no reactor connection." }),
1290
+ props.value && !known && (listed || bound.invalid) ? /* @__PURE__ */ jsx("p", {
1291
+ className: "mt-1.5 text-xs text-wf-warn",
1292
+ children: "Not a reactor connection in this drive."
1293
+ }) : null,
1294
+ error ? /* @__PURE__ */ jsx("p", {
1295
+ className: "mt-1.5 text-xs font-medium text-wf-fail",
1296
+ children: error
1297
+ }) : null
1298
+ ] }), !props.value ? /* @__PURE__ */ jsx(SignInPrompt, {
1299
+ gate,
1300
+ reason: "Sign in so the workflow runs as you when it reaches documents."
1301
+ }) : null]
1302
+ });
1303
+ }
1304
+ const DEFAULT_RETRY = {
1305
+ maxAttempts: 3,
1306
+ backoff: "EXPONENTIAL",
1307
+ initialDelaySeconds: 5,
1308
+ maxDelaySeconds: 300,
1309
+ retryOn: []
1310
+ };
1311
+ function clampInt(value, min, max) {
1312
+ if (!Number.isFinite(value)) return min;
1313
+ return Math.min(max, Math.max(min, Math.trunc(value)));
1314
+ }
1315
+ function normalizeRetry(policy) {
1316
+ const initialDelaySeconds = clampInt(policy.initialDelaySeconds, 0, 300);
1317
+ return {
1318
+ maxAttempts: clampInt(policy.maxAttempts, 1, 10),
1319
+ backoff: policy.backoff === "EXPONENTIAL" ? "EXPONENTIAL" : "FIXED",
1320
+ initialDelaySeconds,
1321
+ maxDelaySeconds: clampInt(policy.maxDelaySeconds, initialDelaySeconds, 300),
1322
+ retryOn: policy.retryOn.map((entry) => entry.trim()).filter(Boolean)
1323
+ };
1324
+ }
1325
+ function inheritedRetryHint(workflowAttempts, actionAttempts) {
1326
+ if (actionAttempts === void 0) return null;
1327
+ const workflow = clampInt(workflowAttempts ?? 1, 1, 10);
1328
+ if (workflow > 1) return `The workflow's default retry (up to ${workflow} attempts) applies, not this action's.`;
1329
+ const action = clampInt(actionAttempts, 1, 10);
1330
+ return action === 1 ? "This action runs once unless the step sets a retry." : `This action makes up to ${action} attempts unless the step sets a retry.`;
1331
+ }
1332
+ function parseRetryOn(raw) {
1333
+ return raw.split(",").map((entry) => entry.trim()).filter((entry) => entry !== "");
1334
+ }
1335
+ //#endregion
1336
+ //#region editors/workflow-editor/ui/schedule-draft.ts
1337
+ const DEFAULT_TIME = "09:00";
1338
+ function isInt(field) {
1339
+ return /^\d+$/.test(field);
1340
+ }
1341
+ function toTime(hour, minute) {
1342
+ return `${hour.padStart(2, "0")}:${minute.padStart(2, "0")}`;
1343
+ }
1344
+ function fromTime(time) {
1345
+ const [hour = "9", minute = "0"] = time.split(":");
1346
+ return {
1347
+ hour: Number(hour),
1348
+ minute: Number(minute)
1349
+ };
1350
+ }
1351
+ function cronDraft(cron) {
1352
+ if (!cron) return {
1353
+ kind: "daily",
1354
+ time: DEFAULT_TIME,
1355
+ weekdaysOnly: false
1356
+ };
1357
+ const fields = cron.split(/\s+/);
1358
+ if (fields.length !== 5) return {
1359
+ kind: "custom",
1360
+ cron
1361
+ };
1362
+ const [minute, hour, dayOfMonth, month, dayOfWeek] = fields;
1363
+ if (!isInt(minute) || !isInt(hour) || dayOfMonth !== "*" || month !== "*") return {
1364
+ kind: "custom",
1365
+ cron
1366
+ };
1367
+ const time = toTime(hour, minute);
1368
+ if (dayOfWeek === "*") return {
1369
+ kind: "daily",
1370
+ time,
1371
+ weekdaysOnly: false
1372
+ };
1373
+ if (dayOfWeek === "1-5") return {
1374
+ kind: "daily",
1375
+ time,
1376
+ weekdaysOnly: true
1377
+ };
1378
+ const days = dayOfWeek.split(",");
1379
+ if (days.every((day) => isInt(day) && Number(day) <= 7)) return {
1380
+ kind: "weekly",
1381
+ time,
1382
+ days: [...new Set(days.map((day) => Number(day) % 7))].sort((a, b) => a - b)
1383
+ };
1384
+ return {
1385
+ kind: "custom",
1386
+ cron
1387
+ };
1388
+ }
1389
+ function draftFromConfig(config) {
1390
+ try {
1391
+ const schedule = parseScheduleConfig(config);
1392
+ return schedule.mode === "interval" ? {
1393
+ kind: "interval",
1394
+ every: schedule.every,
1395
+ unit: schedule.unit
1396
+ } : cronDraft(schedule.cron);
1397
+ } catch {}
1398
+ const record = config ?? {};
1399
+ if (record.mode === "interval") return {
1400
+ kind: "interval",
1401
+ every: 15,
1402
+ unit: "minutes"
1403
+ };
1404
+ return cronDraft(typeof record.cron === "string" ? record.cron.trim() : "");
1405
+ }
1406
+ /** The cron a draft stands for; undefined for an interval. */
1407
+ function cronFromDraft(draft) {
1408
+ switch (draft.kind) {
1409
+ case "daily": {
1410
+ const { hour, minute } = fromTime(draft.time);
1411
+ return `${minute} ${hour} * * ${draft.weekdaysOnly ? "1-5" : "*"}`;
1412
+ }
1413
+ case "weekly": {
1414
+ const { hour, minute } = fromTime(draft.time);
1415
+ return `${minute} ${hour} * * ${draft.days.length > 0 ? draft.days.join(",") : "1"}`;
1416
+ }
1417
+ case "custom": return draft.cron;
1418
+ case "interval": return;
1419
+ }
1420
+ }
1421
+ /** The config the runtime reads; UTC is the default, so it isn't stored. */
1422
+ function configFromDraft(draft, timezone) {
1423
+ const zone = timezone && timezone !== DEFAULT_TIMEZONE ? { timezone } : void 0;
1424
+ if (draft.kind === "interval") return {
1425
+ mode: "interval",
1426
+ every: draft.every,
1427
+ unit: draft.unit,
1428
+ ...zone
1429
+ };
1430
+ return {
1431
+ mode: "cron",
1432
+ cron: cronFromDraft(draft),
1433
+ ...zone
1434
+ };
1435
+ }
1436
+ /** Switches kind, keeping whatever carries over (the time, mostly). */
1437
+ function switchKind(draft, kind) {
1438
+ if (draft.kind === kind) return draft;
1439
+ const time = "time" in draft ? draft.time : DEFAULT_TIME;
1440
+ switch (kind) {
1441
+ case "daily": return {
1442
+ kind,
1443
+ time,
1444
+ weekdaysOnly: false
1445
+ };
1446
+ case "weekly": return {
1447
+ kind,
1448
+ time,
1449
+ days: [1]
1450
+ };
1451
+ case "interval": return {
1452
+ kind,
1453
+ every: 15,
1454
+ unit: "minutes"
1455
+ };
1456
+ case "custom": return {
1457
+ kind,
1458
+ cron: cronFromDraft(draft) ?? "0 9 * * *"
1459
+ };
1460
+ }
1461
+ }
1462
+ function timezoneOf(config) {
1463
+ const zone = config?.timezone;
1464
+ return typeof zone === "string" && zone ? zone : DEFAULT_TIMEZONE;
1465
+ }
1466
+ //#endregion
1467
+ //#region editors/workflow-editor/ui/ScheduleBuilder.tsx
1468
+ const KINDS = [
1469
+ {
1470
+ value: "daily",
1471
+ label: "Daily"
1472
+ },
1473
+ {
1474
+ value: "weekly",
1475
+ label: "Weekly"
1476
+ },
1477
+ {
1478
+ value: "interval",
1479
+ label: "Interval"
1480
+ },
1481
+ {
1482
+ value: "custom",
1483
+ label: "Custom"
1484
+ }
1485
+ ];
1486
+ const DAYS = [
1487
+ {
1488
+ value: 1,
1489
+ label: "Mon",
1490
+ name: "Monday"
1491
+ },
1492
+ {
1493
+ value: 2,
1494
+ label: "Tue",
1495
+ name: "Tuesday"
1496
+ },
1497
+ {
1498
+ value: 3,
1499
+ label: "Wed",
1500
+ name: "Wednesday"
1501
+ },
1502
+ {
1503
+ value: 4,
1504
+ label: "Thu",
1505
+ name: "Thursday"
1506
+ },
1507
+ {
1508
+ value: 5,
1509
+ label: "Fri",
1510
+ name: "Friday"
1511
+ },
1512
+ {
1513
+ value: 6,
1514
+ label: "Sat",
1515
+ name: "Saturday"
1516
+ },
1517
+ {
1518
+ value: 0,
1519
+ label: "Sun",
1520
+ name: "Sunday"
1521
+ }
1522
+ ];
1523
+ const UNITS = [
1524
+ {
1525
+ value: "minutes",
1526
+ label: "Minutes"
1527
+ },
1528
+ {
1529
+ value: "hours",
1530
+ label: "Hours"
1531
+ },
1532
+ {
1533
+ value: "days",
1534
+ label: "Days"
1535
+ }
1536
+ ];
1537
+ function timezones() {
1538
+ try {
1539
+ return ["UTC", ...Intl.supportedValuesOf("timeZone").filter((z) => z !== "UTC")];
1540
+ } catch {
1541
+ return ["UTC"];
1542
+ }
1543
+ }
1544
+ const TIMEZONES = timezones();
1545
+ function TimeField(props) {
1546
+ const id = useId();
1547
+ return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(FieldLabel, {
1548
+ htmlFor: id,
1549
+ label: "At"
1550
+ }), /* @__PURE__ */ jsx("input", {
1551
+ id,
1552
+ type: "time",
1553
+ className: `${textInputClass} w-32 tabular-nums`,
1554
+ value: props.time,
1555
+ onChange: (event) => {
1556
+ if (event.target.value) props.onChange(event.target.value);
1557
+ }
1558
+ })] });
1559
+ }
1560
+ function isEvery(text) {
1561
+ const every = Number(text);
1562
+ return text !== "" && Number.isInteger(every) && every >= 1;
1563
+ }
1564
+ function EveryInput(props) {
1565
+ const [text, setText] = useState(String(props.every));
1566
+ const [seen, setSeen] = useState(props.every);
1567
+ if (seen !== props.every) {
1568
+ setSeen(props.every);
1569
+ if (Number(text) !== props.every) setText(String(props.every));
1570
+ }
1571
+ return /* @__PURE__ */ jsx("input", {
1572
+ id: props.id,
1573
+ type: "number",
1574
+ min: 1,
1575
+ step: 1,
1576
+ className: `${textInputClass} w-24 tabular-nums`,
1577
+ value: text,
1578
+ onChange: (event) => {
1579
+ setText(event.target.value);
1580
+ if (!isEvery(event.target.value)) return;
1581
+ const every = Number(event.target.value);
1582
+ if (every !== props.every) props.onCommit(every);
1583
+ },
1584
+ onBlur: () => {
1585
+ if (!isEvery(text)) setText(String(props.every));
1586
+ }
1587
+ });
1588
+ }
1589
+ function ScheduleBuilder(props) {
1590
+ const everyId = useId();
1591
+ const cronId = useId();
1592
+ const echo = usePendingEcho(props.config, props.onChange);
1593
+ const config = echo.value;
1594
+ const parsed = draftFromConfig(config);
1595
+ const timezone = timezoneOf(config);
1596
+ const [customPinned, setCustomPinned] = useState(parsed.kind === "custom");
1597
+ const draft = customPinned && parsed.kind !== "custom" ? switchKind(parsed, "custom") : parsed;
1598
+ const commit = (next, zone = timezone) => echo.commit(configFromDraft(next, zone));
1599
+ const issue = scheduleConfigIssue(config);
1600
+ return /* @__PURE__ */ jsxs("div", {
1601
+ className: "flex flex-col gap-5",
1602
+ onBlur: echo.onBlur,
1603
+ children: [
1604
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(FieldLabel, { label: "Repeats" }), /* @__PURE__ */ jsx(Segmented, {
1605
+ value: draft.kind,
1606
+ options: KINDS,
1607
+ onChange: (value) => {
1608
+ const kind = value;
1609
+ setCustomPinned(kind === "custom");
1610
+ commit(switchKind(draft, kind));
1611
+ }
1612
+ })] }),
1613
+ draft.kind === "daily" ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(TimeField, {
1614
+ time: draft.time,
1615
+ onChange: (time) => commit({
1616
+ ...draft,
1617
+ time
1618
+ })
1619
+ }), /* @__PURE__ */ jsx(Switch, {
1620
+ checked: draft.weekdaysOnly,
1621
+ onChange: (weekdaysOnly) => commit({
1622
+ ...draft,
1623
+ weekdaysOnly
1624
+ }),
1625
+ label: "Weekdays only",
1626
+ description: "Skip Saturdays and Sundays."
1627
+ })] }) : null,
1628
+ draft.kind === "weekly" ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(FieldLabel, { label: "On" }), /* @__PURE__ */ jsx("div", {
1629
+ role: "group",
1630
+ "aria-label": "Days",
1631
+ className: "flex gap-1",
1632
+ children: DAYS.map((day) => {
1633
+ const on = draft.days.includes(day.value);
1634
+ return /* @__PURE__ */ jsx("button", {
1635
+ type: "button",
1636
+ "aria-pressed": on,
1637
+ "aria-label": day.name,
1638
+ className: `h-8 flex-1 rounded-md text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 ${on ? "bg-primary text-primary-foreground" : "border border-solid border-foreground/15 text-muted-foreground hover:bg-accent hover:text-foreground"}`,
1639
+ onClick: () => {
1640
+ const days = on ? draft.days.filter((value) => value !== day.value) : [...draft.days, day.value];
1641
+ if (days.length > 0) commit({
1642
+ ...draft,
1643
+ days
1644
+ });
1645
+ },
1646
+ children: day.label
1647
+ }, day.value);
1648
+ })
1649
+ })] }), /* @__PURE__ */ jsx(TimeField, {
1650
+ time: draft.time,
1651
+ onChange: (time) => commit({
1652
+ ...draft,
1653
+ time
1654
+ })
1655
+ })] }) : null,
1656
+ draft.kind === "interval" ? /* @__PURE__ */ jsxs("div", { children: [
1657
+ /* @__PURE__ */ jsx(FieldLabel, {
1658
+ htmlFor: everyId,
1659
+ label: "Every"
1660
+ }),
1661
+ /* @__PURE__ */ jsxs("div", {
1662
+ className: "flex items-center gap-2",
1663
+ children: [/* @__PURE__ */ jsx(EveryInput, {
1664
+ id: everyId,
1665
+ every: draft.every,
1666
+ onCommit: (every) => commit({
1667
+ ...draft,
1668
+ every
1669
+ })
1670
+ }), /* @__PURE__ */ jsx("div", {
1671
+ className: "w-32",
1672
+ children: /* @__PURE__ */ jsx(Select, {
1673
+ value: draft.unit,
1674
+ options: UNITS,
1675
+ onChange: (unit) => commit({
1676
+ ...draft,
1677
+ unit
1678
+ })
1679
+ })
1680
+ })]
1681
+ }),
1682
+ /* @__PURE__ */ jsx(Hint, { text: "Counted from when the workflow is enabled." })
1683
+ ] }) : null,
1684
+ draft.kind === "custom" ? /* @__PURE__ */ jsxs("div", { children: [
1685
+ /* @__PURE__ */ jsx(FieldLabel, {
1686
+ htmlFor: cronId,
1687
+ label: "Cron expression"
1688
+ }),
1689
+ /* @__PURE__ */ jsx("input", {
1690
+ id: cronId,
1691
+ className: `${textInputClass} font-mono`,
1692
+ value: draft.cron,
1693
+ spellCheck: false,
1694
+ placeholder: "0 9 * * 1-5",
1695
+ onChange: (event) => commit({
1696
+ kind: "custom",
1697
+ cron: event.target.value
1698
+ })
1699
+ }),
1700
+ issue ? /* @__PURE__ */ jsx(FieldError, { children: issue.replace(/^Schedule: /, "") }) : /* @__PURE__ */ jsx(Hint, { text: describeCron(draft.cron) ?? "Minute, hour, day of month, month, weekday." })
1701
+ ] }) : null,
1702
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(FieldLabel, { label: "Timezone" }), /* @__PURE__ */ jsx(Select, {
1703
+ value: timezone,
1704
+ options: TIMEZONES.map((zone) => ({
1705
+ value: zone,
1706
+ label: zone.replace(/_/g, " ")
1707
+ })),
1708
+ onChange: (zone) => commit(draft, zone)
1709
+ })] }),
1710
+ /* @__PURE__ */ jsxs("p", {
1711
+ className: "rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground",
1712
+ children: [
1713
+ "Runs",
1714
+ " ",
1715
+ /* @__PURE__ */ jsx("span", {
1716
+ className: "font-medium text-foreground",
1717
+ children: describeSchedule(config).replace(/^\w/, (c) => c.toLowerCase())
1718
+ })
1719
+ ]
1720
+ })
1721
+ ]
1722
+ });
1723
+ }
1724
+ //#endregion
1725
+ //#region editors/workflow-editor/ui/step-test.ts
1726
+ const UPSTREAM = /^Test "(.+?)" first(?::|$)/;
1727
+ const TRIGGER = /^Test the trigger first(?::|$)/;
1728
+ const REDACTED = /^"(.+?)" reads a value redacted from the last test of (.+)$/;
1729
+ const VARIABLE = /^(?:Secret variable|Variable) "(.+?)" /;
1730
+ const QUOTED = /"([^"]+)"/g;
1731
+ function sourcesOf(list) {
1732
+ const targets = [...list.matchAll(QUOTED)].map((match) => ({
1733
+ kind: "step",
1734
+ key: match[1]
1735
+ }));
1736
+ if (/\bthe trigger\b/.test(list)) targets.unshift({ kind: "trigger" });
1737
+ return targets;
1738
+ }
1739
+ function explainTestError(error) {
1740
+ const upstream = UPSTREAM.exec(error);
1741
+ if (upstream) return {
1742
+ message: error,
1743
+ targets: [{
1744
+ kind: "step",
1745
+ key: upstream[1]
1746
+ }]
1747
+ };
1748
+ if (TRIGGER.test(error)) return {
1749
+ message: error,
1750
+ targets: [{ kind: "trigger" }]
1751
+ };
1752
+ const redacted = REDACTED.exec(error);
1753
+ if (redacted) return {
1754
+ message: error,
1755
+ targets: sourcesOf(redacted[2])
1756
+ };
1757
+ if (VARIABLE.test(error)) return {
1758
+ message: error,
1759
+ targets: [{ kind: "variables" }]
1760
+ };
1761
+ return {
1762
+ message: error,
1763
+ targets: []
1764
+ };
1765
+ }
1766
+ function testOutcomeView(status) {
1767
+ if (status === "SUCCEEDED") return "output";
1768
+ if (status === "INDETERMINATE") return "indeterminate";
1769
+ return "failed";
1770
+ }
1771
+ //#endregion
1772
+ //#region editors/workflow-editor/ui/test-state.ts
1773
+ function testState(block, runStatus) {
1774
+ const test = block.lastTest;
1775
+ if (!test) return "never";
1776
+ if (block.updatedAt && Date.parse(block.updatedAt) > Date.parse(test.testedAt)) return "stale";
1777
+ return runStatus === "FAILED" ? "failed" : "passed";
1778
+ }
1779
+ function isTestableTrigger(block) {
1780
+ return block.kind === "trigger" && !isCoreBlock(block);
1781
+ }
1782
+ function relativeTime(iso, now = Date.now()) {
1783
+ const diff = now - new Date(iso).getTime();
1784
+ if (diff < 6e4) return "just now";
1785
+ if (diff < 36e5) return `${Math.floor(diff / 6e4)}m ago`;
1786
+ if (diff < 864e5) return `${Math.floor(diff / 36e5)}h ago`;
1787
+ return new Date(iso).toLocaleDateString();
1788
+ }
1789
+ //#endregion
1790
+ //#region editors/workflow-editor/ui/StepTest.tsx
1791
+ function TestedLine(props) {
1792
+ const { block } = props;
1793
+ const run = useRunById(block.lastTest?.runId);
1794
+ if (!block.lastTest) return /* @__PURE__ */ jsx("span", {
1795
+ className: "text-xs text-muted-foreground",
1796
+ children: "Not tested yet"
1797
+ });
1798
+ const state = testState(block, run?.status);
1799
+ return /* @__PURE__ */ jsxs("span", {
1800
+ className: "flex flex-wrap items-center gap-x-1.5 text-xs text-muted-foreground",
1801
+ title: new Date(block.lastTest.testedAt).toLocaleString(),
1802
+ children: [/* @__PURE__ */ jsxs("span", {
1803
+ className: state === "failed" ? "font-medium text-wf-fail" : "text-foreground",
1804
+ children: [
1805
+ state === "failed" ? "Test failed" : "Tested",
1806
+ " ",
1807
+ relativeTime(block.lastTest.testedAt)
1808
+ ]
1809
+ }), state === "stale" ? /* @__PURE__ */ jsxs("span", {
1810
+ className: "text-wf-warn",
1811
+ children: [
1812
+ "The ",
1813
+ props.noun,
1814
+ " changed since, so test it again."
1815
+ ]
1816
+ }) : null]
1817
+ });
1818
+ }
1819
+ function targetLabel(target, model) {
1820
+ if (target.kind === "trigger") return "Open the trigger";
1821
+ if (target.kind === "variables") return "Open variables";
1822
+ return `Open ${model.steps.find((entry) => entry.key === target.key)?.name || target.key}`;
1823
+ }
1824
+ function targetId(target, model) {
1825
+ if (target.kind === "trigger") return model.trigger?.id;
1826
+ if (target.kind === "variables") return VARIABLES_VIEW;
1827
+ return model.steps.find((entry) => entry.key === target.key)?.id;
1828
+ }
1829
+ function TestError(props) {
1830
+ const explained = explainTestError(props.error);
1831
+ return /* @__PURE__ */ jsxs("div", {
1832
+ role: "alert",
1833
+ className: "flex flex-col gap-1.5 rounded-md bg-wf-fail/10 p-2.5 text-xs text-wf-fail",
1834
+ children: [/* @__PURE__ */ jsxs("span", {
1835
+ className: "whitespace-pre-wrap break-words",
1836
+ children: [props.ran ? null : /* @__PURE__ */ jsx("span", {
1837
+ className: "font-medium",
1838
+ children: "Nothing ran. "
1839
+ }), explained.message]
1840
+ }), props.onSelect && explained.targets.length > 0 ? /* @__PURE__ */ jsx("span", {
1841
+ className: "flex flex-wrap gap-x-3",
1842
+ children: explained.targets.map((target) => {
1843
+ const id = targetId(target, props.model);
1844
+ if (!id) return null;
1845
+ return /* @__PURE__ */ jsx("button", {
1846
+ type: "button",
1847
+ className: "font-medium underline underline-offset-2 hover:no-underline",
1848
+ onClick: () => props.onSelect(id),
1849
+ children: targetLabel(target, props.model)
1850
+ }, id);
1851
+ })
1852
+ }) : null]
1853
+ });
1854
+ }
1855
+ function TestIndeterminate(props) {
1856
+ return /* @__PURE__ */ jsxs("div", {
1857
+ role: "alert",
1858
+ className: "flex flex-col gap-1.5 rounded-md bg-wf-warn/10 p-2.5 text-xs text-wf-warn",
1859
+ children: [/* @__PURE__ */ jsx("span", {
1860
+ className: "font-medium",
1861
+ children: "Indeterminate: this test may have written something. Check the target before testing again."
1862
+ }), /* @__PURE__ */ jsx("span", {
1863
+ className: "whitespace-pre-wrap break-words",
1864
+ children: props.error
1865
+ })]
1866
+ });
1867
+ }
1868
+ function LastTestResult(props) {
1869
+ const run = useRunById(props.step.lastTest?.runId);
1870
+ if (!props.step.lastTest) return null;
1871
+ if (run === void 0) return /* @__PURE__ */ jsx("div", { className: "h-12 animate-pulse rounded-md bg-foreground/5" });
1872
+ if (run === null) return /* @__PURE__ */ jsx("p", {
1873
+ className: "text-xs text-muted-foreground",
1874
+ children: "That test run is no longer kept."
1875
+ });
1876
+ const record = run.steps.at(0);
1877
+ const error = record?.error ?? run.error;
1878
+ if (error) return /* @__PURE__ */ jsx(TestError, {
1879
+ error,
1880
+ ran: true,
1881
+ model: props.model,
1882
+ onSelect: props.onSelect
1883
+ });
1884
+ return /* @__PURE__ */ jsx(DataViewer, {
1885
+ label: "Output",
1886
+ value: record?.output,
1887
+ root: `steps.${props.step.key}.output`
1888
+ });
1889
+ }
1890
+ function StepTestSection(props) {
1891
+ const { step } = props;
1892
+ const runTest = useTestStepRunner();
1893
+ const [attempt, setAttempt] = useState(null);
1894
+ const running = attempt?.kind === "running";
1895
+ return /* @__PURE__ */ jsxs("div", {
1896
+ className: "flex flex-col gap-3",
1897
+ children: [/* @__PURE__ */ jsxs("div", {
1898
+ className: "flex items-center justify-between gap-3",
1899
+ children: [/* @__PURE__ */ jsx(TestedLine, {
1900
+ block: step,
1901
+ noun: "step"
1902
+ }), runTest ? /* @__PURE__ */ jsxs(Button, {
1903
+ size: "sm",
1904
+ disabled: running,
1905
+ "aria-busy": running,
1906
+ onClick: () => {
1907
+ setAttempt({ kind: "running" });
1908
+ runTest(step.id).then((outcome) => setAttempt({
1909
+ kind: "done",
1910
+ outcome
1911
+ }), (error) => setAttempt({
1912
+ kind: "error",
1913
+ message: error instanceof Error ? error.message : String(error)
1914
+ }));
1915
+ },
1916
+ children: [/* @__PURE__ */ jsx(Icon, {
1917
+ name: "play",
1918
+ className: "h-3.5 w-3.5"
1919
+ }), running ? "Testing…" : "Test step"]
1920
+ }) : null]
1921
+ }), attempt === null ? /* @__PURE__ */ jsx(LastTestResult, {
1922
+ step,
1923
+ model: props.model,
1924
+ onSelect: props.onSelect
1925
+ }) : attempt.kind === "running" ? /* @__PURE__ */ jsx("div", {
1926
+ role: "status",
1927
+ "aria-label": "Testing the step",
1928
+ className: "h-12 animate-pulse rounded-md bg-foreground/5"
1929
+ }) : attempt.kind === "error" ? /* @__PURE__ */ jsx(TestError, {
1930
+ error: attempt.message,
1931
+ ran: false,
1932
+ model: props.model,
1933
+ onSelect: props.onSelect
1934
+ }) : testOutcomeView(attempt.outcome.status) === "failed" ? /* @__PURE__ */ jsx(TestError, {
1935
+ error: attempt.outcome.error ?? "The test failed",
1936
+ ran: attempt.outcome.runId !== null,
1937
+ model: props.model,
1938
+ onSelect: props.onSelect
1939
+ }) : testOutcomeView(attempt.outcome.status) === "indeterminate" ? /* @__PURE__ */ jsx(TestIndeterminate, { error: attempt.outcome.error ?? "A host call the step made timed out" }) : /* @__PURE__ */ jsx(DataViewer, {
1940
+ label: "Output",
1941
+ value: attempt.outcome.output,
1942
+ root: `steps.${step.key}.output`
1943
+ })]
1944
+ });
1945
+ }
1946
+ //#endregion
1947
+ //#region editors/workflow-editor/ui/use-validity.ts
1948
+ function configOf(block) {
1949
+ return block.config && typeof block.config === "object" ? block.config : {};
1950
+ }
1951
+ function unknownDynamic(block, form) {
1952
+ if (!form || form === "loading" || block.skip) return [];
1953
+ const config = configOf(block);
1954
+ return form.props.filter((prop) => prop.type === "DYNAMIC" && isPropVisible(prop, config) && settingFor(block.propertySettings, prop.name)?.mode !== "EXPRESSION" && !storedSchema(block.propertySettings, prop.name)).map((prop) => resolverInputFor(block.block, prop, config, block.connectionId, block.reactorConnectionId));
1955
+ }
1956
+ function withIssues(missing, issues) {
1957
+ if (issues.length === 0) return missing;
1958
+ return [...missing ?? [], ...issues];
1959
+ }
1960
+ function useBlockCheck(block) {
1961
+ const { form, error } = useBlockForm(block.block);
1962
+ const lookup = useDynamicLookup();
1963
+ return {
1964
+ form,
1965
+ formError: error,
1966
+ issues: block.skip ? [] : undeclaredPortIssues(form, block.outgoingPorts, block),
1967
+ missing: blockMissing({
1968
+ form,
1969
+ block: block.block,
1970
+ config: block.config,
1971
+ connectionId: block.connectionId,
1972
+ reactorConnectionId: block.reactorConnectionId,
1973
+ propertySettings: block.propertySettings,
1974
+ skip: block.skip,
1975
+ resolveDynamic: lookup
1976
+ }),
1977
+ lookup
1978
+ };
1979
+ }
1980
+ function useWorkflowCheck(model) {
1981
+ const blocks = useMemo(() => {
1982
+ const byId = new Map(model.steps.map((step) => [step.id, {
1983
+ ...step,
1984
+ block: stepBlock(step)
1985
+ }]));
1986
+ const ordered = model.trigger ? [{
1987
+ ...model.trigger,
1988
+ block: triggerBlock(model.trigger)
1989
+ }] : [];
1990
+ for (const id of flowOrder(model)) {
1991
+ const step = byId.get(id);
1992
+ if (step) ordered.push(step);
1993
+ }
1994
+ return ordered.map((block) => ({
1995
+ ...block,
1996
+ outgoingPorts: model.edges.filter((edge) => edge.from === block.id).map((edge) => edge.port)
1997
+ }));
1998
+ }, [model]);
1999
+ const forms = useBlockForms(blocks.map((block) => block.block));
2000
+ const formOf = (block) => forms.get(blockRefKey(block.block));
2001
+ const lookup = useDynamicLookup();
2002
+ const prefetch = useDynamicPrefetch();
2003
+ const wanted = blocks.flatMap((block) => unknownDynamic(block, formOf(block)).map((input) => ({
2004
+ input,
2005
+ config: configOf(block)
2006
+ })));
2007
+ const wantedKey = JSON.stringify(wanted);
2008
+ useEffect(() => {
2009
+ const entries = JSON.parse(wantedKey);
2010
+ for (const entry of entries) prefetch(entry.input, entry.config);
2011
+ }, [wantedKey, prefetch]);
2012
+ const results = blocks.map((block) => ({
2013
+ id: block.id,
2014
+ missing: withIssues(blockMissing({
2015
+ form: formOf(block),
2016
+ block: block.block,
2017
+ config: block.config,
2018
+ connectionId: block.connectionId,
2019
+ reactorConnectionId: block.reactorConnectionId,
2020
+ propertySettings: block.propertySettings,
2021
+ skip: block.skip,
2022
+ resolveDynamic: lookup
2023
+ }), block.skip ? [] : undeclaredPortIssues(formOf(block), block.outgoingPorts, block))
2024
+ }));
2025
+ return {
2026
+ readiness: workflowReadiness(results, Boolean(model.trigger)),
2027
+ missing: new Map(results.map((result) => [result.id, result.missing]))
2028
+ };
2029
+ }
2030
+ //#endregion
2031
+ //#region editors/workflow-editor/ui/StepPanel.tsx
2032
+ function stringify(value) {
2033
+ try {
2034
+ return JSON.stringify(value ?? {}, null, 2);
2035
+ } catch {
2036
+ return "{}";
2037
+ }
2038
+ }
2039
+ function Section(props) {
2040
+ return /* @__PURE__ */ jsxs("section", {
2041
+ className: "flex flex-col gap-4 border-t border-solid border-foreground/10 pt-5 first:border-t-0 first:pt-0",
2042
+ children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h4", {
2043
+ className: "text-[13px] font-semibold text-foreground",
2044
+ children: props.title
2045
+ }), props.description ? /* @__PURE__ */ jsx("p", {
2046
+ className: "mt-0.5 text-xs text-muted-foreground",
2047
+ children: props.description
2048
+ }) : null] }), props.children]
2049
+ });
2050
+ }
2051
+ function RawConfigEditor(props) {
2052
+ const [text, setText] = useState(() => stringify(props.value));
2053
+ const [error, setError] = useState(null);
2054
+ const [prevValue, setPrevValue] = useState(props.value);
2055
+ if (props.value !== prevValue) {
2056
+ setPrevValue(props.value);
2057
+ setText(stringify(props.value));
2058
+ }
2059
+ const dirty = text !== stringify(props.value);
2060
+ return /* @__PURE__ */ jsxs("div", { children: [
2061
+ /* @__PURE__ */ jsx("textarea", {
2062
+ "aria-label": "Configuration as JSON",
2063
+ className: `${textAreaClass} min-h-40 font-mono text-xs`,
2064
+ value: text,
2065
+ onChange: (event) => setText(event.target.value),
2066
+ spellCheck: false
2067
+ }),
2068
+ /* @__PURE__ */ jsx(FieldError, { children: error }),
2069
+ /* @__PURE__ */ jsxs("div", {
2070
+ className: "mt-2 flex gap-2",
2071
+ children: [/* @__PURE__ */ jsx(Button, {
2072
+ size: "sm",
2073
+ disabled: !dirty,
2074
+ onClick: () => {
2075
+ try {
2076
+ props.onApply(JSON.parse(text));
2077
+ setError(null);
2078
+ } catch (parseError) {
2079
+ setError(parseError instanceof Error ? parseError.message : "Not valid JSON");
2080
+ }
2081
+ },
2082
+ children: "Apply JSON"
2083
+ }), dirty ? /* @__PURE__ */ jsx(Button, {
2084
+ size: "sm",
2085
+ variant: "ghost",
2086
+ onClick: () => {
2087
+ setText(stringify(props.value));
2088
+ setError(null);
2089
+ },
2090
+ children: "Discard"
2091
+ }) : null]
2092
+ })
2093
+ ] });
2094
+ }
2095
+ function FormSkeleton() {
2096
+ return /* @__PURE__ */ jsx("div", {
2097
+ className: "flex animate-pulse flex-col gap-5",
2098
+ "aria-label": "Loading",
2099
+ children: [
2100
+ 0,
2101
+ 1,
2102
+ 2
2103
+ ].map((row) => /* @__PURE__ */ jsxs("div", {
2104
+ className: "flex flex-col gap-2",
2105
+ children: [/* @__PURE__ */ jsx("div", { className: "h-3 w-24 rounded bg-foreground/10" }), /* @__PURE__ */ jsx("div", { className: "h-9 rounded-md bg-foreground/5" })]
2106
+ }, row))
2107
+ });
2108
+ }
2109
+ function ConfigSection(props) {
2110
+ const { form } = props;
2111
+ const designTime = useDesignTime();
2112
+ const gate = useSignInGate();
2113
+ const configRecord = props.config ?? {};
2114
+ const declared = form && form !== "loading" ? form.requireReactor : void 0;
2115
+ const optionsBlocked = declared && gate.required ? "Sign in to load options" : void 0;
2116
+ const explainOptionsError = declared && !props.reactorConnectionId ? (message) => `Bind a reactor connection first. ${message}` : void 0;
2117
+ if (form === "loading") return /* @__PURE__ */ jsx(FormSkeleton, {});
2118
+ return /* @__PURE__ */ jsxs("div", {
2119
+ className: "flex flex-col gap-5",
2120
+ children: [
2121
+ form?.description || form?.classification === "DESTRUCTIVE" ? /* @__PURE__ */ jsxs("div", {
2122
+ className: "flex flex-col gap-2",
2123
+ children: [form.classification === "DESTRUCTIVE" ? /* @__PURE__ */ jsxs("span", {
2124
+ className: "inline-flex items-center gap-1 self-start rounded-full bg-wf-fail/10 px-2 py-0.5 text-[11px] font-medium text-wf-fail",
2125
+ children: [/* @__PURE__ */ jsx(Icon, {
2126
+ name: "alert",
2127
+ className: "h-3 w-3"
2128
+ }), "Changes or deletes data"]
2129
+ }) : null, form.description ? /* @__PURE__ */ jsx("p", {
2130
+ className: "text-[13px] leading-relaxed text-muted-foreground",
2131
+ children: form.description
2132
+ }) : null]
2133
+ }) : null,
2134
+ props.formError ? /* @__PURE__ */ jsx("p", {
2135
+ className: "rounded-md bg-wf-fail/10 px-3 py-2 text-xs text-wf-fail",
2136
+ children: props.formError
2137
+ }) : null,
2138
+ form && form.props.length > 0 ? /* @__PURE__ */ jsx(PropertyForm, {
2139
+ props: form.props,
2140
+ groups: form.propertyGroups,
2141
+ value: configRecord,
2142
+ onChange: props.onChange,
2143
+ settings: props.settings,
2144
+ writesSettings: props.writesSettings,
2145
+ scopeStepId: props.scopeStepId,
2146
+ connectionId: props.connectionId,
2147
+ reactorConnectionId: props.reactorConnectionId,
2148
+ optionsBlocked,
2149
+ explainOptionsError,
2150
+ secrets: designTime?.secrets,
2151
+ block: props.block,
2152
+ webhookUrl: props.webhookUrl,
2153
+ loadOptions: designTime ? (propName, current, searchValue) => designTime.loadOptions(props.block, propName, current, props.connectionId, searchValue, props.reactorConnectionId) : void 0
2154
+ }) : null,
2155
+ form && form.props.length === 0 ? /* @__PURE__ */ jsx("p", {
2156
+ className: "text-[13px] text-muted-foreground",
2157
+ children: "Nothing to set up. This block runs as it is."
2158
+ }) : null,
2159
+ !form && !props.formError ? /* @__PURE__ */ jsx("p", {
2160
+ className: "text-[13px] text-muted-foreground",
2161
+ children: "This block has no form. Edit its configuration as JSON under Settings."
2162
+ }) : null
2163
+ ]
2164
+ });
2165
+ }
2166
+ function PanelHeader(props) {
2167
+ return /* @__PURE__ */ jsxs("header", {
2168
+ className: "border-b border-solid border-foreground/10 px-4 pt-4",
2169
+ children: [
2170
+ /* @__PURE__ */ jsxs("div", {
2171
+ className: "flex items-start gap-3",
2172
+ children: [
2173
+ /* @__PURE__ */ jsx("div", {
2174
+ className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-lg border border-solid border-foreground/10 bg-card",
2175
+ children: /* @__PURE__ */ jsx(BlockLogo, {
2176
+ block: props.block,
2177
+ size: 24
2178
+ })
2179
+ }),
2180
+ /* @__PURE__ */ jsxs("div", {
2181
+ className: "min-w-0 flex-1",
2182
+ children: [props.onRename ? /* @__PURE__ */ jsx("input", {
2183
+ "aria-label": "Step name",
2184
+ className: "-mx-1 w-full rounded-md border border-solid border-transparent bg-transparent px-1 text-[15px] font-semibold text-foreground hover:border-foreground/15 focus:border-ring focus:outline-none focus:ring-2 focus:ring-ring/25",
2185
+ defaultValue: props.name,
2186
+ spellCheck: false,
2187
+ onKeyDown: (event) => {
2188
+ if (event.key === "Enter") event.currentTarget.blur();
2189
+ if (event.key === "Escape") {
2190
+ event.currentTarget.value = props.name;
2191
+ event.currentTarget.blur();
2192
+ }
2193
+ },
2194
+ onBlur: (event) => {
2195
+ const name = event.target.value.trim();
2196
+ if (name && name !== props.name) props.onRename(name);
2197
+ else event.target.value = props.name;
2198
+ }
2199
+ }, props.name) : /* @__PURE__ */ jsx("h3", {
2200
+ className: "truncate text-[15px] font-semibold text-foreground",
2201
+ children: props.name
2202
+ }), /* @__PURE__ */ jsx("p", {
2203
+ className: "truncate text-xs text-muted-foreground",
2204
+ children: props.actionLabel
2205
+ })]
2206
+ }),
2207
+ props.position ? /* @__PURE__ */ jsxs("div", {
2208
+ className: "flex shrink-0 items-center",
2209
+ children: [
2210
+ /* @__PURE__ */ jsx(IconButton, {
2211
+ icon: "back",
2212
+ label: "Previous step",
2213
+ disabled: !props.position.onPrevious,
2214
+ onClick: props.position.onPrevious
2215
+ }),
2216
+ /* @__PURE__ */ jsxs("span", {
2217
+ className: "px-0.5 text-xs tabular-nums text-muted-foreground",
2218
+ children: [
2219
+ props.position.index + 1,
2220
+ " of ",
2221
+ props.position.total
2222
+ ]
2223
+ }),
2224
+ /* @__PURE__ */ jsx(IconButton, {
2225
+ icon: "chevron",
2226
+ label: "Next step",
2227
+ disabled: !props.position.onNext,
2228
+ onClick: props.position.onNext
2229
+ })
2230
+ ]
2231
+ }) : null,
2232
+ /* @__PURE__ */ jsx(IconButton, {
2233
+ icon: "close",
2234
+ label: "Close panel",
2235
+ onClick: props.onClose
2236
+ })
2237
+ ]
2238
+ }),
2239
+ /* @__PURE__ */ jsx("div", {
2240
+ className: "mt-3 flex items-center gap-1.5 text-xs",
2241
+ children: props.skipped ? /* @__PURE__ */ jsx("span", {
2242
+ className: "flex items-center gap-1.5 text-muted-foreground",
2243
+ children: "Skipped: runs pass over this step"
2244
+ }) : props.loading ? /* @__PURE__ */ jsx("span", {
2245
+ className: "text-muted-foreground",
2246
+ children: "Checking setup…"
2247
+ }) : props.issues && props.issues.length > 0 ? /* @__PURE__ */ jsxs("span", {
2248
+ className: "flex min-w-0 items-center gap-1.5 text-wf-fail",
2249
+ title: props.issues.join("\n"),
2250
+ children: [/* @__PURE__ */ jsx(Icon, {
2251
+ name: "alert",
2252
+ className: "h-3.5 w-3.5"
2253
+ }), /* @__PURE__ */ jsx("span", {
2254
+ className: "truncate",
2255
+ children: props.issues[0]
2256
+ })]
2257
+ }) : props.missing === null ? null : props.missing.length > 0 ? /* @__PURE__ */ jsxs("span", {
2258
+ className: "flex min-w-0 items-center gap-1.5 text-wf-warn",
2259
+ title: props.missing.join(", "),
2260
+ children: [/* @__PURE__ */ jsx(Icon, {
2261
+ name: "alert",
2262
+ className: "h-3.5 w-3.5"
2263
+ }), /* @__PURE__ */ jsx("span", {
2264
+ className: "truncate",
2265
+ children: props.missing.length === 1 ? `${props.missing[0]} needs a value` : `${props.missing.length} fields need a value: ${props.missing.join(", ")}`
2266
+ })]
2267
+ }) : /* @__PURE__ */ jsxs("span", {
2268
+ className: "flex items-center gap-1.5 text-wf-ok",
2269
+ children: [/* @__PURE__ */ jsx(Icon, {
2270
+ name: "check",
2271
+ className: "h-3.5 w-3.5"
2272
+ }), "Ready to run"]
2273
+ })
2274
+ }),
2275
+ /* @__PURE__ */ jsx("div", {
2276
+ className: "mt-3",
2277
+ children: props.children
2278
+ })
2279
+ ]
2280
+ });
2281
+ }
2282
+ function intOrUndefined(raw) {
2283
+ const parsed = Number.parseInt(raw.trim(), 10);
2284
+ return Number.isFinite(parsed) && parsed >= 0 ? parsed : void 0;
2285
+ }
2286
+ function NumberField(props) {
2287
+ return /* @__PURE__ */ jsxs("label", {
2288
+ className: "block",
2289
+ children: [
2290
+ /* @__PURE__ */ jsx(FieldLabel, { label: props.label }),
2291
+ /* @__PURE__ */ jsxs("span", {
2292
+ className: "relative block",
2293
+ children: [/* @__PURE__ */ jsx("input", {
2294
+ type: "number",
2295
+ min: props.min,
2296
+ max: props.max,
2297
+ className: `${textInputClass} ${props.unit ? "pr-16" : ""}`,
2298
+ defaultValue: props.value ?? "",
2299
+ placeholder: props.placeholder,
2300
+ onBlur: (event) => {
2301
+ const raw = event.target.value.trim();
2302
+ if (raw === "") return props.onCommit(null);
2303
+ let next = intOrUndefined(raw);
2304
+ if (next !== void 0 && props.max !== void 0 && next > props.max) {
2305
+ next = props.max;
2306
+ event.target.value = String(next);
2307
+ }
2308
+ if (next !== void 0 && next >= (props.min ?? 0)) props.onCommit(next);
2309
+ }
2310
+ }, `${props.label}-${props.value ?? ""}`), props.unit ? /* @__PURE__ */ jsx("span", {
2311
+ className: "pointer-events-none absolute inset-y-0 right-3 flex items-center text-xs text-muted-foreground",
2312
+ children: props.unit
2313
+ }) : null]
2314
+ }),
2315
+ props.hint ? /* @__PURE__ */ jsx(Hint, { children: props.hint }) : null
2316
+ ]
2317
+ });
2318
+ }
2319
+ function RetryEditor(props) {
2320
+ const retry = props.value;
2321
+ const patch = (partial) => props.onChange(normalizeRetry({
2322
+ ...retry ?? DEFAULT_RETRY,
2323
+ ...partial
2324
+ }));
2325
+ return /* @__PURE__ */ jsxs("div", {
2326
+ className: "flex flex-col gap-4",
2327
+ children: [/* @__PURE__ */ jsx(Switch, {
2328
+ checked: retry !== null,
2329
+ onChange: (checked) => props.onChange(checked ? DEFAULT_RETRY : null),
2330
+ label: "Retry when it fails",
2331
+ description: "Try the step again before failing the run."
2332
+ }), retry ? /* @__PURE__ */ jsxs("div", {
2333
+ className: "grid grid-cols-2 gap-3",
2334
+ children: [
2335
+ /* @__PURE__ */ jsx(NumberField, {
2336
+ label: "Attempts",
2337
+ value: retry.maxAttempts,
2338
+ min: 1,
2339
+ max: 10,
2340
+ hint: `Including the first run; up to 10.`,
2341
+ onCommit: (next) => {
2342
+ if (next !== null) patch({ maxAttempts: next });
2343
+ }
2344
+ }),
2345
+ /* @__PURE__ */ jsxs("label", {
2346
+ className: "block",
2347
+ children: [/* @__PURE__ */ jsx(FieldLabel, { label: "Backoff" }), /* @__PURE__ */ jsx(Select, {
2348
+ value: retry.backoff,
2349
+ options: [{
2350
+ value: "FIXED",
2351
+ label: "Fixed"
2352
+ }, {
2353
+ value: "EXPONENTIAL",
2354
+ label: "Exponential"
2355
+ }],
2356
+ onChange: (backoff) => patch({ backoff })
2357
+ })]
2358
+ }),
2359
+ /* @__PURE__ */ jsx(NumberField, {
2360
+ label: "First delay",
2361
+ unit: "seconds",
2362
+ value: retry.initialDelaySeconds,
2363
+ max: 300,
2364
+ onCommit: (next) => {
2365
+ if (next !== null) patch({ initialDelaySeconds: next });
2366
+ }
2367
+ }),
2368
+ /* @__PURE__ */ jsx(NumberField, {
2369
+ label: "Longest delay",
2370
+ unit: "seconds",
2371
+ value: retry.maxDelaySeconds,
2372
+ max: 300,
2373
+ hint: `Up to 300.`,
2374
+ onCommit: (next) => {
2375
+ if (next !== null) patch({ maxDelaySeconds: next });
2376
+ }
2377
+ }),
2378
+ /* @__PURE__ */ jsxs("label", {
2379
+ className: "col-span-2 block",
2380
+ children: [
2381
+ /* @__PURE__ */ jsx(FieldLabel, {
2382
+ label: "Retry on",
2383
+ optional: true
2384
+ }),
2385
+ /* @__PURE__ */ jsx("input", {
2386
+ className: `${textInputClass} font-mono text-xs`,
2387
+ defaultValue: retry.retryOn.join(", "),
2388
+ placeholder: "TRANSIENT, RATE_LIMIT",
2389
+ onBlur: (event) => patch({ retryOn: parseRetryOn(event.target.value) })
2390
+ }, `on-${retry.retryOn.join(",")}`),
2391
+ /* @__PURE__ */ jsx(Hint, { children: "Error classes, comma-separated. Empty retries every error." })
2392
+ ]
2393
+ })
2394
+ ]
2395
+ }) : null]
2396
+ });
2397
+ }
2398
+ const PORT_LABEL = {
2399
+ next: "Then",
2400
+ true: "When true",
2401
+ false: "When false"
2402
+ };
2403
+ function EdgeRow(props) {
2404
+ return /* @__PURE__ */ jsxs("div", {
2405
+ className: `flex min-w-0 items-center gap-2 rounded-md border border-solid px-2 py-1.5 text-[13px] ${props.tone === "warn" ? "border-wf-warn/30 bg-wf-warn/5" : props.tone === "fail" ? "border-wf-fail/30 bg-wf-fail/5" : "border-foreground/10 bg-muted/40"}`,
2406
+ children: [
2407
+ /* @__PURE__ */ jsx(Icon, {
2408
+ name: "arrowRight",
2409
+ className: "h-3.5 w-3.5 text-muted-foreground"
2410
+ }),
2411
+ props.target ? /* @__PURE__ */ jsx(BlockLogo, {
2412
+ block: stepBlock(props.target),
2413
+ size: 16
2414
+ }) : null,
2415
+ /* @__PURE__ */ jsx("span", {
2416
+ className: "min-w-0 flex-1 truncate text-foreground",
2417
+ children: props.target ? props.target.name || props.target.key : props.fallback
2418
+ }),
2419
+ /* @__PURE__ */ jsx(IconButton, {
2420
+ icon: "close",
2421
+ label: "Disconnect",
2422
+ onClick: props.onRemove
2423
+ })
2424
+ ]
2425
+ });
2426
+ }
2427
+ function FlowPortEditor(props) {
2428
+ const { step, model, callbacks } = props;
2429
+ const block = stepBlock(step);
2430
+ const { form } = useBlockForm(block);
2431
+ const declared = stepPorts(block, step.config, () => form && form !== "loading" ? form.ports : void 0, model.edges.filter((edge) => edge.from === step.id).map((e) => e.port));
2432
+ const ports = declared ? flowPorts(declared) : [];
2433
+ const dead = declared ? model.edges.filter((edge) => edge.from === step.id && !declared.includes(edge.port)) : [];
2434
+ const attached = model.trigger ? reachableFrom(model.trigger.id, model.edges) : /* @__PURE__ */ new Set();
2435
+ const candidates = acyclicTargets(model, step.id);
2436
+ return /* @__PURE__ */ jsxs("div", {
2437
+ className: "flex flex-col gap-4",
2438
+ children: [dead.length > 0 ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(FieldLabel, { label: "Never taken" }), /* @__PURE__ */ jsx("div", {
2439
+ className: "flex flex-col gap-1.5",
2440
+ children: dead.map((edge) => /* @__PURE__ */ jsx(EdgeRow, {
2441
+ tone: "fail",
2442
+ target: model.steps.find((entry) => entry.id === edge.to),
2443
+ fallback: `${edge.to} (port "${edge.port}")`,
2444
+ onRemove: () => callbacks.removeEdge(edge.id)
2445
+ }, edge.id))
2446
+ })] }) : null, ports.map((port) => {
2447
+ const edges = model.edges.filter((candidate) => candidate.from === step.id && candidate.port === port);
2448
+ const targets = candidates.filter((candidate) => !edges.some((edge) => edge.to === candidate.id));
2449
+ return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(FieldLabel, { label: stepPortLabel(block, step.config, port) ?? PORT_LABEL[port] ?? port }), /* @__PURE__ */ jsxs("div", {
2450
+ className: "flex flex-col gap-1.5",
2451
+ children: [edges.map((edge) => /* @__PURE__ */ jsx(EdgeRow, {
2452
+ target: model.steps.find((entry) => entry.id === edge.to),
2453
+ fallback: edge.to,
2454
+ onRemove: () => callbacks.removeEdge(edge.id)
2455
+ }, edge.id)), /* @__PURE__ */ jsx(Select, {
2456
+ value: "",
2457
+ disabled: targets.length === 0,
2458
+ placeholder: targets.length === 0 ? "No other step to connect to" : edges.length > 0 ? "Also run…" : "Run next…",
2459
+ options: targets.map((target) => ({
2460
+ value: target.id,
2461
+ label: target.name || target.key,
2462
+ description: attached.has(target.id) ? void 0 : "Not connected to the trigger yet",
2463
+ icon: /* @__PURE__ */ jsx(BlockLogo, {
2464
+ block: stepBlock(target),
2465
+ size: 16
2466
+ })
2467
+ })),
2468
+ onChange: (to) => {
2469
+ if (to) callbacks.addEdge({
2470
+ from: step.id,
2471
+ to,
2472
+ port
2473
+ });
2474
+ }
2475
+ })]
2476
+ })] }, port);
2477
+ })]
2478
+ });
2479
+ }
2480
+ function ErrorPortEditor(props) {
2481
+ const { step, model, callbacks } = props;
2482
+ const errorEdges = model.edges.filter((edge) => edge.from === step.id && edge.port === "error");
2483
+ const targets = acyclicTargets(model, step.id).filter((candidate) => !errorEdges.some((edge) => edge.to === candidate.id));
2484
+ return /* @__PURE__ */ jsxs("div", { children: [
2485
+ /* @__PURE__ */ jsx(FieldLabel, {
2486
+ label: "On error, run",
2487
+ optional: true
2488
+ }),
2489
+ /* @__PURE__ */ jsxs("div", {
2490
+ className: "flex flex-col gap-1.5",
2491
+ children: [errorEdges.map((edge) => /* @__PURE__ */ jsx(EdgeRow, {
2492
+ tone: "warn",
2493
+ target: model.steps.find((entry) => entry.id === edge.to),
2494
+ fallback: edge.to,
2495
+ onRemove: () => callbacks.removeEdge(edge.id)
2496
+ }, edge.id)), /* @__PURE__ */ jsx(Select, {
2497
+ value: "",
2498
+ disabled: targets.length === 0,
2499
+ placeholder: targets.length === 0 ? "No other step to run" : errorEdges.length > 0 ? "Also run…" : "Fail the run",
2500
+ options: targets.map((target) => ({
2501
+ value: target.id,
2502
+ label: target.name || target.key,
2503
+ icon: /* @__PURE__ */ jsx(BlockLogo, {
2504
+ block: stepBlock(target),
2505
+ size: 16
2506
+ })
2507
+ })),
2508
+ onChange: (to) => {
2509
+ if (to) callbacks.addEdge({
2510
+ from: step.id,
2511
+ to,
2512
+ port: "error"
2513
+ });
2514
+ }
2515
+ })]
2516
+ }),
2517
+ /* @__PURE__ */ jsx(Hint, { children: "Route failures to another step instead of failing the run." })
2518
+ ] });
2519
+ }
2520
+ function insertAtCursor(element, text) {
2521
+ const start = element.selectionStart ?? element.value.length;
2522
+ const end = element.selectionEnd ?? start;
2523
+ element.value = element.value.slice(0, start) + text + element.value.slice(end);
2524
+ return element.value;
2525
+ }
2526
+ function IdempotencyField(props) {
2527
+ const { step, callbacks } = props;
2528
+ const ref = useRef(null);
2529
+ const [draft, setDraft] = useState(step.idempotencyKeyExpression ?? "");
2530
+ const commit = (raw) => {
2531
+ const next = raw.trim() || null;
2532
+ if (next !== step.idempotencyKeyExpression) callbacks.updateStep({
2533
+ id: step.id,
2534
+ idempotencyKeyExpression: next
2535
+ });
2536
+ };
2537
+ const field = useExpressionField({
2538
+ stepId: step.id,
2539
+ label: "Idempotency key",
2540
+ insert: (expression) => {
2541
+ if (!ref.current) return;
2542
+ const next = insertAtCursor(ref.current, expression);
2543
+ setDraft(next);
2544
+ commit(next);
2545
+ }
2546
+ });
2547
+ return /* @__PURE__ */ jsxs("div", {
2548
+ className: "group/field",
2549
+ children: [
2550
+ /* @__PURE__ */ jsx(FieldLabel, {
2551
+ label: "Idempotency key",
2552
+ optional: true,
2553
+ action: /* @__PURE__ */ jsx(ExpressionPickerButton, {
2554
+ active: field.active,
2555
+ onFocusField: field.focus
2556
+ })
2557
+ }),
2558
+ /* @__PURE__ */ jsx("input", {
2559
+ ref,
2560
+ "aria-label": "Idempotency key",
2561
+ className: `${textInputClass} font-mono text-xs`,
2562
+ defaultValue: step.idempotencyKeyExpression ?? "",
2563
+ placeholder: "{{trigger.payload.id}}",
2564
+ spellCheck: false,
2565
+ onFocus: field.focus,
2566
+ onChange: (event) => setDraft(event.target.value),
2567
+ onBlur: (event) => commit(event.target.value)
2568
+ }, `${step.id}-idem`),
2569
+ /* @__PURE__ */ jsx(ExpressionTokenLine, { value: draft }),
2570
+ /* @__PURE__ */ jsx(Hint, { children: "Two runs with the same key count as one side effect." })
2571
+ ]
2572
+ });
2573
+ }
2574
+ function KeyField(props) {
2575
+ const { step, callbacks } = props;
2576
+ const [copied, setCopied] = useState(false);
2577
+ const id = useId();
2578
+ return /* @__PURE__ */ jsxs("div", { children: [
2579
+ /* @__PURE__ */ jsx(FieldLabel, {
2580
+ htmlFor: id,
2581
+ label: "Key",
2582
+ action: /* @__PURE__ */ jsx(IconButton, {
2583
+ icon: copied ? "check" : "copy",
2584
+ label: "Copy reference",
2585
+ onClick: (event) => {
2586
+ event.preventDefault();
2587
+ navigator.clipboard.writeText(`{{steps.${step.key}.output}}`).then(() => setCopied(true), () => void 0);
2588
+ }
2589
+ })
2590
+ }),
2591
+ /* @__PURE__ */ jsx("input", {
2592
+ id,
2593
+ className: `${textInputClass} font-mono text-xs`,
2594
+ defaultValue: step.key,
2595
+ spellCheck: false,
2596
+ onBlur: (event) => {
2597
+ const key = event.target.value.trim();
2598
+ if (key && key !== step.key) callbacks.updateStep({
2599
+ id: step.id,
2600
+ key
2601
+ });
2602
+ else event.target.value = step.key;
2603
+ }
2604
+ }, `${step.id}-key-${step.key}`),
2605
+ /* @__PURE__ */ jsxs(Hint, { children: [
2606
+ "Later steps read this step's output as",
2607
+ " ",
2608
+ /* @__PURE__ */ jsx("code", {
2609
+ className: "rounded bg-muted px-1 font-mono text-[11px] text-foreground",
2610
+ children: `{{steps.${step.key}.output.…}}`
2611
+ }),
2612
+ ". Renaming it doesn't update expressions that use it."
2613
+ ] })
2614
+ ] });
2615
+ }
2616
+ function PieceVersionSection(props) {
2617
+ const resolution = useResolution(props.id, props.block);
2618
+ const update = updateVersion(resolution);
2619
+ const [updated, setUpdated] = useState(null);
2620
+ const differs = resolution ? runsDifferentVersion(resolution) : false;
2621
+ if (!resolution && !updated) return null;
2622
+ if (isCoreBlock(props.block) && !differs && !update && !updated) return null;
2623
+ return /* @__PURE__ */ jsxs(Section, {
2624
+ title: "Piece version",
2625
+ children: [/* @__PURE__ */ jsxs("div", {
2626
+ className: "flex items-center justify-between gap-3",
2627
+ children: [/* @__PURE__ */ jsx("p", {
2628
+ className: "text-xs text-muted-foreground",
2629
+ children: resolution ? differs ? resolutionText(resolution) : `Runs v${resolution.pieceVersion}${resolution.source ? ` from ${resolution.source}` : ""}` : null
2630
+ }), update && props.onUpdate ? /* @__PURE__ */ jsxs(Button, {
2631
+ size: "sm",
2632
+ variant: "secondary",
2633
+ onClick: () => {
2634
+ props.onUpdate(update);
2635
+ setUpdated(update);
2636
+ },
2637
+ children: ["Update to v", update]
2638
+ }) : null]
2639
+ }), updated ? /* @__PURE__ */ jsxs("p", {
2640
+ role: "status",
2641
+ className: "text-xs text-muted-foreground",
2642
+ children: [
2643
+ "Updated to v",
2644
+ updated,
2645
+ ". The ",
2646
+ props.kind,
2647
+ "'s fields are re-checked against this version."
2648
+ ]
2649
+ }) : null]
2650
+ });
2651
+ }
2652
+ function StepSettings(props) {
2653
+ const { step, callbacks } = props;
2654
+ const retryHint = step.retry ? null : inheritedRetryHint(props.model.defaultRetryAttempts, props.actionDefaults?.retryAttempts);
2655
+ return /* @__PURE__ */ jsxs("div", {
2656
+ className: "flex flex-col gap-6",
2657
+ children: [
2658
+ /* @__PURE__ */ jsx(PieceVersionSection, {
2659
+ id: step.id,
2660
+ block: stepBlock(step),
2661
+ kind: "step",
2662
+ onUpdate: (pieceVersion) => callbacks.updateStep({
2663
+ id: step.id,
2664
+ pieceVersion
2665
+ })
2666
+ }),
2667
+ /* @__PURE__ */ jsx(Section, {
2668
+ title: "Run",
2669
+ children: /* @__PURE__ */ jsx(Switch, {
2670
+ checked: step.skip === true,
2671
+ onChange: (skip) => callbacks.updateStep({
2672
+ id: step.id,
2673
+ skip
2674
+ }),
2675
+ label: "Skip this step",
2676
+ description: "Runs pass over it and carry on with the next step."
2677
+ })
2678
+ }),
2679
+ /* @__PURE__ */ jsx(Section, {
2680
+ title: "Identity",
2681
+ children: /* @__PURE__ */ jsx(KeyField, {
2682
+ step,
2683
+ callbacks
2684
+ })
2685
+ }),
2686
+ /* @__PURE__ */ jsx(Section, {
2687
+ title: "What runs next",
2688
+ description: "Any step that isn't upstream of this one.",
2689
+ children: /* @__PURE__ */ jsx(FlowPortEditor, {
2690
+ step,
2691
+ model: props.model,
2692
+ callbacks
2693
+ })
2694
+ }),
2695
+ /* @__PURE__ */ jsxs(Section, {
2696
+ title: "When it fails",
2697
+ children: [
2698
+ /* @__PURE__ */ jsx(ErrorPortEditor, {
2699
+ step,
2700
+ model: props.model,
2701
+ callbacks
2702
+ }),
2703
+ /* @__PURE__ */ jsx(NumberField, {
2704
+ label: "Timeout",
2705
+ unit: "seconds",
2706
+ min: 1,
2707
+ value: step.timeoutSeconds,
2708
+ placeholder: props.actionDefaults?.timeoutSeconds ? `Action default: ${props.actionDefaults.timeoutSeconds}` : "Runtime default",
2709
+ onCommit: (next) => {
2710
+ if (next === 0) return;
2711
+ if (next !== step.timeoutSeconds) callbacks.updateStep({
2712
+ id: step.id,
2713
+ timeoutSeconds: next
2714
+ });
2715
+ }
2716
+ }),
2717
+ retryHint ? /* @__PURE__ */ jsx(Hint, { children: retryHint }) : null,
2718
+ props.errorHandling?.retryOnFailure?.defaultValue && props.actionDefaults?.retryAttempts === void 0 ? /* @__PURE__ */ jsx(Hint, { children: "This piece suggests retrying the step when it fails." }) : null,
2719
+ props.errorHandling?.retryOnFailure?.hide === true ? null : /* @__PURE__ */ jsx(RetryEditor, {
2720
+ value: step.retry,
2721
+ onChange: (retry) => callbacks.updateStep({
2722
+ id: step.id,
2723
+ retry
2724
+ })
2725
+ }),
2726
+ /* @__PURE__ */ jsxs("fieldset", {
2727
+ hidden: props.errorHandling?.retryOnFailure?.hide === true,
2728
+ disabled: true,
2729
+ className: "m-0 flex min-w-0 flex-col gap-4 rounded-lg border border-dashed border-foreground/15 p-3",
2730
+ children: [/* @__PURE__ */ jsx("legend", {
2731
+ className: "px-1",
2732
+ children: /* @__PURE__ */ jsx(AvailableSoon, { children: "idempotency" })
2733
+ }), /* @__PURE__ */ jsx("div", {
2734
+ className: "opacity-70",
2735
+ children: /* @__PURE__ */ jsx(IdempotencyField, {
2736
+ step,
2737
+ callbacks
2738
+ })
2739
+ })]
2740
+ })
2741
+ ]
2742
+ }),
2743
+ /* @__PURE__ */ jsx(Section, {
2744
+ title: "Configuration as JSON",
2745
+ description: "Everything the setup form stores, for pasting or bulk edits.",
2746
+ children: /* @__PURE__ */ jsx(RawConfigEditor, {
2747
+ value: step.config,
2748
+ onApply: (config) => callbacks.updateStep({
2749
+ id: step.id,
2750
+ config
2751
+ })
2752
+ })
2753
+ }),
2754
+ /* @__PURE__ */ jsx(Section, {
2755
+ title: "Remove",
2756
+ children: /* @__PURE__ */ jsxs("div", {
2757
+ className: "flex items-center justify-between gap-3",
2758
+ children: [/* @__PURE__ */ jsx("p", {
2759
+ className: "text-xs text-muted-foreground",
2760
+ children: "Removes the step and its connections."
2761
+ }), /* @__PURE__ */ jsxs(Button, {
2762
+ variant: "danger",
2763
+ onClick: () => {
2764
+ callbacks.removeStep(step.id);
2765
+ props.onRemoved();
2766
+ },
2767
+ children: [/* @__PURE__ */ jsx(Icon, {
2768
+ name: "trash",
2769
+ className: "h-3.5 w-3.5"
2770
+ }), "Remove step"]
2771
+ })]
2772
+ })
2773
+ })
2774
+ ]
2775
+ });
2776
+ }
2777
+ const RUN_TEXT = {
2778
+ SUCCEEDED: "text-wf-ok",
2779
+ FAILED: "text-wf-fail",
2780
+ SKIPPED: "text-muted-foreground"
2781
+ };
2782
+ function LastRunSection(props) {
2783
+ const own = useLatestRun(props.latest === void 0);
2784
+ const latest = props.latest ?? own;
2785
+ if (!latest) return null;
2786
+ const run = latest.kind === "ready" ? latest.run : null;
2787
+ const step = props.stepKey ? run?.steps.find((entry) => entry.stepKey === props.stepKey) : void 0;
2788
+ const status = props.stepKey ? step?.status : run ? "FIRED" : void 0;
2789
+ const body = /* @__PURE__ */ jsx(Fragment$1, { children: latest.kind === "loading" ? /* @__PURE__ */ jsx("div", { className: "h-16 animate-pulse rounded-md bg-foreground/5" }) : !run ? /* @__PURE__ */ jsxs("p", {
2790
+ className: "text-xs text-muted-foreground",
2791
+ children: [
2792
+ "No runs yet. Once the workflow runs, what this",
2793
+ " ",
2794
+ props.stepKey ? "step receives and produces" : "trigger hands on",
2795
+ " ",
2796
+ "shows up here."
2797
+ ]
2798
+ }) : props.stepKey && !step ? /* @__PURE__ */ jsxs("p", {
2799
+ className: "text-xs text-muted-foreground",
2800
+ children: [
2801
+ "The last run, ",
2802
+ relativeTime(run.startedAt),
2803
+ ", didn't reach this step."
2804
+ ]
2805
+ }) : /* @__PURE__ */ jsxs("div", {
2806
+ className: "flex flex-col gap-3",
2807
+ children: [
2808
+ /* @__PURE__ */ jsxs("p", {
2809
+ className: "text-xs text-muted-foreground",
2810
+ children: [
2811
+ /* @__PURE__ */ jsx("span", {
2812
+ className: `font-medium ${RUN_TEXT[status ?? ""] ?? "text-wf-ok"}`,
2813
+ children: status === "FIRED" ? "Fired" : (status ?? "").charAt(0) + (status ?? "").slice(1).toLowerCase()
2814
+ }),
2815
+ " ",
2816
+ relativeTime(run.startedAt)
2817
+ ]
2818
+ }),
2819
+ step?.error ? /* @__PURE__ */ jsx(StepError, { error: step.error }) : null,
2820
+ step ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(DataViewer, {
2821
+ label: "Received",
2822
+ value: step.input
2823
+ }), /* @__PURE__ */ jsx(DataViewer, {
2824
+ label: "Produced",
2825
+ value: step.output,
2826
+ root: `steps.${props.stepKey}.output`
2827
+ })] }) : /* @__PURE__ */ jsx(DataViewer, {
2828
+ label: "Payload",
2829
+ value: run.triggerPayload,
2830
+ root: "trigger.payload"
2831
+ })
2832
+ ]
2833
+ }) });
2834
+ return props.bare ? /* @__PURE__ */ jsx("div", {
2835
+ className: "flex flex-col gap-4",
2836
+ children: body
2837
+ }) : /* @__PURE__ */ jsx(Section, {
2838
+ title: "Last run",
2839
+ children: body
2840
+ });
2841
+ }
2842
+ const STEP_TABS = [
2843
+ "setup",
2844
+ "run",
2845
+ "settings"
2846
+ ];
2847
+ function settingsCustomised(step, model) {
2848
+ return [
2849
+ step.retry !== null,
2850
+ step.timeoutSeconds !== null,
2851
+ step.idempotencyKeyExpression !== null,
2852
+ model.edges.some((edge) => edge.from === step.id && edge.port === "error")
2853
+ ].filter(Boolean).length;
2854
+ }
2855
+ function StepPanel(props) {
2856
+ const { step, callbacks } = props;
2857
+ const designTime = useDesignTime();
2858
+ const [tab, setTabParam] = useSearchParam("tab", "setup", STEP_TABS);
2859
+ const setTab = (next) => setTabParam(next, { replace: true });
2860
+ const block = stepBlock(step);
2861
+ const meta = useBlockMeta(block);
2862
+ const { form, formError, missing, issues } = useBlockCheck({
2863
+ ...step,
2864
+ block,
2865
+ outgoingPorts: props.model.edges.filter((edge) => edge.from === step.id).map((edge) => edge.port)
2866
+ });
2867
+ const writes = !props.readOnly;
2868
+ const customised = settingsCustomised(step, props.model);
2869
+ const update = updateVersion(useResolution(step.id, block));
2870
+ const latest = useLatestRun();
2871
+ const lastStatus = latest?.kind === "ready" ? latest.run?.steps.find((entry) => entry.stepKey === step.key)?.status : void 0;
2872
+ const order = flowOrder(props.model);
2873
+ const index = order.indexOf(step.id);
2874
+ const select = props.onSelect;
2875
+ const position = select && index >= 0 ? {
2876
+ index,
2877
+ total: order.length,
2878
+ onPrevious: index > 0 ? () => select(order[index - 1]) : void 0,
2879
+ onNext: index < order.length - 1 ? () => select(order[index + 1]) : void 0
2880
+ } : void 0;
2881
+ return /* @__PURE__ */ jsxs("div", {
2882
+ className: "flex min-h-full flex-col",
2883
+ children: [/* @__PURE__ */ jsx(PanelHeader, {
2884
+ block,
2885
+ name: step.name || step.key,
2886
+ onRename: (name) => callbacks.updateStep({
2887
+ id: step.id,
2888
+ name
2889
+ }),
2890
+ actionLabel: form && form !== "loading" && form.title ? form.title : [meta.subtitle, meta.displayName].filter(Boolean).join(": "),
2891
+ missing,
2892
+ issues,
2893
+ loading: form === "loading",
2894
+ skipped: step.skip === true,
2895
+ onClose: props.onClose,
2896
+ position,
2897
+ children: /* @__PURE__ */ jsx(Tabs, {
2898
+ value: tab,
2899
+ onChange: setTab,
2900
+ tabs: [
2901
+ {
2902
+ value: "setup",
2903
+ label: "Setup"
2904
+ },
2905
+ ...latest ? [{
2906
+ value: "run",
2907
+ label: "Last run",
2908
+ badge: lastStatus ? /* @__PURE__ */ jsx("span", {
2909
+ "aria-label": lastStatus.toLowerCase(),
2910
+ className: `h-1.5 w-1.5 rounded-full ${lastStatus === "SUCCEEDED" ? "bg-wf-ok" : lastStatus === "FAILED" ? "bg-wf-fail" : "bg-foreground/30"}`
2911
+ }) : void 0
2912
+ }] : [],
2913
+ {
2914
+ value: "settings",
2915
+ label: "Settings",
2916
+ badge: customised > 0 ? /* @__PURE__ */ jsx("span", {
2917
+ className: "rounded-full bg-muted px-1.5 text-[11px] tabular-nums text-muted-foreground",
2918
+ children: customised
2919
+ }) : update ? /* @__PURE__ */ jsx("span", {
2920
+ "aria-label": "Update available",
2921
+ title: `v${update} is available`,
2922
+ className: "h-1.5 w-1.5 rounded-full bg-wf-run"
2923
+ }) : void 0
2924
+ }
2925
+ ]
2926
+ })
2927
+ }), /* @__PURE__ */ jsx("div", {
2928
+ className: "flex-1 px-4 py-5",
2929
+ children: tab === "setup" ? /* @__PURE__ */ jsxs("div", {
2930
+ className: "flex flex-col gap-5",
2931
+ children: [
2932
+ /* @__PURE__ */ jsx(ConnectionField, {
2933
+ block,
2934
+ value: step.connectionId ?? "",
2935
+ onChange: (connectionId) => callbacks.updateStep({
2936
+ id: step.id,
2937
+ connectionId
2938
+ })
2939
+ }, `${step.id}-conn`),
2940
+ /* @__PURE__ */ jsx(ReactorConnectionField, {
2941
+ block,
2942
+ value: step.reactorConnectionId ?? "",
2943
+ workflowId: designTime?.workflowId,
2944
+ publishedVersion: props.model.published?.version,
2945
+ onChange: (reactorConnectionId) => callbacks.updateStep({
2946
+ id: step.id,
2947
+ reactorConnectionId
2948
+ })
2949
+ }, `${step.id}-reactor`),
2950
+ /* @__PURE__ */ jsx(ConfigSection, {
2951
+ block,
2952
+ form,
2953
+ formError,
2954
+ config: step.config,
2955
+ settings: step.propertySettings,
2956
+ onChange: (config, settings) => callbacks.setStepConfig(step.id, config, writes ? { propertySettings: settings } : void 0),
2957
+ writesSettings: writes,
2958
+ connectionId: step.connectionId ?? void 0,
2959
+ reactorConnectionId: step.reactorConnectionId ?? void 0,
2960
+ scopeStepId: step.id
2961
+ }, `${step.id}-config`),
2962
+ writes ? /* @__PURE__ */ jsx(Section, {
2963
+ title: "Test",
2964
+ children: /* @__PURE__ */ jsx(StepTestSection, {
2965
+ step,
2966
+ model: props.model,
2967
+ onSelect: props.onSelect
2968
+ })
2969
+ }) : null
2970
+ ]
2971
+ }) : tab === "run" ? /* @__PURE__ */ jsx(LastRunSection, {
2972
+ stepKey: step.key,
2973
+ latest,
2974
+ bare: true
2975
+ }) : /* @__PURE__ */ jsx(StepSettings, {
2976
+ step,
2977
+ model: props.model,
2978
+ callbacks,
2979
+ errorHandling: form && form !== "loading" ? form.errorHandling : void 0,
2980
+ actionDefaults: form && form !== "loading" ? form.actionDefaults : void 0,
2981
+ onRemoved: props.onClose
2982
+ })
2983
+ })]
2984
+ });
2985
+ }
2986
+ function LastTestLine(props) {
2987
+ const { trigger } = props;
2988
+ const [open, setOpen] = useState(false);
2989
+ const run = useRunById(trigger.lastTest?.runId);
2990
+ const state = testState(trigger, run?.status);
2991
+ if (!trigger.lastTest) return /* @__PURE__ */ jsx("p", {
2992
+ className: "text-xs text-muted-foreground",
2993
+ children: "Not tested yet"
2994
+ });
2995
+ const output = run?.steps.at(0);
2996
+ return /* @__PURE__ */ jsxs("div", {
2997
+ className: "flex flex-col gap-2",
2998
+ children: [/* @__PURE__ */ jsxs("p", {
2999
+ className: "flex flex-wrap items-center gap-x-1.5 text-xs text-muted-foreground",
3000
+ children: [/* @__PURE__ */ jsxs("button", {
3001
+ type: "button",
3002
+ "aria-expanded": open,
3003
+ className: `font-medium underline decoration-foreground/20 underline-offset-2 hover:decoration-current ${state === "failed" ? "text-wf-fail" : "text-foreground"}`,
3004
+ title: new Date(trigger.lastTest.testedAt).toLocaleString(),
3005
+ onClick: () => setOpen((value) => !value),
3006
+ children: [
3007
+ state === "failed" ? "Test failed" : "Tested",
3008
+ " ",
3009
+ relativeTime(trigger.lastTest.testedAt)
3010
+ ]
3011
+ }), state === "stale" ? /* @__PURE__ */ jsx("span", {
3012
+ className: "text-wf-warn",
3013
+ children: "The trigger changed since, so test it again."
3014
+ }) : null]
3015
+ }), open ? run === void 0 ? /* @__PURE__ */ jsx("div", { className: "h-12 animate-pulse rounded-md bg-foreground/5" }) : run === null ? /* @__PURE__ */ jsx("p", {
3016
+ className: "text-xs text-muted-foreground",
3017
+ children: "That test run is no longer kept."
3018
+ }) : output?.error || run.error ? /* @__PURE__ */ jsx("pre", {
3019
+ className: "overflow-auto whitespace-pre-wrap rounded-md bg-wf-fail/10 p-2.5 text-xs text-wf-fail",
3020
+ children: output?.error ?? run.error
3021
+ }) : /* @__PURE__ */ jsx(DataViewer, {
3022
+ label: "Sample",
3023
+ value: output?.output,
3024
+ root: "trigger.payload"
3025
+ }) : null]
3026
+ });
3027
+ }
3028
+ function TestTriggerSection(props) {
3029
+ const [state, setState] = useState({ kind: "idle" });
3030
+ return /* @__PURE__ */ jsxs("div", {
3031
+ className: "flex flex-col gap-3",
3032
+ children: [
3033
+ /* @__PURE__ */ jsx(LastTestLine, { trigger: props.trigger }),
3034
+ /* @__PURE__ */ jsxs("div", {
3035
+ className: "flex items-center justify-between gap-3",
3036
+ children: [/* @__PURE__ */ jsx("p", {
3037
+ className: "text-xs text-muted-foreground",
3038
+ children: "Fetch sample data to see what this trigger hands the next steps."
3039
+ }), /* @__PURE__ */ jsxs(Button, {
3040
+ size: "sm",
3041
+ disabled: state.kind === "loading",
3042
+ onClick: () => {
3043
+ setState({ kind: "loading" });
3044
+ props.onTest().then((result) => setState({
3045
+ kind: "done",
3046
+ result: JSON.stringify(result, null, 2),
3047
+ failed: false
3048
+ }), (error) => setState({
3049
+ kind: "done",
3050
+ result: error instanceof Error ? error.message : String(error),
3051
+ failed: true
3052
+ }));
3053
+ },
3054
+ children: [/* @__PURE__ */ jsx(Icon, {
3055
+ name: "play",
3056
+ className: "h-3.5 w-3.5"
3057
+ }), state.kind === "loading" ? "Testing…" : "Test trigger"]
3058
+ })]
3059
+ }),
3060
+ state.kind === "done" ? /* @__PURE__ */ jsx("pre", {
3061
+ className: `mt-3 max-h-56 overflow-auto rounded-md p-2 text-xs ${state.failed ? "bg-wf-fail/10 text-wf-fail" : "bg-muted text-foreground"}`,
3062
+ children: state.result
3063
+ }) : null
3064
+ ]
3065
+ });
3066
+ }
3067
+ function WebhookUrlSection(props) {
3068
+ const [copied, setCopied] = useState(false);
3069
+ const state = props.state;
3070
+ return /* @__PURE__ */ jsxs("div", { children: [
3071
+ /* @__PURE__ */ jsx(FieldLabel, { label: "Endpoint URL" }),
3072
+ state.kind === "loading" ? /* @__PURE__ */ jsx("div", { className: "h-9 animate-pulse rounded-md bg-foreground/5" }) : null,
3073
+ state.kind === "syncing" ? /* @__PURE__ */ jsx("p", {
3074
+ className: "rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground",
3075
+ children: "Syncing the workflow to the runtime…"
3076
+ }) : null,
3077
+ state.kind === "empty" ? /* @__PURE__ */ jsx("p", {
3078
+ className: "rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground",
3079
+ children: "Enable the workflow to create its endpoint."
3080
+ }) : null,
3081
+ state.kind === "error" ? /* @__PURE__ */ jsx("p", {
3082
+ className: "text-xs text-wf-fail",
3083
+ children: state.message
3084
+ }) : null,
3085
+ state.kind === "ready" ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
3086
+ /* @__PURE__ */ jsxs("div", {
3087
+ className: "flex items-center gap-1.5",
3088
+ children: [/* @__PURE__ */ jsx("input", {
3089
+ readOnly: true,
3090
+ "aria-label": "Endpoint URL",
3091
+ className: `${textInputClass} bg-muted/50 font-mono text-xs`,
3092
+ value: state.endpoint.url,
3093
+ onFocus: (event) => event.currentTarget.select()
3094
+ }), /* @__PURE__ */ jsxs(Button, {
3095
+ onClick: () => {
3096
+ navigator.clipboard.writeText(state.endpoint.url).then(() => setCopied(true), () => void 0);
3097
+ },
3098
+ children: [/* @__PURE__ */ jsx(Icon, {
3099
+ name: copied ? "check" : "copy",
3100
+ className: "h-3.5 w-3.5"
3101
+ }), copied ? "Copied" : "Copy"]
3102
+ })]
3103
+ }),
3104
+ !state.endpoint.armed ? /* @__PURE__ */ jsx("p", {
3105
+ className: "mt-2 rounded-md bg-wf-warn/10 px-3 py-2 text-xs text-wf-warn",
3106
+ children: "Not accepting deliveries: the workflow is disabled or its webhook config is invalid."
3107
+ }) : null,
3108
+ !state.endpoint.absoluteUrl ? /* @__PURE__ */ jsx("p", {
3109
+ className: "mt-2 rounded-md bg-wf-warn/10 px-3 py-2 text-xs text-wf-warn",
3110
+ children: "This reactor doesn't know its public address, so the URL is missing its host. Prefix it with the host the provider can reach."
3111
+ }) : null,
3112
+ /* @__PURE__ */ jsx(Hint, { children: "Treat this URL as a secret: anyone who has it can call the endpoint." })
3113
+ ] }) : null
3114
+ ] });
3115
+ }
3116
+ function TriggerPanel(props) {
3117
+ const { trigger, callbacks } = props;
3118
+ const designTime = useDesignTime();
3119
+ const testTrigger = useTestTrigger();
3120
+ const block = triggerBlock(trigger);
3121
+ const meta = useBlockMeta(block);
3122
+ const isPieceTrigger = !isCoreBlock(block);
3123
+ const { form, formError, missing } = useBlockCheck({
3124
+ ...trigger,
3125
+ block
3126
+ });
3127
+ const writes = !props.readOnly;
3128
+ const isWebhookTrigger = form !== "loading" && form?.triggerDelivery === "webhook" && !sameBlock(block, CALLABLE_FLOW_TRIGGER$1);
3129
+ const endpoint = useWebhookEndpoint(isWebhookTrigger);
3130
+ const setTriggerConfig = (config, settings) => callbacks.setTriggerConfig(config, writes ? { propertySettings: settings } : void 0);
3131
+ return /* @__PURE__ */ jsxs("div", {
3132
+ className: "flex min-h-full flex-col",
3133
+ children: [/* @__PURE__ */ jsx(PanelHeader, {
3134
+ block,
3135
+ name: form && form !== "loading" && form.title && !namedByCoreTab(block) ? form.title : meta.displayName,
3136
+ actionLabel: namedByCoreTab(block) ? meta.subtitle : describeTrigger(trigger),
3137
+ missing,
3138
+ loading: form === "loading",
3139
+ onClose: props.onClose
3140
+ }), /* @__PURE__ */ jsxs("div", {
3141
+ className: "flex flex-1 flex-col gap-6 px-4 py-5",
3142
+ children: [
3143
+ isWebhookTrigger && designTime?.webhookEndpoint ? /* @__PURE__ */ jsx(WebhookUrlSection, { state: endpoint }) : null,
3144
+ isPieceTrigger ? /* @__PURE__ */ jsx(ConnectionField, {
3145
+ block,
3146
+ value: trigger.connectionId ?? "",
3147
+ onChange: (connectionId) => callbacks.setTriggerConnection({ connectionId })
3148
+ }, `${trigger.id}-conn`) : null,
3149
+ isPieceTrigger ? /* @__PURE__ */ jsx(ReactorConnectionField, {
3150
+ block,
3151
+ value: trigger.reactorConnectionId ?? "",
3152
+ workflowId: designTime?.workflowId,
3153
+ publishedVersion: props.publishedVersion,
3154
+ onChange: (reactorConnectionId) => callbacks.setTriggerConnection({ reactorConnectionId })
3155
+ }, `${trigger.id}-reactor`) : null,
3156
+ form !== "loading" && form?.display === "schedule" ? /* @__PURE__ */ jsx(ScheduleBuilder, {
3157
+ config: trigger.config,
3158
+ onChange: (config) => setTriggerConfig(config)
3159
+ }, trigger.id) : /* @__PURE__ */ jsx(ConfigSection, {
3160
+ block,
3161
+ form,
3162
+ formError,
3163
+ config: trigger.config,
3164
+ settings: trigger.propertySettings,
3165
+ onChange: (config, settings) => setTriggerConfig(config, settings),
3166
+ writesSettings: writes,
3167
+ connectionId: trigger.connectionId ?? void 0,
3168
+ reactorConnectionId: trigger.reactorConnectionId ?? void 0,
3169
+ webhookUrl: endpoint.kind === "ready" ? endpoint.endpoint.url : void 0
3170
+ }, trigger.id),
3171
+ /* @__PURE__ */ jsx(LastRunSection, {}),
3172
+ /* @__PURE__ */ jsx(PieceVersionSection, {
3173
+ id: trigger.id,
3174
+ block,
3175
+ kind: "trigger",
3176
+ onUpdate: writes ? (pieceVersion) => callbacks.setTriggerPieceVersion(pieceVersion) : void 0
3177
+ }),
3178
+ isPieceTrigger && testTrigger ? /* @__PURE__ */ jsx(Section, {
3179
+ title: "Try it",
3180
+ children: /* @__PURE__ */ jsx(TestTriggerSection, {
3181
+ trigger,
3182
+ onTest: testTrigger
3183
+ })
3184
+ }) : null,
3185
+ /* @__PURE__ */ jsx(Section, {
3186
+ title: "Remove",
3187
+ children: /* @__PURE__ */ jsxs("div", {
3188
+ className: "flex items-center justify-between gap-3",
3189
+ children: [/* @__PURE__ */ jsx("p", {
3190
+ className: "text-xs text-muted-foreground",
3191
+ children: "Without a trigger the workflow never starts."
3192
+ }), /* @__PURE__ */ jsxs(Button, {
3193
+ variant: "danger",
3194
+ onClick: () => {
3195
+ callbacks.clearTrigger();
3196
+ props.onClose();
3197
+ },
3198
+ children: [/* @__PURE__ */ jsx(Icon, {
3199
+ name: "trash",
3200
+ className: "h-3.5 w-3.5"
3201
+ }), "Remove trigger"]
3202
+ })]
3203
+ })
3204
+ })
3205
+ ]
3206
+ })]
3207
+ });
3208
+ }
3209
+ //#endregion
3210
+ //#region editors/workflow-editor/ui/VariablesEditor.tsx
3211
+ const KEY_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
3212
+ const TYPE_OPTIONS = VARIABLE_TYPES.map((type) => ({
3213
+ value: type,
3214
+ label: VARIABLE_TYPE_LABEL[type]
3215
+ }));
3216
+ const typeOf = (variable) => variable.type ?? "TEXT";
3217
+ function stringifyValue(value, pretty = false) {
3218
+ if (value === void 0 || value === null) return "";
3219
+ if (typeof value === "string") return value;
3220
+ try {
3221
+ return JSON.stringify(value, null, pretty ? 2 : void 0);
3222
+ } catch {
3223
+ return String(value);
3224
+ }
3225
+ }
3226
+ function SecretValue(props) {
3227
+ const id = useId();
3228
+ const secret = useSecretRef({
3229
+ value: props.variable.value,
3230
+ secrets: props.secrets,
3231
+ label: `Variable ${props.variable.key}`,
3232
+ onCommit: props.onCommit
3233
+ });
3234
+ if (!props.secrets) return /* @__PURE__ */ jsx("p", {
3235
+ className: "text-xs text-muted-foreground",
3236
+ children: "Managed secrets are unavailable in this session."
3237
+ });
3238
+ return /* @__PURE__ */ jsxs("div", { children: [
3239
+ secret.managed ? /* @__PURE__ */ jsxs("p", {
3240
+ className: "mb-1.5 flex items-center gap-1.5 text-xs text-muted-foreground",
3241
+ children: [/* @__PURE__ */ jsx("span", {
3242
+ className: "font-medium text-foreground",
3243
+ children: secret.stat?.label ?? "Stored secret"
3244
+ }), secret.stat ? /* @__PURE__ */ jsxs("span", { children: ["version ", secret.stat.version] }) : null]
3245
+ }) : null,
3246
+ /* @__PURE__ */ jsxs("div", {
3247
+ className: "flex items-center gap-1",
3248
+ children: [/* @__PURE__ */ jsx("input", {
3249
+ id,
3250
+ "aria-label": `Value of ${props.variable.key}`,
3251
+ className: textInputClass,
3252
+ type: "password",
3253
+ value: secret.draft,
3254
+ disabled: secret.busy,
3255
+ placeholder: secret.managed ? "Paste a new value to replace it" : "Paste the secret value",
3256
+ autoComplete: "off",
3257
+ spellCheck: false,
3258
+ onChange: (event) => secret.setDraft(event.target.value),
3259
+ onKeyDown: (event) => {
3260
+ if (event.key === "Enter") secret.commit();
3261
+ },
3262
+ onBlur: secret.commit
3263
+ }), secret.ref ? /* @__PURE__ */ jsx(IconButton, {
3264
+ icon: "close",
3265
+ label: "Remove secret",
3266
+ onClick: () => props.onCommit(null)
3267
+ }) : null]
3268
+ }),
3269
+ /* @__PURE__ */ jsx(FieldError, { children: secret.error })
3270
+ ] });
3271
+ }
3272
+ function ValueControl(props) {
3273
+ const { variable } = props;
3274
+ const type = typeOf(variable);
3275
+ const designTime = useDesignTime();
3276
+ const [error, setError] = useState(null);
3277
+ const label = `Value of ${variable.key}`;
3278
+ const mismatch = valueMismatch(type, variable.value);
3279
+ if (type === "SECRET") return /* @__PURE__ */ jsx(SecretValue, {
3280
+ variable,
3281
+ secrets: designTime?.secrets,
3282
+ onCommit: props.commit
3283
+ });
3284
+ if (type === "BOOLEAN" && !mismatch) return /* @__PURE__ */ jsx(Switch, {
3285
+ checked: variable.value === true,
3286
+ onChange: (checked) => props.commit(checked),
3287
+ label: variable.value === true ? "True" : "False"
3288
+ });
3289
+ const json = type === "JSON";
3290
+ const commitText = (raw) => {
3291
+ const parsed = parseTypedValue(type, raw);
3292
+ if (!parsed.ok) return setError(parsed.error);
3293
+ setError(null);
3294
+ if (stringifyValue(parsed.value) !== stringifyValue(variable.value)) props.commit(parsed.value);
3295
+ };
3296
+ const shown = error ?? mismatch;
3297
+ const common = {
3298
+ "aria-label": label,
3299
+ "aria-invalid": shown ? true : void 0,
3300
+ defaultValue: stringifyValue(variable.value, json),
3301
+ placeholder: type === "NUMBER" ? "0" : "value",
3302
+ spellCheck: false
3303
+ };
3304
+ return /* @__PURE__ */ jsxs("div", { children: [json ? /* @__PURE__ */ jsx("textarea", {
3305
+ ...common,
3306
+ className: `${textAreaClass} font-mono text-xs`,
3307
+ onBlur: (event) => commitText(event.target.value)
3308
+ }, `${variable.id}-${stringifyValue(variable.value)}`) : /* @__PURE__ */ jsx("input", {
3309
+ ...common,
3310
+ inputMode: type === "NUMBER" ? "decimal" : void 0,
3311
+ className: `${textInputClass} font-mono text-xs`,
3312
+ onBlur: (event) => commitText(event.target.value),
3313
+ onKeyDown: (event) => {
3314
+ if (event.key === "Enter") event.currentTarget.blur();
3315
+ }
3316
+ }, `${variable.id}-${stringifyValue(variable.value)}`), /* @__PURE__ */ jsx(FieldError, { children: shown })] });
3317
+ }
3318
+ function VariableRow(props) {
3319
+ const { variable, callbacks } = props;
3320
+ const type = typeOf(variable);
3321
+ const set = (value, nextType = type) => callbacks.setVariable({
3322
+ id: variable.id,
3323
+ key: variable.key,
3324
+ value,
3325
+ type: nextType
3326
+ });
3327
+ return /* @__PURE__ */ jsxs("div", {
3328
+ className: "flex flex-col gap-2 rounded-lg border border-solid border-foreground/10 bg-card p-3",
3329
+ children: [/* @__PURE__ */ jsxs("div", {
3330
+ className: "flex items-center gap-2",
3331
+ children: [
3332
+ /* @__PURE__ */ jsx("code", {
3333
+ className: "min-w-0 flex-1 truncate font-mono text-xs font-medium text-foreground",
3334
+ title: "Keys are fixed once created; remove and re-add to rename",
3335
+ children: variable.key
3336
+ }),
3337
+ /* @__PURE__ */ jsx("div", {
3338
+ className: "w-44",
3339
+ children: /* @__PURE__ */ jsx(Select, {
3340
+ ariaLabel: `Type of ${variable.key}`,
3341
+ value: type,
3342
+ options: TYPE_OPTIONS,
3343
+ onChange: (next) => {
3344
+ const nextType = next;
3345
+ set(convertVariableValue(variable.value, type, nextType), nextType);
3346
+ }
3347
+ })
3348
+ }),
3349
+ /* @__PURE__ */ jsx(IconButton, {
3350
+ icon: "trash",
3351
+ label: `Remove ${variable.key}`,
3352
+ onClick: () => callbacks.removeVariable(variable.id)
3353
+ })
3354
+ ]
3355
+ }), /* @__PURE__ */ jsx(ValueControl, {
3356
+ variable,
3357
+ commit: (value) => set(value)
3358
+ }, type)]
3359
+ });
3360
+ }
3361
+ function VariablesEditor(props) {
3362
+ const [key, setKey] = useState("");
3363
+ const [type, setType] = useState("TEXT");
3364
+ const [value, setValue] = useState("");
3365
+ const trimmedKey = key.trim();
3366
+ const keyError = trimmedKey === "" ? null : !KEY_PATTERN.test(trimmedKey) ? "Letters, digits and _ only; must not start with a digit" : props.variables.some((variable) => variable.key === trimmedKey) ? "A variable with this name already exists" : null;
3367
+ const parsed = type === "SECRET" ? {
3368
+ ok: true,
3369
+ value: null
3370
+ } : parseTypedValue(type, value);
3371
+ const valueError = parsed.ok || value.trim() === "" ? null : parsed.error;
3372
+ const canAdd = trimmedKey !== "" && keyError === null && parsed.ok;
3373
+ const add = () => {
3374
+ if (!canAdd) return;
3375
+ props.callbacks.setVariable({
3376
+ key: trimmedKey,
3377
+ value: parsed.value,
3378
+ type
3379
+ });
3380
+ setKey("");
3381
+ setValue("");
3382
+ };
3383
+ return /* @__PURE__ */ jsxs("div", {
3384
+ className: "flex flex-col gap-3 p-4",
3385
+ children: [
3386
+ /* @__PURE__ */ jsxs("div", {
3387
+ className: "flex items-center justify-between",
3388
+ children: [/* @__PURE__ */ jsx("h3", {
3389
+ className: "text-sm font-semibold text-foreground",
3390
+ children: "Variables"
3391
+ }), /* @__PURE__ */ jsx(IconButton, {
3392
+ icon: "close",
3393
+ label: "Close",
3394
+ onClick: props.onClose
3395
+ })]
3396
+ }),
3397
+ /* @__PURE__ */ jsxs("p", {
3398
+ className: "text-xs text-muted-foreground",
3399
+ children: [
3400
+ "Reference a variable in any step field as",
3401
+ " ",
3402
+ /* @__PURE__ */ jsx("code", {
3403
+ className: "font-mono",
3404
+ children: "{{variables.name}}"
3405
+ }),
3406
+ ". Secrets are stored in the secret store; the workflow keeps only a reference."
3407
+ ]
3408
+ }),
3409
+ props.variables.length === 0 ? /* @__PURE__ */ jsx("p", {
3410
+ className: "text-xs text-muted-foreground",
3411
+ children: "No variables yet."
3412
+ }) : /* @__PURE__ */ jsx("div", {
3413
+ className: "flex flex-col gap-2",
3414
+ children: props.variables.map((variable) => /* @__PURE__ */ jsx(VariableRow, {
3415
+ variable,
3416
+ callbacks: props.callbacks
3417
+ }, variable.id))
3418
+ }),
3419
+ /* @__PURE__ */ jsxs("div", {
3420
+ className: "flex flex-col gap-2 rounded-lg border border-dashed border-foreground/15 p-3",
3421
+ children: [/* @__PURE__ */ jsxs("div", {
3422
+ className: "flex items-start gap-2",
3423
+ children: [/* @__PURE__ */ jsxs("div", {
3424
+ className: "min-w-0 flex-1",
3425
+ children: [/* @__PURE__ */ jsx("input", {
3426
+ "aria-label": "New variable name",
3427
+ className: `${textInputClass} font-mono text-xs`,
3428
+ placeholder: "new_variable",
3429
+ value: key,
3430
+ spellCheck: false,
3431
+ onChange: (event) => setKey(event.target.value),
3432
+ onKeyDown: (event) => {
3433
+ if (event.key === "Enter") add();
3434
+ }
3435
+ }), /* @__PURE__ */ jsx(FieldError, { children: keyError })]
3436
+ }), /* @__PURE__ */ jsx("div", {
3437
+ className: "w-36",
3438
+ children: /* @__PURE__ */ jsx(Select, {
3439
+ ariaLabel: "New variable type",
3440
+ value: type,
3441
+ options: TYPE_OPTIONS,
3442
+ onChange: (next) => setType(next)
3443
+ })
3444
+ })]
3445
+ }), /* @__PURE__ */ jsxs("div", {
3446
+ className: "flex items-start gap-2",
3447
+ children: [/* @__PURE__ */ jsxs("div", {
3448
+ className: "min-w-0 flex-1",
3449
+ children: [type === "SECRET" ? /* @__PURE__ */ jsx("p", {
3450
+ className: "py-2 text-xs text-muted-foreground",
3451
+ children: "Paste the secret once the variable is added."
3452
+ }) : /* @__PURE__ */ jsx("input", {
3453
+ "aria-label": "New variable value",
3454
+ className: `${textInputClass} font-mono text-xs`,
3455
+ placeholder: type === "BOOLEAN" ? "true or false" : "value",
3456
+ value,
3457
+ spellCheck: false,
3458
+ onChange: (event) => setValue(event.target.value),
3459
+ onKeyDown: (event) => {
3460
+ if (event.key === "Enter") add();
3461
+ }
3462
+ }), /* @__PURE__ */ jsx(FieldError, { children: valueError })]
3463
+ }), /* @__PURE__ */ jsx(Button, {
3464
+ variant: "primary",
3465
+ disabled: !canAdd,
3466
+ onClick: add,
3467
+ children: "Add"
3468
+ })]
3469
+ })]
3470
+ })
3471
+ ]
3472
+ });
3473
+ }
3474
+ //#endregion
3475
+ //#region editors/workflow-editor/ui/use-selected-block.ts
3476
+ const VARIABLES_PARAM = "variables";
3477
+ /** The open panel, kept in the `step` param. Each pick is a history entry, so
3478
+ * back closes it; a new pick starts on the step's first tab. */
3479
+ function useSelectedBlock() {
3480
+ const [param, setParam] = useSearchParam(STEP_PARAM, "");
3481
+ const selectedId = param === VARIABLES_PARAM ? VARIABLES_VIEW : param || null;
3482
+ const select = (id) => setParam(id === "__variables" ? VARIABLES_PARAM : id ?? "", { also: id === selectedId ? void 0 : { ["tab"]: void 0 } });
3483
+ return [selectedId, select];
3484
+ }
3485
+ //#endregion
3486
+ //#region editors/workflow-editor/ui/step-drag.ts
3487
+ function moveRejection(model, move) {
3488
+ if (move.stepId === move.toParentId) return "self";
3489
+ if (model.edges.some((edge) => edge.from === move.toParentId && edge.to === move.stepId && edge.port === move.port)) return "already-there";
3490
+ if (reachableFrom(move.stepId, model.edges).has(move.toParentId)) return "cycle";
3491
+ return null;
3492
+ }
3493
+ const MOVE_REJECTION_TEXT = {
3494
+ self: "A step can't follow itself",
3495
+ cycle: "That slot is inside this step's own path",
3496
+ "already-there": "Already connected there"
3497
+ };
3498
+ let dragging;
3499
+ const listeners = /* @__PURE__ */ new Set();
3500
+ function setDraggingStep(stepId) {
3501
+ if (dragging === stepId) return;
3502
+ dragging = stepId;
3503
+ for (const listener of listeners) listener();
3504
+ }
3505
+ function subscribe(listener) {
3506
+ listeners.add(listener);
3507
+ return () => listeners.delete(listener);
3508
+ }
3509
+ function snapshot() {
3510
+ return dragging;
3511
+ }
3512
+ function useDraggingStep() {
3513
+ return useSyncExternalStore(subscribe, snapshot, snapshot);
3514
+ }
3515
+ //#endregion
3516
+ //#region editors/workflow-editor/ui/ap-nodes.tsx
3517
+ const hiddenHandle = {
3518
+ opacity: 0,
3519
+ pointerEvents: "none"
3520
+ };
3521
+ const BADGE_CLASS = "inline-flex shrink-0 items-center rounded-full px-1.5 text-[10px] font-medium leading-4";
3522
+ function badgeTitle(badge) {
3523
+ switch (badge.kind) {
3524
+ case "invalid": return badge.issues.join("\n");
3525
+ case "incomplete": return `Needs a value: ${badge.missing.join(", ")}`;
3526
+ case "test": return badge.stale ? "Changed since its last test" : "Not tested yet";
3527
+ case "failed": return "The last test failed";
3528
+ case "passed": return "Tested";
3529
+ }
3530
+ }
3531
+ const TEST_SEVERITY = {
3532
+ passed: 0,
3533
+ test: 2,
3534
+ incomplete: 3,
3535
+ failed: 4,
3536
+ invalid: 6
3537
+ };
3538
+ const VERSION_SEVERITY = {
3539
+ neutral: 1,
3540
+ warn: 3,
3541
+ fail: 5
3542
+ };
3543
+ const VERSION_CLASS = {
3544
+ neutral: "bg-muted text-muted-foreground",
3545
+ warn: "bg-wf-warn/15 text-wf-warn",
3546
+ fail: "bg-wf-fail/10 text-wf-fail"
3547
+ };
3548
+ function Badge(props) {
3549
+ const { badge, version } = props;
3550
+ if (version && (!badge || VERSION_SEVERITY[version.tone] > TEST_SEVERITY[badge.kind])) return /* @__PURE__ */ jsx("span", {
3551
+ "data-testid": "version-badge",
3552
+ className: `${BADGE_CLASS} ${VERSION_CLASS[version.tone]}`,
3553
+ title: badge ? `${version.title}\n${badgeTitle(badge)}` : version.title,
3554
+ children: version.label
3555
+ });
3556
+ if (!badge) return null;
3557
+ const title = version ? `${badgeTitle(badge)}\n${version.title}` : badgeTitle(badge);
3558
+ switch (badge.kind) {
3559
+ case "invalid": return /* @__PURE__ */ jsx("span", {
3560
+ className: `${BADGE_CLASS} bg-wf-fail/10 text-wf-fail`,
3561
+ title,
3562
+ children: "Miswired"
3563
+ });
3564
+ case "incomplete": return /* @__PURE__ */ jsx("span", {
3565
+ className: `${BADGE_CLASS} bg-wf-warn/15 text-wf-warn`,
3566
+ title,
3567
+ children: "Incomplete"
3568
+ });
3569
+ case "test": return /* @__PURE__ */ jsx("span", {
3570
+ className: `${BADGE_CLASS} bg-muted text-muted-foreground`,
3571
+ title,
3572
+ children: "Test me"
3573
+ });
3574
+ case "failed": return /* @__PURE__ */ jsx("span", {
3575
+ className: `${BADGE_CLASS} bg-wf-fail/10 text-wf-fail`,
3576
+ title,
3577
+ children: "Failed"
3578
+ });
3579
+ case "passed": return /* @__PURE__ */ jsx("span", {
3580
+ className: "flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full bg-wf-ok/15 text-wf-ok",
3581
+ title,
3582
+ "aria-label": "Tested",
3583
+ children: /* @__PURE__ */ jsx("svg", {
3584
+ viewBox: "0 0 24 24",
3585
+ className: "h-2.5 w-2.5",
3586
+ children: /* @__PURE__ */ jsx("path", {
3587
+ d: "M5 12l5 5 9-10",
3588
+ stroke: "currentColor",
3589
+ strokeWidth: 3,
3590
+ fill: "none",
3591
+ strokeLinecap: "round"
3592
+ })
3593
+ })
3594
+ });
3595
+ }
3596
+ }
3597
+ function ApStepNode(props) {
3598
+ const data = props.data;
3599
+ const ref = data.kind === "trigger" ? triggerBlock(data.trigger) : stepBlock(data.step);
3600
+ const meta = useBlockMeta(ref);
3601
+ const title = data.kind === "trigger" ? meta.displayName : data.step.name || data.step.key;
3602
+ const block = data.kind === "trigger" ? data.trigger : data.step;
3603
+ const skipped = data.kind === "step" && data.step.skip === true;
3604
+ const check = useBlockCheck({
3605
+ ...block,
3606
+ block: ref,
3607
+ skip: skipped,
3608
+ outgoingPorts: data.outgoingPorts
3609
+ });
3610
+ const designTime = useDesignTime();
3611
+ const testable = data.kind === "trigger" ? isTestableTrigger(ref) && Boolean(designTime?.testTrigger) : Boolean(designTime?.testStep);
3612
+ const testRun = useRunById(testable ? block.lastTest?.runId : null);
3613
+ const tested = testable ? testState(block, testRun?.status) : null;
3614
+ const test = tested === "passed" && testRun === void 0 ? null : tested;
3615
+ const badge = skipped ? null : check.issues.length > 0 ? {
3616
+ kind: "invalid",
3617
+ issues: check.issues
3618
+ } : check.missing && check.missing.length > 0 ? {
3619
+ kind: "incomplete",
3620
+ missing: check.missing
3621
+ } : test === "never" || test === "stale" ? {
3622
+ kind: "test",
3623
+ stale: test === "stale"
3624
+ } : test === "failed" ? { kind: "failed" } : test === "passed" ? { kind: "passed" } : null;
3625
+ const resolution = useResolution(block.id, ref);
3626
+ const version = skipped ? null : versionBadge(resolution);
3627
+ const dragging = useDraggingStep();
3628
+ const isDragged = data.kind === "step" && dragging === data.step.id;
3629
+ return /* @__PURE__ */ jsxs("div", {
3630
+ style: {
3631
+ width: 232,
3632
+ height: 60
3633
+ },
3634
+ className: `border-box group relative overflow-visible rounded-md border border-solid bg-card shadow-sm transition-all ${props.selected ? "border-wf-run" : "border-foreground/10"} ${isDragged ? "opacity-40" : ""} ${skipped ? "border-dashed" : ""} ${data.kind === "step" ? "nodrag nopan cursor-grab active:cursor-grabbing" : ""}`,
3635
+ draggable: data.kind === "step",
3636
+ onDragStart: (event) => {
3637
+ if (data.kind !== "step") return;
3638
+ event.dataTransfer.effectAllowed = "move";
3639
+ event.dataTransfer.setData("text/plain", data.step.id);
3640
+ setDraggingStep(data.step.id);
3641
+ },
3642
+ onDragEnd: () => setDraggingStep(void 0),
3643
+ children: [
3644
+ /* @__PURE__ */ jsx(Handle, {
3645
+ type: "target",
3646
+ position: Position.Top,
3647
+ style: hiddenHandle
3648
+ }),
3649
+ /* @__PURE__ */ jsxs("div", {
3650
+ className: `flex h-full items-center gap-3 px-3 ${skipped ? "opacity-50 grayscale" : ""}`,
3651
+ children: [/* @__PURE__ */ jsx(BlockLogo, {
3652
+ block: ref,
3653
+ size: 36
3654
+ }), /* @__PURE__ */ jsxs("div", {
3655
+ className: "min-w-0 grow",
3656
+ children: [/* @__PURE__ */ jsxs("div", {
3657
+ className: "flex items-center gap-1.5",
3658
+ children: [
3659
+ /* @__PURE__ */ jsx("span", {
3660
+ className: "truncate text-sm font-medium text-foreground",
3661
+ children: title
3662
+ }),
3663
+ skipped ? /* @__PURE__ */ jsx("span", {
3664
+ className: "shrink-0 rounded bg-muted px-1 text-[10px] font-medium text-muted-foreground",
3665
+ children: "Skipped"
3666
+ }) : null,
3667
+ /* @__PURE__ */ jsx(Badge, {
3668
+ badge,
3669
+ version
3670
+ })
3671
+ ]
3672
+ }), /* @__PURE__ */ jsx("div", {
3673
+ className: "truncate text-xs text-muted-foreground/80",
3674
+ children: data.kind === "trigger" ? meta.subtitle : stepSubtitle(meta)
3675
+ })]
3676
+ })]
3677
+ }),
3678
+ /* @__PURE__ */ jsx(Handle, {
3679
+ type: "source",
3680
+ position: Position.Bottom,
3681
+ style: hiddenHandle
3682
+ })
3683
+ ]
3684
+ });
3685
+ }
3686
+ const PORT_LABEL_CLASSES = {
3687
+ true: "bg-wf-ok/10 text-wf-ok hover:bg-green-200",
3688
+ false: "bg-foreground/5 text-muted-foreground hover:bg-foreground/10",
3689
+ error: "bg-wf-fail/10 text-wf-fail hover:bg-red-200",
3690
+ each: "bg-violet-500/10 text-violet-500 hover:bg-violet-500/20",
3691
+ otherwise: "bg-foreground/5 text-muted-foreground hover:bg-foreground/10"
3692
+ };
3693
+ const BRANCH_CLASSES = "bg-wf-run/10 text-wf-run hover:bg-blue-200";
3694
+ function portClasses(port) {
3695
+ return PORT_LABEL_CLASSES[port] ?? (/^branch_\d+$/.test(port) ? BRANCH_CLASSES : void 0);
3696
+ }
3697
+ function AddButton(props) {
3698
+ const [open, setOpen] = useState(false);
3699
+ const anchor = useRef(null);
3700
+ const close = useCallback(() => setOpen(false), []);
3701
+ const size = props.size ?? 20;
3702
+ const label = props.label;
3703
+ return /* @__PURE__ */ jsxs("div", {
3704
+ className: "relative",
3705
+ style: {
3706
+ width: size,
3707
+ height: size
3708
+ },
3709
+ children: [/* @__PURE__ */ jsx("button", {
3710
+ ref: anchor,
3711
+ type: "button",
3712
+ "aria-label": props.title,
3713
+ "aria-expanded": open,
3714
+ style: label ? { height: size } : {
3715
+ width: size,
3716
+ height: size
3717
+ },
3718
+ className: `flex cursor-pointer items-center justify-center rounded-md border border-solid transition-all ${label ? "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 px-1.5 text-[10px] font-semibold" : ""} ${open ? "border-wf-run bg-wf-run text-card" : label ? `border-transparent ${portClasses(props.port ?? label) ?? "bg-muted text-muted-foreground hover:bg-foreground/10"}` : "border-foreground/15 bg-card text-foreground hover:border-foreground/25"}`,
3719
+ onClick: (event) => {
3720
+ event.stopPropagation();
3721
+ setOpen((value) => !value);
3722
+ },
3723
+ children: label ? label : /* @__PURE__ */ jsx("svg", {
3724
+ width: size * .55,
3725
+ height: size * .55,
3726
+ viewBox: "0 0 24 24",
3727
+ children: /* @__PURE__ */ jsx("path", {
3728
+ d: "M12 5v14M5 12h14",
3729
+ stroke: "currentColor",
3730
+ strokeWidth: 3,
3731
+ strokeLinecap: "round",
3732
+ fill: "none"
3733
+ })
3734
+ })
3735
+ }), open ? /* @__PURE__ */ jsx(PickerPopover, {
3736
+ anchor,
3737
+ onClose: close,
3738
+ children: (placement) => /* @__PURE__ */ jsx(BlockSelector, {
3739
+ anchor,
3740
+ width: placement.width,
3741
+ height: placement.height,
3742
+ title: props.title,
3743
+ presets: props.presets,
3744
+ showPieces: props.showPieces,
3745
+ pieceMode: props.pieceMode,
3746
+ attachSteps: props.attachSteps,
3747
+ onAttach: props.onAttach ? (stepId) => {
3748
+ setOpen(false);
3749
+ props.onAttach?.(stepId);
3750
+ } : void 0,
3751
+ onPick: (preset) => {
3752
+ setOpen(false);
3753
+ props.onPick(preset);
3754
+ },
3755
+ onClose: close
3756
+ })
3757
+ }) : null]
3758
+ });
3759
+ }
3760
+ const CanvasHandlersContext = createContext(void 0);
3761
+ const CanvasHandlersProvider = CanvasHandlersContext.Provider;
3762
+ function useCanvasHandlers() {
3763
+ return useContext(CanvasHandlersContext);
3764
+ }
3765
+ function ApAppendNode(props) {
3766
+ const data = props.data;
3767
+ const portName = data.portLabel ?? data.port;
3768
+ const handlers = useCanvasHandlers();
3769
+ const attachSteps = handlers?.attachableSteps(data.parentId);
3770
+ const dragging = useDraggingStep();
3771
+ const move = dragging ? {
3772
+ stepId: dragging,
3773
+ toParentId: data.parentId,
3774
+ port: data.port
3775
+ } : void 0;
3776
+ const rejection = move ? handlers?.moveRejection(move) : void 0;
3777
+ if (move) return /* @__PURE__ */ jsxs("div", {
3778
+ className: "relative",
3779
+ style: data.card ? {
3780
+ width: 232,
3781
+ height: 60
3782
+ } : {
3783
+ width: 20,
3784
+ height: 20
3785
+ },
3786
+ children: [/* @__PURE__ */ jsx(Handle, {
3787
+ type: "target",
3788
+ position: Position.Top,
3789
+ style: hiddenHandle
3790
+ }), /* @__PURE__ */ jsx("div", {
3791
+ style: {
3792
+ width: 232,
3793
+ height: 60
3794
+ },
3795
+ className: `nodrag nopan absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-md border-2 border-dashed text-xs font-medium transition-colors ${rejection ? "border-foreground/10 bg-muted/50 text-muted-foreground/80" : "border-wf-run bg-wf-run/10 text-wf-run"}`,
3796
+ title: rejection ? MOVE_REJECTION_TEXT[rejection] : void 0,
3797
+ onDragOver: (event) => {
3798
+ if (rejection) return;
3799
+ event.preventDefault();
3800
+ event.dataTransfer.dropEffect = "move";
3801
+ },
3802
+ onDrop: (event) => {
3803
+ event.preventDefault();
3804
+ if (rejection) return;
3805
+ handlers?.moveStep(move);
3806
+ setDraggingStep(void 0);
3807
+ },
3808
+ children: rejection ? MOVE_REJECTION_TEXT[rejection] : data.port === "next" ? "Move here" : `Move to ${data.port}`
3809
+ })]
3810
+ });
3811
+ if (data.card) return /* @__PURE__ */ jsxs("div", {
3812
+ style: {
3813
+ width: 232,
3814
+ height: 60
3815
+ },
3816
+ className: "relative flex items-center justify-center rounded-md border border-dashed border-foreground/15 bg-muted/40",
3817
+ children: [
3818
+ /* @__PURE__ */ jsx(Handle, {
3819
+ type: "target",
3820
+ position: Position.Top,
3821
+ style: hiddenHandle
3822
+ }),
3823
+ /* @__PURE__ */ jsx("span", {
3824
+ className: `absolute left-3 top-3 rounded px-1.5 text-[10px] font-semibold ${portClasses(data.port) ?? "bg-muted text-muted-foreground"}`,
3825
+ children: portName
3826
+ }),
3827
+ /* @__PURE__ */ jsx(AddButton, {
3828
+ title: `Add step (${portName})`,
3829
+ presets: STEP_PRESETS,
3830
+ showPieces: true,
3831
+ attachSteps,
3832
+ onAttach: (stepId) => handlers?.attachStep(data.parentId, data.port, stepId),
3833
+ onPick: (preset) => handlers?.appendStep(data.parentId, data.port, preset)
3834
+ })
3835
+ ]
3836
+ });
3837
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
3838
+ /* @__PURE__ */ jsx(Handle, {
3839
+ type: "target",
3840
+ position: Position.Top,
3841
+ style: hiddenHandle
3842
+ }),
3843
+ data.hint ? /* @__PURE__ */ jsx("span", {
3844
+ className: "pointer-events-none absolute left-1/2 top-full mt-2 -translate-x-1/2 whitespace-nowrap text-xs text-muted-foreground",
3845
+ children: "Add your first step with +"
3846
+ }) : null,
3847
+ /* @__PURE__ */ jsx(AddButton, {
3848
+ title: data.port === "next" && !data.portLabel ? "Add step" : `Add step (${portName})`,
3849
+ label: data.port === "next" && !data.portLabel ? void 0 : portName,
3850
+ port: data.port,
3851
+ presets: STEP_PRESETS,
3852
+ showPieces: true,
3853
+ attachSteps,
3854
+ onAttach: (stepId) => handlers?.attachStep(data.parentId, data.port, stepId),
3855
+ onPick: (preset) => handlers?.appendStep(data.parentId, data.port, preset)
3856
+ })
3857
+ ] });
3858
+ }
3859
+ function ApBigButtonNode(_props) {
3860
+ const handlers = useCanvasHandlers();
3861
+ return /* @__PURE__ */ jsxs("div", {
3862
+ className: "flex flex-col items-center gap-2",
3863
+ children: [/* @__PURE__ */ jsx(AddButton, {
3864
+ size: 50,
3865
+ title: "Choose a trigger",
3866
+ presets: TRIGGER_PRESETS,
3867
+ showPieces: true,
3868
+ pieceMode: "triggers",
3869
+ onPick: (preset) => handlers?.pickTrigger(preset)
3870
+ }), /* @__PURE__ */ jsx("span", {
3871
+ className: "text-xs text-muted-foreground/80",
3872
+ children: "Select a trigger"
3873
+ })]
3874
+ });
3875
+ }
3876
+ function ApLoopFrameNode(props) {
3877
+ const data = props.data;
3878
+ return /* @__PURE__ */ jsx("div", {
3879
+ style: {
3880
+ width: data.width,
3881
+ height: data.height
3882
+ },
3883
+ className: "pointer-events-none rounded-lg border border-dashed border-violet-500/30 bg-violet-500/[0.03]"
3884
+ });
3885
+ }
3886
+ const apNodeTypes = {
3887
+ apStep: ApStepNode,
3888
+ apAppend: ApAppendNode,
3889
+ apBigButton: ApBigButtonNode,
3890
+ apLoopFrame: ApLoopFrameNode
3891
+ };
3892
+ //#endregion
3893
+ //#region editors/workflow-editor/ui/ap-edge.tsx
3894
+ const RADIUS = 15;
3895
+ function roundedPath(points) {
3896
+ const pts = points.filter((p, i) => i === 0 || p[0] !== points[i - 1][0] || p[1] !== points[i - 1][1]);
3897
+ let d = `M ${pts[0][0]} ${pts[0][1]}`;
3898
+ for (let i = 1; i < pts.length - 1; i++) {
3899
+ const [px, py] = pts[i - 1];
3900
+ const [cx, cy] = pts[i];
3901
+ const [nx, ny] = pts[i + 1];
3902
+ const inLen = Math.hypot(cx - px, cy - py);
3903
+ const outLen = Math.hypot(nx - cx, ny - cy);
3904
+ const r = Math.min(RADIUS, inLen / 2, outLen / 2);
3905
+ const ax = cx - (cx - px) / inLen * r;
3906
+ const ay = cy - (cy - py) / inLen * r;
3907
+ const bx = cx + (nx - cx) / outLen * r;
3908
+ const by = cy + (ny - cy) / outLen * r;
3909
+ d += ` L ${ax} ${ay} Q ${cx} ${cy} ${bx} ${by}`;
3910
+ }
3911
+ const [lx, ly] = pts[pts.length - 1];
3912
+ return `${d} L ${lx} ${ly}`;
3913
+ }
3914
+ function lanePath(sx, sy, lane, tx, ty) {
3915
+ const turn = sy + Math.min(30, (ty - sy) / 2);
3916
+ const entry = Math.max(ty - 15, turn);
3917
+ return [
3918
+ roundedPath([
3919
+ [sx, sy],
3920
+ [sx, turn],
3921
+ [lane, turn],
3922
+ [lane, entry],
3923
+ [tx, entry],
3924
+ [tx, ty]
3925
+ ]),
3926
+ (sx + lane) / 2,
3927
+ turn
3928
+ ];
3929
+ }
3930
+ function ApEdge(props) {
3931
+ const handlers = useCanvasHandlers();
3932
+ const data = props.data;
3933
+ const [path, labelX, labelY] = data.lane !== void 0 && props.targetY > props.sourceY ? lanePath(props.sourceX, props.sourceY, data.lane, props.targetX, props.targetY) : getSmoothStepPath({
3934
+ sourceX: props.sourceX,
3935
+ sourceY: props.sourceY,
3936
+ targetX: props.targetX,
3937
+ targetY: props.targetY,
3938
+ sourcePosition: Position.Bottom,
3939
+ targetPosition: Position.Top,
3940
+ borderRadius: RADIUS
3941
+ });
3942
+ const portLabel = data.dead ? `${data.portLabel ?? data.port} · never taken` : data.port !== "next" || data.portLabel ? data.portLabel ?? data.port : null;
3943
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(BaseEdge, {
3944
+ id: props.id,
3945
+ path,
3946
+ style: {
3947
+ stroke: data.dead ? "var(--wf-fail)" : "var(--wf-edge)",
3948
+ strokeWidth: 1.5,
3949
+ ...data.dead ? { strokeDasharray: "5 4" } : {},
3950
+ ...data.fromSkipped ? {
3951
+ opacity: .45,
3952
+ strokeDasharray: "2 3"
3953
+ } : {}
3954
+ }
3955
+ }), /* @__PURE__ */ jsx(EdgeLabelRenderer, { children: /* @__PURE__ */ jsxs("div", {
3956
+ className: "nodrag nopan pointer-events-auto absolute flex items-center gap-1",
3957
+ style: { transform: `translate(-50%, -50%) translate(${labelX}px, ${labelY}px)` },
3958
+ children: [portLabel ? /* @__PURE__ */ jsxs("span", {
3959
+ className: `rounded px-1.5 py-0.5 text-[10px] font-semibold ${data.dead ? "border border-solid border-wf-fail/40 bg-card text-wf-fail" : portClasses(data.port) ?? "bg-muted text-muted-foreground"}`,
3960
+ title: data.dead ? `The source never leaves on "${data.port}", so no run takes this edge` : void 0,
3961
+ children: [portLabel, data.condition ? " ?" : ""]
3962
+ }) : null, /* @__PURE__ */ jsx(AddButton, {
3963
+ title: "Insert step",
3964
+ presets: STEP_PRESETS,
3965
+ showPieces: true,
3966
+ onPick: (preset) => handlers?.insertOnEdge(data.edgeId, preset)
3967
+ })]
3968
+ }) })] });
3969
+ }
3970
+ function ApLinkEdge(props) {
3971
+ const [path] = getSmoothStepPath({
3972
+ sourceX: props.sourceX,
3973
+ sourceY: props.sourceY,
3974
+ targetX: props.targetX,
3975
+ targetY: props.targetY,
3976
+ sourcePosition: Position.Bottom,
3977
+ targetPosition: Position.Top,
3978
+ borderRadius: 15
3979
+ });
3980
+ return /* @__PURE__ */ jsx(BaseEdge, {
3981
+ id: props.id,
3982
+ path,
3983
+ style: {
3984
+ stroke: "var(--wf-edge)",
3985
+ strokeWidth: 1.5,
3986
+ strokeDasharray: "4 3"
3987
+ }
3988
+ });
3989
+ }
3990
+ const apEdgeTypes = {
3991
+ apEdge: ApEdge,
3992
+ apLink: ApLinkEdge
3993
+ };
3994
+ //#endregion
3995
+ //#region editors/workflow-editor/ui/CanvasContextMenu.tsx
3996
+ const PICKERS = {
3997
+ addBelow: "Add step",
3998
+ addStep: "Add step",
3999
+ insertStep: "Insert step",
4000
+ changeTrigger: "Choose a trigger"
4001
+ };
4002
+ function CanvasContextMenu(props) {
4003
+ const [picker, setPicker] = useState(null);
4004
+ const containerRef = useRef(null);
4005
+ useEffect(() => {
4006
+ const onMouseDown = (event) => {
4007
+ if (!containerRef.current?.contains(event.target)) props.onClose();
4008
+ };
4009
+ const onKeyDown = (event) => {
4010
+ if (event.key === "Escape") props.onClose();
4011
+ };
4012
+ window.addEventListener("mousedown", onMouseDown, true);
4013
+ window.addEventListener("keydown", onKeyDown);
4014
+ window.addEventListener("scroll", props.onClose, true);
4015
+ return () => {
4016
+ window.removeEventListener("mousedown", onMouseDown, true);
4017
+ window.removeEventListener("keydown", onKeyDown);
4018
+ window.removeEventListener("scroll", props.onClose, true);
4019
+ };
4020
+ }, [props]);
4021
+ const items = contextMenuItems(props.state.target, props.model, props.portsOf);
4022
+ const size = picker ? {
4023
+ width: Math.min(PICKER_SIZE.width, window.innerWidth - 16),
4024
+ height: Math.min(PICKER_SIZE.height, window.innerHeight - 16)
4025
+ } : {
4026
+ width: 176,
4027
+ height: menuHeight(items.length)
4028
+ };
4029
+ const position = menuPosition(props.state.point, size, {
4030
+ width: window.innerWidth,
4031
+ height: window.innerHeight
4032
+ });
4033
+ return /* @__PURE__ */ jsx("div", {
4034
+ ref: containerRef,
4035
+ className: "workflow-context-menu nodrag nopan fixed",
4036
+ style: {
4037
+ left: position.x,
4038
+ top: position.y
4039
+ },
4040
+ onContextMenu: (event) => event.preventDefault(),
4041
+ children: picker ? /* @__PURE__ */ jsx(BlockSelector, {
4042
+ title: PICKERS[picker] ?? "",
4043
+ presets: picker === "changeTrigger" ? TRIGGER_PRESETS : STEP_PRESETS,
4044
+ showPieces: true,
4045
+ width: size.width,
4046
+ height: size.height,
4047
+ pieceMode: picker === "changeTrigger" ? "triggers" : "actions",
4048
+ onPick: (preset) => props.onAction(picker, preset),
4049
+ onClose: props.onClose
4050
+ }) : /* @__PURE__ */ jsx("div", {
4051
+ style: { width: 176 },
4052
+ className: "rounded-md border border-solid border-foreground/10 bg-card py-1 shadow-lg",
4053
+ children: items.map((item) => /* @__PURE__ */ jsx("button", {
4054
+ type: "button",
4055
+ className: `flex w-full items-center px-3 py-1.5 text-left text-xs text-foreground ${item.disabled ? "cursor-not-allowed opacity-50" : "hover:bg-muted/50"}`,
4056
+ disabled: item.disabled,
4057
+ onClick: () => {
4058
+ if (PICKERS[item.id]) setPicker(item.id);
4059
+ else props.onAction(item.id);
4060
+ },
4061
+ children: item.label
4062
+ }, item.id))
4063
+ })
4064
+ });
4065
+ }
4066
+ //#endregion
4067
+ //#region editors/workflow-editor/ui/WorkflowCanvas.tsx
4068
+ function presetToInput(preset, model, config) {
4069
+ return {
4070
+ key: uniqueStepKey(model.steps.map((step) => step.key), preset.label),
4071
+ name: preset.label,
4072
+ ...stepFields(preset.block),
4073
+ config
4074
+ };
4075
+ }
4076
+ const MINIMAP_MIN_STEPS = 8;
4077
+ const MINIMAP_NODE_COLOR = (node) => node.type === "apStep" ? "var(--wf-edge)" : "transparent";
4078
+ function WorkflowCanvas({ model, callbacks, onSelect }) {
4079
+ const blocks = useMemo(() => [...model.trigger ? [triggerBlock(model.trigger)] : [], ...model.steps.map(stepBlock)], [model]);
4080
+ const portsOf = useBlockPorts(blocks);
4081
+ const loadForm = useBlockFormLoader();
4082
+ const cachedForm = useCachedBlockForm();
4083
+ const portsKey = blocks.map((block) => portsOf(block)?.join("|")).join(",");
4084
+ const { nodes, edges } = useMemo(() => layoutWorkflow(model, portsOf), [model, portsKey]);
4085
+ const add = useCallback((preset, commit) => {
4086
+ const cached = cachedForm(preset.block);
4087
+ const added = commit(cached ? withPropDefaults(cached.props, preset.defaultConfig) : preset.defaultConfig);
4088
+ if (!added) return;
4089
+ onSelect(added.id);
4090
+ if (cached) return;
4091
+ loadForm(preset.block).then((form) => {
4092
+ if (form) callbacks.completeBlock(added, form);
4093
+ });
4094
+ }, [
4095
+ cachedForm,
4096
+ loadForm,
4097
+ callbacks,
4098
+ onSelect
4099
+ ]);
4100
+ const insertOnEdge = useCallback((edgeId, preset) => {
4101
+ const ports = cachedForm(preset.block)?.ports ?? knownPorts(preset.block);
4102
+ const port = flowPorts(ports)[0];
4103
+ if (!port) {
4104
+ console.error(`${preset.block.pieceName} ${preset.block.name} declares no port to continue on`);
4105
+ return;
4106
+ }
4107
+ add(preset, (config) => callbacks.insertStepOnEdge(edgeId, presetToInput(preset, model, config), port));
4108
+ }, [
4109
+ add,
4110
+ cachedForm,
4111
+ callbacks,
4112
+ model
4113
+ ]);
4114
+ const [menu, setMenu] = useState(null);
4115
+ const [flow, setFlow] = useState(null);
4116
+ const appendStep = (fromId, port, preset) => add(preset, (config) => callbacks.appendStep(fromId, port, presetToInput(preset, model, config)));
4117
+ const pickTrigger = (preset) => add(preset, (config) => callbacks.setTrigger({
4118
+ ...triggerFields(preset.block),
4119
+ config
4120
+ }));
4121
+ const handlers = useMemo(() => ({
4122
+ appendStep: (fromId, port, preset) => add(preset, (config) => callbacks.appendStep(fromId, port, presetToInput(preset, model, config))),
4123
+ insertOnEdge,
4124
+ pickTrigger: (preset) => add(preset, (config) => callbacks.setTrigger({
4125
+ ...triggerFields(preset.block),
4126
+ config
4127
+ })),
4128
+ attachableSteps: (fromId) => attachableSteps(model, fromId),
4129
+ moveStep: (move) => callbacks.moveStep(move),
4130
+ moveRejection: (move) => moveRejection(model, move),
4131
+ attachStep: (fromId, port, stepId) => callbacks.addEdge({
4132
+ from: fromId,
4133
+ to: stepId,
4134
+ port
4135
+ })
4136
+ }), [
4137
+ callbacks,
4138
+ model,
4139
+ add,
4140
+ insertOnEdge
4141
+ ]);
4142
+ const onDelete = ({ nodes: deletedNodes, edges: deletedEdges }) => {
4143
+ const stepIds = new Set(model.steps.map((step) => step.id));
4144
+ const removedSteps = new Set(deletedNodes.filter((node) => node.type === "apStep" && stepIds.has(node.id)).map((node) => node.id));
4145
+ for (const id of removedSteps) callbacks.removeStep(id);
4146
+ for (const edge of deletedEdges) {
4147
+ if (edge.type !== "apEdge") continue;
4148
+ if (removedSteps.has(edge.source) || removedSteps.has(edge.target)) continue;
4149
+ if (model.edges.some((entry) => entry.id === edge.id)) callbacks.removeEdge(edge.id);
4150
+ }
4151
+ if (removedSteps.size > 0) onSelect(null);
4152
+ };
4153
+ const openMenu = (event, target) => {
4154
+ event.preventDefault();
4155
+ setMenu({
4156
+ target,
4157
+ point: {
4158
+ x: event.clientX,
4159
+ y: event.clientY
4160
+ }
4161
+ });
4162
+ };
4163
+ const onMenuAction = (action, preset) => {
4164
+ if (!menu) return;
4165
+ const target = menu.target;
4166
+ const point = menu.point;
4167
+ setMenu(null);
4168
+ switch (action) {
4169
+ case "open":
4170
+ onSelect(target.kind === "step" ? target.id : model.trigger?.id ?? null);
4171
+ break;
4172
+ case "addBelow": {
4173
+ const fromId = target.kind === "step" ? target.id : model.trigger?.id;
4174
+ if (preset && fromId) appendStep(fromId, "next", preset);
4175
+ break;
4176
+ }
4177
+ case "duplicate":
4178
+ if (target.kind === "step") callbacks.duplicateStep(target.id);
4179
+ break;
4180
+ case "toggleSkip":
4181
+ if (target.kind === "step") {
4182
+ const step = model.steps.find((entry) => entry.id === target.id);
4183
+ if (step) callbacks.updateStep({
4184
+ id: step.id,
4185
+ skip: !step.skip
4186
+ });
4187
+ }
4188
+ break;
4189
+ case "removeStep":
4190
+ if (target.kind === "step") {
4191
+ callbacks.removeStep(target.id);
4192
+ onSelect(null);
4193
+ }
4194
+ break;
4195
+ case "changeTrigger":
4196
+ if (preset) pickTrigger(preset);
4197
+ break;
4198
+ case "removeTrigger":
4199
+ callbacks.clearTrigger();
4200
+ onSelect(null);
4201
+ break;
4202
+ case "insertStep":
4203
+ if (preset && target.kind === "edge") insertOnEdge(target.id, preset);
4204
+ break;
4205
+ case "removeEdge":
4206
+ if (target.kind === "edge") callbacks.removeEdge(target.id);
4207
+ break;
4208
+ case "addStep":
4209
+ if (preset) {
4210
+ const position = flow?.screenToFlowPosition(point);
4211
+ add(preset, (config) => callbacks.addStep({
4212
+ ...presetToInput(preset, model, config),
4213
+ position
4214
+ }));
4215
+ }
4216
+ break;
4217
+ case "selectAll":
4218
+ flow?.setNodes((current) => current.map((node) => node.type === "apStep" ? {
4219
+ ...node,
4220
+ selected: true
4221
+ } : node));
4222
+ break;
4223
+ case "fitView": flow?.fitView({
4224
+ padding: .25,
4225
+ maxZoom: 1
4226
+ });
4227
+ }
4228
+ };
4229
+ return /* @__PURE__ */ jsx(CanvasHandlersProvider, {
4230
+ value: handlers,
4231
+ children: /* @__PURE__ */ jsxs("div", {
4232
+ className: "relative h-full w-full",
4233
+ onContextMenu: (event) => event.preventDefault(),
4234
+ children: [/* @__PURE__ */ jsxs(ReactFlow, {
4235
+ nodes,
4236
+ edges,
4237
+ nodeTypes: apNodeTypes,
4238
+ edgeTypes: apEdgeTypes,
4239
+ onInit: setFlow,
4240
+ onNodeClick: (_event, node) => {
4241
+ setMenu(null);
4242
+ if (node.type === "apStep") onSelect(node.id);
4243
+ },
4244
+ onPaneClick: () => {
4245
+ setMenu(null);
4246
+ onSelect(null);
4247
+ },
4248
+ onNodeContextMenu: (event, node) => openMenu(event, node.type !== "apStep" ? { kind: "pane" } : node.id === model.trigger?.id ? { kind: "trigger" } : {
4249
+ kind: "step",
4250
+ id: node.id
4251
+ }),
4252
+ onEdgeContextMenu: (event, edge) => openMenu(event, edge.type === "apEdge" ? {
4253
+ kind: "edge",
4254
+ id: edge.id
4255
+ } : { kind: "pane" }),
4256
+ onPaneContextMenu: (event) => openMenu(event, { kind: "pane" }),
4257
+ onMove: () => setMenu(null),
4258
+ onDelete,
4259
+ nodesDraggable: false,
4260
+ nodesConnectable: false,
4261
+ deleteKeyCode: ["Backspace", "Delete"],
4262
+ zoomOnDoubleClick: false,
4263
+ fitView: true,
4264
+ fitViewOptions: {
4265
+ padding: .25,
4266
+ maxZoom: 1
4267
+ },
4268
+ proOptions: { hideAttribution: true },
4269
+ children: [
4270
+ /* @__PURE__ */ jsx(Background, { gap: 16 }),
4271
+ /* @__PURE__ */ jsx(Controls, { showInteractive: false }),
4272
+ model.steps.length > MINIMAP_MIN_STEPS ? /* @__PURE__ */ jsx(MiniMap, {
4273
+ pannable: true,
4274
+ zoomable: true,
4275
+ nodeColor: MINIMAP_NODE_COLOR,
4276
+ nodeStrokeWidth: 0,
4277
+ style: {
4278
+ width: 140,
4279
+ height: 90
4280
+ }
4281
+ }) : null
4282
+ ]
4283
+ }), menu ? /* @__PURE__ */ jsx(CanvasContextMenu, {
4284
+ portsOf,
4285
+ state: menu,
4286
+ model,
4287
+ onAction: onMenuAction,
4288
+ onClose: () => setMenu(null)
4289
+ }) : null]
4290
+ })
4291
+ });
4292
+ }
4293
+ //#endregion
4294
+ //#region editors/workflow-editor/ui/WorkflowEditorApp.tsx
4295
+ function WorkflowEditorApp(props) {
4296
+ const { model, callbacks } = props;
4297
+ const [selectedId, setSelectedId] = useSelectedBlock();
4298
+ const panel = usePanelWidth();
4299
+ const { publishing, error: publishError, publish } = usePublish(callbacks);
4300
+ const { readiness } = useWorkflowCheck(model);
4301
+ const selectedStep = model.steps.find((step) => step.id === selectedId);
4302
+ const selectedTrigger = model.trigger && model.trigger.id === selectedId ? model.trigger : null;
4303
+ const showVariables = selectedId === VARIABLES_VIEW;
4304
+ const workflowId = useDesignTime()?.workflowId ?? "";
4305
+ const signIn = useSignInGate();
4306
+ const denial = useReactorAccessDenial(workflowId || void 0, `${model.published?.version ?? 0}:${model.status}`);
4307
+ const trigger = useMemo(() => model.trigger ? triggerBlock(model.trigger) : void 0, [model.trigger]);
4308
+ const blocks = useMemo(() => [...model.trigger && trigger ? [{
4309
+ id: model.trigger.id,
4310
+ block: trigger
4311
+ }] : [], ...model.steps.map((step) => ({
4312
+ id: step.id,
4313
+ block: stepBlock(step)
4314
+ }))], [
4315
+ model.trigger,
4316
+ trigger,
4317
+ model.steps
4318
+ ]);
4319
+ const resolutions = useBlockResolutions(workflowId, blocks);
4320
+ const publishedBlocks = useMemo(() => model.published?.blocks ?? [], [model.published]);
4321
+ const publishedForms = useBlockForms(publishedBlocks);
4322
+ const publishedMissing = missingInPublished(publishedBlocks.map((block) => {
4323
+ const form = publishedForms.get(blockRefKey(block));
4324
+ return {
4325
+ label: block.label,
4326
+ reactorConnectionId: block.reactorConnectionId,
4327
+ requireReactor: form && form !== "loading" ? form.requireReactor : null
4328
+ };
4329
+ }));
4330
+ const draftBlocks = useMemo(() => blocks.map((entry) => entry.block), [blocks]);
4331
+ const stepBlocks = useMemo(() => Object.fromEntries(model.steps.map((step) => [step.key, stepBlock(step)])), [model.steps]);
4332
+ return /* @__PURE__ */ jsx(BlockResolutionsProvider, {
4333
+ resolutions,
4334
+ blocks: draftBlocks,
4335
+ children: /* @__PURE__ */ jsxs("div", {
4336
+ className: "flex min-h-0 flex-1 flex-col",
4337
+ children: [/* @__PURE__ */ jsxs("div", {
4338
+ className: "flex flex-wrap items-center gap-x-3 gap-y-1.5 border-b border-solid border-foreground/10 bg-background px-4 py-2",
4339
+ children: [
4340
+ props.leading ? /* @__PURE__ */ jsxs(Fragment$1, { children: [props.leading, /* @__PURE__ */ jsx("span", {
4341
+ "aria-hidden": true,
4342
+ className: "h-5 w-px bg-foreground/10"
4343
+ })] }) : null,
4344
+ /* @__PURE__ */ jsx("input", {
4345
+ "aria-label": "Workflow name",
4346
+ className: "min-w-16 max-w-72 shrink rounded-md border border-solid border-transparent bg-transparent px-1.5 py-1 text-[15px] font-semibold [field-sizing:content] text-foreground hover:border-foreground/15 focus:border-ring focus:outline-none focus:ring-2 focus:ring-ring/25",
4347
+ defaultValue: model.name,
4348
+ placeholder: "Untitled workflow",
4349
+ spellCheck: false,
4350
+ onKeyDown: (event) => {
4351
+ if (event.key === "Enter") event.currentTarget.blur();
4352
+ },
4353
+ onBlur: (event) => {
4354
+ const name = event.target.value.trim();
4355
+ if (name && name !== model.name) callbacks.setName(name);
4356
+ }
4357
+ }, model.name),
4358
+ /* @__PURE__ */ jsxs("span", {
4359
+ className: "text-xs tabular-nums text-muted-foreground",
4360
+ children: ["v", model.version]
4361
+ }),
4362
+ /* @__PURE__ */ jsx("input", {
4363
+ "aria-label": "Workflow description",
4364
+ className: "min-w-32 max-w-md flex-1 rounded-md border border-solid border-transparent bg-transparent px-1.5 py-1 text-[13px] text-muted-foreground placeholder:text-muted-foreground/60 hover:border-foreground/15 focus:border-ring focus:text-foreground focus:outline-none focus:ring-2 focus:ring-ring/25",
4365
+ defaultValue: model.description ?? "",
4366
+ placeholder: "Add a description",
4367
+ title: model.description ?? void 0,
4368
+ onKeyDown: (event) => {
4369
+ if (event.key === "Enter") event.currentTarget.blur();
4370
+ },
4371
+ onBlur: (event) => {
4372
+ const description = event.target.value.trim();
4373
+ if (description !== (model.description ?? "")) callbacks.setDescription(description);
4374
+ }
4375
+ }, model.description ?? ""),
4376
+ /* @__PURE__ */ jsx(PublishState, { model }),
4377
+ /* @__PURE__ */ jsx(PublishedMissingNote, { missing: publishedMissing }),
4378
+ /* @__PURE__ */ jsx(ReactorDenialNote, { denial }),
4379
+ /* @__PURE__ */ jsx(VersionSummary, {
4380
+ resolutions,
4381
+ onSelect: setSelectedId
4382
+ }),
4383
+ /* @__PURE__ */ jsx("span", {
4384
+ className: "ml-auto flex items-center gap-3",
4385
+ children: props.trailing
4386
+ }),
4387
+ /* @__PURE__ */ jsxs(Button, {
4388
+ size: "sm",
4389
+ variant: showVariables ? "primary" : "secondary",
4390
+ "aria-pressed": showVariables,
4391
+ onClick: () => setSelectedId(showVariables ? null : VARIABLES_VIEW),
4392
+ children: [
4393
+ /* @__PURE__ */ jsx(Icon, {
4394
+ name: "braces",
4395
+ className: "h-3.5 w-3.5"
4396
+ }),
4397
+ "Variables",
4398
+ model.variables.length > 0 ? /* @__PURE__ */ jsx("span", {
4399
+ className: "tabular-nums opacity-70",
4400
+ children: model.variables.length
4401
+ }) : null
4402
+ ]
4403
+ }),
4404
+ /* @__PURE__ */ jsx("span", {
4405
+ "aria-hidden": true,
4406
+ className: "h-5 w-px bg-foreground/10"
4407
+ }),
4408
+ /* @__PURE__ */ jsx(StatusToggle, {
4409
+ published: Boolean(model.published),
4410
+ status: model.status,
4411
+ onChange: callbacks.setStatus
4412
+ }),
4413
+ publishError && !hasDraftChanges(model) ? /* @__PURE__ */ jsx("span", {
4414
+ role: "alert",
4415
+ className: "max-w-64 truncate text-xs text-wf-fail",
4416
+ title: publishError,
4417
+ children: publishError
4418
+ }) : null,
4419
+ /* @__PURE__ */ jsx(PublishButton, {
4420
+ model,
4421
+ readiness,
4422
+ publishing,
4423
+ onPublish: publish,
4424
+ onSelect: setSelectedId,
4425
+ signIn
4426
+ })
4427
+ ]
4428
+ }), /* @__PURE__ */ jsxs("div", {
4429
+ className: "flex min-h-0 flex-1",
4430
+ children: [
4431
+ /* @__PURE__ */ jsxs("div", {
4432
+ className: "relative min-h-[480px] min-w-0 flex-1",
4433
+ children: [/* @__PURE__ */ jsx(WorkflowCanvas, {
4434
+ model,
4435
+ callbacks,
4436
+ onSelect: setSelectedId
4437
+ }), /* @__PURE__ */ jsx("div", {
4438
+ className: "pointer-events-none absolute inset-x-0 top-3 z-10 flex justify-center px-4",
4439
+ children: model.managedBy ? /* @__PURE__ */ jsx(ManagedBanner, { model }) : /* @__PURE__ */ jsx(DraftBanner, {
4440
+ model,
4441
+ readiness,
4442
+ publishing,
4443
+ error: publishError,
4444
+ onPublish: publish,
4445
+ onDiscard: callbacks.discardChanges,
4446
+ onSelect: setSelectedId,
4447
+ signIn
4448
+ })
4449
+ })]
4450
+ }),
4451
+ showVariables ? /* @__PURE__ */ jsxs("aside", {
4452
+ className: "relative flex min-h-0 shrink-0 flex-col border-l border-solid border-foreground/10 bg-card",
4453
+ style: { width: panel.width },
4454
+ children: [/* @__PURE__ */ jsx(PanelResizer, {
4455
+ width: panel.width,
4456
+ onResize: panel.resize
4457
+ }), /* @__PURE__ */ jsx("div", {
4458
+ className: "min-h-0 flex-1 overflow-y-auto",
4459
+ children: /* @__PURE__ */ jsx(VariablesEditor, {
4460
+ variables: model.variables,
4461
+ callbacks,
4462
+ onClose: () => setSelectedId(null)
4463
+ })
4464
+ })]
4465
+ }) : null,
4466
+ selectedStep || selectedTrigger ? /* @__PURE__ */ jsx(ExpressionTargetProvider, {
4467
+ stepBlocks,
4468
+ triggerBlock: trigger,
4469
+ children: /* @__PURE__ */ jsxs("aside", {
4470
+ className: "relative flex min-h-0 shrink-0 flex-col border-l border-solid border-foreground/10 bg-card",
4471
+ style: { width: panel.width },
4472
+ children: [
4473
+ /* @__PURE__ */ jsx(PanelResizer, {
4474
+ width: panel.width,
4475
+ onResize: panel.resize
4476
+ }),
4477
+ /* @__PURE__ */ jsxs("div", {
4478
+ className: "min-h-0 flex-1 overflow-y-auto",
4479
+ children: [selectedStep ? /* @__PURE__ */ jsx(StepPanel, {
4480
+ step: selectedStep,
4481
+ model,
4482
+ callbacks,
4483
+ onClose: () => setSelectedId(null),
4484
+ onSelect: setSelectedId,
4485
+ readOnly: model.readOnly
4486
+ }, selectedStep.id) : null, selectedTrigger ? /* @__PURE__ */ jsx(TriggerPanel, {
4487
+ trigger: selectedTrigger,
4488
+ callbacks,
4489
+ onClose: () => setSelectedId(null),
4490
+ readOnly: model.readOnly,
4491
+ publishedVersion: model.published?.version
4492
+ }, selectedTrigger.id) : null]
4493
+ }),
4494
+ /* @__PURE__ */ jsx(ExpressionPickerPopup, {})
4495
+ ]
4496
+ })
4497
+ }, selectedId) : null
4498
+ ]
4499
+ })]
4500
+ })
4501
+ });
4502
+ }
4503
+ //#endregion
4504
+ //#region editors/workflow-editor/editor.tsx
4505
+ function treeValue(nodes) {
4506
+ return Object.fromEntries(nodes.map((node) => [node.name, node.children ? treeValue(node.children) : node.type]));
4507
+ }
4508
+ async function authoredOutput(runtime, block, config) {
4509
+ try {
4510
+ const tree = await runtime.queryClient.fetchQuery(outputTreeQuery(runtime.client, block, config));
4511
+ if (tree.nodes.length > 0) return treeValue(tree.nodes);
4512
+ return tree.source === "none" ? "no declared schema" : "value";
4513
+ } catch {
4514
+ return {};
4515
+ }
4516
+ }
4517
+ const LAST_RUN_POLL_MS = 1e4;
4518
+ function LastRunFact(props) {
4519
+ const runs = useRunsQuery({
4520
+ workflowId: props.workflowId,
4521
+ limit: 1
4522
+ }, { pollMs: LAST_RUN_POLL_MS });
4523
+ if (runs.status === "pending") return null;
4524
+ const run = runs.data?.at(0) ?? null;
4525
+ if (run === null) return /* @__PURE__ */ jsx("span", {
4526
+ className: "whitespace-nowrap text-xs text-muted-foreground",
4527
+ children: "Not run yet"
4528
+ });
4529
+ const tone = toneOf(RUN_TONE, run.status);
4530
+ return /* @__PURE__ */ jsxs("span", {
4531
+ className: "flex items-center gap-1.5 text-xs text-muted-foreground",
4532
+ title: formatAbsolute(run.startedAt),
4533
+ children: [
4534
+ "Last run",
4535
+ /* @__PURE__ */ jsx("span", { className: `h-1.5 w-1.5 rounded-full ${TONE_DOT[tone]}` }),
4536
+ /* @__PURE__ */ jsx("span", {
4537
+ className: TONE_TEXT[tone],
4538
+ children: formatWhen(run.startedAt)
4539
+ }),
4540
+ run.status === "WAITING" ? /* @__PURE__ */ jsx("span", {
4541
+ className: TONE_TEXT[tone],
4542
+ children: "waiting"
4543
+ }) : /* @__PURE__ */ jsx("span", {
4544
+ className: "tabular-nums",
4545
+ children: formatDuration(run.startedAt, run.endedAt)
4546
+ })
4547
+ ]
4548
+ });
4549
+ }
4550
+ function WorkflowEditor() {
4551
+ const { client, queryClient } = useRuntime();
4552
+ const actions = useRuntimeActions();
4553
+ const { model, callbacks } = useWorkflowModel();
4554
+ const [document] = useSelectedWorkflowDocument();
4555
+ const workflowId = document.header.id;
4556
+ const modules = useDocumentModelModules();
4557
+ const driveNodes = useFileNodesInSelectedDrive();
4558
+ const driveId = useSelectedDriveId() ?? void 0;
4559
+ const driveConnections = driveNodes ? driveNodes.filter((node) => node.documentType === "powerhouse/connection").map((node) => node.id).join(",") : null;
4560
+ const designTime = useMemo(() => ({
4561
+ workflowId,
4562
+ getBlockForm: (block) => client.getBlockForm(block),
4563
+ loadOptions: (block, propName, input, connectionId, searchValue, reactorConnectionId) => client.loadBlockOptions(block, propName, input, connectionId, searchValue, reactorConnectionId, workflowId),
4564
+ testTrigger: () => client.testTrigger(workflowId, driveId),
4565
+ testStep: (stepId) => client.testStep(workflowId, stepId, driveId),
4566
+ webhookEndpoint: () => client.fetchWebhookEndpoint(workflowId, driveId),
4567
+ connectionScope: driveConnections ?? void 0,
4568
+ listConnections: () => client.fetchConnections().then((connections) => {
4569
+ if (driveConnections === null) return connections;
4570
+ const inDrive = new Set(driveConnections.split(",").filter(Boolean));
4571
+ return connections.filter((connection) => inDrive.has(connection.id));
4572
+ }),
4573
+ latestRun: () => client.fetchRuns({
4574
+ workflowId,
4575
+ limit: 1,
4576
+ excludeTriggerKinds: [TEST_TRIGGER_KIND]
4577
+ }).then((runs) => realRuns(runs).at(0) ?? null),
4578
+ fetchRun: (runId) => client.fetchRun(runId),
4579
+ blockResolutions: () => client.blockResolutions(workflowId),
4580
+ secrets: {
4581
+ save: async ({ ref, value, label }) => {
4582
+ const stat = ref ? await client.fetchSecretStat(ref) : null;
4583
+ return ref && stat?.ownerId === workflowId && stat.manageable ? actions.rotateSecret(ref, value) : actions.createSecret(workflowId, value, label);
4584
+ },
4585
+ stat: (ref) => client.fetchSecretStat(ref)
4586
+ }
4587
+ }), [
4588
+ client,
4589
+ actions,
4590
+ workflowId,
4591
+ driveId,
4592
+ driveConnections
4593
+ ]);
4594
+ const scopeSource = useMemo(() => ({ load: async ({ stepId }) => {
4595
+ if (!stepId) return EMPTY_SCOPE;
4596
+ const latestRun = await queryClient.fetchQuery(runsQuery(client, {
4597
+ workflowId,
4598
+ limit: 1
4599
+ })).then((runs) => runs[0], () => void 0);
4600
+ return buildExpressionScope({
4601
+ model,
4602
+ stepId,
4603
+ latestRun,
4604
+ authoredOutput: (block, config) => authoredOutput({
4605
+ client,
4606
+ queryClient
4607
+ }, block, config),
4608
+ documentOutput: async (reference) => {
4609
+ const referenced = modules?.filter((module) => module.documentModel.global.id === reference.documentType).sort((a, b) => (b.version ?? 1) - (a.version ?? 1)).at(0)?.documentModel.global;
4610
+ const global = referenced ? await stateFieldsFromSdl({
4611
+ name: referenced.name,
4612
+ schema: referenced.specifications.at(-1)?.state.global.schema ?? null
4613
+ }) : {};
4614
+ return documentShape(reference, global);
4615
+ },
4616
+ testOutput: async (blockId) => {
4617
+ const block = model.trigger?.id === blockId ? model.trigger : model.steps.find((step) => step.id === blockId);
4618
+ const tree = await queryClient.fetchQuery(stepOutputTreeQuery(client, workflowId, blockId, block?.lastTest?.testedAt ?? null));
4619
+ return tree.source === "test" && tree.testedAt ? {
4620
+ value: tree.sample,
4621
+ testedAt: tree.testedAt
4622
+ } : void 0;
4623
+ }
4624
+ });
4625
+ } }), [
4626
+ client,
4627
+ queryClient,
4628
+ model,
4629
+ workflowId,
4630
+ modules
4631
+ ]);
4632
+ const maxSuspensionDays = document.state.global.policy.maxSuspensionDays;
4633
+ const placeholders = useMemo(() => ({ pausedFlowTimeoutDays: maxSuspensionDays > 0 ? maxSuspensionDays : void 0 }), [maxSuspensionDays]);
4634
+ return /* @__PURE__ */ jsx(DesignTimeProvider, {
4635
+ service: designTime,
4636
+ queryClient,
4637
+ scope: client.url,
4638
+ children: /* @__PURE__ */ jsx(ExpressionScopeSourceProvider, {
4639
+ value: scopeSource,
4640
+ children: /* @__PURE__ */ jsx(PiecePlaceholderContext.Provider, {
4641
+ value: placeholders,
4642
+ children: /* @__PURE__ */ jsx("div", {
4643
+ className: "flex h-full min-h-0 flex-col bg-background",
4644
+ children: /* @__PURE__ */ jsx(WorkflowEditorApp, {
4645
+ model,
4646
+ callbacks,
4647
+ leading: /* @__PURE__ */ jsx(BackButton, { documentId: workflowId }),
4648
+ trailing: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(LastRunFact, { workflowId }), /* @__PURE__ */ jsx(UndoRedo, {
4649
+ documentId: workflowId,
4650
+ reducer,
4651
+ policy: WORKFLOW_UNDO,
4652
+ readOnly: model.readOnly
4653
+ })] })
4654
+ })
4655
+ })
4656
+ })
4657
+ })
4658
+ });
4659
+ }
4660
+ function Editor({ document }) {
4661
+ return /* @__PURE__ */ jsx(DocumentErrorBoundary, {
4662
+ documentId: document.header.id,
4663
+ children: /* @__PURE__ */ jsx(WorkflowRuntimeProvider, { children: /* @__PURE__ */ jsx(WorkflowEditor, {}) })
4664
+ });
4665
+ }
4666
+ //#endregion
4667
+ export { Editor as default };
4668
+
4669
+ //# sourceMappingURL=editor-DYjoPfta.js.map