@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.
@@ -34917,7 +34917,7 @@ func.UI.component.init_xu_nav = function ($container, $nav) {
34917
34917
  };
34918
34918
  func.expression = {};
34919
34919
 
34920
- 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) {
34920
+ 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) {
34921
34921
  class xu_class {
34922
34922
  async get() {
34923
34923
  var ret;
@@ -35271,7 +35271,161 @@ func.expression.get = async function (SESSION_ID, valP, dsSessionP, sourceP, row
35271
35271
  return new_class.get();
35272
35272
  };
35273
35273
 
35274
- func.expression.get_bad = async function (SESSION_ID, valP, dsSessionP, sourceP, rowIdP, sourceActionP, secondPassP, calling_fieldIdP, fieldsP = {}, debug_infoP, iterate_info, js_script_callback, jobNo, api_output_type) {
35274
+ 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) {
35275
+ class xu_class {
35276
+ async get() {
35277
+ let ret, error, warning, var_error_found;
35278
+ const fields = { ...fieldsP };
35279
+ const evalJson = (text) => eval(`(${text})`);
35280
+
35281
+ // Initial value processing
35282
+ ret = valP === null || typeof valP === 'undefined' ? '' : typeof valP === 'boolean' ? (valP ? 'Y' : 'N') : valP.toString();
35283
+ ret = ret.replace(/\&/g, '&').replace(func.utils.replace_studio_drive_url(SESSION_ID, ret));
35284
+
35285
+ const endResults = () => {
35286
+ if (['update', 'javascript'].includes(sourceP) && typeof ret === 'string') {
35287
+ for (const [key, val] of Object.entries(fields)) {
35288
+ if (typeof val === 'string') ret = ret.replace(`"${val}"`, val.replace(/"/g, ''));
35289
+ }
35290
+ }
35291
+ if (error && SESSION_OBJ[SESSION_ID]?.DS_GLB[dsSessionP]) {
35292
+ func.utils.debug.log(SESSION_ID, SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].nodeId, {
35293
+ module: 'expression',
35294
+ action: sourceP,
35295
+ source: calling_fieldIdP,
35296
+ prop: ret,
35297
+ details: ret,
35298
+ result: ret,
35299
+ error,
35300
+ warning,
35301
+ fields: null,
35302
+ type: 'exp',
35303
+ prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
35304
+ debug_info: debug_infoP,
35305
+ });
35306
+ }
35307
+ return { result: ret, fields, error, warning, req: valP, var_error_found };
35308
+ };
35309
+
35310
+ const handleNonVariable = async () => {
35311
+ try {
35312
+ if (sourceP !== 'arguments') {
35313
+ if (ret.startsWith('_DATE_')) ret = ret.slice(6);
35314
+ else if (/^\d{4}-\d{2}-\d{2}$/.test(ret) || ret === 'self') return endResults();
35315
+ else ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
35316
+ } else {
35317
+ ret = ret.replace(/_NULL/gi, '');
35318
+ }
35319
+ return endResults();
35320
+ } catch (err) {
35321
+ error = err.message;
35322
+ return endResults();
35323
+ }
35324
+ };
35325
+
35326
+ if (!func.expression.validate_variables(valP)) return await handleNonVariable();
35327
+ if (glb.emailRegex.test(await func.expression.secure_eval(SESSION_ID, sourceP, valP, jobNo, dsSessionP, js_script_callback))) {
35328
+ return await handleNonVariable();
35329
+ }
35330
+
35331
+ const var_Arr = await Promise.all(
35332
+ (func.expression.parse(ret) || []).map(async (val, key) => {
35333
+ const result = { value: val.value, fieldId: val.fieldId };
35334
+ if (!val.fieldId) return result;
35335
+
35336
+ if (val.fieldId.startsWith('_THIS') && calling_fieldIdP) {
35337
+ result.fieldId = val.fieldId.length === 5 ? calling_fieldIdP : calling_fieldIdP + val.fieldId.slice(5);
35338
+ }
35339
+
35340
+ const { ret: fetchedValue, fieldIdP } = await func.datasource.get_value(SESSION_ID, result.fieldId, dsSessionP, rowIdP);
35341
+ result.value = fetchedValue?.value ?? (sourceP === 'exp' ? fetchedValue?.value : '""');
35342
+ result.type = fetchedValue?.type;
35343
+
35344
+ if (iterate_info) {
35345
+ if (iterate_info.iterator_key === fieldIdP) result.value = iterate_info._key;
35346
+ if (iterate_info.iterator_val === fieldIdP) result.value = iterate_info._val;
35347
+ }
35348
+
35349
+ if (val.value.includes('[') || val.value.includes('.')) {
35350
+ const { property1, property2 } = await func.expression.get_property(val.value);
35351
+ const data = fetchedValue?.type === 'object' ? fetchedValue.value : fetchedValue?.prop;
35352
+
35353
+ if (key > 0 && val.value.includes(']') && !val.value.includes('[') && var_Arr[key - 1]?.value) {
35354
+ const prevData = var_Arr[key - 1].value;
35355
+ result.value = prevData[fieldIdP] ?? '';
35356
+ if (val.value.includes('.') && prevData[fieldIdP]) result.value = prevData[fieldIdP][property2] ?? '';
35357
+ } else if (data) {
35358
+ if (property1) result.value = data[property1] ?? '';
35359
+ if (property2) result.value = (property1 ? data[property1]?.[property2] : data[property2]) ?? '';
35360
+ }
35361
+ }
35362
+ fields[fieldIdP] = result.value;
35363
+ return result;
35364
+ }),
35365
+ );
35366
+
35367
+ try {
35368
+ const res = var_Arr.map((val, key) => {
35369
+ if (sourceP === 'UI Property EXP' || sourceP === 'UI Attr EXP') {
35370
+ const { changed, value } = func.utils.get_drive_url(SESSION_ID, val.value, sourceP === 'UI Property EXP' || var_Arr.length > 1);
35371
+ if (changed) return value;
35372
+ }
35373
+
35374
+ let value = val.value;
35375
+ if (var_Arr.length > 1) {
35376
+ if (!['DbQuery', 'alert', 'exp', 'api_rendered_output'].includes(sourceP) && ['string', 'date'].includes(val.type)) {
35377
+ value = `\`${value}\``;
35378
+ } else if (sourceP === 'api_rendered_output' && api_output_type === 'json' && ['string', 'date'].includes(val.type)) {
35379
+ value = `"${value}"`;
35380
+ }
35381
+ }
35382
+
35383
+ if (val.fieldId && typeof value === 'string') {
35384
+ if (['query', 'condition', 'range', 'sort', 'locate'].includes(sourceP)) value = value.replace(/↵|\r\n|\n|\r/g, '');
35385
+ if (['init', 'update', 'virtual'].includes(sourceP)) value = value.replace(/↵|\r\n|\n|\r/g, '\\n');
35386
+ if (typeof IS_PROCESS_SERVER !== 'undefined') value = value.replace(/↵|\r\n|\n|\r/g, '<br>');
35387
+ fields[val.fieldId] = value;
35388
+ }
35389
+
35390
+ if (typeof value === 'object' && var_Arr.length > 1) {
35391
+ value = Array.isArray(value) || var_Arr[key + 1]?.value?.includes('.') ? JSON.stringify(value) : `(${JSON.stringify(value)})`;
35392
+ }
35393
+
35394
+ if (val.type !== 'exp' && sourceP !== 'exp' && typeof value === 'string' && value.startsWith('@')) {
35395
+ warning = `Error encoding ${value}`;
35396
+ var_error_found = true;
35397
+ return '0';
35398
+ }
35399
+ return value;
35400
+ });
35401
+
35402
+ ret = res.length === 1 ? res[0] : res.join('');
35403
+ if (var_Arr.some((v) => v.type === 'exp') && sourceP !== 'exp' && !secondPassP) {
35404
+ const exp = await func.expression.get(SESSION_ID, ret, dsSessionP, sourceP, rowIdP, sourceActionP, true, calling_fieldIdP, fields, debug_infoP);
35405
+ ret = exp.res?.[0] ?? exp.result;
35406
+ Object.assign(fields, exp.fields);
35407
+ } else if (!secondPassP && !['arguments', 'api_rendered_output', 'DbQuery'].includes(sourceP)) {
35408
+ ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
35409
+ } else if (sourceP === 'DbQuery') {
35410
+ ret = JSON.stringify(evalJson(ret));
35411
+ }
35412
+
35413
+ if (typeof ret === 'string' && ret.startsWith('@')) {
35414
+ error = 'Error encoding @ var';
35415
+ var_error_found = true;
35416
+ }
35417
+ } catch (err) {
35418
+ error = err.message;
35419
+ }
35420
+
35421
+ return endResults();
35422
+ }
35423
+ }
35424
+
35425
+ return new xu_class().get();
35426
+ };
35427
+
35428
+ 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) {
35275
35429
  const evalJson = (text) => eval(`(${text})`);
35276
35430
  const replaceQuotes = (str) => {
35277
35431
  for (const [key, val] of Object.entries(fields)) {
@@ -35565,7 +35719,7 @@ func.expression.parse = function (input) {
35565
35719
  return segments;
35566
35720
  };
35567
35721
 
35568
- func.expression.get_property_org = async function (valP) {
35722
+ func.expression.get_property = async function (valP) {
35569
35723
  async function secure_eval(val) {
35570
35724
  if (typeof IS_PROCESS_SERVER === 'undefined') {
35571
35725
  try {
@@ -35604,7 +35758,7 @@ func.expression.get_property_org = async function (valP) {
35604
35758
  };
35605
35759
  };
35606
35760
 
35607
- func.expression.get_property = async function (valP) {
35761
+ func.expression.get_property_bad = async function (valP) {
35608
35762
  if (typeof valP !== 'string') return { property1: undefined, property2: undefined };
35609
35763
 
35610
35764
  const secureEval = async (expr) => {
@@ -35649,31 +35803,31 @@ func.expression.get_property = async function (valP) {
35649
35803
  return { property1, property2 };
35650
35804
  };
35651
35805
 
35652
- func.expression.validate_constant_org = function (valP) {
35806
+ func.expression.validate_constant = function (valP) {
35653
35807
  var patt = /["']/;
35654
35808
  if (typeof valP === 'string' && patt.test(valP.substr(0, 1)) && patt.test(valP.substr(0, valP.length - 1))) return true;
35655
35809
  else return false;
35656
35810
  };
35657
- func.expression.validate_variables_org = function (valP) {
35811
+ func.expression.validate_variables = function (valP) {
35658
35812
  if (typeof valP === 'string' && valP.indexOf('@') > -1) return true;
35659
35813
  else return false;
35660
35814
  };
35661
- func.expression.remove_quotes_org = function (valP) {
35815
+ func.expression.remove_quotes = function (valP) {
35662
35816
  if (func.expression.validate_constant(valP)) return valP.substr(1, valP.length - 2);
35663
35817
  else return valP;
35664
35818
  };
35665
35819
 
35666
- func.expression.validate_constant = function (valP) {
35667
- typeof valP === 'string' && /^["'].*["']$/.test(valP);
35668
- };
35820
+ // func.expression.validate_constant = function (valP) {
35821
+ // typeof valP === 'string' && /^["'].*["']$/.test(valP);
35822
+ // };
35669
35823
 
35670
- func.expression.validate_variables = function (valP) {
35671
- typeof valP === 'string' && valP.includes('@');
35672
- };
35824
+ // func.expression.validate_variables = function (valP) {
35825
+ // typeof valP === 'string' && valP.includes('@');
35826
+ // };
35673
35827
 
35674
- func.expression.remove_quotes = function (valP) {
35675
- func.expression.validate_constant(valP) && typeof valP === 'string' ? valP.slice(1, -1) : valP;
35676
- };
35828
+ // func.expression.remove_quotes = function (valP) {
35829
+ // func.expression.validate_constant(valP) && typeof valP === 'string' ? valP.slice(1, -1) : valP;
35830
+ // };
35677
35831
 
35678
35832
  func.expression.secure_eval_org = async function (SESSION_ID, sourceP, val, job_id, dsSessionP, js_script_callback, evt) {
35679
35833
  const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {