@tsed/json-mapper 8.22.0 → 8.24.0

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 (43) hide show
  1. package/lib/esm/components/PrimitiveMapper.js +3 -0
  2. package/lib/esm/decorators/afterDeserialize.js +1 -1
  3. package/lib/esm/decorators/beforeDeserialize.js +1 -1
  4. package/lib/esm/decorators/jsonMapper.js +14 -3
  5. package/lib/esm/decorators/onDeserialize.js +1 -1
  6. package/lib/esm/decorators/onSerialize.js +1 -1
  7. package/lib/esm/domain/JsonDeserializer.js +4 -0
  8. package/lib/esm/domain/JsonMapperCompiler.js +5 -0
  9. package/lib/esm/domain/JsonMapperSettings.js +3 -0
  10. package/lib/esm/domain/JsonMapperTypesContainer.js +2 -2
  11. package/lib/esm/domain/JsonSerializer.js +6 -0
  12. package/lib/esm/domain/Writer.js +4 -0
  13. package/lib/esm/hooks/alterAfterDeserialize.js +3 -0
  14. package/lib/esm/hooks/alterBeforeDeserialize.js +4 -0
  15. package/lib/esm/hooks/alterOnDeserialize.js +3 -0
  16. package/lib/esm/hooks/alterOnSerialize.js +4 -0
  17. package/lib/esm/utils/deserialize.js +11 -0
  18. package/lib/esm/utils/getObjectProperties.js +3 -0
  19. package/lib/esm/utils/serialize.js +12 -0
  20. package/lib/types/components/PrimitiveMapper.d.ts +3 -0
  21. package/lib/types/decorators/afterDeserialize.d.ts +1 -1
  22. package/lib/types/decorators/beforeDeserialize.d.ts +1 -1
  23. package/lib/types/decorators/jsonMapper.d.ts +14 -3
  24. package/lib/types/decorators/onDeserialize.d.ts +1 -1
  25. package/lib/types/decorators/onSerialize.d.ts +1 -1
  26. package/lib/types/domain/JsonDeserializer.d.ts +4 -0
  27. package/lib/types/domain/JsonDeserializerOptions.d.ts +4 -0
  28. package/lib/types/domain/JsonMapperCompiler.d.ts +15 -0
  29. package/lib/types/domain/JsonMapperGlobalOptions.d.ts +3 -0
  30. package/lib/types/domain/JsonMapperSettings.d.ts +3 -0
  31. package/lib/types/domain/JsonMapperTypesContainer.d.ts +2 -2
  32. package/lib/types/domain/JsonSerializer.d.ts +6 -0
  33. package/lib/types/domain/JsonSerializerOptions.d.ts +4 -0
  34. package/lib/types/domain/Writer.d.ts +4 -0
  35. package/lib/types/hooks/alterAfterDeserialize.d.ts +3 -0
  36. package/lib/types/hooks/alterBeforeDeserialize.d.ts +4 -0
  37. package/lib/types/hooks/alterOnDeserialize.d.ts +3 -0
  38. package/lib/types/hooks/alterOnSerialize.d.ts +4 -0
  39. package/lib/types/interfaces/JsonMapperMethods.d.ts +11 -8
  40. package/lib/types/utils/deserialize.d.ts +11 -0
  41. package/lib/types/utils/getObjectProperties.d.ts +3 -0
  42. package/lib/types/utils/serialize.d.ts +12 -0
  43. package/package.json +5 -5
@@ -4,6 +4,9 @@ import { JsonMapper } from "../decorators/jsonMapper.js";
4
4
  function isNullish(data) {
5
5
  return [null, "null"].includes(data);
6
6
  }
