@d34dman/flowdrop 0.0.17 → 0.0.19

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 +34 -47
  2. package/dist/api/enhanced-client.d.ts +2 -2
  3. package/dist/api/enhanced-client.js +5 -5
  4. package/dist/components/NotesNode.svelte +3 -3
  5. package/dist/components/NotesNode.svelte.d.ts +3 -3
  6. package/dist/components/SimpleNode.svelte +3 -3
  7. package/dist/components/SimpleNode.svelte.d.ts +3 -3
  8. package/dist/components/SquareNode.svelte +3 -3
  9. package/dist/components/SquareNode.svelte.d.ts +3 -3
  10. package/dist/components/TerminalNode.svelte +583 -0
  11. package/dist/components/TerminalNode.svelte.d.ts +24 -0
  12. package/dist/components/UniversalNode.svelte +7 -33
  13. package/dist/components/WorkflowEditor.svelte +1 -9
  14. package/dist/helpers/workflowEditorHelper.d.ts +3 -3
  15. package/dist/helpers/workflowEditorHelper.js +5 -7
  16. package/dist/index.d.ts +4 -7
  17. package/dist/index.js +2 -5
  18. package/dist/registry/builtinNodes.d.ts +3 -3
  19. package/dist/registry/builtinNodes.js +16 -3
  20. package/dist/services/api.d.ts +0 -5
  21. package/dist/services/api.js +0 -20
  22. package/dist/svelte-app.d.ts +0 -6
  23. package/dist/svelte-app.js +0 -8
  24. package/dist/types/auth.d.ts +0 -15
  25. package/dist/types/auth.js +0 -15
  26. package/dist/types/config.d.ts +11 -151
  27. package/dist/types/config.js +3 -0
  28. package/dist/types/index.d.ts +2 -8
  29. package/dist/utils/colors.d.ts +0 -5
  30. package/dist/utils/colors.js +3 -4
  31. package/dist/utils/config.d.ts +0 -8
  32. package/dist/utils/config.js +0 -14
  33. package/dist/utils/connections.d.ts +0 -5
  34. package/dist/utils/connections.js +10 -16
  35. package/dist/utils/icons.js +1 -1
  36. package/dist/utils/nodeTypes.d.ts +1 -1
  37. package/dist/utils/nodeTypes.js +4 -19
  38. package/package.json +144 -138
  39. package/dist/clients/ApiClient.d.ts +0 -199
  40. package/dist/clients/ApiClient.js +0 -214
  41. package/dist/config/apiConfig.d.ts +0 -34
  42. package/dist/config/apiConfig.js +0 -40
  43. package/dist/examples/adapter-usage.d.ts +0 -66
  44. package/dist/examples/adapter-usage.js +0 -133
  45. package/dist/examples/api-client-usage.d.ts +0 -32
  46. package/dist/examples/api-client-usage.js +0 -243
