@decaf-ts/core 0.5.1 → 0.5.3

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 (206) hide show
  1. package/LICENSE.md +21 -157
  2. package/README.md +652 -15
  3. package/dist/core.cjs +2111 -133
  4. package/dist/core.esm.cjs +2112 -134
  5. package/lib/esm/identity/decorators.d.ts +52 -7
  6. package/lib/esm/identity/decorators.js +58 -13
  7. package/lib/esm/identity/index.js +3 -3
  8. package/lib/esm/identity/utils.d.ts +19 -0
  9. package/lib/esm/identity/utils.js +22 -3
  10. package/lib/esm/index.d.ts +10 -3
  11. package/lib/esm/index.js +19 -12
  12. package/lib/esm/interfaces/ErrorParser.d.ts +12 -0
  13. package/lib/esm/interfaces/ErrorParser.js +1 -1
  14. package/lib/esm/interfaces/Executor.d.ts +13 -0
  15. package/lib/esm/interfaces/Executor.js +1 -1
  16. package/lib/esm/interfaces/Observable.d.ts +27 -0
  17. package/lib/esm/interfaces/Observable.js +1 -1
  18. package/lib/esm/interfaces/Observer.d.ts +12 -0
  19. package/lib/esm/interfaces/Observer.js +1 -1
  20. package/lib/esm/interfaces/Paginatable.d.ts +15 -0
  21. package/lib/esm/interfaces/Paginatable.js +1 -1
  22. package/lib/esm/interfaces/Queriable.d.ts +34 -9
  23. package/lib/esm/interfaces/Queriable.js +1 -1
  24. package/lib/esm/interfaces/RawExecutor.d.ts +14 -0
  25. package/lib/esm/interfaces/RawExecutor.js +1 -1
  26. package/lib/esm/interfaces/SequenceOptions.d.ts +52 -0
  27. package/lib/esm/interfaces/SequenceOptions.js +19 -1
  28. package/lib/esm/interfaces/index.js +8 -8
  29. package/lib/esm/model/BaseModel.d.ts +31 -0
  30. package/lib/esm/model/BaseModel.js +24 -1
  31. package/lib/esm/model/construction.d.ts +433 -0
  32. package/lib/esm/model/construction.js +444 -5
  33. package/lib/esm/model/decorators.d.ts +159 -29
  34. package/lib/esm/model/decorators.js +167 -37
  35. package/lib/esm/model/index.js +5 -5
  36. package/lib/esm/model/types.d.ts +9 -0
  37. package/lib/esm/model/types.js +1 -1
  38. package/lib/esm/persistence/Adapter.d.ts +358 -17
  39. package/lib/esm/persistence/Adapter.js +292 -24
  40. package/lib/esm/persistence/Dispatch.d.ts +114 -1
  41. package/lib/esm/persistence/Dispatch.js +104 -6
  42. package/lib/esm/persistence/ObserverHandler.d.ts +95 -0
  43. package/lib/esm/persistence/ObserverHandler.js +96 -1
  44. package/lib/esm/persistence/Sequence.d.ts +89 -0
  45. package/lib/esm/persistence/Sequence.js +71 -2
  46. package/lib/esm/persistence/constants.d.ts +22 -0
  47. package/lib/esm/persistence/constants.js +23 -1
  48. package/lib/esm/persistence/decorators.d.ts +10 -0
  49. package/lib/esm/persistence/decorators.js +13 -3
  50. package/lib/esm/persistence/errors.d.ts +23 -0
  51. package/lib/esm/persistence/errors.js +24 -1
  52. package/lib/esm/persistence/index.js +9 -9
  53. package/lib/esm/persistence/types.d.ts +18 -0
  54. package/lib/esm/persistence/types.js +1 -1
  55. package/lib/esm/query/Condition.d.ts +78 -31
  56. package/lib/esm/query/Condition.js +134 -55
  57. package/lib/esm/query/Paginator.d.ts +56 -0
  58. package/lib/esm/query/Paginator.js +58 -2
  59. package/lib/esm/query/Statement.d.ts +51 -0
  60. package/lib/esm/query/Statement.js +55 -4
  61. package/lib/esm/query/constants.d.ts +25 -0
  62. package/lib/esm/query/constants.js +26 -1
  63. package/lib/esm/query/errors.d.ts +14 -0
  64. package/lib/esm/query/errors.js +15 -1
  65. package/lib/esm/query/index.js +8 -8
  66. package/lib/esm/query/options.d.ts +21 -3
  67. package/lib/esm/query/options.js +1 -1
  68. package/lib/esm/query/selectors.d.ts +26 -0
  69. package/lib/esm/query/selectors.js +1 -1
  70. package/lib/esm/ram/RamAdapter.d.ts +311 -0
  71. package/lib/esm/ram/RamAdapter.js +319 -8
  72. package/lib/esm/ram/RamContext.d.ts +16 -1
  73. package/lib/esm/ram/RamContext.js +18 -3
  74. package/lib/esm/ram/RamPaginator.d.ts +43 -0
  75. package/lib/esm/ram/RamPaginator.js +55 -3
  76. package/lib/esm/ram/RamSequence.d.ts +61 -0
  77. package/lib/esm/ram/RamSequence.js +66 -5
  78. package/lib/esm/ram/RamStatement.d.ts +74 -0
  79. package/lib/esm/ram/RamStatement.js +78 -4
  80. package/lib/esm/ram/constants.d.ts +8 -0
  81. package/lib/esm/ram/constants.js +9 -1
  82. package/lib/esm/ram/handlers.d.ts +19 -0
  83. package/lib/esm/ram/handlers.js +21 -2
  84. package/lib/esm/ram/index.js +11 -11
  85. package/lib/esm/ram/model/RamSequence.d.ts +25 -0
  86. package/lib/esm/ram/model/RamSequence.js +21 -3
  87. package/lib/esm/ram/model/index.js +2 -2
  88. package/lib/esm/ram/types.d.ts +42 -0
  89. package/lib/esm/ram/types.js +1 -1
  90. package/lib/esm/repository/Repository.d.ts +363 -8
  91. package/lib/esm/repository/Repository.js +369 -24
  92. package/lib/esm/repository/constants.d.ts +25 -0
  93. package/lib/esm/repository/constants.js +26 -1
  94. package/lib/esm/repository/decorators.d.ts +27 -0
  95. package/lib/esm/repository/decorators.js +29 -2
  96. package/lib/esm/repository/errors.d.ts +12 -5
  97. package/lib/esm/repository/errors.js +13 -6
  98. package/lib/esm/repository/index.js +8 -8
  99. package/lib/esm/repository/injectables.d.ts +18 -0
  100. package/lib/esm/repository/injectables.js +23 -5
  101. package/lib/esm/repository/types.d.ts +15 -0
  102. package/lib/esm/repository/types.js +1 -1
  103. package/lib/esm/repository/utils.d.ts +11 -0
  104. package/lib/esm/repository/utils.js +15 -4
  105. package/lib/esm/utils/decorators.d.ts +8 -0
  106. package/lib/esm/utils/decorators.js +9 -1
  107. package/lib/esm/utils/errors.d.ts +46 -0
  108. package/lib/esm/utils/errors.js +47 -1
  109. package/lib/esm/utils/index.js +3 -3
  110. package/lib/identity/decorators.cjs +53 -8
  111. package/lib/identity/decorators.d.ts +52 -7
  112. package/lib/identity/utils.cjs +20 -1
  113. package/lib/identity/utils.d.ts +19 -0
  114. package/lib/index.cjs +11 -4
  115. package/lib/index.d.ts +10 -3
  116. package/lib/interfaces/ErrorParser.cjs +1 -1
  117. package/lib/interfaces/ErrorParser.d.ts +12 -0
  118. package/lib/interfaces/Executor.cjs +1 -1
  119. package/lib/interfaces/Executor.d.ts +13 -0
  120. package/lib/interfaces/Observable.cjs +1 -1
  121. package/lib/interfaces/Observable.d.ts +27 -0
  122. package/lib/interfaces/Observer.cjs +1 -1
  123. package/lib/interfaces/Observer.d.ts +12 -0
  124. package/lib/interfaces/Paginatable.cjs +1 -1
  125. package/lib/interfaces/Paginatable.d.ts +15 -0
  126. package/lib/interfaces/Queriable.cjs +1 -1
  127. package/lib/interfaces/Queriable.d.ts +34 -9
  128. package/lib/interfaces/RawExecutor.cjs +1 -1
  129. package/lib/interfaces/RawExecutor.d.ts +14 -0
  130. package/lib/interfaces/SequenceOptions.cjs +19 -1
  131. package/lib/interfaces/SequenceOptions.d.ts +52 -0
  132. package/lib/model/BaseModel.cjs +24 -1
  133. package/lib/model/BaseModel.d.ts +31 -0
  134. package/lib/model/construction.cjs +441 -2
  135. package/lib/model/construction.d.ts +433 -0
  136. package/lib/model/decorators.cjs +160 -30
  137. package/lib/model/decorators.d.ts +159 -29
  138. package/lib/model/types.cjs +1 -1
  139. package/lib/model/types.d.ts +9 -0
  140. package/lib/persistence/Adapter.cjs +287 -19
  141. package/lib/persistence/Adapter.d.ts +358 -17
  142. package/lib/persistence/Dispatch.cjs +102 -4
  143. package/lib/persistence/Dispatch.d.ts +114 -1
  144. package/lib/persistence/ObserverHandler.cjs +96 -1
  145. package/lib/persistence/ObserverHandler.d.ts +95 -0
  146. package/lib/persistence/Sequence.cjs +70 -1
  147. package/lib/persistence/Sequence.d.ts +89 -0
  148. package/lib/persistence/constants.cjs +23 -1
  149. package/lib/persistence/constants.d.ts +22 -0
  150. package/lib/persistence/decorators.cjs +11 -1
  151. package/lib/persistence/decorators.d.ts +10 -0
  152. package/lib/persistence/errors.cjs +24 -1
  153. package/lib/persistence/errors.d.ts +23 -0
  154. package/lib/persistence/types.cjs +1 -1
  155. package/lib/persistence/types.d.ts +18 -0
  156. package/lib/query/Condition.cjs +132 -53
  157. package/lib/query/Condition.d.ts +78 -31
  158. package/lib/query/Paginator.cjs +57 -1
  159. package/lib/query/Paginator.d.ts +56 -0
  160. package/lib/query/Statement.cjs +52 -1
  161. package/lib/query/Statement.d.ts +51 -0
  162. package/lib/query/constants.cjs +26 -1
  163. package/lib/query/constants.d.ts +25 -0
  164. package/lib/query/errors.cjs +15 -1
  165. package/lib/query/errors.d.ts +14 -0
  166. package/lib/query/options.cjs +1 -1
  167. package/lib/query/options.d.ts +21 -3
  168. package/lib/query/selectors.cjs +1 -1
  169. package/lib/query/selectors.d.ts +26 -0
  170. package/lib/ram/RamAdapter.cjs +312 -1
  171. package/lib/ram/RamAdapter.d.ts +311 -0
  172. package/lib/ram/RamContext.cjs +18 -3
  173. package/lib/ram/RamContext.d.ts +16 -1
  174. package/lib/ram/RamPaginator.cjs +54 -2
  175. package/lib/ram/RamPaginator.d.ts +43 -0
  176. package/lib/ram/RamSequence.cjs +63 -2
  177. package/lib/ram/RamSequence.d.ts +61 -0
  178. package/lib/ram/RamStatement.cjs +75 -1
  179. package/lib/ram/RamStatement.d.ts +74 -0
  180. package/lib/ram/constants.cjs +9 -1
  181. package/lib/ram/constants.d.ts +8 -0
  182. package/lib/ram/handlers.cjs +20 -1
  183. package/lib/ram/handlers.d.ts +19 -0
  184. package/lib/ram/model/RamSequence.cjs +19 -1
  185. package/lib/ram/model/RamSequence.d.ts +25 -0
  186. package/lib/ram/types.cjs +1 -1
  187. package/lib/ram/types.d.ts +42 -0
  188. package/lib/repository/Repository.cjs +360 -15
  189. package/lib/repository/Repository.d.ts +363 -8
  190. package/lib/repository/constants.cjs +26 -1
  191. package/lib/repository/constants.d.ts +25 -0
  192. package/lib/repository/decorators.cjs +28 -1
  193. package/lib/repository/decorators.d.ts +27 -0
  194. package/lib/repository/errors.cjs +13 -6
  195. package/lib/repository/errors.d.ts +12 -5
  196. package/lib/repository/injectables.cjs +19 -1
  197. package/lib/repository/injectables.d.ts +18 -0
  198. package/lib/repository/types.cjs +1 -1
  199. package/lib/repository/types.d.ts +15 -0
  200. package/lib/repository/utils.cjs +12 -1
  201. package/lib/repository/utils.d.ts +11 -0
  202. package/lib/utils/decorators.cjs +9 -1
  203. package/lib/utils/decorators.d.ts +8 -0
  204. package/lib/utils/errors.cjs +47 -1
  205. package/lib/utils/errors.d.ts +46 -0
  206. package/package.json +5 -5
