awing-library 2.1.2-stable.3 → 2.1.2-stable.4
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.
|
@@ -15,12 +15,12 @@ var fillConfigs = function (input) {
|
|
|
15
15
|
};
|
|
16
16
|
exports.fillConfigs = fillConfigs;
|
|
17
17
|
var isJSON = function (value) {
|
|
18
|
-
if (typeof value !==
|
|
18
|
+
if (typeof value !== 'string')
|
|
19
19
|
return false;
|
|
20
20
|
try {
|
|
21
21
|
var result = JSON.parse(value);
|
|
22
22
|
var type = Object.prototype.toString.call(result);
|
|
23
|
-
return type ===
|
|
23
|
+
return type === '[object Object]' || type === '[object Array]';
|
|
24
24
|
}
|
|
25
25
|
catch (err) {
|
|
26
26
|
return false;
|
|
@@ -28,15 +28,30 @@ var isJSON = function (value) {
|
|
|
28
28
|
};
|
|
29
29
|
exports.isJSON = isJSON;
|
|
30
30
|
var getValueByPath = function (object, path) {
|
|
31
|
-
var keys = path.split(
|
|
31
|
+
var keys = path.split('.');
|
|
32
32
|
var result = object;
|
|
33
33
|
for (var i = 0; i < keys.length; i++) {
|
|
34
|
-
result = (result === null || result === void 0 ? void 0 : result[keys[i]]) ||
|
|
34
|
+
result = (result === null || result === void 0 ? void 0 : result[keys[i]]) || '';
|
|
35
35
|
}
|
|
36
36
|
return result;
|
|
37
37
|
};
|
|
38
38
|
exports.getValueByPath = getValueByPath;
|
|
39
39
|
var runScript = function (params, script) {
|
|
40
|
+
var sandboxUrl = window.REACT_APP_API_ENDPOINT + '/api/Sandbox';
|
|
41
|
+
fetch(sandboxUrl, {
|
|
42
|
+
method: 'POST',
|
|
43
|
+
headers: {
|
|
44
|
+
"Content-Type": "application/json-patch+json",
|
|
45
|
+
"Accept": "text/plain"
|
|
46
|
+
},
|
|
47
|
+
body: JSON.stringify({
|
|
48
|
+
jsCode: "\n const fn = (function func() {\n ".concat(script, "\n })();\n return fn(").concat(Array.from(params).map(function (i) { return JSON.stringify(i); }), ");\n ").trim(),
|
|
49
|
+
sandboxType: 0,
|
|
50
|
+
}).trim(),
|
|
51
|
+
credentials: 'include',
|
|
52
|
+
})
|
|
53
|
+
.then(function (r) { return r.json(); })
|
|
54
|
+
.then(console.log);
|
|
40
55
|
return new Promise(function (resolve, reject) {
|
|
41
56
|
try {
|
|
42
57
|
// eslint-disable-next-line
|
|
@@ -52,6 +67,7 @@ var runScript = function (params, script) {
|
|
|
52
67
|
};
|
|
53
68
|
}
|
|
54
69
|
scriptFunction.apply(void 0, params).then(function (result) {
|
|
70
|
+
console.log('Script result:', result);
|
|
55
71
|
resolve(result);
|
|
56
72
|
});
|
|
57
73
|
});
|
|
@@ -60,9 +76,11 @@ exports.runScript = runScript;
|
|
|
60
76
|
var convertRelativeLink = function (link, pagePath, templateId, configs) {
|
|
61
77
|
var isTemplatePath = link === null || link === void 0 ? void 0 : link.includes(constant_1.ACM_TEMPLATE_PATH);
|
|
62
78
|
if (isTemplatePath) {
|
|
63
|
-
return "".concat(configs.TEMPLATE_FILE_PATH, "/").concat(templateId, "/").concat(link.split(
|
|
79
|
+
return "".concat(configs.TEMPLATE_FILE_PATH, "/").concat(templateId, "/").concat(link.split('/')[link.split('/').length - 1]);
|
|
64
80
|
}
|
|
65
|
-
return (link === null || link === void 0 ? void 0 : link.includes(constant_1.ACM_PAGE_PATH))
|
|
81
|
+
return (link === null || link === void 0 ? void 0 : link.includes(constant_1.ACM_PAGE_PATH))
|
|
82
|
+
? "".concat(pagePath, "/").concat(link.split('/')[link.split('/').length - 1]) || ''
|
|
83
|
+
: link;
|
|
66
84
|
};
|
|
67
85
|
exports.convertRelativeLink = convertRelativeLink;
|
|
68
86
|
var generateRandomInteger = function (max) {
|