@reeve-iot/workflow-mui 0.0.0-stage → 1.1.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/LICENSE +21 -0
- package/README.md +68 -2
- package/dist/canvas/BlockNode.d.ts +30 -0
- package/dist/canvas/BlockNode.js +211 -0
- package/dist/canvas/Connection.d.ts +10 -0
- package/dist/canvas/Connection.js +22 -0
- package/dist/canvas/WorkflowCanvas.d.ts +16 -0
- package/dist/canvas/WorkflowCanvas.js +258 -0
- package/dist/canvas/analysedPortTerm.d.ts +6 -0
- package/dist/canvas/analysedPortTerm.js +17 -0
- package/dist/canvas/geometry.d.ts +14 -0
- package/dist/canvas/geometry.js +16 -0
- package/dist/canvas/graphTopology.d.ts +12 -0
- package/dist/canvas/graphTopology.js +32 -0
- package/dist/canvas/highlights.d.ts +12 -0
- package/dist/canvas/highlights.js +1 -0
- package/dist/canvas/nodePorts.d.ts +19 -0
- package/dist/canvas/nodePorts.js +28 -0
- package/dist/canvas/portCustomization.d.ts +21 -0
- package/dist/canvas/portCustomization.js +6 -0
- package/dist/canvas/portGeometry.d.ts +3 -0
- package/dist/canvas/portGeometry.js +3 -0
- package/dist/canvas/portLabelLayout.d.ts +9 -0
- package/dist/canvas/portLabelLayout.js +47 -0
- package/dist/canvas/unavailableBlock.d.ts +15 -0
- package/dist/canvas/unavailableBlock.js +9 -0
- package/dist/config/ErrorHandlingSection.d.ts +12 -0
- package/dist/config/ErrorHandlingSection.js +55 -0
- package/dist/config/NodeConfigPanel.d.ts +19 -0
- package/dist/config/NodeConfigPanel.js +246 -0
- package/dist/config/PassthroughSection.d.ts +18 -0
- package/dist/config/PassthroughSection.js +37 -0
- package/dist/config/ResiliencySection.d.ts +17 -0
- package/dist/config/ResiliencySection.js +156 -0
- package/dist/config/TypeArgumentPicker.d.ts +6 -0
- package/dist/config/TypeArgumentPicker.js +31 -0
- package/dist/config/nodeConfigCustomization.d.ts +100 -0
- package/dist/config/nodeConfigCustomization.js +6 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +26 -0
- package/dist/mapping/MappingDialog.d.ts +10 -0
- package/dist/mapping/MappingDialog.js +282 -0
- package/dist/mapping/mappingCustomization.d.ts +50 -0
- package/dist/mapping/mappingCustomization.js +8 -0
- package/dist/mapping/wireSourceOutputs.d.ts +29 -0
- package/dist/mapping/wireSourceOutputs.js +67 -0
- package/dist/nameDraft.d.ts +23 -0
- package/dist/nameDraft.js +19 -0
- package/dist/navigation/SubCanvasBreadcrumb.d.ts +7 -0
- package/dist/navigation/SubCanvasBreadcrumb.js +30 -0
- package/dist/palette/BlockPalette.d.ts +17 -0
- package/dist/palette/BlockPalette.js +55 -0
- package/dist/ports/KeyValueRowsField.d.ts +34 -0
- package/dist/ports/KeyValueRowsField.js +111 -0
- package/dist/ports/PortDeclarationTable.d.ts +18 -0
- package/dist/ports/PortDeclarationTable.js +111 -0
- package/dist/ports/PortValueEditor.d.ts +69 -0
- package/dist/ports/PortValueEditor.js +168 -0
- package/dist/ports/collectionComposer.d.ts +26 -0
- package/dist/ports/collectionComposer.js +37 -0
- package/dist/ports/refusedLiteral.d.ts +9 -0
- package/dist/ports/refusedLiteral.js +10 -0
- package/dist/ports/writeTerm.d.ts +5 -0
- package/dist/ports/writeTerm.js +10 -0
- package/dist/settings/ConcurrencySection.d.ts +8 -0
- package/dist/settings/ConcurrencySection.js +31 -0
- package/dist/settings/ParameterDeclarationDialog.d.ts +35 -0
- package/dist/settings/ParameterDeclarationDialog.js +81 -0
- package/dist/settings/WorkflowExecutionSection.d.ts +14 -0
- package/dist/settings/WorkflowExecutionSection.js +222 -0
- package/dist/theme/editorColors.d.ts +29 -0
- package/dist/theme/editorColors.js +30 -0
- package/dist/validation/ValidationFindings.d.ts +27 -0
- package/dist/validation/ValidationFindings.js +39 -0
- package/package.json +55 -4
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DescribeUnavailableBlock } from '../canvas/unavailableBlock.js';
|
|
2
|
+
import type { PortValueEditorProps } from '../ports/PortValueEditor.js';
|
|
3
|
+
export interface NodeConfigPanelProps {
|
|
4
|
+
/** Passed through to every generated port editor, which is where a host's expression editor and
|
|
5
|
+
* type-specific editors are supplied. */
|
|
6
|
+
portValueEditor?: Pick<PortValueEditorProps, 'renderTypeEditor' | 'renderExpressionEditor' | 'expressionPrefix'>;
|
|
7
|
+
rootCanvasLabel?: string;
|
|
8
|
+
/** The host's wording for a selected node whose block type is not in the catalogue. Such a node gets a read-only panel
|
|
9
|
+
* showing what it stores; without this it says the block type is not available on this host. */
|
|
10
|
+
describeUnavailableBlock?: DescribeUnavailableBlock;
|
|
11
|
+
/** Draws each input fed by a literal on an incoming wire with a value editor that writes the wire's mapping, in place
|
|
12
|
+
* of a schema field of the same name. Off by default: a host that draws such an input in its own section turns this
|
|
13
|
+
* on and returns null from `NodeConfigCustomization.renderWireLiteral` for it. */
|
|
14
|
+
showWireLiterals?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Configuration form for the selected node: the block type's own schema, then resiliency, error handling
|
|
17
|
+
* and passthrough. Everything domain-specific arrives through NodeConfigCustomization — the panel itself
|
|
18
|
+
* knows nothing beyond what a descriptor declares. */
|
|
19
|
+
export declare function NodeConfigPanel({ portValueEditor, rootCanvasLabel, describeUnavailableBlock, showWireLiterals, }: NodeConfigPanelProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, useMemo, useState } from 'react';
|
|
3
|
+
import { Alert, Box, Divider, Paper, Typography } from '@mui/material';
|
|
4
|
+
import { nullConfigurationKeys } from '@reeve-iot/workflow-core';
|
|
5
|
+
import { WORKFLOW_INPUT_BLOCK_TYPE_ID, WORKFLOW_OUTPUT_BLOCK_TYPE_ID, buildPortTypeScopes, computeIncomingVariables, createPortTypeResolver, draftAnalysisFreshness, feedsInput, indexDraftAnalysis, isMapTerm, literalFormOfType, openTermLiteralType, readMapping, usePortTypes, useWorkflowEditorStore, } from '@reeve-iot/workflow-core';
|
|
6
|
+
import { useAnalysedPortTerm } from '../canvas/analysedPortTerm.js';
|
|
7
|
+
import { NODE_CONFIG_PANEL_WIDTH } from '../canvas/geometry.js';
|
|
8
|
+
import { useNodePorts } from '../canvas/nodePorts.js';
|
|
9
|
+
import { unavailableBlockText } from '../canvas/unavailableBlock.js';
|
|
10
|
+
import { WiredJsonOutputs } from '../mapping/wireSourceOutputs.js';
|
|
11
|
+
import { DeclaredOutputPortTable, PortDeclarationTable } from '../ports/PortDeclarationTable.js';
|
|
12
|
+
import { PortValueEditor } from '../ports/PortValueEditor.js';
|
|
13
|
+
import { inputWriteTerm } from '../ports/writeTerm.js';
|
|
14
|
+
import { ErrorHandlingSection } from './ErrorHandlingSection.js';
|
|
15
|
+
import { PassthroughSection } from './PassthroughSection.js';
|
|
16
|
+
import { ResiliencySection } from './ResiliencySection.js';
|
|
17
|
+
import { useNodeConfigCustomization } from './nodeConfigCustomization.js';
|
|
18
|
+
const RESERVED_CONFIG_KEYS = new Set(['timeoutSeconds', 'retryCount', 'retryEnabled', 'retryBackoffSeconds', 'errorPolicy']);
|
|
19
|
+
const DESIGN_TIME_CONFIG_PREFIX = '__';
|
|
20
|
+
function describeMapping(mapping) {
|
|
21
|
+
const read = readMapping(mapping);
|
|
22
|
+
return read.literal ? `= ${read.value === undefined ? 'nothing' : JSON.stringify(read.value)}` : `↳ ${read.source}`;
|
|
23
|
+
}
|
|
24
|
+
function UnavailableBlockPanel({ node, edges, describe }) {
|
|
25
|
+
const text = unavailableBlockText(node, describe);
|
|
26
|
+
const wires = edges.flatMap((edge) => {
|
|
27
|
+
if (edge.targetNodeId === node.id)
|
|
28
|
+
return Object.entries(edge.mappings).map(([input, mapping]) => `${input} ${describeMapping(mapping)} (from ${edge.sourceNodeId})`);
|
|
29
|
+
if (edge.sourceNodeId === node.id)
|
|
30
|
+
return Object.entries(edge.mappings).map(([input, mapping]) => `${edge.targetNodeId}.${input} ${describeMapping(mapping)}`);
|
|
31
|
+
return [];
|
|
32
|
+
});
|
|
33
|
+
return (_jsxs(Paper, { elevation: 2, "data-testid": "node-config-panel", "data-unavailable": "true", sx: { width: NODE_CONFIG_PANEL_WIDTH, boxSizing: 'border-box', height: '100%', overflow: 'auto', borderLeft: '1px solid', borderColor: 'divider', flexShrink: 0 }, children: [_jsxs(Box, { sx: { p: 2, borderBottom: '1px solid', borderColor: 'divider' }, children: [_jsx(Typography, { variant: "subtitle2", sx: { fontWeight: 'bold' }, children: text.title }), _jsxs(Typography, { variant: "caption", color: "text.secondary", sx: { display: 'block' }, children: ["Node: ", node.id] }), _jsxs(Typography, { variant: "caption", color: "text.secondary", sx: { display: 'block' }, children: ["Block type: ", node.blockTypeId] })] }), _jsxs(Box, { sx: { p: 2, display: 'flex', flexDirection: 'column', gap: 1 }, children: [_jsx(Alert, { severity: "warning", "data-testid": "unavailable-block-reason", children: text.reason }), _jsx(Typography, { variant: "caption", color: "text.secondary", children: "Stored configuration" }), _jsx(Box, { component: "pre", "data-testid": "unavailable-block-configuration", sx: { m: 0, p: 1, fontFamily: 'monospace', fontSize: 11, whiteSpace: 'pre-wrap', wordBreak: 'break-all', bgcolor: 'action.hover', borderRadius: 1 }, children: JSON.stringify(node.configuration, null, 2) }), wires.length > 0 && (_jsxs(_Fragment, { children: [_jsx(Typography, { variant: "caption", color: "text.secondary", children: "Stored wire mappings" }), _jsx(Box, { component: "ul", "data-testid": "unavailable-block-wires", sx: { m: 0, pl: 2, fontFamily: 'monospace', fontSize: 11 }, children: wires.map((line) => _jsx("li", { children: line }, line)) })] }))] })] }));
|
|
34
|
+
}
|
|
35
|
+
/** The control a literal of `declared` is edited with, given its closed term where one is known: the map term for a map, Json
|
|
36
|
+
* for a term with no form of its own whose open literal is JSON, the closed term otherwise, or text while the term is open. */
|
|
37
|
+
function editorFieldType(declared, closed, portTypes) {
|
|
38
|
+
const writeTerm = closed ?? openTermLiteralType(declared);
|
|
39
|
+
const mapTerm = closed ?? declared;
|
|
40
|
+
if (isMapTerm(mapTerm))
|
|
41
|
+
return mapTerm;
|
|
42
|
+
return literalFormOfType(writeTerm, portTypes) === undefined && openTermLiteralType(writeTerm) === 'Json' ? 'Json' : writeTerm;
|
|
43
|
+
}
|
|
44
|
+
const UNBOUND_HINT = 'The type of this input is not chosen yet; the value is checked once it is.';
|
|
45
|
+
/** Configuration form for the selected node: the block type's own schema, then resiliency, error handling
|
|
46
|
+
* and passthrough. Everything domain-specific arrives through NodeConfigCustomization — the panel itself
|
|
47
|
+
* knows nothing beyond what a descriptor declares. */
|
|
48
|
+
export function NodeConfigPanel({ portValueEditor, rootCanvasLabel = 'Main Workflow', describeUnavailableBlock, showWireLiterals = false, }) {
|
|
49
|
+
const custom = useNodeConfigCustomization();
|
|
50
|
+
const portTypes = usePortTypes();
|
|
51
|
+
const selectedNodeId = useWorkflowEditorStore((s) => s.selectedNodeId);
|
|
52
|
+
const nodes = useWorkflowEditorStore((s) => s.nodes);
|
|
53
|
+
const edges = useWorkflowEditorStore((s) => s.edges);
|
|
54
|
+
const blockTypes = useWorkflowEditorStore((s) => s.blockTypes);
|
|
55
|
+
const canvasStack = useWorkflowEditorStore((s) => s.canvasStack);
|
|
56
|
+
const workflowInputParams = useWorkflowEditorStore((s) => s.workflowInputParams);
|
|
57
|
+
const isPaletteDragActive = useWorkflowEditorStore((s) => s.isPaletteDragActive);
|
|
58
|
+
const updateNodeConfig = useWorkflowEditorStore((s) => s.updateNodeConfig);
|
|
59
|
+
const patchNodeConfig = useWorkflowEditorStore((s) => s.patchNodeConfig);
|
|
60
|
+
const updateNodePassthrough = useWorkflowEditorStore((s) => s.updateNodePassthrough);
|
|
61
|
+
const updateNodeOutputPorts = useWorkflowEditorStore((s) => s.updateNodeOutputPorts);
|
|
62
|
+
const updateNodeErrorPolicy = useWorkflowEditorStore((s) => s.updateNodeErrorPolicy);
|
|
63
|
+
const updateEdgeMappings = useWorkflowEditorStore((s) => s.updateEdgeMappings);
|
|
64
|
+
const setNodeTypeArguments = useWorkflowEditorStore((s) => s.setNodeTypeArguments);
|
|
65
|
+
const analysis = useWorkflowEditorStore((s) => s.analysis);
|
|
66
|
+
const analysisIndex = useMemo(() => indexDraftAnalysis(analysis), [analysis]);
|
|
67
|
+
const revision = useWorkflowEditorStore((s) => s.revision);
|
|
68
|
+
const analysisFreshness = draftAnalysisFreshness(analysis, revision);
|
|
69
|
+
const analysedTerm = useAnalysedPortTerm();
|
|
70
|
+
const canvasPath = useMemo(() => canvasStack.map((f) => ({ nodeId: f.parentNodeId, branchName: f.subCanvasName })), [canvasStack]);
|
|
71
|
+
const [refusedNull, setRefusedNull] = useState(null);
|
|
72
|
+
const node = selectedNodeId === null ? undefined : nodes.find((n) => n.id === selectedNodeId);
|
|
73
|
+
const blockType = blockTypes.find((bt) => bt.blockTypeId === node?.blockTypeId);
|
|
74
|
+
const nodeIds = useMemo(() => new Set(nodes.map((n) => n.id)), [nodes]);
|
|
75
|
+
const hostPorts = useNodePorts(node ?? null, blockType);
|
|
76
|
+
const resolver = useMemo(() => createPortTypeResolver({
|
|
77
|
+
scopes: buildPortTypeScopes({ nodes, edges, canvasStack }),
|
|
78
|
+
blockTypes,
|
|
79
|
+
workflowInputParams,
|
|
80
|
+
}), [nodes, edges, canvasStack, blockTypes, workflowInputParams]);
|
|
81
|
+
const incoming = useMemo(() => (node
|
|
82
|
+
? computeIncomingVariables({ node, nodes, edges, blockTypes, canvasStack, workflowInputParams, resolver, analysis: analysisIndex, freshness: analysisFreshness })
|
|
83
|
+
: []), [node, nodes, edges, blockTypes, canvasStack, workflowInputParams, resolver, analysisIndex, analysisFreshness]);
|
|
84
|
+
if (!node)
|
|
85
|
+
return null;
|
|
86
|
+
if (node.blockTypeId === WORKFLOW_INPUT_BLOCK_TYPE_ID || node.blockTypeId === WORKFLOW_OUTPUT_BLOCK_TYPE_ID)
|
|
87
|
+
return null;
|
|
88
|
+
if (!blockType)
|
|
89
|
+
return _jsx(UnavailableBlockPanel, { node: node, edges: edges, describe: describeUnavailableBlock });
|
|
90
|
+
const passthrough = node.passthrough ?? [];
|
|
91
|
+
const refusesNull = (written) => {
|
|
92
|
+
const keys = nullConfigurationKeys(written);
|
|
93
|
+
setRefusedNull(keys.length > 0 ? { nodeId: node.id, keys } : null);
|
|
94
|
+
return keys.length > 0;
|
|
95
|
+
};
|
|
96
|
+
const setConfiguration = (configuration) => {
|
|
97
|
+
if (!refusesNull(configuration))
|
|
98
|
+
updateNodeConfig(node.id, configuration);
|
|
99
|
+
};
|
|
100
|
+
const setField = (fieldName, value) => {
|
|
101
|
+
if (!refusesNull({ [fieldName]: value }))
|
|
102
|
+
patchNodeConfig(node.id, { [fieldName]: value });
|
|
103
|
+
};
|
|
104
|
+
const nullFault = (keys) => {
|
|
105
|
+
const refused = refusedNull?.nodeId === node.id ? keys.filter((key) => refusedNull.keys.includes(key)) : [];
|
|
106
|
+
return refused.length === 0 ? null : (_jsxs(Typography, { role: "alert", variant: "caption", color: "error", children: ["Not saved: ", refused.join(', '), " cannot be null. Clearing a value removes it."] }, `null:${refused.join(',')}`));
|
|
107
|
+
};
|
|
108
|
+
const clearFields = (fieldNames) => {
|
|
109
|
+
const dropped = new Set(fieldNames);
|
|
110
|
+
setConfiguration(Object.fromEntries(Object.entries(node.configuration).filter(([key]) => !dropped.has(key))));
|
|
111
|
+
};
|
|
112
|
+
const writeErrorPolicy = (policy) => {
|
|
113
|
+
updateNodeErrorPolicy(node.id, policy);
|
|
114
|
+
if (Object.hasOwn(node.configuration, 'errorPolicy'))
|
|
115
|
+
clearFields(['errorPolicy']);
|
|
116
|
+
};
|
|
117
|
+
const readEdgeBinding = (inputName) => {
|
|
118
|
+
for (const edge of edges) {
|
|
119
|
+
if (edge.targetNodeId !== node.id || !feedsInput(edge, inputName, nodeIds))
|
|
120
|
+
continue;
|
|
121
|
+
const mapping = edge.mappings[inputName];
|
|
122
|
+
const read = mapping && readMapping(mapping);
|
|
123
|
+
if (read?.literal)
|
|
124
|
+
return `= ${String(read.value)}`;
|
|
125
|
+
if (read?.source)
|
|
126
|
+
return `↳ ${read.source}`;
|
|
127
|
+
}
|
|
128
|
+
return undefined;
|
|
129
|
+
};
|
|
130
|
+
const isFedByAnEdge = (inputName) => edges.some((e) => e.targetNodeId === node.id && feedsInput(e, inputName, nodeIds));
|
|
131
|
+
const literalFormOf = (type) => (type === undefined ? undefined : literalFormOfType(type, portTypes));
|
|
132
|
+
const prefix = portValueEditor?.expressionPrefix ?? 'expr:';
|
|
133
|
+
const refusalOf = (value, closed) => value === undefined || closed === undefined || (typeof value === 'string' && value.startsWith(prefix)) || portTypes.isLiteralOf(value, closed)
|
|
134
|
+
? undefined : closed;
|
|
135
|
+
const closedTermOf = (declared, name) => inputWriteTerm(declared, node, name, analysisIndex, canvasPath);
|
|
136
|
+
const schemaFieldOf = (name) => (blockType.configurationSchema ?? []).find((f) => f.name === name);
|
|
137
|
+
const wireLiterals = !showWireLiterals ? [] : blockType.inputs.flatMap((input) => {
|
|
138
|
+
if (hostPorts.isInputHidden(input.name))
|
|
139
|
+
return [];
|
|
140
|
+
const edge = edges.find((e) => e.targetNodeId === node.id && feedsInput(e, input.name, nodeIds) && readMapping(e.mappings[input.name] ?? {}).literal);
|
|
141
|
+
if (edge === undefined)
|
|
142
|
+
return [];
|
|
143
|
+
const declared = hostPorts.inputType(input);
|
|
144
|
+
const field = schemaFieldOf(input.name);
|
|
145
|
+
const allowed = (input.allowedValues ?? []).length > 0 ? input.allowedValues : field?.type === 'Enum' ? field.allowedValues : undefined;
|
|
146
|
+
return [{ input, edge, declared, closed: closedTermOf(declared, input.name), allowed: allowed ?? undefined }];
|
|
147
|
+
});
|
|
148
|
+
const wireLiteralOf = (name) => wireLiterals.find((wired) => wired.input.name === name);
|
|
149
|
+
const writeWireLiteral = (edge, inputName, value) => {
|
|
150
|
+
const written = { ...(edge.mappings[inputName] ?? { type: 'literal' }) };
|
|
151
|
+
delete written.literalValue;
|
|
152
|
+
if (value !== undefined)
|
|
153
|
+
written.literalValue = value;
|
|
154
|
+
updateEdgeMappings(edge.id, { ...edge.mappings, [inputName]: written });
|
|
155
|
+
};
|
|
156
|
+
const renderWireLiteral = ({ input, edge, declared, closed, allowed }) => {
|
|
157
|
+
const read = readMapping(edge.mappings[input.name] ?? {});
|
|
158
|
+
const value = read.literal ? read.value : undefined;
|
|
159
|
+
const fieldType = allowed === undefined ? editorFieldType(declared, closed, portTypes) : 'Enum';
|
|
160
|
+
const hosted = custom.renderWireLiteral?.({
|
|
161
|
+
node, blockType, input, edgeId: edge.id, value, portType: (closed ?? declared),
|
|
162
|
+
onChange: (next) => { writeWireLiteral(edge, input.name, next); },
|
|
163
|
+
});
|
|
164
|
+
if (hosted !== undefined)
|
|
165
|
+
return hosted === null ? null : _jsx(Box, { children: hosted }, `${node.id}:wire:${input.name}`);
|
|
166
|
+
return (_jsx(Box, { "data-testid": `wire-literal-${input.name}`, children: _jsx(PortValueEditor, { fieldName: input.name, label: input.displayName, required: input.isRequired, rawValue: value === undefined ? '' : value, fieldType: fieldType, literalForm: allowed === undefined ? literalFormOfType(fieldType, portTypes) : undefined, allowedValues: allowed, description: closed === undefined ? UNBOUND_HINT : 'Set on the incoming connection.', hasConnection: false, storedValueRefusal: allowed === undefined ? refusalOf(value, closed) : undefined, valueTerm: closed, secretValues: input.secretValues, canProtectSecrets: portTypes.secretCodec, onClear: () => { writeWireLiteral(edge, input.name, undefined); }, onChange: (next) => { writeWireLiteral(edge, input.name, next); }, onObjectChange: (next) => { writeWireLiteral(edge, input.name, next); }, ...portValueEditor }) }, `${node.id}:wire:${edge.id}:${input.name}`));
|
|
167
|
+
};
|
|
168
|
+
const mapInputs = blockType.inputs.flatMap((input) => {
|
|
169
|
+
if ((blockType.configurationSchema ?? []).some((f) => f.name === input.name))
|
|
170
|
+
return [];
|
|
171
|
+
if (wireLiteralOf(input.name) !== undefined)
|
|
172
|
+
return [];
|
|
173
|
+
const term = closedTermOf(input.type, input.name) ?? input.type;
|
|
174
|
+
return isMapTerm(term) ? [{ port: input, term: term }] : [];
|
|
175
|
+
});
|
|
176
|
+
const isValueAuthorable = (name) => !RESERVED_CONFIG_KEYS.has(name) &&
|
|
177
|
+
!name.startsWith(DESIGN_TIME_CONFIG_PREFIX) &&
|
|
178
|
+
!(blockType.configurationSchema ?? []).some((f) => f.name === name) &&
|
|
179
|
+
!mapInputs.some(({ port }) => port.name === name);
|
|
180
|
+
const togglePassthrough = (name) => {
|
|
181
|
+
if (!passthrough.includes(name)) {
|
|
182
|
+
updateNodePassthrough(node.id, [...passthrough, name]);
|
|
183
|
+
const offer = incoming.find((v) => v.name === name);
|
|
184
|
+
const edge = offer?.edgeId === undefined ? undefined : edges.find((e) => e.id === offer.edgeId);
|
|
185
|
+
if (edge && !edge.mappings[name]) {
|
|
186
|
+
updateEdgeMappings(edge.id, { ...edge.mappings, [name]: { type: 'direct', sourceOutputName: name } });
|
|
187
|
+
}
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
updateNodePassthrough(node.id, passthrough.filter((p) => p !== name));
|
|
191
|
+
if (blockType.inputs.some((i) => i.name === name))
|
|
192
|
+
return;
|
|
193
|
+
const owner = edges.find((e) => e.targetNodeId === node.id &&
|
|
194
|
+
e.mappings[name]?.type === 'direct' &&
|
|
195
|
+
e.mappings[name]?.sourceOutputName === name);
|
|
196
|
+
if (owner) {
|
|
197
|
+
updateEdgeMappings(owner.id, Object.fromEntries(Object.entries(owner.mappings).filter(([key]) => key !== name)));
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
const incomingEdges = edges.filter((e) => e.targetNodeId === node.id);
|
|
201
|
+
const renderField = (field) => {
|
|
202
|
+
const wired = wireLiteralOf(field.name);
|
|
203
|
+
if (wired !== undefined)
|
|
204
|
+
return renderWireLiteral(wired);
|
|
205
|
+
const value = node.configuration[field.name];
|
|
206
|
+
const context = {
|
|
207
|
+
node, blockType, field, value,
|
|
208
|
+
portType: blockType.inputs.find((input) => input.name === field.name)?.type,
|
|
209
|
+
edgeBinding: readEdgeBinding(field.name),
|
|
210
|
+
onChange: (next) => { setField(field.name, next); },
|
|
211
|
+
onConfigurationChange: setConfiguration,
|
|
212
|
+
};
|
|
213
|
+
const hosted = custom.renderConfigField?.(context);
|
|
214
|
+
if (hosted !== undefined) {
|
|
215
|
+
return hosted === null ? null : _jsxs(Box, { children: [hosted, nullFault([field.name])] }, `${node.id}:${field.name}`);
|
|
216
|
+
}
|
|
217
|
+
const portTerm = context.portType === undefined ? undefined
|
|
218
|
+
: closedTermOf(context.portType, field.name);
|
|
219
|
+
const writeTerm = context.portType === undefined ? undefined : portTerm ?? openTermLiteralType(context.portType);
|
|
220
|
+
const mapTerm = portTerm ?? context.portType;
|
|
221
|
+
const fieldType = field.type === 'Enum' || writeTerm === undefined ? field.type
|
|
222
|
+
: mapTerm !== undefined && isMapTerm(mapTerm) ? mapTerm
|
|
223
|
+
: literalFormOfType(writeTerm, portTypes) === undefined && openTermLiteralType(writeTerm) === 'Json' ? 'Json'
|
|
224
|
+
: writeTerm;
|
|
225
|
+
const opensAsExpression = (value === undefined || value === null || value === '') && portValueEditor?.renderExpressionEditor !== undefined
|
|
226
|
+
&& (field.defaultValue ?? '').startsWith(prefix);
|
|
227
|
+
const expressionBody = typeof value === 'string' && value.startsWith(prefix) ? value.slice(prefix.length) : opensAsExpression ? '' : null;
|
|
228
|
+
return (_jsxs(Fragment, { children: [_jsx(PortValueEditor, { fieldName: field.name, label: field.label, rawValue: value ?? '', placeholder: field.defaultValue ?? undefined, fieldType: fieldType, literalForm: field.type === 'Enum' ? undefined : literalFormOfType(fieldType, portTypes), allowedValues: field.allowedValues, onClear: () => { clearFields([field.name]); }, description: field.description ?? undefined, required: field.required, hasConnection: isFedByAnEdge(field.name), storedValueRefusal: field.type === 'Enum' ? undefined : refusalOf(value, portTerm), valueTerm: portTerm, secretValues: blockType.inputs.find((input) => input.name === field.name)?.secretValues, canProtectSecrets: portTypes.secretCodec, onChange: context.onChange, onObjectChange: (value) => { setField(field.name, value); }, ...portValueEditor }), expressionBody !== null && custom.renderProjectionControl && (_jsx(WiredJsonOutputs, { edges: incomingEdges, children: (jsonOutputs) => jsonOutputs.length > 0 && custom.renderProjectionControl?.({
|
|
229
|
+
placement: 'configuration', node, blockType, fieldName: field.name, targetType: fieldType, jsonOutputs, expressionBody,
|
|
230
|
+
onExpressionChange: (body) => { setField(field.name, `${prefix}${body}`); },
|
|
231
|
+
}) })), nullFault([field.name])] }, `${node.id}:${field.name}`));
|
|
232
|
+
};
|
|
233
|
+
const schemaFields = (blockType.configurationSchema ?? []).filter((field) => !(blockType.hasDynamicPorts && (field.name === 'InputPorts' || field.name === 'OutputPorts')));
|
|
234
|
+
return (_jsxs(Paper, { elevation: 2, "data-testid": "node-config-panel", sx: {
|
|
235
|
+
width: NODE_CONFIG_PANEL_WIDTH, boxSizing: 'border-box', height: '100%', overflow: 'auto',
|
|
236
|
+
borderLeft: '1px solid', borderColor: 'divider',
|
|
237
|
+
display: 'flex', flexDirection: 'column', flexShrink: 0,
|
|
238
|
+
pointerEvents: isPaletteDragActive ? 'none' : 'auto',
|
|
239
|
+
opacity: isPaletteDragActive ? 0.6 : 1,
|
|
240
|
+
}, children: [_jsxs(Box, { sx: { p: 2, borderBottom: '1px solid', borderColor: 'divider' }, children: [_jsx(Typography, { variant: "subtitle2", sx: { fontWeight: 'bold' }, children: blockType.displayName }), _jsxs(Typography, { variant: "caption", color: "text.secondary", sx: { display: 'block' }, children: ["Node: ", node.id] }), canvasStack.length > 0 && (_jsxs(Typography, { variant: "caption", color: "text.secondary", sx: { display: 'block' }, children: ["Path: ", rootCanvasLabel, " / ", canvasStack.map((frame) => frame.subCanvasName).join(' / ')] })), _jsx(Typography, { variant: "caption", color: "text.secondary", children: "Configuration" })] }), _jsxs(Box, { sx: { p: 2, display: 'flex', flexDirection: 'column', gap: 2 }, children: [blockType.hasDynamicPorts && (_jsxs(_Fragment, { children: [_jsx(PortDeclarationTable, { label: "Input Ports", value: node.configuration['InputPorts'], onChange: (json) => { setField('InputPorts', json); } }, `${node.id}-input-ports`), _jsx(PortDeclarationTable, { label: "Output Ports", value: node.configuration['OutputPorts'], onChange: (json) => { setField('OutputPorts', json); } }, `${node.id}-output-ports`), _jsx(Divider, {})] })), blockType.supportsDeclaredOutputs && (_jsxs(_Fragment, { children: [_jsx(DeclaredOutputPortTable, { label: "Declared Outputs (mapped per branch)", subCanvasNames: blockType.subCanvasNames ?? [], value: node.outputPorts, onChange: (ports) => { updateNodeOutputPorts(node.id, ports); } }, `${node.id}-declared-outputs`), _jsx(Divider, {})] })), schemaFields.map(renderField), wireLiterals.filter((wired) => schemaFieldOf(wired.input.name) === undefined).map(renderWireLiteral), mapInputs.map(({ port, term }) => (_jsxs(Fragment, { children: [_jsx(PortValueEditor, { fieldName: port.name, label: port.displayName, required: port.isRequired, rawValue: node.configuration[port.name] ?? '', fieldType: term, literalForm: literalFormOfType(term, portTypes), onClear: () => { clearFields([port.name]); }, hasConnection: isFedByAnEdge(port.name), storedValueRefusal: refusalOf(node.configuration[port.name], closedTermOf(port.type, port.name)), valueTerm: closedTermOf(port.type, port.name), secretValues: port.secretValues, canProtectSecrets: portTypes.secretCodec, onChange: (value) => { setField(port.name, value); }, onObjectChange: (value) => { setField(port.name, value); }, ...portValueEditor }), nullFault([port.name])] }, `${node.id}:${port.name}`))), (blockType.typeParameters ?? []).length > 0 && custom.renderTypeArgumentPicker?.({
|
|
241
|
+
node, blockType, typeParameters: blockType.typeParameters ?? [], typeArguments: node.typeArguments ?? {},
|
|
242
|
+
onChange: (typeArguments) => { setNodeTypeArguments(node.id, typeArguments); },
|
|
243
|
+
}), custom.renderNodeSections?.({ node, blockType, onConfigurationChange: setConfiguration }), nullFault((refusedNull?.keys ?? []).filter((key) => !schemaFields.some((field) => field.name === key))), _jsx(Divider, {}), _jsx(ResiliencySection, { configuration: node.configuration, onChange: setField, isContainer: (blockType.subCanvasNames ?? []).length > 0, onClear: clearFields }, `${node.id}-resiliency`), _jsx(Divider, {}), _jsx(ErrorHandlingSection, { errorPolicy: node.errorPolicy, onChange: writeErrorPolicy, onReset: () => { writeErrorPolicy(null); } }), _jsx(Divider, {}), _jsx(PassthroughSection, { incoming: incoming, passthrough: passthrough, termOf: (name) => analysedTerm(node.id, 'inputs', name), onToggle: togglePassthrough, subCanvasNames: blockType.subCanvasNames ?? [], renderValueEditor: (name) => (isValueAuthorable(name)
|
|
244
|
+
? (_jsx(PortValueEditor, { fieldName: name, label: name, rawValue: node.configuration[name] ?? '', fieldType: incoming.find((v) => v.name === name)?.type, literalForm: literalFormOf(incoming.find((v) => v.name === name)?.type), onClear: () => { clearFields([name]); }, hasConnection: isFedByAnEdge(name), onChange: (value) => { setField(name, value); }, onObjectChange: (value) => { setField(name, value); }, ...portValueEditor }, `${node.id}:passthrough:${name}`))
|
|
245
|
+
: null) }, `${node.id}-passthrough`)] })] }));
|
|
246
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { IncomingVariable, PortTermDisplay } from '@reeve-iot/workflow-core';
|
|
3
|
+
export interface PassthroughSectionProps {
|
|
4
|
+
incoming: readonly IncomingVariable[];
|
|
5
|
+
passthrough: readonly string[];
|
|
6
|
+
/** Ticking a name is more than adding it to a list — a host may have to feed it on the wire too — so the
|
|
7
|
+
* section reports the name and leaves the meaning to its owner. */
|
|
8
|
+
onToggle: (name: string) => void;
|
|
9
|
+
/** Branch names this block owns, named in the hint: a tick here also reaches those sub-canvases. */
|
|
10
|
+
subCanvasNames?: readonly string[];
|
|
11
|
+
/** A value editor for a forwarded name, or null for a name that must not be authored here. */
|
|
12
|
+
renderValueEditor?: (name: string) => ReactNode;
|
|
13
|
+
/** The term the server's analysis gives a name this node forwards, shown in place of the incoming one; the feed decides it. */
|
|
14
|
+
termOf?: (name: string) => PortTermDisplay | undefined;
|
|
15
|
+
}
|
|
16
|
+
/** Which incoming variables this node forwards to its own outputs, plus names typed by hand for a value
|
|
17
|
+
* the editor cannot see yet — a plugin output the catalogue has not caught up with. */
|
|
18
|
+
export declare function PassthroughSection({ incoming, passthrough, onToggle, subCanvasNames, renderValueEditor, termOf, }: PassthroughSectionProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Box, Checkbox, IconButton, InputAdornment, List, ListItem, ListItemIcon, ListItemText, TextField, Typography, } from '@mui/material';
|
|
4
|
+
import AddIcon from '@mui/icons-material/Add';
|
|
5
|
+
import { termText } from '../canvas/analysedPortTerm.js';
|
|
6
|
+
import { BLANK_NAME_ACCEPTED, draftInScope, nameFault } from '../nameDraft.js';
|
|
7
|
+
const incomingTerm = (v, own) => own !== undefined ? termText(own) : v.type === undefined ? undefined : v.stale ? `${v.type} (stale)` : v.type;
|
|
8
|
+
const customTerm = (own) => own === undefined ? 'Custom' : `Custom (${termText(own)})`;
|
|
9
|
+
/** Which incoming variables this node forwards to its own outputs, plus names typed by hand for a value
|
|
10
|
+
* the editor cannot see yet — a plugin output the catalogue has not caught up with. */
|
|
11
|
+
export function PassthroughSection({ incoming, passthrough, onToggle, subCanvasNames = [], renderValueEditor, termOf, }) {
|
|
12
|
+
const context = JSON.stringify([incoming.map((v) => v.name), passthrough]);
|
|
13
|
+
const [draft, setDraft] = useState({ scope: context, text: '', touched: false });
|
|
14
|
+
const live = draftInScope(draft, context) ?? { scope: context, text: '', touched: false };
|
|
15
|
+
const toggle = onToggle;
|
|
16
|
+
const addCustom = () => {
|
|
17
|
+
setDraft({ scope: context, text: live.text, touched: true });
|
|
18
|
+
if (nameFault(live.text, BLANK_NAME_ACCEPTED) !== null || passthrough.includes(live.text))
|
|
19
|
+
return;
|
|
20
|
+
onToggle(live.text);
|
|
21
|
+
setDraft({ scope: context, text: '', touched: false });
|
|
22
|
+
};
|
|
23
|
+
const nameFaultText = live.text === '' && !live.touched ? null : nameFault(live.text, BLANK_NAME_ACCEPTED);
|
|
24
|
+
const valueEditors = passthrough
|
|
25
|
+
.map((name) => [name, renderValueEditor?.(name) ?? null])
|
|
26
|
+
.filter(([, editor]) => editor !== null);
|
|
27
|
+
const custom = passthrough.filter((p) => !incoming.some((v) => v.name === p));
|
|
28
|
+
return (_jsxs(Box, { children: [_jsx(Typography, { variant: "subtitle2", sx: { mb: 1 }, children: "Passthrough Variables" }), _jsx(Typography, { variant: "caption", color: "text.secondary", sx: { display: 'block', mb: 2 }, children: "Incoming variables that should be passed to the output." }), subCanvasNames.length > 0 && (_jsxs(Typography, { variant: "caption", color: "text.secondary", sx: { display: 'block', mb: 2 }, children: ["Each also reaches ", subCanvasNames.join(' / '), ": a sub-canvas is seeded with this block's resolved inputs, so ticking one gives Workflow Input inside the branch a matching port."] })), _jsxs(List, { disablePadding: true, children: [incoming.map((v) => (_jsxs(ListItem, { dense: true, disableGutters: true, children: [_jsx(ListItemIcon, { sx: { minWidth: 36 }, children: _jsx(Checkbox, { size: "small", edge: "start", checked: passthrough.includes(v.name), slotProps: { input: { 'aria-label': `Forward ${v.name}` } }, onChange: () => { toggle(v.name); } }) }), _jsx(ListItemText, { primary: v.name, secondary: incomingTerm(v, passthrough.includes(v.name) ? termOf?.(v.name) : undefined), slotProps: { primary: { variant: 'body2' } } })] }, v.name))), custom.map((p) => (_jsxs(ListItem, { dense: true, disableGutters: true, children: [_jsx(ListItemIcon, { sx: { minWidth: 36 }, children: _jsx(Checkbox, { size: "small", edge: "start", checked: true, slotProps: { input: { 'aria-label': `Forward ${p}` } }, onChange: () => { toggle(p); } }) }), _jsx(ListItemText, { primary: p, secondary: customTerm(termOf?.(p)), slotProps: { primary: { variant: 'body2' } } })] }, p)))] }), valueEditors.length > 0 && (_jsxs(Box, { sx: { mt: 2, display: 'flex', flexDirection: 'column', gap: 1.5 }, children: [_jsx(Typography, { variant: "caption", color: "text.secondary", children: subCanvasNames.length > 0
|
|
29
|
+
? 'Values — a variable no wire feeds can be given a constant or an expression, and reaches the sub-canvas the same way.'
|
|
30
|
+
: 'Values' }), valueEditors.map(([name, editor]) => _jsx(Box, { children: editor }, `passthrough-${name}`))] })), _jsx(Box, { sx: { mt: 2, display: 'flex', gap: 1 }, children: _jsx(TextField, { size: "small", placeholder: "Add variable name", value: live.text, error: nameFaultText !== null, helperText: nameFaultText ?? undefined, slotProps: {
|
|
31
|
+
htmlInput: { 'aria-label': 'Add variable name' },
|
|
32
|
+
input: {
|
|
33
|
+
endAdornment: (_jsx(InputAdornment, { position: "end", children: _jsx(IconButton, { size: "small", "aria-label": "Add passthrough variable", onClick: addCustom, children: _jsx(AddIcon, { fontSize: "small" }) }) })),
|
|
34
|
+
},
|
|
35
|
+
}, onChange: (e) => { setDraft({ scope: context, text: e.target.value, touched: true }); }, onKeyDown: (e) => { if (e.key === 'Enter')
|
|
36
|
+
addCustom(); } }) })] }));
|
|
37
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const DEFAULT_TIMEOUT_SECONDS = 30;
|
|
2
|
+
export declare const DEFAULT_RETRY_COUNT = 3;
|
|
3
|
+
export declare const DEFAULT_RETRY_BACKOFF_SECONDS = 1;
|
|
4
|
+
export interface ResiliencySectionProps {
|
|
5
|
+
configuration: Record<string, unknown>;
|
|
6
|
+
onChange: (fieldName: string, value: number | boolean) => void;
|
|
7
|
+
/** Whether this node holds a sub-canvas. The engine applies its block default to a leaf and nothing at all
|
|
8
|
+
* to a container, so the timeout box must not offer a container a default it will never get. */
|
|
9
|
+
isContainer?: boolean;
|
|
10
|
+
/** Removes fields rather than giving them values; a container with no timeout has no key, not a number.
|
|
11
|
+
* A set rather than one name: going back to the retry default takes three keys off in one write, and a
|
|
12
|
+
* host removing them one at a time would write each from the configuration it had before the first. */
|
|
13
|
+
onClear?: (fieldNames: readonly string[]) => void;
|
|
14
|
+
}
|
|
15
|
+
/** Per-node timeout and retry. What the engine does with an unset retry is not a fixed answer — it is the
|
|
16
|
+
* block's own IsIdempotent — so the box offers that as a state rather than guessing one of the two. */
|
|
17
|
+
export declare function ResiliencySection({ configuration, onChange, isContainer, onClear }: ResiliencySectionProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Box, TextField, Typography } from '@mui/material';
|
|
4
|
+
export const DEFAULT_TIMEOUT_SECONDS = 30;
|
|
5
|
+
export const DEFAULT_RETRY_COUNT = 3;
|
|
6
|
+
export const DEFAULT_RETRY_BACKOFF_SECONDS = 1.0;
|
|
7
|
+
const WIDEST_ENGINE_INTEGER = 2147483647;
|
|
8
|
+
const LONGEST_ENGINE_WAIT_SECONDS = 86400;
|
|
9
|
+
const NUMBER_INPUT_TEXT = /^-?(\d+(\.\d+)?|\.\d+)(e[-+]?\d+)?$/i;
|
|
10
|
+
function refuse(value, bounds) {
|
|
11
|
+
if (Number.isNaN(value))
|
|
12
|
+
return { kind: 'refused', reason: 'Enter a number' };
|
|
13
|
+
if (!Number.isFinite(value) || (bounds.whole && value > WIDEST_ENGINE_INTEGER)) {
|
|
14
|
+
return { kind: 'refused', reason: 'Too large for the engine to read — the run fails at this block' };
|
|
15
|
+
}
|
|
16
|
+
if (bounds.whole && value < -WIDEST_ENGINE_INTEGER - 1) {
|
|
17
|
+
return { kind: 'refused', reason: 'Further below zero than the engine reads — the run fails at this block' };
|
|
18
|
+
}
|
|
19
|
+
if (bounds.whole && !Number.isInteger(value)) {
|
|
20
|
+
return { kind: 'refused', reason: 'Whole numbers only — with a fraction here the run fails at this block' };
|
|
21
|
+
}
|
|
22
|
+
if (bounds.wait !== undefined && value > LONGEST_ENGINE_WAIT_SECONDS) {
|
|
23
|
+
return {
|
|
24
|
+
kind: 'refused',
|
|
25
|
+
reason: `At most ${LONGEST_ENGINE_WAIT_SECONDS} seconds — one day, the longest single wait the engine `
|
|
26
|
+
+ `can apply. ${bounds.wait}`,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (value < bounds.min) {
|
|
30
|
+
return {
|
|
31
|
+
kind: 'clamped',
|
|
32
|
+
reason: `Must be at least ${bounds.min} — the engine runs anything lower as ${bounds.min}`,
|
|
33
|
+
typed: `Must be at least ${bounds.min} — the engine would run anything lower as ${bounds.min}`,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
function typeName(value) {
|
|
39
|
+
if (typeof value === 'string')
|
|
40
|
+
return 'text';
|
|
41
|
+
if (typeof value === 'boolean')
|
|
42
|
+
return 'true/false';
|
|
43
|
+
if (Array.isArray(value))
|
|
44
|
+
return 'a list';
|
|
45
|
+
if (typeof value === 'object')
|
|
46
|
+
return 'an object';
|
|
47
|
+
return `a ${typeof value}`;
|
|
48
|
+
}
|
|
49
|
+
function storedVerdict(value, bounds) {
|
|
50
|
+
if (value === undefined || value === null)
|
|
51
|
+
return null;
|
|
52
|
+
if (typeof value !== 'number') {
|
|
53
|
+
return {
|
|
54
|
+
kind: 'refused',
|
|
55
|
+
reason: `Stored as ${typeName(value)}, not a number — the engine refuses the definition and the run `
|
|
56
|
+
+ 'fails at this block',
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return refuse(value, bounds);
|
|
60
|
+
}
|
|
61
|
+
function displayStored(value, fallback) {
|
|
62
|
+
if (value === undefined || value === null)
|
|
63
|
+
return fallback;
|
|
64
|
+
return typeof value === 'object' ? JSON.stringify(value) : String(value);
|
|
65
|
+
}
|
|
66
|
+
function CommittedNumberField({ label, display, stored = null, bounds, helperText, placeholder, onCommit, onCommitEmpty }) {
|
|
67
|
+
const [draft, setDraft] = useState(null);
|
|
68
|
+
const [refusal, setRefusal] = useState(null);
|
|
69
|
+
const commit = () => {
|
|
70
|
+
if (draft === null)
|
|
71
|
+
return;
|
|
72
|
+
const text = draft.trim();
|
|
73
|
+
if (text === '') {
|
|
74
|
+
setDraft(null);
|
|
75
|
+
setRefusal(null);
|
|
76
|
+
onCommitEmpty();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const value = Number(text);
|
|
80
|
+
const verdict = refuse(value, bounds);
|
|
81
|
+
if (verdict !== null) {
|
|
82
|
+
setRefusal(verdict.typed ?? verdict.reason);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
setDraft(null);
|
|
86
|
+
setRefusal(null);
|
|
87
|
+
onCommit(value);
|
|
88
|
+
};
|
|
89
|
+
const showing = draft ?? display;
|
|
90
|
+
const parsable = display === '' || NUMBER_INPUT_TEXT.test(display);
|
|
91
|
+
return (_jsx(TextField, { fullWidth: true, size: "small", label: label, type: parsable ? 'number' : 'text', value: showing, placeholder: placeholder, error: refusal !== null || (draft === null && stored?.kind === 'refused'), slotProps: { htmlInput: { 'aria-label': label } }, onChange: (e) => { setDraft(e.target.value); setRefusal(null); }, onBlur: commit, onKeyDown: (e) => {
|
|
92
|
+
if (e.key === 'Enter') {
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
commit();
|
|
95
|
+
}
|
|
96
|
+
else if (e.key === 'Escape') {
|
|
97
|
+
setDraft(null);
|
|
98
|
+
setRefusal(null);
|
|
99
|
+
}
|
|
100
|
+
}, helperText: refusal ?? (draft === null ? stored?.reason : null) ?? helperText }));
|
|
101
|
+
}
|
|
102
|
+
const RETRY_KEYS = ['retryEnabled', 'retryCount', 'retryBackoffSeconds'];
|
|
103
|
+
function readRetryChoice(configuration) {
|
|
104
|
+
const flag = configuration['retryEnabled'];
|
|
105
|
+
if (flag === true)
|
|
106
|
+
return 'on';
|
|
107
|
+
if (flag === false)
|
|
108
|
+
return 'off';
|
|
109
|
+
return flag === undefined || flag === null ? 'default' : 'unreadable';
|
|
110
|
+
}
|
|
111
|
+
const RETRY_HELP = {
|
|
112
|
+
default: 'The block’s own declaration decides, together with the host’s retry setting',
|
|
113
|
+
on: 'Retried on failure, a timeout included, as many times as the count below',
|
|
114
|
+
off: 'Never retried',
|
|
115
|
+
unreadable: 'This node stores a retry flag the engine cannot read; the run fails at this block',
|
|
116
|
+
};
|
|
117
|
+
const isSet = (value) => value !== undefined && value !== null;
|
|
118
|
+
const TIMEOUT_BOUNDS = {
|
|
119
|
+
min: 1,
|
|
120
|
+
whole: true,
|
|
121
|
+
wait: 'A longer one fails the run at this block, and a block that must run longer than a day carries no '
|
|
122
|
+
+ 'timeout of its own.',
|
|
123
|
+
};
|
|
124
|
+
const COUNT_BOUNDS = { min: 0, whole: true };
|
|
125
|
+
function backoffBounds(retryChoice, configuration) {
|
|
126
|
+
const count = configuration['retryCount'];
|
|
127
|
+
const attempts = typeof count === 'number' ? count : isSet(count) ? 0 : DEFAULT_RETRY_COUNT;
|
|
128
|
+
return retryChoice === 'on' && attempts > 0
|
|
129
|
+
? { min: 0, whole: false, wait: 'A longer delay fails the run at this block.' }
|
|
130
|
+
: { min: 0, whole: false };
|
|
131
|
+
}
|
|
132
|
+
/** Per-node timeout and retry. What the engine does with an unset retry is not a fixed answer — it is the
|
|
133
|
+
* block's own IsIdempotent — so the box offers that as a state rather than guessing one of the two. */
|
|
134
|
+
export function ResiliencySection({ configuration, onChange, isContainer = false, onClear }) {
|
|
135
|
+
const retryChoice = readRetryChoice(configuration);
|
|
136
|
+
const stored = configuration['timeoutSeconds'];
|
|
137
|
+
const backoff = backoffBounds(retryChoice, configuration);
|
|
138
|
+
return (_jsxs(Box, { children: [_jsx(Typography, { variant: "subtitle2", sx: { mb: 1 }, children: "Resiliency" }), _jsxs(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: [_jsx(CommittedNumberField, { label: "Timeout (seconds)", display: displayStored(stored, ''), stored: storedVerdict(stored, TIMEOUT_BOUNDS), bounds: TIMEOUT_BOUNDS, onCommit: (value) => { onChange('timeoutSeconds', value); }, onCommitEmpty: () => {
|
|
139
|
+
if (onClear)
|
|
140
|
+
onClear(['timeoutSeconds']);
|
|
141
|
+
else
|
|
142
|
+
onChange('timeoutSeconds', DEFAULT_TIMEOUT_SECONDS);
|
|
143
|
+
}, placeholder: isContainer ? undefined : String(DEFAULT_TIMEOUT_SECONDS), helperText: isContainer
|
|
144
|
+
? 'Empty means this block sets no deadline of its own'
|
|
145
|
+
: 'Empty leaves the engine’s own 30-second default in place' }), _jsxs(TextField, { select: true, fullWidth: true, size: "small", label: "Retry", value: retryChoice, slotProps: {
|
|
146
|
+
select: { native: true }, inputLabel: { shrink: true }, htmlInput: { 'aria-label': 'Retry' },
|
|
147
|
+
}, onChange: (e) => {
|
|
148
|
+
const next = e.target.value;
|
|
149
|
+
if (next === 'on')
|
|
150
|
+
onChange('retryEnabled', true);
|
|
151
|
+
else if (next === 'off')
|
|
152
|
+
onChange('retryEnabled', false);
|
|
153
|
+
else
|
|
154
|
+
onClear?.(RETRY_KEYS);
|
|
155
|
+
}, helperText: RETRY_HELP[retryChoice], children: [_jsx("option", { value: "default", disabled: onClear === undefined, children: "Default \u2014 the block decides" }), _jsx("option", { value: "on", children: "On" }), _jsx("option", { value: "off", children: "Off" }), retryChoice === 'unreadable' && (_jsx("option", { value: "unreadable", disabled: true, children: "Unreadable \u2014 the engine refuses this node" }))] }), (retryChoice === 'on' || isSet(configuration['retryCount'])) && (_jsx(CommittedNumberField, { label: "Retry Count", display: displayStored(configuration['retryCount'], String(DEFAULT_RETRY_COUNT)), stored: storedVerdict(configuration['retryCount'], COUNT_BOUNDS), bounds: COUNT_BOUNDS, onCommit: (value) => { onChange('retryCount', value); }, onCommitEmpty: () => { onChange('retryCount', DEFAULT_RETRY_COUNT); }, helperText: "Retry attempts after the first, where 0 means none. Max time is roughly count x timeout." })), (retryChoice === 'on' || isSet(configuration['retryBackoffSeconds'])) && (_jsx(CommittedNumberField, { label: "Backoff (seconds)", display: displayStored(configuration['retryBackoffSeconds'], String(DEFAULT_RETRY_BACKOFF_SECONDS)), stored: storedVerdict(configuration['retryBackoffSeconds'], backoff), bounds: backoff, onCommit: (value) => { onChange('retryBackoffSeconds', value); }, onCommitEmpty: () => { onChange('retryBackoffSeconds', DEFAULT_RETRY_BACKOFF_SECONDS); }, helperText: "Initial delay for exponential backoff" }))] })] }));
|
|
156
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TypeArgumentPickerContext } from './nodeConfigCustomization.js';
|
|
2
|
+
/** One row per type parameter: the registered terms implementing its constraints, a collection or nullable level, and Clear,
|
|
3
|
+
* which removes the entry so the compiler infers it again. */
|
|
4
|
+
export declare function TypeArgumentPicker({ context }: {
|
|
5
|
+
context: TypeArgumentPickerContext;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { Box, Button, MenuItem, Select, Typography } from '@mui/material';
|
|
4
|
+
import { typeArgumentBases, usePortTypes, wrapTypeArgument } from '@reeve-iot/workflow-core';
|
|
5
|
+
import { typesWithCurrent } from '../ports/collectionComposer.js';
|
|
6
|
+
const INFERRED = ' inferred';
|
|
7
|
+
function ParameterRow({ parameter, context }) {
|
|
8
|
+
const portTypes = usePortTypes();
|
|
9
|
+
const constraints = useMemo(() => parameter.constraints ?? [], [parameter]);
|
|
10
|
+
const bases = useMemo(() => typeArgumentBases(portTypes, constraints), [portTypes, constraints]);
|
|
11
|
+
const stored = Object.hasOwn(context.typeArguments, parameter.name) ? context.typeArguments[parameter.name] : undefined;
|
|
12
|
+
const name = parameter.name;
|
|
13
|
+
const write = (term) => {
|
|
14
|
+
const next = { ...context.typeArguments };
|
|
15
|
+
if (term === undefined)
|
|
16
|
+
delete next[name];
|
|
17
|
+
else
|
|
18
|
+
next[name] = term;
|
|
19
|
+
context.onChange(next);
|
|
20
|
+
};
|
|
21
|
+
const collection = stored === undefined ? undefined : wrapTypeArgument(portTypes, stored, 'collection', constraints);
|
|
22
|
+
const nullable = stored === undefined ? undefined : wrapTypeArgument(portTypes, stored, 'nullable', constraints);
|
|
23
|
+
return (_jsxs(Box, { sx: { display: 'flex', gap: 1, alignItems: 'center', flexWrap: 'wrap', mb: 1 }, "data-testid": `type-argument-${name}`, children: [_jsx(Typography, { variant: "body2", sx: { minWidth: 40 }, children: name }), _jsxs(Select, { size: "small", variant: "standard", displayEmpty: true, value: stored ?? INFERRED, sx: { minWidth: 140 }, inputProps: { 'aria-label': `Type argument ${name}` }, onChange: (event) => { write(event.target.value === INFERRED ? undefined : event.target.value); }, children: [_jsx(MenuItem, { value: INFERRED, children: _jsx("em", { children: "Inferred" }) }), typesWithCurrent(bases, stored).map((term) => _jsx(MenuItem, { value: term, children: term }, term)), stored === '' && _jsx(MenuItem, { value: "", children: "(empty)" })] }), _jsx(Button, { size: "small", variant: "outlined", disabled: collection === undefined, "aria-label": `Type argument ${name} in a collection`, onClick: () => { if (collection !== undefined)
|
|
24
|
+
write(collection); }, children: "Collection" }), _jsx(Button, { size: "small", variant: "outlined", disabled: nullable === undefined, "aria-label": `Type argument ${name} nullable`, onClick: () => { if (nullable !== undefined)
|
|
25
|
+
write(nullable); }, children: "Nullable" }), _jsx(Button, { size: "small", disabled: stored === undefined, "aria-label": `Clear type argument ${name}`, onClick: () => { write(undefined); }, children: "Clear" }), constraints.length > 0 && _jsx(Typography, { variant: "caption", color: "text.secondary", children: constraints.join(', ') })] }));
|
|
26
|
+
}
|
|
27
|
+
/** One row per type parameter: the registered terms implementing its constraints, a collection or nullable level, and Clear,
|
|
28
|
+
* which removes the entry so the compiler infers it again. */
|
|
29
|
+
export function TypeArgumentPicker({ context }) {
|
|
30
|
+
return (_jsxs(Box, { sx: { mt: 2, mb: 2 }, children: [_jsx(Typography, { variant: "subtitle2", sx: { mb: 1 }, children: "Type Arguments" }), context.typeParameters.map((parameter) => _jsx(ParameterRow, { parameter: parameter, context: context }, parameter.name))] }));
|
|
31
|
+
}
|