@xuda.io/xuda-worker-bundle-min 1.3.844 → 1.3.845

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.
Files changed (2) hide show
  1. package/index.js +70 -63
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -49,20 +49,9 @@ func.common.find_ROWID_idx = function (_ds, rowId) {
49
49
  if (!_ds?.data_feed?.rows) {
50
50
  throw new Error("data_feed not found");
51
51
  }
52
- // let index;
53
- // if (rowId === "newRecord") {
54
- // index = glb.newRecord;
55
- // if (!_ds.data_feed.rows[index]) {
56
- // index = -1;
57
- // }
58
- // } else {
52
+
59
53
  // Find the index of the object with the given _ROWID
60
54
  const index = _ds.data_feed.rows.findIndex((item) => item._ROWID === rowId);
61
- // }
62
- // If the index is -1, the ROWID was not found, so throw an error
63
- // if (index === -1) {
64
- // throw new Error(`ROWID "${rowId}" not found`);
65
- // }
66
55
 
67
56
  // Return the found index
68
57
  return index;
@@ -2493,24 +2482,24 @@ func.datasource.execute = async function (
2493
2482
  "after_record"
2494
2483
  );
2495
2484
  };
2496
- let data_arr = [];
2485
+ let _raw_data_rows = [];
2497
2486
  switch (tree_obj.menuType) {
2498
2487
  case "api": {
2499
2488
  _ds.api_rendered_output = "";
2500
2489
  let has_datasource = await calc_batch_loops();
2501
2490
 
2502
- data_arr = _ds.data_feed.rows || [];
2491
+ _raw_data_rows = _ds.raw_data.rows || [];
2503
2492
  if (!has_datasource) {
2504
2493
  for (n = 0; n < _ds.v.batch_loops; n++) {
2505
- data_arr.push({ _ROWID: n });
2494
+ _raw_data_rows.push({ id: n, value: {} });
2506
2495
  }
2507
2496
  }
2508
2497
  _ds.currentRecordId = "dataset";
2509
- for await (let [key, val] of Object.entries(data_arr)) {
2498
+ for await (let [key, raw_data_row] of Object.entries(_raw_data_rows)) {
2510
2499
  if (has_datasource && Number(key) >= _ds.v.batch_loops) break;
2511
2500
 
2512
2501
  if (!has_datasource) {
2513
- val = _ds?.data_feed?.rows?.[key] || { _ROWID: key };
2502
+ raw_data_row = _ds?.raw_data?.rows?.[key] || { id: key, value: {} };
2514
2503
  }
2515
2504
 
2516
2505
  if (await get_before_record_count()) {
@@ -2524,7 +2513,7 @@ func.datasource.execute = async function (
2524
2513
  await func.datasource.render_fields_dataset(
2525
2514
  SESSION_ID,
2526
2515
  dataSourceSession,
2527
- val
2516
+ raw_data_row
2528
2517
  );
2529
2518
 
2530
2519
  if (await get_after_record_count()) {
@@ -2556,18 +2545,18 @@ func.datasource.execute = async function (
2556
2545
  case "batch": {
2557
2546
  let has_datasource = await calc_batch_loops();
2558
2547
 
2559
- data_arr = _ds?.data_feed?.rows || [];
2548
+ _raw_data_rows = _ds?.raw_data?.rows || [];
2560
2549
  if (!has_datasource) {
2561
2550
  for (n = 0; n < _ds.v.batch_loops; n++) {
2562
- data_arr.push({ _ROWID: n });
2551
+ _raw_data_rows.push({ id: n, value: {} });
2563
2552
  }
2564
2553
  }
2565
2554
  _ds.currentRecordId = "dataset";
2566
- for await (let [key, val] of Object.entries(data_arr)) {
2555
+ for await (let [key, raw_data_row] of Object.entries(_raw_data_rows)) {
2567
2556
  if (has_datasource && Number(key) >= _ds.v.batch_loops) break;
2568
2557
 
2569
2558
  if (!has_datasource) {
2570
- val = _ds?.data_feed?.rows?.[key] || { _ROWID: key };
2559
+ raw_data_row = _ds?.raw_data?.rows?.[key] || { id: key, value: {} };
2571
2560
  }
2572
2561
 
2573
2562
  if (await get_before_record_count()) {
@@ -2581,7 +2570,7 @@ func.datasource.execute = async function (
2581
2570
  await func.datasource.render_fields_dataset(
2582
2571
  SESSION_ID,
2583
2572
  dataSourceSession,
2584
- val
2573
+ raw_data_row
2585
2574
  );
2586
2575
 
2587
2576
  if (await get_after_record_count()) {
@@ -2635,14 +2624,34 @@ func.datasource.execute = async function (
2635
2624
  );
2636
2625
  }
2637
2626
 
2627
+ const get_data_from_data_feed = function () {
2628
+ const rows = _ds?.data_feed?.rows || [];
2629
+ return rows.map((item) => ({
2630
+ id: item._ROWID,
2631
+ value: {
2632
+ ...item.value,
2633
+ },
2634
+ }));
2635
+ };
2636
+
2637
+ const find_ROWID_idx_from_raw_data_arr = function (rowId) {
2638
+ if (!_raw_data_rows) {
2639
+ throw new Error("_raw_data_rows not found");
2640
+ }
2641
+
2642
+ const index = _raw_data_rows.findIndex((item) => item.id === rowId);
2643
+
2644
+ return index;
2645
+ };
2646
+
2638
2647
  if (tree_obj.crudMode === "U") {
2639
2648
  _ds.set_mode = "U";
2640
- data_arr = _ds?.data_feed?.rows || [];
2649
+ _raw_data_rows = get_data_from_data_feed(); // _ds?.raw_data?.rows || [];
2641
2650
  }
2642
2651
 
2643
2652
  if (tree_obj.crudMode === "D") {
2644
2653
  _ds.set_mode = "D";
2645
- data_arr = _ds.data_feed?.rows || [];
2654
+ _raw_data_rows = get_data_from_data_feed(); // _ds.raw_data?.rows || [];
2646
2655
  }
2647
2656
 
2648
2657
  // initiated with Update but no rows found
@@ -2652,28 +2661,28 @@ func.datasource.execute = async function (
2652
2661
  !_ds?.data_feed?.rows?.length
2653
2662
  ) {
2654
2663
  _ds.set_mode = "C";
2655
- // data_arr[glb.newRecord] = [{ _ROWID: "newRecord" }];
2664
+ // _raw_data_rows[glb.newRecord] = [{ _ROWID: "newRecord" }];
2656
2665
 
2657
2666
  try {
2658
- const row_idx = func.common.find_ROWID_idx(_ds, "newRecord");
2659
- data_arr[row_idx] = [{ _ROWID: "newRecord" }];
2667
+ const row_idx = find_ROWID_idx_from_raw_data_arr("newRecord");
2668
+ _raw_data_rows[row_idx] = [{ id: "newRecord", value: {} }];
2660
2669
  } catch (error) {
2661
- data_arr.push({ _ROWID: "newRecord" });
2670
+ _raw_data_rows.push({ _ROWID: "newRecord" });
2662
2671
  }
2663
2672
  }
2664
2673
 
2665
2674
  if (tree_obj.crudMode === "C") {
2666
2675
  _ds.set_mode = "C";
2667
- // data_arr[glb.newRecord] = [{ _ROWID: "newRecord" }];
2676
+ // _raw_data_rows[glb.newRecord] = [{ _ROWID: "newRecord" }];
2668
2677
  try {
2669
- const row_idx = func.common.find_ROWID_idx(_ds, "newRecord");
2670
- data_arr[row_idx] = [{ _ROWID: "newRecord" }];
2678
+ const row_idx = find_ROWID_idx_from_raw_data_arr("newRecord");
2679
+ _raw_data_rows[row_idx] = [{ id: "newRecord", value: {} }];
2671
2680
  } catch (error) {
2672
- data_arr.push({ _ROWID: "newRecord" });
2681
+ _raw_data_rows.push({ id: "newRecord", value: {} });
2673
2682
  }
2674
2683
  }
2675
2684
 
2676
- for await (let val of data_arr) {
2685
+ for await (let raw_data_row of _raw_data_rows) {
2677
2686
  _ds.currentRecordId = val.id;
2678
2687
  if (await get_before_record_count()) {
2679
2688
  await func.datasource.execute_view_events(
@@ -2686,7 +2695,7 @@ func.datasource.execute = async function (
2686
2695
  await func.datasource.render_fields_dataset(
2687
2696
  SESSION_ID,
2688
2697
  dataSourceSession,
2689
- val
2698
+ raw_data_row
2690
2699
  );
2691
2700
  let data_feed_str = JSON.stringify(_ds.data_feed);
2692
2701
 
@@ -2737,7 +2746,7 @@ func.datasource.execute = async function (
2737
2746
  await func.datasource.render_fields_form(
2738
2747
  SESSION_ID,
2739
2748
  dataSourceSession,
2740
- { id: "newRecord" }
2749
+ { id: "newRecord", value: {} }
2741
2750
  );
2742
2751
  }
2743
2752
 
@@ -2798,6 +2807,7 @@ func.datasource.execute = async function (
2798
2807
  };
2799
2808
 
2800
2809
  for await (const [key, val] of Object.entries(_ds.raw_data.rows)) {
2810
+ const raw_data_row = val.value;
2801
2811
  if (await get_before_record_count()) {
2802
2812
  await func.datasource.execute_view_events(
2803
2813
  SESSION_ID,
@@ -2810,7 +2820,7 @@ func.datasource.execute = async function (
2810
2820
  SESSION_ID,
2811
2821
  dataSourceSession,
2812
2822
  key,
2813
- val.value
2823
+ raw_data_row
2814
2824
  );
2815
2825
 
2816
2826
  if (await get_after_record_count()) {
@@ -2841,7 +2851,7 @@ func.datasource.execute = async function (
2841
2851
  func.datasource.render_fields_dataset = async function (
2842
2852
  SESSION_ID,
2843
2853
  dataSourceSession,
2844
- data
2854
+ raw_data_row
2845
2855
  ) {
2846
2856
  var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
2847
2857
  var args = _ds.args;
@@ -2923,11 +2933,11 @@ func.datasource.render_fields_dataset = async function (
2923
2933
  var fieldId = val.data.field_id;
2924
2934
 
2925
2935
  if (val.data.type === "virtual" || _ds.set_mode === "C") {
2926
- if (typeof data?.[fieldId] !== "undefined") {
2936
+ if (typeof raw_data_row?.value?.[fieldId] !== "undefined") {
2927
2937
  // supports x=x+1
2928
2938
  _ds.data_feed.rows[row_idx][fieldId] = await get_value(
2929
2939
  fieldId,
2930
- data[fieldId]
2940
+ raw_data_row.value[fieldId]
2931
2941
  );
2932
2942
  continue;
2933
2943
  }
@@ -2954,12 +2964,12 @@ func.datasource.render_fields_dataset = async function (
2954
2964
  continue;
2955
2965
  }
2956
2966
  if (val.data.type === "table" || val.data.type === "datasource") {
2957
- if (typeof data[fieldId] === "undefined") {
2967
+ if (typeof raw_data_row.value[fieldId] === "undefined") {
2958
2968
  throw "field do not exist in data: " + fieldId;
2959
2969
  }
2960
2970
  _ds.data_feed.rows[row_idx][fieldId] = await get_value(
2961
2971
  fieldId,
2962
- data[fieldId]
2972
+ raw_data_row.value[fieldId]
2963
2973
  );
2964
2974
  }
2965
2975
  } catch (err) {
@@ -2967,13 +2977,6 @@ func.datasource.render_fields_dataset = async function (
2967
2977
  }
2968
2978
  }
2969
2979
  }
2970
-
2971
- // let data_feed = { _ROWID: _ds.currentRecordId };
2972
-
2973
- // _ds.data_feed._ROWID = _ds.currentRecordId;
2974
-
2975
- // _ds.data_feed.rows.push(data_feed);
2976
- // _ds.data_feed.rows[0] = data_feed;
2977
2980
  };
2978
2981
 
2979
2982
  func.datasource.run_events_functions = async function (
@@ -3010,7 +3013,7 @@ func.datasource.run_events_functions = async function (
3010
3013
  func.datasource.render_fields_form = async function (
3011
3014
  SESSION_ID,
3012
3015
  dataSourceSession,
3013
- data
3016
+ raw_data_row
3014
3017
  ) {
3015
3018
  var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
3016
3019
  // var v = _ds.v;
@@ -3085,15 +3088,15 @@ func.datasource.render_fields_form = async function (
3085
3088
 
3086
3089
  let row_idx;
3087
3090
  try {
3088
- row_idx = func.common.find_ROWID_idx(_ds, data.id);
3091
+ row_idx = func.common.find_ROWID_idx(_ds, raw_data_row.id);
3089
3092
  // data_arr[row_idx] = [{ _ROWID: "newRecord" }];
3090
3093
  } catch (error) {
3091
- // if (data._ROWID === "newRecord") {
3092
- // _ds.data_feed.rows[glb.newRecord] = { _ROWID: data._ROWID };
3094
+ // if (raw_data_row._ROWID === "newRecord") {
3095
+ // _ds.data_feed.rows[glb.newRecord] = { _ROWID: raw_data_row._ROWID };
3093
3096
  // } else {
3094
- _ds.data_feed.rows.push({ _ROWID: data.id });
3097
+ _ds.data_feed.rows.push({ _ROWID: raw_data_row.id });
3095
3098
  // }
3096
- row_idx = func.common.find_ROWID_idx(_ds, data.id);
3099
+ row_idx = func.common.find_ROWID_idx(_ds, raw_data_row.id);
3097
3100
  }
3098
3101
 
3099
3102
  _ds.dataset_alias = {};
@@ -3102,7 +3105,7 @@ func.datasource.render_fields_form = async function (
3102
3105
  try {
3103
3106
  var fieldId = val.data.field_id;
3104
3107
 
3105
- if (val.data.type === "virtual" || data.id === "newRecord") {
3108
+ if (val.data.type === "virtual" || raw_data_row.id === "newRecord") {
3106
3109
  if (glb.PROTECTED_VARS.includes(fieldId)) {
3107
3110
  switch (fieldId) {
3108
3111
  case "_ROWNO": {
@@ -3115,7 +3118,7 @@ func.datasource.render_fields_form = async function (
3115
3118
  case "_ROWID": {
3116
3119
  _ds.data_feed.rows[row_idx][fieldId] = await get_value(
3117
3120
  fieldId,
3118
- data.id
3121
+ raw_data_row.id
3119
3122
  );
3120
3123
 
3121
3124
  continue;
@@ -3123,7 +3126,7 @@ func.datasource.render_fields_form = async function (
3123
3126
  case "_ROWDOC": {
3124
3127
  _ds.data_feed.rows[row_idx][fieldId] = await get_value(
3125
3128
  fieldId,
3126
- data.value
3129
+ raw_data_row.value
3127
3130
  );
3128
3131
 
3129
3132
  continue;
@@ -3138,7 +3141,7 @@ func.datasource.render_fields_form = async function (
3138
3141
  val.props?.propExpressions?.fieldValue,
3139
3142
  dataSourceSession,
3140
3143
  "update",
3141
- data.id
3144
+ raw_data_row.id
3142
3145
  );
3143
3146
  _ds.data_feed.rows[row_idx][fieldId] = await get_value(
3144
3147
  fieldId,
@@ -3156,12 +3159,12 @@ func.datasource.render_fields_form = async function (
3156
3159
  continue;
3157
3160
  }
3158
3161
  if (val.data.type === "table" || val.data.type === "datasource") {
3159
- if (typeof data[fieldId] === "undefined") {
3162
+ if (typeof raw_data_row[fieldId] === "undefined") {
3160
3163
  throw "field do not exist in data: " + fieldId;
3161
3164
  }
3162
3165
  _ds.data_feed.rows[row_idx][fieldId] = await get_value(
3163
3166
  fieldId,
3164
- data.value[fieldId]
3167
+ raw_data_row.value[fieldId]
3165
3168
  );
3166
3169
  }
3167
3170
  } catch (err) {
@@ -3174,7 +3177,7 @@ func.datasource.run_rows_form = async function (
3174
3177
  SESSION_ID,
3175
3178
  dataSourceSession,
3176
3179
  rowIdxP,
3177
- data
3180
+ raw_data_row
3178
3181
  ) {
3179
3182
  var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
3180
3183
  if (!_ds) return;
@@ -3198,7 +3201,11 @@ func.datasource.run_rows_form = async function (
3198
3201
 
3199
3202
  _ds.currentRecordId = _ROWID; // set temporary to allow expression decoder work
3200
3203
 
3201
- await func.datasource.render_fields_form(SESSION_ID, dataSourceSession, data);
3204
+ await func.datasource.render_fields_form(
3205
+ SESSION_ID,
3206
+ dataSourceSession,
3207
+ raw_data_row
3208
+ );
3202
3209
  const init_count = await func.datasource.get_field_init_count(
3203
3210
  SESSION_ID,
3204
3211
  dataSourceSession,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-worker-bundle-min",
3
- "version": "1.3.844",
3
+ "version": "1.3.845",
4
4
  "description": "xuda framework min",
5
5
  "main": "index.js",
6
6
  "scripts": {