@xuda.io/runtime-bundle 1.0.323 → 1.0.325
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 +2 -2
- package/js/modules/xuda-event-javascript-module.mjs +40 -101
- package/js/xuda-runtime-bundle.js +144 -306
- package/js/xuda-runtime-bundle.min.js +3 -3
- package/js/xuda-runtime-slim.js +144 -306
- package/js/xuda-runtime-slim.min.es.js +144 -306
- package/js/xuda-runtime-slim.min.js +3 -3
- package/js/xuda-server-bundle.min.mjs +2 -2
- package/js/xuda-server-bundle.mjs +140 -302
- package/js/xuda-worker-bundle.js +140 -302
- package/js/xuda-worker-bundle.min.js +2 -2
- package/package.json +1 -1
|
@@ -32735,6 +32735,10 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
|
|
|
32735
32735
|
const trigger = val.key.split('xu-on:')[1].toLowerCase();
|
|
32736
32736
|
$elm.on(trigger, async function (evt) {
|
|
32737
32737
|
for await (const [key, val] of Object.entries($elm.data().xuAttributes['xu-on:' + evt.type])) {
|
|
32738
|
+
if (val.event_modifiers && evt[val.event_modifiers]) {
|
|
32739
|
+
evt[val.event_modifiers]();
|
|
32740
|
+
}
|
|
32741
|
+
|
|
32738
32742
|
if (val.handler === 'custom') {
|
|
32739
32743
|
// do BL
|
|
32740
32744
|
for await (const [key2, val2] of Object.entries(val.event)) {
|
|
@@ -32745,10 +32749,6 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
|
|
|
32745
32749
|
}
|
|
32746
32750
|
if (!cond) continue;
|
|
32747
32751
|
|
|
32748
|
-
if (val.event_modifiers && evt[val.event_modifiers]) {
|
|
32749
|
-
evt[val.event_modifiers]();
|
|
32750
|
-
}
|
|
32751
|
-
|
|
32752
32752
|
func.events.add_to_queue(SESSION_ID, 'element event', val2.id, evt.type, val2.data.action, val2.data.name, null, $elm.attr('xu-ui-id'), null, evt, null, null, null, paramsP.dsSessionP, null, null, null, evt.type, val2.data.name, null, null, val2, null, null, null, null, null, null);
|
|
32753
32753
|
}
|
|
32754
32754
|
}
|
|
@@ -35299,22 +35299,7 @@ func.UI.component.init_xu_nav = function ($container, $nav) {
|
|
|
35299
35299
|
};
|
|
35300
35300
|
func.expression = {};
|
|
35301
35301
|
|
|
35302
|
-
func.expression.get = async function (
|
|
35303
|
-
SESSION_ID,
|
|
35304
|
-
valP,
|
|
35305
|
-
dsSessionP,
|
|
35306
|
-
sourceP,
|
|
35307
|
-
rowIdP,
|
|
35308
|
-
sourceActionP,
|
|
35309
|
-
secondPassP,
|
|
35310
|
-
calling_fieldIdP,
|
|
35311
|
-
fieldsP,
|
|
35312
|
-
debug_infoP,
|
|
35313
|
-
iterate_info,
|
|
35314
|
-
js_script_callback,
|
|
35315
|
-
jobNo,
|
|
35316
|
-
api_output_type
|
|
35317
|
-
) {
|
|
35302
|
+
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) {
|
|
35318
35303
|
class xu_class {
|
|
35319
35304
|
async get() {
|
|
35320
35305
|
var ret;
|
|
@@ -35323,23 +35308,23 @@ func.expression.get = async function (
|
|
|
35323
35308
|
var warning;
|
|
35324
35309
|
|
|
35325
35310
|
function evalJson(text) {
|
|
35326
|
-
return eval(
|
|
35311
|
+
return eval('(' + text + ')');
|
|
35327
35312
|
}
|
|
35328
35313
|
|
|
35329
35314
|
if (valP === null) {
|
|
35330
|
-
ret =
|
|
35315
|
+
ret = '';
|
|
35331
35316
|
} else {
|
|
35332
35317
|
switch (typeof valP) {
|
|
35333
|
-
case
|
|
35318
|
+
case 'string':
|
|
35334
35319
|
ret = valP;
|
|
35335
35320
|
break;
|
|
35336
35321
|
|
|
35337
|
-
case
|
|
35338
|
-
ret =
|
|
35322
|
+
case 'undefined':
|
|
35323
|
+
ret = '';
|
|
35339
35324
|
break;
|
|
35340
35325
|
|
|
35341
|
-
case
|
|
35342
|
-
ret = valP ?
|
|
35326
|
+
case 'boolean':
|
|
35327
|
+
ret = valP ? 'Y' : 'N';
|
|
35343
35328
|
break;
|
|
35344
35329
|
|
|
35345
35330
|
default:
|
|
@@ -35348,40 +35333,35 @@ func.expression.get = async function (
|
|
|
35348
35333
|
}
|
|
35349
35334
|
}
|
|
35350
35335
|
|
|
35351
|
-
ret = ret.replace(/\&/g,
|
|
35336
|
+
ret = ret.replace(/\&/g, '&');
|
|
35352
35337
|
ret = func.utils.replace_studio_drive_url(SESSION_ID, ret);
|
|
35353
35338
|
|
|
35354
35339
|
const end_results = function () {
|
|
35355
35340
|
const replace_quotes = function (ret) {
|
|
35356
35341
|
for (const [key, val] of Object.entries(fields)) {
|
|
35357
|
-
if (typeof val ===
|
|
35358
|
-
ret = ret.replace('"' + val + '"', val.replace(/"/gi, ""));
|
|
35342
|
+
if (typeof val === 'string') ret = ret.replace('"' + val + '"', val.replace(/"/gi, ''));
|
|
35359
35343
|
}
|
|
35360
35344
|
return ret;
|
|
35361
35345
|
};
|
|
35362
|
-
if ([
|
|
35363
|
-
if (typeof ret ===
|
|
35346
|
+
if (['update', 'javascript'].includes(sourceP)) {
|
|
35347
|
+
if (typeof ret === 'string') ret = replace_quotes(ret);
|
|
35364
35348
|
}
|
|
35365
35349
|
const log_error = function () {
|
|
35366
35350
|
if (SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP]) {
|
|
35367
|
-
func.utils.debug.log(
|
|
35368
|
-
|
|
35369
|
-
|
|
35370
|
-
|
|
35371
|
-
|
|
35372
|
-
|
|
35373
|
-
|
|
35374
|
-
|
|
35375
|
-
|
|
35376
|
-
|
|
35377
|
-
|
|
35378
|
-
|
|
35379
|
-
|
|
35380
|
-
|
|
35381
|
-
prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
35382
|
-
debug_info: debug_infoP,
|
|
35383
|
-
}
|
|
35384
|
-
);
|
|
35351
|
+
func.utils.debug.log(SESSION_ID, SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].nodeId, {
|
|
35352
|
+
module: 'expression',
|
|
35353
|
+
action: sourceP,
|
|
35354
|
+
source: calling_fieldIdP,
|
|
35355
|
+
prop: ret,
|
|
35356
|
+
details: ret,
|
|
35357
|
+
result: ret,
|
|
35358
|
+
error: error,
|
|
35359
|
+
warning: warning,
|
|
35360
|
+
fields: null,
|
|
35361
|
+
type: 'exp',
|
|
35362
|
+
prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
35363
|
+
debug_info: debug_infoP,
|
|
35364
|
+
});
|
|
35385
35365
|
}
|
|
35386
35366
|
};
|
|
35387
35367
|
if (error) log_error();
|
|
@@ -35399,32 +35379,22 @@ func.expression.get = async function (
|
|
|
35399
35379
|
};
|
|
35400
35380
|
const variable_not_exist = async function () {
|
|
35401
35381
|
try {
|
|
35402
|
-
if (sourceP !==
|
|
35403
|
-
if (ret && ret.substr(0, 6) ===
|
|
35382
|
+
if (sourceP !== 'arguments') {
|
|
35383
|
+
if (ret && ret.substr(0, 6) === '_DATE_') {
|
|
35404
35384
|
ret = ret.substr(6);
|
|
35405
35385
|
} else if (
|
|
35406
|
-
(ret &&
|
|
35407
|
-
|
|
35408
|
-
ret.substr(4, 1) === "-" &&
|
|
35409
|
-
ret.substr(7, 1) === "-") ||
|
|
35410
|
-
ret === "self" // bypass eval for date 2017-03-22
|
|
35386
|
+
(ret && ret.length === 10 && ret.substr(4, 1) === '-' && ret.substr(7, 1) === '-') ||
|
|
35387
|
+
ret === 'self' // bypass eval for date 2017-03-22
|
|
35411
35388
|
) {
|
|
35412
35389
|
ret = ret;
|
|
35413
35390
|
} else {
|
|
35414
|
-
ret = await func.expression.secure_eval(
|
|
35415
|
-
SESSION_ID,
|
|
35416
|
-
sourceP,
|
|
35417
|
-
ret,
|
|
35418
|
-
jobNo,
|
|
35419
|
-
dsSessionP,
|
|
35420
|
-
js_script_callback
|
|
35421
|
-
);
|
|
35391
|
+
ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
35422
35392
|
}
|
|
35423
35393
|
// console.log("AFTER OK", ret)
|
|
35424
35394
|
return end_results();
|
|
35425
35395
|
} else {
|
|
35426
35396
|
// do eval for arithmetic vals
|
|
35427
|
-
ret = ret.replace(/_NULL/gi,
|
|
35397
|
+
ret = ret.replace(/_NULL/gi, '');
|
|
35428
35398
|
return end_results();
|
|
35429
35399
|
}
|
|
35430
35400
|
} catch (err) {
|
|
@@ -35437,14 +35407,7 @@ func.expression.get = async function (
|
|
|
35437
35407
|
}
|
|
35438
35408
|
|
|
35439
35409
|
const validate_email = async function () {
|
|
35440
|
-
const ret = await func.expression.secure_eval(
|
|
35441
|
-
SESSION_ID,
|
|
35442
|
-
sourceP,
|
|
35443
|
-
valP,
|
|
35444
|
-
jobNo,
|
|
35445
|
-
dsSessionP,
|
|
35446
|
-
js_script_callback
|
|
35447
|
-
);
|
|
35410
|
+
const ret = await func.expression.secure_eval(SESSION_ID, sourceP, valP, jobNo, dsSessionP, js_script_callback);
|
|
35448
35411
|
|
|
35449
35412
|
return glb.emailRegex.test(ret);
|
|
35450
35413
|
};
|
|
@@ -35463,10 +35426,7 @@ func.expression.get = async function (
|
|
|
35463
35426
|
var_Arr[key].value = val.value;
|
|
35464
35427
|
//--------------
|
|
35465
35428
|
const replace_value_in_string = async function (retP, fieldIdP) {
|
|
35466
|
-
if (
|
|
35467
|
-
iterate_info?.iterator_key === fieldIdP ||
|
|
35468
|
-
iterate_info?.iterator_val === fieldIdP
|
|
35469
|
-
) {
|
|
35429
|
+
if (iterate_info?.iterator_key === fieldIdP || iterate_info?.iterator_val === fieldIdP) {
|
|
35470
35430
|
if (iterate_info.iterator_key === fieldIdP) {
|
|
35471
35431
|
retP.value = iterate_info._key;
|
|
35472
35432
|
}
|
|
@@ -35476,50 +35436,43 @@ func.expression.get = async function (
|
|
|
35476
35436
|
}
|
|
35477
35437
|
|
|
35478
35438
|
const set_value = function (valP) {
|
|
35479
|
-
if (typeof valP !==
|
|
35439
|
+
if (typeof valP !== 'undefined') {
|
|
35480
35440
|
var_Arr[key].value = valP;
|
|
35481
|
-
if (typeof valP ===
|
|
35441
|
+
if (typeof valP === 'string') var_Arr[key].type = 'string';
|
|
35482
35442
|
} else {
|
|
35483
|
-
if (retP.type ===
|
|
35484
|
-
var_Arr[key].value =
|
|
35485
|
-
var_Arr[key].type =
|
|
35443
|
+
if (retP.type === 'object') {
|
|
35444
|
+
var_Arr[key].value = '';
|
|
35445
|
+
var_Arr[key].type = 'string';
|
|
35486
35446
|
}
|
|
35487
35447
|
}
|
|
35488
35448
|
};
|
|
35489
35449
|
|
|
35490
|
-
if (sourceP ===
|
|
35450
|
+
if (sourceP === 'exp' && retP.type !== 'exp') {
|
|
35491
35451
|
var_Arr[key].type = retP.type;
|
|
35492
35452
|
return;
|
|
35493
35453
|
}
|
|
35494
|
-
if (typeof retP.value !==
|
|
35454
|
+
if (typeof retP.value !== 'undefined') {
|
|
35495
35455
|
var_Arr[key].type = retP.type;
|
|
35496
35456
|
var_Arr[key].value = retP.value;
|
|
35497
|
-
if ((val.value.indexOf(
|
|
35457
|
+
if ((val.value.indexOf('[') > -1) | (val.value.indexOf('.') > -1)) {
|
|
35498
35458
|
//get values from array '@var==="sss" && @var_B==="sss" && @obj.property===5 && @objA["value"]===123 | @objB["value"].property===1234'
|
|
35499
35459
|
var data = retP.prop;
|
|
35500
|
-
if (retP.type ===
|
|
35460
|
+
if (retP.type === 'object') data = retP.value;
|
|
35501
35461
|
var property1, property2;
|
|
35502
35462
|
//check for split situation: @objB[@var].property 1: @objB[ 2:@var].property
|
|
35503
|
-
if (
|
|
35504
|
-
val.value.indexOf("[") === -1 &&
|
|
35505
|
-
val.value.indexOf("]") > -1 &&
|
|
35506
|
-
val.value.substr(0, 1) === "@"
|
|
35507
|
-
) {
|
|
35463
|
+
if (val.value.indexOf('[') === -1 && val.value.indexOf(']') > -1 && val.value.substr(0, 1) === '@') {
|
|
35508
35464
|
//check situation 2
|
|
35509
35465
|
var prevData = var_Arr[key - 1].value;
|
|
35510
35466
|
var_Arr[key].value = prevData[data]; // @objB[@var]
|
|
35511
|
-
if (val.value.indexOf(
|
|
35512
|
-
property2 = await func.expression.get_property(val.value)
|
|
35513
|
-
.property2; //val.value.substr(val.value.indexOf(".") + 1, val.value.length); // get .
|
|
35467
|
+
if (val.value.indexOf('.') > -1) {
|
|
35468
|
+
property2 = await func.expression.get_property(val.value).property2; //val.value.substr(val.value.indexOf(".") + 1, val.value.length); // get .
|
|
35514
35469
|
if (prevData[data]) set_value(prevData[data][property2]);
|
|
35515
35470
|
// var_Arr[key].value = prevData[data][property2]; //@objB[@var].property
|
|
35516
35471
|
}
|
|
35517
35472
|
delete var_Arr[key - 1];
|
|
35518
35473
|
} else {
|
|
35519
|
-
property1 = await func.expression.get_property(val.value)
|
|
35520
|
-
|
|
35521
|
-
property2 = await func.expression.get_property(val.value)
|
|
35522
|
-
.property2;
|
|
35474
|
+
property1 = await func.expression.get_property(val.value).property1;
|
|
35475
|
+
property2 = await func.expression.get_property(val.value).property2;
|
|
35523
35476
|
if (property1) {
|
|
35524
35477
|
var_Arr[key].value = data[property1]; // @var["value"] or @var.property
|
|
35525
35478
|
if (property2) {
|
|
@@ -35547,19 +35500,11 @@ func.expression.get = async function (
|
|
|
35547
35500
|
//>>>>>>>>>>>>>>>>>>
|
|
35548
35501
|
if (val.fieldId) {
|
|
35549
35502
|
// @_THIS
|
|
35550
|
-
if (
|
|
35551
|
-
val.fieldId &&
|
|
35552
|
-
val.fieldId.substr(0, 5) === "_THIS" &&
|
|
35553
|
-
calling_fieldIdP &&
|
|
35554
|
-
(val.fieldId.length === 5 ||
|
|
35555
|
-
(val.fieldId.length > 5 && val.fieldId.substr(5, 1) === "."))
|
|
35556
|
-
) {
|
|
35503
|
+
if (val.fieldId && val.fieldId.substr(0, 5) === '_THIS' && calling_fieldIdP && (val.fieldId.length === 5 || (val.fieldId.length > 5 && val.fieldId.substr(5, 1) === '.'))) {
|
|
35557
35504
|
if (val.fieldId.length === 5) val.fieldId = calling_fieldIdP;
|
|
35558
|
-
else
|
|
35559
|
-
val.fieldId =
|
|
35560
|
-
calling_fieldIdP + val.fieldId(5, val.fieldId.length - 1);
|
|
35505
|
+
else val.fieldId = calling_fieldIdP + val.fieldId(5, val.fieldId.length - 1);
|
|
35561
35506
|
}
|
|
35562
|
-
if (!sourceP ===
|
|
35507
|
+
if (!sourceP === 'exp') {
|
|
35563
35508
|
var_Arr[key].value = '""';
|
|
35564
35509
|
} // put default
|
|
35565
35510
|
fields[val.fieldId] = var_Arr[key].value;
|
|
@@ -35569,7 +35514,7 @@ func.expression.get = async function (
|
|
|
35569
35514
|
val.fieldId,
|
|
35570
35515
|
dsSessionP,
|
|
35571
35516
|
|
|
35572
|
-
rowIdP
|
|
35517
|
+
rowIdP,
|
|
35573
35518
|
); // find field in dataSources
|
|
35574
35519
|
|
|
35575
35520
|
await replace_value_in_string(ret.ret, ret.fieldIdP);
|
|
@@ -35582,7 +35527,7 @@ func.expression.get = async function (
|
|
|
35582
35527
|
var var_error_found;
|
|
35583
35528
|
// merge arr values
|
|
35584
35529
|
_.forEach(var_Arr, function (val, key) {
|
|
35585
|
-
if (sourceP ===
|
|
35530
|
+
if (sourceP === 'UI Property EXP') {
|
|
35586
35531
|
let ret = func.utils.get_drive_url(SESSION_ID, val.value, true);
|
|
35587
35532
|
if (ret.changed) {
|
|
35588
35533
|
res[key] = ret.value;
|
|
@@ -35590,108 +35535,72 @@ func.expression.get = async function (
|
|
|
35590
35535
|
}
|
|
35591
35536
|
}
|
|
35592
35537
|
|
|
35593
|
-
if (sourceP ===
|
|
35594
|
-
let ret = func.utils.get_drive_url(
|
|
35595
|
-
SESSION_ID,
|
|
35596
|
-
val.value,
|
|
35597
|
-
var_Arr.length == 1 ? false : true
|
|
35598
|
-
);
|
|
35538
|
+
if (sourceP === 'UI Attr EXP') {
|
|
35539
|
+
let ret = func.utils.get_drive_url(SESSION_ID, val.value, var_Arr.length == 1 ? false : true);
|
|
35599
35540
|
if (ret.changed) {
|
|
35600
35541
|
res[key] = ret.value;
|
|
35601
35542
|
return true;
|
|
35602
35543
|
}
|
|
35603
35544
|
}
|
|
35604
35545
|
|
|
35605
|
-
if (val.type ===
|
|
35546
|
+
if (val.type === 'exp') {
|
|
35606
35547
|
exp_exist = true;
|
|
35607
35548
|
}
|
|
35608
35549
|
res[key] = val.value;
|
|
35609
35550
|
|
|
35610
|
-
if (var_Arr.length > 1) {
|
|
35611
|
-
|
|
35612
|
-
|
|
35613
|
-
|
|
35614
|
-
) &&
|
|
35615
|
-
["string", "date"].includes(val.type)
|
|
35616
|
-
) {
|
|
35617
|
-
res[key] = "`" + val.value + "`";
|
|
35551
|
+
if (var_Arr.length > 1) {
|
|
35552
|
+
// complex input
|
|
35553
|
+
if (!['DbQuery', 'alert', 'exp', 'api_rendered_output'].includes(sourceP) && ['string', 'date'].includes(val.type)) {
|
|
35554
|
+
res[key] = '`' + val.value + '`';
|
|
35618
35555
|
}
|
|
35619
35556
|
// new Dec 18 2024 for Ishai // json,html,xml,text,css
|
|
35620
|
-
if (
|
|
35621
|
-
["api_rendered_output"].includes(sourceP) && ["json"].includes(api_output_type) &&
|
|
35622
|
-
["string", "date"].includes(val.type)
|
|
35623
|
-
) {
|
|
35557
|
+
if (['api_rendered_output'].includes(sourceP) && ['json'].includes(api_output_type) && ['string', 'date'].includes(val.type)) {
|
|
35624
35558
|
res[key] = `"` + val.value + `"`;
|
|
35625
35559
|
}
|
|
35626
35560
|
}
|
|
35627
|
-
if (val.fieldId && val.value && typeof val.value ===
|
|
35628
|
-
if (
|
|
35629
|
-
|
|
35630
|
-
|
|
35631
|
-
)
|
|
35632
|
-
) {
|
|
35633
|
-
if (val.value.indexOf("↵") > -1) {
|
|
35634
|
-
res[key] = val.value.split("↵").join("");
|
|
35561
|
+
if (val.fieldId && val.value && typeof val.value === 'string') {
|
|
35562
|
+
if (['query', 'condition', 'range', 'sort', 'locate'].includes(sourceP)) {
|
|
35563
|
+
if (val.value.indexOf('↵') > -1) {
|
|
35564
|
+
res[key] = val.value.split('↵').join('');
|
|
35635
35565
|
}
|
|
35636
|
-
res[key] = res[key].replace(/(\r\n|\n|\r)/gm,
|
|
35566
|
+
res[key] = res[key].replace(/(\r\n|\n|\r)/gm, ''); //.replace(/"/g,'\"');//.replace(/'/g,"");
|
|
35637
35567
|
}
|
|
35638
35568
|
|
|
35639
|
-
if ([
|
|
35640
|
-
if (val.value.indexOf(
|
|
35641
|
-
|
|
35642
|
-
res[key] = res[key].replace(/(\r\n|\n|\r)/gm, "\\n");
|
|
35569
|
+
if (['init', 'update', 'virtual'].includes(sourceP)) {
|
|
35570
|
+
if (val.value.indexOf('↵') > -1) res[key] = val.value.split('↵').join('\n');
|
|
35571
|
+
res[key] = res[key].replace(/(\r\n|\n|\r)/gm, '\\n');
|
|
35643
35572
|
}
|
|
35644
35573
|
|
|
35645
|
-
if (typeof IS_PROCESS_SERVER !==
|
|
35646
|
-
res[key] = res[key].replace(/(\r\n|\n|\r)/gm,
|
|
35574
|
+
if (typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
35575
|
+
res[key] = res[key].replace(/(\r\n|\n|\r)/gm, '<br>');
|
|
35647
35576
|
}
|
|
35648
35577
|
|
|
35649
35578
|
fields[val.fieldId] = res[key];
|
|
35650
35579
|
}
|
|
35651
35580
|
// extract object
|
|
35652
|
-
if (typeof val.value ===
|
|
35653
|
-
if (
|
|
35654
|
-
!Array.isArray(val.value) &&
|
|
35655
|
-
!var_Arr[key + 1].value?.includes(".")
|
|
35656
|
-
) {
|
|
35581
|
+
if (typeof val.value === 'object' && var_Arr.length > 1) {
|
|
35582
|
+
if (!Array.isArray(val.value) && !var_Arr[key + 1].value?.includes('.')) {
|
|
35657
35583
|
// && !["api_rendered_output"].includes(sourceP)
|
|
35658
35584
|
|
|
35659
35585
|
// prevent cast on single value expression
|
|
35660
|
-
res[key] =
|
|
35586
|
+
res[key] = '(' + JSON.stringify(val.value) + ')';
|
|
35661
35587
|
} else {
|
|
35662
35588
|
res[key] = JSON.stringify(val.value);
|
|
35663
35589
|
}
|
|
35664
35590
|
}
|
|
35665
35591
|
|
|
35666
|
-
if (
|
|
35667
|
-
|
|
35668
|
-
sourceP !== "exp" &&
|
|
35669
|
-
val.value &&
|
|
35670
|
-
typeof val.value === "string" &&
|
|
35671
|
-
val.value.substr(0, 1) === "@"
|
|
35672
|
-
) {
|
|
35673
|
-
warning = "Error encoding " + val.value;
|
|
35592
|
+
if (!exp_exist && sourceP !== 'exp' && val.value && typeof val.value === 'string' && val.value.substr(0, 1) === '@') {
|
|
35593
|
+
warning = 'Error encoding ' + val.value;
|
|
35674
35594
|
var_error_found = true;
|
|
35675
35595
|
res[key] = 0;
|
|
35676
35596
|
}
|
|
35677
35597
|
});
|
|
35678
35598
|
var join = function (arrP) {
|
|
35679
|
-
return arrP.join(
|
|
35599
|
+
return arrP.join('');
|
|
35680
35600
|
};
|
|
35681
35601
|
var exp = undefined;
|
|
35682
|
-
if (exp_exist && sourceP !==
|
|
35683
|
-
exp = await func.expression.get(
|
|
35684
|
-
SESSION_ID,
|
|
35685
|
-
join(res),
|
|
35686
|
-
dsSessionP,
|
|
35687
|
-
sourceP,
|
|
35688
|
-
rowIdP,
|
|
35689
|
-
sourceActionP,
|
|
35690
|
-
true,
|
|
35691
|
-
calling_fieldIdP,
|
|
35692
|
-
fields,
|
|
35693
|
-
debug_infoP
|
|
35694
|
-
);
|
|
35602
|
+
if (exp_exist && sourceP !== 'exp') {
|
|
35603
|
+
exp = await func.expression.get(SESSION_ID, join(res), dsSessionP, sourceP, rowIdP, sourceActionP, true, calling_fieldIdP, fields, debug_infoP);
|
|
35695
35604
|
if (exp.res) res = exp.res;
|
|
35696
35605
|
// do second pass when exp exist
|
|
35697
35606
|
else res = [exp.result];
|
|
@@ -35706,39 +35615,28 @@ func.expression.get = async function (
|
|
|
35706
35615
|
|
|
35707
35616
|
if (secondPassP) {
|
|
35708
35617
|
ret = result;
|
|
35709
|
-
} else if (sourceP !==
|
|
35618
|
+
} else if (sourceP !== 'exp') {
|
|
35710
35619
|
// no eval for second pass
|
|
35711
35620
|
// return single value
|
|
35712
|
-
if (
|
|
35713
|
-
res.length === 1 &&
|
|
35714
|
-
typeof res[0] === "string" &&
|
|
35715
|
-
typeof res[0] !== "object"
|
|
35716
|
-
) {
|
|
35621
|
+
if (res.length === 1 && typeof res[0] === 'string' && typeof res[0] !== 'object') {
|
|
35717
35622
|
// avoid eval when query leading zeros problem
|
|
35718
35623
|
ret = join(res);
|
|
35719
|
-
if (ret && ret.substr(0, 1) ===
|
|
35720
|
-
error =
|
|
35624
|
+
if (ret && ret.substr(0, 1) === '@') {
|
|
35625
|
+
error = 'Error encoding @ var';
|
|
35721
35626
|
var_error_found = true;
|
|
35722
35627
|
}
|
|
35723
35628
|
} else {
|
|
35724
35629
|
if (
|
|
35725
35630
|
![
|
|
35726
|
-
|
|
35631
|
+
'arguments',
|
|
35727
35632
|
// "alert",
|
|
35728
|
-
|
|
35729
|
-
|
|
35633
|
+
'api_rendered_output',
|
|
35634
|
+
'DbQuery',
|
|
35730
35635
|
].includes(sourceP)
|
|
35731
35636
|
) {
|
|
35732
|
-
ret = await func.expression.secure_eval(
|
|
35733
|
-
SESSION_ID,
|
|
35734
|
-
sourceP,
|
|
35735
|
-
result,
|
|
35736
|
-
jobNo,
|
|
35737
|
-
dsSessionP,
|
|
35738
|
-
js_script_callback
|
|
35739
|
-
);
|
|
35637
|
+
ret = await func.expression.secure_eval(SESSION_ID, sourceP, result, jobNo, dsSessionP, js_script_callback);
|
|
35740
35638
|
} else {
|
|
35741
|
-
if (sourceP ===
|
|
35639
|
+
if (sourceP === 'DbQuery') {
|
|
35742
35640
|
ret = JSON.stringify(evalJson(result));
|
|
35743
35641
|
} else {
|
|
35744
35642
|
// try eval
|
|
@@ -35767,12 +35665,7 @@ func.expression.parse = function (strP) {
|
|
|
35767
35665
|
if (!posP) posP = 0;
|
|
35768
35666
|
var clean_split_str = function (arrP) {
|
|
35769
35667
|
var arr = [];
|
|
35770
|
-
if (
|
|
35771
|
-
arrP &&
|
|
35772
|
-
arrP.length > 1 &&
|
|
35773
|
-
arrP[0] === "" &&
|
|
35774
|
-
arrP[1].indexOf("@") > -1
|
|
35775
|
-
) {
|
|
35668
|
+
if (arrP && arrP.length > 1 && arrP[0] === '' && arrP[1].indexOf('@') > -1) {
|
|
35776
35669
|
for (var i = 1; i <= arrP.length; i++) {
|
|
35777
35670
|
arr.push(arrP[i]);
|
|
35778
35671
|
}
|
|
@@ -35783,7 +35676,7 @@ func.expression.parse = function (strP) {
|
|
|
35783
35676
|
var validSymbolsNoArray = /[^.@\[]/; //valid symbols no array /[^.@\[\]\]]/
|
|
35784
35677
|
var validSymbolsWithArray = /[^.@"'\[\]]/; //valid symbols with array
|
|
35785
35678
|
var validSymbols = validSymbolsNoArray;
|
|
35786
|
-
var splitTmp = strP.replace(/@/g,
|
|
35679
|
+
var splitTmp = strP.replace(/@/g, '^^@').split('^^');
|
|
35787
35680
|
var split = clean_split_str(splitTmp);
|
|
35788
35681
|
var obj = [];
|
|
35789
35682
|
if (split) {
|
|
@@ -35791,8 +35684,8 @@ func.expression.parse = function (strP) {
|
|
|
35791
35684
|
// run on @ segments
|
|
35792
35685
|
if (val) {
|
|
35793
35686
|
var pos = strP.indexOf(val);
|
|
35794
|
-
if (val && val.substr(0, 1) ===
|
|
35795
|
-
var tmpStr =
|
|
35687
|
+
if (val && val.substr(0, 1) === '@') {
|
|
35688
|
+
var tmpStr = '';
|
|
35796
35689
|
var word_start_pos = undefined;
|
|
35797
35690
|
var word_end_pos = undefined;
|
|
35798
35691
|
// run on @ segment string
|
|
@@ -35800,7 +35693,7 @@ func.expression.parse = function (strP) {
|
|
|
35800
35693
|
var key1 = i;
|
|
35801
35694
|
var val1 = val.substr(i, 1);
|
|
35802
35695
|
if (
|
|
35803
|
-
val1 ===
|
|
35696
|
+
val1 === '.' &&
|
|
35804
35697
|
!word_start_pos // find first dot
|
|
35805
35698
|
)
|
|
35806
35699
|
word_start_pos = key1;
|
|
@@ -35810,40 +35703,24 @@ func.expression.parse = function (strP) {
|
|
|
35810
35703
|
nonLettersPatt.test(val1) // find any sign character to mark the end of word
|
|
35811
35704
|
)
|
|
35812
35705
|
word_end_pos = key1;
|
|
35813
|
-
if (
|
|
35814
|
-
word_start_pos &&
|
|
35815
|
-
word_start_pos >= 0 &&
|
|
35816
|
-
word_end_pos &&
|
|
35817
|
-
word_end_pos >= 0
|
|
35818
|
-
) {
|
|
35706
|
+
if (word_start_pos && word_start_pos >= 0 && word_end_pos && word_end_pos >= 0) {
|
|
35819
35707
|
// find the word
|
|
35820
|
-
var word = val.substr(
|
|
35821
|
-
word_start_pos + 1,
|
|
35822
|
-
word_end_pos - word_start_pos - 1
|
|
35823
|
-
); // get the word
|
|
35708
|
+
var word = val.substr(word_start_pos + 1, word_end_pos - word_start_pos - 1); // get the word
|
|
35824
35709
|
// if (glb.ALL_PROPERTIES_ARR.indexOf(word) === -1) {
|
|
35825
35710
|
// compare with internal properties
|
|
35826
|
-
tmpStr =
|
|
35827
|
-
tmpStr.substr(0, word_start_pos) +
|
|
35828
|
-
"^^" +
|
|
35829
|
-
tmpStr.substr(word_start_pos, word_end_pos);
|
|
35711
|
+
tmpStr = tmpStr.substr(0, word_start_pos) + '^^' + tmpStr.substr(word_start_pos, word_end_pos);
|
|
35830
35712
|
// }
|
|
35831
|
-
if (val.substr(word_end_pos, 1) ===
|
|
35832
|
-
word_start_pos = word_end_pos;
|
|
35713
|
+
if (val.substr(word_end_pos, 1) === '.') word_start_pos = word_end_pos;
|
|
35833
35714
|
else word_start_pos = null;
|
|
35834
35715
|
word_end_pos = null;
|
|
35835
35716
|
}
|
|
35836
|
-
if (val1 ===
|
|
35837
|
-
if (
|
|
35838
|
-
|
|
35839
|
-
validSymbols.test(val1) &&
|
|
35840
|
-
tmpStr.indexOf("^^") === -1
|
|
35841
|
-
) {
|
|
35842
|
-
tmpStr += "^^" + val1;
|
|
35717
|
+
if (val1 === '[') validSymbols = validSymbolsWithArray;
|
|
35718
|
+
if (nonLettersPatt.test(val1) && validSymbols.test(val1) && tmpStr.indexOf('^^') === -1) {
|
|
35719
|
+
tmpStr += '^^' + val1;
|
|
35843
35720
|
} else tmpStr += val1;
|
|
35844
35721
|
}
|
|
35845
35722
|
// });
|
|
35846
|
-
if (tmpStr.indexOf(
|
|
35723
|
+
if (tmpStr.indexOf('^^') > -1) {
|
|
35847
35724
|
var obj1 = extract_str(tmpStr, pos);
|
|
35848
35725
|
obj = obj.concat(obj1);
|
|
35849
35726
|
} else {
|
|
@@ -35851,10 +35728,8 @@ func.expression.parse = function (strP) {
|
|
|
35851
35728
|
var fieldId = undefined;
|
|
35852
35729
|
if (val) {
|
|
35853
35730
|
fieldId = val.substr(1, val.length);
|
|
35854
|
-
if (val.indexOf(
|
|
35855
|
-
|
|
35856
|
-
if (val.indexOf("[") > -1)
|
|
35857
|
-
fieldId = val.substr(1, val.indexOf("[") - 1);
|
|
35731
|
+
if (val.indexOf('.') > -1) fieldId = val.substr(1, val.indexOf('.') - 1);
|
|
35732
|
+
if (val.indexOf('[') > -1) fieldId = val.substr(1, val.indexOf('[') - 1);
|
|
35858
35733
|
//
|
|
35859
35734
|
// if (val.indexOf("]") > -1)
|
|
35860
35735
|
// fieldId = val.substr(1, val.indexOf("]") - 1);
|
|
@@ -35882,7 +35757,7 @@ func.expression.parse = function (strP) {
|
|
|
35882
35757
|
|
|
35883
35758
|
func.expression.get_property = async function (valP) {
|
|
35884
35759
|
async function secure_eval(val) {
|
|
35885
|
-
if (typeof IS_PROCESS_SERVER ===
|
|
35760
|
+
if (typeof IS_PROCESS_SERVER === 'undefined') {
|
|
35886
35761
|
try {
|
|
35887
35762
|
return eval(val);
|
|
35888
35763
|
} catch (err) {
|
|
@@ -35903,20 +35778,16 @@ func.expression.get_property = async function (valP) {
|
|
|
35903
35778
|
});
|
|
35904
35779
|
return await vm.run(val);
|
|
35905
35780
|
} catch (err) {
|
|
35906
|
-
throw
|
|
35781
|
+
throw '';
|
|
35907
35782
|
}
|
|
35908
35783
|
}
|
|
35909
35784
|
|
|
35910
35785
|
var property1, property2;
|
|
35911
|
-
if (valP.indexOf(
|
|
35912
|
-
property1 = valP.substr(
|
|
35913
|
-
valP.indexOf("[") + 1,
|
|
35914
|
-
valP.indexOf("]") - valP.indexOf("[") - 1
|
|
35915
|
-
); // get []
|
|
35786
|
+
if (valP.indexOf('[') > -1 && valP.indexOf(']') > -1) {
|
|
35787
|
+
property1 = valP.substr(valP.indexOf('[') + 1, valP.indexOf(']') - valP.indexOf('[') - 1); // get []
|
|
35916
35788
|
property1 = await secure_eval(property1);
|
|
35917
35789
|
}
|
|
35918
|
-
if (valP.indexOf(
|
|
35919
|
-
property2 = valP.substr(valP.indexOf(".") + 1, valP.length); // get .
|
|
35790
|
+
if (valP.indexOf('.') > -1) property2 = valP.substr(valP.indexOf('.') + 1, valP.length); // get .
|
|
35920
35791
|
return {
|
|
35921
35792
|
property1: property1,
|
|
35922
35793
|
property2: property2,
|
|
@@ -35924,52 +35795,32 @@ func.expression.get_property = async function (valP) {
|
|
|
35924
35795
|
};
|
|
35925
35796
|
func.expression.validate_constant = function (valP) {
|
|
35926
35797
|
var patt = /["']/;
|
|
35927
|
-
if (
|
|
35928
|
-
typeof valP === "string" &&
|
|
35929
|
-
patt.test(valP.substr(0, 1)) &&
|
|
35930
|
-
patt.test(valP.substr(0, valP.length - 1))
|
|
35931
|
-
)
|
|
35932
|
-
return true;
|
|
35798
|
+
if (typeof valP === 'string' && patt.test(valP.substr(0, 1)) && patt.test(valP.substr(0, valP.length - 1))) return true;
|
|
35933
35799
|
else return false;
|
|
35934
35800
|
};
|
|
35935
35801
|
func.expression.validate_variables = function (valP) {
|
|
35936
|
-
if (typeof valP ===
|
|
35802
|
+
if (typeof valP === 'string' && valP.indexOf('@') > -1) return true;
|
|
35937
35803
|
else return false;
|
|
35938
35804
|
};
|
|
35939
35805
|
func.expression.remove_quotes = function (valP) {
|
|
35940
|
-
if (func.expression.validate_constant(valP))
|
|
35941
|
-
return valP.substr(1, valP.length - 2);
|
|
35806
|
+
if (func.expression.validate_constant(valP)) return valP.substr(1, valP.length - 2);
|
|
35942
35807
|
else return valP;
|
|
35943
35808
|
};
|
|
35944
35809
|
|
|
35945
|
-
func.expression.secure_eval = async function (
|
|
35946
|
-
SESSION_ID,
|
|
35947
|
-
|
|
35948
|
-
|
|
35949
|
-
|
|
35950
|
-
dsSessionP,
|
|
35951
|
-
js_script_callback
|
|
35952
|
-
) {
|
|
35953
|
-
const api_utils = await func.common.get_module(
|
|
35810
|
+
func.expression.secure_eval = async function (SESSION_ID, sourceP, val, job_id, dsSessionP, js_script_callback, evt) {
|
|
35811
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
35812
|
+
func,
|
|
35813
|
+
glb,
|
|
35814
|
+
SESSION_OBJ,
|
|
35954
35815
|
SESSION_ID,
|
|
35955
|
-
|
|
35956
|
-
|
|
35957
|
-
|
|
35958
|
-
|
|
35959
|
-
SESSION_OBJ,
|
|
35960
|
-
SESSION_ID,
|
|
35961
|
-
APP_OBJ,
|
|
35962
|
-
dsSession: dsSessionP,
|
|
35963
|
-
job_id,
|
|
35964
|
-
}
|
|
35965
|
-
);
|
|
35816
|
+
APP_OBJ,
|
|
35817
|
+
dsSession: dsSessionP,
|
|
35818
|
+
job_id,
|
|
35819
|
+
});
|
|
35966
35820
|
|
|
35967
35821
|
const xu = api_utils;
|
|
35968
35822
|
|
|
35969
|
-
if (
|
|
35970
|
-
typeof IS_PROCESS_SERVER === "undefined" &&
|
|
35971
|
-
typeof IS_DOCKER === "undefined"
|
|
35972
|
-
) {
|
|
35823
|
+
if (typeof IS_PROCESS_SERVER === 'undefined' && typeof IS_DOCKER === 'undefined') {
|
|
35973
35824
|
try {
|
|
35974
35825
|
return eval(val);
|
|
35975
35826
|
} catch (err) {
|
|
@@ -35982,39 +35833,19 @@ func.expression.secure_eval = async function (
|
|
|
35982
35833
|
}
|
|
35983
35834
|
}
|
|
35984
35835
|
// server side execution
|
|
35985
|
-
if (sourceP ===
|
|
35986
|
-
process.on(
|
|
35987
|
-
console.error(
|
|
35836
|
+
if (sourceP === 'javascript') {
|
|
35837
|
+
process.on('uncaughtException', (err) => {
|
|
35838
|
+
console.error('Asynchronous error caught.', err);
|
|
35988
35839
|
|
|
35989
35840
|
func.events.delete_job(SESSION_ID, job_id);
|
|
35990
|
-
if (
|
|
35991
|
-
typeof IS_PROCESS_SERVER !== "undefined" ||
|
|
35992
|
-
typeof IS_DOCKER !== "undefined"
|
|
35993
|
-
) {
|
|
35841
|
+
if (typeof IS_PROCESS_SERVER !== 'undefined' || typeof IS_DOCKER !== 'undefined') {
|
|
35994
35842
|
if (SESSION_OBJ[SESSION_ID].crawler) return;
|
|
35995
|
-
return __.rpi.write_log(
|
|
35996
|
-
SESSION_OBJ[SESSION_ID].app_id,
|
|
35997
|
-
"error",
|
|
35998
|
-
"worker",
|
|
35999
|
-
"vm error",
|
|
36000
|
-
err,
|
|
36001
|
-
null,
|
|
36002
|
-
val,
|
|
36003
|
-
"func.expression.get.secure_eval"
|
|
36004
|
-
);
|
|
35843
|
+
return __.rpi.write_log(SESSION_OBJ[SESSION_ID].app_id, 'error', 'worker', 'vm error', err, null, val, 'func.expression.get.secure_eval');
|
|
36005
35844
|
}
|
|
36006
35845
|
});
|
|
36007
35846
|
try {
|
|
36008
|
-
const dir = path.join(
|
|
36009
|
-
|
|
36010
|
-
SESSION_OBJ[SESSION_ID].app_id,
|
|
36011
|
-
"node_modules",
|
|
36012
|
-
"/"
|
|
36013
|
-
);
|
|
36014
|
-
const script = new VM.VMScript(
|
|
36015
|
-
`try{${val}}catch(e){func.api.error(SESSION_ID, "nodejs error", e); console.error(e); func.events.delete_job(SESSION_ID, job_id);}`,
|
|
36016
|
-
{ filename: dir, dirname: dir }
|
|
36017
|
-
);
|
|
35847
|
+
const dir = path.join(_conf.studio_drive_path, SESSION_OBJ[SESSION_ID].app_id, 'node_modules', '/');
|
|
35848
|
+
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 });
|
|
36018
35849
|
let vm = new VM.NodeVM({
|
|
36019
35850
|
require: {
|
|
36020
35851
|
external: true,
|
|
@@ -36037,11 +35868,11 @@ func.expression.secure_eval = async function (
|
|
|
36037
35868
|
dirname: dir,
|
|
36038
35869
|
});
|
|
36039
35870
|
} catch (err) {
|
|
36040
|
-
console.error(
|
|
35871
|
+
console.error('Failed to execute script.', err);
|
|
36041
35872
|
|
|
36042
|
-
if (typeof IS_PROCESS_SERVER !==
|
|
35873
|
+
if (typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
36043
35874
|
func.events.delete_job(SESSION_ID, jobNo);
|
|
36044
|
-
return __.db.add_error_log(SESSION_OBJ[SESSION_ID].app_id,
|
|
35875
|
+
return __.db.add_error_log(SESSION_OBJ[SESSION_ID].app_id, 'api', err);
|
|
36045
35876
|
}
|
|
36046
35877
|
}
|
|
36047
35878
|
} else {
|
|
@@ -36060,12 +35891,12 @@ func.expression.secure_eval = async function (
|
|
|
36060
35891
|
allowAsync: false,
|
|
36061
35892
|
});
|
|
36062
35893
|
let ret = val;
|
|
36063
|
-
if (typeof val ===
|
|
35894
|
+
if (typeof val === 'string') {
|
|
36064
35895
|
ret = await vm.run(val);
|
|
36065
35896
|
}
|
|
36066
35897
|
return ret;
|
|
36067
35898
|
} catch (err) {
|
|
36068
|
-
throw
|
|
35899
|
+
throw '';
|
|
36069
35900
|
}
|
|
36070
35901
|
} catch (err) {
|
|
36071
35902
|
try {
|
|
@@ -36840,6 +36671,10 @@ func.events.execute = async function (
|
|
|
36840
36671
|
`(async function(el,evt) {
|
|
36841
36672
|
${refIdP.value}
|
|
36842
36673
|
})(document.querySelector(\`[xu-ui-id=${elementP}]\`),evt)`,
|
|
36674
|
+
null,
|
|
36675
|
+
null,
|
|
36676
|
+
null,
|
|
36677
|
+
evt,
|
|
36843
36678
|
);
|
|
36844
36679
|
await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
|
|
36845
36680
|
|
|
@@ -36856,6 +36691,9 @@ func.events.execute = async function (
|
|
|
36856
36691
|
${refIdP.value}
|
|
36857
36692
|
})(document.querySelector(\`[xu-ui-id=${elementP}]\`),evt)`,
|
|
36858
36693
|
true,
|
|
36694
|
+
null,
|
|
36695
|
+
null,
|
|
36696
|
+
evt,
|
|
36859
36697
|
);
|
|
36860
36698
|
await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
|
|
36861
36699
|
|