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