@d34dman/flowdrop 0.0.16 → 0.0.18
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/README.md +106 -0
- package/dist/api/enhanced-client.d.ts +3 -3
- package/dist/api/enhanced-client.js +57 -57
- package/dist/components/FlowDropZone.svelte +4 -5
- package/dist/components/FlowDropZone.svelte.d.ts +1 -1
- package/dist/components/TerminalNode.svelte +565 -0
- package/dist/components/TerminalNode.svelte.d.ts +24 -0
- package/dist/components/UniversalNode.svelte +94 -34
- package/dist/components/WorkflowEditor.svelte +63 -3
- package/dist/config/runtimeConfig.d.ts +2 -2
- package/dist/config/runtimeConfig.js +7 -7
- package/dist/helpers/workflowEditorHelper.d.ts +44 -4
- package/dist/helpers/workflowEditorHelper.js +161 -30
- package/dist/index.d.ts +16 -13
- package/dist/index.js +19 -8
- package/dist/registry/builtinNodes.d.ts +77 -0
- package/dist/registry/builtinNodes.js +194 -0
- package/dist/registry/index.d.ts +7 -0
- package/dist/registry/index.js +10 -0
- package/dist/registry/nodeComponentRegistry.d.ts +307 -0
- package/dist/registry/nodeComponentRegistry.js +315 -0
- package/dist/registry/plugin.d.ts +215 -0
- package/dist/registry/plugin.js +249 -0
- package/dist/services/draftStorage.d.ts +1 -1
- package/dist/services/draftStorage.js +5 -5
- package/dist/stores/workflowStore.d.ts +2 -2
- package/dist/stores/workflowStore.js +16 -16
- package/dist/styles/base.css +15 -0
- package/dist/svelte-app.d.ts +6 -6
- package/dist/svelte-app.js +25 -25
- package/dist/types/auth.d.ts +2 -2
- package/dist/types/auth.js +7 -7
- package/dist/types/events.d.ts +2 -2
- package/dist/types/index.d.ts +38 -3
- package/dist/utils/nodeTypes.d.ts +76 -21
- package/dist/utils/nodeTypes.js +182 -32
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
* A Svelte 5 component library built on @xyflow/svelte for creating node-based workflow editors
|
|
4
4
|
*/
|
|
5
5
|
// Import CSS to ensure styles are included in the library build
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import './styles/base.css';
|
|
7
|
+
// Initialize built-in node components in the registry
|
|
8
|
+
// This import has a side effect of registering all built-in nodes
|
|
9
|
+
import './registry/builtinNodes.js';
|
|
10
|
+
export { StaticAuthProvider, CallbackAuthProvider, NoAuthProvider, createAuthProviderFromLegacyConfig } from './types/auth.js';
|
|
11
|
+
export { DEFAULT_FEATURES, mergeFeatures } from './types/events.js';
|
|
9
12
|
// Export API clients
|
|
10
13
|
export { FlowDropApiClient } from './api/client.js';
|
|
11
14
|
export { EnhancedFlowDropApiClient } from './api/enhanced-client.js';
|
|
@@ -43,21 +46,29 @@ export * from './utils/config.js';
|
|
|
43
46
|
export * from './utils/nodeTypes.js';
|
|
44
47
|
export { getStatusColor, getStatusIcon, getStatusLabel, getStatusBackgroundColor, getStatusTextColor, createDefaultExecutionInfo, updateExecutionStart, updateExecutionComplete, updateExecutionFailed, resetExecutionInfo, formatExecutionDuration, formatLastExecuted } from './utils/nodeStatus.js';
|
|
45
48
|
export { createNodeWrapperConfig, shouldShowNodeStatus, getOptimalStatusPosition, getOptimalStatusSize, DEFAULT_NODE_STATUS_CONFIG } from './utils/nodeWrapper.js';
|
|
49
|
+
// Export node component registry
|
|
50
|
+
export {
|
|
51
|
+
// Core registry
|
|
52
|
+
nodeComponentRegistry, createNamespacedType, parseNamespacedType,
|
|
53
|
+
// Built-in nodes
|
|
54
|
+
BUILTIN_NODE_COMPONENTS, BUILTIN_NODE_TYPES, FLOWDROP_SOURCE, registerBuiltinNodes, areBuiltinsRegistered, isBuiltinType, getBuiltinTypes, resolveBuiltinAlias,
|
|
55
|
+
// Plugin system
|
|
56
|
+
registerFlowDropPlugin, unregisterFlowDropPlugin, registerCustomNode, createPlugin, isValidNamespace, getRegisteredPlugins, getPluginNodeCount } from './registry/index.js';
|
|
46
57
|
// Export services
|
|
47
58
|
export * from './services/api.js';
|
|
48
59
|
export { showSuccess, showError, showWarning, showInfo, showLoading, dismissToast, dismissAllToasts, showPromise, showConfirmation, apiToasts, workflowToasts, pipelineToasts } from './services/toastService.js';
|
|
49
60
|
export { NodeExecutionService, nodeExecutionService } from './services/nodeExecutionService.js';
|
|
50
61
|
export { saveWorkflow, updateWorkflow, getWorkflow, getWorkflows, deleteWorkflow, getWorkflowCount, initializeSampleWorkflows } from './services/workflowStorage.js';
|
|
51
62
|
export { globalSaveWorkflow, globalExportWorkflow, initializeGlobalSave } from './services/globalSave.js';
|
|
52
|
-
export { fetchPortConfig, validatePortConfig } from
|
|
63
|
+
export { fetchPortConfig, validatePortConfig } from './services/portConfigApi.js';
|
|
53
64
|
// Export draft storage service
|
|
54
|
-
export { getDraftStorageKey, saveDraft, loadDraft, deleteDraft, hasDraft, getDraftMetadata, DraftAutoSaveManager } from
|
|
65
|
+
export { getDraftStorageKey, saveDraft, loadDraft, deleteDraft, hasDraft, getDraftMetadata, DraftAutoSaveManager } from './services/draftStorage.js';
|
|
55
66
|
// Export helpers
|
|
56
67
|
export { EdgeStylingHelper, NodeOperationsHelper, WorkflowOperationsHelper, ConfigurationHelper } from './helpers/workflowEditorHelper.js';
|
|
57
68
|
// Export stores
|
|
58
69
|
export { workflowStore, workflowActions, workflowId, workflowName, workflowNodes, workflowEdges, workflowMetadata, workflowChanged, workflowValidation, workflowMetadataChanged,
|
|
59
70
|
// Dirty state tracking
|
|
60
|
-
isDirtyStore, isDirty, markAsSaved, getWorkflow as getWorkflowFromStore, setOnDirtyStateChange, setOnWorkflowChange } from
|
|
71
|
+
isDirtyStore, isDirty, markAsSaved, getWorkflow as getWorkflowFromStore, setOnDirtyStateChange, setOnWorkflowChange } from './stores/workflowStore.js';
|
|
61
72
|
// Export endpoint configuration
|
|
62
73
|
export * from './config/endpoints.js';
|
|
63
74
|
export { defaultApiConfig, getEndpointUrl } from './config/apiConfig.js';
|
|
@@ -68,6 +79,6 @@ export * from './adapters/WorkflowAdapter.js';
|
|
|
68
79
|
// Export API client
|
|
69
80
|
export * from './clients/ApiClient.js';
|
|
70
81
|
// Export Svelte app wrapper for framework integration
|
|
71
|
-
export { mountWorkflowEditor, unmountWorkflowEditor, mountFlowDropApp, unmountFlowDropApp } from
|
|
82
|
+
export { mountWorkflowEditor, unmountWorkflowEditor, mountFlowDropApp, unmountFlowDropApp } from './svelte-app.js';
|
|
72
83
|
// Export API error class
|
|
73
|
-
export { ApiError } from
|
|
84
|
+
export { ApiError } from './api/enhanced-client.js';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in Node Components Registration
|
|
3
|
+
* Registers all default FlowDrop node components with the registry.
|
|
4
|
+
*
|
|
5
|
+
* This module is automatically loaded when the library initializes,
|
|
6
|
+
* ensuring all built-in node types are available without user action.
|
|
7
|
+
*/
|
|
8
|
+
import { type NodeComponentRegistration } from './nodeComponentRegistry.js';
|
|
9
|
+
/**
|
|
10
|
+
* Source identifier for built-in FlowDrop components
|
|
11
|
+
*/
|
|
12
|
+
export declare const FLOWDROP_SOURCE = "flowdrop";
|
|
13
|
+
/**
|
|
14
|
+
* Built-in FlowDrop node component registrations.
|
|
15
|
+
* These are the default node types that ship with FlowDrop.
|
|
16
|
+
*/
|
|
17
|
+
export declare const BUILTIN_NODE_COMPONENTS: NodeComponentRegistration[];
|
|
18
|
+
/**
|
|
19
|
+
* Alias mapping for backwards compatibility.
|
|
20
|
+
* Maps old type names to their canonical registration.
|
|
21
|
+
*/
|
|
22
|
+
export declare const BUILTIN_TYPE_ALIASES: Record<string, string>;
|
|
23
|
+
/**
|
|
24
|
+
* Initialize the registry with built-in components.
|
|
25
|
+
* This is called automatically when the library loads.
|
|
26
|
+
*
|
|
27
|
+
* Safe to call multiple times - will only register once.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* // Usually not needed - called automatically
|
|
32
|
+
* // But can be called manually if needed
|
|
33
|
+
* registerBuiltinNodes();
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function registerBuiltinNodes(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Check if built-in nodes have been registered.
|
|
39
|
+
*
|
|
40
|
+
* @returns true if registerBuiltinNodes() has been called
|
|
41
|
+
*/
|
|
42
|
+
export declare function areBuiltinsRegistered(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Reset the registration state.
|
|
45
|
+
* Primarily useful for testing.
|
|
46
|
+
*/
|
|
47
|
+
export declare function resetBuiltinRegistration(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Get the canonical type for a given type string.
|
|
50
|
+
* Handles aliases like "default" -> "workflowNode".
|
|
51
|
+
*
|
|
52
|
+
* @param type - The type string to resolve
|
|
53
|
+
* @returns The canonical type string
|
|
54
|
+
*/
|
|
55
|
+
export declare function resolveBuiltinAlias(type: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* Check if a type is a built-in FlowDrop type.
|
|
58
|
+
*
|
|
59
|
+
* @param type - The type to check
|
|
60
|
+
* @returns true if this is a built-in type
|
|
61
|
+
*/
|
|
62
|
+
export declare function isBuiltinType(type: string): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Get all built-in type identifiers.
|
|
65
|
+
*
|
|
66
|
+
* @returns Array of built-in type strings
|
|
67
|
+
*/
|
|
68
|
+
export declare function getBuiltinTypes(): string[];
|
|
69
|
+
/**
|
|
70
|
+
* Type for built-in node types.
|
|
71
|
+
* Use this when you specifically need a built-in type.
|
|
72
|
+
*/
|
|
73
|
+
export type BuiltinNodeType = 'workflowNode' | 'simple' | 'square' | 'tool' | 'gateway' | 'note' | 'terminal';
|
|
74
|
+
/**
|
|
75
|
+
* Array of built-in type strings for runtime validation.
|
|
76
|
+
*/
|
|
77
|
+
export declare const BUILTIN_NODE_TYPES: BuiltinNodeType[];
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in Node Components Registration
|
|
3
|
+
* Registers all default FlowDrop node components with the registry.
|
|
4
|
+
*
|
|
5
|
+
* This module is automatically loaded when the library initializes,
|
|
6
|
+
* ensuring all built-in node types are available without user action.
|
|
7
|
+
*/
|
|
8
|
+
import { nodeComponentRegistry } from './nodeComponentRegistry.js';
|
|
9
|
+
import WorkflowNode from '../components/WorkflowNode.svelte';
|
|
10
|
+
import SimpleNode from '../components/SimpleNode.svelte';
|
|
11
|
+
import SquareNode from '../components/SquareNode.svelte';
|
|
12
|
+
import ToolNode from '../components/ToolNode.svelte';
|
|
13
|
+
import GatewayNode from '../components/GatewayNode.svelte';
|
|
14
|
+
import NotesNode from '../components/NotesNode.svelte';
|
|
15
|
+
import TerminalNode from '../components/TerminalNode.svelte';
|
|
16
|
+
/**
|
|
17
|
+
* Source identifier for built-in FlowDrop components
|
|
18
|
+
*/
|
|
19
|
+
export const FLOWDROP_SOURCE = 'flowdrop';
|
|
20
|
+
/**
|
|
21
|
+
* Built-in FlowDrop node component registrations.
|
|
22
|
+
* These are the default node types that ship with FlowDrop.
|
|
23
|
+
*/
|
|
24
|
+
export const BUILTIN_NODE_COMPONENTS = [
|
|
25
|
+
{
|
|
26
|
+
type: 'workflowNode',
|
|
27
|
+
displayName: 'Default (Standard Workflow Node)',
|
|
28
|
+
description: 'Full-featured workflow node with inputs/outputs display',
|
|
29
|
+
component: WorkflowNode,
|
|
30
|
+
icon: 'mdi:vector-square',
|
|
31
|
+
category: 'visual',
|
|
32
|
+
source: FLOWDROP_SOURCE,
|
|
33
|
+
statusPosition: 'top-right',
|
|
34
|
+
statusSize: 'md'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: 'simple',
|
|
38
|
+
displayName: 'Simple (Compact Layout)',
|
|
39
|
+
description: 'Compact node with header, icon, and description',
|
|
40
|
+
component: SimpleNode,
|
|
41
|
+
icon: 'mdi:card-outline',
|
|
42
|
+
category: 'visual',
|
|
43
|
+
source: FLOWDROP_SOURCE,
|
|
44
|
+
statusPosition: 'top-right',
|
|
45
|
+
statusSize: 'md'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: 'square',
|
|
49
|
+
displayName: 'Square (Minimal Icon)',
|
|
50
|
+
description: 'Minimal square node showing only an icon',
|
|
51
|
+
component: SquareNode,
|
|
52
|
+
icon: 'mdi:square',
|
|
53
|
+
category: 'visual',
|
|
54
|
+
source: FLOWDROP_SOURCE,
|
|
55
|
+
statusPosition: 'top-right',
|
|
56
|
+
statusSize: 'sm'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
type: 'tool',
|
|
60
|
+
displayName: 'Tool (Agent Tool)',
|
|
61
|
+
description: 'Specialized node for agent tools with tool metadata',
|
|
62
|
+
component: ToolNode,
|
|
63
|
+
icon: 'mdi:tools',
|
|
64
|
+
category: 'functional',
|
|
65
|
+
source: FLOWDROP_SOURCE,
|
|
66
|
+
statusPosition: 'top-left',
|
|
67
|
+
statusSize: 'sm'
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
type: 'gateway',
|
|
71
|
+
displayName: 'Gateway (Branching)',
|
|
72
|
+
description: 'Branching control flow node with multiple output branches',
|
|
73
|
+
component: GatewayNode,
|
|
74
|
+
icon: 'mdi:source-branch',
|
|
75
|
+
category: 'functional',
|
|
76
|
+
source: FLOWDROP_SOURCE,
|
|
77
|
+
statusPosition: 'top-right',
|
|
78
|
+
statusSize: 'md'
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: 'note',
|
|
82
|
+
displayName: 'Note (Sticky Note)',
|
|
83
|
+
description: 'Documentation note with markdown support',
|
|
84
|
+
component: NotesNode,
|
|
85
|
+
icon: 'mdi:note-text',
|
|
86
|
+
category: 'layout',
|
|
87
|
+
source: FLOWDROP_SOURCE,
|
|
88
|
+
statusPosition: 'bottom-right',
|
|
89
|
+
statusSize: 'sm'
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: 'terminal',
|
|
93
|
+
displayName: 'Terminal (Start/End/Exit)',
|
|
94
|
+
description: 'Circular terminal node for workflow start, end, or exit points',
|
|
95
|
+
component: TerminalNode,
|
|
96
|
+
icon: 'mdi:circle-double',
|
|
97
|
+
category: 'functional',
|
|
98
|
+
source: FLOWDROP_SOURCE,
|
|
99
|
+
statusPosition: 'top-right',
|
|
100
|
+
statusSize: 'sm'
|
|
101
|
+
}
|
|
102
|
+
];
|
|
103
|
+
/**
|
|
104
|
+
* Alias mapping for backwards compatibility.
|
|
105
|
+
* Maps old type names to their canonical registration.
|
|
106
|
+
*/
|
|
107
|
+
export const BUILTIN_TYPE_ALIASES = {
|
|
108
|
+
default: 'workflowNode'
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Track whether built-in nodes have been registered.
|
|
112
|
+
* Prevents duplicate registration on hot reload.
|
|
113
|
+
*/
|
|
114
|
+
let builtinsRegistered = false;
|
|
115
|
+
/**
|
|
116
|
+
* Initialize the registry with built-in components.
|
|
117
|
+
* This is called automatically when the library loads.
|
|
118
|
+
*
|
|
119
|
+
* Safe to call multiple times - will only register once.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* // Usually not needed - called automatically
|
|
124
|
+
* // But can be called manually if needed
|
|
125
|
+
* registerBuiltinNodes();
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
export function registerBuiltinNodes() {
|
|
129
|
+
if (builtinsRegistered) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
// Register all built-in components
|
|
133
|
+
nodeComponentRegistry.registerAll(BUILTIN_NODE_COMPONENTS, true);
|
|
134
|
+
// Set the default type
|
|
135
|
+
nodeComponentRegistry.setDefaultType('workflowNode');
|
|
136
|
+
builtinsRegistered = true;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Check if built-in nodes have been registered.
|
|
140
|
+
*
|
|
141
|
+
* @returns true if registerBuiltinNodes() has been called
|
|
142
|
+
*/
|
|
143
|
+
export function areBuiltinsRegistered() {
|
|
144
|
+
return builtinsRegistered;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Reset the registration state.
|
|
148
|
+
* Primarily useful for testing.
|
|
149
|
+
*/
|
|
150
|
+
export function resetBuiltinRegistration() {
|
|
151
|
+
builtinsRegistered = false;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Get the canonical type for a given type string.
|
|
155
|
+
* Handles aliases like "default" -> "workflowNode".
|
|
156
|
+
*
|
|
157
|
+
* @param type - The type string to resolve
|
|
158
|
+
* @returns The canonical type string
|
|
159
|
+
*/
|
|
160
|
+
export function resolveBuiltinAlias(type) {
|
|
161
|
+
return BUILTIN_TYPE_ALIASES[type] ?? type;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Check if a type is a built-in FlowDrop type.
|
|
165
|
+
*
|
|
166
|
+
* @param type - The type to check
|
|
167
|
+
* @returns true if this is a built-in type
|
|
168
|
+
*/
|
|
169
|
+
export function isBuiltinType(type) {
|
|
170
|
+
const canonicalType = resolveBuiltinAlias(type);
|
|
171
|
+
return BUILTIN_NODE_COMPONENTS.some((reg) => reg.type === canonicalType);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Get all built-in type identifiers.
|
|
175
|
+
*
|
|
176
|
+
* @returns Array of built-in type strings
|
|
177
|
+
*/
|
|
178
|
+
export function getBuiltinTypes() {
|
|
179
|
+
return BUILTIN_NODE_COMPONENTS.map((reg) => reg.type);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Array of built-in type strings for runtime validation.
|
|
183
|
+
*/
|
|
184
|
+
export const BUILTIN_NODE_TYPES = [
|
|
185
|
+
'workflowNode',
|
|
186
|
+
'simple',
|
|
187
|
+
'square',
|
|
188
|
+
'tool',
|
|
189
|
+
'gateway',
|
|
190
|
+
'note',
|
|
191
|
+
'terminal'
|
|
192
|
+
];
|
|
193
|
+
// Auto-register built-ins when this module is imported
|
|
194
|
+
registerBuiltinNodes();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node Component Registry Module
|
|
3
|
+
* Exports all registry-related functionality.
|
|
4
|
+
*/
|
|
5
|
+
export { nodeComponentRegistry, createNamespacedType, parseNamespacedType, type NodeComponentProps, type NodeComponentRegistration, type NodeComponentCategory, type StatusPosition, type StatusSize, type NodeRegistrationFilter } from './nodeComponentRegistry.js';
|
|
6
|
+
export { BUILTIN_NODE_COMPONENTS, BUILTIN_NODE_TYPES, FLOWDROP_SOURCE, registerBuiltinNodes, areBuiltinsRegistered, resetBuiltinRegistration, resolveBuiltinAlias, isBuiltinType, getBuiltinTypes, type BuiltinNodeType } from './builtinNodes.js';
|
|
7
|
+
export { registerFlowDropPlugin, unregisterFlowDropPlugin, registerCustomNode, createPlugin, isValidNamespace, getRegisteredPlugins, getPluginNodeCount, type FlowDropPluginConfig, type PluginNodeDefinition, type PluginRegistrationResult } from './plugin.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node Component Registry Module
|
|
3
|
+
* Exports all registry-related functionality.
|
|
4
|
+
*/
|
|
5
|
+
// Core registry
|
|
6
|
+
export { nodeComponentRegistry, createNamespacedType, parseNamespacedType } from './nodeComponentRegistry.js';
|
|
7
|
+
// Built-in nodes
|
|
8
|
+
export { BUILTIN_NODE_COMPONENTS, BUILTIN_NODE_TYPES, FLOWDROP_SOURCE, registerBuiltinNodes, areBuiltinsRegistered, resetBuiltinRegistration, resolveBuiltinAlias, isBuiltinType, getBuiltinTypes } from './builtinNodes.js';
|
|
9
|
+
// Plugin system
|
|
10
|
+
export { registerFlowDropPlugin, unregisterFlowDropPlugin, registerCustomNode, createPlugin, isValidNamespace, getRegisteredPlugins, getPluginNodeCount } from './plugin.js';
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node Component Registry
|
|
3
|
+
* Central registry for node component types that allows built-in and third-party
|
|
4
|
+
* components to be registered and resolved at runtime.
|
|
5
|
+
*
|
|
6
|
+
* This enables:
|
|
7
|
+
* - Custom node components to be registered by users
|
|
8
|
+
* - External libraries to contribute node types via plugins
|
|
9
|
+
* - Runtime switching between different node visualizations
|
|
10
|
+
*/
|
|
11
|
+
import type { Component } from 'svelte';
|
|
12
|
+
import type { WorkflowNode } from '../types/index.js';
|
|
13
|
+
/**
|
|
14
|
+
* Props interface that all node components must accept.
|
|
15
|
+
* Any component registered in the registry must be compatible with these props.
|
|
16
|
+
*/
|
|
17
|
+
export interface NodeComponentProps {
|
|
18
|
+
/** Node data containing label, config, metadata, executionInfo */
|
|
19
|
+
data: WorkflowNode['data'] & {
|
|
20
|
+
nodeId?: string;
|
|
21
|
+
onConfigOpen?: (node: {
|
|
22
|
+
id: string;
|
|
23
|
+
type: string;
|
|
24
|
+
data: WorkflowNode['data'];
|
|
25
|
+
}) => void;
|
|
26
|
+
};
|
|
27
|
+
/** Whether the node is currently selected */
|
|
28
|
+
selected?: boolean;
|
|
29
|
+
/** Whether the node is in processing state */
|
|
30
|
+
isProcessing?: boolean;
|
|
31
|
+
/** Whether the node has an error */
|
|
32
|
+
isError?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Position options for the status overlay on nodes
|
|
36
|
+
*/
|
|
37
|
+
export type StatusPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
38
|
+
/**
|
|
39
|
+
* Size options for the status overlay on nodes
|
|
40
|
+
*/
|
|
41
|
+
export type StatusSize = 'sm' | 'md' | 'lg';
|
|
42
|
+
/**
|
|
43
|
+
* Category for organizing node types in the UI
|
|
44
|
+
*/
|
|
45
|
+
export type NodeComponentCategory = 'visual' | 'functional' | 'layout' | 'custom';
|
|
46
|
+
/**
|
|
47
|
+
* Metadata for registered node components.
|
|
48
|
+
* Contains all information needed to use and display a node type.
|
|
49
|
+
*/
|
|
50
|
+
export interface NodeComponentRegistration {
|
|
51
|
+
/** Unique identifier for this node type (e.g., "simple", "mylib:custom") */
|
|
52
|
+
type: string;
|
|
53
|
+
/** Display name for UI purposes (e.g., "Simple Node") */
|
|
54
|
+
displayName: string;
|
|
55
|
+
/** Description of what this node type is for */
|
|
56
|
+
description?: string;
|
|
57
|
+
/** The Svelte component to render for this node type */
|
|
58
|
+
component: Component<NodeComponentProps>;
|
|
59
|
+
/** Icon to show in the node type selector (iconify format) */
|
|
60
|
+
icon?: string;
|
|
61
|
+
/** Category for grouping in UI */
|
|
62
|
+
category?: NodeComponentCategory;
|
|
63
|
+
/** Source of the registration (e.g., "flowdrop", "mylib") for debugging/filtering */
|
|
64
|
+
source?: string;
|
|
65
|
+
/** Default status overlay position for this node type */
|
|
66
|
+
statusPosition?: StatusPosition;
|
|
67
|
+
/** Default status overlay size for this node type */
|
|
68
|
+
statusSize?: StatusSize;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Options for filtering node registrations
|
|
72
|
+
*/
|
|
73
|
+
export interface NodeRegistrationFilter {
|
|
74
|
+
/** Filter by category */
|
|
75
|
+
category?: NodeComponentCategory;
|
|
76
|
+
/** Filter by source */
|
|
77
|
+
source?: string;
|
|
78
|
+
/** Custom filter function */
|
|
79
|
+
predicate?: (registration: NodeComponentRegistration) => boolean;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Central registry for node component types.
|
|
83
|
+
* Allows built-in and third-party components to be registered and resolved.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* // Register a custom node
|
|
88
|
+
* nodeComponentRegistry.register({
|
|
89
|
+
* type: "myCustomNode",
|
|
90
|
+
* displayName: "My Custom Node",
|
|
91
|
+
* component: MyCustomNodeComponent,
|
|
92
|
+
* icon: "mdi:star",
|
|
93
|
+
* category: "custom"
|
|
94
|
+
* });
|
|
95
|
+
*
|
|
96
|
+
* // Get a component
|
|
97
|
+
* const component = nodeComponentRegistry.getComponent("myCustomNode");
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
declare class NodeComponentRegistry {
|
|
101
|
+
/** Map of type -> registration */
|
|
102
|
+
private components;
|
|
103
|
+
/** Default type to use when requested type is not found */
|
|
104
|
+
private defaultType;
|
|
105
|
+
/** Listeners for registry changes */
|
|
106
|
+
private listeners;
|
|
107
|
+
/**
|
|
108
|
+
* Register a node component type.
|
|
109
|
+
*
|
|
110
|
+
* @param registration - The component registration details
|
|
111
|
+
* @param overwrite - If true, allows overwriting existing registrations
|
|
112
|
+
* @throws Error if type already registered and overwrite is false
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* nodeComponentRegistry.register({
|
|
117
|
+
* type: "fancy",
|
|
118
|
+
* displayName: "Fancy Node",
|
|
119
|
+
* component: FancyNode,
|
|
120
|
+
* icon: "mdi:sparkles"
|
|
121
|
+
* });
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
register(registration: NodeComponentRegistration, overwrite?: boolean): void;
|
|
125
|
+
/**
|
|
126
|
+
* Register multiple components at once.
|
|
127
|
+
* Useful for libraries registering multiple node types.
|
|
128
|
+
*
|
|
129
|
+
* @param registrations - Array of registrations to add
|
|
130
|
+
* @param overwrite - If true, allows overwriting existing registrations
|
|
131
|
+
*/
|
|
132
|
+
registerAll(registrations: NodeComponentRegistration[], overwrite?: boolean): void;
|
|
133
|
+
/**
|
|
134
|
+
* Unregister a node component type.
|
|
135
|
+
*
|
|
136
|
+
* @param type - The type identifier to remove
|
|
137
|
+
* @returns true if the type was found and removed, false otherwise
|
|
138
|
+
*/
|
|
139
|
+
unregister(type: string): boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Get a registration by type.
|
|
142
|
+
*
|
|
143
|
+
* @param type - The type identifier to look up
|
|
144
|
+
* @returns The registration if found, undefined otherwise
|
|
145
|
+
*/
|
|
146
|
+
get(type: string): NodeComponentRegistration | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* Get the component for a type, with fallback to default.
|
|
149
|
+
*
|
|
150
|
+
* @param type - The type identifier to look up
|
|
151
|
+
* @returns The component if found, or the default component
|
|
152
|
+
*/
|
|
153
|
+
getComponent(type: string): Component<NodeComponentProps> | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* Check if a type is registered.
|
|
156
|
+
*
|
|
157
|
+
* @param type - The type identifier to check
|
|
158
|
+
* @returns true if the type is registered
|
|
159
|
+
*/
|
|
160
|
+
has(type: string): boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Get all registered type identifiers.
|
|
163
|
+
*
|
|
164
|
+
* @returns Array of registered type strings
|
|
165
|
+
*/
|
|
166
|
+
getTypes(): string[];
|
|
167
|
+
/**
|
|
168
|
+
* Get all registrations.
|
|
169
|
+
*
|
|
170
|
+
* @returns Array of all registered node component metadata
|
|
171
|
+
*/
|
|
172
|
+
getAll(): NodeComponentRegistration[];
|
|
173
|
+
/**
|
|
174
|
+
* Get registrations filtered by criteria.
|
|
175
|
+
*
|
|
176
|
+
* @param filter - Filter options
|
|
177
|
+
* @returns Filtered array of registrations
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* // Get all visual nodes
|
|
182
|
+
* const visualNodes = nodeComponentRegistry.filter({ category: "visual" });
|
|
183
|
+
*
|
|
184
|
+
* // Get nodes from a specific library
|
|
185
|
+
* const libNodes = nodeComponentRegistry.filter({ source: "mylib" });
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
filter(filter: NodeRegistrationFilter): NodeComponentRegistration[];
|
|
189
|
+
/**
|
|
190
|
+
* Get registrations filtered by category.
|
|
191
|
+
*
|
|
192
|
+
* @param category - The category to filter by
|
|
193
|
+
* @returns Array of registrations in that category
|
|
194
|
+
*/
|
|
195
|
+
getByCategory(category: NodeComponentCategory): NodeComponentRegistration[];
|
|
196
|
+
/**
|
|
197
|
+
* Get registrations filtered by source.
|
|
198
|
+
*
|
|
199
|
+
* @param source - The source identifier to filter by (e.g., "flowdrop", "mylib")
|
|
200
|
+
* @returns Array of registrations from that source
|
|
201
|
+
*/
|
|
202
|
+
getBySource(source: string): NodeComponentRegistration[];
|
|
203
|
+
/**
|
|
204
|
+
* Set the default fallback type.
|
|
205
|
+
*
|
|
206
|
+
* @param type - The type to use as default when requested type is not found
|
|
207
|
+
* @throws Error if the type is not registered
|
|
208
|
+
*/
|
|
209
|
+
setDefaultType(type: string): void;
|
|
210
|
+
/**
|
|
211
|
+
* Get the current default type.
|
|
212
|
+
*
|
|
213
|
+
* @returns The default type identifier
|
|
214
|
+
*/
|
|
215
|
+
getDefaultType(): string;
|
|
216
|
+
/**
|
|
217
|
+
* Subscribe to registry changes.
|
|
218
|
+
* Called whenever components are registered or unregistered.
|
|
219
|
+
*
|
|
220
|
+
* @param listener - Callback to invoke on changes
|
|
221
|
+
* @returns Unsubscribe function
|
|
222
|
+
*/
|
|
223
|
+
subscribe(listener: () => void): () => void;
|
|
224
|
+
/**
|
|
225
|
+
* Notify all listeners of a change.
|
|
226
|
+
*/
|
|
227
|
+
private notifyListeners;
|
|
228
|
+
/**
|
|
229
|
+
* Get enum options for config forms.
|
|
230
|
+
* Returns arrays suitable for JSON Schema enum/enumNames.
|
|
231
|
+
*
|
|
232
|
+
* @param filterFn - Optional filter function to limit which types are included
|
|
233
|
+
* @returns Object with enum (type values) and enumNames (display names)
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```typescript
|
|
237
|
+
* const { enum: types, enumNames } = nodeComponentRegistry.getEnumOptions();
|
|
238
|
+
* // Use in configSchema: { type: "string", enum: types, enumNames }
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
getEnumOptions(filterFn?: (reg: NodeComponentRegistration) => boolean): {
|
|
242
|
+
enum: string[];
|
|
243
|
+
enumNames: string[];
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Get the status position for a node type.
|
|
247
|
+
*
|
|
248
|
+
* @param type - The node type
|
|
249
|
+
* @returns The status position, or default "top-right"
|
|
250
|
+
*/
|
|
251
|
+
getStatusPosition(type: string): StatusPosition;
|
|
252
|
+
/**
|
|
253
|
+
* Get the status size for a node type.
|
|
254
|
+
*
|
|
255
|
+
* @param type - The node type
|
|
256
|
+
* @returns The status size, or default "md"
|
|
257
|
+
*/
|
|
258
|
+
getStatusSize(type: string): StatusSize;
|
|
259
|
+
/**
|
|
260
|
+
* Clear all registrations.
|
|
261
|
+
* Primarily useful for testing.
|
|
262
|
+
*/
|
|
263
|
+
clear(): void;
|
|
264
|
+
/**
|
|
265
|
+
* Get the count of registered components.
|
|
266
|
+
*
|
|
267
|
+
* @returns Number of registered node types
|
|
268
|
+
*/
|
|
269
|
+
get size(): number;
|
|
270
|
+
}
|
|
271
|
+
/** Singleton instance of the node component registry */
|
|
272
|
+
export declare const nodeComponentRegistry: NodeComponentRegistry;
|
|
273
|
+
/**
|
|
274
|
+
* Helper function to create a namespaced type identifier.
|
|
275
|
+
* Use this to avoid conflicts when registering custom nodes.
|
|
276
|
+
*
|
|
277
|
+
* @param namespace - Your library/project namespace
|
|
278
|
+
* @param type - The node type name
|
|
279
|
+
* @returns Namespaced type string (e.g., "mylib:custom")
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```typescript
|
|
283
|
+
* const type = createNamespacedType("mylib", "fancy");
|
|
284
|
+
* // Returns "mylib:fancy"
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
export declare function createNamespacedType(namespace: string, type: string): string;
|
|
288
|
+
/**
|
|
289
|
+
* Parse a namespaced type into its components.
|
|
290
|
+
*
|
|
291
|
+
* @param namespacedType - The full namespaced type (e.g., "mylib:custom")
|
|
292
|
+
* @returns Object with namespace and type, or null if not namespaced
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```typescript
|
|
296
|
+
* parseNamespacedType("mylib:fancy");
|
|
297
|
+
* // Returns { namespace: "mylib", type: "fancy" }
|
|
298
|
+
*
|
|
299
|
+
* parseNamespacedType("simple");
|
|
300
|
+
* // Returns null (not namespaced)
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
export declare function parseNamespacedType(namespacedType: string): {
|
|
304
|
+
namespace: string;
|
|
305
|
+
type: string;
|
|
306
|
+
} | null;
|
|
307
|
+
export {};
|