@workglow/task-graph 0.0.103 → 0.0.105

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/node.js CHANGED
@@ -799,6 +799,26 @@ function getSchemaFormat(schema) {
799
799
  }
800
800
  return;
801
801
  }
802
+ function getObjectSchema(schema) {
803
+ if (typeof schema !== "object" || schema === null)
804
+ return;
805
+ const s = schema;
806
+ if (s.type === "object" && s.properties && typeof s.properties === "object") {
807
+ return s;
808
+ }
809
+ const variants = s.oneOf ?? s.anyOf;
810
+ if (Array.isArray(variants)) {
811
+ for (const variant of variants) {
812
+ if (typeof variant === "object" && variant !== null) {
813
+ const v = variant;
814
+ if (v.type === "object" && v.properties && typeof v.properties === "object") {
815
+ return v;
816
+ }
817
+ }
818
+ }
819
+ }
820
+ return;
821
+ }
802
822
  function getFormatPrefix(format) {
803
823
  const colonIndex = format.indexOf(":");
804
824
  return colonIndex >= 0 ? format.substring(0, colonIndex) : format;
@@ -812,22 +832,30 @@ async function resolveSchemaInputs(input, schema, config) {
812
832
  const resolvers = getInputResolvers();
813
833
  const resolved = { ...input };
814
834
  for (const [key, propSchema] of Object.entries(properties)) {
815
- const value = resolved[key];
835
+ let value = resolved[key];
816
836
  const format = getSchemaFormat(propSchema);
817
- if (!format)
818
- continue;
819
- let resolver = resolvers.get(format);
820
- if (!resolver) {
821
- const prefix = getFormatPrefix(format);
822
- resolver = resolvers.get(prefix);
837
+ if (format) {
838
+ let resolver = resolvers.get(format);
839
+ if (!resolver) {
840
+ const prefix = getFormatPrefix(format);
841
+ resolver = resolvers.get(prefix);
842
+ }
843
+ if (resolver) {
844
+ if (typeof value === "string") {
845
+ value = await resolver(value, format, config.registry);
846
+ resolved[key] = value;
847
+ } else if (Array.isArray(value) && value.every((item) => typeof item === "string")) {
848
+ const results = await Promise.all(value.map((item) => resolver(item, format, config.registry)));
849
+ value = results.filter((result) => result !== undefined);
850
+ resolved[key] = value;
851
+ }
852
+ }
823
853
  }
824
- if (!resolver)
825
- continue;
826
- if (typeof value === "string") {
827
- resolved[key] = await resolver(value, format, config.registry);
828
- } else if (Array.isArray(value) && value.every((item) => typeof item === "string")) {
829
- const results = await Promise.all(value.map((item) => resolver(item, format, config.registry)));
830
- resolved[key] = results.filter((result) => result !== undefined);
854
+ if (value !== null && value !== undefined && typeof value === "object" && !Array.isArray(value)) {
855
+ const objectSchema = getObjectSchema(propSchema);
856
+ if (objectSchema) {
857
+ resolved[key] = await resolveSchemaInputs(value, objectSchema, config);
858
+ }
831
859
  }
832
860
  }
833
861
  return resolved;
@@ -1475,7 +1503,7 @@ class Task {
1475
1503
  this.runInputData[inputId] = prop.default;
1476
1504
  }
1477
1505
  }
1478
- if (schema.additionalProperties === true) {
1506
+ if (schema.additionalProperties) {
1479
1507
  for (const [inputId, value] of Object.entries(input)) {
1480
1508
  if (!(inputId in properties)) {
1481
1509
  this.runInputData[inputId] = value;
@@ -1528,7 +1556,7 @@ class Task {
1528
1556
  }
1529
1557
  }
1530
1558
  }
1531
- if (inputSchema.additionalProperties === true) {
1559
+ if (inputSchema.additionalProperties) {
1532
1560
  for (const [inputId, value] of Object.entries(overrides)) {
1533
1561
  if (!(inputId in properties)) {
1534
1562
  if (!deepEqual(this.runInputData[inputId], value)) {
@@ -2250,13 +2278,24 @@ class TaskGraphRunner {
2250
2278
  const dataflows = this.graph.getTargetDataflows(node.id);
2251
2279
  for (const dataflow of dataflows) {
2252
2280
  const compatibility = dataflow.semanticallyCompatible(this.graph, dataflow);
2281
+ getLogger3().debug("pushOutputFromNodeToEdges", {
2282
+ dataflowId: dataflow.id,
2283
+ compatibility,
2284
+ resultsKeys: Object.keys(results)
2285
+ });
2253
2286
  if (compatibility === "static") {
2254
2287
  dataflow.setPortData(results);
2255
2288
  } else if (compatibility === "runtime") {
2256
2289
  const task = this.graph.getTask(dataflow.targetTaskId);
2257
2290
  const narrowed = await task.narrowInput({ ...results }, this.registry);
2258
2291
  dataflow.setPortData(narrowed);
2259
- } else {}
2292
+ } else {
2293
+ getLogger3().warn("pushOutputFromNodeToEdges", {
2294
+ dataflowId: dataflow.id,
2295
+ compatibility,
2296
+ resultsKeys: Object.keys(results)
2297
+ });
2298
+ }
2260
2299
  }
2261
2300
  }
2262
2301
  pushStatusFromNodeToEdges(graph, node, status) {
@@ -6166,4 +6205,4 @@ export {
6166
6205
  ConditionalTask
6167
6206
  };
6168
6207
 
6169
- //# debugId=2492C1E27B2BED5064756E2164756E21
6208
+ //# debugId=E66B1E17B5EBC70464756E2164756E21