@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.
- 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 +13 -4
- 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
|
@@ -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 {}
|