@workglow/task-graph 0.0.55 → 0.0.57
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 +53 -5
- package/dist/browser.js.map +6 -6
- package/dist/bun.js +53 -5
- package/dist/bun.js.map +6 -6
- package/dist/node.js +53 -5
- package/dist/node.js.map +6 -6
- package/dist/task/Task.d.ts.map +1 -1
- package/dist/task/TaskJSON.d.ts +3 -3
- package/dist/task/TaskJSON.d.ts.map +1 -1
- package/dist/task-graph/ITaskGraph.d.ts +3 -1
- package/dist/task-graph/ITaskGraph.d.ts.map +1 -1
- package/dist/task-graph/TaskGraph.d.ts +17 -1
- package/dist/task-graph/TaskGraph.d.ts.map +1 -1
- package/dist/task-graph/TaskGraphEvents.d.ts +8 -8
- package/dist/task-graph/TaskGraphEvents.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/browser.js
CHANGED
|
@@ -779,7 +779,7 @@ class Task {
|
|
|
779
779
|
let json = this.stripSymbols({
|
|
780
780
|
id: this.config.id,
|
|
781
781
|
type: this.type,
|
|
782
|
-
|
|
782
|
+
defaults: this.defaults,
|
|
783
783
|
...Object.keys(provenance).length ? { provenance } : {},
|
|
784
784
|
...extras && Object.keys(extras).length ? { extras } : {}
|
|
785
785
|
});
|
|
@@ -2217,6 +2217,54 @@ class TaskGraph {
|
|
|
2217
2217
|
this.on(name, fn);
|
|
2218
2218
|
return () => this.off(name, fn);
|
|
2219
2219
|
}
|
|
2220
|
+
subscribeToTaskStatus(callback) {
|
|
2221
|
+
const unsubscribes = [];
|
|
2222
|
+
const tasks = this.getTasks();
|
|
2223
|
+
tasks.forEach((task) => {
|
|
2224
|
+
const unsub = task.subscribe("status", (status) => {
|
|
2225
|
+
callback(task.config.id, status);
|
|
2226
|
+
});
|
|
2227
|
+
unsubscribes.push(unsub);
|
|
2228
|
+
});
|
|
2229
|
+
const handleTaskAdded = (taskId) => {
|
|
2230
|
+
const task = this.getTask(taskId);
|
|
2231
|
+
if (!task || typeof task.subscribe !== "function")
|
|
2232
|
+
return;
|
|
2233
|
+
const unsub = task.subscribe("status", (status) => {
|
|
2234
|
+
callback(task.config.id, status);
|
|
2235
|
+
});
|
|
2236
|
+
unsubscribes.push(unsub);
|
|
2237
|
+
};
|
|
2238
|
+
const graphUnsub = this.subscribe("task_added", handleTaskAdded);
|
|
2239
|
+
unsubscribes.push(graphUnsub);
|
|
2240
|
+
return () => {
|
|
2241
|
+
unsubscribes.forEach((unsub) => unsub());
|
|
2242
|
+
};
|
|
2243
|
+
}
|
|
2244
|
+
subscribeToDataflowStatus(callback) {
|
|
2245
|
+
const unsubscribes = [];
|
|
2246
|
+
const dataflows = this.getDataflows();
|
|
2247
|
+
dataflows.forEach((dataflow) => {
|
|
2248
|
+
const unsub = dataflow.subscribe("status", (status) => {
|
|
2249
|
+
callback(dataflow.id, status);
|
|
2250
|
+
});
|
|
2251
|
+
unsubscribes.push(unsub);
|
|
2252
|
+
});
|
|
2253
|
+
const handleDataflowAdded = (dataflowId) => {
|
|
2254
|
+
const dataflow = this.getDataflow(dataflowId);
|
|
2255
|
+
if (!dataflow || typeof dataflow.subscribe !== "function")
|
|
2256
|
+
return;
|
|
2257
|
+
const unsub = dataflow.subscribe("status", (status) => {
|
|
2258
|
+
callback(dataflow.id, status);
|
|
2259
|
+
});
|
|
2260
|
+
unsubscribes.push(unsub);
|
|
2261
|
+
};
|
|
2262
|
+
const graphUnsub = this.subscribe("dataflow_added", handleDataflowAdded);
|
|
2263
|
+
unsubscribes.push(graphUnsub);
|
|
2264
|
+
return () => {
|
|
2265
|
+
unsubscribes.forEach((unsub) => unsub());
|
|
2266
|
+
};
|
|
2267
|
+
}
|
|
2220
2268
|
on(name, fn) {
|
|
2221
2269
|
const dagEvent = EventTaskGraphToDagMapping[name];
|
|
2222
2270
|
if (dagEvent) {
|
|
@@ -2578,8 +2626,8 @@ var createSingleTaskFromJSON = (item) => {
|
|
|
2578
2626
|
throw new TaskJSONError("Task id required");
|
|
2579
2627
|
if (!item.type)
|
|
2580
2628
|
throw new TaskJSONError("Task type required");
|
|
2581
|
-
if (item.
|
|
2582
|
-
throw new TaskJSONError("Task
|
|
2629
|
+
if (item.defaults && (Array.isArray(item.defaults) || Array.isArray(item.provenance)))
|
|
2630
|
+
throw new TaskJSONError("Task defaults must be an object");
|
|
2583
2631
|
if (item.provenance && (Array.isArray(item.provenance) || typeof item.provenance !== "object"))
|
|
2584
2632
|
throw new TaskJSONError("Task provenance must be an object");
|
|
2585
2633
|
const taskClass = TaskRegistry.all.get(item.type);
|
|
@@ -2591,7 +2639,7 @@ var createSingleTaskFromJSON = (item) => {
|
|
|
2591
2639
|
provenance: item.provenance ?? {},
|
|
2592
2640
|
extras: item.extras
|
|
2593
2641
|
};
|
|
2594
|
-
const task = new taskClass(item.
|
|
2642
|
+
const task = new taskClass(item.defaults ?? {}, taskConfig);
|
|
2595
2643
|
return task;
|
|
2596
2644
|
};
|
|
2597
2645
|
var createTaskFromDependencyJSON = (item) => {
|
|
@@ -2839,4 +2887,4 @@ export {
|
|
|
2839
2887
|
ArrayTask
|
|
2840
2888
|
};
|
|
2841
2889
|
|
|
2842
|
-
//# debugId=
|
|
2890
|
+
//# debugId=903B84386F51FF2464756E2164756E21
|