@flowdrop/flowdrop 2.0.0-beta.5 → 2.0.0-beta.7

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 (34) hide show
  1. package/CHANGELOG.md +39 -2
  2. package/dist/commands/executor.js +46 -20
  3. package/dist/components/App.svelte +1 -10
  4. package/dist/components/ConfigForm.svelte +98 -529
  5. package/dist/components/ConfigForm.svelte.d.ts +4 -6
  6. package/dist/components/ConfigModal.svelte +0 -1
  7. package/dist/components/form/FormField.svelte +15 -0
  8. package/dist/components/form/FormFieldLight.svelte +14 -0
  9. package/dist/components/form/FormFieldset.svelte +44 -10
  10. package/dist/components/form/FormPorts.svelte +262 -0
  11. package/dist/components/form/FormPorts.svelte.d.ts +13 -0
  12. package/dist/components/form/FormRangeField.svelte +43 -3
  13. package/dist/components/nodes/AtomNode.svelte +13 -39
  14. package/dist/components/nodes/GatewayNode.svelte +20 -56
  15. package/dist/components/nodes/SimpleNode.svelte +23 -49
  16. package/dist/components/nodes/SquareNode.svelte +23 -49
  17. package/dist/components/nodes/TerminalNode.svelte +25 -31
  18. package/dist/components/nodes/WorkflowNode.svelte +37 -84
  19. package/dist/core/index.d.ts +1 -1
  20. package/dist/openapi/v1/openapi.yaml +33 -21
  21. package/dist/schemas/v1/workflow.schema.json +16 -14
  22. package/dist/services/dynamicSchemaService.d.ts +29 -2
  23. package/dist/services/dynamicSchemaService.js +54 -25
  24. package/dist/stores/workflowStore.svelte.d.ts +1 -1
  25. package/dist/stores/workflowStore.svelte.js +7 -2
  26. package/dist/types/index.d.ts +74 -20
  27. package/dist/types/uischema.d.ts +5 -0
  28. package/dist/utils/colors.d.ts +27 -0
  29. package/dist/utils/colors.js +23 -0
  30. package/dist/utils/portUtils.d.ts +47 -11
  31. package/dist/utils/portUtils.js +67 -14
  32. package/dist/utils/schemaMerge.d.ts +25 -0
  33. package/dist/utils/schemaMerge.js +61 -0
  34. package/package.json +1 -1
@@ -3,14 +3,16 @@
3
3
  Visual representation of gateway/branch nodes with branching flow indicators
4
4
  Shows active branches and execution paths
5
5
  Styled with BEM syntax following WorkflowNode pattern
6
-
7
- UI Extensions Support:
8
- - hideUnconnectedHandles: Hides ports that are not connected to reduce visual clutter
6
+
7
+ Port rendering:
8
+ - Input-port exposure (data.config.ports, falling back to each port's
9
+ exposedByDefault) decides which input ports render, in effective order.
10
+ Branches are authored output paths and always render.
9
11
  -->
10
12
 
11
13
  <script lang="ts">
12
14
  import { Position, Handle } from '@xyflow/svelte';
13
- import type { WorkflowNode, NodePort, Branch } from '../../types/index.js';
15
+ import type { WorkflowNode, Branch, PortsConfig } from '../../types/index.js';
14
16
  import Icon from '@iconify/svelte';
15
17
  import NodeConfigButton from './NodeConfigButton.svelte';
16
18
  import { getNodeIcon } from '../../utils/icons.js';
@@ -20,6 +22,7 @@
20
22
  getPortBackgroundColor
21
23
  } from '../../utils/colors.js';
22
24
  import { getInstance } from '../../stores/getInstance.svelte.js';
25
+ import { orderPortsFor, isPortVisible } from '../../utils/portUtils.js';
23
26
  import { m } from '../../messages/index.js';
24
27
 
25
28
  interface Props {
@@ -56,60 +59,21 @@
56
59
  );
57
60
 
