@d34dman/flowdrop 0.0.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 (46) hide show
  1. package/README.md +293 -0
  2. package/dist/adapters/WorkflowAdapter.d.ts +166 -0
  3. package/dist/adapters/WorkflowAdapter.js +337 -0
  4. package/dist/api/client.d.ts +79 -0
  5. package/dist/api/client.js +208 -0
  6. package/dist/app.css +0 -0
  7. package/dist/clients/ApiClient.d.ts +203 -0
  8. package/dist/clients/ApiClient.js +212 -0
  9. package/dist/components/App.svelte +237 -0
  10. package/dist/components/App.svelte.d.ts +3 -0
  11. package/dist/components/CanvasBanner.svelte +51 -0
  12. package/dist/components/CanvasBanner.svelte.d.ts +22 -0
  13. package/dist/components/LoadingSpinner.svelte +36 -0
  14. package/dist/components/LoadingSpinner.svelte.d.ts +8 -0
  15. package/dist/components/Node.svelte +38 -0
  16. package/dist/components/Node.svelte.d.ts +4 -0
  17. package/dist/components/NodeSidebar.svelte +500 -0
  18. package/dist/components/NodeSidebar.svelte.d.ts +9 -0
  19. package/dist/components/WorkflowEditor.svelte +542 -0
  20. package/dist/components/WorkflowEditor.svelte.d.ts +10 -0
  21. package/dist/components/WorkflowNode.svelte +558 -0
  22. package/dist/components/WorkflowNode.svelte.d.ts +11 -0
  23. package/dist/data/samples.d.ts +17 -0
  24. package/dist/data/samples.js +1193 -0
  25. package/dist/examples/adapter-usage.d.ts +66 -0
  26. package/dist/examples/adapter-usage.js +138 -0
  27. package/dist/examples/api-client-usage.d.ts +31 -0
  28. package/dist/examples/api-client-usage.js +241 -0
  29. package/dist/index.d.ts +19 -0
  30. package/dist/index.js +27 -0
  31. package/dist/services/api.d.ts +110 -0
  32. package/dist/services/api.js +149 -0
  33. package/dist/services/workflowStorage.d.ts +37 -0
  34. package/dist/services/workflowStorage.js +116 -0
  35. package/dist/styles/base.css +858 -0
  36. package/dist/svelte-app.d.ts +17 -0
  37. package/dist/svelte-app.js +30 -0
  38. package/dist/types/index.d.ts +179 -0
  39. package/dist/types/index.js +4 -0
  40. package/dist/utils/colors.d.ts +121 -0
  41. package/dist/utils/colors.js +240 -0
  42. package/dist/utils/connections.d.ts +47 -0
  43. package/dist/utils/connections.js +240 -0
  44. package/dist/utils/icons.d.ts +102 -0
  45. package/dist/utils/icons.js +149 -0
  46. package/package.json +99 -0