@@ -1,12 +1,64 @@
1
+ /**
2
+ * @description Interface for sequence configuration options
3
+ * @summary Defines the configuration options for creating and managing sequences
4
+ * @interface SequenceOptions
5
+ * @memberOf module:core
6
+ */
1
7
  export interface SequenceOptions {
8
+ /**
9
+ * @description Optional name for the sequence
10
+ * @summary A unique identifier for the sequence
11
+ */
2
12
  name?: string;
13
+ /**
14
+ * @description The data type of the sequence
15
+ * @summary Specifies whether the sequence generates Number or BigInt values
16
+ */
3
17
  type: "Number" | "BigInt" | undefined;
18
+ /**
19
+ * @description The initial value of the sequence
20
+ * @summary The value that the sequence starts with
21
+ */
4
22
  startWith: number;
23
+ /**
24
+ * @description The increment value for each step in the sequence
25
+ * @summary The amount by which the sequence increases with each call
26
+ */
5
27
  incrementBy: number;
28
+ /**
29
+ * @description Optional minimum value for the sequence
30
+ * @summary The lowest value that the sequence can generate
31
+ */
6
32
  minValue?: number;
33
+ /**
34
+ * @description Optional maximum value for the sequence
35
+ * @summary The highest value that the sequence can generate
36
+ */
7
37
  maxValue?: number;
38
+ /**
39
+ * @description Whether the sequence should cycle when reaching its limits
40
+ * @summary If true, the sequence will restart from minValue when reaching maxValue
41
+ */
8
42
  cycle: boolean;
9
43
  }
