@decaf-ts/decorator-validation 1.6.2 → 1.6.4

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 (167) hide show
  1. package/dist/decorator-validation.cjs +1016 -1164
  2. package/dist/decorator-validation.esm.cjs +971 -1134
  3. package/lib/constants/index.cjs +18 -0
  4. package/lib/constants/index.d.ts +1 -0
  5. package/lib/constants/validation.cjs +14 -0
  6. package/lib/constants/validation.d.ts +10 -0
  7. package/lib/esm/constants/index.d.ts +1 -0
  8. package/lib/esm/constants/index.js +2 -0
  9. package/lib/esm/constants/validation.d.ts +10 -0
  10. package/lib/esm/constants/validation.js +11 -0
  11. package/lib/esm/index.d.ts +37 -5
  12. package/lib/esm/index.js +38 -6
  13. package/lib/esm/model/Model.d.ts +29 -100
  14. package/lib/esm/model/Model.js +37 -104
  15. package/lib/esm/model/constants.d.ts +3 -3
  16. package/lib/esm/model/constants.js +4 -4
  17. package/lib/esm/model/construction.d.ts +3 -3
  18. package/lib/esm/model/construction.js +4 -4
  19. package/lib/esm/model/decorators.d.ts +4 -4
  20. package/lib/esm/model/decorators.js +5 -6
  21. package/lib/esm/model/types.d.ts +11 -30
  22. package/lib/esm/model/types.js +1 -1
  23. package/lib/esm/model/validation.d.ts +2 -2
  24. package/lib/esm/model/validation.js +18 -7
  25. package/lib/esm/utils/constants.d.ts +9 -27
  26. package/lib/esm/utils/constants.js +10 -28
  27. package/lib/esm/utils/dates.d.ts +16 -26
  28. package/lib/esm/utils/dates.js +17 -27
  29. package/lib/esm/utils/decorators.d.ts +0 -41
  30. package/lib/esm/utils/decorators.js +1 -42
  31. package/lib/esm/utils/hashing.d.ts +6 -50
  32. package/lib/esm/utils/hashing.js +5 -49
  33. package/lib/esm/utils/index.d.ts +0 -1
  34. package/lib/esm/utils/index.js +1 -2
  35. package/lib/esm/utils/registry.d.ts +2 -2
  36. package/lib/esm/utils/registry.js +1 -1
  37. package/lib/esm/utils/serialization.d.ts +1 -1
  38. package/lib/esm/utils/serialization.js +2 -2
  39. package/lib/esm/utils/strings.d.ts +4 -4
  40. package/lib/esm/utils/strings.js +5 -5
  41. package/lib/esm/utils/types.d.ts +16 -123
  42. package/lib/esm/utils/types.js +1 -1
  43. package/lib/esm/validation/Validators/DateValidator.d.ts +8 -40
  44. package/lib/esm/validation/Validators/DateValidator.js +9 -41
  45. package/lib/esm/validation/Validators/DiffValidator.d.ts +27 -0
  46. package/lib/esm/validation/Validators/DiffValidator.js +58 -0
  47. package/lib/esm/validation/Validators/EmailValidator.d.ts +7 -39
  48. package/lib/esm/validation/Validators/EmailValidator.js +8 -40
  49. package/lib/esm/validation/Validators/EqualsValidator.d.ts +27 -0
  50. package/lib/esm/validation/Validators/EqualsValidator.js +63 -0
  51. package/lib/esm/validation/Validators/GreaterThanOrEqualValidator.d.ts +27 -0
  52. package/lib/esm/validation/Validators/GreaterThanOrEqualValidator.js +65 -0
  53. package/lib/esm/validation/Validators/GreaterThanValidator.d.ts +27 -0
  54. package/lib/esm/validation/Validators/GreaterThanValidator.js +62 -0
  55. package/lib/esm/validation/Validators/LessThanOrEqualValidator.d.ts +27 -0
  56. package/lib/esm/validation/Validators/LessThanOrEqualValidator.js +65 -0
  57. package/lib/esm/validation/Validators/LessThanValidator.d.ts +27 -0
  58. package/lib/esm/validation/Validators/LessThanValidator.js +62 -0
  59. package/lib/esm/validation/Validators/ListValidator.d.ts +6 -44
  60. package/lib/esm/validation/Validators/ListValidator.js +7 -45
  61. package/lib/esm/validation/Validators/MaxValidator.d.ts +6 -52
  62. package/lib/esm/validation/Validators/MaxValidator.js +7 -53
  63. package/lib/esm/validation/Validators/MinValidator.d.ts +6 -52
  64. package/lib/esm/validation/Validators/MinValidator.js +7 -53
  65. package/lib/esm/validation/Validators/PatternValidator.d.ts +9 -75
  66. package/lib/esm/validation/Validators/PatternValidator.js +10 -76
  67. package/lib/esm/validation/Validators/RequiredValidator.d.ts +6 -52
  68. package/lib/esm/validation/Validators/RequiredValidator.js +7 -53
  69. package/lib/esm/validation/Validators/TypeValidator.d.ts +6 -60
  70. package/lib/esm/validation/Validators/TypeValidator.js +7 -69
  71. package/lib/esm/validation/Validators/URLValidator.d.ts +7 -41
  72. package/lib/esm/validation/Validators/URLValidator.js +8 -42
  73. package/lib/esm/validation/Validators/Validator.d.ts +17 -77
  74. package/lib/esm/validation/Validators/Validator.js +11 -68
  75. package/lib/esm/validation/Validators/ValidatorRegistry.d.ts +7 -1
  76. package/lib/esm/validation/Validators/ValidatorRegistry.js +11 -4
  77. package/lib/esm/validation/Validators/constants.d.ts +41 -0
  78. package/lib/esm/validation/Validators/constants.js +43 -1
  79. package/lib/esm/validation/Validators/index.d.ts +7 -0
  80. package/lib/esm/validation/Validators/index.js +8 -1
  81. package/lib/esm/validation/Validators/utils.d.ts +52 -0
  82. package/lib/esm/validation/Validators/utils.js +174 -0
  83. package/lib/esm/validation/decorators.d.ts +124 -50
  84. package/lib/esm/validation/decorators.js +173 -102
  85. package/lib/esm/validation/types.d.ts +31 -146
  86. package/lib/esm/validation/types.js +1 -1
  87. package/lib/index.cjs +39 -7
  88. package/lib/index.d.ts +37 -5
  89. package/lib/model/Model.cjs +39 -104
  90. package/lib/model/Model.d.ts +29 -100
  91. package/lib/model/constants.cjs +4 -4
  92. package/lib/model/constants.d.ts +3 -3
  93. package/lib/model/construction.cjs +4 -4
  94. package/lib/model/construction.d.ts +3 -3
  95. package/lib/model/decorators.cjs +5 -6
  96. package/lib/model/decorators.d.ts +4 -4
  97. package/lib/model/types.cjs +1 -1
  98. package/lib/model/types.d.ts +11 -30
  99. package/lib/model/validation.cjs +25 -14
  100. package/lib/model/validation.d.ts +2 -2
  101. package/lib/utils/constants.cjs +11 -29
  102. package/lib/utils/constants.d.ts +9 -27
  103. package/lib/utils/dates.cjs +17 -27
  104. package/lib/utils/dates.d.ts +16 -26
  105. package/lib/utils/decorators.cjs +1 -42
  106. package/lib/utils/decorators.d.ts +0 -41
  107. package/lib/utils/hashing.cjs +5 -49
  108. package/lib/utils/hashing.d.ts +6 -50
  109. package/lib/utils/index.cjs +1 -2
  110. package/lib/utils/index.d.ts +0 -1
  111. package/lib/utils/registry.cjs +1 -1
  112. package/lib/utils/registry.d.ts +2 -2
  113. package/lib/utils/serialization.cjs +2 -2
  114. package/lib/utils/serialization.d.ts +1 -1
  115. package/lib/utils/strings.cjs +5 -5
  116. package/lib/utils/strings.d.ts +4 -4
  117. package/lib/utils/types.cjs +1 -1
  118. package/lib/utils/types.d.ts +16 -123
  119. package/lib/validation/Validators/DateValidator.cjs +9 -41
  120. package/lib/validation/Validators/DateValidator.d.ts +8 -40
  121. package/lib/validation/Validators/DiffValidator.cjs +61 -0
  122. package/lib/validation/Validators/DiffValidator.d.ts +27 -0
  123. package/lib/validation/Validators/EmailValidator.cjs +8 -40
  124. package/lib/validation/Validators/EmailValidator.d.ts +7 -39
  125. package/lib/validation/Validators/EqualsValidator.cjs +66 -0
  126. package/lib/validation/Validators/EqualsValidator.d.ts +27 -0
  127. package/lib/validation/Validators/GreaterThanOrEqualValidator.cjs +68 -0
  128. package/lib/validation/Validators/GreaterThanOrEqualValidator.d.ts +27 -0
  129. package/lib/validation/Validators/GreaterThanValidator.cjs +65 -0
  130. package/lib/validation/Validators/GreaterThanValidator.d.ts +27 -0
  131. package/lib/validation/Validators/LessThanOrEqualValidator.cjs +68 -0
  132. package/lib/validation/Validators/LessThanOrEqualValidator.d.ts +27 -0
  133. package/lib/validation/Validators/LessThanValidator.cjs +65 -0
  134. package/lib/validation/Validators/LessThanValidator.d.ts +27 -0
  135. package/lib/validation/Validators/ListValidator.cjs +7 -45
  136. package/lib/validation/Validators/ListValidator.d.ts +6 -44
  137. package/lib/validation/Validators/MaxValidator.cjs +7 -53
  138. package/lib/validation/Validators/MaxValidator.d.ts +6 -52
  139. package/lib/validation/Validators/MinValidator.cjs +7 -53
  140. package/lib/validation/Validators/MinValidator.d.ts +6 -52
  141. package/lib/validation/Validators/PatternValidator.cjs +10 -76
  142. package/lib/validation/Validators/PatternValidator.d.ts +9 -75
  143. package/lib/validation/Validators/RequiredValidator.cjs +7 -53
  144. package/lib/validation/Validators/RequiredValidator.d.ts +6 -52
  145. package/lib/validation/Validators/TypeValidator.cjs +7 -69
  146. package/lib/validation/Validators/TypeValidator.d.ts +6 -60
  147. package/lib/validation/Validators/URLValidator.cjs +8 -42
  148. package/lib/validation/Validators/URLValidator.d.ts +7 -41
  149. package/lib/validation/Validators/Validator.cjs +11 -68
  150. package/lib/validation/Validators/Validator.d.ts +17 -77
  151. package/lib/validation/Validators/ValidatorRegistry.cjs +12 -4
  152. package/lib/validation/Validators/ValidatorRegistry.d.ts +7 -1
  153. package/lib/validation/Validators/constants.cjs +44 -2
  154. package/lib/validation/Validators/constants.d.ts +41 -0
  155. package/lib/validation/Validators/index.cjs +8 -1
  156. package/lib/validation/Validators/index.d.ts +7 -0
  157. package/lib/validation/Validators/utils.cjs +180 -0
  158. package/lib/validation/Validators/utils.d.ts +52 -0
  159. package/lib/validation/decorators.cjs +179 -102
  160. package/lib/validation/decorators.d.ts +124 -50
  161. package/lib/validation/types.cjs +1 -1
  162. package/lib/validation/types.d.ts +31 -146
  163. package/package.json +1 -1
  164. package/lib/esm/utils/Decoration.d.ts +0 -123
  165. package/lib/esm/utils/Decoration.js +0 -188
  166. package/lib/utils/Decoration.cjs +0 -192
  167. package/lib/utils/Decoration.d.ts +0 -123
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./validation.cjs"), exports);
18
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29uc3RhbnRzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSwrQ0FBNkIiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgKiBmcm9tIFwiLi92YWxpZGF0aW9uXCI7XG4iXX0=
@@ -0,0 +1 @@
1
+ export * from "./validation";
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VALIDATION_PARENT_KEY = void 0;
4
+ /**
5
+ * Symbol used to internally track the parent object during nested validation.
6
+ *
7
+ * This key is attached to child objects to provide context about their parent
8
+ * in the object hierarchy, enabling validations that depend on parent values.
9
+ *
10
+ * @constant VALIDATION_PARENT_KEY
11
+ * @memberOf module:decorator-validation.Model
12
+ */
13
+ exports.VALIDATION_PARENT_KEY = Symbol("_validationParentRef");
14
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb25zdGFudHMvdmFsaWRhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQTs7Ozs7Ozs7R0FRRztBQUNVLFFBQUEscUJBQXFCLEdBQUcsTUFBTSxDQUFDLHNCQUFzQixDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIFN5bWJvbCB1c2VkIHRvIGludGVybmFsbHkgdHJhY2sgdGhlIHBhcmVudCBvYmplY3QgZHVyaW5nIG5lc3RlZCB2YWxpZGF0aW9uLlxuICpcbiAqIFRoaXMga2V5IGlzIGF0dGFjaGVkIHRvIGNoaWxkIG9iamVjdHMgdG8gcHJvdmlkZSBjb250ZXh0IGFib3V0IHRoZWlyIHBhcmVudFxuICogaW4gdGhlIG9iamVjdCBoaWVyYXJjaHksIGVuYWJsaW5nIHZhbGlkYXRpb25zIHRoYXQgZGVwZW5kIG9uIHBhcmVudCB2YWx1ZXMuXG4gKlxuICogQGNvbnN0YW50IFZBTElEQVRJT05fUEFSRU5UX0tFWVxuICogQG1lbWJlck9mIG1vZHVsZTpkZWNvcmF0b3ItdmFsaWRhdGlvbi5Nb2RlbFxuICovXG5leHBvcnQgY29uc3QgVkFMSURBVElPTl9QQVJFTlRfS0VZID0gU3ltYm9sKFwiX3ZhbGlkYXRpb25QYXJlbnRSZWZcIik7XG4iXX0=
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Symbol used to internally track the parent object during nested validation.
3
+ *
4
+ * This key is attached to child objects to provide context about their parent
5
+ * in the object hierarchy, enabling validations that depend on parent values.
6
+ *
7
+ * @constant VALIDATION_PARENT_KEY
8
+ * @memberOf module:decorator-validation.Model
9
+ */
10
+ export declare const VALIDATION_PARENT_KEY: unique symbol;
@@ -0,0 +1 @@
1
+ export * from "./validation";
@@ -0,0 +1,2 @@
1
+ export * from "./validation";
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY29uc3RhbnRzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsY0FBYyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSBcIi4vdmFsaWRhdGlvblwiO1xuIl19
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Symbol used to internally track the parent object during nested validation.
3
+ *
4
+ * This key is attached to child objects to provide context about their parent
5
+ * in the object hierarchy, enabling validations that depend on parent values.
6
+ *
7
+ * @constant VALIDATION_PARENT_KEY
8
+ * @memberOf module:decorator-validation.Model
9
+ */
10
+ export declare const VALIDATION_PARENT_KEY: unique symbol;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Symbol used to internally track the parent object during nested validation.
3
+ *
4
+ * This key is attached to child objects to provide context about their parent
5
+ * in the object hierarchy, enabling validations that depend on parent values.
6
+ *
7
+ * @constant VALIDATION_PARENT_KEY
8
+ * @memberOf module:decorator-validation.Model
9
+ */
10
+ export const VALIDATION_PARENT_KEY = Symbol("_validationParentRef");
11
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jb25zdGFudHMvdmFsaWRhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7Ozs7R0FRRztBQUNILE1BQU0sQ0FBQyxNQUFNLHFCQUFxQixHQUFHLE1BQU0sQ0FBQyxzQkFBc0IsQ0FBQyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBTeW1ib2wgdXNlZCB0byBpbnRlcm5hbGx5IHRyYWNrIHRoZSBwYXJlbnQgb2JqZWN0IGR1cmluZyBuZXN0ZWQgdmFsaWRhdGlvbi5cbiAqXG4gKiBUaGlzIGtleSBpcyBhdHRhY2hlZCB0byBjaGlsZCBvYmplY3RzIHRvIHByb3ZpZGUgY29udGV4dCBhYm91dCB0aGVpciBwYXJlbnRcbiAqIGluIHRoZSBvYmplY3QgaGllcmFyY2h5LCBlbmFibGluZyB2YWxpZGF0aW9ucyB0aGF0IGRlcGVuZCBvbiBwYXJlbnQgdmFsdWVzLlxuICpcbiAqIEBjb25zdGFudCBWQUxJREFUSU9OX1BBUkVOVF9LRVlcbiAqIEBtZW1iZXJPZiBtb2R1bGU6ZGVjb3JhdG9yLXZhbGlkYXRpb24uTW9kZWxcbiAqL1xuZXhwb3J0IGNvbnN0IFZBTElEQVRJT05fUEFSRU5UX0tFWSA9IFN5bWJvbChcIl92YWxpZGF0aW9uUGFyZW50UmVmXCIpO1xuIl19
@@ -1,11 +1,43 @@
1
1
  /**
2
2
  * @module decorator-validation
3
- * @description TypeScript decorator-based validation library
4
- * @summary This module provides a comprehensive validation framework using TypeScript decorators.
5
- * It exposes utility functions, validation decorators, and model-related functionality for
6
- * implementing type-safe, declarative validation in TypeScript applications.
7
3
  */
