@dipscope/type-manager 3.0.0 → 4.0.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/CHANGELOG.md +33 -0
- package/README.md +653 -119
- package/core/discriminant.d.ts +8 -0
- package/core/discriminator.d.ts +6 -0
- package/core/fn.d.ts +21 -11
- package/core/generic-argument.d.ts +1 -1
- package/core/generic-metadata.d.ts +1 -1
- package/core/index.d.ts +8 -0
- package/core/index.js +2 -2
- package/core/inject-index.d.ts +6 -0
- package/core/inject-metadata.d.ts +15 -14
- package/core/inject-options.d.ts +5 -5
- package/core/log.d.ts +6 -6
- package/core/metadata.d.ts +3 -3
- package/core/property-metadata.d.ts +24 -36
- package/core/property-name.d.ts +6 -0
- package/core/property-options.d.ts +58 -2
- package/core/serializer-context-options.d.ts +6 -6
- package/core/serializer-context.d.ts +65 -6
- package/core/type-abstraction.d.ts +8 -0
- package/core/type-argument.d.ts +2 -2
- package/core/type-ctor.d.ts +1 -1
- package/core/type-fn.d.ts +8 -0
- package/core/type-like.d.ts +1 -1
- package/core/type-metadata-symbol.d.ts +6 -0
- package/core/type-metadata.d.ts +118 -28
- package/core/type-name.d.ts +6 -0
- package/core/type-options-base.d.ts +15 -8
- package/core/type-options.d.ts +21 -5
- package/core/type-resolver.d.ts +2 -2
- package/discriminant.d.ts +11 -0
- package/discriminator.d.ts +11 -0
- package/factories/index.js +2 -2
- package/factory.d.ts +4 -4
- package/index.d.ts +3 -3
- package/index.js +2 -2
- package/inject.d.ts +3 -3
- package/injector.d.ts +3 -3
- package/injectors/index.js +2 -2
- package/naming-conventions/index.js +2 -2
- package/naming-conventions/pascal-case.naming-convention.d.ts +1 -1
- package/package.json +1 -1
- package/preserve-discriminator.d.ts +10 -0
- package/property.d.ts +3 -3
- package/reference-handlers/index.js +2 -2
- package/reference-handlers/path.reference-handler.d.ts +22 -6
- package/serializers/index.js +2 -2
- package/type-manager-options.d.ts +3 -3
- package/type-manager.d.ts +217 -46
- package/inject-artisan.d.ts +0 -20
- package/property-artisan.d.ts +0 -20
- package/type-artisan.d.ts +0 -95
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { InjectIndex } from './inject-index';
|
|
1
2
|
import { InjectOptions } from './inject-options';
|
|
2
3
|
import { Metadata } from './metadata';
|
|
3
|
-
import {
|
|
4
|
+
import { TypeFn } from './type-fn';
|
|
4
5
|
import { TypeMetadata } from './type-metadata';
|
|
5
6
|
/**
|
|
6
7
|
* Main class used to describe an injection.
|
|
@@ -15,19 +16,19 @@ export declare class InjectMetadata<TDeclaringType, TType> extends Metadata {
|
|
|
15
16
|
*/
|
|
16
17
|
readonly declaringTypeMetadata: TypeMetadata<TDeclaringType>;
|
|
17
18
|
/**
|
|
18
|
-
*
|
|
19
|
+
* Type function defined using reflect metadata.
|
|
20
|
+
*
|
|
21
|
+
* Used as a fallback when type function is not defined.
|
|
19
22
|
*
|
|
20
|
-
* @type {
|
|
23
|
+
* @type {TypeFn<TType>}
|
|
21
24
|
*/
|
|
22
|
-
readonly
|
|
25
|
+
readonly reflectTypeFn: TypeFn<TType>;
|
|
23
26
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* Used as a fallback when type constructor is not defined.
|
|
27
|
+
* Index of injection within a type constructor function.
|
|
27
28
|
*
|
|
28
|
-
* @type {
|
|
29
|
+
* @type {InjectIndex}
|
|
29
30
|
*/
|
|
30
|
-
readonly
|
|
31
|
+
readonly injectIndex: InjectIndex;
|
|
31
32
|
/**
|
|
32
33
|
* Inject options.
|
|
33
34
|
*
|
|
@@ -38,10 +39,10 @@ export declare class InjectMetadata<TDeclaringType, TType> extends Metadata {
|
|
|
38
39
|
* Constructor.
|
|
39
40
|
*
|
|
40
41
|
* @param {TypeMetadata<TDeclaringType>} declaringTypeMetadata Type metadata to which inject metadata belongs to.
|
|
41
|
-
* @param {
|
|
42
|
+
* @param {InjectIndex} injectIndex Index of injection within a type constructor function.
|
|
42
43
|
* @param {InjectOptions<TType>} injectOptions Inject options.
|
|
43
44
|
*/
|
|
44
|
-
constructor(declaringTypeMetadata: TypeMetadata<TDeclaringType>,
|
|
45
|
+
constructor(declaringTypeMetadata: TypeMetadata<TDeclaringType>, injectIndex: InjectIndex, injectOptions: InjectOptions<TType>);
|
|
45
46
|
/**
|
|
46
47
|
* Gets key.
|
|
47
48
|
*
|
|
@@ -49,11 +50,11 @@ export declare class InjectMetadata<TDeclaringType, TType> extends Metadata {
|
|
|
49
50
|
*/
|
|
50
51
|
get key(): string | undefined;
|
|
51
52
|
/**
|
|
52
|
-
* Gets type
|
|
53
|
+
* Gets type function.
|
|
53
54
|
*
|
|
54
|
-
* @returns {
|
|
55
|
+
* @returns {TypeFn<TType>|undefined} Type constructor or undefined.
|
|
55
56
|
*/
|
|
56
|
-
get
|
|
57
|
+
get typeFn(): TypeFn<TType> | undefined;
|
|
57
58
|
/**
|
|
58
59
|
* Gets inject type metadata.
|
|
59
60
|
*
|
package/core/inject-options.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TypeFn } from './type-fn';
|
|
2
2
|
/**
|
|
3
3
|
* Inject options.
|
|
4
4
|
*
|
|
@@ -6,8 +6,8 @@ import { TypeCtor } from './type-ctor';
|
|
|
6
6
|
*/
|
|
7
7
|
export interface InjectOptions<TType> {
|
|
8
8
|
/**
|
|
9
|
-
* Parameter key to inject within a type context. If specified
|
|
10
|
-
* type
|
|
9
|
+
* Parameter key to inject within a type context. If specified then
|
|
10
|
+
* type function will be ignored.
|
|
11
11
|
*
|
|
12
12
|
* @type {string}
|
|
13
13
|
*/
|
|
@@ -16,7 +16,7 @@ export interface InjectOptions<TType> {
|
|
|
16
16
|
* Type of injection. Used if key is not specified. Will be resolved using
|
|
17
17
|
* type injector.
|
|
18
18
|
*
|
|
19
|
-
* @type {
|
|
19
|
+
* @type {TypeFn<TType>}
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
typeFn?: TypeFn<TType>;
|
|
22
22
|
}
|
package/core/log.d.ts
CHANGED
|
@@ -39,27 +39,27 @@ export declare class Log {
|
|
|
39
39
|
* Displays info message.
|
|
40
40
|
*
|
|
41
41
|
* @param {string} message Message to display.
|
|
42
|
-
* @param {any
|
|
42
|
+
* @param {Array<any>} optionalParams Optional data related to a message.
|
|
43
43
|
*
|
|
44
44
|
* @returns {void}
|
|
45
45
|
*/
|
|
46
|
-
info(message: string, ...optionalParams: any
|
|
46
|
+
info(message: string, ...optionalParams: Array<any>): void;
|
|
47
47
|
/**
|
|
48
48
|
* Displays warn message.
|
|
49
49
|
*
|
|
50
50
|
* @param {string} message Message to display.
|
|
51
|
-
* @param {any
|
|
51
|
+
* @param {Array<any>} optionalParams Optional data related to a message.
|
|
52
52
|
*
|
|
53
53
|
* @returns {void}
|
|
54
54
|
*/
|
|
55
|
-
warn(message: any, ...optionalParams: any
|
|
55
|
+
warn(message: any, ...optionalParams: Array<any>): void;
|
|
56
56
|
/**
|
|
57
57
|
* Displays error message.
|
|
58
58
|
*
|
|
59
59
|
* @param {string} message Message to display.
|
|
60
|
-
* @param {any
|
|
60
|
+
* @param {Array<any>} optionalParams Optional data related to a message.
|
|
61
61
|
*
|
|
62
62
|
* @returns {void}
|
|
63
63
|
*/
|
|
64
|
-
error(message: string, ...optionalParams: any
|
|
64
|
+
error(message: string, ...optionalParams: Array<any>): void;
|
|
65
65
|
}
|
package/core/metadata.d.ts
CHANGED
|
@@ -34,9 +34,9 @@ export declare class Metadata {
|
|
|
34
34
|
/**
|
|
35
35
|
* Defines generic metadatas based on provided generic arguments.
|
|
36
36
|
*
|
|
37
|
-
* @param {GenericArgument<any
|
|
37
|
+
* @param {Array<GenericArgument<any>>} genericArguments Generic arguments.
|
|
38
38
|
*
|
|
39
|
-
* @returns {GenericMetadata<any
|
|
39
|
+
* @returns {Array<GenericMetadata<any>>} Generics metadatas.
|
|
40
40
|
*/
|
|
41
|
-
protected defineGenericMetadatas(genericArguments: GenericArgument<any
|
|
41
|
+
protected defineGenericMetadatas(genericArguments: Array<GenericArgument<any>>): Array<GenericMetadata<any>>;
|
|
42
42
|
}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { Alias } from './alias';
|
|
2
2
|
import { CustomData } from './custom-data';
|
|
3
|
-
import { Factory } from './factory';
|
|
4
3
|
import { GenericArgument } from './generic-argument';
|
|
5
4
|
import { GenericMetadata } from './generic-metadata';
|
|
6
|
-
import { Injector } from './injector';
|
|
7
|
-
import { Log } from './log';
|
|
8
5
|
import { Metadata } from './metadata';
|
|
9
6
|
import { NamingConvention } from './naming-convention';
|
|
7
|
+
import { PropertyName } from './property-name';
|
|
10
8
|
import { PropertyOptions } from './property-options';
|
|
11
9
|
import { ReferenceHandler } from './reference-handler';
|
|
12
10
|
import { Serializer } from './serializer';
|
|
13
11
|
import { TypeArgument } from './type-argument';
|
|
14
|
-
import {
|
|
12
|
+
import { TypeFn } from './type-fn';
|
|
15
13
|
import { TypeMetadata } from './type-metadata';
|
|
16
14
|
/**
|
|
17
15
|
* Main class used to describe a certain property.
|
|
@@ -26,19 +24,19 @@ export declare class PropertyMetadata<TDeclaringType, TType> extends Metadata {
|
|
|
26
24
|
*/
|
|
27
25
|
readonly declaringTypeMetadata: TypeMetadata<TDeclaringType>;
|
|
28
26
|
/**
|
|
29
|
-
*
|
|
27
|
+
* Type function defined using reflect metadata.
|
|
28
|
+
*
|
|
29
|
+
* Used as a fallback when type argument is not defined.
|
|
30
30
|
*
|
|
31
|
-
* @type {
|
|
31
|
+
* @type {TypeFn<TType>}
|
|
32
32
|
*/
|
|
33
|
-
readonly
|
|
33
|
+
readonly reflectTypeFn: TypeFn<TType>;
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* Used as a fallback when type argument is not defined.
|
|
35
|
+
* Property name as declared in type.
|
|
38
36
|
*
|
|
39
|
-
* @type {
|
|
37
|
+
* @type {PropertyName}
|
|
40
38
|
*/
|
|
41
|
-
readonly
|
|
39
|
+
readonly propertyName: PropertyName;
|
|
42
40
|
/**
|
|
43
41
|
* Property options.
|
|
44
42
|
*
|
|
@@ -49,10 +47,10 @@ export declare class PropertyMetadata<TDeclaringType, TType> extends Metadata {
|
|
|
49
47
|
* Constructor.
|
|
50
48
|
*
|
|
51
49
|
* @param {TypeMetadata<TDeclaringType>} declaringTypeMetadata Type metadata to which property metadata belongs to.
|
|
52
|
-
* @param {
|
|
50
|
+
* @param {PropertyName} propertyName Property name.
|
|
53
51
|
* @param {PropertyOptions<TType>} propertyOptions Property options.
|
|
54
52
|
*/
|
|
55
|
-
constructor(declaringTypeMetadata: TypeMetadata<TDeclaringType>,
|
|
53
|
+
constructor(declaringTypeMetadata: TypeMetadata<TDeclaringType>, propertyName: PropertyName, propertyOptions: PropertyOptions<TType>);
|
|
56
54
|
/**
|
|
57
55
|
* Gets alias.
|
|
58
56
|
*
|
|
@@ -77,36 +75,18 @@ export declare class PropertyMetadata<TDeclaringType, TType> extends Metadata {
|
|
|
77
75
|
* @returns {boolean|undefined} Deserializable indicator or undefined.
|
|
78
76
|
*/
|
|
79
77
|
get deserializable(): boolean | undefined;
|
|
80
|
-
/**
|
|
81
|
-
* Gets factory.
|
|
82
|
-
*
|
|
83
|
-
* @returns {Factory} Factory.
|
|
84
|
-
*/
|
|
85
|
-
get factory(): Factory;
|
|
86
78
|
/**
|
|
87
79
|
* Gets generic arguments.
|
|
88
80
|
*
|
|
89
|
-
* @returns {GenericArgument<any
|
|
81
|
+
* @returns {Array<GenericArgument<any>>|undefined} Generic arguments or undefined.
|
|
90
82
|
*/
|
|
91
|
-
get genericArguments(): GenericArgument<any
|
|
83
|
+
get genericArguments(): Array<GenericArgument<any>> | undefined;
|
|
92
84
|
/**
|
|
93
85
|
* Gets generic metadatas.
|
|
94
86
|
*
|
|
95
|
-
* @returns {GenericMetadata<any
|
|
96
|
-
*/
|
|
97
|
-
get genericMetadatas(): GenericMetadata<any>[] | undefined;
|
|
98
|
-
/**
|
|
99
|
-
* Gets injector.
|
|
100
|
-
*
|
|
101
|
-
* @returns {Injector} Injector.
|
|
102
|
-
*/
|
|
103
|
-
get injector(): Injector;
|
|
104
|
-
/**
|
|
105
|
-
* Gets log.
|
|
106
|
-
*
|
|
107
|
-
* @returns {Log} Log.
|
|
87
|
+
* @returns {Array<GenericMetadata<any>>|undefined} Generic metadatas.
|
|
108
88
|
*/
|
|
109
|
-
get
|
|
89
|
+
get genericMetadatas(): Array<GenericMetadata<any>> | undefined;
|
|
110
90
|
/**
|
|
111
91
|
* Gets naming convention.
|
|
112
92
|
*
|
|
@@ -161,6 +141,14 @@ export declare class PropertyMetadata<TDeclaringType, TType> extends Metadata {
|
|
|
161
141
|
* @returns {boolean} Use implicit conversion indicator.
|
|
162
142
|
*/
|
|
163
143
|
get useImplicitConversion(): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Configures custom data.
|
|
146
|
+
*
|
|
147
|
+
* @param {CustomData} customData Custom data.
|
|
148
|
+
*
|
|
149
|
+
* @returns {PropertyMetadata<TDeclaringType, TType>} Instance of property metadata.
|
|
150
|
+
*/
|
|
151
|
+
private configureCustomData;
|
|
164
152
|
/**
|
|
165
153
|
* Configures property metadata based on provided options.
|
|
166
154
|
*
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { Alias } from './alias';
|
|
2
|
+
import { CustomData } from './custom-data';
|
|
3
|
+
import { GenericArgument } from './generic-argument';
|
|
4
|
+
import { NamingConvention } from './naming-convention';
|
|
5
|
+
import { ReferenceHandler } from './reference-handler';
|
|
6
|
+
import { Serializer } from './serializer';
|
|
2
7
|
import { TypeArgument } from './type-argument';
|
|
3
|
-
import { TypeOptionsBase } from './type-options-base';
|
|
4
8
|
/**
|
|
5
9
|
* Property options.
|
|
6
10
|
*
|
|
7
11
|
* @type {PropertyOptions<TType>}
|
|
8
12
|
*/
|
|
9
|
-
export interface PropertyOptions<TType>
|
|
13
|
+
export interface PropertyOptions<TType> {
|
|
10
14
|
/**
|
|
11
15
|
* Property alias.
|
|
12
16
|
*
|
|
@@ -15,22 +19,74 @@ export interface PropertyOptions<TType> extends Partial<TypeOptionsBase<TType>>
|
|
|
15
19
|
* @type {Alias}
|
|
16
20
|
*/
|
|
17
21
|
alias?: Alias;
|
|
22
|
+
/**
|
|
23
|
+
* Custom developer data.
|
|
24
|
+
*
|
|
25
|
+
* @type {CustomData}
|
|
26
|
+
*/
|
|
27
|
+
customData?: CustomData;
|
|
28
|
+
/**
|
|
29
|
+
* Default value for undefined ones.
|
|
30
|
+
*
|
|
31
|
+
* Can be a lazy function which returns a value. Assigned only when
|
|
32
|
+
* use default value option is true.
|
|
33
|
+
*
|
|
34
|
+
* @type {any}
|
|
35
|
+
*/
|
|
36
|
+
defaultValue?: any;
|
|
18
37
|
/**
|
|
19
38
|
* Deserializable from object?
|
|
20
39
|
*
|
|
21
40
|
* @type {boolean}
|
|
22
41
|
*/
|
|
23
42
|
deserializable?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Generic arguments.
|
|
45
|
+
*
|
|
46
|
+
* @type {Array<GenericArgument<any>>}
|
|
47
|
+
*/
|
|
48
|
+
genericArguments?: Array<GenericArgument<any>>;
|
|
49
|
+
/**
|
|
50
|
+
* Naming convention.
|
|
51
|
+
*
|
|
52
|
+
* @type {NamingConvention}
|
|
53
|
+
*/
|
|
54
|
+
namingConvention?: NamingConvention;
|
|
55
|
+
/**
|
|
56
|
+
* Reference handler.
|
|
57
|
+
*
|
|
58
|
+
* @type {ReferenceHandler}
|
|
59
|
+
*/
|
|
60
|
+
referenceHandler?: ReferenceHandler;
|
|
24
61
|
/**
|
|
25
62
|
* Serializable to object?
|
|
26
63
|
*
|
|
27
64
|
* @type {boolean}
|
|
28
65
|
*/
|
|
29
66
|
serializable?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Serializer used to serialize and deserialize a property.
|
|
69
|
+
*
|
|
70
|
+
* @type {Serializer<TType>}
|
|
71
|
+
*/
|
|
72
|
+
serializer?: Serializer<TType>;
|
|
30
73
|
/**
|
|
31
74
|
* Type argument.
|
|
32
75
|
*
|
|
33
76
|
* @type {TypeArgument<TType>}
|
|
34
77
|
*/
|
|
35
78
|
typeArgument?: TypeArgument<TType>;
|
|
79
|
+
/**
|
|
80
|
+
* Use default value assignment for undefined values?
|
|
81
|
+
*
|
|
82
|
+
* @type {boolean}
|
|
83
|
+
*/
|
|
84
|
+
useDefaultValue?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Use implicit conversion when provided value can be converted
|
|
87
|
+
* to the target one?
|
|
88
|
+
*
|
|
89
|
+
* @type {boolean}
|
|
90
|
+
*/
|
|
91
|
+
useImplicitConversion?: boolean;
|
|
36
92
|
}
|
|
@@ -21,9 +21,9 @@ export interface SerializerContextOptions<TType> {
|
|
|
21
21
|
/**
|
|
22
22
|
* Generic arguments.
|
|
23
23
|
*
|
|
24
|
-
* @type {GenericArgument<any
|
|
24
|
+
* @type {Array<GenericArgument<any>>}
|
|
25
25
|
*/
|
|
26
|
-
genericArguments?: GenericArgument<any
|
|
26
|
+
genericArguments?: Array<GenericArgument<any>>;
|
|
27
27
|
/**
|
|
28
28
|
* JSONPath from serializer context root.
|
|
29
29
|
*
|
|
@@ -33,7 +33,7 @@ export interface SerializerContextOptions<TType> {
|
|
|
33
33
|
*/
|
|
34
34
|
path: string;
|
|
35
35
|
/**
|
|
36
|
-
* Property metadata
|
|
36
|
+
* Property metadata.
|
|
37
37
|
*
|
|
38
38
|
* @type {PropertyMetadata<any, TType>}
|
|
39
39
|
*/
|
|
@@ -43,9 +43,9 @@ export interface SerializerContextOptions<TType> {
|
|
|
43
43
|
*
|
|
44
44
|
* Used to assign object references in a later time due to circular dependency.
|
|
45
45
|
*
|
|
46
|
-
* @type {WeakMap<ReferenceKey, ReferenceCallback
|
|
46
|
+
* @type {WeakMap<ReferenceKey, Array<ReferenceCallback>>}
|
|
47
47
|
*/
|
|
48
|
-
referenceCallbackMap: WeakMap<ReferenceKey, ReferenceCallback
|
|
48
|
+
referenceCallbackMap: WeakMap<ReferenceKey, Array<ReferenceCallback>>;
|
|
49
49
|
/**
|
|
50
50
|
* Reference map.
|
|
51
51
|
*
|
|
@@ -55,7 +55,7 @@ export interface SerializerContextOptions<TType> {
|
|
|
55
55
|
*/
|
|
56
56
|
referenceMap: WeakMap<ReferenceKey, ReferenceValue>;
|
|
57
57
|
/**
|
|
58
|
-
* Type metadata
|
|
58
|
+
* Type metadata.
|
|
59
59
|
*
|
|
60
60
|
* @type {TypeMetadata<TType>}
|
|
61
61
|
*/
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { CustomData } from './custom-data';
|
|
2
|
+
import { Discriminant } from './discriminant';
|
|
3
|
+
import { Discriminator } from './discriminator';
|
|
2
4
|
import { Factory } from './factory';
|
|
3
5
|
import { GenericArgument } from './generic-argument';
|
|
4
6
|
import { GenericMetadata } from './generic-metadata';
|
|
@@ -15,6 +17,7 @@ import { ReferenceValueInitializer } from './reference-value-initializer';
|
|
|
15
17
|
import { ReferenceValueResolver } from './reference-value-resolver';
|
|
16
18
|
import { Serializer } from './serializer';
|
|
17
19
|
import { SerializerContextOptions } from './serializer-context-options';
|
|
20
|
+
import { TypeFn } from './type-fn';
|
|
18
21
|
import { TypeLike } from './type-like';
|
|
19
22
|
import { TypeMetadata } from './type-metadata';
|
|
20
23
|
/**
|
|
@@ -53,6 +56,24 @@ export declare class SerializerContext<TType> extends Metadata {
|
|
|
53
56
|
* @returns {any|undefined} Resolved default value or undefined.
|
|
54
57
|
*/
|
|
55
58
|
get defaultValue(): any | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Gets discriminant.
|
|
61
|
+
*
|
|
62
|
+
* @returns {Discriminant} Discriminant.
|
|
63
|
+
*/
|
|
64
|
+
get discriminant(): Discriminant;
|
|
65
|
+
/**
|
|
66
|
+
* Gets discriminant map.
|
|
67
|
+
*
|
|
68
|
+
* @returns {Map<TypeFn<any>, Discriminant>} Discriminant map.
|
|
69
|
+
*/
|
|
70
|
+
get discriminantMap(): Map<TypeFn<any>, Discriminant>;
|
|
71
|
+
/**
|
|
72
|
+
* Gets discriminator.
|
|
73
|
+
*
|
|
74
|
+
* @returns {Discriminator} Discriminator.
|
|
75
|
+
*/
|
|
76
|
+
get discriminator(): Discriminator;
|
|
56
77
|
/**
|
|
57
78
|
* Gets factory.
|
|
58
79
|
*
|
|
@@ -62,15 +83,15 @@ export declare class SerializerContext<TType> extends Metadata {
|
|
|
62
83
|
/**
|
|
63
84
|
* Gets generic arguments.
|
|
64
85
|
*
|
|
65
|
-
* @returns {GenericArgument<any
|
|
86
|
+
* @returns {Array<GenericArgument<any>>|undefined} Generic arguments or undefined.
|
|
66
87
|
*/
|
|
67
|
-
get genericArguments(): GenericArgument<any
|
|
88
|
+
get genericArguments(): Array<GenericArgument<any>> | undefined;
|
|
68
89
|
/**
|
|
69
90
|
* Gets generic metadatas.
|
|
70
91
|
*
|
|
71
|
-
* @returns {GenericMetadata<any
|
|
92
|
+
* @returns {Array<GenericMetadata<any>>|undefined} Generic metadatas.
|
|
72
93
|
*/
|
|
73
|
-
get genericMetadatas(): GenericMetadata<any
|
|
94
|
+
get genericMetadatas(): Array<GenericMetadata<any>> | undefined;
|
|
74
95
|
/**
|
|
75
96
|
* Gets injector.
|
|
76
97
|
*
|
|
@@ -101,12 +122,24 @@ export declare class SerializerContext<TType> extends Metadata {
|
|
|
101
122
|
* @returns {string} Path.
|
|
102
123
|
*/
|
|
103
124
|
get path(): string;
|
|
125
|
+
/**
|
|
126
|
+
* Gets indicator if context is polymorphic.
|
|
127
|
+
*
|
|
128
|
+
* @returns {boolean} True when context is polymorphic. False otherwise.
|
|
129
|
+
*/
|
|
130
|
+
get polymorphic(): boolean;
|
|
104
131
|
/**
|
|
105
132
|
* Gets property metadata.
|
|
106
133
|
*
|
|
107
134
|
* @returns {PropertyMetadata<any, TType>|undefined} Property metadata or undefined.
|
|
108
135
|
*/
|
|
109
136
|
get propertyMetadata(): PropertyMetadata<any, TType> | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* Gets indicator if discriminator should be preserved.
|
|
139
|
+
*
|
|
140
|
+
* @returns {boolean} True when discriminator should be preserved. False otherwise.
|
|
141
|
+
*/
|
|
142
|
+
get preserveDiscriminator(): boolean;
|
|
110
143
|
/**
|
|
111
144
|
* Gets reference handler.
|
|
112
145
|
*
|
|
@@ -116,9 +149,9 @@ export declare class SerializerContext<TType> extends Metadata {
|
|
|
116
149
|
/**
|
|
117
150
|
* Gets reference callback map.
|
|
118
151
|
*
|
|
119
|
-
* @returns {WeakMap<ReferenceKey, ReferenceCallback
|
|
152
|
+
* @returns {WeakMap<ReferenceKey, Array<ReferenceCallback>>} Reference callback map.
|
|
120
153
|
*/
|
|
121
|
-
get referenceCallbackMap(): WeakMap<ReferenceKey, ReferenceCallback
|
|
154
|
+
get referenceCallbackMap(): WeakMap<ReferenceKey, Array<ReferenceCallback>>;
|
|
122
155
|
/**
|
|
123
156
|
* Gets reference map.
|
|
124
157
|
*
|
|
@@ -228,4 +261,30 @@ export declare class SerializerContext<TType> extends Metadata {
|
|
|
228
261
|
* @returns {SerializerContext<any>} Generic serializer context.
|
|
229
262
|
*/
|
|
230
263
|
defineGenericSerializerContext(genericIndex: number): SerializerContext<any>;
|
|
264
|
+
/**
|
|
265
|
+
* Defines polymorphic serializer context by type function.
|
|
266
|
+
*
|
|
267
|
+
* @param {TypeFn<any>} typeFn Type function.
|
|
268
|
+
*
|
|
269
|
+
* @returns {SerializerContext<any>} Polymorphic serializer context.
|
|
270
|
+
*/
|
|
271
|
+
private definePolymorphicSerializerContextByTypeFn;
|
|
272
|
+
/**
|
|
273
|
+
* Defines polymorphic serializer context by discriminant.
|
|
274
|
+
*
|
|
275
|
+
* @param {Record<string, any>} record Some record.
|
|
276
|
+
*
|
|
277
|
+
* @returns {SerializerContext<any>} Polymorphic serializer context.
|
|
278
|
+
*/
|
|
279
|
+
private definePolymorphicSerializerContextByDiscriminant;
|
|
280
|
+
/**
|
|
281
|
+
* Defines polymorphic serializer context.
|
|
282
|
+
*
|
|
283
|
+
* Called by serializers which work with polymorphic types.
|
|
284
|
+
*
|
|
285
|
+
* @param {TypeFn<any>|Record<string, any>} x Type function or record.
|
|
286
|
+
*
|
|
287
|
+
* @returns {SerializerContext<any>} Polymorphic serializer context.
|
|
288
|
+
*/
|
|
289
|
+
definePolymorphicSerializerContext(x: TypeFn<any> | Record<string, any>): SerializerContext<any>;
|
|
231
290
|
}
|
package/core/type-argument.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Alias } from './alias';
|
|
2
|
-
import {
|
|
2
|
+
import { TypeFn } from './type-fn';
|
|
3
3
|
import { TypeResolver } from './type-resolver';
|
|
4
4
|
/**
|
|
5
5
|
* Type argument represents a data which can be passed to define a certain type.
|
|
6
6
|
*
|
|
7
7
|
* @type {TypeArgument<TType>}
|
|
8
8
|
*/
|
|
9
|
-
export declare type TypeArgument<TType> = Alias |
|
|
9
|
+
export declare type TypeArgument<TType> = Alias | TypeFn<TType> | TypeResolver<TType>;
|
package/core/type-ctor.d.ts
CHANGED
package/core/type-like.d.ts
CHANGED