@xuda.io/runtime-bundle 1.0.1428 → 1.0.1430
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 +68 -2
- package/js/xuda-runtime-bundle.min.js +2 -2
- package/js/xuda-runtime-slim.js +68 -2
- package/js/xuda-runtime-slim.min.es.js +68 -2
- package/js/xuda-runtime-slim.min.js +2 -2
- package/js/xuda-server-bundle.min.mjs +2 -2
- package/js/xuda-server-bundle.mjs +68 -2
- package/js/xuda-worker-bundle.js +68 -2
- package/js/xuda-worker-bundle.min.js +2 -2
- package/package.json +1 -1
package/js/xuda-runtime-slim.js
CHANGED
|
@@ -6387,6 +6387,38 @@ func.datasource.get_viewFields_for_update_function = function (SESSION_ID, calli
|
|
|
6387
6387
|
return viewFields;
|
|
6388
6388
|
};
|
|
6389
6389
|
func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, rowIdP, org_dsSessionP) {
|
|
6390
|
+
const normalize_field_id = function (field_id) {
|
|
6391
|
+
if (typeof field_id === 'string') {
|
|
6392
|
+
return field_id;
|
|
6393
|
+
}
|
|
6394
|
+
if (typeof field_id?.field_id === 'string') {
|
|
6395
|
+
return field_id.field_id;
|
|
6396
|
+
}
|
|
6397
|
+
if (typeof field_id?.id === 'string') {
|
|
6398
|
+
return field_id.id;
|
|
6399
|
+
}
|
|
6400
|
+
if (typeof field_id === 'number' || typeof field_id === 'boolean' || typeof field_id === 'bigint') {
|
|
6401
|
+
return field_id.toString();
|
|
6402
|
+
}
|
|
6403
|
+
const coerced = field_id?.toString?.();
|
|
6404
|
+
if (typeof coerced === 'string' && coerced && coerced !== '[object Object]') {
|
|
6405
|
+
return coerced;
|
|
6406
|
+
}
|
|
6407
|
+
return null;
|
|
6408
|
+
};
|
|
6409
|
+
const return_missing_value = function (field_id, currentRecordId = null) {
|
|
6410
|
+
return {
|
|
6411
|
+
ret: {
|
|
6412
|
+
value: undefined,
|
|
6413
|
+
type: 'string',
|
|
6414
|
+
prop: null,
|
|
6415
|
+
},
|
|
6416
|
+
dsSessionP,
|
|
6417
|
+
fieldIdP: field_id,
|
|
6418
|
+
currentRecordId,
|
|
6419
|
+
found: false,
|
|
6420
|
+
};
|
|
6421
|
+
};
|
|
6390
6422
|
const return_value = async (field_id, value) => {
|
|
6391
6423
|
const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSessionP);
|
|
6392
6424
|
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
@@ -6515,9 +6547,21 @@ func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, ro
|
|
|
6515
6547
|
// let prev_ds = dsSessionP - 1;
|
|
6516
6548
|
return await func.datasource.get_value(SESSION_ID, fieldIdP, dsSessionP - 1, rowIdP, org_dsSessionP);
|
|
6517
6549
|
}
|
|
6550
|
+
const normalized_missing_field = normalize_field_id(fieldIdP);
|
|
6551
|
+
if (normalized_missing_field === null) {
|
|
6552
|
+
return return_missing_value(fieldIdP);
|
|
6553
|
+
}
|
|
6554
|
+
fieldIdP = normalized_missing_field;
|
|
6518
6555
|
return await return_value(fieldIdP);
|
|
6519
6556
|
} //console.error("error: datasource not exist: " + dsSessionP);
|
|
6520
6557
|
|
|
6558
|
+
const normalized_field_id = normalize_field_id(fieldIdP);
|
|
6559
|
+
if (normalized_field_id === null) {
|
|
6560
|
+
func.utils.debug_report(SESSION_ID, 'Datasource get value', `Invalid field id type: ${typeof fieldIdP}`, 'W');
|
|
6561
|
+
return return_missing_value(fieldIdP, _ds.currentRecordId);
|
|
6562
|
+
}
|
|
6563
|
+
fieldIdP = normalized_field_id;
|
|
6564
|
+
|
|
6521
6565
|
let recordId = rowIdP;
|
|
6522
6566
|
if (!recordId) {
|
|
6523
6567
|
recordId = _ds.currentRecordId;
|
|
@@ -19720,6 +19764,29 @@ func.events.execute = async function (
|
|
|
19720
19764
|
return result;
|
|
19721
19765
|
},
|
|
19722
19766
|
update: async function () {
|
|
19767
|
+
const resolve_update_field_id = async function (field_expr, iterate_info) {
|
|
19768
|
+
let trimmed = field_expr?.trim?.() || '';
|
|
19769
|
+
if (!trimmed) {
|
|
19770
|
+
return trimmed;
|
|
19771
|
+
}
|
|
19772
|
+
|
|
19773
|
+
const first = trimmed.substring(0, 1);
|
|
19774
|
+
const last = trimmed.substring(trimmed.length - 1);
|
|
19775
|
+
if ((first === "'" || first === '"' || first === '`') && last === first) {
|
|
19776
|
+
trimmed = trimmed.substring(1, trimmed.length - 1).trim();
|
|
19777
|
+
}
|
|
19778
|
+
|
|
19779
|
+
if (/^@?[A-Za-z_][\w\-\:\.]*$/.test(trimmed)) {
|
|
19780
|
+
return trimmed.substring(0, 1) === '@' ? trimmed.substring(1) : trimmed;
|
|
19781
|
+
}
|
|
19782
|
+
|
|
19783
|
+
let ret_field_id = await func.expression.get(SESSION_ID, trimmed, dsSessionP, 'update', null, null, null, null, null, null, iterate_info);
|
|
19784
|
+
if (typeof ret_field_id?.result === 'string' && ret_field_id.result.substring(0, 1) === '@') {
|
|
19785
|
+
return ret_field_id.result.substring(1);
|
|
19786
|
+
}
|
|
19787
|
+
return ret_field_id?.result;
|
|
19788
|
+
};
|
|
19789
|
+
|
|
19723
19790
|
const obj_values_to_update = func.datasource.get_viewFields_for_update_function(SESSION_ID, calling_trigger_prop, null, dsSessionP);
|
|
19724
19791
|
if (!obj_values_to_update || xu_isEmpty(obj_values_to_update)) {
|
|
19725
19792
|
func.utils.debug_report(SESSION_ID, 'Update values object is empty', '', 'W');
|
|
@@ -19737,9 +19804,8 @@ func.events.execute = async function (
|
|
|
19737
19804
|
iterate_info = element_meta?.iterate_info || null;
|
|
19738
19805
|
}
|
|
19739
19806
|
|
|
19740
|
-
let ret_field_id = await func.expression.get(SESSION_ID, val.id.trim(), dsSessionP, 'update', null, null, null, null, null, null, iterate_info);
|
|
19741
19807
|
let ret_value = await func.expression.get(SESSION_ID, val.val.trim(), dsSessionP, 'update', null, null, null, null, null, null, iterate_info);
|
|
19742
|
-
let _field_id =
|
|
19808
|
+
let _field_id = await resolve_update_field_id(val.id, iterate_info);
|
|
19743
19809
|
let _value = ret_value.result;
|
|
19744
19810
|
|
|
19745
19811
|
updates.push({ _field_id, _value });
|
|
@@ -6313,6 +6313,38 @@ func.datasource.get_viewFields_for_update_function = function (SESSION_ID, calli
|
|
|
6313
6313
|
return viewFields;
|
|
6314
6314
|
};
|
|
6315
6315
|
func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, rowIdP, org_dsSessionP) {
|
|
6316
|
+
const normalize_field_id = function (field_id) {
|
|
6317
|
+
if (typeof field_id === 'string') {
|
|
6318
|
+
return field_id;
|
|
6319
|
+
}
|
|
6320
|
+
if (typeof field_id?.field_id === 'string') {
|
|
6321
|
+
return field_id.field_id;
|
|
6322
|
+
}
|
|
6323
|
+
if (typeof field_id?.id === 'string') {
|
|
6324
|
+
return field_id.id;
|
|
6325
|
+
}
|
|
6326
|
+
if (typeof field_id === 'number' || typeof field_id === 'boolean' || typeof field_id === 'bigint') {
|
|
6327
|
+
return field_id.toString();
|
|
6328
|
+
}
|
|
6329
|
+
const coerced = field_id?.toString?.();
|
|
6330
|
+
if (typeof coerced === 'string' && coerced && coerced !== '[object Object]') {
|
|
6331
|
+
return coerced;
|
|
6332
|
+
}
|
|
6333
|
+
return null;
|
|
6334
|
+
};
|
|
6335
|
+
const return_missing_value = function (field_id, currentRecordId = null) {
|
|
6336
|
+
return {
|
|
6337
|
+
ret: {
|
|
6338
|
+
value: undefined,
|
|
6339
|
+
type: 'string',
|
|
6340
|
+
prop: null,
|
|
6341
|
+
},
|
|
6342
|
+
dsSessionP,
|
|
6343
|
+
fieldIdP: field_id,
|
|
6344
|
+
currentRecordId,
|
|
6345
|
+
found: false,
|
|
6346
|
+
};
|
|
6347
|
+
};
|
|
6316
6348
|
const return_value = async (field_id, value) => {
|
|
6317
6349
|
const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSessionP);
|
|
6318
6350
|
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
@@ -6441,9 +6473,21 @@ func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, ro
|
|
|
6441
6473
|
// let prev_ds = dsSessionP - 1;
|
|
6442
6474
|
return await func.datasource.get_value(SESSION_ID, fieldIdP, dsSessionP - 1, rowIdP, org_dsSessionP);
|
|
6443
6475
|
}
|
|
6476
|
+
const normalized_missing_field = normalize_field_id(fieldIdP);
|
|
6477
|
+
if (normalized_missing_field === null) {
|
|
6478
|
+
return return_missing_value(fieldIdP);
|
|
6479
|
+
}
|
|
6480
|
+
fieldIdP = normalized_missing_field;
|
|
6444
6481
|
return await return_value(fieldIdP);
|
|
6445
6482
|
} //console.error("error: datasource not exist: " + dsSessionP);
|
|
6446
6483
|
|
|
6484
|
+
const normalized_field_id = normalize_field_id(fieldIdP);
|
|
6485
|
+
if (normalized_field_id === null) {
|
|
6486
|
+
func.utils.debug_report(SESSION_ID, 'Datasource get value', `Invalid field id type: ${typeof fieldIdP}`, 'W');
|
|
6487
|
+
return return_missing_value(fieldIdP, _ds.currentRecordId);
|
|
6488
|
+
}
|
|
6489
|
+
fieldIdP = normalized_field_id;
|
|
6490
|
+
|
|
6447
6491
|
let recordId = rowIdP;
|
|
6448
6492
|
if (!recordId) {
|
|
6449
6493
|
recordId = _ds.currentRecordId;
|
|
@@ -20411,6 +20455,29 @@ func.events.execute = async function (
|
|
|
20411
20455
|
return result;
|
|
20412
20456
|
},
|
|
20413
20457
|
update: async function () {
|
|
20458
|
+
const resolve_update_field_id = async function (field_expr, iterate_info) {
|
|
20459
|
+
let trimmed = field_expr?.trim?.() || '';
|
|
20460
|
+
if (!trimmed) {
|
|
20461
|
+
return trimmed;
|
|
20462
|
+
}
|
|
20463
|
+
|
|
20464
|
+
const first = trimmed.substring(0, 1);
|
|
20465
|
+
const last = trimmed.substring(trimmed.length - 1);
|
|
20466
|
+
if ((first === "'" || first === '"' || first === '`') && last === first) {
|
|
20467
|
+
trimmed = trimmed.substring(1, trimmed.length - 1).trim();
|
|
20468
|
+
}
|
|
20469
|
+
|
|
20470
|
+
if (/^@?[A-Za-z_][\w\-\:\.]*$/.test(trimmed)) {
|
|
20471
|
+
return trimmed.substring(0, 1) === '@' ? trimmed.substring(1) : trimmed;
|
|
20472
|
+
}
|
|
20473
|
+
|
|
20474
|
+
let ret_field_id = await func.expression.get(SESSION_ID, trimmed, dsSessionP, 'update', null, null, null, null, null, null, iterate_info);
|
|
20475
|
+
if (typeof ret_field_id?.result === 'string' && ret_field_id.result.substring(0, 1) === '@') {
|
|
20476
|
+
return ret_field_id.result.substring(1);
|
|
20477
|
+
}
|
|
20478
|
+
return ret_field_id?.result;
|
|
20479
|
+
};
|
|
20480
|
+
|
|
20414
20481
|
const obj_values_to_update = func.datasource.get_viewFields_for_update_function(SESSION_ID, calling_trigger_prop, null, dsSessionP);
|
|
20415
20482
|
if (!obj_values_to_update || xu_isEmpty(obj_values_to_update)) {
|
|
20416
20483
|
func.utils.debug_report(SESSION_ID, 'Update values object is empty', '', 'W');
|
|
@@ -20428,9 +20495,8 @@ func.events.execute = async function (
|
|
|
20428
20495
|
iterate_info = element_meta?.iterate_info || null;
|
|
20429
20496
|
}
|
|
20430
20497
|
|
|
20431
|
-
let ret_field_id = await func.expression.get(SESSION_ID, val.id.trim(), dsSessionP, 'update', null, null, null, null, null, null, iterate_info);
|
|
20432
20498
|
let ret_value = await func.expression.get(SESSION_ID, val.val.trim(), dsSessionP, 'update', null, null, null, null, null, null, iterate_info);
|
|
20433
|
-
let _field_id =
|
|
20499
|
+
let _field_id = await resolve_update_field_id(val.id, iterate_info);
|
|
20434
20500
|
let _value = ret_value.result;
|
|
20435
20501
|
|
|
20436
20502
|
updates.push({ _field_id, _value });
|