@steroidsjs/nest 3.0.3 → 3.2.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 (200) hide show
  1. package/infrastructure/adapters/QueryAdapterTypeORM.js +2 -2
  2. package/infrastructure/adapters/QueryAdapterTypeORM.js.map +1 -1
  3. package/infrastructure/applications/rest/RestApplication.js +1 -0
  4. package/infrastructure/applications/rest/RestApplication.js.map +1 -1
  5. package/infrastructure/base/ModelTableStorage.d.ts +4 -0
  6. package/infrastructure/base/ModelTableStorage.js +21 -0
  7. package/infrastructure/base/ModelTableStorage.js.map +1 -0
  8. package/infrastructure/commands/entity-generator/templates/TableTemplate.txt +2 -2
  9. package/infrastructure/decorators/fields/BaseField.d.ts +2 -2
  10. package/infrastructure/decorators/fields/BaseField.js +68 -80
  11. package/infrastructure/decorators/fields/BaseField.js.map +1 -1
  12. package/infrastructure/decorators/fields/BooleanField.js +1 -9
  13. package/infrastructure/decorators/fields/BooleanField.js.map +1 -1
  14. package/infrastructure/decorators/fields/ComputableField.js +1 -1
  15. package/infrastructure/decorators/fields/ComputableField.js.map +1 -1
  16. package/infrastructure/decorators/fields/CoordinateField.js +0 -8
  17. package/infrastructure/decorators/fields/CoordinateField.js.map +1 -1
  18. package/infrastructure/decorators/fields/CreateTimeField.js +1 -23
  19. package/infrastructure/decorators/fields/CreateTimeField.js.map +1 -1
  20. package/infrastructure/decorators/fields/DateField.js +0 -6
  21. package/infrastructure/decorators/fields/DateField.js.map +1 -1
  22. package/infrastructure/decorators/fields/DateTimeField.js +6 -16
  23. package/infrastructure/decorators/fields/DateTimeField.js.map +1 -1
  24. package/infrastructure/decorators/fields/DecimalField.js +0 -8
  25. package/infrastructure/decorators/fields/DecimalField.js.map +1 -1
  26. package/infrastructure/decorators/fields/DecimalNumberField.js +3 -12
  27. package/infrastructure/decorators/fields/DecimalNumberField.js.map +1 -1
  28. package/infrastructure/decorators/fields/DeleteDateField.js +0 -5
  29. package/infrastructure/decorators/fields/DeleteDateField.js.map +1 -1
  30. package/infrastructure/decorators/fields/EmailField.js +0 -7
  31. package/infrastructure/decorators/fields/EmailField.js.map +1 -1
  32. package/infrastructure/decorators/fields/EnumField.js +2 -9
  33. package/infrastructure/decorators/fields/EnumField.js.map +1 -1
  34. package/infrastructure/decorators/fields/ExtendField.d.ts +1 -1
  35. package/infrastructure/decorators/fields/ExtendField.js +3 -2
  36. package/infrastructure/decorators/fields/ExtendField.js.map +1 -1
  37. package/infrastructure/decorators/fields/FileField.js +0 -6
  38. package/infrastructure/decorators/fields/FileField.js.map +1 -1
  39. package/infrastructure/decorators/fields/HtmlField.js +0 -5
  40. package/infrastructure/decorators/fields/HtmlField.js.map +1 -1
  41. package/infrastructure/decorators/fields/ImageField.js.map +1 -1
  42. package/infrastructure/decorators/fields/IntegerField.js +0 -7
  43. package/infrastructure/decorators/fields/IntegerField.js.map +1 -1
  44. package/infrastructure/decorators/fields/JSONBField.d.ts +1 -2
  45. package/infrastructure/decorators/fields/JSONBField.js +0 -8
  46. package/infrastructure/decorators/fields/JSONBField.js.map +1 -1
  47. package/infrastructure/decorators/fields/PasswordField.js +0 -6
  48. package/infrastructure/decorators/fields/PasswordField.js.map +1 -1
  49. package/infrastructure/decorators/fields/PhoneField.js +0 -8
  50. package/infrastructure/decorators/fields/PhoneField.js.map +1 -1
  51. package/infrastructure/decorators/fields/PrimaryKeyField.js +1 -2
  52. package/infrastructure/decorators/fields/PrimaryKeyField.js.map +1 -1
  53. package/infrastructure/decorators/fields/RelationField.js +4 -51
  54. package/infrastructure/decorators/fields/RelationField.js.map +1 -1
  55. package/infrastructure/decorators/fields/RelationIdField.js +8 -16
  56. package/infrastructure/decorators/fields/RelationIdField.js.map +1 -1
  57. package/infrastructure/decorators/fields/StringField.js +0 -9
  58. package/infrastructure/decorators/fields/StringField.js.map +1 -1
  59. package/infrastructure/decorators/fields/TextField.js +0 -7
  60. package/infrastructure/decorators/fields/TextField.js.map +1 -1
  61. package/infrastructure/decorators/fields/TimeField.js +1 -8
  62. package/infrastructure/decorators/fields/TimeField.js.map +1 -1
  63. package/infrastructure/decorators/fields/UidField.d.ts +0 -1
  64. package/infrastructure/decorators/fields/UidField.js +2 -28
  65. package/infrastructure/decorators/fields/UidField.js.map +1 -1
  66. package/infrastructure/decorators/fields/UpdateTimeField.js +2 -26
  67. package/infrastructure/decorators/fields/UpdateTimeField.js.map +1 -1
  68. package/infrastructure/decorators/fields/index.d.ts +57 -16
  69. package/infrastructure/decorators/fields/index.js +110 -54
  70. package/infrastructure/decorators/fields/index.js.map +1 -1
  71. package/infrastructure/decorators/typeorm/TypeOrmDecoratorFactory.d.ts +2 -0
  72. package/infrastructure/decorators/typeorm/TypeOrmDecoratorFactory.js +65 -0
  73. package/infrastructure/decorators/typeorm/TypeOrmDecoratorFactory.js.map +1 -0
  74. package/infrastructure/decorators/typeorm/TypeOrmTableFromModel.d.ts +6 -0
  75. package/infrastructure/decorators/typeorm/TypeOrmTableFromModel.js +29 -0
  76. package/infrastructure/decorators/typeorm/TypeOrmTableFromModel.js.map +1 -0
  77. package/infrastructure/decorators/typeorm/fields/TypeOrmBooleanField/index.d.ts +3 -0
  78. package/infrastructure/decorators/typeorm/fields/TypeOrmBooleanField/index.js +14 -0
  79. package/infrastructure/decorators/typeorm/fields/TypeOrmBooleanField/index.js.map +1 -0
  80. package/infrastructure/decorators/typeorm/fields/TypeOrmCoordinateField/index.d.ts +3 -0
  81. package/infrastructure/decorators/typeorm/fields/TypeOrmCoordinateField/index.js +13 -0
  82. package/infrastructure/decorators/typeorm/fields/TypeOrmCoordinateField/index.js.map +1 -0
  83. package/infrastructure/decorators/typeorm/fields/TypeOrmCreateTimeField/TypeOrmCreateTimeBehaviour.d.ts +1 -0
  84. package/infrastructure/decorators/typeorm/fields/TypeOrmCreateTimeField/TypeOrmCreateTimeBehaviour.js +22 -0
  85. package/infrastructure/decorators/typeorm/fields/TypeOrmCreateTimeField/TypeOrmCreateTimeBehaviour.js.map +1 -0
  86. package/infrastructure/decorators/typeorm/fields/TypeOrmCreateTimeField/index.d.ts +3 -0
  87. package/infrastructure/decorators/typeorm/fields/TypeOrmCreateTimeField/index.js +17 -0
  88. package/infrastructure/decorators/typeorm/fields/TypeOrmCreateTimeField/index.js.map +1 -0
  89. package/infrastructure/decorators/typeorm/fields/TypeOrmDateField/index.d.ts +3 -0
  90. package/infrastructure/decorators/typeorm/fields/TypeOrmDateField/index.js +11 -0
  91. package/infrastructure/decorators/typeorm/fields/TypeOrmDateField/index.js.map +1 -0
  92. package/infrastructure/decorators/typeorm/fields/TypeOrmDateTimeField/index.d.ts +3 -0
  93. package/infrastructure/decorators/typeorm/fields/TypeOrmDateTimeField/index.js +12 -0
  94. package/infrastructure/decorators/typeorm/fields/TypeOrmDateTimeField/index.js.map +1 -0
  95. package/infrastructure/decorators/typeorm/fields/TypeOrmDecimalField/index.d.ts +3 -0
  96. package/infrastructure/decorators/typeorm/fields/TypeOrmDecimalField/index.js +13 -0
  97. package/infrastructure/decorators/typeorm/fields/TypeOrmDecimalField/index.js.map +1 -0
  98. package/infrastructure/decorators/typeorm/fields/TypeOrmDecimalNumberField/index.d.ts +3 -0
  99. package/infrastructure/decorators/typeorm/fields/TypeOrmDecimalNumberField/index.js +13 -0
  100. package/infrastructure/decorators/typeorm/fields/TypeOrmDecimalNumberField/index.js.map +1 -0
  101. package/infrastructure/decorators/typeorm/fields/TypeOrmDeleteDateColumn/index.d.ts +2 -0
  102. package/infrastructure/decorators/typeorm/fields/TypeOrmDeleteDateColumn/index.js +10 -0
  103. package/infrastructure/decorators/typeorm/fields/TypeOrmDeleteDateColumn/index.js.map +1 -0
  104. package/infrastructure/decorators/typeorm/fields/TypeOrmEmailField/index.d.ts +3 -0
  105. package/infrastructure/decorators/typeorm/fields/TypeOrmEmailField/index.js +12 -0
  106. package/infrastructure/decorators/typeorm/fields/TypeOrmEmailField/index.js.map +1 -0
  107. package/infrastructure/decorators/typeorm/fields/TypeOrmEnumField/index.d.ts +3 -0
  108. package/infrastructure/decorators/typeorm/fields/TypeOrmEnumField/index.js +12 -0
  109. package/infrastructure/decorators/typeorm/fields/TypeOrmEnumField/index.js.map +1 -0
  110. package/infrastructure/decorators/typeorm/fields/TypeOrmFileField/index.d.ts +3 -0
  111. package/infrastructure/decorators/typeorm/fields/TypeOrmFileField/index.js +11 -0
  112. package/infrastructure/decorators/typeorm/fields/TypeOrmFileField/index.js.map +1 -0
  113. package/infrastructure/decorators/typeorm/fields/TypeOrmHtmlField/index.d.ts +3 -0
  114. package/infrastructure/decorators/typeorm/fields/TypeOrmHtmlField/index.js +11 -0
  115. package/infrastructure/decorators/typeorm/fields/TypeOrmHtmlField/index.js.map +1 -0
  116. package/infrastructure/decorators/typeorm/fields/TypeOrmImageField/index.d.ts +3 -0
  117. package/infrastructure/decorators/typeorm/fields/TypeOrmImageField/index.js +11 -0
  118. package/infrastructure/decorators/typeorm/fields/TypeOrmImageField/index.js.map +1 -0
  119. package/infrastructure/decorators/typeorm/fields/TypeOrmIntegerField/index.d.ts +3 -0
  120. package/infrastructure/decorators/typeorm/fields/TypeOrmIntegerField/index.js +12 -0
  121. package/infrastructure/decorators/typeorm/fields/TypeOrmIntegerField/index.js.map +1 -0
  122. package/infrastructure/decorators/typeorm/fields/TypeOrmJSONBField/index.d.ts +3 -0
  123. package/infrastructure/decorators/typeorm/fields/TypeOrmJSONBField/index.js +13 -0
  124. package/infrastructure/decorators/typeorm/fields/TypeOrmJSONBField/index.js.map +1 -0
  125. package/infrastructure/decorators/typeorm/fields/TypeOrmPasswordField/index.d.ts +3 -0
  126. package/infrastructure/decorators/typeorm/fields/TypeOrmPasswordField/index.js +12 -0
  127. package/infrastructure/decorators/typeorm/fields/TypeOrmPasswordField/index.js.map +1 -0
  128. package/infrastructure/decorators/typeorm/fields/TypeOrmPhoneField/index.d.ts +3 -0
  129. package/infrastructure/decorators/typeorm/fields/TypeOrmPhoneField/index.js +13 -0
  130. package/infrastructure/decorators/typeorm/fields/TypeOrmPhoneField/index.js.map +1 -0
  131. package/infrastructure/decorators/typeorm/fields/TypeOrmPrimaryKeyField/index.d.ts +2 -0
  132. package/infrastructure/decorators/typeorm/fields/TypeOrmPrimaryKeyField/index.js +7 -0
  133. package/infrastructure/decorators/typeorm/fields/TypeOrmPrimaryKeyField/index.js.map +1 -0
  134. package/infrastructure/decorators/typeorm/fields/TypeOrmRelationField/TypeOrmRelationBehaviour.d.ts +4 -0
  135. package/infrastructure/decorators/typeorm/fields/TypeOrmRelationField/TypeOrmRelationBehaviour.js +30 -0
  136. package/infrastructure/decorators/typeorm/fields/TypeOrmRelationField/TypeOrmRelationBehaviour.js.map +1 -0
  137. package/infrastructure/decorators/typeorm/fields/TypeOrmRelationField/index.d.ts +3 -0
  138. package/infrastructure/decorators/typeorm/fields/TypeOrmRelationField/index.js +17 -0
  139. package/infrastructure/decorators/typeorm/fields/TypeOrmRelationField/index.js.map +1 -0
  140. package/infrastructure/decorators/typeorm/fields/TypeOrmRelationIdField/index.d.ts +3 -0
  141. package/infrastructure/decorators/typeorm/fields/TypeOrmRelationIdField/index.js +10 -0
  142. package/infrastructure/decorators/typeorm/fields/TypeOrmRelationIdField/index.js.map +1 -0
  143. package/infrastructure/decorators/typeorm/fields/TypeOrmStringField/index.d.ts +3 -0
  144. package/infrastructure/decorators/typeorm/fields/TypeOrmStringField/index.js +14 -0
  145. package/infrastructure/decorators/typeorm/fields/TypeOrmStringField/index.js.map +1 -0
  146. package/infrastructure/decorators/typeorm/fields/TypeOrmTextField/index.d.ts +3 -0
  147. package/infrastructure/decorators/typeorm/fields/TypeOrmTextField/index.js +12 -0
  148. package/infrastructure/decorators/typeorm/fields/TypeOrmTextField/index.js.map +1 -0
  149. package/infrastructure/decorators/typeorm/fields/TypeOrmTimeField/index.d.ts +3 -0
  150. package/infrastructure/decorators/typeorm/fields/TypeOrmTimeField/index.js +12 -0
  151. package/infrastructure/decorators/typeorm/fields/TypeOrmTimeField/index.js.map +1 -0
  152. package/infrastructure/decorators/typeorm/fields/TypeOrmUidField/TypeOrmUidBehaviour.d.ts +2 -0
  153. package/infrastructure/decorators/typeorm/fields/TypeOrmUidField/TypeOrmUidBehaviour.js +26 -0
  154. package/infrastructure/decorators/typeorm/fields/TypeOrmUidField/TypeOrmUidBehaviour.js.map +1 -0
  155. package/infrastructure/decorators/typeorm/fields/TypeOrmUidField/index.d.ts +3 -0
  156. package/infrastructure/decorators/typeorm/fields/TypeOrmUidField/index.js +14 -0
  157. package/infrastructure/decorators/typeorm/fields/TypeOrmUidField/index.js.map +1 -0
  158. package/infrastructure/decorators/typeorm/fields/TypeOrmUpdateTimeField/TypeOrmUpdateTimeBehaviour.d.ts +1 -0
  159. package/infrastructure/decorators/typeorm/fields/TypeOrmUpdateTimeField/TypeOrmUpdateTimeBehaviour.js +24 -0
  160. package/infrastructure/decorators/typeorm/fields/TypeOrmUpdateTimeField/TypeOrmUpdateTimeBehaviour.js.map +1 -0
  161. package/infrastructure/decorators/typeorm/fields/TypeOrmUpdateTimeField/index.d.ts +3 -0
  162. package/infrastructure/decorators/typeorm/fields/TypeOrmUpdateTimeField/index.js +17 -0
  163. package/infrastructure/decorators/typeorm/fields/TypeOrmUpdateTimeField/index.js.map +1 -0
  164. package/infrastructure/repositories/CrudRepository.d.ts +5 -0
  165. package/infrastructure/repositories/CrudRepository.js +13 -4
  166. package/infrastructure/repositories/CrudRepository.js.map +1 -1
  167. package/infrastructure/tests/app/tables/ArticleTable.js +2 -2
  168. package/infrastructure/tests/app/tables/ArticleTable.js.map +1 -1
  169. package/infrastructure/tests/app/tables/CommentTable.js +2 -2
  170. package/infrastructure/tests/app/tables/CommentTable.js.map +1 -1
  171. package/infrastructure/tests/app/tables/FileTable.js +2 -2
  172. package/infrastructure/tests/app/tables/FileTable.js.map +1 -1
  173. package/infrastructure/tests/app/tables/ImageTable.js +2 -2
  174. package/infrastructure/tests/app/tables/ImageTable.js.map +1 -1
  175. package/infrastructure/tests/app/tables/TagTable.js +2 -2
  176. package/infrastructure/tests/app/tables/TagTable.js.map +1 -1
  177. package/infrastructure/tests/app/tables/UserInfoTable.js +2 -2
  178. package/infrastructure/tests/app/tables/UserInfoTable.js.map +1 -1
  179. package/infrastructure/tests/app/tables/UserTable.js +2 -2
  180. package/infrastructure/tests/app/tables/UserTable.js.map +1 -1
  181. package/package.json +1 -1
  182. package/tsconfig.tsbuildinfo +1 -1
  183. package/usecases/exceptions/ClassValidatorException.d.ts +5 -0
  184. package/usecases/exceptions/ClassValidatorException.js +10 -0
  185. package/usecases/exceptions/ClassValidatorException.js.map +1 -0
  186. package/usecases/helpers/DataMapper.js +2 -2
  187. package/usecases/helpers/DataMapper.js.map +1 -1
  188. package/usecases/helpers/ValidationHelper.d.ts +1 -0
  189. package/usecases/helpers/ValidationHelper.js +57 -6
  190. package/usecases/helpers/ValidationHelper.js.map +1 -1
  191. package/usecases/interfaces/ICrudRepository.d.ts +1 -0
  192. package/usecases/services/ReadService.d.ts +5 -0
  193. package/usecases/services/ReadService.js +7 -0
  194. package/usecases/services/ReadService.js.map +1 -1
  195. package/usecases/validators/Validator.d.ts +5 -5
  196. package/usecases/validators/Validator.js +16 -8
  197. package/usecases/validators/Validator.js.map +1 -1
  198. package/infrastructure/decorators/TableFromModel.d.ts +0 -9
  199. package/infrastructure/decorators/TableFromModel.js +0 -44
  200. package/infrastructure/decorators/TableFromModel.js.map +0 -1
