@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.
Files changed (81) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/app/platform.app.d.ts +2 -1
  3. package/dist/app/platform.app.js.map +1 -1
  4. package/dist/config/config.const.d.ts +13 -0
  5. package/dist/config/config.const.js +17 -0
  6. package/dist/config/config.const.js.map +1 -0
  7. package/dist/config/metadata/decorators/config-section.decorator.d.ts +4 -0
  8. package/dist/config/metadata/decorators/config-section.decorator.js.map +1 -1
  9. package/dist/config/types.d.ts +3 -1
  10. package/dist/exceptions.handling/global-exceptions.config.js +4 -1
  11. package/dist/exceptions.handling/global-exceptions.config.js.map +1 -1
  12. package/dist/health/autodoc/heath.autodoc-resolver.d.ts +16 -0
  13. package/dist/health/autodoc/heath.autodoc-resolver.js +24 -0
  14. package/dist/health/autodoc/heath.autodoc-resolver.js.map +1 -0
  15. package/dist/health/health.service.d.ts +2 -1
  16. package/dist/health/health.service.js.map +1 -1
  17. package/dist/health/index.d.ts +1 -0
  18. package/dist/health/index.js +3 -0
  19. package/dist/health/index.js.map +1 -1
  20. package/dist/health/metadata/indicator.decorator.d.ts +16 -0
  21. package/dist/health/metadata/indicator.decorator.js +21 -0
  22. package/dist/health/metadata/indicator.decorator.js.map +1 -1
  23. package/dist/health/metadata/indicators.registry.js +0 -3
  24. package/dist/health/metadata/indicators.registry.js.map +1 -1
  25. package/dist/index.d.ts +1 -0
  26. package/dist/index.js +3 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/logging/logging.config.js +4 -1
  29. package/dist/logging/logging.config.js.map +1 -1
  30. package/dist/metrics/index.d.ts +2 -0
  31. package/dist/metrics/index.js +3 -1
  32. package/dist/metrics/index.js.map +1 -1
  33. package/dist/metrics/metadata/autodoc/metrics.autodoc-resolver.d.ts +8 -0
  34. package/dist/metrics/metadata/autodoc/metrics.autodoc-resolver.js +26 -0
  35. package/dist/metrics/metadata/autodoc/metrics.autodoc-resolver.js.map +1 -0
  36. package/dist/metrics/metadata/decorators/metric.decorator.d.ts +12 -5
  37. package/dist/metrics/metadata/decorators/metric.decorator.js.map +1 -1
  38. package/dist/metrics/metadata/index.d.ts +2 -0
  39. package/dist/metrics/metadata/index.js +3 -0
  40. package/dist/metrics/metadata/index.js.map +1 -1
  41. package/dist/metrics/metadata/types.d.ts +8 -0
  42. package/dist/metrics/metadata/types.js +3 -0
  43. package/dist/metrics/metadata/types.js.map +1 -0
  44. package/dist/metrics/metrics.config.js +5 -1
  45. package/dist/metrics/metrics.config.js.map +1 -1
  46. package/dist/metrics/metrics.module.js +15 -3
  47. package/dist/metrics/metrics.module.js.map +1 -1
  48. package/dist/platform.context.d.ts +5 -3
  49. package/dist/platform.context.js +31 -14
  50. package/dist/platform.context.js.map +1 -1
  51. package/dist/tracing/tracing.config.js +4 -1
  52. package/dist/tracing/tracing.config.js.map +1 -1
  53. package/dist/types/metadata.d.ts +7 -1
  54. package/dist/types/metadata.js.map +1 -1
  55. package/dist/types/options.d.ts +3 -1
  56. package/package.json +20 -18
  57. package/src/app/platform.app.ts +1 -1
  58. package/src/config/config.const.ts +13 -0
  59. package/src/config/metadata/decorators/config-section.decorator.ts +4 -0
  60. package/src/config/types.ts +3 -1
  61. package/src/exceptions.handling/global-exceptions.config.ts +4 -1
  62. package/src/health/autodoc/heath.autodoc-resolver.ts +33 -0
  63. package/src/health/health.service.ts +2 -1
  64. package/src/health/index.ts +1 -0
  65. package/src/health/metadata/indicator.decorator.ts +34 -0
  66. package/src/health/metadata/indicators.registry.ts +0 -4
  67. package/src/index.ts +2 -0
  68. package/src/logging/logging.config.ts +4 -1
  69. package/src/metrics/index.ts +2 -0
  70. package/src/metrics/metadata/autodoc/metrics.autodoc-resolver.ts +30 -0
  71. package/src/metrics/metadata/decorators/metric.decorator.ts +14 -6
  72. package/src/metrics/metadata/index.ts +3 -0
  73. package/src/metrics/metadata/types.ts +11 -0
  74. package/src/metrics/metrics.config.ts +5 -1
  75. package/src/metrics/metrics.module.ts +23 -2
  76. package/src/platform.context.ts +40 -21
  77. package/src/tracing/tracing.config.ts +4 -1
  78. package/src/types/metadata.ts +8 -1
  79. package/src/types/options.ts +3 -1
  80. package/tsconfig.json +0 -1
  81. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -2,10 +2,12 @@ import type { DynamicModule, INestMicroservice } 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 { Constructor } from '@rsdk/common';
