Skip to content

Commit

Permalink
Update lib
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Actions Bot committed May 9, 2024
1 parent 4638f85 commit 9c3c5ba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/node.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export declare class ComputedNode extends Node {
readonly graphId: string;
readonly isResult: boolean;
readonly params: NodeDataParams;
private readonly dynamicParams;
readonly nestedGraph?: GraphData;
readonly retryLimit: number;
retryCount: number;
Expand Down
19 changes: 18 additions & 1 deletion lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ class ComputedNode extends Node {
(0, utils_2.assert)(!!this.ifSource.nodeId, `Invalid data source ${data.if}`);
this.pendings.add(this.ifSource.nodeId);
}
const regex = /^\$\{([^{}]+)\}$/;
this.dynamicParams = Object.keys(this.params).reduce((tmp, key) => {
const value = this.params[key];
const match = typeof value === "string" ? value.match(regex) : null;
if (match) {
const dataSource = (0, utils_2.parseNodeName)(match[1]);
tmp[key] = dataSource;
(0, utils_2.assert)(!!dataSource.nodeId, `Invalid data source ${key}:${value}`);
this.pendings.add(dataSource.nodeId);
}
return tmp;
}, {});
this.log.initForComputedNode(this);
}
getAgentId() {
Expand Down Expand Up @@ -190,8 +202,13 @@ class ComputedNode extends Node {
try {
const callback = this.agentFunction ?? this.graph.getCallback(this.agentId);
const localLog = [];
const params = Object.keys(this.dynamicParams).reduce((tmp, key) => {
const [result] = this.graph.resultsOf([this.dynamicParams[key]]);
tmp[key] = result;
return tmp;
}, { ...this.params });
const context = {
params: this.params,
params: params,
inputs: previousResults,
debugInfo: {
nodeId: this.nodeId,
Expand Down

0 comments on commit 9c3c5ba

Please sign in to comment.