@flowdrop/flowdrop 1.0.0

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 (403) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +252 -0
  3. package/dist/adapters/WorkflowAdapter.d.ts +167 -0
  4. package/dist/adapters/WorkflowAdapter.js +368 -0
  5. package/dist/adapters/agentspec/AgentSpecAdapter.d.ts +96 -0
  6. package/dist/adapters/agentspec/AgentSpecAdapter.js +626 -0
  7. package/dist/adapters/agentspec/agentAdapter.d.ts +59 -0
  8. package/dist/adapters/agentspec/agentAdapter.js +91 -0
  9. package/dist/adapters/agentspec/autoLayout.d.ts +34 -0
  10. package/dist/adapters/agentspec/autoLayout.js +127 -0
  11. package/dist/adapters/agentspec/componentTypeDefaults.d.ts +73 -0
  12. package/dist/adapters/agentspec/componentTypeDefaults.js +238 -0
  13. package/dist/adapters/agentspec/defaultNodeTypes.d.ts +53 -0
  14. package/dist/adapters/agentspec/defaultNodeTypes.js +561 -0
  15. package/dist/adapters/agentspec/index.d.ts +37 -0
  16. package/dist/adapters/agentspec/index.js +39 -0
  17. package/dist/adapters/agentspec/validator.d.ts +34 -0
  18. package/dist/adapters/agentspec/validator.js +169 -0
  19. package/dist/api/enhanced-client.d.ts +183 -0
  20. package/dist/api/enhanced-client.js +430 -0
  21. package/dist/components/App.svelte +981 -0
  22. package/dist/components/App.svelte.d.ts +54 -0
  23. package/dist/components/CanvasBanner.stories.svelte +29 -0
  24. package/dist/components/CanvasBanner.stories.svelte.d.ts +27 -0
  25. package/dist/components/CanvasBanner.svelte +57 -0
  26. package/dist/components/CanvasBanner.svelte.d.ts +8 -0
  27. package/dist/components/ConfigForm.svelte +1138 -0
  28. package/dist/components/ConfigForm.svelte.d.ts +44 -0
  29. package/dist/components/ConfigModal.svelte +188 -0
  30. package/dist/components/ConfigModal.svelte.d.ts +13 -0
  31. package/dist/components/ConfigPanel.stories.svelte +47 -0
  32. package/dist/components/ConfigPanel.stories.svelte.d.ts +27 -0
  33. package/dist/components/ConfigPanel.svelte +182 -0
  34. package/dist/components/ConfigPanel.svelte.d.ts +32 -0
  35. package/dist/components/ConnectionLine.svelte +32 -0
  36. package/dist/components/ConnectionLine.svelte.d.ts +3 -0
  37. package/dist/components/EdgeRefresher.svelte +41 -0
  38. package/dist/components/EdgeRefresher.svelte.d.ts +9 -0
  39. package/dist/components/FlowDropZone.svelte +83 -0
  40. package/dist/components/FlowDropZone.svelte.d.ts +13 -0
  41. package/dist/components/LoadingSpinner.stories.svelte +30 -0
  42. package/dist/components/LoadingSpinner.stories.svelte.d.ts +27 -0
  43. package/dist/components/LoadingSpinner.svelte +36 -0
  44. package/dist/components/LoadingSpinner.svelte.d.ts +8 -0
  45. package/dist/components/Logo.stories.svelte +22 -0
  46. package/dist/components/Logo.stories.svelte.d.ts +27 -0
  47. package/dist/components/Logo.svelte +102 -0
  48. package/dist/components/Logo.svelte.d.ts +26 -0
  49. package/dist/components/LogsSidebar.svelte +563 -0
  50. package/dist/components/LogsSidebar.svelte.d.ts +17 -0
  51. package/dist/components/MarkdownDisplay.stories.svelte +36 -0
  52. package/dist/components/MarkdownDisplay.stories.svelte.d.ts +27 -0
  53. package/dist/components/MarkdownDisplay.svelte +29 -0
  54. package/dist/components/MarkdownDisplay.svelte.d.ts +7 -0
  55. package/dist/components/Navbar.stories.svelte +53 -0
  56. package/dist/components/Navbar.stories.svelte.d.ts +27 -0
  57. package/dist/components/Navbar.svelte +726 -0
  58. package/dist/components/Navbar.svelte.d.ts +29 -0
  59. package/dist/components/NodeSidebar.svelte +762 -0
  60. package/dist/components/NodeSidebar.svelte.d.ts +9 -0
  61. package/dist/components/NodeStatusOverlay.stories.svelte +85 -0
  62. package/dist/components/NodeStatusOverlay.stories.svelte.d.ts +27 -0
  63. package/dist/components/NodeStatusOverlay.svelte +327 -0
  64. package/dist/components/NodeStatusOverlay.svelte.d.ts +11 -0
  65. package/dist/components/PipelineStatus.svelte +314 -0
  66. package/dist/components/PipelineStatus.svelte.d.ts +20 -0
  67. package/dist/components/PortCoordinateTracker.svelte +58 -0
  68. package/dist/components/PortCoordinateTracker.svelte.d.ts +12 -0
  69. package/dist/components/ReadOnlyDetails.svelte +170 -0
  70. package/dist/components/ReadOnlyDetails.svelte.d.ts +25 -0
  71. package/dist/components/SchemaForm.stories.svelte +116 -0
  72. package/dist/components/SchemaForm.stories.svelte.d.ts +27 -0
  73. package/dist/components/SchemaForm.svelte +536 -0
  74. package/dist/components/SchemaForm.svelte.d.ts +83 -0
  75. package/dist/components/SettingsModal.svelte +279 -0
  76. package/dist/components/SettingsModal.svelte.d.ts +23 -0
  77. package/dist/components/SettingsPanel.svelte +638 -0
  78. package/dist/components/SettingsPanel.svelte.d.ts +21 -0
  79. package/dist/components/StatusIcon.stories.svelte +60 -0
  80. package/dist/components/StatusIcon.stories.svelte.d.ts +27 -0
  81. package/dist/components/StatusIcon.svelte +119 -0
  82. package/dist/components/StatusIcon.svelte.d.ts +10 -0
  83. package/dist/components/StatusLabel.stories.svelte +17 -0
  84. package/dist/components/StatusLabel.stories.svelte.d.ts +27 -0
  85. package/dist/components/StatusLabel.svelte +33 -0
  86. package/dist/components/StatusLabel.svelte.d.ts +7 -0
  87. package/dist/components/ThemeToggle.stories.svelte +25 -0
  88. package/dist/components/ThemeToggle.stories.svelte.d.ts +27 -0
  89. package/dist/components/ThemeToggle.svelte +185 -0
  90. package/dist/components/ThemeToggle.svelte.d.ts +14 -0
  91. package/dist/components/UniversalNode.svelte +155 -0
  92. package/dist/components/UniversalNode.svelte.d.ts +15 -0
  93. package/dist/components/WorkflowEditor.svelte +1035 -0
  94. package/dist/components/WorkflowEditor.svelte.d.ts +23 -0
  95. package/dist/components/form/FormArray.svelte +1049 -0
  96. package/dist/components/form/FormArray.svelte.d.ts +22 -0
  97. package/dist/components/form/FormAutocomplete.svelte +1009 -0
  98. package/dist/components/form/FormAutocomplete.svelte.d.ts +25 -0
  99. package/dist/components/form/FormCheckboxGroup.stories.svelte +28 -0
  100. package/dist/components/form/FormCheckboxGroup.stories.svelte.d.ts +27 -0
  101. package/dist/components/form/FormCheckboxGroup.svelte +155 -0
  102. package/dist/components/form/FormCheckboxGroup.svelte.d.ts +17 -0
  103. package/dist/components/form/FormCodeEditor.svelte +458 -0
  104. package/dist/components/form/FormCodeEditor.svelte.d.ts +25 -0
  105. package/dist/components/form/FormField.svelte +417 -0
  106. package/dist/components/form/FormField.svelte.d.ts +29 -0
  107. package/dist/components/form/FormFieldLight.svelte +425 -0
  108. package/dist/components/form/FormFieldLight.svelte.d.ts +18 -0
  109. package/dist/components/form/FormFieldWrapper.stories.svelte +53 -0
  110. package/dist/components/form/FormFieldWrapper.stories.svelte.d.ts +27 -0
  111. package/dist/components/form/FormFieldWrapper.svelte +125 -0
  112. package/dist/components/form/FormFieldWrapper.svelte.d.ts +18 -0
  113. package/dist/components/form/FormFieldset.svelte +142 -0
  114. package/dist/components/form/FormFieldset.svelte.d.ts +11 -0
  115. package/dist/components/form/FormMarkdownEditor.svelte +752 -0
  116. package/dist/components/form/FormMarkdownEditor.svelte.d.ts +33 -0
  117. package/dist/components/form/FormNumberField.stories.svelte +36 -0
  118. package/dist/components/form/FormNumberField.stories.svelte.d.ts +27 -0
  119. package/dist/components/form/FormNumberField.svelte +112 -0
  120. package/dist/components/form/FormNumberField.svelte.d.ts +25 -0
  121. package/dist/components/form/FormRangeField.stories.svelte +31 -0
  122. package/dist/components/form/FormRangeField.stories.svelte.d.ts +27 -0
  123. package/dist/components/form/FormRangeField.svelte +246 -0
  124. package/dist/components/form/FormRangeField.svelte.d.ts +23 -0
  125. package/dist/components/form/FormSelect.stories.svelte +50 -0
  126. package/dist/components/form/FormSelect.stories.svelte.d.ts +27 -0
  127. package/dist/components/form/FormSelect.svelte +129 -0
  128. package/dist/components/form/FormSelect.svelte.d.ts +20 -0
  129. package/dist/components/form/FormTemplateEditor.svelte +825 -0
  130. package/dist/components/form/FormTemplateEditor.svelte.d.ts +41 -0
  131. package/dist/components/form/FormTextField.stories.svelte +30 -0
  132. package/dist/components/form/FormTextField.stories.svelte.d.ts +27 -0
  133. package/dist/components/form/FormTextField.svelte +91 -0
  134. package/dist/components/form/FormTextField.svelte.d.ts +19 -0
  135. package/dist/components/form/FormTextarea.stories.svelte +34 -0
  136. package/dist/components/form/FormTextarea.stories.svelte.d.ts +27 -0
  137. package/dist/components/form/FormTextarea.svelte +97 -0
  138. package/dist/components/form/FormTextarea.svelte.d.ts +21 -0
  139. package/dist/components/form/FormToggle.stories.svelte +30 -0
  140. package/dist/components/form/FormToggle.stories.svelte.d.ts +27 -0
  141. package/dist/components/form/FormToggle.svelte +126 -0
  142. package/dist/components/form/FormToggle.svelte.d.ts +19 -0
  143. package/dist/components/form/FormUISchemaRenderer.svelte +136 -0
  144. package/dist/components/form/FormUISchemaRenderer.svelte.d.ts +32 -0
  145. package/dist/components/form/index.d.ts +50 -0
  146. package/dist/components/form/index.js +54 -0
  147. package/dist/components/form/templateAutocomplete.d.ts +29 -0
  148. package/dist/components/form/templateAutocomplete.js +254 -0
  149. package/dist/components/form/types.d.ts +485 -0
  150. package/dist/components/form/types.js +73 -0
  151. package/dist/components/interrupt/ChoicePrompt.stories.svelte +52 -0
  152. package/dist/components/interrupt/ChoicePrompt.stories.svelte.d.ts +27 -0
  153. package/dist/components/interrupt/ChoicePrompt.svelte +401 -0
  154. package/dist/components/interrupt/ChoicePrompt.svelte.d.ts +23 -0
  155. package/dist/components/interrupt/ConfirmationPrompt.stories.svelte +71 -0
  156. package/dist/components/interrupt/ConfirmationPrompt.stories.svelte.d.ts +27 -0
  157. package/dist/components/interrupt/ConfirmationPrompt.svelte +292 -0
  158. package/dist/components/interrupt/ConfirmationPrompt.svelte.d.ts +25 -0
  159. package/dist/components/interrupt/FormPrompt.svelte +236 -0
  160. package/dist/components/interrupt/FormPrompt.svelte.d.ts +23 -0
  161. package/dist/components/interrupt/InterruptBubble.svelte +601 -0
  162. package/dist/components/interrupt/InterruptBubble.svelte.d.ts +16 -0
  163. package/dist/components/interrupt/ReviewPrompt.stories.svelte +67 -0
  164. package/dist/components/interrupt/ReviewPrompt.stories.svelte.d.ts +27 -0
  165. package/dist/components/interrupt/ReviewPrompt.svelte +861 -0
  166. package/dist/components/interrupt/ReviewPrompt.svelte.d.ts +23 -0
  167. package/dist/components/interrupt/TextInputPrompt.stories.svelte +47 -0
  168. package/dist/components/interrupt/TextInputPrompt.stories.svelte.d.ts +27 -0
  169. package/dist/components/interrupt/TextInputPrompt.svelte +346 -0
  170. package/dist/components/interrupt/TextInputPrompt.svelte.d.ts +23 -0
  171. package/dist/components/interrupt/index.d.ts +13 -0
  172. package/dist/components/interrupt/index.js +15 -0
  173. package/dist/components/layouts/MainLayout.svelte +718 -0
  174. package/dist/components/layouts/MainLayout.svelte.d.ts +62 -0
  175. package/dist/components/nodes/GatewayNode.stories.svelte +108 -0
  176. package/dist/components/nodes/GatewayNode.stories.svelte.d.ts +26 -0
  177. package/dist/components/nodes/GatewayNode.svelte +591 -0
  178. package/dist/components/nodes/GatewayNode.svelte.d.ts +15 -0
  179. package/dist/components/nodes/IdeaNode.stories.svelte +52 -0
  180. package/dist/components/nodes/IdeaNode.stories.svelte.d.ts +26 -0
  181. package/dist/components/nodes/IdeaNode.svelte +455 -0
  182. package/dist/components/nodes/IdeaNode.svelte.d.ts +24 -0
  183. package/dist/components/nodes/NotesNode.stories.svelte +76 -0
  184. package/dist/components/nodes/NotesNode.stories.svelte.d.ts +26 -0
  185. package/dist/components/nodes/NotesNode.svelte +378 -0
  186. package/dist/components/nodes/NotesNode.svelte.d.ts +24 -0
  187. package/dist/components/nodes/SimpleNode.stories.svelte +159 -0
  188. package/dist/components/nodes/SimpleNode.stories.svelte.d.ts +26 -0
  189. package/dist/components/nodes/SimpleNode.svelte +451 -0
  190. package/dist/components/nodes/SimpleNode.svelte.d.ts +25 -0
  191. package/dist/components/nodes/SquareNode.stories.svelte +82 -0
  192. package/dist/components/nodes/SquareNode.stories.svelte.d.ts +26 -0
  193. package/dist/components/nodes/SquareNode.svelte +407 -0
  194. package/dist/components/nodes/SquareNode.svelte.d.ts +25 -0
  195. package/dist/components/nodes/TerminalNode.stories.svelte +25 -0
  196. package/dist/components/nodes/TerminalNode.stories.svelte.d.ts +26 -0
  197. package/dist/components/nodes/TerminalNode.svelte +690 -0
  198. package/dist/components/nodes/TerminalNode.svelte.d.ts +25 -0
  199. package/dist/components/nodes/ToolNode.stories.svelte +189 -0
  200. package/dist/components/nodes/ToolNode.stories.svelte.d.ts +26 -0
  201. package/dist/components/nodes/ToolNode.svelte +471 -0
  202. package/dist/components/nodes/ToolNode.svelte.d.ts +36 -0
  203. package/dist/components/nodes/WorkflowNode.stories.svelte +55 -0
  204. package/dist/components/nodes/WorkflowNode.stories.svelte.d.ts +26 -0
  205. package/dist/components/nodes/WorkflowNode.svelte +571 -0
  206. package/dist/components/nodes/WorkflowNode.svelte.d.ts +15 -0
  207. package/dist/components/playground/ChatPanel.svelte +905 -0
  208. package/dist/components/playground/ChatPanel.svelte.d.ts +46 -0
  209. package/dist/components/playground/ExecutionLogs.svelte +488 -0
  210. package/dist/components/playground/ExecutionLogs.svelte.d.ts +14 -0
  211. package/dist/components/playground/InputCollector.svelte +444 -0
  212. package/dist/components/playground/InputCollector.svelte.d.ts +16 -0
  213. package/dist/components/playground/MessageBubble.stories.svelte +62 -0
  214. package/dist/components/playground/MessageBubble.stories.svelte.d.ts +27 -0
  215. package/dist/components/playground/MessageBubble.svelte +633 -0
  216. package/dist/components/playground/MessageBubble.svelte.d.ts +24 -0
  217. package/dist/components/playground/Playground.svelte +1075 -0
  218. package/dist/components/playground/Playground.svelte.d.ts +25 -0
  219. package/dist/components/playground/PlaygroundModal.svelte +220 -0
  220. package/dist/components/playground/PlaygroundModal.svelte.d.ts +25 -0
  221. package/dist/components/playground/SessionManager.svelte +538 -0
  222. package/dist/components/playground/SessionManager.svelte.d.ts +20 -0
  223. package/dist/config/agentSpecEndpoints.d.ts +70 -0
  224. package/dist/config/agentSpecEndpoints.js +65 -0
  225. package/dist/config/constants.d.ts +43 -0
  226. package/dist/config/constants.js +31 -0
  227. package/dist/config/defaultCategories.d.ts +7 -0
  228. package/dist/config/defaultCategories.js +126 -0
  229. package/dist/config/defaultPortConfig.d.ts +6 -0
  230. package/dist/config/defaultPortConfig.js +201 -0
  231. package/dist/config/endpoints.d.ts +160 -0
  232. package/dist/config/endpoints.js +146 -0
  233. package/dist/config/runtimeConfig.d.ts +47 -0
  234. package/dist/config/runtimeConfig.js +80 -0
  235. package/dist/core/index.d.ts +75 -0
  236. package/dist/core/index.js +92 -0
  237. package/dist/display/index.d.ts +29 -0
  238. package/dist/display/index.js +36 -0
  239. package/dist/editor/index.d.ts +95 -0
  240. package/dist/editor/index.js +138 -0
  241. package/dist/form/code.d.ts +101 -0
  242. package/dist/form/code.js +168 -0
  243. package/dist/form/fieldRegistry.d.ts +169 -0
  244. package/dist/form/fieldRegistry.js +152 -0
  245. package/dist/form/full.d.ts +56 -0
  246. package/dist/form/full.js +80 -0
  247. package/dist/form/index.d.ts +77 -0
  248. package/dist/form/index.js +91 -0
  249. package/dist/form/markdown.d.ts +69 -0
  250. package/dist/form/markdown.js +103 -0
  251. package/dist/helpers/nodeLayoutHelper.d.ts +14 -0
  252. package/dist/helpers/nodeLayoutHelper.js +19 -0
  253. package/dist/helpers/proximityConnect.d.ts +94 -0
  254. package/dist/helpers/proximityConnect.js +314 -0
  255. package/dist/helpers/workflowEditorHelper.d.ts +183 -0
  256. package/dist/helpers/workflowEditorHelper.js +595 -0
  257. package/dist/index.d.ts +37 -0
  258. package/dist/index.js +64 -0
  259. package/dist/mocks/app-environment.d.ts +8 -0
  260. package/dist/mocks/app-environment.js +16 -0
  261. package/dist/mocks/app-forms.d.ts +2 -0
  262. package/dist/mocks/app-forms.js +22 -0
  263. package/dist/mocks/app-navigation.d.ts +5 -0
  264. package/dist/mocks/app-navigation.js +36 -0
  265. package/dist/mocks/app-stores.d.ts +14 -0
  266. package/dist/mocks/app-stores.js +26 -0
  267. package/dist/playground/index.d.ts +131 -0
  268. package/dist/playground/index.js +172 -0
  269. package/dist/playground/mount.d.ts +203 -0
  270. package/dist/playground/mount.js +235 -0
  271. package/dist/registry/BaseRegistry.d.ts +92 -0
  272. package/dist/registry/BaseRegistry.js +124 -0
  273. package/dist/registry/builtinFormats.d.ts +23 -0
  274. package/dist/registry/builtinFormats.js +70 -0
  275. package/dist/registry/builtinNodes.d.ts +77 -0
  276. package/dist/registry/builtinNodes.js +211 -0
  277. package/dist/registry/index.d.ts +8 -0
  278. package/dist/registry/index.js +12 -0
  279. package/dist/registry/nodeComponentRegistry.d.ts +276 -0
  280. package/dist/registry/nodeComponentRegistry.js +262 -0
  281. package/dist/registry/plugin.d.ts +215 -0
  282. package/dist/registry/plugin.js +249 -0
  283. package/dist/registry/workflowFormatRegistry.d.ts +122 -0
  284. package/dist/registry/workflowFormatRegistry.js +96 -0
  285. package/dist/schema/index.d.ts +23 -0
  286. package/dist/schema/index.js +23 -0
  287. package/dist/schemas/v1/workflow.schema.json +1078 -0
  288. package/dist/services/agentSpecExecutionService.d.ts +106 -0
  289. package/dist/services/agentSpecExecutionService.js +334 -0
  290. package/dist/services/api.d.ts +115 -0
  291. package/dist/services/api.js +214 -0
  292. package/dist/services/apiVariableService.d.ts +114 -0
  293. package/dist/services/apiVariableService.js +338 -0
  294. package/dist/services/autoSaveService.d.ts +112 -0
  295. package/dist/services/autoSaveService.js +227 -0
  296. package/dist/services/categoriesApi.d.ts +14 -0
  297. package/dist/services/categoriesApi.js +49 -0
  298. package/dist/services/draftStorage.d.ts +171 -0
  299. package/dist/services/draftStorage.js +299 -0
  300. package/dist/services/dynamicSchemaService.d.ts +108 -0
  301. package/dist/services/dynamicSchemaService.js +444 -0
  302. package/dist/services/globalSave.d.ts +69 -0
  303. package/dist/services/globalSave.js +248 -0
  304. package/dist/services/historyService.d.ts +208 -0
  305. package/dist/services/historyService.js +321 -0
  306. package/dist/services/interruptService.d.ts +133 -0
  307. package/dist/services/interruptService.js +280 -0
  308. package/dist/services/nodeExecutionService.d.ts +63 -0
  309. package/dist/services/nodeExecutionService.js +266 -0
  310. package/dist/services/playgroundService.d.ts +130 -0
  311. package/dist/services/playgroundService.js +321 -0
  312. package/dist/services/portConfigApi.d.ts +14 -0
  313. package/dist/services/portConfigApi.js +54 -0
  314. package/dist/services/settingsService.d.ts +92 -0
  315. package/dist/services/settingsService.js +196 -0
  316. package/dist/services/toastService.d.ts +156 -0
  317. package/dist/services/toastService.js +265 -0
  318. package/dist/services/variableService.d.ts +141 -0
  319. package/dist/services/variableService.js +463 -0
  320. package/dist/services/workflowStorage.d.ts +37 -0
  321. package/dist/services/workflowStorage.js +116 -0
  322. package/dist/settings/index.d.ts +25 -0
  323. package/dist/settings/index.js +33 -0
  324. package/dist/stores/categoriesStore.svelte.d.ts +32 -0
  325. package/dist/stores/categoriesStore.svelte.js +77 -0
  326. package/dist/stores/editorStateMachine.svelte.d.ts +42 -0
  327. package/dist/stores/editorStateMachine.svelte.js +132 -0
  328. package/dist/stores/historyStore.svelte.d.ts +136 -0
  329. package/dist/stores/historyStore.svelte.js +207 -0
  330. package/dist/stores/interruptStore.svelte.d.ts +179 -0
  331. package/dist/stores/interruptStore.svelte.js +346 -0
  332. package/dist/stores/playgroundStore.svelte.d.ts +230 -0
  333. package/dist/stores/playgroundStore.svelte.js +515 -0
  334. package/dist/stores/portCoordinateStore.svelte.d.ts +66 -0
  335. package/dist/stores/portCoordinateStore.svelte.js +186 -0
  336. package/dist/stores/settingsStore.svelte.d.ts +158 -0
  337. package/dist/stores/settingsStore.svelte.js +544 -0
  338. package/dist/stores/workflowStore.svelte.d.ts +260 -0
  339. package/dist/stores/workflowStore.svelte.js +649 -0
  340. package/dist/stories/CanvasDecorator.svelte +49 -0
  341. package/dist/stories/CanvasDecorator.svelte.d.ts +8 -0
  342. package/dist/stories/NodeDecorator.svelte +73 -0
  343. package/dist/stories/NodeDecorator.svelte.d.ts +8 -0
  344. package/dist/stories/utils.d.ts +93 -0
  345. package/dist/stories/utils.js +122 -0
  346. package/dist/styles/base.css +1300 -0
  347. package/dist/styles/toast.css +35 -0
  348. package/dist/styles/tokens.css +475 -0
  349. package/dist/svelte-app.d.ts +150 -0
  350. package/dist/svelte-app.js +295 -0
  351. package/dist/types/agentspec.d.ts +318 -0
  352. package/dist/types/agentspec.js +48 -0
  353. package/dist/types/auth.d.ts +263 -0
  354. package/dist/types/auth.js +229 -0
  355. package/dist/types/config.d.ts +151 -0
  356. package/dist/types/config.js +7 -0
  357. package/dist/types/events.d.ts +190 -0
  358. package/dist/types/events.js +30 -0
  359. package/dist/types/index.d.ts +1234 -0
  360. package/dist/types/index.js +27 -0
  361. package/dist/types/interrupt.d.ts +390 -0
  362. package/dist/types/interrupt.js +145 -0
  363. package/dist/types/interruptState.d.ts +211 -0
  364. package/dist/types/interruptState.js +308 -0
  365. package/dist/types/playground.d.ts +351 -0
  366. package/dist/types/playground.js +95 -0
  367. package/dist/types/settings.d.ts +189 -0
  368. package/dist/types/settings.js +97 -0
  369. package/dist/types/uischema.d.ts +144 -0
  370. package/dist/types/uischema.js +51 -0
  371. package/dist/utils/colors.d.ts +288 -0
  372. package/dist/utils/colors.js +548 -0
  373. package/dist/utils/config.d.ts +37 -0
  374. package/dist/utils/config.js +226 -0
  375. package/dist/utils/connections.d.ts +125 -0
  376. package/dist/utils/connections.js +414 -0
  377. package/dist/utils/errors.d.ts +28 -0
  378. package/dist/utils/errors.js +44 -0
  379. package/dist/utils/fetchWithAuth.d.ts +25 -0
  380. package/dist/utils/fetchWithAuth.js +34 -0
  381. package/dist/utils/handleIds.d.ts +35 -0
  382. package/dist/utils/handleIds.js +58 -0
  383. package/dist/utils/handlePositioning.d.ts +31 -0
  384. package/dist/utils/handlePositioning.js +35 -0
  385. package/dist/utils/icons.d.ts +106 -0
  386. package/dist/utils/icons.js +157 -0
  387. package/dist/utils/logger.d.ts +47 -0
  388. package/dist/utils/logger.js +72 -0
  389. package/dist/utils/nodeStatus.d.ts +53 -0
  390. package/dist/utils/nodeStatus.js +183 -0
  391. package/dist/utils/nodeTypes.d.ts +117 -0
  392. package/dist/utils/nodeTypes.js +244 -0
  393. package/dist/utils/nodeWrapper.d.ts +39 -0
  394. package/dist/utils/nodeWrapper.js +62 -0
  395. package/dist/utils/performanceUtils.d.ts +30 -0
  396. package/dist/utils/performanceUtils.js +108 -0
  397. package/dist/utils/sanitize.d.ts +19 -0
  398. package/dist/utils/sanitize.js +31 -0
  399. package/dist/utils/uischema.d.ts +52 -0
  400. package/dist/utils/uischema.js +88 -0
  401. package/dist/utils/validation.d.ts +29 -0
  402. package/dist/utils/validation.js +39 -0
  403. package/package.json +292 -0
