@xuda.io/runtime-bundle 1.0.655 → 1.0.657

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.
@@ -2528,12 +2528,19 @@ func.datasource.run_events_functions = async function (SESSION_ID, dataSourceSes
2528
2528
  for (let job_num of jobs) {
2529
2529
  job_promises.push(
2530
2530
  new Promise((resolve, reject) => {
2531
+ let i = 0;
2531
2532
  const interval = setInterval(() => {
2533
+ i++;
2532
2534
  var job_index = func.events.find_job_index(SESSION_ID, job_num);
2533
2535
  if (job_index == null) {
2534
2536
  clearInterval(interval);
2535
2537
  resolve(job_num);
2536
2538
  }
2539
+ if (i > 20) {
2540
+ console.error('deadlock detected');
2541
+ clearInterval(interval);
2542
+ resolve(job_num);
2543
+ }
2537
2544
  }, 100);
2538
2545
  }),
2539
2546
  );
@@ -3110,201 +3117,6 @@ func.datasource.del = function (SESSION_ID, dsP) {
3110
3117
  }
3111
3118
  perform_delete();
3112
3119
  };
3113
- // func.datasource.update_old = async function (SESSION_ID, datasource_changes, update_local_scope_only, avoid_refresh) {
3114
- // return new Promise(async (resolve, reject) => {
3115
- // var _session = SESSION_OBJ[SESSION_ID];
3116
-
3117
- // if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== 'undefined' || typeof IS_PROCESS_SERVER !== 'undefined') {
3118
- // update_local_scope_only = true;
3119
- // }
3120
-
3121
- // if (typeof glb.GLOBAL_VARS === 'undefined') {
3122
- // glb.GLOBAL_VARS = (await func.common.get_module(SESSION_ID, 'xuda-system-globals-module.mjs')).system_globals;
3123
- // }
3124
-
3125
- // const set_fieldComputed_dependencies = async function (dsNo, field_id, parent_ds) {
3126
- // // iterate child ds
3127
- // for (const [dsSession, _ds] of Object.entries(_session.DS_GLB)) {
3128
- // if (parent_ds !== null) {
3129
- // if (_ds.parentDataSourceNo != parent_ds) continue;
3130
- // } else {
3131
- // if (dsSession != dsNo) continue;
3132
- // }
3133
- // let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
3134
- // if (tree_ret.menuType === 'component' || tree_ret.menuType === 'globals') {
3135
- // // check if field has fieldComputed property
3136
- // const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSession);
3137
- // // find if field is computed
3138
- // let fieldComputed_propExpressions, fieldComputed_id;
3139
- // for await (const val of _progFields) {
3140
- // const fieldId = val.data.field_id;
3141
-
3142
- // // if (fieldId !== field_id) continue
3143
- // if (val.data.type !== 'virtual' || !val.props.fieldComputed) continue;
3144
-
3145
- // const _propExpressions = val.props?.propExpressions?.fieldValue;
3146
- // if (_propExpressions && JSON.stringify(_propExpressions).includes(field_id)) {
3147
- // fieldComputed_propExpressions = _propExpressions;
3148
- // fieldComputed_id = fieldId;
3149
- // }
3150
- // }
3151
-
3152
- // if (!fieldComputed_id) return;
3153
-
3154
- // // iterate ds rows
3155
- // for (const row of _ds.data_feed?.rows || []) {
3156
- // // iterate row fields
3157
- // for (const [key, val] of Object.entries(row)) {
3158
- // if (key !== fieldComputed_id) continue;
3159
- // try {
3160
- // let ret = await func.expression.get(SESSION_ID, fieldComputed_propExpressions, dsNo, 'update', row._ROWID);
3161
-
3162
- // const row_idx = func.common.find_ROWID_idx(_ds, row._ROWID);
3163
- // if (_ds.data_feed.rows[row_idx][fieldComputed_id] !== ret.result) {
3164
- // _ds.data_feed.rows[row_idx][fieldComputed_id] = ret.result;
3165
- // if (!fields_changed.includes(fieldComputed_id)) {
3166
- // fields_changed.push(fieldComputed_id);
3167
- // }
3168
- // if (!datasource_changed.includes(dsSession)) {
3169
- // datasource_changed.push(dsSession);
3170
- // }
3171
- // }
3172
- // } catch (err) {
3173
- // console.error(err);
3174
- // }
3175
- // }
3176
- // }
3177
- // }
3178
- // await set_fieldComputed_dependencies(dsNo, field_id, dsSession);
3179
- // }
3180
- // };
3181
-
3182
- // var fields_changed = [];
3183
- // var datasource_changed = [];
3184
- // let client_datasource_changes = {};
3185
- // let server_datasource_changes = {};
3186
- // // iterate changes datasource
3187
- // for await (const [dataSource, row_data] of Object.entries(datasource_changes)) {
3188
- // var _ds = _session.DS_GLB[dataSource];
3189
- // if (!_ds) {
3190
- // continue;
3191
- // }
3192
-
3193
- // const update_xu_ref = async function () {
3194
- // let _ds_0 = _session.DS_GLB[0];
3195
- // for ([ref_name, val] of Object.entries(_ds_0.data_system['SYS_GLOBAL_OBJ_REFS'])) {
3196
- // if (val.ds.dsSession == dataSource) {
3197
- // func.UI.update_xu_ref(SESSION_ID, dataSource, ref_name);
3198
- // }
3199
- // }
3200
- // };
3201
-
3202
- // // iterate changes records
3203
- // for (const [record_id, fields_data] of Object.entries(row_data)) {
3204
- // // iterate changes fields
3205
- // for (const [field_id, value] of Object.entries(fields_data)) {
3206
- // // mechanism to make update directly on the datasource object
3207
- // if (record_id === 'datasource_main') {
3208
- // _.set(_ds, field_id, value);
3209
- // update_xu_ref();
3210
- // continue;
3211
- // }
3212
-
3213
- // if (typeof fields_data === 'object') {
3214
- // if (glb.GLOBAL_VARS[field_id]) {
3215
- // _ds.data_system[field_id] = value;
3216
- // continue;
3217
- // }
3218
-
3219
- // // try {
3220
- // const row_idx = func.common.find_ROWID_idx(_ds, record_id);
3221
- // if (_ds.data_feed.rows[row_idx][field_id] !== value) {
3222
- // _ds.data_feed.rows[row_idx][field_id] = value;
3223
- // await set_fieldComputed_dependencies(dataSource, field_id, null);
3224
-
3225
- // // search the field in refs
3226
- // update_xu_ref();
3227
-
3228
- // if (!update_local_scope_only) {
3229
- // let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
3230
- // if (glb.IS_WORKER) {
3231
- // // RUN AT SERVER
3232
- // if (tree_ret.menuType === 'globals' || tree_ret.menuType === 'component') {
3233
- // const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSource);
3234
- // let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
3235
- // if (!view_field_obj?.data?.serverField && record_id !== 'data_system') {
3236
- // if (!client_datasource_changes[dataSource]) {
3237
- // client_datasource_changes[dataSource] = {};
3238
- // }
3239
- // if (!client_datasource_changes[dataSource][record_id]) {
3240
- // client_datasource_changes[dataSource][record_id] = {};
3241
- // }
3242
- // client_datasource_changes[dataSource][record_id][field_id] = value;
3243
- // }
3244
- // }
3245
- // } else {
3246
- // // RUN AT CLIENT
3247
- // if ((tree_ret.menuType === 'component' && _ds._run_at !== 'client') || tree_ret.menuType === 'globals') {
3248
- // if (!server_datasource_changes[dataSource]) {
3249
- // server_datasource_changes[dataSource] = {};
3250
- // }
3251
- // if (!server_datasource_changes[dataSource][record_id]) {
3252
- // server_datasource_changes[dataSource][record_id] = {};
3253
- // }
3254
- // server_datasource_changes[dataSource][record_id][field_id] = value;
3255
- // }
3256
- // }
3257
- // }
3258
-
3259
- // if (!fields_changed.includes(field_id)) {
3260
- // fields_changed.push(field_id);
3261
- // }
3262
- // if (!datasource_changed.includes(dataSource)) {
3263
- // datasource_changed.push(dataSource);
3264
- // }
3265
-
3266
- // if (!_ds.data_feed.rows_changed) {
3267
- // _ds.data_feed.rows_changed = [];
3268
- // }
3269
- // if (!_ds.data_feed.rows_changed.includes(record_id)) _ds.data_feed.rows_changed.push(record_id);
3270
- // }
3271
- // } else if (fields_data === 'set') {
3272
- // _ds.currentRecordId = record_id;
3273
- // }
3274
- // }
3275
- // }
3276
- // }
3277
-
3278
- // if (glb.IS_WORKER) {
3279
- // if (!update_local_scope_only && !_.isEmpty(client_datasource_changes)) {
3280
- // func.utils.post_back_to_client(SESSION_ID, 'update_client_eventChangesResults_from_worker', _session.worker_id, client_datasource_changes);
3281
- // }
3282
- // } else {
3283
- // if (!update_local_scope_only && !_.isEmpty(server_datasource_changes)) {
3284
- // const ret = await func.index.call_worker(SESSION_ID, {
3285
- // service: 'update_datasource_changes_from_client',
3286
- // data: {
3287
- // session_id: SESSION_ID,
3288
- // datasource_changes: server_datasource_changes,
3289
- // },
3290
- // id: _ds.worker_id,
3291
- // });
3292
- // }
3293
- // ///// REFRESH SCREEN
3294
- // if (!avoid_refresh && fields_changed.length) {
3295
- // await func.UI.screen.refresh_xu_attributes(SESSION_ID, fields_changed);
3296
- // // await removed from the below function cause to dead lock Mar 3 25
3297
- // func.UI.screen.refresh_screen(
3298
- // SESSION_ID,
3299
- // fields_changed,
3300
- // null,
3301
- // datasource_changed[0], // refresh the current datasource only
3302
- // );
3303
- // }
3304
- // }
3305
- // resolve();
3306
- // });
3307
- // };
3308
3120
 
3309
3121
  func.datasource.update = async function (SESSION_ID, datasource_changes, update_local_scope_only, avoid_refresh) {
3310
3122
  return new Promise(async (resolve, reject) => {
@@ -2528,12 +2528,19 @@ func.datasource.run_events_functions = async function (SESSION_ID, dataSourceSes
2528
2528
  for (let job_num of jobs) {
2529
2529
  job_promises.push(
2530
2530
  new Promise((resolve, reject) => {
2531
+ let i = 0;
2531
2532
  const interval = setInterval(() => {
2533
+ i++;
2532
2534
  var job_index = func.events.find_job_index(SESSION_ID, job_num);
2533
2535
  if (job_index == null) {
2534
2536
  clearInterval(interval);
2535
2537
  resolve(job_num);
2536
2538
  }
2539
+ if (i > 20) {
2540
+ console.error('deadlock detected');
2541
+ clearInterval(interval);
2542
+ resolve(job_num);
2543
+ }
2537
2544
  }, 100);
2538
2545
  }),
2539
2546
  );
@@ -3110,201 +3117,6 @@ func.datasource.del = function (SESSION_ID, dsP) {
3110
3117
  }
3111
3118
  perform_delete();
3112
3119
  };
3113
- // func.datasource.update_old = async function (SESSION_ID, datasource_changes, update_local_scope_only, avoid_refresh) {
3114
- // return new Promise(async (resolve, reject) => {
3115
- // var _session = SESSION_OBJ[SESSION_ID];
3116
-
3117
- // if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== 'undefined' || typeof IS_PROCESS_SERVER !== 'undefined') {
3118
- // update_local_scope_only = true;
3119
- // }
3120
-
3121
- // if (typeof glb.GLOBAL_VARS === 'undefined') {
3122
- // glb.GLOBAL_VARS = (await func.common.get_module(SESSION_ID, 'xuda-system-globals-module.mjs')).system_globals;
3123
- // }
3124
-
3125
- // const set_fieldComputed_dependencies = async function (dsNo, field_id, parent_ds) {
3126
- // // iterate child ds
3127
- // for (const [dsSession, _ds] of Object.entries(_session.DS_GLB)) {
3128
- // if (parent_ds !== null) {
3129
- // if (_ds.parentDataSourceNo != parent_ds) continue;
3130
- // } else {
3131
- // if (dsSession != dsNo) continue;
3132
- // }
3133
- // let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
3134
- // if (tree_ret.menuType === 'component' || tree_ret.menuType === 'globals') {
3135
- // // check if field has fieldComputed property
3136
- // const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSession);
3137
- // // find if field is computed
3138
- // let fieldComputed_propExpressions, fieldComputed_id;
3139
- // for await (const val of _progFields) {
3140
- // const fieldId = val.data.field_id;
3141
-
3142
- // // if (fieldId !== field_id) continue
3143
- // if (val.data.type !== 'virtual' || !val.props.fieldComputed) continue;
3144
-
3145
- // const _propExpressions = val.props?.propExpressions?.fieldValue;
3146
- // if (_propExpressions && JSON.stringify(_propExpressions).includes(field_id)) {
3147
- // fieldComputed_propExpressions = _propExpressions;
3148
- // fieldComputed_id = fieldId;
3149
- // }
3150
- // }
3151
-
3152
- // if (!fieldComputed_id) return;
3153
-
3154
- // // iterate ds rows
3155
- // for (const row of _ds.data_feed?.rows || []) {
3156
- // // iterate row fields
3157
- // for (const [key, val] of Object.entries(row)) {
3158
- // if (key !== fieldComputed_id) continue;
3159
- // try {
3160
- // let ret = await func.expression.get(SESSION_ID, fieldComputed_propExpressions, dsNo, 'update', row._ROWID);
3161
-
3162
- // const row_idx = func.common.find_ROWID_idx(_ds, row._ROWID);
3163
- // if (_ds.data_feed.rows[row_idx][fieldComputed_id] !== ret.result) {
3164
- // _ds.data_feed.rows[row_idx][fieldComputed_id] = ret.result;
3165
- // if (!fields_changed.includes(fieldComputed_id)) {
3166
- // fields_changed.push(fieldComputed_id);
3167
- // }
3168
- // if (!datasource_changed.includes(dsSession)) {
3169
- // datasource_changed.push(dsSession);
3170
- // }
3171
- // }
3172
- // } catch (err) {
3173
- // console.error(err);
3174
- // }
3175
- // }
3176
- // }
3177
- // }
3178
- // await set_fieldComputed_dependencies(dsNo, field_id, dsSession);
3179
- // }
3180
- // };
3181
-
3182
- // var fields_changed = [];
3183
- // var datasource_changed = [];
3184
- // let client_datasource_changes = {};
3185
- // let server_datasource_changes = {};
3186
- // // iterate changes datasource
3187
- // for await (const [dataSource, row_data] of Object.entries(datasource_changes)) {
3188
- // var _ds = _session.DS_GLB[dataSource];
3189
- // if (!_ds) {
3190
- // continue;
3191
- // }
3192
-
3193
- // const update_xu_ref = async function () {
3194
- // let _ds_0 = _session.DS_GLB[0];
3195
- // for ([ref_name, val] of Object.entries(_ds_0.data_system['SYS_GLOBAL_OBJ_REFS'])) {
3196
- // if (val.ds.dsSession == dataSource) {
3197
- // func.UI.update_xu_ref(SESSION_ID, dataSource, ref_name);
3198
- // }
3199
- // }
3200
- // };
3201
-
3202
- // // iterate changes records
3203
- // for (const [record_id, fields_data] of Object.entries(row_data)) {
3204
- // // iterate changes fields
3205
- // for (const [field_id, value] of Object.entries(fields_data)) {
3206
- // // mechanism to make update directly on the datasource object
3207
- // if (record_id === 'datasource_main') {
3208
- // _.set(_ds, field_id, value);
3209
- // update_xu_ref();
3210
- // continue;
3211
- // }
3212
-
3213
- // if (typeof fields_data === 'object') {
3214
- // if (glb.GLOBAL_VARS[field_id]) {
3215
- // _ds.data_system[field_id] = value;
3216
- // continue;
3217
- // }
3218
-
3219
- // // try {
3220
- // const row_idx = func.common.find_ROWID_idx(_ds, record_id);
3221
- // if (_ds.data_feed.rows[row_idx][field_id] !== value) {
3222
- // _ds.data_feed.rows[row_idx][field_id] = value;
3223
- // await set_fieldComputed_dependencies(dataSource, field_id, null);
3224
-
3225
- // // search the field in refs
3226
- // update_xu_ref();
3227
-
3228
- // if (!update_local_scope_only) {
3229
- // let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
3230
- // if (glb.IS_WORKER) {
3231
- // // RUN AT SERVER
3232
- // if (tree_ret.menuType === 'globals' || tree_ret.menuType === 'component') {
3233
- // const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSource);
3234
- // let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
3235
- // if (!view_field_obj?.data?.serverField && record_id !== 'data_system') {
3236
- // if (!client_datasource_changes[dataSource]) {
3237
- // client_datasource_changes[dataSource] = {};
3238
- // }
3239
- // if (!client_datasource_changes[dataSource][record_id]) {
3240
- // client_datasource_changes[dataSource][record_id] = {};
3241
- // }
3242
- // client_datasource_changes[dataSource][record_id][field_id] = value;
3243
- // }
3244
- // }
3245
- // } else {
3246
- // // RUN AT CLIENT
3247
- // if ((tree_ret.menuType === 'component' && _ds._run_at !== 'client') || tree_ret.menuType === 'globals') {
3248
- // if (!server_datasource_changes[dataSource]) {
3249
- // server_datasource_changes[dataSource] = {};
3250
- // }
3251
- // if (!server_datasource_changes[dataSource][record_id]) {
3252
- // server_datasource_changes[dataSource][record_id] = {};
3253
- // }
3254
- // server_datasource_changes[dataSource][record_id][field_id] = value;
3255
- // }
3256
- // }
3257
- // }
3258
-
3259
- // if (!fields_changed.includes(field_id)) {
3260
- // fields_changed.push(field_id);
3261
- // }
3262
- // if (!datasource_changed.includes(dataSource)) {
3263
- // datasource_changed.push(dataSource);
3264
- // }
3265
-
3266
- // if (!_ds.data_feed.rows_changed) {
3267
- // _ds.data_feed.rows_changed = [];
3268
- // }
3269
- // if (!_ds.data_feed.rows_changed.includes(record_id)) _ds.data_feed.rows_changed.push(record_id);
3270
- // }
3271
- // } else if (fields_data === 'set') {
3272
- // _ds.currentRecordId = record_id;
3273
- // }
3274
- // }
3275
- // }
3276
- // }
3277
-
3278
- // if (glb.IS_WORKER) {
3279
- // if (!update_local_scope_only && !_.isEmpty(client_datasource_changes)) {
3280
- // func.utils.post_back_to_client(SESSION_ID, 'update_client_eventChangesResults_from_worker', _session.worker_id, client_datasource_changes);
3281
- // }
3282
- // } else {
3283
- // if (!update_local_scope_only && !_.isEmpty(server_datasource_changes)) {
3284
- // const ret = await func.index.call_worker(SESSION_ID, {
3285
- // service: 'update_datasource_changes_from_client',
3286
- // data: {
3287
- // session_id: SESSION_ID,
3288
- // datasource_changes: server_datasource_changes,
3289
- // },
3290
- // id: _ds.worker_id,
3291
- // });
3292
- // }
3293
- // ///// REFRESH SCREEN
3294
- // if (!avoid_refresh && fields_changed.length) {
3295
- // await func.UI.screen.refresh_xu_attributes(SESSION_ID, fields_changed);
3296
- // // await removed from the below function cause to dead lock Mar 3 25
3297
- // func.UI.screen.refresh_screen(
3298
- // SESSION_ID,
3299
- // fields_changed,
3300
- // null,
3301
- // datasource_changed[0], // refresh the current datasource only
3302
- // );
3303
- // }
3304
- // }
3305
- // resolve();
3306
- // });
3307
- // };
3308
3120
 
3309
3121
  func.datasource.update = async function (SESSION_ID, datasource_changes, update_local_scope_only, avoid_refresh) {
3310
3122
  return new Promise(async (resolve, reject) => {