@flowdrop/flowdrop 1.15.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 +71 -47
- 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 +18 -25
- 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 +8 -6
- 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 +17 -5
- 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 +90 -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 +3 -2
- package/dist/helpers/proximityConnect.js +2 -5
- 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 +3 -3
- 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 +0 -25
- package/dist/registry/builtinNodes.js +1 -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 +3 -3
- 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 -222
- package/dist/stores/playgroundStore.svelte.js +515 -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 +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 +33 -3
- 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/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 +26 -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
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @module services/autoSaveService
|
|
8
8
|
*/
|
|
9
9
|
import { getBehaviorSettings, onSettingsChange } from '../stores/settingsStore.svelte.js';
|
|
10
|
-
import {
|
|
10
|
+
import { getDefaultInstance } from '../stores/instanceContainer.svelte.js';
|
|
11
11
|
import { logger } from '../utils/logger.js';
|
|
12
12
|
/**
|
|
13
13
|
* Initialize auto-save functionality based on user settings
|
|
@@ -40,7 +40,7 @@ import { logger } from '../utils/logger.js';
|
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
42
|
export function initAutoSave(options) {
|
|
43
|
-
const { onSave, onError, onSuccess } = options;
|
|
43
|
+
const { onSave, onError, onSuccess, isDirty: isDirtyProbe = () => getDefaultInstance().workflow.isDirty } = options;
|
|
44
44
|
const state = {
|
|
45
45
|
intervalId: null,
|
|
46
46
|
isSaving: false,
|
|
@@ -52,7 +52,7 @@ export function initAutoSave(options) {
|
|
|
52
52
|
*/
|
|
53
53
|
async function performAutoSave() {
|
|
54
54
|
// Skip if already saving or not dirty
|
|
55
|
-
if (state.isSaving || !
|
|
55
|
+
if (state.isSaving || !isDirtyProbe()) {
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
state.isSaving = true;
|
|
@@ -127,6 +127,7 @@ export class AutoSaveManager {
|
|
|
127
127
|
onSave;
|
|
128
128
|
onError;
|
|
129
129
|
onSuccess;
|
|
130
|
+
isDirtyProbe;
|
|
130
131
|
/**
|
|
131
132
|
* Create a new AutoSaveManager
|
|
132
133
|
*
|
|
@@ -136,6 +137,7 @@ export class AutoSaveManager {
|
|
|
136
137
|
this.onSave = options.onSave;
|
|
137
138
|
this.onError = options.onError;
|
|
138
139
|
this.onSuccess = options.onSuccess;
|
|
140
|
+
this.isDirtyProbe = options.isDirty ?? (() => getDefaultInstance().workflow.isDirty);
|
|
139
141
|
}
|
|
140
142
|
/**
|
|
141
143
|
* Start the auto-save manager
|
|
@@ -207,7 +209,7 @@ export class AutoSaveManager {
|
|
|
207
209
|
* Perform the save operation
|
|
208
210
|
*/
|
|
209
211
|
async performSave() {
|
|
210
|
-
if (this.isSaving || !
|
|
212
|
+
if (this.isSaving || !this.isDirtyProbe()) {
|
|
211
213
|
return;
|
|
212
214
|
}
|
|
213
215
|
this.isSaving = true;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @module services/chatService
|
|
8
8
|
*/
|
|
9
9
|
import type { ChatRequest, ChatResponse, ChatHistoryMessage } from '../types/chat.js';
|
|
10
|
+
import type { EndpointConfig } from '../config/endpoints.js';
|
|
10
11
|
/**
|
|
11
12
|
* Chat Service class
|
|
12
13
|
*
|
|
@@ -23,7 +24,9 @@ export declare class ChatService {
|
|
|
23
24
|
*/
|
|
24
25
|
static getInstance(): ChatService;
|
|
25
26
|
/**
|
|
26
|
-
*
|
|
27
|
+
* Validate and return the caller-supplied endpoint configuration.
|
|
28
|
+
*
|
|
29
|
+
* Callers thread the config from `getInstance().api.config`.
|
|
27
30
|
*
|
|
28
31
|
* @throws Error if endpoint configuration is not set
|
|
29
32
|
* @returns The endpoint configuration
|
|
@@ -32,6 +35,7 @@ export declare class ChatService {
|
|
|
32
35
|
/**
|
|
33
36
|
* Generic API request helper
|
|
34
37
|
*
|
|
38
|
+
* @param config - The endpoint configuration
|
|
35
39
|
* @param url - The URL to fetch
|
|
36
40
|
* @param options - Fetch options
|
|
37
41
|
* @returns The parsed JSON response
|
|
@@ -44,20 +48,20 @@ export declare class ChatService {
|
|
|
44
48
|
* @param request - The chat request payload
|
|
45
49
|
* @returns The chat response from the LLM
|
|
46
50
|
*/
|
|
47
|
-
sendMessage(workflowId: string, request: ChatRequest): Promise<ChatResponse>;
|
|
51
|
+
sendMessage(endpointConfig: EndpointConfig | null, workflowId: string, request: ChatRequest): Promise<ChatResponse>;
|
|
48
52
|
/**
|
|
49
53
|
* Get conversation history for a workflow
|
|
50
54
|
*
|
|
51
55
|
* @param workflowId - The workflow ID
|
|
52
56
|
* @returns Array of chat history messages
|
|
53
57
|
*/
|
|
54
|
-
getHistory(workflowId: string): Promise<ChatHistoryMessage[]>;
|
|
58
|
+
getHistory(endpointConfig: EndpointConfig | null, workflowId: string): Promise<ChatHistoryMessage[]>;
|
|
55
59
|
/**
|
|
56
60
|
* Clear conversation history for a workflow
|
|
57
61
|
*
|
|
58
62
|
* @param workflowId - The workflow ID
|
|
59
63
|
*/
|
|
60
|
-
clearHistory(workflowId: string): Promise<void>;
|
|
64
|
+
clearHistory(endpointConfig: EndpointConfig | null, workflowId: string): Promise<void>;
|
|
61
65
|
}
|
|
62
66
|
/**
|
|
63
67
|
* Pre-instantiated ChatService singleton
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* @module services/chatService
|
|
8
8
|
*/
|
|
9
9
|
import { buildEndpointUrl, getEndpointHeaders } from '../config/endpoints.js';
|
|
10
|
-
import { getEndpointConfig } from './api.js';
|
|
11
10
|
import { logger } from '../utils/logger.js';
|
|
12
11
|
/**
|
|
13
12
|
* Chat Service class
|
|
@@ -30,27 +29,28 @@ export class ChatService {
|
|
|
30
29
|
return ChatService.instance;
|
|
31
30
|
}
|
|
32
31
|
/**
|
|
33
|
-
*
|
|
32
|
+
* Validate and return the caller-supplied endpoint configuration.
|
|
33
|
+
*
|
|
34
|
+
* Callers thread the config from `getInstance().api.config`.
|
|
34
35
|
*
|
|
35
36
|
* @throws Error if endpoint configuration is not set
|
|
36
37
|
* @returns The endpoint configuration
|
|
37
38
|
*/
|
|
38
|
-
getConfig() {
|
|
39
|
-
const config = getEndpointConfig();
|
|
39
|
+
getConfig(config) {
|
|
40
40
|
if (!config) {
|
|
41
|
-
throw new Error('Endpoint configuration not set.
|
|
41
|
+
throw new Error('Endpoint configuration not set. Configure the instance via fd.api.configure().');
|
|
42
42
|
}
|
|
43
43
|
return config;
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Generic API request helper
|
|
47
47
|
*
|
|
48
|
+
* @param config - The endpoint configuration
|
|
48
49
|
* @param url - The URL to fetch
|
|
49
50
|
* @param options - Fetch options
|
|
50
51
|
* @returns The parsed JSON response
|
|
51
52
|
*/
|
|
52
|
-
async request(url, options = {}) {
|
|
53
|
-
const config = this.getConfig();
|
|
53
|
+
async request(config, url, options = {}) {
|
|
54
54
|
const headers = getEndpointHeaders(config, 'chat');
|
|
55
55
|
const response = await fetch(url, {
|
|
56
56
|
...options,
|
|
@@ -83,13 +83,13 @@ export class ChatService {
|
|
|
83
83
|
* @param request - The chat request payload
|
|
84
84
|
* @returns The chat response from the LLM
|
|
85
85
|
*/
|
|
86
|
-
async sendMessage(workflowId, request) {
|
|
87
|
-
const config = this.getConfig();
|
|
86
|
+
async sendMessage(endpointConfig, workflowId, request) {
|
|
87
|
+
const config = this.getConfig(endpointConfig);
|
|
88
88
|
const url = buildEndpointUrl(config, config.endpoints.chat.sendMessage, {
|
|
89
89
|
id: workflowId
|
|
90
90
|
});
|
|
91
91
|
logger.debug('[ChatService] Sending message to', url);
|
|
92
|
-
return this.request(url, {
|
|
92
|
+
return this.request(config, url, {
|
|
93
93
|
method: 'POST',
|
|
94
94
|
body: JSON.stringify(request)
|
|
95
95
|
});
|
|
@@ -100,21 +100,21 @@ export class ChatService {
|
|
|
100
100
|
* @param workflowId - The workflow ID
|
|
101
101
|
* @returns Array of chat history messages
|
|
102
102
|
*/
|
|
103
|
-
async getHistory(workflowId) {
|
|
104
|
-
const config = this.getConfig();
|
|
103
|
+
async getHistory(endpointConfig, workflowId) {
|
|
104
|
+
const config = this.getConfig(endpointConfig);
|
|
105
105
|
const url = buildEndpointUrl(config, config.endpoints.chat.getHistory, {
|
|
106
106
|
id: workflowId
|
|
107
107
|
});
|
|
108
108
|
logger.debug('[ChatService] Getting history from', url);
|
|
109
|
-
return this.request(url);
|
|
109
|
+
return this.request(config, url);
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
112
|
* Clear conversation history for a workflow
|
|
113
113
|
*
|
|
114
114
|
* @param workflowId - The workflow ID
|
|
115
115
|
*/
|
|
116
|
-
async clearHistory(workflowId) {
|
|
117
|
-
const config = this.getConfig();
|
|
116
|
+
async clearHistory(endpointConfig, workflowId) {
|
|
117
|
+
const config = this.getConfig(endpointConfig);
|
|
118
118
|
const url = buildEndpointUrl(config, config.endpoints.chat.clearHistory, {
|
|
119
119
|
id: workflowId
|
|
120
120
|
});
|
|
@@ -1,12 +1,82 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Draft Storage Service for FlowDrop
|
|
3
3
|
*
|
|
4
|
-
* Handles saving and loading workflow drafts to/from
|
|
4
|
+
* Handles saving and loading workflow drafts to/from browser storage
|
|
5
|
+
* (localStorage by default, configurable via {@link setDraftStorage}).
|
|
5
6
|
* Provides interval-based auto-save functionality.
|
|
6
7
|
*
|
|
7
8
|
* @module services/draftStorage
|
|
8
9
|
*/
|
|
9
10
|
import type { Workflow } from '../types/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Minimal storage adapter used for draft persistence.
|
|
13
|
+
*
|
|
14
|
+
* Implement this to back drafts with anything other than the built-in
|
|
15
|
+
* `localStorage` / `sessionStorage` options — e.g. an in-memory store, a
|
|
16
|
+
* key-prefixed wrapper, or a synchronous write-through cache.
|
|
17
|
+
*
|
|
18
|
+
* Note the interface is deliberately **synchronous**. Async backends
|
|
19
|
+
* (IndexedDB, network storage, WebCrypto-encrypted stores) cannot implement
|
|
20
|
+
* it directly — put a synchronous in-memory cache in front and flush to the
|
|
21
|
+
* async backend out of band. An `async` method assigned here will type-check
|
|
22
|
+
* (a Promise is assignable to `void`) but its errors are silently swallowed.
|
|
23
|
+
*/
|
|
24
|
+
export interface DraftStorageAdapter {
|
|
25
|
+
/** Read a value, or null when absent */
|
|
26
|
+
getItem(key: string): string | null;
|
|
27
|
+
/** Write a value */
|
|
28
|
+
setItem(key: string, value: string): void;
|
|
29
|
+
/** Remove a value */
|
|
30
|
+
removeItem(key: string): void;
|
|
31
|
+
/** List all keys currently held by the adapter */
|
|
32
|
+
keys(): string[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Built-in storage backends
|
|
36
|
+
* - 'local': localStorage — drafts persist on the device even after the tab
|
|
37
|
+
* or browser is closed, until saved or cleared
|
|
38
|
+
* - 'session': sessionStorage — drafts are scoped to the tab and removed
|
|
39
|
+
* when it closes (they do not survive crash-and-reopen)
|
|
40
|
+
*/
|
|
41
|
+
export type DraftStorageType = 'local' | 'session';
|
|
42
|
+
/** Accepted values for the `draftStorage` mount option */
|
|
43
|
+
export type DraftStorageOption = DraftStorageType | DraftStorageAdapter;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve a {@link DraftStorageOption} to a concrete adapter.
|
|
46
|
+
*
|
|
47
|
+
* `'local'` / `'session'` map to the built-in Web Storage adapters, a custom
|
|
48
|
+
* adapter is returned as-is, and `undefined` resolves to the current
|
|
49
|
+
* module-level default (see {@link setDraftStorage}).
|
|
50
|
+
*/
|
|
51
|
+
export declare function resolveDraftStorage(option?: DraftStorageOption): DraftStorageAdapter;
|
|
52
|
+
/**
|
|
53
|
+
* Configure the module-level default for where workflow drafts are persisted.
|
|
54
|
+
*
|
|
55
|
+
* - `'local'` (default): `localStorage` — drafts survive reloads and browser
|
|
56
|
+
* restarts, and remain stored on the device even after the tab is closed,
|
|
57
|
+
* until saved or cleared.
|
|
58
|
+
* - `'session'`: `sessionStorage` — drafts are scoped to the current tab and
|
|
59
|
+
* removed when it closes. Note this also means drafts do not survive a
|
|
60
|
+
* crash-and-reopen.
|
|
61
|
+
* - A custom {@link DraftStorageAdapter} for anything else.
|
|
62
|
+
*
|
|
63
|
+
* This sets the default used by the standalone helpers and by managers
|
|
64
|
+
* constructed without an explicit `storage` option. Mounted apps capture
|
|
65
|
+
* their own adapter at mount time, so calling this does not retarget
|
|
66
|
+
* already-running instances. With multiple mounts the most recent mount's
|
|
67
|
+
* backend wins *for the standalone helpers only*.
|
|
68
|
+
*
|
|
69
|
+
* Security note: neither built-in backend protects against same-origin
|
|
70
|
+
* script access (XSS) — both are readable by any script on the page. If
|
|
71
|
+
* workflows may contain secrets in node configs, disable drafts via
|
|
72
|
+
* `features.autoSaveDraft: false` or keep them off-disk with a custom
|
|
73
|
+
* in-memory adapter.
|
|
74
|
+
*/
|
|
75
|
+
export declare function setDraftStorage(option: DraftStorageOption): void;
|
|
76
|
+
/**
|
|
77
|
+
* Get the current module-level default draft storage adapter
|
|
78
|
+
*/
|
|
79
|
+
export declare function getDraftStorage(): DraftStorageAdapter;
|
|
10
80
|
/**
|
|
11
81
|
* Draft metadata stored alongside the workflow
|
|
12
82
|
*/
|
|
@@ -19,7 +89,7 @@ interface DraftMetadata {
|
|
|
19
89
|
workflowName?: string;
|
|
20
90
|
}
|
|
21
91
|
/**
|
|
22
|
-
* Complete draft data stored in
|
|
92
|
+
* Complete draft data stored in draft storage
|
|
23
93
|
*/
|
|
24
94
|
interface StoredDraft {
|
|
25
95
|
/** The workflow data */
|
|
@@ -27,6 +97,14 @@ interface StoredDraft {
|
|
|
27
97
|
/** Draft metadata */
|
|
28
98
|
metadata: DraftMetadata;
|
|
29
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Storage prefix of the page-default instance (`flowdrop:draft:default`).
|
|
102
|
+
*
|
|
103
|
+
* Every instance — including the default — uses an id-scoped prefix since
|
|
104
|
+
* v2.0. Standalone helper callers that don't pass a prefix get this one, so
|
|
105
|
+
* they keep addressing the default editor's drafts.
|
|
106
|
+
*/
|
|
107
|
+
export declare const DEFAULT_INSTANCE_DRAFT_PREFIX = "flowdrop:draft:default";
|
|
30
108
|
/**
|
|
31
109
|
* Generate a storage key for a workflow
|
|
32
110
|
*
|
|
@@ -35,48 +113,70 @@ interface StoredDraft {
|
|
|
35
113
|
*
|
|
36
114
|
* @param workflowId - The workflow ID (optional)
|
|
37
115
|
* @param customKey - Custom storage key provided by enterprise (optional)
|
|
116
|
+
* @param prefix - Key namespace; pass a FlowDrop instance's `storagePrefix`
|
|
117
|
+
* to scope drafts per instance. Defaults to the page-default instance's
|
|
118
|
+
* prefix.
|
|
38
119
|
* @returns The storage key to use
|
|
39
120
|
*/
|
|
40
|
-
export declare function getDraftStorageKey(workflowId?: string, customKey?: string): string;
|
|
121
|
+
export declare function getDraftStorageKey(workflowId?: string, customKey?: string, prefix?: string): string;
|
|
122
|
+
/**
|
|
123
|
+
* One-time migration of a 1.x draft key to its 2.0 scoped equivalent.
|
|
124
|
+
*
|
|
125
|
+
* In 1.x the page-default instance stored drafts under the bare
|
|
126
|
+
* `flowdrop:draft:<workflowId>` key; since 2.0 it uses
|
|
127
|
+
* `flowdrop:draft:default:<workflowId>`. When the scoped key is empty and the
|
|
128
|
+
* legacy key holds a draft, the draft is moved (copied, then the legacy key
|
|
129
|
+
* removed) so users upgrading mid-edit don't lose work.
|
|
130
|
+
*
|
|
131
|
+
* @param legacyKey - The 1.x bare-prefix key
|
|
132
|
+
* @param scopedKey - The 2.0 instance-scoped key
|
|
133
|
+
* @param storage - Adapter to migrate within (defaults to the module-level default)
|
|
134
|
+
*/
|
|
135
|
+
export declare function migrateLegacyDraftKey(legacyKey: string, scopedKey: string, storage?: DraftStorageAdapter): void;
|
|
41
136
|
/**
|
|
42
|
-
* Save a workflow draft to
|
|
137
|
+
* Save a workflow draft to draft storage
|
|
43
138
|
*
|
|
44
139
|
* @param workflow - The workflow to save
|
|
45
140
|
* @param storageKey - The storage key to use
|
|
141
|
+
* @param storage - Adapter to write to (defaults to the module-level default)
|
|
46
142
|
* @returns true if saved successfully, false otherwise
|
|
47
143
|
*/
|
|
48
|
-
export declare function saveDraft(workflow: Workflow, storageKey: string): boolean;
|
|
144
|
+
export declare function saveDraft(workflow: Workflow, storageKey: string, storage?: DraftStorageAdapter): boolean;
|
|
49
145
|
/**
|
|
50
|
-
* Load a workflow draft from
|
|
146
|
+
* Load a workflow draft from draft storage
|
|
51
147
|
*
|
|
52
148
|
* @param storageKey - The storage key to load from
|
|
149
|
+
* @param storage - Adapter to read from (defaults to the module-level default)
|
|
53
150
|
* @returns The stored draft, or null if not found
|
|
54
151
|
*/
|
|
55
|
-
export declare function loadDraft(storageKey: string): StoredDraft | null;
|
|
152
|
+
export declare function loadDraft(storageKey: string, storage?: DraftStorageAdapter): StoredDraft | null;
|
|
56
153
|
/**
|
|
57
|
-
* Delete a workflow draft from
|
|
154
|
+
* Delete a workflow draft from draft storage
|
|
58
155
|
*
|
|
59
156
|
* @param storageKey - The storage key to delete
|
|
157
|
+
* @param storage - Adapter to delete from (defaults to the module-level default)
|
|
60
158
|
*/
|
|
61
|
-
export declare function deleteDraft(storageKey: string): void;
|
|
159
|
+
export declare function deleteDraft(storageKey: string, storage?: DraftStorageAdapter): void;
|
|
62
160
|
/**
|
|
63
161
|
* Check if a draft exists for a given storage key
|
|
64
162
|
*
|
|
65
163
|
* @param storageKey - The storage key to check
|
|
164
|
+
* @param storage - Adapter to check (defaults to the module-level default)
|
|
66
165
|
* @returns true if a draft exists
|
|
67
166
|
*/
|
|
68
|
-
export declare function hasDraft(storageKey: string): boolean;
|
|
167
|
+
export declare function hasDraft(storageKey: string, storage?: DraftStorageAdapter): boolean;
|
|
69
168
|
/**
|
|
70
169
|
* Get draft metadata without loading the full workflow
|
|
71
170
|
*
|
|
72
171
|
* Useful for displaying draft information without parsing the entire workflow.
|
|
73
172
|
*
|
|
74
173
|
* @param storageKey - The storage key to check
|
|
174
|
+
* @param storage - Adapter to read from (defaults to the module-level default)
|
|
75
175
|
* @returns Draft metadata, or null if not found
|
|
76
176
|
*/
|
|
77
|
-
export declare function getDraftMetadata(storageKey: string): DraftMetadata | null;
|
|
177
|
+
export declare function getDraftMetadata(storageKey: string, storage?: DraftStorageAdapter): DraftMetadata | null;
|
|
78
178
|
/**
|
|
79
|
-
* Clear all FlowDrop drafts from
|
|
179
|
+
* Clear all FlowDrop drafts from draft storage
|
|
80
180
|
*
|
|
81
181
|
* Removes every key beginning with `flowdrop:draft:`. Intended to be called
|
|
82
182
|
* from a host application's logout handler so workflow drafts do not persist
|
|
@@ -85,9 +185,10 @@ export declare function getDraftMetadata(storageKey: string): DraftMetadata | nu
|
|
|
85
185
|
* @param extraKeys - Additional explicit keys to remove. Pass any custom
|
|
86
186
|
* `draftStorageKey` values configured at mount time so they are cleared
|
|
87
187
|
* alongside the default-prefixed keys.
|
|
188
|
+
* @param storage - Adapter to clear (defaults to the module-level default)
|
|
88
189
|
* @returns The number of entries removed.
|
|
89
190
|
*/
|
|
90
|
-
export declare function clearAllDrafts(extraKeys?: readonly string[]): number;
|
|
191
|
+
export declare function clearAllDrafts(extraKeys?: readonly string[], storage?: DraftStorageAdapter): number;
|
|
91
192
|
/**
|
|
92
193
|
* Draft auto-save manager
|
|
93
194
|
*
|
|
@@ -107,6 +208,17 @@ export declare class DraftAutoSaveManager {
|
|
|
107
208
|
private getWorkflow;
|
|
108
209
|
/** Function to check if workflow is dirty */
|
|
109
210
|
private isDirty;
|
|
211
|
+
/**
|
|
212
|
+
* Runtime gate for draft persistence (e.g. a user-facing opt-out setting).
|
|
213
|
+
* Checked on every save, so it can change after construction.
|
|
214
|
+
*/
|
|
215
|
+
private isPersistenceAllowed;
|
|
216
|
+
/**
|
|
217
|
+
* Storage adapter this instance writes to.
|
|
218
|
+
* Captured at construction, so a later `setDraftStorage()` call (e.g. from
|
|
219
|
+
* another FlowDrop mount on the same page) cannot retarget this manager.
|
|
220
|
+
*/
|
|
221
|
+
private storage;
|
|
110
222
|
/** Last saved workflow hash (for change detection) */
|
|
111
223
|
private lastSavedHash;
|
|
112
224
|
/**
|
|
@@ -120,6 +232,10 @@ export declare class DraftAutoSaveManager {
|
|
|
120
232
|
enabled: boolean;
|
|
121
233
|
getWorkflow: () => Workflow | null;
|
|
122
234
|
isDirty: () => boolean;
|
|
235
|
+
/** Optional runtime gate — return false to suppress draft writes (default: always allowed) */
|
|
236
|
+
isPersistenceAllowed?: () => boolean;
|
|
237
|
+
/** Storage backend for this instance (default: the module-level default at construction time) */
|
|
238
|
+
storage?: DraftStorageOption;
|
|
123
239
|
});
|
|
124
240
|
/**
|
|
125
241
|
* Start auto-save interval
|