@pristine-ts/data-mapping 0.0.281 → 0.0.283

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 (205) hide show
  1. package/dist/lib/cjs/data-mapping.module.js +31 -10
  2. package/dist/lib/cjs/data-mapping.module.js.map +1 -1
  3. package/dist/lib/cjs/decorators/type.decorator.js +2 -2
  4. package/dist/lib/cjs/decorators/type.decorator.js.map +1 -1
  5. package/dist/lib/cjs/interceptors/default-data-mapping.interceptor.js +1 -1
  6. package/dist/lib/cjs/interceptors/default-data-mapping.interceptor.js.map +1 -1
  7. package/dist/lib/esm/data-mapping.module.js +31 -10
  8. package/dist/lib/esm/data-mapping.module.js.map +1 -1
  9. package/dist/lib/esm/decorators/type.decorator.js +1 -1
  10. package/dist/lib/esm/decorators/type.decorator.js.map +1 -1
  11. package/dist/lib/esm/interceptors/default-data-mapping.interceptor.js +1 -1
  12. package/dist/lib/esm/interceptors/default-data-mapping.interceptor.js.map +1 -1
  13. package/dist/types/data-mapping.module.d.ts +1 -9
  14. package/dist/types/interceptors/default-data-mapping.interceptor.d.ts +1 -2
  15. package/package.json +6 -4
  16. package/dist/lib/cjs/builders/auto-data-mapping.builder.js +0 -147
  17. package/dist/lib/cjs/builders/auto-data-mapping.builder.js.map +0 -1
  18. package/dist/lib/cjs/builders/builders.js +0 -19
  19. package/dist/lib/cjs/builders/builders.js.map +0 -1
  20. package/dist/lib/cjs/builders/data-mapping.builder.js +0 -178
  21. package/dist/lib/cjs/builders/data-mapping.builder.js.map +0 -1
  22. package/dist/lib/cjs/enums/data-mapping-node-type.enum.js +0 -11
  23. package/dist/lib/cjs/enums/data-mapping-node-type.enum.js.map +0 -1
  24. package/dist/lib/cjs/enums/enums.js +0 -18
  25. package/dist/lib/cjs/enums/enums.js.map +0 -1
  26. package/dist/lib/cjs/errors/array-data-mapping-node-invalid-source-property-type.error.js +0 -20
  27. package/dist/lib/cjs/errors/array-data-mapping-node-invalid-source-property-type.error.js.map +0 -1
  28. package/dist/lib/cjs/errors/data-after-mapping-interceptor-already-added.error.js +0 -21
  29. package/dist/lib/cjs/errors/data-after-mapping-interceptor-already-added.error.js.map +0 -1
  30. package/dist/lib/cjs/errors/data-before-mapping-interceptor-already-added.error.js +0 -21
  31. package/dist/lib/cjs/errors/data-before-mapping-interceptor-already-added.error.js.map +0 -1
  32. package/dist/lib/cjs/errors/data-mapping-interceptor-not-found.error.js +0 -21
  33. package/dist/lib/cjs/errors/data-mapping-interceptor-not-found.error.js.map +0 -1
  34. package/dist/lib/cjs/errors/data-mapping-source-property-not-found.error.js +0 -20
  35. package/dist/lib/cjs/errors/data-mapping-source-property-not-found.error.js.map +0 -1
  36. package/dist/lib/cjs/errors/data-normalizer-already-added.error.js +0 -21
  37. package/dist/lib/cjs/errors/data-normalizer-already-added.error.js.map +0 -1
  38. package/dist/lib/cjs/errors/errors.js +0 -25
  39. package/dist/lib/cjs/errors/errors.js.map +0 -1
  40. package/dist/lib/cjs/errors/normalizer-invalid-source-type.error.js +0 -23
  41. package/dist/lib/cjs/errors/normalizer-invalid-source-type.error.js.map +0 -1
  42. package/dist/lib/cjs/errors/undefined-source-property.error.js +0 -20
  43. package/dist/lib/cjs/errors/undefined-source-property.error.js.map +0 -1
  44. package/dist/lib/cjs/interfaces/data-mapping-interceptor.interface.js +0 -3
  45. package/dist/lib/cjs/interfaces/data-mapping-interceptor.interface.js.map +0 -1
  46. package/dist/lib/cjs/interfaces/data-normalizer.interface.js +0 -3
  47. package/dist/lib/cjs/interfaces/data-normalizer.interface.js.map +0 -1
  48. package/dist/lib/cjs/interfaces/interfaces.js +0 -19
  49. package/dist/lib/cjs/interfaces/interfaces.js.map +0 -1
  50. package/dist/lib/cjs/mappers/data.mapper.js +0 -126
  51. package/dist/lib/cjs/mappers/data.mapper.js.map +0 -1
  52. package/dist/lib/cjs/mappers/mappers.js +0 -18
  53. package/dist/lib/cjs/mappers/mappers.js.map +0 -1
  54. package/dist/lib/cjs/nodes/base-data-mapping.node.js +0 -24
  55. package/dist/lib/cjs/nodes/base-data-mapping.node.js.map +0 -1
  56. package/dist/lib/cjs/nodes/data-mapping.leaf.js +0 -184
  57. package/dist/lib/cjs/nodes/data-mapping.leaf.js.map +0 -1
  58. package/dist/lib/cjs/nodes/data-mapping.node.js +0 -217
  59. package/dist/lib/cjs/nodes/data-mapping.node.js.map +0 -1
  60. package/dist/lib/cjs/nodes/nodes.js +0 -20
  61. package/dist/lib/cjs/nodes/nodes.js.map +0 -1
  62. package/dist/lib/cjs/normalizer-options/base-normalizer.options.js +0 -12
  63. package/dist/lib/cjs/normalizer-options/base-normalizer.options.js.map +0 -1
  64. package/dist/lib/cjs/normalizer-options/date-normalizer.options.js +0 -21
  65. package/dist/lib/cjs/normalizer-options/date-normalizer.options.js.map +0 -1
  66. package/dist/lib/cjs/normalizer-options/lowercase-normalizer.options.js +0 -11
  67. package/dist/lib/cjs/normalizer-options/lowercase-normalizer.options.js.map +0 -1
  68. package/dist/lib/cjs/normalizer-options/normalizer-options.js +0 -22
  69. package/dist/lib/cjs/normalizer-options/normalizer-options.js.map +0 -1
  70. package/dist/lib/cjs/normalizer-options/number-normalizer.options.js +0 -16
  71. package/dist/lib/cjs/normalizer-options/number-normalizer.options.js.map +0 -1
  72. package/dist/lib/cjs/normalizer-options/string-normalizer.options.js +0 -17
  73. package/dist/lib/cjs/normalizer-options/string-normalizer.options.js.map +0 -1
  74. package/dist/lib/cjs/normalizers/date.normalizer.js +0 -73
  75. package/dist/lib/cjs/normalizers/date.normalizer.js.map +0 -1
  76. package/dist/lib/cjs/normalizers/lowercase.normalizer.js +0 -33
  77. package/dist/lib/cjs/normalizers/lowercase.normalizer.js.map +0 -1
  78. package/dist/lib/cjs/normalizers/normalizers.js +0 -21
  79. package/dist/lib/cjs/normalizers/normalizers.js.map +0 -1
  80. package/dist/lib/cjs/normalizers/number.normalizer.js +0 -41
  81. package/dist/lib/cjs/normalizers/number.normalizer.js.map +0 -1
  82. package/dist/lib/cjs/normalizers/string.normalizer.js +0 -63
  83. package/dist/lib/cjs/normalizers/string.normalizer.js.map +0 -1
  84. package/dist/lib/cjs/options/auto-data-mapping-builder.options.js +0 -11
  85. package/dist/lib/cjs/options/auto-data-mapping-builder.options.js.map +0 -1
  86. package/dist/lib/cjs/types/data-mapping-interceptor-unique-key.type.js +0 -3
  87. package/dist/lib/cjs/types/data-mapping-interceptor-unique-key.type.js.map +0 -1
  88. package/dist/lib/cjs/types/data-normalizer-unique-key.type.js +0 -3
  89. package/dist/lib/cjs/types/data-normalizer-unique-key.type.js.map +0 -1
  90. package/dist/lib/cjs/types/types.js +0 -19
  91. package/dist/lib/cjs/types/types.js.map +0 -1
  92. package/dist/lib/esm/builders/auto-data-mapping.builder.js +0 -144
  93. package/dist/lib/esm/builders/auto-data-mapping.builder.js.map +0 -1
  94. package/dist/lib/esm/builders/builders.js +0 -3
  95. package/dist/lib/esm/builders/builders.js.map +0 -1
  96. package/dist/lib/esm/builders/data-mapping.builder.js +0 -174
  97. package/dist/lib/esm/builders/data-mapping.builder.js.map +0 -1
  98. package/dist/lib/esm/enums/data-mapping-node-type.enum.js +0 -8
  99. package/dist/lib/esm/enums/data-mapping-node-type.enum.js.map +0 -1
  100. package/dist/lib/esm/enums/enums.js +0 -2
  101. package/dist/lib/esm/enums/enums.js.map +0 -1
  102. package/dist/lib/esm/errors/array-data-mapping-node-invalid-source-property-type.error.js +0 -16
  103. package/dist/lib/esm/errors/array-data-mapping-node-invalid-source-property-type.error.js.map +0 -1
  104. package/dist/lib/esm/errors/data-after-mapping-interceptor-already-added.error.js +0 -17
  105. package/dist/lib/esm/errors/data-after-mapping-interceptor-already-added.error.js.map +0 -1
  106. package/dist/lib/esm/errors/data-before-mapping-interceptor-already-added.error.js +0 -17
  107. package/dist/lib/esm/errors/data-before-mapping-interceptor-already-added.error.js.map +0 -1
  108. package/dist/lib/esm/errors/data-mapping-interceptor-not-found.error.js +0 -17
  109. package/dist/lib/esm/errors/data-mapping-interceptor-not-found.error.js.map +0 -1
  110. package/dist/lib/esm/errors/data-mapping-source-property-not-found.error.js +0 -16
  111. package/dist/lib/esm/errors/data-mapping-source-property-not-found.error.js.map +0 -1
  112. package/dist/lib/esm/errors/data-normalizer-already-added.error.js +0 -17
  113. package/dist/lib/esm/errors/data-normalizer-already-added.error.js.map +0 -1
  114. package/dist/lib/esm/errors/errors.js +0 -9
  115. package/dist/lib/esm/errors/errors.js.map +0 -1
  116. package/dist/lib/esm/errors/normalizer-invalid-source-type.error.js +0 -19
  117. package/dist/lib/esm/errors/normalizer-invalid-source-type.error.js.map +0 -1
  118. package/dist/lib/esm/errors/undefined-source-property.error.js +0 -16
  119. package/dist/lib/esm/errors/undefined-source-property.error.js.map +0 -1
  120. package/dist/lib/esm/interfaces/data-mapping-interceptor.interface.js +0 -2
  121. package/dist/lib/esm/interfaces/data-mapping-interceptor.interface.js.map +0 -1
  122. package/dist/lib/esm/interfaces/data-normalizer.interface.js +0 -2
  123. package/dist/lib/esm/interfaces/data-normalizer.interface.js.map +0 -1
  124. package/dist/lib/esm/interfaces/interfaces.js +0 -3
  125. package/dist/lib/esm/interfaces/interfaces.js.map +0 -1
  126. package/dist/lib/esm/mappers/data.mapper.js +0 -123
  127. package/dist/lib/esm/mappers/data.mapper.js.map +0 -1
  128. package/dist/lib/esm/mappers/mappers.js +0 -2
  129. package/dist/lib/esm/mappers/mappers.js.map +0 -1
  130. package/dist/lib/esm/nodes/base-data-mapping.node.js +0 -20
  131. package/dist/lib/esm/nodes/base-data-mapping.node.js.map +0 -1
  132. package/dist/lib/esm/nodes/data-mapping.leaf.js +0 -180
  133. package/dist/lib/esm/nodes/data-mapping.leaf.js.map +0 -1
  134. package/dist/lib/esm/nodes/data-mapping.node.js +0 -213
  135. package/dist/lib/esm/nodes/data-mapping.node.js.map +0 -1
  136. package/dist/lib/esm/nodes/nodes.js +0 -4
  137. package/dist/lib/esm/nodes/nodes.js.map +0 -1
  138. package/dist/lib/esm/normalizer-options/base-normalizer.options.js +0 -8
  139. package/dist/lib/esm/normalizer-options/base-normalizer.options.js.map +0 -1
  140. package/dist/lib/esm/normalizer-options/date-normalizer.options.js +0 -17
  141. package/dist/lib/esm/normalizer-options/date-normalizer.options.js.map +0 -1
  142. package/dist/lib/esm/normalizer-options/lowercase-normalizer.options.js +0 -7
  143. package/dist/lib/esm/normalizer-options/lowercase-normalizer.options.js.map +0 -1
  144. package/dist/lib/esm/normalizer-options/normalizer-options.js +0 -6
  145. package/dist/lib/esm/normalizer-options/normalizer-options.js.map +0 -1
  146. package/dist/lib/esm/normalizer-options/number-normalizer.options.js +0 -12
  147. package/dist/lib/esm/normalizer-options/number-normalizer.options.js.map +0 -1
  148. package/dist/lib/esm/normalizer-options/string-normalizer.options.js +0 -13
  149. package/dist/lib/esm/normalizer-options/string-normalizer.options.js.map +0 -1
  150. package/dist/lib/esm/normalizers/date.normalizer.js +0 -70
  151. package/dist/lib/esm/normalizers/date.normalizer.js.map +0 -1
  152. package/dist/lib/esm/normalizers/lowercase.normalizer.js +0 -30
  153. package/dist/lib/esm/normalizers/lowercase.normalizer.js.map +0 -1
  154. package/dist/lib/esm/normalizers/normalizers.js +0 -5
  155. package/dist/lib/esm/normalizers/normalizers.js.map +0 -1
  156. package/dist/lib/esm/normalizers/number.normalizer.js +0 -38
  157. package/dist/lib/esm/normalizers/number.normalizer.js.map +0 -1
  158. package/dist/lib/esm/normalizers/string.normalizer.js +0 -60
  159. package/dist/lib/esm/normalizers/string.normalizer.js.map +0 -1
  160. package/dist/lib/esm/options/auto-data-mapping-builder.options.js +0 -7
  161. package/dist/lib/esm/options/auto-data-mapping-builder.options.js.map +0 -1
  162. package/dist/lib/esm/types/data-mapping-interceptor-unique-key.type.js +0 -2
  163. package/dist/lib/esm/types/data-mapping-interceptor-unique-key.type.js.map +0 -1
  164. package/dist/lib/esm/types/data-normalizer-unique-key.type.js +0 -2
  165. package/dist/lib/esm/types/data-normalizer-unique-key.type.js.map +0 -1
  166. package/dist/lib/esm/types/types.js +0 -3
  167. package/dist/lib/esm/types/types.js.map +0 -1
  168. package/dist/types/builders/auto-data-mapping.builder.d.ts +0 -25
  169. package/dist/types/builders/builders.d.ts +0 -2
  170. package/dist/types/builders/data-mapping.builder.d.ts +0 -110
  171. package/dist/types/enums/data-mapping-node-type.enum.d.ts +0 -6
  172. package/dist/types/enums/enums.d.ts +0 -1
  173. package/dist/types/errors/array-data-mapping-node-invalid-source-property-type.error.d.ts +0 -7
  174. package/dist/types/errors/data-after-mapping-interceptor-already-added.error.d.ts +0 -8
  175. package/dist/types/errors/data-before-mapping-interceptor-already-added.error.d.ts +0 -8
  176. package/dist/types/errors/data-mapping-interceptor-not-found.error.d.ts +0 -8
  177. package/dist/types/errors/data-mapping-source-property-not-found.error.d.ts +0 -7
  178. package/dist/types/errors/data-normalizer-already-added.error.d.ts +0 -7
  179. package/dist/types/errors/errors.d.ts +0 -8
  180. package/dist/types/errors/normalizer-invalid-source-type.error.d.ts +0 -7
  181. package/dist/types/errors/undefined-source-property.error.d.ts +0 -9
  182. package/dist/types/interfaces/data-mapping-interceptor.interface.d.ts +0 -19
  183. package/dist/types/interfaces/data-normalizer.interface.d.ts +0 -15
  184. package/dist/types/interfaces/interfaces.d.ts +0 -2
  185. package/dist/types/mappers/data.mapper.d.ts +0 -38
  186. package/dist/types/mappers/mappers.d.ts +0 -1
  187. package/dist/types/nodes/base-data-mapping.node.d.ts +0 -15
  188. package/dist/types/nodes/data-mapping.leaf.d.ts +0 -92
  189. package/dist/types/nodes/data-mapping.node.d.ts +0 -104
  190. package/dist/types/nodes/nodes.d.ts +0 -3
  191. package/dist/types/normalizer-options/base-normalizer.options.d.ts +0 -4
  192. package/dist/types/normalizer-options/date-normalizer.options.d.ts +0 -12
  193. package/dist/types/normalizer-options/lowercase-normalizer.options.d.ts +0 -4
  194. package/dist/types/normalizer-options/normalizer-options.d.ts +0 -5
  195. package/dist/types/normalizer-options/number-normalizer.options.d.ts +0 -8
  196. package/dist/types/normalizer-options/string-normalizer.options.d.ts +0 -12
  197. package/dist/types/normalizers/date.normalizer.d.ts +0 -6
  198. package/dist/types/normalizers/lowercase.normalizer.d.ts +0 -7
  199. package/dist/types/normalizers/normalizers.d.ts +0 -4
  200. package/dist/types/normalizers/number.normalizer.d.ts +0 -6
  201. package/dist/types/normalizers/string.normalizer.d.ts +0 -6
  202. package/dist/types/options/auto-data-mapping-builder.options.d.ts +0 -11
  203. package/dist/types/types/data-mapping-interceptor-unique-key.type.d.ts +0 -1
  204. package/dist/types/types/data-normalizer-unique-key.type.d.ts +0 -1
  205. package/dist/types/types/types.d.ts +0 -2
