@flowdrop/flowdrop 2.2.2 → 2.4.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 +57 -1
- package/dist/components/ConfigForm.svelte +4 -1
- package/dist/components/form/FormPorts.svelte +14 -23
- package/dist/components/form/FormTemplateEditor.svelte +1 -2
- package/dist/components/nodes/GatewayNode.svelte +31 -98
- package/dist/components/nodes/WorkflowNode.stories.svelte +51 -0
- package/dist/components/nodes/WorkflowNode.svelte +7 -70
- package/dist/components/ports/PortLaneChip.svelte +35 -0
- package/dist/components/ports/PortLaneChip.svelte.d.ts +11 -0
- package/dist/components/ports/PortShapeSymbol.svelte +54 -0
- package/dist/components/ports/PortShapeSymbol.svelte.d.ts +19 -0
- package/dist/components/ports/PortTypeBadge.svelte +133 -0
- package/dist/components/ports/PortTypeBadge.svelte.d.ts +43 -0
- package/dist/config/defaultPortConfig.d.ts +12 -2
- package/dist/config/defaultPortConfig.js +94 -5
- package/dist/editor/index.d.ts +3 -0
- package/dist/editor/index.js +19 -0
- package/dist/services/pipelineSignalService.js +51 -3
- package/dist/services/variableService.d.ts +47 -7
- package/dist/services/variableService.js +59 -20
- package/dist/styles/base.css +56 -31
- package/dist/styles/tokens.css +2 -0
- package/dist/types/index.d.ts +39 -0
- package/dist/utils/colors.d.ts +19 -3
- package/dist/utils/colors.js +30 -20
- package/dist/utils/config.js +8 -5
- package/dist/utils/portShape.d.ts +113 -0
- package/dist/utils/portShape.js +224 -0
- package/package.json +1 -1
|
@@ -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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
199
|
-
|
|
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
|
};
|
package/dist/editor/index.d.ts
CHANGED
|
@@ -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';
|
package/dist/editor/index.js
CHANGED
|
@@ -125,6 +125,25 @@ 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.
|
|
134
|
+
// `portShape` takes 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. `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.
|
|
144
|
+
export { SHAPE_GLYPH, portShape, portGlyph } from '../utils/portShape.js';
|
|
145
|
+
export { default as PortTypeBadge } from '../components/ports/PortTypeBadge.svelte';
|
|
146
|
+
// ============================================================================
|
|
128
147
|
// Runtime Configuration
|
|
129
148
|
// ============================================================================
|
|
130
149
|
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
|
-
/**
|
|
31
|
-
|
|
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
|
}
|
|
@@ -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>;
|