@mbc-cqrs-serverless/cli 0.1.50-beta.0 → 0.1.51-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.
Files changed (108) hide show
  1. package/dist/actions/generate.action.js +44 -0
  2. package/dist/actions/new.action.get-package-version.spec.js +29 -0
  3. package/dist/actions/new.action.is-latest-version.spec.js +36 -0
  4. package/dist/actions/new.action.js +12 -6
  5. package/dist/actions/new.action.spec.js +84 -0
  6. package/dist/actions/new.action.update-env-local.spec.js +35 -0
  7. package/dist/actions/new.action.use-package-version.spec.js +46 -0
  8. package/dist/actions/ui.action.js +7 -5
  9. package/dist/commands/command.input.js +2 -0
  10. package/dist/commands/generate.command.js +24 -0
  11. package/dist/commands/index.js +2 -0
  12. package/dist/index.js +13 -2
  13. package/dist/runners/abstract.runner.js +44 -0
  14. package/dist/runners/schematic.runner.js +21 -0
  15. package/dist/schematics/collection.json +34 -0
  16. package/dist/schematics/index.js +17 -0
  17. package/dist/schematics/lib/controller/controller.factory.js +40 -0
  18. package/dist/schematics/lib/controller/controller.factory.spec.js +79 -0
  19. package/dist/schematics/lib/controller/files/__name@dasherize__.controller.ts +11 -0
  20. package/dist/schematics/lib/controller/schema.json +18 -0
  21. package/dist/schematics/lib/controller/units/__name@dasherize__.controller.__specFileSuffix__.ts +19 -0
  22. package/dist/schematics/lib/dto/dto.factory.js +32 -0
  23. package/dist/schematics/lib/dto/dto.factory.spec.js +128 -0
  24. package/dist/schematics/lib/dto/files/dto/__name@dasherize__-attributes.dto.ts +6 -0
  25. package/dist/schematics/lib/dto/files/dto/__name@dasherize__-command.dto.ts +16 -0
  26. package/dist/schematics/lib/dto/files/dto/__name@dasherize__-create.dto.ts +18 -0
  27. package/dist/schematics/lib/dto/files/dto/__name@dasherize__-search.dto.ts +2 -0
  28. package/dist/schematics/lib/dto/files/dto/__name@dasherize__-update.dto.ts +34 -0
  29. package/dist/schematics/lib/dto/schema.json +18 -0
  30. package/dist/schematics/lib/entity/entity.factory.js +30 -0
  31. package/dist/schematics/lib/entity/entity.factory.spec.js +86 -0
  32. package/dist/schematics/lib/entity/files/entity/__name@dasherize__-command.entity.ts +12 -0
  33. package/dist/schematics/lib/entity/files/entity/__name@dasherize__-data-list.entity.ts +12 -0
  34. package/dist/schematics/lib/entity/files/entity/__name@dasherize__-data.entity.ts +12 -0
  35. package/dist/schematics/lib/entity/schema.json +18 -0
  36. package/dist/schematics/lib/module/files/async/__name@dasherize__.controller.ts +74 -0
  37. package/dist/schematics/lib/module/files/async/__name@dasherize__.module.ts +19 -0
  38. package/dist/schematics/lib/module/files/async/__name@dasherize__.service.ts +164 -0
  39. package/dist/schematics/lib/module/files/async/dto/__name@dasherize__-attributes.dto.ts +6 -0
  40. package/dist/schematics/lib/module/files/async/dto/__name@dasherize__-command.dto.ts +16 -0
  41. package/dist/schematics/lib/module/files/async/dto/__name@dasherize__-create.dto.ts +18 -0
  42. package/dist/schematics/lib/module/files/async/dto/__name@dasherize__-search.dto.ts +2 -0
  43. package/dist/schematics/lib/module/files/async/dto/__name@dasherize__-update.dto.ts +34 -0
  44. package/dist/schematics/lib/module/files/async/entity/__name@dasherize__-command.entity.ts +12 -0
  45. package/dist/schematics/lib/module/files/async/entity/__name@dasherize__-data-list.entity.ts +12 -0
  46. package/dist/schematics/lib/module/files/async/entity/__name@dasherize__-data.entity.ts +12 -0
  47. package/dist/schematics/lib/module/files/async/handler/__name@dasherize__-rds.handler.ts +62 -0
  48. package/dist/schematics/lib/module/files/sync/__name@dasherize__.controller.ts +74 -0
  49. package/dist/schematics/lib/module/files/sync/__name@dasherize__.module.ts +19 -0
  50. package/dist/schematics/lib/module/files/sync/__name@dasherize__.service.ts +164 -0
  51. package/dist/schematics/lib/module/files/sync/dto/__name@dasherize__-attributes.dto.ts +6 -0
  52. package/dist/schematics/lib/module/files/sync/dto/__name@dasherize__-command.dto.ts +16 -0
  53. package/dist/schematics/lib/module/files/sync/dto/__name@dasherize__-create.dto.ts +18 -0
  54. package/dist/schematics/lib/module/files/sync/dto/__name@dasherize__-search.dto.ts +2 -0
  55. package/dist/schematics/lib/module/files/sync/dto/__name@dasherize__-update.dto.ts +34 -0
  56. package/dist/schematics/lib/module/files/sync/entity/__name@dasherize__-command.entity.ts +12 -0
  57. package/dist/schematics/lib/module/files/sync/entity/__name@dasherize__-data-list.entity.ts +12 -0
  58. package/dist/schematics/lib/module/files/sync/entity/__name@dasherize__-data.entity.ts +12 -0
  59. package/dist/schematics/lib/module/files/sync/handler/__name@dasherize__-rds.handler.ts +62 -0
  60. package/dist/schematics/lib/module/module.factory.js +204 -0
  61. package/dist/schematics/lib/module/module.factory.spec.js +188 -0
  62. package/dist/schematics/lib/module/schema.json +28 -0
  63. package/dist/schematics/lib/module/units/__name@dasherize__.controller.__specFileSuffix__.ts +19 -0
  64. package/dist/schematics/lib/module/units/__name@dasherize__.service.__specFileSuffix__.ts +19 -0
  65. package/dist/schematics/lib/service/files/__name@dasherize__.service.ts +12 -0
  66. package/dist/schematics/lib/service/schema.json +18 -0
  67. package/dist/schematics/lib/service/service.factory.js +40 -0
  68. package/dist/schematics/lib/service/service.factory.spec.js +81 -0
  69. package/dist/schematics/lib/service/units/__name@dasherize__.service.__specFileSuffix__.ts +19 -0
  70. package/dist/schematics/schematic.colection.js +60 -0
  71. package/dist/schematics/schematic.option.js +44 -0
  72. package/dist/schematics/utils/check-files-exist.js +13 -0
  73. package/dist/schematics/utils/index.js +17 -0
  74. package/dist/ui/index.js +18 -0
  75. package/dist/ui/logger.js +54 -0
  76. package/dist/ui/message.js +6 -0
  77. package/dist/utils/formatting.js +18 -0
  78. package/dist/utils/index.js +18 -0
  79. package/dist/utils/local-binaries.js +20 -0
  80. package/package.json +13 -4
  81. package/templates/.env.local +1 -1
  82. package/templates/README.md +1 -1
  83. package/templates/infra/README.md +6 -1
  84. package/templates/infra/libs/infra-stack.ts +1 -1
  85. package/templates/infra-local/docker-compose.yml +1 -1
  86. package/templates/infra-local/serverless.yml +19 -21
  87. package/templates/infra-local/swagger.json +396 -0
  88. package/templates/package.json +1 -0
  89. package/templates/prisma/dynamodbs/cqrs.json +1 -1
  90. package/templates/prisma/schema.prisma +4 -7
  91. package/templates/src/helpers/id.ts +12 -0
  92. package/templates/src/helpers/index.ts +1 -0
  93. package/templates/src/main.module.ts +2 -2
  94. package/templates/src/{master/dto/master-attributes.dto.ts → sample/dto/sample-attributes.dto.ts} +2 -2
  95. package/templates/src/{master/dto/master-command.dto.ts → sample/dto/sample-command.dto.ts} +4 -4
  96. package/templates/src/sample/entity/sample-command.entity.ts +13 -0
  97. package/templates/src/sample/entity/sample-data-list.entity.ts +13 -0
  98. package/templates/src/sample/entity/sample-data.entity.ts +13 -0
  99. package/templates/src/{master/handler/master-rds.handler.ts → sample/handler/sample-rds.handler.ts} +5 -7
  100. package/templates/src/{master/master.controller.ts → sample/sample.controller.ts} +22 -22
  101. package/templates/src/sample/sample.module.ts +19 -0
  102. package/templates/src/{master/master.service.ts → sample/sample.service.ts} +12 -12
  103. package/templates/test/api.http +25 -0
  104. package/templates/tsconfig.json +1 -1
  105. package/templates/src/master/entity/master-command.entity.ts +0 -13
  106. package/templates/src/master/entity/master-data-list.entity.ts +0 -13
  107. package/templates/src/master/entity/master-data.entity.ts +0 -13
  108. package/templates/src/master/master.module.ts +0 -19
