@powerhousedao/workflow 6.2.3-dev.24 → 6.2.3-dev.26

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 (308) hide show
  1. package/README.md +37 -0
  2. package/dist/browser/BlockSelector-QQgOCVH3.js +1355 -0
  3. package/dist/browser/BlockSelector-QQgOCVH3.js.map +1 -0
  4. package/dist/browser/{PieceMarkdown-CZYNY1qQ.js → PieceMarkdown-C8Gv88TV.js} +139 -105
  5. package/dist/browser/PieceMarkdown-C8Gv88TV.js.map +1 -0
  6. package/dist/browser/assets/{entry-CSJBrcX5.js → entry-DhaRsTID.js} +2 -3
  7. package/dist/browser/assets/{projection-entry-D67cdPsg.js → projection-entry-qrF_MLsE.js} +7 -13
  8. package/dist/browser/{connection-DEe5aDuU.js → connection-BUum0hJI.js} +2 -2
  9. package/dist/browser/{connection-DEe5aDuU.js.map → connection-BUum0hJI.js.map} +1 -1
  10. package/dist/browser/connection-form-XKR4zQgQ.js +533 -0
  11. package/dist/browser/connection-form-XKR4zQgQ.js.map +1 -0
  12. package/dist/browser/data-tree-DKrDFeQg.js +1896 -0
  13. package/dist/browser/data-tree-DKrDFeQg.js.map +1 -0
  14. package/dist/browser/document-models/connection/index.js +2 -2
  15. package/dist/browser/document-models/index.js +3 -3
  16. package/dist/browser/document-models/workflow/index.js +2 -2
  17. package/dist/browser/{document-models-BYheX-te.js → document-models-C6ebrsd9.js} +3 -3
  18. package/dist/browser/{document-models-BYheX-te.js.map → document-models-C6ebrsd9.js.map} +1 -1
  19. package/dist/browser/editor-C_E_JTp6.js +257 -0
  20. package/dist/browser/editor-C_E_JTp6.js.map +1 -0
  21. package/dist/browser/{editor-D0sdUxJa.js → editor-YZw296bf.js} +3348 -1610
  22. package/dist/browser/editor-YZw296bf.js.map +1 -0
  23. package/dist/browser/editor-fjwq-8Yq.js +1527 -0
  24. package/dist/browser/editor-fjwq-8Yq.js.map +1 -0
  25. package/dist/browser/editors/connection-editor/module.js +1 -1
  26. package/dist/browser/editors/connection-editor/module.js.map +1 -1
  27. package/dist/browser/editors/workflow-editor/module.js +1 -1
  28. package/dist/browser/editors/workflow-editor/module.js.map +1 -1
  29. package/dist/browser/editors/workflow-studio/module.js +1 -1
  30. package/dist/browser/editors/workflow-studio/module.js.map +1 -1
  31. package/dist/browser/index.js +7 -5
  32. package/dist/browser/index.js.map +1 -1
  33. package/dist/browser/{module-CYQnNZWl.js → module-Bkms70LV.js} +3 -3
  34. package/dist/browser/{module-CYQnNZWl.js.map → module-Bkms70LV.js.map} +1 -1
  35. package/dist/{node/module-IA-Ay7ig.mjs → browser/module-jDZ4pq3W.js} +2 -2
  36. package/dist/browser/{module-12vI18HY.js.map → module-jDZ4pq3W.js.map} +1 -1
  37. package/dist/browser/piece-auth-Z4mZEOtL.js +113 -0
  38. package/dist/browser/piece-auth-Z4mZEOtL.js.map +1 -0
  39. package/dist/browser/reactor/index.js +2 -2
  40. package/dist/browser/{chunk-BoAXSpZd.js → rolldown-runtime-DC62tzP2.js} +2 -2
  41. package/dist/browser/{runtime-api-DKlnn45K.js → runtime-api-xwvg5PzA.js} +40 -123
  42. package/dist/browser/runtime-api-xwvg5PzA.js.map +1 -0
  43. package/dist/browser/style.css +26 -0
  44. package/dist/browser/trigger-text-CdNxQOHw.js +551 -0
  45. package/dist/browser/trigger-text-CdNxQOHw.js.map +1 -0
  46. package/dist/browser/upgrade-manifests-BLrv3cf2.js +8 -0
  47. package/dist/browser/{upgrade-manifests-Cnpfo6kC.js.map → upgrade-manifests-BLrv3cf2.js.map} +1 -1
  48. package/dist/browser/{workflow-CFZUezoY.js → workflow-CGtVlhr8.js} +2 -2
  49. package/dist/browser/{workflow-CFZUezoY.js.map → workflow-CGtVlhr8.js.map} +1 -1
  50. package/dist/node/BlockSelector-COZm6-ev.mjs +1355 -0
  51. package/dist/node/BlockSelector-COZm6-ev.mjs.map +1 -0
  52. package/dist/node/{PieceMarkdown-D9nI2gI2.mjs → PieceMarkdown-DIxZY5aG.mjs} +132 -100
  53. package/dist/node/PieceMarkdown-DIxZY5aG.mjs.map +1 -0
  54. package/dist/node/{connection-DGsS2Db3.mjs → connection-D544oqVW.mjs} +2 -2
  55. package/dist/node/{connection-DGsS2Db3.mjs.map → connection-D544oqVW.mjs.map} +1 -1
  56. package/dist/node/connection-form-BLduFusc.mjs +533 -0
  57. package/dist/node/connection-form-BLduFusc.mjs.map +1 -0
  58. package/dist/node/data-tree-CmiGqG7C.mjs +1903 -0
  59. package/dist/node/data-tree-CmiGqG7C.mjs.map +1 -0
  60. package/dist/node/document-models/connection/index.mjs +2 -2
  61. package/dist/node/document-models/index.mjs +3 -3
  62. package/dist/node/document-models/workflow/index.mjs +2 -2
  63. package/dist/node/{editor-sVzt1o51.mjs → editor-B2ZoeGue.mjs} +3200 -1508
  64. package/dist/node/editor-B2ZoeGue.mjs.map +1 -0
  65. package/dist/node/editor-CN4PEGrW.mjs +257 -0
  66. package/dist/node/editor-CN4PEGrW.mjs.map +1 -0
  67. package/dist/node/editor-CyNBEKoj.mjs +1527 -0
  68. package/dist/node/editor-CyNBEKoj.mjs.map +1 -0
  69. package/dist/node/editors/connection-editor/module.mjs +1 -1
  70. package/dist/node/editors/connection-editor/module.mjs.map +1 -1
  71. package/dist/node/editors/workflow-editor/module.mjs +1 -1
  72. package/dist/node/editors/workflow-editor/module.mjs.map +1 -1
  73. package/dist/node/editors/workflow-studio/module.mjs +1 -1
  74. package/dist/node/editors/workflow-studio/module.mjs.map +1 -1
  75. package/dist/node/index.mjs +8 -6
  76. package/dist/node/index.mjs.map +1 -1
  77. package/dist/{browser/module-12vI18HY.js → node/module-BMwJQh65.mjs} +2 -2
  78. package/dist/node/{module-IA-Ay7ig.mjs.map → module-BMwJQh65.mjs.map} +1 -1
  79. package/dist/node/{module-IRMgzJC1.mjs → module-DuxxhgKs.mjs} +3 -3
  80. package/dist/node/{module-IRMgzJC1.mjs.map → module-DuxxhgKs.mjs.map} +1 -1
  81. package/dist/node/piece-auth-Z4mZEOtL.mjs +113 -0
  82. package/dist/node/piece-auth-Z4mZEOtL.mjs.map +1 -0
  83. package/dist/node/pieces/index.mjs.map +1 -1
  84. package/dist/node/pieces/reactor/index.mjs +226 -488
  85. package/dist/node/pieces/reactor/index.mjs.map +1 -1
  86. package/dist/node/{chunk-BSw8zbkd.mjs → rolldown-runtime-BMI-E3GI.mjs} +11 -4
  87. package/dist/node/{runtime-api-CtvvFHut.mjs → runtime-api-xwvg5PzA.mjs} +40 -123
  88. package/dist/node/runtime-api-xwvg5PzA.mjs.map +1 -0
  89. package/dist/node/style.css +26 -0
  90. package/dist/node/trigger-text-qj_U3Qzd.mjs +551 -0
  91. package/dist/node/trigger-text-qj_U3Qzd.mjs.map +1 -0
  92. package/dist/node/upgrade-manifests-C1sl_M-H.mjs +8 -0
  93. package/dist/node/{upgrade-manifests-3VN0Bfcf.mjs.map → upgrade-manifests-C1sl_M-H.mjs.map} +1 -1
  94. package/dist/node/{workflow-fFvyypuu.mjs → workflow-C-uuQPnf.mjs} +2 -2
  95. package/dist/node/{workflow-fFvyypuu.mjs.map → workflow-C-uuQPnf.mjs.map} +1 -1
  96. package/dist/style.css +927 -252
  97. package/dist/types/document-models/connection/upgrades/versions.d.ts.map +1 -1
  98. package/dist/types/document-models/connection/v1/actions.d.ts +6 -10
  99. package/dist/types/document-models/connection/v1/actions.d.ts.map +1 -1
  100. package/dist/types/document-models/connection/v1/gen/config/creators.d.ts.map +1 -1
  101. package/dist/types/document-models/connection/v1/gen/config/error.d.ts.map +1 -1
  102. package/dist/types/document-models/connection/v1/gen/connection/creators.d.ts.map +1 -1
  103. package/dist/types/document-models/connection/v1/gen/health/creators.d.ts.map +1 -1
  104. package/dist/types/document-models/connection/v1/gen/schema/zod.d.ts.map +1 -1
  105. package/dist/types/document-models/connection/v1/module.d.ts +6 -10
  106. package/dist/types/document-models/connection/v1/module.d.ts.map +1 -1
  107. package/dist/types/document-models/connection/v1/tests/document-model.test.d.ts +0 -8
  108. package/dist/types/document-models/connection/v1/tests/document-model.test.d.ts.map +1 -1
  109. package/dist/types/document-models/document-models.d.ts +15 -23
  110. package/dist/types/document-models/document-models.d.ts.map +1 -1
  111. package/dist/types/document-models/workflow/upgrades/versions.d.ts.map +1 -1
  112. package/dist/types/document-models/workflow/v1/actions.d.ts +9 -13
  113. package/dist/types/document-models/workflow/v1/actions.d.ts.map +1 -1
  114. package/dist/types/document-models/workflow/v1/gen/edges/creators.d.ts.map +1 -1
  115. package/dist/types/document-models/workflow/v1/gen/edges/error.d.ts.map +1 -1
  116. package/dist/types/document-models/workflow/v1/gen/policy/creators.d.ts.map +1 -1
  117. package/dist/types/document-models/workflow/v1/gen/runtime/creators.d.ts.map +1 -1
  118. package/dist/types/document-models/workflow/v1/gen/schema/zod.d.ts.map +1 -1
  119. package/dist/types/document-models/workflow/v1/gen/steps/creators.d.ts.map +1 -1
  120. package/dist/types/document-models/workflow/v1/gen/steps/error.d.ts.map +1 -1
  121. package/dist/types/document-models/workflow/v1/gen/trigger/creators.d.ts.map +1 -1
  122. package/dist/types/document-models/workflow/v1/gen/trigger/error.d.ts.map +1 -1
  123. package/dist/types/document-models/workflow/v1/gen/variables/creators.d.ts.map +1 -1
  124. package/dist/types/document-models/workflow/v1/gen/variables/error.d.ts.map +1 -1
  125. package/dist/types/document-models/workflow/v1/gen/workflow/creators.d.ts.map +1 -1
  126. package/dist/types/document-models/workflow/v1/module.d.ts +9 -13
  127. package/dist/types/document-models/workflow/v1/module.d.ts.map +1 -1
  128. package/dist/types/document-models/workflow/v1/tests/document-model.test.d.ts +0 -8
  129. package/dist/types/document-models/workflow/v1/tests/document-model.test.d.ts.map +1 -1
  130. package/dist/types/editors/connection-editor/ConnectionToolbar.d.ts +2 -0
  131. package/dist/types/editors/connection-editor/ConnectionToolbar.d.ts.map +1 -1
  132. package/dist/types/editors/connection-editor/UsedBy.d.ts +6 -0
  133. package/dist/types/editors/connection-editor/UsedBy.d.ts.map +1 -0
  134. package/dist/types/editors/connection-editor/connection-callbacks.d.ts.map +1 -1
  135. package/dist/types/editors/connection-editor/connection-callbacks.test.d.ts +2 -0
  136. package/dist/types/editors/connection-editor/connection-callbacks.test.d.ts.map +1 -0
  137. package/dist/types/editors/connection-editor/connection-form.d.ts +5 -1
  138. package/dist/types/editors/connection-editor/connection-form.d.ts.map +1 -1
  139. package/dist/types/editors/connection-editor/connection-usage.d.ts.map +1 -0
  140. package/dist/types/editors/connection-editor/connection-usage.test.d.ts.map +1 -0
  141. package/dist/types/editors/connection-editor/editor.d.ts.map +1 -1
  142. package/dist/types/editors/connection-editor/piece-auth.d.ts +2 -0
  143. package/dist/types/editors/connection-editor/piece-auth.d.ts.map +1 -1
  144. package/dist/types/editors/connection-editor/status.d.ts +3 -1
  145. package/dist/types/editors/connection-editor/status.d.ts.map +1 -1
  146. package/dist/types/editors/shared/DocumentErrorBoundary.d.ts.map +1 -1
  147. package/dist/types/editors/shared/controls.d.ts +98 -0
  148. package/dist/types/editors/shared/controls.d.ts.map +1 -0
  149. package/dist/types/editors/shared/data-tree.d.ts +5 -0
  150. package/dist/types/editors/shared/data-tree.d.ts.map +1 -0
  151. package/dist/types/editors/shared/data-viewer.d.ts +7 -0
  152. package/dist/types/editors/shared/data-viewer.d.ts.map +1 -0
  153. package/dist/types/editors/shared/editor-chrome.d.ts +7 -0
  154. package/dist/types/editors/shared/editor-chrome.d.ts.map +1 -0
  155. package/dist/types/editors/shared/icons.d.ts +36 -0
  156. package/dist/types/editors/shared/icons.d.ts.map +1 -0
  157. package/dist/types/editors/workflow-editor/editor.d.ts.map +1 -1
  158. package/dist/types/editors/workflow-editor/runtime-api.d.ts +2 -0
  159. package/dist/types/editors/workflow-editor/runtime-api.d.ts.map +1 -1
  160. package/dist/types/editors/workflow-editor/ui/ActionListEditor.d.ts.map +1 -1
  161. package/dist/types/editors/workflow-editor/ui/Autocomplete.d.ts +1 -0
  162. package/dist/types/editors/workflow-editor/ui/Autocomplete.d.ts.map +1 -1
  163. package/dist/types/editors/workflow-editor/ui/BlockSelector.d.ts +1 -0
  164. package/dist/types/editors/workflow-editor/ui/BlockSelector.d.ts.map +1 -1
  165. package/dist/types/editors/workflow-editor/ui/ConnectionField.d.ts.map +1 -1
  166. package/dist/types/editors/workflow-editor/ui/CreateConnectionModal.d.ts +1 -1
  167. package/dist/types/editors/workflow-editor/ui/CreateConnectionModal.d.ts.map +1 -1
  168. package/dist/types/editors/workflow-editor/ui/ExpressionPicker.d.ts.map +1 -1
  169. package/dist/types/editors/workflow-editor/ui/PieceMarkdown.d.ts.map +1 -1
  170. package/dist/types/editors/workflow-editor/ui/PropertyForm.d.ts.map +1 -1
  171. package/dist/types/editors/workflow-editor/ui/ScheduleBuilder.d.ts +5 -0
  172. package/dist/types/editors/workflow-editor/ui/ScheduleBuilder.d.ts.map +1 -0
  173. package/dist/types/editors/workflow-editor/ui/StepPanel.d.ts +1 -0
  174. package/dist/types/editors/workflow-editor/ui/StepPanel.d.ts.map +1 -1
  175. package/dist/types/editors/workflow-editor/ui/WorkflowCanvas.d.ts.map +1 -1
  176. package/dist/types/editors/workflow-editor/ui/WorkflowEditorApp.d.ts +3 -0
  177. package/dist/types/editors/workflow-editor/ui/WorkflowEditorApp.d.ts.map +1 -1
  178. package/dist/types/editors/workflow-editor/ui/ap-edge.d.ts.map +1 -1
  179. package/dist/types/editors/workflow-editor/ui/ap-layout.d.ts +1 -0
  180. package/dist/types/editors/workflow-editor/ui/ap-layout.d.ts.map +1 -1
  181. package/dist/types/editors/workflow-editor/ui/ap-nodes.d.ts.map +1 -1
  182. package/dist/types/editors/workflow-editor/ui/block-meta.d.ts +6 -0
  183. package/dist/types/editors/workflow-editor/ui/block-meta.d.ts.map +1 -1
  184. package/dist/types/editors/workflow-editor/ui/connection-create.d.ts +1 -1
  185. package/dist/types/editors/workflow-editor/ui/connection-create.d.ts.map +1 -1
  186. package/dist/types/editors/workflow-editor/ui/forms.d.ts +14 -0
  187. package/dist/types/editors/workflow-editor/ui/forms.d.ts.map +1 -1
  188. package/dist/types/editors/workflow-editor/ui/model.test.d.ts +2 -0
  189. package/dist/types/editors/workflow-editor/ui/model.test.d.ts.map +1 -0
  190. package/dist/types/editors/workflow-editor/ui/schedule-draft.d.ts +35 -0
  191. package/dist/types/editors/workflow-editor/ui/schedule-draft.d.ts.map +1 -0
  192. package/dist/types/editors/workflow-editor/ui/schedule-draft.test.d.ts +2 -0
  193. package/dist/types/editors/workflow-editor/ui/schedule-draft.test.d.ts.map +1 -0
  194. package/dist/types/editors/workflow-editor/ui/trigger-text.d.ts +9 -0
  195. package/dist/types/editors/workflow-editor/ui/trigger-text.d.ts.map +1 -0
  196. package/dist/types/editors/workflow-editor/ui/trigger-text.test.d.ts +2 -0
  197. package/dist/types/editors/workflow-editor/ui/trigger-text.test.d.ts.map +1 -0
  198. package/dist/types/editors/workflow-editor/ui/validation.d.ts.map +1 -1
  199. package/dist/types/editors/workflow-studio/components/RunsTable.d.ts +2 -0
  200. package/dist/types/editors/workflow-studio/components/RunsTable.d.ts.map +1 -1
  201. package/dist/types/editors/workflow-studio/components/RunsTable.test.d.ts +2 -0
  202. package/dist/types/editors/workflow-studio/components/RunsTable.test.d.ts.map +1 -0
  203. package/dist/types/editors/workflow-studio/components/RunsView.d.ts.map +1 -1
  204. package/dist/types/editors/workflow-studio/components/Sidebar.d.ts +1 -1
  205. package/dist/types/editors/workflow-studio/components/Sidebar.d.ts.map +1 -1
  206. package/dist/types/editors/workflow-studio/components/WorkflowBoard.d.ts +8 -0
  207. package/dist/types/editors/workflow-studio/components/WorkflowBoard.d.ts.map +1 -0
  208. package/dist/types/editors/workflow-studio/components/WorkflowHeader.d.ts.map +1 -1
  209. package/dist/types/editors/workflow-studio/components/WorkflowSteps.d.ts.map +1 -1
  210. package/dist/types/editors/workflow-studio/components/WorkflowStudio.d.ts.map +1 -1
  211. package/dist/types/editors/workflow-studio/components/chain.d.ts +18 -0
  212. package/dist/types/editors/workflow-studio/components/chain.d.ts.map +1 -0
  213. package/dist/types/editors/workflow-studio/components/run-format.d.ts +29 -6
  214. package/dist/types/editors/workflow-studio/components/run-format.d.ts.map +1 -1
  215. package/dist/types/editors/workflow-studio/components/run-format.test.d.ts +2 -0
  216. package/dist/types/editors/workflow-studio/components/run-format.test.d.ts.map +1 -0
  217. package/dist/types/editors/workflow-studio/components/run-timeline.test.d.ts +2 -0
  218. package/dist/types/editors/workflow-studio/components/run-timeline.test.d.ts.map +1 -0
  219. package/dist/types/editors/workflow-studio/components/ui.d.ts +20 -0
  220. package/dist/types/editors/workflow-studio/components/ui.d.ts.map +1 -0
  221. package/dist/types/editors/workflow-studio/components/useRuns.d.ts +1 -1
  222. package/dist/types/editors/workflow-studio/components/useRuns.d.ts.map +1 -1
  223. package/dist/types/pieces/index.d.ts.map +1 -1
  224. package/dist/types/pieces/reactor/index.d.ts.map +1 -1
  225. package/dist/types/pieces/reactor/lib/reactor.d.ts.map +1 -1
  226. package/dist/types/pieces/reactor/lib/triggers/document-event.d.ts +12 -12
  227. package/dist/types/playwright.config.d.ts +3 -0
  228. package/dist/types/playwright.config.d.ts.map +1 -0
  229. package/dist/types/scripts/ui-shots.d.ts +2 -0
  230. package/dist/types/scripts/ui-shots.d.ts.map +1 -0
  231. package/dist/types/scripts/ui-stack.d.ts +77 -0
  232. package/dist/types/scripts/ui-stack.d.ts.map +1 -0
  233. package/dist/types/test/ui/connection-editor.spec.d.ts +2 -0
  234. package/dist/types/test/ui/connection-editor.spec.d.ts.map +1 -0
  235. package/dist/types/test/ui/data-viewer.spec.d.ts +2 -0
  236. package/dist/types/test/ui/data-viewer.spec.d.ts.map +1 -0
  237. package/dist/types/test/ui/fixtures.d.ts +9 -0
  238. package/dist/types/test/ui/fixtures.d.ts.map +1 -0
  239. package/dist/types/test/ui/global-setup.d.ts +2 -0
  240. package/dist/types/test/ui/global-setup.d.ts.map +1 -0
  241. package/dist/types/test/ui/pieces.spec.d.ts +2 -0
  242. package/dist/types/test/ui/pieces.spec.d.ts.map +1 -0
  243. package/dist/types/test/ui/step-panel.spec.d.ts +2 -0
  244. package/dist/types/test/ui/step-panel.spec.d.ts.map +1 -0
  245. package/dist/types/test/ui/studio.spec.d.ts +2 -0
  246. package/dist/types/test/ui/studio.spec.d.ts.map +1 -0
  247. package/dist/types/vitest.config.d.ts.map +1 -1
  248. package/package.json +18 -12
  249. package/dist/browser/PieceMarkdown-CZYNY1qQ.js.map +0 -1
  250. package/dist/browser/ap-layout-BpKqIHQt.js +0 -337
  251. package/dist/browser/ap-layout-BpKqIHQt.js.map +0 -1
  252. package/dist/browser/connection-form-B1SkwNgY.js +0 -453
  253. package/dist/browser/connection-form-B1SkwNgY.js.map +0 -1
  254. package/dist/browser/editor-CCKpl-Gd.js +0 -1550
  255. package/dist/browser/editor-CCKpl-Gd.js.map +0 -1
  256. package/dist/browser/editor-CIZRPdKM.js +0 -134
  257. package/dist/browser/editor-CIZRPdKM.js.map +0 -1
  258. package/dist/browser/editor-D0sdUxJa.js.map +0 -1
  259. package/dist/browser/runtime-api-DKlnn45K.js.map +0 -1
  260. package/dist/browser/status-kpDX5CIA.js +0 -11
  261. package/dist/browser/status-kpDX5CIA.js.map +0 -1
  262. package/dist/browser/upgrade-manifests-Cnpfo6kC.js +0 -8
  263. package/dist/browser/use-runtime-url-By5q3sa_.js +0 -174
  264. package/dist/browser/use-runtime-url-By5q3sa_.js.map +0 -1
  265. package/dist/node/PieceMarkdown-D9nI2gI2.mjs.map +0 -1
  266. package/dist/node/ap-layout-Dzhi9JFC.mjs +0 -337
  267. package/dist/node/ap-layout-Dzhi9JFC.mjs.map +0 -1
  268. package/dist/node/connection-form-DejaNF09.mjs +0 -453
  269. package/dist/node/connection-form-DejaNF09.mjs.map +0 -1
  270. package/dist/node/editor-DfFRZS9L.mjs +0 -134
  271. package/dist/node/editor-DfFRZS9L.mjs.map +0 -1
  272. package/dist/node/editor-NbAB78He.mjs +0 -1550
  273. package/dist/node/editor-NbAB78He.mjs.map +0 -1
  274. package/dist/node/editor-sVzt1o51.mjs.map +0 -1
  275. package/dist/node/runtime-api-CtvvFHut.mjs.map +0 -1
  276. package/dist/node/status-CDRcDUMS.mjs +0 -11
  277. package/dist/node/status-CDRcDUMS.mjs.map +0 -1
  278. package/dist/node/upgrade-manifests-3VN0Bfcf.mjs +0 -8
  279. package/dist/node/use-runtime-url-BbFEkaZy.mjs +0 -174
  280. package/dist/node/use-runtime-url-BbFEkaZy.mjs.map +0 -1
  281. package/dist/types/document-models/connection/v1/tests/config.test.d.ts +0 -2
  282. package/dist/types/document-models/connection/v1/tests/config.test.d.ts.map +0 -1
  283. package/dist/types/document-models/connection/v1/tests/connection.test.d.ts +0 -2
  284. package/dist/types/document-models/connection/v1/tests/connection.test.d.ts.map +0 -1
  285. package/dist/types/document-models/connection/v1/tests/health.test.d.ts +0 -2
  286. package/dist/types/document-models/connection/v1/tests/health.test.d.ts.map +0 -1
  287. package/dist/types/document-models/workflow/v1/tests/edges.test.d.ts +0 -2
  288. package/dist/types/document-models/workflow/v1/tests/edges.test.d.ts.map +0 -1
  289. package/dist/types/document-models/workflow/v1/tests/policy.test.d.ts +0 -2
  290. package/dist/types/document-models/workflow/v1/tests/policy.test.d.ts.map +0 -1
  291. package/dist/types/document-models/workflow/v1/tests/runtime.test.d.ts +0 -2
  292. package/dist/types/document-models/workflow/v1/tests/runtime.test.d.ts.map +0 -1
  293. package/dist/types/document-models/workflow/v1/tests/steps.test.d.ts +0 -2
  294. package/dist/types/document-models/workflow/v1/tests/steps.test.d.ts.map +0 -1
  295. package/dist/types/document-models/workflow/v1/tests/trigger.test.d.ts +0 -2
  296. package/dist/types/document-models/workflow/v1/tests/trigger.test.d.ts.map +0 -1
  297. package/dist/types/document-models/workflow/v1/tests/variables.test.d.ts +0 -2
  298. package/dist/types/document-models/workflow/v1/tests/variables.test.d.ts.map +0 -1
  299. package/dist/types/document-models/workflow/v1/tests/workflow.test.d.ts +0 -2
  300. package/dist/types/document-models/workflow/v1/tests/workflow.test.d.ts.map +0 -1
  301. package/dist/types/editors/workflow-studio/components/ConnectionView.d.ts +0 -7
  302. package/dist/types/editors/workflow-studio/components/ConnectionView.d.ts.map +0 -1
  303. package/dist/types/editors/workflow-studio/components/EditorToolbar.d.ts +0 -8
  304. package/dist/types/editors/workflow-studio/components/EditorToolbar.d.ts.map +0 -1
  305. package/dist/types/editors/workflow-studio/components/connection-usage.d.ts.map +0 -1
  306. package/dist/types/editors/workflow-studio/components/connection-usage.test.d.ts.map +0 -1
  307. /package/dist/types/editors/{workflow-studio/components → connection-editor}/connection-usage.d.ts +0 -0
  308. /package/dist/types/editors/{workflow-studio/components → connection-editor}/connection-usage.test.d.ts +0 -0
