@flowdrop/flowdrop 2.0.0-beta.1 → 2.0.0-beta.10

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 (228) hide show
  1. package/CHANGELOG.md +173 -0
  2. package/MIGRATION-2.0.md +173 -3
  3. package/README.md +5 -5
  4. package/dist/adapters/WorkflowAdapter.js +4 -5
  5. package/dist/adapters/agentspec/AgentSpecAdapter.js +3 -3
  6. package/dist/adapters/agentspec/defaultNodeTypes.js +9 -9
  7. package/dist/api/enhanced-client.js +6 -11
  8. package/dist/commands/executor.js +51 -26
  9. package/dist/commands/storeIntegration.svelte.js +11 -1
  10. package/dist/commands/types.js +5 -5
  11. package/dist/components/App.svelte +547 -386
  12. package/dist/components/App.svelte.d.ts +16 -8
  13. package/dist/components/Button.stories.svelte +65 -0
  14. package/dist/components/Button.stories.svelte.d.ts +19 -0
  15. package/dist/components/Button.svelte +62 -0
  16. package/dist/components/Button.svelte.d.ts +24 -0
  17. package/dist/components/CanvasIconButton.svelte +76 -0
  18. package/dist/components/CanvasIconButton.svelte.d.ts +18 -0
  19. package/dist/components/ConfigForm.svelte +167 -562
  20. package/dist/components/ConfigForm.svelte.d.ts +24 -7
  21. package/dist/components/ConfigModal.svelte +9 -1
  22. package/dist/components/ConfigPanel.svelte +234 -15
  23. package/dist/components/ConfigPanel.svelte.d.ts +6 -0
  24. package/dist/components/EditorStatusBar.stories.svelte +44 -0
  25. package/dist/components/EditorStatusBar.stories.svelte.d.ts +27 -0
  26. package/dist/components/EditorStatusBar.svelte +99 -0
  27. package/dist/components/EditorStatusBar.svelte.d.ts +15 -0
  28. package/dist/components/IconButton.svelte +80 -0
  29. package/dist/components/IconButton.svelte.d.ts +30 -0
  30. package/dist/components/Input.svelte +74 -0
  31. package/dist/components/Input.svelte.d.ts +17 -0
  32. package/dist/components/LogoWordmark.svelte +113 -0
  33. package/dist/components/LogoWordmark.svelte.d.ts +26 -0
  34. package/dist/components/Navbar.svelte +17 -63
  35. package/dist/components/Navbar.svelte.d.ts +3 -0
  36. package/dist/components/NodeSidebar.svelte +21 -126
  37. package/dist/components/NodeSwapPicker.svelte +12 -30
  38. package/dist/components/PipelineStatus.svelte +6 -1
  39. package/dist/components/PipelineStatus.svelte.d.ts +3 -0
  40. package/dist/components/PortMappingRow.svelte +0 -2
  41. package/dist/components/SchemaForm.svelte +4 -14
  42. package/dist/components/Select.svelte +53 -0
  43. package/dist/components/Select.svelte.d.ts +15 -0
  44. package/dist/components/SettingsModal.svelte +0 -5
  45. package/dist/components/SettingsPanel.svelte +24 -6
  46. package/dist/components/Textarea.svelte +39 -0
  47. package/dist/components/Textarea.svelte.d.ts +12 -0
  48. package/dist/components/ThemeToggle.svelte +15 -94
  49. package/dist/components/UniversalNode.svelte +36 -4
  50. package/dist/components/UniversalNode.svelte.d.ts +1 -1
  51. package/dist/components/WorkflowEditor.svelte +66 -52
  52. package/dist/components/WorkflowEditor.svelte.d.ts +21 -0
  53. package/dist/components/chat/AIChatPanel.svelte +7 -2
  54. package/dist/components/console/ConsoleAutocomplete.svelte +1 -1
  55. package/dist/components/console/ConsoleInput.svelte +3 -3
  56. package/dist/components/console/ConsoleOutput.svelte +2 -2
  57. package/dist/components/form/FormArray.svelte +37 -173
  58. package/dist/components/form/FormAutocomplete.svelte +18 -15
  59. package/dist/components/form/FormCheckboxGroup.svelte +1 -5
  60. package/dist/components/form/FormCodeEditor.svelte +9 -7
  61. package/dist/components/form/FormField.svelte +18 -42
  62. package/dist/components/form/FormFieldLight.svelte +52 -48
  63. package/dist/components/form/FormFieldLight.svelte.d.ts +12 -0
  64. package/dist/components/form/FormFieldset.svelte +45 -11
  65. package/dist/components/form/FormMarkdownEditor.svelte +8 -5
  66. package/dist/components/form/FormNumberField.svelte +4 -36
  67. package/dist/components/form/FormPorts.svelte +262 -0
  68. package/dist/components/form/FormPorts.svelte.d.ts +13 -0
  69. package/dist/components/form/FormRangeField.svelte +61 -30
  70. package/dist/components/form/FormSelect.svelte +13 -75
  71. package/dist/components/form/FormTemplateEditor.svelte +6 -4
  72. package/dist/components/form/FormTextField.svelte +3 -35
  73. package/dist/components/form/FormTextarea.svelte +4 -39
  74. package/dist/components/form/FormToggle.svelte +0 -4
  75. package/dist/components/form/FormUISchemaRenderer.svelte +3 -1
  76. package/dist/components/form/resolveFieldType.d.ts +24 -0
  77. package/dist/components/form/resolveFieldType.js +55 -0
  78. package/dist/components/icons/CloseIcon.svelte +6 -0
  79. package/dist/components/icons/CloseIcon.svelte.d.ts +26 -0
  80. package/dist/components/icons/CommandLineIcon.svelte +15 -0
  81. package/dist/components/icons/CommandLineIcon.svelte.d.ts +26 -0
  82. package/dist/components/icons/MenuIcon.svelte +4 -0
  83. package/dist/components/icons/MenuIcon.svelte.d.ts +26 -0
  84. package/dist/components/icons/MenuOpenIcon.svelte +6 -0
  85. package/dist/components/icons/MenuOpenIcon.svelte.d.ts +26 -0
  86. package/dist/components/interrupt/ChoicePrompt.svelte +0 -10
  87. package/dist/components/interrupt/ConfirmationPrompt.svelte +0 -5
  88. package/dist/components/interrupt/InterruptBubble.svelte +11 -12
  89. package/dist/components/interrupt/ReviewPrompt.svelte +0 -20
  90. package/dist/components/interrupt/TextInputPrompt.svelte +0 -6
  91. package/dist/components/layouts/MainLayout.svelte +4 -5
  92. package/dist/components/nodes/AtomNode.svelte +62 -76
  93. package/dist/components/nodes/AtomNode.svelte.d.ts +1 -1
  94. package/dist/components/nodes/GatewayNode.svelte +117 -164
  95. package/dist/components/nodes/GatewayNode.svelte.d.ts +1 -1
  96. package/dist/components/nodes/IdeaNode.svelte +72 -98
  97. package/dist/components/nodes/IdeaNode.svelte.d.ts +8 -4
  98. package/dist/components/nodes/NodeConfigButton.svelte +86 -0
  99. package/dist/components/nodes/NodeConfigButton.svelte.d.ts +15 -0
  100. package/dist/components/nodes/NotesNode.svelte +76 -85
  101. package/dist/components/nodes/NotesNode.svelte.d.ts +8 -4
  102. package/dist/components/nodes/SimpleNode.svelte +59 -133
  103. package/dist/components/nodes/SimpleNode.svelte.d.ts +4 -4
  104. package/dist/components/nodes/SquareNode.svelte +110 -164
  105. package/dist/components/nodes/SquareNode.svelte.d.ts +4 -4
  106. package/dist/components/nodes/TerminalNode.svelte +62 -124
  107. package/dist/components/nodes/TerminalNode.svelte.d.ts +4 -4
  108. package/dist/components/nodes/ToolNode.svelte +92 -103
  109. package/dist/components/nodes/ToolNode.svelte.d.ts +6 -6
  110. package/dist/components/nodes/WorkflowNode.svelte +132 -191
  111. package/dist/components/nodes/WorkflowNode.svelte.d.ts +1 -1
  112. package/dist/components/playground/ChatInput.svelte +0 -1
  113. package/dist/components/playground/InputCollector.svelte +11 -48
  114. package/dist/components/playground/PipelineKanbanView.svelte +6 -4
  115. package/dist/components/playground/PipelineKanbanView.svelte.d.ts +2 -0
  116. package/dist/components/playground/PipelinePanel.svelte +20 -3
  117. package/dist/components/playground/PipelinePanel.svelte.d.ts +2 -0
  118. package/dist/components/playground/PipelineTableView.svelte +6 -4
  119. package/dist/components/playground/PipelineTableView.svelte.d.ts +2 -0
  120. package/dist/components/playground/Playground.svelte +76 -25
  121. package/dist/components/playground/Playground.svelte.d.ts +3 -0
  122. package/dist/components/playground/PlaygroundApp.svelte +6 -1
  123. package/dist/components/playground/PlaygroundApp.svelte.d.ts +3 -0
  124. package/dist/components/playground/PlaygroundModal.svelte +5 -0
  125. package/dist/components/playground/PlaygroundModal.svelte.d.ts +3 -0
  126. package/dist/components/playground/PlaygroundStudio.svelte +7 -6
  127. package/dist/components/playground/PlaygroundStudio.svelte.d.ts +3 -0
  128. package/dist/components/playground/pipelineViewUtils.svelte.d.ts +2 -1
  129. package/dist/components/playground/pipelineViewUtils.svelte.js +2 -2
  130. package/dist/components/surfaces/SurfaceOverlay.svelte +153 -0
  131. package/dist/components/surfaces/SurfaceOverlay.svelte.d.ts +14 -0
  132. package/dist/components/surfaces/TabbedSurface.svelte +133 -0
  133. package/dist/components/surfaces/TabbedSurface.svelte.d.ts +27 -0
  134. package/dist/config/endpoints.d.ts +23 -0
  135. package/dist/config/endpoints.js +28 -0
  136. package/dist/core/index.d.ts +2 -3
  137. package/dist/core/index.js +2 -6
  138. package/dist/display/index.d.ts +6 -1
  139. package/dist/display/index.js +9 -1
  140. package/dist/editor/index.d.ts +1 -1
  141. package/dist/editor/index.js +1 -1
  142. package/dist/form/full.d.ts +2 -1
  143. package/dist/form/full.js +4 -1
  144. package/dist/form/index.d.ts +0 -1
  145. package/dist/form/index.js +3 -2
  146. package/dist/helpers/workflowEditorHelper.d.ts +4 -2
  147. package/dist/helpers/workflowEditorHelper.js +8 -8
  148. package/dist/messages/index.d.ts +1 -1
  149. package/dist/messages/index.js +1 -1
  150. package/dist/openapi/v1/openapi.yaml +35 -23
  151. package/dist/playground/index.d.ts +2 -2
  152. package/dist/playground/index.js +2 -2
  153. package/dist/playground/mount.d.ts +19 -5
  154. package/dist/playground/mount.js +16 -8
  155. package/dist/registry/builtinNodeTypes.d.ts +53 -0
  156. package/dist/registry/builtinNodeTypes.js +67 -0
  157. package/dist/registry/builtinNodes.d.ts +2 -39
  158. package/dist/registry/builtinNodes.js +6 -53
  159. package/dist/registry/nodeComponentRegistry.d.ts +2 -1
  160. package/dist/schemas/v1/workflow.schema.json +16 -14
  161. package/dist/services/agentSpecExecutionService.d.ts +0 -2
  162. package/dist/services/agentSpecExecutionService.js +0 -2
  163. package/dist/services/apiVariableService.js +12 -26
  164. package/dist/services/categoriesApi.js +3 -6
  165. package/dist/services/chatService.d.ts +4 -3
  166. package/dist/services/chatService.js +13 -18
  167. package/dist/services/dynamicSchemaService.d.ts +31 -4
  168. package/dist/services/dynamicSchemaService.js +62 -33
  169. package/dist/services/historyService.d.ts +30 -8
  170. package/dist/services/historyService.js +51 -15
  171. package/dist/services/interruptService.d.ts +7 -6
  172. package/dist/services/interruptService.js +19 -21
  173. package/dist/services/playgroundService.d.ts +9 -8
  174. package/dist/services/playgroundService.js +23 -25
  175. package/dist/services/portConfigApi.js +3 -6
  176. package/dist/services/settingsService.d.ts +9 -4
  177. package/dist/services/settingsService.js +23 -12
  178. package/dist/skins/drafter.d.ts +30 -0
  179. package/dist/skins/drafter.js +198 -0
  180. package/dist/skins/index.d.ts +2 -1
  181. package/dist/skins/index.js +4 -2
  182. package/dist/stores/apiContext.d.ts +11 -0
  183. package/dist/stores/apiContext.js +15 -0
  184. package/dist/stores/categoriesStore.svelte.js +0 -1
  185. package/dist/stores/historyStore.svelte.d.ts +17 -3
  186. package/dist/stores/historyStore.svelte.js +30 -3
  187. package/dist/stores/instanceContainer.svelte.js +5 -0
  188. package/dist/stores/playgroundStore.svelte.js +1 -3
  189. package/dist/stores/settingsStore.svelte.d.ts +13 -0
  190. package/dist/stores/settingsStore.svelte.js +32 -0
  191. package/dist/stores/workflowStore.svelte.d.ts +42 -5
  192. package/dist/stores/workflowStore.svelte.js +109 -32
  193. package/dist/styles/base.css +285 -14
  194. package/dist/styles/tokens.css +60 -2
  195. package/dist/svelte-app.d.ts +18 -1
  196. package/dist/svelte-app.js +75 -110
  197. package/dist/themes/drafter.d.ts +2 -0
  198. package/dist/themes/drafter.js +15 -0
  199. package/dist/themes/index.d.ts +2 -1
  200. package/dist/themes/index.js +8 -2
  201. package/dist/types/auth.d.ts +9 -51
  202. package/dist/types/auth.js +4 -54
  203. package/dist/types/events.d.ts +18 -0
  204. package/dist/types/events.js +2 -1
  205. package/dist/types/index.d.ts +84 -29
  206. package/dist/types/index.js +0 -1
  207. package/dist/types/settings.d.ts +17 -1
  208. package/dist/types/settings.js +4 -2
  209. package/dist/types/skin.d.ts +1 -1
  210. package/dist/types/theme.d.ts +16 -2
  211. package/dist/types/uischema.d.ts +5 -0
  212. package/dist/utils/colors.d.ts +27 -0
  213. package/dist/utils/colors.js +23 -0
  214. package/dist/utils/connections.js +20 -56
  215. package/dist/utils/edgeStyling.js +9 -5
  216. package/dist/utils/fetchWithAuth.d.ts +36 -15
  217. package/dist/utils/fetchWithAuth.js +53 -23
  218. package/dist/utils/nodeIds.d.ts +1 -1
  219. package/dist/utils/nodeIds.js +1 -1
  220. package/dist/utils/nodeSwap.js +3 -6
  221. package/dist/utils/nodeTypes.js +1 -1
  222. package/dist/utils/portUtils.d.ts +47 -11
  223. package/dist/utils/portUtils.js +67 -14
  224. package/dist/utils/portal.d.ts +18 -0
  225. package/dist/utils/portal.js +34 -0
  226. package/dist/utils/schemaMerge.d.ts +25 -0
  227. package/dist/utils/schemaMerge.js +61 -0
  228. package/package.json +2 -1
