@itzworking/decorated-class 0.0.151 → 0.0.157

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 (175) hide show
  1. package/README.md +3 -3
  2. package/{src → dist}/decorated-class.d.ts +1 -0
  3. package/dist/decorated-class.d.ts.map +1 -0
  4. package/{src → dist}/decorated-class.js +11 -16
  5. package/{src → dist}/decorators/attribute/attribute.d.ts +1 -0
  6. package/dist/decorators/attribute/attribute.d.ts.map +1 -0
  7. package/{src → dist}/decorators/attribute/attribute.js +11 -16
  8. package/dist/decorators/attribute/index.d.ts +5 -0
  9. package/dist/decorators/attribute/index.d.ts.map +1 -0
  10. package/{src → dist}/decorators/attribute/is-attribute.d.ts +1 -0
  11. package/dist/decorators/attribute/is-attribute.d.ts.map +1 -0
  12. package/dist/decorators/attribute/is-attribute.js +4 -0
  13. package/{src → dist}/decorators/attribute/list-attributes.d.ts +1 -0
  14. package/dist/decorators/attribute/list-attributes.d.ts.map +1 -0
  15. package/dist/decorators/attribute/list-attributes.js +11 -0
  16. package/{src → dist}/decorators/attribute/symbol.d.ts +1 -0
  17. package/dist/decorators/attribute/symbol.d.ts.map +1 -0
  18. package/dist/decorators/attribute/symbol.js +1 -0
  19. package/{src → dist}/decorators/attribute/types/attribute-decorator.d.ts +1 -0
  20. package/dist/decorators/attribute/types/attribute-decorator.d.ts.map +1 -0
  21. package/dist/decorators/attribute/types/attribute-decorator.js +1 -0
  22. package/{src → dist}/decorators/attribute/types/attribute-definition.d.ts +1 -0
  23. package/dist/decorators/attribute/types/attribute-definition.d.ts.map +1 -0
  24. package/dist/decorators/attribute/types/attribute-definition.js +1 -0
  25. package/dist/decorators/attribute/types/attribute-type-alias.d.ts +3 -0
  26. package/dist/decorators/attribute/types/attribute-type-alias.d.ts.map +1 -0
  27. package/{src → dist}/decorators/attribute/types/attribute-type.d.ts +1 -0
  28. package/dist/decorators/attribute/types/attribute-type.d.ts.map +1 -0
  29. package/{src → dist}/decorators/attribute/types/attribute-type.js +3 -6
  30. package/dist/decorators/attribute/types/index.d.ts +6 -0
  31. package/dist/decorators/attribute/types/index.d.ts.map +1 -0
  32. package/{src → dist}/decorators/attribute/types/primitive-type.d.ts +1 -0
  33. package/dist/decorators/attribute/types/primitive-type.d.ts.map +1 -0
  34. package/dist/decorators/attribute/types/primitive-type.js +8 -0
  35. package/dist/decorators/attribute/utils/index.d.ts +2 -0
  36. package/dist/decorators/attribute/utils/index.d.ts.map +1 -0
  37. package/{src → dist}/decorators/attribute/utils/update-attributes.d.ts +1 -0
  38. package/dist/decorators/attribute/utils/update-attributes.d.ts.map +1 -0
  39. package/{src → dist}/decorators/attribute/utils/update-attributes.js +8 -13
  40. package/dist/decorators/index.d.ts +5 -0
  41. package/dist/decorators/index.d.ts.map +1 -0
  42. package/dist/decorators/validation/index.d.ts +8 -0
  43. package/dist/decorators/validation/index.d.ts.map +1 -0
  44. package/{src → dist}/decorators/validation/max.d.ts +1 -0
  45. package/dist/decorators/validation/max.d.ts.map +1 -0
  46. package/dist/decorators/validation/max.js +17 -0
  47. package/{src → dist}/decorators/validation/min.d.ts +1 -0
  48. package/dist/decorators/validation/min.d.ts.map +1 -0
  49. package/dist/decorators/validation/min.js +17 -0
  50. package/{src → dist}/decorators/validation/not-blank.d.ts +1 -0
  51. package/dist/decorators/validation/not-blank.d.ts.map +1 -0
  52. package/dist/decorators/validation/not-blank.js +11 -0
  53. package/{src → dist}/decorators/validation/not-null.d.ts +1 -0
  54. package/dist/decorators/validation/not-null.d.ts.map +1 -0
  55. package/dist/decorators/validation/not-null.js +2 -0
  56. package/{src → dist}/decorators/validation/pattern.d.ts +1 -0
  57. package/dist/decorators/validation/pattern.d.ts.map +1 -0
  58. package/dist/decorators/validation/pattern.js +12 -0
  59. package/dist/decorators/validation/types/index.d.ts +3 -0
  60. package/dist/decorators/validation/types/index.d.ts.map +1 -0
  61. package/{src → dist}/decorators/validation/types/validation-definition.d.ts +1 -0
  62. package/dist/decorators/validation/types/validation-definition.d.ts.map +1 -0
  63. package/dist/decorators/validation/types/validation-definition.js +1 -0
  64. package/{src → dist}/decorators/validation/types/validation-type.d.ts +1 -0
  65. package/dist/decorators/validation/types/validation-type.d.ts.map +1 -0
  66. package/dist/decorators/validation/types/validation-type.js +1 -0
  67. package/dist/decorators/validation/utils/index.d.ts +2 -0
  68. package/dist/decorators/validation/utils/index.d.ts.map +1 -0
  69. package/{src → dist}/decorators/validation/utils/register-constraint.d.ts +1 -0
  70. package/dist/decorators/validation/utils/register-constraint.d.ts.map +1 -0
  71. package/{src → dist}/decorators/validation/utils/register-constraint.js +10 -16
  72. package/{src → dist}/errors/attributes-not-valid-error.d.ts +1 -0
  73. package/dist/errors/attributes-not-valid-error.d.ts.map +1 -0
  74. package/dist/errors/attributes-not-valid-error.js +9 -0
  75. package/dist/errors/index.d.ts +4 -0
  76. package/dist/errors/index.d.ts.map +1 -0
  77. package/{src → dist}/errors/invalid-target-error.d.ts +1 -0
  78. package/dist/errors/invalid-target-error.d.ts.map +1 -0
  79. package/dist/errors/invalid-target-error.js +6 -0
  80. package/{src → dist}/errors/unsupported-decorator-error.d.ts +1 -0
  81. package/dist/errors/unsupported-decorator-error.d.ts.map +1 -0
  82. package/{src → dist}/errors/unsupported-decorator-error.js +4 -6
  83. package/dist/index.d.ts +6 -0
  84. package/dist/index.d.ts.map +1 -0
  85. package/{src → dist}/types.d.ts +1 -0
  86. package/dist/types.d.ts.map +1 -0
  87. package/dist/types.js +2 -0
  88. package/dist/validator/index.d.ts +2 -0
  89. package/dist/validator/index.d.ts.map +1 -0
  90. package/{src → dist}/validator/list-validation-errors.d.ts +1 -0
  91. package/dist/validator/list-validation-errors.d.ts.map +1 -0
  92. package/{src → dist}/validator/list-validation-errors.js +8 -13
  93. package/{src → dist}/validator/validate.d.ts +1 -0
  94. package/dist/validator/validate.d.ts.map +1 -0
  95. package/dist/validator/validate.js +8 -0
  96. package/{src → dist}/validator/validator.d.ts +1 -0
  97. package/dist/validator/validator.d.ts.map +1 -0
  98. package/dist/validator/validator.js +6 -0
  99. package/package.json +36 -8
  100. package/src/decorated-class.js.map +0 -1
  101. package/src/decorators/attribute/attribute.js.map +0 -1
  102. package/src/decorators/attribute/index.js +0 -8
  103. package/src/decorators/attribute/index.js.map +0 -1
  104. package/src/decorators/attribute/is-attribute.js +0 -9
  105. package/src/decorators/attribute/is-attribute.js.map +0 -1
  106. package/src/decorators/attribute/list-attributes.js +0 -16
  107. package/src/decorators/attribute/list-attributes.js.map +0 -1
  108. package/src/decorators/attribute/symbol.js +0 -5
  109. package/src/decorators/attribute/symbol.js.map +0 -1
  110. package/src/decorators/attribute/types/attribute-decorator.js +0 -3
  111. package/src/decorators/attribute/types/attribute-decorator.js.map +0 -1
  112. package/src/decorators/attribute/types/attribute-definition.js +0 -3
  113. package/src/decorators/attribute/types/attribute-definition.js.map +0 -1
  114. package/src/decorators/attribute/types/attribute-type-alias.js +0 -6
  115. package/src/decorators/attribute/types/attribute-type-alias.js.map +0 -1
  116. package/src/decorators/attribute/types/attribute-type.js.map +0 -1
  117. package/src/decorators/attribute/types/index.js +0 -9
  118. package/src/decorators/attribute/types/index.js.map +0 -1
  119. package/src/decorators/attribute/types/primitive-type.js +0 -12
  120. package/src/decorators/attribute/types/primitive-type.js.map +0 -1
  121. package/src/decorators/attribute/utils/index.js +0 -5
  122. package/src/decorators/attribute/utils/index.js.map +0 -1
  123. package/src/decorators/attribute/utils/update-attributes.js.map +0 -1
  124. package/src/decorators/index.js +0 -8
  125. package/src/decorators/index.js.map +0 -1
  126. package/src/decorators/validation/index.js +0 -11
  127. package/src/decorators/validation/index.js.map +0 -1
  128. package/src/decorators/validation/max.js +0 -21
  129. package/src/decorators/validation/max.js.map +0 -1
  130. package/src/decorators/validation/min.js +0 -21
  131. package/src/decorators/validation/min.js.map +0 -1
  132. package/src/decorators/validation/not-blank.js +0 -15
  133. package/src/decorators/validation/not-blank.js.map +0 -1
  134. package/src/decorators/validation/not-null.js +0 -6
  135. package/src/decorators/validation/not-null.js.map +0 -1
  136. package/src/decorators/validation/pattern.js +0 -16
  137. package/src/decorators/validation/pattern.js.map +0 -1
  138. package/src/decorators/validation/types/index.js +0 -6
  139. package/src/decorators/validation/types/index.js.map +0 -1
  140. package/src/decorators/validation/types/validation-definition.js +0 -3
  141. package/src/decorators/validation/types/validation-definition.js.map +0 -1
  142. package/src/decorators/validation/types/validation-type.js +0 -3
  143. package/src/decorators/validation/types/validation-type.js.map +0 -1
  144. package/src/decorators/validation/utils/index.js +0 -5
  145. package/src/decorators/validation/utils/index.js.map +0 -1
  146. package/src/decorators/validation/utils/register-constraint.js.map +0 -1
  147. package/src/errors/attributes-not-valid-error.js +0 -13
  148. package/src/errors/attributes-not-valid-error.js.map +0 -1
  149. package/src/errors/index.js +0 -7
  150. package/src/errors/index.js.map +0 -1
  151. package/src/errors/invalid-target-error.js +0 -11
  152. package/src/errors/invalid-target-error.js.map +0 -1
  153. package/src/errors/unsupported-decorator-error.js.map +0 -1
  154. package/src/index.js +0 -9
  155. package/src/index.js.map +0 -1
  156. package/src/types.js +0 -4
  157. package/src/types.js.map +0 -1
  158. package/src/validator/index.js +0 -5
  159. package/src/validator/index.js.map +0 -1
  160. package/src/validator/list-validation-errors.js.map +0 -1
  161. package/src/validator/validate.js +0 -13
  162. package/src/validator/validate.js.map +0 -1
  163. package/src/validator/validator.js +0 -10
  164. package/src/validator/validator.js.map +0 -1
  165. /package/{src/decorators/attribute/index.d.ts → dist/decorators/attribute/index.js} +0 -0
  166. /package/{src/decorators/attribute/types/attribute-type-alias.d.ts → dist/decorators/attribute/types/attribute-type-alias.js} +0 -0
  167. /package/{src/decorators/attribute/types/index.d.ts → dist/decorators/attribute/types/index.js} +0 -0
  168. /package/{src/decorators/attribute/utils/index.d.ts → dist/decorators/attribute/utils/index.js} +0 -0
  169. /package/{src/decorators/index.d.ts → dist/decorators/index.js} +0 -0
  170. /package/{src/decorators/validation/index.d.ts → dist/decorators/validation/index.js} +0 -0
  171. /package/{src/decorators/validation/types/index.d.ts → dist/decorators/validation/types/index.js} +0 -0
  172. /package/{src/decorators/validation/utils/index.d.ts → dist/decorators/validation/utils/index.js} +0 -0
  173. /package/{src/errors/index.d.ts → dist/errors/index.js} +0 -0
  174. /package/{src/index.d.ts → dist/index.js} +0 -0
  175. /package/{src/validator/index.d.ts → dist/validator/index.js} +0 -0
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # ItzWorking (AWS Serverless, Next.js, TypeScript)
1
+ # ITz Working (AWS Serverless, TypeScript)
2
2
 
