@d34dman/flowdrop 0.0.15 → 0.0.17
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 +64 -1
- package/dist/api/enhanced-client.d.ts +119 -3
- package/dist/api/enhanced-client.js +233 -54
- package/dist/components/App.svelte +145 -33
- package/dist/components/App.svelte.d.ts +27 -1
- package/dist/components/FlowDropZone.svelte +4 -5
- package/dist/components/FlowDropZone.svelte.d.ts +1 -1
- 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/data/samples.js +9 -9
- package/dist/examples/adapter-usage.js +1 -1
- package/dist/helpers/workflowEditorHelper.d.ts +44 -4
- package/dist/helpers/workflowEditorHelper.js +161 -30
- package/dist/index.d.ts +12 -2
- package/dist/index.js +20 -1
- package/dist/registry/builtinNodes.d.ts +77 -0
- package/dist/registry/builtinNodes.js +181 -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 +171 -0
- package/dist/services/draftStorage.js +298 -0
- package/dist/stores/workflowStore.d.ts +103 -0
- package/dist/stores/workflowStore.js +249 -29
- package/dist/styles/base.css +15 -0
- package/dist/svelte-app.d.ts +110 -28
- package/dist/svelte-app.js +150 -27
- package/dist/types/auth.d.ts +278 -0
- package/dist/types/auth.js +244 -0
- package/dist/types/events.d.ts +163 -0
- package/dist/types/events.js +30 -0
- package/dist/types/index.d.ts +38 -3
- package/dist/utils/nodeTypes.d.ts +76 -21
- package/dist/utils/nodeTypes.js +180 -32
- package/package.json +1 -2
package/dist/utils/nodeTypes.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Node type utilities for FlowDrop
|
|
3
|
-
* Handles dynamic node type resolution based on NodeMetadata
|
|
3
|
+
* Handles dynamic node type resolution based on NodeMetadata.
|
|
4
|
+
*
|
|
5
|
+
* This module provides utilities for:
|
|
6
|
+
* - Resolving which node type to use based on metadata and config
|
|
7
|
+
* - Getting available node types for a given metadata
|
|
8
|
+
* - Creating config schema properties for node type selection
|
|
9
|
+
*
|
|
10
|
+
* Works with both built-in types and custom registered types.
|
|
4
11
|
*/
|
|
12
|
+
import { nodeComponentRegistry } from '../registry/nodeComponentRegistry.js';
|
|
13
|
+
import { resolveBuiltinAlias, isBuiltinType } from '../registry/builtinNodes.js';
|
|
5
14
|
/**
|
|
6
|
-
* Maps NodeType to SvelteFlow component names
|
|
15
|
+
* Maps built-in NodeType to SvelteFlow component names.
|
|
16
|
+
* This is kept for backwards compatibility.
|
|
7
17
|
*/
|
|
8
18
|
const NODE_TYPE_TO_COMPONENT_MAP = {
|
|
9
19
|
note: 'note',
|
|
@@ -14,14 +24,43 @@ const NODE_TYPE_TO_COMPONENT_MAP = {
|
|
|
14
24
|
default: 'workflowNode'
|
|
15
25
|
};
|
|
16
26
|
/**
|
|
17
|
-
*
|
|
27
|
+
* Display names for built-in node types.
|
|
28
|
+
*/
|
|
29
|
+
const TYPE_DISPLAY_NAMES = {
|
|
30
|
+
note: 'Note (sticky note style)',
|
|
31
|
+
simple: 'Simple (compact layout)',
|
|
32
|
+
square: 'Square (geometric layout)',
|
|
33
|
+
tool: 'Tool (specialized for agent tools)',
|
|
34
|
+
gateway: 'Gateway (branching control flow)',
|
|
35
|
+
default: 'Default (standard workflow node)'
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Gets the SvelteFlow component name for a given NodeType.
|
|
39
|
+
* Supports both built-in types and registered custom types.
|
|
40
|
+
*
|
|
41
|
+
* @param nodeType - The node type identifier
|
|
42
|
+
* @returns The component name to use
|
|
18
43
|
*/
|
|
19
44
|
export function getComponentNameForNodeType(nodeType) {
|
|
20
|
-
|
|
45
|
+
// Resolve aliases first (e.g., "default" -> "workflowNode")
|
|
46
|
+
const resolvedType = resolveBuiltinAlias(nodeType);
|
|
47
|
+
// Check if it's registered in the registry
|
|
48
|
+
if (nodeComponentRegistry.has(resolvedType)) {
|
|
49
|
+
return resolvedType;
|
|
50
|
+
}
|
|
51
|
+
// Fall back to built-in mapping
|
|
52
|
+
if (nodeType in NODE_TYPE_TO_COMPONENT_MAP) {
|
|
53
|
+
return NODE_TYPE_TO_COMPONENT_MAP[nodeType];
|
|
54
|
+
}
|
|
55
|
+
// Unknown type - return as-is (might be a custom type)
|
|
56
|
+
return resolvedType;
|
|
21
57
|
}
|
|
22
58
|
/**
|
|
23
|
-
* Gets the available node types for a given NodeMetadata
|
|
59
|
+
* Gets the available node types for a given NodeMetadata.
|
|
24
60
|
* Priority: supportedTypes > type > "default"
|
|
61
|
+
*
|
|
62
|
+
* @param metadata - The node metadata
|
|
63
|
+
* @returns Array of available node type identifiers
|
|
25
64
|
*/
|
|
26
65
|
export function getAvailableNodeTypes(metadata) {
|
|
27
66
|
if (metadata.supportedTypes && metadata.supportedTypes.length > 0) {
|
|
@@ -33,71 +72,139 @@ export function getAvailableNodeTypes(metadata) {
|
|
|
33
72
|
return ['default'];
|
|
34
73
|
}
|
|
35
74
|
/**
|
|
36
|
-
* Gets the primary (default) node type for a given NodeMetadata
|
|
37
|
-
* This is used when no specific type is configured by the user
|
|
75
|
+
* Gets the primary (default) node type for a given NodeMetadata.
|
|
76
|
+
* This is used when no specific type is configured by the user.
|
|
77
|
+
*
|
|
78
|
+
* @param metadata - The node metadata
|
|
79
|
+
* @returns The primary node type
|
|
38
80
|
*/
|
|
39
81
|
export function getPrimaryNodeType(metadata) {
|
|
40
82
|
const availableTypes = getAvailableNodeTypes(metadata);
|
|
41
83
|
return availableTypes[0];
|
|
42
84
|
}
|
|
43
85
|
/**
|
|
44
|
-
* Determines the appropriate node type based on configuration and metadata
|
|
86
|
+
* Determines the appropriate node type based on configuration and metadata.
|
|
87
|
+
*
|
|
45
88
|
* Priority:
|
|
46
89
|
* 1. configNodeType (if valid for this metadata)
|
|
47
90
|
* 2. metadata.type (if valid)
|
|
48
91
|
* 3. First supportedType
|
|
49
92
|
* 4. "default"
|
|
93
|
+
*
|
|
94
|
+
* @param metadata - The node metadata
|
|
95
|
+
* @param configNodeType - Optional type from user config
|
|
96
|
+
* @returns The resolved node type
|
|
50
97
|
*/
|
|
51
98
|
export function resolveNodeType(metadata, configNodeType) {
|
|
52
99
|
const availableTypes = getAvailableNodeTypes(metadata);
|
|
53
100
|
// Check if configNodeType is valid for this metadata
|
|
54
|
-
if (configNodeType
|
|
55
|
-
|
|
101
|
+
if (configNodeType) {
|
|
102
|
+
// Resolve alias for comparison
|
|
103
|
+
const resolvedConfig = resolveBuiltinAlias(configNodeType);
|
|
104
|
+
// Check if it's in available types
|
|
105
|
+
if (availableTypes.includes(configNodeType) ||
|
|
106
|
+
availableTypes.includes(resolvedConfig)) {
|
|
107
|
+
return configNodeType;
|
|
108
|
+
}
|
|
109
|
+
// Check if it's a registered custom type
|
|
110
|
+
if (nodeComponentRegistry.has(configNodeType) || nodeComponentRegistry.has(resolvedConfig)) {
|
|
111
|
+
return configNodeType;
|
|
112
|
+
}
|
|
56
113
|
}
|
|
57
114
|
// Fall back to primary type
|
|
58
115
|
return getPrimaryNodeType(metadata);
|
|
59
116
|
}
|
|
60
117
|
/**
|
|
61
|
-
* Gets the SvelteFlow component name for resolved node type
|
|
62
|
-
* This
|
|
118
|
+
* Gets the SvelteFlow component name for resolved node type.
|
|
119
|
+
* This is the main function used by UniversalNode to determine which component to render.
|
|
120
|
+
*
|
|
121
|
+
* @param metadata - The node metadata
|
|
122
|
+
* @param configNodeType - Optional type from user config
|
|
123
|
+
* @returns The component name to use
|
|
63
124
|
*/
|
|
64
125
|
export function resolveComponentName(metadata, configNodeType) {
|
|
65
126
|
const nodeType = resolveNodeType(metadata, configNodeType);
|
|
66
127
|
return getComponentNameForNodeType(nodeType);
|
|
67
128
|
}
|
|
68
129
|
/**
|
|
69
|
-
* Validates if a node type is supported by the given metadata
|
|
130
|
+
* Validates if a node type is supported by the given metadata.
|
|
131
|
+
*
|
|
132
|
+
* @param metadata - The node metadata
|
|
133
|
+
* @param nodeType - The type to check
|
|
134
|
+
* @returns true if the type is supported
|
|
70
135
|
*/
|
|
71
136
|
export function isNodeTypeSupported(metadata, nodeType) {
|
|
72
137
|
const availableTypes = getAvailableNodeTypes(metadata);
|
|
73
|
-
|
|
138
|
+
// Check direct match
|
|
139
|
+
if (availableTypes.includes(nodeType)) {
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
// Check alias match
|
|
143
|
+
const resolvedType = resolveBuiltinAlias(nodeType);
|
|
144
|
+
if (availableTypes.includes(resolvedType)) {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
// Check if it's a registered custom type that's in the available list
|
|
148
|
+
if (nodeComponentRegistry.has(nodeType)) {
|
|
149
|
+
return availableTypes.some((t) => t === nodeType || resolveBuiltinAlias(t) === nodeType);
|
|
150
|
+
}
|
|
151
|
+
return false;
|
|
74
152
|
}
|
|
75
153
|
/**
|
|
76
|
-
* Gets enum options for node type configuration
|
|
77
|
-
* Used in config schemas to show available options
|
|
154
|
+
* Gets enum options for node type configuration.
|
|
155
|
+
* Used in config schemas to show available options.
|
|
156
|
+
*
|
|
157
|
+
* This function combines:
|
|
158
|
+
* - Types specified in metadata.supportedTypes
|
|
159
|
+
* - Registered custom types (optionally filtered)
|
|
160
|
+
*
|
|
161
|
+
* @param metadata - The node metadata
|
|
162
|
+
* @param includeCustomTypes - Whether to include registered custom types
|
|
163
|
+
* @returns Object with enum values and display names
|
|
78
164
|
*/
|
|
79
|
-
export function getNodeTypeEnumOptions(metadata) {
|
|
165
|
+
export function getNodeTypeEnumOptions(metadata, includeCustomTypes = false) {
|
|
80
166
|
const availableTypes = getAvailableNodeTypes(metadata);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
167
|
+
// Build enum values and names
|
|
168
|
+
const enumValues = [];
|
|
169
|
+
const enumNames = [];
|
|
170
|
+
for (const type of availableTypes) {
|
|
171
|
+
enumValues.push(type);
|
|
172
|
+
// Get display name from registry or fallback to built-in names
|
|
173
|
+
const registration = nodeComponentRegistry.get(type);
|
|
174
|
+
if (registration) {
|
|
175
|
+
enumNames.push(registration.displayName);
|
|
176
|
+
}
|
|
177
|
+
else if (type in TYPE_DISPLAY_NAMES) {
|
|
178
|
+
enumNames.push(TYPE_DISPLAY_NAMES[type]);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
// Format unknown type nicely
|
|
182
|
+
enumNames.push(formatTypeName(type));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// Optionally include all registered custom types
|
|
186
|
+
if (includeCustomTypes) {
|
|
187
|
+
const registrations = nodeComponentRegistry.filter({
|
|
188
|
+
predicate: (reg) => !isBuiltinType(reg.type) && !enumValues.includes(reg.type)
|
|
189
|
+
});
|
|
190
|
+
for (const reg of registrations) {
|
|
191
|
+
enumValues.push(reg.type);
|
|
192
|
+
enumNames.push(reg.displayName);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return { enum: enumValues, enumNames };
|
|
93
196
|
}
|
|
94
197
|
/**
|
|
95
|
-
* Creates a nodeType config property that respects supportedTypes
|
|
96
|
-
* This replaces hardcoded enum values in config schemas
|
|
198
|
+
* Creates a nodeType config property that respects supportedTypes.
|
|
199
|
+
* This replaces hardcoded enum values in config schemas.
|
|
200
|
+
*
|
|
201
|
+
* @param metadata - The node metadata
|
|
202
|
+
* @param defaultType - Optional default type override
|
|
203
|
+
* @returns Config schema property object
|
|
97
204
|
*/
|
|
98
205
|
export function createNodeTypeConfigProperty(metadata, defaultType) {
|
|
99
206
|
const { enum: enumValues, enumNames } = getNodeTypeEnumOptions(metadata);
|
|
100
|
-
const primaryType = defaultType
|
|
207
|
+
const primaryType = defaultType ?? getPrimaryNodeType(metadata);
|
|
101
208
|
return {
|
|
102
209
|
type: 'string',
|
|
103
210
|
title: 'Node Type',
|
|
@@ -107,3 +214,44 @@ export function createNodeTypeConfigProperty(metadata, defaultType) {
|
|
|
107
214
|
enumNames
|
|
108
215
|
};
|
|
109
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* Check if a type string represents a valid registered or built-in type.
|
|
219
|
+
*
|
|
220
|
+
* @param type - The type to check
|
|
221
|
+
* @returns true if the type is valid
|
|
222
|
+
*/
|
|
223
|
+
export function isValidNodeType(type) {
|
|
224
|
+
return isBuiltinType(type) || nodeComponentRegistry.has(type);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Get all available node types (built-in + registered).
|
|
228
|
+
*
|
|
229
|
+
* @returns Array of all valid node type identifiers
|
|
230
|
+
*/
|
|
231
|
+
export function getAllNodeTypes() {
|
|
232
|
+
return nodeComponentRegistry.getTypes();
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Format a type name for display when no display name is registered.
|
|
236
|
+
*
|
|
237
|
+
* @param type - The raw type string
|
|
238
|
+
* @returns Formatted display name
|
|
239
|
+
*/
|
|
240
|
+
function formatTypeName(type) {
|
|
241
|
+
// Handle namespaced types (e.g., "mylib:fancy" -> "Mylib: Fancy")
|
|
242
|
+
if (type.includes(':')) {
|
|
243
|
+
const [namespace, name] = type.split(':');
|
|
244
|
+
return `${capitalize(namespace)}: ${capitalize(name)}`;
|
|
245
|
+
}
|
|
246
|
+
// Capitalize and add spaces for camelCase
|
|
247
|
+
return capitalize(type.replace(/([A-Z])/g, ' $1').trim());
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Capitalize the first letter of a string.
|
|
251
|
+
*
|
|
252
|
+
* @param str - The string to capitalize
|
|
253
|
+
* @returns Capitalized string
|
|
254
|
+
*/
|
|
255
|
+
function capitalize(str) {
|
|
256
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
257
|
+
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@d34dman/flowdrop",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.17",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite dev",
|
|
8
8
|
"build": "vite build && npm run prepack",
|
|
@@ -93,7 +93,6 @@
|
|
|
93
93
|
"@eslint/js": "^9.18.0",
|
|
94
94
|
"@iconify/svelte": "^5.0.0",
|
|
95
95
|
"@playwright/test": "^1.49.1",
|
|
96
|
-
"@storybook/addon-a11y": "^9.0.15",
|
|
97
96
|
"@storybook/addon-docs": "^9.0.15",
|
|
98
97
|
"@storybook/addon-svelte-csf": "^5.0.4",
|
|
99
98
|
"@storybook/addon-vitest": "^9.0.15",
|