@@ -0,0 +1,414 @@
1
+ /**
2
+ * Connection validation utilities for FlowDrop
3
+ */
4
+ /**
5
+ * Loopback port name constant
6
+ * This is the standard input port name used for loop iteration triggers
7
+ */
8
+ const LOOPBACK_PORT_NAME = 'loop_back';
9
+ /**
10
+ * Determines if an edge is a loopback edge.
11
+ * Loopback edges target the special `loop_back` input port on ForEach nodes.
12
+ * These edges are used to trigger the next iteration in a loop construct.
13
+ *
14
+ * @param edge - The edge to check
15
+ * @returns True if the edge is a loopback edge
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const edge = { targetHandle: "foreach.1-input-loop_back", ... };
20
+ * const isLoop = isLoopbackEdge(edge); // true
21
+ * ```
22
+ */
23
+ export function isLoopbackEdge(edge) {
24
+ const targetHandle = edge.targetHandle ?? '';
25
+ return targetHandle.includes(`-input-${LOOPBACK_PORT_NAME}`);
26
+ }
27
+ /**
28
+ * Checks if a cycle consists entirely of loopback edges.
29
+ * A valid loopback cycle only contains edges that target loop_back ports.
30
+ *
31
+ * @param cycleEdges - Array of edges that form a cycle
32
+ * @returns True if all edges in the cycle are loopback edges
33
+ */
34
+ export function isValidLoopbackCycle(cycleEdges) {
35
+ return cycleEdges.every((edge) => isLoopbackEdge(edge));
36
+ }
37
+ /**
38
+ * Configurable port compatibility checker
39
+ */
40
+ export class PortCompatibilityChecker {
41
+ portConfig;
42
+ compatibilityMap;
43
+ constructor(portConfig) {
44
+ this.portConfig = portConfig;
45
+ this.compatibilityMap = new Map();
46
+ this.buildCompatibilityMap();
47
+ }
48
+ /**
49
+ * Build the compatibility map from configuration rules
50
+ */
51
+ buildCompatibilityMap() {
52
+ this.compatibilityMap.clear();
53
+ // First, add direct type matches (every type is compatible with itself)
54
+ for (const dataType of this.portConfig.dataTypes) {
55
+ if (!this.compatibilityMap.has(dataType.id)) {
56
+ this.compatibilityMap.set(dataType.id, new Set());
57
+ }
58
+ this.compatibilityMap.get(dataType.id).add(dataType.id);
59
+ }
60
+ // Then add configured compatibility rules
61
+ for (const rule of this.portConfig.compatibilityRules) {
62
+ if (!this.compatibilityMap.has(rule.from)) {
63
+ this.compatibilityMap.set(rule.from, new Set());
64
+ }
65
+ this.compatibilityMap.get(rule.from).add(rule.to);
66
+ }
67
+ // Add alias support
68
+ for (const dataType of this.portConfig.dataTypes) {
69
+ if (dataType.aliases) {
70
+ for (const alias of dataType.aliases) {
71
+ // Make aliases point to the main type's compatibility set
72
+ const mainCompatibility = this.compatibilityMap.get(dataType.id);
73
+ if (mainCompatibility) {
74
+ this.compatibilityMap.set(alias, new Set(mainCompatibility));
75
+ // Also make the main type compatible with the alias
76
+ mainCompatibility.add(alias);
77
+ }
78
+ }
79
+ }
80
+ }
81
+ }
82
+ /**
83
+ * Check if two data types are compatible for connection
84
+ */
85
+ areDataTypesCompatible(outputType, inputType) {
86
+ const compatibleTypes = this.compatibilityMap.get(outputType);
87
+ return compatibleTypes ? compatibleTypes.has(inputType) : false;
88
+ }
89
+ /**
90
+ * Get all compatible target types for a source type
91
+ */
92
+ getCompatibleTypes(sourceType) {
93
+ const compatibleTypes = this.compatibilityMap.get(sourceType);
94
+ return compatibleTypes ? Array.from(compatibleTypes) : [];
95
+ }
96
+ /**
97
+ * Get data type configuration by ID
98
+ */
99
+ getDataTypeConfig(dataTypeId) {
100
+ return this.portConfig.dataTypes.find((dt) => dt.id === dataTypeId || dt.aliases?.includes(dataTypeId));
101
+ }
102
+ /**
103
+ * Get all enabled data types
104
+ */
105
+ getEnabledDataTypes() {
106
+ return this.portConfig.dataTypes.filter((dt) => dt.enabled !== false);
107
+ }
108
+ }
109
+ // Global instance - will be initialized with configuration
110
+ let globalCompatibilityChecker = null;
111
+ /**
112
+ * Initialize the global port compatibility checker
113
+ */
114
+ export function initializePortCompatibility(portConfig) {
115
+ globalCompatibilityChecker = new PortCompatibilityChecker(portConfig);
116
+ }
117
+ /**
118
+ * Get the global port compatibility checker
119
+ */
120
+ export function getPortCompatibilityChecker() {
121
+ if (!globalCompatibilityChecker) {
122
+ throw new Error('Port compatibility checker not initialized. Call initializePortCompatibility() first.');
123
+ }
124
+ return globalCompatibilityChecker;
125
+ }
126
+ /**
127
+ * Get all possible connections from a source node to target nodes
128
+ */
129
+ export function getPossibleConnections(sourceNode, targetNodes, nodeTypes) {
130
+ const sourceMetadata = nodeTypes.find((nt) => nt.id === sourceNode.data.metadata.id);
131
+ if (!sourceMetadata)
132
+ return [];
133
+ const possibleConnections = [];
134
+ // Get all output ports from source node
135
+ const sourceOutputs = sourceMetadata.outputs;
136
+ // Get the compatibility checker instance
137
+ const checker = getPortCompatibilityChecker();
138
+ // Check each target node
139
+ for (const targetNode of targetNodes) {
140
+ if (targetNode.id === sourceNode.id)
141
+ continue; // Skip self-connection
142
+ const targetMetadata = nodeTypes.find((nt) => nt.id === targetNode.data.metadata.id);
143
+ if (!targetMetadata)
144
+ continue;
145
+ // Get all input ports from target node
146
+ const targetInputs = targetMetadata.inputs;
147
+ // Check each output-input combination
148
+ for (const sourcePort of sourceOutputs) {
149
+ for (const targetPort of targetInputs) {
150
+ const compatible = checker.areDataTypesCompatible(sourcePort.dataType, targetPort.dataType);
151
+ possibleConnections.push({
152
+ sourceNodeId: sourceNode.id,
153
+ sourcePortId: sourcePort.id,
154
+ sourcePort,
155
+ targetNodeId: targetNode.id,
156
+ targetPortId: targetPort.id,
157
+ targetPort,
158
+ compatible
159
+ });
160
+ }
161
+ }
162
+ }
163
+ return possibleConnections;
164
+ }
165
+ /**
166
+ * Validate if a specific connection is valid
167
+ */
168
+ export function validateConnection(sourceNodeId, sourcePortId, targetNodeId, targetPortId, nodes, nodeTypes) {
169
+ // Check if nodes exist
170
+ const sourceNode = nodes.find((n) => n.id === sourceNodeId);
171
+ const targetNode = nodes.find((n) => n.id === targetNodeId);
172
+ if (!sourceNode) {
173
+ return { valid: false, error: 'Source node not found' };
174
+ }
175
+ if (!targetNode) {
176
+ return { valid: false, error: 'Target node not found' };
177
+ }
178
+ // Check for self-connection
179
+ if (sourceNodeId === targetNodeId) {
180
+ return { valid: false, error: 'Cannot connect node to itself' };
181
+ }
182
+ // Get node metadata
183
+ const sourceMetadata = nodeTypes.find((nt) => nt.id === sourceNode.data.metadata.id);
184
+ const targetMetadata = nodeTypes.find((nt) => nt.id === targetNode.data.metadata.id);
185
+ if (!sourceMetadata || !targetMetadata) {
186
+ return { valid: false, error: 'Node metadata not found' };
187
+ }
188
+ // Find ports
189
+ const sourcePort = sourceMetadata.outputs.find((p) => p.id === sourcePortId);
190
+ const targetPort = targetMetadata.inputs.find((p) => p.id === targetPortId);
191
+ if (!sourcePort) {
192
+ return { valid: false, error: 'Source port not found' };
193
+ }
194
+ if (!targetPort) {
195
+ return { valid: false, error: 'Target port not found' };
196
+ }
197
+ // Check data type compatibility using the global checker
198
+ const checker = getPortCompatibilityChecker();
199
+ if (!checker.areDataTypesCompatible(sourcePort.dataType, targetPort.dataType)) {
200
+ return {
201
+ valid: false,
202
+ error: `Incompatible data types: ${sourcePort.dataType} cannot connect to ${targetPort.dataType}`
203
+ };
204
+ }
205
+ return { valid: true };
206
+ }
207
+ /**
208
+ * Get connection suggestions for a node
209
+ */
210
+ export function getConnectionSuggestions(nodeId, nodes, nodeTypes) {
211
+ const node = nodes.find((n) => n.id === nodeId);
212
+ if (!node)
213
+ return [];
214
+ const metadata = nodeTypes.find((nt) => nt.id === node.data.metadata.id);
215
+ if (!metadata)
216
+ return [];
217
+ const suggestions = [];
218
+ // Get all other nodes
219
+ const otherNodes = nodes.filter((n) => n.id !== nodeId);
220
+ // Get the compatibility checker instance
221
+ const checker = getPortCompatibilityChecker();
222
+ for (const otherNode of otherNodes) {
223
+ const otherMetadata = nodeTypes.find((nt) => nt.id === otherNode.data.metadata.id);
224
+ if (!otherMetadata)
225
+ continue;
226
+ // Check outputs from other nodes to inputs of current node
227
+ for (const output of otherMetadata.outputs) {
228
+ for (const input of metadata.inputs) {
229
+ const compatible = checker.areDataTypesCompatible(output.dataType, input.dataType);
230
+ suggestions.push({
231
+ nodeId: otherNode.id,
232
+ nodeName: otherNode.data.label,
233
+ portId: output.id,
234
+ portName: output.name,
235
+ portType: 'output',
236
+ dataType: output.dataType,
237
+ compatible
238
+ });
239
+ }
240
+ }
241
+ // Check outputs from current node to inputs of other nodes
242
+ for (const output of metadata.outputs) {
243
+ for (const input of otherMetadata.inputs) {
244
+ const compatible = checker.areDataTypesCompatible(output.dataType, input.dataType);
245
+ suggestions.push({
246
+ nodeId: otherNode.id,
247
+ nodeName: otherNode.data.label,
248
+ portId: input.id,
249
+ portName: input.name,
250
+ portType: 'input',
251
+ dataType: input.dataType,
252
+ compatible
253
+ });
254
+ }
255
+ }
256
+ }
257
+ return suggestions;
258
+ }
259
+ /**
260
+ * Check if a workflow has any cycles (prevent infinite loops)
261
+ * Note: This function detects ALL cycles, including valid loopback cycles.
262
+ * Use `hasInvalidCycles` to check only for cycles that could cause infinite execution.
263
+ *
264
+ * @param nodes - Array of workflow nodes
265
+ * @param edges - Array of workflow edges
266
+ * @returns True if any cycle exists in the workflow
267
+ */
268
+ export function hasCycles(nodes, edges) {
269
+ // Build adjacency map once (O(E)) so the DFS inner loop is O(1) per lookup
270
+ // instead of scanning all edges on every recursive call (which was O(V*E)).
271
+ const adjacencyMap = new Map();
272
+ for (const node of nodes) {
273
+ adjacencyMap.set(node.id, []);
274
+ }
275
+ for (const edge of edges) {
276
+ const neighbors = adjacencyMap.get(edge.source);
277
+ if (neighbors) {
278
+ neighbors.push(edge.target);
279
+ }
280
+ }
281
+ const visited = new Set();
282
+ const recursionStack = new Set();
283
+ function hasCycleUtil(nodeId) {
284
+ if (recursionStack.has(nodeId))
285
+ return true;
286
+ if (visited.has(nodeId))
287
+ return false;
288
+ visited.add(nodeId);
289
+ recursionStack.add(nodeId);
290
+ // Use pre-built adjacency map instead of filtering all edges each call
291
+ const neighbors = adjacencyMap.get(nodeId) || [];
292
+ for (const target of neighbors) {
293
+ if (hasCycleUtil(target))
294
+ return true;
295
+ }
296
+ recursionStack.delete(nodeId);
297
+ return false;
298
+ }
299
+ // Check each node
300
+ for (const node of nodes) {
301
+ if (!visited.has(node.id)) {
302
+ if (hasCycleUtil(node.id))
303
+ return true;
304
+ }
305
+ }
306
+ return false;
307
+ }
308
+ /**
309
+ * Check if a workflow has any invalid cycles (non-loopback cycles).
310
+ * This excludes valid loopback cycles used for ForEach iteration.
311
+ * Only cycles that could cause infinite execution are detected.
312
+ *
313
+ * @param nodes - Array of workflow nodes
314
+ * @param edges - Array of workflow edges
315
+ * @returns True if any invalid (non-loopback) cycle exists
316
+ *
317
+ * @example
318
+ * ```typescript
319
+ * // A cycle through a loopback edge is valid (returns false)
320
+ * // A cycle through regular data edges is invalid (returns true)
321
+ * const hasInvalid = hasInvalidCycles(nodes, edges);
322
+ * ```
323
+ */
324
+ export function hasInvalidCycles(nodes, edges) {
325
+ // Filter out loopback edges - these create valid cycles for loop iteration
326
+ const nonLoopbackEdges = edges.filter((edge) => !isLoopbackEdge(edge));
327
+ // Build adjacency map from non-loopback edges once (O(E)) so the DFS inner
328
+ // loop is O(1) per lookup instead of scanning all edges on every recursive
329
+ // call (which was O(V*E)).
330
+ const adjacencyMap = new Map();
331
+ for (const node of nodes) {
332
+ adjacencyMap.set(node.id, []);
333
+ }
334
+ for (const edge of nonLoopbackEdges) {
335
+ const neighbors = adjacencyMap.get(edge.source);
336
+ if (neighbors) {
337
+ neighbors.push(edge.target);
338
+ }
339
+ }
340
+ // Check for cycles using only non-loopback edges
341
+ const visited = new Set();
342
+ const recursionStack = new Set();
343
+ /**
344
+ * DFS utility to detect cycles in the graph
345
+ * @param nodeId - Current node being visited
346
+ * @returns True if a cycle is found from this node
347
+ */
348
+ function hasCycleUtil(nodeId) {
349
+ if (recursionStack.has(nodeId))
350
+ return true;
351
+ if (visited.has(nodeId))
352
+ return false;
353
+ visited.add(nodeId);
354
+ recursionStack.add(nodeId);
355
+ // Use pre-built adjacency map instead of filtering all edges each call
356
+ const neighbors = adjacencyMap.get(nodeId) || [];
357
+ for (const target of neighbors) {
358
+ if (hasCycleUtil(target))
359
+ return true;
360
+ }
361
+ recursionStack.delete(nodeId);
362
+ return false;
363
+ }
364
+ // Check each node for cycles
365
+ for (const node of nodes) {
366
+ if (!visited.has(node.id)) {
367
+ if (hasCycleUtil(node.id))
368
+ return true;
369
+ }
370
+ }
371
+ return false;
372
+ }
373
+ /**
374
+ * Get the execution order for a workflow (topological sort)
375
+ */
376
+ export function getExecutionOrder(nodes, edges) {
377
+ const inDegree = new Map();
378
+ const graph = new Map();
379
+ // Initialize
380
+ for (const node of nodes) {
381
+ inDegree.set(node.id, 0);
382
+ graph.set(node.id, []);
383
+ }
384
+ // Build graph and calculate in-degrees
385
+ for (const edge of edges) {
386
+ const current = inDegree.get(edge.target) || 0;
387
+ inDegree.set(edge.target, current + 1);
388
+ const neighbors = graph.get(edge.source) || [];
389
+ neighbors.push(edge.target);
390
+ graph.set(edge.source, neighbors);
391
+ }
392
+ // Topological sort
393
+ const queue = [];
394
+ const result = [];
395
+ // Add nodes with no incoming edges
396
+ for (const [nodeId, degree] of inDegree) {
397
+ if (degree === 0) {
398
+ queue.push(nodeId);
399
+ }
400
+ }
401
+ while (queue.length > 0) {
402
+ const nodeId = queue.shift();
403
+ result.push(nodeId);
404
+ const neighbors = graph.get(nodeId) || [];
405
+ for (const neighbor of neighbors) {
406
+ const degree = inDegree.get(neighbor) - 1;
407
+ inDegree.set(neighbor, degree);
408
+ if (degree === 0) {
409
+ queue.push(neighbor);
410
+ }
411
+ }
412
+ }
413
+ return result;
414
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Error Handling Utilities
3
+ *
4
+ * @module utils/errors
5
+ */
6
+ /**
7
+ * Normalize an unknown caught value into an Error instance.
8
+ *
9
+ * Use in catch blocks where the error type is `unknown`:
10
+ * ```typescript
11
+ * try { ... } catch (error) {
12
+ * const err = normalizeError(error);
13
+ * logger.error(err.message);
14
+ * }
15
+ * ```
16
+ *
17
+ * @param error - The caught value (may be Error, string, or anything)
18
+ * @returns An Error instance with a meaningful message
19
+ */
20
+ export declare function normalizeError(error: unknown): Error;
21
+ /**
22
+ * Extract a human-readable message from an unknown error.
23
+ *
24
+ * @param error - The caught value
25
+ * @param fallback - Fallback message if error has no useful info
26
+ * @returns A string message
27
+ */
28
+ export declare function getErrorMessage(error: unknown, fallback?: string): string;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Error Handling Utilities
3
+ *
4
+ * @module utils/errors
5
+ */
6
+ /**
7
+ * Normalize an unknown caught value into an Error instance.
8
+ *
9
+ * Use in catch blocks where the error type is `unknown`:
10
+ * ```typescript
11
+ * try { ... } catch (error) {
12
+ * const err = normalizeError(error);
13
+ * logger.error(err.message);
14
+ * }
15
+ * ```
16
+ *
17
+ * @param error - The caught value (may be Error, string, or anything)
18
+ * @returns An Error instance with a meaningful message
19
+ */
20
+ export function normalizeError(error) {
21
+ if (error instanceof Error) {
22
+ return error;
23
+ }
24
+ if (typeof error === 'string') {
25
+ return new Error(error);
26
+ }
27
+ return new Error(String(error));
28
+ }
29
+ /**
30
+ * Extract a human-readable message from an unknown error.
31
+ *
32
+ * @param error - The caught value
33
+ * @param fallback - Fallback message if error has no useful info
34
+ * @returns A string message
35
+ */
36
+ export function getErrorMessage(error, fallback = 'Unknown error') {
37
+ if (error instanceof Error) {
38
+ return error.message;
39
+ }
40
+ if (typeof error === 'string') {
41
+ return error;
42
+ }
43
+ return fallback;
44
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Fetch authentication utilities
3
+ *
4
+ * Shared logic for building HTTP headers with authentication.
5
+ * Used by components that make authenticated API requests (e.g., FormAutocomplete).
6
+ *
7
+ * @module utils/fetchWithAuth
8
+ */
9
+ import type { AuthProvider } from '../types/auth.js';
10
+ /**
11
+ * Build fetch headers with optional authentication
12
+ *
13
+ * Constructs standard JSON request headers and merges in authentication
14
+ * headers from the provided AuthProvider, if available.
15
+ *
16
+ * @param authProvider - Optional auth provider to get headers from
17
+ * @returns Promise resolving to a complete headers object
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const headers = await buildFetchHeaders(authProvider);
22
+ * const response = await fetch(url, { headers });
23
+ * ```
24
+ */
25
+ export declare function buildFetchHeaders(authProvider?: AuthProvider): Promise<Record<string, string>>;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Fetch authentication utilities
3
+ *
4
+ * Shared logic for building HTTP headers with authentication.
5
+ * Used by components that make authenticated API requests (e.g., FormAutocomplete).
6
+ *
7
+ * @module utils/fetchWithAuth
8
+ */
9
+ /**
10
+ * Build fetch headers with optional authentication
11
+ *
12
+ * Constructs standard JSON request headers and merges in authentication
13
+ * headers from the provided AuthProvider, if available.
14
+ *
15
+ * @param authProvider - Optional auth provider to get headers from
16
+ * @returns Promise resolving to a complete headers object
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const headers = await buildFetchHeaders(authProvider);
21
+ * const response = await fetch(url, { headers });
22
+ * ```
23
+ */
24
+ export async function buildFetchHeaders(authProvider) {
25
+ const headers = {
26
+ Accept: 'application/json',
27
+ 'Content-Type': 'application/json'
28
+ };
29
+ if (authProvider) {
30
+ const authHeaders = await authProvider.getAuthHeaders();
31
+ Object.assign(headers, authHeaders);
32
+ }
33
+ return headers;
34
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Handle ID utilities for FlowDrop
3
+ *
4
+ * Handle IDs encode node + direction + port in the format:
5
+ * `${nodeId}-${direction}-${portId}` (e.g., "node1-output-trigger")
6
+ *
7
+ * @module utils/handleIds
8
+ */
9
+ /**
10
+ * Build a handle ID from its parts.
11
+ *
12
+ * @param nodeId - The node identifier
13
+ * @param direction - 'input' or 'output'
14
+ * @param portId - The port identifier
15
+ * @returns A composite handle ID string
16
+ */
17
+ export declare function buildHandleId(nodeId: string, direction: 'input' | 'output', portId: string): string;
18
+ /**
19
+ * Extract the port ID from a composite handle ID.
20
+ *
21
+ * Supports two formats:
22
+ * 1. Standard: `${nodeId}-output-${portId}` or `${nodeId}-input-${portId}`
23
+ * 2. Short: just the portId itself (returned as-is)
24
+ *
25
+ * @param handleId - The handle ID string
26
+ * @returns The port ID, or null if handleId is empty/undefined
27
+ */
28
+ export declare function extractPortId(handleId: string | undefined): string | null;
29
+ /**
30
+ * Extract the direction from a composite handle ID.
31
+ *
32
+ * @param handleId - The handle ID string
33
+ * @returns 'input', 'output', or null if not found
34
+ */
35
+ export declare function extractDirection(handleId: string | undefined): 'input' | 'output' | null;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Handle ID utilities for FlowDrop
3
+ *
4
+ * Handle IDs encode node + direction + port in the format:
5
+ * `${nodeId}-${direction}-${portId}` (e.g., "node1-output-trigger")
6
+ *
7
+ * @module utils/handleIds
8
+ */
9
+ /**
10
+ * Build a handle ID from its parts.
11
+ *
12
+ * @param nodeId - The node identifier
13
+ * @param direction - 'input' or 'output'
14
+ * @param portId - The port identifier
15
+ * @returns A composite handle ID string
16
+ */
17
+ export function buildHandleId(nodeId, direction, portId) {
18
+ return `${nodeId}-${direction}-${portId}`;
19
+ }
20
+ /**
21
+ * Extract the port ID from a composite handle ID.
22
+ *
23
+ * Supports two formats:
24
+ * 1. Standard: `${nodeId}-output-${portId}` or `${nodeId}-input-${portId}`
25
+ * 2. Short: just the portId itself (returned as-is)
26
+ *
27
+ * @param handleId - The handle ID string
28
+ * @returns The port ID, or null if handleId is empty/undefined
29
+ */
30
+ export function extractPortId(handleId) {
31
+ if (!handleId)
32
+ return null;
33
+ const outputMatch = handleId.lastIndexOf('-output-');
34
+ if (outputMatch !== -1) {
35
+ return handleId.substring(outputMatch + '-output-'.length);
36
+ }
37
+ const inputMatch = handleId.lastIndexOf('-input-');
38
+ if (inputMatch !== -1) {
39
+ return handleId.substring(inputMatch + '-input-'.length);
40
+ }
41
+ // Short format: the handleId IS the port ID
42
+ return handleId;
43
+ }
44
+ /**
45
+ * Extract the direction from a composite handle ID.
46
+ *
47
+ * @param handleId - The handle ID string
48
+ * @returns 'input', 'output', or null if not found
49
+ */
50
+ export function extractDirection(handleId) {
51
+ if (!handleId)
52
+ return null;
53
+ if (handleId.includes('-output-'))
54
+ return 'output';
55
+ if (handleId.includes('-input-'))
56
+ return 'input';
57
+ return null;
58
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Utility functions for calculating handle positions on nodes
3
+ */
4
+ export interface HandlePosition {
5
+ left: number;
6
+ top: number;
7
+ }
8
+ /**
9
+ * Calculate handle position along a circle arc using cos/sin
10
+ *
11
+ * Distributes handles evenly along an arc on the left or right side of a circle.
12
+ * For N handles, they are positioned at angles calculated as:
13
+ * angle = centerAngle - arcSpan/2 + arcSpan * (index + 1) / (count + 1)
14
+ *
15
+ * @param index - The index of the handle (0-based)
16
+ * @param count - Total number of handles on this side
17
+ * @param side - 'left' for inputs, 'right' for outputs
18
+ * @param radius - The radius of the circle (default: 40px for 80px diameter)
19
+ * @param arcSpan - The arc span in radians (default: 5π/6 = 150°)
20
+ * @returns Object with left and top pixel values relative to the circle's bounding box
21
+ *
22
+ * @example
23
+ * // Single handle on left side - positioned at center (180°)
24
+ * getCircleHandlePosition(0, 1, 'left') // { left: 0, top: 36 }
25
+ *
26
+ * @example
27
+ * // Two handles on left side - positioned at 150° and 210°
28
+ * getCircleHandlePosition(0, 2, 'left') // { left: ~4.8, top: ~18 }
29
+ * getCircleHandlePosition(1, 2, 'left') // { left: ~4.8, top: ~54 }
30
+ */
31
+ export declare function getCircleHandlePosition(index: number, count: number, side: 'left' | 'right', radius?: number, arcSpan?: number): HandlePosition;