@@ -0,0 +1,396 @@
1
+ {
2
+ "openapi": "3.0.0",
3
+ "paths": {
4
+ "/": {
5
+ "get": {
6
+ "operationId": "AppController_getHello",
7
+ "parameters": [
8
+ {
9
+ "in": "header",
10
+ "required": false,
11
+ "name": "x-tenant-code",
12
+ "schema": {}
13
+ }
14
+ ],
15
+ "responses": { "200": { "description": "" } },
16
+ "tags": ["main"]
17
+ }
18
+ },
19
+ "/api/sample": {
20
+ "post": {
21
+ "operationId": "SampleController_publishCommand",
22
+ "parameters": [
23
+ {
24
+ "in": "header",
25
+ "required": false,
26
+ "name": "x-tenant-code",
27
+ "schema": {}
28
+ }
29
+ ],
30
+ "requestBody": {
31
+ "required": true,
32
+ "content": {
33
+ "application/json": {
34
+ "schema": { "$ref": "#/components/schemas/SampleCommandDto" }
35
+ }
36
+ }
37
+ },
38
+ "responses": {
39
+ "201": {
40
+ "description": "",
41
+ "content": {
42
+ "application/json": {
43
+ "schema": { "$ref": "#/components/schemas/SampleDataEntity" }
44
+ }
45
+ }
46
+ }
47
+ },
48
+ "tags": ["sample"]
49
+ }
50
+ },
51
+ "/api/sample/command/{pk}/{sk}": {
52
+ "get": {
53
+ "operationId": "SampleController_getCommand",
54
+ "parameters": [
55
+ {
56
+ "name": "pk",
57
+ "required": true,
58
+ "in": "path",
59
+ "schema": { "type": "string" }
60
+ },
61
+ {
62
+ "name": "sk",
63
+ "required": true,
64
+ "in": "path",
65
+ "schema": { "type": "string" }
66
+ },
67
+ {
68
+ "in": "header",
69
+ "required": false,
70
+ "name": "x-tenant-code",
71
+ "schema": {}
72
+ }
73
+ ],
74
+ "responses": {
75
+ "200": {
76
+ "description": "",
77
+ "content": {
78
+ "application/json": {
79
+ "schema": { "$ref": "#/components/schemas/SampleCommandEntity" }
80
+ }
81
+ }
82
+ }
83
+ },
84
+ "tags": ["sample"]
85
+ }
86
+ },
87
+ "/api/sample/data/{pk}/{sk}": {
88
+ "get": {
89
+ "operationId": "SampleController_getData",
90
+ "parameters": [
91
+ {
92
+ "name": "pk",
93
+ "required": true,
94
+ "in": "path",
95
+ "schema": { "type": "string" }
96
+ },
97
+ {
98
+ "name": "sk",
99
+ "required": true,
100
+ "in": "path",
101
+ "schema": { "type": "string" }
102
+ },
103
+ {
104
+ "in": "header",
105
+ "required": false,
106
+ "name": "x-tenant-code",
107
+ "schema": {}
108
+ }
109
+ ],
110
+ "responses": {
111
+ "200": {
112
+ "description": "",
113
+ "content": {
114
+ "application/json": {
115
+ "schema": { "$ref": "#/components/schemas/SampleDataEntity" }
116
+ }
117
+ }
118
+ }
119
+ },
120
+ "tags": ["sample"]
121
+ }
122
+ },
123
+ "/api/sample/data/{pk}": {
124
+ "get": {
125
+ "operationId": "SampleController_listDataByPk",
126
+ "parameters": [
127
+ {
128
+ "name": "pk",
129
+ "required": true,
130
+ "in": "path",
131
+ "schema": { "type": "string" }
132
+ },
133
+ {
134
+ "in": "header",
135
+ "required": false,
136
+ "name": "x-tenant-code",
137
+ "schema": {}
138
+ }
139
+ ],
140
+ "responses": {
141
+ "200": {
142
+ "description": "",
143
+ "content": {
144
+ "application/json": {
145
+ "schema": {
146
+ "$ref": "#/components/schemas/SampleDataListEntity"
147
+ }
148
+ }
149
+ }
150
+ }
151
+ },
152
+ "tags": ["sample"]
153
+ }
154
+ },
155
+ "/api/sample/data": {
156
+ "get": {
157
+ "operationId": "SampleController_searchData",
158
+ "parameters": [
159
+ {
160
+ "name": "page",
161
+ "required": false,
162
+ "in": "query",
163
+ "schema": { "type": "number" }
164
+ },
165
+ {
166
+ "name": "pageSize",
167
+ "required": false,
168
+ "in": "query",
169
+ "schema": { "type": "number" }
170
+ },
171
+ {
172
+ "name": "keyword",
173
+ "required": false,
174
+ "in": "query",
175
+ "schema": { "type": "string" }
176
+ },
177
+ {
178
+ "name": "id",
179
+ "required": false,
180
+ "in": "query",
181
+ "schema": { "type": "string" }
182
+ },
183
+ {
184
+ "name": "pk",
185
+ "required": false,
186
+ "in": "query",
187
+ "schema": { "type": "string" }
188
+ },
189
+ {
190
+ "name": "sk",
191
+ "required": false,
192
+ "in": "query",
193
+ "schema": { "type": "string" }
194
+ },
195
+ {
196
+ "name": "orderBys",
197
+ "required": false,
198
+ "in": "query",
199
+ "schema": { "type": "array", "items": { "type": "string" } }
200
+ },
201
+ {
202
+ "in": "header",
203
+ "required": false,
204
+ "name": "x-tenant-code",
205
+ "schema": {}
206
+ }
207
+ ],
208
+ "responses": {
209
+ "200": {
210
+ "description": "",
211
+ "content": {
212
+ "application/json": {
213
+ "schema": {
214
+ "$ref": "#/components/schemas/SampleDataListEntity"
215
+ }
216
+ }
217
+ }
218
+ }
219
+ },
220
+ "tags": ["sample"]
221
+ }
222
+ }
223
+ },
224
+ "info": {
225
+ "title": "serverless",
226
+ "description": "The serverless API",
227
+ "version": "1.0.0",
228
+ "contact": {}
229
+ },
230
+ "tags": [],
231
+ "servers": [{ "url": "http://localhost:3000/", "description": "local" }],
232
+ "components": {
233
+ "securitySchemes": {
234
+ "Api-Key": { "type": "apiKey", "in": "header", "name": "Authorization" }
235
+ },
236
+ "schemas": {
237
+ "SampleAttributes": {
238
+ "type": "object",
239
+ "properties": { "value": { "type": "object" } },
240
+ "required": ["value"]
241
+ },
242
+ "SampleCommandDto": {
243
+ "type": "object",
244
+ "properties": {
245
+ "pk": { "type": "string" },
246
+ "sk": { "type": "string" },
247
+ "id": { "type": "string" },
248
+ "code": { "type": "string" },
249
+ "name": { "type": "string" },
250
+ "version": { "type": "number" },
251
+ "tenantCode": { "type": "string" },
252
+ "type": { "type": "string" },
253
+ "seq": { "type": "number" },
254
+ "ttl": { "type": "number" },
255
+ "isDeleted": { "type": "boolean" },
256
+ "attributes": { "$ref": "#/components/schemas/SampleAttributes" }
257
+ },
258
+ "required": [
259
+ "pk",
260
+ "sk",
261
+ "id",
262
+ "code",
263
+ "name",
264
+ "version",
265
+ "tenantCode",
266
+ "type",
267
+ "attributes"
268
+ ]
269
+ },
270
+ "SampleDataEntity": {
271
+ "type": "object",
272
+ "properties": {
273
+ "cpk": { "type": "string" },
274
+ "csk": { "type": "string" },
275
+ "source": { "type": "string" },
276
+ "requestId": { "type": "string" },
277
+ "createdAt": { "format": "date-time", "type": "string" },
278
+ "updatedAt": { "format": "date-time", "type": "string" },
279
+ "createdBy": { "type": "string" },
280
+ "updatedBy": { "type": "string" },
281
+ "createdIp": { "type": "string" },
282
+ "updatedIp": { "type": "string" },
283
+ "pk": { "type": "string" },
284
+ "sk": { "type": "string" },
285
+ "id": { "type": "string" },
286
+ "code": { "type": "string" },
287
+ "name": { "type": "string" },
288
+ "version": { "type": "number" },
289
+ "tenantCode": { "type": "string" },
290
+ "type": { "type": "string" },
291
+ "seq": { "type": "number" },
292
+ "ttl": { "type": "number" },
293
+ "isDeleted": { "type": "boolean" },
294
+ "attributes": { "$ref": "#/components/schemas/SampleAttributes" }
295
+ },
296
+ "required": [
297
+ "pk",
298
+ "sk",
299
+ "id",
300
+ "code",
301
+ "name",
302
+ "version",
303
+ "tenantCode",
304
+ "type",
305
+ "attributes"
306
+ ]
307
+ },
308
+ "SampleCommandEntity": {
309
+ "type": "object",
310
+ "properties": {
311
+ "source": { "type": "string" },
312
+ "isDeleted": { "type": "boolean" },
313
+ "status": { "type": "string" },
314
+ "requestId": { "type": "string" },
315
+ "createdAt": { "format": "date-time", "type": "string" },
316
+ "updatedAt": { "format": "date-time", "type": "string" },
317
+ "createdBy": { "type": "string" },
318
+ "updatedBy": { "type": "string" },
319
+ "createdIp": { "type": "string" },
320
+ "updatedIp": { "type": "string" },
321
+ "pk": { "type": "string" },
322
+ "sk": { "type": "string" },
323
+ "id": { "type": "string" },
324
+ "code": { "type": "string" },
325
+ "name": { "type": "string" },
326
+ "version": { "type": "number" },
327
+ "tenantCode": { "type": "string" },
328
+ "type": { "type": "string" },
329
+ "seq": { "type": "number" },
330
+ "ttl": { "type": "number" },
331
+ "attributes": { "$ref": "#/components/schemas/SampleAttributes" }
332
+ },
333
+ "required": [
334
+ "pk",
335
+ "sk",
336
+ "id",
337
+ "code",
338
+ "name",
339
+ "version",
340
+ "tenantCode",
341
+ "type",
342
+ "attributes"
343
+ ]
344
+ },
345
+ "DataEntity": {
346
+ "type": "object",
347
+ "properties": {
348
+ "cpk": { "type": "string" },
349
+ "csk": { "type": "string" },
350
+ "source": { "type": "string" },
351
+ "requestId": { "type": "string" },
352
+ "createdAt": { "format": "date-time", "type": "string" },
353
+ "updatedAt": { "format": "date-time", "type": "string" },
354
+ "createdBy": { "type": "string" },
355
+ "updatedBy": { "type": "string" },
356
+ "createdIp": { "type": "string" },
357
+ "updatedIp": { "type": "string" },
358
+ "pk": { "type": "string" },
359
+ "sk": { "type": "string" },
360
+ "id": { "type": "string" },
361
+ "code": { "type": "string" },
362
+ "name": { "type": "string" },
363
+ "version": { "type": "number" },
364
+ "tenantCode": { "type": "string" },
365
+ "type": { "type": "string" },
366
+ "seq": { "type": "number" },
367
+ "ttl": { "type": "number" },
368
+ "isDeleted": { "type": "boolean" }
369
+ },
370
+ "required": [
371
+ "pk",
372
+ "sk",
373
+ "id",
374
+ "code",
375
+ "name",
376
+ "version",
377
+ "tenantCode",
378
+ "type"
379
+ ]
380
+ },
381
+ "SampleDataListEntity": {
382
+ "type": "object",
383
+ "properties": {
384
+ "total": { "type": "number" },
385
+ "lastSk": { "type": "string" },
386
+ "items": {
387
+ "type": "array",
388
+ "items": { "$ref": "#/components/schemas/DataEntity" }
389
+ }
390
+ },
391
+ "required": ["items"]
392
+ }
393
+ }
394
+ },
395
+ "security": [{ "Api-Key": [] }]
396
+ }
@@ -45,6 +45,7 @@
45
45
  "prisma": "^5.7.1"
