@flowdrop/flowdrop 2.16.0 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +95 -0
- package/README.md +6 -1
- package/dist/api/enhanced-client.d.ts +3 -1
- package/dist/api/enhanced-client.js +4 -2
- package/dist/commands/executor.js +9 -0
- package/dist/commands/storeIntegration.svelte.js +6 -0
- package/dist/commands/types.d.ts +8 -0
- package/dist/components/App.svelte +414 -105
- package/dist/components/App.svelte.d.ts +31 -0
- package/dist/components/CanvasToolbar.svelte +40 -3
- package/dist/components/CanvasToolbar.svelte.d.ts +5 -1
- package/dist/components/ConnectPortPicker.svelte +8 -4
- package/dist/components/DoctorMenu.svelte +208 -126
- package/dist/components/FlowDropZone.svelte +7 -1
- package/dist/components/FlowDropZone.svelte.d.ts +5 -0
- package/dist/components/ImpactConfirm.svelte +554 -0
- package/dist/components/ImpactConfirm.svelte.d.ts +22 -0
- package/dist/components/Input.svelte +8 -2
- package/dist/components/LockBanner.svelte +76 -0
- package/dist/components/LockBanner.svelte.d.ts +14 -0
- package/dist/components/LockFence.svelte +33 -0
- package/dist/components/LockFence.svelte.d.ts +19 -0
- package/dist/components/Navbar.svelte +77 -9
- package/dist/components/Navbar.svelte.d.ts +10 -0
- package/dist/components/NodeSidebar.svelte +36 -15
- package/dist/components/NodeSidebar.svelte.d.ts +2 -0
- package/dist/components/NodeSwapPicker.svelte +4 -14
- package/dist/components/RunBar.svelte +50 -3
- package/dist/components/RunBar.svelte.d.ts +5 -0
- package/dist/components/RunInputsDialog.svelte +198 -0
- package/dist/components/RunInputsDialog.svelte.d.ts +34 -0
- package/dist/components/Textarea.svelte +7 -1
- package/dist/components/WorkflowCompareDialog.svelte +177 -0
- package/dist/components/WorkflowCompareDialog.svelte.d.ts +10 -0
- package/dist/components/WorkflowEditor.svelte +120 -15
- package/dist/components/WorkflowEditor.svelte.d.ts +6 -0
- package/dist/components/WorkflowInterfaceEditor.svelte +17 -4
- package/dist/components/WorkflowInterfaceEntryCard.svelte +40 -7
- package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +2 -0
- package/dist/components/WorkflowPlaygroundSettings.svelte +9 -1
- package/dist/components/form/FieldFactory.svelte +13 -6
- package/dist/components/form/FormArray.svelte +0 -1
- package/dist/components/form/FormArrayRows.svelte +4 -4
- package/dist/components/form/FormCodeEditor.svelte +18 -2
- package/dist/components/form/FormMarkdownEditor.svelte +22 -8
- package/dist/components/form/FormTemplateEditor.svelte +17 -1
- package/dist/components/form/readOnly.d.ts +13 -0
- package/dist/components/form/readOnly.js +18 -0
- package/dist/components/nodes/CaptionNode.svelte +1 -0
- package/dist/components/nodes/NodeCard.svelte +2 -2
- package/dist/components/primitives/Checkbox.svelte +5 -1
- package/dist/components/primitives/Select.svelte +6 -1
- package/dist/components/primitives/Switch.svelte +5 -1
- package/dist/components/toast/DismissibleToast.svelte +25 -6
- package/dist/components/toast/DismissibleToast.svelte.d.ts +3 -0
- package/dist/config/endpoints.d.ts +7 -0
- package/dist/config/endpoints.js +2 -1
- package/dist/editor/connectCandidates.d.ts +3 -0
- package/dist/editor/connectCandidates.js +14 -5
- package/dist/editor/index.d.ts +2 -1
- package/dist/editor/index.js +1 -1
- package/dist/helpers/workflowEditorHelper.d.ts +15 -0
- package/dist/helpers/workflowEditorHelper.js +9 -0
- package/dist/index.d.ts +2 -0
- package/dist/messages/defaults.d.ts +145 -0
- package/dist/messages/defaults.js +139 -1
- package/dist/openapi/v1/openapi.yaml +492 -0
- package/dist/registry/nodeComponentRegistry.d.ts +5 -0
- package/dist/schemas/v1/workflow.schema.json +2 -0
- package/dist/services/draftStorage.d.ts +24 -10
- package/dist/services/draftStorage.js +60 -35
- package/dist/services/globalSave.d.ts +45 -10
- package/dist/services/globalSave.js +296 -32
- package/dist/services/impactGate.d.ts +38 -0
- package/dist/services/impactGate.js +72 -0
- package/dist/services/impactService.d.ts +45 -0
- package/dist/services/impactService.js +157 -0
- package/dist/services/runsService.d.ts +9 -0
- package/dist/services/runsService.js +13 -0
- package/dist/services/toastQueue.d.ts +9 -0
- package/dist/services/toastService.d.ts +4 -0
- package/dist/services/toastService.js +9 -3
- package/dist/services/workflowLaunchService.d.ts +6 -0
- package/dist/services/workflowLaunchService.js +5 -1
- package/dist/settings/index.d.ts +2 -2
- package/dist/settings/index.js +1 -1
- package/dist/stores/doctorStore.svelte.d.ts +24 -1
- package/dist/stores/doctorStore.svelte.js +105 -2
- package/dist/stores/historyStore.svelte.d.ts +12 -2
- package/dist/stores/historyStore.svelte.js +25 -2
- package/dist/stores/instanceContainer.svelte.d.ts +23 -0
- package/dist/stores/instanceContainer.svelte.js +32 -2
- package/dist/stores/lockStore.svelte.d.ts +39 -0
- package/dist/stores/lockStore.svelte.js +109 -0
- package/dist/stores/runController.svelte.d.ts +2 -0
- package/dist/stores/runController.svelte.js +27 -11
- package/dist/stores/saveConflictStore.svelte.d.ts +62 -0
- package/dist/stores/saveConflictStore.svelte.js +169 -0
- package/dist/stores/workflowStore.svelte.d.ts +14 -4
- package/dist/stores/workflowStore.svelte.js +55 -18
- package/dist/styles/base.css +6 -0
- package/dist/styles/toast.css +10 -1
- package/dist/svelte-app.d.ts +33 -0
- package/dist/svelte-app.js +178 -22
- package/dist/types/doctor.d.ts +3 -1
- package/dist/types/events.d.ts +37 -0
- package/dist/types/events.js +2 -0
- package/dist/types/impact.d.ts +77 -0
- package/dist/types/impact.js +7 -0
- package/dist/types/lock.d.ts +35 -0
- package/dist/types/lock.js +13 -0
- package/dist/types/navbar.d.ts +6 -0
- package/dist/types/settings.d.ts +31 -0
- package/dist/types/settings.js +132 -0
- package/dist/utils/draftRestore.d.ts +27 -0
- package/dist/utils/draftRestore.js +36 -0
- package/dist/utils/interfaceTags.js +4 -1
- package/dist/utils/links.d.ts +29 -0
- package/dist/utils/links.js +63 -0
- package/dist/utils/nodeSearch.d.ts +10 -0
- package/dist/utils/nodeSearch.js +37 -0
- package/dist/utils/runOffer.d.ts +21 -0
- package/dist/utils/runOffer.js +13 -0
- package/dist/utils/workflowCompare.d.ts +35 -0
- package/dist/utils/workflowCompare.js +84 -0
- package/dist/utils/workflowInterface.d.ts +26 -1
- package/dist/utils/workflowInterface.js +91 -11
- package/dist/webmcp/runtime.js +16 -3
- package/dist/webmcp/types.d.ts +11 -1
- package/package.json +3 -2
package/dist/svelte-app.js
CHANGED
|
@@ -13,12 +13,14 @@ import { DEFAULT_PORT_CONFIG } from './config/defaultPortConfig.js';
|
|
|
13
13
|
import { fetchPortConfig } from './services/portConfigApi.js';
|
|
14
14
|
import { fetchCategories } from './services/categoriesApi.js';
|
|
15
15
|
import { createFlowDropInstance, definedHostHooks, getDefaultInstance, DEFAULT_DRAFT_PREFIX } from './stores/instanceContainer.svelte.js';
|
|
16
|
-
import { DraftAutoSaveManager, getDraftStorageKey, migrateLegacyDraftKey, setDraftStorage, resolveDraftStorage, clearAllDrafts as clearAllDraftsFromStorage } from './services/draftStorage.js';
|
|
16
|
+
import { DraftAutoSaveManager, loadDraft, getDraftStorageKey, migrateLegacyDraftKey, setDraftStorage, resolveDraftStorage, clearAllDrafts as clearAllDraftsFromStorage } from './services/draftStorage.js';
|
|
17
17
|
import { mergeFeatures } from './types/events.js';
|
|
18
18
|
import { initializeSettings, getHostColorSchemeRegistration, releaseHostColorScheme, getBehaviorSettings, onSettingsChange } from './stores/settingsStore.svelte.js';
|
|
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 { draftOffer, draftTimeLabel } from './utils/draftRestore.js';
|
|
23
|
+
import { showInfo, showWarning } from './services/toastService.js';
|
|
22
24
|
import { parseCommand } from './commands/parser.js';
|
|
23
25
|
import { executeCommand } from './commands/executor.js';
|
|
24
26
|
import { isSessionLine } from './commands/session.js';
|
|
@@ -64,6 +66,16 @@ function releaseInstance(fd, isDefault) {
|
|
|
64
66
|
fd.destroy();
|
|
65
67
|
}
|
|
66
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Forget the lock of a released default instance. A lock belongs to the mount
|
|
71
|
+
* that set it; the next mount starts unlocked unless its own options say
|
|
72
|
+
* otherwise. Called after the component is unmounted, so a blur during the
|
|
73
|
+
* unmount cannot write into the instance once it is unlocked again.
|
|
74
|
+
*/
|
|
75
|
+
function releaseLock(fd, isDefault) {
|
|
76
|
+
if (isDefault)
|
|
77
|
+
fd.lock.clear();
|
|
78
|
+
}
|
|
67
79
|
/**
|
|
68
80
|
* Resolve endpoint config, port config and categories from mount options and
|
|
69
81
|
* apply them to the given instance (API context, port-compatibility checker,
|
|
@@ -254,6 +266,18 @@ function createRunCommand(fd, isDestroyed, registerCancel, onBaseline) {
|
|
|
254
266
|
}
|
|
255
267
|
});
|
|
256
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* What the default `onSave` tells an agent when the backend refused the save
|
|
271
|
+
* because things use the workflow, by what the person chose in the dialog.
|
|
272
|
+
*/
|
|
273
|
+
const SAVE_REFUSED_MESSAGES = {
|
|
274
|
+
kept: 'Nothing was saved: the change breaks places that use this workflow, so the server refused it. ' +
|
|
275
|
+
'The person was shown those places and kept editing; tell them, do not retry.',
|
|
276
|
+
copied: 'The workflow itself was not changed: the change breaks places that use it, so the server ' +
|
|
277
|
+
'refused it, and the person saved the draft as a new workflow instead.',
|
|
278
|
+
discarded: 'Nothing was saved: the change breaks places that use this workflow, so the server refused it, ' +
|
|
279
|
+
'and the person discarded the unsaved changes. The editor now holds the saved version.'
|
|
280
|
+
};
|
|
257
281
|
/**
|
|
258
282
|
* Mount the full FlowDrop App with navbar, sidebars, and workflow editor
|
|
259
283
|
*
|
|
@@ -279,7 +303,7 @@ function createRunCommand(fd, isDestroyed, registerCancel, onBaseline) {
|
|
|
279
303
|
* ```
|
|
280
304
|
*/
|
|
281
305
|
export async function mountFlowDropApp(container, 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, navbarEnd, showSettings, showStatus, authProvider, eventHandlers, features: userFeatures, settings: initialSettings, colorScheme, draftStorageKey: customDraftKey, draftStorage, formatAdapters, workflowFormats, workflowSettingsSchema, theme, settingsCategories, showSettingsSyncButton, showSettingsResetButton, instanceId, webmcp, host, contextMenu } = options;
|
|
306
|
+
const { workflow, nodes, endpointConfig, portConfig, categories, height = '100vh', width = '100%', showNavbar = false, disableSidebar, configPlacement, consolePlacement, mode, lock, onLockAction, editorMode, onEditorModeChange, playground, pipelineId, navbarTitle, navbarTitleLevel, navbarActions, branding, navbarEnd, showSettings, showStatus, authProvider, eventHandlers, features: userFeatures, settings: initialSettings, colorScheme, draftStorageKey: customDraftKey, draftStorage, formatAdapters, workflowFormats, workflowSettingsSchema, theme, settingsCategories, showSettingsSyncButton, showSettingsResetButton, instanceId, webmcp, host, contextMenu } = options;
|
|
283
307
|
// The host's element callback becomes a snippet: one empty host element, handed
|
|
284
308
|
// to the callback in `setup`, whose return value is the cleanup.
|
|
285
309
|
if (navbarEnd && showNavbar !== true) {
|
|
@@ -377,11 +401,14 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
377
401
|
configPlacement,
|
|
378
402
|
consolePlacement,
|
|
379
403
|
mode,
|
|
404
|
+
lock,
|
|
405
|
+
onLockAction,
|
|
380
406
|
editorMode,
|
|
381
407
|
onEditorModeChange,
|
|
382
408
|
playground,
|
|
383
409
|
pipelineId,
|
|
384
410
|
navbarTitle,
|
|
411
|
+
navbarTitleLevel,
|
|
385
412
|
navbarActions,
|
|
386
413
|
branding,
|
|
387
414
|
navbarEnd: navbarEndSnippet,
|
|
@@ -396,6 +423,8 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
396
423
|
onBeforeSave: eventHandlers?.onBeforeSave,
|
|
397
424
|
onAfterSave: eventHandlers?.onAfterSave,
|
|
398
425
|
onSaveError: eventHandlers?.onSaveError,
|
|
426
|
+
onSavedAsCopy: eventHandlers?.onSavedAsCopy,
|
|
427
|
+
onDiscardDraft: () => state.draftManager?.markAsSaved(),
|
|
399
428
|
onApiError: eventHandlers?.onApiError,
|
|
400
429
|
onWorkflowLoad: eventHandlers?.onWorkflowLoad,
|
|
401
430
|
onExternalEdit: eventHandlers?.onExternalEdit
|
|
@@ -416,6 +445,7 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
416
445
|
// Set up draft auto-save manager
|
|
417
446
|
let draftManager = null;
|
|
418
447
|
let unsubscribeDraftSettings = null;
|
|
448
|
+
let cancelDraftOffer = null;
|
|
419
449
|
if (features.autoSaveDraft) {
|
|
420
450
|
// Instance-scoped prefix: every instance (including the default) gets
|
|
421
451
|
// 'flowdrop:draft:<id>' sub-keys.
|
|
@@ -438,6 +468,82 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
438
468
|
storage: draftStorageAdapter
|
|
439
469
|
});
|
|
440
470
|
draftManager.start();
|
|
471
|
+
// Offer a draft left behind by an earlier session (a reload, a crash).
|
|
472
|
+
// Not for a brand-new workflow: its key is shared by every tab.
|
|
473
|
+
const offerKey = draftManager.getStorageKey();
|
|
474
|
+
if (mode !== 'readonly' && mode !== 'locked' && !offerKey.endsWith(':new')) {
|
|
475
|
+
const manager = draftManager;
|
|
476
|
+
const offerDraft = (loaded) => {
|
|
477
|
+
const draft = loadDraft(offerKey, draftStorageAdapter);
|
|
478
|
+
const offer = draftOffer(draft, loaded);
|
|
479
|
+
if (!draft)
|
|
480
|
+
return;
|
|
481
|
+
if (!offer) {
|
|
482
|
+
manager.clearDraft();
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
const text = fd.messages().drafts;
|
|
486
|
+
// The offer is open until Restore or Discard: keep the draft meanwhile.
|
|
487
|
+
const release = manager.holdDraft();
|
|
488
|
+
showWarning({
|
|
489
|
+
title: text.found({ time: draftTimeLabel(offer.savedAt) }),
|
|
490
|
+
body: offer.savedSince ? text.savedSince : undefined,
|
|
491
|
+
actions: [
|
|
492
|
+
{
|
|
493
|
+
label: text.restore,
|
|
494
|
+
primary: true,
|
|
495
|
+
onClick: () => {
|
|
496
|
+
// A locked workflow refuses the restore, and saving the draft
|
|
497
|
+
// now would write the saved version over it. Keep the hold, so
|
|
498
|
+
// the clean workflow does not delete the draft either: it is
|
|
499
|
+
// offered again when the workflow next opens.
|
|
500
|
+
if (fd.workflow.locked) {
|
|
501
|
+
showInfo(text.restoreLocked);
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
release();
|
|
505
|
+
fd.workflow.batchUpdate({
|
|
506
|
+
nodes: draft.workflow.nodes,
|
|
507
|
+
edges: draft.workflow.edges,
|
|
508
|
+
name: draft.workflow.name,
|
|
509
|
+
description: draft.workflow.description,
|
|
510
|
+
interface: draft.workflow.interface,
|
|
511
|
+
playground: draft.workflow.playground
|
|
512
|
+
});
|
|
513
|
+
manager.forceSave();
|
|
514
|
+
}
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
label: text.discard,
|
|
518
|
+
onClick: () => {
|
|
519
|
+
release();
|
|
520
|
+
manager.clearDraft();
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
]
|
|
524
|
+
}, { id: `flowdrop:draft-offer:${offerKey}` });
|
|
525
|
+
};
|
|
526
|
+
if (fd.lock.isLocked) {
|
|
527
|
+
// A locked editor cannot restore, so the offer waits for the lock to go.
|
|
528
|
+
// Meanwhile the workflow is clean and an autosave tick would delete the
|
|
529
|
+
// draft: hold it until then.
|
|
530
|
+
const releaseLockHold = manager.holdDraft();
|
|
531
|
+
const stopWatching = fd.lock.onChange((locked) => {
|
|
532
|
+
if (locked)
|
|
533
|
+
return;
|
|
534
|
+
stopWatching();
|
|
535
|
+
releaseLockHold();
|
|
536
|
+
cancelDraftOffer = whenWorkflowLoaded(fd, offerDraft);
|
|
537
|
+
});
|
|
538
|
+
cancelDraftOffer = () => {
|
|
539
|
+
stopWatching();
|
|
540
|
+
releaseLockHold();
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
else {
|
|
544
|
+
cancelDraftOffer = whenWorkflowLoaded(fd, offerDraft);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
441
547
|
// When the user opts out, also remove the draft already in storage.
|
|
442
548
|
unsubscribeDraftSettings = onSettingsChange((event) => {
|
|
443
549
|
if (event.category === 'behavior' &&
|
|
@@ -460,13 +566,57 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
460
566
|
let destroyed = false;
|
|
461
567
|
// Calls to runCommand still waiting for the workflow; settled on destroy.
|
|
462
568
|
const pendingRuns = new Set();
|
|
569
|
+
// Ask the browser to confirm leaving the page while there are unsaved changes.
|
|
570
|
+
let removeLeaveGuard;
|
|
571
|
+
if (features.confirmUnsavedLeave &&
|
|
572
|
+
mode !== 'readonly' &&
|
|
573
|
+
mode !== 'locked' &&
|
|
574
|
+
typeof window !== 'undefined') {
|
|
575
|
+
const onBeforeUnload = (event) => {
|
|
576
|
+
if (!fd.workflow.isDirty)
|
|
577
|
+
return;
|
|
578
|
+
event.preventDefault();
|
|
579
|
+
event.returnValue = '';
|
|
580
|
+
};
|
|
581
|
+
window.addEventListener('beforeunload', onBeforeUnload);
|
|
582
|
+
removeLeaveGuard = () => window.removeEventListener('beforeunload', onBeforeUnload);
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* The mount's Save (`app.save()`, the default WebMCP `onSave`). `onRefused` hears
|
|
586
|
+
* when the backend refused it because things use the workflow.
|
|
587
|
+
*/
|
|
588
|
+
const saveFromMount = (onRefused) => globalSaveWorkflow({
|
|
589
|
+
instance: fd,
|
|
590
|
+
onRefused,
|
|
591
|
+
// The refused-save answers reach the host from here too, as from the Save button.
|
|
592
|
+
eventHandlers: {
|
|
593
|
+
onSavedAsCopy: eventHandlers?.onSavedAsCopy,
|
|
594
|
+
onWorkflowLoad: eventHandlers?.onWorkflowLoad
|
|
595
|
+
},
|
|
596
|
+
onDiscardDraft: () => state.draftManager?.markAsSaved(),
|
|
597
|
+
onSaved: (saved) => {
|
|
598
|
+
// globalSaveWorkflow does not write the server-assigned ID back to the
|
|
599
|
+
// workflow store, so we cannot read it from the store here.
|
|
600
|
+
// Instead we use the savedWorkflow returned by the API directly.
|
|
601
|
+
// This migrates '<prefix>:new' to a unique per-workflow key
|
|
602
|
+
// immediately after the first save, preventing cross-tab collisions
|
|
603
|
+
// when multiple new workflows are open simultaneously.
|
|
604
|
+
if (state.draftManager && !customDraftKey && saved.id) {
|
|
605
|
+
state.draftManager.updateStorageKey(getDraftStorageKey(saved.id, undefined, fd.storagePrefix));
|
|
606
|
+
}
|
|
607
|
+
// A saved workflow has no draft
|
|
608
|
+
state.draftManager?.markAsSaved();
|
|
609
|
+
}
|
|
610
|
+
});
|
|
463
611
|
// Create the mounted app interface
|
|
464
612
|
const mountedApp = {
|
|
465
613
|
instance: fd,
|
|
614
|
+
setLock: (next) => fd.lock.set(next),
|
|
466
615
|
get webmcp() {
|
|
467
616
|
return webmcpHandle;
|
|
468
617
|
},
|
|
469
618
|
destroy: () => {
|
|
619
|
+
removeLeaveGuard?.();
|
|
470
620
|
// Remove the agent-facing tools before anything else goes away.
|
|
471
621
|
destroyed = true;
|
|
472
622
|
webmcpHandle?.detach();
|
|
@@ -487,6 +637,8 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
487
637
|
}
|
|
488
638
|
state.draftManager.stop();
|
|
489
639
|
}
|
|
640
|
+
// A draft offer still waiting for the workflow is no longer wanted
|
|
641
|
+
cancelDraftOffer?.();
|
|
490
642
|
// Stop listening for the draft opt-out setting
|
|
491
643
|
if (state.unsubscribeDraftSettings) {
|
|
492
644
|
state.unsubscribeDraftSettings();
|
|
@@ -501,6 +653,7 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
501
653
|
releaseInstance(fd, isDefault);
|
|
502
654
|
// Unmount Svelte app
|
|
503
655
|
unmount(state.svelteApp);
|
|
656
|
+
releaseLock(fd, isDefault);
|
|
504
657
|
},
|
|
505
658
|
isDirty: () => fd.workflow.isDirty,
|
|
506
659
|
markAsSaved: () => {
|
|
@@ -528,22 +681,7 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
528
681
|
},
|
|
529
682
|
// The re-baselined workflow is clean, so it is not a draft to restore.
|
|
530
683
|
() => state.draftManager?.markAsSaved()),
|
|
531
|
-
save: async () =>
|
|
532
|
-
return globalSaveWorkflow({
|
|
533
|
-
instance: fd,
|
|
534
|
-
onSaved: (saved) => {
|
|
535
|
-
// globalSaveWorkflow does not write the server-assigned ID back to the
|
|
536
|
-
// workflow store, so we cannot read it from the store here.
|
|
537
|
-
// Instead we use the savedWorkflow returned by the API directly.
|
|
538
|
-
// This migrates '<prefix>:new' to a unique per-workflow key
|
|
539
|
-
// immediately after the first save, preventing cross-tab collisions
|
|
540
|
-
// when multiple new workflows are open simultaneously.
|
|
541
|
-
if (state.draftManager && !customDraftKey && saved.id) {
|
|
542
|
-
state.draftManager.updateStorageKey(getDraftStorageKey(saved.id, undefined, fd.storagePrefix));
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
});
|
|
546
|
-
},
|
|
684
|
+
save: async () => saveFromMount(),
|
|
547
685
|
export: () => {
|
|
548
686
|
globalExportWorkflow({ instance: fd });
|
|
549
687
|
},
|
|
@@ -566,13 +704,24 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
566
704
|
// WebMCP is on: the chat panel's tool loop offers `save`, `run` and
|
|
567
705
|
// `run_status` through them, so the built-in assistant and a browser agent
|
|
568
706
|
// persist and run the same way.
|
|
569
|
-
const defaultOnSave = async () =>
|
|
570
|
-
|
|
571
|
-
|
|
707
|
+
const defaultOnSave = async () => {
|
|
708
|
+
// The dialog answers through the callback, before the save resolves.
|
|
709
|
+
const heard = {};
|
|
710
|
+
if (await saveFromMount((outcome) => (heard.refused = outcome)))
|
|
711
|
+
return undefined;
|
|
712
|
+
if (heard.refused) {
|
|
713
|
+
return {
|
|
714
|
+
ok: false,
|
|
715
|
+
code: 'WORKFLOW_IN_USE_BREAKING',
|
|
716
|
+
message: SAVE_REFUSED_MESSAGES[heard.refused]
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
return {
|
|
572
720
|
ok: false,
|
|
573
721
|
code: 'UNAVAILABLE',
|
|
574
722
|
message: 'Nothing was saved: the host cancelled the save or no workflow is loaded.'
|
|
575
723
|
};
|
|
724
|
+
};
|
|
576
725
|
// Hook keys are merged through `definedHostHooks` on both inputs, so an
|
|
577
726
|
// explicit `onSave: undefined` in either never shadows the default.
|
|
578
727
|
const webmcpGiven = webmcp === true || !webmcp ? {} : webmcp;
|
|
@@ -608,7 +757,7 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
608
757
|
* @returns Promise resolving to a MountedFlowDropApp instance
|
|
609
758
|
*/
|
|
610
759
|
export async function mountWorkflowEditor(container, options = {}) {
|
|
611
|
-
const { workflow, endpointConfig, portConfig, categories, authProvider, instanceId, builtinEditors, contextMenu } = options;
|
|
760
|
+
const { workflow, endpointConfig, portConfig, categories, authProvider, instanceId, builtinEditors, contextMenu, lock, onLockAction } = options;
|
|
612
761
|
// Per-instance state container (see mountFlowDropApp)
|
|
613
762
|
const { fd, isDefault } = acquireInstance(instanceId);
|
|
614
763
|
// Resolve and apply endpoint config, port config and categories to this
|
|
@@ -624,6 +773,10 @@ export async function mountWorkflowEditor(container, options = {}) {
|
|
|
624
773
|
if (workflow) {
|
|
625
774
|
fd.workflow.initialize(workflow);
|
|
626
775
|
}
|
|
776
|
+
// A lock does not stop `initialize`, so the order of the two does not matter.
|
|
777
|
+
if (lock !== undefined)
|
|
778
|
+
fd.lock.set(lock);
|
|
779
|
+
const unsubscribeLockAction = onLockAction ? fd.lock.onAction((id) => onLockAction(id)) : null;
|
|
627
780
|
// Create the Svelte component
|
|
628
781
|
const svelteApp = mount(WorkflowEditor, {
|
|
629
782
|
target: container,
|
|
@@ -640,12 +793,15 @@ export async function mountWorkflowEditor(container, options = {}) {
|
|
|
640
793
|
// Create the mounted app interface (simpler version)
|
|
641
794
|
const mountedApp = {
|
|
642
795
|
instance: fd,
|
|
796
|
+
setLock: (next) => fd.lock.set(next),
|
|
643
797
|
destroy: () => {
|
|
644
798
|
destroyed = true;
|
|
645
799
|
for (const cancel of [...pendingRuns])
|
|
646
800
|
cancel();
|
|
801
|
+
unsubscribeLockAction?.();
|
|
647
802
|
releaseInstance(fd, isDefault);
|
|
648
803
|
unmount(svelteApp);
|
|
804
|
+
releaseLock(fd, isDefault);
|
|
649
805
|
},
|
|
650
806
|
isDirty: () => fd.workflow.isDirty,
|
|
651
807
|
markAsSaved: () => fd.workflow.markAsSaved(),
|
package/dist/types/doctor.d.ts
CHANGED
|
@@ -20,10 +20,12 @@ export interface DoctorRemedy {
|
|
|
20
20
|
/**
|
|
21
21
|
* What the remedy needs from the person. Today `choices` (value => label)
|
|
22
22
|
* for a remedy that must be told which one (`replace_node_type`); the chosen
|
|
23
|
-
* value goes back as `params[<name>]`.
|
|
23
|
+
* value goes back as `params[<name>]`. `automatic: true` says the editor
|
|
24
|
+
* may apply this remedy by itself.
|
|
24
25
|
*/
|
|
25
26
|
params?: {
|
|
26
27
|
choices?: Record<string, string>;
|
|
28
|
+
automatic?: boolean;
|
|
27
29
|
} & Record<string, unknown>;
|
|
28
30
|
}
|
|
29
31
|
/** One finding on the draft. */
|
package/dist/types/events.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @module types/events
|
|
8
8
|
*/
|
|
9
9
|
import type { Workflow, NodeExecutionInfo, WorkflowNode, ConfigValues, ExternalEditLink } from './index.js';
|
|
10
|
+
import type { SavedCopy } from './impact.js';
|
|
10
11
|
import type { SwapEventContext, SwapResult } from '../utils/nodeSwap.js';
|
|
11
12
|
/**
|
|
12
13
|
* Types of workflow changes
|
|
@@ -91,6 +92,22 @@ export interface FlowDropEventHandlers {
|
|
|
91
92
|
* @param workflow - The saved workflow (may include server-assigned IDs)
|
|
92
93
|
*/
|
|
93
94
|
onAfterSave?: (workflow: Workflow) => Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Called after the refused save was saved as a copy instead ("Save as a copy"
|
|
97
|
+
* in the save dialog).
|
|
98
|
+
*
|
|
99
|
+
* The original workflow is unchanged and the editor still holds the draft.
|
|
100
|
+
* Without this handler the editor follows `copy.editorUrl` (when the backend
|
|
101
|
+
* sent one): it first marks the workflow as saved, so the leave prompt stays
|
|
102
|
+
* quiet, and drops the stored draft of the original. With no URL either, it
|
|
103
|
+
* shows a "saved a copy" toast and stays as it is. With this handler the host
|
|
104
|
+
* decides what happens next and the editor does nothing else. An error thrown
|
|
105
|
+
* here is logged and never counts as a failed save.
|
|
106
|
+
*
|
|
107
|
+
* @param copy - The new workflow: its id and editor URL, when the backend names them
|
|
108
|
+
* @param workflow - The draft that was copied
|
|
109
|
+
*/
|
|
110
|
+
onSavedAsCopy?: (copy: SavedCopy, workflow: Workflow) => void | Promise<void>;
|
|
94
111
|
/**
|
|
95
112
|
* Called when save fails
|
|
96
113
|
*
|
|
@@ -211,6 +228,17 @@ export interface FlowDropFeatures {
|
|
|
211
228
|
* @default true
|
|
212
229
|
*/
|
|
213
230
|
showToasts?: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Ask the browser to confirm before leaving the page while the workflow has
|
|
233
|
+
* unsaved changes.
|
|
234
|
+
*
|
|
235
|
+
* Applies to `mountFlowDropApp` only (not `mountWorkflowEditor`, whose host
|
|
236
|
+
* owns the page) and not to `readonly` or `locked` mounts. The browser shows
|
|
237
|
+
* its own wording. The listener is removed again on `destroy()`.
|
|
238
|
+
*
|
|
239
|
+
* @default true
|
|
240
|
+
*/
|
|
241
|
+
confirmUnsavedLeave?: boolean;
|
|
214
242
|
/**
|
|
215
243
|
* Enable node swap functionality
|
|
216
244
|
*
|
|
@@ -275,6 +303,15 @@ export interface FlowDropFeatures {
|
|
|
275
303
|
* @default true
|
|
276
304
|
*/
|
|
277
305
|
testMode?: boolean;
|
|
306
|
+
/**
|
|
307
|
+
* Offer a Run button in the canvas toolbar in Edit mode. It saves unsaved
|
|
308
|
+
* changes, then starts the workflow through `host.onRun` or the
|
|
309
|
+
* `workflows.run` endpoint and shows the run on the canvas. Drawn only for a
|
|
310
|
+
* saved workflow on an editable canvas whose backend can start a run.
|
|
311
|
+
*
|
|
312
|
+
* @default true
|
|
313
|
+
*/
|
|
314
|
+
runButton?: boolean;
|
|
278
315
|
/**
|
|
279
316
|
* Offer the Runs list in Test mode: a "Runs" control in the canvas toolbar
|
|
280
317
|
* listing the workflow's past runs (from `endpoints.pipelines.list`), where
|
package/dist/types/events.js
CHANGED
|
@@ -15,11 +15,13 @@ export const DEFAULT_FEATURES = {
|
|
|
15
15
|
autoSaveDraft: true,
|
|
16
16
|
autoSaveDraftInterval: 30000,
|
|
17
17
|
showToasts: true,
|
|
18
|
+
confirmUnsavedLeave: true,
|
|
18
19
|
enableNodeSwap: true,
|
|
19
20
|
builtinEditors: true,
|
|
20
21
|
console: true,
|
|
21
22
|
assistant: true,
|
|
22
23
|
testMode: true,
|
|
24
|
+
runButton: true,
|
|
23
25
|
runsList: true,
|
|
24
26
|
adminLinks: {}
|
|
25
27
|
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Impact types: what saving a draft would change for the things that use the
|
|
3
|
+
* workflow, as a backend reports it before the save.
|
|
4
|
+
*
|
|
5
|
+
* @module types/impact
|
|
6
|
+
*/
|
|
7
|
+
export type ImpactSeverity = 'breaks' | 'changes' | 'info';
|
|
8
|
+
/** One thing the save touches. */
|
|
9
|
+
export interface ImpactItem {
|
|
10
|
+
kind: string;
|
|
11
|
+
severity: ImpactSeverity;
|
|
12
|
+
label: string;
|
|
13
|
+
message: string;
|
|
14
|
+
/** Where to look at the affected thing, when the backend knows. */
|
|
15
|
+
url: string | null;
|
|
16
|
+
}
|
|
17
|
+
/** The answer of the impact check. */
|
|
18
|
+
export interface ImpactReport {
|
|
19
|
+
/** The editor asks before saving when this is set. */
|
|
20
|
+
confirm: boolean;
|
|
21
|
+
/** The level of the interface change, as the backend names it. */
|
|
22
|
+
interfaceLevel: string;
|
|
23
|
+
interfaceBreaking: boolean;
|
|
24
|
+
items: ImpactItem[];
|
|
25
|
+
/** The save is refused while things use the workflow. Absent from an older backend: `false`. */
|
|
26
|
+
refused?: boolean;
|
|
27
|
+
/** The backend's own words for the refusal, when it gives them. */
|
|
28
|
+
refusedMessage?: string | null;
|
|
29
|
+
/** Where to POST the draft to save it as a new workflow instead (`Save as a copy`). */
|
|
30
|
+
copyUrl?: string | null;
|
|
31
|
+
/** Renamed inputs and outputs, with the places that follow when the person agrees. */
|
|
32
|
+
renames?: ImpactRename[];
|
|
33
|
+
}
|
|
34
|
+
/** An interface input or output the draft renames. */
|
|
35
|
+
export interface ImpactRename {
|
|
36
|
+
direction: 'input' | 'output';
|
|
37
|
+
from: string;
|
|
38
|
+
to: string;
|
|
39
|
+
/** What uses the old name and is updated when the rename is followed. */
|
|
40
|
+
places: ImpactRenamePlace[];
|
|
41
|
+
}
|
|
42
|
+
/** One place that uses a renamed input or output. */
|
|
43
|
+
export interface ImpactRenamePlace {
|
|
44
|
+
kind: string;
|
|
45
|
+
label: string;
|
|
46
|
+
/** Where to look at the place, when the backend knows. */
|
|
47
|
+
url: string | null;
|
|
48
|
+
/** What the rename does to it, when the backend says. */
|
|
49
|
+
message?: string;
|
|
50
|
+
/** `false` when the place is switched off; absent when the backend does not say. */
|
|
51
|
+
enabled?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/** The new workflow a `Save as a copy` made. */
|
|
54
|
+
export interface SavedCopy {
|
|
55
|
+
/** The new workflow id, when the backend names it. */
|
|
56
|
+
id: string | null;
|
|
57
|
+
/** The editor URL of the copy, when the backend names it. */
|
|
58
|
+
editorUrl: string | null;
|
|
59
|
+
}
|
|
60
|
+
/** What the person decided in the impact dialog. Internal: nothing public takes or returns it. */
|
|
61
|
+
export type ImpactAnswer =
|
|
62
|
+
/** Save. `followRenames` is set only when the dialog listed renames. */
|
|
63
|
+
{
|
|
64
|
+
action: 'save';
|
|
65
|
+
followRenames?: boolean;
|
|
66
|
+
} | {
|
|
67
|
+
action: 'cancel';
|
|
68
|
+
}
|
|
69
|
+
/** The draft was saved as a new workflow. */
|
|
70
|
+
| {
|
|
71
|
+
action: 'copied';
|
|
72
|
+
copy: SavedCopy;
|
|
73
|
+
}
|
|
74
|
+
/** The unsaved edits were thrown away and the saved version was loaded. */
|
|
75
|
+
| {
|
|
76
|
+
action: 'discarded';
|
|
77
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor lock: why a workflow is read-only, and what the person may do about it.
|
|
3
|
+
*
|
|
4
|
+
* A host passes a lock (the `lock` mount option, or `app.setLock(...)`) while
|
|
5
|
+
* something stops the workflow from being edited, for example a workflow that
|
|
6
|
+
* live users depend on, or one a module manages. The editor then refuses every
|
|
7
|
+
* edit and shows the reasons and the actions in a banner above the canvas. An
|
|
8
|
+
* action is only a button: the host answers `onLockAction(id)`, and "Edit
|
|
9
|
+
* anyway" is just an action the host answers by removing the lock.
|
|
10
|
+
*
|
|
11
|
+
* @module types/lock
|
|
12
|
+
*/
|
|
13
|
+
/** One reason the workflow is locked. */
|
|
14
|
+
export interface EditorLockReason {
|
|
15
|
+
/** What kind of reason this is, for example `'in_use'` or `'managed'`. Free text; the editor does not interpret it. */
|
|
16
|
+
kind: string;
|
|
17
|
+
/** A plain sentence for the person. Shown as text, never as HTML. */
|
|
18
|
+
message: string;
|
|
19
|
+
/** Where to read more (for example the page that lists who uses the workflow). Only `http(s)` and site-relative links are drawn. */
|
|
20
|
+
url?: string | null;
|
|
21
|
+
}
|
|
22
|
+
/** One button on the lock banner. */
|
|
23
|
+
export interface EditorLockAction {
|
|
24
|
+
/** Handed to `onLockAction` when the button is pressed. */
|
|
25
|
+
id: string;
|
|
26
|
+
/** The button text. */
|
|
27
|
+
label: string;
|
|
28
|
+
/** Draw the button as the main one. */
|
|
29
|
+
primary?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** A lock on the editor. `null` (or no lock) means the editor is not locked. */
|
|
32
|
+
export interface EditorLock {
|
|
33
|
+
reasons: EditorLockReason[];
|
|
34
|
+
actions: EditorLockAction[];
|
|
35
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor lock: why a workflow is read-only, and what the person may do about it.
|
|
3
|
+
*
|
|
4
|
+
* A host passes a lock (the `lock` mount option, or `app.setLock(...)`) while
|
|
5
|
+
* something stops the workflow from being edited, for example a workflow that
|
|
6
|
+
* live users depend on, or one a module manages. The editor then refuses every
|
|
7
|
+
* edit and shows the reasons and the actions in a banner above the canvas. An
|
|
8
|
+
* action is only a button: the host answers `onLockAction(id)`, and "Edit
|
|
9
|
+
* anyway" is just an action the host answers by removing the lock.
|
|
10
|
+
*
|
|
11
|
+
* @module types/lock
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
package/dist/types/navbar.d.ts
CHANGED
|
@@ -10,6 +10,12 @@ export interface NavbarAction {
|
|
|
10
10
|
icon?: string;
|
|
11
11
|
variant?: 'primary' | 'secondary' | 'outline';
|
|
12
12
|
onclick?: (event: Event) => void;
|
|
13
|
+
/**
|
|
14
|
+
* The action is shown but cannot be used right now (Save on a locked
|
|
15
|
+
* workflow): it is dimmed, announced as disabled, and ignores clicks and
|
|
16
|
+
* the Save shortcut.
|
|
17
|
+
*/
|
|
18
|
+
disabled?: boolean;
|
|
13
19
|
/** If true, opens link in new tab with `rel="noopener noreferrer"`. */
|
|
14
20
|
external?: boolean;
|
|
15
21
|
/**
|
package/dist/types/settings.d.ts
CHANGED
|
@@ -321,6 +321,37 @@ export declare const DEFAULT_API_SETTINGS: ApiSettings;
|
|
|
321
321
|
* Complete default settings object
|
|
322
322
|
*/
|
|
323
323
|
export declare const DEFAULT_SETTINGS: FlowDropSettings;
|
|
324
|
+
/**
|
|
325
|
+
* Describes one editor setting: its value type, a short label, and the
|
|
326
|
+
* values it allows. Lets a host build a settings form or validate input
|
|
327
|
+
* without reading the TypeScript types.
|
|
328
|
+
*/
|
|
329
|
+
export interface SettingsFieldSchema {
|
|
330
|
+
type: 'boolean' | 'number' | 'string' | 'object';
|
|
331
|
+
label: string;
|
|
332
|
+
description?: string;
|
|
333
|
+
/** Allowed values of a string setting */
|
|
334
|
+
enum?: readonly string[];
|
|
335
|
+
/** Lowest allowed value of a number setting */
|
|
336
|
+
minimum?: number;
|
|
337
|
+
/** Highest allowed value of a number setting */
|
|
338
|
+
maximum?: number;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* One field schema per setting: the compiler flags a missing or an extra key.
|
|
342
|
+
* An optional setting (`theme.explicit`, an internal marker) has no schema.
|
|
343
|
+
*/
|
|
344
|
+
export type SettingsFieldSchemaMap = {
|
|
345
|
+
[C in keyof FlowDropSettings]: {
|
|
346
|
+
[K in keyof FlowDropSettings[C] as undefined extends FlowDropSettings[C][K] ? never : K]: SettingsFieldSchema;
|
|
347
|
+
};
|
|
348
|
+
};
|
|
349
|
+
/**
|
|
350
|
+
* A field schema for every key of {@link DEFAULT_SETTINGS}, by category.
|
|
351
|
+
* The nested width and zoom-tier settings are replaced as a whole, so they are
|
|
352
|
+
* plain `object` fields.
|
|
353
|
+
*/
|
|
354
|
+
export declare const SETTINGS_FIELD_SCHEMA: SettingsFieldSchemaMap;
|
|
324
355
|
/**
|
|
325
356
|
* Deep partial type for nested settings updates
|
|
326
357
|
*/
|