@xuda.io/runtime-bundle 1.0.290 → 1.0.291

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.
@@ -29533,6 +29533,7 @@ func.datasource.execute = async function (SESSION_ID, dataSourceSession, IS_DATA
29533
29533
  await func.datasource.execute_field_init_events(SESSION_ID, dataSourceSession, 'form', 'newRecord');
29534
29534
  }
29535
29535
  }
29536
+ await func.datasource.callback(SESSION_ID, dataSourceSession, args.dataSourceNoP, args.rowIdP, args.jobNoP, null, _ds.prog_id);
29536
29537
  };
29537
29538
  if (!rows) {
29538
29539
  await row_not_found();
@@ -29820,64 +29821,6 @@ func.datasource.render_fields_form = async function (SESSION_ID, dataSourceSessi
29820
29821
  }
29821
29822
  };
29822
29823
 
29823
- // func.datasource.run_rows_form = async function (
29824
- // SESSION_ID,
29825
- // dataSourceSession,
29826
- // rowIdxP,
29827
- // raw_data_row
29828
- // ) {
29829
- // var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
29830
- // if (!_ds) return;
29831
- // let _ROWID = raw_data_row.id;
29832
- // // var val = _ds.data_feed.rows[rowIdxP];
29833
-
29834
- // var idx = rowIdxP;
29835
-
29836
- // const find_ROWID_idx_from_raw_data_arr = function (rowId) {
29837
- // if (!_ds?.v?.raw_data?.rows) {
29838
- // throw new Error("ds.v.raw_data.rows not found");
29839
- // }
29840
-
29841
- // const index = _ds.v.raw_data.rows.findIndex((item) => item.id === rowId);
29842
- // if (index === -1) {
29843
- // throw new Error(`item.id "${rowId}" not found`);
29844
- // }
29845
- // return index;
29846
- // };
29847
-
29848
- // try {
29849
- // idx = find_ROWID_idx_from_raw_data_arr(raw_data_row.id);
29850
- // } catch (e) {
29851
- // _ROWID = "newRecord";
29852
- // _ds.data_feed.rows.push({ _ROWID });
29853
- // idx = func.common.find_ROWID_idx(_ds, _ROWID);
29854
- // }
29855
-
29856
- // _ds.currentRecordId = _ROWID; // set temporary to allow expression decoder work
29857
-
29858
- // await func.datasource.render_fields_form(
29859
- // SESSION_ID,
29860
- // dataSourceSession,
29861
- // raw_data_row
29862
- // );
29863
- // const init_count = await func.datasource.get_field_init_count(
29864
- // SESSION_ID,
29865
- // dataSourceSession,
29866
- // _ROWID,
29867
- // false,
29868
- // _ds.oninit_triggers_to_run
29869
- // );
29870
- // if (init_count > 0) {
29871
- // await func.datasource.execute_field_init_events(
29872
- // SESSION_ID,
29873
- // dataSourceSession,
29874
- // "form",
29875
- // _ds.data_feed.rows[idx]._ROWID
29876
- // );
29877
- // }
29878
- // // await form_continue();
29879
- // };
29880
-
29881
29824
  func.datasource.execute_field_init_events = async function (SESSION_ID, dataSourceSession, sourceP, rowIdP) {
29882
29825
  var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
29883
29826
  var args = _ds.args;
@@ -30499,11 +30442,6 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
30499
30442
  _ds.currentRecordId = record_id;
30500
30443
  }
30501
30444
  }
30502
- // if (!_ds.data_feed.rows_changed) {
30503
- // _ds.data_feed.rows_changed = [];
30504
- // }
30505
- // if (!_ds.data_feed.rows_changed.includes(record_id))
30506
- // _ds.data_feed.rows_changed.push(record_id);
30507
30445
  }
30508
30446
  }
30509
30447
 
@@ -30537,234 +30475,6 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
30537
30475
  });
30538
30476
  };
30539
30477
 
