@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,8 +1,27 @@
1
- import { UnsupportedError } from "../persistence";
1
+ import { UnsupportedError } from "./../persistence/index.js";
2
+ /**
3
+ * @description Sets the created by field on a model during RAM create/update operations
4
+ * @summary Automatically populates a model field with the UUID from the context during create or update operations.
5
+ * This function is designed to be used as a handler for RAM operations to track entity creation.
6
+ * @template M - Type of the model being created/updated
7
+ * @template R - Type of the repository handling the model
8
+ * @template V - Type of the relations metadata
9
+ * @template F - Type of the RAM flags
10
+ * @template C - Type of the context
11
+ * @param {R} this - The repository instance
12
+ * @param {Context<F>} context - The operation context containing user identification
13
+ * @param {V} data - The relations metadata
14
+ * @param key - The property key to set with the UUID
15
+ * @param {M} model - The model instance being created/updated
16
+ * @return {Promise<void>} A promise that resolves when the field has been set
17
+ * @function createdByOnRamCreateUpdate
18
+ * @memberOf module:core
19
+ * @category Ram
20
+ */
2
21
  export async function createdByOnRamCreateUpdate(context, data, key, model) {
3
22
  const uuid = context.get("UUID");
4
23
  if (!uuid)
5
24
  throw new UnsupportedError("This adapter does not support user identification");
6
25
  model[key] = uuid;
7
26
  }
8
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGFuZGxlcnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcmFtL2hhbmRsZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBLE9BQU8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XNlPHZvaWQ+IHtcbiAgY29uc3QgdXVpZDogc3RyaW5nID0gY29udGV4dC5nZXQoXCJVVUlEXCIpO1xuICBpZiAoIXV1aWQpXG4gICAgdGhyb3cgbmV3IFVuc3VwcG9ydGVkRXJyb3IoXG4gICAgICBcIlRoaXMgYWRhcHRlciBkb2VzIG5vdCBzdXBwb3J0IHVzZXIgaWRlbnRpZmljYXRpb25cIlxuICAgICk7XG4gIG1vZGVsW2tleV0gPSB1dWlkIGFzIE1ba2V5b2YgTV07XG59XG4iXX0=
@@ -1,14 +1,14 @@
1
- import { RamAdapter } from "./RamAdapter";
1
+ import { RamAdapter } from "./RamAdapter.js";
2
2
  // Invoked there to ensure decoration override
3
3
  RamAdapter.decoration();
4
- export * from "./model";
5
- export * from "./constants";
6
- export * from "./handlers";
7
- export * from "./RamContext";
8
- export * from "./RamPaginator";
9
- export * from "./RamStatement";
10
- export * from "./RamSequence";
11
- export * from "./types";
4
+ export * from "./model/index.js";
5
+ export * from "./constants.js";
6
+ export * from "./handlers.js";
7
+ export * from "./RamContext.js";
8
+ export * from "./RamPaginator.js";
9
+ export * from "./RamStatement.js";
10
+ export * from "./RamSequence.js";
11
+ export * from "./types.js";
12
12
  // left to last on purpose
13
- export * from "./RamAdapter";
14
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcmFtL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxjQUFjLENBQUM7QUFFMUMsOENBQThDO0FBQzlDLFVBQVUsQ0FBQyxVQUFVLEVBQUUsQ0FBQztBQUV4QixjQUFjLFNBQVMsQ0FBQztBQUN4QixjQUFjLGFBQWEsQ0FBQztBQUM1QixjQUFjLFlBQVksQ0FBQztBQUMzQixjQUFjLGNBQWMsQ0F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FQUFFLENBQUM7QUFFeEIsaUNBQXdCO0FBQ3hCLCtCQUE0QjtBQUM1Qiw4QkFBMkI7QUFDM0IsZ0NBQTZCO0FBQzdCLGtDQUErQjtBQUMvQixrQ0FBK0I7QUFDL0IsaUNBQThCO0FBQzlCLDJCQUF3QjtBQUN4QiwwQkFBMEI7QUFDMUIsZ0NBQTZCIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgUmFtQWRhcHRlciB9IGZyb20gXCIuL1JhbUFkYXB0ZXJcIjtcblxuLy8gSW52b2tlZCB0aGVyZSB0byBlbnN1cmUgZGVjb3JhdGlvbiBvdmVycmlkZVxuUmFtQWRhcHRlci5kZWNvcmF0aW9uKCk7XG5cbmV4cG9ydCAqIGZyb20gXCIuL21vZGVsXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9jb25zdGFudHNcIjtcbmV4cG9ydCAqIGZyb20gXCIuL2hhbmRsZXJzXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9SYW1Db250ZXh0XCI7XG5leHBvcnQgKiBmcm9tIFwiLi9SYW1QYWdpbmF0b3JcIjtcbmV4cG9ydCAqIGZyb20gXCIuL1JhbVN0YXRlbWVudFwiO1xuZXhwb3J0ICogZnJvbSBcIi4vUmFtU2VxdWVuY2VcIjtcbmV4cG9ydCAqIGZyb20gXCIuL3R5cGVzXCI7XG4vLyBsZWZ0IHRvIGxhc3Qgb24gcHVycG9zZVxuZXhwb3J0ICogZnJvbSBcIi4vUmFtQWRhcHRlclwiO1xuIl19
@@ -1,7 +1,32 @@
1
1
  import type { ModelArg } from "@decaf-ts/decorator-validation";