4
+ /**
5
+ * @summary Model definition functionality
6
+ * @description defines the base class and related functionality
7
+ *
8
+ * @namespace Model
9
+ * @memberOf module:decorator-validation
10
+ */
11
+ /**
12
+ * @summary Holds all the supported decorators
13
+ * @namespace Decorators
14
+ * @memberOf module:decorator-validation
15
+ */
16
+ /**
17
+ * @summary Validation related functionality
18
+ * @description Defines the Model validation apis and base classes for validators
19
+ *
20
+ * @namespace Validation
21
+ * @memberOf module:decorator-validation
22
+ */
23
+ /**
24
+ * @namespace Dates
25
+ * @memberOf module:decorator-validation
26
+ */
27
+ /**
28
+ * @namespace Hashing
29
+ * @memberOf module:decorator-validation
30
+ */
31
+ /**
32
+ * @namespace Serialization
33
+ * @memberOf module:decorator-validation
34
+ */
35
+ /**
36
+ * @namespace Format
37
+ * @memberOf module:decorator-validation
38
+ */
39
+ export * from "./constants";
8
40
  export * from "./utils";
9
41
  export * from "./validation";
10
42
  export * from "./model";
11
- export declare const VERSION = "1.6.2";
43
+ export declare const VERSION = "1.6.4";
package/lib/esm/index.js CHANGED
@@ -1,12 +1,44 @@
1
1
  /**
2
2
  * @module decorator-validation
3
- * @description TypeScript decorator-based validation library
4
- * @summary This module provides a comprehensive validation framework using TypeScript decorators.
5
- * It exposes utility functions, validation decorators, and model-related functionality for
6
- * implementing type-safe, declarative validation in TypeScript applications.
7
3
  */
