@flowdrop/flowdrop 2.14.0 → 2.15.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 +66 -0
- package/dist/api/enhanced-client.js +2 -1
- package/dist/commands/types.d.ts +6 -2
- package/dist/commands/uiActionTarget.d.ts +24 -0
- package/dist/commands/uiActionTarget.js +31 -0
- package/dist/commands/validate.d.ts +15 -0
- package/dist/commands/validate.js +115 -0
- package/dist/components/App.svelte +43 -1
- package/dist/components/App.svelte.d.ts +2 -0
- package/dist/components/ConfigForm.svelte +42 -1
- package/dist/components/ConfigForm.svelte.d.ts +10 -1
- package/dist/components/ExternalLinkRow.svelte +16 -1
- package/dist/components/ExternalLinkRow.svelte.d.ts +5 -0
- package/dist/components/form/FormAutocomplete.svelte +110 -44
- package/dist/core/index.d.ts +1 -1
- package/dist/editor/index.d.ts +3 -3
- package/dist/index.d.ts +3 -2
- package/dist/messages/defaults.d.ts +1 -0
- package/dist/messages/defaults.js +1 -0
- package/dist/stores/workflowStore.svelte.d.ts +10 -0
- package/dist/stores/workflowStore.svelte.js +41 -13
- package/dist/svelte-app.d.ts +62 -1
- package/dist/svelte-app.js +144 -1
- package/dist/types/events.d.ts +18 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/utils/externalEdit.svelte.d.ts +48 -0
- package/dist/utils/externalEdit.svelte.js +62 -0
- package/dist/utils/fetchWithAuth.d.ts +10 -0
- package/dist/utils/fetchWithAuth.js +23 -1
- package/dist/utils/inspectorContext.d.ts +5 -0
- package/package.json +1 -1
package/dist/svelte-app.js
CHANGED
|
@@ -19,6 +19,12 @@ import { initializeSettings, getHostColorSchemeRegistration, releaseHostColorSch
|
|
|
19
19
|
import { logger } from './utils/logger.js';
|
|
20
20
|
import { globalSaveWorkflow, globalExportWorkflow } from './services/globalSave.js';
|
|
21
21
|
import { whenWorkflowLoaded } from './utils/whenWorkflowLoaded.svelte.js';
|
|
22
|
+
import { parseCommand } from './commands/parser.js';
|
|
23
|
+
import { executeCommand } from './commands/executor.js';
|
|
24
|
+
import { isSessionLine } from './commands/session.js';
|
|
25
|
+
import { createStoreCommandContext } from './commands/storeIntegration.svelte.js';
|
|
26
|
+
import { dispatchUIAction } from './commands/uiActionTarget.js';
|
|
27
|
+
import { validateCommand } from './commands/validate.js';
|
|
22
28
|
// ---------------------------------------------------------------------------
|
|
23
29
|
// Instance acquisition
|
|
24
30
|
// ---------------------------------------------------------------------------
|
|
@@ -134,6 +140,120 @@ function attachWebMCPToMount(fd, options, isDestroyed) {
|
|
|
134
140
|
});
|
|
135
141
|
});
|
|
136
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Build `runCommand` for a mount (shared by `mountFlowDropApp` and
|
|
145
|
+
* `mountWorkflowEditor`).
|
|
146
|
+
*
|
|
147
|
+
* @param isDestroyed - Whether the mount is gone.
|
|
148
|
+
* @param registerCancel - Registers a callback the mount calls on destroy to
|
|
149
|
+
* settle a call still waiting for the workflow; returns its unregister.
|
|
150
|
+
* @param onBaseline - Runs after a successful baseline run, e.g. to tell a
|
|
151
|
+
* draft manager the re-baselined workflow is not an unsaved draft.
|
|
152
|
+
*/
|
|
153
|
+
function createRunCommand(fd, isDestroyed, registerCancel, onBaseline) {
|
|
154
|
+
const gone = () => ({
|
|
155
|
+
ok: false,
|
|
156
|
+
code: 'NO_WORKFLOW',
|
|
157
|
+
error: 'The editor was destroyed before a workflow was available.'
|
|
158
|
+
});
|
|
159
|
+
const run = (command, options) => {
|
|
160
|
+
if (isDestroyed() || !fd.workflow.current)
|
|
161
|
+
return gone();
|
|
162
|
+
let parsed;
|
|
163
|
+
if (typeof command === 'string') {
|
|
164
|
+
if (isSessionLine(command)) {
|
|
165
|
+
return {
|
|
166
|
+
ok: false,
|
|
167
|
+
code: 'SESSION_REFUSED',
|
|
168
|
+
error: '`session` commands run only in the editor Console; they are not available here.'
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
const result = parseCommand(command);
|
|
172
|
+
if (!result.ok)
|
|
173
|
+
return { ok: false, code: 'PARSE_ERROR', error: result.error };
|
|
174
|
+
parsed = result.command;
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
// Not from the parser: a host may have built it by hand, in plain JS.
|
|
178
|
+
const problem = validateCommand(command);
|
|
179
|
+
if (problem)
|
|
180
|
+
return { ok: false, code: 'INVALID_ARGUMENT', error: problem };
|
|
181
|
+
parsed = command;
|
|
182
|
+
}
|
|
183
|
+
const baseline = options?.baseline === true;
|
|
184
|
+
if (baseline && fd.workflow.isDirty) {
|
|
185
|
+
return {
|
|
186
|
+
ok: false,
|
|
187
|
+
code: 'DIRTY',
|
|
188
|
+
error: 'baseline needs a workflow with no unsaved changes; save or discard them first. Nothing was run.'
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
// Undo/redo would step past the saved state and then call it clean.
|
|
192
|
+
if (baseline && (parsed.type === 'undo' || parsed.type === 'redo')) {
|
|
193
|
+
return {
|
|
194
|
+
ok: false,
|
|
195
|
+
code: 'INVALID_ARGUMENT',
|
|
196
|
+
error: `${parsed.type} cannot be run as a baseline. Nothing was run.`
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
const context = createStoreCommandContext(fd.nodeTypes.current ?? [], (action) => dispatchUIAction(fd, action), fd);
|
|
200
|
+
if (!context)
|
|
201
|
+
return gone();
|
|
202
|
+
// A baseline run is not a change the host should hear about: on release
|
|
203
|
+
// it is told only what is still true (a failed command that left changes).
|
|
204
|
+
const release = baseline ? fd.workflow.muteCallbacks() : null;
|
|
205
|
+
try {
|
|
206
|
+
const result = executeCommand(parsed, context);
|
|
207
|
+
// A command that changed nothing (`info`, `list nodes`, ...) leaves the
|
|
208
|
+
// workflow clean: keep its undo history.
|
|
209
|
+
if (baseline && result.ok && fd.workflow.isDirty) {
|
|
210
|
+
const current = fd.workflow.current;
|
|
211
|
+
if (current)
|
|
212
|
+
fd.workflow.initialize(current);
|
|
213
|
+
onBaseline?.();
|
|
214
|
+
}
|
|
215
|
+
return result;
|
|
216
|
+
}
|
|
217
|
+
finally {
|
|
218
|
+
release?.();
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
// The promise never rejects, whatever the executor does.
|
|
222
|
+
const settle = (command, options) => {
|
|
223
|
+
try {
|
|
224
|
+
return run(command, options);
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
logger.error('runCommand failed:', error);
|
|
228
|
+
return {
|
|
229
|
+
ok: false,
|
|
230
|
+
code: 'INTERNAL_ERROR',
|
|
231
|
+
error: `The command failed: ${error instanceof Error ? error.message : String(error)}`
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
return (command, options) => new Promise((resolve) => {
|
|
236
|
+
if (isDestroyed())
|
|
237
|
+
return resolve(gone());
|
|
238
|
+
let settled = false;
|
|
239
|
+
let unregister = null;
|
|
240
|
+
const finish = (result) => {
|
|
241
|
+
if (settled)
|
|
242
|
+
return;
|
|
243
|
+
settled = true;
|
|
244
|
+
unregister?.();
|
|
245
|
+
resolve(result);
|
|
246
|
+
};
|
|
247
|
+
// Fires at once when the workflow is already loaded.
|
|
248
|
+
const stopWaiting = whenWorkflowLoaded(fd, () => finish(settle(command, options)));
|
|
249
|
+
if (!settled) {
|
|
250
|
+
unregister = registerCancel(() => {
|
|
251
|
+
stopWaiting();
|
|
252
|
+
finish(gone());
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
137
257
|
/**
|
|
138
258
|
* Mount the full FlowDrop App with navbar, sidebars, and workflow editor
|
|
139
259
|
*
|
|
@@ -159,7 +279,7 @@ function attachWebMCPToMount(fd, options, isDestroyed) {
|
|
|
159
279
|
* ```
|
|
160
280
|
*/
|
|
161
281
|
export async function mountFlowDropApp(container, options = {}) {
|
|
162
|
-
const { workflow, nodes, endpointConfig, portConfig, categories, height = '100vh', width = '100%', showNavbar = false, disableSidebar, configPlacement, consolePlacement, mode, editorMode, onEditorModeChange, playground, pipelineId, navbarTitle, navbarActions, branding, showSettings, showStatus, authProvider, eventHandlers, features: userFeatures, settings: initialSettings, colorScheme, draftStorageKey: customDraftKey, draftStorage, formatAdapters, workflowFormats, theme, settingsCategories, showSettingsSyncButton, showSettingsResetButton, instanceId, webmcp, host, contextMenu } = options;
|
|
282
|
+
const { workflow, nodes, endpointConfig, portConfig, categories, height = '100vh', width = '100%', showNavbar = false, disableSidebar, configPlacement, consolePlacement, mode, editorMode, onEditorModeChange, playground, pipelineId, navbarTitle, navbarActions, branding, showSettings, showStatus, authProvider, eventHandlers, features: userFeatures, settings: initialSettings, colorScheme, draftStorageKey: customDraftKey, draftStorage, formatAdapters, workflowFormats, workflowSettingsSchema, theme, settingsCategories, showSettingsSyncButton, showSettingsResetButton, instanceId, webmcp, host, contextMenu } = options;
|
|
163
283
|
// Per-instance state container — this is what allows multiple FlowDrop
|
|
164
284
|
// editors to coexist on one page without sharing workflow/history state.
|
|
165
285
|
const { fd, isDefault } = acquireInstance(instanceId);
|
|
@@ -239,6 +359,9 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
239
359
|
onSaveError: eventHandlers?.onSaveError,
|
|
240
360
|
onApiError: eventHandlers?.onApiError,
|
|
241
361
|
onWorkflowLoad: eventHandlers?.onWorkflowLoad,
|
|
362
|
+
onExternalEdit: eventHandlers?.onExternalEdit
|
|
363
|
+
? (node, link) => eventHandlers.onExternalEdit(node, link)
|
|
364
|
+
: undefined,
|
|
242
365
|
onBeforeSwap: eventHandlers?.onBeforeSwap,
|
|
243
366
|
onAfterSwap: eventHandlers?.onAfterSwap,
|
|
244
367
|
features,
|
|
@@ -247,6 +370,7 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
247
370
|
showSettingsSyncButton,
|
|
248
371
|
showSettingsResetButton,
|
|
249
372
|
workflowFormats,
|
|
373
|
+
workflowSettingsSchema,
|
|
250
374
|
contextMenu
|
|
251
375
|
}
|
|
252
376
|
});
|
|
@@ -295,6 +419,8 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
295
419
|
// its default `onSave` is `mountedApp.save()`.
|
|
296
420
|
let webmcpHandle;
|
|
297
421
|
let destroyed = false;
|
|
422
|
+
// Calls to runCommand still waiting for the workflow; settled on destroy.
|
|
423
|
+
const pendingRuns = new Set();
|
|
298
424
|
// Create the mounted app interface
|
|
299
425
|
const mountedApp = {
|
|
300
426
|
instance: fd,
|
|
@@ -305,6 +431,8 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
305
431
|
// Remove the agent-facing tools before anything else goes away.
|
|
306
432
|
destroyed = true;
|
|
307
433
|
webmcpHandle?.detach();
|
|
434
|
+
for (const cancel of [...pendingRuns])
|
|
435
|
+
cancel();
|
|
308
436
|
// Call onBeforeUnmount if provided
|
|
309
437
|
if (state.eventHandlers?.onBeforeUnmount) {
|
|
310
438
|
const currentWorkflow = fd.workflow.current;
|
|
@@ -355,6 +483,12 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
355
483
|
}
|
|
356
484
|
},
|
|
357
485
|
getWorkflow: () => fd.workflow.current,
|
|
486
|
+
runCommand: createRunCommand(fd, () => destroyed, (cancel) => {
|
|
487
|
+
pendingRuns.add(cancel);
|
|
488
|
+
return () => pendingRuns.delete(cancel);
|
|
489
|
+
},
|
|
490
|
+
// The re-baselined workflow is clean, so it is not a draft to restore.
|
|
491
|
+
() => state.draftManager?.markAsSaved()),
|
|
358
492
|
save: async () => {
|
|
359
493
|
return globalSaveWorkflow({
|
|
360
494
|
instance: fd,
|
|
@@ -462,16 +596,25 @@ export async function mountWorkflowEditor(container, options = {}) {
|
|
|
462
596
|
contextMenu
|
|
463
597
|
}
|
|
464
598
|
});
|
|
599
|
+
let destroyed = false;
|
|
600
|
+
const pendingRuns = new Set();
|
|
465
601
|
// Create the mounted app interface (simpler version)
|
|
466
602
|
const mountedApp = {
|
|
467
603
|
instance: fd,
|
|
468
604
|
destroy: () => {
|
|
605
|
+
destroyed = true;
|
|
606
|
+
for (const cancel of [...pendingRuns])
|
|
607
|
+
cancel();
|
|
469
608
|
releaseInstance(fd, isDefault);
|
|
470
609
|
unmount(svelteApp);
|
|
471
610
|
},
|
|
472
611
|
isDirty: () => fd.workflow.isDirty,
|
|
473
612
|
markAsSaved: () => fd.workflow.markAsSaved(),
|
|
474
613
|
getWorkflow: () => fd.workflow.current,
|
|
614
|
+
runCommand: createRunCommand(fd, () => destroyed, (cancel) => {
|
|
615
|
+
pendingRuns.add(cancel);
|
|
616
|
+
return () => pendingRuns.delete(cancel);
|
|
617
|
+
}),
|
|
475
618
|
save: async () => {
|
|
476
619
|
return globalSaveWorkflow({ instance: fd });
|
|
477
620
|
},
|
package/dist/types/events.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module types/events
|
|
8
8
|
*/
|
|
9
|
-
import type { Workflow, NodeExecutionInfo, WorkflowNode } from './index.js';
|
|
9
|
+
import type { Workflow, NodeExecutionInfo, WorkflowNode, ConfigValues, ExternalEditLink } from './index.js';
|
|
10
10
|
import type { SwapEventContext, SwapResult } from '../utils/nodeSwap.js';
|
|
11
11
|
/**
|
|
12
12
|
* Types of workflow changes
|
|
@@ -36,6 +36,23 @@ export type WorkflowChangeType = 'node_add' | 'node_remove' | 'node_move' | 'nod
|
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
38
|
export interface FlowDropEventHandlers {
|
|
39
|
+
/**
|
|
40
|
+
* Called instead of opening a node's externalEditLink. Resolve with the new
|
|
41
|
+
* config to write it into the node (one undo step), or with nothing to leave
|
|
42
|
+
* the node as it is.
|
|
43
|
+
*
|
|
44
|
+
* `node` and `link` are copies: changing them does not change the workflow;
|
|
45
|
+
* return the config instead. The returned config replaces the node's
|
|
46
|
+
* config; it is not merged, and it is copied, so changing the object later
|
|
47
|
+
* does not change the workflow either. Anything but a plain object is
|
|
48
|
+
* ignored. A rejection is logged and leaves the node unchanged. While the
|
|
49
|
+
* editor is read-only or locked the handler is still called but its result
|
|
50
|
+
* is not written (a console warning says so).
|
|
51
|
+
*
|
|
52
|
+
* @param node - The node whose external edit link was activated
|
|
53
|
+
* @param link - That node's resolved external edit link
|
|
54
|
+
*/
|
|
55
|
+
onExternalEdit?(node: WorkflowNode, link: ExternalEditLink): ConfigValues | void | Promise<ConfigValues | void>;
|
|
39
56
|
/**
|
|
40
57
|
* Called when workflow changes (any modification)
|
|
41
58
|
*
|
package/dist/types/index.d.ts
CHANGED
|
@@ -546,6 +546,9 @@ export interface ExternalEditLink {
|
|
|
546
546
|
/**
|
|
547
547
|
* Callback URL parameter name for FlowDrop to receive updates
|
|
548
548
|
* If set, the external form should redirect back with config updates
|
|
549
|
+
*
|
|
550
|
+
* @deprecated Nothing passes a callback URL, so this has no effect. Handle the
|
|
551
|
+
* round trip in the host with `FlowDropEventHandlers.onExternalEdit` instead.
|
|
549
552
|
*/
|
|
550
553
|
callbackUrlParam?: string;
|
|
551
554
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-handled external editing (`onExternalEdit`).
|
|
3
|
+
*
|
|
4
|
+
* Calls the host's handler for a node's external edit link and, when the host
|
|
5
|
+
* resolves with a config, writes it into the node as one undo step.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/externalEdit
|
|
8
|
+
*/
|
|
9
|
+
import type { ConfigValues, ExternalEditLink, Workflow, WorkflowNode } from '../types/index.js';
|
|
10
|
+
/** The slice of the workflow store this needs. */
|
|
11
|
+
export interface ExternalEditStore {
|
|
12
|
+
readonly current: Workflow | null;
|
|
13
|
+
updateNodeConfig(nodeId: string, updates: Partial<WorkflowNode>): void;
|
|
14
|
+
finalizeNodeConfig(): void;
|
|
15
|
+
}
|
|
16
|
+
export interface RunExternalEditOptions {
|
|
17
|
+
node: WorkflowNode;
|
|
18
|
+
link: ExternalEditLink;
|
|
19
|
+
/** The host's `onExternalEdit` handler. */
|
|
20
|
+
handler: (node: WorkflowNode, link: ExternalEditLink) => ConfigValues | void | Promise<ConfigValues | void>;
|
|
21
|
+
store: ExternalEditStore;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the editor accepts the result, asked when the handler resolves
|
|
24
|
+
* (the editor may have been locked while the host form was open). False
|
|
25
|
+
* when read-only or locked: the handler is still called (the link is shown
|
|
26
|
+
* there), but its result is not written. Defaults to writable.
|
|
27
|
+
*/
|
|
28
|
+
canWrite?: () => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Ids of nodes whose host form is open. A node already in it is skipped
|
|
31
|
+
* (the handler is not called again); the caller keeps the set alive.
|
|
32
|
+
*/
|
|
33
|
+
pending?: Set<string>;
|
|
34
|
+
/** Called with the node as written, e.g. to refresh the canvas. */
|
|
35
|
+
onWritten?: (node: WorkflowNode) => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Run the host handler and apply its result.
|
|
39
|
+
*
|
|
40
|
+
* - A config replaces the node's config (not merged): one undo step, workflow dirty.
|
|
41
|
+
* It is copied, so the host keeps no reference into the workflow.
|
|
42
|
+
* - Anything but a plain object (an array, a string, ...) is logged and dropped.
|
|
43
|
+
* - Nothing resolved: the node is left as it is.
|
|
44
|
+
* - A rejection is logged and swallowed.
|
|
45
|
+
* - A node deleted while the host form was open: the result is dropped.
|
|
46
|
+
* - A node whose host form is already open (`pending`): nothing happens.
|
|
47
|
+
*/
|
|
48
|
+
export declare function runExternalEdit(options: RunExternalEditOptions): Promise<void>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-handled external editing (`onExternalEdit`).
|
|
3
|
+
*
|
|
4
|
+
* Calls the host's handler for a node's external edit link and, when the host
|
|
5
|
+
* resolves with a config, writes it into the node as one undo step.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/externalEdit
|
|
8
|
+
*/
|
|
9
|
+
import { logger } from './logger.js';
|
|
10
|
+
/**
|
|
11
|
+
* Run the host handler and apply its result.
|
|
12
|
+
*
|
|
13
|
+
* - A config replaces the node's config (not merged): one undo step, workflow dirty.
|
|
14
|
+
* It is copied, so the host keeps no reference into the workflow.
|
|
15
|
+
* - Anything but a plain object (an array, a string, ...) is logged and dropped.
|
|
16
|
+
* - Nothing resolved: the node is left as it is.
|
|
17
|
+
* - A rejection is logged and swallowed.
|
|
18
|
+
* - A node deleted while the host form was open: the result is dropped.
|
|
19
|
+
* - A node whose host form is already open (`pending`): nothing happens.
|
|
20
|
+
*/
|
|
21
|
+
export async function runExternalEdit(options) {
|
|
22
|
+
const { node, link, handler, store, canWrite, pending, onWritten } = options;
|
|
23
|
+
if (pending?.has(node.id))
|
|
24
|
+
return;
|
|
25
|
+
pending?.add(node.id);
|
|
26
|
+
let result;
|
|
27
|
+
try {
|
|
28
|
+
result = await handler(node, link);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
logger.warn('onExternalEdit rejected; node left unchanged:', error);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
pending?.delete(node.id);
|
|
36
|
+
}
|
|
37
|
+
if (result === undefined || result === null)
|
|
38
|
+
return;
|
|
39
|
+
if (typeof result !== 'object' || Array.isArray(result)) {
|
|
40
|
+
logger.warn('onExternalEdit resolved with something other than a config object; ignored:', result);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (canWrite && !canWrite()) {
|
|
44
|
+
logger.warn('onExternalEdit result ignored: the editor is read-only or locked');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// A copy, so the host keeps no reference into the workflow (a Svelte host's
|
|
48
|
+
// `$state` proxy included).
|
|
49
|
+
const config = $state.snapshot(result);
|
|
50
|
+
const current = store.current?.nodes.find((n) => n.id === node.id);
|
|
51
|
+
if (!current) {
|
|
52
|
+
logger.debug(`onExternalEdit result dropped: node ${node.id} no longer exists`);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
// Close any open field-editing session first so this is a step of its own.
|
|
56
|
+
store.finalizeNodeConfig();
|
|
57
|
+
store.updateNodeConfig(node.id, { data: { ...current.data, config } });
|
|
58
|
+
store.finalizeNodeConfig();
|
|
59
|
+
const written = store.current?.nodes.find((n) => n.id === node.id);
|
|
60
|
+
if (written)
|
|
61
|
+
onWritten?.(written);
|
|
62
|
+
}
|
|
@@ -35,6 +35,16 @@ export interface AuthenticatedFetchOptions {
|
|
|
35
35
|
/** Base headers for requests not tied to a configured endpoint. */
|
|
36
36
|
baseHeaders?: Record<string, string>;
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Call the provider's `onUnauthorized()`, sharing one call between every
|
|
40
|
+
* request that gets a `401` while it is pending. A form whose autocomplete
|
|
41
|
+
* fields all look up their labels at once would otherwise refresh the token
|
|
42
|
+
* (or prompt for a login) once per field.
|
|
43
|
+
*
|
|
44
|
+
* @param authProvider - The provider whose session expired
|
|
45
|
+
* @returns Whether the provider refreshed its credentials
|
|
46
|
+
*/
|
|
47
|
+
export declare function refreshAuth(authProvider: AuthProvider): Promise<boolean>;
|
|
38
48
|
/**
|
|
39
49
|
* Perform an authenticated fetch with consistent 401/403 handling.
|
|
40
50
|
*
|
|
@@ -37,6 +37,28 @@ async function buildHeaders(init, opts) {
|
|
|
37
37
|
}
|
|
38
38
|
return headers;
|
|
39
39
|
}
|
|
40
|
+
const pendingRefreshes = new WeakMap();
|
|
41
|
+
/**
|
|
42
|
+
* Call the provider's `onUnauthorized()`, sharing one call between every
|
|
43
|
+
* request that gets a `401` while it is pending. A form whose autocomplete
|
|
44
|
+
* fields all look up their labels at once would otherwise refresh the token
|
|
45
|
+
* (or prompt for a login) once per field.
|
|
46
|
+
*
|
|
47
|
+
* @param authProvider - The provider whose session expired
|
|
48
|
+
* @returns Whether the provider refreshed its credentials
|
|
49
|
+
*/
|
|
50
|
+
export function refreshAuth(authProvider) {
|
|
51
|
+
if (!authProvider.onUnauthorized)
|
|
52
|
+
return Promise.resolve(false);
|
|
53
|
+
let pending = pendingRefreshes.get(authProvider);
|
|
54
|
+
if (!pending) {
|
|
55
|
+
pending = authProvider.onUnauthorized().finally(() => {
|
|
56
|
+
pendingRefreshes.delete(authProvider);
|
|
57
|
+
});
|
|
58
|
+
pendingRefreshes.set(authProvider, pending);
|
|
59
|
+
}
|
|
60
|
+
return pending;
|
|
61
|
+
}
|
|
40
62
|
/**
|
|
41
63
|
* Perform an authenticated fetch with consistent 401/403 handling.
|
|
42
64
|
*
|
|
@@ -50,7 +72,7 @@ export async function authenticatedFetch(url, init = {}, opts = {}) {
|
|
|
50
72
|
let response = await fetch(url, { ...init, headers });
|
|
51
73
|
// 401 → let the provider refresh, then retry once with fresh headers.
|
|
52
74
|
if (response.status === 401 && opts.authProvider?.onUnauthorized) {
|
|
53
|
-
const refreshed = await opts.authProvider
|
|
75
|
+
const refreshed = await refreshAuth(opts.authProvider);
|
|
54
76
|
if (refreshed) {
|
|
55
77
|
const retryHeaders = await buildHeaders(init, opts);
|
|
56
78
|
response = await fetch(url, { ...init, headers: retryHeaders });
|
|
@@ -8,6 +8,11 @@ export interface ExternalLinkInfo {
|
|
|
8
8
|
title?: string;
|
|
9
9
|
href: string;
|
|
10
10
|
newTab: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* When set, a plain left click calls this instead of following the link
|
|
13
|
+
* (the host opens its own form). Modified clicks still follow the href.
|
|
14
|
+
*/
|
|
15
|
+
onActivate?: () => void;
|
|
11
16
|
}
|
|
12
17
|
export interface InspectorContext {
|
|
13
18
|
/** The form tab currently shown. */
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "A drop-in visual workflow editor for any web application. You own the backend. You own the data. You own the orchestration.",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.15.1",
|
|
7
7
|
"author": "Shibin Das (D34dMan)",
|
|
8
8
|
"bugs": {
|
|
9
9
|
"url": "https://github.com/flowdrop-io/flowdrop/issues"
|