44
+ /**
45
+ * @description Default options for sequences
46
+ * @summary Provides a standard configuration for number sequences starting at 0 and incrementing by 1
47
+ * @const DefaultSequenceOptions
48
+ * @memberOf module:core
49
+ */
10
50
  export declare const DefaultSequenceOptions: SequenceOptions;
51
+ /**
52
+ * @description Predefined options for numeric sequences
53
+ * @summary Configuration for standard number sequences starting at 0 and incrementing by 1
54
+ * @const NumericSequence
55
+ * @memberOf module:core
56
+ */
11
57
  export declare const NumericSequence: SequenceOptions;
58
+ /**
59
+ * @description Predefined options for BigInt sequences
60
+ * @summary Configuration for BigInt sequences starting at 0 and incrementing by 1
61
+ * @const BigIntSequence
62
+ * @memberOf module:core
63
+ */
12
64
  export declare const BigIntSequence: SequenceOptions;
@@ -1,19 +1,37 @@
1
+ /**
2
+ * @description Default options for sequences
3
+ * @summary Provides a standard configuration for number sequences starting at 0 and incrementing by 1
4
+ * @const DefaultSequenceOptions
5
+ * @memberOf module:core
6
+ */
1
7
  export const DefaultSequenceOptions = {
2
8
  type: "Number",
3
9
  startWith: 0,
4
10
  incrementBy: 1,
5
11
  cycle: false,
6
12
  };
13
+ /**
14
+ * @description Predefined options for numeric sequences
15
+ * @summary Configuration for standard number sequences starting at 0 and incrementing by 1
16
+ * @const NumericSequence
17
+ * @memberOf module:core
18
+ */
7
19
  export const NumericSequence = {
8
20
  type: "Number",
9
21
  startWith: 0,
10
22
  incrementBy: 1,
11
23
  cycle: false,
12
24
  };
25
+ /**
26
+ * @description Predefined options for BigInt sequences
27
+ * @summary Configuration for BigInt sequences starting at 0 and incrementing by 1
28
+ * @const BigIntSequence
29
+ * @memberOf module:core
30
+ */
13
31
  export const BigIntSequence = {
14
32
  type: "BigInt",
15
33
  startWith: 0,
16
34
  incrementBy: 1,
17
35
  cycle: false,
18
36
  };