5
6
  import { LoggerFactory } from '@rsdk/logging';
6
7
  import { groupBy, intersection } from 'lodash';
7
8
 
8
9
  import { Manifest } from './manifest/manifest';
10
+ import type { Config, SectionMetadata } from './config';
9
11
  import { ConfigMetadataRegistry, PlatformConfigModule } from './config';
10
12
  import {
11
13
  DuplicateProtocolException,
@@ -34,12 +36,11 @@ import {
34
36
  */
35
37
  export class PlatformContext {
36
38
  readonly logger = LoggerFactory.create('App');
37
- readonly root: DynamicModule;
38
-
39
39
  private microservices: Map<INestMicroservice, IMicroserviceTransport>;
40
40
  private readonly httpTransport: IHttpTransport | undefined;
41
41
  private readonly httpAdapter: AbstractHttpAdapter;
42
- private readonly extendedOptions: PlatformExtendedOptions;
42
+ private _extendedOptions: PlatformExtendedOptions;
43
+ private _root: DynamicModule;
43
44
 
44
45
  /**
45
46
  * Создаёт контекст проводя базовые проверки
@@ -53,28 +54,39 @@ export class PlatformContext {
53
54
  PlatformContext.assertTransportCompatability(options);
54
55
  PlatformContext.assertPluginCompatability(options);
55
56
 
56
- const { name, description, version } = Manifest.getData(
57
- options.manifestPath,
58
- );
57
+ this.httpTransport = options.transports?.find?.(isHttpTransport);
58
+ this.httpAdapter =
59
+ this.httpTransport?.getAdapter() ?? new NoopHttpAdapter();
60
+ }
61
+
62
+ get root(): DynamicModule {
63
+ if (this._root) {
64
+ return this._root;
65
+ }
66
+ PlatformConfigModule.bootstrap({
67
+ ...(this.extendedOptions.config ?? {}),
68
+ appName: this.extendedOptions.name,
69
+ });
70
+ this._root = PlatformModule.forRoot(this.extendedOptions);
71
+ return this._root;
72
+ }
73
+
74
+ get extendedOptions(): PlatformExtendedOptions {
75
+ if (this._extendedOptions) {
76
+ return this._extendedOptions;
77
+ }
78
+ const manifestData = Manifest.getData(this.options.manifestPath);
79
+ const { name, description, version } = manifestData;
59
80
 
60
81
  const extendedOptions: PlatformExtendedOptions = {
61
82
  description,
62
83
  name,
63
84
  version,
64
- ...options,
85
+ ...this.options,
65
86
  };
66
87
 
67
- this.extendedOptions = extendedOptions;
68
-
69
- PlatformConfigModule.bootstrap({
70
- ...(extendedOptions.config ?? {}),
71
- appName: extendedOptions.name,
72
- });
73
- this.httpTransport = options.transports?.find?.(isHttpTransport);
74
- this.httpAdapter =
75
- this.httpTransport?.getAdapter() ?? new NoopHttpAdapter();
76
-
77
- this.root = PlatformModule.forRoot(this.extendedOptions);
88
+ this._extendedOptions = extendedOptions;
89
+ return this._extendedOptions;
78
90
  }
79
91
 
80
92
  private static assertPluginCompatability(options: PlatformOptions): void {
@@ -115,14 +127,21 @@ export class PlatformContext {
115
127
 
116
128
  return {
117
129
  name: options.name,
118
-
130
+ version: options.version,
119
131
  description: options.description,
120
132
  protocols: protocols,
121
133
 
122
134
  config: {
123
135
  prefix: options.name,
124
- sections: [...confMetadata.sections.values()].map(
125
- transformSectionMetadata,
136
+ sections: [...confMetadata.sections.entries()].map(
137
+ ([section, metadata]: [
138
+ section: Constructor<Config>,
139
+ metadata: SectionMetadata,
140
+ ]) =>
141
+ transformSectionMetadata({
142
+ ...metadata,
143
+ constructorName: section.name,
144
+ }),
126
145
  ),
127
146
  sources: [...confMetadata.sources.values()],
128
147
 
@@ -5,8 +5,11 @@ import {
5
5
  Property,
6
6
  UrlParser,
7
7
  } from '../config';
8
+ import { ConfigTag } from '../config/config.const';
8
9
 
9
- @ConfigSection()
10
+ @ConfigSection({
11
+ tags: [ConfigTag.infrastructure, ConfigTag.tracing],
12
+ })
10
13
  export class TracingModuleConfig extends Config {
11
14
  @Property('TRACING_ENABLED', new BoolParser(), {
12
15
  defaultValue: false,
@@ -49,7 +49,9 @@ export type SerializableSectionMetadata = Omit<
49
49
  export const transformSectionMetadata = ({
50
50
  properties,
51
51
  ...rest
52
- }: SectionMetadata): SerializableSectionMetadata => ({
52
+ }: SectionMetadata & {
53
+ constructorName: string;
54
+ }): SerializableSectionMetadata => ({
53
55
  ...rest,
54
56
  // TODO: Если properties переделается в мапу, может быть проблема
55
57
  properties: Object.values(properties).map(serializePropertyMetadata),
@@ -76,6 +78,11 @@ export interface PlatformAppMetadata {
76
78
  */
77
79
  description: string;
78
80
 
81
+ /**
82
+ * Application version
83
+ */
84
+ version: string;
85
+
79
86
  /**
80
87
  * Supported protocols
81
88
  */
@@ -1,3 +1,4 @@
1
+ import type { DynamicModule } from '@nestjs/common';
1
2
  import type { Constructor, RequiredFields } from '@rsdk/common';
2
3
 
3
4
  import type { ConfigModuleOptions } from '../config';
@@ -8,7 +9,8 @@ import type { IPrimaryTransport, ITransport } from './transports';
8
9
  /**
9
10
  * Not empty collection of modules
10
11
  */
11
- type Modules = [Constructor, ...Constructor[]];
12
+ type Module = DynamicModule | Constructor;
13
+ type Modules = [Module, ...Module[]];
12
14
 
13
15
  export interface ManifestData {
14
16
  /**
package/tsconfig.json CHANGED
@@ -1,5 +1,4 @@
1
1
  {
2
-
3
2
  "extends": "@rsdk/tsconfig/base.json",
4
3
  "compilerOptions": {
5
4
  "declaration": true,