58
61
  /**
59
- * Get the hideUnconnectedHandles setting from extensions
60
- * Merges node type defaults with instance overrides
61
- */
62
- const hideUnconnectedHandles = $derived(
63
- props.data.extensions?.ui?.hideUnconnectedHandles ??
64
- props.data.metadata?.extensions?.ui?.hideUnconnectedHandles ??
65
- false
66
- );
67
-
68
- /**
69
- * Check if a port should be visible based on connection state and settings
70
- * @param port - The port to check
71
- * @param type - Whether this is an 'input' or 'output' port
72
- * @returns true if the port should be visible
62
+ * Per-instance port order + exposure, in config. Order overrides the metadata
63
+ * default; exposure is semantic (a not-exposed port is hidden, not wireable,
64
+ * not runtime-overridable).
73
65
  */
74
- function isPortVisible(port: NodePort, type: 'input' | 'output'): boolean {
75
- // Always show if hideUnconnectedHandles is disabled
76
- if (!hideUnconnectedHandles) {
77
- return true;
78
- }
79
-
80
- // Always show required ports
81
- if (port.required) {
82
- return true;
83
- }
84
-
85
- // Check if port is connected
86
- const handleId = `${props.id}-${type}-${port.id}`;
87
- return fd.workflow.connectedHandles.has(handleId);
88
- }
66
+ const portsConfig = $derived((props.data.config?.ports as PortsConfig | undefined) ?? {});
89
67
 
90
68
  /**
91
- * Derived list of visible input ports based on hideUnconnectedHandles setting
69
+ * Derived list of exposed input ports, in effective order.
92
70
  */
93
71
  const visibleInputPorts = $derived(
94
- props.data.metadata.inputs.filter((port) => isPortVisible(port, 'input'))
72
+ orderPortsFor(props.data.metadata.inputs, portsConfig.inputs).filter((port) =>
73
+ isPortVisible(port, 'input', portsConfig)
74
+ )
95
75
  );
96
76
 
97
- /**
98
- * Check if a branch output should be visible based on connection state
99
- * @param branchName - The branch name to check
100
- * @returns true if the branch should be visible
101
- */
102
- function isBranchVisible(branchName: string): boolean {
103
- // Always show if hideUnconnectedHandles is disabled
104
- if (!hideUnconnectedHandles) {
105
- return true;
106
- }
107
-
108
- // Check if branch output is connected
109
- const handleId = `${props.id}-output-${branchName}`;
110
- return fd.workflow.connectedHandles.has(handleId);
111
- }
112
-
113
77
  // Gateway-specific data - branches are calculated at runtime from config
114
78
  let branches = $derived((props.data.config?.branches as Branch[]) || []);
115
79
  let activeBranches = $derived(
@@ -117,9 +81,9 @@
117
81
  );
118
82
 
119
83
  /**
120
- * Derived list of visible branches based on hideUnconnectedHandles setting
84
+ * Branches are authored output paths, so they always render.
121
85
  */
122
- const visibleBranches = $derived(branches.filter((branch) => isBranchVisible(branch.name)));
86
+ const visibleBranches = $derived(branches);
123
87
 
