@dipscope/type-manager 4.0.4 → 5.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/{LICENSE.txt → LICENSE.md} +0 -0
  3. package/README.md +143 -321
  4. package/alias.d.ts +3 -7
  5. package/custom-data.d.ts +3 -8
  6. package/default-value-resolver.d.ts +7 -0
  7. package/default-value.d.ts +4 -7
  8. package/discriminant.d.ts +5 -8
  9. package/discriminator.d.ts +3 -8
  10. package/factories/type-factory.d.ts +3 -3
  11. package/factory.d.ts +15 -8
  12. package/functions/get-own-reflect-metadata.d.ts +9 -0
  13. package/functions/get-reflect-metadata.d.ts +10 -0
  14. package/functions/get-words.d.ts +8 -0
  15. package/functions/index.d.ts +16 -0
  16. package/functions/is-arrow-function.d.ts +8 -0
  17. package/functions/is-ctor-function.d.ts +8 -0
  18. package/functions/is-data-view.d.ts +8 -0
  19. package/functions/is-float-32-array.d.ts +8 -0
  20. package/functions/is-float-64-array.d.ts +8 -0
  21. package/functions/is-int-16-array.d.ts +8 -0
  22. package/functions/is-int-32-array.d.ts +8 -0
  23. package/functions/is-int-8-array.d.ts +8 -0
  24. package/functions/is-uint-16-array.d.ts +8 -0
  25. package/functions/is-uint-32-array.d.ts +8 -0
  26. package/functions/is-uint-8-array.d.ts +8 -0
  27. package/functions/is-uint-8-clamped-array.d.ts +8 -0
  28. package/functions/name-of.d.ts +8 -0
  29. package/{core/generic-argument.d.ts → generic-argument.d.ts} +0 -0
  30. package/{core/generic-metadata.d.ts → generic-metadata.d.ts} +0 -0
  31. package/index.d.ts +39 -7
  32. package/index.js +1 -2
  33. package/{core/inject-index.d.ts → inject-index.d.ts} +0 -0
  34. package/{core/inject-metadata.d.ts → inject-metadata.d.ts} +0 -0
  35. package/{core/inject-options.d.ts → inject-options.d.ts} +0 -0
  36. package/inject.d.ts +2 -2
  37. package/injector.d.ts +13 -8
  38. package/injectors/singleton-injector.d.ts +2 -2
  39. package/{core/log-level.d.ts → log-level.d.ts} +0 -0
  40. package/{core/log.d.ts → log.d.ts} +41 -11
  41. package/{core/metadata.d.ts → metadata.d.ts} +0 -0
  42. package/naming-convention.d.ts +12 -8
  43. package/naming-conventions/camel-case-naming-convention.d.ts +1 -1
  44. package/naming-conventions/flat-case-naming-convention.d.ts +1 -1
  45. package/naming-conventions/flat-upper-case-naming-convention.d.ts +1 -1
  46. package/naming-conventions/kebab-case-naming-convention.d.ts +1 -1
  47. package/naming-conventions/kebab-upper-case-naming-convention.d.ts +1 -1
  48. package/naming-conventions/pascal-case-naming-convention.d.ts +1 -1
  49. package/naming-conventions/snake-case-naming-convention.d.ts +1 -1
  50. package/naming-conventions/snake-upper-case-naming-convention.d.ts +1 -1
  51. package/package.json +6 -3
  52. package/{core/property-metadata.d.ts → property-metadata.d.ts} +18 -12
  53. package/{core/property-name.d.ts → property-name.d.ts} +0 -0
  54. package/{core/property-options.d.ts → property-options.d.ts} +21 -4
  55. package/property.d.ts +3 -2
  56. package/{core/reference-callback.d.ts → reference-callback.d.ts} +0 -0
  57. package/reference-handler.d.ts +29 -8
  58. package/reference-handlers/direct-reference-handler.d.ts +6 -6
  59. package/reference-handlers/lead-reference-handler.d.ts +6 -6
  60. package/reference-handlers/path-reference-handler.d.ts +6 -6
  61. package/{core/reference-key.d.ts → reference-key.d.ts} +0 -0
  62. package/{core/reference-value-initializer.d.ts → reference-value-initializer.d.ts} +0 -0
  63. package/{core/reference-value-resolver.d.ts → reference-value-resolver.d.ts} +0 -0
  64. package/{core/reference-value.d.ts → reference-value.d.ts} +0 -0
  65. package/{core/serializer-context-options.d.ts → serializer-context-options.d.ts} +0 -0
  66. package/{core/serializer-context.d.ts → serializer-context.d.ts} +9 -3
  67. package/serializer.d.ts +24 -8
  68. package/serializers/array-buffer-serializer.d.ts +3 -3
  69. package/serializers/array-serializer.d.ts +3 -3
  70. package/serializers/boolean-serializer.d.ts +3 -3
  71. package/serializers/data-view-serializer.d.ts +3 -3
  72. package/serializers/date-serializer.d.ts +3 -3
  73. package/serializers/float-32-array-serializer.d.ts +3 -3
  74. package/serializers/float-64-array-serializer.d.ts +3 -3
  75. package/serializers/int-16-array-serializer.d.ts +3 -3
  76. package/serializers/int-32-array-serializer.d.ts +3 -3
  77. package/serializers/int-8-array-serializer.d.ts +3 -3
  78. package/serializers/map-serializer.d.ts +3 -3
  79. package/serializers/number-serializer.d.ts +3 -3
  80. package/serializers/set-serializer.d.ts +3 -3
  81. package/serializers/string-serializer.d.ts +3 -3
  82. package/serializers/type-serializer.d.ts +3 -3
  83. package/serializers/uint-16-array-serializer.d.ts +3 -3
  84. package/serializers/uint-32-array-serializer.d.ts +3 -3
  85. package/serializers/uint-8-array-serializer.d.ts +3 -3
  86. package/serializers/uint-8-clamped-array-serializer.d.ts +3 -3
  87. package/{core/type-abstraction.d.ts → type-abstraction.d.ts} +0 -0
  88. package/{core/type-argument.d.ts → type-argument.d.ts} +0 -0
  89. package/{core/type-context-entry.d.ts → type-context-entry.d.ts} +0 -0
  90. package/{core/type-context.d.ts → type-context.d.ts} +0 -0
  91. package/{core/type-ctor.d.ts → type-ctor.d.ts} +0 -0
  92. package/{core/type-fn.d.ts → type-fn.d.ts} +0 -0
  93. package/{core/type-like.d.ts → type-like.d.ts} +0 -0
  94. package/type-manager-options.d.ts +3 -3
  95. package/type-manager.d.ts +10 -10
  96. package/{core/type-metadata-resolver.d.ts → type-metadata-resolver.d.ts} +0 -0
  97. package/{core/type-metadata-symbol.d.ts → type-metadata-symbol.d.ts} +0 -0
  98. package/{core/type-metadata.d.ts → type-metadata.d.ts} +9 -3
  99. package/{core/type-name.d.ts → type-name.d.ts} +0 -0
  100. package/{core/type-options-base.d.ts → type-options-base.d.ts} +0 -9
  101. package/{core/type-options.d.ts → type-options.d.ts} +26 -0
  102. package/{core/type-resolver.d.ts → type-resolver.d.ts} +0 -0
  103. package/type.d.ts +1 -1
  104. package/core/alias.d.ts +0 -6
  105. package/core/custom-data.d.ts +0 -6
  106. package/core/discriminant.d.ts +0 -8
  107. package/core/discriminator.d.ts +0 -6
  108. package/core/factory.d.ts +0 -18
  109. package/core/fn.d.ts +0 -316
  110. package/core/index.d.ts +0 -42
  111. package/core/index.js +0 -2
  112. package/core/injector.d.ts +0 -16
  113. package/core/naming-convention.d.ts +0 -15
  114. package/core/reference-handler.d.ts +0 -32
  115. package/core/serializer.d.ts +0 -27
  116. package/deserializable.d.ts +0 -11
  117. package/factories/index.js +0 -2
  118. package/injectable.d.ts +0 -10
  119. package/injectors/index.js +0 -2
  120. package/naming-conventions/index.js +0 -2
  121. package/preserve-discriminator.d.ts +0 -10
  122. package/reference-handlers/index.js +0 -2
  123. package/serializable.d.ts +0 -11
  124. package/serializers/index.js +0 -2
  125. package/type-and-property.d.ts +0 -12
  126. package/use-default-value.d.ts +0 -10
  127. package/use-implicit-conversion.d.ts +0 -10
