@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.
- package/CHANGELOG.md +39 -2
- package/dist/commands/executor.js +46 -20
- package/dist/components/App.svelte +1 -10
- package/dist/components/ConfigForm.svelte +98 -529
- package/dist/components/ConfigForm.svelte.d.ts +4 -6
- package/dist/components/ConfigModal.svelte +0 -1
- package/dist/components/form/FormField.svelte +15 -0
- package/dist/components/form/FormFieldLight.svelte +14 -0
- package/dist/components/form/FormFieldset.svelte +44 -10
- package/dist/components/form/FormPorts.svelte +262 -0
- package/dist/components/form/FormPorts.svelte.d.ts +13 -0
- package/dist/components/form/FormRangeField.svelte +43 -3
- package/dist/components/nodes/AtomNode.svelte +13 -39
- package/dist/components/nodes/GatewayNode.svelte +20 -56
- package/dist/components/nodes/SimpleNode.svelte +23 -49
- package/dist/components/nodes/SquareNode.svelte +23 -49
- package/dist/components/nodes/TerminalNode.svelte +25 -31
- package/dist/components/nodes/WorkflowNode.svelte +37 -84
- package/dist/core/index.d.ts +1 -1
- package/dist/openapi/v1/openapi.yaml +33 -21
- package/dist/schemas/v1/workflow.schema.json +16 -14
- package/dist/services/dynamicSchemaService.d.ts +29 -2
- package/dist/services/dynamicSchemaService.js +54 -25
- package/dist/stores/workflowStore.svelte.d.ts +1 -1
- package/dist/stores/workflowStore.svelte.js +7 -2
- package/dist/types/index.d.ts +74 -20
- package/dist/types/uischema.d.ts +5 -0
- package/dist/utils/colors.d.ts +27 -0
- package/dist/utils/colors.js +23 -0
- package/dist/utils/portUtils.d.ts +47 -11
- package/dist/utils/portUtils.js +67 -14
- package/dist/utils/schemaMerge.d.ts +25 -0
- package/dist/utils/schemaMerge.js +61 -0
- package/package.json +1 -1
|
@@ -237,7 +237,7 @@ export class WorkflowStore {
|
|
|
237
237
|
/**
|
|
238
238
|
* Set of all handle IDs currently connected to edges.
|
|
239
239
|
*
|
|
240
|
-
*
|
|
240
|
+
* Handle IDs are formatted `{nodeId}-{direction}-{portId}`.
|
|
241
241
|
*/
|
|
242
242
|
get connectedHandles() {
|
|
243
243
|
const handles = new Set();
|
|
@@ -478,9 +478,14 @@ export class WorkflowStore {
|
|
|
478
478
|
}
|
|
479
479
|
/** Add an edge. */
|
|
480
480
|
addEdge(edge) {
|
|
481
|
-
this.#pushToHistory('Add connection');
|
|
482
481
|
if (!this.#workflow)
|
|
483
482
|
return;
|
|
483
|
+
// Never append an edge whose id already exists — SvelteFlow keys edges by id
|
|
484
|
+
// and a duplicate throws `each_key_duplicate`, taking down the canvas. Guard
|
|
485
|
+
// before touching history so a no-op stays a no-op.
|
|
486
|
+
if (this.#workflow.edges.some((e) => e.id === edge.id))
|
|
487
|
+
return;
|
|
488
|
+
this.#pushToHistory('Add connection');
|
|
484
489
|
this.#workflow = {
|
|
485
490
|
...this.#workflow,
|
|
486
491
|
edges: [...this.#workflow.edges, edge],
|
package/dist/types/index.d.ts
CHANGED
|
@@ -117,12 +117,57 @@ export interface NodePort {
|
|
|
117
117
|
required?: boolean;
|
|
118
118
|
description?: string;
|
|
119
119
|
defaultValue?: unknown;
|
|
120
|
+
/**
|
|
121
|
+
* Whether this port is exposed when the instance sets no explicit exposure
|
|
122
|
+
* for it. Defaults to `true` (a missing flag reads as exposed). Reserved ports
|
|
123
|
+
* that ship hidden until an author opts in (e.g. the `error` output) carry
|
|
124
|
+
* `false`. The instance's `ports` config can override it per port. See
|
|
125
|
+
* `.claude/plans/exposed-ports.md`.
|
|
126
|
+
*/
|
|
127
|
+
exposedByDefault?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Default sort weight for the port's render position, ascending; ties break
|
|
130
|
+
* on declaration order. Author-declared ports default to `0`. Reserved ports
|
|
131
|
+
* (the `error` output and `trigger`/`tool` control ports) need no value — the
|
|
132
|
+
* library sinks them to the bottom automatically (see
|
|
133
|
+
* `RESERVED_PORT_DISPLAY_ORDER`); set this only to override that. Cosmetic
|
|
134
|
+
* only. The instance's `ports` config order overrides it.
|
|
135
|
+
*/
|
|
136
|
+
displayOrder?: number;
|
|
120
137
|
/**
|
|
121
138
|
* Optional JSON Schema describing the structure of data on this port.
|
|
122
139
|
* Used for template variable autocomplete to drill into nested properties.
|
|
123
140
|
*/
|
|
124
141
|
schema?: OutputSchema | InputSchema;
|
|
125
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* One entry in a {@link PortsConfig} direction list: a port id, with display
|
|
145
|
+
* order encoded by its position and an optional exposure override.
|
|
146
|
+
*/
|
|
147
|
+
export interface PortConfigEntry {
|
|
148
|
+
id: string;
|
|
149
|
+
/**
|
|
150
|
+
* Explicit exposure for this port. Stored only when it diverges from the
|
|
151
|
+
* port's metadata `exposedByDefault`. In v2 exposure is semantic: a
|
|
152
|
+
* not-exposed port is hidden on the canvas, not wireable, and not
|
|
153
|
+
* runtime-overridable.
|
|
154
|
+
*/
|
|
155
|
+
exposed?: boolean;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Per-instance port order + exposure, stored in `data.config.ports`.
|
|
159
|
+
*
|
|
160
|
+
* A per-direction ordered list of the node's ports: array index encodes display
|
|
161
|
+
* order relative to the metadata default, and the optional `exposed` flag
|
|
162
|
+
* overrides the port's `exposedByDefault`. A port the author never touched is
|
|
163
|
+
* absent from the list; an untouched node stores no `ports` key at all. Order
|
|
164
|
+
* is cosmetic (the engine ignores it); exposure is semantic. See
|
|
165
|
+
* `.claude/plans/exposed-ports.md`.
|
|
166
|
+
*/
|
|
167
|
+
export interface PortsConfig {
|
|
168
|
+
inputs?: PortConfigEntry[];
|
|
169
|
+
outputs?: PortConfigEntry[];
|
|
170
|
+
}
|
|
126
171
|
/**
|
|
127
172
|
* Absolute position of a port handle in canvas space.
|
|
128
173
|
* Used by proximity connect and other features that need port positions.
|
|
@@ -370,6 +415,35 @@ export interface DynamicSchemaEndpoint {
|
|
|
370
415
|
* @default true
|
|
371
416
|
*/
|
|
372
417
|
cacheSchema?: boolean;
|
|
418
|
+
/**
|
|
419
|
+
* How the fetched schema combines with the node's static schema
|
|
420
|
+
* (the direct `schema` prop or `metadata.configSchema`).
|
|
421
|
+
*
|
|
422
|
+
* - `"replace"` (default): the fetched schema is used as-is and the static
|
|
423
|
+
* schema is ignored. This is the historical behaviour.
|
|
424
|
+
* - `"merge"`: the fetched schema is layered onto the static schema —
|
|
425
|
+
* properties are merged (fetched wins per key) and `required` is unioned —
|
|
426
|
+
* so the endpoint only has to return the fields it actually drives.
|
|
427
|
+
*
|
|
428
|
+
* When there is no static schema to combine with, both strategies behave
|
|
429
|
+
* identically: the fetched schema is the form.
|
|
430
|
+
*
|
|
431
|
+
* @default "replace"
|
|
432
|
+
*/
|
|
433
|
+
mergeStrategy?: 'replace' | 'merge';
|
|
434
|
+
/**
|
|
435
|
+
* Restricts the fetched schema to a region of the static schema instead of
|
|
436
|
+
* the whole form. A dot-path of property keys descending through nested
|
|
437
|
+
* object `properties` (e.g. `"advanced"` or `"advanced.retry"`); the fetched
|
|
438
|
+
* schema is spliced in at that location and every other field stays static.
|
|
439
|
+
*
|
|
440
|
+
* Use this to make just one section (or one field) server-driven while
|
|
441
|
+
* authoring the rest of the form locally. `mergeStrategy` then decides whether
|
|
442
|
+
* the fetched schema replaces or merges into the property at that path.
|
|
443
|
+
*
|
|
444
|
+
* When omitted, the fetch applies at the form root (per `mergeStrategy`).
|
|
445
|
+
*/
|
|
446
|
+
target?: string;
|
|
373
447
|
}
|
|
374
448
|
/**
|
|
375
449
|
* External edit link configuration
|
|
@@ -529,27 +603,8 @@ export interface AtomUIConfig {
|
|
|
529
603
|
maxWidth?: number;
|
|
530
604
|
}
|
|
531
605
|
export interface NodeUIExtensions {
|
|
532
|
-
/** Show/hide unconnected handles (ports) to reduce visual noise */
|
|
533
|
-
hideUnconnectedHandles?: boolean;
|
|
534
606
|
/** Display/behavior config for minimalist atom nodes (Constant, Cast, …) */
|
|
535
607
|
atom?: AtomUIConfig;
|
|
536
|
-
/**
|
|
537
|
-
* Visual-only port display order (no effect on execution).
|
|
538
|
-
* Arrays of port IDs in the desired render order.
|
|
539
|
-
* Ports not listed appear at the end in metadata order.
|
|
540
|
-
*/
|
|
541
|
-
portOrder?: {
|
|
542
|
-
inputs?: string[];
|
|
543
|
-
outputs?: string[];
|
|
544
|
-
};
|
|
545
|
-
/**
|
|
546
|
-
* Manually hidden ports (visual only, no effect on execution).
|
|
547
|
-
* Required ports cannot be added here — enforced in the UI.
|
|
548
|
-
*/
|
|
549
|
-
hiddenPorts?: {
|
|
550
|
-
inputs?: string[];
|
|
551
|
-
outputs?: string[];
|
|
552
|
-
};
|
|
553
608
|
/** Custom styles or theme overrides */
|
|
554
609
|
style?: Record<string, unknown>;
|
|
555
610
|
/** Any other UI-specific settings */
|
|
@@ -563,7 +618,6 @@ export interface NodeUIExtensions {
|
|
|
563
618
|
* ```typescript
|
|
564
619
|
* const extensions: NodeExtensions = {
|
|
565
620
|
* ui: {
|
|
566
|
-
* hideUnconnectedHandles: true,
|
|
567
621
|
* style: { opacity: 0.8 }
|
|
568
622
|
* },
|
|
569
623
|
* "myapp:analytics": {
|
package/dist/types/uischema.d.ts
CHANGED
|
@@ -124,6 +124,11 @@ export interface UISchemaGroup extends UISchemaElementBase {
|
|
|
124
124
|
* @default true
|
|
125
125
|
*/
|
|
126
126
|
defaultOpen?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Optional Iconify icon name shown in the group's header bar.
|
|
129
|
+
* Falls back to a neutral default when omitted.
|
|
130
|
+
*/
|
|
131
|
+
icon?: string;
|
|
127
132
|
}
|
|
128
133
|
/**
|
|
129
134
|
* Union type of all supported UISchema elements.
|
package/dist/utils/colors.d.ts
CHANGED
|
@@ -241,6 +241,33 @@ export declare function getPortBackgroundColor(checker: PortCompatibilityChecker
|
|
|
241
241
|
* @returns CSS color value for the port border
|
|
242
242
|
*/
|
|
243
243
|
export declare function getPortBorderColor(checker: PortCompatibilityChecker, dataType: string): string;
|
|
244
|
+
/**
|
|
245
|
+
* Whether a port is the reserved `error` output port.
|
|
246
|
+
*
|
|
247
|
+
* The reserved error output carries an arbitrary data type (json) but should
|
|
248
|
+
* read as an error affordance (red) wherever it surfaces. See
|
|
249
|
+
* `.claude/plans/exposed-ports.md`.
|
|
250
|
+
*/
|
|
251
|
+
export declare function isErrorPort(port: {
|
|
252
|
+
id: string;
|
|
253
|
+
type?: string;
|
|
254
|
+
}): boolean;
|
|
255
|
+
/**
|
|
256
|
+
* Port colour token: red for the reserved error output, else its data type.
|
|
257
|
+
*/
|
|
258
|
+
export declare function getPortColorToken(checker: PortCompatibilityChecker, port: {
|
|
259
|
+
id: string;
|
|
260
|
+
type?: string;
|
|
261
|
+
dataType: string;
|
|
262
|
+
}): string;
|
|
263
|
+
/**
|
|
264
|
+
* Port background tint, honouring the reserved error port's red affordance.
|
|
265
|
+
*/
|
|
266
|
+
export declare function getPortBackgroundColorForPort(checker: PortCompatibilityChecker, port: {
|
|
267
|
+
id: string;
|
|
268
|
+
type?: string;
|
|
269
|
+
dataType: string;
|
|
270
|
+
}, opacity?: number): string;
|
|
244
271
|
/**
|
|
245
272
|
* Convert RGB components to hex color string
|
|
246
273
|
* @param r - Red component (0-255)
|
package/dist/utils/colors.js
CHANGED
|
@@ -429,6 +429,29 @@ export function getPortBackgroundColor(checker, dataType, opacity = 25) {
|
|
|
429
429
|
export function getPortBorderColor(checker, dataType) {
|
|
430
430
|
return getDataTypeColorToken(checker, dataType);
|
|
431
431
|
}
|
|
432
|
+
/**
|
|
433
|
+
* Whether a port is the reserved `error` output port.
|
|
434
|
+
*
|
|
435
|
+
* The reserved error output carries an arbitrary data type (json) but should
|
|
436
|
+
* read as an error affordance (red) wherever it surfaces. See
|
|
437
|
+
* `.claude/plans/exposed-ports.md`.
|
|
438
|
+
*/
|
|
439
|
+
export function isErrorPort(port) {
|
|
440
|
+
return port.id === 'error' && port.type !== 'input';
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Port colour token: red for the reserved error output, else its data type.
|
|
444
|
+
*/
|
|
445
|
+
export function getPortColorToken(checker, port) {
|
|
446
|
+
return isErrorPort(port) ? 'var(--fd-node-red)' : getDataTypeColorToken(checker, port.dataType);
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Port background tint, honouring the reserved error port's red affordance.
|
|
450
|
+
*/
|
|
451
|
+
export function getPortBackgroundColorForPort(checker, port, opacity = 25) {
|
|
452
|
+
const colorToken = getPortColorToken(checker, port);
|
|
453
|
+
return `color-mix(in srgb, ${colorToken} ${opacity}%, transparent)`;
|
|
454
|
+
}
|
|
432
455
|
/**
|
|
433
456
|
* Convert RGB components to hex color string
|
|
434
457
|
* @param r - Red component (0-255)
|
|
@@ -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
|
-
*
|
|
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
|
-
*
|
|
17
|
-
|
|
18
|
-
|
|
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;
|
package/dist/utils/portUtils.js
CHANGED
|
@@ -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
|
-
*
|
|
83
|
+
* Whether a port is exposed, and so rendered on the canvas.
|
|
28
84
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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,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.
|
|
6
|
+
"version": "2.0.0-beta.7",
|
|
7
7
|
"author": "Shibin Das (D34dMan)",
|
|
8
8
|
"bugs": {
|
|
9
9
|
"url": "https://github.com/flowdrop-io/flowdrop/issues"
|