@@ -1,34 +1,64 @@
1
1
  /**
2
- * Fetch authentication utilities
2
+ * Authenticated fetch
3
3
  *
4
- * Shared logic for building HTTP headers with authentication.
5
- * Used by components that make authenticated API requests (e.g., FormAutocomplete).
4
+ * The single fetch path for FlowDrop's per-instance services. It builds request
5
+ * headers (static endpoint headers + the {@link AuthProvider}'s headers + any
6
+ * caller headers) and uniformly applies the auth lifecycle: on `401` it invokes
7
+ * `onUnauthorized()` and — if that reports a successful refresh — retries the
8
+ * request once with freshly fetched headers; on `403` it invokes
9
+ * `onForbidden()`. Callers receive the raw {@link Response} and keep their own
10
+ * status/parse handling.
11
+ *
12
+ * Routing every service through this helper means a configured `AuthProvider`
13
+ * authenticates *and* refreshes consistently — matching the behaviour the typed
14
+ * workflow/node API gets from {@link EnhancedFlowDropApiClient}.
6
15
  *
7
16
  * @module utils/fetchWithAuth
8
17
  */
18
+ import { getEndpointHeaders } from '../config/endpoints.js';
19
+ const DEFAULT_HEADERS = {
20
+ Accept: 'application/json',
21
+ 'Content-Type': 'application/json'
22
+ };
9
23
  /**
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
24
+ * Build the merged header set: base headers < auth headers < per-request headers.
17
25
  *
18
- * @example
19
- * ```typescript
20
- * const headers = await buildFetchHeaders(authProvider);
21
- * const response = await fetch(url, { headers });
22
- * ```
26
+ * Re-invoked for the retry so a refreshed token is picked up.
23
27
  */
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);
28
+ async function buildHeaders(init, opts) {
29
+ const headers = opts.config && opts.endpointKey
30
+ ? getEndpointHeaders(opts.config, opts.endpointKey)
31
+ : { ...DEFAULT_HEADERS, ...opts.baseHeaders };
32
+ if (opts.authProvider) {
33
+ Object.assign(headers, await opts.authProvider.getAuthHeaders());
34
+ }
35
+ if (init.headers) {
36
+ Object.assign(headers, init.headers);
32
37
  }
33
38
  return headers;
34
39
  }