File without changes
package/inject.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { InjectOptions } from './core/inject-options';
2
- import { TypeFn } from './core/type-fn';
1
+ import { InjectOptions } from './inject-options';
2
+ import { TypeFn } from './type-fn';
3
3
  /**
4
4
  * Inject decorator.
5
5
  *
package/injector.d.ts CHANGED
@@ -1,11 +1,16 @@
1
- import { Injector } from './core/injector';
1
+ import { TypeMetadata } from './type-metadata';
2
2
  /**
3
- * Injector decorator.
3
+ * Injector used to resolve dependent types.
4
4
  *
5
- * Used to define custom injector for a type.
6
- *
7
- * @param {Injector} injector Injector.
8
- *
9
- * @returns {ClassDecorator} Class decorator.
5
+ * @type {Injector}
10
6
  */
11
- export declare function Injector(injector: Injector): ClassDecorator;
7
+ export interface Injector {
8
+ /**
9
+ * Method to get instance described by type metadata.
10
+ *
11
+ * @param {TypeMetadata<TType>} typeMetadata Type metadata.
12
+ *
13
+ * @returns {TType|undefined} Instance of type described by type metadata or undefined.
14
+ */
15
+ get<TType>(typeMetadata: TypeMetadata<TType>): TType | undefined;
16
+ }
@@ -1,5 +1,5 @@
1
- import { Injector } from '../core/injector';
2
- import { TypeMetadata } from '../core/type-metadata';
1
+ import { Injector } from '../injector';
2
+ import { TypeMetadata } from '../type-metadata';
3
3
  /**
4
4
  * Singleton injector.
5
5
  *
File without changes
@@ -1,6 +1,6 @@
1
1
  import { LogLevel } from './log-level';
2
2
  /**
3
- * Main logger class.
3
+ * Main logger class used by serializers for displaying messages.
4
4
  *
5
5
  * @type {Log}
6
6
  */
