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