@tsed/json-mapper 7.35.1 → 7.36.0-rc.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.
- 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 +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 +167 -0
- package/lib/cjs/domain/JsonMapperCompiler.js.map +1 -0
- package/lib/cjs/domain/JsonSerializer.js +219 -0
- package/lib/cjs/domain/JsonSerializer.js.map +1 -0
- package/lib/cjs/domain/JsonSerializerOptions.js +3 -0
- package/lib/cjs/domain/JsonSerializerOptions.js.map +1 -0
- package/lib/cjs/domain/Writer.js +141 -0
- package/lib/cjs/domain/Writer.js.map +1 -0
- package/lib/cjs/hooks/alterOnDeserialize.js +8 -0
- package/lib/cjs/hooks/alterOnDeserialize.js.map +1 -0
- package/lib/cjs/hooks/alterOnSerialize.js +8 -0
- package/lib/cjs/hooks/alterOnSerialize.js.map +1 -0
- package/lib/cjs/index.js +9 -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/cjs/utils/getObjectProperties.js +9 -0
- package/lib/cjs/utils/getObjectProperties.js.map +1 -0
- package/lib/cjs/utils/serialize.js +5 -143
- package/lib/cjs/utils/serialize.js.map +1 -1
- package/lib/esm/components/DateMapper.js +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 +163 -0
- package/lib/esm/domain/JsonMapperCompiler.js.map +1 -0
- package/lib/esm/domain/JsonSerializer.js +215 -0
- package/lib/esm/domain/JsonSerializer.js.map +1 -0
- package/lib/esm/domain/JsonSerializerOptions.js +2 -0
- package/lib/esm/domain/JsonSerializerOptions.js.map +1 -0
- package/lib/esm/domain/Writer.js +137 -0
- package/lib/esm/domain/Writer.js.map +1 -0
- package/lib/esm/hooks/alterOnDeserialize.js +4 -0
- package/lib/esm/hooks/alterOnDeserialize.js.map +1 -0
- package/lib/esm/hooks/alterOnSerialize.js +4 -0
- package/lib/esm/hooks/alterOnSerialize.js.map +1 -0
- package/lib/esm/index.js +9 -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/esm/utils/getObjectProperties.js +5 -0
- package/lib/esm/utils/getObjectProperties.js.map +1 -0
- package/lib/esm/utils/serialize.js +4 -141
- package/lib/esm/utils/serialize.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 +58 -0
- package/lib/types/domain/JsonSerializer.d.ts +21 -0
- package/lib/types/domain/JsonSerializerOptions.d.ts +13 -0
- package/lib/types/domain/Writer.d.ts +43 -0
- package/lib/types/hooks/alterOnDeserialize.d.ts +2 -0
- package/lib/types/hooks/alterOnSerialize.d.ts +2 -0
- package/lib/types/index.d.ts +9 -4
- package/lib/types/utils/deserialize.d.ts +2 -47
- package/lib/types/utils/getObjectProperties.d.ts +1 -0
- package/lib/types/utils/serialize.d.ts +2 -18
- package/package.json +11 -8
- 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
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import { JsonSchema } from "@tsed/schema";
|
|
3
|
+
export type JsonMapperCallback<Options> = (input: any, options?: Options) => any;
|
|
4
|
+
export type CachedJsonMapper<Options> = {
|
|
5
|
+
id: string;
|
|
6
|
+
fn: JsonMapperCallback<Options>;
|
|
7
|
+
};
|
|
8
|
+
export type CachedGroupsJsonMapper<Options> = Map<string, CachedJsonMapper<Options>>;
|
|
9
|
+
export declare abstract class JsonMapperCompiler<Options extends Record<string, any> = any> {
|
|
10
|
+
/**
|
|
11
|
+
* Cached mappers metadata
|
|
12
|
+
* @protected
|
|
13
|
+
*/
|
|
14
|
+
protected cache: Map<string | Type<any>, CachedGroupsJsonMapper<Options>>;
|
|
15
|
+
/**
|
|
16
|
+
* Cached executable mappers by his id
|
|
17
|
+
* @protected
|
|
18
|
+
*/
|
|
19
|
+
protected mappers: Record<string, JsonMapperCallback<Options>>;
|
|
20
|
+
/**
|
|
21
|
+
* Cached schemas
|
|
22
|
+
* @protected
|
|
23
|
+
*/
|
|
24
|
+
protected schemes: Record<string, any>;
|
|
25
|
+
/**
|
|
26
|
+
* Cached classes by his id
|
|
27
|
+
* @protected
|
|
28
|
+
*/
|
|
29
|
+
protected constructors: Record<string, Type<any>>;
|
|
30
|
+
/**
|
|
31
|
+
* Global variables available in the mapper
|
|
32
|
+
* @protected
|
|
33
|
+
*/
|
|
34
|
+
protected globals: Record<string, any>;
|
|
35
|
+
constructor();
|
|
36
|
+
addTypeMapper(model: Type<any> | string, fn: any): this;
|
|
37
|
+
removeTypeMapper(model: Type<any> | string): void;
|
|
38
|
+
addGlobal(key: string, value: any): this;
|
|
39
|
+
eval(mapper: string, { id, groupsId, model }: {
|
|
40
|
+
id: string;
|
|
41
|
+
model: Type<any>;
|
|
42
|
+
groupsId: string;
|
|
43
|
+
}): CachedJsonMapper<Options>;
|
|
44
|
+
createContext(options: Options): Options & {
|
|
45
|
+
cache: Map<string | Type<any>, CachedGroupsJsonMapper<Options>>;
|
|
46
|
+
};
|
|
47
|
+
compile(model: Type<any>, groups: false | string[]): CachedJsonMapper<Options>;
|
|
48
|
+
protected execMapper(id: string, value: any, options: Options): any;
|
|
49
|
+
protected abstract map(input: any, options: Options): any;
|
|
50
|
+
protected abstract alterValue(schemaId: string, value: any, options: Options): any;
|
|
51
|
+
protected abstract createMapper(model: Type<any>, id: string, groups: false | string[]): string;
|
|
52
|
+
protected getType(model: Type<any>): Type<any> | MapConstructor | ObjectConstructor | ArrayConstructor | SetConstructor;
|
|
53
|
+
protected alterIgnore(id: string, options: Options): any;
|
|
54
|
+
protected alterGroups(schema: JsonSchema, groups: false | string[]): any;
|
|
55
|
+
protected getGroupsId(groups: false | string[]): string;
|
|
56
|
+
protected getId(model: Type<any>, groupsId: string): string;
|
|
57
|
+
protected getSchemaId(id: string, propertyKey: string): string;
|
|
58
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import { JsonMapperCompiler } from "./JsonMapperCompiler";
|
|
3
|
+
import { JsonSerializerOptions } from "./JsonSerializerOptions";
|
|
4
|
+
export declare class JsonSerializer extends JsonMapperCompiler<JsonSerializerOptions> {
|
|
5
|
+
constructor();
|
|
6
|
+
map(input: any, options?: JsonSerializerOptions): any;
|
|
7
|
+
protected alterValue(schemaId: string, value: any, options: JsonSerializerOptions): any;
|
|
8
|
+
protected createMapper(model: Type<any>, id: string, groups: false | string[]): string;
|
|
9
|
+
private mapOptions;
|
|
10
|
+
private mapProperty;
|
|
11
|
+
private getPropertyFiller;
|
|
12
|
+
private mapPrecondition;
|
|
13
|
+
private mapDiscriminator;
|
|
14
|
+
private mapAdditionalProperties;
|
|
15
|
+
private mapObject;
|
|
16
|
+
private mapSet;
|
|
17
|
+
private mapArray;
|
|
18
|
+
private mapMap;
|
|
19
|
+
private mapItem;
|
|
20
|
+
private mapJSON;
|
|
21
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MetadataTypes, Type } from "@tsed/core";
|
|
2
|
+
import { JsonMapperMethods } from "../interfaces/JsonMapperMethods";
|
|
3
|
+
export interface JsonSerializerOptions<T = any, C = any> extends MetadataTypes<T, C> {
|
|
4
|
+
/**
|
|
5
|
+
* Types used to map complex types (Symbol, Number, String, etc...)
|
|
6
|
+
*/
|
|
7
|
+
types?: Map<Type<any> | Symbol | string, JsonMapperMethods>;
|
|
8
|
+
/**
|
|
9
|
+
* useAlias mapping
|
|
10
|
+
*/
|
|
11
|
+
useAlias?: boolean;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare class Writer {
|
|
2
|
+
static object: {
|
|
3
|
+
assign(...args: string[]): string;
|
|
4
|
+
};
|
|
5
|
+
protected _root?: Writer;
|
|
6
|
+
protected body: (string | Writer)[];
|
|
7
|
+
private _indent;
|
|
8
|
+
constructor(root?: Writer);
|
|
9
|
+
static indent(lines: string[]): string[];
|
|
10
|
+
static mapper(mapperId: string, key: string, options: string): string;
|
|
11
|
+
static mapperFrom(key: string, options: string): string;
|
|
12
|
+
static options(...args: string[]): string;
|
|
13
|
+
add(...lines: (undefined | string | Writer)[]): this;
|
|
14
|
+
arrow(...args: string[]): Writer;
|
|
15
|
+
build(): string[];
|
|
16
|
+
callMapper(id: string, key: string, ...options: string[]): this;
|
|
17
|
+
returnCallMapper(id: string, key: string, ...options: string[]): Writer;
|
|
18
|
+
const(name: string, line: string): this;
|
|
19
|
+
each(iterable: string, args?: string[]): Writer;
|
|
20
|
+
if(condition: string): IfWriter;
|
|
21
|
+
switch(input: string): SwitchWriter;
|
|
22
|
+
indent(indent: boolean): this;
|
|
23
|
+
new(indent?: boolean): Writer;
|
|
24
|
+
return(line: string): Writer;
|
|
25
|
+
root(): Writer;
|
|
26
|
+
set(left: string, right: string): this;
|
|
27
|
+
toString(): string;
|
|
28
|
+
}
|
|
29
|
+
declare class IfWriter extends Writer {
|
|
30
|
+
protected condition: string;
|
|
31
|
+
protected elseWriter?: Writer;
|
|
32
|
+
constructor(condition: string, root: Writer);
|
|
33
|
+
else(): Writer;
|
|
34
|
+
build(): string[];
|
|
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
|
+
}
|
|
43
|
+
export {};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
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";
|
|
15
|
-
export * from "./domain/
|
|
12
|
+
export * from "./domain/JsonDeserializer";
|
|
13
|
+
export * from "./domain/JsonDeserializerOptions";
|
|
14
|
+
export * from "./domain/JsonMapperCompiler";
|
|
16
15
|
export * from "./domain/JsonMapperSettings";
|
|
17
16
|
export * from "./domain/JsonMapperTypesContainer";
|
|
17
|
+
export * from "./domain/JsonSerializer";
|
|
18
|
+
export * from "./domain/JsonSerializerOptions";
|
|
19
|
+
export * from "./domain/Writer";
|
|
18
20
|
export * from "./hooks/alterAfterDeserialize";
|
|
19
21
|
export * from "./hooks/alterBeforeDeserialize";
|
|
22
|
+
export * from "./hooks/alterOnDeserialize";
|
|
23
|
+
export * from "./hooks/alterOnSerialize";
|
|
20
24
|
export * from "./interfaces/JsonMapperMethods";
|
|
21
25
|
export * from "./utils/deserialize";
|
|
26
|
+
export * from "./utils/getObjectProperties";
|
|
22
27
|
export * from "./utils/serialize";
|
|
@@ -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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getObjectProperties(obj: any): [string, any][];
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
import { MetadataTypes, Type } from "@tsed/core";
|
|
2
|
-
import "../components/ArrayMapper";
|
|
3
1
|
import "../components/DateMapper";
|
|
4
|
-
import "../components/MapMapper";
|
|
5
2
|
import "../components/PrimitiveMapper";
|
|
6
|
-
import "../components/SetMapper";
|
|
7
3
|
import "../components/SymbolMapper";
|
|
8
|
-
import {
|
|
9
|
-
export
|
|
10
|
-
/**
|
|
11
|
-
* Types used to map complex types (Symbol, Array, Set, Map)
|
|
12
|
-
*/
|
|
13
|
-
types?: Map<Type<any>, JsonMapperMethods>;
|
|
14
|
-
/**
|
|
15
|
-
* useAlias mapping
|
|
16
|
-
*/
|
|
17
|
-
useAlias?: boolean;
|
|
18
|
-
[key: string]: any;
|
|
19
|
-
}
|
|
20
|
-
export declare function classToPlainObject(obj: any, options: JsonSerializerOptions<any, any>): any;
|
|
21
|
-
export declare function serialize(obj: any, { type, collectionType, groups, ...options }?: JsonSerializerOptions): any;
|
|
4
|
+
import { JsonSerializerOptions } from "../domain/JsonSerializerOptions";
|
|
5
|
+
export declare function serialize(input: any, options?: JsonSerializerOptions): any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/json-mapper",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.36.0-rc.2",
|
|
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.
|
|
45
|
-
"@tsed/eslint": "7.
|
|
46
|
-
"@tsed/schema": "7.
|
|
47
|
-
"@tsed/typescript": "7.
|
|
44
|
+
"@tsed/core": "7.36.0-rc.2",
|
|
45
|
+
"@tsed/eslint": "7.36.0-rc.2",
|
|
46
|
+
"@tsed/schema": "7.36.0-rc.2",
|
|
47
|
+
"@tsed/typescript": "7.36.0-rc.2",
|
|
48
48
|
"eslint": "^8.12.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@tsed/core": "^7.
|
|
52
|
-
"@tsed/schema": "^7.
|
|
51
|
+
"@tsed/core": "^7.36.0-rc.2",
|
|
52
|
+
"@tsed/schema": "^7.36.0-rc.2"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {
|
|
55
55
|
"@tsed/core": {
|
|
@@ -65,5 +65,8 @@
|
|
|
65
65
|
},
|
|
66
66
|
"homepage": "https://github.com/tsedio/tsed/tree/production/packages/specs/json-mapper",
|
|
67
67
|
"author": "Romain Lenzotti",
|
|
68
|
-
"license": "MIT"
|
|
68
|
+
"license": "MIT",
|
|
69
|
+
"publishConfig": {
|
|
70
|
+
"tag": "rc"
|
|
71
|
+
}
|
|
69
72
|
}
|
|
@@ -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
|
-
}
|