@powerhousedao/workflow 6.2.3-dev.88 → 6.2.3-dev.90

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 (147) hide show
  1. package/dist/browser/{BlockSelector-BKAJwJ4Y.js → BlockSelector-DFzzAWXh.js} +65 -7
  2. package/dist/browser/BlockSelector-DFzzAWXh.js.map +1 -0
  3. package/dist/browser/{connection-form-DltdMa8F.js → connection-form-B6zpGmAm.js} +3 -3
  4. package/dist/browser/{connection-form-DltdMa8F.js.map → connection-form-B6zpGmAm.js.map} +1 -1
  5. package/dist/browser/{data-tree-DAw8e0j8.js → data-tree-DKS0EQys.js} +2 -2
  6. package/dist/browser/{data-tree-DAw8e0j8.js.map → data-tree-DKS0EQys.js.map} +1 -1
  7. package/dist/browser/{editor-Dl6lzxkM.js → editor-Yt-_V04R.js} +207 -58
  8. package/dist/browser/editor-Yt-_V04R.js.map +1 -0
  9. package/dist/browser/{editor-CZLe6CAF.js → editor-bHCkW_XB.js} +4 -4
  10. package/dist/browser/{editor-CZLe6CAF.js.map → editor-bHCkW_XB.js.map} +1 -1
  11. package/dist/browser/{editor--J61vLSC.js → editor-gCkAwv09.js} +64 -132
  12. package/dist/browser/editor-gCkAwv09.js.map +1 -0
  13. package/dist/browser/editors/connection-editor/module.js +1 -1
  14. package/dist/browser/editors/runtime/index.js +1 -1
  15. package/dist/browser/editors/workflow-editor/module.js +1 -1
  16. package/dist/browser/editors/workflow-studio/module.js +1 -1
  17. package/dist/browser/index.js +2 -1
  18. package/dist/browser/index.js.map +1 -1
  19. package/dist/browser/{runtime-queries-D81Ghpok.js → runtime-queries-C5bqAgQy.js} +84 -13
  20. package/dist/browser/runtime-queries-C5bqAgQy.js.map +1 -0
  21. package/dist/browser/{trigger-text-BSVi5oGZ.js → trigger-text-BfIu-QcC.js} +176 -11
  22. package/dist/browser/trigger-text-BfIu-QcC.js.map +1 -0
  23. package/dist/node/document-models/connection/index.mjs +67 -3
  24. package/dist/node/document-models/connection/index.mjs.map +1 -0
  25. package/dist/node/document-models/index.mjs +3 -3
  26. package/dist/node/document-models/workflow/index.mjs +86 -3
  27. package/dist/node/document-models/workflow/index.mjs.map +1 -0
  28. package/dist/node/editors/index.mjs +6 -4
  29. package/dist/node/editors/index.mjs.map +1 -0
  30. package/dist/node/index.mjs +5 -411
  31. package/dist/node/index.mjs.map +1 -1
  32. package/dist/node/{module-CuTg45ct.mjs → module-BXKUB58R.mjs} +9 -4
  33. package/dist/node/module-BXKUB58R.mjs.map +1 -0
  34. package/dist/node/{module-BEEASith.mjs → module-CaBtkQmd.mjs} +16 -16
  35. package/dist/node/module-CaBtkQmd.mjs.map +1 -0
  36. package/dist/node/pieces/ai/descriptor.json +70 -1
  37. package/dist/node/pieces/ai/index.mjs +125 -125
  38. package/dist/node/pieces/ai/package.json +1 -1
  39. package/dist/node/pieces/reactor/descriptor.json +35 -1
  40. package/dist/node/pieces/reactor/index.mjs +39 -39
  41. package/dist/node/pieces/reactor/package.json +1 -1
  42. package/dist/node/rolldown-runtime-D7D4PA-g.mjs +13 -0
  43. package/dist/node/upgrade-manifests-BCCpSD1J.mjs +8 -0
  44. package/dist/node/{upgrade-manifests-BA5OaR4H.mjs.map → upgrade-manifests-BCCpSD1J.mjs.map} +1 -1
  45. package/dist/powerhouse.manifest.json +2 -2
  46. package/dist/style.css +1 -1
  47. package/dist/types/ai/workflow-tools.d.ts.map +1 -1
  48. package/dist/types/document-models/connection/v1/actions.d.ts +1 -0
  49. package/dist/types/document-models/connection/v1/actions.d.ts.map +1 -1
  50. package/dist/types/document-models/connection/v1/module.d.ts +1 -0
  51. package/dist/types/document-models/connection/v1/module.d.ts.map +1 -1
  52. package/dist/types/document-models/document-models.d.ts +2 -0
  53. package/dist/types/document-models/document-models.d.ts.map +1 -1
  54. package/dist/types/document-models/workflow/v1/actions.d.ts +1 -0
  55. package/dist/types/document-models/workflow/v1/actions.d.ts.map +1 -1
  56. package/dist/types/document-models/workflow/v1/module.d.ts +1 -0
  57. package/dist/types/document-models/workflow/v1/module.d.ts.map +1 -1
  58. package/dist/types/editors/shared/icons.d.ts +4 -0
  59. package/dist/types/editors/shared/icons.d.ts.map +1 -1
  60. package/dist/types/editors/workflow-editor/editor.d.ts.map +1 -1
  61. package/dist/types/editors/workflow-editor/runtime-client.d.ts +5 -1
  62. package/dist/types/editors/workflow-editor/runtime-client.d.ts.map +1 -1
  63. package/dist/types/editors/workflow-editor/ui/BlockSelector.d.ts.map +1 -1
  64. package/dist/types/editors/workflow-editor/ui/PropertyForm.d.ts +1 -0
  65. package/dist/types/editors/workflow-editor/ui/PropertyForm.d.ts.map +1 -1
  66. package/dist/types/editors/workflow-editor/ui/StepPanel.d.ts.map +1 -1
  67. package/dist/types/editors/workflow-editor/ui/ap-edge.d.ts +1 -0
  68. package/dist/types/editors/workflow-editor/ui/ap-edge.d.ts.map +1 -1
  69. package/dist/types/editors/workflow-editor/ui/ap-layout.d.ts.map +1 -1
  70. package/dist/types/editors/workflow-editor/ui/ap-nodes.d.ts +4 -0
  71. package/dist/types/editors/workflow-editor/ui/ap-nodes.d.ts.map +1 -1
  72. package/dist/types/editors/workflow-editor/ui/block-meta.d.ts +3 -0
  73. package/dist/types/editors/workflow-editor/ui/block-meta.d.ts.map +1 -1
  74. package/dist/types/editors/workflow-editor/ui/blocks.d.ts +8 -0
  75. package/dist/types/editors/workflow-editor/ui/blocks.d.ts.map +1 -1
  76. package/dist/types/editors/workflow-editor/ui/canvas-menu.d.ts.map +1 -1
  77. package/dist/types/editors/workflow-editor/ui/flow-control.test.d.ts +2 -0
  78. package/dist/types/editors/workflow-editor/ui/flow-control.test.d.ts.map +1 -0
  79. package/dist/types/editors/workflow-editor/ui/prop-layout.d.ts +1 -0
  80. package/dist/types/editors/workflow-editor/ui/prop-layout.d.ts.map +1 -1
  81. package/dist/types/editors/workflow-editor/ui/prop-layout.test.d.ts +2 -0
  82. package/dist/types/editors/workflow-editor/ui/prop-layout.test.d.ts.map +1 -0
  83. package/dist/types/editors/workflow-editor/ui/trigger-text.d.ts.map +1 -1
  84. package/dist/types/editors/workflow-editor/ui/use-validity.d.ts.map +1 -1
  85. package/dist/types/editors/workflow-editor/ui/validation.d.ts +4 -1
  86. package/dist/types/editors/workflow-editor/ui/validation.d.ts.map +1 -1
  87. package/dist/types/editors/workflow-studio/components/RunsTable.d.ts +4 -1
  88. package/dist/types/editors/workflow-studio/components/RunsTable.d.ts.map +1 -1
  89. package/dist/types/editors/workflow-studio/components/Waitpoints.d.ts +9 -1
  90. package/dist/types/editors/workflow-studio/components/Waitpoints.d.ts.map +1 -1
  91. package/dist/types/editors/workflow-studio/components/WorkflowGraph.d.ts.map +1 -1
  92. package/dist/types/editors/workflow-studio/components/graph-layout.d.ts +1 -0
  93. package/dist/types/editors/workflow-studio/components/graph-layout.d.ts.map +1 -1
  94. package/dist/types/editors/workflow-studio/components/tips.d.ts.map +1 -1
  95. package/dist/types/pieces/ai/lib/actions/decide-on-documents.d.ts.map +1 -1
  96. package/dist/types/pieces/ai/lib/actions/extract.d.ts.map +1 -1
  97. package/dist/types/pieces/ai/lib/actions/propose-actions.d.ts.map +1 -1
  98. package/dist/types/pieces/ai/lib/actions/summarize.d.ts.map +1 -1
  99. package/dist/types/pieces/reactor/lib/actions/document-find.d.ts.map +1 -1
  100. package/dist/types/test/ui/flow-control.spec.d.ts +2 -0
  101. package/dist/types/test/ui/flow-control.spec.d.ts.map +1 -0
  102. package/package.json +22 -10
  103. package/dist/browser/BlockSelector-BKAJwJ4Y.js.map +0 -1
  104. package/dist/browser/editor--J61vLSC.js.map +0 -1
  105. package/dist/browser/editor-Dl6lzxkM.js.map +0 -1
  106. package/dist/browser/runtime-queries-D81Ghpok.js.map +0 -1
  107. package/dist/browser/trigger-text-BSVi5oGZ.js.map +0 -1
  108. package/dist/node/BlockSelector-DnTRF-C7.mjs +0 -8669
  109. package/dist/node/BlockSelector-DnTRF-C7.mjs.map +0 -1
  110. package/dist/node/PieceMarkdown-CUSdTMH4.mjs +0 -23307
  111. package/dist/node/PieceMarkdown-CUSdTMH4.mjs.map +0 -1
  112. package/dist/node/block-type-kX-27vVt.mjs +0 -44
  113. package/dist/node/block-type-kX-27vVt.mjs.map +0 -1
  114. package/dist/node/connection-BZxipUlb.mjs +0 -90
  115. package/dist/node/connection-BZxipUlb.mjs.map +0 -1
  116. package/dist/node/connection-form-DwSHfIRw.mjs +0 -1364
  117. package/dist/node/connection-form-DwSHfIRw.mjs.map +0 -1
  118. package/dist/node/data-tree-uSJU9Ost.mjs +0 -1916
  119. package/dist/node/data-tree-uSJU9Ost.mjs.map +0 -1
  120. package/dist/node/editor-B4ZwM3pR.mjs +0 -3286
  121. package/dist/node/editor-B4ZwM3pR.mjs.map +0 -1
  122. package/dist/node/editor-_4XHbqGl.mjs +0 -15424
  123. package/dist/node/editor-_4XHbqGl.mjs.map +0 -1
  124. package/dist/node/editor-cXi5dIsd.mjs +0 -370
  125. package/dist/node/editor-cXi5dIsd.mjs.map +0 -1
  126. package/dist/node/editors/connection-editor/module.mjs +0 -15
  127. package/dist/node/editors/connection-editor/module.mjs.map +0 -1
  128. package/dist/node/editors/runtime/index.mjs +0 -2
  129. package/dist/node/editors/workflow-editor/module.mjs +0 -15
  130. package/dist/node/editors/workflow-editor/module.mjs.map +0 -1
  131. package/dist/node/editors/workflow-studio/module.mjs +0 -15
  132. package/dist/node/editors/workflow-studio/module.mjs.map +0 -1
  133. package/dist/node/graphql-D76E1YiQ.mjs +0 -14554
  134. package/dist/node/graphql-D76E1YiQ.mjs.map +0 -1
  135. package/dist/node/module-BEEASith.mjs.map +0 -1
  136. package/dist/node/module-CuTg45ct.mjs.map +0 -1
  137. package/dist/node/piece-auth-C0u0XTO8.mjs +0 -154
  138. package/dist/node/piece-auth-C0u0XTO8.mjs.map +0 -1
  139. package/dist/node/rolldown-runtime-B4iAMlE-.mjs +0 -35
  140. package/dist/node/runtime-queries-VXJsWno5.mjs +0 -2891
  141. package/dist/node/runtime-queries-VXJsWno5.mjs.map +0 -1
  142. package/dist/node/style.css +0 -667
  143. package/dist/node/trigger-text-BBP7QVLj.mjs +0 -3045
  144. package/dist/node/trigger-text-BBP7QVLj.mjs.map +0 -1
  145. package/dist/node/upgrade-manifests-BA5OaR4H.mjs +0 -8
  146. package/dist/node/workflow-BgURVzdc.mjs +0 -109
  147. package/dist/node/workflow-BgURVzdc.mjs.map +0 -1
