@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
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication Provider Types for FlowDrop
|
|
3
|
+
*
|
|
4
|
+
* Provides interfaces and implementations for authentication in FlowDrop.
|
|
5
|
+
* AuthProvider is passed at mount time and cannot be changed without remounting.
|
|
6
|
+
*
|
|
7
|
+
* @module types/auth
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Static authentication provider
|
|
11
|
+
*
|
|
12
|
+
* Provides authentication using static credentials configured at instantiation.
|
|
13
|
+
* Suitable for simple use cases where tokens don't change during the session.
|
|
14
|
+
* Also used internally for backward compatibility with existing endpointConfig.auth.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Bearer token authentication
|
|
19
|
+
* const authProvider = new StaticAuthProvider({
|
|
20
|
+
* type: "bearer",
|
|
21
|
+
* token: "your-jwt-token"
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // API key authentication
|
|
25
|
+
* const authProvider = new StaticAuthProvider({
|
|
26
|
+
* type: "api_key",
|
|
27
|
+
* apiKey: "your-api-key"
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* // Custom headers
|
|
31
|
+
* const authProvider = new StaticAuthProvider({
|
|
32
|
+
* type: "custom",
|
|
33
|
+
* headers: {
|
|
34
|
+
* "X-Custom-Auth": "value",
|
|
35
|
+
* "X-Tenant-ID": "tenant123"
|
|
36
|
+
* }
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export class StaticAuthProvider {
|
|
41
|
+
/** Cached authentication headers */
|
|
42
|
+
headers;
|
|
43
|
+
/**
|
|
44
|
+
* Create a new StaticAuthProvider
|
|
45
|
+
*
|
|
46
|
+
* @param config - Static authentication configuration
|
|
47
|
+
*/
|
|
48
|
+
constructor(config) {
|
|
49
|
+
this.headers = {};
|
|
50
|
+
switch (config.type) {
|
|
51
|
+
case 'bearer':
|
|
52
|
+
if (config.token) {
|
|
53
|
+
this.headers['Authorization'] = `Bearer ${config.token}`;
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
case 'api_key':
|
|
57
|
+
if (config.apiKey) {
|
|
58
|
+
this.headers['X-API-Key'] = config.apiKey;
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
case 'custom':
|
|
62
|
+
if (config.headers) {
|
|
63
|
+
this.headers = { ...config.headers };
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
case 'none':
|
|
67
|
+
default:
|
|
68
|
+
// No headers needed
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get authentication headers
|
|
74
|
+
*
|
|
75
|
+
* Returns the statically configured headers.
|
|
76
|
+
*
|
|
77
|
+
* @returns Promise resolving to authentication headers
|
|
78
|
+
*/
|
|
79
|
+
async getAuthHeaders() {
|
|
80
|
+
return this.headers;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Check if authenticated
|
|
84
|
+
*
|
|
85
|
+
* Returns true if any auth headers are configured.
|
|
86
|
+
*
|
|
87
|
+
* @returns true if headers are configured
|
|
88
|
+
*/
|
|
89
|
+
isAuthenticated() {
|
|
90
|
+
return Object.keys(this.headers).length > 0;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Handle unauthorized response
|
|
94
|
+
*
|
|
95
|
+
* Static provider cannot refresh tokens, so always returns false.
|
|
96
|
+
*
|
|
97
|
+
* @returns Promise resolving to false (cannot refresh)
|
|
98
|
+
*/
|
|
99
|
+
async onUnauthorized() {
|
|
100
|
+
// Static provider cannot refresh tokens
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Handle forbidden response
|
|
105
|
+
*
|
|
106
|
+
* Static provider has no special handling for 403.
|
|
107
|
+
*/
|
|
108
|
+
async onForbidden() {
|
|
109
|
+
// No special handling for static provider
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Callback-based authentication provider
|
|
114
|
+
*
|
|
115
|
+
* Provides authentication using callback functions for dynamic token retrieval.
|
|
116
|
+
* Ideal for enterprise integrations where the parent application manages auth.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* const authProvider = new CallbackAuthProvider({
|
|
121
|
+
* getToken: async () => {
|
|
122
|
+
* return authService.getAccessToken();
|
|
123
|
+
* },
|
|
124
|
+
* onUnauthorized: async () => {
|
|
125
|
+
* const refreshed = await authService.refreshToken();
|
|
126
|
+
* return refreshed;
|
|
127
|
+
* },
|
|
128
|
+
* onForbidden: async () => {
|
|
129
|
+
* showError("You don't have permission to access this resource");
|
|
130
|
+
* }
|
|
131
|
+
* });
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export class CallbackAuthProvider {
|
|
135
|
+
/** Function to get the current token */
|
|
136
|
+
getToken;
|
|
137
|
+
/** Optional unauthorized callback */
|
|
138
|
+
onUnauthorizedCallback;
|
|
139
|
+
/** Optional forbidden callback */
|
|
140
|
+
onForbiddenCallback;
|
|
141
|
+
/**
|
|
142
|
+
* Create a new CallbackAuthProvider
|
|
143
|
+
*
|
|
144
|
+
* @param config - Callback authentication configuration
|
|
145
|
+
*/
|
|
146
|
+
constructor(config) {
|
|
147
|
+
this.getToken = config.getToken;
|
|
148
|
+
this.onUnauthorizedCallback = config.onUnauthorized;
|
|
149
|
+
this.onForbiddenCallback = config.onForbidden;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Get authentication headers
|
|
153
|
+
*
|
|
154
|
+
* Calls the getToken callback to retrieve the current token.
|
|
155
|
+
*
|
|
156
|
+
* @returns Promise resolving to authentication headers
|
|
157
|
+
*/
|
|
158
|
+
async getAuthHeaders() {
|
|
159
|
+
const token = await this.getToken();
|
|
160
|
+
if (token) {
|
|
161
|
+
return { Authorization: `Bearer ${token}` };
|
|
162
|
+
}
|
|
163
|
+
return {};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Check if authenticated
|
|
167
|
+
*
|
|
168
|
+
* For callback-based auth, we assume authenticated if getToken exists.
|
|
169
|
+
* The actual token validity is checked when making requests.
|
|
170
|
+
*
|
|
171
|
+
* @returns true (assumes authenticated, actual check happens on request)
|
|
172
|
+
*/
|
|
173
|
+
isAuthenticated() {
|
|
174
|
+
// For callback-based auth, we assume authenticated if getToken exists
|
|
175
|
+
// The actual token validity is checked when making requests
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Handle unauthorized response
|
|
180
|
+
*
|
|
181
|
+
* Calls the onUnauthorized callback if provided.
|
|
182
|
+
*
|
|
183
|
+
* @returns Promise resolving to true if auth was refreshed
|
|
184
|
+
*/
|
|
185
|
+
async onUnauthorized() {
|
|
186
|
+
if (this.onUnauthorizedCallback) {
|
|
187
|
+
return this.onUnauthorizedCallback();
|
|
188
|
+
}
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Handle forbidden response
|
|
193
|
+
*
|
|
194
|
+
* Calls the onForbidden callback if provided.
|
|
195
|
+
*/
|
|
196
|
+
async onForbidden() {
|
|
197
|
+
if (this.onForbiddenCallback) {
|
|
198
|
+
await this.onForbiddenCallback();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* No-op authentication provider
|
|
204
|
+
*
|
|
205
|
+
* Used when no authentication is required.
|
|
206
|
+
* Provides empty headers and always returns not authenticated.
|
|
207
|
+
*/
|
|
208
|
+
export class NoAuthProvider {
|
|
209
|
+
/**
|
|
210
|
+
* Get authentication headers
|
|
211
|
+
*
|
|
212
|
+
* Returns empty headers (no auth).
|
|
213
|
+
*
|
|
214
|
+
* @returns Promise resolving to empty object
|
|
215
|
+
*/
|
|
216
|
+
async getAuthHeaders() {
|
|
217
|
+
return {};
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Check if authenticated
|
|
221
|
+
*
|
|
222
|
+
* Always returns false (no auth configured).
|
|
223
|
+
*
|
|
224
|
+
* @returns false
|
|
225
|
+
*/
|
|
226
|
+
isAuthenticated() {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Create an AuthProvider from legacy endpointConfig.auth configuration
|
|
232
|
+
*
|
|
233
|
+
* Used internally for backward compatibility with existing code that uses
|
|
234
|
+
* the old auth configuration format in EndpointConfig.
|
|
235
|
+
*
|
|
236
|
+
* @param authConfig - Legacy auth configuration from EndpointConfig
|
|
237
|
+
* @returns AuthProvider instance
|
|
238
|
+
*/
|
|
239
|
+
export function createAuthProviderFromLegacyConfig(authConfig) {
|
|
240
|
+
if (!authConfig || authConfig.type === 'none') {
|
|
241
|
+
return new NoAuthProvider();
|
|
242
|
+
}
|
|
243
|
+
return new StaticAuthProvider(authConfig);
|
|
244
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event Handler Types for FlowDrop
|
|
3
|
+
*
|
|
4
|
+
* Defines high-level event handlers for enterprise integration.
|
|
5
|
+
* These events allow parent applications to react to workflow lifecycle events.
|
|
6
|
+
*
|
|
7
|
+
* @module types/events
|
|
8
|
+
*/
|
|
9
|
+
import type { Workflow } from './index.js';
|
|
10
|
+
/**
|
|
11
|
+
* Types of workflow changes
|
|
12
|
+
*
|
|
13
|
+
* Used to identify what kind of change triggered the onWorkflowChange event.
|
|
14
|
+
*/
|
|
15
|
+
export type WorkflowChangeType = 'node_add' | 'node_remove' | 'node_move' | 'node_config' | 'edge_add' | 'edge_remove' | 'metadata' | 'name' | 'description';
|
|
16
|
+
/**
|
|
17
|
+
* High-level event handlers for enterprise integration
|
|
18
|
+
*
|
|
19
|
+
* These event handlers allow parent applications to hook into FlowDrop's
|
|
20
|
+
* workflow lifecycle. All handlers are optional.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const eventHandlers: FlowDropEventHandlers = {
|
|
25
|
+
* onWorkflowChange: (workflow, changeType) => {
|
|
26
|
+
* console.log(`Workflow changed: ${changeType}`);
|
|
27
|
+
* },
|
|
28
|
+
* onDirtyStateChange: (isDirty) => {
|
|
29
|
+
* updateSaveButtonState(isDirty);
|
|
30
|
+
* },
|
|
31
|
+
* onAfterSave: async (workflow) => {
|
|
32
|
+
* showSuccess("Workflow saved!");
|
|
33
|
+
* }
|
|
34
|
+
* };
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export interface FlowDropEventHandlers {
|
|
38
|
+
/**
|
|
39
|
+
* Called when workflow changes (any modification)
|
|
40
|
+
*
|
|
41
|
+
* Triggered after nodes are added/removed/moved, edges are added/removed,
|
|
42
|
+
* or node configurations are changed.
|
|
43
|
+
*
|
|
44
|
+
* @param workflow - The updated workflow
|
|
45
|
+
* @param changeType - The type of change that occurred
|
|
46
|
+
*/
|
|
47
|
+
onWorkflowChange?: (workflow: Workflow, changeType: WorkflowChangeType) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Called when dirty state changes
|
|
50
|
+
*
|
|
51
|
+
* Triggered when the workflow transitions between saved and unsaved states.
|
|
52
|
+
* Useful for updating UI indicators or enabling/disabling save buttons.
|
|
53
|
+
*
|
|
54
|
+
* @param isDirty - true if there are unsaved changes
|
|
55
|
+
*/
|
|
56
|
+
onDirtyStateChange?: (isDirty: boolean) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Called before save - return false to cancel
|
|
59
|
+
*
|
|
60
|
+
* Allows the parent application to validate or confirm before saving.
|
|
61
|
+
* If this returns false, the save operation is cancelled.
|
|
62
|
+
*
|
|
63
|
+
* @param workflow - The workflow about to be saved
|
|
64
|
+
* @returns Promise resolving to false to cancel, true/void to proceed
|
|
65
|
+
*/
|
|
66
|
+
onBeforeSave?: (workflow: Workflow) => Promise<boolean | void>;
|
|
67
|
+
/**
|
|
68
|
+
* Called after successful save
|
|
69
|
+
*
|
|
70
|
+
* Triggered after the workflow has been successfully saved to the backend.
|
|
71
|
+
* Useful for showing success notifications or clearing draft storage.
|
|
72
|
+
*
|
|
73
|
+
* @param workflow - The saved workflow (may include server-assigned IDs)
|
|
74
|
+
*/
|
|
75
|
+
onAfterSave?: (workflow: Workflow) => Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Called when save fails
|
|
78
|
+
*
|
|
79
|
+
* Triggered when the save operation fails due to API error.
|
|
80
|
+
* Useful for showing error notifications or logging.
|
|
81
|
+
*
|
|
82
|
+
* @param error - The error that occurred
|
|
83
|
+
* @param workflow - The workflow that failed to save
|
|
84
|
+
*/
|
|
85
|
+
onSaveError?: (error: Error, workflow: Workflow) => Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Called when workflow is loaded
|
|
88
|
+
*
|
|
89
|
+
* Triggered after a workflow is loaded and initialized.
|
|
90
|
+
* This includes both initial load and subsequent loads.
|
|
91
|
+
*
|
|
92
|
+
* @param workflow - The loaded workflow
|
|
93
|
+
*/
|
|
94
|
+
onWorkflowLoad?: (workflow: Workflow) => void;
|
|
95
|
+
/**
|
|
96
|
+
* Called before unmount
|
|
97
|
+
*
|
|
98
|
+
* Triggered before FlowDrop is destroyed/unmounted.
|
|
99
|
+
* Allows parent application to save drafts or perform cleanup.
|
|
100
|
+
*
|
|
101
|
+
* @param workflow - The current workflow state
|
|
102
|
+
* @param isDirty - true if there are unsaved changes
|
|
103
|
+
*/
|
|
104
|
+
onBeforeUnmount?: (workflow: Workflow, isDirty: boolean) => void;
|
|
105
|
+
/**
|
|
106
|
+
* Called on any API error
|
|
107
|
+
*
|
|
108
|
+
* Triggered when any API request fails.
|
|
109
|
+
* Return true to suppress FlowDrop's default error toast.
|
|
110
|
+
*
|
|
111
|
+
* @param error - The error that occurred
|
|
112
|
+
* @param operation - Description of the operation that failed (e.g., "save", "load", "fetchNodes")
|
|
113
|
+
* @returns true to suppress default error handling, false/void to show default toast
|
|
114
|
+
*/
|
|
115
|
+
onApiError?: (error: Error, operation: string) => boolean | void;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Feature flags for FlowDrop
|
|
119
|
+
*
|
|
120
|
+
* Controls optional features and behaviors.
|
|
121
|
+
* All features have sensible defaults.
|
|
122
|
+
*/
|
|
123
|
+
export interface FlowDropFeatures {
|
|
124
|
+
/**
|
|
125
|
+
* Save drafts to localStorage automatically
|
|
126
|
+
*
|
|
127
|
+
* When enabled, FlowDrop will periodically save the current workflow
|
|
128
|
+
* to localStorage as a draft. This helps prevent data loss.
|
|
129
|
+
*
|
|
130
|
+
* @default true
|
|
131
|
+
*/
|
|
132
|
+
autoSaveDraft?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Auto-save interval in milliseconds
|
|
135
|
+
*
|
|
136
|
+
* How often to save drafts to localStorage when autoSaveDraft is enabled.
|
|
137
|
+
*
|
|
138
|
+
* @default 30000 (30 seconds)
|
|
139
|
+
*/
|
|
140
|
+
autoSaveDraftInterval?: number;
|
|
141
|
+
/**
|
|
142
|
+
* Show toast notifications
|
|
143
|
+
*
|
|
144
|
+
* When enabled, FlowDrop will show toast notifications for
|
|
145
|
+
* success, error, and loading states.
|
|
146
|
+
*
|
|
147
|
+
* @default true
|
|
148
|
+
*/
|
|
149
|
+
showToasts?: boolean;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Default feature values
|
|
153
|
+
*
|
|
154
|
+
* Used when features are not explicitly configured.
|
|
155
|
+
*/
|
|
156
|
+
export declare const DEFAULT_FEATURES: Required<FlowDropFeatures>;
|
|
157
|
+
/**
|
|
158
|
+
* Merge user-provided features with defaults
|
|
159
|
+
*
|
|
160
|
+
* @param features - User-provided feature configuration
|
|
161
|
+
* @returns Complete feature configuration with defaults applied
|
|
162
|
+
*/
|
|
163
|
+
export declare function mergeFeatures(features?: FlowDropFeatures): Required<FlowDropFeatures>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event Handler Types for FlowDrop
|
|
3
|
+
*
|
|
4
|
+
* Defines high-level event handlers for enterprise integration.
|
|
5
|
+
* These events allow parent applications to react to workflow lifecycle events.
|
|
6
|
+
*
|
|
7
|
+
* @module types/events
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Default feature values
|
|
11
|
+
*
|
|
12
|
+
* Used when features are not explicitly configured.
|
|
13
|
+
*/
|
|
14
|
+
export const DEFAULT_FEATURES = {
|
|
15
|
+
autoSaveDraft: true,
|
|
16
|
+
autoSaveDraftInterval: 30000,
|
|
17
|
+
showToasts: true
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Merge user-provided features with defaults
|
|
21
|
+
*
|
|
22
|
+
* @param features - User-provided feature configuration
|
|
23
|
+
* @returns Complete feature configuration with defaults applied
|
|
24
|
+
*/
|
|
25
|
+
export function mergeFeatures(features) {
|
|
26
|
+
return {
|
|
27
|
+
...DEFAULT_FEATURES,
|
|
28
|
+
...features
|
|
29
|
+
};
|
|
30
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -71,9 +71,27 @@ export interface NodePort {
|
|
|
71
71
|
defaultValue?: unknown;
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
* Built-in node types for explicit component rendering.
|
|
75
|
+
* These are the node types that ship with FlowDrop.
|
|
76
|
+
*/
|
|
77
|
+
export type BuiltinNodeType = 'note' | 'simple' | 'square' | 'tool' | 'gateway' | 'default';
|
|
78
|
+
/**
|
|
79
|
+
* Node type for component rendering.
|
|
80
|
+
* Includes built-in types and allows custom registered types.
|
|
81
|
+
*
|
|
82
|
+
* Built-in types: note, simple, square, tool, gateway, default
|
|
83
|
+
* Custom types: Any string registered via nodeComponentRegistry
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* // Built-in type
|
|
88
|
+
* const type: NodeType = "simple";
|
|
89
|
+
*
|
|
90
|
+
* // Custom registered type
|
|
91
|
+
* const customType: NodeType = "mylib:fancy";
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export type NodeType = BuiltinNodeType | (string & Record<never, never>);
|
|
77
95
|
/**
|
|
78
96
|
* Node configuration metadata
|
|
79
97
|
*/
|
|
@@ -85,6 +103,7 @@ export interface NodeMetadata {
|
|
|
85
103
|
* Array of supported node types that this node can be rendered as.
|
|
86
104
|
* If not specified, defaults to the single 'type' field or 'default'.
|
|
87
105
|
* This allows nodes to support multiple rendering modes (e.g., both 'simple' and 'default').
|
|
106
|
+
* Can include both built-in types and custom registered types.
|
|
88
107
|
*/
|
|
89
108
|
supportedTypes?: NodeType[];
|
|
90
109
|
description: string;
|
|
@@ -252,6 +271,14 @@ export interface WorkflowNode extends Node {
|
|
|
252
271
|
executionInfo?: NodeExecutionInfo;
|
|
253
272
|
};
|
|
254
273
|
}
|
|
274
|
+
/**
|
|
275
|
+
* Edge category types based on source port data type
|
|
276
|
+
* Used for visual styling of edges on the canvas
|
|
277
|
+
* - trigger: For control flow connections (dataType: "trigger")
|
|
278
|
+
* - tool: Dashed amber line for tool connections (dataType: "tool")
|
|
279
|
+
* - data: Normal gray line for all other data connections
|
|
280
|
+
*/
|
|
281
|
+
export type EdgeCategory = 'trigger' | 'tool' | 'data';
|
|
255
282
|
/**
|
|
256
283
|
* Extended edge type for workflows
|
|
257
284
|
*/
|
|
@@ -267,6 +294,14 @@ export interface WorkflowEdge extends Edge {
|
|
|
267
294
|
data?: {
|
|
268
295
|
label?: string;
|
|
269
296
|
condition?: string;
|
|
297
|
+
/** Edge metadata for API and persistence */
|
|
298
|
+
metadata?: {
|
|
299
|
+
/** Edge type for styling ("tool" or "data") */
|
|
300
|
+
edgeType?: EdgeCategory;
|
|
301
|
+
/** Data type of the source output port (e.g., "tool", "string", "number") */
|
|
302
|
+
sourcePortDataType?: string;
|
|
303
|
+
};
|
|
304
|
+
/** @deprecated Use metadata.edgeType instead - kept for backward compatibility */
|
|
270
305
|
isToolConnection?: boolean;
|
|
271
306
|
targetNodeType?: string;
|
|
272
307
|
targetCategory?: string;
|
|
@@ -1,57 +1,112 @@
|
|
|
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
|
*/
|
|
5
12
|
import type { NodeType, NodeMetadata } from '../types/index.js';
|
|
6
13
|
/**
|
|
7
|
-
* Gets the SvelteFlow component name for a given NodeType
|
|
14
|
+
* Gets the SvelteFlow component name for a given NodeType.
|
|
15
|
+
* Supports both built-in types and registered custom types.
|
|
16
|
+
*
|
|
17
|
+
* @param nodeType - The node type identifier
|
|
18
|
+
* @returns The component name to use
|
|
8
19
|
*/
|
|
9
|
-
export declare function getComponentNameForNodeType(nodeType: NodeType): string;
|
|
20
|
+
export declare function getComponentNameForNodeType(nodeType: NodeType | string): string;
|
|
10
21
|
/**
|
|
11
|
-
* Gets the available node types for a given NodeMetadata
|
|
22
|
+
* Gets the available node types for a given NodeMetadata.
|
|
12
23
|
* Priority: supportedTypes > type > "default"
|
|
24
|
+
*
|
|
25
|
+
* @param metadata - The node metadata
|
|
26
|
+
* @returns Array of available node type identifiers
|
|
13
27
|
*/
|
|
14
|
-
export declare function getAvailableNodeTypes(metadata: NodeMetadata): NodeType[];
|
|
28
|
+
export declare function getAvailableNodeTypes(metadata: NodeMetadata): (NodeType | string)[];
|
|
15
29
|
/**
|
|
16
|
-
* Gets the primary (default) node type for a given NodeMetadata
|
|
17
|
-
* This is used when no specific type is configured by the user
|
|
30
|
+
* Gets the primary (default) node type for a given NodeMetadata.
|
|
31
|
+
* This is used when no specific type is configured by the user.
|
|
32
|
+
*
|
|
33
|
+
* @param metadata - The node metadata
|
|
34
|
+
* @returns The primary node type
|
|
18
35
|
*/
|
|
19
|
-
export declare function getPrimaryNodeType(metadata: NodeMetadata): NodeType;
|
|
36
|
+
export declare function getPrimaryNodeType(metadata: NodeMetadata): NodeType | string;
|
|
20
37
|
/**
|
|
21
|
-
* Determines the appropriate node type based on configuration and metadata
|
|
38
|
+
* Determines the appropriate node type based on configuration and metadata.
|
|
39
|
+
*
|
|
22
40
|
* Priority:
|
|
23
41
|
* 1. configNodeType (if valid for this metadata)
|
|
24
42
|
* 2. metadata.type (if valid)
|
|
25
43
|
* 3. First supportedType
|
|
26
44
|
* 4. "default"
|
|
45
|
+
*
|
|
46
|
+
* @param metadata - The node metadata
|
|
47
|
+
* @param configNodeType - Optional type from user config
|
|
48
|
+
* @returns The resolved node type
|
|
27
49
|
*/
|
|
28
|
-
export declare function resolveNodeType(metadata: NodeMetadata, configNodeType?: string): NodeType;
|
|
50
|
+
export declare function resolveNodeType(metadata: NodeMetadata, configNodeType?: string): NodeType | string;
|
|
29
51
|
/**
|
|
30
|
-
* Gets the SvelteFlow component name for resolved node type
|
|
31
|
-
* This
|
|
52
|
+
* Gets the SvelteFlow component name for resolved node type.
|
|
53
|
+
* This is the main function used by UniversalNode to determine which component to render.
|
|
54
|
+
*
|
|
55
|
+
* @param metadata - The node metadata
|
|
56
|
+
* @param configNodeType - Optional type from user config
|
|
57
|
+
* @returns The component name to use
|
|
32
58
|
*/
|
|
33
59
|
export declare function resolveComponentName(metadata: NodeMetadata, configNodeType?: string): string;
|
|
34
60
|
/**
|
|
35
|
-
* Validates if a node type is supported by the given metadata
|
|
61
|
+
* Validates if a node type is supported by the given metadata.
|
|
62
|
+
*
|
|
63
|
+
* @param metadata - The node metadata
|
|
64
|
+
* @param nodeType - The type to check
|
|
65
|
+
* @returns true if the type is supported
|
|
36
66
|
*/
|
|
37
|
-
export declare function isNodeTypeSupported(metadata: NodeMetadata, nodeType: NodeType): boolean;
|
|
67
|
+
export declare function isNodeTypeSupported(metadata: NodeMetadata, nodeType: NodeType | string): boolean;
|
|
38
68
|
/**
|
|
39
|
-
* Gets enum options for node type configuration
|
|
40
|
-
* Used in config schemas to show available options
|
|
69
|
+
* Gets enum options for node type configuration.
|
|
70
|
+
* Used in config schemas to show available options.
|
|
71
|
+
*
|
|
72
|
+
* This function combines:
|
|
73
|
+
* - Types specified in metadata.supportedTypes
|
|
74
|
+
* - Registered custom types (optionally filtered)
|
|
75
|
+
*
|
|
76
|
+
* @param metadata - The node metadata
|
|
77
|
+
* @param includeCustomTypes - Whether to include registered custom types
|
|
78
|
+
* @returns Object with enum values and display names
|
|
41
79
|
*/
|
|
42
|
-
export declare function getNodeTypeEnumOptions(metadata: NodeMetadata): {
|
|
80
|
+
export declare function getNodeTypeEnumOptions(metadata: NodeMetadata, includeCustomTypes?: boolean): {
|
|
43
81
|
enum: string[];
|
|
44
82
|
enumNames: string[];
|
|
45
83
|
};
|
|
46
84
|
/**
|
|
47
|
-
* Creates a nodeType config property that respects supportedTypes
|
|
48
|
-
* This replaces hardcoded enum values in config schemas
|
|
85
|
+
* Creates a nodeType config property that respects supportedTypes.
|
|
86
|
+
* This replaces hardcoded enum values in config schemas.
|
|
87
|
+
*
|
|
88
|
+
* @param metadata - The node metadata
|
|
89
|
+
* @param defaultType - Optional default type override
|
|
90
|
+
* @returns Config schema property object
|
|
49
91
|
*/
|
|
50
|
-
export declare function createNodeTypeConfigProperty(metadata: NodeMetadata, defaultType?: NodeType): {
|
|
92
|
+
export declare function createNodeTypeConfigProperty(metadata: NodeMetadata, defaultType?: NodeType | string): {
|
|
51
93
|
type: "string";
|
|
52
94
|
title: string;
|
|
53
95
|
description: string;
|
|
54
|
-
default:
|
|
96
|
+
default: string;
|
|
55
97
|
enum: string[];
|
|
56
98
|
enumNames: string[];
|
|
57
99
|
};
|
|
100
|
+
/**
|
|
101
|
+
* Check if a type string represents a valid registered or built-in type.
|
|
102
|
+
*
|
|
103
|
+
* @param type - The type to check
|
|
104
|
+
* @returns true if the type is valid
|
|
105
|
+
*/
|
|
106
|
+
export declare function isValidNodeType(type: string): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Get all available node types (built-in + registered).
|
|
109
|
+
*
|
|
110
|
+
* @returns Array of all valid node type identifiers
|
|
111
|
+
*/
|
|
112
|
+
export declare function getAllNodeTypes(): string[];
|