@flowdrop/flowdrop 1.15.0 → 2.0.0-beta.2
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/CHANGELOG.md +508 -0
- package/MIGRATION-2.0.md +629 -0
- package/README.md +23 -23
- package/dist/adapters/WorkflowAdapter.d.ts +1 -1
- package/dist/adapters/WorkflowAdapter.js +14 -8
- package/dist/adapters/agentspec/AgentSpecAdapter.js +7 -7
- package/dist/api/enhanced-client.js +6 -11
- package/dist/chat/batchFeedback.d.ts +39 -0
- package/dist/chat/batchFeedback.js +51 -0
- package/dist/commands/executor.js +15 -1
- package/dist/commands/storeIntegration.svelte.d.ts +4 -1
- package/dist/commands/storeIntegration.svelte.js +26 -21
- package/dist/commands/types.d.ts +2 -0
- package/dist/components/App.svelte +163 -192
- package/dist/components/App.svelte.d.ts +47 -8
- package/dist/components/ConfigForm.svelte +77 -49
- package/dist/components/ConfigModal.svelte +7 -2
- package/dist/components/ConnectionLine.svelte +4 -2
- package/dist/components/Navbar.svelte +61 -1
- package/dist/components/NodeSidebar.svelte +27 -45
- package/dist/components/NodeStatusOverlay.svelte +94 -6
- package/dist/components/NodeSwapPicker.svelte +10 -8
- package/dist/components/PipelineStatus.svelte +22 -68
- package/dist/components/PipelineStatus.svelte.d.ts +3 -0
- package/dist/components/PortCoordinateTracker.svelte +5 -6
- package/dist/components/SchemaForm.stories.svelte +1 -3
- package/dist/components/SchemaForm.svelte +22 -27
- package/dist/components/SchemaForm.svelte.d.ts +0 -8
- package/dist/components/SettingsModal.svelte +8 -3
- package/dist/components/SettingsPanel.svelte +20 -4
- package/dist/components/SwapMappingEditor.svelte +67 -49
- package/dist/components/SwapMappingEditor.svelte.d.ts +0 -2
- package/dist/components/UniversalNode.svelte +9 -7
- package/dist/components/WorkflowEditor.svelte +121 -111
- package/dist/components/WorkflowEditor.svelte.d.ts +21 -10
- package/dist/components/chat/AIChatPanel.svelte +98 -89
- package/dist/components/chat/AIChatPanel.svelte.d.ts +0 -4
- package/dist/components/chat/CommandPreview.svelte +2 -1
- package/dist/components/console/CommandConsole.svelte +7 -5
- package/dist/components/console/ConsoleAutocomplete.svelte +10 -11
- package/dist/components/console/ConsoleAutocomplete.svelte.d.ts +6 -0
- package/dist/components/console/ConsoleInput.svelte +15 -6
- package/dist/components/console/ConsoleOutput.svelte +2 -1
- package/dist/components/form/FormArray.svelte +5 -9
- package/dist/components/form/FormArray.svelte.d.ts +2 -1
- package/dist/components/form/FormAutocomplete.svelte +16 -15
- package/dist/components/form/FormField.svelte +4 -2
- package/dist/components/form/FormFieldLight.svelte +34 -3
- package/dist/components/form/FormFieldLight.svelte.d.ts +12 -0
- package/dist/components/form/FormMarkdownEditor.svelte +9 -4
- package/dist/components/form/FormRangeField.svelte +1 -0
- package/dist/components/form/FormTemplateEditor.svelte +11 -3
- package/dist/components/form/FormToggle.svelte +5 -12
- package/dist/components/form/FormToggle.svelte.d.ts +4 -2
- package/dist/components/form/FormUISchemaRenderer.svelte +3 -1
- package/dist/components/form/templateAutocomplete.js +1 -5
- package/dist/components/form/types.d.ts +1 -14
- package/dist/components/interrupt/FormPrompt.svelte +3 -2
- package/dist/components/interrupt/InterruptBubble.svelte +25 -17
- package/dist/components/interrupt/ReviewPrompt.svelte +10 -3
- package/dist/components/interrupt/TextInputPrompt.svelte +2 -1
- package/dist/components/layouts/MainLayout.svelte +20 -13
- package/dist/components/layouts/MainLayout.svelte.d.ts +4 -0
- package/dist/components/nodes/AtomNode.svelte +17 -5
- package/dist/components/nodes/GatewayNode.svelte +19 -10
- package/dist/components/nodes/IdeaNode.svelte +7 -0
- package/dist/components/nodes/SimpleNode.svelte +11 -6
- package/dist/components/nodes/SquareNode.svelte +15 -8
- package/dist/components/nodes/TerminalNode.svelte +9 -4
- package/dist/components/nodes/ToolNode.svelte +7 -1
- package/dist/components/nodes/WorkflowNode.svelte +16 -7
- package/dist/components/playground/ChatInput.svelte +11 -14
- package/dist/components/playground/ChatPanel.svelte +6 -49
- package/dist/components/playground/ChatPanel.svelte.d.ts +0 -14
- package/dist/components/playground/ControlPanel.svelte +134 -123
- package/dist/components/playground/ControlPanel.svelte.d.ts +3 -0
- package/dist/components/playground/ExecutionLogs.svelte +11 -9
- package/dist/components/playground/InputCollector.svelte +11 -9
- package/dist/components/playground/MessageStream.svelte +17 -23
- package/dist/components/playground/PipelineKanbanView.svelte +69 -8
- package/dist/components/playground/PipelineKanbanView.svelte.d.ts +2 -0
- package/dist/components/playground/PipelinePanel.svelte +31 -8
- package/dist/components/playground/PipelinePanel.svelte.d.ts +2 -0
- package/dist/components/playground/PipelineTableView.svelte +188 -44
- package/dist/components/playground/PipelineTableView.svelte.d.ts +2 -0
- package/dist/components/playground/Playground.svelte +154 -105
- package/dist/components/playground/Playground.svelte.d.ts +5 -0
- package/dist/components/playground/PlaygroundApp.svelte +11 -1
- package/dist/components/playground/PlaygroundApp.svelte.d.ts +6 -0
- package/dist/components/playground/PlaygroundModal.svelte +18 -3
- package/dist/components/playground/PlaygroundModal.svelte.d.ts +6 -0
- package/dist/components/playground/PlaygroundStudio.svelte +40 -32
- package/dist/components/playground/PlaygroundStudio.svelte.d.ts +6 -0
- package/dist/components/playground/SessionManager.svelte +9 -12
- package/dist/components/playground/pipelineViewUtils.svelte.d.ts +30 -1
- package/dist/components/playground/pipelineViewUtils.svelte.js +40 -3
- package/dist/config/endpoints.d.ts +23 -7
- package/dist/config/endpoints.js +30 -10
- package/dist/core/index.d.ts +5 -6
- package/dist/core/index.js +8 -12
- package/dist/display/index.d.ts +6 -3
- package/dist/display/index.js +7 -5
- package/dist/editor/index.d.ts +20 -21
- package/dist/editor/index.js +26 -36
- package/dist/form/code.d.ts +25 -15
- package/dist/form/code.js +44 -41
- package/dist/form/fieldRegistry.d.ts +17 -13
- package/dist/form/fieldRegistry.js +32 -12
- package/dist/form/full.d.ts +19 -14
- package/dist/form/full.js +26 -28
- package/dist/form/index.d.ts +3 -4
- package/dist/form/index.js +6 -5
- package/dist/form/markdown.d.ts +13 -8
- package/dist/form/markdown.js +22 -23
- package/dist/helpers/proximityConnect.d.ts +3 -2
- package/dist/helpers/proximityConnect.js +2 -5
- package/dist/helpers/workflowEditorHelper.d.ts +14 -5
- package/dist/helpers/workflowEditorHelper.js +28 -25
- package/dist/index.d.ts +28 -24
- package/dist/index.js +27 -50
- package/dist/messages/defaults.d.ts +2 -5
- package/dist/messages/defaults.js +3 -6
- package/dist/messages/index.d.ts +0 -1
- package/dist/messages/index.js +0 -1
- package/dist/mocks/app-forms.d.ts +6 -2
- package/dist/mocks/app-forms.js +11 -4
- package/dist/openapi/v1/openapi.yaml +3 -3
- package/dist/playground/index.d.ts +4 -5
- package/dist/playground/index.js +4 -32
- package/dist/playground/mount.d.ts +25 -0
- package/dist/playground/mount.js +50 -20
- package/dist/registry/{BaseRegistry.d.ts → BaseRegistry.svelte.d.ts} +22 -1
- package/dist/registry/{BaseRegistry.js → BaseRegistry.svelte.js} +37 -1
- package/dist/registry/builtinFormats.d.ts +9 -18
- package/dist/registry/builtinFormats.js +9 -39
- package/dist/registry/builtinNodeTypes.d.ts +53 -0
- package/dist/registry/builtinNodeTypes.js +67 -0
- package/dist/registry/builtinNodes.d.ts +2 -64
- package/dist/registry/builtinNodes.js +7 -103
- package/dist/registry/index.d.ts +3 -4
- package/dist/registry/index.js +4 -6
- package/dist/registry/nodeComponentRegistry.d.ts +182 -15
- package/dist/registry/nodeComponentRegistry.js +235 -17
- package/dist/registry/workflowFormatRegistry.d.ts +14 -9
- package/dist/registry/workflowFormatRegistry.js +24 -8
- package/dist/{schema → schemas}/index.d.ts +2 -2
- package/dist/{schema → schemas}/index.js +2 -2
- package/dist/schemas/v1/workflow.schema.json +3 -3
- package/dist/services/agentSpecExecutionService.d.ts +0 -2
- package/dist/services/agentSpecExecutionService.js +0 -3
- package/dist/services/apiVariableService.d.ts +2 -1
- package/dist/services/apiVariableService.js +16 -47
- package/dist/services/autoSaveService.d.ts +7 -0
- package/dist/services/autoSaveService.js +6 -4
- package/dist/services/categoriesApi.js +3 -6
- package/dist/services/chatService.d.ts +9 -4
- package/dist/services/chatService.js +23 -28
- package/dist/services/draftStorage.d.ts +129 -13
- package/dist/services/draftStorage.js +185 -37
- package/dist/services/dynamicSchemaService.d.ts +2 -1
- package/dist/services/dynamicSchemaService.js +5 -22
- package/dist/services/globalSave.d.ts +13 -12
- package/dist/services/globalSave.js +29 -51
- package/dist/services/historyService.d.ts +9 -3
- package/dist/services/historyService.js +9 -3
- package/dist/services/interruptService.d.ts +15 -9
- package/dist/services/interruptService.js +35 -37
- package/dist/services/nodeExecutionService.d.ts +18 -3
- package/dist/services/nodeExecutionService.js +71 -45
- package/dist/services/playgroundService.d.ts +16 -10
- package/dist/services/playgroundService.js +42 -43
- package/dist/services/portConfigApi.js +3 -6
- package/dist/services/settingsService.d.ts +9 -4
- package/dist/services/settingsService.js +23 -12
- package/dist/services/variableService.d.ts +2 -1
- package/dist/services/variableService.js +2 -2
- package/dist/services/workflowStorage.js +6 -6
- package/dist/stores/apiContext.d.ts +56 -0
- package/dist/stores/apiContext.js +80 -0
- package/dist/stores/categoriesStore.svelte.d.ts +28 -23
- package/dist/stores/categoriesStore.svelte.js +69 -64
- package/dist/stores/getInstance.svelte.d.ts +39 -0
- package/dist/stores/getInstance.svelte.js +65 -0
- package/dist/stores/historyStore.svelte.d.ts +77 -93
- package/dist/stores/historyStore.svelte.js +134 -160
- package/dist/stores/instanceContainer.svelte.d.ts +111 -0
- package/dist/stores/instanceContainer.svelte.js +114 -0
- package/dist/stores/interruptStore.svelte.d.ts +112 -82
- package/dist/stores/interruptStore.svelte.js +253 -226
- package/dist/stores/pipelinePanelStore.svelte.d.ts +27 -3
- package/dist/stores/pipelinePanelStore.svelte.js +61 -14
- package/dist/stores/playgroundStore.svelte.d.ts +169 -222
- package/dist/stores/playgroundStore.svelte.js +513 -580
- package/dist/stores/portCoordinateStore.svelte.d.ts +57 -51
- package/dist/stores/portCoordinateStore.svelte.js +109 -98
- package/dist/stores/settingsStore.svelte.d.ts +4 -1
- package/dist/stores/settingsStore.svelte.js +47 -12
- package/dist/stores/workflowStore.svelte.d.ts +178 -213
- package/dist/stores/workflowStore.svelte.js +449 -501
- package/dist/stories/EdgeDecorator.svelte +5 -2
- package/dist/stories/NodeDecorator.svelte +5 -3
- package/dist/svelte-app.d.ts +60 -10
- package/dist/svelte-app.js +159 -54
- package/dist/types/auth.d.ts +9 -51
- package/dist/types/auth.js +4 -54
- package/dist/types/events.d.ts +6 -3
- package/dist/types/index.d.ts +37 -5
- package/dist/types/index.js +0 -1
- package/dist/types/navbar.d.ts +7 -0
- package/dist/types/playground.d.ts +18 -3
- package/dist/types/settings.d.ts +13 -0
- package/dist/types/settings.js +1 -0
- package/dist/utils/colors.d.ts +47 -21
- package/dist/utils/colors.js +69 -68
- package/dist/utils/connections.d.ts +9 -15
- package/dist/utils/connections.js +13 -32
- package/dist/utils/duration.d.ts +13 -0
- package/dist/utils/duration.js +45 -0
- package/dist/utils/edgeStyling.js +9 -5
- package/dist/utils/fetchWithAuth.d.ts +36 -15
- package/dist/utils/fetchWithAuth.js +53 -23
- package/dist/utils/icons.d.ts +5 -2
- package/dist/utils/icons.js +6 -5
- package/dist/utils/nodeSwap.d.ts +6 -2
- package/dist/utils/nodeSwap.js +62 -126
- package/dist/utils/nodeTypes.d.ts +17 -8
- package/dist/utils/nodeTypes.js +27 -20
- package/dist/utils/performanceUtils.js +7 -0
- package/package.json +7 -5
- package/dist/messages/deprecation.d.ts +0 -20
- package/dist/messages/deprecation.js +0 -33
- package/dist/registry/plugin.d.ts +0 -215
- package/dist/registry/plugin.js +0 -249
- package/dist/services/api.d.ts +0 -129
- package/dist/services/api.js +0 -217
package/dist/registry/plugin.js
DELETED
|
@@ -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
|
-
}
|
package/dist/services/api.d.ts
DELETED
|
@@ -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
|
-
};
|
package/dist/services/api.js
DELETED
|
@@ -1,217 +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 { buildEndpointUrl, getEndpointMethod, getEndpointHeaders } from '../config/endpoints.js';
|
|
6
|
-
let endpointConfig = null;
|
|
7
|
-
/**
|
|
8
|
-
* Set the endpoint configuration at runtime
|
|
9
|
-
*/
|
|
10
|
-
export function setEndpointConfig(config) {
|
|
11
|
-
endpointConfig = config;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Get the current endpoint configuration
|
|
15
|
-
*/
|
|
16
|
-
export function getEndpointConfig() {
|
|
17
|
-
return endpointConfig;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Generic API request helper with endpoint configuration
|
|
21
|
-
*/
|
|
22
|
-
async function apiRequest(endpointKey, endpointPath, params, options = {}) {
|
|
23
|
-
if (!endpointConfig) {
|
|
24
|
-
throw new Error('Endpoint configuration not set. Call setEndpointConfig() first.');
|
|
25
|
-
}
|
|
26
|
-
const url = buildEndpointUrl(endpointConfig, endpointPath, params);
|
|
27
|
-
const method = getEndpointMethod(endpointConfig, endpointKey);
|
|
28
|
-
const headers = getEndpointHeaders(endpointConfig, endpointKey);
|
|
29
|
-
const response = await fetch(url, {
|
|
30
|
-
method,
|
|
31
|
-
headers,
|
|
32
|
-
...options
|
|
33
|
-
});
|
|
34
|
-
// Check if response is JSON
|
|
35
|
-
const contentType = response.headers.get('content-type');
|
|
36
|
-
const isJson = contentType?.includes('application/json');
|
|
37
|
-
if (!response.ok) {
|
|
38
|
-
// Try to get error details
|
|
39
|
-
let errorMessage = `HTTP ${response.status}: ${response.statusText}`;
|
|
40
|
-
if (isJson) {
|
|
41
|
-
try {
|
|
42
|
-
const data = await response.json();
|
|
43
|
-
errorMessage = data.error || data.message || errorMessage;
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
// Failed to parse JSON, use default error message
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
// Response is not JSON (probably HTML error page)
|
|
51
|
-
try {
|
|
52
|
-
const text = await response.text();
|
|
53
|
-
// Extract first 200 characters for debugging
|
|
54
|
-
const preview = text.substring(0, 200).trim();
|
|
55
|
-
errorMessage = `${errorMessage}. Server returned: ${preview}...`;
|
|
56
|
-
}
|
|
57
|
-
catch {
|
|
58
|
-
// Failed to read response text
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
throw new Error(errorMessage);
|
|
62
|
-
}
|
|
63
|
-
// Parse successful response
|
|
64
|
-
const data = await response.json();
|
|
65
|
-
return data;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Node API methods
|
|
69
|
-
*/
|
|
70
|
-
export const nodeApi = {
|
|
71
|
-
/**
|
|
72
|
-
* Get all node types with optional filtering
|
|
73
|
-
*/
|
|
74
|
-
async getNodes(options) {
|
|
75
|
-
if (!endpointConfig) {
|
|
76
|
-
throw new Error('Endpoint configuration not set');
|
|
77
|
-
}
|
|
78
|
-
const params = new URLSearchParams();
|
|
79
|
-
if (options?.category)
|
|
80
|
-
params.append('category', options.category);
|
|
81
|
-
if (options?.search)
|
|
82
|
-
params.append('search', options.search);
|
|
83
|
-
if (options?.limit)
|
|
84
|
-
params.append('limit', options.limit.toString());
|
|
85
|
-
if (options?.offset)
|
|
86
|
-
params.append('offset', options.offset.toString());
|
|
87
|
-
const response = await apiRequest('nodes.list', endpointConfig.endpoints.nodes.list + '?' + params.toString());
|
|
88
|
-
return response.data || [];
|
|
89
|
-
},
|
|
90
|
-
/**
|
|
91
|
-
* Get a specific node type by ID
|
|
92
|
-
*/
|
|
93
|
-
async getNode(id) {
|
|
94
|
-
if (!endpointConfig) {
|
|
95
|
-
throw new Error('Endpoint configuration not set');
|
|
96
|
-
}
|
|
97
|
-
const response = await apiRequest('nodes.get', endpointConfig.endpoints.nodes.get, { id });
|
|
98
|
-
if (!response.data) {
|
|
99
|
-
throw new Error('Node not found');
|
|
100
|
-
}
|
|
101
|
-
return response.data;
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* Workflow API methods
|
|
106
|
-
*/
|
|
107
|
-
export const workflowApi = {
|
|
108
|
-
/**
|
|
109
|
-
* Get all workflows with optional filtering
|
|
110
|
-
*/
|
|
111
|
-
async getWorkflows(options) {
|
|
112
|
-
if (!endpointConfig) {
|
|
113
|
-
throw new Error('Endpoint configuration not set');
|
|
114
|
-
}
|
|
115
|
-
const params = new URLSearchParams();
|
|
116
|
-
if (options?.search)
|
|
117
|
-
params.append('search', options.search);
|
|
118
|
-
if (options?.limit)
|
|
119
|
-
params.append('limit', options.limit.toString());
|
|
120
|
-
if (options?.offset)
|
|
121
|
-
params.append('offset', options.offset.toString());
|
|
122
|
-
const response = await apiRequest('workflows.list', endpointConfig.endpoints.workflows.list + '?' + params.toString());
|
|
123
|
-
return response.data || [];
|
|
124
|
-
},
|
|
125
|
-
/**
|
|
126
|
-
* Get a specific workflow by ID
|
|
127
|
-
*/
|
|
128
|
-
async getWorkflow(id) {
|
|
129
|
-
if (!endpointConfig) {
|
|
130
|
-
throw new Error('Endpoint configuration not set');
|
|
131
|
-
}
|
|
132
|
-
const response = await apiRequest('workflows.get', endpointConfig.endpoints.workflows.get, { id });
|
|
133
|
-
if (!response.data) {
|
|
134
|
-
throw new Error('Workflow not found');
|
|
135
|
-
}
|
|
136
|
-
return response.data;
|
|
137
|
-
},
|
|
138
|
-
/**
|
|
139
|
-
* Create a new workflow
|
|
140
|
-
*/
|
|
141
|
-
async createWorkflow(workflow) {
|
|
142
|
-
if (!endpointConfig) {
|
|
143
|
-
throw new Error('Endpoint configuration not set');
|
|
144
|
-
}
|
|
145
|
-
// Apply the consumer-provided payload transform (e.g. Drupal's label mapping).
|
|
146
|
-
// The default is the identity function — no CMS-specific logic in the core library.
|
|
147
|
-
const transform = endpointConfig.transformWorkflowPayload ?? ((w) => w);
|
|
148
|
-
const body = transform(workflow);
|
|
149
|
-
const response = await apiRequest('workflows.create', endpointConfig.endpoints.workflows.create, undefined, {
|
|
150
|
-
method: 'POST',
|
|
151
|
-
body: JSON.stringify(body)
|
|
152
|
-
});
|
|
153
|
-
if (!response.data) {
|
|
154
|
-
throw new Error('Failed to create workflow');
|
|
155
|
-
}
|
|
156
|
-
return response.data;
|
|
157
|
-
},
|
|
158
|
-
/**
|
|
159
|
-
* Update an existing workflow
|
|
160
|
-
*/
|
|
161
|
-
async updateWorkflow(id, workflow) {
|
|
162
|
-
if (!endpointConfig) {
|
|
163
|
-
throw new Error('Endpoint configuration not set');
|
|
164
|
-
}
|
|
165
|
-
// Apply the consumer-provided payload transform (e.g. Drupal's label mapping).
|
|
166
|
-
// The default is the identity function — no CMS-specific logic in the core library.
|
|
167
|
-
const transform = endpointConfig.transformWorkflowPayload ?? ((w) => w);
|
|
168
|
-
const body = transform(workflow);
|
|
169
|
-
const response = await apiRequest('workflows.update', endpointConfig.endpoints.workflows.update, { id }, {
|
|
170
|
-
method: 'PUT',
|
|
171
|
-
body: JSON.stringify(body)
|
|
172
|
-
});
|
|
173
|
-
if (!response.data) {
|
|
174
|
-
throw new Error('Failed to update workflow');
|
|
175
|
-
}
|
|
176
|
-
return response.data;
|
|
177
|
-
},
|
|
178
|
-
/**
|
|
179
|
-
* Delete a workflow
|
|
180
|
-
*/
|
|
181
|
-
async deleteWorkflow(id) {
|
|
182
|
-
if (!endpointConfig) {
|
|
183
|
-
throw new Error('Endpoint configuration not set');
|
|
184
|
-
}
|
|
185
|
-
await apiRequest('workflows.delete', endpointConfig.endpoints.workflows.delete, { id }, { method: 'DELETE' });
|
|
186
|
-
},
|
|
187
|
-
/**
|
|
188
|
-
* Save workflow (create or update).
|
|
189
|
-
*
|
|
190
|
-
* A workflow is considered existing when it already has an id (any format —
|
|
191
|
-
* integer, UUID, slug). Only a missing/empty id means "truly new".
|
|
192
|
-
*
|
|
193
|
-
* Note: globalSave.ts bypasses this method and calls createWorkflow /
|
|
194
|
-
* updateWorkflow directly so it can capture the new/existing decision before
|
|
195
|
-
* the uuidv4() fallback. This method is kept for external callers.
|
|
196
|
-
*/
|
|
197
|
-
async saveWorkflow(workflow) {
|
|
198
|
-
const isExistingWorkflow = !!(workflow.id && workflow.id.length > 0);
|
|
199
|
-
if (isExistingWorkflow) {
|
|
200
|
-
// Update existing workflow
|
|
201
|
-
return this.updateWorkflow(workflow.id, workflow);
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
// Create new workflow
|
|
205
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
206
|
-
const { id, ...workflowData } = workflow;
|
|
207
|
-
return this.createWorkflow(workflowData);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
/**
|
|
212
|
-
* Export the API service
|
|
213
|
-
*/
|
|
214
|
-
export const api = {
|
|
215
|
-
nodes: nodeApi,
|
|
216
|
-
workflows: workflowApi
|
|
217
|
-
};
|