@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.
@@ -132,7 +132,7 @@ async function configureInstance(fd, options) {
132
132
  * ```
133
133
  */
134
134
  export async function mountFlowDropApp(container, options = {}) {
135
- const { workflow, nodes, endpointConfig, portConfig, categories, height = '100vh', width = '100%', showNavbar = false, disableSidebar, mode, pipelineId, navbarTitle, navbarActions, showSettings, showStatus, authProvider, eventHandlers, features: userFeatures, settings: initialSettings, draftStorageKey: customDraftKey, draftStorage, formatAdapters, theme, settingsCategories, showSettingsSyncButton, showSettingsResetButton, instanceId } = options;
135
+ const { workflow, nodes, endpointConfig, portConfig, categories, height = '100vh', width = '100%', showNavbar = false, disableSidebar, configPlacement, consolePlacement, mode, pipelineId, navbarTitle, navbarActions, showSettings, showStatus, authProvider, eventHandlers, features: userFeatures, settings: initialSettings, draftStorageKey: customDraftKey, draftStorage, formatAdapters, theme, settingsCategories, showSettingsSyncButton, showSettingsResetButton, instanceId } = options;
136
136
  // Per-instance state container — this is what allows multiple FlowDrop
137
137
  // editors to coexist on one page without sharing workflow/history state.
138
138
  const { fd, isDefault } = acquireInstance(instanceId);
@@ -181,6 +181,8 @@ export async function mountFlowDropApp(container, options = {}) {
181
181
  width,
182
182
  showNavbar,
183
183
  disableSidebar,
184
+ configPlacement,
185
+ consolePlacement,
184
186
  mode,
185
187
  pipelineId,
186
188
  navbarTitle,
@@ -415,6 +415,35 @@ export interface DynamicSchemaEndpoint {
415
415
  * @default true
416
416
  */
417
417
  cacheSchema?: boolean;
418
+ /**
419
+ * How the fetched schema combines with the node's static schema
420
+ * (the direct `schema` prop or `metadata.configSchema`).
421
+ *
422
+ * - `"replace"` (default): the fetched schema is used as-is and the static
423
+ * schema is ignored. This is the historical behaviour.
424
+ * - `"merge"`: the fetched schema is layered onto the static schema —
425
+ * properties are merged (fetched wins per key) and `required` is unioned —
426
+ * so the endpoint only has to return the fields it actually drives.
427
+ *
428
+ * When there is no static schema to combine with, both strategies behave
429
+ * identically: the fetched schema is the form.
430
+ *
431
+ * @default "replace"
432
+ */
433
+ mergeStrategy?: 'replace' | 'merge';
434
+ /**
435
+ * Restricts the fetched schema to a region of the static schema instead of
436
+ * the whole form. A dot-path of property keys descending through nested
437
+ * object `properties` (e.g. `"advanced"` or `"advanced.retry"`); the fetched
438
+ * schema is spliced in at that location and every other field stays static.
439
+ *
440
+ * Use this to make just one section (or one field) server-driven while
441
+ * authoring the rest of the form locally. `mergeStrategy` then decides whether
442
+ * the fetched schema replaces or merges into the property at that path.
443
+ *
444
+ * When omitted, the fetch applies at the form root (per `mergeStrategy`).
445
+ */
446
+ target?: string;
418
447
  }
419
448
  /**
420
449
  * External edit link configuration
@@ -45,6 +45,18 @@ export interface EditorSettings {
45
45
  /** Distance threshold in pixels for proximity connect */
46
46
  proximityConnectDistance: number;
47
47
  }
48
+ /**
49
+ * Where an auxiliary surface (config panel, console/chat) is hosted.
50
+ *
51
+ * - `sidebar` — the right rail.
52
+ * - `modal` — a centered overlay floating above the canvas.
53
+ * - `below` — the bottom panel.
54
+ *
55
+ * Surfaces routed to the same host coexist as tabs. Modelled as one enum per
56
+ * surface (rather than a boolean per host) so invalid combinations — two hosts
57
+ * at once, or none — are unrepresentable.
58
+ */
59
+ export type SurfacePlacement = 'sidebar' | 'modal' | 'below';
48
60
  /**
49
61
  * UI layout and display settings
50
62
  */
@@ -63,6 +75,10 @@ export interface UISettings {
63
75
  consoleHeight: number;
64
76
  /** Active tab in the bottom panel */
65
77
  bottomPanelTab: 'console' | 'chat';
78
+ /** Where the node/workflow configuration panel is hosted. Default `sidebar`. */
79
+ configPlacement: SurfacePlacement;
80
+ /** Where the console / AI Assistant group is hosted. Default `below`. */
81
+ consolePlacement: SurfacePlacement;
66
82
  }
67
83
  /**
68
84
  * Application behavior and automation settings
@@ -62,7 +62,9 @@ export const DEFAULT_UI_SETTINGS = {
62
62
  theme: 'default',
63
63
  consoleOpen: false,
64
64
  consoleHeight: 300,
65
- bottomPanelTab: 'console'
65
+ bottomPanelTab: 'console',
66
+ configPlacement: 'sidebar',
67
+ consolePlacement: 'below'
66
68
  };
67
69
  /**
68
70
  * Default behavior settings
@@ -124,6 +124,11 @@ export interface UISchemaGroup extends UISchemaElementBase {
124
124
  * @default true
125
125
  */
126
126
  defaultOpen?: boolean;
127
+ /**
128
+ * Optional Iconify icon name shown in the group's header bar.
129
+ * Falls back to a neutral default when omitted.
130
+ */
131
+ icon?: string;
127
132
  }
128
133
  /**
129
134
  * Union type of all supported UISchema elements.
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Svelte action that relocates an element to `document.body` (or another
3
+ * target) for its lifetime, then removes it on destroy.
4
+ *
5
+ * Modals and overlays use `position: fixed` expecting the viewport as their
6
+ * containing block. When any ancestor establishes a containing block — via
7
+ * `transform`, `filter`, `backdrop-filter`, `will-change`, `contain`, etc. —
8
+ * `fixed` resolves against that ancestor instead, causing clipping and
9
+ * mis-centering. Portalling the node to `document.body` sidesteps this by
10
+ * escaping those ancestors entirely.
11
+ *
12
+ * Usage: `<div use:portal>…</div>` or `<div use:portal={targetElement}>…</div>`.
13
+ * No-op during SSR (no `document`).
14
+ */
15
+ export declare function portal(node: HTMLElement, target?: HTMLElement | undefined): {
16
+ update(nextTarget: HTMLElement | undefined): void;
17
+ destroy(): void;
18
+ };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Svelte action that relocates an element to `document.body` (or another
3
+ * target) for its lifetime, then removes it on destroy.
4
+ *
5
+ * Modals and overlays use `position: fixed` expecting the viewport as their
6
+ * containing block. When any ancestor establishes a containing block — via
7
+ * `transform`, `filter`, `backdrop-filter`, `will-change`, `contain`, etc. —
8
+ * `fixed` resolves against that ancestor instead, causing clipping and
9
+ * mis-centering. Portalling the node to `document.body` sidesteps this by
10
+ * escaping those ancestors entirely.
11
+ *
12
+ * Usage: `<div use:portal>…</div>` or `<div use:portal={targetElement}>…</div>`.
13
+ * No-op during SSR (no `document`).
14
+ */
15
+ export function portal(node, target = undefined) {
16
+ let host = null;
17
+ function mount(to) {
18
+ if (typeof document === 'undefined')
19
+ return;
20
+ host = to ?? document.body;
21
+ host.appendChild(node);
22
+ }
23
+ mount(target);
24
+ return {
25
+ update(nextTarget) {
26
+ mount(nextTarget);
27
+ },
28
+ destroy() {
29
+ if (node.parentNode) {
30
+ node.parentNode.removeChild(node);
31
+ }
32
+ }
33
+ };
34
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Combines a dynamically-fetched config schema with a node's static schema.
3
+ *
4
+ * Dynamic schema used to be all-or-nothing: the fetched schema replaced the
5
+ * whole form, so an endpoint had to re-serve every field even to drive one, and
6
+ * a narrower response silently dropped fields (and their values) the form no
7
+ * longer rendered. `applyFetchedSchema` lets the fetch instead *layer onto* the
8
+ * static schema — merging fields or targeting a single region — so the rest of
9
+ * the form stays exactly as authored.
10
+ *
11
+ * Kept as a standalone pure function so it can be unit-tested directly against
12
+ * the same code `ConfigForm` runs, rather than through the component.
13
+ */
14
+ import type { ConfigSchema, DynamicSchemaEndpoint } from '../types/index.js';
15
+ /**
16
+ * Resolves the schema `ConfigForm` should render from a node's static schema
17
+ * and a freshly-fetched dynamic schema, per the endpoint's `mergeStrategy` and
18
+ * `target`.
19
+ *
20
+ * @param base - The node's static schema (`schema` prop or `metadata.configSchema`), if any
21
+ * @param fetched - The schema returned by the dynamic endpoint
22
+ * @param endpoint - Supplies `mergeStrategy` (default `"replace"`) and optional `target`
23
+ * @returns The effective schema to render
24
+ */
25
+ export declare function applyFetchedSchema(base: ConfigSchema | undefined, fetched: ConfigSchema, endpoint: Pick<DynamicSchemaEndpoint, 'mergeStrategy' | 'target'>): ConfigSchema;
@@ -0,0 +1,61 @@
1
+ /** Union two `required` arrays, dropping duplicates; `undefined` when neither has entries. */
2
+ function unionRequired(a, b) {
3
+ if (!a?.length && !b?.length)
4
+ return undefined;
5
+ return Array.from(new Set([...(a ?? []), ...(b ?? [])]));
6
+ }
7
+ /**
8
+ * Layers `fetched` onto `base`: fetched top-level attributes win, `properties`
9
+ * are shallow-merged per key (a field is wholly static or wholly fetched, never
10
+ * half of each), and `required` is unioned.
11
+ */
12
+ function mergeNodes(base, fetched) {
13
+ const merged = { ...base, ...fetched };
14
+ if (base.properties || fetched.properties) {
15
+ merged.properties = { ...(base.properties ?? {}), ...(fetched.properties ?? {}) };
16
+ }
17
+ const required = unionRequired(base.required, fetched.required);
18
+ if (required)
19
+ merged.required = required;
20
+ else
21
+ delete merged.required;
22
+ return merged;
23
+ }
24
+ /**
25
+ * Places `fetched` at `segments` within `base`, cloning each node along the
26
+ * path so the input is never mutated. At the leaf the strategy decides between
27
+ * replacing the existing node outright and merging into it.
28
+ */
29
+ function spliceAtPath(base, fetched, segments, strategy) {
30
+ if (segments.length === 0) {
31
+ return strategy === 'merge' ? mergeNodes(base, fetched) : fetched;
32
+ }
33
+ const [head, ...rest] = segments;
34
+ const properties = base.properties ?? {};
35
+ const existing = (properties[head] ?? {});
36
+ return {
37
+ ...base,
38
+ properties: {
39
+ ...properties,
40
+ [head]: spliceAtPath(existing, fetched, rest, strategy)
41
+ }
42
+ };
43
+ }
44
+ /**
45
+ * Resolves the schema `ConfigForm` should render from a node's static schema
46
+ * and a freshly-fetched dynamic schema, per the endpoint's `mergeStrategy` and
47
+ * `target`.
48
+ *
49
+ * @param base - The node's static schema (`schema` prop or `metadata.configSchema`), if any
50
+ * @param fetched - The schema returned by the dynamic endpoint
51
+ * @param endpoint - Supplies `mergeStrategy` (default `"replace"`) and optional `target`
52
+ * @returns The effective schema to render
53
+ */
54
+ export function applyFetchedSchema(base, fetched, endpoint) {
55
+ const strategy = endpoint.mergeStrategy ?? 'replace';
56
+ // Nothing to combine with: the fetched schema is the whole form.
57
+ if (!base)
58
+ return fetched;
59
+ const segments = endpoint.target ? endpoint.target.split('.').filter(Boolean) : [];
60
+ return spliceAtPath(base, fetched, segments, strategy);
61
+ }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A drop-in visual workflow editor for any web application. You own the backend. You own the data. You own the orchestration.",
4
4
  "license": "MIT",
5
5
  "private": false,
6
- "version": "2.0.0-beta.6",
6
+ "version": "2.0.0-beta.8",
7
7
  "author": "Shibin Das (D34dMan)",
8
8
  "bugs": {
9
9
  "url": "https://github.com/flowdrop-io/flowdrop/issues"