@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
@@ -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
  }
@@ -1,18 +1,43 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DefaultCascade = exports.Cascade = exports.OrderDirection = void 0;
4
+ /**
5
+ * @description Enumeration of possible sort directions.
6
+ * @summary Defines the available sort directions for ordering query results.
7
+ * @enum {string}
8
+ * @readonly
9
+ * @memberOf module:core
10
+ */
4
11
  var OrderDirection;
5
12
  (function (OrderDirection) {
13
+ /** Ascending order (A to Z, 0 to 9) */
6
14
  OrderDirection["ASC"] = "asc";
15
+ /** Descending order (Z to A, 9 to 0) */
7
16
  OrderDirection["DSC"] = "desc";
8
17
  })(OrderDirection || (exports.OrderDirection = OrderDirection = {}));
18
+ /**
19
+ * @description Enumeration of cascade operation types.
20
+ * @summary Defines the available cascade behaviors for entity relationships.
21
+ * @enum {string}
22
+ * @readonly
23
+ * @memberOf module:core
24
+ */
9
25
  var Cascade;
10
26
  (function (Cascade) {
27
+ /** Perform cascade operation on related entities */
11
28
  Cascade["CASCADE"] = "cascade";
29
+ /** Do not perform cascade operation on related entities */
12
30
  Cascade["NONE"] = "none";
13
31
  })(Cascade || (exports.Cascade = Cascade = {}));
32
+ /**
33
+ * @description Default cascade configuration for entity relationships.
34
+ * @summary Provides the default cascade behavior where updates cascade but deletes do not.
35
+ * @type {CascadeMetadata}
36
+ * @const DefaultCascade
37
+ * @memberOf module:core
38
+ */
14
39
  exports.DefaultCascade = {
15
40
  update: Cascade.CASCADE,
16
41
  delete: Cascade.NONE,
17
42
  };
18
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3JlcG9zaXRvcnkvY29uc3RhbnRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUVBLElBQVksY0FJWDtBQUpELFdBQVksY0F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+ * @summary Defines the available sort directions for ordering query results.
5
+ * @enum {string}
6
+ * @readonly
7
+ * @memberOf module:core
8
+ */
2
9
  export declare enum OrderDirection {
10
+ /** Ascending order (A to Z, 0 to 9) */
3
11
  ASC = "asc",
12
+ /** Descending order (Z to A, 9 to 0) */
4
13
  DSC = "desc"
5
14
  }
15
+ /**
16
+ * @description Enumeration of cascade operation types.
17
+ * @summary Defines the available cascade behaviors for entity relationships.
18
+ * @enum {string}
19
+ * @readonly
20
+ * @memberOf module:core
21
+ */
6
22
  export declare enum Cascade {
23
+ /** Perform cascade operation on related entities */
7
24
  CASCADE = "cascade",
25
+ /** Do not perform cascade operation on related entities */
8
26
  NONE = "none"
9
27
  }
28
+ /**
29
+ * @description Default cascade configuration for entity relationships.
30
+ * @summary Provides the default cascade behavior where updates cascade but deletes do not.
31
+ * @type {CascadeMetadata}
32
+ * @const DefaultCascade
33
+ * @memberOf module:core
34
+ */
10
35
  export declare const DefaultCascade: CascadeMetadata;
@@ -5,6 +5,33 @@ const injectable_decorators_1 = require("@decaf-ts/injectable-decorators");
5
5
  const db_decorators_1 = require("@decaf-ts/db-decorators");
6
6
  const reflection_1 = require("@decaf-ts/reflection");
7
7
  const Repository_1 = require("./Repository.cjs");
8
+ /**
9
+ * @description Repository decorator for model classes.
10
+ * @summary Creates and registers a repository for a model class. Can be used as both a property decorator and a class decorator.
11
+ * @template T - The model type that extends Model.
12
+ * @param {Constructor<T>} model - The constructor of the model class.
13
+ * @param {string} [nameOverride] - Optional name override for the repository.
14
+ * @return {any} - The decorator function.
15
+ * @function repository
16
+ * @mermaid
17
+ * sequenceDiagram
18
+ * participant C as Client Code
19
+ * participant D as Decorator
20
+ * participant R as Repository
21
+ * participant M as Metadata
22
+ *
23
+ * C->>D: Apply @repository(Model)
24
+ * alt Property Decorator
25
+ * D->>D: Check if propertyKey exists
26
+ * D->>+C: Return inject(name) decorator
27
+ * else Class Decorator
28
+ * D->>M: Set repository metadata on model
29
+ * D->>R: Register model with Repository
30
+ * D->>+C: Return injectable decorator with config
31
+ * C->>C: Define DBKeys.CLASS property
32
+ * end
33
+ * @category Decorators
34
+ */
8
35
  function repository(model, nameOverride) {
9
36
  return ((original, propertyKey) => {
10
37
  if (propertyKey) {
@@ -22,4 +49,4 @@ function repository(model, nameOverride) {
22
49
  })(original);
23
50
  });
24
51
  }