40
+ /**
41
+ * Perform an authenticated fetch with consistent 401/403 handling.
42
+ *
43
+ * @param url - The fully-resolved request URL
44
+ * @param init - Standard fetch options (method, body, signal, headers, …)
45
+ * @param opts - Auth provider and header source
46
+ * @returns The raw {@link Response}; callers handle `.ok`/parsing themselves
47
+ */
48
+ export async function authenticatedFetch(url, init = {}, opts = {}) {
49
+ const headers = await buildHeaders(init, opts);
50
+ let response = await fetch(url, { ...init, headers });
51
+ // 401 → let the provider refresh, then retry once with fresh headers.
52
+ if (response.status === 401 && opts.authProvider?.onUnauthorized) {
53
+ const refreshed = await opts.authProvider.onUnauthorized();
54
+ if (refreshed) {
55
+ const retryHeaders = await buildHeaders(init, opts);
56
+ response = await fetch(url, { ...init, headers: retryHeaders });
57
+ }
58
+ }
59
+ // 403 → notify the provider (e.g. surface a permission error).
60
+ if (response.status === 403 && opts.authProvider?.onForbidden) {
61
+ await opts.authProvider.onForbidden();
62
+ }
63
+ return response;
64
+ }
@@ -12,7 +12,7 @@ interface NodeWithMetadata {
12
12
  id: string;
13
13
  data?: {
14
14
  metadata?: {
15
- id?: string;
15
+ node_type_id?: string;
16
16
  };
17
17
  };
18
18
  }