2
2
  import { BaseModel } from "../../model";
3
+ /**
4
+ * @description RAM sequence model for auto-incrementing values
5
+ * @summary A model class that represents a sequence in the RAM adapter. It stores the current value
6
+ * of a sequence that can be used for generating sequential identifiers for entities.
7
+ * The sequence is identified by its ID and maintains the current value.
8
+ * @param {ModelArg<Sequence>} seq - Initial sequence data
9
+ * @class Sequence
10
+ * @category Ram
11
+ * @example
12
+ * ```typescript
13
+ * // Create a new sequence
14
+ * const orderSequence = new Sequence({ id: 'order_seq', current: 1 });
15
+ *
16
+ * // Use the sequence to get the next value
17
+ * const nextOrderId = parseInt(orderSequence.current.toString()) + 1;
18
+ * orderSequence.current = nextOrderId;
19
+ * ```
20
+ */
3
21
  export declare class Sequence extends BaseModel {
22
+ /**
23
+ * @description Primary key identifier for the sequence
24
+ */
4
25
  id: string;
26
+ /**
27
+ * @description Current value of the sequence
28
+ * Used to generate the next sequential value
29
+ */
5
30
  current: string | number;
6
31
  constructor(seq?: ModelArg<Sequence>);
7
32
  }
@@ -8,8 +8,26 @@ var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
10
  import { model, required } from "@decaf-ts/decorator-validation";