@@ -0,0 +1,1527 @@
1
+ import { f as fireWorkflow, g as rerunRun, l as fetchRuns } from "./runtime-api-xwvg5PzA.mjs";
2
+ import { y as actions } from "./module-DuxxhgKs.mjs";
3
+ import { r as useWorkflowDocumentsInSelectedDrive } from "./workflow-C-uuQPnf.mjs";
4
+ import { C as runStats, D as workflowHealth, E as toneOf, F as Select, H as DocumentErrorBoundary, O as useSyncWorkflowRuntimeUrl, S as formatWhen, T as statusLabel, U as DocumentLoadError, V as Icon, W as errorMessage, _ as durationMs, b as formatMs, d as RUN_TONE, f as STEP_TONE, g as WORKFLOW_TONE, h as TONE_TEXT, k as Button, l as CONNECTION_TONE, m as TONE_DOT, p as TONE_BADGE, r as blockMeta, s as usePieceLogos, t as BlockLogo, u as RUN_STATUSES, v as formatAbsolute, w as runTimeline, x as formatTrigger, y as formatDuration } from "./BlockSelector-COZm6-ev.mjs";
5
+ import { c as DataViewer, p as portRank, r as describeTrigger } from "./trigger-text-qj_U3Qzd.mjs";
6
+ import { addDocument, setSelectedNode, showDeleteNodeModal, useDispatch, useDocumentSafe, useFileNodesInSelectedDrive, usePHToast, useSelectedDrive, useSelectedNode, useSetPHAppConfig } from "@powerhousedao/reactor-browser";
7
+ import { Fragment, useCallback, useEffect, useMemo, useRef, useState } from "react";
8
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
9
+ //#region editors/workflow-studio/components/chain.tsx
10
+ const RING$1 = {
11
+ ok: "ring-wf-ok",
12
+ fail: "ring-wf-fail",
13
+ warn: "ring-wf-warn",
14
+ run: "ring-wf-run",
15
+ idle: "ring-foreground/15"
16
+ };
17
+ const RAIL$1 = {
18
+ ok: "bg-wf-ok",
19
+ fail: "bg-wf-fail",
20
+ warn: "bg-wf-warn",
21
+ run: "bg-wf-run",
22
+ idle: "bg-foreground/15"
23
+ };
24
+ const MAX_STOPS = 6;
25
+ function MiniChain(props) {
26
+ const md = props.size === "md";
27
+ const overflow = props.links.length > MAX_STOPS;
28
+ const shown = overflow ? props.links.slice(0, 5) : props.links;
29
+ const hidden = props.links.length - shown.length;
30
+ const tones = shown.map((link) => link.status ? toneOf(STEP_TONE, link.status) : "idle");
31
+ return /* @__PURE__ */ jsxs("ol", {
32
+ className: "flex items-center",
33
+ "aria-label": props.links.map((link) => `${link.label}${link.status ? `: ${link.status.toLowerCase()}` : ""}`).join(", "),
34
+ children: [shown.map((link, index) => /* @__PURE__ */ jsxs("li", {
35
+ className: "flex items-center",
36
+ children: [index > 0 ? /* @__PURE__ */ jsx("span", {
37
+ "aria-hidden": true,
38
+ className: `h-0.5 ${md ? "w-5" : "w-3"} ${RAIL$1[tones[index]]}`
39
+ }) : null, /* @__PURE__ */ jsx("span", {
40
+ title: link.status ? `${link.label}: ${link.status.toLowerCase()}` : link.label,
41
+ className: `flex shrink-0 items-center justify-center rounded-full bg-card ring-[1.5px] dark:bg-white ${md ? "h-8 w-8" : "h-6 w-6"} ${RING$1[tones[index]]} ${link.status === "SKIPPED" ? "opacity-50" : ""}`,
42
+ children: /* @__PURE__ */ jsx(BlockLogo, {
43
+ bare: true,
44
+ blockType: link.blockType,
45
+ size: md ? 16 : 14
46
+ })
47
+ })]
48
+ }, link.id)), overflow ? /* @__PURE__ */ jsxs("li", {
49
+ "aria-hidden": true,
50
+ className: "flex items-center",
51
+ children: [/* @__PURE__ */ jsx("span", { className: `h-0.5 ${md ? "w-5" : "w-3"} bg-foreground/15` }), /* @__PURE__ */ jsxs("span", {
52
+ title: props.links.slice(shown.length).map((link) => link.label).join(", "),
53
+ className: `flex shrink-0 items-center justify-center rounded-full bg-muted px-1.5 text-[11px] font-medium tabular-nums text-muted-foreground ${md ? "h-8" : "h-6"}`,
54
+ children: ["+", hidden]
55
+ })]
56
+ }) : null]
57
+ });
58
+ }
59
+ /** A run's own chain: the trigger, then every step it recorded. */
60
+ function runLinks(run, triggerBlockType) {
61
+ return [{
62
+ id: "trigger",
63
+ blockType: triggerBlockType ?? `core#${run.triggerKind}`,
64
+ label: "Trigger",
65
+ status: "SUCCEEDED"
66
+ }, ...run.steps.map((step) => ({
67
+ id: step.stepId + step.stepKey,
68
+ blockType: step.blockType,
69
+ label: step.stepKey,
70
+ status: step.status
71
+ }))];
72
+ }
73
+ const STRIP_LENGTH = 14;
74
+ const TICK = {
75
+ ok: "bg-wf-ok",
76
+ fail: "bg-wf-fail",
77
+ warn: "bg-wf-warn",
78
+ run: "bg-wf-run animate-pulse",
79
+ idle: "bg-foreground/25"
80
+ };
81
+ /** Recent runs as ticks, oldest to newest, padded so strips line up. */
82
+ function RunStrip(props) {
83
+ const recent = props.runs.slice(0, STRIP_LENGTH).reverse();
84
+ const padding = STRIP_LENGTH - recent.length;
85
+ return /* @__PURE__ */ jsxs("span", {
86
+ className: "flex h-5 items-end gap-[3px]",
87
+ "aria-label": recent.length === 0 ? "No runs yet" : `Last ${recent.length} runs: ${recent.map((run) => run.status.toLowerCase()).join(", ")}`,
88
+ children: [Array.from({ length: padding }, (_, index) => /* @__PURE__ */ jsx("span", {
89
+ "aria-hidden": true,
90
+ className: "h-1.5 w-1.5 rounded-full bg-foreground/10"
91
+ }, `pad-${index}`)), recent.map((run) => /* @__PURE__ */ jsx("span", {
92
+ "aria-hidden": true,
93
+ title: `${statusLabel(run.status)}, ${formatAbsolute(run.startedAt)}`,
94
+ className: `h-5 w-1.5 rounded-full ${TICK[toneOf(RUN_TONE, run.status)]}`
95
+ }, run.id))]
96
+ });
97
+ }
98
+ //#endregion
99
+ //#region editors/workflow-studio/components/ui.tsx
100
+ function StatusDot(props) {
101
+ const hollow = props.tone === "idle";
102
+ return /* @__PURE__ */ jsx("span", {
103
+ "aria-hidden": true,
104
+ className: `inline-block h-2 w-2 shrink-0 rounded-full ${hollow ? "border border-solid border-muted-foreground/60" : TONE_DOT[props.tone]} ${props.className ?? ""}`
105
+ });
106
+ }
107
+ function StatusText(props) {
108
+ return /* @__PURE__ */ jsxs("span", {
109
+ className: `inline-flex items-center gap-1.5 font-medium ${TONE_TEXT[props.tone]} ${props.className ?? ""}`,
110
+ children: [/* @__PURE__ */ jsx(StatusDot, { tone: props.tone }), statusLabel(props.status)]
111
+ });
112
+ }
113
+ /** A label/value pair for a header's facts line. */
114
+ function Fact(props) {
115
+ return /* @__PURE__ */ jsxs("div", {
116
+ className: "flex min-w-0 flex-col gap-0.5",
117
+ title: props.title,
118
+ children: [/* @__PURE__ */ jsx("dt", {
119
+ className: "text-xs text-muted-foreground",
120
+ children: props.label
121
+ }), /* @__PURE__ */ jsx("dd", {
122
+ className: "truncate text-[13px] tabular-nums text-foreground",
123
+ children: props.children
124
+ })]
125
+ });
126
+ }
127
+ //#endregion
128
+ //#region editors/workflow-studio/components/RunsTable.tsx
129
+ const CONTROL = "h-8 rounded-md border border-solid border-border bg-card px-2.5 text-[13px] text-foreground placeholder:text-muted-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring";
130
+ function stringify(value) {
131
+ if (value === void 0) return "";
132
+ try {
133
+ return JSON.stringify(value, null, 2);
134
+ } catch {
135
+ return String(value);
136
+ }
137
+ }
138
+ function TimelineBar(props) {
139
+ return /* @__PURE__ */ jsxs("span", {
140
+ className: "ml-auto flex shrink-0 items-center gap-2",
141
+ children: [/* @__PURE__ */ jsx("span", {
142
+ "aria-hidden": true,
143
+ className: "relative hidden h-1.5 w-40 overflow-hidden rounded-full bg-muted sm:block",
144
+ children: props.span ? /* @__PURE__ */ jsx("span", {
145
+ className: `absolute inset-y-0 rounded-full ${TONE_DOT[props.tone]}`,
146
+ style: {
147
+ left: `${props.span.offset * 100}%`,
148
+ width: `max(${props.span.width * 100}%, 4px)`
149
+ }
150
+ }) : null
151
+ }), /* @__PURE__ */ jsx("span", {
152
+ className: "w-14 text-right text-[11px] tabular-nums text-muted-foreground",
153
+ children: props.span ? formatMs(props.span.ms) : "–"
154
+ })]
155
+ });
156
+ }
157
+ function StepRow(props) {
158
+ const { step } = props;
159
+ const meta = blockMeta(step.blockType);
160
+ const [open, setOpen] = useState(false);
161
+ return /* @__PURE__ */ jsxs("div", {
162
+ role: "listitem",
163
+ className: "border-t border-solid border-border",
164
+ children: [/* @__PURE__ */ jsxs("button", {
165
+ type: "button",
166
+ "aria-expanded": open,
167
+ className: "flex w-full items-center gap-3 px-3 py-2 text-left text-[13px] hover:bg-accent/60 focus-visible:bg-accent/60 focus-visible:outline-none",
168
+ onClick: () => setOpen((value) => !value),
169
+ children: [
170
+ /* @__PURE__ */ jsx(Icon, {
171
+ name: "chevron",
172
+ className: `h-3.5 w-3.5 text-muted-foreground transition-transform ${open ? "rotate-90" : ""}`
173
+ }),
174
+ /* @__PURE__ */ jsx(StatusText, {
175
+ tone: toneOf(STEP_TONE, step.status),
176
+ status: step.status,
177
+ className: "w-24 shrink-0 text-xs"
178
+ }),
179
+ /* @__PURE__ */ jsx("span", {
180
+ className: "shrink-0 font-medium text-foreground",
181
+ title: `Key: ${step.stepKey}`,
182
+ children: props.name ?? step.stepKey
183
+ }),
184
+ /* @__PURE__ */ jsxs("span", {
185
+ className: "flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",
186
+ children: [meta.logoUrl ? /* @__PURE__ */ jsx("img", {
187
+ src: meta.logoUrl,
188
+ alt: "",
189
+ title: meta.subtitle,
190
+ className: "h-3.5 w-3.5"
191
+ }) : null, /* @__PURE__ */ jsx("span", {
192
+ className: "truncate",
193
+ children: meta.logoUrl ? meta.displayName : `${meta.subtitle}: ${meta.displayName}`
194
+ })]
195
+ }),
196
+ step.port && step.port !== "next" ? /* @__PURE__ */ jsxs("span", {
197
+ className: "shrink-0 rounded bg-muted px-1.5 text-[11px] text-muted-foreground",
198
+ children: ["took ", step.port]
199
+ }) : null,
200
+ /* @__PURE__ */ jsx(TimelineBar, {
201
+ span: props.span,
202
+ tone: toneOf(STEP_TONE, step.status)
203
+ })
204
+ ]
205
+ }), open ? /* @__PURE__ */ jsxs("div", {
206
+ className: "space-y-2 pb-3 pl-10 pr-3",
207
+ children: [step.error ? /* @__PURE__ */ jsx("pre", {
208
+ className: "overflow-x-auto whitespace-pre-wrap rounded-md bg-wf-fail/10 p-2 text-xs text-wf-fail",
209
+ children: step.error
210
+ }) : null, step.status === "SKIPPED" ? /* @__PURE__ */ jsx("p", {
211
+ className: "text-xs text-muted-foreground",
212
+ children: "The run never reached this step."
213
+ }) : /* @__PURE__ */ jsxs("div", {
214
+ className: "grid items-start gap-2 md:grid-cols-2",
215
+ children: [/* @__PURE__ */ jsx(DataViewer, {
216
+ label: "Received",
217
+ value: step.input
218
+ }), /* @__PURE__ */ jsx(DataViewer, {
219
+ label: "Produced",
220
+ value: step.output,
221
+ root: `steps.${step.stepKey}.output`,
222
+ emptyText: step.status === "FAILED" ? "Nothing, the step failed" : void 0
223
+ })]
224
+ })]
225
+ }) : null]
226
+ });
227
+ }
228
+ const TRIGGER_LABEL = {
229
+ manual: "Manual",
230
+ schedule: "Schedule",
231
+ webhook: "Webhook",
232
+ "document-event": "Document change",
233
+ piece: "Piece trigger",
234
+ rerun: "Rerun"
235
+ };
236
+ function triggerLabel(kind) {
237
+ if (kind.startsWith("piece:")) return describeTrigger({
238
+ blockType: kind.slice(6),
239
+ config: null
240
+ });
241
+ return TRIGGER_LABEL[kind] ?? formatTrigger(kind);
242
+ }
243
+ function describeRunError(error, names) {
244
+ return error.replace(/^Step "([^"]+)" failed: /, (whole, key) => {
245
+ const name = names.get(key);
246
+ return name ? `${name} failed: ` : whole;
247
+ });
248
+ }
249
+ function TriggerRow(props) {
250
+ const { run } = props;
251
+ const [open, setOpen] = useState(false);
252
+ const payload = stringify(run.triggerPayload);
253
+ const hasPayload = payload !== "" && payload !== "null" && payload !== "{}";
254
+ return /* @__PURE__ */ jsxs("div", {
255
+ role: "listitem",
256
+ children: [/* @__PURE__ */ jsxs("button", {
257
+ type: "button",
258
+ "aria-expanded": hasPayload ? open : void 0,
259
+ disabled: !hasPayload,
260
+ className: "flex w-full items-center gap-3 px-3 py-2 text-left text-[13px] enabled:hover:bg-accent/60 focus-visible:bg-accent/60 focus-visible:outline-none",
261
+ onClick: () => setOpen((value) => !value),
262
+ children: [
263
+ /* @__PURE__ */ jsx(Icon, {
264
+ name: "chevron",
265
+ className: `h-3.5 w-3.5 text-muted-foreground transition-transform ${open ? "rotate-90" : ""} ${hasPayload ? "" : "invisible"}`
266
+ }),
267
+ /* @__PURE__ */ jsx(StatusText, {
268
+ tone: "ok",
269
+ status: "FIRED",
270
+ className: "w-24 shrink-0 text-xs"
271
+ }),
272
+ /* @__PURE__ */ jsx("span", {
273
+ className: "shrink-0 font-medium text-foreground",
274
+ children: "Trigger"
275
+ }),
276
+ /* @__PURE__ */ jsx("span", {
277
+ className: "truncate text-xs text-muted-foreground",
278
+ children: triggerLabel(run.triggerKind)
279
+ }),
280
+ !hasPayload ? /* @__PURE__ */ jsx("span", {
281
+ className: "shrink-0 text-[11px] text-muted-foreground",
282
+ children: "No payload"
283
+ }) : null,
284
+ /* @__PURE__ */ jsxs("span", {
285
+ className: "ml-auto flex shrink-0 items-center gap-2",
286
+ children: [/* @__PURE__ */ jsx("span", {
287
+ "aria-hidden": true,
288
+ className: "relative hidden h-1.5 w-40 sm:block",
289
+ children: /* @__PURE__ */ jsx("span", { className: "absolute inset-y-0 left-0 w-1 rounded-full bg-wf-ok" })
290
+ }), /* @__PURE__ */ jsx("span", {
291
+ className: "w-14 text-right text-[11px] tabular-nums text-muted-foreground",
292
+ children: new Date(run.startedAt).toLocaleTimeString([], {
293
+ hour: "2-digit",
294
+ minute: "2-digit",
295
+ second: "2-digit",
296
+ hour12: false
297
+ })
298
+ })]
299
+ })
300
+ ]
301
+ }), open ? /* @__PURE__ */ jsx("div", {
302
+ className: "pb-3 pl-10 pr-3",
303
+ children: /* @__PURE__ */ jsx(DataViewer, {
304
+ label: "Payload",
305
+ value: run.triggerPayload,
306
+ root: "trigger.payload"
307
+ })
308
+ }) : null]
309
+ });
310
+ }
311
+ function RunDetail(props) {
312
+ const { run, names } = props;
313
+ const timeline = runTimeline(run);
314
+ const [rerunning, setRerunning] = useState(false);
315
+ const [rerunError, setRerunError] = useState(null);
316
+ return /* @__PURE__ */ jsxs("div", {
317
+ className: "space-y-3 bg-muted/40 px-4 py-4",
318
+ children: [
319
+ run.error ? /* @__PURE__ */ jsx("p", {
320
+ className: "rounded-md bg-wf-fail/10 px-3 py-2 text-[13px] text-wf-fail",
321
+ children: describeRunError(run.error, names)
322
+ }) : null,
323
+ /* @__PURE__ */ jsxs("div", {
324
+ className: "flex flex-wrap items-center gap-x-5 gap-y-1 text-xs text-muted-foreground",
325
+ children: [
326
+ /* @__PURE__ */ jsxs("span", { children: ["Run ", /* @__PURE__ */ jsx("span", {
327
+ className: "font-mono",
328
+ children: run.id.slice(0, 8)
329
+ })] }),
330
+ /* @__PURE__ */ jsxs("span", { children: ["Started ", formatAbsolute(run.startedAt)] }),
331
+ run.rerunOf ? /* @__PURE__ */ jsxs("span", { children: ["Resumes ", /* @__PURE__ */ jsx("span", {
332
+ className: "font-mono",
333
+ children: run.rerunOf.slice(0, 8)
334
+ })] }) : null,
335
+ run.status === "FAILED" ? /* @__PURE__ */ jsxs(Button, {
336
+ className: "ml-auto",
337
+ disabled: rerunning,
338
+ onClick: () => {
339
+ setRerunning(true);
340
+ setRerunError(null);
341
+ rerunRun(run.id).then((result) => setRerunError(result.error)).catch((error) => setRerunError(error instanceof Error ? error.message : String(error))).finally(() => {
342
+ setRerunning(false);
343
+ props.onChanged();
344
+ });
345
+ },
346
+ children: [/* @__PURE__ */ jsx(Icon, {
347
+ name: "retry",
348
+ className: "h-3.5 w-3.5"
349
+ }), rerunning ? "Rerunning…" : "Rerun from failed step"]
350
+ }) : null,
351
+ rerunError ? /* @__PURE__ */ jsx("span", {
352
+ className: "text-wf-fail",
353
+ children: rerunError
354
+ }) : null
355
+ ]
356
+ }),
357
+ /* @__PURE__ */ jsxs("div", {
358
+ role: "list",
359
+ "aria-label": "Steps of this run",
360
+ className: "overflow-hidden rounded-md border border-solid border-border bg-card",
361
+ children: [
362
+ /* @__PURE__ */ jsx(TriggerRow, { run }),
363
+ run.steps.map((step) => /* @__PURE__ */ jsx(StepRow, {
364
+ step,
365
+ name: names.get(step.stepKey),
366
+ span: timeline.get(step.stepId)
367
+ }, step.stepId + step.stepKey)),
368
+ run.steps.length === 0 ? /* @__PURE__ */ jsx("p", {
369
+ className: "border-t border-solid border-border px-3 py-2 pl-10 text-xs text-muted-foreground",
370
+ children: "No steps ran."
371
+ }) : null
372
+ ]
373
+ })
374
+ ]
375
+ });
376
+ }
377
+ function SortHeader(props) {
378
+ return /* @__PURE__ */ jsx("th", {
379
+ scope: "col",
380
+ className: props.className,
381
+ children: /* @__PURE__ */ jsxs("button", {
382
+ type: "button",
383
+ className: `flex items-center gap-1 hover:text-foreground ${props.active ? "text-foreground" : ""}`,
384
+ onClick: props.onClick,
385
+ children: [props.label, /* @__PURE__ */ jsx("span", {
386
+ "aria-hidden": true,
387
+ className: props.active ? "" : "opacity-0",
388
+ children: props.descending ? "↓" : "↑"
389
+ })]
390
+ })
391
+ });
392
+ }
393
+ function RunsTable(props) {
394
+ const [query, setQuery] = useState("");
395
+ const [status, setStatus] = useState("ALL");
396
+ const [workflow, setWorkflow] = useState("ALL");
397
+ const [trigger, setTrigger] = useState("ALL");
398
+ const [sort, setSort] = useState("startedAt");
399
+ const [descending, setDescending] = useState(true);
400
+ const [expanded, setExpanded] = useState(null);
401
+ const documents = useWorkflowDocumentsInSelectedDrive() ?? [];
402
+ const triggerBlock = new Map(documents.map((document) => [document.header.id, document.state.global.trigger?.blockType]));
403
+ const stepNames = new Map(documents.map((document) => [document.header.id, new Map(document.state.global.steps.map((step) => [step.key, step.name || step.key]))]));
404
+ usePieceLogos();
405
+ const workflowOptions = useMemo(() => [...new Map(props.runs.map((run) => [run.workflowId, run.workflowName]))].map(([id, name]) => ({
406
+ id,
407
+ name
408
+ })).sort((a, b) => a.name.localeCompare(b.name)), [props.runs]);
409
+ const triggerOptions = useMemo(() => [...new Set(props.runs.map((run) => run.triggerKind))].sort(), [props.runs]);
410
+ const scoped = useMemo(() => {
411
+ const needle = query.trim().toLowerCase();
412
+ return props.runs.filter((run) => {
413
+ if (workflow !== "ALL" && run.workflowId !== workflow) return false;
414
+ if (trigger !== "ALL" && run.triggerKind !== trigger) return false;
415
+ if (!needle) return true;
416
+ return run.workflowName.toLowerCase().includes(needle) || run.id.toLowerCase().includes(needle) || (run.error?.toLowerCase().includes(needle) ?? false) || run.steps.some((step) => step.stepKey.toLowerCase().includes(needle));
417
+ });
418
+ }, [
419
+ props.runs,
420
+ query,
421
+ workflow,
422
+ trigger
423
+ ]);
424
+ const counts = useMemo(() => ({
425
+ ALL: scoped.length,
426
+ RUNNING: scoped.filter((run) => run.status === "RUNNING").length,
427
+ SUCCEEDED: scoped.filter((run) => run.status === "SUCCEEDED").length,
428
+ FAILED: scoped.filter((run) => run.status === "FAILED").length
429
+ }), [scoped]);
430
+ const visible = useMemo(() => {
431
+ const rows = scoped.filter((run) => status === "ALL" || run.status === status);
432
+ const direction = descending ? -1 : 1;
433
+ return [...rows].sort((a, b) => {
434
+ if (sort === "duration") return ((durationMs(a.startedAt, a.endedAt) ?? Infinity) - (durationMs(b.startedAt, b.endedAt) ?? Infinity)) * direction;
435
+ return (new Date(a.startedAt).getTime() - new Date(b.startedAt).getTime()) * direction;
436
+ });
437
+ }, [
438
+ scoped,
439
+ status,
440
+ sort,
441
+ descending
442
+ ]);
443
+ const filtered = query.trim() || workflow !== "ALL" || trigger !== "ALL";
444
+ const sortBy = (key) => {
445
+ if (key === sort) {
446
+ setDescending((value) => !value);
447
+ return;
448
+ }
449
+ setSort(key);
450
+ setDescending(true);
451
+ };
452
+ return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
453
+ className: "mb-3 flex flex-wrap items-center gap-2",
454
+ children: [
455
+ /* @__PURE__ */ jsx("div", {
456
+ className: "flex h-8 items-center gap-0.5 rounded-md bg-muted p-0.5",
457
+ children: ["ALL", ...RUN_STATUSES].map((option) => /* @__PURE__ */ jsxs("button", {
458
+ type: "button",
459
+ "aria-pressed": status === option,
460
+ className: `h-7 rounded px-2.5 text-[13px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${status === option ? "bg-card font-medium text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"}`,
461
+ onClick: () => setStatus(option),
462
+ children: [option === "ALL" ? "All" : statusLabel(option), /* @__PURE__ */ jsx("span", {
463
+ className: "ml-1.5 tabular-nums text-muted-foreground",
464
+ children: counts[option]
465
+ })]
466
+ }, option))
467
+ }),
468
+ /* @__PURE__ */ jsx("input", {
469
+ type: "search",
470
+ className: `${CONTROL} w-48`,
471
+ placeholder: "Search runs",
472
+ value: query,
473
+ onChange: (event) => setQuery(event.target.value)
474
+ }),
475
+ props.showWorkflow && workflowOptions.length > 1 ? /* @__PURE__ */ jsx("div", {
476
+ className: "w-44",
477
+ children: /* @__PURE__ */ jsx(Select, {
478
+ value: workflow,
479
+ options: [{
480
+ value: "ALL",
481
+ label: "Every workflow"
482
+ }, ...workflowOptions.map((option) => ({
483
+ value: option.id,
484
+ label: option.name
485
+ }))],
486
+ onChange: setWorkflow
487
+ })
488
+ }) : null,
489
+ triggerOptions.length > 1 ? /* @__PURE__ */ jsx("div", {
490
+ className: "w-40",
491
+ children: /* @__PURE__ */ jsx(Select, {
492
+ value: trigger,
493
+ options: [{
494
+ value: "ALL",
495
+ label: "Every trigger"
496
+ }, ...triggerOptions.map((option) => ({
497
+ value: option,
498
+ label: triggerLabel(option)
499
+ }))],
500
+ onChange: setTrigger
501
+ })
502
+ }) : null,
503
+ filtered ? /* @__PURE__ */ jsx("button", {
504
+ type: "button",
505
+ className: "text-[13px] text-muted-foreground underline underline-offset-2 hover:text-foreground",
506
+ onClick: () => {
507
+ setQuery("");
508
+ setWorkflow("ALL");
509
+ setTrigger("ALL");
510
+ },
511
+ children: "Clear filters"
512
+ }) : null,
513
+ /* @__PURE__ */ jsxs("span", {
514
+ className: "ml-auto text-xs tabular-nums text-muted-foreground",
515
+ children: [
516
+ visible.length,
517
+ " of ",
518
+ props.runs.length,
519
+ " runs"
520
+ ]
521
+ })
522
+ ]
523
+ }), /* @__PURE__ */ jsx("div", {
524
+ className: "overflow-x-auto rounded-lg border border-solid border-border bg-card",
525
+ children: /* @__PURE__ */ jsxs("table", {
526
+ className: "w-full border-collapse text-left",
527
+ children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", {
528
+ className: "border-b border-solid border-border text-xs font-medium text-muted-foreground",
529
+ children: [
530
+ /* @__PURE__ */ jsx("th", {
531
+ scope: "col",
532
+ className: "px-3 py-2.5 font-medium",
533
+ children: "Status"
534
+ }),
535
+ props.showWorkflow ? /* @__PURE__ */ jsx("th", {
536
+ scope: "col",
537
+ className: "px-3 py-2.5 font-medium",
538
+ children: "Workflow"
539
+ }) : null,
540
+ /* @__PURE__ */ jsx("th", {
541
+ scope: "col",
542
+ className: "px-3 py-2.5 font-medium",
543
+ children: "Trigger"
544
+ }),
545
+ /* @__PURE__ */ jsx(SortHeader, {
546
+ label: "Started",
547
+ className: "px-3 py-2.5 font-medium",
548
+ active: sort === "startedAt",
549
+ descending,
550
+ onClick: () => sortBy("startedAt")
551
+ }),
552
+ /* @__PURE__ */ jsx(SortHeader, {
553
+ label: "Duration",
554
+ className: "px-3 py-2.5 font-medium",
555
+ active: sort === "duration",
556
+ descending,
557
+ onClick: () => sortBy("duration")
558
+ }),
559
+ /* @__PURE__ */ jsx("th", {
560
+ scope: "col",
561
+ className: "px-3 py-2.5 font-medium",
562
+ children: "Steps"
563
+ }),
564
+ /* @__PURE__ */ jsx("th", {
565
+ scope: "col",
566
+ className: "w-8 px-3 py-2",
567
+ children: /* @__PURE__ */ jsx("span", {
568
+ className: "sr-only",
569
+ children: "Details"
570
+ })
571
+ })
572
+ ]
573
+ }) }), /* @__PURE__ */ jsx("tbody", { children: visible.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", {
574
+ colSpan: props.showWorkflow ? 7 : 6,
575
+ className: "px-3 py-8 text-center text-[13px] text-muted-foreground",
576
+ children: "No runs match these filters."
577
+ }) }) : visible.map((run) => {
578
+ const open = expanded === run.id;
579
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("tr", {
580
+ className: `cursor-pointer border-b border-solid border-border text-[13px] last:border-b-0 ${open ? "bg-muted/40" : "hover:bg-accent/60"}`,
581
+ onClick: () => setExpanded(open ? null : run.id),
582
+ children: [
583
+ /* @__PURE__ */ jsx("td", {
584
+ className: "px-3 py-2.5",
585
+ children: /* @__PURE__ */ jsx(StatusText, {
586
+ tone: toneOf(RUN_TONE, run.status),
587
+ status: run.status
588
+ })
589
+ }),
590
+ props.showWorkflow ? /* @__PURE__ */ jsx("td", {
591
+ className: "max-w-48 truncate px-3 py-2.5 font-medium text-foreground",
592
+ children: run.workflowName
593
+ }) : null,
594
+ /* @__PURE__ */ jsxs("td", {
595
+ className: "px-3 py-2.5 text-muted-foreground",
596
+ children: [triggerLabel(run.triggerKind), /* @__PURE__ */ jsxs("span", {
597
+ className: "ml-1.5 text-xs text-muted-foreground/70",
598
+ children: ["v", run.workflowVersion]
599
+ })]
600
+ }),
601
+ /* @__PURE__ */ jsx("td", {
602
+ className: "whitespace-nowrap px-3 py-2.5 tabular-nums text-muted-foreground",
603
+ title: formatAbsolute(run.startedAt),
604
+ children: formatWhen(run.startedAt)
605
+ }),
606
+ /* @__PURE__ */ jsx("td", {
607
+ className: "whitespace-nowrap px-3 py-2.5 tabular-nums text-muted-foreground",
608
+ children: formatDuration(run.startedAt, run.endedAt)
609
+ }),
610
+ /* @__PURE__ */ jsx("td", {
611
+ className: "px-3 py-2",
612
+ children: /* @__PURE__ */ jsx(MiniChain, { links: runLinks(run, triggerBlock.get(run.workflowId)) })
613
+ }),
614
+ /* @__PURE__ */ jsx("td", {
615
+ className: "px-3 py-2.5",
616
+ children: /* @__PURE__ */ jsx("button", {
617
+ type: "button",
618
+ "aria-expanded": open,
619
+ "aria-label": `${open ? "Hide" : "Show"} steps of the run started ${formatAbsolute(run.startedAt)}`,
620
+ className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
621
+ onClick: (event) => {
622
+ event.stopPropagation();
623
+ setExpanded(open ? null : run.id);
624
+ },
625
+ children: /* @__PURE__ */ jsx(Icon, {
626
+ name: "chevron",
627
+ className: `h-3.5 w-3.5 transition-transform ${open ? "rotate-90" : ""}`
628
+ })
629
+ })
630
+ })
631
+ ]
632
+ }), open ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", {
633
+ colSpan: props.showWorkflow ? 7 : 6,
634
+ className: "border-b border-solid border-border p-0",
635
+ children: /* @__PURE__ */ jsx(RunDetail, {
636
+ run,
637
+ names: stepNames.get(run.workflowId) ?? /* @__PURE__ */ new Map(),
638
+ onChanged: props.onChanged
639
+ })
640
+ }) }) : null] }, run.id);
641
+ }) })]
642
+ })
643
+ })] });
644
+ }
645
+ //#endregion
646
+ //#region editors/workflow-studio/components/RunsView.tsx
647
+ function RunsView(props) {
648
+ const [firing, setFiring] = useState(false);
649
+ const [fireError, setFireError] = useState(null);
650
+ const { runs } = props;
651
+ return /* @__PURE__ */ jsxs("div", {
652
+ className: "w-full",
653
+ children: [
654
+ /* @__PURE__ */ jsxs("div", {
655
+ className: "mb-4 flex items-center gap-3",
656
+ children: [
657
+ /* @__PURE__ */ jsx("h2", {
658
+ className: "text-[15px] font-semibold text-foreground",
659
+ children: props.title
660
+ }),
661
+ /* @__PURE__ */ jsx("span", { className: "grow" }),
662
+ props.onFire ? /* @__PURE__ */ jsxs(Button, {
663
+ variant: "primary",
664
+ disabled: firing,
665
+ onClick: () => {
666
+ setFiring(true);
667
+ setFireError(null);
668
+ props.onFire().then((fireResultError) => setFireError(fireResultError)).catch((fireCallError) => setFireError(fireCallError instanceof Error ? fireCallError.message : String(fireCallError))).finally(() => {
669
+ setFiring(false);
670
+ props.reload();
671
+ });
672
+ },
673
+ children: [/* @__PURE__ */ jsx(Icon, {
674
+ name: "play",
675
+ className: "h-3.5 w-3.5"
676
+ }), firing ? "Running…" : "Run now"]
677
+ }) : null
678
+ ]
679
+ }),
680
+ fireError ? /* @__PURE__ */ jsx("p", {
681
+ className: "mb-3 rounded-md bg-wf-fail/10 px-3 py-2 text-[13px] text-wf-fail",
682
+ children: fireError
683
+ }) : null,
684
+ props.error ? /* @__PURE__ */ jsxs("p", {
685
+ className: "rounded-md bg-wf-warn/10 px-3 py-2 text-[13px] text-wf-warn",
686
+ children: ["Runs can't be listed because the workflow runtime is unreachable.", /* @__PURE__ */ jsx("span", {
687
+ className: "mt-0.5 block text-xs opacity-80",
688
+ children: props.error
689
+ })]
690
+ }) : runs === null ? /* @__PURE__ */ jsx("p", {
691
+ className: "text-[13px] text-muted-foreground",
692
+ children: "Loading runs…"
693
+ }) : runs.length === 0 ? /* @__PURE__ */ jsxs("div", {
694
+ className: "rounded-lg border border-dashed border-border px-4 py-10 text-center",
695
+ children: [/* @__PURE__ */ jsx("p", {
696
+ className: "text-[13px] font-medium text-foreground",
697
+ children: "No runs yet"
698
+ }), /* @__PURE__ */ jsx("p", {
699
+ className: "mt-1 text-xs text-muted-foreground",
700
+ children: props.onFire ? "Use Run now to record the first one." : "Runs appear here once the trigger fires."
701
+ })]
702
+ }) : /* @__PURE__ */ jsx(RunsTable, {
703
+ runs,
704
+ showWorkflow: props.showWorkflow,
705
+ onChanged: props.reload
706
+ })
707
+ ]
708
+ });
709
+ }
710
+ //#endregion
711
+ //#region editors/workflow-studio/components/Sidebar.tsx
712
+ const WORKFLOW_TYPE$2 = "powerhouse/workflow";
713
+ function documentName(document, fallback) {
714
+ return (document?.state?.global)?.name || fallback || "(unnamed)";
715
+ }
716
+ function documentStatus(document) {
717
+ return (document?.state?.global)?.status;
718
+ }
719
+ function Row(props) {
720
+ return /* @__PURE__ */ jsxs("div", {
721
+ className: `group mx-2 flex items-center rounded-md ${props.active ? "bg-accent" : "hover:bg-accent/60"}`,
722
+ children: [/* @__PURE__ */ jsx("button", {
723
+ type: "button",
724
+ "aria-current": props.active ? "true" : void 0,
725
+ className: `flex min-w-0 grow items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-[13px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${props.active ? "font-medium text-foreground" : "text-foreground/80"}`,
726
+ onClick: props.onClick,
727
+ children: props.children
728
+ }), props.trailing]
729
+ });
730
+ }
731
+ const ROW_ACTION = "flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground opacity-0 hover:bg-background hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100";
732
+ const DELETE_ACTION = `${ROW_ACTION} hover:text-wf-fail`;
733
+ function DeleteButton(props) {
734
+ return /* @__PURE__ */ jsx("button", {
735
+ type: "button",
736
+ title: "Delete",
737
+ "aria-label": `Delete ${props.label}`,
738
+ className: DELETE_ACTION,
739
+ onClick: () => showDeleteNodeModal(props.node),
740
+ children: /* @__PURE__ */ jsx(Icon, {
741
+ name: "trash",
742
+ className: "h-3.5 w-3.5"
743
+ })
744
+ });
745
+ }
746
+ function NodeRow(props) {
747
+ const { node } = props;
748
+ const { data: document, error } = useDocumentSafe(node.id);
749
+ useEffect(() => {
750
+ if (error !== void 0) console.error(`Failed to load document ${node.id}:`, error);
751
+ }, [error, node.id]);
752
+ if (error !== void 0) return /* @__PURE__ */ jsxs(Row, {
753
+ active: props.active,
754
+ onClick: props.onOpen,
755
+ trailing: /* @__PURE__ */ jsx("span", {
756
+ className: "mr-1.5 flex shrink-0 items-center",
757
+ children: /* @__PURE__ */ jsx(DeleteButton, {
758
+ node,
759
+ label: node.name || node.id
760
+ })
761
+ }),
762
+ children: [/* @__PURE__ */ jsx("span", {
763
+ className: "shrink-0 text-xs text-wf-fail",
764
+ title: `Could not load ${node.id}: ${errorMessage(error)}`,
765
+ "aria-hidden": true,
766
+ children: "⚠"
767
+ }), /* @__PURE__ */ jsx("span", {
768
+ className: "min-w-0 truncate text-wf-fail",
769
+ children: node.name || "(unnamed)"
770
+ })]
771
+ });
772
+ const status = documentStatus(document);
773
+ const { tone, label } = node.documentType === WORKFLOW_TYPE$2 ? workflowHealth(status, props.lastRunStatus) : {
774
+ tone: toneOf(CONNECTION_TONE, status),
775
+ label: status
776
+ };
777
+ return /* @__PURE__ */ jsxs(Row, {
778
+ active: props.active,
779
+ onClick: props.onOpen,
780
+ trailing: /* @__PURE__ */ jsxs("span", {
781
+ className: "mr-1.5 flex shrink-0 items-center",
782
+ children: [props.onEdit ? /* @__PURE__ */ jsx("button", {
783
+ type: "button",
784
+ title: "Open in editor",
785
+ "aria-label": `Open ${documentName(document, node.name)} in the editor`,
786
+ className: ROW_ACTION,
787
+ onClick: props.onEdit,
788
+ children: /* @__PURE__ */ jsx(Icon, {
789
+ name: "pencil",
790
+ className: "h-3.5 w-3.5"
791
+ })
792
+ }) : null, /* @__PURE__ */ jsx(DeleteButton, {
793
+ node,
794
+ label: documentName(document, node.name)
795
+ })]
796
+ }),
797
+ children: [/* @__PURE__ */ jsx("span", {
798
+ title: label,
799
+ className: "flex",
800
+ children: /* @__PURE__ */ jsx(StatusDot, { tone })
801
+ }), /* @__PURE__ */ jsx("span", {
802
+ className: "min-w-0 truncate",
803
+ children: documentName(document, node.name)
804
+ })]
805
+ });
806
+ }
807
+ function Section(props) {
808
+ return /* @__PURE__ */ jsxs("div", {
809
+ className: "mt-5",
810
+ children: [/* @__PURE__ */ jsxs("div", {
811
+ className: "mb-1 flex items-center justify-between pl-4 pr-3",
812
+ children: [/* @__PURE__ */ jsx("h3", {
813
+ className: "text-xs font-medium text-muted-foreground",
814
+ children: props.title
815
+ }), /* @__PURE__ */ jsx("button", {
816
+ type: "button",
817
+ disabled: props.creating,
818
+ className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",
819
+ title: props.addLabel,
820
+ "aria-label": props.addLabel,
821
+ onClick: props.onCreate,
822
+ children: /* @__PURE__ */ jsx(Icon, {
823
+ name: "plus",
824
+ className: "h-3.5 w-3.5"
825
+ })
826
+ })]
827
+ }), props.nodes.length === 0 ? /* @__PURE__ */ jsx("p", {
828
+ className: "px-4 py-1 text-xs text-muted-foreground",
829
+ children: props.empty
830
+ }) : /* @__PURE__ */ jsx("div", {
831
+ className: "flex flex-col gap-0.5",
832
+ children: props.nodes.map((node) => /* @__PURE__ */ jsx(NodeRow, {
833
+ node,
834
+ lastRunStatus: props.lastRuns?.get(node.id),
835
+ active: props.activeId === node.id,
836
+ onOpen: () => props.onOpen(node),
837
+ onEdit: props.onEdit ? () => props.onEdit(node) : void 0
838
+ }, node.id))
839
+ })]
840
+ });
841
+ }
842
+ function Sidebar(props) {
843
+ return /* @__PURE__ */ jsxs("aside", {
844
+ className: "w-60 shrink-0 overflow-y-auto border-r border-solid border-border bg-muted/50 py-3",
845
+ children: [
846
+ /* @__PURE__ */ jsxs(Row, {
847
+ active: props.allRunsActive,
848
+ onClick: props.onShowAllRuns,
849
+ children: [/* @__PURE__ */ jsx(Icon, {
850
+ name: "list",
851
+ className: "text-muted-foreground"
852
+ }), /* @__PURE__ */ jsx("span", { children: "Overview" })]
853
+ }),
854
+ /* @__PURE__ */ jsx(Section, {
855
+ title: "Workflows",
856
+ addLabel: "New workflow",
857
+ empty: "No workflows yet.",
858
+ nodes: props.workflows,
859
+ lastRuns: props.lastRuns,
860
+ activeId: props.activeId,
861
+ onOpen: props.onOpenWorkflow,
862
+ onEdit: props.onEditWorkflow,
863
+ onCreate: props.onCreateWorkflow,
864
+ creating: props.creating
865
+ }),
866
+ /* @__PURE__ */ jsx(Section, {
867
+ title: "Connections",
868
+ addLabel: "New connection",
869
+ empty: "No connections yet.",
870
+ nodes: props.connections,
871
+ activeId: props.activeId,
872
+ onOpen: props.onOpenConnection,
873
+ onCreate: props.onCreateConnection,
874
+ creating: props.creating
875
+ })
876
+ ]
877
+ });
878
+ }
879
+ //#endregion
880
+ //#region editors/workflow-studio/components/use-hash-selection.ts
881
+ function readHash() {
882
+ return window.location.hash.replace(/^#/, "") || void 0;
883
+ }
884
+ function useHashSelection() {
885
+ const [selected, setSelected] = useState(readHash);
886
+ useEffect(() => {
887
+ const sync = () => setSelected(readHash());
888
+ window.addEventListener("hashchange", sync);
889
+ window.addEventListener("popstate", sync);
890
+ return () => {
891
+ window.removeEventListener("hashchange", sync);
892
+ window.removeEventListener("popstate", sync);
893
+ };
894
+ }, []);
895
+ return [selected, useCallback((id) => {
896
+ setSelected(id);
897
+ const url = new URL(window.location.href);
898
+ url.hash = id ?? "";
899
+ window.history.replaceState(null, "", url);
900
+ }, [])];
901
+ }
902
+ //#endregion
903
+ //#region editors/workflow-studio/components/useRuns.ts
904
+ const POLL_MS = 5e3;
905
+ function useRuns(scope, active = true) {
906
+ const { workflowId, driveId, limit } = scope;
907
+ const [runs, setRuns] = useState(null);
908
+ const [error, setError] = useState(null);
909
+ const load = useRef(() => void 0);
910
+ useEffect(() => {
911
+ if (!active) return;
912
+ let cancelled = false;
913
+ const run = () => {
914
+ fetchRuns({
915
+ workflowId,
916
+ driveId,
917
+ limit
918
+ }).then((result) => {
919
+ if (cancelled) return;
920
+ setRuns(result);
921
+ setError(null);
922
+ }, (loadError) => {
923
+ if (cancelled) return;
924
+ setError(loadError instanceof Error ? loadError.message : String(loadError));
925
+ });
926
+ };
927
+ load.current = run;
928
+ setRuns(null);
929
+ run();
930
+ const timer = setInterval(run, POLL_MS);
931
+ return () => {
932
+ cancelled = true;
933
+ clearInterval(timer);
934
+ };
935
+ }, [
936
+ workflowId,
937
+ driveId,
938
+ limit,
939
+ active
940
+ ]);
941
+ return {
942
+ runs,
943
+ error,
944
+ reload: useCallback(() => load.current(), [])
945
+ };
946
+ }
947
+ //#endregion
948
+ //#region editors/workflow-studio/components/step-outline.ts
949
+ function stepOutline(args) {
950
+ const stepById = new Map(args.steps.map((step) => [step.id, step]));
951
+ const outgoing = /* @__PURE__ */ new Map();
952
+ for (const edge of args.edges) {
953
+ if (!stepById.has(edge.to)) continue;
954
+ const list = outgoing.get(edge.from) ?? [];
955
+ list.push(edge);
956
+ outgoing.set(edge.from, list);
957
+ }
958
+ for (const list of outgoing.values()) list.sort((a, b) => portRank(a.port) - portRank(b.port));
959
+ const rows = [];
960
+ const seen = /* @__PURE__ */ new Set();
961
+ const walk = (fromId, port) => {
962
+ const step = stepById.get(fromId);
963
+ if (step) {
964
+ if (seen.has(fromId)) return;
965
+ seen.add(fromId);
966
+ rows.push({
967
+ step,
968
+ port: port === "next" ? null : port
969
+ });
970
+ }
971
+ for (const edge of outgoing.get(fromId) ?? []) walk(edge.to, edge.port);
972
+ };
973
+ if (args.triggerId) walk(args.triggerId, null);
974
+ return {
975
+ rows,
976
+ orphans: args.steps.filter((step) => !seen.has(step.id))
977
+ };
978
+ }
979
+ //#endregion
980
+ //#region editors/workflow-studio/components/WorkflowBoard.tsx
981
+ function summary(rows) {
982
+ const count = `${rows.length} ${rows.length === 1 ? "workflow" : "workflows"}`;
983
+ const failing = rows.filter((row) => row.runs[0]?.status === "FAILED").length;
984
+ const parts = [count, `${rows.filter((row) => row.status === "ENABLED").length} enabled`];
985
+ if (failing > 0) parts.push(`${failing} failed on the last run`);
986
+ return parts.join(", ");
987
+ }
988
+ function WorkflowBoard(props) {
989
+ usePieceLogos();
990
+ const documents = useWorkflowDocumentsInSelectedDrive() ?? [];
991
+ const runs = props.runs ?? [];
992
+ const rows = documents.map((document) => {
993
+ const state = document.state.global;
994
+ const workflowRuns = runs.filter((run) => run.workflowId === document.header.id);
995
+ const latest = workflowRuns.at(0);
996
+ const statusByKey = new Map((latest?.steps ?? []).map((step) => [step.stepKey, step.status]));
997
+ const outline = stepOutline({
998
+ triggerId: state.trigger?.id,
999
+ steps: state.steps,
1000
+ edges: state.edges
1001
+ });
1002
+ const links = [...state.trigger ? [{
1003
+ id: state.trigger.id,
1004
+ blockType: state.trigger.blockType,
1005
+ label: "Trigger",
1006
+ status: latest ? "SUCCEEDED" : void 0
1007
+ }] : [], ...outline.rows.map((row) => ({
1008
+ id: row.step.id,
1009
+ blockType: row.step.blockType,
1010
+ label: row.step.name || row.step.key,
1011
+ status: statusByKey.get(row.step.key)
1012
+ }))];
1013
+ return {
1014
+ id: document.header.id,
1015
+ name: state.name || document.header.name || "Untitled workflow",
1016
+ status: state.status,
1017
+ trigger: describeTrigger(state.trigger),
1018
+ links,
1019
+ runs: workflowRuns
1020
+ };
1021
+ }).sort((a, b) => {
1022
+ const at = a.runs[0]?.startedAt ?? "";
1023
+ const bt = b.runs[0]?.startedAt ?? "";
1024
+ if (at !== bt) return bt.localeCompare(at);
1025
+ return a.name.localeCompare(b.name);
1026
+ });
1027
+ return /* @__PURE__ */ jsxs("section", {
1028
+ className: "mb-10",
1029
+ children: [/* @__PURE__ */ jsxs("div", {
1030
+ className: "mb-4 flex flex-wrap items-end justify-between gap-3",
1031
+ children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h2", {
1032
+ className: "text-2xl font-semibold tracking-tight text-foreground",
1033
+ children: "Workflows"
1034
+ }), /* @__PURE__ */ jsx("p", {
1035
+ className: "mt-1 text-[13px] text-muted-foreground",
1036
+ children: rows.length === 0 ? "Automations in this drive" : summary(rows)
1037
+ })] }), /* @__PURE__ */ jsxs(Button, {
1038
+ variant: "primary",
1039
+ disabled: props.creating,
1040
+ onClick: props.onCreate,
1041
+ children: [/* @__PURE__ */ jsx(Icon, {
1042
+ name: "plus",
1043
+ className: "h-3.5 w-3.5"
1044
+ }), "New workflow"]
1045
+ })]
1046
+ }), rows.length === 0 ? /* @__PURE__ */ jsxs("div", {
1047
+ className: "rounded-xl border border-dashed border-foreground/15 px-6 py-12 text-center",
1048
+ children: [/* @__PURE__ */ jsx("p", {
1049
+ className: "text-[15px] font-medium text-foreground",
1050
+ children: "No workflows yet"
1051
+ }), /* @__PURE__ */ jsx("p", {
1052
+ className: "mx-auto mt-1 max-w-sm text-[13px] text-muted-foreground",
1053
+ children: "A workflow starts on a trigger, like a schedule or a webhook, and runs a chain of steps across your services."
1054
+ })]
1055
+ }) : /* @__PURE__ */ jsx("ul", {
1056
+ "aria-label": "Workflows",
1057
+ className: "overflow-hidden rounded-xl border border-solid border-foreground/10 bg-card",
1058
+ children: rows.map((row) => {
1059
+ const latest = row.runs.at(0);
1060
+ const latestTone = toneOf(RUN_TONE, latest?.status);
1061
+ const health = workflowHealth(row.status, latest?.status);
1062
+ return /* @__PURE__ */ jsx("li", {
1063
+ className: "border-b border-solid border-foreground/10 last:border-b-0",
1064
+ children: /* @__PURE__ */ jsxs("button", {
1065
+ type: "button",
1066
+ className: "grid w-full grid-cols-[minmax(0,1fr)_auto] items-center gap-x-6 gap-y-3 px-5 py-4 text-left transition-colors hover:bg-accent/50 focus-visible:bg-accent/50 focus-visible:outline-none md:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)_minmax(0,0.8fr)_auto]",
1067
+ onClick: () => props.onOpen(row.id),
1068
+ children: [
1069
+ /* @__PURE__ */ jsxs("span", {
1070
+ className: "min-w-0",
1071
+ children: [/* @__PURE__ */ jsxs("span", {
1072
+ className: "flex items-center gap-2",
1073
+ children: [
1074
+ /* @__PURE__ */ jsx("span", {
1075
+ title: health.label,
1076
+ className: "flex",
1077
+ children: /* @__PURE__ */ jsx(StatusDot, { tone: health.tone })
1078
+ }),
1079
+ /* @__PURE__ */ jsx("span", {
1080
+ className: "truncate text-[15px] font-semibold text-foreground",
1081
+ children: row.name
1082
+ }),
1083
+ row.status !== "ENABLED" ? /* @__PURE__ */ jsx("span", {
1084
+ className: "shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground",
1085
+ children: statusLabel(row.status)
1086
+ }) : null
1087
+ ]
1088
+ }), /* @__PURE__ */ jsx("span", {
1089
+ className: "mt-0.5 block truncate pl-4 text-[13px] text-muted-foreground",
1090
+ children: row.trigger
1091
+ })]
1092
+ }),
1093
+ /* @__PURE__ */ jsx("span", {
1094
+ className: "hidden md:block",
1095
+ children: /* @__PURE__ */ jsx(MiniChain, { links: row.links })
1096
+ }),
1097
+ /* @__PURE__ */ jsx("span", {
1098
+ className: "hidden text-[13px] md:block",
1099
+ title: latest ? formatAbsolute(latest.startedAt) : void 0,
1100
+ children: latest ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
1101
+ className: `font-medium ${latestTone === "fail" ? "text-wf-fail" : latestTone === "ok" ? "text-wf-ok" : "text-foreground"}`,
1102
+ children: statusLabel(latest.status)
1103
+ }), /* @__PURE__ */ jsx("span", {
1104
+ className: "block text-xs text-muted-foreground",
1105
+ children: formatWhen(latest.startedAt)
1106
+ })] }) : /* @__PURE__ */ jsx("span", {
1107
+ className: "text-muted-foreground",
1108
+ children: "Not run yet"
1109
+ })
1110
+ }),
1111
+ /* @__PURE__ */ jsx(RunStrip, { runs: row.runs })
1112
+ ]
1113
+ })
1114
+ }, row.id);
1115
+ })
1116
+ })]
1117
+ });
1118
+ }
1119
+ //#endregion
1120
+ //#region editors/workflow-studio/components/WorkflowSteps.tsx
1121
+ const RAIL = {
1122
+ ok: "bg-wf-ok",
1123
+ fail: "bg-wf-fail",
1124
+ warn: "bg-wf-warn",
1125
+ run: "bg-wf-run",
1126
+ idle: "bg-border"
1127
+ };
1128
+ const RING = {
1129
+ ok: "ring-wf-ok",
1130
+ fail: "ring-wf-fail",
1131
+ warn: "ring-wf-warn",
1132
+ run: "ring-wf-run",
1133
+ idle: "ring-border"
1134
+ };
1135
+ function TrackStop(props) {
1136
+ const { stop } = props;
1137
+ const tone = stop.status ? toneOf(STEP_TONE, stop.status) : "idle";
1138
+ return /* @__PURE__ */ jsxs("li", {
1139
+ className: "relative flex w-40 shrink-0 flex-col items-center",
1140
+ children: [
1141
+ /* @__PURE__ */ jsx("span", {
1142
+ "aria-hidden": true,
1143
+ className: `absolute left-0 top-[19px] h-0.5 w-1/2 ${props.first ? "invisible" : RAIL[props.inbound]}`
1144
+ }),
1145
+ /* @__PURE__ */ jsx("span", {
1146
+ "aria-hidden": true,
1147
+ className: `absolute right-0 top-[19px] h-0.5 w-1/2 ${props.last ? "invisible" : RAIL[props.outbound]}`
1148
+ }),
1149
+ stop.port ? /* @__PURE__ */ jsx("span", {
1150
+ className: "absolute -left-4 top-0 rounded bg-background px-1 text-[11px] text-muted-foreground",
1151
+ children: stop.port
1152
+ }) : null,
1153
+ /* @__PURE__ */ jsx("button", {
1154
+ type: "button",
1155
+ title: stop.status ? `${stop.title}: ${stop.status.toLowerCase()}` : stop.title,
1156
+ "aria-label": `${stop.title}: ${stop.status ? stop.status.toLowerCase() : "not run"}`,
1157
+ className: `relative z-10 flex h-10 w-10 items-center justify-center rounded-full bg-card ring-2 transition-shadow dark:bg-white hover:ring-4 focus-visible:outline-none focus-visible:ring-4 ${RING[tone]}`,
1158
+ onClick: props.onClick,
1159
+ children: /* @__PURE__ */ jsx(BlockLogo, {
1160
+ bare: true,
1161
+ blockType: stop.blockType,
1162
+ size: 20
1163
+ })
1164
+ }),
1165
+ /* @__PURE__ */ jsx("span", {
1166
+ className: "mt-2 max-w-full truncate px-2 text-[13px] font-medium text-foreground",
1167
+ children: stop.title
1168
+ }),
1169
+ /* @__PURE__ */ jsx("span", {
1170
+ className: "max-w-full truncate px-2 text-xs text-muted-foreground",
1171
+ title: stop.subtitle,
1172
+ children: stop.subtitle
1173
+ })
1174
+ ]
1175
+ });
1176
+ }
1177
+ function Track(props) {
1178
+ const tones = props.stops.map((stop) => stop.status ? toneOf(STEP_TONE, stop.status) : "idle");
1179
+ return /* @__PURE__ */ jsx("ol", {
1180
+ className: "-mx-6 flex overflow-x-auto px-6 py-1.5",
1181
+ children: props.stops.map((stop, index) => /* @__PURE__ */ jsx(TrackStop, {
1182
+ stop,
1183
+ first: index === 0,
1184
+ last: index === props.stops.length - 1,
1185
+ inbound: tones[index],
1186
+ outbound: tones[index + 1] ?? "idle",
1187
+ onClick: props.onOpenEditor
1188
+ }, stop.id))
1189
+ });
1190
+ }
1191
+ function WorkflowSteps(props) {
1192
+ const { state } = props;
1193
+ usePieceLogos();
1194
+ const outline = stepOutline({
1195
+ triggerId: state.trigger?.id,
1196
+ steps: state.steps,
1197
+ edges: state.edges
1198
+ });
1199
+ const statusByKey = new Map((props.latestRun?.steps ?? []).map((step) => [step.stepKey, step.status]));
1200
+ const stopFor = (step, port) => {
1201
+ const meta = blockMeta(step.blockType);
1202
+ return {
1203
+ id: step.id,
1204
+ title: step.name || step.key,
1205
+ subtitle: meta.displayName,
1206
+ blockType: step.blockType,
1207
+ status: statusByKey.get(step.key),
1208
+ port
1209
+ };
1210
+ };
1211
+ if (!state.trigger && state.steps.length === 0) return /* @__PURE__ */ jsx("section", {
1212
+ className: "mt-8 border-t border-solid border-border pt-6",
1213
+ children: /* @__PURE__ */ jsxs("p", {
1214
+ className: "text-[13px] text-muted-foreground",
1215
+ children: [
1216
+ "This workflow has no trigger or steps yet.",
1217
+ " ",
1218
+ /* @__PURE__ */ jsx("button", {
1219
+ type: "button",
1220
+ className: "font-medium text-foreground underline underline-offset-2",
1221
+ onClick: props.onOpenEditor,
1222
+ children: "Open the editor"
1223
+ }),
1224
+ " ",
1225
+ "to build it."
1226
+ ]
1227
+ })
1228
+ });
1229
+ const triggerMeta = state.trigger ? blockMeta(state.trigger.blockType) : null;
1230
+ const stops = [...state.trigger && triggerMeta ? [{
1231
+ id: state.trigger.id,
1232
+ title: triggerMeta.displayName,
1233
+ subtitle: "Trigger",
1234
+ blockType: state.trigger.blockType,
1235
+ status: props.latestRun ? "SUCCEEDED" : void 0
1236
+ }] : [], ...outline.rows.map((row) => stopFor(row.step, row.port))];
1237
+ return /* @__PURE__ */ jsxs("section", {
1238
+ className: "mt-8 border-t border-solid border-border pt-6",
1239
+ children: [
1240
+ /* @__PURE__ */ jsxs("div", {
1241
+ className: "mb-4 flex items-baseline gap-2",
1242
+ children: [/* @__PURE__ */ jsx("h3", {
1243
+ className: "text-[13px] font-medium text-foreground",
1244
+ children: "Steps"
1245
+ }), /* @__PURE__ */ jsx("span", {
1246
+ className: "text-xs text-muted-foreground",
1247
+ children: props.latestRun ? "Coloured by the latest run" : "Not run yet"
1248
+ })]
1249
+ }),
1250
+ !state.trigger ? /* @__PURE__ */ jsx("p", {
1251
+ className: "mb-3 text-xs text-wf-warn",
1252
+ children: "No trigger set, so this workflow never starts on its own."
1253
+ }) : null,
1254
+ /* @__PURE__ */ jsx(Track, {
1255
+ stops,
1256
+ onOpenEditor: props.onOpenEditor
1257
+ }),
1258
+ outline.orphans.length > 0 ? /* @__PURE__ */ jsxs("div", {
1259
+ className: "mt-5",
1260
+ children: [/* @__PURE__ */ jsx("p", {
1261
+ className: "mb-3 text-xs text-muted-foreground",
1262
+ children: "Not connected to the trigger, so runs never reach these:"
1263
+ }), /* @__PURE__ */ jsx("ol", {
1264
+ className: "-mx-6 flex overflow-x-auto px-6 py-1.5 opacity-60",
1265
+ children: outline.orphans.map((step) => /* @__PURE__ */ jsx(TrackStop, {
1266
+ stop: stopFor(step, null),
1267
+ first: true,
1268
+ last: true,
1269
+ inbound: "idle",
1270
+ outbound: "idle",
1271
+ onClick: props.onOpenEditor
1272
+ }, step.id))
1273
+ })]
1274
+ }) : null
1275
+ ]
1276
+ });
1277
+ }
1278
+ //#endregion
1279
+ //#region editors/workflow-studio/components/WorkflowHeader.tsx
1280
+ const WORKFLOW_TYPE$1 = "powerhouse/workflow";
1281
+ function WorkflowHeader(props) {
1282
+ const workflowId = props.node.id;
1283
+ const { data: document, error, reload } = useDocumentSafe(workflowId);
1284
+ const [, dispatch] = useDispatch(document);
1285
+ if (error !== void 0) return /* @__PURE__ */ jsx(DocumentLoadError, {
1286
+ title: "This workflow could not be loaded",
1287
+ documentId: workflowId,
1288
+ error,
1289
+ onRetry: () => {
1290
+ reload();
1291
+ }
1292
+ });
1293
+ if (document?.header.documentType !== WORKFLOW_TYPE$1) return null;
1294
+ const state = document.state.global;
1295
+ const enabled = state.status === "ENABLED";
1296
+ const stats = runStats(props.runs ?? []);
1297
+ const lastTone = toneOf(RUN_TONE, stats.lastRun?.status);
1298
+ const statusTone = toneOf(WORKFLOW_TONE, state.status);
1299
+ return /* @__PURE__ */ jsxs("header", {
1300
+ className: "mb-8",
1301
+ children: [
1302
+ /* @__PURE__ */ jsxs("div", {
1303
+ className: "flex flex-wrap items-start gap-3",
1304
+ children: [/* @__PURE__ */ jsxs("div", {
1305
+ className: "min-w-0 grow",
1306
+ children: [/* @__PURE__ */ jsxs("div", {
1307
+ className: "flex items-center gap-2.5",
1308
+ children: [/* @__PURE__ */ jsx("h2", {
1309
+ className: "min-w-0 truncate text-xl font-semibold tracking-tight text-foreground",
1310
+ children: state.name || props.node.name || "Untitled workflow"
1311
+ }), /* @__PURE__ */ jsx("span", {
1312
+ className: `rounded-full px-2 py-0.5 text-xs font-medium ${TONE_BADGE[statusTone]}`,
1313
+ children: statusLabel(state.status)
1314
+ })]
1315
+ }), state.description ? /* @__PURE__ */ jsx("p", {
1316
+ className: "mt-1 max-w-prose text-[13px] text-muted-foreground",
1317
+ children: state.description
1318
+ }) : null]
1319
+ }), /* @__PURE__ */ jsxs("div", {
1320
+ className: "flex items-center gap-2",
1321
+ children: [
1322
+ /* @__PURE__ */ jsx(Button, {
1323
+ variant: "danger",
1324
+ onClick: () => showDeleteNodeModal(props.node),
1325
+ children: "Delete"
1326
+ }),
1327
+ /* @__PURE__ */ jsx(Button, {
1328
+ onClick: () => dispatch(actions.setWorkflowStatus({ status: enabled ? "DISABLED" : "ENABLED" })),
1329
+ children: enabled ? "Disable" : "Enable"
1330
+ }),
1331
+ /* @__PURE__ */ jsx(Button, {
1332
+ variant: "primary",
1333
+ onClick: props.onEdit,
1334
+ children: "Edit workflow"
1335
+ })
1336
+ ]
1337
+ })]
1338
+ }),
1339
+ /* @__PURE__ */ jsxs("dl", {
1340
+ className: "mt-5 flex flex-wrap gap-x-10 gap-y-3",
1341
+ children: [
1342
+ /* @__PURE__ */ jsx(Fact, {
1343
+ label: "Starts",
1344
+ children: state.trigger ? describeTrigger(state.trigger) : /* @__PURE__ */ jsx("span", {
1345
+ className: "text-wf-warn",
1346
+ children: "Never: no trigger"
1347
+ })
1348
+ }),
1349
+ /* @__PURE__ */ jsx(Fact, {
1350
+ label: "Last run",
1351
+ title: stats.lastRun ? formatAbsolute(stats.lastRun.startedAt) : void 0,
1352
+ children: stats.lastRun ? /* @__PURE__ */ jsxs("span", {
1353
+ className: `inline-flex items-center gap-1.5 ${TONE_TEXT[lastTone]}`,
1354
+ children: [/* @__PURE__ */ jsx(StatusDot, { tone: lastTone }), formatWhen(stats.lastRun.startedAt)]
1355
+ }) : /* @__PURE__ */ jsx("span", {
1356
+ className: "text-muted-foreground",
1357
+ children: "Never"
1358
+ })
1359
+ }),
1360
+ /* @__PURE__ */ jsx(Fact, {
1361
+ label: "Recent runs",
1362
+ children: stats.total > 0 ? /* @__PURE__ */ jsx(RunStrip, { runs: props.runs ?? [] }) : /* @__PURE__ */ jsx("span", {
1363
+ className: "text-muted-foreground",
1364
+ children: "None yet"
1365
+ })
1366
+ }),
1367
+ /* @__PURE__ */ jsx(Fact, {
1368
+ label: "Success rate",
1369
+ children: stats.successRate === null ? /* @__PURE__ */ jsx("span", {
1370
+ className: "text-muted-foreground",
1371
+ children: "No finished runs"
1372
+ }) : `${stats.successRate}%`
1373
+ }),
1374
+ /* @__PURE__ */ jsxs(Fact, {
1375
+ label: "Version",
1376
+ children: ["v", state.version]
1377
+ })
1378
+ ]
1379
+ }),
1380
+ /* @__PURE__ */ jsx(WorkflowSteps, {
1381
+ state,
1382
+ latestRun: stats.lastRun,
1383
+ onOpenEditor: props.onEdit
1384
+ })
1385
+ ]
1386
+ });
1387
+ }
1388
+ //#endregion
1389
+ //#region editors/workflow-studio/components/WorkflowStudio.tsx
1390
+ const WORKFLOW_TYPE = "powerhouse/workflow";
1391
+ const CONNECTION_TYPE = "powerhouse/connection";
1392
+ function WorkflowStudio(props) {
1393
+ const [drive] = useSelectedDrive();
1394
+ const fileNodes = useFileNodesInSelectedDrive() ?? [];
1395
+ const selectedNode = useSelectedNode();
1396
+ const selectedNodeId = selectedNode?.id;
1397
+ const toast = usePHToast();
1398
+ const [selectedId, select] = useHashSelection();
1399
+ const [creating, setCreating] = useState(false);
1400
+ const driveId = drive.header.id;
1401
+ const workflows = fileNodes.filter((node) => node.documentType === WORKFLOW_TYPE);
1402
+ const connections = fileNodes.filter((node) => node.documentType === CONNECTION_TYPE);
1403
+ const editorOpen = Boolean(props.children && selectedNodeId);
1404
+ const create = (documentType, baseName, count) => {
1405
+ if (creating) return;
1406
+ setCreating(true);
1407
+ addDocument(driveId, `${baseName} ${count + 1}`, documentType).then((node) => {
1408
+ select(node.id);
1409
+ setSelectedNode(node.id);
1410
+ }).catch((error) => {
1411
+ toast?.(error instanceof Error ? error.message : `Failed to create ${baseName}`, { type: "error" });
1412
+ }).finally(() => setCreating(false));
1413
+ };
1414
+ const showRuns = (node) => {
1415
+ setSelectedNode(void 0);
1416
+ select(node?.id);
1417
+ };
1418
+ const liveTarget = workflows.find((node) => node.id === selectedId) ?? null;
1419
+ const connectionSelected = connections.some((node) => node.id === selectedId);
1420
+ const wasEditing = useRef(editorOpen);
1421
+ useEffect(() => {
1422
+ if (wasEditing.current && !editorOpen && connectionSelected) select(void 0);
1423
+ wasEditing.current = editorOpen;
1424
+ }, [
1425
+ editorOpen,
1426
+ connectionSelected,
1427
+ select
1428
+ ]);
1429
+ const selectionExists = fileNodes.some((node) => node.id === selectedId);
1430
+ useEffect(() => {
1431
+ if (selectedId && fileNodes.length > 0 && !selectionExists) select(void 0);
1432
+ }, [
1433
+ fileNodes.length,
1434
+ select,
1435
+ selectedId,
1436
+ selectionExists
1437
+ ]);
1438
+ const focusedWorkflow = liveTarget;
1439
+ const driveFeed = useRuns({ driveId });
1440
+ const workflowFeed = useRuns({ workflowId: focusedWorkflow?.id }, Boolean(focusedWorkflow));
1441
+ const { runs, error: runsError, reload: reloadRuns } = focusedWorkflow ? workflowFeed : driveFeed;
1442
+ const lastRuns = /* @__PURE__ */ new Map();
1443
+ for (const run of driveFeed.runs ?? []) if (!lastRuns.has(run.workflowId)) lastRuns.set(run.workflowId, run.status);
1444
+ const { data: targetDocument } = useDocumentSafe(liveTarget?.id ?? null);
1445
+ const manualTrigger = targetDocument?.header.documentType === WORKFLOW_TYPE && targetDocument.state.global.trigger?.blockType === "core#manual";
1446
+ return /* @__PURE__ */ jsxs("div", {
1447
+ className: "flex h-full min-h-0",
1448
+ children: [/* @__PURE__ */ jsx(Sidebar, {
1449
+ workflows,
1450
+ connections,
1451
+ lastRuns,
1452
+ activeId: selectedId,
1453
+ allRunsActive: !selectedId,
1454
+ creating,
1455
+ onShowAllRuns: () => showRuns(null),
1456
+ onOpenWorkflow: (node) => showRuns(node),
1457
+ onEditWorkflow: (node) => {
1458
+ select(node.id);
1459
+ setSelectedNode(node.id);
1460
+ },
1461
+ onOpenConnection: (node) => {
1462
+ select(node.id);
1463
+ setSelectedNode(node.id);
1464
+ },
1465
+ onCreateWorkflow: () => create(WORKFLOW_TYPE, "Workflow", workflows.length),
1466
+ onCreateConnection: () => create(CONNECTION_TYPE, "Connection", connections.length)
1467
+ }), /* @__PURE__ */ jsx("main", {
1468
+ className: "min-w-0 flex-1 overflow-y-auto",
1469
+ children: editorOpen ? /* @__PURE__ */ jsx("div", {
1470
+ className: "flex h-full min-h-0 flex-col",
1471
+ children: /* @__PURE__ */ jsx("div", {
1472
+ className: "flex min-h-0 flex-1 flex-col [&>#document-editor-container]:min-h-0",
1473
+ children: /* @__PURE__ */ jsx(DocumentErrorBoundary, {
1474
+ documentId: selectedNodeId,
1475
+ label: selectedNode?.name,
1476
+ onDismiss: () => setSelectedNode(void 0),
1477
+ children: props.children
1478
+ }, selectedNodeId)
1479
+ })
1480
+ }) : /* @__PURE__ */ jsxs("div", {
1481
+ className: "mx-auto w-full max-w-6xl px-8 py-10",
1482
+ children: [liveTarget ? /* @__PURE__ */ jsx(WorkflowHeader, {
1483
+ node: liveTarget,
1484
+ runs,
1485
+ onEdit: () => setSelectedNode(liveTarget.id)
1486
+ }, liveTarget.id) : /* @__PURE__ */ jsx(WorkflowBoard, {
1487
+ runs,
1488
+ creating,
1489
+ onOpen: (workflowId) => select(workflowId),
1490
+ onCreate: () => create(WORKFLOW_TYPE, "Workflow", workflows.length)
1491
+ }), /* @__PURE__ */ jsx(RunsView, {
1492
+ title: liveTarget ? "Runs" : "Recent runs",
1493
+ runs,
1494
+ error: runsError,
1495
+ reload: reloadRuns,
1496
+ showWorkflow: liveTarget === null,
1497
+ onFire: liveTarget && manualTrigger ? () => fireWorkflow(liveTarget.id).then((result) => result.error) : void 0
1498
+ })]
1499
+ })
1500
+ })]
1501
+ });
1502
+ }
1503
+ //#endregion
1504
+ //#region editors/workflow-studio/config.ts
1505
+ const editorConfig = {
1506
+ isDragAndDropEnabled: true,
1507
+ allowedDocumentTypes: ["powerhouse/workflow", "powerhouse/connection"]
1508
+ };
1509
+ //#endregion
1510
+ //#region editors/workflow-studio/editor.tsx
1511
+ /**
1512
+ * WARNING: DO NOT EDIT
1513
+ * This file is auto-generated and updated by codegen
1514
+ */
1515
+ /** Editor component for the app */
1516
+ function Editor(props) {
1517
+ useSetPHAppConfig(editorConfig);
1518
+ useSyncWorkflowRuntimeUrl();
1519
+ return /* @__PURE__ */ jsx("div", {
1520
+ className: "h-full min-h-0 bg-background",
1521
+ children: /* @__PURE__ */ jsx(WorkflowStudio, { children: props.children })
1522
+ });
1523
+ }
1524
+ //#endregion
1525
+ export { Editor as default };
1526
+
1527
+ //# sourceMappingURL=editor-CyNBEKoj.mjs.map