cc-core-cli 1.0.136 → 1.0.138
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
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"sonar:coverage": "jest --coverage --coverageReporters=lcov --coverageDirectory=coverage"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@shopstack/cc-core-lib": "
|
|
26
|
+
"@shopstack/cc-core-lib": "2.5.328",
|
|
27
27
|
"reflect-metadata": "^0.1.14"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as _ from "lodash";
|
|
2
|
-
import {
|
|
3
|
-
Module,
|
|
4
|
-
} from "@nestjs/common";
|
|
2
|
+
import { Module } from "@nestjs/common";
|
|
5
3
|
import { MongooseModule } from "@nestjs/mongoose";
|
|
6
4
|
import { ClsModule } from "nestjs-cls";
|
|
7
5
|
import * as dotenv from "dotenv";
|
|
@@ -41,25 +39,21 @@ import {
|
|
|
41
39
|
CustomFunctionModule,
|
|
42
40
|
CacheModule,
|
|
43
41
|
PipelineModule,
|
|
44
|
-
RewriteUrlModule
|
|
45
|
-
|
|
42
|
+
RewriteUrlModule,
|
|
43
|
+
SearchTextModule,
|
|
44
|
+
} from "@shopstack/cc-core-lib/core";
|
|
46
45
|
|
|
47
|
-
import { CoreModule } from
|
|
46
|
+
import { CoreModule } from "./core/core.module";
|
|
48
47
|
|
|
49
48
|
// const { CoreModule } = core
|
|
50
49
|
|
|
51
50
|
dotenv.config();
|
|
52
51
|
|
|
53
|
-
const SPECIFY_CUSTOM_MODULES =
|
|
54
|
-
process.env.CUSTOM_MODULES === "" || process.env.CUSTOM_MODULES === undefined
|
|
55
|
-
? []
|
|
56
|
-
: process.env.CUSTOM_MODULES.split(",");
|
|
52
|
+
const SPECIFY_CUSTOM_MODULES = process.env.CUSTOM_MODULES === "" || process.env.CUSTOM_MODULES === undefined ? [] : process.env.CUSTOM_MODULES.split(",");
|
|
57
53
|
const RUN_CUSTOM_MODULES =
|
|
58
54
|
SPECIFY_CUSTOM_MODULES.length === 0
|
|
59
|
-
? CUSTOM_MODULES.map(c => c.module)
|
|
60
|
-
: CUSTOM_MODULES.filter(c =>
|
|
61
|
-
SPECIFY_CUSTOM_MODULES.includes(c.module.name)
|
|
62
|
-
).map(c => c.module);
|
|
55
|
+
? CUSTOM_MODULES.map((c) => c.module)
|
|
56
|
+
: CUSTOM_MODULES.filter((c) => SPECIFY_CUSTOM_MODULES.includes(c.module.name)).map((c) => c.module);
|
|
63
57
|
|
|
64
58
|
const mongoConfig = {};
|
|
65
59
|
|
|
@@ -103,9 +97,9 @@ if (+process.env.MONGODB_MAX_POOL_SIZE) {
|
|
|
103
97
|
body: _.get(req, "body", {}),
|
|
104
98
|
action_profile: _.get(req, "action_profile", {}),
|
|
105
99
|
permisson_entities: _.get(req, "permisson_entities", {}),
|
|
106
|
-
permisson_tab: _.get(req, "permisson_tab", {})
|
|
100
|
+
permisson_tab: _.get(req, "permisson_tab", {}),
|
|
107
101
|
});
|
|
108
|
-
}
|
|
102
|
+
},
|
|
109
103
|
},
|
|
110
104
|
interceptor: {
|
|
111
105
|
mount: true,
|
|
@@ -118,9 +112,7 @@ if (+process.env.MONGODB_MAX_POOL_SIZE) {
|
|
|
118
112
|
roles: _.get(req, "roles", []),
|
|
119
113
|
headers: _.get(req, "headers", {}),
|
|
120
114
|
// ip: req.connection.remoteAddress,
|
|
121
|
-
ip:
|
|
122
|
-
_.get(req, "socket.remoteAddress") ||
|
|
123
|
-
_.get(req, "connection.remoteAddress"),
|
|
115
|
+
ip: _.get(req, "socket.remoteAddress") || _.get(req, "connection.remoteAddress"),
|
|
124
116
|
protocol: _.get(req, "protocol"),
|
|
125
117
|
hostname: _.get(req, "hostname"),
|
|
126
118
|
url: _.get(req, "url"),
|
|
@@ -128,10 +120,10 @@ if (+process.env.MONGODB_MAX_POOL_SIZE) {
|
|
|
128
120
|
body: _.get(req, "body", {}),
|
|
129
121
|
action_profile: _.get(req, "action_profile", {}),
|
|
130
122
|
permisson_entities: _.get(req, "permisson_entities", {}),
|
|
131
|
-
permisson_tab: _.get(req, "permisson_tab", {})
|
|
123
|
+
permisson_tab: _.get(req, "permisson_tab", {}),
|
|
132
124
|
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
125
|
+
},
|
|
126
|
+
},
|
|
135
127
|
}),
|
|
136
128
|
|
|
137
129
|
EntitiesModule,
|
|
@@ -163,12 +155,13 @@ if (+process.env.MONGODB_MAX_POOL_SIZE) {
|
|
|
163
155
|
PipelineModule,
|
|
164
156
|
LayoutModule,
|
|
165
157
|
RewriteUrlModule,
|
|
158
|
+
SearchTextModule,
|
|
166
159
|
|
|
167
160
|
// ...RUN_CUSTOM_MODULES,
|
|
168
161
|
|
|
169
|
-
CoreModule
|
|
162
|
+
CoreModule,
|
|
170
163
|
],
|
|
171
164
|
controllers: [AppController, StoragePrivateController],
|
|
172
|
-
providers: [AppService]
|
|
165
|
+
providers: [AppService],
|
|
173
166
|
})
|
|
174
|
-
export class AppModule {
|
|
167
|
+
export class AppModule {}
|
|
@@ -3,11 +3,7 @@ import * as _ from "lodash";
|
|
|
3
3
|
import { Module } from "@nestjs/common";
|
|
4
4
|
import { CUSTOM_MODULES } from "src/modules/modules";
|
|
5
5
|
import { CoreController } from "./core.controller";
|
|
6
|
-
import {
|
|
7
|
-
CoreLogService,
|
|
8
|
-
CoreService,
|
|
9
|
-
CoreSettingService
|
|
10
|
-
} from "./core.service";
|
|
6
|
+
import { CoreLogService, CoreService, CoreSettingService } from "./core.service";
|
|
11
7
|
import {
|
|
12
8
|
EntitiesModule,
|
|
13
9
|
ActivityLogModule,
|
|
@@ -36,20 +32,16 @@ import {
|
|
|
36
32
|
WidgetModule,
|
|
37
33
|
LayoutModule,
|
|
38
34
|
AuditLogModule,
|
|
39
|
-
PipelineModule
|
|
40
|
-
|
|
35
|
+
PipelineModule,
|
|
36
|
+
SearchTextModule,
|
|
37
|
+
} from "@shopstack/cc-core-lib/core";
|
|
41
38
|
|
|
42
|
-
const SPECIFY_CUSTOM_MODULES =
|
|
43
|
-
process.env.CUSTOM_MODULES === "" || process.env.CUSTOM_MODULES === undefined
|
|
44
|
-
? []
|
|
45
|
-
: process.env.CUSTOM_MODULES.split(",");
|
|
39
|
+
const SPECIFY_CUSTOM_MODULES = process.env.CUSTOM_MODULES === "" || process.env.CUSTOM_MODULES === undefined ? [] : process.env.CUSTOM_MODULES.split(",");
|
|
46
40
|
|
|
47
41
|
const RUN_CUSTOM_MODULES =
|
|
48
42
|
SPECIFY_CUSTOM_MODULES.length === 0
|
|
49
|
-
? CUSTOM_MODULES.map(c => c.module)
|
|
50
|
-
: CUSTOM_MODULES.filter(c =>
|
|
51
|
-
SPECIFY_CUSTOM_MODULES.includes(c.module.name)
|
|
52
|
-
).map(c => c.module);
|
|
43
|
+
? CUSTOM_MODULES.map((c) => c.module)
|
|
44
|
+
: CUSTOM_MODULES.filter((c) => SPECIFY_CUSTOM_MODULES.includes(c.module.name)).map((c) => c.module);
|
|
53
45
|
|
|
54
46
|
@Module({
|
|
55
47
|
imports: [
|
|
@@ -81,10 +73,10 @@ const RUN_CUSTOM_MODULES =
|
|
|
81
73
|
WidgetModule,
|
|
82
74
|
PipelineModule,
|
|
83
75
|
LayoutModule,
|
|
84
|
-
|
|
85
|
-
...RUN_CUSTOM_MODULES
|
|
76
|
+
SearchTextModule,
|
|
77
|
+
...RUN_CUSTOM_MODULES,
|
|
86
78
|
],
|
|
87
79
|
controllers: [CoreController],
|
|
88
|
-
providers: [CoreService, CoreLogService, CoreSettingService]
|
|
80
|
+
providers: [CoreService, CoreLogService, CoreSettingService],
|
|
89
81
|
})
|
|
90
|
-
export class CoreModule {
|
|
82
|
+
export class CoreModule {}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import * as _ from "lodash";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
Inject,
|
|
5
|
-
Injectable,
|
|
6
|
-
OnModuleInit,
|
|
7
|
-
} from "@nestjs/common";
|
|
3
|
+
import { Inject, Injectable, OnModuleInit } from "@nestjs/common";
|
|
8
4
|
import { ModuleRef } from "@nestjs/core";
|
|
9
5
|
|
|
10
|
-
|
|
11
6
|
import { CUSTOM_MODULES } from "src/modules/modules";
|
|
12
7
|
|
|
13
8
|
import {
|
|
@@ -62,35 +57,24 @@ import {
|
|
|
62
57
|
PipelineJobService,
|
|
63
58
|
PipelineLogService,
|
|
64
59
|
PrintLogService,
|
|
65
|
-
|
|
60
|
+
SearchTextService,
|
|
61
|
+
} from "@shopstack/cc-core-lib/core";
|
|
66
62
|
|
|
67
|
-
const SPECIFY_CUSTOM_MODULES =
|
|
68
|
-
process.env.CUSTOM_MODULES === "" || process.env.CUSTOM_MODULES === undefined
|
|
69
|
-
? []
|
|
70
|
-
: process.env.CUSTOM_MODULES.split(",");
|
|
63
|
+
const SPECIFY_CUSTOM_MODULES = process.env.CUSTOM_MODULES === "" || process.env.CUSTOM_MODULES === undefined ? [] : process.env.CUSTOM_MODULES.split(",");
|
|
71
64
|
|
|
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
|
-
);
|
|
65
|
+
const RUN_CUSTOM_MODULES = SPECIFY_CUSTOM_MODULES.length === 0 ? CUSTOM_MODULES : CUSTOM_MODULES.filter((c) => SPECIFY_CUSTOM_MODULES.includes(c.module.name));
|
|
78
66
|
|
|
79
67
|
const CUSTOM_SERVICES = _.reduce(
|
|
80
68
|
RUN_CUSTOM_MODULES,
|
|
81
69
|
(r, v) => {
|
|
82
|
-
const moduleName = _.snakeCase(
|
|
83
|
-
`${v.module.name.slice(0, 2).toLowerCase()}${v.module.name.slice(2)}`
|
|
84
|
-
)
|
|
70
|
+
const moduleName = _.snakeCase(`${v.module.name.slice(0, 2).toLowerCase()}${v.module.name.slice(2)}`)
|
|
85
71
|
.replace(/_[0-9]*_/g, (m, g1, g2, i) => {
|
|
86
72
|
return m.slice(1);
|
|
87
73
|
})
|
|
88
74
|
.toLowerCase()
|
|
89
75
|
.replace("_module", "");
|
|
90
76
|
for (const service of v.services || []) {
|
|
91
|
-
const serviceName = `${service.name
|
|
92
|
-
.slice(0, 2)
|
|
93
|
-
.toLowerCase()}${service.name.slice(2)}`;
|
|
77
|
+
const serviceName = `${service.name.slice(0, 2).toLowerCase()}${service.name.slice(2)}`;
|
|
94
78
|
let key = `${moduleName}_${_.snakeCase(serviceName)
|
|
95
79
|
.replace(/_[0-9]*_/g, (m, g1, g2, i) => {
|
|
96
80
|
return m.slice(1);
|
|
@@ -111,15 +95,11 @@ const CUSTOM_SERVICES = _.reduce(
|
|
|
111
95
|
const CUSTOM_LOG_SERVICES = _.reduce(
|
|
112
96
|
RUN_CUSTOM_MODULES,
|
|
113
97
|
(r, v) => {
|
|
114
|
-
const moduleName = _.snakeCase(
|
|
115
|
-
`${v.module.name.slice(0, 2).toLowerCase()}${v.module.name.slice(2)}`
|
|
116
|
-
)
|
|
98
|
+
const moduleName = _.snakeCase(`${v.module.name.slice(0, 2).toLowerCase()}${v.module.name.slice(2)}`)
|
|
117
99
|
.toLowerCase()
|
|
118
100
|
.replace("_module", "");
|
|
119
101
|
for (const service of v.services || []) {
|
|
120
|
-
const serviceName = _.snakeCase(
|
|
121
|
-
`${service.name.slice(0, 2).toLowerCase()}${service.name.slice(2)}`
|
|
122
|
-
)
|
|
102
|
+
const serviceName = _.snakeCase(`${service.name.slice(0, 2).toLowerCase()}${service.name.slice(2)}`)
|
|
123
103
|
.toLowerCase()
|
|
124
104
|
.replace("_service", "")
|
|
125
105
|
.replace(`${moduleName}_`, "");
|
|
@@ -136,15 +116,11 @@ const CUSTOM_LOG_SERVICES = _.reduce(
|
|
|
136
116
|
const CUSTOM_SETTING_SERVICES = _.reduce(
|
|
137
117
|
RUN_CUSTOM_MODULES,
|
|
138
118
|
(r, v) => {
|
|
139
|
-
const moduleName = _.snakeCase(
|
|
140
|
-
`${v.module.name.slice(0, 2).toLowerCase()}${v.module.name.slice(2)}`
|
|
141
|
-
)
|
|
119
|
+
const moduleName = _.snakeCase(`${v.module.name.slice(0, 2).toLowerCase()}${v.module.name.slice(2)}`)
|
|
142
120
|
.toLowerCase()
|
|
143
121
|
.replace("_module", "");
|
|
144
122
|
for (const service of v.services || []) {
|
|
145
|
-
const serviceName = _.snakeCase(
|
|
146
|
-
`${service.name.slice(0, 2).toLowerCase()}${service.name.slice(2)}`
|
|
147
|
-
)
|
|
123
|
+
const serviceName = _.snakeCase(`${service.name.slice(0, 2).toLowerCase()}${service.name.slice(2)}`)
|
|
148
124
|
.toLowerCase()
|
|
149
125
|
.replace("_service", "")
|
|
150
126
|
.replace(`${moduleName}_`, "");
|
|
@@ -209,17 +185,16 @@ export class CoreService implements OnModuleInit {
|
|
|
209
185
|
@Inject(PipelineService) private readonly _pipelineService: PipelineService;
|
|
210
186
|
@Inject(PipelineJobService) private readonly _pipelineJobService: PipelineJobService;
|
|
211
187
|
@Inject(PipelineLogService) private readonly _pipelineLogService: PipelineLogService;
|
|
212
|
-
|
|
213
|
-
|
|
188
|
+
@Inject(SearchTextService) private readonly _searchTextService: SearchTextService;
|
|
214
189
|
private services: any = {};
|
|
215
190
|
|
|
216
|
-
constructor(private moduleRef: ModuleRef) {
|
|
191
|
+
constructor(private moduleRef: ModuleRef) {}
|
|
217
192
|
|
|
218
193
|
async onModuleInit() {
|
|
219
194
|
// console.log(CUSTOM_SERVICES);
|
|
220
195
|
for (const key of Object.keys(CUSTOM_SERVICES)) {
|
|
221
196
|
this.services[key] = await this.moduleRef.get(CUSTOM_SERVICES[key], {
|
|
222
|
-
strict: false
|
|
197
|
+
strict: false,
|
|
223
198
|
});
|
|
224
199
|
}
|
|
225
200
|
}
|
|
@@ -324,6 +299,8 @@ export class CoreService implements OnModuleInit {
|
|
|
324
299
|
return this._widgetService;
|
|
325
300
|
case "audit_log":
|
|
326
301
|
return this._auditLogService;
|
|
302
|
+
case "search_text":
|
|
303
|
+
return this._searchTextService;
|
|
327
304
|
|
|
328
305
|
default:
|
|
329
306
|
const customService = this.services[entityName];
|
|
@@ -356,26 +333,10 @@ export class CoreService implements OnModuleInit {
|
|
|
356
333
|
fields?: Array<string>
|
|
357
334
|
): Promise<SearchResultDto> {
|
|
358
335
|
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
|
-
);
|
|
336
|
+
return service.search(keywords, filters, page, pageSize, sort, grouping, noTranslate, fields);
|
|
369
337
|
}
|
|
370
338
|
|
|
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>> {
|
|
339
|
+
public async searchIds(entityName: string, keywords: string, filters?: any, page?: number, pagesize?: number, sort?: Object): Promise<Array<string>> {
|
|
379
340
|
const service = await this._getService(entityName);
|
|
380
341
|
return service.searchIds(keywords, filters, page, pagesize, sort);
|
|
381
342
|
}
|
|
@@ -392,64 +353,30 @@ export class CoreService implements OnModuleInit {
|
|
|
392
353
|
isDetail?: boolean
|
|
393
354
|
): Promise<SearchResultDto> {
|
|
394
355
|
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
|
-
);
|
|
356
|
+
return service.searchWithLayout(layoutCode, keywords, filters, page, pageSize, sort, grouping, isDetail);
|
|
405
357
|
}
|
|
406
358
|
|
|
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> {
|
|
359
|
+
public async find(entityName: string, keywords: string, filters?: any, sort: string = "", noTranslate?: boolean, fields?: Array<string>): Promise<any> {
|
|
415
360
|
const service = await this._getService(entityName);
|
|
416
361
|
return service.find(keywords, filters, sort, noTranslate, fields);
|
|
417
362
|
}
|
|
418
363
|
|
|
419
|
-
public async findWithLayout(
|
|
420
|
-
entityName: string,
|
|
421
|
-
layoutCode: string,
|
|
422
|
-
keywords: string,
|
|
423
|
-
filters?: any,
|
|
424
|
-
sort?: Object
|
|
425
|
-
): Promise<any> {
|
|
364
|
+
public async findWithLayout(entityName: string, layoutCode: string, keywords: string, filters?: any, sort?: Object): Promise<any> {
|
|
426
365
|
const service = await this._getService(entityName);
|
|
427
366
|
return service.findWithLayout(layoutCode, keywords, filters, sort);
|
|
428
367
|
}
|
|
429
368
|
|
|
430
|
-
public async findOne(
|
|
431
|
-
entityName: string,
|
|
432
|
-
id: string,
|
|
433
|
-
fields?: Array<string>
|
|
434
|
-
): Promise<any> {
|
|
369
|
+
public async findOne(entityName: string, id: string, fields?: Array<string>): Promise<any> {
|
|
435
370
|
const service = await this._getService(entityName);
|
|
436
371
|
return service.findOne(id, fields);
|
|
437
372
|
}
|
|
438
373
|
|
|
439
|
-
public async findOneWithLayout(
|
|
440
|
-
entityName: string,
|
|
441
|
-
layoutCode: string,
|
|
442
|
-
id: string
|
|
443
|
-
): Promise<any> {
|
|
374
|
+
public async findOneWithLayout(entityName: string, layoutCode: string, id: string): Promise<any> {
|
|
444
375
|
const service = await this._getService(entityName);
|
|
445
376
|
return service.findOneWithLayout(layoutCode, id);
|
|
446
377
|
}
|
|
447
378
|
|
|
448
|
-
public async count(
|
|
449
|
-
entityName: string,
|
|
450
|
-
filters?: any,
|
|
451
|
-
keywords?: string
|
|
452
|
-
): Promise<number> {
|
|
379
|
+
public async count(entityName: string, filters?: any, keywords?: string): Promise<number> {
|
|
453
380
|
const service = await this._getService(entityName);
|
|
454
381
|
return service.count(filters, keywords);
|
|
455
382
|
}
|
|
@@ -494,10 +421,7 @@ export class CoreService implements OnModuleInit {
|
|
|
494
421
|
return service.bulkDelete(ids);
|
|
495
422
|
}
|
|
496
423
|
|
|
497
|
-
public async prepareGenerateData(
|
|
498
|
-
entityName: string,
|
|
499
|
-
data?: any
|
|
500
|
-
): Promise<any> {
|
|
424
|
+
public async prepareGenerateData(entityName: string, data?: any): Promise<any> {
|
|
501
425
|
const service = await this._getService(entityName);
|
|
502
426
|
return service.prepareGenerateData(data);
|
|
503
427
|
}
|
|
@@ -507,19 +431,12 @@ export class CoreService implements OnModuleInit {
|
|
|
507
431
|
return service.generateData(data);
|
|
508
432
|
}
|
|
509
433
|
|
|
510
|
-
public async progressGenerateData(
|
|
511
|
-
entityName: string,
|
|
512
|
-
ref_id: string
|
|
513
|
-
): Promise<any> {
|
|
434
|
+
public async progressGenerateData(entityName: string, ref_id: string): Promise<any> {
|
|
514
435
|
const service = await this._getService(entityName);
|
|
515
436
|
return service.progressGenerateData(ref_id);
|
|
516
437
|
}
|
|
517
438
|
|
|
518
|
-
public async approve(
|
|
519
|
-
entityName: string,
|
|
520
|
-
id: string,
|
|
521
|
-
data: any
|
|
522
|
-
): Promise<any> {
|
|
439
|
+
public async approve(entityName: string, id: string, data: any): Promise<any> {
|
|
523
440
|
const service = await this._getService(entityName);
|
|
524
441
|
return service.approve(id, data);
|
|
525
442
|
}
|
|
@@ -529,50 +446,27 @@ export class CoreService implements OnModuleInit {
|
|
|
529
446
|
return service.workflowActions(id);
|
|
530
447
|
}
|
|
531
448
|
|
|
532
|
-
public async executeWorkflowAction(
|
|
533
|
-
entityName: string,
|
|
534
|
-
id: string,
|
|
535
|
-
body: any
|
|
536
|
-
): Promise<any> {
|
|
449
|
+
public async executeWorkflowAction(entityName: string, id: string, body: any): Promise<any> {
|
|
537
450
|
const service = await this._getService(entityName);
|
|
538
451
|
return service.executeWorkflowAction(id, body);
|
|
539
452
|
}
|
|
540
453
|
|
|
541
|
-
public async dataWithLocale(
|
|
542
|
-
entityName: string,
|
|
543
|
-
layout: string,
|
|
544
|
-
id: string,
|
|
545
|
-
locale: string
|
|
546
|
-
): Promise<any> {
|
|
454
|
+
public async dataWithLocale(entityName: string, layout: string, id: string, locale: string): Promise<any> {
|
|
547
455
|
const service = await this._getService(entityName);
|
|
548
456
|
return service.dataWithLocale(layout, id, locale);
|
|
549
457
|
}
|
|
550
458
|
|
|
551
|
-
public async findWithLocale(
|
|
552
|
-
entityName: string,
|
|
553
|
-
locale: string,
|
|
554
|
-
keywords: string,
|
|
555
|
-
filters?: any,
|
|
556
|
-
sort?: Object
|
|
557
|
-
): Promise<any> {
|
|
459
|
+
public async findWithLocale(entityName: string, locale: string, keywords: string, filters?: any, sort?: Object): Promise<any> {
|
|
558
460
|
const service = await this._getService(entityName);
|
|
559
461
|
return service.findWithLocale(locale, keywords, filters, sort);
|
|
560
462
|
}
|
|
561
463
|
|
|
562
|
-
public async setDataLocale(
|
|
563
|
-
entityName: string,
|
|
564
|
-
id: string,
|
|
565
|
-
locale: string,
|
|
566
|
-
data: any
|
|
567
|
-
): Promise<any> {
|
|
464
|
+
public async setDataLocale(entityName: string, id: string, locale: string, data: any): Promise<any> {
|
|
568
465
|
const service = await this._getService(entityName);
|
|
569
466
|
return service.setDataLocale(id, locale, data);
|
|
570
467
|
}
|
|
571
468
|
|
|
572
|
-
public async exampleOutputMapping(
|
|
573
|
-
entityName: string,
|
|
574
|
-
data: any
|
|
575
|
-
): Promise<any> {
|
|
469
|
+
public async exampleOutputMapping(entityName: string, data: any): Promise<any> {
|
|
576
470
|
const service = await this._getService(entityName);
|
|
577
471
|
return service.exampleOutputMapping(data);
|
|
578
472
|
}
|
|
@@ -582,24 +476,9 @@ export class CoreService implements OnModuleInit {
|
|
|
582
476
|
return service.searchText(data);
|
|
583
477
|
}
|
|
584
478
|
|
|
585
|
-
public async importValidate(
|
|
586
|
-
entityName
|
|
587
|
-
id
|
|
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
|
-
);
|
|
479
|
+
public async importValidate(entityName: string, id: string, code: string, data: any, dataText: string, originalData, filename): Promise<any> {
|
|
480
|
+
const service = await this._getService(entityName);
|
|
481
|
+
return service.importValidate(id, code, data, dataText, originalData, filename);
|
|
603
482
|
}
|
|
604
483
|
}
|
|
605
484
|
|
|
@@ -627,11 +506,11 @@ export class CoreLogService implements OnModuleInit {
|
|
|
627
506
|
private readonly _auditLogService: AuditLogService;
|
|
628
507
|
@Inject(PipelineLogService)
|
|
629
508
|
private readonly _pipelineLogService: PipelineLogService;
|
|
630
|
-
|
|
631
|
-
|
|
509
|
+
@Inject(SearchTextService)
|
|
510
|
+
private readonly _searchTextService: SearchTextService;
|
|
632
511
|
private services: any = {};
|
|
633
512
|
|
|
634
|
-
constructor(private moduleRef: ModuleRef) {
|
|
513
|
+
constructor(private moduleRef: ModuleRef) {}
|
|
635
514
|
|
|
636
515
|
private _getService(entityName: string): any {
|
|
637
516
|
switch (entityName) {
|
|
@@ -670,7 +549,7 @@ export class CoreLogService implements OnModuleInit {
|
|
|
670
549
|
// console.log(CUSTOM_LOG_SERVICES);
|
|
671
550
|
for (const key of Object.keys(CUSTOM_LOG_SERVICES)) {
|
|
672
551
|
this.services[key] = await this.moduleRef.get(CUSTOM_LOG_SERVICES[key], {
|
|
673
|
-
strict: false
|
|
552
|
+
strict: false,
|
|
674
553
|
});
|
|
675
554
|
}
|
|
676
555
|
}
|
|
@@ -685,7 +564,7 @@ export class CoreLogService implements OnModuleInit {
|
|
|
685
564
|
export class CoreSettingService implements OnModuleInit {
|
|
686
565
|
private services: any = {};
|
|
687
566
|
|
|
688
|
-
constructor(private moduleRef: ModuleRef) {
|
|
567
|
+
constructor(private moduleRef: ModuleRef) {}
|
|
689
568
|
|
|
690
569
|
private _getService(entityName: string): IBaseModuleSettingService {
|
|
691
570
|
switch (entityName) {
|
|
@@ -701,12 +580,9 @@ export class CoreSettingService implements OnModuleInit {
|
|
|
701
580
|
async onModuleInit() {
|
|
702
581
|
// console.log(CUSTOM_SETTING_SERVICES);
|
|
703
582
|
for (const key of Object.keys(CUSTOM_SETTING_SERVICES)) {
|
|
704
|
-
this.services[key] = await this.moduleRef.get(
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
strict: false
|
|
708
|
-
}
|
|
709
|
-
);
|
|
583
|
+
this.services[key] = await this.moduleRef.get(CUSTOM_SETTING_SERVICES[key], {
|
|
584
|
+
strict: false,
|
|
585
|
+
});
|
|
710
586
|
}
|
|
711
587
|
}
|
|
712
588
|
|
|
@@ -714,11 +590,7 @@ export class CoreSettingService implements OnModuleInit {
|
|
|
714
590
|
const service = await this._getService(entityName);
|
|
715
591
|
return service.getSetting(key);
|
|
716
592
|
}
|
|
717
|
-
public async setSetting(
|
|
718
|
-
entityName: string,
|
|
719
|
-
data: any,
|
|
720
|
-
key?: string
|
|
721
|
-
): Promise<any> {
|
|
593
|
+
public async setSetting(entityName: string, data: any, key?: string): Promise<any> {
|
|
722
594
|
const service = await this._getService(entityName);
|
|
723
595
|
return service.setSetting(data, key);
|
|
724
596
|
}
|
|
@@ -727,10 +599,7 @@ export class CoreSettingService implements OnModuleInit {
|
|
|
727
599
|
const service = await this._getService(entityName);
|
|
728
600
|
return service.defaultPermission();
|
|
729
601
|
}
|
|
730
|
-
public async setPermission(
|
|
731
|
-
entityName: string,
|
|
732
|
-
permissoin: any
|
|
733
|
-
): Promise<any> {
|
|
602
|
+
public async setPermission(entityName: string, permissoin: any): Promise<any> {
|
|
734
603
|
const service = await this._getService(entityName);
|
|
735
604
|
return service.setPermission(permissoin);
|
|
736
605
|
}
|
|
@@ -10,14 +10,11 @@ import * as moment from "moment";
|
|
|
10
10
|
import { v4 as uuid } from "uuid";
|
|
11
11
|
import * as rTracer from "cls-rtracer";
|
|
12
12
|
import { NestFactory } from "@nestjs/core";
|
|
13
|
-
import {
|
|
14
|
-
FastifyAdapter,
|
|
15
|
-
NestFastifyApplication
|
|
16
|
-
} from "@nestjs/platform-fastify";
|
|
13
|
+
import { FastifyAdapter, NestFastifyApplication } from "@nestjs/platform-fastify";
|
|
17
14
|
import { AppModule } from "./app.module";
|
|
18
15
|
import * as path from "path";
|
|
19
16
|
import { AppClusterService } from "./app_cluster.service";
|
|
20
|
-
import { CUSTOM_MODULES as LIB_CUSTOM_MODULES } from
|
|
17
|
+
import { CUSTOM_MODULES as LIB_CUSTOM_MODULES } from "@shopstack/cc-core-lib/module";
|
|
21
18
|
import { Logger, RequestMethod } from "@nestjs/common";
|
|
22
19
|
import {
|
|
23
20
|
IGNORE_ENDPOINT_PATHS,
|
|
@@ -84,8 +81,9 @@ import {
|
|
|
84
81
|
PrintLogService,
|
|
85
82
|
redisCache,
|
|
86
83
|
RewriteUrlService,
|
|
87
|
-
SearchTextService
|
|
88
|
-
|
|
84
|
+
SearchTextService,
|
|
85
|
+
ReindexSearchTextService,
|
|
86
|
+
} from "@shopstack/cc-core-lib/core";
|
|
89
87
|
|
|
90
88
|
import { CUSTOM_MODULES } from "src/modules/modules";
|
|
91
89
|
import * as packageData from "../package.json";
|
|
@@ -95,10 +93,7 @@ async function initialService(app: NestFastifyApplication, serviceClass: any) {
|
|
|
95
93
|
const service = await app.resolve<typeof serviceClass>(serviceClass);
|
|
96
94
|
await service.init();
|
|
97
95
|
let end = now();
|
|
98
|
-
Logger.log(
|
|
99
|
-
`${service.constructor.name} initial done (${(end - start).toFixed(3)})`,
|
|
100
|
-
"MAIN"
|
|
101
|
-
);
|
|
96
|
+
Logger.log(`${service.constructor.name} initial done (${(end - start).toFixed(3)})`, "MAIN");
|
|
102
97
|
}
|
|
103
98
|
|
|
104
99
|
async function refreshService(app: NestFastifyApplication, serviceClass: any) {
|
|
@@ -106,38 +101,26 @@ async function refreshService(app: NestFastifyApplication, serviceClass: any) {
|
|
|
106
101
|
const service = await app.resolve<typeof serviceClass>(serviceClass);
|
|
107
102
|
await service.initRefresh();
|
|
108
103
|
let end = now();
|
|
109
|
-
Logger.log(
|
|
110
|
-
`${service.constructor.name} initial refresh done (${(end - start).toFixed(
|
|
111
|
-
3
|
|
112
|
-
)})`,
|
|
113
|
-
"MAIN"
|
|
114
|
-
);
|
|
104
|
+
Logger.log(`${service.constructor.name} initial refresh done (${(end - start).toFixed(3)})`, "MAIN");
|
|
115
105
|
}
|
|
116
106
|
|
|
117
107
|
async function initialCustomService(app: NestFastifyApplication) {
|
|
118
|
-
const SPECIFY_CUSTOM_MODULES =
|
|
119
|
-
process.env.CUSTOM_MODULES === "" ||
|
|
120
|
-
process.env.CUSTOM_MODULES === undefined
|
|
121
|
-
? []
|
|
122
|
-
: process.env.CUSTOM_MODULES.split(",");
|
|
108
|
+
const SPECIFY_CUSTOM_MODULES = process.env.CUSTOM_MODULES === "" || process.env.CUSTOM_MODULES === undefined ? [] : process.env.CUSTOM_MODULES.split(",");
|
|
123
109
|
const RUN_CUSTOM_SERVICES = [];
|
|
124
110
|
SPECIFY_CUSTOM_MODULES.length === 0
|
|
125
|
-
? CUSTOM_MODULES.forEach(c => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
: CUSTOM_MODULES.filter(c =>
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
RUN_CUSTOM_SERVICES.push(...(c.services || []));
|
|
132
|
-
});
|
|
111
|
+
? CUSTOM_MODULES.forEach((c) => {
|
|
112
|
+
RUN_CUSTOM_SERVICES.push(...(c.services || []));
|
|
113
|
+
})
|
|
114
|
+
: CUSTOM_MODULES.filter((c) => SPECIFY_CUSTOM_MODULES.includes(c.module.name)).forEach((c) => {
|
|
115
|
+
RUN_CUSTOM_SERVICES.push(...(c.services || []));
|
|
116
|
+
});
|
|
133
117
|
for (const customService of RUN_CUSTOM_SERVICES) {
|
|
134
118
|
await initialService(app, customService);
|
|
135
119
|
}
|
|
136
120
|
}
|
|
137
121
|
|
|
138
122
|
async function initial(app: NestFastifyApplication) {
|
|
139
|
-
|
|
140
|
-
LIB_CUSTOM_MODULES.push(...CUSTOM_MODULES)
|
|
123
|
+
LIB_CUSTOM_MODULES.push(...CUSTOM_MODULES);
|
|
141
124
|
|
|
142
125
|
await initialService(app, SettingService);
|
|
143
126
|
await initialService(app, EntitiesService);
|
|
@@ -195,6 +178,7 @@ async function initial(app: NestFastifyApplication) {
|
|
|
195
178
|
await initialService(app, LayoutShareWidgetService);
|
|
196
179
|
|
|
197
180
|
await initialService(app, SearchTextService);
|
|
181
|
+
await initialService(app, ReindexSearchTextService);
|
|
198
182
|
|
|
199
183
|
await initialCustomModules();
|
|
200
184
|
await initialCustomProviders();
|
|
@@ -227,40 +211,35 @@ async function initial(app: NestFastifyApplication) {
|
|
|
227
211
|
async function bootstrap() {
|
|
228
212
|
dotenv.config();
|
|
229
213
|
const fastify = new FastifyAdapter({ logger: true, bodyLimit: 104857600 });
|
|
230
|
-
|
|
214
|
+
|
|
231
215
|
fastify.register(require("@fastify/cors"), {
|
|
232
216
|
// put your options here
|
|
233
217
|
});
|
|
234
218
|
|
|
235
219
|
fastify.register(rTracer.fastifyPlugin, {
|
|
236
|
-
requestIdFactory: req => ({
|
|
220
|
+
requestIdFactory: (req) => ({
|
|
237
221
|
request_id: uuid(),
|
|
238
222
|
user_ip: req.headers["client-ip"],
|
|
239
|
-
user_agent: req.headers["user-agent"]
|
|
240
|
-
})
|
|
223
|
+
user_agent: req.headers["user-agent"],
|
|
224
|
+
}),
|
|
241
225
|
});
|
|
242
|
-
|
|
226
|
+
|
|
243
227
|
// Register the multipart plugin
|
|
244
228
|
fastify.register(require("@fastify/multipart"), { attachFieldsToBody: true });
|
|
245
229
|
|
|
246
230
|
// Register the fastify-xml-body-parser plugin
|
|
247
231
|
fastify.register(require("fastify-xml-body-parser"));
|
|
248
|
-
|
|
249
|
-
const app = await NestFactory.create<NestFastifyApplication>(
|
|
250
|
-
AppModule,
|
|
251
|
-
fastify
|
|
252
|
-
);
|
|
232
|
+
|
|
233
|
+
const app = await NestFactory.create<NestFastifyApplication>(AppModule, fastify);
|
|
253
234
|
|
|
254
235
|
app.useStaticAssets({
|
|
255
236
|
root: `${process.cwd()}/storage/public`,
|
|
256
|
-
prefix: `/public
|
|
237
|
+
prefix: `/public`,
|
|
257
238
|
});
|
|
258
239
|
|
|
259
240
|
// Serve specific file for "/"
|
|
260
241
|
fastify.get("/", (request, reply) => {
|
|
261
|
-
reply
|
|
262
|
-
.type("text/html")
|
|
263
|
-
.sendFile("index.html", path.join(process.cwd(), "storage/documents"));
|
|
242
|
+
reply.type("text/html").sendFile("index.html", path.join(process.cwd(), "storage/documents"));
|
|
264
243
|
});
|
|
265
244
|
|
|
266
245
|
_.set(CONST, "app", app);
|
|
@@ -271,7 +250,7 @@ async function bootstrap() {
|
|
|
271
250
|
app.useGlobalGuards(new JWTAuthGuard(reflector, auth));
|
|
272
251
|
app.useGlobalGuards(new CsrfGuard(reflector));
|
|
273
252
|
app.setGlobalPrefix("api/v1", {
|
|
274
|
-
exclude: [{ path: "private/*", method: RequestMethod.GET }]
|
|
253
|
+
exclude: [{ path: "private/*", method: RequestMethod.GET }],
|
|
275
254
|
});
|
|
276
255
|
app.use(request);
|
|
277
256
|
app.useGlobalInterceptors(new FilterInterceptor(reflector));
|
|
@@ -285,18 +264,18 @@ async function bootstrap() {
|
|
|
285
264
|
app
|
|
286
265
|
.getHttpAdapter()
|
|
287
266
|
.getInstance()
|
|
288
|
-
.addHook("onRoute", route => {
|
|
267
|
+
.addHook("onRoute", (route) => {
|
|
289
268
|
if (!ignoreRouteRegex.test(route.path)) {
|
|
290
269
|
routes.push({
|
|
291
270
|
path: route.path.replace("/api/v1/", ""),
|
|
292
|
-
method: route.method
|
|
271
|
+
method: route.method,
|
|
293
272
|
});
|
|
294
273
|
}
|
|
295
274
|
});
|
|
296
275
|
app
|
|
297
276
|
.getHttpAdapter()
|
|
298
277
|
.getInstance()
|
|
299
|
-
.addHook("onReady", done => {
|
|
278
|
+
.addHook("onReady", (done) => {
|
|
300
279
|
CONST.ENDPOINT_PATHS = routes;
|
|
301
280
|
done();
|
|
302
281
|
});
|