@xuda.io/runtime-bundle 1.0.517 → 1.0.519

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.
@@ -30161,201 +30161,201 @@ func.datasource.del = function (SESSION_ID, dsP) {
30161
30161
  }
30162
30162
  perform_delete();
30163
30163
  };
30164
- func.datasource.update_old = async function (SESSION_ID, datasource_changes, update_local_scope_only, avoid_refresh) {
30165
- return new Promise(async (resolve, reject) => {
30166
- var _session = SESSION_OBJ[SESSION_ID];
30167
-
30168
- if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== 'undefined' || typeof IS_PROCESS_SERVER !== 'undefined') {
30169
- update_local_scope_only = true;
30170
- }
30171
-
30172
- if (typeof glb.GLOBAL_VARS === 'undefined') {
30173
- glb.GLOBAL_VARS = (await func.common.get_module(SESSION_ID, 'xuda-system-globals-module.mjs')).system_globals;
30174
- }
30175
-
30176
- const set_fieldComputed_dependencies = async function (dsNo, field_id, parent_ds) {
30177
- // iterate child ds
30178
- for (const [dsSession, _ds] of Object.entries(_session.DS_GLB)) {
30179
- if (parent_ds !== null) {
30180
- if (_ds.parentDataSourceNo != parent_ds) continue;
30181
- } else {
30182
- if (dsSession != dsNo) continue;
30183
- }
30184
- let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
30185
- if (tree_ret.menuType === 'component' || tree_ret.menuType === 'globals') {
30186
- // check if field has fieldComputed property
30187
- const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSession);
30188
- // find if field is computed
30189
- let fieldComputed_propExpressions, fieldComputed_id;
30190
- for await (const val of _progFields) {
30191
- const fieldId = val.data.field_id;
30192
-
30193
- // if (fieldId !== field_id) continue
30194
- if (val.data.type !== 'virtual' || !val.props.fieldComputed) continue;
30195
-
30196
- const _propExpressions = val.props?.propExpressions?.fieldValue;
30197
- if (_propExpressions && JSON.stringify(_propExpressions).includes(field_id)) {
30198
- fieldComputed_propExpressions = _propExpressions;
30199
- fieldComputed_id = fieldId;
30200
- }
30201
- }
30164
+ // func.datasource.update_old = async function (SESSION_ID, datasource_changes, update_local_scope_only, avoid_refresh) {
30165
+ // return new Promise(async (resolve, reject) => {
30166
+ // var _session = SESSION_OBJ[SESSION_ID];
30202
30167
 
30203
- if (!fieldComputed_id) return;
30204
-
30205
- // iterate ds rows
30206
- for (const row of _ds.data_feed?.rows || []) {
30207
- // iterate row fields
30208
- for (const [key, val] of Object.entries(row)) {
30209
- if (key !== fieldComputed_id) continue;
30210
- try {
30211
- let ret = await func.expression.get(SESSION_ID, fieldComputed_propExpressions, dsNo, 'update', row._ROWID);
30212
-
30213
- const row_idx = func.common.find_ROWID_idx(_ds, row._ROWID);
30214
- if (_ds.data_feed.rows[row_idx][fieldComputed_id] !== ret.result) {
30215
- _ds.data_feed.rows[row_idx][fieldComputed_id] = ret.result;
30216
- if (!fields_changed.includes(fieldComputed_id)) {
30217
- fields_changed.push(fieldComputed_id);
30218
- }
30219
- if (!datasource_changed.includes(dsSession)) {
30220
- datasource_changed.push(dsSession);
30221
- }
30222
- }
30223
- } catch (err) {
30224
- console.error(err);
30225
- }
30226
- }
30227
- }
30228
- }
30229
- await set_fieldComputed_dependencies(dsNo, field_id, dsSession);
30230
- }
30231
- };
30168
+ // if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== 'undefined' || typeof IS_PROCESS_SERVER !== 'undefined') {
30169
+ // update_local_scope_only = true;
30170
+ // }
30232
30171
 
30233
- var fields_changed = [];
30234
- var datasource_changed = [];
30235
- let client_datasource_changes = {};
30236
- let server_datasource_changes = {};
30237
- // iterate changes datasource
30238
- for await (const [dataSource, row_data] of Object.entries(datasource_changes)) {
30239
- var _ds = _session.DS_GLB[dataSource];
30240
- if (!_ds) {
30241
- continue;
30242
- }
30172
+ // if (typeof glb.GLOBAL_VARS === 'undefined') {
30173
+ // glb.GLOBAL_VARS = (await func.common.get_module(SESSION_ID, 'xuda-system-globals-module.mjs')).system_globals;
30174
+ // }
30243
30175
 
30244
- const update_xu_ref = async function () {
30245
- let _ds_0 = _session.DS_GLB[0];
30246
- for ([ref_name, val] of Object.entries(_ds_0.data_system['SYS_GLOBAL_OBJ_REFS'])) {
30247
- if (val.ds.dsSession == dataSource) {
30248
- func.UI.update_xu_ref(SESSION_ID, dataSource, ref_name);
30249
- }
30250
- }
30251
- };
30176
+ // const set_fieldComputed_dependencies = async function (dsNo, field_id, parent_ds) {
30177
+ // // iterate child ds
30178
+ // for (const [dsSession, _ds] of Object.entries(_session.DS_GLB)) {
30179
+ // if (parent_ds !== null) {
30180
+ // if (_ds.parentDataSourceNo != parent_ds) continue;
30181
+ // } else {
30182
+ // if (dsSession != dsNo) continue;
30183
+ // }
30184
+ // let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
30185
+ // if (tree_ret.menuType === 'component' || tree_ret.menuType === 'globals') {
30186
+ // // check if field has fieldComputed property
30187
+ // const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSession);
30188
+ // // find if field is computed
30189
+ // let fieldComputed_propExpressions, fieldComputed_id;
30190
+ // for await (const val of _progFields) {
30191
+ // const fieldId = val.data.field_id;
30192
+
30193
+ // // if (fieldId !== field_id) continue
30194
+ // if (val.data.type !== 'virtual' || !val.props.fieldComputed) continue;
30195
+
30196
+ // const _propExpressions = val.props?.propExpressions?.fieldValue;
30197
+ // if (_propExpressions && JSON.stringify(_propExpressions).includes(field_id)) {
30198
+ // fieldComputed_propExpressions = _propExpressions;
30199
+ // fieldComputed_id = fieldId;
30200
+ // }
30201
+ // }
30252
30202
 
30253
- // iterate changes records
30254
- for (const [record_id, fields_data] of Object.entries(row_data)) {
30255
- // iterate changes fields
30256
- for (const [field_id, value] of Object.entries(fields_data)) {
30257
- // mechanism to make update directly on the datasource object
30258
- if (record_id === 'datasource_main') {
30259
- _.set(_ds, field_id, value);
30260
- update_xu_ref();
30261
- continue;
30262
- }
30203
+ // if (!fieldComputed_id) return;
30204
+
30205
+ // // iterate ds rows
30206
+ // for (const row of _ds.data_feed?.rows || []) {
30207
+ // // iterate row fields
30208
+ // for (const [key, val] of Object.entries(row)) {
30209
+ // if (key !== fieldComputed_id) continue;
30210
+ // try {
30211
+ // let ret = await func.expression.get(SESSION_ID, fieldComputed_propExpressions, dsNo, 'update', row._ROWID);
30212
+
30213
+ // const row_idx = func.common.find_ROWID_idx(_ds, row._ROWID);
30214
+ // if (_ds.data_feed.rows[row_idx][fieldComputed_id] !== ret.result) {
30215
+ // _ds.data_feed.rows[row_idx][fieldComputed_id] = ret.result;
30216
+ // if (!fields_changed.includes(fieldComputed_id)) {
30217
+ // fields_changed.push(fieldComputed_id);
30218
+ // }
30219
+ // if (!datasource_changed.includes(dsSession)) {
30220
+ // datasource_changed.push(dsSession);
30221
+ // }
30222
+ // }
30223
+ // } catch (err) {
30224
+ // console.error(err);
30225
+ // }
30226
+ // }
30227
+ // }
30228
+ // }
30229
+ // await set_fieldComputed_dependencies(dsNo, field_id, dsSession);
30230
+ // }
30231
+ // };
30232
+
30233
+ // var fields_changed = [];
30234
+ // var datasource_changed = [];
30235
+ // let client_datasource_changes = {};
30236
+ // let server_datasource_changes = {};
30237
+ // // iterate changes datasource
30238
+ // for await (const [dataSource, row_data] of Object.entries(datasource_changes)) {
30239
+ // var _ds = _session.DS_GLB[dataSource];
30240
+ // if (!_ds) {
30241
+ // continue;
30242
+ // }
30263
30243
 
30264
- if (typeof fields_data === 'object') {
30265
- if (glb.GLOBAL_VARS[field_id]) {
30266
- _ds.data_system[field_id] = value;
30267
- continue;
30268
- }
30244
+ // const update_xu_ref = async function () {
30245
+ // let _ds_0 = _session.DS_GLB[0];
30246
+ // for ([ref_name, val] of Object.entries(_ds_0.data_system['SYS_GLOBAL_OBJ_REFS'])) {
30247
+ // if (val.ds.dsSession == dataSource) {
30248
+ // func.UI.update_xu_ref(SESSION_ID, dataSource, ref_name);
30249
+ // }
30250
+ // }
30251
+ // };
30269
30252
 
30270
- // try {
30271
- const row_idx = func.common.find_ROWID_idx(_ds, record_id);
30272
- if (_ds.data_feed.rows[row_idx][field_id] !== value) {
30273
- _ds.data_feed.rows[row_idx][field_id] = value;
30274
- await set_fieldComputed_dependencies(dataSource, field_id, null);
30253
+ // // iterate changes records
30254
+ // for (const [record_id, fields_data] of Object.entries(row_data)) {
30255
+ // // iterate changes fields
30256
+ // for (const [field_id, value] of Object.entries(fields_data)) {
30257
+ // // mechanism to make update directly on the datasource object
30258
+ // if (record_id === 'datasource_main') {
30259
+ // _.set(_ds, field_id, value);
30260
+ // update_xu_ref();
30261
+ // continue;
30262
+ // }
30275
30263
 
30276
- // search the field in refs
30277
- update_xu_ref();
30264
+ // if (typeof fields_data === 'object') {
30265
+ // if (glb.GLOBAL_VARS[field_id]) {
30266
+ // _ds.data_system[field_id] = value;
30267
+ // continue;
30268
+ // }
30278
30269
 
30279
- if (!update_local_scope_only) {
30280
- let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
30281
- if (glb.IS_WORKER) {
30282
- // RUN AT SERVER
30283
- if (tree_ret.menuType === 'globals' || tree_ret.menuType === 'component') {
30284
- const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSource);
30285
- let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
30286
- if (!view_field_obj?.data?.serverField && record_id !== 'data_system') {
30287
- if (!client_datasource_changes[dataSource]) {
30288
- client_datasource_changes[dataSource] = {};
30289
- }
30290
- if (!client_datasource_changes[dataSource][record_id]) {
30291
- client_datasource_changes[dataSource][record_id] = {};
30292
- }
30293
- client_datasource_changes[dataSource][record_id][field_id] = value;
30294
- }
30295
- }
30296
- } else {
30297
- // RUN AT CLIENT
30298
- if ((tree_ret.menuType === 'component' && _ds._run_at !== 'client') || tree_ret.menuType === 'globals') {
30299
- if (!server_datasource_changes[dataSource]) {
30300
- server_datasource_changes[dataSource] = {};
30301
- }
30302
- if (!server_datasource_changes[dataSource][record_id]) {
30303
- server_datasource_changes[dataSource][record_id] = {};
30304
- }
30305
- server_datasource_changes[dataSource][record_id][field_id] = value;
30306
- }
30307
- }
30308
- }
30270
+ // // try {
30271
+ // const row_idx = func.common.find_ROWID_idx(_ds, record_id);
30272
+ // if (_ds.data_feed.rows[row_idx][field_id] !== value) {
30273
+ // _ds.data_feed.rows[row_idx][field_id] = value;
30274
+ // await set_fieldComputed_dependencies(dataSource, field_id, null);
30275
+
30276
+ // // search the field in refs
30277
+ // update_xu_ref();
30278
+
30279
+ // if (!update_local_scope_only) {
30280
+ // let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
30281
+ // if (glb.IS_WORKER) {
30282
+ // // RUN AT SERVER
30283
+ // if (tree_ret.menuType === 'globals' || tree_ret.menuType === 'component') {
30284
+ // const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSource);
30285
+ // let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
30286
+ // if (!view_field_obj?.data?.serverField && record_id !== 'data_system') {
30287
+ // if (!client_datasource_changes[dataSource]) {
30288
+ // client_datasource_changes[dataSource] = {};
30289
+ // }
30290
+ // if (!client_datasource_changes[dataSource][record_id]) {
30291
+ // client_datasource_changes[dataSource][record_id] = {};
30292
+ // }
30293
+ // client_datasource_changes[dataSource][record_id][field_id] = value;
30294
+ // }
30295
+ // }
30296
+ // } else {
30297
+ // // RUN AT CLIENT
30298
+ // if ((tree_ret.menuType === 'component' && _ds._run_at !== 'client') || tree_ret.menuType === 'globals') {
30299
+ // if (!server_datasource_changes[dataSource]) {
30300
+ // server_datasource_changes[dataSource] = {};
30301
+ // }
30302
+ // if (!server_datasource_changes[dataSource][record_id]) {
30303
+ // server_datasource_changes[dataSource][record_id] = {};
30304
+ // }
30305
+ // server_datasource_changes[dataSource][record_id][field_id] = value;
30306
+ // }
30307
+ // }
30308
+ // }
30309
30309
 
30310
- if (!fields_changed.includes(field_id)) {
30311
- fields_changed.push(field_id);
30312
- }
30313
- if (!datasource_changed.includes(dataSource)) {
30314
- datasource_changed.push(dataSource);
30315
- }
30310
+ // if (!fields_changed.includes(field_id)) {
30311
+ // fields_changed.push(field_id);
30312
+ // }
30313
+ // if (!datasource_changed.includes(dataSource)) {
30314
+ // datasource_changed.push(dataSource);
30315
+ // }
30316
30316
 
30317
- if (!_ds.data_feed.rows_changed) {
30318
- _ds.data_feed.rows_changed = [];
30319
- }
30320
- if (!_ds.data_feed.rows_changed.includes(record_id)) _ds.data_feed.rows_changed.push(record_id);
30321
- }
30322
- } else if (fields_data === 'set') {
30323
- _ds.currentRecordId = record_id;
30324
- }
30325
- }
30326
- }
30327
- }
30317
+ // if (!_ds.data_feed.rows_changed) {
30318
+ // _ds.data_feed.rows_changed = [];
30319
+ // }
30320
+ // if (!_ds.data_feed.rows_changed.includes(record_id)) _ds.data_feed.rows_changed.push(record_id);
30321
+ // }
30322
+ // } else if (fields_data === 'set') {
30323
+ // _ds.currentRecordId = record_id;
30324
+ // }
30325
+ // }
30326
+ // }
30327
+ // }
30328
30328
 
