@xuda.io/runtime-bundle 1.0.779 → 1.0.781
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/xuda-runtime-bundle.js +396 -394
- package/js/xuda-runtime-bundle.min.js +3 -3
- package/js/xuda-runtime-slim.js +398 -396
- package/js/xuda-runtime-slim.min.es.js +398 -396
- package/js/xuda-runtime-slim.min.js +3 -3
- package/js/xuda-server-bundle.min.mjs +3 -3
- package/js/xuda-server-bundle.mjs +402 -400
- package/js/xuda-worker-bundle.js +402 -400
- package/js/xuda-worker-bundle.min.js +3 -3
- package/js/xuda_common-bundle.js +13 -13
- package/js/xuda_common-bundle.min.js +1 -1
- package/package.json +1 -1
|
@@ -2542,19 +2542,19 @@ func.api.call_javascript = async function (prog_id, params, evaluate) {
|
|
|
2542
2542
|
return await api_utils.call_javascript(prog_id, params, evaluate);
|
|
2543
2543
|
};
|
|
2544
2544
|
|
|
2545
|
-
func.api.call_javascript = async function (prog_id, params, evaluate) {
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2545
|
+
// func.api.call_javascript = async function (prog_id, params, evaluate) {
|
|
2546
|
+
// const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
2547
|
+
// const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
2548
|
+
// func,
|
|
2549
|
+
// glb,
|
|
2550
|
+
// SESSION_OBJ,
|
|
2551
|
+
// SESSION_ID,
|
|
2552
|
+
// APP_OBJ,
|
|
2553
|
+
// dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2554
|
+
// });
|
|
2555
2555
|
|
|
2556
|
-
|
|
2557
|
-
};
|
|
2556
|
+
// return await api_utils.call_javascript(prog_id, params, evaluate);
|
|
2557
|
+
// };
|
|
2558
2558
|
|
|
2559
2559
|
glb.rpi_request_queue_num = 0;
|
|
2560
2560
|
func.common.perform_rpi_request = async function (SESSION_ID, serviceP, opt = {}, data) {
|
|
@@ -13781,14 +13781,14 @@ func.events.execute = async function (
|
|
|
13781
13781
|
|
|
13782
13782
|
call_native_javascript: async function () {
|
|
13783
13783
|
const module = await func.common.get_module(SESSION_ID, 'xuda-event-javascript-module.mjs');
|
|
13784
|
-
const result = await module.call_javascript(SESSION_ID, jobNoP, refIdP, dsSession, false, $
|
|
13784
|
+
const result = await module.call_javascript(SESSION_ID, jobNoP, refIdP, dsSession, false, $div);
|
|
13785
13785
|
await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
|
|
13786
13786
|
|
|
13787
13787
|
return result;
|
|
13788
13788
|
},
|
|
13789
13789
|
call_evaluate_javascript: async function () {
|
|
13790
13790
|
const module = await func.common.get_module(SESSION_ID, 'xuda-event-javascript-module.mjs');
|
|
13791
|
-
const result = await module.call_javascript(SESSION_ID, jobNoP, refIdP, dsSession, true, $
|
|
13791
|
+
const result = await module.call_javascript(SESSION_ID, jobNoP, refIdP, dsSession, true, $div);
|
|
13792
13792
|
await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
|
|
13793
13793
|
|
|
13794
13794
|
return result;
|
|
@@ -13807,6 +13807,7 @@ func.events.execute = async function (
|
|
|
13807
13807
|
null,
|
|
13808
13808
|
null,
|
|
13809
13809
|
evt,
|
|
13810
|
+
$div,
|
|
13810
13811
|
);
|
|
13811
13812
|
await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
|
|
13812
13813
|
|
|
@@ -13826,6 +13827,7 @@ func.events.execute = async function (
|
|
|
13826
13827
|
null,
|
|
13827
13828
|
null,
|
|
13828
13829
|
evt,
|
|
13830
|
+
$div,
|
|
13829
13831
|
);
|
|
13830
13832
|
await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
|
|
13831
13833
|
|
|
@@ -14741,271 +14743,271 @@ func.expression.get = async function (SESSION_ID, valP, dsSessionP, sourceP, row
|
|
|
14741
14743
|
return new_class.get();
|
|
14742
14744
|
};
|
|
14743
14745
|
|
|
14744
|
-
func.expression.get_bad1 = async function (SESSION_ID, valP, dsSessionP, sourceP, rowIdP, sourceActionP, secondPassP, calling_fieldIdP, fieldsP = {}, debug_infoP, iterate_info, js_script_callback, jobNo, api_output_type) {
|
|
14745
|
-
|
|
14746
|
-
|
|
14747
|
-
|
|
14748
|
-
|
|
14749
|
-
|
|
14750
|
-
|
|
14751
|
-
|
|
14746
|
+
// func.expression.get_bad1 = async function (SESSION_ID, valP, dsSessionP, sourceP, rowIdP, sourceActionP, secondPassP, calling_fieldIdP, fieldsP = {}, debug_infoP, iterate_info, js_script_callback, jobNo, api_output_type) {
|
|
14747
|
+
// const evalJson = (text) => eval(`(${text})`);
|
|
14748
|
+
// const replaceQuotes = (str) => {
|
|
14749
|
+
// for (const [key, val] of Object.entries(fields)) {
|
|
14750
|
+
// if (typeof val === 'string') str = str.replace(`"${val}"`, val.replace(/"/g, ''));
|
|
14751
|
+
// }
|
|
14752
|
+
// return str;
|
|
14753
|
+
// };
|
|
14752
14754
|
|
|
14753
|
-
|
|
14754
|
-
|
|
14755
|
+
// let ret, error, warning, var_error_found;
|
|
14756
|
+
// const fields = { ...fieldsP };
|
|
14755
14757
|
|
|
14756
|
-
|
|
14757
|
-
|
|
14758
|
-
|
|
14759
|
-
|
|
14758
|
+
// // Initial value processing
|
|
14759
|
+
// if (valP === null || typeof valP === 'undefined') ret = '';
|
|
14760
|
+
// else if (typeof valP === 'boolean') ret = valP ? 'Y' : 'N';
|
|
14761
|
+
// else ret = valP.toString();
|
|
14760
14762
|
|
|
14761
|
-
|
|
14762
|
-
|
|
14763
|
+
// ret = ret.replace(/\&/g, '&');
|
|
14764
|
+
// ret = func.utils.replace_studio_drive_url(SESSION_ID, ret);
|
|
14763
14765
|
|
|
14764
|
-
|
|
14765
|
-
|
|
14766
|
-
|
|
14767
|
-
|
|
14768
|
-
|
|
14769
|
-
|
|
14770
|
-
|
|
14771
|
-
|
|
14772
|
-
|
|
14773
|
-
|
|
14774
|
-
|
|
14775
|
-
|
|
14776
|
-
|
|
14777
|
-
|
|
14778
|
-
|
|
14779
|
-
|
|
14780
|
-
|
|
14781
|
-
|
|
14782
|
-
|
|
14783
|
-
|
|
14784
|
-
|
|
14785
|
-
|
|
14786
|
-
|
|
14766
|
+
// // End results helper
|
|
14767
|
+
// const endResults = () => {
|
|
14768
|
+
// if (['update', 'javascript'].includes(sourceP) && typeof ret === 'string') {
|
|
14769
|
+
// ret = replaceQuotes(ret);
|
|
14770
|
+
// }
|
|
14771
|
+
// if ((error || warning) && SESSION_OBJ[SESSION_ID]?.DS_GLB[dsSessionP]) {
|
|
14772
|
+
// func.utils.debug.log(SESSION_ID, SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].nodeId, {
|
|
14773
|
+
// module: 'expression',
|
|
14774
|
+
// action: sourceP,
|
|
14775
|
+
// source: calling_fieldIdP,
|
|
14776
|
+
// prop: ret,
|
|
14777
|
+
// details: ret,
|
|
14778
|
+
// result: ret,
|
|
14779
|
+
// error,
|
|
14780
|
+
// warning,
|
|
14781
|
+
// fields: null,
|
|
14782
|
+
// type: 'exp',
|
|
14783
|
+
// prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
14784
|
+
// debug_info: debug_infoP,
|
|
14785
|
+
// });
|
|
14786
|
+
// }
|
|
14787
|
+
// return { result: ret, fields, error, warning, req: valP, var_error_found };
|
|
14788
|
+
// };
|
|
14787
14789
|
|
|
14788
|
-
|
|
14789
|
-
|
|
14790
|
-
|
|
14791
|
-
|
|
14792
|
-
|
|
14793
|
-
|
|
14794
|
-
|
|
14795
|
-
|
|
14796
|
-
|
|
14797
|
-
|
|
14798
|
-
|
|
14799
|
-
|
|
14800
|
-
|
|
14801
|
-
|
|
14802
|
-
|
|
14803
|
-
|
|
14790
|
+
// // Handle non-variable cases
|
|
14791
|
+
// const handleNonVariable = async () => {
|
|
14792
|
+
// try {
|
|
14793
|
+
// if (sourceP !== 'arguments') {
|
|
14794
|
+
// if (ret.startsWith('_DATE_')) ret = ret.slice(6);
|
|
14795
|
+
// else if (/^\d{4}-\d{2}-\d{2}$/.test(ret) || ret === 'self') return endResults();
|
|
14796
|
+
// else ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
14797
|
+
// } else {
|
|
14798
|
+
// ret = ret.replace(/_NULL/gi, '');
|
|
14799
|
+
// }
|
|
14800
|
+
// return endResults();
|
|
14801
|
+
// } catch (err) {
|
|
14802
|
+
// error = err.message;
|
|
14803
|
+
// return endResults();
|
|
14804
|
+
// }
|
|
14805
|
+
// };
|
|
14804
14806
|
|
|
14805
|
-
|
|
14806
|
-
|
|
14807
|
-
|
|
14808
|
-
|
|
14809
|
-
|
|
14807
|
+
// // Early return for simple cases
|
|
14808
|
+
// if (!func.expression.validate_variables(valP)) return await handleNonVariable();
|
|
14809
|
+
// if (glb.emailRegex.test(await func.expression.secure_eval(SESSION_ID, sourceP, valP, jobNo, dsSessionP, js_script_callback))) {
|
|
14810
|
+
// return await handleNonVariable();
|
|
14811
|
+
// }
|
|
14810
14812
|
|
|
14811
|
-
|
|
14812
|
-
|
|
14813
|
-
|
|
14814
|
-
|
|
14815
|
-
|
|
14813
|
+
// // Parse and process variables
|
|
14814
|
+
// const split = func.expression.parse(ret) || [];
|
|
14815
|
+
// const var_Arr = await Promise.all(
|
|
14816
|
+
// split.map(async (val, key) => {
|
|
14817
|
+
// const result = { value: val.value, fieldId: val.fieldId };
|
|
14816
14818
|
|
|
14817
|
-
|
|
14819
|
+
// if (!val.fieldId) return result;
|
|
14818
14820
|
|
|
14819
|
-
|
|
14820
|
-
|
|
14821
|
-
|
|
14822
|
-
|
|
14821
|
+
// // Handle _THIS substitution
|
|
14822
|
+
// if (val.fieldId.startsWith('_THIS') && calling_fieldIdP) {
|
|
14823
|
+
// result.fieldId = val.fieldId.length === 5 ? calling_fieldIdP : calling_fieldIdP + val.fieldId.slice(5);
|
|
14824
|
+
// }
|
|
14823
14825
|
|
|
14824
|
-
|
|
14825
|
-
|
|
14826
|
-
|
|
14827
|
-
|
|
14826
|
+
// // Fetch value from datasource
|
|
14827
|
+
// const { ret: fetchedValue, fieldIdP } = await func.datasource.get_value(SESSION_ID, result.fieldId, dsSessionP, rowIdP);
|
|
14828
|
+
// result.value = fetchedValue?.value ?? (sourceP === 'exp' ? fetchedValue?.value : '""');
|
|
14829
|
+
// result.type = fetchedValue?.type;
|
|
14828
14830
|
|
|
14829
|
-
|
|
14830
|
-
|
|
14831
|
-
|
|
14832
|
-
|
|
14833
|
-
|
|
14831
|
+
// // Handle iteration
|
|
14832
|
+
// if (iterate_info) {
|
|
14833
|
+
// if (iterate_info.iterator_key === fieldIdP) result.value = iterate_info._key;
|
|
14834
|
+
// if (iterate_info.iterator_val === fieldIdP) result.value = iterate_info._val;
|
|
14835
|
+
// }
|
|
14834
14836
|
|
|
14835
|
-
|
|
14836
|
-
|
|
14837
|
-
|
|
14838
|
-
|
|
14837
|
+
// // Process nested properties
|
|
14838
|
+
// if (val.value.includes('[') || val.value.includes('.')) {
|
|
14839
|
+
// const { property1, property2 } = await func.expression.get_property(val.value);
|
|
14840
|
+
// const data = fetchedValue?.type === 'object' ? fetchedValue.value : fetchedValue?.prop;
|
|
14839
14841
|
|
|
14840
|
-
|
|
14841
|
-
|
|
14842
|
-
|
|
14843
|
-
|
|
14844
|
-
|
|
14845
|
-
|
|
14846
|
-
|
|
14847
|
-
|
|
14848
|
-
|
|
14849
|
-
|
|
14850
|
-
|
|
14842
|
+
// if (key > 0 && val.value.includes(']') && !val.value.includes('[') && split[key - 1].value) {
|
|
14843
|
+
// const prevData = split[key - 1].value;
|
|
14844
|
+
// result.value = prevData[fieldIdP];
|
|
14845
|
+
// if (val.value.includes('.') && prevData[fieldIdP]) {
|
|
14846
|
+
// result.value = prevData[fieldIdP][property2] ?? '';
|
|
14847
|
+
// }
|
|
14848
|
+
// } else if (data) {
|
|
14849
|
+
// if (property1) result.value = data[property1] ?? '';
|
|
14850
|
+
// if (property2) result.value = (property1 ? data[property1]?.[property2] : data[property2]) ?? '';
|
|
14851
|
+
// }
|
|
14852
|
+
// }
|
|
14851
14853
|
|
|
14852
|
-
|
|
14853
|
-
|
|
14854
|
-
|
|
14855
|
-
|
|
14854
|
+
// fields[fieldIdP] = result.value;
|
|
14855
|
+
// return result;
|
|
14856
|
+
// }),
|
|
14857
|
+
// );
|
|
14856
14858
|
|
|
14857
|
-
|
|
14858
|
-
|
|
14859
|
-
|
|
14860
|
-
|
|
14861
|
-
|
|
14862
|
-
|
|
14863
|
-
|
|
14864
|
-
|
|
14865
|
-
let value = val.value;
|
|
14866
|
-
if (var_Arr.length > 1) {
|
|
14867
|
-
if (!['DbQuery', 'alert', 'exp', 'api_rendered_output'].includes(sourceP) && ['string', 'date'].includes(val.type)) {
|
|
14868
|
-
value = `\`${value}\``;
|
|
14869
|
-
} else if (sourceP === 'api_rendered_output' && api_output_type === 'json' && ['string', 'date'].includes(val.type)) {
|
|
14870
|
-
value = `"${value}"`;
|
|
14871
|
-
}
|
|
14872
|
-
}
|
|
14859
|
+
// // Final evaluation
|
|
14860
|
+
// try {
|
|
14861
|
+
// const res = var_Arr.map((val, key) => {
|
|
14862
|
+
// if (sourceP === 'UI Property EXP' || sourceP === 'UI Attr EXP') {
|
|
14863
|
+
// const { changed, value } = func.utils.get_drive_url(SESSION_ID, val.value, sourceP === 'UI Attr EXP' && var_Arr.length > 1);
|
|
14864
|
+
// if (changed) return value;
|
|
14865
|
+
// }
|
|
14873
14866
|
|
|
14874
|
-
|
|
14875
|
-
|
|
14876
|
-
|
|
14877
|
-
|
|
14878
|
-
|
|
14879
|
-
|
|
14867
|
+
// let value = val.value;
|
|
14868
|
+
// if (var_Arr.length > 1) {
|
|
14869
|
+
// if (!['DbQuery', 'alert', 'exp', 'api_rendered_output'].includes(sourceP) && ['string', 'date'].includes(val.type)) {
|
|
14870
|
+
// value = `\`${value}\``;
|
|
14871
|
+
// } else if (sourceP === 'api_rendered_output' && api_output_type === 'json' && ['string', 'date'].includes(val.type)) {
|
|
14872
|
+
// value = `"${value}"`;
|
|
14873
|
+
// }
|
|
14874
|
+
// }
|
|
14880
14875
|
|
|
14881
|
-
|
|
14882
|
-
|
|
14883
|
-
|
|
14876
|
+
// if (val.fieldId && typeof value === 'string') {
|
|
14877
|
+
// if (['query', 'condition', 'range', 'sort', 'locate'].includes(sourceP)) value = value.replace(/↵|\r\n|\n|\r/g, '');
|
|
14878
|
+
// if (['init', 'update', 'virtual'].includes(sourceP)) value = value.replace(/↵|\r\n|\n|\r/g, '\\n');
|
|
14879
|
+
// if (typeof IS_PROCESS_SERVER !== 'undefined') value = value.replace(/↵|\r\n|\n|\r/g, '<br>');
|
|
14880
|
+
// fields[val.fieldId] = value;
|
|
14881
|
+
// }
|
|
14884
14882
|
|
|
14885
|
-
|
|
14886
|
-
|
|
14887
|
-
|
|
14888
|
-
return '0';
|
|
14889
|
-
}
|
|
14890
|
-
return value;
|
|
14891
|
-
});
|
|
14883
|
+
// if (typeof value === 'object' && var_Arr.length > 1) {
|
|
14884
|
+
// value = Array.isArray(value) || var_Arr[key + 1]?.value?.includes('.') ? JSON.stringify(value) : `(${JSON.stringify(value)})`;
|
|
14885
|
+
// }
|
|
14892
14886
|
|
|
14893
|
-
|
|
14894
|
-
|
|
14895
|
-
|
|
14896
|
-
|
|
14897
|
-
|
|
14898
|
-
|
|
14899
|
-
|
|
14900
|
-
} else if (sourceP === 'DbQuery') {
|
|
14901
|
-
ret = JSON.stringify(evalJson(ret));
|
|
14902
|
-
}
|
|
14887
|
+
// if (!val.type === 'exp' && sourceP !== 'exp' && typeof value === 'string' && value.startsWith('@')) {
|
|
14888
|
+
// warning = `Error encoding ${value}`;
|
|
14889
|
+
// var_error_found = true;
|
|
14890
|
+
// return '0';
|
|
14891
|
+
// }
|
|
14892
|
+
// return value;
|
|
14893
|
+
// });
|
|
14903
14894
|
|
|
14904
|
-
|
|
14905
|
-
|
|
14906
|
-
|
|
14907
|
-
|
|
14908
|
-
|
|
14909
|
-
|
|
14910
|
-
|
|
14895
|
+
// ret = res.length === 1 ? res[0] : res.join('');
|
|
14896
|
+
// if (var_Arr.some((v) => v.type === 'exp') && sourceP !== 'exp' && !secondPassP) {
|
|
14897
|
+
// const exp = await func.expression.get(SESSION_ID, ret, dsSessionP, sourceP, rowIdP, sourceActionP, true, calling_fieldIdP, fields, debug_infoP);
|
|
14898
|
+
// ret = exp.res?.[0] ?? exp.result;
|
|
14899
|
+
// Object.assign(fields, exp.fields);
|
|
14900
|
+
// } else if (!secondPassP && !['arguments', 'api_rendered_output', 'DbQuery'].includes(sourceP)) {
|
|
14901
|
+
// ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
14902
|
+
// } else if (sourceP === 'DbQuery') {
|
|
14903
|
+
// ret = JSON.stringify(evalJson(ret));
|
|
14904
|
+
// }
|
|
14911
14905
|
|
|
14912
|
-
|
|
14913
|
-
|
|
14906
|
+
// if (typeof ret === 'string' && ret.startsWith('@')) {
|
|
14907
|
+
// error = 'Error encoding @ var';
|
|
14908
|
+
// var_error_found = true;
|
|
14909
|
+
// }
|
|
14910
|
+
// } catch (err) {
|
|
14911
|
+
// error = err.message;
|
|
14912
|
+
// }
|
|
14914
14913
|
|
|
14915
|
-
|
|
14916
|
-
|
|
14917
|
-
|
|
14918
|
-
|
|
14919
|
-
|
|
14920
|
-
|
|
14921
|
-
|
|
14922
|
-
|
|
14923
|
-
|
|
14924
|
-
|
|
14925
|
-
|
|
14926
|
-
|
|
14927
|
-
|
|
14928
|
-
|
|
14929
|
-
|
|
14930
|
-
|
|
14931
|
-
|
|
14932
|
-
|
|
14933
|
-
|
|
14934
|
-
|
|
14935
|
-
|
|
14936
|
-
|
|
14937
|
-
|
|
14938
|
-
|
|
14939
|
-
|
|
14940
|
-
|
|
14941
|
-
|
|
14942
|
-
|
|
14943
|
-
|
|
14944
|
-
|
|
14945
|
-
|
|
14946
|
-
|
|
14947
|
-
|
|
14948
|
-
|
|
14949
|
-
|
|
14950
|
-
|
|
14951
|
-
|
|
14952
|
-
|
|
14953
|
-
|
|
14954
|
-
|
|
14955
|
-
|
|
14956
|
-
|
|
14957
|
-
|
|
14958
|
-
|
|
14959
|
-
|
|
14960
|
-
|
|
14961
|
-
|
|
14962
|
-
|
|
14963
|
-
|
|
14964
|
-
|
|
14965
|
-
|
|
14966
|
-
|
|
14967
|
-
|
|
14968
|
-
|
|
14969
|
-
|
|
14970
|
-
|
|
14971
|
-
|
|
14972
|
-
|
|
14973
|
-
|
|
14974
|
-
|
|
14975
|
-
|
|
14976
|
-
|
|
14977
|
-
|
|
14978
|
-
|
|
14979
|
-
|
|
14980
|
-
|
|
14981
|
-
|
|
14982
|
-
|
|
14983
|
-
|
|
14984
|
-
|
|
14985
|
-
|
|
14986
|
-
|
|
14987
|
-
|
|
14988
|
-
|
|
14989
|
-
|
|
14990
|
-
|
|
14991
|
-
|
|
14992
|
-
|
|
14993
|
-
|
|
14994
|
-
|
|
14995
|
-
|
|
14996
|
-
|
|
14997
|
-
|
|
14998
|
-
|
|
14999
|
-
|
|
15000
|
-
|
|
15001
|
-
|
|
15002
|
-
|
|
15003
|
-
|
|
15004
|
-
|
|
15005
|
-
|
|
15006
|
-
|
|
15007
|
-
|
|
15008
|
-
};
|
|
14914
|
+
// return endResults();
|
|
14915
|
+
// };
|
|
14916
|
+
|
|
14917
|
+
// func.expression.parse_org = function (strP) {
|
|
14918
|
+
// var extract_str = function (strP, posP) {
|
|
14919
|
+
// if (!posP) posP = 0;
|
|
14920
|
+
// var clean_split_str = function (arrP) {
|
|
14921
|
+
// var arr = [];
|
|
14922
|
+
// if (arrP && arrP.length > 1 && arrP[0] === '' && arrP[1].indexOf('@') > -1) {
|
|
14923
|
+
// for (var i = 1; i <= arrP.length; i++) {
|
|
14924
|
+
// arr.push(arrP[i]);
|
|
14925
|
+
// }
|
|
14926
|
+
// return arr;
|
|
14927
|
+
// } else return arrP;
|
|
14928
|
+
// };
|
|
14929
|
+
// var nonLettersPatt = /\W/; // non letters
|
|
14930
|
+
// var validSymbolsNoArray = /[^.@\[]/; //valid symbols no array /[^.@\[\]\]]/
|
|
14931
|
+
// var validSymbolsWithArray = /[^.@"'\[\]]/; //valid symbols with array
|
|
14932
|
+
// var validSymbols = validSymbolsNoArray;
|
|
14933
|
+
// var splitTmp = strP.replace(/@/g, '^^@').split('^^');
|
|
14934
|
+
// var split = clean_split_str(splitTmp);
|
|
14935
|
+
// var obj = [];
|
|
14936
|
+
// if (split) {
|
|
14937
|
+
// for (let val of split) {
|
|
14938
|
+
// // run on @ segments
|
|
14939
|
+
// if (val) {
|
|
14940
|
+
// var pos = strP.indexOf(val);
|
|
14941
|
+
// if (val && val.substr(0, 1) === '@') {
|
|
14942
|
+
// var tmpStr = '';
|
|
14943
|
+
// var word_start_pos = undefined;
|
|
14944
|
+
// var word_end_pos = undefined;
|
|
14945
|
+
// // run on @ segment string
|
|
14946
|
+
// for (var i = 0; i <= val.length; i++) {
|
|
14947
|
+
// var key1 = i;
|
|
14948
|
+
// var val1 = val.substr(i, 1);
|
|
14949
|
+
// if (
|
|
14950
|
+
// val1 === '.' &&
|
|
14951
|
+
// !word_start_pos // find first dot
|
|
14952
|
+
// )
|
|
14953
|
+
// word_start_pos = key1;
|
|
14954
|
+
// if (
|
|
14955
|
+
// word_start_pos &&
|
|
14956
|
+
// key1 > word_start_pos &&
|
|
14957
|
+
// nonLettersPatt.test(val1) // find any sign character to mark the end of word
|
|
14958
|
+
// )
|
|
14959
|
+
// word_end_pos = key1;
|
|
14960
|
+
// if (word_start_pos && word_start_pos >= 0 && word_end_pos && word_end_pos >= 0) {
|
|
14961
|
+
// // find the word
|
|
14962
|
+
// var word = val.substr(word_start_pos + 1, word_end_pos - word_start_pos - 1); // get the word
|
|
14963
|
+
// // if (glb.ALL_PROPERTIES_ARR.indexOf(word) === -1) {
|
|
14964
|
+
// // compare with internal properties
|
|
14965
|
+
// tmpStr = tmpStr.substr(0, word_start_pos) + '^^' + tmpStr.substr(word_start_pos, word_end_pos);
|
|
14966
|
+
// // }
|
|
14967
|
+
// if (val.substr(word_end_pos, 1) === '.') word_start_pos = word_end_pos;
|
|
14968
|
+
// else word_start_pos = null;
|
|
14969
|
+
// word_end_pos = null;
|
|
14970
|
+
// }
|
|
14971
|
+
// if (val1 === '[') validSymbols = validSymbolsWithArray;
|
|
14972
|
+
// if (nonLettersPatt.test(val1) && validSymbols.test(val1) && tmpStr.indexOf('^^') === -1) {
|
|
14973
|
+
// tmpStr += '^^' + val1;
|
|
14974
|
+
// } else tmpStr += val1;
|
|
14975
|
+
// }
|
|
14976
|
+
// // });
|
|
14977
|
+
// if (tmpStr.indexOf('^^') > -1) {
|
|
14978
|
+
// var obj1 = extract_str(tmpStr, pos);
|
|
14979
|
+
// obj = obj.concat(obj1);
|
|
14980
|
+
// } else {
|
|
14981
|
+
// // push clean @var
|
|
14982
|
+
// var fieldId = undefined;
|
|
14983
|
+
// if (val) {
|
|
14984
|
+
// fieldId = val.substr(1, val.length);
|
|
14985
|
+
// if (val.indexOf('.') > -1) fieldId = val.substr(1, val.indexOf('.') - 1);
|
|
14986
|
+
// if (val.indexOf('[') > -1) fieldId = val.substr(1, val.indexOf('[') - 1);
|
|
14987
|
+
// //
|
|
14988
|
+
// // if (val.indexOf("]") > -1)
|
|
14989
|
+
// // fieldId = val.substr(1, val.indexOf("]") - 1);
|
|
14990
|
+
// }
|
|
14991
|
+
// obj.push({
|
|
14992
|
+
// value: val,
|
|
14993
|
+
// fieldId: fieldId,
|
|
14994
|
+
// pos: pos + posP,
|
|
14995
|
+
// });
|
|
14996
|
+
// }
|
|
14997
|
+
// } else {
|
|
14998
|
+
// obj.push({
|
|
14999
|
+
// value: val,
|
|
15000
|
+
// pos: pos + posP,
|
|
15001
|
+
// });
|
|
15002
|
+
// }
|
|
15003
|
+
// }
|
|
15004
|
+
// }
|
|
15005
|
+
// return obj;
|
|
15006
|
+
// }
|
|
15007
|
+
// };
|
|
15008
|
+
// var res = extract_str(strP);
|
|
15009
|
+
// return res;
|
|
15010
|
+
// };
|
|
15009
15011
|
|
|
15010
15012
|
func.expression.parse = function (input) {
|
|
15011
15013
|
if (typeof input !== 'string') return [];
|
|
@@ -15074,50 +15076,50 @@ func.expression.get_property = async function (valP) {
|
|
|
15074
15076
|
};
|
|
15075
15077
|
};
|
|
15076
15078
|
|
|
15077
|
-
func.expression.get_property_bad = async function (valP) {
|
|
15078
|
-
|
|
15079
|
+
// func.expression.get_property_bad = async function (valP) {
|
|
15080
|
+
// if (typeof valP !== 'string') return { property1: undefined, property2: undefined };
|
|
15079
15081
|
|
|
15080
|
-
|
|
15081
|
-
|
|
15082
|
-
|
|
15083
|
-
|
|
15084
|
-
|
|
15085
|
-
|
|
15086
|
-
|
|
15087
|
-
|
|
15088
|
-
|
|
15089
|
-
|
|
15090
|
-
|
|
15091
|
-
|
|
15092
|
-
|
|
15093
|
-
|
|
15094
|
-
|
|
15095
|
-
|
|
15096
|
-
|
|
15097
|
-
|
|
15098
|
-
|
|
15099
|
-
|
|
15100
|
-
|
|
15101
|
-
|
|
15102
|
-
|
|
15103
|
-
|
|
15082
|
+
// const secureEval = async (expr) => {
|
|
15083
|
+
// if (typeof IS_PROCESS_SERVER === 'undefined') {
|
|
15084
|
+
// try {
|
|
15085
|
+
// return eval(expr);
|
|
15086
|
+
// } catch (err) {
|
|
15087
|
+
// console.error(err);
|
|
15088
|
+
// return undefined;
|
|
15089
|
+
// }
|
|
15090
|
+
// }
|
|
15091
|
+
// try {
|
|
15092
|
+
// const vm = new VM.VM({
|
|
15093
|
+
// sandbox: {
|
|
15094
|
+
// func,
|
|
15095
|
+
// SESSION_ID,
|
|
15096
|
+
// SESSION_OBJ: { [SESSION_ID]: SESSION_OBJ[SESSION_ID] },
|
|
15097
|
+
// },
|
|
15098
|
+
// timeout: 1000,
|
|
15099
|
+
// allowAsync: false,
|
|
15100
|
+
// });
|
|
15101
|
+
// return await vm.run(expr);
|
|
15102
|
+
// } catch {
|
|
15103
|
+
// return undefined; // Simplified error handling
|
|
15104
|
+
// }
|
|
15105
|
+
// };
|
|
15104
15106
|
|
|
15105
|
-
|
|
15106
|
-
|
|
15107
|
-
|
|
15107
|
+
// let property1, property2;
|
|
15108
|
+
// const bracketStart = valP.indexOf('[');
|
|
15109
|
+
// const bracketEnd = valP.indexOf(']');
|
|
15108
15110
|
|
|
15109
|
-
|
|
15110
|
-
|
|
15111
|
-
|
|
15112
|
-
|
|
15111
|
+
// if (bracketStart > -1 && bracketEnd > bracketStart) {
|
|
15112
|
+
// const expr = valP.slice(bracketStart + 1, bracketEnd);
|
|
15113
|
+
// property1 = await secureEval(expr);
|
|
15114
|
+
// }
|
|
15113
15115
|
|
|
15114
|
-
|
|
15115
|
-
|
|
15116
|
-
|
|
15117
|
-
|
|
15116
|
+
// const dotIndex = valP.indexOf('.');
|
|
15117
|
+
// if (dotIndex > -1) {
|
|
15118
|
+
// property2 = valP.slice(dotIndex + 1);
|
|
15119
|
+
// }
|
|
15118
15120
|
|
|
15119
|
-
|
|
15120
|
-
};
|
|
15121
|
+
// return { property1, property2 };
|
|
15122
|
+
// };
|
|
15121
15123
|
|
|
15122
15124
|
func.expression.validate_constant = function (valP) {
|
|
15123
15125
|
var patt = /["']/;
|
|
@@ -15145,107 +15147,107 @@ func.expression.remove_quotes = function (valP) {
|
|
|
15145
15147
|
// func.expression.validate_constant(valP) && typeof valP === 'string' ? valP.slice(1, -1) : valP;
|
|
15146
15148
|
// };
|
|
15147
15149
|
|
|
15148
|
-
func.expression.secure_eval_org = async function (SESSION_ID, sourceP, val, job_id, dsSessionP, js_script_callback, evt) {
|
|
15149
|
-
|
|
15150
|
-
|
|
15151
|
-
|
|
15152
|
-
|
|
15153
|
-
|
|
15154
|
-
|
|
15155
|
-
|
|
15156
|
-
|
|
15157
|
-
|
|
15158
|
-
|
|
15159
|
-
const xu = api_utils;
|
|
15160
|
-
|
|
15161
|
-
if (typeof IS_PROCESS_SERVER === 'undefined' && typeof IS_DOCKER === 'undefined') {
|
|
15162
|
-
try {
|
|
15163
|
-
return eval(val);
|
|
15164
|
-
} catch (err) {
|
|
15165
|
-
try {
|
|
15166
|
-
return JSON5.parse(val);
|
|
15167
|
-
} catch (err) {
|
|
15168
|
-
// console.error(err);
|
|
15169
|
-
return val;
|
|
15170
|
-
}
|
|
15171
|
-
}
|
|
15172
|
-
}
|
|
15173
|
-
// server side execution
|
|
15174
|
-
if (sourceP === 'javascript') {
|
|
15175
|
-
process.on('uncaughtException', (err) => {
|
|
15176
|
-
console.error('Asynchronous error caught.', err);
|
|
15177
|
-
|
|
15178
|
-
func.events.delete_job(SESSION_ID, job_id);
|
|
15179
|
-
if (typeof IS_PROCESS_SERVER !== 'undefined' || typeof IS_DOCKER !== 'undefined') {
|
|
15180
|
-
if (SESSION_OBJ[SESSION_ID].crawler) return;
|
|
15181
|
-
return __.rpi.write_log(SESSION_OBJ[SESSION_ID].app_id, 'error', 'worker', 'vm error', err, null, val, 'func.expression.get.secure_eval');
|
|
15182
|
-
}
|
|
15183
|
-
});
|
|
15184
|
-
try {
|
|
15185
|
-
const dir = path.join(_conf.studio_drive_path, SESSION_OBJ[SESSION_ID].app_id, 'node_modules', '/');
|
|
15186
|
-
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 });
|
|
15187
|
-
let vm = new VM.NodeVM({
|
|
15188
|
-
require: {
|
|
15189
|
-
external: true,
|
|
15190
|
-
},
|
|
15191
|
-
sandbox: {
|
|
15192
|
-
func,
|
|
15193
|
-
xu,
|
|
15194
|
-
SESSION_ID,
|
|
15195
|
-
SESSION_OBJ: { [`${SESSION_ID}`]: SESSION_OBJ[SESSION_ID] },
|
|
15196
|
-
callback: js_script_callback,
|
|
15197
|
-
job_id,
|
|
15198
|
-
axios,
|
|
15199
|
-
got,
|
|
15200
|
-
FormData,
|
|
15201
|
-
},
|
|
15202
|
-
timeout: 60000,
|
|
15203
|
-
});
|
|
15204
|
-
return await vm.run(script, {
|
|
15205
|
-
filename: dir,
|
|
15206
|
-
dirname: dir,
|
|
15207
|
-
});
|
|
15208
|
-
} catch (err) {
|
|
15209
|
-
console.error('Failed to execute script.', err);
|
|
15150
|
+
// func.expression.secure_eval_org = async function (SESSION_ID, sourceP, val, job_id, dsSessionP, js_script_callback, evt) {
|
|
15151
|
+
// const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
15152
|
+
// func,
|
|
15153
|
+
// glb,
|
|
15154
|
+
// SESSION_OBJ,
|
|
15155
|
+
// SESSION_ID,
|
|
15156
|
+
// APP_OBJ,
|
|
15157
|
+
// dsSession: dsSessionP,
|
|
15158
|
+
// job_id,
|
|
15159
|
+
// });
|
|
15210
15160
|
|
|
15211
|
-
|
|
15212
|
-
|
|
15213
|
-
|
|
15214
|
-
|
|
15215
|
-
|
|
15216
|
-
|
|
15217
|
-
|
|
15218
|
-
|
|
15219
|
-
|
|
15220
|
-
|
|
15221
|
-
|
|
15222
|
-
|
|
15223
|
-
|
|
15224
|
-
|
|
15225
|
-
|
|
15226
|
-
|
|
15227
|
-
|
|
15228
|
-
|
|
15229
|
-
|
|
15230
|
-
|
|
15231
|
-
|
|
15232
|
-
|
|
15233
|
-
|
|
15234
|
-
|
|
15235
|
-
|
|
15236
|
-
|
|
15237
|
-
|
|
15238
|
-
|
|
15239
|
-
|
|
15240
|
-
|
|
15241
|
-
|
|
15242
|
-
|
|
15243
|
-
|
|
15244
|
-
|
|
15245
|
-
|
|
15246
|
-
|
|
15247
|
-
|
|
15248
|
-
|
|
15161
|
+
// const xu = api_utils;
|
|
15162
|
+
|
|
15163
|
+
// if (typeof IS_PROCESS_SERVER === 'undefined' && typeof IS_DOCKER === 'undefined') {
|
|
15164
|
+
// try {
|
|
15165
|
+
// return eval(val);
|
|
15166
|
+
// } catch (err) {
|
|
15167
|
+
// try {
|
|
15168
|
+
// return JSON5.parse(val);
|
|
15169
|
+
// } catch (err) {
|
|
15170
|
+
// // console.error(err);
|
|
15171
|
+
// return val;
|
|
15172
|
+
// }
|
|
15173
|
+
// }
|
|
15174
|
+
// }
|
|
15175
|
+
// // server side execution
|
|
15176
|
+
// if (sourceP === 'javascript') {
|
|
15177
|
+
// process.on('uncaughtException', (err) => {
|
|
15178
|
+
// console.error('Asynchronous error caught.', err);
|
|
15179
|
+
|
|
15180
|
+
// func.events.delete_job(SESSION_ID, job_id);
|
|
15181
|
+
// if (typeof IS_PROCESS_SERVER !== 'undefined' || typeof IS_DOCKER !== 'undefined') {
|
|
15182
|
+
// if (SESSION_OBJ[SESSION_ID].crawler) return;
|
|
15183
|
+
// return __.rpi.write_log(SESSION_OBJ[SESSION_ID].app_id, 'error', 'worker', 'vm error', err, null, val, 'func.expression.get.secure_eval');
|
|
15184
|
+
// }
|
|
15185
|
+
// });
|
|
15186
|
+
// try {
|
|
15187
|
+
// const dir = path.join(_conf.studio_drive_path, SESSION_OBJ[SESSION_ID].app_id, 'node_modules', '/');
|
|
15188
|
+
// 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 });
|
|
15189
|
+
// let vm = new VM.NodeVM({
|
|
15190
|
+
// require: {
|
|
15191
|
+
// external: true,
|
|
15192
|
+
// },
|
|
15193
|
+
// sandbox: {
|
|
15194
|
+
// func,
|
|
15195
|
+
// xu,
|
|
15196
|
+
// SESSION_ID,
|
|
15197
|
+
// SESSION_OBJ: { [`${SESSION_ID}`]: SESSION_OBJ[SESSION_ID] },
|
|
15198
|
+
// callback: js_script_callback,
|
|
15199
|
+
// job_id,
|
|
15200
|
+
// axios,
|
|
15201
|
+
// got,
|
|
15202
|
+
// FormData,
|
|
15203
|
+
// },
|
|
15204
|
+
// timeout: 60000,
|
|
15205
|
+
// });
|
|
15206
|
+
// return await vm.run(script, {
|
|
15207
|
+
// filename: dir,
|
|
15208
|
+
// dirname: dir,
|
|
15209
|
+
// });
|
|
15210
|
+
// } catch (err) {
|
|
15211
|
+
// console.error('Failed to execute script.', err);
|
|
15212
|
+
|
|
15213
|
+
// if (typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
15214
|
+
// func.events.delete_job(SESSION_ID, jobNo);
|
|
15215
|
+
// return __.db.add_error_log(SESSION_OBJ[SESSION_ID].app_id, 'api', err);
|
|
15216
|
+
// }
|
|
15217
|
+
// }
|
|
15218
|
+
// } else {
|
|
15219
|
+
// try {
|
|
15220
|
+
// try {
|
|
15221
|
+
// let vm = new VM.VM({
|
|
15222
|
+
// sandbox: {
|
|
15223
|
+
// xu,
|
|
15224
|
+
// func,
|
|
15225
|
+
// SESSION_ID,
|
|
15226
|
+
// SESSION_OBJ: { [`${SESSION_ID}`]: SESSION_OBJ[SESSION_ID] },
|
|
15227
|
+
// callback: js_script_callback,
|
|
15228
|
+
// job_id,
|
|
15229
|
+
// },
|
|
15230
|
+
// timeout: 1000,
|
|
15231
|
+
// allowAsync: false,
|
|
15232
|
+
// });
|
|
15233
|
+
// let ret = val;
|
|
15234
|
+
// if (typeof val === 'string') {
|
|
15235
|
+
// ret = await vm.run(val);
|
|
15236
|
+
// }
|
|
15237
|
+
// return ret;
|
|
15238
|
+
// } catch (err) {
|
|
15239
|
+
// throw '';
|
|
15240
|
+
// }
|
|
15241
|
+
// } catch (err) {
|
|
15242
|
+
// try {
|
|
15243
|
+
// return JSON5.parse(val);
|
|
15244
|
+
// } catch (err) {
|
|
15245
|
+
// // console.error(err);
|
|
15246
|
+
// return val;
|
|
15247
|
+
// }
|
|
15248
|
+
// }
|
|
15249
|
+
// }
|
|
15250
|
+
// };
|
|
15249
15251
|
|
|
15250
15252
|
func.expression.secure_eval = async function (SESSION_ID, sourceP, val, job_id, dsSessionP, js_script_callback, evt) {
|
|
15251
15253
|
if (typeof val !== 'string') return val;
|