@workglow/task-graph 0.0.100 → 0.0.101
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 +205 -48
- package/dist/browser.js.map +15 -15
- package/dist/bun.js +205 -48
- package/dist/bun.js.map +15 -15
- package/dist/node.js +205 -48
- package/dist/node.js.map +15 -15
- package/dist/task/ConditionalTask.d.ts +53 -21
- package/dist/task/ConditionalTask.d.ts.map +1 -1
- package/dist/task/GraphAsTask.d.ts +37 -2
- package/dist/task/GraphAsTask.d.ts.map +1 -1
- package/dist/task/ITask.d.ts +26 -2
- package/dist/task/ITask.d.ts.map +1 -1
- package/dist/task/IteratorTask.d.ts +49 -3
- package/dist/task/IteratorTask.d.ts.map +1 -1
- package/dist/task/JobQueueTask.d.ts +39 -3
- package/dist/task/JobQueueTask.d.ts.map +1 -1
- package/dist/task/MapTask.d.ts +54 -2
- package/dist/task/MapTask.d.ts.map +1 -1
- package/dist/task/ReduceTask.d.ts +49 -2
- package/dist/task/ReduceTask.d.ts.map +1 -1
- package/dist/task/Task.d.ts +43 -3
- package/dist/task/Task.d.ts.map +1 -1
- package/dist/task/TaskJSON.d.ts +10 -8
- package/dist/task/TaskJSON.d.ts.map +1 -1
- package/dist/task/TaskTypes.d.ts +60 -18
- package/dist/task/TaskTypes.d.ts.map +1 -1
- package/dist/task/WhileTask.d.ts +70 -7
- package/dist/task/WhileTask.d.ts.map +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,22 @@ var TaskStatus = {
|
|
|
11
11
|
ABORTING: "ABORTING",
|
|
12
12
|
FAILED: "FAILED"
|
|
13
13
|
};
|
|
14
|
+
var TaskConfigSchema = {
|
|
15
|
+
type: "object",
|
|
16
|
+
properties: {
|
|
17
|
+
id: {},
|
|
18
|
+
title: { type: "string" },
|
|
19
|
+
description: { type: "string" },
|
|
20
|
+
cacheable: { type: "boolean" },
|
|
21
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: true },
|
|
22
|
+
outputSchema: { type: "object", properties: {}, additionalProperties: true },
|
|
23
|
+
extras: {
|
|
24
|
+
type: "object",
|
|
25
|
+
additionalProperties: true
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
additionalProperties: false
|
|
29
|
+
};
|
|
14
30
|
|
|
15
31
|
// src/task-graph/Dataflow.ts
|
|
16
32
|
var DATAFLOW_ALL_PORTS = "*";
|
|
@@ -717,7 +733,7 @@ class TaskRunner {
|
|
|
717
733
|
this.abortController.signal.addEventListener("abort", () => {
|
|
718
734
|
this.handleAbort();
|
|
719
735
|
});
|
|
720
|
-
const cache =
|
|
736
|
+
const cache = config.outputCache ?? this.task.runConfig?.outputCache;
|
|
721
737
|
if (cache === true) {
|
|
722
738
|
let instance = globalServiceRegistry.get(TASK_OUTPUT_REPOSITORY);
|
|
723
739
|
this.outputCache = instance;
|
|
@@ -809,8 +825,10 @@ class Task {
|
|
|
809
825
|
static type = "Task";
|
|
810
826
|
static category = "Hidden";
|
|
811
827
|
static title = "";
|
|
828
|
+
static description = "";
|
|
812
829
|
static cacheable = true;
|
|
813
830
|
static hasDynamicSchemas = false;
|
|
831
|
+
static passthroughInputsToOutputs = false;
|
|
814
832
|
static inputSchema() {
|
|
815
833
|
return {
|
|
816
834
|
type: "object",
|
|
@@ -825,6 +843,9 @@ class Task {
|
|
|
825
843
|
additionalProperties: false
|
|
826
844
|
};
|
|
827
845
|
}
|
|
846
|
+
static configSchema() {
|
|
847
|
+
return TaskConfigSchema;
|
|
848
|
+
}
|
|
828
849
|
async execute(_input, context) {
|
|
829
850
|
if (context.signal?.aborted) {
|
|
830
851
|
throw new TaskAbortedError("Task aborted");
|
|
@@ -841,8 +862,8 @@ class Task {
|
|
|
841
862
|
}
|
|
842
863
|
return this._runner;
|
|
843
864
|
}
|
|
844
|
-
async run(overrides = {}) {
|
|
845
|
-
return this.runner.run(overrides);
|
|
865
|
+
async run(overrides = {}, runConfig = {}) {
|
|
866
|
+
return this.runner.run(overrides, { ...this.runConfig, ...runConfig });
|
|
846
867
|
}
|
|
847
868
|
async runReactive(overrides = {}) {
|
|
848
869
|
return this.runner.runReactive(overrides);
|
|
@@ -859,6 +880,9 @@ class Task {
|
|
|
859
880
|
outputSchema() {
|
|
860
881
|
return this.constructor.outputSchema();
|
|
861
882
|
}
|
|
883
|
+
configSchema() {
|
|
884
|
+
return this.constructor.configSchema();
|
|
885
|
+
}
|
|
862
886
|
get type() {
|
|
863
887
|
return this.constructor.type;
|
|
864
888
|
}
|
|
@@ -866,15 +890,19 @@ class Task {
|
|
|
866
890
|
return this.constructor.category;
|
|
867
891
|
}
|
|
868
892
|
get title() {
|
|
869
|
-
return this.constructor.title;
|
|
893
|
+
return this.config?.title ?? this.constructor.title;
|
|
894
|
+
}
|
|
895
|
+
get description() {
|
|
896
|
+
return this.config?.description ?? this.constructor.description;
|
|
870
897
|
}
|
|
871
898
|
get cacheable() {
|
|
872
|
-
return this.config?.cacheable ?? this.constructor.cacheable;
|
|
899
|
+
return this.runConfig?.cacheable ?? this.config?.cacheable ?? this.constructor.cacheable;
|
|
873
900
|
}
|
|
874
901
|
defaults;
|
|
875
902
|
runInputData = {};
|
|
876
903
|
runOutputData = {};
|
|
877
904
|
config;
|
|
905
|
+
runConfig = {};
|
|
878
906
|
status = TaskStatus.PENDING;
|
|
879
907
|
progress = 0;
|
|
880
908
|
createdAt = new Date;
|
|
@@ -888,16 +916,18 @@ class Task {
|
|
|
888
916
|
return this._events;
|
|
889
917
|
}
|
|
890
918
|
_events;
|
|
891
|
-
constructor(callerDefaultInputs = {}, config = {}) {
|
|
919
|
+
constructor(callerDefaultInputs = {}, config = {}, runConfig = {}) {
|
|
892
920
|
const inputDefaults = this.getDefaultInputsFromStaticInputDefinitions();
|
|
893
921
|
const mergedDefaults = Object.assign(inputDefaults, callerDefaultInputs);
|
|
894
922
|
this.defaults = this.stripSymbols(mergedDefaults);
|
|
895
923
|
this.resetInputData();
|
|
896
|
-
const
|
|
897
|
-
|
|
924
|
+
const title = this.constructor.title || undefined;
|
|
925
|
+
const baseConfig = Object.assign({
|
|
898
926
|
id: uuid4(),
|
|
899
|
-
|
|
927
|
+
...title ? { title } : {}
|
|
900
928
|
}, config);
|
|
929
|
+
this.config = this.validateAndApplyConfigDefaults(baseConfig);
|
|
930
|
+
this.runConfig = runConfig;
|
|
901
931
|
}
|
|
902
932
|
getDefaultInputsFromStaticInputDefinitions() {
|
|
903
933
|
const schema = this.inputSchema();
|
|
@@ -934,7 +964,7 @@ class Task {
|
|
|
934
964
|
return obj;
|
|
935
965
|
}
|
|
936
966
|
if (visited.has(obj)) {
|
|
937
|
-
throw new
|
|
967
|
+
throw new TaskConfigurationError("Circular reference detected in input data. " + "Cannot clone objects with circular references.");
|
|
938
968
|
}
|
|
939
969
|
if (ArrayBuffer.isView(obj)) {
|
|
940
970
|
if (typeof DataView !== "undefined" && obj instanceof DataView) {
|
|
@@ -1079,6 +1109,37 @@ class Task {
|
|
|
1079
1109
|
const finalOutputSchema = outputSchema ?? this.outputSchema();
|
|
1080
1110
|
this.emit("schemaChange", finalInputSchema, finalOutputSchema);
|
|
1081
1111
|
}
|
|
1112
|
+
static _configSchemaNode = new Map;
|
|
1113
|
+
static getConfigSchemaNode(type) {
|
|
1114
|
+
const schema = this.configSchema();
|
|
1115
|
+
if (!schema)
|
|
1116
|
+
return;
|
|
1117
|
+
if (!this._configSchemaNode.has(type)) {
|
|
1118
|
+
try {
|
|
1119
|
+
const schemaNode = typeof schema === "boolean" ? compileSchema(schema ? {} : { not: {} }) : compileSchema(schema);
|
|
1120
|
+
this._configSchemaNode.set(type, schemaNode);
|
|
1121
|
+
} catch (error) {
|
|
1122
|
+
console.warn(`Failed to compile config schema for ${this.type}:`, error);
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
return this._configSchemaNode.get(type);
|
|
1127
|
+
}
|
|
1128
|
+
validateAndApplyConfigDefaults(config) {
|
|
1129
|
+
const ctor = this.constructor;
|
|
1130
|
+
const schemaNode = ctor.getConfigSchemaNode(this.type);
|
|
1131
|
+
if (!schemaNode)
|
|
1132
|
+
return config;
|
|
1133
|
+
const result = schemaNode.validate(config);
|
|
1134
|
+
if (!result.valid) {
|
|
1135
|
+
const errorMessages = result.errors.map((e) => {
|
|
1136
|
+
const path = e.data?.pointer || "";
|
|
1137
|
+
return `${e.message}${path ? ` (${path})` : ""}`;
|
|
1138
|
+
});
|
|
1139
|
+
throw new TaskConfigurationError(`[${ctor.name}] Configuration Error: ${errorMessages.join(", ")}`);
|
|
1140
|
+
}
|
|
1141
|
+
return config;
|
|
1142
|
+
}
|
|
1082
1143
|
static _inputSchemaNode = new Map;
|
|
1083
1144
|
static generateInputSchemaNode(schema) {
|
|
1084
1145
|
if (typeof schema === "boolean") {
|
|
@@ -1143,12 +1204,16 @@ class Task {
|
|
|
1143
1204
|
}
|
|
1144
1205
|
toJSON() {
|
|
1145
1206
|
const extras = this.config.extras;
|
|
1146
|
-
|
|
1207
|
+
const json = this.stripSymbols({
|
|
1147
1208
|
id: this.config.id,
|
|
1148
1209
|
type: this.type,
|
|
1149
|
-
...this.config.name ? { name: this.config.name } : {},
|
|
1150
1210
|
defaults: this.defaults,
|
|
1151
|
-
|
|
1211
|
+
config: {
|
|
1212
|
+
...this.config.title ? { title: this.config.title } : {},
|
|
1213
|
+
...this.config.inputSchema ? { inputSchema: this.config.inputSchema } : {},
|
|
1214
|
+
...this.config.outputSchema ? { outputSchema: this.config.outputSchema } : {},
|
|
1215
|
+
...extras && Object.keys(extras).length ? { extras } : {}
|
|
1216
|
+
}
|
|
1152
1217
|
});
|
|
1153
1218
|
return json;
|
|
1154
1219
|
}
|
|
@@ -1191,12 +1256,27 @@ class Task {
|
|
|
1191
1256
|
}
|
|
1192
1257
|
|
|
1193
1258
|
// src/task/ConditionalTask.ts
|
|
1259
|
+
var conditionalTaskConfigSchema = {
|
|
1260
|
+
type: "object",
|
|
1261
|
+
properties: {
|
|
1262
|
+
...TaskConfigSchema["properties"],
|
|
1263
|
+
branches: { type: "array", items: {} },
|
|
1264
|
+
defaultBranch: { type: "string" },
|
|
1265
|
+
exclusive: { type: "boolean" },
|
|
1266
|
+
conditionConfig: { type: "object", additionalProperties: true }
|
|
1267
|
+
},
|
|
1268
|
+
additionalProperties: false
|
|
1269
|
+
};
|
|
1270
|
+
|
|
1194
1271
|
class ConditionalTask extends Task {
|
|
1195
1272
|
static type = "ConditionalTask";
|
|
1196
1273
|
static category = "Flow Control";
|
|
1197
1274
|
static title = "Condition";
|
|
1198
1275
|
static description = "Route data based on conditions";
|
|
1199
1276
|
static hasDynamicSchemas = true;
|
|
1277
|
+
static configSchema() {
|
|
1278
|
+
return conditionalTaskConfigSchema;
|
|
1279
|
+
}
|
|
1200
1280
|
activeBranches = new Set;
|
|
1201
1281
|
buildBranchesFromConditionConfig(conditionConfig) {
|
|
1202
1282
|
if (!conditionConfig?.branches || conditionConfig.branches.length === 0) {
|
|
@@ -1227,7 +1307,7 @@ class ConditionalTask extends Task {
|
|
|
1227
1307
|
fromConditionConfig: false
|
|
1228
1308
|
};
|
|
1229
1309
|
}
|
|
1230
|
-
const conditionConfig = input.conditionConfig ?? this.config.
|
|
1310
|
+
const conditionConfig = input.conditionConfig ?? this.config.conditionConfig;
|
|
1231
1311
|
if (conditionConfig) {
|
|
1232
1312
|
return {
|
|
1233
1313
|
branches: this.buildBranchesFromConditionConfig(conditionConfig),
|
|
@@ -1931,9 +2011,7 @@ class TaskGraphRunner {
|
|
|
1931
2011
|
task.runOutputData = {};
|
|
1932
2012
|
task.error = undefined;
|
|
1933
2013
|
task.progress = 0;
|
|
1934
|
-
|
|
1935
|
-
task.config.runnerId = runId;
|
|
1936
|
-
}
|
|
2014
|
+
task.runConfig = { ...task.runConfig, runnerId: runId };
|
|
1937
2015
|
this.pushStatusFromNodeToEdges(graph, task);
|
|
1938
2016
|
this.pushErrorFromNodeToEdges(graph, task);
|
|
1939
2017
|
task.emit("reset");
|
|
@@ -2097,6 +2175,15 @@ class GraphAsTaskRunner extends TaskRunner {
|
|
|
2097
2175
|
}
|
|
2098
2176
|
|
|
2099
2177
|
// src/task/GraphAsTask.ts
|
|
2178
|
+
var graphAsTaskConfigSchema = {
|
|
2179
|
+
type: "object",
|
|
2180
|
+
properties: {
|
|
2181
|
+
...TaskConfigSchema["properties"],
|
|
2182
|
+
compoundMerge: { type: "string" }
|
|
2183
|
+
},
|
|
2184
|
+
additionalProperties: false
|
|
2185
|
+
};
|
|
2186
|
+
|
|
2100
2187
|
class GraphAsTask extends Task {
|
|
2101
2188
|
static type = "GraphAsTask";
|
|
2102
2189
|
static title = "Group";
|
|
@@ -2118,11 +2205,14 @@ class GraphAsTask extends Task {
|
|
|
2118
2205
|
}
|
|
2119
2206
|
return this._runner;
|
|
2120
2207
|
}
|
|
2208
|
+
static configSchema() {
|
|
2209
|
+
return graphAsTaskConfigSchema;
|
|
2210
|
+
}
|
|
2121
2211
|
get compoundMerge() {
|
|
2122
2212
|
return this.config?.compoundMerge || this.constructor.compoundMerge;
|
|
2123
2213
|
}
|
|
2124
2214
|
get cacheable() {
|
|
2125
|
-
return this.config?.cacheable ?? (this.constructor.cacheable && !this.hasChildren());
|
|
2215
|
+
return this.runConfig?.cacheable ?? this.config?.cacheable ?? (this.constructor.cacheable && !this.hasChildren());
|
|
2126
2216
|
}
|
|
2127
2217
|
inputSchema() {
|
|
2128
2218
|
if (!this.hasChildren()) {
|
|
@@ -2999,17 +3089,19 @@ function ensureTask(arg, config = {}) {
|
|
|
2999
3089
|
return arg;
|
|
3000
3090
|
}
|
|
3001
3091
|
if (arg instanceof TaskGraph) {
|
|
3002
|
-
|
|
3003
|
-
|
|
3092
|
+
const { isOwned, ...cleanConfig } = config;
|
|
3093
|
+
if (isOwned) {
|
|
3094
|
+
return new OwnGraphTask({}, { ...cleanConfig, subGraph: arg });
|
|
3004
3095
|
} else {
|
|
3005
|
-
return new GraphTask({}, { ...
|
|
3096
|
+
return new GraphTask({}, { ...cleanConfig, subGraph: arg });
|
|
3006
3097
|
}
|
|
3007
3098
|
}
|
|
3008
3099
|
if (arg instanceof Workflow) {
|
|
3009
|
-
|
|
3010
|
-
|
|
3100
|
+
const { isOwned, ...cleanConfig } = config;
|
|
3101
|
+
if (isOwned) {
|
|
3102
|
+
return new OwnWorkflowTask({}, { ...cleanConfig, subGraph: arg.graph });
|
|
3011
3103
|
} else {
|
|
3012
|
-
return new WorkflowTask2({}, { ...
|
|
3104
|
+
return new WorkflowTask2({}, { ...cleanConfig, subGraph: arg.graph });
|
|
3013
3105
|
}
|
|
3014
3106
|
}
|
|
3015
3107
|
return convertPipeFunctionToTask(arg, config);
|
|
@@ -3486,6 +3578,16 @@ var ITERATOR_CONTEXT_SCHEMA = {
|
|
|
3486
3578
|
}
|
|
3487
3579
|
}
|
|
3488
3580
|
};
|
|
3581
|
+
var iteratorTaskConfigSchema = {
|
|
3582
|
+
type: "object",
|
|
3583
|
+
properties: {
|
|
3584
|
+
...graphAsTaskConfigSchema["properties"],
|
|
3585
|
+
concurrencyLimit: { type: "integer", minimum: 1 },
|
|
3586
|
+
batchSize: { type: "integer", minimum: 1 },
|
|
3587
|
+
iterationInputConfig: { type: "object", additionalProperties: true }
|
|
3588
|
+
},
|
|
3589
|
+
additionalProperties: false
|
|
3590
|
+
};
|
|
3489
3591
|
function isArrayVariant(schema) {
|
|
3490
3592
|
if (!schema || typeof schema !== "object")
|
|
3491
3593
|
return false;
|
|
@@ -3594,6 +3696,9 @@ class IteratorTask extends GraphAsTask {
|
|
|
3594
3696
|
static title = "Iterator";
|
|
3595
3697
|
static description = "Base class for loop-type tasks";
|
|
3596
3698
|
static hasDynamicSchemas = true;
|
|
3699
|
+
static configSchema() {
|
|
3700
|
+
return iteratorTaskConfigSchema;
|
|
3701
|
+
}
|
|
3597
3702
|
static getIterationContextSchema() {
|
|
3598
3703
|
return ITERATOR_CONTEXT_SCHEMA;
|
|
3599
3704
|
}
|
|
@@ -3954,6 +4059,20 @@ var WHILE_CONTEXT_SCHEMA = {
|
|
|
3954
4059
|
}
|
|
3955
4060
|
}
|
|
3956
4061
|
};
|
|
4062
|
+
var whileTaskConfigSchema = {
|
|
4063
|
+
type: "object",
|
|
4064
|
+
properties: {
|
|
4065
|
+
...graphAsTaskConfigSchema["properties"],
|
|
4066
|
+
condition: {},
|
|
4067
|
+
maxIterations: { type: "integer", minimum: 1 },
|
|
4068
|
+
chainIterations: { type: "boolean" },
|
|
4069
|
+
conditionField: { type: "string" },
|
|
4070
|
+
conditionOperator: { type: "string" },
|
|
4071
|
+
conditionValue: { type: "string" },
|
|
4072
|
+
iterationInputConfig: { type: "object", additionalProperties: true }
|
|
4073
|
+
},
|
|
4074
|
+
additionalProperties: false
|
|
4075
|
+
};
|
|
3957
4076
|
|
|
3958
4077
|
class WhileTask extends GraphAsTask {
|
|
3959
4078
|
static type = "WhileTask";
|
|
@@ -3961,6 +4080,9 @@ class WhileTask extends GraphAsTask {
|
|
|
3961
4080
|
static title = "While Loop";
|
|
3962
4081
|
static description = "Loops until a condition function returns false";
|
|
3963
4082
|
static hasDynamicSchemas = true;
|
|
4083
|
+
static configSchema() {
|
|
4084
|
+
return whileTaskConfigSchema;
|
|
4085
|
+
}
|
|
3964
4086
|
static getIterationContextSchema() {
|
|
3965
4087
|
return WHILE_CONTEXT_SCHEMA;
|
|
3966
4088
|
}
|
|
@@ -3978,38 +4100,30 @@ class WhileTask extends GraphAsTask {
|
|
|
3978
4100
|
return this.config.condition;
|
|
3979
4101
|
}
|
|
3980
4102
|
get maxIterations() {
|
|
3981
|
-
|
|
3982
|
-
return this.config.maxIterations;
|
|
3983
|
-
const wc = this.config.extras?.whileConfig;
|
|
3984
|
-
return wc?.maxIterations ?? 100;
|
|
4103
|
+
return this.config.maxIterations ?? 100;
|
|
3985
4104
|
}
|
|
3986
4105
|
get chainIterations() {
|
|
3987
|
-
|
|
3988
|
-
return this.config.chainIterations;
|
|
3989
|
-
const wc = this.config.extras?.whileConfig;
|
|
3990
|
-
return wc?.chainIterations ?? true;
|
|
4106
|
+
return this.config.chainIterations ?? true;
|
|
3991
4107
|
}
|
|
3992
4108
|
get currentIteration() {
|
|
3993
4109
|
return this._currentIteration;
|
|
3994
4110
|
}
|
|
3995
|
-
|
|
3996
|
-
const
|
|
3997
|
-
if (!
|
|
4111
|
+
buildConditionFromConfig() {
|
|
4112
|
+
const { conditionOperator, conditionField, conditionValue } = this.config;
|
|
4113
|
+
if (!conditionOperator) {
|
|
3998
4114
|
return;
|
|
3999
4115
|
}
|
|
4000
|
-
const { conditionField, conditionOperator, conditionValue } = wc;
|
|
4001
4116
|
return (output) => {
|
|
4002
4117
|
const fieldValue = conditionField ? getNestedValue(output, conditionField) : output;
|
|
4003
4118
|
return evaluateCondition(fieldValue, conditionOperator, conditionValue ?? "");
|
|
4004
4119
|
};
|
|
4005
4120
|
}
|
|
4006
4121
|
analyzeArrayInputs(input) {
|
|
4007
|
-
|
|
4008
|
-
if (!wc?.iterationInputConfig) {
|
|
4122
|
+
if (!this.config.iterationInputConfig) {
|
|
4009
4123
|
return null;
|
|
4010
4124
|
}
|
|
4011
4125
|
const inputData = input;
|
|
4012
|
-
const config =
|
|
4126
|
+
const config = this.config.iterationInputConfig;
|
|
4013
4127
|
const arrayPorts = [];
|
|
4014
4128
|
const scalarPorts = [];
|
|
4015
4129
|
const iteratedValues = {};
|
|
@@ -4065,7 +4179,7 @@ class WhileTask extends GraphAsTask {
|
|
|
4065
4179
|
if (!this.hasChildren()) {
|
|
4066
4180
|
throw new TaskConfigurationError(`${this.type}: No subgraph set for while loop`);
|
|
4067
4181
|
}
|
|
4068
|
-
const condition = this.condition ?? this.
|
|
4182
|
+
const condition = this.condition ?? this.buildConditionFromConfig();
|
|
4069
4183
|
if (!condition) {
|
|
4070
4184
|
throw new TaskConfigurationError(`${this.type}: No condition function provided`);
|
|
4071
4185
|
}
|
|
@@ -4110,7 +4224,7 @@ class WhileTask extends GraphAsTask {
|
|
|
4110
4224
|
if (!this.hasChildren()) {
|
|
4111
4225
|
throw new TaskConfigurationError(`${this.type}: No subgraph set for while loop`);
|
|
4112
4226
|
}
|
|
4113
|
-
const condition = this.condition ?? this.
|
|
4227
|
+
const condition = this.condition ?? this.buildConditionFromConfig();
|
|
4114
4228
|
if (!condition) {
|
|
4115
4229
|
throw new TaskConfigurationError(`${this.type}: No condition function provided`);
|
|
4116
4230
|
}
|
|
@@ -4180,12 +4294,11 @@ class WhileTask extends GraphAsTask {
|
|
|
4180
4294
|
const baseSchema = super.inputSchema();
|
|
4181
4295
|
if (typeof baseSchema === "boolean")
|
|
4182
4296
|
return baseSchema;
|
|
4183
|
-
|
|
4184
|
-
if (!wc?.iterationInputConfig) {
|
|
4297
|
+
if (!this.config.iterationInputConfig) {
|
|
4185
4298
|
return baseSchema;
|
|
4186
4299
|
}
|
|
4187
4300
|
const properties = { ...baseSchema.properties || {} };
|
|
4188
|
-
for (const [key, propConfig] of Object.entries(
|
|
4301
|
+
for (const [key, propConfig] of Object.entries(this.config.iterationInputConfig)) {
|
|
4189
4302
|
if (propConfig.mode === "array" && properties[key]) {
|
|
4190
4303
|
const scalarSchema = properties[key];
|
|
4191
4304
|
properties[key] = {
|
|
@@ -4594,9 +4707,21 @@ function setTaskQueueRegistry(registry) {
|
|
|
4594
4707
|
}
|
|
4595
4708
|
|
|
4596
4709
|
// src/task/JobQueueTask.ts
|
|
4710
|
+
var jobQueueTaskConfigSchema = {
|
|
4711
|
+
type: "object",
|
|
4712
|
+
properties: {
|
|
4713
|
+
...graphAsTaskConfigSchema["properties"],
|
|
4714
|
+
queue: {}
|
|
4715
|
+
},
|
|
4716
|
+
additionalProperties: false
|
|
4717
|
+
};
|
|
4718
|
+
|
|
4597
4719
|
class JobQueueTask extends GraphAsTask {
|
|
4598
4720
|
static type = "JobQueueTask";
|
|
4599
4721
|
static canRunDirectly = true;
|
|
4722
|
+
static configSchema() {
|
|
4723
|
+
return jobQueueTaskConfigSchema;
|
|
4724
|
+
}
|
|
4600
4725
|
currentQueueName;
|
|
4601
4726
|
currentJobId;
|
|
4602
4727
|
currentRunnerId;
|
|
@@ -4727,11 +4852,24 @@ class JobQueueTask extends GraphAsTask {
|
|
|
4727
4852
|
}
|
|
4728
4853
|
}
|
|
4729
4854
|
// src/task/MapTask.ts
|
|
4855
|
+
var mapTaskConfigSchema = {
|
|
4856
|
+
type: "object",
|
|
4857
|
+
properties: {
|
|
4858
|
+
...iteratorTaskConfigSchema["properties"],
|
|
4859
|
+
preserveOrder: { type: "boolean" },
|
|
4860
|
+
flatten: { type: "boolean" }
|
|
4861
|
+
},
|
|
4862
|
+
additionalProperties: false
|
|
4863
|
+
};
|
|
4864
|
+
|
|
4730
4865
|
class MapTask extends IteratorTask {
|
|
4731
4866
|
static type = "MapTask";
|
|
4732
4867
|
static category = "Flow Control";
|
|
4733
4868
|
static title = "Map";
|
|
4734
4869
|
static description = "Transforms array inputs by running a workflow per item";
|
|
4870
|
+
static configSchema() {
|
|
4871
|
+
return mapTaskConfigSchema;
|
|
4872
|
+
}
|
|
4735
4873
|
static compoundMerge = PROPERTY_ARRAY;
|
|
4736
4874
|
static inputSchema() {
|
|
4737
4875
|
return {
|
|
@@ -4794,11 +4932,23 @@ queueMicrotask(() => {
|
|
|
4794
4932
|
Workflow.prototype.endMap = CreateEndLoopWorkflow("endMap");
|
|
4795
4933
|
});
|
|
4796
4934
|
// src/task/ReduceTask.ts
|
|
4935
|
+
var reduceTaskConfigSchema = {
|
|
4936
|
+
type: "object",
|
|
4937
|
+
properties: {
|
|
4938
|
+
...iteratorTaskConfigSchema["properties"],
|
|
4939
|
+
initialValue: {}
|
|
4940
|
+
},
|
|
4941
|
+
additionalProperties: false
|
|
4942
|
+
};
|
|
4943
|
+
|
|
4797
4944
|
class ReduceTask extends IteratorTask {
|
|
4798
4945
|
static type = "ReduceTask";
|
|
4799
4946
|
static category = "Flow Control";
|
|
4800
4947
|
static title = "Reduce";
|
|
4801
4948
|
static description = "Processes iterated inputs sequentially with an accumulator (fold)";
|
|
4949
|
+
static configSchema() {
|
|
4950
|
+
return reduceTaskConfigSchema;
|
|
4951
|
+
}
|
|
4802
4952
|
constructor(input = {}, config = {}) {
|
|
4803
4953
|
const reduceConfig = {
|
|
4804
4954
|
...config,
|
|
@@ -4898,9 +5048,8 @@ var createSingleTaskFromJSON = (item) => {
|
|
|
4898
5048
|
if (!taskClass)
|
|
4899
5049
|
throw new TaskJSONError(`Task type ${item.type} not found, perhaps not registered?`);
|
|
4900
5050
|
const taskConfig = {
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
extras: item.extras
|
|
5051
|
+
...item.config,
|
|
5052
|
+
id: item.id
|
|
4904
5053
|
};
|
|
4905
5054
|
const task = new taskClass(item.defaults ?? {}, taskConfig);
|
|
4906
5055
|
return task;
|
|
@@ -5106,6 +5255,7 @@ class TaskOutputTabularRepository extends TaskOutputRepository {
|
|
|
5106
5255
|
}
|
|
5107
5256
|
export {
|
|
5108
5257
|
wrapSchemaInArray,
|
|
5258
|
+
whileTaskConfigSchema,
|
|
5109
5259
|
setTaskQueueRegistry,
|
|
5110
5260
|
serialGraph,
|
|
5111
5261
|
schemaAcceptsArray,
|
|
@@ -5113,15 +5263,20 @@ export {
|
|
|
5113
5263
|
removeIterationProperties,
|
|
5114
5264
|
registerJobQueueFactory,
|
|
5115
5265
|
registerBaseTasks,
|
|
5266
|
+
reduceTaskConfigSchema,
|
|
5116
5267
|
pipe,
|
|
5117
5268
|
parallel,
|
|
5118
5269
|
mergeChainedOutputToInput,
|
|
5270
|
+
mapTaskConfigSchema,
|
|
5271
|
+
jobQueueTaskConfigSchema,
|
|
5272
|
+
iteratorTaskConfigSchema,
|
|
5119
5273
|
isTaskStreamable,
|
|
5120
5274
|
isStrictArraySchema,
|
|
5121
5275
|
isIterationProperty,
|
|
5122
5276
|
isFlexibleSchema,
|
|
5123
5277
|
hasVectorOutput,
|
|
5124
5278
|
hasVectorLikeInput,
|
|
5279
|
+
graphAsTaskConfigSchema,
|
|
5125
5280
|
getTaskQueueRegistry,
|
|
5126
5281
|
getStreamingPorts,
|
|
5127
5282
|
getPortStreamMode,
|
|
@@ -5147,6 +5302,7 @@ export {
|
|
|
5147
5302
|
createFlexibleSchema,
|
|
5148
5303
|
createArraySchema,
|
|
5149
5304
|
connect,
|
|
5305
|
+
conditionalTaskConfigSchema,
|
|
5150
5306
|
buildIterationInputSchema,
|
|
5151
5307
|
addIterationContextToSchema,
|
|
5152
5308
|
WorkflowError,
|
|
@@ -5172,6 +5328,7 @@ export {
|
|
|
5172
5328
|
TaskFailedError,
|
|
5173
5329
|
TaskError,
|
|
5174
5330
|
TaskConfigurationError,
|
|
5331
|
+
TaskConfigSchema,
|
|
5175
5332
|
TaskAbortedError,
|
|
5176
5333
|
Task,
|
|
5177
5334
|
TASK_OUTPUT_REPOSITORY,
|
|
@@ -5201,4 +5358,4 @@ export {
|
|
|
5201
5358
|
ConditionalTask
|
|
5202
5359
|
};
|
|
5203
5360
|
|
|
5204
|
-
//# debugId=
|
|
5361
|
+
//# debugId=75D3D24E4274E79564756E2164756E21
|