cc-core-cli 1.0.133 → 1.0.136
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/bin/index.js +4 -4
- package/package.json +1 -1
- package/template/admin_v3/src/pages/api/database/[type]/index.ts +23 -0
- package/template/admin_v3/src/pages/api/layout_chart_widget/[name]/index.ts +18 -0
- package/template/admin_v3/src/pages/api/layout_chart_widget/compare_matrix.ts +17 -0
- package/template/admin_v3/src/pages/api/redis/[type]/[connect]/index.ts +20 -0
- package/template/admin_v3/src/pages/api/redis/custom.ts +10 -0
- package/template/admin_v3/src/pages/api/setting/module/[code].ts +34 -0
- package/template/admin_v3/src/pages/api/template/[type].ts +21 -0
- package/template/admin_v3/src/pages/api/template/bulk_print/[id].ts +15 -0
- package/template/admin_v3/src/pages/api/template/print/[id]/[doc_ref].ts +11 -0
- package/template/core/src/main.ts +4 -1
- package/template/core_v3/Dockerfile +60 -0
- package/template/core_v3/_env +12 -0
- package/template/core_v3/_gitignore +52 -0
- package/template/core_v3/_npmrc +1 -0
- package/template/core_v3/buildspec.yml +29 -0
- package/template/core_v3/docker-compose.yml +11 -0
- package/template/core_v3/jest.config.js +43 -0
- package/template/core_v3/newrelic.sh +15 -0
- package/template/core_v3/package.json +54 -0
- package/template/core_v3/post-install.js +34 -0
- package/template/core_v3/sonar-project.properties +27 -0
- package/template/core_v3/src/app.controller.ts +39 -0
- package/template/core_v3/src/app.module.ts +174 -0
- package/template/core_v3/src/app.service.ts +21 -0
- package/template/core_v3/src/app_cluster.service.ts +61 -0
- package/template/core_v3/src/core/core.controller.ts +444 -0
- package/template/core_v3/src/core/core.module.ts +90 -0
- package/template/core_v3/src/core/core.service.ts +737 -0
- package/template/core_v3/src/core/setting/_settings/about.layout.json +105 -0
- package/template/core_v3/src/core/setting/_settings/cache.layout.json +309 -0
- package/template/core_v3/src/core/setting/_settings/global_login.json +299 -0
- package/template/core_v3/src/core/setting/_settings/header_footer.json +83 -0
- package/template/core_v3/src/core/setting/_settings/import_export.layout.json +69 -0
- package/template/core_v3/src/core/setting/_settings/list_detail.json +685 -0
- package/template/core_v3/src/core/setting/_settings/logs.layout.json +39 -0
- package/template/core_v3/src/core/setting/_settings/queue.layout.json +63 -0
- package/template/core_v3/src/core/setting/_settings/schedule.layout.json +132 -0
- package/template/core_v3/src/core/setting/_settings/security.layout.json +1110 -0
- package/template/core_v3/src/core/setting/_settings/storage.layout.json +158 -0
- package/template/core_v3/src/core/setting/_settings/swagger.layout.json +128 -0
- package/template/core_v3/src/core/setting/_settings/toast.json +344 -0
- package/template/core_v3/src/main.ts +308 -0
- package/template/core_v3/src/modules/modules.ts +16 -0
- package/template/core_v3/src/private.controller.ts +18 -0
- package/template/core_v3/storage/documents/index.html +14 -0
- package/template/core_v3/storage/public/system/menu/icons/company.svg +1 -0
- package/template/core_v3/storage/public/system/menu/icons/deploy.svg +2 -0
- package/template/core_v3/storage/public/system/menu/icons/entities.svg +55 -0
- package/template/core_v3/storage/public/system/menu/icons/files.svg +1 -0
- package/template/core_v3/storage/public/system/menu/icons/gateway.svg +1 -0
- package/template/core_v3/storage/public/system/menu/icons/import-export.svg +41 -0
- package/template/core_v3/storage/public/system/menu/icons/integration.svg +1 -0
- package/template/core_v3/storage/public/system/menu/icons/master_data.svg +53 -0
- package/template/core_v3/storage/public/system/menu/icons/modules.svg +79 -0
- package/template/core_v3/storage/public/system/menu/icons/monitoring.svg +114 -0
- package/template/core_v3/storage/public/system/menu/icons/pipeline.svg +1 -0
- package/template/core_v3/storage/public/system/menu/icons/provider.svg +1 -0
- package/template/core_v3/storage/public/system/menu/icons/report.svg +69 -0
- package/template/core_v3/storage/public/system/menu/icons/schedule.svg +1 -0
- package/template/core_v3/storage/public/system/menu/icons/security.svg +1 -0
- package/template/core_v3/storage/public/system/menu/icons/storage.svg +1 -0
- package/template/core_v3/storage/public/system/menu/icons/template.svg +44 -0
- package/template/core_v3/storage/public/system/menu/icons/theme-layout.svg +1 -0
- package/template/core_v3/test/__mocks__/cc-core-lib.d.ts +161 -0
- package/template/core_v3/test/__mocks__/cc-core-lib.js +311 -0
- package/template/core_v3/test/__mocks__/pdf-img-convert.js +5 -0
- package/template/core_v3/test/jest.setup.ts +25 -0
- package/template/core_v3/tsconfig.build.json +4 -0
- package/template/core_v3/tsconfig.json +22 -0
- package/template/core_v3/tsconfig.test.json +17 -0
- package/template/core_v3/version.json +5 -0
- package/template/admin_v3/src/pages/api/redis/[connect]/index.ts +0 -0
- package/template/admin_v3/src/pages/api/redis/index.ts +0 -0
|
@@ -0,0 +1,737 @@
|
|
|
1
|
+
import * as _ from "lodash";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Inject,
|
|
5
|
+
Injectable,
|
|
6
|
+
OnModuleInit,
|
|
7
|
+
} from "@nestjs/common";
|
|
8
|
+
import { ModuleRef } from "@nestjs/core";
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
import { CUSTOM_MODULES } from "src/modules/modules";
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
ActivityLogService,
|
|
15
|
+
ApiKeyService,
|
|
16
|
+
AttachmentService,
|
|
17
|
+
AuditLogService,
|
|
18
|
+
CommentDataService,
|
|
19
|
+
CustomFunctionService,
|
|
20
|
+
CompanyService,
|
|
21
|
+
AddressService,
|
|
22
|
+
CountryService,
|
|
23
|
+
ProvinceService,
|
|
24
|
+
DistrictService,
|
|
25
|
+
SubdistrictService,
|
|
26
|
+
TimeZoneService,
|
|
27
|
+
CurrencyService,
|
|
28
|
+
DeployDestinationService,
|
|
29
|
+
DeployPackageService,
|
|
30
|
+
DeployLogService,
|
|
31
|
+
ExecutionLogService,
|
|
32
|
+
ImportExportService,
|
|
33
|
+
ImportExportLogService,
|
|
34
|
+
LanguageService,
|
|
35
|
+
MailSettingService,
|
|
36
|
+
MailLogService,
|
|
37
|
+
MapLocationService,
|
|
38
|
+
ReasonMasterService,
|
|
39
|
+
ReasonOptionService,
|
|
40
|
+
ReasonDataService,
|
|
41
|
+
ScheduleActionService,
|
|
42
|
+
ScheduleLogService,
|
|
43
|
+
SmsService,
|
|
44
|
+
SmsLogService,
|
|
45
|
+
TemplateService,
|
|
46
|
+
TranslateService,
|
|
47
|
+
NotificationLogService,
|
|
48
|
+
ShortlyUrlService,
|
|
49
|
+
LayoutShareWidgetService,
|
|
50
|
+
SearchResultDto,
|
|
51
|
+
UserService,
|
|
52
|
+
UserRoleService,
|
|
53
|
+
UserRolePermissonService,
|
|
54
|
+
UserFilterService,
|
|
55
|
+
VersionDataService,
|
|
56
|
+
WidgetService,
|
|
57
|
+
IBaseModuleSettingService,
|
|
58
|
+
NotificationSubscriptionService,
|
|
59
|
+
NotificationMessageService,
|
|
60
|
+
NotificationMessageQueueService,
|
|
61
|
+
PipelineService,
|
|
62
|
+
PipelineJobService,
|
|
63
|
+
PipelineLogService,
|
|
64
|
+
PrintLogService,
|
|
65
|
+
} from '@shopstack/cc-core-lib/core'
|
|
66
|
+
|
|
67
|
+
const SPECIFY_CUSTOM_MODULES =
|
|
68
|
+
process.env.CUSTOM_MODULES === "" || process.env.CUSTOM_MODULES === undefined
|
|
69
|
+
? []
|
|
70
|
+
: process.env.CUSTOM_MODULES.split(",");
|
|
71
|
+
|
|
72
|
+
const RUN_CUSTOM_MODULES =
|
|
73
|
+
SPECIFY_CUSTOM_MODULES.length === 0
|
|
74
|
+
? CUSTOM_MODULES
|
|
75
|
+
: CUSTOM_MODULES.filter(c =>
|
|
76
|
+
SPECIFY_CUSTOM_MODULES.includes(c.module.name)
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const CUSTOM_SERVICES = _.reduce(
|
|
80
|
+
RUN_CUSTOM_MODULES,
|
|
81
|
+
(r, v) => {
|
|
82
|
+
const moduleName = _.snakeCase(
|
|
83
|
+
`${v.module.name.slice(0, 2).toLowerCase()}${v.module.name.slice(2)}`
|
|
84
|
+
)
|
|
85
|
+
.replace(/_[0-9]*_/g, (m, g1, g2, i) => {
|
|
86
|
+
return m.slice(1);
|
|
87
|
+
})
|
|
88
|
+
.toLowerCase()
|
|
89
|
+
.replace("_module", "");
|
|
90
|
+
for (const service of v.services || []) {
|
|
91
|
+
const serviceName = `${service.name
|
|
92
|
+
.slice(0, 2)
|
|
93
|
+
.toLowerCase()}${service.name.slice(2)}`;
|
|
94
|
+
let key = `${moduleName}_${_.snakeCase(serviceName)
|
|
95
|
+
.replace(/_[0-9]*_/g, (m, g1, g2, i) => {
|
|
96
|
+
return m.slice(1);
|
|
97
|
+
})
|
|
98
|
+
.toLowerCase()
|
|
99
|
+
.replace("_service", "")
|
|
100
|
+
.replace(`${moduleName}_`, "")}`;
|
|
101
|
+
if (key === "sellers_seller_user") {
|
|
102
|
+
key = "sellers_user";
|
|
103
|
+
}
|
|
104
|
+
r[key] = service;
|
|
105
|
+
}
|
|
106
|
+
return r;
|
|
107
|
+
},
|
|
108
|
+
{}
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const CUSTOM_LOG_SERVICES = _.reduce(
|
|
112
|
+
RUN_CUSTOM_MODULES,
|
|
113
|
+
(r, v) => {
|
|
114
|
+
const moduleName = _.snakeCase(
|
|
115
|
+
`${v.module.name.slice(0, 2).toLowerCase()}${v.module.name.slice(2)}`
|
|
116
|
+
)
|
|
117
|
+
.toLowerCase()
|
|
118
|
+
.replace("_module", "");
|
|
119
|
+
for (const service of v.services || []) {
|
|
120
|
+
const serviceName = _.snakeCase(
|
|
121
|
+
`${service.name.slice(0, 2).toLowerCase()}${service.name.slice(2)}`
|
|
122
|
+
)
|
|
123
|
+
.toLowerCase()
|
|
124
|
+
.replace("_service", "")
|
|
125
|
+
.replace(`${moduleName}_`, "");
|
|
126
|
+
if (serviceName === "log") {
|
|
127
|
+
const key = `${moduleName}_${serviceName}`;
|
|
128
|
+
r[key] = service;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return r;
|
|
132
|
+
},
|
|
133
|
+
{}
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
const CUSTOM_SETTING_SERVICES = _.reduce(
|
|
137
|
+
RUN_CUSTOM_MODULES,
|
|
138
|
+
(r, v) => {
|
|
139
|
+
const moduleName = _.snakeCase(
|
|
140
|
+
`${v.module.name.slice(0, 2).toLowerCase()}${v.module.name.slice(2)}`
|
|
141
|
+
)
|
|
142
|
+
.toLowerCase()
|
|
143
|
+
.replace("_module", "");
|
|
144
|
+
for (const service of v.services || []) {
|
|
145
|
+
const serviceName = _.snakeCase(
|
|
146
|
+
`${service.name.slice(0, 2).toLowerCase()}${service.name.slice(2)}`
|
|
147
|
+
)
|
|
148
|
+
.toLowerCase()
|
|
149
|
+
.replace("_service", "")
|
|
150
|
+
.replace(`${moduleName}_`, "");
|
|
151
|
+
if (serviceName === "setting") {
|
|
152
|
+
const key = `${moduleName}_${serviceName}`;
|
|
153
|
+
r[key] = service;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return r;
|
|
157
|
+
},
|
|
158
|
+
{}
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
@Injectable()
|
|
162
|
+
export class CoreService implements OnModuleInit {
|
|
163
|
+
@Inject(ActivityLogService) private readonly _activityLogService: ActivityLogService;
|
|
164
|
+
@Inject(AddressService) private readonly _addressService: AddressService;
|
|
165
|
+
@Inject(ApiKeyService) private readonly _apiKeyService: ApiKeyService;
|
|
166
|
+
@Inject(AttachmentService) private readonly _attachmentService: AttachmentService;
|
|
167
|
+
@Inject(CommentDataService) private readonly _commentDataService: CommentDataService;
|
|
168
|
+
@Inject(CountryService) private readonly _countryService: CountryService;
|
|
169
|
+
@Inject(CompanyService) private readonly _companyService: CompanyService;
|
|
170
|
+
@Inject(CustomFunctionService) private readonly _customFunctionService: CustomFunctionService;
|
|
171
|
+
@Inject(DeployDestinationService) private readonly _deployDestinationService: DeployDestinationService;
|
|
172
|
+
@Inject(DeployLogService) private readonly _deployLogService: DeployLogService;
|
|
173
|
+
@Inject(DeployPackageService) private readonly _deployPackageService: DeployPackageService;
|
|
174
|
+
@Inject(DistrictService) private readonly _districtService: DistrictService;
|
|
175
|
+
@Inject(ExecutionLogService) private readonly _executionLogService: ExecutionLogService;
|
|
176
|
+
@Inject(ImportExportService) private readonly _importExportService: ImportExportService;
|
|
177
|
+
@Inject(ImportExportLogService) private readonly _importExportLogService: ImportExportLogService;
|
|
178
|
+
@Inject(PrintLogService) private readonly _printLogService: PrintLogService;
|
|
179
|
+
@Inject(LanguageService) private readonly _languageService: LanguageService;
|
|
180
|
+
@Inject(LayoutShareWidgetService) private readonly _layoutShareWidgetService: LayoutShareWidgetService;
|
|
181
|
+
@Inject(MailSettingService) private readonly _mailService: MailSettingService;
|
|
182
|
+
@Inject(MailLogService) private readonly _mailLogService: MailLogService;
|
|
183
|
+
@Inject(MapLocationService) private readonly _mapLocationService: MapLocationService;
|
|
184
|
+
@Inject(NotificationSubscriptionService) private readonly _notificationSubscriptionService: NotificationSubscriptionService;
|
|
185
|
+
@Inject(NotificationMessageService) private readonly _notificationMessageService: NotificationMessageService;
|
|
186
|
+
@Inject(NotificationMessageQueueService) private readonly _notificationMessageQueueService: NotificationMessageQueueService;
|
|
187
|
+
@Inject(NotificationLogService) private readonly _notificationLogService: NotificationLogService;
|
|
188
|
+
@Inject(ProvinceService) private readonly _provinceService: ProvinceService;
|
|
189
|
+
@Inject(ReasonDataService) private readonly _reasonDataService: ReasonDataService;
|
|
190
|
+
@Inject(ReasonMasterService) private readonly _reasonMasterService: ReasonMasterService;
|
|
191
|
+
@Inject(ReasonOptionService) private readonly _reasonOptionService: ReasonOptionService;
|
|
192
|
+
@Inject(ScheduleActionService) private readonly _scheduleActionService: ScheduleActionService;
|
|
193
|
+
@Inject(ScheduleLogService) private readonly _scheduleLogService: ScheduleLogService;
|
|
194
|
+
@Inject(ShortlyUrlService) private readonly _shortlyUrlService: ShortlyUrlService;
|
|
195
|
+
@Inject(SmsService) private readonly _smsService: SmsService;
|
|
196
|
+
@Inject(SmsLogService) private readonly _smsLogService: SmsLogService;
|
|
197
|
+
@Inject(SubdistrictService) private readonly _subdistrictService: SubdistrictService;
|
|
198
|
+
@Inject(TemplateService) private readonly _templateService: TemplateService;
|
|
199
|
+
@Inject(TimeZoneService) private readonly _timeZoneService: TimeZoneService;
|
|
200
|
+
@Inject(CurrencyService) private readonly _currencyService: CurrencyService;
|
|
201
|
+
@Inject(TranslateService) private readonly _translateService: TranslateService;
|
|
202
|
+
@Inject(UserFilterService) private readonly _userFilterService: UserFilterService;
|
|
203
|
+
@Inject(UserRoleService) private readonly _userRoleService: UserRoleService;
|
|
204
|
+
@Inject(UserRolePermissonService) private readonly _userRolePermissonService: UserRolePermissonService;
|
|
205
|
+
@Inject(UserService) private readonly _userService: UserService;
|
|
206
|
+
@Inject(VersionDataService) private readonly _versionDataService: VersionDataService;
|
|
207
|
+
@Inject(WidgetService) private readonly _widgetService: WidgetService;
|
|
208
|
+
@Inject(AuditLogService) private readonly _auditLogService: AuditLogService;
|
|
209
|
+
@Inject(PipelineService) private readonly _pipelineService: PipelineService;
|
|
210
|
+
@Inject(PipelineJobService) private readonly _pipelineJobService: PipelineJobService;
|
|
211
|
+
@Inject(PipelineLogService) private readonly _pipelineLogService: PipelineLogService;
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
private services: any = {};
|
|
215
|
+
|
|
216
|
+
constructor(private moduleRef: ModuleRef) { }
|
|
217
|
+
|
|
218
|
+
async onModuleInit() {
|
|
219
|
+
// console.log(CUSTOM_SERVICES);
|
|
220
|
+
for (const key of Object.keys(CUSTOM_SERVICES)) {
|
|
221
|
+
this.services[key] = await this.moduleRef.get(CUSTOM_SERVICES[key], {
|
|
222
|
+
strict: false
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
private async _getService(entityName: string): Promise<any> {
|
|
228
|
+
switch (entityName) {
|
|
229
|
+
case "activity_log":
|
|
230
|
+
return this._activityLogService;
|
|
231
|
+
case "address":
|
|
232
|
+
return this._addressService;
|
|
233
|
+
case "api_key":
|
|
234
|
+
return this._apiKeyService;
|
|
235
|
+
case "attachment":
|
|
236
|
+
return this._attachmentService;
|
|
237
|
+
case "comment_data":
|
|
238
|
+
return this._commentDataService;
|
|
239
|
+
case "country":
|
|
240
|
+
return this._countryService;
|
|
241
|
+
case "company":
|
|
242
|
+
return this._companyService;
|
|
243
|
+
case "custom_function":
|
|
244
|
+
return this._customFunctionService;
|
|
245
|
+
case "deploy_destination":
|
|
246
|
+
return this._deployDestinationService;
|
|
247
|
+
case "deploy_package":
|
|
248
|
+
return this._deployPackageService;
|
|
249
|
+
case "deploy_log":
|
|
250
|
+
return this._deployLogService;
|
|
251
|
+
case "district":
|
|
252
|
+
return this._districtService;
|
|
253
|
+
case "execution_log":
|
|
254
|
+
return this._executionLogService;
|
|
255
|
+
case "import_export":
|
|
256
|
+
return this._importExportService;
|
|
257
|
+
case "import_export_log":
|
|
258
|
+
return this._importExportLogService;
|
|
259
|
+
case "language":
|
|
260
|
+
return this._languageService;
|
|
261
|
+
case "layout_share_widget":
|
|
262
|
+
return this._layoutShareWidgetService;
|
|
263
|
+
case "mail_setting":
|
|
264
|
+
return this._mailService;
|
|
265
|
+
case "mail_log":
|
|
266
|
+
return this._mailLogService;
|
|
267
|
+
case "map_location":
|
|
268
|
+
return this._mapLocationService;
|
|
269
|
+
case "notification_subscription":
|
|
270
|
+
return this._notificationSubscriptionService;
|
|
271
|
+
case "notification_message":
|
|
272
|
+
return this._notificationMessageService;
|
|
273
|
+
case "notification_message_queue":
|
|
274
|
+
return this._notificationMessageQueueService;
|
|
275
|
+
case "notification_log":
|
|
276
|
+
return this._notificationLogService;
|
|
277
|
+
case "pipeline":
|
|
278
|
+
return this._pipelineService;
|
|
279
|
+
case "pipeline_job":
|
|
280
|
+
return this._pipelineJobService;
|
|
281
|
+
case "pipeline_log":
|
|
282
|
+
return this._pipelineLogService;
|
|
283
|
+
case "province":
|
|
284
|
+
return this._provinceService;
|
|
285
|
+
case "reason_data":
|
|
286
|
+
return this._reasonDataService;
|
|
287
|
+
case "reason_master":
|
|
288
|
+
return this._reasonMasterService;
|
|
289
|
+
case "reason_option":
|
|
290
|
+
return this._reasonOptionService;
|
|
291
|
+
case "schedule_action":
|
|
292
|
+
return this._scheduleActionService;
|
|
293
|
+
case "schedule_log":
|
|
294
|
+
return this._scheduleLogService;
|
|
295
|
+
case "shortly_url":
|
|
296
|
+
return this._shortlyUrlService;
|
|
297
|
+
case "sms":
|
|
298
|
+
return this._smsService;
|
|
299
|
+
case "sms_log":
|
|
300
|
+
return this._smsLogService;
|
|
301
|
+
case "print_log":
|
|
302
|
+
return this._printLogService;
|
|
303
|
+
case "subdistrict":
|
|
304
|
+
return this._subdistrictService;
|
|
305
|
+
case "template":
|
|
306
|
+
return this._templateService;
|
|
307
|
+
case "time_zone":
|
|
308
|
+
return this._timeZoneService;
|
|
309
|
+
case "currency":
|
|
310
|
+
return this._currencyService;
|
|
311
|
+
case "translate":
|
|
312
|
+
return this._translateService;
|
|
313
|
+
case "user":
|
|
314
|
+
return this._userService;
|
|
315
|
+
case "user_role":
|
|
316
|
+
return this._userRoleService;
|
|
317
|
+
case "user_role_permission":
|
|
318
|
+
return this._userRolePermissonService;
|
|
319
|
+
case "user_filter":
|
|
320
|
+
return this._userFilterService;
|
|
321
|
+
case "version_data":
|
|
322
|
+
return this._versionDataService;
|
|
323
|
+
case "widget":
|
|
324
|
+
return this._widgetService;
|
|
325
|
+
case "audit_log":
|
|
326
|
+
return this._auditLogService;
|
|
327
|
+
|
|
328
|
+
default:
|
|
329
|
+
const customService = this.services[entityName];
|
|
330
|
+
if (_.isEmpty(customService)) {
|
|
331
|
+
throw new Error(`Invalid entity ${entityName}.`);
|
|
332
|
+
}
|
|
333
|
+
return customService;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
public async init(entityName: string): Promise<string> {
|
|
338
|
+
const service = await this._getService(entityName);
|
|
339
|
+
return service.init();
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
public async initData(entityName: string): Promise<void> {
|
|
343
|
+
const service = await this._getService(entityName);
|
|
344
|
+
await service.initData();
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
public async search(
|
|
348
|
+
entityName: string,
|
|
349
|
+
keywords: string,
|
|
350
|
+
filters?: any,
|
|
351
|
+
page: number = 1,
|
|
352
|
+
pageSize: number = 10,
|
|
353
|
+
sort: string = "",
|
|
354
|
+
grouping?: Array<string>,
|
|
355
|
+
noTranslate?: boolean,
|
|
356
|
+
fields?: Array<string>
|
|
357
|
+
): Promise<SearchResultDto> {
|
|
358
|
+
const service = await this._getService(entityName);
|
|
359
|
+
return service.search(
|
|
360
|
+
keywords,
|
|
361
|
+
filters,
|
|
362
|
+
page,
|
|
363
|
+
pageSize,
|
|
364
|
+
sort,
|
|
365
|
+
grouping,
|
|
366
|
+
noTranslate,
|
|
367
|
+
fields
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
public async searchIds(
|
|
372
|
+
entityName: string,
|
|
373
|
+
keywords: string,
|
|
374
|
+
filters?: any,
|
|
375
|
+
page?: number,
|
|
376
|
+
pagesize?: number,
|
|
377
|
+
sort?: Object
|
|
378
|
+
): Promise<Array<string>> {
|
|
379
|
+
const service = await this._getService(entityName);
|
|
380
|
+
return service.searchIds(keywords, filters, page, pagesize, sort);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
public async searchWithLayout(
|
|
384
|
+
entityName: string,
|
|
385
|
+
layoutCode: string,
|
|
386
|
+
keywords: string,
|
|
387
|
+
filters?: any,
|
|
388
|
+
page?: number,
|
|
389
|
+
pageSize?: number,
|
|
390
|
+
sort?: any,
|
|
391
|
+
grouping?: Array<string>,
|
|
392
|
+
isDetail?: boolean
|
|
393
|
+
): Promise<SearchResultDto> {
|
|
394
|
+
const service = await this._getService(entityName);
|
|
395
|
+
return service.searchWithLayout(
|
|
396
|
+
layoutCode,
|
|
397
|
+
keywords,
|
|
398
|
+
filters,
|
|
399
|
+
page,
|
|
400
|
+
pageSize,
|
|
401
|
+
sort,
|
|
402
|
+
grouping,
|
|
403
|
+
isDetail
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
public async find(
|
|
408
|
+
entityName: string,
|
|
409
|
+
keywords: string,
|
|
410
|
+
filters?: any,
|
|
411
|
+
sort: string = "",
|
|
412
|
+
noTranslate?: boolean,
|
|
413
|
+
fields?: Array<string>
|
|
414
|
+
): Promise<any> {
|
|
415
|
+
const service = await this._getService(entityName);
|
|
416
|
+
return service.find(keywords, filters, sort, noTranslate, fields);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
public async findWithLayout(
|
|
420
|
+
entityName: string,
|
|
421
|
+
layoutCode: string,
|
|
422
|
+
keywords: string,
|
|
423
|
+
filters?: any,
|
|
424
|
+
sort?: Object
|
|
425
|
+
): Promise<any> {
|
|
426
|
+
const service = await this._getService(entityName);
|
|
427
|
+
return service.findWithLayout(layoutCode, keywords, filters, sort);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
public async findOne(
|
|
431
|
+
entityName: string,
|
|
432
|
+
id: string,
|
|
433
|
+
fields?: Array<string>
|
|
434
|
+
): Promise<any> {
|
|
435
|
+
const service = await this._getService(entityName);
|
|
436
|
+
return service.findOne(id, fields);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
public async findOneWithLayout(
|
|
440
|
+
entityName: string,
|
|
441
|
+
layoutCode: string,
|
|
442
|
+
id: string
|
|
443
|
+
): Promise<any> {
|
|
444
|
+
const service = await this._getService(entityName);
|
|
445
|
+
return service.findOneWithLayout(layoutCode, id);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
public async count(
|
|
449
|
+
entityName: string,
|
|
450
|
+
filters?: any,
|
|
451
|
+
keywords?: string
|
|
452
|
+
): Promise<number> {
|
|
453
|
+
const service = await this._getService(entityName);
|
|
454
|
+
return service.count(filters, keywords);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
public async aggregate(entityName: string, query: string): Promise<any> {
|
|
458
|
+
const service = await this._getService(entityName);
|
|
459
|
+
return service.aggregate(query);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
public async create(entityName: string, data: any): Promise<any> {
|
|
463
|
+
const service = await this._getService(entityName);
|
|
464
|
+
return service.create(data);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
public async update(entityName: string, id: string, data: any): Promise<any> {
|
|
468
|
+
const service = await this._getService(entityName);
|
|
469
|
+
return service.update(id, data);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
public async delete(entityName: string, id: string): Promise<any> {
|
|
473
|
+
const service = await this._getService(entityName);
|
|
474
|
+
return service.delete(id);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
public async deleteMany(entityName: string, filter: any): Promise<any> {
|
|
478
|
+
const service = await this._getService(entityName);
|
|
479
|
+
return service.deleteMany(filter);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
public async bulkCreate(entityName: string, data: any[]): Promise<any> {
|
|
483
|
+
const service = await this._getService(entityName);
|
|
484
|
+
return service.bulkCreate(data);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
public async bulkUpdate(entityName: string, data: any[]): Promise<any> {
|
|
488
|
+
const service = await this._getService(entityName);
|
|
489
|
+
return service.bulkUpdate(data);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
public async bulkDelete(entityName: string, ids: string[]): Promise<any> {
|
|
493
|
+
const service = await this._getService(entityName);
|
|
494
|
+
return service.bulkDelete(ids);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
public async prepareGenerateData(
|
|
498
|
+
entityName: string,
|
|
499
|
+
data?: any
|
|
500
|
+
): Promise<any> {
|
|
501
|
+
const service = await this._getService(entityName);
|
|
502
|
+
return service.prepareGenerateData(data);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
public async generateData(entityName: string, data?: any): Promise<boolean> {
|
|
506
|
+
const service = await this._getService(entityName);
|
|
507
|
+
return service.generateData(data);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
public async progressGenerateData(
|
|
511
|
+
entityName: string,
|
|
512
|
+
ref_id: string
|
|
513
|
+
): Promise<any> {
|
|
514
|
+
const service = await this._getService(entityName);
|
|
515
|
+
return service.progressGenerateData(ref_id);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
public async approve(
|
|
519
|
+
entityName: string,
|
|
520
|
+
id: string,
|
|
521
|
+
data: any
|
|
522
|
+
): Promise<any> {
|
|
523
|
+
const service = await this._getService(entityName);
|
|
524
|
+
return service.approve(id, data);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
public async workflowActions(entityName: string, id: string): Promise<any> {
|
|
528
|
+
const service = await this._getService(entityName);
|
|
529
|
+
return service.workflowActions(id);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
public async executeWorkflowAction(
|
|
533
|
+
entityName: string,
|
|
534
|
+
id: string,
|
|
535
|
+
body: any
|
|
536
|
+
): Promise<any> {
|
|
537
|
+
const service = await this._getService(entityName);
|
|
538
|
+
return service.executeWorkflowAction(id, body);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
public async dataWithLocale(
|
|
542
|
+
entityName: string,
|
|
543
|
+
layout: string,
|
|
544
|
+
id: string,
|
|
545
|
+
locale: string
|
|
546
|
+
): Promise<any> {
|
|
547
|
+
const service = await this._getService(entityName);
|
|
548
|
+
return service.dataWithLocale(layout, id, locale);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
public async findWithLocale(
|
|
552
|
+
entityName: string,
|
|
553
|
+
locale: string,
|
|
554
|
+
keywords: string,
|
|
555
|
+
filters?: any,
|
|
556
|
+
sort?: Object
|
|
557
|
+
): Promise<any> {
|
|
558
|
+
const service = await this._getService(entityName);
|
|
559
|
+
return service.findWithLocale(locale, keywords, filters, sort);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
public async setDataLocale(
|
|
563
|
+
entityName: string,
|
|
564
|
+
id: string,
|
|
565
|
+
locale: string,
|
|
566
|
+
data: any
|
|
567
|
+
): Promise<any> {
|
|
568
|
+
const service = await this._getService(entityName);
|
|
569
|
+
return service.setDataLocale(id, locale, data);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
public async exampleOutputMapping(
|
|
573
|
+
entityName: string,
|
|
574
|
+
data: any
|
|
575
|
+
): Promise<any> {
|
|
576
|
+
const service = await this._getService(entityName);
|
|
577
|
+
return service.exampleOutputMapping(data);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
public async searchText(entityName: string, data: any): Promise<any> {
|
|
581
|
+
const service = await this._getService(entityName);
|
|
582
|
+
return service.searchText(data);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
public async importValidate(
|
|
586
|
+
entityName: string,
|
|
587
|
+
id: string,
|
|
588
|
+
code: string,
|
|
589
|
+
data: any,
|
|
590
|
+
dataText: string,
|
|
591
|
+
originalData,
|
|
592
|
+
filename
|
|
593
|
+
): Promise<any> {
|
|
594
|
+
const service = await this._getService(entityName);
|
|
595
|
+
return service.importValidate(
|
|
596
|
+
id,
|
|
597
|
+
code,
|
|
598
|
+
data,
|
|
599
|
+
dataText,
|
|
600
|
+
originalData,
|
|
601
|
+
filename
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
@Injectable()
|
|
607
|
+
export class CoreLogService implements OnModuleInit {
|
|
608
|
+
@Inject(ActivityLogService)
|
|
609
|
+
private readonly _activityLogService: ActivityLogService;
|
|
610
|
+
@Inject(DeployLogService)
|
|
611
|
+
private readonly _deployLogService: DeployLogService;
|
|
612
|
+
@Inject(ExecutionLogService)
|
|
613
|
+
private readonly _executionLogService: ExecutionLogService;
|
|
614
|
+
@Inject(ImportExportLogService)
|
|
615
|
+
private readonly _importExportLogService: ImportExportLogService;
|
|
616
|
+
@Inject(PrintLogService)
|
|
617
|
+
private readonly _printLogService: PrintLogService;
|
|
618
|
+
@Inject(MailLogService)
|
|
619
|
+
private readonly _mailLogService: MailLogService;
|
|
620
|
+
@Inject(NotificationLogService)
|
|
621
|
+
private readonly _notificationLogService: NotificationLogService;
|
|
622
|
+
@Inject(ScheduleLogService)
|
|
623
|
+
private readonly _scheduleLogService: ScheduleLogService;
|
|
624
|
+
@Inject(SmsLogService)
|
|
625
|
+
private readonly _smsLogService: SmsLogService;
|
|
626
|
+
@Inject(AuditLogService)
|
|
627
|
+
private readonly _auditLogService: AuditLogService;
|
|
628
|
+
@Inject(PipelineLogService)
|
|
629
|
+
private readonly _pipelineLogService: PipelineLogService;
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
private services: any = {};
|
|
633
|
+
|
|
634
|
+
constructor(private moduleRef: ModuleRef) { }
|
|
635
|
+
|
|
636
|
+
private _getService(entityName: string): any {
|
|
637
|
+
switch (entityName) {
|
|
638
|
+
case "deploy_log":
|
|
639
|
+
return this._deployLogService;
|
|
640
|
+
case "schedule_log":
|
|
641
|
+
return this._scheduleLogService;
|
|
642
|
+
case "activity_log":
|
|
643
|
+
return this._activityLogService;
|
|
644
|
+
case "import_export_log":
|
|
645
|
+
return this._importExportLogService;
|
|
646
|
+
case "mail_log":
|
|
647
|
+
return this._mailLogService;
|
|
648
|
+
case "sms_log":
|
|
649
|
+
return this._smsLogService;
|
|
650
|
+
case "print_log":
|
|
651
|
+
return this._printLogService;
|
|
652
|
+
case "execution_log":
|
|
653
|
+
return this._executionLogService;
|
|
654
|
+
case "notification_log":
|
|
655
|
+
return this._notificationLogService;
|
|
656
|
+
case "audit_log":
|
|
657
|
+
return this._auditLogService;
|
|
658
|
+
case "pipeline_log":
|
|
659
|
+
return this._pipelineLogService;
|
|
660
|
+
default:
|
|
661
|
+
const customService = this.services[entityName];
|
|
662
|
+
if (_.isEmpty(customService)) {
|
|
663
|
+
throw new Error(`Invalid entity ${entityName}.`);
|
|
664
|
+
}
|
|
665
|
+
return customService;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
async onModuleInit() {
|
|
670
|
+
// console.log(CUSTOM_LOG_SERVICES);
|
|
671
|
+
for (const key of Object.keys(CUSTOM_LOG_SERVICES)) {
|
|
672
|
+
this.services[key] = await this.moduleRef.get(CUSTOM_LOG_SERVICES[key], {
|
|
673
|
+
strict: false
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
public async purgeLog(entityName: string, setting: any) {
|
|
679
|
+
const service = await this._getService(entityName);
|
|
680
|
+
return service.purgeLog(setting);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
@Injectable()
|
|
685
|
+
export class CoreSettingService implements OnModuleInit {
|
|
686
|
+
private services: any = {};
|
|
687
|
+
|
|
688
|
+
constructor(private moduleRef: ModuleRef) { }
|
|
689
|
+
|
|
690
|
+
private _getService(entityName: string): IBaseModuleSettingService {
|
|
691
|
+
switch (entityName) {
|
|
692
|
+
default:
|
|
693
|
+
const customService = this.services[entityName];
|
|
694
|
+
if (_.isEmpty(customService)) {
|
|
695
|
+
throw new Error(`Invalid entity ${entityName}.`);
|
|
696
|
+
}
|
|
697
|
+
return customService;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
async onModuleInit() {
|
|
702
|
+
// console.log(CUSTOM_SETTING_SERVICES);
|
|
703
|
+
for (const key of Object.keys(CUSTOM_SETTING_SERVICES)) {
|
|
704
|
+
this.services[key] = await this.moduleRef.get(
|
|
705
|
+
CUSTOM_SETTING_SERVICES[key],
|
|
706
|
+
{
|
|
707
|
+
strict: false
|
|
708
|
+
}
|
|
709
|
+
);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
public async getSetting(entityName: string, key?: string): Promise<any> {
|
|
714
|
+
const service = await this._getService(entityName);
|
|
715
|
+
return service.getSetting(key);
|
|
716
|
+
}
|
|
717
|
+
public async setSetting(
|
|
718
|
+
entityName: string,
|
|
719
|
+
data: any,
|
|
720
|
+
key?: string
|
|
721
|
+
): Promise<any> {
|
|
722
|
+
const service = await this._getService(entityName);
|
|
723
|
+
return service.setSetting(data, key);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
public async defaultPermission(entityName: string): Promise<any> {
|
|
727
|
+
const service = await this._getService(entityName);
|
|
728
|
+
return service.defaultPermission();
|
|
729
|
+
}
|
|
730
|
+
public async setPermission(
|
|
731
|
+
entityName: string,
|
|
732
|
+
permissoin: any
|
|
733
|
+
): Promise<any> {
|
|
734
|
+
const service = await this._getService(entityName);
|
|
735
|
+
return service.setPermission(permissoin);
|
|
736
|
+
}
|
|
737
|
+
}
|