@xuda.io/xuda-worker-bundle-min 1.3.2453 → 1.3.2455
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/index.js +68 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -5288,6 +5288,38 @@ func.datasource.get_viewFields_for_update_function = function (SESSION_ID, calli
|
|
|
5288
5288
|
return viewFields;
|
|
5289
5289
|
};
|
|
5290
5290
|
func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, rowIdP, org_dsSessionP) {
|
|
5291
|
+
const normalize_field_id = function (field_id) {
|
|
5292
|
+
if (typeof field_id === 'string') {
|
|
5293
|
+
return field_id;
|
|
5294
|
+
}
|
|
5295
|
+
if (typeof field_id?.field_id === 'string') {
|
|
5296
|
+
return field_id.field_id;
|
|
5297
|
+
}
|
|
5298
|
+
if (typeof field_id?.id === 'string') {
|
|
5299
|
+
return field_id.id;
|
|
5300
|
+
}
|
|
5301
|
+
if (typeof field_id === 'number' || typeof field_id === 'boolean' || typeof field_id === 'bigint') {
|
|
5302
|
+
return field_id.toString();
|
|
5303
|
+
}
|
|
5304
|
+
const coerced = field_id?.toString?.();
|
|
5305
|
+
if (typeof coerced === 'string' && coerced && coerced !== '[object Object]') {
|
|
5306
|
+
return coerced;
|
|
5307
|
+
}
|
|
5308
|
+
return null;
|
|
5309
|
+
};
|
|
5310
|
+
const return_missing_value = function (field_id, currentRecordId = null) {
|
|
5311
|
+
return {
|
|
5312
|
+
ret: {
|
|
5313
|
+
value: undefined,
|
|
5314
|
+
type: 'string',
|
|
5315
|
+
prop: null,
|
|
5316
|
+
},
|
|
5317
|
+
dsSessionP,
|
|
5318
|
+
fieldIdP: field_id,
|
|
5319
|
+
currentRecordId,
|
|
5320
|
+
found: false,
|
|
5321
|
+
};
|
|
5322
|
+
};
|
|
5291
5323
|
const return_value = async (field_id, value) => {
|
|
5292
5324
|
const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSessionP);
|
|
5293
5325
|
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
@@ -5416,9 +5448,21 @@ func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, ro
|
|
|
5416
5448
|
// let prev_ds = dsSessionP - 1;
|
|
5417
5449
|
return await func.datasource.get_value(SESSION_ID, fieldIdP, dsSessionP - 1, rowIdP, org_dsSessionP);
|
|
5418
5450
|
}
|
|
5451
|
+
const normalized_missing_field = normalize_field_id(fieldIdP);
|
|
5452
|
+
if (normalized_missing_field === null) {
|
|
5453
|
+
return return_missing_value(fieldIdP);
|
|
5454
|
+
}
|
|
5455
|
+
fieldIdP = normalized_missing_field;
|
|
5419
5456
|
return await return_value(fieldIdP);
|
|
5420
5457
|
} //console.error("error: datasource not exist: " + dsSessionP);
|
|
5421
5458
|
|
|
5459
|
+
const normalized_field_id = normalize_field_id(fieldIdP);
|
|
5460
|
+
if (normalized_field_id === null) {
|
|
5461
|
+
func.utils.debug_report(SESSION_ID, 'Datasource get value', `Invalid field id type: ${typeof fieldIdP}`, 'W');
|
|
5462
|
+
return return_missing_value(fieldIdP, _ds.currentRecordId);
|
|
5463
|
+
}
|
|
5464
|
+
fieldIdP = normalized_field_id;
|
|
5465
|
+
|
|
5422
5466
|
let recordId = rowIdP;
|
|
5423
5467
|
if (!recordId) {
|
|
5424
5468
|
recordId = _ds.currentRecordId;
|
|
@@ -8823,6 +8867,29 @@ func.events.execute = async function (
|
|
|
8823
8867
|
return result;
|
|
8824
8868
|
},
|
|
8825
8869
|
update: async function () {
|
|
8870
|
+
const resolve_update_field_id = async function (field_expr, iterate_info) {
|
|
8871
|
+
let trimmed = field_expr?.trim?.() || '';
|
|
8872
|
+
if (!trimmed) {
|
|
8873
|
+
return trimmed;
|
|
8874
|
+
}
|
|
8875
|
+
|
|
8876
|
+
const first = trimmed.substring(0, 1);
|
|
8877
|
+
const last = trimmed.substring(trimmed.length - 1);
|
|
8878
|
+
if ((first === "'" || first === '"' || first === '`') && last === first) {
|
|
8879
|
+
trimmed = trimmed.substring(1, trimmed.length - 1).trim();
|
|
8880
|
+
}
|
|
8881
|
+
|
|
8882
|
+
if (/^@?[A-Za-z_][\w\-\:\.]*$/.test(trimmed)) {
|
|
8883
|
+
return trimmed.substring(0, 1) === '@' ? trimmed.substring(1) : trimmed;
|
|
8884
|
+
}
|
|
8885
|
+
|
|
8886
|
+
let ret_field_id = await func.expression.get(SESSION_ID, trimmed, dsSessionP, 'update', null, null, null, null, null, null, iterate_info);
|
|
8887
|
+
if (typeof ret_field_id?.result === 'string' && ret_field_id.result.substring(0, 1) === '@') {
|
|
8888
|
+
return ret_field_id.result.substring(1);
|
|
8889
|
+
}
|
|
8890
|
+
return ret_field_id?.result;
|
|
8891
|
+
};
|
|
8892
|
+
|
|
8826
8893
|
const obj_values_to_update = func.datasource.get_viewFields_for_update_function(SESSION_ID, calling_trigger_prop, null, dsSessionP);
|
|
8827
8894
|
if (!obj_values_to_update || xu_isEmpty(obj_values_to_update)) {
|
|
8828
8895
|
func.utils.debug_report(SESSION_ID, 'Update values object is empty', '', 'W');
|
|
@@ -8840,9 +8907,8 @@ func.events.execute = async function (
|
|
|
8840
8907
|
iterate_info = element_meta?.iterate_info || null;
|
|
8841
8908
|
}
|
|
8842
8909
|
|
|
8843
|
-
let ret_field_id = await func.expression.get(SESSION_ID, val.id.trim(), dsSessionP, 'update', null, null, null, null, null, null, iterate_info);
|
|
8844
8910
|
let ret_value = await func.expression.get(SESSION_ID, val.val.trim(), dsSessionP, 'update', null, null, null, null, null, null, iterate_info);
|
|
8845
|
-
let _field_id =
|
|
8911
|
+
let _field_id = await resolve_update_field_id(val.id, iterate_info);
|
|
8846
8912
|
let _value = ret_value.result;
|
|
8847
8913
|
|
|
8848
8914
|
updates.push({ _field_id, _value });
|