package/README.md ADDED
@@ -0,0 +1,293 @@
1
+ # FlowDrop
2
+
3
+ A powerful Svelte Flow-based library for building workflows with a drag-and-drop interface. Inspired by tools like n8n, Langflow, and Flowise.
4
+
5
+ ## Features
6
+
7
+ - 🎯 **Node-based Workflow Editor** - Drag and drop interface for building workflows
8
+ - 🔌 **HTTP API Integration** - Fetch node definitions and manage workflows via REST API
9
+ - 🎨 **Modern UI** - Built with DaisyUI and Tailwind CSS for a beautiful, responsive interface
10
+ - 📱 **Responsive Design** - Works seamlessly on desktop and mobile devices
11
+ - 🔧 **TypeScript Support** - Full TypeScript support with comprehensive type definitions
12
+ - 🚀 **SvelteKit Ready** - Built for SvelteKit applications
13
+ - 📦 **Modular Architecture** - Easy to extend and customize
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install flowdrop
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ### 1. Basic Setup
24
+
25
+ ```svelte
26
+ <script lang="ts">
27
+ import { WorkflowEditor } from "flowdrop";
28
+ import type { FlowDropConfig } from "flowdrop";
29
+
30
+ const config: FlowDropConfig = {
31
+ apiBaseUrl: "https://your-api.com",
32
+ theme: "auto",
33
+ enableDebug: true
34
+ };
35
+ </script>
36
+
37
+ <WorkflowEditor {config} />
38
+ ```
39
+
40
+ ### 2. With Sample Data
41
+
42
+ ```svelte
43
+ <script lang="ts">
44
+ import { WorkflowEditor, sampleWorkflow } from "flowdrop";
45
+ import type { FlowDropConfig } from "flowdrop";
46
+
47
+ const config: FlowDropConfig = {
48
+ apiBaseUrl: "https://your-api.com",
49
+ theme: "auto"
50
+ };
51
+ </script>
52
+
53
+ <WorkflowEditor {config} workflow={sampleWorkflow} />
54
+ ```
55
+
56
+ ### 3. Custom API Client
57
+
58
+ ```svelte
59
+ <script lang="ts">
60
+ import { WorkflowEditor, FlowDropApiClient } from "flowdrop";
61
+ import type { FlowDropConfig } from "flowdrop";
62
+
63
+ const config: FlowDropConfig = {
64
+ apiBaseUrl: "https://your-api.com",
65
+ apiKey: "your-api-key"
66
+ };
67
+
68
+ const apiClient = new FlowDropApiClient(config.apiBaseUrl, config.apiKey);
69
+ </script>
70
+
71
+ <WorkflowEditor {config} />
72
+ ```
73
+
74
+ ## API Reference
75
+
76
+ ### Configuration
77
+
78
+ ```typescript
79
+ interface FlowDropConfig {
80
+ apiBaseUrl: string; // Your API endpoint
81
+ theme?: "light" | "dark" | "auto";
82
+ enableDebug?: boolean;
83
+ autoSave?: boolean;
84
+ autoSaveInterval?: number; // milliseconds
85
+ maxUndoSteps?: number;
86
+ nodeSpacing?: number;
87
+ gridSize?: number;
88
+ }
89
+ ```
90
+
91
+ ### Node Types
92
+
93
+ The library supports various node categories:
94
+
95
+ - **Models** - OpenAI, Anthropic, and other model providers
96
+ - **Input/Output** - Text input, file upload, display output
97
+ - **Processing** - Text transformation, data processing
98
+ - **Conditional** - Logic gates, conditional flows
99
+ - **Utility** - Helper functions, data manipulation
100
+ - **Integration** - External service connections
101
+
102
+ ### Node Metadata Structure
103
+
104
+ ```typescript
105
+ interface NodeMetadata {
106
+ id: string;
107
+ name: string;
108
+ description: string;
109
+ category: NodeCategory;
110
+ icon?: string;
111
+ color?: string;
112
+ inputs: NodePort[];
113
+ outputs: NodePort[];
114
+ configSchema?: Record<string, unknown>;
115
+ tags?: string[];
116
+ }
117
+ ```
118
+
119
+ ### API Endpoints
120
+
121
+ The library expects the following API endpoints:
122
+
123
+ - `GET /api/nodes` - Fetch available node types
124
+ - `GET /api/nodes?category={category}` - Fetch nodes by category
125
+ - `GET /api/nodes/{id}` - Fetch specific node metadata
126
+ - `POST /api/workflows` - Save workflow
127
+ - `PUT /api/workflows/{id}` - Update workflow
128
+ - `GET /api/workflows/{id}` - Load workflow
129
+ - `GET /api/workflows` - List workflows
130
+ - `DELETE /api/workflows/{id}` - Delete workflow
131
+ - `POST /api/workflows/{id}/execute` - Execute workflow
132
+ - `GET /api/executions/{id}` - Get execution status
133
+ - `POST /api/executions/{id}/cancel` - Cancel execution
134
+
135
+ ## Components
136
+
137
+ ### WorkflowEditor
138
+
139
+ The main component that provides the complete workflow editing experience.
140
+
141
+ ```svelte
142
+ <WorkflowEditor
143
+ config={config}
144
+ workflow={workflow}
145
+ apiKey="optional-api-key"
146
+ />
147
+ ```
148
+
149
+ ### NodeSidebar
150
+
151
+ A sidebar component that displays available nodes organized by category.
152
+
153
+ ```svelte
154
+ <NodeSidebar
155
+ nodes={availableNodes}
156
+ loading={false}
157
+ on:nodeSelected={handleNodeSelected}
158
+ on:categoryChanged={handleCategoryChanged}
159
+ on:searchChanged={handleSearchChanged}
160
+ />
161
+ ```
162
+
163
+ ### WorkflowNode
164
+
165
+ A customizable node component for displaying workflow nodes.
166
+
167
+ ```svelte
168
+ <WorkflowNode
169
+ data={nodeData}
170
+ selected={false}
171
+ on:configChanged={handleConfigChange}
172
+ on:nodeSelected={handleNodeSelect}
173
+ />
174
+ ```
175
+
176
+ ## Events
177
+
178
+ The library dispatches various events for integration:
179
+
180
+ ```typescript
181
+ // Node events
182
+ nodeSelected: { node: NodeMetadata }
183
+ nodeAdded: { node: WorkflowNode }
184
+ nodeRemoved: { nodeId: string }
185
+ nodeUpdated: { node: WorkflowNode }
186
+
187
+ // Edge events
188
+ edgeAdded: { edge: WorkflowEdge }
189
+ edgeRemoved: { edgeId: string }
190
+
191
+ // Workflow events
192
+ workflowSaved: { workflow: Workflow }
193
+ workflowLoaded: { workflow: Workflow }
194
+
195
+ // Execution events
196
+ executionStarted: { workflowId: string }
197
+ executionCompleted: { result: ExecutionResult }
198
+ executionFailed: { error: string }
199
+ ```
200
+
201
+ ## Customization
202
+
203
+ ### Custom Node Types
204
+
205
+ You can create custom node types by extending the base components:
206
+
207
+ ```svelte
208
+ <script lang="ts">
209
+ import WorkflowNode from "flowdrop/WorkflowNode.svelte";
210
+
211
+ // Custom node logic here
212
+ </script>
213
+
214
+ <div class="custom-node">
215
+ <!-- Your custom node UI -->
216
+ </div>
217
+ ```
218
+
219
+ ### Custom Styling
220
+
221
+ The library uses DaisyUI and Tailwind CSS. You can customize the appearance by:
222
+
223
+ 1. Overriding CSS variables
224
+ 2. Using DaisyUI themes
225
+ 3. Adding custom CSS classes
226
+
227
+ ```css
228
+ :root {
229
+ --primary: 220 14% 96%;
230
+ --primary-content: 220 9% 46%;
231
+ --secondary: 220 14% 96%;
232
+ --secondary-content: 220 9% 46%;
233
+ /* ... more variables */
234
+ }
235
+ ```
236
+
237
+ ## Development
238
+
239
+ ### Prerequisites
240
+
241
+ - Node.js 18+
242
+ - npm or yarn
243
+
244
+ ### Setup
245
+
246
+ ```bash
247
+ git clone https://github.com/your-repo/flowdrop.git
248
+ cd flowdrop
249
+ npm install
250
+ ```
251
+
252
+ ### Development Server
253
+
254
+ ```bash
255
+ npm run dev
256
+ ```
257
+
258
+ ### Build
259
+
260
+ ```bash
261
+ npm run build
262
+ ```
263
+
264
+ ### Testing
265
+
266
+ ```bash
267
+ npm run test
268
+ ```
269
+
270
+ ## Contributing
271
+
272
+ 1. Fork the repository
273
+ 2. Create a feature branch
274
+ 3. Make your changes
275
+ 4. Add tests if applicable
276
+ 5. Submit a pull request
277
+
278
+ ## License
279
+
280
+ MIT License - see [LICENSE](LICENSE) file for details.
281
+
282
+ ## Support
283
+
284
+ - 📚 [Documentation](https://flowdrop.dev)
285
+ - 🐛 [Issue Tracker](https://github.com/your-repo/flowdrop/issues)
286
+ - 💬 [Discussions](https://github.com/your-repo/flowdrop/discussions)
287
+
288
+ ## Acknowledgments
289
+
290
+ - [Svelte Flow](https://github.com/xyflow/xyflow) - The underlying flow library
291
+ - [DaisyUI](https://daisyui.com/) - Beautiful UI components
292
+ - [Tailwind CSS](https://tailwindcss.com/) - Utility-first CSS framework
293
+ - [SvelteKit](https://kit.svelte.dev/) - The web framework
@@ -0,0 +1,166 @@
1
+ /**
2
+ * WorkflowAdapter - Abstracts SvelteFlow internals for external systems
3
+ *
4
+ * This adapter provides a clean interface for working with workflows without
5
+ * needing to understand SvelteFlow's internal structure. It handles:
6
+ * - Converting between standard workflow format and SvelteFlow format
7
+ * - CRUD operations on workflows, nodes, and edges
8
+ * - Validation and error checking
9
+ * - Import/export functionality
10
+ *
11
+ * The adapter is designed to be used by:
12
+ * - Backend systems that need to process workflows
13
+ * - External applications that want to integrate with FlowDrop
14
+ * - Systems that need to generate or modify workflows programmatically
15
+ */
16
+ import type { Workflow, NodeMetadata } from "../types/index.js";
17
+ /**
18
+ * Standard workflow node interface (SvelteFlow-agnostic)
19
+ */
20
+ export interface StandardNode {
21
+ id: string;
22
+ type: string;
23
+ position: {
24
+ x: number;
25
+ y: number;
26
+ };
27
+ data: {
28
+ label: string;
29
+ config: Record<string, unknown>;
30
+ metadata: NodeMetadata;
31
+ };
32
+ }
33
+ /**
34
+ * Standard workflow edge interface (SvelteFlow-agnostic)
35
+ */
36
+ export interface StandardEdge {
37
+ id: string;
38
+ source: string;
39
+ target: string;
40
+ sourceHandle?: string;
41
+ targetHandle?: string;
42
+ }
43
+ /**
44
+ * Standard workflow interface (SvelteFlow-agnostic)
45
+ */
46
+ export interface StandardWorkflow {
47
+ id: string;
48
+ name: string;
49
+ description?: string;
50
+ nodes: StandardNode[];
51
+ edges: StandardEdge[];
52
+ metadata?: {
53
+ version: string;
54
+ createdAt: string;
55
+ updatedAt: string;
56
+ author?: string;
57
+ tags?: string[];
58
+ };
59
+ }
60
+ /**
61
+ * Workflow execution result
62
+ */
63
+ export interface WorkflowExecutionResult {
64
+ success: boolean;
65
+ data?: unknown;
66
+ error?: string;
67
+ executionTime?: number;
68
+ nodeResults?: Record<string, unknown>;
69
+ }
70
+ /**
71
+ * Workflow validation result
72
+ */
73
+ export interface WorkflowValidationResult {
74
+ valid: boolean;
75
+ errors: string[];
76
+ warnings: string[];
77
+ }
78
+ /**
79
+ * Workflow Adapter Class
80
+ * Provides a clean API for workflow operations without exposing SvelteFlow internals
81
+ */
82
+ export declare class WorkflowAdapter {
83
+ private nodeTypes;
84
+ constructor(nodeTypes?: NodeMetadata[]);
85
+ /**
86
+ * Create a new workflow
87
+ */
88
+ createWorkflow(name: string, description?: string): StandardWorkflow;
89
+ /**
90
+ * Add a node to a workflow
91
+ */
92
+ addNode(workflow: StandardWorkflow, nodeType: string, position: {
93
+ x: number;
94
+ y: number;
95
+ }, config?: Record<string, unknown>): StandardNode;
96
+ /**
97
+ * Remove a node from a workflow
98
+ */
99
+ removeNode(workflow: StandardWorkflow, nodeId: string): boolean;
100
+ /**
101
+ * Update node position
102
+ */
103
+ updateNodePosition(workflow: StandardWorkflow, nodeId: string, position: {
104
+ x: number;
105
+ y: number;
106
+ }): boolean;
107
+ /**
108
+ * Update node configuration
109
+ */
110
+ updateNodeConfig(workflow: StandardWorkflow, nodeId: string, config: Record<string, unknown>): boolean;
111
+ /**
112
+ * Add an edge between nodes
113
+ */
114
+ addEdge(workflow: StandardWorkflow, sourceNodeId: string, targetNodeId: string, sourceHandle?: string, targetHandle?: string): StandardEdge;
115
+ /**
116
+ * Remove an edge from a workflow
117
+ */
118
+ removeEdge(workflow: StandardWorkflow, edgeId: string): boolean;
119
+ /**
120
+ * Get all nodes of a specific type
121
+ */
122
+ getNodesByType(workflow: StandardWorkflow, nodeType: string): StandardNode[];
123
+ /**
124
+ * Get all edges connected to a node
125
+ */
126
+ getNodeEdges(workflow: StandardWorkflow, nodeId: string): StandardEdge[];
127
+ /**
128
+ * Get connected nodes (both incoming and outgoing)
129
+ */
130
+ getConnectedNodes(workflow: StandardWorkflow, nodeId: string): StandardNode[];
131
+ /**
132
+ * Validate workflow structure
133
+ */
134
+ validateWorkflow(workflow: StandardWorkflow): WorkflowValidationResult;
135
+ /**
136
+ * Export workflow to JSON
137
+ */
138
+ exportWorkflow(workflow: StandardWorkflow): string;
139
+ /**
140
+ * Import workflow from JSON
141
+ */
142
+ importWorkflow(json: string): StandardWorkflow;
143
+ /**
144
+ * Convert SvelteFlow workflow to standard format
145
+ */
146
+ fromSvelteFlow(svelteFlowWorkflow: Workflow): StandardWorkflow;
147
+ /**
148
+ * Convert standard workflow to SvelteFlow format
149
+ */
150
+ toSvelteFlow(workflow: StandardWorkflow): Workflow;
151
+ /**
152
+ * Get workflow statistics
153
+ */
154
+ getWorkflowStats(workflow: StandardWorkflow): {
155
+ totalNodes: number;
156
+ totalEdges: number;
157
+ nodeTypeCounts: {
158
+ [k: string]: number;
159
+ };
160
+ lastModified: string;
161
+ };
162
+ /**
163
+ * Clone a workflow
164
+ */
165
+ cloneWorkflow(workflow: StandardWorkflow, newName?: string): StandardWorkflow;
166
+ }