@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
|
@@ -10776,6 +10776,10 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
|
|
|
10776
10776
|
const trigger = val.key.split('xu-on:')[1].toLowerCase();
|
|
10777
10777
|
$elm.on(trigger, async function (evt) {
|
|
10778
10778
|
for await (const [key, val] of Object.entries($elm.data().xuAttributes['xu-on:' + evt.type])) {
|
|
10779
|
+
if (val.event_modifiers && evt[val.event_modifiers]) {
|
|
10780
|
+
evt[val.event_modifiers]();
|
|
10781
|
+
}
|
|
10782
|
+
|
|
10779
10783
|
if (val.handler === 'custom') {
|
|
10780
10784
|
// do BL
|
|
10781
10785
|
for await (const [key2, val2] of Object.entries(val.event)) {
|
|
@@ -10786,10 +10790,6 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
|
|
|
10786
10790
|
}
|
|
10787
10791
|
if (!cond) continue;
|
|
10788
10792
|
|
|
10789
|
-
if (val.event_modifiers && evt[val.event_modifiers]) {
|
|
10790
|
-
evt[val.event_modifiers]();
|
|
10791
|
-
}
|
|
10792
|
-
|
|
10793
10793
|
func.events.add_to_queue(SESSION_ID, 'element event', val2.id, evt.type, val2.data.action, val2.data.name, null, $elm.attr('xu-ui-id'), null, evt, null, null, null, paramsP.dsSessionP, null, null, null, evt.type, val2.data.name, null, null, val2, null, null, null, null, null, null);
|
|
10794
10794
|
}
|
|
10795
10795
|
}
|
|
@@ -14101,6 +14101,10 @@ func.events.execute = async function (
|
|
|
14101
14101
|
`(async function(el,evt) {
|
|
14102
14102
|
${refIdP.value}
|
|
14103
14103
|
})(document.querySelector(\`[xu-ui-id=${elementP}]\`),evt)`,
|
|
14104
|
+
null,
|
|
14105
|
+
null,
|
|
14106
|
+
null,
|
|
14107
|
+
evt,
|
|
14104
14108
|
);
|
|
14105
14109
|
await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
|
|
14106
14110
|
|
|
@@ -14117,6 +14121,9 @@ func.events.execute = async function (
|
|
|
14117
14121
|
${refIdP.value}
|
|
14118
14122
|
})(document.querySelector(\`[xu-ui-id=${elementP}]\`),evt)`,
|
|
14119
14123
|
true,
|
|
14124
|
+
null,
|
|
14125
|
+
null,
|
|
14126
|
+
evt,
|
|
14120
14127
|
);
|
|
14121
14128
|
await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
|
|
14122
14129
|
|
|
@@ -14657,22 +14664,7 @@ func.events.invoke = async function (event_id) {
|
|
|
14657
14664
|
};
|
|
14658
14665
|
func.expression = {};
|
|
14659
14666
|
|
|
14660
|
-
func.expression.get = async function (
|
|
14661
|
-
SESSION_ID,
|
|
14662
|
-
valP,
|
|
14663
|
-
dsSessionP,
|
|
14664
|
-
sourceP,
|
|
14665
|
-
rowIdP,
|
|
14666
|
-
sourceActionP,
|
|
14667
|
-
secondPassP,
|
|
14668
|
-
calling_fieldIdP,
|
|
14669
|
-
fieldsP,
|
|
14670
|
-
debug_infoP,
|
|
14671
|
-
iterate_info,
|
|
14672
|
-
js_script_callback,
|
|
14673
|
-
jobNo,
|
|
14674
|
-
api_output_type
|
|
14675
|
-
) {
|
|
14667
|
+
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) {
|
|
14676
14668
|
class xu_class {
|
|
14677
14669
|
async get() {
|
|
14678
14670
|
var ret;
|
|
@@ -14681,23 +14673,23 @@ func.expression.get = async function (
|
|
|
14681
14673
|
var warning;
|
|
14682
14674
|
|
|
14683
14675
|
function evalJson(text) {
|
|
14684
|
-
return eval(
|
|
14676
|
+
return eval('(' + text + ')');
|
|
14685
14677
|
}
|
|
14686
14678
|
|
|
14687
14679
|
if (valP === null) {
|
|
14688
|
-
ret =
|
|
14680
|
+
ret = '';
|
|
14689
14681
|
} else {
|
|
14690
14682
|
switch (typeof valP) {
|
|
14691
|
-
case
|
|
14683
|
+
case 'string':
|
|
14692
14684
|
ret = valP;
|
|
14693
14685
|
break;
|
|
14694
14686
|
|
|
14695
|
-
case
|
|
14696
|
-
ret =
|
|
14687
|
+
case 'undefined':
|
|
14688
|
+
ret = '';
|
|
14697
14689
|
break;
|
|
14698
14690
|
|
|
14699
|
-
case
|
|
14700
|
-
ret = valP ?
|
|
14691
|
+
case 'boolean':
|
|
14692
|
+
ret = valP ? 'Y' : 'N';
|
|
14701
14693
|
break;
|
|
14702
14694
|
|
|
14703
14695
|
default:
|
|
@@ -14706,40 +14698,35 @@ func.expression.get = async function (
|
|
|
14706
14698
|
}
|
|
14707
14699
|
}
|
|
14708
14700
|
|
|
14709
|
-
ret = ret.replace(/\&/g,
|
|
14701
|
+
ret = ret.replace(/\&/g, '&');
|
|
14710
14702
|
ret = func.utils.replace_studio_drive_url(SESSION_ID, ret);
|
|
14711
14703
|
|
|
14712
14704
|
const end_results = function () {
|
|
14713
14705
|
const replace_quotes = function (ret) {
|
|
14714
14706
|
for (const [key, val] of Object.entries(fields)) {
|
|
14715
|
-
if (typeof val ===
|
|
14716
|
-
ret = ret.replace('"' + val + '"', val.replace(/"/gi, ""));
|
|
14707
|
+
if (typeof val === 'string') ret = ret.replace('"' + val + '"', val.replace(/"/gi, ''));
|
|
14717
14708
|
}
|
|
14718
14709
|
return ret;
|
|
14719
14710
|
};
|
|
14720
|
-
if ([
|
|
14721
|
-
if (typeof ret ===
|
|
14711
|
+
if (['update', 'javascript'].includes(sourceP)) {
|
|
14712
|
+
if (typeof ret === 'string') ret = replace_quotes(ret);
|
|
14722
14713
|
}
|
|
14723
14714
|
const log_error = function () {
|
|
14724
14715
|
if (SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP]) {
|
|
14725
|
-
func.utils.debug.log(
|
|
14726
|
-
|
|
14727
|
-
|
|
14728
|
-
|
|
14729
|
-
|
|
14730
|
-
|
|
14731
|
-
|
|
14732
|
-
|
|
14733
|
-
|
|
14734
|
-
|
|
14735
|
-
|
|
14736
|
-
|
|
14737
|
-
|
|
14738
|
-
|
|
14739
|
-
prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
14740
|
-
debug_info: debug_infoP,
|
|
14741
|
-
}
|
|
14742
|
-
);
|
|
14716
|
+
func.utils.debug.log(SESSION_ID, SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].nodeId, {
|
|
14717
|
+
module: 'expression',
|
|
14718
|
+
action: sourceP,
|
|
14719
|
+
source: calling_fieldIdP,
|
|
14720
|
+
prop: ret,
|
|
14721
|
+
details: ret,
|
|
14722
|
+
result: ret,
|
|
14723
|
+
error: error,
|
|
14724
|
+
warning: warning,
|
|
14725
|
+
fields: null,
|
|
14726
|
+
type: 'exp',
|
|
14727
|
+
prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
14728
|
+
debug_info: debug_infoP,
|
|
14729
|
+
});
|
|
14743
14730
|
}
|
|
14744
14731
|
};
|
|
14745
14732
|
if (error) log_error();
|
|
@@ -14757,32 +14744,22 @@ func.expression.get = async function (
|
|
|
14757
14744
|
};
|
|
14758
14745
|
const variable_not_exist = async function () {
|
|
14759
14746
|
try {
|
|
14760
|
-
if (sourceP !==
|
|
14761
|
-
if (ret && ret.substr(0, 6) ===
|
|
14747
|
+
if (sourceP !== 'arguments') {
|
|
14748
|
+
if (ret && ret.substr(0, 6) === '_DATE_') {
|
|
14762
14749
|
ret = ret.substr(6);
|
|
14763
14750
|
} else if (
|
|
14764
|
-
(ret &&
|
|
14765
|
-
|
|
14766
|
-
ret.substr(4, 1) === "-" &&
|
|
14767
|
-
ret.substr(7, 1) === "-") ||
|
|
14768
|
-
ret === "self" // bypass eval for date 2017-03-22
|
|
14751
|
+
(ret && ret.length === 10 && ret.substr(4, 1) === '-' && ret.substr(7, 1) === '-') ||
|
|
14752
|
+
ret === 'self' // bypass eval for date 2017-03-22
|
|
14769
14753
|
) {
|
|
14770
14754
|
ret = ret;
|
|
14771
14755
|
} else {
|
|
14772
|
-
ret = await func.expression.secure_eval(
|
|
14773
|
-
SESSION_ID,
|
|
14774
|
-
sourceP,
|
|
14775
|
-
ret,
|
|
14776
|
-
jobNo,
|
|
14777
|
-
dsSessionP,
|
|
14778
|
-
js_script_callback
|
|
14779
|
-
);
|
|
14756
|
+
ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
14780
14757
|
}
|
|
14781
14758
|
// console.log("AFTER OK", ret)
|
|
14782
14759
|
return end_results();
|
|
14783
14760
|
} else {
|
|
14784
14761
|
// do eval for arithmetic vals
|
|
14785
|
-
ret = ret.replace(/_NULL/gi,
|
|
14762
|
+
ret = ret.replace(/_NULL/gi, '');
|
|
14786
14763
|
return end_results();
|
|
14787
14764
|
}
|
|
14788
14765
|
} catch (err) {
|
|
@@ -14795,14 +14772,7 @@ func.expression.get = async function (
|
|
|
14795
14772
|
}
|
|
14796
14773
|
|
|
14797
14774
|
const validate_email = async function () {
|
|
14798
|
-
const ret = await func.expression.secure_eval(
|
|
14799
|
-
SESSION_ID,
|
|
14800
|
-
sourceP,
|
|
14801
|
-
valP,
|
|
14802
|
-
jobNo,
|
|
14803
|
-
dsSessionP,
|
|
14804
|
-
js_script_callback
|
|
14805
|
-
);
|
|
14775
|
+
const ret = await func.expression.secure_eval(SESSION_ID, sourceP, valP, jobNo, dsSessionP, js_script_callback);
|
|
14806
14776
|
|
|
14807
14777
|
return glb.emailRegex.test(ret);
|
|
14808
14778
|
};
|
|
@@ -14821,10 +14791,7 @@ func.expression.get = async function (
|
|
|
14821
14791
|
var_Arr[key].value = val.value;
|
|
14822
14792
|
//--------------
|
|
14823
14793
|
const replace_value_in_string = async function (retP, fieldIdP) {
|
|
14824
|
-
if (
|
|
14825
|
-
iterate_info?.iterator_key === fieldIdP ||
|
|
14826
|
-
iterate_info?.iterator_val === fieldIdP
|
|
14827
|
-
) {
|
|
14794
|
+
if (iterate_info?.iterator_key === fieldIdP || iterate_info?.iterator_val === fieldIdP) {
|
|
14828
14795
|
if (iterate_info.iterator_key === fieldIdP) {
|
|
14829
14796
|
retP.value = iterate_info._key;
|
|
14830
14797
|
}
|
|
@@ -14834,50 +14801,43 @@ func.expression.get = async function (
|
|
|
14834
14801
|
}
|
|
14835
14802
|
|
|
14836
14803
|
const set_value = function (valP) {
|
|
14837
|
-
if (typeof valP !==
|
|
14804
|
+
if (typeof valP !== 'undefined') {
|
|
14838
14805
|
var_Arr[key].value = valP;
|
|
14839
|
-
if (typeof valP ===
|
|
14806
|
+
if (typeof valP === 'string') var_Arr[key].type = 'string';
|
|
14840
14807
|
} else {
|
|
14841
|
-
if (retP.type ===
|
|
14842
|
-
var_Arr[key].value =
|
|
14843
|
-
var_Arr[key].type =
|
|
14808
|
+
if (retP.type === 'object') {
|
|
14809
|
+
var_Arr[key].value = '';
|
|
14810
|
+
var_Arr[key].type = 'string';
|
|
14844
14811
|
}
|
|
14845
14812
|
}
|
|
14846
14813
|
};
|
|
14847
14814
|
|
|
14848
|
-
if (sourceP ===
|
|
14815
|
+
if (sourceP === 'exp' && retP.type !== 'exp') {
|
|
14849
14816
|
var_Arr[key].type = retP.type;
|
|
14850
14817
|
return;
|
|
14851
14818
|
}
|
|
14852
|
-
if (typeof retP.value !==
|
|
14819
|
+
if (typeof retP.value !== 'undefined') {
|
|
14853
14820
|
var_Arr[key].type = retP.type;
|
|
14854
14821
|
var_Arr[key].value = retP.value;
|
|
14855
|
-
if ((val.value.indexOf(
|
|
14822
|
+
if ((val.value.indexOf('[') > -1) | (val.value.indexOf('.') > -1)) {
|
|
14856
14823
|
//get values from array '@var==="sss" && @var_B==="sss" && @obj.property===5 && @objA["value"]===123 | @objB["value"].property===1234'
|
|
14857
14824
|
var data = retP.prop;
|
|
14858
|
-
if (retP.type ===
|
|
14825
|
+
if (retP.type === 'object') data = retP.value;
|
|
14859
14826
|
var property1, property2;
|
|
14860
14827
|
//check for split situation: @objB[@var].property 1: @objB[ 2:@var].property
|
|
14861
|
-
if (
|
|
14862
|
-
val.value.indexOf("[") === -1 &&
|
|
14863
|
-
val.value.indexOf("]") > -1 &&
|
|
14864
|
-
val.value.substr(0, 1) === "@"
|
|
14865
|
-
) {
|
|
14828
|
+
if (val.value.indexOf('[') === -1 && val.value.indexOf(']') > -1 && val.value.substr(0, 1) === '@') {
|
|
14866
14829
|
//check situation 2
|
|
14867
14830
|
var prevData = var_Arr[key - 1].value;
|
|
14868
14831
|
var_Arr[key].value = prevData[data]; // @objB[@var]
|
|
14869
|
-
if (val.value.indexOf(
|
|
14870
|
-
property2 = await func.expression.get_property(val.value)
|
|
14871
|
-
.property2; //val.value.substr(val.value.indexOf(".") + 1, val.value.length); // get .
|
|
14832
|
+
if (val.value.indexOf('.') > -1) {
|
|
14833
|
+
property2 = await func.expression.get_property(val.value).property2; //val.value.substr(val.value.indexOf(".") + 1, val.value.length); // get .
|
|
14872
14834
|
if (prevData[data]) set_value(prevData[data][property2]);
|
|
14873
14835
|
// var_Arr[key].value = prevData[data][property2]; //@objB[@var].property
|
|
14874
14836
|
}
|
|
14875
14837
|
delete var_Arr[key - 1];
|
|
14876
14838
|
} else {
|
|
14877
|
-
property1 = await func.expression.get_property(val.value)
|
|
14878
|
-
|
|
14879
|
-
property2 = await func.expression.get_property(val.value)
|
|
14880
|
-
.property2;
|
|
14839
|
+
property1 = await func.expression.get_property(val.value).property1;
|
|
14840
|
+
property2 = await func.expression.get_property(val.value).property2;
|
|
14881
14841
|
if (property1) {
|
|
14882
14842
|
var_Arr[key].value = data[property1]; // @var["value"] or @var.property
|
|
14883
14843
|
if (property2) {
|
|
@@ -14905,19 +14865,11 @@ func.expression.get = async function (
|
|
|
14905
14865
|
//>>>>>>>>>>>>>>>>>>
|
|
14906
14866
|
if (val.fieldId) {
|
|
14907
14867
|
// @_THIS
|
|
14908
|
-
if (
|
|
14909
|
-
val.fieldId &&
|
|
14910
|
-
val.fieldId.substr(0, 5) === "_THIS" &&
|
|
14911
|
-
calling_fieldIdP &&
|
|
14912
|
-
(val.fieldId.length === 5 ||
|
|
14913
|
-
(val.fieldId.length > 5 && val.fieldId.substr(5, 1) === "."))
|
|
14914
|
-
) {
|
|
14868
|
+
if (val.fieldId && val.fieldId.substr(0, 5) === '_THIS' && calling_fieldIdP && (val.fieldId.length === 5 || (val.fieldId.length > 5 && val.fieldId.substr(5, 1) === '.'))) {
|
|
14915
14869
|
if (val.fieldId.length === 5) val.fieldId = calling_fieldIdP;
|
|
14916
|
-
else
|
|
14917
|
-
val.fieldId =
|
|
14918
|
-
calling_fieldIdP + val.fieldId(5, val.fieldId.length - 1);
|
|
14870
|
+
else val.fieldId = calling_fieldIdP + val.fieldId(5, val.fieldId.length - 1);
|
|
14919
14871
|
}
|
|
14920
|
-
if (!sourceP ===
|
|
14872
|
+
if (!sourceP === 'exp') {
|
|
14921
14873
|
var_Arr[key].value = '""';
|
|
14922
14874
|
} // put default
|
|
14923
14875
|
fields[val.fieldId] = var_Arr[key].value;
|
|
@@ -14927,7 +14879,7 @@ func.expression.get = async function (
|
|
|
14927
14879
|
val.fieldId,
|
|
14928
14880
|
dsSessionP,
|
|
14929
14881
|
|
|
14930
|
-
rowIdP
|
|
14882
|
+
rowIdP,
|
|
14931
14883
|
); // find field in dataSources
|
|
14932
14884
|
|
|
14933
14885
|
await replace_value_in_string(ret.ret, ret.fieldIdP);
|
|
@@ -14940,7 +14892,7 @@ func.expression.get = async function (
|
|
|
14940
14892
|
var var_error_found;
|
|
14941
14893
|
// merge arr values
|
|
14942
14894
|
_.forEach(var_Arr, function (val, key) {
|
|
14943
|
-
if (sourceP ===
|
|
14895
|
+
if (sourceP === 'UI Property EXP') {
|
|
14944
14896
|
let ret = func.utils.get_drive_url(SESSION_ID, val.value, true);
|
|
14945
14897
|
if (ret.changed) {
|
|
14946
14898
|
res[key] = ret.value;
|
|
@@ -14948,108 +14900,72 @@ func.expression.get = async function (
|
|
|
14948
14900
|
}
|
|
14949
14901
|
}
|
|
14950
14902
|
|
|
14951
|
-
if (sourceP ===
|
|
14952
|
-
let ret = func.utils.get_drive_url(
|
|
14953
|
-
SESSION_ID,
|
|
14954
|
-
val.value,
|
|
14955
|
-
var_Arr.length == 1 ? false : true
|
|
14956
|
-
);
|
|
14903
|
+
if (sourceP === 'UI Attr EXP') {
|
|
14904
|
+
let ret = func.utils.get_drive_url(SESSION_ID, val.value, var_Arr.length == 1 ? false : true);
|
|
14957
14905
|
if (ret.changed) {
|
|
14958
14906
|
res[key] = ret.value;
|
|
14959
14907
|
return true;
|
|
14960
14908
|
}
|
|
14961
14909
|
}
|
|
14962
14910
|
|
|
14963
|
-
if (val.type ===
|
|
14911
|
+
if (val.type === 'exp') {
|
|
14964
14912
|
exp_exist = true;
|
|
14965
14913
|
}
|
|
14966
14914
|
res[key] = val.value;
|
|
14967
14915
|
|
|
14968
|
-
if (var_Arr.length > 1) {
|
|
14969
|
-
|
|
14970
|
-
|
|
14971
|
-
|
|
14972
|
-
) &&
|
|
14973
|
-
["string", "date"].includes(val.type)
|
|
14974
|
-
) {
|
|
14975
|
-
res[key] = "`" + val.value + "`";
|
|
14916
|
+
if (var_Arr.length > 1) {
|
|
14917
|
+
// complex input
|
|
14918
|
+
if (!['DbQuery', 'alert', 'exp', 'api_rendered_output'].includes(sourceP) && ['string', 'date'].includes(val.type)) {
|
|
14919
|
+
res[key] = '`' + val.value + '`';
|
|
14976
14920
|
}
|
|
14977
14921
|
// new Dec 18 2024 for Ishai // json,html,xml,text,css
|
|
14978
|
-
if (
|
|
14979
|
-
["api_rendered_output"].includes(sourceP) && ["json"].includes(api_output_type) &&
|
|
14980
|
-
["string", "date"].includes(val.type)
|
|
14981
|
-
) {
|
|
14922
|
+
if (['api_rendered_output'].includes(sourceP) && ['json'].includes(api_output_type) && ['string', 'date'].includes(val.type)) {
|
|
14982
14923
|
res[key] = `"` + val.value + `"`;
|
|
14983
14924
|
}
|
|
14984
14925
|
}
|
|
14985
|
-
if (val.fieldId && val.value && typeof val.value ===
|
|
14986
|
-
if (
|
|
14987
|
-
|
|
14988
|
-
|
|
14989
|
-
)
|
|
14990
|
-
) {
|
|
14991
|
-
if (val.value.indexOf("↵") > -1) {
|
|
14992
|
-
res[key] = val.value.split("↵").join("");
|
|
14926
|
+
if (val.fieldId && val.value && typeof val.value === 'string') {
|
|
14927
|
+
if (['query', 'condition', 'range', 'sort', 'locate'].includes(sourceP)) {
|
|
14928
|
+
if (val.value.indexOf('↵') > -1) {
|
|
14929
|
+
res[key] = val.value.split('↵').join('');
|
|
14993
14930
|
}
|
|
14994
|
-
res[key] = res[key].replace(/(\r\n|\n|\r)/gm,
|
|
14931
|
+
res[key] = res[key].replace(/(\r\n|\n|\r)/gm, ''); //.replace(/"/g,'\"');//.replace(/'/g,"");
|
|
14995
14932
|
}
|
|
14996
14933
|
|
|
14997
|
-
if ([
|
|
14998
|
-
if (val.value.indexOf(
|
|
14999
|
-
|
|
15000
|
-
res[key] = res[key].replace(/(\r\n|\n|\r)/gm, "\\n");
|
|
14934
|
+
if (['init', 'update', 'virtual'].includes(sourceP)) {
|
|
14935
|
+
if (val.value.indexOf('↵') > -1) res[key] = val.value.split('↵').join('\n');
|
|
14936
|
+
res[key] = res[key].replace(/(\r\n|\n|\r)/gm, '\\n');
|
|
15001
14937
|
}
|
|
15002
14938
|
|
|
15003
|
-
if (typeof IS_PROCESS_SERVER !==
|
|
15004
|
-
res[key] = res[key].replace(/(\r\n|\n|\r)/gm,
|
|
14939
|
+
if (typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
14940
|
+
res[key] = res[key].replace(/(\r\n|\n|\r)/gm, '<br>');
|
|
15005
14941
|
}
|
|
15006
14942
|
|
|
15007
14943
|
fields[val.fieldId] = res[key];
|
|
15008
14944
|
}
|
|
15009
14945
|
// extract object
|
|
15010
|
-
if (typeof val.value ===
|
|
15011
|
-
if (
|
|
15012
|
-
!Array.isArray(val.value) &&
|
|
15013
|
-
!var_Arr[key + 1].value?.includes(".")
|
|
15014
|
-
) {
|
|
14946
|
+
if (typeof val.value === 'object' && var_Arr.length > 1) {
|
|
14947
|
+
if (!Array.isArray(val.value) && !var_Arr[key + 1].value?.includes('.')) {
|
|
15015
14948
|
// && !["api_rendered_output"].includes(sourceP)
|
|
15016
14949
|
|
|
15017
14950
|
// prevent cast on single value expression
|
|
15018
|
-
res[key] =
|
|
14951
|
+
res[key] = '(' + JSON.stringify(val.value) + ')';
|
|
15019
14952
|
} else {
|
|
15020
14953
|
res[key] = JSON.stringify(val.value);
|
|
15021
14954
|
}
|
|
15022
14955
|
}
|
|
15023
14956
|
|
|
15024
|
-
if (
|
|
15025
|
-
|
|
15026
|
-
sourceP !== "exp" &&
|
|
15027
|
-
val.value &&
|
|
15028
|
-
typeof val.value === "string" &&
|
|
15029
|
-
val.value.substr(0, 1) === "@"
|
|
15030
|
-
) {
|
|
15031
|
-
warning = "Error encoding " + val.value;
|
|
14957
|
+
if (!exp_exist && sourceP !== 'exp' && val.value && typeof val.value === 'string' && val.value.substr(0, 1) === '@') {
|
|
14958
|
+
warning = 'Error encoding ' + val.value;
|
|
15032
14959
|
var_error_found = true;
|
|
15033
14960
|
res[key] = 0;
|
|
15034
14961
|
}
|
|
15035
14962
|
});
|
|
15036
14963
|
var join = function (arrP) {
|
|
15037
|
-
return arrP.join(
|
|
14964
|
+
return arrP.join('');
|
|
15038
14965
|
};
|
|
15039
14966
|
var exp = undefined;
|
|
15040
|
-
if (exp_exist && sourceP !==
|
|
15041
|
-
exp = await func.expression.get(
|
|
15042
|
-
SESSION_ID,
|
|
15043
|
-
join(res),
|
|
15044
|
-
dsSessionP,
|
|
15045
|
-
sourceP,
|
|
15046
|
-
rowIdP,
|
|
15047
|
-
sourceActionP,
|
|
15048
|
-
true,
|
|
15049
|
-
calling_fieldIdP,
|
|
15050
|
-
fields,
|
|
15051
|
-
debug_infoP
|
|
15052
|
-
);
|
|
14967
|
+
if (exp_exist && sourceP !== 'exp') {
|
|
14968
|
+
exp = await func.expression.get(SESSION_ID, join(res), dsSessionP, sourceP, rowIdP, sourceActionP, true, calling_fieldIdP, fields, debug_infoP);
|
|
15053
14969
|
if (exp.res) res = exp.res;
|
|
15054
14970
|
// do second pass when exp exist
|
|
15055
14971
|
else res = [exp.result];
|
|
@@ -15064,39 +14980,28 @@ func.expression.get = async function (
|
|
|
15064
14980
|
|
|
15065
14981
|
if (secondPassP) {
|
|
15066
14982
|
ret = result;
|
|
15067
|
-
} else if (sourceP !==
|
|
14983
|
+
} else if (sourceP !== 'exp') {
|
|
15068
14984
|
// no eval for second pass
|
|
15069
14985
|
// return single value
|
|
15070
|
-
if (
|
|
15071
|
-
res.length === 1 &&
|
|
15072
|
-
typeof res[0] === "string" &&
|
|
15073
|
-
typeof res[0] !== "object"
|
|
15074
|
-
) {
|
|
14986
|
+
if (res.length === 1 && typeof res[0] === 'string' && typeof res[0] !== 'object') {
|
|
15075
14987
|
// avoid eval when query leading zeros problem
|
|
15076
14988
|
ret = join(res);
|
|
15077
|
-
if (ret && ret.substr(0, 1) ===
|
|
15078
|
-
error =
|
|
14989
|
+
if (ret && ret.substr(0, 1) === '@') {
|
|
14990
|
+
error = 'Error encoding @ var';
|
|
15079
14991
|
var_error_found = true;
|
|
15080
14992
|
}
|
|
15081
14993
|
} else {
|
|
15082
14994
|
if (
|
|
15083
14995
|
![
|
|
15084
|
-
|
|
14996
|
+
'arguments',
|
|
15085
14997
|
// "alert",
|
|
15086
|
-
|
|
15087
|
-
|
|
14998
|
+
'api_rendered_output',
|
|
14999
|
+
'DbQuery',
|
|
15088
15000
|
].includes(sourceP)
|
|
15089
15001
|
) {
|
|
15090
|
-
ret = await func.expression.secure_eval(
|
|
15091
|
-
SESSION_ID,
|
|
15092
|
-
sourceP,
|
|
15093
|
-
result,
|
|
15094
|
-
jobNo,
|
|
15095
|
-
dsSessionP,
|
|
15096
|
-
js_script_callback
|
|
15097
|
-
);
|
|
15002
|
+
ret = await func.expression.secure_eval(SESSION_ID, sourceP, result, jobNo, dsSessionP, js_script_callback);
|
|
15098
15003
|
} else {
|
|
15099
|
-
if (sourceP ===
|
|
15004
|
+
if (sourceP === 'DbQuery') {
|
|
15100
15005
|
ret = JSON.stringify(evalJson(result));
|
|
15101
15006
|
} else {
|
|
15102
15007
|
// try eval
|
|
@@ -15125,12 +15030,7 @@ func.expression.parse = function (strP) {
|
|
|
15125
15030
|
if (!posP) posP = 0;
|
|
15126
15031
|
var clean_split_str = function (arrP) {
|
|
15127
15032
|
var arr = [];
|
|
15128
|
-
if (
|
|
15129
|
-
arrP &&
|
|
15130
|
-
arrP.length > 1 &&
|
|
15131
|
-
arrP[0] === "" &&
|
|
15132
|
-
arrP[1].indexOf("@") > -1
|
|
15133
|
-
) {
|
|
15033
|
+
if (arrP && arrP.length > 1 && arrP[0] === '' && arrP[1].indexOf('@') > -1) {
|
|
15134
15034
|
for (var i = 1; i <= arrP.length; i++) {
|
|
15135
15035
|
arr.push(arrP[i]);
|
|
15136
15036
|
}
|
|
@@ -15141,7 +15041,7 @@ func.expression.parse = function (strP) {
|
|
|
15141
15041
|
var validSymbolsNoArray = /[^.@\[]/; //valid symbols no array /[^.@\[\]\]]/
|
|
15142
15042
|
var validSymbolsWithArray = /[^.@"'\[\]]/; //valid symbols with array
|
|
15143
15043
|
var validSymbols = validSymbolsNoArray;
|
|
15144
|
-
var splitTmp = strP.replace(/@/g,
|
|
15044
|
+
var splitTmp = strP.replace(/@/g, '^^@').split('^^');
|
|
15145
15045
|
var split = clean_split_str(splitTmp);
|
|
15146
15046
|
var obj = [];
|
|
15147
15047
|
if (split) {
|
|
@@ -15149,8 +15049,8 @@ func.expression.parse = function (strP) {
|
|
|
15149
15049
|
// run on @ segments
|
|
15150
15050
|
if (val) {
|
|
15151
15051
|
var pos = strP.indexOf(val);
|
|
15152
|
-
if (val && val.substr(0, 1) ===
|
|
15153
|
-
var tmpStr =
|
|
15052
|
+
if (val && val.substr(0, 1) === '@') {
|
|
15053
|
+
var tmpStr = '';
|
|
15154
15054
|
var word_start_pos = undefined;
|
|
15155
15055
|
var word_end_pos = undefined;
|
|
15156
15056
|
// run on @ segment string
|
|
@@ -15158,7 +15058,7 @@ func.expression.parse = function (strP) {
|
|
|
15158
15058
|
var key1 = i;
|
|
15159
15059
|
var val1 = val.substr(i, 1);
|
|
15160
15060
|
if (
|
|
15161
|
-
val1 ===
|
|
15061
|
+
val1 === '.' &&
|
|
15162
15062
|
!word_start_pos // find first dot
|
|
15163
15063
|
)
|
|
15164
15064
|
word_start_pos = key1;
|
|
@@ -15168,40 +15068,24 @@ func.expression.parse = function (strP) {
|
|
|
15168
15068
|
nonLettersPatt.test(val1) // find any sign character to mark the end of word
|
|
15169
15069
|
)
|
|
15170
15070
|
word_end_pos = key1;
|
|
15171
|
-
if (
|
|
15172
|
-
word_start_pos &&
|
|
15173
|
-
word_start_pos >= 0 &&
|
|
15174
|
-
word_end_pos &&
|
|
15175
|
-
word_end_pos >= 0
|
|
15176
|
-
) {
|
|
15071
|
+
if (word_start_pos && word_start_pos >= 0 && word_end_pos && word_end_pos >= 0) {
|
|
15177
15072
|
// find the word
|
|
15178
|
-
var word = val.substr(
|
|
15179
|
-
word_start_pos + 1,
|
|
15180
|
-
word_end_pos - word_start_pos - 1
|
|
15181
|
-
); // get the word
|
|
15073
|
+
var word = val.substr(word_start_pos + 1, word_end_pos - word_start_pos - 1); // get the word
|
|
15182
15074
|
// if (glb.ALL_PROPERTIES_ARR.indexOf(word) === -1) {
|
|
15183
15075
|
// compare with internal properties
|
|
15184
|
-
tmpStr =
|
|
15185
|
-
tmpStr.substr(0, word_start_pos) +
|
|
15186
|
-
"^^" +
|
|
15187
|
-
tmpStr.substr(word_start_pos, word_end_pos);
|
|
15076
|
+
tmpStr = tmpStr.substr(0, word_start_pos) + '^^' + tmpStr.substr(word_start_pos, word_end_pos);
|
|
15188
15077
|
// }
|
|
15189
|
-
if (val.substr(word_end_pos, 1) ===
|
|
15190
|
-
word_start_pos = word_end_pos;
|
|
15078
|
+
if (val.substr(word_end_pos, 1) === '.') word_start_pos = word_end_pos;
|
|
15191
15079
|
else word_start_pos = null;
|
|
15192
15080
|
word_end_pos = null;
|
|
15193
15081
|
}
|
|
15194
|
-
if (val1 ===
|
|
15195
|
-
if (
|
|
15196
|
-
|
|
15197
|
-
validSymbols.test(val1) &&
|
|
15198
|
-
tmpStr.indexOf("^^") === -1
|
|
15199
|
-
) {
|
|
15200
|
-
tmpStr += "^^" + val1;
|
|
15082
|
+
if (val1 === '[') validSymbols = validSymbolsWithArray;
|
|
15083
|
+
if (nonLettersPatt.test(val1) && validSymbols.test(val1) && tmpStr.indexOf('^^') === -1) {
|
|
15084
|
+
tmpStr += '^^' + val1;
|
|
15201
15085
|
} else tmpStr += val1;
|
|
15202
15086
|
}
|
|
15203
15087
|
// });
|
|
15204
|
-
if (tmpStr.indexOf(
|
|
15088
|
+
if (tmpStr.indexOf('^^') > -1) {
|
|
15205
15089
|
var obj1 = extract_str(tmpStr, pos);
|
|
15206
15090
|
obj = obj.concat(obj1);
|
|
15207
15091
|
} else {
|
|
@@ -15209,10 +15093,8 @@ func.expression.parse = function (strP) {
|
|
|
15209
15093
|
var fieldId = undefined;
|
|
15210
15094
|
if (val) {
|
|
15211
15095
|
fieldId = val.substr(1, val.length);
|
|
15212
|
-
if (val.indexOf(
|
|
15213
|
-
|
|
15214
|
-
if (val.indexOf("[") > -1)
|
|
15215
|
-
fieldId = val.substr(1, val.indexOf("[") - 1);
|
|
15096
|
+
if (val.indexOf('.') > -1) fieldId = val.substr(1, val.indexOf('.') - 1);
|
|
15097
|
+
if (val.indexOf('[') > -1) fieldId = val.substr(1, val.indexOf('[') - 1);
|
|
15216
15098
|
//
|
|
15217
15099
|
// if (val.indexOf("]") > -1)
|
|
15218
15100
|
// fieldId = val.substr(1, val.indexOf("]") - 1);
|
|
@@ -15240,7 +15122,7 @@ func.expression.parse = function (strP) {
|
|
|
15240
15122
|
|
|
15241
15123
|
func.expression.get_property = async function (valP) {
|
|
15242
15124
|
async function secure_eval(val) {
|
|
15243
|
-
if (typeof IS_PROCESS_SERVER ===
|
|
15125
|
+
if (typeof IS_PROCESS_SERVER === 'undefined') {
|
|
15244
15126
|
try {
|
|
15245
15127
|
return eval(val);
|
|
15246
15128
|
} catch (err) {
|
|
@@ -15261,20 +15143,16 @@ func.expression.get_property = async function (valP) {
|
|
|
15261
15143
|
});
|
|
15262
15144
|
return await vm.run(val);
|
|
15263
15145
|
} catch (err) {
|
|
15264
|
-
throw
|
|
15146
|
+
throw '';
|
|
15265
15147
|
}
|
|
15266
15148
|
}
|
|
15267
15149
|
|
|
15268
15150
|
var property1, property2;
|
|
15269
|
-
if (valP.indexOf(
|
|
15270
|
-
property1 = valP.substr(
|
|
15271
|
-
valP.indexOf("[") + 1,
|
|
15272
|
-
valP.indexOf("]") - valP.indexOf("[") - 1
|
|
15273
|
-
); // get []
|
|
15151
|
+
if (valP.indexOf('[') > -1 && valP.indexOf(']') > -1) {
|
|
15152
|
+
property1 = valP.substr(valP.indexOf('[') + 1, valP.indexOf(']') - valP.indexOf('[') - 1); // get []
|
|
15274
15153
|
property1 = await secure_eval(property1);
|
|
15275
15154
|
}
|
|
15276
|
-
if (valP.indexOf(
|
|
15277
|
-
property2 = valP.substr(valP.indexOf(".") + 1, valP.length); // get .
|
|
15155
|
+
if (valP.indexOf('.') > -1) property2 = valP.substr(valP.indexOf('.') + 1, valP.length); // get .
|
|
15278
15156
|
return {
|
|
15279
15157
|
property1: property1,
|
|
15280
15158
|
property2: property2,
|
|
@@ -15282,52 +15160,32 @@ func.expression.get_property = async function (valP) {
|
|
|
15282
15160
|
};
|
|
15283
15161
|
func.expression.validate_constant = function (valP) {
|
|
15284
15162
|
var patt = /["']/;
|
|
15285
|
-
if (
|
|
15286
|
-
typeof valP === "string" &&
|
|
15287
|
-
patt.test(valP.substr(0, 1)) &&
|
|
15288
|
-
patt.test(valP.substr(0, valP.length - 1))
|
|
15289
|
-
)
|
|
15290
|
-
return true;
|
|
15163
|
+
if (typeof valP === 'string' && patt.test(valP.substr(0, 1)) && patt.test(valP.substr(0, valP.length - 1))) return true;
|
|
15291
15164
|
else return false;
|
|
15292
15165
|
};
|
|
15293
15166
|
func.expression.validate_variables = function (valP) {
|
|
15294
|
-
if (typeof valP ===
|
|
15167
|
+
if (typeof valP === 'string' && valP.indexOf('@') > -1) return true;
|
|
15295
15168
|
else return false;
|
|
15296
15169
|
};
|
|
15297
15170
|
func.expression.remove_quotes = function (valP) {
|
|
15298
|
-
if (func.expression.validate_constant(valP))
|
|
15299
|
-
return valP.substr(1, valP.length - 2);
|
|
15171
|
+
if (func.expression.validate_constant(valP)) return valP.substr(1, valP.length - 2);
|
|
15300
15172
|
else return valP;
|
|
15301
15173
|
};
|
|
15302
15174
|
|
|
15303
|
-
func.expression.secure_eval = async function (
|
|
15304
|
-
SESSION_ID,
|
|
15305
|
-
|
|
15306
|
-
|
|
15307
|
-
|
|
15308
|
-
dsSessionP,
|
|
15309
|
-
js_script_callback
|
|
15310
|
-
) {
|
|
15311
|
-
const api_utils = await func.common.get_module(
|
|
15175
|
+
func.expression.secure_eval = async function (SESSION_ID, sourceP, val, job_id, dsSessionP, js_script_callback, evt) {
|
|
15176
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
15177
|
+
func,
|
|
15178
|
+
glb,
|
|
15179
|
+
SESSION_OBJ,
|
|
15312
15180
|
SESSION_ID,
|
|
15313
|
-
|
|
15314
|
-
|
|
15315
|
-
|
|
15316
|
-
|
|
15317
|
-
SESSION_OBJ,
|
|
15318
|
-
SESSION_ID,
|
|
15319
|
-
APP_OBJ,
|
|
15320
|
-
dsSession: dsSessionP,
|
|
15321
|
-
job_id,
|
|
15322
|
-
}
|
|
15323
|
-
);
|
|
15181
|
+
APP_OBJ,
|
|
15182
|
+
dsSession: dsSessionP,
|
|
15183
|
+
job_id,
|
|
15184
|
+
});
|
|
15324
15185
|
|
|
15325
15186
|
const xu = api_utils;
|
|
15326
15187
|
|
|
15327
|
-
if (
|
|
15328
|
-
typeof IS_PROCESS_SERVER === "undefined" &&
|
|
15329
|
-
typeof IS_DOCKER === "undefined"
|
|
15330
|
-
) {
|
|
15188
|
+
if (typeof IS_PROCESS_SERVER === 'undefined' && typeof IS_DOCKER === 'undefined') {
|
|
15331
15189
|
try {
|
|
15332
15190
|
return eval(val);
|
|
15333
15191
|
} catch (err) {
|
|
@@ -15340,39 +15198,19 @@ func.expression.secure_eval = async function (
|
|
|
15340
15198
|
}
|
|
15341
15199
|
}
|
|
15342
15200
|
// server side execution
|
|
15343
|
-
if (sourceP ===
|
|
15344
|
-
process.on(
|
|
15345
|
-
console.error(
|
|
15201
|
+
if (sourceP === 'javascript') {
|
|
15202
|
+
process.on('uncaughtException', (err) => {
|
|
15203
|
+
console.error('Asynchronous error caught.', err);
|
|
15346
15204
|
|
|
15347
15205
|
func.events.delete_job(SESSION_ID, job_id);
|
|
15348
|
-
if (
|
|
15349
|
-
typeof IS_PROCESS_SERVER !== "undefined" ||
|
|
15350
|
-
typeof IS_DOCKER !== "undefined"
|
|
15351
|
-
) {
|
|
15206
|
+
if (typeof IS_PROCESS_SERVER !== 'undefined' || typeof IS_DOCKER !== 'undefined') {
|
|
15352
15207
|
if (SESSION_OBJ[SESSION_ID].crawler) return;
|
|
15353
|
-
return __.rpi.write_log(
|
|
15354
|
-
SESSION_OBJ[SESSION_ID].app_id,
|
|
15355
|
-
"error",
|
|
15356
|
-
"worker",
|
|
15357
|
-
"vm error",
|
|
15358
|
-
err,
|
|
15359
|
-
null,
|
|
15360
|
-
val,
|
|
15361
|
-
"func.expression.get.secure_eval"
|
|
15362
|
-
);
|
|
15208
|
+
return __.rpi.write_log(SESSION_OBJ[SESSION_ID].app_id, 'error', 'worker', 'vm error', err, null, val, 'func.expression.get.secure_eval');
|
|
15363
15209
|
}
|
|
15364
15210
|
});
|
|
15365
15211
|
try {
|
|
15366
|
-
const dir = path.join(
|
|
15367
|
-
|
|
15368
|
-
SESSION_OBJ[SESSION_ID].app_id,
|
|
15369
|
-
"node_modules",
|
|
15370
|
-
"/"
|
|
15371
|
-
);
|
|
15372
|
-
const script = new VM.VMScript(
|
|
15373
|
-
`try{${val}}catch(e){func.api.error(SESSION_ID, "nodejs error", e); console.error(e); func.events.delete_job(SESSION_ID, job_id);}`,
|
|
15374
|
-
{ filename: dir, dirname: dir }
|
|
15375
|
-
);
|
|
15212
|
+
const dir = path.join(_conf.studio_drive_path, SESSION_OBJ[SESSION_ID].app_id, 'node_modules', '/');
|
|
15213
|
+
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 });
|
|
15376
15214
|
let vm = new VM.NodeVM({
|
|
15377
15215
|
require: {
|
|
15378
15216
|
external: true,
|
|
@@ -15395,11 +15233,11 @@ func.expression.secure_eval = async function (
|
|
|
15395
15233
|
dirname: dir,
|
|
15396
15234
|
});
|
|
15397
15235
|
} catch (err) {
|
|
15398
|
-
console.error(
|
|
15236
|
+
console.error('Failed to execute script.', err);
|
|
15399
15237
|
|
|
15400
|
-
if (typeof IS_PROCESS_SERVER !==
|
|
15238
|
+
if (typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
15401
15239
|
func.events.delete_job(SESSION_ID, jobNo);
|
|
15402
|
-
return __.db.add_error_log(SESSION_OBJ[SESSION_ID].app_id,
|
|
15240
|
+
return __.db.add_error_log(SESSION_OBJ[SESSION_ID].app_id, 'api', err);
|
|
15403
15241
|
}
|
|
15404
15242
|
}
|
|
15405
15243
|
} else {
|
|
@@ -15418,12 +15256,12 @@ func.expression.secure_eval = async function (
|
|
|
15418
15256
|
allowAsync: false,
|
|
15419
15257
|
});
|
|
15420
15258
|
let ret = val;
|
|
15421
|
-
if (typeof val ===
|
|
15259
|
+
if (typeof val === 'string') {
|
|
15422
15260
|
ret = await vm.run(val);
|
|
15423
15261
|
}
|
|
15424
15262
|
return ret;
|
|
15425
15263
|
} catch (err) {
|
|
15426
|
-
throw
|
|
15264
|
+
throw '';
|
|
15427
15265
|
}
|
|
15428
15266
|
} catch (err) {
|
|
15429
15267
|
try {
|