@decaf-ts/decorator-validation 1.7.1 → 1.7.2

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 (44) hide show
  1. package/README.md +312 -20
  2. package/dist/decorator-validation.cjs +242 -94
  3. package/dist/decorator-validation.esm.cjs +242 -95
  4. package/lib/constants/validation.cjs +6 -8
  5. package/lib/constants/validation.d.ts +4 -6
  6. package/lib/esm/constants/validation.d.ts +4 -6
  7. package/lib/esm/constants/validation.js +6 -8
  8. package/lib/esm/index.d.ts +8 -1
  9. package/lib/esm/index.js +9 -2
  10. package/lib/esm/model/Model.d.ts +164 -40
  11. package/lib/esm/model/Model.js +165 -41
  12. package/lib/esm/model/construction.d.ts +4 -2
  13. package/lib/esm/model/construction.js +4 -2
  14. package/lib/esm/model/decorators.d.ts +25 -1
  15. package/lib/esm/model/decorators.js +26 -2
  16. package/lib/esm/model/types.d.ts +48 -31
  17. package/lib/esm/model/types.js +1 -1
  18. package/lib/esm/utils/decorators.d.ts +7 -12
  19. package/lib/esm/utils/decorators.js +8 -13
  20. package/lib/esm/validation/Validators/decorators.d.ts +1 -1
  21. package/lib/esm/validation/Validators/decorators.js +2 -2
  22. package/lib/esm/validation/Validators/utils.d.ts +4 -0
  23. package/lib/esm/validation/Validators/utils.js +5 -1
  24. package/lib/esm/validation/decorators.d.ts +20 -26
  25. package/lib/esm/validation/decorators.js +21 -27
  26. package/lib/index.cjs +9 -2
  27. package/lib/index.d.ts +8 -1
  28. package/lib/model/Model.cjs +165 -41
  29. package/lib/model/Model.d.ts +164 -40
  30. package/lib/model/construction.cjs +4 -2
  31. package/lib/model/construction.d.ts +4 -2
  32. package/lib/model/decorators.cjs +26 -2
  33. package/lib/model/decorators.d.ts +25 -1
  34. package/lib/model/types.cjs +1 -1
  35. package/lib/model/types.d.ts +48 -31
  36. package/lib/utils/decorators.cjs +8 -13
  37. package/lib/utils/decorators.d.ts +7 -12
  38. package/lib/validation/Validators/decorators.cjs +2 -2
  39. package/lib/validation/Validators/decorators.d.ts +1 -1
  40. package/lib/validation/Validators/utils.cjs +5 -1
  41. package/lib/validation/Validators/utils.d.ts +4 -0
  42. package/lib/validation/decorators.cjs +21 -27
  43. package/lib/validation/decorators.d.ts +20 -26
  44. package/package.json +1 -1
@@ -2,13 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VALIDATION_PARENT_KEY = void 0;
4
4
  /**
5
- * Symbol used to internally track the parent object during nested validation.
5
+ * @description Symbol key for tracking parent-child relationships in validation
6
+ * @summary Symbol used to internally track the parent object during nested validation
6
7
  *
7
- * This key is attached to child objects to provide context about their parent
8
- * in the object hierarchy, enabling validations that depend on parent values.
9
- *
10
- * @constant VALIDATION_PARENT_KEY
11
- * @memberOf module:decorator-validation.Model
8
+ * @const VALIDATION_PARENT_KEY
9
+ * @memberOf module:decorator-validation
12
10
  */