19
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2VxdWVuY2VPcHRpb25zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2ludGVyZmFjZXMvU2VxdWVuY2VPcHRpb25zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQVVBLE1BQU0sQ0FBQyxNQUFNLHNCQU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JpZ0ludFwiLFxuICBzdGFydFdpdGg6IDAsXG4gIGluY3JlbWVudEJ5OiAxLFxuICBjeWNsZTogZmFsc2UsXG59O1xuIl19
@@ -1,8 +1,8 @@
1
- export * from "./ErrorParser";
2
- export * from "./Executor";
3
- export * from "./Observable";
4
- export * from "./Observer";
5
- export * from "./Queriable";
6
- export * from "./RawExecutor";
7
- export * from "./SequenceOptions";
8
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvaW50ZXJmYWNlcy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLGVBQWUsQ0FBQztBQUM5QixjQUFjLFlBQVksQ0FBQztBQUMzQixjQUFjLGNBQWMsQ0FBQztBQUM3QixjQUFjLFlBQVksQ0FBQztBQUMzQixjQUFjLGFBQWEsQ0FBQztBQUM1QixjQUFjLGVBQWUsQ0FBQztBQUM5QixjQUFjLG1CQUFtQixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSBcIi4vRXJyb3JQYXJzZXJcIjtcbmV4cG9ydCAqIGZyb20gXCIuL0V4ZWN1dG9yXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9PYnNlcnZhYmxlXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9PYnNlcnZlclwiO1xuZXhwb3J0ICogZnJvbSBcIi4vUXVlcmlhYmxlXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9SYXdFeGVjdXRvclwiO1xuZXhwb3J0ICogZnJvbSBcIi4vU2VxdWVuY2VPcHRpb25zXCI7XG4iXX0=
1
+ export * from "./ErrorParser.js";
2
+ export * from "./Executor.js";
3
+ export * from "./Observable.js";
4
+ export * from "./Observer.js";
5
+ export * from "./Queriable.js";
6
+ export * from "./RawExecutor.js";
7
+ export * from "./SequenceOptions.js";
8
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvaW50ZXJmYWNlcy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxpQ0FBOEI7QUFDOUIsOEJBQTJCO0FBQzNCLGdDQUE2QjtBQUM3Qiw4QkFBMkI7QUFDM0IsK0JBQTRCO0FBQzVCLGlDQUE4QjtBQUM5QixxQ0FBa0MiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgKiBmcm9tIFwiLi9FcnJvclBhcnNlclwiO1xuZXhwb3J0ICogZnJvbSBcIi4vRXhlY3V0b3JcIjtcbmV4cG9ydCAqIGZyb20gXCIuL09ic2VydmFibGVcIjtcbmV4cG9ydCAqIGZyb20gXCIuL09ic2VydmVyXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9RdWVyaWFibGVcIjtcbmV4cG9ydCAqIGZyb20gXCIuL1Jhd0V4ZWN1dG9yXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9TZXF1ZW5jZU9wdGlvbnNcIjtcbiJdfQ==
@@ -1,6 +1,37 @@
1
1
  import { ModelArg, Model } from "@decaf-ts/decorator-validation";
2
+ /**
3
+ * @description Base model class for all domain models
4
+ * @summary An abstract base class that extends the Model class from decorator-validation and adds timestamp functionality.
5
+ * All domain models in the application should extend this class to inherit common properties and behaviors.
6
+ * @param {ModelArg<BaseModel>} arg - Optional initialization data for the model
7
+ * @class BaseModel
8
+ * @example
9
+ * ```typescript
10
+ * class User extends BaseModel {
11
+ * @required()
12
+ * username!: string;
13
+ *
14
+ * @email()
15
+ * email!: string;
16
+ *
17
+ * constructor(data?: ModelArg<User>) {
18
+ * super(data);
19
+ * }
20
+ * }
21
+ *
22
+ * const user = new User({ username: 'john', email: 'john@example.com' });
23
+ * ```
24
+ */
2
25
  export declare abstract class BaseModel extends Model {
26
+ /**
27
+ * @description Creation timestamp for the model
28
+ * @summary Automatically set to the current date and time when the model is created
29
+ */
3
30
  createdOn: Date;
31
+ /**
32
+ * @description Last update timestamp for the model
33
+ * @summary Automatically updated to the current date and time whenever the model is modified
34
+ */
4
35
  updatedOn: Date;
5
36
  protected constructor(arg?: ModelArg<BaseModel>);
6
37
  }
@@ -9,6 +9,29 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  };
10
10
  import { DBOperations, timestamp } from "@decaf-ts/db-decorators";
11
11
  import { Model } from "@decaf-ts/decorator-validation";
