@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
package/js/xuda-runtime-slim.js
CHANGED
|
@@ -10065,6 +10065,10 @@ func.events.execute = async function (
|
|
|
10065
10065
|
`(async function(el,evt) {
|
|
10066
10066
|
${refIdP.value}
|
|
10067
10067
|
})(document.querySelector(\`[xu-ui-id=${elementP}]\`),evt)`,
|
|
10068
|
+
null,
|
|
10069
|
+
null,
|
|
10070
|
+
null,
|
|
10071
|
+
evt,
|
|
10068
10072
|
);
|
|
10069
10073
|
await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
|
|
10070
10074
|
|
|
@@ -10081,6 +10085,9 @@ func.events.execute = async function (
|
|
|
10081
10085
|
${refIdP.value}
|
|
10082
10086
|
})(document.querySelector(\`[xu-ui-id=${elementP}]\`),evt)`,
|
|
10083
10087
|
true,
|
|
10088
|
+
null,
|
|
10089
|
+
null,
|
|
10090
|
+
evt,
|
|
10084
10091
|
);
|
|
10085
10092
|
await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
|
|
10086
10093
|
|
|
@@ -10621,22 +10628,7 @@ func.events.invoke = async function (event_id) {
|
|
|
10621
10628
|
};
|
|
10622
10629
|
func.expression = {};
|
|
10623
10630
|
|
|
10624
|
-
func.expression.get = async function (
|
|
10625
|
-
SESSION_ID,
|
|
10626
|
-
valP,
|
|
10627
|
-
dsSessionP,
|
|
10628
|
-
sourceP,
|
|
10629
|
-
rowIdP,
|
|
10630
|
-
sourceActionP,
|
|
10631
|
-
secondPassP,
|
|
10632
|
-
calling_fieldIdP,
|
|
10633
|
-
fieldsP,
|
|
10634
|
-
debug_infoP,
|
|
10635
|
-
iterate_info,
|
|
10636
|
-
js_script_callback,
|
|
10637
|
-
jobNo,
|
|
10638
|
-
api_output_type
|
|
10639
|
-
) {
|
|
10631
|
+
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) {
|
|
10640
10632
|
class xu_class {
|
|
10641
10633
|
async get() {
|
|
10642
10634
|
var ret;
|
|
@@ -10645,23 +10637,23 @@ func.expression.get = async function (
|
|
|
10645
10637
|
var warning;
|
|
10646
10638
|
|
|
10647
10639
|
function evalJson(text) {
|
|
10648
|
-
return eval(
|
|
10640
|
+
return eval('(' + text + ')');
|
|
10649
10641
|
}
|
|
10650
10642
|
|
|
10651
10643
|
if (valP === null) {
|
|
10652
|
-
ret =
|
|
10644
|
+
ret = '';
|
|
10653
10645
|
} else {
|
|
10654
10646
|
switch (typeof valP) {
|
|
10655
|
-
case
|
|
10647
|
+
case 'string':
|
|
10656
10648
|
ret = valP;
|
|
10657
10649
|
break;
|
|
10658
10650
|
|
|
10659
|
-
case
|
|
10660
|
-
ret =
|
|
10651
|
+
case 'undefined':
|
|
10652
|
+
ret = '';
|
|
10661
10653
|
break;
|
|
10662
10654
|
|
|
10663
|
-
case
|
|
10664
|
-
ret = valP ?
|
|
10655
|
+
case 'boolean':
|
|
10656
|
+
ret = valP ? 'Y' : 'N';
|
|
10665
10657
|
break;
|
|
10666
10658
|
|
|
10667
10659
|
default:
|
|
@@ -10670,40 +10662,35 @@ func.expression.get = async function (
|
|
|
10670
10662
|
}
|
|
10671
10663
|
}
|
|
10672
10664
|
|
|
10673
|
-
ret = ret.replace(/\&/g,
|
|
10665
|
+
ret = ret.replace(/\&/g, '&');
|
|
10674
10666
|
ret = func.utils.replace_studio_drive_url(SESSION_ID, ret);
|
|
10675
10667
|
|
|
10676
10668
|
const end_results = function () {
|
|
10677
10669
|
const replace_quotes = function (ret) {
|
|
10678
10670
|
for (const [key, val] of Object.entries(fields)) {
|
|
10679
|
-
if (typeof val ===
|
|
10680
|
-
ret = ret.replace('"' + val + '"', val.replace(/"/gi, ""));
|
|
10671
|
+
if (typeof val === 'string') ret = ret.replace('"' + val + '"', val.replace(/"/gi, ''));
|
|
10681
10672
|
}
|
|
10682
10673
|
return ret;
|
|
10683
10674
|
};
|
|
10684
|
-
if ([
|
|
10685
|
-
if (typeof ret ===
|
|
10675
|
+
if (['update', 'javascript'].includes(sourceP)) {
|
|
10676
|
+
if (typeof ret === 'string') ret = replace_quotes(ret);
|
|
10686
10677
|
}
|
|
10687
10678
|
const log_error = function () {
|
|
10688
10679
|
if (SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP]) {
|
|
10689
|
-
func.utils.debug.log(
|
|
10690
|
-
|
|
10691
|
-
|
|
10692
|
-
|
|
10693
|
-
|
|
10694
|
-
|
|
10695
|
-
|
|
10696
|
-
|
|
10697
|
-
|
|
10698
|
-
|
|
10699
|
-
|
|
10700
|
-
|
|
10701
|
-
|
|
10702
|
-
|
|
10703
|
-
prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
10704
|
-
debug_info: debug_infoP,
|
|
10705
|
-
}
|
|
10706
|
-
);
|
|
10680
|
+
func.utils.debug.log(SESSION_ID, SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].nodeId, {
|
|
10681
|
+
module: 'expression',
|
|
10682
|
+
action: sourceP,
|
|
10683
|
+
source: calling_fieldIdP,
|
|
10684
|
+
prop: ret,
|
|
10685
|
+
details: ret,
|
|
10686
|
+
result: ret,
|
|
10687
|
+
error: error,
|
|
10688
|
+
warning: warning,
|
|
10689
|
+
fields: null,
|
|
10690
|
+
type: 'exp',
|
|
10691
|
+
prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
10692
|
+
debug_info: debug_infoP,
|
|
10693
|
+
});
|
|
10707
10694
|
}
|
|
10708
10695
|
};
|
|
10709
10696
|
if (error) log_error();
|
|
@@ -10721,32 +10708,22 @@ func.expression.get = async function (
|
|
|
10721
10708
|
};
|
|
10722
10709
|
const variable_not_exist = async function () {
|
|
10723
10710
|
try {
|
|
10724
|
-
if (sourceP !==
|
|
10725
|
-
if (ret && ret.substr(0, 6) ===
|
|
10711
|
+
if (sourceP !== 'arguments') {
|
|
10712
|
+
if (ret && ret.substr(0, 6) === '_DATE_') {
|
|
10726
10713
|
ret = ret.substr(6);
|
|
10727
10714
|
} else if (
|
|
10728
|
-
(ret &&
|
|
10729
|
-
|
|
10730
|
-
ret.substr(4, 1) === "-" &&
|
|
10731
|
-
ret.substr(7, 1) === "-") ||
|
|
10732
|
-
ret === "self" // bypass eval for date 2017-03-22
|
|
10715
|
+
(ret && ret.length === 10 && ret.substr(4, 1) === '-' && ret.substr(7, 1) === '-') ||
|
|
10716
|
+
ret === 'self' // bypass eval for date 2017-03-22
|
|
10733
10717
|
) {
|
|
10734
10718
|
ret = ret;
|
|
10735
10719
|
} else {
|
|
10736
|
-
ret = await func.expression.secure_eval(
|
|
10737
|
-
SESSION_ID,
|
|
10738
|
-
sourceP,
|
|
10739
|
-
ret,
|
|
10740
|
-
jobNo,
|
|
10741
|
-
dsSessionP,
|
|
10742
|
-
js_script_callback
|
|
10743
|
-
);
|
|
10720
|
+
ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
10744
10721
|
}
|
|
10745
10722
|
// console.log("AFTER OK", ret)
|
|
10746
10723
|
return end_results();
|
|
10747
10724
|
} else {
|
|
10748
10725
|
// do eval for arithmetic vals
|
|
10749
|
-
ret = ret.replace(/_NULL/gi,
|
|
10726
|
+
ret = ret.replace(/_NULL/gi, '');
|
|
10750
10727
|
return end_results();
|
|
10751
10728
|
}
|
|
10752
10729
|
} catch (err) {
|
|
@@ -10759,14 +10736,7 @@ func.expression.get = async function (
|
|
|
10759
10736
|
}
|
|
10760
10737
|
|
|
10761
10738
|
const validate_email = async function () {
|
|
10762
|
-
const ret = await func.expression.secure_eval(
|
|
10763
|
-
SESSION_ID,
|
|
10764
|
-
sourceP,
|
|
10765
|
-
valP,
|
|
10766
|
-
jobNo,
|
|
10767
|
-
dsSessionP,
|
|
10768
|
-
js_script_callback
|
|
10769
|
-
);
|
|
10739
|
+
const ret = await func.expression.secure_eval(SESSION_ID, sourceP, valP, jobNo, dsSessionP, js_script_callback);
|
|
10770
10740
|
|
|
10771
10741
|
return glb.emailRegex.test(ret);
|
|
10772
10742
|
};
|
|
@@ -10785,10 +10755,7 @@ func.expression.get = async function (
|
|
|
10785
10755
|
var_Arr[key].value = val.value;
|
|
10786
10756
|
//--------------
|
|
10787
10757
|
const replace_value_in_string = async function (retP, fieldIdP) {
|
|
10788
|
-
if (
|
|
10789
|
-
iterate_info?.iterator_key === fieldIdP ||
|
|
10790
|
-
iterate_info?.iterator_val === fieldIdP
|
|
10791
|
-
) {
|
|
10758
|
+
if (iterate_info?.iterator_key === fieldIdP || iterate_info?.iterator_val === fieldIdP) {
|
|
10792
10759
|
if (iterate_info.iterator_key === fieldIdP) {
|
|
10793
10760
|
retP.value = iterate_info._key;
|
|
10794
10761
|
}
|
|
@@ -10798,50 +10765,43 @@ func.expression.get = async function (
|
|
|
10798
10765
|
}
|
|
10799
10766
|
|
|
10800
10767
|
const set_value = function (valP) {
|
|
10801
|
-
if (typeof valP !==
|
|
10768
|
+
if (typeof valP !== 'undefined') {
|
|
10802
10769
|
var_Arr[key].value = valP;
|
|
10803
|
-
if (typeof valP ===
|
|
10770
|
+
if (typeof valP === 'string') var_Arr[key].type = 'string';
|
|
10804
10771
|
} else {
|
|
10805
|
-
if (retP.type ===
|
|
10806
|
-
var_Arr[key].value =
|
|
10807
|
-
var_Arr[key].type =
|
|
10772
|
+
if (retP.type === 'object') {
|
|
10773
|
+
var_Arr[key].value = '';
|
|
10774
|
+
var_Arr[key].type = 'string';
|
|
10808
10775
|
}
|
|
10809
10776
|
}
|
|
10810
10777
|
};
|
|
10811
10778
|
|
|
10812
|
-
if (sourceP ===
|
|
10779
|
+
if (sourceP === 'exp' && retP.type !== 'exp') {
|
|
10813
10780
|
var_Arr[key].type = retP.type;
|
|
10814
10781
|
return;
|
|
10815
10782
|
}
|
|
10816
|
-
if (typeof retP.value !==
|
|
10783
|
+
if (typeof retP.value !== 'undefined') {
|
|
10817
10784
|
var_Arr[key].type = retP.type;
|
|
10818
10785
|
var_Arr[key].value = retP.value;
|
|
10819
|
-
if ((val.value.indexOf(
|
|
10786
|
+
if ((val.value.indexOf('[') > -1) | (val.value.indexOf('.') > -1)) {
|
|
10820
10787
|
//get values from array '@var==="sss" && @var_B==="sss" && @obj.property===5 && @objA["value"]===123 | @objB["value"].property===1234'
|
|
10821
10788
|
var data = retP.prop;
|
|
10822
|
-
if (retP.type ===
|
|
10789
|
+
if (retP.type === 'object') data = retP.value;
|
|
10823
10790
|
var property1, property2;
|
|
10824
10791
|
//check for split situation: @objB[@var].property 1: @objB[ 2:@var].property
|
|
10825
|
-
if (
|
|
10826
|
-
val.value.indexOf("[") === -1 &&
|
|
10827
|
-
val.value.indexOf("]") > -1 &&
|
|
10828
|
-
val.value.substr(0, 1) === "@"
|
|
10829
|
-
) {
|
|
10792
|
+
if (val.value.indexOf('[') === -1 && val.value.indexOf(']') > -1 && val.value.substr(0, 1) === '@') {
|
|
10830
10793
|
//check situation 2
|
|
10831
10794
|
var prevData = var_Arr[key - 1].value;
|
|
10832
10795
|
var_Arr[key].value = prevData[data]; // @objB[@var]
|
|
10833
|
-
if (val.value.indexOf(
|
|
10834
|
-
property2 = await func.expression.get_property(val.value)
|
|
10835
|
-
.property2; //val.value.substr(val.value.indexOf(".") + 1, val.value.length); // get .
|
|
10796
|
+
if (val.value.indexOf('.') > -1) {
|
|
10797
|
+
property2 = await func.expression.get_property(val.value).property2; //val.value.substr(val.value.indexOf(".") + 1, val.value.length); // get .
|
|
10836
10798
|
if (prevData[data]) set_value(prevData[data][property2]);
|
|
10837
10799
|
// var_Arr[key].value = prevData[data][property2]; //@objB[@var].property
|
|
10838
10800
|
}
|
|
10839
10801
|
delete var_Arr[key - 1];
|
|
10840
10802
|
} else {
|
|
10841
|
-
property1 = await func.expression.get_property(val.value)
|
|
10842
|
-
|
|
10843
|
-
property2 = await func.expression.get_property(val.value)
|
|
10844
|
-
.property2;
|
|
10803
|
+
property1 = await func.expression.get_property(val.value).property1;
|
|
10804
|
+
property2 = await func.expression.get_property(val.value).property2;
|
|
10845
10805
|
if (property1) {
|
|
10846
10806
|
var_Arr[key].value = data[property1]; // @var["value"] or @var.property
|
|
10847
10807
|
if (property2) {
|
|
@@ -10869,19 +10829,11 @@ func.expression.get = async function (
|
|
|
10869
10829
|
//>>>>>>>>>>>>>>>>>>
|
|
10870
10830
|
if (val.fieldId) {
|
|
10871
10831
|
// @_THIS
|
|
10872
|
-
if (
|
|
10873
|
-
val.fieldId &&
|
|
10874
|
-
val.fieldId.substr(0, 5) === "_THIS" &&
|
|
10875
|
-
calling_fieldIdP &&
|
|
10876
|
-
(val.fieldId.length === 5 ||
|
|
10877
|
-
(val.fieldId.length > 5 && val.fieldId.substr(5, 1) === "."))
|
|
10878
|
-
) {
|
|
10832
|
+
if (val.fieldId && val.fieldId.substr(0, 5) === '_THIS' && calling_fieldIdP && (val.fieldId.length === 5 || (val.fieldId.length > 5 && val.fieldId.substr(5, 1) === '.'))) {
|
|
10879
10833
|
if (val.fieldId.length === 5) val.fieldId = calling_fieldIdP;
|
|
10880
|
-
else
|
|
10881
|
-
val.fieldId =
|
|
10882
|
-
calling_fieldIdP + val.fieldId(5, val.fieldId.length - 1);
|
|
10834
|
+
else val.fieldId = calling_fieldIdP + val.fieldId(5, val.fieldId.length - 1);
|
|
10883
10835
|
}
|
|
10884
|
-
if (!sourceP ===
|
|
10836
|
+
if (!sourceP === 'exp') {
|
|
10885
10837
|
var_Arr[key].value = '""';
|
|
10886
10838
|
} // put default
|
|
10887
10839
|
fields[val.fieldId] = var_Arr[key].value;
|
|
@@ -10891,7 +10843,7 @@ func.expression.get = async function (
|
|
|
10891
10843
|
val.fieldId,
|
|
10892
10844
|
dsSessionP,
|
|
10893
10845
|
|
|
10894
|
-
rowIdP
|
|
10846
|
+
rowIdP,
|
|
10895
10847
|
); // find field in dataSources
|
|
10896
10848
|
|
|
10897
10849
|
await replace_value_in_string(ret.ret, ret.fieldIdP);
|
|
@@ -10904,7 +10856,7 @@ func.expression.get = async function (
|
|
|
10904
10856
|
var var_error_found;
|
|
10905
10857
|
// merge arr values
|
|
10906
10858
|
_.forEach(var_Arr, function (val, key) {
|
|
10907
|
-
if (sourceP ===
|
|
10859
|
+
if (sourceP === 'UI Property EXP') {
|
|
10908
10860
|
let ret = func.utils.get_drive_url(SESSION_ID, val.value, true);
|
|
10909
10861
|
if (ret.changed) {
|
|
10910
10862
|
res[key] = ret.value;
|
|
@@ -10912,108 +10864,72 @@ func.expression.get = async function (
|
|
|
10912
10864
|
}
|
|
10913
10865
|
}
|
|
10914
10866
|
|
|
10915
|
-
if (sourceP ===
|
|
10916
|
-
let ret = func.utils.get_drive_url(
|
|
10917
|
-
SESSION_ID,
|
|
10918
|
-
val.value,
|
|
10919
|
-
var_Arr.length == 1 ? false : true
|
|
10920
|
-
);
|
|
10867
|
+
if (sourceP === 'UI Attr EXP') {
|
|
10868
|
+
let ret = func.utils.get_drive_url(SESSION_ID, val.value, var_Arr.length == 1 ? false : true);
|
|
10921
10869
|
if (ret.changed) {
|
|
10922
10870
|
res[key] = ret.value;
|
|
10923
10871
|
return true;
|
|
10924
10872
|
}
|
|
10925
10873
|
}
|
|
10926
10874
|
|
|
10927
|
-
if (val.type ===
|
|
10875
|
+
if (val.type === 'exp') {
|
|
10928
10876
|
exp_exist = true;
|
|
10929
10877
|
}
|
|
10930
10878
|
res[key] = val.value;
|
|
10931
10879
|
|
|
10932
|
-
if (var_Arr.length > 1) {
|
|
10933
|
-
|
|
10934
|
-
|
|
10935
|
-
|
|
10936
|
-
) &&
|
|
10937
|
-
["string", "date"].includes(val.type)
|
|
10938
|
-
) {
|
|
10939
|
-
res[key] = "`" + val.value + "`";
|
|
10880
|
+
if (var_Arr.length > 1) {
|
|
10881
|
+
// complex input
|
|
10882
|
+
if (!['DbQuery', 'alert', 'exp', 'api_rendered_output'].includes(sourceP) && ['string', 'date'].includes(val.type)) {
|
|
10883
|
+
res[key] = '`' + val.value + '`';
|
|
10940
10884
|
}
|
|
10941
10885
|
// new Dec 18 2024 for Ishai // json,html,xml,text,css
|
|
10942
|
-
if (
|
|
10943
|
-
["api_rendered_output"].includes(sourceP) && ["json"].includes(api_output_type) &&
|
|
10944
|
-
["string", "date"].includes(val.type)
|
|
10945
|
-
) {
|
|
10886
|
+
if (['api_rendered_output'].includes(sourceP) && ['json'].includes(api_output_type) && ['string', 'date'].includes(val.type)) {
|
|
10946
10887
|
res[key] = `"` + val.value + `"`;
|
|
10947
10888
|
}
|
|
10948
10889
|
}
|
|
10949
|
-
if (val.fieldId && val.value && typeof val.value ===
|
|
10950
|
-
if (
|
|
10951
|
-
|
|
10952
|
-
|
|
10953
|
-
)
|
|
10954
|
-
) {
|
|
10955
|
-
if (val.value.indexOf("↵") > -1) {
|
|
10956
|
-
res[key] = val.value.split("↵").join("");
|
|
10890
|
+
if (val.fieldId && val.value && typeof val.value === 'string') {
|
|
10891
|
+
if (['query', 'condition', 'range', 'sort', 'locate'].includes(sourceP)) {
|
|
10892
|
+
if (val.value.indexOf('↵') > -1) {
|
|
10893
|
+
res[key] = val.value.split('↵').join('');
|
|
10957
10894
|
}
|
|
10958
|
-
res[key] = res[key].replace(/(\r\n|\n|\r)/gm,
|
|
10895
|
+
res[key] = res[key].replace(/(\r\n|\n|\r)/gm, ''); //.replace(/"/g,'\"');//.replace(/'/g,"");
|
|
10959
10896
|
}
|
|
10960
10897
|
|
|
10961
|
-
if ([
|
|
10962
|
-
if (val.value.indexOf(
|
|
10963
|
-
|
|
10964
|
-
res[key] = res[key].replace(/(\r\n|\n|\r)/gm, "\\n");
|
|
10898
|
+
if (['init', 'update', 'virtual'].includes(sourceP)) {
|
|
10899
|
+
if (val.value.indexOf('↵') > -1) res[key] = val.value.split('↵').join('\n');
|
|
10900
|
+
res[key] = res[key].replace(/(\r\n|\n|\r)/gm, '\\n');
|
|
10965
10901
|
}
|
|
10966
10902
|
|
|
10967
|
-
if (typeof IS_PROCESS_SERVER !==
|
|
10968
|
-
res[key] = res[key].replace(/(\r\n|\n|\r)/gm,
|
|
10903
|
+
if (typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
10904
|
+
res[key] = res[key].replace(/(\r\n|\n|\r)/gm, '<br>');
|
|
10969
10905
|
}
|
|
10970
10906
|
|
|
10971
10907
|
fields[val.fieldId] = res[key];
|
|
10972
10908
|
}
|
|
10973
10909
|
// extract object
|
|
10974
|
-
if (typeof val.value ===
|
|
10975
|
-
if (
|
|
10976
|
-
!Array.isArray(val.value) &&
|
|
10977
|
-
!var_Arr[key + 1].value?.includes(".")
|
|
10978
|
-
) {
|
|
10910
|
+
if (typeof val.value === 'object' && var_Arr.length > 1) {
|
|
10911
|
+
if (!Array.isArray(val.value) && !var_Arr[key + 1].value?.includes('.')) {
|
|
10979
10912
|
// && !["api_rendered_output"].includes(sourceP)
|
|
10980
10913
|
|
|
10981
10914
|
// prevent cast on single value expression
|
|
10982
|
-
res[key] =
|
|
10915
|
+
res[key] = '(' + JSON.stringify(val.value) + ')';
|
|
10983
10916
|
} else {
|
|
10984
10917
|
res[key] = JSON.stringify(val.value);
|
|
10985
10918
|
}
|
|
10986
10919
|
}
|
|
10987
10920
|
|
|
10988
|
-
if (
|
|
10989
|
-
|
|
10990
|
-
sourceP !== "exp" &&
|
|
10991
|
-
val.value &&
|
|
10992
|
-
typeof val.value === "string" &&
|
|
10993
|
-
val.value.substr(0, 1) === "@"
|
|
10994
|
-
) {
|
|
10995
|
-
warning = "Error encoding " + val.value;
|
|
10921
|
+
if (!exp_exist && sourceP !== 'exp' && val.value && typeof val.value === 'string' && val.value.substr(0, 1) === '@') {
|
|
10922
|
+
warning = 'Error encoding ' + val.value;
|
|
10996
10923
|
var_error_found = true;
|
|
10997
10924
|
res[key] = 0;
|
|
10998
10925
|
}
|
|
10999
10926
|
});
|
|
11000
10927
|
var join = function (arrP) {
|
|
11001
|
-
return arrP.join(
|
|
10928
|
+
return arrP.join('');
|
|
11002
10929
|
};
|
|
11003
10930
|
var exp = undefined;
|
|
11004
|
-
if (exp_exist && sourceP !==
|
|
11005
|
-
exp = await func.expression.get(
|
|
11006
|
-
SESSION_ID,
|
|
11007
|
-
join(res),
|
|
11008
|
-
dsSessionP,
|
|
11009
|
-
sourceP,
|
|
11010
|
-
rowIdP,
|
|
11011
|
-
sourceActionP,
|
|
11012
|
-
true,
|
|
11013
|
-
calling_fieldIdP,
|
|
11014
|
-
fields,
|
|
11015
|
-
debug_infoP
|
|
11016
|
-
);
|
|
10931
|
+
if (exp_exist && sourceP !== 'exp') {
|
|
10932
|
+
exp = await func.expression.get(SESSION_ID, join(res), dsSessionP, sourceP, rowIdP, sourceActionP, true, calling_fieldIdP, fields, debug_infoP);
|
|
11017
10933
|
if (exp.res) res = exp.res;
|
|
11018
10934
|
// do second pass when exp exist
|
|
11019
10935
|
else res = [exp.result];
|
|
@@ -11028,39 +10944,28 @@ func.expression.get = async function (
|
|
|
11028
10944
|
|
|
11029
10945
|
if (secondPassP) {
|
|
11030
10946
|
ret = result;
|
|
11031
|
-
} else if (sourceP !==
|
|
10947
|
+
} else if (sourceP !== 'exp') {
|
|
11032
10948
|
// no eval for second pass
|
|
11033
10949
|
// return single value
|
|
11034
|
-
if (
|
|
11035
|
-
res.length === 1 &&
|
|
11036
|
-
typeof res[0] === "string" &&
|
|
11037
|
-
typeof res[0] !== "object"
|
|
11038
|
-
) {
|
|
10950
|
+
if (res.length === 1 && typeof res[0] === 'string' && typeof res[0] !== 'object') {
|
|
11039
10951
|
// avoid eval when query leading zeros problem
|
|
11040
10952
|
ret = join(res);
|
|
11041
|
-
if (ret && ret.substr(0, 1) ===
|
|
11042
|
-
error =
|
|
10953
|
+
if (ret && ret.substr(0, 1) === '@') {
|
|
10954
|
+
error = 'Error encoding @ var';
|
|
11043
10955
|
var_error_found = true;
|
|
11044
10956
|
}
|
|
11045
10957
|
} else {
|
|
11046
10958
|
if (
|
|
11047
10959
|
![
|
|
11048
|
-
|
|
10960
|
+
'arguments',
|
|
11049
10961
|
// "alert",
|
|
11050
|
-
|
|
11051
|
-
|
|
10962
|
+
'api_rendered_output',
|
|
10963
|
+
'DbQuery',
|
|
11052
10964
|
].includes(sourceP)
|
|
11053
10965
|
) {
|
|
11054
|
-
ret = await func.expression.secure_eval(
|
|
11055
|
-
SESSION_ID,
|
|
11056
|
-
sourceP,
|
|
11057
|
-
result,
|
|
11058
|
-
jobNo,
|
|
11059
|
-
dsSessionP,
|
|
11060
|
-
js_script_callback
|
|
11061
|
-
);
|
|
10966
|
+
ret = await func.expression.secure_eval(SESSION_ID, sourceP, result, jobNo, dsSessionP, js_script_callback);
|
|
11062
10967
|
} else {
|
|
11063
|
-
if (sourceP ===
|
|
10968
|
+
if (sourceP === 'DbQuery') {
|
|
11064
10969
|
ret = JSON.stringify(evalJson(result));
|
|
11065
10970
|
} else {
|
|
11066
10971
|
// try eval
|
|
@@ -11089,12 +10994,7 @@ func.expression.parse = function (strP) {
|
|
|
11089
10994
|
if (!posP) posP = 0;
|
|
11090
10995
|
var clean_split_str = function (arrP) {
|
|
11091
10996
|
var arr = [];
|
|
11092
|
-
if (
|
|
11093
|
-
arrP &&
|
|
11094
|
-
arrP.length > 1 &&
|
|
11095
|
-
arrP[0] === "" &&
|
|
11096
|
-
arrP[1].indexOf("@") > -1
|
|
11097
|
-
) {
|
|
10997
|
+
if (arrP && arrP.length > 1 && arrP[0] === '' && arrP[1].indexOf('@') > -1) {
|
|
11098
10998
|
for (var i = 1; i <= arrP.length; i++) {
|
|
11099
10999
|
arr.push(arrP[i]);
|
|
11100
11000
|
}
|
|
@@ -11105,7 +11005,7 @@ func.expression.parse = function (strP) {
|
|
|
11105
11005
|
var validSymbolsNoArray = /[^.@\[]/; //valid symbols no array /[^.@\[\]\]]/
|
|
11106
11006
|
var validSymbolsWithArray = /[^.@"'\[\]]/; //valid symbols with array
|
|
11107
11007
|
var validSymbols = validSymbolsNoArray;
|
|
11108
|
-
var splitTmp = strP.replace(/@/g,
|
|
11008
|
+
var splitTmp = strP.replace(/@/g, '^^@').split('^^');
|
|
11109
11009
|
var split = clean_split_str(splitTmp);
|
|
11110
11010
|
var obj = [];
|
|
11111
11011
|
if (split) {
|
|
@@ -11113,8 +11013,8 @@ func.expression.parse = function (strP) {
|
|
|
11113
11013
|
// run on @ segments
|
|
11114
11014
|
if (val) {
|
|
11115
11015
|
var pos = strP.indexOf(val);
|
|
11116
|
-
if (val && val.substr(0, 1) ===
|
|
11117
|
-
var tmpStr =
|
|
11016
|
+
if (val && val.substr(0, 1) === '@') {
|
|
11017
|
+
var tmpStr = '';
|
|
11118
11018
|
var word_start_pos = undefined;
|
|
11119
11019
|
var word_end_pos = undefined;
|
|
11120
11020
|
// run on @ segment string
|
|
@@ -11122,7 +11022,7 @@ func.expression.parse = function (strP) {
|
|
|
11122
11022
|
var key1 = i;
|
|
11123
11023
|
var val1 = val.substr(i, 1);
|
|
11124
11024
|
if (
|
|
11125
|
-
val1 ===
|
|
11025
|
+
val1 === '.' &&
|
|
11126
11026
|
!word_start_pos // find first dot
|
|
11127
11027
|
)
|
|
11128
11028
|
word_start_pos = key1;
|
|
@@ -11132,40 +11032,24 @@ func.expression.parse = function (strP) {
|
|
|
11132
11032
|
nonLettersPatt.test(val1) // find any sign character to mark the end of word
|
|
11133
11033
|
)
|
|
11134
11034
|
word_end_pos = key1;
|
|
11135
|
-
if (
|
|
11136
|
-
word_start_pos &&
|
|
11137
|
-
word_start_pos >= 0 &&
|
|
11138
|
-
word_end_pos &&
|
|
11139
|
-
word_end_pos >= 0
|
|
11140
|
-
) {
|
|
11035
|
+
if (word_start_pos && word_start_pos >= 0 && word_end_pos && word_end_pos >= 0) {
|
|
11141
11036
|
// find the word
|
|
11142
|
-
var word = val.substr(
|
|
11143
|
-
word_start_pos + 1,
|
|
11144
|
-
word_end_pos - word_start_pos - 1
|
|
11145
|
-
); // get the word
|
|
11037
|
+
var word = val.substr(word_start_pos + 1, word_end_pos - word_start_pos - 1); // get the word
|
|
11146
11038
|
// if (glb.ALL_PROPERTIES_ARR.indexOf(word) === -1) {
|
|
11147
11039
|
// compare with internal properties
|
|
11148
|
-
tmpStr =
|
|
11149
|
-
tmpStr.substr(0, word_start_pos) +
|
|
11150
|
-
"^^" +
|
|
11151
|
-
tmpStr.substr(word_start_pos, word_end_pos);
|
|
11040
|
+
tmpStr = tmpStr.substr(0, word_start_pos) + '^^' + tmpStr.substr(word_start_pos, word_end_pos);
|
|
11152
11041
|
// }
|
|
11153
|
-
if (val.substr(word_end_pos, 1) ===
|
|
11154
|
-
word_start_pos = word_end_pos;
|
|
11042
|
+
if (val.substr(word_end_pos, 1) === '.') word_start_pos = word_end_pos;
|
|
11155
11043
|
else word_start_pos = null;
|
|
11156
11044
|
word_end_pos = null;
|
|
11157
11045
|
}
|
|
11158
|
-
if (val1 ===
|
|
11159
|
-
if (
|
|
11160
|
-
|
|
11161
|
-
validSymbols.test(val1) &&
|
|
11162
|
-
tmpStr.indexOf("^^") === -1
|
|
11163
|
-
) {
|
|
11164
|
-
tmpStr += "^^" + val1;
|
|
11046
|
+
if (val1 === '[') validSymbols = validSymbolsWithArray;
|
|
11047
|
+
if (nonLettersPatt.test(val1) && validSymbols.test(val1) && tmpStr.indexOf('^^') === -1) {
|
|
11048
|
+
tmpStr += '^^' + val1;
|
|
11165
11049
|
} else tmpStr += val1;
|
|
11166
11050
|
}
|
|
11167
11051
|
// });
|
|
11168
|
-
if (tmpStr.indexOf(
|
|
11052
|
+
if (tmpStr.indexOf('^^') > -1) {
|
|
11169
11053
|
var obj1 = extract_str(tmpStr, pos);
|
|
11170
11054
|
obj = obj.concat(obj1);
|
|
11171
11055
|
} else {
|
|
@@ -11173,10 +11057,8 @@ func.expression.parse = function (strP) {
|
|
|
11173
11057
|
var fieldId = undefined;
|
|
11174
11058
|
if (val) {
|
|
11175
11059
|
fieldId = val.substr(1, val.length);
|
|
11176
|
-
if (val.indexOf(
|
|
11177
|
-
|
|
11178
|
-
if (val.indexOf("[") > -1)
|
|
11179
|
-
fieldId = val.substr(1, val.indexOf("[") - 1);
|
|
11060
|
+
if (val.indexOf('.') > -1) fieldId = val.substr(1, val.indexOf('.') - 1);
|
|
11061
|
+
if (val.indexOf('[') > -1) fieldId = val.substr(1, val.indexOf('[') - 1);
|
|
11180
11062
|
//
|
|
11181
11063
|
// if (val.indexOf("]") > -1)
|
|
11182
11064
|
// fieldId = val.substr(1, val.indexOf("]") - 1);
|
|
@@ -11204,7 +11086,7 @@ func.expression.parse = function (strP) {
|
|
|
11204
11086
|
|
|
11205
11087
|
func.expression.get_property = async function (valP) {
|
|
11206
11088
|
async function secure_eval(val) {
|
|
11207
|
-
if (typeof IS_PROCESS_SERVER ===
|
|
11089
|
+
if (typeof IS_PROCESS_SERVER === 'undefined') {
|
|
11208
11090
|
try {
|
|
11209
11091
|
return eval(val);
|
|
11210
11092
|
} catch (err) {
|
|
@@ -11225,20 +11107,16 @@ func.expression.get_property = async function (valP) {
|
|
|
11225
11107
|
});
|
|
11226
11108
|
return await vm.run(val);
|
|
11227
11109
|
} catch (err) {
|
|
11228
|
-
throw
|
|
11110
|
+
throw '';
|
|
11229
11111
|
}
|
|
11230
11112
|
}
|
|
11231
11113
|
|
|
11232
11114
|
var property1, property2;
|
|
11233
|
-
if (valP.indexOf(
|
|
11234
|
-
property1 = valP.substr(
|
|
11235
|
-
valP.indexOf("[") + 1,
|
|
11236
|
-
valP.indexOf("]") - valP.indexOf("[") - 1
|
|
11237
|
-
); // get []
|
|
11115
|
+
if (valP.indexOf('[') > -1 && valP.indexOf(']') > -1) {
|
|
11116
|
+
property1 = valP.substr(valP.indexOf('[') + 1, valP.indexOf(']') - valP.indexOf('[') - 1); // get []
|
|
11238
11117
|
property1 = await secure_eval(property1);
|
|
11239
11118
|
}
|
|
11240
|
-
if (valP.indexOf(
|
|
11241
|
-
property2 = valP.substr(valP.indexOf(".") + 1, valP.length); // get .
|
|
11119
|
+
if (valP.indexOf('.') > -1) property2 = valP.substr(valP.indexOf('.') + 1, valP.length); // get .
|
|
11242
11120
|
return {
|
|
11243
11121
|
property1: property1,
|
|
11244
11122
|
property2: property2,
|
|
@@ -11246,52 +11124,32 @@ func.expression.get_property = async function (valP) {
|
|
|
11246
11124
|
};
|
|
11247
11125
|
func.expression.validate_constant = function (valP) {
|
|
11248
11126
|
var patt = /["']/;
|
|
11249
|
-
if (
|
|
11250
|
-
typeof valP === "string" &&
|
|
11251
|
-
patt.test(valP.substr(0, 1)) &&
|
|
11252
|
-
patt.test(valP.substr(0, valP.length - 1))
|
|
11253
|
-
)
|
|
11254
|
-
return true;
|
|
11127
|
+
if (typeof valP === 'string' && patt.test(valP.substr(0, 1)) && patt.test(valP.substr(0, valP.length - 1))) return true;
|
|
11255
11128
|
else return false;
|
|
11256
11129
|
};
|
|
11257
11130
|
func.expression.validate_variables = function (valP) {
|
|
11258
|
-
if (typeof valP ===
|
|
11131
|
+
if (typeof valP === 'string' && valP.indexOf('@') > -1) return true;
|
|
11259
11132
|
else return false;
|
|
11260
11133
|
};
|
|
11261
11134
|
func.expression.remove_quotes = function (valP) {
|
|
11262
|
-
if (func.expression.validate_constant(valP))
|
|
11263
|
-
return valP.substr(1, valP.length - 2);
|
|
11135
|
+
if (func.expression.validate_constant(valP)) return valP.substr(1, valP.length - 2);
|
|
11264
11136
|
else return valP;
|
|
11265
11137
|
};
|
|
11266
11138
|
|
|
11267
|
-
func.expression.secure_eval = async function (
|
|
11268
|
-
SESSION_ID,
|
|
11269
|
-
|
|
11270
|
-
|
|
11271
|
-
|
|
11272
|
-
dsSessionP,
|
|
11273
|
-
js_script_callback
|
|
11274
|
-
) {
|
|
11275
|
-
const api_utils = await func.common.get_module(
|
|
11139
|
+
func.expression.secure_eval = async function (SESSION_ID, sourceP, val, job_id, dsSessionP, js_script_callback, evt) {
|
|
11140
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
11141
|
+
func,
|
|
11142
|
+
glb,
|
|
11143
|
+
SESSION_OBJ,
|
|
11276
11144
|
SESSION_ID,
|
|
11277
|
-
|
|
11278
|
-
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
SESSION_OBJ,
|
|
11282
|
-
SESSION_ID,
|
|
11283
|
-
APP_OBJ,
|
|
11284
|
-
dsSession: dsSessionP,
|
|
11285
|
-
job_id,
|
|
11286
|
-
}
|
|
11287
|
-
);
|
|
11145
|
+
APP_OBJ,
|
|
11146
|
+
dsSession: dsSessionP,
|
|
11147
|
+
job_id,
|
|
11148
|
+
});
|
|
11288
11149
|
|
|
11289
11150
|
const xu = api_utils;
|
|
11290
11151
|
|
|
11291
|
-
if (
|
|
11292
|
-
typeof IS_PROCESS_SERVER === "undefined" &&
|
|
11293
|
-
typeof IS_DOCKER === "undefined"
|
|
11294
|
-
) {
|
|
11152
|
+
if (typeof IS_PROCESS_SERVER === 'undefined' && typeof IS_DOCKER === 'undefined') {
|
|
11295
11153
|
try {
|
|
11296
11154
|
return eval(val);
|
|
11297
11155
|
} catch (err) {
|
|
@@ -11304,39 +11162,19 @@ func.expression.secure_eval = async function (
|
|
|
11304
11162
|
}
|
|
11305
11163
|
}
|
|
11306
11164
|
// server side execution
|
|
11307
|
-
if (sourceP ===
|
|
11308
|
-
process.on(
|
|
11309
|
-
console.error(
|
|
11165
|
+
if (sourceP === 'javascript') {
|
|
11166
|
+
process.on('uncaughtException', (err) => {
|
|
11167
|
+
console.error('Asynchronous error caught.', err);
|
|
11310
11168
|
|
|
11311
11169
|
func.events.delete_job(SESSION_ID, job_id);
|
|
11312
|
-
if (
|
|
11313
|
-
typeof IS_PROCESS_SERVER !== "undefined" ||
|
|
11314
|
-
typeof IS_DOCKER !== "undefined"
|
|
11315
|
-
) {
|
|
11170
|
+
if (typeof IS_PROCESS_SERVER !== 'undefined' || typeof IS_DOCKER !== 'undefined') {
|
|
11316
11171
|
if (SESSION_OBJ[SESSION_ID].crawler) return;
|
|
11317
|
-
return __.rpi.write_log(
|
|
11318
|
-
SESSION_OBJ[SESSION_ID].app_id,
|
|
11319
|
-
"error",
|
|
11320
|
-
"worker",
|
|
11321
|
-
"vm error",
|
|
11322
|
-
err,
|
|
11323
|
-
null,
|
|
11324
|
-
val,
|
|
11325
|
-
"func.expression.get.secure_eval"
|
|
11326
|
-
);
|
|
11172
|
+
return __.rpi.write_log(SESSION_OBJ[SESSION_ID].app_id, 'error', 'worker', 'vm error', err, null, val, 'func.expression.get.secure_eval');
|
|
11327
11173
|
}
|
|
11328
11174
|
});
|
|
11329
11175
|
try {
|
|
11330
|
-
const dir = path.join(
|
|
11331
|
-
|
|
11332
|
-
SESSION_OBJ[SESSION_ID].app_id,
|
|
11333
|
-
"node_modules",
|
|
11334
|
-
"/"
|
|
11335
|
-
);
|
|
11336
|
-
const script = new VM.VMScript(
|
|
11337
|
-
`try{${val}}catch(e){func.api.error(SESSION_ID, "nodejs error", e); console.error(e); func.events.delete_job(SESSION_ID, job_id);}`,
|
|
11338
|
-
{ filename: dir, dirname: dir }
|
|
11339
|
-
);
|
|
11176
|
+
const dir = path.join(_conf.studio_drive_path, SESSION_OBJ[SESSION_ID].app_id, 'node_modules', '/');
|
|
11177
|
+
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 });
|
|
11340
11178
|
let vm = new VM.NodeVM({
|
|
11341
11179
|
require: {
|
|
11342
11180
|
external: true,
|
|
@@ -11359,11 +11197,11 @@ func.expression.secure_eval = async function (
|
|
|
11359
11197
|
dirname: dir,
|
|
11360
11198
|
});
|
|
11361
11199
|
} catch (err) {
|
|
11362
|
-
console.error(
|
|
11200
|
+
console.error('Failed to execute script.', err);
|
|
11363
11201
|
|
|
11364
|
-
if (typeof IS_PROCESS_SERVER !==
|
|
11202
|
+
if (typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
11365
11203
|
func.events.delete_job(SESSION_ID, jobNo);
|
|
11366
|
-
return __.db.add_error_log(SESSION_OBJ[SESSION_ID].app_id,
|
|
11204
|
+
return __.db.add_error_log(SESSION_OBJ[SESSION_ID].app_id, 'api', err);
|
|
11367
11205
|
}
|
|
11368
11206
|
}
|
|
11369
11207
|
} else {
|
|
@@ -11382,12 +11220,12 @@ func.expression.secure_eval = async function (
|
|
|
11382
11220
|
allowAsync: false,
|
|
11383
11221
|
});
|
|
11384
11222
|
let ret = val;
|
|
11385
|
-
if (typeof val ===
|
|
11223
|
+
if (typeof val === 'string') {
|
|
11386
11224
|
ret = await vm.run(val);
|
|
11387
11225
|
}
|
|
11388
11226
|
return ret;
|
|
11389
11227
|
} catch (err) {
|
|
11390
|
-
throw
|
|
11228
|
+
throw '';
|
|
11391
11229
|
}
|
|
11392
11230
|
} catch (err) {
|
|
11393
11231
|
try {
|
|
@@ -12872,6 +12710,10 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
|
|
|
12872
12710
|
const trigger = val.key.split('xu-on:')[1].toLowerCase();
|
|
12873
12711
|
$elm.on(trigger, async function (evt) {
|
|
12874
12712
|
for await (const [key, val] of Object.entries($elm.data().xuAttributes['xu-on:' + evt.type])) {
|
|
12713
|
+
if (val.event_modifiers && evt[val.event_modifiers]) {
|
|
12714
|
+
evt[val.event_modifiers]();
|
|
12715
|
+
}
|
|
12716
|
+
|
|
12875
12717
|
if (val.handler === 'custom') {
|
|
12876
12718
|
// do BL
|
|
12877
12719
|
for await (const [key2, val2] of Object.entries(val.event)) {
|
|
@@ -12882,10 +12724,6 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
|
|
|
12882
12724
|
}
|
|
12883
12725
|
if (!cond) continue;
|
|
12884
12726
|
|
|
12885
|
-
if (val.event_modifiers && evt[val.event_modifiers]) {
|
|
12886
|
-
evt[val.event_modifiers]();
|
|
12887
|
-
}
|
|
12888
|
-
|
|
12889
12727
|
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);
|
|
12890
12728
|
}
|
|
12891
12729
|
}
|