@flowdrop/flowdrop 1.14.0 → 2.0.0-beta.1

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.
Files changed (218) hide show
  1. package/CHANGELOG.md +475 -0
  2. package/MIGRATION-2.0.md +472 -0
  3. package/README.md +23 -23
  4. package/dist/adapters/WorkflowAdapter.d.ts +1 -1
  5. package/dist/adapters/WorkflowAdapter.js +14 -8
  6. package/dist/adapters/agentspec/AgentSpecAdapter.js +7 -7
  7. package/dist/chat/batchFeedback.d.ts +39 -0
  8. package/dist/chat/batchFeedback.js +51 -0
  9. package/dist/commands/executor.js +15 -1
  10. package/dist/commands/storeIntegration.svelte.d.ts +4 -1
  11. package/dist/commands/storeIntegration.svelte.js +26 -21
  12. package/dist/commands/types.d.ts +2 -0
  13. package/dist/components/App.svelte +162 -192
  14. package/dist/components/App.svelte.d.ts +47 -8
  15. package/dist/components/ConfigForm.svelte +110 -66
  16. package/dist/components/ConfigModal.svelte +7 -2
  17. package/dist/components/ConnectionLine.svelte +4 -2
  18. package/dist/components/Navbar.svelte +61 -1
  19. package/dist/components/NodeSidebar.svelte +27 -45
  20. package/dist/components/NodeStatusOverlay.svelte +94 -6
  21. package/dist/components/NodeSwapPicker.svelte +10 -8
  22. package/dist/components/PipelineStatus.svelte +16 -67
  23. package/dist/components/PortCoordinateTracker.svelte +5 -6
  24. package/dist/components/SchemaForm.stories.svelte +1 -3
  25. package/dist/components/SchemaForm.svelte +45 -40
  26. package/dist/components/SchemaForm.svelte.d.ts +0 -8
  27. package/dist/components/SettingsModal.svelte +8 -3
  28. package/dist/components/SettingsPanel.svelte +20 -4
  29. package/dist/components/SwapMappingEditor.svelte +67 -49
  30. package/dist/components/SwapMappingEditor.svelte.d.ts +0 -2
  31. package/dist/components/UniversalNode.svelte +9 -7
  32. package/dist/components/WorkflowEditor.svelte +118 -111
  33. package/dist/components/WorkflowEditor.svelte.d.ts +18 -10
  34. package/dist/components/chat/AIChatPanel.svelte +93 -89
  35. package/dist/components/chat/AIChatPanel.svelte.d.ts +0 -4
  36. package/dist/components/chat/CommandPreview.svelte +2 -1
  37. package/dist/components/console/CommandConsole.svelte +7 -5
  38. package/dist/components/console/ConsoleAutocomplete.svelte +10 -11
  39. package/dist/components/console/ConsoleAutocomplete.svelte.d.ts +6 -0
  40. package/dist/components/console/ConsoleInput.svelte +15 -6
  41. package/dist/components/console/ConsoleOutput.svelte +2 -1
  42. package/dist/components/form/FormArray.svelte +5 -9
  43. package/dist/components/form/FormArray.svelte.d.ts +2 -1
  44. package/dist/components/form/FormAutocomplete.svelte +29 -13
  45. package/dist/components/form/FormField.svelte +4 -2
  46. package/dist/components/form/FormFieldLight.svelte +4 -2
  47. package/dist/components/form/FormMarkdownEditor.svelte +9 -4
  48. package/dist/components/form/FormRangeField.svelte +1 -0
  49. package/dist/components/form/FormTemplateEditor.svelte +11 -3
  50. package/dist/components/form/FormToggle.svelte +5 -12
  51. package/dist/components/form/FormToggle.svelte.d.ts +4 -2
  52. package/dist/components/form/templateAutocomplete.js +1 -5
  53. package/dist/components/form/types.d.ts +1 -14
  54. package/dist/components/interrupt/FormPrompt.svelte +3 -2
  55. package/dist/components/interrupt/InterruptBubble.svelte +16 -17
  56. package/dist/components/interrupt/ReviewPrompt.svelte +10 -3
  57. package/dist/components/interrupt/TextInputPrompt.svelte +2 -1
  58. package/dist/components/layouts/MainLayout.svelte +20 -13
  59. package/dist/components/layouts/MainLayout.svelte.d.ts +4 -0
  60. package/dist/components/nodes/AtomNode.svelte +292 -0
  61. package/dist/components/nodes/AtomNode.svelte.d.ts +26 -0
  62. package/dist/components/nodes/GatewayNode.svelte +19 -10
  63. package/dist/components/nodes/IdeaNode.svelte +7 -0
  64. package/dist/components/nodes/SimpleNode.svelte +11 -6
  65. package/dist/components/nodes/SquareNode.svelte +15 -8
  66. package/dist/components/nodes/TerminalNode.svelte +9 -4
  67. package/dist/components/nodes/ToolNode.svelte +7 -1
  68. package/dist/components/nodes/WorkflowNode.svelte +16 -7
  69. package/dist/components/playground/ChatInput.svelte +11 -14
  70. package/dist/components/playground/ChatPanel.svelte +6 -49
  71. package/dist/components/playground/ChatPanel.svelte.d.ts +0 -14
  72. package/dist/components/playground/ControlPanel.svelte +134 -123
  73. package/dist/components/playground/ControlPanel.svelte.d.ts +3 -0
  74. package/dist/components/playground/ExecutionLogs.svelte +11 -9
  75. package/dist/components/playground/InputCollector.svelte +11 -9
  76. package/dist/components/playground/MessageStream.svelte +17 -23
  77. package/dist/components/playground/PipelineKanbanView.svelte +65 -6
  78. package/dist/components/playground/PipelinePanel.svelte +11 -5
  79. package/dist/components/playground/PipelineTableView.svelte +186 -44
  80. package/dist/components/playground/Playground.svelte +95 -92
  81. package/dist/components/playground/Playground.svelte.d.ts +2 -0
  82. package/dist/components/playground/PlaygroundApp.svelte +6 -1
  83. package/dist/components/playground/PlaygroundApp.svelte.d.ts +3 -0
  84. package/dist/components/playground/PlaygroundModal.svelte +13 -3
  85. package/dist/components/playground/PlaygroundModal.svelte.d.ts +3 -0
  86. package/dist/components/playground/PlaygroundStudio.svelte +34 -32
  87. package/dist/components/playground/PlaygroundStudio.svelte.d.ts +3 -0
  88. package/dist/components/playground/SessionManager.svelte +9 -12
  89. package/dist/components/playground/pipelineViewUtils.svelte.d.ts +28 -0
  90. package/dist/components/playground/pipelineViewUtils.svelte.js +38 -1
  91. package/dist/config/endpoints.d.ts +0 -7
  92. package/dist/config/endpoints.js +2 -10
  93. package/dist/core/index.d.ts +4 -4
  94. package/dist/core/index.js +6 -6
  95. package/dist/display/index.d.ts +0 -2
  96. package/dist/display/index.js +0 -6
  97. package/dist/editor/index.d.ts +19 -20
  98. package/dist/editor/index.js +25 -35
  99. package/dist/form/code.d.ts +25 -15
  100. package/dist/form/code.js +44 -41
  101. package/dist/form/fieldRegistry.d.ts +17 -13
  102. package/dist/form/fieldRegistry.js +32 -12
  103. package/dist/form/full.d.ts +17 -13
  104. package/dist/form/full.js +22 -27
  105. package/dist/form/index.d.ts +3 -3
  106. package/dist/form/index.js +3 -3
  107. package/dist/form/markdown.d.ts +13 -8
  108. package/dist/form/markdown.js +22 -23
  109. package/dist/helpers/proximityConnect.d.ts +7 -3
  110. package/dist/helpers/proximityConnect.js +19 -6
  111. package/dist/helpers/workflowEditorHelper.d.ts +12 -5
  112. package/dist/helpers/workflowEditorHelper.js +27 -25
  113. package/dist/index.d.ts +28 -24
  114. package/dist/index.js +27 -50
  115. package/dist/messages/defaults.d.ts +2 -5
  116. package/dist/messages/defaults.js +3 -6
  117. package/dist/messages/index.d.ts +0 -1
  118. package/dist/messages/index.js +0 -1
  119. package/dist/mocks/app-forms.d.ts +6 -2
  120. package/dist/mocks/app-forms.js +11 -4
  121. package/dist/openapi/v1/openapi.yaml +227 -164
  122. package/dist/playground/index.d.ts +2 -3
  123. package/dist/playground/index.js +2 -30
  124. package/dist/playground/mount.d.ts +15 -0
  125. package/dist/playground/mount.js +46 -20
  126. package/dist/registry/{BaseRegistry.d.ts → BaseRegistry.svelte.d.ts} +22 -1
  127. package/dist/registry/{BaseRegistry.js → BaseRegistry.svelte.js} +37 -1
  128. package/dist/registry/builtinFormats.d.ts +9 -18
  129. package/dist/registry/builtinFormats.js +9 -39
  130. package/dist/registry/builtinNodes.d.ts +1 -26
  131. package/dist/registry/builtinNodes.js +14 -50
  132. package/dist/registry/index.d.ts +3 -4
  133. package/dist/registry/index.js +4 -6
  134. package/dist/registry/nodeComponentRegistry.d.ts +182 -15
  135. package/dist/registry/nodeComponentRegistry.js +235 -17
  136. package/dist/registry/workflowFormatRegistry.d.ts +14 -9
  137. package/dist/registry/workflowFormatRegistry.js +24 -8
  138. package/dist/{schema → schemas}/index.d.ts +2 -2
  139. package/dist/{schema → schemas}/index.js +2 -2
  140. package/dist/schemas/v1/workflow.schema.json +53 -6
  141. package/dist/services/agentSpecExecutionService.js +0 -1
  142. package/dist/services/apiVariableService.d.ts +2 -1
  143. package/dist/services/apiVariableService.js +5 -22
  144. package/dist/services/autoSaveService.d.ts +7 -0
  145. package/dist/services/autoSaveService.js +6 -4
  146. package/dist/services/chatService.d.ts +8 -4
  147. package/dist/services/chatService.js +15 -15
  148. package/dist/services/draftStorage.d.ts +129 -13
  149. package/dist/services/draftStorage.js +185 -37
  150. package/dist/services/dynamicSchemaService.d.ts +2 -1
  151. package/dist/services/dynamicSchemaService.js +5 -22
  152. package/dist/services/globalSave.d.ts +13 -12
  153. package/dist/services/globalSave.js +29 -51
  154. package/dist/services/historyService.d.ts +9 -3
  155. package/dist/services/historyService.js +9 -3
  156. package/dist/services/interruptService.d.ts +14 -9
  157. package/dist/services/interruptService.js +27 -27
  158. package/dist/services/nodeExecutionService.d.ts +18 -3
  159. package/dist/services/nodeExecutionService.js +71 -45
  160. package/dist/services/playgroundService.d.ts +14 -9
  161. package/dist/services/playgroundService.js +31 -30
  162. package/dist/services/variableService.d.ts +2 -1
  163. package/dist/services/variableService.js +2 -2
  164. package/dist/services/workflowStorage.js +6 -6
  165. package/dist/stores/apiContext.d.ts +45 -0
  166. package/dist/stores/apiContext.js +65 -0
  167. package/dist/stores/categoriesStore.svelte.d.ts +28 -23
  168. package/dist/stores/categoriesStore.svelte.js +70 -64
  169. package/dist/stores/getInstance.svelte.d.ts +39 -0
  170. package/dist/stores/getInstance.svelte.js +65 -0
  171. package/dist/stores/historyStore.svelte.d.ts +77 -93
  172. package/dist/stores/historyStore.svelte.js +134 -160
  173. package/dist/stores/instanceContainer.svelte.d.ts +111 -0
  174. package/dist/stores/instanceContainer.svelte.js +114 -0
  175. package/dist/stores/interruptStore.svelte.d.ts +112 -82
  176. package/dist/stores/interruptStore.svelte.js +253 -226
  177. package/dist/stores/pipelinePanelStore.svelte.d.ts +27 -3
  178. package/dist/stores/pipelinePanelStore.svelte.js +61 -14
  179. package/dist/stores/playgroundStore.svelte.d.ts +169 -216
  180. package/dist/stores/playgroundStore.svelte.js +515 -572
  181. package/dist/stores/portCoordinateStore.svelte.d.ts +57 -51
  182. package/dist/stores/portCoordinateStore.svelte.js +109 -98
  183. package/dist/stores/settingsStore.svelte.d.ts +4 -1
  184. package/dist/stores/settingsStore.svelte.js +47 -12
  185. package/dist/stores/workflowStore.svelte.d.ts +178 -213
  186. package/dist/stores/workflowStore.svelte.js +449 -501
  187. package/dist/stories/EdgeDecorator.svelte +5 -2
  188. package/dist/stories/NodeDecorator.svelte +5 -3
  189. package/dist/svelte-app.d.ts +60 -10
  190. package/dist/svelte-app.js +157 -53
  191. package/dist/types/events.d.ts +6 -3
  192. package/dist/types/index.d.ts +71 -6
  193. package/dist/types/navbar.d.ts +7 -0
  194. package/dist/types/playground.d.ts +18 -3
  195. package/dist/types/settings.d.ts +13 -0
  196. package/dist/types/settings.js +1 -0
  197. package/dist/utils/colors.d.ts +47 -21
  198. package/dist/utils/colors.js +69 -68
  199. package/dist/utils/connections.d.ts +9 -15
  200. package/dist/utils/connections.js +13 -32
  201. package/dist/utils/duration.d.ts +13 -0
  202. package/dist/utils/duration.js +45 -0
  203. package/dist/utils/formMerge.d.ts +36 -0
  204. package/dist/utils/formMerge.js +70 -0
  205. package/dist/utils/icons.d.ts +5 -2
  206. package/dist/utils/icons.js +6 -5
  207. package/dist/utils/nodeSwap.d.ts +6 -2
  208. package/dist/utils/nodeSwap.js +62 -126
  209. package/dist/utils/nodeTypes.d.ts +17 -8
  210. package/dist/utils/nodeTypes.js +27 -19
  211. package/dist/utils/performanceUtils.js +7 -0
  212. package/package.json +6 -5
  213. package/dist/messages/deprecation.d.ts +0 -20
  214. package/dist/messages/deprecation.js +0 -33
  215. package/dist/registry/plugin.d.ts +0 -215
  216. package/dist/registry/plugin.js +0 -249
  217. package/dist/services/api.d.ts +0 -129
  218. package/dist/services/api.js +0 -217
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A drop-in visual workflow editor for any web application. You own the backend. You own the data. You own the orchestration.",
4
4
  "license": "MIT",
