@nest-omni/core 3.1.1-10 → 3.1.1-9
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/package.json +27 -19
- package/.hygen/new/crud/controller.ejs.t +0 -82
- package/.hygen/new/crud/create.dto.ejs.t +0 -12
- package/.hygen/new/crud/entity.ejs.t +0 -26
- package/.hygen/new/crud/get.dto.ejs.t +0 -19
- package/.hygen/new/crud/index-dto.ejs.t +0 -29
- package/.hygen/new/crud/index-response.dto.ejs.t +0 -18
- package/.hygen/new/crud/module.ejs.t +0 -32
- package/.hygen/new/crud/prompt.js +0 -89
- package/.hygen/new/crud/service.ejs.t +0 -76
- package/.hygen/new/crud/update.dto.ejs.t +0 -11
- package/.hygen/new/module/controller.ejs.t +0 -93
- package/.hygen/new/module/create-command.ejs.t +0 -90
- package/.hygen/new/module/create.dto.ejs.t +0 -11
- package/.hygen/new/module/dto.ejs.t +0 -24
- package/.hygen/new/module/entity.ejs.t +0 -33
- package/.hygen/new/module/get-query.ejs.t +0 -57
- package/.hygen/new/module/module.ejs.t +0 -44
- package/.hygen/new/module/not-found.exception.ejs.t +0 -18
- package/.hygen/new/module/page-options.dto.ejs.t +0 -12
- package/.hygen/new/module/prompt.js +0 -104
- package/.hygen/new/module/repository.ejs.t +0 -16
- package/.hygen/new/module/service.ejs.t +0 -139
- package/.hygen/new/module/translation-dto.ejs.t +0 -27
- package/.hygen/new/module/translation-entity.ejs.t +0 -40
- package/.hygen/new/module/translation-repository.ejs.t +0 -16
- package/.hygen/new/module/update.dto.ejs.t +0 -10
- package/.hygen.js +0 -116
- package/common/abstract.entity.d.ts +0 -18
- package/common/abstract.entity.js +0 -78
- package/common/boilerplate.polyfill.d.ts +0 -39
- package/common/boilerplate.polyfill.js +0 -77
- package/common/dto/abstract.dto.d.ts +0 -13
- package/common/dto/abstract.dto.js +0 -59
- package/common/dto/bulk-id.dto.d.ts +0 -3
- package/common/dto/bulk-id.dto.js +0 -27
- package/common/dto/create-translation.dto.d.ts +0 -5
- package/common/dto/create-translation.dto.js +0 -25
- package/common/dto/index.d.ts +0 -6
- package/common/dto/index.js +0 -22
- package/common/dto/page-meta.dto.d.ts +0 -15
- package/common/dto/page-meta.dto.js +0 -48
- package/common/dto/page-options.dto.d.ts +0 -8
- package/common/dto/page-options.dto.js +0 -52
- package/common/dto/page.dto.d.ts +0 -11
- package/common/dto/page.dto.js +0 -53
- package/common/index.d.ts +0 -6
- package/common/index.js +0 -22
- package/common/snake-naming.strategy.d.ts +0 -11
- package/common/snake-naming.strategy.js +0 -37
- package/common/types.d.ts +0 -9
- package/common/types.js +0 -2
- package/common/utils.d.ts +0 -3
- package/common/utils.js +0 -24
- package/constants/index.d.ts +0 -2
- package/constants/index.js +0 -18
- package/constants/language-code.d.ts +0 -5
- package/constants/language-code.js +0 -9
- package/constants/order.d.ts +0 -4
- package/constants/order.js +0 -8
- package/decorators/api-page-ok-response.decorator.d.ts +0 -5
- package/decorators/api-page-ok-response.decorator.js +0 -24
- package/decorators/auth-user.decorator.d.ts +0 -1
- package/decorators/auth-user.decorator.js +0 -14
- package/decorators/controller.decorator.d.ts +0 -1
- package/decorators/controller.decorator.js +0 -10
- package/decorators/field.decorators.d.ts +0 -79
- package/decorators/field.decorators.js +0 -497
- package/decorators/http.decorators.d.ts +0 -3
- package/decorators/http.decorators.js +0 -7
- package/decorators/index.d.ts +0 -12
- package/decorators/index.js +0 -28
- package/decorators/operation.decorator.d.ts +0 -1
- package/decorators/operation.decorator.js +0 -6
- package/decorators/property.decorators.d.ts +0 -15
- package/decorators/property.decorators.js +0 -31
- package/decorators/public-route.decorator.d.ts +0 -3
- package/decorators/public-route.decorator.js +0 -7
- package/decorators/swagger.schema.d.ts +0 -5
- package/decorators/swagger.schema.js +0 -78
- package/decorators/timestamp-column.decorator.d.ts +0 -1
- package/decorators/timestamp-column.decorator.js +0 -27
- package/decorators/transform.decorators.d.ts +0 -8
- package/decorators/transform.decorators.js +0 -100
- package/decorators/translate.decorator.d.ts +0 -5
- package/decorators/translate.decorator.js +0 -17
- package/decorators/use-dto.decorator.d.ts +0 -4
- package/decorators/use-dto.decorator.js +0 -8
- package/decorators/user-check.decorator.d.ts +0 -6
- package/decorators/user-check.decorator.js +0 -21
- package/decorators/user.decorator.d.ts +0 -12
- package/decorators/user.decorator.js +0 -44
- package/decorators/user_auth.decorator.d.ts +0 -1
- package/decorators/user_auth.decorator.js +0 -15
- package/decorators/validator.decorators.d.ts +0 -11
- package/decorators/validator.decorators.js +0 -78
- package/exceptions/file-not-image.exception.d.ts +0 -4
- package/exceptions/file-not-image.exception.js +0 -10
- package/exceptions/index.d.ts +0 -2
- package/exceptions/index.js +0 -18
- package/exceptions/page-type.exception.d.ts +0 -4
- package/exceptions/page-type.exception.js +0 -10
- package/exceptions/user-not-found.exception.d.ts +0 -4
- package/exceptions/user-not-found.exception.js +0 -10
- package/filters/bad-request.filter.d.ts +0 -5
- package/filters/bad-request.filter.js +0 -71
- package/filters/constraint-errors.d.ts +0 -1
- package/filters/constraint-errors.js +0 -6
- package/filters/index.d.ts +0 -3
- package/filters/index.js +0 -19
- package/filters/query-failed.filter.d.ts +0 -10
- package/filters/query-failed.filter.js +0 -42
- package/health-checker/health-checker.controller.d.ts +0 -13
- package/health-checker/health-checker.controller.js +0 -69
- package/health-checker/health-checker.module.d.ts +0 -2
- package/health-checker/health-checker.module.js +0 -24
- package/health-checker/index.d.ts +0 -2
- package/health-checker/index.js +0 -18
- package/helpers/common.helper.d.ts +0 -3
- package/helpers/common.helper.js +0 -36
- package/helpers/date.helper.d.ts +0 -10
- package/helpers/date.helper.js +0 -57
- package/helpers/index.d.ts +0 -2
- package/helpers/index.js +0 -18
- package/i18n/en_US/validation.json +0 -41
- package/i18n/zh_CN/validation.json +0 -41
- package/index.d.ts +0 -15
- package/interceptors/index.d.ts +0 -2
- package/interceptors/index.js +0 -18
- package/interceptors/language-interceptor.service.d.ts +0 -6
- package/interceptors/language-interceptor.service.js +0 -29
- package/interceptors/translation-interceptor.service.d.ts +0 -5
- package/interceptors/translation-interceptor.service.js +0 -34
- package/interfaces/IApiFile.d.ts +0 -4
- package/interfaces/IApiFile.js +0 -2
- package/interfaces/IFile.d.ts +0 -8
- package/interfaces/IFile.js +0 -2
- package/interfaces/ITranslationDecoratorInterface.d.ts +0 -3
- package/interfaces/ITranslationDecoratorInterface.js +0 -2
- package/interfaces/index.d.ts +0 -3
- package/interfaces/index.js +0 -19
- package/interfaces/response.d.ts +0 -25
- package/interfaces/response.js +0 -2
- package/middlewares/index.d.ts +0 -4
- package/middlewares/index.js +0 -20
- package/middlewares/omni-auth.middleware.d.ts +0 -1
- package/middlewares/omni-auth.middleware.js +0 -13
- package/middlewares/powerby.middleware.d.ts +0 -1
- package/middlewares/powerby.middleware.js +0 -10
- package/middlewares/request-id.middleware.d.ts +0 -7
- package/middlewares/request-id.middleware.js +0 -22
- package/middlewares/xml.middleware.d.ts +0 -4
- package/middlewares/xml.middleware.js +0 -24
- package/providers/context.provider.d.ts +0 -34
- package/providers/context.provider.js +0 -80
- package/providers/generator.provider.d.ts +0 -9
- package/providers/generator.provider.js +0 -50
- package/providers/index.d.ts +0 -2
- package/providers/index.js +0 -18
- package/setup/bootstrap.setup.d.ts +0 -2
- package/setup/bootstrap.setup.js +0 -177
- package/setup/index.d.ts +0 -6
- package/setup/index.js +0 -22
- package/setup/mode.setup.d.ts +0 -12
- package/setup/mode.setup.js +0 -60
- package/setup/redis.lock.decorator.d.ts +0 -5
- package/setup/redis.lock.decorator.js +0 -60
- package/setup/redis.lock.service.d.ts +0 -56
- package/setup/redis.lock.service.js +0 -338
- package/setup/schedule.decorator.d.ts +0 -21
- package/setup/schedule.decorator.js +0 -127
- package/setup/worker.decorator.d.ts +0 -14
- package/setup/worker.decorator.js +0 -130
- package/shared/index.d.ts +0 -2
- package/shared/index.js +0 -18
- package/shared/serviceRegistryModule.d.ts +0 -2
- package/shared/serviceRegistryModule.js +0 -109
- package/shared/services/api-config.service.d.ts +0 -59
- package/shared/services/api-config.service.js +0 -311
- package/shared/services/generator.service.d.ts +0 -4
- package/shared/services/generator.service.js +0 -23
- package/shared/services/index.d.ts +0 -4
- package/shared/services/index.js +0 -20
- package/shared/services/translation.service.d.ts +0 -9
- package/shared/services/translation.service.js +0 -70
- package/shared/services/validator.service.d.ts +0 -3
- package/shared/services/validator.service.js +0 -20
- package/validator-json/decorators.d.ts +0 -6
- package/validator-json/decorators.js +0 -22
- package/validator-json/default.d.ts +0 -6
- package/validator-json/default.js +0 -138
- package/validator-json/defaultConverters.d.ts +0 -8
- package/validator-json/defaultConverters.js +0 -376
- package/validator-json/index.d.ts +0 -4
- package/validator-json/index.js +0 -20
- package/validator-json/options.d.ts +0 -11
- package/validator-json/options.js +0 -10
- package/validators/file-mimetype.validator.d.ts +0 -13
- package/validators/file-mimetype.validator.js +0 -21
- package/validators/index.d.ts +0 -6
- package/validators/index.js +0 -22
- package/validators/is-exists.validator.d.ts +0 -18
- package/validators/is-exists.validator.js +0 -60
- package/validators/is-unique.validator.d.ts +0 -17
- package/validators/is-unique.validator.js +0 -91
- package/validators/phone-country-code.validator.d.ts +0 -2
- package/validators/phone-country-code.validator.js +0 -29
- package/validators/same-as.validator.d.ts +0 -2
- package/validators/same-as.validator.js +0 -24
- package/validators/skip-empty.validator.d.ts +0 -1
- package/validators/skip-empty.validator.js +0 -17
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "src/modules/<%= h.fileName(name) %>/commands/<%= h.createCommandFileName(name) %>.ts"
|
|
3
|
-
unless_exists: true
|
|
4
|
-
skip_if: <%= !blocks.includes('CreateCommand') %>
|
|
5
|
-
---
|
|
6
|
-
<%
|
|
7
|
-
|
|
8
|
-
ClassName = h.ClassName(name);
|
|
9
|
-
fieldName = h.changeCase.camel(ClassName);
|
|
10
|
-
|
|
11
|
-
CreateCommandName = h.CreateCommandName(name);
|
|
12
|
-
CreateHandlerName = h.CreateHandlerName(name);
|
|
13
|
-
|
|
14
|
-
CreateDtoName = h.CreateDtoName(name);
|
|
15
|
-
createDtoName = h.changeCase.camel(CreateDtoName);
|
|
16
|
-
createDtoFileName = h.createDtoFileName(name);
|
|
17
|
-
|
|
18
|
-
EntityName = h.EntityName(name);
|
|
19
|
-
entityName = h.changeCase.camel(EntityName);
|
|
20
|
-
|
|
21
|
-
EntityName = h.EntityName(name);
|
|
22
|
-
entityName = h.changeCase.camel(EntityName);
|
|
23
|
-
entityFileName = h.entityFileName(name);
|
|
24
|
-
|
|
25
|
-
RepositoryName = h.RepositoryName(name);
|
|
26
|
-
TranslationRepositoryName = h.TranslationRepositoryName(name);
|
|
27
|
-
repositoryName = h.changeCase.camel(RepositoryName);
|
|
28
|
-
translationRepositoryName = h.changeCase.camel(TranslationRepositoryName);
|
|
29
|
-
repositoryFileName = h.repositoryFileName(name);
|
|
30
|
-
|
|
31
|
-
TranslationEntityName = h.TranslationEntityName(name);
|
|
32
|
-
TranslationDtoName = h.TranslationDtoName(name);
|
|
33
|
-
translationEntityFileName = h.translationEntityFileName(name);
|
|
34
|
-
translationRepositoryFileName = h.translationRepositoryFileName(name);
|
|
35
|
-
translationEntityName = h.changeCase.camel(TranslationEntityName);
|
|
36
|
-
|
|
37
|
-
%>import type { ICommand, ICommandHandler } from '@nestjs/cqrs';
|
|
38
|
-
import { CommandHandler } from '@nestjs/cqrs';
|
|
39
|
-
import { find } from 'lodash';
|
|
40
|
-
|
|
41
|
-
import type { <%= CreateDtoName %> } from '../dtos/<%= createDtoFileName %>';
|
|
42
|
-
import type { <%= EntityName %> } from '../<%= entityFileName %>';
|
|
43
|
-
import { <%= RepositoryName %> } from '../<%= repositoryFileName %>';
|
|
44
|
-
import type { <%= TranslationEntityName %> } from '../<%= translationEntityFileName %>';
|
|
45
|
-
import { <%= TranslationRepositoryName %> } from '../<%= translationRepositoryFileName %>';
|
|
46
|
-
|
|
47
|
-
export class <%= CreateCommandName %> implements ICommand {
|
|
48
|
-
constructor(
|
|
49
|
-
public readonly <%=createDtoName %>: <%= CreateDtoName %>,
|
|
50
|
-
) {}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@CommandHandler(<%= CreateCommandName %>)
|
|
54
|
-
export class <%= CreateHandlerName %>
|
|
55
|
-
implements ICommandHandler<<%= CreateCommandName %>, <%= EntityName %>>
|
|
56
|
-
{
|
|
57
|
-
constructor(
|
|
58
|
-
private <%= repositoryName %>: <%= RepositoryName %>,
|
|
59
|
-
private <%= translationRepositoryName %>: <%= TranslationRepositoryName %>,
|
|
60
|
-
) {}
|
|
61
|
-
|
|
62
|
-
async execute(command: <%= CreateCommandName %>) {
|
|
63
|
-
const { <%=createDtoName %> } = command;
|
|
64
|
-
const <%= entityName %> = this.<%= repositoryName %>.create();
|
|
65
|
-
const translations: <%= TranslationEntityName %>[] = [];
|
|
66
|
-
|
|
67
|
-
await this.<%= repositoryName %>.save(<%= entityName %>);
|
|
68
|
-
|
|
69
|
-
// FIXME: Create generic function for translation creation
|
|
70
|
-
for (const createTranslationDto of <%=createDtoName %>.title) {
|
|
71
|
-
const languageCode = createTranslationDto.languageCode;
|
|
72
|
-
const translationEntity = this.<%= translationRepositoryName %>.create({
|
|
73
|
-
<%= fieldName %>Id: <%= entityName %>.id,
|
|
74
|
-
languageCode,
|
|
75
|
-
title: createTranslationDto.text,
|
|
76
|
-
description: find(<%=createDtoName %>.description, {
|
|
77
|
-
languageCode,
|
|
78
|
-
})!.text,
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
translations.push(translationEntity);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
await this.<%= translationRepositoryName %>.save(translations);
|
|
85
|
-
|
|
86
|
-
<%= entityName %>.translations = translations;
|
|
87
|
-
|
|
88
|
-
return <%= entityName %>;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "src/modules/<%= h.fileName(name) %>/dtos/<%= h.createDtoFileName(name) %>.ts"
|
|
3
|
-
unless_exists: true
|
|
4
|
-
skip_if: <%= !blocks.includes('CreateDTO') %>
|
|
5
|
-
---
|
|
6
|
-
<%
|
|
7
|
-
|
|
8
|
-
ClassName = h.ClassName(name);
|
|
9
|
-
CreateDtoName = h.CreateDtoName(name);
|
|
10
|
-
|
|
11
|
-
%>export class <%= CreateDtoName %> {}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "src/modules/<%= h.fileName(name) %>/dtos/<%= h.dtoFileName(name) %>.ts"
|
|
3
|
-
unless_exists: true
|
|
4
|
-
skip_if: <%= !blocks.includes('DTO') %>
|
|
5
|
-
---
|
|
6
|
-
<%
|
|
7
|
-
|
|
8
|
-
DtoName = h.DtoName(name);
|
|
9
|
-
DtoOptionName = h.DtoOptionName(name);
|
|
10
|
-
EntityName = h.EntityName(name);
|
|
11
|
-
entityName = h.changeCase.camel(EntityName);
|
|
12
|
-
entityFileName = h.entityFileName(name);
|
|
13
|
-
|
|
14
|
-
%>import { AbstractDto } from '@nest-omni/core/common/dto/abstract.dto';
|
|
15
|
-
import type { <%= EntityName %> } from '../<%= entityFileName %>';
|
|
16
|
-
|
|
17
|
-
export interface <%= DtoOptionName %> {
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export class <%= DtoName %> extends AbstractDto {
|
|
21
|
-
constructor(entityName: <%= EntityName %>, options?: <%= DtoOptionName %>) {
|
|
22
|
-
super(entityName);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "src/modules/<%= h.fileName(name) %>/<%= h.entityFileName(name) %>.ts"
|
|
3
|
-
unless_exists: true
|
|
4
|
-
skip_if: <%= !blocks.includes('Entity') %>
|
|
5
|
-
---
|
|
6
|
-
<%
|
|
7
|
-
ClassName = h.ClassName(name);
|
|
8
|
-
DtoName = h.DtoName(name);
|
|
9
|
-
fieldName = h.changeCase.camel(ClassName);
|
|
10
|
-
dtoFileName = h.dtoFileName(name);
|
|
11
|
-
translationEntityFileName = h.translationEntityFileName(name);
|
|
12
|
-
DtoOptionName = h.DtoOptionName(name);
|
|
13
|
-
TableName = h.TableName(name);
|
|
14
|
-
EntityName = h.EntityName(name);
|
|
15
|
-
TranslationEntityName = h.TranslationEntityName(name);
|
|
16
|
-
translationEntityName = h.changeCase.camel(TranslationEntityName);
|
|
17
|
-
%>import { Entity, OneToMany } from 'typeorm';
|
|
18
|
-
|
|
19
|
-
import { AbstractEntity } from '@nest-omni/core/common/abstract.entity';
|
|
20
|
-
import { UseDto } from '@nest-omni/core/decorators';
|
|
21
|
-
import type { <%= DtoOptionName %> } from './dtos/<%= dtoFileName %>';
|
|
22
|
-
import { <%= DtoName %> } from './dtos/<%= dtoFileName %>';
|
|
23
|
-
import { <%= TranslationEntityName %> } from './<%= translationEntityFileName %>';
|
|
24
|
-
|
|
25
|
-
@Entity({ name: '<%= TableName %>' })
|
|
26
|
-
@UseDto(<%= DtoName %>)
|
|
27
|
-
export class <%= EntityName %> extends AbstractEntity<<%= DtoName %>, <%= DtoOptionName %>> {
|
|
28
|
-
@OneToMany(
|
|
29
|
-
() => <%= TranslationEntityName %>,
|
|
30
|
-
(<%= translationEntityName %>) => <%= translationEntityName %>.<%= fieldName %>,
|
|
31
|
-
)
|
|
32
|
-
translations: <%= TranslationEntityName %>[];
|
|
33
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "src/modules/<%= h.fileName(name) %>/queries/<%= h.getQueryFileName(name) %>.ts"
|
|
3
|
-
unless_exists: true
|
|
4
|
-
skip_if: <%= !blocks.includes('GetQuery') %>
|
|
5
|
-
---
|
|
6
|
-
<%
|
|
7
|
-
|
|
8
|
-
ClassName = h.ClassName(name);
|
|
9
|
-
fieldName = h.changeCase.camel(ClassName);
|
|
10
|
-
|
|
11
|
-
GetQueryName = h.GetQueryName(name);
|
|
12
|
-
GetHandlerName = h.GetHandlerName(name);
|
|
13
|
-
|
|
14
|
-
CreateDtoName = h.CreateDtoName(name);
|
|
15
|
-
createDtoName = h.changeCase.camel(CreateDtoName);
|
|
16
|
-
createDtoFileName = h.createDtoFileName(name);
|
|
17
|
-
|
|
18
|
-
EntityName = h.EntityName(name);
|
|
19
|
-
entityName = h.changeCase.camel(EntityName);
|
|
20
|
-
|
|
21
|
-
EntityName = h.EntityName(name);
|
|
22
|
-
entityName = h.changeCase.camel(EntityName);
|
|
23
|
-
entityFileName = h.entityFileName(name);
|
|
24
|
-
|
|
25
|
-
RepositoryName = h.RepositoryName(name);
|
|
26
|
-
TranslationRepositoryName = h.TranslationRepositoryName(name);
|
|
27
|
-
repositoryName = h.changeCase.camel(RepositoryName);
|
|
28
|
-
translationRepositoryName = h.changeCase.camel(TranslationRepositoryName);
|
|
29
|
-
repositoryFileName = h.repositoryFileName(name);
|
|
30
|
-
|
|
31
|
-
TranslationEntityName = h.TranslationEntityName(name);
|
|
32
|
-
TranslationDtoName = h.TranslationDtoName(name);
|
|
33
|
-
translationEntityFileName = h.translationEntityFileName(name);
|
|
34
|
-
translationRepositoryFileName = h.translationRepositoryFileName(name);
|
|
35
|
-
translationEntityName = h.changeCase.camel(TranslationEntityName);
|
|
36
|
-
|
|
37
|
-
%>import type { ICommand, IQueryHandler } from '@nestjs/cqrs';
|
|
38
|
-
import { QueryHandler } from '@nestjs/cqrs';
|
|
39
|
-
|
|
40
|
-
import { <%= RepositoryName %> } from '../<%= repositoryFileName %>';
|
|
41
|
-
|
|
42
|
-
export class <%= GetQueryName %> implements ICommand {
|
|
43
|
-
constructor(
|
|
44
|
-
public readonly userId: Uuid,
|
|
45
|
-
) {}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
@QueryHandler(<%= GetQueryName %>)
|
|
49
|
-
export class <%= GetHandlerName %> implements IQueryHandler<<%= GetQueryName %>> {
|
|
50
|
-
constructor(private <%= repositoryName %>: <%= RepositoryName %>) {}
|
|
51
|
-
|
|
52
|
-
async execute(query: <%= GetQueryName %>) {
|
|
53
|
-
return this.<%= repositoryName %>.find({
|
|
54
|
-
userId: query.userId,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "src/modules/<%= h.fileName(name) %>/<%= h.moduleFileName(name) %>.ts"
|
|
3
|
-
unless_exists: true
|
|
4
|
-
---
|
|
5
|
-
<%
|
|
6
|
-
|
|
7
|
-
ModuleName = h.ModuleName(name);
|
|
8
|
-
fileName = h.inflection.dasherize(name);
|
|
9
|
-
|
|
10
|
-
ControllerName = h.ControllerName(name);
|
|
11
|
-
controllerFileName = h.controllerFileName(name);
|
|
12
|
-
|
|
13
|
-
ServiceName = h.ServiceName(name);
|
|
14
|
-
serviceFileName = h.serviceFileName(name);
|
|
15
|
-
|
|
16
|
-
RepositoryName = h.RepositoryName(name);
|
|
17
|
-
repositoryFileName = h.repositoryFileName(name);
|
|
18
|
-
|
|
19
|
-
createCommandFileName = h.createCommandFileName(name);
|
|
20
|
-
getQueryFileName = h.getQueryFileName(name);
|
|
21
|
-
|
|
22
|
-
%>import { Module } from '@nestjs/common';
|
|
23
|
-
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
24
|
-
|
|
25
|
-
import { <%= CreateHandlerName %> } from './commands/<%= createCommandFileName %>';
|
|
26
|
-
import { <%= ControllerName %> } from './<%= controllerFileName %>';
|
|
27
|
-
import { <%= RepositoryName %> } from './<%= repositoryFileName %>';
|
|
28
|
-
import { <%= TranslationRepositoryName %> } from './<%= translationRepositoryFileName %>';
|
|
29
|
-
import { <%= ServiceName %> } from './<%= serviceFileName %>';
|
|
30
|
-
import { <%= GetHandlerName %> } from './queries/<%= getQueryFileName %>';
|
|
31
|
-
|
|
32
|
-
export const handlers = [
|
|
33
|
-
<%= CreateHandlerName %>,
|
|
34
|
-
<%= GetHandlerName %>,
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
@Module({
|
|
38
|
-
imports: [
|
|
39
|
-
TypeOrmModule.forFeature([<%= RepositoryName %>, <%= TranslationRepositoryName %>]),
|
|
40
|
-
],
|
|
41
|
-
providers: [<%= ServiceName %>, ...handlers],
|
|
42
|
-
controllers: [<%= ControllerName %>],
|
|
43
|
-
})
|
|
44
|
-
export class <%= ModuleName %> {}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "src/modules/<%= h.fileName(name) %>/exceptions/<%= h.notFoundExceptionFileName(name) %>.ts"
|
|
3
|
-
unless_exists: true
|
|
4
|
-
skip_if: <%= !blocks.includes('NotFoundException') %>
|
|
5
|
-
---
|
|
6
|
-
<%
|
|
7
|
-
|
|
8
|
-
ClassName = h.ClassName(name);
|
|
9
|
-
fieldName = h.changeCase.camel(ClassName);
|
|
10
|
-
NotFoundExceptionName = h.NotFoundExceptionName(name);
|
|
11
|
-
|
|
12
|
-
%>import { NotFoundException } from '@nestjs/common';
|
|
13
|
-
|
|
14
|
-
export class <%= NotFoundExceptionName %> extends NotFoundException {
|
|
15
|
-
constructor(error?: string) {
|
|
16
|
-
super('error.<%= fieldName %>NotFound', error);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "src/modules/<%= h.fileName(name) %>/dtos/<%= h.pageOptionsDtoFileName(name) %>.ts"
|
|
3
|
-
unless_exists: true
|
|
4
|
-
skip_if: <%= !blocks.includes('PageOptionsDTO') %>
|
|
5
|
-
---
|
|
6
|
-
<%
|
|
7
|
-
|
|
8
|
-
PageOptionsDtoName = h.PageOptionsDtoName(name);
|
|
9
|
-
|
|
10
|
-
%>import { PageOptionsDto } from '@nest-omni/core/common/dto/page-options.dto';
|
|
11
|
-
|
|
12
|
-
export class <%= PageOptionsDtoName %> extends PageOptionsDto {}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
prompt: ({ prompter, args }) => {
|
|
5
|
-
return prompter.prompt([
|
|
6
|
-
{
|
|
7
|
-
type: 'input',
|
|
8
|
-
name: 'name',
|
|
9
|
-
message: 'Name:',
|
|
10
|
-
validate(value) {
|
|
11
|
-
if (!value.length) {
|
|
12
|
-
return 'Module must have a name.';
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
type: 'MultiSelect',
|
|
19
|
-
name: 'blocks',
|
|
20
|
-
message: 'Blocks:',
|
|
21
|
-
initial: [
|
|
22
|
-
'Controller',
|
|
23
|
-
'CreateCommand',
|
|
24
|
-
'CreateDTO',
|
|
25
|
-
'DTO',
|
|
26
|
-
'Entity',
|
|
27
|
-
'GetQuery',
|
|
28
|
-
//'Module',
|
|
29
|
-
'NotFoundException',
|
|
30
|
-
'PageOptionsDTO',
|
|
31
|
-
'Repository',
|
|
32
|
-
'Service',
|
|
33
|
-
'TranslationDTO',
|
|
34
|
-
'TranslationEntity',
|
|
35
|
-
'TranslationRepository',
|
|
36
|
-
'UpdateDTO'
|
|
37
|
-
],
|
|
38
|
-
choices: [
|
|
39
|
-
{
|
|
40
|
-
name: 'Controller',
|
|
41
|
-
value: 'controller',
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
name: 'CreateCommand',
|
|
45
|
-
value: 'create-command',
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: 'CreateDTO',
|
|
49
|
-
value: 'create-dto',
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: 'DTO',
|
|
53
|
-
value: 'dto',
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: 'Entity',
|
|
57
|
-
value: 'entity',
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: 'GetQuery',
|
|
61
|
-
value: 'get-query',
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: 'NotFoundException',
|
|
65
|
-
value: 'not-found-exception',
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
name: 'PageOptionsDTO',
|
|
69
|
-
value: 'page-options-dto',
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
name: 'Repository',
|
|
73
|
-
value: 'repository',
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
name: 'Service',
|
|
77
|
-
value: 'service',
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
name: 'TranslationDTO',
|
|
81
|
-
value: 'translation-dto',
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
name: 'TranslationEntity',
|
|
85
|
-
value: 'translationEntity',
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
name: 'TranslationRepository',
|
|
89
|
-
value: 'translation-repository',
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
name: 'UpdateDTO',
|
|
93
|
-
value: 'update-dto',
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
}
|
|
97
|
-
])
|
|
98
|
-
.then(answer => {
|
|
99
|
-
//// For debugging
|
|
100
|
-
// console.log(answer)
|
|
101
|
-
return answer;
|
|
102
|
-
})
|
|
103
|
-
}
|
|
104
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "src/modules/<%= h.fileName(name) %>/<%= h.repositoryFileName(name) %>.ts"
|
|
3
|
-
unless_exists: true
|
|
4
|
-
skip_if: <%= !blocks.includes('Repository') %>
|
|
5
|
-
---
|
|
6
|
-
<%
|
|
7
|
-
EntityName = h.EntityName(name);
|
|
8
|
-
entityFileName = h.entityFileName(name);
|
|
9
|
-
|
|
10
|
-
RepositoryName = h.RepositoryName(name);
|
|
11
|
-
%>import { EntityRepository, Repository } from 'typeorm';
|
|
12
|
-
|
|
13
|
-
import { <%= EntityName %> } from './<%= entityFileName %>';
|
|
14
|
-
|
|
15
|
-
@EntityRepository(<%= EntityName %>)
|
|
16
|
-
export class <%= RepositoryName %> extends Repository<<%= EntityName %>> {}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "src/modules/<%= h.fileName(name) %>/<%= h.serviceFileName(name) %>.ts"
|
|
3
|
-
unless_exists: true
|
|
4
|
-
skip_if: <%= !blocks.includes('Service') %>
|
|
5
|
-
---
|
|
6
|
-
<%
|
|
7
|
-
|
|
8
|
-
ClassName = h.ClassName(name);
|
|
9
|
-
fieldName = h.changeCase.camel(ClassName);
|
|
10
|
-
|
|
11
|
-
DtoName = h.DtoName(name);
|
|
12
|
-
dtoFileName = h.dtoFileName(name);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
CreateCommandName = h.CreateCommandName(name);
|
|
16
|
-
createCommandFileName = h.createCommandFileName(name);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
EntityName = h.EntityName(name);
|
|
20
|
-
entityName = h.changeCase.camel(EntityName);
|
|
21
|
-
entityFileName = h.entityFileName(name);
|
|
22
|
-
|
|
23
|
-
ServiceName = h.ServiceName(name);
|
|
24
|
-
|
|
25
|
-
UpdateDtoName = h.UpdateDtoName(name);
|
|
26
|
-
updateDtoFileName = h.updateDtoFileName(name);
|
|
27
|
-
updateDtoName = h.changeCase.camel(UpdateDtoName);
|
|
28
|
-
|
|
29
|
-
fileName = h.fileName(name);
|
|
30
|
-
|
|
31
|
-
RepositoryName = h.RepositoryName(name);
|
|
32
|
-
repositoryName = h.changeCase.camel(RepositoryName);
|
|
33
|
-
repositoryFileName = h.repositoryFileName(name);
|
|
34
|
-
|
|
35
|
-
NotFoundExceptionName = h.NotFoundExceptionName(name);
|
|
36
|
-
notFoundExceptionFileName = h.notFoundExceptionFileName(name);
|
|
37
|
-
|
|
38
|
-
createFunctionName = 'create' + ClassName;
|
|
39
|
-
updateFunctionName = 'update' + ClassName;
|
|
40
|
-
deleteFunctionName = 'delete' + ClassName;
|
|
41
|
-
getAllFunctionName = 'getAll' + ClassName;
|
|
42
|
-
getSingleFunctionName = 'getSingle' + ClassName;
|
|
43
|
-
controllerName = moduleName + 'Controller';
|
|
44
|
-
serviceName = moduleName + 'Service';
|
|
45
|
-
CreateDtoName = h.CreateDtoName(name);
|
|
46
|
-
createDtoFileName = h.createDtoFileName(name);
|
|
47
|
-
|
|
48
|
-
PageOptionsDtoName = h.PageOptionsDtoName(name);
|
|
49
|
-
pageOptionsDtoName = h.changeCase.camel(PageOptionsDtoName);
|
|
50
|
-
pageOptionsDtoFileName = h.pageOptionsDtoFileName(name);
|
|
51
|
-
|
|
52
|
-
%>import { Injectable } from '@nestjs/common';
|
|
53
|
-
import { CommandBus } from '@nestjs/cqrs';
|
|
54
|
-
import { Transactional } from 'typeorm-transactional';
|
|
55
|
-
|
|
56
|
-
import type { PageDto } from '@nest-omni/core/common/dto/page.dto';
|
|
57
|
-
import { ValidatorService } from '@nest-omni/core/shared/services/validator.service';
|
|
58
|
-
import { <%= CreateCommandName %> } from './commands/<%= createCommandFileName %>';
|
|
59
|
-
import type { <%= DtoName %> } from './dtos/<%= dtoFileName %>';
|
|
60
|
-
import type { <%= PageOptionsDtoName %> } from './dtos/<%= pageOptionsDtoFileName %>';
|
|
61
|
-
import { <%= NotFoundExceptionName %> } from './exceptions/<%= notFoundExceptionFileName %>';
|
|
62
|
-
import type { <%= EntityName %> } from './<%= entityFileName %>';
|
|
63
|
-
import { <%= RepositoryName %> } from './<%= repositoryFileName %>';
|
|
64
|
-
import { <%= CreateDtoName %> } from './dtos/<%= createDtoFileName %>';
|
|
65
|
-
import type { <%= UpdateDtoName %> } from './dtos/<%= updateDtoFileName %>';
|
|
66
|
-
|
|
67
|
-
@Injectable()
|
|
68
|
-
export class <%= ServiceName %> {
|
|
69
|
-
constructor(
|
|
70
|
-
private <%= repositoryName %>: <%= RepositoryName %>,
|
|
71
|
-
private validatorService: ValidatorService,
|
|
72
|
-
private commandBus: CommandBus,
|
|
73
|
-
) {}
|
|
74
|
-
|
|
75
|
-
@Transactional()
|
|
76
|
-
<%= createFunctionName %>(<%= createDtoName %>: <%= CreateDtoName %>): Promise<<%= EntityName %>> {
|
|
77
|
-
return this.commandBus.execute<<%= CreateCommandName %>, <%= EntityName %>>(
|
|
78
|
-
new <%= CreateCommandName %>(<%= createDtoName %>),
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
async <%= getAllFunctionName %>(
|
|
83
|
-
<%= pageOptionsDtoName %>: <%= PageOptionsDtoName %>,
|
|
84
|
-
): Promise<PageDto<<%= DtoName %>>> {
|
|
85
|
-
const queryBuilder = this.<%= repositoryName %>
|
|
86
|
-
.createQueryBuilder('<%= fieldName %>')
|
|
87
|
-
.leftJoinAndSelect('<%= fieldName %>.translations', '<%= fieldName %>Translation');
|
|
88
|
-
const [items, pageMetaDto] = await queryBuilder.paginate(<%= pageOptionsDtoName %>);
|
|
89
|
-
|
|
90
|
-
return items.toPageDto(pageMetaDto);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
async <%= getSingleFunctionName %>(id: Uuid): Promise<<%= EntityName %>> {
|
|
94
|
-
const queryBuilder = this.<%= repositoryName %>
|
|
95
|
-
.createQueryBuilder('<%= fieldName %>')
|
|
96
|
-
.where('<%= fieldName %>.id = :id', { id });
|
|
97
|
-
|
|
98
|
-
const <%= entityName %> = await queryBuilder.getOne();
|
|
99
|
-
|
|
100
|
-
if (!<%= entityName %>) {
|
|
101
|
-
throw new <%= NotFoundExceptionName %>();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return <%= entityName %>;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
async <%= updateFunctionName %>(
|
|
108
|
-
id: Uuid,
|
|
109
|
-
<%= updateDtoName %>: <%= UpdateDtoName %>,
|
|
110
|
-
): Promise<void> {
|
|
111
|
-
const queryBuilder = this.<%= repositoryName %>
|
|
112
|
-
.createQueryBuilder('<%= fieldName %>')
|
|
113
|
-
.where('<%= fieldName %>.id = :id', { id });
|
|
114
|
-
|
|
115
|
-
const <%= entityName %> = await queryBuilder.getOne();
|
|
116
|
-
|
|
117
|
-
if (!<%= entityName %>) {
|
|
118
|
-
throw new <%= NotFoundExceptionName %>();
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
this.<%= repositoryName %>.merge(<%= entityName %>, <%= updateDtoName %>);
|
|
122
|
-
|
|
123
|
-
await this.<%= repositoryName %>.save(<%= updateDtoName %>);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
async <%= deleteFunctionName %>(id: Uuid): Promise<void> {
|
|
127
|
-
const queryBuilder = this.<%= repositoryName %>
|
|
128
|
-
.createQueryBuilder('<%= fieldName %>')
|
|
129
|
-
.where('<%= fieldName %>.id = :id', { id });
|
|
130
|
-
|
|
131
|
-
const <%= entityName %> = await queryBuilder.getOne();
|
|
132
|
-
|
|
133
|
-
if (!<%= entityName %>) {
|
|
134
|
-
throw new <%= NotFoundExceptionName %>();
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
await this.<%= repositoryName %>.remove(<%= entityName %>);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "src/modules/<%= h.fileName(name) %>/dtos/<%= h.translationDtoFileName(name) %>.ts"
|
|
3
|
-
unless_exists: true
|
|
4
|
-
skip_if: <%= !blocks.includes('TranslationDTO') %>
|
|
5
|
-
---
|
|
6
|
-
<%
|
|
7
|
-
|
|
8
|
-
TranslationDtoName = h.TranslationDtoName(name);
|
|
9
|
-
translationEntityFileName = h.translationEntityFileName(name);
|
|
10
|
-
TranslationEntityName = h.TranslationEntityName(name);
|
|
11
|
-
translationEntityName = h.changeCase.camel(TranslationEntityName);
|
|
12
|
-
|
|
13
|
-
%>import { AbstractTranslationDto } from '@nest-omni/core/common/dto/abstract.dto';
|
|
14
|
-
import { LanguageCode } from '../../../constants';
|
|
15
|
-
import { ApiEnumPropertyOptional } from '../@nest-omni/core/decorators';
|
|
16
|
-
import type { <%= TranslationEntityName %> } from '../<%= translationEntityFileName %>';
|
|
17
|
-
|
|
18
|
-
export class <%= TranslationDtoName %> extends AbstractTranslationDto {
|
|
19
|
-
@ApiEnumPropertyOptional(() => LanguageCode)
|
|
20
|
-
languageCode: LanguageCode;
|
|
21
|
-
|
|
22
|
-
constructor(<%= translationEntityName %>: <%= TranslationEntityName %>) {
|
|
23
|
-
super(<%= translationEntityName %>);
|
|
24
|
-
|
|
25
|
-
this.languageCode = <%= translationEntityName %>.languageCode;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "src/modules/<%= h.fileName(name) %>/<%= h.translationEntityFileName(name) %>.ts"
|
|
3
|
-
unless_exists: true
|
|
4
|
-
skip_if: <%= !blocks.includes('TranslationEntity') %>
|
|
5
|
-
---
|
|
6
|
-
<%
|
|
7
|
-
ClassName = h.ClassName(name);
|
|
8
|
-
fieldName = h.changeCase.camel(ClassName);
|
|
9
|
-
DtoName = h.DtoName(name);
|
|
10
|
-
dtoFileName = h.dtoFileName(name);
|
|
11
|
-
translationDtoFileName = h.translationDtoFileName(name);
|
|
12
|
-
translationEntityFileName = h.translationEntityFileName(name);
|
|
13
|
-
DtoOptionName = h.DtoOptionName(name);
|
|
14
|
-
var_name = h.inflection.dasherize(name);
|
|
15
|
-
EntityName = h.EntityName(name);
|
|
16
|
-
entityName = h.changeCase.camel(EntityName);
|
|
17
|
-
TranslationEntityName = h.TranslationEntityName(name);
|
|
18
|
-
TranslationDtoName = h.TranslationDtoName(name);
|
|
19
|
-
translationEntityName = h.changeCase.camel(TranslationEntityName);
|
|
20
|
-
%>import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm';
|
|
21
|
-
|
|
22
|
-
import { AbstractTranslationEntity } from '@nest-omni/core/common/abstract.entity';
|
|
23
|
-
import { UseDto } from '@nest-omni/core/decorators';
|
|
24
|
-
import { <%= TranslationDtoName %> } from './dtos/<%= translationDtoFileName %>';
|
|
25
|
-
import { <%= EntityName %> } from './<%= entityFileName %>';
|
|
26
|
-
|
|
27
|
-
@Entity({ name: '<%= var_name %>_translations' })
|
|
28
|
-
@UseDto(<%= TranslationDtoName %>)
|
|
29
|
-
export class <%= TranslationEntityName %> extends AbstractTranslationEntity<<%= TranslationDtoName %>> {
|
|
30
|
-
@Column({ type: 'uuid' })
|
|
31
|
-
<%= fieldName %>Id: Uuid;
|
|
32
|
-
|
|
33
|
-
@ManyToOne(() => <%= EntityName %>, (<%= entityName %>) => <%= entityName %>.translations, {
|
|
34
|
-
onDelete: 'CASCADE',
|
|
35
|
-
onUpdate: 'CASCADE',
|
|
36
|
-
})
|
|
37
|
-
@JoinColumn({ name: '<%= var_name %>_id' })
|
|
38
|
-
<%= fieldName %>: <%= EntityName %>;
|
|
39
|
-
}
|
|
40
|
-
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "src/modules/<%= h.fileName(name) %>/<%= h.translationRepositoryFileName(name) %>.ts"
|
|
3
|
-
unless_exists: true
|
|
4
|
-
skip_if: <%= !blocks.includes('TranslationRepository') %>
|
|
5
|
-
---
|
|
6
|
-
<%
|
|
7
|
-
TranslationEntityName = h.TranslationEntityName(name);
|
|
8
|
-
translationEntityFileName = h.translationEntityFileName(name);
|
|
9
|
-
|
|
10
|
-
TranslationRepositoryName = h.TranslationRepositoryName(name);
|
|
11
|
-
%>import { EntityRepository, Repository } from 'typeorm';
|
|
12
|
-
|
|
13
|
-
import { <%= TranslationEntityName %> } from './<%= translationEntityFileName %>';
|
|
14
|
-
|
|
15
|
-
@EntityRepository(<%= TranslationEntityName %>)
|
|
16
|
-
export class <%= TranslationRepositoryName %> extends Repository<<%= TranslationEntityName %>> {}
|