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.
Files changed (75) hide show
  1. package/bin/index.js +4 -4
  2. package/package.json +1 -1
  3. package/template/admin_v3/src/pages/api/database/[type]/index.ts +23 -0
  4. package/template/admin_v3/src/pages/api/layout_chart_widget/[name]/index.ts +18 -0
  5. package/template/admin_v3/src/pages/api/layout_chart_widget/compare_matrix.ts +17 -0
  6. package/template/admin_v3/src/pages/api/redis/[type]/[connect]/index.ts +20 -0
  7. package/template/admin_v3/src/pages/api/redis/custom.ts +10 -0
  8. package/template/admin_v3/src/pages/api/setting/module/[code].ts +34 -0
  9. package/template/admin_v3/src/pages/api/template/[type].ts +21 -0
  10. package/template/admin_v3/src/pages/api/template/bulk_print/[id].ts +15 -0
  11. package/template/admin_v3/src/pages/api/template/print/[id]/[doc_ref].ts +11 -0
  12. package/template/core/src/main.ts +4 -1
  13. package/template/core_v3/Dockerfile +60 -0
  14. package/template/core_v3/_env +12 -0
  15. package/template/core_v3/_gitignore +52 -0
  16. package/template/core_v3/_npmrc +1 -0
  17. package/template/core_v3/buildspec.yml +29 -0
  18. package/template/core_v3/docker-compose.yml +11 -0
  19. package/template/core_v3/jest.config.js +43 -0
  20. package/template/core_v3/newrelic.sh +15 -0
  21. package/template/core_v3/package.json +54 -0
  22. package/template/core_v3/post-install.js +34 -0
  23. package/template/core_v3/sonar-project.properties +27 -0
  24. package/template/core_v3/src/app.controller.ts +39 -0
  25. package/template/core_v3/src/app.module.ts +174 -0
  26. package/template/core_v3/src/app.service.ts +21 -0
  27. package/template/core_v3/src/app_cluster.service.ts +61 -0
  28. package/template/core_v3/src/core/core.controller.ts +444 -0
  29. package/template/core_v3/src/core/core.module.ts +90 -0
  30. package/template/core_v3/src/core/core.service.ts +737 -0
  31. package/template/core_v3/src/core/setting/_settings/about.layout.json +105 -0
  32. package/template/core_v3/src/core/setting/_settings/cache.layout.json +309 -0
  33. package/template/core_v3/src/core/setting/_settings/global_login.json +299 -0
  34. package/template/core_v3/src/core/setting/_settings/header_footer.json +83 -0
  35. package/template/core_v3/src/core/setting/_settings/import_export.layout.json +69 -0
  36. package/template/core_v3/src/core/setting/_settings/list_detail.json +685 -0
  37. package/template/core_v3/src/core/setting/_settings/logs.layout.json +39 -0
  38. package/template/core_v3/src/core/setting/_settings/queue.layout.json +63 -0
  39. package/template/core_v3/src/core/setting/_settings/schedule.layout.json +132 -0
  40. package/template/core_v3/src/core/setting/_settings/security.layout.json +1110 -0
  41. package/template/core_v3/src/core/setting/_settings/storage.layout.json +158 -0
  42. package/template/core_v3/src/core/setting/_settings/swagger.layout.json +128 -0
  43. package/template/core_v3/src/core/setting/_settings/toast.json +344 -0
  44. package/template/core_v3/src/main.ts +308 -0
  45. package/template/core_v3/src/modules/modules.ts +16 -0
  46. package/template/core_v3/src/private.controller.ts +18 -0
  47. package/template/core_v3/storage/documents/index.html +14 -0
  48. package/template/core_v3/storage/public/system/menu/icons/company.svg +1 -0
  49. package/template/core_v3/storage/public/system/menu/icons/deploy.svg +2 -0
  50. package/template/core_v3/storage/public/system/menu/icons/entities.svg +55 -0
  51. package/template/core_v3/storage/public/system/menu/icons/files.svg +1 -0
  52. package/template/core_v3/storage/public/system/menu/icons/gateway.svg +1 -0
  53. package/template/core_v3/storage/public/system/menu/icons/import-export.svg +41 -0
  54. package/template/core_v3/storage/public/system/menu/icons/integration.svg +1 -0
  55. package/template/core_v3/storage/public/system/menu/icons/master_data.svg +53 -0
  56. package/template/core_v3/storage/public/system/menu/icons/modules.svg +79 -0
  57. package/template/core_v3/storage/public/system/menu/icons/monitoring.svg +114 -0
  58. package/template/core_v3/storage/public/system/menu/icons/pipeline.svg +1 -0
  59. package/template/core_v3/storage/public/system/menu/icons/provider.svg +1 -0
  60. package/template/core_v3/storage/public/system/menu/icons/report.svg +69 -0
  61. package/template/core_v3/storage/public/system/menu/icons/schedule.svg +1 -0
  62. package/template/core_v3/storage/public/system/menu/icons/security.svg +1 -0
  63. package/template/core_v3/storage/public/system/menu/icons/storage.svg +1 -0
  64. package/template/core_v3/storage/public/system/menu/icons/template.svg +44 -0
  65. package/template/core_v3/storage/public/system/menu/icons/theme-layout.svg +1 -0
  66. package/template/core_v3/test/__mocks__/cc-core-lib.d.ts +161 -0
  67. package/template/core_v3/test/__mocks__/cc-core-lib.js +311 -0
  68. package/template/core_v3/test/__mocks__/pdf-img-convert.js +5 -0
  69. package/template/core_v3/test/jest.setup.ts +25 -0
  70. package/template/core_v3/tsconfig.build.json +4 -0
  71. package/template/core_v3/tsconfig.json +22 -0
  72. package/template/core_v3/tsconfig.test.json +17 -0
  73. package/template/core_v3/version.json +5 -0
  74. package/template/admin_v3/src/pages/api/redis/[connect]/index.ts +0 -0
  75. package/template/admin_v3/src/pages/api/redis/index.ts +0 -0