@@ -1,110 +0,0 @@
1
- import { DataMappingNode } from "../nodes/data-mapping.node";
2
- import { DataNormalizerUniqueKey } from "../types/data-normalizer-unique-key.type";
3
- import { DataMappingInterceptorUniqueKeyType } from "../types/data-mapping-interceptor-unique-key.type";
4
- import { DataMappingLeaf } from "../nodes/data-mapping.leaf";
5
- import { BaseDataMappingNode } from "../nodes/base-data-mapping.node";
6
- export declare class DataMappingBuilder extends BaseDataMappingNode {
7
- normalizers: {
8
- key: DataNormalizerUniqueKey;
9
- options: any;
10
- }[];
11
- beforeMappingInterceptors: {
12
- key: DataMappingInterceptorUniqueKeyType;
13
- options: any;
14
- }[];
15
- afterMappingInterceptors: {
16
- key: DataMappingInterceptorUniqueKeyType;
17
- options: any;
18
- }[];
19
- /**
20
- * This method adds a normalizer to the root that will be applied on each node (unless they explicitly exclude to do
21
- * so).
22
- *
23
- * @param normalizerUniqueKey
24
- * @param options
25
- */
26
- addNormalizer(normalizerUniqueKey: DataNormalizerUniqueKey, options?: any): DataMappingBuilder;
27
- /**
28
- * This method returns whether there's a normalizer for the specified key or not.
29
- *
30
- * @param normalizerUniqueKey
31
- */
32
- hasNormalizer(normalizerUniqueKey: DataNormalizerUniqueKey): boolean;
33
- /**
34
- * This method adds an interceptor that will be executed **before** the object is mapped.
35
- *
36
- * @param key
37
- * @param options
38
- */
39
- addBeforeMappingInterceptor(key: DataMappingInterceptorUniqueKeyType, options?: any): DataMappingBuilder;
40
- /**
41
- * This method returns whether a **before** interceptor already exists.
42
- * @param key
43
- */
44
- hasBeforeMappingInterceptor(key: DataMappingInterceptorUniqueKeyType): boolean;
45
- /**
46
- * This method adds an interceptor that will be executed **after** the object is mapped.
47
- *
48
- * @param key
49
- * @param options
50
- */
51
- addAfterMappingInterceptor(key: DataMappingInterceptorUniqueKeyType, options?: any): DataMappingBuilder;
52
- /**
53
- * This method returns whether a **after** interceptor already exists.
54
- * @param key
55
- */
56
- hasAfterMappingInterceptor(key: DataMappingInterceptorUniqueKeyType): boolean;
57
- /**
58
- * This property creates a new DataMappingLeaf and returns it. It doesn't add it yet. To do so, the `end()` method
59
- * must be called.
60
- */
61
- add(): DataMappingLeaf;
62
- /**
63
- * This method adds a nesting level. This should be used when the property contains an object and you want to map
64
- * this object into another object.
65
- */
66
- addNestingLevel(): DataMappingNode;
67
- /**
68
- * This method adds an array of Scalar allowing you to apply the normalizer on each scalar in the array. The
69
- * `sourceProperty` and `destinationProperty` correspond to the name of the property that is an array. But, the
70
- * values in the array will be normalized using the normalizer.
71
- *
72
- */
73
- addArrayOfScalar(): DataMappingLeaf;
74
- /**
75
- * This method adds an array of objects allowing to define a node for each property in the object. Each object in
76
- * the array will be treated as being the same.
77
- */
78
- addArrayOfObjects(): DataMappingNode;
79
- /**
80
- * This method is called at the end just to make it nice since all the nodes will have one, it's nice
81
- * that the builder has one too.
82
- */
83
- end(): DataMappingBuilder;
84
- /**
85
- * This method imports a schema.
86
- *
87
- * @param schema
88
- */
89
- import(schema: any): void;
90
- /**
91
- * This method exports this node.
92
- */
93
- export(): {
94
- nodes: {
95
- [x: string]: DataMappingLeaf | DataMappingNode;
96
- };
97
- normalizers: {
98
- key: string;
99
- options: any;
100
- }[];
101
- beforeMappingInterceptors: {
102
- key: string;
103
- options: any;
104
- }[];
105
- afterMappingInterceptors: {
106
- key: string;
107
- options: any;
108
- }[];
109
- };
110
- }
@@ -1,6 +0,0 @@
1
- export declare enum DataMappingNodeTypeEnum {
2
- ScalarArray = "DATA_MAPPING_NODE_SCALAR_ARRAY",
3
- ObjectArray = "DATA_MAPPING_NODE_OBJECT_ARRAY",
4
- Node = "DATA_MAPPING_NODE",
5
- Leaf = "DATA_MAPPING_LEAF"
6
- }
@@ -1 +0,0 @@
1
- export * from "./data-mapping-node-type.enum";
@@ -1,7 +0,0 @@
1
- import { LoggableError } from "@pristine-ts/common";
2
- /**
3
- * This Error is thrown when a node is of type array but the `source[sourceProperty]` doesn't actually contain an array.
4
- */
5
- export declare class ArrayDataMappingNodeInvalidSourcePropertyTypeError extends LoggableError {
6
- constructor(message: string, sourceProperty: string);
7
- }
@@ -1,8 +0,0 @@
1
- import { LoggableError } from "@pristine-ts/common";
2
- import { DataMappingInterceptorUniqueKeyType } from "../types/data-mapping-interceptor-unique-key.type";
3
- /**
4
- * This Error is thrown when the before row interceptor is added more than once to the builder.
5
- */
6
- export declare class DataAfterMappingInterceptorAlreadyAddedError extends LoggableError {
7
- constructor(message: string, uniqueKey: DataMappingInterceptorUniqueKeyType, options?: any);
8
- }
@@ -1,8 +0,0 @@
1
- import { LoggableError } from "@pristine-ts/common";
2
- import { DataMappingInterceptorUniqueKeyType } from "../types/data-mapping-interceptor-unique-key.type";
3
- /**
4
- * This Error is thrown when the after row interceptor is added more than once to the builder.
5
- */
6
- export declare class DataBeforeMappingInterceptorAlreadyAddedError extends LoggableError {
7
- constructor(message: string, uniqueKey: DataMappingInterceptorUniqueKeyType, options?: any);
8
- }
@@ -1,8 +0,0 @@
1
- import { LoggableError } from "@pristine-ts/common";
2
- import { DataMappingInterceptorUniqueKeyType } from "../types/data-mapping-interceptor-unique-key.type";
3
- /**
4
- * This Error is thrown if the Data Transformer Class is not found in the list of available interceptors. It might be missing a tag.
5
- */
6
- export declare class DataMappingInterceptorNotFoundError extends LoggableError {
7
- constructor(message: string, uniqueKey: DataMappingInterceptorUniqueKeyType, options?: any);
8
- }
@@ -1,7 +0,0 @@
1
- import { LoggableError } from "@pristine-ts/common";
2
- /**
3
- * This Error is thrown when a property isn't optional and should be found in the source object.
4
- */
5
- export declare class DataMappingSourcePropertyNotFoundError extends LoggableError {
6
- constructor(message: string, sourceProperty: string);
7
- }
@@ -1,7 +0,0 @@
1
- import { LoggableError } from "@pristine-ts/common";
2
- /**
3
- * This Error is thrown when a normalizer is added more than once.
4
- */
5
- export declare class DataNormalizerAlreadyAdded extends LoggableError {
6
- constructor(message: string, normalizerUniqueKey: string, options?: any);
7
- }
@@ -1,8 +0,0 @@
1
- export * from "./array-data-mapping-node-invalid-source-property-type.error";
2
- export * from "./data-after-mapping-interceptor-already-added.error";
3
- export * from "./data-before-mapping-interceptor-already-added.error";
4
- export * from "./data-normalizer-already-added.error";
5
- export * from "./data-mapping-interceptor-not-found.error";
6
- export * from "./data-mapping-source-property-not-found.error";
7
- export * from "./normalizer-invalid-source-type.error";
8
- export * from "./undefined-source-property.error";
@@ -1,7 +0,0 @@
1
- import { LoggableError } from "@pristine-ts/common";
2
- /**
3
- * This Error is thrown when an invalid source type is passed to the source type while the normalizer expects another type.
4
- */
5
- export declare class NormalizerInvalidSourceTypeError extends LoggableError {
6
- constructor(message: string, normalizerUniqueKey: string, options: any, source: any, sourceType: any);
7
- }
@@ -1,9 +0,0 @@
1
- import { LoggableError } from "@pristine-ts/common";
2
- import { DataMappingLeaf } from "../nodes/data-mapping.leaf";
3
- import { DataMappingNode } from "../nodes/data-mapping.node";
4
- /**
5
- * This Error is thrown when you are trying to add a Node which has an undefined sourceProperty value.
6
- */
7
- export declare class UndefinedSourcePropertyError extends LoggableError {
8
- constructor(node: DataMappingLeaf | DataMappingNode);
9
- }
@@ -1,19 +0,0 @@
1
- import { DataMappingInterceptorUniqueKeyType } from "../types/data-mapping-interceptor-unique-key.type";
2
- export interface DataMappingInterceptorInterface {
3
- /**
4
- * Every data mapping interceptor must define a unique key. Then, during the mapping, the schema can specify which
5
- * interceptors must be called.
6
- */
7
- getUniqueKey(): DataMappingInterceptorUniqueKeyType;
8
- /**
9
- * This method is called before the row is being mapped and normalized. It allows you to combine fields for example if that's what you want.
10
- * @param row
11
- */
12
- beforeMapping(row: any): Promise<any>;
13
- /**
14
- * This method is called after the row is being mapped and normalized. It can allow you to apply operations on each
15
- * field or combine fields for example.
16
- * @param row
17
- */
18
- afterMapping(row: any): Promise<any>;
19
- }
@@ -1,15 +0,0 @@
1
- import { DataNormalizerUniqueKey } from "../types/data-normalizer-unique-key.type";
2
- export interface DataNormalizerInterface<T, R> {
3
- /**
4
- * Every data normalizer must define a unique key. Then, during the transformation, the schema can specify which
5
- * normalizer it must use. Using the unique key, we can quickly (in O(1)) retrieve the normalizer.
6
- */
7
- getUniqueKey(): DataNormalizerUniqueKey;
8
- /**
9
- * This method takes the source property value, can receive options to control the behaviour (example, you might
10
- * want to specify a number of significant digits or a data format) and returns the normalized value.
11
- * @param source
12
- * @param options
13
- */
14
- normalize(source: any, options?: R): T;
15
- }
@@ -1,2 +0,0 @@
1
- export * from "./data-normalizer.interface";
2
- export * from "./data-mapping-interceptor.interface";
@@ -1,38 +0,0 @@
1
- import { DataNormalizerInterface } from "../interfaces/data-normalizer.interface";
2
- import { DataMappingInterceptorInterface } from "../interfaces/data-mapping-interceptor.interface";
3
- import { DataMappingBuilder } from "../builders/data-mapping.builder";
4
- import { ClassConstructor } from "class-transformer";
5
- import { AutoDataMappingBuilder } from "../builders/auto-data-mapping.builder";
6
- import { AutoDataMappingBuilderOptions } from "../options/auto-data-mapping-builder.options";
7
- export declare class DataMapper {
8
- private readonly autoDataMappingBuilder;
9
- private readonly dataNormalizers;
10
- private readonly dataTransformerInterceptors;
11
- private readonly dataNormalizersMap;
12
- private readonly dataTransformerInterceptorsMap;
13
- constructor(autoDataMappingBuilder: AutoDataMappingBuilder, dataNormalizers: DataNormalizerInterface<any, any>[], dataTransformerInterceptors: DataMappingInterceptorInterface[]);
14
- /**
15
- * This method takes an array of source and maps each item.
16
- *
17
- * @param builder
18
- * @param source
19
- * @param destinationType
20
- */
21
- mapAll(builder: DataMappingBuilder, source: any[], destinationType?: ClassConstructor<any>): Promise<any[]>;
22
- /**
23
- * This method automatically maps a source object into the DestinationType.
24
- * @param source
25
- * @param destinationType
26
- * @param options
27
- */
28
- autoMap(source: any, destinationType: ClassConstructor<any>, options?: AutoDataMappingBuilderOptions): Promise<any>;
29
- /**
30
- * This method takes a builder, a source and maps it according to the builder. You can pass a `destinationType (optional)`
31
- * that is an object that will be constructed.
32
- *
33
- * @param builder
34
- * @param source
35
- * @param destinationType
36
- */
37
- map(builder: DataMappingBuilder, source: any, destinationType?: ClassConstructor<any>): Promise<any>;
38
- }
@@ -1 +0,0 @@
1
- export * from "./data.mapper";
@@ -1,15 +0,0 @@
1
- import { DataMappingNode } from "./data-mapping.node";
2
- import { DataMappingLeaf } from "./data-mapping.leaf";
3
- export declare abstract class BaseDataMappingNode {
4
- nodes: {
5
- [sourceProperty in string]: DataMappingNode | DataMappingLeaf;
6
- };
7
- /**
8
- * This method is called by the node itself to tell its parent that it has been build and is ready to be added.
9
- * We use this mechanism to force the `end()` method on the leaf to be called so we can do some validations before
10
- * adding it to the tree.
11
- *
12
- * @param node
13
- */
14
- addNode(node: DataMappingLeaf | DataMappingNode): void;
15
- }
@@ -1,92 +0,0 @@
1
- import { DataMappingNodeTypeEnum } from "../enums/data-mapping-node-type.enum";
2
- import { DataNormalizerUniqueKey } from "../types/data-normalizer-unique-key.type";
3
- import { DataMappingBuilder } from "../builders/data-mapping.builder";
4
- import { DataMappingNode } from "./data-mapping.node";
5
- import { DataNormalizerInterface } from "../interfaces/data-normalizer.interface";
6
- export declare class DataMappingLeaf {
7
- private readonly root;
8
- readonly parent: DataMappingNode | DataMappingBuilder;
9
- readonly type: DataMappingNodeTypeEnum;
10
- /**
11
- * This property represents the property referenced in the `source` object.
12
- */
13
- sourceProperty: string;
14
- /**
15
- * This property represents the property referenced in the `destination` object.
16
- */
17
- destinationProperty: string;
18
- /**
19
- * This property contains an array of Normalizers to apply sequentially when mapping this property.
20
- */
21
- normalizers: {
22
- key: DataNormalizerUniqueKey;
23
- options: any;
24
- }[];
25
- /**
26
- * This property contains an array of Normalizers that must be excluded from normalizers defined by parents.
27
- */
28
- excludedNormalizers: Set<DataNormalizerUniqueKey>;
29
- /**
30
- * This method specified whether it's possible that this element not be present in the `source` object.
31
- */
32
- isOptional: boolean;
33
- constructor(root: DataMappingBuilder, parent: DataMappingNode | DataMappingBuilder, type?: DataMappingNodeTypeEnum);
34
- /**
35
- * This is a setter for `sourceProperty`.
36
- * @param sourceProperty
37
- */
38
- setSourceProperty(sourceProperty: string): DataMappingLeaf;
39
- /**
40
- * This is a setter for `destinationProperty`.
41
- * @param destinationProperty
42
- */
43
- setDestinationProperty(destinationProperty: string): DataMappingLeaf;
44
- /**
45
- * This is a setter for `isOptional`.
46
- * @param isOptional
47
- */
48
- setIsOptional(isOptional: boolean): DataMappingLeaf;
49
- /**
50
- * This methods adds a normalizer but checks that this normalizer hasn't been added already (either at the root) or
51
- * directly on this leaf.
52
- *
53
- * @param normalizerUniqueKey
54
- * @param options
55
- */
56
- addNormalizer(normalizerUniqueKey: DataNormalizerUniqueKey, options?: any): DataMappingLeaf;
57
- /**
58
- * This method simply returns whether the normalizer was already added to this node.
59
- * @param normalizerUniqueKey
60
- */
61
- hasNormalizer(normalizerUniqueKey: DataNormalizerUniqueKey): boolean;
62
- /**
63
- * This method adds a normalizer that must be excluded from the normalizers applied at a higher level.à
64
- * @param normalizerUniqueKey
65
- */
66
- excludeNormalizer(normalizerUniqueKey: DataNormalizerUniqueKey): DataMappingLeaf;
67
- /**
68
- * This method adds this node to its parent and returns the parent.
69
- */
70
- end(): DataMappingNode | DataMappingBuilder;
71
- /**
72
- * This method maps the `sourceProperty` from the `source` object and maps it to the `destinationProperty` of the
73
- * `destination` object while applying the normalizers.
74
- *
75
- * @param source
76
- * @param destination
77
- * @param normalizersMap
78
- */
79
- map(source: any, destination: any, normalizersMap: {
80
- [key in DataNormalizerUniqueKey]: DataNormalizerInterface<any, any>;
81
- }): Promise<void>;
82
- /**
83
- * This method imports a schema.
84
- *
85
- * @param schema
86
- */
87
- import(schema: any): void;
88
- /**
89
- * This method exports this node.
90
- */
91
- export(): any;
92
- }
@@ -1,104 +0,0 @@
1
- import { DataMappingNodeTypeEnum } from "../enums/data-mapping-node-type.enum";
2
- import { DataMappingLeaf } from "./data-mapping.leaf";
3
- import { DataMappingBuilder } from "../builders/data-mapping.builder";
4
- import { BaseDataMappingNode } from "./base-data-mapping.node";
5
- import { DataNormalizerUniqueKey } from "../types/data-normalizer-unique-key.type";
6
- import { DataNormalizerInterface } from "../interfaces/data-normalizer.interface";
7
- import { ClassConstructor } from "class-transformer";
8
- export declare class DataMappingNode extends BaseDataMappingNode {
9
- readonly root: DataMappingBuilder;
10
- readonly parent: DataMappingNode | DataMappingBuilder;
11
- readonly type: DataMappingNodeTypeEnum;
12
- /**
13
- * This property represents the property referenced in the `source` object.
14
- */
15
- sourceProperty: string;
16
- /**
17
- * This property represents the property referenced in the `destination` object.
18
- */
19
- destinationProperty: string;
20
- /**
21
- * This method specified whether it's possible that this element not be present in the `source` object.
22
- */
23
- isOptional: boolean;
24
- /**
25
- * IMPORTANT: This property is not serializable. It will be lost during the export.
26
- */
27
- destinationType?: ClassConstructor<any>;
28
- constructor(root: DataMappingBuilder, parent: DataMappingNode | DataMappingBuilder, type?: DataMappingNodeTypeEnum);
29
- /**
30
- * This is a setter for `sourceProperty`.
31
- * @param sourceProperty
32
- */
33
- setSourceProperty(sourceProperty: string): DataMappingNode;
34
- /**
35
- * This is a setter for `destinationProperty`.
36
- * @param destinationProperty
37
- */
38
- setDestinationProperty(destinationProperty: string): DataMappingNode;
39
- /**
40
- * This is a setter for `destinationType`.
41
- * @param destinationType
42
- */
43
- setDestinationType(destinationType: ClassConstructor<any>): DataMappingNode;
44
- /**
45
- * This is a setter for `isOptional`.
46
- * @param isOptional
47
- */
48
- setIsOptional(isOptional: boolean): DataMappingNode;
49
- /**
50
- * This property creates a new DataMappingLeaf and returns it. It doesn't add it yet. To do so, the `end()` method
51
- * must be called.
52
- */
53
- add(): DataMappingLeaf;
54
- /**
55
- * This method adds a nesting level. This should be used when the property contains an object and you want to map
56
- * this object into another object.
57
- */
58
- addNestingLevel(): DataMappingNode;
59
- /**
60
- * This method adds an array of Scalar allowing you to apply the normalizer on each scalar in the array. The
61
- * `sourceProperty` and `destinationProperty` correspond to the name of the property that is an array. But, the
62
- * values in the array will be normalized using the normalizer.
63
- *
64
- */
65
- addArrayOfScalar(): DataMappingLeaf;
66
- /**
67
- * This method adds an array of objects allowing to define a node for each property in the object. Each object in
68
- * the array will be treated as being the same.
69
- */
70
- addArrayOfObjects(): DataMappingNode;
71
- /**
72
- * This method adds this node to its parent and returns the parent.
73
- */
74
- end(): DataMappingNode | DataMappingBuilder;
75
- /**
76
- * This method maps the `sourceProperty` from the `source` object and maps it to the `destinationProperty` of the
77
- * `destination` object while applying the normalizers.
78
- *
79
- * @param source
80
- * @param destination
81
- * @param normalizersMap
82
- */
83
- map(source: any, destination: any, normalizersMap: {
84
- [key in DataNormalizerUniqueKey]: DataNormalizerInterface<any, any>;
85
- }): Promise<void>;
86
- /**
87
- * This method imports a schema.
88
- *
89
- * @param schema
90
- */
91
- import(schema: any): void;
92
- /**
93
- * This method exports this node.
94
- */
95
- export(): {
96
- _type: DataMappingNodeTypeEnum;
97
- sourceProperty: string;
98
- destinationProperty: string;
99
- isOptional: boolean;
100
- nodes: {
101
- [x: string]: DataMappingLeaf | DataMappingNode;
102
- };
103
- };
104
- }
@@ -1,3 +0,0 @@
1
- export * from "./base-data-mapping.node";
2
- export * from "./data-mapping.leaf";
3
- export * from "./data-mapping.node";
@@ -1,4 +0,0 @@
1
- export declare abstract class BaseNormalizerOptions {
2
- shouldThrowIfTypeIsNotString: boolean;
3
- constructor(options?: Partial<BaseNormalizerOptions>);
4
- }
@@ -1,12 +0,0 @@
1
- export declare class DateNormalizerOptions {
2
- /**
3
- * This property specifies whether an invalid date should return undefined or a date object.
4
- */
5
- returnUndefinedOnInvalidDate: boolean;
6
- /**
7
- * This property specifies if a number should be treated as being in seconds or not. Since JS Date expects a
8
- * timestamp in milliseconds, if the number is in seconds, it will be multiplied by 1000.
9
- */
10
- treatNumbers: "milliseconds" | "seconds";
11
- constructor(options?: Partial<DateNormalizerOptions>);
12
- }
@@ -1,4 +0,0 @@
1
- import { BaseNormalizerOptions } from "./base-normalizer.options";
2
- export declare class LowercaseNormalizerOptions extends BaseNormalizerOptions {
3
- constructor(options?: Partial<LowercaseNormalizerOptions>);
4
- }
@@ -1,5 +0,0 @@
1
- export * from "./base-normalizer.options";
2
- export * from "./date-normalizer.options";
3
- export * from "./lowercase-normalizer.options";
4
- export * from "./number-normalizer.options";
5
- export * from "./string-normalizer.options";
@@ -1,8 +0,0 @@
1
- export declare class NumberNormalizerOptions {
2
- /**
3
- * This property specifies whether an undefined value should be ignored and simply returned or treated as a potential string
4
- * and return an empty string `""`.
5
- */
6
- ignoreUndefined: boolean;
7
- constructor(options?: Partial<NumberNormalizerOptions>);
8
- }
@@ -1,12 +0,0 @@
1
- export declare class StringNormalizerOptions {
2
- /**
3
- * This property specifies whether an undefined value should be ignored and simply returned or treated as a potential string
4
- * and return an empty string `""`.
5
- */
6
- ignoreUndefined: boolean;
7
- /**
8
- * This represents the format of the date that the normalizer should use when outputting a date object to a string.
9
- */
10
- dateFormat?: string;
11
- constructor(options?: Partial<StringNormalizerOptions>);
12
- }
@@ -1,6 +0,0 @@
1
- import { DataNormalizerInterface } from "../interfaces/data-normalizer.interface";
2
- import { DateNormalizerOptions } from "../normalizer-options/date-normalizer.options";
3
- export declare class DateNormalizer implements DataNormalizerInterface<Date | undefined, DateNormalizerOptions> {
4
- getUniqueKey(): string;
5
- normalize(source: any, options?: DateNormalizerOptions): Date | undefined;
6
- }
@@ -1,7 +0,0 @@
1
- import { DataNormalizerInterface } from "../interfaces/data-normalizer.interface";
2
- import { DataNormalizerUniqueKey } from "../types/data-normalizer-unique-key.type";
3
- import { LowercaseNormalizerOptions } from "../normalizer-options/lowercase-normalizer.options";
4
- export declare class LowercaseNormalizer implements DataNormalizerInterface<string, LowercaseNormalizerOptions> {
5
- getUniqueKey(): DataNormalizerUniqueKey;
6
- normalize(source: any, options?: LowercaseNormalizerOptions): string;
7
- }
@@ -1,4 +0,0 @@
1
- export * from "./date.normalizer";
2
- export * from "./lowercase.normalizer";
3
- export * from "./number.normalizer";
4
- export * from "./string.normalizer";
@@ -1,6 +0,0 @@
1
- import { DataNormalizerInterface } from "../interfaces/data-normalizer.interface";
2
- import { NumberNormalizerOptions } from "../normalizer-options/number-normalizer.options";
3
- export declare class NumberNormalizer implements DataNormalizerInterface<number | undefined, NumberNormalizerOptions> {
4
- getUniqueKey(): string;
5
- normalize(source: any, options?: NumberNormalizerOptions): number | undefined;
6
- }
@@ -1,6 +0,0 @@
1
- import { DataNormalizerInterface } from "../interfaces/data-normalizer.interface";
2
- import { StringNormalizerOptions } from "../normalizer-options/string-normalizer.options";
3
- export declare class StringNormalizer implements DataNormalizerInterface<string | undefined, StringNormalizerOptions> {
4
- getUniqueKey(): string;
5
- normalize(source: any, options?: StringNormalizerOptions): string | undefined;
6
- }
@@ -1,11 +0,0 @@
1
- export declare class AutoDataMappingBuilderOptions {
2
- /**
3
- * This property is used to specify the default value for the `ìsOptional` property in the builder.
4
- *
5
- * It will not override the `isNullable` metadata for the property.
6
- *
7
- * Default value is `false`.
8
- */
9
- isOptionalDefaultValue: boolean;
10
- constructor(options?: Partial<AutoDataMappingBuilderOptions>);
11
- }
@@ -1 +0,0 @@
1
- export type DataMappingInterceptorUniqueKeyType = string;
@@ -1 +0,0 @@
1
- export type DataNormalizerUniqueKey = string;
@@ -1,2 +0,0 @@
1
- export * from "./data-normalizer-unique-key.type";
2
- export * from "./data-mapping-interceptor-unique-key.type";