@flowdrop/flowdrop 2.16.0 → 2.17.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 +80 -0
- package/README.md +6 -1
- package/dist/components/App.svelte +212 -6
- package/dist/components/App.svelte.d.ts +2 -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/ImpactConfirm.svelte +341 -0
- package/dist/components/ImpactConfirm.svelte.d.ts +12 -0
- package/dist/components/Navbar.svelte +42 -3
- package/dist/components/Navbar.svelte.d.ts +4 -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 +36 -1
- 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/WorkflowCompareDialog.svelte +177 -0
- package/dist/components/WorkflowCompareDialog.svelte.d.ts +10 -0
- package/dist/components/WorkflowEditor.svelte +88 -6
- package/dist/components/WorkflowEditor.svelte.d.ts +6 -0
- package/dist/components/WorkflowInterfaceEditor.svelte +14 -4
- package/dist/components/WorkflowInterfaceEntryCard.svelte +19 -3
- package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +2 -0
- package/dist/components/nodes/NodeCard.svelte +2 -2
- 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 +1 -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 +1 -0
- package/dist/messages/defaults.d.ts +100 -0
- package/dist/messages/defaults.js +91 -1
- package/dist/services/draftStorage.d.ts +24 -10
- package/dist/services/draftStorage.js +60 -35
- package/dist/services/globalSave.d.ts +28 -10
- package/dist/services/globalSave.js +135 -31
- package/dist/services/impactGate.d.ts +34 -0
- package/dist/services/impactGate.js +70 -0
- package/dist/services/impactService.d.ts +28 -0
- package/dist/services/impactService.js +71 -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.js +3 -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/instanceContainer.svelte.d.ts +16 -0
- package/dist/stores/instanceContainer.svelte.js +22 -2
- package/dist/stores/saveConflictStore.svelte.d.ts +62 -0
- package/dist/stores/saveConflictStore.svelte.js +169 -0
- package/dist/stores/workflowStore.svelte.d.ts +7 -3
- package/dist/stores/workflowStore.svelte.js +14 -5
- package/dist/styles/toast.css +10 -1
- package/dist/svelte-app.d.ts +2 -0
- package/dist/svelte-app.js +74 -2
- package/dist/types/doctor.d.ts +3 -1
- package/dist/types/events.d.ts +20 -0
- package/dist/types/events.js +2 -0
- package/dist/types/impact.d.ts +25 -0
- package/dist/types/impact.js +7 -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/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/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 { 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';
|
|
@@ -279,7 +281,7 @@ function createRunCommand(fd, isDestroyed, registerCancel, onBaseline) {
|
|
|
279
281
|
* ```
|
|
280
282
|
*/
|
|
281
283
|
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;
|
|
284
|
+
const { workflow, nodes, endpointConfig, portConfig, categories, height = '100vh', width = '100%', showNavbar = false, disableSidebar, configPlacement, consolePlacement, mode, 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
285
|
// The host's element callback becomes a snippet: one empty host element, handed
|
|
284
286
|
// to the callback in `setup`, whose return value is the cleanup.
|
|
285
287
|
if (navbarEnd && showNavbar !== true) {
|
|
@@ -382,6 +384,7 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
382
384
|
playground,
|
|
383
385
|
pipelineId,
|
|
384
386
|
navbarTitle,
|
|
387
|
+
navbarTitleLevel,
|
|
385
388
|
navbarActions,
|
|
386
389
|
branding,
|
|
387
390
|
navbarEnd: navbarEndSnippet,
|
|
@@ -416,6 +419,7 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
416
419
|
// Set up draft auto-save manager
|
|
417
420
|
let draftManager = null;
|
|
418
421
|
let unsubscribeDraftSettings = null;
|
|
422
|
+
let cancelDraftOffer = null;
|
|
419
423
|
if (features.autoSaveDraft) {
|
|
420
424
|
// Instance-scoped prefix: every instance (including the default) gets
|
|
421
425
|
// 'flowdrop:draft:<id>' sub-keys.
|
|
@@ -438,6 +442,54 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
438
442
|
storage: draftStorageAdapter
|
|
439
443
|
});
|
|
440
444
|
draftManager.start();
|
|
445
|
+
// Offer a draft left behind by an earlier session (a reload, a crash).
|
|
446
|
+
// Not for a brand-new workflow: its key is shared by every tab.
|
|
447
|
+
const offerKey = draftManager.getStorageKey();
|
|
448
|
+
if (mode !== 'readonly' && mode !== 'locked' && !offerKey.endsWith(':new')) {
|
|
449
|
+
const manager = draftManager;
|
|
450
|
+
cancelDraftOffer = whenWorkflowLoaded(fd, (loaded) => {
|
|
451
|
+
const draft = loadDraft(offerKey, draftStorageAdapter);
|
|
452
|
+
const offer = draftOffer(draft, loaded);
|
|
453
|
+
if (!draft)
|
|
454
|
+
return;
|
|
455
|
+
if (!offer) {
|
|
456
|
+
manager.clearDraft();
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
const text = fd.messages().drafts;
|
|
460
|
+
// The offer is open until Restore or Discard: keep the draft meanwhile.
|
|
461
|
+
const release = manager.holdDraft();
|
|
462
|
+
showWarning({
|
|
463
|
+
title: text.found({ time: draftTimeLabel(offer.savedAt) }),
|
|
464
|
+
body: offer.savedSince ? text.savedSince : undefined,
|
|
465
|
+
actions: [
|
|
466
|
+
{
|
|
467
|
+
label: text.restore,
|
|
468
|
+
primary: true,
|
|
469
|
+
onClick: () => {
|
|
470
|
+
release();
|
|
471
|
+
fd.workflow.batchUpdate({
|
|
472
|
+
nodes: draft.workflow.nodes,
|
|
473
|
+
edges: draft.workflow.edges,
|
|
474
|
+
name: draft.workflow.name,
|
|
475
|
+
description: draft.workflow.description,
|
|
476
|
+
interface: draft.workflow.interface,
|
|
477
|
+
playground: draft.workflow.playground
|
|
478
|
+
});
|
|
479
|
+
manager.forceSave();
|
|
480
|
+
}
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
label: text.discard,
|
|
484
|
+
onClick: () => {
|
|
485
|
+
release();
|
|
486
|
+
manager.clearDraft();
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
]
|
|
490
|
+
}, { id: `flowdrop:draft-offer:${offerKey}` });
|
|
491
|
+
});
|
|
492
|
+
}
|
|
441
493
|
// When the user opts out, also remove the draft already in storage.
|
|
442
494
|
unsubscribeDraftSettings = onSettingsChange((event) => {
|
|
443
495
|
if (event.category === 'behavior' &&
|
|
@@ -460,6 +512,21 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
460
512
|
let destroyed = false;
|
|
461
513
|
// Calls to runCommand still waiting for the workflow; settled on destroy.
|
|
462
514
|
const pendingRuns = new Set();
|
|
515
|
+
// Ask the browser to confirm leaving the page while there are unsaved changes.
|
|
516
|
+
let removeLeaveGuard;
|
|
517
|
+
if (features.confirmUnsavedLeave &&
|
|
518
|
+
mode !== 'readonly' &&
|
|
519
|
+
mode !== 'locked' &&
|
|
520
|
+
typeof window !== 'undefined') {
|
|
521
|
+
const onBeforeUnload = (event) => {
|
|
522
|
+
if (!fd.workflow.isDirty)
|
|
523
|
+
return;
|
|
524
|
+
event.preventDefault();
|
|
525
|
+
event.returnValue = '';
|
|
526
|
+
};
|
|
527
|
+
window.addEventListener('beforeunload', onBeforeUnload);
|
|
528
|
+
removeLeaveGuard = () => window.removeEventListener('beforeunload', onBeforeUnload);
|
|
529
|
+
}
|
|
463
530
|
// Create the mounted app interface
|
|
464
531
|
const mountedApp = {
|
|
465
532
|
instance: fd,
|
|
@@ -467,6 +534,7 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
467
534
|
return webmcpHandle;
|
|
468
535
|
},
|
|
469
536
|
destroy: () => {
|
|
537
|
+
removeLeaveGuard?.();
|
|
470
538
|
// Remove the agent-facing tools before anything else goes away.
|
|
471
539
|
destroyed = true;
|
|
472
540
|
webmcpHandle?.detach();
|
|
@@ -487,6 +555,8 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
487
555
|
}
|
|
488
556
|
state.draftManager.stop();
|
|
489
557
|
}
|
|
558
|
+
// A draft offer still waiting for the workflow is no longer wanted
|
|
559
|
+
cancelDraftOffer?.();
|
|
490
560
|
// Stop listening for the draft opt-out setting
|
|
491
561
|
if (state.unsubscribeDraftSettings) {
|
|
492
562
|
state.unsubscribeDraftSettings();
|
|
@@ -541,6 +611,8 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
541
611
|
if (state.draftManager && !customDraftKey && saved.id) {
|
|
542
612
|
state.draftManager.updateStorageKey(getDraftStorageKey(saved.id, undefined, fd.storagePrefix));
|
|
543
613
|
}
|
|
614
|
+
// A saved workflow has no draft
|
|
615
|
+
state.draftManager?.markAsSaved();
|
|
544
616
|
}
|
|
545
617
|
});
|
|
546
618
|
},
|
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
|
@@ -211,6 +211,17 @@ export interface FlowDropFeatures {
|
|
|
211
211
|
* @default true
|
|
212
212
|
*/
|
|
213
213
|
showToasts?: boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Ask the browser to confirm before leaving the page while the workflow has
|
|
216
|
+
* unsaved changes.
|
|
217
|
+
*
|
|
218
|
+
* Applies to `mountFlowDropApp` only (not `mountWorkflowEditor`, whose host
|
|
219
|
+
* owns the page) and not to `readonly` or `locked` mounts. The browser shows
|
|
220
|
+
* its own wording. The listener is removed again on `destroy()`.
|
|
221
|
+
*
|
|
222
|
+
* @default true
|
|
223
|
+
*/
|
|
224
|
+
confirmUnsavedLeave?: boolean;
|
|
214
225
|
/**
|
|
215
226
|
* Enable node swap functionality
|
|
216
227
|
*
|
|
@@ -275,6 +286,15 @@ export interface FlowDropFeatures {
|
|
|
275
286
|
* @default true
|
|
276
287
|
*/
|
|
277
288
|
testMode?: boolean;
|
|
289
|
+
/**
|
|
290
|
+
* Offer a Run button in the canvas toolbar in Edit mode. It saves unsaved
|
|
291
|
+
* changes, then starts the workflow through `host.onRun` or the
|
|
292
|
+
* `workflows.run` endpoint and shows the run on the canvas. Drawn only for a
|
|
293
|
+
* saved workflow on an editable canvas whose backend can start a run.
|
|
294
|
+
*
|
|
295
|
+
* @default true
|
|
296
|
+
*/
|
|
297
|
+
runButton?: boolean;
|
|
278
298
|
/**
|
|
279
299
|
* Offer the Runs list in Test mode: a "Runs" control in the canvas toolbar
|
|
280
300
|
* 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,25 @@
|
|
|
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
|
+
}
|
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
|
*/
|
package/dist/types/settings.js
CHANGED
|
@@ -130,6 +130,138 @@ export const DEFAULT_SETTINGS = {
|
|
|
130
130
|
behavior: DEFAULT_BEHAVIOR_SETTINGS,
|
|
131
131
|
api: DEFAULT_API_SETTINGS
|
|
132
132
|
};
|
|
133
|
+
const SURFACE_PLACEMENTS = [
|
|
134
|
+
'sidebar',
|
|
135
|
+
'modal',
|
|
136
|
+
'below'
|
|
137
|
+
];
|
|
138
|
+
/**
|
|
139
|
+
* A field schema for every key of {@link DEFAULT_SETTINGS}, by category.
|
|
140
|
+
* The nested width and zoom-tier settings are replaced as a whole, so they are
|
|
141
|
+
* plain `object` fields.
|
|
142
|
+
*/
|
|
143
|
+
export const SETTINGS_FIELD_SCHEMA = {
|
|
144
|
+
theme: {
|
|
145
|
+
preference: {
|
|
146
|
+
type: 'string',
|
|
147
|
+
label: 'Colour scheme',
|
|
148
|
+
description: 'Light, dark, follow the system, or follow the embedding page',
|
|
149
|
+
enum: ['light', 'dark', 'auto', 'host']
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
editor: {
|
|
153
|
+
showGrid: { type: 'boolean', label: 'Show grid' },
|
|
154
|
+
snapToGrid: { type: 'boolean', label: 'Snap to grid' },
|
|
155
|
+
gridSize: {
|
|
156
|
+
type: 'number',
|
|
157
|
+
label: 'Grid size',
|
|
158
|
+
description: 'In pixels; 10 or 20',
|
|
159
|
+
minimum: 10,
|
|
160
|
+
maximum: 20
|
|
161
|
+
},
|
|
162
|
+
layoutGapX: {
|
|
163
|
+
type: 'number',
|
|
164
|
+
label: 'Layout gap across',
|
|
165
|
+
description: 'Pixels between cards side by side, a multiple of 20',
|
|
166
|
+
minimum: 0
|
|
167
|
+
},
|
|
168
|
+
layoutGapY: {
|
|
169
|
+
type: 'number',
|
|
170
|
+
label: 'Layout gap down',
|
|
171
|
+
description: 'Pixels between stacked cards, a multiple of 20',
|
|
172
|
+
minimum: 0
|
|
173
|
+
},
|
|
174
|
+
showMinimap: { type: 'boolean', label: 'Show minimap' },
|
|
175
|
+
defaultZoom: { type: 'number', label: 'Default zoom', description: '1 is 100%', minimum: 0 },
|
|
176
|
+
fitViewOnLoad: { type: 'boolean', label: 'Fit workflow to view on load' },
|
|
177
|
+
proximityConnect: { type: 'boolean', label: 'Connect nodes by proximity' },
|
|
178
|
+
proximityConnectDistance: {
|
|
179
|
+
type: 'number',
|
|
180
|
+
label: 'Proximity distance',
|
|
181
|
+
description: 'In pixels',
|
|
182
|
+
minimum: 0
|
|
183
|
+
},
|
|
184
|
+
showNodeDescriptions: { type: 'boolean', label: 'Show node descriptions' },
|
|
185
|
+
zoomTiers: {
|
|
186
|
+
type: 'object',
|
|
187
|
+
label: 'Zoom tiers',
|
|
188
|
+
description: 'The zoom at which each tier (full, outline, glyph, map) starts'
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
ui: {
|
|
192
|
+
sidebarWidth: {
|
|
193
|
+
type: 'number',
|
|
194
|
+
label: 'Sidebar width',
|
|
195
|
+
description: 'Deprecated; use sidebar widths',
|
|
196
|
+
minimum: 0
|
|
197
|
+
},
|
|
198
|
+
sidebarWidths: {
|
|
199
|
+
type: 'object',
|
|
200
|
+
label: 'Sidebar widths',
|
|
201
|
+
description: 'Width per tab, in pixels'
|
|
202
|
+
},
|
|
203
|
+
sheetWidths: {
|
|
204
|
+
type: 'object',
|
|
205
|
+
label: 'Sheet widths',
|
|
206
|
+
description: 'Width per sheet, in pixels'
|
|
207
|
+
},
|
|
208
|
+
sidebarCollapsed: { type: 'boolean', label: 'Collapse sidebar' },
|
|
209
|
+
compactMode: { type: 'boolean', label: 'Compact mode' },
|
|
210
|
+
theme: {
|
|
211
|
+
type: 'string',
|
|
212
|
+
label: 'Theme',
|
|
213
|
+
enum: ['classic', 'minimal', 'drafter', 'graphite']
|
|
214
|
+
},
|
|
215
|
+
consoleOpen: { type: 'boolean', label: 'Open the console' },
|
|
216
|
+
consoleHeight: {
|
|
217
|
+
type: 'number',
|
|
218
|
+
label: 'Console height',
|
|
219
|
+
description: 'In pixels',
|
|
220
|
+
minimum: 0
|
|
221
|
+
},
|
|
222
|
+
bottomPanelTab: {
|
|
223
|
+
type: 'string',
|
|
224
|
+
label: 'Bottom panel tab',
|
|
225
|
+
enum: ['console', 'chat']
|
|
226
|
+
},
|
|
227
|
+
configPlacement: {
|
|
228
|
+
type: 'string',
|
|
229
|
+
label: 'Configuration panel placement',
|
|
230
|
+
enum: SURFACE_PLACEMENTS
|
|
231
|
+
},
|
|
232
|
+
consolePlacement: { type: 'string', label: 'Console placement', enum: SURFACE_PLACEMENTS }
|
|
233
|
+
},
|
|
234
|
+
behavior: {
|
|
235
|
+
autoSave: { type: 'boolean', label: 'Auto-save' },
|
|
236
|
+
autoSaveInterval: {
|
|
237
|
+
type: 'number',
|
|
238
|
+
label: 'Auto-save interval',
|
|
239
|
+
description: 'In milliseconds',
|
|
240
|
+
minimum: 0
|
|
241
|
+
},
|
|
242
|
+
storeDraftsInBrowser: { type: 'boolean', label: 'Keep drafts in the browser' },
|
|
243
|
+
undoHistoryLimit: { type: 'number', label: 'Undo history limit', minimum: 0 },
|
|
244
|
+
confirmDelete: { type: 'boolean', label: 'Confirm before deleting' },
|
|
245
|
+
chatMode: {
|
|
246
|
+
type: 'string',
|
|
247
|
+
label: 'Assistant mode',
|
|
248
|
+
enum: ['tools', 'dsl']
|
|
249
|
+
},
|
|
250
|
+
chatAutoRetry: { type: 'boolean', label: 'Retry failed assistant changes' },
|
|
251
|
+
chatAllowLayoutChanges: { type: 'boolean', label: 'Let the assistant move nodes' }
|
|
252
|
+
},
|
|
253
|
+
api: {
|
|
254
|
+
timeout: {
|
|
255
|
+
type: 'number',
|
|
256
|
+
label: 'Request timeout',
|
|
257
|
+
description: 'In milliseconds',
|
|
258
|
+
minimum: 0
|
|
259
|
+
},
|
|
260
|
+
retryEnabled: { type: 'boolean', label: 'Retry failed requests' },
|
|
261
|
+
retryAttempts: { type: 'number', label: 'Retry attempts', minimum: 0 },
|
|
262
|
+
cacheEnabled: { type: 'boolean', label: 'Cache responses' }
|
|
263
|
+
}
|
|
264
|
+
};
|
|
133
265
|
// =========================================================================
|
|
134
266
|
// Settings Persistence Types
|
|
135
267
|
// =========================================================================
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decides whether a stored draft is worth offering back to the user.
|
|
3
|
+
*
|
|
4
|
+
* Pure: the mount reads the draft and the loaded workflow, asks here, and
|
|
5
|
+
* shows the Restore / Discard toast only when this returns an offer.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/draftRestore
|
|
8
|
+
*/
|
|
9
|
+
import { type loadDraft } from '../services/draftStorage.js';
|
|
10
|
+
import type { Workflow } from '../types/index.js';
|
|
11
|
+
type StoredDraft = NonNullable<ReturnType<typeof loadDraft>>;
|
|
12
|
+
/** What the Restore / Discard toast needs to know about a draft. */
|
|
13
|
+
export interface DraftOffer {
|
|
14
|
+
/** ISO time the draft was written */
|
|
15
|
+
savedAt: string;
|
|
16
|
+
/** The workflow was saved after this draft started, so restoring overwrites that save */
|
|
17
|
+
savedSince: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The offer for a draft, or null when there is nothing to offer: no draft, no
|
|
21
|
+
* loaded workflow, a draft of another workflow, or a draft that matches what
|
|
22
|
+
* is loaded.
|
|
23
|
+
*/
|
|
24
|
+
export declare function draftOffer(draft: StoredDraft | null, loaded: Workflow | null): DraftOffer | null;
|
|
25
|
+
/** Time of day for a draft written today, otherwise the date and time. */
|
|
26
|
+
export declare function draftTimeLabel(savedAt: string, now?: Date): string;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decides whether a stored draft is worth offering back to the user.
|
|
3
|
+
*
|
|
4
|
+
* Pure: the mount reads the draft and the loaded workflow, asks here, and
|
|
5
|
+
* shows the Restore / Discard toast only when this returns an offer.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/draftRestore
|
|
8
|
+
*/
|
|
9
|
+
import { draftFingerprint } from '../services/draftStorage.js';
|
|
10
|
+
/**
|
|
11
|
+
* The offer for a draft, or null when there is nothing to offer: no draft, no
|
|
12
|
+
* loaded workflow, a draft of another workflow, or a draft that matches what
|
|
13
|
+
* is loaded.
|
|
14
|
+
*/
|
|
15
|
+
export function draftOffer(draft, loaded) {
|
|
16
|
+
if (!draft || !loaded)
|
|
17
|
+
return null;
|
|
18
|
+
if (draft.workflow.id !== loaded.id)
|
|
19
|
+
return null;
|
|
20
|
+
if (draftFingerprint(draft.workflow) === draftFingerprint(loaded))
|
|
21
|
+
return null;
|
|
22
|
+
const base = draft.metadata.baseRevision;
|
|
23
|
+
return {
|
|
24
|
+
savedAt: draft.metadata.savedAt,
|
|
25
|
+
savedSince: base !== undefined && base !== String(loaded.revision)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Time of day for a draft written today, otherwise the date and time. */
|
|
29
|
+
export function draftTimeLabel(savedAt, now = new Date()) {
|
|
30
|
+
const when = new Date(savedAt);
|
|
31
|
+
if (Number.isNaN(when.getTime()))
|
|
32
|
+
return savedAt;
|
|
33
|
+
return when.toDateString() === now.toDateString()
|
|
34
|
+
? when.toLocaleTimeString()
|
|
35
|
+
: when.toLocaleString();
|
|
36
|
+
}
|
|
@@ -178,7 +178,10 @@ export function exposePortAsEntry(workflow, target, id) {
|
|
|
178
178
|
const candidate = exposableCandidate(workflow, target.nodeId, target.direction, target.portId);
|
|
179
179
|
if (!candidate)
|
|
180
180
|
return null;
|
|
181
|
-
const entry = {
|
|
181
|
+
const entry = {
|
|
182
|
+
...entryFromBindablePort(candidate, [], workflow, target.direction),
|
|
183
|
+
id: trimmed
|
|
184
|
+
};
|
|
182
185
|
return {
|
|
183
186
|
interface: withSide(workflow, target.direction, [
|
|
184
187
|
...entriesOf(workflow, target.direction),
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Palette search for node types: matches name, tags (keywords) and description,
|
|
3
|
+
* and orders matches so exact name and keyword hits come first.
|
|
4
|
+
*/
|
|
5
|
+
import type { NodeMetadata } from '../types/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Filter and rank node types for a search query. A blank query returns the
|
|
8
|
+
* input unchanged. Equal scores keep the input (API) order.
|
|
9
|
+
*/
|
|
10
|
+
export declare function searchNodeTypes(nodes: NodeMetadata[], query: string): NodeMetadata[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Lower is better; null means no match. */
|
|
2
|
+
function scoreNode(node, query) {
|
|
3
|
+
const name = node.name.toLowerCase();
|
|
4
|
+
const tags = (node.tags ?? []).map((tag) => tag.toLowerCase());
|
|
5
|
+
if (name === query)
|
|
6
|
+
return 0;
|
|
7
|
+
if (tags.includes(query))
|
|
8
|
+
return 1;
|
|
9
|
+
if (name.startsWith(query))
|
|
10
|
+
return 2;
|
|
11
|
+
if (name.split(/\s+/).some((word) => word.startsWith(query)))
|
|
12
|
+
return 3;
|
|
13
|
+
if (name.includes(query))
|
|
14
|
+
return 4;
|
|
15
|
+
if (tags.some((tag) => tag.includes(query)))
|
|
16
|
+
return 5;
|
|
17
|
+
if ((node.description ?? '').toLowerCase().includes(query))
|
|
18
|
+
return 6;
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Filter and rank node types for a search query. A blank query returns the
|
|
23
|
+
* input unchanged. Equal scores keep the input (API) order.
|
|
24
|
+
*/
|
|
25
|
+
export function searchNodeTypes(nodes, query) {
|
|
26
|
+
const needle = query.trim().toLowerCase();
|
|
27
|
+
if (!needle)
|
|
28
|
+
return nodes;
|
|
29
|
+
const scored = [];
|
|
30
|
+
nodes.forEach((node, index) => {
|
|
31
|
+
const score = scoreNode(node, needle);
|
|
32
|
+
if (score !== null)
|
|
33
|
+
scored.push({ node, score, index });
|
|
34
|
+
});
|
|
35
|
+
scored.sort((a, b) => a.score - b.score || a.index - b.index);
|
|
36
|
+
return scored.map((entry) => entry.node);
|
|
37
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the editor offers a Run button in Edit mode.
|
|
3
|
+
*
|
|
4
|
+
* @module utils/runOffer
|
|
5
|
+
*/
|
|
6
|
+
export interface RunOfferState {
|
|
7
|
+
/** `features.runButton` (default on). */
|
|
8
|
+
runButton: boolean | undefined;
|
|
9
|
+
/** The canvas is editable (`mode: 'edit'`). */
|
|
10
|
+
canvasEditable: boolean;
|
|
11
|
+
/** A run-history view of one pipeline, not the editor's workflow. */
|
|
12
|
+
pipelineId: string | undefined;
|
|
13
|
+
/** The id of the saved workflow, if it has one. */
|
|
14
|
+
workflowId: string | undefined;
|
|
15
|
+
/** The host supplied an `onRun` hook. */
|
|
16
|
+
hostCanRun: boolean;
|
|
17
|
+
/** The backend exposes the `workflows.run` endpoint. */
|
|
18
|
+
backendCanRun: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** True when a Run button makes sense: editable, saved, and something can start the run. */
|
|
21
|
+
export declare function canOfferRun(state: RunOfferState): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the editor offers a Run button in Edit mode.
|
|
3
|
+
*
|
|
4
|
+
* @module utils/runOffer
|
|
5
|
+
*/
|
|
6
|
+
/** True when a Run button makes sense: editable, saved, and something can start the run. */
|
|
7
|
+
export function canOfferRun(state) {
|
|
8
|
+
return (state.runButton !== false &&
|
|
9
|
+
state.canvasEditable &&
|
|
10
|
+
!state.pipelineId &&
|
|
11
|
+
!!state.workflowId &&
|
|
12
|
+
(state.hostCanRun || state.backendCanRun));
|
|
13
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compare two versions of a workflow: yours and the saved one.
|
|
3
|
+
*
|
|
4
|
+
* Pure. Steps (nodes) match by id, wires (edges) by their four endpoints.
|
|
5
|
+
*/
|
|
6
|
+
import type { Workflow } from '../types/index.js';
|
|
7
|
+
export interface WorkflowComparison {
|
|
8
|
+
name?: {
|
|
9
|
+
mine: string;
|
|
10
|
+
theirs: string;
|
|
11
|
+
};
|
|
12
|
+
description?: {
|
|
13
|
+
mine: string | undefined;
|
|
14
|
+
theirs: string | undefined;
|
|
15
|
+
};
|
|
16
|
+
nodesOnlyMine: {
|
|
17
|
+
id: string;
|
|
18
|
+
label: string;
|
|
19
|
+
}[];
|
|
20
|
+
nodesOnlyTheirs: {
|
|
21
|
+
id: string;
|
|
22
|
+
label: string;
|
|
23
|
+
}[];
|
|
24
|
+
nodesChanged: {
|
|
25
|
+
id: string;
|
|
26
|
+
label: string;
|
|
27
|
+
what: ('settings' | 'label' | 'position')[];
|
|
28
|
+
}[];
|
|
29
|
+
edgesOnlyMine: number;
|
|
30
|
+
edgesOnlyTheirs: number;
|
|
31
|
+
interfaceChanged: boolean;
|
|
32
|
+
chatChanged: boolean;
|
|
33
|
+
same: boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare function compareWorkflows(mine: Workflow, theirs: Workflow): WorkflowComparison;
|