@pristine-ts/data-mapping-common 2.0.9 → 2.0.10
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.
- package/dist/lib/cjs/data-mapping-common.js +1 -0
- package/dist/lib/cjs/data-mapping-common.js.map +1 -1
- package/dist/lib/cjs/mappers/data.mapper.js +12 -2
- package/dist/lib/cjs/mappers/data.mapper.js.map +1 -1
- package/dist/lib/cjs/reporters/console-error.reporter.js +23 -0
- package/dist/lib/cjs/reporters/console-error.reporter.js.map +1 -0
- package/dist/lib/cjs/reporters/reporters.js +18 -0
- package/dist/lib/cjs/reporters/reporters.js.map +1 -0
- package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/lib/cjs/types/data-mapper-error-reporter.type.js +3 -0
- package/dist/lib/cjs/types/data-mapper-error-reporter.type.js.map +1 -0
- package/dist/lib/cjs/types/types.js +1 -0
- package/dist/lib/cjs/types/types.js.map +1 -1
- package/dist/lib/esm/data-mapping-common.js +1 -0
- package/dist/lib/esm/data-mapping-common.js.map +1 -1
- package/dist/lib/esm/mappers/data.mapper.js +12 -2
- package/dist/lib/esm/mappers/data.mapper.js.map +1 -1
- package/dist/lib/esm/reporters/console-error.reporter.js +19 -0
- package/dist/lib/esm/reporters/console-error.reporter.js.map +1 -0
- package/dist/lib/esm/reporters/reporters.js +2 -0
- package/dist/lib/esm/reporters/reporters.js.map +1 -0
- package/dist/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/lib/esm/types/data-mapper-error-reporter.type.js +2 -0
- package/dist/lib/esm/types/data-mapper-error-reporter.type.js.map +1 -0
- package/dist/lib/esm/types/types.js +1 -0
- package/dist/lib/esm/types/types.js.map +1 -1
- package/dist/types/data-mapping-common.d.ts +1 -0
- package/dist/types/mappers/data.mapper.d.ts +15 -1
- package/dist/types/reporters/console-error.reporter.d.ts +16 -0
- package/dist/types/reporters/reporters.d.ts +1 -0
- package/dist/types/types/data-mapper-error-reporter.type.d.ts +21 -0
- package/dist/types/types/types.d.ts +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-mapper-error-reporter.type.js","sourceRoot":"","sources":["../../../../src/types/data-mapper-error-reporter.type.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from "./array-member-type-factory-callback.type";
|
|
2
|
+
export * from "./data-mapper-error-reporter.type";
|
|
2
3
|
export * from "./data-normalizer-unique-key.type";
|
|
3
4
|
export * from "./data-mapping-interceptor-unique-key.type";
|
|
4
5
|
export * from "./type-factory-callback.type";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAAA,cAAc,2CAA2C,CAAC;AAC1D,cAAc,mCAAmC,CAAC;AAClD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAAA,cAAc,2CAA2C,CAAC;AAC1D,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8BAA8B,CAAC"}
|
|
@@ -6,13 +6,27 @@ import { AutoDataMappingBuilder } from "../builders/auto-data-mapping.builder";
|
|
|
6
6
|
import { AutoDataMappingBuilderOptions } from "../options/auto-data-mapping-builder.options";
|
|
7
7
|
import { DataMapperOptions } from "../options/data-mapper.options";
|
|
8
8
|
import { PrimitiveType } from "../enums/primitive-type.enum";
|
|
9
|
+
import { DataMapperErrorReporter } from "../types/data-mapper-error-reporter.type";
|
|
9
10
|
export declare class DataMapper {
|
|
10
11
|
private readonly autoDataMappingBuilder;
|
|
11
12
|
private readonly dataNormalizers;
|
|
12
13
|
private readonly dataTransformerInterceptors;
|
|
13
14
|
private readonly dataNormalizersMap;
|
|
14
15
|
private readonly dataTransformerInterceptorsMap;
|
|
15
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Resolved error reporter — either the one passed to the constructor, or the built-in
|
|
18
|
+
* `console.error` fallback. Resolved once so the catch path doesn't ?? on every call.
|
|
19
|
+
*/
|
|
20
|
+
private readonly errorReporter;
|
|
21
|
+
constructor(autoDataMappingBuilder: AutoDataMappingBuilder, dataNormalizers: DataNormalizerInterface<any, any>[], dataTransformerInterceptors: DataMappingInterceptorInterface[],
|
|
22
|
+
/**
|
|
23
|
+
* Where `autoMap` should send errors when `logErrors: true` is set in the call options.
|
|
24
|
+
*
|
|
25
|
+
* Default: writes to `console.error`. Pass a custom function to route into your app's
|
|
26
|
+
* logger (e.g. the DI-wired DataMapper in `@pristine-ts/data-mapping` adapts this to
|
|
27
|
+
* `LogHandlerInterface`). Pass `() => {}` to silence reports even when `logErrors` is on.
|
|
28
|
+
*/
|
|
29
|
+
errorReporter?: DataMapperErrorReporter);
|
|
16
30
|
/**
|
|
17
31
|
* This method takes an array of source and maps each item.
|
|
18
32
|
*
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DataMapperErrorReporter } from "../types/data-mapper-error-reporter.type";
|
|
2
|
+
/**
|
|
3
|
+
* Built-in default reporter. Writes a header line + the error + a structured context payload
|
|
4
|
+
* to `console.error`. Used when no custom reporter is supplied to DataMapper — gives the
|
|
5
|
+
* frontend (and any non-DI caller) useful output out of the box.
|
|
6
|
+
*
|
|
7
|
+
* Exposed as a class-with-static-method so callers can compose it from their own reporters,
|
|
8
|
+
* e.g. `(err, ctx) => { sendToSentry(err); ConsoleErrorReporter.report(err, ctx); }`.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ConsoleErrorReporter {
|
|
11
|
+
/**
|
|
12
|
+
* Matches the `DataMapperErrorReporter` shape so a method reference (`ConsoleErrorReporter.report`)
|
|
13
|
+
* can be passed wherever the callback type is expected.
|
|
14
|
+
*/
|
|
15
|
+
static readonly report: DataMapperErrorReporter;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./console-error.reporter";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Callback the DataMapper invokes when `autoMap` swallows an error and `logErrors: true`
|
|
3
|
+
* is set on the options.
|
|
4
|
+
*
|
|
5
|
+
* Defined as a plain function type so `data-mapping-common` stays free of a logging-framework
|
|
6
|
+
* dependency — important because this package is consumed by frontend bundles (Angular, etc.)
|
|
7
|
+
* where pulling `@pristine-ts/logging` and its transitive deps in would add weight for no
|
|
8
|
+
* functional benefit.
|
|
9
|
+
*
|
|
10
|
+
* Wiring options:
|
|
11
|
+
* - Pass nothing to DataMapper → errors print via the built-in `ConsoleErrorReporter`.
|
|
12
|
+
* - Pass a custom reporter → errors go where you want them.
|
|
13
|
+
* - Pass `() => {}` (no-op) → errors are silently dropped even when `logErrors: true`.
|
|
14
|
+
*
|
|
15
|
+
* The DI-wired DataMapper in `@pristine-ts/data-mapping` provides an adapter that routes
|
|
16
|
+
* into the framework's `LogHandlerInterface`.
|
|
17
|
+
*/
|
|
18
|
+
export type DataMapperErrorReporter = (error: Error, context: {
|
|
19
|
+
source: unknown;
|
|
20
|
+
destinationType: unknown;
|
|
21
|
+
}) => void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from "./array-member-type-factory-callback.type";
|
|
2
|
+
export * from "./data-mapper-error-reporter.type";
|
|
2
3
|
export * from "./data-normalizer-unique-key.type";
|
|
3
4
|
export * from "./data-mapping-interceptor-unique-key.type";
|
|
4
5
|
export * from "./type-factory-callback.type";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pristine-ts/data-mapping-common",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"module": "dist/lib/esm/data-mapping-common.js",
|
|
6
6
|
"main": "dist/lib/cjs/data-mapping-common.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@pristine-ts/class-validator": "^2.0.4",
|
|
24
|
-
"@pristine-ts/common": "^2.0.
|
|
24
|
+
"@pristine-ts/common": "^2.0.10",
|
|
25
25
|
"@pristine-ts/metadata": "^1.0.16",
|
|
26
26
|
"class-transformer": "^0.5.1",
|
|
27
27
|
"date-fns": "^3.3.1"
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"jest-extended/all"
|
|
64
64
|
]
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "3d0126d73d7a0dec99fcda3824981d893d1d0662",
|
|
67
67
|
"repository": {
|
|
68
68
|
"type": "git",
|
|
69
69
|
"url": "https://github.com/magieno/pristine-ts.git",
|