@@ -11,7 +11,7 @@
11
11
  export function generateNodeId(nodeTypeId, existingNodes) {
12
12
  // Count how many nodes of this type already exist
13
13
  const existingNodeIds = existingNodes
14
- .filter((node) => node.data?.metadata?.id === nodeTypeId)
14
+ .filter((node) => node.data?.metadata?.node_type_id === nodeTypeId)
15
15
  .map((node) => node.id);
16
16
  // Extract the numbers from existing IDs with the same prefix
17
17
  const existingNumbers = existingNodeIds
@@ -176,9 +176,6 @@ export function executeSwap(oldNode, newMetadata, preview, allNodes, allEdges) {
176
176
  label: newMetadata.name,
177
177
  config: mappedConfig,
178
178
  metadata: newMetadata,
179
- // Node components derive their handle IDs from data.nodeId — without it
180
- // every edge anchored to this node silently disappears from the canvas.
181
- nodeId: newNodeId,
182
179
  extensions
183
180
  }
184
181
  };
@@ -218,7 +215,7 @@ export function executeSwap(oldNode, newMetadata, preview, allNodes, allEdges) {
218
215
  * @returns The newer NodeMetadata if an upgrade is available, null otherwise
219
216
  */
220
217
  export function getVersionUpgrade(currentMetadata, allNodeTypes) {
221
- const available = allNodeTypes.find((n) => n.id === currentMetadata.id);
218
+ const available = allNodeTypes.find((n) => n.node_type_id === currentMetadata.node_type_id);
222
219
  if (!available)
223
220
  return null;
224
221
  if (compareSemver(available.version, currentMetadata.version) > 0) {
@@ -253,7 +250,7 @@ function classifyMatch(oldPort, matchedPort) {
253
250
  export function computeSwapPreviewWithOptions(oldNode, newMetadata, edges, allNodes, options) {
254
251
  const checker = options.checker ?? null;
255
252
  const oldNodeId = oldNode.id;
256
- const newNodeId = generateNodeId(newMetadata.id, allNodes);
253
+ const newNodeId = generateNodeId(newMetadata.node_type_id, allNodes);
257
254
  // Collect connected edges
258
255
  const connectedEdges = edges.filter((e) => e.source === oldNodeId || e.target === oldNodeId);
259
256
  // Try strategy-based port mapping
@@ -420,7 +417,7 @@ export function computeSwapPreviewWithOptions(oldNode, newMetadata, edges, allNo
420
417
  */
421
418
  export function computeInteractiveState(oldNode, newMetadata, edges, allNodes, options = {}) {
422
419
  const oldNodeId = oldNode.id;
423
- const newNodeId = generateNodeId(newMetadata.id, allNodes);
420
+ const newNodeId = generateNodeId(newMetadata.node_type_id, allNodes);
424
421
  const connectedEdges = edges.filter((e) => e.source === oldNodeId || e.target === oldNodeId);
425
422
  // Compute the base preview to get auto-matched ports
426
423
  const preview = computeSwapPreviewWithOptions(oldNode, newMetadata, edges, allNodes, options);
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * Works with both built-in types and custom registered types.
11
11
  */
12
- import { resolveBuiltinAlias, isBuiltinType } from '../registry/builtinNodes.js';
12
+ import { resolveBuiltinAlias, isBuiltinType } from '../registry/builtinNodeTypes.js';
13
13
  /**
14
14
  * Display names for built-in node types.
15
15
  */
@@ -1,9 +1,46 @@
1
- import type { NodePort } from '../types/index.js';
1
+ import type { NodePort, PortConfigEntry, PortsConfig } from '../types/index.js';
2
+ /**
3
+ * Default sort weight applied to reserved ports (the `error` output and the
4
+ * `trigger`/`tool` control-flow ports) that don't set an explicit
5
+ * `displayOrder`. High enough to sink them below author-declared ports, which
6
+ * default to `0`. The single home for the "high weight" the docs refer to — an
7
+ * explicit `displayOrder` on the port still overrides it.
8
+ */
9
+ export declare const RESERVED_PORT_DISPLAY_ORDER = 100;
10
+ /**
11
+ * Whether a port is a reserved one that should default to the bottom of its
12
+ * direction: the reserved `error` output, or a `trigger`/`tool` control-flow
13
+ * port (identified by data type, mirroring the port config's control types).
14
+ */
15
+ export declare function isReservedPort(port: {
16
+ id: string;
17
+ type?: string;
18
+ dataType?: string;
19
+ }): boolean;
2
20
  /**
3
21
  * Sort ports by an ordered array of port IDs.
4
22
  * Ports not listed appear at the end in their original order.
5
23
  */
6
24
  export declare function applyPortOrder(ports: NodePort[], orderedIds: string[] | undefined): NodePort[];
25
+ /**
26
+ * Sort ports by their effective `displayOrder` weight (ascending), breaking ties
27
+ * on declaration order (stable). This is the default order before any
28
+ * instance-level reordering — reserved ports (trigger/tool/error) carry a high
29
+ * default weight so they land at the bottom without authors hand-setting it.
30
+ */
31
+ export declare function byDefaultOrder(ports: NodePort[]): NodePort[];
32
+ /**
33
+ * Effective render order for a direction: the metadata default order, then the
34
+ * instance's `ports` config override (listed ports first in their stored order,
35
+ * the rest following in default order).
36
+ */
37
+ export declare function orderPortsFor(ports: NodePort[], entries: PortConfigEntry[] | undefined): NodePort[];
38
+ /**
39
+ * Effective exposure for a port: the instance's explicit `exposed` override if
40
+ * present, else the port's metadata `exposedByDefault` (which itself defaults to
41
+ * exposed).
42
+ */
43
+ export declare function isPortExposed(port: NodePort, entries: PortConfigEntry[] | undefined): boolean;
7
44
  /**
8
45
  * Compute the CSS `top` offset (px) for a port handle.
9
46
  * - 1 port: centered at 40px
@@ -11,14 +48,13 @@ export declare function applyPortOrder(ports: NodePort[], orderedIds: string[] |
11
48
  */
12
49
  export declare function getPortTop(index: number, count: number): number;
13
50
  /**
14
- * Determine whether a port should be rendered.
51
+ * Whether a port is exposed, and so rendered on the canvas.
52
+ *
53
+ * In v2 exposure is semantic, not cosmetic: a not-exposed port is hidden, not
54
+ * wireable, and not runtime-overridable. Effective exposure is the instance's
55
+ * explicit `data.config.ports` override for the port, falling back to the port's
56
+ * metadata `exposedByDefault` (which itself defaults to exposed).
15
57
  *
16
- * Priority:
17
- * 1. Manual hide (`hiddenPorts`) — always wins, regardless of connections
18
- * 2. `hideUnconnectedHandles` — hide if not present in the connected handles set
19
- * 3. Default — visible
20
- */
21
- export declare function isPortVisible(port: NodePort, direction: 'input' | 'output', hiddenPorts: {
22
- inputs?: string[];
23
- outputs?: string[];
24
- }, hideUnconnectedHandles: boolean, connectedHandles: Set<string>, nodeId: string | undefined): boolean;
58
+ * @see .claude/plans/exposed-ports.md
59
+ */
60
+ export declare function isPortVisible(port: NodePort, direction: 'input' | 'output', ports: PortsConfig | undefined): boolean;
@@ -1,3 +1,27 @@
1
+ import { isErrorPort } from './colors.js';
2
+ /**
3
+ * Default sort weight applied to reserved ports (the `error` output and the
4
+ * `trigger`/`tool` control-flow ports) that don't set an explicit
5
+ * `displayOrder`. High enough to sink them below author-declared ports, which
6
+ * default to `0`. The single home for the "high weight" the docs refer to — an
7
+ * explicit `displayOrder` on the port still overrides it.
8
+ */
9
+ export const RESERVED_PORT_DISPLAY_ORDER = 100;
10
+ /**
11
+ * Whether a port is a reserved one that should default to the bottom of its
12
+ * direction: the reserved `error` output, or a `trigger`/`tool` control-flow
13
+ * port (identified by data type, mirroring the port config's control types).
14
+ */
15
+ export function isReservedPort(port) {
16
+ return isErrorPort(port) || port.dataType === 'trigger' || port.dataType === 'tool';
17
+ }
18
+ /**
19
+ * The port's effective default sort weight: its explicit `displayOrder` if set,
20
+ * else a high weight for reserved ports, else `0`.
21
+ */
22
+ function defaultWeight(port) {
23
+ return port.displayOrder ?? (isReservedPort(port) ? RESERVED_PORT_DISPLAY_ORDER : 0);
24
+ }
1
25
  /**
2
26
  * Sort ports by an ordered array of port IDs.
3
27
  * Ports not listed appear at the end in their original order.
@@ -13,6 +37,38 @@ export function applyPortOrder(ports, orderedIds) {
13
37
  return aIdx === bIdx ? 0 : aIdx - bIdx;
14
38
  });
15
39
  }
40
+ /**
41
+ * Sort ports by their effective `displayOrder` weight (ascending), breaking ties
42
+ * on declaration order (stable). This is the default order before any
43
+ * instance-level reordering — reserved ports (trigger/tool/error) carry a high
44
+ * default weight so they land at the bottom without authors hand-setting it.
45
+ */
46
+ export function byDefaultOrder(ports) {
47
+ return ports
48
+ .map((port, index) => ({ port, index }))
49
+ .sort((a, b) => defaultWeight(a.port) - defaultWeight(b.port) || a.index - b.index)
50
+ .map(({ port }) => port);
51
+ }
52
+ /**
53
+ * Effective render order for a direction: the metadata default order, then the
54
+ * instance's `ports` config override (listed ports first in their stored order,
55
+ * the rest following in default order).
56
+ */
57
+ export function orderPortsFor(ports, entries) {
58
+ const base = byDefaultOrder(ports);
59
+ return applyPortOrder(base, entries?.map((entry) => entry.id));
60
+ }
61
+ /**
62
+ * Effective exposure for a port: the instance's explicit `exposed` override if
63
+ * present, else the port's metadata `exposedByDefault` (which itself defaults to
64
+ * exposed).
65
+ */
66
+ export function isPortExposed(port, entries) {
67
+ const entry = entries?.find((candidate) => candidate.id === port.id);
68
+ if (entry && entry.exposed !== undefined)
69
+ return entry.exposed;
70
+ return port.exposedByDefault ?? true;
71
+ }
16
72
  /**
17
73
  * Compute the CSS `top` offset (px) for a port handle.
18
74
  * - 1 port: centered at 40px
@@ -24,19 +80,16 @@ export function getPortTop(index, count) {
24
80
  return 20 + index * 40;
25
81
  }
26
82
  /**
27
- * Determine whether a port should be rendered.
83
+ * Whether a port is exposed, and so rendered on the canvas.
28
84
  *
29
- * Priority:
30
- * 1. Manual hide (`hiddenPorts`) — always wins, regardless of connections
31
- * 2. `hideUnconnectedHandles` — hide if not present in the connected handles set
32
- * 3. Default — visible
33
- */
34
- export function isPortVisible(port, direction, hiddenPorts, hideUnconnectedHandles, connectedHandles, nodeId) {
35
- const hiddenList = direction === 'input' ? hiddenPorts.inputs : hiddenPorts.outputs;
36
- if (hiddenList?.includes(port.id))
37
- return false;
38
- if (hideUnconnectedHandles) {
39
- return connectedHandles.has(`${nodeId}-${direction}-${port.id}`);
40
- }
41
- return true;
85
+ * In v2 exposure is semantic, not cosmetic: a not-exposed port is hidden, not
86
+ * wireable, and not runtime-overridable. Effective exposure is the instance's
87
+ * explicit `data.config.ports` override for the port, falling back to the port's
88
+ * metadata `exposedByDefault` (which itself defaults to exposed).
89
+ *
90
+ * @see .claude/plans/exposed-ports.md
91
+ */
92
+ export function isPortVisible(port, direction, ports) {
93
+ const entries = direction === 'input' ? ports?.inputs : ports?.outputs;
94
+ return isPortExposed(port, entries);
42
95
  }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Svelte action that relocates an element to `document.body` (or another
3
+ * target) for its lifetime, then removes it on destroy.
4
+ *
5
+ * Modals and overlays use `position: fixed` expecting the viewport as their
6
+ * containing block. When any ancestor establishes a containing block — via
7
+ * `transform`, `filter`, `backdrop-filter`, `will-change`, `contain`, etc. —
8
+ * `fixed` resolves against that ancestor instead, causing clipping and
9
+ * mis-centering. Portalling the node to `document.body` sidesteps this by
10
+ * escaping those ancestors entirely.
11
+ *
12
+ * Usage: `<div use:portal>…</div>` or `<div use:portal={targetElement}>…</div>`.
13
+ * No-op during SSR (no `document`).
14
+ */
15
+ export declare function portal(node: HTMLElement, target?: HTMLElement | undefined): {
16
+ update(nextTarget: HTMLElement | undefined): void;
17
+ destroy(): void;
18
+ };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Svelte action that relocates an element to `document.body` (or another
3
+ * target) for its lifetime, then removes it on destroy.
4
+ *
5
+ * Modals and overlays use `position: fixed` expecting the viewport as their
6
+ * containing block. When any ancestor establishes a containing block — via
7
+ * `transform`, `filter`, `backdrop-filter`, `will-change`, `contain`, etc. —
8
+ * `fixed` resolves against that ancestor instead, causing clipping and
9
+ * mis-centering. Portalling the node to `document.body` sidesteps this by
10
+ * escaping those ancestors entirely.
11
+ *
12
+ * Usage: `<div use:portal>…</div>` or `<div use:portal={targetElement}>…</div>`.
13
+ * No-op during SSR (no `document`).
14
+ */
15
+ export function portal(node, target = undefined) {
16
+ let host = null;
17
+ function mount(to) {
18
+ if (typeof document === 'undefined')
19
+ return;
20
+ host = to ?? document.body;
21
+ host.appendChild(node);
22
+ }
23
+ mount(target);
24
+ return {
25
+ update(nextTarget) {
26
+ mount(nextTarget);
27
+ },
28
+ destroy() {
29
+ if (node.parentNode) {
30
+ node.parentNode.removeChild(node);
31
+ }
32
+ }
33
+ };
34
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Combines a dynamically-fetched config schema with a node's static schema.
3
+ *
4
+ * Dynamic schema used to be all-or-nothing: the fetched schema replaced the
5
+ * whole form, so an endpoint had to re-serve every field even to drive one, and
6
+ * a narrower response silently dropped fields (and their values) the form no
7
+ * longer rendered. `applyFetchedSchema` lets the fetch instead *layer onto* the
8
+ * static schema — merging fields or targeting a single region — so the rest of
9
+ * the form stays exactly as authored.
10
+ *
11
+ * Kept as a standalone pure function so it can be unit-tested directly against
12
+ * the same code `ConfigForm` runs, rather than through the component.
13
+ */
14
+ import type { ConfigSchema, DynamicSchemaEndpoint } from '../types/index.js';
15
+ /**
16
+ * Resolves the schema `ConfigForm` should render from a node's static schema
17
+ * and a freshly-fetched dynamic schema, per the endpoint's `mergeStrategy` and
18
+ * `target`.
19
+ *
20
+ * @param base - The node's static schema (`schema` prop or `metadata.configSchema`), if any
21
+ * @param fetched - The schema returned by the dynamic endpoint
22
+ * @param endpoint - Supplies `mergeStrategy` (default `"replace"`) and optional `target`
23
+ * @returns The effective schema to render
24
+ */
25
+ export declare function applyFetchedSchema(base: ConfigSchema | undefined, fetched: ConfigSchema, endpoint: Pick<DynamicSchemaEndpoint, 'mergeStrategy' | 'target'>): ConfigSchema;
@@ -0,0 +1,61 @@
1
+ /** Union two `required` arrays, dropping duplicates; `undefined` when neither has entries. */
2
+ function unionRequired(a, b) {
3
+ if (!a?.length && !b?.length)
4
+ return undefined;
5
+ return Array.from(new Set([...(a ?? []), ...(b ?? [])]));
6
+ }
7
+ /**
8
+ * Layers `fetched` onto `base`: fetched top-level attributes win, `properties`
9
+ * are shallow-merged per key (a field is wholly static or wholly fetched, never
10
+ * half of each), and `required` is unioned.
11
+ */
12
+ function mergeNodes(base, fetched) {
13
+ const merged = { ...base, ...fetched };
14
+ if (base.properties || fetched.properties) {
15
+ merged.properties = { ...(base.properties ?? {}), ...(fetched.properties ?? {}) };
16
+ }
17
+ const required = unionRequired(base.required, fetched.required);
18
+ if (required)
19
+ merged.required = required;
20
+ else
21
+ delete merged.required;
22
+ return merged;
23
+ }
24
+ /**
25
+ * Places `fetched` at `segments` within `base`, cloning each node along the
26
+ * path so the input is never mutated. At the leaf the strategy decides between
27
+ * replacing the existing node outright and merging into it.
28
+ */
29
+ function spliceAtPath(base, fetched, segments, strategy) {
30
+ if (segments.length === 0) {
31
+ return strategy === 'merge' ? mergeNodes(base, fetched) : fetched;
32
+ }
33
+ const [head, ...rest] = segments;
34
+ const properties = base.properties ?? {};
35
+ const existing = (properties[head] ?? {});
36
+ return {
37
+ ...base,
38
+ properties: {
39
+ ...properties,
40
+ [head]: spliceAtPath(existing, fetched, rest, strategy)
41
+ }
42
+ };
43
+ }
44
+ /**
45
+ * Resolves the schema `ConfigForm` should render from a node's static schema
46
+ * and a freshly-fetched dynamic schema, per the endpoint's `mergeStrategy` and
47
+ * `target`.
48
+ *
49
+ * @param base - The node's static schema (`schema` prop or `metadata.configSchema`), if any
50
+ * @param fetched - The schema returned by the dynamic endpoint
51
+ * @param endpoint - Supplies `mergeStrategy` (default `"replace"`) and optional `target`
52
+ * @returns The effective schema to render
53
+ */
54
+ export function applyFetchedSchema(base, fetched, endpoint) {
55
+ const strategy = endpoint.mergeStrategy ?? 'replace';
56
+ // Nothing to combine with: the fetched schema is the whole form.
57
+ if (!base)
58
+ return fetched;
59
+ const segments = endpoint.target ? endpoint.target.split('.').filter(Boolean) : [];
60
+ return spliceAtPath(base, fetched, segments, strategy);
61
+ }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A drop-in visual workflow editor for any web application. You own the backend. You own the data. You own the orchestration.",
4
4
  "license": "MIT",
5
5
  "private": false,
6
- "version": "2.0.0-beta.1",
6
+ "version": "2.0.0-beta.10",
7
7
  "author": "Shibin Das (D34dMan)",
8
8
  "bugs": {
9
9
  "url": "https://github.com/flowdrop-io/flowdrop/issues"
@@ -289,6 +289,7 @@
289
289
  "watch:build": "npm-watch build",
290
290
  "preview": "vite preview",
291
291
  "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
292
+ "check:bundle": "node scripts/check-bundle.mjs",
292
293
  "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
293
294
  "lint": "eslint . && prettier --check .",
294
295
  "test": "vitest run",