@tsed/json-mapper 8.33.0 → 8.35.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.
@@ -1,6 +1,6 @@
1
1
  import { __decorate } from "tslib";
2
- import { isBoolean } from "@tsed/core";
3
2
  import { JsonMapper } from "../decorators/jsonMapper.js";
3
+ import { isBoolean } from "@tsed/core";
4
4
  /**
5
5
  * Mapper for `Date` type.
6
6
  * @jsonmapper
@@ -1,6 +1,6 @@
1
1
  import { __decorate } from "tslib";
2
- import { nameOf } from "@tsed/core";
3
2
  import { JsonMapper } from "../decorators/jsonMapper.js";
3
+ import { nameOf } from "@tsed/core";
4
4
  function isNullish(data) {
5
5
  return [null, "null"].includes(data);
6
6
  }
@@ -1,5 +1,5 @@
1
- import { isBoolean } from "@tsed/core";
2
1
  import { JsonMapper } from "../decorators/jsonMapper.js";
2
+ import { isBoolean } from "@tsed/core";
3
3
  /**
4
4
  * Older runtimes (e.g. Node < 24) don't expose it, so it may be `undefined` at import time.
5
5
  */
@@ -1,12 +1,12 @@
1
+ import { JsonMapperCompiler } from "./JsonMapperCompiler.js";
2
+ import { JsonParameterStore, JsonSchema, VendorKeys, getPropertiesStores, s } from "@tsed/schema";
1
3
  import { classOf, isArray, isBoolean, isEmpty, isNil, nameOf, objectKeys } from "@tsed/core";
2
- import { getPropertiesStores, JsonEntityStore, JsonParameterStore, JsonSchema, VendorKeys } from "@tsed/schema";
4
+ import { JsonMapperSettings } from "./JsonMapperSettings.js";
5
+ import { Writer } from "./Writer.js";
3
6
  import { alterAfterDeserialize } from "../hooks/alterAfterDeserialize.js";
4
7
  import { alterBeforeDeserialize } from "../hooks/alterBeforeDeserialize.js";
5
8
  import { alterOnDeserialize } from "../hooks/alterOnDeserialize.js";
6
- import { JsonMapperCompiler } from "./JsonMapperCompiler.js";
7
- import { JsonMapperSettings } from "./JsonMapperSettings.js";
8
9
  import { getJsonMapperTypes } from "./JsonMapperTypesContainer.js";
