@mbc-cqrs-serverless/cli 0.1.49-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.
- package/README.md +94 -63
- package/dist/actions/generate.action.js +44 -0
- package/dist/actions/new.action.get-package-version.spec.js +29 -0
- package/dist/actions/new.action.is-latest-version.spec.js +36 -0
- package/dist/actions/new.action.js +12 -6
- package/dist/actions/new.action.spec.js +84 -0
- package/dist/actions/new.action.update-env-local.spec.js +35 -0
- package/dist/actions/new.action.use-package-version.spec.js +46 -0
- package/dist/actions/ui.action.js +7 -5
- package/dist/commands/command.input.js +2 -0
- package/dist/commands/generate.command.js +24 -0
- package/dist/commands/index.js +2 -0
- package/dist/index.js +13 -2
- package/dist/runners/abstract.runner.js +44 -0
- package/dist/runners/schematic.runner.js +21 -0
- package/dist/schematics/collection.json +34 -0
- package/dist/schematics/index.js +17 -0
- package/dist/schematics/lib/controller/controller.factory.js +40 -0
- package/dist/schematics/lib/controller/controller.factory.spec.js +79 -0
- package/dist/schematics/lib/controller/files/__name@dasherize__.controller.ts +11 -0
- package/dist/schematics/lib/controller/schema.json +18 -0
- package/dist/schematics/lib/controller/units/__name@dasherize__.controller.__specFileSuffix__.ts +19 -0
- package/dist/schematics/lib/dto/dto.factory.js +32 -0
- package/dist/schematics/lib/dto/dto.factory.spec.js +128 -0
- package/dist/schematics/lib/dto/files/dto/__name@dasherize__-attributes.dto.ts +6 -0
- package/dist/schematics/lib/dto/files/dto/__name@dasherize__-command.dto.ts +16 -0
- package/dist/schematics/lib/dto/files/dto/__name@dasherize__-create.dto.ts +18 -0
- package/dist/schematics/lib/dto/files/dto/__name@dasherize__-search.dto.ts +2 -0
- package/dist/schematics/lib/dto/files/dto/__name@dasherize__-update.dto.ts +34 -0
- package/dist/schematics/lib/dto/schema.json +18 -0
- package/dist/schematics/lib/entity/entity.factory.js +30 -0
- package/dist/schematics/lib/entity/entity.factory.spec.js +86 -0
- package/dist/schematics/lib/entity/files/entity/__name@dasherize__-command.entity.ts +12 -0
- package/dist/schematics/lib/entity/files/entity/__name@dasherize__-data-list.entity.ts +12 -0
- package/dist/schematics/lib/entity/files/entity/__name@dasherize__-data.entity.ts +12 -0
- package/dist/schematics/lib/entity/schema.json +18 -0
- package/dist/schematics/lib/module/files/async/__name@dasherize__.controller.ts +74 -0
- package/dist/schematics/lib/module/files/async/__name@dasherize__.module.ts +19 -0
- package/dist/schematics/lib/module/files/async/__name@dasherize__.service.ts +164 -0
- package/dist/schematics/lib/module/files/async/dto/__name@dasherize__-attributes.dto.ts +6 -0
- package/dist/schematics/lib/module/files/async/dto/__name@dasherize__-command.dto.ts +16 -0
- package/dist/schematics/lib/module/files/async/dto/__name@dasherize__-create.dto.ts +18 -0
- package/dist/schematics/lib/module/files/async/dto/__name@dasherize__-search.dto.ts +2 -0
- package/dist/schematics/lib/module/files/async/dto/__name@dasherize__-update.dto.ts +34 -0
- package/dist/schematics/lib/module/files/async/entity/__name@dasherize__-command.entity.ts +12 -0
- package/dist/schematics/lib/module/files/async/entity/__name@dasherize__-data-list.entity.ts +12 -0
- package/dist/schematics/lib/module/files/async/entity/__name@dasherize__-data.entity.ts +12 -0
- package/dist/schematics/lib/module/files/async/handler/__name@dasherize__-rds.handler.ts +62 -0
- package/dist/schematics/lib/module/files/sync/__name@dasherize__.controller.ts +74 -0
- package/dist/schematics/lib/module/files/sync/__name@dasherize__.module.ts +19 -0
- package/dist/schematics/lib/module/files/sync/__name@dasherize__.service.ts +164 -0
- package/dist/schematics/lib/module/files/sync/dto/__name@dasherize__-attributes.dto.ts +6 -0
- package/dist/schematics/lib/module/files/sync/dto/__name@dasherize__-command.dto.ts +16 -0
- package/dist/schematics/lib/module/files/sync/dto/__name@dasherize__-create.dto.ts +18 -0
- package/dist/schematics/lib/module/files/sync/dto/__name@dasherize__-search.dto.ts +2 -0
- package/dist/schematics/lib/module/files/sync/dto/__name@dasherize__-update.dto.ts +34 -0
- package/dist/schematics/lib/module/files/sync/entity/__name@dasherize__-command.entity.ts +12 -0
- package/dist/schematics/lib/module/files/sync/entity/__name@dasherize__-data-list.entity.ts +12 -0
- package/dist/schematics/lib/module/files/sync/entity/__name@dasherize__-data.entity.ts +12 -0
- package/dist/schematics/lib/module/files/sync/handler/__name@dasherize__-rds.handler.ts +62 -0
- package/dist/schematics/lib/module/module.factory.js +204 -0
- package/dist/schematics/lib/module/module.factory.spec.js +188 -0
- package/dist/schematics/lib/module/schema.json +28 -0
- package/dist/schematics/lib/module/units/__name@dasherize__.controller.__specFileSuffix__.ts +19 -0
- package/dist/schematics/lib/module/units/__name@dasherize__.service.__specFileSuffix__.ts +19 -0
- package/dist/schematics/lib/service/files/__name@dasherize__.service.ts +12 -0
- package/dist/schematics/lib/service/schema.json +18 -0
- package/dist/schematics/lib/service/service.factory.js +40 -0
- package/dist/schematics/lib/service/service.factory.spec.js +81 -0
- package/dist/schematics/lib/service/units/__name@dasherize__.service.__specFileSuffix__.ts +19 -0
- package/dist/schematics/schematic.colection.js +60 -0
- package/dist/schematics/schematic.option.js +44 -0
- package/dist/schematics/utils/check-files-exist.js +13 -0
- package/dist/schematics/utils/index.js +17 -0
- package/dist/ui/index.js +18 -0
- package/dist/ui/logger.js +54 -0
- package/dist/ui/message.js +6 -0
- package/dist/utils/formatting.js +18 -0
- package/dist/utils/index.js +18 -0
- package/dist/utils/local-binaries.js +20 -0
- package/package.json +14 -5
- package/templates/.env.local +1 -1
- package/templates/README.md +1 -1
- package/templates/infra/README.md +6 -1
- package/templates/infra/libs/infra-stack.ts +1 -1
- package/templates/infra-local/docker-compose.yml +1 -1
- package/templates/infra-local/serverless.yml +19 -21
- package/templates/infra-local/swagger.json +396 -0
- package/templates/package.json +1 -0
- package/templates/prisma/dynamodbs/cqrs.json +1 -1
- package/templates/prisma/schema.prisma +4 -7
- package/templates/src/helpers/id.ts +12 -0
- package/templates/src/helpers/index.ts +1 -0
- package/templates/src/main.module.ts +2 -2
- package/templates/src/{master/dto/master-attributes.dto.ts → sample/dto/sample-attributes.dto.ts} +2 -2
- package/templates/src/{master/dto/master-command.dto.ts → sample/dto/sample-command.dto.ts} +4 -4
- package/templates/src/sample/entity/sample-command.entity.ts +13 -0
- package/templates/src/sample/entity/sample-data-list.entity.ts +13 -0
- package/templates/src/sample/entity/sample-data.entity.ts +13 -0
- package/templates/src/{master/handler/master-rds.handler.ts → sample/handler/sample-rds.handler.ts} +5 -7
- package/templates/src/{master/master.controller.ts → sample/sample.controller.ts} +22 -22
- package/templates/src/sample/sample.module.ts +19 -0
- package/templates/src/{master/master.service.ts → sample/sample.service.ts} +12 -12
- package/templates/test/api.http +25 -0
- package/templates/tsconfig.json +1 -1
- package/templates/src/master/entity/master-command.entity.ts +0 -13
- package/templates/src/master/entity/master-data-list.entity.ts +0 -13
- package/templates/src/master/entity/master-data.entity.ts +0 -13
- package/templates/src/master/master.module.ts +0 -19
|
@@ -13,14 +13,12 @@ datasource db {
|
|
|
13
13
|
relationMode = "prisma"
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
model
|
|
16
|
+
model Sample {
|
|
17
17
|
id String @id
|
|
18
18
|
cpk String // コマンド用PK
|
|
19
19
|
csk String // コマンド用SK
|
|
20
|
-
pk String // データ用PK,
|
|
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
|
-
|
|
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("
|
|
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,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
|
-
|
|
22
|
+
SampleModule,
|
|
23
23
|
],
|
|
24
24
|
providers: [CustomEventFactory],
|
|
25
25
|
})
|
|
@@ -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 {
|
|
5
|
+
import { SampleAttributes } from './sample-attributes.dto'
|
|
6
6
|
|
|
7
|
-
export class
|
|
8
|
-
@Type(() =>
|
|
7
|
+
export class SampleCommandDto extends CommandDto {
|
|
8
|
+
@Type(() => SampleAttributes)
|
|
9
9
|
@ValidateNested()
|
|
10
10
|
@IsOptional()
|
|
11
|
-
attributes:
|
|
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
|
+
}
|
package/templates/src/{master/handler/master-rds.handler.ts → sample/handler/sample-rds.handler.ts}
RENAMED
|
@@ -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
|
|
11
|
-
private readonly logger = new Logger(
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
44
|
+
attributes: cmd.attributes?.value,
|
|
47
45
|
createdAt: cmd.createdAt,
|
|
48
46
|
createdBy: cmd.createdBy,
|
|
49
47
|
createdIp: cmd.createdIp,
|
|
@@ -18,68 +18,68 @@ import {
|
|
|
18
18
|
} from '@nestjs/common'
|
|
19
19
|
import { ApiTags } from '@nestjs/swagger'
|
|
20
20
|
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
21
|
+
import { SampleCommandDto } from './dto/sample-command.dto'
|
|
22
|
+
import { SampleCommandEntity } from './entity/sample-command.entity'
|
|
23
|
+
import { SampleDataEntity } from './entity/sample-data.entity'
|
|
24
|
+
import { SampleDataListEntity } from './entity/sample-data-list.entity'
|
|
25
|
+
import { SampleService } from './sample.service'
|
|
26
26
|
|
|
27
|
-
@Controller('api/
|
|
28
|
-
@ApiTags('
|
|
29
|
-
export class
|
|
30
|
-
private readonly logger = new Logger(
|
|
27
|
+
@Controller('api/sample')
|
|
28
|
+
@ApiTags('sample')
|
|
29
|
+
export class SampleController {
|
|
30
|
+
private readonly logger = new Logger(SampleController.name)
|
|
31
31
|
|
|
32
32
|
constructor(
|
|
33
33
|
private readonly commandService: CommandService,
|
|
34
34
|
private readonly dataService: DataService,
|
|
35
|
-
private readonly
|
|
35
|
+
private readonly sampleService: SampleService,
|
|
36
36
|
) {}
|
|
37
37
|
|
|
38
38
|
@Post('/')
|
|
39
39
|
async publishCommand(
|
|
40
40
|
@INVOKE_CONTEXT() invokeContext: IInvoke,
|
|
41
|
-
@Body()
|
|
42
|
-
): Promise<
|
|
43
|
-
this.logger.debug('cmd:',
|
|
41
|
+
@Body() sampleDto: SampleCommandDto,
|
|
42
|
+
): Promise<SampleDataEntity> {
|
|
43
|
+
this.logger.debug('cmd:', sampleDto)
|
|
44
44
|
this.logger.debug('commandService:' + this.commandService.tableName)
|
|
45
|
-
const item = await this.commandService.publishAsync(
|
|
45
|
+
const item = await this.commandService.publishAsync(sampleDto, {
|
|
46
46
|
invokeContext,
|
|
47
47
|
})
|
|
48
|
-
return new
|
|
48
|
+
return new SampleDataEntity(item as SampleDataEntity)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
@Get('command/:pk/:sk')
|
|
52
52
|
async getCommand(
|
|
53
53
|
@Param() detailDto: DetailDto,
|
|
54
|
-
): Promise<
|
|
54
|
+
): Promise<SampleCommandEntity> {
|
|
55
55
|
this.logger.debug('commandService:' + this.commandService.tableName)
|
|
56
56
|
const item = await this.commandService.getItem(detailDto)
|
|
57
57
|
if (!item) {
|
|
58
58
|
throw new NotFoundException()
|
|
59
59
|
}
|
|
60
60
|
this.logger.debug('item:', item)
|
|
61
|
-
return new
|
|
61
|
+
return new SampleCommandEntity(item as SampleCommandEntity)
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
@Get('data/:pk/:sk')
|
|
65
|
-
async getData(@Param() detailDto: DetailDto): Promise<
|
|
65
|
+
async getData(@Param() detailDto: DetailDto): Promise<SampleDataEntity> {
|
|
66
66
|
this.logger.debug('dataService:' + this.dataService.tableName)
|
|
67
67
|
const item = await this.dataService.getItem(detailDto)
|
|
68
68
|
if (!item) {
|
|
69
69
|
throw new NotFoundException()
|
|
70
70
|
}
|
|
71
71
|
this.logger.debug('item:', item)
|
|
72
|
-
return new
|
|
72
|
+
return new SampleDataEntity(item as SampleDataEntity)
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
@Get('data/:pk')
|
|
76
|
-
async listDataByPk(@Param('pk') pk: string): Promise<
|
|
76
|
+
async listDataByPk(@Param('pk') pk: string): Promise<SampleDataListEntity> {
|
|
77
77
|
const res = await this.dataService.listItemsByPk(pk)
|
|
78
|
-
return new
|
|
78
|
+
return new SampleDataListEntity(res as SampleDataListEntity)
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
@Get('data')
|
|
82
82
|
async searchData(@Query() searchDto: SearchDto) {
|
|
83
|
-
return await this.
|
|
83
|
+
return await this.sampleService.searchData(searchDto)
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CommandModule } from '@mbc-cqrs-serverless/core'
|
|
2
|
+
import { Module } from '@nestjs/common'
|
|
3
|
+
|
|
4
|
+
import { SampleDataSyncRdsHandler } from './handler/sample-rds.handler'
|
|
5
|
+
import { SampleController } from './sample.controller'
|
|
6
|
+
import { SampleService } from './sample.service'
|
|
7
|
+
|
|
8
|
+
@Module({
|
|
9
|
+
imports: [
|
|
10
|
+
CommandModule.register({
|
|
11
|
+
tableName: 'sample',
|
|
12
|
+
dataSyncHandlers: [SampleDataSyncRdsHandler],
|
|
13
|
+
}),
|
|
14
|
+
],
|
|
15
|
+
controllers: [SampleController],
|
|
16
|
+
providers: [SampleService],
|
|
17
|
+
exports: [SampleService],
|
|
18
|
+
})
|
|
19
|
+
export class SampleModule {}
|
|
@@ -4,17 +4,17 @@ import { Prisma } from '@prisma/client'
|
|
|
4
4
|
import { getOrderBys } from 'src/helpers'
|
|
5
5
|
import { PrismaService } from 'src/prisma'
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { SampleDataEntity } from './entity/sample-data.entity'
|
|
8
|
+
import { SampleDataListEntity } from './entity/sample-data-list.entity'
|
|
9
9
|
|
|
10
10
|
@Injectable()
|
|
11
|
-
export class
|
|
12
|
-
private readonly logger = new Logger(
|
|
11
|
+
export class SampleService {
|
|
12
|
+
private readonly logger = new Logger(SampleService.name)
|
|
13
13
|
|
|
14
14
|
constructor(private readonly prismaService: PrismaService) {}
|
|
15
15
|
|
|
16
|
-
async searchData(searchDto: SearchDto): Promise<
|
|
17
|
-
const where: Prisma.
|
|
16
|
+
async searchData(searchDto: SearchDto): Promise<SampleDataListEntity> {
|
|
17
|
+
const where: Prisma.SampleWhereInput = {
|
|
18
18
|
isDeleted: false,
|
|
19
19
|
}
|
|
20
20
|
if (searchDto.keyword?.trim()) {
|
|
@@ -33,23 +33,23 @@ export class MasterService {
|
|
|
33
33
|
const { pageSize = 10, page = 1, orderBys = ['-createdAt'] } = searchDto
|
|
34
34
|
|
|
35
35
|
const [total, items] = await Promise.all([
|
|
36
|
-
this.prismaService.
|
|
37
|
-
this.prismaService.
|
|
36
|
+
this.prismaService.sample.count({ where }),
|
|
37
|
+
this.prismaService.sample.findMany({
|
|
38
38
|
where,
|
|
39
39
|
take: pageSize,
|
|
40
40
|
skip: pageSize * (page - 1),
|
|
41
|
-
orderBy: getOrderBys<Prisma.
|
|
41
|
+
orderBy: getOrderBys<Prisma.SampleOrderByWithRelationInput>(orderBys),
|
|
42
42
|
}),
|
|
43
43
|
])
|
|
44
44
|
|
|
45
|
-
return new
|
|
45
|
+
return new SampleDataListEntity({
|
|
46
46
|
total,
|
|
47
47
|
items: items.map(
|
|
48
48
|
(item) =>
|
|
49
|
-
new
|
|
49
|
+
new SampleDataEntity({
|
|
50
50
|
...item,
|
|
51
51
|
attributes: {
|
|
52
|
-
|
|
52
|
+
value: item.attributes as object,
|
|
53
53
|
},
|
|
54
54
|
}),
|
|
55
55
|
),
|
package/templates/test/api.http
CHANGED
|
@@ -40,3 +40,28 @@ X-Amz-Target: AWSCognitoIdentityProviderService.InitiateAuth
|
|
|
40
40
|
GET {{endpoint}}
|
|
41
41
|
Accept: application/json
|
|
42
42
|
Authorization: {{token}}
|
|
43
|
+
|
|
44
|
+
###
|
|
45
|
+
# sample
|
|
46
|
+
POST {{apiBaseUrl}}/sample
|
|
47
|
+
Accept: application/json
|
|
48
|
+
Content-Type: application/json
|
|
49
|
+
Authorization: {{token}}
|
|
50
|
+
X-Tenant-Code: mbc
|
|
51
|
+
|
|
52
|
+
{
|
|
53
|
+
"pk": "SAMPLE#mbc",
|
|
54
|
+
"sk": "foo#bar",
|
|
55
|
+
"id": "SAMPLE#mbc#foo#bar",
|
|
56
|
+
"code": "foo#bar",
|
|
57
|
+
"name": "Test",
|
|
58
|
+
"version": 0,
|
|
59
|
+
"isDeleted": true,
|
|
60
|
+
"type": "SAMPLE",
|
|
61
|
+
"tenantCode": "mbc",
|
|
62
|
+
"attributes": {
|
|
63
|
+
"value": {
|
|
64
|
+
"foo": "bar"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
package/templates/tsconfig.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { CommandEntity } from '@mbc-cqrs-serverless/core'
|
|
2
|
-
|
|
3
|
-
import { MasterAttributes } from '../dto/master-attributes.dto'
|
|
4
|
-
|
|
5
|
-
export class MasterCommandEntity extends CommandEntity {
|
|
6
|
-
attributes: MasterAttributes
|
|
7
|
-
|
|
8
|
-
constructor(partial: Partial<MasterCommandEntity>) {
|
|
9
|
-
super()
|
|
10
|
-
|
|
11
|
-
Object.assign(this, partial)
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { DataListEntity } from '@mbc-cqrs-serverless/core'
|
|
2
|
-
|
|
3
|
-
import { MasterDataEntity } from './master-data.entity'
|
|
4
|
-
|
|
5
|
-
export class MasterDataListEntity extends DataListEntity {
|
|
6
|
-
items: MasterDataEntity[]
|
|
7
|
-
|
|
8
|
-
constructor(partial: Partial<MasterDataListEntity>) {
|
|
9
|
-
super(partial)
|
|
10
|
-
|
|
11
|
-
Object.assign(this, partial)
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { DataEntity } from '@mbc-cqrs-serverless/core'
|
|
2
|
-
|
|
3
|
-
import { MasterAttributes } from '../dto/master-attributes.dto'
|
|
4
|
-
|
|
5
|
-
export class MasterDataEntity extends DataEntity {
|
|
6
|
-
attributes: MasterAttributes
|
|
7
|
-
|
|
8
|
-
constructor(partial: Partial<MasterDataEntity>) {
|
|
9
|
-
super(partial)
|
|
10
|
-
|
|
11
|
-
Object.assign(this, partial)
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { CommandModule } from '@mbc-cqrs-serverless/core'
|
|
2
|
-
import { Module } from '@nestjs/common'
|
|
3
|
-
|
|
4
|
-
import { MasterDataSyncRdsHandler } from './handler/master-rds.handler'
|
|
5
|
-
import { MasterController } from './master.controller'
|
|
6
|
-
import { MasterService } from './master.service'
|
|
7
|
-
|
|
8
|
-
@Module({
|
|
9
|
-
imports: [
|
|
10
|
-
CommandModule.register({
|
|
11
|
-
tableName: 'master',
|
|
12
|
-
dataSyncHandlers: [MasterDataSyncRdsHandler],
|
|
13
|
-
}),
|
|
14
|
-
],
|
|
15
|
-
controllers: [MasterController],
|
|
16
|
-
providers: [MasterService],
|
|
17
|
-
exports: [MasterService],
|
|
18
|
-
})
|
|
19
|
-
export class MasterModule {}
|