46
46
  },
47
47
  "devDependencies": {
48
+ "@golevelup/ts-jest": "^0.6.1",
48
49
  "@mbc-cqrs-serverless/cli": "",
49
50
  "@nestjs/cli": "^10.2.1",
50
51
  "@nestjs/common": "^10.3.0",
@@ -1 +1 @@
1
- ["master"]
1
+ ["sample"]
@@ -13,14 +13,12 @@ datasource db {
13
13
  relationMode = "prisma"
14
14
  }
15
15
 
16
- model Master {
16
+ model Sample {
17
17
  id String @id
18
18
  cpk String // コマンド用PK
19
19
  csk String // コマンド用SK
20
- pk String // データ用PK, MASTER#tenantCode (テナントコード)
20
+ pk String // データ用PK, SAMPLE#tenantCode (テナントコード)
21
21
  sk String // データ用SK, マスタ種別コード#マスタコード
22
- masterTypeCode String @map("master_type_code") // マスタ種別コード, 【共通マスタ】 or 【テナント固有マスタ】
23
- masterCode String @map("master_code") // マスタコード
24
22
  tenantCode String @map("tenant_code") // テナントコード, 【テナントコードマスタ】
25
23
  seq Int @default(0) // 並び順, 採番機能を使用する
26
24
  code String // レコードのコード, マスタ種別コード#マスタコード
@@ -34,12 +32,11 @@ model Master {
34
32
  updatedIp String @default("") @map("updated_ip") // 更新IP, IPv6も考慮する
35
33
  updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamp(0) // 更新日時
36
34
 
37
- atttributesMaster Json? @map("atttributes_master")
35
+ attributes Json? @map("attributes")
38
36
 
39
37
  @@unique([cpk, csk])
40
38
  @@unique([pk, sk])
41
39
  @@unique([tenantCode, code])
42
- @@unique([tenantCode, masterTypeCode, masterCode])
43
40
  @@index([tenantCode, name])
44
- @@map("masters")
41
+ @@map("samples")
45
42
  }
@@ -0,0 +1,12 @@
1
+ import { KEY_SEPARATOR } from '@mbc-cqrs-serverless/core'
2
+
3
+ export function parsePk(pk: string): { type: string; tenantCode: string } {
4
+ if (pk.split(KEY_SEPARATOR).length !== 2) {
5
+ throw new Error('Invalid PK')
6
+ }
7
+ const [type, tenantCode] = pk.split(KEY_SEPARATOR)
8
+ return {
9
+ type,
10
+ tenantCode,
11
+ }
12
+ }
@@ -1 +1,2 @@
1
1
  export * from './get-order'
2
+ export * from './id'
@@ -1,8 +1,8 @@
1
1
  import { Module } from '@nestjs/common'
2
2
 
3
3
  import { CustomEventFactory } from './event-factory'
4
- import { MasterModule } from './master/master.module'
5
4
  import { prismaLoggingMiddleware, PrismaModule } from './prisma'
5
+ import { SampleModule } from './sample/sample.module'
6
6
 
7
7
  @Module({
8
8
  imports: [
@@ -19,7 +19,7 @@ import { prismaLoggingMiddleware, PrismaModule } from './prisma'
19
19
  explicitConnect: false,
20
20
  },
21
21
  }),
22
- MasterModule,
22
+ SampleModule,
23
23
  ],
24
24
  providers: [CustomEventFactory],
25
25
  })
