@rsdk/core 5.7.0-next.3 → 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
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./timespan.parser"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/config/parsers/timespan/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TimespanParser = void 0;
|
|
4
|
-
const common_1 = require("@rsdk/common");
|
|
5
|
-
class TimespanParser {
|
|
6
|
-
type() {
|
|
7
|
-
return 'Timespan';
|
|
8
|
-
}
|
|
9
|
-
description() {
|
|
10
|
-
return (0, common_1.text) `
|
|
11
|
-
Parses string in timespan format into Timespan instance.
|
|
12
|
-
Format is: ${common_1.TIMESPAN_STRING_PATTERN}. For example: 1s, 2h, 4d.
|
|
13
|
-
`;
|
|
14
|
-
}
|
|
15
|
-
parse(value) {
|
|
16
|
-
common_1.Assert.isString(value);
|
|
17
|
-
return common_1.Timespan.parse(value);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.TimespanParser = TimespanParser;
|
|
21
|
-
//# sourceMappingURL=timespan.parser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timespan.parser.js","sourceRoot":"","sources":["../../../../src/config/parsers/timespan/timespan.parser.ts"],"names":[],"mappings":";;;AAAA,yCAA+E;AAI/E,MAAa,cAAc;IACzB,IAAI;QACF,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,WAAW;QACT,OAAO,IAAA,aAAI,EAAA;;mBAEI,gCAAuB;KACrC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,KAAc;QAClB,eAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAEvB,OAAO,iBAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;CACF;AAjBD,wCAiBC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { BootstrapException } from '../../../exceptions';
|
|
2
|
-
export declare class InvalidUrl extends BootstrapException {
|
|
3
|
-
constructor(str: string, cause: unknown);
|
|
4
|
-
}
|
|
5
|
-
export declare class InvalidProtocol extends BootstrapException {
|
|
6
|
-
constructor(expectedProtocols: string[], protocol: string, url: URL);
|
|
7
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InvalidProtocol = exports.InvalidUrl = void 0;
|
|
4
|
-
const exceptions_1 = require("../../../exceptions");
|
|
5
|
-
class InvalidUrl extends exceptions_1.BootstrapException {
|
|
6
|
-
constructor(str, cause) {
|
|
7
|
-
super(`Invalid url string: <${str}>`, {
|
|
8
|
-
cause,
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.InvalidUrl = InvalidUrl;
|
|
13
|
-
class InvalidProtocol extends exceptions_1.BootstrapException {
|
|
14
|
-
constructor(expectedProtocols, protocol, url) {
|
|
15
|
-
super(`Invalid protocol: <${protocol}>, expected: ${expectedProtocols}`, {
|
|
16
|
-
details: {
|
|
17
|
-
protocol,
|
|
18
|
-
url,
|
|
19
|
-
expected: expectedProtocols,
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.InvalidProtocol = InvalidProtocol;
|
|
25
|
-
//# sourceMappingURL=exception.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exception.js","sourceRoot":"","sources":["../../../../src/config/parsers/url/exception.ts"],"names":[],"mappings":";;;AAAA,oDAAyD;AAEzD,MAAa,UAAW,SAAQ,+BAAkB;IAChD,YAAY,GAAW,EAAE,KAAc;QACrC,KAAK,CAAC,wBAAwB,GAAG,GAAG,EAAE;YACpC,KAAK;SACN,CAAC,CAAC;IACL,CAAC;CACF;AAND,gCAMC;AAED,MAAa,eAAgB,SAAQ,+BAAkB;IACrD,YAAY,iBAA2B,EAAE,QAAgB,EAAE,GAAQ;QACjE,KAAK,CAAC,sBAAsB,QAAQ,gBAAgB,iBAAiB,EAAE,EAAE;YACvE,OAAO,EAAE;gBACP,QAAQ;gBACR,GAAG;gBACH,QAAQ,EAAE,iBAAiB;aAC5B;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAVD,0CAUC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.InvalidUrl = void 0;
|
|
18
|
-
__exportStar(require("./url.parser"), exports);
|
|
19
|
-
var exception_1 = require("./exception");
|
|
20
|
-
Object.defineProperty(exports, "InvalidUrl", { enumerable: true, get: function () { return exception_1.InvalidUrl; } });
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/config/parsers/url/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,yCAAyC;AAAhC,uGAAA,UAAU,OAAA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { PropertyParser } from '../../types';
|
|
2
|
-
export declare class UrlParser implements PropertyParser<URL> {
|
|
3
|
-
private readonly protocols;
|
|
4
|
-
constructor(...protocols: string[]);
|
|
5
|
-
type(): string;
|
|
6
|
-
description(): string;
|
|
7
|
-
parse(value: unknown): URL;
|
|
8
|
-
private assertProtocol;
|
|
9
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UrlParser = void 0;
|
|
4
|
-
const common_1 = require("@rsdk/common");
|
|
5
|
-
const exception_1 = require("./exception");
|
|
6
|
-
class UrlParser {
|
|
7
|
-
protocols;
|
|
8
|
-
constructor(...protocols) {
|
|
9
|
-
this.protocols = protocols;
|
|
10
|
-
}
|
|
11
|
-
type() {
|
|
12
|
-
return 'URL';
|
|
13
|
-
}
|
|
14
|
-
description() {
|
|
15
|
-
return 'Parses string into instance of URL';
|
|
16
|
-
}
|
|
17
|
-
parse(value) {
|
|
18
|
-
common_1.Assert.isString(value);
|
|
19
|
-
try {
|
|
20
|
-
const url = new URL(value);
|
|
21
|
-
this.assertProtocol(url);
|
|
22
|
-
return url;
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
throw new exception_1.InvalidUrl(value, error);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
assertProtocol(url) {
|
|
29
|
-
if (this.protocols.length === 0) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
if (!this.protocols.includes(url.protocol)) {
|
|
33
|
-
throw new exception_1.InvalidProtocol(this.protocols, url.protocol, url);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.UrlParser = UrlParser;
|
|
38
|
-
//# sourceMappingURL=url.parser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"url.parser.js","sourceRoot":"","sources":["../../../../src/config/parsers/url/url.parser.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AAItC,2CAA0D;AAE1D,MAAa,SAAS;IACH,SAAS,CAAW;IAErC,YAAY,GAAG,SAAmB;QAChC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,IAAI;QACF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,WAAW;QACT,OAAO,oCAAoC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,KAAc;QAClB,eAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAEvB,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;YAE3B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;YACzB,OAAO,GAAG,CAAC;QACb,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,sBAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAEO,cAAc,CAAC,GAAQ;QAC7B,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAChC,OAAO;QACT,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,2BAAe,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;CACF;AArCD,8BAqCC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger-initializing.module.js","sourceRoot":"","sources":["../../src/logging/logger-initializing.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwC;AACxC,2CAA8C;AAE9C,gDAAwB;AAExB,qDAAiD;AAG1C,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;;IAC3B,MAAM,CAAC,MAAM,GAAG,uBAAa,CAAC,MAAM,CAAC,0BAAwB,CAAC,CAAC;IAEvE,YAAY,MAAqB;QAC/B,MAAM,GAAG,GAAG,GAAS,EAAE;YACrB,0BAAwB,CAAC,MAAM,CAAC,IAAI,CAClC,uBAAuB,MAAM,CAAC,KAAK,GAAG,EACtC;gBACE,QAAQ,EAAE,MAAM,CAAC,KAAK;aACvB,CACF,CAAC;YAEF,uBAAa,CAAC,WAAW,CAAC;gBACxB,GAAG,MAAM;gBACT,MAAM,EAAE,cAAI,CAAC,SAAS,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;aAC3D,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACrB,GAAG,EAAE,CAAC;IACR,CAAC;IAEO,qBAAqB,CAAC,MAAqB;QACjD,MAAM,OAAO,GAA6B;YACxC;gBACE,MAAM,EAAE,WAAW;gBACnB,OAAO,EAAE,EAAE,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE;gBAC3C,KAAK,EAAE,MAAM,CAAC,KAAK;aACpB;SACF,CAAC;QAEF,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;YACvB,OAAO,CAAC,IAAI,CAAC;gBACX,MAAM,EAAE,8BAA8B;gBAEtC;;;mBAGG;gBACH,OAAO,EAAE,EAAE;gBACX,KAAK,EAAE,MAAM,CAAC,KAAK;aACpB,CAAC,CAAC;QACL,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;;AA7CU,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,eAAM,EAAC,EAAE,CAAC;qCAIW,8BAAa;GAHtB,wBAAwB,CA8CpC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logging.module.js","sourceRoot":"","sources":["../../src/logging/logging.module.ts"],"names":[],"mappings":";AAAA,8BAA8B;;;;;;;;;;AAG9B,2CAAwC;AAExC,2CAA8C;AAE9C,6CAGwB;AAExB,oDAAmE;AACnE,uCAA2C;AAIpC,IAAM,aAAa,qBAAnB,MAAM,aAAa;IACxB,MAAM,CAAC,QAAQ,CACb,MAAc,EACd,OAA6B,EAC7B,KAAK,GAAG,IAAA,wBAAc,EAAC,OAAO,CAAC;QAE/B,uBAAY,CAAC,GAAG,CACd,MAAM,EACN,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,EAC/B,6CAAkC,CACnC,CAAC;QAEF,uBAAY,CAAC,GAAG,CACd,MAAM,EACN;YACE,OAAO;YACP,KAAK;YACL,MAAM;SACP,EACD,uCAA2B,CAC5B,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,MAAM,CAAC,UAAU,CACf,OAA6B,EAC7B,KAAK,GAAG,IAAA,wBAAc,EAAC,OAAO,CAAC;QAE/B,OAAO;YACL,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,eAAa;YACrB,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,KAAK;oBACd,QAAQ,EAAE,uBAAa,CAAC,MAAM,CAAC,OAAO,CAAC;iBACxC;aACF;YACD,OAAO,EAAE,CAAC,KAAK,CAAC;SACjB,CAAC;IACJ,CAAC;CACF,CAAA;AApEY,sCAAa;wBAAb,aAAa;IADzB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,aAAa,CAoEzB"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Assert, text } from '@rsdk/common';
|
|
2
|
-
|
|
3
|
-
import type { PropertyParser } from '../../types';
|
|
4
|
-
|
|
5
|
-
export class ArrayParser<T> implements PropertyParser<T[]> {
|
|
6
|
-
constructor(
|
|
7
|
-
private readonly singleValueParser: PropertyParser<T>,
|
|
8
|
-
private readonly options = { separator: ',' },
|
|
9
|
-
) {}
|
|
10
|
-
|
|
11
|
-
type(): string {
|
|
12
|
-
return `(array)${this.singleValueParser.type()}`;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
description(): string {
|
|
16
|
-
return text`
|
|
17
|
-
Extracts array of values. If raw value is a string
|
|
18
|
-
<${this.options.separator}> will used as separator. Each value:
|
|
19
|
-
${this.singleValueParser.description()}
|
|
20
|
-
`;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
parse(value: unknown): T[] {
|
|
24
|
-
if (Array.isArray(value)) {
|
|
25
|
-
return value.map((x) => this.singleValueParser.parse(x));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
Assert.isString(value);
|
|
29
|
-
|
|
30
|
-
return value
|
|
31
|
-
.split(this.options.separator)
|
|
32
|
-
.map((x) => this.singleValueParser.parse(x));
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './array.parser';
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Convert, text } from '@rsdk/common';
|
|
2
|
-
|
|
3
|
-
import type { PropertyParser } from '../../types';
|
|
4
|
-
|
|
5
|
-
export class BoolParser implements PropertyParser<boolean> {
|
|
6
|
-
type(): string {
|
|
7
|
-
return 'boolean';
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
description(): string {
|
|
11
|
-
return text`
|
|
12
|
-
Extracts boolean value. Any boolean value or strings
|
|
13
|
-
'true' and 'false' will pass.
|
|
14
|
-
`;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
parse(value: unknown): boolean {
|
|
18
|
-
return Convert.boolean(value);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './bool.parser';
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { EnumLike, EnumValue } from '@rsdk/common';
|
|
2
|
-
import { Convert, Enum, text } from '@rsdk/common';
|
|
3
|
-
|
|
4
|
-
import type { PropertyParser } from '../../types';
|
|
5
|
-
|
|
6
|
-
export class EnumParser<E extends EnumValue> implements PropertyParser<E> {
|
|
7
|
-
constructor(private readonly enumeration: EnumLike) {}
|
|
8
|
-
|
|
9
|
-
type(): string {
|
|
10
|
-
return `string|number(enum_value)`;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
description(): string {
|
|
14
|
-
return text`
|
|
15
|
-
Extracts strings or numbers and ensures it is one of:
|
|
16
|
-
${Enum.values(this.enumeration).join(', ')}
|
|
17
|
-
`;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
parse(value: unknown): E {
|
|
21
|
-
return Convert.enum<E>(value, this.enumeration);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './enum.parser';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export * from './boolean';
|
|
2
|
-
export * from './enum';
|
|
3
|
-
export * from './int';
|
|
4
|
-
export * from './number';
|
|
5
|
-
export * from './path';
|
|
6
|
-
export * from './size';
|
|
7
|
-
export * from './string';
|
|
8
|
-
export * from './timespan';
|
|
9
|
-
export * from './url';
|
|
10
|
-
export * from './array/';
|
|
11
|
-
export * from './json/';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './int.parser';
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Convert, text } from '@rsdk/common';
|
|
2
|
-
|
|
3
|
-
import type { PropertyParser } from '../../types';
|
|
4
|
-
|
|
5
|
-
export class IntParser implements PropertyParser<number> {
|
|
6
|
-
type(): string {
|
|
7
|
-
return 'number(int)';
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
description(): string {
|
|
11
|
-
return text`
|
|
12
|
-
Extracts valid integer (uses parseInt under the hood).
|
|
13
|
-
Floating point numbers, NaN, Infinity will be rejected.
|
|
14
|
-
`;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
parse(value: unknown): number {
|
|
18
|
-
return Convert.int(value);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './json.parser';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { PropertyParser } from '../../types';
|
|
2
|
-
|
|
3
|
-
export class JsonParser implements PropertyParser<Record<string, any>> {
|
|
4
|
-
description(): string {
|
|
5
|
-
return 'parse string as json';
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
parse(value: string): Record<string, any> {
|
|
9
|
-
return JSON.parse(value);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
type(): string {
|
|
13
|
-
return 'json';
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './number.parser';
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Convert, text } from '@rsdk/common';
|
|
2
|
-
|
|
3
|
-
import type { PropertyParser } from '../../types';
|
|
4
|
-
|
|
5
|
-
export class NumberParser implements PropertyParser<number> {
|
|
6
|
-
type(): string {
|
|
7
|
-
return 'number';
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
description(): string {
|
|
11
|
-
return text`
|
|
12
|
-
Extracts numeric value (uses parseFloat under the hood).
|
|
13
|
-
NaN and Infinity will be rejected.
|
|
14
|
-
|
|
15
|
-
NOTE: Use correct decimal delimiter according to locale. See
|
|
16
|
-
https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Intl
|
|
17
|
-
`;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
parse(value: unknown): number {
|
|
21
|
-
return Convert.number(value);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Assert, text } from '@rsdk/common';
|
|
2
|
-
import { accessSync, existsSync, lstatSync } from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { cwd } from 'node:process';
|
|
5
|
-
|
|
6
|
-
import type { PropertyParser } from '../../types';
|
|
7
|
-
|
|
8
|
-
export class FsPathParser implements PropertyParser<string> {
|
|
9
|
-
constructor(private readonly objectType: 'file' | 'dir') {}
|
|
10
|
-
|
|
11
|
-
type(): string {
|
|
12
|
-
return 'string(fs_path)';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
description(): string {
|
|
16
|
-
return text`
|
|
17
|
-
Extracts path to file or directory. Checks that object exists on
|
|
18
|
-
file system and that application has access to it.
|
|
19
|
-
`;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
parse(value: unknown): string {
|
|
23
|
-
Assert.isString(value);
|
|
24
|
-
|
|
25
|
-
const wasRelative = !path.isAbsolute(value);
|
|
26
|
-
const absolutePath = wasRelative ? path.join(cwd(), value) : value;
|
|
27
|
-
|
|
28
|
-
if (!existsSync(absolutePath)) {
|
|
29
|
-
const warning = wasRelative
|
|
30
|
-
? ' Since you have used relative path, check you current working directory is repos root.'
|
|
31
|
-
: '';
|
|
32
|
-
|
|
33
|
-
throw new Error(
|
|
34
|
-
`File or directory <${absolutePath}> not found!${warning}`,
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
accessSync(absolutePath);
|
|
40
|
-
} catch {
|
|
41
|
-
throw new Error(`Can't access <${absolutePath}>!`);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const stat = lstatSync(absolutePath);
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Otherwise we'll have problems with IsNotDirectoryException
|
|
48
|
-
* when using symlinks.
|
|
49
|
-
*/
|
|
50
|
-
if (stat.isSymbolicLink()) {
|
|
51
|
-
return absolutePath;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (this.objectType === 'dir' && !stat.isDirectory()) {
|
|
55
|
-
throw new Error(`<${absolutePath}> is not a directory!`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (this.objectType === 'file' && !stat.isFile()) {
|
|
59
|
-
throw new Error(`<${absolutePath}> is not a file!`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return absolutePath;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './fspath.parser';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './size.parser';
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Assert, Size, SIZE_STRING_PATTERN, text } from '@rsdk/common';
|
|
2
|
-
|
|
3
|
-
import type { PropertyParser } from '../../types';
|
|
4
|
-
|
|
5
|
-
export class SizeParser implements PropertyParser<Size> {
|
|
6
|
-
type(): string {
|
|
7
|
-
return 'Timespan';
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
description(): string {
|
|
11
|
-
return text`
|
|
12
|
-
Parses string in size format into Timespan instance.
|
|
13
|
-
Format is: ${SIZE_STRING_PATTERN}. For example: 8b, 10kb, 2gb.
|
|
14
|
-
`;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
parse(value: unknown): Size {
|
|
18
|
-
Assert.isString(value);
|
|
19
|
-
|
|
20
|
-
return Size.parse(value);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './string.parser';
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Assert } from '@rsdk/common';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
|
|
4
|
-
import type { PropertyParser } from '../../types';
|
|
5
|
-
|
|
6
|
-
export class StringParser implements PropertyParser<string> {
|
|
7
|
-
constructor(private readonly pattern?: RegExp) {}
|
|
8
|
-
|
|
9
|
-
type(): string {
|
|
10
|
-
return 'string';
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
description(): string {
|
|
14
|
-
return 'Extract arbitrary string.';
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
parse(value: unknown): string {
|
|
18
|
-
Assert.isString(value);
|
|
19
|
-
|
|
20
|
-
if (this.pattern) {
|
|
21
|
-
assert(this.pattern.test(value));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return value;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { StringParser } from './string.parser';
|
|
2
|
-
|
|
3
|
-
describe('StringMatcher', () => {
|
|
4
|
-
it('match', () => {
|
|
5
|
-
const parser = new StringParser(/^[a-z]+$/);
|
|
6
|
-
|
|
7
|
-
expect(parser.parse('abcd')).toBe('abcd');
|
|
8
|
-
expect(() => parser.parse('1234')).toThrow();
|
|
9
|
-
});
|
|
10
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './timespan.parser';
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Assert, text, Timespan, TIMESPAN_STRING_PATTERN } from '@rsdk/common';
|
|
2
|
-
|
|
3
|
-
import type { PropertyParser } from '../../types';
|
|
4
|
-
|
|
5
|
-
export class TimespanParser implements PropertyParser<Timespan> {
|
|
6
|
-
type(): string {
|
|
7
|
-
return 'Timespan';
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
description(): string {
|
|
11
|
-
return text`
|
|
12
|
-
Parses string in timespan format into Timespan instance.
|
|
13
|
-
Format is: ${TIMESPAN_STRING_PATTERN}. For example: 1s, 2h, 4d.
|
|
14
|
-
`;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
parse(value: unknown): Timespan {
|
|
18
|
-
Assert.isString(value);
|
|
19
|
-
|
|
20
|
-
return Timespan.parse(value);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { BootstrapException } from '../../../exceptions';
|
|
2
|
-
|
|
3
|
-
export class InvalidUrl extends BootstrapException {
|
|
4
|
-
constructor(str: string, cause: unknown) {
|
|
5
|
-
super(`Invalid url string: <${str}>`, {
|
|
6
|
-
cause,
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class InvalidProtocol extends BootstrapException {
|
|
12
|
-
constructor(expectedProtocols: string[], protocol: string, url: URL) {
|
|
13
|
-
super(`Invalid protocol: <${protocol}>, expected: ${expectedProtocols}`, {
|
|
14
|
-
details: {
|
|
15
|
-
protocol,
|
|
16
|
-
url,
|
|
17
|
-
expected: expectedProtocols,
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Assert } from '@rsdk/common';
|
|
2
|
-
|
|
3
|
-
import type { PropertyParser } from '../../types';
|
|
4
|
-
|
|
5
|
-
import { InvalidProtocol, InvalidUrl } from './exception';
|
|
6
|
-
|
|
7
|
-
export class UrlParser implements PropertyParser<URL> {
|
|
8
|
-
private readonly protocols: string[];
|
|
9
|
-
|
|
10
|
-
constructor(...protocols: string[]) {
|
|
11
|
-
this.protocols = protocols;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
type(): string {
|
|
15
|
-
return 'URL';
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
description(): string {
|
|
19
|
-
return 'Parses string into instance of URL';
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
parse(value: unknown): URL {
|
|
23
|
-
Assert.isString(value);
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
const url = new URL(value);
|
|
27
|
-
|
|
28
|
-
this.assertProtocol(url);
|
|
29
|
-
return url;
|
|
30
|
-
} catch (error) {
|
|
31
|
-
throw new InvalidUrl(value, error);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
private assertProtocol(url: URL): void {
|
|
36
|
-
if (this.protocols.length === 0) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (!this.protocols.includes(url.protocol)) {
|
|
41
|
-
throw new InvalidProtocol(this.protocols, url.protocol, url);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|