@pristine-ts/data-mapping-common 2.0.8 → 2.0.9

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 (52) hide show
  1. package/dist/lib/cjs/builders/auto-data-mapping.builder.js +36 -1
  2. package/dist/lib/cjs/builders/auto-data-mapping.builder.js.map +1 -1
  3. package/dist/lib/cjs/builders/data-mapping.builder.js +7 -6
  4. package/dist/lib/cjs/builders/data-mapping.builder.js.map +1 -1
  5. package/dist/lib/cjs/errors/data-normalizer-not-found.error.js +15 -0
  6. package/dist/lib/cjs/errors/data-normalizer-not-found.error.js.map +1 -0
  7. package/dist/lib/cjs/errors/errors.js +3 -0
  8. package/dist/lib/cjs/errors/errors.js.map +1 -1
  9. package/dist/lib/cjs/errors/undefined-destination-property.error.js +14 -0
  10. package/dist/lib/cjs/errors/undefined-destination-property.error.js.map +1 -0
  11. package/dist/lib/cjs/mappers/data.mapper.js +3 -5
  12. package/dist/lib/cjs/mappers/data.mapper.js.map +1 -1
  13. package/dist/lib/cjs/nodes/base-data-mapping.node.js +4 -0
  14. package/dist/lib/cjs/nodes/base-data-mapping.node.js.map +1 -1
  15. package/dist/lib/cjs/nodes/data-mapping.leaf.js +36 -11
  16. package/dist/lib/cjs/nodes/data-mapping.leaf.js.map +1 -1
  17. package/dist/lib/cjs/nodes/data-mapping.node.js +119 -49
  18. package/dist/lib/cjs/nodes/data-mapping.node.js.map +1 -1
  19. package/dist/lib/cjs/options/auto-data-mapping-builder.options.js +2 -1
  20. package/dist/lib/cjs/options/auto-data-mapping-builder.options.js.map +1 -1
  21. package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  22. package/dist/lib/esm/builders/auto-data-mapping.builder.js +36 -1
  23. package/dist/lib/esm/builders/auto-data-mapping.builder.js.map +1 -1
  24. package/dist/lib/esm/builders/data-mapping.builder.js +7 -6
  25. package/dist/lib/esm/builders/data-mapping.builder.js.map +1 -1
  26. package/dist/lib/esm/errors/data-normalizer-not-found.error.js +11 -0
  27. package/dist/lib/esm/errors/data-normalizer-not-found.error.js.map +1 -0
  28. package/dist/lib/esm/errors/errors.js +3 -0
  29. package/dist/lib/esm/errors/errors.js.map +1 -1
  30. package/dist/lib/esm/errors/undefined-destination-property.error.js +10 -0
  31. package/dist/lib/esm/errors/undefined-destination-property.error.js.map +1 -0
  32. package/dist/lib/esm/mappers/data.mapper.js +3 -5
  33. package/dist/lib/esm/mappers/data.mapper.js.map +1 -1
  34. package/dist/lib/esm/nodes/base-data-mapping.node.js +4 -0
  35. package/dist/lib/esm/nodes/base-data-mapping.node.js.map +1 -1
  36. package/dist/lib/esm/nodes/data-mapping.leaf.js +36 -11
  37. package/dist/lib/esm/nodes/data-mapping.leaf.js.map +1 -1
  38. package/dist/lib/esm/nodes/data-mapping.node.js +119 -49
  39. package/dist/lib/esm/nodes/data-mapping.node.js.map +1 -1
  40. package/dist/lib/esm/options/auto-data-mapping-builder.options.js +2 -1
  41. package/dist/lib/esm/options/auto-data-mapping-builder.options.js.map +1 -1
  42. package/dist/lib/esm/tsconfig.tsbuildinfo +1 -1
  43. package/dist/types/builders/auto-data-mapping.builder.d.ts +16 -0
  44. package/dist/types/builders/data-mapping.builder.d.ts +3 -2
  45. package/dist/types/errors/data-normalizer-not-found.error.d.ts +8 -0
  46. package/dist/types/errors/errors.d.ts +3 -0
  47. package/dist/types/errors/undefined-destination-property.error.d.ts +8 -0
  48. package/dist/types/interfaces/data-mapping-interceptor.interface.d.ts +6 -2
  49. package/dist/types/nodes/data-mapping.leaf.d.ts +11 -0
  50. package/dist/types/nodes/data-mapping.node.d.ts +54 -2
  51. package/dist/types/options/auto-data-mapping-builder.options.d.ts +12 -0
  52. package/package.json +3 -3