30329
- if (glb.IS_WORKER) {
30330
- if (!update_local_scope_only && !_.isEmpty(client_datasource_changes)) {
30331
- func.utils.post_back_to_client(SESSION_ID, 'update_client_eventChangesResults_from_worker', _session.worker_id, client_datasource_changes);
30332
- }
30333
- } else {
30334
- if (!update_local_scope_only && !_.isEmpty(server_datasource_changes)) {
30335
- const ret = await func.index.call_worker(SESSION_ID, {
30336
- service: 'update_datasource_changes_from_client',
30337
- data: {
30338
- session_id: SESSION_ID,
30339
- datasource_changes: server_datasource_changes,
30340
- },
30341
- id: _ds.worker_id,
30342
- });
30343
- }
30344
- ///// REFRESH SCREEN
30345
- if (!avoid_refresh && fields_changed.length) {
30346
- await func.UI.screen.refresh_xu_attributes(SESSION_ID, fields_changed);
30347
- // await removed from the below function cause to dead lock Mar 3 25
30348
- func.UI.screen.refresh_screen(
30349
- SESSION_ID,
30350
- fields_changed,
30351
- null,
30352
- datasource_changed[0], // refresh the current datasource only
30353
- );
30354
- }
30355
- }
30356
- resolve();
30357
- });
30358
- };
30329
+ // if (glb.IS_WORKER) {
30330
+ // if (!update_local_scope_only && !_.isEmpty(client_datasource_changes)) {
30331
+ // func.utils.post_back_to_client(SESSION_ID, 'update_client_eventChangesResults_from_worker', _session.worker_id, client_datasource_changes);
30332
+ // }
30333
+ // } else {
30334
+ // if (!update_local_scope_only && !_.isEmpty(server_datasource_changes)) {
30335
+ // const ret = await func.index.call_worker(SESSION_ID, {
30336
+ // service: 'update_datasource_changes_from_client',
30337
+ // data: {
30338
+ // session_id: SESSION_ID,
30339
+ // datasource_changes: server_datasource_changes,
30340
+ // },
30341
+ // id: _ds.worker_id,
30342
+ // });
30343
+ // }
30344
+ // ///// REFRESH SCREEN
30345
+ // if (!avoid_refresh && fields_changed.length) {
30346
+ // await func.UI.screen.refresh_xu_attributes(SESSION_ID, fields_changed);
30347
+ // // await removed from the below function cause to dead lock Mar 3 25
30348
+ // func.UI.screen.refresh_screen(
30349
+ // SESSION_ID,
30350
+ // fields_changed,
30351
+ // null,
30352
+ // datasource_changed[0], // refresh the current datasource only
30353
+ // );
30354
+ // }
30355
+ // }
30356
+ // resolve();
30357
+ // });
30358
+ // };
30359
30359
 