13
- exports.VALIDATION_PARENT_KEY = Symbol("_validationParentRef");
14
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb25zdGFudHMvdmFsaWRhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQTs7Ozs7Ozs7R0FRRztBQUNVLFFBQUEscUJBQXFCLEdBQUcsTUFBTSxDQUFDLHNCQUFzQixDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIFN5bWJvbCB1c2VkIHRvIGludGVybmFsbHkgdHJhY2sgdGhlIHBhcmVudCBvYmplY3QgZHVyaW5nIG5lc3RlZCB2YWxpZGF0aW9uLlxuICpcbiAqIFRoaXMga2V5IGlzIGF0dGFjaGVkIHRvIGNoaWxkIG9iamVjdHMgdG8gcHJvdmlkZSBjb250ZXh0IGFib3V0IHRoZWlyIHBhcmVudFxuICogaW4gdGhlIG9iamVjdCBoaWVyYXJjaHksIGVuYWJsaW5nIHZhbGlkYXRpb25zIHRoYXQgZGVwZW5kIG9uIHBhcmVudCB2YWx1ZXMuXG4gKlxuICogQGNvbnN0YW50IFZBTElEQVRJT05fUEFSRU5UX0tFWVxuICogQG1lbWJlck9mIG1vZHVsZTpkZWNvcmF0b3ItdmFsaWRhdGlvbi5Nb2RlbFxuICovXG5leHBvcnQgY29uc3QgVkFMSURBVElPTl9QQVJFTlRfS0VZID0gU3ltYm9sKFwiX3ZhbGlkYXRpb25QYXJlbnRSZWZcIik7XG4iXX0=
11
+ exports.VALIDATION_PARENT_KEY = Symbol("_parent");
12
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb25zdGFudHMvdmFsaWRhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQTs7Ozs7O0dBTUc7QUFDVSxRQUFBLHFCQUFxQixHQUFHLE1BQU0sQ0FBQyxTQUFTLENBQUMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogQGRlc2NyaXB0aW9uIFN5bWJvbCBrZXkgZm9yIHRyYWNraW5nIHBhcmVudC1jaGlsZCByZWxhdGlvbnNoaXBzIGluIHZhbGlkYXRpb25cbiAqIEBzdW1tYXJ5IFN5bWJvbCB1c2VkIHRvIGludGVybmFsbHkgdHJhY2sgdGhlIHBhcmVudCBvYmplY3QgZHVyaW5nIG5lc3RlZCB2YWxpZGF0aW9uXG4gKlxuICogQGNvbnN0IFZBTElEQVRJT05fUEFSRU5UX0tFWVxuICogQG1lbWJlck9mIG1vZHVsZTpkZWNvcmF0b3ItdmFsaWRhdGlvblxuICovXG5leHBvcnQgY29uc3QgVkFMSURBVElPTl9QQVJFTlRfS0VZID0gU3ltYm9sKFwiX3BhcmVudFwiKTtcbiJdfQ==
@@ -1,10 +1,8 @@
1
1
  /**
2
- * Symbol used to internally track the parent object during nested validation.
2
+ * @description Symbol key for tracking parent-child relationships in validation
3
+ * @summary Symbol used to internally track the parent object during nested validation
3
4
  *
4
- * This key is attached to child objects to provide context about their parent
5
- * in the object hierarchy, enabling validations that depend on parent values.
6
- *
7
- * @constant VALIDATION_PARENT_KEY
8
- * @memberOf module:decorator-validation.Model
5
+ * @const VALIDATION_PARENT_KEY
6
+ * @memberOf module:decorator-validation
9
7
  */
10
8
  export declare const VALIDATION_PARENT_KEY: unique symbol;
@@ -1,10 +1,8 @@
1
1
  /**
2
- * Symbol used to internally track the parent object during nested validation.
2
+ * @description Symbol key for tracking parent-child relationships in validation
3
+ * @summary Symbol used to internally track the parent object during nested validation
3
4
  *
4
- * This key is attached to child objects to provide context about their parent
5
- * in the object hierarchy, enabling validations that depend on parent values.
6
- *
7
- * @constant VALIDATION_PARENT_KEY
8
- * @memberOf module:decorator-validation.Model
5
+ * @const VALIDATION_PARENT_KEY
6
+ * @memberOf module:decorator-validation
9
7
  */
10
8
  export declare const VALIDATION_PARENT_KEY: unique symbol;
