graphai 2.0.11 → 2.0.12
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/lib/bundle.cjs.js +1 -1
- package/lib/bundle.cjs.js.map +1 -1
- package/lib/bundle.esm.js +27 -4
- package/lib/bundle.esm.js.map +1 -1
- package/lib/bundle.umd.js +1 -1
- package/lib/bundle.umd.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -1
- package/lib/node.d.ts +1 -0
- package/lib/node.js +9 -0
- package/lib/type.d.ts +4 -0
- package/lib/utils/data_source.js +1 -1
- package/lib/utils/prop_function.js +15 -2
- package/lib/validators/common.js +1 -0
- package/package.json +1 -1
package/lib/node.js
CHANGED
|
@@ -64,6 +64,7 @@ class ComputedNode extends Node {
|
|
|
64
64
|
this.filterParams = data.filterParams ?? {};
|
|
65
65
|
this.passThrough = data.passThrough;
|
|
66
66
|
this.retryLimit = data.retry ?? graph.retryLimit ?? 0;
|
|
67
|
+
this.repeatUntil = data.repeatUntil;
|
|
67
68
|
this.timeout = data.timeout;
|
|
68
69
|
this.isResult = data.isResult ?? false;
|
|
69
70
|
this.priority = data.priority ?? 0;
|
|
@@ -299,6 +300,14 @@ class ComputedNode extends Node {
|
|
|
299
300
|
GraphAILogger_1.GraphAILogger.log(`-- transactionId mismatch with ${this.nodeId} (probably timeout)`);
|
|
300
301
|
return;
|
|
301
302
|
}
|
|
303
|
+
if (this.repeatUntil?.exists) {
|
|
304
|
+
const dummyResult = { self: { result: this.getResult(result) } };
|
|
305
|
+
const repeatResult = (0, result_1.resultsOf)({ data: this.repeatUntil?.exists }, dummyResult, [], true);
|
|
306
|
+
if ((0, utils_1.isNull)(repeatResult?.data)) {
|
|
307
|
+
this.retry(type_1.NodeState.Failed, Error("Repeat Until"));
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
302
311
|
// after process
|
|
303
312
|
this.afterExecute(result, localLog);
|
|
304
313
|
}
|
package/lib/type.d.ts
CHANGED
|
@@ -45,6 +45,9 @@ export type GraphDataLoaderOption = {
|
|
|
45
45
|
fileName: string;
|
|
46
46
|
option?: any;
|
|
47
47
|
};
|
|
48
|
+
export type RepeatUntil = {
|
|
49
|
+
exists?: string;
|
|
50
|
+
};
|
|
48
51
|
export type ComputedNodeData = {
|
|
49
52
|
agent: string | AgentAnonymousFunction;
|
|
50
53
|
inputs?: Record<string, any>;
|
|
@@ -53,6 +56,7 @@ export type ComputedNodeData = {
|
|
|
53
56
|
params?: NodeDataParams;
|
|
54
57
|
filterParams?: AgentFilterParams;
|
|
55
58
|
retry?: number;
|
|
59
|
+
repeatUntil?: RepeatUntil;
|
|
56
60
|
timeout?: number;
|
|
57
61
|
if?: string;
|
|
58
62
|
unless?: string;
|
package/lib/utils/data_source.js
CHANGED
|
@@ -35,7 +35,7 @@ const getNestedData = (result, propId, propFunctions) => {
|
|
|
35
35
|
return undefined;
|
|
36
36
|
};
|
|
37
37
|
const innerGetDataFromSource = (result, propIds, propFunctions) => {
|
|
38
|
-
if (
|
|
38
|
+
if (propIds && propIds.length > 0) {
|
|
39
39
|
const propId = propIds[0];
|
|
40
40
|
const ret = getNestedData(result, propId, propFunctions);
|
|
41
41
|
if (ret === undefined) {
|
|
@@ -116,7 +116,7 @@ const propNumberFunction = (result, propId) => {
|
|
|
116
116
|
if (match) {
|
|
117
117
|
return Number(result) + Number(match[1]);
|
|
118
118
|
}
|
|
119
|
-
const equalMatch = propId.match(/^equal\(([A-Za-z0-9!#$%&()
|
|
119
|
+
const equalMatch = propId.match(/^equal\(([A-Za-z0-9!#$%&()*+,\-/:;<=>?@]+)\)/);
|
|
120
120
|
if (equalMatch) {
|
|
121
121
|
return result === Number(equalMatch[1]);
|
|
122
122
|
}
|
|
@@ -131,7 +131,20 @@ const propBooleanFunction = (result, propId) => {
|
|
|
131
131
|
}
|
|
132
132
|
return undefined;
|
|
133
133
|
};
|
|
134
|
-
|
|
134
|
+
const propUndefinrdFunction = (result, propId) => {
|
|
135
|
+
if (result === undefined) {
|
|
136
|
+
const equalMatch = propId.match(/^default\(([A-Za-z0-9!#$%&()*+,\-/:;<=>?@]+)\)/);
|
|
137
|
+
if (equalMatch) {
|
|
138
|
+
if (equalMatch[1].match(/^[0-9-]+$/)) {
|
|
139
|
+
return Number(equalMatch[1]);
|
|
140
|
+
}
|
|
141
|
+
return equalMatch[1];
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return undefined;
|
|
145
|
+
};
|
|
146
|
+
// TODO if (result === undefined) {default()}
|
|
147
|
+
exports.propFunctions = [propArrayFunction, propObjectFunction, propStringFunction, propNumberFunction, propBooleanFunction, propUndefinrdFunction];
|
|
135
148
|
const utilsFunctions = (input, nodes) => {
|
|
136
149
|
if (input === "@now" || input === "@now_ms") {
|
|
137
150
|
return Date.now();
|
package/lib/validators/common.js
CHANGED