@pristine-ts/data-mapping-common 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 (213) hide show
  1. package/LICENSE +201 -0
  2. package/dist/lib/cjs/builders/auto-data-mapping.builder.js +137 -0
  3. package/dist/lib/cjs/builders/auto-data-mapping.builder.js.map +1 -0
  4. package/dist/lib/cjs/builders/builders.js +19 -0
  5. package/dist/lib/cjs/builders/builders.js.map +1 -0
  6. package/dist/lib/cjs/builders/data-mapping.builder.js +178 -0
  7. package/dist/lib/cjs/builders/data-mapping.builder.js.map +1 -0
  8. package/dist/lib/cjs/data-mapping-common.js +26 -0
  9. package/dist/lib/cjs/data-mapping-common.js.map +1 -0
  10. package/dist/lib/cjs/decorators/decorators.js +18 -0
  11. package/dist/lib/cjs/decorators/decorators.js.map +1 -0
  12. package/dist/lib/cjs/decorators/type.decorator.js +20 -0
  13. package/dist/lib/cjs/decorators/type.decorator.js.map +1 -0
  14. package/dist/lib/cjs/enums/data-mapping-node-type.enum.js +11 -0
  15. package/dist/lib/cjs/enums/data-mapping-node-type.enum.js.map +1 -0
  16. package/dist/lib/cjs/enums/enums.js +19 -0
  17. package/dist/lib/cjs/enums/enums.js.map +1 -0
  18. package/dist/lib/cjs/enums/metadata.enum.js +8 -0
  19. package/dist/lib/cjs/enums/metadata.enum.js.map +1 -0
  20. package/dist/lib/cjs/errors/array-data-mapping-node-invalid-source-property-type.error.js +17 -0
  21. package/dist/lib/cjs/errors/array-data-mapping-node-invalid-source-property-type.error.js.map +1 -0
  22. package/dist/lib/cjs/errors/data-after-mapping-interceptor-already-added.error.js +17 -0
  23. package/dist/lib/cjs/errors/data-after-mapping-interceptor-already-added.error.js.map +1 -0
  24. package/dist/lib/cjs/errors/data-before-mapping-interceptor-already-added.error.js +17 -0
  25. package/dist/lib/cjs/errors/data-before-mapping-interceptor-already-added.error.js.map +1 -0
  26. package/dist/lib/cjs/errors/data-mapping-interceptor-not-found.error.js +17 -0
  27. package/dist/lib/cjs/errors/data-mapping-interceptor-not-found.error.js.map +1 -0
  28. package/dist/lib/cjs/errors/data-mapping-source-property-not-found.error.js +17 -0
  29. package/dist/lib/cjs/errors/data-mapping-source-property-not-found.error.js.map +1 -0
  30. package/dist/lib/cjs/errors/data-normalizer-already-added.error.js +17 -0
  31. package/dist/lib/cjs/errors/data-normalizer-already-added.error.js.map +1 -0
  32. package/dist/lib/cjs/errors/errors.js +25 -0
  33. package/dist/lib/cjs/errors/errors.js.map +1 -0
  34. package/dist/lib/cjs/errors/normalizer-invalid-source-type.error.js +17 -0
  35. package/dist/lib/cjs/errors/normalizer-invalid-source-type.error.js.map +1 -0
  36. package/dist/lib/cjs/errors/undefined-source-property.error.js +17 -0
  37. package/dist/lib/cjs/errors/undefined-source-property.error.js.map +1 -0
  38. package/dist/lib/cjs/interfaces/data-mapping-interceptor.interface.js +3 -0
  39. package/dist/lib/cjs/interfaces/data-mapping-interceptor.interface.js.map +1 -0
  40. package/dist/lib/cjs/interfaces/data-normalizer.interface.js +3 -0
  41. package/dist/lib/cjs/interfaces/data-normalizer.interface.js.map +1 -0
  42. package/dist/lib/cjs/interfaces/interfaces.js +19 -0
  43. package/dist/lib/cjs/interfaces/interfaces.js.map +1 -0
  44. package/dist/lib/cjs/mappers/data.mapper.js +103 -0
  45. package/dist/lib/cjs/mappers/data.mapper.js.map +1 -0
  46. package/dist/lib/cjs/mappers/mappers.js +18 -0
  47. package/dist/lib/cjs/mappers/mappers.js.map +1 -0
  48. package/dist/lib/cjs/nodes/base-data-mapping.node.js +24 -0
  49. package/dist/lib/cjs/nodes/base-data-mapping.node.js.map +1 -0
  50. package/dist/lib/cjs/nodes/data-mapping.leaf.js +184 -0
  51. package/dist/lib/cjs/nodes/data-mapping.leaf.js.map +1 -0
  52. package/dist/lib/cjs/nodes/data-mapping.node.js +217 -0
  53. package/dist/lib/cjs/nodes/data-mapping.node.js.map +1 -0
  54. package/dist/lib/cjs/nodes/nodes.js +20 -0
  55. package/dist/lib/cjs/nodes/nodes.js.map +1 -0
  56. package/dist/lib/cjs/normalizer-options/base-normalizer.options.js +12 -0
  57. package/dist/lib/cjs/normalizer-options/base-normalizer.options.js.map +1 -0
  58. package/dist/lib/cjs/normalizer-options/date-normalizer.options.js +21 -0
  59. package/dist/lib/cjs/normalizer-options/date-normalizer.options.js.map +1 -0
  60. package/dist/lib/cjs/normalizer-options/lowercase-normalizer.options.js +11 -0
  61. package/dist/lib/cjs/normalizer-options/lowercase-normalizer.options.js.map +1 -0
  62. package/dist/lib/cjs/normalizer-options/normalizer-options.js +22 -0
  63. package/dist/lib/cjs/normalizer-options/normalizer-options.js.map +1 -0
  64. package/dist/lib/cjs/normalizer-options/number-normalizer.options.js +16 -0
  65. package/dist/lib/cjs/normalizer-options/number-normalizer.options.js.map +1 -0
  66. package/dist/lib/cjs/normalizer-options/string-normalizer.options.js +17 -0
  67. package/dist/lib/cjs/normalizer-options/string-normalizer.options.js.map +1 -0
  68. package/dist/lib/cjs/normalizers/date.normalizer.js +62 -0
  69. package/dist/lib/cjs/normalizers/date.normalizer.js.map +1 -0
  70. package/dist/lib/cjs/normalizers/lowercase.normalizer.js +20 -0
  71. package/dist/lib/cjs/normalizers/lowercase.normalizer.js.map +1 -0
  72. package/dist/lib/cjs/normalizers/normalizers.js +21 -0
  73. package/dist/lib/cjs/normalizers/normalizers.js.map +1 -0
  74. package/dist/lib/cjs/normalizers/number.normalizer.js +30 -0
  75. package/dist/lib/cjs/normalizers/number.normalizer.js.map +1 -0
  76. package/dist/lib/cjs/normalizers/string.normalizer.js +52 -0
  77. package/dist/lib/cjs/normalizers/string.normalizer.js.map +1 -0
  78. package/dist/lib/cjs/options/auto-data-mapping-builder.options.js +11 -0
  79. package/dist/lib/cjs/options/auto-data-mapping-builder.options.js.map +1 -0
  80. package/dist/lib/cjs/types/data-mapping-interceptor-unique-key.type.js +3 -0
  81. package/dist/lib/cjs/types/data-mapping-interceptor-unique-key.type.js.map +1 -0
  82. package/dist/lib/cjs/types/data-normalizer-unique-key.type.js +3 -0
  83. package/dist/lib/cjs/types/data-normalizer-unique-key.type.js.map +1 -0
  84. package/dist/lib/cjs/types/types.js +19 -0
  85. package/dist/lib/cjs/types/types.js.map +1 -0
  86. package/dist/lib/esm/builders/auto-data-mapping.builder.js +133 -0
  87. package/dist/lib/esm/builders/auto-data-mapping.builder.js.map +1 -0
  88. package/dist/lib/esm/builders/builders.js +3 -0
  89. package/dist/lib/esm/builders/builders.js.map +1 -0
  90. package/dist/lib/esm/builders/data-mapping.builder.js +174 -0
  91. package/dist/lib/esm/builders/data-mapping.builder.js.map +1 -0
  92. package/dist/lib/esm/data-mapping-common.js +10 -0
  93. package/dist/lib/esm/data-mapping-common.js.map +1 -0
  94. package/dist/lib/esm/decorators/decorators.js +2 -0
  95. package/dist/lib/esm/decorators/decorators.js.map +1 -0
  96. package/dist/lib/esm/decorators/type.decorator.js +16 -0
  97. package/dist/lib/esm/decorators/type.decorator.js.map +1 -0
  98. package/dist/lib/esm/enums/data-mapping-node-type.enum.js +8 -0
  99. package/dist/lib/esm/enums/data-mapping-node-type.enum.js.map +1 -0
  100. package/dist/lib/esm/enums/enums.js +3 -0
  101. package/dist/lib/esm/enums/enums.js.map +1 -0
  102. package/dist/lib/esm/enums/metadata.enum.js +5 -0
  103. package/dist/lib/esm/enums/metadata.enum.js.map +1 -0
  104. package/dist/lib/esm/errors/array-data-mapping-node-invalid-source-property-type.error.js +13 -0
  105. package/dist/lib/esm/errors/array-data-mapping-node-invalid-source-property-type.error.js.map +1 -0
  106. package/dist/lib/esm/errors/data-after-mapping-interceptor-already-added.error.js +13 -0
  107. package/dist/lib/esm/errors/data-after-mapping-interceptor-already-added.error.js.map +1 -0
  108. package/dist/lib/esm/errors/data-before-mapping-interceptor-already-added.error.js +13 -0
  109. package/dist/lib/esm/errors/data-before-mapping-interceptor-already-added.error.js.map +1 -0
  110. package/dist/lib/esm/errors/data-mapping-interceptor-not-found.error.js +13 -0
  111. package/dist/lib/esm/errors/data-mapping-interceptor-not-found.error.js.map +1 -0
  112. package/dist/lib/esm/errors/data-mapping-source-property-not-found.error.js +13 -0
  113. package/dist/lib/esm/errors/data-mapping-source-property-not-found.error.js.map +1 -0
  114. package/dist/lib/esm/errors/data-normalizer-already-added.error.js +13 -0
  115. package/dist/lib/esm/errors/data-normalizer-already-added.error.js.map +1 -0
  116. package/dist/lib/esm/errors/errors.js +9 -0
  117. package/dist/lib/esm/errors/errors.js.map +1 -0
  118. package/dist/lib/esm/errors/normalizer-invalid-source-type.error.js +13 -0
  119. package/dist/lib/esm/errors/normalizer-invalid-source-type.error.js.map +1 -0
  120. package/dist/lib/esm/errors/undefined-source-property.error.js +13 -0
  121. package/dist/lib/esm/errors/undefined-source-property.error.js.map +1 -0
  122. package/dist/lib/esm/interfaces/data-mapping-interceptor.interface.js +2 -0
  123. package/dist/lib/esm/interfaces/data-mapping-interceptor.interface.js.map +1 -0
  124. package/dist/lib/esm/interfaces/data-normalizer.interface.js +2 -0
  125. package/dist/lib/esm/interfaces/data-normalizer.interface.js.map +1 -0
  126. package/dist/lib/esm/interfaces/interfaces.js +3 -0
  127. package/dist/lib/esm/interfaces/interfaces.js.map +1 -0
  128. package/dist/lib/esm/mappers/data.mapper.js +99 -0
  129. package/dist/lib/esm/mappers/data.mapper.js.map +1 -0
  130. package/dist/lib/esm/mappers/mappers.js +2 -0
  131. package/dist/lib/esm/mappers/mappers.js.map +1 -0
  132. package/dist/lib/esm/nodes/base-data-mapping.node.js +20 -0
  133. package/dist/lib/esm/nodes/base-data-mapping.node.js.map +1 -0
  134. package/dist/lib/esm/nodes/data-mapping.leaf.js +180 -0
  135. package/dist/lib/esm/nodes/data-mapping.leaf.js.map +1 -0
  136. package/dist/lib/esm/nodes/data-mapping.node.js +213 -0
  137. package/dist/lib/esm/nodes/data-mapping.node.js.map +1 -0
  138. package/dist/lib/esm/nodes/nodes.js +4 -0
  139. package/dist/lib/esm/nodes/nodes.js.map +1 -0
  140. package/dist/lib/esm/normalizer-options/base-normalizer.options.js +8 -0
  141. package/dist/lib/esm/normalizer-options/base-normalizer.options.js.map +1 -0
  142. package/dist/lib/esm/normalizer-options/date-normalizer.options.js +17 -0
  143. package/dist/lib/esm/normalizer-options/date-normalizer.options.js.map +1 -0
  144. package/dist/lib/esm/normalizer-options/lowercase-normalizer.options.js +7 -0
  145. package/dist/lib/esm/normalizer-options/lowercase-normalizer.options.js.map +1 -0
  146. package/dist/lib/esm/normalizer-options/normalizer-options.js +6 -0
  147. package/dist/lib/esm/normalizer-options/normalizer-options.js.map +1 -0
  148. package/dist/lib/esm/normalizer-options/number-normalizer.options.js +12 -0
  149. package/dist/lib/esm/normalizer-options/number-normalizer.options.js.map +1 -0
  150. package/dist/lib/esm/normalizer-options/string-normalizer.options.js +13 -0
  151. package/dist/lib/esm/normalizer-options/string-normalizer.options.js.map +1 -0
  152. package/dist/lib/esm/normalizers/date.normalizer.js +58 -0
  153. package/dist/lib/esm/normalizers/date.normalizer.js.map +1 -0
  154. package/dist/lib/esm/normalizers/lowercase.normalizer.js +16 -0
  155. package/dist/lib/esm/normalizers/lowercase.normalizer.js.map +1 -0
  156. package/dist/lib/esm/normalizers/normalizers.js +5 -0
  157. package/dist/lib/esm/normalizers/normalizers.js.map +1 -0
  158. package/dist/lib/esm/normalizers/number.normalizer.js +26 -0
  159. package/dist/lib/esm/normalizers/number.normalizer.js.map +1 -0
  160. package/dist/lib/esm/normalizers/string.normalizer.js +48 -0
  161. package/dist/lib/esm/normalizers/string.normalizer.js.map +1 -0
  162. package/dist/lib/esm/options/auto-data-mapping-builder.options.js +7 -0
  163. package/dist/lib/esm/options/auto-data-mapping-builder.options.js.map +1 -0
  164. package/dist/lib/esm/types/data-mapping-interceptor-unique-key.type.js +2 -0
  165. package/dist/lib/esm/types/data-mapping-interceptor-unique-key.type.js.map +1 -0
  166. package/dist/lib/esm/types/data-normalizer-unique-key.type.js +2 -0
  167. package/dist/lib/esm/types/data-normalizer-unique-key.type.js.map +1 -0
  168. package/dist/lib/esm/types/types.js +3 -0
  169. package/dist/lib/esm/types/types.js.map +1 -0
  170. package/dist/types/builders/auto-data-mapping.builder.d.ts +25 -0
  171. package/dist/types/builders/builders.d.ts +2 -0
  172. package/dist/types/builders/data-mapping.builder.d.ts +110 -0
  173. package/dist/types/data-mapping-common.d.ts +9 -0
  174. package/dist/types/decorators/decorators.d.ts +1 -0
  175. package/dist/types/decorators/type.decorator.d.ts +2 -0
  176. package/dist/types/enums/data-mapping-node-type.enum.d.ts +6 -0
  177. package/dist/types/enums/enums.d.ts +2 -0
  178. package/dist/types/enums/metadata.enum.d.ts +3 -0
  179. package/dist/types/errors/array-data-mapping-node-invalid-source-property-type.error.d.ts +6 -0
  180. package/dist/types/errors/data-after-mapping-interceptor-already-added.error.d.ts +7 -0
  181. package/dist/types/errors/data-before-mapping-interceptor-already-added.error.d.ts +7 -0
  182. package/dist/types/errors/data-mapping-interceptor-not-found.error.d.ts +7 -0
  183. package/dist/types/errors/data-mapping-source-property-not-found.error.d.ts +6 -0
  184. package/dist/types/errors/data-normalizer-already-added.error.d.ts +6 -0
  185. package/dist/types/errors/errors.d.ts +8 -0
  186. package/dist/types/errors/normalizer-invalid-source-type.error.d.ts +6 -0
  187. package/dist/types/errors/undefined-source-property.error.d.ts +8 -0
  188. package/dist/types/interfaces/data-mapping-interceptor.interface.d.ts +19 -0
  189. package/dist/types/interfaces/data-normalizer.interface.d.ts +15 -0
  190. package/dist/types/interfaces/interfaces.d.ts +2 -0
  191. package/dist/types/mappers/data.mapper.d.ts +38 -0
  192. package/dist/types/mappers/mappers.d.ts +1 -0
  193. package/dist/types/nodes/base-data-mapping.node.d.ts +15 -0
  194. package/dist/types/nodes/data-mapping.leaf.d.ts +92 -0
  195. package/dist/types/nodes/data-mapping.node.d.ts +104 -0
  196. package/dist/types/nodes/nodes.d.ts +3 -0
  197. package/dist/types/normalizer-options/base-normalizer.options.d.ts +4 -0
  198. package/dist/types/normalizer-options/date-normalizer.options.d.ts +12 -0
  199. package/dist/types/normalizer-options/lowercase-normalizer.options.d.ts +4 -0
  200. package/dist/types/normalizer-options/normalizer-options.d.ts +5 -0
  201. package/dist/types/normalizer-options/number-normalizer.options.d.ts +8 -0
  202. package/dist/types/normalizer-options/string-normalizer.options.d.ts +12 -0
  203. package/dist/types/normalizers/date.normalizer.d.ts +6 -0
  204. package/dist/types/normalizers/lowercase.normalizer.d.ts +7 -0
  205. package/dist/types/normalizers/normalizers.d.ts +4 -0
  206. package/dist/types/normalizers/number.normalizer.d.ts +6 -0
  207. package/dist/types/normalizers/string.normalizer.d.ts +6 -0
  208. package/dist/types/options/auto-data-mapping-builder.options.d.ts +11 -0
  209. package/dist/types/types/data-mapping-interceptor-unique-key.type.d.ts +1 -0
  210. package/dist/types/types/data-normalizer-unique-key.type.d.ts +1 -0
  211. package/dist/types/types/types.d.ts +2 -0
  212. package/package.json +67 -0
  213. package/readme.md +1 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AutoDataMappingBuilder = void 0;
