@rsdk/core 5.7.0-next.2 → 6.0.0-next.0
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/config/index.d.ts +0 -1
- package/dist/config/index.js +0 -1
- package/dist/config/index.js.map +1 -1
- package/dist/config/metadata/decorators/declare-property.decorator.d.ts +2 -1
- package/dist/config/metadata/decorators/declare-property.decorator.js.map +1 -1
- package/dist/config/metadata/decorators/property.decorator.d.ts +2 -1
- package/dist/config/metadata/decorators/property.decorator.js.map +1 -1
- package/dist/config/sources/implementations/json-file.source.js +1 -2
- package/dist/config/sources/implementations/json-file.source.js.map +1 -1
- package/dist/config/sources/implementations/relodable-json-file.source.js +1 -2
- package/dist/config/sources/implementations/relodable-json-file.source.js.map +1 -1
- package/dist/config/types.d.ts +1 -20
- package/dist/config/types.js.map +1 -1
- package/dist/exceptions.handling/default.formatter.d.ts +6 -0
- package/dist/exceptions.handling/default.formatter.js +12 -0
- package/dist/exceptions.handling/default.formatter.js.map +1 -0
- package/dist/exceptions.handling/default.sender.d.ts +8 -0
- package/dist/exceptions.handling/default.sender.js +13 -0
- package/dist/exceptions.handling/default.sender.js.map +1 -0
- package/dist/exceptions.handling/global-exceptions.config.js +1 -1
- package/dist/exceptions.handling/global-exceptions.config.js.map +1 -1
- package/dist/exceptions.handling/global-exceptions.filter.d.ts +8 -11
- package/dist/exceptions.handling/global-exceptions.filter.js +38 -56
- package/dist/exceptions.handling/global-exceptions.filter.js.map +1 -1
- package/dist/exceptions.handling/global-exceptions.interceptor.d.ts +18 -0
- package/dist/exceptions.handling/global-exceptions.interceptor.js +57 -0
- package/dist/exceptions.handling/global-exceptions.interceptor.js.map +1 -0
- package/dist/exceptions.handling/global-exceptions.module.d.ts +2 -23
- package/dist/exceptions.handling/global-exceptions.module.js +38 -3
- package/dist/exceptions.handling/global-exceptions.module.js.map +1 -1
- package/dist/exceptions.handling/types.d.ts +2 -2
- package/dist/index.d.ts +31 -2
- package/dist/index.js +34 -1
- package/dist/index.js.map +1 -1
- package/dist/logging/constants.d.ts +1 -0
- package/dist/logging/constants.js +5 -0
- package/dist/logging/constants.js.map +1 -0
- package/dist/logging/decorators/inject-logger.decorator.js +2 -2
- package/dist/logging/decorators/inject-logger.decorator.js.map +1 -1
- package/dist/logging/formatters/default.formatter.d.ts +7 -0
- package/dist/logging/formatters/default.formatter.js +17 -0
- package/dist/logging/formatters/default.formatter.js.map +1 -0
- package/dist/logging/formatters/index.d.ts +2 -0
- package/dist/{config/parsers/array → logging/formatters}/index.js +2 -1
- package/dist/logging/formatters/index.js.map +1 -0
- package/dist/logging/formatters/interfaces.d.ts +23 -0
- package/dist/logging/formatters/interfaces.js +3 -0
- package/dist/logging/formatters/interfaces.js.map +1 -0
- package/dist/logging/index.d.ts +3 -2
- package/dist/logging/index.js +6 -4
- package/dist/logging/index.js.map +1 -1
- package/dist/logging/logging-core.module.d.ts +10 -0
- package/dist/logging/{logger-initializing.module.js → logging-core.module.js} +46 -10
- package/dist/logging/logging-core.module.js.map +1 -0
- package/dist/logging/{logging.module.d.ts → logging-instances.module.d.ts} +1 -1
- package/dist/logging/{logging.module.js → logging-instances.module.js} +8 -9
- package/dist/logging/logging-instances.module.js.map +1 -0
- package/dist/logging/logging.config.d.ts +3 -0
- package/dist/logging/logging.config.js +29 -4
- package/dist/logging/logging.config.js.map +1 -1
- package/dist/logging/logging.interceptor.d.ts +37 -0
- package/dist/logging/logging.interceptor.js +124 -0
- package/dist/logging/logging.interceptor.js.map +1 -0
- package/dist/metrics/metrics.config.js +3 -2
- package/dist/metrics/metrics.config.js.map +1 -1
- package/dist/platform.context.d.ts +1 -1
- package/dist/platform.context.js +3 -2
- package/dist/platform.context.js.map +1 -1
- package/dist/platform.module.js +19 -6
- package/dist/platform.module.js.map +1 -1
- package/dist/tracing/constants.d.ts +4 -5
- package/dist/tracing/constants.js +9 -7
- package/dist/tracing/constants.js.map +1 -1
- package/dist/tracing/index.d.ts +1 -0
- package/dist/tracing/index.js +1 -0
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/request-id/index.d.ts +4 -0
- package/dist/{config/parsers/enum → tracing/request-id}/index.js +4 -1
- package/dist/tracing/request-id/index.js.map +1 -0
- package/dist/tracing/request-id/metadata.helpers.d.ts +13 -0
- package/dist/tracing/request-id/metadata.helpers.js +23 -0
- package/dist/tracing/request-id/metadata.helpers.js.map +1 -0
- package/dist/tracing/request-id/request-id-gen.decorator.d.ts +8 -0
- package/dist/tracing/request-id/request-id-gen.decorator.js +17 -0
- package/dist/tracing/request-id/request-id-gen.decorator.js.map +1 -0
- package/dist/tracing/request-id/types.d.ts +2 -0
- package/dist/tracing/request-id/types.js +3 -0
- package/dist/tracing/request-id/types.js.map +1 -0
- package/dist/tracing/request-id/with-prefix.fn.d.ts +30 -0
- package/dist/tracing/request-id/with-prefix.fn.js +36 -0
- package/dist/tracing/request-id/with-prefix.fn.js.map +1 -0
- package/dist/tracing/tracing.config.d.ts +5 -0
- package/dist/tracing/tracing.config.js +42 -0
- package/dist/tracing/tracing.config.js.map +1 -0
- package/dist/tracing/tracing.interceptor.d.ts +7 -9
- package/dist/tracing/tracing.interceptor.js +30 -28
- package/dist/tracing/tracing.interceptor.js.map +1 -1
- package/dist/tracing/tracing.module.d.ts +13 -2
- package/dist/tracing/tracing.module.js +60 -17
- package/dist/tracing/tracing.module.js.map +1 -1
- package/dist/transport/protocol.detector.d.ts +1 -1
- package/dist/transport/protocol.detector.js +17 -2
- package/dist/transport/protocol.detector.js.map +1 -1
- package/dist/transport/transport.module.d.ts +0 -1
- package/dist/transport/transport.module.js +0 -20
- package/dist/transport/transport.module.js.map +1 -1
- package/dist/types/plugins.d.ts +2 -15
- package/dist/types/plugins.js.map +1 -1
- package/dist/types/transports.d.ts +23 -13
- package/dist/types/transports.js.map +1 -1
- package/dist/unhandled-rejection.handler.js +8 -13
- package/dist/unhandled-rejection.handler.js.map +1 -1
- package/package.json +3 -2
- package/src/config/index.ts +0 -1
- package/src/config/metadata/decorators/declare-property.decorator.ts +3 -1
- package/src/config/metadata/decorators/property.decorator.ts +3 -5
- package/src/config/sources/implementations/json-file.source.ts +1 -2
- package/src/config/sources/implementations/relodable-json-file.source.ts +1 -2
- package/src/config/types.ts +2 -23
- package/src/exceptions.handling/default.formatter.ts +11 -0
- package/src/exceptions.handling/default.sender.ts +15 -0
- package/src/exceptions.handling/global-exceptions.config.ts +2 -2
- package/src/exceptions.handling/global-exceptions.filter.ts +45 -77
- package/src/exceptions.handling/global-exceptions.interceptor.ts +57 -0
- package/src/exceptions.handling/global-exceptions.module.ts +46 -33
- package/src/exceptions.handling/types.ts +2 -2
- package/src/index.ts +53 -2
- package/src/logging/constants.ts +1 -0
- package/src/logging/decorators/inject-logger.decorator.ts +2 -2
- package/src/logging/formatters/default.formatter.ts +17 -0
- package/src/logging/formatters/index.ts +2 -0
- package/src/logging/formatters/interfaces.ts +34 -0
- package/src/logging/index.ts +3 -2
- package/src/logging/logging-core.module.ts +102 -0
- package/src/logging/{logging.module.ts → logging-instances.module.ts} +2 -4
- package/src/logging/logging.config.ts +22 -6
- package/src/logging/logging.interceptor.ts +138 -0
- package/src/metrics/metrics.config.ts +3 -1
- package/src/platform.context.ts +5 -2
- package/src/platform.module.ts +28 -7
- package/src/tracing/constants.ts +8 -7
- package/src/tracing/index.ts +1 -0
- package/src/tracing/request-id/index.ts +4 -0
- package/src/tracing/request-id/metadata.helpers.ts +24 -0
- package/src/tracing/request-id/request-id-gen.decorator.ts +16 -0
- package/src/tracing/request-id/types.ts +6 -0
- package/src/tracing/request-id/with-prefix.fn.ts +44 -0
- package/src/tracing/tracing.config.ts +23 -0
- package/src/tracing/tracing.interceptor.ts +36 -31
- package/src/tracing/tracing.module.ts +68 -19
- package/src/transport/protocol.detector.ts +24 -4
- package/src/transport/transport.module.ts +0 -25
- package/src/types/plugins.ts +11 -22
- package/src/types/transports.ts +32 -16
- package/src/unhandled-rejection.handler.ts +10 -18
- package/test/logging.interceptor.spec.ts +292 -0
- package/dist/config/parsers/array/array.parser.d.ts +0 -11
- package/dist/config/parsers/array/array.parser.js +0 -33
- package/dist/config/parsers/array/array.parser.js.map +0 -1
- package/dist/config/parsers/array/index.d.ts +0 -1
- package/dist/config/parsers/array/index.js.map +0 -1
- package/dist/config/parsers/boolean/bool.parser.d.ts +0 -6
- package/dist/config/parsers/boolean/bool.parser.js +0 -20
- package/dist/config/parsers/boolean/bool.parser.js.map +0 -1
- package/dist/config/parsers/boolean/index.d.ts +0 -1
- package/dist/config/parsers/boolean/index.js +0 -18
- package/dist/config/parsers/boolean/index.js.map +0 -1
- package/dist/config/parsers/enum/enum.parser.d.ts +0 -9
- package/dist/config/parsers/enum/enum.parser.js +0 -24
- package/dist/config/parsers/enum/enum.parser.js.map +0 -1
- package/dist/config/parsers/enum/index.d.ts +0 -1
- package/dist/config/parsers/enum/index.js.map +0 -1
- package/dist/config/parsers/index.d.ts +0 -11
- package/dist/config/parsers/index.js +0 -28
- package/dist/config/parsers/index.js.map +0 -1
- package/dist/config/parsers/int/index.d.ts +0 -1
- package/dist/config/parsers/int/index.js +0 -18
- package/dist/config/parsers/int/index.js.map +0 -1
- package/dist/config/parsers/int/int.parser.d.ts +0 -6
- package/dist/config/parsers/int/int.parser.js +0 -20
- package/dist/config/parsers/int/int.parser.js.map +0 -1
- package/dist/config/parsers/json/index.d.ts +0 -1
- package/dist/config/parsers/json/index.js +0 -18
- package/dist/config/parsers/json/index.js.map +0 -1
- package/dist/config/parsers/json/json.parser.d.ts +0 -6
- package/dist/config/parsers/json/json.parser.js +0 -16
- package/dist/config/parsers/json/json.parser.js.map +0 -1
- package/dist/config/parsers/number/index.d.ts +0 -1
- package/dist/config/parsers/number/index.js +0 -18
- package/dist/config/parsers/number/index.js.map +0 -1
- package/dist/config/parsers/number/number.parser.d.ts +0 -6
- package/dist/config/parsers/number/number.parser.js +0 -23
- package/dist/config/parsers/number/number.parser.js.map +0 -1
- package/dist/config/parsers/path/fspath.parser.d.ts +0 -8
- package/dist/config/parsers/path/fspath.parser.js +0 -59
- package/dist/config/parsers/path/fspath.parser.js.map +0 -1
- package/dist/config/parsers/path/index.d.ts +0 -1
- package/dist/config/parsers/path/index.js +0 -18
- package/dist/config/parsers/path/index.js.map +0 -1
- package/dist/config/parsers/size/index.d.ts +0 -1
- package/dist/config/parsers/size/index.js +0 -18
- package/dist/config/parsers/size/index.js.map +0 -1
- package/dist/config/parsers/size/size.parser.d.ts +0 -7
- package/dist/config/parsers/size/size.parser.js +0 -21
- package/dist/config/parsers/size/size.parser.js.map +0 -1
- package/dist/config/parsers/string/index.d.ts +0 -1
- package/dist/config/parsers/string/index.js +0 -18
- package/dist/config/parsers/string/index.js.map +0 -1
- package/dist/config/parsers/string/string.parser.d.ts +0 -8
- package/dist/config/parsers/string/string.parser.js +0 -29
- package/dist/config/parsers/string/string.parser.js.map +0 -1
- package/dist/config/parsers/timespan/index.d.ts +0 -1
- package/dist/config/parsers/timespan/index.js +0 -18
- package/dist/config/parsers/timespan/index.js.map +0 -1
- package/dist/config/parsers/timespan/timespan.parser.d.ts +0 -7
- package/dist/config/parsers/timespan/timespan.parser.js +0 -21
- package/dist/config/parsers/timespan/timespan.parser.js.map +0 -1
- package/dist/config/parsers/url/exception.d.ts +0 -7
- package/dist/config/parsers/url/exception.js +0 -25
- package/dist/config/parsers/url/exception.js.map +0 -1
- package/dist/config/parsers/url/index.d.ts +0 -2
- package/dist/config/parsers/url/index.js +0 -21
- package/dist/config/parsers/url/index.js.map +0 -1
- package/dist/config/parsers/url/url.parser.d.ts +0 -9
- package/dist/config/parsers/url/url.parser.js +0 -38
- package/dist/config/parsers/url/url.parser.js.map +0 -1
- package/dist/logging/logger-initializing.module.d.ts +0 -6
- package/dist/logging/logger-initializing.module.js.map +0 -1
- package/dist/logging/logging.module.js.map +0 -1
- package/src/config/parsers/array/array.parser.ts +0 -34
- package/src/config/parsers/array/index.ts +0 -1
- package/src/config/parsers/boolean/bool.parser.ts +0 -20
- package/src/config/parsers/boolean/bool.spec.ts +0 -4
- package/src/config/parsers/boolean/index.ts +0 -1
- package/src/config/parsers/enum/enum.parser.ts +0 -23
- package/src/config/parsers/enum/enum.spec.ts +0 -5
- package/src/config/parsers/enum/index.ts +0 -1
- package/src/config/parsers/index.ts +0 -11
- package/src/config/parsers/int/index.ts +0 -1
- package/src/config/parsers/int/int.parser.ts +0 -20
- package/src/config/parsers/int/int.spec.ts +0 -5
- package/src/config/parsers/json/index.ts +0 -1
- package/src/config/parsers/json/json.parser.ts +0 -15
- package/src/config/parsers/number/index.ts +0 -1
- package/src/config/parsers/number/number.parser.ts +0 -23
- package/src/config/parsers/number/number.spec.ts +0 -5
- package/src/config/parsers/path/fspath.parser.ts +0 -64
- package/src/config/parsers/path/index.ts +0 -1
- package/src/config/parsers/size/index.ts +0 -1
- package/src/config/parsers/size/size.parser.ts +0 -22
- package/src/config/parsers/size/size.spec.ts +0 -4
- package/src/config/parsers/string/index.ts +0 -1
- package/src/config/parsers/string/string.parser.ts +0 -26
- package/src/config/parsers/string/string.spec.ts +0 -10
- package/src/config/parsers/timespan/index.ts +0 -1
- package/src/config/parsers/timespan/timespan.parser.ts +0 -22
- package/src/config/parsers/timespan/timespan.spec.ts +0 -5
- package/src/config/parsers/url/exception.ts +0 -21
- package/src/config/parsers/url/index.ts +0 -2
- package/src/config/parsers/url/url.parser.ts +0 -44
- package/src/logging/logger-initializing.module.ts +0 -55
package/dist/config/index.d.ts
CHANGED
package/dist/config/index.js
CHANGED
|
@@ -15,7 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.ConfigContext = exports.ConfigPropertyMetadataNotFound = exports.AdditionalSourceModule = void 0;
|
|
18
|
-
__exportStar(require("./parsers"), exports);
|
|
19
18
|
__exportStar(require("./config.module"), exports);
|
|
20
19
|
__exportStar(require("./sources"), exports);
|
|
21
20
|
__exportStar(require("./config.abstract"), exports);
|
package/dist/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,4CAA0B;AAC1B,oDAAkC;AAClC,6CAA2B;AAC3B,0CAAwB;AACxB,2CAAyB;AACzB,yFAAsF;AAA7E,kIAAA,sBAAsB,OAAA;AAE/B,2CAA8D;AAArD,4HAAA,8BAA8B,OAAA;AACvC,2DAAyD;AAAhD,+GAAA,aAAa,OAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PropertyParser } from '@rsdk/common';
|
|
2
|
+
import type { PropertyOptions } from '../../types';
|
|
2
3
|
/**
|
|
3
4
|
* Declares standalone property. Properties declared in this way,
|
|
4
5
|
* can be injected with @InjectProperty() decorator.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declare-property.decorator.js","sourceRoot":"","sources":["../../../../src/config/metadata/decorators/declare-property.decorator.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"declare-property.decorator.js","sourceRoot":"","sources":["../../../../src/config/metadata/decorators/declare-property.decorator.ts"],"names":[],"mappings":";;;AAGA,0EAAqE;AAErE;;;;;;;;;;;;;;;;GAgBG;AACI,MAAM,eAAe,GAAG,CAC7B,KAAa,EACb,MAAyB,EACzB,OAA2B,EACX,EAAE;IAClB,OAAO,UAAU,MAAM;QACrB,iDAAsB,CAAC,gBAAgB,CAAC,MAAM,EAAE,KAAK,EAAE;YACrD,aAAa,EAAE,IAAI;YACnB,GAAG,OAAO;YACV,GAAG,EAAE,KAAK;YACV,MAAM;SACP,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,eAAe,mBAa1B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PropertyParser } from '@rsdk/common';
|
|
2
|
+
import type { PropertyOptions } from '../../types';
|
|
2
3
|
export declare const CONFIG_METADATA_KEY = "CONFIG_METADATA";
|
|
3
4
|
/**
|
|
4
5
|
* Sets metadata that will be used to populate the field
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"property.decorator.js","sourceRoot":"","sources":["../../../../src/config/metadata/decorators/property.decorator.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"property.decorator.js","sourceRoot":"","sources":["../../../../src/config/metadata/decorators/property.decorator.ts"],"names":[],"mappings":";;;AAIa,QAAA,mBAAmB,GAAG,iBAAiB,CAAC;AAErD;;;;;;;;GAQG;AACI,MAAM,QAAQ,GAAG,CACtB,GAAW,EACX,MAAyB,EACzB,OAA2B,EACsB,EAAE,CACnD,UAAU,MAAc,EAAE,WAAmB;IAC3C,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC;IAEhC,MAAM,QAAQ,GAAI,OAAO,CAAC,WAAW,CACnC,2BAAmB,EACnB,IAAI,CACe,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;IAE5C,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG;QACjC,aAAa,EAAE,KAAK;QACpB,GAAG;QACH,MAAM;QACN,GAAG,OAAO;KACX,CAAC;IAEF,OAAO,CAAC,cAAc,CAAC,2BAAmB,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;AAC9D,CAAC,CAAC;AArBS,QAAA,QAAQ,YAqBjB;AAEJ,6GAA6G"}
|
|
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.StaticFileSource = void 0;
|
|
16
16
|
const common_node_1 = require("@rsdk/common.node");
|
|
17
17
|
const metadata_1 = require("../../metadata");
|
|
18
|
-
const parsers_1 = require("../../parsers");
|
|
19
18
|
const base_1 = require("../base");
|
|
20
19
|
const config_source_decorator_1 = require("../config-source.decorator");
|
|
21
20
|
let StaticFileSource = class StaticFileSource extends base_1.ConfigSource {
|
|
@@ -37,7 +36,7 @@ let StaticFileSource = class StaticFileSource extends base_1.ConfigSource {
|
|
|
37
36
|
exports.StaticFileSource = StaticFileSource;
|
|
38
37
|
exports.StaticFileSource = StaticFileSource = __decorate([
|
|
39
38
|
(0, config_source_decorator_1.Source)('static'),
|
|
40
|
-
(0, metadata_1.DeclareProperty)(`CONFIG_PATH`, new
|
|
39
|
+
(0, metadata_1.DeclareProperty)(`CONFIG_PATH`, new common_node_1.FsPathParser('file'), {
|
|
41
40
|
description: 'Path to some configuration file',
|
|
42
41
|
}),
|
|
43
42
|
__param(0, (0, metadata_1.InjectProperty)('CONFIG_PATH')),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-file.source.js","sourceRoot":"","sources":["../../../../src/config/sources/implementations/json-file.source.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"json-file.source.js","sourceRoot":"","sources":["../../../../src/config/sources/implementations/json-file.source.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAA0D;AAE1D,6CAAiE;AAEjE,kCAAuC;AACvC,wEAAoD;AAM7C,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,mBAAY;IACY;IAA5D,YAA4D,IAAY;QACtE,KAAK,EAAE,CAAC;QADkD,SAAI,GAAJ,IAAI,CAAQ;IAExE,CAAC;IAEQ,IAAI;QACX,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEQ,IAAI;QACX,OAAO,qBAAqB,IAAI,CAAC,IAAI,EAAE,CAAC;IAC1C,CAAC;IAEQ,OAAO;QACd,OAAO,IAAA,qBAAO,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF,CAAA;AAhBY,4CAAgB;2BAAhB,gBAAgB;IAJ5B,IAAA,gCAAM,EAAC,QAAQ,CAAC;IAChB,IAAA,0BAAe,EAAC,aAAa,EAAE,IAAI,0BAAY,CAAC,MAAM,CAAC,EAAE;QACxD,WAAW,EAAE,iCAAiC;KAC/C,CAAC;IAEa,WAAA,IAAA,yBAAc,EAAC,aAAa,CAAC,CAAA;;GAD/B,gBAAgB,CAgB5B"}
|
|
@@ -18,7 +18,6 @@ const common_node_1 = require("@rsdk/common.node");
|
|
|
18
18
|
const logging_1 = require("@rsdk/logging");
|
|
19
19
|
const node_fs_1 = require("node:fs");
|
|
20
20
|
const metadata_1 = require("../../metadata");
|
|
21
|
-
const parsers_1 = require("../../parsers");
|
|
22
21
|
const reload_1 = require("../../reload");
|
|
23
22
|
const base_1 = require("../base");
|
|
24
23
|
const config_source_decorator_1 = require("../config-source.decorator");
|
|
@@ -47,7 +46,7 @@ let ReloadableFileSource = ReloadableFileSource_1 = class ReloadableFileSource e
|
|
|
47
46
|
exports.ReloadableFileSource = ReloadableFileSource;
|
|
48
47
|
exports.ReloadableFileSource = ReloadableFileSource = ReloadableFileSource_1 = __decorate([
|
|
49
48
|
(0, config_source_decorator_1.Source)('reloadable'),
|
|
50
|
-
(0, metadata_1.DeclareProperty)('CONFIG_PATH', new
|
|
49
|
+
(0, metadata_1.DeclareProperty)('CONFIG_PATH', new common_node_1.FsPathParser('file'), {
|
|
51
50
|
description: 'Path to some configuration file',
|
|
52
51
|
}),
|
|
53
52
|
__param(0, (0, metadata_1.InjectProperty)('CONFIG_PATH')),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relodable-json-file.source.js","sourceRoot":"","sources":["../../../../src/config/sources/implementations/relodable-json-file.source.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"relodable-json-file.source.js","sourceRoot":"","sources":["../../../../src/config/sources/implementations/relodable-json-file.source.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAA0D;AAC1D,2CAA8C;AAC9C,qCAAgC;AAEhC,6CAAiE;AACjE,yCAA4C;AAC5C,kCAAiD;AACjD,wEAAoD;AAM7C,IAAM,oBAAoB,4BAA1B,MAAM,oBAAqB,SAAQ,6BAAsB;IAEZ;IADlD,YACkD,IAAY,EAC5D,YAA0B;QAE1B,KAAK,CAAC,uBAAa,CAAC,MAAM,CAAC,sBAAoB,CAAC,EAAE,YAAY,CAAC,CAAC;QAHhB,SAAI,GAAJ,IAAI,CAAQ;IAI9D,CAAC;IAEQ,IAAI;QACX,OAAO,uBAAuB,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5C,CAAC;IAEQ,OAAO;QACd,OAAO,IAAA,qBAAO,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAEQ,IAAI;QACX,IAAA,eAAK,EAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE;YACzB,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACvB,OAAO;YACT,CAAC;YAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YAE5D,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA3BY,oDAAoB;+BAApB,oBAAoB;IAJhC,IAAA,gCAAM,EAAC,YAAY,CAAC;IACpB,IAAA,0BAAe,EAAC,aAAa,EAAE,IAAI,0BAAY,CAAC,MAAM,CAAC,EAAE;QACxD,WAAW,EAAE,iCAAiC;KAC/C,CAAC;IAGG,WAAA,IAAA,yBAAc,EAAC,aAAa,CAAC,CAAA;6CAChB,qBAAY;GAHjB,oBAAoB,CA2BhC"}
|
package/dist/config/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PropertyParser } from '@rsdk/common';
|
|
1
2
|
export type SourceType = 'static' | 'reloadable';
|
|
2
3
|
export interface Changes {
|
|
3
4
|
createdKeys: string[];
|
|
@@ -44,26 +45,6 @@ export interface ParserMetadata {
|
|
|
44
45
|
type: string;
|
|
45
46
|
description: string;
|
|
46
47
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Implement this interface to create more parsers.
|
|
49
|
-
* For example: email, BigInt, guid etc.
|
|
50
|
-
*
|
|
51
|
-
* NOTE: In other modules it is more common to define metadata
|
|
52
|
-
* via decorators. But this case is a bit different.
|
|
53
|
-
*
|
|
54
|
-
* 1. Parser implementations can have constructors with parameters
|
|
55
|
-
* which will affect it's behaviour. It's will be nice to have it
|
|
56
|
-
* in metadata, and decorators won't provide this.
|
|
57
|
-
*
|
|
58
|
-
* 2. Metadata will be extracted via type() and description() methods
|
|
59
|
-
* mostly during decorator factories (such as @Property()) code is
|
|
60
|
-
* executed. Thus output **can** be used in autodoc
|
|
61
|
-
*/
|
|
62
|
-
export interface PropertyParser<T = any> {
|
|
63
|
-
type(): string;
|
|
64
|
-
description(): string;
|
|
65
|
-
parse(value: unknown): T;
|
|
66
|
-
}
|
|
67
48
|
export type RawValues = Map<string, unknown>;
|
|
68
49
|
export declare enum AppNameStrategyType {
|
|
69
50
|
LEGACY = "LEGACY",
|
package/dist/config/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":";;;AA4DA,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC7B,wCAAiB,CAAA;IACjB,4CAAqB,CAAA;AACvB,CAAC,EAHW,mBAAmB,mCAAnB,mBAAmB,QAG9B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_FORMATTER = exports.DefaultFormatter = void 0;
|
|
4
|
+
class DefaultFormatter {
|
|
5
|
+
protocol = 'default';
|
|
6
|
+
format(ex, verbose) {
|
|
7
|
+
return verbose ? ex : { message: 'NO FORMATTER' };
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.DefaultFormatter = DefaultFormatter;
|
|
11
|
+
exports.DEFAULT_FORMATTER = new DefaultFormatter();
|
|
12
|
+
//# sourceMappingURL=default.formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.formatter.js","sourceRoot":"","sources":["../../src/exceptions.handling/default.formatter.ts"],"names":[],"mappings":";;;AAEA,MAAa,gBAAgB;IAClB,QAAQ,GAAG,SAAS,CAAC;IAE9B,MAAM,CAAC,EAAW,EAAE,OAAgB;QAClC,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;IACpD,CAAC;CACF;AAND,4CAMC;AAEY,QAAA,iBAAiB,GAAG,IAAI,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ArgumentsHost } from '@nestjs/common';
|
|
2
|
+
import type { Observable } from 'rxjs';
|
|
3
|
+
import type { IErrorsSender } from './types';
|
|
4
|
+
export declare class DefaultSender implements IErrorsSender {
|
|
5
|
+
readonly protocol = "default";
|
|
6
|
+
send(_: ArgumentsHost, ex: unknown): Observable<any>;
|
|
7
|
+
}
|
|
8
|
+
export declare const DEFAULT_SENDER: DefaultSender;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_SENDER = exports.DefaultSender = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
class DefaultSender {
|
|
6
|
+
protocol = 'default';
|
|
7
|
+
send(_, ex) {
|
|
8
|
+
return (0, rxjs_1.throwError)(() => ex);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.DefaultSender = DefaultSender;
|
|
12
|
+
exports.DEFAULT_SENDER = new DefaultSender();
|
|
13
|
+
//# sourceMappingURL=default.sender.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.sender.js","sourceRoot":"","sources":["../../src/exceptions.handling/default.sender.ts"],"names":[],"mappings":";;;AAEA,+BAAkC;AAIlC,MAAa,aAAa;IACf,QAAQ,GAAG,SAAS,CAAC;IAE9B,IAAI,CAAC,CAAgB,EAAE,EAAW;QAChC,OAAO,IAAA,iBAAU,EAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;CACF;AAND,sCAMC;AAEY,QAAA,cAAc,GAAG,IAAI,aAAa,EAAE,CAAC"}
|
|
@@ -18,7 +18,7 @@ let GlobalExceptionsConfig = class GlobalExceptionsConfig extends config_1.Confi
|
|
|
18
18
|
};
|
|
19
19
|
exports.GlobalExceptionsConfig = GlobalExceptionsConfig;
|
|
20
20
|
__decorate([
|
|
21
|
-
(0, config_1.Property)('VERBOSE_ERRORS', new
|
|
21
|
+
(0, config_1.Property)('VERBOSE_ERRORS', new common_1.BoolParser(), {
|
|
22
22
|
defaultValue: true,
|
|
23
23
|
description: (0, common_1.text) `
|
|
24
24
|
If set "true" all exception messages will be returned to client.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-exceptions.config.js","sourceRoot":"","sources":["../../src/exceptions.handling/global-exceptions.config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"global-exceptions.config.js","sourceRoot":"","sources":["../../src/exceptions.handling/global-exceptions.config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAgD;AAEhD,sCAA4D;AAC5D,yDAAmD;AAK5C,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,eAAM;IAQvC,OAAO,CAAW;CAC5B,CAAA;AATY,wDAAsB;AAQxB;IAPR,IAAA,iBAAQ,EAAC,gBAAgB,EAAE,IAAI,mBAAU,EAAE,EAAE;QAC5C,YAAY,EAAE,IAAI;QAClB,WAAW,EAAE,IAAA,aAAI,EAAA;;;KAGhB;KACF,CAAC;;uDACyB;iCARhB,sBAAsB;IAHlC,IAAA,sBAAa,EAAC;QACb,IAAI,EAAE,CAAC,wBAAS,CAAC,cAAc,EAAE,wBAAS,CAAC,aAAa,CAAC;KAC1D,CAAC;GACW,sBAAsB,CASlC"}
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import type { ArgumentsHost, ExceptionFilter } from '@nestjs/common';
|
|
2
|
-
import { ILogger } from '@rsdk/logging';
|
|
3
2
|
import type { Observable } from 'rxjs';
|
|
3
|
+
import { PipelineException } from '../exceptions';
|
|
4
|
+
import { ILogger } from '../logging';
|
|
4
5
|
import { ProtocolDetector } from '../transport/protocol.detector';
|
|
5
6
|
import { GlobalExceptionsConfig } from './global-exceptions.config';
|
|
6
|
-
import type { IErrorsFormatter, IErrorsSender
|
|
7
|
+
import type { IErrorsFormatter, IErrorsSender } from './types';
|
|
7
8
|
export declare class GlobalExceptionsFilter implements ExceptionFilter {
|
|
8
|
-
private readonly formatters;
|
|
9
|
-
private readonly transformers;
|
|
10
9
|
private readonly senders;
|
|
10
|
+
private readonly formatters;
|
|
11
11
|
private readonly logger;
|
|
12
|
-
private readonly config;
|
|
13
12
|
private readonly detector;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
private format;
|
|
18
|
-
private getFormatter;
|
|
19
|
-
private send;
|
|
13
|
+
private readonly config;
|
|
14
|
+
constructor(senders: Map<string, IErrorsSender>, formatters: Map<string, IErrorsFormatter>, logger: ILogger, detector: ProtocolDetector, config: GlobalExceptionsConfig);
|
|
15
|
+
catch(ex: PipelineException, host: ArgumentsHost): Observable<any>;
|
|
20
16
|
private getSender;
|
|
17
|
+
private getFormatter;
|
|
21
18
|
}
|
|
@@ -15,85 +15,67 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.GlobalExceptionsFilter = void 0;
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
17
|
const common_2 = require("@rsdk/common");
|
|
18
|
-
const rxjs_1 = require("rxjs");
|
|
19
|
-
const exceptions_1 = require("../exceptions");
|
|
20
18
|
const logging_1 = require("../logging");
|
|
21
19
|
const protocol_detector_1 = require("../transport/protocol.detector");
|
|
22
20
|
const constants_1 = require("./constants");
|
|
21
|
+
const default_formatter_1 = require("./default.formatter");
|
|
22
|
+
const default_sender_1 = require("./default.sender");
|
|
23
23
|
const global_exceptions_config_1 = require("./global-exceptions.config");
|
|
24
24
|
let GlobalExceptionsFilter = class GlobalExceptionsFilter {
|
|
25
|
-
formatters;
|
|
26
|
-
transformers;
|
|
27
25
|
senders;
|
|
26
|
+
formatters;
|
|
28
27
|
logger;
|
|
29
|
-
config;
|
|
30
28
|
detector;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.transformers = transformers;
|
|
29
|
+
config;
|
|
30
|
+
constructor(senders, formatters, logger, detector, config) {
|
|
34
31
|
this.senders = senders;
|
|
32
|
+
this.formatters = formatters;
|
|
35
33
|
this.logger = logger;
|
|
36
|
-
this.config = config;
|
|
37
34
|
this.detector = detector;
|
|
35
|
+
this.config = config;
|
|
38
36
|
}
|
|
39
37
|
catch(ex, host) {
|
|
40
|
-
const transformed = ex instanceof exceptions_1.PipelineException ? ex : this.transform(ex);
|
|
41
|
-
// Error is transformed to standard PipelineException
|
|
42
|
-
this.logger.error(transformed);
|
|
43
|
-
const formatted = this.format(host, transformed);
|
|
44
|
-
return this.send(host, formatted);
|
|
45
|
-
}
|
|
46
|
-
transform(ex) {
|
|
47
|
-
const transformer = this.transformers.find((x) => x.match(ex));
|
|
48
|
-
if (transformer) {
|
|
49
|
-
return transformer.transform(ex);
|
|
50
|
-
}
|
|
51
|
-
const err = new exceptions_1.InternalException(ex.message ?? 'UNKNOWN ERROR', ex);
|
|
52
|
-
err.stack = ex.stack;
|
|
53
|
-
return err;
|
|
54
|
-
}
|
|
55
|
-
format(host, ex) {
|
|
56
38
|
const protocol = this.detector.getProtocol(host);
|
|
39
|
+
const sender = this.getSender(host, protocol);
|
|
57
40
|
const formatter = this.getFormatter(host, protocol);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
41
|
+
const formatted = formatter.format(ex, this.config.verbose);
|
|
42
|
+
const normalized = (0, common_2.normalizer)()(formatted, {
|
|
43
|
+
filterKeys: ['stack'],
|
|
44
|
+
sortKeys: common_2.sortErrorKeys,
|
|
45
|
+
});
|
|
46
|
+
return sender.send(host, normalized);
|
|
47
|
+
}
|
|
48
|
+
getSender(host, protocol) {
|
|
49
|
+
const sender = this.senders.get(protocol) ?? this.senders.get(host.getType());
|
|
50
|
+
if (sender) {
|
|
51
|
+
this.logger.trace(`Found sender: ${sender.constructor.name}`);
|
|
52
|
+
return sender;
|
|
69
53
|
}
|
|
70
|
-
|
|
54
|
+
this.logger.warn((0, common_2.text) `
|
|
55
|
+
No sender for protocol = ${protocol}
|
|
56
|
+
(hostType = ${host.getType()})`);
|
|
57
|
+
return default_sender_1.DEFAULT_SENDER;
|
|
71
58
|
}
|
|
72
59
|
getFormatter(host, protocol) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const protocol = this.detector.getProtocol(host);
|
|
78
|
-
const sender = this.getSender(host, protocol);
|
|
79
|
-
return sender?.send(host, ex) ?? (0, rxjs_1.throwError)(() => ex);
|
|
80
|
-
}
|
|
81
|
-
getSender(host, protocol) {
|
|
82
|
-
const s = this.senders.find((x) => x.protocol === protocol);
|
|
83
|
-
if (!s) {
|
|
84
|
-
return this.senders.find((x) => x.protocol === host.getType());
|
|
60
|
+
const formatter = this.formatters.get(protocol) ?? this.formatters.get(host.getType());
|
|
61
|
+
if (formatter) {
|
|
62
|
+
this.logger.trace(`Found formatter: ${formatter.constructor.name}`);
|
|
63
|
+
return formatter;
|
|
85
64
|
}
|
|
86
|
-
|
|
65
|
+
this.logger.warn((0, common_2.text) `
|
|
66
|
+
No formatter for protocol = ${protocol}
|
|
67
|
+
(hostType = ${host.getType()})`);
|
|
68
|
+
return default_formatter_1.DEFAULT_FORMATTER;
|
|
87
69
|
}
|
|
88
70
|
};
|
|
89
71
|
exports.GlobalExceptionsFilter = GlobalExceptionsFilter;
|
|
90
72
|
exports.GlobalExceptionsFilter = GlobalExceptionsFilter = __decorate([
|
|
91
73
|
(0, common_1.Catch)(),
|
|
92
|
-
__param(0, (0, common_1.Inject)(constants_1.
|
|
93
|
-
__param(1, (0, common_1.Inject)(constants_1.
|
|
94
|
-
__param(2, (0,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
74
|
+
__param(0, (0, common_1.Inject)(constants_1.SENDERS)),
|
|
75
|
+
__param(1, (0, common_1.Inject)(constants_1.FORMATTERS)),
|
|
76
|
+
__param(2, (0, logging_1.InjectLogger)(GlobalExceptionsFilter)),
|
|
77
|
+
__metadata("design:paramtypes", [Map,
|
|
78
|
+
Map, Object, protocol_detector_1.ProtocolDetector,
|
|
79
|
+
global_exceptions_config_1.GlobalExceptionsConfig])
|
|
98
80
|
], GlobalExceptionsFilter);
|
|
99
81
|
//# sourceMappingURL=global-exceptions.filter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-exceptions.filter.js","sourceRoot":"","sources":["../../src/exceptions.handling/global-exceptions.filter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,2CAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"global-exceptions.filter.js","sourceRoot":"","sources":["../../src/exceptions.handling/global-exceptions.filter.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
|
|
2
|
+
import type { Observable } from 'rxjs';
|
|
3
|
+
import type { IErrorsTransformer } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Обработка ошибки состоит из трёх этапов:
|
|
6
|
+
* 1. Трансформация ошибки в PipelineException
|
|
7
|
+
* 2. Логирование ошибки
|
|
8
|
+
* 3. Отправка ошибки клиенту, в зависимости от транспорта.
|
|
9
|
+
*
|
|
10
|
+
* Этот интерцептор отвечает за 1-й этап. Важно, что в пайплайне обработки
|
|
11
|
+
* он должен стоять перед LoggingInterceptor, который обеспечивает логирование
|
|
12
|
+
*/
|
|
13
|
+
export declare class GlobalExceptionsInterceptor implements NestInterceptor {
|
|
14
|
+
private readonly transformers;
|
|
15
|
+
constructor(transformers: IErrorsTransformer[]);
|
|
16
|
+
intercept(_: ExecutionContext, next: CallHandler<any>): Observable<any> | Promise<Observable<any>>;
|
|
17
|
+
private transform;
|
|
18
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.GlobalExceptionsInterceptor = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const rxjs_1 = require("rxjs");
|
|
18
|
+
const exceptions_1 = require("../exceptions");
|
|
19
|
+
const constants_1 = require("./constants");
|
|
20
|
+
/**
|
|
21
|
+
* Обработка ошибки состоит из трёх этапов:
|
|
22
|
+
* 1. Трансформация ошибки в PipelineException
|
|
23
|
+
* 2. Логирование ошибки
|
|
24
|
+
* 3. Отправка ошибки клиенту, в зависимости от транспорта.
|
|
25
|
+
*
|
|
26
|
+
* Этот интерцептор отвечает за 1-й этап. Важно, что в пайплайне обработки
|
|
27
|
+
* он должен стоять перед LoggingInterceptor, который обеспечивает логирование
|
|
28
|
+
*/
|
|
29
|
+
let GlobalExceptionsInterceptor = class GlobalExceptionsInterceptor {
|
|
30
|
+
transformers;
|
|
31
|
+
constructor(transformers) {
|
|
32
|
+
this.transformers = transformers;
|
|
33
|
+
}
|
|
34
|
+
intercept(_, next) {
|
|
35
|
+
return next.handle().pipe((0, rxjs_1.catchError)((error) => {
|
|
36
|
+
// Error is transformed to standard PipelineException
|
|
37
|
+
const transformed = error instanceof exceptions_1.PipelineException ? error : this.transform(error);
|
|
38
|
+
return (0, rxjs_1.throwError)(() => transformed);
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
transform(ex) {
|
|
42
|
+
const transformer = this.transformers.find((x) => x.match(ex));
|
|
43
|
+
if (transformer) {
|
|
44
|
+
return transformer.transform(ex);
|
|
45
|
+
}
|
|
46
|
+
const err = new exceptions_1.InternalException(ex.message ?? 'UNKNOWN ERROR', ex);
|
|
47
|
+
err.stack = ex.stack;
|
|
48
|
+
return err;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
exports.GlobalExceptionsInterceptor = GlobalExceptionsInterceptor;
|
|
52
|
+
exports.GlobalExceptionsInterceptor = GlobalExceptionsInterceptor = __decorate([
|
|
53
|
+
(0, common_1.Injectable)(),
|
|
54
|
+
__param(0, (0, common_1.Inject)(constants_1.TRANSFORMERS)),
|
|
55
|
+
__metadata("design:paramtypes", [Array])
|
|
56
|
+
], GlobalExceptionsInterceptor);
|
|
57
|
+
//# sourceMappingURL=global-exceptions.interceptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-exceptions.interceptor.js","sourceRoot":"","sources":["../../src/exceptions.handling/global-exceptions.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,2CAAoD;AAEpD,+BAA8C;AAE9C,8CAAqE;AAErE,2CAA2C;AAG3C;;;;;;;;GAQG;AAEI,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IAEG;IADzC,YACyC,YAAkC;QAAlC,iBAAY,GAAZ,YAAY,CAAsB;IACxE,CAAC;IAEJ,SAAS,CACP,CAAmB,EACnB,IAAsB;QAEtB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACvB,IAAA,iBAAU,EAAC,CAAC,KAAK,EAAE,EAAE;YACnB,qDAAqD;YACrD,MAAM,WAAW,GACf,KAAK,YAAY,8BAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YAErE,OAAO,IAAA,iBAAU,EAAC,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC;QACvC,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;IAEO,SAAS,CAAC,EAAO;QACvB,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;QAC/D,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QACnC,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,8BAAiB,CAAC,EAAE,CAAC,OAAO,IAAI,eAAe,EAAE,EAAE,CAAC,CAAC;QAErE,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC;QAErB,OAAO,GAAG,CAAC;IACb,CAAC;CACF,CAAA;AAhCY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,wBAAY,CAAC,CAAA;;GAFZ,2BAA2B,CAgCvC"}
|
|
@@ -1,26 +1,5 @@
|
|
|
1
1
|
import type { DynamicModule } from '@nestjs/common';
|
|
2
|
-
import
|
|
3
|
-
export interface GlobalExceptionModuleOptions {
|
|
4
|
-
/**
|
|
5
|
-
* Formatters are used to transform exceptions to transport specific
|
|
6
|
-
* final implementations. Usually formatter expects transport agnostic
|
|
7
|
-
* subclasses of BaseException.
|
|
8
|
-
*/
|
|
9
|
-
formatters: IErrorsFormatter[];
|
|
10
|
-
/**
|
|
11
|
-
* Senders are used to actually respond to client (algorithm
|
|
12
|
-
* is transport specific)
|
|
13
|
-
*/
|
|
14
|
-
senders: IErrorsSender[];
|
|
15
|
-
/**
|
|
16
|
-
* Sometimes application throws a lot of unconventional
|
|
17
|
-
* (not inheriting BaseExceptions). Usually they are throw by
|
|
18
|
-
* libraries: typeorm, axios, etc. Transformers are used to
|
|
19
|
-
* catch them and convert to any subtype of BaseException which
|
|
20
|
-
* will be processed further by transport specific formatters.
|
|
21
|
-
*/
|
|
22
|
-
transformers?: IErrorsTransformer[];
|
|
23
|
-
}
|
|
2
|
+
import { PlatformExtendedOptions } from '../types';
|
|
24
3
|
export declare class GlobalExceptionsModule {
|
|
25
|
-
static forRoot(options:
|
|
4
|
+
static forRoot(options: PlatformExtendedOptions): DynamicModule;
|
|
26
5
|
}
|
|
@@ -12,26 +12,61 @@ const common_1 = require("@nestjs/common");
|
|
|
12
12
|
const core_1 = require("@nestjs/core");
|
|
13
13
|
const constants_1 = require("./constants");
|
|
14
14
|
const global_exceptions_filter_1 = require("./global-exceptions.filter");
|
|
15
|
+
const global_exceptions_interceptor_1 = require("./global-exceptions.interceptor");
|
|
15
16
|
let GlobalExceptionsModule = GlobalExceptionsModule_1 = class GlobalExceptionsModule {
|
|
16
17
|
static forRoot(options) {
|
|
18
|
+
const entities = [
|
|
19
|
+
...(options.transports || []),
|
|
20
|
+
...(options.plugins || []),
|
|
21
|
+
];
|
|
22
|
+
/**
|
|
23
|
+
* Formatters are used to transform exceptions to transport specific
|
|
24
|
+
* final implementations. Usually formatter expects transport agnostic
|
|
25
|
+
* subclasses of BaseException.
|
|
26
|
+
*/
|
|
27
|
+
const formatters = entities
|
|
28
|
+
.flatMap((x) => x.errorFormatter?.() || [])
|
|
29
|
+
.reduce((acc, x) => acc.set(x.protocol, x), new Map());
|
|
30
|
+
/**
|
|
31
|
+
* Senders are used to actually respond to client (algorithm
|
|
32
|
+
* is transport specific)
|
|
33
|
+
*/
|
|
34
|
+
const senders = entities
|
|
35
|
+
.flatMap((x) => x.errorSender?.() || [])
|
|
36
|
+
.reduce((acc, x) => acc.set(x.protocol, x), new Map());
|
|
37
|
+
/**
|
|
38
|
+
* Sometimes application throws a lot of unconventional
|
|
39
|
+
* (not inheriting BaseExceptions). Usually they are throw by
|
|
40
|
+
* libraries: typeorm, axios, etc. Transformers are used to
|
|
41
|
+
* catch them and convert to any subtype of BaseException which
|
|
42
|
+
* will be processed further by transport specific formatters.
|
|
43
|
+
*
|
|
44
|
+
* NOTE: Unlike formatters and senders, transformers can't be grouped
|
|
45
|
+
* by protocol, because their matchers are a bit more complex.
|
|
46
|
+
*/
|
|
47
|
+
const transformers = entities.flatMap((x) => x.errorTransformers?.() || []);
|
|
17
48
|
return {
|
|
18
49
|
module: GlobalExceptionsModule_1,
|
|
19
50
|
providers: [
|
|
51
|
+
{
|
|
52
|
+
provide: core_1.APP_INTERCEPTOR,
|
|
53
|
+
useClass: global_exceptions_interceptor_1.GlobalExceptionsInterceptor,
|
|
54
|
+
},
|
|
20
55
|
{
|
|
21
56
|
provide: core_1.APP_FILTER,
|
|
22
57
|
useClass: global_exceptions_filter_1.GlobalExceptionsFilter,
|
|
23
58
|
},
|
|
24
59
|
{
|
|
25
60
|
provide: constants_1.FORMATTERS,
|
|
26
|
-
useValue:
|
|
61
|
+
useValue: formatters,
|
|
27
62
|
},
|
|
28
63
|
{
|
|
29
64
|
provide: constants_1.SENDERS,
|
|
30
|
-
useValue:
|
|
65
|
+
useValue: senders,
|
|
31
66
|
},
|
|
32
67
|
{
|
|
33
68
|
provide: constants_1.TRANSFORMERS,
|
|
34
|
-
useValue:
|
|
69
|
+
useValue: transformers,
|
|
35
70
|
},
|
|
36
71
|
],
|
|
37
72
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-exceptions.module.js","sourceRoot":"","sources":["../../src/exceptions.handling/global-exceptions.module.ts"],"names":[],"mappings":";;;;;;;;;;AACA,2CAAwC;AACxC,
|
|
1
|
+
{"version":3,"file":"global-exceptions.module.js","sourceRoot":"","sources":["../../src/exceptions.handling/global-exceptions.module.ts"],"names":[],"mappings":";;;;;;;;;;AACA,2CAAwC;AACxC,uCAA2D;AAI3D,2CAAgE;AAChE,yEAAoE;AACpE,mFAA8E;AAIvE,IAAM,sBAAsB,8BAA5B,MAAM,sBAAsB;IACjC,MAAM,CAAC,OAAO,CAAC,OAAgC;QAC7C,MAAM,QAAQ,GAAG;YACf,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC;YAC7B,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;SAC3B,CAAC;QAEF;;;;WAIG;QACH,MAAM,UAAU,GAAkC,QAAQ;aACvD,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,CAAC;aAC1C,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QAEzD;;;WAGG;QACH,MAAM,OAAO,GAA+B,QAAQ;aACjD,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC;aACvC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QAEzD;;;;;;;;;WASG;QACH,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QAE5E,OAAO;YACL,MAAM,EAAE,wBAAsB;YAC9B,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,sBAAe;oBACxB,QAAQ,EAAE,2DAA2B;iBACtC;gBACD;oBACE,OAAO,EAAE,iBAAU;oBACnB,QAAQ,EAAE,iDAAsB;iBACjC;gBACD;oBACE,OAAO,EAAE,sBAAU;oBACnB,QAAQ,EAAE,UAAU;iBACrB;gBACD;oBACE,OAAO,EAAE,mBAAO;oBAChB,QAAQ,EAAE,OAAO;iBAClB;gBACD;oBACE,OAAO,EAAE,wBAAY;oBACrB,QAAQ,EAAE,YAAY;iBACvB;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA9DY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,sBAAsB,CA8DlC"}
|
|
@@ -3,7 +3,7 @@ import type { EMPTY, Observable } from 'rxjs';
|
|
|
3
3
|
import type { PipelineException } from '../exceptions/base';
|
|
4
4
|
/**
|
|
5
5
|
* Errors formatter is used to map transport-agnostic
|
|
6
|
-
*
|
|
6
|
+
* business exception to transport-specific on (with appropriate
|
|
7
7
|
* status code and other attributes)
|
|
8
8
|
*
|
|
9
9
|
* @implementme Implement this interface if you need to create a
|
|
@@ -66,7 +66,7 @@ export interface IErrorsTransformer {
|
|
|
66
66
|
*/
|
|
67
67
|
match(ex: any): boolean;
|
|
68
68
|
/**
|
|
69
|
-
*
|
|
69
|
+
* Transformation algorithm
|
|
70
70
|
*
|
|
71
71
|
* @param ex Exception itself
|
|
72
72
|
*/
|