@steroidsjs/nest 1.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.
Files changed (127) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/domain/base/BaseEnum.d.ts +9 -0
  4. package/domain/base/BaseEnum.js +35 -0
  5. package/domain/base/BaseEnum.js.map +1 -0
  6. package/index.d.ts +0 -0
  7. package/index.js +1 -0
  8. package/index.js.map +1 -0
  9. package/infrastructure/commands/MigrateCommand.d.ts +23 -0
  10. package/infrastructure/commands/MigrateCommand.js +186 -0
  11. package/infrastructure/commands/MigrateCommand.js.map +1 -0
  12. package/infrastructure/decorators/ApiOkSearchResponse.d.ts +1 -0
  13. package/infrastructure/decorators/ApiOkSearchResponse.js +25 -0
  14. package/infrastructure/decorators/ApiOkSearchResponse.js.map +1 -0
  15. package/infrastructure/decorators/fields/BaseField.d.ts +17 -0
  16. package/infrastructure/decorators/fields/BaseField.js +24 -0
  17. package/infrastructure/decorators/fields/BaseField.js.map +1 -0
  18. package/infrastructure/decorators/fields/BooleanField.d.ts +2 -0
  19. package/infrastructure/decorators/fields/BooleanField.js +17 -0
  20. package/infrastructure/decorators/fields/BooleanField.js.map +1 -0
  21. package/infrastructure/decorators/fields/CoordinateField.d.ts +7 -0
  22. package/infrastructure/decorators/fields/CoordinateField.js +18 -0
  23. package/infrastructure/decorators/fields/CoordinateField.js.map +1 -0
  24. package/infrastructure/decorators/fields/CreateTimeField.d.ts +5 -0
  25. package/infrastructure/decorators/fields/CreateTimeField.js +35 -0
  26. package/infrastructure/decorators/fields/CreateTimeField.js.map +1 -0
  27. package/infrastructure/decorators/fields/DateField.d.ts +2 -0
  28. package/infrastructure/decorators/fields/DateField.js +17 -0
  29. package/infrastructure/decorators/fields/DateField.js.map +1 -0
  30. package/infrastructure/decorators/fields/DateTimeField.d.ts +5 -0
  31. package/infrastructure/decorators/fields/DateTimeField.js +19 -0
  32. package/infrastructure/decorators/fields/DateTimeField.js.map +1 -0
  33. package/infrastructure/decorators/fields/DecimalField.d.ts +7 -0
  34. package/infrastructure/decorators/fields/DecimalField.js +18 -0
  35. package/infrastructure/decorators/fields/DecimalField.js.map +1 -0
  36. package/infrastructure/decorators/fields/EmailField.d.ts +2 -0
  37. package/infrastructure/decorators/fields/EmailField.js +19 -0
  38. package/infrastructure/decorators/fields/EmailField.js.map +1 -0
  39. package/infrastructure/decorators/fields/EnumField.d.ts +6 -0
  40. package/infrastructure/decorators/fields/EnumField.js +31 -0
  41. package/infrastructure/decorators/fields/EnumField.js.map +1 -0
  42. package/infrastructure/decorators/fields/ExtendField.d.ts +5 -0
  43. package/infrastructure/decorators/fields/ExtendField.js +20 -0
  44. package/infrastructure/decorators/fields/ExtendField.js.map +1 -0
  45. package/infrastructure/decorators/fields/ExtendFields.d.ts +1 -0
  46. package/infrastructure/decorators/fields/ExtendFields.js +15 -0
  47. package/infrastructure/decorators/fields/ExtendFields.js.map +1 -0
  48. package/infrastructure/decorators/fields/FileField.d.ts +2 -0
  49. package/infrastructure/decorators/fields/FileField.js +16 -0
  50. package/infrastructure/decorators/fields/FileField.js.map +1 -0
  51. package/infrastructure/decorators/fields/HtmlField.d.ts +2 -0
  52. package/infrastructure/decorators/fields/HtmlField.js +15 -0
  53. package/infrastructure/decorators/fields/HtmlField.js.map +1 -0
  54. package/infrastructure/decorators/fields/IntegerField.d.ts +2 -0
  55. package/infrastructure/decorators/fields/IntegerField.js +22 -0
  56. package/infrastructure/decorators/fields/IntegerField.js.map +1 -0
  57. package/infrastructure/decorators/fields/PasswordField.d.ts +2 -0
  58. package/infrastructure/decorators/fields/PasswordField.js +20 -0
  59. package/infrastructure/decorators/fields/PasswordField.js.map +1 -0
  60. package/infrastructure/decorators/fields/PhoneField.d.ts +2 -0
  61. package/infrastructure/decorators/fields/PhoneField.js +20 -0
  62. package/infrastructure/decorators/fields/PhoneField.js.map +1 -0
  63. package/infrastructure/decorators/fields/PrimaryKeyField.d.ts +2 -0
  64. package/infrastructure/decorators/fields/PrimaryKeyField.js +14 -0
  65. package/infrastructure/decorators/fields/PrimaryKeyField.js.map +1 -0
  66. package/infrastructure/decorators/fields/RelationField.d.ts +6 -0
  67. package/infrastructure/decorators/fields/RelationField.js +16 -0
  68. package/infrastructure/decorators/fields/RelationField.js.map +1 -0
  69. package/infrastructure/decorators/fields/StringField.d.ts +2 -0
  70. package/infrastructure/decorators/fields/StringField.js +24 -0
  71. package/infrastructure/decorators/fields/StringField.js.map +1 -0
  72. package/infrastructure/decorators/fields/TextField.d.ts +2 -0
  73. package/infrastructure/decorators/fields/TextField.js +16 -0
  74. package/infrastructure/decorators/fields/TextField.js.map +1 -0
  75. package/infrastructure/decorators/fields/TimeField.d.ts +2 -0
  76. package/infrastructure/decorators/fields/TimeField.js +17 -0
  77. package/infrastructure/decorators/fields/TimeField.js.map +1 -0
  78. package/infrastructure/decorators/fields/UidField.d.ts +2 -0
  79. package/infrastructure/decorators/fields/UidField.js +34 -0
  80. package/infrastructure/decorators/fields/UidField.js.map +1 -0
  81. package/infrastructure/decorators/fields/UpdateTimeField.d.ts +5 -0
  82. package/infrastructure/decorators/fields/UpdateTimeField.js +37 -0
  83. package/infrastructure/decorators/fields/UpdateTimeField.js.map +1 -0
  84. package/infrastructure/decorators/fields/index.d.ts +18 -0
  85. package/infrastructure/decorators/fields/index.js +40 -0
  86. package/infrastructure/decorators/fields/index.js.map +1 -0
  87. package/infrastructure/exception/ValidationException.d.ts +5 -0
  88. package/infrastructure/exception/ValidationException.js +12 -0
  89. package/infrastructure/exception/ValidationException.js.map +1 -0
  90. package/infrastructure/helpers/ConditionHelper.d.ts +8 -0
  91. package/infrastructure/helpers/ConditionHelper.js +74 -0
  92. package/infrastructure/helpers/ConditionHelper.js.map +1 -0
  93. package/infrastructure/helpers/DataMapperHelper.d.ts +4 -0
  94. package/infrastructure/helpers/DataMapperHelper.js +18 -0
  95. package/infrastructure/helpers/DataMapperHelper.js.map +1 -0
  96. package/infrastructure/helpers/MetaHelper.d.ts +5 -0
  97. package/infrastructure/helpers/MetaHelper.js +35 -0
  98. package/infrastructure/helpers/MetaHelper.js.map +1 -0
  99. package/infrastructure/helpers/SearchHelper.d.ts +7 -0
  100. package/infrastructure/helpers/SearchHelper.js +30 -0
  101. package/infrastructure/helpers/SearchHelper.js.map +1 -0
  102. package/infrastructure/pipes/ValidationPipe.d.ts +4 -0
  103. package/infrastructure/pipes/ValidationPipe.js +37 -0
  104. package/infrastructure/pipes/ValidationPipe.js.map +1 -0
  105. package/infrastructure/repositories/CrudRepository.d.ts +18 -0
  106. package/infrastructure/repositories/CrudRepository.js +53 -0
  107. package/infrastructure/repositories/CrudRepository.js.map +1 -0
  108. package/infrastructure/schemas/BaseSchema.d.ts +6 -0
  109. package/infrastructure/schemas/BaseSchema.js +19 -0
  110. package/infrastructure/schemas/BaseSchema.js.map +1 -0
  111. package/infrastructure/schemas/SearchSchema.d.ts +7 -0
  112. package/infrastructure/schemas/SearchSchema.js +36 -0
  113. package/infrastructure/schemas/SearchSchema.js.map +1 -0
  114. package/package.json +40 -0
  115. package/tsconfig.tsbuildinfo +1 -0
  116. package/usecases/dtos/SearchInputDto.d.ts +10 -0
  117. package/usecases/dtos/SearchInputDto.js +29 -0
  118. package/usecases/dtos/SearchInputDto.js.map +1 -0
  119. package/usecases/dtos/SearchResultDto.d.ts +5 -0
  120. package/usecases/dtos/SearchResultDto.js +7 -0
  121. package/usecases/dtos/SearchResultDto.js.map +1 -0
  122. package/usecases/interfaces/ICrudRepository.d.ts +12 -0
  123. package/usecases/interfaces/ICrudRepository.js +3 -0
  124. package/usecases/interfaces/ICrudRepository.js.map +1 -0
  125. package/usecases/services/CrudService.d.ts +16 -0
  126. package/usecases/services/CrudService.js +45 -0
  127. package/usecases/services/CrudService.js.map +1 -0