4
+ /**
5
+ * @summary Model definition functionality
6
+ * @description defines the base class and related functionality
7
+ *
8
+ * @namespace Model
9
+ * @memberOf module:decorator-validation
10
+ */
11
+ /**
12
+ * @summary Holds all the supported decorators
13
+ * @namespace Decorators
14
+ * @memberOf module:decorator-validation
15
+ */
16
+ /**
17
+ * @summary Validation related functionality
18
+ * @description Defines the Model validation apis and base classes for validators
19
+ *
20
+ * @namespace Validation
21
+ * @memberOf module:decorator-validation
22
+ */
23
+ /**
24
+ * @namespace Dates
25
+ * @memberOf module:decorator-validation
26
+ */
27
+ /**
28
+ * @namespace Hashing
29
+ * @memberOf module:decorator-validation
30
+ */
31
+ /**
32
+ * @namespace Serialization
33
+ * @memberOf module:decorator-validation
34
+ */
35
+ /**
36
+ * @namespace Format
37
+ * @memberOf module:decorator-validation
38
+ */
39
+ export * from "./constants";
8
40
  export * from "./utils";
9
41
  export * from "./validation";
10
42
  export * from "./model";
11
- export const VERSION = "1.6.2";
12
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBQ0gsY0FBYyxTQUFTLENBQUM7QUFDeEIsY0FBYyxjQUFjLENBQUM7QUFDN0IsY0FBYyxTQUFTLENBQUM7QUFFeEIsTUFBTSxDQUFDLE1BQU0sT0FBTyxHQUFHLGFBQWEsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogQG1vZHVsZSBkZWNvcmF0b3ItdmFsaWRhdGlvblxuICogQGRlc2NyaXB0aW9uIFR5cGVTY3JpcHQgZGVjb3JhdG9yLWJhc2VkIHZhbGlkYXRpb24gbGlicmFyeVxuICogQHN1bW1hcnkgVGhpcyBtb2R1bGUgcHJvdmlkZXM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XRcbiAqIEBtZW1iZXJPZiBtb2R1bGU6ZGVjb3JhdG9yLXZhbGlkYXRpb25cbiAqL1xuXG5leHBvcnQgKiBmcm9tIFwiLi9jb25zdGFudHNcIjtcbmV4cG9ydCAqIGZyb20gXCIuL3V0aWxzXCI7XG5leHBvcnQgKiBmcm9tIFwiLi92YWxpZGF0aW9uXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9tb2RlbFwiO1xuXG5leHBvcnQgY29uc3QgVkVSU0lPTiA9IFwiIyNWRVJTSU9OIyNcIjtcbiJdfQ==
@@ -1,94 +1,58 @@
1
1
  import { BuilderRegistry } from "../utils/registry";