@@ -13,6 +13,19 @@ const auto_data_mapping_builder_options_1 = require("../options/auto-data-mappin
13
13
  const metadata_enum_1 = require("../enums/metadata.enum");
14
14
  const boolean_normalizer_1 = require("../normalizers/boolean.normalizer");
15
15
  class AutoDataMappingBuilder {
16
+ constructor() {
17
+ /**
18
+ * Schema cache keyed by destination class. The auto-built schema is deterministic in `destinationType`
19
+ * + the *shape* of the source (which decoration metadata describes), so for a stable class definition
20
+ * the same builder can be reused across calls. We key only by destinationType to keep things simple;
21
+ * if the source shape varies and the auto-inference depends on it (e.g. inferring scalar-array member
22
+ * type from `source[propertyKey][0]`), callers needing fresh inference can bypass the cache via the
23
+ * `disableCache` option.
24
+ *
25
+ * Stored under a WeakMap so unused destination classes can be garbage-collected.
26
+ */
27
+ this.cache = new WeakMap();
28
+ }
16
29
  /**
17
30
  * This method receives a source object and a destinationType that corresponds to the type of the class
18
31
  * that the source should be mapped to. It then creates a DataMappingBuilder object that contains the schema
@@ -22,10 +35,32 @@ class AutoDataMappingBuilder {
22
35
  * @param options
23
36
  */
24
37
  build(source, destinationType, options) {
38
+ const resolvedOptions = new auto_data_mapping_builder_options_1.AutoDataMappingBuilderOptions(options);
39
+ if (resolvedOptions.disableCache !== true) {
40
+ const cached = this.cache.get(destinationType);
41
+ if (cached !== undefined) {
42
+ return cached;
43
+ }
44
+ }
25
45
  const dataMappingBuilder = new data_mapping_builder_1.DataMappingBuilder();
26
- this.internalBuild(source, destinationType, dataMappingBuilder, dataMappingBuilder, new auto_data_mapping_builder_options_1.AutoDataMappingBuilderOptions(options));
46
+ this.internalBuild(source, destinationType, dataMappingBuilder, dataMappingBuilder, resolvedOptions);
47
+ if (resolvedOptions.disableCache !== true) {
48
+ this.cache.set(destinationType, dataMappingBuilder);
49
+ }
27
50
  return dataMappingBuilder;
28
51
  }
52
+ /**
53
+ * Clear the cached schema for a destinationType (or the whole cache when no argument is passed).
54
+ * Useful in tests, or when class metadata changes at runtime (rare).
55
+ */
56
+ clearCache(destinationType) {
57
+ if (destinationType === undefined) {
58
+ // WeakMap has no .clear() — recreate.
59
+ this.cache = new WeakMap();
60
+ return;
61
+ }
62
+ this.cache.delete(destinationType);
63
+ }
29
64
  /**
30
65
  * This method is the internal method that is called recursively to build the schema.
31
66
  *
@@ -1 +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,oDAAoH;AACpH,kEAA2D;AAC3D,wEAA2E;AAC3E,wEAA2E;AAC3E,oEAAuE;AACvE,sFAA6E;AAC7E,oGAA2F;AAC3F,0DAAoD;AAEpD,0EAA6E;AAE7E,MAAa,sBAAsB;IACjC;;;;;;;OAOG;IACH,KAAK,CAAC,MAAW,EAAE,eAAsC,EAAE,OAAuC;QAChG,MAAM,kBAAkB,GAAG,IAAI,yCAAkB,EAAE,CAAC;QAEpD,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,IAAI,iEAA6B,CAAC,OAAO,CAAC,CAAC,CAAC;QAEhI,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED;;;;;;;;;OASG;IACK,aAAa,CAAC,MAAW,EAAE,eAAsC,EAAE,IAAwB,EAC7E,MAA4C,EAAE,OAAsC;QACxG,IAAI,CAAC,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;YAChC,OAAO;QACT,CAAC;QAED,IAAI,CAAC;YACH,uEAAuE;YACvE,MAAM,gBAAgB,GAAG,wBAAa,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;YAEvE,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;;gBAChD,yCAAyC;gBACzC,MAAM,mBAAmB,GAAG,2BAAgB,CAAC,cAAc,CAAC,eAAe,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;gBAEpG,IAAI,UAAU,GAAG,mBAAmB,CAAC,UAAU,CAAC;gBAEhD,sGAAsG;gBACtG,+FAA+F;gBAC/F,MAAM,mBAAmB,GAAwB,2BAAgB,CAAC,WAAW,CAAC,eAAe,CAAC,SAAS,EAAE,WAAW,EAAE,4BAAY,CAAC,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BAC9B,sBAAsB,CAAC,WAAW,CAAC;qBACnC,aAAa,CAAC,MAAA,mBAAmB,CAAC,UAAU,mCAAI,OAAO,CAAC,sBAAsB,CAAC;qBAC/E,GAAG,EAAE,CAAC;YACX,CAAC,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,EAAE,CAAC;gBACvB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACnB,CAAC;YAED,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,EAAE,CAAC;gBAC3B,MAAM,CAAC,CAAC;YACV,CAAC;QACH,CAAC;IACH,CAAC;CACF;AArKD,wDAqKC"}
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,oDAAoH;AACpH,kEAA2D;AAC3D,wEAA2E;AAC3E,wEAA2E;AAC3E,oEAAuE;AACvE,sFAA6E;AAC7E,oGAA2F;AAC3F,0DAAoD;AAEpD,0EAA6E;AAE7E,MAAa,sBAAsB;IAAnC;QACE;;;;;;;;;WASG;QACc,UAAK,GAAuD,IAAI,OAAO,EAAE,CAAC;IAiM7F,CAAC;IA/LC;;;;;;;OAOG;IACH,KAAK,CAAC,MAAW,EAAE,eAAsC,EAAE,OAAuC;QAChG,MAAM,eAAe,GAAG,IAAI,iEAA6B,CAAC,OAAO,CAAC,CAAC;QAEnE,IAAI,eAAe,CAAC,YAAY,KAAK,IAAI,EAAE,CAAC;YAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;YAC/C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;QAED,MAAM,kBAAkB,GAAG,IA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,aAAa,CAAC,MAAA,mBAAmB,CAAC,UAAU,mCAAI,OAAO,CAAC,sBAAsB,CAAC;qBAC/E,GAAG,EAAE,CAAC;YACX,CAAC,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,EAAE,CAAC;gBACvB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACnB,CAAC;YAED,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,EAAE,CAAC;gBAC3B,MAAM,CAAC,CAAC;YACV,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA5MD,wDA4MC"}
@@ -156,18 +156,19 @@ class DataMappingBuilder extends base_data_mapping_node_1.BaseDataMappingNode {
156
156
  }
157
157
  }
158
158
  /**
159
- * This method exports this node.
159
+ * This method exports the schema as a plain object. The export does not mutate the live tree —
160
+ * the builder remains usable for mapping after this call returns.
160
161
  */
161
162
  export() {
162
- const nodes = this.nodes;
163
- for (const key in nodes) {
164
- if (nodes.hasOwnProperty(key) === false) {
163
+ const exportedNodes = {};
164
+ for (const key in this.nodes) {
165
+ if (this.nodes.hasOwnProperty(key) === false) {
165
166
  continue;
166
167
  }
167
- nodes[key] = nodes[key].export();
168
+ exportedNodes[key] = this.nodes[key].export();
168
169
  }
169
170
  return {
170
- "nodes": nodes,
171
+ "nodes": exportedNodes,
171
172
  "normalizers": this.normalizers,
172
173
  "beforeMappingInterceptors": this.beforeMappingInterceptors,
173
174
  "afterMappingInterceptors": this.afterMappingInterceptors,
@@ -1 +1 @@
1
- {"version":3,"file":"data-mapping.builder.js","sourceRoot":"","sources":["../../../../src/builders/data-mapping.builder.ts"],"names":[],"mappings":";;;AAAA,kEAA2D;AAE3D,uGAAyF;AAEzF,uIAA4H;AAC5H,qIAA0H;AAC1H,kEAA2D;AAC3D,4EAAoE;AACpE,sFAA6E;AAE7E,MAAa,kBAAmB,SAAQ,4CA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AAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;oBACvC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,MAAM;QACX,MAAM,aAAa,GAA2B,EAAE,CAAC;QAEjD,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC7B,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE,CAAC;gBAC7C,SAAS;YACX,CAAC;YAED,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;QAChD,CAAC;QAED,OAAO;YACL,OAAO,EAAE,aAAa;YACtB,aAAa,EAAE,IAAI,CAAC,WAAW;YAC/B,2BAA2B,EAAE,IAAI,CAAC,yBAAyB;YAC3D,0BAA0B,EAAE,IAAI,CAAC,wBAAwB;SAC1D,CAAA;IACH,CAAC;CACF;AA9LD,gDA8LC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataNormalizerNotFoundError = void 0;
4
+ /**
5
+ * Thrown when a leaf references a normalizer key that hasn't been registered with the DataMapper.
6
+ */
7
+ class DataNormalizerNotFoundError extends Error {
8
+ constructor(message, normalizerUniqueKey) {
9
+ super(message);
10
+ this.normalizerUniqueKey = normalizerUniqueKey;
11
+ Object.setPrototypeOf(this, DataNormalizerNotFoundError.prototype);
12
+ }
13
+ }
14
+ exports.DataNormalizerNotFoundError = DataNormalizerNotFoundError;
15
+ //# sourceMappingURL=data-normalizer-not-found.error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-normalizer-not-found.error.js","sourceRoot":"","sources":["../../../../src/errors/data-normalizer-not-found.error.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,2BAA4B,SAAQ,KAAK;IACpD,YAAmB,OAAe,EAAkB,mBAA4C;QAC9F,KAAK,CAAC,OAAO,CAAC,CAAC;QADmC,wBAAmB,GAAnB,mBAAmB,CAAyB;QAG9F,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,2BAA2B,CAAC,SAAS,CAAC,CAAC;IACrE,CAAC;CACF;AAND,kEAMC"}
@@ -15,11 +15,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./array-data-mapping-node-invalid-source-property-type.error"), exports);
18
+ __exportStar(require("./auto-map-primitive-type-normalizer-not-found.error"), exports);
18
19
  __exportStar(require("./data-after-mapping-interceptor-already-added.error"), exports);
19
20
  __exportStar(require("./data-before-mapping-interceptor-already-added.error"), exports);
20
21
  __exportStar(require("./data-normalizer-already-added.error"), exports);
22
+ __exportStar(require("./data-normalizer-not-found.error"), exports);
21
23
  __exportStar(require("./data-mapping-interceptor-not-found.error"), exports);
22
24
  __exportStar(require("./data-mapping-source-property-not-found.error"), exports);
23
25
  __exportStar(require("./normalizer-invalid-source-type.error"), exports);
26
+ __exportStar(require("./undefined-destination-property.error"), exports);
24
27
  __exportStar(require("./undefined-source-property.error"), exports);
25
28
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/errors/errors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+FAA6E;AAC7E,uFAAqE;AACrE,wFAAsE;AACtE,wEAAsD;AACtD,6EAA2D;AAC3D,iFAA+D;AAC/D,yEAAuD;AACvD,oEAAkD"}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/errors/errors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+FAA6E;AAC7E,uFAAqE;AACrE,uFAAqE;AACrE,wFAAsE;AACtE,wEAAsD;AACtD,oEAAkD;AAClD,6EAA2D;AAC3D,iFAA+D;AAC/D,yEAAuD;AACvD,yEAAuD;AACvD,oEAAkD"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UndefinedDestinationPropertyError = void 0;
4
+ /**
5
+ * Thrown when a Node is being committed to its parent without a `destinationProperty` set.
6
+ */
7
+ class UndefinedDestinationPropertyError extends Error {
8
+ constructor(node) {
9
+ super("The `destinationProperty` property of the Node cannot be undefined to be added as a Node to its parent. Source property: '" + node.sourceProperty + "'.");
10
+ Object.setPrototypeOf(this, UndefinedDestinationPropertyError.prototype);
11
+ }
12
+ }
13
+ exports.UndefinedDestinationPropertyError = UndefinedDestinationPropertyError;
14
+ //# sourceMappingURL=undefined-destination-property.error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"undefined-destination-property.error.js","sourceRoot":"","sources":["../../../../src/errors/undefined-destination-property.error.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH,MAAa,iCAAkC,SAAQ,KAAK;IAE1D,YAAmB,IAAuC;QACxD,KAAK,CAAC,4HAA4H,GAAG,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;QAEjK,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,iCAAiC,CAAC,SAAS,CAAC,CAAC;IAC3E,CAAC;CACF;AAPD,8EAOC"}
@@ -147,8 +147,7 @@ class DataMapper {
147
147
  if (interceptor === undefined) {
148
148
  throw new data_mapping_interceptor_not_found_error_1.DataMappingInterceptorNotFoundError("The interceptor wasn't found and cannot be loaded.", element.key);
149
149
  }
150
- // todo: Pass the options when we start using them.
151
- interceptedSource = yield interceptor.beforeMapping(interceptedSource);
150
+ interceptedSource = yield interceptor.beforeMapping(interceptedSource, element.options);
152
151
  }
153
152
  // Loop over the properties defined in the builder
154
153
  for (const key in builder.nodes) {
@@ -158,14 +157,13 @@ class DataMapper {
158
157
  const node = builder.nodes[key];
159
158
  yield node.map(interceptedSource, destination, this.dataNormalizersMap, options);
160
159
  }
161
- // Execute the before interceptors.
160
+ // Execute the after interceptors.
162
161
  for (const element of builder.afterMappingInterceptors) {
163
162
  const interceptor = this.dataTransformerInterceptorsMap[element.key];
164
163
  if (interceptor === undefined) {
165
164
  throw new data_mapping_interceptor_not_found_error_1.DataMappingInterceptorNotFoundError("The interceptor wasn't found and cannot be loaded.", element.key);
166
165
  }
167
- // todo pass the options when we start using it.
168
- destination = yield interceptor.afterMapping(destination);
166
+ destination = yield interceptor.afterMapping(destination, element.options);
169
167
  }
170
168
  if (destinationType) {
171
169
  destination = (0, class_transformer_1.plainToInstance)(destinationType, destination);
@@ -1 +1 @@
1
- {"version":3,"file":"data.mapper.js","sourceRoot":"","sources":["../../../../src/mappers/data.mapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAIA,2EAAoE;AACpE,yDAAoE;AACpE,iHAAuG;AAEvG,oGAA2F;AAC3F,wEAAiE;AACjE,sEAA2D;AAC3D,gDAAqD;AACrD,wEAA2E;AAC3E,qIAAyH;AACzH,wEAA2E;AAC3E,0EAA6E;AAC7E,oEAAuE;AAEvE,MAAa,UAAU;IAIrB,YACmB,sBAA8C,EAC9C,eAAoD,EACpD,2BAA8D;QAF9D,2BAAsB,GAAtB,sBAAsB,CAAwB;QAC9C,oBAAe,GAAf,eAAe,CAAqC;QACpD,gCAA2B,GAA3B,2BAA2B,CAAmC;QANhE,uBAAkB,GAA4E,EAAE,CAAA;QAChG,mCAA8B,GAAsF,EAAE,CAAA;QAMrI,eAAe,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE;YACvC,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC,GAAG,cAAc,CAAC;QAC1E,CAAC,CAAC,CAAA;QAEF,2BAA2B,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;YAChD,IAAI,CAAC,8BAA8B,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,GAAG,WAAW,CAAC;QAChF,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IAEU,MAAM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CA+DxI;AAYY;IADZ,IAAA,eAAM,GAAE;;qCACiB,yCAAkB,kBAAkE,uCAAiB;;qCAkD9H"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseDataMappingNode = void 0;
4
4
  const undefined_source_property_error_1 = require("../errors/undefined-source-property.error");
5
+ const undefined_destination_property_error_1 = require("../errors/undefined-destination-property.error");
5
6
  class BaseDataMappingNode {
6
7
  constructor() {
7
8
  this.nodes = {};
@@ -17,6 +18,9 @@ class BaseDataMappingNode {
17
18
  if (node.sourceProperty === undefined) {
18
19
  throw new undefined_source_property_error_1.UndefinedSourcePropertyError(node);
19
20
  }
21
+ if (node.destinationProperty === undefined) {
22
+ throw new undefined_destination_property_error_1.UndefinedDestinationPropertyError(node);
23
+ }
20
24
  this.nodes[node.sourceProperty] = node;
21
25
  }
22
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"base-data-mapping.node.js","sourceRoot":"","sources":["../../../../src/nodes/base-data-mapping.node.ts"],"names":[],"mappings":";;;AAEA,+FAAuF;AAEvF,MAAsB,mBAAmB;IAAzC;QACS,UAAK,GAAsE,EAAE,CAAC;IAkBvF,CAAC;IAhBC;;;;;;OAMG;IACI,OAAO,CAAC,IAAuC;QACpD,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;YACtC,MAAM,IAAI,8DAA4B,CAAC,IAAI,CAAC,CAAC;QAC/C,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IACzC,CAAC;CAGF;AAnBD,kDAmBC"}
1
+ {"version":3,"file":"base-data-mapping.node.js","sourceRoot":"","sources":["../../../../src/nodes/base-data-mapping.node.ts"],"names":[],"mappings":";;;AAEA,+FAAuF;AACvF,yGAAiG;AAEjG,MAAsB,mBAAmB;IAAzC;QACS,UAAK,GAAsE,EAAE,CAAC;IAsBvF,CAAC;IApBC;;;;;;OAMG;IACI,OAAO,CAAC,IAAuC;QACpD,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;YACtC,MAAM,IAAI,8DAA4B,CAAC,IAAI,CAAC,CAAC;QAC/C,CAAC;QAED,IAAI,IAAI,CAAC,mBAAmB,KAAK,SAAS,EAAE,CAAC;YAC3C,MAAM,IAAI,wEAAiC,CAAC,IAAI,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IACzC,CAAC;CAGF;AAvBD,kDAuBC"}
@@ -14,6 +14,7 @@ const data_mapping_node_type_enum_1 = require("../enums/data-mapping-node-type.e
14
14
  const data_normalizer_already_added_error_1 = require("../errors/data-normalizer-already-added.error");
15
15
  const data_mapping_source_property_not_found_error_1 = require("../errors/data-mapping-source-property-not-found.error");
16
16
  const array_data_mapping_node_invalid_source_property_type_error_1 = require("../errors/array-data-mapping-node-invalid-source-property-type.error");
17
+ const data_normalizer_not_found_error_1 = require("../errors/data-normalizer-not-found.error");
17
18
  class DataMappingLeaf {
18
19
  constructor(root, parent, type = data_mapping_node_type_enum_1.DataMappingNodeTypeEnum.Leaf) {
19
20
  this.root = root;
@@ -74,6 +75,7 @@ class DataMappingLeaf {
74
75
  key: normalizerUniqueKey,
75
76
  options,
76
77
  });
78
+ this.effectiveNormalizersCache = undefined;
77
79
  return this;
78
80
  }
79
81
  /**
@@ -92,8 +94,23 @@ class DataMappingLeaf {
92
94
  throw new data_normalizer_already_added_error_1.DataNormalizerAlreadyAdded("The EXCLUDED data normalizer '" + normalizerUniqueKey + "' has already been added to this source property: '" + this.sourceProperty + "'.", normalizerUniqueKey);
93
95
  }
94
96
  this.excludedNormalizers.add(normalizerUniqueKey);
97
+ this.effectiveNormalizersCache = undefined;
95
98
  return this;
96
99
  }
100
+ /**
101
+ * Returns the merged list of normalizers applied to this leaf: inherited root normalizers minus the
102
+ * ones explicitly excluded here, followed by leaf-local normalizers. Memoized — the cache is cleared
103
+ * by `addNormalizer`/`excludeNormalizer`.
104
+ */
105
+ getEffectiveNormalizers() {
106
+ if (this.effectiveNormalizersCache === undefined) {
107
+ this.effectiveNormalizersCache = [
108
+ ...this.root.normalizers.filter(element => this.excludedNormalizers.has(element.key) === false),
109
+ ...this.normalizers,
110
+ ];
111
+ }
112
+ return this.effectiveNormalizersCache;
113
+ }
97
114
  /**
98
115
  * This method adds this node to its parent and returns the parent.
99
116
  */
@@ -118,8 +135,7 @@ class DataMappingLeaf {
118
135
  }
119
136
  throw new data_mapping_source_property_not_found_error_1.DataMappingSourcePropertyNotFoundError("The property '" + this.sourceProperty + "' isn't found in the Source object and isn't marked as Optional. If you want to ignore this property, use the 'setIsOptional(true)' method in the builder.", this.sourceProperty);
120
137
  }
121
- const normalizers = this.root.normalizers.filter(element => this.excludedNormalizers.has(element.key) === false);
122
- normalizers.push(...this.normalizers);
138
+ const normalizers = this.getEffectiveNormalizers();
123
139
  if (this.type === data_mapping_node_type_enum_1.DataMappingNodeTypeEnum.ScalarArray) {
124
140
  // This means that the source[propertyKey] contains an array of objects and each object should be mapped
125
141
  const array = source[this.sourceProperty];
@@ -128,20 +144,25 @@ class DataMappingLeaf {
128
144
  }
129
145
  destination[this.destinationProperty] = [];
130
146
  for (let value of array) {
131
- normalizers.forEach(element => {
147
+ for (const element of normalizers) {
132
148
  const normalizer = normalizersMap[element.key];
133
- if (normalizer)
134
- value = normalizer.normalize(value, element.options);
135
- });
149
+ if (normalizer === undefined) {
150
+ throw new data_normalizer_not_found_error_1.DataNormalizerNotFoundError("The normalizer '" + element.key + "' wasn't found and cannot be loaded for source property '" + this.sourceProperty + "'.", element.key);
151
+ }
152
+ value = normalizer.normalize(value, element.options);
153
+ }
136
154
  destination[this.destinationProperty].push(value);
137
155
  }
138
156
  return;
139
157
  }
140
158
  let value = source[this.sourceProperty];
141
- normalizers.forEach(element => {
159
+ for (const element of normalizers) {
142
160
  const normalizer = normalizersMap[element.key];
161
+ if (normalizer === undefined) {
162
+ throw new data_normalizer_not_found_error_1.DataNormalizerNotFoundError("The normalizer '" + element.key + "' wasn't found and cannot be loaded for source property '" + this.sourceProperty + "'.", element.key);
163
+ }
143
164
  value = normalizer.normalize(value, element.options);
144
- });
165
+ }
145
166
  destination[this.destinationProperty] = value;
146
167
  return;
147
168
  });
@@ -152,16 +173,20 @@ class DataMappingLeaf {
152
173
  * @param schema
153
174
  */
154
175
  import(schema) {
155
- this.normalizers = schema.normalizers;
176
+ this.normalizers = Array.isArray(schema.normalizers) ? schema.normalizers : [];
156
177
  this.excludedNormalizers = new Set();
157
- if (schema.hasOwnProperty("excludedNormalizers")) {
178
+ if (schema.hasOwnProperty("excludedNormalizers") && schema.excludedNormalizers) {
158
179
  for (const item in schema.excludedNormalizers) {
159
- this.excludeNormalizer(item);
180
+ if (schema.excludedNormalizers.hasOwnProperty(item) === false) {
181
+ continue;
182
+ }
183
+ this.excludedNormalizers.add(item);
160
184
  }
161
185
  }
162
186
  this.isOptional = schema.isOptional;
163
187
  this.sourceProperty = schema.sourceProperty;
164
188
  this.destinationProperty = schema.destinationProperty;
189
+ this.effectiveNormalizersCache = undefined;
165
190
  }
166
191
  /**
167
192
  * This method exports this node.
@@ -1 +1 @@
1
- {"version":3,"file":"data-mapping.leaf.js","sourceRoot":"","sources":["../../../../src/nodes/data-mapping.leaf.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sFAA6E;AAE7E,uGAAyF;AAGzF,yHAA8G;AAE9G,qJAAwI;AAIxI,MAAa,eAAe;IA0B1B,YACmB,IAAwB,EACzB,MAA4C,EAC5C,OAAgC,qDAAuB,CAAC,IAAI;QAF3D,SAAI,GAAJ,IAAI,CAAoB;QACzB,WAAM,GAAN,MAAM,CAAsC;QAC5C,SAAI,GAAJ,IAAI,CAAwD;QAlB9E;;WAEG;QACI,gBAAW,GAAqD,EAAE,CAAC;QAE1E;;WAEG;QACI,wBAAmB,GAAiC,IAAI,GAAG,EAA2B,CAAC;QAE9F;;WAEG;QACI,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IAAI,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;QAED,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;QAC5C,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC,mBAAmB,CAAC;QACtD,IAAI,CAAC,yBAAyB,GAAG,SAAS,CAAC;IAC7C,CAAC;IAED;;OAEG;IACI,MAAM;QACX,MAAM,mBAAmB,GAAQ,EAAE,CAAA;QAEnC,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,EAAE,CAAC;YACxD,mBAAmB,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;QACtC,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,IAAI;YAClB,gBAAgB,EAAE,IAAI,CAAC,cAAc;YACrC,qBAAqB,EAAE,IAAI,CAAC,mBAAmB;YAC/C,YAAY,EAAE,IAAI,CAAC,UAAU;YAC7B,aAAa,EAAE,IAAI,CAAC,WAAW;YAC/B,qBAAqB,EAAE,mBAAmB;SAC3C,CAAA;IACH,CAAC;CACF;AAlPD,0CAkPC"}
@@ -117,61 +117,125 @@ class DataMappingNode extends base_data_mapping_node_1.BaseDataMappingNode {
117
117
  if (sourceElement === undefined) {
118
118
  return;
119
119
  }
120
+ // Whether source-keyed properties should be carried through to the destination.
121
+ // When `excludeExtraneousValues === true`, only renamed destination keys (written by
122
+ // sub-nodes below) end up on the destination — source keys are dropped.
123
+ const includeSourceKeys = (options === null || options === void 0 ? void 0 : options.excludeExtraneousValues) === false;
120
124
  if (this.type === data_mapping_node_type_enum_1.DataMappingNodeTypeEnum.ObjectArray) {
125
+ // Array case: handled below in its own loop. Just pre-allocate the array here.
121
126
  destination[this.destinationProperty] = [];
122
127
  }
123
128
  else {
124
- if (this.destinationType) {
125
- destination[this.destinationProperty] = (0, class_transformer_1.plainToInstance)(this.destinationType, sourceElement);
126
- }
127
- else {
128
- destination[this.destinationProperty] = {};
129
- }
130
- if ((options === null || options === void 0 ? void 0 : options.excludeExtraneousValues) === false) {
131
- if (typeof sourceElement === "object" || Array.isArray(sourceElement)) {
132
- Object.keys(sourceElement).forEach(property => {
133
- destination[this.destinationProperty][property] = sourceElement[property];
134
- });
135
- }
136
- }
129
+ // Single-object case: build the destination value once, then let sub-nodes overlay
130
+ // renamed keys onto it.
131
+ destination[this.destinationProperty] = this.buildDestinationObject(sourceElement, includeSourceKeys);
137
132
  }
138
133
  const destinationElement = destination[this.destinationProperty];
139
134
  if (this.type === data_mapping_node_type_enum_1.DataMappingNodeTypeEnum.ObjectArray) {
140
- // This means that the source[propertyKey] contains an array of objects and each object should be mapped
141
- const array = source[this.sourceProperty];
142
- if (Array.isArray(array) === false) {
143
- throw new array_data_mapping_node_invalid_source_property_type_error_1.ArrayDataMappingNodeInvalidSourcePropertyTypeError(`According to your schema, the property '${this.sourceProperty}' in the source object must contain an Array of objects. Instead, it contains: '${typeof array}'.`, this.sourceProperty);
135
+ const sourceArray = source[this.sourceProperty];
136
+ if (Array.isArray(sourceArray) === false) {
137
+ throw new array_data_mapping_node_invalid_source_property_type_error_1.ArrayDataMappingNodeInvalidSourcePropertyTypeError(`According to your schema, the property '${this.sourceProperty}' in the source object must contain an Array of objects. Instead, it contains: '${typeof sourceArray}'.`, this.sourceProperty);
144
138
  }
145
- let index = 0;
146
- for (const element of array) {
147
- let dest = {};
148
- if (this.destinationType) {
149
- if (typeof this.destinationType === "function" && !this.destinationType.prototype) {
150
- const destinationType = this.destinationType;
151
- dest = (0, class_transformer_1.plainToInstance)(destinationType(source, this.sourceProperty, index).constructor, (options === null || options === void 0 ? void 0 : options.excludeExtraneousValues) === false ? element : {});
152
- }
153
- else if (this.destinationType.prototype) {
154
- dest = (0, class_transformer_1.plainToInstance)(this.destinationType, {});
155
- }
156
- }
157
- if ((options === null || options === void 0 ? void 0 : options.excludeExtraneousValues) === false) {
158
- Object.keys(element).forEach(property => {
159
- dest[property] = element[property];
160
- });
161
- }
162
- for (const key in this.nodes) {
163
- if (this.nodes.hasOwnProperty(key) === false) {
164
- continue;
165
- }
166
- const node = this.nodes[key];
167
- yield node.map(element, dest, normalizersMap, options);
168
- }
139
+ // For each source element: build the destination object (whose concrete class may
140
+ // depend on the element index when `destinationType` is a factory callback), let the
141
+ // sub-nodes overlay their renamed keys, then push.
142
+ for (let index = 0; index < sourceArray.length; index++) {
143
+ const element = sourceArray[index];
144
+ const dest = this.buildArrayMemberDestination(source, element, index, includeSourceKeys);
145
+ yield this.runSubNodes(element, dest, normalizersMap, options);
169
146
  destinationElement.push(dest);
170
147
  }
171
- index++;
172
148
  return;
173
149
  }
174
- // When the current node is not an array, we simply iterate
150
+ // Single-object case: sub-nodes write into the destination we just built above.
151
+ yield this.runSubNodes(sourceElement, destinationElement, normalizersMap, options);
152
+ });
153
+ }
154
+ /**
155
+ * Build the destination object for the single-object case.
156
+ *
157
+ * If a `destinationType` (class constructor) is set, instantiate the class. Otherwise return
158
+ * a plain object. When `includeSourceKeys` is true, the source's own enumerable properties are
159
+ * seeded onto the result so they survive the mapping; sub-nodes then overlay renamed keys on top.
160
+ *
161
+ * Note: the single-object case treats `destinationType` strictly as a class constructor.
162
+ * Factory callbacks only make sense for the per-element ObjectArray case below.
163
+ */
164
+ buildDestinationObject(sourceElement, includeSourceKeys) {
165
+ const seedFromSource = includeSourceKeys
166
+ && sourceElement !== null
167
+ && (typeof sourceElement === "object" || Array.isArray(sourceElement));
168
+ if (this.destinationType !== undefined) {
169
+ return (0, class_transformer_1.plainToInstance)(this.destinationType, seedFromSource ? sourceElement : {});
170
+ }
171
+ const result = {};
172
+ if (seedFromSource) {
173
+ Object.keys(sourceElement).forEach(property => {
174
+ result[property] = sourceElement[property];
175
+ });
176
+ }
177
+ return result;
178
+ }
179
+ /**
180
+ * Build the destination object for a single element of an ObjectArray. Mirrors
181
+ * `buildDestinationObject`, with two extra wrinkles unique to arrays:
182
+ *
183
+ * 1. `destinationType` can be a *factory callback* instead of a fixed class. The callback
184
+ * receives the source array's parent + the element's index and returns an instance of
185
+ * the concrete class to use. This is how polymorphic arrays work (e.g. some elements
186
+ * become `Cat`, others `Dog`).
187
+ * 2. The seed value is the per-element object, not the whole array.
188
+ */
189
+ buildArrayMemberDestination(source, element, index, includeSourceKeys) {
190
+ const seedFromSource = includeSourceKeys && element !== null && typeof element === "object";
191
+ if (this.destinationType === undefined) {
192
+ // Untyped array — produce a plain object, optionally seeded with the element's own keys.
193
+ const result = {};
194
+ if (seedFromSource) {
195
+ Object.keys(element).forEach(property => {
196
+ result[property] = element[property];
197
+ });
198
+ }
199
+ return result;
200
+ }
201
+ const memberConstructor = this.resolveArrayMemberConstructor(source, index);
202
+ return (0, class_transformer_1.plainToInstance)(memberConstructor, seedFromSource ? element : {});
203
+ }
204
+ /**
205
+ * Resolve the concrete class constructor for a single element of an ObjectArray.
206
+ *
207
+ * `destinationType` here is one of two things:
208
+ *
209
+ * - a **class constructor** (uniform array — every element maps to the same class), or
210
+ * - a **factory callback** of shape `(source, sourceProperty, index) => instance`
211
+ * (polymorphic array — class is chosen per element).
212
+ *
213
+ * JavaScript gives us no clean way to distinguish a class constructor from a callback —
214
+ * both are `typeof === "function"`. The conventional discriminant: a class constructor has
215
+ * a `.prototype` object (where its instance methods live); an arrow function does not.
216
+ *
217
+ * Caveat: a regular `function() { ... }` expression used as a callback would also have a
218
+ * `.prototype` and would be mis-classified as a class. The public type only documents the
219
+ * arrow-function form (`ArrayMemberTypeFactoryCallbackType = (...) => any`), and in practice
220
+ * callers use arrow functions, so this is safe for documented usage.
221
+ */
222
+ resolveArrayMemberConstructor(source, index) {
223
+ const destinationType = this.destinationType;
224
+ const isFactoryCallback = typeof destinationType === "function"
225
+ && destinationType.prototype === undefined;
226
+ if (isFactoryCallback) {
227
+ const factory = destinationType;
228
+ const sampleInstance = factory(source, this.sourceProperty, index);
229
+ return sampleInstance.constructor;
230
+ }
231
+ return destinationType;
232
+ }
233
+ /**
234
+ * Run every direct child node against `(sourceElement, destinationElement)`. Each child
235
+ * writes its mapped destination property onto `destinationElement`.
236
+ */
237
+ runSubNodes(sourceElement, destinationElement, normalizersMap, options) {
238
+ return __awaiter(this, void 0, void 0, function* () {
175
239
  for (const key in this.nodes) {
176
240
  if (this.nodes.hasOwnProperty(key) === false) {
177
241
  continue;
@@ -215,22 +279,28 @@ class DataMappingNode extends base_data_mapping_node_1.BaseDataMappingNode {
215
279
  }
216
280
  }
217
281
  /**
218
- * This method exports this node.
282
+ * This method exports this node. The exported representation is a plain object — it does not mutate
283
+ * the live tree, so the same builder can continue to be used for mapping after `export()` is called.
284
+ *
285
+ * `destinationType` is intentionally not serialized: class constructors aren't transferable, and
286
+ * factory callbacks (`ArrayMemberTypeFactoryCallbackType`) hold closures. To rehydrate a schema with
287
+ * the same destination instantiation behavior, decorate the destination class with class-transformer's
288
+ * `@Type()` and pass the destination class to `DataMapper.map()`.
219
289
  */
220
290
  export() {
221
- const nodes = this.nodes;
222
- for (const key in nodes) {
223
- if (nodes.hasOwnProperty(key) === false) {
291
+ const exportedNodes = {};
292
+ for (const key in this.nodes) {
293
+ if (this.nodes.hasOwnProperty(key) === false) {
224
294
  continue;
225
295
  }
226
- nodes[key] = nodes[key].export();
296
+ exportedNodes[key] = this.nodes[key].export();
227
297
  }
228
298
  return {
229
299
  "_type": this.type,
230
300
  "sourceProperty": this.sourceProperty,
231
301
  "destinationProperty": this.destinationProperty,
232
302
  "isOptional": this.isOptional,
233
- "nodes": nodes,
303
+ "nodes": exportedNodes,
234
304
  };
235
305
  }
236
306
  }