30360
30360
  func.datasource.update = async function (SESSION_ID, datasource_changes, update_local_scope_only, avoid_refresh) {
30361
30361
  return new Promise(async (resolve, reject) => {
@@ -30430,6 +30430,19 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
30430
30430
  var datasource_changed = [];
30431
30431
  let client_datasource_changes = {};
30432
30432
  let server_datasource_changes = {};
30433
+
30434
+ const update_xu_ref = async function (dataSource, field_id) {
30435
+ let ret;
30436
+ let _ds_0 = _session.DS_GLB[0];
30437
+ for ([ref_name, val] of Object.entries(_ds_0.data_system['SYS_GLOBAL_OBJ_REFS'])) {
30438
+ if (val.ds.dsSession == dataSource) {
30439
+ func.UI.update_xu_ref(SESSION_ID, dataSource, ref_name);
30440
+ ret = true;
30441
+ }
30442
+ }
30443
+ return ret;
30444
+ };
30445
+
30433
30446
  // iterate changes datasource
30434
30447
  for await (const [dataSource, row_data] of Object.entries(datasource_changes)) {
30435
30448
  var _ds = _session.DS_GLB[dataSource];
@@ -30437,15 +30450,6 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
30437
30450
  continue;
30438
30451
  }
30439
30452
 
30440
- const update_xu_ref = async function () {
30441
- let _ds_0 = _session.DS_GLB[0];
30442
- for ([ref_name, val] of Object.entries(_ds_0.data_system['SYS_GLOBAL_OBJ_REFS'])) {
30443
- if (val.ds.dsSession == dataSource) {
30444
- func.UI.update_xu_ref(SESSION_ID, dataSource, ref_name);
30445
- }
30446
- }
30447
- };
30448
-
30449
30453
  // iterate changes records
30450
30454
  for (const [record_id, fields_data] of Object.entries(row_data)) {
30451
30455
  // iterate changes fields
@@ -30453,7 +30457,11 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
30453
30457
  // mechanism to make update directly on the datasource object
30454
30458
  if (record_id === 'datasource_main') {
30455
30459
  _.set(_ds, field_id, value);
30456
- update_xu_ref();
30460
+ const ret = update_xu_ref(dataSource, field_id);
30461
+ if (ret) {
30462
+ fields_changed.push(field_id);
30463
+ datasource_changed.push(dataSource);
30464
+ }
30457
30465
  continue;
30458
30466
  }
30459
30467
 
@@ -30470,7 +30478,7 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
30470
30478
  await set_fieldComputed_dependencies(dataSource, field_id, null);
30471
30479
 
30472
30480
  // search the field in refs
30473
- update_xu_ref();
30481
+ update_xu_ref(dataSource, field_id);
30474
30482
 
30475
30483
  if (!update_local_scope_only) {
30476
30484
  let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);