@rsdk/core 1.0.9 → 1.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/CHANGELOG.md +6 -0
- package/dist/app/platform.app.d.ts +2 -1
- package/dist/app/platform.app.js.map +1 -1
- package/dist/config/config.const.d.ts +13 -0
- package/dist/config/config.const.js +17 -0
- package/dist/config/config.const.js.map +1 -0
- package/dist/config/metadata/decorators/config-section.decorator.d.ts +4 -0
- package/dist/config/metadata/decorators/config-section.decorator.js.map +1 -1
- package/dist/config/types.d.ts +3 -1
- package/dist/exceptions.handling/global-exceptions.config.js +4 -1
- package/dist/exceptions.handling/global-exceptions.config.js.map +1 -1
- package/dist/health/autodoc/heath.autodoc-resolver.d.ts +16 -0
- package/dist/health/autodoc/heath.autodoc-resolver.js +24 -0
- package/dist/health/autodoc/heath.autodoc-resolver.js.map +1 -0
- package/dist/health/health.service.d.ts +2 -1
- package/dist/health/health.service.js.map +1 -1
- package/dist/health/index.d.ts +1 -0
- package/dist/health/index.js +3 -0
- package/dist/health/index.js.map +1 -1
- package/dist/health/metadata/indicator.decorator.d.ts +16 -0
- package/dist/health/metadata/indicator.decorator.js +21 -0
- package/dist/health/metadata/indicator.decorator.js.map +1 -1
- package/dist/health/metadata/indicators.registry.js +0 -3
- package/dist/health/metadata/indicators.registry.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/logging/logging.config.js +4 -1
- package/dist/logging/logging.config.js.map +1 -1
- package/dist/metrics/index.d.ts +2 -0
- package/dist/metrics/index.js +3 -1
- package/dist/metrics/index.js.map +1 -1
- package/dist/metrics/metadata/autodoc/metrics.autodoc-resolver.d.ts +8 -0
- package/dist/metrics/metadata/autodoc/metrics.autodoc-resolver.js +26 -0
- package/dist/metrics/metadata/autodoc/metrics.autodoc-resolver.js.map +1 -0
- package/dist/metrics/metadata/decorators/metric.decorator.d.ts +12 -5
- package/dist/metrics/metadata/decorators/metric.decorator.js.map +1 -1
- package/dist/metrics/metadata/index.d.ts +2 -0
- package/dist/metrics/metadata/index.js +3 -0
- package/dist/metrics/metadata/index.js.map +1 -1
- package/dist/metrics/metadata/types.d.ts +8 -0
- package/dist/metrics/metadata/types.js +3 -0
- package/dist/metrics/metadata/types.js.map +1 -0
- package/dist/metrics/metrics.config.js +5 -1
- package/dist/metrics/metrics.config.js.map +1 -1
- package/dist/metrics/metrics.module.js +15 -3
- package/dist/metrics/metrics.module.js.map +1 -1
- package/dist/platform.context.d.ts +5 -3
- package/dist/platform.context.js +31 -14
- package/dist/platform.context.js.map +1 -1
- package/dist/tracing/tracing.config.js +4 -1
- package/dist/tracing/tracing.config.js.map +1 -1
- package/dist/types/metadata.d.ts +7 -1
- package/dist/types/metadata.js.map +1 -1
- package/dist/types/options.d.ts +3 -1
- package/package.json +20 -18
- package/src/app/platform.app.ts +1 -1
- package/src/config/config.const.ts +13 -0
- package/src/config/metadata/decorators/config-section.decorator.ts +4 -0
- package/src/config/types.ts +3 -1
- package/src/exceptions.handling/global-exceptions.config.ts +4 -1
- package/src/health/autodoc/heath.autodoc-resolver.ts +33 -0
- package/src/health/health.service.ts +2 -1
- package/src/health/index.ts +1 -0
- package/src/health/metadata/indicator.decorator.ts +34 -0
- package/src/health/metadata/indicators.registry.ts +0 -4
- package/src/index.ts +2 -0
- package/src/logging/logging.config.ts +4 -1
- package/src/metrics/index.ts +2 -0
- package/src/metrics/metadata/autodoc/metrics.autodoc-resolver.ts +30 -0
- package/src/metrics/metadata/decorators/metric.decorator.ts +14 -6
- package/src/metrics/metadata/index.ts +3 -0
- package/src/metrics/metadata/types.ts +11 -0
- package/src/metrics/metrics.config.ts +5 -1
- package/src/metrics/metrics.module.ts +23 -2
- package/src/platform.context.ts +40 -21
- package/src/tracing/tracing.config.ts +4 -1
- package/src/types/metadata.ts +8 -1
- package/src/types/options.ts +3 -1
- package/tsconfig.json +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -2,18 +2,18 @@ import type { DynamicModule } from '@nestjs/common';
|
|
|
2
2
|
import type { INestApplication } from '@nestjs/common/interfaces';
|
|
3
3
|
import type { NestApplicationOptions } from '@nestjs/common/interfaces/nest-application-options.interface';
|
|
4
4
|
import type { AbstractHttpAdapter } from '@nestjs/core';
|
|
5
|
-
import type { PlatformAppMetadata, PlatformOptions } from './types';
|
|
5
|
+
import type { PlatformAppMetadata, PlatformExtendedOptions, PlatformOptions } from './types';
|
|
6
6
|
/**
|
|
7
7
|
* Агрегат для хранения опций приложения, а также методы для конфигурации и запуска приложения
|
|
8
8
|
*/
|
|
9
9
|
export declare class PlatformContext {
|
|
10
10
|
readonly options: PlatformOptions;
|
|
11
11
|
readonly logger: import("@rsdk/logging").ILogger;
|
|
12
|
-
readonly root: DynamicModule;
|
|
13
12
|
private microservices;
|
|
14
13
|
private readonly httpTransport;
|
|
15
14
|
private readonly httpAdapter;
|
|
16
|
-
private
|
|
15
|
+
private _extendedOptions;
|
|
16
|
+
private _root;
|
|
17
17
|
/**
|
|
18
18
|
* Создаёт контекст проводя базовые проверки
|
|
19
19
|
* - все транспорты совместимы между собой
|
|
@@ -23,6 +23,8 @@ export declare class PlatformContext {
|
|
|
23
23
|
* @param options
|
|
24
24
|
*/
|
|
25
25
|
constructor(options: PlatformOptions);
|
|
26
|
+
get root(): DynamicModule;
|
|
27
|
+
get extendedOptions(): PlatformExtendedOptions;
|
|
26
28
|
private static assertPluginCompatability;
|
|
27
29
|
private static assertTransportCompatability;
|
|
28
30
|
/**
|
package/dist/platform.context.js
CHANGED
|
@@ -16,11 +16,11 @@ const types_1 = require("./types");
|
|
|
16
16
|
class PlatformContext {
|
|
17
17
|
options;
|
|
18
18
|
logger = logging_1.LoggerFactory.create('App');
|
|
19
|
-
root;
|
|
20
19
|
microservices;
|
|
21
20
|
httpTransport;
|
|
22
21
|
httpAdapter;
|
|
23
|
-
|
|
22
|
+
_extendedOptions;
|
|
23
|
+
_root;
|
|
24
24
|
/**
|
|
25
25
|
* Создаёт контекст проводя базовые проверки
|
|
26
26
|
* - все транспорты совместимы между собой
|
|
@@ -33,22 +33,35 @@ class PlatformContext {
|
|
|
33
33
|
this.options = options;
|
|
34
34
|
PlatformContext.assertTransportCompatability(options);
|
|
35
35
|
PlatformContext.assertPluginCompatability(options);
|
|
36
|
-
|
|
36
|
+
this.httpTransport = options.transports?.find?.(types_1.isHttpTransport);
|
|
37
|
+
this.httpAdapter =
|
|
38
|
+
this.httpTransport?.getAdapter() ?? new noop_http_adapter_1.NoopHttpAdapter();
|
|
39
|
+
}
|
|
40
|
+
get root() {
|
|
41
|
+
if (this._root) {
|
|
42
|
+
return this._root;
|
|
43
|
+
}
|
|
44
|
+
config_1.PlatformConfigModule.bootstrap({
|
|
45
|
+
...(this.extendedOptions.config ?? {}),
|
|
46
|
+
appName: this.extendedOptions.name,
|
|
47
|
+
});
|
|
48
|
+
this._root = platform_module_1.PlatformModule.forRoot(this.extendedOptions);
|
|
49
|
+
return this._root;
|
|
50
|
+
}
|
|
51
|
+
get extendedOptions() {
|
|
52
|
+
if (this._extendedOptions) {
|
|
53
|
+
return this._extendedOptions;
|
|
54
|
+
}
|
|
55
|
+
const manifestData = manifest_1.Manifest.getData(this.options.manifestPath);
|
|
56
|
+
const { name, description, version } = manifestData;
|
|
37
57
|
const extendedOptions = {
|
|
38
58
|
description,
|
|
39
59
|
name,
|
|
40
60
|
version,
|
|
41
|
-
...options,
|
|
61
|
+
...this.options,
|
|
42
62
|
};
|
|
43
|
-
this.
|
|
44
|
-
|
|
45
|
-
...(extendedOptions.config ?? {}),
|
|
46
|
-
appName: extendedOptions.name,
|
|
47
|
-
});
|
|
48
|
-
this.httpTransport = options.transports?.find?.(types_1.isHttpTransport);
|
|
49
|
-
this.httpAdapter =
|
|
50
|
-
this.httpTransport?.getAdapter() ?? new noop_http_adapter_1.NoopHttpAdapter();
|
|
51
|
-
this.root = platform_module_1.PlatformModule.forRoot(this.extendedOptions);
|
|
63
|
+
this._extendedOptions = extendedOptions;
|
|
64
|
+
return this._extendedOptions;
|
|
52
65
|
}
|
|
53
66
|
static assertPluginCompatability(options) {
|
|
54
67
|
if (!options.plugins) {
|
|
@@ -82,11 +95,15 @@ class PlatformContext {
|
|
|
82
95
|
const protocols = (options?.transports ?? []).map((x) => x.getProtocol());
|
|
83
96
|
return {
|
|
84
97
|
name: options.name,
|
|
98
|
+
version: options.version,
|
|
85
99
|
description: options.description,
|
|
86
100
|
protocols: protocols,
|
|
87
101
|
config: {
|
|
88
102
|
prefix: options.name,
|
|
89
|
-
sections: [...confMetadata.sections.
|
|
103
|
+
sections: [...confMetadata.sections.entries()].map(([section, metadata]) => (0, types_1.transformSectionMetadata)({
|
|
104
|
+
...metadata,
|
|
105
|
+
constructorName: section.name,
|
|
106
|
+
})),
|
|
90
107
|
sources: [...confMetadata.sources.values()],
|
|
91
108
|
properties: [...confMetadata.properties.values()].map(types_1.serializePropertyMetadata),
|
|
92
109
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.context.js","sourceRoot":"","sources":["../src/platform.context.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"platform.context.js","sourceRoot":"","sources":["../src/platform.context.ts"],"names":[],"mappings":";;;AAKA,2CAA8C;AAC9C,mCAA+C;AAE/C,kDAA+C;AAE/C,qCAAwE;AACxE,6CAGsB;AACtB,uCAA8C;AAC9C,2DAAsD;AACtD,uDAAmD;AAQnD,mCAMiB;AAEjB;;GAEG;AACH,MAAa,eAAe;IAgBL;IAfZ,MAAM,GAAG,uBAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtC,aAAa,CAAiD;IACrD,aAAa,CAA6B;IAC1C,WAAW,CAAsB;IAC1C,gBAAgB,CAA0B;IAC1C,KAAK,CAAgB;IAE7B;;;;;;;OAOG;IACH,YAAqB,OAAwB;QAAxB,YAAO,GAAP,OAAO,CAAiB;QAC3C,eAAe,CAAC,4BAA4B,CAAC,OA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
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.TracingModuleConfig = void 0;
|
|
13
13
|
const config_1 = require("../config");
|
|
14
|
+
const config_const_1 = require("../config/config.const");
|
|
14
15
|
let TracingModuleConfig = class TracingModuleConfig extends config_1.Config {
|
|
15
16
|
enabled;
|
|
16
17
|
collectorUrl;
|
|
@@ -30,7 +31,9 @@ __decorate([
|
|
|
30
31
|
__metadata("design:type", URL)
|
|
31
32
|
], TracingModuleConfig.prototype, "collectorUrl", void 0);
|
|
32
33
|
TracingModuleConfig = __decorate([
|
|
33
|
-
(0, config_1.ConfigSection)(
|
|
34
|
+
(0, config_1.ConfigSection)({
|
|
35
|
+
tags: [config_const_1.ConfigTag.infrastructure, config_const_1.ConfigTag.tracing],
|
|
36
|
+
})
|
|
34
37
|
], TracingModuleConfig);
|
|
35
38
|
exports.TracingModuleConfig = TracingModuleConfig;
|
|
36
39
|
//# sourceMappingURL=tracing.config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracing.config.js","sourceRoot":"","sources":["../../src/tracing/tracing.config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAMmB;
|
|
1
|
+
{"version":3,"file":"tracing.config.js","sourceRoot":"","sources":["../../src/tracing/tracing.config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAMmB;AACnB,yDAAmD;AAK5C,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,eAAM;IAK7C,OAAO,CAAW;IAMlB,YAAY,CAAO;CACpB,CAAA;AAXC;IAAC,IAAA,iBAAQ,EAAC,iBAAiB,EAAE,IAAI,mBAAU,EAAE,EAAE;QAC7C,YAAY,EAAE,KAAK;QACnB,WAAW,EAAE,4BAA4B;KAC1C,CAAC;;oDACgB;AAElB;IAAC,IAAA,iBAAQ,EAAC,uBAAuB,EAAE,IAAI,kBAAS,EAAE,EAAE;QAClD,YAAY,EAAE,IAAI,GAAG,CAAC,iCAAiC,CAAC;QACxD,WAAW,EAAE,0CAA0C;KACxD,CAAC;8BACa,GAAG;yDAAC;AAXR,mBAAmB;IAH/B,IAAA,sBAAa,EAAC;QACb,IAAI,EAAE,CAAC,wBAAS,CAAC,cAAc,EAAE,wBAAS,CAAC,OAAO,CAAC;KACpD,CAAC;GACW,mBAAmB,CAY/B;AAZY,kDAAmB"}
|
package/dist/types/metadata.d.ts
CHANGED
|
@@ -8,7 +8,9 @@ export declare const serializePropertyMetadata: (metadata: PropertyMetadata) =>
|
|
|
8
8
|
export type SerializableSectionMetadata = Omit<SectionMetadata, 'properties'> & {
|
|
9
9
|
properties: SerializablePropertyMetadata[];
|
|
10
10
|
};
|
|
11
|
-
export declare const transformSectionMetadata: ({ properties, ...rest }: SectionMetadata
|
|
11
|
+
export declare const transformSectionMetadata: ({ properties, ...rest }: SectionMetadata & {
|
|
12
|
+
constructorName: string;
|
|
13
|
+
}) => SerializableSectionMetadata;
|
|
12
14
|
export type SerializableConfigMetadata = {
|
|
13
15
|
prefix: string;
|
|
14
16
|
sources: SourceMetadata[];
|
|
@@ -27,6 +29,10 @@ export interface PlatformAppMetadata {
|
|
|
27
29
|
* Application description
|
|
28
30
|
*/
|
|
29
31
|
description: string;
|
|
32
|
+
/**
|
|
33
|
+
* Application version
|
|
34
|
+
*/
|
|
35
|
+
version: string;
|
|
30
36
|
/**
|
|
31
37
|
* Supported protocols
|
|
32
38
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/types/metadata.ts"],"names":[],"mappings":";;;AACA,yCAAmD;AAiB5C,MAAM,yBAAyB,GAAG,CACvC,QAA0B,EACI,EAAE;IAChC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAAC;IAEnD,OAAO;QACL,GAAG,IAAI;QACP,MAAM,EAAE;YACN,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE;YAEnB,WAAW,EAAE,MAAM,C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AC,EAAE,EAAE,CAAC,CAAC,IAAA,oBAAW,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;oBAC9D,CAAC,CAAC,YAAY,EAAE,QAAQ,EAAE;SAC7B,CAAC;KAC6B,CAAC;AACpC,CAAC,CAAC;AArBW,QAAA,yBAAyB,6BAqBpC;AASK,MAAM,wBAAwB,GAAG,CAAC,EACvC,UAAU,EACV,GAAG,IAAI,EAGR,EAA+B,EAAE,CAAC,CAAC;IAClC,GAAG,IAAI;IACP,iEAAiE;IACjE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,iCAAyB,CAAC;CACrE,CAAC,CAAC;AATU,QAAA,wBAAwB,4BASlC"}
|
package/dist/types/options.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DynamicModule } from '@nestjs/common';
|
|
1
2
|
import type { Constructor, RequiredFields } from '@rsdk/common';
|
|
2
3
|
import type { ConfigModuleOptions } from '../config';
|
|
3
4
|
import type { PlatformAppPlugin } from './plugins';
|
|
@@ -5,7 +6,8 @@ import type { IPrimaryTransport, ITransport } from './transports';
|
|
|
5
6
|
/**
|
|
6
7
|
* Not empty collection of modules
|
|
7
8
|
*/
|
|
8
|
-
type
|
|
9
|
+
type Module = DynamicModule | Constructor;
|
|
10
|
+
type Modules = [Module, ...Module[]];
|
|
9
11
|
export interface ManifestData {
|
|
10
12
|
/**
|
|
11
13
|
* Application name
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdk/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "Nestjs based microservice chassis",
|
|
5
5
|
"license": "Apache License 2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -11,29 +11,31 @@
|
|
|
11
11
|
},
|
|
12
12
|
"main": "dist/index.js",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@opentelemetry/api": "1.4.
|
|
15
|
-
"@opentelemetry/auto-instrumentations-node": "0.
|
|
16
|
-
"@opentelemetry/context-async-hooks": "1.
|
|
17
|
-
"@opentelemetry/core": "1.
|
|
18
|
-
"@opentelemetry/exporter-trace-otlp-http": "0.
|
|
19
|
-
"@opentelemetry/propagator-b3": "1.
|
|
20
|
-
"@opentelemetry/resources": "1.
|
|
21
|
-
"@opentelemetry/sdk-node": "0.
|
|
22
|
-
"@opentelemetry/sdk-trace-base": "1.
|
|
23
|
-
"@opentelemetry/semantic-conventions": "1.
|
|
14
|
+
"@opentelemetry/api": "1.4.1",
|
|
15
|
+
"@opentelemetry/auto-instrumentations-node": "0.37.0",
|
|
16
|
+
"@opentelemetry/context-async-hooks": "1.13.0",
|
|
17
|
+
"@opentelemetry/core": "1.13.0",
|
|
18
|
+
"@opentelemetry/exporter-trace-otlp-http": "0.39.1",
|
|
19
|
+
"@opentelemetry/propagator-b3": "1.13.0",
|
|
20
|
+
"@opentelemetry/resources": "1.13.0",
|
|
21
|
+
"@opentelemetry/sdk-node": "^0.39.1",
|
|
22
|
+
"@opentelemetry/sdk-trace-base": "1.13.0",
|
|
23
|
+
"@opentelemetry/semantic-conventions": "1.13.0",
|
|
24
24
|
"prom-client": "^14.2.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@nestjs/common": "
|
|
28
|
-
"@nestjs/core": "
|
|
29
|
-
"@nestjs/microservices": "
|
|
30
|
-
"@rsdk/
|
|
31
|
-
"@rsdk/
|
|
32
|
-
"@rsdk/
|
|
27
|
+
"@nestjs/common": "~9.3.8",
|
|
28
|
+
"@nestjs/core": "~9.3.8",
|
|
29
|
+
"@nestjs/microservices": "~9.3.8",
|
|
30
|
+
"@rsdk/autodoc-protocol": "^1.0.10",
|
|
31
|
+
"@rsdk/common": "^1.0.10",
|
|
32
|
+
"@rsdk/decorators": "^1.0.10",
|
|
33
|
+
"@rsdk/logging": "^1.0.10",
|
|
34
|
+
"@rsdk/metadata": "^1.0.10",
|
|
33
35
|
"axios": "^1.1.3",
|
|
34
36
|
"lodash": "^4.17.21",
|
|
35
37
|
"reflect-metadata": "^0.1.13",
|
|
36
38
|
"rxjs": "^7.0.0"
|
|
37
39
|
},
|
|
38
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "172c83d3a3d6d9387ac103b633ed498e50a642b5"
|
|
39
41
|
}
|
package/src/app/platform.app.ts
CHANGED
|
@@ -15,7 +15,7 @@ import type { PlatformAppMetadata, PlatformAppOptions } from '../types';
|
|
|
15
15
|
export class PlatformApp {
|
|
16
16
|
private static logger = LoggerFactory.create(PlatformApp);
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
readonly context: PlatformContext;
|
|
19
19
|
|
|
20
20
|
static {
|
|
21
21
|
const { logger } = PlatformApp;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const ConfigTag = {
|
|
2
|
+
infrastructure: 'infrastructure',
|
|
3
|
+
logging: 'logging',
|
|
4
|
+
errorHandling: 'error-handling',
|
|
5
|
+
metric: 'metric',
|
|
6
|
+
tracing: 'tracing',
|
|
7
|
+
storage: 'storage',
|
|
8
|
+
transport: 'transport',
|
|
9
|
+
graphql: 'graphql',
|
|
10
|
+
http: 'http',
|
|
11
|
+
grpcServer: 'grpc-server',
|
|
12
|
+
natsHemera: 'nats-hemera',
|
|
13
|
+
} as const;
|
package/src/config/types.ts
CHANGED
|
@@ -45,11 +45,13 @@ export interface PropertyMetadata<T extends ConfigValue = ConfigValue> {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export interface SectionMetadata {
|
|
48
|
-
name
|
|
48
|
+
name?: string;
|
|
49
|
+
constructorName: string;
|
|
49
50
|
// TODO: Why use Record instead of map here
|
|
50
51
|
// TODO: Why symbol here
|
|
51
52
|
properties: Record<string | symbol, PropertyMetadata>;
|
|
52
53
|
description?: string;
|
|
54
|
+
tags?: string[];
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
export interface SourceMetadata {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { text } from '@rsdk/common';
|
|
2
2
|
|
|
3
3
|
import { BoolParser, Config, ConfigSection, Property } from '../config';
|
|
4
|
+
import { ConfigTag } from '../config/config.const';
|
|
4
5
|
|
|
5
|
-
@ConfigSection(
|
|
6
|
+
@ConfigSection({
|
|
7
|
+
tags: [ConfigTag.infrastructure, ConfigTag.errorHandling],
|
|
8
|
+
})
|
|
6
9
|
export class GlobalExceptionsConfig extends Config {
|
|
7
10
|
@Property('VERBOSE_ERRORS', new BoolParser(), {
|
|
8
11
|
defaultValue: true,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { DocumentNode, DocumentResolver } from '@rsdk/autodoc-protocol';
|
|
2
|
+
import { Composite, Table } from '@rsdk/autodoc-protocol';
|
|
3
|
+
import type { RsdkMetadata } from '@rsdk/metadata';
|
|
4
|
+
|
|
5
|
+
import type { IndicatorOptions } from '../metadata';
|
|
6
|
+
|
|
7
|
+
export class IndicatorAutodoc implements DocumentResolver {
|
|
8
|
+
constructor(
|
|
9
|
+
readonly rsdkMetadata: RsdkMetadata<{
|
|
10
|
+
key: string;
|
|
11
|
+
options: IndicatorOptions;
|
|
12
|
+
constructorName: string;
|
|
13
|
+
}>,
|
|
14
|
+
) {}
|
|
15
|
+
|
|
16
|
+
getNode(): DocumentNode | null {
|
|
17
|
+
const resources = this.rsdkMetadata.get();
|
|
18
|
+
if (!resources) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return new Composite(
|
|
22
|
+
new Table(
|
|
23
|
+
resources.map(({ value }) => ({
|
|
24
|
+
key: value.key,
|
|
25
|
+
scope: value.options.scope ?? '-',
|
|
26
|
+
description: value.options.description ?? '-',
|
|
27
|
+
name: value.constructorName,
|
|
28
|
+
})),
|
|
29
|
+
),
|
|
30
|
+
'Health indicators',
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { OnModuleInit } from '@nestjs/common';
|
|
1
2
|
import { Injectable } from '@nestjs/common';
|
|
2
3
|
import { ModuleRef } from '@nestjs/core';
|
|
3
4
|
import type { Constructor } from '@rsdk/common';
|
|
@@ -15,7 +16,7 @@ import type {
|
|
|
15
16
|
} from './types';
|
|
16
17
|
|
|
17
18
|
@Injectable()
|
|
18
|
-
export class HealthChecksService {
|
|
19
|
+
export class HealthChecksService implements OnModuleInit {
|
|
19
20
|
private readonly indicators: ResolvedIndicators = { common: [] };
|
|
20
21
|
private readonly indicatorNames = new Map<HealthIndicator, string>();
|
|
21
22
|
|
package/src/health/index.ts
CHANGED
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
2
|
|
|
3
|
+
import { AutodocMetadata } from '@rsdk/autodoc-protocol';
|
|
3
4
|
import type { Constructor } from '@rsdk/common';
|
|
5
|
+
import { RsdkMetadata } from '@rsdk/metadata';
|
|
4
6
|
|
|
7
|
+
import { IndicatorAutodoc } from '../autodoc/heath.autodoc-resolver';
|
|
5
8
|
import type { HealthIndicator } from '../types';
|
|
6
9
|
|
|
7
10
|
import { IndicatorsRegistry } from './indicators.registry';
|
|
8
11
|
|
|
9
12
|
export interface IndicatorOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Description
|
|
15
|
+
*/
|
|
10
16
|
description?: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* FIXME: WTF?
|
|
20
|
+
*/
|
|
11
21
|
scope?: string;
|
|
12
22
|
}
|
|
13
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Registers health indicator. Indicators should be added to application
|
|
26
|
+
* modules as providers and use common DI to inject necessary services
|
|
27
|
+
* (api, database clients, etc.)
|
|
28
|
+
* @param {string} key Healthcheck response is object where each key
|
|
29
|
+
* is a specific indicator. Thus you can use key to recognize an
|
|
30
|
+
* indicator in healthcheck response
|
|
31
|
+
* @param {IndicatorOptions} options Indicator metadata
|
|
32
|
+
* @returns {ClassDecorator}
|
|
33
|
+
*/
|
|
14
34
|
export const Indicator = (
|
|
15
35
|
key: string,
|
|
16
36
|
options: IndicatorOptions = {},
|
|
@@ -21,5 +41,19 @@ export const Indicator = (
|
|
|
21
41
|
scope: 'common',
|
|
22
42
|
...options,
|
|
23
43
|
});
|
|
44
|
+
const rsdkMetadata = new RsdkMetadata<{
|
|
45
|
+
key: string;
|
|
46
|
+
options: IndicatorOptions;
|
|
47
|
+
constructorName: string;
|
|
48
|
+
}>(target, 'health-indicator');
|
|
49
|
+
|
|
50
|
+
rsdkMetadata.add({
|
|
51
|
+
key,
|
|
52
|
+
options,
|
|
53
|
+
constructorName: target.name,
|
|
54
|
+
});
|
|
55
|
+
const autodocMetadata = new AutodocMetadata(rsdkMetadata);
|
|
56
|
+
|
|
57
|
+
autodocMetadata.defineResolver(new IndicatorAutodoc(rsdkMetadata));
|
|
24
58
|
};
|
|
25
59
|
};
|
|
@@ -23,10 +23,6 @@ export class IndicatorsRegistry {
|
|
|
23
23
|
throw new DoubleInitException('Health indicator', target.name);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
this.logger.info(`Registering indicator: ${target.name}`, {
|
|
27
|
-
indicator: target.name,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
26
|
this.indicators.set(target, options);
|
|
31
27
|
}
|
|
32
28
|
|
package/src/index.ts
CHANGED
|
@@ -8,8 +8,11 @@ import {
|
|
|
8
8
|
Property,
|
|
9
9
|
StringParser,
|
|
10
10
|
} from '../config';
|
|
11
|
+
import { ConfigTag } from '../config/config.const';
|
|
11
12
|
|
|
12
|
-
@ConfigSection(
|
|
13
|
+
@ConfigSection({
|
|
14
|
+
tags: [ConfigTag.infrastructure, ConfigTag.logging],
|
|
15
|
+
})
|
|
13
16
|
export class LoggingConfig extends Config {
|
|
14
17
|
@Property('LOG_LEVEL', new EnumParser(LogLevel), {
|
|
15
18
|
// TODO: Can pass anything instead of enum value. Need to handle this!
|
package/src/metrics/index.ts
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { DocumentNode, DocumentResolver } from '@rsdk/autodoc-protocol';
|
|
2
|
+
import { Composite, Table } from '@rsdk/autodoc-protocol';
|
|
3
|
+
import type { RsdkMetadata } from '@rsdk/metadata';
|
|
4
|
+
|
|
5
|
+
import type { MetricRsdkMetadata } from '../types';
|
|
6
|
+
|
|
7
|
+
export class MetricAutodocResolver implements DocumentResolver {
|
|
8
|
+
constructor(readonly rsdkMetadata: RsdkMetadata<MetricRsdkMetadata>) {}
|
|
9
|
+
|
|
10
|
+
getNode(): DocumentNode | null {
|
|
11
|
+
const resources = this.rsdkMetadata.get();
|
|
12
|
+
if (!resources) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return new Composite(
|
|
17
|
+
new Table(
|
|
18
|
+
resources.map(({ value }) => {
|
|
19
|
+
return {
|
|
20
|
+
name: value.metadata.name,
|
|
21
|
+
description: value.metadata.description,
|
|
22
|
+
type: value.type,
|
|
23
|
+
controllerName: value.metricController.name,
|
|
24
|
+
};
|
|
25
|
+
}),
|
|
26
|
+
),
|
|
27
|
+
'Metrics',
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -11,13 +11,21 @@ import type {
|
|
|
11
11
|
} from '../../types';
|
|
12
12
|
import { MetricsRegistry } from '../metrics.registry';
|
|
13
13
|
|
|
14
|
+
export type MetricType = 'counter' | 'gauge' | 'histogram' | 'summary';
|
|
15
|
+
|
|
14
16
|
/**
|
|
15
|
-
* Registers metric
|
|
16
|
-
*
|
|
17
|
-
*
|
|
17
|
+
* Registers a custom metric. Metrics a added to MetricsModules inside
|
|
18
|
+
* the core, so you **should NOT** use them as providers in your application.
|
|
19
|
+
*
|
|
20
|
+
* Conventional usage is to create a class that extends one of prom-client
|
|
21
|
+
* metric: Counter, Gauge, Histogram or Summary, and mark it with this
|
|
22
|
+
* decorator. The class should stay empty - it's is used only as a "host"
|
|
23
|
+
* for Metrics decorator.
|
|
18
24
|
*
|
|
19
|
-
* @param type type of metric
|
|
20
|
-
* @param
|
|
25
|
+
* @param {counter|gauge|histogram|summary} type type of metric
|
|
26
|
+
* @param {CounterMetadata|GaugeMetadata|HistogramMetadata|SummaryMetadata} metadata
|
|
27
|
+
* respective metadata
|
|
28
|
+
* @returns {ClassDecorator}
|
|
21
29
|
*/
|
|
22
30
|
export function Metric(
|
|
23
31
|
type: 'counter',
|
|
@@ -36,7 +44,7 @@ export function Metric(
|
|
|
36
44
|
metadata: OmitType<SummaryMetadata>,
|
|
37
45
|
): ClassDecorator;
|
|
38
46
|
export function Metric(
|
|
39
|
-
type:
|
|
47
|
+
type: MetricType,
|
|
40
48
|
metadata: OmitType<MetricMetadata>,
|
|
41
49
|
): ClassDecorator {
|
|
42
50
|
return function (target: Function): void {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Constructor } from '@rsdk/common';
|
|
2
|
+
|
|
3
|
+
import type { AnyMetric, MetricMetadata, OmitType } from '../types';
|
|
4
|
+
|
|
5
|
+
import type { MetricType } from './decorators';
|
|
6
|
+
|
|
7
|
+
export type MetricRsdkMetadata = {
|
|
8
|
+
type: MetricType;
|
|
9
|
+
metadata: OmitType<MetricMetadata>;
|
|
10
|
+
metricController: Constructor<AnyMetric>;
|
|
11
|
+
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { BoolParser, Config, ConfigSection, Property } from '../config';
|
|
2
|
+
import { ConfigTag } from '../config/config.const';
|
|
2
3
|
|
|
3
|
-
@ConfigSection({
|
|
4
|
+
@ConfigSection({
|
|
5
|
+
name: 'Metrics configuration',
|
|
6
|
+
tags: [ConfigTag.infrastructure, ConfigTag.metric],
|
|
7
|
+
})
|
|
4
8
|
export class MetricsModuleConfig extends Config {
|
|
5
9
|
@Property('METRICS_ENABLED', new BoolParser(), {
|
|
6
10
|
defaultValue: true,
|
|
@@ -4,12 +4,15 @@ import type {
|
|
|
4
4
|
Provider,
|
|
5
5
|
} from '@nestjs/common';
|
|
6
6
|
import { Module } from '@nestjs/common';
|
|
7
|
+
import { AutodocMetadata } from '@rsdk/autodoc-protocol';
|
|
7
8
|
import type { Constructor } from '@rsdk/common';
|
|
9
|
+
import { RsdkMetadata } from '@rsdk/metadata';
|
|
8
10
|
import client from 'prom-client';
|
|
9
11
|
|
|
10
12
|
import { PlatformConfigModule } from '../config';
|
|
11
13
|
|
|
12
|
-
import {
|
|
14
|
+
import type { MetricRsdkMetadata } from './metadata';
|
|
15
|
+
import { MetricAutodocResolver, MetricsRegistry } from './metadata';
|
|
13
16
|
import { MetricsModuleConfig } from './metrics.config';
|
|
14
17
|
import type { AnyMetric, MetricsModuleOptions } from './types';
|
|
15
18
|
|
|
@@ -65,10 +68,28 @@ export class MetricsModule implements OnApplicationBootstrap {
|
|
|
65
68
|
|
|
66
69
|
const metadata = MetricsRegistry.getOne(ctor);
|
|
67
70
|
|
|
68
|
-
|
|
71
|
+
const provider = {
|
|
69
72
|
provide: ctor,
|
|
70
73
|
useValue: new ctor(metadata),
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const rsdkMetadata = new RsdkMetadata<MetricRsdkMetadata>(
|
|
77
|
+
provider,
|
|
78
|
+
'metrics',
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
rsdkMetadata.add({
|
|
82
|
+
type: metadata.type,
|
|
83
|
+
metricController: ctor,
|
|
84
|
+
metadata,
|
|
71
85
|
});
|
|
86
|
+
|
|
87
|
+
const autodocMetadata = new AutodocMetadata(rsdkMetadata);
|
|
88
|
+
|
|
89
|
+
const metricsDocumentResolver = new MetricAutodocResolver(rsdkMetadata);
|
|
90
|
+
|
|
91
|
+
autodocMetadata.defineResolver(metricsDocumentResolver);
|
|
92
|
+
providers.push(provider);
|
|
72
93
|
}
|
|
73
94
|
|
|
74
95
|
return {
|