@pristine-ts/data-mapping 2.0.9 → 2.0.11

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.
@@ -15,29 +15,22 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.DataMappingModule = void 0;
18
- const common_1 = require("@pristine-ts/common");
19
18
  const data_mapping_module_keyname_1 = require("./data-mapping.module.keyname");
20
19
  const data_mapping_common_1 = require("@pristine-ts/data-mapping-common");
21
- __exportStar(require("./interceptors/interceptors"), exports);
22
20
  // To facilitate things, this module should re-export everything. Therefore, no one else needs to know that we have two
23
21
  // modules unless you specifically just want the raw classes (like in the frontend).
24
22
  __exportStar(require("@pristine-ts/data-mapping-common"), exports);
25
- const normalizers = [
23
+ // The built-in normalizers don't carry the `@tag` decorator themselves (they live in
24
+ // data-mapping-common, which we want to keep frontend-friendly and decorator-light). They
25
+ // are aliased here under the "DataNormalizerInterface" tag via providerRegistrations so the
26
+ // registration is tied to module initialization rather than to module-file import order.
27
+ const builtInNormalizers = [
26
28
  data_mapping_common_1.StringNormalizer,
27
29
  data_mapping_common_1.NumberNormalizer,
28
30
  data_mapping_common_1.DateNormalizer,
29
31
  data_mapping_common_1.BooleanNormalizer,
30
32
  data_mapping_common_1.LowercaseNormalizer,
31
33
  ];
32
- normalizers.forEach((normalizer) => {
33
- common_1.taggedProviderRegistrationsRegistry.push({
34
- constructor: normalizer,
35
- providerRegistration: {
36
- token: "DataNormalizerInterface",
37
- useToken: normalizer,
38
- },
39
- });
40
- });
41
34
  exports.DataMappingModule = {
42
35
  keyname: data_mapping_module_keyname_1.DataMappingModuleKeyname,
43
36
  importModules: [],
@@ -46,6 +39,10 @@ exports.DataMappingModule = {
46
39
  token: data_mapping_common_1.AutoDataMappingBuilder,
47
40
  useClass: data_mapping_common_1.AutoDataMappingBuilder,
48
41
  },
42
+ ...builtInNormalizers.map(normalizer => ({
43
+ token: "DataNormalizerInterface",
44
+ useToken: normalizer,
45
+ })),
49
46
  {
50
47
  token: data_mapping_common_1.DataMapper,
51
48
  // ── container.resolve / container.resolveAll, justified ───────────────────
@@ -54,7 +51,18 @@ exports.DataMappingModule = {
54
51
  // the DataMapper's dependencies through it is how DI factories work in
55
52
  // tsyringe. There's no class to constructor-inject into.
56
53
  useFactory: (container) => {
57
- return new data_mapping_common_1.DataMapper(container.resolve(data_mapping_common_1.AutoDataMappingBuilder), container.resolveAll("DataNormalizerInterface"), container.resolveAll("DataMappingInterceptorInterface"));
54
+ // Interceptors are optional. Use `isRegistered` rather than relying on a
55
+ // placeholder no-op interceptor: tsyringe's `resolveAll` throws when no
56
+ // providers are registered, so we guard the call ourselves.
57
+ const interceptors = container.isRegistered("DataMappingInterceptorInterface", true)
58
+ ? container.resolveAll("DataMappingInterceptorInterface")
59
+ : [];
60
+ // Adapter: data-mapping-common takes a plain callback so it can be used in
61
+ // frontend bundles without pulling @pristine-ts/logging. Here on the backend we
62
+ // bridge that callback to the framework's standard LogHandlerInterface so reports
63
+ // flow through LogStore / Sentry / whatever the project has configured.
64
+ const logHandler = container.resolve("LogHandlerInterface");
65
+ return new data_mapping_common_1.DataMapper(container.resolve(data_mapping_common_1.AutoDataMappingBuilder), container.resolveAll("DataNormalizerInterface"), interceptors, (error, context) => logHandler.error("DataMapper.autoMap caught an error.", Object.assign({ error }, context)));
58
66
  }
59
67
  },
60
68
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"data-mapping.module.js","sourceRoot":"","sources":["../../../src/data-mapping.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,gDAAyF;AACzF,+EAAuE;AACvE,0EAQyC;AAGzC,8DAA4C;AAE5C,uHAAuH;AACvH,oFAAoF;AACpF,mEAAiD;AAEjD,MAAM,WAAW,GAAG;IAClB,sCAAgB;IAChB,sCAAgB;IAChB,oCAAc;IACd,uCAAiB;IACjB,yCAAmB;CACpB,CAAA;AAED,WAAW,CAAC,OAAO,CAAC,CAAC,UAAe,EAAE,EAAE;IACtC,4CAAmC,CAAC,IAAI,CAAC;QACvC,WAAW,EAAE,UAAU;QACvB,oBAAoB,EAAE;YACpB,KAAK,EAAE,yBAAyB;YAChC,QAAQ,EAAE,UAAU;SACrB;KACF,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEW,QAAA,iBAAiB,GAAoB;IAChD,OAAO,EAAE,sDAAwB;IACjC,aAAa,EAAE,EAAE;IACjB,qBAAqB,EAAE;QACrB;YACE,KAAK,EAAE,4CAAsB;YAC7B,QAAQ,EAAE,4CAAsB;SACjC;QACD;YACE,KAAK,EAAE,gCAAU;YACjB,6EAA6E;YAC7E,6EAA6E;YAC7E,2EAA2E;YAC3E,uEAAuE;YACvE,yDAAyD;YACzD,UAAU,EAAE,CAAC,SAA8B,EAAE,EAAE;gBAC7C,OAAO,IAAI,gCAAU,CAAC,SAAS,CAAC,OAAO,CAAC,4CAAsB,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,yBAAyB,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,iCAAiC,CAAC,CAAC,CAAC;YAC7K,CAAC;SACF;KACF;IACD,wBAAwB,EAAE,EAAE;CAE7B,CAAA"}
1
+ {"version":3,"file":"data-mapping.module.js","sourceRoot":"","sources":["../../../src/data-mapping.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,+EAAuE;AACvE,0EAUyC;AAIzC,uHAAuH;AACvH,oFAAoF;AACpF,mEAAiD;AAEjD,qFAAqF;AACrF,0FAA0F;AAC1F,4FAA4F;AAC5F,yFAAyF;AACzF,MAAM,kBAAkB,GAAG;IACzB,sCAAgB;IAChB,sCAAgB;IAChB,oCAAc;IACd,uCAAiB;IACjB,yCAAmB;CACpB,CAAC;AAEW,QAAA,iBAAiB,GAAoB;IAChD,OAAO,EAAE,sDAAwB;IACjC,aAAa,EAAE,EAAE;IACjB,qBAAqB,EAAE;QACrB;YACE,KAAK,EAAE,4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