@@ -0,0 +1,174 @@
1
+ import * as _ from "lodash";
2
+ import {
3
+ Module,
4
+ } from "@nestjs/common";
5
+ import { MongooseModule } from "@nestjs/mongoose";
6
+ import { ClsModule } from "nestjs-cls";
7
+ import * as dotenv from "dotenv";
8
+
9
+ import { NestEmitterModule } from "nest-emitter";
10
+ import { EventEmitter } from "events";
11
+
12
+ import { StoragePrivateController } from "./private.controller";
13
+ import { AppController } from "./app.controller";
14
+ import { AppService } from "./app.service";
15
+ import { ScheduleModule } from "@nestjs/schedule";
16
+
17
+ import { CUSTOM_MODULES } from "./modules/modules";
18
+ // import { CoreModule } from "./core/core.module";
19
+ import {
20
+ UserModule,
21
+ AuthModule,
22
+ EntitiesModule,
23
+ ScheduleActionModule,
24
+ SettingModule,
25
+ TemplateModule,
26
+ QueueModule,
27
+ TranslateModule,
28
+ AttachmentModule,
29
+ NotificationModule,
30
+ RedisModule,
31
+ MailSettingModule,
32
+ SmsModule,
33
+ ShortlyModule,
34
+ LayoutModule,
35
+ CompanyModule,
36
+ LanguageModule,
37
+ ImportExportModule,
38
+ CommentDataModule,
39
+ DatabaseModule,
40
+ DeployModule,
41
+ CustomFunctionModule,
42
+ CacheModule,
43
+ PipelineModule,
44
+ RewriteUrlModule
45
+ } from '@shopstack/cc-core-lib/core'
46
+
47
+ import { CoreModule } from './core/core.module'
48
+
49
+ // const { CoreModule } = core
50
+
51
+ dotenv.config();
52
+
53
+ const SPECIFY_CUSTOM_MODULES =
54
+ process.env.CUSTOM_MODULES === "" || process.env.CUSTOM_MODULES === undefined
55
+ ? []
56
+ : process.env.CUSTOM_MODULES.split(",");
57
+ const RUN_CUSTOM_MODULES =
58
+ 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);
63
+
64
+ const mongoConfig = {};
65
+
66
+ if (+process.env.MONGODB_MIN_POOL_SIZE) {
67
+ mongoConfig["minPoolSize"] = +process.env.MONGODB_MIN_POOL_SIZE;
68
+ }
69
+
70
+ if (+process.env.MONGODB_MAX_POOL_SIZE) {
71
+ mongoConfig["maxPoolSize"] = +process.env.MONGODB_MAX_POOL_SIZE;
72
+ }
73
+
74
+ @Module({
75
+ imports: [
76
+ // MongooseModule.forRootAsync({
77
+ // useFactory: async () => ({
78
+ // uri: process.env.MONGODB_URI,
79
+ // useNewUrlParser: true,
80
+ // useFindAndModify: false
81
+ // })
82
+ // }),
83
+ MongooseModule.forRoot(process.env.MONGODB_URI, mongoConfig),
84
+ // Register the ClsModule,
85
+ ClsModule.forRoot({
86
+ middleware: {
87
+ // automatically mount the
88
+ // ClsMiddleware for all routes
89
+ mount: true,
90
+ // and use the setup method to
91
+ // provide default store values.
92
+ setup: (cls, req) => {
93
+ cls.set("request", {
94
+ api_key: _.get(req, "api_key", {}),
95
+ profile: _.get(req, "profile", {}),
96
+ permissions: _.get(req, "permissions", []),
97
+ headers: _.get(req, "headers", {}),
98
+ ip: _.get(req, "ip"),
99
+ protocol: _.get(req, "protocol"),
100
+ hostname: _.get(req, "hostname"),
101
+ url: _.get(req, "url"),
102
+ method: _.get(req, "method"),
103
+ body: _.get(req, "body", {}),
104
+ action_profile: _.get(req, "action_profile", {}),
105
+ permisson_entities: _.get(req, "permisson_entities", {}),
106
+ permisson_tab: _.get(req, "permisson_tab", {})
107
+ });
108
+ }
109
+ },
110
+ interceptor: {
111
+ mount: true,
112
+ setup: (cls, ctx) => {
113
+ const req = ctx.switchToHttp().getRequest();
114
+ cls.set("request", {
115
+ api_key: _.get(req, "api_key", {}),
116
+ profile: _.get(req, "profile", {}),
117
+ permissions: _.get(req, "permissions", []),
118
+ roles: _.get(req, "roles", []),
119
+ headers: _.get(req, "headers", {}),
120
+ // ip: req.connection.remoteAddress,
121
+ ip:
122
+ _.get(req, "socket.remoteAddress") ||
123
+ _.get(req, "connection.remoteAddress"),
124
+ protocol: _.get(req, "protocol"),
125
+ hostname: _.get(req, "hostname"),
126
+ url: _.get(req, "url"),
127
+ method: _.get(req, "method"),
128
+ body: _.get(req, "body", {}),
129
+ action_profile: _.get(req, "action_profile", {}),
130
+ permisson_entities: _.get(req, "permisson_entities", {}),
131
+ permisson_tab: _.get(req, "permisson_tab", {})
132
+ });
133
+ }
134
+ }
135
+ }),
136
+
137
+ EntitiesModule,
138
+ NestEmitterModule.forRoot(new EventEmitter()),
139
+ ScheduleModule.forRoot(),
140
+ AuthModule,
141
+ SettingModule,
142
+ QueueModule,
143
+ RedisModule,
144
+ DatabaseModule,
145
+ CacheModule,
146
+
147
+ CompanyModule,
148
+
149
+ AttachmentModule,
150
+ CommentDataModule,
151
+ CustomFunctionModule,
152
+ DeployModule,
153
+ ImportExportModule,
154
+ LanguageModule,
155
+ MailSettingModule,
156
+ ScheduleActionModule,
157
+ SmsModule,
158
+ TemplateModule,
159
+ TranslateModule,
160
+ NotificationModule,
161
+ ShortlyModule,
162
+ UserModule,
163
+ PipelineModule,
164
+ LayoutModule,
165
+ RewriteUrlModule,
166
+
167
+ // ...RUN_CUSTOM_MODULES,
168
+
169
+ CoreModule
170
+ ],
171
+ controllers: [AppController, StoragePrivateController],
172
+ providers: [AppService]
173
+ })
174
+ export class AppModule { }
@@ -0,0 +1,21 @@
1
+ import { Injectable, Logger } from "@nestjs/common";
2
+ import * as os from "os";
3
+ import { CONST } from "@shopstack/cc-core-lib/core";
4
+
5
+ @Injectable()
6
+ export class AppService {
7
+ private _isReady: boolean;
8
+
9
+ init(): string {
10
+ this._isReady = true;
11
+ Logger.log(`CPU cores ${os.cpus().length}`, "OS");
12
+ return "health_check";
13
+ }
14
+
15
+ healthCheck(): boolean {
16
+ if (!CONST.HEALTH_CHECK) {
17
+ throw new Error("not ready");
18
+ }
19
+ return true;
20
+ }
21
+ }
@@ -0,0 +1,61 @@
1
+ import * as _ from "lodash";
2
+ import * as cluster from "cluster";
3
+ import * as os from "os";
4
+ import { Injectable } from "@nestjs/common";
5
+ import axios, { AxiosInstance } from "axios";
6
+ import { CONST } from '@shopstack/cc-core-lib/core'
7
+
8
+ CONST.INTERNAL_DOMAIN = `http://${process.env.LOOP_BACK_IP}:${process.env
9
+ .PORT || 3000}/api/v1`;
10
+
11
+ const numCPUs = _.isEmpty(process.env.MAX_WORKER)
12
+ ? os.cpus().length
13
+ : parseInt(process.env.MAX_WORKER, 10) === 0
14
+ ? os.cpus().length
15
+ : parseInt(process.env.MAX_WORKER, 10);
16
+ console.log("MAXIMUM WORKER PROCESS: " + numCPUs);
17
+ // const numCPUs = 2;
18
+ let checkInit = false;
19
+ let mainPID = 0;
20
+
21
+ @Injectable()
22
+ export class AppClusterService {
23
+ static async clusterize(callback: Function): Promise<void> {
24
+ if (cluster.isMaster) {
25
+ console.log(`Master server started on ${process.pid}`);
26
+ CONST.MAIN_PROCESS = true;
27
+ for (let i = 0; i < numCPUs; i++) {
28
+ const env = { WORKER_NO: i + 1 }
29
+ const worker = cluster.fork(env);
30
+ worker.process['env'] = env
31
+ }
32
+ cluster.on("listening", (worker, address) => {
33
+ console.log(
34
+ `A worker is now connected to ${address.address}:${address.port}`
35
+ );
36
+ const http: AxiosInstance = axios.create();
37
+ if (worker.process["env"].WORKER_NO == "1") {
38
+ http.get(`${CONST.INTERNAL_DOMAIN}/entities/init_data`);
39
+ http.get(`${CONST.INTERNAL_DOMAIN}/setting/update_version`);
40
+ }
41
+ http.get(`${CONST.INTERNAL_DOMAIN}/user_role/reload_system`);
42
+ http.get(`${CONST.INTERNAL_DOMAIN}/translate/generate`);
43
+ http.get(`${CONST.INTERNAL_DOMAIN}/health_check/init`);
44
+ });
45
+ // cluster.on("online", worker => {
46
+ // console.log("Yay, the worker responded after it was forked");
47
+ // });
48
+ cluster.on("exit", (worker, code, signal, ...other) => {
49
+ const env = worker.process['env']
50
+ console.log(
51
+ `Worker ${worker.process.pid} (${code},${signal}) died. Restarting`
52
+ );
53
+ const newWorker = cluster.fork(env);
54
+ newWorker.process['env'] = env
55
+ });
56
+ } else {
57
+ console.log(`Cluster server started on ${process.pid}`);
58
+ await callback();
59
+ }
60
+ }
61
+ }
@@ -0,0 +1,444 @@
1
+ import * as _ from "lodash";
2
+
3
+ import {
4
+ Get,
5
+ Post,
6
+ Put,
7
+ Patch,
8
+ Body,
9
+ Param,
10
+ Delete,
11
+ Query,
12
+ Controller
13
+ } from "@nestjs/common";
14
+ import {
15
+ CoreLogService,
16
+ CoreService,
17
+ CoreSettingService
18
+ } from "./core.service";
19
+ import {
20
+ Basic,
21
+ SearchResultDto,
22
+ convertFilter
23
+ } from '@shopstack/cc-core-lib/core'
24
+
25
+ @Controller()
26
+ export class CoreController {
27
+ constructor(
28
+ private readonly service: CoreService,
29
+ private readonly serviceLog: CoreLogService,
30
+ private readonly serviceSetting: CoreSettingService
31
+ ) { }
32
+
33
+ private _convertFields(fields: string) {
34
+ return _.isEmpty(fields) ? undefined : fields.split(",");
35
+ }
36
+
37
+ @Get("/:entity/init")
38
+ async init(@Param() params: any): Promise<string> {
39
+ if (
40
+ !["mail_setting"].includes(params.entity) &&
41
+ params.entity.indexOf("_setting") !== -1
42
+ ) {
43
+ return "Not implement yet.";
44
+ }
45
+ return this.service.init(params.entity);
46
+ }
47
+
48
+ @Get("/:entity/init_data")
49
+ async initData(@Param() params: any): Promise<void> {
50
+ await this.service.initData(params.entity);
51
+ }
52
+
53
+ @Basic()
54
+ @Get("/:entity")
55
+ async search(
56
+ @Param() params: any,
57
+ @Query() query: any
58
+ ): Promise<SearchResultDto> {
59
+ if (
60
+ !["mail_setting"].includes(params.entity) &&
61
+ params.entity.indexOf("_setting") !== -1
62
+ ) {
63
+ return this.serviceSetting.getSetting(params.entity);
64
+ } else {
65
+ const { keywords, filters, page, page_size, sort, grouping, fields } = query;
66
+ return this.service.search(
67
+ params.entity,
68
+ keywords,
69
+ convertFilter(filters),
70
+ page ? parseInt(page, 10) : 1,
71
+ page_size ? parseInt(page_size, 10) : 10,
72
+ sort,
73
+ this._convertFields(grouping),
74
+ false,
75
+ this._convertFields(fields)
76
+ );
77
+ }
78
+ }
79
+
80
+ @Basic()
81
+ @Get("/:entity/find")
82
+ async find(@Param() params: any, @Query() query: any): Promise<any> {
83
+ const { keywords, filters, sort, fields } = query;
84
+ return this.service.find(
85
+ params.entity,
86
+ keywords,
87
+ convertFilter(filters),
88
+ sort,
89
+ false,
90
+ this._convertFields(fields)
91
+ );
92
+ }
93
+
94
+ @Basic()
95
+ @Get("/:entity/workflow/:id")
96
+ workflowActions(@Param() params: any): Promise<any> {
97
+ return this.service.workflowActions(params.entity, params.id);
98
+ }
99
+
100
+ @Basic()
101
+ @Get("/:entity/aggregate")
102
+ aggregate(@Param() params: any, @Query() query: any): any {
103
+ return this.service.aggregate(params.entity, query.query);
104
+ }
105
+
106
+ @Basic()
107
+ @Patch("/:entity/aggregate")
108
+ aggregateBody(@Param() params: any, @Body() body: any): any {
109
+ return this.service.aggregate(
110
+ params.entity,
111
+ JSON.stringify({ query: body })
112
+ );
113
+ }
114
+
115
+ @Basic()
116
+ @Get("/:entity/count")
117
+ async count(@Param() params: any, @Query() query: any): Promise<any> {
118
+ const { filters, keywords } = query;
119
+ return this.service.count(params.entity, convertFilter(filters), keywords);
120
+ }
121
+
122
+ @Get("/:entity/:layout/find")
123
+ async findWithLayout(
124
+ @Query() query: any,
125
+ @Param() params: any
126
+ ): Promise<any> {
127
+ const { keywords, filters, sort } = query;
128
+ return this.service.findWithLayout(
129
+ params.entity,
130
+ params.layout,
131
+ keywords,
132
+ convertFilter(filters),
133
+ sort
134
+ );
135
+ }
136
+
137
+ @Get("/:entity/:layout/aggregate")
138
+ aggregateWithLayout(@Param() params: any, @Query() query: any): any {
139
+ return this.service.aggregate(params.entity, query.query);
140
+ }
141
+
142
+ @Get("/:entity/:layout/count")
143
+ async countWithLayout(
144
+ @Param() params: any,
145
+ @Query() query: any
146
+ ): Promise<any> {
147
+ const { filters, keywords } = query;
148
+ return this.service.count(params.entity, convertFilter(filters), keywords);
149
+ }
150
+
151
+ @Basic()
152
+ @Get("/:entity/:key")
153
+ async findOneOrSearchWithLayout(
154
+ @Param() params: any,
155
+ @Query() query: any
156
+ ): Promise<any> {
157
+ const { keywords, filters, page, page_size, sort, grouping } = query;
158
+ const searchKey = `${keywords || ""}${
159
+ _.isEmpty(filters) ? "" : JSON.stringify(filters)
160
+ }${page || ""}${page_size || ""}${sort || ""}${grouping || ""}`;
161
+ if (
162
+ !["mail_setting"].includes(params.entity) &&
163
+ params.entity.indexOf("_setting") !== -1
164
+ ) {
165
+ return this.serviceSetting.getSetting(params.entity, params.key);
166
+ } else {
167
+ if (
168
+ /^(?=[a-f\d]{24}$)(\d+[a-f]|[a-f]+\d)/i.test(params.key) ||
169
+ _.isEmpty(searchKey)
170
+ ) {
171
+ return this.service.findOne(
172
+ params.entity,
173
+ params.key,
174
+ this._convertFields(query.fields)
175
+ );
176
+ }
177
+ return this.service.searchWithLayout(
178
+ params.entity,
179
+ params.key,
180
+ keywords,
181
+ convertFilter(filters),
182
+ page ? parseInt(page, 10) : 1,
183
+ page_size ? parseInt(page_size, 10) : 10,
184
+ sort,
185
+ this._convertFields(grouping)
186
+ );
187
+ }
188
+ }
189
+
190
+ @Basic()
191
+ @Get("/:entity/ids")
192
+ dataIdsSearch(@Param() params: any, @Query() query: any): any {
193
+ const { keywords, filters, page, page_size, sort } = query;
194
+ return this.service.searchIds(
195
+ params.entity,
196
+ keywords,
197
+ convertFilter(filters),
198
+ page ? parseInt(page, 10) : 1,
199
+ page_size ? parseInt(page_size, 10) : 10,
200
+ sort
201
+ );
202
+ }
203
+
204
+ @Get("/:entity/:layout/:id")
205
+ async searchWithLayout(@Param() params: any): Promise<any> {
206
+ return this.service.findOneWithLayout(
207
+ params.entity,
208
+ params.layout,
209
+ params.id
210
+ );
211
+ }
212
+
213
+ @Basic()
214
+ @Get("/:entity/find/translate/:locale")
215
+ async findWithLocale(
216
+ @Param() params: any,
217
+ @Query() query: any
218
+ ): Promise<any> {
219
+ const { keywords, filters, sort } = query;
220
+ return this.service.findWithLocale(
221
+ params.entity,
222
+ params.locale,
223
+ keywords,
224
+ convertFilter(filters),
225
+ sort
226
+ );
227
+ }
228
+
229
+ @Get("/:entity/:layout/:id/translate/:locale")
230
+ async dataWithLocale(@Param() params: any): Promise<any> {
231
+ return this.service.dataWithLocale(
232
+ params.entity,
233
+ params.layout,
234
+ params.id,
235
+ params.locale
236
+ );
237
+ }
238
+
239
+ @Basic()
240
+ @Post("/:entity")
241
+ async create(@Param() params: any, @Body() data: any): Promise<any> {
242
+ return this.service.create(params.entity, data);
243
+ }
244
+
245
+ @Basic()
246
+ @Put("/:entity")
247
+ async setSetting(@Param() params: any, @Body() body: any): Promise<any> {
248
+ return this.serviceSetting.setSetting(params.entity, body);
249
+ }
250
+
251
+ @Basic()
252
+ @Put("/:entity/:id")
253
+ async update(@Param() params: any, @Body() data: any): Promise<any> {
254
+ if (
255
+ !["mail_setting"].includes(params.entity) &&
256
+ params.entity.indexOf("_setting") !== -1
257
+ ) {
258
+ return this.serviceSetting.setSetting(params.entity, data, params.id);
259
+ } else {
260
+ return this.service.update(params.entity, params.id, data);
261
+ }
262
+ }
263
+
264
+ @Basic()
265
+ @Put("/:entity/:id/approve")
266
+ async approve(@Param() params: any, @Body() data: any): Promise<any> {
267
+ return this.service.approve(params.entity, params.id, data);
268
+ }
269
+
270
+ @Put("/:entity/:layout/:id/approve")
271
+ async approveWithLayout(
272
+ @Param() params: any,
273
+ @Body() data: any
274
+ ): Promise<any> {
275
+ return this.service.approve(params.entity, params.id, data);
276
+ }
277
+
278
+ @Put("/:entity/:layout/:id")
279
+ async updateWithLayout(
280
+ @Param() params: any,
281
+ @Body() data: any
282
+ ): Promise<any> {
283
+ return this.service.update(params.entity, params.id, data);
284
+ }
285
+
286
+ @Basic()
287
+ @Put("/:entity/:id/translate/:locale")
288
+ async setDataLocale(@Param() params: any, @Body() data: any): Promise<any> {
289
+ return this.service.setDataLocale(
290
+ params.entity,
291
+ params.id,
292
+ params.locale,
293
+ data
294
+ );
295
+ }
296
+
297
+ @Basic()
298
+ @Delete("/:entity/:id")
299
+ async delete(@Param() params: any): Promise<any> {
300
+ return this.service.delete(params.entity, params.id);
301
+ }
302
+
303
+ @Delete("/:entity/:layout/:id")
304
+ async deleteWithLayout(@Param() params: any): Promise<any> {
305
+ return this.service.delete(params.entity, params.id);
306
+ }
307
+
308
+ @Basic()
309
+ @Post("/:entity/bulk_create")
310
+ async bulkCreate(@Param() params: any, @Body() body: any): Promise<any> {
311
+ return this.service.bulkCreate(params.entity, body.data);
312
+ }
313
+
314
+ @Basic()
315
+ @Post("/:entity/bulk_update")
316
+ async bulkUpdate(@Param() params: any, @Body() body: any): Promise<any> {
317
+ return this.service.bulkUpdate(params.entity, body.data);
318
+ }
319
+
320
+ @Basic()
321
+ @Post("/:entity/bulk_delete")
322
+ async bulkDelete(@Param() params: any, @Body() data: any): Promise<any> {
323
+ return this.service.bulkDelete(params.entity, data.ids);
324
+ }
325
+
326
+ @Post("/:entity/:layout/bulk_update")
327
+ async bulkUpdateWithLayout(
328
+ @Param() params: any,
329
+ @Body() body: any
330
+ ): Promise<any> {
331
+ return this.service.bulkUpdate(params.entity, body.data);
332
+ }
333
+
334
+ @Post("/:entity/:layout/bulk_delete")
335
+ async bulkDeleteWithLayout(
336
+ @Param() params: any,
337
+ @Body() data: any
338
+ ): Promise<any> {
339
+ return this.service.bulkDelete(params.entity, data.ids);
340
+ }
341
+
342
+ @Post("/:entity/:layout")
343
+ async createWithLayout(
344
+ @Param() params: any,
345
+ @Body() data: any
346
+ ): Promise<any> {
347
+ return this.service.create(params.entity, data);
348
+ }
349
+
350
+ @Basic()
351
+ @Patch("/:entity/prepare_generate_data")
352
+ async prepareGenerateData(
353
+ @Param() params: any,
354
+ @Body() data: any
355
+ ): Promise<any> {
356
+ return this.service.prepareGenerateData(params.entity, data);
357
+ }
358
+
359
+ @Basic()
360
+ @Patch("/:entity/generate_data")
361
+ async generateData(
362
+ @Param() params: any,
363
+ @Body() data: any
364
+ ): Promise<boolean> {
365
+ return this.service.generateData(params.entity, data);
366
+ }
367
+
368
+ @Basic()
369
+ @Patch("/:entity/progress_generate_data")
370
+ async progressGenerateData(
371
+ @Param() params: any,
372
+ @Body() data: any
373
+ ): Promise<any> {
374
+ return this.service.progressGenerateData(params.entity, data.ref_id);
375
+ }
376
+
377
+ @Basic()
378
+ @Patch("/:entity/workflow/:id")
379
+ async executeWorkflowAction(
380
+ @Param() params: any,
381
+ @Body() body: any
382
+ ): Promise<boolean> {
383
+ return this.service.executeWorkflowAction(params.entity, params.id, body);
384
+ }
385
+
386
+ @Patch("/:entity/:layout/generate_data")
387
+ async generateDataWithLayout(@Param() params: any): Promise<boolean> {
388
+ return this.service.generateData(params.entity);
389
+ }
390
+
391
+ @Basic()
392
+ @Patch("/:entity/example_output_mapping")
393
+ async exampleOutputMapping(
394
+ @Param() params: any,
395
+ @Body() data: any
396
+ ): Promise<any> {
397
+ return this.service.exampleOutputMapping(params.entity, data);
398
+ }
399
+
400
+ @Basic()
401
+ @Patch("/:entity/search")
402
+ async searchText(
403
+ @Param() params: any,
404
+ @Body() data: any
405
+ ): Promise<any> {
406
+ return this.service.searchText(params.entity, data);
407
+ }
408
+
409
+ @Basic()
410
+ @Patch("/:entity/purge_log")
411
+ async purgeLog(@Param() params: any, @Body() body): Promise<boolean> {
412
+ return this.serviceLog.purgeLog(params.entity, body);
413
+ }
414
+
415
+ @Basic()
416
+ @Get("/:entity/permission/default")
417
+ async defaultPermission(@Param() params: any): Promise<string> {
418
+ return this.serviceSetting.defaultPermission(params.entity);
419
+ }
420
+
421
+ @Basic()
422
+ @Put("/:entity/permission")
423
+ async setPermission(
424
+ @Param() params: any,
425
+ @Body() body: any
426
+ ): Promise<string> {
427
+ const result = await this.serviceSetting.setPermission(params.entity, body);
428
+ return result;
429
+ }
430
+
431
+ @Basic()
432
+ @Patch("/:entity/import_validate")
433
+ async importValidate(@Param() params: any, @Body() body): Promise<boolean> {
434
+ return this.service.importValidate(
435
+ params.entity,
436
+ body.id,
437
+ body.code,
438
+ body.data,
439
+ body.data_text,
440
+ body.original_data,
441
+ body.filename
442
+ );
443
+ }
444
+ }