@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
package/alias.d.ts CHANGED
@@ -1,10 +1,6 @@
1
1
  /**
2
- * Alias decorator.
2
+ * Type to explicitly define an alias within a source code.
3
3
  *
4
- * Can be used on type and property to define an alias.
5
- *
6
- * @param {string} alias Type or property alias.
7
- *
8
- * @returns {ClassDecorator&PropertyDecorator} Class and property decorator.
4
+ * @type {Alias}
9
5
  */
10
- export declare function Alias(alias: string): ClassDecorator & PropertyDecorator;
6
+ export declare type Alias = string;
package/custom-data.d.ts CHANGED
@@ -1,11 +1,6 @@
1
- import { CustomData } from './core';
2
1
  /**
3
- * Custom data decorator.
2
+ * Custom data which can be defined by developer.
4
3
  *
5
- * Used to define custom data for type and property.
6
- *
7
- * @param {CustomData} customData Custom data.
8
- *
9
- * @returns {ClassDecorator&PropertyDecorator} Class and property decorator.
4
+ * @type {CustomData}
10
5
  */
11
- export declare function CustomData(customData: CustomData): ClassDecorator & PropertyDecorator;
6
+ export declare type CustomData = Record<string, any>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Resolver used to get default value. May be used if type represents a reference
3
+ * which have to be unique.
4
+ *
5
+ * @type {DefaultValueResolver}
6
+ */
7
+ export declare type DefaultValueResolver = () => any;
@@ -1,10 +1,7 @@
1
+ import { DefaultValueResolver } from './default-value-resolver';
1
2
  /**
2
- * Default value decorator.
3
+ * Default value which can be defined by developer.
3
4
  *
4
- * Used to define default value for type and property.
5
- *
6
- * @param {any} defaultValue Default value.
7
- *
8
- * @returns {ClassDecorator&PropertyDecorator} Class and property decorator.
5
+ * @type {DefaultValue}
9
6
  */
10
- export declare function DefaultValue(defaultValue: any): ClassDecorator & PropertyDecorator;
7
+ export declare type DefaultValue = any | DefaultValueResolver;
package/discriminant.d.ts CHANGED
@@ -1,11 +1,8 @@
1
- import { Discriminant } from './core/discriminant';
1
+ import { TypeName } from './type-name';
2
2
  /**
3
- * Discriminant decorator.
3
+ * Discriminant intends to describe a unique key for a polymorphic type which will be
4
+ * used during serialization and deserialization. Can be a type name, any string or number.
4
5
  *
5
- * Used to define a discriminant for a type.
6
- *
7
- * @param {Discriminant} discriminant Discriminant.
8
- *
9
- * @returns {ClassDecorator} Class decorator.
6
+ * @type {Discriminant}
10
7
  */
11
- export declare function Discriminant(discriminant: Discriminant): ClassDecorator;
8
+ export declare type Discriminant = TypeName | string | number;
@@ -1,11 +1,6 @@
1
- import { Discriminator } from './core/discriminator';
2
1
  /**
3
- * Discriminator decorator.
2
+ * Discriminator intends to indicate the property used to identify the type of an object.
4
3
  *
5
- * Used to define a discriminator for a type.
6
- *
7
- * @param {Discriminator} discriminator Discriminator.
8
- *
9
- * @returns {ClassDecorator} Class decorator.
4
+ * @type {Discriminator}
10
5
  */
11
- export declare function Discriminator(discriminator: Discriminator): ClassDecorator;
6
+ export declare type Discriminator = string;
@@ -1,6 +1,6 @@
1
- import { Factory } from '../core/factory';
2
- import { Injector } from '../core/injector';
3
- import { TypeContext } from '../core/type-context';
1
+ import { Factory } from '../factory';
2
+ import { Injector } from '../injector';
3
+ import { TypeContext } from '../type-context';
4
4
  /**
5
5
  * Type factory.
6
6
  *
package/factory.d.ts CHANGED
@@ -1,11 +1,18 @@
1
- import { Factory } from './core/factory';
1
+ import { Injector } from './injector';
2
+ import { TypeContext } from './type-context';
2
3
  /**
3
- * Factory decorator.
4
+ * Factory for building types.
4
5
  *
5
- * Used to define custom factory for a type.
6
- *
7
- * @param {Factory} factory Factory.
8
- *
9
- * @returns {ClassDecorator} Class decorator.
6
+ * @type {Factory}
10
7
  */