@@ -1,6 +1,6 @@
1
1
  import { IsObject } from 'class-validator'
2
2
 
3
- export class MasterAttributes {
3
+ export class SampleAttributes {
4
4
  @IsObject()
5
- master: object
5
+ value: object
6
6
  }
@@ -2,11 +2,11 @@ import { CommandDto } from '@mbc-cqrs-serverless/core'
2
2
  import { Type } from 'class-transformer'
3
3
  import { IsOptional, ValidateNested } from 'class-validator'
4
4
 
5
- import { MasterAttributes } from './master-attributes.dto'
5
+ import { SampleAttributes } from './sample-attributes.dto'
6
6
 
7
- export class MasterCommandDto extends CommandDto {
8
- @Type(() => MasterAttributes)
7
+ export class SampleCommandDto extends CommandDto {
8
+ @Type(() => SampleAttributes)
9
9
  @ValidateNested()
10
10
  @IsOptional()
11
- attributes: MasterAttributes
11
+ attributes: SampleAttributes
12
12
  }
@@ -0,0 +1,13 @@
1
+ import { CommandEntity } from '@mbc-cqrs-serverless/core'
2
+
3
+ import { SampleAttributes } from '../dto/sample-attributes.dto'
4
+
5
+ export class SampleCommandEntity extends CommandEntity {
6
+ attributes: SampleAttributes
7
+
8
+ constructor(partial: Partial<SampleCommandEntity>) {
9
+ super()
10
+
11
+ Object.assign(this, partial)
12
+ }
13
+ }
@@ -0,0 +1,13 @@
1
+ import { DataListEntity } from '@mbc-cqrs-serverless/core'
2
+
3
+ import { SampleDataEntity } from './sample-data.entity'
4
+
5
+ export class SampleDataListEntity extends DataListEntity {
6
+ items: SampleDataEntity[]
7
+
8
+ constructor(partial: Partial<SampleDataListEntity>) {
9
+ super(partial)
10
+
11
+ Object.assign(this, partial)
12
+ }
13
+ }
@@ -0,0 +1,13 @@
1
+ import { DataEntity } from '@mbc-cqrs-serverless/core'
2
+
3
+ import { SampleAttributes } from '../dto/sample-attributes.dto'
4
+
5
+ export class SampleDataEntity extends DataEntity {
6
+ attributes: SampleAttributes
7
+
8
+ constructor(partial: Partial<SampleDataEntity>) {
9
+ super(partial)
10
+
11
+ Object.assign(this, partial)
12
+ }
13
+ }
@@ -7,15 +7,15 @@ import { Injectable, Logger } from '@nestjs/common'
7
7
  import { PrismaService } from 'src/prisma'
8
8
 
9
9
  @Injectable()
10
- export class MasterDataSyncRdsHandler implements IDataSyncHandler {
11
- private readonly logger = new Logger(MasterDataSyncRdsHandler.name)
10
+ export class SampleDataSyncRdsHandler implements IDataSyncHandler {
11
+ private readonly logger = new Logger(SampleDataSyncRdsHandler.name)
12
12
 
13
13
  constructor(private readonly prismaService: PrismaService) {}
14
14
 
15
15
  async up(cmd: CommandModel): Promise<any> {
16
16
  this.logger.debug(cmd)
17
17
  const sk = removeSortKeyVersion(cmd.sk)
18
- await this.prismaService.master.upsert({
18
+ await this.prismaService.sample.upsert({
19
19
  where: {
20
20
  id: cmd.id,
21
21
  },
@@ -24,7 +24,7 @@ export class MasterDataSyncRdsHandler implements IDataSyncHandler {
24
24
  name: cmd.name,
25
25
  version: cmd.version,
26
26
  seq: cmd.seq,
27
- atttributesMaster: cmd.attributes?.master,
27
+ attributes: cmd.attributes?.value,
28
28
  isDeleted: cmd.isDeleted || false,
29
29
  updatedAt: cmd.updatedAt,
30
30
  updatedBy: cmd.updatedBy,
@@ -36,14 +36,12 @@ export class MasterDataSyncRdsHandler implements IDataSyncHandler {
36
36
  csk: cmd.sk,
37
37
  pk: cmd.pk,
38
38
  sk,
39
- masterTypeCode: sk.substring(0, sk.indexOf('#')),
40
- masterCode: sk.substring(sk.indexOf('#') + 1),
41
39
  code: sk,
42
40
  name: cmd.name,
43
41
  version: cmd.version,
44
42
  tenantCode: cmd.tenantCode,
45
43
  seq: cmd.seq,
46
- atttributesMaster: cmd.attributes?.master,
44
+ attributes: cmd.attributes?.value,
47
45
  createdAt: cmd.createdAt,
48
46
  createdBy: cmd.createdBy,
49
47
  createdIp: cmd.createdIp,