@flowdrop/flowdrop 1.15.0 → 2.0.0-beta.10
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 +648 -0
- package/MIGRATION-2.0.md +642 -0
- package/README.md +28 -28
- package/dist/adapters/WorkflowAdapter.d.ts +1 -1
- package/dist/adapters/WorkflowAdapter.js +18 -13
- package/dist/adapters/agentspec/AgentSpecAdapter.js +10 -10
- package/dist/adapters/agentspec/defaultNodeTypes.js +9 -9
- package/dist/api/enhanced-client.js +6 -11
- package/dist/chat/batchFeedback.d.ts +39 -0
- package/dist/chat/batchFeedback.js +51 -0
- package/dist/commands/executor.js +66 -27
- package/dist/commands/storeIntegration.svelte.d.ts +4 -1
- package/dist/commands/storeIntegration.svelte.js +36 -21
- package/dist/commands/types.d.ts +2 -0
- package/dist/commands/types.js +5 -5
- package/dist/components/App.svelte +696 -565
- package/dist/components/App.svelte.d.ts +63 -16
- package/dist/components/Button.stories.svelte +65 -0
- package/dist/components/Button.stories.svelte.d.ts +19 -0
- package/dist/components/Button.svelte +62 -0
- package/dist/components/Button.svelte.d.ts +24 -0
- package/dist/components/CanvasIconButton.svelte +76 -0
- package/dist/components/CanvasIconButton.svelte.d.ts +18 -0
- package/dist/components/ConfigForm.svelte +181 -552
- package/dist/components/ConfigForm.svelte.d.ts +24 -7
- package/dist/components/ConfigModal.svelte +16 -3
- package/dist/components/ConfigPanel.svelte +234 -15
- package/dist/components/ConfigPanel.svelte.d.ts +6 -0
- package/dist/components/ConnectionLine.svelte +4 -2
- package/dist/components/EditorStatusBar.stories.svelte +44 -0
- package/dist/components/EditorStatusBar.stories.svelte.d.ts +27 -0
- package/dist/components/EditorStatusBar.svelte +99 -0
- package/dist/components/EditorStatusBar.svelte.d.ts +15 -0
- package/dist/components/IconButton.svelte +80 -0
- package/dist/components/IconButton.svelte.d.ts +30 -0
- package/dist/components/Input.svelte +74 -0
- package/dist/components/Input.svelte.d.ts +17 -0
- package/dist/components/LogoWordmark.svelte +113 -0
- package/dist/components/LogoWordmark.svelte.d.ts +26 -0
- package/dist/components/Navbar.svelte +78 -64
- package/dist/components/Navbar.svelte.d.ts +3 -0
- package/dist/components/NodeSidebar.svelte +48 -171
- package/dist/components/NodeStatusOverlay.svelte +94 -6
- package/dist/components/NodeSwapPicker.svelte +22 -38
- package/dist/components/PipelineStatus.svelte +22 -68
- package/dist/components/PipelineStatus.svelte.d.ts +3 -0
- package/dist/components/PortCoordinateTracker.svelte +5 -6
- package/dist/components/PortMappingRow.svelte +0 -2
- package/dist/components/SchemaForm.stories.svelte +1 -3
- package/dist/components/SchemaForm.svelte +22 -39
- package/dist/components/SchemaForm.svelte.d.ts +0 -8
- package/dist/components/Select.svelte +53 -0
- package/dist/components/Select.svelte.d.ts +15 -0
- package/dist/components/SettingsModal.svelte +8 -8
- package/dist/components/SettingsPanel.svelte +44 -10
- package/dist/components/SwapMappingEditor.svelte +67 -49
- package/dist/components/SwapMappingEditor.svelte.d.ts +0 -2
- package/dist/components/Textarea.svelte +39 -0
- package/dist/components/Textarea.svelte.d.ts +12 -0
- package/dist/components/ThemeToggle.svelte +15 -94
- package/dist/components/UniversalNode.svelte +45 -11
- package/dist/components/UniversalNode.svelte.d.ts +1 -1
- package/dist/components/WorkflowEditor.svelte +183 -162
- package/dist/components/WorkflowEditor.svelte.d.ts +39 -10
- package/dist/components/chat/AIChatPanel.svelte +99 -90
- package/dist/components/chat/AIChatPanel.svelte.d.ts +0 -4
- package/dist/components/chat/CommandPreview.svelte +2 -1
- package/dist/components/console/CommandConsole.svelte +7 -5
- package/dist/components/console/ConsoleAutocomplete.svelte +11 -12
- package/dist/components/console/ConsoleAutocomplete.svelte.d.ts +6 -0
- package/dist/components/console/ConsoleInput.svelte +18 -9
- package/dist/components/console/ConsoleOutput.svelte +4 -3
- package/dist/components/form/FormArray.svelte +42 -182
- package/dist/components/form/FormArray.svelte.d.ts +2 -1
- package/dist/components/form/FormAutocomplete.svelte +26 -21
- package/dist/components/form/FormCheckboxGroup.svelte +1 -5
- package/dist/components/form/FormCodeEditor.svelte +9 -7
- package/dist/components/form/FormField.svelte +22 -44
- package/dist/components/form/FormFieldLight.svelte +56 -50
- package/dist/components/form/FormFieldLight.svelte.d.ts +12 -0
- package/dist/components/form/FormFieldset.svelte +45 -11
- package/dist/components/form/FormMarkdownEditor.svelte +17 -9
- package/dist/components/form/FormNumberField.svelte +4 -36
- package/dist/components/form/FormPorts.svelte +262 -0
- package/dist/components/form/FormPorts.svelte.d.ts +13 -0
- package/dist/components/form/FormRangeField.svelte +62 -30
- package/dist/components/form/FormSelect.svelte +13 -75
- package/dist/components/form/FormTemplateEditor.svelte +17 -7
- package/dist/components/form/FormTextField.svelte +3 -35
- package/dist/components/form/FormTextarea.svelte +4 -39
- package/dist/components/form/FormToggle.svelte +5 -16
- package/dist/components/form/FormToggle.svelte.d.ts +4 -2
- package/dist/components/form/FormUISchemaRenderer.svelte +3 -1
- package/dist/components/form/resolveFieldType.d.ts +24 -0
- package/dist/components/form/resolveFieldType.js +55 -0
- package/dist/components/form/templateAutocomplete.js +1 -5
- package/dist/components/form/types.d.ts +1 -14
- package/dist/components/icons/CloseIcon.svelte +6 -0
- package/dist/components/icons/CloseIcon.svelte.d.ts +26 -0
- package/dist/components/icons/CommandLineIcon.svelte +15 -0
- package/dist/components/icons/CommandLineIcon.svelte.d.ts +26 -0
- package/dist/components/icons/MenuIcon.svelte +4 -0
- package/dist/components/icons/MenuIcon.svelte.d.ts +26 -0
- package/dist/components/icons/MenuOpenIcon.svelte +6 -0
- package/dist/components/icons/MenuOpenIcon.svelte.d.ts +26 -0
- package/dist/components/interrupt/ChoicePrompt.svelte +0 -10
- package/dist/components/interrupt/ConfirmationPrompt.svelte +0 -5
- package/dist/components/interrupt/FormPrompt.svelte +3 -2
- package/dist/components/interrupt/InterruptBubble.svelte +25 -27
- package/dist/components/interrupt/ReviewPrompt.svelte +10 -23
- package/dist/components/interrupt/TextInputPrompt.svelte +2 -7
- package/dist/components/layouts/MainLayout.svelte +24 -18
- package/dist/components/layouts/MainLayout.svelte.d.ts +4 -0
- package/dist/components/nodes/AtomNode.svelte +70 -72
- package/dist/components/nodes/AtomNode.svelte.d.ts +1 -1
- package/dist/components/nodes/GatewayNode.svelte +134 -172
- package/dist/components/nodes/GatewayNode.svelte.d.ts +1 -1
- package/dist/components/nodes/IdeaNode.svelte +79 -98
- package/dist/components/nodes/IdeaNode.svelte.d.ts +8 -4
- package/dist/components/nodes/NodeConfigButton.svelte +86 -0
- package/dist/components/nodes/NodeConfigButton.svelte.d.ts +15 -0
- package/dist/components/nodes/NotesNode.svelte +76 -85
- package/dist/components/nodes/NotesNode.svelte.d.ts +8 -4
- package/dist/components/nodes/SimpleNode.svelte +68 -137
- package/dist/components/nodes/SimpleNode.svelte.d.ts +4 -4
- package/dist/components/nodes/SquareNode.svelte +122 -169
- package/dist/components/nodes/SquareNode.svelte.d.ts +4 -4
- package/dist/components/nodes/TerminalNode.svelte +70 -127
- package/dist/components/nodes/TerminalNode.svelte.d.ts +4 -4
- package/dist/components/nodes/ToolNode.svelte +99 -104
- package/dist/components/nodes/ToolNode.svelte.d.ts +6 -6
- package/dist/components/nodes/WorkflowNode.svelte +145 -195
- package/dist/components/nodes/WorkflowNode.svelte.d.ts +1 -1
- package/dist/components/playground/ChatInput.svelte +11 -15
- package/dist/components/playground/ChatPanel.svelte +6 -49
- package/dist/components/playground/ChatPanel.svelte.d.ts +0 -14
- package/dist/components/playground/ControlPanel.svelte +134 -123
- package/dist/components/playground/ControlPanel.svelte.d.ts +3 -0
- package/dist/components/playground/ExecutionLogs.svelte +11 -9
- package/dist/components/playground/InputCollector.svelte +22 -57
- package/dist/components/playground/MessageStream.svelte +17 -23
- package/dist/components/playground/PipelineKanbanView.svelte +69 -8
- package/dist/components/playground/PipelineKanbanView.svelte.d.ts +2 -0
- package/dist/components/playground/PipelinePanel.svelte +31 -8
- package/dist/components/playground/PipelinePanel.svelte.d.ts +2 -0
- package/dist/components/playground/PipelineTableView.svelte +188 -44
- package/dist/components/playground/PipelineTableView.svelte.d.ts +2 -0
- package/dist/components/playground/Playground.svelte +154 -105
- package/dist/components/playground/Playground.svelte.d.ts +5 -0
- package/dist/components/playground/PlaygroundApp.svelte +12 -2
- package/dist/components/playground/PlaygroundApp.svelte.d.ts +6 -0
- package/dist/components/playground/PlaygroundModal.svelte +18 -3
- package/dist/components/playground/PlaygroundModal.svelte.d.ts +6 -0
- package/dist/components/playground/PlaygroundStudio.svelte +40 -37
- package/dist/components/playground/PlaygroundStudio.svelte.d.ts +6 -0
- package/dist/components/playground/SessionManager.svelte +9 -12
- package/dist/components/playground/pipelineViewUtils.svelte.d.ts +30 -1
- package/dist/components/playground/pipelineViewUtils.svelte.js +40 -3
- package/dist/components/surfaces/SurfaceOverlay.svelte +153 -0
- package/dist/components/surfaces/SurfaceOverlay.svelte.d.ts +14 -0
- package/dist/components/surfaces/TabbedSurface.svelte +133 -0
- package/dist/components/surfaces/TabbedSurface.svelte.d.ts +27 -0
- package/dist/config/endpoints.d.ts +23 -7
- package/dist/config/endpoints.js +30 -10
- package/dist/core/index.d.ts +6 -7
- package/dist/core/index.js +8 -12
- package/dist/display/index.d.ts +6 -3
- package/dist/display/index.js +7 -5
- package/dist/editor/index.d.ts +20 -21
- package/dist/editor/index.js +26 -36
- package/dist/form/code.d.ts +25 -15
- package/dist/form/code.js +44 -41
- package/dist/form/fieldRegistry.d.ts +17 -13
- package/dist/form/fieldRegistry.js +32 -12
- package/dist/form/full.d.ts +19 -14
- package/dist/form/full.js +26 -28
- package/dist/form/index.d.ts +3 -4
- package/dist/form/index.js +6 -5
- package/dist/form/markdown.d.ts +13 -8
- package/dist/form/markdown.js +22 -23
- package/dist/helpers/proximityConnect.d.ts +3 -2
- package/dist/helpers/proximityConnect.js +2 -5
- package/dist/helpers/workflowEditorHelper.d.ts +14 -5
- package/dist/helpers/workflowEditorHelper.js +32 -30
- package/dist/index.d.ts +28 -24
- package/dist/index.js +27 -50
- package/dist/messages/defaults.d.ts +2 -5
- package/dist/messages/defaults.js +3 -6
- package/dist/messages/index.d.ts +1 -2
- package/dist/messages/index.js +1 -2
- package/dist/mocks/app-forms.d.ts +6 -2
- package/dist/mocks/app-forms.js +11 -4
- package/dist/openapi/v1/openapi.yaml +38 -26
- package/dist/playground/index.d.ts +4 -5
- package/dist/playground/index.js +4 -32
- package/dist/playground/mount.d.ts +34 -5
- package/dist/playground/mount.js +58 -24
- package/dist/registry/{BaseRegistry.d.ts → BaseRegistry.svelte.d.ts} +22 -1
- package/dist/registry/{BaseRegistry.js → BaseRegistry.svelte.js} +37 -1
- package/dist/registry/builtinFormats.d.ts +9 -18
- package/dist/registry/builtinFormats.js +9 -39
- package/dist/registry/builtinNodeTypes.d.ts +53 -0
- package/dist/registry/builtinNodeTypes.js +67 -0
- package/dist/registry/builtinNodes.d.ts +2 -64
- package/dist/registry/builtinNodes.js +7 -103
- package/dist/registry/index.d.ts +3 -4
- package/dist/registry/index.js +4 -6
- package/dist/registry/nodeComponentRegistry.d.ts +184 -16
- package/dist/registry/nodeComponentRegistry.js +235 -17
- package/dist/registry/workflowFormatRegistry.d.ts +14 -9
- package/dist/registry/workflowFormatRegistry.js +24 -8
- package/dist/{schema → schemas}/index.d.ts +2 -2
- package/dist/{schema → schemas}/index.js +2 -2
- package/dist/schemas/v1/workflow.schema.json +19 -17
- package/dist/services/agentSpecExecutionService.d.ts +0 -2
- package/dist/services/agentSpecExecutionService.js +0 -3
- package/dist/services/apiVariableService.d.ts +2 -1
- package/dist/services/apiVariableService.js +16 -47
- package/dist/services/autoSaveService.d.ts +7 -0
- package/dist/services/autoSaveService.js +6 -4
- package/dist/services/categoriesApi.js +3 -6
- package/dist/services/chatService.d.ts +9 -4
- package/dist/services/chatService.js +23 -28
- package/dist/services/draftStorage.d.ts +129 -13
- package/dist/services/draftStorage.js +185 -37
- package/dist/services/dynamicSchemaService.d.ts +33 -5
- package/dist/services/dynamicSchemaService.js +67 -55
- package/dist/services/globalSave.d.ts +13 -12
- package/dist/services/globalSave.js +29 -51
- package/dist/services/historyService.d.ts +39 -11
- package/dist/services/historyService.js +60 -18
- package/dist/services/interruptService.d.ts +15 -9
- package/dist/services/interruptService.js +35 -37
- package/dist/services/nodeExecutionService.d.ts +18 -3
- package/dist/services/nodeExecutionService.js +71 -45
- package/dist/services/playgroundService.d.ts +16 -10
- package/dist/services/playgroundService.js +42 -43
- package/dist/services/portConfigApi.js +3 -6
- package/dist/services/settingsService.d.ts +9 -4
- package/dist/services/settingsService.js +23 -12
- package/dist/services/variableService.d.ts +2 -1
- package/dist/services/variableService.js +2 -2
- package/dist/services/workflowStorage.js +6 -6
- package/dist/skins/drafter.d.ts +30 -0
- package/dist/skins/drafter.js +198 -0
- package/dist/skins/index.d.ts +2 -1
- package/dist/skins/index.js +4 -2
- package/dist/stores/apiContext.d.ts +56 -0
- package/dist/stores/apiContext.js +80 -0
- package/dist/stores/categoriesStore.svelte.d.ts +28 -23
- package/dist/stores/categoriesStore.svelte.js +69 -64
- package/dist/stores/getInstance.svelte.d.ts +39 -0
- package/dist/stores/getInstance.svelte.js +65 -0
- package/dist/stores/historyStore.svelte.d.ts +89 -91
- package/dist/stores/historyStore.svelte.js +159 -158
- package/dist/stores/instanceContainer.svelte.d.ts +111 -0
- package/dist/stores/instanceContainer.svelte.js +119 -0
- package/dist/stores/interruptStore.svelte.d.ts +112 -82
- package/dist/stores/interruptStore.svelte.js +253 -226
- package/dist/stores/pipelinePanelStore.svelte.d.ts +27 -3
- package/dist/stores/pipelinePanelStore.svelte.js +61 -14
- package/dist/stores/playgroundStore.svelte.d.ts +169 -222
- package/dist/stores/playgroundStore.svelte.js +513 -580
- package/dist/stores/portCoordinateStore.svelte.d.ts +57 -51
- package/dist/stores/portCoordinateStore.svelte.js +109 -98
- package/dist/stores/settingsStore.svelte.d.ts +17 -1
- package/dist/stores/settingsStore.svelte.js +79 -12
- package/dist/stores/workflowStore.svelte.d.ts +212 -210
- package/dist/stores/workflowStore.svelte.js +527 -502
- package/dist/stories/EdgeDecorator.svelte +5 -2
- package/dist/stories/NodeDecorator.svelte +5 -3
- package/dist/styles/base.css +285 -14
- package/dist/styles/tokens.css +60 -2
- package/dist/svelte-app.d.ts +78 -11
- package/dist/svelte-app.js +210 -141
- package/dist/themes/drafter.d.ts +2 -0
- package/dist/themes/drafter.js +15 -0
- package/dist/themes/index.d.ts +2 -1
- package/dist/themes/index.js +8 -2
- package/dist/types/auth.d.ts +9 -51
- package/dist/types/auth.js +4 -54
- package/dist/types/events.d.ts +24 -3
- package/dist/types/events.js +2 -1
- package/dist/types/index.d.ts +117 -32
- package/dist/types/index.js +0 -1
- package/dist/types/navbar.d.ts +7 -0
- package/dist/types/playground.d.ts +18 -3
- package/dist/types/settings.d.ts +30 -1
- package/dist/types/settings.js +5 -2
- package/dist/types/skin.d.ts +1 -1
- package/dist/types/theme.d.ts +16 -2
- package/dist/types/uischema.d.ts +5 -0
- package/dist/utils/colors.d.ts +74 -21
- package/dist/utils/colors.js +92 -68
- package/dist/utils/connections.d.ts +9 -15
- package/dist/utils/connections.js +33 -88
- package/dist/utils/duration.d.ts +13 -0
- package/dist/utils/duration.js +45 -0
- package/dist/utils/edgeStyling.js +9 -5
- package/dist/utils/fetchWithAuth.d.ts +36 -15
- package/dist/utils/fetchWithAuth.js +53 -23
- package/dist/utils/icons.d.ts +5 -2
- package/dist/utils/icons.js +6 -5
- package/dist/utils/nodeIds.d.ts +1 -1
- package/dist/utils/nodeIds.js +1 -1
- package/dist/utils/nodeSwap.d.ts +6 -2
- package/dist/utils/nodeSwap.js +62 -129
- package/dist/utils/nodeTypes.d.ts +17 -8
- package/dist/utils/nodeTypes.js +27 -20
- package/dist/utils/performanceUtils.js +7 -0
- package/dist/utils/portUtils.d.ts +47 -11
- package/dist/utils/portUtils.js +67 -14
- package/dist/utils/portal.d.ts +18 -0
- package/dist/utils/portal.js +34 -0
- package/dist/utils/schemaMerge.d.ts +25 -0
- package/dist/utils/schemaMerge.js +61 -0
- package/package.json +7 -5
- package/dist/messages/deprecation.d.ts +0 -20
- package/dist/messages/deprecation.js +0 -33
- package/dist/registry/plugin.d.ts +0 -215
- package/dist/registry/plugin.js +0 -249
- package/dist/services/api.d.ts +0 -129
- package/dist/services/api.js +0 -217
|
@@ -18,6 +18,13 @@ import { logger } from '../utils/logger.js';
|
|
|
18
18
|
* a complete copy of the workflow state. This trades memory for simplicity
|
|
19
19
|
* and reliability.
|
|
20
20
|
*
|
|
21
|
+
* Snapshot model: the undo stack holds *committed* states, and its **top is the
|
|
22
|
+
* current live state**. `initialize()` seeds it with the starting state, and each
|
|
23
|
+
* mutation pushes the state *after* the change. One `undo()` moves the top back by
|
|
24
|
+
* exactly one committed change, and `redo()` restores the state that was undone.
|
|
25
|
+
* (Callers must push the post-change state — pushing pre-change snapshots makes a
|
|
26
|
+
* single undo skip a step once there are ≥2 sequential edits; see issue #39.)
|
|
27
|
+
*
|
|
21
28
|
* @example
|
|
22
29
|
* ```typescript
|
|
23
30
|
* const historyService = new HistoryService();
|
|
@@ -25,7 +32,7 @@ import { logger } from '../utils/logger.js';
|
|
|
25
32
|
* // Initialize with current workflow
|
|
26
33
|
* historyService.initialize(workflow);
|
|
27
34
|
*
|
|
28
|
-
* // Push state
|
|
35
|
+
* // Push state AFTER making changes (the new committed state)
|
|
29
36
|
* historyService.push(workflow, { description: "Add node" });
|
|
30
37
|
*
|
|
31
38
|
* // Undo/Redo
|
|
@@ -82,12 +89,13 @@ export class HistoryService {
|
|
|
82
89
|
this.notifyChange();
|
|
83
90
|
}
|
|
84
91
|
/**
|
|
85
|
-
* Push
|
|
92
|
+
* Push a new committed state to history
|
|
86
93
|
*
|
|
87
|
-
* Call this
|
|
94
|
+
* Call this AFTER modifying the workflow, with the resulting ("after") state:
|
|
95
|
+
* the stack top is the current live state, so one undo == one committed change.
|
|
88
96
|
* The redo stack is cleared when new changes are pushed.
|
|
89
97
|
*
|
|
90
|
-
* @param workflow - The
|
|
98
|
+
* @param workflow - The workflow state after the change
|
|
91
99
|
* @param options - Options for this history entry
|
|
92
100
|
*/
|
|
93
101
|
push(workflow, options = {}) {
|
|
@@ -109,6 +117,15 @@ export class HistoryService {
|
|
|
109
117
|
* @returns The previous workflow state, or null if cannot undo
|
|
110
118
|
*/
|
|
111
119
|
undo() {
|
|
120
|
+
// A transaction is the store's to finalize (it holds the live state), and it
|
|
121
|
+
// must do so BEFORE calling undo — the facade and command dispatch both
|
|
122
|
+
// finalize first, and the editor's blur commits earlier still. If one is
|
|
123
|
+
// still open here, the caller violated that contract; abandon it (rather than
|
|
124
|
+
// guess a snapshot to commit) so the flag can't wedge future pushes, and warn.
|
|
125
|
+
if (this.inTransaction) {
|
|
126
|
+
logger.warn('HistoryService: undo() called with an open transaction; finalize the edit session first. Abandoning it.');
|
|
127
|
+
this.clearTransaction();
|
|
128
|
+
}
|
|
112
129
|
// Need at least 2 entries to undo (initial + 1 change)
|
|
113
130
|
if (this.undoStack.length <= 1) {
|
|
114
131
|
return null;
|
|
@@ -131,6 +148,13 @@ export class HistoryService {
|
|
|
131
148
|
* @returns The next workflow state, or null if cannot redo
|
|
132
149
|
*/
|
|
133
150
|
redo() {
|
|
151
|
+
// Same contract as undo(): the caller must finalize any open edit session
|
|
152
|
+
// first. A dangling transaction here is a caller bug — abandon it and warn
|
|
153
|
+
// rather than committing a state we don't have.
|
|
154
|
+
if (this.inTransaction) {
|
|
155
|
+
logger.warn('HistoryService: redo() called with an open transaction; finalize the edit session first. Abandoning it.');
|
|
156
|
+
this.clearTransaction();
|
|
157
|
+
}
|
|
134
158
|
if (this.redoStack.length === 0) {
|
|
135
159
|
return null;
|
|
136
160
|
}
|
|
@@ -147,9 +171,13 @@ export class HistoryService {
|
|
|
147
171
|
* Start a transaction for grouping multiple changes
|
|
148
172
|
*
|
|
149
173
|
* All changes made during a transaction are combined into a single undo entry.
|
|
150
|
-
* Useful for operations like "delete node" which also removes connected edges
|
|
174
|
+
* Useful for operations like "delete node" which also removes connected edges,
|
|
175
|
+
* or coalescing a burst of live config edits into one step. While open, `push()`
|
|
176
|
+
* is suppressed; `commitTransaction()` records a single post-change entry.
|
|
151
177
|
*
|
|
152
|
-
* @param workflow - The current workflow state
|
|
178
|
+
* @param workflow - The current workflow state at transaction start. Retained so
|
|
179
|
+
* {@link cancelTransaction} can restore it; the committed entry is the *final*
|
|
180
|
+
* state passed to {@link commitTransaction}, not this snapshot.
|
|
153
181
|
* @param description - Description for the combined change
|
|
154
182
|
*/
|
|
155
183
|
startTransaction(workflow, description) {
|
|
@@ -164,19 +192,23 @@ export class HistoryService {
|
|
|
164
192
|
/**
|
|
165
193
|
* Commit the current transaction
|
|
166
194
|
*
|
|
167
|
-
*
|
|
195
|
+
* Records the transaction's *post-change* state as a single history entry, so
|
|
196
|
+
* one undo reverts the whole grouped operation and redo restores its result.
|
|
197
|
+
*
|
|
198
|
+
* The final state is required: the transaction's owner (the store) holds the
|
|
199
|
+
* live workflow and must supply it. There is deliberately no "commit whatever
|
|
200
|
+
* you captured at start" fallback — that would silently record a pre-change
|
|
201
|
+
* snapshot and reintroduce the off-by-one this model exists to prevent (#39).
|
|
202
|
+
*
|
|
203
|
+
* @param finalWorkflow - The workflow state after the grouped change.
|
|
168
204
|
*/
|
|
169
|
-
commitTransaction() {
|
|
205
|
+
commitTransaction(finalWorkflow) {
|
|
170
206
|
if (!this.inTransaction || !this.transactionSnapshot) {
|
|
171
207
|
logger.warn('HistoryService: No transaction in progress, ignoring commitTransaction');
|
|
172
208
|
return;
|
|
173
209
|
}
|
|
174
|
-
|
|
175
|
-
this.
|
|
176
|
-
// Clear transaction state
|
|
177
|
-
this.inTransaction = false;
|
|
178
|
-
this.transactionSnapshot = null;
|
|
179
|
-
this.transactionDescription = null;
|
|
210
|
+
this.pushInternal(finalWorkflow, this.transactionDescription ?? undefined);
|
|
211
|
+
this.clearTransaction();
|
|
180
212
|
}
|
|
181
213
|
/**
|
|
182
214
|
* Cancel the current transaction without committing
|
|
@@ -187,10 +219,14 @@ export class HistoryService {
|
|
|
187
219
|
*/
|
|
188
220
|
cancelTransaction() {
|
|
189
221
|
const snapshot = this.transactionSnapshot;
|
|
222
|
+
this.clearTransaction();
|
|
223
|
+
return snapshot;
|
|
224
|
+
}
|
|
225
|
+
/** Reset the in-progress transaction bookkeeping. */
|
|
226
|
+
clearTransaction() {
|
|
190
227
|
this.inTransaction = false;
|
|
191
228
|
this.transactionSnapshot = null;
|
|
192
229
|
this.transactionDescription = null;
|
|
193
|
-
return snapshot;
|
|
194
230
|
}
|
|
195
231
|
/**
|
|
196
232
|
* Clear all history
|
|
@@ -328,9 +364,15 @@ export class HistoryService {
|
|
|
328
364
|
// Singleton Instance
|
|
329
365
|
// =========================================================================
|
|
330
366
|
/**
|
|
331
|
-
*
|
|
367
|
+
* History service of the page-default FlowDrop instance.
|
|
368
|
+
*
|
|
369
|
+
* Kept as a module-level export for backward compatibility (re-exported via
|
|
370
|
+
* `@flowdrop/flowdrop/editor`) — `createFlowDropInstance({ isDefault: true })`
|
|
371
|
+
* adopts this exact object, so legacy `historyService.undo()` calls keep
|
|
372
|
+
* operating on the default editor's history stack. Holds no reactive state,
|
|
373
|
+
* so module-level construction is SSR-safe.
|
|
332
374
|
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
375
|
+
* For additional editor instances, the instance container creates a fresh
|
|
376
|
+
* `new HistoryService()` — use `getInstance().history` in components.
|
|
335
377
|
*/
|
|
336
378
|
export const historyService = new HistoryService();
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* @module services/interruptService
|
|
9
9
|
*/
|
|
10
10
|
import type { Interrupt, InterruptPollingConfig } from '../types/interrupt.js';
|
|
11
|
+
import type { EndpointConfig } from '../config/endpoints.js';
|
|
12
|
+
import type { AuthProvider } from '../types/auth.js';
|
|
11
13
|
/**
|
|
12
14
|
* Interrupt Service class
|
|
13
15
|
*
|
|
@@ -46,19 +48,23 @@ export declare class InterruptService {
|
|
|
46
48
|
/**
|
|
47
49
|
* Check if interrupt endpoints are configured
|
|
48
50
|
*
|
|
51
|
+
* @param config - The instance's endpoint configuration (from fd.api.config)
|
|
49
52
|
* @returns True if interrupt endpoints are available
|
|
50
53
|
*/
|
|
51
|
-
isConfigured(): boolean;
|
|
54
|
+
isConfigured(config: EndpointConfig | null): boolean;
|
|
52
55
|
/**
|
|
53
|
-
*
|
|
56
|
+
* Validate and return the caller-supplied endpoint configuration.
|
|
54
57
|
*
|
|
55
|
-
*
|
|
58
|
+
* Callers thread the config from `getInstance().api.config`.
|
|
59
|
+
*
|
|
60
|
+
* @throws Error if endpoint configuration is not set or lacks interrupts
|
|
56
61
|
* @returns The endpoint configuration
|
|
57
62
|
*/
|
|
58
63
|
private getConfig;
|
|
59
64
|
/**
|
|
60
65
|
* Generic API request helper
|
|
61
66
|
*
|
|
67
|
+
* @param config - The endpoint configuration
|
|
62
68
|
* @param url - The URL to fetch
|
|
63
69
|
* @param options - Fetch options
|
|
64
70
|
* @returns The parsed JSON response
|
|
@@ -70,7 +76,7 @@ export declare class InterruptService {
|
|
|
70
76
|
* @param interruptId - The interrupt UUID
|
|
71
77
|
* @returns The interrupt details
|
|
72
78
|
*/
|
|
73
|
-
getInterrupt(interruptId: string): Promise<Interrupt>;
|
|
79
|
+
getInterrupt(endpointConfig: EndpointConfig | null, interruptId: string, authProvider?: AuthProvider): Promise<Interrupt>;
|
|
74
80
|
/**
|
|
75
81
|
* Resolve an interrupt with user response
|
|
76
82
|
*
|
|
@@ -78,28 +84,28 @@ export declare class InterruptService {
|
|
|
78
84
|
* @param value - The user's response value
|
|
79
85
|
* @returns The updated interrupt
|
|
80
86
|
*/
|
|
81
|
-
resolveInterrupt(interruptId: string, value: unknown): Promise<Interrupt>;
|
|
87
|
+
resolveInterrupt(endpointConfig: EndpointConfig | null, interruptId: string, value: unknown, authProvider?: AuthProvider): Promise<Interrupt>;
|
|
82
88
|
/**
|
|
83
89
|
* Cancel a pending interrupt
|
|
84
90
|
*
|
|
85
91
|
* @param interruptId - The interrupt UUID
|
|
86
92
|
* @returns The updated interrupt
|
|
87
93
|
*/
|
|
88
|
-
cancelInterrupt(interruptId: string): Promise<Interrupt>;
|
|
94
|
+
cancelInterrupt(endpointConfig: EndpointConfig | null, interruptId: string, authProvider?: AuthProvider): Promise<Interrupt>;
|
|
89
95
|
/**
|
|
90
96
|
* List interrupts for a playground session
|
|
91
97
|
*
|
|
92
98
|
* @param sessionId - The session UUID
|
|
93
99
|
* @returns Array of interrupts for the session
|
|
94
100
|
*/
|
|
95
|
-
listSessionInterrupts(sessionId: string): Promise<Interrupt[]>;
|
|
101
|
+
listSessionInterrupts(endpointConfig: EndpointConfig | null, sessionId: string, authProvider?: AuthProvider): Promise<Interrupt[]>;
|
|
96
102
|
/**
|
|
97
103
|
* List interrupts for a pipeline
|
|
98
104
|
*
|
|
99
105
|
* @param pipelineId - The pipeline UUID
|
|
100
106
|
* @returns Array of interrupts for the pipeline
|
|
101
107
|
*/
|
|
102
|
-
listPipelineInterrupts(pipelineId: string): Promise<Interrupt[]>;
|
|
108
|
+
listPipelineInterrupts(endpointConfig: EndpointConfig | null, pipelineId: string, authProvider?: AuthProvider): Promise<Interrupt[]>;
|
|
103
109
|
/**
|
|
104
110
|
* Start polling for interrupts in a session
|
|
105
111
|
*
|
|
@@ -109,7 +115,7 @@ export declare class InterruptService {
|
|
|
109
115
|
* @param sessionId - The session UUID to poll
|
|
110
116
|
* @param callback - Callback function to handle new interrupts
|
|
111
117
|
*/
|
|
112
|
-
startPolling(sessionId: string, callback: (interrupts: Interrupt[]) => void): void;
|
|
118
|
+
startPolling(endpointConfig: EndpointConfig | null, sessionId: string, callback: (interrupts: Interrupt[]) => void, authProvider?: AuthProvider): void;
|
|
113
119
|
/**
|
|
114
120
|
* Stop polling for interrupts
|
|
115
121
|
*/
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* @module services/interruptService
|
|
9
9
|
*/
|
|
10
10
|
import { defaultInterruptPollingConfig } from '../types/interrupt.js';
|
|
11
|
-
import { buildEndpointUrl
|
|
12
|
-
import {
|
|
11
|
+
import { buildEndpointUrl } from '../config/endpoints.js';
|
|
12
|
+
import { authenticatedFetch } from '../utils/fetchWithAuth.js';
|
|
13
13
|
import { logger } from '../utils/logger.js';
|
|
14
14
|
/**
|
|
15
15
|
* Interrupt Service class
|
|
@@ -62,22 +62,23 @@ export class InterruptService {
|
|
|
62
62
|
/**
|
|
63
63
|
* Check if interrupt endpoints are configured
|
|
64
64
|
*
|
|
65
|
+
* @param config - The instance's endpoint configuration (from fd.api.config)
|
|
65
66
|
* @returns True if interrupt endpoints are available
|
|
66
67
|
*/
|
|
67
|
-
isConfigured() {
|
|
68
|
-
const config = getEndpointConfig();
|
|
68
|
+
isConfigured(config) {
|
|
69
69
|
return Boolean(config?.endpoints?.interrupts);
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* Validate and return the caller-supplied endpoint configuration.
|
|
73
73
|
*
|
|
74
|
-
*
|
|
74
|
+
* Callers thread the config from `getInstance().api.config`.
|
|
75
|
+
*
|
|
76
|
+
* @throws Error if endpoint configuration is not set or lacks interrupts
|
|
75
77
|
* @returns The endpoint configuration
|
|
76
78
|
*/
|
|
77
|
-
getConfig() {
|
|
78
|
-
const config = getEndpointConfig();
|
|
79
|
+
getConfig(config) {
|
|
79
80
|
if (!config) {
|
|
80
|
-
throw new Error('Endpoint configuration not set.
|
|
81
|
+
throw new Error('Endpoint configuration not set. Configure the instance via fd.api.configure().');
|
|
81
82
|
}
|
|
82
83
|
if (!config.endpoints.interrupts) {
|
|
83
84
|
throw new Error('Interrupt endpoints not configured.');
|
|
@@ -87,19 +88,16 @@ export class InterruptService {
|
|
|
87
88
|
/**
|
|
88
89
|
* Generic API request helper
|
|
89
90
|
*
|
|
91
|
+
* @param config - The endpoint configuration
|
|
90
92
|
* @param url - The URL to fetch
|
|
91
93
|
* @param options - Fetch options
|
|
92
94
|
* @returns The parsed JSON response
|
|
93
95
|
*/
|
|
94
|
-
async request(url, options = {}) {
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
headers: {
|
|
100
|
-
...headers,
|
|
101
|
-
...options.headers
|
|
102
|
-
}
|
|
96
|
+
async request(config, url, options = {}, authProvider) {
|
|
97
|
+
const response = await authenticatedFetch(url, options, {
|
|
98
|
+
config,
|
|
99
|
+
endpointKey: 'interrupts',
|
|
100
|
+
authProvider
|
|
103
101
|
});
|
|
104
102
|
if (!response.ok) {
|
|
105
103
|
const errorData = await response.json().catch(() => ({}));
|
|
@@ -119,12 +117,12 @@ export class InterruptService {
|
|
|
119
117
|
* @param interruptId - The interrupt UUID
|
|
120
118
|
* @returns The interrupt details
|
|
121
119
|
*/
|
|
122
|
-
async getInterrupt(interruptId) {
|
|
123
|
-
const config = this.getConfig();
|
|
120
|
+
async getInterrupt(endpointConfig, interruptId, authProvider) {
|
|
121
|
+
const config = this.getConfig(endpointConfig);
|
|
124
122
|
const url = buildEndpointUrl(config, config.endpoints.interrupts.get, {
|
|
125
123
|
interruptId
|
|
126
124
|
});
|
|
127
|
-
const response = await this.request(url);
|
|
125
|
+
const response = await this.request(config, url, {}, authProvider);
|
|
128
126
|
if (!response.data) {
|
|
129
127
|
throw new Error('Interrupt not found');
|
|
130
128
|
}
|
|
@@ -137,16 +135,16 @@ export class InterruptService {
|
|
|
137
135
|
* @param value - The user's response value
|
|
138
136
|
* @returns The updated interrupt
|
|
139
137
|
*/
|
|
140
|
-
async resolveInterrupt(interruptId, value) {
|
|
141
|
-
const config = this.getConfig();
|
|
138
|
+
async resolveInterrupt(endpointConfig, interruptId, value, authProvider) {
|
|
139
|
+
const config = this.getConfig(endpointConfig);
|
|
142
140
|
const url = buildEndpointUrl(config, config.endpoints.interrupts.resolve, {
|
|
143
141
|
interruptId
|
|
144
142
|
});
|
|
145
143
|
const resolution = { value };
|
|
146
|
-
const response = await this.request(url, {
|
|
144
|
+
const response = await this.request(config, url, {
|
|
147
145
|
method: 'POST',
|
|
148
146
|
body: JSON.stringify(resolution)
|
|
149
|
-
});
|
|
147
|
+
}, authProvider);
|
|
150
148
|
if (!response.data) {
|
|
151
149
|
throw new Error('Failed to resolve interrupt: No data returned');
|
|
152
150
|
}
|
|
@@ -158,14 +156,14 @@ export class InterruptService {
|
|
|
158
156
|
* @param interruptId - The interrupt UUID
|
|
159
157
|
* @returns The updated interrupt
|
|
160
158
|
*/
|
|
161
|
-
async cancelInterrupt(interruptId) {
|
|
162
|
-
const config = this.getConfig();
|
|
159
|
+
async cancelInterrupt(endpointConfig, interruptId, authProvider) {
|
|
160
|
+
const config = this.getConfig(endpointConfig);
|
|
163
161
|
const url = buildEndpointUrl(config, config.endpoints.interrupts.cancel, {
|
|
164
162
|
interruptId
|
|
165
163
|
});
|
|
166
|
-
const response = await this.request(url, {
|
|
164
|
+
const response = await this.request(config, url, {
|
|
167
165
|
method: 'POST'
|
|
168
|
-
});
|
|
166
|
+
}, authProvider);
|
|
169
167
|
if (!response.data) {
|
|
170
168
|
throw new Error('Failed to cancel interrupt: No data returned');
|
|
171
169
|
}
|
|
@@ -177,12 +175,12 @@ export class InterruptService {
|
|
|
177
175
|
* @param sessionId - The session UUID
|
|
178
176
|
* @returns Array of interrupts for the session
|
|
179
177
|
*/
|
|
180
|
-
async listSessionInterrupts(sessionId) {
|
|
181
|
-
const config = this.getConfig();
|
|
178
|
+
async listSessionInterrupts(endpointConfig, sessionId, authProvider) {
|
|
179
|
+
const config = this.getConfig(endpointConfig);
|
|
182
180
|
const url = buildEndpointUrl(config, config.endpoints.interrupts.listBySession, {
|
|
183
181
|
sessionId
|
|
184
182
|
});
|
|
185
|
-
const response = await this.request(url);
|
|
183
|
+
const response = await this.request(config, url, {}, authProvider);
|
|
186
184
|
return response.data ?? [];
|
|
187
185
|
}
|
|
188
186
|
/**
|
|
@@ -191,12 +189,12 @@ export class InterruptService {
|
|
|
191
189
|
* @param pipelineId - The pipeline UUID
|
|
192
190
|
* @returns Array of interrupts for the pipeline
|
|
193
191
|
*/
|
|
194
|
-
async listPipelineInterrupts(pipelineId) {
|
|
195
|
-
const config = this.getConfig();
|
|
192
|
+
async listPipelineInterrupts(endpointConfig, pipelineId, authProvider) {
|
|
193
|
+
const config = this.getConfig(endpointConfig);
|
|
196
194
|
const url = buildEndpointUrl(config, config.endpoints.interrupts.listByPipeline, {
|
|
197
195
|
pipelineId
|
|
198
196
|
});
|
|
199
|
-
const response = await this.request(url);
|
|
197
|
+
const response = await this.request(config, url, {}, authProvider);
|
|
200
198
|
return response.data ?? [];
|
|
201
199
|
}
|
|
202
200
|
// =========================================================================
|
|
@@ -211,7 +209,7 @@ export class InterruptService {
|
|
|
211
209
|
* @param sessionId - The session UUID to poll
|
|
212
210
|
* @param callback - Callback function to handle new interrupts
|
|
213
211
|
*/
|
|
214
|
-
startPolling(sessionId, callback) {
|
|
212
|
+
startPolling(endpointConfig, sessionId, callback, authProvider) {
|
|
215
213
|
if (!this.pollingConfig.enabled) {
|
|
216
214
|
logger.warn('[InterruptService] Polling is disabled. Enable via setPollingConfig().');
|
|
217
215
|
return;
|
|
@@ -225,7 +223,7 @@ export class InterruptService {
|
|
|
225
223
|
return;
|
|
226
224
|
}
|
|
227
225
|
try {
|
|
228
|
-
const interrupts = await this.listSessionInterrupts(sessionId);
|
|
226
|
+
const interrupts = await this.listSessionInterrupts(endpointConfig, sessionId, authProvider);
|
|
229
227
|
const pendingInterrupts = interrupts.filter((i) => i.status === 'pending');
|
|
230
228
|
// Reset backoff on successful request
|
|
231
229
|
this.currentBackoff = this.pollingConfig.interval ?? defaultInterruptPollingConfig.interval;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Handles fetching and managing node execution information from the backend
|
|
4
4
|
*/
|
|
5
5
|
import type { NodeExecutionInfo } from '../types/index.js';
|
|
6
|
+
import type { EndpointConfig } from '../config/endpoints.js';
|
|
6
7
|
/**
|
|
7
8
|
* Service for managing node execution information
|
|
8
9
|
*/
|
|
@@ -18,15 +19,15 @@ export declare class NodeExecutionService {
|
|
|
18
19
|
/**
|
|
19
20
|
* Get execution information for a specific node from pipeline data
|
|
20
21
|
*/
|
|
21
|
-
getNodeExecutionInfo(nodeId: string, pipelineId?: string): Promise<NodeExecutionInfo | null>;
|
|
22
|
+
getNodeExecutionInfo(endpointConfig: EndpointConfig | null, nodeId: string, pipelineId?: string): Promise<NodeExecutionInfo | null>;
|
|
22
23
|
/**
|
|
23
24
|
* Get execution information for multiple nodes from pipeline data
|
|
24
25
|
*/
|
|
25
|
-
getMultipleNodeExecutionInfo(nodeIds: string[], pipelineId?: string): Promise<Record<string, NodeExecutionInfo>>;
|
|
26
|
+
getMultipleNodeExecutionInfo(endpointConfig: EndpointConfig | null, nodeIds: string[], pipelineId?: string): Promise<Record<string, NodeExecutionInfo>>;
|
|
26
27
|
/**
|
|
27
28
|
* Get all node execution counts
|
|
28
29
|
*/
|
|
29
|
-
getAllNodeExecutionCounts(): Promise<Record<string, number>>;
|
|
30
|
+
getAllNodeExecutionCounts(endpointConfig: EndpointConfig | null): Promise<Record<string, number>>;
|
|
30
31
|
/**
|
|
31
32
|
* Get cached execution info for a node
|
|
32
33
|
*/
|
|
@@ -47,6 +48,20 @@ export declare class NodeExecutionService {
|
|
|
47
48
|
* Update execution info for a node (for real-time updates)
|
|
48
49
|
*/
|
|
49
50
|
updateNodeExecutionInfo(nodeId: string, executionInfo: Partial<NodeExecutionInfo>): void;
|
|
51
|
+
/**
|
|
52
|
+
* Build execution info for one node from the pipeline payload.
|
|
53
|
+
*
|
|
54
|
+
* The `node_statuses` entry is the backend-resolved summary (latest job's
|
|
55
|
+
* status, timing from the most recent run, `executions` count); the per-job
|
|
56
|
+
* history is attached from the `jobs` array so loop iterations stay
|
|
57
|
+
* inspectable. Falls back to the node's jobs when no entry exists (older
|
|
58
|
+
* backends).
|
|
59
|
+
*/
|
|
60
|
+
private buildNodeExecutionInfo;
|
|
61
|
+
/**
|
|
62
|
+
* Map a pipeline job payload entry to a NodeJobExecution history item.
|
|
63
|
+
*/
|
|
64
|
+
private mapJobToNodeJobExecution;
|
|
50
65
|
/**
|
|
51
66
|
* Map job status to execution status
|
|
52
67
|
*/
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Node Execution Service
|
|
3
3
|
* Handles fetching and managing node execution information from the backend
|
|
4
4
|
*/
|
|
5
|
-
import { getEndpointConfig } from './api.js';
|
|
6
5
|
import { buildEndpointUrl } from '../config/endpoints.js';
|
|
7
6
|
import { NODE_EXECUTION_CACHE_TIMEOUT_MS, PIPELINE_API_UNAVAILABLE_DURATION_MS } from '../config/constants.js';
|
|
8
7
|
import { logger } from '../utils/logger.js';
|
|
@@ -26,12 +25,11 @@ export class NodeExecutionService {
|
|
|
26
25
|
/**
|
|
27
26
|
* Get execution information for a specific node from pipeline data
|
|
28
27
|
*/
|
|
29
|
-
async getNodeExecutionInfo(nodeId, pipelineId) {
|
|
28
|
+
async getNodeExecutionInfo(endpointConfig, nodeId, pipelineId) {
|
|
30
29
|
if (!pipelineId) {
|
|
31
30
|
return null;
|
|
32
31
|
}
|
|
33
32
|
try {
|
|
34
|
-
const endpointConfig = getEndpointConfig();
|
|
35
33
|
if (!endpointConfig)
|
|
36
34
|
throw new Error('Endpoint config not available');
|
|
37
35
|
const url = buildEndpointUrl(endpointConfig, endpointConfig.endpoints.pipelines.get, {
|
|
@@ -45,24 +43,7 @@ export class NodeExecutionService {
|
|
|
45
43
|
const pipelineData = raw.data ?? raw;
|
|
46
44
|
const jobs = pipelineData.jobs || [];
|
|
47
45
|
const nodeStatuses = pipelineData.node_statuses || {};
|
|
48
|
-
|
|
49
|
-
const nodeJob = jobs.find((job) => job.node_id === nodeId);
|
|
50
|
-
const nodeStatus = nodeStatuses[nodeId];
|
|
51
|
-
if (!nodeJob && !nodeStatus) {
|
|
52
|
-
return {
|
|
53
|
-
status: 'idle',
|
|
54
|
-
executionCount: 0,
|
|
55
|
-
isExecuting: false
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
const executionInfo = {
|
|
59
|
-
status: this.mapJobStatusToExecutionStatus(nodeStatus?.status || nodeJob?.status || 'idle'),
|
|
60
|
-
executionCount: nodeJob?.execution_count || 0,
|
|
61
|
-
isExecuting: nodeStatus?.status === 'running' || nodeJob?.status === 'running',
|
|
62
|
-
lastExecuted: nodeJob?.last_executed || nodeStatus?.last_executed,
|
|
63
|
-
lastExecutionDuration: nodeJob?.execution_time || nodeStatus?.execution_time,
|
|
64
|
-
lastError: nodeJob?.error || nodeStatus?.error
|
|
65
|
-
};
|
|
46
|
+
const executionInfo = this.buildNodeExecutionInfo(nodeId, nodeStatuses[nodeId], jobs);
|
|
66
47
|
this.cache.set(nodeId, executionInfo);
|
|
67
48
|
return executionInfo;
|
|
68
49
|
}
|
|
@@ -74,7 +55,7 @@ export class NodeExecutionService {
|
|
|
74
55
|
/**
|
|
75
56
|
* Get execution information for multiple nodes from pipeline data
|
|
76
57
|
*/
|
|
77
|
-
async getMultipleNodeExecutionInfo(nodeIds, pipelineId) {
|
|
58
|
+
async getMultipleNodeExecutionInfo(endpointConfig, nodeIds, pipelineId) {
|
|
78
59
|
if (!pipelineId) {
|
|
79
60
|
return {};
|
|
80
61
|
}
|
|
@@ -91,7 +72,6 @@ export class NodeExecutionService {
|
|
|
91
72
|
return defaultExecutionInfo;
|
|
92
73
|
}
|
|
93
74
|
try {
|
|
94
|
-
const endpointConfig = getEndpointConfig();
|
|
95
75
|
if (!endpointConfig)
|
|
96
76
|
throw new Error('Endpoint config not available');
|
|
97
77
|
const url = buildEndpointUrl(endpointConfig, endpointConfig.endpoints.pipelines.get, {
|
|
@@ -120,28 +100,11 @@ export class NodeExecutionService {
|
|
|
120
100
|
const raw = await response.json();
|
|
121
101
|
const result = raw.data ?? raw;
|
|
122
102
|
const jobs = result.jobs || [];
|
|
103
|
+
const nodeStatuses = result.node_statuses || {};
|
|
123
104
|
const executionInfoMap = {};
|
|
124
|
-
// Initialize all nodes with default values
|
|
125
105
|
nodeIds.forEach((nodeId) => {
|
|
126
|
-
executionInfoMap[nodeId] =
|
|
127
|
-
|
|
128
|
-
executionCount: 0,
|
|
129
|
-
isExecuting: false
|
|
130
|
-
};
|
|
131
|
-
});
|
|
132
|
-
// Update with actual job data
|
|
133
|
-
jobs.forEach((job) => {
|
|
134
|
-
const nodeId = job.node_id;
|
|
135
|
-
if (nodeIds.includes(nodeId)) {
|
|
136
|
-
executionInfoMap[nodeId] = {
|
|
137
|
-
status: this.mapJobStatusToExecutionStatus(job.status),
|
|
138
|
-
executionCount: job.execution_count || 0,
|
|
139
|
-
isExecuting: job.status === 'running',
|
|
140
|
-
lastExecuted: job.completed || job.started,
|
|
141
|
-
lastExecutionDuration: job.execution_time,
|
|
142
|
-
lastError: job.error_message
|
|
143
|
-
};
|
|
144
|
-
// Update cache
|
|
106
|
+
executionInfoMap[nodeId] = this.buildNodeExecutionInfo(nodeId, nodeStatuses[nodeId], jobs);
|
|
107
|
+
if (executionInfoMap[nodeId].status !== 'idle' || executionInfoMap[nodeId].jobs) {
|
|
145
108
|
this.cache.set(nodeId, executionInfoMap[nodeId]);
|
|
146
109
|
}
|
|
147
110
|
});
|
|
@@ -164,9 +127,8 @@ export class NodeExecutionService {
|
|
|
164
127
|
/**
|
|
165
128
|
* Get all node execution counts
|
|
166
129
|
*/
|
|
167
|
-
async getAllNodeExecutionCounts() {
|
|
130
|
+
async getAllNodeExecutionCounts(endpointConfig) {
|
|
168
131
|
try {
|
|
169
|
-
const endpointConfig = getEndpointConfig();
|
|
170
132
|
if (!endpointConfig)
|
|
171
133
|
throw new Error('Endpoint config not available');
|
|
172
134
|
const url = buildEndpointUrl(endpointConfig, '/node-execution-counts');
|
|
@@ -227,6 +189,66 @@ export class NodeExecutionService {
|
|
|
227
189
|
});
|
|
228
190
|
}
|
|
229
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* Build execution info for one node from the pipeline payload.
|
|
194
|
+
*
|
|
195
|
+
* The `node_statuses` entry is the backend-resolved summary (latest job's
|
|
196
|
+
* status, timing from the most recent run, `executions` count); the per-job
|
|
197
|
+
* history is attached from the `jobs` array so loop iterations stay
|
|
198
|
+
* inspectable. Falls back to the node's jobs when no entry exists (older
|
|
199
|
+
* backends).
|
|
200
|
+
*/
|
|
201
|
+
buildNodeExecutionInfo(nodeId, entry, jobs) {
|
|
202
|
+
const nodeJobs = jobs.filter((job) => job.node_id === nodeId);
|
|
203
|
+
if (!entry && nodeJobs.length === 0) {
|
|
204
|
+
return {
|
|
205
|
+
status: 'idle',
|
|
206
|
+
executionCount: 0,
|
|
207
|
+
isExecuting: false
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
// Fallback for payloads without a node_statuses entry: the last job in
|
|
211
|
+
// pipeline order mirrors the backend's latest-wins resolution.
|
|
212
|
+
const lastJob = nodeJobs[nodeJobs.length - 1];
|
|
213
|
+
const status = entry?.status ?? lastJob?.status ?? 'idle';
|
|
214
|
+
const startedCount = nodeJobs.filter((job) => job.started).length;
|
|
215
|
+
const executionInfo = {
|
|
216
|
+
status: this.mapJobStatusToExecutionStatus(status),
|
|
217
|
+
executionCount: entry?.executions ?? startedCount,
|
|
218
|
+
isExecuting: status === 'running' || nodeJobs.some((job) => job.status === 'running'),
|
|
219
|
+
lastExecuted: entry?.last_executed ?? lastJob?.completed ?? lastJob?.started ?? undefined,
|
|
220
|
+
lastExecutionDuration: entry?.execution_time ?? lastJob?.execution_time ?? undefined,
|
|
221
|
+
lastExecutionDurationUs: entry?.execution_time_us ?? lastJob?.execution_time_us ?? undefined,
|
|
222
|
+
lastError: entry?.error ?? lastJob?.error_message ?? undefined
|
|
223
|
+
};
|
|
224
|
+
if (nodeJobs.length > 0) {
|
|
225
|
+
executionInfo.jobs = nodeJobs.map((job) => this.mapJobToNodeJobExecution(job));
|
|
226
|
+
}
|
|
227
|
+
return executionInfo;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Map a pipeline job payload entry to a NodeJobExecution history item.
|
|
231
|
+
*/
|
|
232
|
+
mapJobToNodeJobExecution(job) {
|
|
233
|
+
let executionTime = job.execution_time;
|
|
234
|
+
if (executionTime == null && job.started && job.completed) {
|
|
235
|
+
const started = Date.parse(job.started);
|
|
236
|
+
const completed = Date.parse(job.completed);
|
|
237
|
+
if (!Number.isNaN(started) && !Number.isNaN(completed)) {
|
|
238
|
+
executionTime = completed - started;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return {
|
|
242
|
+
id: job.id,
|
|
243
|
+
label: job.label,
|
|
244
|
+
status: this.mapJobStatusToExecutionStatus(job.status),
|
|
245
|
+
started: job.started,
|
|
246
|
+
completed: job.completed,
|
|
247
|
+
executionTime,
|
|
248
|
+
executionTimeUs: job.execution_time_us ?? (executionTime != null ? executionTime * 1000 : undefined),
|
|
249
|
+
error: job.error_message ?? job.error
|
|
250
|
+
};
|
|
251
|
+
}
|
|
230
252
|
/**
|
|
231
253
|
* Map job status to execution status
|
|
232
254
|
*/
|
|
@@ -244,6 +266,10 @@ export class NodeExecutionService {
|
|
|
244
266
|
return 'cancelled';
|
|
245
267
|
case 'skipped':
|
|
246
268
|
return 'skipped';
|
|
269
|
+
case 'paused':
|
|
270
|
+
return 'paused';
|
|
271
|
+
case 'interrupted':
|
|
272
|
+
return 'interrupted';
|
|
247
273
|
default:
|
|
248
274
|
return 'idle';
|
|
249
275
|
}
|