@xuda.io/runtime-bundle 1.0.656 → 1.0.658

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