@workglow/task-graph 0.0.100 → 0.0.102
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/dist/browser.js +231 -55
- package/dist/browser.js.map +16 -16
- package/dist/bun.js +231 -55
- package/dist/bun.js.map +16 -16
- package/dist/node.js +231 -55
- package/dist/node.js.map +16 -16
- package/dist/task/ConditionalTask.d.ts +58 -21
- package/dist/task/ConditionalTask.d.ts.map +1 -1
- package/dist/task/GraphAsTask.d.ts +43 -2
- package/dist/task/GraphAsTask.d.ts.map +1 -1
- package/dist/task/ITask.d.ts +27 -2
- package/dist/task/ITask.d.ts.map +1 -1
- package/dist/task/IteratorTask.d.ts +61 -9
- package/dist/task/IteratorTask.d.ts.map +1 -1
- package/dist/task/JobQueueTask.d.ts +53 -3
- package/dist/task/JobQueueTask.d.ts.map +1 -1
- package/dist/task/MapTask.d.ts +60 -2
- package/dist/task/MapTask.d.ts.map +1 -1
- package/dist/task/ReduceTask.d.ts +55 -2
- package/dist/task/ReduceTask.d.ts.map +1 -1
- package/dist/task/Task.d.ts +48 -3
- package/dist/task/Task.d.ts.map +1 -1
- package/dist/task/TaskJSON.d.ts +14 -8
- package/dist/task/TaskJSON.d.ts.map +1 -1
- package/dist/task/TaskTypes.d.ts +65 -18
- package/dist/task/TaskTypes.d.ts.map +1 -1
- package/dist/task/WhileTask.d.ts +76 -7
- package/dist/task/WhileTask.d.ts.map +1 -1
- package/dist/task/iterationSchema.d.ts +1 -1
- package/dist/task-graph/Conversions.d.ts.map +1 -1
- package/dist/task-graph/TaskGraphRunner.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/node.js
CHANGED
|
@@ -11,6 +11,35 @@ var TaskStatus = {
|
|
|
11
11
|
ABORTING: "ABORTING",
|
|
12
12
|
FAILED: "FAILED"
|
|
13
13
|
};
|
|
14
|
+
var TaskConfigSchema = {
|
|
15
|
+
type: "object",
|
|
16
|
+
properties: {
|
|
17
|
+
id: {
|
|
18
|
+
"x-ui-hidden": true
|
|
19
|
+
},
|
|
20
|
+
title: { type: "string" },
|
|
21
|
+
description: { type: "string" },
|
|
22
|
+
cacheable: { type: "boolean" },
|
|
23
|
+
inputSchema: {
|
|
24
|
+
type: "object",
|
|
25
|
+
properties: {},
|
|
26
|
+
additionalProperties: true,
|
|
27
|
+
"x-ui-hidden": true
|
|
28
|
+
},
|
|
29
|
+
outputSchema: {
|
|
30
|
+
type: "object",
|
|
31
|
+
properties: {},
|
|
32
|
+
additionalProperties: true,
|
|
33
|
+
"x-ui-hidden": true
|
|
34
|
+
},
|
|
35
|
+
extras: {
|
|
36
|
+
type: "object",
|
|
37
|
+
additionalProperties: true,
|
|
38
|
+
"x-ui-hidden": true
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
additionalProperties: false
|
|
42
|
+
};
|
|
14
43
|
|
|
15
44
|
// src/task-graph/Dataflow.ts
|
|
16
45
|
var DATAFLOW_ALL_PORTS = "*";
|
|
@@ -717,7 +746,7 @@ class TaskRunner {
|
|
|
717
746
|
this.abortController.signal.addEventListener("abort", () => {
|
|
718
747
|
this.handleAbort();
|
|
719
748
|
});
|
|
720
|
-
const cache =
|
|
749
|
+
const cache = config.outputCache ?? this.task.runConfig?.outputCache;
|
|
721
750
|
if (cache === true) {
|
|
722
751
|
let instance = globalServiceRegistry.get(TASK_OUTPUT_REPOSITORY);
|
|
723
752
|
this.outputCache = instance;
|
|
@@ -809,8 +838,11 @@ class Task {
|
|
|
809
838
|
static type = "Task";
|
|
810
839
|
static category = "Hidden";
|
|
811
840
|
static title = "";
|
|
841
|
+
static description = "";
|
|
812
842
|
static cacheable = true;
|
|
813
843
|
static hasDynamicSchemas = false;
|
|
844
|
+
static passthroughInputsToOutputs = false;
|
|
845
|
+
static customizable = false;
|
|
814
846
|
static inputSchema() {
|
|
815
847
|
return {
|
|
816
848
|
type: "object",
|
|
@@ -825,6 +857,9 @@ class Task {
|
|
|
825
857
|
additionalProperties: false
|
|
826
858
|
};
|
|
827
859
|
}
|
|
860
|
+
static configSchema() {
|
|
861
|
+
return TaskConfigSchema;
|
|
862
|
+
}
|
|
828
863
|
async execute(_input, context) {
|
|
829
864
|
if (context.signal?.aborted) {
|
|
830
865
|
throw new TaskAbortedError("Task aborted");
|
|
@@ -841,8 +876,8 @@ class Task {
|
|
|
841
876
|
}
|
|
842
877
|
return this._runner;
|
|
843
878
|
}
|
|
844
|
-
async run(overrides = {}) {
|
|
845
|
-
return this.runner.run(overrides);
|
|
879
|
+
async run(overrides = {}, runConfig = {}) {
|
|
880
|
+
return this.runner.run(overrides, { ...this.runConfig, ...runConfig });
|
|
846
881
|
}
|
|
847
882
|
async runReactive(overrides = {}) {
|
|
848
883
|
return this.runner.runReactive(overrides);
|
|
@@ -859,6 +894,9 @@ class Task {
|
|
|
859
894
|
outputSchema() {
|
|
860
895
|
return this.constructor.outputSchema();
|
|
861
896
|
}
|
|
897
|
+
configSchema() {
|
|
898
|
+
return this.constructor.configSchema();
|
|
899
|
+
}
|
|
862
900
|
get type() {
|
|
863
901
|
return this.constructor.type;
|
|
864
902
|
}
|
|
@@ -866,15 +904,19 @@ class Task {
|
|
|
866
904
|
return this.constructor.category;
|
|
867
905
|
}
|
|
868
906
|
get title() {
|
|
869
|
-
return this.constructor.title;
|
|
907
|
+
return this.config?.title ?? this.constructor.title;
|
|
908
|
+
}
|
|
909
|
+
get description() {
|
|
910
|
+
return this.config?.description ?? this.constructor.description;
|
|
870
911
|
}
|
|
871
912
|
get cacheable() {
|
|
872
|
-
return this.config?.cacheable ?? this.constructor.cacheable;
|
|
913
|
+
return this.runConfig?.cacheable ?? this.config?.cacheable ?? this.constructor.cacheable;
|
|
873
914
|
}
|
|
874
915
|
defaults;
|
|
875
916
|
runInputData = {};
|
|
876
917
|
runOutputData = {};
|
|
877
918
|
config;
|
|
919
|
+
runConfig = {};
|
|
878
920
|
status = TaskStatus.PENDING;
|
|
879
921
|
progress = 0;
|
|
880
922
|
createdAt = new Date;
|
|
@@ -888,16 +930,18 @@ class Task {
|
|
|
888
930
|
return this._events;
|
|
889
931
|
}
|
|
890
932
|
_events;
|
|
891
|
-
constructor(callerDefaultInputs = {}, config = {}) {
|
|
933
|
+
constructor(callerDefaultInputs = {}, config = {}, runConfig = {}) {
|
|
892
934
|
const inputDefaults = this.getDefaultInputsFromStaticInputDefinitions();
|
|
893
935
|
const mergedDefaults = Object.assign(inputDefaults, callerDefaultInputs);
|
|
894
936
|
this.defaults = this.stripSymbols(mergedDefaults);
|
|
895
937
|
this.resetInputData();
|
|
896
|
-
const
|
|
897
|
-
|
|
938
|
+
const title = this.constructor.title || undefined;
|
|
939
|
+
const baseConfig = Object.assign({
|
|
898
940
|
id: uuid4(),
|
|
899
|
-
|
|
941
|
+
...title ? { title } : {}
|
|
900
942
|
}, config);
|
|
943
|
+
this.config = this.validateAndApplyConfigDefaults(baseConfig);
|
|
944
|
+
this.runConfig = runConfig;
|
|
901
945
|
}
|
|
902
946
|
getDefaultInputsFromStaticInputDefinitions() {
|
|
903
947
|
const schema = this.inputSchema();
|
|
@@ -934,7 +978,7 @@ class Task {
|
|
|
934
978
|
return obj;
|
|
935
979
|
}
|
|
936
980
|
if (visited.has(obj)) {
|
|
937
|
-
throw new
|
|
981
|
+
throw new TaskConfigurationError("Circular reference detected in input data. " + "Cannot clone objects with circular references.");
|
|
938
982
|
}
|
|
939
983
|
if (ArrayBuffer.isView(obj)) {
|
|
940
984
|
if (typeof DataView !== "undefined" && obj instanceof DataView) {
|
|
@@ -1079,6 +1123,37 @@ class Task {
|
|
|
1079
1123
|
const finalOutputSchema = outputSchema ?? this.outputSchema();
|
|
1080
1124
|
this.emit("schemaChange", finalInputSchema, finalOutputSchema);
|
|
1081
1125
|
}
|
|
1126
|
+
static _configSchemaNode = new Map;
|
|
1127
|
+
static getConfigSchemaNode(type) {
|
|
1128
|
+
const schema = this.configSchema();
|
|
1129
|
+
if (!schema)
|
|
1130
|
+
return;
|
|
1131
|
+
if (!this._configSchemaNode.has(type)) {
|
|
1132
|
+
try {
|
|
1133
|
+
const schemaNode = typeof schema === "boolean" ? compileSchema(schema ? {} : { not: {} }) : compileSchema(schema);
|
|
1134
|
+
this._configSchemaNode.set(type, schemaNode);
|
|
1135
|
+
} catch (error) {
|
|
1136
|
+
console.warn(`Failed to compile config schema for ${this.type}:`, error);
|
|
1137
|
+
return;
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
return this._configSchemaNode.get(type);
|
|
1141
|
+
}
|
|
1142
|
+
validateAndApplyConfigDefaults(config) {
|
|
1143
|
+
const ctor = this.constructor;
|
|
1144
|
+
const schemaNode = ctor.getConfigSchemaNode(this.type);
|
|
1145
|
+
if (!schemaNode)
|
|
1146
|
+
return config;
|
|
1147
|
+
const result = schemaNode.validate(config);
|
|
1148
|
+
if (!result.valid) {
|
|
1149
|
+
const errorMessages = result.errors.map((e) => {
|
|
1150
|
+
const path = e.data?.pointer || "";
|
|
1151
|
+
return `${e.message}${path ? ` (${path})` : ""}`;
|
|
1152
|
+
});
|
|
1153
|
+
throw new TaskConfigurationError(`[${ctor.name}] Configuration Error: ${errorMessages.join(", ")}`);
|
|
1154
|
+
}
|
|
1155
|
+
return config;
|
|
1156
|
+
}
|
|
1082
1157
|
static _inputSchemaNode = new Map;
|
|
1083
1158
|
static generateInputSchemaNode(schema) {
|
|
1084
1159
|
if (typeof schema === "boolean") {
|
|
@@ -1106,7 +1181,14 @@ class Task {
|
|
|
1106
1181
|
return this.constructor.getInputSchemaNode(type);
|
|
1107
1182
|
}
|
|
1108
1183
|
async validateInput(input) {
|
|
1109
|
-
const
|
|
1184
|
+
const ctor = this.constructor;
|
|
1185
|
+
let schemaNode;
|
|
1186
|
+
if (ctor.hasDynamicSchemas) {
|
|
1187
|
+
const instanceSchema = this.inputSchema();
|
|
1188
|
+
schemaNode = ctor.generateInputSchemaNode(instanceSchema);
|
|
1189
|
+
} else {
|
|
1190
|
+
schemaNode = this.getInputSchemaNode(this.type);
|
|
1191
|
+
}
|
|
1110
1192
|
const result = schemaNode.validate(input);
|
|
1111
1193
|
if (!result.valid) {
|
|
1112
1194
|
const errorMessages = result.errors.map((e) => {
|
|
@@ -1143,12 +1225,16 @@ class Task {
|
|
|
1143
1225
|
}
|
|
1144
1226
|
toJSON() {
|
|
1145
1227
|
const extras = this.config.extras;
|
|
1146
|
-
|
|
1228
|
+
const json = this.stripSymbols({
|
|
1147
1229
|
id: this.config.id,
|
|
1148
1230
|
type: this.type,
|
|
1149
|
-
...this.config.name ? { name: this.config.name } : {},
|
|
1150
1231
|
defaults: this.defaults,
|
|
1151
|
-
|
|
1232
|
+
config: {
|
|
1233
|
+
...this.config.title ? { title: this.config.title } : {},
|
|
1234
|
+
...this.config.inputSchema ? { inputSchema: this.config.inputSchema } : {},
|
|
1235
|
+
...this.config.outputSchema ? { outputSchema: this.config.outputSchema } : {},
|
|
1236
|
+
...extras && Object.keys(extras).length ? { extras } : {}
|
|
1237
|
+
}
|
|
1152
1238
|
});
|
|
1153
1239
|
return json;
|
|
1154
1240
|
}
|
|
@@ -1191,12 +1277,27 @@ class Task {
|
|
|
1191
1277
|
}
|
|
1192
1278
|
|
|
1193
1279
|
// src/task/ConditionalTask.ts
|
|
1280
|
+
var conditionalTaskConfigSchema = {
|
|
1281
|
+
type: "object",
|
|
1282
|
+
properties: {
|
|
1283
|
+
...TaskConfigSchema["properties"],
|
|
1284
|
+
branches: { type: "array", items: {} },
|
|
1285
|
+
defaultBranch: { type: "string" },
|
|
1286
|
+
exclusive: { type: "boolean" },
|
|
1287
|
+
conditionConfig: { type: "object", additionalProperties: true }
|
|
1288
|
+
},
|
|
1289
|
+
additionalProperties: false
|
|
1290
|
+
};
|
|
1291
|
+
|
|
1194
1292
|
class ConditionalTask extends Task {
|
|
1195
1293
|
static type = "ConditionalTask";
|
|
1196
1294
|
static category = "Flow Control";
|
|
1197
1295
|
static title = "Condition";
|
|
1198
1296
|
static description = "Route data based on conditions";
|
|
1199
1297
|
static hasDynamicSchemas = true;
|
|
1298
|
+
static configSchema() {
|
|
1299
|
+
return conditionalTaskConfigSchema;
|
|
1300
|
+
}
|
|
1200
1301
|
activeBranches = new Set;
|
|
1201
1302
|
buildBranchesFromConditionConfig(conditionConfig) {
|
|
1202
1303
|
if (!conditionConfig?.branches || conditionConfig.branches.length === 0) {
|
|
@@ -1227,7 +1328,7 @@ class ConditionalTask extends Task {
|
|
|
1227
1328
|
fromConditionConfig: false
|
|
1228
1329
|
};
|
|
1229
1330
|
}
|
|
1230
|
-
const conditionConfig = input.conditionConfig ?? this.config.
|
|
1331
|
+
const conditionConfig = input.conditionConfig ?? this.config.conditionConfig;
|
|
1231
1332
|
if (conditionConfig) {
|
|
1232
1333
|
return {
|
|
1233
1334
|
branches: this.buildBranchesFromConditionConfig(conditionConfig),
|
|
@@ -1931,9 +2032,7 @@ class TaskGraphRunner {
|
|
|
1931
2032
|
task.runOutputData = {};
|
|
1932
2033
|
task.error = undefined;
|
|
1933
2034
|
task.progress = 0;
|
|
1934
|
-
|
|
1935
|
-
task.config.runnerId = runId;
|
|
1936
|
-
}
|
|
2035
|
+
task.runConfig = { ...task.runConfig, runnerId: runId };
|
|
1937
2036
|
this.pushStatusFromNodeToEdges(graph, task);
|
|
1938
2037
|
this.pushErrorFromNodeToEdges(graph, task);
|
|
1939
2038
|
task.emit("reset");
|
|
@@ -2097,6 +2196,15 @@ class GraphAsTaskRunner extends TaskRunner {
|
|
|
2097
2196
|
}
|
|
2098
2197
|
|
|
2099
2198
|
// src/task/GraphAsTask.ts
|
|
2199
|
+
var graphAsTaskConfigSchema = {
|
|
2200
|
+
type: "object",
|
|
2201
|
+
properties: {
|
|
2202
|
+
...TaskConfigSchema["properties"],
|
|
2203
|
+
compoundMerge: { type: "string", "x-ui-hidden": true }
|
|
2204
|
+
},
|
|
2205
|
+
additionalProperties: false
|
|
2206
|
+
};
|
|
2207
|
+
|
|
2100
2208
|
class GraphAsTask extends Task {
|
|
2101
2209
|
static type = "GraphAsTask";
|
|
2102
2210
|
static title = "Group";
|
|
@@ -2118,11 +2226,14 @@ class GraphAsTask extends Task {
|
|
|
2118
2226
|
}
|
|
2119
2227
|
return this._runner;
|
|
2120
2228
|
}
|
|
2229
|
+
static configSchema() {
|
|
2230
|
+
return graphAsTaskConfigSchema;
|
|
2231
|
+
}
|
|
2121
2232
|
get compoundMerge() {
|
|
2122
2233
|
return this.config?.compoundMerge || this.constructor.compoundMerge;
|
|
2123
2234
|
}
|
|
2124
2235
|
get cacheable() {
|
|
2125
|
-
return this.config?.cacheable ?? (this.constructor.cacheable && !this.hasChildren());
|
|
2236
|
+
return this.runConfig?.cacheable ?? this.config?.cacheable ?? (this.constructor.cacheable && !this.hasChildren());
|
|
2126
2237
|
}
|
|
2127
2238
|
inputSchema() {
|
|
2128
2239
|
if (!this.hasChildren()) {
|
|
@@ -2999,17 +3110,19 @@ function ensureTask(arg, config = {}) {
|
|
|
2999
3110
|
return arg;
|
|
3000
3111
|
}
|
|
3001
3112
|
if (arg instanceof TaskGraph) {
|
|
3002
|
-
|
|
3003
|
-
|
|
3113
|
+
const { isOwned, ...cleanConfig } = config;
|
|
3114
|
+
if (isOwned) {
|
|
3115
|
+
return new OwnGraphTask({}, { ...cleanConfig, subGraph: arg });
|
|
3004
3116
|
} else {
|
|
3005
|
-
return new GraphTask({}, { ...
|
|
3117
|
+
return new GraphTask({}, { ...cleanConfig, subGraph: arg });
|
|
3006
3118
|
}
|
|
3007
3119
|
}
|
|
3008
3120
|
if (arg instanceof Workflow) {
|
|
3009
|
-
|
|
3010
|
-
|
|
3121
|
+
const { isOwned, ...cleanConfig } = config;
|
|
3122
|
+
if (isOwned) {
|
|
3123
|
+
return new OwnWorkflowTask({}, { ...cleanConfig, subGraph: arg.graph });
|
|
3011
3124
|
} else {
|
|
3012
|
-
return new WorkflowTask2({}, { ...
|
|
3125
|
+
return new WorkflowTask2({}, { ...cleanConfig, subGraph: arg.graph });
|
|
3013
3126
|
}
|
|
3014
3127
|
}
|
|
3015
3128
|
return convertPipeFunctionToTask(arg, config);
|
|
@@ -3486,6 +3599,16 @@ var ITERATOR_CONTEXT_SCHEMA = {
|
|
|
3486
3599
|
}
|
|
3487
3600
|
}
|
|
3488
3601
|
};
|
|
3602
|
+
var iteratorTaskConfigSchema = {
|
|
3603
|
+
type: "object",
|
|
3604
|
+
properties: {
|
|
3605
|
+
...graphAsTaskConfigSchema["properties"],
|
|
3606
|
+
concurrencyLimit: { type: "integer", minimum: 1 },
|
|
3607
|
+
batchSize: { type: "integer", minimum: 1 },
|
|
3608
|
+
iterationInputConfig: { type: "object", additionalProperties: true }
|
|
3609
|
+
},
|
|
3610
|
+
additionalProperties: false
|
|
3611
|
+
};
|
|
3489
3612
|
function isArrayVariant(schema) {
|
|
3490
3613
|
if (!schema || typeof schema !== "object")
|
|
3491
3614
|
return false;
|
|
@@ -3533,23 +3656,17 @@ function inferIterationFromSchema(schema) {
|
|
|
3533
3656
|
return false;
|
|
3534
3657
|
}
|
|
3535
3658
|
function createFlexibleSchema(baseSchema) {
|
|
3536
|
-
if (typeof baseSchema === "boolean")
|
|
3537
|
-
return baseSchema;
|
|
3538
3659
|
return {
|
|
3539
3660
|
anyOf: [baseSchema, { type: "array", items: baseSchema }]
|
|
3540
3661
|
};
|
|
3541
3662
|
}
|
|
3542
3663
|
function createArraySchema(baseSchema) {
|
|
3543
|
-
if (typeof baseSchema === "boolean")
|
|
3544
|
-
return baseSchema;
|
|
3545
3664
|
return {
|
|
3546
3665
|
type: "array",
|
|
3547
3666
|
items: baseSchema
|
|
3548
3667
|
};
|
|
3549
3668
|
}
|
|
3550
3669
|
function extractBaseSchema(schema) {
|
|
3551
|
-
if (typeof schema === "boolean")
|
|
3552
|
-
return schema;
|
|
3553
3670
|
const schemaType = schema.type;
|
|
3554
3671
|
if (schemaType === "array" && schema.items) {
|
|
3555
3672
|
return schema.items;
|
|
@@ -3594,6 +3711,9 @@ class IteratorTask extends GraphAsTask {
|
|
|
3594
3711
|
static title = "Iterator";
|
|
3595
3712
|
static description = "Base class for loop-type tasks";
|
|
3596
3713
|
static hasDynamicSchemas = true;
|
|
3714
|
+
static configSchema() {
|
|
3715
|
+
return iteratorTaskConfigSchema;
|
|
3716
|
+
}
|
|
3597
3717
|
static getIterationContextSchema() {
|
|
3598
3718
|
return ITERATOR_CONTEXT_SCHEMA;
|
|
3599
3719
|
}
|
|
@@ -3954,6 +4074,20 @@ var WHILE_CONTEXT_SCHEMA = {
|
|
|
3954
4074
|
}
|
|
3955
4075
|
}
|
|
3956
4076
|
};
|
|
4077
|
+
var whileTaskConfigSchema = {
|
|
4078
|
+
type: "object",
|
|
4079
|
+
properties: {
|
|
4080
|
+
...graphAsTaskConfigSchema["properties"],
|
|
4081
|
+
condition: {},
|
|
4082
|
+
maxIterations: { type: "integer", minimum: 1 },
|
|
4083
|
+
chainIterations: { type: "boolean" },
|
|
4084
|
+
conditionField: { type: "string" },
|
|
4085
|
+
conditionOperator: { type: "string" },
|
|
4086
|
+
conditionValue: { type: "string" },
|
|
4087
|
+
iterationInputConfig: { type: "object", additionalProperties: true }
|
|
4088
|
+
},
|
|
4089
|
+
additionalProperties: false
|
|
4090
|
+
};
|
|
3957
4091
|
|
|
3958
4092
|
class WhileTask extends GraphAsTask {
|
|
3959
4093
|
static type = "WhileTask";
|
|
@@ -3961,6 +4095,9 @@ class WhileTask extends GraphAsTask {
|
|
|
3961
4095
|
static title = "While Loop";
|
|
3962
4096
|
static description = "Loops until a condition function returns false";
|
|
3963
4097
|
static hasDynamicSchemas = true;
|
|
4098
|
+
static configSchema() {
|
|
4099
|
+
return whileTaskConfigSchema;
|
|
4100
|
+
}
|
|
3964
4101
|
static getIterationContextSchema() {
|
|
3965
4102
|
return WHILE_CONTEXT_SCHEMA;
|
|
3966
4103
|
}
|
|
@@ -3978,38 +4115,30 @@ class WhileTask extends GraphAsTask {
|
|
|
3978
4115
|
return this.config.condition;
|
|
3979
4116
|
}
|
|
3980
4117
|
get maxIterations() {
|
|
3981
|
-
|
|
3982
|
-
return this.config.maxIterations;
|
|
3983
|
-
const wc = this.config.extras?.whileConfig;
|
|
3984
|
-
return wc?.maxIterations ?? 100;
|
|
4118
|
+
return this.config.maxIterations ?? 100;
|
|
3985
4119
|
}
|
|
3986
4120
|
get chainIterations() {
|
|
3987
|
-
|
|
3988
|
-
return this.config.chainIterations;
|
|
3989
|
-
const wc = this.config.extras?.whileConfig;
|
|
3990
|
-
return wc?.chainIterations ?? true;
|
|
4121
|
+
return this.config.chainIterations ?? true;
|
|
3991
4122
|
}
|
|
3992
4123
|
get currentIteration() {
|
|
3993
4124
|
return this._currentIteration;
|
|
3994
4125
|
}
|
|
3995
|
-
|
|
3996
|
-
const
|
|
3997
|
-
if (!
|
|
4126
|
+
buildConditionFromConfig() {
|
|
4127
|
+
const { conditionOperator, conditionField, conditionValue } = this.config;
|
|
4128
|
+
if (!conditionOperator) {
|
|
3998
4129
|
return;
|
|
3999
4130
|
}
|
|
4000
|
-
const { conditionField, conditionOperator, conditionValue } = wc;
|
|
4001
4131
|
return (output) => {
|
|
4002
4132
|
const fieldValue = conditionField ? getNestedValue(output, conditionField) : output;
|
|
4003
4133
|
return evaluateCondition(fieldValue, conditionOperator, conditionValue ?? "");
|
|
4004
4134
|
};
|
|
4005
4135
|
}
|
|
4006
4136
|
analyzeArrayInputs(input) {
|
|
4007
|
-
|
|
4008
|
-
if (!wc?.iterationInputConfig) {
|
|
4137
|
+
if (!this.config.iterationInputConfig) {
|
|
4009
4138
|
return null;
|
|
4010
4139
|
}
|
|
4011
4140
|
const inputData = input;
|
|
4012
|
-
const config =
|
|
4141
|
+
const config = this.config.iterationInputConfig;
|
|
4013
4142
|
const arrayPorts = [];
|
|
4014
4143
|
const scalarPorts = [];
|
|
4015
4144
|
const iteratedValues = {};
|
|
@@ -4065,7 +4194,7 @@ class WhileTask extends GraphAsTask {
|
|
|
4065
4194
|
if (!this.hasChildren()) {
|
|
4066
4195
|
throw new TaskConfigurationError(`${this.type}: No subgraph set for while loop`);
|
|
4067
4196
|
}
|
|
4068
|
-
const condition = this.condition ?? this.
|
|
4197
|
+
const condition = this.condition ?? this.buildConditionFromConfig();
|
|
4069
4198
|
if (!condition) {
|
|
4070
4199
|
throw new TaskConfigurationError(`${this.type}: No condition function provided`);
|
|
4071
4200
|
}
|
|
@@ -4110,7 +4239,7 @@ class WhileTask extends GraphAsTask {
|
|
|
4110
4239
|
if (!this.hasChildren()) {
|
|
4111
4240
|
throw new TaskConfigurationError(`${this.type}: No subgraph set for while loop`);
|
|
4112
4241
|
}
|
|
4113
|
-
const condition = this.condition ?? this.
|
|
4242
|
+
const condition = this.condition ?? this.buildConditionFromConfig();
|
|
4114
4243
|
if (!condition) {
|
|
4115
4244
|
throw new TaskConfigurationError(`${this.type}: No condition function provided`);
|
|
4116
4245
|
}
|
|
@@ -4180,12 +4309,11 @@ class WhileTask extends GraphAsTask {
|
|
|
4180
4309
|
const baseSchema = super.inputSchema();
|
|
4181
4310
|
if (typeof baseSchema === "boolean")
|
|
4182
4311
|
return baseSchema;
|
|
4183
|
-
|
|
4184
|
-
if (!wc?.iterationInputConfig) {
|
|
4312
|
+
if (!this.config.iterationInputConfig) {
|
|
4185
4313
|
return baseSchema;
|
|
4186
4314
|
}
|
|
4187
4315
|
const properties = { ...baseSchema.properties || {} };
|
|
4188
|
-
for (const [key, propConfig] of Object.entries(
|
|
4316
|
+
for (const [key, propConfig] of Object.entries(this.config.iterationInputConfig)) {
|
|
4189
4317
|
if (propConfig.mode === "array" && properties[key]) {
|
|
4190
4318
|
const scalarSchema = properties[key];
|
|
4191
4319
|
properties[key] = {
|
|
@@ -4594,9 +4722,25 @@ function setTaskQueueRegistry(registry) {
|
|
|
4594
4722
|
}
|
|
4595
4723
|
|
|
4596
4724
|
// src/task/JobQueueTask.ts
|
|
4725
|
+
var jobQueueTaskConfigSchema = {
|
|
4726
|
+
type: "object",
|
|
4727
|
+
properties: {
|
|
4728
|
+
...graphAsTaskConfigSchema["properties"],
|
|
4729
|
+
queue: {
|
|
4730
|
+
oneOf: [{ type: "boolean" }, { type: "string" }],
|
|
4731
|
+
description: "Queue handling: false=run inline, true=use default, string=explicit queue name",
|
|
4732
|
+
"x-ui-hidden": true
|
|
4733
|
+
}
|
|
4734
|
+
},
|
|
4735
|
+
additionalProperties: false
|
|
4736
|
+
};
|
|
4737
|
+
|
|
4597
4738
|
class JobQueueTask extends GraphAsTask {
|
|
4598
4739
|
static type = "JobQueueTask";
|
|
4599
4740
|
static canRunDirectly = true;
|
|
4741
|
+
static configSchema() {
|
|
4742
|
+
return jobQueueTaskConfigSchema;
|
|
4743
|
+
}
|
|
4600
4744
|
currentQueueName;
|
|
4601
4745
|
currentJobId;
|
|
4602
4746
|
currentRunnerId;
|
|
@@ -4727,11 +4871,24 @@ class JobQueueTask extends GraphAsTask {
|
|
|
4727
4871
|
}
|
|
4728
4872
|
}
|
|
4729
4873
|
// src/task/MapTask.ts
|
|
4874
|
+
var mapTaskConfigSchema = {
|
|
4875
|
+
type: "object",
|
|
4876
|
+
properties: {
|
|
4877
|
+
...iteratorTaskConfigSchema["properties"],
|
|
4878
|
+
preserveOrder: { type: "boolean" },
|
|
4879
|
+
flatten: { type: "boolean" }
|
|
4880
|
+
},
|
|
4881
|
+
additionalProperties: false
|
|
4882
|
+
};
|
|
4883
|
+
|
|
4730
4884
|
class MapTask extends IteratorTask {
|
|
4731
4885
|
static type = "MapTask";
|
|
4732
4886
|
static category = "Flow Control";
|
|
4733
4887
|
static title = "Map";
|
|
4734
4888
|
static description = "Transforms array inputs by running a workflow per item";
|
|
4889
|
+
static configSchema() {
|
|
4890
|
+
return mapTaskConfigSchema;
|
|
4891
|
+
}
|
|
4735
4892
|
static compoundMerge = PROPERTY_ARRAY;
|
|
4736
4893
|
static inputSchema() {
|
|
4737
4894
|
return {
|
|
@@ -4794,11 +4951,23 @@ queueMicrotask(() => {
|
|
|
4794
4951
|
Workflow.prototype.endMap = CreateEndLoopWorkflow("endMap");
|
|
4795
4952
|
});
|
|
4796
4953
|
// src/task/ReduceTask.ts
|
|
4954
|
+
var reduceTaskConfigSchema = {
|
|
4955
|
+
type: "object",
|
|
4956
|
+
properties: {
|
|
4957
|
+
...iteratorTaskConfigSchema["properties"],
|
|
4958
|
+
initialValue: {}
|
|
4959
|
+
},
|
|
4960
|
+
additionalProperties: false
|
|
4961
|
+
};
|
|
4962
|
+
|
|
4797
4963
|
class ReduceTask extends IteratorTask {
|
|
4798
4964
|
static type = "ReduceTask";
|
|
4799
4965
|
static category = "Flow Control";
|
|
4800
4966
|
static title = "Reduce";
|
|
4801
4967
|
static description = "Processes iterated inputs sequentially with an accumulator (fold)";
|
|
4968
|
+
static configSchema() {
|
|
4969
|
+
return reduceTaskConfigSchema;
|
|
4970
|
+
}
|
|
4802
4971
|
constructor(input = {}, config = {}) {
|
|
4803
4972
|
const reduceConfig = {
|
|
4804
4973
|
...config,
|
|
@@ -4898,9 +5067,8 @@ var createSingleTaskFromJSON = (item) => {
|
|
|
4898
5067
|
if (!taskClass)
|
|
4899
5068
|
throw new TaskJSONError(`Task type ${item.type} not found, perhaps not registered?`);
|
|
4900
5069
|
const taskConfig = {
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
extras: item.extras
|
|
5070
|
+
...item.config,
|
|
5071
|
+
id: item.id
|
|
4904
5072
|
};
|
|
4905
5073
|
const task = new taskClass(item.defaults ?? {}, taskConfig);
|
|
4906
5074
|
return task;
|
|
@@ -5106,6 +5274,7 @@ class TaskOutputTabularRepository extends TaskOutputRepository {
|
|
|
5106
5274
|
}
|
|
5107
5275
|
export {
|
|
5108
5276
|
wrapSchemaInArray,
|
|
5277
|
+
whileTaskConfigSchema,
|
|
5109
5278
|
setTaskQueueRegistry,
|
|
5110
5279
|
serialGraph,
|
|
5111
5280
|
schemaAcceptsArray,
|
|
@@ -5113,15 +5282,20 @@ export {
|
|
|
5113
5282
|
removeIterationProperties,
|
|
5114
5283
|
registerJobQueueFactory,
|
|
5115
5284
|
registerBaseTasks,
|
|
5285
|
+
reduceTaskConfigSchema,
|
|
5116
5286
|
pipe,
|
|
5117
5287
|
parallel,
|
|
5118
5288
|
mergeChainedOutputToInput,
|
|
5289
|
+
mapTaskConfigSchema,
|
|
5290
|
+
jobQueueTaskConfigSchema,
|
|
5291
|
+
iteratorTaskConfigSchema,
|
|
5119
5292
|
isTaskStreamable,
|
|
5120
5293
|
isStrictArraySchema,
|
|
5121
5294
|
isIterationProperty,
|
|
5122
5295
|
isFlexibleSchema,
|
|
5123
5296
|
hasVectorOutput,
|
|
5124
5297
|
hasVectorLikeInput,
|
|
5298
|
+
graphAsTaskConfigSchema,
|
|
5125
5299
|
getTaskQueueRegistry,
|
|
5126
5300
|
getStreamingPorts,
|
|
5127
5301
|
getPortStreamMode,
|
|
@@ -5147,6 +5321,7 @@ export {
|
|
|
5147
5321
|
createFlexibleSchema,
|
|
5148
5322
|
createArraySchema,
|
|
5149
5323
|
connect,
|
|
5324
|
+
conditionalTaskConfigSchema,
|
|
5150
5325
|
buildIterationInputSchema,
|
|
5151
5326
|
addIterationContextToSchema,
|
|
5152
5327
|
WorkflowError,
|
|
@@ -5172,6 +5347,7 @@ export {
|
|
|
5172
5347
|
TaskFailedError,
|
|
5173
5348
|
TaskError,
|
|
5174
5349
|
TaskConfigurationError,
|
|
5350
|
+
TaskConfigSchema,
|
|
5175
5351
|
TaskAbortedError,
|
|
5176
5352
|
Task,
|
|
5177
5353
|
TASK_OUTPUT_REPOSITORY,
|
|
@@ -5201,4 +5377,4 @@ export {
|
|
|
5201
5377
|
ConditionalTask
|
|
5202
5378
|
};
|
|
5203
5379
|
|
|
5204
|
-
//# debugId=
|
|
5380
|
+
//# debugId=16A7365B6A62FFD964756E2164756E21
|