@dipscope/type-manager 4.0.1 → 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 CHANGED
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [4.0.2] - 2022-05-01
9
+
10
+ ### Changed
11
+
12
+ - Used symbol instead of string based key to store type metadata.
13
+ - Avoid complete reset of custom data by providing `null` as argument.
14
+ - Code style improvements.
15
+
8
16
  ## [4.0.1] - 2021-08-01
9
17
 
10
18
  ### Changed
package/README.md CHANGED
@@ -6,6 +6,10 @@ Type manager is a parsing package for `TypeScript` which will help you to transf
6
6
 
7
7
  We recommend to use our [official website](https://dipscope.com/type-manager/what-issues-it-solves) to navigate through available features. You can also use the latest documentation described below.
8
8
 
9
+ ## Give a star :star:
10
+
11
+ If you like or are using this project please give it a star. Thanks!
12
+
9
13
  ## Table of contents
10
14
 
11
15
  * [What issues it solves?](#what-issues-it-solves)
@@ -1319,7 +1323,7 @@ It uses 2 special configurable type options:
1319
1323
 
1320
1324
  This options have default values if you have not configured them explicitly.
1321
1325
 
1322
- * Default value of discriminator is a `__type__`. During deserialization `TypeManager` expects such property to be present inside a polymorphic object.
1326
+ * Default value of discriminator is a `$type`. During deserialization `TypeManager` expects such property to be present inside a polymorphic object.
1323
1327
  * Default value of discriminant is a `ClassName` which determined based on the type function.
1324
1328
 
1325
1329
  For proper deserialization of polymorphic types you have to provide such information inside your JSON.
@@ -1328,18 +1332,18 @@ For proper deserialization of polymorphic types you have to provide such informa
1328
1332
  {
1329
1333
  "shapes": [
1330
1334
  {
1331
- "__type__": "Rectangle",
1335
+ "$type": "Rectangle",
1332
1336
  "title": "Cool rectangle",
1333
1337
  "width": 10,
1334
1338
  "height": 10
1335
1339
  },
1336
1340
  {
1337
- "__type__": "Square",
1341
+ "$type": "Square",
1338
1342
  "title": "Perfect square",
1339
1343
  "width": 10
1340
1344
  },
1341
1345
  {
1342
- "__type__": "Circle",
1346
+ "$type": "Circle",
1343
1347
  "title": "Simple circle",
1344
1348
  "radius": 6
1345
1349
  }
@@ -1349,7 +1353,7 @@ For proper deserialization of polymorphic types you have to provide such informa
1349
1353
 
1350
1354
  Now your JSON will be handled properly and you will get `Rectangle`, `Square` and `Circle` class instances in return.
1351
1355
 
1352
- In most cases your `Discriminator` and `Discriminant` values will not match to our default ones. For example library like [Json.NET](https://www.newtonsoft.com/json) can be used on the backend side to send a response from your API. It uses `$type` property as `Discriminator` and full name of class as `Discriminant`. In such scenario our JSON may look like this.
1356
+ In some cases your `Discriminator` or `Discriminant` values will not match to our default ones. For example library like [Json.NET](https://www.newtonsoft.com/json) can be used on the backend side to send a response from your API. It uses `$type` property as `Discriminator` and full name of class as `Discriminant`. In such scenario our JSON may look like this.
1353
1357
 
1354
1358
  ```json
1355
1359
  {
@@ -1381,7 +1385,7 @@ import { TypeManagerOptions } from '@dipscope/type-manager';
1381
1385
  import { TypeOptionsBase } from '@dipscope/type-manager/core';
1382
1386
 
1383
1387
  const typeOptionsBase: TypeOptionsBase<any> = {
1384
- discriminator: '$type'
1388
+ discriminator: '$customType'
1385
1389
  };
1386
1390
 
1387
1391
  const typeManagerOptions: TypeManagerOptions = {
@@ -1990,11 +1994,11 @@ Polymorphic types are supported. In most cases additional configuration is requi
1990
1994
 
1991
1995
  See information about breaking changes, release notes and migration steps between versions [here](https://github.com/dipscope/TypeManager.TS/blob/master/CHANGELOG.md).
1992
1996
 
1993
- Thanks for checking this package. If you like it please give repo a star.
1997
+ Thanks for checking this package.
1994
1998
 
1995
1999
  Feel free to create an issue if you find any mistakes in documentation or have any improvements in mind.
1996
2000
 
1997
- I wish you good luck and happy coding! ;)
2001
+ We wish you good luck and happy coding!
1998
2002
 
1999
2003
  ## License
2000
2004
 
package/core/fn.d.ts CHANGED
@@ -51,7 +51,7 @@ export declare class Fn {
51
51
  *
52
52
  * @returns {boolean} True when value is function. False otherwise.
53
53
  */
54
- static isFunction(x: any): x is (...args: any[]) => any;
54
+ static isFunction(x: any): x is (...args: Array<any>) => any;
55
55
  /**
56
56
  * Checks if value is an arrow function.
57
57
  *
@@ -59,7 +59,7 @@ export declare class Fn {
59
59
  *
60
60
  * @returns {boolean} True when value is an arrow function. False otherwise.
61
61
  */
62
- static isArrowFunction(x: any): x is (...args: any[]) => any;
62
+ static isArrowFunction(x: any): x is (...args: Array<any>) => any;
63
63
  /**
64
64
  * Checks if value is a constructor.
65
65
  *
@@ -67,7 +67,7 @@ export declare class Fn {
67
67
  *
68
68
  * @returns {boolean} True when value is a constructor. False otherwise.
69
69
  */
70
- static isCtor(x: any): x is new (...args: any[]) => any;
70
+ static isCtor(x: any): x is new (...args: Array<any>) => any;
71
71
  /**
72
72
  * Checks if value is string.
73
73
  *
@@ -107,7 +107,7 @@ export declare class Fn {
107
107
  *
108
108
  * @returns {boolean} True when value is array. False otherwise.
109
109
  */
110
- static isArray(x: any): x is any[];
110
+ static isArray(x: any): x is Array<any>;
111
111
  /**
112
112
  * Checks if value is date.
113
113
  *
@@ -248,7 +248,7 @@ export declare class Fn {
248
248
  * Performs deep assignment and returns target object.
249
249
  *
250
250
  * @param {Record<string, any>} target Target object.
251
- * @param {Record<string, any>[]} sources Source objects.
251
+ * @param {Array<Record<string, any>>} sources Source objects.
252
252
  *
253
253
  * @returns {Record<string, any>} Target object.
254
254
  */
@@ -268,25 +268,25 @@ export declare class Fn {
268
268
  *
269
269
  * @param {string} x String.
270
270
  *
271
- * @returns {string[]} Array with the words of provided string.
271
+ * @returns {Array<string>} Array with the words of provided string.
272
272
  */
273
- static unicodeWords(x: string): string[];
273
+ static unicodeWords(x: string): Array<string>;
274
274
  /**
275
275
  * Splits a ASCII string into an array of its words.
276
276
  *
277
277
  * @param {string} x String.
278
278
  *
279
- * @returns {string[]} Array with the words of provided string.
279
+ * @returns {Array<string>} Array with the words of provided string.
280
280
  */
281
- static asciiWords(x: string): string[];
281
+ static asciiWords(x: string): Array<string>;
282
282
  /**
283
283
  * Splits string into an array of its words.
284
284
  *
285
285
  * @param {string} x String.
286
286
  *
287
- * @returns {string[]} Array with the words of provided string.
287
+ * @returns {Array<string>} Array with the words of provided string.
288
288
  */
289
- static words(x: string): string[];
289
+ static words(x: string): Array<string>;
290
290
  /**
291
291
  * Checks if reflect metadata is supported.
292
292
  *
@@ -4,4 +4,4 @@ import { TypeArgument } from './type-argument';
4
4
  *
5
5
  * @type {GenericArgument<TType>}
6
6
  */
7
- export declare type GenericArgument<TType> = TypeArgument<TType> | [TypeArgument<TType>, GenericArgument<any>[]];
7
+ export declare type GenericArgument<TType> = TypeArgument<TType> | [TypeArgument<TType>, Array<GenericArgument<any>>];
@@ -4,4 +4,4 @@ import { TypeMetadata } from './type-metadata';
4
4
  *
5
5
  * @type {GenericMetadata<TType>}
6
6
  */
7
- export declare type GenericMetadata<TType> = [TypeMetadata<TType>, GenericMetadata<any>[]];
7
+ export declare type GenericMetadata<TType> = [TypeMetadata<TType>, Array<GenericMetadata<any>>];
package/core/index.d.ts CHANGED
@@ -34,6 +34,7 @@ export * from './type-ctor';
34
34
  export * from './type-fn';
35
35
  export * from './type-like';
36
36
  export * from './type-metadata-resolver';
37
+ export * from './type-metadata-symbol';
37
38
  export * from './type-metadata';
38
39
  export * from './type-name';
39
40
  export * from './type-options-base';