12
+ /**
13
+ * @description Base model class for all domain models
14
+ * @summary An abstract base class that extends the Model class from decorator-validation and adds timestamp functionality.
15
+ * All domain models in the application should extend this class to inherit common properties and behaviors.
16
+ * @param {ModelArg<BaseModel>} arg - Optional initialization data for the model
17
+ * @class BaseModel
18
+ * @example
19
+ * ```typescript
20
+ * class User extends BaseModel {
21
+ * @required()
22
+ * username!: string;
23
+ *
24
+ * @email()
25
+ * email!: string;
26
+ *
27
+ * constructor(data?: ModelArg<User>) {
28
+ * super(data);
29
+ * }
30
+ * }
31
+ *
32
+ * const user = new User({ username: 'john', email: 'john@example.com' });
33
+ * ```
34
+ */
12
35
  export class BaseModel extends Model {
13
36
  constructor(arg) {
14
37
  super(arg);
@@ -22,4 +45,4 @@ __decorate([
22
45
  timestamp(),
23
46
  __metadata("design:type", Date)
24
47
  ], BaseModel.prototype, "updatedOn", void 0);
25
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQmFzZU1vZGVsLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL21vZGVsL0Jhc2VNb2RlbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7QUFBQSxPQUFPLEVBQUUsWUFBWSxFQUFFLFNBQVMsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQ2xFLE9BQU8sRUFBWSxLQU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maWVkXG4gICAqL1xuICBAdGltZXN0YW1wKClcbiAgdXBkYXRlZE9uITogRGF0ZTtcblxuICBwcm90ZWN0ZWQgY29uc3RydWN0b3IoYXJnPzogTW9kZWxBcmc8QmFzZU1vZGVsPikge1xuICAgIHN1cGVyKGFyZyk7XG4gIH1cbn1cbiJdfQ==
@@ -3,16 +3,449 @@ import { Repo } from "../repository/Repository";
3
3
  import { RelationsMetadata } from "./types";
4
4
  import { RepositoryFlags } from "@decaf-ts/db-decorators";
5
5
  import { Context } from "@decaf-ts/db-decorators";
6
+ /**
7
+ * @description Creates or updates a model instance
8
+ * @summary Determines whether to create a new model or update an existing one based on the presence of a primary key
9
+ * @template M - The model type extending Model
10
+ * @template F - The repository flags type
11
+ * @param {M} model - The model instance to create or update
12
+ * @param {Context<F>} context - The context for the operation
13
+ * @param {Repo<M, F, Context<F>>} [repository] - Optional repository to use for the operation
14
+ * @return {Promise<M>} A promise that resolves to the created or updated model
15
+ * @function createOrUpdate
16
+ * @memberOf module:core
17
+ * @mermaid
18
+ * sequenceDiagram
19
+ * participant Caller
20
+ * participant createOrUpdate
21
+ * participant Repository
22
+ * participant Model
23
+ *
24
+ * Caller->>createOrUpdate: model, context, repository?
25
+ * alt repository not provided
26
+ * createOrUpdate->>Model: get(model.constructor.name)
27
+ * Model-->>createOrUpdate: constructor
28
+ * createOrUpdate->>Repository: forModel(constructor)
29
+ * Repository-->>createOrUpdate: repository
30
+ * end
31
+ *
32
+ * alt primary key undefined
33
+ * createOrUpdate->>Repository: create(model, context)
34
+ * Repository-->>createOrUpdate: created model
35
+ * else primary key defined
36
+ * createOrUpdate->>Repository: update(model, context)
37
+ * alt update successful
38
+ * Repository-->>createOrUpdate: updated model
39
+ * else NotFoundError
40
+ * createOrUpdate->>Repository: create(model, context)
41
+ * Repository-->>createOrUpdate: created model
42
+ * end
43
+ * end
44
+ *
45
+ * createOrUpdate-->>Caller: model
46
+ */
6
47
  export declare function createOrUpdate<M extends Model, F extends RepositoryFlags>(model: M, context: Context<F>, repository?: Repo<M, F, Context<F>>): Promise<M>;
48
+ /**
49
+ * @description Handles one-to-one relationship creation
50
+ * @summary Processes a one-to-one relationship when creating a model, either by referencing an existing model or creating a new one
51
+ * @template M - The model type extending Model
52
+ * @template R - The repository type extending Repo<M, F, C>
53
+ * @template V - The relations metadata type extending RelationsMetadata
54
+ * @template F - The repository flags type
55
+ * @template C - The context type extending Context<F>
56
+ * @param {R} this - The repository instance
57
+ * @param {Context<F>} context - The context for the operation
58
+ * @param {V} data - The relations metadata
59
+ * @param {string} key - The property key of the relationship
60
+ * @param {M} model - The model instance
61
+ * @return {Promise<void>} A promise that resolves when the operation is complete
62
+ * @function oneToOneOnCreate
63
+ * @memberOf module:core
64
+ * @mermaid
65
+ * sequenceDiagram
66
+ * participant Caller
67
+ * participant oneToOneOnCreate
68
+ * participant repositoryFromTypeMetadata
69
+ * participant Model
70
+ * participant Repository
71
+ * participant cacheModelForPopulate
72
+ *
73
+ * Caller->>oneToOneOnCreate: this, context, data, key, model
74
+ * oneToOneOnCreate->>oneToOneOnCreate: check if propertyValue exists
75
+ *
76
+ * alt propertyValue is not an object
77
+ * oneToOneOnCreate->>repositoryFromTypeMetadata: model, key
78
+ * repositoryFromTypeMetadata-->>oneToOneOnCreate: innerRepo
79
+ * oneToOneOnCreate->>innerRepo: read(propertyValue)
80
+ * innerRepo-->>oneToOneOnCreate: read
81
+ * oneToOneOnCreate->>cacheModelForPopulate: context, model, key, propertyValue, read
82
+ * oneToOneOnCreate->>oneToOneOnCreate: set model[key] = propertyValue
83
+ * else propertyValue is an object
84
+ * oneToOneOnCreate->>Model: get(data.class)
85
+ * Model-->>oneToOneOnCreate: constructor
86
+ * oneToOneOnCreate->>Repository: forModel(constructor)
87
+ * Repository-->>oneToOneOnCreate: repo
88
+ * oneToOneOnCreate->>repo: create(propertyValue)
89
+ * repo-->>oneToOneOnCreate: created
90
+ * oneToOneOnCreate->>findPrimaryKey: created
91
+ * findPrimaryKey-->>oneToOneOnCreate: pk
92
+ * oneToOneOnCreate->>cacheModelForPopulate: context, model, key, created[pk], created
93
+ * oneToOneOnCreate->>oneToOneOnCreate: set model[key] = created[pk]
94
+ * end
95
+ *
96
+ * oneToOneOnCreate-->>Caller: void
97
+ */
7
98
  export declare function oneToOneOnCreate<M extends Model, R extends Repo<M, F, C>, V extends RelationsMetadata, F extends RepositoryFlags, C extends Context<F>>(this: R, context: Context<F>, data: V, key: keyof M, model: M): Promise<void>;
99
+ /**
100
+ * @description Handles one-to-one relationship updates
101
+ * @summary Processes a one-to-one relationship when updating a model, either by referencing an existing model or updating the related model
102
+ * @template M - The model type extending Model
103
+ * @template R - The repository type extending Repo<M, F, C>
104
+ * @template V - The relations metadata type extending RelationsMetadata
105
+ * @template F - The repository flags type
106
+ * @template C - The context type extending Context<F>
107
+ * @param {R} this - The repository instance
108
+ * @param {Context<F>} context - The context for the operation
109
+ * @param {V} data - The relations metadata
110
+ * @param key - The property key of the relationship
111
+ * @param {M} model - The model instance
112
+ * @return {Promise<void>} A promise that resolves when the operation is complete
113
+ * @function oneToOneOnUpdate
114
+ * @memberOf module:core
115
+ * @mermaid
116
+ * sequenceDiagram
117
+ * participant Caller
118
+ * participant oneToOneOnUpdate
119
+ * participant repositoryFromTypeMetadata
120
+ * participant createOrUpdate
121
+ * participant findPrimaryKey
122
+ * participant cacheModelForPopulate
123
+ *
124
+ * Caller->>oneToOneOnUpdate: this, context, data, key, model
125
+ * oneToOneOnUpdate->>oneToOneOnUpdate: check if propertyValue exists
126
+ * oneToOneOnUpdate->>oneToOneOnUpdate: check if cascade.update is CASCADE
127
+ *
128
+ * alt propertyValue is not an object
129
+ * oneToOneOnUpdate->>repositoryFromTypeMetadata: model, key
130
+ * repositoryFromTypeMetadata-->>oneToOneOnUpdate: innerRepo
131
+ * oneToOneOnUpdate->>innerRepo: read(propertyValue)
132
+ * innerRepo-->>oneToOneOnUpdate: read
133
+ * oneToOneOnUpdate->>cacheModelForPopulate: context, model, key, propertyValue, read
134
+ * oneToOneOnUpdate->>oneToOneOnUpdate: set model[key] = propertyValue
135
+ * else propertyValue is an object
136
+ * oneToOneOnUpdate->>createOrUpdate: model[key], context
137
+ * createOrUpdate-->>oneToOneOnUpdate: updated
138
+ * oneToOneOnUpdate->>findPrimaryKey: updated
139
+ * findPrimaryKey-->>oneToOneOnUpdate: pk
140
+ * oneToOneOnUpdate->>cacheModelForPopulate: context, model, key, updated[pk], updated
141
+ * oneToOneOnUpdate->>oneToOneOnUpdate: set model[key] = updated[pk]
142
+ * end
143
+ *
144
+ * oneToOneOnUpdate-->>Caller: void
145
+ */
8
146
  export declare function oneToOneOnUpdate<M extends Model, R extends Repo<M, F, C>, V extends RelationsMetadata, F extends RepositoryFlags, C extends Context<F>>(this: R, context: Context<F>, data: V, key: keyof M, model: M): Promise<void>;
147
+ /**
148
+ * @description Handles one-to-one relationship deletion
149
+ * @summary Processes a one-to-one relationship when deleting a model, deleting the related model if cascade is enabled
150
+ * @template M - The model type extending Model
151
+ * @template R - The repository type extending Repo<M, F, C>
152
+ * @template V - The relations metadata type extending RelationsMetadata
153
+ * @template F - The repository flags type
154
+ * @template C - The context type extending Context<F>
155
+ * @param {R} this - The repository instance
156
+ * @param {Context<F>} context - The context for the operation
157
+ * @param {V} data - The relations metadata
158
+ * @param key - The property key of the relationship
159
+ * @param {M} model - The model instance
160
+ * @return {Promise<void>} A promise that resolves when the operation is complete
161
+ * @function oneToOneOnDelete
162
+ * @memberOf module:core
163
+ * @mermaid
164
+ * sequenceDiagram
165
+ * participant Caller
166
+ * participant oneToOneOnDelete
167
+ * participant repositoryFromTypeMetadata
168
+ * participant cacheModelForPopulate
169
+ *
170
+ * Caller->>oneToOneOnDelete: this, context, data, key, model
171
+ * oneToOneOnDelete->>oneToOneOnDelete: check if propertyValue exists
172
+ * oneToOneOnDelete->>oneToOneOnDelete: check if cascade.update is CASCADE
173
+ *
174
+ * oneToOneOnDelete->>repositoryFromTypeMetadata: model, key
175
+ * repositoryFromTypeMetadata-->>oneToOneOnDelete: innerRepo
176
+ *
177
+ * alt propertyValue is not a Model instance
178
+ * oneToOneOnDelete->>innerRepo: delete(model[key], context)
179
+ * innerRepo-->>oneToOneOnDelete: deleted
180
+ * else propertyValue is a Model instance
181
+ * oneToOneOnDelete->>innerRepo: delete(model[key][innerRepo.pk], context)
182
+ * innerRepo-->>oneToOneOnDelete: deleted
183
+ * end
184
+ *
185
+ * oneToOneOnDelete->>cacheModelForPopulate: context, model, key, deleted[innerRepo.pk], deleted
186
+ * oneToOneOnDelete-->>Caller: void
187
+ */
9
188
  export declare function oneToOneOnDelete<M extends Model, R extends Repo<M, F, C>, V extends RelationsMetadata, F extends RepositoryFlags, C extends Context<F>>(this: R, context: Context<F>, data: V, key: keyof M, model: M): Promise<void>;
189
+ /**
190
+ * @description Handles one-to-many relationship creation
191
+ * @summary Processes a one-to-many relationship when creating a model, either by referencing existing models or creating new ones
192
+ * @template M - The model type extending Model
193
+ * @template R - The repository type extending Repo<M, F, C>
194
+ * @template V - The relations metadata type extending RelationsMetadata
195
+ * @template F - The repository flags type
196
+ * @template C - The context type extending Context<F>
197
+ * @param {R} this - The repository instance
198
+ * @param {Context<F>} context - The context for the operation
199
+ * @param {V} data - The relations metadata
200
+ * @param key - The property key of the relationship
201
+ * @param {M} model - The model instance
202
+ * @return {Promise<void>} A promise that resolves when the operation is complete
203
+ * @function oneToManyOnCreate
204
+ * @memberOf module:core
205
+ * @mermaid
206
+ * sequenceDiagram
207
+ * participant Caller
208
+ * participant oneToManyOnCreate
209
+ * participant repositoryFromTypeMetadata
210
+ * participant createOrUpdate
211
+ * participant findPrimaryKey
212
+ * participant cacheModelForPopulate
213
+ *
214
+ * Caller->>oneToManyOnCreate: this, context, data, key, model
215
+ * oneToManyOnCreate->>oneToManyOnCreate: check if propertyValues exists and has length
216
+ * oneToManyOnCreate->>oneToManyOnCreate: check if all elements have same type
217
+ * oneToManyOnCreate->>oneToManyOnCreate: create uniqueValues set
218
+ *
219
+ * alt arrayType is not "object"
220
+ * oneToManyOnCreate->>repositoryFromTypeMetadata: model, key
221
+ * repositoryFromTypeMetadata-->>oneToManyOnCreate: repo
222
+ * loop for each id in uniqueValues
223
+ * oneToManyOnCreate->>repo: read(id)
224
+ * repo-->>oneToManyOnCreate: read
225
+ * oneToManyOnCreate->>cacheModelForPopulate: context, model, key, id, read
226
+ * end
227
+ * oneToManyOnCreate->>oneToManyOnCreate: set model[key] = [...uniqueValues]
228
+ * else arrayType is "object"
229
+ * oneToManyOnCreate->>findPrimaryKey: propertyValues[0]
230
+ * findPrimaryKey-->>oneToManyOnCreate: pkName
231
+ * oneToManyOnCreate->>oneToManyOnCreate: create result set
232
+ * loop for each m in propertyValues
233
+ * oneToManyOnCreate->>createOrUpdate: m, context
234
+ * createOrUpdate-->>oneToManyOnCreate: record
235
+ * oneToManyOnCreate->>cacheModelForPopulate: context, model, key, record[pkName], record
236
+ * oneToManyOnCreate->>oneToManyOnCreate: add record[pkName] to result
237
+ * end
238
+ * oneToManyOnCreate->>oneToManyOnCreate: set model[key] = [...result]
239
+ * end
240
+ *
241
+ * oneToManyOnCreate-->>Caller: void
242
+ */
10
243
  export declare function oneToManyOnCreate<M extends Model, R extends Repo<M, F, C>, V extends RelationsMetadata, F extends RepositoryFlags, C extends Context<F>>(this: R, context: Context<F>, data: V, key: keyof M, model: M): Promise<void>;
244
+ /**
245
+ * @description Handles one-to-many relationship updates
246
+ * @summary Processes a one-to-many relationship when updating a model, delegating to oneToManyOnCreate if cascade update is enabled
247
+ * @template M - The model type extending Model
248
+ * @template R - The repository type extending Repo<M, F, C>
249
+ * @template V - The relations metadata type extending RelationsMetadata
250
+ * @template F - The repository flags type
251
+ * @template C - The context type extending Context<F>
252
+ * @param {R} this - The repository instance
253
+ * @param {Context<F>} context - The context for the operation
254
+ * @param {V} data - The relations metadata
255
+ * @param key - The property key of the relationship
256
+ * @param {M} model - The model instance
257
+ * @return {Promise<void>} A promise that resolves when the operation is complete
258
+ * @function oneToManyOnUpdate
259
+ * @memberOf module:core
260
+ * @mermaid
261
+ * sequenceDiagram
262
+ * participant Caller
263
+ * participant oneToManyOnUpdate
264
+ * participant oneToManyOnCreate
265
+ *
266
+ * Caller->>oneToManyOnUpdate: this, context, data, key, model
267
+ * oneToManyOnUpdate->>oneToManyOnUpdate: check if cascade.update is CASCADE
268
+ *
269
+ * alt cascade.update is CASCADE
270
+ * oneToManyOnUpdate->>oneToManyOnCreate: apply(this, [context, data, key, model])
271
+ * oneToManyOnCreate-->>oneToManyOnUpdate: void
272
+ * end
273
+ *
274
+ * oneToManyOnUpdate-->>Caller: void
275
+ */
11
276
  export declare function oneToManyOnUpdate<M extends Model, R extends Repo<M, F, C>, V extends RelationsMetadata, F extends RepositoryFlags, C extends Context<F>>(this: R, context: Context<F>, data: V, key: keyof M, model: M): Promise<void>;
277
+ /**
278
+ * @description Handles one-to-many relationship deletion
279
+ * @summary Processes a one-to-many relationship when deleting a model, deleting all related models if cascade delete is enabled
280
+ * @template M - The model type extending Model
281
+ * @template R - The repository type extending Repo<M, F, C>
282
+ * @template V - The relations metadata type extending RelationsMetadata
283
+ * @template F - The repository flags type
284
+ * @template C - The context type extending Context<F>
285
+ * @param {R} this - The repository instance
286
+ * @param {Context<F>} context - The context for the operation
287
+ * @param {V} data - The relations metadata
288
+ * @param key - The property key of the relationship
289
+ * @param {M} model - The model instance
290
+ * @return {Promise<void>} A promise that resolves when the operation is complete
291
+ * @function oneToManyOnDelete
292
+ * @memberOf module:core
293
+ * @mermaid
294
+ * sequenceDiagram
295
+ * participant Caller
296
+ * participant oneToManyOnDelete
297
+ * participant Repository
298
+ * participant repositoryFromTypeMetadata
299
+ * participant cacheModelForPopulate
300
+ *
301
+ * Caller->>oneToManyOnDelete: this, context, data, key, model
302
+ * oneToManyOnDelete->>oneToManyOnDelete: check if cascade.delete is CASCADE
303
+ * oneToManyOnDelete->>oneToManyOnDelete: check if values exists and has length
304
+ * oneToManyOnDelete->>oneToManyOnDelete: check if all elements have same type
305
+ *
306
+ * alt isInstantiated (arrayType is "object")
307
+ * oneToManyOnDelete->>Repository: forModel(values[0])
308
+ * Repository-->>oneToManyOnDelete: repo
309
+ * else not instantiated
310
+ * oneToManyOnDelete->>repositoryFromTypeMetadata: model, key
311
+ * repositoryFromTypeMetadata-->>oneToManyOnDelete: repo
312
+ * end
313
+ *
314
+ * oneToManyOnDelete->>oneToManyOnDelete: create uniqueValues set
315
+ *
316
+ * loop for each id in uniqueValues
317
+ * oneToManyOnDelete->>repo: delete(id, context)
318
+ * repo-->>oneToManyOnDelete: deleted
319
+ * oneToManyOnDelete->>cacheModelForPopulate: context, model, key, id, deleted
320
+ * end
321
+ *
322
+ * oneToManyOnDelete->>oneToManyOnDelete: set model[key] = [...uniqueValues]
323
+ * oneToManyOnDelete-->>Caller: void
324
+ */
12
325
  export declare function oneToManyOnDelete<M extends Model, R extends Repo<M, F, C>, V extends RelationsMetadata, F extends RepositoryFlags, C extends Context<F>>(this: R, context: Context<F>, data: V, key: keyof M, model: M): Promise<void>;
326
+ /**
327
+ * @description Generates a key for caching populated model relationships
328
+ * @summary Creates a unique key for storing and retrieving populated model relationships in the cache
329
+ * @param {string} tableName - The name of the table or model
330
+ * @param {string} fieldName - The name of the field or property
331
+ * @param {string|number} id - The identifier of the related model
332
+ * @return {string} A dot-separated string that uniquely identifies the relationship
333
+ * @function getPopulateKey
334
+ * @memberOf module:core
335
+ */
13
336
  export declare function getPopulateKey(tableName: string, fieldName: string, id: string | number): string;
337
+ /**
338
+ * @description Caches a model for later population
339
+ * @summary Stores a model in the context cache for efficient retrieval during relationship population
340
+ * @template M - The model type extending Model
341
+ * @template F - The repository flags type
342
+ * @param {Context<F>} context - The context for the operation
343
+ * @param {M} parentModel - The parent model that contains the relationship
344
+ * @param propertyKey - The property key of the relationship
345
+ * @param {string | number} pkValue - The primary key value of the related model
346
+ * @param {any} cacheValue - The model instance to cache
347
+ * @return {Promise<any>} A promise that resolves with the result of the cache operation
348
+ * @function cacheModelForPopulate
349
+ * @memberOf module:core
350
+ */
14
351
  export declare function cacheModelForPopulate<M extends Model, F extends RepositoryFlags>(context: Context<F>, parentModel: M, propertyKey: keyof M | string, pkValue: string | number, cacheValue: any): Promise<Context<F & {
15
352
  [x: string]: any;
16
353
  }>>;
354
+ /**
355
+ * @description Populates a model's relationship
356
+ * @summary Retrieves and attaches related models to a model's relationship property
357
+ * @template M - The model type extending Model
358
+ * @template R - The repository type extending Repo<M, F, C>
359
+ * @template V - The relations metadata type extending RelationsMetadata
360
+ * @template F - The repository flags type
361
+ * @template C - The context type extending Context<F>
362
+ * @param {R} this - The repository instance
363
+ * @param {Context<F>} context - The context for the operation
364
+ * @param {V} data - The relations metadata
365
+ * @param key - The property key of the relationship
366
+ * @param {M} model - The model instance
367
+ * @return {Promise<void>} A promise that resolves when the operation is complete
368
+ * @function populate
369
+ * @memberOf module:core
370
+ * @mermaid
371
+ * sequenceDiagram
372
+ * participant Caller
373
+ * participant populate
374
+ * participant fetchPopulateValues
375
+ * participant getPopulateKey
376
+ * participant Context
377
+ * participant repositoryFromTypeMetadata
378
+ *
379
+ * Caller->>populate: this, context, data, key, model
380
+ * populate->>populate: check if data.populate is true
381
+ * populate->>populate: get nested value and check if it exists
382
+ *
383
+ * populate->>fetchPopulateValues: context, model, key, isArr ? nested : [nested]
384
+ *
385
+ * fetchPopulateValues->>fetchPopulateValues: initialize variables
386
+ *
387
+ * loop for each proKeyValue in propKeyValues
388
+ * fetchPopulateValues->>getPopulateKey: model.constructor.name, propName, proKeyValue
389
+ * getPopulateKey-->>fetchPopulateValues: cacheKey
390
+ *
391
+ * alt try to get from cache
392
+ * fetchPopulateValues->>Context: get(cacheKey)
393
+ * Context-->>fetchPopulateValues: val
394
+ * else catch error
395
+ * fetchPopulateValues->>repositoryFromTypeMetadata: model, propName
396
+ * repositoryFromTypeMetadata-->>fetchPopulateValues: repo
397
+ * fetchPopulateValues->>repo: read(proKeyValue)
398
+ * repo-->>fetchPopulateValues: val
399
+ * end
400
+ *
401
+ * fetchPopulateValues->>fetchPopulateValues: add val to results
402
+ * end
403
+ *
404
+ * fetchPopulateValues-->>populate: results
405
+ * populate->>populate: set model[key] = isArr ? res : res[0]
406
+ * populate-->>Caller: void
407
+ */
17
408
  export declare function populate<M extends Model, R extends Repo<M, F, C>, V extends RelationsMetadata, F extends RepositoryFlags, C extends Context<F>>(this: R, context: Context<F>, data: V, key: keyof M, model: M): Promise<void>;
409
+ /**
410
+ * @description Retrieves a repository for a model property based on its type metadata
411
+ * @summary Examines a model property's type metadata to determine the appropriate repository for related models
412
+ * @template M - The model type extending Model
413
+ * @param {any} model - The model instance containing the property
414
+ * @param propertyKey - The property key to examine
415
+ * @return {Repo<M>} A repository for the model type associated with the property
416
+ * @function repositoryFromTypeMetadata
417
+ * @memberOf module:core
418
+ * @mermaid
419
+ * sequenceDiagram
420
+ * participant Caller
421
+ * participant repositoryFromTypeMetadata
422
+ * participant Reflect
423
+ * participant Validation
424
+ * participant Model
425
+ * participant Repository
426
+ *
427
+ * Caller->>repositoryFromTypeMetadata: model, propertyKey
428
+ *
429
+ * repositoryFromTypeMetadata->>Validation: key(Array.isArray(model[propertyKey]) ? ValidationKeys.LIST : ValidationKeys.TYPE)
430
+ * Validation-->>repositoryFromTypeMetadata: validationKey
431
+ *
432
+ * repositoryFromTypeMetadata->>Reflect: getMetadata(validationKey, model, propertyKey)
433
+ * Reflect-->>repositoryFromTypeMetadata: types
434
+ *
435
+ * repositoryFromTypeMetadata->>repositoryFromTypeMetadata: determine customTypes based on property type
436
+ * repositoryFromTypeMetadata->>repositoryFromTypeMetadata: check if types and customTypes exist
437
+ *
438
+ * repositoryFromTypeMetadata->>repositoryFromTypeMetadata: create allowedTypes array
439
+ * repositoryFromTypeMetadata->>repositoryFromTypeMetadata: find constructorName not in commomTypes
440
+ * repositoryFromTypeMetadata->>repositoryFromTypeMetadata: check if constructorName exists
441
+ *
442
+ * repositoryFromTypeMetadata->>Model: get(constructorName)
443
+ * Model-->>repositoryFromTypeMetadata: constructor
444
+ * repositoryFromTypeMetadata->>repositoryFromTypeMetadata: check if constructor exists
445
+ *
446
+ * repositoryFromTypeMetadata->>Repository: forModel(constructor)
447
+ * Repository-->>repositoryFromTypeMetadata: repo
448
+ *
449
+ * repositoryFromTypeMetadata-->>Caller: repo
450
+ */
18
451
  export declare function repositoryFromTypeMetadata<M extends Model>(model: any, propertyKey: string | keyof M): Repo<M>;