@@ -10,31 +10,61 @@ export declare class Log {
10
10
  *
11
11
  * @type {LogLevel}
12
12
  */
13
- logLevel: LogLevel;
13
+ readonly logLevel: LogLevel;
14
14
  /**
15
- * Constructor.
15
+ * Info enabled?
16
16
  *
17
- * @param {LogLevel} logLevel Log level.
17
+ * @type {boolean}
18
18
  */
19
- constructor(logLevel: LogLevel);
19
+ readonly infoEnabled: boolean;
20
+ /**
21
+ * Warn enabled?
22
+ *
23
+ * @type {boolean}
24
+ */
25
+ readonly warnEnabled: boolean;
26
+ /**
27
+ * Error enabled?
28
+ *
29
+ * @type {boolean}
30
+ */
31
+ readonly errorEnabled: boolean;
32
+ /**
33
+ * Supports console?
34
+ *
35
+ * @type {boolean}
36
+ */
37
+ readonly supportsConsole: boolean;
38
+ /**
39
+ * Supports console log?
40
+ *
41
+ * @type {boolean}
42
+ */
43
+ readonly supportsConsoleLog: boolean;
20
44
  /**
21
- * Info log level is enabled?
45
+ * Supports console info?
22
46
  *
23
47
  * @type {boolean}
24
48
  */
25
- get infoEnabled(): boolean;
49
+ readonly supportsConsoleInfo: boolean;
26
50
  /**
27
- * Warn log level is enabled?
51
+ * Supports console warn?
28
52
  *
29
53
  * @type {boolean}
30
54
  */
31
- get warnEnabled(): boolean;
55
+ readonly supportsConsoleWarn: boolean;
32
56
  /**
33
- * Error log level is enabled?
57
+ * Supports console error?
34
58
  *
35
59
  * @type {boolean}
36
60
  */
37
- get errorEnabled(): boolean;
61
+ readonly supportsConsoleError: boolean;
62
+ /**
63
+ * Constructor.
64
+ *
65
+ * @param {LogLevel} logLevel Log level.
66
+ */
67
+ constructor(logLevel: LogLevel);
38
68
  /**
39
69
  * Displays info message.
40
70
  *
File without changes
@@ -1,11 +1,15 @@
1
- import { NamingConvention } from './core/naming-convention';
2
1
  /**
3
- * Naming convention decorator.
2
+ * Represents naming convention.
4
3
  *
5
- * Used to define custom naming convention for type and property.
6
- *
7
- * @param {NamingConvention} namingConvention Naming convention.
8
- *
9
- * @returns {ClassDecorator&PropertyDecorator} Class and property decorator.
4
+ * @type {NamingConvention}
10
5
  */
11
- export declare function NamingConvention(namingConvention: NamingConvention): ClassDecorator & PropertyDecorator;
6
+ export interface NamingConvention {
7
+ /**
8
+ * Converts name from provided to target one.
9
+ *
10
+ * @param {string} name Name.
11
+ *
12
+ * @returns {string} Converted name.
13
+ */
14
+ convert(name: string): string;
15
+ }
@@ -1,4 +1,4 @@
1
- import { NamingConvention } from '../core/naming-convention';
1
+ import { NamingConvention } from '../naming-convention';
2
2
  /**
3
3
  * Camel case naming convention.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { NamingConvention } from '../core/naming-convention';
1
+ import { NamingConvention } from '../naming-convention';
2
2
  /**
3
3
  * Flat case naming convention.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { NamingConvention } from '../core/naming-convention';
1
+ import { NamingConvention } from '../naming-convention';
2
2
  /**
3
3
  * Flat upper case naming convention.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { NamingConvention } from '../core/naming-convention';
1
+ import { NamingConvention } from '../naming-convention';
2
2
  /**
3
3
  * Kebab case naming convention.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { NamingConvention } from '../core/naming-convention';
1
+ import { NamingConvention } from '../naming-convention';
2
2
  /**
3
3
  * Kebab upper naming case.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { NamingConvention } from '../core/naming-convention';
1
+ import { NamingConvention } from '../naming-convention';
2
2
  /**
3
3
  * Pascal case naming convention.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { NamingConvention } from '../core/naming-convention';
1
+ import { NamingConvention } from '../naming-convention';
2
2
  /**
3
3
  * Snake case naming convention.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { NamingConvention } from '../core/naming-convention';
1
+ import { NamingConvention } from '../naming-convention';
2
2
  /**
3
3
  * Snake upper case naming convention.
4
4
  *
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "author": "DipScope authors and contributors",
3
- "dependencies": {},
3
+ "dependencies": {
4
+ "lodash": "^4.17.21"
5
+ },
4
6
  "description": "A package which will help you to transform your JSON strings or plain objects into JS object instances.",
5
7
  "devDependencies": {
8
+ "@types/lodash": "^4.14.182",
6
9
  "@types/jasmine": "^3.6.3",
7
10
  "@typescript-eslint/eslint-plugin": "^4.14.2",
8
11
  "@typescript-eslint/parser": "^4.14.2",
@@ -39,10 +42,10 @@
39
42
  "scripts": {
40
43
  "build": "npm run clean && npx webpack --config=webpack.config.js && npm run copy",
41
44
  "clean": "shx rm -rf dist",
42
- "copy": "shx cp CHANGELOG.md dist && shx cp LICENSE.txt dist && shx cp package.json dist && shx cp README.md dist",
45
+ "copy": "shx cp CHANGELOG.md dist && shx cp LICENSE.md dist && shx cp package.json dist && shx cp README.md dist",
43
46
  "test": "jasmine-ts --config=jasmine.json",
44
47
  "lint": "eslint . --ext .ts"
45
48
  },
46
49
  "types": "index.d.ts",
47
- "version": "4.0.4"
50
+ "version": "5.0.0-beta.0"
48
51
  }
@@ -64,23 +64,35 @@ export declare class PropertyMetadata<TDeclaringType, TType> extends Metadata {
64
64
  */
65
65
  get customData(): CustomData;
66
66
  /**
67
- * Gets default value.
67
+ * Gets serialized default value.
68
68
  *
69
- * @returns {any|undefined} Resolved default value or undefined.
69
+ * @returns {any|undefined} Resolved serialized default value or undefined.
70
70
  */
71
- get defaultValue(): any | undefined;
71
+ get serializedDefaultValue(): any | undefined;
72
72
  /**
73
- * Gets deserializable value.
73
+ * Gets deserialized default value.
74
74
  *
75
- * @returns {boolean|undefined} Deserializable indicator or undefined.
75
+ * @returns {any|undefined} Resolved deserialized default value or undefined.
76
76
  */
77
- get deserializable(): boolean | undefined;
77
+ get deserializedDefaultValue(): any | undefined;
78
+ /**
79
+ * Gets serialized property name.
80
+ *
81
+ * @returns {string} Serialized property name.
82
+ */
83
+ get serializedPropertyName(): string;
78
84
  /**
79
85
  * Gets deserialized property name.
80
86
  *
81
87
  * @returns {string} Deserialized property name.
82
88
  */
83
89
  get deserializedPropertyName(): string;
90
+ /**
91
+ * Gets deserializable value.
92
+ *
93
+ * @returns {boolean|undefined} Deserializable indicator or undefined.
94
+ */
95
+ get deserializable(): boolean | undefined;
84
96
  /**
85
97
  * Gets generic arguments.
86
98
  *
@@ -111,12 +123,6 @@ export declare class PropertyMetadata<TDeclaringType, TType> extends Metadata {
111
123
  * @returns {boolean|undefined} Serializable indicator or undefined.
112
124
  */
113
125
  get serializable(): boolean | undefined;
114
- /**
115
- * Gets serialized property name.
116
- *
117
- * @returns {string} Serialized property name.
118
- */
119
- get serializedPropertyName(): string;
120
126
  /**
121
127
  * Checks if serialization configured.
122
128
  *
File without changes
@@ -1,5 +1,6 @@
1
1
  import { Alias } from './alias';
2
2
  import { CustomData } from './custom-data';
3
+ import { DefaultValue } from './default-value';
3
4
  import { GenericArgument } from './generic-argument';
4
5
  import { NamingConvention } from './naming-convention';
5
6
  import { ReferenceHandler } from './reference-handler';
@@ -28,12 +29,28 @@ export interface PropertyOptions<TType> {
28
29
  /**
29
30
  * Default value for undefined ones.
30
31
  *
31
- * Can be a lazy function which returns a value. Assigned only when
32
- * use default value option is true.
32
+ * Used to set both serialized and deserialized default values and
33
+ * only when use default value option is true.
33
34
  *
34
- * @type {any}
35
+ * @type {DefaultValue}
35
36
  */
36
- defaultValue?: any;
37
+ defaultValue?: DefaultValue;
38
+ /**
39
+ * Serialized default value for undefined ones.
40
+ *
41
+ * Used only when use default value option is true.
42
+ *
43
+ * @type {DefaultValue}
44
+ */
45
+ serializedDefaultValue?: DefaultValue;
46
+ /**
47
+ * Deserialized default value for undefined ones.
48
+ *
49
+ * Used only when use default value option is true.
50
+ *
51
+ * @type {DefaultValue}
52
+ */
53
+ deserializedDefaultValue?: DefaultValue;
37
54
  /**
38
55
  * Deserializable from object?
39
56
  *
package/property.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { GenericArgument, TypeArgument } from './core';
2
- import { PropertyOptions } from './core/property-options';
1
+ import { GenericArgument } from './generic-argument';
2
+ import { PropertyOptions } from './property-options';
3
+ import { TypeArgument } from './type-argument';
3
4
  /**
4
5
  * Property decorator.
5
6
  *
@@ -1,11 +1,32 @@
1
- import { ReferenceHandler } from './core/reference-handler';
1
+ import { ReferenceKey } from './reference-key';
2
+ import { ReferenceValue } from './reference-value';
3
+ import { ReferenceValueInitializer } from './reference-value-initializer';
4
+ import { ReferenceValueResolver } from './reference-value-resolver';
5
+ import { SerializerContext } from './serializer-context';
2
6
  /**
3
- * Reference handler decorator.
7
+ * Reference handler to resolve object references.
4
8
  *
5
- * Used to define custom reference handler for type and property.
6
- *
7
- * @param {ReferenceHandler} referenceHandler Reference handler.
8
- *
9
- * @returns {ClassDecorator&PropertyDecorator} Class and property decorator.
9
+ * @type {ReferenceHandler}
10
10
  */
11
- export declare function ReferenceHandler(referenceHandler: ReferenceHandler): ClassDecorator & PropertyDecorator;
11
+ export interface ReferenceHandler {
12
+ /**
13
+ * Defines reference. Called during serialization.
14
+ *
15
+ * @param {SerializerContext<any>} serializerContext Serializer context.
16
+ * @param {ReferenceKey} referenceKey Reference which acts as a key. This is basically a serializing object.
17
+ * @param {ReferenceValueInitializer} referenceValueInitializer Function to initialize a reference value when one is not yet present for a key.
18
+ *
19
+ * @returns {ReferenceValue|ReferenceValueResolver} Resolved reference value or reference resolver when circular dependency is detected.
20
+ */
21
+ define(serializerContext: SerializerContext<any>, referenceKey: ReferenceKey, referenceValueInitializer: ReferenceValueInitializer): ReferenceValue | ReferenceValueResolver;
22
+ /**
23
+ * Restores reference. Called during deserialization.
24
+ *
25
+ * @param {SerializerContext<any>} serializerContext Serializer context.
26
+ * @param {ReferenceKey} referenceKey Reference which acts as a key. This is basically a deserializing object.
27
+ * @param {ReferenceValueInitializer} referenceValueInitializer Function to initialize a reference value when one is not yet present for a key.
28
+ *
29
+ * @returns {ReferenceValue|ReferenceValueResolver} Resolved reference value or reference resolver when circular dependency is detected.
30
+ */
31
+ restore(serializerContext: SerializerContext<any>, referenceKey: ReferenceKey, referenceValueInitializer: ReferenceValueInitializer): ReferenceValue | ReferenceValueResolver;
32
+ }
@@ -1,9 +1,9 @@
1
- import { ReferenceHandler } from '../core/reference-handler';
2
- import { ReferenceKey } from '../core/reference-key';
3
- import { ReferenceValue } from '../core/reference-value';
4
- import { ReferenceValueInitializer } from '../core/reference-value-initializer';
5
- import { ReferenceValueResolver } from '../core/reference-value-resolver';
6
- import { SerializerContext } from '../core/serializer-context';
1
+ import { ReferenceHandler } from '../reference-handler';
2
+ import { ReferenceKey } from '../reference-key';
3
+ import { ReferenceValue } from '../reference-value';
4
+ import { ReferenceValueInitializer } from '../reference-value-initializer';
5
+ import { ReferenceValueResolver } from '../reference-value-resolver';
6
+ import { SerializerContext } from '../serializer-context';
7
7
  /**
8
8
  * Direct reference handler which preserves references as is.
9
9
  *
@@ -1,9 +1,9 @@
1
- import { ReferenceHandler } from '../core/reference-handler';
2
- import { ReferenceKey } from '../core/reference-key';
3
- import { ReferenceValue } from '../core/reference-value';
4
- import { ReferenceValueInitializer } from '../core/reference-value-initializer';
5
- import { ReferenceValueResolver } from '../core/reference-value-resolver';
6
- import { SerializerContext } from '../core/serializer-context';
1
+ import { ReferenceHandler } from '../reference-handler';
2
+ import { ReferenceKey } from '../reference-key';
3
+ import { ReferenceValue } from '../reference-value';
4
+ import { ReferenceValueInitializer } from '../reference-value-initializer';
5
+ import { ReferenceValueResolver } from '../reference-value-resolver';
6
+ import { SerializerContext } from '../serializer-context';
7
7
  /**
8
8
  * Lead reference handler preserves references except circular. If circular reference is detected the it will
9
9
  * be setted to undefined so only first occurance is handled.
@@ -1,9 +1,9 @@
1
- import { ReferenceHandler } from '../core/reference-handler';
2
- import { ReferenceKey } from '../core/reference-key';
3
- import { ReferenceValue } from '../core/reference-value';
4
- import { ReferenceValueInitializer } from '../core/reference-value-initializer';
5
- import { ReferenceValueResolver } from '../core/reference-value-resolver';
6
- import { SerializerContext } from '../core/serializer-context';
1
+ import { ReferenceHandler } from '../reference-handler';
2
+ import { ReferenceKey } from '../reference-key';
3
+ import { ReferenceValue } from '../reference-value';
4
+ import { ReferenceValueInitializer } from '../reference-value-initializer';
5
+ import { ReferenceValueResolver } from '../reference-value-resolver';
6
+ import { SerializerContext } from '../serializer-context';
7
7
  /**
8
8
  * Path reference handler preserves references using JSONPath.
9
9
  *
File without changes
@@ -51,11 +51,17 @@ export declare class SerializerContext<TType> extends Metadata {
51
51
  */
52
52
  get customData(): CustomData;
53
53
  /**
54
- * Gets default value.
54
+ * Gets serialized default value.
55
55
  *
56
- * @returns {any|undefined} Resolved default value or undefined.
56
+ * @returns {any|undefined} Resolved serialized default value or undefined.
57
57
  */
58
- get defaultValue(): any | undefined;
58
+ get serializedDefaultValue(): any | undefined;
59
+ /**
60
+ * Gets deserialized default value.
61
+ *
62
+ * @returns {any|undefined} Resolved deserialized default value or undefined.
63
+ */
64
+ get deserializedDefaultValue(): any | undefined;
59
65
  /**
60
66
  * Gets discriminant.
61
67
  *
package/serializer.d.ts CHANGED
@@ -1,11 +1,27 @@
1
- import { Serializer } from './core/serializer';
1
+ import { SerializerContext } from './serializer-context';
2
+ import { TypeLike } from './type-like';
2
3
  /**
3
- * Serializer decorator.
4
+ * Serializer.
4
5
  *
5
- * Used to define custom serializer for type and property.
6
- *
7
- * @param {Serializer<TType>} serializer Serializer.
8
- *
9
- * @returns {ClassDecorator&PropertyDecorator} Class and property decorator.
6
+ * @type {Serializer<TType>}
10
7
  */
11
- export declare function Serializer<TType>(serializer: Serializer<TType>): ClassDecorator & PropertyDecorator;
8
+ export interface Serializer<TType> {
9
+ /**
10
+ * Serializes provided value.
11
+ *
12
+ * @param {TypeLike<TType>} x Some value.
13
+ * @param {SerializerContext<TType>} serializerContext Serializer context.
14
+ *
15
+ * @returns {TypeLike<any>} Serialized value.
16
+ */
17
+ serialize(x: TypeLike<TType>, serializerContext: SerializerContext<TType>): TypeLike<any>;
18
+ /**
19
+ * Deserializes provided value.
20
+ *
21
+ * @param {TypeLike<any>} x Some value.
22
+ * @param {SerializerContext<TType>} serializerContext Serializer context.
23
+ *
24
+ * @returns {TypeLike<TType>} Deserialized value.
25
+ */
26
+ deserialize(x: TypeLike<any>, serializerContext: SerializerContext<TType>): TypeLike<TType>;
27
+ }
@@ -1,6 +1,6 @@
1
- import { Serializer } from '../core/serializer';
2
- import { SerializerContext } from '../core/serializer-context';
3
- import { TypeLike } from '../core/type-like';
1
+ import { Serializer } from '../serializer';
2
+ import { SerializerContext } from '../serializer-context';
3
+ import { TypeLike } from '../type-like';
4
4
  /**
5
5
  * Array buffer serializer.
6
6
  *
@@ -1,6 +1,6 @@
1
- import { Serializer } from '../core/serializer';
2
- import { SerializerContext } from '../core/serializer-context';
3
- import { TypeLike } from '../core/type-like';
1
+ import { Serializer } from '../serializer';
2
+ import { SerializerContext } from '../serializer-context';
3
+ import { TypeLike } from '../type-like';
4
4
  /**
5
5
  * Array serializer.
6
6
  *
@@ -1,6 +1,6 @@
1
- import { Serializer } from '../core/serializer';
2
- import { SerializerContext } from '../core/serializer-context';
3
- import { TypeLike } from '../core/type-like';
1
+ import { Serializer } from '../serializer';
2
+ import { SerializerContext } from '../serializer-context';
3
+ import { TypeLike } from '../type-like';
4
4
  /**
5
5
  * Boolean serializer.
6
6
  *
@@ -1,6 +1,6 @@
1
- import { Serializer } from '../core/serializer';
2
- import { SerializerContext } from '../core/serializer-context';
3
- import { TypeLike } from '../core/type-like';
1
+ import { Serializer } from '../serializer';
2
+ import { SerializerContext } from '../serializer-context';
3
+ import { TypeLike } from '../type-like';
4
4
  /**
5
5
  * Data view serializer.
6
6
  *
@@ -1,6 +1,6 @@
1
- import { Serializer } from '../core/serializer';
2
- import { SerializerContext } from '../core/serializer-context';
3
- import { TypeLike } from '../core/type-like';
1
+ import { Serializer } from '../serializer';
2
+ import { SerializerContext } from '../serializer-context';
3
+ import { TypeLike } from '../type-like';
4
4
  /**
5
5
  * Date serializer.
6
6
  *
@@ -1,6 +1,6 @@
1
- import { Serializer } from '../core/serializer';
2
- import { SerializerContext } from '../core/serializer-context';
3
- import { TypeLike } from '../core/type-like';
1
+ import { Serializer } from '../serializer';
2
+ import { SerializerContext } from '../serializer-context';
3
+ import { TypeLike } from '../type-like';
4
4
  /**
5
5
  * Float 32 array serializer.
6
6
  *
@@ -1,6 +1,6 @@
1
- import { Serializer } from '../core/serializer';
2
- import { SerializerContext } from '../core/serializer-context';
3
- import { TypeLike } from '../core/type-like';
1
+ import { Serializer } from '../serializer';
2
+ import { SerializerContext } from '../serializer-context';
3
+ import { TypeLike } from '../type-like';
4
4
  /**
5
5
  * Float 64 array serializer.
6
6
  *
@@ -1,6 +1,6 @@
1
- import { Serializer } from '../core/serializer';
2
- import { SerializerContext } from '../core/serializer-context';
3
- import { TypeLike } from '../core/type-like';
1
+ import { Serializer } from '../serializer';
2
+ import { SerializerContext } from '../serializer-context';
3
+ import { TypeLike } from '../type-like';
4
4
  /**
5
5
  * Int 16 array serializer.
6
6
  *
@@ -1,6 +1,6 @@
1
- import { Serializer } from '../core/serializer';
2
- import { SerializerContext } from '../core/serializer-context';
3
- import { TypeLike } from '../core/type-like';
1
+ import { Serializer } from '../serializer';
2
+ import { SerializerContext } from '../serializer-context';
3
+ import { TypeLike } from '../type-like';
4
4
  /**
5
5
  * Int 32 array serializer.
6
6
  *
@@ -1,6 +1,6 @@
1
- import { Serializer } from '../core/serializer';
2
- import { SerializerContext } from '../core/serializer-context';
3
- import { TypeLike } from '../core/type-like';
1
+ import { Serializer } from '../serializer';
2
+ import { SerializerContext } from '../serializer-context';
3
+ import { TypeLike } from '../type-like';
4
4
  /**
5
5
  * Int 8 array serializer.
6
6
  *