@@ -0,0 +1,5 @@
1
+ import { IErrorsCompositeObject } from '../interfaces/IErrorsCompositeObject';
2
+ export declare class ClassValidatorException {
3
+ params: IErrorsCompositeObject;
4
+ constructor(params: IErrorsCompositeObject);
5
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClassValidatorException = void 0;
4
+ class ClassValidatorException {
5
+ constructor(params) {
6
+ this.params = params;
7
+ }
8
+ }
9
+ exports.ClassValidatorException = ClassValidatorException;
10
+ //# sourceMappingURL=ClassValidatorException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClassValidatorException.js","sourceRoot":"","sources":["../../../src/usecases/exceptions/ClassValidatorException.ts"],"names":[],"mappings":";;;AAEA,MAAa,uBAAuB;IAGhC,YAAY,MAA8B;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;CACJ;AAND,0DAMC"}
@@ -6,7 +6,7 @@ const lodash_2 = require("lodash");
6
6
  const BaseField_1 = require("../../infrastructure/decorators/fields/BaseField");
7
7
  const constants_1 = require("@nestjs/swagger/dist/constants");
8
8
  const Transform_1 = require("../../infrastructure/decorators/Transform");
9
- const TableFromModel_1 = require("../../infrastructure/decorators/TableFromModel");
9
+ const ModelTableStorage_1 = require("../../infrastructure/base/ModelTableStorage");
10
10
  class DataMapper {
11
11
  static create(MetaClass, values, transformType = Transform_1.TRANSFORM_TYPE_DEFAULT, skipBuilder = false) {
12
12
  // Check empty
@@ -16,7 +16,7 @@ class DataMapper {
16
16
  if (Array.isArray(values)) {
17
17
  return values.map((value) => (this.create(MetaClass, value, transformType, skipBuilder)));
18
18
  }
19
- const builder = !skipBuilder && (0, TableFromModel_1.getModelBuilder)(MetaClass);
19
+ const builder = !skipBuilder && (0, ModelTableStorage_1.getModelBuilder)(MetaClass);
20
20
  if (builder) {
21
21
  return builder(values);
22
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DataMapper.js","sourceRoot":"","sources":["../../../src/usecases/helpers/DataMapper.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,mCAA6C;AAC7C,gFAA6G;AAE7G,8DAA0D;AAE1D,yEAKmD;AACnD,mFAA+E;AAG/E,MAAa,UAAU;IAenB,MAAM,CAAC,MAAM,CACT,SAAmB,EACnB,MAAyC,EACzC,gBAAgC,kCAAsB,EACtD,WAAW,GAAG,KAAK;QAEnB,cAAc;QACd,IAAI,MAAM,KAAK,IAAI,EAAE;YACjB,OAAO,IAAI,CAAC;SACf;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAA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CAAC,IAAI,CAAC,CAAC,IAAI;yBAC7E;wBACD,CAAC,CAAC,EAAE,CAAC,CACZ,CAAC;oBAEF,IAAI,SAAS,CAAC,IAAI,KAAK,UAAU,EAAE;wBAC/B,SAAS,CAAC,YAAY,CAAC,GAAI,OAAiC,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC;qBACrF;oBAED,OAAO,SAAS,CAAC;gBACrB,CAAC,CAAC;aACL,CAAC;QACN,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,KAAY;QAC3B,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACjB,IAAI,IAAI,CAAC,OAAO,EAAE;gBACd,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;oBAChB,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE;iBACzB,CAAC;aACL;QACL,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AApJD,gCAoJC"}
@@ -34,5 +34,6 @@ export declare class ValidationHelper {
34
34
  */
35
35
  static getSteroidsErrors(dto: any, params?: IValidatorParams, validatorsInstances?: IValidator[]): Promise<IErrorsCompositeObject | null>;
36
36
  protected static getSteroidsFieldValidatorsErrors(dto: any, key: string, params: IValidatorParams, validatorsInstances: IValidator[]): Promise<string[]>;
37
+ protected static getSteroidsClassValidatorsErrors(dto: any, params: IValidatorParams, validatorsInstances: IValidator[]): Promise<IErrorsCompositeObject>;
37
38
  static parseClassValidatorErrors(errors: ValidationError[]): IErrorsCompositeObject;
38
39
  }
@@ -7,10 +7,23 @@ const exceptions_1 = require("../exceptions");
7
7
  const FieldValidatorException_1 = require("../exceptions/FieldValidatorException");
8
8
  const BaseField_1 = require("../../infrastructure/decorators/fields/BaseField");
9
9
  const Validator_1 = require("../validators/Validator");
10
+ const ClassValidatorException_1 = require("../exceptions/ClassValidatorException");
10
11
  const defaultValidatorOptions = {
11
12
  whitelist: false,
12
13
  forbidUnknownValues: false,
13
14
  };
15
+ /**
16
+ * Merge two objects of IErrorsCompositeObject into one, the fields with arrays are merged, not rewritten
17
+ * @param object
18
+ * @param source
19
+ */
20
+ function mergeErrorsCompositeObjects(object, source) {
21
+ return (0, lodash_1.mergeWith)(object, source, (objValue, srcValue) => {
22
+ if (Array.isArray(objValue)) {
23
+ return objValue.concat(srcValue);
24
+ }
25
+ });
26
+ }
14
27
  /**
15
28
  * @deprecated Use ValidationHelper.validate()
16
29
  * @throws {ValidationException}
@@ -41,11 +54,7 @@ class ValidationHelper {
41
54
  var _a;
42
55
  const classValidatorErrors = await this.getClassValidatorErrors(dto);
43
56
  const steroidsValidatorsErrors = await this.getSteroidsErrors(dto, params, allValidators);
44
- const errors = (0, lodash_1.mergeWith)(classValidatorErrors, steroidsValidatorsErrors, (objValue, srcValue) => {
45
- if (Array.isArray(objValue)) {
46
- return objValue.concat(srcValue);
47
- }
48
- });
57
+ const errors = mergeErrorsCompositeObjects(classValidatorErrors, steroidsValidatorsErrors);
49
58
  if (errors && ((_a = Object.keys(errors)) === null || _a === void 0 ? void 0 : _a.length) > 0) {
50
59
  throw new exceptions_1.ValidationException(errors);
51
60
  }
@@ -101,6 +110,10 @@ class ValidationHelper {
101
110
  errors[key] = fieldValidatorsErrors;
102
111
  }
103
112
  }
113
+ const classValidatorsErrors = await this.getSteroidsClassValidatorsErrors(dto, params, validatorsInstances);
114
+ if (Object.keys(classValidatorsErrors).length > 0) {
115
+ return mergeErrorsCompositeObjects(errors, classValidatorsErrors);
116
+ }
104
117
  // Has errors?
105
118
  if (Object.keys(errors).length > 0) {
106
119
  return errors;
@@ -110,7 +123,7 @@ class ValidationHelper {
110
123
  static async getSteroidsFieldValidatorsErrors(dto, key, params, validatorsInstances) {
111
124
  let fieldValidatorErrors = [];
112
125
  // Get field validators
113
- const fieldValidators = (0, Validator_1.getFieldValidators)(dto.constructor, key);
126
+ const fieldValidators = (0, Validator_1.getValidators)(dto.constructor, key);
114
127
  for (const fieldValidator of fieldValidators) {
115
128
  try {
116
129
  // Find validator instance
@@ -145,6 +158,44 @@ class ValidationHelper {
145
158
  }
146
159
  return fieldValidatorErrors;
147
160
  }
161
+ static async getSteroidsClassValidatorsErrors(dto, params, validatorsInstances) {
162
+ let classValidatorErrors = {};
163
+ // Get class validators
164
+ const classValidators = (0, Validator_1.getValidators)(dto.constructor);
165
+ for (const classValidator of classValidators) {
166
+ try {
167
+ // Find validator instance
168
+ const validator = (validatorsInstances || []).find(item => {
169
+ try {
170
+ return item instanceof classValidator;
171
+ }
172
+ catch (e) {
173
+ return false;
174
+ }
175
+ });
176
+ if (!validator && typeof classValidator === 'function') {
177
+ await classValidator(dto, params);
178
+ continue;
179
+ }
180
+ if (!validator) {
181
+ throw new Error(`Not found validator instance for "${dto.constructor.name}"`
182
+ + ' Please add it to CrudService.validators array.');
183
+ }
184
+ // Run validator
185
+ await validator.validate(dto, params);
186
+ }
187
+ catch (error) {
188
+ // Check validator is throw specific exception
189
+ if (error instanceof ClassValidatorException_1.ClassValidatorException) {
190
+ classValidatorErrors = mergeErrorsCompositeObjects(classValidatorErrors, error.params);
191
+ }
192
+ else {
193
+ throw error;
194
+ }
195
+ }
196
+ }
197
+ return classValidatorErrors;
198
+ }
148
199
  static parseClassValidatorErrors(errors) {
149
200
  var _a;
150
201
  if (!Array.isArray(errors)) {
@@ -1 +1 @@
1
- {"version":3,"file":"ValidationHelper.js","sourceRoot":"","sources":["../../../src/usecases/helpers/ValidationHelper.ts"],"names":[],"mappings":";;;AAAA,mCAAsE;AACtE,qDAA4E;AAC5E,8CAAkD;AAElD,mFAA8E;AAC9E,gFAA4F;AAC5F,uDAA2D;AAG3D,MAAM,uBAAuB,GAAqB;IAC9C,SAAS,EAAE,KAAK;IAChB,mBAAmB,EAAE,KAAK;CAC7B,CAAC;AAEF;;;GAGG;AACI,KAAK,UAAU,gBAAgB,CAAC,GAAQ,EAAE,gBAAm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,MAAM,CAAC,CAAC;iBAC1F;qBAAM;oBACH,MAAM,KAAK,CAAC;iBACf;aACJ;SACJ;QAED,OAAO,oBAAoB,CAAC;IAChC,CAAC;IAEM,MAAM,CAAC,yBAAyB,CAAC,MAAyB;;QAC7D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACxB,OAAO,MAAM,CAAC;SACjB;QAED,MAAM,MAAM,GAA2B,EAAE,CAAC;QAC1C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YACxB,IAAI,KAAK,CAAC,WAAW,EAAE;gBACnB,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;aACxE;YACD,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,IAAG,CAAC,EAAE;gBAC5B,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,yBAAyB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;aAC3E;SACJ;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAxND,4CAwNC"}
@@ -13,4 +13,5 @@ export interface ICrudRepository<TModel> {
13
13
  save: (model: TModel, transactionHandler?: TransactionHandler<TModel>) => Promise<TModel>;
14
14
  softRemove: (id: number, transactionHandler?: (callback: () => Promise<void>) => Promise<void>) => Promise<void>;
15
15
  update: (id: number, model: TModel, transactionHandler?: TransactionHandler<TModel>) => Promise<TModel>;
16
+ isExistsById: (id: number) => Promise<boolean>;
16
17
  }
@@ -42,6 +42,11 @@ export declare class ReadService<TModel, TSearchDto = ISearchInputDto> {
42
42
  * @param searchQuery
43
43
  */
44
44
  findMany(searchQuery: SearchQuery<TModel>): Promise<TModel[]>;
45
+ /**
46
+ * Check existence by id
47
+ * @param id
48
+ */
49
+ isExistsById(id: number | string): Promise<boolean>;
45
50
  createQuery(config?: ISearchQueryConfig<TModel>): SearchQuery<TModel>;
46
51
  /**
47
52
  * Mapping model to schema class
@@ -61,6 +61,13 @@ class ReadService {
61
61
  async findMany(searchQuery) {
62
62
  return await this.repository.findMany(searchQuery);
63
63
  }
64
+ /**
65
+ * Check existence by id
66
+ * @param id
67
+ */
68
+ isExistsById(id) {
69
+ return this.repository.isExistsById((0, lodash_1.toInteger)(id));
70
+ }
64
71
  createQuery(config) {
65
72
  return new SearchQuery_1.default(Object.assign({ onGetMany: this.findMany.bind(this), onGetOne: this.findOne.bind(this) }, (config || {})));
66
73
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ReadService.js","sourceRoot":"","sources":["../../../src/usecases/services/ReadService.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;AAE/C,sDAAiD;AAGjD,kEAA6D;AAC7D,qDAAoE;AAKpE;;GAEG;AACH,MAAa,WAAW;IAAxB;QACI;;WAEG;QACO,eAAU,GAAW,IAAI,CAAC;IAyHxC,CAAC;IAtGG,IAAI,CAAC,UAAmC,EAAE,UAAyB;QAC/D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IASD;;;;;OAKG;IACH,KAAK,CAAC,MAAM,CACR,GAAe,EACf,UAAsB,IAAI,EAC1B,cAA8B,IAAI;QAElC,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;YACrB,OAAO;SACV,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CACvC,GAAG,EACH,WAAW,CAAC,CAAC,CAAC,qBAAW,CAAC,gBAAgB,CAAS,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,qBAAW,EAAE,CACtF,CAAC;QACF,IAAI,WAAW,EAAE;YACb,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,CAA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;IAED;;;;;OAKG;IACO,aAAa,CAAU,KAAa,EAAE,WAA2B;QACvE,OAAO,uBAAU,CAAC,MAAM,CAAC,WAAW,EAAE,KAAY,CAAC,CAAC;IACxD,CAAC;IAES,KAAK,CAAC,QAAQ,CAAC,GAAQ,EAAE,MAAyB;QACxD,MAAM,mCAAgB,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAClE,CAAC;IAES,OAAO,CAAC,GAAY;QAC1B,OAAO,GAAG,YAAY,IAAI,CAAC,UAAU,CAAC;IAC1C,CAAC;CACJ;AArID,kCAqIC"}
@@ -1,6 +1,6 @@
1
- import { IValidatorParams } from '../interfaces/IValidator';
1
+ import { IValidator, IValidatorParams } from '../interfaces/IValidator';
2
+ import { IType } from '../interfaces/IType';
2
3
  export declare const STEROIDS_META_VALIDATORS = "steroids_meta_validators";
3
- type IValidateFunction = (dto: any, params?: IValidatorParams) => Promise<void> | void;
4
- export declare const getFieldValidators: (MetaClass: any, fieldName: any) => any;
5
- export declare function Validator(validatorInstance: IValidateFunction | any): (object: any, fieldName: any) => void;
6
- export {};
4
+ export type ValidateFunctionType = (dto: any, params?: IValidatorParams) => Promise<void> | void;
5
+ export declare const getValidators: (MetaClass: any, fieldName?: string) => any;
6
+ export declare function Validator(validatorInstance: ValidateFunctionType | IType<IValidator>): (target: any, fieldName?: string) => void;
@@ -1,19 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Validator = exports.getFieldValidators = exports.STEROIDS_META_VALIDATORS = void 0;
3
+ exports.Validator = exports.getValidators = exports.STEROIDS_META_VALIDATORS = void 0;
4
4
  exports.STEROIDS_META_VALIDATORS = 'steroids_meta_validators';
5
- const getFieldValidators = (MetaClass, fieldName) => {
6
- return Reflect.getMetadata(exports.STEROIDS_META_VALIDATORS, MetaClass.prototype, fieldName) || [];
5
+ const getValidators = (MetaClass, fieldName) => {
6
+ const metadataParams = fieldName
7
+ ? [exports.STEROIDS_META_VALIDATORS, MetaClass.prototype, fieldName]
8
+ : [exports.STEROIDS_META_VALIDATORS, MetaClass];
9
+ return Reflect.getMetadata(...metadataParams) || [];
7
10
  };
8
- exports.getFieldValidators = getFieldValidators;
11
+ exports.getValidators = getValidators;
9
12
  function Validator(validatorInstance) {
10
- return (object, fieldName) => {
11
- // Add field to list
12
- const validators = Reflect.getMetadata(exports.STEROIDS_META_VALIDATORS, object, fieldName) || [];
13
+ return (target, fieldName) => {
14
+ const getMetadataParams = fieldName
15
+ ? [exports.STEROIDS_META_VALIDATORS, target, fieldName]
16
+ : [exports.STEROIDS_META_VALIDATORS, target];
17
+ const validators = Reflect.getMetadata(...getMetadataParams) || [];
13
18
  if (!validators.includes(validatorInstance)) {
14
19
  validators.push(validatorInstance);
15
20
  }
16
- Reflect.defineMetadata(exports.STEROIDS_META_VALIDATORS, validators, object, fieldName);
21
+ const defineMetadataParams = fieldName
22
+ ? [exports.STEROIDS_META_VALIDATORS, validators, target, fieldName]
23
+ : [exports.STEROIDS_META_VALIDATORS, validators, target];
24
+ Reflect.defineMetadata(...defineMetadataParams);
17
25
  };
18
26
  }
19
27
  exports.Validator = Validator;
@@ -1 +1 @@
1
- {"version":3,"file":"Validator.js","sourceRoot":"","sources":["../../../src/usecases/validators/Validator.ts"],"names":[],"mappings":";;;AAEa,QAAA,wBAAwB,GAAG,0BAA0B,CAAC;AAI5D,MAAM,kBAAkB,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;IACvD,OAAO,OAAO,CAAC,WAAW,CAAC,gCAAwB,EAAE,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC;AAC/F,CAAC,CAAA;AAFY,QAAA,kBAAkB,sBAE9B;AAED,SAAgB,SAAS,CAAC,iBAA0C;IAChE,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE;QAEzB,oBAAoB;QACpB,MAAM,UAAU,GAAG,OAAO,CAAC,WA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AAM,oBAAoB,GAAgC,SAAS;YAC/D,CAAC,CAAC,CAAC,gCAAwB,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC;YAC3D,CAAC,CAAC,CAAC,gCAAwB,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;QAErD,OAAO,CAAC,cAAc,CAAC,GAAG,oBAAoB,CAAC,CAAC;IACpD,CAAC,CAAC;AACN,CAAC;AAlBD,8BAkBC"}
@@ -1,9 +0,0 @@
1
- export interface ITableOptions {
2
- name: string;
3
- label?: string;
4
- modelClass?: any;
5
- }
6
- export declare const setModelBuilder: (ModelClass: any, builderHandler: any) => void;
7
- export declare const getTableFromModel: (ModelClass: any) => any;
8
- export declare const getModelBuilder: (ModelClass: any) => any;
9
- export declare function TableFromModel(ModelClass: any, tableName: any): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TableFromModel = exports.getModelBuilder = exports.getTableFromModel = exports.setModelBuilder = void 0;
4
- const typeorm_1 = require("@steroidsjs/typeorm");
5
- const ExtendField_1 = require("./fields/ExtendField");
6
- const common_1 = require("@nestjs/common");
7
- const BaseField_1 = require("./fields/BaseField");
8
- const modelToTableMap = {};
9
- const modelBuildersMap = {};
10
- const setModelBuilder = (ModelClass, builderHandler) => {
11
- if (builderHandler && modelBuildersMap[ModelClass.name]) {
12
- throw new Error('Model "' + ModelClass.name + '" already has builder');
13
- }
14
- modelBuildersMap[ModelClass.name] = builderHandler;
15
- };
16
- exports.setModelBuilder = setModelBuilder;
17
- const getTableFromModel = (ModelClass) => {
18
- return modelToTableMap[ModelClass.name] || null;
19
- };
20
- exports.getTableFromModel = getTableFromModel;
21
- const getModelBuilder = (ModelClass) => {
22
- return modelBuildersMap[ModelClass.name] || null;
23
- };
24
- exports.getModelBuilder = getModelBuilder;
25
- function TableFromModelInternal(ModelClass) {
26
- return (target) => {
27
- modelToTableMap[ModelClass.name] = target;
28
- (0, BaseField_1.getMetaFields)(ModelClass).forEach(field => {
29
- // считаем что поле модели полем таблицы, если для него задан декоратор,
30
- // так как все steroids-поля задают декораторы
31
- // @todo нужно определять является ли поле колонкой в бд более семантически логичным способом
32
- const options = (0, BaseField_1.getFieldOptions)(ModelClass, field);
33
- const isTableColumn = !!(0, BaseField_1.getFieldDecoratorName)(ModelClass, field);
34
- if (isTableColumn && options && !options.noColumn) {
35
- (0, ExtendField_1.ExtendField)(ModelClass)(target.prototype, field);
36
- }
37
- });
38
- };
39
- }
40
- function TableFromModel(ModelClass, tableName) {
41
- return (0, common_1.applyDecorators)((0, typeorm_1.Entity)(tableName), TableFromModelInternal(ModelClass));
42
- }
43
- exports.TableFromModel = TableFromModel;
44
- //# sourceMappingURL=TableFromModel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableFromModel.js","sourceRoot":"","sources":["../../../src/infrastructure/decorators/TableFromModel.ts"],"names":[],"mappings":";;;AAAA,iDAA2C;AAC3C,sDAAiD;AACjD,2CAA+C;AAC/C,kDAAyF;AAQzF,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAErB,MAAM,eAAe,GAAG,CAAC,UAAU,EAAE,cAAc,EAAE,EAAE;IAC1D,IAAI,cAAc,IAAI,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QACrD,MAAM,IAAI,KAAK,CAAC,SAAS,GAAG,UAAU,CAAC,IAAI,GAAG,uBAAuB,CAAC,CAAC;KAC1E;IACD,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC;AACvD,CAAC,CAAA;AALY,QAAA,eAAe,mBAK3B;AAEM,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,EAAE;IAC5C,OAAO,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;AACpD,CA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