@@ -1,11 +1,9 @@
1
1
  /**
2
- * Symbol used to internally track the parent object during nested validation.
2
+ * @description Symbol key for tracking parent-child relationships in validation
3
+ * @summary Symbol used to internally track the parent object during nested validation
3
4
  *
4
- * This key is attached to child objects to provide context about their parent
5
- * in the object hierarchy, enabling validations that depend on parent values.
6
- *
7
- * @constant VALIDATION_PARENT_KEY
8
- * @memberOf module:decorator-validation.Model
5
+ * @const VALIDATION_PARENT_KEY
6
+ * @memberOf module:decorator-validation
9
7
  */
10
- export const VALIDATION_PARENT_KEY = Symbol("_validationParentRef");
11
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jb25zdGFudHMvdmFsaWRh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Y2VzQ29udGVudCI6WyIvKipcbiAqIEBkZXNjcmlwdGlvbiBTeW1ib2wga2V5IGZvciB0cmFja2luZyBwYXJlbnQtY2hpbGQgcmVsYXRpb25zaGlwcyBpbiB2YWxpZGF0aW9uXG4gKiBAc3VtbWFyeSBTeW1ib2wgdXNlZCB0byBpbnRlcm5hbGx5IHRyYWNrIHRoZSBwYXJlbnQgb2JqZWN0IGR1cmluZyBuZXN0ZWQgdmFsaWRhdGlvblxuICpcbiAqIEBjb25zdCBWQUxJREFUSU9OX1BBUkVOVF9LRVlcbiAqIEBtZW1iZXJPZiBtb2R1bGU6ZGVjb3JhdG9yLXZhbGlkYXRpb25cbiAqL1xuZXhwb3J0IGNvbnN0IFZBTElEQVRJT05fUEFSRU5UX0tFWSA9IFN5bWJvbChcIl9wYXJlbnRcIik7XG4iXX0=
@@ -5,7 +5,14 @@
5
5
  * It exposes utility functions, validation decorators, and model-related functionality for
6
6
  * implementing type-safe, declarative validation in TypeScript applications.
7
7
  */
8
+ export * from "./constants";
8
9
  export * from "./utils";
9
10
  export * from "./validation";
10
11
  export * from "./model";
11
- export declare const VERSION = "1.7.1";
12
+ /**
13
+ * @description Current version of the reflection package
14
+ * @summary Stores the semantic version number of the package
15
+ * @const VERSION
16
+ * @memberOf module:decorator-validation
17
+ */
18
+ export declare const VERSION = "1.7.2";
package/lib/esm/index.js CHANGED
@@ -5,8 +5,15 @@
5
5
  * It exposes utility functions, validation decorators, and model-related functionality for
6
6
  * implementing type-safe, declarative validation in TypeScript applications.
7
7
  */
8
+ export * from "./constants";
8
9
  export * from "./utils";
9
10
  export * from "./validation";
10
11
  export * from "./model";
