graphai 1.0.6 → 1.0.8
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 +37 -8
- 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/graphai.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/node.js +6 -2
- package/lib/utils/prop_function.d.ts +1 -0
- package/lib/utils/prop_function.js +13 -1
- package/lib/utils/result.js +20 -5
- package/package.json +1 -1
package/lib/utils/result.js
CHANGED
|
@@ -3,6 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.cleanResult = exports.cleanResultInner = exports.resultOf = exports.resultsOf = void 0;
|
|
4
4
|
const utils_1 = require("./utils");
|
|
5
5
|
const data_source_1 = require("./data_source");
|
|
6
|
+
const prop_function_1 = require("./prop_function");
|
|
7
|
+
const replaceTemplatePlaceholders = (input, templateMatch, nodes, propFunctions, isSelfNode) => {
|
|
8
|
+
// GOD format ${:node.prop1.prop2}
|
|
9
|
+
const godResults = resultsOfInner(templateMatch.filter((text) => text.startsWith(":")), nodes, propFunctions, isSelfNode);
|
|
10
|
+
// utilsFunctions ${@now}
|
|
11
|
+
const utilsFuncResult = templateMatch
|
|
12
|
+
.filter((text) => text.startsWith("@"))
|
|
13
|
+
.reduce((tmp, key) => {
|
|
14
|
+
tmp[key] = (0, prop_function_1.utilsFunctions)(key);
|
|
15
|
+
return tmp;
|
|
16
|
+
}, {});
|
|
17
|
+
return Array.from(templateMatch.keys()).reduce((tmp, key) => {
|
|
18
|
+
if (templateMatch[key].startsWith(":")) {
|
|
19
|
+
return tmp.replaceAll("${" + templateMatch[key] + "}", godResults[key]);
|
|
20
|
+
}
|
|
21
|
+
return tmp.replaceAll("${" + templateMatch[key] + "}", utilsFuncResult[templateMatch[key]]);
|
|
22
|
+
}, input);
|
|
23
|
+
};
|
|
6
24
|
const resultsOfInner = (input, nodes, propFunctions, isSelfNode = false) => {
|
|
7
25
|
if (Array.isArray(input)) {
|
|
8
26
|
return input.map((inp) => resultsOfInner(inp, nodes, propFunctions, isSelfNode));
|
|
@@ -11,12 +29,9 @@ const resultsOfInner = (input, nodes, propFunctions, isSelfNode = false) => {
|
|
|
11
29
|
return (0, exports.resultsOf)(input, nodes, propFunctions, isSelfNode);
|
|
12
30
|
}
|
|
13
31
|
if (typeof input === "string") {
|
|
14
|
-
const templateMatch = [...input.matchAll(/\${(
|
|
32
|
+
const templateMatch = [...input.matchAll(/\${([:@][^}]+)}/g)].map((m) => m[1]);
|
|
15
33
|
if (templateMatch.length > 0) {
|
|
16
|
-
|
|
17
|
-
return Array.from(templateMatch.keys()).reduce((tmp, key) => {
|
|
18
|
-
return tmp.replaceAll("${" + templateMatch[key] + "}", results[key]);
|
|
19
|
-
}, input);
|
|
34
|
+
return replaceTemplatePlaceholders(input, templateMatch, nodes, propFunctions, isSelfNode);
|
|
20
35
|
}
|
|
21
36
|
}
|
|
22
37
|
return (0, exports.resultOf)((0, utils_1.parseNodeName)(input, isSelfNode), nodes, propFunctions);
|