124
88
  /**
125
89
  * Handle double-click to open config
@@ -178,7 +142,7 @@
178
142
  </p>
179
143
  </div>
180
144
 
181
- <!-- Input Ports Container (filtered based on hideUnconnectedHandles) -->
145
+ <!-- Input Ports Container (exposed input ports) -->
182
146
  {#if visibleInputPorts.length > 0}
183
147
  <div class="flowdrop-workflow-node__ports">
184
148
  <div class="flowdrop-workflow-node__ports-list">
@@ -232,7 +196,7 @@
232
196
  </div>
233
197
  {/if}
234
198
 
235
- <!-- Branches Section (Output Ports) - filtered based on hideUnconnectedHandles -->
199
+ <!-- Branches Section (Output Ports) -->
236
200
  {#if visibleBranches.length > 0}
237
201
  <div class="flowdrop-workflow-node__ports">
238
202
  <div class="flowdrop-workflow-node__ports-list">
@@ -300,7 +264,7 @@
300
264
  </div>
301
265
  </div>
302
266
  {/if}
303
- <!-- Note: When all branches are hidden due to hideUnconnectedHandles, we don't show anything -->
267
+ <!-- Note: When there are no branches, we don't show anything -->
304
268
 
305
269
  <!-- Config button -->
306
270
  <NodeConfigButton onclick={handleNodeDoubleClick} title="Configure node" />
@@ -3,10 +3,11 @@
3
3
  A simple node with optional input and output ports
4
4
  Styled with BEM syntax
5
5
 
6
- UI Extensions Support:
7
- - hideUnconnectedHandles: Hides ports that are not connected to reduce visual clutter
8
- - hiddenPorts: Manually hide individual ports (visual-only, no effect on execution)
9
- - portOrder: Reorder ports by ID array (unspecified ports appear at end in original order)
6
+ Port rendering:
7
+ - Exposure (data.config.ports, falling back to each port's exposedByDefault)
8
+ decides which ports render — a not-exposed port is hidden.
9
+ - Order: data.config.ports order overrides the metadata default (displayOrder);
10
+ unlisted ports follow in default order.
10
11
  -->
11
12
 
12
13
  <script lang="ts">
@@ -16,13 +17,14 @@
16
17
  NodeMetadata,
17
18
  NodeExtensions,
18
19
  NodePort,
19
- DynamicPort
20
+ DynamicPort,
21
+ PortsConfig
20
22
  } from '../../types/index.js';
21
23
  import { dynamicPortToNodePort } from '../../types/index.js';
22
24
  import Icon from '@iconify/svelte';
23
- import { getDataTypeColor, getCategoryColorToken } from '../../utils/colors.js';
25
+ import { getPortColorToken, getCategoryColorToken } from '../../utils/colors.js';
24
26
  import { getInstance } from '../../stores/getInstance.svelte.js';
25
- import { applyPortOrder, getPortTop, isPortVisible } from '../../utils/portUtils.js';
27
+ import { orderPortsFor, getPortTop, isPortVisible } from '../../utils/portUtils.js';
26
28
  import NodeConfigButton from './NodeConfigButton.svelte';
27
29
  import AlertCircleIcon from '../icons/AlertCircleIcon.svelte';
28
30
 
@@ -50,21 +52,11 @@
50
52
  const checker = fd.portCompatibility;
51
53
 
52
54
  /**
53
- * Get UI extension settings from extensions, merging node type defaults with instance overrides.
55
+ * Per-instance port order + exposure, in config. Order overrides the metadata
56
+ * default; exposure is semantic (a not-exposed port is hidden, not wireable,
57
+ * not runtime-overridable).
54
58
  */
55
- const hideUnconnectedHandles = $derived(
56
- props.data.extensions?.ui?.hideUnconnectedHandles ??
57
- props.data.metadata?.extensions?.ui?.hideUnconnectedHandles ??
58
- false
59
- );
60
-
61
- const hiddenPorts = $derived(
62
- props.data.extensions?.ui?.hiddenPorts ?? props.data.metadata?.extensions?.ui?.hiddenPorts ?? {}
63
- );
64
-
65
- const portOrder = $derived(
66
- props.data.extensions?.ui?.portOrder ?? props.data.metadata?.extensions?.ui?.portOrder ?? {}
67
- );
59
+ const portsConfig = $derived((props.data.config?.ports as PortsConfig | undefined) ?? {});
68
60
 
69
61
  // Prioritize metadata icon over config icon for simple nodes (metadata is the node definition)