11
- export const VERSION = "1.7.1";
12
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBQ0gsY0FBYyxTQUFTLENBQUM7QUFDeEIsY0FBYyxjQUFjLENBQUM7QUFDN0IsY0FBYyxTQUFTLENBQUM7QUFFeEIsTUFBTSxDQUFDLE1BQU0sT0FBTyxHQUFHLGFBQWEsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogQG1vZHVsZSBkZWNvcmF0b3ItdmFsaWRhdGlvblxuICogQGRlc2NyaXB0aW9uIFR5cGVTY3JpcHQgZGVjb3JhdG9yLWJhc2VkIHZhbGlkYXRpb24gbGlicmFyeVxuICogQHN1bW1hcnkgVGhpcyBtb2R1bGUgcHJvdmlkZXMgYSBjb21wcmVoZW5zaXZlIHZhbGlkYXRpb24gZnJhbWV3b3JrIHVzaW5nIFR5cGVTY3JpcHQgZGVjb3JhdG9ycy5cbiAqIEl0IGV4cG9zZXMgdXRpbGl0eSBmdW5jdGlvbnMsIHZhbGlkYXRpb24gZGVjb3JhdG9ycywgYW5kIG1vZGVsLXJlbGF0ZWQgZnVuY3Rpb25hbGl0eSBmb3JcbiAqIGltcGxlbWVudGluZyB0eXBlLXNhZmUsIGRlY2xhcmF0aXZlIHZhbGlkYXRpb24gaW4gVHlwZVNjcmlwdCBhcHBsaWNhdGlvbnMuXG4gKi9cbmV4cG9ydCAqIGZyb20gXCIuL3V0aWxzXCI7XG5leHBvcnQgKiBmcm9tIFwiLi92YWxpZGF0aW9uXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9tb2RlbFwiO1xuXG5leHBvcnQgY29uc3QgVkVSU0lPTiA9IFwiIyNWRVJTSU9OIyNcIjtcbiJdfQ==
12
+ /**
13
+ * @description Current version of the reflection package
14
+ * @summary Stores the semantic version number of the package
15
+ * @const VERSION
16
+ * @memberOf module:decorator-validation
17
+ */
18
+ export const VERSION = "1.7.2";
19
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cm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IEBzdW1tYXJ5IFN0b3JlcyB0aGUgc2VtYW50aWMgdmVyc2lvbiBudW1iZXIgb2YgdGhlIHBhY2thZ2VcbiAqIEBjb25zdCBWRVJTSU9OXG4gKiBAbWVtYmVyT2YgbW9kdWxlOmRlY29yYXRvci12YWxpZGF0aW9uXG4gKi9cbmV4cG9ydCBjb25zdCBWRVJTSU9OID0gXCIjI1ZFUlNJT04jI1wiO1xuIl19
@@ -131,112 +131,236 @@ export declare function bulkModelRegister<M extends Model>(...models: (Construct
131
131
  export declare abstract class Model implements Validatable, Serializable, Hashable, Comparable<Model> {
132
132
  protected constructor(arg?: ModelArg<Model>);
133
133
  /**
134
- * @summary Validates the object according to its decorated properties
134
+ * @description Validates the model object against its defined validation rules
135
+ * @summary Validates the object according to its decorated properties, returning any validation errors
135
136
  *
136
- * @param {any[]} [exceptions] properties in the object to be ignored for the validation. Marked as 'any' to allow for extension but expects strings
137
+ * @param {any[]} [exceptions] - Properties in the object to be ignored for the validation. Marked as 'any' to allow for extension but expects strings
138
+ * @return {ModelErrorDefinition | undefined} - Returns a ModelErrorDefinition object if validation errors exist, otherwise undefined
137
139
  */
138
140
  hasErrors(...exceptions: any[]): ModelErrorDefinition | undefined;
139
141
  /**
140
- * @summary Compare object equality recursively
141
- * @param {any} obj object to compare to
142
- * @param {string} [exceptions] property names to be excluded from the comparison
142
+ * @description Determines if this model is equal to another object
143
+ * @summary Compare object equality recursively, checking all properties unless excluded
144
+ *
145
+ * @param {any} obj - Object to compare to
146
+ * @param {string[]} [exceptions] - Property names to be excluded from the comparison
147
+ * @return {boolean} - True if objects are equal, false otherwise
143
148
  */
144
149
  equals(obj: any, ...exceptions: string[]): boolean;
145
150
  /**
151
+ * @description Converts the model to a serialized string representation
146
152
  * @summary Returns the serialized model according to the currently defined {@link Serializer}
153
+ *
154
+ * @return {string} - The serialized string representation of the model
147
155
  */
148
156
  serialize(): string;
149
157
  /**
150
- * @summary Override the implementation for js's 'toString()' which sucks...
158
+ * @description Provides a human-readable string representation of the model
159
+ * @summary Override the implementation for js's 'toString()' to provide a more useful representation
160
+ *
161
+ * @return {string} - A string representation of the model including its class name and JSON representation
151
162
  * @override
152
163
  */
153
164
  toString(): string;
154
165
  /**
155
- * @summary Defines a default implementation for object hash. Relies on a very basic implementation based on Java's string hash;
166
+ * @description Generates a hash string for the model object
167
+ * @summary Defines a default implementation for object hash, relying on a basic implementation based on Java's string hash
168
+ *
169
+ * @return {string} - A hash string representing the model
156
170
  */
157
171
  hash(): string;
158
172
  /**
159
- * @summary Deserializes a Model
160
- * @param {string} str
173
+ * @description Converts a serialized string back into a model instance
174
+ * @summary Deserializes a Model from its string representation
161
175
  *
176
+ * @param {string} str - The serialized string to convert back to a model
177
+ * @return {any} - The deserialized model instance
162
178
  * @throws {Error} If it fails to parse the string, or if it fails to build the model
163
179
  */
164
180
  static deserialize(str: string): any;
165
181
  /**
182
+ * @description Copies properties from a source object to a model instance
166
183
  * @summary Repopulates the Object properties with the ones from the new object
167
- * @description Iterates all common properties of obj (if existing) and self, and copies them onto self
168
- *
169
- * @param {T} self
170
- * @param {T | Record<string, any>} [obj]
171
184
  *
185
+ * @template T
186
+ * @param {T} self - The target model instance to update
187
+ * @param {T | Record<string, any>} [obj] - The source object containing properties to copy
188
+ * @return {T} - The updated model instance
172
189
  */
173
190
  static fromObject<T extends Model>(self: T, obj?: T | Record<string, any>): T;
174
191
  /**
175
- * @summary Repopulates the instance with the ones from the new Model Object
176
- * @description Iterates all common properties of obj (if existing) and self, and copies them onto self.
177
- * Is aware of nested Model Objects and rebuilds them also.
178
- * When List properties are decorated with {@link list}, they list items will also be rebuilt
192
+ * @description Copies and rebuilds properties from a source object to a model instance, handling nested models
193
+ * @summary Repopulates the instance with properties from the new Model Object, recursively rebuilding nested models
179
194
  *
180
- * @param {T} self
181
- * @param {T | Record<string, any>} [obj]
195
+ * @template T
196
+ * @param {T} self - The target model instance to update
197
+ * @param {T | Record<string, any>} [obj] - The source object containing properties to copy
198
+ * @return {T} - The updated model instance with rebuilt nested models
182
199
  *
200
+ * @mermaid
201
+ * sequenceDiagram
202
+ * participant C as Client
203
+ * participant M as Model.fromModel
204
+ * participant B as Model.build
205
+ * participant R as Reflection
206
+ *
207
+ * C->>M: fromModel(self, obj)
208
+ * M->>M: Get attributes from self
209
+ * loop For each property
210
+ * M->>M: Copy property from obj to self
211
+ * alt Property is a model
212
+ * M->>M: Check if property is a model
213
+ * M->>B: build(property, modelType)
214
+ * B-->>M: Return built model
215
+ * else Property is a complex type
216
+ * M->>R: Get property decorators
217
+ * R-->>M: Return decorators
218
+ * M->>M: Filter type decorators
219
+ * alt Property is Array/Set with list decorator
220
+ * M->>M: Process each item in collection
221
+ * loop For each item
222
+ * M->>B: build(item, itemModelType)
223
+ * B-->>M: Return built model
224
+ * end
225
+ * else Property is another model type
226
+ * M->>B: build(property, propertyType)
227
+ * B-->>M: Return built model
228
+ * end
229
+ * end
230
+ * end
231
+ * M-->>C: Return updated self
183
232
  */
184
233
  static fromModel<T extends Model>(self: T, obj?: T | Record<string, any>): T;
185
234
  /**
186
- * @summary Sets the Global {@link ModelBuilderFunction}
187
- * @param {ModelBuilderFunction} [builder]
235
+ * @description Configures the global model builder function
236
+ * @summary Sets the Global {@link ModelBuilderFunction} used for building model instances
237
+ *
238
+ * @param {ModelBuilderFunction} [builder] - The builder function to set as the global builder
239
+ * @return {void}
188
240
  */
189
241
  static setBuilder(builder?: ModelBuilderFunction): void;
190
242
  /**
191
- * @summary Retrieves the current global {@link ModelBuilderFunction}
243
+ * @description Retrieves the currently configured global model builder function
244
+ * @summary Returns the current global {@link ModelBuilderFunction} used for building model instances
245
+ *
246
+ * @return {ModelBuilderFunction | undefined} - The current global builder function or undefined if not set
192
247
  */
193
248
  static getBuilder(): ModelBuilderFunction | undefined;
194
249
  /**
195
- * Returns the current {@link ModelRegistryManager}
250
+ * @description Provides access to the current model registry
251
+ * @summary Returns the current {@link ModelRegistryManager} instance, creating one if it doesn't exist
196
252
  *
197
- * @return ModelRegistry, defaults to {@link ModelRegistryManager}
253
+ * @return {ModelRegistry<any>} - The current model registry, defaults to a new {@link ModelRegistryManager} if not set
254
+ * @private
198
255
  */
199
256
  private static getRegistry;
200
257
  /**
201
- * Returns the current actingModelRegistry
258
+ * @description Configures the model registry to be used by the Model system
259
+ * @summary Sets the current model registry to a custom implementation
202
260
  *
203
- * @param {BuilderRegistry} modelRegistry the new implementation of Registry
261
+ * @param {BuilderRegistry<any>} modelRegistry - The new implementation of Registry to use
262
+ * @return {void}
204
263
  */
205
264
  static setRegistry(modelRegistry: BuilderRegistry<any>): void;
206
265
  /**
207
- * @summary register new Models
208
- * @param {any} constructor
209
- * @param {string} [name] when not defined, the name of the constructor will be used
266
+ * @description Registers a model constructor with the model registry
267
+ * @summary Registers new model classes to make them available for serialization and deserialization
268
+ *
269
+ * @template T
270
+ * @param {ModelConstructor<T>} constructor - The model constructor to register
271
+ * @param {string} [name] - Optional name to register the constructor under, defaults to constructor.name
272
+ * @return {void}
210
273
  *
211
274
  * @see ModelRegistry
212
275
  */
213
276
  static register<T extends Model>(constructor: ModelConstructor<T>, name?: string): void;
214
277
  /**
215
- * @summary Gets a registered Model {@link ModelConstructor}
216
- * @param {string} name
278
+ * @description Retrieves a registered model constructor by name
279
+ * @summary Gets a registered Model {@link ModelConstructor} from the model registry
280
+ *
281
+ * @template T
282
+ * @param {string} name - The name of the model constructor to retrieve
283
+ * @return {ModelConstructor<T> | undefined} - The model constructor if found, undefined otherwise
217
284
  *
218
285
  * @see ModelRegistry
219
286
  */
220
287
  static get<T extends Model>(name: string): ModelConstructor<T> | undefined;
221
288
  /**
222
- * @param {Record<string, any>} obj
223
- * @param {string} [clazz] when provided, it will attempt to find the matching constructor
289
+ * @description Creates a model instance from a plain object
290
+ * @summary Builds a model instance using the model registry, optionally specifying the model class
224
291
  *
225
- * @throws Error If clazz is not found, or obj is not a {@link Model} meaning it has no {@link ModelKeys.ANCHOR} property
292
+ * @template T
293
+ * @param {Record<string, any>} obj - The source object to build the model from
294
+ * @param {string} [clazz] - When provided, it will attempt to find the matching constructor by name
295
+ * @return {T} - The built model instance
296
+ * @throws {Error} If clazz is not found, or obj is not a {@link Model} meaning it has no {@link ModelKeys.ANCHOR} property
226
297
  *
227
298
  * @see ModelRegistry
228
299
  */
229
300
  static build<T extends Model>(obj?: Record<string, any>, clazz?: string): T;
301
+ /**
302
+ * @description Retrieves the model metadata from a model instance
303
+ * @summary Gets the metadata associated with a model instance, typically the model class name
304
+ *
305
+ * @template M
306
+ * @param {M} model - The model instance to get metadata from
307
+ * @return {string} - The model metadata (typically the class name)
308
+ */
230
309
  static getMetadata<M extends Model>(model: M): any;
310
+ /**
311
+ * @description Retrieves all attribute names from a model class or instance
312
+ * @summary Gets all attributes defined in a model, traversing the prototype chain to include inherited attributes
313
+ *
314
+ * @template V
315
+ * @param {Constructor<V> | V} model - The model class or instance to get attributes from
316
+ * @return {string[]} - Array of attribute names defined in the model
317
+ */
231
318
  static getAttributes<V extends Model>(model: Constructor<V> | V): string[];
319
+ /**
320
+ * @description Compares two model instances for equality
321
+ * @summary Determines if two model instances are equal by comparing their properties
322
+ *
323
+ * @template M
324
+ * @param {M} obj1 - First model instance to compare
325
+ * @param {M} obj2 - Second model instance to compare
326
+ * @param {any[]} [exceptions] - Property names to exclude from comparison
327
+ * @return {boolean} - True if the models are equal, false otherwise
328
+ */
232
329
  static equals<M extends Model>(obj1: M, obj2: M, ...exceptions: any[]): boolean;
330
+ /**
331
+ * @description Validates a model instance against its validation rules
332
+ * @summary Checks if a model has validation errors, optionally ignoring specified properties
333
+ *
334
+ * @template M
335
+ * @param {M} model - The model instance to validate
336
+ * @param {string[]} [propsToIgnore] - Properties to exclude from validation
337
+ * @return {ModelErrorDefinition | undefined} - Returns validation errors if any, otherwise undefined
338
+ */
233
339
  static hasErrors<M extends Model>(model: M, ...propsToIgnore: string[]): ModelErrorDefinition | undefined;
340
+ /**
341
+ * @description Converts a model instance to a serialized string
342
+ * @summary Serializes a model instance using the configured serializer or the default one
343
+ *
344
+ * @template M
345
+ * @param {M} model - The model instance to serialize
346
+ * @return {string} - The serialized string representation of the model
347
+ */
234
348
  static serialize<M extends Model>(model: M): any;
349
+ /**
350
+ * @description Generates a hash string for a model instance
351
+ * @summary Creates a hash representation of a model using the configured algorithm or the default one
352
+ *
353
+ * @template M
354
+ * @param {M} model - The model instance to hash
355
+ * @return {string} - The hash string representing the model
356
+ */
235
357
  static hash<M extends Model>(model: M): any;
236
358
  /**
359
+ * @description Creates a metadata key for use with the Reflection API
237
360
  * @summary Builds the key to store as Metadata under Reflections
238
- * @description concatenates {@link ModelKeys#REFLECT} with the provided key
239
- * @param {string} str
361
+ *
362
+ * @param {string} str - The base key to concatenate with the model reflection prefix
363
+ * @return {string} - The complete metadata key
240
364
  */
241
365
  static key(str: string): string;
242
366
  /**
@@ -264,12 +388,12 @@ export declare abstract class Model implements Validatable, Serializable, Hashab
264
388
  /**
265
389
  * @description Checks if a property of a model is itself a model or has a model type
266
390
  * @summary Determines whether a specific property of a model instance is either a model instance
267
- * or has a type that is registered as a model. This function is used for model serialization
268
- * and deserialization to properly handle nested models.
269
- * @template M extends {@link Model}
391
+ * or has a type that is registered as a model
392
+ *
393
+ * @template M
270
394
  * @param {M} target - The model instance to check
271
395
  * @param {string} attribute - The property name to check
272
- * @return {boolean | string | undefined} Returns true if the property is a model instance,
396
+ * @return {boolean | string | undefined} - Returns true if the property is a model instance,
273
397
  * the model name if the property has a model type, or undefined if not a model
274
398
  */
275
399
  static isPropertyModel<M extends Model>(target: M, attribute: string): boolean | string | undefined;