@@ -1,214 +0,0 @@
1
- /**
2
- * FlowDrop API Client
3
- * Type-safe client for the FlowDrop API
4
- */
5
- /**
6
- * FlowDrop API Client Class
7
- */
8
- export class ApiClient {
9
- config;
10
- defaultHeaders;
11
- constructor(config) {
12
- this.config = {
13
- timeout: 30000,
14
- ...config
15
- };
16
- this.defaultHeaders = {
17
- 'Content-Type': 'application/json',
18
- ...config.headers
19
- };
20
- if (config.apiKey) {
21
- this.defaultHeaders.Authorization = `Bearer ${config.apiKey}`;
22
- }
23
- }
24
- /**
25
- * Make an HTTP request
26
- */
27
- async request(method, path, data, options = {}) {
28
- const url = `${this.config.baseUrl}${path}`;
29
- const headers = { ...this.defaultHeaders, ...options.headers };
30
- const timeout = options.timeout || this.config.timeout;
31
- const controller = new AbortController();
32
- const timeoutId = setTimeout(() => controller.abort(), timeout);
33
- try {
34
- const response = await fetch(url, {
35
- method,
36
- headers,
37
- body: data ? JSON.stringify(data) : undefined,
38
- signal: controller.signal
39
- });
40
- clearTimeout(timeoutId);
41
- if (!response.ok) {
42
- const errorData = await response.json().catch(() => ({}));
43
- throw new ApiError(response.status, errorData.error || `HTTP ${response.status}`, errorData.code, errorData.details);
44
- }
45
- return await response.json();
46
- }
47
- catch (error) {
48
- clearTimeout(timeoutId);
49
- if (error instanceof ApiError) {
50
- throw error;
51
- }
52
- if (error instanceof Error && error.name === 'AbortError') {
53
- throw new ApiError(408, 'Request timeout', 'TIMEOUT');
54
- }
55
- throw new ApiError(500, error instanceof Error ? error.message : 'Network error', 'NETWORK_ERROR');
56
- }
57
- }
58
- // ===== HEALTH CHECK =====
59
- /**
60
- * Check API health
61
- */
62
- async healthCheck() {
63
- return this.request('GET', '/health');
64
- }
65
- // ===== NODE TYPES =====
66
- /**
67
- * Get all node types
68
- */
69
- async getNodeTypes(query) {
70
- const params = new URLSearchParams();
71
- if (query?.category)
72
- params.append('category', query.category);
73
- if (query?.search)
74
- params.append('search', query.search);
75
- if (query?.limit)
76
- params.append('limit', query.limit.toString());
77
- if (query?.offset)
78
- params.append('offset', query.offset.toString());
79
- const path = `/nodes${params.toString() ? `?${params.toString()}` : ''}`;
80
- return this.request('GET', path);
81
- }
82
- /**
83
- * Get node type by ID
84
- */
85
- async getNodeType(id) {
86
- return this.request('GET', `/nodes/${id}`);
87
- }
88
- // ===== WORKFLOWS =====
89
- /**
90
- * Get all workflows
91
- */
92
- async getWorkflows(query) {
93
- const params = new URLSearchParams();
94
- if (query?.search)
95
- params.append('search', query.search);
96
- if (query?.tags)
97
- params.append('tags', query.tags);
98
- if (query?.limit)
99
- params.append('limit', query.limit.toString());
100
- if (query?.offset)
101
- params.append('offset', query.offset.toString());
102
- if (query?.sort)
103
- params.append('sort', query.sort);
104
- if (query?.order)
105
- params.append('order', query.order);
106
- const path = `/workflows${params.toString() ? `?${params.toString()}` : ''}`;
107
- return this.request('GET', path);
108
- }
109
- /**
110
- * Get workflow by ID
111
- */
112
- async getWorkflow(id) {
113
- return this.request('GET', `/workflows/${id}`);
114
- }
115
- /**
116
- * Create a new workflow
117
- */
118
- async createWorkflow(data) {
119
- return this.request('POST', '/workflows', data);
120
- }
121
- /**
122
- * Update workflow
123
- */
124
- async updateWorkflow(id, data) {
125
- return this.request('PUT', `/workflows/${id}`, data);
126
- }
127
- /**
128
- * Delete workflow
129
- */
130
- async deleteWorkflow(id) {
131
- return this.request('DELETE', `/workflows/${id}`);
132
- }
133
- // ===== WORKFLOW EXECUTION =====
134
- /**
135
- * Execute workflow
136
- */
137
- async executeWorkflow(id, data) {
138
- return this.request('POST', `/workflows/${id}/execute`, data);
139
- }
140
- /**
141
- * Get execution status
142
- */
143
- async getExecutionStatus(id) {
144
- return this.request('GET', `/executions/${id}`);
145
- }
146
- /**
147
- * Cancel execution
148
- */
149
- async cancelExecution(id) {
150
- return this.request('POST', `/executions/${id}/cancel`);
151
- }
152
- // ===== IMPORT/EXPORT =====
153
- /**
154
- * Export workflow
155
- */
156
- async exportWorkflow(id, format = 'json') {
157
- return this.request('GET', `/workflows/${id}/export?format=${format}`);
158
- }
159
- /**
160
- * Import workflow
161
- */
162
- async importWorkflow(workflow) {
163
- return this.request('POST', '/workflows/import', workflow);
164
- }
165
- // ===== VALIDATION =====
166
- /**
167
- * Validate workflow
168
- */
169
- async validateWorkflow(workflow) {
170
- return this.request('POST', '/workflows/validate', workflow);
171
- }
172
- // ===== UTILITY METHODS =====
173
- /**
174
- * Wait for execution completion
175
- */
176
- async waitForExecution(id, pollInterval = 1000) {
177
- while (true) {
178
- const status = await this.getExecutionStatus(id);
179
- if (status.data?.status === 'completed' ||
180
- status.data?.status === 'failed' ||
181
- status.data?.status === 'cancelled') {
182
- return status;
183
- }
184
- await new Promise((resolve) => setTimeout(resolve, pollInterval));
185
- }
186
- }
187
- /**
188
- * Get workflows by tag
189
- */
190
- async getWorkflowsByTag(tag, query) {
191
- return this.getWorkflows({ ...query, tags: tag });
192
- }
193
- /**
194
- * Get node types by category
195
- */
196
- async getNodeTypesByCategory(category, query) {
197
- return this.getNodeTypes({ ...query, category });
198
- }
199
- }
200
- /**
201
- * API Error Class
202
- */
203
- export class ApiError extends Error {
204
- status;
205
- code;
206
- details;
207
- constructor(status, message, code, details) {
208
- super(message);
209
- this.status = status;
210
- this.code = code;
211
- this.details = details;
212
- this.name = 'ApiError';
213
- }
214
- }
@@ -1,34 +0,0 @@
1
- /**
2
- * API Configuration
3
- * Centralized configuration for all API endpoints
4
- */
5
- export interface ApiConfig {
6
- baseUrl: string;
7
- endpoints: {
8
- workflows: {
9
- list: string;
10
- get: string;
11
- create: string;
12
- update: string;
13
- delete: string;
14
- execute: string;
15
- executionState: string;
16
- };
17
- executions: {
18
- active: string;
19
- };
20
- nodes: {
21
- list: string;
22
- };
23
- };
24
- }
25
- /**
26
- * Default API configuration
27
- * For library usage, configuration should be provided at runtime
28
- * This provides sensible defaults that can be overridden
29
- */
30
- export declare const defaultApiConfig: ApiConfig;
31
- /**
32
- * Get full URL for an endpoint
33
- */
34
- export declare function getEndpointUrl(config: ApiConfig, endpoint: string, params?: Record<string, string>): string;
@@ -1,40 +0,0 @@
1
- /**
2
- * API Configuration
3
- * Centralized configuration for all API endpoints
4
- */
5
- /**
6
- * Default API configuration
7
- * For library usage, configuration should be provided at runtime
8
- * This provides sensible defaults that can be overridden
9
- */
10
- export const defaultApiConfig = {
11
- baseUrl: '/api/flowdrop',
12
- endpoints: {
13
- workflows: {
14
- list: '/workflows',
15
- get: '/workflows/{id}',
16
- create: '/workflows',
17
- update: '/workflows/{id}',
18
- delete: '/workflows/{id}',
19
- execute: '/workflows/{id}/execute',
20
- executionState: '/workflows/{id}/executions/{execution_id}/state'
21
- },
22
- executions: {
23
- active: '/executions/active'
24
- },
25
- nodes: {
26
- list: '/nodes'
27
- }
28
- }
29
- };
30
- /**
31
- * Get full URL for an endpoint
32
- */
33
- export function getEndpointUrl(config, endpoint, params = {}) {
34
- let url = config.baseUrl + endpoint;
35
- // Replace path parameters
36
- for (const [key, value] of Object.entries(params)) {
37
- url = url.replace(`{${key}}`, value);
38
- }
39
- return url;
40
- }
@@ -1,66 +0,0 @@
1
- /**
2
- * Example: Using WorkflowAdapter for workflow management
3
- * This demonstrates how systems can work with workflows without knowing SvelteFlow internals
4
- */
5
- import { type StandardWorkflow } from '../adapters/WorkflowAdapter.js';
6
- declare function createSimpleWorkflow(): StandardWorkflow;
7
- declare function analyzeWorkflow(workflow: StandardWorkflow): {
8
- stats: {
9
- totalNodes: number;
10
- totalEdges: number;
11
- nodeTypeCounts: {
12
- [k: string]: number;
13
- };
14
- lastModified: string;
15
- };
16
- validation: import("../index.js").WorkflowValidationResult;
17
- complexity: number;
18
- };
19
- declare function calculateComplexity(workflow: StandardWorkflow): number;
20
- declare function optimizeWorkflow(workflow: StandardWorkflow): StandardWorkflow;
21
- declare function exportWorkflow(workflow: StandardWorkflow): string;
22
- declare function importWorkflow(json: string): StandardWorkflow;
23
- declare function getWorkflowStructure(workflow: StandardWorkflow): {
24
- nodes: {
25
- id: string;
26
- type: string;
27
- position: {
28
- x: number;
29
- y: number;
30
- };
31
- config: Record<string, unknown>;
32
- }[];
33
- edges: {
34
- source: string;
35
- target: string;
36
- sourceHandle: string;
37
- targetHandle: string;
38
- }[];
39
- metadata: {
40
- name: string;
41
- description: string;
42
- version: string;
43
- lastModified: string;
44
- };
45
- };
46
- declare function getAvailableNodeTypes(): {
47
- id: string;
48
- name: string;
49
- category: import("../index.js").NodeCategory;
50
- description: string;
51
- inputs: {
52
- name: string;
53
- type: string;
54
- required: boolean;
55
- }[];
56
- outputs: {
57
- name: string;
58
- type: string;
59
- }[];
60
- }[];
61
- declare function validateGeneratedWorkflow(workflowJson: string): {
62
- valid: boolean;
63
- errors: string[];
64
- suggestions: string[];
65
- };
66
- export { createSimpleWorkflow, analyzeWorkflow, calculateComplexity, optimizeWorkflow, exportWorkflow, importWorkflow, getWorkflowStructure, getAvailableNodeTypes, validateGeneratedWorkflow };
@@ -1,133 +0,0 @@
1
- /**
2
- * Example: Using WorkflowAdapter for workflow management
3
- * This demonstrates how systems can work with workflows without knowing SvelteFlow internals
4
- */
5
- import { WorkflowAdapter } from '../adapters/WorkflowAdapter.js';
6
- import { sampleNodes } from '../data/samples.js';
7
- // Initialize the adapter with available node types
8
- const adapter = new WorkflowAdapter(sampleNodes);
9
- // Example 1: Create a simple workflow programmatically
10
- function createSimpleWorkflow() {
11
- const workflow = adapter.createWorkflow('Chat Workflow', 'A simple chat workflow');
12
- // Add nodes
13
- const inputNode = adapter.addNode(workflow, 'text-input', { x: 100, y: 100 }, {
14
- placeholder: 'Enter your message'
15
- });
16
- const modelNode = adapter.addNode(workflow, 'openai', { x: 300, y: 100 }, {
17
- model: 'gpt-4o-mini',
18
- temperature: 0.7
19
- });
20
- const outputNode = adapter.addNode(workflow, 'text-output', { x: 500, y: 100 });
21
- // Connect nodes
22
- adapter.addEdge(workflow, inputNode.id, modelNode.id, 'text', 'prompt');
23
- adapter.addEdge(workflow, modelNode.id, outputNode.id, 'text', 'text');
24
- return workflow;
25
- }
26
- // Example 2: Analyze a workflow structure
27
- function analyzeWorkflow(workflow) {
28
- const stats = adapter.getWorkflowStats(workflow);
29
- const validation = adapter.validateWorkflow(workflow);
30
- if (validation.errors.length > 0) {
31
- console.log('Errors:', validation.errors);
32
- }
33
- if (validation.warnings.length > 0) {
34
- console.log('Warnings:', validation.warnings);
35
- }
36
- return {
37
- stats,
38
- validation,
39
- complexity: calculateComplexity(workflow)
40
- };
41
- }
42
- // Example 3: Calculate workflow complexity
43
- function calculateComplexity(workflow) {
44
- const nodeCount = workflow.nodes.length;
45
- const edgeCount = workflow.edges.length;
46
- const avgConnections = edgeCount / Math.max(nodeCount, 1);
47
- // Simple complexity score
48
- return nodeCount * avgConnections;
49
- }
50
- // Example 4: Optimize a workflow
51
- function optimizeWorkflow(workflow) {
52
- const optimized = adapter.cloneWorkflow(workflow, `${workflow.name} (Optimized)`);
53
- // Could make optimizations here
54
- // For example, removing unused nodes, optimizing connections, etc.
55
- return optimized;
56
- }
57
- // Example 5: Export/Import workflows
58
- function exportWorkflow(workflow) {
59
- return adapter.exportWorkflow(workflow);
60
- }
61
- function importWorkflow(json) {
62
- return adapter.importWorkflow(json);
63
- }
64
- // Example 6: Get workflow structure for analysis
65
- function getWorkflowStructure(workflow) {
66
- return {
67
- nodes: workflow.nodes.map((node) => ({
68
- id: node.id,
69
- type: node.type,
70
- position: node.position,
71
- config: node.data.config
72
- })),
73
- edges: workflow.edges.map((edge) => ({
74
- source: edge.source,
75
- target: edge.target,
76
- sourceHandle: edge.sourceHandle,
77
- targetHandle: edge.targetHandle
78
- })),
79
- metadata: {
80
- name: workflow.name,
81
- description: workflow.description,
82
- version: workflow.metadata?.version,
83
- lastModified: workflow.metadata?.updatedAt
84
- }
85
- };
86
- }
87
- // Example 7: Get available node types
88
- function getAvailableNodeTypes() {
89
- return sampleNodes.map((node) => ({
90
- id: node.id,
91
- name: node.name,
92
- category: node.category,
93
- description: node.description,
94
- inputs: node.inputs.map((input) => ({
95
- name: input.name,
96
- type: input.dataType,
97
- required: input.required
98
- })),
99
- outputs: node.outputs.map((output) => ({
100
- name: output.name,
101
- type: output.dataType
102
- }))
103
- }));
104
- }
105
- // Example 8: Validate generated workflow
106
- function validateGeneratedWorkflow(workflowJson) {
107
- try {
108
- const workflow = adapter.importWorkflow(workflowJson);
109
- const validation = adapter.validateWorkflow(workflow);
110
- const suggestions = [];
111
- // Provide suggestions based on validation results
112
- if (workflow.nodes.length === 0) {
113
- suggestions.push('Consider adding input and output nodes');
114
- }
115
- if (workflow.edges.length === 0) {
116
- suggestions.push('Connect nodes to create a data flow');
117
- }
118
- return {
119
- valid: validation.valid,
120
- errors: validation.errors,
121
- suggestions
122
- };
123
- }
124
- catch (error) {
125
- return {
126
- valid: false,
127
- errors: [error instanceof Error ? error.message : 'Unknown error'],
128
- suggestions: ['Check the JSON format and required fields']
129
- };
130
- }
131
- }
132
- // Export all examples for use
133
- export { createSimpleWorkflow, analyzeWorkflow, calculateComplexity, optimizeWorkflow, exportWorkflow, importWorkflow, getWorkflowStructure, getAvailableNodeTypes, validateGeneratedWorkflow };
@@ -1,32 +0,0 @@
1
- /**
2
- * Example: Using FlowDrop API Client
3
- * Demonstrates how to integrate with FlowDrop API from applications
4
- * This client can be used with any backend that implements the FlowDrop API specification
5
- */
6
- import type { Workflow } from '../types/index.js';
7
- declare function checkApiHealth(): Promise<{
8
- status: string;
9
- timestamp: string;
10
- version: string;
11
- }>;
12
- declare function getNodeTypes(): Promise<import("../index.js").NodesResponse>;
13
- declare function manageWorkflows(): Promise<import("../index.js").WorkflowResponse>;
14
- declare function executeWorkflow(workflowId: string): Promise<import("../index.js").ExecutionStatusResponse>;
15
- declare function importExportWorkflow(workflowId: string): Promise<import("../index.js").WorkflowResponse>;
16
- declare function validateWorkflow(workflow: Workflow): Promise<import("../index.js").ValidationResponse>;
17
- declare function handleApiErrors(): Promise<void>;
18
- declare function batchOperations(): Promise<PromiseSettledResult<{
19
- id: string;
20
- name: string;
21
- valid: boolean;
22
- errors: number;
23
- error?: undefined;
24
- } | {
25
- id: string;
26
- name: string;
27
- valid: boolean;
28
- error: string;
29
- errors?: undefined;
30
- }>[]>;
31
- declare function monitorExecutions(workflowId: string): Promise<void>;
32
- export { checkApiHealth, getNodeTypes, manageWorkflows, executeWorkflow, importExportWorkflow, validateWorkflow, handleApiErrors, batchOperations, monitorExecutions };