7
+ /**
8
+ * Error thrown when a primitive conversion cannot be performed safely.
9
+ */
7
10
  export class CastError extends Error {
8
11
  constructor(message) {
9
12
  super(`Cast error. ${message}`);
@@ -2,7 +2,7 @@ import { JsonEntityFn } from "@tsed/schema";
2
2
  /**
3
3
  * Call the function after JsonMapper.
4
4
  *
5
- * ## Example
5
+ * ### Example
6
6
  *
7
7
  * ```typescript
8
8
  * @AfterDeserialize((data: Model) => { // After deserialize get the instance class
@@ -2,7 +2,7 @@ import { JsonEntityFn } from "@tsed/schema";
2
2
  /**
3
3
  * Call the function before JsonMapper.
4
4
  *
5
- * ## Example
5
+ * ### Example
6
6
  *
7
7
  * ```typescript
8
8
  * @BeforeDeserialize((data: Record<string, unknown>) => { // Before deserialize get the data
@@ -1,8 +1,19 @@
1
1
  import { registerJsonTypeMapper } from "../domain/JsonMapperTypesContainer.js";
2
2
  /**
3
- * Register a new JsonMapper Type
4
- * @param types
5
- * @constructor
3
+ * Register a class as the mapper responsible for the given primitive/class tokens.
4
+ * The decorator instantiates the mapper and stores it inside the JSON mapper types container.
5
+ *
6
+ * ### Example
7
+ *
8
+ * ```ts
9
+ * @JsonMapper(MyCustomType)
10
+ * export class MyCustomTypeMapper implements JsonMapperMethods {
11
+ * serialize() {/* ... *\/}
12
+ * deserialize() {/* ... *\/}
13
+ * }
14
+ * ```
15
+ *
16
+ * @param types One or more constructors/symbols handled by the mapper.
6
17
  */
7
18
  export function JsonMapper(...types) {
8
19
  return (target) => {
@@ -2,7 +2,7 @@ import { JsonEntityFn } from "@tsed/schema";
2
2
  /**
3
3
  * Call the function before property deserialization.
4
4
  *
5
- * ## Example
5
+ * ### Example
6
6
  *
7
7
  * ```typescript
8
8
  * class Model {
@@ -2,7 +2,7 @@ import { JsonEntityFn } from "@tsed/schema";
2
2
  /**
3
3
  * Call the function before property serialization.
4
4
  *
5
- * ## Example
5
+ * ### Example
6
6
  *
7
7
  * ```typescript
8
8
  * class Model {
@@ -26,6 +26,10 @@ function mapParamStoreOptions(store, options) {
26
26
  generics: store.parameter.schema().getGenericOf()
27
27
  };
28
28
  }
29
+ /**
30
+ * Deserializes raw JSON data into class instances based on schema metadata,
31
+ * handling collections, discriminators, hooks, and registered type mappers.
32
+ */
29
33
  export class JsonDeserializer extends JsonMapperCompiler {
30
34
  constructor() {
31
35
  super();
@@ -1,4 +1,9 @@
1
1
  import { ancestorsOf, classOf, getRandomId, hasJsonMethod, isClass, isCollection, isDate, isMomentObject, isMongooseObject, isNil, isObject, isObjectID, isString, nameOf, objectKeys } from "@tsed/core";
2
+ /**
3
+ * Base compiler that turns schema metadata into executable (de)serialization functions.
4
+ * Subclasses supply `map`, `alterValue`, and `createMapper` implementations to specialize
5
+ * the pipeline for serialization or deserialization.
6
+ */
2
7
  export class JsonMapperCompiler {
3
8
  constructor() {
4
9
  /**
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Default runtime settings applied by the JSON mapper pipeline.
3
+ */
1
4
  export const JsonMapperSettings = {
2
5
  disableUnsecureConstructor: true,
3
6
  additionalProperties: false,
@@ -4,13 +4,13 @@
4
4
  // tslint:disable-next-line:variable-name
5
5
  const JsonMapperTypesContainer = new Map();
6
6
  /**
7
- * @ignore
7
+ * Register a mapper class for a specific primitive/complex type so it can be reused by the serializers.
8
8
  */
9
9
  export function registerJsonTypeMapper(type, token) {
10
10
  JsonMapperTypesContainer.set(type, new token());
11
11
  }
12
12
  /**
13
- * @ignore
13
+ * Retrieve the registry of custom JSON mapper instances keyed by the types they support.
14
14
  */
15
15
  export function getJsonMapperTypes() {
16
16
  return JsonMapperTypesContainer;
@@ -19,6 +19,12 @@ function getBestType(type, obj) {
19
19
  function varKey(k) {
20
20
  return `__${k}`;
21
21
  }
22
+ /**
23
+ * Serializes data structures according to the metadata captured by `@tsed/schema`.
24
+ *
25
+ * The serializer walks entity schemas, applies hooks, honors alias/group rules, and falls back to the
26
+ * registered type mappers (e.g., components in `src/components`).
27
+ */
22
28
  export class JsonSerializer extends JsonMapperCompiler {
23
29
  constructor() {
24
30
  super();
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Tiny utility used by the mapper compilers to build executable arrow functions as strings.
3
+ * It provides helpers for scoping, branching, and composing mapper fragments before `eval`.
4
+ */
1
5
  export class Writer {
2
6
  static { this.object = {
3
7
  assign(...args) {
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Trigger the `afterDeserialize` lifecycle in order to finalize instances after mapping.
3
+ */
1
4
  export function alterAfterDeserialize(data, schema, options) {
2
5
  return schema?.$hooks?.alter("afterDeserialize", data, [options]);
3
6
  }
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Trigger the `beforeDeserialize` hooks declared on the schema to massage raw payloads
3
+ * prior to property mapping.
4
+ */
1
5
  export function alterBeforeDeserialize(data, schema, options) {
2
6
  return schema?.$hooks?.alter("beforeDeserialize", data, [options]);
3
7
  }
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Execute the `onDeserialize` hooks registered on a schema before writing the value onto the target.
3
+ */
1
4
  export function alterOnDeserialize(schema, value, options) {
2
5
  return schema.$hooks.alter("onDeserialize", value, [options]);
3
6
  }
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Execute the `onSerialize` hooks registered on a schema before emitting a value.
3
+ * Used internally by the serializer when a property exposes lifecycle hooks.
4
+ */
1
5
  export function alterOnSerialize(schema, value, options) {
2
6
  return schema.$hooks.alter("onSerialize", value, [options]);
3
7
  }
@@ -3,6 +3,17 @@ import "../components/PrimitiveMapper.js";
3
3
  import "../components/SymbolMapper.js";
4
4
  import { JsonDeserializer } from "../domain/JsonDeserializer.js";
5
5
  const deserializer = new JsonDeserializer();
6
+ /**
7
+ * Deserialize arbitrary data into the provided model type using the shared `JsonDeserializer`.
8
+ *
9
+ * ### Example
10
+ *
11
+ * ```ts
12
+ * import {deserialize} from "@tsed/json-mapper";
13
+ *
14
+ * const model = deserialize<UserModel>(payload, {type: UserModel, useAlias: true});
15
+ * ```
16
+ */
6
17
  export function deserialize(input, options) {
7
18
  return deserializer.map(input, options);
8
19
  }
@@ -1,4 +1,7 @@
1
1
  import { isFunction } from "@tsed/core";
2
+ /**
3
+ * Return enumerable entries of an object while skipping function values (methods/getters).
4
+ */
2
5
  export function getObjectProperties(obj) {
3
6
  return Object.entries(obj).filter(([, value]) => !isFunction(value));
4
7
  }
@@ -3,6 +3,18 @@ import "../components/PrimitiveMapper.js";
3
3
  import "../components/SymbolMapper.js";
4
4
  import { JsonSerializer } from "../domain/JsonSerializer.js";
5
5
  const serializer = new JsonSerializer();
6
+ /**
7
+ * Serialize any value using the shared `JsonSerializer` instance.
8
+ * Respects schema metadata, hooks, aliases, and registered custom mappers.
9
+ *
10
+ * ### Example
11
+ *
12
+ * ```ts
13
+ * import {serialize} from "@tsed/json-mapper";
14
+ *
15
+ * const payload = serialize(model, {type: UserModel, useAlias: true});
16
+ * ```
17
+ */
6
18
  export function serialize(input, options) {
7
19
  return serializer.map(input, options);
8
20
  }
@@ -1,4 +1,7 @@
1
1
  import { JsonMapperCtx, JsonMapperMethods } from "../interfaces/JsonMapperMethods.js";
2
+ /**
3
+ * Error thrown when a primitive conversion cannot be performed safely.
4
+ */
2
5
  export declare class CastError extends Error {
3
6
  name: string;
4
7
  constructor(message: string);
@@ -5,7 +5,7 @@ export interface AfterDeserializeCallback {
5
5
  /**
6
6
  * Call the function after JsonMapper.
7
7
  *
8
- * ## Example
8
+ * ### Example
9
9
  *
10
10
  * ```typescript
11
11
  * @AfterDeserialize((data: Model) => { // After deserialize get the instance class
@@ -5,7 +5,7 @@ export interface BeforeDeserializeCallback {
5
5
  /**
6
6
  * Call the function before JsonMapper.
7
7
  *
8
- * ## Example
8
+ * ### Example
9
9
  *
10
10
  * ```typescript
11
11
  * @BeforeDeserialize((data: Record<string, unknown>) => { // Before deserialize get the data
@@ -1,7 +1,18 @@
1
1
  import { Type } from "@tsed/core";
2
2
  /**
3
- * Register a new JsonMapper Type
4
- * @param types
5
- * @constructor
3
+ * Register a class as the mapper responsible for the given primitive/class tokens.
4
+ * The decorator instantiates the mapper and stores it inside the JSON mapper types container.
5
+ *
6
+ * ### Example
7
+ *
8
+ * ```ts
9
+ * @JsonMapper(MyCustomType)
10
+ * export class MyCustomTypeMapper implements JsonMapperMethods {
11
+ * serialize() {/* ... *\/}
12
+ * deserialize() {/* ... *\/}
13
+ * }
14
+ * ```
15
+ *
16
+ * @param types One or more constructors/symbols handled by the mapper.
6
17
  */
7
18
  export declare function JsonMapper(...types: (any | Type)[]): ClassDecorator;
@@ -5,7 +5,7 @@ export interface OnDeserializeCallback {
5
5
  /**
6
6
  * Call the function before property deserialization.
7
7
  *
8
- * ## Example
8
+ * ### Example
9
9
  *
10
10
  * ```typescript
11
11
  * class Model {
@@ -5,7 +5,7 @@ export interface OnSerializeCallback {
5
5
  /**
6
6
  * Call the function before property serialization.
7
7
  *
8
- * ## Example
8
+ * ### Example
9
9
  *
10
10
  * ```typescript
11
11
  * class Model {
@@ -1,6 +1,10 @@
1
1
  import { Type } from "@tsed/core";
2
2
  import { JsonDeserializerOptions } from "./JsonDeserializerOptions.js";
3
3
  import { CachedJsonMapper, JsonMapperCompiler } from "./JsonMapperCompiler.js";
4
+ /**
5
+ * Deserializes raw JSON data into class instances based on schema metadata,
6
+ * handling collections, discriminators, hooks, and registered type mappers.
7
+ */
4
8
  export declare class JsonDeserializer extends JsonMapperCompiler<JsonDeserializerOptions> {
5
9
  /**
6
10
  * Cached classes by his id
@@ -2,6 +2,10 @@ import { MetadataTypes, Type } from "@tsed/core";
2
2
  import { type GenericsMap, JsonEntityStore } from "@tsed/schema";
3
3
  import { JsonMapperMethods } from "../interfaces/JsonMapperMethods.js";
4
4
  import { JsonMapperGlobalOptions } from "./JsonMapperGlobalOptions.js";
5
+ /**
6
+ * Options accepted by the `JsonDeserializer`. They describe the target type,
7
+ * collection strategy, additional mapper types, and hook configuration used while materializing data.
8
+ */
5
9
  export interface JsonDeserializerOptions<T = any, C = any> extends MetadataTypes<T, C>, JsonMapperGlobalOptions {
6
10
  /**
7
11
  * Types used to map complex types (Symbol, Array, Set, Map)
@@ -1,11 +1,26 @@
1
1
  import { Type } from "@tsed/core";
2
2
  import { JsonSchema } from "@tsed/schema";
3
+ /**
4
+ * Signature exposed by compiled mappers. They accept an input value plus contextual options
5
+ * and return the serialized/deserialized result.
6
+ */
3
7
  export type JsonMapperCallback<Options> = (input: any, options?: Options) => any;
8
+ /**
9
+ * Executable mapper plus its unique identifier stored in the compiler cache.
10
+ */
4
11
  export type CachedJsonMapper<Options> = {
5
12
  id: string;
6
13
  fn: JsonMapperCallback<Options>;
7
14
  };
15
+ /**
16
+ * Cached mapper registry keyed by the groups fingerprint generated for a schema.
17
+ */
8
18
  export type CachedGroupsJsonMapper<Options> = Map<string, CachedJsonMapper<Options>>;
19
+ /**
20
+ * Base compiler that turns schema metadata into executable (de)serialization functions.
21
+ * Subclasses supply `map`, `alterValue`, and `createMapper` implementations to specialize
22
+ * the pipeline for serialization or deserialization.
23
+ */
9
24
  export declare abstract class JsonMapperCompiler<Options extends Record<string, any> = any> {
10
25
  /**
11
26
  * Cached mappers metadata
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Shared configuration flags used by both serialization and deserialization flows.
3
+ */
1
4
  export interface JsonMapperGlobalOptions {
2
5
  /**
3
6
  * JsonMapper additional property policy. (see [JsonMapper](/docs/json-mapper.md))
@@ -1,2 +1,5 @@
1
1
  import type { JsonMapperGlobalOptions } from "./JsonMapperGlobalOptions.js";
2
+ /**
3
+ * Default runtime settings applied by the JSON mapper pipeline.
4
+ */
2
5
  export declare const JsonMapperSettings: JsonMapperGlobalOptions;
@@ -1,10 +1,10 @@
1
1
  import { Type } from "@tsed/core";
2
2
  import { JsonMapperMethods } from "../interfaces/JsonMapperMethods.js";
3
3
  /**
4
- * @ignore
4
+ * Register a mapper class for a specific primitive/complex type so it can be reused by the serializers.
5
5
  */
6
6
  export declare function registerJsonTypeMapper(type: Type<any> | Symbol | string, token: Type<JsonMapperMethods>): void;
7
7
  /**
8
- * @ignore
8
+ * Retrieve the registry of custom JSON mapper instances keyed by the types they support.
9
9
  */
10
10
  export declare function getJsonMapperTypes(): Map<Type<any> | Symbol | string, JsonMapperMethods>;
@@ -1,6 +1,12 @@
1
1
  import { Type } from "@tsed/core";
2
2
  import { JsonMapperCompiler } from "./JsonMapperCompiler.js";
3
3
  import { JsonSerializerOptions } from "./JsonSerializerOptions.js";
4
+ /**
5
+ * Serializes data structures according to the metadata captured by `@tsed/schema`.
6
+ *
7
+ * The serializer walks entity schemas, applies hooks, honors alias/group rules, and falls back to the
8
+ * registered type mappers (e.g., components in `src/components`).
9
+ */
4
10
  export declare class JsonSerializer extends JsonMapperCompiler<JsonSerializerOptions> {
5
11
  constructor();
6
12
  map(input: any, options?: JsonSerializerOptions): any;
@@ -1,6 +1,10 @@
1
1
  import { MetadataTypes, Type } from "@tsed/core";
2
2
  import { JsonMapperMethods } from "../interfaces/JsonMapperMethods.js";
3
3
  import { JsonMapperGlobalOptions } from "./JsonMapperGlobalOptions.js";
4
+ /**
5
+ * Options accepted by the `JsonSerializer`. They describe the target type, alias strategy,
6
+ * additional type mappers, and group handling.
7
+ */
4
8
  export interface JsonSerializerOptions<T = any, C = any> extends MetadataTypes<T, C>, Pick<JsonMapperGlobalOptions, "strictGroups"> {
5
9
  /**
6
10
  * Types used to map complex types (Symbol, Number, String, etc...)
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Tiny utility used by the mapper compilers to build executable arrow functions as strings.
3
+ * It provides helpers for scoping, branching, and composing mapper fragments before `eval`.
4
+ */
1
5
  export declare class Writer {
2
6
  static object: {
3
7
  assign(...args: string[]): string;
@@ -1,4 +1,7 @@
1
1
  import type { Hooks } from "@tsed/hooks";
2
+ /**
3
+ * Trigger the `afterDeserialize` lifecycle in order to finalize instances after mapping.
4
+ */
2
5
  export declare function alterAfterDeserialize(data: any, schema: {
3
6
  $hooks: Hooks;
4
7
  }, options: any): any;
@@ -1,4 +1,8 @@
1
1
  import type { Hooks } from "@tsed/hooks";
2
+ /**
3
+ * Trigger the `beforeDeserialize` hooks declared on the schema to massage raw payloads
4
+ * prior to property mapping.
5
+ */
2
6
  export declare function alterBeforeDeserialize(data: any, schema: {
3
7
  $hooks: Hooks;
4
8
  }, options: any): any;
@@ -1,2 +1,5 @@
1
1
  import { JsonHookContext, JsonSchema } from "@tsed/schema";
2
+ /**
3
+ * Execute the `onDeserialize` hooks registered on a schema before writing the value onto the target.
4
+ */
2
5
  export declare function alterOnDeserialize(schema: JsonSchema, value: any, options: JsonHookContext): any;
@@ -1,2 +1,6 @@
1
1
  import { JsonHookContext, JsonSchema } from "@tsed/schema";
2
+ /**
3
+ * Execute the `onSerialize` hooks registered on a schema before emitting a value.
4
+ * Used internally by the serializer when a property exposes lifecycle hooks.
5
+ */
2
6
  export declare function alterOnSerialize(schema: JsonSchema, value: any, options: JsonHookContext): any;
@@ -1,4 +1,7 @@
1
1
  import { Type } from "@tsed/core";
2
+ /**
3
+ * Runtime context passed to mapper methods so they can inspect target types, collection wrappers, and format options.
4
+ */
2
5
  export interface JsonMapperCtx<T = any, C = any> {
3
6
  collectionType: Type<C> | undefined;
4
7
  type: Type<T> | T;
@@ -7,22 +10,22 @@ export interface JsonMapperCtx<T = any, C = any> {
7
10
  format?: string;
8
11
  };
9
12
  }
13
+ /**
14
+ * Function used to delegate to the next mapper in the chain (e.g., nested serialization).
15
+ */
10
16
  export interface JsonMapperNext {
11
17
  (obj: any): any;
12
18
  }
19
+ /**
20
+ * Contract implemented by every custom JSON mapper.
21
+ */
13
22
  export interface JsonMapperMethods {
14
23
  /**
15
- *
16
- * @param obj
17
- * @param {JsonMapperNext} ctx
18
- * @returns {any}
24
+ * Transform raw data into the target type or collection item.
19
25
  */
20
26
  deserialize<T = any, C = any>(obj: any, ctx: JsonMapperCtx<T, C>): any;
21
27
  /**
22
- *
23
- * @param obj
24
- * @param ctx
25
- * @returns {any}
28
+ * Transform a runtime value into its serialized representation.
26
29
  */
27
30
  serialize(obj: any, ctx: JsonMapperCtx<any>): any;
28
31
  }
@@ -2,4 +2,15 @@ import "../components/DateMapper.js";
2
2
  import "../components/PrimitiveMapper.js";
3
3
  import "../components/SymbolMapper.js";
4
4
  import { JsonDeserializerOptions } from "../domain/JsonDeserializerOptions.js";
5
+ /**
6
+ * Deserialize arbitrary data into the provided model type using the shared `JsonDeserializer`.
7
+ *
8
+ * ### Example
9
+ *
10
+ * ```ts
11
+ * import {deserialize} from "@tsed/json-mapper";
12
+ *
13
+ * const model = deserialize<UserModel>(payload, {type: UserModel, useAlias: true});
14
+ * ```
15
+ */
5
16
  export declare function deserialize<Model = any>(input: any, options?: JsonDeserializerOptions): Model;
@@ -1 +1,4 @@
1
+ /**
2
+ * Return enumerable entries of an object while skipping function values (methods/getters).
3
+ */
1
4
  export declare function getObjectProperties(obj: any): [string, any][];
@@ -2,4 +2,16 @@ import "../components/DateMapper.js";
2
2
  import "../components/PrimitiveMapper.js";
3
3
  import "../components/SymbolMapper.js";
4
4
  import { JsonSerializerOptions } from "../domain/JsonSerializerOptions.js";
5
+ /**
6
+ * Serialize any value using the shared `JsonSerializer` instance.
7
+ * Respects schema metadata, hooks, aliases, and registered custom mappers.
8
+ *
9
+ * ### Example
10
+ *
11
+ * ```ts
12
+ * import {serialize} from "@tsed/json-mapper";
13
+ *
14
+ * const payload = serialize(model, {type: UserModel, useAlias: true});
15
+ * ```
16
+ */
5
17
  export declare function serialize(input: any, options?: JsonSerializerOptions): any;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tsed/json-mapper",
3
3
  "description": "Json mapper module for Ts.ED Framework",
4
4
  "type": "module",
5
- "version": "8.22.0",
5
+ "version": "8.24.0",
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
@@ -41,10 +41,10 @@
41
41
  "tslib": "2.7.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@tsed/barrels": "8.22.0",
45
- "@tsed/core": "8.22.0",
46
- "@tsed/schema": "8.22.0",
47
- "@tsed/typescript": "8.22.0",
44
+ "@tsed/barrels": "8.24.0",
45
+ "@tsed/core": "8.24.0",
46
+ "@tsed/schema": "8.24.0",
47
+ "@tsed/typescript": "8.24.0",
48
48
  "eslint": "9.12.0",
49
49
  "typescript": "5.9.3",
50
50
  "vitest": "3.2.4"