25
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVjb3JhdG9ycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9yZXBvc2l0b3J5L2RlY29yYXRvcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFNQSxnQ0EyQkM7QUFqQ0QsMkVBQXFFO0FBQ3JFLDJEQUE4RDtBQUM5RCxxREFBZ0Q7QUFFaEQsaURBQTBDO0FBRTFDLFNBQWdCLFVBQVUsQ0FDeEIsS0FBcUIsRUFDckIsWUFBcUI7SUFFckIsT0FBTyxDQUFDLENBQUMsUUFBYSxFQUFFLFdBQWlCLEVBQUUsRUFBRTtRQUMzQyxJQUFJLFdBQVcsRUFBRSxDQUFDO1lBQ2hCLE9BQU8sSUFBQSw4QkFBTSxFQUFDLFlBQVksSUFBSSxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUMsUUFBUSxFQUFFLFdBQVcsQ0FBQyxDQUFDO1FBQ25FLENBQUM7UUFFRCxJQUFBLHFCQUFRLEVBQ04sdUJBQVUsQ0FBQyxHQUFHLENBQUMsc0JBQU0sQ0FBQyxVQUFVLENBQUMsRUFDakMsWUFBWSxJQUFJLFFBQVEsQ0FBQyxJQUFJLENBQzlCLENBQUMsS0FBSyxDQUFDLENBQUM7UUFDVCx1QkFBVSxDQUFDLFFBQVEsQ0FBQyxLQUFLLEVBQUUsUUFBUSxDQUFDLENBQUM7UUFDckMsT0FBTyxJQUFBLGtDQUFVLEVBQ2YsWUFBWSxJQUFJLFFBQVEsQ0FBQyxJQU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gICBuYW1lT3ZlcnJpZGUgfHwgb3JpZ2luYWwubmFtZVxuICAgICkobW9kZWwpO1xuICAgIFJlcG9zaXRvcnkucmVnaXN0ZXIobW9kZWwsIG9yaWdpbmFsKTtcbiAgICByZXR1cm4gaW5qZWN0YWJsZShcbiAgICAgIG5hbWVPdmVycmlkZSB8fCBvcmlnaW5hbC5uYW1lLFxuICAgICAgdHJ1ZSxcbiAgICAgIChpbnN0YW5jZTogSVJlcG9zaXRvcnk8VD4pID0+IHtcbiAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGluc3RhbmNlLCBEQktleXMuQ0xBU1MsIHtcbiAgICAgICAgICBlbnVtZXJhYmxlOiBmYWxzZSxcbiAgICAgICAgICBjb25maWd1cmFibGU6IGZhbHNlLFxuICAgICAgICAgIHdyaXRhYmxlOiBmYWxzZSxcbiAgICAgICAgICB2YWx1ZTogbW9kZWwsXG4gICAgICAgIH0pO1xuICAgICAgfVxuICAgICkob3JpZ2luYWwpO1xuICB9KSBhcyBhbnk7XG59XG4iXX0=
@@ -1,2 +1,29 @@
1
1
  import { Constructor, Model } from "@decaf-ts/decorator-validation";
2
+ /**
3
+ * @description Repository decorator for model classes.
4
+ * @summary Creates and registers a repository for a model class. Can be used as both a property decorator and a class decorator.
5
+ * @template T - The model type that extends Model.
6
+ * @param {Constructor<T>} model - The constructor of the model class.
7
+ * @param {string} [nameOverride] - Optional name override for the repository.
8
+ * @return {any} - The decorator function.
9
+ * @function repository
10
+ * @mermaid
11
+ * sequenceDiagram
12
+ * participant C as Client Code
13
+ * participant D as Decorator
14
+ * participant R as Repository
15
+ * participant M as Metadata
16
+ *
17
+ * C->>D: Apply @repository(Model)
18
+ * alt Property Decorator
19
+ * D->>D: Check if propertyKey exists
20
+ * D->>+C: Return inject(name) decorator
21
+ * else Class Decorator
22
+ * D->>M: Set repository metadata on model
23
+ * D->>R: Register model with Repository
24
+ * D->>+C: Return injectable decorator with config
25
+ * C->>C: Define DBKeys.CLASS property
26
+ * end
27
+ * @category Decorators
28
+ */
2
29
  export declare function repository<T extends Model>(model: Constructor<T>, nameOverride?: string): any;