11
- export declare function Factory(factory: Factory): ClassDecorator;
8
+ export interface Factory {
9
+ /**
10
+ * Builds type described by provided type context.
11
+ *
12
+ * @param {TypeContext<TType>} typeContext Type context.
13
+ * @param {Injector} injector Injector.
14
+ *
15
+ * @returns {TType} Type instance described by provided type context.
16
+ */
17
+ build<TType>(typeContext: TypeContext<TType>, injector: Injector): TType;
18
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Gets own reflect metadata.
3
+ *
4
+ * @param {string} metadataKey Unique metadata key.
5
+ * @param {any} target Target to extract from.
6
+ *
7
+ * @returns {any} Metadata for a key or undefined if metadata is not present.
8
+ */
9
+ export declare function getOwnReflectMetadata(metadataKey: string, target: any): any;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Gets reflect metadata.
3
+ *
4
+ * @param {string} metadataKey Unique metadata key.
5
+ * @param {any} target Target to extract from.
6
+ * @param {string|symbol} propertyKey Key in a target.
7
+ *
8
+ * @returns {any} Metadata for a key or undefined if metadata is not present.
9
+ */
10
+ export declare function getReflectMetadata(metadataKey: string, target: any, propertyKey: string | symbol): any;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Gets words from a string.
3
+ *
4
+ * @param {string} x String.
5
+ *
6
+ * @returns {Array<string>} Array with the words of provided string.
7
+ */
8
+ export declare function getWords(x: string): Array<string>;
@@ -0,0 +1,16 @@
1
+ export * from './get-reflect-metadata';
2
+ export * from './get-own-reflect-metadata';
3
+ export * from './get-words';
4
+ export * from './is-arrow-function';
5
+ export * from './is-ctor-function';
6
+ export * from './is-data-view';
7
+ export * from './is-float-32-array';
8
+ export * from './is-float-64-array';
9
+ export * from './is-int-8-array';
10
+ export * from './is-int-16-array';
11
+ export * from './is-int-32-array';
12
+ export * from './is-uint-8-array';
13
+ export * from './is-uint-8-clamped-array';
14
+ export * from './is-uint-16-array';
15
+ export * from './is-uint-32-array';
16
+ export * from './name-of';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Checks if value is an arrow function.
3
+ *
4
+ * @param {any} x Input value.
5
+ *
6
+ * @returns {boolean} True when value is an arrow function. False otherwise.
7
+ */
8
+ export declare function isArrowFunction(x: any): x is (...args: Array<any>) => any;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Checks if value is a constructor function.
3
+ *
4
+ * @param {any} x Input value.
5
+ *
6
+ * @returns {boolean} True when value is a constructor function. False otherwise.
7
+ */
8
+ export declare function isCtorFunction(x: any): x is new (...args: Array<any>) => any;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Checks if value is data view.
3
+ *
4
+ * @param {any} x Input value.
5
+ *
6
+ * @returns {boolean} True when value is data view. False otherwise.
7
+ */
8
+ export declare function isDataView(x: any): x is DataView;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Checks if value is float 32 array.
3
+ *
4
+ * @param {any} x Input value.
5
+ *
6
+ * @returns {boolean} True when value is float 32 array. False otherwise.
7
+ */
8
+ export declare function isFloat32Array(x: any): x is Float32Array;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Checks if value is float 64 array.
3
+ *
4
+ * @param {any} x Input value.
5
+ *
6
+ * @returns {boolean} True when value is float 64 array. False otherwise.
7
+ */
8
+ export declare function isFloat64Array(x: any): x is Float64Array;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Checks if value is int 16 array.
3
+ *
4
+ * @param {any} x Input value.
5
+ *
6
+ * @returns {boolean} True when value is int 16 array. False otherwise.
7
+ */
8
+ export declare function isInt16Array(x: any): x is Int16Array;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Checks if value is int 32 array.
3
+ *
4
+ * @param {any} x Input value.
5
+ *
6
+ * @returns {boolean} True when value is int 32 array. False otherwise.
7
+ */
8
+ export declare function isInt32Array(x: any): x is Int32Array;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Checks if value is int 8 array.
3
+ *
4
+ * @param {any} x Input value.
5
+ *
6
+ * @returns {boolean} True when value is int 8 array. False otherwise.
7
+ */
8
+ export declare function isInt8Array(x: any): x is Int8Array;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Checks if value is uint 16 array.
3
+ *
4
+ * @param {any} x Input value.
5
+ *
6
+ * @returns {boolean} True when value is uint 16 array. False otherwise.
7
+ */
8
+ export declare function isUint16Array(x: any): x is Uint16Array;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Checks if value is uint 32 array.
3
+ *
4
+ * @param {any} x Input value.
5
+ *
6
+ * @returns {boolean} True when value is uint 32 array. False otherwise.
7
+ */
8
+ export declare function isUint32Array(x: any): x is Uint32Array;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Checks if value is uint 8 array.
3
+ *
4
+ * @param {any} x Input value.
5
+ *
6
+ * @returns {boolean} True when value is uint 8 array. False otherwise.
7
+ */
8
+ export declare function isUint8Array(x: any): x is Uint8Array;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Checks if value is uint 8 clamped array.
3
+ *
4
+ * @param {any} x Input value.
5
+ *
6
+ * @returns {boolean} True when value is uint 8 clamped array. False otherwise.
7
+ */
8
+ export declare function isUint8ClampedArray(x: any): x is Uint8ClampedArray;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Defines name for any value.
3
+ *
4
+ * @param {any} x Input value.
5
+ *
6
+ * @returns {boolean} Name when present. Unknown otherwise.
7
+ */
8
+ export declare function nameOf(x: any): string;
package/index.d.ts CHANGED
@@ -1,22 +1,54 @@
1
+ export * from './factories';
2
+ export * from './functions';
3
+ export * from './injectors';
4
+ export * from './naming-conventions';
5
+ export * from './reference-handlers';
6
+ export * from './serializers';
1
7
  export * from './alias';
2
8
  export * from './custom-data';
9
+ export * from './default-value-resolver';
3
10
  export * from './default-value';
4
- export * from './deserializable';
5
11
  export * from './discriminant';
6
12
  export * from './discriminator';
7
13
  export * from './factory';
14
+ export * from './generic-argument';
15
+ export * from './generic-metadata';
16
+ export * from './inject-index';
17
+ export * from './inject-metadata';
18
+ export * from './inject-options';
8
19
  export * from './inject';
9
- export * from './injectable';
10
20
  export * from './injector';
21
+ export * from './log-level';
22
+ export * from './log';
23
+ export * from './metadata';
11
24
  export * from './naming-convention';
12
- export * from './preserve-discriminator';
25
+ export * from './property-metadata';
26
+ export * from './property-name';
27
+ export * from './property-options';
13
28
  export * from './property';
29
+ export * from './reference-callback';
14
30
  export * from './reference-handler';
15
- export * from './serializable';
31
+ export * from './reference-key';
32
+ export * from './reference-value-initializer';
33
+ export * from './reference-value-resolver';
34
+ export * from './reference-value';
35
+ export * from './serializer-context-options';
36
+ export * from './serializer-context';
16
37
  export * from './serializer';
17
- export * from './type-and-property';
38
+ export * from './type-abstraction';
39
+ export * from './type-argument';
40
+ export * from './type-context-entry';
41
+ export * from './type-context';
42
+ export * from './type-ctor';
43
+ export * from './type-fn';
44
+ export * from './type-like';
18
45
  export * from './type-manager-options';
19
46
  export * from './type-manager';
47
+ export * from './type-metadata-resolver';
48
+ export * from './type-metadata-symbol';
49
+ export * from './type-metadata';
50
+ export * from './type-name';
51
+ export * from './type-options-base';
52
+ export * from './type-options';
53
+ export * from './type-resolver';
20
54
  export * from './type';
21
- export * from './use-default-value';
22
- export * from './use-implicit-conversion';