3
- > **ItzWorking because you built it!**
3
+ > **ITz Working because you built it!**
4
4
 
5
- Framework for building AWS Serverless applications with Next.js and TypeScript.
5
+ Framework for building AWS Serverless applications with TypeScript.
6
6
 
7
7
  - [Intro](#intro)
8
8
  - [Key features](#key-features)
@@ -2,3 +2,4 @@ export type DecoratedClassConstructorProps = any;
2
2
  export declare abstract class DecoratedClass {
3
3
  protected constructor(props?: DecoratedClassConstructorProps);
4
4
  }
5
+ //# sourceMappingURL=decorated-class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorated-class.d.ts","sourceRoot":"","sources":["../src/decorated-class.ts"],"names":[],"mappings":"AAoEA,MAAM,MAAM,8BAA8B,GAAG,GAAG,CAAC;AAEjD,8BAAsB,cAAc;IAClC,SAAS,aAAa,KAAK,GAAE,8BAAmC;CAkBjE"}
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DecoratedClass = void 0;
4
- const decorators_1 = require("./decorators");
1
+ import { AttributeType, listAttributes, PrimitiveType } from "./decorators";
5
2
  const parseBoolean = (value) => {
6
3
  switch (value) {
7
4
  case true:
@@ -23,27 +20,27 @@ const parseBoolean = (value) => {
23
20
  }
24
21
  };
25
22
  const isPrimitiveType = (type) => {
26
- return Object.values(decorators_1.PrimitiveType).includes(type);
23
+ return Object.values(PrimitiveType).includes(type);
27
24
  };
28
25
  const parseType = (value, type, nestedType) => {
29
- if (type === decorators_1.AttributeType.Float) {
26
+ if (type === AttributeType.Float) {
30
27
  return parseFloat(value);
31
28
  }
32
- if (type === decorators_1.AttributeType.Integer) {
29
+ if (type === AttributeType.Integer) {
33
30
  return parseInt(value);
34
31
  }
35
- if (type === decorators_1.AttributeType.Boolean) {
32
+ if (type === AttributeType.Boolean) {
36
33
  return parseBoolean(value);
37
34
  }
38
- if (type === decorators_1.AttributeType.Date) {
35
+ if (type === AttributeType.Date) {
39
36
  return new Date(value);
40
37
  }
41
- if (type === decorators_1.AttributeType.Object &&
38
+ if (type === AttributeType.Object &&
42
39
  nestedType &&
43
40
  nestedType.prototype instanceof DecoratedClass) {
44
41
  return new nestedType(value);
45
42
  }
46
- if (type === decorators_1.AttributeType.List) {
43
+ if (type === AttributeType.List) {
47
44
  if (!value || !Array.isArray(value)) {
48
45
  return undefined;
49
46
  }
@@ -52,18 +49,18 @@ const parseType = (value, type, nestedType) => {
52
49
  return value.map((item) => parseType(item, nestedType));
53
50
  }
54
51
  else if (nestedType.prototype instanceof DecoratedClass) {
55
- return value.map((item) => parseType(item, decorators_1.AttributeType.Object, nestedType));
52
+ return value.map((item) => parseType(item, AttributeType.Object, nestedType));
56
53
  }
57
54
  }
58
55
  }
59
56
  return value;
60
57
  };
61
- class DecoratedClass {
58
+ export class DecoratedClass {
62
59
  constructor(props = {}) {
63
60
  if (!props) {
64
61
  return;
65
62
  }
66
- const attributes = (0, decorators_1.listAttributes)(this);
63
+ const attributes = listAttributes(this);
67
64
  const self = this;
68
65
  for (const attribute of attributes) {
69
66
  const { attributeName: key, attributeType, nestedType } = attribute;
@@ -78,5 +75,3 @@ class DecoratedClass {
78
75
  }
79
76
  }
80
77
  }
81
- exports.DecoratedClass = DecoratedClass;
82
- //# sourceMappingURL=decorated-class.js.map
@@ -3,3 +3,4 @@ import { DecoratedClass } from "../../decorated-class";
3
3
  export declare const Attribute: (attributeType: AttributeType, options?: {
4
4
  nestedType?: PrimitiveType | DecoratedClass | any;
5
5
  }) => import("./types").AttributeDecorator;
6
+ //# sourceMappingURL=attribute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attribute.d.ts","sourceRoot":"","sources":["../../../src/decorators/attribute/attribute.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,eAAO,MAAM,SAAS,kBACL,aAAa,YACnB;IAAE,UAAU,CAAC,EAAE,aAAa,GAAG,cAAc,GAAG,GAAG,CAAA;CAAE,yCAiC/D,CAAC"}
@@ -1,36 +1,32 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Attribute = void 0;
4
- const utils_1 = require("./utils");
5
- const types_1 = require("./types");
6
- const Attribute = (attributeType, options = {}) => {
1
+ import { updateAttributes } from "./utils";
2
+ import { AttributeType } from "./types";
3
+ export const Attribute = (attributeType, options = {}) => {
7
4
  let isValidType = () => true;
8
- if (attributeType === types_1.AttributeType.String) {
5
+ if (attributeType === AttributeType.String) {
9
6
  isValidType = (value) => value === undefined || value === null || typeof value === "string";
10
7
  }
11
- else if (attributeType === types_1.AttributeType.Integer) {
8
+ else if (attributeType === AttributeType.Integer) {
12
9
  isValidType = (value) => value === undefined ||
13
10
  value === null ||
14
11
  (Number(value) === value && value % 1 === 0);
15
12
  }
16
- else if (attributeType === types_1.AttributeType.Float) {
13
+ else if (attributeType === AttributeType.Float) {
17
14
  isValidType = (value) => value === undefined || value === null || Number(value) === value;
18
15
  }
19
- else if (attributeType === types_1.AttributeType.Boolean) {
16
+ else if (attributeType === AttributeType.Boolean) {
20
17
  isValidType = (value) => value === undefined || value === null || typeof value === "boolean";
21
18
  }
22
- else if (attributeType === types_1.AttributeType.Date) {
19
+ else if (attributeType === AttributeType.Date) {
23
20
  isValidType = (value) => value === undefined || value === null || value instanceof Date;
24
21
  }
25
- else if (attributeType === types_1.AttributeType.List) {
22
+ else if (attributeType === AttributeType.List) {
26
23
  isValidType = (value) => value === undefined || value === null || Array.isArray(value);
27
24
  }
28
- else if (attributeType === types_1.AttributeType.Object) {
25
+ else if (attributeType === AttributeType.Object) {
29
26
  isValidType = (value) => value === undefined || value === null || typeof value === "object";
30
27
  }
31
- return (0, utils_1.updateAttributes)(attributeType, isValidType, options);
28
+ return updateAttributes(attributeType, isValidType, options);
32
29
  };
33
- exports.Attribute = Attribute;
34
30
  // export const OldAttribute = {
35
31
  // List: (type: PrimitiveType | any) =>
36
32
  // updateAttributes(
@@ -47,4 +43,3 @@ exports.Attribute = Attribute;
47
43
  // type
48
44
  // ),
49
45
  // };
50
- //# sourceMappingURL=attribute.js.map
@@ -0,0 +1,5 @@
1
+ export * from "./types";
2
+ export * from "./attribute";
3
+ export * from "./is-attribute";
4
+ export * from "./list-attributes";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/decorators/attribute/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC"}
@@ -1 +1,2 @@
1
1
  export declare const isAttribute: (target: any, propertyKey: string) => boolean;
2
+ //# sourceMappingURL=is-attribute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-attribute.d.ts","sourceRoot":"","sources":["../../../src/decorators/attribute/is-attribute.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,WAAY,GAAG,eAAe,MAAM,YAE3D,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { symbol } from "./symbol";
2
+ export const isAttribute = (target, propertyKey) => {
3
+ return !!Reflect.getMetadata(symbol, target, propertyKey);
4
+ };
@@ -1,2 +1,3 @@
1
1
  import { AttributeDefinition } from "./types";
2
2
  export declare const listAttributes: (target: any) => AttributeDefinition[];
3
+ //# sourceMappingURL=list-attributes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-attributes.d.ts","sourceRoot":"","sources":["../../../src/decorators/attribute/list-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAG9C,eAAO,MAAM,cAAc,WAAY,GAAG,KAAG,mBAAmB,EAS/D,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { symbol } from "./symbol";
2
+ export const listAttributes = (target) => {
3
+ let attributes = [];
4
+ let targetToUse = Object.getPrototypeOf(target);
5
+ while (targetToUse && targetToUse !== Object.prototype) {
6
+ const parentAttributes = Reflect.getOwnMetadata(symbol, targetToUse) || [];
7
+ attributes = [...parentAttributes, ...attributes];
8
+ targetToUse = Object.getPrototypeOf(targetToUse);
9
+ }
10
+ return attributes;
11
+ };
@@ -1 +1,2 @@
1
1
  export declare const symbol: unique symbol;
2
+ //# sourceMappingURL=symbol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"symbol.d.ts","sourceRoot":"","sources":["../../../src/decorators/attribute/symbol.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,eAA0B,CAAC"}
@@ -0,0 +1 @@
1
+ export const symbol = Symbol("itw_attribute");
@@ -1,3 +1,4 @@
1
1
  export type AttributeDecorator = (target: any, context: string | ((ClassMethodDecoratorContext | ClassFieldDecoratorContext) & {
2
2
  name: string;
3
3
  })) => void;
4
+ //# sourceMappingURL=attribute-decorator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attribute-decorator.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attribute/types/attribute-decorator.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,CAC/B,MAAM,EAAE,GAAG,EACX,OAAO,EACH,MAAM,GACN,CAAC,CAAC,2BAA2B,GAAG,0BAA0B,CAAC,GAAG;IAC5D,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,KACH,IAAI,CAAC"}
@@ -13,3 +13,4 @@ export type AttributeDefinition = {
13
13
  nestedType?: PrimitiveType | DecoratedClass | any;
14
14
  isValidTypeInTarget: (target: any) => boolean;
15
15
  };
16
+ //# sourceMappingURL=attribute-definition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attribute-definition.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attribute/types/attribute-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,MAAM,MAAM,oBAAoB,GAAG;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC;IAClC,eAAe,CAAC,EAAE,GAAG,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,WAAW,EAAE,oBAAoB,EAAE,CAAC;IACpC,UAAU,CAAC,EAAE,aAAa,GAAG,cAAc,GAAG,GAAG,CAAC;IAClD,mBAAmB,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC;CAC/C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { AttributeType as AT } from "./attribute-type";
2
+ export { AT };
3
+ //# sourceMappingURL=attribute-type-alias.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attribute-type-alias.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attribute/types/attribute-type-alias.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,EAAE,EAAE,CAAC"}
@@ -7,3 +7,4 @@ export declare enum AttributeType {
7
7
  List = "List",
8
8
  Object = "Object"
9
9
  }
10
+ //# sourceMappingURL=attribute-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attribute-type.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attribute/types/attribute-type.ts"],"names":[],"mappings":"AAEA,oBAAY,aAAa;IACvB,MAAM,WAAuB;IAC7B,KAAK,UAAsB;IAC3B,OAAO,YAAwB;IAC/B,OAAO,YAAwB;IAC/B,IAAI,SAAqB;IACzB,IAAI,SAAS;IACb,MAAM,WAAW;CAClB"}
@@ -1,7 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AttributeType = void 0;
4
- var AttributeType;
1
+ import { PrimitiveType } from "./primitive-type";
2
+ export var AttributeType;
5
3
  (function (AttributeType) {
6
4
  AttributeType["String"] = "String";
7
5
  AttributeType["Float"] = "Float";
@@ -10,5 +8,4 @@ var AttributeType;
10
8
  AttributeType["Date"] = "Date";
11
9
  AttributeType["List"] = "List";
12
10
  AttributeType["Object"] = "Object";
13
- })(AttributeType || (exports.AttributeType = AttributeType = {}));
14
- //# sourceMappingURL=attribute-type.js.map
11
+ })(AttributeType || (AttributeType = {}));
@@ -0,0 +1,6 @@
1
+ export * from "./attribute-decorator";
2
+ export * from "./attribute-definition";
3
+ export * from "./attribute-type";
4
+ export * from "./attribute-type-alias";
5
+ export * from "./primitive-type";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attribute/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC"}
@@ -5,3 +5,4 @@ export declare enum PrimitiveType {
5
5
  Boolean = "Boolean",
6
6
  Date = "Date"
7
7
  }
8
+ //# sourceMappingURL=primitive-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitive-type.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attribute/types/primitive-type.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa;IACvB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,IAAI,SAAS;CACd"}
@@ -0,0 +1,8 @@
1
+ export var PrimitiveType;
2
+ (function (PrimitiveType) {
3
+ PrimitiveType["String"] = "String";
4
+ PrimitiveType["Integer"] = "Integer";
5
+ PrimitiveType["Float"] = "Float";
6
+ PrimitiveType["Boolean"] = "Boolean";
7
+ PrimitiveType["Date"] = "Date";
8
+ })(PrimitiveType || (PrimitiveType = {}));
@@ -0,0 +1,2 @@
1
+ export * from "./update-attributes";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attribute/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
@@ -2,3 +2,4 @@ import "reflect-metadata";
2
2
  import { AttributeDecorator, AttributeType, PrimitiveType } from "../types";
3
3
  import { DecoratedClass } from "../../../decorated-class";
4
4
  export declare const updateAttributes: (attributeType: AttributeType, isValidType: (value: any, nestedType?: PrimitiveType | DecoratedClass | any) => boolean, options?: any) => AttributeDecorator;
5
+ //# sourceMappingURL=update-attributes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-attributes.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attribute/utils/update-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EACL,kBAAkB,EAElB,aAAa,EACb,aAAa,EACd,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,eAAO,MAAM,gBAAgB,kBAEV,aAAa,eACf,CACX,KAAK,EAAE,GAAG,EACV,UAAU,CAAC,EAAE,aAAa,GAAG,cAAc,GAAG,GAAG,KAC9C,OAAO,YACH,GAAG,KACX,kBAqCF,CAAC"}
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateAttributes = void 0;
4
- require("reflect-metadata");
5
- const symbol_1 = require("../symbol");
6
- const updateAttributes = (attributeType, isValidType, options = {}) => (target, context) => {
7
- const attributes = Reflect.getOwnMetadata(symbol_1.symbol, target) || [];
1
+ import "reflect-metadata";
2
+ import { symbol } from "../symbol";
3
+ export const updateAttributes = (attributeType, isValidType, options = {}) => (target, context) => {
4
+ const attributes = Reflect.getOwnMetadata(symbol, target) || [];
8
5
  const attributeName = typeof context === "string" ? context : context.name;
9
6
  let currentAttribute = attributes.find((attribute) => attribute.attributeName === attributeName);
10
7
  const isValidTypeInTarget = (target) => isValidType(typeof target[attributeName] === "function"
@@ -16,7 +13,7 @@ const updateAttributes = (attributeType, isValidType, options = {}) => (target,
16
13
  attributeType,
17
14
  constraints: [],
18
15
  // isMethod: typeof target[attributeName] === "function",
19
- nestedType: options === null || options === void 0 ? void 0 : options.nestedType,
16
+ nestedType: options?.nestedType,
20
17
  isValidTypeInTarget,
21
18
  };
22
19
  attributes.push(currentAttribute);
@@ -24,11 +21,9 @@ const updateAttributes = (attributeType, isValidType, options = {}) => (target,
24
21
  else {
25
22
  currentAttribute.attributeType = attributeType;
26
23
  // currentAttribute.isMethod = typeof target[attributeName] === "function";
27
- currentAttribute.nestedType = options === null || options === void 0 ? void 0 : options.nestedType;
24
+ currentAttribute.nestedType = options?.nestedType;
28
25
  currentAttribute.isValidTypeInTarget = isValidTypeInTarget;
29
26
  }
30
- Reflect.defineMetadata(symbol_1.symbol, attributes, target);
31
- Reflect.defineMetadata(symbol_1.symbol, currentAttribute, target, attributeName);
27
+ Reflect.defineMetadata(symbol, attributes, target);
28
+ Reflect.defineMetadata(symbol, currentAttribute, target, attributeName);
32
29
  };
33
- exports.updateAttributes = updateAttributes;
34
- //# sourceMappingURL=update-attributes.js.map
@@ -0,0 +1,5 @@
1
+ import "reflect-metadata";
2
+ export * from "./attribute";
3
+ export * from "./attribute/types/primitive-type";
4
+ export * from "./validation";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,cAAc,aAAa,CAAC;AAC5B,cAAc,kCAAkC,CAAC;AACjD,cAAc,cAAc,CAAC"}
@@ -0,0 +1,8 @@
1
+ export * from "./types";
2
+ export * from "./utils";
3
+ export * from "./max";
4
+ export * from "./min";
5
+ export * from "./not-blank";
6
+ export * from "./not-null";
7
+ export * from "./pattern";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/decorators/validation/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
@@ -1 +1,2 @@
1
1
  export declare const Max: (props: number) => import("..").AttributeDecorator;
2
+ //# sourceMappingURL=max.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"max.d.ts","sourceRoot":"","sources":["../../../src/decorators/validation/max.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,GAAG,oDAiBf,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { registerConstraintWithProps } from "./utils";
2
+ import { UnsupportedDecoratorError } from "../../errors";
3
+ export const Max = registerConstraintWithProps("Max", (max) => (value) => {
4
+ if (value === null || value === undefined) {
5
+ return true;
6
+ }
7
+ if (typeof value === "string") {
8
+ return value.length <= max;
9
+ }
10
+ if (typeof value === "number") {
11
+ return value <= max;
12
+ }
13
+ if (Array.isArray(value)) {
14
+ return value.length <= max;
15
+ }
16
+ throw new UnsupportedDecoratorError();
17
+ });
@@ -1 +1,2 @@
1
1
  export declare const Min: (props: number) => import("..").AttributeDecorator;
2
+ //# sourceMappingURL=min.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"min.d.ts","sourceRoot":"","sources":["../../../src/decorators/validation/min.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,GAAG,oDAiBf,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { registerConstraintWithProps } from "./utils";
2
+ import { UnsupportedDecoratorError } from "../../errors";
3
+ export const Min = registerConstraintWithProps("Min", (min) => (value) => {
4
+ if (value === null || value === undefined) {
5
+ return true;
6
+ }
7
+ if (typeof value === "string") {
8
+ return value.length >= min;
9
+ }
10
+ if (typeof value === "number") {
11
+ return value >= min;
12
+ }
13
+ if (Array.isArray(value)) {
14
+ return value.length >= min;
15
+ }
16
+ throw new UnsupportedDecoratorError();
17
+ });
@@ -1 +1,2 @@
1
1
  export declare const NotBlank: import("..").AttributeDecorator;
2
+ //# sourceMappingURL=not-blank.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"not-blank.d.ts","sourceRoot":"","sources":["../../../src/decorators/validation/not-blank.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ,iCAWpB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { registerConstraintWithoutProps } from "./utils";
2
+ import { UnsupportedDecoratorError } from "../../errors";
3
+ export const NotBlank = registerConstraintWithoutProps("NotBlank", (value) => {
4
+ if (value === null || value === undefined) {
5
+ return true;
6
+ }
7
+ if (typeof value !== "string") {
8
+ throw new UnsupportedDecoratorError();
9
+ }
10
+ return value.trim().length > 0;
11
+ });
@@ -1 +1,2 @@
1
1
  export declare const NotNull: import("..").AttributeDecorator;
2
+ //# sourceMappingURL=not-null.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"not-null.d.ts","sourceRoot":"","sources":["../../../src/decorators/validation/not-null.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,iCAGnB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { registerConstraintWithoutProps } from "./utils";
2
+ export const NotNull = registerConstraintWithoutProps("NotNull", (value) => value !== null && value !== undefined);
@@ -1 +1,2 @@
1
1
  export declare const Pattern: (props: string | RegExp) => import("..").AttributeDecorator;
2
+ //# sourceMappingURL=pattern.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pattern.d.ts","sourceRoot":"","sources":["../../../src/decorators/validation/pattern.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,6DAYnB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { registerConstraintWithProps } from "./utils";
2
+ import { UnsupportedDecoratorError } from "../../errors";
3
+ export const Pattern = registerConstraintWithProps("Pattern", (pattern) => (value) => {
4
+ if (value === null || value === undefined) {
5
+ return true;
6
+ }
7
+ if (typeof value !== "string") {
8
+ throw new UnsupportedDecoratorError();
9
+ }
10
+ const r = value.match(pattern);
11
+ return !!r && r.length > 0;
12
+ });
@@ -0,0 +1,3 @@
1
+ export * from "./validation-definition";
2
+ export * from "./validation-type";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/decorators/validation/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC"}
@@ -4,3 +4,4 @@ export type ValidationDefinition = {
4
4
  isValidInTargetMethod: (target: any) => boolean;
5
5
  validationOptions?: any;
6
6
  };
7
+ //# sourceMappingURL=validation-definition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation-definition.d.ts","sourceRoot":"","sources":["../../../../src/decorators/validation/types/validation-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,EAAE,cAAc,CAAC;IAC/B,qBAAqB,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC;IAChD,iBAAiB,CAAC,EAAE,GAAG,CAAC;CACzB,CAAC"}
@@ -1 +1,2 @@
1
1
  export type ValidationType = "NotNull" | "Min" | "Max" | "Pattern" | "NotBlank" | "Email";
2
+ //# sourceMappingURL=validation-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation-type.d.ts","sourceRoot":"","sources":["../../../../src/decorators/validation/types/validation-type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,KAAK,GACL,KAAK,GACL,SAAS,GACT,UAAU,GACV,OAAO,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./register-constraint";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/decorators/validation/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
@@ -60,3 +60,4 @@ export declare const registerConstraintWithProps: <T = void>(constraintId: strin
60
60
  */
61
61
  export declare const registerConstraintWithoutProps: (constraintId: string, constraintValidator: ConstraintWithoutProps) => AttributeDecorator;
62
62
  export declare const registerConstraint: (constraintId: string, constraintValidator: ConstraintWithoutProps) => AttributeDecorator;
63
+ //# sourceMappingURL=register-constraint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-constraint.d.ts","sourceRoot":"","sources":["../../../../src/decorators/validation/utils/register-constraint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,iBAAiB,CAAC;AAI1E,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CACnC,eAAe,EAAE,CAAC,KACf,CAAC,KAAK,EAAE,GAAG,GAAG,SAAS,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC;AAE7D,MAAM,MAAM,sBAAsB,GAAG,CACnC,KAAK,EAAE,GAAG,GAAG,SAAS,GAAG,IAAI,EAC7B,MAAM,EAAE,GAAG,KACR,OAAO,CAAC;AAEb;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,2BAA2B,GAAI,CAAC,uBAC7B,MAAM,uBACC,mBAAmB,CAAC,CAAC,CAAC,KAC1C,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,kBAAkB,CAiDnC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,8BAA8B,iBAC3B,MAAM,uBACC,sBAAsB,KAC1C,kBAEF,CAAC;AAEF,eAAO,MAAM,kBAAkB,iBANf,MAAM,uBACC,sBAAsB,KAC1C,kBAI6D,CAAC"}