11
- import { BaseModel, index, table } from "../../model";
12
- import { pk } from "../../identity";
11
+ import { BaseModel, index, table } from "./../../model/index.js";
12
+ import { pk } from "./../../identity/index.js";
13
+ /**
14
+ * @description RAM sequence model for auto-incrementing values
15
+ * @summary A model class that represents a sequence in the RAM adapter. It stores the current value
16
+ * of a sequence that can be used for generating sequential identifiers for entities.
17
+ * The sequence is identified by its ID and maintains the current value.
18
+ * @param {ModelArg<Sequence>} seq - Initial sequence data
19
+ * @class Sequence
20
+ * @category Ram
21
+ * @example
22
+ * ```typescript
23
+ * // Create a new sequence
24
+ * const orderSequence = new Sequence({ id: 'order_seq', current: 1 });
25
+ *
26
+ * // Use the sequence to get the next value
27
+ * const nextOrderId = parseInt(orderSequence.current.toString()) + 1;
28
+ * orderSequence.current = nextOrderId;
29
+ * ```
30
+ */
13
31
  let Sequence = class Sequence extends BaseModel {
14
32
  constructor(seq) {
15
33
  super(seq);
@@ -30,4 +48,4 @@ Sequence = __decorate([
30
48
  __metadata("design:paramtypes", [Object])
31
49
  ], Sequence);
32
50
  export { Sequence };
33
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJ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bWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsZUFBZSxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSBcIi4vUmFtU2VxdWVuY2VcIjtcbiJdfQ==
1
+ export * from "./RamSequence.js";
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvcmFtL21vZGVsL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGlDQUE4QiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCAqIGZyb20gXCIuL1JhbVNlcXVlbmNlXCI7XG4iXX0=
@@ -2,7 +2,31 @@ import { Constructor, Model } from "@decaf-ts/decorator-validation";
2
2
  import { Repository } from "../repository";
3
3
  import { Context, RepositoryFlags } from "@decaf-ts/db-decorators";
4
4
  import { RamAdapter } from "./RamAdapter";
5
+ /**
6
+ * @description In-memory storage structure for the RAM adapter
7
+ * @summary A nested Map structure that stores all entities by their table name and primary key.
8
+ * The outer Map uses table names as keys, while the inner Map uses entity IDs as keys and entity instances as values.
9
+ * @typedef {Map<string, Map<string | number, any>>} RamStorage
10
+ * @memberOf module:core
11
+ * @category Ram
12
+ */
5
13
  export type RamStorage = Map<string, Map<string | number, any>>;
14
+ /**
15
+ * @description Query specification for RAM adapter
16
+ * @summary Defines the structure of a query for retrieving data from the in-memory storage.
17
+ * It specifies what fields to select, which model to query, filtering conditions,
18
+ * sorting criteria, and pagination options.
19
+ * @template M - The model type being queried
20
+ * @typedef {Object} RawRamQuery
21
+ * @property select - Fields to select from the model, or undefined for all fields
22
+ * @property {Constructor<M>} from - The model constructor to query
23
+ * @property {function(M): boolean} where - Predicate function for filtering entities
24
+ * @property {function(M, M): number} [sort] - Optional comparator function for sorting results
25
+ * @property {number} [limit] - Optional maximum number of results to return
26
+ * @property {number} [skip] - Optional number of results to skip (for pagination)
27
+ * @memberOf module:core
28
+ * @category Ram
29
+ */
6
30
  export type RawRamQuery<M extends Model> = {
7
31
  select: undefined | (keyof M)[];
8
32
  from: Constructor<M>;
@@ -11,7 +35,25 @@ export type RawRamQuery<M extends Model> = {
11
35
  limit?: number;
12
36
  skip?: number;
13
37
  };
38
+ /**
39
+ * @description Flags for RAM adapter operations
40
+ * @summary Interface that extends the base repository flags with RAM-specific flags.
41
+ * Contains user identification information needed for tracking entity creation and updates.
42
+ * @interface RamFlags
43
+ * @property {string} UUID - Unique identifier for the current user
44
+ * @memberOf module:core
45
+ * @category Ram
46
+ */
14
47
  export interface RamFlags extends RepositoryFlags {
15
48
  UUID: string;
16
49
  }
50
+ /**
51
+ * @description Type definition for RAM-specific repository
52
+ * @summary A specialized repository type for working with models in the RAM adapter.
53
+ * It combines the model type with RAM-specific query, adapter, flags, and context types.
54
+ * @template M - The model type managed by the repository
55
+ * @typedef {Repository<M, RawRamQuery<any>, RamAdapter, RamFlags, Context<RamFlags>>} RamRepository
56
+ * @memberOf module:core
57
+ * @category Ram
58
+ */
17
59
  export type RamRepository<M extends Model> = Repository<M, RawRamQuery<any>, RamAdapter, RamFlags, Context<RamFlags>>;
@@ -1,2 +1,2 @@
1
1
  export {};
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcmFtL3R5cGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBDb25zdHJ1Y3RvciwgTW9kZWwgfSBmcm9tIFwiQGRlY2FmLXRzL2RlY29yYXRvci12YWxpZGF0aW9uXCI7XG5pbXBvcnQgeyBSZXBvc2l0b3J5IH0gZnJvbSBcIi4uL3JlcG9zaXRvcnlcIjtcbmltcG9ydCB7IENvbnRle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GUgUkFNIGFkYXB0ZXIuXG4gKiBJdCBjb21iaW5lcyB0aGUgbW9kZWwgdHlwZSB3aXRoIFJBTS1zcGVjaWZpYyBxdWVyeSwgYWRhcHRlciwgZmxhZ3MsIGFuZCBjb250ZXh0IHR5cGVzLlxuICogQHRlbXBsYXRlIE0gLSBUaGUgbW9kZWwgdHlwZSBtYW5hZ2VkIGJ5IHRoZSByZXBvc2l0b3J5XG4gKiBAdHlwZWRlZiB7UmVwb3NpdG9yeTxNLCBSYXdSYW1RdWVyeTxhbnk+LCBSYW1BZGFwdGVyLCBSYW1GbGFncywgQ29udGV4dDxSYW1GbGFncz4+fSBSYW1SZXBvc2l0b3J5XG4gKiBAbWVtYmVyT2YgbW9kdWxlOmNvcmVcbiAqIEBjYXRlZ29yeSBSYW1cbiAqL1xuZXhwb3J0IHR5cGUgUmFtUmVwb3NpdG9yeTxNIGV4dGVuZHMgTW9kZWw+ID0gUmVwb3NpdG9yeTxcbiAgTSxcbiAgUmF3UmFtUXVlcnk8YW55PixcbiAgUmFtQWRhcHRlcixcbiAgUmFtRmxhZ3MsXG4gIENvbnRleHQ8UmFtRmxhZ3M+XG4+O1xuIl19
@@ -13,7 +13,71 @@ import { SelectSelector } from "../query/selectors";
13
13
  import { Logger } from "@decaf-ts/logging";
14
14
  import { ObserverHandler } from "../persistence/ObserverHandler";
15
15
  import type { EventIds, ObserverFilter } from "../persistence";
16
+ /**
17
+ * @description Type alias for Repository class with simplified generic parameters.
18
+ * @summary Provides a more concise way to reference the Repository class with its generic parameters.
19
+ * @template M - The model type that extends Model.
20
+ * @template F - The repository flags type.
21
+ * @template C - The context type.
22
+ * @template Q - The query type.
23
+ * @template A - The adapter type.
24
+ * @typedef Repo
25
+ * @memberOf module:core
26
+ */
16
27
  export type Repo<M extends Model, F extends RepositoryFlags = any, C extends Context<F> = any, Q = any, A extends Adapter<any, Q, F, C> = any> = Repository<M, Q, A, F, C>;
28
+ /**
29
+ * @description Core repository implementation for database operations on models on a table by table way.
30
+ * @summary Provides CRUD operations, querying capabilities, and observer pattern implementation for model persistence.
31
+ * @template M - The model type that extends Model.
32
+ * @template Q - The query type used by the adapter.
33
+ * @template A - The adapter type for database operations.
34
+ * @template F - The repository flags type.
35
+ * @template C - The context type for operations.
36
+ * @param {A} [adapter] - Optional adapter instance for database operations.
37
+ * @param {Constructor<M>} [clazz] - Optional constructor for the model class.
38
+ * @param {...any[]} [args] - Additional arguments for repository initialization.
39
+ * @class Repository
40
+ * @example
41
+ * // Creating a repository for User model
42
+ * const userRepo = Repository.forModel(User);
43
+ *
44
+ * // Using the repository for CRUD operations
45
+ * const user = await userRepo.create(new User({ name: 'John' }));
46
+ * const retrievedUser = await userRepo.read(user.id);
47
+ * user.name = 'Jane';
48
+ * await userRepo.update(user);
49
+ * await userRepo.delete(user.id);
50
+ *
51
+ * // Querying with conditions
52
+ * const users = await userRepo
53
+ * .select()
54
+ * .where({ name: 'Jane' })
55
+ * .orderBy('createdAt', OrderDirection.DSC)
56
+ * .limit(10)
57
+ * .execute();
58
+ * @mermaid
59
+ * sequenceDiagram
60
+ * participant C as Client Code
61
+ * participant R as Repository
62
+ * participant A as Adapter
63
+ * participant DB as Database
64
+ * participant O as Observers
65
+ *
66
+ * C->>+R: create(model)
67
+ * R->>R: createPrefix(model)
68
+ * R->>+A: prepare(model)
69
+ * A-->>-R: prepared data
70
+ * R->>+A: create(table, id, record)
71
+ * A->>+DB: Insert Operation
72
+ * DB-->>-A: Result
73
+ * A-->>-R: record
74
+ * R->>+A: revert(record)
75
+ * A-->>-R: model instance
76
+ * R->>R: createSuffix(model)
77
+ * R->>+O: updateObservers(table, CREATE, id)
78
+ * O-->>-R: Notification complete
79
+ * R-->>-C: created model
80
+ */
17
81
  export declare class Repository<M extends Model, Q, A extends Adapter<any, Q, F, C>, F extends RepositoryFlags = RepositoryFlags, C extends Context<F> = Context<F>> extends Rep<M, F, C> implements Observable, Observer, Queriable<M>, IRepository<M, F, C> {
18
82
  private static _cache;
19
83
  protected observers: Observer[];
@@ -22,56 +86,347 @@ export declare class Repository<M extends Model, Q, A extends Adapter<any, Q, F,
22
86
  private _tableName;
23
87
  private _overrides?;
24
88
  private logger;
89
+ /**
90
+ * @description Logger instance for this repository.
91
+ * @summary Provides access to the logger for this repository instance.
92
+ * @return {Logger} The logger instance.
93
+ */
25
94
  get log(): Logger;
95
+ /**
96
+ * @description Adapter for database operations.
97
+ * @summary Provides access to the adapter instance for this repository.
98
+ * @template A - The adapter type.
99
+ * @return {A} The adapter instance.
100
+ * @throws {InternalError} If no adapter is found.
101
+ */
26
102
  protected get adapter(): A;
103
+ /**
104
+ * @description Table name for this repository's model.
105
+ * @summary Gets the database table name associated with this repository's model.
106
+ * @return {string} The table name.
107
+ */
27
108
  protected get tableName(): string;
109
+ /**
110
+ * @description Primary key properties for this repository's model.
111
+ * @summary Gets the sequence options containing primary key information.
112
+ * @return {SequenceOptions} The primary key properties.
113
+ */
28
114
  protected get pkProps(): SequenceOptions;
29
115
  constructor(adapter?: A, clazz?: Constructor<M>, ...args: any[]);
30
- override(flags: Partial<F>): this;
116
+ /**
117
+ * @description Creates a proxy with overridden repository flags.
118
+ * @summary Returns a proxy of this repository with the specified flags overridden.
119
+ * @param {Partial<F>} flags - The flags to override.
120
+ * @return {Repository} A proxy of this repository with overridden flags.
121
+ */
122
+ override(flags: Partial<F>): Repository<M, Q, A, F, C>;
123
+ /**
124
+ * @description Creates a new observer handler.
125
+ * @summary Factory method for creating an observer handler instance.
126
+ * @return {ObserverHandler} A new observer handler instance.
127
+ */
31
128
  protected ObserverHandler(): ObserverHandler;
129
+ /**
130
+ * @description Prepares a model for creation.
131
+ * @summary Validates the model and prepares it for creation in the database.
132
+ * @template M - The model type.
133
+ * @param {M} model - The model to create.
134
+ * @param {...any[]} args - Additional arguments.
135
+ * @return The prepared model and context arguments.
136
+ * @throws {ValidationError} If the model fails validation.
137
+ */
32
138
  protected createPrefix(model: M, ...args: any[]): Promise<[M, ...any[]]>;
139
+ /**
140
+ * @description Creates a model in the database.
141
+ * @summary Persists a model instance to the database.
142
+ * @param {M} model - The model to create.
143
+ * @param {...any[]} args - Additional arguments.
144
+ * @return {Promise<M>} The created model with updated properties.
145
+ */
33
146
  create(model: M, ...args: any[]): Promise<M>;
147
+ /**
148
+ * @description Post-creation hook.
149
+ * @summary Executes after a model is created to perform additional operations.
150
+ * @param {M} model - The created model.
151
+ * @param {C} context - The operation context.
152
+ * @return {Promise<M>} The processed model.
153
+ */
34
154
  createSuffix(model: M, context: C): Promise<M>;
155
+ /**
156
+ * @description Creates multiple models in the database.
157
+ * @summary Persists multiple model instances to the database in a batch operation.
158
+ * @param {M[]} models - The models to create.
159
+ * @param {...any[]} args - Additional arguments.
160
+ * @return {Promise<M[]>} The created models with updated properties.
161
+ */
35
162
  createAll(models: M[], ...args: any[]): Promise<M[]>;
163
+ /**
164
+ * @description Prepares multiple models for creation.
165
+ * @summary Validates multiple models and prepares them for creation in the database.
166
+ * @param {M[]} models - The models to create.
167
+ * @param {...any[]} args - Additional arguments.
168
+ * @return The prepared models and context arguments.
169
+ * @throws {ValidationError} If any model fails validation.
170
+ */
36
171
  protected createAllPrefix(models: M[], ...args: any[]): Promise<any[]>;
172
+ /**
173
+ * @description Prepares for reading a model by ID.
174
+ * @summary Prepares the context and enforces decorators before reading a model.
175
+ * @param {string} key - The primary key of the model to read.
176
+ * @param {...any[]} args - Additional arguments.
177
+ * @return The key and context arguments.
178
+ */
37
179
  protected readPrefix(key: string, ...args: any[]): Promise<any[]>;
180
+ /**
181
+ * @description Reads a model from the database by ID.
182
+ * @summary Retrieves a model instance from the database using its primary key.
183
+ * @param {string|number|bigint} id - The primary key of the model to read.
184
+ * @param {...any[]} args - Additional arguments.
185
+ * @return {Promise<M>} The retrieved model instance.
186
+ */
38
187
  read(id: string | number | bigint, ...args: any[]): Promise<M>;
188
+ /**
189
+ * @description Prepares for reading multiple models by IDs.
190
+ * @summary Prepares the context and enforces decorators before reading multiple models.
191
+ * @param {string[]|number[]} keys - The primary keys of the models to read.
192
+ * @param {...any[]} args - Additional arguments.
193
+ * @return The keys and context arguments.
194
+ */
39
195
  protected readAllPrefix(keys: string[] | number[], ...args: any[]): Promise<any[]>;
196
+ /**
197
+ * @description Reads multiple models from the database by IDs.
198
+ * @summary Retrieves multiple model instances from the database using their primary keys.
199
+ * @param {string[]|number[]} keys - The primary keys of the models to read.
200
+ * @param {...any[]} args - Additional arguments.
201
+ * @return {Promise<M[]>} The retrieved model instances.
202
+ */
40
203
  readAll(keys: string[] | number[], ...args: any[]): Promise<M[]>;
204
+ /**
205
+ * @description Updates a model in the database.
206
+ * @summary Persists changes to an existing model instance in the database.
207
+ * @param {M} model - The model to update.
208
+ * @param {...any[]} args - Additional arguments.
209
+ * @return {Promise<M>} The updated model with refreshed properties.
210
+ */
41
211
  update(model: M, ...args: any[]): Promise<M>;
212
+ /**
213
+ * @description Prepares a model for update.
214
+ * @summary Validates the model and prepares it for update in the database.
215
+ * @param {M} model - The model to update.
216
+ * @param {...any[]} args - Additional arguments.
217
+ * @return The prepared model and context arguments.
218
+ * @throws {InternalError} If the model has no primary key value.
219
+ * @throws {ValidationError} If the model fails validation.
220
+ */
42
221
  protected updatePrefix(model: M, ...args: any[]): Promise<[M, ...args: any[]]>;
222
+ /**
223
+ * @description Updates multiple models in the database.
224
+ * @summary Persists changes to multiple existing model instances in the database in a batch operation.
225
+ * @param {M[]} models - The models to update.
226
+ * @param {...any[]} args - Additional arguments.
227
+ * @return {Promise<M[]>} The updated models with refreshed properties.
228
+ */
43
229
  updateAll(models: M[], ...args: any[]): Promise<M[]>;
230
+ /**
231
+ * @description Prepares multiple models for update.
232
+ * @summary Validates multiple models and prepares them for update in the database.
233
+ * @param {M[]} models - The models to update.
234
+ * @param {...any[]} args - Additional arguments.
235
+ * @return {Promise<any[]>} The prepared models and context arguments.
236
+ * @throws {InternalError} If any model has no primary key value.
237
+ * @throws {ValidationError} If any model fails validation.
238
+ */
44
239
  protected updateAllPrefix(models: M[], ...args: any[]): Promise<any[]>;
240
+ /**
241
+ * @description Prepares for deleting a model by ID.
242
+ * @summary Prepares the context and enforces decorators before deleting a model.
243
+ * @param {any} key - The primary key of the model to delete.
244
+ * @param {...any[]} args - Additional arguments.
245
+ * @return The key and context arguments.
246
+ */
45
247
  protected deletePrefix(key: any, ...args: any[]): Promise<any[]>;
248
+ /**
249
+ * @description Deletes a model from the database by ID.
250
+ * @summary Removes a model instance from the database using its primary key.
251
+ * @param {string|number|bigint} id - The primary key of the model to delete.
252
+ * @param {...any[]} args - Additional arguments.
253
+ * @return {Promise<M>} The deleted model instance.
254
+ */
46
255
  delete(id: string | number | bigint, ...args: any[]): Promise<M>;
256
+ /**
257
+ * @description Prepares for deleting multiple models by IDs.
258
+ * @summary Prepares the context and enforces decorators before deleting multiple models.
259
+ * @param {string[]|number[]} keys - The primary keys of the models to delete.
260
+ * @param {...any[]} args - Additional arguments.
261
+ * @return The keys and context arguments.
262
+ */
47
263
  protected deleteAllPrefix(keys: string[] | number[], ...args: any[]): Promise<any[]>;
264
+ /**
265
+ * @description Deletes multiple models from the database by IDs.
266
+ * @summary Removes multiple model instances from the database using their primary keys.
267
+ * @param {string[]|number[]} keys - The primary keys of the models to delete.
268
+ * @param {...any[]} args - Additional arguments.
269
+ * @return {Promise<M[]>} The deleted model instances.
270
+ */
48
271
  deleteAll(keys: string[] | number[], ...args: any[]): Promise<M[]>;
272
+ /**
273
+ * @description Creates a select query without specifying fields.
274
+ * @summary Starts building a query that will return all fields of the model.
275
+ * @template S - The array type of select selectors.
276
+ * @return A query builder for the model.
277
+ */
49
278
  select<S extends readonly SelectSelector<M>[]>(): WhereOption<M, M[]>;
279
+ /**
280
+ * @description Creates a select query with specific fields.
281
+ * @summary Starts building a query that will return only the specified fields of the model.
282
+ * @template S - The array type of select selectors.
283
+ * @param selector - The fields to select.
284
+ * @return A query builder for the selected fields.
285
+ */
50
286
  select<S extends readonly SelectSelector<M>[]>(selector: readonly [...S]): WhereOption<M, Pick<M, S[number]>[]>;
287
+ /**
288
+ * @description Executes a query with the specified conditions and options.
289
+ * @summary Provides a simplified way to query the database with common query parameters.
290
+ * @param {Condition<M>} condition - The condition to filter records.
291
+ * @param orderBy - The field to order results by.
292
+ * @param {OrderDirection} [order=OrderDirection.ASC] - The sort direction.
293
+ * @param {number} [limit] - Optional maximum number of results to return.
294
+ * @param {number} [skip] - Optional number of results to skip.
295
+ * @return {Promise<M[]>} The query results as model instances.
296
+ */
51
297
  query(condition: Condition<M>, orderBy: keyof M, order?: OrderDirection, limit?: number, skip?: number): Promise<M[]>;
52
298
  /**
53
- *
299
+ * @description Registers an observer for this repository.
300
+ * @summary Adds an observer that will be notified of changes to models in this repository.
301
+ * @param {Observer} observer - The observer to register.
302
+ * @param {ObserverFilter} [filter] - Optional filter to limit which events the observer receives.
303
+ * @return {void}
54
304
  * @see {Observable#observe}
55
305
  */
56
306
  observe(observer: Observer, filter?: ObserverFilter): void;
57
307
  /**
58
- * @summary Unregisters an {@link Observer}
59
- * @param {Observer} observer
60
- *
308
+ * @description Unregisters an observer from this repository.
309
+ * @summary Removes an observer so it will no longer receive notifications of changes.
310
+ * @param {Observer} observer - The observer to unregister.
311
+ * @return {void}
312
+ * @throws {InternalError} If the observer handler is not initialized.
61
313
  * @see {Observable#unObserve}
62
314
  */
63
315
  unObserve(observer: Observer): void;
316
+ /**
317
+ * @description Notifies all observers of an event.
318
+ * @summary Updates all registered observers with information about a database event.
319
+ * @param {string} table - The table name where the event occurred.
320
+ * @param {OperationKeys|BulkCrudOperationKeys|string} event - The type of event that occurred.
321
+ * @param {EventIds} id - The ID or IDs of the affected records.
322
+ * @param {...any[]} args - Additional arguments.
323
+ * @return {Promise<void>} A promise that resolves when all observers have been notified.
324
+ * @throws {InternalError} If the observer handler is not initialized.
325
+ */
64
326
  updateObservers(table: string, event: OperationKeys | BulkCrudOperationKeys | string, id: EventIds, ...args: any[]): Promise<void>;
327
+ /**
328
+ * @description Alias for updateObservers.
329
+ * @summary Notifies all observers of an event (alias for updateObservers).
330
+ * @param {string} table - The table name where the event occurred.
331
+ * @param {OperationKeys|BulkCrudOperationKeys|string} event - The type of event that occurred.
332
+ * @param {EventIds} id - The ID or IDs of the affected records.
333
+ * @param {...any[]} args - Additional arguments.
334
+ * @return {Promise<void>} A promise that resolves when all observers have been notified.
335
+ */
65
336
  refresh(table: string, event: OperationKeys | BulkCrudOperationKeys | string, id: EventIds, ...args: any[]): Promise<void>;
66
- static forModel<M extends Model, R extends Repo<M>>(model: Constructor<M>, defaultFlavour?: string, ...args: any[]): R;
337
+ /**
338
+ * @description Creates or retrieves a repository for a model.
339
+ * @summary Factory method that returns a repository instance for the specified model.
340
+ * @template M - The model type that extends Model.
341
+ * @template R - The repository type that extends Repo<M>.
342
+ * @param {Constructor<M>} model - The model constructor.
343
+ * @param {string} [defaultFlavour] - Optional default adapter flavour if not specified on the model.
344
+ * @param {...any[]} [args] - Additional arguments to pass to the repository constructor.
345
+ * @return {R} A repository instance for the model.
346
+ * @throws {InternalError} If no adapter is registered for the flavour.
347
+ */
348
+ static forModel<M extends Model, R extends Repo<M>>(model: Constructor<M>, alias?: string, ...args: any[]): R;
349
+ /**
350
+ * @description Retrieves a repository for a model from the cache.
351
+ * @summary Gets a repository constructor or instance for the specified model from the internal cache.
352
+ * @template M - The model type that extends Model.
353
+ * @param {Constructor<M>} model - The model constructor.
354
+ * @return {Constructor<Repo<M>> | Repo<M>} The repository constructor or instance.
355
+ * @throws {InternalError} If no repository is registered for the model.
356
+ */
67
357
  private static get;
68
- static register<M extends Model>(model: Constructor<M>, repo: Constructor<Repo<M>> | Repo<M>): void;
358
+ /**
359
+ * @description Registers a repository for a model.
360
+ * @summary Associates a repository constructor or instance with a model in the internal cache.
361
+ * @template M - The model type that extends Model.
362
+ * @param {Constructor<M>} model - The model constructor.
363
+ * @param {Constructor<Repo<M>> | Repo<M>} repo - The repository constructor or instance.
364
+ * @throws {InternalError} If a repository is already registered for the model.
365
+ */
366
+ static register<M extends Model>(model: Constructor<M>, repo: Constructor<Repo<M>> | Repo<M>, alias?: string): void;
367
+ /**
368
+ * @description Sets metadata on a model instance.
369
+ * @summary Attaches metadata to a model instance using a non-enumerable property.
370
+ * @template M - The model type that extends Model.
371
+ * @param {M} model - The model instance.
372
+ * @param {any} metadata - The metadata to attach to the model.
373
+ */
69
374
  static setMetadata<M extends Model>(model: M, metadata: any): void;
375
+ /**
376
+ * @description Gets metadata from a model instance.
377
+ * @summary Retrieves previously attached metadata from a model instance.
378
+ * @template M - The model type that extends Model.
379
+ * @param {M} model - The model instance.
380
+ * @return {any} The metadata or undefined if not found.
381
+ */
70
382
  static getMetadata<M extends Model>(model: M): any;
383
+ /**
384
+ * @description Removes metadata from a model instance.
385
+ * @summary Deletes the metadata property from a model instance.
386
+ * @template M - The model type that extends Model.
387
+ * @param {M} model - The model instance.
388
+ */
71
389
  static removeMetadata<M extends Model>(model: M): void;
390
+ /**
391
+ * @description Gets sequence options for a model's primary key.
392
+ * @summary Retrieves the sequence configuration for a model's primary key from metadata.
393
+ * @template M - The model type that extends Model.
394
+ * @param {M} model - The model instance.
395
+ * @return {SequenceOptions} The sequence options for the model's primary key.
396
+ * @throws {InternalError} If no sequence options are defined for the model.
397
+ */
72
398
  static getSequenceOptions<M extends Model>(model: M): SequenceOptions;
399
+ /**
400
+ * @description Gets all indexes defined on a model.
401
+ * @summary Retrieves all index metadata from a model's property decorators.
402
+ * @template M - The model type that extends Model.
403
+ * @param {M | Constructor<M>} model - The model instance or constructor.
404
+ * @return {Record<string, Record<string, IndexMetadata>>} A nested record of property names to index metadata.
405
+ */
73
406
  static indexes<M extends Model>(model: M | Constructor<M>): Record<string, Record<string, IndexMetadata>>;
407
+ /**
408
+ * @description Gets all relation properties defined on a model.
409
+ * @summary Retrieves the names of all properties marked as relations in the model hierarchy.
410
+ * @template M - The model type that extends Model.
411
+ * @param {M | Constructor<M>} model - The model instance or constructor.
412
+ * @return {string[]} An array of property names that are relations.
413
+ */
74
414
  static relations<M extends Model>(model: M | Constructor<M>): string[];
415
+ /**
416
+ * @description Gets the table name for a model.
417
+ * @summary Retrieves the database table name associated with a model.
418
+ * @template M - The model type that extends Model.
419
+ * @param {M | Constructor<M>} model - The model instance or constructor.
420
+ * @return {string} The table name for the model.
421
+ */
75
422
  static table<M extends Model>(model: M | Constructor<M>): string;
76
- static column<M extends Model>(model: M, attribute: string): any;
423
+ /**
424
+ * @description Gets the column name for a model attribute.
425
+ * @summary Retrieves the database column name for a model property.
426
+ * @template M - The model type that extends Model.
427
+ * @param {M} model - The model instance.
428
+ * @param {string} attribute - The attribute/property name.
429
+ * @return {string} The column name for the attribute.
430
+ */
431
+ static column<M extends Model>(model: M, attribute: string): string;
77
432
  }