@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
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Impact gate: mounts the {@link ImpactConfirm} dialog imperatively and
|
|
3
|
+
* resolves once with the person's decision.
|
|
4
|
+
*
|
|
5
|
+
* The dialog mounts outside the editor tree, so the host passes the element
|
|
6
|
+
* whose scope it should look like (`host`: the editor root, read for the skin
|
|
7
|
+
* scope and colour scheme) or the scheme itself (`theme`).
|
|
8
|
+
*
|
|
9
|
+
* @module services/impactGate
|
|
10
|
+
*/
|
|
11
|
+
import { type Messages } from '../messages/index.js';
|
|
12
|
+
import type { ImpactAnswer, ImpactReport, SavedCopy } from '../types/impact.js';
|
|
13
|
+
import type { FlowDropInstance } from '../stores/instanceContainer.svelte.js';
|
|
14
|
+
export interface ConfirmImpactOptions {
|
|
15
|
+
/** What the check found. */
|
|
16
|
+
report?: ImpactReport;
|
|
17
|
+
/** The reason the check failed; the dialog then shows that one line. */
|
|
18
|
+
error?: string;
|
|
19
|
+
/** The editor element; its skin scope is copied onto the dialog. Default `document.body` for mounting only. */
|
|
20
|
+
host?: HTMLElement;
|
|
21
|
+
/** The colour scheme (`light` | `dark`). Default: follows the editor's resolved scheme. */
|
|
22
|
+
theme?: string;
|
|
23
|
+
/** The editor's messages (`fd.messages`). Default: the built-in English. */
|
|
24
|
+
messages?: () => Messages;
|
|
25
|
+
/**
|
|
26
|
+
* The editor instance asking. At most one question is open per instance: a
|
|
27
|
+
* second ask while one is open resolves `false` and opens no second dialog.
|
|
28
|
+
*/
|
|
29
|
+
instance?: FlowDropInstance;
|
|
30
|
+
/** Saves the draft as a new workflow; offered in the refused state when the report has a `copyUrl`. */
|
|
31
|
+
saveAsCopy?: () => Promise<SavedCopy>;
|
|
32
|
+
/** Throws away the unsaved edits and loads the saved version; offered in the refused state. */
|
|
33
|
+
discard?: () => Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/** Whether this instance has an impact question open. */
|
|
36
|
+
export declare function impactPending(instance: FlowDropInstance): boolean;
|
|
37
|
+
/** Ask whether the save may go ahead, and answer what the person chose. */
|
|
38
|
+
export declare function confirmImpact(options: ConfirmImpactOptions): Promise<ImpactAnswer>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Impact gate: mounts the {@link ImpactConfirm} dialog imperatively and
|
|
3
|
+
* resolves once with the person's decision.
|
|
4
|
+
*
|
|
5
|
+
* The dialog mounts outside the editor tree, so the host passes the element
|
|
6
|
+
* whose scope it should look like (`host`: the editor root, read for the skin
|
|
7
|
+
* scope and colour scheme) or the scheme itself (`theme`).
|
|
8
|
+
*
|
|
9
|
+
* @module services/impactGate
|
|
10
|
+
*/
|
|
11
|
+
import { mount, unmount } from 'svelte';
|
|
12
|
+
import { defaultMessages, messagesContext } from '../messages/index.js';
|
|
13
|
+
import ImpactConfirm from '../components/ImpactConfirm.svelte';
|
|
14
|
+
import { SCOPE_ATTR } from '../utils/portal.js';
|
|
15
|
+
import { themeScope } from '../utils/themeScope.svelte.js';
|
|
16
|
+
const pending = new WeakSet();
|
|
17
|
+
/** Whether this instance has an impact question open. */
|
|
18
|
+
export function impactPending(instance) {
|
|
19
|
+
return pending.has(instance);
|
|
20
|
+
}
|
|
21
|
+
/** Ask whether the save may go ahead, and answer what the person chose. */
|
|
22
|
+
export function confirmImpact(options) {
|
|
23
|
+
if (typeof document === 'undefined') {
|
|
24
|
+
// No DOM to ask in: refuse rather than silently save.
|
|
25
|
+
return Promise.resolve({ action: 'cancel' });
|
|
26
|
+
}
|
|
27
|
+
const key = options.instance;
|
|
28
|
+
if (key && pending.has(key))
|
|
29
|
+
return Promise.resolve({ action: 'cancel' });
|
|
30
|
+
if (key)
|
|
31
|
+
pending.add(key);
|
|
32
|
+
return new Promise((resolve) => {
|
|
33
|
+
let settled = false;
|
|
34
|
+
const element = document.createElement('div');
|
|
35
|
+
element.className = 'fd-impact-confirm-host';
|
|
36
|
+
const scope = options.host?.closest(`[${SCOPE_ATTR}]`)?.getAttribute(SCOPE_ATTR);
|
|
37
|
+
if (scope)
|
|
38
|
+
element.setAttribute(SCOPE_ATTR, scope);
|
|
39
|
+
const theme = options.theme ? null : themeScope(element);
|
|
40
|
+
if (options.theme)
|
|
41
|
+
element.setAttribute('data-theme', options.theme);
|
|
42
|
+
document.body.appendChild(element);
|
|
43
|
+
let component = null;
|
|
44
|
+
let forget = null;
|
|
45
|
+
const finish = (answer) => {
|
|
46
|
+
if (settled)
|
|
47
|
+
return;
|
|
48
|
+
settled = true;
|
|
49
|
+
forget?.();
|
|
50
|
+
if (key)
|
|
51
|
+
pending.delete(key);
|
|
52
|
+
if (component)
|
|
53
|
+
void unmount(component);
|
|
54
|
+
theme?.destroy();
|
|
55
|
+
element.remove();
|
|
56
|
+
resolve(answer);
|
|
57
|
+
};
|
|
58
|
+
component = mount(ImpactConfirm, {
|
|
59
|
+
target: element,
|
|
60
|
+
context: messagesContext(options.messages ?? (() => defaultMessages)),
|
|
61
|
+
props: {
|
|
62
|
+
report: options.report ?? null,
|
|
63
|
+
error: options.error,
|
|
64
|
+
onResolve: finish,
|
|
65
|
+
onSaveAsCopy: options.saveAsCopy,
|
|
66
|
+
onDiscard: options.discard
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
// The instance going away takes the question with it.
|
|
70
|
+
forget = key?.onDestroy(() => finish({ action: 'cancel' })) ?? null;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Impact service: asks the backend what saving the editor's draft would change
|
|
3
|
+
* for the workflows, profiles and triggers that use it. Nothing is saved.
|
|
4
|
+
*
|
|
5
|
+
* Refusals are results, not exceptions: a backend without the route simply
|
|
6
|
+
* leaves the save unasked.
|
|
7
|
+
*
|
|
8
|
+
* @module services/impactService
|
|
9
|
+
*/
|
|
10
|
+
import type { EndpointConfig } from '../config/endpoints.js';
|
|
11
|
+
import type { AuthProvider } from '../types/auth.js';
|
|
12
|
+
import type { ImpactItem, ImpactReport, SavedCopy } from '../types/impact.js';
|
|
13
|
+
import type { Workflow } from '../types/index.js';
|
|
14
|
+
export type ImpactResult = {
|
|
15
|
+
status: 'ok';
|
|
16
|
+
report: ImpactReport;
|
|
17
|
+
}
|
|
18
|
+
/** The backend has no such route, refuses it, or does not know this workflow. */
|
|
19
|
+
| {
|
|
20
|
+
status: 'unavailable';
|
|
21
|
+
} | {
|
|
22
|
+
status: 'error';
|
|
23
|
+
message: string;
|
|
24
|
+
};
|
|
25
|
+
/** Whether the configuration offers the impact check at all. */
|
|
26
|
+
export declare function impactSupported(config: EndpointConfig | null | undefined): boolean;
|
|
27
|
+
/** Read a list of impact items; entries without a label and message are skipped. */
|
|
28
|
+
export declare function parseImpactItems(raw: unknown): ImpactItem[];
|
|
29
|
+
export declare function parseReport(data: unknown): ImpactReport;
|
|
30
|
+
/** Ask what saving `draft` over the saved workflow `workflowId` would change. */
|
|
31
|
+
export declare function checkImpact(config: EndpointConfig, authProvider: AuthProvider | undefined, workflowId: string, draft: Workflow): Promise<ImpactResult>;
|
|
32
|
+
/**
|
|
33
|
+
* Whether a `copyUrl` may receive the draft and the auth headers: a path on
|
|
34
|
+
* this site (one `/`, not `//` or `/\`), or an `http(s)` address on this
|
|
35
|
+
* site's origin or the API's.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isSafeCopyUrl(config: EndpointConfig, copyUrl: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Save the draft as a new workflow: POST it to the `copyUrl` the impact check
|
|
40
|
+
* named (a path on this site, or a full URL on this site's or the API's
|
|
41
|
+
* origin). Throws with the backend's
|
|
42
|
+
* reason when it refuses. The answer names the copy as `{ data: { id,
|
|
43
|
+
* editorUrl } }`; either may be missing.
|
|
44
|
+
*/
|
|
45
|
+
export declare function saveAsCopy(config: EndpointConfig, authProvider: AuthProvider | undefined, copyUrl: string, draft: Workflow): Promise<SavedCopy>;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Impact service: asks the backend what saving the editor's draft would change
|
|
3
|
+
* for the workflows, profiles and triggers that use it. Nothing is saved.
|
|
4
|
+
*
|
|
5
|
+
* Refusals are results, not exceptions: a backend without the route simply
|
|
6
|
+
* leaves the save unasked.
|
|
7
|
+
*
|
|
8
|
+
* @module services/impactService
|
|
9
|
+
*/
|
|
10
|
+
import { buildEndpointUrl } from '../config/endpoints.js';
|
|
11
|
+
import { authenticatedFetch } from '../utils/fetchWithAuth.js';
|
|
12
|
+
import { resolveRequestUrl, safeLinkUrl } from '../utils/links.js';
|
|
13
|
+
const SEVERITIES = ['breaks', 'changes', 'info'];
|
|
14
|
+
/** Whether the configuration offers the impact check at all. */
|
|
15
|
+
export function impactSupported(config) {
|
|
16
|
+
return !!config?.endpoints?.workflows?.impact;
|
|
17
|
+
}
|
|
18
|
+
/** Read a list of impact items; entries without a label and message are skipped. */
|
|
19
|
+
export function parseImpactItems(raw) {
|
|
20
|
+
const items = [];
|
|
21
|
+
for (const entry of Array.isArray(raw) ? raw : []) {
|
|
22
|
+
if (typeof entry !== 'object' || entry === null)
|
|
23
|
+
continue;
|
|
24
|
+
const i = entry;
|
|
25
|
+
if (typeof i.label !== 'string' || typeof i.message !== 'string')
|
|
26
|
+
continue;
|
|
27
|
+
items.push({
|
|
28
|
+
kind: typeof i.kind === 'string' ? i.kind : '',
|
|
29
|
+
severity: SEVERITIES.includes(i.severity)
|
|
30
|
+
? i.severity
|
|
31
|
+
: 'info',
|
|
32
|
+
label: i.label,
|
|
33
|
+
message: i.message,
|
|
34
|
+
url: typeof i.url === 'string' ? i.url : null
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return items;
|
|
38
|
+
}
|
|
39
|
+
/** Read the places a rename touches; only a label is required. */
|
|
40
|
+
function parseRenamePlaces(raw) {
|
|
41
|
+
const places = [];
|
|
42
|
+
for (const entry of Array.isArray(raw) ? raw : []) {
|
|
43
|
+
if (typeof entry !== 'object' || entry === null)
|
|
44
|
+
continue;
|
|
45
|
+
const p = entry;
|
|
46
|
+
if (typeof p.label !== 'string' || p.label === '')
|
|
47
|
+
continue;
|
|
48
|
+
places.push({
|
|
49
|
+
kind: typeof p.kind === 'string' ? p.kind : '',
|
|
50
|
+
label: p.label,
|
|
51
|
+
url: typeof p.url === 'string' && p.url ? p.url : null,
|
|
52
|
+
...(typeof p.message === 'string' && p.message ? { message: p.message } : {}),
|
|
53
|
+
...(typeof p.enabled === 'boolean' ? { enabled: p.enabled } : {})
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return places;
|
|
57
|
+
}
|
|
58
|
+
function parseRenames(raw) {
|
|
59
|
+
const renames = [];
|
|
60
|
+
const seen = new Set();
|
|
61
|
+
for (const entry of Array.isArray(raw) ? raw : []) {
|
|
62
|
+
if (typeof entry !== 'object' || entry === null)
|
|
63
|
+
continue;
|
|
64
|
+
const r = entry;
|
|
65
|
+
if (typeof r.from !== 'string' || typeof r.to !== 'string')
|
|
66
|
+
continue;
|
|
67
|
+
const direction = r.direction === 'output' ? 'output' : 'input';
|
|
68
|
+
// The dialog keys its rows by direction and name: the first one wins.
|
|
69
|
+
const key = `${direction}:${r.from}`;
|
|
70
|
+
if (seen.has(key))
|
|
71
|
+
continue;
|
|
72
|
+
seen.add(key);
|
|
73
|
+
renames.push({
|
|
74
|
+
direction,
|
|
75
|
+
from: r.from,
|
|
76
|
+
to: r.to,
|
|
77
|
+
places: parseRenamePlaces(r.places)
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return renames;
|
|
81
|
+
}
|
|
82
|
+
export function parseReport(data) {
|
|
83
|
+
const d = (typeof data === 'object' && data !== null ? data : {});
|
|
84
|
+
const iface = (typeof d.interface === 'object' && d.interface !== null ? d.interface : {});
|
|
85
|
+
return {
|
|
86
|
+
confirm: d.confirm === true,
|
|
87
|
+
interfaceLevel: typeof iface.level === 'string' ? iface.level : '',
|
|
88
|
+
interfaceBreaking: iface.breaking === true,
|
|
89
|
+
items: parseImpactItems(d.items),
|
|
90
|
+
refused: d.refused === true,
|
|
91
|
+
refusedMessage: typeof d.refusedMessage === 'string' && d.refusedMessage ? d.refusedMessage : null,
|
|
92
|
+
copyUrl: typeof d.copyUrl === 'string' && d.copyUrl ? d.copyUrl : null,
|
|
93
|
+
renames: parseRenames(d.renames)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
async function errorMessage(response) {
|
|
97
|
+
const payload = (await response.json().catch(() => ({})));
|
|
98
|
+
return payload.error ?? payload.message ?? `HTTP ${response.status}: ${response.statusText}`;
|
|
99
|
+
}
|
|
100
|
+
/** Ask what saving `draft` over the saved workflow `workflowId` would change. */
|
|
101
|
+
export async function checkImpact(config, authProvider, workflowId, draft) {
|
|
102
|
+
const path = config.endpoints.workflows.impact;
|
|
103
|
+
if (!path)
|
|
104
|
+
return { status: 'unavailable' };
|
|
105
|
+
try {
|
|
106
|
+
const response = await authenticatedFetch(buildEndpointUrl(config, path, { id: workflowId }), { method: 'POST', body: JSON.stringify(draft) }, { config, endpointKey: 'workflows.impact', authProvider });
|
|
107
|
+
// 404/405: no such route. 401/403: a backend that answers an unknown route
|
|
108
|
+
// with a login or access refusal. The route ships in the default endpoints,
|
|
109
|
+
// so these must not read as a failed check before every save.
|
|
110
|
+
if ([401, 403, 404, 405].includes(response.status))
|
|
111
|
+
return { status: 'unavailable' };
|
|
112
|
+
if (!response.ok)
|
|
113
|
+
return { status: 'error', message: await errorMessage(response) };
|
|
114
|
+
const body = (await response.json().catch(() => null));
|
|
115
|
+
if (!body || body.success === false) {
|
|
116
|
+
return { status: 'error', message: body?.error ?? 'Impact check failed' };
|
|
117
|
+
}
|
|
118
|
+
return { status: 'ok', report: parseReport(body.data) };
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
return { status: 'error', message: error instanceof Error ? error.message : String(error) };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Whether a `copyUrl` may receive the draft and the auth headers: a path on
|
|
126
|
+
* this site (one `/`, not `//` or `/\`), or an `http(s)` address on this
|
|
127
|
+
* site's origin or the API's.
|
|
128
|
+
*/
|
|
129
|
+
export function isSafeCopyUrl(config, copyUrl) {
|
|
130
|
+
return resolveRequestUrl(copyUrl, config.baseUrl) !== null;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Save the draft as a new workflow: POST it to the `copyUrl` the impact check
|
|
134
|
+
* named (a path on this site, or a full URL on this site's or the API's
|
|
135
|
+
* origin). Throws with the backend's
|
|
136
|
+
* reason when it refuses. The answer names the copy as `{ data: { id,
|
|
137
|
+
* editorUrl } }`; either may be missing.
|
|
138
|
+
*/
|
|
139
|
+
export async function saveAsCopy(config, authProvider, copyUrl, draft) {
|
|
140
|
+
// A path is a path on this site, as the backend wrote it, not one under the API base.
|
|
141
|
+
const url = resolveRequestUrl(copyUrl, config.baseUrl);
|
|
142
|
+
if (url === null)
|
|
143
|
+
throw new Error('The copy address is not on this server');
|
|
144
|
+
const response = await authenticatedFetch(url, { method: 'POST', body: JSON.stringify(draft) }, { config, endpointKey: 'workflows.copy', authProvider });
|
|
145
|
+
if (!response.ok)
|
|
146
|
+
throw new Error(await errorMessage(response));
|
|
147
|
+
const body = (await response.json().catch(() => null));
|
|
148
|
+
if (body?.success === false)
|
|
149
|
+
throw new Error(body.error ?? 'Saving a copy failed');
|
|
150
|
+
const data = body?.data ?? {};
|
|
151
|
+
const editorUrl = data.editorUrl ?? data.editor_url;
|
|
152
|
+
const id = data.id;
|
|
153
|
+
return {
|
|
154
|
+
id: typeof id === 'string' || typeof id === 'number' ? String(id) : null,
|
|
155
|
+
editorUrl: typeof editorUrl === 'string' ? safeLinkUrl(editorUrl) : null
|
|
156
|
+
};
|
|
157
|
+
}
|
|
@@ -36,6 +36,15 @@ export declare function listRuns(config: EndpointConfig, workflowId: string, pag
|
|
|
36
36
|
}, authProvider?: AuthProvider): Promise<RunSummary[]>;
|
|
37
37
|
/** The status of one run (`pipelines.status`), or `undefined` when it cannot be read. */
|
|
38
38
|
export declare function readRunStatus(config: EndpointConfig, pipelineId: string, authProvider?: AuthProvider): Promise<string | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* The status of one run plus what the site says is happening to it
|
|
41
|
+
* (`activity.kind`, for example `waiting_for_worker`), or `undefined` when it
|
|
42
|
+
* cannot be read. Older backends send no activity.
|
|
43
|
+
*/
|
|
44
|
+
export declare function readRunState(config: EndpointConfig, pipelineId: string, authProvider?: AuthProvider): Promise<{
|
|
45
|
+
status: string | undefined;
|
|
46
|
+
activityKind: string | null;
|
|
47
|
+
} | undefined>;
|
|
39
48
|
/** Re-run a finished run; the answer names the new pipeline. */
|
|
40
49
|
export declare function rerunRun(config: EndpointConfig, pipelineId: string, authProvider?: AuthProvider): Promise<RunActionResult>;
|
|
41
50
|
/** Cancel a run that has not finished. */
|
|
@@ -52,6 +52,19 @@ export async function readRunStatus(config, pipelineId, authProvider) {
|
|
|
52
52
|
const body = (await response.json().catch(() => null));
|
|
53
53
|
return body?.data?.status;
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* The status of one run plus what the site says is happening to it
|
|
57
|
+
* (`activity.kind`, for example `waiting_for_worker`), or `undefined` when it
|
|
58
|
+
* cannot be read. Older backends send no activity.
|
|
59
|
+
*/
|
|
60
|
+
export async function readRunState(config, pipelineId, authProvider) {
|
|
61
|
+
const url = buildEndpointUrl(config, config.endpoints.pipelines.status, { id: pipelineId });
|
|
62
|
+
const response = await authenticatedFetch(url, { method: 'GET' }, { config, endpointKey: 'pipelines.status', authProvider });
|
|
63
|
+
if (!response.ok)
|
|
64
|
+
return undefined;
|
|
65
|
+
const body = (await response.json().catch(() => null));
|
|
66
|
+
return { status: body?.data?.status, activityKind: body?.data?.activity?.kind ?? null };
|
|
67
|
+
}
|
|
55
68
|
/** Re-run a finished run; the answer names the new pipeline. */
|
|
56
69
|
export async function rerunRun(config, pipelineId, authProvider) {
|
|
57
70
|
const path = config.endpoints.pipelines.rerun;
|
|
@@ -12,6 +12,15 @@ export type ToastKind = 'success' | 'error' | 'warning' | 'info' | 'loading';
|
|
|
12
12
|
export interface ToastAction {
|
|
13
13
|
label: string;
|
|
14
14
|
onClick: () => void;
|
|
15
|
+
/** Draws this action as the main one when a toast offers several (default: the first). */
|
|
16
|
+
primary?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Leave the toast on screen after this action runs (default: it is
|
|
19
|
+
* dismissed). For a choice that can fail or be cancelled, where the person
|
|
20
|
+
* still needs the other options; the caller dismisses the toast itself once
|
|
21
|
+
* the matter is settled.
|
|
22
|
+
*/
|
|
23
|
+
keepOpen?: boolean;
|
|
15
24
|
}
|
|
16
25
|
export interface ActiveToast {
|
|
17
26
|
id: string;
|
|
@@ -28,6 +28,8 @@ export interface ToastContent {
|
|
|
28
28
|
body?: string;
|
|
29
29
|
details?: readonly string[];
|
|
30
30
|
action?: ToastAction;
|
|
31
|
+
/** Several follow-up steps; listed after `action`. */
|
|
32
|
+
actions?: readonly ToastAction[];
|
|
31
33
|
}
|
|
32
34
|
/** What the show* helpers take: a plain string (the title) or its parts. */
|
|
33
35
|
export type ToastInput = string | ToastContent;
|
|
@@ -44,6 +46,8 @@ export interface ToastOptions {
|
|
|
44
46
|
details?: readonly string[];
|
|
45
47
|
/** Same as `action` on a `ToastContent`; the content's own action wins. */
|
|
46
48
|
action?: ToastAction;
|
|
49
|
+
/** Same as `actions` on a `ToastContent`; the content's own list wins. */
|
|
50
|
+
actions?: readonly ToastAction[];
|
|
47
51
|
/**
|
|
48
52
|
* Stable id: a toast with the same id replaces the one already showing
|
|
49
53
|
* instead of stacking. Errors and warnings default to an id derived from
|
|
@@ -52,9 +52,14 @@ function toContent(input, options) {
|
|
|
52
52
|
return {
|
|
53
53
|
...content,
|
|
54
54
|
details: content.details ?? options?.details,
|
|
55
|
-
action: content.action ?? options?.action
|
|
55
|
+
action: content.action ?? options?.action,
|
|
56
|
+
actions: content.actions ?? options?.actions
|
|
56
57
|
};
|
|
57
58
|
}
|
|
59
|
+
/** Every action a toast offers, in order: the single `action` first, then `actions`. */
|
|
60
|
+
function actionList(content) {
|
|
61
|
+
return [...(content.action ? [content.action] : []), ...(content.actions ?? [])];
|
|
62
|
+
}
|
|
58
63
|
/** Default id for a persistent toast: one per distinct text. */
|
|
59
64
|
function dedupeId(kind, content) {
|
|
60
65
|
return `${kind}:${[content.title, content.body ?? '', ...(content.details ?? [])].join('\n')}`;
|
|
@@ -74,7 +79,8 @@ function present(kind, input, options, defaults) {
|
|
|
74
79
|
const content = toContent(input, options);
|
|
75
80
|
// An action is the next step the user may take: it must not vanish while they
|
|
76
81
|
// read (or reach for) it, so it never auto-dismisses and can always be closed.
|
|
77
|
-
const
|
|
82
|
+
const actions = actionList(content);
|
|
83
|
+
const sticky = actions.length > 0;
|
|
78
84
|
const id = options?.id ?? defaults.id ?? dedupeId(kind, content);
|
|
79
85
|
for (const evicted of planToastEviction(activeToasts(), { id, kind })) {
|
|
80
86
|
toast.dismiss(evicted);
|
|
@@ -85,7 +91,7 @@ function present(kind, input, options, defaults) {
|
|
|
85
91
|
text: content.title,
|
|
86
92
|
body: content.body,
|
|
87
93
|
details: content.details ?? [],
|
|
88
|
-
|
|
94
|
+
actions,
|
|
89
95
|
kind,
|
|
90
96
|
dismissible: sticky || defaults.dismissible
|
|
91
97
|
},
|
|
@@ -70,6 +70,12 @@ export interface LaunchOptions {
|
|
|
70
70
|
* server's own refusal. Value type/schema checking stays with the server.
|
|
71
71
|
*/
|
|
72
72
|
workflow?: Workflow;
|
|
73
|
+
/**
|
|
74
|
+
* Tell the backend where the run was started from, so its run page can say
|
|
75
|
+
* so. Only `'editor'` is sent today; a backend that does not know the field
|
|
76
|
+
* ignores it.
|
|
77
|
+
*/
|
|
78
|
+
origin?: 'editor';
|
|
73
79
|
}
|
|
74
80
|
declare class WorkflowLaunchService {
|
|
75
81
|
/** True when this configuration exposes an explicit launch verb. */
|
|
@@ -47,6 +47,8 @@ class WorkflowLaunchService {
|
|
|
47
47
|
body.inputs = options.inputs;
|
|
48
48
|
if (options.sessionId)
|
|
49
49
|
body.sessionId = options.sessionId;
|
|
50
|
+
if (options.origin)
|
|
51
|
+
body.origin = options.origin;
|
|
50
52
|
const response = await authenticatedFetch(url, {
|
|
51
53
|
method: 'POST',
|
|
52
54
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -73,7 +75,9 @@ class WorkflowLaunchService {
|
|
|
73
75
|
return { status: 'invalid-workflow', message, errors: payload.details ?? [] };
|
|
74
76
|
}
|
|
75
77
|
if (response.status === 400) {
|
|
76
|
-
|
|
78
|
+
// Per-input details, when the backend names them, are the useful message.
|
|
79
|
+
const detail = (payload.details ?? []).map((item) => item.message).filter(Boolean);
|
|
80
|
+
return { status: 'invalid-input', message: detail.length > 0 ? detail.join(' ') : message };
|
|
77
81
|
}
|
|
78
82
|
return { status: 'failed', message };
|
|
79
83
|
}
|
package/dist/settings/index.d.ts
CHANGED
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
export { default as ThemeToggle } from '../components/ThemeToggle.svelte';
|
|
20
20
|
export { default as SettingsPanel } from '../components/SettingsPanel.svelte';
|
|
21
21
|
export { default as SettingsModal } from '../components/SettingsModal.svelte';
|
|
22
|
-
export type { ThemeSettings, EditorSettings, UISettings, BehaviorSettings, ApiSettings, FlowDropSettings, SettingsCategory, PartialSettings, DeepPartial, SettingsChangeEvent, SettingsChangeCallback, SyncStatus, SettingsStoreState } from '../types/settings.js';
|
|
22
|
+
export type { ThemeSettings, EditorSettings, UISettings, BehaviorSettings, ApiSettings, FlowDropSettings, SettingsCategory, SettingsFieldSchema, SettingsFieldSchemaMap, PartialSettings, DeepPartial, SettingsChangeEvent, SettingsChangeCallback, SyncStatus, SettingsStoreState } from '../types/settings.js';
|
|
23
23
|
export type { ZoomTierConfig, ZoomTierName } from '../utils/zoomTier.js';
|
|
24
|
-
export { SETTINGS_CATEGORIES, SETTINGS_CATEGORY_LABELS, SETTINGS_CATEGORY_ICONS, DEFAULT_THEME_SETTINGS, DEFAULT_EDITOR_SETTINGS, DEFAULT_UI_SETTINGS, DEFAULT_BEHAVIOR_SETTINGS, DEFAULT_API_SETTINGS, DEFAULT_SETTINGS, SETTINGS_STORAGE_KEY } from '../types/settings.js';
|
|
24
|
+
export { SETTINGS_CATEGORIES, SETTINGS_CATEGORY_LABELS, SETTINGS_CATEGORY_ICONS, DEFAULT_THEME_SETTINGS, DEFAULT_EDITOR_SETTINGS, DEFAULT_UI_SETTINGS, DEFAULT_BEHAVIOR_SETTINGS, DEFAULT_API_SETTINGS, DEFAULT_SETTINGS, SETTINGS_FIELD_SCHEMA, SETTINGS_STORAGE_KEY } from '../types/settings.js';
|
|
25
25
|
export { getSettings as settingsStore, getThemeSettings as themeSettings, getEditorSettings as editorSettings, getUiSettings as uiSettings, getBehaviorSettings as behaviorSettings, getApiSettings as apiSettings, getSyncStatus as syncStatusStore, updateSettings, resetSettings, getSettings, initializeSettings, setSettingsService, syncSettingsToApi, loadSettingsFromApi, onSettingsChange } from '../stores/settingsStore.svelte.js';
|
|
26
26
|
export { settingsApi, SettingsService, createSettingsService, setSettingsEndpointConfig, getSettingsEndpointConfig } from '../services/settingsService.js';
|
package/dist/settings/index.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
export { default as ThemeToggle } from '../components/ThemeToggle.svelte';
|
|
23
23
|
export { default as SettingsPanel } from '../components/SettingsPanel.svelte';
|
|
24
24
|
export { default as SettingsModal } from '../components/SettingsModal.svelte';
|
|
25
|
-
export { SETTINGS_CATEGORIES, SETTINGS_CATEGORY_LABELS, SETTINGS_CATEGORY_ICONS, DEFAULT_THEME_SETTINGS, DEFAULT_EDITOR_SETTINGS, DEFAULT_UI_SETTINGS, DEFAULT_BEHAVIOR_SETTINGS, DEFAULT_API_SETTINGS, DEFAULT_SETTINGS, SETTINGS_STORAGE_KEY } from '../types/settings.js';
|
|
25
|
+
export { SETTINGS_CATEGORIES, SETTINGS_CATEGORY_LABELS, SETTINGS_CATEGORY_ICONS, DEFAULT_THEME_SETTINGS, DEFAULT_EDITOR_SETTINGS, DEFAULT_UI_SETTINGS, DEFAULT_BEHAVIOR_SETTINGS, DEFAULT_API_SETTINGS, DEFAULT_SETTINGS, SETTINGS_FIELD_SCHEMA, SETTINGS_STORAGE_KEY } from '../types/settings.js';
|
|
26
26
|
// ============================================================================
|
|
27
27
|
// Settings Stores
|
|
28
28
|
// ============================================================================
|
|
@@ -11,13 +11,28 @@
|
|
|
11
11
|
* workflow update, which is one undo step; an operation the editor cannot map
|
|
12
12
|
* aborts the whole remedy before anything changes.
|
|
13
13
|
*
|
|
14
|
+
* A remedy the server marks `params.automatic` is applied by the editor itself
|
|
15
|
+
* when its problem first appears after the workflow loaded (never for a problem
|
|
16
|
+
* present at load, a destructive remedy or one that needs a choice), once per
|
|
17
|
+
* code per workflow, with an Undo toast. See {@link DoctorStore.setAutoApply}.
|
|
18
|
+
*
|
|
14
19
|
* @module stores/doctorStore
|
|
15
20
|
*/
|
|
16
21
|
import type { DoctorProblem, DoctorRemedy, DoctorSeverity } from '../types/doctor.js';
|
|
17
22
|
import type { WorkflowStore } from './workflowStore.svelte.js';
|
|
18
23
|
import type { ApiContext } from './apiContext.js';
|
|
24
|
+
import { type Messages } from '../messages/index.js';
|
|
19
25
|
/** How long the draft must sit still before it is diagnosed. */
|
|
20
26
|
export declare const DOCTOR_IDLE_MS = 800;
|
|
27
|
+
/** What a {@link DoctorStore} can be given beyond the workflow and the api. */
|
|
28
|
+
export interface DoctorStoreOptions {
|
|
29
|
+
/** How long the draft must sit still before it is diagnosed. Default {@link DOCTOR_IDLE_MS}. */
|
|
30
|
+
idleMs?: number;
|
|
31
|
+
/** The undo history, for the Undo toast. Default: nothing to undo. */
|
|
32
|
+
history?: DoctorHistory;
|
|
33
|
+
/** The editor's messages. Default: the built-in English. */
|
|
34
|
+
messages?: () => Messages;
|
|
35
|
+
}
|
|
21
36
|
export type DoctorStatus = 'off' | 'idle' | 'checking' | 'ready' | 'error';
|
|
22
37
|
/** What the last remedy attempt ended in, other than success. The view words it. */
|
|
23
38
|
export type DoctorNotice = {
|
|
@@ -34,9 +49,17 @@ export type DoctorNotice = {
|
|
|
34
49
|
problemId: string;
|
|
35
50
|
message: string;
|
|
36
51
|
};
|
|
52
|
+
/** The undo history as the store needs it: undo one step, and say where the history stands. */
|
|
53
|
+
export interface DoctorHistory {
|
|
54
|
+
undo(): boolean;
|
|
55
|
+
/** A number that changes with every step added, undone or redone. */
|
|
56
|
+
position(): number;
|
|
57
|
+
}
|
|
37
58
|
export declare class DoctorStore {
|
|
38
59
|
#private;
|
|
39
|
-
constructor(workflow: WorkflowStore, api: ApiContext,
|
|
60
|
+
constructor(workflow: WorkflowStore, api: ApiContext, options?: DoctorStoreOptions);
|
|
61
|
+
/** Whether the editor may apply automatic remedies (the canvas is editable). */
|
|
62
|
+
setAutoApply(enabled: boolean): void;
|
|
40
63
|
/** Whether the backend offers a Doctor (the endpoints are configured). */
|
|
41
64
|
get supported(): boolean;
|
|
42
65
|
get status(): DoctorStatus;
|