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