@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
|
@@ -7753,7 +7753,7 @@ func.events.invoke = async function (event_id) {
|
|
|
7753
7753
|
};
|
|
7754
7754
|
func.expression = {};
|
|
7755
7755
|
|
|
7756
|
-
func.expression.
|
|
7756
|
+
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) {
|
|
7757
7757
|
class xu_class {
|
|
7758
7758
|
async get() {
|
|
7759
7759
|
var ret;
|
|
@@ -8107,7 +8107,161 @@ func.expression.get = async function (SESSION_ID, valP, dsSessionP, sourceP, row
|
|
|
8107
8107
|
return new_class.get();
|
|
8108
8108
|
};
|
|
8109
8109
|
|
|
8110
|
-
func.expression.
|
|
8110
|
+
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) {
|
|
8111
|
+
class xu_class {
|
|
8112
|
+
async get() {
|
|
8113
|
+
let ret, error, warning, var_error_found;
|
|
8114
|
+
const fields = { ...fieldsP };
|
|
8115
|
+
const evalJson = (text) => eval(`(${text})`);
|
|
8116
|
+
|
|
8117
|
+
// Initial value processing
|
|
8118
|
+
ret = valP === null || typeof valP === 'undefined' ? '' : typeof valP === 'boolean' ? (valP ? 'Y' : 'N') : valP.toString();
|
|
8119
|
+
ret = ret.replace(/\&/g, '&').replace(func.utils.replace_studio_drive_url(SESSION_ID, ret));
|
|
8120
|
+
|
|
8121
|
+
const endResults = () => {
|
|
8122
|
+
if (['update', 'javascript'].includes(sourceP) && typeof ret === 'string') {
|
|
8123
|
+
for (const [key, val] of Object.entries(fields)) {
|
|
8124
|
+
if (typeof val === 'string') ret = ret.replace(`"${val}"`, val.replace(/"/g, ''));
|
|
8125
|
+
}
|
|
8126
|
+
}
|
|
8127
|
+
if (error && SESSION_OBJ[SESSION_ID]?.DS_GLB[dsSessionP]) {
|
|
8128
|
+
func.utils.debug.log(SESSION_ID, SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].nodeId, {
|
|
8129
|
+
module: 'expression',
|
|
8130
|
+
action: sourceP,
|
|
8131
|
+
source: calling_fieldIdP,
|
|
8132
|
+
prop: ret,
|
|
8133
|
+
details: ret,
|
|
8134
|
+
result: ret,
|
|
8135
|
+
error,
|
|
8136
|
+
warning,
|
|
8137
|
+
fields: null,
|
|
8138
|
+
type: 'exp',
|
|
8139
|
+
prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
8140
|
+
debug_info: debug_infoP,
|
|
8141
|
+
});
|
|
8142
|
+
}
|
|
8143
|
+
return { result: ret, fields, error, warning, req: valP, var_error_found };
|
|
8144
|
+
};
|
|
8145
|
+
|
|
8146
|
+
const handleNonVariable = async () => {
|
|
8147
|
+
try {
|
|
8148
|
+
if (sourceP !== 'arguments') {
|
|
8149
|
+
if (ret.startsWith('_DATE_')) ret = ret.slice(6);
|
|
8150
|
+
else if (/^\d{4}-\d{2}-\d{2}$/.test(ret) || ret === 'self') return endResults();
|
|
8151
|
+
else ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
8152
|
+
} else {
|
|
8153
|
+
ret = ret.replace(/_NULL/gi, '');
|
|
8154
|
+
}
|
|
8155
|
+
return endResults();
|
|
8156
|
+
} catch (err) {
|
|
8157
|
+
error = err.message;
|
|
8158
|
+
return endResults();
|
|
8159
|
+
}
|
|
8160
|
+
};
|
|
8161
|
+
|
|
8162
|
+
if (!func.expression.validate_variables(valP)) return await handleNonVariable();
|
|
8163
|
+
if (glb.emailRegex.test(await func.expression.secure_eval(SESSION_ID, sourceP, valP, jobNo, dsSessionP, js_script_callback))) {
|
|
8164
|
+
return await handleNonVariable();
|
|
8165
|
+
}
|
|
8166
|
+
|
|
8167
|
+
const var_Arr = await Promise.all(
|
|
8168
|
+
(func.expression.parse(ret) || []).map(async (val, key) => {
|
|
8169
|
+
const result = { value: val.value, fieldId: val.fieldId };
|
|
8170
|
+
if (!val.fieldId) return result;
|
|
8171
|
+
|
|
8172
|
+
if (val.fieldId.startsWith('_THIS') && calling_fieldIdP) {
|
|
8173
|
+
result.fieldId = val.fieldId.length === 5 ? calling_fieldIdP : calling_fieldIdP + val.fieldId.slice(5);
|
|
8174
|
+
}
|
|
8175
|
+
|
|
8176
|
+
const { ret: fetchedValue, fieldIdP } = await func.datasource.get_value(SESSION_ID, result.fieldId, dsSessionP, rowIdP);
|
|
8177
|
+
result.value = fetchedValue?.value ?? (sourceP === 'exp' ? fetchedValue?.value : '""');
|
|
8178
|
+
result.type = fetchedValue?.type;
|
|
8179
|
+
|
|
8180
|
+
if (iterate_info) {
|
|
8181
|
+
if (iterate_info.iterator_key === fieldIdP) result.value = iterate_info._key;
|
|
8182
|
+
if (iterate_info.iterator_val === fieldIdP) result.value = iterate_info._val;
|
|
8183
|
+
}
|
|
8184
|
+
|
|
8185
|
+
if (val.value.includes('[') || val.value.includes('.')) {
|
|
8186
|
+
const { property1, property2 } = await func.expression.get_property(val.value);
|
|
8187
|
+
const data = fetchedValue?.type === 'object' ? fetchedValue.value : fetchedValue?.prop;
|
|
8188
|
+
|
|
8189
|
+
if (key > 0 && val.value.includes(']') && !val.value.includes('[') && var_Arr[key - 1]?.value) {
|
|
8190
|
+
const prevData = var_Arr[key - 1].value;
|
|
8191
|
+
result.value = prevData[fieldIdP] ?? '';
|
|
8192
|
+
if (val.value.includes('.') && prevData[fieldIdP]) result.value = prevData[fieldIdP][property2] ?? '';
|
|
8193
|
+
} else if (data) {
|
|
8194
|
+
if (property1) result.value = data[property1] ?? '';
|
|
8195
|
+
if (property2) result.value = (property1 ? data[property1]?.[property2] : data[property2]) ?? '';
|
|
8196
|
+
}
|
|
8197
|
+
}
|
|
8198
|
+
fields[fieldIdP] = result.value;
|
|
8199
|
+
return result;
|
|
8200
|
+
}),
|
|
8201
|
+
);
|
|
8202
|
+
|
|
8203
|
+
try {
|
|
8204
|
+
const res = var_Arr.map((val, key) => {
|
|
8205
|
+
if (sourceP === 'UI Property EXP' || sourceP === 'UI Attr EXP') {
|
|
8206
|
+
const { changed, value } = func.utils.get_drive_url(SESSION_ID, val.value, sourceP === 'UI Property EXP' || var_Arr.length > 1);
|
|
8207
|
+
if (changed) return value;
|
|
8208
|
+
}
|
|
8209
|
+
|
|
8210
|
+
let value = val.value;
|
|
8211
|
+
if (var_Arr.length > 1) {
|
|
8212
|
+
if (!['DbQuery', 'alert', 'exp', 'api_rendered_output'].includes(sourceP) && ['string', 'date'].includes(val.type)) {
|
|
8213
|
+
value = `\`${value}\``;
|
|
8214
|
+
} else if (sourceP === 'api_rendered_output' && api_output_type === 'json' && ['string', 'date'].includes(val.type)) {
|
|
8215
|
+
value = `"${value}"`;
|
|
8216
|
+
}
|
|
8217
|
+
}
|
|
8218
|
+
|
|
8219
|
+
if (val.fieldId && typeof value === 'string') {
|
|
8220
|
+
if (['query', 'condition', 'range', 'sort', 'locate'].includes(sourceP)) value = value.replace(/↵|\r\n|\n|\r/g, '');
|
|
8221
|
+
if (['init', 'update', 'virtual'].includes(sourceP)) value = value.replace(/↵|\r\n|\n|\r/g, '\\n');
|
|
8222
|
+
if (typeof IS_PROCESS_SERVER !== 'undefined') value = value.replace(/↵|\r\n|\n|\r/g, '<br>');
|
|
8223
|
+
fields[val.fieldId] = value;
|
|
8224
|
+
}
|
|
8225
|
+
|
|
8226
|
+
if (typeof value === 'object' && var_Arr.length > 1) {
|
|
8227
|
+
value = Array.isArray(value) || var_Arr[key + 1]?.value?.includes('.') ? JSON.stringify(value) : `(${JSON.stringify(value)})`;
|
|
8228
|
+
}
|
|
8229
|
+
|
|
8230
|
+
if (val.type !== 'exp' && sourceP !== 'exp' && typeof value === 'string' && value.startsWith('@')) {
|
|
8231
|
+
warning = `Error encoding ${value}`;
|
|
8232
|
+
var_error_found = true;
|
|
8233
|
+
return '0';
|
|
8234
|
+
}
|
|
8235
|
+
return value;
|
|
8236
|
+
});
|
|
8237
|
+
|
|
8238
|
+
ret = res.length === 1 ? res[0] : res.join('');
|
|
8239
|
+
if (var_Arr.some((v) => v.type === 'exp') && sourceP !== 'exp' && !secondPassP) {
|
|
8240
|
+
const exp = await func.expression.get(SESSION_ID, ret, dsSessionP, sourceP, rowIdP, sourceActionP, true, calling_fieldIdP, fields, debug_infoP);
|
|
8241
|
+
ret = exp.res?.[0] ?? exp.result;
|
|
8242
|
+
Object.assign(fields, exp.fields);
|
|
8243
|
+
} else if (!secondPassP && !['arguments', 'api_rendered_output', 'DbQuery'].includes(sourceP)) {
|
|
8244
|
+
ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
8245
|
+
} else if (sourceP === 'DbQuery') {
|
|
8246
|
+
ret = JSON.stringify(evalJson(ret));
|
|
8247
|
+
}
|
|
8248
|
+
|
|
8249
|
+
if (typeof ret === 'string' && ret.startsWith('@')) {
|
|
8250
|
+
error = 'Error encoding @ var';
|
|
8251
|
+
var_error_found = true;
|
|
8252
|
+
}
|
|
8253
|
+
} catch (err) {
|
|
8254
|
+
error = err.message;
|
|
8255
|
+
}
|
|
8256
|
+
|
|
8257
|
+
return endResults();
|
|
8258
|
+
}
|
|
8259
|
+
}
|
|
8260
|
+
|
|
8261
|
+
return new xu_class().get();
|
|
8262
|
+
};
|
|
8263
|
+
|
|
8264
|
+
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) {
|
|
8111
8265
|
const evalJson = (text) => eval(`(${text})`);
|
|
8112
8266
|
const replaceQuotes = (str) => {
|
|
8113
8267
|
for (const [key, val] of Object.entries(fields)) {
|
|
@@ -8401,7 +8555,7 @@ func.expression.parse = function (input) {
|
|
|
8401
8555
|
return segments;
|
|
8402
8556
|
};
|
|
8403
8557
|
|
|
8404
|
-
func.expression.
|
|
8558
|
+
func.expression.get_property = async function (valP) {
|
|
8405
8559
|
async function secure_eval(val) {
|
|
8406
8560
|
if (typeof IS_PROCESS_SERVER === 'undefined') {
|
|
8407
8561
|
try {
|
|
@@ -8440,7 +8594,7 @@ func.expression.get_property_org = async function (valP) {
|
|
|
8440
8594
|
};
|
|
8441
8595
|
};
|
|
8442
8596
|
|
|
8443
|
-
func.expression.
|
|
8597
|
+
func.expression.get_property_bad = async function (valP) {
|
|
8444
8598
|
if (typeof valP !== 'string') return { property1: undefined, property2: undefined };
|
|
8445
8599
|
|
|
8446
8600
|
const secureEval = async (expr) => {
|
|
@@ -8485,31 +8639,31 @@ func.expression.get_property = async function (valP) {
|
|
|
8485
8639
|
return { property1, property2 };
|
|
8486
8640
|
};
|
|
8487
8641
|
|
|
8488
|
-
func.expression.
|
|
8642
|
+
func.expression.validate_constant = function (valP) {
|
|
8489
8643
|
var patt = /["']/;
|
|
8490
8644
|
if (typeof valP === 'string' && patt.test(valP.substr(0, 1)) && patt.test(valP.substr(0, valP.length - 1))) return true;
|
|
8491
8645
|
else return false;
|
|
8492
8646
|
};
|
|
8493
|
-
func.expression.
|
|
8647
|
+
func.expression.validate_variables = function (valP) {
|
|
8494
8648
|
if (typeof valP === 'string' && valP.indexOf('@') > -1) return true;
|
|
8495
8649
|
else return false;
|
|
8496
8650
|
};
|
|
8497
|
-
func.expression.
|
|
8651
|
+
func.expression.remove_quotes = function (valP) {
|
|
8498
8652
|
if (func.expression.validate_constant(valP)) return valP.substr(1, valP.length - 2);
|
|
8499
8653
|
else return valP;
|
|
8500
8654
|
};
|
|
8501
8655
|
|
|
8502
|
-
func.expression.validate_constant = function (valP) {
|
|
8503
|
-
|
|
8504
|
-
};
|
|
8656
|
+
// func.expression.validate_constant = function (valP) {
|
|
8657
|
+
// typeof valP === 'string' && /^["'].*["']$/.test(valP);
|
|
8658
|
+
// };
|
|
8505
8659
|
|
|
8506
|
-
func.expression.validate_variables = function (valP) {
|
|
8507
|
-
|
|
8508
|
-
};
|
|
8660
|
+
// func.expression.validate_variables = function (valP) {
|
|
8661
|
+
// typeof valP === 'string' && valP.includes('@');
|
|
8662
|
+
// };
|
|
8509
8663
|
|
|
8510
|
-
func.expression.remove_quotes = function (valP) {
|
|
8511
|
-
|
|
8512
|
-
};
|
|
8664
|
+
// func.expression.remove_quotes = function (valP) {
|
|
8665
|
+
// func.expression.validate_constant(valP) && typeof valP === 'string' ? valP.slice(1, -1) : valP;
|
|
8666
|
+
// };
|
|
8513
8667
|
|
|
8514
8668
|
func.expression.secure_eval_org = async function (SESSION_ID, sourceP, val, job_id, dsSessionP, js_script_callback, evt) {
|
|
8515
8669
|
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
package/js/xuda-worker-bundle.js
CHANGED
|
@@ -7753,7 +7753,7 @@ func.events.invoke = async function (event_id) {
|
|
|
7753
7753
|
};
|
|
7754
7754
|
func.expression = {};
|
|
7755
7755
|
|
|
7756
|
-
func.expression.
|
|
7756
|
+
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) {
|
|
7757
7757
|
class xu_class {
|
|
7758
7758
|
async get() {
|
|
7759
7759
|
var ret;
|
|
@@ -8107,7 +8107,161 @@ func.expression.get = async function (SESSION_ID, valP, dsSessionP, sourceP, row
|
|
|
8107
8107
|
return new_class.get();
|
|
8108
8108
|
};
|
|
8109
8109
|
|
|
8110
|
-
func.expression.
|
|
8110
|
+
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) {
|
|
8111
|
+
class xu_class {
|
|
8112
|
+
async get() {
|
|
8113
|
+
let ret, error, warning, var_error_found;
|
|
8114
|
+
const fields = { ...fieldsP };
|
|
8115
|
+
const evalJson = (text) => eval(`(${text})`);
|
|
8116
|
+
|
|
8117
|
+
// Initial value processing
|
|
8118
|
+
ret = valP === null || typeof valP === 'undefined' ? '' : typeof valP === 'boolean' ? (valP ? 'Y' : 'N') : valP.toString();
|
|
8119
|
+
ret = ret.replace(/\&/g, '&').replace(func.utils.replace_studio_drive_url(SESSION_ID, ret));
|
|
8120
|
+
|
|
8121
|
+
const endResults = () => {
|
|
8122
|
+
if (['update', 'javascript'].includes(sourceP) && typeof ret === 'string') {
|
|
8123
|
+
for (const [key, val] of Object.entries(fields)) {
|
|
8124
|
+
if (typeof val === 'string') ret = ret.replace(`"${val}"`, val.replace(/"/g, ''));
|
|
8125
|
+
}
|
|
8126
|
+
}
|
|
8127
|
+
if (error && SESSION_OBJ[SESSION_ID]?.DS_GLB[dsSessionP]) {
|
|
8128
|
+
func.utils.debug.log(SESSION_ID, SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].nodeId, {
|
|
8129
|
+
module: 'expression',
|
|
8130
|
+
action: sourceP,
|
|
8131
|
+
source: calling_fieldIdP,
|
|
8132
|
+
prop: ret,
|
|
8133
|
+
details: ret,
|
|
8134
|
+
result: ret,
|
|
8135
|
+
error,
|
|
8136
|
+
warning,
|
|
8137
|
+
fields: null,
|
|
8138
|
+
type: 'exp',
|
|
8139
|
+
prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
8140
|
+
debug_info: debug_infoP,
|
|
8141
|
+
});
|
|
8142
|
+
}
|
|
8143
|
+
return { result: ret, fields, error, warning, req: valP, var_error_found };
|
|
8144
|
+
};
|
|
8145
|
+
|
|
8146
|
+
const handleNonVariable = async () => {
|
|
8147
|
+
try {
|
|
8148
|
+
if (sourceP !== 'arguments') {
|
|
8149
|
+
if (ret.startsWith('_DATE_')) ret = ret.slice(6);
|
|
8150
|
+
else if (/^\d{4}-\d{2}-\d{2}$/.test(ret) || ret === 'self') return endResults();
|
|
8151
|
+
else ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
8152
|
+
} else {
|
|
8153
|
+
ret = ret.replace(/_NULL/gi, '');
|
|
8154
|
+
}
|
|
8155
|
+
return endResults();
|
|
8156
|
+
} catch (err) {
|
|
8157
|
+
error = err.message;
|
|
8158
|
+
return endResults();
|
|
8159
|
+
}
|
|
8160
|
+
};
|
|
8161
|
+
|
|
8162
|
+
if (!func.expression.validate_variables(valP)) return await handleNonVariable();
|
|
8163
|
+
if (glb.emailRegex.test(await func.expression.secure_eval(SESSION_ID, sourceP, valP, jobNo, dsSessionP, js_script_callback))) {
|
|
8164
|
+
return await handleNonVariable();
|
|
8165
|
+
}
|
|
8166
|
+
|
|
8167
|
+
const var_Arr = await Promise.all(
|
|
8168
|
+
(func.expression.parse(ret) || []).map(async (val, key) => {
|
|
8169
|
+
const result = { value: val.value, fieldId: val.fieldId };
|
|
8170
|
+
if (!val.fieldId) return result;
|
|
8171
|
+
|
|
8172
|
+
if (val.fieldId.startsWith('_THIS') && calling_fieldIdP) {
|
|
8173
|
+
result.fieldId = val.fieldId.length === 5 ? calling_fieldIdP : calling_fieldIdP + val.fieldId.slice(5);
|
|
8174
|
+
}
|
|
8175
|
+
|
|
8176
|
+
const { ret: fetchedValue, fieldIdP } = await func.datasource.get_value(SESSION_ID, result.fieldId, dsSessionP, rowIdP);
|
|
8177
|
+
result.value = fetchedValue?.value ?? (sourceP === 'exp' ? fetchedValue?.value : '""');
|
|
8178
|
+
result.type = fetchedValue?.type;
|
|
8179
|
+
|
|
8180
|
+
if (iterate_info) {
|
|
8181
|
+
if (iterate_info.iterator_key === fieldIdP) result.value = iterate_info._key;
|
|
8182
|
+
if (iterate_info.iterator_val === fieldIdP) result.value = iterate_info._val;
|
|
8183
|
+
}
|
|
8184
|
+
|
|
8185
|
+
if (val.value.includes('[') || val.value.includes('.')) {
|
|
8186
|
+
const { property1, property2 } = await func.expression.get_property(val.value);
|
|
8187
|
+
const data = fetchedValue?.type === 'object' ? fetchedValue.value : fetchedValue?.prop;
|
|
8188
|
+
|
|
8189
|
+
if (key > 0 && val.value.includes(']') && !val.value.includes('[') && var_Arr[key - 1]?.value) {
|
|
8190
|
+
const prevData = var_Arr[key - 1].value;
|
|
8191
|
+
result.value = prevData[fieldIdP] ?? '';
|
|
8192
|
+
if (val.value.includes('.') && prevData[fieldIdP]) result.value = prevData[fieldIdP][property2] ?? '';
|
|
8193
|
+
} else if (data) {
|
|
8194
|
+
if (property1) result.value = data[property1] ?? '';
|
|
8195
|
+
if (property2) result.value = (property1 ? data[property1]?.[property2] : data[property2]) ?? '';
|
|
8196
|
+
}
|
|
8197
|
+
}
|
|
8198
|
+
fields[fieldIdP] = result.value;
|
|
8199
|
+
return result;
|
|
8200
|
+
}),
|
|
8201
|
+
);
|
|
8202
|
+
|
|
8203
|
+
try {
|
|
8204
|
+
const res = var_Arr.map((val, key) => {
|
|
8205
|
+
if (sourceP === 'UI Property EXP' || sourceP === 'UI Attr EXP') {
|
|
8206
|
+
const { changed, value } = func.utils.get_drive_url(SESSION_ID, val.value, sourceP === 'UI Property EXP' || var_Arr.length > 1);
|
|
8207
|
+
if (changed) return value;
|
|
8208
|
+
}
|
|
8209
|
+
|
|
8210
|
+
let value = val.value;
|
|
8211
|
+
if (var_Arr.length > 1) {
|
|
8212
|
+
if (!['DbQuery', 'alert', 'exp', 'api_rendered_output'].includes(sourceP) && ['string', 'date'].includes(val.type)) {
|
|
8213
|
+
value = `\`${value}\``;
|
|
8214
|
+
} else if (sourceP === 'api_rendered_output' && api_output_type === 'json' && ['string', 'date'].includes(val.type)) {
|
|
8215
|
+
value = `"${value}"`;
|
|
8216
|
+
}
|
|
8217
|
+
}
|
|
8218
|
+
|
|
8219
|
+
if (val.fieldId && typeof value === 'string') {
|
|
8220
|
+
if (['query', 'condition', 'range', 'sort', 'locate'].includes(sourceP)) value = value.replace(/↵|\r\n|\n|\r/g, '');
|
|
8221
|
+
if (['init', 'update', 'virtual'].includes(sourceP)) value = value.replace(/↵|\r\n|\n|\r/g, '\\n');
|
|
8222
|
+
if (typeof IS_PROCESS_SERVER !== 'undefined') value = value.replace(/↵|\r\n|\n|\r/g, '<br>');
|
|
8223
|
+
fields[val.fieldId] = value;
|
|
8224
|
+
}
|
|
8225
|
+
|
|
8226
|
+
if (typeof value === 'object' && var_Arr.length > 1) {
|
|
8227
|
+
value = Array.isArray(value) || var_Arr[key + 1]?.value?.includes('.') ? JSON.stringify(value) : `(${JSON.stringify(value)})`;
|
|
8228
|
+
}
|
|
8229
|
+
|
|
8230
|
+
if (val.type !== 'exp' && sourceP !== 'exp' && typeof value === 'string' && value.startsWith('@')) {
|
|
8231
|
+
warning = `Error encoding ${value}`;
|
|
8232
|
+
var_error_found = true;
|
|
8233
|
+
return '0';
|
|
8234
|
+
}
|
|
8235
|
+
return value;
|
|
8236
|
+
});
|
|
8237
|
+
|
|
8238
|
+
ret = res.length === 1 ? res[0] : res.join('');
|
|
8239
|
+
if (var_Arr.some((v) => v.type === 'exp') && sourceP !== 'exp' && !secondPassP) {
|
|
8240
|
+
const exp = await func.expression.get(SESSION_ID, ret, dsSessionP, sourceP, rowIdP, sourceActionP, true, calling_fieldIdP, fields, debug_infoP);
|
|
8241
|
+
ret = exp.res?.[0] ?? exp.result;
|
|
8242
|
+
Object.assign(fields, exp.fields);
|
|
8243
|
+
} else if (!secondPassP && !['arguments', 'api_rendered_output', 'DbQuery'].includes(sourceP)) {
|
|
8244
|
+
ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
8245
|
+
} else if (sourceP === 'DbQuery') {
|
|
8246
|
+
ret = JSON.stringify(evalJson(ret));
|
|
8247
|
+
}
|
|
8248
|
+
|
|
8249
|
+
if (typeof ret === 'string' && ret.startsWith('@')) {
|
|
8250
|
+
error = 'Error encoding @ var';
|
|
8251
|
+
var_error_found = true;
|
|
8252
|
+
}
|
|
8253
|
+
} catch (err) {
|
|
8254
|
+
error = err.message;
|
|
8255
|
+
}
|
|
8256
|
+
|
|
8257
|
+
return endResults();
|
|
8258
|
+
}
|
|
8259
|
+
}
|
|
8260
|
+
|
|
8261
|
+
return new xu_class().get();
|
|
8262
|
+
};
|
|
8263
|
+
|
|
8264
|
+
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) {
|
|
8111
8265
|
const evalJson = (text) => eval(`(${text})`);
|
|
8112
8266
|
const replaceQuotes = (str) => {
|
|
8113
8267
|
for (const [key, val] of Object.entries(fields)) {
|
|
@@ -8401,7 +8555,7 @@ func.expression.parse = function (input) {
|
|
|
8401
8555
|
return segments;
|
|
8402
8556
|
};
|
|
8403
8557
|
|
|
8404
|
-
func.expression.
|
|
8558
|
+
func.expression.get_property = async function (valP) {
|
|
8405
8559
|
async function secure_eval(val) {
|
|
8406
8560
|
if (typeof IS_PROCESS_SERVER === 'undefined') {
|
|
8407
8561
|
try {
|
|
@@ -8440,7 +8594,7 @@ func.expression.get_property_org = async function (valP) {
|
|
|
8440
8594
|
};
|
|
8441
8595
|
};
|
|
8442
8596
|
|
|
8443
|
-
func.expression.
|
|
8597
|
+
func.expression.get_property_bad = async function (valP) {
|
|
8444
8598
|
if (typeof valP !== 'string') return { property1: undefined, property2: undefined };
|
|
8445
8599
|
|
|
8446
8600
|
const secureEval = async (expr) => {
|
|
@@ -8485,31 +8639,31 @@ func.expression.get_property = async function (valP) {
|
|
|
8485
8639
|
return { property1, property2 };
|
|
8486
8640
|
};
|
|
8487
8641
|
|
|
8488
|
-
func.expression.
|
|
8642
|
+
func.expression.validate_constant = function (valP) {
|
|
8489
8643
|
var patt = /["']/;
|
|
8490
8644
|
if (typeof valP === 'string' && patt.test(valP.substr(0, 1)) && patt.test(valP.substr(0, valP.length - 1))) return true;
|
|
8491
8645
|
else return false;
|
|
8492
8646
|
};
|
|
8493
|
-
func.expression.
|
|
8647
|
+
func.expression.validate_variables = function (valP) {
|
|
8494
8648
|
if (typeof valP === 'string' && valP.indexOf('@') > -1) return true;
|
|
8495
8649
|
else return false;
|
|
8496
8650
|
};
|
|
8497
|
-
func.expression.
|
|
8651
|
+
func.expression.remove_quotes = function (valP) {
|
|
8498
8652
|
if (func.expression.validate_constant(valP)) return valP.substr(1, valP.length - 2);
|
|
8499
8653
|
else return valP;
|
|
8500
8654
|
};
|
|
8501
8655
|
|
|
8502
|
-
func.expression.validate_constant = function (valP) {
|
|
8503
|
-
|
|
8504
|
-
};
|
|
8656
|
+
// func.expression.validate_constant = function (valP) {
|
|
8657
|
+
// typeof valP === 'string' && /^["'].*["']$/.test(valP);
|
|
8658
|
+
// };
|
|
8505
8659
|
|
|
8506
|
-
func.expression.validate_variables = function (valP) {
|
|
8507
|
-
|
|
8508
|
-
};
|
|
8660
|
+
// func.expression.validate_variables = function (valP) {
|
|
8661
|
+
// typeof valP === 'string' && valP.includes('@');
|
|
8662
|
+
// };
|
|
8509
8663
|
|
|
8510
|
-
func.expression.remove_quotes = function (valP) {
|
|
8511
|
-
|
|
8512
|
-
};
|
|
8664
|
+
// func.expression.remove_quotes = function (valP) {
|
|
8665
|
+
// func.expression.validate_constant(valP) && typeof valP === 'string' ? valP.slice(1, -1) : valP;
|
|
8666
|
+
// };
|
|
8513
8667
|
|
|
8514
8668
|
func.expression.secure_eval_org = async function (SESSION_ID, sourceP, val, job_id, dsSessionP, js_script_callback, evt) {
|
|
8515
8669
|
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|