@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
|
@@ -40128,6 +40128,38 @@ func.datasource.get_viewFields_for_update_function = function (SESSION_ID, calli
|
|
|
40128
40128
|
return viewFields;
|
|
40129
40129
|
};
|
|
40130
40130
|
func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, rowIdP, org_dsSessionP) {
|
|
40131
|
+
const normalize_field_id = function (field_id) {
|
|
40132
|
+
if (typeof field_id === 'string') {
|
|
40133
|
+
return field_id;
|
|
40134
|
+
}
|
|
40135
|
+
if (typeof field_id?.field_id === 'string') {
|
|
40136
|
+
return field_id.field_id;
|
|
40137
|
+
}
|
|
40138
|
+
if (typeof field_id?.id === 'string') {
|
|
40139
|
+
return field_id.id;
|
|
40140
|
+
}
|
|
40141
|
+
if (typeof field_id === 'number' || typeof field_id === 'boolean' || typeof field_id === 'bigint') {
|
|
40142
|
+
return field_id.toString();
|
|
40143
|
+
}
|
|
40144
|
+
const coerced = field_id?.toString?.();
|
|
40145
|
+
if (typeof coerced === 'string' && coerced && coerced !== '[object Object]') {
|
|
40146
|
+
return coerced;
|
|
40147
|
+
}
|
|
40148
|
+
return null;
|
|
40149
|
+
};
|
|
40150
|
+
const return_missing_value = function (field_id, currentRecordId = null) {
|
|
40151
|
+
return {
|
|
40152
|
+
ret: {
|
|
40153
|
+
value: undefined,
|
|
40154
|
+
type: 'string',
|
|
40155
|
+
prop: null,
|
|
40156
|
+
},
|
|
40157
|
+
dsSessionP,
|
|
40158
|
+
fieldIdP: field_id,
|
|
40159
|
+
currentRecordId,
|
|
40160
|
+
found: false,
|
|
40161
|
+
};
|
|
40162
|
+
};
|
|
40131
40163
|
const return_value = async (field_id, value) => {
|
|
40132
40164
|
const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSessionP);
|
|
40133
40165
|
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
@@ -40256,9 +40288,21 @@ func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, ro
|
|
|
40256
40288
|
// let prev_ds = dsSessionP - 1;
|
|
40257
40289
|
return await func.datasource.get_value(SESSION_ID, fieldIdP, dsSessionP - 1, rowIdP, org_dsSessionP);
|
|
40258
40290
|
}
|
|
40291
|
+
const normalized_missing_field = normalize_field_id(fieldIdP);
|
|
40292
|
+
if (normalized_missing_field === null) {
|
|
40293
|
+
return return_missing_value(fieldIdP);
|
|
40294
|
+
}
|
|
40295
|
+
fieldIdP = normalized_missing_field;
|
|
40259
40296
|
return await return_value(fieldIdP);
|
|
40260
40297
|
} //console.error("error: datasource not exist: " + dsSessionP);
|
|
40261
40298
|
|
|
40299
|
+
const normalized_field_id = normalize_field_id(fieldIdP);
|
|
40300
|
+
if (normalized_field_id === null) {
|
|
40301
|
+
func.utils.debug_report(SESSION_ID, 'Datasource get value', `Invalid field id type: ${typeof fieldIdP}`, 'W');
|
|
40302
|
+
return return_missing_value(fieldIdP, _ds.currentRecordId);
|
|
40303
|
+
}
|
|
40304
|
+
fieldIdP = normalized_field_id;
|
|
40305
|
+
|
|
40262
40306
|
let recordId = rowIdP;
|
|
40263
40307
|
if (!recordId) {
|
|
40264
40308
|
recordId = _ds.currentRecordId;
|
|
@@ -43416,6 +43460,29 @@ func.events.execute = async function (
|
|
|
43416
43460
|
return result;
|
|
43417
43461
|
},
|
|
43418
43462
|
update: async function () {
|
|
43463
|
+
const resolve_update_field_id = async function (field_expr, iterate_info) {
|
|
43464
|
+
let trimmed = field_expr?.trim?.() || '';
|
|
43465
|
+
if (!trimmed) {
|
|
43466
|
+
return trimmed;
|
|
43467
|
+
}
|
|
43468
|
+
|
|
43469
|
+
const first = trimmed.substring(0, 1);
|
|
43470
|
+
const last = trimmed.substring(trimmed.length - 1);
|
|
43471
|
+
if ((first === "'" || first === '"' || first === '`') && last === first) {
|
|
43472
|
+
trimmed = trimmed.substring(1, trimmed.length - 1).trim();
|
|
43473
|
+
}
|
|
43474
|
+
|
|
43475
|
+
if (/^@?[A-Za-z_][\w\-\:\.]*$/.test(trimmed)) {
|
|
43476
|
+
return trimmed.substring(0, 1) === '@' ? trimmed.substring(1) : trimmed;
|
|
43477
|
+
}
|
|
43478
|
+
|
|
43479
|
+
let ret_field_id = await func.expression.get(SESSION_ID, trimmed, dsSessionP, 'update', null, null, null, null, null, null, iterate_info);
|
|
43480
|
+
if (typeof ret_field_id?.result === 'string' && ret_field_id.result.substring(0, 1) === '@') {
|
|
43481
|
+
return ret_field_id.result.substring(1);
|
|
43482
|
+
}
|
|
43483
|
+
return ret_field_id?.result;
|
|
43484
|
+
};
|
|
43485
|
+
|
|
43419
43486
|
const obj_values_to_update = func.datasource.get_viewFields_for_update_function(SESSION_ID, calling_trigger_prop, null, dsSessionP);
|
|
43420
43487
|
if (!obj_values_to_update || xu_isEmpty(obj_values_to_update)) {
|
|
43421
43488
|
func.utils.debug_report(SESSION_ID, 'Update values object is empty', '', 'W');
|
|
@@ -43433,9 +43500,8 @@ func.events.execute = async function (
|
|
|
43433
43500
|
iterate_info = element_meta?.iterate_info || null;
|
|
43434
43501
|
}
|
|
43435
43502
|
|
|
43436
|
-
let ret_field_id = await func.expression.get(SESSION_ID, val.id.trim(), dsSessionP, 'update', null, null, null, null, null, null, iterate_info);
|
|
43437
43503
|
let ret_value = await func.expression.get(SESSION_ID, val.val.trim(), dsSessionP, 'update', null, null, null, null, null, null, iterate_info);
|
|
43438
|
-
let _field_id =
|
|
43504
|
+
let _field_id = await resolve_update_field_id(val.id, iterate_info);
|
|
43439
43505
|
let _value = ret_value.result;
|
|
43440
43506
|
|
|
43441
43507
|
updates.push({ _field_id, _value });
|