@flowdrop/flowdrop 2.0.0-beta.6 → 2.0.0-beta.8
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 +25 -0
- package/dist/commands/executor.js +46 -20
- package/dist/components/App.svelte +467 -182
- package/dist/components/App.svelte.d.ts +14 -1
- package/dist/components/ConfigForm.svelte +93 -25
- package/dist/components/ConfigPanel.svelte +223 -12
- package/dist/components/ConfigPanel.svelte.d.ts +6 -0
- package/dist/components/SettingsPanel.svelte +22 -0
- package/dist/components/form/FormFieldset.svelte +44 -10
- package/dist/components/form/FormRangeField.svelte +43 -3
- package/dist/components/surfaces/SurfaceOverlay.svelte +146 -0
- package/dist/components/surfaces/SurfaceOverlay.svelte.d.ts +14 -0
- package/dist/components/surfaces/TabbedSurface.svelte +133 -0
- package/dist/components/surfaces/TabbedSurface.svelte.d.ts +27 -0
- package/dist/services/dynamicSchemaService.d.ts +29 -2
- package/dist/services/dynamicSchemaService.js +54 -25
- package/dist/stores/settingsStore.svelte.d.ts +13 -0
- package/dist/stores/settingsStore.svelte.js +32 -0
- package/dist/stores/workflowStore.svelte.js +6 -1
- package/dist/svelte-app.d.ts +12 -1
- package/dist/svelte-app.js +3 -1
- package/dist/types/index.d.ts +29 -0
- package/dist/types/settings.d.ts +16 -0
- package/dist/types/settings.js +3 -1
- package/dist/types/uischema.d.ts +5 -0
- package/dist/utils/portal.d.ts +18 -0
- package/dist/utils/portal.js +34 -0
- package/dist/utils/schemaMerge.d.ts +25 -0
- package/dist/utils/schemaMerge.js +61 -0
- package/package.json +1 -1
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
value = 0,
|
|
38
38
|
min = 0,
|
|
39
39
|
max = 100,
|
|
40
|
-
step
|
|
40
|
+
step,
|
|
41
41
|
required = false,
|
|
42
42
|
disabled = false,
|
|
43
43
|
ariaDescribedBy,
|
|
@@ -56,6 +56,40 @@
|
|
|
56
56
|
return isNaN(parsed) ? min : parsed;
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
+
/** Count the decimal places of a finite number (e.g. 0.7 -> 1, 3 -> 0). */
|
|
60
|
+
function decimalPlaces(n: number): number {
|
|
61
|
+
if (!Number.isFinite(n)) return 0;
|
|
62
|
+
const text = String(n);
|
|
63
|
+
const dot = text.indexOf('.');
|
|
64
|
+
return dot === -1 ? 0 : text.length - dot - 1;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Resolve the step the native input should use.
|
|
69
|
+
*
|
|
70
|
+
* The backend often omits `step`, and a default of 1 makes the browser snap a
|
|
71
|
+
* fractional value (0.7) to the nearest integer (1) — the thumb jumps to that
|
|
72
|
+
* snapped position while our fill/label still show the raw value, so they
|
|
73
|
+
* disagree on load. When no step is given, infer one from the precision of the
|
|
74
|
+
* initial value/min/max so a value like 0.7 yields a step of 0.1.
|
|
75
|
+
*
|
|
76
|
+
* Granularity is a property of the field, not the live value, so it is captured
|
|
77
|
+
* ONCE. Recomputing from the live value would coarsen the step back to 1 the
|
|
78
|
+
* instant the user drags onto a whole number (e.g. 1.0), stranding the slider
|
|
79
|
+
* on integer increments.
|
|
80
|
+
*/
|
|
81
|
+
const initialNumeric = typeof value === 'number' ? value : Number(value);
|
|
82
|
+
const inferredStep = ((): number => {
|
|
83
|
+
const places = Math.max(
|
|
84
|
+
decimalPlaces(Number.isNaN(initialNumeric) ? min : initialNumeric),
|
|
85
|
+
decimalPlaces(min),
|
|
86
|
+
decimalPlaces(max)
|
|
87
|
+
);
|
|
88
|
+
return places > 0 ? Math.pow(10, -places) : 1;
|
|
89
|
+
})();
|
|
90
|
+
|
|
91
|
+
const effectiveStep = $derived(typeof step === 'number' && step > 0 ? step : inferredStep);
|
|
92
|
+
|
|
59
93
|
/**
|
|
60
94
|
* Compute the percentage position for the filled track
|
|
61
95
|
* Used to show visual progress of the slider
|
|
@@ -79,14 +113,20 @@
|
|
|
79
113
|
|
|
80
114
|
<div class="form-range-container">
|
|
81
115
|
<div class="form-range-slider">
|
|
116
|
+
<!--
|
|
117
|
+
Order matters: min/max/step must be applied BEFORE value. A range input
|
|
118
|
+
defaults to step=1, so setting value=0.7 first snaps it to 1, and the later
|
|
119
|
+
step=0.1 does not re-validate the already-snapped value. Setting the bounds
|
|
120
|
+
and step first lets the value land truthfully.
|
|
121
|
+
-->
|
|
82
122
|
<input
|
|
83
123
|
{id}
|
|
84
124
|
type="range"
|
|
85
125
|
class="form-range-field"
|
|
86
|
-
value={numericValue}
|
|
87
126
|
{min}
|
|
88
127
|
{max}
|
|
89
|
-
{
|
|
128
|
+
step={effectiveStep}
|
|
129
|
+
value={numericValue}
|
|
90
130
|
{disabled}
|
|
91
131
|
{required}
|
|
92
132
|
aria-describedby={ariaDescribedBy}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
SurfaceOverlay
|
|
3
|
+
A reusable centered modal shell used to host a surface (or a TabbedSurface of
|
|
4
|
+
several) in the `modal` placement. Portals to `document.body` so the fixed
|
|
5
|
+
backdrop escapes any ancestor that establishes a containing block (transform,
|
|
6
|
+
filter, backdrop-filter, …). Esc and backdrop-click close it.
|
|
7
|
+
|
|
8
|
+
Promotes the modal shell first built inline in ConfigPanel so config, console,
|
|
9
|
+
and chat can all float when their placement is `modal`.
|
|
10
|
+
-->
|
|
11
|
+
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import type { Snippet } from 'svelte';
|
|
14
|
+
import { portal } from '../../utils/portal.js';
|
|
15
|
+
|
|
16
|
+
interface Props {
|
|
17
|
+
/** Header title. */
|
|
18
|
+
title: string;
|
|
19
|
+
/** Accessible label for the close button. */
|
|
20
|
+
closeLabel?: string;
|
|
21
|
+
/** Called on Esc, backdrop click, or the close button. */
|
|
22
|
+
onClose: () => void;
|
|
23
|
+
/** Overlay body. */
|
|
24
|
+
children: Snippet;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const { title, closeLabel = 'Close', onClose, children }: Props = $props();
|
|
28
|
+
|
|
29
|
+
const uid = $props.id();
|
|
30
|
+
const titleId = `${uid}-surface-overlay-title`;
|
|
31
|
+
|
|
32
|
+
function handleKeydown(event: KeyboardEvent) {
|
|
33
|
+
if (event.key === 'Escape') {
|
|
34
|
+
event.stopPropagation();
|
|
35
|
+
onClose();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function handleBackdropClick(event: MouseEvent) {
|
|
40
|
+
if (event.target === event.currentTarget) {
|
|
41
|
+
onClose();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
47
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
48
|
+
<div
|
|
49
|
+
class="surface-overlay__backdrop"
|
|
50
|
+
use:portal
|
|
51
|
+
onclick={handleBackdropClick}
|
|
52
|
+
onkeydown={handleKeydown}
|
|
53
|
+
>
|
|
54
|
+
<div
|
|
55
|
+
class="surface-overlay"
|
|
56
|
+
role="dialog"
|
|
57
|
+
aria-modal="true"
|
|
58
|
+
aria-labelledby={titleId}
|
|
59
|
+
tabindex="-1"
|
|
60
|
+
>
|
|
61
|
+
<div class="surface-overlay__header">
|
|
62
|
+
<h2 id={titleId} class="surface-overlay__title">{title}</h2>
|
|
63
|
+
<button class="surface-overlay__close" onclick={onClose} aria-label={closeLabel}> × </button>
|
|
64
|
+
</div>
|
|
65
|
+
<div class="surface-overlay__body">
|
|
66
|
+
{@render children()}
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<style>
|
|
72
|
+
.surface-overlay__backdrop {
|
|
73
|
+
position: fixed;
|
|
74
|
+
inset: 0;
|
|
75
|
+
background-color: var(--fd-backdrop, rgba(0, 0, 0, 0.5));
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
justify-content: center;
|
|
79
|
+
z-index: 1000;
|
|
80
|
+
padding: 1rem;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.surface-overlay {
|
|
84
|
+
display: flex;
|
|
85
|
+
flex-direction: column;
|
|
86
|
+
width: 100%;
|
|
87
|
+
max-width: 48rem;
|
|
88
|
+
max-height: 90vh;
|
|
89
|
+
background-color: var(--fd-panel-bg, var(--fd-card));
|
|
90
|
+
border: 1px solid var(--fd-border);
|
|
91
|
+
border-radius: var(--fd-radius-lg, 0.75rem);
|
|
92
|
+
box-shadow: var(--fd-shadow-lg, 0 20px 25px -5px rgba(0, 0, 0, 0.25));
|
|
93
|
+
overflow: hidden;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.surface-overlay__header {
|
|
97
|
+
display: flex;
|
|
98
|
+
justify-content: space-between;
|
|
99
|
+
align-items: center;
|
|
100
|
+
padding: 0.875rem 1rem;
|
|
101
|
+
border-bottom: 1px solid var(--fd-border);
|
|
102
|
+
background-color: var(--fd-card);
|
|
103
|
+
flex-shrink: 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.surface-overlay__title {
|
|
107
|
+
margin: 0;
|
|
108
|
+
font-size: 1rem;
|
|
109
|
+
font-weight: 600;
|
|
110
|
+
color: var(--fd-foreground);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.surface-overlay__close {
|
|
114
|
+
background: none;
|
|
115
|
+
border: none;
|
|
116
|
+
font-size: 1.25rem;
|
|
117
|
+
line-height: 1;
|
|
118
|
+
cursor: pointer;
|
|
119
|
+
color: var(--fd-muted-foreground);
|
|
120
|
+
padding: 0.25rem;
|
|
121
|
+
border-radius: var(--fd-radius-sm);
|
|
122
|
+
transition:
|
|
123
|
+
color var(--fd-transition-fast),
|
|
124
|
+
background-color var(--fd-transition-fast);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.surface-overlay__close:hover {
|
|
128
|
+
color: var(--fd-foreground);
|
|
129
|
+
background-color: var(--fd-subtle);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.surface-overlay__body {
|
|
133
|
+
flex: 1;
|
|
134
|
+
min-height: 0;
|
|
135
|
+
overflow-y: auto;
|
|
136
|
+
display: flex;
|
|
137
|
+
flex-direction: column;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@media (max-width: 640px) {
|
|
141
|
+
.surface-overlay {
|
|
142
|
+
max-width: 100%;
|
|
143
|
+
max-height: 95vh;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Header title. */
|
|
4
|
+
title: string;
|
|
5
|
+
/** Accessible label for the close button. */
|
|
6
|
+
closeLabel?: string;
|
|
7
|
+
/** Called on Esc, backdrop click, or the close button. */
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
/** Overlay body. */
|
|
10
|
+
children: Snippet;
|
|
11
|
+
}
|
|
12
|
+
declare const SurfaceOverlay: import("svelte").Component<Props, {}, "">;
|
|
13
|
+
type SurfaceOverlay = ReturnType<typeof SurfaceOverlay>;
|
|
14
|
+
export default SurfaceOverlay;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
TabbedSurface
|
|
3
|
+
A reusable tabbed container that hosts one or more "surfaces" (config panel,
|
|
4
|
+
console, AI Assistant). Promotes the bottom-panel tab strip so the same
|
|
5
|
+
container can host surfaces in the sidebar, bottom panel, or a modal overlay.
|
|
6
|
+
|
|
7
|
+
All tab bodies stay mounted (toggled via `display`) so surface state — console
|
|
8
|
+
scrollback, chat history, in-progress form edits — survives tab switches. The
|
|
9
|
+
tab bar hides itself when only a single surface is present, so a lone surface
|
|
10
|
+
reads as a plain panel with no redundant chrome.
|
|
11
|
+
-->
|
|
12
|
+
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
import type { Snippet } from 'svelte';
|
|
15
|
+
|
|
16
|
+
/** A single hostable surface. */
|
|
17
|
+
export interface SurfaceTab {
|
|
18
|
+
/** Stable identifier, unique within the host. */
|
|
19
|
+
id: string;
|
|
20
|
+
/** Tab-strip label. */
|
|
21
|
+
label: string;
|
|
22
|
+
/** Body content. Rendered once — a surface has exactly one host. */
|
|
23
|
+
content: Snippet;
|
|
24
|
+
/**
|
|
25
|
+
* `display` value applied while active. Some surfaces (the console) expect
|
|
26
|
+
* to be a direct flex child of the content area and use `contents`; most
|
|
27
|
+
* use `flex`. Defaults to `flex`.
|
|
28
|
+
*/
|
|
29
|
+
display?: 'flex' | 'contents';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface Props {
|
|
33
|
+
/** Surfaces to host, in tab order. */
|
|
34
|
+
tabs: SurfaceTab[];
|
|
35
|
+
/** Currently active tab id. */
|
|
36
|
+
activeId: string;
|
|
37
|
+
/** Called when a tab is selected. */
|
|
38
|
+
onSelect: (id: string) => void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const { tabs, activeId, onSelect }: Props = $props();
|
|
42
|
+
|
|
43
|
+
// Fall back to the first tab when `activeId` doesn't match any present tab
|
|
44
|
+
// (e.g. the active surface was just routed to a different host).
|
|
45
|
+
const resolvedActiveId = $derived(
|
|
46
|
+
tabs.some((t) => t.id === activeId) ? activeId : (tabs[0]?.id ?? '')
|
|
47
|
+
);
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<div class="tabbed-surface">
|
|
51
|
+
{#if tabs.length > 1}
|
|
52
|
+
<div class="tabbed-surface__bar" role="tablist">
|
|
53
|
+
{#each tabs as tab (tab.id)}
|
|
54
|
+
<button
|
|
55
|
+
class="tabbed-surface__tab {tab.id === resolvedActiveId
|
|
56
|
+
? 'tabbed-surface__tab--active'
|
|
57
|
+
: ''}"
|
|
58
|
+
role="tab"
|
|
59
|
+
aria-selected={tab.id === resolvedActiveId}
|
|
60
|
+
onclick={() => onSelect(tab.id)}
|
|
61
|
+
>
|
|
62
|
+
{tab.label}
|
|
63
|
+
</button>
|
|
64
|
+
{/each}
|
|
65
|
+
</div>
|
|
66
|
+
{/if}
|
|
67
|
+
|
|
68
|
+
<div class="tabbed-surface__content">
|
|
69
|
+
{#each tabs as tab (tab.id)}
|
|
70
|
+
<div
|
|
71
|
+
class="tabbed-surface__panel"
|
|
72
|
+
style:display={tab.id === resolvedActiveId ? (tab.display ?? 'flex') : 'none'}
|
|
73
|
+
>
|
|
74
|
+
{@render tab.content()}
|
|
75
|
+
</div>
|
|
76
|
+
{/each}
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<style>
|
|
81
|
+
.tabbed-surface {
|
|
82
|
+
display: flex;
|
|
83
|
+
flex-direction: column;
|
|
84
|
+
height: 100%;
|
|
85
|
+
overflow: hidden;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.tabbed-surface__bar {
|
|
89
|
+
display: flex;
|
|
90
|
+
gap: 0;
|
|
91
|
+
background: var(--fd-muted);
|
|
92
|
+
border-bottom: 1px solid var(--fd-border);
|
|
93
|
+
flex-shrink: 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.tabbed-surface__tab {
|
|
97
|
+
padding: 0.375rem 0.75rem;
|
|
98
|
+
font-size: 0.75rem;
|
|
99
|
+
font-weight: 500;
|
|
100
|
+
cursor: pointer;
|
|
101
|
+
border: none;
|
|
102
|
+
border-bottom: 2px solid transparent;
|
|
103
|
+
background: transparent;
|
|
104
|
+
color: var(--fd-muted-foreground);
|
|
105
|
+
transition: all var(--fd-transition-fast);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.tabbed-surface__tab:hover {
|
|
109
|
+
color: var(--fd-foreground);
|
|
110
|
+
background: var(--fd-background);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.tabbed-surface__tab--active {
|
|
114
|
+
color: var(--fd-foreground);
|
|
115
|
+
border-bottom-color: var(--fd-primary);
|
|
116
|
+
background: var(--fd-background);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.tabbed-surface__content {
|
|
120
|
+
flex: 1;
|
|
121
|
+
min-height: 0;
|
|
122
|
+
overflow: hidden;
|
|
123
|
+
display: flex;
|
|
124
|
+
flex-direction: column;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.tabbed-surface__panel {
|
|
128
|
+
flex: 1;
|
|
129
|
+
min-height: 0;
|
|
130
|
+
overflow: hidden;
|
|
131
|
+
flex-direction: column;
|
|
132
|
+
}
|
|
133
|
+
</style>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
/** A single hostable surface. */
|
|
3
|
+
export interface SurfaceTab {
|
|
4
|
+
/** Stable identifier, unique within the host. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** Tab-strip label. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Body content. Rendered once — a surface has exactly one host. */
|
|
9
|
+
content: Snippet;
|
|
10
|
+
/**
|
|
11
|
+
* `display` value applied while active. Some surfaces (the console) expect
|
|
12
|
+
* to be a direct flex child of the content area and use `contents`; most
|
|
13
|
+
* use `flex`. Defaults to `flex`.
|
|
14
|
+
*/
|
|
15
|
+
display?: 'flex' | 'contents';
|
|
16
|
+
}
|
|
17
|
+
interface Props {
|
|
18
|
+
/** Surfaces to host, in tab order. */
|
|
19
|
+
tabs: SurfaceTab[];
|
|
20
|
+
/** Currently active tab id. */
|
|
21
|
+
activeId: string;
|
|
22
|
+
/** Called when a tab is selected. */
|
|
23
|
+
onSelect: (id: string) => void;
|
|
24
|
+
}
|
|
25
|
+
declare const TabbedSurface: import("svelte").Component<Props, {}, "">;
|
|
26
|
+
type TabbedSurface = ReturnType<typeof TabbedSurface>;
|
|
27
|
+
export default TabbedSurface;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @module services/dynamicSchemaService
|
|
7
7
|
*/
|
|
8
|
-
import type { ConfigSchema, DynamicSchemaEndpoint, ExternalEditLink, ConfigEditOptions, WorkflowNode } from '../types/index.js';
|
|
8
|
+
import type { ConfigSchema, DynamicSchemaEndpoint, ExternalEditLink, ConfigEditOptions, UISchemaElement, WorkflowNode } from '../types/index.js';
|
|
9
9
|
import type { EndpointConfig } from '../config/endpoints.js';
|
|
10
10
|
/**
|
|
11
11
|
* Result of a dynamic schema fetch operation
|
|
@@ -15,11 +15,33 @@ export interface DynamicSchemaResult {
|
|
|
15
15
|
success: boolean;
|
|
16
16
|
/** The fetched config schema (if successful) */
|
|
17
17
|
schema?: ConfigSchema;
|
|
18
|
+
/**
|
|
19
|
+
* The fetched uiSchema, when the endpoint returns one alongside the schema.
|
|
20
|
+
* Lets a server-hydrated response carry its own field grouping/layout so the
|
|
21
|
+
* form isn't stuck with the node's static-metadata uiSchema (which only
|
|
22
|
+
* references the static schema's properties).
|
|
23
|
+
*/
|
|
24
|
+
uiSchema?: UISchemaElement;
|
|
18
25
|
/** Error message (if failed) */
|
|
19
26
|
error?: string;
|
|
20
27
|
/** Whether the schema was loaded from cache */
|
|
21
28
|
fromCache?: boolean;
|
|
22
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Resolves the fetch key for a node's dynamic-schema endpoint: the endpoint URL
|
|
32
|
+
* with all template variables substituted from the node context.
|
|
33
|
+
*
|
|
34
|
+
* The key changes whenever a config value the endpoint's `parameterMapping`
|
|
35
|
+
* references changes (e.g. a trigger node's `event_type`). Callers watch it to
|
|
36
|
+
* refetch the schema when the inputs that shape it change, keeping the rendered
|
|
37
|
+
* form in step with the current configuration.
|
|
38
|
+
*
|
|
39
|
+
* @param endpoint - The dynamic schema endpoint configuration
|
|
40
|
+
* @param node - The workflow node instance
|
|
41
|
+
* @param workflowId - Optional workflow ID for context
|
|
42
|
+
* @returns The resolved endpoint URL, used as a reactive refetch key
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveDynamicSchemaKey(endpoint: DynamicSchemaEndpoint, node: WorkflowNode, workflowId?: string): string;
|
|
23
45
|
/**
|
|
24
46
|
* Fetches a dynamic configuration schema from a REST endpoint.
|
|
25
47
|
*
|
|
@@ -82,10 +104,15 @@ export declare function clearSchemaCache(pattern?: string): void;
|
|
|
82
104
|
/**
|
|
83
105
|
* Invalidates a specific schema cache entry for a node.
|
|
84
106
|
*
|
|
107
|
+
* The workflow ID must match the value passed when the schema was fetched:
|
|
108
|
+
* endpoints whose URL references `{workflowId}` resolve to a different cache key
|
|
109
|
+
* without it, so omitting it here would miss the entry the fetch created.
|
|
110
|
+
*
|
|
85
111
|
* @param node - The workflow node to invalidate cache for
|
|
86
112
|
* @param endpoint - The dynamic schema endpoint configuration
|
|
113
|
+
* @param workflowId - Optional workflow ID, matching the fetch context
|
|
87
114
|
*/
|
|
88
|
-
export declare function invalidateSchemaCache(node: WorkflowNode, endpoint: DynamicSchemaEndpoint): void;
|
|
115
|
+
export declare function invalidateSchemaCache(node: WorkflowNode, endpoint: DynamicSchemaEndpoint, workflowId?: string): void;
|
|
89
116
|
/**
|
|
90
117
|
* Checks if a node has config edit options configured.
|
|
91
118
|
*
|
|
@@ -104,6 +104,44 @@ function generateCacheKey(endpoint, context) {
|
|
|
104
104
|
const url = resolveTemplate(endpoint.url, endpoint.parameterMapping, context);
|
|
105
105
|
return `schema:${url}`;
|
|
106
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Builds the template-resolution context for a node.
|
|
109
|
+
*
|
|
110
|
+
* Shared by every function that resolves a dynamic-schema URL, external-edit
|
|
111
|
+
* URL, or cache key, so they all read identical values — and therefore compute
|
|
112
|
+
* matching keys — from a single place.
|
|
113
|
+
*
|
|
114
|
+
* @param node - The workflow node instance
|
|
115
|
+
* @param workflowId - Optional workflow ID for context
|
|
116
|
+
* @returns The node context used for template resolution
|
|
117
|
+
*/
|
|
118
|
+
function buildNodeContext(node, workflowId) {
|
|
119
|
+
return {
|
|
120
|
+
id: node.id,
|
|
121
|
+
type: node.type,
|
|
122
|
+
metadata: node.data.metadata,
|
|
123
|
+
config: node.data.config,
|
|
124
|
+
extensions: node.data.extensions,
|
|
125
|
+
workflowId
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Resolves the fetch key for a node's dynamic-schema endpoint: the endpoint URL
|
|
130
|
+
* with all template variables substituted from the node context.
|
|
131
|
+
*
|
|
132
|
+
* The key changes whenever a config value the endpoint's `parameterMapping`
|
|
133
|
+
* references changes (e.g. a trigger node's `event_type`). Callers watch it to
|
|
134
|
+
* refetch the schema when the inputs that shape it change, keeping the rendered
|
|
135
|
+
* form in step with the current configuration.
|
|
136
|
+
*
|
|
137
|
+
* @param endpoint - The dynamic schema endpoint configuration
|
|
138
|
+
* @param node - The workflow node instance
|
|
139
|
+
* @param workflowId - Optional workflow ID for context
|
|
140
|
+
* @returns The resolved endpoint URL, used as a reactive refetch key
|
|
141
|
+
*/
|
|
142
|
+
export function resolveDynamicSchemaKey(endpoint, node, workflowId) {
|
|
143
|
+
return resolveTemplate(endpoint.url, endpoint.parameterMapping, buildNodeContext(node, workflowId));
|
|
144
|
+
}
|
|
107
145
|
/**
|
|
108
146
|
* Checks if a cached schema is still valid (not expired).
|
|
109
147
|
*
|
|
@@ -138,14 +176,7 @@ function isCacheValid(entry, ttl = DEFAULT_CACHE_TTL) {
|
|
|
138
176
|
*/
|
|
139
177
|
export async function fetchDynamicSchema(endpointConfig, endpoint, node, workflowId) {
|
|
140
178
|
// Build the context from the node
|
|
141
|
-
const context =
|
|
142
|
-
id: node.id,
|
|
143
|
-
type: node.type,
|
|
144
|
-
metadata: node.data.metadata,
|
|
145
|
-
config: node.data.config,
|
|
146
|
-
extensions: node.data.extensions,
|
|
147
|
-
workflowId
|
|
148
|
-
};
|
|
179
|
+
const context = buildNodeContext(node, workflowId);
|
|
149
180
|
// Generate cache key
|
|
150
181
|
const cacheKey = generateCacheKey(endpoint, context);
|
|
151
182
|
// Check cache first (if caching is enabled)
|
|
@@ -155,6 +186,7 @@ export async function fetchDynamicSchema(endpointConfig, endpoint, node, workflo
|
|
|
155
186
|
return {
|
|
156
187
|
success: true,
|
|
157
188
|
schema: cached.schema,
|
|
189
|
+
uiSchema: cached.uiSchema,
|
|
158
190
|
fromCache: true
|
|
159
191
|
};
|
|
160
192
|
}
|
|
@@ -232,10 +264,15 @@ export async function fetchDynamicSchema(endpointConfig, endpoint, node, workflo
|
|
|
232
264
|
error: 'Invalid schema format received from endpoint'
|
|
233
265
|
};
|
|
234
266
|
}
|
|
267
|
+
// A companion uiSchema may ride alongside the schema (server-hydrated
|
|
268
|
+
// forms). Look for it next to wherever the schema was found — sibling of
|
|
269
|
+
// the envelope, or nested in the same `data`/`schema` wrapper.
|
|
270
|
+
const uiSchema = (data.uiSchema ?? data.data?.uiSchema ?? data.schema?.uiSchema);
|
|
235
271
|
// Cache the schema (if caching is enabled)
|
|
236
272
|
if (endpoint.cacheSchema !== false) {
|
|
237
273
|
schemaCache.set(cacheKey, {
|
|
238
274
|
schema,
|
|
275
|
+
uiSchema,
|
|
239
276
|
cachedAt: Date.now(),
|
|
240
277
|
cacheKey
|
|
241
278
|
});
|
|
@@ -243,6 +280,7 @@ export async function fetchDynamicSchema(endpointConfig, endpoint, node, workflo
|
|
|
243
280
|
return {
|
|
244
281
|
success: true,
|
|
245
282
|
schema,
|
|
283
|
+
uiSchema,
|
|
246
284
|
fromCache: false
|
|
247
285
|
};
|
|
248
286
|
}
|
|
@@ -288,14 +326,7 @@ export async function fetchDynamicSchema(endpointConfig, endpoint, node, workflo
|
|
|
288
326
|
*/
|
|
289
327
|
export function resolveExternalEditUrl(link, node, workflowId, callbackUrl) {
|
|
290
328
|
// Build the context from the node
|
|
291
|
-
const context =
|
|
292
|
-
id: node.id,
|
|
293
|
-
type: node.type,
|
|
294
|
-
metadata: node.data.metadata,
|
|
295
|
-
config: node.data.config,
|
|
296
|
-
extensions: node.data.extensions,
|
|
297
|
-
workflowId
|
|
298
|
-
};
|
|
329
|
+
const context = buildNodeContext(node, workflowId);
|
|
299
330
|
// Resolve the URL with template variables
|
|
300
331
|
let url = resolveTemplate(link.url, link.parameterMapping, context);
|
|
301
332
|
// Append callback URL if configured
|
|
@@ -367,18 +398,16 @@ export function clearSchemaCache(pattern) {
|
|
|
367
398
|
/**
|
|
368
399
|
* Invalidates a specific schema cache entry for a node.
|
|
369
400
|
*
|
|
401
|
+
* The workflow ID must match the value passed when the schema was fetched:
|
|
402
|
+
* endpoints whose URL references `{workflowId}` resolve to a different cache key
|
|
403
|
+
* without it, so omitting it here would miss the entry the fetch created.
|
|
404
|
+
*
|
|
370
405
|
* @param node - The workflow node to invalidate cache for
|
|
371
406
|
* @param endpoint - The dynamic schema endpoint configuration
|
|
407
|
+
* @param workflowId - Optional workflow ID, matching the fetch context
|
|
372
408
|
*/
|
|
373
|
-
export function invalidateSchemaCache(node, endpoint) {
|
|
374
|
-
const
|
|
375
|
-
id: node.id,
|
|
376
|
-
type: node.type,
|
|
377
|
-
metadata: node.data.metadata,
|
|
378
|
-
config: node.data.config,
|
|
379
|
-
extensions: node.data.extensions
|
|
380
|
-
};
|
|
381
|
-
const cacheKey = generateCacheKey(endpoint, context);
|
|
409
|
+
export function invalidateSchemaCache(node, endpoint, workflowId) {
|
|
410
|
+
const cacheKey = generateCacheKey(endpoint, buildNodeContext(node, workflowId));
|
|
382
411
|
schemaCache.delete(cacheKey);
|
|
383
412
|
}
|
|
384
413
|
/**
|
|
@@ -64,6 +64,19 @@ export declare function getSystemThemeState(): ResolvedTheme;
|
|
|
64
64
|
* @returns Cleanup function that removes the listener
|
|
65
65
|
*/
|
|
66
66
|
export declare function initThemeListener(): () => void;
|
|
67
|
+
/**
|
|
68
|
+
* Seed UI settings from host-provided defaults (e.g. mount props) without
|
|
69
|
+
* overriding a returning user's persisted choices.
|
|
70
|
+
*
|
|
71
|
+
* For each provided key, the value is applied only when that key is **absent**
|
|
72
|
+
* from the persisted snapshot — so a mount prop sets the initial behavior but a
|
|
73
|
+
* value the user has actually changed always wins. Seeded values are not
|
|
74
|
+
* written to storage (storage stays user-driven), matching the precedence used
|
|
75
|
+
* by {@link initializeSettings}: library default < host default < user snapshot.
|
|
76
|
+
*
|
|
77
|
+
* @param partial - UI defaults to seed
|
|
78
|
+
*/
|
|
79
|
+
export declare function seedUiDefaults(partial: Partial<UISettings>): void;
|
|
67
80
|
/**
|
|
68
81
|
* Update settings with partial values
|
|
69
82
|
*
|
|
@@ -268,6 +268,38 @@ function notifyChange(category, key, previousValue, newValue) {
|
|
|
268
268
|
function getCategoryAsRecord(settings, category) {
|
|
269
269
|
return Object.fromEntries(Object.entries(settings[category]));
|
|
270
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Seed UI settings from host-provided defaults (e.g. mount props) without
|
|
273
|
+
* overriding a returning user's persisted choices.
|
|
274
|
+
*
|
|
275
|
+
* For each provided key, the value is applied only when that key is **absent**
|
|
276
|
+
* from the persisted snapshot — so a mount prop sets the initial behavior but a
|
|
277
|
+
* value the user has actually changed always wins. Seeded values are not
|
|
278
|
+
* written to storage (storage stays user-driven), matching the precedence used
|
|
279
|
+
* by {@link initializeSettings}: library default < host default < user snapshot.
|
|
280
|
+
*
|
|
281
|
+
* @param partial - UI defaults to seed
|
|
282
|
+
*/
|
|
283
|
+
export function seedUiDefaults(partial) {
|
|
284
|
+
const persistedUi = loadRawFromStorage()?.ui ?? {};
|
|
285
|
+
const seeded = {};
|
|
286
|
+
for (const key of Object.keys(partial)) {
|
|
287
|
+
if (partial[key] === undefined)
|
|
288
|
+
continue;
|
|
289
|
+
if (key in persistedUi)
|
|
290
|
+
continue;
|
|
291
|
+
seeded[key] = partial[key];
|
|
292
|
+
}
|
|
293
|
+
if (Object.keys(seeded).length === 0)
|
|
294
|
+
return;
|
|
295
|
+
storeState = {
|
|
296
|
+
...storeState,
|
|
297
|
+
settings: {
|
|
298
|
+
...storeState.settings,
|
|
299
|
+
ui: { ...storeState.settings.ui, ...seeded }
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
}
|
|
271
303
|
/**
|
|
272
304
|
* Update settings with partial values
|
|
273
305
|
*
|
|
@@ -478,9 +478,14 @@ export class WorkflowStore {
|
|
|
478
478
|
}
|
|
479
479
|
/** Add an edge. */
|
|
480
480
|
addEdge(edge) {
|
|
481
|
-
this.#pushToHistory('Add connection');
|
|
482
481
|
if (!this.#workflow)
|
|
483
482
|
return;
|
|
483
|
+
// Never append an edge whose id already exists — SvelteFlow keys edges by id
|
|
484
|
+
// and a duplicate throws `each_key_duplicate`, taking down the canvas. Guard
|
|
485
|
+
// before touching history so a no-op stays a no-op.
|
|
486
|
+
if (this.#workflow.edges.some((e) => e.id === edge.id))
|
|
487
|
+
return;
|
|
488
|
+
this.#pushToHistory('Add connection');
|
|
484
489
|
this.#workflow = {
|
|
485
490
|
...this.#workflow,
|
|
486
491
|
edges: [...this.#workflow.edges, edge],
|
package/dist/svelte-app.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ import type { FlowDropTheme, FlowDropThemeName } from './types/theme.js';
|
|
|
14
14
|
import type { WorkflowFormatAdapter } from './registry/workflowFormatRegistry.js';
|
|
15
15
|
import { type FlowDropInstance } from './stores/instanceContainer.svelte.js';
|
|
16
16
|
import { type DraftStorageOption } from './services/draftStorage.js';
|
|
17
|
-
import type { PartialSettings, SettingsCategory } from './types/settings.js';
|
|
17
|
+
import type { PartialSettings, SettingsCategory, SurfacePlacement } from './types/settings.js';
|
|
18
18
|
import type { NavbarAction } from './types/navbar.js';
|
|
19
19
|
export type { NavbarAction };
|
|
20
20
|
/**
|
|
@@ -39,6 +39,17 @@ export interface FlowDropMountOptions {
|
|
|
39
39
|
showNavbar?: boolean;
|
|
40
40
|
/** Disable the node sidebar */
|
|
41
41
|
disableSidebar?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Default host for the config panel: `sidebar` (default), `modal`, or
|
|
44
|
+
* `below`. Seeds the user setting on first load; a later user change wins.
|
|
45
|
+
*/
|
|
46
|
+
configPlacement?: SurfacePlacement;
|
|
47
|
+
/**
|
|
48
|
+
* Default host for the console / AI Assistant group: `below` (default),
|
|
49
|
+
* `sidebar`, or `modal`. Seeds the user setting on first load; a later user
|
|
50
|
+
* change wins.
|
|
51
|
+
*/
|
|
52
|
+
consolePlacement?: SurfacePlacement;
|
|
42
53
|
/**
|
|
43
54
|
* Editor interaction mode. Replaces the former `readOnly` + `lockWorkflow`
|
|
44
55
|
* mount options (2.0). `'edit'` (default) allows editing; `'readonly'` and
|