@flowdrop/flowdrop 1.14.0 → 2.0.0-beta.1
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 +475 -0
- package/MIGRATION-2.0.md +472 -0
- package/README.md +23 -23
- package/dist/adapters/WorkflowAdapter.d.ts +1 -1
- package/dist/adapters/WorkflowAdapter.js +14 -8
- package/dist/adapters/agentspec/AgentSpecAdapter.js +7 -7
- package/dist/chat/batchFeedback.d.ts +39 -0
- package/dist/chat/batchFeedback.js +51 -0
- package/dist/commands/executor.js +15 -1
- package/dist/commands/storeIntegration.svelte.d.ts +4 -1
- package/dist/commands/storeIntegration.svelte.js +26 -21
- package/dist/commands/types.d.ts +2 -0
- package/dist/components/App.svelte +162 -192
- package/dist/components/App.svelte.d.ts +47 -8
- package/dist/components/ConfigForm.svelte +110 -66
- package/dist/components/ConfigModal.svelte +7 -2
- package/dist/components/ConnectionLine.svelte +4 -2
- package/dist/components/Navbar.svelte +61 -1
- package/dist/components/NodeSidebar.svelte +27 -45
- package/dist/components/NodeStatusOverlay.svelte +94 -6
- package/dist/components/NodeSwapPicker.svelte +10 -8
- package/dist/components/PipelineStatus.svelte +16 -67
- package/dist/components/PortCoordinateTracker.svelte +5 -6
- package/dist/components/SchemaForm.stories.svelte +1 -3
- package/dist/components/SchemaForm.svelte +45 -40
- package/dist/components/SchemaForm.svelte.d.ts +0 -8
- package/dist/components/SettingsModal.svelte +8 -3
- package/dist/components/SettingsPanel.svelte +20 -4
- package/dist/components/SwapMappingEditor.svelte +67 -49
- package/dist/components/SwapMappingEditor.svelte.d.ts +0 -2
- package/dist/components/UniversalNode.svelte +9 -7
- package/dist/components/WorkflowEditor.svelte +118 -111
- package/dist/components/WorkflowEditor.svelte.d.ts +18 -10
- package/dist/components/chat/AIChatPanel.svelte +93 -89
- 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 +10 -11
- package/dist/components/console/ConsoleAutocomplete.svelte.d.ts +6 -0
- package/dist/components/console/ConsoleInput.svelte +15 -6
- package/dist/components/console/ConsoleOutput.svelte +2 -1
- package/dist/components/form/FormArray.svelte +5 -9
- package/dist/components/form/FormArray.svelte.d.ts +2 -1
- package/dist/components/form/FormAutocomplete.svelte +29 -13
- package/dist/components/form/FormField.svelte +4 -2
- package/dist/components/form/FormFieldLight.svelte +4 -2
- package/dist/components/form/FormMarkdownEditor.svelte +9 -4
- package/dist/components/form/FormRangeField.svelte +1 -0
- package/dist/components/form/FormTemplateEditor.svelte +11 -3
- package/dist/components/form/FormToggle.svelte +5 -12
- package/dist/components/form/FormToggle.svelte.d.ts +4 -2
- package/dist/components/form/templateAutocomplete.js +1 -5
- package/dist/components/form/types.d.ts +1 -14
- package/dist/components/interrupt/FormPrompt.svelte +3 -2
- package/dist/components/interrupt/InterruptBubble.svelte +16 -17
- package/dist/components/interrupt/ReviewPrompt.svelte +10 -3
- package/dist/components/interrupt/TextInputPrompt.svelte +2 -1
- package/dist/components/layouts/MainLayout.svelte +20 -13
- package/dist/components/layouts/MainLayout.svelte.d.ts +4 -0
- package/dist/components/nodes/AtomNode.svelte +292 -0
- package/dist/components/nodes/AtomNode.svelte.d.ts +26 -0
- package/dist/components/nodes/GatewayNode.svelte +19 -10
- package/dist/components/nodes/IdeaNode.svelte +7 -0
- package/dist/components/nodes/SimpleNode.svelte +11 -6
- package/dist/components/nodes/SquareNode.svelte +15 -8
- package/dist/components/nodes/TerminalNode.svelte +9 -4
- package/dist/components/nodes/ToolNode.svelte +7 -1
- package/dist/components/nodes/WorkflowNode.svelte +16 -7
- package/dist/components/playground/ChatInput.svelte +11 -14
- 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 +11 -9
- package/dist/components/playground/MessageStream.svelte +17 -23
- package/dist/components/playground/PipelineKanbanView.svelte +65 -6
- package/dist/components/playground/PipelinePanel.svelte +11 -5
- package/dist/components/playground/PipelineTableView.svelte +186 -44
- package/dist/components/playground/Playground.svelte +95 -92
- package/dist/components/playground/Playground.svelte.d.ts +2 -0
- package/dist/components/playground/PlaygroundApp.svelte +6 -1
- package/dist/components/playground/PlaygroundApp.svelte.d.ts +3 -0
- package/dist/components/playground/PlaygroundModal.svelte +13 -3
- package/dist/components/playground/PlaygroundModal.svelte.d.ts +3 -0
- package/dist/components/playground/PlaygroundStudio.svelte +34 -32
- package/dist/components/playground/PlaygroundStudio.svelte.d.ts +3 -0
- package/dist/components/playground/SessionManager.svelte +9 -12
- package/dist/components/playground/pipelineViewUtils.svelte.d.ts +28 -0
- package/dist/components/playground/pipelineViewUtils.svelte.js +38 -1
- package/dist/config/endpoints.d.ts +0 -7
- package/dist/config/endpoints.js +2 -10
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +6 -6
- package/dist/display/index.d.ts +0 -2
- package/dist/display/index.js +0 -6
- package/dist/editor/index.d.ts +19 -20
- package/dist/editor/index.js +25 -35
- 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 +17 -13
- package/dist/form/full.js +22 -27
- package/dist/form/index.d.ts +3 -3
- package/dist/form/index.js +3 -3
- package/dist/form/markdown.d.ts +13 -8
- package/dist/form/markdown.js +22 -23
- package/dist/helpers/proximityConnect.d.ts +7 -3
- package/dist/helpers/proximityConnect.js +19 -6
- package/dist/helpers/workflowEditorHelper.d.ts +12 -5
- package/dist/helpers/workflowEditorHelper.js +27 -25
- 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 +0 -1
- package/dist/messages/index.js +0 -1
- package/dist/mocks/app-forms.d.ts +6 -2
- package/dist/mocks/app-forms.js +11 -4
- package/dist/openapi/v1/openapi.yaml +227 -164
- package/dist/playground/index.d.ts +2 -3
- package/dist/playground/index.js +2 -30
- package/dist/playground/mount.d.ts +15 -0
- package/dist/playground/mount.js +46 -20
- 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/builtinNodes.d.ts +1 -26
- package/dist/registry/builtinNodes.js +14 -50
- package/dist/registry/index.d.ts +3 -4
- package/dist/registry/index.js +4 -6
- package/dist/registry/nodeComponentRegistry.d.ts +182 -15
- 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 +53 -6
- package/dist/services/agentSpecExecutionService.js +0 -1
- package/dist/services/apiVariableService.d.ts +2 -1
- package/dist/services/apiVariableService.js +5 -22
- package/dist/services/autoSaveService.d.ts +7 -0
- package/dist/services/autoSaveService.js +6 -4
- package/dist/services/chatService.d.ts +8 -4
- package/dist/services/chatService.js +15 -15
- package/dist/services/draftStorage.d.ts +129 -13
- package/dist/services/draftStorage.js +185 -37
- package/dist/services/dynamicSchemaService.d.ts +2 -1
- package/dist/services/dynamicSchemaService.js +5 -22
- package/dist/services/globalSave.d.ts +13 -12
- package/dist/services/globalSave.js +29 -51
- package/dist/services/historyService.d.ts +9 -3
- package/dist/services/historyService.js +9 -3
- package/dist/services/interruptService.d.ts +14 -9
- package/dist/services/interruptService.js +27 -27
- package/dist/services/nodeExecutionService.d.ts +18 -3
- package/dist/services/nodeExecutionService.js +71 -45
- package/dist/services/playgroundService.d.ts +14 -9
- package/dist/services/playgroundService.js +31 -30
- package/dist/services/variableService.d.ts +2 -1
- package/dist/services/variableService.js +2 -2
- package/dist/services/workflowStorage.js +6 -6
- package/dist/stores/apiContext.d.ts +45 -0
- package/dist/stores/apiContext.js +65 -0
- package/dist/stores/categoriesStore.svelte.d.ts +28 -23
- package/dist/stores/categoriesStore.svelte.js +70 -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 +77 -93
- package/dist/stores/historyStore.svelte.js +134 -160
- package/dist/stores/instanceContainer.svelte.d.ts +111 -0
- package/dist/stores/instanceContainer.svelte.js +114 -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 -216
- package/dist/stores/playgroundStore.svelte.js +515 -572
- package/dist/stores/portCoordinateStore.svelte.d.ts +57 -51
- package/dist/stores/portCoordinateStore.svelte.js +109 -98
- package/dist/stores/settingsStore.svelte.d.ts +4 -1
- package/dist/stores/settingsStore.svelte.js +47 -12
- package/dist/stores/workflowStore.svelte.d.ts +178 -213
- package/dist/stores/workflowStore.svelte.js +449 -501
- package/dist/stories/EdgeDecorator.svelte +5 -2
- package/dist/stories/NodeDecorator.svelte +5 -3
- package/dist/svelte-app.d.ts +60 -10
- package/dist/svelte-app.js +157 -53
- package/dist/types/events.d.ts +6 -3
- package/dist/types/index.d.ts +71 -6
- package/dist/types/navbar.d.ts +7 -0
- package/dist/types/playground.d.ts +18 -3
- package/dist/types/settings.d.ts +13 -0
- package/dist/types/settings.js +1 -0
- package/dist/utils/colors.d.ts +47 -21
- package/dist/utils/colors.js +69 -68
- package/dist/utils/connections.d.ts +9 -15
- package/dist/utils/connections.js +13 -32
- package/dist/utils/duration.d.ts +13 -0
- package/dist/utils/duration.js +45 -0
- package/dist/utils/formMerge.d.ts +36 -0
- package/dist/utils/formMerge.js +70 -0
- package/dist/utils/icons.d.ts +5 -2
- package/dist/utils/icons.js +6 -5
- package/dist/utils/nodeSwap.d.ts +6 -2
- package/dist/utils/nodeSwap.js +62 -126
- package/dist/utils/nodeTypes.d.ts +17 -8
- package/dist/utils/nodeTypes.js +27 -19
- package/dist/utils/performanceUtils.js +7 -0
- package/package.json +6 -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
|
@@ -1,283 +1,248 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Workflow Store for FlowDrop (Svelte 5 Runes)
|
|
3
3
|
*
|
|
4
|
-
* Provides
|
|
5
|
-
* and undo/redo history integration.
|
|
4
|
+
* Provides per-instance state management for workflows with dirty state
|
|
5
|
+
* tracking and undo/redo history integration.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* The reactive state lives in the {@link WorkflowStore} class — one per
|
|
8
|
+
* FlowDrop instance, created by `createFlowDropInstance()` and resolved in
|
|
9
|
+
* components via `getInstance().workflow`.
|
|
10
10
|
*
|
|
11
11
|
* @module stores/workflowStore
|
|
12
12
|
*/
|
|
13
13
|
import type { Workflow, WorkflowNode, WorkflowEdge } from '../types';
|
|
14
14
|
import type { WorkflowChangeType } from '../types/events.js';
|
|
15
|
-
type
|
|
15
|
+
import type { HistoryService } from '../services/historyService.js';
|
|
16
|
+
type WorkflowMetadata = Workflow['metadata'];
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
export declare function getWorkflowStore(): Workflow | null;
|
|
22
|
-
/**
|
|
23
|
-
* Get the current dirty state reactively
|
|
24
|
-
*
|
|
25
|
-
* Reads both _editVersion and _savedVersion, so Svelte tracks them
|
|
26
|
-
* as reactive dependencies — any component using this will re-render
|
|
27
|
-
* when dirty state changes.
|
|
28
|
-
*
|
|
29
|
-
* @returns true if there are unsaved changes
|
|
30
|
-
*/
|
|
31
|
-
export declare function getIsDirty(): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Get the workflow ID reactively
|
|
34
|
-
*
|
|
35
|
-
* @returns The workflow ID or null
|
|
36
|
-
*/
|
|
37
|
-
export declare function getWorkflowId(): string | null;
|
|
38
|
-
/**
|
|
39
|
-
* Get the workflow name reactively
|
|
40
|
-
*
|
|
41
|
-
* @returns The workflow name or 'Untitled Workflow'
|
|
42
|
-
*/
|
|
43
|
-
export declare function getWorkflowName(): string;
|
|
44
|
-
/**
|
|
45
|
-
* Get the workflow nodes reactively
|
|
46
|
-
*
|
|
47
|
-
* @returns Array of workflow nodes
|
|
48
|
-
*/
|
|
49
|
-
export declare function getWorkflowNodes(): WorkflowNode[];
|
|
50
|
-
/**
|
|
51
|
-
* Get the workflow edges reactively
|
|
52
|
-
*
|
|
53
|
-
* @returns Array of workflow edges
|
|
18
|
+
* Loosely-typed shape a workflow may arrive in before healing — a 1.x document
|
|
19
|
+
* may have no `metadata`, or metadata carrying the legacy `version` key instead
|
|
20
|
+
* of `schemaVersion`.
|
|
54
21
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
* @returns The workflow metadata with defaults
|
|
60
|
-
*/
|
|
61
|
-
export declare function getWorkflowMetadata(): WorkflowMetadata;
|
|
62
|
-
/**
|
|
63
|
-
* Get the current workflow format reactively
|
|
64
|
-
*
|
|
65
|
-
* @returns The workflow format string
|
|
66
|
-
*/
|
|
67
|
-
export declare function getWorkflowFormat(): string;
|
|
68
|
-
/**
|
|
69
|
-
* Get workflow change summary reactively (useful for triggering saves)
|
|
70
|
-
*
|
|
71
|
-
* @returns Object with nodes, edges, and name
|
|
72
|
-
*/
|
|
73
|
-
export declare function getWorkflowChanged(): {
|
|
74
|
-
nodes: WorkflowNode[];
|
|
75
|
-
edges: WorkflowEdge[];
|
|
76
|
-
name: string;
|
|
22
|
+
type LegacyWorkflow = Omit<Workflow, 'metadata'> & {
|
|
23
|
+
metadata?: (Partial<WorkflowMetadata> & {
|
|
24
|
+
version?: string;
|
|
25
|
+
}) | null;
|
|
77
26
|
};
|
|
78
27
|
/**
|
|
79
|
-
*
|
|
28
|
+
* Normalize workflow metadata at load time (the only back-compat path we keep,
|
|
29
|
+
* mirroring the storage-key migration in commit 8fab9157).
|
|
80
30
|
*
|
|
81
|
-
*
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
hasEdges: boolean;
|
|
86
|
-
nodeCount: number;
|
|
87
|
-
edgeCount: number;
|
|
88
|
-
isValid: boolean;
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Get workflow metadata change summary reactively
|
|
31
|
+
* Rules:
|
|
32
|
+
* - missing `metadata` → `buildMetadata(undefined)` (fresh required defaults)
|
|
33
|
+
* - legacy `version` key present → copied to `schemaVersion` when absent, then
|
|
34
|
+
* the legacy key is dropped
|
|
92
35
|
*
|
|
93
|
-
*
|
|
36
|
+
* Idempotent: re-running on an already-healed workflow returns equivalent
|
|
37
|
+
* metadata (round-trip stable).
|
|
94
38
|
*/
|
|
95
|
-
export declare function
|
|
96
|
-
createdAt: string;
|
|
97
|
-
updatedAt: string;
|
|
98
|
-
version: string;
|
|
99
|
-
};
|
|
39
|
+
export declare function normalizeWorkflowMetadata(workflow: LegacyWorkflow): Workflow;
|
|
100
40
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* Provides a Set of all handle IDs that are currently connected to edges.
|
|
104
|
-
* Used by node components to implement hideUnconnectedHandles functionality.
|
|
41
|
+
* Mutation actions for a {@link WorkflowStore}.
|
|
105
42
|
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* import { getConnectedHandles } from './workflowStore.svelte.js';
|
|
109
|
-
*
|
|
110
|
-
* // Check if a specific handle is connected
|
|
111
|
-
* const isConnected = getConnectedHandles().has('node-1-input-data');
|
|
112
|
-
* ```
|
|
43
|
+
* Bound facade — safe to detach (`onclick={fd.workflow.actions.undo}`)
|
|
44
|
+
* because every entry is bound to its store in the constructor.
|
|
113
45
|
*/
|
|
114
|
-
export
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
* Use this for the save verification protocol:
|
|
144
|
-
* 1. Before save: `const v = getEditVersion()`
|
|
145
|
-
* 2. Include `v` in the save request payload
|
|
146
|
-
* 3. Backend echoes `v` in the response
|
|
147
|
-
* 4. If echoed version matches: `markAsSaved()`
|
|
148
|
-
* 5. If not: the save didn't persist the version you submitted — reset from backend response
|
|
149
|
-
*
|
|
150
|
-
* @returns The current monotonic edit version
|
|
151
|
-
*/
|
|
152
|
-
export declare function getEditVersion(): number;
|
|
153
|
-
/**
|
|
154
|
-
* Enable or disable history recording
|
|
155
|
-
*
|
|
156
|
-
* Useful for bulk operations where you don't want individual history entries.
|
|
157
|
-
*
|
|
158
|
-
* @param enabled - Whether history should be recorded
|
|
159
|
-
*/
|
|
160
|
-
export declare function setHistoryEnabled(enabled: boolean): void;
|
|
161
|
-
/**
|
|
162
|
-
* Check if history recording is enabled
|
|
163
|
-
*
|
|
164
|
-
* @returns true if history is being recorded
|
|
165
|
-
*/
|
|
166
|
-
export declare function isHistoryEnabled(): boolean;
|
|
167
|
-
/**
|
|
168
|
-
* Set the restoring from history flag
|
|
169
|
-
*
|
|
170
|
-
* Used internally by the history store when performing undo/redo.
|
|
171
|
-
*
|
|
172
|
-
* @param restoring - Whether we're currently restoring from history
|
|
173
|
-
*/
|
|
174
|
-
export declare function setRestoringFromHistory(restoring: boolean): void;
|
|
175
|
-
/**
|
|
176
|
-
* Get the current workflow (non-reactive version for plain TS)
|
|
177
|
-
*
|
|
178
|
-
* @returns The current workflow or null
|
|
179
|
-
*/
|
|
180
|
-
export declare function getWorkflow(): Workflow | null;
|
|
46
|
+
export interface WorkflowStoreActions {
|
|
47
|
+
initialize: (workflow: Workflow) => void;
|
|
48
|
+
updateWorkflow: (workflow: Workflow) => void;
|
|
49
|
+
restoreFromHistory: (workflow: Workflow) => void;
|
|
50
|
+
updateNodes: (nodes: WorkflowNode[]) => void;
|
|
51
|
+
updateEdges: (edges: WorkflowEdge[]) => void;
|
|
52
|
+
updateName: (name: string) => void;
|
|
53
|
+
addNode: (node: WorkflowNode) => void;
|
|
54
|
+
removeNode: (nodeId: string) => void;
|
|
55
|
+
addEdge: (edge: WorkflowEdge) => void;
|
|
56
|
+
removeEdge: (edgeId: string) => void;
|
|
57
|
+
updateNode: (nodeId: string, updates: Partial<WorkflowNode>) => void;
|
|
58
|
+
clear: () => void;
|
|
59
|
+
updateMetadata: (metadata: Partial<Workflow['metadata']>) => void;
|
|
60
|
+
batchUpdate: (updates: {
|
|
61
|
+
nodes?: WorkflowNode[];
|
|
62
|
+
edges?: WorkflowEdge[];
|
|
63
|
+
name?: string;
|
|
64
|
+
description?: string;
|
|
65
|
+
metadata?: Partial<Workflow['metadata']>;
|
|
66
|
+
config?: Record<string, unknown>;
|
|
67
|
+
}) => void;
|
|
68
|
+
swapNode: (updates: {
|
|
69
|
+
nodes: WorkflowNode[];
|
|
70
|
+
edges: WorkflowEdge[];
|
|
71
|
+
description?: string;
|
|
72
|
+
}) => void;
|
|
73
|
+
pushHistory: (description?: string, workflow?: Workflow) => void;
|
|
74
|
+
}
|
|
181
75
|
/**
|
|
182
|
-
*
|
|
76
|
+
* Per-instance workflow state with dirty tracking and history integration.
|
|
183
77
|
*
|
|
184
|
-
* All
|
|
185
|
-
*
|
|
78
|
+
* All reads go through getters backed by `$state`, so reading them inside a
|
|
79
|
+
* component template or `$derived` tracks reactively, exactly like the
|
|
80
|
+
* legacy module-level functions did.
|
|
186
81
|
*/
|
|
187
|
-
export declare
|
|
82
|
+
export declare class WorkflowStore {
|
|
83
|
+
#private;
|
|
84
|
+
/** Bound mutation facade — see {@link WorkflowStoreActions}. */
|
|
85
|
+
readonly actions: WorkflowStoreActions;
|
|
86
|
+
constructor(history: HistoryService);
|
|
87
|
+
/** The current workflow, or null when none is loaded. */
|
|
88
|
+
get current(): Workflow | null;
|
|
188
89
|
/**
|
|
189
|
-
*
|
|
90
|
+
* Whether there are unsaved changes.
|
|
190
91
|
*
|
|
191
|
-
*
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
92
|
+
* Reads both #editVersion and #savedVersion, so Svelte tracks them as
|
|
93
|
+
* reactive dependencies — any component using this re-renders when dirty
|
|
94
|
+
* state changes.
|
|
95
|
+
*/
|
|
96
|
+
get isDirty(): boolean;
|
|
97
|
+
/** The workflow ID, or null. */
|
|
98
|
+
get id(): string | null;
|
|
99
|
+
/** The workflow name, or 'Untitled Workflow'. */
|
|
100
|
+
get name(): string;
|
|
101
|
+
/** The workflow nodes. */
|
|
102
|
+
get nodes(): WorkflowNode[];
|
|
103
|
+
/** The workflow edges. */
|
|
104
|
+
get edges(): WorkflowEdge[];
|
|
105
|
+
/** The workflow metadata, with defaults. */
|
|
106
|
+
get metadata(): WorkflowMetadata;
|
|
107
|
+
/** The workflow format string. */
|
|
108
|
+
get format(): string;
|
|
109
|
+
/** Workflow change summary (useful for triggering saves). */
|
|
110
|
+
get changeSummary(): {
|
|
111
|
+
nodes: WorkflowNode[];
|
|
112
|
+
edges: WorkflowEdge[];
|
|
113
|
+
name: string;
|
|
114
|
+
};
|
|
115
|
+
/** Workflow validation state. */
|
|
116
|
+
get validation(): {
|
|
117
|
+
hasNodes: boolean;
|
|
118
|
+
hasEdges: boolean;
|
|
119
|
+
nodeCount: number;
|
|
120
|
+
edgeCount: number;
|
|
121
|
+
isValid: boolean;
|
|
122
|
+
};
|
|
123
|
+
/** Workflow metadata change summary. */
|
|
124
|
+
get metadataChangeSummary(): {
|
|
125
|
+
createdAt: string;
|
|
126
|
+
updatedAt: string;
|
|
127
|
+
schemaVersion: string;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Set of all handle IDs currently connected to edges.
|
|
196
131
|
*
|
|
197
|
-
*
|
|
198
|
-
* for every small change. History is pushed by specific actions or drag handlers.
|
|
132
|
+
* Used by node components to implement hideUnconnectedHandles.
|
|
199
133
|
*/
|
|
200
|
-
|
|
134
|
+
get connectedHandles(): Set<string>;
|
|
201
135
|
/**
|
|
202
|
-
*
|
|
136
|
+
* The current monotonic edit version.
|
|
203
137
|
*
|
|
204
|
-
*
|
|
138
|
+
* Use this for the save verification protocol:
|
|
139
|
+
* 1. Before save: `const v = store.editVersion`
|
|
140
|
+
* 2. Include `v` in the save request payload
|
|
141
|
+
* 3. Backend echoes `v` in the response
|
|
142
|
+
* 4. If echoed version matches: `store.markAsSaved()`
|
|
143
|
+
* 5. If not: the save didn't persist the version you submitted — reset from backend response
|
|
144
|
+
*/
|
|
145
|
+
get editVersion(): number;
|
|
146
|
+
/** Whether history recording is enabled. */
|
|
147
|
+
get historyEnabled(): boolean;
|
|
148
|
+
/** Enable or disable history recording (e.g. for bulk operations). */
|
|
149
|
+
set historyEnabled(enabled: boolean);
|
|
150
|
+
/** Set the dirty state change callback. */
|
|
151
|
+
setOnDirtyStateChange(callback: ((isDirty: boolean) => void) | null): void;
|
|
152
|
+
/** Set the workflow change callback. */
|
|
153
|
+
setOnWorkflowChange(callback: ((workflow: Workflow, changeType: WorkflowChangeType) => void) | null): void;
|
|
154
|
+
/**
|
|
155
|
+
* Mark the current workflow state as saved.
|
|
156
|
+
*
|
|
157
|
+
* Captures the current edit version so isDirty becomes false.
|
|
158
|
+
* Call this after a successful backend save.
|
|
205
159
|
*/
|
|
206
|
-
|
|
160
|
+
markAsSaved(): void;
|
|
207
161
|
/**
|
|
208
|
-
*
|
|
162
|
+
* Set the restoring from history flag.
|
|
163
|
+
*
|
|
164
|
+
* Used internally by the history store when performing undo/redo.
|
|
209
165
|
*/
|
|
210
|
-
|
|
166
|
+
setRestoringFromHistory(restoring: boolean): void;
|
|
211
167
|
/**
|
|
212
|
-
*
|
|
168
|
+
* Initialize workflow (from load or new).
|
|
169
|
+
*
|
|
170
|
+
* This sets the initial saved snapshot, clears dirty state, and initializes history.
|
|
213
171
|
*/
|
|
214
|
-
|
|
172
|
+
initialize(workflow: Workflow): void;
|
|
215
173
|
/**
|
|
216
|
-
* Update workflow
|
|
174
|
+
* Update the entire workflow.
|
|
175
|
+
*
|
|
176
|
+
* Note: This is typically called from SvelteFlow sync and should not push to history
|
|
177
|
+
* for every small change. History is pushed by specific actions or drag handlers.
|
|
217
178
|
*/
|
|
218
|
-
|
|
179
|
+
updateWorkflow(workflow: Workflow): void;
|
|
219
180
|
/**
|
|
220
|
-
*
|
|
181
|
+
* Restore workflow from history (undo/redo).
|
|
182
|
+
*
|
|
183
|
+
* This bypasses history recording to prevent recursive loops.
|
|
221
184
|
*/
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
|
|
185
|
+
restoreFromHistory(workflow: Workflow): void;
|
|
186
|
+
/** Update nodes. */
|
|
187
|
+
updateNodes(nodes: WorkflowNode[]): void;
|
|
188
|
+
/** Update edges. */
|
|
189
|
+
updateEdges(edges: WorkflowEdge[]): void;
|
|
190
|
+
/** Update workflow name. */
|
|
191
|
+
updateName(name: string): void;
|
|
192
|
+
/** Add a node. */
|
|
193
|
+
addNode(node: WorkflowNode): void;
|
|
194
|
+
/**
|
|
195
|
+
* Remove a node.
|
|
225
196
|
*
|
|
226
197
|
* This is an atomic operation that also removes connected edges.
|
|
227
198
|
* A single undo will restore both the node and its edges.
|
|
228
199
|
*/
|
|
229
|
-
removeNode
|
|
230
|
-
/**
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Remove an edge
|
|
236
|
-
*/
|
|
237
|
-
removeEdge: (edgeId: string) => void;
|
|
200
|
+
removeNode(nodeId: string): void;
|
|
201
|
+
/** Add an edge. */
|
|
202
|
+
addEdge(edge: WorkflowEdge): void;
|
|
203
|
+
/** Remove an edge. */
|
|
204
|
+
removeEdge(edgeId: string): void;
|
|
238
205
|
/**
|
|
239
|
-
* Update a specific node
|
|
206
|
+
* Update a specific node.
|
|
240
207
|
*
|
|
241
208
|
* Used for config changes. Pushes to history for undo support.
|
|
242
209
|
*/
|
|
243
|
-
updateNode
|
|
210
|
+
updateNode(nodeId: string, updates: Partial<WorkflowNode>): void;
|
|
244
211
|
/**
|
|
245
|
-
* Clear the workflow
|
|
212
|
+
* Clear the workflow.
|
|
246
213
|
*
|
|
247
214
|
* Resets the workflow and clears history.
|
|
248
215
|
*/
|
|
249
|
-
clear
|
|
250
|
-
/**
|
|
251
|
-
|
|
252
|
-
*/
|
|
253
|
-
updateMetadata: (metadata: Partial<Workflow["metadata"]>) => void;
|
|
216
|
+
clear(): void;
|
|
217
|
+
/** Update workflow metadata. */
|
|
218
|
+
updateMetadata(metadata: Partial<Workflow['metadata']>): void;
|
|
254
219
|
/**
|
|
255
|
-
* Batch update nodes and edges
|
|
220
|
+
* Batch update nodes and edges.
|
|
256
221
|
*
|
|
257
222
|
* Useful for complex operations that update multiple things at once.
|
|
258
223
|
* Creates a single history entry for the entire batch.
|
|
259
224
|
*/
|
|
260
|
-
batchUpdate
|
|
225
|
+
batchUpdate(updates: {
|
|
261
226
|
nodes?: WorkflowNode[];
|
|
262
227
|
edges?: WorkflowEdge[];
|
|
263
228
|
name?: string;
|
|
264
229
|
description?: string;
|
|
265
|
-
metadata?: Partial<Workflow[
|
|
230
|
+
metadata?: Partial<Workflow['metadata']>;
|
|
266
231
|
config?: Record<string, unknown>;
|
|
267
|
-
})
|
|
232
|
+
}): void;
|
|
268
233
|
/**
|
|
269
234
|
* Swap a node — atomically replaces nodes and edges with a descriptive history entry.
|
|
270
235
|
*
|
|
271
236
|
* Unlike batchUpdate, this uses `"node_swap"` as the change type and
|
|
272
237
|
* records a meaningful description for the undo history.
|
|
273
238
|
*/
|
|
274
|
-
swapNode
|
|
239
|
+
swapNode(updates: {
|
|
275
240
|
nodes: WorkflowNode[];
|
|
276
241
|
edges: WorkflowEdge[];
|
|
277
242
|
description?: string;
|
|
278
|
-
})
|
|
243
|
+
}): void;
|
|
279
244
|
/**
|
|
280
|
-
* Push current state to history manually
|
|
245
|
+
* Push current state to history manually.
|
|
281
246
|
*
|
|
282
247
|
* Use this before operations that modify the workflow through other means
|
|
283
248
|
* (e.g., drag operations handled by SvelteFlow directly).
|
|
@@ -285,6 +250,6 @@ export declare const workflowActions: {
|
|
|
285
250
|
* @param description - Description of the upcoming change
|
|
286
251
|
* @param workflow - Optional workflow to push (uses store state if not provided)
|
|
287
252
|
*/
|
|
288
|
-
pushHistory
|
|
289
|
-
}
|
|
253
|
+
pushHistory(description?: string, workflow?: Workflow): void;
|
|
254
|
+
}
|
|
290
255
|
export {};
|