5
5
  "private": false,
6
- "version": "1.14.0",
6
+ "version": "2.0.0-beta.1",
7
7
  "author": "Shibin Das (D34dMan)",
8
8
  "bugs": {
9
9
  "url": "https://github.com/flowdrop-io/flowdrop/issues"
@@ -47,12 +47,12 @@
47
47
  "dist",
48
48
  "!dist/**/*.test.*",
49
49
  "!dist/**/*.spec.*",
50
- "!dist/**/*.map"
50
+ "!dist/**/*.map",
51
+ "CHANGELOG.md",
52
+ "MIGRATION-2.0.md"
51
53
  ],
52
54
  "sideEffects": [
53
- "**/*.css",
54
- "./dist/styles/base.css",
55
- "./dist/editor/index.js"
55
+ "**/*.css"
56
56
  ],
57
57
  "svelte": "./dist/index.js",
58
58
  "types": "./dist/index.d.ts",
@@ -269,6 +269,7 @@
269
269
  "dependencies": {
270
270
  "diff": "^8.0.3",
271
271
  "dompurify": "^3.3.1",
272
+ "esm-env": "^1.2.2",
272
273
  "marked": "^16.1.1",
273
274
  "svelte-5-french-toast": "^2.0.6",
274
275
  "uuid": "^11.1.0"
@@ -1,20 +0,0 @@
1
- /**
2
- * One-shot deprecation warning helper for the messages migration.
3
- *
4
- * Components that previously accepted per-string label props (e.g.
5
- * `saveLabel`, `cancelLabel`, `placeholder`, `addLabel`) keep accepting them
6
- * during the v1.x deprecation window. When a consumer passes one explicitly
7
- * we emit a single console.warn per (component, prop) pair so the noise is
8
- * bounded even if the prop is rebound on every render.
9
- *
10
- * Production builds skip the warning entirely.
11
- *
12
- * Removed in v2.0 along with the props themselves.
13
- */
14
- export declare function warnDeprecatedProp(component: string, prop: string, replacement: string): void;
15
- /**
16
- * Test-only: clear the warned-once cache so subsequent renders re-emit the
17
- * warning. Storybook stories and Vitest specs that share a module instance
18
- * need this to assert the warning fires per case.
19
- */
20
- export declare function __resetDeprecationWarningsForTests(): void;
@@ -1,33 +0,0 @@
1
- /**
2
- * One-shot deprecation warning helper for the messages migration.
3
- *
4
- * Components that previously accepted per-string label props (e.g.
5
- * `saveLabel`, `cancelLabel`, `placeholder`, `addLabel`) keep accepting them
6
- * during the v1.x deprecation window. When a consumer passes one explicitly
7
- * we emit a single console.warn per (component, prop) pair so the noise is
8
- * bounded even if the prop is rebound on every render.
9
- *
10
- * Production builds skip the warning entirely.
11
- *
12
- * Removed in v2.0 along with the props themselves.
13
- */
14
- const warned = new Set();
15
- export function warnDeprecatedProp(component, prop, replacement) {
16
- if (import.meta.env.PROD)
17
- return;
18
- const key = `${component}.${prop}`;
19
- if (warned.has(key))
20
- return;
21
- warned.add(key);
22
- // eslint-disable-next-line no-console
23
- console.warn(`[flowdrop] <${component}> prop \`${prop}\` is deprecated and will be removed in v2.0. ` +
24
- `Use \`messages\` on <FlowDrop> instead: ${replacement}`);
25
- }
26
- /**
27
- * Test-only: clear the warned-once cache so subsequent renders re-emit the
28
- * warning. Storybook stories and Vitest specs that share a module instance
29
- * need this to assert the warning fires per case.
30
- */
31
- export function __resetDeprecationWarningsForTests() {
32
- warned.clear();
33
- }
@@ -1,215 +0,0 @@
1
- /**
2
- * FlowDrop Plugin System
3
- * Provides APIs for external libraries to register custom node components.
4
- *
5
- * This enables a plugin ecosystem where:
6
- * - Third-party libraries can provide custom node types
7
- * - Custom nodes are namespaced to avoid conflicts
8
- * - Registration is simplified with a clean API
9
- */
10
- import { type NodeComponentProps, type NodeComponentCategory, type StatusPosition, type StatusSize } from './nodeComponentRegistry.js';
11
- import type { Component } from 'svelte';
12
- /**
13
- * Plugin configuration for external libraries.
14
- * Use this to register multiple node types from a library.
15
- */
16
- export interface FlowDropPluginConfig {
17
- /**
18
- * Unique namespace for this plugin.
19
- * Used to prefix all node types (e.g., "mylib" -> "mylib:nodename").
20
- * Should be lowercase, alphanumeric with optional hyphens.
21
- */
22
- namespace: string;
23
- /** Display name for the plugin (for UI/debugging purposes) */
24
- name: string;
25
- /** Plugin version (optional, for debugging) */
26
- version?: string;
27
- /** Description of what this plugin provides */
28
- description?: string;
29
- /** Node components to register */
30
- nodes: PluginNodeDefinition[];
31
- }
32
- /**
33
- * Simplified node definition for plugins.
34
- * Provides a cleaner API than full NodeComponentRegistration.
35
- */
36
- export interface PluginNodeDefinition {
37
- /**
38
- * Type identifier for this node.
39
- * Will be prefixed with the plugin namespace (e.g., "fancy" -> "mylib:fancy").
40
- */
41
- type: string;
42
- /** Display name shown in UI */
43
- displayName: string;
44
- /** Description of what this node does */
45
- description?: string;
46
- /** The Svelte component to render */
47
- component: Component<NodeComponentProps>;
48
- /** Icon in iconify format (e.g., "mdi:star") */
49
- icon?: string;
50
- /** Category for organizing in UI */
51
- category?: NodeComponentCategory;
52
- /** Status overlay position */
53
- statusPosition?: StatusPosition;
54
- /** Status overlay size */
55
- statusSize?: StatusSize;
56
- }
57
- /**
58
- * Result of plugin registration.
59
- * Contains information about what was registered and any errors.
60
- */
61
- export interface PluginRegistrationResult {
62
- /** Whether all nodes were registered successfully */
63
- success: boolean;
64
- /** The plugin namespace */
65
- namespace: string;
66
- /** Array of successfully registered type identifiers (namespaced) */
67
- registeredTypes: string[];
68
- /** Array of error messages for failed registrations */
69
- errors: string[];
70
- }
71
- /**
72
- * Register a FlowDrop plugin with custom node components.
73
- * All node types are automatically namespaced with the plugin namespace.
74
- *
75
- * @param config - Plugin configuration with namespace and node definitions
76
- * @returns Result object with registered types and any errors
77
- *
78
- * @example
79
- * ```typescript
80
- * import { registerFlowDropPlugin } from "@flowdrop/lib";
81
- * import FancyNode from "./FancyNode.svelte";
82
- * import GlowNode from "./GlowNode.svelte";
83
- *
84
- * const result = registerFlowDropPlugin({
85
- * namespace: "awesome",
86
- * name: "Awesome Nodes",
87
- * version: "1.0.0",
88
- * nodes: [
89
- * {
90
- * type: "fancy",
91
- * displayName: "Fancy Node",
92
- * component: FancyNode,
93
- * icon: "mdi:sparkles"
94
- * },
95
- * {
96
- * type: "glow",
97
- * displayName: "Glowing Node",
98
- * component: GlowNode,
99
- * icon: "mdi:lightbulb"
100
- * }
101
- * ]
102
- * });
103
- *
104
- * // Result:
105
- * // {
106
- * // success: true,
107
- * // namespace: "awesome",
108
- * // registeredTypes: ["awesome:fancy", "awesome:glow"],
109
- * // errors: []
110
- * // }
111
- * ```
112
- */
113
- export declare function registerFlowDropPlugin(config: FlowDropPluginConfig): PluginRegistrationResult;
114
- /**
115
- * Unregister all nodes from a plugin by namespace.
116
- *
117
- * @param namespace - The plugin namespace to unregister
118
- * @returns Array of unregistered type identifiers
119
- *
120
- * @example
121
- * ```typescript
122
- * const removed = unregisterFlowDropPlugin("awesome");
123
- * // Returns ["awesome:fancy", "awesome:glow"]
124
- * ```
125
- */
126
- export declare function unregisterFlowDropPlugin(namespace: string): string[];
127
- /**
128
- * Check if a namespace is valid.
129
- * Must be lowercase alphanumeric with optional hyphens.
130
- *
131
- * @param namespace - The namespace to validate
132
- * @returns true if valid
133
- */
134
- export declare function isValidNamespace(namespace: string): boolean;
135
- /**
136
- * Get all registered plugins (unique namespaces).
137
- *
138
- * @returns Array of namespace strings
139
- */
140
- export declare function getRegisteredPlugins(): string[];
141
- /**
142
- * Get the count of nodes registered by a plugin.
143
- *
144
- * @param namespace - The plugin namespace
145
- * @returns Number of nodes registered by this plugin
146
- */
147
- export declare function getPluginNodeCount(namespace: string): number;
148
- /**
149
- * Register a single custom node without a full plugin.
150
- * Useful for project-specific custom nodes.
151
- *
152
- * @param type - Type identifier (can be namespaced or plain)
153
- * @param displayName - Display name for UI
154
- * @param component - Svelte component
155
- * @param options - Additional options
156
- *
157
- * @example
158
- * ```typescript
159
- * import { registerCustomNode } from "@flowdrop/lib";
160
- * import MyNode from "./MyNode.svelte";
161
- *
162
- * registerCustomNode("myproject:special", "Special Node", MyNode, {
163
- * icon: "mdi:star",
164
- * description: "A special node for my project"
165
- * });
166
- * ```
167
- */
168
- export declare function registerCustomNode(type: string, displayName: string, component: Component<NodeComponentProps>, options?: {
169
- description?: string;
170
- icon?: string;
171
- category?: NodeComponentCategory;
172
- source?: string;
173
- statusPosition?: StatusPosition;
174
- statusSize?: StatusSize;
175
- }): void;
176
- /**
177
- * Create a plugin builder for a fluent API experience.
178
- *
179
- * @param namespace - Plugin namespace
180
- * @param name - Plugin name
181
- * @returns Plugin builder with chainable methods
182
- *
183
- * @example
184
- * ```typescript
185
- * import { createPlugin } from "@flowdrop/lib";
186
- *
187
- * createPlugin("awesome", "Awesome Nodes")
188
- * .version("1.0.0")
189
- * .node("fancy", "Fancy Node", FancyNode)
190
- * .node("glow", "Glowing Node", GlowNode, { icon: "mdi:lightbulb" })
191
- * .register();
192
- * ```
193
- */
194
- export declare function createPlugin(namespace: string, name: string): {
195
- /**
196
- * Set plugin version
197
- */
198
- version(v: string): /*elided*/ any;
199
- /**
200
- * Set plugin description
201
- */
202
- description(desc: string): /*elided*/ any;
203
- /**
204
- * Add a node to the plugin
205
- */
206
- node(type: string, displayName: string, component: Component<NodeComponentProps>, options?: Partial<Omit<PluginNodeDefinition, "type" | "displayName" | "component">>): /*elided*/ any;
207
- /**
208
- * Register the plugin
209
- */
210
- register(): PluginRegistrationResult;
211
- /**
212
- * Get the config without registering (for testing/inspection)
213
- */
214
- getConfig(): FlowDropPluginConfig;
215
- };
@@ -1,249 +0,0 @@
1
- /**
2
- * FlowDrop Plugin System
3
- * Provides APIs for external libraries to register custom node components.
4
- *
5
- * This enables a plugin ecosystem where:
6
- * - Third-party libraries can provide custom node types
7
- * - Custom nodes are namespaced to avoid conflicts
8
- * - Registration is simplified with a clean API
9
- */
10
- import { nodeComponentRegistry, createNamespacedType } from './nodeComponentRegistry.js';
11
- /**
12
- * Register a FlowDrop plugin with custom node components.
13
- * All node types are automatically namespaced with the plugin namespace.
14
- *
15
- * @param config - Plugin configuration with namespace and node definitions
16
- * @returns Result object with registered types and any errors
17
- *
18
- * @example
19
- * ```typescript
20
- * import { registerFlowDropPlugin } from "@flowdrop/lib";
21
- * import FancyNode from "./FancyNode.svelte";
22
- * import GlowNode from "./GlowNode.svelte";
23
- *
24
- * const result = registerFlowDropPlugin({
25
- * namespace: "awesome",
26
- * name: "Awesome Nodes",
27
- * version: "1.0.0",
28
- * nodes: [
29
- * {
30
- * type: "fancy",
31
- * displayName: "Fancy Node",
32
- * component: FancyNode,
33
- * icon: "mdi:sparkles"
34
- * },
35
- * {
36
- * type: "glow",
37
- * displayName: "Glowing Node",
38
- * component: GlowNode,
39
- * icon: "mdi:lightbulb"
40
- * }
41
- * ]
42
- * });
43
- *
44
- * // Result:
45
- * // {
46
- * // success: true,
47
- * // namespace: "awesome",
48
- * // registeredTypes: ["awesome:fancy", "awesome:glow"],
49
- * // errors: []
50
- * // }
51
- * ```
52
- */
53
- export function registerFlowDropPlugin(config) {
54
- const result = {
55
- success: true,
56
- namespace: config.namespace,
57
- registeredTypes: [],
58
- errors: []
59
- };
60
- // Validate namespace
61
- if (!isValidNamespace(config.namespace)) {
62
- result.success = false;
63
- result.errors.push(`Invalid namespace "${config.namespace}". ` +
64
- `Namespace must be lowercase alphanumeric with optional hyphens.`);
65
- return result;
66
- }
67
- // Register each node
68
- for (const nodeDef of config.nodes) {
69
- try {
70
- const namespacedType = createNamespacedType(config.namespace, nodeDef.type);
71
- const registration = {
72
- type: namespacedType,
73
- displayName: nodeDef.displayName,
74
- description: nodeDef.description,
75
- component: nodeDef.component,
76
- icon: nodeDef.icon,
77
- category: nodeDef.category ?? 'custom',
78
- source: config.namespace,
79
- statusPosition: nodeDef.statusPosition,
80
- statusSize: nodeDef.statusSize
81
- };
82
- nodeComponentRegistry.register(registration);
83
- result.registeredTypes.push(namespacedType);
84
- }
85
- catch (error) {
86
- result.success = false;
87
- const errorMessage = error instanceof Error ? error.message : String(error);
88
- result.errors.push(`Failed to register ${config.namespace}:${nodeDef.type}: ${errorMessage}`);
89
- }
90
- }
91
- return result;
92
- }
93
- /**
94
- * Unregister all nodes from a plugin by namespace.
95
- *
96
- * @param namespace - The plugin namespace to unregister
97
- * @returns Array of unregistered type identifiers
98
- *
99
- * @example
100
- * ```typescript
101
- * const removed = unregisterFlowDropPlugin("awesome");
102
- * // Returns ["awesome:fancy", "awesome:glow"]
103
- * ```
104
- */
105
- export function unregisterFlowDropPlugin(namespace) {
106
- const unregistered = [];
107
- const types = nodeComponentRegistry.getTypes();
108
- for (const type of types) {
109
- if (type.startsWith(`${namespace}:`)) {
110
- if (nodeComponentRegistry.unregister(type)) {
111
- unregistered.push(type);
112
- }
113
- }
114
- }
115
- return unregistered;
116
- }
117
- /**
118
- * Check if a namespace is valid.
119
- * Must be lowercase alphanumeric with optional hyphens.
120
- *
121
- * @param namespace - The namespace to validate
122
- * @returns true if valid
123
- */
124
- export function isValidNamespace(namespace) {
125
- return /^[a-z][a-z0-9-]*$/.test(namespace);
126
- }
127
- /**
128
- * Get all registered plugins (unique namespaces).
129
- *
130
- * @returns Array of namespace strings
131
- */
132
- export function getRegisteredPlugins() {
133
- const sources = new Set();
134
- const registrations = nodeComponentRegistry.getAll();
135
- for (const reg of registrations) {
136
- if (reg.source && reg.source !== 'flowdrop') {
137
- sources.add(reg.source);
138
- }
139
- }
140
- return Array.from(sources);
141
- }
142
- /**
143
- * Get the count of nodes registered by a plugin.
144
- *
145
- * @param namespace - The plugin namespace
146
- * @returns Number of nodes registered by this plugin
147
- */
148
- export function getPluginNodeCount(namespace) {
149
- return nodeComponentRegistry.getBySource(namespace).length;
150
- }
151
- /**
152
- * Register a single custom node without a full plugin.
153
- * Useful for project-specific custom nodes.
154
- *
155
- * @param type - Type identifier (can be namespaced or plain)
156
- * @param displayName - Display name for UI
157
- * @param component - Svelte component
158
- * @param options - Additional options
159
- *
160
- * @example
161
- * ```typescript
162
- * import { registerCustomNode } from "@flowdrop/lib";
163
- * import MyNode from "./MyNode.svelte";
164
- *
165
- * registerCustomNode("myproject:special", "Special Node", MyNode, {
166
- * icon: "mdi:star",
167
- * description: "A special node for my project"
168
- * });
169
- * ```
170
- */
171
- export function registerCustomNode(type, displayName, component, options = {}) {
172
- nodeComponentRegistry.register({
173
- type,
174
- displayName,
175
- component,
176
- description: options.description,
177
- icon: options.icon,
178
- category: options.category ?? 'custom',
179
- source: options.source ?? 'custom',
180
- statusPosition: options.statusPosition,
181
- statusSize: options.statusSize
182
- });
183
- }
184
- /**
185
- * Create a plugin builder for a fluent API experience.
186
- *
187
- * @param namespace - Plugin namespace
188
- * @param name - Plugin name
189
- * @returns Plugin builder with chainable methods
190
- *
191
- * @example
192
- * ```typescript
193
- * import { createPlugin } from "@flowdrop/lib";
194
- *
195
- * createPlugin("awesome", "Awesome Nodes")
196
- * .version("1.0.0")
197
- * .node("fancy", "Fancy Node", FancyNode)
198
- * .node("glow", "Glowing Node", GlowNode, { icon: "mdi:lightbulb" })
199
- * .register();
200
- * ```
201
- */
202
- export function createPlugin(namespace, name) {
203
- const config = {
204
- namespace,
205
- name,
206
- nodes: []
207
- };
208
- const builder = {
209
- /**
210
- * Set plugin version
211
- */
212
- version(v) {
213
- config.version = v;
214
- return builder;
215
- },
216
- /**
217
- * Set plugin description
218
- */
219
- description(desc) {
220
- config.description = desc;
221
- return builder;
222
- },
223
- /**
224
- * Add a node to the plugin
225
- */
226
- node(type, displayName, component, options = {}) {
227
- config.nodes.push({
228
- type,
229
- displayName,
230
- component,
231
- ...options
232
- });
233
- return builder;
234
- },
235
- /**
236
- * Register the plugin
237
- */
238
- register() {
239
- return registerFlowDropPlugin(config);
240
- },
241
- /**
242
- * Get the config without registering (for testing/inspection)
243
- */
244
- getConfig() {
245
- return { ...config };
246
- }
247
- };
248
- return builder;
249
- }
@@ -1,129 +0,0 @@
1
- /**
2
- * Client-side API service for FlowDrop
3
- * Provides methods to interact with the backend APIs using configurable endpoints
4
- */
5
- import type { NodeMetadata, Workflow } from '../types/index.js';
6
- import type { EndpointConfig } from '../config/endpoints.js';
7
- /**
8
- * Set the endpoint configuration at runtime
9
- */
10
- export declare function setEndpointConfig(config: EndpointConfig): void;
11
- /**
12
- * Get the current endpoint configuration
13
- */
14
- export declare function getEndpointConfig(): EndpointConfig | null;
15
- /**
16
- * Node API methods
17
- */
18
- export declare const nodeApi: {
19
- /**
20
- * Get all node types with optional filtering
21
- */
22
- getNodes(options?: {
23
- category?: string;
24
- search?: string;
25
- limit?: number;
26
- offset?: number;
27
- }): Promise<NodeMetadata[]>;
28
- /**
29
- * Get a specific node type by ID
30
- */
31
- getNode(id: string): Promise<NodeMetadata>;
32
- };
33
- /**
34
- * Workflow API methods
35
- */
36
- export declare const workflowApi: {
37
- /**
38
- * Get all workflows with optional filtering
39
- */
40
- getWorkflows(options?: {
41
- search?: string;
42
- limit?: number;
43
- offset?: number;
44
- }): Promise<Workflow[]>;
45
- /**
46
- * Get a specific workflow by ID
47
- */
48
- getWorkflow(id: string): Promise<Workflow>;
49
- /**
50
- * Create a new workflow
51
- */
52
- createWorkflow(workflow: Omit<Workflow, "id">): Promise<Workflow>;
53
- /**
54
- * Update an existing workflow
55
- */
56
- updateWorkflow(id: string, workflow: Partial<Workflow>): Promise<Workflow>;
57
- /**
58
- * Delete a workflow
59
- */
60
- deleteWorkflow(id: string): Promise<void>;
61
- /**
62
- * Save workflow (create or update).
63
- *
64
- * A workflow is considered existing when it already has an id (any format —
65
- * integer, UUID, slug). Only a missing/empty id means "truly new".
66
- *
67
- * Note: globalSave.ts bypasses this method and calls createWorkflow /
68
- * updateWorkflow directly so it can capture the new/existing decision before
69
- * the uuidv4() fallback. This method is kept for external callers.
70
- */
71
- saveWorkflow(workflow: Workflow): Promise<Workflow>;
72
- };
73
- /**
74
- * Export the API service
75
- */
76
- export declare const api: {
77
- nodes: {
78
- /**
79
- * Get all node types with optional filtering
80
- */
81
- getNodes(options?: {
82
- category?: string;
83
- search?: string;
84
- limit?: number;
85
- offset?: number;
86
- }): Promise<NodeMetadata[]>;
87
- /**
88
- * Get a specific node type by ID
89
- */
90
- getNode(id: string): Promise<NodeMetadata>;
91
- };
92
- workflows: {
93
- /**
94
- * Get all workflows with optional filtering
95
- */
96
- getWorkflows(options?: {
97
- search?: string;
98
- limit?: number;
99
- offset?: number;
100
- }): Promise<Workflow[]>;
101
- /**
102
- * Get a specific workflow by ID
103
- */
104
- getWorkflow(id: string): Promise<Workflow>;
105
- /**
106
- * Create a new workflow
107
- */
108
- createWorkflow(workflow: Omit<Workflow, "id">): Promise<Workflow>;
109
- /**
110
- * Update an existing workflow
111
- */
112
- updateWorkflow(id: string, workflow: Partial<Workflow>): Promise<Workflow>;
113
- /**
114
- * Delete a workflow
115
- */
116
- deleteWorkflow(id: string): Promise<void>;
117
- /**
118
- * Save workflow (create or update).
119
- *
120
- * A workflow is considered existing when it already has an id (any format —
121
- * integer, UUID, slug). Only a missing/empty id means "truly new".
122
- *
123
- * Note: globalSave.ts bypasses this method and calls createWorkflow /
124
- * updateWorkflow directly so it can capture the new/existing decision before
125
- * the uuidv4() fallback. This method is kept for external callers.
126
- */
127
- saveWorkflow(workflow: Workflow): Promise<Workflow>;
128
- };
129
- };