2
2
  import { ModelErrorDefinition } from "./ModelErrorDefinition";
3
3
  import { Comparable, Constructor, Hashable, ModelArg, ModelBuilderFunction, ModelConstructor, Serializable, Validatable } from "./types";
4
+ export declare function isPropertyModel<M extends Model>(target: M, attribute: string): boolean | string | undefined;
4
5
  /**
5
- * @description Registry type for storing and retrieving model constructors
6
- * @summary The ModelRegistry type defines a registry for model constructors that extends
7
- * the BuilderRegistry interface. It provides a standardized way to register, retrieve,
8
- * and build model instances, enabling the model system to work with different types of models.
6
+ * @summary For Serialization/deserialization purposes.
7
+ * @description Reads the {@link ModelKeys.ANCHOR} property of a {@link Model} to discover the class to instantiate
8
+ *
9
+ * @function isModel
10
+ * @memberOf module:decorator-validation.Validation
11
+ * @category Validation
12
+ */
13
+ export declare function isModel(target: Record<string, any>): boolean;
14
+ /**
15
+ * @summary ModelRegistry Interface
9
16
  *
10
17
  * @interface ModelRegistry
11
- * @template T Type of model that can be registered, must extend Model
12
- * @extends BuilderRegistry<T>
13
- * @memberOf module:decorator-validation
18
+ * @extends BuilderRegistry<Model>
19
+ *
14
20
  * @category Model
15
21
  */
