@mbc-cqrs-serverless/master 0.1.68-beta.0 → 0.1.70-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +2 -1
- package/dist/constants/index.js.map +1 -1
- package/dist/controllers/master-data.controller.d.ts +6 -0
- package/dist/controllers/master-data.controller.js +74 -0
- package/dist/controllers/master-data.controller.js.map +1 -1
- package/dist/controllers/master-setting.controller.d.ts +8 -0
- package/dist/controllers/master-setting.controller.js +98 -0
- package/dist/controllers/master-setting.controller.js.map +1 -1
- package/dist/custom-task/custom-task.module.d.ts +2 -0
- package/dist/custom-task/custom-task.module.js +30 -0
- package/dist/custom-task/custom-task.module.js.map +1 -0
- package/dist/custom-task/event/task-queue-event-factory.d.ts +6 -0
- package/dist/custom-task/event/task-queue-event-factory.js +23 -0
- package/dist/custom-task/event/task-queue-event-factory.js.map +1 -0
- package/dist/custom-task/my-task.controller.d.ts +9 -0
- package/dist/custom-task/my-task.controller.js +56 -0
- package/dist/custom-task/my-task.controller.js.map +1 -0
- package/dist/custom-task/my-task.service.d.ts +12 -0
- package/dist/custom-task/my-task.service.js +76 -0
- package/dist/custom-task/my-task.service.js.map +1 -0
- package/dist/decorators/index.d.ts +1 -0
- package/dist/decorators/index.js +18 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/key.d.ts +1 -0
- package/dist/decorators/key.js +34 -0
- package/dist/decorators/key.js.map +1 -0
- package/dist/dto/index.d.ts +1 -0
- package/dist/dto/index.js +1 -0
- package/dist/dto/index.js.map +1 -1
- package/dist/dto/master-copy/index.d.ts +8 -0
- package/dist/dto/master-copy/index.js +25 -0
- package/dist/dto/master-copy/index.js.map +1 -0
- package/dist/dto/master-copy/master-copy.dto.d.ts +19 -0
- package/dist/dto/master-copy/master-copy.dto.js +92 -0
- package/dist/dto/master-copy/master-copy.dto.js.map +1 -0
- package/dist/dto/master-copy/master-data-create.dto.d.ts +7 -0
- package/dist/dto/master-copy/master-data-create.dto.js +43 -0
- package/dist/dto/master-copy/master-data-create.dto.js.map +1 -0
- package/dist/dto/master-copy/master-data-search.dto.d.ts +6 -0
- package/dist/dto/master-copy/master-data-search.dto.js +39 -0
- package/dist/dto/master-copy/master-data-search.dto.js.map +1 -0
- package/dist/dto/master-copy/master-data-update.dto.d.ts +6 -0
- package/dist/dto/master-copy/master-data-update.dto.js +41 -0
- package/dist/dto/master-copy/master-data-update.dto.js.map +1 -0
- package/dist/dto/master-copy/master-rds-list.entity.d.ts +6 -0
- package/dist/dto/master-copy/master-rds-list.entity.js +33 -0
- package/dist/dto/master-copy/master-rds-list.entity.js.map +1 -0
- package/dist/dto/master-copy/master-rds.entity.d.ts +26 -0
- package/dist/dto/master-copy/master-rds.entity.js +116 -0
- package/dist/dto/master-copy/master-rds.entity.js.map +1 -0
- package/dist/dto/master-copy/master-setting-search.dto.d.ts +6 -0
- package/dist/dto/master-copy/master-setting-search.dto.js +39 -0
- package/dist/dto/master-copy/master-setting-search.dto.js.map +1 -0
- package/dist/dto/master-copy/master-setting-update.dto.d.ts +4 -0
- package/dist/dto/master-copy/master-setting-update.dto.js +31 -0
- package/dist/dto/master-copy/master-setting-update.dto.js.map +1 -0
- package/dist/handler/master-sfn-task.event.d.ts +3 -0
- package/dist/handler/master-sfn-task.event.js +8 -0
- package/dist/handler/master-sfn-task.event.js.map +1 -0
- package/dist/handler/master-sfn-task.handler.d.ts +24 -0
- package/dist/handler/master-sfn-task.handler.js +242 -0
- package/dist/handler/master-sfn-task.handler.js.map +1 -0
- package/dist/helpers/index.d.ts +7 -0
- package/dist/helpers/index.js +15 -0
- package/dist/helpers/index.js.map +1 -1
- package/dist/helpers/rds.d.ts +4 -0
- package/dist/helpers/rds.js +19 -0
- package/dist/helpers/rds.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/master-data.interface.d.ts +2 -2
- package/dist/master.module-definition.d.ts +2 -0
- package/dist/master.module-definition.js +2 -1
- package/dist/master.module-definition.js.map +1 -1
- package/dist/master.module.js +19 -0
- package/dist/master.module.js.map +1 -1
- package/dist/services/master-data.service.d.ts +10 -9
- package/dist/services/master-data.service.js +112 -4
- package/dist/services/master-data.service.js.map +1 -1
- package/dist/services/master-setting.service.d.ts +16 -3
- package/dist/services/master-setting.service.js +126 -3
- package/dist/services/master-setting.service.js.map +1 -1
- package/dist/services/master-setting.service.spec.js +16 -0
- package/dist/services/master-setting.service.spec.js.map +1 -1
- package/dist/update-scheme.js +2 -10
- package/dist/update-scheme.js.map +1 -1
- package/package.json +6 -4
- package/src/templates/master/handler/master-rds.handler.ts +0 -4
- package/src/templates/master/master.module.ts +6 -18
- package/src/templates/custom-task/custom-task.module.ts +0 -18
- package/src/templates/custom-task/event/task-queue-event-factory.ts +0 -26
- package/src/templates/custom-task/my-task.controller.ts +0 -28
- package/src/templates/custom-task/my-task.service.ts +0 -99
- package/src/templates/master/dto/master-copy.dto.ts +0 -73
- package/src/templates/master/dto/master-data-create.dto.ts +0 -20
- package/src/templates/master/dto/master-data-search.dto.ts +0 -20
- package/src/templates/master/dto/master-data-update.dto.ts +0 -25
- package/src/templates/master/dto/master-rds-list.entity.ts +0 -15
- package/src/templates/master/dto/master-rds.entity.ts +0 -77
- package/src/templates/master/dto/master-setting-search.dto.ts +0 -20
- package/src/templates/master/dto/master-setting-update.dto.ts +0 -11
- package/src/templates/master/handler/master-sfn-task.event.ts +0 -3
- package/src/templates/master/handler/master-sfn-task.handler.ts +0 -334
- package/src/templates/master/master-data.controller.ts +0 -98
- package/src/templates/master/master-data.service.ts +0 -181
- package/src/templates/master/master-setting.controller.ts +0 -103
- package/src/templates/master/master-setting.service.ts +0 -201
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DataService,
|
|
3
|
-
DetailDto,
|
|
4
|
-
getUserContext,
|
|
5
|
-
IInvoke,
|
|
6
|
-
UserContext,
|
|
7
|
-
} from '@mbc-cqrs-serverless/core'
|
|
8
|
-
import { MasterSettingService } from '@mbc-cqrs-serverless/master'
|
|
9
|
-
import { CommonSettingDto } from '@mbc-cqrs-serverless/master/dist/dto'
|
|
10
|
-
import { TaskService } from '@mbc-cqrs-serverless/task'
|
|
11
|
-
import {
|
|
12
|
-
BadRequestException,
|
|
13
|
-
Injectable,
|
|
14
|
-
Logger,
|
|
15
|
-
NotFoundException,
|
|
16
|
-
} from '@nestjs/common'
|
|
17
|
-
import { Prisma } from '@prisma/client'
|
|
18
|
-
import { PrismaService } from 'src/prisma'
|
|
19
|
-
|
|
20
|
-
import { DataCopyMode, MasterCopyDto } from './dto/master-copy.dto'
|
|
21
|
-
import { MasterRdsEntity } from './dto/master-rds.entity'
|
|
22
|
-
import { MasterRdsListEntity } from './dto/master-rds-list.entity'
|
|
23
|
-
import { MasterSettingSearchDto } from './dto/master-setting-search.dto'
|
|
24
|
-
import { MasterSettingUpdateDto } from './dto/master-setting-update.dto'
|
|
25
|
-
import {
|
|
26
|
-
getOrderBys,
|
|
27
|
-
MASTER_COPY_SK_PREFIX,
|
|
28
|
-
parseId,
|
|
29
|
-
SETTING_SK_PREFIX,
|
|
30
|
-
} from './helpers'
|
|
31
|
-
|
|
32
|
-
@Injectable()
|
|
33
|
-
export class CustomMasterSettingService {
|
|
34
|
-
private readonly logger = new Logger(CustomMasterSettingService.name)
|
|
35
|
-
|
|
36
|
-
constructor(
|
|
37
|
-
private readonly masterSettingService: MasterSettingService,
|
|
38
|
-
private readonly prismaService: PrismaService,
|
|
39
|
-
private readonly dataService: DataService,
|
|
40
|
-
private readonly taskService: TaskService,
|
|
41
|
-
) {}
|
|
42
|
-
|
|
43
|
-
async list(searchDto: MasterSettingSearchDto, invokeContext: IInvoke) {
|
|
44
|
-
const userContext = getUserContext(invokeContext)
|
|
45
|
-
|
|
46
|
-
const where: Prisma.MasterWhereInput = {
|
|
47
|
-
tenantCode: this.getUserTenantCode(userContext),
|
|
48
|
-
masterType: SETTING_SK_PREFIX,
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (searchDto.isDeleted === false || searchDto.isDeleted === undefined) {
|
|
52
|
-
where.isDeleted = false
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const andConditions: Prisma.MasterWhereInput[] = []
|
|
56
|
-
|
|
57
|
-
if (searchDto.name?.trim()) {
|
|
58
|
-
andConditions.push({
|
|
59
|
-
name: { contains: searchDto.name.trim() },
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (searchDto.keyword?.trim()) {
|
|
64
|
-
andConditions.push({
|
|
65
|
-
attributes: {
|
|
66
|
-
path: 'description',
|
|
67
|
-
string_contains: searchDto.keyword.trim(),
|
|
68
|
-
},
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (searchDto.code?.trim()) {
|
|
73
|
-
andConditions.push({
|
|
74
|
-
masterCode: { contains: searchDto.code.trim() },
|
|
75
|
-
})
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (andConditions.length) {
|
|
79
|
-
where.AND = andConditions
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const { pageSize = 10, page = 1, orderBys = ['-createdAt'] } = searchDto
|
|
83
|
-
|
|
84
|
-
const [total, items] = await Promise.all([
|
|
85
|
-
this.prismaService.master.count({ where }),
|
|
86
|
-
this.prismaService.master.findMany({
|
|
87
|
-
where,
|
|
88
|
-
take: pageSize,
|
|
89
|
-
skip: pageSize * (page - 1),
|
|
90
|
-
orderBy: getOrderBys<Prisma.MasterOrderByWithRelationInput>(orderBys),
|
|
91
|
-
}),
|
|
92
|
-
])
|
|
93
|
-
|
|
94
|
-
return new MasterRdsListEntity({
|
|
95
|
-
total,
|
|
96
|
-
items: items.map((item) => new MasterRdsEntity(item)),
|
|
97
|
-
})
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
async getDetail(key: DetailDto) {
|
|
101
|
-
const data = await this.dataService.getItem(key)
|
|
102
|
-
|
|
103
|
-
if (!data) throw new NotFoundException()
|
|
104
|
-
|
|
105
|
-
return new MasterRdsEntity(data)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async create(createDto: CommonSettingDto, invokeContext: IInvoke) {
|
|
109
|
-
const userContext = getUserContext(invokeContext)
|
|
110
|
-
return await this.masterSettingService.createTenantSetting(
|
|
111
|
-
{
|
|
112
|
-
...createDto,
|
|
113
|
-
tenantCode: userContext.tenantCode,
|
|
114
|
-
},
|
|
115
|
-
{ invokeContext },
|
|
116
|
-
)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
async update(
|
|
120
|
-
key: DetailDto,
|
|
121
|
-
updateDto: MasterSettingUpdateDto,
|
|
122
|
-
invokeContext: IInvoke,
|
|
123
|
-
) {
|
|
124
|
-
const code = key.sk.split('#')[1]
|
|
125
|
-
const userContext = getUserContext(invokeContext)
|
|
126
|
-
|
|
127
|
-
return await this.masterSettingService.updateSetting(
|
|
128
|
-
key,
|
|
129
|
-
{
|
|
130
|
-
code,
|
|
131
|
-
tenantCode: userContext.tenantCode,
|
|
132
|
-
name: updateDto.name,
|
|
133
|
-
settingValue: updateDto.attributes,
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
invokeContext,
|
|
137
|
-
},
|
|
138
|
-
)
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
async delete(key: DetailDto, invokeContext: IInvoke) {
|
|
142
|
-
return this.masterSettingService.deleteSetting(key, { invokeContext })
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
async checkExistCode(code: string, invokeContext: IInvoke) {
|
|
146
|
-
const userContext = getUserContext(invokeContext)
|
|
147
|
-
|
|
148
|
-
const item = await this.prismaService.master.findFirst({
|
|
149
|
-
where: {
|
|
150
|
-
tenantCode: userContext.tenantCode,
|
|
151
|
-
masterType: SETTING_SK_PREFIX,
|
|
152
|
-
masterCode: code,
|
|
153
|
-
},
|
|
154
|
-
})
|
|
155
|
-
|
|
156
|
-
return !!item && !item.isDeleted
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
async copy(
|
|
160
|
-
masterCopyDto: MasterCopyDto,
|
|
161
|
-
opts: { invokeContext: IInvoke },
|
|
162
|
-
): Promise<any> {
|
|
163
|
-
this.logger.debug('cmd:', JSON.stringify(masterCopyDto))
|
|
164
|
-
|
|
165
|
-
const userContext = getUserContext(opts.invokeContext)
|
|
166
|
-
|
|
167
|
-
const { masterSettingId, targetTenants, dataCopyOption } = masterCopyDto
|
|
168
|
-
|
|
169
|
-
if (dataCopyOption?.mode === DataCopyMode.PARTIAL) {
|
|
170
|
-
if (!dataCopyOption.id?.length) {
|
|
171
|
-
throw new BadRequestException('Must provide ID when mode is PARTIAL.')
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const setting = await this.dataService.getItem(parseId(masterSettingId))
|
|
176
|
-
|
|
177
|
-
if (!setting || setting.isDeleted) {
|
|
178
|
-
throw new BadRequestException('Master setting does not exist')
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const item = targetTenants.map((tenant) => ({
|
|
182
|
-
...masterCopyDto,
|
|
183
|
-
targetTenants: [tenant],
|
|
184
|
-
}))
|
|
185
|
-
|
|
186
|
-
const taskItem = await this.taskService.createStepFunctionTask(
|
|
187
|
-
{
|
|
188
|
-
input: item,
|
|
189
|
-
taskType: `${MASTER_COPY_SK_PREFIX}_${masterSettingId.split('#').at(-1)}`,
|
|
190
|
-
tenantCode: userContext.tenantCode,
|
|
191
|
-
},
|
|
192
|
-
opts,
|
|
193
|
-
)
|
|
194
|
-
|
|
195
|
-
return taskItem
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
private getUserTenantCode(userContext: UserContext): string {
|
|
199
|
-
return userContext.tenantCode
|
|
200
|
-
}
|
|
201
|
-
}
|