@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/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,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Links a backend or host hands the editor: which ones it may draw, follow or
|
|
3
|
+
* send a request to.
|
|
4
|
+
*
|
|
5
|
+
* One set of rules for every place that takes such a link (the lock banner,
|
|
6
|
+
* the save dialog, a saved copy's editor URL, the copy endpoint), so they
|
|
7
|
+
* cannot drift apart.
|
|
8
|
+
*
|
|
9
|
+
* @module utils/links
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Whether `url` is a path on this site: it starts with one `/`. `//host` and
|
|
13
|
+
* `/\host` are not paths, browsers read both as another site.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isSitePath(url: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The link as given when it may be drawn or followed (a site path or an
|
|
18
|
+
* `http(s)` address), otherwise `null`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function safeLinkUrl(url: string | null | undefined): string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Where a request may go when it carries the editor's draft and auth headers:
|
|
23
|
+
* a path on this site, or an `http(s)` address on this site's origin or on the
|
|
24
|
+
* API's origin. Answers the full address, or `null` when it may not go there.
|
|
25
|
+
*
|
|
26
|
+
* @param url - The address as the backend gave it
|
|
27
|
+
* @param apiBaseUrl - The API base URL (may itself be a path on this site)
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveRequestUrl(url: string, apiBaseUrl: string): string | null;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Links a backend or host hands the editor: which ones it may draw, follow or
|
|
3
|
+
* send a request to.
|
|
4
|
+
*
|
|
5
|
+
* One set of rules for every place that takes such a link (the lock banner,
|
|
6
|
+
* the save dialog, a saved copy's editor URL, the copy endpoint), so they
|
|
7
|
+
* cannot drift apart.
|
|
8
|
+
*
|
|
9
|
+
* @module utils/links
|
|
10
|
+
*/
|
|
11
|
+
/** Browsers drop tabs and line breaks inside a URL, so a link that holds one reads differently. */
|
|
12
|
+
function hasLineBreakOrTab(url) {
|
|
13
|
+
return /[\t\r\n]/.test(url);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Whether `url` is a path on this site: it starts with one `/`. `//host` and
|
|
17
|
+
* `/\host` are not paths, browsers read both as another site.
|
|
18
|
+
*/
|
|
19
|
+
export function isSitePath(url) {
|
|
20
|
+
return !hasLineBreakOrTab(url) && /^\/(?![/\\])/.test(url);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The link as given when it may be drawn or followed (a site path or an
|
|
24
|
+
* `http(s)` address), otherwise `null`.
|
|
25
|
+
*/
|
|
26
|
+
export function safeLinkUrl(url) {
|
|
27
|
+
if (!url || hasLineBreakOrTab(url))
|
|
28
|
+
return null;
|
|
29
|
+
if (isSitePath(url))
|
|
30
|
+
return url;
|
|
31
|
+
try {
|
|
32
|
+
const protocol = new URL(url).protocol;
|
|
33
|
+
return protocol === 'https:' || protocol === 'http:' ? url : null;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Where a request may go when it carries the editor's draft and auth headers:
|
|
41
|
+
* a path on this site, or an `http(s)` address on this site's origin or on the
|
|
42
|
+
* API's origin. Answers the full address, or `null` when it may not go there.
|
|
43
|
+
*
|
|
44
|
+
* @param url - The address as the backend gave it
|
|
45
|
+
* @param apiBaseUrl - The API base URL (may itself be a path on this site)
|
|
46
|
+
*/
|
|
47
|
+
export function resolveRequestUrl(url, apiBaseUrl) {
|
|
48
|
+
if (!url || hasLineBreakOrTab(url) || typeof window === 'undefined')
|
|
49
|
+
return null;
|
|
50
|
+
const here = window.location.href;
|
|
51
|
+
try {
|
|
52
|
+
if (isSitePath(url))
|
|
53
|
+
return new URL(url, here).href;
|
|
54
|
+
const target = new URL(url);
|
|
55
|
+
if (target.protocol !== 'https:' && target.protocol !== 'http:')
|
|
56
|
+
return null;
|
|
57
|
+
const allowed = [new URL(here).origin, new URL(apiBaseUrl, here).origin];
|
|
58
|
+
return allowed.includes(target.origin) ? target.href : null;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -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;
|
|
@@ -0,0 +1,84 @@
|
|
|
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 { nodeCanvasLabel } from './workflowInterface.js';
|
|
7
|
+
/** JSON with object keys sorted at every depth, so key order never counts as a change. */
|
|
8
|
+
function stable(value) {
|
|
9
|
+
return JSON.stringify(value ?? null, (_key, v) => {
|
|
10
|
+
if (v && typeof v === 'object' && !Array.isArray(v)) {
|
|
11
|
+
return Object.fromEntries(Object.keys(v)
|
|
12
|
+
.sort()
|
|
13
|
+
.map((k) => [k, v[k]]));
|
|
14
|
+
}
|
|
15
|
+
return v;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function nodeLabel(node) {
|
|
19
|
+
return nodeCanvasLabel(node);
|
|
20
|
+
}
|
|
21
|
+
function edgeKey(edge) {
|
|
22
|
+
return [edge.source, edge.sourceHandle ?? '', edge.target, edge.targetHandle ?? ''].join('\u0000');
|
|
23
|
+
}
|
|
24
|
+
function countOnlyIn(from, other) {
|
|
25
|
+
const keys = new Set(other.map(edgeKey));
|
|
26
|
+
return from.filter((e) => !keys.has(edgeKey(e))).length;
|
|
27
|
+
}
|
|
28
|
+
export function compareWorkflows(mine, theirs) {
|
|
29
|
+
const myNodes = new Map((mine.nodes ?? []).map((n) => [n.id, n]));
|
|
30
|
+
const theirNodes = new Map((theirs.nodes ?? []).map((n) => [n.id, n]));
|
|
31
|
+
const nodesOnlyMine = [...myNodes.values()]
|
|
32
|
+
.filter((n) => !theirNodes.has(n.id))
|
|
33
|
+
.map((n) => ({ id: n.id, label: nodeLabel(n) }));
|
|
34
|
+
const nodesOnlyTheirs = [...theirNodes.values()]
|
|
35
|
+
.filter((n) => !myNodes.has(n.id))
|
|
36
|
+
.map((n) => ({ id: n.id, label: nodeLabel(n) }));
|
|
37
|
+
const nodesChanged = [];
|
|
38
|
+
for (const [id, a] of myNodes) {
|
|
39
|
+
const b = theirNodes.get(id);
|
|
40
|
+
if (!b)
|
|
41
|
+
continue;
|
|
42
|
+
const what = [];
|
|
43
|
+
if (stable(a.data?.config) !== stable(b.data?.config))
|
|
44
|
+
what.push('settings');
|
|
45
|
+
if ((a.data?.label ?? '') !== (b.data?.label ?? ''))
|
|
46
|
+
what.push('label');
|
|
47
|
+
if (Math.abs((a.position?.x ?? 0) - (b.position?.x ?? 0)) > 1 ||
|
|
48
|
+
Math.abs((a.position?.y ?? 0) - (b.position?.y ?? 0)) > 1) {
|
|
49
|
+
what.push('position');
|
|
50
|
+
}
|
|
51
|
+
if (what.length > 0)
|
|
52
|
+
nodesChanged.push({ id, label: nodeLabel(a), what });
|
|
53
|
+
}
|
|
54
|
+
const edgesOnlyMine = countOnlyIn(mine.edges ?? [], theirs.edges ?? []);
|
|
55
|
+
const edgesOnlyTheirs = countOnlyIn(theirs.edges ?? [], mine.edges ?? []);
|
|
56
|
+
const interfaceChanged = stable(mine.interface) !== stable(theirs.interface);
|
|
57
|
+
const chatChanged = stable(mine.playground) !== stable(theirs.playground);
|
|
58
|
+
const result = {
|
|
59
|
+
nodesOnlyMine,
|
|
60
|
+
nodesOnlyTheirs,
|
|
61
|
+
nodesChanged,
|
|
62
|
+
edgesOnlyMine,
|
|
63
|
+
edgesOnlyTheirs,
|
|
64
|
+
interfaceChanged,
|
|
65
|
+
chatChanged,
|
|
66
|
+
same: false
|
|
67
|
+
};
|
|
68
|
+
if (mine.name !== theirs.name)
|
|
69
|
+
result.name = { mine: mine.name, theirs: theirs.name };
|
|
70
|
+
if ((mine.description ?? '') !== (theirs.description ?? '')) {
|
|
71
|
+
result.description = { mine: mine.description, theirs: theirs.description };
|
|
72
|
+
}
|
|
73
|
+
result.same =
|
|
74
|
+
!result.name &&
|
|
75
|
+
!result.description &&
|
|
76
|
+
nodesOnlyMine.length === 0 &&
|
|
77
|
+
nodesOnlyTheirs.length === 0 &&
|
|
78
|
+
nodesChanged.length === 0 &&
|
|
79
|
+
edgesOnlyMine === 0 &&
|
|
80
|
+
edgesOnlyTheirs === 0 &&
|
|
81
|
+
!interfaceChanged &&
|
|
82
|
+
!chatChanged;
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
@@ -211,6 +211,15 @@ export declare function nodeCanvasLabel(node: {
|
|
|
211
211
|
config?: Record<string, unknown>;
|
|
212
212
|
};
|
|
213
213
|
}): string;
|
|
214
|
+
/**
|
|
215
|
+
* Tells same-named nodes apart in a picker: when two or more items with
|
|
216
|
+
* different node ids share a label, each of them gets " · <node id>" appended.
|
|
217
|
+
* Unique labels, and several ports of one node, stay as they are.
|
|
218
|
+
*/
|
|
219
|
+
export declare function disambiguateLabels<T extends {
|
|
220
|
+
nodeId: string;
|
|
221
|
+
nodeLabel: string;
|
|
222
|
+
}>(items: T[]): T[];
|
|
214
223
|
/** One inner port a `WorkflowInterfaceEntry` could bind to, plus its owning node. */
|
|
215
224
|
export interface BindablePort {
|
|
216
225
|
nodeId: string;
|
|
@@ -275,7 +284,23 @@ export declare function rankBindablePorts(workflow: Workflow, direction: 'input'
|
|
|
275
284
|
* re-derives it. DN1's concern — a contract silently keyed on internal port
|
|
276
285
|
* names — is about that ongoing coupling, which this does not introduce.
|
|
277
286
|
*/
|
|
278
|
-
export declare function entryFromBindablePort(candidate: BindablePort, existingIds: Iterable<string
|
|
287
|
+
export declare function entryFromBindablePort(candidate: BindablePort, existingIds: Iterable<string>, workflow?: Workflow, direction?: 'input' | 'output'): WorkflowInterfaceEntry;
|
|
288
|
+
/** Port ids too generic to name a public entry: the node's title names it instead. */
|
|
289
|
+
export declare const GENERIC_PORT_IDS: readonly string[];
|
|
290
|
+
/**
|
|
291
|
+
* The id, title and type to seed a new entry with for a picked port.
|
|
292
|
+
*
|
|
293
|
+
* A generic port id (`data`, `value`, ...) says nothing about the contract, so
|
|
294
|
+
* the bound node's canvas label gives the id (snake_case) and the title. A
|
|
295
|
+
* `mixed` port takes the type of the port at the other end of an edge on its
|
|
296
|
+
* handle, when that one is typed. The id gets a numeric suffix only on a
|
|
297
|
+
* collision with `existingIds`.
|
|
298
|
+
*/
|
|
299
|
+
export declare function suggestEntryFromBindablePort(workflow: Workflow | undefined, candidate: BindablePort, existingIds: Iterable<string>, direction?: 'input' | 'output'): {
|
|
300
|
+
id: string;
|
|
301
|
+
name: string;
|
|
302
|
+
dataType: string;
|
|
303
|
+
};
|
|
279
304
|
/** The turn values an entry of this direction may carry, in selector order. */
|
|
280
305
|
export declare function turnsFor(direction: 'input' | 'output'): readonly WorkflowInterfaceTurn[];
|
|
281
306
|
/** Whether a value is in this library's turn vocabulary (either direction). */
|