@@ -3,12 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ObserverError = void 0;
4
4
  const db_decorators_1 = require("@decaf-ts/db-decorators");
5
5
  /**
6
- * @summary Represents a failure in observer communication
7
- *
8
- * @param {string} msg the error message
9
- *
6
+ * @description Error thrown when observer communication fails.
7
+ * @summary Represents a failure in observer communication between repositories.
8
+ * @param {string|Error} msg - The error message or Error object.
10
9
  * @class ObserverError
11
- * @extends BaseError
10
+ * @category Errors
11
+ * @example
12
+ * try {
13
+ * // Some repository observer operation
14
+ * } catch (error) {
15
+ * if (error instanceof ObserverError) {
16
+ * console.error('Observer communication failed:', error.message);
17
+ * }
18
+ * }
12
19
  */
13
20
  class ObserverError extends db_decorators_1.BaseError {
14
21
  constructor(msg) {
@@ -16,4 +23,4 @@ class ObserverError extends db_decorators_1.BaseError {
16
23
  }
17
24
  }
18
25
  exports.ObserverError = ObserverError;
19
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJyb3JzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3JlcG9zaXRvcnkvZXJyb3JzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLDJEQUFvRDtBQUVwRDs7Ozs7OztHQU9HO0FBQ0gsTUFBYSxhQUFjLFNBQVEseUJBQVM7SUFDMUMsWUFBWSxHQUFtQjtRQUM3QixLQUFLLENBQUMsYUFBYSxDQUFDLElBQUksRUFBRSxHQUFHLEVBQUUsR0FBRyxDQUFDLENBQUM7SUFDdEMsQ0FBQztDQUNGO0FBSkQsc0NBSUMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBCYXNlRXJyb3IgfSBmcm9tIFwiQGRlY2FmLXRzL2RiLWRlY29yYXRvcnNcIjtcblxuLy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HVyZSBpbiBvYnNlcnZlciBjb21tdW5pY2F0aW9uIGJldHdlZW4gcmVwb3NpdG9yaWVzLlxuICogQHBhcmFtIHtzdHJpbmd8RXJyb3J9IG1zZyAtIFRoZSBlcnJvciBtZXNzYWdlIG9yIEVycm9yIG9iamVjdC5cbiAqIEBjbGFzcyBPYnNlcnZlckVycm9yXG4gKiBAY2F0ZWdvcnkgRXJyb3JzXG4gKiBAZXhhbXBsZVxuICogdHJ5IHtcbiAqICAgLy8gU29tZSByZXBvc2l0b3J5IG9ic2VydmVyIG9wZXJhdGlvblxuICogfSBjYXRjaCAoZXJyb3IpIHtcbiAqICAgaWYgKGVycm9yIGluc3RhbmNlb2YgT2JzZXJ2ZXJFcnJvcikge1xuICogICAgIGNvbnNvbGUuZXJyb3IoJ09ic2VydmVyIGNvbW11bmljYXRpb24gZmFpbGVkOicsIGVycm9yLm1lc3NhZ2UpO1xuICogICB9XG4gKiB9XG4gKi9cbmV4cG9ydCBjbGFzcyBPYnNlcnZlckVycm9yIGV4dGVuZHMgQmFzZUVycm9yIHtcbiAgY29uc3RydWN0b3IobXNnOiBzdHJpbmcgfCBFcnJvcikge1xuICAgIHN1cGVyKE9ic2VydmVyRXJyb3IubmFtZSwgbXNnLCA1MDApO1xuICB9XG59XG4iXX0=
@@ -1,11 +1,18 @@
1
1
  import { BaseError } from "@decaf-ts/db-decorators";
2
2
  /**
3
- * @summary Represents a failure in observer communication
4
- *
5
- * @param {string} msg the error message
6
- *
3
+ * @description Error thrown when observer communication fails.
4
+ * @summary Represents a failure in observer communication between repositories.
5
+ * @param {string|Error} msg - The error message or Error object.
7
6
  * @class ObserverError
8
- * @extends BaseError
7
+ * @category Errors
8
+ * @example
9
+ * try {
10
+ * // Some repository observer operation
11
+ * } catch (error) {
12
+ * if (error instanceof ObserverError) {
13
+ * console.error('Observer communication failed:', error.message);
14
+ * }
15
+ * }
9
16
  */
10
17
  export declare class ObserverError extends BaseError {
11
18
  constructor(msg: string | Error);