@flowdrop/flowdrop 2.2.2 → 2.3.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.
@@ -0,0 +1,133 @@
1
+ <!--
2
+ One port's label row: shape symbol, port name, lane chip.
3
+
4
+ The single home for a treatment that was duplicated character-for-character
5
+ between WorkflowNode's input and output blocks, and approximated again in
6
+ GatewayNode. Inputs read `[symbol] Name (lane)`; outputs mirror the order so
7
+ the symbols line up as a column beside their handles.
8
+
9
+ Layout lives here rather than on the node's scoped utility classes, because
10
+ Svelte's scoped CSS does not reach into a child component. That is also why
11
+ `active` is a boolean rather than a caller-supplied class name: a gateway
12
+ passing its own `.text--active` down would hand over a class Svelte never
13
+ scopes to this component, and the rule would silently not apply.
14
+
15
+ The row is deliberately NOT reused by the inspector's port list (FormPorts):
16
+ that row is a flat list item carrying reorder buttons, a bound-link marker and
17
+ an exposure toggle, laid out by its own flex with its own gaps. It shares the
18
+ two chips, which is the part that must agree; nesting this row inside it would
19
+ buy an invariant it does not need (it is left-aligned) at the cost of its
20
+ spacing.
21
+ -->
22
+
23
+ <script lang="ts">
24
+ import type { Snippet } from 'svelte';
25
+ import type { PortCompatibilityChecker } from '../../utils/connections.js';
26
+ import PortShapeSymbol from './PortShapeSymbol.svelte';
27
+ import PortLaneChip from './PortLaneChip.svelte';
28
+
29
+ interface Props {
30
+ checker: PortCompatibilityChecker;
31
+ /**
32
+ * The port to draw. Structural rather than a `NodePort`, for the same reason
33
+ * as PortShapeSymbol's: a gateway branch is an authored control-flow path,
34
+ * not a port, and should not have to fabricate an id to be rendered. An
35
+ * absent id simply never matches the reserved `error` output.
36
+ */
37
+ port: { id?: string; type?: string; dataType: string; name?: string; required?: boolean };
38
+ /**
39
+ * `left` for input rows, `right` for output rows — which mirrors the order
40
+ * and pushes the row to the node edge.
41
+ */
42
+ align?: 'left' | 'right';
43
+ /** Row text, when it is not the port's own name (a branch's label). */
44
+ label?: string;
45
+ /**
46
+ * The row's path was taken in the last run — draws the label in the success
47
+ * colour. A boolean and not a class name: see the note above.
48
+ */
49
+ active?: boolean;
50
+ /** Show the required marker when the port is required. Input rows only. */
51
+ showRequired?: boolean;
52
+ /** Wording of the required marker, so callers keep control of it. */
53
+ requiredLabel?: string;
54
+ /**
55
+ * Rendered at the row's leading edge, outside the mirrored group — an
56
+ * execution marker, say. Stays put in both alignments, so it never lands
57
+ * between the name and its chips.
58
+ */
59
+ leading?: Snippet;
60
+ }
61
+
62
+ let {
63
+ checker,
64
+ port,
65
+ align = 'left',
66
+ label,
67
+ active = false,
68
+ showRequired = false,
69
+ requiredLabel = 'Required',
70
+ leading
71
+ }: Props = $props();
72
+
73
+ const text = $derived(label ?? port.name ?? '');
74
+ </script>
75
+
76
+ <div class="fd-port-label" class:fd-port-label--right={align === 'right'}>
77
+ {@render leading?.()}
78
+ {#if align === 'right'}
79
+ <PortLaneChip {checker} {port} />
80
+ <span class="fd-port-label__name" class:fd-port-label__name--active={active}>{text}</span>
81
+ <PortShapeSymbol {checker} {port} />
82
+ {:else}
83
+ <PortShapeSymbol {checker} {port} />
84
+ <span class="fd-port-label__name" class:fd-port-label__name--active={active}>{text}</span>
85
+ <PortLaneChip {checker} {port} />
86
+ {#if showRequired && port.required}
87
+ <span class="flowdrop-badge flowdrop-badge--sm fd-port-label__required">{requiredLabel}</span>
88
+ {/if}
89
+ {/if}
90
+ </div>
91
+
92
+ <style>
93
+ /* One 20px canvas grid row, so the handle positioned at that offset lines
94
+ up with the label. Harmless where there is no grid (the inspector). */
95
+ .fd-port-label {
96
+ display: flex;
97
+ align-items: center;
98
+ gap: var(--fd-space-xs);
99
+ min-width: 0;
100
+ min-height: var(--fd-node-port-row-height);
101
+ }
102
+
103
+ .fd-port-label--right {
104
+ justify-content: flex-end;
105
+ }
106
+
107
+ /* Ellipsize a long port name rather than widen the node. The name absorbs
108
+ the row's slack, which is what puts the shape symbol and the lane chip at
109
+ opposite ends: the symbols read as one column against the node edge beside
110
+ their handles, the chips as a second column against the node's inside. */
111
+ .fd-port-label__name {
112
+ flex: 1 1 auto;
113
+ min-width: 0;
114
+ font-size: var(--fd-text-xs);
115
+ line-height: 16px;
116
+ font-weight: 500;
117
+ overflow: hidden;
118
+ text-overflow: ellipsis;
119
+ white-space: nowrap;
120
+ }
121
+
122
+ .fd-port-label__name--active {
123
+ color: var(--fd-success);
124
+ font-weight: 600;
125
+ }
126
+
127
+ /* Matches the solid error badge the node components already drew. */
128
+ .fd-port-label__required {
129
+ flex: none;
130
+ background-color: var(--fd-error);
131
+ color: var(--fd-error-foreground);
132
+ }
133
+ </style>
@@ -0,0 +1,43 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { PortCompatibilityChecker } from '../../utils/connections.js';
3
+ interface Props {
4
+ checker: PortCompatibilityChecker;
5
+ /**
6
+ * The port to draw. Structural rather than a `NodePort`, for the same reason
7
+ * as PortShapeSymbol's: a gateway branch is an authored control-flow path,
8
+ * not a port, and should not have to fabricate an id to be rendered. An
9
+ * absent id simply never matches the reserved `error` output.
10
+ */
11
+ port: {
12
+ id?: string;
13
+ type?: string;
14
+ dataType: string;
15
+ name?: string;
16
+ required?: boolean;
17
+ };
18
+ /**
19
+ * `left` for input rows, `right` for output rows — which mirrors the order
20
+ * and pushes the row to the node edge.
21
+ */
22
+ align?: 'left' | 'right';
23
+ /** Row text, when it is not the port's own name (a branch's label). */
24
+ label?: string;
25
+ /**
26
+ * The row's path was taken in the last run — draws the label in the success
27
+ * colour. A boolean and not a class name: see the note above.
28
+ */
29
+ active?: boolean;
30
+ /** Show the required marker when the port is required. Input rows only. */
31
+ showRequired?: boolean;
32
+ /** Wording of the required marker, so callers keep control of it. */
33
+ requiredLabel?: string;
34
+ /**
35
+ * Rendered at the row's leading edge, outside the mirrored group — an
36
+ * execution marker, say. Stays put in both alignments, so it never lands
37
+ * between the name and its chips.
38
+ */
39
+ leading?: Snippet;
40
+ }
41
+ declare const PortTypeBadge: import("svelte").Component<Props, {}, "">;
42
+ type PortTypeBadge = ReturnType<typeof PortTypeBadge>;
43
+ export default PortTypeBadge;
@@ -1,6 +1,16 @@
1
1
  /**
2
- * Default port configuration for FlowDrop
3
- * Provides backward compatibility and serves as an example configuration
2
+ * Default port configuration for FlowDrop.
3
+ *
4
+ * The fallback the editor uses before (or instead of) the backend's
5
+ * `getPortConfiguration()` payload. It is a HAND MIRROR of that payload, and
6
+ * every id and rule missing from it is a lane the editor treats as unknown —
7
+ * compatible with nothing, not even another port of its own lane. It was
8
+ * missing three (`any`, `mixed`, `messages`), which is why a `messages` port
9
+ * on library defaults would not connect to anything at all.
10
+ *
11
+ * Generating this from the backend's single declaration site is the
12
+ * workflow-contract axis's job; until then, a lane added on the Drupal side
13
+ * must be added here in the same change.
4
14
  */
5
15
  import type { PortConfig } from '../types/index.js';
6
16
  export declare const DEFAULT_PORT_CONFIG: PortConfig;
@@ -1,10 +1,52 @@
1
1
  /**
2
- * Default port configuration for FlowDrop
3
- * Provides backward compatibility and serves as an example configuration
2
+ * Default port configuration for FlowDrop.
3
+ *
4
+ * The fallback the editor uses before (or instead of) the backend's
5
+ * `getPortConfiguration()` payload. It is a HAND MIRROR of that payload, and
6
+ * every id and rule missing from it is a lane the editor treats as unknown —
7
+ * compatible with nothing, not even another port of its own lane. It was
8
+ * missing three (`any`, `mixed`, `messages`), which is why a `messages` port
9
+ * on library defaults would not connect to anything at all.
10
+ *
11
+ * Generating this from the backend's single declaration site is the
12
+ * workflow-contract axis's job; until then, a lane added on the Drupal side
13
+ * must be added here in the same change.
4
14
  */
15
+ /**
16
+ * Every lane a sink rule fans out over: all of them but `tool`.
17
+ *
18
+ * A capability wire into a sink says nothing and a sink value is not a
19
+ * callable, so `tool` stays self-compatible only.
20
+ */
21
+ const SINK_LANES = [
22
+ 'trigger',
23
+ 'mixed',
24
+ 'string',
25
+ 'number',
26
+ 'boolean',
27
+ 'array',
28
+ 'string[]',
29
+ 'number[]',
30
+ 'boolean[]',
31
+ 'json[]',
32
+ 'file[]',
33
+ 'image[]',
34
+ 'json',
35
+ 'messages',
36
+ 'file',
37
+ 'image',
38
+ 'audio',
39
+ 'video',
40
+ 'url',
41
+ 'email',
42
+ 'date',
43
+ 'datetime',
44
+ 'time'
45
+ ];
5
46
  export const DEFAULT_PORT_CONFIG = {
6
47
  version: '1.0.0',
7
- defaultDataType: 'string',
48
+ // The sink, not `string`: a port with no declared lane constrains nothing.
49
+ defaultDataType: 'mixed',
8
50
  dataTypes: [
9
51
  // Control flow types
10
52
  {
@@ -15,6 +57,21 @@ export const DEFAULT_PORT_CONFIG = {
15
57
  category: 'basic',
16
58
  enabled: true
17
59
  },
60
+ // The sink: what a port declares when its schema declares no shape.
61
+ // Wire anything in, wire it anywhere. `any` was its second spelling and
62
+ // is retired.
63
+ //
64
+ // Slate, not a lane hue: a port that constrains nothing has nothing to
65
+ // claim, and slate is already what an unrecognised lane falls back to. It
66
+ // sat on teal, which put the sink in the media family beside `video`.
67
+ {
68
+ id: 'mixed',
69
+ name: 'Mixed',
70
+ description: 'A value of any type',
71
+ color: 'var(--fd-node-slate)',
72
+ category: 'basic',
73
+ enabled: true
74
+ },
18
75
  // Text and basic types
19
76
  {
20
77
  id: 'string',
@@ -192,10 +249,42 @@ export const DEFAULT_PORT_CONFIG = {
192
249
  color: 'var(--fd-node-lime)',
193
250
  category: 'temporal',
194
251
  enabled: true
252
+ },
253
+ // A list of provider-shaped chat messages. JSON-Schema `array`
254
+ // underneath, but not an arbitrary array — which is the whole reason it
255
+ // is its own lane.
256
+ {
257
+ id: 'messages',
258
+ name: 'Messages',
259
+ description: 'A conversation: a list of provider-shaped chat messages',
260
+ color: 'var(--fd-node-fuchsia)',
261
+ category: 'complex',
262
+ enabled: true
195
263
  }
196
264
  ],
197
265
  compatibilityRules: [
198
- // Pure same-type compatibility: string connects to string, number to number, etc.
199
- // No additional rules needed - the system handles same-type connections automatically
266
+ // buildCompatibilityMap() seeds exact-match only, so a lane accepts
267
+ // another lane ONLY through a rule here. Same-type connections need no
268
+ // rule; everything below is a deliberate widening.
269
+ //
270
+ // The sink both ways. `mixed` is worn by outputs as well as inputs, so
271
+ // the incoming direction alone would leave those outputs wireable into
272
+ // nothing. Aliases would not have done it either — they copy the
273
+ // outgoing set only.
274
+ ...SINK_LANES.flatMap((id) => [
275
+ { from: id, to: 'mixed' },
276
+ { from: 'mixed', to: id }
277
+ ]),
278
+ // The control sink. What a loopback or trigger input accepts; this is
279
+ // the rule set `any` used to carry.
280
+ ...SINK_LANES.map((id) => ({ from: id, to: 'trigger' })),
281
+ // `messages` flows one way into `array` and `json`: existing consumers
282
+ // typed one of those must keep accepting a message list without being
283
+ // rewired. The reverse is deliberately absent — an `array`/`json` port
284
+ // carries no guarantee of provider-message shape, and accepting one into
285
+ // a `messages` input is exactly the silent mistyping the lane exists to
286
+ // catch.
287
+ { from: 'messages', to: 'array' },
288
+ { from: 'messages', to: 'json' }
200
289
  ]
201
290
  };
@@ -84,6 +84,9 @@ export { getDraftStorageKey, saveDraft, loadDraft, deleteDraft, hasDraft, getDra
84
84
  export type { DraftStorageAdapter, DraftStorageType, DraftStorageOption } from '../services/draftStorage.js';
85
85
  export { EnhancedFlowDropApiClient, ApiError } from '../api/enhanced-client.js';
86
86
  export { isLoopbackEdge, isValidLoopbackCycle, PortCompatibilityChecker, getPossibleConnections, validateConnection, getConnectionSuggestions, hasCycles, hasInvalidCycles, getExecutionOrder } from '../utils/connections.js';
87
+ export { SHAPE_GLYPH, portShape, portGlyph } from '../utils/portShape.js';
88
+ export type { PortShape } from '../utils/portShape.js';
89
+ export { default as PortTypeBadge } from '../components/ports/PortTypeBadge.svelte';
87
90
  export { fetchRuntimeConfig, getRuntimeConfig, clearRuntimeConfigCache, initRuntimeConfig } from '../config/runtimeConfig.js';
88
91
  export type { RuntimeConfig } from '../config/runtimeConfig.js';
89
92
  export type { Workflow, WorkflowNode, WorkflowEdge, NodeMetadata, NodePort, DynamicPort, Branch, ExecutionStatus, ExecutionResult, FlowDropConfig, PortConfig, ConfigSchema, ConfigProperty, ConfigEditOptions } from '../types/index.js';
@@ -125,6 +125,22 @@ export { EnhancedFlowDropApiClient, ApiError } from '../api/enhanced-client.js';
125
125
  // ============================================================================
126
126
  export { isLoopbackEdge, isValidLoopbackCycle, PortCompatibilityChecker, getPossibleConnections, validateConnection, getConnectionSuggestions, hasCycles, hasInvalidCycles, getExecutionOrder } from '../utils/connections.js';
127
127
  // ============================================================================
128
+ // Port Shape Symbols
129
+ // ============================================================================
130
+ // A port's JSON-Schema shape and its semantic lane are two separate marks on
131
+ // the canvas: a small coloured glyph for the shape, a quiet outlined chip for
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. Both
134
+ // functions take the instance's port-compatibility checker, the same source
135
+ // colour reads, so a served or aliased lane shapes the way it colours. See
136
+ // utils/portShape.ts for where the shape comes from.
137
+ //
138
+ // Deliberately small: the lane table, the shape labels and the two-component
139
+ // split behind `PortTypeBadge` are implementation, and stay so until something
140
+ // outside the library needs them.
141
+ export { SHAPE_GLYPH, portShape, portGlyph } from '../utils/portShape.js';
142
+ export { default as PortTypeBadge } from '../components/ports/PortTypeBadge.svelte';
143
+ // ============================================================================
128
144
  // Runtime Configuration
129
145
  // ============================================================================
130
146
  export { fetchRuntimeConfig, getRuntimeConfig, clearRuntimeConfigCache, initRuntimeConfig } from '../config/runtimeConfig.js';
@@ -27,13 +27,60 @@
27
27
  import { buildEndpointUrl } from '../config/endpoints.js';
28
28
  import { authenticatedFetch } from '../utils/fetchWithAuth.js';
29
29
  import { logger } from '../utils/logger.js';
30
- /** Map a refusal HTTP status + payload onto a modelled reason. */
31
- function classifyRefusal(status, message) {
30
+ /**
31
+ * Stable refusal codes, as published by the reference backend.
32
+ *
33
+ * Reading a code is the only way to classify a refusal that does not depend on
34
+ * the server's prose. Every entry here is a name the backend has committed
35
+ * never to redefine, so this map is append-only: a code that stops appearing is
36
+ * dropped from the backend, never given a new meaning.
37
+ *
38
+ * An unrecognised code is deliberately *not* fatal — a newer backend may refuse
39
+ * for a reason this client does not model yet, and the fallback below decides
40
+ * what to do about it.
41
+ */
42
+ const REFUSAL_CODES = {
43
+ PIPELINE_TERMINAL: 'terminal',
44
+ INWARD_SIGNAL_ALREADY_PENDING: 'duplicate',
45
+ NO_ACTIVE_PAUSE: 'not-paused'
46
+ };
47
+ /**
48
+ * Map a refusal HTTP status + payload onto a modelled reason.
49
+ *
50
+ * ## Why there are two paths
51
+ *
52
+ * All three of the backend's 409s are the same status code, so for a long time
53
+ * the only way to tell them apart was to match substrings of the human message
54
+ * — which made the server's wording load-bearing: a reword that dropped a
55
+ * substring silently reclassified the refusal, the operator was shown the wrong
56
+ * explanation, and nothing errored anywhere. The backend now publishes a stable
57
+ * `error_code` beside `error` for exactly this, and it is preferred whenever
58
+ * present.
59
+ *
60
+ * The substring path stays as the fallback because it must: this client talks to
61
+ * backends it does not ship with, and one that predates the codes still answers
62
+ * a 409 with nothing but prose. Dropping the fallback would reclassify every one
63
+ * of those refusals as a generic rejection — the same bug, in the other
64
+ * direction. It is removed when the oldest supported backend emits codes, not
65
+ * when the newest does.
66
+ *
67
+ * @param status HTTP status of the refusal.
68
+ * @param message The human `error` string, used only by the fallback path.
69
+ * @param code The backend's stable `error_code`, when it published one.
70
+ */
71
+ function classifyRefusal(status, message, code) {
32
72
  if (status === 404)
33
73
  return 'not-found';
34
74
  if (status === 403 || status === 401)
35
75
  return 'forbidden';
76
+ if (code && REFUSAL_CODES[code])
77
+ return REFUSAL_CODES[code];
36
78
  if (status === 409) {
79
+ // A code we do not recognise still tells us the backend classified this
80
+ // deliberately, so guessing from its prose would be worse than admitting
81
+ // the refusal is one this client does not model.
82
+ if (code)
83
+ return 'rejected';
37
84
  const text = message.toLowerCase();
38
85
  if (text.includes('terminal'))
39
86
  return 'terminal';
@@ -82,10 +129,11 @@ class PipelineSignalService {
82
129
  }
83
130
  const payload = (await response.json().catch(() => ({})));
84
131
  const message = payload.error ?? payload.message ?? `HTTP ${response.status}: ${response.statusText}`;
132
+ const code = typeof payload.error_code === 'string' ? payload.error_code : undefined;
85
133
  logger.warn(`Pipeline signal "${signal}" refused for ${pipelineId}:`, message);
86
134
  return {
87
135
  status: 'refused',
88
- reason: classifyRefusal(response.status, message),
136
+ reason: classifyRefusal(response.status, message, code),
89
137
  message
90
138
  };
91
139
  }
@@ -571,6 +571,62 @@ p {
571
571
  color: var(--fd-error-hover);
572
572
  }
573
573
 
574
+ /* Small badge — the node/port scale. */
575
+ .flowdrop-badge--sm {
576
+ font-size: 10px;
577
+ padding: 2px 4px;
578
+ }
579
+
580
+ /* Outlined badge: readable, copyable, and not competing for attention. Used by
581
+ the port lane chip, where the row's one saturated mark is the shape symbol
582
+ beside it — so the two sit side by side and must agree on box metrics. */
583
+ .flowdrop-badge--outline {
584
+ box-sizing: border-box;
585
+ height: 17px;
586
+ padding: 0 4px;
587
+ border: 1px solid var(--fd-border);
588
+ border-radius: var(--fd-radius-sm);
589
+ background-color: transparent;
590
+ color: var(--fd-muted-foreground);
591
+ line-height: 1;
592
+ }
593
+
594
+ /* Port shape symbol: the glyph chip that says what SHAPE a port carries
595
+ (`S` text, `#` number, `[]` list, `{}` object, `?` unknown, `T` trigger,
596
+ `()` callable). See components/ports/PortShapeSymbol.svelte.
597
+
598
+ The component sets only `--fd-port-symbol-color`, the port's lane colour, so
599
+ everything else here — including the tint ratios — stays overridable by a
600
+ consumer stylesheet instead of being locked behind an inline declaration.
601
+ `--fd-port-skin-color` is the same per-instance override the handles honour.
602
+
603
+ 19x17 is one glyph of the 10px mono face plus its padding: wide enough that
604
+ the two-character glyphs (`[]`, `{}`, `()`) do not set a wider box than the
605
+ one-character ones, so the chips form an even column down a dense node. */
606
+ .flowdrop-port-symbol {
607
+ --_fd-symbol-color: var(--fd-port-skin-color, var(--fd-port-symbol-color, var(--fd-node-slate)));
608
+
609
+ display: inline-flex;
610
+ align-items: center;
611
+ justify-content: center;
612
+ flex: none;
613
+ box-sizing: border-box;
614
+ min-width: 19px;
615
+ height: 17px;
616
+ padding: 0 3px;
617
+ border: 1px solid color-mix(in srgb, var(--_fd-symbol-color) 30%, transparent);
618
+ border-radius: var(--fd-radius-sm);
619
+ background-color: color-mix(in srgb, var(--_fd-symbol-color) 15%, transparent);
620
+ color: var(--_fd-symbol-color);
621
+ font-family: var(--fd-font-mono);
622
+ font-size: 10px;
623
+ font-weight: 600;
624
+ line-height: 1;
625
+ letter-spacing: -0.02em;
626
+ white-space: nowrap;
627
+ user-select: none;
628
+ }
629
+
574
630
  /* Navbar styles */
575
631
  .flowdrop-navbar {
576
632
  display: flex;
@@ -321,6 +321,7 @@
321
321
  --fd-node-lime: #84cc16; /* @public */
322
322
  --fd-node-slate: #64748b; /* @public */
323
323
  --fd-node-purple: #9333ea; /* @public */
324
+ --fd-node-fuchsia: #d946ef; /* @public */
324
325
 
325
326
  /** Icon on node squircle: dark in light theme, white in dark theme */
326
327
  --fd-node-icon: var(--_gray-9); /* @public */
@@ -466,6 +467,7 @@
466
467
  --fd-node-lime: #a3e635;
467
468
  --fd-node-slate: #94a3b8;
468
469
  --fd-node-purple: #c084fc;
470
+ --fd-node-fuchsia: #e879f9;
469
471
 
470
472
  /** Icon on node squircle: white in dark theme */
471
473
  --fd-node-icon: #ffffff;
@@ -12,6 +12,22 @@ import type { CategoriesStore } from '../stores/categoriesStore.svelte.js';
12
12
  * These serve as static defaults; the categories store provides dynamic overrides.
13
13
  */
14
14
  export declare const CATEGORY_COLOR_TOKENS: Record<string, string>;
15
+ /**
16
+ * Legacy data-type spellings that were never lane ids: alternative words older
17
+ * workflows and third-party payloads use. Kept as an alias layer so they still
18
+ * colour, but they are NOT part of the shipped vocabulary — that comes from
19
+ * DEFAULT_PORT_CONFIG below.
20
+ *
21
+ * **This list is closed.** It is the last hand-maintained colour list in the
22
+ * library and it has no upstream source to drift from, which is exactly why
23
+ * nothing new goes in it: a new lane belongs in the port config, and a new
24
+ * spelling of an existing lane belongs in that lane's `aliases`.
25
+ *
26
+ * Exported for the test suite only (not re-exported from any entry point): it
27
+ * is what `portShape.test.ts` asserts the lane→shape table is total over, so a
28
+ * spelling can never have a colour and no shape.
29
+ */
30
+ export declare const LEGACY_DATA_TYPE_COLORS: Record<string, string>;
15
31
  /**
16
32
  * Get the design token for a category color.
17
33
  * Checks the categories store first (which includes API overrides),
@@ -248,14 +264,14 @@ export declare function getPortBorderColor(checker: PortCompatibilityChecker, da
248
264
  * read as an error affordance (red) wherever it surfaces.
249
265
  */
250
266
  export declare function isErrorPort(port: {
251
- id: string;
267
+ id?: string;
252
268
  type?: string;
253
269
  }): boolean;
254
270
  /**
255
271
  * Port colour token: red for the reserved error output, else its data type.
256
272
  */
257
273
  export declare function getPortColorToken(checker: PortCompatibilityChecker, port: {
258
- id: string;
274
+ id?: string;
259
275
  type?: string;
260
276
  dataType: string;
261
277
  }): string;
@@ -263,7 +279,7 @@ export declare function getPortColorToken(checker: PortCompatibilityChecker, por
263
279
  * Port background tint, honouring the reserved error port's red affordance.
264
280
  */
265
281
  export declare function getPortBackgroundColorForPort(checker: PortCompatibilityChecker, port: {
266
- id: string;
282
+ id?: string;
267
283
  type?: string;
268
284
  dataType: string;
269
285
  }, opacity?: number): string;
@@ -3,6 +3,7 @@
3
3
  * Ensures consistent category colors across sidebar and canvas
4
4
  * Uses BEM syntax for CSS classes
5
5
  */
6
+ import { DEFAULT_PORT_CONFIG } from '../config/defaultPortConfig.js';
6
7
  /**
7
8
  * Category color mapping to design tokens (CSS variables)
8
9
  * Uses --fd-node-* tokens from tokens.css
@@ -28,38 +29,47 @@ export const CATEGORY_COLOR_TOKENS = {
28
29
  bundles: 'var(--fd-node-slate)'
29
30
  };
30
31
  /**
31
- * Default data type colors for fallback when port configuration is not available
32
- * Uses --fd-node-* tokens from tokens.css
32
+ * Legacy data-type spellings that were never lane ids: alternative words older
33
+ * workflows and third-party payloads use. Kept as an alias layer so they still
34
+ * colour, but they are NOT part of the shipped vocabulary — that comes from
35
+ * DEFAULT_PORT_CONFIG below.
36
+ *
37
+ * **This list is closed.** It is the last hand-maintained colour list in the
38
+ * library and it has no upstream source to drift from, which is exactly why
39
+ * nothing new goes in it: a new lane belongs in the port config, and a new
40
+ * spelling of an existing lane belongs in that lane's `aliases`.
41
+ *
42
+ * Exported for the test suite only (not re-exported from any entry point): it
43
+ * is what `portShape.test.ts` asserts the lane→shape table is total over, so a
44
+ * spelling can never have a colour and no shape.
33
45
  */
34
- const DEFAULT_DATA_TYPE_COLORS = {
35
- string: 'var(--fd-node-emerald)',
46
+ export const LEGACY_DATA_TYPE_COLORS = {
36
47
  text: 'var(--fd-node-emerald)',
37
- number: 'var(--fd-node-blue)',
38
48
  integer: 'var(--fd-node-blue)',
39
49
  float: 'var(--fd-node-blue)',
40
- boolean: 'var(--fd-node-purple)',
41
- array: 'var(--fd-node-amber)',
42
50
  list: 'var(--fd-node-amber)',
43
51
  object: 'var(--fd-node-orange)',
44
- json: 'var(--fd-node-orange)',
45
- mixed: 'var(--fd-node-orange)',
46
- file: 'var(--fd-node-red)',
47
52
  document: 'var(--fd-node-red)',
48
- image: 'var(--fd-node-pink)',
49
53
  picture: 'var(--fd-node-pink)',
50
- audio: 'var(--fd-node-indigo)',
51
54
  sound: 'var(--fd-node-indigo)',
52
- video: 'var(--fd-node-teal)',
53
55
  movie: 'var(--fd-node-teal)',
54
- url: 'var(--fd-node-cyan)',
55
- email: 'var(--fd-node-cyan)',
56
- date: 'var(--fd-node-lime)',
57
- datetime: 'var(--fd-node-lime)',
58
- time: 'var(--fd-node-lime)',
59
- tool: 'var(--fd-node-amber)',
60
- trigger: 'var(--fd-edge-trigger)',
61
56
  branch: 'var(--fd-node-purple)'
62
57
  };
58
+ /**
59
+ * Fallback lane colours for when no port configuration has loaded yet — which
60
+ * is exactly when the first render happens, so these are seen.
61
+ *
62
+ * Derived from DEFAULT_PORT_CONFIG rather than hand-written. It used to be a
63
+ * third, independently maintained colour list, and it had drifted: `mixed` was
64
+ * orange against the payload's teal, and the typed-array lanes (`string[]`,
65
+ * `json[]`, …) and `messages` were missing entirely, so a first render painted
66
+ * them slate. Deriving makes that class of drift unrepresentable — a lane added
67
+ * to the shipped config is coloured here by construction.
68
+ */
69
+ const DEFAULT_DATA_TYPE_COLORS = {
70
+ ...LEGACY_DATA_TYPE_COLORS,
71
+ ...Object.fromEntries(DEFAULT_PORT_CONFIG.dataTypes.map((dataType) => [dataType.id.toLowerCase(), dataType.color]))
72
+ };
63
73
  /**
64
74
  * Get the design token for a category color.
65
75
  * Checks the categories store first (which includes API overrides),
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Configuration utilities for FlowDrop Editor
3
3
  */
4
+ import { DEFAULT_PORT_CONFIG } from '../config/defaultPortConfig.js';
4
5
  import { createEndpointConfig } from '../config/endpoints.js';
5
6
  /**
6
7
  * Create default editor features configuration
@@ -108,11 +109,13 @@ export function createDefaultConfig(endpointConfig) {
108
109
  ...createDefaultAPIConfig(),
109
110
  endpoints: endpointConfig || createEndpointConfig('/api/flowdrop')
110
111
  },
111
- ports: {
112
- dataTypes: [],
113
- compatibilityRules: [],
114
- defaultDataType: 'mixed'
115
- },
112
+ // Not `{dataTypes: [], compatibilityRules: [], defaultDataType: 'mixed'}`:
113
+ // an empty type list is not a permissive default, it is a config in which
114
+ // NOTHING is compatible with anything — buildCompatibilityMap() seeds
115
+ // itself from `dataTypes`, so a `mixed` default naming a lane the list
116
+ // never declares leaves every port refusing every edge. The shipped
117
+ // defaults are the default.
118
+ ports: DEFAULT_PORT_CONFIG,
116
119
  execution: createDefaultExecutionConfig(),
117
120
  storage: createDefaultStorageConfig()
118
121
  };