diff --git a/lib/graphai.js b/lib/graphai.js index 560df1b58..85cb18634 100644 --- a/lib/graphai.js +++ b/lib/graphai.js @@ -40,8 +40,7 @@ class GraphAI { }); return nodes; } - getValueFromResults(key, results) { - const source = (0, utils_1.parseNodeName)(key, this.version); + getValueFromResults(source, results) { return (0, utils_1.getDataFromSource)(source.nodeId ? results[source.nodeId] : undefined, source); } // for static @@ -59,7 +58,7 @@ class GraphAI { const update = node?.update; if (update && previousResults) { const result = this.getValueFromResults(update, previousResults); - this.injectValue(nodeId, result, update); + this.injectValue(nodeId, result, update.nodeId); } } }); @@ -199,7 +198,8 @@ class GraphAI { this.initializeNodes(results); // Notice that we need to check the while condition *after* calling initializeNodes. if (loop.while) { - const value = this.getValueFromResults(loop.while, this.results(true)); + const source = (0, utils_1.parseNodeName)(loop.while, this.version); + const value = this.getValueFromResults(source, this.results(true)); // NOTE: We treat an empty array as false. if (Array.isArray(value) ? value.length === 0 : !value) { return false; // while condition is not met diff --git a/lib/node.d.ts b/lib/node.d.ts index 84608871b..773fa221f 100644 --- a/lib/node.d.ts +++ b/lib/node.d.ts @@ -49,7 +49,7 @@ export declare class ComputedNode extends Node { } export declare class StaticNode extends Node { value?: ResultData; - readonly update?: string; + readonly update?: DataSource; readonly isResult: boolean; readonly isStaticNode = true; readonly isComputedNode = false; diff --git a/lib/node.js b/lib/node.js index 267c5a7d6..3b6e887fa 100644 --- a/lib/node.js +++ b/lib/node.js @@ -280,7 +280,7 @@ class StaticNode extends Node { this.isStaticNode = true; this.isComputedNode = false; this.value = data.value; - this.update = data.update; + this.update = data.update ? (0, utils_2.parseNodeName)(data.update, graph.version) : undefined; this.isResult = data.isResult ?? false; } injectValue(value, injectFrom) {