@d34dman/flowdrop 0.0.28 → 0.0.29

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.
@@ -0,0 +1,117 @@
1
+ /**
2
+ * FlowDrop Editor Module
3
+ *
4
+ * Provides the WorkflowEditor component and related functionality for
5
+ * building visual workflow editors. This module includes @xyflow/svelte
6
+ * and all node components.
7
+ *
8
+ * @module editor
9
+ *
10
+ * @example Mounting a standalone workflow editor:
11
+ * ```typescript
12
+ * import { mountFlowDropApp, WorkflowEditor } from "@d34dman/flowdrop/editor";
13
+ * import "@d34dman/flowdrop/styles";
14
+ *
15
+ * const app = await mountFlowDropApp(document.getElementById("editor"), {
16
+ * workflow: myWorkflow,
17
+ * nodes: availableNodes
18
+ * });
19
+ * ```
20
+ *
21
+ * @example Using WorkflowEditor in Svelte:
22
+ * ```svelte
23
+ * <script>
24
+ * import { WorkflowEditor } from "@d34dman/flowdrop/editor";
25
+ * </script>
26
+ *
27
+ * <WorkflowEditor nodes={availableNodes} />
28
+ * ```
29
+ */
30
+ // ============================================================================
31
+ // Initialize Built-in Nodes
32
+ // This side effect is intentional for the editor module - users importing
33
+ // the editor expect all node types to be available.
34
+ // ============================================================================
35
+ import "../registry/builtinNodes.js";
36
+ // ============================================================================
37
+ // Main Editor Components
38
+ // ============================================================================
39
+ export { default as WorkflowEditor } from "../components/WorkflowEditor.svelte";
40
+ export { default as App } from "../components/App.svelte";
41
+ // ============================================================================
42
+ // Node Components
43
+ // ============================================================================
44
+ export { default as WorkflowNodeComponent } from "../components/nodes/WorkflowNode.svelte";
45
+ export { default as SimpleNodeComponent } from "../components/nodes/SimpleNode.svelte";
46
+ export { default as ToolNodeComponent } from "../components/nodes/ToolNode.svelte";
47
+ export { default as NotesNodeComponent } from "../components/nodes/NotesNode.svelte";
48
+ export { default as GatewayNode } from "../components/nodes/GatewayNode.svelte";
49
+ export { default as SquareNode } from "../components/nodes/SquareNode.svelte";
50
+ export { default as TerminalNode } from "../components/nodes/TerminalNode.svelte";
51
+ export { default as UniversalNode } from "../components/UniversalNode.svelte";
52
+ // ============================================================================
53
+ // Supporting Editor Components
54
+ // ============================================================================
55
+ export { default as NodeSidebar } from "../components/NodeSidebar.svelte";
56
+ export { default as CanvasBanner } from "../components/CanvasBanner.svelte";
57
+ export { default as LoadingSpinner } from "../components/LoadingSpinner.svelte";
58
+ export { default as StatusIcon } from "../components/StatusIcon.svelte";
59
+ export { default as StatusLabel } from "../components/StatusLabel.svelte";
60
+ export { default as NodeStatusOverlay } from "../components/NodeStatusOverlay.svelte";
61
+ export { default as ConfigForm } from "../components/ConfigForm.svelte";
62
+ export { default as ConfigModal } from "../components/ConfigModal.svelte";
63
+ export { default as ConfigPanel } from "../components/ConfigPanel.svelte";
64
+ export { default as ReadOnlyDetails } from "../components/ReadOnlyDetails.svelte";
65
+ export { default as ConnectionLine } from "../components/ConnectionLine.svelte";
66
+ export { default as LogsSidebar } from "../components/LogsSidebar.svelte";
67
+ export { default as PipelineStatus } from "../components/PipelineStatus.svelte";
68
+ export { default as Navbar } from "../components/Navbar.svelte";
69
+ export { default as Logo } from "../components/Logo.svelte";
70
+ // ============================================================================
71
+ // Mount Functions
72
+ // ============================================================================
73
+ export { mountWorkflowEditor, mountFlowDropApp, unmountFlowDropApp } from "../svelte-app.js";
74
+ // ============================================================================
75
+ // Node Component Registry
76
+ // ============================================================================
77
+ export {
78
+ // Core registry
79
+ nodeComponentRegistry, createNamespacedType, parseNamespacedType,
80
+ // Built-in nodes
81
+ BUILTIN_NODE_COMPONENTS, BUILTIN_NODE_TYPES, FLOWDROP_SOURCE, registerBuiltinNodes, areBuiltinsRegistered, isBuiltinType, getBuiltinTypes, resolveBuiltinAlias,
82
+ // Plugin system
83
+ registerFlowDropPlugin, unregisterFlowDropPlugin, registerCustomNode, createPlugin, isValidNamespace, getRegisteredPlugins, getPluginNodeCount } from "../registry/index.js";
84
+ // ============================================================================
85
+ // Editor Helpers
86
+ // ============================================================================
87
+ export { EdgeStylingHelper, NodeOperationsHelper, WorkflowOperationsHelper, ConfigurationHelper } from "../helpers/workflowEditorHelper.js";
88
+ // ============================================================================
89
+ // Stores
90
+ // ============================================================================
91
+ export { workflowStore, workflowActions, workflowId, workflowName, workflowNodes, workflowEdges, workflowMetadata, workflowChanged, workflowValidation, workflowMetadataChanged, connectedHandles,
92
+ // Dirty state tracking
93
+ isDirtyStore, isDirty, markAsSaved, getWorkflow as getWorkflowFromStore, setOnDirtyStateChange, setOnWorkflowChange } from "../stores/workflowStore.js";
94
+ // ============================================================================
95
+ // Services
96
+ // ============================================================================
97
+ export * from "../services/api.js";
98
+ export { showSuccess, showError, showWarning, showInfo, showLoading, dismissToast, dismissAllToasts, showPromise, showConfirmation, apiToasts, workflowToasts, pipelineToasts } from "../services/toastService.js";
99
+ export { NodeExecutionService, nodeExecutionService } from "../services/nodeExecutionService.js";
100
+ export { saveWorkflow, updateWorkflow, getWorkflow, getWorkflows, deleteWorkflow, getWorkflowCount, initializeSampleWorkflows } from "../services/workflowStorage.js";
101
+ export { globalSaveWorkflow, globalExportWorkflow, initializeGlobalSave } from "../services/globalSave.js";
102
+ export { fetchPortConfig, validatePortConfig } from "../services/portConfigApi.js";
103
+ export { fetchDynamicSchema, resolveExternalEditUrl, getEffectiveConfigEditOptions, clearSchemaCache, invalidateSchemaCache, hasConfigEditOptions, shouldShowExternalEdit, shouldUseDynamicSchema } from "../services/dynamicSchemaService.js";
104
+ export { getDraftStorageKey, saveDraft, loadDraft, deleteDraft, hasDraft, getDraftMetadata, DraftAutoSaveManager } from "../services/draftStorage.js";
105
+ // ============================================================================
106
+ // API Clients
107
+ // ============================================================================
108
+ export { FlowDropApiClient } from "../api/client.js";
109
+ export { EnhancedFlowDropApiClient, ApiError } from "../api/enhanced-client.js";
110
+ // ============================================================================
111
+ // Connection Utilities
112
+ // ============================================================================
113
+ export * from "../utils/connections.js";
114
+ // ============================================================================
115
+ // Runtime Configuration
116
+ // ============================================================================
117
+ export * from "../config/runtimeConfig.js";
@@ -0,0 +1,100 @@
1
+ /**
2
+ * FlowDrop Form Code Editor Module
3
+ *
4
+ * Adds CodeMirror-based code/JSON editor support to SchemaForm.
5
+ * This module bundles CodeMirror dependencies (~300KB).
6
+ *
7
+ * @module form/code
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { SchemaForm } from "@d34dman/flowdrop/form";
12
+ * import { registerCodeEditorField, registerTemplateEditorField } from "@d34dman/flowdrop/form/code";
13
+ *
14
+ * // Register code editor support (call once at app startup)
15
+ * registerCodeEditorField();
16
+ *
17
+ * // Optionally also register template editor
18
+ * registerTemplateEditorField();
19
+ *
20
+ * // Now SchemaForm will render code editors for format: "json", "code", or "template"
21
+ * ```
22
+ */
23
+ import type { FieldSchema } from "../components/form/types.js";
24
+ export { default as FormCodeEditor } from "../components/form/FormCodeEditor.svelte";
25
+ export { default as FormTemplateEditor } from "../components/form/FormTemplateEditor.svelte";
26
+ export type { CodeEditorFieldProps, TemplateEditorFieldProps } from "../components/form/types.js";
27
+ /**
28
+ * Matcher for code/JSON editor fields
29
+ * Matches: format "json", "code", or type "object" without specific format
30
+ */
31
+ export declare function codeEditorFieldMatcher(schema: FieldSchema): boolean;
32
+ /**
33
+ * Matcher for template editor fields
34
+ * Matches: format "template" (Twig/Liquid-style templates)
35
+ */
36
+ export declare function templateEditorFieldMatcher(schema: FieldSchema): boolean;
37
+ /**
38
+ * Register the code/JSON editor field component
39
+ *
40
+ * Call this function once at application startup to enable
41
+ * code editor fields in SchemaForm. This loads CodeMirror dependencies.
42
+ *
43
+ * @param priority - Priority for field matching (default: 100)
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * // In your app's entry point:
48
+ * import { registerCodeEditorField } from "@d34dman/flowdrop/form/code";
49
+ *
50
+ * registerCodeEditorField();
51
+ * ```
52
+ */
53
+ export declare function registerCodeEditorField(priority?: number): void;
54
+ /**
55
+ * Register the template editor field component
56
+ *
57
+ * Call this function once at application startup to enable
58
+ * template editor fields (Twig/Liquid syntax) in SchemaForm.
59
+ *
60
+ * @param priority - Priority for field matching (default: 100)
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * // In your app's entry point:
65
+ * import { registerTemplateEditorField } from "@d34dman/flowdrop/form/code";
66
+ *
67
+ * registerTemplateEditorField();
68
+ * ```
69
+ */
70
+ export declare function registerTemplateEditorField(priority?: number): void;
71
+ /**
72
+ * Register all code-related editor fields (code + template)
73
+ *
74
+ * Convenience function to register both code editor types at once.
75
+ *
76
+ * @param priority - Priority for field matching (default: 100)
77
+ */
78
+ export declare function registerAllCodeEditors(priority?: number): void;
79
+ /**
80
+ * Synchronously register code editor field using the imported component
81
+ *
82
+ * Use this when you've already imported the component and want immediate registration.
83
+ *
84
+ * @param priority - Priority for field matching (default: 100)
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * import { registerCodeEditorFieldWithComponent, FormCodeEditor } from "@d34dman/flowdrop/form/code";
89
+ * registerCodeEditorFieldWithComponent(FormCodeEditor);
90
+ * ```
91
+ */
92
+ export declare function registerCodeEditorFieldWithComponent(component: any, priority?: number): void;
93
+ /**
94
+ * Check if code editor field is registered
95
+ */
96
+ export declare function isCodeEditorRegistered(): boolean;
97
+ /**
98
+ * Check if template editor field is registered
99
+ */
100
+ export declare function isTemplateEditorRegistered(): boolean;
@@ -0,0 +1,153 @@
1
+ /**
2
+ * FlowDrop Form Code Editor Module
3
+ *
4
+ * Adds CodeMirror-based code/JSON editor support to SchemaForm.
5
+ * This module bundles CodeMirror dependencies (~300KB).
6
+ *
7
+ * @module form/code
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { SchemaForm } from "@d34dman/flowdrop/form";
12
+ * import { registerCodeEditorField, registerTemplateEditorField } from "@d34dman/flowdrop/form/code";
13
+ *
14
+ * // Register code editor support (call once at app startup)
15
+ * registerCodeEditorField();
16
+ *
17
+ * // Optionally also register template editor
18
+ * registerTemplateEditorField();
19
+ *
20
+ * // Now SchemaForm will render code editors for format: "json", "code", or "template"
21
+ * ```
22
+ */
23
+ import { registerFieldComponent } from "./fieldRegistry.js";
24
+ // Re-export the components for direct usage if needed
25
+ export { default as FormCodeEditor } from "../components/form/FormCodeEditor.svelte";
26
+ export { default as FormTemplateEditor } from "../components/form/FormTemplateEditor.svelte";
27
+ /**
28
+ * Matcher for code/JSON editor fields
29
+ * Matches: format "json", "code", or type "object" without specific format
30
+ */
31
+ export function codeEditorFieldMatcher(schema) {
32
+ // JSON/code format
33
+ if (schema.format === "json" || schema.format === "code") {
34
+ return true;
35
+ }
36
+ // Object type without specific format (render as JSON editor)
37
+ if (schema.type === "object" && !schema.format) {
38
+ return true;
39
+ }
40
+ return false;
41
+ }
42
+ /**
43
+ * Matcher for template editor fields
44
+ * Matches: format "template" (Twig/Liquid-style templates)
45
+ */
46
+ export function templateEditorFieldMatcher(schema) {
47
+ return schema.format === "template";
48
+ }
49
+ /**
50
+ * Track if code editor is registered
51
+ */
52
+ let codeEditorRegistered = false;
53
+ /**
54
+ * Track if template editor is registered
55
+ */
56
+ let templateEditorRegistered = false;
57
+ /**
58
+ * Register the code/JSON editor field component
59
+ *
60
+ * Call this function once at application startup to enable
61
+ * code editor fields in SchemaForm. This loads CodeMirror dependencies.
62
+ *
63
+ * @param priority - Priority for field matching (default: 100)
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * // In your app's entry point:
68
+ * import { registerCodeEditorField } from "@d34dman/flowdrop/form/code";
69
+ *
70
+ * registerCodeEditorField();
71
+ * ```
72
+ */
73
+ export function registerCodeEditorField(priority = 100) {
74
+ if (codeEditorRegistered) {
75
+ return;
76
+ }
77
+ // Dynamic import to ensure proper code splitting
78
+ import("../components/form/FormCodeEditor.svelte").then((module) => {
79
+ registerFieldComponent("code-editor", module.default, codeEditorFieldMatcher, priority);
80
+ codeEditorRegistered = true;
81
+ });
82
+ }
83
+ /**
84
+ * Register the template editor field component
85
+ *
86
+ * Call this function once at application startup to enable
87
+ * template editor fields (Twig/Liquid syntax) in SchemaForm.
88
+ *
89
+ * @param priority - Priority for field matching (default: 100)
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * // In your app's entry point:
94
+ * import { registerTemplateEditorField } from "@d34dman/flowdrop/form/code";
95
+ *
96
+ * registerTemplateEditorField();
97
+ * ```
98
+ */
99
+ export function registerTemplateEditorField(priority = 100) {
100
+ if (templateEditorRegistered) {
101
+ return;
102
+ }
103
+ // Dynamic import to ensure proper code splitting
104
+ import("../components/form/FormTemplateEditor.svelte").then((module) => {
105
+ registerFieldComponent("template-editor", module.default, templateEditorFieldMatcher, priority);
106
+ templateEditorRegistered = true;
107
+ });
108
+ }
109
+ /**
110
+ * Register all code-related editor fields (code + template)
111
+ *
112
+ * Convenience function to register both code editor types at once.
113
+ *
114
+ * @param priority - Priority for field matching (default: 100)
115
+ */
116
+ export function registerAllCodeEditors(priority = 100) {
117
+ registerCodeEditorField(priority);
118
+ registerTemplateEditorField(priority);
119
+ }
120
+ /**
121
+ * Synchronously register code editor field using the imported component
122
+ *
123
+ * Use this when you've already imported the component and want immediate registration.
124
+ *
125
+ * @param priority - Priority for field matching (default: 100)
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * import { registerCodeEditorFieldWithComponent, FormCodeEditor } from "@d34dman/flowdrop/form/code";
130
+ * registerCodeEditorFieldWithComponent(FormCodeEditor);
131
+ * ```
132
+ */
133
+ export function registerCodeEditorFieldWithComponent(
134
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
135
+ component, priority = 100) {
136
+ if (codeEditorRegistered) {
137
+ return;
138
+ }
139
+ registerFieldComponent("code-editor", component, codeEditorFieldMatcher, priority);
140
+ codeEditorRegistered = true;
141
+ }
142
+ /**
143
+ * Check if code editor field is registered
144
+ */
145
+ export function isCodeEditorRegistered() {
146
+ return codeEditorRegistered;
147
+ }
148
+ /**
149
+ * Check if template editor field is registered
150
+ */
151
+ export function isTemplateEditorRegistered() {
152
+ return templateEditorRegistered;
153
+ }
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Form Field Component Registry
3
+ *
4
+ * Provides a registry system for form field components that enables:
5
+ * - Tree-shaking: Heavy components (code editor, markdown) are only bundled when registered
6
+ * - Dynamic field types: Users can add custom field renderers
7
+ * - Lazy loading: Components can be registered at runtime
8
+ *
9
+ * @module form/fieldRegistry
10
+ *
11
+ * @example Basic usage with light fields only (no codemirror/easymde):
12
+ * ```typescript
13
+ * import { SchemaForm } from "@d34dman/flowdrop/form";
14
+ * // Uses only basic fields - small bundle size
15
+ * ```
16
+ *
17
+ * @example Adding code editor support:
18
+ * ```typescript
19
+ * import { SchemaForm, registerFieldComponent } from "@d34dman/flowdrop/form";
20
+ * import { FormCodeEditor, codeEditorFieldMatcher } from "@d34dman/flowdrop/form/code";
21
+ *
22
+ * registerFieldComponent("code-editor", FormCodeEditor, codeEditorFieldMatcher);
23
+ * ```
24
+ */
25
+ import type { Component } from "svelte";
26
+ import type { FieldSchema } from "../components/form/types.js";
27
+ /**
28
+ * Base field component props that all registered field components should accept.
29
+ * Components may have additional specific props.
30
+ */
31
+ export interface FieldComponentProps {
32
+ /** Field identifier */
33
+ id: string;
34
+ /** Current field value */
35
+ value: unknown;
36
+ /** Placeholder text */
37
+ placeholder?: string;
38
+ /** Whether field is required */
39
+ required?: boolean;
40
+ /** ARIA description ID */
41
+ ariaDescribedBy?: string;
42
+ /** Change callback */
43
+ onChange: (value: unknown) => void;
44
+ /** Additional schema-derived props */
45
+ [key: string]: unknown;
46
+ }
47
+ /**
48
+ * Function type for determining if a field schema should use a specific component
49
+ */
50
+ export type FieldMatcher = (schema: FieldSchema) => boolean;
51
+ /**
52
+ * Generic component type that accepts any props
53
+ * This is needed because different field components have different prop requirements
54
+ */
55
+ export type FieldComponent = Component<any, any, any>;
56
+ /**
57
+ * Registration entry for a field component
58
+ */
59
+ export interface FieldComponentRegistration {
60
+ /** The Svelte component to render */
61
+ component: FieldComponent;
62
+ /** Function to determine if this component should handle a given schema */
63
+ matcher: FieldMatcher;
64
+ /** Priority for matching (higher = checked first) */
65
+ priority: number;
66
+ }
67
+ /**
68
+ * Register a field component for a specific field type
69
+ *
70
+ * @param type - Unique identifier for this field type
71
+ * @param component - Svelte component to render for matching fields
72
+ * @param matcher - Function to determine if a schema matches this type
73
+ * @param priority - Priority for matching (default: 0, higher = checked first)
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * registerFieldComponent(
78
+ * "code-editor",
79
+ * FormCodeEditor,
80
+ * (schema) => schema.format === "json" || schema.format === "code",
81
+ * 100 // High priority to override default
82
+ * );
83
+ * ```
84
+ */
85
+ export declare function registerFieldComponent(type: string, component: FieldComponent, matcher: FieldMatcher, priority?: number): void;
86
+ /**
87
+ * Unregister a field component
88
+ *
89
+ * @param type - The field type to unregister
90
+ * @returns true if the component was registered and removed
91
+ */
92
+ export declare function unregisterFieldComponent(type: string): boolean;
93
+ /**
94
+ * Get all registered field types
95
+ *
96
+ * @returns Array of registered field type identifiers
97
+ */
98
+ export declare function getRegisteredFieldTypes(): string[];
99
+ /**
100
+ * Check if a field type is registered
101
+ *
102
+ * @param type - Field type to check
103
+ * @returns true if the type is registered
104
+ */
105
+ export declare function isFieldTypeRegistered(type: string): boolean;
106
+ /**
107
+ * Resolve which component should render a given field schema
108
+ * Checks registered matchers in priority order
109
+ *
110
+ * @param schema - The field schema to resolve
111
+ * @returns The matching registration or null if no match
112
+ */
113
+ export declare function resolveFieldComponent(schema: FieldSchema): FieldComponentRegistration | null;
114
+ /**
115
+ * Clear all registered field components
116
+ * Useful for testing or reset scenarios
117
+ */
118
+ export declare function clearFieldRegistry(): void;
119
+ /**
120
+ * Get the registry size
121
+ * @returns Number of registered field components
122
+ */
123
+ export declare function getFieldRegistrySize(): number;
124
+ /**
125
+ * Matcher for hidden fields (should not render)
126
+ */
127
+ export declare const hiddenFieldMatcher: FieldMatcher;
128
+ /**
129
+ * Matcher for checkbox group fields (enum with multiple)
130
+ */
131
+ export declare const checkboxGroupMatcher: FieldMatcher;
132
+ /**
133
+ * Matcher for enum select fields
134
+ */
135
+ export declare const enumSelectMatcher: FieldMatcher;
136
+ /**
137
+ * Matcher for multiline textarea fields
138
+ */
139
+ export declare const textareaMatcher: FieldMatcher;
140
+ /**
141
+ * Matcher for range slider fields
142
+ */
143
+ export declare const rangeMatcher: FieldMatcher;
144
+ /**
145
+ * Matcher for string text fields
146
+ */
147
+ export declare const textFieldMatcher: FieldMatcher;
148
+ /**
149
+ * Matcher for number fields
150
+ */
151
+ export declare const numberFieldMatcher: FieldMatcher;
152
+ /**
153
+ * Matcher for boolean toggle fields
154
+ */
155
+ export declare const toggleMatcher: FieldMatcher;
156
+ /**
157
+ * Matcher for select fields with options
158
+ */
159
+ export declare const selectOptionsMatcher: FieldMatcher;
160
+ /**
161
+ * Matcher for array fields
162
+ */
163
+ export declare const arrayMatcher: FieldMatcher;