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