16
22
  export type ModelRegistry<T extends Model> = BuilderRegistry<T>;
17
23
  /**
18
- * @description Registry manager for model constructors that enables serialization and rebuilding
19
- * @summary The ModelRegistryManager implements the ModelRegistry interface and provides
20
- * functionality for registering, retrieving, and building model instances. It maintains
21
- * a cache of model constructors indexed by name, allowing for efficient lookup and instantiation.
22
- * This class is essential for the serialization and deserialization of model objects.
24
+ * @summary Util class to enable serialization and correct rebuilding
23
25
  *
24
- * @param {function(Record<string, any>): boolean} [testFunction] - Function to test if an object is a model, defaults to {@link isModel}
26
+ * @param {string} anchorKey defaults to {@link ModelKeys.ANCHOR}. The property name where the registered class name is stored;
27
+ * @param {function(Record<string, any>): boolean} [testFunction] method to test if the provided object is a Model Object. defaults to {@link isModel}
25
28
  *
26
29
  * @class ModelRegistryManager
27
- * @template M Type of model that can be registered, must extend Model
28
- * @implements ModelRegistry<M>
29
- * @category Model
30
- *
31
- * @example
32
- * ```typescript
33
- * // Create a model registry
34
- * const registry = new ModelRegistryManager();
35
- *
36
- * // Register a model class
37
- * registry.register(User);
38
- *
39
- * // Retrieve a model constructor by name
40
- * const UserClass = registry.get("User");
30
+ * @implements ModelRegistry
41
31
  *
42
- * // Build a model instance from a plain object
43
- * const userData = { name: "John", age: 30 };
44
- * const user = registry.build(userData, "User");
45
- * ```
46
- *
47
- * @mermaid
48
- * sequenceDiagram
49
- * participant C as Client
50
- * participant R as ModelRegistryManager
51
- * participant M as Model Class
52
- *
53
- * C->>R: new ModelRegistryManager(testFunction)
54
- * C->>R: register(ModelClass)
55
- * R->>R: Store in cache
56
- * C->>R: get("ModelName")
57
- * R-->>C: ModelClass constructor
58
- * C->>R: build(data, "ModelName")
59
- * R->>R: Get constructor from cache
60
- * R->>M: new ModelClass(data)
61
- * M-->>R: Model instance
62
- * R-->>C: Model instance
32
+ * @category Model
63
33
  */
