flowscale 1.3.4 → 2.0.0
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 +30 -29
- package/README.md +16 -34
- package/dist/index.d.ts +3 -4
- package/dist/index.js +62 -97
- package/dist/types.d.ts +1 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.0.0] - 2026-02-08
|
|
11
|
+
|
|
12
|
+
### 🚨 Breaking Changes
|
|
13
|
+
- `executeWorkflowAsync` now always returns `GetAllOutputsResponse` (array format).
|
|
14
|
+
- Removed legacy boolean 6th argument support in `executeWorkflowAsync`.
|
|
15
|
+
- Removed legacy response types: `LegacyGetOutputResponse` and `DeprecationWarning`.
|
|
16
|
+
|
|
17
|
+
### 🔄 Changed
|
|
18
|
+
- `ExecuteWorkflowAsyncOptions` now only supports `onIntermediateResponse`.
|
|
19
|
+
- README documentation updated for the v2 async execution API and migration guidance.
|
|
20
|
+
|
|
21
|
+
## [1.3.5] - 2026-02-08
|
|
22
|
+
|
|
10
23
|
### ✨ Added
|
|
11
24
|
- `executeWorkflowAsync` now supports an options object with `onIntermediateResponse` callback to emit intermediate polling updates.
|
|
12
25
|
- Added `subscribeRunEvents(runId, options)` to consume run events via SSE (`/api/v1/runs/{run_id}/events`).
|
|
@@ -14,6 +27,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
14
27
|
### 🔄 Changed
|
|
15
28
|
- `executeWorkflowAsync` still accepts the legacy boolean as the 6th parameter for backward compatibility.
|
|
16
29
|
- `GetOutputResponse` and `RunDetail` types now include optional progress-related fields returned by the API.
|
|
30
|
+
- `GetAllOutputsResponse` now supports both binary outputs (`download_url`) and text outputs (`file_content`).
|
|
31
|
+
|
|
32
|
+
### 🐛 Fixed
|
|
33
|
+
- `executeWorkflowAsync` now emits `run_status` updates continuously during polling (not only before output names are discovered).
|
|
34
|
+
- `getOutput` now handles HTTP `204` responses correctly as "not ready", avoiding `status: undefined` output warnings.
|
|
35
|
+
- `executeWorkflowAsync` now returns `file_content` outputs correctly instead of returning entries with `download_url: undefined`.
|
|
36
|
+
|
|
37
|
+
### 🗑️ Removed
|
|
17
38
|
- Removed WebSocket APIs from the JavaScript SDK (`connectWebSocket`, `disconnectWebSocket`, `sendWebSocketMessage`, `isWebSocketConnected`) and removed related examples.
|
|
18
39
|
|
|
19
40
|
## [1.1.0] - 2025-01-29
|
|
@@ -38,7 +59,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
38
59
|
- Enhanced error messages with better context
|
|
39
60
|
|
|
40
61
|
### 🗓️ Deprecated
|
|
41
|
-
- Legacy single output format in `executeWorkflowAsync` (removal:
|
|
62
|
+
- Legacy single output format in `executeWorkflowAsync` (planned removal: v2.0.0)
|
|
42
63
|
- Will be completely removed in v2.0.0
|
|
43
64
|
|
|
44
65
|
### 📚 Documentation
|
|
@@ -113,45 +134,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
113
134
|
|
|
114
135
|
## Migration Guides
|
|
115
136
|
|
|
116
|
-
### From 1.
|
|
137
|
+
### From 1.x to 2.0.0
|
|
117
138
|
|
|
118
|
-
|
|
139
|
+
`executeWorkflowAsync` no longer returns the legacy single-output object.
|
|
119
140
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
**Old code** (still works):
|
|
141
|
+
**Before (v1.x legacy usage):**
|
|
123
142
|
```javascript
|
|
124
143
|
const result = await flowscale.executeWorkflowAsync(workflowId, data);
|
|
125
|
-
console.log(result.data.download_url);
|
|
144
|
+
console.log(result.data.download_url);
|
|
126
145
|
```
|
|
127
146
|
|
|
128
|
-
**
|
|
147
|
+
**After (v2.0.0):**
|
|
129
148
|
```javascript
|
|
130
|
-
const result = await flowscale.executeWorkflowAsync(workflowId, data
|
|
149
|
+
const result = await flowscale.executeWorkflowAsync(workflowId, data);
|
|
131
150
|
result.data.forEach(output => {
|
|
132
|
-
console.log(output.download_url);
|
|
151
|
+
console.log(output.download_url || output.file_content);
|
|
133
152
|
});
|
|
134
153
|
```
|
|
135
154
|
|
|
136
|
-
|
|
137
|
-
```javascript
|
|
138
|
-
const result = await flowscale.executeWorkflowAsync(workflowId, data);
|
|
139
|
-
|
|
140
|
-
if (Array.isArray(result.data)) {
|
|
141
|
-
// New format - multiple outputs
|
|
142
|
-
result.data.forEach(output => console.log(output.download_url));
|
|
143
|
-
} else {
|
|
144
|
-
// Legacy format - single output
|
|
145
|
-
console.log(result.data.download_url);
|
|
146
|
-
}
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### Future Migration (v2.0.0 - September 1st, 2025)
|
|
150
|
-
|
|
151
|
-
In v2.0.0, the legacy format will be completely removed:
|
|
152
|
-
- `executeWorkflowAsync` will always return array format
|
|
153
|
-
- `returnAllOutputs` parameter will be removed
|
|
154
|
-
- `LegacyGetOutputResponse` type will be removed
|
|
155
|
+
`returnAllOutputs` and legacy response types are removed in v2.0.0.
|
|
155
156
|
|
|
156
157
|
---
|
|
157
158
|
|
package/README.md
CHANGED
|
@@ -259,7 +259,7 @@ console.log('Workflow Result:', result);
|
|
|
259
259
|
|
|
260
260
|
---
|
|
261
261
|
|
|
262
|
-
### 5 `executeWorkflowAsync(workflowId, data, groupId?, pollIntervalMs?, timeoutMs?,
|
|
262
|
+
### 5 `executeWorkflowAsync(workflowId, data, groupId?, pollIntervalMs?, timeoutMs?, options?)`
|
|
263
263
|
|
|
264
264
|
**Description:**
|
|
265
265
|
Execute a workflow and automatically wait for all outputs by polling. This is a convenience method that combines `executeWorkflow` and `getOutput` with automatic polling. Unlike `executeWorkflow`, this method waits for completion and returns the actual workflow outputs.
|
|
@@ -270,8 +270,7 @@ Execute a workflow and automatically wait for all outputs by polling. This is a
|
|
|
270
270
|
- `groupId` *(string, optional)*: A custom identifier for grouping runs.
|
|
271
271
|
- `pollIntervalMs` *(number, optional)*: Polling interval in milliseconds (default: 2000).
|
|
272
272
|
- `timeoutMs` *(number, optional)*: Maximum time to wait for results in milliseconds (default: 600000 - 10 minutes).
|
|
273
|
-
- `
|
|
274
|
-
- `returnAllOutputs` *(boolean, options only)*: Force return all outputs in new array format (default: auto-detect based on output count).
|
|
273
|
+
- `options` *(object, optional)*: Additional async execution options.
|
|
275
274
|
- `onIntermediateResponse` *(function, options only)*: Callback fired for intermediate API responses while polling. Useful for queue/progress UI updates.
|
|
276
275
|
|
|
277
276
|
**Usage:**
|
|
@@ -303,7 +302,6 @@ const result = await flowscale.executeWorkflowAsync(
|
|
|
303
302
|
2000,
|
|
304
303
|
600000,
|
|
305
304
|
{
|
|
306
|
-
returnAllOutputs: true,
|
|
307
305
|
onIntermediateResponse: (update) => {
|
|
308
306
|
// update.type: workflow_submitted | run_status | output_status | poll_retry | completed
|
|
309
307
|
console.log('Async update:', update);
|
|
@@ -323,49 +321,31 @@ const result = await flowscale.executeWorkflowAsync(
|
|
|
323
321
|
"generation_status": "success"
|
|
324
322
|
},
|
|
325
323
|
{
|
|
326
|
-
"filename": "
|
|
327
|
-
"
|
|
324
|
+
"filename": "output_text_1",
|
|
325
|
+
"file_content": "hello world",
|
|
328
326
|
"generation_status": "success"
|
|
329
327
|
}
|
|
330
328
|
]
|
|
331
329
|
}
|
|
332
330
|
```
|
|
333
331
|
|
|
334
|
-
|
|
332
|
+
Each output entry contains either:
|
|
333
|
+
- `download_url` for binary/media outputs
|
|
334
|
+
- `file_content` for text/non-binary outputs
|
|
335
335
|
|
|
336
|
-
|
|
336
|
+
#### ⚠️ Breaking Change (v2.0.0)
|
|
337
337
|
|
|
338
|
-
|
|
339
|
-
- **Multiple Outputs**: Returns new array format
|
|
338
|
+
`executeWorkflowAsync` now always returns array output format (`GetAllOutputsResponse`).
|
|
340
339
|
|
|
341
|
-
|
|
342
|
-
```javascript
|
|
343
|
-
// Old single output format (still works but shows deprecation warning)
|
|
344
|
-
const result = await flowscale.executeWorkflowAsync(workflowId, data);
|
|
345
|
-
// Returns: { status: "success", data: { download_url: "...", generation_status: "..." }, _deprecation: {...} }
|
|
346
|
-
```
|
|
340
|
+
If you migrated from v1.x and previously accessed `result.data.download_url` directly, update to iterate outputs:
|
|
347
341
|
|
|
348
|
-
**New Format (Recommended):**
|
|
349
342
|
```javascript
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
// Or handle both formats:
|
|
355
|
-
if (Array.isArray(result.data)) {
|
|
356
|
-
// New format - multiple outputs
|
|
357
|
-
result.data.forEach(output => console.log(output.download_url));
|
|
358
|
-
} else {
|
|
359
|
-
// Legacy format - single output (with deprecation warning)
|
|
360
|
-
console.log(result.data.download_url);
|
|
361
|
-
}
|
|
343
|
+
const result = await flowscale.executeWorkflowAsync(workflowId, data);
|
|
344
|
+
result.data.forEach((output) => {
|
|
345
|
+
console.log(output.download_url || output.file_content);
|
|
346
|
+
});
|
|
362
347
|
```
|
|
363
348
|
|
|
364
|
-
**Migration Steps:**
|
|
365
|
-
1. **Immediate**: Your existing code continues working with deprecation warnings
|
|
366
|
-
2. **Short-term**: Update your code to handle the new array format
|
|
367
|
-
3. **Long-term**: Migrate to the new format which supports multiple output
|
|
368
|
-
|
|
369
349
|
---
|
|
370
350
|
|
|
371
351
|
### 6. `getOutput(filename)`
|
|
@@ -393,6 +373,8 @@ console.log('Workflow Output:', output);
|
|
|
393
373
|
}
|
|
394
374
|
```
|
|
395
375
|
|
|
376
|
+
For text outputs, `data` may contain `file_content` instead of `download_url`.
|
|
377
|
+
|
|
396
378
|
---
|
|
397
379
|
|
|
398
380
|
### 7. `cancelRun(runId)`
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HealthCheckResponse, QueueResponse, ExecuteWorkflowResponse, GetOutputResponse, GetAllOutputsResponse,
|
|
1
|
+
import { HealthCheckResponse, QueueResponse, ExecuteWorkflowResponse, GetOutputResponse, GetAllOutputsResponse, RunDetailResponse, RunListResponse, CancelRunResponse, ExecuteWorkflowAsyncOptions, RunEventsSSEConnection, RunEventsSSEOptions, FlowscaleConfig, WorkflowResponse } from './types';
|
|
2
2
|
export declare class FlowscaleAPI {
|
|
3
3
|
private apiKey;
|
|
4
4
|
private baseUrl;
|
|
@@ -38,11 +38,11 @@ export declare class FlowscaleAPI {
|
|
|
38
38
|
* @param groupId - Optional group ID.
|
|
39
39
|
* @param pollIntervalMs - Optional polling interval in milliseconds (default: 2000)
|
|
40
40
|
* @param timeoutMs - Optional timeout in milliseconds (default: 600000 - 10 minutes)
|
|
41
|
-
* @param
|
|
41
|
+
* @param options - Optional configuration for intermediate responses.
|
|
42
42
|
*/
|
|
43
43
|
executeWorkflowAsync(workflowId: string, data: {
|
|
44
44
|
[key: string]: any;
|
|
45
|
-
}, groupId?: string, pollIntervalMs?: number, timeoutMs?: number,
|
|
45
|
+
}, groupId?: string, pollIntervalMs?: number, timeoutMs?: number, options?: ExecuteWorkflowAsyncOptions): Promise<GetAllOutputsResponse>;
|
|
46
46
|
/**
|
|
47
47
|
* Retrieves the output of a specific run by providing the filename.
|
|
48
48
|
* @param filename - The filename of the output to retrieve.
|
|
@@ -71,7 +71,6 @@ export declare class FlowscaleAPI {
|
|
|
71
71
|
* @returns Connection handle with `close()` and `done` promise.
|
|
72
72
|
*/
|
|
73
73
|
subscribeRunEvents(runId: string, options?: RunEventsSSEOptions): RunEventsSSEConnection;
|
|
74
|
-
private resolveExecuteWorkflowAsyncOptions;
|
|
75
74
|
private emitExecuteWorkflowAsyncIntermediateResponse;
|
|
76
75
|
private formatUnknownError;
|
|
77
76
|
private sleep;
|
package/dist/index.js
CHANGED
|
@@ -232,17 +232,17 @@ var FlowscaleAPI = /** @class */ (function () {
|
|
|
232
232
|
* @param groupId - Optional group ID.
|
|
233
233
|
* @param pollIntervalMs - Optional polling interval in milliseconds (default: 2000)
|
|
234
234
|
* @param timeoutMs - Optional timeout in milliseconds (default: 600000 - 10 minutes)
|
|
235
|
-
* @param
|
|
235
|
+
* @param options - Optional configuration for intermediate responses.
|
|
236
236
|
*/
|
|
237
237
|
FlowscaleAPI.prototype.executeWorkflowAsync = function (workflowId_1, data_1, groupId_1) {
|
|
238
|
-
return __awaiter(this, arguments, void 0, function (workflowId, data, groupId, pollIntervalMs, timeoutMs,
|
|
239
|
-
var
|
|
238
|
+
return __awaiter(this, arguments, void 0, function (workflowId, data, groupId, pollIntervalMs, timeoutMs, options) {
|
|
239
|
+
var onIntermediateResponse, startTime, executeResponse, runId, resolvedWorkflowId, run_status, output_names, runResponse, attempts, runResponse, latestOutputNames, outputPromises, outputResults, successfulOutputs, pendingOutputs, hasErrors, _i, outputResults_1, result, outputData, hasFileContent, hasDownloadUrl, allOutputsResponse, error_1, errorMessage, isIntentionalError;
|
|
240
240
|
var _this = this;
|
|
241
|
-
var _b, _c, _d, _e, _f, _g, _h
|
|
241
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
242
242
|
if (pollIntervalMs === void 0) { pollIntervalMs = 2000; }
|
|
243
243
|
if (timeoutMs === void 0) { timeoutMs = 600000; }
|
|
244
|
-
return __generator(this, function (
|
|
245
|
-
switch (
|
|
244
|
+
return __generator(this, function (_j) {
|
|
245
|
+
switch (_j.label) {
|
|
246
246
|
case 0:
|
|
247
247
|
// Validate inputs
|
|
248
248
|
if (!workflowId || typeof workflowId !== 'string' || workflowId.trim() === '') {
|
|
@@ -257,15 +257,15 @@ var FlowscaleAPI = /** @class */ (function () {
|
|
|
257
257
|
if (timeoutMs <= 0) {
|
|
258
258
|
throw new Error('Timeout must be greater than 0');
|
|
259
259
|
}
|
|
260
|
-
|
|
260
|
+
onIntermediateResponse = options === null || options === void 0 ? void 0 : options.onIntermediateResponse;
|
|
261
261
|
startTime = Date.now();
|
|
262
262
|
return [4 /*yield*/, this.executeWorkflow(workflowId, data, groupId)];
|
|
263
263
|
case 1:
|
|
264
|
-
executeResponse =
|
|
265
|
-
if (!((
|
|
264
|
+
executeResponse = _j.sent();
|
|
265
|
+
if (!((_a = executeResponse === null || executeResponse === void 0 ? void 0 : executeResponse.data) === null || _a === void 0 ? void 0 : _a.run_id)) {
|
|
266
266
|
throw new Error('No run ID returned from workflow execution');
|
|
267
267
|
}
|
|
268
|
-
if (!((
|
|
268
|
+
if (!((_b = executeResponse === null || executeResponse === void 0 ? void 0 : executeResponse.data) === null || _b === void 0 ? void 0 : _b.workflow_id)) {
|
|
269
269
|
throw new Error('No workflow ID returned from workflow execution');
|
|
270
270
|
}
|
|
271
271
|
runId = executeResponse.data.run_id;
|
|
@@ -278,10 +278,10 @@ var FlowscaleAPI = /** @class */ (function () {
|
|
|
278
278
|
response: executeResponse,
|
|
279
279
|
})];
|
|
280
280
|
case 2:
|
|
281
|
-
|
|
281
|
+
_j.sent();
|
|
282
282
|
run_status = "queued";
|
|
283
283
|
output_names = [];
|
|
284
|
-
|
|
284
|
+
_j.label = 3;
|
|
285
285
|
case 3:
|
|
286
286
|
if (!(output_names.length === 0)) return [3 /*break*/, 8];
|
|
287
287
|
if (Date.now() - startTime > timeoutMs) {
|
|
@@ -289,9 +289,9 @@ var FlowscaleAPI = /** @class */ (function () {
|
|
|
289
289
|
}
|
|
290
290
|
return [4 /*yield*/, this.getRun(runId)];
|
|
291
291
|
case 4:
|
|
292
|
-
runResponse =
|
|
293
|
-
run_status = ((
|
|
294
|
-
output_names = ((
|
|
292
|
+
runResponse = _j.sent();
|
|
293
|
+
run_status = ((_c = runResponse === null || runResponse === void 0 ? void 0 : runResponse.data) === null || _c === void 0 ? void 0 : _c.status) || "queued";
|
|
294
|
+
output_names = ((_d = runResponse === null || runResponse === void 0 ? void 0 : runResponse.data) === null || _d === void 0 ? void 0 : _d.output_names) || [];
|
|
295
295
|
return [4 /*yield*/, this.emitExecuteWorkflowAsyncIntermediateResponse(onIntermediateResponse, {
|
|
296
296
|
type: 'run_status',
|
|
297
297
|
timestamp: new Date().toISOString(),
|
|
@@ -299,19 +299,19 @@ var FlowscaleAPI = /** @class */ (function () {
|
|
|
299
299
|
workflow_id: resolvedWorkflowId,
|
|
300
300
|
run_status: run_status,
|
|
301
301
|
output_names: output_names,
|
|
302
|
-
progress: ((
|
|
302
|
+
progress: ((_e = runResponse === null || runResponse === void 0 ? void 0 : runResponse.data) === null || _e === void 0 ? void 0 : _e.progress) || undefined,
|
|
303
303
|
response: runResponse,
|
|
304
304
|
})];
|
|
305
305
|
case 5:
|
|
306
|
-
|
|
306
|
+
_j.sent();
|
|
307
307
|
if (run_status === 'failed' || run_status === 'cancelled') {
|
|
308
308
|
throw new Error("Run ".concat(runId, " failed with status: ").concat(run_status));
|
|
309
309
|
}
|
|
310
310
|
if (!(output_names.length === 0)) return [3 /*break*/, 7];
|
|
311
311
|
return [4 /*yield*/, this.sleep(pollIntervalMs)];
|
|
312
312
|
case 6:
|
|
313
|
-
|
|
314
|
-
|
|
313
|
+
_j.sent();
|
|
314
|
+
_j.label = 7;
|
|
315
315
|
case 7: return [3 /*break*/, 3];
|
|
316
316
|
case 8:
|
|
317
317
|
if (!output_names || output_names.length === 0) {
|
|
@@ -319,20 +319,20 @@ var FlowscaleAPI = /** @class */ (function () {
|
|
|
319
319
|
}
|
|
320
320
|
this.logInfo("Found ".concat(output_names.length, " outputs to wait for: ").concat(output_names.join(', ')));
|
|
321
321
|
attempts = 0;
|
|
322
|
-
|
|
322
|
+
_j.label = 9;
|
|
323
323
|
case 9:
|
|
324
|
-
if (!true) return [3 /*break*/,
|
|
324
|
+
if (!true) return [3 /*break*/, 21];
|
|
325
325
|
if (Date.now() - startTime > timeoutMs) {
|
|
326
326
|
throw new Error("Workflow execution timed out after ".concat(timeoutMs, "ms"));
|
|
327
327
|
}
|
|
328
|
-
|
|
328
|
+
_j.label = 10;
|
|
329
329
|
case 10:
|
|
330
|
-
|
|
330
|
+
_j.trys.push([10, 17, , 20]);
|
|
331
331
|
return [4 /*yield*/, this.getRun(runId)];
|
|
332
332
|
case 11:
|
|
333
|
-
runResponse =
|
|
334
|
-
run_status = ((
|
|
335
|
-
latestOutputNames = ((
|
|
333
|
+
runResponse = _j.sent();
|
|
334
|
+
run_status = ((_f = runResponse === null || runResponse === void 0 ? void 0 : runResponse.data) === null || _f === void 0 ? void 0 : _f.status) || run_status;
|
|
335
|
+
latestOutputNames = ((_g = runResponse === null || runResponse === void 0 ? void 0 : runResponse.data) === null || _g === void 0 ? void 0 : _g.output_names) || [];
|
|
336
336
|
if (latestOutputNames.length > 0) {
|
|
337
337
|
output_names = latestOutputNames;
|
|
338
338
|
}
|
|
@@ -344,11 +344,11 @@ var FlowscaleAPI = /** @class */ (function () {
|
|
|
344
344
|
attempt: attempts,
|
|
345
345
|
run_status: run_status,
|
|
346
346
|
output_names: output_names,
|
|
347
|
-
progress: ((
|
|
347
|
+
progress: ((_h = runResponse === null || runResponse === void 0 ? void 0 : runResponse.data) === null || _h === void 0 ? void 0 : _h.progress) || undefined,
|
|
348
348
|
response: runResponse,
|
|
349
349
|
})];
|
|
350
350
|
case 12:
|
|
351
|
-
|
|
351
|
+
_j.sent();
|
|
352
352
|
if (run_status === 'failed' || run_status === 'cancelled') {
|
|
353
353
|
throw new Error("Run ".concat(runId, " failed with status: ").concat(run_status));
|
|
354
354
|
}
|
|
@@ -397,7 +397,7 @@ var FlowscaleAPI = /** @class */ (function () {
|
|
|
397
397
|
}); });
|
|
398
398
|
return [4 /*yield*/, Promise.all(outputPromises)];
|
|
399
399
|
case 13:
|
|
400
|
-
outputResults =
|
|
400
|
+
outputResults = _j.sent();
|
|
401
401
|
successfulOutputs = [];
|
|
402
402
|
pendingOutputs = [];
|
|
403
403
|
hasErrors = false;
|
|
@@ -414,20 +414,27 @@ var FlowscaleAPI = /** @class */ (function () {
|
|
|
414
414
|
continue;
|
|
415
415
|
}
|
|
416
416
|
if (result.output.status === 'success') {
|
|
417
|
-
|
|
417
|
+
outputData = result.output.data || {};
|
|
418
|
+
hasFileContent = outputData.file_content !== undefined && outputData.file_content !== null;
|
|
419
|
+
hasDownloadUrl = typeof outputData.download_url === 'string' && outputData.download_url.trim() !== '';
|
|
420
|
+
if (hasFileContent) {
|
|
418
421
|
successfulOutputs.push({
|
|
419
422
|
filename: result.filename,
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
generation_status: result.output.data.generation_status || 'success'
|
|
423
|
+
file_content: outputData.file_content,
|
|
424
|
+
generation_status: outputData.generation_status || 'success'
|
|
423
425
|
});
|
|
424
426
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
427
|
+
else if (hasDownloadUrl) {
|
|
428
|
+
successfulOutputs.push({
|
|
429
|
+
filename: result.filename,
|
|
430
|
+
download_url: outputData.download_url,
|
|
431
|
+
generation_status: outputData.generation_status || 'success'
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
this.logWarn("Output ".concat(result.filename, " marked success but has no download_url or file_content"));
|
|
436
|
+
pendingOutputs.push(result.filename);
|
|
437
|
+
}
|
|
431
438
|
}
|
|
432
439
|
else if (result.output.status === 'in_progress') {
|
|
433
440
|
this.logDebug("Output ".concat(result.filename, " still in progress"));
|
|
@@ -446,40 +453,8 @@ var FlowscaleAPI = /** @class */ (function () {
|
|
|
446
453
|
if (hasErrors) {
|
|
447
454
|
throw new Error('One or more workflow outputs failed');
|
|
448
455
|
}
|
|
449
|
-
if (!(pendingOutputs.length === 0)) return [3 /*break*/,
|
|
456
|
+
if (!(pendingOutputs.length === 0)) return [3 /*break*/, 15];
|
|
450
457
|
this.logInfo("All ".concat(successfulOutputs.length, " outputs completed successfully"));
|
|
451
|
-
if (!(returnAllOutputs === false || (returnAllOutputs === undefined && successfulOutputs.length === 1))) return [3 /*break*/, 15];
|
|
452
|
-
deprecationWarning = {
|
|
453
|
-
message: successfulOutputs.length > 1
|
|
454
|
-
? 'Single output format is deprecated. This workflow returned multiple outputs but only the first is shown.'
|
|
455
|
-
: 'Single output format is deprecated. Please migrate to the new multi-output format.',
|
|
456
|
-
migration_guide: 'Use executeWorkflowAsync(workflowId, data, groupId, pollInterval, timeout, true) to get all outputs, or access response.data[0] for the first output.',
|
|
457
|
-
removal_version: '2.0.0 (September 1st, 2025)'
|
|
458
|
-
};
|
|
459
|
-
// Log deprecation warning to console
|
|
460
|
-
this.logWarn('DEPRECATION WARNING: executeWorkflowAsync single output format is deprecated and will be removed in v2.0.0 (September 1st, 2025). ' +
|
|
461
|
-
'Use returnAllOutputs: true parameter to get the new format with all outputs.');
|
|
462
|
-
legacyResponse = {
|
|
463
|
-
status: 'success',
|
|
464
|
-
data: {
|
|
465
|
-
download_url: successfulOutputs[0].download_url,
|
|
466
|
-
generation_status: successfulOutputs[0].generation_status
|
|
467
|
-
},
|
|
468
|
-
_deprecation: deprecationWarning
|
|
469
|
-
};
|
|
470
|
-
return [4 /*yield*/, this.emitExecuteWorkflowAsyncIntermediateResponse(onIntermediateResponse, {
|
|
471
|
-
type: 'completed',
|
|
472
|
-
timestamp: new Date().toISOString(),
|
|
473
|
-
run_id: runId,
|
|
474
|
-
workflow_id: resolvedWorkflowId,
|
|
475
|
-
output_names: output_names,
|
|
476
|
-
completed_outputs: successfulOutputs.map(function (output) { return output.filename; }),
|
|
477
|
-
response: legacyResponse,
|
|
478
|
-
})];
|
|
479
|
-
case 14:
|
|
480
|
-
_k.sent();
|
|
481
|
-
return [2 /*return*/, legacyResponse];
|
|
482
|
-
case 15:
|
|
483
458
|
allOutputsResponse = {
|
|
484
459
|
status: 'success',
|
|
485
460
|
data: successfulOutputs
|
|
@@ -493,18 +468,18 @@ var FlowscaleAPI = /** @class */ (function () {
|
|
|
493
468
|
completed_outputs: successfulOutputs.map(function (output) { return output.filename; }),
|
|
494
469
|
response: allOutputsResponse,
|
|
495
470
|
})];
|
|
496
|
-
case
|
|
497
|
-
|
|
471
|
+
case 14:
|
|
472
|
+
_j.sent();
|
|
498
473
|
return [2 /*return*/, allOutputsResponse];
|
|
499
|
-
case
|
|
474
|
+
case 15:
|
|
500
475
|
// If some outputs are still pending, continue polling
|
|
501
476
|
this.logDebug("".concat(pendingOutputs.length, " outputs still pending: ").concat(pendingOutputs.join(', ')));
|
|
502
477
|
return [4 /*yield*/, this.sleep(pollIntervalMs)];
|
|
503
|
-
case
|
|
504
|
-
|
|
505
|
-
return [3 /*break*/,
|
|
506
|
-
case
|
|
507
|
-
error_1 =
|
|
478
|
+
case 16:
|
|
479
|
+
_j.sent();
|
|
480
|
+
return [3 /*break*/, 20];
|
|
481
|
+
case 17:
|
|
482
|
+
error_1 = _j.sent();
|
|
508
483
|
errorMessage = error_1 instanceof Error ? error_1.message : String(error_1);
|
|
509
484
|
isIntentionalError = errorMessage.includes('failed with status:') ||
|
|
510
485
|
errorMessage.includes('One or more workflow outputs failed');
|
|
@@ -522,22 +497,22 @@ var FlowscaleAPI = /** @class */ (function () {
|
|
|
522
497
|
output_names: output_names,
|
|
523
498
|
error: this.formatUnknownError(error_1),
|
|
524
499
|
})];
|
|
525
|
-
case
|
|
526
|
-
|
|
500
|
+
case 18:
|
|
501
|
+
_j.sent();
|
|
527
502
|
// After several failures, increase polling interval to avoid excessive requests
|
|
528
503
|
if (attempts > 5) {
|
|
529
504
|
pollIntervalMs = Math.min(pollIntervalMs * 1.5, 10000); // Increase interval, max 10s
|
|
530
505
|
}
|
|
531
506
|
// Wait before retrying
|
|
532
507
|
return [4 /*yield*/, this.sleep(pollIntervalMs)];
|
|
533
|
-
case
|
|
508
|
+
case 19:
|
|
534
509
|
// Wait before retrying
|
|
535
|
-
|
|
536
|
-
return [3 /*break*/,
|
|
537
|
-
case
|
|
510
|
+
_j.sent();
|
|
511
|
+
return [3 /*break*/, 20];
|
|
512
|
+
case 20:
|
|
538
513
|
attempts++;
|
|
539
514
|
return [3 /*break*/, 9];
|
|
540
|
-
case
|
|
515
|
+
case 21: return [2 /*return*/];
|
|
541
516
|
}
|
|
542
517
|
});
|
|
543
518
|
});
|
|
@@ -677,16 +652,6 @@ var FlowscaleAPI = /** @class */ (function () {
|
|
|
677
652
|
done: done,
|
|
678
653
|
};
|
|
679
654
|
};
|
|
680
|
-
FlowscaleAPI.prototype.resolveExecuteWorkflowAsyncOptions = function (returnAllOutputsOrOptions) {
|
|
681
|
-
if (returnAllOutputsOrOptions == null ||
|
|
682
|
-
typeof returnAllOutputsOrOptions === 'boolean') {
|
|
683
|
-
return { returnAllOutputs: returnAllOutputsOrOptions };
|
|
684
|
-
}
|
|
685
|
-
return {
|
|
686
|
-
returnAllOutputs: returnAllOutputsOrOptions.returnAllOutputs,
|
|
687
|
-
onIntermediateResponse: returnAllOutputsOrOptions.onIntermediateResponse,
|
|
688
|
-
};
|
|
689
|
-
};
|
|
690
655
|
FlowscaleAPI.prototype.emitExecuteWorkflowAsyncIntermediateResponse = function (callback, update) {
|
|
691
656
|
return __awaiter(this, void 0, void 0, function () {
|
|
692
657
|
var error_4;
|
package/dist/types.d.ts
CHANGED
|
@@ -77,11 +77,10 @@ export interface ExecuteWorkflowAsyncIntermediateResponse {
|
|
|
77
77
|
pending_outputs?: string[];
|
|
78
78
|
completed_outputs?: string[];
|
|
79
79
|
progress?: RunProgress;
|
|
80
|
-
response?: ExecuteWorkflowResponse | RunDetailResponse | GetOutputResponse | GetAllOutputsResponse |
|
|
80
|
+
response?: ExecuteWorkflowResponse | RunDetailResponse | GetOutputResponse | GetAllOutputsResponse | null;
|
|
81
81
|
error?: string;
|
|
82
82
|
}
|
|
83
83
|
export interface ExecuteWorkflowAsyncOptions {
|
|
84
|
-
returnAllOutputs?: boolean;
|
|
85
84
|
onIntermediateResponse?: (update: ExecuteWorkflowAsyncIntermediateResponse) => void | Promise<void>;
|
|
86
85
|
}
|
|
87
86
|
export interface RunEventsSSEEvent {
|
|
@@ -105,14 +104,6 @@ export interface RunEventsSSEConnection {
|
|
|
105
104
|
close: () => void;
|
|
106
105
|
done: Promise<void>;
|
|
107
106
|
}
|
|
108
|
-
export interface DeprecationWarning {
|
|
109
|
-
message: string;
|
|
110
|
-
migration_guide: string;
|
|
111
|
-
removal_version: string;
|
|
112
|
-
}
|
|
113
|
-
export interface LegacyGetOutputResponse extends GetOutputResponse {
|
|
114
|
-
_deprecation?: DeprecationWarning;
|
|
115
|
-
}
|
|
116
107
|
export interface RunDetail {
|
|
117
108
|
_id: string;
|
|
118
109
|
team_id: string;
|