@tsed/json-mapper 7.35.0-beta.2 → 7.35.0-beta.4
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.
- package/jest.config.js +3 -3
- package/lib/browser/json-mapper.umd.min.js +1 -1
- package/lib/browser/json-mapper.umd.min.js.map +1 -1
- package/lib/cjs/components/DateMapper.js.map +1 -1
- package/lib/cjs/components/PrimitiveMapper.js +30 -26
- package/lib/cjs/components/PrimitiveMapper.js.map +1 -1
- package/lib/cjs/components/SymbolMapper.js.map +1 -1
- package/lib/cjs/domain/JsonDeserializer.js +275 -0
- package/lib/cjs/domain/JsonDeserializer.js.map +1 -0
- package/lib/cjs/domain/JsonDeserializerOptions.js +3 -0
- package/lib/cjs/domain/JsonDeserializerOptions.js.map +1 -0
- package/lib/cjs/domain/JsonMapperCompiler.js +11 -2
- package/lib/cjs/domain/JsonMapperCompiler.js.map +1 -1
- package/lib/cjs/domain/JsonSerializer.js +16 -15
- package/lib/cjs/domain/JsonSerializer.js.map +1 -1
- package/lib/cjs/domain/Writer.js +30 -0
- package/lib/cjs/domain/Writer.js.map +1 -1
- package/lib/cjs/hooks/alterOnDeserialize.js +8 -0
- package/lib/cjs/hooks/alterOnDeserialize.js.map +1 -0
- package/lib/cjs/index.js +3 -4
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/utils/deserialize.js +5 -202
- package/lib/cjs/utils/deserialize.js.map +1 -1
- package/lib/esm/components/DateMapper.js.map +1 -1
- package/lib/esm/components/PrimitiveMapper.js +30 -26
- package/lib/esm/components/PrimitiveMapper.js.map +1 -1
- package/lib/esm/components/SymbolMapper.js.map +1 -1
- package/lib/esm/domain/JsonDeserializer.js +271 -0
- package/lib/esm/domain/JsonDeserializer.js.map +1 -0
- package/lib/esm/domain/JsonDeserializerOptions.js +2 -0
- package/lib/esm/domain/JsonDeserializerOptions.js.map +1 -0
- package/lib/esm/domain/JsonMapperCompiler.js +11 -2
- package/lib/esm/domain/JsonMapperCompiler.js.map +1 -1
- package/lib/esm/domain/JsonSerializer.js +16 -15
- package/lib/esm/domain/JsonSerializer.js.map +1 -1
- package/lib/esm/domain/Writer.js +31 -2
- package/lib/esm/domain/Writer.js.map +1 -1
- package/lib/esm/hooks/alterOnDeserialize.js +4 -0
- package/lib/esm/hooks/alterOnDeserialize.js.map +1 -0
- package/lib/esm/index.js +3 -4
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/utils/deserialize.js +4 -200
- package/lib/esm/utils/deserialize.js.map +1 -1
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/components/PrimitiveMapper.d.ts +4 -0
- package/lib/types/domain/JsonDeserializer.d.ts +33 -0
- package/lib/types/domain/JsonDeserializerOptions.d.ts +31 -0
- package/lib/types/domain/JsonMapperCompiler.d.ts +7 -1
- package/lib/types/domain/JsonSerializer.d.ts +1 -0
- package/lib/types/domain/Writer.d.ts +9 -0
- package/lib/types/hooks/alterOnDeserialize.d.ts +2 -0
- package/lib/types/index.d.ts +3 -4
- package/lib/types/utils/deserialize.d.ts +2 -47
- package/package.json +7 -7
- package/lib/cjs/components/ArrayMapper.js +0 -23
- package/lib/cjs/components/ArrayMapper.js.map +0 -1
- package/lib/cjs/components/MapMapper.js +0 -30
- package/lib/cjs/components/MapMapper.js.map +0 -1
- package/lib/cjs/components/SetMapper.js +0 -30
- package/lib/cjs/components/SetMapper.js.map +0 -1
- package/lib/cjs/domain/JsonMapperContext.js +0 -27
- package/lib/cjs/domain/JsonMapperContext.js.map +0 -1
- package/lib/esm/components/ArrayMapper.js +0 -20
- package/lib/esm/components/ArrayMapper.js.map +0 -1
- package/lib/esm/components/MapMapper.js +0 -27
- package/lib/esm/components/MapMapper.js.map +0 -1
- package/lib/esm/components/SetMapper.js +0 -27
- package/lib/esm/components/SetMapper.js.map +0 -1
- package/lib/esm/domain/JsonMapperContext.js +0 -23
- package/lib/esm/domain/JsonMapperContext.js.map +0 -1
- package/lib/types/components/ArrayMapper.d.ts +0 -10
- package/lib/types/components/MapMapper.d.ts +0 -12
- package/lib/types/components/SetMapper.d.ts +0 -10
- package/lib/types/domain/JsonMapperContext.d.ts +0 -20
|
@@ -11,4 +11,8 @@ export declare class CastError extends Error {
|
|
|
11
11
|
export declare class PrimitiveMapper implements JsonMapperMethods {
|
|
12
12
|
deserialize<T>(data: any, ctx: JsonMapperCtx): string | number | boolean | void | null | BigInt;
|
|
13
13
|
serialize(object: string | number | boolean | BigInt): string | number | boolean | BigInt;
|
|
14
|
+
protected String(data: any): string | null;
|
|
15
|
+
protected Boolean(data: any): boolean | null | undefined;
|
|
16
|
+
protected Number(data: any): number | null;
|
|
17
|
+
protected BigInt(data: any): bigint | null;
|
|
14
18
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import { JsonDeserializerOptions } from "./JsonDeserializerOptions";
|
|
3
|
+
import { CachedJsonMapper, JsonMapperCompiler } from "./JsonMapperCompiler";
|
|
4
|
+
export declare class JsonDeserializer extends JsonMapperCompiler<JsonDeserializerOptions> {
|
|
5
|
+
/**
|
|
6
|
+
* Cached classes by his id
|
|
7
|
+
* @protected
|
|
8
|
+
*/
|
|
9
|
+
protected constructors: Record<string, Type<any>>;
|
|
10
|
+
constructor();
|
|
11
|
+
map<Model = any>(input: any, options?: JsonDeserializerOptions): Model;
|
|
12
|
+
compile(model: Type<any>, groups: false | string[]): CachedJsonMapper<JsonDeserializerOptions>;
|
|
13
|
+
eval(mapper: string, { id, groupsId, model }: {
|
|
14
|
+
id: string;
|
|
15
|
+
model: Type<any>;
|
|
16
|
+
groupsId: string;
|
|
17
|
+
}): CachedJsonMapper<JsonDeserializerOptions>;
|
|
18
|
+
protected newInstanceOf(id: string, obj: any, options: any): any;
|
|
19
|
+
protected createMapper(model: Type<any>, id: string, groups: false | string[]): string;
|
|
20
|
+
protected alterValue(schemaId: string, value: any, options: JsonDeserializerOptions): any;
|
|
21
|
+
private mapDiscriminator;
|
|
22
|
+
private mapProperty;
|
|
23
|
+
private getPropertyFiller;
|
|
24
|
+
private mapOptions;
|
|
25
|
+
private mapAdditionalProperties;
|
|
26
|
+
private mapObject;
|
|
27
|
+
private mapSet;
|
|
28
|
+
private mapArray;
|
|
29
|
+
private mapMap;
|
|
30
|
+
private mapItem;
|
|
31
|
+
private alterBeforeDeserialize;
|
|
32
|
+
private alterAfterDeserialize;
|
|
33
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { MetadataTypes, Type } from "@tsed/core";
|
|
2
|
+
import { JsonEntityStore } from "@tsed/schema";
|
|
3
|
+
import { JsonMapperMethods } from "../interfaces/JsonMapperMethods";
|
|
4
|
+
export interface JsonDeserializerOptions<T = any, C = any> extends MetadataTypes<T, C> {
|
|
5
|
+
/**
|
|
6
|
+
* Types used to map complex types (Symbol, Array, Set, Map)
|
|
7
|
+
*/
|
|
8
|
+
types?: Map<Type<any> | Symbol | string, JsonMapperMethods>;
|
|
9
|
+
/**
|
|
10
|
+
* useAlias mapping
|
|
11
|
+
*/
|
|
12
|
+
useAlias?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Accept additionalProperties or ignore it
|
|
15
|
+
*/
|
|
16
|
+
additionalProperties?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
disableUnsecureConstructor?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Use the store which have all metadata to deserialize correctly the model. This
|
|
23
|
+
* property is useful when you deal with metadata parameters.
|
|
24
|
+
*/
|
|
25
|
+
store?: JsonEntityStore;
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
groups?: string[] | false;
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
}
|
|
@@ -22,6 +22,11 @@ export declare abstract class JsonMapperCompiler<Options extends Record<string,
|
|
|
22
22
|
* @protected
|
|
23
23
|
*/
|
|
24
24
|
protected schemes: Record<string, any>;
|
|
25
|
+
/**
|
|
26
|
+
* Cached classes by his id
|
|
27
|
+
* @protected
|
|
28
|
+
*/
|
|
29
|
+
protected constructors: Record<string, Type<any>>;
|
|
25
30
|
/**
|
|
26
31
|
* Global variables available in the mapper
|
|
27
32
|
* @protected
|
|
@@ -44,9 +49,10 @@ export declare abstract class JsonMapperCompiler<Options extends Record<string,
|
|
|
44
49
|
protected abstract map(input: any, options: Options): any;
|
|
45
50
|
protected abstract alterValue(schemaId: string, value: any, options: Options): any;
|
|
46
51
|
protected abstract createMapper(model: Type<any>, id: string, groups: false | string[]): string;
|
|
47
|
-
protected getType(model: Type<any>): Type<any> |
|
|
52
|
+
protected getType(model: Type<any>): Type<any> | MapConstructor | ObjectConstructor | ArrayConstructor | SetConstructor;
|
|
48
53
|
protected alterIgnore(id: string, options: Options): any;
|
|
49
54
|
protected alterGroups(schema: JsonSchema, groups: false | string[]): any;
|
|
50
55
|
protected getGroupsId(groups: false | string[]): string;
|
|
51
56
|
protected getId(model: Type<any>, groupsId: string): string;
|
|
57
|
+
protected getSchemaId(id: string, propertyKey: string): string;
|
|
52
58
|
}
|
|
@@ -8,6 +8,7 @@ export declare class JsonSerializer extends JsonMapperCompiler<JsonSerializerOpt
|
|
|
8
8
|
protected createMapper(model: Type<any>, id: string, groups: false | string[]): string;
|
|
9
9
|
private mapOptions;
|
|
10
10
|
private mapProperty;
|
|
11
|
+
private getPropertyFiller;
|
|
11
12
|
private mapPrecondition;
|
|
12
13
|
private mapDiscriminator;
|
|
13
14
|
private mapAdditionalProperties;
|
|
@@ -14,9 +14,11 @@ export declare class Writer {
|
|
|
14
14
|
arrow(...args: string[]): Writer;
|
|
15
15
|
build(): string[];
|
|
16
16
|
callMapper(id: string, key: string, ...options: string[]): this;
|
|
17
|
+
returnCallMapper(id: string, key: string, ...options: string[]): Writer;
|
|
17
18
|
const(name: string, line: string): this;
|
|
18
19
|
each(iterable: string, args?: string[]): Writer;
|
|
19
20
|
if(condition: string): IfWriter;
|
|
21
|
+
switch(input: string): SwitchWriter;
|
|
20
22
|
indent(indent: boolean): this;
|
|
21
23
|
new(indent?: boolean): Writer;
|
|
22
24
|
return(line: string): Writer;
|
|
@@ -31,4 +33,11 @@ declare class IfWriter extends Writer {
|
|
|
31
33
|
else(): Writer;
|
|
32
34
|
build(): string[];
|
|
33
35
|
}
|
|
36
|
+
declare class SwitchWriter extends Writer {
|
|
37
|
+
#private;
|
|
38
|
+
private input;
|
|
39
|
+
constructor(input: string);
|
|
40
|
+
case(condition: string): Writer;
|
|
41
|
+
build(): string[];
|
|
42
|
+
}
|
|
34
43
|
export {};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file Automatically generated by barrelsby.
|
|
3
3
|
*/
|
|
4
|
-
export * from "./components/ArrayMapper";
|
|
5
4
|
export * from "./components/DateMapper";
|
|
6
|
-
export * from "./components/MapMapper";
|
|
7
5
|
export * from "./components/PrimitiveMapper";
|
|
8
|
-
export * from "./components/SetMapper";
|
|
9
6
|
export * from "./components/SymbolMapper";
|
|
10
7
|
export * from "./decorators/afterDeserialize";
|
|
11
8
|
export * from "./decorators/beforeDeserialize";
|
|
12
9
|
export * from "./decorators/jsonMapper";
|
|
13
10
|
export * from "./decorators/onDeserialize";
|
|
14
11
|
export * from "./decorators/onSerialize";
|
|
12
|
+
export * from "./domain/JsonDeserializer";
|
|
13
|
+
export * from "./domain/JsonDeserializerOptions";
|
|
15
14
|
export * from "./domain/JsonMapperCompiler";
|
|
16
|
-
export * from "./domain/JsonMapperContext";
|
|
17
15
|
export * from "./domain/JsonMapperSettings";
|
|
18
16
|
export * from "./domain/JsonMapperTypesContainer";
|
|
19
17
|
export * from "./domain/JsonSerializer";
|
|
@@ -21,6 +19,7 @@ export * from "./domain/JsonSerializerOptions";
|
|
|
21
19
|
export * from "./domain/Writer";
|
|
22
20
|
export * from "./hooks/alterAfterDeserialize";
|
|
23
21
|
export * from "./hooks/alterBeforeDeserialize";
|
|
22
|
+
export * from "./hooks/alterOnDeserialize";
|
|
24
23
|
export * from "./hooks/alterOnSerialize";
|
|
25
24
|
export * from "./interfaces/JsonMapperMethods";
|
|
26
25
|
export * from "./utils/deserialize";
|
|
@@ -1,50 +1,5 @@
|
|
|
1
|
-
import { MetadataTypes, Type } from "@tsed/core";
|
|
2
|
-
import { JsonEntityStore } from "@tsed/schema";
|
|
3
|
-
import "../components/ArrayMapper";
|
|
4
1
|
import "../components/DateMapper";
|
|
5
|
-
import "../components/MapMapper";
|
|
6
2
|
import "../components/PrimitiveMapper";
|
|
7
|
-
import "../components/SetMapper";
|
|
8
3
|
import "../components/SymbolMapper";
|
|
9
|
-
import {
|
|
10
|
-
export
|
|
11
|
-
/**
|
|
12
|
-
* Types used to map complex types (Symbol, Array, Set, Map)
|
|
13
|
-
*/
|
|
14
|
-
types?: WeakMap<Type<any>, JsonMapperMethods>;
|
|
15
|
-
/**
|
|
16
|
-
* useAlias mapping
|
|
17
|
-
*/
|
|
18
|
-
useAlias?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Accept additionalProperties or ignore it
|
|
21
|
-
*/
|
|
22
|
-
additionalProperties?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
*/
|
|
26
|
-
disableUnsecureConstructor?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Use the store which have all metadata to deserialize correctly the model. This
|
|
29
|
-
* property is useful when you deal with metadata parameters.
|
|
30
|
-
*/
|
|
31
|
-
store?: JsonEntityStore;
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
*/
|
|
35
|
-
groups?: string[] | false;
|
|
36
|
-
[key: string]: any;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Transform given plain object to class.
|
|
40
|
-
* @param src
|
|
41
|
-
* @param options
|
|
42
|
-
*/
|
|
43
|
-
export declare function plainObjectToClass<T = any>(src: any, options: JsonDeserializerOptions): T;
|
|
44
|
-
/**
|
|
45
|
-
* Transform given source to class base on the given `options.type`.
|
|
46
|
-
*
|
|
47
|
-
* @param src
|
|
48
|
-
* @param options
|
|
49
|
-
*/
|
|
50
|
-
export declare function deserialize<T = any>(src: any, options?: JsonDeserializerOptions): T;
|
|
4
|
+
import { JsonDeserializerOptions } from "../domain/JsonDeserializerOptions";
|
|
5
|
+
export declare function deserialize<Model = any>(input: any, options?: JsonDeserializerOptions): Model;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/json-mapper",
|
|
3
|
-
"version": "7.35.0-beta.
|
|
3
|
+
"version": "7.35.0-beta.4",
|
|
4
4
|
"description": "Json mapper module for Ts.ED Framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
"tslib": "2.5.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@tsed/core": "7.35.0-beta.
|
|
45
|
-
"@tsed/eslint": "7.35.0-beta.
|
|
46
|
-
"@tsed/schema": "7.35.0-beta.
|
|
47
|
-
"@tsed/typescript": "7.35.0-beta.
|
|
44
|
+
"@tsed/core": "7.35.0-beta.4",
|
|
45
|
+
"@tsed/eslint": "7.35.0-beta.4",
|
|
46
|
+
"@tsed/schema": "7.35.0-beta.4",
|
|
47
|
+
"@tsed/typescript": "7.35.0-beta.4",
|
|
48
48
|
"eslint": "^8.12.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@tsed/core": "^7.35.0-beta.
|
|
52
|
-
"@tsed/schema": "^7.35.0-beta.
|
|
51
|
+
"@tsed/core": "^7.35.0-beta.4",
|
|
52
|
+
"@tsed/schema": "^7.35.0-beta.4"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {
|
|
55
55
|
"@tsed/core": {
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ArrayMapper = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const jsonMapper_1 = require("../decorators/jsonMapper");
|
|
6
|
-
/**
|
|
7
|
-
* Mapper for `Array` type.
|
|
8
|
-
* @jsonmapper
|
|
9
|
-
* @component
|
|
10
|
-
*/
|
|
11
|
-
let ArrayMapper = class ArrayMapper {
|
|
12
|
-
deserialize(data, options) {
|
|
13
|
-
return [].concat(data).map((item) => options.next(item));
|
|
14
|
-
}
|
|
15
|
-
serialize(data, options) {
|
|
16
|
-
return [].concat(data).map((item) => options.next(item));
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
ArrayMapper = tslib_1.__decorate([
|
|
20
|
-
(0, jsonMapper_1.JsonMapper)(Array)
|
|
21
|
-
], ArrayMapper);
|
|
22
|
-
exports.ArrayMapper = ArrayMapper;
|
|
23
|
-
//# sourceMappingURL=ArrayMapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayMapper.js","sourceRoot":"","sources":["../../../src/components/ArrayMapper.ts"],"names":[],"mappings":";;;;AAAA,yDAAoD;AAGpD;;;;GAIG;AAEH,IAAa,WAAW,GAAxB,MAAa,WAAW;IACtB,WAAW,CAAU,IAAS,EAAE,OAAsB;QACpD,OAAO,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,SAAS,CAAC,IAAW,EAAE,OAAsB;QAC3C,OAAO,EAAE,CAAC,MAAM,CAAC,IAAW,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAClE,CAAC;CACF,CAAA;AARY,WAAW;IADvB,IAAA,uBAAU,EAAC,KAAK,CAAC;GACL,WAAW,CAQvB;AARY,kCAAW"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MapMapper = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const core_1 = require("@tsed/core");
|
|
6
|
-
const jsonMapper_1 = require("../decorators/jsonMapper");
|
|
7
|
-
/**
|
|
8
|
-
* Mapper for `Map` type.
|
|
9
|
-
* @jsonmapper
|
|
10
|
-
* @component
|
|
11
|
-
*/
|
|
12
|
-
let MapMapper = class MapMapper {
|
|
13
|
-
deserialize(data, ctx) {
|
|
14
|
-
const obj = new Map();
|
|
15
|
-
(0, core_1.objectKeys)(data).forEach((key) => {
|
|
16
|
-
obj.set(key, ctx.next(data[key]));
|
|
17
|
-
});
|
|
18
|
-
return obj;
|
|
19
|
-
}
|
|
20
|
-
serialize(data, ctx) {
|
|
21
|
-
const obj = {};
|
|
22
|
-
data.forEach((value, key) => (obj[key] = ctx.next(value)));
|
|
23
|
-
return obj;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
MapMapper = tslib_1.__decorate([
|
|
27
|
-
(0, jsonMapper_1.JsonMapper)(Map)
|
|
28
|
-
], MapMapper);
|
|
29
|
-
exports.MapMapper = MapMapper;
|
|
30
|
-
//# sourceMappingURL=MapMapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MapMapper.js","sourceRoot":"","sources":["../../../src/components/MapMapper.ts"],"names":[],"mappings":";;;;AAAA,qCAAsC;AACtC,yDAAoD;AAGpD;;;;GAIG;AAEH,IAAa,SAAS,GAAtB,MAAa,SAAS;IACpB,WAAW,CAA8B,IAA0B,EAAE,GAAwB;QAC3F,MAAM,GAAG,GAAG,IAAI,GAAG,EAAa,CAAC;QAEjC,IAAA,iBAAU,EAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/B,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAM,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,CAAC;IACb,CAAC;IAED,SAAS,CAAI,IAAoB,EAAE,GAAkB;QACnD,MAAM,GAAG,GAAQ,EAAE,CAAC;QAEpB,IAAI,CAAC,OAAO,CAAC,CAAC,KAAQ,EAAE,GAAW,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAEtE,OAAO,GAAG,CAAC;IACb,CAAC;CACF,CAAA;AAlBY,SAAS;IADrB,IAAA,uBAAU,EAAC,GAAG,CAAC;GACH,SAAS,CAkBrB;AAlBY,8BAAS"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SetMapper = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const core_1 = require("@tsed/core");
|
|
6
|
-
const jsonMapper_1 = require("../decorators/jsonMapper");
|
|
7
|
-
/**
|
|
8
|
-
* Mapper for the `Set` Type.
|
|
9
|
-
* @jsonmapper
|
|
10
|
-
* @component
|
|
11
|
-
*/
|
|
12
|
-
let SetMapper = class SetMapper {
|
|
13
|
-
deserialize(data, ctx) {
|
|
14
|
-
const obj = new Set();
|
|
15
|
-
(0, core_1.objectKeys)(data).forEach((key) => {
|
|
16
|
-
obj.add(ctx.next(data[key]));
|
|
17
|
-
});
|
|
18
|
-
return obj;
|
|
19
|
-
}
|
|
20
|
-
serialize(data, ctx) {
|
|
21
|
-
const array = [];
|
|
22
|
-
data.forEach((value) => array.push(ctx.next(value)));
|
|
23
|
-
return array;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
SetMapper = tslib_1.__decorate([
|
|
27
|
-
(0, jsonMapper_1.JsonMapper)(Set)
|
|
28
|
-
], SetMapper);
|
|
29
|
-
exports.SetMapper = SetMapper;
|
|
30
|
-
//# sourceMappingURL=SetMapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SetMapper.js","sourceRoot":"","sources":["../../../src/components/SetMapper.ts"],"names":[],"mappings":";;;;AAAA,qCAAsC;AACtC,yDAAoD;AAGpD;;;;GAIG;AAEH,IAAa,SAAS,GAAtB,MAAa,SAAS;IACpB,WAAW,CAAI,IAAS,EAAE,GAAkB;QAC1C,MAAM,GAAG,GAAG,IAAI,GAAG,EAAK,CAAC;QAEzB,IAAA,iBAAU,EAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/B,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,CAAC;IACb,CAAC;IAED,SAAS,CAAI,IAAY,EAAE,GAAkB;QAC3C,MAAM,KAAK,GAAU,EAAE,CAAC;QAExB,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAErD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AAlBY,SAAS;IADrB,IAAA,uBAAU,EAAC,GAAG,CAAC;GACH,SAAS,CAkBrB;AAlBY,8BAAS"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JsonMapperContext = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
/**
|
|
6
|
-
* @ignore
|
|
7
|
-
*/
|
|
8
|
-
class JsonMapperContext {
|
|
9
|
-
collectionType;
|
|
10
|
-
type;
|
|
11
|
-
options;
|
|
12
|
-
_next;
|
|
13
|
-
constructor({ type, collectionType, next, options }) {
|
|
14
|
-
this.type = type;
|
|
15
|
-
this.collectionType = (0, core_1.isCollection)(collectionType) ? collectionType : undefined;
|
|
16
|
-
this._next = next;
|
|
17
|
-
this.options = options;
|
|
18
|
-
}
|
|
19
|
-
next(data) {
|
|
20
|
-
return this._next(data, {
|
|
21
|
-
...this.options,
|
|
22
|
-
type: this.type
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.JsonMapperContext = JsonMapperContext;
|
|
27
|
-
//# sourceMappingURL=JsonMapperContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JsonMapperContext.js","sourceRoot":"","sources":["../../../src/domain/JsonMapperContext.ts"],"names":[],"mappings":";;;AAAA,qCAA8C;AAS9C;;GAEG;AACH,MAAa,iBAAiB;IACnB,cAAc,CAAwB;IACtC,IAAI,CAAkB;IACtB,OAAO,CAAM;IACd,KAAK,CAAoC;IAEjD,YAAY,EAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAyB;QACvE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,cAAc,GAAG,IAAA,mBAAY,EAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC;QAChF,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,IAAI,CAAC,IAAS;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;YACtB,GAAG,IAAI,CAAC,OAAO;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;CACF;AAnBD,8CAmBC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { JsonMapper } from "../decorators/jsonMapper.js";
|
|
3
|
-
/**
|
|
4
|
-
* Mapper for `Array` type.
|
|
5
|
-
* @jsonmapper
|
|
6
|
-
* @component
|
|
7
|
-
*/
|
|
8
|
-
let ArrayMapper = class ArrayMapper {
|
|
9
|
-
deserialize(data, options) {
|
|
10
|
-
return [].concat(data).map((item) => options.next(item));
|
|
11
|
-
}
|
|
12
|
-
serialize(data, options) {
|
|
13
|
-
return [].concat(data).map((item) => options.next(item));
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
ArrayMapper = __decorate([
|
|
17
|
-
JsonMapper(Array)
|
|
18
|
-
], ArrayMapper);
|
|
19
|
-
export { ArrayMapper };
|
|
20
|
-
//# sourceMappingURL=ArrayMapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayMapper.js","sourceRoot":"","sources":["../../../src/components/ArrayMapper.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AAGpD;;;;GAIG;AAEH,IAAa,WAAW,GAAxB,MAAa,WAAW;IACtB,WAAW,CAAU,IAAS,EAAE,OAAsB;QACpD,OAAO,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,SAAS,CAAC,IAAW,EAAE,OAAsB;QAC3C,OAAO,EAAE,CAAC,MAAM,CAAC,IAAW,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAClE,CAAC;CACF,CAAA;AARY,WAAW;IADvB,UAAU,CAAC,KAAK,CAAC;GACL,WAAW,CAQvB;SARY,WAAW"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { objectKeys } from "@tsed/core";
|
|
3
|
-
import { JsonMapper } from "../decorators/jsonMapper.js";
|
|
4
|
-
/**
|
|
5
|
-
* Mapper for `Map` type.
|
|
6
|
-
* @jsonmapper
|
|
7
|
-
* @component
|
|
8
|
-
*/
|
|
9
|
-
let MapMapper = class MapMapper {
|
|
10
|
-
deserialize(data, ctx) {
|
|
11
|
-
const obj = new Map();
|
|
12
|
-
objectKeys(data).forEach((key) => {
|
|
13
|
-
obj.set(key, ctx.next(data[key]));
|
|
14
|
-
});
|
|
15
|
-
return obj;
|
|
16
|
-
}
|
|
17
|
-
serialize(data, ctx) {
|
|
18
|
-
const obj = {};
|
|
19
|
-
data.forEach((value, key) => (obj[key] = ctx.next(value)));
|
|
20
|
-
return obj;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
MapMapper = __decorate([
|
|
24
|
-
JsonMapper(Map)
|
|
25
|
-
], MapMapper);
|
|
26
|
-
export { MapMapper };
|
|
27
|
-
//# sourceMappingURL=MapMapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MapMapper.js","sourceRoot":"","sources":["../../../src/components/MapMapper.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AACtC,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AAGpD;;;;GAIG;AAEH,IAAa,SAAS,GAAtB,MAAa,SAAS;IACpB,WAAW,CAA8B,IAA0B,EAAE,GAAwB;QAC3F,MAAM,GAAG,GAAG,IAAI,GAAG,EAAa,CAAC;QAEjC,UAAU,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/B,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAM,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,CAAC;IACb,CAAC;IAED,SAAS,CAAI,IAAoB,EAAE,GAAkB;QACnD,MAAM,GAAG,GAAQ,EAAE,CAAC;QAEpB,IAAI,CAAC,OAAO,CAAC,CAAC,KAAQ,EAAE,GAAW,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAEtE,OAAO,GAAG,CAAC;IACb,CAAC;CACF,CAAA;AAlBY,SAAS;IADrB,UAAU,CAAC,GAAG,CAAC;GACH,SAAS,CAkBrB;SAlBY,SAAS"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { objectKeys } from "@tsed/core";
|
|
3
|
-
import { JsonMapper } from "../decorators/jsonMapper.js";
|
|
4
|
-
/**
|
|
5
|
-
* Mapper for the `Set` Type.
|
|
6
|
-
* @jsonmapper
|
|
7
|
-
* @component
|
|
8
|
-
*/
|
|
9
|
-
let SetMapper = class SetMapper {
|
|
10
|
-
deserialize(data, ctx) {
|
|
11
|
-
const obj = new Set();
|
|
12
|
-
objectKeys(data).forEach((key) => {
|
|
13
|
-
obj.add(ctx.next(data[key]));
|
|
14
|
-
});
|
|
15
|
-
return obj;
|
|
16
|
-
}
|
|
17
|
-
serialize(data, ctx) {
|
|
18
|
-
const array = [];
|
|
19
|
-
data.forEach((value) => array.push(ctx.next(value)));
|
|
20
|
-
return array;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
SetMapper = __decorate([
|
|
24
|
-
JsonMapper(Set)
|
|
25
|
-
], SetMapper);
|
|
26
|
-
export { SetMapper };
|
|
27
|
-
//# sourceMappingURL=SetMapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SetMapper.js","sourceRoot":"","sources":["../../../src/components/SetMapper.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AACtC,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AAGpD;;;;GAIG;AAEH,IAAa,SAAS,GAAtB,MAAa,SAAS;IACpB,WAAW,CAAI,IAAS,EAAE,GAAkB;QAC1C,MAAM,GAAG,GAAG,IAAI,GAAG,EAAK,CAAC;QAEzB,UAAU,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/B,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,CAAC;IACb,CAAC;IAED,SAAS,CAAI,IAAY,EAAE,GAAkB;QAC3C,MAAM,KAAK,GAAU,EAAE,CAAC;QAExB,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAErD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AAlBY,SAAS;IADrB,UAAU,CAAC,GAAG,CAAC;GACH,SAAS,CAkBrB;SAlBY,SAAS"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { isCollection } from "@tsed/core";
|
|
2
|
-
/**
|
|
3
|
-
* @ignore
|
|
4
|
-
*/
|
|
5
|
-
export class JsonMapperContext {
|
|
6
|
-
collectionType;
|
|
7
|
-
type;
|
|
8
|
-
options;
|
|
9
|
-
_next;
|
|
10
|
-
constructor({ type, collectionType, next, options }) {
|
|
11
|
-
this.type = type;
|
|
12
|
-
this.collectionType = isCollection(collectionType) ? collectionType : undefined;
|
|
13
|
-
this._next = next;
|
|
14
|
-
this.options = options;
|
|
15
|
-
}
|
|
16
|
-
next(data) {
|
|
17
|
-
return this._next(data, {
|
|
18
|
-
...this.options,
|
|
19
|
-
type: this.type
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=JsonMapperContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JsonMapperContext.js","sourceRoot":"","sources":["../../../src/domain/JsonMapperContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAO,MAAM,YAAY,CAAC;AAS9C;;GAEG;AACH,MAAM,OAAO,iBAAiB;IACnB,cAAc,CAAwB;IACtC,IAAI,CAAkB;IACtB,OAAO,CAAM;IACd,KAAK,CAAoC;IAEjD,YAAY,EAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAyB;QACvE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC;QAChF,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,IAAI,CAAC,IAAS;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;YACtB,GAAG,IAAI,CAAC,OAAO;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { JsonMapperCtx, JsonMapperMethods } from "../interfaces/JsonMapperMethods";
|
|
2
|
-
/**
|
|
3
|
-
* Mapper for `Array` type.
|
|
4
|
-
* @jsonmapper
|
|
5
|
-
* @component
|
|
6
|
-
*/
|
|
7
|
-
export declare class ArrayMapper implements JsonMapperMethods {
|
|
8
|
-
deserialize<T = any>(data: any, options: JsonMapperCtx): T[];
|
|
9
|
-
serialize(data: any[], options: JsonMapperCtx): any;
|
|
10
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { JsonMapperCtx, JsonMapperMethods } from "../interfaces/JsonMapperMethods";
|
|
2
|
-
/**
|
|
3
|
-
* Mapper for `Map` type.
|
|
4
|
-
* @jsonmapper
|
|
5
|
-
* @component
|
|
6
|
-
*/
|
|
7
|
-
export declare class MapMapper implements JsonMapperMethods {
|
|
8
|
-
deserialize<T = any, C = Map<string, T>>(data: {
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
}, ctx: JsonMapperCtx<T, C>): Map<string, T>;
|
|
11
|
-
serialize<T>(data: Map<string, T>, ctx: JsonMapperCtx): any;
|
|
12
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { JsonMapperCtx, JsonMapperMethods } from "../interfaces/JsonMapperMethods";
|
|
2
|
-
/**
|
|
3
|
-
* Mapper for the `Set` Type.
|
|
4
|
-
* @jsonmapper
|
|
5
|
-
* @component
|
|
6
|
-
*/
|
|
7
|
-
export declare class SetMapper implements JsonMapperMethods {
|
|
8
|
-
deserialize<T>(data: any, ctx: JsonMapperCtx): Set<T>;
|
|
9
|
-
serialize<T>(data: Set<T>, ctx: JsonMapperCtx): any[];
|
|
10
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Type } from "@tsed/core";
|
|
2
|
-
import { JsonMapperCtx } from "../interfaces/JsonMapperMethods";
|
|
3
|
-
/**
|
|
4
|
-
* @ignore
|
|
5
|
-
*/
|
|
6
|
-
export interface JsonMapperContextProps extends Partial<Omit<JsonMapperCtx, "next">> {
|
|
7
|
-
next: (data: any, options: any) => void;
|
|
8
|
-
options: any;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* @ignore
|
|
12
|
-
*/
|
|
13
|
-
export declare class JsonMapperContext implements JsonMapperCtx {
|
|
14
|
-
readonly collectionType: Type<any> | undefined;
|
|
15
|
-
readonly type: Type<any> | any;
|
|
16
|
-
readonly options: any;
|
|
17
|
-
private _next;
|
|
18
|
-
constructor({ type, collectionType, next, options }: JsonMapperContextProps);
|
|
19
|
-
next(data: any): void;
|
|
20
|
-
}
|