64
- export declare class ModelRegistryManager<M extends Model> implements ModelRegistry<M> {
34
+ export declare class ModelRegistryManager<T extends Model> implements ModelRegistry<T> {
65
35
  private cache;
66
36
  private readonly testFunction;
67
37
  constructor(testFunction?: (obj: Record<string, any>) => boolean);
68
38
  /**
69
- * @description Registers a model constructor with the registry
70
- * @summary Adds a model constructor to the registry cache, making it available for
71
- * later retrieval and instantiation. If no name is provided, the constructor's name
72
- * property is used as the key in the registry.
73
- *
74
- * @param {ModelConstructor<M>} constructor - The model constructor to register
75
- * @param {string} [name] - Optional name to register the constructor under, defaults to constructor.name
76
- * @return {void}
77
- * @throws {Error} If the constructor is not a function
39
+ * @summary register new Models
40
+ * @param {any} constructor
41
+ * @param {string} [name] when not defined, the name of the constructor will be used
78
42
  */
79
- register(constructor: ModelConstructor<M>, name?: string): void;
43
+ register(constructor: ModelConstructor<T>, name?: string): void;
80
44
  /**
81
45
  * @summary Gets a registered Model {@link ModelConstructor}
82
46
  * @param {string} name
83
47
  */
84
- get(name: string): ModelConstructor<M> | undefined;
48
+ get(name: string): ModelConstructor<T> | undefined;
85
49
  /**
86
50
  * @param {Record<string, any>} obj
87
51
  * @param {string} [clazz] when provided, it will attempt to find the matching constructor
88
52
  *
89
53
  * @throws Error If clazz is not found, or obj is not a {@link Model} meaning it has no {@link ModelKeys.ANCHOR} property
90
54
  */
91
- build(obj?: Record<string, any>, clazz?: string): M;
55
+ build(obj?: Record<string, any>, clazz?: string): T;
92
56
  }
93
57
  /**
94
58
  * @summary Bulk Registers Models
@@ -96,12 +60,12 @@ export declare class ModelRegistryManager<M extends Model> implements ModelRegis
96
60
  *
97
61
  * @param {Array<Constructor<T>> | Array<{name: string, constructor: Constructor<T>}>} [models]
98
62
  *
99
- * @memberOf module:decorator-validation
63
+ * @memberOf module:decorator-validation.Model
100
64
  * @category Model
101
65
  */
102
- export declare function bulkModelRegister<M extends Model>(...models: (Constructor<M> | {
66
+ export declare function bulkModelRegister<T extends Model>(...models: (Constructor<T> | {
103
67
  name: string;
104
- constructor: Constructor<M>;
68
+ constructor: Constructor<T>;
105
69
  })[]): void;
106
70
  /**
107
71
  * @summary Abstract class representing a Validatable Model object
@@ -111,10 +75,9 @@ export declare function bulkModelRegister<M extends Model>(...models: (Construct
111
75
  * - Have all their required properties marked with '!';
112
76
  * - Have all their optional properties marked as '?':
113
77
  *
114
- * @param {ModelArg<Model>} model base object from which to populate properties from
78
+ * @param {Model | {}} model base object from which to populate properties from
115
79
  *
116
80
  * @class Model
117
- * @category Model
118
81
  * @abstract
119
82
  * @implements Validatable
120
83
  * @implements Serializable
@@ -238,38 +201,4 @@ export declare abstract class Model implements Validatable, Serializable, Hashab
238
201
  * @param {string} str
239
202
  */
240
203
  static key(str: string): string;
241
- /**
242
- * @description Determines if an object is a model instance or has model metadata
243
- * @summary Checks whether a given object is either an instance of the Model class or
244
- * has model metadata attached to it. This function is essential for serialization and
245
- * deserialization processes, as it helps identify model objects that need special handling.
246
- * It safely handles potential errors during metadata retrieval.
247
- *
248
- * @param {Record<string, any>} target - The object to check
249
- * @return {boolean} True if the object is a model instance or has model metadata, false otherwise
250
- *
251
- * @example
252
- * ```typescript
253
- * // Check if an object is a model
254
- * const user = new User({ name: "John" });
255
- * const isUserModel = isModel(user); // true
256
- *
257
- * // Check a plain object
258
- * const plainObject = { name: "John" };
259
- * const isPlainObjectModel = isModel(plainObject); // false
260
- * ```
261
- */
262
- static isModel(target: Record<string, any>): boolean;
263
- /**
264
- * @description Checks if a property of a model is itself a model or has a model type
265
- * @summary Determines whether a specific property of a model instance is either a model instance
266
- * or has a type that is registered as a model. This function is used for model serialization
267
- * and deserialization to properly handle nested models.
268
- * @template M extends {@link Model}
269
- * @param {M} target - The model instance to check
270
- * @param {string} attribute - The property name to check
271
- * @return {boolean | string | undefined} Returns true if the property is a model instance,
272
- * the model name if the property has a model type, or undefined if not a model
273
- */
274
- static isPropertyModel<M extends Model>(target: M, attribute: string): boolean | string | undefined;
275
204
  }