@xuda.io/runtime-bundle 1.0.498 → 1.0.500
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 +170 -16
- package/js/xuda-runtime-bundle.min.js +1 -1
- package/js/xuda-runtime-slim.js +170 -16
- package/js/xuda-runtime-slim.min.es.js +170 -16
- package/js/xuda-runtime-slim.min.js +1 -1
- package/js/xuda-server-bundle.min.mjs +1 -1
- package/js/xuda-server-bundle.mjs +170 -16
- package/js/xuda-worker-bundle.js +170 -16
- package/js/xuda-worker-bundle.min.js +1 -1
- package/package.json +1 -1
package/js/xuda-runtime-slim.js
CHANGED
|
@@ -10474,7 +10474,7 @@ func.events.invoke = async function (event_id) {
|
|
|
10474
10474
|
};
|
|
10475
10475
|
func.expression = {};
|
|
10476
10476
|
|
|
10477
|
-
func.expression.
|
|
10477
|
+
func.expression.get_org = async function (SESSION_ID, valP, dsSessionP, sourceP, rowIdP, sourceActionP, secondPassP, calling_fieldIdP, fieldsP, debug_infoP, iterate_info, js_script_callback, jobNo, api_output_type) {
|
|
10478
10478
|
class xu_class {
|
|
10479
10479
|
async get() {
|
|
10480
10480
|
var ret;
|
|
@@ -10828,7 +10828,161 @@ func.expression.get = async function (SESSION_ID, valP, dsSessionP, sourceP, row
|
|
|
10828
10828
|
return new_class.get();
|
|
10829
10829
|
};
|
|
10830
10830
|
|
|
10831
|
-
func.expression.
|
|
10831
|
+
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) {
|
|
10832
|
+
class xu_class {
|
|
10833
|
+
async get() {
|
|
10834
|
+
let ret, error, warning, var_error_found;
|
|
10835
|
+
const fields = { ...fieldsP };
|
|
10836
|
+
const evalJson = (text) => eval(`(${text})`);
|
|
10837
|
+
|
|
10838
|
+
// Initial value processing
|
|
10839
|
+
ret = valP === null || typeof valP === 'undefined' ? '' : typeof valP === 'boolean' ? (valP ? 'Y' : 'N') : valP.toString();
|
|
10840
|
+
ret = ret.replace(/\&/g, '&').replace(func.utils.replace_studio_drive_url(SESSION_ID, ret));
|
|
10841
|
+
|
|
10842
|
+
const endResults = () => {
|
|
10843
|
+
if (['update', 'javascript'].includes(sourceP) && typeof ret === 'string') {
|
|
10844
|
+
for (const [key, val] of Object.entries(fields)) {
|
|
10845
|
+
if (typeof val === 'string') ret = ret.replace(`"${val}"`, val.replace(/"/g, ''));
|
|
10846
|
+
}
|
|
10847
|
+
}
|
|
10848
|
+
if (error && SESSION_OBJ[SESSION_ID]?.DS_GLB[dsSessionP]) {
|
|
10849
|
+
func.utils.debug.log(SESSION_ID, SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].nodeId, {
|
|
10850
|
+
module: 'expression',
|
|
10851
|
+
action: sourceP,
|
|
10852
|
+
source: calling_fieldIdP,
|
|
10853
|
+
prop: ret,
|
|
10854
|
+
details: ret,
|
|
10855
|
+
result: ret,
|
|
10856
|
+
error,
|
|
10857
|
+
warning,
|
|
10858
|
+
fields: null,
|
|
10859
|
+
type: 'exp',
|
|
10860
|
+
prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
10861
|
+
debug_info: debug_infoP,
|
|
10862
|
+
});
|
|
10863
|
+
}
|
|
10864
|
+
return { result: ret, fields, error, warning, req: valP, var_error_found };
|
|
10865
|
+
};
|
|
10866
|
+
|
|
10867
|
+
const handleNonVariable = async () => {
|
|
10868
|
+
try {
|
|
10869
|
+
if (sourceP !== 'arguments') {
|
|
10870
|
+
if (ret.startsWith('_DATE_')) ret = ret.slice(6);
|
|
10871
|
+
else if (/^\d{4}-\d{2}-\d{2}$/.test(ret) || ret === 'self') return endResults();
|
|
10872
|
+
else ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
10873
|
+
} else {
|
|
10874
|
+
ret = ret.replace(/_NULL/gi, '');
|
|
10875
|
+
}
|
|
10876
|
+
return endResults();
|
|
10877
|
+
} catch (err) {
|
|
10878
|
+
error = err.message;
|
|
10879
|
+
return endResults();
|
|
10880
|
+
}
|
|
10881
|
+
};
|
|
10882
|
+
|
|
10883
|
+
if (!func.expression.validate_variables(valP)) return await handleNonVariable();
|
|
10884
|
+
if (glb.emailRegex.test(await func.expression.secure_eval(SESSION_ID, sourceP, valP, jobNo, dsSessionP, js_script_callback))) {
|
|
10885
|
+
return await handleNonVariable();
|
|
10886
|
+
}
|
|
10887
|
+
|
|
10888
|
+
const var_Arr = await Promise.all(
|
|
10889
|
+
(func.expression.parse(ret) || []).map(async (val, key) => {
|
|
10890
|
+
const result = { value: val.value, fieldId: val.fieldId };
|
|
10891
|
+
if (!val.fieldId) return result;
|
|
10892
|
+
|
|
10893
|
+
if (val.fieldId.startsWith('_THIS') && calling_fieldIdP) {
|
|
10894
|
+
result.fieldId = val.fieldId.length === 5 ? calling_fieldIdP : calling_fieldIdP + val.fieldId.slice(5);
|
|
10895
|
+
}
|
|
10896
|
+
|
|
10897
|
+
const { ret: fetchedValue, fieldIdP } = await func.datasource.get_value(SESSION_ID, result.fieldId, dsSessionP, rowIdP);
|
|
10898
|
+
result.value = fetchedValue?.value ?? (sourceP === 'exp' ? fetchedValue?.value : '""');
|
|
10899
|
+
result.type = fetchedValue?.type;
|
|
10900
|
+
|
|
10901
|
+
if (iterate_info) {
|
|
10902
|
+
if (iterate_info.iterator_key === fieldIdP) result.value = iterate_info._key;
|
|
10903
|
+
if (iterate_info.iterator_val === fieldIdP) result.value = iterate_info._val;
|
|
10904
|
+
}
|
|
10905
|
+
|
|
10906
|
+
if (val.value.includes('[') || val.value.includes('.')) {
|
|
10907
|
+
const { property1, property2 } = await func.expression.get_property(val.value);
|
|
10908
|
+
const data = fetchedValue?.type === 'object' ? fetchedValue.value : fetchedValue?.prop;
|
|
10909
|
+
|
|
10910
|
+
if (key > 0 && val.value.includes(']') && !val.value.includes('[') && var_Arr[key - 1]?.value) {
|
|
10911
|
+
const prevData = var_Arr[key - 1].value;
|
|
10912
|
+
result.value = prevData[fieldIdP] ?? '';
|
|
10913
|
+
if (val.value.includes('.') && prevData[fieldIdP]) result.value = prevData[fieldIdP][property2] ?? '';
|
|
10914
|
+
} else if (data) {
|
|
10915
|
+
if (property1) result.value = data[property1] ?? '';
|
|
10916
|
+
if (property2) result.value = (property1 ? data[property1]?.[property2] : data[property2]) ?? '';
|
|
10917
|
+
}
|
|
10918
|
+
}
|
|
10919
|
+
fields[fieldIdP] = result.value;
|
|
10920
|
+
return result;
|
|
10921
|
+
}),
|
|
10922
|
+
);
|
|
10923
|
+
|
|
10924
|
+
try {
|
|
10925
|
+
const res = var_Arr.map((val, key) => {
|
|
10926
|
+
if (sourceP === 'UI Property EXP' || sourceP === 'UI Attr EXP') {
|
|
10927
|
+
const { changed, value } = func.utils.get_drive_url(SESSION_ID, val.value, sourceP === 'UI Property EXP' || var_Arr.length > 1);
|
|
10928
|
+
if (changed) return value;
|
|
10929
|
+
}
|
|
10930
|
+
|
|
10931
|
+
let value = val.value;
|
|
10932
|
+
if (var_Arr.length > 1) {
|
|
10933
|
+
if (!['DbQuery', 'alert', 'exp', 'api_rendered_output'].includes(sourceP) && ['string', 'date'].includes(val.type)) {
|
|
10934
|
+
value = `\`${value}\``;
|
|
10935
|
+
} else if (sourceP === 'api_rendered_output' && api_output_type === 'json' && ['string', 'date'].includes(val.type)) {
|
|
10936
|
+
value = `"${value}"`;
|
|
10937
|
+
}
|
|
10938
|
+
}
|
|
10939
|
+
|
|
10940
|
+
if (val.fieldId && typeof value === 'string') {
|
|
10941
|
+
if (['query', 'condition', 'range', 'sort', 'locate'].includes(sourceP)) value = value.replace(/↵|\r\n|\n|\r/g, '');
|
|
10942
|
+
if (['init', 'update', 'virtual'].includes(sourceP)) value = value.replace(/↵|\r\n|\n|\r/g, '\\n');
|
|
10943
|
+
if (typeof IS_PROCESS_SERVER !== 'undefined') value = value.replace(/↵|\r\n|\n|\r/g, '<br>');
|
|
10944
|
+
fields[val.fieldId] = value;
|
|
10945
|
+
}
|
|
10946
|
+
|
|
10947
|
+
if (typeof value === 'object' && var_Arr.length > 1) {
|
|
10948
|
+
value = Array.isArray(value) || var_Arr[key + 1]?.value?.includes('.') ? JSON.stringify(value) : `(${JSON.stringify(value)})`;
|
|
10949
|
+
}
|
|
10950
|
+
|
|
10951
|
+
if (val.type !== 'exp' && sourceP !== 'exp' && typeof value === 'string' && value.startsWith('@')) {
|
|
10952
|
+
warning = `Error encoding ${value}`;
|
|
10953
|
+
var_error_found = true;
|
|
10954
|
+
return '0';
|
|
10955
|
+
}
|
|
10956
|
+
return value;
|
|
10957
|
+
});
|
|
10958
|
+
|
|
10959
|
+
ret = res.length === 1 ? res[0] : res.join('');
|
|
10960
|
+
if (var_Arr.some((v) => v.type === 'exp') && sourceP !== 'exp' && !secondPassP) {
|
|
10961
|
+
const exp = await func.expression.get(SESSION_ID, ret, dsSessionP, sourceP, rowIdP, sourceActionP, true, calling_fieldIdP, fields, debug_infoP);
|
|
10962
|
+
ret = exp.res?.[0] ?? exp.result;
|
|
10963
|
+
Object.assign(fields, exp.fields);
|
|
10964
|
+
} else if (!secondPassP && !['arguments', 'api_rendered_output', 'DbQuery'].includes(sourceP)) {
|
|
10965
|
+
ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
10966
|
+
} else if (sourceP === 'DbQuery') {
|
|
10967
|
+
ret = JSON.stringify(evalJson(ret));
|
|
10968
|
+
}
|
|
10969
|
+
|
|
10970
|
+
if (typeof ret === 'string' && ret.startsWith('@')) {
|
|
10971
|
+
error = 'Error encoding @ var';
|
|
10972
|
+
var_error_found = true;
|
|
10973
|
+
}
|
|
10974
|
+
} catch (err) {
|
|
10975
|
+
error = err.message;
|
|
10976
|
+
}
|
|
10977
|
+
|
|
10978
|
+
return endResults();
|
|
10979
|
+
}
|
|
10980
|
+
}
|
|
10981
|
+
|
|
10982
|
+
return new xu_class().get();
|
|
10983
|
+
};
|
|
10984
|
+
|
|
10985
|
+
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) {
|
|
10832
10986
|
const evalJson = (text) => eval(`(${text})`);
|
|
10833
10987
|
const replaceQuotes = (str) => {
|
|
10834
10988
|
for (const [key, val] of Object.entries(fields)) {
|
|
@@ -11122,7 +11276,7 @@ func.expression.parse = function (input) {
|
|
|
11122
11276
|
return segments;
|
|
11123
11277
|
};
|
|
11124
11278
|
|
|
11125
|
-
func.expression.
|
|
11279
|
+
func.expression.get_property = async function (valP) {
|
|
11126
11280
|
async function secure_eval(val) {
|
|
11127
11281
|
if (typeof IS_PROCESS_SERVER === 'undefined') {
|
|
11128
11282
|
try {
|
|
@@ -11161,7 +11315,7 @@ func.expression.get_property_org = async function (valP) {
|
|
|
11161
11315
|
};
|
|
11162
11316
|
};
|
|
11163
11317
|
|
|
11164
|
-
func.expression.
|
|
11318
|
+
func.expression.get_property_bad = async function (valP) {
|
|
11165
11319
|
if (typeof valP !== 'string') return { property1: undefined, property2: undefined };
|
|
11166
11320
|
|
|
11167
11321
|
const secureEval = async (expr) => {
|
|
@@ -11206,31 +11360,31 @@ func.expression.get_property = async function (valP) {
|
|
|
11206
11360
|
return { property1, property2 };
|
|
11207
11361
|
};
|
|
11208
11362
|
|
|
11209
|
-
func.expression.
|
|
11363
|
+
func.expression.validate_constant = function (valP) {
|
|
11210
11364
|
var patt = /["']/;
|
|
11211
11365
|
if (typeof valP === 'string' && patt.test(valP.substr(0, 1)) && patt.test(valP.substr(0, valP.length - 1))) return true;
|
|
11212
11366
|
else return false;
|
|
11213
11367
|
};
|
|
11214
|
-
func.expression.
|
|
11368
|
+
func.expression.validate_variables = function (valP) {
|
|
11215
11369
|
if (typeof valP === 'string' && valP.indexOf('@') > -1) return true;
|
|
11216
11370
|
else return false;
|
|
11217
11371
|
};
|
|
11218
|
-
func.expression.
|
|
11372
|
+
func.expression.remove_quotes = function (valP) {
|
|
11219
11373
|
if (func.expression.validate_constant(valP)) return valP.substr(1, valP.length - 2);
|
|
11220
11374
|
else return valP;
|
|
11221
11375
|
};
|
|
11222
11376
|
|
|
11223
|
-
func.expression.validate_constant = function (valP) {
|
|
11224
|
-
|
|
11225
|
-
};
|
|
11377
|
+
// func.expression.validate_constant = function (valP) {
|
|
11378
|
+
// typeof valP === 'string' && /^["'].*["']$/.test(valP);
|
|
11379
|
+
// };
|
|
11226
11380
|
|
|
11227
|
-
func.expression.validate_variables = function (valP) {
|
|
11228
|
-
|
|
11229
|
-
};
|
|
11381
|
+
// func.expression.validate_variables = function (valP) {
|
|
11382
|
+
// typeof valP === 'string' && valP.includes('@');
|
|
11383
|
+
// };
|
|
11230
11384
|
|
|
11231
|
-
func.expression.remove_quotes = function (valP) {
|
|
11232
|
-
|
|
11233
|
-
};
|
|
11385
|
+
// func.expression.remove_quotes = function (valP) {
|
|
11386
|
+
// func.expression.validate_constant(valP) && typeof valP === 'string' ? valP.slice(1, -1) : valP;
|
|
11387
|
+
// };
|
|
11234
11388
|
|
|
11235
11389
|
func.expression.secure_eval_org = async function (SESSION_ID, sourceP, val, job_id, dsSessionP, js_script_callback, evt) {
|
|
11236
11390
|
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
@@ -14282,7 +14282,7 @@ func.events.invoke = async function (event_id) {
|
|
|
14282
14282
|
};
|
|
14283
14283
|
func.expression = {};
|
|
14284
14284
|
|
|
14285
|
-
func.expression.
|
|
14285
|
+
func.expression.get_org = async function (SESSION_ID, valP, dsSessionP, sourceP, rowIdP, sourceActionP, secondPassP, calling_fieldIdP, fieldsP, debug_infoP, iterate_info, js_script_callback, jobNo, api_output_type) {
|
|
14286
14286
|
class xu_class {
|
|
14287
14287
|
async get() {
|
|
14288
14288
|
var ret;
|
|
@@ -14636,7 +14636,161 @@ func.expression.get = async function (SESSION_ID, valP, dsSessionP, sourceP, row
|
|
|
14636
14636
|
return new_class.get();
|
|
14637
14637
|
};
|
|
14638
14638
|
|
|
14639
|
-
func.expression.
|
|
14639
|
+
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) {
|
|
14640
|
+
class xu_class {
|
|
14641
|
+
async get() {
|
|
14642
|
+
let ret, error, warning, var_error_found;
|
|
14643
|
+
const fields = { ...fieldsP };
|
|
14644
|
+
const evalJson = (text) => eval(`(${text})`);
|
|
14645
|
+
|
|
14646
|
+
// Initial value processing
|
|
14647
|
+
ret = valP === null || typeof valP === 'undefined' ? '' : typeof valP === 'boolean' ? (valP ? 'Y' : 'N') : valP.toString();
|
|
14648
|
+
ret = ret.replace(/\&/g, '&').replace(func.utils.replace_studio_drive_url(SESSION_ID, ret));
|
|
14649
|
+
|
|
14650
|
+
const endResults = () => {
|
|
14651
|
+
if (['update', 'javascript'].includes(sourceP) && typeof ret === 'string') {
|
|
14652
|
+
for (const [key, val] of Object.entries(fields)) {
|
|
14653
|
+
if (typeof val === 'string') ret = ret.replace(`"${val}"`, val.replace(/"/g, ''));
|
|
14654
|
+
}
|
|
14655
|
+
}
|
|
14656
|
+
if (error && SESSION_OBJ[SESSION_ID]?.DS_GLB[dsSessionP]) {
|
|
14657
|
+
func.utils.debug.log(SESSION_ID, SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].nodeId, {
|
|
14658
|
+
module: 'expression',
|
|
14659
|
+
action: sourceP,
|
|
14660
|
+
source: calling_fieldIdP,
|
|
14661
|
+
prop: ret,
|
|
14662
|
+
details: ret,
|
|
14663
|
+
result: ret,
|
|
14664
|
+
error,
|
|
14665
|
+
warning,
|
|
14666
|
+
fields: null,
|
|
14667
|
+
type: 'exp',
|
|
14668
|
+
prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
14669
|
+
debug_info: debug_infoP,
|
|
14670
|
+
});
|
|
14671
|
+
}
|
|
14672
|
+
return { result: ret, fields, error, warning, req: valP, var_error_found };
|
|
14673
|
+
};
|
|
14674
|
+
|
|
14675
|
+
const handleNonVariable = async () => {
|
|
14676
|
+
try {
|
|
14677
|
+
if (sourceP !== 'arguments') {
|
|
14678
|
+
if (ret.startsWith('_DATE_')) ret = ret.slice(6);
|
|
14679
|
+
else if (/^\d{4}-\d{2}-\d{2}$/.test(ret) || ret === 'self') return endResults();
|
|
14680
|
+
else ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
14681
|
+
} else {
|
|
14682
|
+
ret = ret.replace(/_NULL/gi, '');
|
|
14683
|
+
}
|
|
14684
|
+
return endResults();
|
|
14685
|
+
} catch (err) {
|
|
14686
|
+
error = err.message;
|
|
14687
|
+
return endResults();
|
|
14688
|
+
}
|
|
14689
|
+
};
|
|
14690
|
+
|
|
14691
|
+
if (!func.expression.validate_variables(valP)) return await handleNonVariable();
|
|
14692
|
+
if (glb.emailRegex.test(await func.expression.secure_eval(SESSION_ID, sourceP, valP, jobNo, dsSessionP, js_script_callback))) {
|
|
14693
|
+
return await handleNonVariable();
|
|
14694
|
+
}
|
|
14695
|
+
|
|
14696
|
+
const var_Arr = await Promise.all(
|
|
14697
|
+
(func.expression.parse(ret) || []).map(async (val, key) => {
|
|
14698
|
+
const result = { value: val.value, fieldId: val.fieldId };
|
|
14699
|
+
if (!val.fieldId) return result;
|
|
14700
|
+
|
|
14701
|
+
if (val.fieldId.startsWith('_THIS') && calling_fieldIdP) {
|
|
14702
|
+
result.fieldId = val.fieldId.length === 5 ? calling_fieldIdP : calling_fieldIdP + val.fieldId.slice(5);
|
|
14703
|
+
}
|
|
14704
|
+
|
|
14705
|
+
const { ret: fetchedValue, fieldIdP } = await func.datasource.get_value(SESSION_ID, result.fieldId, dsSessionP, rowIdP);
|
|
14706
|
+
result.value = fetchedValue?.value ?? (sourceP === 'exp' ? fetchedValue?.value : '""');
|
|
14707
|
+
result.type = fetchedValue?.type;
|
|
14708
|
+
|
|
14709
|
+
if (iterate_info) {
|
|
14710
|
+
if (iterate_info.iterator_key === fieldIdP) result.value = iterate_info._key;
|
|
14711
|
+
if (iterate_info.iterator_val === fieldIdP) result.value = iterate_info._val;
|
|
14712
|
+
}
|
|
14713
|
+
|
|
14714
|
+
if (val.value.includes('[') || val.value.includes('.')) {
|
|
14715
|
+
const { property1, property2 } = await func.expression.get_property(val.value);
|
|
14716
|
+
const data = fetchedValue?.type === 'object' ? fetchedValue.value : fetchedValue?.prop;
|
|
14717
|
+
|
|
14718
|
+
if (key > 0 && val.value.includes(']') && !val.value.includes('[') && var_Arr[key - 1]?.value) {
|
|
14719
|
+
const prevData = var_Arr[key - 1].value;
|
|
14720
|
+
result.value = prevData[fieldIdP] ?? '';
|
|
14721
|
+
if (val.value.includes('.') && prevData[fieldIdP]) result.value = prevData[fieldIdP][property2] ?? '';
|
|
14722
|
+
} else if (data) {
|
|
14723
|
+
if (property1) result.value = data[property1] ?? '';
|
|
14724
|
+
if (property2) result.value = (property1 ? data[property1]?.[property2] : data[property2]) ?? '';
|
|
14725
|
+
}
|
|
14726
|
+
}
|
|
14727
|
+
fields[fieldIdP] = result.value;
|
|
14728
|
+
return result;
|
|
14729
|
+
}),
|
|
14730
|
+
);
|
|
14731
|
+
|
|
14732
|
+
try {
|
|
14733
|
+
const res = var_Arr.map((val, key) => {
|
|
14734
|
+
if (sourceP === 'UI Property EXP' || sourceP === 'UI Attr EXP') {
|
|
14735
|
+
const { changed, value } = func.utils.get_drive_url(SESSION_ID, val.value, sourceP === 'UI Property EXP' || var_Arr.length > 1);
|
|
14736
|
+
if (changed) return value;
|
|
14737
|
+
}
|
|
14738
|
+
|
|
14739
|
+
let value = val.value;
|
|
14740
|
+
if (var_Arr.length > 1) {
|
|
14741
|
+
if (!['DbQuery', 'alert', 'exp', 'api_rendered_output'].includes(sourceP) && ['string', 'date'].includes(val.type)) {
|
|
14742
|
+
value = `\`${value}\``;
|
|
14743
|
+
} else if (sourceP === 'api_rendered_output' && api_output_type === 'json' && ['string', 'date'].includes(val.type)) {
|
|
14744
|
+
value = `"${value}"`;
|
|
14745
|
+
}
|
|
14746
|
+
}
|
|
14747
|
+
|
|
14748
|
+
if (val.fieldId && typeof value === 'string') {
|
|
14749
|
+
if (['query', 'condition', 'range', 'sort', 'locate'].includes(sourceP)) value = value.replace(/↵|\r\n|\n|\r/g, '');
|
|
14750
|
+
if (['init', 'update', 'virtual'].includes(sourceP)) value = value.replace(/↵|\r\n|\n|\r/g, '\\n');
|
|
14751
|
+
if (typeof IS_PROCESS_SERVER !== 'undefined') value = value.replace(/↵|\r\n|\n|\r/g, '<br>');
|
|
14752
|
+
fields[val.fieldId] = value;
|
|
14753
|
+
}
|
|
14754
|
+
|
|
14755
|
+
if (typeof value === 'object' && var_Arr.length > 1) {
|
|
14756
|
+
value = Array.isArray(value) || var_Arr[key + 1]?.value?.includes('.') ? JSON.stringify(value) : `(${JSON.stringify(value)})`;
|
|
14757
|
+
}
|
|
14758
|
+
|
|
14759
|
+
if (val.type !== 'exp' && sourceP !== 'exp' && typeof value === 'string' && value.startsWith('@')) {
|
|
14760
|
+
warning = `Error encoding ${value}`;
|
|
14761
|
+
var_error_found = true;
|
|
14762
|
+
return '0';
|
|
14763
|
+
}
|
|
14764
|
+
return value;
|
|
14765
|
+
});
|
|
14766
|
+
|
|
14767
|
+
ret = res.length === 1 ? res[0] : res.join('');
|
|
14768
|
+
if (var_Arr.some((v) => v.type === 'exp') && sourceP !== 'exp' && !secondPassP) {
|
|
14769
|
+
const exp = await func.expression.get(SESSION_ID, ret, dsSessionP, sourceP, rowIdP, sourceActionP, true, calling_fieldIdP, fields, debug_infoP);
|
|
14770
|
+
ret = exp.res?.[0] ?? exp.result;
|
|
14771
|
+
Object.assign(fields, exp.fields);
|
|
14772
|
+
} else if (!secondPassP && !['arguments', 'api_rendered_output', 'DbQuery'].includes(sourceP)) {
|
|
14773
|
+
ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
14774
|
+
} else if (sourceP === 'DbQuery') {
|
|
14775
|
+
ret = JSON.stringify(evalJson(ret));
|
|
14776
|
+
}
|
|
14777
|
+
|
|
14778
|
+
if (typeof ret === 'string' && ret.startsWith('@')) {
|
|
14779
|
+
error = 'Error encoding @ var';
|
|
14780
|
+
var_error_found = true;
|
|
14781
|
+
}
|
|
14782
|
+
} catch (err) {
|
|
14783
|
+
error = err.message;
|
|
14784
|
+
}
|
|
14785
|
+
|
|
14786
|
+
return endResults();
|
|
14787
|
+
}
|
|
14788
|
+
}
|
|
14789
|
+
|
|
14790
|
+
return new xu_class().get();
|
|
14791
|
+
};
|
|
14792
|
+
|
|
14793
|
+
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) {
|
|
14640
14794
|
const evalJson = (text) => eval(`(${text})`);
|
|
14641
14795
|
const replaceQuotes = (str) => {
|
|
14642
14796
|
for (const [key, val] of Object.entries(fields)) {
|
|
@@ -14930,7 +15084,7 @@ func.expression.parse = function (input) {
|
|
|
14930
15084
|
return segments;
|
|
14931
15085
|
};
|
|
14932
15086
|
|
|
14933
|
-
func.expression.
|
|
15087
|
+
func.expression.get_property = async function (valP) {
|
|
14934
15088
|
async function secure_eval(val) {
|
|
14935
15089
|
if (typeof IS_PROCESS_SERVER === 'undefined') {
|
|
14936
15090
|
try {
|
|
@@ -14969,7 +15123,7 @@ func.expression.get_property_org = async function (valP) {
|
|
|
14969
15123
|
};
|
|
14970
15124
|
};
|
|
14971
15125
|
|
|
14972
|
-
func.expression.
|
|
15126
|
+
func.expression.get_property_bad = async function (valP) {
|
|
14973
15127
|
if (typeof valP !== 'string') return { property1: undefined, property2: undefined };
|
|
14974
15128
|
|
|
14975
15129
|
const secureEval = async (expr) => {
|
|
@@ -15014,31 +15168,31 @@ func.expression.get_property = async function (valP) {
|
|
|
15014
15168
|
return { property1, property2 };
|
|
15015
15169
|
};
|
|
15016
15170
|
|
|
15017
|
-
func.expression.
|
|
15171
|
+
func.expression.validate_constant = function (valP) {
|
|
15018
15172
|
var patt = /["']/;
|
|
15019
15173
|
if (typeof valP === 'string' && patt.test(valP.substr(0, 1)) && patt.test(valP.substr(0, valP.length - 1))) return true;
|
|
15020
15174
|
else return false;
|
|
15021
15175
|
};
|
|
15022
|
-
func.expression.
|
|
15176
|
+
func.expression.validate_variables = function (valP) {
|
|
15023
15177
|
if (typeof valP === 'string' && valP.indexOf('@') > -1) return true;
|
|
15024
15178
|
else return false;
|
|
15025
15179
|
};
|
|
15026
|
-
func.expression.
|
|
15180
|
+
func.expression.remove_quotes = function (valP) {
|
|
15027
15181
|
if (func.expression.validate_constant(valP)) return valP.substr(1, valP.length - 2);
|
|
15028
15182
|
else return valP;
|
|
15029
15183
|
};
|
|
15030
15184
|
|
|
15031
|
-
func.expression.validate_constant = function (valP) {
|
|
15032
|
-
|
|
15033
|
-
};
|
|
15185
|
+
// func.expression.validate_constant = function (valP) {
|
|
15186
|
+
// typeof valP === 'string' && /^["'].*["']$/.test(valP);
|
|
15187
|
+
// };
|
|
15034
15188
|
|
|
15035
|
-
func.expression.validate_variables = function (valP) {
|
|
15036
|
-
|
|
15037
|
-
};
|
|
15189
|
+
// func.expression.validate_variables = function (valP) {
|
|
15190
|
+
// typeof valP === 'string' && valP.includes('@');
|
|
15191
|
+
// };
|
|
15038
15192
|
|
|
15039
|
-
func.expression.remove_quotes = function (valP) {
|
|
15040
|
-
|
|
15041
|
-
};
|
|
15193
|
+
// func.expression.remove_quotes = function (valP) {
|
|
15194
|
+
// func.expression.validate_constant(valP) && typeof valP === 'string' ? valP.slice(1, -1) : valP;
|
|
15195
|
+
// };
|
|
15042
15196
|
|
|
15043
15197
|
func.expression.secure_eval_org = async function (SESSION_ID, sourceP, val, job_id, dsSessionP, js_script_callback, evt) {
|
|
15044
15198
|
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|