9
- import { Writer } from "./Writer.js";
10
10
  function isDeserializable(obj, options) {
11
11
  if ((!!options.collectionType && isNil(obj)) || obj === undefined) {
12
12
  return false;
@@ -85,7 +85,7 @@ export class JsonDeserializer extends JsonMapperCompiler {
85
85
  }
86
86
  }
87
87
  createMapper(model, id, groups) {
88
- const entity = JsonEntityStore.from(model);
88
+ const entity = s.store(model);
89
89
  const properties = new Set();
90
90
  const schemaProperties = [...getPropertiesStores(entity).values()];
91
91
  const writer = new Writer().arrow("input", "options");
@@ -1,11 +1,11 @@
1
+ import { getPropertiesStores, s } from "@tsed/schema";
1
2
  import { classOf, hasJsonMethod, isArray, isBoolean, isClassObject, isCollection, isDate, isMomentObject, isMongooseObject, isNil, isObject, isPrimitive, nameOf } from "@tsed/core";
2
- import { getPropertiesStores, JsonEntityStore } from "@tsed/schema";
3
- import { alterOnSerialize } from "../hooks/alterOnSerialize.js";
4
- import { getObjectProperties } from "../utils/getObjectProperties.js";
5
3
  import { JsonMapperCompiler } from "./JsonMapperCompiler.js";
6
4
  import { JsonMapperSettings } from "./JsonMapperSettings.js";
7
- import { getJsonMapperTypes } from "./JsonMapperTypesContainer.js";
8
5
  import { Writer } from "./Writer.js";
6
+ import { alterOnSerialize } from "../hooks/alterOnSerialize.js";
7
+ import { getJsonMapperTypes } from "./JsonMapperTypesContainer.js";
8
+ import { getObjectProperties } from "../utils/getObjectProperties.js";
9
9
  const getCollectionType = (input) => {
10
10
  return isArray(input) ? "Array" : input instanceof Set ? "Set" : input instanceof Map ? "Map" : undefined;
11
11
  };
@@ -48,7 +48,7 @@ export class JsonSerializer extends JsonMapperCompiler {
48
48
  return alterOnSerialize(this.schemes[schemaId], value, options);
49
49
  }
50
50
  createMapper(model, id, groups) {
51
- const entity = JsonEntityStore.from(model);
51
+ const entity = s.store(model);
52
52
  const properties = new Set();
53
53
  const schemaProperties = [...getPropertiesStores(entity).values()];
54
54
  const writer = new Writer().arrow("input", "options");
@@ -1,6 +1,6 @@
1
+ import { CachedGroupsJsonMapper, CachedJsonMapper, JsonMapperCompiler } from "./JsonMapperCompiler.js";
1
2
  import { Type } from "@tsed/core";
2
3
  import { JsonDeserializerOptions } from "./JsonDeserializerOptions.js";
3
- import { CachedGroupsJsonMapper, CachedJsonMapper, JsonMapperCompiler } from "./JsonMapperCompiler.js";
4
4
  /**
5
5
  * Deserializes raw JSON data into class instances based on schema metadata,
6
6
  * handling collections, discriminators, hooks, and registered type mappers.
@@ -1,7 +1,7 @@
1
- import { MetadataTypes, Type } from "@tsed/core";
2
1
  import { type GenericsMap, JsonEntityStore } from "@tsed/schema";
3
- import { JsonMapperMethods } from "../interfaces/JsonMapperMethods.js";
2
+ import { MetadataTypes, Type } from "@tsed/core";
4
3
  import { JsonMapperGlobalOptions } from "./JsonMapperGlobalOptions.js";
4
+ import { JsonMapperMethods } from "../interfaces/JsonMapperMethods.js";
5
5
  /**
6
6
  * Options accepted by the `JsonDeserializer`. They describe the target type,
7
7
  * collection strategy, additional mapper types, and hook configuration used while materializing data.
@@ -1,5 +1,5 @@
1
- import { Type } from "@tsed/core";
2
1
  import { JsonMapperMethods } from "../interfaces/JsonMapperMethods.js";
2
+ import { Type } from "@tsed/core";
3
3
  /**
4
4
  * Register a mapper class for a specific primitive/complex type so it can be reused by the serializers.
5
5
  */
@@ -1,6 +1,6 @@
1
1
  import { MetadataTypes, Type } from "@tsed/core";
2
- import { JsonMapperMethods } from "../interfaces/JsonMapperMethods.js";
3
2
  import { JsonMapperGlobalOptions } from "./JsonMapperGlobalOptions.js";
3
+ import { JsonMapperMethods } from "../interfaces/JsonMapperMethods.js";
4
4
  /**
5
5
  * Options accepted by the `JsonSerializer`. They describe the target type, alias strategy,
6
6
  * additional type mappers, and group handling.
package/package.json CHANGED
@@ -1,13 +1,25 @@
1
1
  {
2
2
  "name": "@tsed/json-mapper",
3
+ "version": "8.35.0",
3
4
  "description": "Json mapper module for Ts.ED Framework",
4
- "type": "module",
5
- "version": "8.33.0",
5
+ "keywords": [
6
+ "TypeScript",
7
+ "class",
8
+ "classes",
9
+ "decorators",
10
+ "deserialization",
11
+ "json mapper",
12
+ "mapper",
13
+ "models",
14
+ "serialization",
15
+ "tsed"
16
+ ],
6
17
  "source": "./src/index.ts",
18
+ "type": "module",
7
19
  "main": "./lib/esm/index.js",
8
20
  "module": "./lib/esm/index.js",
9
- "typings": "./lib/types/index.d.ts",
10
21
  "browser": "./lib/esm/index.js",
22
+ "typings": "./lib/types/index.d.ts",
11
23
  "exports": {
12
24
  ".": {
13
25
  "tsed-source": "./src/index.ts",
@@ -25,27 +37,14 @@
25
37
  "build:ts": "tsc --build tsconfig.esm.json",
26
38
  "test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
27
39
  },
28
- "keywords": [
29
- "TypeScript",
30
- "decorators",
31
- "models",
32
- "json mapper",
33
- "mapper",
34
- "serialization",
35
- "deserialization",
36
- "class",
37
- "classes",
38
- "tsed"
39
- ],
40
40
  "dependencies": {
41
41
  "tslib": ">=2.7.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@tsed/barrels": "8.33.0",
45
- "@tsed/core": "8.33.0",
46
- "@tsed/schema": "8.33.0",
47
- "@tsed/typescript": "8.33.0",
48
- "eslint": "9.12.0",
44
+ "@tsed/barrels": "8.35.0",
45
+ "@tsed/core": "8.35.0",
46
+ "@tsed/schema": "8.35.0",
47
+ "@tsed/typescript": "8.35.0",
49
48
  "temporal-polyfill": "1.0.1",
50
49
  "typescript": "6.0.2",
51
50
  "vitest": "4.1.4"