70
62
  let nodeIcon = $derived(
@@ -124,38 +116,20 @@
124
116
  * All visible input ports in user-defined order.
125
117
  */
126
118
  const visibleInputPorts = $derived(
127
- applyPortOrder(
119
+ orderPortsFor(
128
120
  [...(props.data.metadata?.inputs ?? []), ...dynamicInputs],
129
- portOrder.inputs
130
- ).filter((p: NodePort) =>
131
- isPortVisible(
132
- p,
133
- 'input',
134
- hiddenPorts,
135
- hideUnconnectedHandles,
136
- fd.workflow.connectedHandles,
137
- props.id
138
- )
139
- )
121
+ portsConfig.inputs
122
+ ).filter((p: NodePort) => isPortVisible(p, 'input', portsConfig))
140
123
  );
141
124
 
142
125
  /**
143
126
  * All visible output ports in user-defined order.
144
127
  */
145
128
  const visibleOutputPorts = $derived(
146
- applyPortOrder(
129
+ orderPortsFor(
147
130
  [...(props.data.metadata?.outputs ?? []), ...dynamicOutputs],
148
- portOrder.outputs
149
- ).filter((p: NodePort) =>
150
- isPortVisible(
151
- p,
152
- 'output',
153
- hiddenPorts,
154
- hideUnconnectedHandles,
155
- fd.workflow.connectedHandles,
156
- props.id
157
- )
158
- )
131
+ portsConfig.outputs
132
+ ).filter((p: NodePort) => isPortVisible(p, 'output', portsConfig))
159
133
  );
160
134
 
161
135
  /**
@@ -174,9 +148,9 @@
174
148
  <Handle
175
149
  type="target"
176
150
  position={Position.Left}
177
- style="--fd-handle-fill: var(--fd-port-skin-color, {getDataTypeColor(
151
+ style="--fd-handle-fill: var(--fd-port-skin-color, {getPortColorToken(
178
152
  checker,
179
- port.dataType
153
+ port
180
154
  )}); --fd-handle-border-color: var(--fd-handle-border); top: {getPortTop(
181
155
  index,
182
156
  visibleInputPorts.length
@@ -246,9 +220,9 @@
246
220
  <Handle
247
221
  type="source"
248
222
  position={Position.Right}
249
- style="--fd-handle-fill: var(--fd-port-skin-color, {getDataTypeColor(
223
+ style="--fd-handle-fill: var(--fd-port-skin-color, {getPortColorToken(
250
224
  checker,
251
- port.dataType
225
+ port
252
226
  )}); --fd-handle-border-color: var(--fd-handle-border); top: {getPortTop(
253
227
  index,
254
228
  visibleOutputPorts.length
@@ -3,10 +3,11 @@
3
3
  A simple square node with optional input and output ports
4
4
  Styled with BEM syntax
5
5
 
6
- UI Extensions Support:
7
- - hideUnconnectedHandles: Hides ports that are not connected to reduce visual clutter
8
- - hiddenPorts: Manually hide individual ports (visual-only, no effect on execution)
9
- - portOrder: Reorder ports by ID array (unspecified ports appear at end in original order)
6
+ Port rendering:
7
+ - Exposure (data.config.ports, falling back to each port's exposedByDefault)
8
+ decides which ports render — a not-exposed port is hidden.
9
+ - Order: data.config.ports order overrides the metadata default (displayOrder);
10
+ unlisted ports follow in default order.
10
11
  -->
11
12
 
12
13
  <script lang="ts">
@@ -16,14 +17,15 @@
16
17
  NodeMetadata,
17
18
  NodeExtensions,
18
19
  NodePort,
19
- DynamicPort
20
+ DynamicPort,
21
+ PortsConfig
20
22
  } from '../../types/index.js';
21
23
  import { dynamicPortToNodePort } from '../../types/index.js';
22
24
  import Icon from '@iconify/svelte';
23
- import { getDataTypeColor, getCategoryColorToken } from '../../utils/colors.js';
25
+ import { getPortColorToken, getCategoryColorToken } from '../../utils/colors.js';
24
26
  import { getNodeIcon } from '../../utils/icons.js';
25
27
  import { getInstance } from '../../stores/getInstance.svelte.js';
26
- import { applyPortOrder, getPortTop, isPortVisible } from '../../utils/portUtils.js';
28
+ import { orderPortsFor, getPortTop, isPortVisible } from '../../utils/portUtils.js';
27
29
  import NodeConfigButton from './NodeConfigButton.svelte';
28
30
  import AlertCircleIcon from '../icons/AlertCircleIcon.svelte';
29
31
 
@@ -51,21 +53,11 @@
51
53
  const checker = fd.portCompatibility;
52
54
 
53
55
  /**
54
- * Get UI extension settings from extensions, merging node type defaults with instance overrides.
56
+ * Per-instance port order + exposure, in config. Order overrides the metadata
57
+ * default; exposure is semantic (a not-exposed port is hidden, not wireable,
58
+ * not runtime-overridable).
55
59
  */
56
- const hideUnconnectedHandles = $derived(
57
- props.data.extensions?.ui?.hideUnconnectedHandles ??
58
- props.data.metadata?.extensions?.ui?.hideUnconnectedHandles ??
59
- false
60
- );
61
-
62
- const hiddenPorts = $derived(
63
- props.data.extensions?.ui?.hiddenPorts ?? props.data.metadata?.extensions?.ui?.hiddenPorts ?? {}
64
- );
65
-
66
- const portOrder = $derived(
67
- props.data.extensions?.ui?.portOrder ?? props.data.metadata?.extensions?.ui?.portOrder ?? {}
68
- );
60
+ const portsConfig = $derived((props.data.config?.ports as PortsConfig | undefined) ?? {});
69
61
 
70
62
  /**
71
63
  * Get icon using the same resolution as WorkflowNode
@@ -120,38 +112,20 @@
120
112
  * All visible input ports in user-defined order.
121
113
  */
122
114
  const visibleInputPorts = $derived(
123
- applyPortOrder(
115
+ orderPortsFor(
124
116
  [...(props.data.metadata?.inputs ?? []), ...dynamicInputs],
125
- portOrder.inputs
126
- ).filter((p: NodePort) =>
127
- isPortVisible(
128
- p,
129
- 'input',
130
- hiddenPorts,
131
- hideUnconnectedHandles,
132
- fd.workflow.connectedHandles,
133
- props.id
134
- )
135
- )
117
+ portsConfig.inputs
118
+ ).filter((p: NodePort) => isPortVisible(p, 'input', portsConfig))
136
119
  );
137
120
 
138
121
  /**
139
122
  * All visible output ports in user-defined order.
140
123
  */
141
124
  const visibleOutputPorts = $derived(
142
- applyPortOrder(
125
+ orderPortsFor(
143
126
  [...(props.data.metadata?.outputs ?? []), ...dynamicOutputs],
144
- portOrder.outputs
145
- ).filter((p: NodePort) =>
146
- isPortVisible(
147
- p,
148
- 'output',
149
- hiddenPorts,
150
- hideUnconnectedHandles,
151
- fd.workflow.connectedHandles,
152
- props.id
153
- )
154
- )
127
+ portsConfig.outputs
128
+ ).filter((p: NodePort) => isPortVisible(p, 'output', portsConfig))
155
129
  );
156
130
 
157
131
  /**
@@ -171,9 +145,9 @@
171
145
  <Handle
172
146
  type="target"
173
147
  position={Position.Left}
174
- style="--fd-handle-fill: var(--fd-port-skin-color, {getDataTypeColor(
148
+ style="--fd-handle-fill: var(--fd-port-skin-color, {getPortColorToken(
175
149
  checker,
176
- port.dataType
150
+ port
177
151
  )}); --fd-handle-border-color: var(--fd-handle-border); top: {getPortTop(
178
152
  index,
179
153
  visibleInputPorts.length
@@ -237,9 +211,9 @@
237
211
  <Handle
238
212
  type="source"
239
213
  position={Position.Right}
240
- style="--fd-handle-fill: var(--fd-port-skin-color, {getDataTypeColor(
214
+ style="--fd-handle-fill: var(--fd-port-skin-color, {getPortColorToken(
241
215
  checker,
242
- port.dataType
216
+ port
243
217
  )}); --fd-handle-border-color: var(--fd-handle-border); top: {getPortTop(
244
218
  index,
245
219
  visibleOutputPorts.length
@@ -10,12 +10,19 @@
10
10
 
11
11
  <script lang="ts">
12
12
  import { Position, Handle } from '@xyflow/svelte';
13
- import type { ConfigValues, NodeMetadata, NodeExtensions, NodePort } from '../../types/index.js';
13
+ import type {
14
+ ConfigValues,
15
+ NodeMetadata,
16
+ NodeExtensions,
17
+ NodePort,
18
+ PortsConfig
19
+ } from '../../types/index.js';
14
20
  import Icon from '@iconify/svelte';
15
21
  import NodeConfigButton from './NodeConfigButton.svelte';
16
- import { getDataTypeColor, getCategoryColorToken } from '../../utils/colors.js';
22
+ import { getPortColorToken, getCategoryColorToken } from '../../utils/colors.js';
17
23
  import { getNodeIcon } from '../../utils/icons.js';
18
24
  import { getCircleHandlePosition } from '../../utils/handlePositioning.js';
25
+ import { orderPortsFor, isPortVisible } from '../../utils/portUtils.js';
19
26
  import { getInstance } from '../../stores/getInstance.svelte.js';
20
27
 
21
28
  /**
@@ -142,28 +149,11 @@
142
149
  let variantConfig = $derived(VARIANT_CONFIGS[variant]);
143
150
 
144
151
  /**
145
- * Get the hideUnconnectedHandles setting from extensions
146
- * Merges node type defaults with instance overrides
152
+ * Per-instance port order + exposure, in config. Order overrides the metadata
153
+ * default; exposure is semantic (a not-exposed port is hidden, not wireable,
154
+ * not runtime-overridable).
147
155
  */
148
- const hideUnconnectedHandles = $derived(
149
- props.data.extensions?.ui?.hideUnconnectedHandles ??
150
- props.data.metadata?.extensions?.ui?.hideUnconnectedHandles ??
151
- false
152
- );
153
-
154
- /**
155
- * Check if a port should be visible based on connection state and settings
156
- */
157
- function isPortVisible(port: NodePort, type: 'input' | 'output'): boolean {
158
- if (!hideUnconnectedHandles) {
159
- return true;
160
- }
161
- if (port.required) {
162
- return true;
163
- }
164
- const handleId = `${props.id}-${type}-${port.id}`;
165
- return fd.workflow.connectedHandles.has(handleId);
166
- }
156
+ const portsConfig = $derived((props.data.config?.ports as PortsConfig | undefined) ?? {});
167
157
 
168
158
  /**
169
159
  * Get icon using the same resolution as WorkflowNode
@@ -271,17 +261,21 @@
271
261
  );
272
262
 
273
263
  /**
274
- * Visible input ports filtered by hideUnconnectedHandles setting
264
+ * Exposed input ports, in effective order.
275
265
  */
276
266
  let visibleInputPorts = $derived(
277
- inputPorts.filter((port: NodePort) => isPortVisible(port, 'input'))
267
+ orderPortsFor(inputPorts, portsConfig.inputs).filter((port: NodePort) =>
268
+ isPortVisible(port, 'input', portsConfig)
269
+ )
278
270
  );
279
271
 
280
272
  /**
281
- * Visible output ports filtered by hideUnconnectedHandles setting
273
+ * Exposed output ports, in effective order.
282
274
  */
283
275
  let visibleOutputPorts = $derived(
284
- outputPorts.filter((port: NodePort) => isPortVisible(port, 'output'))
276
+ orderPortsFor(outputPorts, portsConfig.outputs).filter((port: NodePort) =>
277
+ isPortVisible(port, 'output', portsConfig)
278
+ )
285
279
  );
286
280
 
287
281
  /**
@@ -344,9 +338,9 @@
344
338
  <Handle
345
339
  type="target"
346
340
  position={Position.Left}
347
- style="--fd-handle-fill: {getDataTypeColor(
341
+ style="--fd-handle-fill: {getPortColorToken(
348
342
  checker,
349
- port.dataType
343
+ port
350
344
  )}; --fd-handle-border-color: var(--fd-handle-border); left: {pos.left}px; top: {pos.top}px; transform: translate(-50%, -50%); z-index: 30;"
351
345
  id={`${props.id}-input-${port.id}`}
352
346
  />
@@ -368,9 +362,9 @@
368
362
  type="source"
369
363
  position={Position.Right}
370
364
  id={`${props.id}-output-${port.id}`}
371
- style="--fd-handle-fill: {getDataTypeColor(
365
+ style="--fd-handle-fill: {getPortColorToken(
372
366
  checker,
373
- port.dataType
367
+ port
374
368
  )}; --fd-handle-border-color: var(--fd-handle-border); left: {pos.left}px; top: {pos.top}px; transform: translate(-50%, -50%); z-index: 30;"
375
369
  />
376
370
  {/each}