flowscale 1.0.11 → 1.0.13

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 (2) hide show
  1. package/README.md +313 -9
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,19 +1,323 @@
1
1
  # Flowscale Node.js SDK
2
2
 
3
- A Node.js SDK for interacting with the Flowscale platform without directly managing API requests. This library simplifies invoking workflows, retrieving outputs, and checking run statuses.
3
+ A comprehensive Node.js SDK designed to simplify interaction with the FlowScale ComfyUI API. This library abstracts away the complexities of API calls, enabling you to effortlessly invoke workflows, retrieve outputs, manage workflow runs, and monitor system health.
4
+
5
+ ---
4
6
 
5
7
  ## Installation
6
8
 
9
+ Install the Flowscale SDK by `npm`, `yarn`, `pnpm` or `bun`:
10
+
7
11
  ```bash
8
12
  npm install flowscale
9
13
 
14
+ yarn add flowscale
15
+
16
+ pnpm install flowscale
17
+
18
+ bun install flowscale
19
+ ```
20
+
21
+ ---
22
+
23
+ ## Quick Start
24
+
25
+ ### Importing the SDK
26
+
27
+ To get started, import the Flowscale SDK into your project:
28
+
29
+ ```javascript
30
+ import { FlowscaleAPI } from 'flowscale';
31
+
32
+ // Initialize the SDK
33
+ const apiKey = process.env.FLOWSCALE_API_KEY;
34
+ const apiUrl = process.env.FLOWSCALE_API_URL;
35
+
36
+ if (!apiKey || !apiUrl) {
37
+ console.error('FLOWSCALE_API_KEY or FLOWSCALE_API_URL not set in .env');
38
+ process.exit(1);
39
+ }
40
+
41
+ const flowscale = new FlowscaleAPI(apiKey, apiUrl);
42
+ ```
43
+
44
+ **Environment Variables:** Add the following to your `.env` file:
45
+
46
+ ```plaintext
47
+ FLOWSCALE_API_KEY=your-api-key
48
+ FLOWSCALE_API_URL=https://your-api-url.pod.flowscale.ai
49
+ ```
50
+
51
+ ---
52
+
53
+ ## SDK Methods
54
+
55
+ Below is a detailed guide to the SDK methods, including descriptions, usage, and response formats.
56
+
57
+ ### 1. `checkHealth()`
58
+
59
+ **Description:**
60
+ Check the health status of the Flowscale platform, including the status of containers and services.
61
+
62
+ **Usage:**
63
+ ```javascript
64
+ const health = await flowscale.checkHealth();
65
+ console.log('API Health:', health);
66
+ ```
67
+
68
+ **Response Example:**
69
+ ```json
70
+ {
71
+ "status": "success",
72
+ "data": [
73
+ {
74
+ "container": "container #1",
75
+ "status": "idle"
76
+ },
77
+ {
78
+ "container": "container #2",
79
+ "status": "running"
80
+ }
81
+ ]
82
+ }
83
+ ```
84
+
85
+ ---
86
+
87
+ ### 2. `getQueue()`
88
+
89
+ **Description:**
90
+ Retrieve the current status of the workflow queue, including running and pending jobs.
91
+
92
+ **Usage:**
93
+ ```javascript
94
+ const queue = await flowscale.getQueue();
95
+ console.log('Queue Details:', queue);
96
+ ```
97
+
98
+ **Response Example:**
99
+ ```json
100
+ {
101
+ "status": "success",
102
+ "data": [
103
+ {
104
+ "container": "container #1",
105
+ "queue": {
106
+ "queue_running": [
107
+ [
108
+ 0,
109
+ "2a0babc4-acce-4521-9576-00fa0e6ecc91"
110
+ ]
111
+ ],
112
+ "queue_pending": [
113
+ [
114
+ 1,
115
+ "5d60718a-7e89-4c64-b32d-0d1366b44e2a"
116
+ ]
117
+ ]
118
+ }
119
+ }
120
+ ]
121
+ }
122
+ ```
123
+
124
+ ---
125
+
126
+ ### 3. `executeWorkflow(workflowId, data, groupId?)`
127
+
128
+ **Description:**
129
+ Trigger a workflow execution using its unique `workflowId`. Input data and an optional `groupId` can be provided for better organization and tracking.
130
+
131
+ **Parameters:**
132
+ - `workflowId` *(string)*: The unique ID of the workflow.
133
+ - `data` *(object)*: Input parameters for the workflow.
134
+ - `groupId` *(string, optional)*: A custom identifier for grouping runs.
135
+
136
+ **Usage:**
137
+ ```javascript
138
+ const workflowId = "bncu0a1kipv";
139
+ const groupId = "test_group";
140
+
141
+ const inputs = {
142
+ "text_51536": "Prompt test",
143
+ "image_1234": { /* File or Blob of image */ },
144
+ "video_1239": { /* File or Blob of video */ }
145
+ };
146
+
147
+ const result = await flowscale.executeWorkflow(workflowId, inputs, groupId);
148
+ console.log('Workflow Result:', result);
149
+ ```
150
+
151
+ **Response Example:**
152
+ ```json
153
+ {
154
+ "status": "success",
155
+ "data": {
156
+ "number": 0,
157
+ "node_errors": {},
158
+ "output_names": [
159
+ "filename_prefix_58358_5WWF7GQUYF"
160
+ ],
161
+ "run_id": "808f34d0-ef97-4b78-a00f-1268077ea6db"
162
+ }
163
+ }
164
+ ```
165
+
166
+ ---
167
+
168
+ ### 4. `getOutput(filename)`
169
+
170
+ **Description:**
171
+ Fetch the output of a completed workflow using its `filename`. Outputs typically include downloadable files or results.
172
+
173
+ **Parameters:**
174
+ - `filename` *(string)*: The name of the output file.
175
+
176
+ **Usage:**
177
+ ```javascript
178
+ const output = await flowscale.getOutput('filename_prefix_58358_5WWF7GQUYF.png');
179
+ console.log('Workflow Output:', output);
180
+ ```
181
+
182
+ **Response Example:**
183
+ ```json
184
+ {
185
+ "status": "success",
186
+ "data": {
187
+ "download_url": "https://runs.s3.amazonaws.com/generations/...",
188
+ "generation_status": "success"
189
+ }
190
+ }
191
+ ```
192
+
193
+ ---
194
+
195
+ ### 5. `cancelRun(runId)`
196
+
197
+ **Description:**
198
+ Cancel a running workflow execution using its unique `runId`.
199
+
200
+ **Parameters:**
201
+ - `runId` *(string)*: The unique identifier of the running workflow.
202
+
203
+ **Usage:**
204
+ ```javascript
205
+ const result = await flowscale.cancelRun('808f34d0-ef97-4b78-a00f-1268077ea6db');
206
+ console.log('Cancellation Result:', result);
207
+ ```
208
+
209
+ **Response Example:**
210
+ ```json
211
+ {
212
+ "status": "success",
213
+ "data": "Run cancelled successfully"
214
+ }
215
+ ```
216
+
217
+ ---
218
+
219
+ ### 6. `getRun(runId)`
220
+
221
+ **Description:**
222
+ Retrieve detailed information about a specific workflow run.
223
+
224
+ **Parameters:**
225
+ - `runId` *(string)*: The unique identifier of the run.
226
+
227
+ **Usage:**
228
+ ```javascript
229
+ const runDetails = await flowscale.getRun('808f34d0-ef97-4b78-a00f-1268077ea6db');
230
+ console.log('Run Details:', runDetails);
231
+ ```
232
+
233
+ **Response Example:**
234
+ ```json
235
+ {
236
+ "status": "success",
237
+ "data": {
238
+ "_id": "808f34d0-ef97-4b78-a00f-1268077ea6db",
239
+ "status": "completed",
240
+ "inputs": [
241
+ {
242
+ "path": "text_51536",
243
+ "value": "a man riding a bike"
244
+ }
245
+ ],
246
+ "outputs": [
247
+ {
248
+ "filename": "filename_prefix_58358_5WWF7GQUYF.png",
249
+ "url": "https://runs.s3.amazonaws.com/generations/..."
250
+ }
251
+ ]
252
+ }
253
+ }
254
+ ```
255
+
256
+ ---
257
+
258
+ ### 7. `getRuns(groupId)`
259
+
260
+ **Description:**
261
+ Retrieve all workflow runs associated with a specific `groupId`. If no `groupId` is provided, all runs for the team are returned.
262
+
263
+ **Parameters:**
264
+ - `groupId` *(string, optional)*: The identifier for grouping runs.
265
+
266
+ **Usage:**
267
+ ```javascript
268
+ const runs = await flowscale.getRuns('test_group');
269
+ console.log('Runs for Group:', runs);
270
+
271
+ // Get all runs for the team
272
+ const allRuns = await flowscale.getRuns();
273
+ console.log('All Runs:', allRuns);
274
+ ```
275
+
276
+ **Response Example:**
277
+ ```json
278
+ {
279
+ "status": "success",
280
+ "data": {
281
+ "group_id": "test_group",
282
+ "count": 2,
283
+ "runs": [
284
+ {
285
+ "_id": "cc29a72d-75b9-4c7b-b991-ccaf2a04d6ea",
286
+ "status": "completed",
287
+ "outputs": [
288
+ {
289
+ "filename": "filename_prefix_58358_G3DRLIVVYP.png",
290
+ "url": "https://runs.s3.amazonaws.com/generations/..."
291
+ }
292
+ ]
293
+ }
294
+ ]
295
+ }
296
+ }
297
+ ```
298
+
299
+ ---
300
+
301
+ ## Best Practices
302
+
303
+ ### Environment Configuration
304
+ - Always store sensitive information such as API keys in environment variables.
305
+ - Use `.env` files and libraries like `dotenv` for easy environment management.
306
+
307
+ ### Error Handling
308
+ - Wrap API calls in try-catch blocks to handle errors gracefully.
309
+ - Log errors for debugging and improve resilience.
310
+
311
+ ### Testing and Debugging
312
+ - Test workflows in a development environment before deploying to production.
313
+ - Validate inputs to ensure they match the workflow requirements.
314
+
315
+ ---
316
+
317
+ ## Support
318
+
319
+ For any questions or assistance, join the Flowscale community on **Discord** or refer to the [Flowscale Documentation](https://docs.flowscale.ai/).
10
320
 
11
- ## Methods
321
+ ---
12
322
 
13
- - checkHealth(): Promise<HealthCheckResponse>
14
- - getQueue(): Promise<QueueResponse>
15
- - executeWorkflow(workflowId: string, data: WorkflowData, groupId?: string): Promise<ExecuteWorkflowResponse>
16
- - getOutput(filename: string): Promise<GetOutputResponse | null>
17
- - cancelRun(runId: string): Promise<CancelRunResponse>
18
- - getRun(runId: string): Promise<RunDetailResponse>
19
- - getRuns(groupId: string): Promise<RunListResponse>
323
+ Simplify your workflow management with the Flowscale Node.js SDK. Happy coding!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowscale",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "An NPM library for communicating with the Flowscale APIs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",