@flowdrop/flowdrop 2.3.0 → 2.5.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.
- package/CHANGELOG.md +39 -0
- package/dist/components/ConfigForm.svelte +4 -1
- package/dist/components/form/FormTemplateEditor.svelte +1 -2
- package/dist/components/ports/PortShapeSymbol.svelte +5 -3
- package/dist/config/defaultPortConfig.js +27 -9
- package/dist/editor/index.js +6 -3
- package/dist/openapi/v1/openapi.yaml +14 -1
- package/dist/schemas/v1/workflow.schema.json +9 -2
- package/dist/services/variableService.d.ts +47 -7
- package/dist/services/variableService.js +59 -20
- package/dist/styles/base.css +0 -31
- package/dist/styles/tokens.css +20 -0
- package/dist/types/index.d.ts +65 -1
- package/dist/utils/portShape.d.ts +35 -23
- package/dist/utils/portShape.js +69 -30
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,45 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.5.0] - 2026-08-23
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- **Six port lanes change colour, and two hues become reserved.** The lane palette had grown by accretion and had stopped carrying information: `file`/`file[]` wore red alongside `error`, so a failed run and a PDF read the same on the canvas; `video` and `messages` sat in the same family; `trigger` was purple, shared with `boolean`, and matched neither its own wire nor the colour the server sent. `tool` needed no move — it was already amber, and is now reserved there. The re-cut: **`file`/`file[]` red → teal**, **`video` teal → fuchsia**, **`messages` fuchsia → orange**, **`array` amber → violet**, **`trigger` purple → ink**. **This is a visible change on every canvas** — handles, chips and shape glyphs on those lanes are a different colour — and it is a change to `DEFAULT_PORT_CONFIG` only, so an app serving its own port config is untouched.
|
|
13
|
+
- **`--fd-node-red` is reserved for `error` and `--fd-node-amber` for `tool`.** Point a data lane at either and you undo the one distinction the palette exists to carry. `amber` and the new `ink` must also track their wires — `--fd-edge-tool` and `--fd-edge-trigger` — or an edge changes colour halfway along its length.
|
|
14
|
+
- The rule behind the rest: **a complex lane wears the hue of the shape it is made of.** `messages` joins `json`/`json[]` on orange because a message list is an array of objects; a _typed_ array inherits its element's hue (`string[]` emerald, `file[]` teal), which is why only the untyped `array` needs a token of its own; and an unclear shape falls back to the sink's slate. `docs/theming.md` now lists which lanes wear which token and states all of this, instead of printing a bare hex table.
|
|
15
|
+
- Two new tokens, both `@public`: **`--fd-node-violet`** (`#7c3aed` light, `#a78bfa` dark) for the untyped `array`, and **`--fd-node-ink`** for `trigger` — deliberately not a hue, resolving to `--_gray-9` / `--_gray-3` exactly as `--fd-edge-trigger` does. A fixed `#18181c` here disappears against the dark canvas.
|
|
16
|
+
- `flowdrop` (the Drupal module) moves its served payload identically, so an editor running against library defaults and one running against that payload agree on **all 24 lanes** — verified pairwise.
|
|
17
|
+
- Also documented in `docs/theming.md`, because it is the trap under all of this: if you redeclare `--fd-node-*` in a stylesheet that loads **after** this library's, redeclare the dark block too. A bare `:root` override loading later wins in both themes at equal specificity and silently flattens dark mode to the light values.
|
|
18
|
+
|
|
19
|
+
- **`WorkflowInterfaceEntry.schema` is a property fragment, not an object schema.** It was typed `InputSchema | OutputSchema` — a whole `{properties: {…}}` object — while nothing in the library populated it, which would have been wrong the moment something did. It is now `WorkflowInterfaceSchema` (`Partial<InputProperty>`): one port's JSON Schema fragment, every key optional, derived from the existing property type rather than restated. No runtime behaviour changes; nothing read or wrote this key.
|
|
20
|
+
|
|
21
|
+
- **The server's `dataType` on an interface entry is now the port's lane.** This library has always typed `WorkflowInterfaceEntry.dataType` as `NodeDataType` and rendered it through the lane-vocabulary picker, but fddo filled it with the fragment's JSON Schema `type` — so an `error` port arrived as `object` and a `messages` port as `array`, and the panel's lane chip contradicted the port the entry was bound to. fddo now sends the lane there and the JSON Schema fragment in `schema`. Nothing changes on this side of the wire; the values simply stop lying. **Needs a backend that serves it** — an older fddo still sends the JSON Schema word.
|
|
22
|
+
- Unchanged, and worth knowing: the server derives both keys from the bound inner port and **ignores them on write**. An author picking a lane in the interface panel is choosing a value the next read replaces. Persisting an author-chosen lane needs a server column that does not exist yet.
|
|
23
|
+
|
|
24
|
+
## [2.4.0] - 2026-08-23
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- **A port's shape now comes from the server when the server declares one.** fddo 2.x serves a JSON Schema per lane (`PortDataTypeConfig.schema`, from its port-shape registry), and `portShape()` reads that schema's `type` ahead of the client's static lane table. The table stays as the fallback — it is what answers on an older fddo, on a third-party server implementing only the port-config endpoint, and on the library's offline defaults, which carry no schemas on purpose. A site's own shape now shapes its own lane: declare `Order` as `type: object` and its ports draw `{}` without this library having heard of it.
|
|
29
|
+
|
|
30
|
+
- **Template variables drill into the fields a port's lane declares.** A template author could reach an `error` port and nothing inside it. A port with no schema of its own now resolves one from its lane, so the four fields of an error payload are offered as `error.message`, `error.code`, `error.node_id` and `error.retryable` — declared once on the lane, restated nowhere. `NodePort.schema` stays empty and stays the per-port refinement slot: what wants it is the narrower schema a run observed for this port on this node, which is per-instance information and could never travel on a payload cached per node type.
|
|
31
|
+
- **This needs a backend that serves it.** fddo serves lane schemas on `2.x`; anything older serves none, and autocomplete then stops at the port exactly as it did before. One caveat worth knowing: a site with a stored `port_config` entry for a lane replaces the composed entry outright, `schema` included — so a site that once customised the `error` lane sees no field list until it re-adds one. That is the port-config overlay's existing whole-entry merge semantics, not a new rule.
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
|
|
35
|
+
- **`getVariableSchema()`'s trailing arguments became one context object.** It had grown to eight positionals, the last three optional and one of them a service, so a call site read `..., workflowId, authProvider, fd.portCompatibility)` and could not be read without counting commas. It is now `(endpointConfig, node, nodes, edges, config, {workflowId, authProvider, portCompatibility})`. **Not a public break** — `variableService` is not exported from any package entry point; the change is listed because its docblock's examples were wrong in the released source (they omitted the first argument entirely) and are now correct.
|
|
36
|
+
|
|
37
|
+
### Deprecated
|
|
38
|
+
|
|
39
|
+
- **`portGlyph()`** — use `SHAPE_GLYPH[portShape(checker, port)]`, which is what it does. Both it and the map shipped in 2.3.0's public surface and only one of them needed to. It keeps working until 3.0.0.
|
|
40
|
+
|
|
41
|
+
### Fixed
|
|
42
|
+
|
|
43
|
+
- **The reserved `error` port drew `?` on every node.** fddo declares the `error` lane as `type: object` and has since its shape registry shipped; the client's lane table has no `error` entry, so the shape fell through to `unknown` while the lane chip beside it was correctly coloured red and — after the change above — while autocomplete was offering the payload's four fields. It draws `{}` now. Same class of disagreement for any served lane the table does not name.
|
|
44
|
+
|
|
45
|
+
- **Six responsive utility classes had never matched anything.** `.flowdrop-sm\:flex`, `.flowdrop-md\:hidden` and their siblings escaped the colon twice, so the selectors were never valid; nothing in the library or the demo apps used them, and this repo lints no CSS, so nothing was ever going to say so. Removed rather than repaired — two display utilities across three breakpoints is not a responsive system, and a consumer needing one can write it against their own breakpoints.
|
|
46
|
+
|
|
8
47
|
## [2.3.0] - 2026-08-22
|
|
9
48
|
|
|
10
49
|
### Added
|
|
@@ -577,7 +577,10 @@
|
|
|
577
577
|
// Compute the variable schema with optional port filtering and port name prefixing
|
|
578
578
|
const computedSchema = getAvailableVariables(node, workflowNodes, workflowEdges, {
|
|
579
579
|
targetPortIds: variablesConfig?.ports,
|
|
580
|
-
includePortName: variablesConfig?.includePortName
|
|
580
|
+
includePortName: variablesConfig?.includePortName,
|
|
581
|
+
// Lets a variable drill into the fields its port's LANE declares —
|
|
582
|
+
// `error.message` rather than only `error`.
|
|
583
|
+
portCompatibility: fd.portCompatibility
|
|
581
584
|
});
|
|
582
585
|
|
|
583
586
|
// Merge computed schema with any pre-defined schema
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
<script lang="ts">
|
|
21
21
|
import type { PortCompatibilityChecker } from '../../utils/connections.js';
|
|
22
22
|
import { getPortColorToken } from '../../utils/colors.js';
|
|
23
|
-
import {
|
|
23
|
+
import { portShape, SHAPE_GLYPH, SHAPE_LABEL } from '../../utils/portShape.js';
|
|
24
24
|
|
|
25
25
|
interface Props {
|
|
26
26
|
/** The instance's port-compatibility checker — the source of lane colour. */
|
|
@@ -38,8 +38,10 @@
|
|
|
38
38
|
|
|
39
39
|
/** Lane colour, or the reserved error output's red. */
|
|
40
40
|
const color = $derived(getPortColorToken(checker, port));
|
|
41
|
-
|
|
42
|
-
const
|
|
41
|
+
/** Resolved once — the glyph and its tooltip are two readings of one shape. */
|
|
42
|
+
const shape = $derived(portShape(checker, port));
|
|
43
|
+
const glyph = $derived(SHAPE_GLYPH[shape]);
|
|
44
|
+
const label = $derived(SHAPE_LABEL[shape]);
|
|
43
45
|
</script>
|
|
44
46
|
|
|
45
47
|
<span
|
|
@@ -48,12 +48,17 @@ export const DEFAULT_PORT_CONFIG = {
|
|
|
48
48
|
// The sink, not `string`: a port with no declared lane constrains nothing.
|
|
49
49
|
defaultDataType: 'mixed',
|
|
50
50
|
dataTypes: [
|
|
51
|
-
// Control flow types
|
|
51
|
+
// Control flow types.
|
|
52
|
+
//
|
|
53
|
+
// Ink, not a hue: the handle must read as the same thing as the trigger
|
|
54
|
+
// WIRE, which is `--fd-edge-trigger` — ink that flips with the theme. It
|
|
55
|
+
// sat on purple, sharing that hue with `boolean`, and matched neither the
|
|
56
|
+
// wire nor the served payload's cyan.
|
|
52
57
|
{
|
|
53
58
|
id: 'trigger',
|
|
54
59
|
name: 'Trigger',
|
|
55
60
|
description: 'Control flow of the workflow',
|
|
56
|
-
color: 'var(--fd-node-
|
|
61
|
+
color: 'var(--fd-node-ink)',
|
|
57
62
|
category: 'basic',
|
|
58
63
|
enabled: true
|
|
59
64
|
},
|
|
@@ -99,12 +104,15 @@ export const DEFAULT_PORT_CONFIG = {
|
|
|
99
104
|
category: 'logical',
|
|
100
105
|
enabled: true
|
|
101
106
|
},
|
|
102
|
-
// Collection types
|
|
107
|
+
// Collection types.
|
|
108
|
+
//
|
|
109
|
+
// Violet: the untyped array is the one array with no element hue to
|
|
110
|
+
// inherit. It had amber until `tool` took that to match its wire.
|
|
103
111
|
{
|
|
104
112
|
id: 'array',
|
|
105
113
|
name: 'Array',
|
|
106
114
|
description: 'Ordered list of items',
|
|
107
|
-
color: 'var(--fd-node-
|
|
115
|
+
color: 'var(--fd-node-violet)',
|
|
108
116
|
category: 'collection',
|
|
109
117
|
enabled: true
|
|
110
118
|
},
|
|
@@ -145,7 +153,7 @@ export const DEFAULT_PORT_CONFIG = {
|
|
|
145
153
|
id: 'file[]',
|
|
146
154
|
name: 'File Array',
|
|
147
155
|
description: 'Array of files',
|
|
148
|
-
color: 'var(--fd-node-
|
|
156
|
+
color: 'var(--fd-node-teal)',
|
|
149
157
|
category: 'collection',
|
|
150
158
|
enabled: true
|
|
151
159
|
},
|
|
@@ -166,12 +174,15 @@ export const DEFAULT_PORT_CONFIG = {
|
|
|
166
174
|
category: 'complex',
|
|
167
175
|
enabled: true
|
|
168
176
|
},
|
|
169
|
-
// File types
|
|
177
|
+
// File types.
|
|
178
|
+
//
|
|
179
|
+
// Teal, vacated by `video`. Red is reserved for `error` alone — a failed
|
|
180
|
+
// run and a PDF are not the same kind of thing and must not share a hue.
|
|
170
181
|
{
|
|
171
182
|
id: 'file',
|
|
172
183
|
name: 'File',
|
|
173
184
|
description: 'File data',
|
|
174
|
-
color: 'var(--fd-node-
|
|
185
|
+
color: 'var(--fd-node-teal)',
|
|
175
186
|
category: 'file',
|
|
176
187
|
enabled: true
|
|
177
188
|
},
|
|
@@ -192,11 +203,14 @@ export const DEFAULT_PORT_CONFIG = {
|
|
|
192
203
|
category: 'media',
|
|
193
204
|
enabled: true
|
|
194
205
|
},
|
|
206
|
+
// Fuchsia, freed by `messages`. Landing beside `image`'s pink is wanted:
|
|
207
|
+
// the two are both visual media, so the near-adjacency reads as a family
|
|
208
|
+
// rather than as a collision.
|
|
195
209
|
{
|
|
196
210
|
id: 'video',
|
|
197
211
|
name: 'Video',
|
|
198
212
|
description: 'Video data',
|
|
199
|
-
color: 'var(--fd-node-
|
|
213
|
+
color: 'var(--fd-node-fuchsia)',
|
|
200
214
|
category: 'media',
|
|
201
215
|
enabled: true
|
|
202
216
|
},
|
|
@@ -253,11 +267,15 @@ export const DEFAULT_PORT_CONFIG = {
|
|
|
253
267
|
// A list of provider-shaped chat messages. JSON-Schema `array`
|
|
254
268
|
// underneath, but not an arbitrary array — which is the whole reason it
|
|
255
269
|
// is its own lane.
|
|
270
|
+
//
|
|
271
|
+
// Orange, with `json` and `json[]`: a complex lane wears the hue of the
|
|
272
|
+
// shape it is made of, and a message list is an array of objects. It sat
|
|
273
|
+
// alone on fuchsia, which said nothing about what it carries.
|
|
256
274
|
{
|
|
257
275
|
id: 'messages',
|
|
258
276
|
name: 'Messages',
|
|
259
277
|
description: 'A conversation: a list of provider-shaped chat messages',
|
|
260
|
-
color: 'var(--fd-node-
|
|
278
|
+
color: 'var(--fd-node-orange)',
|
|
261
279
|
category: 'complex',
|
|
262
280
|
enabled: true
|
|
263
281
|
}
|
package/dist/editor/index.js
CHANGED
|
@@ -130,14 +130,17 @@ export { isLoopbackEdge, isValidLoopbackCycle, PortCompatibilityChecker, getPoss
|
|
|
130
130
|
// A port's JSON-Schema shape and its semantic lane are two separate marks on
|
|
131
131
|
// the canvas: a small coloured glyph for the shape, a quiet outlined chip for
|
|
132
132
|
// the lane's name. `PortTypeBadge` draws one port's whole label row; the rest
|
|
133
|
-
// is for a custom node component that wants the same glyph vocabulary.
|
|
134
|
-
//
|
|
133
|
+
// is for a custom node component that wants the same glyph vocabulary.
|
|
134
|
+
// `portShape` takes the instance's port-compatibility checker, the same source
|
|
135
135
|
// colour reads, so a served or aliased lane shapes the way it colours. See
|
|
136
136
|
// utils/portShape.ts for where the shape comes from.
|
|
137
137
|
//
|
|
138
138
|
// Deliberately small: the lane table, the shape labels and the two-component
|
|
139
139
|
// split behind `PortTypeBadge` are implementation, and stay so until something
|
|
140
|
-
// outside the library needs them.
|
|
140
|
+
// outside the library needs them. `portGlyph` is the one name here that fails
|
|
141
|
+
// that test — it is `SHAPE_GLYPH[portShape(…)]`, and shipping both it and the
|
|
142
|
+
// map was a surface we did not need. Deprecated rather than deleted: it went
|
|
143
|
+
// out in 2.3.0, so it leaves in 3.0.0.
|
|
141
144
|
export { SHAPE_GLYPH, portShape, portGlyph } from '../utils/portShape.js';
|
|
142
145
|
export { default as PortTypeBadge } from '../components/ports/PortTypeBadge.svelte';
|
|
143
146
|
// ============================================================================
|
|
@@ -4021,6 +4021,13 @@ components:
|
|
|
4021
4021
|
description: Help text describing what this entry represents to external callers.
|
|
4022
4022
|
dataType:
|
|
4023
4023
|
$ref: '#/components/schemas/NodeDataType'
|
|
4024
|
+
description: |
|
|
4025
|
+
The port's LANE — what it is and what it may connect to — not the JSON
|
|
4026
|
+
Schema type of its value, which is `schema.type`. The two vocabularies
|
|
4027
|
+
overlap on `string`/`number`/`boolean`/`array` and diverge where it
|
|
4028
|
+
matters: a `messages` port is a JSON `array`, an `error` port a JSON
|
|
4029
|
+
`object`. Derived by the server from the bound inner port and ignored
|
|
4030
|
+
on write.
|
|
4024
4031
|
required:
|
|
4025
4032
|
type: boolean
|
|
4026
4033
|
description: Whether callers must supply a value. Inputs only; ignored on outputs.
|
|
@@ -4035,7 +4042,13 @@ components:
|
|
|
4035
4042
|
only; ignored on outputs. Never validated against `schema`.
|
|
4036
4043
|
schema:
|
|
4037
4044
|
$ref: '#/components/schemas/PortDataSchema'
|
|
4038
|
-
description:
|
|
4045
|
+
description: |
|
|
4046
|
+
The JSON Schema fragment for this one port — a single property's
|
|
4047
|
+
schema (`{"type": "array"}`), not a whole object schema. Carries the
|
|
4048
|
+
structural contract only: whatever the entry states itself (the lane,
|
|
4049
|
+
`name`, `description`, `examples`, `required`) is not repeated inside
|
|
4050
|
+
it. Derived by the server from the bound inner port and ignored on
|
|
4051
|
+
write; absent when the bound port declares no structural contract.
|
|
4039
4052
|
bindings:
|
|
4040
4053
|
type: array
|
|
4041
4054
|
items:
|
|
@@ -1122,7 +1122,14 @@
|
|
|
1122
1122
|
"description": "Help text describing what this entry represents to external callers."
|
|
1123
1123
|
},
|
|
1124
1124
|
"dataType": {
|
|
1125
|
-
"
|
|
1125
|
+
"allOf": [
|
|
1126
|
+
{
|
|
1127
|
+
"$ref": "#/$defs/NodeDataType"
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
"description": "The port's LANE — what it is and what it may connect to — not the JSON\nSchema type of its value, which is `schema.type`. The two vocabularies\noverlap on `string`/`number`/`boolean`/`array` and diverge where it\nmatters: a `messages` port is a JSON `array`, an `error` port a JSON\n`object`. Derived by the server from the bound inner port and ignored\non write.\n"
|
|
1131
|
+
}
|
|
1132
|
+
]
|
|
1126
1133
|
},
|
|
1127
1134
|
"required": {
|
|
1128
1135
|
"type": "boolean",
|
|
@@ -1142,7 +1149,7 @@
|
|
|
1142
1149
|
"$ref": "#/$defs/PortDataSchema"
|
|
1143
1150
|
},
|
|
1144
1151
|
{
|
|
1145
|
-
"description": "JSON Schema
|
|
1152
|
+
"description": "The JSON Schema fragment for this one port — a single property's\nschema (`{\"type\": \"array\"}`), not a whole object schema. Carries the\nstructural contract only: whatever the entry states itself (the lane,\n`name`, `description`, `examples`, `required`) is not repeated inside\nit. Derived by the server from the bound inner port and ignored on\nwrite; absent when the bound port declares no structural contract.\n"
|
|
1146
1153
|
}
|
|
1147
1154
|
]
|
|
1148
1155
|
},
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { WorkflowNode, WorkflowEdge, VariableSchema, TemplateVariable, TemplateVariablesConfig, AuthProvider } from '../types/index.js';
|
|
9
9
|
import type { EndpointConfig } from '../config/endpoints.js';
|
|
10
|
+
import type { PortCompatibilityChecker } from '../utils/connections.js';
|
|
10
11
|
/**
|
|
11
12
|
* Options for deriving available variables.
|
|
12
13
|
*/
|
|
@@ -23,6 +24,15 @@ export interface GetAvailableVariablesOptions {
|
|
|
23
24
|
* When false (default), schema properties are unpacked as top-level variables.
|
|
24
25
|
*/
|
|
25
26
|
includePortName?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The instance's port compatibility checker, used to read the schema a
|
|
29
|
+
* port's LANE declares when the port declares none of its own.
|
|
30
|
+
*
|
|
31
|
+
* Optional, and omitting it costs only depth: variables still resolve, they
|
|
32
|
+
* just stop at the port instead of drilling into its fields. That is the
|
|
33
|
+
* pre-shape behaviour, so an embedder that never passes it sees no change.
|
|
34
|
+
*/
|
|
35
|
+
portCompatibility?: PortCompatibilityChecker;
|
|
26
36
|
}
|
|
27
37
|
/**
|
|
28
38
|
* Derives available template variables from connected upstream nodes.
|
|
@@ -108,35 +118,65 @@ export declare function hasChildren(schema: VariableSchema, path: string): boole
|
|
|
108
118
|
* ```
|
|
109
119
|
*/
|
|
110
120
|
export declare function mergeVariableSchemas(primary: VariableSchema, secondary: VariableSchema): VariableSchema;
|
|
121
|
+
/**
|
|
122
|
+
* The optional context {@link getVariableSchema} resolves variables against.
|
|
123
|
+
*
|
|
124
|
+
* A bag rather than three more positional parameters: the required five say
|
|
125
|
+
* WHAT to resolve, and everything here says what is available while doing it.
|
|
126
|
+
* The signature had grown to eight positionals, of which the last three were
|
|
127
|
+
* optional and one was a service — a call site read
|
|
128
|
+
* `..., workflowId, authProvider, fd.portCompatibility)` and there was no
|
|
129
|
+
* reading it without counting commas.
|
|
130
|
+
*/
|
|
131
|
+
export interface GetVariableSchemaContext {
|
|
132
|
+
/** Workflow id, for the API mode's endpoint interpolation. */
|
|
133
|
+
workflowId?: string;
|
|
134
|
+
/** Auth provider for the API-mode request. */
|
|
135
|
+
authProvider?: AuthProvider;
|
|
136
|
+
/**
|
|
137
|
+
* The instance's port compatibility checker, used to read the schema a port's
|
|
138
|
+
* LANE declares when the port declares none of its own. Omitting it costs
|
|
139
|
+
* only depth — see {@link GetAvailableVariablesOptions.portCompatibility}.
|
|
140
|
+
*/
|
|
141
|
+
portCompatibility?: PortCompatibilityChecker;
|
|
142
|
+
}
|
|
111
143
|
/**
|
|
112
144
|
* Gets variable schema using the appropriate mode (API, schema-based, or hybrid).
|
|
113
145
|
* This is the main orchestration function that determines how to fetch variables
|
|
114
146
|
* based on the configuration.
|
|
115
147
|
*
|
|
148
|
+
* @param endpointConfig - API endpoint configuration, or null when there is none
|
|
116
149
|
* @param node - The current node being configured
|
|
117
150
|
* @param nodes - All nodes in the workflow
|
|
118
151
|
* @param edges - All edges in the workflow
|
|
119
152
|
* @param config - Template variables configuration
|
|
120
|
-
* @param
|
|
121
|
-
*
|
|
153
|
+
* @param context - Optional resolution context: workflow id, auth provider, and
|
|
154
|
+
* the port compatibility checker
|
|
122
155
|
* @returns A promise that resolves to the variable schema
|
|
123
156
|
*
|
|
124
157
|
* @example
|
|
125
158
|
* ```typescript
|
|
126
159
|
* // Schema-based mode (existing behavior)
|
|
127
160
|
* const config = { ports: ["data"], schema: {...} };
|
|
128
|
-
* const schema = await getVariableSchema(node, nodes, edges, config);
|
|
161
|
+
* const schema = await getVariableSchema(null, node, nodes, edges, config);
|
|
129
162
|
*
|
|
130
163
|
* // API mode
|
|
131
164
|
* const config = { api: { endpoint: { url: "/api/variables/{workflowId}/{nodeId}" } } };
|
|
132
|
-
* const schema = await getVariableSchema(node, nodes, edges, config,
|
|
165
|
+
* const schema = await getVariableSchema(endpointConfig, node, nodes, edges, config, {
|
|
166
|
+
* workflowId,
|
|
167
|
+
* authProvider
|
|
168
|
+
* });
|
|
133
169
|
*
|
|
134
|
-
* // Hybrid mode (API + static schema)
|
|
170
|
+
* // Hybrid mode (API + static schema), drilling into each port's lane schema
|
|
135
171
|
* const config = {
|
|
136
172
|
* schema: {...},
|
|
137
173
|
* api: { endpoint: {...}, mergeWithSchema: true }
|
|
138
174
|
* };
|
|
139
|
-
* const schema = await getVariableSchema(node, nodes, edges, config,
|
|
175
|
+
* const schema = await getVariableSchema(endpointConfig, node, nodes, edges, config, {
|
|
176
|
+
* workflowId,
|
|
177
|
+
* authProvider,
|
|
178
|
+
* portCompatibility: fd.portCompatibility
|
|
179
|
+
* });
|
|
140
180
|
* ```
|
|
141
181
|
*/
|
|
142
|
-
export declare function getVariableSchema(endpointConfig: EndpointConfig | null, node: WorkflowNode, nodes: WorkflowNode[], edges: WorkflowEdge[], config: TemplateVariablesConfig,
|
|
182
|
+
export declare function getVariableSchema(endpointConfig: EndpointConfig | null, node: WorkflowNode, nodes: WorkflowNode[], edges: WorkflowEdge[], config: TemplateVariablesConfig, context?: GetVariableSchemaContext): Promise<VariableSchema>;
|
|
@@ -64,17 +64,42 @@ function propertyToTemplateVariable(name, property, sourcePort, sourceNode) {
|
|
|
64
64
|
}
|
|
65
65
|
return variable;
|
|
66
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* The schema in force for a port: its own if it has one, else its lane's.
|
|
69
|
+
*
|
|
70
|
+
* A port's own schema is the refinement — narrower, and specific to this port —
|
|
71
|
+
* so it wins. The lane's schema is what a port shape declares, served once on
|
|
72
|
+
* the lane entry for every port that declares the lane, which is how the
|
|
73
|
+
* `error` port comes to know it carries `{message, code, node_id, retryable}`.
|
|
74
|
+
*
|
|
75
|
+
* Resolved through the checker rather than a private lookup, for the reason
|
|
76
|
+
* `portShape()` is: a table of its own cannot follow an alias, so the same
|
|
77
|
+
* lane could come back styled and schemaless at once.
|
|
78
|
+
*
|
|
79
|
+
* @param port - The port to resolve a schema for
|
|
80
|
+
* @param checker - The instance's compatibility checker, when one is available
|
|
81
|
+
* @returns The schema in force, or undefined when neither declares one
|
|
82
|
+
*/
|
|
83
|
+
function resolvePortSchema(port, checker) {
|
|
84
|
+
if (port.schema)
|
|
85
|
+
return port.schema;
|
|
86
|
+
if (!checker || !port.dataType)
|
|
87
|
+
return undefined;
|
|
88
|
+
return checker.getDataTypeConfig(port.dataType)?.schema;
|
|
89
|
+
}
|
|
67
90
|
/**
|
|
68
91
|
* Creates a TemplateVariable from a NodePort.
|
|
69
|
-
* Uses the port
|
|
92
|
+
* Uses the schema in force for the port if there is one, otherwise creates a
|
|
93
|
+
* basic variable from the port's lane.
|
|
70
94
|
*
|
|
71
95
|
* @param port - The output port to convert
|
|
72
96
|
* @param sourceNode - The source node ID
|
|
97
|
+
* @param schema - The schema in force, from {@link resolvePortSchema}
|
|
73
98
|
* @returns A TemplateVariable representing the port's data
|
|
74
99
|
*/
|
|
75
|
-
function portToTemplateVariable(port, sourceNode) {
|
|
76
|
-
// If
|
|
77
|
-
if (
|
|
100
|
+
function portToTemplateVariable(port, sourceNode, schema) {
|
|
101
|
+
// If a schema is in force, use it to build a detailed variable
|
|
102
|
+
if (schema && schema.properties) {
|
|
78
103
|
const variable = {
|
|
79
104
|
name: port.id,
|
|
80
105
|
label: port.name,
|
|
@@ -84,7 +109,7 @@ function portToTemplateVariable(port, sourceNode) {
|
|
|
84
109
|
sourceNode,
|
|
85
110
|
properties: {}
|
|
86
111
|
};
|
|
87
|
-
for (const [propName, propValue] of Object.entries(
|
|
112
|
+
for (const [propName, propValue] of Object.entries(schema.properties)) {
|
|
88
113
|
variable.properties[propName] = propertyToTemplateVariable(propName, propValue, port.id, sourceNode);
|
|
89
114
|
}
|
|
90
115
|
return variable;
|
|
@@ -181,7 +206,7 @@ function findUpstreamConnections(node, nodes, edges) {
|
|
|
181
206
|
*/
|
|
182
207
|
export function getAvailableVariables(node, nodes, edges, options) {
|
|
183
208
|
const variables = {};
|
|
184
|
-
const { targetPortIds, includePortName } = options ?? {};
|
|
209
|
+
const { targetPortIds, includePortName, portCompatibility } = options ?? {};
|
|
185
210
|
// Find all upstream connections
|
|
186
211
|
const connections = findUpstreamConnections(node, nodes, edges);
|
|
187
212
|
for (const connection of connections) {
|
|
@@ -200,11 +225,14 @@ export function getAvailableVariables(node, nodes, edges, options) {
|
|
|
200
225
|
}
|
|
201
226
|
if (!sourcePort)
|
|
202
227
|
continue;
|
|
203
|
-
//
|
|
204
|
-
//
|
|
205
|
-
|
|
228
|
+
// The schema in force for this port: its own, else the one its lane
|
|
229
|
+
// declares. Resolved once, because both branches below read it.
|
|
230
|
+
const sourceSchema = resolvePortSchema(sourcePort, portCompatibility);
|
|
231
|
+
// If the schema has top-level properties, unpack them as top-level
|
|
232
|
+
// variables (unless includePortName is true)
|
|
233
|
+
if (sourceSchema?.properties && !includePortName) {
|
|
206
234
|
// Unpack schema properties as top-level variables
|
|
207
|
-
for (const [propName, propValue] of Object.entries(
|
|
235
|
+
for (const [propName, propValue] of Object.entries(sourceSchema.properties)) {
|
|
208
236
|
// Skip if we already have a variable with this name
|
|
209
237
|
if (variables[propName])
|
|
210
238
|
continue;
|
|
@@ -217,7 +245,7 @@ export function getAvailableVariables(node, nodes, edges, options) {
|
|
|
217
245
|
// Skip if we already have a variable with this name
|
|
218
246
|
if (variables[variableName])
|
|
219
247
|
continue;
|
|
220
|
-
const variable = portToTemplateVariable(sourcePort, sourceNode.id);
|
|
248
|
+
const variable = portToTemplateVariable(sourcePort, sourceNode.id, sourceSchema);
|
|
221
249
|
variable.name = variableName;
|
|
222
250
|
variable.label = targetPort?.name ?? sourcePort.name;
|
|
223
251
|
variables[variableName] = variable;
|
|
@@ -379,33 +407,42 @@ export function mergeVariableSchemas(primary, secondary) {
|
|
|
379
407
|
* This is the main orchestration function that determines how to fetch variables
|
|
380
408
|
* based on the configuration.
|
|
381
409
|
*
|
|
410
|
+
* @param endpointConfig - API endpoint configuration, or null when there is none
|
|
382
411
|
* @param node - The current node being configured
|
|
383
412
|
* @param nodes - All nodes in the workflow
|
|
384
413
|
* @param edges - All edges in the workflow
|
|
385
414
|
* @param config - Template variables configuration
|
|
386
|
-
* @param
|
|
387
|
-
*
|
|
415
|
+
* @param context - Optional resolution context: workflow id, auth provider, and
|
|
416
|
+
* the port compatibility checker
|
|
388
417
|
* @returns A promise that resolves to the variable schema
|
|
389
418
|
*
|
|
390
419
|
* @example
|
|
391
420
|
* ```typescript
|
|
392
421
|
* // Schema-based mode (existing behavior)
|
|
393
422
|
* const config = { ports: ["data"], schema: {...} };
|
|
394
|
-
* const schema = await getVariableSchema(node, nodes, edges, config);
|
|
423
|
+
* const schema = await getVariableSchema(null, node, nodes, edges, config);
|
|
395
424
|
*
|
|
396
425
|
* // API mode
|
|
397
426
|
* const config = { api: { endpoint: { url: "/api/variables/{workflowId}/{nodeId}" } } };
|
|
398
|
-
* const schema = await getVariableSchema(node, nodes, edges, config,
|
|
427
|
+
* const schema = await getVariableSchema(endpointConfig, node, nodes, edges, config, {
|
|
428
|
+
* workflowId,
|
|
429
|
+
* authProvider
|
|
430
|
+
* });
|
|
399
431
|
*
|
|
400
|
-
* // Hybrid mode (API + static schema)
|
|
432
|
+
* // Hybrid mode (API + static schema), drilling into each port's lane schema
|
|
401
433
|
* const config = {
|
|
402
434
|
* schema: {...},
|
|
403
435
|
* api: { endpoint: {...}, mergeWithSchema: true }
|
|
404
436
|
* };
|
|
405
|
-
* const schema = await getVariableSchema(node, nodes, edges, config,
|
|
437
|
+
* const schema = await getVariableSchema(endpointConfig, node, nodes, edges, config, {
|
|
438
|
+
* workflowId,
|
|
439
|
+
* authProvider,
|
|
440
|
+
* portCompatibility: fd.portCompatibility
|
|
441
|
+
* });
|
|
406
442
|
* ```
|
|
407
443
|
*/
|
|
408
|
-
export async function getVariableSchema(endpointConfig, node, nodes, edges, config,
|
|
444
|
+
export async function getVariableSchema(endpointConfig, node, nodes, edges, config, context) {
|
|
445
|
+
const { workflowId, authProvider, portCompatibility } = context ?? {};
|
|
409
446
|
let resultSchema = { variables: {} };
|
|
410
447
|
// Try API mode first (if configured)
|
|
411
448
|
if (config.api) {
|
|
@@ -423,7 +460,8 @@ export async function getVariableSchema(endpointConfig, node, nodes, edges, conf
|
|
|
423
460
|
if (config.api.mergeWithPorts) {
|
|
424
461
|
const portSchema = getAvailableVariables(node, nodes, edges, {
|
|
425
462
|
targetPortIds: config.ports,
|
|
426
|
-
includePortName: config.includePortName
|
|
463
|
+
includePortName: config.includePortName,
|
|
464
|
+
portCompatibility
|
|
427
465
|
});
|
|
428
466
|
resultSchema = mergeVariableSchemas(resultSchema, portSchema);
|
|
429
467
|
}
|
|
@@ -451,7 +489,8 @@ export async function getVariableSchema(endpointConfig, node, nodes, edges, conf
|
|
|
451
489
|
if (config.ports !== undefined || !config.api) {
|
|
452
490
|
const portSchema = getAvailableVariables(node, nodes, edges, {
|
|
453
491
|
targetPortIds: config.ports,
|
|
454
|
-
includePortName: config.includePortName
|
|
492
|
+
includePortName: config.includePortName,
|
|
493
|
+
portCompatibility
|
|
455
494
|
});
|
|
456
495
|
resultSchema = portSchema;
|
|
457
496
|
}
|
package/dist/styles/base.css
CHANGED
|
@@ -1026,37 +1026,6 @@ p {
|
|
|
1026
1026
|
opacity: 0.6;
|
|
1027
1027
|
}
|
|
1028
1028
|
|
|
1029
|
-
/* Responsive utilities */
|
|
1030
|
-
@media (min-width: 640px) {
|
|
1031
|
-
.flowdrop-sm\\:flex {
|
|
1032
|
-
display: flex;
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
.flowdrop-sm\\:hidden {
|
|
1036
|
-
display: none;
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
@media (min-width: 768px) {
|
|
1041
|
-
.flowdrop-md\\:flex {
|
|
1042
|
-
display: flex;
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
.flowdrop-md\\:hidden {
|
|
1046
|
-
display: none;
|
|
1047
|
-
}
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
@media (min-width: 1024px) {
|
|
1051
|
-
.flowdrop-lg\\:flex {
|
|
1052
|
-
display: flex;
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
.flowdrop-lg\\:hidden {
|
|
1056
|
-
display: none;
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
1029
|
/* Color system - Category colors */
|
|
1061
1030
|
.flowdrop-color--primary {
|
|
1062
1031
|
background-color: var(--fd-primary);
|
package/dist/styles/tokens.css
CHANGED
|
@@ -323,6 +323,22 @@
|
|
|
323
323
|
--fd-node-purple: #9333ea; /* @public */
|
|
324
324
|
--fd-node-fuchsia: #d946ef; /* @public */
|
|
325
325
|
|
|
326
|
+
/**
|
|
327
|
+
* The control lane's ink. Deliberately NOT a hue: a trigger handle must read
|
|
328
|
+
* as the same thing as the trigger WIRE, and `--fd-edge-trigger` is ink that
|
|
329
|
+
* flips with the theme rather than a fixed black. Keep the two in step — a
|
|
330
|
+
* literal #18181c handle disappears against the dark canvas.
|
|
331
|
+
*/
|
|
332
|
+
--fd-node-ink: var(--_gray-9); /* @public */
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Worn by the untyped `array` lane, and by nothing else. A TYPED array
|
|
336
|
+
* inherits its element's hue (`string[]` is emerald, `file[]` is teal), so
|
|
337
|
+
* the one array with no element shape needs a hue of its own. It had amber
|
|
338
|
+
* until `tool` took that to match `--fd-edge-tool`.
|
|
339
|
+
*/
|
|
340
|
+
--fd-node-violet: #7c3aed; /* @public */
|
|
341
|
+
|
|
326
342
|
/** Icon on node squircle: dark in light theme, white in dark theme */
|
|
327
343
|
--fd-node-icon: var(--_gray-9); /* @public */
|
|
328
344
|
/** Opacity of the icon squircle background (color-mix percentage). Light mode: 15% / 22% hover; dark mode uses higher values. */
|
|
@@ -469,6 +485,10 @@
|
|
|
469
485
|
--fd-node-purple: #c084fc;
|
|
470
486
|
--fd-node-fuchsia: #e879f9;
|
|
471
487
|
|
|
488
|
+
/* Mirrors --fd-edge-trigger's dark value, so handle and wire stay one colour. */
|
|
489
|
+
--fd-node-ink: var(--_gray-3);
|
|
490
|
+
--fd-node-violet: #a78bfa;
|
|
491
|
+
|
|
472
492
|
/** Icon on node squircle: white in dark theme */
|
|
473
493
|
--fd-node-icon: #ffffff;
|
|
474
494
|
/** Icon squircle background opacity: higher in dark mode for visibility on dark surfaces */
|
package/dist/types/index.d.ts
CHANGED
|
@@ -75,6 +75,38 @@ export interface PortDataTypeConfig {
|
|
|
75
75
|
aliases?: string[];
|
|
76
76
|
/** Whether this data type is enabled */
|
|
77
77
|
enabled?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* The JSON Schema this lane promises, when a port shape declares one.
|
|
80
|
+
*
|
|
81
|
+
* This is what lets template autocomplete offer `error.message` rather than
|
|
82
|
+
* only `error`: the lane says what fields travel on it, once, for every port
|
|
83
|
+
* that declares the lane. Absent — not empty — when the lane promises
|
|
84
|
+
* nothing beyond its name, so "no promise" stays distinguishable from
|
|
85
|
+
* "an object with no properties".
|
|
86
|
+
*
|
|
87
|
+
* Authoring information only. Nothing validates a value against it, and a
|
|
88
|
+
* port may still carry a NARROWER {@link NodePort.schema} of its own, which
|
|
89
|
+
* wins.
|
|
90
|
+
*/
|
|
91
|
+
schema?: PortSchema;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* A JSON Schema as served on a lane entry or a port.
|
|
95
|
+
*
|
|
96
|
+
* Deliberately looser than {@link OutputSchema}: a lane may promise something
|
|
97
|
+
* that is not an object at all (the `messages` lane is a top-level `array`),
|
|
98
|
+
* and a JSON Schema's keyword space is not ours to enumerate — the backend
|
|
99
|
+
* stores it untyped for exactly that reason. Readers take `properties` when
|
|
100
|
+
* there is one and fall back to the port itself when there is not.
|
|
101
|
+
*/
|
|
102
|
+
export interface PortSchema {
|
|
103
|
+
type?: string;
|
|
104
|
+
title?: string;
|
|
105
|
+
description?: string;
|
|
106
|
+
required?: string[];
|
|
107
|
+
properties?: Record<string, BaseProperty>;
|
|
108
|
+
items?: BaseProperty;
|
|
109
|
+
[key: string]: unknown;
|
|
78
110
|
}
|
|
79
111
|
/**
|
|
80
112
|
* Port compatibility rule configuration
|
|
@@ -136,6 +168,13 @@ export interface NodePort {
|
|
|
136
168
|
/**
|
|
137
169
|
* Optional JSON Schema describing the structure of data on this port.
|
|
138
170
|
* Used for template variable autocomplete to drill into nested properties.
|
|
171
|
+
*
|
|
172
|
+
* This is the per-port REFINEMENT slot, and it wins over the schema the
|
|
173
|
+
* port's lane declares ({@link PortDataTypeConfig.schema}), which is where a
|
|
174
|
+
* shape's own field list travels. It is left for the narrower thing: a
|
|
175
|
+
* schema that applies to this port on this node in this workflow rather than
|
|
176
|
+
* to the lane in general — a lane promising `object` whose values turn out
|
|
177
|
+
* to carry `{title, description}`. Nothing populates it yet.
|
|
139
178
|
*/
|
|
140
179
|
schema?: OutputSchema | InputSchema;
|
|
141
180
|
}
|
|
@@ -1238,6 +1277,15 @@ export interface PortBinding {
|
|
|
1238
1277
|
nodeId: string;
|
|
1239
1278
|
portId: string;
|
|
1240
1279
|
}
|
|
1280
|
+
/**
|
|
1281
|
+
* A single port's JSON Schema fragment as it rides a workflow's contract.
|
|
1282
|
+
*
|
|
1283
|
+
* Derived from {@link InputProperty} rather than restated, so the fragment
|
|
1284
|
+
* vocabulary has one definition; every key is optional because an interface
|
|
1285
|
+
* entry states its own annotations one level up and the server strips them
|
|
1286
|
+
* from the fragment on the way out.
|
|
1287
|
+
*/
|
|
1288
|
+
export type WorkflowInterfaceSchema = Partial<InputProperty>;
|
|
1241
1289
|
/**
|
|
1242
1290
|
* One entry in a workflow's public contract. Owns its own identity: `id` is
|
|
1243
1291
|
* stable and workflow-scoped, independent of whichever inner port it currently
|
|
@@ -1263,7 +1311,23 @@ export interface WorkflowInterfaceEntry {
|
|
|
1263
1311
|
* outputs. Never validated against `schema`.
|
|
1264
1312
|
*/
|
|
1265
1313
|
examples?: unknown[];
|
|
1266
|
-
|
|
1314
|
+
/**
|
|
1315
|
+
* The port's JSON Schema fragment — the shape of the value, as opposed to
|
|
1316
|
+
* `dataType`, which is the lane it travels in. These are two vocabularies
|
|
1317
|
+
* that overlap on `string`/`number`/`boolean`/`array` and diverge exactly
|
|
1318
|
+
* where it matters: a `messages` port is an `array`, an `error` port is an
|
|
1319
|
+
* `object`, and a named shape is whatever its schema says.
|
|
1320
|
+
*
|
|
1321
|
+
* A single PROPERTY fragment, not an object schema — this was typed
|
|
1322
|
+
* `InputSchema | OutputSchema` (a whole `{properties: {...}}` object) while
|
|
1323
|
+
* nothing populated it, which would have been wrong the moment something
|
|
1324
|
+
* did. Every key is optional because the server strips what the entry
|
|
1325
|
+
* already states: no `title`/`description`/`examples`/`required`, and no
|
|
1326
|
+
* lane, since that is `dataType`.
|
|
1327
|
+
*
|
|
1328
|
+
* Absent when the bound port declares no structural contract at all.
|
|
1329
|
+
*/
|
|
1330
|
+
schema?: WorkflowInterfaceSchema;
|
|
1267
1331
|
/**
|
|
1268
1332
|
* Inner ports this entry maps to. Every entry — input or output — must
|
|
1269
1333
|
* resolve to exactly one binding; more than one is reported as `over-bound`.
|
|
@@ -10,23 +10,33 @@
|
|
|
10
10
|
*
|
|
11
11
|
* ## Where the shape comes from
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
* declared for template autocomplete and no producer populates it), so the
|
|
15
|
-
* shape is derived client-side from the lane. Every lane FlowDrop ships implies
|
|
16
|
-
* exactly one shape, so the map below answers the question against every
|
|
17
|
-
* backend — including older fddo and third-party servers that only implement
|
|
18
|
-
* the port-config endpoint.
|
|
13
|
+
* Two sources, in this order:
|
|
19
14
|
*
|
|
20
|
-
*
|
|
15
|
+
* 1. **The lane's served schema** (`PortDataTypeConfig.schema`) — a JSON Schema
|
|
16
|
+
* the backend's shape registry declares for the lane. Its `type` IS the
|
|
17
|
+
* shape, said by the side that knows: fddo's `error` shape declares
|
|
18
|
+
* `type: object`, `messages` declares `type: array`, and a site's own
|
|
19
|
+
* `Order` shape answers for itself without the client having heard of it.
|
|
20
|
+
* 2. **The lane table below**, when no schema is served — which is every lane
|
|
21
|
+
* on an older fddo, on a third-party server implementing only the
|
|
22
|
+
* port-config endpoint, and on the library's offline defaults (which stay
|
|
23
|
+
* presentation-only on purpose and carry no schemas).
|
|
24
|
+
*
|
|
25
|
+
* The table was the whole answer before shapes reached the wire, and the
|
|
26
|
+
* ordering above is why the fallback stays: it is what draws a glyph when
|
|
27
|
+
* nothing declares one, not a second opinion competing with a served answer.
|
|
28
|
+
*
|
|
29
|
+
* Two things the fallback cannot do, both known and accepted:
|
|
21
30
|
* - **`integer` vs `number` collapse.** The server already maps both onto lane
|
|
22
|
-
* `number`, so nothing is lost that the client ever had.
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
31
|
+
* `number`, so nothing is lost that the client ever had. A served schema
|
|
32
|
+
* saying `integer` collapses the same way, for the same reason.
|
|
33
|
+
* - **A site-defined lane with no shape resolves to `unknown` (`?`).** A lane
|
|
34
|
+
* added through the `port_config` overlay alone has nothing to read. `?` is
|
|
35
|
+
* the honest answer, and declaring a shape for the lane is how a site
|
|
36
|
+
* improves it.
|
|
26
37
|
*
|
|
27
|
-
* {@link portShape} is the
|
|
28
|
-
*
|
|
29
|
-
* function and no caller.
|
|
38
|
+
* {@link portShape} is the one function either source is read in, which is what
|
|
39
|
+
* kept adding the first source to a single place.
|
|
30
40
|
*
|
|
31
41
|
* It takes the **checker** for exactly that reason. Colour has always asked the
|
|
32
42
|
* checker, which resolves an alias to its canonical lane and sees whatever the
|
|
@@ -83,19 +93,21 @@ interface ShapedPort {
|
|
|
83
93
|
*/
|
|
84
94
|
export declare function laneShape(dataType: string | undefined): PortShape;
|
|
85
95
|
/**
|
|
86
|
-
* The shape to draw for a port —
|
|
96
|
+
* The shape to draw for a port — both sources, in the order the top of this
|
|
97
|
+
* file states: the lane's served schema, then the table.
|
|
87
98
|
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* aliases rather than as an unknown of its own.
|
|
99
|
+
* The lane is resolved through the checker either way, so an alias (`text`
|
|
100
|
+
* declared as an alias of `string`) reads the schema and the table of the lane
|
|
101
|
+
* it aliases rather than answering as an unknown of its own.
|
|
91
102
|
*/
|
|
92
103
|
export declare function portShape(checker: PortCompatibilityChecker, port: ShapedPort): PortShape;
|
|
93
104
|
/**
|
|
94
|
-
* The glyph to draw for a port
|
|
105
|
+
* The glyph to draw for a port.
|
|
106
|
+
*
|
|
107
|
+
* @deprecated since 2.4.0 — `SHAPE_GLYPH[portShape(checker, port)]`, which is
|
|
108
|
+
* what this is. Both it and the map went out in 2.3.0's public surface and only
|
|
109
|
+
* one of them needs to be there: the map is the vocabulary, and composing it is
|
|
110
|
+
* a lookup. Kept until 3.0.0 because removing a released export is not a minor.
|
|
95
111
|
*/
|
|
96
112
|
export declare function portGlyph(checker: PortCompatibilityChecker, port: ShapedPort): string;
|
|
97
|
-
/**
|
|
98
|
-
* A human name for a port's shape, for the symbol's tooltip.
|
|
99
|
-
*/
|
|
100
|
-
export declare function portShapeLabel(checker: PortCompatibilityChecker, port: ShapedPort): string;
|
|
101
113
|
export {};
|
package/dist/utils/portShape.js
CHANGED
|
@@ -10,23 +10,33 @@
|
|
|
10
10
|
*
|
|
11
11
|
* ## Where the shape comes from
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
13
|
+
* Two sources, in this order:
|
|
14
|
+
*
|
|
15
|
+
* 1. **The lane's served schema** (`PortDataTypeConfig.schema`) — a JSON Schema
|
|
16
|
+
* the backend's shape registry declares for the lane. Its `type` IS the
|
|
17
|
+
* shape, said by the side that knows: fddo's `error` shape declares
|
|
18
|
+
* `type: object`, `messages` declares `type: array`, and a site's own
|
|
19
|
+
* `Order` shape answers for itself without the client having heard of it.
|
|
20
|
+
* 2. **The lane table below**, when no schema is served — which is every lane
|
|
21
|
+
* on an older fddo, on a third-party server implementing only the
|
|
22
|
+
* port-config endpoint, and on the library's offline defaults (which stay
|
|
23
|
+
* presentation-only on purpose and carry no schemas).
|
|
24
|
+
*
|
|
25
|
+
* The table was the whole answer before shapes reached the wire, and the
|
|
26
|
+
* ordering above is why the fallback stays: it is what draws a glyph when
|
|
27
|
+
* nothing declares one, not a second opinion competing with a served answer.
|
|
28
|
+
*
|
|
29
|
+
* Two things the fallback cannot do, both known and accepted:
|
|
21
30
|
* - **`integer` vs `number` collapse.** The server already maps both onto lane
|
|
22
|
-
* `number`, so nothing is lost that the client ever had.
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
31
|
+
* `number`, so nothing is lost that the client ever had. A served schema
|
|
32
|
+
* saying `integer` collapses the same way, for the same reason.
|
|
33
|
+
* - **A site-defined lane with no shape resolves to `unknown` (`?`).** A lane
|
|
34
|
+
* added through the `port_config` overlay alone has nothing to read. `?` is
|
|
35
|
+
* the honest answer, and declaring a shape for the lane is how a site
|
|
36
|
+
* improves it.
|
|
26
37
|
*
|
|
27
|
-
* {@link portShape} is the
|
|
28
|
-
*
|
|
29
|
-
* function and no caller.
|
|
38
|
+
* {@link portShape} is the one function either source is read in, which is what
|
|
39
|
+
* kept adding the first source to a single place.
|
|
30
40
|
*
|
|
31
41
|
* It takes the **checker** for exactly that reason. Colour has always asked the
|
|
32
42
|
* checker, which resolves an alias to its canonical lane and sees whatever the
|
|
@@ -78,8 +88,9 @@ export const SHAPE_LABEL = {
|
|
|
78
88
|
* zero declaring ports, the schema-type→lane resolver
|
|
79
89
|
* (`NodeMetadataResolver::mapSchemaTypeToDataType`) can never emit them, and no
|
|
80
90
|
* fddo plan schedules a shape for them. "URI string" was a plausible guess with
|
|
81
|
-
* nothing behind it, and a wrong glyph is worse than an honest `?`.
|
|
82
|
-
*
|
|
91
|
+
* nothing behind it, and a wrong glyph is worse than an honest `?`. A site that
|
|
92
|
+
* does use them declares a shape for the lane, which {@link portShape} reads
|
|
93
|
+
* ahead of this table.
|
|
83
94
|
*
|
|
84
95
|
* The legacy spellings (`text`, `list`, `integer`, `float`, `object`,
|
|
85
96
|
* `document`, `picture`, `sound`, `movie`, `branch`) are here because
|
|
@@ -145,6 +156,34 @@ const LANE_SHAPE = {
|
|
|
145
156
|
* port config, which is what stops a new lane shipping without a glyph.
|
|
146
157
|
*/
|
|
147
158
|
export const LANE_SHAPES = LANE_SHAPE;
|
|
159
|
+
/**
|
|
160
|
+
* JSON Schema `type` → shape, for reading a lane's served schema.
|
|
161
|
+
*
|
|
162
|
+
* `integer` collapses onto `number` exactly as the server's own lane mapping
|
|
163
|
+
* does, so a shape declaring `integer` and a port on lane `number` draw the same
|
|
164
|
+
* `#`. `null` is deliberately absent: a lane whose schema promises only `null`
|
|
165
|
+
* has no shape worth a glyph, and falling through to the table is the better
|
|
166
|
+
* answer than inventing one.
|
|
167
|
+
*/
|
|
168
|
+
const SCHEMA_TYPE_SHAPE = {
|
|
169
|
+
string: 'string',
|
|
170
|
+
number: 'number',
|
|
171
|
+
integer: 'number',
|
|
172
|
+
boolean: 'boolean',
|
|
173
|
+
array: 'array',
|
|
174
|
+
object: 'object'
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* The shape a served schema declares, or `undefined` when it declares none —
|
|
178
|
+
* which includes a schema with no `type` at all (`{properties: {…}}` alone, or
|
|
179
|
+
* a bare `$ref`), because the shape is the `type` and nothing else in the
|
|
180
|
+
* keyword space is being guessed at.
|
|
181
|
+
*/
|
|
182
|
+
function schemaShape(schema) {
|
|
183
|
+
if (!schema?.type)
|
|
184
|
+
return undefined;
|
|
185
|
+
return SCHEMA_TYPE_SHAPE[schema.type.toLowerCase()];
|
|
186
|
+
}
|
|
148
187
|
/**
|
|
149
188
|
* The shape a lane id implies, straight from the table. `unknown` for any lane
|
|
150
189
|
* not in it, including every site-defined one.
|
|
@@ -161,25 +200,25 @@ export function laneShape(dataType) {
|
|
|
161
200
|
return LANE_SHAPE[dataType.toLowerCase()] ?? 'unknown';
|
|
162
201
|
}
|
|
163
202
|
/**
|
|
164
|
-
* The shape to draw for a port —
|
|
203
|
+
* The shape to draw for a port — both sources, in the order the top of this
|
|
204
|
+
* file states: the lane's served schema, then the table.
|
|
165
205
|
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* aliases rather than as an unknown of its own.
|
|
206
|
+
* The lane is resolved through the checker either way, so an alias (`text`
|
|
207
|
+
* declared as an alias of `string`) reads the schema and the table of the lane
|
|
208
|
+
* it aliases rather than answering as an unknown of its own.
|
|
169
209
|
*/
|
|
170
210
|
export function portShape(checker, port) {
|
|
171
|
-
const
|
|
172
|
-
return laneShape(
|
|
211
|
+
const lane = port.dataType ? checker.getDataTypeConfig(port.dataType) : undefined;
|
|
212
|
+
return schemaShape(lane?.schema) ?? laneShape(lane?.id ?? port.dataType);
|
|
173
213
|
}
|
|
174
214
|
/**
|
|
175
|
-
* The glyph to draw for a port
|
|
215
|
+
* The glyph to draw for a port.
|
|
216
|
+
*
|
|
217
|
+
* @deprecated since 2.4.0 — `SHAPE_GLYPH[portShape(checker, port)]`, which is
|
|
218
|
+
* what this is. Both it and the map went out in 2.3.0's public surface and only
|
|
219
|
+
* one of them needs to be there: the map is the vocabulary, and composing it is
|
|
220
|
+
* a lookup. Kept until 3.0.0 because removing a released export is not a minor.
|
|
176
221
|
*/
|
|
177
222
|
export function portGlyph(checker, port) {
|
|
178
223
|
return SHAPE_GLYPH[portShape(checker, port)];
|
|
179
224
|
}
|
|
180
|
-
/**
|
|
181
|
-
* A human name for a port's shape, for the symbol's tooltip.
|
|
182
|
-
*/
|
|
183
|
-
export function portShapeLabel(checker, port) {
|
|
184
|
-
return SHAPE_LABEL[portShape(checker, port)];
|
|
185
|
-
}
|
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.
|
|
6
|
+
"version": "2.5.0",
|
|
7
7
|
"author": "Shibin Das (D34dMan)",
|
|
8
8
|
"bugs": {
|
|
9
9
|
"url": "https://github.com/flowdrop-io/flowdrop/issues"
|