4
+ const data_mapping_builder_1 = require("./data-mapping.builder");
5
+ const data_mapping_node_1 = require("../nodes/data-mapping.node");
6
+ const metadata_1 = require("@pristine-ts/metadata");
7
+ const data_mapping_leaf_1 = require("../nodes/data-mapping.leaf");
8
+ const number_normalizer_1 = require("../normalizers/number.normalizer");
9
+ const string_normalizer_1 = require("../normalizers/string.normalizer");
10
+ const date_normalizer_1 = require("../normalizers/date.normalizer");
11
+ const data_mapping_node_type_enum_1 = require("../enums/data-mapping-node-type.enum");
12
+ const auto_data_mapping_builder_options_1 = require("../options/auto-data-mapping-builder.options");
13
+ const metadata_enum_1 = require("../enums/metadata.enum");
14
+ class AutoDataMappingBuilder {
15
+ /**
16
+ * This method receives a source object and a destinationType that corresponds to the type of the class
17
+ * that the source should be mapped to. It then creates a DataMappingBuilder object that contains the schema
18
+ * needed to map the source to the destinationType.
19
+ * @param source
20
+ * @param destinationType
21
+ * @param options
22
+ */
23
+ build(source, destinationType, options) {
24
+ const dataMappingBuilder = new data_mapping_builder_1.DataMappingBuilder();
25
+ this.internalBuild(source, destinationType, dataMappingBuilder, dataMappingBuilder, new auto_data_mapping_builder_options_1.AutoDataMappingBuilderOptions(options));
26
+ return dataMappingBuilder;
27
+ }
28
+ /**
29
+ * This method is the internal method that is called recursively to build the schema.
30
+ *
31
+ * @param source
32
+ * @param destinationType
33
+ * @param root
34
+ * @param parent
35
+ * @param options
36
+ * @private
37
+ */
38
+ internalBuild(source, destinationType, root, parent, options) {
39
+ if (!source) {
40
+ return;
41
+ }
42
+ // Get the metadata of destinationType and iterate over its properties.
43
+ const classInformation = metadata_1.ClassMetadata.getInformation(destinationType);
44
+ classInformation.properties.forEach(propertyKey => {
45
+ var _a, _b, _c, _d;
46
+ // Retrieve the metadata for the property
47
+ const propertyInformation = metadata_1.PropertyMetadata.getInformation(destinationType.prototype, propertyKey);
48
+ let typeObject = propertyInformation.typeObject;
49
+ // Check if we have a `@typeFactory` decorator, it means that there's a callback that must be executed
50
+ // for this property to retrieve the actual DestinationType object. If there's one, execute it.
51
+ const typeFactoryCallback = metadata_1.PropertyMetadata.getMetadata(destinationType.prototype, propertyKey, metadata_enum_1.MetadataEnum.TypeFactory);
52
+ if (typeFactoryCallback) {
53
+ typeObject = typeFactoryCallback(source, propertyKey).constructor;
54
+ }
55
+ // If the property references an object, this means that we need to recursively call this method to build the schema.
56
+ if (propertyInformation.typeEnum === metadata_1.TypeEnum.Object) {
57
+ const dataMappingNode = new data_mapping_node_1.DataMappingNode(root, parent);
58
+ dataMappingNode
59
+ .setSourceProperty(propertyKey)
60
+ .setDestinationProperty(propertyKey)
61
+ .setDestinationType(typeObject)
62
+ .setIsOptional((_a = propertyInformation.isNullable) !== null && _a !== void 0 ? _a : options.isOptionalDefaultValue)
63
+ .end();
64
+ return this.internalBuild(source[propertyKey], typeObject, root, dataMappingNode, options);
65
+ }
66
+ else if (propertyInformation.typeEnum === metadata_1.TypeEnum.Array) { // If the property references an array, we need to iterate over each element and recursively call this method to build the schema.
67
+ let nestedType = data_mapping_node_type_enum_1.DataMappingNodeTypeEnum.ScalarArray;
68
+ if (!source.hasOwnProperty(propertyKey) || Array.isArray(source[propertyKey]) === false || source[propertyKey].length === 0) {
69
+ return;
70
+ }
71
+ // Use the first element in the array to determine the type of content stored in the array. Here, we assume that all the elements in the array are of the same type.
72
+ const nestedElementType = metadata_1.TypeUtils.getTypeOfValue(source[propertyKey][0]);
73
+ switch (nestedElementType) {
74
+ case metadata_1.TypeEnum.Object:
75
+ nestedType = data_mapping_node_type_enum_1.DataMappingNodeTypeEnum.ObjectArray;
76
+ break;
77
+ }
78
+ // If the array is an array of scalars, then it will be a LeafNode of type ScalarArray with no children.
79
+ if (nestedType === data_mapping_node_type_enum_1.DataMappingNodeTypeEnum.ScalarArray) {
80
+ const dataMappingLeaf = parent.addArrayOfScalar();
81
+ const normalizers = [];
82
+ // todo: Allow for options to be specified per attribute. We should probably add a decorator to can customize the normalizer.
83
+ switch (nestedElementType) {
84
+ case metadata_1.TypeEnum.Number:
85
+ normalizers.push(number_normalizer_1.NumberNormalizer.name);
86
+ break;
87
+ case metadata_1.TypeEnum.String:
88
+ normalizers.push(string_normalizer_1.StringNormalizer.name);
89
+ break;
90
+ case metadata_1.TypeEnum.Date:
91
+ normalizers.push(date_normalizer_1.DateNormalizer.name);
92
+ break;
93
+ }
94
+ normalizers.forEach(normalizer => dataMappingLeaf.addNormalizer(normalizer));
95
+ dataMappingLeaf.setSourceProperty(propertyKey)
96
+ .setDestinationProperty(propertyKey)
97
+ .setIsOptional((_b = propertyInformation.isNullable) !== null && _b !== void 0 ? _b : options.isOptionalDefaultValue)
98
+ .end();
99
+ return;
100
+ }
101
+ // Else, it's an array of objects and we must iterate over the first element to get all the properties and
102
+ // build the tree.
103
+ const dataMappingNode = parent.addArrayOfObjects();
104
+ dataMappingNode
105
+ .setSourceProperty(propertyKey)
106
+ .setDestinationProperty(propertyKey)
107
+ .setDestinationType(propertyInformation.arrayMemberObject)
108
+ .setIsOptional((_c = propertyInformation.isNullable) !== null && _c !== void 0 ? _c : options.isOptionalDefaultValue)
109
+ .end();
110
+ // We assume all the objects are similar so we use only the first one to build the schema
111
+ return this.internalBuild(source[propertyKey][0], propertyInformation.arrayMemberObject, root, dataMappingNode, options);
112
+ }
113
+ const normalizers = [];
114
+ // todo: Allow for options to be specified per attribute. We should probably add a decorator to can customize the normalizer.
115
+ switch (propertyInformation.typeEnum) {
116
+ case metadata_1.TypeEnum.Number:
117
+ normalizers.push(number_normalizer_1.NumberNormalizer.name);
118
+ break;
119
+ case metadata_1.TypeEnum.String:
120
+ normalizers.push(string_normalizer_1.StringNormalizer.name);
121
+ break;
122
+ case metadata_1.TypeEnum.Date:
123
+ normalizers.push(date_normalizer_1.DateNormalizer.name);
124
+ break;
125
+ }
126
+ const dataMappingLeaf = new data_mapping_leaf_1.DataMappingLeaf(root, parent);
127
+ normalizers.forEach(normalizer => dataMappingLeaf.addNormalizer(normalizer));
128
+ dataMappingLeaf
129
+ .setSourceProperty(propertyKey)
130
+ .setDestinationProperty(propertyKey)
131
+ .setIsOptional((_d = propertyInformation.isNullable) !== null && _d !== void 0 ? _d : options.isOptionalDefaultValue)
132
+ .end();
133
+ });
134
+ }
135
+ }
136
+ exports.AutoDataMappingBuilder = AutoDataMappingBuilder;
137
+ //# sourceMappingURL=auto-data-mapping.builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-data-mapping.builder.js","sourceRoot":"","sources":["../../../../src/builders/auto-data-mapping.builder.ts"],"names":[],"mappings":";;;AACA,iEAA0D;AAC1D,kEAA2D;AAC3D,oDAA2F;AAC3F,kEAA2D;AAC3D,wEAAkE;AAClE,wEAAkE;AAClE,oEAA8D;AAE9D,sFAA6E;AAC7E,oGAA2F;AAC3F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ACnC,KAAK,mBAAQ,CAAC,MAAM;oBAChB,WAAW,CAAC,IAAI,CAAC,oCAAgB,CAAC,IAAI,CAAC,CAAC;oBACxC,MAAM;gBAEV,KAAK,mBAAQ,CAAC,MAAM;oBAChB,WAAW,CAAC,IAAI,CAAC,oCAAgB,CAAC,IAAI,CAAC,CAAC;oBACxC,MAAM;gBAEV,KAAK,mBAAQ,CAAC,IAAI;oBACd,WAAW,CAAC,IAAI,CAAC,gCAAc,CAAC,IAAI,CAAC,CAAC;oBACtC,MAAM;YACd,CAAC;YAED,MAAM,eAAe,GAAG,IAAI,mCAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC1D,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,eAAe,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;YAE7E,eAAe;iBACV,iBAAiB,CAAC,WAAW,CAAC;iBAC9B,sBAAsB,CAAC,WAAW,CAAC;iBACnC,aAAa,CAAC,MAAA,mBAAmB,CAAC,UAAU,mCAAI,OAAO,CAAC,sBAAsB,CAAC;iBAC/E,GAAG,EAAE,CAAC;QACf,CAAC,CAAC,CAAA;IACN,CAAC;CACJ;AArJD,wDAqJC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./auto-data-mapping.builder"), exports);
18
+ __exportStar(require("./data-mapping.builder"), exports);
19
+ //# sourceMappingURL=builders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builders.js","sourceRoot":"","sources":["../../../../src/builders/builders.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA4C;AAC5C,yDAAuC"}
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataMappingBuilder = void 0;
4
+ const data_mapping_node_1 = require("../nodes/data-mapping.node");
5
+ const data_normalizer_already_added_error_1 = require("../errors/data-normalizer-already-added.error");
6
+ const data_before_mapping_interceptor_already_added_error_1 = require("../errors/data-before-mapping-interceptor-already-added.error");
7
+ const data_after_mapping_interceptor_already_added_error_1 = require("../errors/data-after-mapping-interceptor-already-added.error");
8
+ const data_mapping_leaf_1 = require("../nodes/data-mapping.leaf");
9
+ const base_data_mapping_node_1 = require("../nodes/base-data-mapping.node");
10
+ const data_mapping_node_type_enum_1 = require("../enums/data-mapping-node-type.enum");
11
+ class DataMappingBuilder extends base_data_mapping_node_1.BaseDataMappingNode {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.normalizers = [];
15
+ this.beforeMappingInterceptors = [];
16
+ this.afterMappingInterceptors = [];
17
+ }
18
+ /**
19
+ * This method adds a normalizer to the root that will be applied on each node (unless they explicitly exclude to do
20
+ * so).
21
+ *
22
+ * @param normalizerUniqueKey
23
+ * @param options
24
+ */
25
+ addNormalizer(normalizerUniqueKey, options) {
26
+ if (this.hasNormalizer(normalizerUniqueKey)) {
27
+ throw new data_normalizer_already_added_error_1.DataNormalizerAlreadyAdded("The data normalizer '" + normalizerUniqueKey + "' has already been added to this builder.", normalizerUniqueKey, options);
28
+ }
29
+ this.normalizers.push({
30
+ key: normalizerUniqueKey,
31
+ options,
32
+ });
33
+ return this;
34
+ }
35
+ /**
36
+ * This method returns whether there's a normalizer for the specified key or not.
37
+ *
38
+ * @param normalizerUniqueKey
39
+ */
40
+ hasNormalizer(normalizerUniqueKey) {
41
+ return this.normalizers.find(element => element.key === normalizerUniqueKey) !== undefined;
42
+ }
43
+ /**
44
+ * This method adds an interceptor that will be executed **before** the object is mapped.
45
+ *
46
+ * @param key
47
+ * @param options
48
+ */
49
+ addBeforeMappingInterceptor(key, options) {
50
+ if (this.hasBeforeMappingInterceptor(key)) {
51
+ throw new data_before_mapping_interceptor_already_added_error_1.DataBeforeMappingInterceptorAlreadyAddedError("The before row transform interceptor has already been added to this Tree.", key, options);
52
+ }
53
+ this.beforeMappingInterceptors.push({
54
+ key,
55
+ options,
56
+ });
57
+ return this;
58
+ }
59
+ /**
60
+ * This method returns whether a **before** interceptor already exists.
61
+ * @param key
62
+ */
63
+ hasBeforeMappingInterceptor(key) {
64
+ return this.beforeMappingInterceptors.find(element => element.key === key) !== undefined;
65
+ }
66
+ /**
67
+ * This method adds an interceptor that will be executed **after** the object is mapped.
68
+ *
69
+ * @param key
70
+ * @param options
71
+ */
72
+ addAfterMappingInterceptor(key, options) {
73
+ if (this.hasAfterMappingInterceptor(key)) {
74
+ throw new data_after_mapping_interceptor_already_added_error_1.DataAfterMappingInterceptorAlreadyAddedError("The after row transform interceptor has already been added to this Tree.", key, options);
75
+ }
76
+ this.afterMappingInterceptors.push({
77
+ key,
78
+ options,
79
+ });
80
+ return this;
81
+ }
82
+ /**
83
+ * This method returns whether a **after** interceptor already exists.
84
+ * @param key
85
+ */
86
+ hasAfterMappingInterceptor(key) {
87
+ return this.afterMappingInterceptors.find(element => element.key === key) !== undefined;
88
+ }
89
+ /**
90
+ * This property creates a new DataMappingLeaf and returns it. It doesn't add it yet. To do so, the `end()` method
91
+ * must be called.
92
+ */
93
+ add() {
94
+ return new data_mapping_leaf_1.DataMappingLeaf(this, this);
95
+ }
96
+ /**
97
+ * This method adds a nesting level. This should be used when the property contains an object and you want to map
98
+ * this object into another object.
99
+ */
100
+ addNestingLevel() {
101
+ return new data_mapping_node_1.DataMappingNode(this, this);
102
+ }
103
+ /**
104
+ * This method adds an array of Scalar allowing you to apply the normalizer on each scalar in the array. The
105
+ * `sourceProperty` and `destinationProperty` correspond to the name of the property that is an array. But, the
106
+ * values in the array will be normalized using the normalizer.
107
+ *
108
+ */
109
+ addArrayOfScalar() {
110
+ return new data_mapping_leaf_1.DataMappingLeaf(this, this, data_mapping_node_type_enum_1.DataMappingNodeTypeEnum.ScalarArray);
111
+ }
112
+ /**
113
+ * This method adds an array of objects allowing to define a node for each property in the object. Each object in
114
+ * the array will be treated as being the same.
115
+ */
116
+ addArrayOfObjects() {
117
+ return new data_mapping_node_1.DataMappingNode(this, this, data_mapping_node_type_enum_1.DataMappingNodeTypeEnum.ObjectArray);
118
+ }
119
+ /**
120
+ * This method is called at the end just to make it nice since all the nodes will have one, it's nice
121
+ * that the builder has one too.
122
+ */
123
+ end() {
124
+ return this;
125
+ }
126
+ /**
127
+ * This method imports a schema.
128
+ *
129
+ * @param schema
130
+ */
131
+ import(schema) {
132
+ this.normalizers = schema.normalizers;
133
+ this.beforeMappingInterceptors = schema.beforeMappingInterceptors;
134
+ this.afterMappingInterceptors = schema.afterMappingInterceptors;
135
+ const nodes = schema.nodes;
136
+ for (const key in nodes) {
137
+ if (nodes.hasOwnProperty(key) === false) {
138
+ continue;
139
+ }
140
+ const nodeInfo = nodes[key];
141
+ const type = nodeInfo["_type"];
142
+ switch (type) {
143
+ case data_mapping_node_type_enum_1.DataMappingNodeTypeEnum.ScalarArray:
144
+ case data_mapping_node_type_enum_1.DataMappingNodeTypeEnum.Leaf:
145
+ const leaf = new data_mapping_leaf_1.DataMappingLeaf(this, this, type);
146
+ leaf.import(nodeInfo);
147
+ this.nodes[leaf.sourceProperty] = leaf;
148
+ continue;
149
+ case data_mapping_node_type_enum_1.DataMappingNodeTypeEnum.Node:
150
+ case data_mapping_node_type_enum_1.DataMappingNodeTypeEnum.ObjectArray:
151
+ const node = new data_mapping_node_1.DataMappingNode(this, this, type);
152
+ node.import(nodeInfo);
153
+ this.nodes[node.sourceProperty] = node;
154
+ continue;
155
+ }
156
+ }
157
+ }
158
+ /**
159
+ * This method exports this node.
160
+ */
161
+ export() {
162
+ const nodes = this.nodes;
163
+ for (const key in nodes) {
164
+ if (nodes.hasOwnProperty(key) === false) {
165
+ continue;
166
+ }
167
+ nodes[key] = nodes[key].export();
168
+ }
169
+ return {
170
+ "nodes": nodes,
171
+ "normalizers": this.normalizers,
172
+ "beforeMappingInterceptors": this.beforeMappingInterceptors,
173
+ "afterMappingInterceptors": this.afterMappingInterceptors,
174
+ };
175
+ }
176
+ }
177
+ exports.DataMappingBuilder = DataMappingBuilder;
178
+ //# sourceMappingURL=data-mapping.builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-mapping.builder.js","sourceRoot":"","sources":["../../../../src/builders/data-mapping.builder.ts"],"names":[],"mappings":";;;AAAA,kEAA2D;AAE3D,uGAAyF;AAEzF,uIAEuE;AACvE,qIAEsE;AACtE,kEAA2D;AAC3D,4EAAoE;AACpE,sFAA6E;AAE7E,MAAa,kBAAmB,SAAQ,4CAAmB;IAA3D;;QACW,gBAAW,GAAoD,EAAE,CAAC;QAClE,8BAAyB,GAAgE,EAAE,CAAC;QAC5F,6BAAwB,GAAgE,EAAE,CAAC;IA2LtG,CAAC;IAzLG;;;;;;OAMG;IACI,aAAa,CAAC,mBAA4C,EAAE,OAAa;QAC5E,IAAG,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACzC,MAAM,IAAI,gEAA0B,CAAC,uBAAuB,GAAG,mBAAmB,GAAG,2CAA2C,EAAE,mBAAmB,EAAE,OAAO,CAAC,CAAC;QACpK,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;YAClB,GAAG,EAAE,mBAAmB;YACxB,OAAO;SACV,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,aAAa,CAAC,mBA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IAAI,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;oBACvC,SAAS;gBAEb,KAAK,qDAAuB,CAAC,IAAI,CAAC;gBAClC,KAAK,qDAAuB,CAAC,WAAW;oBACpC,MAAM,IAAI,GAAG,IAAI,mCAAe,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;oBACnD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;oBACtB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;oBACvC,SAAS;YACjB,CAAC;QACL,CAAC;IACL,CAAC;IAED;;OAEG;IACI,MAAM;QACT,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAEzB,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;YACtB,IAAG,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE,CAAC;gBACrC,SAAS;YACb,CAAC;YAED,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;QACrC,CAAC;QAED,OAAO;YACH,OAAO,EAAE,KAAK;YACd,aAAa,EAAC,IAAI,CAAC,WAAW;YAC9B,2BAA2B,EAAE,IAAI,CAAC,yBAAyB;YAC3D,0BAA0B,EAAE,IAAI,CAAC,wBAAwB;SAE5D,CAAA;IACL,CAAC;CACJ;AA9LD,gDA8LC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./builders/builders"), exports);
18
+ __exportStar(require("./enums/enums"), exports);
19
+ __exportStar(require("./errors/errors"), exports);
20
+ __exportStar(require("./interfaces/interfaces"), exports);
21
+ __exportStar(require("./mappers/mappers"), exports);
22
+ __exportStar(require("./nodes/nodes"), exports);
23
+ __exportStar(require("./normalizer-options/normalizer-options"), exports);
24
+ __exportStar(require("./normalizers/normalizers"), exports);
25
+ __exportStar(require("./types/types"), exports);
26
+ //# sourceMappingURL=data-mapping-common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-mapping-common.js","sourceRoot":"","sources":["../../../src/data-mapping-common.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,gDAA8B;AAC9B,kDAAgC;AAChC,0DAAwC;AACxC,oDAAkC;AAClC,gDAA8B;AAC9B,0EAAwD;AACxD,4DAA0C;AAC1C,gDAA8B"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./type.decorator"), exports);
18
+ //# sourceMappingURL=decorators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../src/decorators/decorators.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.type = void 0;
4
+ const metadata_1 = require("@pristine-ts/metadata");
5
+ const metadata_enum_1 = require("../enums/metadata.enum");
6
+ const type = (callback) => {
7
+ return (
8
+ /**
9
+ * The class on which the decorator is used.
10
+ */
11
+ target,
12
+ /**
13
+ * The property on which the decorator is used.
14
+ */
15
+ propertyKey) => {
16
+ metadata_1.PropertyMetadata.defineMetadata(target, propertyKey, metadata_enum_1.MetadataEnum.TypeFactory, callback);
17
+ };
18
+ };
19
+ exports.type = type;
20
+ //# sourceMappingURL=type.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/type.decorator.ts"],"names":[],"mappings":";;;AAAA,oDAAuD;AACvD,0DAAoD;AAI7C,MAAM,IAAI,GAAG,CAAC,QAA6B,EAAE,EAAE;IAClD,OAAO;IACH;;OAEG;IACH,MAAW;IAEX;;OAEG;IACH,WAA4B,EAC9B,EAAE;QACA,2BAAgB,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,4BAAY,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAC7F,CAAC,CAAA;AACL,CAAC,CAAA;AAdY,QAAA,IAAI,QAchB"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataMappingNodeTypeEnum = void 0;
4
+ var DataMappingNodeTypeEnum;
5
+ (function (DataMappingNodeTypeEnum) {
6
+ DataMappingNodeTypeEnum["ScalarArray"] = "DATA_MAPPING_NODE_SCALAR_ARRAY";
7
+ DataMappingNodeTypeEnum["ObjectArray"] = "DATA_MAPPING_NODE_OBJECT_ARRAY";
8
+ DataMappingNodeTypeEnum["Node"] = "DATA_MAPPING_NODE";
9
+ DataMappingNodeTypeEnum["Leaf"] = "DATA_MAPPING_LEAF";
10
+ })(DataMappingNodeTypeEnum || (exports.DataMappingNodeTypeEnum = DataMappingNodeTypeEnum = {}));
11
+ //# sourceMappingURL=data-mapping-node-type.enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-mapping-node-type.enum.js","sourceRoot":"","sources":["../../../../src/enums/data-mapping-node-type.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,uBAKX;AALD,WAAY,uBAAuB;IAC/B,yEAA8C,CAAA;IAC9C,yEAA8C,CAAA;IAC9C,qDAA0B,CAAA;IAC1B,qDAA0B,CAAA;AAC9B,CAAC,EALW,uBAAuB,uCAAvB,uBAAuB,QAKlC"}