@workglow/tasks 0.0.85 → 0.0.87
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/README.md +73 -0
- package/dist/browser.js +817 -596
- package/dist/browser.js.map +17 -12
- package/dist/bun.js +5113 -4894
- package/dist/bun.js.map +18 -13
- package/dist/common.d.ts +14 -0
- package/dist/common.d.ts.map +1 -1
- package/dist/node.js +5113 -4894
- package/dist/node.js.map +18 -13
- package/dist/task/ArrayTask.d.ts +109 -0
- package/dist/task/ArrayTask.d.ts.map +1 -0
- package/dist/task/DebugLogTask.d.ts.map +1 -1
- package/dist/task/DelayTask.d.ts.map +1 -1
- package/dist/task/FetchUrlTask.d.ts +1 -1
- package/dist/task/FetchUrlTask.d.ts.map +1 -1
- package/dist/task/FileLoaderTask.d.ts.map +1 -1
- package/dist/task/FileLoaderTask.server.d.ts +2 -2
- package/dist/task/FileLoaderTask.server.d.ts.map +1 -1
- package/dist/task/InputTask.d.ts +32 -0
- package/dist/task/InputTask.d.ts.map +1 -0
- package/dist/task/JavaScriptTask.d.ts.map +1 -1
- package/dist/task/JsonTask.d.ts +2 -0
- package/dist/task/JsonTask.d.ts.map +1 -1
- package/dist/task/LambdaTask.d.ts +7 -26
- package/dist/task/LambdaTask.d.ts.map +1 -1
- package/dist/task/MergeTask.d.ts.map +1 -1
- package/dist/task/OutputTask.d.ts +35 -0
- package/dist/task/OutputTask.d.ts.map +1 -0
- package/dist/task/SplitTask.d.ts.map +1 -1
- package/package.json +11 -10
package/dist/browser.js
CHANGED
|
@@ -6,132 +6,18 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
6
6
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
// src/
|
|
10
|
-
import {
|
|
11
|
-
var log_levels = ["dir", "log", "debug", "info", "warn", "error"];
|
|
12
|
-
var DEFAULT_LOG_LEVEL = "log";
|
|
13
|
-
var inputSchema = {
|
|
14
|
-
type: "object",
|
|
15
|
-
properties: {
|
|
16
|
-
console: {
|
|
17
|
-
title: "Message",
|
|
18
|
-
description: "The message to log"
|
|
19
|
-
},
|
|
20
|
-
log_level: {
|
|
21
|
-
type: "string",
|
|
22
|
-
enum: log_levels,
|
|
23
|
-
title: "Log Level",
|
|
24
|
-
description: "The log level to use",
|
|
25
|
-
default: DEFAULT_LOG_LEVEL
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
additionalProperties: false
|
|
29
|
-
};
|
|
30
|
-
var outputSchema = {
|
|
31
|
-
type: "object",
|
|
32
|
-
properties: {
|
|
33
|
-
console: {
|
|
34
|
-
title: "Messages",
|
|
35
|
-
description: "The messages logged by the task"
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
additionalProperties: false
|
|
39
|
-
};
|
|
9
|
+
// src/browser.ts
|
|
10
|
+
import { TaskRegistry as TaskRegistry2 } from "@workglow/task-graph";
|
|
40
11
|
|
|
41
|
-
|
|
42
|
-
static type = "DebugLogTask";
|
|
43
|
-
static category = "Utility";
|
|
44
|
-
static title = "Debug Log";
|
|
45
|
-
static description = "Logs messages to the console with configurable log levels for debugging task graphs";
|
|
46
|
-
static cacheable = false;
|
|
47
|
-
static inputSchema() {
|
|
48
|
-
return inputSchema;
|
|
49
|
-
}
|
|
50
|
-
static outputSchema() {
|
|
51
|
-
return outputSchema;
|
|
52
|
-
}
|
|
53
|
-
async executeReactive(input, output) {
|
|
54
|
-
const { log_level = DEFAULT_LOG_LEVEL, console: messages } = input;
|
|
55
|
-
if (log_level == "dir") {
|
|
56
|
-
console.dir(messages, { depth: null });
|
|
57
|
-
} else {
|
|
58
|
-
console[log_level](messages);
|
|
59
|
-
}
|
|
60
|
-
output.console = input.console;
|
|
61
|
-
return output;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
TaskRegistry.registerTask(DebugLogTask);
|
|
65
|
-
var debugLog = (input, config = {}) => {
|
|
66
|
-
const task = new DebugLogTask(input, config);
|
|
67
|
-
return task.run();
|
|
68
|
-
};
|
|
69
|
-
Workflow.prototype.debugLog = CreateWorkflow(DebugLogTask);
|
|
70
|
-
// src/task/DelayTask.ts
|
|
12
|
+
// src/task/FileLoaderTask.ts
|
|
71
13
|
import {
|
|
72
14
|
CreateWorkflow as CreateWorkflow2,
|
|
73
|
-
Task
|
|
15
|
+
Task,
|
|
74
16
|
TaskAbortedError,
|
|
75
|
-
TaskRegistry as TaskRegistry2,
|
|
76
17
|
Workflow as Workflow2
|
|
77
18
|
} from "@workglow/task-graph";
|
|
78
|
-
import
|
|
79
|
-
var inputSchema2 = {
|
|
80
|
-
type: "object",
|
|
81
|
-
properties: {
|
|
82
|
-
delay: {
|
|
83
|
-
type: "number",
|
|
84
|
-
title: "Delay (ms)",
|
|
85
|
-
default: 1
|
|
86
|
-
},
|
|
87
|
-
pass_through: {
|
|
88
|
-
title: "Pass Through",
|
|
89
|
-
description: "Pass through data to the output"
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
additionalProperties: false
|
|
93
|
-
};
|
|
94
|
-
var outputSchema2 = {
|
|
95
|
-
type: "object",
|
|
96
|
-
properties: {},
|
|
97
|
-
additionalProperties: true
|
|
98
|
-
};
|
|
19
|
+
import Papa from "papaparse";
|
|
99
20
|
|
|
100
|
-
class DelayTask extends Task2 {
|
|
101
|
-
static type = "DelayTask";
|
|
102
|
-
static category = "Utility";
|
|
103
|
-
static title = "Delay";
|
|
104
|
-
static description = "Delays execution for a specified duration with progress tracking";
|
|
105
|
-
static inputSchema() {
|
|
106
|
-
return inputSchema2;
|
|
107
|
-
}
|
|
108
|
-
static outputSchema() {
|
|
109
|
-
return outputSchema2;
|
|
110
|
-
}
|
|
111
|
-
async execute(input, executeContext) {
|
|
112
|
-
const delay = input.delay ?? 0;
|
|
113
|
-
if (delay > 100) {
|
|
114
|
-
const iterations = Math.min(100, Math.floor(delay / 16));
|
|
115
|
-
const chunkSize = delay / iterations;
|
|
116
|
-
for (let i = 0;i < iterations; i++) {
|
|
117
|
-
if (executeContext.signal.aborted) {
|
|
118
|
-
throw new TaskAbortedError("Task aborted");
|
|
119
|
-
}
|
|
120
|
-
await sleep(chunkSize);
|
|
121
|
-
await executeContext.updateProgress(100 * i / iterations, `Delaying for ${delay}ms`);
|
|
122
|
-
}
|
|
123
|
-
} else {
|
|
124
|
-
await sleep(delay);
|
|
125
|
-
}
|
|
126
|
-
return input.pass_through;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
TaskRegistry2.registerTask(DelayTask);
|
|
130
|
-
var delay = (input, config = {}) => {
|
|
131
|
-
const task = new DelayTask(input, config);
|
|
132
|
-
return task.run();
|
|
133
|
-
};
|
|
134
|
-
Workflow2.prototype.delay = CreateWorkflow2(DelayTask);
|
|
135
21
|
// src/task/FetchUrlTask.ts
|
|
136
22
|
import {
|
|
137
23
|
AbortSignalJobError,
|
|
@@ -140,14 +26,13 @@ import {
|
|
|
140
26
|
RetryableJobError
|
|
141
27
|
} from "@workglow/job-queue";
|
|
142
28
|
import {
|
|
143
|
-
CreateWorkflow
|
|
29
|
+
CreateWorkflow,
|
|
144
30
|
JobQueueTask,
|
|
145
31
|
TaskConfigurationError,
|
|
146
32
|
TaskInvalidInputError,
|
|
147
|
-
|
|
148
|
-
Workflow as Workflow3
|
|
33
|
+
Workflow
|
|
149
34
|
} from "@workglow/task-graph";
|
|
150
|
-
var
|
|
35
|
+
var inputSchema = {
|
|
151
36
|
type: "object",
|
|
152
37
|
properties: {
|
|
153
38
|
url: {
|
|
@@ -196,7 +81,7 @@ var inputSchema3 = {
|
|
|
196
81
|
required: ["url"],
|
|
197
82
|
additionalProperties: false
|
|
198
83
|
};
|
|
199
|
-
var
|
|
84
|
+
var outputSchema = {
|
|
200
85
|
type: "object",
|
|
201
86
|
properties: {
|
|
202
87
|
json: {
|
|
@@ -356,10 +241,10 @@ class FetchUrlTask extends JobQueueTask {
|
|
|
356
241
|
static description = "Fetches data from a URL with progress tracking and automatic retry handling";
|
|
357
242
|
static hasDynamicSchemas = true;
|
|
358
243
|
static inputSchema() {
|
|
359
|
-
return
|
|
244
|
+
return inputSchema;
|
|
360
245
|
}
|
|
361
246
|
static outputSchema() {
|
|
362
|
-
return
|
|
247
|
+
return outputSchema;
|
|
363
248
|
}
|
|
364
249
|
outputSchema() {
|
|
365
250
|
const responseType = this.runInputData?.response_type ?? this.defaults?.response_type ?? null;
|
|
@@ -435,84 +320,665 @@ class FetchUrlTask extends JobQueueTask {
|
|
|
435
320
|
}
|
|
436
321
|
}
|
|
437
322
|
}
|
|
438
|
-
TaskRegistry3.registerTask(FetchUrlTask);
|
|
439
323
|
var fetchUrl = async (input, config = {}) => {
|
|
440
|
-
const result = await new FetchUrlTask(
|
|
324
|
+
const result = await new FetchUrlTask({}, config).run(input);
|
|
441
325
|
return result;
|
|
442
326
|
};
|
|
443
|
-
|
|
444
|
-
// src/task/JavaScriptTask.ts
|
|
445
|
-
import { CreateWorkflow as CreateWorkflow4, Task as Task3, TaskRegistry as TaskRegistry4, Workflow as Workflow4 } from "@workglow/task-graph";
|
|
327
|
+
Workflow.prototype.fetch = CreateWorkflow(FetchUrlTask);
|
|
446
328
|
|
|
447
|
-
// src/
|
|
448
|
-
var
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
program: null,
|
|
468
|
-
sourceFile: null,
|
|
469
|
-
directSourceFile: null
|
|
329
|
+
// src/task/FileLoaderTask.ts
|
|
330
|
+
var inputSchema2 = {
|
|
331
|
+
type: "object",
|
|
332
|
+
properties: {
|
|
333
|
+
url: {
|
|
334
|
+
type: "string",
|
|
335
|
+
title: "URL",
|
|
336
|
+
description: "URL to load document from (http://, https://)",
|
|
337
|
+
format: "uri"
|
|
338
|
+
},
|
|
339
|
+
format: {
|
|
340
|
+
type: "string",
|
|
341
|
+
enum: ["text", "markdown", "json", "csv", "pdf", "image", "html", "auto"],
|
|
342
|
+
title: "Format",
|
|
343
|
+
description: "File format (auto-detected from URL if 'auto')",
|
|
344
|
+
default: "auto"
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
required: ["url"],
|
|
348
|
+
additionalProperties: false
|
|
470
349
|
};
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
350
|
+
var outputSchema2 = {
|
|
351
|
+
type: "object",
|
|
352
|
+
properties: {
|
|
353
|
+
text: {
|
|
354
|
+
type: "string",
|
|
355
|
+
title: "Text",
|
|
356
|
+
description: "Text content (for text, markdown, html formats)"
|
|
357
|
+
},
|
|
358
|
+
json: {
|
|
359
|
+
title: "JSON",
|
|
360
|
+
description: "Parsed JSON object or array"
|
|
361
|
+
},
|
|
362
|
+
csv: {
|
|
363
|
+
type: "array",
|
|
364
|
+
title: "CSV",
|
|
365
|
+
description: "Parsed CSV data as array of objects"
|
|
366
|
+
},
|
|
367
|
+
image: {
|
|
368
|
+
type: "string",
|
|
369
|
+
title: "Image",
|
|
370
|
+
description: "Base64 data URL for image files",
|
|
371
|
+
format: "image:data-uri"
|
|
372
|
+
},
|
|
373
|
+
pdf: {
|
|
374
|
+
type: "string",
|
|
375
|
+
title: "PDF",
|
|
376
|
+
description: "Base64 data URL for PDF files"
|
|
377
|
+
},
|
|
378
|
+
metadata: {
|
|
379
|
+
type: "object",
|
|
380
|
+
properties: {
|
|
381
|
+
url: { type: "string" },
|
|
382
|
+
format: { type: "string" },
|
|
383
|
+
size: { type: "number" },
|
|
384
|
+
title: { type: "string" },
|
|
385
|
+
mimeType: { type: "string" }
|
|
386
|
+
},
|
|
387
|
+
additionalProperties: false,
|
|
388
|
+
title: "Metadata",
|
|
389
|
+
description: "File metadata"
|
|
476
390
|
}
|
|
391
|
+
},
|
|
392
|
+
required: ["metadata"],
|
|
393
|
+
additionalProperties: false
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
class FileLoaderTask extends Task {
|
|
397
|
+
static type = "FileLoaderTask";
|
|
398
|
+
static category = "Document";
|
|
399
|
+
static title = "File Loader";
|
|
400
|
+
static description = "Load documents from URLs (http://, https://)";
|
|
401
|
+
static cacheable = true;
|
|
402
|
+
static inputSchema() {
|
|
403
|
+
return inputSchema2;
|
|
477
404
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
var getLineInfo = function(input2, offset) {
|
|
481
|
-
for (var line = 1, cur = 0;; ) {
|
|
482
|
-
lineBreak.lastIndex = cur;
|
|
483
|
-
var match = lineBreak.exec(input2);
|
|
484
|
-
if (match && match.index < offset) {
|
|
485
|
-
++line;
|
|
486
|
-
cur = match.index + match[0].length;
|
|
487
|
-
} else {
|
|
488
|
-
break;
|
|
489
|
-
}
|
|
405
|
+
static outputSchema() {
|
|
406
|
+
return outputSchema2;
|
|
490
407
|
}
|
|
491
|
-
|
|
492
|
-
};
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
408
|
+
async execute(input, context) {
|
|
409
|
+
const { url, format = "auto" } = input;
|
|
410
|
+
if (context.signal.aborted) {
|
|
411
|
+
throw new TaskAbortedError("Task aborted");
|
|
412
|
+
}
|
|
413
|
+
await context.updateProgress(0, "Detecting file format");
|
|
414
|
+
const detectedFormat = this.detectFormat(url, format);
|
|
415
|
+
const responseType = this.detectResponseType(detectedFormat);
|
|
416
|
+
if (context.signal.aborted) {
|
|
417
|
+
throw new TaskAbortedError("Task aborted");
|
|
418
|
+
}
|
|
419
|
+
await context.updateProgress(10, `Fetching ${detectedFormat} file from ${url}`);
|
|
420
|
+
const fetchTask = context.own(new FetchUrlTask({
|
|
421
|
+
url,
|
|
422
|
+
response_type: responseType,
|
|
423
|
+
queue: false
|
|
424
|
+
}));
|
|
425
|
+
const response = await fetchTask.run();
|
|
426
|
+
if (context.signal.aborted) {
|
|
427
|
+
throw new TaskAbortedError("Task aborted");
|
|
428
|
+
}
|
|
429
|
+
await context.updateProgress(60, "Parsing file content");
|
|
430
|
+
const title = url.split("/").pop() || url;
|
|
431
|
+
const { text, json, csv, image, pdf, size, mimeType } = await this.parseResponse(response, url, detectedFormat);
|
|
432
|
+
if (context.signal.aborted) {
|
|
433
|
+
throw new TaskAbortedError("Task aborted");
|
|
434
|
+
}
|
|
435
|
+
await context.updateProgress(100, "File loaded successfully");
|
|
436
|
+
return {
|
|
437
|
+
text,
|
|
438
|
+
json,
|
|
439
|
+
csv,
|
|
440
|
+
image,
|
|
441
|
+
pdf,
|
|
442
|
+
metadata: {
|
|
443
|
+
url,
|
|
444
|
+
format: detectedFormat,
|
|
445
|
+
size,
|
|
446
|
+
title,
|
|
447
|
+
mimeType
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
parseJsonContent(content) {
|
|
452
|
+
return JSON.parse(content);
|
|
453
|
+
}
|
|
454
|
+
parseCsvContent(content) {
|
|
455
|
+
try {
|
|
456
|
+
const result = Papa.parse(content, {
|
|
457
|
+
header: true,
|
|
458
|
+
skipEmptyLines: true,
|
|
459
|
+
transformHeader: (header) => header.trim()
|
|
460
|
+
});
|
|
461
|
+
return result.data;
|
|
462
|
+
} catch (error) {
|
|
463
|
+
throw new Error(`Failed to parse CSV: ${error}`);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
async parseResponse(response, url, detectedFormat) {
|
|
467
|
+
const responseMimeType = response.metadata?.contentType || "";
|
|
468
|
+
if (detectedFormat === "json") {
|
|
469
|
+
if (!response.json) {
|
|
470
|
+
throw new Error(`Failed to load JSON from ${url}`);
|
|
471
|
+
}
|
|
472
|
+
const jsonData = response.json;
|
|
473
|
+
const content2 = JSON.stringify(jsonData, null, 2);
|
|
474
|
+
return {
|
|
475
|
+
text: undefined,
|
|
476
|
+
json: jsonData,
|
|
477
|
+
csv: undefined,
|
|
478
|
+
image: undefined,
|
|
479
|
+
pdf: undefined,
|
|
480
|
+
size: content2.length,
|
|
481
|
+
mimeType: responseMimeType || "application/json"
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
if (detectedFormat === "csv") {
|
|
485
|
+
const content2 = response.text || "";
|
|
486
|
+
if (!content2) {
|
|
487
|
+
throw new Error(`Failed to load CSV from ${url}`);
|
|
488
|
+
}
|
|
489
|
+
const csvData = this.parseCsvContent(content2);
|
|
490
|
+
return {
|
|
491
|
+
text: undefined,
|
|
492
|
+
json: undefined,
|
|
493
|
+
csv: csvData,
|
|
494
|
+
image: undefined,
|
|
495
|
+
pdf: undefined,
|
|
496
|
+
size: content2.length,
|
|
497
|
+
mimeType: responseMimeType || "text/csv"
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
if (detectedFormat === "image") {
|
|
501
|
+
if (!response.blob) {
|
|
502
|
+
throw new Error(`Failed to load image from ${url}`);
|
|
503
|
+
}
|
|
504
|
+
const blob = response.blob;
|
|
505
|
+
const mimeType2 = responseMimeType || (blob.type && blob.type !== "" ? blob.type : this.getImageMimeType(url));
|
|
506
|
+
const imageData = await this.blobToBase64DataURL(blob, mimeType2);
|
|
507
|
+
return {
|
|
508
|
+
text: undefined,
|
|
509
|
+
json: undefined,
|
|
510
|
+
csv: undefined,
|
|
511
|
+
image: imageData,
|
|
512
|
+
pdf: undefined,
|
|
513
|
+
size: blob.size,
|
|
514
|
+
mimeType: mimeType2
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
if (detectedFormat === "pdf") {
|
|
518
|
+
if (!response.blob) {
|
|
519
|
+
throw new Error(`Failed to load PDF from ${url}`);
|
|
520
|
+
}
|
|
521
|
+
const blob = response.blob;
|
|
522
|
+
const mimeType2 = responseMimeType || "application/pdf";
|
|
523
|
+
const pdfData = await this.blobToBase64DataURL(blob, mimeType2);
|
|
524
|
+
return {
|
|
525
|
+
text: undefined,
|
|
526
|
+
json: undefined,
|
|
527
|
+
csv: undefined,
|
|
528
|
+
image: undefined,
|
|
529
|
+
pdf: pdfData,
|
|
530
|
+
size: blob.size,
|
|
531
|
+
mimeType: mimeType2
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
const content = response.text || "";
|
|
535
|
+
if (!content) {
|
|
536
|
+
throw new Error(`Failed to load content from ${url}`);
|
|
537
|
+
}
|
|
538
|
+
const mimeType = responseMimeType || (detectedFormat === "markdown" ? "text/markdown" : detectedFormat === "html" ? "text/html" : "text/plain");
|
|
539
|
+
return {
|
|
540
|
+
text: content,
|
|
541
|
+
json: undefined,
|
|
542
|
+
csv: undefined,
|
|
543
|
+
image: undefined,
|
|
544
|
+
pdf: undefined,
|
|
545
|
+
size: content.length,
|
|
546
|
+
mimeType
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
detectResponseType(detectedFormat) {
|
|
550
|
+
let responseType = "text";
|
|
551
|
+
if (detectedFormat === "json") {
|
|
552
|
+
responseType = "json";
|
|
553
|
+
} else if (detectedFormat === "image" || detectedFormat === "pdf") {
|
|
554
|
+
responseType = "blob";
|
|
555
|
+
} else if (detectedFormat === "csv" || detectedFormat === "text" || detectedFormat === "markdown" || detectedFormat === "html") {
|
|
556
|
+
responseType = "text";
|
|
557
|
+
}
|
|
558
|
+
return responseType;
|
|
559
|
+
}
|
|
560
|
+
detectFormat(url, format) {
|
|
561
|
+
if (format === "auto") {
|
|
562
|
+
const urlLower = url.toLowerCase();
|
|
563
|
+
if (urlLower.endsWith(".md") || urlLower.endsWith(".markdown")) {
|
|
564
|
+
return "markdown";
|
|
565
|
+
} else if (urlLower.endsWith(".json")) {
|
|
566
|
+
return "json";
|
|
567
|
+
} else if (urlLower.endsWith(".csv")) {
|
|
568
|
+
return "csv";
|
|
569
|
+
} else if (urlLower.endsWith(".pdf")) {
|
|
570
|
+
return "pdf";
|
|
571
|
+
} else if (urlLower.match(/\.(jpg|jpeg|png|gif|bmp|webp|svg|ico)$/)) {
|
|
572
|
+
return "image";
|
|
573
|
+
} else if (urlLower.endsWith(".html") || urlLower.endsWith(".htm")) {
|
|
574
|
+
return "html";
|
|
575
|
+
} else {
|
|
576
|
+
return "text";
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
return format;
|
|
580
|
+
}
|
|
581
|
+
getImageMimeType(url) {
|
|
582
|
+
const urlLower = url.toLowerCase();
|
|
583
|
+
if (urlLower.endsWith(".png"))
|
|
584
|
+
return "image/png";
|
|
585
|
+
if (urlLower.endsWith(".jpg") || urlLower.endsWith(".jpeg"))
|
|
586
|
+
return "image/jpeg";
|
|
587
|
+
if (urlLower.endsWith(".gif"))
|
|
588
|
+
return "image/gif";
|
|
589
|
+
if (urlLower.endsWith(".webp"))
|
|
590
|
+
return "image/webp";
|
|
591
|
+
if (urlLower.endsWith(".bmp"))
|
|
592
|
+
return "image/bmp";
|
|
593
|
+
if (urlLower.endsWith(".svg"))
|
|
594
|
+
return "image/svg+xml";
|
|
595
|
+
if (urlLower.endsWith(".ico"))
|
|
596
|
+
return "image/x-icon";
|
|
597
|
+
return "image/jpeg";
|
|
598
|
+
}
|
|
599
|
+
async blobToBase64DataURL(blob, mimeType) {
|
|
600
|
+
if (typeof Buffer !== "undefined") {
|
|
601
|
+
const arrayBuffer = await blob.arrayBuffer();
|
|
602
|
+
const buffer = Buffer.from(arrayBuffer);
|
|
603
|
+
return `data:${mimeType};base64,${buffer.toString("base64")}`;
|
|
604
|
+
}
|
|
605
|
+
return new Promise((resolve, reject) => {
|
|
606
|
+
const reader = new FileReader;
|
|
607
|
+
reader.onloadend = () => {
|
|
608
|
+
const result = reader.result;
|
|
609
|
+
if (result.startsWith("data:;base64,")) {
|
|
610
|
+
resolve(`data:${mimeType};base64,${result.substring(13)}`);
|
|
611
|
+
} else {
|
|
612
|
+
resolve(result);
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
reader.onerror = reject;
|
|
616
|
+
reader.readAsDataURL(blob);
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
var fileLoader = (input, config) => {
|
|
621
|
+
return new FileLoaderTask({}, config).run(input);
|
|
622
|
+
};
|
|
623
|
+
Workflow2.prototype.fileLoader = CreateWorkflow2(FileLoaderTask);
|
|
624
|
+
|
|
625
|
+
// src/task/ArrayTask.ts
|
|
626
|
+
import {
|
|
627
|
+
uuid4
|
|
628
|
+
} from "@workglow/util";
|
|
629
|
+
import {
|
|
630
|
+
GraphAsTask,
|
|
631
|
+
GraphAsTaskRunner,
|
|
632
|
+
PROPERTY_ARRAY,
|
|
633
|
+
TaskGraph
|
|
634
|
+
} from "@workglow/task-graph";
|
|
635
|
+
var TypeReplicateArray = (type, annotations = {}) => ({
|
|
636
|
+
oneOf: [type, { type: "array", items: type }],
|
|
637
|
+
title: type.title,
|
|
638
|
+
description: type.description,
|
|
639
|
+
...type.format ? { format: type.format } : {},
|
|
640
|
+
...annotations,
|
|
641
|
+
"x-replicate": true
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
class ArrayTask extends GraphAsTask {
|
|
645
|
+
static type = "ArrayTask";
|
|
646
|
+
static compoundMerge = PROPERTY_ARRAY;
|
|
647
|
+
inputSchema() {
|
|
648
|
+
return this.constructor.inputSchema();
|
|
649
|
+
}
|
|
650
|
+
outputSchema() {
|
|
651
|
+
return this.constructor.outputSchema();
|
|
652
|
+
}
|
|
653
|
+
executeMerge(_input, output) {
|
|
654
|
+
return output;
|
|
655
|
+
}
|
|
656
|
+
regenerateGraph() {
|
|
657
|
+
const arrayInputs = new Map;
|
|
658
|
+
let hasArrayInputs = false;
|
|
659
|
+
const inputSchema3 = this.inputSchema();
|
|
660
|
+
if (typeof inputSchema3 !== "boolean") {
|
|
661
|
+
const keys = Object.keys(inputSchema3.properties || {});
|
|
662
|
+
for (const inputId of keys) {
|
|
663
|
+
const inputValue = this.runInputData[inputId];
|
|
664
|
+
const inputDef = inputSchema3.properties?.[inputId];
|
|
665
|
+
if (typeof inputDef === "object" && inputDef !== null && "x-replicate" in inputDef && inputDef["x-replicate"] === true && Array.isArray(inputValue) && inputValue.length > 1) {
|
|
666
|
+
arrayInputs.set(inputId, inputValue);
|
|
667
|
+
hasArrayInputs = true;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
this.subGraph = new TaskGraph;
|
|
672
|
+
if (!hasArrayInputs) {
|
|
673
|
+
super.regenerateGraph();
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
const inputIds = Array.from(arrayInputs.keys());
|
|
677
|
+
const inputObject = Object.fromEntries(arrayInputs);
|
|
678
|
+
const combinations = this.generateCombinations(inputObject, inputIds);
|
|
679
|
+
const tasks = combinations.map((combination) => {
|
|
680
|
+
const { id, name, ...rest } = this.config;
|
|
681
|
+
const task = new this.constructor({ ...this.defaults, ...this.runInputData, ...combination }, { ...rest, id: `${id}_${uuid4()}` });
|
|
682
|
+
return task;
|
|
683
|
+
});
|
|
684
|
+
this.subGraph.addTasks(tasks);
|
|
685
|
+
super.regenerateGraph();
|
|
686
|
+
}
|
|
687
|
+
generateCombinations(input, inputMakeArray) {
|
|
688
|
+
const arraysToCombine = inputMakeArray.map((key) => Array.isArray(input[key]) ? input[key] : []);
|
|
689
|
+
const indices = new Array(arraysToCombine.length).fill(0);
|
|
690
|
+
const combinations = [];
|
|
691
|
+
let done = false;
|
|
692
|
+
while (!done) {
|
|
693
|
+
combinations.push([...indices]);
|
|
694
|
+
for (let i = indices.length - 1;i >= 0; i--) {
|
|
695
|
+
if (++indices[i] < arraysToCombine[i].length)
|
|
696
|
+
break;
|
|
697
|
+
if (i === 0)
|
|
698
|
+
done = true;
|
|
699
|
+
else
|
|
700
|
+
indices[i] = 0;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
const combos = combinations.map((combination) => {
|
|
704
|
+
const result = { ...input };
|
|
705
|
+
combination.forEach((valueIndex, arrayIndex) => {
|
|
706
|
+
const key = inputMakeArray[arrayIndex];
|
|
707
|
+
if (Array.isArray(input[key]))
|
|
708
|
+
result[key] = input[key][valueIndex];
|
|
709
|
+
});
|
|
710
|
+
return result;
|
|
711
|
+
});
|
|
712
|
+
return combos;
|
|
713
|
+
}
|
|
714
|
+
toJSON() {
|
|
715
|
+
const { subgraph, ...result } = super.toJSON();
|
|
716
|
+
return result;
|
|
717
|
+
}
|
|
718
|
+
toDependencyJSON() {
|
|
719
|
+
const { subtasks, ...result } = super.toDependencyJSON();
|
|
720
|
+
return result;
|
|
721
|
+
}
|
|
722
|
+
get runner() {
|
|
723
|
+
if (!this._runner) {
|
|
724
|
+
this._runner = new ArrayTaskRunner(this);
|
|
725
|
+
}
|
|
726
|
+
return this._runner;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
class ArrayTaskRunner extends GraphAsTaskRunner {
|
|
731
|
+
async executeTaskChildren(_input) {
|
|
732
|
+
return super.executeTaskChildren({});
|
|
733
|
+
}
|
|
734
|
+
async executeTaskReactive(input, output) {
|
|
735
|
+
await super.executeTaskReactive(input, output);
|
|
736
|
+
if (this.task.hasChildren()) {
|
|
737
|
+
this.task.runOutputData = this.task.executeMerge(input, this.task.runOutputData);
|
|
738
|
+
}
|
|
739
|
+
return this.task.runOutputData;
|
|
740
|
+
}
|
|
741
|
+
async executeTask(input) {
|
|
742
|
+
await super.executeTask(input);
|
|
743
|
+
if (this.task.hasChildren()) {
|
|
744
|
+
this.task.runOutputData = this.task.executeMerge(input, this.task.runOutputData);
|
|
745
|
+
}
|
|
746
|
+
return this.task.runOutputData;
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
// src/task/DebugLogTask.ts
|
|
750
|
+
import { CreateWorkflow as CreateWorkflow3, Task as Task2, Workflow as Workflow3 } from "@workglow/task-graph";
|
|
751
|
+
var log_levels = ["dir", "log", "debug", "info", "warn", "error"];
|
|
752
|
+
var DEFAULT_LOG_LEVEL = "log";
|
|
753
|
+
var inputSchema3 = {
|
|
754
|
+
type: "object",
|
|
755
|
+
properties: {
|
|
756
|
+
console: {
|
|
757
|
+
title: "Message",
|
|
758
|
+
description: "The message to log"
|
|
759
|
+
},
|
|
760
|
+
log_level: {
|
|
761
|
+
type: "string",
|
|
762
|
+
enum: log_levels,
|
|
763
|
+
title: "Log Level",
|
|
764
|
+
description: "The log level to use",
|
|
765
|
+
default: DEFAULT_LOG_LEVEL
|
|
766
|
+
}
|
|
767
|
+
},
|
|
768
|
+
additionalProperties: false
|
|
769
|
+
};
|
|
770
|
+
var outputSchema3 = {
|
|
771
|
+
type: "object",
|
|
772
|
+
properties: {
|
|
773
|
+
console: {
|
|
774
|
+
title: "Messages",
|
|
775
|
+
description: "The messages logged by the task"
|
|
776
|
+
}
|
|
777
|
+
},
|
|
778
|
+
additionalProperties: false
|
|
779
|
+
};
|
|
780
|
+
|
|
781
|
+
class DebugLogTask extends Task2 {
|
|
782
|
+
static type = "DebugLogTask";
|
|
783
|
+
static category = "Utility";
|
|
784
|
+
static title = "Debug Log";
|
|
785
|
+
static description = "Logs messages to the console with configurable log levels for debugging task graphs";
|
|
786
|
+
static cacheable = false;
|
|
787
|
+
static inputSchema() {
|
|
788
|
+
return inputSchema3;
|
|
789
|
+
}
|
|
790
|
+
static outputSchema() {
|
|
791
|
+
return outputSchema3;
|
|
792
|
+
}
|
|
793
|
+
async executeReactive(input, output) {
|
|
794
|
+
const { log_level = DEFAULT_LOG_LEVEL, console: messages } = input;
|
|
795
|
+
if (log_level == "dir") {
|
|
796
|
+
console.dir(messages, { depth: null });
|
|
797
|
+
} else {
|
|
798
|
+
console[log_level](messages);
|
|
799
|
+
}
|
|
800
|
+
output.console = input.console;
|
|
801
|
+
return output;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
var debugLog = (input, config = {}) => {
|
|
805
|
+
const task = new DebugLogTask({}, config);
|
|
806
|
+
return task.run(input);
|
|
807
|
+
};
|
|
808
|
+
Workflow3.prototype.debugLog = CreateWorkflow3(DebugLogTask);
|
|
809
|
+
// src/task/DelayTask.ts
|
|
810
|
+
import {
|
|
811
|
+
CreateWorkflow as CreateWorkflow4,
|
|
812
|
+
Task as Task3,
|
|
813
|
+
TaskAbortedError as TaskAbortedError2,
|
|
814
|
+
Workflow as Workflow4
|
|
815
|
+
} from "@workglow/task-graph";
|
|
816
|
+
import { sleep } from "@workglow/util";
|
|
817
|
+
var inputSchema4 = {
|
|
818
|
+
type: "object",
|
|
819
|
+
properties: {
|
|
820
|
+
delay: {
|
|
821
|
+
type: "number",
|
|
822
|
+
title: "Delay (ms)",
|
|
823
|
+
default: 1
|
|
824
|
+
},
|
|
825
|
+
pass_through: {
|
|
826
|
+
title: "Pass Through",
|
|
827
|
+
description: "Pass through data to the output"
|
|
828
|
+
}
|
|
829
|
+
},
|
|
830
|
+
additionalProperties: false
|
|
831
|
+
};
|
|
832
|
+
var outputSchema4 = {
|
|
833
|
+
type: "object",
|
|
834
|
+
properties: {},
|
|
835
|
+
additionalProperties: true
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
class DelayTask extends Task3 {
|
|
839
|
+
static type = "DelayTask";
|
|
840
|
+
static category = "Utility";
|
|
841
|
+
static title = "Delay";
|
|
842
|
+
static description = "Delays execution for a specified duration with progress tracking";
|
|
843
|
+
static inputSchema() {
|
|
844
|
+
return inputSchema4;
|
|
845
|
+
}
|
|
846
|
+
static outputSchema() {
|
|
847
|
+
return outputSchema4;
|
|
848
|
+
}
|
|
849
|
+
async execute(input, executeContext) {
|
|
850
|
+
const delay = input.delay ?? 0;
|
|
851
|
+
if (delay > 100) {
|
|
852
|
+
const iterations = Math.min(100, Math.floor(delay / 16));
|
|
853
|
+
const chunkSize = delay / iterations;
|
|
854
|
+
for (let i = 0;i < iterations; i++) {
|
|
855
|
+
if (executeContext.signal.aborted) {
|
|
856
|
+
throw new TaskAbortedError2("Task aborted");
|
|
857
|
+
}
|
|
858
|
+
await sleep(chunkSize);
|
|
859
|
+
await executeContext.updateProgress(100 * i / iterations, `Delaying for ${delay}ms`);
|
|
860
|
+
}
|
|
861
|
+
} else {
|
|
862
|
+
await sleep(delay);
|
|
863
|
+
}
|
|
864
|
+
return input.pass_through;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
var delay = (input, config = {}) => {
|
|
868
|
+
const task = new DelayTask({}, config);
|
|
869
|
+
return task.run(input);
|
|
870
|
+
};
|
|
871
|
+
Workflow4.prototype.delay = CreateWorkflow4(DelayTask);
|
|
872
|
+
// src/task/InputTask.ts
|
|
873
|
+
import { CreateWorkflow as CreateWorkflow5, Task as Task4, Workflow as Workflow5 } from "@workglow/task-graph";
|
|
874
|
+
|
|
875
|
+
class InputTask extends Task4 {
|
|
876
|
+
static type = "InputTask";
|
|
877
|
+
static category = "Flow Control";
|
|
878
|
+
static title = "Input";
|
|
879
|
+
static description = "Starts the workflow";
|
|
880
|
+
static hasDynamicSchemas = true;
|
|
881
|
+
static cacheable = false;
|
|
882
|
+
static inputSchema() {
|
|
883
|
+
return {
|
|
884
|
+
type: "object",
|
|
885
|
+
properties: {},
|
|
886
|
+
additionalProperties: true
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
static outputSchema() {
|
|
890
|
+
return {
|
|
891
|
+
type: "object",
|
|
892
|
+
properties: {},
|
|
893
|
+
additionalProperties: true
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
inputSchema() {
|
|
897
|
+
return this.config?.extras?.inputSchema ?? this.constructor.inputSchema();
|
|
898
|
+
}
|
|
899
|
+
outputSchema() {
|
|
900
|
+
return this.config?.extras?.outputSchema ?? this.constructor.outputSchema();
|
|
901
|
+
}
|
|
902
|
+
async execute(input) {
|
|
903
|
+
return input;
|
|
904
|
+
}
|
|
905
|
+
async executeReactive(input) {
|
|
906
|
+
return input;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
Workflow5.prototype.input = CreateWorkflow5(InputTask);
|
|
910
|
+
// src/task/JavaScriptTask.ts
|
|
911
|
+
import { CreateWorkflow as CreateWorkflow6, Task as Task5, Workflow as Workflow6 } from "@workglow/task-graph";
|
|
912
|
+
|
|
913
|
+
// src/util/acorn.js
|
|
914
|
+
var options;
|
|
915
|
+
var input = "";
|
|
916
|
+
var inputLen;
|
|
917
|
+
var sourceFile;
|
|
918
|
+
var parse = function(inpt, opts) {
|
|
919
|
+
input = String(inpt);
|
|
920
|
+
inputLen = input.length;
|
|
921
|
+
setOptions(opts);
|
|
922
|
+
initTokenState();
|
|
923
|
+
return parseTopLevel(options.program);
|
|
924
|
+
};
|
|
925
|
+
var defaultOptions = {
|
|
926
|
+
strictSemicolons: false,
|
|
927
|
+
allowTrailingCommas: true,
|
|
928
|
+
forbidReserved: false,
|
|
929
|
+
allowReturnOutsideFunction: false,
|
|
930
|
+
locations: false,
|
|
931
|
+
onComment: null,
|
|
932
|
+
ranges: false,
|
|
933
|
+
program: null,
|
|
934
|
+
sourceFile: null,
|
|
935
|
+
directSourceFile: null
|
|
936
|
+
};
|
|
937
|
+
function setOptions(opts) {
|
|
938
|
+
options = opts || {};
|
|
939
|
+
for (var opt in defaultOptions) {
|
|
940
|
+
if (!Object.prototype.hasOwnProperty.call(options, opt)) {
|
|
941
|
+
options[opt] = defaultOptions[opt];
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
sourceFile = options.sourceFile;
|
|
945
|
+
}
|
|
946
|
+
var getLineInfo = function(input2, offset) {
|
|
947
|
+
for (var line = 1, cur = 0;; ) {
|
|
948
|
+
lineBreak.lastIndex = cur;
|
|
949
|
+
var match = lineBreak.exec(input2);
|
|
950
|
+
if (match && match.index < offset) {
|
|
951
|
+
++line;
|
|
952
|
+
cur = match.index + match[0].length;
|
|
953
|
+
} else {
|
|
954
|
+
break;
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
return { line, column: offset - cur };
|
|
958
|
+
};
|
|
959
|
+
var tokPos = 0;
|
|
960
|
+
var tokStart = 0;
|
|
961
|
+
var tokEnd = 0;
|
|
962
|
+
var tokStartLoc;
|
|
963
|
+
var tokEndLoc;
|
|
964
|
+
var tokType;
|
|
965
|
+
var tokVal;
|
|
966
|
+
var tokRegexpAllowed;
|
|
967
|
+
var tokCurLine;
|
|
968
|
+
var tokLineStart;
|
|
969
|
+
var lastStart = 0;
|
|
970
|
+
var lastEnd = 0;
|
|
971
|
+
var lastEndLoc;
|
|
972
|
+
var inFunction;
|
|
973
|
+
var labels;
|
|
974
|
+
var strict;
|
|
975
|
+
function raise(pos, message) {
|
|
976
|
+
var loc = getLineInfo(input, pos);
|
|
977
|
+
message += " (" + loc.line + ":" + loc.column + ")";
|
|
978
|
+
var err = new SyntaxError(message);
|
|
979
|
+
err.pos = pos;
|
|
980
|
+
err.loc = loc;
|
|
981
|
+
err.raisedAt = tokPos;
|
|
516
982
|
throw err;
|
|
517
983
|
}
|
|
518
984
|
var empty = [];
|
|
@@ -4905,7 +5371,7 @@ Interpreter["VALUE_IN_DESCRIPTOR"] = Interpreter.VALUE_IN_DESCRIPTOR;
|
|
|
4905
5371
|
Interpreter["Status"] = Interpreter.Status;
|
|
4906
5372
|
|
|
4907
5373
|
// src/task/JavaScriptTask.ts
|
|
4908
|
-
var
|
|
5374
|
+
var inputSchema5 = {
|
|
4909
5375
|
type: "object",
|
|
4910
5376
|
properties: {
|
|
4911
5377
|
javascript_code: {
|
|
@@ -4919,7 +5385,7 @@ var inputSchema4 = {
|
|
|
4919
5385
|
required: ["javascript_code"],
|
|
4920
5386
|
additionalProperties: true
|
|
4921
5387
|
};
|
|
4922
|
-
var
|
|
5388
|
+
var outputSchema5 = {
|
|
4923
5389
|
type: "object",
|
|
4924
5390
|
properties: {
|
|
4925
5391
|
output: {
|
|
@@ -4931,16 +5397,16 @@ var outputSchema4 = {
|
|
|
4931
5397
|
additionalProperties: false
|
|
4932
5398
|
};
|
|
4933
5399
|
|
|
4934
|
-
class JavaScriptTask extends
|
|
5400
|
+
class JavaScriptTask extends Task5 {
|
|
4935
5401
|
static type = "JavaScriptTask";
|
|
4936
5402
|
static category = "Utility";
|
|
4937
5403
|
static title = "JavaScript Interpreter";
|
|
4938
5404
|
static description = "Executes JavaScript code in a sandboxed interpreter environment";
|
|
4939
5405
|
static inputSchema() {
|
|
4940
|
-
return
|
|
5406
|
+
return inputSchema5;
|
|
4941
5407
|
}
|
|
4942
5408
|
static outputSchema() {
|
|
4943
|
-
return
|
|
5409
|
+
return outputSchema5;
|
|
4944
5410
|
}
|
|
4945
5411
|
async executeReactive(input2, output) {
|
|
4946
5412
|
if (input2.javascript_code) {
|
|
@@ -4959,22 +5425,20 @@ class JavaScriptTask extends Task3 {
|
|
|
4959
5425
|
return output;
|
|
4960
5426
|
}
|
|
4961
5427
|
}
|
|
4962
|
-
TaskRegistry4.registerTask(JavaScriptTask);
|
|
4963
5428
|
var javaScript = (input2, config = {}) => {
|
|
4964
|
-
return new JavaScriptTask(
|
|
5429
|
+
return new JavaScriptTask({}, config).run(input2);
|
|
4965
5430
|
};
|
|
4966
|
-
|
|
5431
|
+
Workflow6.prototype.javaScript = CreateWorkflow6(JavaScriptTask);
|
|
4967
5432
|
// src/task/JsonTask.ts
|
|
4968
5433
|
import {
|
|
4969
5434
|
createGraphFromDependencyJSON,
|
|
4970
|
-
CreateWorkflow as
|
|
5435
|
+
CreateWorkflow as CreateWorkflow7,
|
|
4971
5436
|
Dataflow,
|
|
4972
|
-
GraphAsTask,
|
|
5437
|
+
GraphAsTask as GraphAsTask2,
|
|
4973
5438
|
TaskConfigurationError as TaskConfigurationError2,
|
|
4974
|
-
|
|
4975
|
-
Workflow as Workflow5
|
|
5439
|
+
Workflow as Workflow7
|
|
4976
5440
|
} from "@workglow/task-graph";
|
|
4977
|
-
var
|
|
5441
|
+
var inputSchema6 = {
|
|
4978
5442
|
type: "object",
|
|
4979
5443
|
properties: {
|
|
4980
5444
|
json: {
|
|
@@ -4985,7 +5449,7 @@ var inputSchema5 = {
|
|
|
4985
5449
|
},
|
|
4986
5450
|
additionalProperties: false
|
|
4987
5451
|
};
|
|
4988
|
-
var
|
|
5452
|
+
var outputSchema6 = {
|
|
4989
5453
|
type: "object",
|
|
4990
5454
|
properties: {
|
|
4991
5455
|
output: {
|
|
@@ -4996,14 +5460,16 @@ var outputSchema5 = {
|
|
|
4996
5460
|
additionalProperties: false
|
|
4997
5461
|
};
|
|
4998
5462
|
|
|
4999
|
-
class JsonTask extends
|
|
5463
|
+
class JsonTask extends GraphAsTask2 {
|
|
5000
5464
|
static type = "JsonTask";
|
|
5001
5465
|
static category = "Hidden";
|
|
5466
|
+
static title = "JSON Task";
|
|
5467
|
+
static description = "A task that creates and manages task graphs from JSON configurations";
|
|
5002
5468
|
static inputSchema() {
|
|
5003
|
-
return
|
|
5469
|
+
return inputSchema6;
|
|
5004
5470
|
}
|
|
5005
5471
|
static outputSchema() {
|
|
5006
|
-
return
|
|
5472
|
+
return outputSchema6;
|
|
5007
5473
|
}
|
|
5008
5474
|
regenerateGraph() {
|
|
5009
5475
|
if (!this.runInputData.json)
|
|
@@ -5031,21 +5497,19 @@ class JsonTask extends GraphAsTask {
|
|
|
5031
5497
|
super.regenerateGraph();
|
|
5032
5498
|
}
|
|
5033
5499
|
}
|
|
5034
|
-
TaskRegistry5.registerTask(JsonTask);
|
|
5035
5500
|
var json = (input2, config = {}) => {
|
|
5036
|
-
return new JsonTask(
|
|
5501
|
+
return new JsonTask({}, config).run(input2);
|
|
5037
5502
|
};
|
|
5038
|
-
|
|
5503
|
+
Workflow7.prototype.json = CreateWorkflow7(JsonTask);
|
|
5039
5504
|
// src/task/LambdaTask.ts
|
|
5040
5505
|
import {
|
|
5041
|
-
CreateWorkflow as
|
|
5506
|
+
CreateWorkflow as CreateWorkflow8,
|
|
5042
5507
|
DATAFLOW_ALL_PORTS,
|
|
5043
|
-
Task as
|
|
5508
|
+
Task as Task6,
|
|
5044
5509
|
TaskConfigurationError as TaskConfigurationError3,
|
|
5045
|
-
|
|
5046
|
-
Workflow as Workflow6
|
|
5510
|
+
Workflow as Workflow8
|
|
5047
5511
|
} from "@workglow/task-graph";
|
|
5048
|
-
var
|
|
5512
|
+
var inputSchema7 = {
|
|
5049
5513
|
type: "object",
|
|
5050
5514
|
properties: {
|
|
5051
5515
|
[DATAFLOW_ALL_PORTS]: {
|
|
@@ -5055,7 +5519,7 @@ var inputSchema6 = {
|
|
|
5055
5519
|
},
|
|
5056
5520
|
additionalProperties: true
|
|
5057
5521
|
};
|
|
5058
|
-
var
|
|
5522
|
+
var outputSchema7 = {
|
|
5059
5523
|
type: "object",
|
|
5060
5524
|
properties: {
|
|
5061
5525
|
[DATAFLOW_ALL_PORTS]: {
|
|
@@ -5066,15 +5530,17 @@ var outputSchema6 = {
|
|
|
5066
5530
|
additionalProperties: true
|
|
5067
5531
|
};
|
|
5068
5532
|
|
|
5069
|
-
class LambdaTask extends
|
|
5533
|
+
class LambdaTask extends Task6 {
|
|
5070
5534
|
static type = "LambdaTask";
|
|
5535
|
+
static title = "Lambda Task";
|
|
5536
|
+
static description = "A task that wraps a provided function and its input";
|
|
5071
5537
|
static category = "Hidden";
|
|
5072
5538
|
static cacheable = true;
|
|
5073
5539
|
static inputSchema() {
|
|
5074
|
-
return
|
|
5540
|
+
return inputSchema7;
|
|
5075
5541
|
}
|
|
5076
5542
|
static outputSchema() {
|
|
5077
|
-
return
|
|
5543
|
+
return outputSchema7;
|
|
5078
5544
|
}
|
|
5079
5545
|
constructor(input2 = {}, config = {}) {
|
|
5080
5546
|
if (!config.execute && !config.executeReactive) {
|
|
@@ -5095,7 +5561,6 @@ class LambdaTask extends Task4 {
|
|
|
5095
5561
|
return output;
|
|
5096
5562
|
}
|
|
5097
5563
|
}
|
|
5098
|
-
TaskRegistry6.registerTask(LambdaTask);
|
|
5099
5564
|
function process(value) {
|
|
5100
5565
|
if (typeof value === "string")
|
|
5101
5566
|
return `Processed: ${value}`;
|
|
@@ -5113,20 +5578,15 @@ function lambda(input2, config) {
|
|
|
5113
5578
|
const task = new LambdaTask(input2, config);
|
|
5114
5579
|
return task.run();
|
|
5115
5580
|
}
|
|
5116
|
-
|
|
5581
|
+
Workflow8.prototype.lambda = CreateWorkflow8(LambdaTask);
|
|
5117
5582
|
// src/task/MergeTask.ts
|
|
5118
|
-
import {
|
|
5119
|
-
|
|
5120
|
-
Task as Task5,
|
|
5121
|
-
TaskRegistry as TaskRegistry7,
|
|
5122
|
-
Workflow as Workflow7
|
|
5123
|
-
} from "@workglow/task-graph";
|
|
5124
|
-
var inputSchema7 = {
|
|
5583
|
+
import { CreateWorkflow as CreateWorkflow9, Task as Task7, Workflow as Workflow9 } from "@workglow/task-graph";
|
|
5584
|
+
var inputSchema8 = {
|
|
5125
5585
|
type: "object",
|
|
5126
5586
|
properties: {},
|
|
5127
5587
|
additionalProperties: true
|
|
5128
5588
|
};
|
|
5129
|
-
var
|
|
5589
|
+
var outputSchema8 = {
|
|
5130
5590
|
type: "object",
|
|
5131
5591
|
properties: {
|
|
5132
5592
|
output: {
|
|
@@ -5138,390 +5598,147 @@ var outputSchema7 = {
|
|
|
5138
5598
|
additionalProperties: false
|
|
5139
5599
|
};
|
|
5140
5600
|
|
|
5141
|
-
class MergeTask extends
|
|
5601
|
+
class MergeTask extends Task7 {
|
|
5142
5602
|
static type = "MergeTask";
|
|
5143
5603
|
static category = "Utility";
|
|
5144
|
-
static title = "Merge";
|
|
5145
|
-
static description = "Merges multiple inputs into a single array output";
|
|
5146
|
-
static cacheable = true;
|
|
5147
|
-
static inputSchema() {
|
|
5148
|
-
return inputSchema7;
|
|
5149
|
-
}
|
|
5150
|
-
static outputSchema() {
|
|
5151
|
-
return outputSchema7;
|
|
5152
|
-
}
|
|
5153
|
-
async execute(input2, context) {
|
|
5154
|
-
const keys = Object.keys(input2).sort();
|
|
5155
|
-
const values = keys.map((key) => input2[key]);
|
|
5156
|
-
return {
|
|
5157
|
-
output: values
|
|
5158
|
-
};
|
|
5159
|
-
}
|
|
5160
|
-
}
|
|
5161
|
-
TaskRegistry7.registerTask(MergeTask);
|
|
5162
|
-
var merge = (input2, config = {}) => {
|
|
5163
|
-
const task = new MergeTask(input2, config);
|
|
5164
|
-
return task.run();
|
|
5165
|
-
};
|
|
5166
|
-
Workflow7.prototype.merge = CreateWorkflow7(MergeTask);
|
|
5167
|
-
// src/task/SplitTask.ts
|
|
5168
|
-
import { CreateWorkflow as CreateWorkflow8, Task as Task6, TaskRegistry as TaskRegistry8, Workflow as Workflow8 } from "@workglow/task-graph";
|
|
5169
|
-
var inputSchema8 = {
|
|
5170
|
-
type: "object",
|
|
5171
|
-
properties: {
|
|
5172
|
-
input: {
|
|
5173
|
-
title: "Single Input",
|
|
5174
|
-
description: "A single value to output"
|
|
5175
|
-
}
|
|
5176
|
-
},
|
|
5177
|
-
additionalProperties: false
|
|
5178
|
-
};
|
|
5179
|
-
var outputSchema8 = {
|
|
5180
|
-
type: "object",
|
|
5181
|
-
properties: {},
|
|
5182
|
-
additionalProperties: true
|
|
5183
|
-
};
|
|
5184
|
-
|
|
5185
|
-
class SplitTask extends Task6 {
|
|
5186
|
-
static type = "SplitTask";
|
|
5187
|
-
static category = "Utility";
|
|
5188
|
-
static title = "Split";
|
|
5189
|
-
static description = "Splits an array into individual outputs, creating one output per element";
|
|
5190
|
-
static hasDynamicSchemas = true;
|
|
5191
|
-
static cacheable = false;
|
|
5192
|
-
static inputSchema() {
|
|
5193
|
-
return inputSchema8;
|
|
5194
|
-
}
|
|
5195
|
-
static outputSchema() {
|
|
5196
|
-
return outputSchema8;
|
|
5197
|
-
}
|
|
5198
|
-
outputSchema() {
|
|
5199
|
-
return outputSchema8;
|
|
5200
|
-
}
|
|
5201
|
-
async executeReactive(input2) {
|
|
5202
|
-
const inputValue = input2.input;
|
|
5203
|
-
const output = {};
|
|
5204
|
-
if (Array.isArray(inputValue)) {
|
|
5205
|
-
inputValue.forEach((item, index) => {
|
|
5206
|
-
output[`output_${index}`] = item;
|
|
5207
|
-
});
|
|
5208
|
-
} else {
|
|
5209
|
-
output.output_0 = inputValue;
|
|
5210
|
-
}
|
|
5211
|
-
return output;
|
|
5212
|
-
}
|
|
5213
|
-
}
|
|
5214
|
-
TaskRegistry8.registerTask(SplitTask);
|
|
5215
|
-
var split = (input2, config = {}) => {
|
|
5216
|
-
const task = new SplitTask(input2, config);
|
|
5217
|
-
return task.run();
|
|
5218
|
-
};
|
|
5219
|
-
Workflow8.prototype.split = CreateWorkflow8(SplitTask);
|
|
5220
|
-
// src/task/FileLoaderTask.ts
|
|
5221
|
-
import {
|
|
5222
|
-
CreateWorkflow as CreateWorkflow9,
|
|
5223
|
-
Task as Task7,
|
|
5224
|
-
TaskAbortedError as TaskAbortedError2,
|
|
5225
|
-
TaskRegistry as TaskRegistry9,
|
|
5226
|
-
Workflow as Workflow9
|
|
5227
|
-
} from "@workglow/task-graph";
|
|
5228
|
-
import { parse as parse2 } from "csv-parse/sync";
|
|
5229
|
-
var inputSchema9 = {
|
|
5230
|
-
type: "object",
|
|
5231
|
-
properties: {
|
|
5232
|
-
url: {
|
|
5233
|
-
type: "string",
|
|
5234
|
-
title: "URL",
|
|
5235
|
-
description: "URL to load document from (http://, https://)",
|
|
5236
|
-
format: "uri"
|
|
5237
|
-
},
|
|
5238
|
-
format: {
|
|
5239
|
-
type: "string",
|
|
5240
|
-
enum: ["text", "markdown", "json", "csv", "pdf", "image", "html", "auto"],
|
|
5241
|
-
title: "Format",
|
|
5242
|
-
description: "File format (auto-detected from URL if 'auto')",
|
|
5243
|
-
default: "auto"
|
|
5244
|
-
}
|
|
5245
|
-
},
|
|
5246
|
-
required: ["url"],
|
|
5247
|
-
additionalProperties: false
|
|
5248
|
-
};
|
|
5249
|
-
var outputSchema9 = {
|
|
5250
|
-
type: "object",
|
|
5251
|
-
properties: {
|
|
5252
|
-
text: {
|
|
5253
|
-
type: "string",
|
|
5254
|
-
title: "Text",
|
|
5255
|
-
description: "Text content (for text, markdown, html formats)"
|
|
5256
|
-
},
|
|
5257
|
-
json: {
|
|
5258
|
-
title: "JSON",
|
|
5259
|
-
description: "Parsed JSON object or array"
|
|
5260
|
-
},
|
|
5261
|
-
csv: {
|
|
5262
|
-
type: "array",
|
|
5263
|
-
title: "CSV",
|
|
5264
|
-
description: "Parsed CSV data as array of objects"
|
|
5265
|
-
},
|
|
5266
|
-
image: {
|
|
5267
|
-
type: "string",
|
|
5268
|
-
title: "Image",
|
|
5269
|
-
description: "Base64 data URL for image files",
|
|
5270
|
-
format: "image:data-uri"
|
|
5271
|
-
},
|
|
5272
|
-
pdf: {
|
|
5273
|
-
type: "string",
|
|
5274
|
-
title: "PDF",
|
|
5275
|
-
description: "Base64 data URL for PDF files"
|
|
5276
|
-
},
|
|
5277
|
-
metadata: {
|
|
5278
|
-
type: "object",
|
|
5279
|
-
properties: {
|
|
5280
|
-
url: { type: "string" },
|
|
5281
|
-
format: { type: "string" },
|
|
5282
|
-
size: { type: "number" },
|
|
5283
|
-
title: { type: "string" },
|
|
5284
|
-
mimeType: { type: "string" }
|
|
5285
|
-
},
|
|
5286
|
-
additionalProperties: false,
|
|
5287
|
-
title: "Metadata",
|
|
5288
|
-
description: "File metadata"
|
|
5289
|
-
}
|
|
5290
|
-
},
|
|
5291
|
-
required: ["metadata"],
|
|
5292
|
-
additionalProperties: false
|
|
5293
|
-
};
|
|
5294
|
-
|
|
5295
|
-
class FileLoaderTask extends Task7 {
|
|
5296
|
-
static type = "FileLoaderTask";
|
|
5297
|
-
static category = "Document";
|
|
5298
|
-
static title = "File Loader";
|
|
5299
|
-
static description = "Load documents from URLs (http://, https://)";
|
|
5604
|
+
static title = "Merge";
|
|
5605
|
+
static description = "Merges multiple inputs into a single array output";
|
|
5300
5606
|
static cacheable = true;
|
|
5301
5607
|
static inputSchema() {
|
|
5302
|
-
return
|
|
5608
|
+
return inputSchema8;
|
|
5303
5609
|
}
|
|
5304
5610
|
static outputSchema() {
|
|
5305
|
-
return
|
|
5611
|
+
return outputSchema8;
|
|
5306
5612
|
}
|
|
5307
5613
|
async execute(input2, context) {
|
|
5308
|
-
const
|
|
5309
|
-
|
|
5310
|
-
throw new TaskAbortedError2("Task aborted");
|
|
5311
|
-
}
|
|
5312
|
-
await context.updateProgress(0, "Detecting file format");
|
|
5313
|
-
const detectedFormat = this.detectFormat(url, format);
|
|
5314
|
-
const responseType = this.detectResponseType(detectedFormat);
|
|
5315
|
-
if (context.signal.aborted) {
|
|
5316
|
-
throw new TaskAbortedError2("Task aborted");
|
|
5317
|
-
}
|
|
5318
|
-
await context.updateProgress(10, `Fetching ${detectedFormat} file from ${url}`);
|
|
5319
|
-
const fetchTask = context.own(new FetchUrlTask({
|
|
5320
|
-
url,
|
|
5321
|
-
response_type: responseType,
|
|
5322
|
-
queue: false
|
|
5323
|
-
}));
|
|
5324
|
-
const response = await fetchTask.run();
|
|
5325
|
-
if (context.signal.aborted) {
|
|
5326
|
-
throw new TaskAbortedError2("Task aborted");
|
|
5327
|
-
}
|
|
5328
|
-
await context.updateProgress(60, "Parsing file content");
|
|
5329
|
-
const title = url.split("/").pop() || url;
|
|
5330
|
-
const { text, json: json2, csv, image, pdf, size, mimeType } = await this.parseResponse(response, url, detectedFormat);
|
|
5331
|
-
if (context.signal.aborted) {
|
|
5332
|
-
throw new TaskAbortedError2("Task aborted");
|
|
5333
|
-
}
|
|
5334
|
-
await context.updateProgress(100, "File loaded successfully");
|
|
5614
|
+
const keys = Object.keys(input2).sort();
|
|
5615
|
+
const values = keys.map((key) => input2[key]);
|
|
5335
5616
|
return {
|
|
5336
|
-
|
|
5337
|
-
json: json2,
|
|
5338
|
-
csv,
|
|
5339
|
-
image,
|
|
5340
|
-
pdf,
|
|
5341
|
-
metadata: {
|
|
5342
|
-
url,
|
|
5343
|
-
format: detectedFormat,
|
|
5344
|
-
size,
|
|
5345
|
-
title,
|
|
5346
|
-
mimeType
|
|
5347
|
-
}
|
|
5617
|
+
output: values
|
|
5348
5618
|
};
|
|
5349
5619
|
}
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
}
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5620
|
+
}
|
|
5621
|
+
var merge = (input2, config = {}) => {
|
|
5622
|
+
const task = new MergeTask({}, config);
|
|
5623
|
+
return task.run(input2);
|
|
5624
|
+
};
|
|
5625
|
+
Workflow9.prototype.merge = CreateWorkflow9(MergeTask);
|
|
5626
|
+
// src/task/OutputTask.ts
|
|
5627
|
+
import { CreateWorkflow as CreateWorkflow10, Task as Task8, Workflow as Workflow10 } from "@workglow/task-graph";
|
|
5628
|
+
|
|
5629
|
+
class OutputTask extends Task8 {
|
|
5630
|
+
static type = "OutputTask";
|
|
5631
|
+
static category = "Flow Control";
|
|
5632
|
+
static title = "Output";
|
|
5633
|
+
static description = "Ends the workflow";
|
|
5634
|
+
static hasDynamicSchemas = true;
|
|
5635
|
+
static cacheable = false;
|
|
5636
|
+
static inputSchema() {
|
|
5637
|
+
return {
|
|
5638
|
+
type: "object",
|
|
5639
|
+
properties: {},
|
|
5640
|
+
additionalProperties: true
|
|
5641
|
+
};
|
|
5363
5642
|
}
|
|
5364
|
-
|
|
5365
|
-
const responseMimeType = response.metadata?.contentType || "";
|
|
5366
|
-
if (detectedFormat === "json") {
|
|
5367
|
-
if (!response.json) {
|
|
5368
|
-
throw new Error(`Failed to load JSON from ${url}`);
|
|
5369
|
-
}
|
|
5370
|
-
const jsonData = response.json;
|
|
5371
|
-
const content2 = JSON.stringify(jsonData, null, 2);
|
|
5372
|
-
return {
|
|
5373
|
-
text: undefined,
|
|
5374
|
-
json: jsonData,
|
|
5375
|
-
csv: undefined,
|
|
5376
|
-
image: undefined,
|
|
5377
|
-
pdf: undefined,
|
|
5378
|
-
size: content2.length,
|
|
5379
|
-
mimeType: responseMimeType || "application/json"
|
|
5380
|
-
};
|
|
5381
|
-
}
|
|
5382
|
-
if (detectedFormat === "csv") {
|
|
5383
|
-
const content2 = response.text || "";
|
|
5384
|
-
if (!content2) {
|
|
5385
|
-
throw new Error(`Failed to load CSV from ${url}`);
|
|
5386
|
-
}
|
|
5387
|
-
const csvData = this.parseCsvContent(content2);
|
|
5388
|
-
return {
|
|
5389
|
-
text: undefined,
|
|
5390
|
-
json: undefined,
|
|
5391
|
-
csv: csvData,
|
|
5392
|
-
image: undefined,
|
|
5393
|
-
pdf: undefined,
|
|
5394
|
-
size: content2.length,
|
|
5395
|
-
mimeType: responseMimeType || "text/csv"
|
|
5396
|
-
};
|
|
5397
|
-
}
|
|
5398
|
-
if (detectedFormat === "image") {
|
|
5399
|
-
if (!response.blob) {
|
|
5400
|
-
throw new Error(`Failed to load image from ${url}`);
|
|
5401
|
-
}
|
|
5402
|
-
const blob = response.blob;
|
|
5403
|
-
const mimeType2 = responseMimeType || (blob.type && blob.type !== "" ? blob.type : this.getImageMimeType(url));
|
|
5404
|
-
const imageData = await this.blobToBase64DataURL(blob, mimeType2);
|
|
5405
|
-
return {
|
|
5406
|
-
text: undefined,
|
|
5407
|
-
json: undefined,
|
|
5408
|
-
csv: undefined,
|
|
5409
|
-
image: imageData,
|
|
5410
|
-
pdf: undefined,
|
|
5411
|
-
size: blob.size,
|
|
5412
|
-
mimeType: mimeType2
|
|
5413
|
-
};
|
|
5414
|
-
}
|
|
5415
|
-
if (detectedFormat === "pdf") {
|
|
5416
|
-
if (!response.blob) {
|
|
5417
|
-
throw new Error(`Failed to load PDF from ${url}`);
|
|
5418
|
-
}
|
|
5419
|
-
const blob = response.blob;
|
|
5420
|
-
const mimeType2 = responseMimeType || "application/pdf";
|
|
5421
|
-
const pdfData = await this.blobToBase64DataURL(blob, mimeType2);
|
|
5422
|
-
return {
|
|
5423
|
-
text: undefined,
|
|
5424
|
-
json: undefined,
|
|
5425
|
-
csv: undefined,
|
|
5426
|
-
image: undefined,
|
|
5427
|
-
pdf: pdfData,
|
|
5428
|
-
size: blob.size,
|
|
5429
|
-
mimeType: mimeType2
|
|
5430
|
-
};
|
|
5431
|
-
}
|
|
5432
|
-
const content = response.text || "";
|
|
5433
|
-
if (!content) {
|
|
5434
|
-
throw new Error(`Failed to load content from ${url}`);
|
|
5435
|
-
}
|
|
5436
|
-
const mimeType = responseMimeType || (detectedFormat === "markdown" ? "text/markdown" : detectedFormat === "html" ? "text/html" : "text/plain");
|
|
5643
|
+
static outputSchema() {
|
|
5437
5644
|
return {
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
image: undefined,
|
|
5442
|
-
pdf: undefined,
|
|
5443
|
-
size: content.length,
|
|
5444
|
-
mimeType
|
|
5645
|
+
type: "object",
|
|
5646
|
+
properties: {},
|
|
5647
|
+
additionalProperties: true
|
|
5445
5648
|
};
|
|
5446
5649
|
}
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
if (detectedFormat === "json") {
|
|
5450
|
-
responseType = "json";
|
|
5451
|
-
} else if (detectedFormat === "image" || detectedFormat === "pdf") {
|
|
5452
|
-
responseType = "blob";
|
|
5453
|
-
} else if (detectedFormat === "csv" || detectedFormat === "text" || detectedFormat === "markdown" || detectedFormat === "html") {
|
|
5454
|
-
responseType = "text";
|
|
5455
|
-
}
|
|
5456
|
-
return responseType;
|
|
5650
|
+
inputSchema() {
|
|
5651
|
+
return this.config?.extras?.inputSchema ?? this.constructor.inputSchema();
|
|
5457
5652
|
}
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5653
|
+
outputSchema() {
|
|
5654
|
+
return this.config?.extras?.outputSchema ?? this.constructor.outputSchema();
|
|
5655
|
+
}
|
|
5656
|
+
async execute(input2) {
|
|
5657
|
+
return input2;
|
|
5658
|
+
}
|
|
5659
|
+
async executeReactive(input2) {
|
|
5660
|
+
return input2;
|
|
5661
|
+
}
|
|
5662
|
+
}
|
|
5663
|
+
Workflow10.prototype.output = CreateWorkflow10(OutputTask);
|
|
5664
|
+
// src/task/SplitTask.ts
|
|
5665
|
+
import { CreateWorkflow as CreateWorkflow11, Task as Task9, Workflow as Workflow11 } from "@workglow/task-graph";
|
|
5666
|
+
var inputSchema9 = {
|
|
5667
|
+
type: "object",
|
|
5668
|
+
properties: {
|
|
5669
|
+
input: {
|
|
5670
|
+
title: "Single Input",
|
|
5671
|
+
description: "A single value to output"
|
|
5476
5672
|
}
|
|
5477
|
-
|
|
5673
|
+
},
|
|
5674
|
+
additionalProperties: false
|
|
5675
|
+
};
|
|
5676
|
+
var outputSchema9 = {
|
|
5677
|
+
type: "object",
|
|
5678
|
+
properties: {},
|
|
5679
|
+
additionalProperties: true
|
|
5680
|
+
};
|
|
5681
|
+
|
|
5682
|
+
class SplitTask extends Task9 {
|
|
5683
|
+
static type = "SplitTask";
|
|
5684
|
+
static category = "Utility";
|
|
5685
|
+
static title = "Split";
|
|
5686
|
+
static description = "Splits an array into individual outputs, creating one output per element";
|
|
5687
|
+
static hasDynamicSchemas = true;
|
|
5688
|
+
static cacheable = false;
|
|
5689
|
+
static inputSchema() {
|
|
5690
|
+
return inputSchema9;
|
|
5478
5691
|
}
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
if (urlLower.endsWith(".png"))
|
|
5482
|
-
return "image/png";
|
|
5483
|
-
if (urlLower.endsWith(".jpg") || urlLower.endsWith(".jpeg"))
|
|
5484
|
-
return "image/jpeg";
|
|
5485
|
-
if (urlLower.endsWith(".gif"))
|
|
5486
|
-
return "image/gif";
|
|
5487
|
-
if (urlLower.endsWith(".webp"))
|
|
5488
|
-
return "image/webp";
|
|
5489
|
-
if (urlLower.endsWith(".bmp"))
|
|
5490
|
-
return "image/bmp";
|
|
5491
|
-
if (urlLower.endsWith(".svg"))
|
|
5492
|
-
return "image/svg+xml";
|
|
5493
|
-
if (urlLower.endsWith(".ico"))
|
|
5494
|
-
return "image/x-icon";
|
|
5495
|
-
return "image/jpeg";
|
|
5692
|
+
static outputSchema() {
|
|
5693
|
+
return outputSchema9;
|
|
5496
5694
|
}
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5695
|
+
outputSchema() {
|
|
5696
|
+
return outputSchema9;
|
|
5697
|
+
}
|
|
5698
|
+
async executeReactive(input2) {
|
|
5699
|
+
const inputValue = input2.input;
|
|
5700
|
+
const output = {};
|
|
5701
|
+
if (Array.isArray(inputValue)) {
|
|
5702
|
+
inputValue.forEach((item, index) => {
|
|
5703
|
+
output[`output_${index}`] = item;
|
|
5704
|
+
});
|
|
5705
|
+
} else {
|
|
5706
|
+
output.output_0 = inputValue;
|
|
5502
5707
|
}
|
|
5503
|
-
return
|
|
5504
|
-
const reader = new FileReader;
|
|
5505
|
-
reader.onloadend = () => {
|
|
5506
|
-
const result = reader.result;
|
|
5507
|
-
if (result.startsWith("data:;base64,")) {
|
|
5508
|
-
resolve(`data:${mimeType};base64,${result.substring(13)}`);
|
|
5509
|
-
} else {
|
|
5510
|
-
resolve(result);
|
|
5511
|
-
}
|
|
5512
|
-
};
|
|
5513
|
-
reader.onerror = reject;
|
|
5514
|
-
reader.readAsDataURL(blob);
|
|
5515
|
-
});
|
|
5708
|
+
return output;
|
|
5516
5709
|
}
|
|
5517
5710
|
}
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
return
|
|
5711
|
+
var split = (input2, config = {}) => {
|
|
5712
|
+
const task = new SplitTask({}, config);
|
|
5713
|
+
return task.run(input2);
|
|
5521
5714
|
};
|
|
5522
|
-
|
|
5715
|
+
Workflow11.prototype.split = CreateWorkflow11(SplitTask);
|
|
5716
|
+
|
|
5717
|
+
// src/common.ts
|
|
5718
|
+
import { TaskRegistry } from "@workglow/task-graph";
|
|
5719
|
+
var registerCommonTasks = () => {
|
|
5720
|
+
const tasks = [
|
|
5721
|
+
ArrayTask,
|
|
5722
|
+
DebugLogTask,
|
|
5723
|
+
DelayTask,
|
|
5724
|
+
FetchUrlTask,
|
|
5725
|
+
InputTask,
|
|
5726
|
+
JavaScriptTask,
|
|
5727
|
+
JsonTask,
|
|
5728
|
+
LambdaTask,
|
|
5729
|
+
MergeTask,
|
|
5730
|
+
OutputTask,
|
|
5731
|
+
SplitTask
|
|
5732
|
+
];
|
|
5733
|
+
tasks.map(TaskRegistry.registerTask);
|
|
5734
|
+
return tasks;
|
|
5735
|
+
};
|
|
5736
|
+
|
|
5737
|
+
// src/browser.ts
|
|
5738
|
+
[FileLoaderTask].map(TaskRegistry2.registerTask);
|
|
5523
5739
|
export {
|
|
5524
5740
|
split,
|
|
5741
|
+
registerCommonTasks,
|
|
5525
5742
|
process,
|
|
5526
5743
|
merge,
|
|
5527
5744
|
lambda,
|
|
@@ -5531,16 +5748,20 @@ export {
|
|
|
5531
5748
|
fetchUrl,
|
|
5532
5749
|
delay,
|
|
5533
5750
|
debugLog,
|
|
5751
|
+
TypeReplicateArray,
|
|
5534
5752
|
SplitTask,
|
|
5753
|
+
OutputTask,
|
|
5535
5754
|
MergeTask,
|
|
5536
5755
|
LambdaTask,
|
|
5537
5756
|
JsonTask,
|
|
5538
5757
|
JavaScriptTask,
|
|
5758
|
+
InputTask,
|
|
5539
5759
|
FileLoaderTask,
|
|
5540
5760
|
FetchUrlTask,
|
|
5541
5761
|
FetchUrlJob,
|
|
5542
5762
|
DelayTask,
|
|
5543
|
-
DebugLogTask
|
|
5763
|
+
DebugLogTask,
|
|
5764
|
+
ArrayTask
|
|
5544
5765
|
};
|
|
5545
5766
|
|
|
5546
|
-
//# debugId=
|
|
5767
|
+
//# debugId=B1BD272CB310F36564756E2164756E21
|