@@ -1,15 +1,15 @@
1
1
  import { h as REACTOR_CONNECTOR_ID, x as actions } from "./module-DJz6oTX0.js";
2
2
  import { t as useConnectionDocumentById } from "./connection-PaKXHYz9.js";
3
3
  import { i as connectorIdForPiece, l as planFromAuth, s as packageFromConnectorId } from "./piece-auth-63iuNFTs.js";
4
- import { G as stepFields, I as STEP_PRESETS, K as triggerBlock, R as TRIGGER_PRESETS, U as sameBlock, V as isCoreBlock, W as stepBlock, b as realRuns, f as stepOutputTreeQuery, g as blockRefKey, i as outputTreeQuery, n as catalogQuery, q as triggerFields, u as runsQuery, y as TEST_TRIGGER_KIND } from "./runtime-queries-D81Ghpok.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-C5bqAgQy.js";
5
5
  import { y as actions$1 } from "./module-mFCt9WHJ.js";
6
6
  import { t as useSelectedWorkflowDocument } from "./workflow-BFdnSGRD.js";
7
- import { $ as useRunById, A as formatWhen, At as FieldLabel, B as useBlockFormLoader, Bt as textAreaClass, E as formatDuration, Et as useSearchParam, Ft as Switch, G as useConnectionList, H as useBlockPorts, Ht as Icon, I as toneOf, It as Tabs, J as useDynamicLookup, K as useDesignTime, Mt as IconButton, Nt as Segmented, Ot as Button, Pt as Select, R as DesignTimeProvider, S as TONE_TEXT, St as useRuntimeActions, T as formatAbsolute, U as useBlockResolutions, V as useBlockForms, Vt as textInputClass, W as useCachedBlockForm, Wt as DocumentErrorBoundary, X as useLatestRun, Y as useDynamicPrefetch, a as BlockResolutionsProvider, at as isPropVisible, bt as useRunsQuery, c as runsDifferentVersion, ct as settingFor, d as versionBadge, dt as undeclaredPortIssues, et as useTestStepRunner, g as usePieceLogos, h as useBlockMeta, i as PickerPopover, jt as Hint, kt as FieldError, l as updateVersion, lt as storedSchema, m as pieceLogo, mt as WorkflowRuntimeProvider, n as BlockSelector, nt as useWebhookEndpoint, o as VersionSummary, p as pieceDisplayName, pt as workflowReadiness, r as PICKER_SIZE, rt as blockMissing, s as resolutionText, st as resolverInputFor, t as BlockLogo, tt as useTestTrigger, u as useResolution, x as TONE_DOT, xt as useRuntime, y as RUN_TONE, z as useBlockForm } from "./BlockSelector-BKAJwJ4Y.js";
8
- import { a as useSignInGate, f as connectionCallbacks, g as newUndoGroup, h as groupedAction, 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-DltdMa8F.js";
9
- import { A as EMPTY_SCOPE, B as menuHeight, C as useSecretRef, D as ExpressionTargetProvider, E as ExpressionScopeSourceProvider, F as parseTypedValue, H as usePendingEcho, I as valueMismatch, L as documentShape, M as VARIABLE_TYPES, N as VARIABLE_TYPE_LABEL, O as ExpressionTokenLine, P as convertVariableValue, R as stateFieldsFromSdl, S as withPropDefaults, T as ExpressionPickerPopup, V as menuPosition, _ as uniqueStepKey, a as StepError, b as PropertyForm, c as PublishButton, d as ReactorDenialNote, f as StatusToggle, g as hasDraftChanges, h as VARIABLES_VIEW, i as DataViewer, j as buildExpressionScope, k as useExpressionField, l as PublishState, m as STEP_PARAM, n as describeSchedule, o as DraftBanner, p as usePublish, r as describeTrigger, s as ManagedBanner, t as describeCron, u as PublishedMissingNote, v as AvailableSoon, w as ExpressionPickerButton, x as lacksDefaults, y as PiecePlaceholderContext, z as contextMenuItems } from "./trigger-text-BSVi5oGZ.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-DFzzAWXh.js";
8
+ import { a as useSignInGate, f as connectionCallbacks, g as newUndoGroup, h as groupedAction, 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-B6zpGmAm.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-BfIu-QcC.js";
10
10
  import { addDocument, dispatchActions, useDocumentModelModules, useDocumentSafe, useFileNodesInSelectedDrive, useSelectedDriveId } from "@powerhousedao/reactor-browser";
11
11
  import { generateId } from "document-model";
12
- import { DEFAULT_TIMEZONE, flowPorts, knownPorts, parseScheduleConfig, scheduleConfigIssue } from "@powerhousedao/pieces-framework/workflow";
12
+ import { DEFAULT_TIMEZONE, flowPorts, knownPorts, parseScheduleConfig, scheduleConfigIssue, stepPortLabel, stepPorts } from "@powerhousedao/pieces-framework/workflow";
13
13
  import { createContext, useCallback, useContext, useEffect, useId, useMemo, useRef, useState, useSyncExternalStore } from "react";
14
14
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
15
15
  import { Modal } from "@powerhousedao/design-system/connect";
@@ -482,14 +482,19 @@ function attachableSteps(model, fromId) {
482
482
  return model.steps.filter((step) => !attached.has(step.id) && step.id !== fromId && !reachableFrom(step.id, model.edges).has(fromId));
483
483
  }
484
484
  const PORT_ORDER = [
485
+ "each",
485
486
  "next",
486
487
  "true",
487
- "false",
488
- "error"
488
+ "false"
489
489
  ];
490
490
  function portRank(port) {
491
491
  const index = PORT_ORDER.indexOf(port);
492
- return index === -1 ? PORT_ORDER.length : index;
492
+ if (index !== -1) return index;
493
+ const branch = /^branch_(\d+)$/.exec(port);
494
+ if (branch) return PORT_ORDER.length + 1 - 1 / Number(branch[1]);
495
+ if (port === "otherwise") return PORT_ORDER.length + 1;
496
+ if (port === "error") return PORT_ORDER.length + 2;
497
+ return PORT_ORDER.length + 3;
493
498
  }
494
499
  function layoutWorkflow(model, portsOf = () => void 0) {
495
500
  const nodes = [];
@@ -520,12 +525,16 @@ function layoutWorkflow(model, portsOf = () => void 0) {
520
525
  outgoing.set(edge.from, list);
521
526
  }
522
527
  for (const list of outgoing.values()) list.sort((a, b) => portRank(a.port) - portRank(b.port));
523
- const placed = /* @__PURE__ */ new Set();
524
528
  const stepById = new Map(model.steps.map((step) => [step.id, step]));
525
529
  const declared = (id) => {
526
530
  const step = stepById.get(id);
527
- const block = id === model.trigger?.id ? triggerBlock(model.trigger) : step ? stepBlock(step) : void 0;
528
- return block ? portsOf(block) : void 0;
531
+ if (id === model.trigger?.id) return portsOf(triggerBlock(model.trigger));
532
+ const wired = (outgoing.get(id) ?? []).map((edge) => edge.port);
533
+ return step ? stepPorts(stepBlock(step), step.config, portsOf, wired) : void 0;
534
+ };
535
+ const labelOf = (id, port) => {
536
+ const step = stepById.get(id);
537
+ return step ? stepPortLabel(stepBlock(step), step.config, port) : void 0;
529
538
  };
530
539
  const outPorts = (id) => {
531
540
  const ports = declared(id);
@@ -535,8 +544,50 @@ function layoutWorkflow(model, portsOf = () => void 0) {
535
544
  const ports = outPorts(id);
536
545
  return ports.length > 1 ? ports : [];
537
546
  };
538
- const outletsOf = (id, used) => {
539
- const edges = (outgoing.get(id) ?? []).filter((edge) => !used(edge.to));
547
+ const reachable = reachableFrom(model.trigger.id, model.edges);
548
+ const via = /* @__PURE__ */ new Map();
549
+ for (const node of graphLayout({
550
+ triggerId: model.trigger.id,
551
+ steps: model.steps,
552
+ edges: model.edges
553
+ }).nodes) if (node.via) via.set(node.step.id, node.via);
554
+ const pending = /* @__PURE__ */ new Map();
555
+ for (const list of outgoing.values()) for (const edge of list) {
556
+ if (!reachable.has(edge.from)) continue;
557
+ pending.set(edge.to, (pending.get(edge.to) ?? 0) + 1);
558
+ }
559
+ const owner = /* @__PURE__ */ new Map();
560
+ const row = /* @__PURE__ */ new Map();
561
+ const visited = /* @__PURE__ */ new Set();
562
+ const visit = (id, gated) => {
563
+ visited.add(id);
564
+ for (const edge of outgoing.get(id) ?? []) {
565
+ if (visited.has(edge.to)) continue;
566
+ const below = row.get(id) + 1;
567
+ row.set(edge.to, gated ? Math.max(row.get(edge.to) ?? 0, below) : below);
568
+ if (gated) {
569
+ const left = pending.get(edge.to) - 1;
570
+ pending.set(edge.to, left);
571
+ if (left > 0) continue;
572
+ }
573
+ const parent = gated ? via.get(edge.to) : void 0;
574
+ const wired = parent && outgoing.get(parent.from)?.includes(parent);
575
+ owner.set(edge.to, wired ? parent : edge);
576
+ visit(edge.to, gated);
577
+ }
578
+ };
579
+ row.set(model.trigger.id, 0);
580
+ visit(model.trigger.id, true);
581
+ const roots = [];
582
+ for (const step of model.steps) {
583
+ if (visited.has(step.id)) continue;
584
+ roots.push(step.id);
585
+ row.set(step.id, 0);
586
+ visit(step.id, false);
587
+ }
588
+ const owns = (edge) => owner.get(edge.to) === edge;
589
+ const outletsOf = (id) => {
590
+ const edges = outgoing.get(id) ?? [];
540
591
  const ports = branchPorts(id);
541
592
  if (ports.length === 0) return edges.map((edge) => ({
542
593
  port: edge.port,
@@ -548,20 +599,19 @@ function layoutWorkflow(model, portsOf = () => void 0) {
548
599
  edge
549
600
  })), ...ports.filter((port) => !wired.has(port)).map((port) => ({ port }))].sort((a, b) => portRank(a.port) - portRank(b.port));
550
601
  };
551
- const subtreeWidth = (id, visited) => {
552
- if (visited.has(id)) return 232;
553
- visited.add(id);
554
- const outlets = outletsOf(id, (target) => visited.has(target));
602
+ const subtreeWidth = (id) => {
603
+ const outlets = outletsOf(id);
555
604
  if (outlets.length === 0) return 232;
556
- const total = outlets.map((outlet) => outlet.edge ? subtreeWidth(outlet.edge.to, visited) : 232).reduce((sum, width) => sum + width, 0);
605
+ const total = outlets.map((outlet) => outlet.edge && owns(outlet.edge) ? subtreeWidth(outlet.edge.to) : 232).reduce((sum, width) => sum + width, 0);
557
606
  return Math.max(232, total + (outlets.length - 1) * 80);
558
607
  };
559
608
  const placeholders = /* @__PURE__ */ new Map();
560
- const place = (id, centerX, y) => {
561
- if (placed.has(id)) return;
562
- placed.add(id);
609
+ const lanes = /* @__PURE__ */ new Map();
610
+ const ROW = 120;
611
+ const place = (id, centerX, top) => {
563
612
  const step = stepById.get(id);
564
613
  const isTrigger = id === model.trigger?.id;
614
+ const y = top + row.get(id) * ROW;
565
615
  nodes.push({
566
616
  id,
567
617
  type: "apStep",
@@ -581,28 +631,28 @@ function layoutWorkflow(model, portsOf = () => void 0) {
581
631
  },
582
632
  draggable: false
583
633
  });
584
- const outlets = outletsOf(id, (target) => placed.has(target));
585
- const widths = outlets.map((outlet) => outlet.edge ? subtreeWidth(outlet.edge.to, new Set(placed)) : 232);
586
- const total = widths.reduce((sum, width) => sum + width, 0) + Math.max(outlets.length - 1, 0) * 80;
587
- const childY = y + 60 + 60;
588
- let cursor = centerX - total / 2;
634
+ const outlets = outletsOf(id);
635
+ const widths = outlets.map((outlet) => outlet.edge && owns(outlet.edge) ? subtreeWidth(outlet.edge.to) : 232);
636
+ let cursor = centerX - (widths.reduce((sum, width) => sum + width, 0) + Math.max(outlets.length - 1, 0) * 80) / 2;
589
637
  outlets.forEach((outlet, index) => {
590
638
  const slotCenter = cursor + widths[index] / 2;
591
- if (outlet.edge) place(outlet.edge.to, slotCenter, childY);
592
- else placeholders.set(`${id}:${outlet.port}`, {
639
+ if (outlet.edge) {
640
+ lanes.set(outlet.edge.id, slotCenter);
641
+ if (owns(outlet.edge)) place(outlet.edge.to, slotCenter, top);
642
+ } else placeholders.set(`${id}:${outlet.port}`, {
593
643
  x: slotCenter,
594
- y: childY
644
+ y: y + ROW
595
645
  });
596
646
  cursor += widths[index] + 80;
597
647
  });
598
648
  };
599
649
  place(model.trigger.id, 0, 0);
650
+ const mainWidth = subtreeWidth(model.trigger.id);
600
651
  let orphanY = 0;
601
- const mainWidth = subtreeWidth(model.trigger.id, /* @__PURE__ */ new Set());
602
- for (const step of model.steps) {
603
- if (placed.has(step.id)) continue;
604
- place(step.id, mainWidth / 2 + 80 + 116, orphanY);
605
- orphanY += 120;
652
+ for (const root of roots) {
653
+ const before = nodes.length;
654
+ place(root, mainWidth / 2 + 80 + 116, orphanY);
655
+ orphanY = Math.max(...nodes.slice(before).map((node) => node.position.y)) + ROW;
606
656
  }
607
657
  const nodeById = new Map(nodes.map((node) => [node.id, node]));
608
658
  for (const edge of model.edges) {
@@ -615,6 +665,8 @@ function layoutWorkflow(model, portsOf = () => void 0) {
615
665
  data: {
616
666
  edgeId: edge.id,
617
667
  port: edge.port,
668
+ portLabel: labelOf(edge.from, edge.port),
669
+ lane: lanes.get(edge.id),
618
670
  condition: edge.condition,
619
671
  fromSkipped: stepById.get(edge.from)?.skip === true,
620
672
  dead: declared(edge.from)?.includes(edge.port) === false
@@ -645,6 +697,7 @@ function layoutWorkflow(model, portsOf = () => void 0) {
645
697
  data: {
646
698
  parentId: node.id,
647
699
  port,
700
+ portLabel: labelOf(node.id, port),
648
701
  card: Boolean(slot),
649
702
  ...model.steps.length === 0 ? { hint: true } : {}
650
703
  },
@@ -661,8 +714,48 @@ function layoutWorkflow(model, portsOf = () => void 0) {
661
714
  });
662
715
  });
663
716
  }
717
+ const LOOP_PAD = 16;
718
+ const sizeOf = (node) => node.type === "apAppend" && !node.data.card ? {
719
+ width: 20,
720
+ height: 20
721
+ } : {
722
+ width: 232,
723
+ height: 60
724
+ };
725
+ const frames = [];
726
+ for (const edge of model.edges) {
727
+ if (edge.port !== "each" || !owns(edge)) continue;
728
+ const body = /* @__PURE__ */ new Set();
729
+ const collect = (id) => {
730
+ body.add(id);
731
+ for (const next of outgoing.get(id) ?? []) if (owns(next)) collect(next.to);
732
+ };
733
+ collect(edge.to);
734
+ const members = nodes.filter((node) => node.type === "apStep" ? body.has(node.id) : body.has(node.data.parentId ?? ""));
735
+ const left = Math.min(...members.map((node) => node.position.x));
736
+ const top = Math.min(...members.map((node) => node.position.y));
737
+ const right = Math.max(...members.map((node) => node.position.x + sizeOf(node).width));
738
+ const bottom = Math.max(...members.map((node) => node.position.y + sizeOf(node).height));
739
+ frames.push({
740
+ id: `__loop:${edge.from}`,
741
+ type: "apLoopFrame",
742
+ position: {
743
+ x: left - LOOP_PAD,
744
+ y: top - LOOP_PAD
745
+ },
746
+ data: {
747
+ width: right - left + 32,
748
+ height: bottom - top + 32
749
+ },
750
+ draggable: false,
751
+ selectable: false,
752
+ focusable: false,
753
+ zIndex: -1,
754
+ style: { pointerEvents: "none" }
755
+ });
756
+ }
664
757
  return {
665
- nodes,
758
+ nodes: [...frames, ...nodes],
666
759
  edges
667
760
  };
668
761
  }
@@ -1865,7 +1958,7 @@ function useBlockCheck(block) {
1865
1958
  return {
1866
1959
  form,
1867
1960
  formError: error,
1868
- issues: block.skip ? [] : undeclaredPortIssues(form, block.outgoingPorts),
1961
+ issues: block.skip ? [] : undeclaredPortIssues(form, block.outgoingPorts, block),
1869
1962
  missing: blockMissing({
1870
1963
  form,
1871
1964
  block: block.block,
@@ -1922,7 +2015,7 @@ function useWorkflowCheck(model) {
1922
2015
  propertySettings: block.propertySettings,
1923
2016
  skip: block.skip,
1924
2017
  resolveDynamic: lookup
1925
- }), block.skip ? [] : undeclaredPortIssues(formOf(block), block.outgoingPorts))
2018
+ }), block.skip ? [] : undeclaredPortIssues(formOf(block), block.outgoingPorts, block))
1926
2019
  }));
1927
2020
  return {
1928
2021
  readiness: workflowReadiness(results, Boolean(model.trigger)),
@@ -2328,8 +2421,9 @@ function EdgeRow(props) {
2328
2421
  }
2329
2422
  function FlowPortEditor(props) {
2330
2423
  const { step, model, callbacks } = props;
2331
- const { form } = useBlockForm(stepBlock(step));
2332
- const declared = form && form !== "loading" ? form.ports : void 0;
2424
+ const block = stepBlock(step);
2425
+ const { form } = useBlockForm(block);
2426
+ 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));
2333
2427
  const ports = declared ? flowPorts(declared) : [];
2334
2428
  const dead = declared ? model.edges.filter((edge) => edge.from === step.id && !declared.includes(edge.port)) : [];
2335
2429
  const attached = model.trigger ? reachableFrom(model.trigger.id, model.edges) : /* @__PURE__ */ new Set();
@@ -2347,7 +2441,7 @@ function FlowPortEditor(props) {
2347
2441
  })] }) : null, ports.map((port) => {
2348
2442
  const edges = model.edges.filter((candidate) => candidate.from === step.id && candidate.port === port);
2349
2443
  const targets = candidates.filter((candidate) => !edges.some((edge) => edge.to === candidate.id));
2350
- return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(FieldLabel, { label: PORT_LABEL[port] ?? port }), /* @__PURE__ */ jsxs("div", {
2444
+ return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(FieldLabel, { label: stepPortLabel(block, step.config, port) ?? PORT_LABEL[port] ?? port }), /* @__PURE__ */ jsxs("div", {
2351
2445
  className: "flex flex-col gap-1.5",
2352
2446
  children: [edges.map((edge) => /* @__PURE__ */ jsx(EdgeRow, {
2353
2447
  target: model.steps.find((entry) => entry.id === edge.to),
@@ -3026,15 +3120,15 @@ function TriggerPanel(props) {
3026
3120
  block
3027
3121
  });
3028
3122
  const writes = !props.readOnly;
3029
- const isWebhookTrigger = form !== "loading" && form?.triggerDelivery === "webhook";
3123
+ const isWebhookTrigger = form !== "loading" && form?.triggerDelivery === "webhook" && !sameBlock(block, CALLABLE_FLOW_TRIGGER$1);
3030
3124
  const endpoint = useWebhookEndpoint(isWebhookTrigger);
3031
3125
  const setTriggerConfig = (config, settings) => callbacks.setTriggerConfig(config, writes ? { propertySettings: settings } : void 0);
3032
3126
  return /* @__PURE__ */ jsxs("div", {
3033
3127
  className: "flex min-h-full flex-col",
3034
3128
  children: [/* @__PURE__ */ jsx(PanelHeader, {
3035
3129
  block,
3036
- name: form && form !== "loading" && form.title ? form.title : meta.displayName,
3037
- actionLabel: describeTrigger(trigger),
3130
+ name: form && form !== "loading" && form.title && !namedByCoreTab(block) ? form.title : meta.displayName,
3131
+ actionLabel: namedByCoreTab(block) ? meta.subtitle : describeTrigger(trigger),
3038
3132
  missing,
3039
3133
  loading: form === "loading",
3040
3134
  onClose: props.onClose
@@ -3572,7 +3666,7 @@ function ApStepNode(props) {
3572
3666
  ]
3573
3667
  }), /* @__PURE__ */ jsx("div", {
3574
3668
  className: "truncate text-xs text-muted-foreground/80",
3575
- children: data.kind === "trigger" ? meta.subtitle === "Trigger" ? "Trigger" : meta.subtitle : meta.subtitle
3669
+ children: data.kind === "trigger" ? meta.subtitle : stepSubtitle(meta)
3576
3670
  })]
3577
3671
  })]
3578
3672
  }),
@@ -3587,8 +3681,14 @@ function ApStepNode(props) {
3587
3681
  const PORT_LABEL_CLASSES = {
3588
3682
  true: "bg-wf-ok/10 text-wf-ok hover:bg-green-200",
3589
3683
  false: "bg-foreground/5 text-muted-foreground hover:bg-foreground/10",
3590
- error: "bg-wf-fail/10 text-wf-fail hover:bg-red-200"
3684
+ error: "bg-wf-fail/10 text-wf-fail hover:bg-red-200",
3685
+ each: "bg-violet-500/10 text-violet-500 hover:bg-violet-500/20",
3686
+ otherwise: "bg-foreground/5 text-muted-foreground hover:bg-foreground/10"
3591
3687
  };
3688
+ const BRANCH_CLASSES = "bg-wf-run/10 text-wf-run hover:bg-blue-200";
3689
+ function portClasses(port) {
3690
+ return PORT_LABEL_CLASSES[port] ?? (/^branch_\d+$/.test(port) ? BRANCH_CLASSES : void 0);
3691
+ }
3592
3692
  function AddButton(props) {
3593
3693
  const [open, setOpen] = useState(false);
3594
3694
  const anchor = useRef(null);
@@ -3610,7 +3710,7 @@ function AddButton(props) {
3610
3710
  width: size,
3611
3711
  height: size
3612
3712
  },
3613
- 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 ${PORT_LABEL_CLASSES[label] ?? "bg-muted text-muted-foreground hover:bg-foreground/10"}` : "border-foreground/15 bg-card text-foreground hover:border-foreground/25"}`,
3713
+ 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"}`,
3614
3714
  onClick: (event) => {
3615
3715
  event.stopPropagation();
3616
3716
  setOpen((value) => !value);
@@ -3659,6 +3759,7 @@ function useCanvasHandlers() {
3659
3759
  }
3660
3760
  function ApAppendNode(props) {
3661
3761
  const data = props.data;
3762
+ const portName = data.portLabel ?? data.port;
3662
3763
  const handlers = useCanvasHandlers();
3663
3764
  const attachSteps = handlers?.attachableSteps(data.parentId);
3664
3765
  const dragging = useDraggingStep();
@@ -3715,11 +3816,11 @@ function ApAppendNode(props) {
3715
3816
  style: hiddenHandle
3716
3817
  }),
3717
3818
  /* @__PURE__ */ jsx("span", {
3718
- className: `absolute left-3 top-3 rounded px-1.5 text-[10px] font-semibold ${PORT_LABEL_CLASSES[data.port] ?? "bg-muted text-muted-foreground"}`,
3719
- children: data.port
3819
+ className: `absolute left-3 top-3 rounded px-1.5 text-[10px] font-semibold ${portClasses(data.port) ?? "bg-muted text-muted-foreground"}`,
3820
+ children: portName
3720
3821
  }),
3721
3822
  /* @__PURE__ */ jsx(AddButton, {
3722
- title: `Add step (${data.port})`,
3823
+ title: `Add step (${portName})`,
3723
3824
  presets: STEP_PRESETS,
3724
3825
  showPieces: true,
3725
3826
  attachSteps,
@@ -3739,8 +3840,9 @@ function ApAppendNode(props) {
3739
3840
  children: "Add your first step with +"
3740
3841
  }) : null,
3741
3842
  /* @__PURE__ */ jsx(AddButton, {
3742
- title: data.port === "next" ? "Add step" : `Add step (${data.port})`,
3743
- label: data.port === "next" ? void 0 : data.port,
3843
+ title: data.port === "next" && !data.portLabel ? "Add step" : `Add step (${portName})`,
3844
+ label: data.port === "next" && !data.portLabel ? void 0 : portName,
3845
+ port: data.port,
3744
3846
  presets: STEP_PRESETS,
3745
3847
  showPieces: true,
3746
3848
  attachSteps,
@@ -3766,26 +3868,73 @@ function ApBigButtonNode(_props) {
3766
3868
  })]
3767
3869
  });
3768
3870
  }
3871
+ function ApLoopFrameNode(props) {
3872
+ const data = props.data;
3873
+ return /* @__PURE__ */ jsx("div", {
3874
+ style: {
3875
+ width: data.width,
3876
+ height: data.height
3877
+ },
3878
+ className: "pointer-events-none rounded-lg border border-dashed border-violet-500/30 bg-violet-500/[0.03]"
3879
+ });
3880
+ }
3769
3881
  const apNodeTypes = {
3770
3882
  apStep: ApStepNode,
3771
3883
  apAppend: ApAppendNode,
3772
- apBigButton: ApBigButtonNode
3884
+ apBigButton: ApBigButtonNode,
3885
+ apLoopFrame: ApLoopFrameNode
3773
3886
  };
3774
3887
  //#endregion
3775
3888
  //#region editors/workflow-editor/ui/ap-edge.tsx
3889
+ const RADIUS = 15;
3890
+ function roundedPath(points) {
3891
+ const pts = points.filter((p, i) => i === 0 || p[0] !== points[i - 1][0] || p[1] !== points[i - 1][1]);
3892
+ let d = `M ${pts[0][0]} ${pts[0][1]}`;
3893
+ for (let i = 1; i < pts.length - 1; i++) {
3894
+ const [px, py] = pts[i - 1];
3895
+ const [cx, cy] = pts[i];
3896
+ const [nx, ny] = pts[i + 1];
3897
+ const inLen = Math.hypot(cx - px, cy - py);
3898
+ const outLen = Math.hypot(nx - cx, ny - cy);
3899
+ const r = Math.min(RADIUS, inLen / 2, outLen / 2);
3900
+ const ax = cx - (cx - px) / inLen * r;
3901
+ const ay = cy - (cy - py) / inLen * r;
3902
+ const bx = cx + (nx - cx) / outLen * r;
3903
+ const by = cy + (ny - cy) / outLen * r;
3904
+ d += ` L ${ax} ${ay} Q ${cx} ${cy} ${bx} ${by}`;
3905
+ }
3906
+ const [lx, ly] = pts[pts.length - 1];
3907
+ return `${d} L ${lx} ${ly}`;
3908
+ }
3909
+ function lanePath(sx, sy, lane, tx, ty) {
3910
+ const turn = sy + Math.min(30, (ty - sy) / 2);
3911
+ const entry = Math.max(ty - 15, turn);
3912
+ return [
3913
+ roundedPath([
3914
+ [sx, sy],
3915
+ [sx, turn],
3916
+ [lane, turn],
3917
+ [lane, entry],
3918
+ [tx, entry],
3919
+ [tx, ty]
3920
+ ]),
3921
+ (sx + lane) / 2,
3922
+ turn
3923
+ ];
3924
+ }
3776
3925
  function ApEdge(props) {
3777
3926
  const handlers = useCanvasHandlers();
3778
3927
  const data = props.data;
3779
- const [path, labelX, labelY] = getSmoothStepPath({
3928
+ const [path, labelX, labelY] = data.lane !== void 0 && props.targetY > props.sourceY ? lanePath(props.sourceX, props.sourceY, data.lane, props.targetX, props.targetY) : getSmoothStepPath({
3780
3929
  sourceX: props.sourceX,
3781
3930
  sourceY: props.sourceY,
3782
3931
  targetX: props.targetX,
3783
3932
  targetY: props.targetY,
3784
3933
  sourcePosition: Position.Bottom,
3785
3934
  targetPosition: Position.Top,
3786
- borderRadius: 15
3935
+ borderRadius: RADIUS
3787
3936
  });
3788
- const portLabel = data.dead ? `${data.port} · never taken` : data.port !== "next" ? data.port : null;
3937
+ const portLabel = data.dead ? `${data.portLabel ?? data.port} · never taken` : data.port !== "next" || data.portLabel ? data.portLabel ?? data.port : null;
3789
3938
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(BaseEdge, {
3790
3939
  id: props.id,
3791
3940
  path,
@@ -3802,7 +3951,7 @@ function ApEdge(props) {
3802
3951
  className: "nodrag nopan pointer-events-auto absolute flex items-center gap-1",
3803
3952
  style: { transform: `translate(-50%, -50%) translate(${labelX}px, ${labelY}px)` },
3804
3953
  children: [portLabel ? /* @__PURE__ */ jsxs("span", {
3805
- 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" : PORT_LABEL_CLASSES[portLabel] ?? "bg-muted text-muted-foreground"}`,
3954
+ 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"}`,
3806
3955
  title: data.dead ? `The source never leaves on "${data.port}", so no run takes this edge` : void 0,
3807
3956
  children: [portLabel, data.condition ? " ?" : ""]
3808
3957
  }) : null, /* @__PURE__ */ jsx(AddButton, {
@@ -4406,7 +4555,7 @@ function WorkflowEditor() {
4406
4555
  const designTime = useMemo(() => ({
4407
4556
  workflowId,
4408
4557
  getBlockForm: (block) => client.getBlockForm(block),
4409
- loadOptions: (...args) => client.loadBlockOptions(...args),
4558
+ loadOptions: (block, propName, input, connectionId, searchValue, reactorConnectionId) => client.loadBlockOptions(block, propName, input, connectionId, searchValue, reactorConnectionId, workflowId),
4410
4559
  testTrigger: () => client.testTrigger(workflowId, driveId),
4411
4560
  testStep: (stepId) => client.testStep(workflowId, stepId, driveId),
4412
4561
  webhookEndpoint: () => client.fetchWebhookEndpoint(workflowId, driveId),
@@ -4510,4 +4659,4 @@ function Editor({ document }) {
4510
4659
  //#endregion
4511
4660
  export { Editor as default };
4512
4661
 
4513
- //# sourceMappingURL=editor-Dl6lzxkM.js.map
4662
+ //# sourceMappingURL=editor-Yt-_V04R.js.map