30540
- // func.datasource.update = async function (
30541
- // SESSION_ID,
30542
- // datasource_changes,
30543
- // update_local_scope_only
30544
- // ) {
30545
- // return new Promise(async (resolve, reject) => {
30546
- // var _session = SESSION_OBJ[SESSION_ID];
30547
-
30548
- // if (typeof glb.GLOBAL_VARS === "undefined") {
30549
- // glb.GLOBAL_VARS = (
30550
- // await func.common.get_module(
30551
- // SESSION_ID,
30552
- // "xuda-system-globals-module.mjs"
30553
- // )
30554
- // ).system_globals;
30555
- // }
30556
-
30557
- // let fieldComputed_datasource_changes = {};
30558
-
30559
- // const set_fieldComputed_dependencies = async function (dsNo, field_id, parent_ds) {
30560
-
30561
- // // iterate child ds
30562
- // for (const [dsSession, _ds] of Object.entries(_session.DS_GLB)) {
30563
- // if (parent_ds !== null) {
30564
- // if (_ds.parentDataSourceNo != parent_ds) continue
30565
- // } else {
30566
- // if (dsSession != dsNo) continue
30567
- // }
30568
- // let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
30569
- // if (tree_ret.menuType === "component" || tree_ret.menuType === "globals") {
30570
- // // check if field has fieldComputed property
30571
- // const _progFields = await func.datasource.get_progFields(
30572
- // SESSION_ID,
30573
- // dsSession
30574
- // );
30575
- // // find if field is computed
30576
- // let propExpressions
30577
- // for await (const val of _progFields) {
30578
-
30579
- // const fieldId = val.data.field_id;
30580
-
30581
- // if (fieldId !== field_id) continue
30582
- // if (val.data.type !== "virtual" || !val.props.fieldComputed) break
30583
-
30584
- // const _propExpressions = val.props?.propExpressions?.fieldValue
30585
- // if (_propExpressions && JSON.stringify(_propExpressions).includes(field_id)) {
30586
- // propExpressions = _propExpressions
30587
- // }
30588
- // }
30589
-
30590
- // if (!propExpressions) return
30591
-
30592
- // if (!fieldComputed_datasource_changes[dsSession]) {
30593
- // fieldComputed_datasource_changes[dsSession] = {}
30594
- // }
30595
- // // iterate ds rows
30596
- // for (const row of _ds.data_feed?.rows || []) {
30597
- // // iterate row fields
30598
- // for (const [key, val] of Object.entries(row)) {
30599
- // if (key !== field_id) return
30600
- // try {
30601
- // if (!fieldComputed_datasource_changes[dsSession][row._ROWID]) {
30602
- // fieldComputed_datasource_changes[dsSession][row._ROWID] = {}
30603
- // }
30604
- // let ret = await func.expression.get(
30605
- // SESSION_ID,
30606
- // propExpressions,
30607
- // dsNo,
30608
- // "update",
30609
- // row._ROWID
30610
- // );
30611
- // fieldComputed_datasource_changes[dsSession][row._ROWID][field_id] = ret.result
30612
- // // const row_idx = func.common.find_ROWID_idx(_ds, record_id);
30613
-
30614
- // // _ds.data_feed.rows[row_idx][field_id] = ret.result;
30615
- // } catch (err) {
30616
- // console.error(err);
30617
- // }
30618
- // }
30619
- // }
30620
- // }
30621
- // await set_fieldComputed_dependencies(dsNo, field_id, dsSession)
30622
- // }
30623
- // debugger
30624
-
30625
- // }
30626
-
30627
- // var fields_changed = [];
30628
- // var datasource_changed = [];
30629
- // let client_datasource_changes={}
30630
- // // iterate changes datasource
30631
- // for await (const [dataSource, row_data] of Object.entries(
30632
- // datasource_changes
30633
- // )) {
30634
- // var _ds = _session.DS_GLB[dataSource];
30635
- // if (!_ds) {
30636
- // continue;
30637
- // }
30638
- // // iterate changes records
30639
- // for (const [record_id, fields_data] of Object.entries(row_data)) {
30640
- // // iterate changes fields
30641
- // for (const [field_id, value] of Object.entries(fields_data)) {
30642
- // // mechanism to make update directly on the datasource object
30643
- // if (record_id === "datasource_main") {
30644
- // _.set(_ds, field_id, value);
30645
- // continue;
30646
- // }
30647
-
30648
- // if (typeof fields_data === "object") {
30649
- // if (glb.GLOBAL_VARS[field_id]) {
30650
- // _ds.data_system[field_id] = value;
30651
-
30652
- // continue;
30653
- // }
30654
-
30655
- // try {
30656
- // const row_idx = func.common.find_ROWID_idx(_ds, record_id);
30657
- // _ds.data_feed.rows[row_idx][field_id] = value;
30658
- // await set_fieldComputed_dependencies(dataSource, field_id, null)
30659
- // } catch (err) {
30660
- // console.error(err);
30661
- // }
30662
-
30663
- // if (!fields_changed.includes(field_id)) {
30664
- // fields_changed.push(field_id);
30665
- // }
30666
- // if (!datasource_changed.includes(dataSource)) {
30667
- // datasource_changed.push(dataSource);
30668
- // }
30669
- // } else if (fields_data === "set") {
30670
- // _ds.currentRecordId = record_id;
30671
- // }
30672
-
30673
- // if (!update_local_scope_only) {
30674
- // if (glb.IS_WORKER) {
30675
- // let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
30676
-
30677
- // if (tree_ret.menuType === "globals") {
30678
-
30679
- // const _progFields = await func.datasource.get_progFields(
30680
- // SESSION_ID,
30681
- // dataSource
30682
- // );
30683
- // let view_field_obj = func.common.find_item_by_key(
30684
- // _progFields,
30685
- // "field_id",
30686
- // field_id
30687
- // );
30688
- // if (view_field_obj?.data?.serverField) {
30689
- // delete datasource_changes[dataSource][record_id][field_id]
30690
- // }
30691
-
30692
- // if (record_id === "data_system") {
30693
- // delete datasource_changes[dataSource][record_id]
30694
- // }
30695
- // }
30696
- // }
30697
- // }
30698
- // }
30699
- // if (!_ds.data_feed.rows_changed) {
30700
- // _ds.data_feed.rows_changed = [];
30701
- // }
30702
- // if (!_ds.data_feed.rows_changed.includes(record_id))
30703
- // _ds.data_feed.rows_changed.push(record_id);
30704
- // }
30705
-
30706
- // let new_datasource_changes = { ...datasource_changes, ...fieldComputed_datasource_changes }
30707
-
30708
- // if (!update_local_scope_only) {
30709
- // if (glb.IS_WORKER) {
30710
- // let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
30711
-
30712
- // if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== "undefined" || typeof IS_PROCESS_SERVER !== "undefined") {
30713
- // continue;
30714
- // }
30715
-
30716
- // if (tree_ret.menuType !== "component" && tree_ret.menuType !== "globals") {
30717
-
30718
- // continue;
30719
-
30720
- // }
30721
-
30722
- // // update client
30723
-
30724
- // func.utils.post_back_to_client(
30725
- // SESSION_ID,
30726
- // "update_client_eventChangesResults_from_worker",
30727
- // _session.worker_id,
30728
- // new_datasource_changes
30729
- // );
30730
- // return resolve();
30731
- // }
30732
-
30733
- // if (!glb.IS_WORKER) {
30734
- // if (_ds._run_at !== "client" || _ds.tree_obj.menuType === "globals") {
30735
- // // no need to update worker
30736
- // // return resolve();
30737
- // // continue;
30738
- // // }
30739
-
30740
- // const ret = await func.index.call_worker(SESSION_ID, {
30741
- // service: "update_datasource_changes_from_client",
30742
- // data: {
30743
- // session_id: SESSION_ID,
30744
- // new_datasource_changes,
30745
- // },
30746
- // id: _ds.worker_id,
30747
- // });
30748
- // }
30749
- // }
30750
- // }
30751
- // }
30752
- // if (!glb.IS_WORKER) {
30753
- // ///// REFRESH SCREEN
30754
- // if (fields_changed.length) {
30755
- // await func.UI.screen.refresh_xu_attributes(SESSION_ID, fields_changed);
30756
- // await func.UI.screen.refresh_screen(
30757
- // SESSION_ID,
30758
- // fields_changed,
30759
- // null,
30760
- // datasource_changed[0] // refresh the current datasource only
30761
- // );
30762
- // }
30763
- // }
30764
- // return resolve();
30765
- // });
30766
- // };
30767
-
30768
30478
  func.datasource.callback = async function (SESSION_ID, dsSessionP, na, rowIdP, jobNoP, NA_callingDataSourceP, NA_isInitP, nodeIdP) {
30769
30479
  var _session = SESSION_OBJ[SESSION_ID];
30770
30480
  var _ds = _session.DS_GLB[dsSessionP];