@xuda.io/runtime-bundle 1.0.488 → 1.0.490
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 +180 -36
- package/js/xuda-runtime-bundle.min.js +1 -1
- package/js/xuda-runtime-slim.js +180 -36
- package/js/xuda-runtime-slim.min.es.js +180 -36
- package/js/xuda-runtime-slim.min.js +1 -1
- package/js/xuda-server-bundle.min.mjs +1 -1
- package/js/xuda-server-bundle.mjs +180 -36
- package/js/xuda-worker-bundle.js +180 -36
- 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;
|
|
@@ -10594,7 +10594,7 @@ func.expression.get = async function (SESSION_ID, valP, dsSessionP, sourceP, row
|
|
|
10594
10594
|
// var split = [];
|
|
10595
10595
|
var var_Arr = [];
|
|
10596
10596
|
const split = func.expression.parse(ret) || [];
|
|
10597
|
-
console.log(valP, split);
|
|
10597
|
+
// console.log(valP, split);
|
|
10598
10598
|
for await (const [arr_key, val] of Object.entries(split)) {
|
|
10599
10599
|
// run each field
|
|
10600
10600
|
const key = Number(arr_key);
|
|
@@ -10828,6 +10828,177 @@ func.expression.get = async function (SESSION_ID, valP, dsSessionP, sourceP, row
|
|
|
10828
10828
|
return new_class.get();
|
|
10829
10829
|
};
|
|
10830
10830
|
|
|
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
|
+
const evalJson = (text) => eval(`(${text})`);
|
|
10833
|
+
const replaceQuotes = (str) => {
|
|
10834
|
+
for (const [key, val] of Object.entries(fields)) {
|
|
10835
|
+
if (typeof val === 'string') str = str.replace(`"${val}"`, val.replace(/"/g, ''));
|
|
10836
|
+
}
|
|
10837
|
+
return str;
|
|
10838
|
+
};
|
|
10839
|
+
|
|
10840
|
+
let ret, error, warning, var_error_found;
|
|
10841
|
+
const fields = { ...fieldsP };
|
|
10842
|
+
|
|
10843
|
+
// Initial value processing
|
|
10844
|
+
if (valP === null || typeof valP === 'undefined') ret = '';
|
|
10845
|
+
else if (typeof valP === 'boolean') ret = valP ? 'Y' : 'N';
|
|
10846
|
+
else ret = valP.toString();
|
|
10847
|
+
|
|
10848
|
+
ret = ret.replace(/\&/g, '&');
|
|
10849
|
+
ret = func.utils.replace_studio_drive_url(SESSION_ID, ret);
|
|
10850
|
+
|
|
10851
|
+
// End results helper
|
|
10852
|
+
const endResults = () => {
|
|
10853
|
+
if (['update', 'javascript'].includes(sourceP) && typeof ret === 'string') {
|
|
10854
|
+
ret = replaceQuotes(ret);
|
|
10855
|
+
}
|
|
10856
|
+
if ((error || warning) && SESSION_OBJ[SESSION_ID]?.DS_GLB[dsSessionP]) {
|
|
10857
|
+
func.utils.debug.log(SESSION_ID, SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].nodeId, {
|
|
10858
|
+
module: 'expression',
|
|
10859
|
+
action: sourceP,
|
|
10860
|
+
source: calling_fieldIdP,
|
|
10861
|
+
prop: ret,
|
|
10862
|
+
details: ret,
|
|
10863
|
+
result: ret,
|
|
10864
|
+
error,
|
|
10865
|
+
warning,
|
|
10866
|
+
fields: null,
|
|
10867
|
+
type: 'exp',
|
|
10868
|
+
prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
10869
|
+
debug_info: debug_infoP,
|
|
10870
|
+
});
|
|
10871
|
+
}
|
|
10872
|
+
return { result: ret, fields, error, warning, req: valP, var_error_found };
|
|
10873
|
+
};
|
|
10874
|
+
|
|
10875
|
+
// Handle non-variable cases
|
|
10876
|
+
const handleNonVariable = async () => {
|
|
10877
|
+
try {
|
|
10878
|
+
if (sourceP !== 'arguments') {
|
|
10879
|
+
if (ret.startsWith('_DATE_')) ret = ret.slice(6);
|
|
10880
|
+
else if (/^\d{4}-\d{2}-\d{2}$/.test(ret) || ret === 'self') return endResults();
|
|
10881
|
+
else ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
10882
|
+
} else {
|
|
10883
|
+
ret = ret.replace(/_NULL/gi, '');
|
|
10884
|
+
}
|
|
10885
|
+
return endResults();
|
|
10886
|
+
} catch (err) {
|
|
10887
|
+
error = err.message;
|
|
10888
|
+
return endResults();
|
|
10889
|
+
}
|
|
10890
|
+
};
|
|
10891
|
+
|
|
10892
|
+
// Early return for simple cases
|
|
10893
|
+
if (!func.expression.validate_variables(valP)) return await handleNonVariable();
|
|
10894
|
+
if (glb.emailRegex.test(await func.expression.secure_eval(SESSION_ID, sourceP, valP, jobNo, dsSessionP, js_script_callback))) {
|
|
10895
|
+
return await handleNonVariable();
|
|
10896
|
+
}
|
|
10897
|
+
|
|
10898
|
+
// Parse and process variables
|
|
10899
|
+
const split = func.expression.parse(ret) || [];
|
|
10900
|
+
const var_Arr = await Promise.all(
|
|
10901
|
+
split.map(async (val, key) => {
|
|
10902
|
+
const result = { value: val.value, fieldId: val.fieldId };
|
|
10903
|
+
|
|
10904
|
+
if (!val.fieldId) return result;
|
|
10905
|
+
|
|
10906
|
+
// Handle _THIS substitution
|
|
10907
|
+
if (val.fieldId.startsWith('_THIS') && calling_fieldIdP) {
|
|
10908
|
+
result.fieldId = val.fieldId.length === 5 ? calling_fieldIdP : calling_fieldIdP + val.fieldId.slice(5);
|
|
10909
|
+
}
|
|
10910
|
+
|
|
10911
|
+
// Fetch value from datasource
|
|
10912
|
+
const { ret: fetchedValue, fieldIdP } = await func.datasource.get_value(SESSION_ID, result.fieldId, dsSessionP, rowIdP);
|
|
10913
|
+
result.value = fetchedValue?.value ?? (sourceP === 'exp' ? fetchedValue?.value : '""');
|
|
10914
|
+
result.type = fetchedValue?.type;
|
|
10915
|
+
|
|
10916
|
+
// Handle iteration
|
|
10917
|
+
if (iterate_info) {
|
|
10918
|
+
if (iterate_info.iterator_key === fieldIdP) result.value = iterate_info._key;
|
|
10919
|
+
if (iterate_info.iterator_val === fieldIdP) result.value = iterate_info._val;
|
|
10920
|
+
}
|
|
10921
|
+
|
|
10922
|
+
// Process nested properties
|
|
10923
|
+
if (val.value.includes('[') || val.value.includes('.')) {
|
|
10924
|
+
const { property1, property2 } = await func.expression.get_property(val.value);
|
|
10925
|
+
const data = fetchedValue?.type === 'object' ? fetchedValue.value : fetchedValue?.prop;
|
|
10926
|
+
|
|
10927
|
+
if (key > 0 && val.value.includes(']') && !val.value.includes('[') && split[key - 1].value) {
|
|
10928
|
+
const prevData = split[key - 1].value;
|
|
10929
|
+
result.value = prevData[fieldIdP];
|
|
10930
|
+
if (val.value.includes('.') && prevData[fieldIdP]) {
|
|
10931
|
+
result.value = prevData[fieldIdP][property2] ?? '';
|
|
10932
|
+
}
|
|
10933
|
+
} else if (data) {
|
|
10934
|
+
if (property1) result.value = data[property1] ?? '';
|
|
10935
|
+
if (property2) result.value = (property1 ? data[property1]?.[property2] : data[property2]) ?? '';
|
|
10936
|
+
}
|
|
10937
|
+
}
|
|
10938
|
+
|
|
10939
|
+
fields[fieldIdP] = result.value;
|
|
10940
|
+
return result;
|
|
10941
|
+
}),
|
|
10942
|
+
);
|
|
10943
|
+
|
|
10944
|
+
// Final evaluation
|
|
10945
|
+
try {
|
|
10946
|
+
const res = var_Arr.map((val, key) => {
|
|
10947
|
+
if (sourceP === 'UI Property EXP' || sourceP === 'UI Attr EXP') {
|
|
10948
|
+
const { changed, value } = func.utils.get_drive_url(SESSION_ID, val.value, sourceP === 'UI Attr EXP' && var_Arr.length > 1);
|
|
10949
|
+
if (changed) return value;
|
|
10950
|
+
}
|
|
10951
|
+
|
|
10952
|
+
let value = val.value;
|
|
10953
|
+
if (var_Arr.length > 1) {
|
|
10954
|
+
if (!['DbQuery', 'alert', 'exp', 'api_rendered_output'].includes(sourceP) && ['string', 'date'].includes(val.type)) {
|
|
10955
|
+
value = `\`${value}\``;
|
|
10956
|
+
} else if (sourceP === 'api_rendered_output' && api_output_type === 'json' && ['string', 'date'].includes(val.type)) {
|
|
10957
|
+
value = `"${value}"`;
|
|
10958
|
+
}
|
|
10959
|
+
}
|
|
10960
|
+
|
|
10961
|
+
if (val.fieldId && typeof value === 'string') {
|
|
10962
|
+
if (['query', 'condition', 'range', 'sort', 'locate'].includes(sourceP)) value = value.replace(/↵|\r\n|\n|\r/g, '');
|
|
10963
|
+
if (['init', 'update', 'virtual'].includes(sourceP)) value = value.replace(/↵|\r\n|\n|\r/g, '\\n');
|
|
10964
|
+
if (typeof IS_PROCESS_SERVER !== 'undefined') value = value.replace(/↵|\r\n|\n|\r/g, '<br>');
|
|
10965
|
+
fields[val.fieldId] = value;
|
|
10966
|
+
}
|
|
10967
|
+
|
|
10968
|
+
if (typeof value === 'object' && var_Arr.length > 1) {
|
|
10969
|
+
value = Array.isArray(value) || var_Arr[key + 1]?.value?.includes('.') ? JSON.stringify(value) : `(${JSON.stringify(value)})`;
|
|
10970
|
+
}
|
|
10971
|
+
|
|
10972
|
+
if (!val.type === 'exp' && sourceP !== 'exp' && typeof value === 'string' && value.startsWith('@')) {
|
|
10973
|
+
warning = `Error encoding ${value}`;
|
|
10974
|
+
var_error_found = true;
|
|
10975
|
+
return '0';
|
|
10976
|
+
}
|
|
10977
|
+
return value;
|
|
10978
|
+
});
|
|
10979
|
+
|
|
10980
|
+
ret = res.length === 1 ? res[0] : res.join('');
|
|
10981
|
+
if (var_Arr.some((v) => v.type === 'exp') && sourceP !== 'exp' && !secondPassP) {
|
|
10982
|
+
const exp = await func.expression.get(SESSION_ID, ret, dsSessionP, sourceP, rowIdP, sourceActionP, true, calling_fieldIdP, fields, debug_infoP);
|
|
10983
|
+
ret = exp.res?.[0] ?? exp.result;
|
|
10984
|
+
Object.assign(fields, exp.fields);
|
|
10985
|
+
} else if (!secondPassP && !['arguments', 'api_rendered_output', 'DbQuery'].includes(sourceP)) {
|
|
10986
|
+
ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
10987
|
+
} else if (sourceP === 'DbQuery') {
|
|
10988
|
+
ret = JSON.stringify(evalJson(ret));
|
|
10989
|
+
}
|
|
10990
|
+
|
|
10991
|
+
if (typeof ret === 'string' && ret.startsWith('@')) {
|
|
10992
|
+
error = 'Error encoding @ var';
|
|
10993
|
+
var_error_found = true;
|
|
10994
|
+
}
|
|
10995
|
+
} catch (err) {
|
|
10996
|
+
error = err.message;
|
|
10997
|
+
}
|
|
10998
|
+
|
|
10999
|
+
return endResults();
|
|
11000
|
+
};
|
|
11001
|
+
|
|
10831
11002
|
func.expression.parse_org = function (strP) {
|
|
10832
11003
|
var extract_str = function (strP, posP) {
|
|
10833
11004
|
if (!posP) posP = 0;
|
|
@@ -10987,50 +11158,23 @@ func.expression.parse = function (input) {
|
|
|
10987
11158
|
const segments = [];
|
|
10988
11159
|
let pos = 0;
|
|
10989
11160
|
|
|
10990
|
-
const parts = input.split(/(
|
|
10991
|
-
|
|
10992
|
-
for (let i = 0; i < parts.length; i++) {
|
|
10993
|
-
const part = parts[i];
|
|
11161
|
+
const parts = input.split(/(@\w+)/).filter(Boolean);
|
|
10994
11162
|
|
|
10995
|
-
|
|
10996
|
-
|
|
10997
|
-
const
|
|
10998
|
-
let fieldId, remainder;
|
|
10999
|
-
|
|
11000
|
-
if (varEnd > 0) {
|
|
11001
|
-
fieldId = nextPart.slice(0, varEnd);
|
|
11002
|
-
remainder = nextPart.slice(varEnd);
|
|
11003
|
-
} else {
|
|
11004
|
-
fieldId = nextPart;
|
|
11005
|
-
remainder = '';
|
|
11006
|
-
}
|
|
11007
|
-
|
|
11008
|
-
// Add @variable segment
|
|
11009
|
-
const fullVarValue = `@${fieldId}`;
|
|
11163
|
+
for (const part of parts) {
|
|
11164
|
+
if (part.startsWith('@')) {
|
|
11165
|
+
const fieldId = part.slice(1);
|
|
11010
11166
|
segments.push({
|
|
11011
|
-
value:
|
|
11167
|
+
value: part,
|
|
11012
11168
|
fieldId,
|
|
11013
11169
|
pos,
|
|
11014
11170
|
});
|
|
11015
|
-
|
|
11016
|
-
|
|
11017
|
-
// Add remainder as a separate segment, if any
|
|
11018
|
-
if (remainder) {
|
|
11019
|
-
segments.push({
|
|
11020
|
-
value: remainder,
|
|
11021
|
-
pos,
|
|
11022
|
-
});
|
|
11023
|
-
pos += remainder.length;
|
|
11024
|
-
}
|
|
11025
|
-
|
|
11026
|
-
i++; // Skip the next part since we consumed it
|
|
11027
|
-
} else if (part !== '@') {
|
|
11171
|
+
} else {
|
|
11028
11172
|
segments.push({
|
|
11029
11173
|
value: part,
|
|
11030
11174
|
pos,
|
|
11031
11175
|
});
|
|
11032
|
-
pos += part.length;
|
|
11033
11176
|
}
|
|
11177
|
+
pos += part.length;
|
|
11034
11178
|
}
|
|
11035
11179
|
|
|
11036
11180
|
return segments;
|
|
@@ -14287,7 +14287,7 @@ func.events.invoke = async function (event_id) {
|
|
|
14287
14287
|
};
|
|
14288
14288
|
func.expression = {};
|
|
14289
14289
|
|
|
14290
|
-
func.expression.
|
|
14290
|
+
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) {
|
|
14291
14291
|
class xu_class {
|
|
14292
14292
|
async get() {
|
|
14293
14293
|
var ret;
|
|
@@ -14407,7 +14407,7 @@ func.expression.get = async function (SESSION_ID, valP, dsSessionP, sourceP, row
|
|
|
14407
14407
|
// var split = [];
|
|
14408
14408
|
var var_Arr = [];
|
|
14409
14409
|
const split = func.expression.parse(ret) || [];
|
|
14410
|
-
console.log(valP, split);
|
|
14410
|
+
// console.log(valP, split);
|
|
14411
14411
|
for await (const [arr_key, val] of Object.entries(split)) {
|
|
14412
14412
|
// run each field
|
|
14413
14413
|
const key = Number(arr_key);
|
|
@@ -14641,6 +14641,177 @@ func.expression.get = async function (SESSION_ID, valP, dsSessionP, sourceP, row
|
|
|
14641
14641
|
return new_class.get();
|
|
14642
14642
|
};
|
|
14643
14643
|
|
|
14644
|
+
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) {
|
|
14645
|
+
const evalJson = (text) => eval(`(${text})`);
|
|
14646
|
+
const replaceQuotes = (str) => {
|
|
14647
|
+
for (const [key, val] of Object.entries(fields)) {
|
|
14648
|
+
if (typeof val === 'string') str = str.replace(`"${val}"`, val.replace(/"/g, ''));
|
|
14649
|
+
}
|
|
14650
|
+
return str;
|
|
14651
|
+
};
|
|
14652
|
+
|
|
14653
|
+
let ret, error, warning, var_error_found;
|
|
14654
|
+
const fields = { ...fieldsP };
|
|
14655
|
+
|
|
14656
|
+
// Initial value processing
|
|
14657
|
+
if (valP === null || typeof valP === 'undefined') ret = '';
|
|
14658
|
+
else if (typeof valP === 'boolean') ret = valP ? 'Y' : 'N';
|
|
14659
|
+
else ret = valP.toString();
|
|
14660
|
+
|
|
14661
|
+
ret = ret.replace(/\&/g, '&');
|
|
14662
|
+
ret = func.utils.replace_studio_drive_url(SESSION_ID, ret);
|
|
14663
|
+
|
|
14664
|
+
// End results helper
|
|
14665
|
+
const endResults = () => {
|
|
14666
|
+
if (['update', 'javascript'].includes(sourceP) && typeof ret === 'string') {
|
|
14667
|
+
ret = replaceQuotes(ret);
|
|
14668
|
+
}
|
|
14669
|
+
if ((error || warning) && SESSION_OBJ[SESSION_ID]?.DS_GLB[dsSessionP]) {
|
|
14670
|
+
func.utils.debug.log(SESSION_ID, SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].nodeId, {
|
|
14671
|
+
module: 'expression',
|
|
14672
|
+
action: sourceP,
|
|
14673
|
+
source: calling_fieldIdP,
|
|
14674
|
+
prop: ret,
|
|
14675
|
+
details: ret,
|
|
14676
|
+
result: ret,
|
|
14677
|
+
error,
|
|
14678
|
+
warning,
|
|
14679
|
+
fields: null,
|
|
14680
|
+
type: 'exp',
|
|
14681
|
+
prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
14682
|
+
debug_info: debug_infoP,
|
|
14683
|
+
});
|
|
14684
|
+
}
|
|
14685
|
+
return { result: ret, fields, error, warning, req: valP, var_error_found };
|
|
14686
|
+
};
|
|
14687
|
+
|
|
14688
|
+
// Handle non-variable cases
|
|
14689
|
+
const handleNonVariable = async () => {
|
|
14690
|
+
try {
|
|
14691
|
+
if (sourceP !== 'arguments') {
|
|
14692
|
+
if (ret.startsWith('_DATE_')) ret = ret.slice(6);
|
|
14693
|
+
else if (/^\d{4}-\d{2}-\d{2}$/.test(ret) || ret === 'self') return endResults();
|
|
14694
|
+
else ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
14695
|
+
} else {
|
|
14696
|
+
ret = ret.replace(/_NULL/gi, '');
|
|
14697
|
+
}
|
|
14698
|
+
return endResults();
|
|
14699
|
+
} catch (err) {
|
|
14700
|
+
error = err.message;
|
|
14701
|
+
return endResults();
|
|
14702
|
+
}
|
|
14703
|
+
};
|
|
14704
|
+
|
|
14705
|
+
// Early return for simple cases
|
|
14706
|
+
if (!func.expression.validate_variables(valP)) return await handleNonVariable();
|
|
14707
|
+
if (glb.emailRegex.test(await func.expression.secure_eval(SESSION_ID, sourceP, valP, jobNo, dsSessionP, js_script_callback))) {
|
|
14708
|
+
return await handleNonVariable();
|
|
14709
|
+
}
|
|
14710
|
+
|
|
14711
|
+
// Parse and process variables
|
|
14712
|
+
const split = func.expression.parse(ret) || [];
|
|
14713
|
+
const var_Arr = await Promise.all(
|
|
14714
|
+
split.map(async (val, key) => {
|
|
14715
|
+
const result = { value: val.value, fieldId: val.fieldId };
|
|
14716
|
+
|
|
14717
|
+
if (!val.fieldId) return result;
|
|
14718
|
+
|
|
14719
|
+
// Handle _THIS substitution
|
|
14720
|
+
if (val.fieldId.startsWith('_THIS') && calling_fieldIdP) {
|
|
14721
|
+
result.fieldId = val.fieldId.length === 5 ? calling_fieldIdP : calling_fieldIdP + val.fieldId.slice(5);
|
|
14722
|
+
}
|
|
14723
|
+
|
|
14724
|
+
// Fetch value from datasource
|
|
14725
|
+
const { ret: fetchedValue, fieldIdP } = await func.datasource.get_value(SESSION_ID, result.fieldId, dsSessionP, rowIdP);
|
|
14726
|
+
result.value = fetchedValue?.value ?? (sourceP === 'exp' ? fetchedValue?.value : '""');
|
|
14727
|
+
result.type = fetchedValue?.type;
|
|
14728
|
+
|
|
14729
|
+
// Handle iteration
|
|
14730
|
+
if (iterate_info) {
|
|
14731
|
+
if (iterate_info.iterator_key === fieldIdP) result.value = iterate_info._key;
|
|
14732
|
+
if (iterate_info.iterator_val === fieldIdP) result.value = iterate_info._val;
|
|
14733
|
+
}
|
|
14734
|
+
|
|
14735
|
+
// Process nested properties
|
|
14736
|
+
if (val.value.includes('[') || val.value.includes('.')) {
|
|
14737
|
+
const { property1, property2 } = await func.expression.get_property(val.value);
|
|
14738
|
+
const data = fetchedValue?.type === 'object' ? fetchedValue.value : fetchedValue?.prop;
|
|
14739
|
+
|
|
14740
|
+
if (key > 0 && val.value.includes(']') && !val.value.includes('[') && split[key - 1].value) {
|
|
14741
|
+
const prevData = split[key - 1].value;
|
|
14742
|
+
result.value = prevData[fieldIdP];
|
|
14743
|
+
if (val.value.includes('.') && prevData[fieldIdP]) {
|
|
14744
|
+
result.value = prevData[fieldIdP][property2] ?? '';
|
|
14745
|
+
}
|
|
14746
|
+
} else if (data) {
|
|
14747
|
+
if (property1) result.value = data[property1] ?? '';
|
|
14748
|
+
if (property2) result.value = (property1 ? data[property1]?.[property2] : data[property2]) ?? '';
|
|
14749
|
+
}
|
|
14750
|
+
}
|
|
14751
|
+
|
|
14752
|
+
fields[fieldIdP] = result.value;
|
|
14753
|
+
return result;
|
|
14754
|
+
}),
|
|
14755
|
+
);
|
|
14756
|
+
|
|
14757
|
+
// Final evaluation
|
|
14758
|
+
try {
|
|
14759
|
+
const res = var_Arr.map((val, key) => {
|
|
14760
|
+
if (sourceP === 'UI Property EXP' || sourceP === 'UI Attr EXP') {
|
|
14761
|
+
const { changed, value } = func.utils.get_drive_url(SESSION_ID, val.value, sourceP === 'UI Attr EXP' && var_Arr.length > 1);
|
|
14762
|
+
if (changed) return value;
|
|
14763
|
+
}
|
|
14764
|
+
|
|
14765
|
+
let value = val.value;
|
|
14766
|
+
if (var_Arr.length > 1) {
|
|
14767
|
+
if (!['DbQuery', 'alert', 'exp', 'api_rendered_output'].includes(sourceP) && ['string', 'date'].includes(val.type)) {
|
|
14768
|
+
value = `\`${value}\``;
|
|
14769
|
+
} else if (sourceP === 'api_rendered_output' && api_output_type === 'json' && ['string', 'date'].includes(val.type)) {
|
|
14770
|
+
value = `"${value}"`;
|
|
14771
|
+
}
|
|
14772
|
+
}
|
|
14773
|
+
|
|
14774
|
+
if (val.fieldId && typeof value === 'string') {
|
|
14775
|
+
if (['query', 'condition', 'range', 'sort', 'locate'].includes(sourceP)) value = value.replace(/↵|\r\n|\n|\r/g, '');
|
|
14776
|
+
if (['init', 'update', 'virtual'].includes(sourceP)) value = value.replace(/↵|\r\n|\n|\r/g, '\\n');
|
|
14777
|
+
if (typeof IS_PROCESS_SERVER !== 'undefined') value = value.replace(/↵|\r\n|\n|\r/g, '<br>');
|
|
14778
|
+
fields[val.fieldId] = value;
|
|
14779
|
+
}
|
|
14780
|
+
|
|
14781
|
+
if (typeof value === 'object' && var_Arr.length > 1) {
|
|
14782
|
+
value = Array.isArray(value) || var_Arr[key + 1]?.value?.includes('.') ? JSON.stringify(value) : `(${JSON.stringify(value)})`;
|
|
14783
|
+
}
|
|
14784
|
+
|
|
14785
|
+
if (!val.type === 'exp' && sourceP !== 'exp' && typeof value === 'string' && value.startsWith('@')) {
|
|
14786
|
+
warning = `Error encoding ${value}`;
|
|
14787
|
+
var_error_found = true;
|
|
14788
|
+
return '0';
|
|
14789
|
+
}
|
|
14790
|
+
return value;
|
|
14791
|
+
});
|
|
14792
|
+
|
|
14793
|
+
ret = res.length === 1 ? res[0] : res.join('');
|
|
14794
|
+
if (var_Arr.some((v) => v.type === 'exp') && sourceP !== 'exp' && !secondPassP) {
|
|
14795
|
+
const exp = await func.expression.get(SESSION_ID, ret, dsSessionP, sourceP, rowIdP, sourceActionP, true, calling_fieldIdP, fields, debug_infoP);
|
|
14796
|
+
ret = exp.res?.[0] ?? exp.result;
|
|
14797
|
+
Object.assign(fields, exp.fields);
|
|
14798
|
+
} else if (!secondPassP && !['arguments', 'api_rendered_output', 'DbQuery'].includes(sourceP)) {
|
|
14799
|
+
ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
14800
|
+
} else if (sourceP === 'DbQuery') {
|
|
14801
|
+
ret = JSON.stringify(evalJson(ret));
|
|
14802
|
+
}
|
|
14803
|
+
|
|
14804
|
+
if (typeof ret === 'string' && ret.startsWith('@')) {
|
|
14805
|
+
error = 'Error encoding @ var';
|
|
14806
|
+
var_error_found = true;
|
|
14807
|
+
}
|
|
14808
|
+
} catch (err) {
|
|
14809
|
+
error = err.message;
|
|
14810
|
+
}
|
|
14811
|
+
|
|
14812
|
+
return endResults();
|
|
14813
|
+
};
|
|
14814
|
+
|
|
14644
14815
|
func.expression.parse_org = function (strP) {
|
|
14645
14816
|
var extract_str = function (strP, posP) {
|
|
14646
14817
|
if (!posP) posP = 0;
|
|
@@ -14800,50 +14971,23 @@ func.expression.parse = function (input) {
|
|
|
14800
14971
|
const segments = [];
|
|
14801
14972
|
let pos = 0;
|
|
14802
14973
|
|
|
14803
|
-
const parts = input.split(/(
|
|
14804
|
-
|
|
14805
|
-
for (let i = 0; i < parts.length; i++) {
|
|
14806
|
-
const part = parts[i];
|
|
14974
|
+
const parts = input.split(/(@\w+)/).filter(Boolean);
|
|
14807
14975
|
|
|
14808
|
-
|
|
14809
|
-
|
|
14810
|
-
const
|
|
14811
|
-
let fieldId, remainder;
|
|
14812
|
-
|
|
14813
|
-
if (varEnd > 0) {
|
|
14814
|
-
fieldId = nextPart.slice(0, varEnd);
|
|
14815
|
-
remainder = nextPart.slice(varEnd);
|
|
14816
|
-
} else {
|
|
14817
|
-
fieldId = nextPart;
|
|
14818
|
-
remainder = '';
|
|
14819
|
-
}
|
|
14820
|
-
|
|
14821
|
-
// Add @variable segment
|
|
14822
|
-
const fullVarValue = `@${fieldId}`;
|
|
14976
|
+
for (const part of parts) {
|
|
14977
|
+
if (part.startsWith('@')) {
|
|
14978
|
+
const fieldId = part.slice(1);
|
|
14823
14979
|
segments.push({
|
|
14824
|
-
value:
|
|
14980
|
+
value: part,
|
|
14825
14981
|
fieldId,
|
|
14826
14982
|
pos,
|
|
14827
14983
|
});
|
|
14828
|
-
|
|
14829
|
-
|
|
14830
|
-
// Add remainder as a separate segment, if any
|
|
14831
|
-
if (remainder) {
|
|
14832
|
-
segments.push({
|
|
14833
|
-
value: remainder,
|
|
14834
|
-
pos,
|
|
14835
|
-
});
|
|
14836
|
-
pos += remainder.length;
|
|
14837
|
-
}
|
|
14838
|
-
|
|
14839
|
-
i++; // Skip the next part since we consumed it
|
|
14840
|
-
} else if (part !== '@') {
|
|
14984
|
+
} else {
|
|
14841
14985
|
segments.push({
|
|
14842
14986
|
value: part,
|
|
14843
14987
|
pos,
|
|
14844
14988
|
});
|
|
14845
|
-
pos += part.length;
|
|
14846
14989
|
}
|
|
14990
|
+
pos += part.length;
|
|
14847
14991
|
}
|
|
14848
14992
|
|
|
14849
14993
|
return segments;
|