@xuda.io/runtime-bundle 1.0.778 → 1.0.780
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 +3 -3
- package/js/modules/xuda-event-javascript-module.mjs +5 -3
- package/js/xuda-runtime-bundle.js +396 -396
- package/js/xuda-runtime-bundle.min.js +3 -3
- package/js/xuda-runtime-slim.js +398 -398
- package/js/xuda-runtime-slim.min.es.js +398 -398
- 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
package/js/xuda-worker-bundle.js
CHANGED
|
@@ -917,19 +917,19 @@ func.api.call_javascript = async function (prog_id, params, evaluate) {
|
|
|
917
917
|
return await api_utils.call_javascript(prog_id, params, evaluate);
|
|
918
918
|
};
|
|
919
919
|
|
|
920
|
-
func.api.call_javascript = async function (prog_id, params, evaluate) {
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
};
|
|
920
|
+
// func.api.call_javascript = async function (prog_id, params, evaluate) {
|
|
921
|
+
// const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
922
|
+
// const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
923
|
+
// func,
|
|
924
|
+
// glb,
|
|
925
|
+
// SESSION_OBJ,
|
|
926
|
+
// SESSION_ID,
|
|
927
|
+
// APP_OBJ,
|
|
928
|
+
// dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
929
|
+
// });
|
|
930
|
+
|
|
931
|
+
// return await api_utils.call_javascript(prog_id, params, evaluate);
|
|
932
|
+
// };
|
|
933
933
|
|
|
934
934
|
glb.rpi_request_queue_num = 0;
|
|
935
935
|
func.common.perform_rpi_request = async function (SESSION_ID, serviceP, opt = {}, data) {
|
|
@@ -6909,14 +6909,14 @@ func.events.execute = async function (
|
|
|
6909
6909
|
|
|
6910
6910
|
call_native_javascript: async function () {
|
|
6911
6911
|
const module = await func.common.get_module(SESSION_ID, 'xuda-event-javascript-module.mjs');
|
|
6912
|
-
const result = await module.call_javascript(SESSION_ID, jobNoP, refIdP, dsSession);
|
|
6912
|
+
const result = await module.call_javascript(SESSION_ID, jobNoP, refIdP, dsSession, false, $(containerP));
|
|
6913
6913
|
await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
|
|
6914
6914
|
|
|
6915
6915
|
return result;
|
|
6916
6916
|
},
|
|
6917
6917
|
call_evaluate_javascript: async function () {
|
|
6918
6918
|
const module = await func.common.get_module(SESSION_ID, 'xuda-event-javascript-module.mjs');
|
|
6919
|
-
const result = await module.call_javascript(SESSION_ID, jobNoP, refIdP, dsSession, true);
|
|
6919
|
+
const result = await module.call_javascript(SESSION_ID, jobNoP, refIdP, dsSession, true, $(containerP));
|
|
6920
6920
|
await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
|
|
6921
6921
|
|
|
6922
6922
|
return result;
|
|
@@ -6935,6 +6935,7 @@ func.events.execute = async function (
|
|
|
6935
6935
|
null,
|
|
6936
6936
|
null,
|
|
6937
6937
|
evt,
|
|
6938
|
+
$(containerP),
|
|
6938
6939
|
);
|
|
6939
6940
|
await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
|
|
6940
6941
|
|
|
@@ -6954,6 +6955,7 @@ func.events.execute = async function (
|
|
|
6954
6955
|
null,
|
|
6955
6956
|
null,
|
|
6956
6957
|
evt,
|
|
6958
|
+
$(containerP),
|
|
6957
6959
|
);
|
|
6958
6960
|
await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
|
|
6959
6961
|
|
|
@@ -7869,271 +7871,271 @@ func.expression.get = async function (SESSION_ID, valP, dsSessionP, sourceP, row
|
|
|
7869
7871
|
return new_class.get();
|
|
7870
7872
|
};
|
|
7871
7873
|
|
|
7872
|
-
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) {
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
|
|
7881
|
-
let ret, error, warning, var_error_found;
|
|
7882
|
-
const fields = { ...fieldsP };
|
|
7883
|
-
|
|
7884
|
-
// Initial value processing
|
|
7885
|
-
if (valP === null || typeof valP === 'undefined') ret = '';
|
|
7886
|
-
else if (typeof valP === 'boolean') ret = valP ? 'Y' : 'N';
|
|
7887
|
-
else ret = valP.toString();
|
|
7874
|
+
// 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) {
|
|
7875
|
+
// const evalJson = (text) => eval(`(${text})`);
|
|
7876
|
+
// const replaceQuotes = (str) => {
|
|
7877
|
+
// for (const [key, val] of Object.entries(fields)) {
|
|
7878
|
+
// if (typeof val === 'string') str = str.replace(`"${val}"`, val.replace(/"/g, ''));
|
|
7879
|
+
// }
|
|
7880
|
+
// return str;
|
|
7881
|
+
// };
|
|
7888
7882
|
|
|
7889
|
-
|
|
7890
|
-
|
|
7883
|
+
// let ret, error, warning, var_error_found;
|
|
7884
|
+
// const fields = { ...fieldsP };
|
|
7891
7885
|
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
}
|
|
7897
|
-
if ((error || warning) && SESSION_OBJ[SESSION_ID]?.DS_GLB[dsSessionP]) {
|
|
7898
|
-
func.utils.debug.log(SESSION_ID, SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].nodeId, {
|
|
7899
|
-
module: 'expression',
|
|
7900
|
-
action: sourceP,
|
|
7901
|
-
source: calling_fieldIdP,
|
|
7902
|
-
prop: ret,
|
|
7903
|
-
details: ret,
|
|
7904
|
-
result: ret,
|
|
7905
|
-
error,
|
|
7906
|
-
warning,
|
|
7907
|
-
fields: null,
|
|
7908
|
-
type: 'exp',
|
|
7909
|
-
prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
7910
|
-
debug_info: debug_infoP,
|
|
7911
|
-
});
|
|
7912
|
-
}
|
|
7913
|
-
return { result: ret, fields, error, warning, req: valP, var_error_found };
|
|
7914
|
-
};
|
|
7886
|
+
// // Initial value processing
|
|
7887
|
+
// if (valP === null || typeof valP === 'undefined') ret = '';
|
|
7888
|
+
// else if (typeof valP === 'boolean') ret = valP ? 'Y' : 'N';
|
|
7889
|
+
// else ret = valP.toString();
|
|
7915
7890
|
|
|
7916
|
-
|
|
7917
|
-
|
|
7918
|
-
try {
|
|
7919
|
-
if (sourceP !== 'arguments') {
|
|
7920
|
-
if (ret.startsWith('_DATE_')) ret = ret.slice(6);
|
|
7921
|
-
else if (/^\d{4}-\d{2}-\d{2}$/.test(ret) || ret === 'self') return endResults();
|
|
7922
|
-
else ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
7923
|
-
} else {
|
|
7924
|
-
ret = ret.replace(/_NULL/gi, '');
|
|
7925
|
-
}
|
|
7926
|
-
return endResults();
|
|
7927
|
-
} catch (err) {
|
|
7928
|
-
error = err.message;
|
|
7929
|
-
return endResults();
|
|
7930
|
-
}
|
|
7931
|
-
};
|
|
7891
|
+
// ret = ret.replace(/\&/g, '&');
|
|
7892
|
+
// ret = func.utils.replace_studio_drive_url(SESSION_ID, ret);
|
|
7932
7893
|
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7894
|
+
// // End results helper
|
|
7895
|
+
// const endResults = () => {
|
|
7896
|
+
// if (['update', 'javascript'].includes(sourceP) && typeof ret === 'string') {
|
|
7897
|
+
// ret = replaceQuotes(ret);
|
|
7898
|
+
// }
|
|
7899
|
+
// if ((error || warning) && SESSION_OBJ[SESSION_ID]?.DS_GLB[dsSessionP]) {
|
|
7900
|
+
// func.utils.debug.log(SESSION_ID, SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].nodeId, {
|
|
7901
|
+
// module: 'expression',
|
|
7902
|
+
// action: sourceP,
|
|
7903
|
+
// source: calling_fieldIdP,
|
|
7904
|
+
// prop: ret,
|
|
7905
|
+
// details: ret,
|
|
7906
|
+
// result: ret,
|
|
7907
|
+
// error,
|
|
7908
|
+
// warning,
|
|
7909
|
+
// fields: null,
|
|
7910
|
+
// type: 'exp',
|
|
7911
|
+
// prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
7912
|
+
// debug_info: debug_infoP,
|
|
7913
|
+
// });
|
|
7914
|
+
// }
|
|
7915
|
+
// return { result: ret, fields, error, warning, req: valP, var_error_found };
|
|
7916
|
+
// };
|
|
7917
|
+
|
|
7918
|
+
// // Handle non-variable cases
|
|
7919
|
+
// const handleNonVariable = async () => {
|
|
7920
|
+
// try {
|
|
7921
|
+
// if (sourceP !== 'arguments') {
|
|
7922
|
+
// if (ret.startsWith('_DATE_')) ret = ret.slice(6);
|
|
7923
|
+
// else if (/^\d{4}-\d{2}-\d{2}$/.test(ret) || ret === 'self') return endResults();
|
|
7924
|
+
// else ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
7925
|
+
// } else {
|
|
7926
|
+
// ret = ret.replace(/_NULL/gi, '');
|
|
7927
|
+
// }
|
|
7928
|
+
// return endResults();
|
|
7929
|
+
// } catch (err) {
|
|
7930
|
+
// error = err.message;
|
|
7931
|
+
// return endResults();
|
|
7932
|
+
// }
|
|
7933
|
+
// };
|
|
7938
7934
|
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
7935
|
+
// // Early return for simple cases
|
|
7936
|
+
// if (!func.expression.validate_variables(valP)) return await handleNonVariable();
|
|
7937
|
+
// if (glb.emailRegex.test(await func.expression.secure_eval(SESSION_ID, sourceP, valP, jobNo, dsSessionP, js_script_callback))) {
|
|
7938
|
+
// return await handleNonVariable();
|
|
7939
|
+
// }
|
|
7944
7940
|
|
|
7945
|
-
|
|
7941
|
+
// // Parse and process variables
|
|
7942
|
+
// const split = func.expression.parse(ret) || [];
|
|
7943
|
+
// const var_Arr = await Promise.all(
|
|
7944
|
+
// split.map(async (val, key) => {
|
|
7945
|
+
// const result = { value: val.value, fieldId: val.fieldId };
|
|
7946
7946
|
|
|
7947
|
-
|
|
7948
|
-
if (val.fieldId.startsWith('_THIS') && calling_fieldIdP) {
|
|
7949
|
-
result.fieldId = val.fieldId.length === 5 ? calling_fieldIdP : calling_fieldIdP + val.fieldId.slice(5);
|
|
7950
|
-
}
|
|
7947
|
+
// if (!val.fieldId) return result;
|
|
7951
7948
|
|
|
7952
|
-
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
|
|
7949
|
+
// // Handle _THIS substitution
|
|
7950
|
+
// if (val.fieldId.startsWith('_THIS') && calling_fieldIdP) {
|
|
7951
|
+
// result.fieldId = val.fieldId.length === 5 ? calling_fieldIdP : calling_fieldIdP + val.fieldId.slice(5);
|
|
7952
|
+
// }
|
|
7956
7953
|
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
7961
|
-
}
|
|
7954
|
+
// // Fetch value from datasource
|
|
7955
|
+
// const { ret: fetchedValue, fieldIdP } = await func.datasource.get_value(SESSION_ID, result.fieldId, dsSessionP, rowIdP);
|
|
7956
|
+
// result.value = fetchedValue?.value ?? (sourceP === 'exp' ? fetchedValue?.value : '""');
|
|
7957
|
+
// result.type = fetchedValue?.type;
|
|
7962
7958
|
|
|
7963
|
-
|
|
7964
|
-
|
|
7965
|
-
|
|
7966
|
-
|
|
7959
|
+
// // Handle iteration
|
|
7960
|
+
// if (iterate_info) {
|
|
7961
|
+
// if (iterate_info.iterator_key === fieldIdP) result.value = iterate_info._key;
|
|
7962
|
+
// if (iterate_info.iterator_val === fieldIdP) result.value = iterate_info._val;
|
|
7963
|
+
// }
|
|
7967
7964
|
|
|
7968
|
-
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7965
|
+
// // Process nested properties
|
|
7966
|
+
// if (val.value.includes('[') || val.value.includes('.')) {
|
|
7967
|
+
// const { property1, property2 } = await func.expression.get_property(val.value);
|
|
7968
|
+
// const data = fetchedValue?.type === 'object' ? fetchedValue.value : fetchedValue?.prop;
|
|
7969
|
+
|
|
7970
|
+
// if (key > 0 && val.value.includes(']') && !val.value.includes('[') && split[key - 1].value) {
|
|
7971
|
+
// const prevData = split[key - 1].value;
|
|
7972
|
+
// result.value = prevData[fieldIdP];
|
|
7973
|
+
// if (val.value.includes('.') && prevData[fieldIdP]) {
|
|
7974
|
+
// result.value = prevData[fieldIdP][property2] ?? '';
|
|
7975
|
+
// }
|
|
7976
|
+
// } else if (data) {
|
|
7977
|
+
// if (property1) result.value = data[property1] ?? '';
|
|
7978
|
+
// if (property2) result.value = (property1 ? data[property1]?.[property2] : data[property2]) ?? '';
|
|
7979
|
+
// }
|
|
7980
|
+
// }
|
|
7979
7981
|
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7982
|
+
// fields[fieldIdP] = result.value;
|
|
7983
|
+
// return result;
|
|
7984
|
+
// }),
|
|
7985
|
+
// );
|
|
7984
7986
|
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
let value = val.value;
|
|
7994
|
-
if (var_Arr.length > 1) {
|
|
7995
|
-
if (!['DbQuery', 'alert', 'exp', 'api_rendered_output'].includes(sourceP) && ['string', 'date'].includes(val.type)) {
|
|
7996
|
-
value = `\`${value}\``;
|
|
7997
|
-
} else if (sourceP === 'api_rendered_output' && api_output_type === 'json' && ['string', 'date'].includes(val.type)) {
|
|
7998
|
-
value = `"${value}"`;
|
|
7999
|
-
}
|
|
8000
|
-
}
|
|
7987
|
+
// // Final evaluation
|
|
7988
|
+
// try {
|
|
7989
|
+
// const res = var_Arr.map((val, key) => {
|
|
7990
|
+
// if (sourceP === 'UI Property EXP' || sourceP === 'UI Attr EXP') {
|
|
7991
|
+
// const { changed, value } = func.utils.get_drive_url(SESSION_ID, val.value, sourceP === 'UI Attr EXP' && var_Arr.length > 1);
|
|
7992
|
+
// if (changed) return value;
|
|
7993
|
+
// }
|
|
8001
7994
|
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
|
|
8006
|
-
|
|
8007
|
-
|
|
7995
|
+
// let value = val.value;
|
|
7996
|
+
// if (var_Arr.length > 1) {
|
|
7997
|
+
// if (!['DbQuery', 'alert', 'exp', 'api_rendered_output'].includes(sourceP) && ['string', 'date'].includes(val.type)) {
|
|
7998
|
+
// value = `\`${value}\``;
|
|
7999
|
+
// } else if (sourceP === 'api_rendered_output' && api_output_type === 'json' && ['string', 'date'].includes(val.type)) {
|
|
8000
|
+
// value = `"${value}"`;
|
|
8001
|
+
// }
|
|
8002
|
+
// }
|
|
8008
8003
|
|
|
8009
|
-
|
|
8010
|
-
|
|
8011
|
-
|
|
8004
|
+
// if (val.fieldId && typeof value === 'string') {
|
|
8005
|
+
// if (['query', 'condition', 'range', 'sort', 'locate'].includes(sourceP)) value = value.replace(/↵|\r\n|\n|\r/g, '');
|
|
8006
|
+
// if (['init', 'update', 'virtual'].includes(sourceP)) value = value.replace(/↵|\r\n|\n|\r/g, '\\n');
|
|
8007
|
+
// if (typeof IS_PROCESS_SERVER !== 'undefined') value = value.replace(/↵|\r\n|\n|\r/g, '<br>');
|
|
8008
|
+
// fields[val.fieldId] = value;
|
|
8009
|
+
// }
|
|
8012
8010
|
|
|
8013
|
-
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
return '0';
|
|
8017
|
-
}
|
|
8018
|
-
return value;
|
|
8019
|
-
});
|
|
8011
|
+
// if (typeof value === 'object' && var_Arr.length > 1) {
|
|
8012
|
+
// value = Array.isArray(value) || var_Arr[key + 1]?.value?.includes('.') ? JSON.stringify(value) : `(${JSON.stringify(value)})`;
|
|
8013
|
+
// }
|
|
8020
8014
|
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
|
|
8015
|
+
// if (!val.type === 'exp' && sourceP !== 'exp' && typeof value === 'string' && value.startsWith('@')) {
|
|
8016
|
+
// warning = `Error encoding ${value}`;
|
|
8017
|
+
// var_error_found = true;
|
|
8018
|
+
// return '0';
|
|
8019
|
+
// }
|
|
8020
|
+
// return value;
|
|
8021
|
+
// });
|
|
8022
|
+
|
|
8023
|
+
// ret = res.length === 1 ? res[0] : res.join('');
|
|
8024
|
+
// if (var_Arr.some((v) => v.type === 'exp') && sourceP !== 'exp' && !secondPassP) {
|
|
8025
|
+
// const exp = await func.expression.get(SESSION_ID, ret, dsSessionP, sourceP, rowIdP, sourceActionP, true, calling_fieldIdP, fields, debug_infoP);
|
|
8026
|
+
// ret = exp.res?.[0] ?? exp.result;
|
|
8027
|
+
// Object.assign(fields, exp.fields);
|
|
8028
|
+
// } else if (!secondPassP && !['arguments', 'api_rendered_output', 'DbQuery'].includes(sourceP)) {
|
|
8029
|
+
// ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
8030
|
+
// } else if (sourceP === 'DbQuery') {
|
|
8031
|
+
// ret = JSON.stringify(evalJson(ret));
|
|
8032
|
+
// }
|
|
8031
8033
|
|
|
8032
|
-
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8034
|
+
// if (typeof ret === 'string' && ret.startsWith('@')) {
|
|
8035
|
+
// error = 'Error encoding @ var';
|
|
8036
|
+
// var_error_found = true;
|
|
8037
|
+
// }
|
|
8038
|
+
// } catch (err) {
|
|
8039
|
+
// error = err.message;
|
|
8040
|
+
// }
|
|
8039
8041
|
|
|
8040
|
-
|
|
8041
|
-
};
|
|
8042
|
+
// return endResults();
|
|
8043
|
+
// };
|
|
8042
8044
|
|
|
8043
|
-
func.expression.parse_org = function (strP) {
|
|
8044
|
-
|
|
8045
|
-
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
|
|
8098
|
-
|
|
8099
|
-
|
|
8100
|
-
|
|
8101
|
-
|
|
8102
|
-
|
|
8103
|
-
|
|
8104
|
-
|
|
8105
|
-
|
|
8106
|
-
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8118
|
-
|
|
8119
|
-
|
|
8120
|
-
|
|
8121
|
-
|
|
8122
|
-
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8126
|
-
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
|
|
8135
|
-
|
|
8136
|
-
};
|
|
8045
|
+
// func.expression.parse_org = function (strP) {
|
|
8046
|
+
// var extract_str = function (strP, posP) {
|
|
8047
|
+
// if (!posP) posP = 0;
|
|
8048
|
+
// var clean_split_str = function (arrP) {
|
|
8049
|
+
// var arr = [];
|
|
8050
|
+
// if (arrP && arrP.length > 1 && arrP[0] === '' && arrP[1].indexOf('@') > -1) {
|
|
8051
|
+
// for (var i = 1; i <= arrP.length; i++) {
|
|
8052
|
+
// arr.push(arrP[i]);
|
|
8053
|
+
// }
|
|
8054
|
+
// return arr;
|
|
8055
|
+
// } else return arrP;
|
|
8056
|
+
// };
|
|
8057
|
+
// var nonLettersPatt = /\W/; // non letters
|
|
8058
|
+
// var validSymbolsNoArray = /[^.@\[]/; //valid symbols no array /[^.@\[\]\]]/
|
|
8059
|
+
// var validSymbolsWithArray = /[^.@"'\[\]]/; //valid symbols with array
|
|
8060
|
+
// var validSymbols = validSymbolsNoArray;
|
|
8061
|
+
// var splitTmp = strP.replace(/@/g, '^^@').split('^^');
|
|
8062
|
+
// var split = clean_split_str(splitTmp);
|
|
8063
|
+
// var obj = [];
|
|
8064
|
+
// if (split) {
|
|
8065
|
+
// for (let val of split) {
|
|
8066
|
+
// // run on @ segments
|
|
8067
|
+
// if (val) {
|
|
8068
|
+
// var pos = strP.indexOf(val);
|
|
8069
|
+
// if (val && val.substr(0, 1) === '@') {
|
|
8070
|
+
// var tmpStr = '';
|
|
8071
|
+
// var word_start_pos = undefined;
|
|
8072
|
+
// var word_end_pos = undefined;
|
|
8073
|
+
// // run on @ segment string
|
|
8074
|
+
// for (var i = 0; i <= val.length; i++) {
|
|
8075
|
+
// var key1 = i;
|
|
8076
|
+
// var val1 = val.substr(i, 1);
|
|
8077
|
+
// if (
|
|
8078
|
+
// val1 === '.' &&
|
|
8079
|
+
// !word_start_pos // find first dot
|
|
8080
|
+
// )
|
|
8081
|
+
// word_start_pos = key1;
|
|
8082
|
+
// if (
|
|
8083
|
+
// word_start_pos &&
|
|
8084
|
+
// key1 > word_start_pos &&
|
|
8085
|
+
// nonLettersPatt.test(val1) // find any sign character to mark the end of word
|
|
8086
|
+
// )
|
|
8087
|
+
// word_end_pos = key1;
|
|
8088
|
+
// if (word_start_pos && word_start_pos >= 0 && word_end_pos && word_end_pos >= 0) {
|
|
8089
|
+
// // find the word
|
|
8090
|
+
// var word = val.substr(word_start_pos + 1, word_end_pos - word_start_pos - 1); // get the word
|
|
8091
|
+
// // if (glb.ALL_PROPERTIES_ARR.indexOf(word) === -1) {
|
|
8092
|
+
// // compare with internal properties
|
|
8093
|
+
// tmpStr = tmpStr.substr(0, word_start_pos) + '^^' + tmpStr.substr(word_start_pos, word_end_pos);
|
|
8094
|
+
// // }
|
|
8095
|
+
// if (val.substr(word_end_pos, 1) === '.') word_start_pos = word_end_pos;
|
|
8096
|
+
// else word_start_pos = null;
|
|
8097
|
+
// word_end_pos = null;
|
|
8098
|
+
// }
|
|
8099
|
+
// if (val1 === '[') validSymbols = validSymbolsWithArray;
|
|
8100
|
+
// if (nonLettersPatt.test(val1) && validSymbols.test(val1) && tmpStr.indexOf('^^') === -1) {
|
|
8101
|
+
// tmpStr += '^^' + val1;
|
|
8102
|
+
// } else tmpStr += val1;
|
|
8103
|
+
// }
|
|
8104
|
+
// // });
|
|
8105
|
+
// if (tmpStr.indexOf('^^') > -1) {
|
|
8106
|
+
// var obj1 = extract_str(tmpStr, pos);
|
|
8107
|
+
// obj = obj.concat(obj1);
|
|
8108
|
+
// } else {
|
|
8109
|
+
// // push clean @var
|
|
8110
|
+
// var fieldId = undefined;
|
|
8111
|
+
// if (val) {
|
|
8112
|
+
// fieldId = val.substr(1, val.length);
|
|
8113
|
+
// if (val.indexOf('.') > -1) fieldId = val.substr(1, val.indexOf('.') - 1);
|
|
8114
|
+
// if (val.indexOf('[') > -1) fieldId = val.substr(1, val.indexOf('[') - 1);
|
|
8115
|
+
// //
|
|
8116
|
+
// // if (val.indexOf("]") > -1)
|
|
8117
|
+
// // fieldId = val.substr(1, val.indexOf("]") - 1);
|
|
8118
|
+
// }
|
|
8119
|
+
// obj.push({
|
|
8120
|
+
// value: val,
|
|
8121
|
+
// fieldId: fieldId,
|
|
8122
|
+
// pos: pos + posP,
|
|
8123
|
+
// });
|
|
8124
|
+
// }
|
|
8125
|
+
// } else {
|
|
8126
|
+
// obj.push({
|
|
8127
|
+
// value: val,
|
|
8128
|
+
// pos: pos + posP,
|
|
8129
|
+
// });
|
|
8130
|
+
// }
|
|
8131
|
+
// }
|
|
8132
|
+
// }
|
|
8133
|
+
// return obj;
|
|
8134
|
+
// }
|
|
8135
|
+
// };
|
|
8136
|
+
// var res = extract_str(strP);
|
|
8137
|
+
// return res;
|
|
8138
|
+
// };
|
|
8137
8139
|
|
|
8138
8140
|
func.expression.parse = function (input) {
|
|
8139
8141
|
if (typeof input !== 'string') return [];
|
|
@@ -8202,50 +8204,50 @@ func.expression.get_property = async function (valP) {
|
|
|
8202
8204
|
};
|
|
8203
8205
|
};
|
|
8204
8206
|
|
|
8205
|
-
func.expression.get_property_bad = async function (valP) {
|
|
8206
|
-
|
|
8207
|
+
// func.expression.get_property_bad = async function (valP) {
|
|
8208
|
+
// if (typeof valP !== 'string') return { property1: undefined, property2: undefined };
|
|
8207
8209
|
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
|
|
8214
|
-
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8224
|
-
|
|
8225
|
-
|
|
8226
|
-
|
|
8227
|
-
|
|
8228
|
-
|
|
8229
|
-
|
|
8230
|
-
|
|
8231
|
-
|
|
8210
|
+
// const secureEval = async (expr) => {
|
|
8211
|
+
// if (typeof IS_PROCESS_SERVER === 'undefined') {
|
|
8212
|
+
// try {
|
|
8213
|
+
// return eval(expr);
|
|
8214
|
+
// } catch (err) {
|
|
8215
|
+
// console.error(err);
|
|
8216
|
+
// return undefined;
|
|
8217
|
+
// }
|
|
8218
|
+
// }
|
|
8219
|
+
// try {
|
|
8220
|
+
// const vm = new VM.VM({
|
|
8221
|
+
// sandbox: {
|
|
8222
|
+
// func,
|
|
8223
|
+
// SESSION_ID,
|
|
8224
|
+
// SESSION_OBJ: { [SESSION_ID]: SESSION_OBJ[SESSION_ID] },
|
|
8225
|
+
// },
|
|
8226
|
+
// timeout: 1000,
|
|
8227
|
+
// allowAsync: false,
|
|
8228
|
+
// });
|
|
8229
|
+
// return await vm.run(expr);
|
|
8230
|
+
// } catch {
|
|
8231
|
+
// return undefined; // Simplified error handling
|
|
8232
|
+
// }
|
|
8233
|
+
// };
|
|
8232
8234
|
|
|
8233
|
-
|
|
8234
|
-
|
|
8235
|
-
|
|
8235
|
+
// let property1, property2;
|
|
8236
|
+
// const bracketStart = valP.indexOf('[');
|
|
8237
|
+
// const bracketEnd = valP.indexOf(']');
|
|
8236
8238
|
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
|
|
8239
|
+
// if (bracketStart > -1 && bracketEnd > bracketStart) {
|
|
8240
|
+
// const expr = valP.slice(bracketStart + 1, bracketEnd);
|
|
8241
|
+
// property1 = await secureEval(expr);
|
|
8242
|
+
// }
|
|
8241
8243
|
|
|
8242
|
-
|
|
8243
|
-
|
|
8244
|
-
|
|
8245
|
-
|
|
8244
|
+
// const dotIndex = valP.indexOf('.');
|
|
8245
|
+
// if (dotIndex > -1) {
|
|
8246
|
+
// property2 = valP.slice(dotIndex + 1);
|
|
8247
|
+
// }
|
|
8246
8248
|
|
|
8247
|
-
|
|
8248
|
-
};
|
|
8249
|
+
// return { property1, property2 };
|
|
8250
|
+
// };
|
|
8249
8251
|
|
|
8250
8252
|
func.expression.validate_constant = function (valP) {
|
|
8251
8253
|
var patt = /["']/;
|
|
@@ -8273,107 +8275,107 @@ func.expression.remove_quotes = function (valP) {
|
|
|
8273
8275
|
// func.expression.validate_constant(valP) && typeof valP === 'string' ? valP.slice(1, -1) : valP;
|
|
8274
8276
|
// };
|
|
8275
8277
|
|
|
8276
|
-
func.expression.secure_eval_org = async function (SESSION_ID, sourceP, val, job_id, dsSessionP, js_script_callback, evt) {
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
|
|
8284
|
-
|
|
8285
|
-
|
|
8286
|
-
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
8292
|
-
|
|
8293
|
-
|
|
8294
|
-
|
|
8295
|
-
|
|
8296
|
-
|
|
8297
|
-
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
|
|
8301
|
-
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
|
|
8306
|
-
|
|
8307
|
-
|
|
8308
|
-
|
|
8309
|
-
|
|
8310
|
-
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
-
|
|
8314
|
-
|
|
8315
|
-
|
|
8316
|
-
|
|
8317
|
-
|
|
8318
|
-
|
|
8319
|
-
|
|
8320
|
-
|
|
8321
|
-
|
|
8322
|
-
|
|
8323
|
-
|
|
8324
|
-
|
|
8325
|
-
|
|
8326
|
-
|
|
8327
|
-
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
|
|
8331
|
-
|
|
8332
|
-
|
|
8333
|
-
|
|
8334
|
-
|
|
8335
|
-
|
|
8336
|
-
|
|
8337
|
-
|
|
8338
|
-
|
|
8339
|
-
|
|
8340
|
-
|
|
8341
|
-
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
|
|
8349
|
-
|
|
8350
|
-
|
|
8351
|
-
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
};
|
|
8278
|
+
// func.expression.secure_eval_org = async function (SESSION_ID, sourceP, val, job_id, dsSessionP, js_script_callback, evt) {
|
|
8279
|
+
// const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
8280
|
+
// func,
|
|
8281
|
+
// glb,
|
|
8282
|
+
// SESSION_OBJ,
|
|
8283
|
+
// SESSION_ID,
|
|
8284
|
+
// APP_OBJ,
|
|
8285
|
+
// dsSession: dsSessionP,
|
|
8286
|
+
// job_id,
|
|
8287
|
+
// });
|
|
8288
|
+
|
|
8289
|
+
// const xu = api_utils;
|
|
8290
|
+
|
|
8291
|
+
// if (typeof IS_PROCESS_SERVER === 'undefined' && typeof IS_DOCKER === 'undefined') {
|
|
8292
|
+
// try {
|
|
8293
|
+
// return eval(val);
|
|
8294
|
+
// } catch (err) {
|
|
8295
|
+
// try {
|
|
8296
|
+
// return JSON5.parse(val);
|
|
8297
|
+
// } catch (err) {
|
|
8298
|
+
// // console.error(err);
|
|
8299
|
+
// return val;
|
|
8300
|
+
// }
|
|
8301
|
+
// }
|
|
8302
|
+
// }
|
|
8303
|
+
// // server side execution
|
|
8304
|
+
// if (sourceP === 'javascript') {
|
|
8305
|
+
// process.on('uncaughtException', (err) => {
|
|
8306
|
+
// console.error('Asynchronous error caught.', err);
|
|
8307
|
+
|
|
8308
|
+
// func.events.delete_job(SESSION_ID, job_id);
|
|
8309
|
+
// if (typeof IS_PROCESS_SERVER !== 'undefined' || typeof IS_DOCKER !== 'undefined') {
|
|
8310
|
+
// if (SESSION_OBJ[SESSION_ID].crawler) return;
|
|
8311
|
+
// return __.rpi.write_log(SESSION_OBJ[SESSION_ID].app_id, 'error', 'worker', 'vm error', err, null, val, 'func.expression.get.secure_eval');
|
|
8312
|
+
// }
|
|
8313
|
+
// });
|
|
8314
|
+
// try {
|
|
8315
|
+
// const dir = path.join(_conf.studio_drive_path, SESSION_OBJ[SESSION_ID].app_id, 'node_modules', '/');
|
|
8316
|
+
// 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 });
|
|
8317
|
+
// let vm = new VM.NodeVM({
|
|
8318
|
+
// require: {
|
|
8319
|
+
// external: true,
|
|
8320
|
+
// },
|
|
8321
|
+
// sandbox: {
|
|
8322
|
+
// func,
|
|
8323
|
+
// xu,
|
|
8324
|
+
// SESSION_ID,
|
|
8325
|
+
// SESSION_OBJ: { [`${SESSION_ID}`]: SESSION_OBJ[SESSION_ID] },
|
|
8326
|
+
// callback: js_script_callback,
|
|
8327
|
+
// job_id,
|
|
8328
|
+
// axios,
|
|
8329
|
+
// got,
|
|
8330
|
+
// FormData,
|
|
8331
|
+
// },
|
|
8332
|
+
// timeout: 60000,
|
|
8333
|
+
// });
|
|
8334
|
+
// return await vm.run(script, {
|
|
8335
|
+
// filename: dir,
|
|
8336
|
+
// dirname: dir,
|
|
8337
|
+
// });
|
|
8338
|
+
// } catch (err) {
|
|
8339
|
+
// console.error('Failed to execute script.', err);
|
|
8340
|
+
|
|
8341
|
+
// if (typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
8342
|
+
// func.events.delete_job(SESSION_ID, jobNo);
|
|
8343
|
+
// return __.db.add_error_log(SESSION_OBJ[SESSION_ID].app_id, 'api', err);
|
|
8344
|
+
// }
|
|
8345
|
+
// }
|
|
8346
|
+
// } else {
|
|
8347
|
+
// try {
|
|
8348
|
+
// try {
|
|
8349
|
+
// let vm = new VM.VM({
|
|
8350
|
+
// sandbox: {
|
|
8351
|
+
// xu,
|
|
8352
|
+
// func,
|
|
8353
|
+
// SESSION_ID,
|
|
8354
|
+
// SESSION_OBJ: { [`${SESSION_ID}`]: SESSION_OBJ[SESSION_ID] },
|
|
8355
|
+
// callback: js_script_callback,
|
|
8356
|
+
// job_id,
|
|
8357
|
+
// },
|
|
8358
|
+
// timeout: 1000,
|
|
8359
|
+
// allowAsync: false,
|
|
8360
|
+
// });
|
|
8361
|
+
// let ret = val;
|
|
8362
|
+
// if (typeof val === 'string') {
|
|
8363
|
+
// ret = await vm.run(val);
|
|
8364
|
+
// }
|
|
8365
|
+
// return ret;
|
|
8366
|
+
// } catch (err) {
|
|
8367
|
+
// throw '';
|
|
8368
|
+
// }
|
|
8369
|
+
// } catch (err) {
|
|
8370
|
+
// try {
|
|
8371
|
+
// return JSON5.parse(val);
|
|
8372
|
+
// } catch (err) {
|
|
8373
|
+
// // console.error(err);
|
|
8374
|
+
// return val;
|
|
8375
|
+
// }
|
|
8376
|
+
// }
|
|
8377
|
+
// }
|
|
8378
|
+
// };
|
|
8377
8379
|
|
|
8378
8380
|
func.expression.secure_eval = async function (SESSION_ID, sourceP, val, job_id, dsSessionP, js_script_callback, evt) {
|
|
8379
8381
|
if (typeof val !== 'string') return val;
|