@@ -0,0 +1,16 @@
1
+ import { ICrudRepository } from '../interfaces/ICrudRepository';
2
+ import { ISearchInputDto } from '../dtos/SearchInputDto';
3
+ import { SearchResultDto } from '../dtos/SearchResultDto';
4
+ export declare class CrudService<TModel, TSearchDto = ISearchInputDto, TSaveDto = TModel> {
5
+ protected primaryKey: string;
6
+ protected repository: ICrudRepository<TModel>;
7
+ protected modelClass: any;
8
+ init(repository: ICrudRepository<TModel>, ModelClass: any): void;
9
+ createModel(): TModel | any;
10
+ search(dto: TSearchDto): Promise<SearchResultDto<TModel>>;
11
+ findById(id: number | string): Promise<TModel>;
12
+ create(dto: TSaveDto): Promise<TModel>;
13
+ update(id: number | string, dto: TSaveDto): Promise<TModel>;
14
+ remove(id: number | string): Promise<void>;
15
+ protected dtoToModel(dto: TSaveDto, model: TModel): TModel;
16
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CrudService = void 0;
4
+ const lodash_1 = require("lodash");
5
+ const DataMapperHelper_1 = require("../../infrastructure/helpers/DataMapperHelper");
6
+ class CrudService {
7
+ constructor() {
8
+ this.primaryKey = 'id';
9
+ }
10
+ init(repository, ModelClass) {
11
+ this.repository = repository;
12
+ this.modelClass = ModelClass;
13
+ }
14
+ createModel() {
15
+ const ModelClass = this.modelClass;
16
+ return new ModelClass();
17
+ }
18
+ async search(dto) {
19
+ const repositoryResult = await this.repository.search(dto);
20
+ return repositoryResult;
21
+ }
22
+ async findById(id) {
23
+ const model = await this.repository.findOne({ [this.primaryKey]: (0, lodash_1.toInteger)(id) });
24
+ return model;
25
+ }
26
+ async create(dto) {
27
+ let model = this.dtoToModel(dto, this.createModel());
28
+ model = await this.repository.create(model);
29
+ return model;
30
+ }
31
+ async update(id, dto) {
32
+ let model = this.dtoToModel(dto, this.createModel());
33
+ model = await this.repository.update((0, lodash_1.toInteger)(id), model);
34
+ return model;
35
+ }
36
+ async remove(id) {
37
+ await this.repository.remove((0, lodash_1.toInteger)(id));
38
+ }
39
+ dtoToModel(dto, model) {
40
+ DataMapperHelper_1.DataMapperHelper.applyFields(model, dto);
41
+ return model;
42
+ }
43
+ }
44
+ exports.CrudService = CrudService;
45
+ //# sourceMappingURL=CrudService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CrudService.js","sourceRoot":"","sources":["../../../src/usecases/services/CrudService.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;AAE/C,oFAA+E;AAO/E,MAAa,WAAW;IAAxB;QAQc,eAAU,GAAW,IAAI,CAAC;IAkFxC,CAAC;IAnEG,IAAI,CAAC,UAAmC,EAAE,UAAU;QAChD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED,WAAW;QACP,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QACnC,OAAO,IAAI,UAAU,EAAE,CAAC;IAC5B,CAAC;IAMD,KAAK,CAAC,MAAM,CAAC,GAAe;QACxB,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC3D,OAAO,gBAAgB,CAAC;IAC5B,CAAC;IAMD,KAAK,CAAC,QAAQ,CAAC,EAAmB;QAC9B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAC,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,IAAA,kBAAU,EAAC,EAAE,CAAC,EAAC,CAAC,CAAC;QACjF,OAAO,KAAK,CAAC;IACjB,CAAC;IAMD,KAAK,CAAC,MAAM,CAAC,GAAa;QACtB,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACrD,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5C,OAAO,KAAK,CAAC;IACjB,CAAC;IAOD,KAAK,CAAC,MAAM,CAAC,EAAmB,EAAE,GAAa;QAC3C,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACrD,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAA,kBAAU,EAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QAC5D,OAAO,KAAK,CAAC;IACjB,CAAC;IAMD,KAAK,CAAC,MAAM,CAAC,EAAmB;QAC5B,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAA,kBAAU,EAAC,EAAE,CAAC,CAAC,CAAC;IACjD,CAAC;IAQS,UAAU,CAAC,GAAa,EAAE,KAAa;QAC7C,mCAAgB,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACzC,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AA1FD,kCA0FC"}