flexbiz-server 12.5.28 → 12.5.31
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/package.json +1 -1
- package/server/controllers/findHandler.js +2 -2
- package/server/controllers/viewHandler.js +252 -13
- package/server/libs/joinData.js +2 -2
- package/server/libs/post-sokho.js +23 -351
- package/server/models/csphucap.js +2 -0
- package/server/models/dmbp.js +2 -2
- package/server/models/pcl.js +1 -1
- package/server/models/ptl.js +1 -2
- package/server/modules/lists/ls-checkin.js +24 -336
- package/server/modules/lists/ls-csphucap.js +1 -0
- package/server/modules/reports/calc-tinhluong.js +25 -22
- package/server/modules/reports/rp-sctluong.js +5 -3
- package/server/modules/vouchers/vo-hd2.js +82 -81
- package/server/modules/vouchers/vo-pcl.js +3 -3
- package/server/modules/vouchers/vo-ptl.js +4 -4
- package/server/templates/product-verify-result.ejs +205 -11
package/package.json
CHANGED
|
@@ -21,8 +21,8 @@ $condition$$.$where?(console.log("phai loai bo $where trong condition"),$model$$
|
|
|
21
21
|
$req$$.result={rows_number:$data$$,groups_number:$groups_number$$};$callback$$("0")})}else{let $field_not_right$$;try{$field_not_right$$=await permission.getFieldNotRight($req$$.user.current_id_app,$req$$.user.email,$ctrl$$.name)}catch($e$$){$field_not_right$$=[]}$data_log_fields_fields$$=$req$$.query.fields;let $gfields$$={};$data_log_fields_fields$$&&(_.isArray($data_log_fields_fields$$)?$data_log_fields_fields$$.forEach($f$$=>{$f$$!=="_id"&&($gfields$$[$f$$]=1)}):_.isObject($data_log_fields_fields$$)?
|
|
22
22
|
$gfields$$={...$gfields$$,...$data_log_fields_fields$$}:$data_log_fields_fields$$.split(",").filter($f$$=>$f$$&&$field_not_right$$.indexOf($f$$)<0).forEach($f$$=>{$f$$!=="_id"&&($gfields$$[$f$$]=1)}));$field_not_right$$.forEach($f$$=>{Object.keys($gfields$$).find($k$$=>$gfields$$[$k$$]==1)?delete $gfields$$[$f$$]:$gfields$$[$f$$]=0});!$data_log_fields_fields$$&&(($data_log_fields_fields$$=$req$$.query.notfields)&&(_.isArray($data_log_fields_fields$$)?$data_log_fields_fields$$.forEach($f$$=>{$f$$&&
|
|
23
23
|
$f$$!=="_id"&&(Object.keys($gfields$$).find($k$$=>$gfields$$[$k$$]==1)?delete $gfields$$[$f$$]:$gfields$$[$f$$]=0)}):_.isObject($data_log_fields_fields$$)?$gfields$$={...$gfields$$,...$data_log_fields_fields$$}:$data_log_fields_fields$$.split(",").forEach($f$$=>{$f$$&&$f$$!=="_id"&&(Object.keys($gfields$$).find($k$$=>$gfields$$[$k$$]==1)?delete $gfields$$[$f$$]:$gfields$$[$f$$]=0)})),$shareRoute$$||$req$$.user.email==="public")&&(Object.keys($gfields$$).find($k$$=>$gfields$$[$k$$]==1)?(delete $gfields$$.dataview_to,
|
|
24
|
-
delete $gfields$$.dataview_to_users):($gfields$$.dataview_to=0,$gfields$$.dataview_to_users=0));$condition$$.$text&&($gfields$$||={},$gfields$$.textScore={$meta:"textScore"});delete $req$$.query_cache;$ctrl$$.cache&&($req$$.query_cache={..._.cloneDeep($req$$.query),..._.cloneDeep($condition$$)},delete $req$$.query_cache.q,delete $req$$.query_cache.refresh_required,$req$$.query_cache.gfields=_.cloneDeep($gfields$$));const $fetchData$$=($condition$$,$limit$$,$page$$,$callback$$)=>{
|
|
25
|
-
|
|
24
|
+
delete $gfields$$.dataview_to_users):($gfields$$.dataview_to=0,$gfields$$.dataview_to_users=0));$condition$$.$text&&($gfields$$||={},$gfields$$.textScore={$meta:"textScore"});delete $req$$.query_cache;$ctrl$$.cache&&($req$$.query_cache={..._.cloneDeep($req$$.query),..._.cloneDeep($condition$$)},delete $req$$.query_cache.q,delete $req$$.query_cache.refresh_required,$req$$.query_cache.gfields=_.cloneDeep($gfields$$));const $fetchData$$=($condition$$,$limit$$,$page$$,$callback$$)=>{setImmediate(async()=>
|
|
25
|
+
{let $query$$;if($req$$.query.group||$req$$.query.project||$req$$.query.match||$req$$.query.aggregate||$req$$.query.$aggregate)try{if($req$$.query.aggregate){var $aggregate_piples_sort$$=JSONParser($req$$.query.$aggregate||$req$$.query.aggregate);if(!Array.isArray($aggregate_piples_sort$$))return $callback$$({error:"Aggregate ph\u1ea3i l\u00e0 m\u1ed9t m\u1ea3ng"});if($aggregate_piples_sort$$.find($f$$=>$f$$.$lookup))return $callback$$({error:"Kh\u00f4ng \u0111\u01b0\u1ee3c ph\u00e9p s\u1eed d\u1ee5ng $lookup trong aggregate"});
|
|
26
26
|
$aggregate_piples_sort$$=[{$match:$condition$$},...$aggregate_piples_sort$$];$query$$=$model$$.aggregate($aggregate_piples_sort$$)}else{$query$$=$model$$.aggregate([{$match:$condition$$}]);let $group$$;$req$$.query.group&&($group$$=JSONParser($req$$.query.group),$query$$.group($group$$));if($req$$.query.match){let $match$$=JSONParser($req$$.query.match);$query$$.match($match$$)}let $project$$;if($req$$.query.project)$project$$=JSONParser($req$$.query.project),$query$$.project($project$$);else if($gfields$$&&
|
|
27
27
|
Object.keys($gfields$$).length>0)$project$$=$gfields$$;else if($project$$={_id:1},$group$$)for(let $key$$ in $group$$)$project$$[$key$$]=1;$query$$.project($project$$)}}catch($e$$){return console.error("[findHanlder]",$e$$,$req$$.query),$callback$$({error:$e$$.message||$e$$.error||$e$$})}else _.has($model$$.schema.paths,"id_app")&&Object.keys($gfields$$).length>0&&Object.keys($gfields$$).find($k$$=>$gfields$$[$k$$]==1)&&($gfields$$.id_app=1),$query$$=$model$$.find($condition$$,$gfields$$);$aggregate_piples_sort$$=
|
|
28
28
|
$req$$.sort;if(!$aggregate_piples_sort$$)$gfields$$.textScore&&($aggregate_piples_sort$$={textScore:{$meta:"textScore"}});else for(var $key$$ in $aggregate_piples_sort$$)if($key$$!=="textScore"&&$aggregate_piples_sort$$[$key$$]!=1&&$aggregate_piples_sort$$[$key$$]!=-1)return console.error("sort is valid",$aggregate_piples_sort$$,$key$$,$aggregate_piples_sort$$[$key$$]),$callback$$({error:`Sort ${JSON.stringify($aggregate_piples_sort$$)} is not valid`});$aggregate_piples_sort$$&&Object.keys($aggregate_piples_sort$$).length>
|
|
@@ -1,13 +1,252 @@
|
|
|
1
|
-
const async=require("async")
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
const async = require("async");
|
|
2
|
+
const _ = require("lodash");
|
|
3
|
+
const redisCache = require("../libs/redis-cache");
|
|
4
|
+
const view = async (user,self,rows,next,options)=> {
|
|
5
|
+
const model = self.model;
|
|
6
|
+
const name = self.name;
|
|
7
|
+
const listinfo_code = options?.req?.query?.["listinfo-code"] || options?.req?.query?.["listinfo_code"] || options?.req?.headers?.["listinfo-code"] || options?.req?.headers?.["Listinfo-Code"];
|
|
8
|
+
let fields_load="";
|
|
9
|
+
if(options && options.req && options.req.query && options.req.query.fields){
|
|
10
|
+
fields_load = options.req.query.fields;
|
|
11
|
+
}
|
|
12
|
+
//
|
|
13
|
+
let schema_paths = model.schema.paths;
|
|
14
|
+
for(let index=0;index<rows.length;index++){
|
|
15
|
+
const item = rows[index];
|
|
16
|
+
if(item._id && typeof(item._id)!=="string"){
|
|
17
|
+
item._id = item._id.toString();
|
|
18
|
+
}
|
|
19
|
+
delete item.__v;
|
|
20
|
+
item.stt_sorted = index;
|
|
21
|
+
delete item.from_cached;
|
|
22
|
+
if (_.has(schema_paths, 'exfields')) {
|
|
23
|
+
if(!item.exfields){
|
|
24
|
+
item.exfields = {};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//xoá refs cache
|
|
28
|
+
//delete item.__refs;
|
|
29
|
+
}
|
|
30
|
+
let items =[];
|
|
31
|
+
//get view of item from cache
|
|
32
|
+
if(options && options.req && options.req.query_cache && !options.req.query.refresh_required){
|
|
33
|
+
await new Promise(resolve=>{
|
|
34
|
+
setImmediate(async()=>{
|
|
35
|
+
let cacheData = await redisCache.getCacheReport(options.req.user.email,(options.req.user.current_id_app||"system").toString(),self.name,options.req.query_cache,0,options.req.query.page);
|
|
36
|
+
if(cacheData){
|
|
37
|
+
for(let index=0;index<rows.length;index++){
|
|
38
|
+
const item = rows[index];
|
|
39
|
+
let cacheds = cacheData.filter(r=>r._id===item._id.toString());
|
|
40
|
+
if(cacheds.length>0){
|
|
41
|
+
for(let cached of cacheds){
|
|
42
|
+
cached.from_cached = true;
|
|
43
|
+
items.push(cached);
|
|
44
|
+
}
|
|
45
|
+
}else{
|
|
46
|
+
items.push(item);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}else{
|
|
50
|
+
items = rows;
|
|
51
|
+
}
|
|
52
|
+
resolve();
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
}else{
|
|
56
|
+
items = rows;
|
|
57
|
+
}
|
|
58
|
+
//
|
|
59
|
+
async.parallel({
|
|
60
|
+
_Participant_created:(callback)=>{
|
|
61
|
+
setImmediate(async ()=>{
|
|
62
|
+
if (_.has(schema_paths, 'id_app')) {
|
|
63
|
+
await items.filter(item=>item.user_created && !item.from_cached).asyncJoinModel2(user.current_id_app,"participant",{where:{user_created:"email"},fields:{name_user_created:"name"}});
|
|
64
|
+
}
|
|
65
|
+
await items.filter(item=>item.user_created && !item.name_user_created && !item.from_cached).asyncJoinModel2(null,"user",{where:{user_created:"email"},fields:{name_user_created:"name"}});
|
|
66
|
+
callback(null);
|
|
67
|
+
})
|
|
68
|
+
},
|
|
69
|
+
_Participant_updated:(callback)=>{
|
|
70
|
+
setImmediate(async ()=>{
|
|
71
|
+
if (_.has(schema_paths, 'id_app')) {
|
|
72
|
+
await items.filter(item=>item.user_updated && !item.from_cached).asyncJoinModel2(user.current_id_app,global.getModel('participant'),{where:{user_updated:"email"},fields:{name_user_updated:"name"}});
|
|
73
|
+
}
|
|
74
|
+
await items.filter(item=>item.user_updated && !item.name_user_updated && !item.from_cached).asyncJoinModel2(null,global.getModel('user'),{where:{user_updated:"email"},fields:{name_user_updated:"name"}});
|
|
75
|
+
callback(null);
|
|
76
|
+
})
|
|
77
|
+
},
|
|
78
|
+
_approve:(callback)=>{
|
|
79
|
+
if(!fields_load || fields_load.indexOf("approve_data")>=0){
|
|
80
|
+
async.map(items,(item,next)=>{
|
|
81
|
+
setImmediate(()=>{
|
|
82
|
+
|
|
83
|
+
global.getModel('approve').find({id_ct:item._id.toString()},{
|
|
84
|
+
data:0,request_content:0,
|
|
85
|
+
}).sort({data_created:-1}).lean().then(async (rs)=>{
|
|
86
|
+
//console.log("🔥[viewHandler] lấy dữ liệu duyệt:",{ma_ct:item.ma_ct,id_ct:item._id.toString()},rs.length);
|
|
87
|
+
setImmediate(async ()=>{
|
|
88
|
+
item.approve_data = rs||[];
|
|
89
|
+
item.approved_latest = item.approve_data.filter(a=>a.user_approved || a.user_denied)[0];
|
|
90
|
+
item.approve_next = item.approve_data.filter(a=>!a.user_approved && !a.user_denied)[0];
|
|
91
|
+
|
|
92
|
+
await item.approve_data.filter(r=>r.user_approved).asyncJoinModel2(item.id_app,global.getModel('participant'),{where:{user_approved:"email"},fields:{user_approved_name:"name",signature_image:"signature_image"}})
|
|
93
|
+
await item.approve_data.filter(r=>r.user_denied).asyncJoinModel2(item.id_app,global.getModel('participant'),{where:{user_denied:"email"},fields:{user_denied_name:"name",signature_image:"signature_image"}})
|
|
94
|
+
|
|
95
|
+
next(null);
|
|
96
|
+
})
|
|
97
|
+
}).catch(e=>{
|
|
98
|
+
console.error(e);
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
},()=>{
|
|
102
|
+
callback(null);
|
|
103
|
+
})
|
|
104
|
+
}else{
|
|
105
|
+
callback(null);
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
transfer_ct:(callback)=>{
|
|
109
|
+
if(_.has(schema_paths, 'id_ct_chuyen') && user.current_app_info && user.current_app_info.options && user.current_app_info.options.id_app_thue){
|
|
110
|
+
async.map(items,(item,next)=>{
|
|
111
|
+
setImmediate(()=>{
|
|
112
|
+
model.findOne({id_app:user.current_app_info.options.id_app_thue,id_ct_chuyen:item._id.toString()},{_id:1}).lean().then(async (rs)=>{
|
|
113
|
+
if(rs){
|
|
114
|
+
item.id_ct_nhan = rs._id;
|
|
115
|
+
}
|
|
116
|
+
next(null);
|
|
117
|
+
}).catch(e=>{
|
|
118
|
+
console.error(e)
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
},()=>{
|
|
122
|
+
callback(null);
|
|
123
|
+
})
|
|
124
|
+
}else{
|
|
125
|
+
return callback()
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
posted:(callback)=>{
|
|
129
|
+
if(options && options.req && (options.req.query.show_posted_book || options.req.query.show_not_post_book) ){
|
|
130
|
+
async.mapLimit(items,10,(item,next)=>{
|
|
131
|
+
setImmediate(async ()=>{
|
|
132
|
+
let book = options.req.query.show_posted_book || options.req.query.show_not_post_book;
|
|
133
|
+
let fields ={_id:1};
|
|
134
|
+
//cần kiểm tra từng vật tư xem có vật tư nào không được post sổ không
|
|
135
|
+
if(book=="sokho" && item.details?.length>0){
|
|
136
|
+
await item.details.asyncJoinModel2(item.id_app,"dmvt",{where:"ma_vt",fields:"tg_tk"});
|
|
137
|
+
fields.ma_vt =1;
|
|
138
|
+
let exists = await global.getModel(book).findOne({id_ct:item._id.toString()},fields).lean();
|
|
139
|
+
if(exists){
|
|
140
|
+
let ds_vt_voucher = item.details.filter(d=>d.tg_tk).map(d=>d.ma_vt).sort((a,b)=>a-b);
|
|
141
|
+
let ds_vt_book = exists.map(d=>d.ma_vt).sort((a,b)=>a-b);
|
|
142
|
+
|
|
143
|
+
if(JSON.stringify(ds_vt_voucher) === JSON.stringify(ds_vt_book)){
|
|
144
|
+
item[`${book}_posted`] = true;//Tất cả các vật tư đã post
|
|
145
|
+
}else{
|
|
146
|
+
item[`${book}_posted`] = false;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
}else{
|
|
150
|
+
item[`${book}_posted`] = false;
|
|
151
|
+
}
|
|
152
|
+
}else{
|
|
153
|
+
let exists = await global.getModel(book).findOne({id_ct:item._id.toString()},fields).lean();
|
|
154
|
+
item[`${book}_posted`] = (!!exists);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
next();
|
|
158
|
+
})
|
|
159
|
+
},()=>{
|
|
160
|
+
callback(null);
|
|
161
|
+
})
|
|
162
|
+
}else{
|
|
163
|
+
callback()
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}, (e)=>{
|
|
167
|
+
if(e) return next(e);
|
|
168
|
+
//only show posted book or not post book
|
|
169
|
+
if(options && options.req && (options.req.query.show_posted_book || options.req.query.show_not_post_book) ){
|
|
170
|
+
let book = options.req.query.show_posted_book || options.req.query.show_not_post_book;
|
|
171
|
+
items = items.filter(r=>{
|
|
172
|
+
if(options.req.query.show_posted_book) return r[`${book}_posted`]
|
|
173
|
+
return !r[`${book}_posted`]
|
|
174
|
+
})
|
|
175
|
+
}
|
|
176
|
+
//handle view
|
|
177
|
+
let items_need_view = items.filter(i=>!i.from_cached);
|
|
178
|
+
|
|
179
|
+
//lưu các ref đã join để tránh join lại trên dynamicView
|
|
180
|
+
/*if(self.dynamicView){
|
|
181
|
+
items_need_view.forEach(r=>{
|
|
182
|
+
r.__refs={}
|
|
183
|
+
})
|
|
184
|
+
}*/
|
|
185
|
+
//
|
|
186
|
+
let items_cached = items.filter(i=>i.from_cached);
|
|
187
|
+
async.series({
|
|
188
|
+
view:(callback)=>{
|
|
189
|
+
if(self.view){
|
|
190
|
+
try{
|
|
191
|
+
self.view(user, items_need_view, function(error,rs) {
|
|
192
|
+
setImmediate(()=>{
|
|
193
|
+
if (error) {
|
|
194
|
+
return callback(error);
|
|
195
|
+
}
|
|
196
|
+
items_need_view = rs||items_need_view;
|
|
197
|
+
callback(null,items_need_view);
|
|
198
|
+
})
|
|
199
|
+
},options);
|
|
200
|
+
}catch(e){
|
|
201
|
+
console.error("Error on view of",name,e);
|
|
202
|
+
callback(null,items_need_view);
|
|
203
|
+
}
|
|
204
|
+
}else{
|
|
205
|
+
callback(null,items_need_view);
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
dynamicView:(callback)=>{
|
|
209
|
+
if(self.dynamicView){
|
|
210
|
+
self.dynamicView(user, items_need_view, function(error,rs) {
|
|
211
|
+
if (error) {
|
|
212
|
+
return callback(error);
|
|
213
|
+
}
|
|
214
|
+
items_need_view = rs||items_need_view;
|
|
215
|
+
callback(null,items_need_view);
|
|
216
|
+
},{listinfo_code,req:options?.req})
|
|
217
|
+
}else{
|
|
218
|
+
callback(null,items_need_view);
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
viewRequired:(callback)=>{
|
|
222
|
+
items = [...items_cached,...items_need_view].sort((a,b)=>{
|
|
223
|
+
return a.stt_sorted-b.stt_sorted
|
|
224
|
+
})
|
|
225
|
+
if(self.viewRequired){
|
|
226
|
+
try{
|
|
227
|
+
self.viewRequired(user, items, function(error,rs) {
|
|
228
|
+
if (error) {
|
|
229
|
+
return callback(error);
|
|
230
|
+
}
|
|
231
|
+
items = rs||items;
|
|
232
|
+
callback(null,items);
|
|
233
|
+
},options);
|
|
234
|
+
}catch(e){
|
|
235
|
+
console.error("Error on viewRequired of",name,e);
|
|
236
|
+
callback(null,items);
|
|
237
|
+
}
|
|
238
|
+
}else{
|
|
239
|
+
callback(null,items);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
},(error)=>{
|
|
243
|
+
if(error) return next(error);
|
|
244
|
+
//xoá các refs
|
|
245
|
+
/*items.forEach(r=>{
|
|
246
|
+
delete r.__refs;
|
|
247
|
+
})*/
|
|
248
|
+
next(null,items);
|
|
249
|
+
})
|
|
250
|
+
})
|
|
251
|
+
}
|
|
252
|
+
module.exports =view;
|
package/server/libs/joinData.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const lodash=require("lodash"),{runWithoutSession}=require("./sessionContext");let cachedKeys={};try{cachedKeys=require("./redis-cache").cachedKeys()}catch($e$$){console.warn("Redis cache config not found, caching disabled.")}
|
|
2
2
|
const {generateRedisKey,sortObjectKeys}=require("./redis-cache"),redisGet=$key$$=>new Promise($resolve$$=>global.clientRedis.get($key$$,($err$$,$reply$$)=>$resolve$$($reply$$||null))),redisMGet=$keys$$=>new Promise($resolve$$=>global.clientRedis.mget($keys$$,($err$$,$reply$$)=>$resolve$$($reply$$||[])));function isValidObjectId($id$$){return $id$$?lodash.isObject($id$$)&&!$id$$._bsontype?!0:global.mongoose.Types.ObjectId.isValid($id$$.toString()):!1}
|
|
3
|
-
function findDynamicFields($dataArray$$){if(!$dataArray$$||$dataArray$$.length<2)return[];const $baseline$$=$dataArray$$[0],$dynamicFields$$=new Set;for(let $i$$=1;$i$$<$dataArray$$.length;$i$$++){const $currentObject$$=$dataArray$$[$i$$];var $currentValue_keys$$=Object.keys($currentObject$$);for(const $key$$ of $currentValue_keys$$)$dynamicFields$$.has($key$$)||($currentValue_keys$$=$currentObject$$[$key$$]
|
|
4
|
-
function getFields($fields$$){if($fields$$&&!lodash.isFunction($fields$$)){var $select$$={};(Array.isArray($fields$$)?$fields$$:[$fields$$]).forEach($map$$=>{lodash.isString($map$$)?$select$$[$map$$]=1:lodash.isObject($map$$)&&($map$$.value?$select$$[$map$$.value]=1:Object.keys($map$$).forEach($key$$=>$select$$[$map$$[$key$$]]=1))});return Object.keys($select$$).length>0?$select$$:void 0}}
|
|
3
|
+
function findDynamicFields($dataArray$$){if(!$dataArray$$||$dataArray$$.length<2)return[];const $baseline$$=$dataArray$$[0],$dynamicFields$$=new Set;for(let $i$$=1;$i$$<$dataArray$$.length;$i$$++){const $currentObject$$=$dataArray$$[$i$$];var $currentValue_keys$$=Object.keys($currentObject$$);for(const $key$$ of $currentValue_keys$$)$dynamicFields$$.has($key$$)||($currentValue_keys$$=$currentObject$$[$key$$],$currentValue_keys$$!==null&&typeof $currentValue_keys$$==="object"||$baseline$$[$key$$]===
|
|
4
|
+
$currentValue_keys$$||$dynamicFields$$.add($key$$))}return Array.from($dynamicFields$$)}function getFields($fields$$){if($fields$$&&!lodash.isFunction($fields$$)){var $select$$={};(Array.isArray($fields$$)?$fields$$:[$fields$$]).forEach($map$$=>{lodash.isString($map$$)?$select$$[$map$$]=1:lodash.isObject($map$$)&&($map$$.value?$select$$[$map$$.value]=1:Object.keys($map$$).forEach($key$$=>$select$$[$map$$[$key$$]]=1))});return Object.keys($select$$).length>0?$select$$:void 0}}
|
|
5
5
|
function normalizeArgs($items$$,$id_app$$,$model$$,$joinFields$$,$_fn_fn$$,$options$$){let $_id_app$$=$id_app$$,$_model$$=$model$$,$_joinFields$$=$joinFields$$;Array.isArray($id_app$$)&&([$_id_app$$,$_model$$,$_joinFields$$,$_fn_fn$$]=[void 0,$id_app$$,$model$$,$joinFields$$]);$_joinFields$$=$_joinFields$$?Array.isArray($_joinFields$$)?$_joinFields$$:[$_joinFields$$]:[];$_joinFields$$.forEach($join$$=>{$join$$.fields_need_get_data||$join$$.setFields||$join$$.asyncSetFields||($join$$.fields_need_get_data=
|
|
6
6
|
getFields($join$$.fields))});return{items:$items$$||[],id_app:$_id_app$$,modelOrigin:Array.isArray($_model$$)?null:$_model$$,joinFields:$_joinFields$$,fn:$_fn_fn$$||(()=>{}),options:$options$$||{cache:!0}}}function safeCallback($fn$$,$result$$){try{typeof $fn$$==="function"&&$fn$$($result$$)}catch($e$$){console.error("Callback Error:",$e$$)}}
|
|
7
7
|
function analyzeJoinStrategy($dynamicKey$jscomp$1_finalIdApp_join$$,$item$$,$model$$,$globalIdApp$$){$dynamicKey$jscomp$1_finalIdApp_join$$.modelName=$model$$?.modelName;var $cacheKey_cacheKey$jscomp$1_finalIdApp$jscomp$1_resolveIdApp_sortedStatic$jscomp$1_value$$=$currentQueryIdApp$$=>{if($model$$.schema?.paths?.id_app)return $item$$.id_app||$globalIdApp$$||$currentQueryIdApp$$},$dynamicKey_queryForKey_v$$={},$finalIdAppForKey_queryForKey$$=$globalIdApp$$;if($dynamicKey$jscomp$1_finalIdApp_join$$.where&&
|