@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/README.md
CHANGED
|
@@ -14,6 +14,7 @@ A package of task types for common operations, workflow management, and data pro
|
|
|
14
14
|
- [JavaScriptTask](#javascripttask)
|
|
15
15
|
- [LambdaTask](#lambdatask)
|
|
16
16
|
- [JsonTask](#jsontask)
|
|
17
|
+
- [ArrayTask](#arraytask)
|
|
17
18
|
- [Workflow Integration](#workflow-integration)
|
|
18
19
|
- [Error Handling](#error-handling)
|
|
19
20
|
- [Configuration](#configuration)
|
|
@@ -494,6 +495,78 @@ const dynamicWorkflow = await new JsonTask({
|
|
|
494
495
|
- Automatic data flow between tasks
|
|
495
496
|
- Enables configuration-driven workflows
|
|
496
497
|
|
|
498
|
+
### ArrayTask
|
|
499
|
+
|
|
500
|
+
A compound task that processes arrays by either executing directly for non-array inputs or creating parallel task instances for array inputs. Supports parallel processing of array elements and combination generation when multiple inputs are arrays.
|
|
501
|
+
|
|
502
|
+
**Key Features:**
|
|
503
|
+
|
|
504
|
+
- Automatically handles single values or arrays
|
|
505
|
+
- Parallel execution for array inputs
|
|
506
|
+
- Generates all combinations when multiple inputs are arrays
|
|
507
|
+
- Uses `x-replicate` annotation to mark array-capable inputs
|
|
508
|
+
|
|
509
|
+
**Examples:**
|
|
510
|
+
|
|
511
|
+
```typescript
|
|
512
|
+
import { ArrayTask, DataPortSchema } from "@workglow/tasks";
|
|
513
|
+
|
|
514
|
+
class ArrayProcessorTask extends ArrayTask<{ items: string[] }, { results: string[] }> {
|
|
515
|
+
static readonly type = "ArrayProcessorTask";
|
|
516
|
+
|
|
517
|
+
static inputSchema() {
|
|
518
|
+
return {
|
|
519
|
+
type: "object",
|
|
520
|
+
properties: {
|
|
521
|
+
items: {
|
|
522
|
+
type: "array",
|
|
523
|
+
items: {
|
|
524
|
+
type: "string",
|
|
525
|
+
},
|
|
526
|
+
},
|
|
527
|
+
},
|
|
528
|
+
required: ["items"],
|
|
529
|
+
additionalProperties: false,
|
|
530
|
+
} as const satisfies DataPortSchema;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
static outputSchema() {
|
|
534
|
+
return {
|
|
535
|
+
type: "object",
|
|
536
|
+
properties: {
|
|
537
|
+
results: {
|
|
538
|
+
type: "array",
|
|
539
|
+
items: {
|
|
540
|
+
type: "string",
|
|
541
|
+
},
|
|
542
|
+
},
|
|
543
|
+
},
|
|
544
|
+
required: ["results"],
|
|
545
|
+
additionalProperties: false,
|
|
546
|
+
} as const satisfies DataPortSchema;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
async execute(input: { items: string[] }) {
|
|
550
|
+
return { results: input.items.map((item) => item.toUpperCase()) };
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// Process array items in parallel
|
|
555
|
+
const task = new ArrayProcessorTask({
|
|
556
|
+
items: ["hello", "world", "foo", "bar"],
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
const result = await task.run();
|
|
560
|
+
// { results: ["HELLO", "WORLD", "FOO", "BAR"] }
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
**Features:**
|
|
564
|
+
|
|
565
|
+
- Parallel processing of array elements
|
|
566
|
+
- Automatic task instance creation per array element
|
|
567
|
+
- Combination generation for multiple array inputs
|
|
568
|
+
- Seamless single-value and array handling
|
|
569
|
+
|
|
497
570
|
## Workflow Integration
|
|
498
571
|
|
|
499
572
|
All tasks can be used standalone or integrated into workflows:
|