@mikemajesty/microservice-crud 6.1.20 → 7.0.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/bin/microservice-crud +3 -2
- package/package.json +10 -6
- package/src/{cli.js → cli.mjs} +52 -46
- package/src/templates/core/entity/entity.mjs +35 -0
- package/src/templates/core/repository/{repository.js → repository.mjs} +2 -2
- package/src/templates/core/use-cases/__tests__/{create.spec.js → create.spec.mjs} +2 -2
- package/src/templates/core/use-cases/__tests__/{delete.spec.js → delete.spec.mjs} +2 -2
- package/src/templates/core/use-cases/__tests__/{get-by-id.spec.js → get-by-id.spec.mjs} +2 -2
- package/src/templates/core/use-cases/__tests__/{list.spec.js → list.spec.mjs} +3 -3
- package/src/templates/core/use-cases/__tests__/{update.spec.js → update.spec.mjs} +2 -2
- package/src/templates/core/use-cases/{create.js → create.mjs} +5 -5
- package/src/templates/core/use-cases/{delete.js → delete.mjs} +5 -5
- package/src/templates/core/use-cases/{get-by-id.js → get-by-id.mjs} +5 -5
- package/src/templates/core/use-cases/{list.js → list.mjs} +5 -5
- package/src/templates/core/use-cases/{update.js → update.mjs} +5 -5
- package/src/templates/core-sigle/entity/entity.mjs +35 -0
- package/src/templates/core-sigle/repository/{repository.js → repository.mjs} +2 -2
- package/src/templates/core-sigle/use-cases/{usecase.js → usecase.mjs} +6 -6
- package/src/templates/infra/{adapter.js → adapter.mjs} +2 -2
- package/src/templates/infra/{index.js → index.mjs} +1 -2
- package/src/templates/infra/{module.js → module.mjs} +2 -2
- package/src/templates/infra/{service.js → service.mjs} +5 -5
- package/src/templates/libs/{adapter.js → adapter.mjs} +2 -4
- package/src/templates/libs/{index.js → index.mjs} +1 -1
- package/src/templates/libs/{module.js → module.mjs} +2 -2
- package/src/templates/libs/{service.js → service.mjs} +5 -5
- package/src/templates/module/{controller.js → controller.mjs} +3 -3
- package/src/templates/module/{module.js → module.mjs} +2 -2
- package/src/templates/mongo/modules/{adapter.js → adapter.mjs} +2 -2
- package/src/templates/mongo/modules/{controller.js → controller.mjs} +3 -3
- package/src/templates/mongo/modules/{module.js → module.mjs} +2 -2
- package/src/templates/mongo/modules/{repository.js → repository.mjs} +3 -3
- package/src/templates/mongo/schemas/{schema.js → schema.mjs} +3 -3
- package/src/templates/postgres/modules/{adapter.js → adapter.mjs} +2 -2
- package/src/templates/postgres/modules/{controller.js → controller.mjs} +3 -3
- package/src/templates/postgres/modules/{module.js → module.mjs} +2 -2
- package/src/templates/postgres/modules/{repository.js → repository.mjs} +2 -2
- package/src/templates/postgres/schemas/{schema.js → schema.mjs} +3 -3
- package/src/templates/core/entity/entity.js +0 -35
- package/src/templates/core-sigle/entity/entity.js +0 -35
- /package/src/{textUtils.js → textUtils.mjs} +0 -0
package/bin/microservice-crud
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikemajesty/microservice-crud",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Monorepo CLI",
|
|
5
5
|
"main": "src/cli.js",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"permission": "chmod -R 777 ./bin/*",
|
|
8
|
-
"crud": "ENV=local node ./bin/microservice-crud"
|
|
9
|
+
"crud": "ENV=local node ./bin/microservice-crud",
|
|
10
|
+
"check-newest:deps": "npx npm-check-updates"
|
|
9
11
|
},
|
|
10
12
|
"bin": {
|
|
11
13
|
"@mikemajesty/microservice-crud": "bin/microservice-crud",
|
|
@@ -25,10 +27,12 @@
|
|
|
25
27
|
"cli-select": "^1.1.2",
|
|
26
28
|
"colorette": "^2.0.20",
|
|
27
29
|
"esm": "^3.2.25",
|
|
28
|
-
"fs": "^
|
|
29
|
-
"fs-extra": "^11.2.0",
|
|
30
|
+
"fs-extra": "^11.3.0",
|
|
30
31
|
"pluralize": "^8.0.0",
|
|
31
32
|
"prompt-sync": "^4.2.0",
|
|
32
|
-
"rimraf": "^
|
|
33
|
+
"rimraf": "^6.0.1"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"npm-check-updates": "^17.1.15"
|
|
33
37
|
}
|
|
34
|
-
}
|
|
38
|
+
}
|
package/src/{cli.js → cli.mjs}
RENAMED
|
@@ -1,48 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getCoreSingleRepository } from './templates/core-sigle/repository/repository';
|
|
3
|
-
import {
|
|
4
|
-
import { getIndexInfra } from './templates/infra';
|
|
5
|
-
import
|
|
6
|
-
import { getModuleInfa } from './templates/infra/module';
|
|
7
|
-
import { getServiceInfra } from './templates/infra/service';
|
|
8
|
-
import { getIndexLib } from './templates/libs';
|
|
9
|
-
import { getAdapterLib } from './templates/libs/adapter';
|
|
10
|
-
import { getModuleLib } from './templates/libs/module';
|
|
11
|
-
import { getServiceLib } from './templates/libs/service';
|
|
12
|
-
import { getModuleControllerModule } from './templates/module/controller';
|
|
13
|
-
import { getModuleModule } from './templates/module/module';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
import { getCoreSingleUsecaseCreate } from './templates/core-sigle/use-cases/usecase.mjs';
|
|
2
|
+
import { getCoreSingleRepository } from './templates/core-sigle/repository/repository.mjs';
|
|
3
|
+
import { getCoreSingleEntity } from './templates/core-sigle/entity/entity.mjs';
|
|
4
|
+
import { getIndexInfra } from './templates/infra/index.mjs';
|
|
5
|
+
import getAdapterInfra from './templates/infra/adapter.mjs';
|
|
6
|
+
import { getModuleInfa } from './templates/infra/module.mjs';
|
|
7
|
+
import { getServiceInfra } from './templates/infra/service.mjs';
|
|
8
|
+
import { getIndexLib } from './templates/libs/index.mjs';
|
|
9
|
+
import { getAdapterLib } from './templates/libs/adapter.mjs';
|
|
10
|
+
import { getModuleLib } from './templates/libs/module.mjs';
|
|
11
|
+
import { getServiceLib } from './templates/libs/service.mjs';
|
|
12
|
+
import { getModuleControllerModule } from './templates/module/controller.mjs';
|
|
13
|
+
import { getModuleModule } from './templates/module/module.mjs';
|
|
14
|
+
|
|
15
|
+
import fs from 'fs';
|
|
16
|
+
import { bold, green, red } from 'colorette';
|
|
17
|
+
import fse from 'fs-extra';
|
|
18
|
+
import path from 'path';
|
|
19
|
+
import cliSelect from 'cli-select';
|
|
20
|
+
import promptSync from 'prompt-sync';
|
|
21
|
+
import { fileURLToPath } from 'url';
|
|
22
|
+
import { dirname } from 'path';
|
|
23
|
+
|
|
24
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
25
|
+
const __dirname = dirname(__filename);
|
|
26
|
+
|
|
27
|
+
const prompt = promptSync();
|
|
28
|
+
|
|
29
|
+
import { getCoreUsecaseCreateTest } from './templates/core/use-cases/__tests__/create.spec.mjs';
|
|
30
|
+
import { getCoreUsecaseUpdateTest } from './templates/core/use-cases/__tests__/update.spec.mjs';
|
|
31
|
+
import { getCoreUsecaseDeleteTest } from './templates/core/use-cases/__tests__/delete.spec.mjs';
|
|
32
|
+
import { getCoreUsecaseListTest } from './templates/core/use-cases/__tests__/list.spec.mjs';
|
|
33
|
+
import { getCoreUsecaseGetByIdTest } from './templates/core/use-cases/__tests__/get-by-id.spec.mjs';
|
|
34
|
+
import { getCoreUsecaseGetById } from './templates/core/use-cases/get-by-id.mjs';
|
|
35
|
+
import { getCoreUsecaseList } from './templates/core/use-cases/list.mjs';
|
|
36
|
+
import { getCoreEntity } from './templates/core/entity/entity.mjs';
|
|
37
|
+
import { getCoreRepository } from './templates/core/repository/repository.mjs';
|
|
38
|
+
import { getCoreUsecaseCreate } from './templates/core/use-cases/create.mjs';
|
|
39
|
+
import { getCoreUsecaseDelete } from './templates/core/use-cases/delete.mjs';
|
|
40
|
+
import { getCoreUsecaseUpdate } from './templates/core/use-cases/update.mjs';
|
|
41
|
+
|
|
42
|
+
import { getModuleAdapter } from './templates/postgres/modules/adapter.mjs';
|
|
43
|
+
import { getModuleController } from './templates/postgres/modules/controller.mjs';
|
|
44
|
+
import { getModule } from './templates/postgres/modules/module.mjs';
|
|
45
|
+
import { getModuleRepository } from './templates/postgres/modules/repository.mjs';
|
|
46
|
+
import { getModuleSchema } from './templates/postgres/schemas/schema.mjs';
|
|
47
|
+
|
|
48
|
+
import { getModuleAdapter as getModuleAdapterMongo } from './templates/mongo/modules/adapter.mjs';
|
|
49
|
+
import { getModuleController as getModuleControllerMongo } from './templates/mongo/modules/controller.mjs';
|
|
50
|
+
import { getModule as getModuleMongo } from './templates/mongo/modules/module.mjs';
|
|
51
|
+
import { getModuleRepository as getModuleRepositoryMongo } from './templates/mongo/modules/repository.mjs';
|
|
52
|
+
import { getModuleSchema as getModuleSchemaMongo } from './templates/mongo/schemas/schema.mjs';
|
|
46
53
|
|
|
47
54
|
const createModule = async (name) => {
|
|
48
55
|
if (!name) throw new Error('--name is required')
|
|
@@ -378,7 +385,6 @@ export async function cli(args) {
|
|
|
378
385
|
try {
|
|
379
386
|
|
|
380
387
|
const dest = path.resolve(`${__dirname}/../../../../`)
|
|
381
|
-
|
|
382
388
|
const src = paths[0]
|
|
383
389
|
|
|
384
390
|
// VALIDATE
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { dashToPascal } from "../../../textUtils.mjs"
|
|
2
|
+
|
|
3
|
+
const getCoreEntity = (name) => `import { BaseEntity } from '@/utils/entity';;
|
|
4
|
+
|
|
5
|
+
import { Infer, InputValidator } from '@/utils/validator';
|
|
6
|
+
|
|
7
|
+
const ID = InputValidator.string().uuid();
|
|
8
|
+
const Name = InputValidator.string().min(1).max(200).trim();
|
|
9
|
+
const CreatedAt = InputValidator.date().nullish();
|
|
10
|
+
const UpdatedAt = InputValidator.date().nullish();
|
|
11
|
+
const DeletedAt = InputValidator.date().nullish();
|
|
12
|
+
|
|
13
|
+
export const ${dashToPascal(name)}EntitySchema = InputValidator.object({
|
|
14
|
+
id: ID,
|
|
15
|
+
name: Name,
|
|
16
|
+
createdAt: CreatedAt,
|
|
17
|
+
updatedAt: UpdatedAt,
|
|
18
|
+
deletedAt: DeletedAt
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
type ${dashToPascal(name)} = Infer<typeof ${dashToPascal(name)}EntitySchema>;
|
|
22
|
+
|
|
23
|
+
export class ${dashToPascal(name)}Entity extends BaseEntity<${dashToPascal(name)}Entity>() {
|
|
24
|
+
name!: string;
|
|
25
|
+
|
|
26
|
+
constructor(entity: ${dashToPascal(name)}) {
|
|
27
|
+
super(${dashToPascal(name)}EntitySchema);
|
|
28
|
+
Object.assign(this, this.validate(entity));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
`
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
getCoreEntity
|
|
35
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal } from "../../../textUtils.mjs"
|
|
2
2
|
|
|
3
3
|
const getCoreRepository = (name) => `import { IRepository } from '@/infra/repository';
|
|
4
4
|
|
|
@@ -10,6 +10,6 @@ export abstract class I${dashToPascal(name)}Repository extends IRepository<${das
|
|
|
10
10
|
}
|
|
11
11
|
`
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
export {
|
|
14
14
|
getCoreRepository
|
|
15
15
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal, snakeToCamel } from "../../../../textUtils.mjs"
|
|
2
2
|
|
|
3
3
|
const getCoreUsecaseCreateTest = (name) => `import { Test } from '@nestjs/testing';
|
|
4
4
|
import { ZodIssue } from 'zod';
|
|
@@ -63,6 +63,6 @@ describe(${dashToPascal(name)}CreateUsecase.name, () => {
|
|
|
63
63
|
});
|
|
64
64
|
`
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
export {
|
|
67
67
|
getCoreUsecaseCreateTest
|
|
68
68
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal, snakeToCamel } from "../../../../textUtils.mjs"
|
|
2
2
|
|
|
3
3
|
const getCoreUsecaseDeleteTest = (name) => `import { Test } from '@nestjs/testing';
|
|
4
4
|
import { ZodIssue } from 'zod';
|
|
@@ -73,6 +73,6 @@ describe(${dashToPascal(name)}DeleteUsecase.name, () => {
|
|
|
73
73
|
});
|
|
74
74
|
`
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
export {
|
|
77
77
|
getCoreUsecaseDeleteTest
|
|
78
78
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal, snakeToCamel } from "../../../../textUtils.mjs"
|
|
2
2
|
|
|
3
3
|
const getCoreUsecaseGetByIdTest = (name) => `import { Test } from '@nestjs/testing';
|
|
4
4
|
import { ZodIssue } from 'zod';
|
|
@@ -68,6 +68,6 @@ describe(${dashToPascal(name)}GetByIdUsecase.name, () => {
|
|
|
68
68
|
});
|
|
69
69
|
`
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
export {
|
|
72
72
|
getCoreUsecaseGetByIdTest
|
|
73
73
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import pluralize from 'pluralize'
|
|
3
|
+
import { dashToPascal, snakeToCamel } from '../../../../textUtils.mjs'
|
|
4
4
|
|
|
5
5
|
const getCoreUsecaseListTest = (name) => `import { Test } from '@nestjs/testing';
|
|
6
6
|
import { ZodIssue } from 'zod';
|
|
@@ -78,6 +78,6 @@ describe(${dashToPascal(name)}ListUsecase.name, () => {
|
|
|
78
78
|
});
|
|
79
79
|
`
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
export {
|
|
82
82
|
getCoreUsecaseListTest
|
|
83
83
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal, snakeToCamel } from "../../../../textUtils.mjs"
|
|
2
2
|
|
|
3
3
|
const getCoreUsecaseUpdateTest = (name) => `import { Test } from '@nestjs/testing';
|
|
4
4
|
import { ZodIssue } from 'zod';
|
|
@@ -77,6 +77,6 @@ describe(${dashToPascal(name)}UpdateUsecase.name, () => {
|
|
|
77
77
|
});
|
|
78
78
|
`
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
export {
|
|
81
81
|
getCoreUsecaseUpdateTest
|
|
82
82
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal, snakeToCamel } from "../../../textUtils.mjs"
|
|
2
2
|
|
|
3
|
-
const getCoreUsecaseCreate = (name) => `import {
|
|
3
|
+
const getCoreUsecaseCreate = (name) => `import { ILoggerAdapter } from '@/infra/logger';
|
|
4
4
|
|
|
5
|
-
import { ILoggerAdapter } from '@/infra/logger';
|
|
6
5
|
import { CreatedModel } from '@/infra/repository';
|
|
7
6
|
import { ValidateSchema } from '@/utils/decorators';
|
|
8
7
|
import { IUsecase } from '@/utils/usecase';
|
|
9
8
|
import { UUIDUtils } from '@/utils/uuid';
|
|
10
9
|
|
|
10
|
+
import { Infer } from '@/utils/validator';
|
|
11
11
|
import { I${dashToPascal(name)}Repository } from '../repository/${name}';
|
|
12
12
|
import { ${dashToPascal(name)}Entity, ${dashToPascal(name)}EntitySchema } from './../entity/${name}';
|
|
13
13
|
|
|
@@ -33,10 +33,10 @@ export class ${dashToPascal(name)}CreateUsecase implements IUsecase {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export type ${dashToPascal(name)}CreateInput =
|
|
36
|
+
export type ${dashToPascal(name)}CreateInput = Infer<typeof ${dashToPascal(name)}CreateSchema>;
|
|
37
37
|
export type ${dashToPascal(name)}CreateOutput = CreatedModel;
|
|
38
38
|
`
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
export {
|
|
41
41
|
getCoreUsecaseCreate
|
|
42
42
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal, snakeToCamel } from "../../../textUtils.mjs"
|
|
2
2
|
|
|
3
|
-
const getCoreUsecaseDelete = (name) => `import {
|
|
3
|
+
const getCoreUsecaseDelete = (name) => `import { I${dashToPascal(name)}Repository } from '@/core/${name}/repository/${name}';
|
|
4
4
|
|
|
5
|
-
import { I${dashToPascal(name)}Repository } from '@/core/${name}/repository/${name}';
|
|
6
5
|
import { ValidateSchema } from '@/utils/decorators';
|
|
7
6
|
import { ApiNotFoundException } from '@/utils/exception';
|
|
8
7
|
import { IUsecase } from '@/utils/usecase';
|
|
9
8
|
|
|
9
|
+
import { Infer } from '@/utils/validator';
|
|
10
10
|
import { ${dashToPascal(name)}Entity, ${dashToPascal(name)}EntitySchema } from '../entity/${name}';
|
|
11
11
|
|
|
12
12
|
export const ${dashToPascal(name)}DeleteSchema = ${dashToPascal(name)}EntitySchema.pick({
|
|
@@ -34,10 +34,10 @@ export class ${dashToPascal(name)}DeleteUsecase implements IUsecase {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export type ${dashToPascal(name)}DeleteInput =
|
|
37
|
+
export type ${dashToPascal(name)}DeleteInput = Infer<typeof ${dashToPascal(name)}DeleteSchema>;
|
|
38
38
|
export type ${dashToPascal(name)}DeleteOutput = ${dashToPascal(name)}Entity;
|
|
39
39
|
`
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
export {
|
|
42
42
|
getCoreUsecaseDelete
|
|
43
43
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal, snakeToCamel } from "../../../textUtils.mjs"
|
|
2
2
|
|
|
3
|
-
const getCoreUsecaseGetById = (name) => `import {
|
|
3
|
+
const getCoreUsecaseGetById = (name) => `import { ${dashToPascal(name)}EntitySchema } from '@/core/${name}/entity/${name}';
|
|
4
4
|
|
|
5
|
-
import { ${dashToPascal(name)}EntitySchema } from '@/core/${name}/entity/${name}';
|
|
6
5
|
import { ValidateSchema } from '@/utils/decorators';
|
|
7
6
|
import { ApiNotFoundException } from '@/utils/exception';
|
|
8
7
|
import { IUsecase } from '@/utils/usecase';
|
|
9
8
|
|
|
9
|
+
import { Infer } from '@/utils/validator';
|
|
10
10
|
import { ${dashToPascal(name)}Entity } from '../entity/${name}';
|
|
11
11
|
import { I${dashToPascal(name)}Repository } from '../repository/${name}';
|
|
12
12
|
|
|
@@ -29,10 +29,10 @@ export class ${dashToPascal(name)}GetByIdUsecase implements IUsecase {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export type ${dashToPascal(name)}GetByIdInput =
|
|
32
|
+
export type ${dashToPascal(name)}GetByIdInput = Infer<typeof ${dashToPascal(name)}GetByIdSchema>;
|
|
33
33
|
export type ${dashToPascal(name)}GetByIdOutput = ${dashToPascal(name)}Entity;
|
|
34
34
|
`
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
export {
|
|
37
37
|
getCoreUsecaseGetById
|
|
38
38
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal, snakeToCamel } from "../../../textUtils.mjs"
|
|
2
2
|
|
|
3
|
-
const getCoreUsecaseList = (name) => `import {
|
|
3
|
+
const getCoreUsecaseList = (name) => `import { ${dashToPascal(name)}Entity } from '@/core/${name}/entity/${name}';;
|
|
4
4
|
|
|
5
|
-
import { ${dashToPascal(name)}Entity } from '@/core/${name}/entity/${name}';
|
|
6
5
|
import { ValidateSchema } from '@/utils/decorators';
|
|
7
6
|
import { PaginationInput, PaginationOutput, PaginationSchema } from '@/utils/pagination';
|
|
8
7
|
import { SearchSchema } from '@/utils/search';
|
|
9
8
|
import { SortSchema } from '@/utils/sort';
|
|
10
9
|
import { IUsecase } from '@/utils/usecase';
|
|
11
10
|
|
|
11
|
+
import { InputValidator } from '@/utils/validator';
|
|
12
12
|
import { I${dashToPascal(name)}Repository } from '../repository/${name}';
|
|
13
13
|
|
|
14
|
-
export const ${dashToPascal(name)}ListSchema =
|
|
14
|
+
export const ${dashToPascal(name)}ListSchema = InputValidator.intersection(PaginationSchema, SortSchema.merge(SearchSchema));
|
|
15
15
|
|
|
16
16
|
export class ${dashToPascal(name)}ListUsecase implements IUsecase {
|
|
17
17
|
constructor(private readonly ${snakeToCamel(name)}Repository: I${dashToPascal(name)}Repository) {}
|
|
@@ -26,6 +26,6 @@ export type ${dashToPascal(name)}ListInput = PaginationInput<${dashToPascal(name
|
|
|
26
26
|
export type ${dashToPascal(name)}ListOutput = PaginationOutput<${dashToPascal(name)}Entity>;
|
|
27
27
|
`
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
export {
|
|
30
30
|
getCoreUsecaseList
|
|
31
31
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal, snakeToCamel } from "../../../textUtils.mjs"
|
|
2
2
|
|
|
3
|
-
const getCoreUsecaseUpdate = (name) => `import {
|
|
3
|
+
const getCoreUsecaseUpdate = (name) => `import { I${dashToPascal(name)}Repository } from '@/core/${name}/repository/${name}';;
|
|
4
4
|
|
|
5
|
-
import { I${dashToPascal(name)}Repository } from '@/core/${name}/repository/${name}';
|
|
6
5
|
import { ILoggerAdapter } from '@/infra/logger';
|
|
7
6
|
import { ValidateSchema } from '@/utils/decorators';
|
|
8
7
|
import { ApiNotFoundException } from '@/utils/exception';
|
|
9
8
|
import { IUsecase } from '@/utils/usecase';
|
|
10
9
|
|
|
10
|
+
import { Infer } from '@/utils/validator';
|
|
11
11
|
import { ${dashToPascal(name)}Entity, ${dashToPascal(name)}EntitySchema } from './../entity/${name}';
|
|
12
12
|
|
|
13
13
|
export const ${dashToPascal(name)}UpdateSchema = ${dashToPascal(name)}EntitySchema.pick({
|
|
@@ -42,10 +42,10 @@ export class ${dashToPascal(name)}UpdateUsecase implements IUsecase {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export type ${dashToPascal(name)}UpdateInput =
|
|
45
|
+
export type ${dashToPascal(name)}UpdateInput = Infer<typeof ${dashToPascal(name)}UpdateSchema>;
|
|
46
46
|
export type ${dashToPascal(name)}UpdateOutput = ${dashToPascal(name)}Entity;
|
|
47
47
|
`
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
export {
|
|
50
50
|
getCoreUsecaseUpdate
|
|
51
51
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { dashToPascal } from "../../../textUtils.mjs"
|
|
2
|
+
|
|
3
|
+
const getCoreSingleEntity = (name) => `import { BaseEntity } from '@/utils/entity';
|
|
4
|
+
|
|
5
|
+
import { Infer, InputValidator } from '@/utils/validator';
|
|
6
|
+
|
|
7
|
+
const ID = InputValidator.string().uuid();
|
|
8
|
+
const Name = InputValidator.string().min(1).max(200).trim();
|
|
9
|
+
const CreatedAt = InputValidator.date().nullish();
|
|
10
|
+
const UpdatedAt = InputValidator.date().nullish();
|
|
11
|
+
const DeletedAt = InputValidator.date().nullish();
|
|
12
|
+
|
|
13
|
+
export const ${dashToPascal(name)}EntitySchema = InputValidator.object({
|
|
14
|
+
id: ID,
|
|
15
|
+
name: Name,
|
|
16
|
+
createdAt: CreatedAt,
|
|
17
|
+
updatedAt: UpdatedAt,
|
|
18
|
+
deletedAt: DeletedAt
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
type ${dashToPascal(name)} = Infer<typeof ${dashToPascal(name)}EntitySchema>;
|
|
22
|
+
|
|
23
|
+
export class ${dashToPascal(name)}Entity extends BaseEntity<${dashToPascal(name)}Entity>() {
|
|
24
|
+
name!: string;
|
|
25
|
+
|
|
26
|
+
constructor(entity: ${dashToPascal(name)}) {
|
|
27
|
+
super(${dashToPascal(name)}EntitySchema);
|
|
28
|
+
Object.assign(this, this.validate(entity));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
`
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
getCoreSingleEntity
|
|
35
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal } from "../../../textUtils.mjs"
|
|
2
2
|
|
|
3
3
|
const getCoreSingleRepository = (name) => `import { IRepository } from '@/infra/repository';
|
|
4
4
|
|
|
@@ -7,6 +7,6 @@ import { ${dashToPascal(name)}Entity } from '../entity/${name}';
|
|
|
7
7
|
export abstract class I${dashToPascal(name)}Repository extends IRepository<${dashToPascal(name)}Entity> {}
|
|
8
8
|
`
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
export {
|
|
11
11
|
getCoreSingleRepository
|
|
12
12
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal } from "../../../textUtils.mjs"
|
|
2
2
|
|
|
3
|
-
const getCoreSingleUsecaseCreate = (name) => `import {
|
|
3
|
+
const getCoreSingleUsecaseCreate = (name) => `import { ValidateSchema } from '@/utils/decorators';;
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Infer, InputValidator } from '@/utils/validator';
|
|
6
6
|
import { IUsecase } from '@/utils/usecase';
|
|
7
7
|
|
|
8
|
-
export const ${dashToPascal(name)}RenameSchema =
|
|
8
|
+
export const ${dashToPascal(name)}RenameSchema = InputValidator.object({ id: InputValidator.string() });
|
|
9
9
|
|
|
10
10
|
export class ${dashToPascal(name)}RenameUsecase implements IUsecase {
|
|
11
11
|
@ValidateSchema(${dashToPascal(name)}RenameSchema)
|
|
@@ -14,10 +14,10 @@ export class ${dashToPascal(name)}RenameUsecase implements IUsecase {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export type ${dashToPascal(name)}RenameUseCaseInput =
|
|
17
|
+
export type ${dashToPascal(name)}RenameUseCaseInput = Infer<typeof ${dashToPascal(name)}RenameSchema>;
|
|
18
18
|
export type ${dashToPascal(name)}RenameUseCaseOutput = ${dashToPascal(name)}RenameUseCaseInput;
|
|
19
19
|
`
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
export {
|
|
22
22
|
getCoreSingleUsecaseCreate
|
|
23
23
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal } from "../../textUtils.mjs"
|
|
2
2
|
|
|
3
3
|
const getAdapterInfra = (name) => `import { ${dashToPascal(name)}GetInput, ${dashToPascal(name)}GetOutput } from './service';
|
|
4
4
|
|
|
@@ -7,6 +7,6 @@ export abstract class I${dashToPascal(name)}Adapter {
|
|
|
7
7
|
}
|
|
8
8
|
`
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
export default {
|
|
11
11
|
getAdapterInfra
|
|
12
12
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal } from "../../textUtils.mjs"
|
|
2
2
|
|
|
3
3
|
const getModuleInfa = (name) => `import { Module } from '@nestjs/common';
|
|
4
4
|
|
|
@@ -18,6 +18,6 @@ import { ${dashToPascal(name)}Service } from './service';
|
|
|
18
18
|
export class ${dashToPascal(name)}Module {}
|
|
19
19
|
`
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
export {
|
|
22
22
|
getModuleInfa
|
|
23
23
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal } from "../../textUtils.mjs"
|
|
2
2
|
|
|
3
3
|
const getServiceInfra = (name) => `import { Injectable } from '@nestjs/common';
|
|
4
|
-
import {
|
|
4
|
+
import { Infer, InputValidator } from '@/utils/validator';
|
|
5
5
|
|
|
6
6
|
import { ValidateSchema } from '@/utils/decorators';
|
|
7
7
|
|
|
8
8
|
import { I${dashToPascal(name)}Adapter } from './adapter';
|
|
9
9
|
|
|
10
|
-
const ${dashToPascal(name)}Schema =
|
|
10
|
+
const ${dashToPascal(name)}Schema = InputValidator.object({ name: InputValidator.string().trim() });
|
|
11
11
|
|
|
12
12
|
@Injectable()
|
|
13
13
|
export class ${dashToPascal(name)}Service implements I${dashToPascal(name)}Adapter {
|
|
@@ -17,10 +17,10 @@ export class ${dashToPascal(name)}Service implements I${dashToPascal(name)}Adapt
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export type ${dashToPascal(name)}GetInput =
|
|
20
|
+
export type ${dashToPascal(name)}GetInput = Infer<typeof ${dashToPascal(name)}Schema>;
|
|
21
21
|
export type ${dashToPascal(name)}GetOutput = ${dashToPascal(name)}GetInput;
|
|
22
22
|
`
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
export {
|
|
25
25
|
getServiceInfra
|
|
26
26
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal } from "../../textUtils.mjs"
|
|
2
2
|
|
|
3
3
|
const getAdapterLib = (name) => `import { ${dashToPascal(name)}Input, ${dashToPascal(name)}Output } from './service';
|
|
4
4
|
|
|
@@ -7,6 +7,4 @@ export abstract class I${dashToPascal(name)}Adapter {
|
|
|
7
7
|
}
|
|
8
8
|
`
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
getAdapterLib
|
|
12
|
-
}
|
|
10
|
+
export { getAdapterLib }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal } from "../../textUtils.mjs"
|
|
2
2
|
|
|
3
3
|
const getModuleLib = (name) => `import { Module } from '@nestjs/common';
|
|
4
4
|
|
|
@@ -18,6 +18,6 @@ import { ${dashToPascal(name)}Service } from './service';
|
|
|
18
18
|
export class ${dashToPascal(name)}LibModule {}
|
|
19
19
|
`
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
export {
|
|
22
22
|
getModuleLib
|
|
23
23
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal } from "../../textUtils.mjs"
|
|
2
2
|
|
|
3
3
|
const getServiceLib = (name) => `import { Injectable } from '@nestjs/common';
|
|
4
|
-
import {
|
|
4
|
+
import { Infer, InputValidator } from '@/utils/validator';
|
|
5
5
|
|
|
6
6
|
import { ValidateSchema } from '@/utils/decorators';
|
|
7
7
|
|
|
8
8
|
import { I${dashToPascal(name)}Adapter } from './adapter';
|
|
9
9
|
|
|
10
|
-
const ${dashToPascal(name)}Schema =
|
|
10
|
+
const ${dashToPascal(name)}Schema = InputValidator.object({ name: InputValidator.string().trim() });
|
|
11
11
|
|
|
12
12
|
@Injectable()
|
|
13
13
|
export class ${dashToPascal(name)}Service implements I${dashToPascal(name)}Adapter {
|
|
@@ -17,10 +17,10 @@ export class ${dashToPascal(name)}Service implements I${dashToPascal(name)}Adapt
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export type ${dashToPascal(name)}Input =
|
|
20
|
+
export type ${dashToPascal(name)}Input = Infer<typeof ${dashToPascal(name)}Schema>;
|
|
21
21
|
export type ${dashToPascal(name)}Output = ${dashToPascal(name)}Input;
|
|
22
22
|
`
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
export {
|
|
25
25
|
getServiceLib
|
|
26
26
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import pluralize from 'pluralize'
|
|
3
|
+
import { dashToPascal } from '../../textUtils.mjs'
|
|
4
4
|
|
|
5
5
|
const getModuleControllerModule = (name) => `import { Controller, Get, Req, Version } from '@nestjs/common';
|
|
6
6
|
|
|
@@ -16,6 +16,6 @@ export class ${dashToPascal(name)}Controller {
|
|
|
16
16
|
}
|
|
17
17
|
`
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
export {
|
|
20
20
|
getModuleControllerModule
|
|
21
21
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal } from "../../textUtils.mjs"
|
|
2
2
|
|
|
3
3
|
const getModuleModule = (name) => `import { Module } from '@nestjs/common';
|
|
4
4
|
|
|
@@ -11,6 +11,6 @@ import { ${dashToPascal(name)}Controller } from './controller';
|
|
|
11
11
|
export class ${dashToPascal(name)}Module {}
|
|
12
12
|
`
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
export {
|
|
15
15
|
getModuleModule
|
|
16
16
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal } from "../../../textUtils.mjs"
|
|
2
2
|
|
|
3
3
|
const getModuleAdapter = (name) => `import { ${dashToPascal(name)}CreateInput, ${dashToPascal(name)}CreateOutput } from '@/core/${name}/use-cases/${name}-create';
|
|
4
4
|
import { ${dashToPascal(name)}DeleteInput, ${dashToPascal(name)}DeleteOutput } from '@/core/${name}/use-cases/${name}-delete';
|
|
@@ -28,6 +28,6 @@ export abstract class I${dashToPascal(name)}GetByIdAdapter implements IUsecase {
|
|
|
28
28
|
}
|
|
29
29
|
`
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
export {
|
|
32
32
|
getModuleAdapter
|
|
33
33
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import pluralize from 'pluralize'
|
|
2
|
+
import { dashToPascal, snakeToCamel } from '../../../textUtils.mjs'
|
|
3
3
|
|
|
4
4
|
const getModuleController = (name) => `import { Controller, Delete, Get, HttpCode, Post, Put, Req, Version } from '@nestjs/common';
|
|
5
5
|
|
|
@@ -70,6 +70,6 @@ export class ${dashToPascal(name)}Controller {
|
|
|
70
70
|
}
|
|
71
71
|
`
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
export {
|
|
74
74
|
getModuleController
|
|
75
75
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal, snakeToCamel } from "../../../textUtils.mjs"
|
|
2
2
|
|
|
3
3
|
const getModule = (name) => `import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
|
|
4
4
|
import { getConnectionToken } from '@nestjs/mongoose';
|
|
@@ -105,6 +105,6 @@ export class ${dashToPascal(name)}Module implements NestModule {
|
|
|
105
105
|
}
|
|
106
106
|
`
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
export {
|
|
109
109
|
getModule
|
|
110
110
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import pluralize from 'pluralize'
|
|
2
|
+
import { dashToPascal, snakeToCamel } from '../../../textUtils.mjs'
|
|
3
3
|
|
|
4
4
|
const getModuleRepository = (name) => `import { Injectable } from '@nestjs/common';
|
|
5
5
|
import { InjectModel } from '@nestjs/mongoose';
|
|
@@ -34,6 +34,6 @@ export class ${dashToPascal(name)}Repository extends MongoRepository<${dashToPas
|
|
|
34
34
|
}
|
|
35
35
|
`
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
export {
|
|
38
38
|
getModuleRepository
|
|
39
39
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import pluralize from 'pluralize'
|
|
3
|
+
import { dashToPascal } from '../../../textUtils.mjs'
|
|
4
4
|
|
|
5
5
|
const getModuleSchema = (name) => `import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
6
6
|
import { Document } from 'mongoose';
|
|
@@ -39,6 +39,6 @@ ${dashToPascal(name)}Schema.virtual('id').get(function () {
|
|
|
39
39
|
export { ${dashToPascal(name)}Schema };
|
|
40
40
|
`
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
export {
|
|
43
43
|
getModuleSchema
|
|
44
44
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal } from "../../../textUtils.mjs"
|
|
2
2
|
|
|
3
3
|
const getModuleAdapter = (name) => `import { ${dashToPascal(name)}CreateInput, ${dashToPascal(name)}CreateOutput } from '@/core/${name}/use-cases/${name}-create';
|
|
4
4
|
import { ${dashToPascal(name)}DeleteInput, ${dashToPascal(name)}DeleteOutput } from '@/core/${name}/use-cases/${name}-delete';
|
|
@@ -28,6 +28,6 @@ export abstract class I${dashToPascal(name)}DeleteAdapter implements IUsecase {
|
|
|
28
28
|
}
|
|
29
29
|
`
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
export {
|
|
32
32
|
getModuleAdapter
|
|
33
33
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import pluralize from 'pluralize'
|
|
2
|
+
import { dashToPascal, snakeToCamel } from '../../../textUtils.mjs'
|
|
3
3
|
|
|
4
4
|
const getModuleController = (name) => `import { Controller, Delete, Get, HttpCode, Post, Put, Req, Version } from '@nestjs/common';
|
|
5
5
|
|
|
@@ -70,6 +70,6 @@ export class ${dashToPascal(name)}Controller {
|
|
|
70
70
|
}
|
|
71
71
|
`
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
export {
|
|
74
74
|
getModuleController
|
|
75
75
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal } from "../../../textUtils.mjs"
|
|
2
2
|
|
|
3
3
|
const getModule = (name) => `import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
|
|
4
4
|
import { getRepositoryToken, TypeOrmModule } from '@nestjs/typeorm';
|
|
@@ -73,6 +73,6 @@ export class ${dashToPascal(name)}Module implements NestModule {
|
|
|
73
73
|
}
|
|
74
74
|
`
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
export {
|
|
77
77
|
getModule
|
|
78
78
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { dashToPascal } from "../../../textUtils.mjs"
|
|
2
2
|
|
|
3
3
|
const getModuleRepository = (name) => `import { Injectable } from '@nestjs/common';
|
|
4
4
|
import { FindOptionsOrder, FindOptionsWhere, Repository } from 'typeorm';
|
|
@@ -37,6 +37,6 @@ export class ${dashToPascal(name)}Repository extends TypeORMRepository<Model> im
|
|
|
37
37
|
type Model = ${dashToPascal(name)}Schema & ${dashToPascal(name)}Entity;
|
|
38
38
|
`
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
export {
|
|
41
41
|
getModuleRepository
|
|
42
42
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import pluralize from 'pluralize'
|
|
3
|
+
import { dashToPascal } from '../../../textUtils.mjs'
|
|
4
4
|
|
|
5
5
|
const getModuleSchema = (name) => `import {
|
|
6
6
|
BaseEntity,
|
|
@@ -31,6 +31,6 @@ export class ${dashToPascal(name)}Schema extends BaseEntity {
|
|
|
31
31
|
}
|
|
32
32
|
`
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
export {
|
|
35
35
|
getModuleSchema
|
|
36
36
|
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const { dashToPascal } = require("../../../textUtils")
|
|
2
|
-
|
|
3
|
-
const getCoreEntity = (name) => `import { z } from 'zod';
|
|
4
|
-
|
|
5
|
-
import { BaseEntity } from '@/utils/entity';
|
|
6
|
-
|
|
7
|
-
const ID = z.string().uuid();
|
|
8
|
-
const Name = z.string().min(1).max(200).trim();
|
|
9
|
-
const CreatedAt = z.date().nullish();
|
|
10
|
-
const UpdatedAt = z.date().nullish();
|
|
11
|
-
const DeletedAt = z.date().nullish();
|
|
12
|
-
|
|
13
|
-
export const ${dashToPascal(name)}EntitySchema = z.object({
|
|
14
|
-
id: ID,
|
|
15
|
-
name: Name,
|
|
16
|
-
createdAt: CreatedAt,
|
|
17
|
-
updatedAt: UpdatedAt,
|
|
18
|
-
deletedAt: DeletedAt
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
type ${dashToPascal(name)} = z.infer<typeof ${dashToPascal(name)}EntitySchema>;
|
|
22
|
-
|
|
23
|
-
export class ${dashToPascal(name)}Entity extends BaseEntity<${dashToPascal(name)}Entity>() {
|
|
24
|
-
name!: string;
|
|
25
|
-
|
|
26
|
-
constructor(entity: ${dashToPascal(name)}) {
|
|
27
|
-
super(${dashToPascal(name)}EntitySchema);
|
|
28
|
-
Object.assign(this, this.validate(entity));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
`
|
|
32
|
-
|
|
33
|
-
module.exports = {
|
|
34
|
-
getCoreEntity
|
|
35
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const { dashToPascal } = require("../../../textUtils")
|
|
2
|
-
|
|
3
|
-
const getCoreSingleEntity = (name) => `import { z } from 'zod';
|
|
4
|
-
|
|
5
|
-
import { BaseEntity } from '@/utils/entity';
|
|
6
|
-
|
|
7
|
-
const ID = z.string().uuid();
|
|
8
|
-
const Name = z.string().min(1).max(200).trim();
|
|
9
|
-
const CreatedAt = z.date().nullish();
|
|
10
|
-
const UpdatedAt = z.date().nullish();
|
|
11
|
-
const DeletedAt = z.date().nullish();
|
|
12
|
-
|
|
13
|
-
export const ${dashToPascal(name)}EntitySchema = z.object({
|
|
14
|
-
id: ID,
|
|
15
|
-
name: Name,
|
|
16
|
-
createdAt: CreatedAt,
|
|
17
|
-
updatedAt: UpdatedAt,
|
|
18
|
-
deletedAt: DeletedAt
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
type ${dashToPascal(name)} = z.infer<typeof ${dashToPascal(name)}EntitySchema>;
|
|
22
|
-
|
|
23
|
-
export class ${dashToPascal(name)}Entity extends BaseEntity<${dashToPascal(name)}Entity>() {
|
|
24
|
-
name!: string;
|
|
25
|
-
|
|
26
|
-
constructor(entity: ${dashToPascal(name)}) {
|
|
27
|
-
super(${dashToPascal(name)}EntitySchema);
|
|
28
|
-
Object.assign(this, this.validate(entity));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
`
|
|
32
|
-
|
|
33
|
-
module.exports = {
|
|
34
|
-
getCoreSingleEntity
|
|
35
|
-
}
|
|
File without changes
|