@xuda.io/runtime-bundle 1.0.323 → 1.0.325
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/js/modules/xuda-event-javascript-module.min.mjs +2 -2
- package/js/modules/xuda-event-javascript-module.mjs +40 -101
- package/js/xuda-runtime-bundle.js +144 -306
- package/js/xuda-runtime-bundle.min.js +3 -3
- package/js/xuda-runtime-slim.js +144 -306
- package/js/xuda-runtime-slim.min.es.js +144 -306
- package/js/xuda-runtime-slim.min.js +3 -3
- package/js/xuda-server-bundle.min.mjs +2 -2
- package/js/xuda-server-bundle.mjs +140 -302
- package/js/xuda-worker-bundle.js +140 -302
- package/js/xuda-worker-bundle.min.js +2 -2
- package/package.json +1 -1
|
@@ -7171,6 +7171,10 @@ func.events.execute = async function (
|
|
|
7171
7171
|
`(async function(el,evt) {
|
|
7172
7172
|
${refIdP.value}
|
|
7173
7173
|
})(document.querySelector(\`[xu-ui-id=${elementP}]\`),evt)`,
|
|
7174
|
+
null,
|
|
7175
|
+
null,
|
|
7176
|
+
null,
|
|
7177
|
+
evt,
|
|
7174
7178
|
);
|
|
7175
7179
|
await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
|
|
7176
7180
|
|
|
@@ -7187,6 +7191,9 @@ func.events.execute = async function (
|
|
|
7187
7191
|
${refIdP.value}
|
|
7188
7192
|
})(document.querySelector(\`[xu-ui-id=${elementP}]\`),evt)`,
|
|
7189
7193
|
true,
|
|
7194
|
+
null,
|
|
7195
|
+
null,
|
|
7196
|
+
evt,
|
|
7190
7197
|
);
|
|
7191
7198
|
await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
|
|
7192
7199
|
|
|
@@ -7727,22 +7734,7 @@ func.events.invoke = async function (event_id) {
|
|
|
7727
7734
|
};
|
|
7728
7735
|
func.expression = {};
|
|
7729
7736
|
|
|
7730
|
-
func.expression.get = async function (
|
|
7731
|
-
SESSION_ID,
|
|
7732
|
-
valP,
|
|
7733
|
-
dsSessionP,
|
|
7734
|
-
sourceP,
|
|
7735
|
-
rowIdP,
|
|
7736
|
-
sourceActionP,
|
|
7737
|
-
secondPassP,
|
|
7738
|
-
calling_fieldIdP,
|
|
7739
|
-
fieldsP,
|
|
7740
|
-
debug_infoP,
|
|
7741
|
-
iterate_info,
|
|
7742
|
-
js_script_callback,
|
|
7743
|
-
jobNo,
|
|
7744
|
-
api_output_type
|
|
7745
|
-
) {
|
|
7737
|
+
func.expression.get = async function (SESSION_ID, valP, dsSessionP, sourceP, rowIdP, sourceActionP, secondPassP, calling_fieldIdP, fieldsP, debug_infoP, iterate_info, js_script_callback, jobNo, api_output_type) {
|
|
7746
7738
|
class xu_class {
|
|
7747
7739
|
async get() {
|
|
7748
7740
|
var ret;
|
|
@@ -7751,23 +7743,23 @@ func.expression.get = async function (
|
|
|
7751
7743
|
var warning;
|
|
7752
7744
|
|
|
7753
7745
|
function evalJson(text) {
|
|
7754
|
-
return eval(
|
|
7746
|
+
return eval('(' + text + ')');
|
|
7755
7747
|
}
|
|
7756
7748
|
|
|
7757
7749
|
if (valP === null) {
|
|
7758
|
-
ret =
|
|
7750
|
+
ret = '';
|
|
7759
7751
|
} else {
|
|
7760
7752
|
switch (typeof valP) {
|
|
7761
|
-
case
|
|
7753
|
+
case 'string':
|
|
7762
7754
|
ret = valP;
|
|
7763
7755
|
break;
|
|
7764
7756
|
|
|
7765
|
-
case
|
|
7766
|
-
ret =
|
|
7757
|
+
case 'undefined':
|
|
7758
|
+
ret = '';
|
|
7767
7759
|
break;
|
|
7768
7760
|
|
|
7769
|
-
case
|
|
7770
|
-
ret = valP ?
|
|
7761
|
+
case 'boolean':
|
|
7762
|
+
ret = valP ? 'Y' : 'N';
|
|
7771
7763
|
break;
|
|
7772
7764
|
|
|
7773
7765
|
default:
|
|
@@ -7776,40 +7768,35 @@ func.expression.get = async function (
|
|
|
7776
7768
|
}
|
|
7777
7769
|
}
|
|
7778
7770
|
|
|
7779
|
-
ret = ret.replace(/\&/g,
|
|
7771
|
+
ret = ret.replace(/\&/g, '&');
|
|
7780
7772
|
ret = func.utils.replace_studio_drive_url(SESSION_ID, ret);
|
|
7781
7773
|
|
|
7782
7774
|
const end_results = function () {
|
|
7783
7775
|
const replace_quotes = function (ret) {
|
|
7784
7776
|
for (const [key, val] of Object.entries(fields)) {
|
|
7785
|
-
if (typeof val ===
|
|
7786
|
-
ret = ret.replace('"' + val + '"', val.replace(/"/gi, ""));
|
|
7777
|
+
if (typeof val === 'string') ret = ret.replace('"' + val + '"', val.replace(/"/gi, ''));
|
|
7787
7778
|
}
|
|
7788
7779
|
return ret;
|
|
7789
7780
|
};
|
|
7790
|
-
if ([
|
|
7791
|
-
if (typeof ret ===
|
|
7781
|
+
if (['update', 'javascript'].includes(sourceP)) {
|
|
7782
|
+
if (typeof ret === 'string') ret = replace_quotes(ret);
|
|
7792
7783
|
}
|
|
7793
7784
|
const log_error = function () {
|
|
7794
7785
|
if (SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP]) {
|
|
7795
|
-
func.utils.debug.log(
|
|
7796
|
-
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
|
|
7809
|
-
prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
7810
|
-
debug_info: debug_infoP,
|
|
7811
|
-
}
|
|
7812
|
-
);
|
|
7786
|
+
func.utils.debug.log(SESSION_ID, SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].nodeId, {
|
|
7787
|
+
module: 'expression',
|
|
7788
|
+
action: sourceP,
|
|
7789
|
+
source: calling_fieldIdP,
|
|
7790
|
+
prop: ret,
|
|
7791
|
+
details: ret,
|
|
7792
|
+
result: ret,
|
|
7793
|
+
error: error,
|
|
7794
|
+
warning: warning,
|
|
7795
|
+
fields: null,
|
|
7796
|
+
type: 'exp',
|
|
7797
|
+
prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
7798
|
+
debug_info: debug_infoP,
|
|
7799
|
+
});
|
|
7813
7800
|
}
|
|
7814
7801
|
};
|
|
7815
7802
|
if (error) log_error();
|
|
@@ -7827,32 +7814,22 @@ func.expression.get = async function (
|
|
|
7827
7814
|
};
|
|
7828
7815
|
const variable_not_exist = async function () {
|
|
7829
7816
|
try {
|
|
7830
|
-
if (sourceP !==
|
|
7831
|
-
if (ret && ret.substr(0, 6) ===
|
|
7817
|
+
if (sourceP !== 'arguments') {
|
|
7818
|
+
if (ret && ret.substr(0, 6) === '_DATE_') {
|
|
7832
7819
|
ret = ret.substr(6);
|
|
7833
7820
|
} else if (
|
|
7834
|
-
(ret &&
|
|
7835
|
-
|
|
7836
|
-
ret.substr(4, 1) === "-" &&
|
|
7837
|
-
ret.substr(7, 1) === "-") ||
|
|
7838
|
-
ret === "self" // bypass eval for date 2017-03-22
|
|
7821
|
+
(ret && ret.length === 10 && ret.substr(4, 1) === '-' && ret.substr(7, 1) === '-') ||
|
|
7822
|
+
ret === 'self' // bypass eval for date 2017-03-22
|
|
7839
7823
|
) {
|
|
7840
7824
|
ret = ret;
|
|
7841
7825
|
} else {
|
|
7842
|
-
ret = await func.expression.secure_eval(
|
|
7843
|
-
SESSION_ID,
|
|
7844
|
-
sourceP,
|
|
7845
|
-
ret,
|
|
7846
|
-
jobNo,
|
|
7847
|
-
dsSessionP,
|
|
7848
|
-
js_script_callback
|
|
7849
|
-
);
|
|
7826
|
+
ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
7850
7827
|
}
|
|
7851
7828
|
// console.log("AFTER OK", ret)
|
|
7852
7829
|
return end_results();
|
|
7853
7830
|
} else {
|
|
7854
7831
|
// do eval for arithmetic vals
|
|
7855
|
-
ret = ret.replace(/_NULL/gi,
|
|
7832
|
+
ret = ret.replace(/_NULL/gi, '');
|
|
7856
7833
|
return end_results();
|
|
7857
7834
|
}
|
|
7858
7835
|
} catch (err) {
|
|
@@ -7865,14 +7842,7 @@ func.expression.get = async function (
|
|
|
7865
7842
|
}
|
|
7866
7843
|
|
|
7867
7844
|
const validate_email = async function () {
|
|
7868
|
-
const ret = await func.expression.secure_eval(
|
|
7869
|
-
SESSION_ID,
|
|
7870
|
-
sourceP,
|
|
7871
|
-
valP,
|
|
7872
|
-
jobNo,
|
|
7873
|
-
dsSessionP,
|
|
7874
|
-
js_script_callback
|
|
7875
|
-
);
|
|
7845
|
+
const ret = await func.expression.secure_eval(SESSION_ID, sourceP, valP, jobNo, dsSessionP, js_script_callback);
|
|
7876
7846
|
|
|
7877
7847
|
return glb.emailRegex.test(ret);
|
|
7878
7848
|
};
|
|
@@ -7891,10 +7861,7 @@ func.expression.get = async function (
|
|
|
7891
7861
|
var_Arr[key].value = val.value;
|
|
7892
7862
|
//--------------
|
|
7893
7863
|
const replace_value_in_string = async function (retP, fieldIdP) {
|
|
7894
|
-
if (
|
|
7895
|
-
iterate_info?.iterator_key === fieldIdP ||
|
|
7896
|
-
iterate_info?.iterator_val === fieldIdP
|
|
7897
|
-
) {
|
|
7864
|
+
if (iterate_info?.iterator_key === fieldIdP || iterate_info?.iterator_val === fieldIdP) {
|
|
7898
7865
|
if (iterate_info.iterator_key === fieldIdP) {
|
|
7899
7866
|
retP.value = iterate_info._key;
|
|
7900
7867
|
}
|
|
@@ -7904,50 +7871,43 @@ func.expression.get = async function (
|
|
|
7904
7871
|
}
|
|
7905
7872
|
|
|
7906
7873
|
const set_value = function (valP) {
|
|
7907
|
-
if (typeof valP !==
|
|
7874
|
+
if (typeof valP !== 'undefined') {
|
|
7908
7875
|
var_Arr[key].value = valP;
|
|
7909
|
-
if (typeof valP ===
|
|
7876
|
+
if (typeof valP === 'string') var_Arr[key].type = 'string';
|
|
7910
7877
|
} else {
|
|
7911
|
-
if (retP.type ===
|
|
7912
|
-
var_Arr[key].value =
|
|
7913
|
-
var_Arr[key].type =
|
|
7878
|
+
if (retP.type === 'object') {
|
|
7879
|
+
var_Arr[key].value = '';
|
|
7880
|
+
var_Arr[key].type = 'string';
|
|
7914
7881
|
}
|
|
7915
7882
|
}
|
|
7916
7883
|
};
|
|
7917
7884
|
|
|
7918
|
-
if (sourceP ===
|
|
7885
|
+
if (sourceP === 'exp' && retP.type !== 'exp') {
|
|
7919
7886
|
var_Arr[key].type = retP.type;
|
|
7920
7887
|
return;
|
|
7921
7888
|
}
|
|
7922
|
-
if (typeof retP.value !==
|
|
7889
|
+
if (typeof retP.value !== 'undefined') {
|
|
7923
7890
|
var_Arr[key].type = retP.type;
|
|
7924
7891
|
var_Arr[key].value = retP.value;
|
|
7925
|
-
if ((val.value.indexOf(
|
|
7892
|
+
if ((val.value.indexOf('[') > -1) | (val.value.indexOf('.') > -1)) {
|
|
7926
7893
|
//get values from array '@var==="sss" && @var_B==="sss" && @obj.property===5 && @objA["value"]===123 | @objB["value"].property===1234'
|
|
7927
7894
|
var data = retP.prop;
|
|
7928
|
-
if (retP.type ===
|
|
7895
|
+
if (retP.type === 'object') data = retP.value;
|
|
7929
7896
|
var property1, property2;
|
|
7930
7897
|
//check for split situation: @objB[@var].property 1: @objB[ 2:@var].property
|
|
7931
|
-
if (
|
|
7932
|
-
val.value.indexOf("[") === -1 &&
|
|
7933
|
-
val.value.indexOf("]") > -1 &&
|
|
7934
|
-
val.value.substr(0, 1) === "@"
|
|
7935
|
-
) {
|
|
7898
|
+
if (val.value.indexOf('[') === -1 && val.value.indexOf(']') > -1 && val.value.substr(0, 1) === '@') {
|
|
7936
7899
|
//check situation 2
|
|
7937
7900
|
var prevData = var_Arr[key - 1].value;
|
|
7938
7901
|
var_Arr[key].value = prevData[data]; // @objB[@var]
|
|
7939
|
-
if (val.value.indexOf(
|
|
7940
|
-
property2 = await func.expression.get_property(val.value)
|
|
7941
|
-
.property2; //val.value.substr(val.value.indexOf(".") + 1, val.value.length); // get .
|
|
7902
|
+
if (val.value.indexOf('.') > -1) {
|
|
7903
|
+
property2 = await func.expression.get_property(val.value).property2; //val.value.substr(val.value.indexOf(".") + 1, val.value.length); // get .
|
|
7942
7904
|
if (prevData[data]) set_value(prevData[data][property2]);
|
|
7943
7905
|
// var_Arr[key].value = prevData[data][property2]; //@objB[@var].property
|
|
7944
7906
|
}
|
|
7945
7907
|
delete var_Arr[key - 1];
|
|
7946
7908
|
} else {
|
|
7947
|
-
property1 = await func.expression.get_property(val.value)
|
|
7948
|
-
|
|
7949
|
-
property2 = await func.expression.get_property(val.value)
|
|
7950
|
-
.property2;
|
|
7909
|
+
property1 = await func.expression.get_property(val.value).property1;
|
|
7910
|
+
property2 = await func.expression.get_property(val.value).property2;
|
|
7951
7911
|
if (property1) {
|
|
7952
7912
|
var_Arr[key].value = data[property1]; // @var["value"] or @var.property
|
|
7953
7913
|
if (property2) {
|
|
@@ -7975,19 +7935,11 @@ func.expression.get = async function (
|
|
|
7975
7935
|
//>>>>>>>>>>>>>>>>>>
|
|
7976
7936
|
if (val.fieldId) {
|
|
7977
7937
|
// @_THIS
|
|
7978
|
-
if (
|
|
7979
|
-
val.fieldId &&
|
|
7980
|
-
val.fieldId.substr(0, 5) === "_THIS" &&
|
|
7981
|
-
calling_fieldIdP &&
|
|
7982
|
-
(val.fieldId.length === 5 ||
|
|
7983
|
-
(val.fieldId.length > 5 && val.fieldId.substr(5, 1) === "."))
|
|
7984
|
-
) {
|
|
7938
|
+
if (val.fieldId && val.fieldId.substr(0, 5) === '_THIS' && calling_fieldIdP && (val.fieldId.length === 5 || (val.fieldId.length > 5 && val.fieldId.substr(5, 1) === '.'))) {
|
|
7985
7939
|
if (val.fieldId.length === 5) val.fieldId = calling_fieldIdP;
|
|
7986
|
-
else
|
|
7987
|
-
val.fieldId =
|
|
7988
|
-
calling_fieldIdP + val.fieldId(5, val.fieldId.length - 1);
|
|
7940
|
+
else val.fieldId = calling_fieldIdP + val.fieldId(5, val.fieldId.length - 1);
|
|
7989
7941
|
}
|
|
7990
|
-
if (!sourceP ===
|
|
7942
|
+
if (!sourceP === 'exp') {
|
|
7991
7943
|
var_Arr[key].value = '""';
|
|
7992
7944
|
} // put default
|
|
7993
7945
|
fields[val.fieldId] = var_Arr[key].value;
|
|
@@ -7997,7 +7949,7 @@ func.expression.get = async function (
|
|
|
7997
7949
|
val.fieldId,
|
|
7998
7950
|
dsSessionP,
|
|
7999
7951
|
|
|
8000
|
-
rowIdP
|
|
7952
|
+
rowIdP,
|
|
8001
7953
|
); // find field in dataSources
|
|
8002
7954
|
|
|
8003
7955
|
await replace_value_in_string(ret.ret, ret.fieldIdP);
|
|
@@ -8010,7 +7962,7 @@ func.expression.get = async function (
|
|
|
8010
7962
|
var var_error_found;
|
|
8011
7963
|
// merge arr values
|
|
8012
7964
|
_.forEach(var_Arr, function (val, key) {
|
|
8013
|
-
if (sourceP ===
|
|
7965
|
+
if (sourceP === 'UI Property EXP') {
|
|
8014
7966
|
let ret = func.utils.get_drive_url(SESSION_ID, val.value, true);
|
|
8015
7967
|
if (ret.changed) {
|
|
8016
7968
|
res[key] = ret.value;
|
|
@@ -8018,108 +7970,72 @@ func.expression.get = async function (
|
|
|
8018
7970
|
}
|
|
8019
7971
|
}
|
|
8020
7972
|
|
|
8021
|
-
if (sourceP ===
|
|
8022
|
-
let ret = func.utils.get_drive_url(
|
|
8023
|
-
SESSION_ID,
|
|
8024
|
-
val.value,
|
|
8025
|
-
var_Arr.length == 1 ? false : true
|
|
8026
|
-
);
|
|
7973
|
+
if (sourceP === 'UI Attr EXP') {
|
|
7974
|
+
let ret = func.utils.get_drive_url(SESSION_ID, val.value, var_Arr.length == 1 ? false : true);
|
|
8027
7975
|
if (ret.changed) {
|
|
8028
7976
|
res[key] = ret.value;
|
|
8029
7977
|
return true;
|
|
8030
7978
|
}
|
|
8031
7979
|
}
|
|
8032
7980
|
|
|
8033
|
-
if (val.type ===
|
|
7981
|
+
if (val.type === 'exp') {
|
|
8034
7982
|
exp_exist = true;
|
|
8035
7983
|
}
|
|
8036
7984
|
res[key] = val.value;
|
|
8037
7985
|
|
|
8038
|
-
if (var_Arr.length > 1) {
|
|
8039
|
-
|
|
8040
|
-
|
|
8041
|
-
|
|
8042
|
-
) &&
|
|
8043
|
-
["string", "date"].includes(val.type)
|
|
8044
|
-
) {
|
|
8045
|
-
res[key] = "`" + val.value + "`";
|
|
7986
|
+
if (var_Arr.length > 1) {
|
|
7987
|
+
// complex input
|
|
7988
|
+
if (!['DbQuery', 'alert', 'exp', 'api_rendered_output'].includes(sourceP) && ['string', 'date'].includes(val.type)) {
|
|
7989
|
+
res[key] = '`' + val.value + '`';
|
|
8046
7990
|
}
|
|
8047
7991
|
// new Dec 18 2024 for Ishai // json,html,xml,text,css
|
|
8048
|
-
if (
|
|
8049
|
-
["api_rendered_output"].includes(sourceP) && ["json"].includes(api_output_type) &&
|
|
8050
|
-
["string", "date"].includes(val.type)
|
|
8051
|
-
) {
|
|
7992
|
+
if (['api_rendered_output'].includes(sourceP) && ['json'].includes(api_output_type) && ['string', 'date'].includes(val.type)) {
|
|
8052
7993
|
res[key] = `"` + val.value + `"`;
|
|
8053
7994
|
}
|
|
8054
7995
|
}
|
|
8055
|
-
if (val.fieldId && val.value && typeof val.value ===
|
|
8056
|
-
if (
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
)
|
|
8060
|
-
) {
|
|
8061
|
-
if (val.value.indexOf("↵") > -1) {
|
|
8062
|
-
res[key] = val.value.split("↵").join("");
|
|
7996
|
+
if (val.fieldId && val.value && typeof val.value === 'string') {
|
|
7997
|
+
if (['query', 'condition', 'range', 'sort', 'locate'].includes(sourceP)) {
|
|
7998
|
+
if (val.value.indexOf('↵') > -1) {
|
|
7999
|
+
res[key] = val.value.split('↵').join('');
|
|
8063
8000
|
}
|
|
8064
|
-
res[key] = res[key].replace(/(\r\n|\n|\r)/gm,
|
|
8001
|
+
res[key] = res[key].replace(/(\r\n|\n|\r)/gm, ''); //.replace(/"/g,'\"');//.replace(/'/g,"");
|
|
8065
8002
|
}
|
|
8066
8003
|
|
|
8067
|
-
if ([
|
|
8068
|
-
if (val.value.indexOf(
|
|
8069
|
-
|
|
8070
|
-
res[key] = res[key].replace(/(\r\n|\n|\r)/gm, "\\n");
|
|
8004
|
+
if (['init', 'update', 'virtual'].includes(sourceP)) {
|
|
8005
|
+
if (val.value.indexOf('↵') > -1) res[key] = val.value.split('↵').join('\n');
|
|
8006
|
+
res[key] = res[key].replace(/(\r\n|\n|\r)/gm, '\\n');
|
|
8071
8007
|
}
|
|
8072
8008
|
|
|
8073
|
-
if (typeof IS_PROCESS_SERVER !==
|
|
8074
|
-
res[key] = res[key].replace(/(\r\n|\n|\r)/gm,
|
|
8009
|
+
if (typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
8010
|
+
res[key] = res[key].replace(/(\r\n|\n|\r)/gm, '<br>');
|
|
8075
8011
|
}
|
|
8076
8012
|
|
|
8077
8013
|
fields[val.fieldId] = res[key];
|
|
8078
8014
|
}
|
|
8079
8015
|
// extract object
|
|
8080
|
-
if (typeof val.value ===
|
|
8081
|
-
if (
|
|
8082
|
-
!Array.isArray(val.value) &&
|
|
8083
|
-
!var_Arr[key + 1].value?.includes(".")
|
|
8084
|
-
) {
|
|
8016
|
+
if (typeof val.value === 'object' && var_Arr.length > 1) {
|
|
8017
|
+
if (!Array.isArray(val.value) && !var_Arr[key + 1].value?.includes('.')) {
|
|
8085
8018
|
// && !["api_rendered_output"].includes(sourceP)
|
|
8086
8019
|
|
|
8087
8020
|
// prevent cast on single value expression
|
|
8088
|
-
res[key] =
|
|
8021
|
+
res[key] = '(' + JSON.stringify(val.value) + ')';
|
|
8089
8022
|
} else {
|
|
8090
8023
|
res[key] = JSON.stringify(val.value);
|
|
8091
8024
|
}
|
|
8092
8025
|
}
|
|
8093
8026
|
|
|
8094
|
-
if (
|
|
8095
|
-
|
|
8096
|
-
sourceP !== "exp" &&
|
|
8097
|
-
val.value &&
|
|
8098
|
-
typeof val.value === "string" &&
|
|
8099
|
-
val.value.substr(0, 1) === "@"
|
|
8100
|
-
) {
|
|
8101
|
-
warning = "Error encoding " + val.value;
|
|
8027
|
+
if (!exp_exist && sourceP !== 'exp' && val.value && typeof val.value === 'string' && val.value.substr(0, 1) === '@') {
|
|
8028
|
+
warning = 'Error encoding ' + val.value;
|
|
8102
8029
|
var_error_found = true;
|
|
8103
8030
|
res[key] = 0;
|
|
8104
8031
|
}
|
|
8105
8032
|
});
|
|
8106
8033
|
var join = function (arrP) {
|
|
8107
|
-
return arrP.join(
|
|
8034
|
+
return arrP.join('');
|
|
8108
8035
|
};
|
|
8109
8036
|
var exp = undefined;
|
|
8110
|
-
if (exp_exist && sourceP !==
|
|
8111
|
-
exp = await func.expression.get(
|
|
8112
|
-
SESSION_ID,
|
|
8113
|
-
join(res),
|
|
8114
|
-
dsSessionP,
|
|
8115
|
-
sourceP,
|
|
8116
|
-
rowIdP,
|
|
8117
|
-
sourceActionP,
|
|
8118
|
-
true,
|
|
8119
|
-
calling_fieldIdP,
|
|
8120
|
-
fields,
|
|
8121
|
-
debug_infoP
|
|
8122
|
-
);
|
|
8037
|
+
if (exp_exist && sourceP !== 'exp') {
|
|
8038
|
+
exp = await func.expression.get(SESSION_ID, join(res), dsSessionP, sourceP, rowIdP, sourceActionP, true, calling_fieldIdP, fields, debug_infoP);
|
|
8123
8039
|
if (exp.res) res = exp.res;
|
|
8124
8040
|
// do second pass when exp exist
|
|
8125
8041
|
else res = [exp.result];
|
|
@@ -8134,39 +8050,28 @@ func.expression.get = async function (
|
|
|
8134
8050
|
|
|
8135
8051
|
if (secondPassP) {
|
|
8136
8052
|
ret = result;
|
|
8137
|
-
} else if (sourceP !==
|
|
8053
|
+
} else if (sourceP !== 'exp') {
|
|
8138
8054
|
// no eval for second pass
|
|
8139
8055
|
// return single value
|
|
8140
|
-
if (
|
|
8141
|
-
res.length === 1 &&
|
|
8142
|
-
typeof res[0] === "string" &&
|
|
8143
|
-
typeof res[0] !== "object"
|
|
8144
|
-
) {
|
|
8056
|
+
if (res.length === 1 && typeof res[0] === 'string' && typeof res[0] !== 'object') {
|
|
8145
8057
|
// avoid eval when query leading zeros problem
|
|
8146
8058
|
ret = join(res);
|
|
8147
|
-
if (ret && ret.substr(0, 1) ===
|
|
8148
|
-
error =
|
|
8059
|
+
if (ret && ret.substr(0, 1) === '@') {
|
|
8060
|
+
error = 'Error encoding @ var';
|
|
8149
8061
|
var_error_found = true;
|
|
8150
8062
|
}
|
|
8151
8063
|
} else {
|
|
8152
8064
|
if (
|
|
8153
8065
|
![
|
|
8154
|
-
|
|
8066
|
+
'arguments',
|
|
8155
8067
|
// "alert",
|
|
8156
|
-
|
|
8157
|
-
|
|
8068
|
+
'api_rendered_output',
|
|
8069
|
+
'DbQuery',
|
|
8158
8070
|
].includes(sourceP)
|
|
8159
8071
|
) {
|
|
8160
|
-
ret = await func.expression.secure_eval(
|
|
8161
|
-
SESSION_ID,
|
|
8162
|
-
sourceP,
|
|
8163
|
-
result,
|
|
8164
|
-
jobNo,
|
|
8165
|
-
dsSessionP,
|
|
8166
|
-
js_script_callback
|
|
8167
|
-
);
|
|
8072
|
+
ret = await func.expression.secure_eval(SESSION_ID, sourceP, result, jobNo, dsSessionP, js_script_callback);
|
|
8168
8073
|
} else {
|
|
8169
|
-
if (sourceP ===
|
|
8074
|
+
if (sourceP === 'DbQuery') {
|
|
8170
8075
|
ret = JSON.stringify(evalJson(result));
|
|
8171
8076
|
} else {
|
|
8172
8077
|
// try eval
|
|
@@ -8195,12 +8100,7 @@ func.expression.parse = function (strP) {
|
|
|
8195
8100
|
if (!posP) posP = 0;
|
|
8196
8101
|
var clean_split_str = function (arrP) {
|
|
8197
8102
|
var arr = [];
|
|
8198
|
-
if (
|
|
8199
|
-
arrP &&
|
|
8200
|
-
arrP.length > 1 &&
|
|
8201
|
-
arrP[0] === "" &&
|
|
8202
|
-
arrP[1].indexOf("@") > -1
|
|
8203
|
-
) {
|
|
8103
|
+
if (arrP && arrP.length > 1 && arrP[0] === '' && arrP[1].indexOf('@') > -1) {
|
|
8204
8104
|
for (var i = 1; i <= arrP.length; i++) {
|
|
8205
8105
|
arr.push(arrP[i]);
|
|
8206
8106
|
}
|
|
@@ -8211,7 +8111,7 @@ func.expression.parse = function (strP) {
|
|
|
8211
8111
|
var validSymbolsNoArray = /[^.@\[]/; //valid symbols no array /[^.@\[\]\]]/
|
|
8212
8112
|
var validSymbolsWithArray = /[^.@"'\[\]]/; //valid symbols with array
|
|
8213
8113
|
var validSymbols = validSymbolsNoArray;
|
|
8214
|
-
var splitTmp = strP.replace(/@/g,
|
|
8114
|
+
var splitTmp = strP.replace(/@/g, '^^@').split('^^');
|
|
8215
8115
|
var split = clean_split_str(splitTmp);
|
|
8216
8116
|
var obj = [];
|
|
8217
8117
|
if (split) {
|
|
@@ -8219,8 +8119,8 @@ func.expression.parse = function (strP) {
|
|
|
8219
8119
|
// run on @ segments
|
|
8220
8120
|
if (val) {
|
|
8221
8121
|
var pos = strP.indexOf(val);
|
|
8222
|
-
if (val && val.substr(0, 1) ===
|
|
8223
|
-
var tmpStr =
|
|
8122
|
+
if (val && val.substr(0, 1) === '@') {
|
|
8123
|
+
var tmpStr = '';
|
|
8224
8124
|
var word_start_pos = undefined;
|
|
8225
8125
|
var word_end_pos = undefined;
|
|
8226
8126
|
// run on @ segment string
|
|
@@ -8228,7 +8128,7 @@ func.expression.parse = function (strP) {
|
|
|
8228
8128
|
var key1 = i;
|
|
8229
8129
|
var val1 = val.substr(i, 1);
|
|
8230
8130
|
if (
|
|
8231
|
-
val1 ===
|
|
8131
|
+
val1 === '.' &&
|
|
8232
8132
|
!word_start_pos // find first dot
|
|
8233
8133
|
)
|
|
8234
8134
|
word_start_pos = key1;
|
|
@@ -8238,40 +8138,24 @@ func.expression.parse = function (strP) {
|
|
|
8238
8138
|
nonLettersPatt.test(val1) // find any sign character to mark the end of word
|
|
8239
8139
|
)
|
|
8240
8140
|
word_end_pos = key1;
|
|
8241
|
-
if (
|
|
8242
|
-
word_start_pos &&
|
|
8243
|
-
word_start_pos >= 0 &&
|
|
8244
|
-
word_end_pos &&
|
|
8245
|
-
word_end_pos >= 0
|
|
8246
|
-
) {
|
|
8141
|
+
if (word_start_pos && word_start_pos >= 0 && word_end_pos && word_end_pos >= 0) {
|
|
8247
8142
|
// find the word
|
|
8248
|
-
var word = val.substr(
|
|
8249
|
-
word_start_pos + 1,
|
|
8250
|
-
word_end_pos - word_start_pos - 1
|
|
8251
|
-
); // get the word
|
|
8143
|
+
var word = val.substr(word_start_pos + 1, word_end_pos - word_start_pos - 1); // get the word
|
|
8252
8144
|
// if (glb.ALL_PROPERTIES_ARR.indexOf(word) === -1) {
|
|
8253
8145
|
// compare with internal properties
|
|
8254
|
-
tmpStr =
|
|
8255
|
-
tmpStr.substr(0, word_start_pos) +
|
|
8256
|
-
"^^" +
|
|
8257
|
-
tmpStr.substr(word_start_pos, word_end_pos);
|
|
8146
|
+
tmpStr = tmpStr.substr(0, word_start_pos) + '^^' + tmpStr.substr(word_start_pos, word_end_pos);
|
|
8258
8147
|
// }
|
|
8259
|
-
if (val.substr(word_end_pos, 1) ===
|
|
8260
|
-
word_start_pos = word_end_pos;
|
|
8148
|
+
if (val.substr(word_end_pos, 1) === '.') word_start_pos = word_end_pos;
|
|
8261
8149
|
else word_start_pos = null;
|
|
8262
8150
|
word_end_pos = null;
|
|
8263
8151
|
}
|
|
8264
|
-
if (val1 ===
|
|
8265
|
-
if (
|
|
8266
|
-
|
|
8267
|
-
validSymbols.test(val1) &&
|
|
8268
|
-
tmpStr.indexOf("^^") === -1
|
|
8269
|
-
) {
|
|
8270
|
-
tmpStr += "^^" + val1;
|
|
8152
|
+
if (val1 === '[') validSymbols = validSymbolsWithArray;
|
|
8153
|
+
if (nonLettersPatt.test(val1) && validSymbols.test(val1) && tmpStr.indexOf('^^') === -1) {
|
|
8154
|
+
tmpStr += '^^' + val1;
|
|
8271
8155
|
} else tmpStr += val1;
|
|
8272
8156
|
}
|
|
8273
8157
|
// });
|
|
8274
|
-
if (tmpStr.indexOf(
|
|
8158
|
+
if (tmpStr.indexOf('^^') > -1) {
|
|
8275
8159
|
var obj1 = extract_str(tmpStr, pos);
|
|
8276
8160
|
obj = obj.concat(obj1);
|
|
8277
8161
|
} else {
|
|
@@ -8279,10 +8163,8 @@ func.expression.parse = function (strP) {
|
|
|
8279
8163
|
var fieldId = undefined;
|
|
8280
8164
|
if (val) {
|
|
8281
8165
|
fieldId = val.substr(1, val.length);
|
|
8282
|
-
if (val.indexOf(
|
|
8283
|
-
|
|
8284
|
-
if (val.indexOf("[") > -1)
|
|
8285
|
-
fieldId = val.substr(1, val.indexOf("[") - 1);
|
|
8166
|
+
if (val.indexOf('.') > -1) fieldId = val.substr(1, val.indexOf('.') - 1);
|
|
8167
|
+
if (val.indexOf('[') > -1) fieldId = val.substr(1, val.indexOf('[') - 1);
|
|
8286
8168
|
//
|
|
8287
8169
|
// if (val.indexOf("]") > -1)
|
|
8288
8170
|
// fieldId = val.substr(1, val.indexOf("]") - 1);
|
|
@@ -8310,7 +8192,7 @@ func.expression.parse = function (strP) {
|
|
|
8310
8192
|
|
|
8311
8193
|
func.expression.get_property = async function (valP) {
|
|
8312
8194
|
async function secure_eval(val) {
|
|
8313
|
-
if (typeof IS_PROCESS_SERVER ===
|
|
8195
|
+
if (typeof IS_PROCESS_SERVER === 'undefined') {
|
|
8314
8196
|
try {
|
|
8315
8197
|
return eval(val);
|
|
8316
8198
|
} catch (err) {
|
|
@@ -8331,20 +8213,16 @@ func.expression.get_property = async function (valP) {
|
|
|
8331
8213
|
});
|
|
8332
8214
|
return await vm.run(val);
|
|
8333
8215
|
} catch (err) {
|
|
8334
|
-
throw
|
|
8216
|
+
throw '';
|
|
8335
8217
|
}
|
|
8336
8218
|
}
|
|
8337
8219
|
|
|
8338
8220
|
var property1, property2;
|
|
8339
|
-
if (valP.indexOf(
|
|
8340
|
-
property1 = valP.substr(
|
|
8341
|
-
valP.indexOf("[") + 1,
|
|
8342
|
-
valP.indexOf("]") - valP.indexOf("[") - 1
|
|
8343
|
-
); // get []
|
|
8221
|
+
if (valP.indexOf('[') > -1 && valP.indexOf(']') > -1) {
|
|
8222
|
+
property1 = valP.substr(valP.indexOf('[') + 1, valP.indexOf(']') - valP.indexOf('[') - 1); // get []
|
|
8344
8223
|
property1 = await secure_eval(property1);
|
|
8345
8224
|
}
|
|
8346
|
-
if (valP.indexOf(
|
|
8347
|
-
property2 = valP.substr(valP.indexOf(".") + 1, valP.length); // get .
|
|
8225
|
+
if (valP.indexOf('.') > -1) property2 = valP.substr(valP.indexOf('.') + 1, valP.length); // get .
|
|
8348
8226
|
return {
|
|
8349
8227
|
property1: property1,
|
|
8350
8228
|
property2: property2,
|
|
@@ -8352,52 +8230,32 @@ func.expression.get_property = async function (valP) {
|
|
|
8352
8230
|
};
|
|
8353
8231
|
func.expression.validate_constant = function (valP) {
|
|
8354
8232
|
var patt = /["']/;
|
|
8355
|
-
if (
|
|
8356
|
-
typeof valP === "string" &&
|
|
8357
|
-
patt.test(valP.substr(0, 1)) &&
|
|
8358
|
-
patt.test(valP.substr(0, valP.length - 1))
|
|
8359
|
-
)
|
|
8360
|
-
return true;
|
|
8233
|
+
if (typeof valP === 'string' && patt.test(valP.substr(0, 1)) && patt.test(valP.substr(0, valP.length - 1))) return true;
|
|
8361
8234
|
else return false;
|
|
8362
8235
|
};
|
|
8363
8236
|
func.expression.validate_variables = function (valP) {
|
|
8364
|
-
if (typeof valP ===
|
|
8237
|
+
if (typeof valP === 'string' && valP.indexOf('@') > -1) return true;
|
|
8365
8238
|
else return false;
|
|
8366
8239
|
};
|
|
8367
8240
|
func.expression.remove_quotes = function (valP) {
|
|
8368
|
-
if (func.expression.validate_constant(valP))
|
|
8369
|
-
return valP.substr(1, valP.length - 2);
|
|
8241
|
+
if (func.expression.validate_constant(valP)) return valP.substr(1, valP.length - 2);
|
|
8370
8242
|
else return valP;
|
|
8371
8243
|
};
|
|
8372
8244
|
|
|
8373
|
-
func.expression.secure_eval = async function (
|
|
8374
|
-
SESSION_ID,
|
|
8375
|
-
|
|
8376
|
-
|
|
8377
|
-
|
|
8378
|
-
dsSessionP,
|
|
8379
|
-
js_script_callback
|
|
8380
|
-
) {
|
|
8381
|
-
const api_utils = await func.common.get_module(
|
|
8245
|
+
func.expression.secure_eval = async function (SESSION_ID, sourceP, val, job_id, dsSessionP, js_script_callback, evt) {
|
|
8246
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
8247
|
+
func,
|
|
8248
|
+
glb,
|
|
8249
|
+
SESSION_OBJ,
|
|
8382
8250
|
SESSION_ID,
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
SESSION_OBJ,
|
|
8388
|
-
SESSION_ID,
|
|
8389
|
-
APP_OBJ,
|
|
8390
|
-
dsSession: dsSessionP,
|
|
8391
|
-
job_id,
|
|
8392
|
-
}
|
|
8393
|
-
);
|
|
8251
|
+
APP_OBJ,
|
|
8252
|
+
dsSession: dsSessionP,
|
|
8253
|
+
job_id,
|
|
8254
|
+
});
|
|
8394
8255
|
|
|
8395
8256
|
const xu = api_utils;
|
|
8396
8257
|
|
|
8397
|
-
if (
|
|
8398
|
-
typeof IS_PROCESS_SERVER === "undefined" &&
|
|
8399
|
-
typeof IS_DOCKER === "undefined"
|
|
8400
|
-
) {
|
|
8258
|
+
if (typeof IS_PROCESS_SERVER === 'undefined' && typeof IS_DOCKER === 'undefined') {
|
|
8401
8259
|
try {
|
|
8402
8260
|
return eval(val);
|
|
8403
8261
|
} catch (err) {
|
|
@@ -8410,39 +8268,19 @@ func.expression.secure_eval = async function (
|
|
|
8410
8268
|
}
|
|
8411
8269
|
}
|
|
8412
8270
|
// server side execution
|
|
8413
|
-
if (sourceP ===
|
|
8414
|
-
process.on(
|
|
8415
|
-
console.error(
|
|
8271
|
+
if (sourceP === 'javascript') {
|
|
8272
|
+
process.on('uncaughtException', (err) => {
|
|
8273
|
+
console.error('Asynchronous error caught.', err);
|
|
8416
8274
|
|
|
8417
8275
|
func.events.delete_job(SESSION_ID, job_id);
|
|
8418
|
-
if (
|
|
8419
|
-
typeof IS_PROCESS_SERVER !== "undefined" ||
|
|
8420
|
-
typeof IS_DOCKER !== "undefined"
|
|
8421
|
-
) {
|
|
8276
|
+
if (typeof IS_PROCESS_SERVER !== 'undefined' || typeof IS_DOCKER !== 'undefined') {
|
|
8422
8277
|
if (SESSION_OBJ[SESSION_ID].crawler) return;
|
|
8423
|
-
return __.rpi.write_log(
|
|
8424
|
-
SESSION_OBJ[SESSION_ID].app_id,
|
|
8425
|
-
"error",
|
|
8426
|
-
"worker",
|
|
8427
|
-
"vm error",
|
|
8428
|
-
err,
|
|
8429
|
-
null,
|
|
8430
|
-
val,
|
|
8431
|
-
"func.expression.get.secure_eval"
|
|
8432
|
-
);
|
|
8278
|
+
return __.rpi.write_log(SESSION_OBJ[SESSION_ID].app_id, 'error', 'worker', 'vm error', err, null, val, 'func.expression.get.secure_eval');
|
|
8433
8279
|
}
|
|
8434
8280
|
});
|
|
8435
8281
|
try {
|
|
8436
|
-
const dir = path.join(
|
|
8437
|
-
|
|
8438
|
-
SESSION_OBJ[SESSION_ID].app_id,
|
|
8439
|
-
"node_modules",
|
|
8440
|
-
"/"
|
|
8441
|
-
);
|
|
8442
|
-
const script = new VM.VMScript(
|
|
8443
|
-
`try{${val}}catch(e){func.api.error(SESSION_ID, "nodejs error", e); console.error(e); func.events.delete_job(SESSION_ID, job_id);}`,
|
|
8444
|
-
{ filename: dir, dirname: dir }
|
|
8445
|
-
);
|
|
8282
|
+
const dir = path.join(_conf.studio_drive_path, SESSION_OBJ[SESSION_ID].app_id, 'node_modules', '/');
|
|
8283
|
+
const script = new VM.VMScript(`try{${val}}catch(e){func.api.error(SESSION_ID, "nodejs error", e); console.error(e); func.events.delete_job(SESSION_ID, job_id);}`, { filename: dir, dirname: dir });
|
|
8446
8284
|
let vm = new VM.NodeVM({
|
|
8447
8285
|
require: {
|
|
8448
8286
|
external: true,
|
|
@@ -8465,11 +8303,11 @@ func.expression.secure_eval = async function (
|
|
|
8465
8303
|
dirname: dir,
|
|
8466
8304
|
});
|
|
8467
8305
|
} catch (err) {
|
|
8468
|
-
console.error(
|
|
8306
|
+
console.error('Failed to execute script.', err);
|
|
8469
8307
|
|
|
8470
|
-
if (typeof IS_PROCESS_SERVER !==
|
|
8308
|
+
if (typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
8471
8309
|
func.events.delete_job(SESSION_ID, jobNo);
|
|
8472
|
-
return __.db.add_error_log(SESSION_OBJ[SESSION_ID].app_id,
|
|
8310
|
+
return __.db.add_error_log(SESSION_OBJ[SESSION_ID].app_id, 'api', err);
|
|
8473
8311
|
}
|
|
8474
8312
|
}
|
|
8475
8313
|
} else {
|
|
@@ -8488,12 +8326,12 @@ func.expression.secure_eval = async function (
|
|
|
8488
8326
|
allowAsync: false,
|
|
8489
8327
|
});
|
|
8490
8328
|
let ret = val;
|
|
8491
|
-
if (typeof val ===
|
|
8329
|
+
if (typeof val === 'string') {
|
|
8492
8330
|
ret = await vm.run(val);
|
|
8493
8331
|
}
|
|
8494
8332
|
return ret;
|
|
8495
8333
|
} catch (err) {
|
|
8496
|
-
throw
|
|
8334
|
+
throw '';
|
|
8497
8335
|
}
|
|
8498
8336
|
} catch (err) {
|
|
8499
8337
|
try {
|