acomm-core-lib 2.6.13 → 2.6.16
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/dist/src/core/auth/auth.module.js +2 -1
- package/dist/src/core/auth/auth.module.js.map +1 -1
- package/dist/src/core/auth/auth.service.js +5 -2
- package/dist/src/core/auth/auth.service.js.map +1 -1
- package/dist/src/core/cache/cache.utils.js +0 -1
- package/dist/src/core/cache/cache.utils.js.map +1 -1
- package/dist/src/core/common/base/base.service.js +163 -91
- package/dist/src/core/common/base/base.service.js.map +1 -1
- package/dist/src/core/common/utils/build_search.js +6 -0
- package/dist/src/core/common/utils/build_search.js.map +1 -1
- package/dist/src/core/common/utils/diff.js +0 -1
- package/dist/src/core/common/utils/diff.js.map +1 -1
- package/dist/src/core/common/utils/func.js +0 -2
- package/dist/src/core/common/utils/func.js.map +1 -1
- package/dist/src/core/common/utils/otp.js +16 -2
- package/dist/src/core/common/utils/otp.js.map +1 -1
- package/dist/src/core/common/utils/redis.js +0 -1
- package/dist/src/core/common/utils/redis.js.map +1 -1
- package/dist/src/core/common/utils/schema.js +2 -2
- package/dist/src/core/common/utils/schema.js.map +1 -1
- package/dist/src/core/common/utils/template.js +0 -1
- package/dist/src/core/common/utils/template.js.map +1 -1
- package/dist/src/core/common/utils/text_search.d.ts +2 -2
- package/dist/src/core/common/utils/text_search.js +12 -3
- package/dist/src/core/common/utils/text_search.js.map +1 -1
- package/dist/src/core/company/company.service.js +5 -1
- package/dist/src/core/company/company.service.js.map +1 -1
- package/dist/src/core/entities/entities.service.js +9 -7
- package/dist/src/core/entities/entities.service.js.map +1 -1
- package/dist/src/core/entities/entity.schema.d.ts +1 -0
- package/dist/src/core/entities/entity.schema.js +4 -0
- package/dist/src/core/entities/entity.schema.js.map +1 -1
- package/dist/src/core/import_export/import_export.service.js +0 -1
- package/dist/src/core/import_export/import_export.service.js.map +1 -1
- package/dist/src/core/index.d.ts +1 -0
- package/dist/src/core/index.js +1 -0
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/core/layout/chart_widget/chart_widget.service.js +0 -1
- package/dist/src/core/layout/chart_widget/chart_widget.service.js.map +1 -1
- package/dist/src/core/notification/message/message.service.js +0 -1
- package/dist/src/core/notification/message/message.service.js.map +1 -1
- package/dist/src/core/pipeline/pipeline.service.js +9 -2
- package/dist/src/core/pipeline/pipeline.service.js.map +1 -1
- package/dist/src/core/search_text/search_text.service.d.ts +1 -1
- package/dist/src/core/search_text/search_text.service.js +27 -6
- package/dist/src/core/search_text/search_text.service.js.map +1 -1
- package/dist/src/core/setting/dto/auth_setting.dto.d.ts +11 -0
- package/dist/src/core/setting/dto/auth_setting.dto.js +40 -1
- package/dist/src/core/setting/dto/auth_setting.dto.js.map +1 -1
- package/dist/src/core/setting/setting.constant.d.ts +11 -4
- package/dist/src/core/setting/setting.constant.js +11 -4
- package/dist/src/core/setting/setting.constant.js.map +1 -1
- package/dist/src/core/setting/setting.service.d.ts +1 -0
- package/dist/src/core/setting/setting.service.js +41 -1
- package/dist/src/core/setting/setting.service.js.map +1 -1
- package/dist/src/core/shortly/url/url.service.js +0 -1
- package/dist/src/core/shortly/url/url.service.js.map +1 -1
- package/dist/src/core/template/provider/template_sms.provider.js +5 -4
- package/dist/src/core/template/provider/template_sms.provider.js.map +1 -1
- package/dist/src/core/template/template.service.js +1 -1
- package/dist/src/core/template/template.service.js.map +1 -1
- package/dist/src/core/translate/translate.json +16 -0
- package/dist/src/core/users/user.controller.js +0 -1
- package/dist/src/core/users/user.controller.js.map +1 -1
- package/dist/src/core/users/user.enum.d.ts +2 -1
- package/dist/src/core/users/user.enum.js +1 -0
- package/dist/src/core/users/user.enum.js.map +1 -1
- package/dist/src/core/users/user.service.d.ts +2 -0
- package/dist/src/core/users/user.service.js +30 -11
- package/dist/src/core/users/user.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -36,6 +36,7 @@ const retry_1 = require("../utils/retry");
|
|
|
36
36
|
const text_search_1 = require("../utils/text_search");
|
|
37
37
|
const external_module_1 = require("../utils/external_module");
|
|
38
38
|
const MAX_SEARCH_IDS_SIZE = 100000;
|
|
39
|
+
const BULK_SEARCH_TEXT_ID_CHUNK_SIZE = 50;
|
|
39
40
|
const TTL = 3000;
|
|
40
41
|
let BaseService = class BaseService {
|
|
41
42
|
constructor(cls, model) {
|
|
@@ -140,9 +141,9 @@ let BaseService = class BaseService {
|
|
|
140
141
|
const request = this.cls.get("request");
|
|
141
142
|
const profile = _.get(request, "profile");
|
|
142
143
|
const entity = await (0, schema_1.loadEntity)(this.model.modelName);
|
|
143
|
-
const isAllowAddSearchText = (0, text_search_1.checkAllowAddSearchText)(
|
|
144
|
+
const isAllowAddSearchText = (0, text_search_1.checkAllowAddSearchText)(entity);
|
|
144
145
|
keywords = (0, text_search_1.modifyKeywords)(keywords);
|
|
145
|
-
let query = (await (0, build_search_1.buildQuery)(keywords, filters, entity, this._getCurrentProfile(), this._getCurrentPermissions(), this._getCurrentApiKey()));
|
|
146
|
+
let query = (await (0, build_search_1.buildQuery)(keywords, filters, entity, this._getCurrentProfile(), this._getCurrentPermissions(), this._getCurrentApiKey(), undefined, !isAllowAddSearchText));
|
|
146
147
|
const needMask = _.get(request, "headers._need_mask");
|
|
147
148
|
query = await (0, build_search_1.buildDataPermissionQuery)(query, profile, this.model.modelName);
|
|
148
149
|
const result = {
|
|
@@ -169,8 +170,32 @@ let BaseService = class BaseService {
|
|
|
169
170
|
const provider = await (0, external_data_1.getExternalDataProvider)(entity, externalSourceProvider);
|
|
170
171
|
return provider.find(query, page, page_size, sort, fields);
|
|
171
172
|
}
|
|
172
|
-
|
|
173
|
-
|
|
173
|
+
if (isAllowAddSearchText) {
|
|
174
|
+
query = await (0, build_search_1.buildAggregateQuery)(keywords, query, entity.fields, this.model.modelName);
|
|
175
|
+
}
|
|
176
|
+
if (_.isEmpty(grouping) && !isAllowAddSearchText) {
|
|
177
|
+
let resultQuery = [];
|
|
178
|
+
let total = 0;
|
|
179
|
+
let doc = this.model.find(query);
|
|
180
|
+
(0, schema_1.buildSelect)(doc, fields);
|
|
181
|
+
await (0, schema_1.buildPopulate)(doc, this.model.modelName, fields);
|
|
182
|
+
doc = doc
|
|
183
|
+
.sort((0, build_search_1.buildSort)(sort))
|
|
184
|
+
.skip(currentPage)
|
|
185
|
+
.limit(page_size);
|
|
186
|
+
resultQuery = await doc.exec();
|
|
187
|
+
total = await this.model.countDocuments(query);
|
|
188
|
+
resultQuery = (0, decimal2Json_1.imageComponent)(resultQuery);
|
|
189
|
+
resultQuery = await (0, schema_1.transformShareWidget)(this.model.modelName, resultQuery);
|
|
190
|
+
resultQuery = await (0, schema_1.transformJsonFields)(this.model.modelName, resultQuery, this._getCurrentHeaders());
|
|
191
|
+
if (!noTranslate) {
|
|
192
|
+
resultQuery = await Promise.all(resultQuery.map(async (i) => await (0, translate_1.translateData)(i, this.model.modelName, _.get(this._getCurrentHeaders(), "accept-language"))));
|
|
193
|
+
}
|
|
194
|
+
result.total = total;
|
|
195
|
+
result.total_page = Math.ceil(total / page_size);
|
|
196
|
+
result.rows = resultQuery;
|
|
197
|
+
}
|
|
198
|
+
else if (_.isEmpty(grouping)) {
|
|
174
199
|
let resultQuery = [];
|
|
175
200
|
let total = 0;
|
|
176
201
|
const aggregate = await (0, schema_1.buildAggregate)(query, this.model.modelName, fields, currentPage, page_size, sort);
|
|
@@ -264,8 +289,9 @@ let BaseService = class BaseService {
|
|
|
264
289
|
const profile = _.get(request, "profile");
|
|
265
290
|
const entity = await (0, schema_1.loadEntity)(this.model.modelName);
|
|
266
291
|
keywords = (0, text_search_1.modifyKeywords)(keywords);
|
|
292
|
+
const isAllowAddSearchText = (0, text_search_1.checkAllowAddSearchText)(entity);
|
|
267
293
|
(0, permission_1.checkPermission)(this.model.modelName, "view", this._getCurrentPermissions(), entity.layouts.find(l => l.code === layoutCode), this._getCurrentRole());
|
|
268
|
-
let query = (await (0, build_search_1.buildQuery)(keywords, filters, entity, this._getCurrentProfile(), this._getCurrentPermissions(), this._getCurrentApiKey(), layoutCode));
|
|
294
|
+
let query = (await (0, build_search_1.buildQuery)(keywords, filters, entity, this._getCurrentProfile(), this._getCurrentPermissions(), this._getCurrentApiKey(), layoutCode, !isAllowAddSearchText));
|
|
269
295
|
query = await (0, build_search_1.buildDataPermissionQuery)(query, profile, this.model.modelName);
|
|
270
296
|
const view = entity.layouts.find(i => i.code === layoutCode);
|
|
271
297
|
if (!view) {
|
|
@@ -298,8 +324,32 @@ let BaseService = class BaseService {
|
|
|
298
324
|
const provider = await (0, external_data_1.getExternalDataProvider)(entity, externalSourceProvider);
|
|
299
325
|
return provider.find(query, page, page_size, sort, fields);
|
|
300
326
|
}
|
|
301
|
-
|
|
302
|
-
|
|
327
|
+
if (isAllowAddSearchText) {
|
|
328
|
+
query = await (0, build_search_1.buildAggregateQuery)(keywords, query, fields, this.model.modelName);
|
|
329
|
+
}
|
|
330
|
+
if (_.isEmpty(grouping) && !isAllowAddSearchText) {
|
|
331
|
+
let resultQuery = [];
|
|
332
|
+
let total = 0;
|
|
333
|
+
let doc = this.model.find(query);
|
|
334
|
+
await (0, schema_1.buildPopulateWithLayout)(doc, fields, isDetail);
|
|
335
|
+
doc = doc
|
|
336
|
+
.sort((0, build_search_1.buildSort)(sort))
|
|
337
|
+
.skip(currentPage)
|
|
338
|
+
.select((0, layout_1.generateSelectFields)(entity.fields, fields, false, [
|
|
339
|
+
_.get(entity, "workflows.field")
|
|
340
|
+
]))
|
|
341
|
+
.limit(page_size);
|
|
342
|
+
resultQuery = await doc.exec();
|
|
343
|
+
total = await this.model.countDocuments(query);
|
|
344
|
+
resultQuery = (0, decimal2Json_1.imageComponent)(resultQuery);
|
|
345
|
+
resultQuery = await (0, schema_1.transformShareWidget)(this.model.modelName, resultQuery);
|
|
346
|
+
resultQuery = await (0, schema_1.transformJsonFields)(this.model.modelName, resultQuery, this._getCurrentHeaders());
|
|
347
|
+
resultQuery = await Promise.all(resultQuery.map(async (i) => await (0, translate_1.translateData)(i, this.model.modelName, _.get(this._getCurrentHeaders(), "accept-language"))));
|
|
348
|
+
result.total = total;
|
|
349
|
+
result.total_page = Math.ceil(total / page_size);
|
|
350
|
+
result.rows = resultQuery;
|
|
351
|
+
}
|
|
352
|
+
else if (_.isEmpty(grouping)) {
|
|
303
353
|
let resultQuery = [];
|
|
304
354
|
let total = 0;
|
|
305
355
|
const aggregate = await (0, schema_1.buildAggregate)(query, this.model.modelName, fields, currentPage, page_size, sort);
|
|
@@ -618,19 +668,21 @@ let BaseService = class BaseService {
|
|
|
618
668
|
profile: this._getCurrentProfile()
|
|
619
669
|
});
|
|
620
670
|
}
|
|
621
|
-
(
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
671
|
+
if (entity.keep_activity_log) {
|
|
672
|
+
(0, schema_1.addActivityLog)(entity, {
|
|
673
|
+
headers: this._getCurrentHeaders(),
|
|
674
|
+
body: this._getCurrentBody(),
|
|
675
|
+
profile: this._getCurrentProfile()
|
|
676
|
+
}, result, activity_log_enum_1.ActivityLogType.activity, activity_log_enum_1.ActivityLogAction.created, activity_log_enum_1.ActivityLogStatus.successfully).catch(err => {
|
|
677
|
+
console.error('Activity log error:', err);
|
|
678
|
+
});
|
|
679
|
+
}
|
|
628
680
|
await (0, hook_1.executeHooks)(entity, "create", "after", {
|
|
629
681
|
headers: this._getCurrentHeaders(),
|
|
630
682
|
body: this._getCurrentBody(),
|
|
631
683
|
profile: this._getCurrentProfile()
|
|
632
684
|
}, result);
|
|
633
|
-
if ((0, text_search_1.checkAllowAddSearchText)(
|
|
685
|
+
if ((0, text_search_1.checkAllowAddSearchText)(entity)) {
|
|
634
686
|
const searchTextData = await (0, text_search_1.getSearchTextIndexObject)(entity, result);
|
|
635
687
|
const searchEncrypt = (0, text_search_1.getSearchEncryptIndex)(entity, data);
|
|
636
688
|
if (!_.isEmpty(searchTextData) || !_.isEmpty(searchEncrypt)) {
|
|
@@ -741,19 +793,21 @@ let BaseService = class BaseService {
|
|
|
741
793
|
profile: this._getCurrentProfile()
|
|
742
794
|
});
|
|
743
795
|
}
|
|
744
|
-
(
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
796
|
+
if (entity.keep_activity_log) {
|
|
797
|
+
(0, schema_1.addActivityLog)(entity, {
|
|
798
|
+
headers: this._getCurrentHeaders(),
|
|
799
|
+
body: this._getCurrentBody(),
|
|
800
|
+
profile: this._getCurrentProfile()
|
|
801
|
+
}, result, activity_log_enum_1.ActivityLogType.activity, activity_log_enum_1.ActivityLogAction.updated, activity_log_enum_1.ActivityLogStatus.successfully, undefined, undefined, "Update successfully", "", result, JSON.parse(JSON.stringify(olddata))).catch(err => {
|
|
802
|
+
console.error('Activity log error:', err);
|
|
803
|
+
});
|
|
804
|
+
}
|
|
751
805
|
await (0, hook_1.executeHooks)(entity, "update", "after", {
|
|
752
806
|
headers: this._getCurrentHeaders(),
|
|
753
807
|
body: this._getCurrentBody(),
|
|
754
808
|
profile: this._getCurrentProfile()
|
|
755
809
|
}, Object.assign(Object.assign({}, result), { _old_data: _.cloneDeep(olddata) }));
|
|
756
|
-
if ((0, text_search_1.checkAllowAddSearchText)(
|
|
810
|
+
if ((0, text_search_1.checkAllowAddSearchText)(entity)) {
|
|
757
811
|
const searchTextData = await (0, text_search_1.getSearchTextIndexObject)(entity, result);
|
|
758
812
|
const searchEncrypt = (0, text_search_1.getSearchEncryptIndex)(entity, result);
|
|
759
813
|
if (!_.isEmpty(searchTextData) || !_.isEmpty(searchEncrypt)) {
|
|
@@ -813,13 +867,15 @@ let BaseService = class BaseService {
|
|
|
813
867
|
}
|
|
814
868
|
}
|
|
815
869
|
const result = await this.model.deleteOne(query);
|
|
816
|
-
(
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
870
|
+
if (entity.keep_activity_log) {
|
|
871
|
+
(0, schema_1.addActivityLog)(entity, {
|
|
872
|
+
headers: this._getCurrentHeaders(),
|
|
873
|
+
body: this._getCurrentBody(),
|
|
874
|
+
profile: this._getCurrentProfile()
|
|
875
|
+
}, Object.assign(Object.assign({}, result), data), activity_log_enum_1.ActivityLogType.activity, activity_log_enum_1.ActivityLogAction.deleted, activity_log_enum_1.ActivityLogStatus.successfully).catch(err => {
|
|
876
|
+
console.error('Activity log error:', err);
|
|
877
|
+
});
|
|
878
|
+
}
|
|
823
879
|
(0, schema_1.callMarkDeletedInternal)(this.model.modelName, [id]);
|
|
824
880
|
await (0, hook_1.executeHooks)(entity, "delete", "after", {
|
|
825
881
|
headers: this._getCurrentHeaders(),
|
|
@@ -882,14 +938,16 @@ let BaseService = class BaseService {
|
|
|
882
938
|
}
|
|
883
939
|
const result = await this.model.bulkWrite(bulkData);
|
|
884
940
|
const ids = Object.values(result.insertedIds).map(i => `${i}`);
|
|
885
|
-
(
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
941
|
+
if (entity.keep_activity_log) {
|
|
942
|
+
(0, schema_1.addActivityLog)(entity, {
|
|
943
|
+
headers: this._getCurrentHeaders(),
|
|
944
|
+
body: this._getCurrentBody(),
|
|
945
|
+
profile: this._getCurrentProfile()
|
|
946
|
+
}, result, activity_log_enum_1.ActivityLogType.activity, activity_log_enum_1.ActivityLogAction.created, activity_log_enum_1.ActivityLogStatus.successfully).catch(err => {
|
|
947
|
+
console.error('Activity log error:', err);
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
if ((0, text_search_1.checkAllowAddSearchText)(entity)) {
|
|
893
951
|
await this._bulkUpdateSearchText(ids);
|
|
894
952
|
}
|
|
895
953
|
return ids;
|
|
@@ -927,15 +985,17 @@ let BaseService = class BaseService {
|
|
|
927
985
|
});
|
|
928
986
|
}
|
|
929
987
|
const result = await this.model.bulkWrite(bulkData);
|
|
930
|
-
(
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
988
|
+
if (entity.keep_activity_log) {
|
|
989
|
+
(0, schema_1.addActivityLog)(entity, {
|
|
990
|
+
headers: this._getCurrentHeaders(),
|
|
991
|
+
body: this._getCurrentBody(),
|
|
992
|
+
profile: this._getCurrentProfile()
|
|
993
|
+
}, result, activity_log_enum_1.ActivityLogType.activity, activity_log_enum_1.ActivityLogAction.updated, activity_log_enum_1.ActivityLogStatus.successfully).catch(err => {
|
|
994
|
+
console.error('Activity log error:', err);
|
|
995
|
+
});
|
|
996
|
+
}
|
|
937
997
|
const ids = data.map(i => i.id || i._id);
|
|
938
|
-
if ((0, text_search_1.checkAllowAddSearchText)(
|
|
998
|
+
if ((0, text_search_1.checkAllowAddSearchText)(entity)) {
|
|
939
999
|
await this._bulkUpdateSearchText(ids);
|
|
940
1000
|
}
|
|
941
1001
|
return ids;
|
|
@@ -949,13 +1009,15 @@ let BaseService = class BaseService {
|
|
|
949
1009
|
bulkData.push({ deleteOne: { filter: { _id: id } } });
|
|
950
1010
|
}
|
|
951
1011
|
const result = await this.model.bulkWrite(bulkData);
|
|
952
|
-
(
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
1012
|
+
if (entity.keep_activity_log) {
|
|
1013
|
+
(0, schema_1.addActivityLog)(entity, {
|
|
1014
|
+
headers: this._getCurrentHeaders(),
|
|
1015
|
+
body: this._getCurrentBody(),
|
|
1016
|
+
profile: this._getCurrentProfile()
|
|
1017
|
+
}, result, activity_log_enum_1.ActivityLogType.activity, activity_log_enum_1.ActivityLogAction.deleted, activity_log_enum_1.ActivityLogStatus.successfully).catch(err => {
|
|
1018
|
+
console.error('Activity log error:', err);
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
959
1021
|
await (0, schema_1.callMarkDeletedInternal)(this.model.modelName, ids);
|
|
960
1022
|
return ids;
|
|
961
1023
|
}
|
|
@@ -1059,13 +1121,15 @@ let BaseService = class BaseService {
|
|
|
1059
1121
|
}, 2, 1000);
|
|
1060
1122
|
result2 = JSON.parse(JSON.stringify(result2));
|
|
1061
1123
|
const workflowMessage = (0, schema_1.getWorkflowLogMessage)(entity, { headers: this._getCurrentHeaders() }, currentState, targetState);
|
|
1062
|
-
(
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1124
|
+
if (entity.keep_activity_log) {
|
|
1125
|
+
(0, schema_1.addActivityLog)(entity, {
|
|
1126
|
+
headers: this._getCurrentHeaders(),
|
|
1127
|
+
body: this._getCurrentBody(),
|
|
1128
|
+
profile: this._getCurrentProfile()
|
|
1129
|
+
}, { id }, activity_log_enum_1.ActivityLogType.workflow, activity_log_enum_1.ActivityLogAction.approved, activity_log_enum_1.ActivityLogStatus.successfully, new Date(), new Date(), _.get(workflowMessage, "message", ""), _.get(workflowMessage, "description", "")).catch(err => {
|
|
1130
|
+
console.error('Activity log error:', err);
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1069
1133
|
reasons.length > 0 && (await (0, schema_1.saveReasons)(entity, id, reasons));
|
|
1070
1134
|
if (_.get(isExists, "executions.length")) {
|
|
1071
1135
|
for (const ex of isExists["executions"].filter(i => i.enabled)) {
|
|
@@ -1209,8 +1273,6 @@ let BaseService = class BaseService {
|
|
|
1209
1273
|
if (!entity)
|
|
1210
1274
|
return;
|
|
1211
1275
|
const supportDeepSearch = _.get(entity, "deep_search_text", true);
|
|
1212
|
-
let hasMore = true;
|
|
1213
|
-
let page = 1;
|
|
1214
1276
|
const pageSize = 200;
|
|
1215
1277
|
const fields = supportDeepSearch
|
|
1216
1278
|
? `*,${entity.fields
|
|
@@ -1218,37 +1280,47 @@ let BaseService = class BaseService {
|
|
|
1218
1280
|
.map(field => `${field.name}.*`)
|
|
1219
1281
|
.join(",")}`
|
|
1220
1282
|
: "*";
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1283
|
+
for (const idChunk of _.chunk(ids, BULK_SEARCH_TEXT_ID_CHUNK_SIZE)) {
|
|
1284
|
+
let hasMore = true;
|
|
1285
|
+
let page = 1;
|
|
1286
|
+
while (hasMore) {
|
|
1287
|
+
const listResult = await (0, schema_1.callListInternalService)(this.model.modelName, "", {
|
|
1288
|
+
_id: {
|
|
1289
|
+
$in: idChunk
|
|
1290
|
+
}
|
|
1291
|
+
}, "", fields, page, pageSize);
|
|
1292
|
+
const rows = _.get(listResult, "rows", []);
|
|
1293
|
+
if (rows.length === 0) {
|
|
1294
|
+
break;
|
|
1225
1295
|
}
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1296
|
+
const searchTextData = await (0, text_search_1.getSearchTextIndexObject)(entity, rows);
|
|
1297
|
+
const bulkUpdate = searchTextData.map(record => ({
|
|
1298
|
+
updateOne: {
|
|
1299
|
+
filter: {
|
|
1300
|
+
_id: record.id
|
|
1301
|
+
},
|
|
1302
|
+
update: {
|
|
1303
|
+
$set: {
|
|
1304
|
+
_search_text: record.textTerm,
|
|
1305
|
+
_need_refresh: supportDeepSearch
|
|
1306
|
+
}
|
|
1307
|
+
},
|
|
1308
|
+
upsert: false
|
|
1309
|
+
}
|
|
1310
|
+
}));
|
|
1311
|
+
await (0, schema_1.callInternalService)("search_text", "post", "execute", {
|
|
1312
|
+
type: "mark_need_refresh",
|
|
1313
|
+
data: {
|
|
1314
|
+
entity: this.model.modelName,
|
|
1315
|
+
searchTextData,
|
|
1316
|
+
dataId: idChunk
|
|
1317
|
+
}
|
|
1318
|
+
});
|
|
1319
|
+
await this.model.bulkWrite(bulkUpdate);
|
|
1320
|
+
page++;
|
|
1321
|
+
if (rows.length < pageSize) {
|
|
1322
|
+
hasMore = false;
|
|
1245
1323
|
}
|
|
1246
|
-
}));
|
|
1247
|
-
await (0, schema_1.callInternalService)("search_text", "post", "execute", { type: "mark_need_refresh", data: { entity: this.model.modelName, searchTextData: searchTextData, dataId: ids } });
|
|
1248
|
-
await this.model.bulkWrite(bulkUpdate);
|
|
1249
|
-
page++;
|
|
1250
|
-
if (rows.length < pageSize) {
|
|
1251
|
-
hasMore = false;
|
|
1252
1324
|
}
|
|
1253
1325
|
}
|
|
1254
1326
|
}
|