@rsdk/core 2.5.0 → 2.6.0-next.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 +44 -0
- package/dist/config/config.module.js.map +1 -1
- package/dist/config/context/config.context.d.ts +3 -3
- package/dist/config/context/config.context.js +5 -2
- package/dist/config/context/config.context.js.map +1 -1
- package/dist/config/metadata/decorators/declare-property.decorator.d.ts +2 -2
- package/dist/config/metadata/decorators/property.decorator.d.ts +2 -2
- package/dist/config/metadata/decorators/property.decorator.js.map +1 -1
- package/dist/config/parsers/array.parser.d.ts +3 -3
- package/dist/config/parsers/array.parser.js.map +1 -1
- package/dist/config/parsers/boolean/bool.parser.d.ts +2 -2
- package/dist/config/parsers/boolean/bool.parser.js.map +1 -1
- package/dist/config/parsers/enum/enum.parser.d.ts +2 -2
- package/dist/config/parsers/enum/enum.parser.js.map +1 -1
- package/dist/config/parsers/int/int.parser.d.ts +2 -2
- package/dist/config/parsers/int/int.parser.js.map +1 -1
- package/dist/config/parsers/number/number.parser.d.ts +2 -2
- package/dist/config/parsers/number/number.parser.js.map +1 -1
- package/dist/config/parsers/path/fspath.parser.d.ts +2 -2
- package/dist/config/parsers/path/fspath.parser.js.map +1 -1
- package/dist/config/parsers/size/size.parser.d.ts +2 -2
- package/dist/config/parsers/size/size.parser.js.map +1 -1
- package/dist/config/parsers/string/string.parser.d.ts +2 -2
- package/dist/config/parsers/string/string.parser.js.map +1 -1
- package/dist/config/parsers/timespan/timespan.parser.d.ts +2 -2
- package/dist/config/parsers/timespan/timespan.parser.js.map +1 -1
- package/dist/config/parsers/url/exception.d.ts +7 -0
- package/dist/config/parsers/url/exception.js +25 -0
- package/dist/config/parsers/url/exception.js.map +1 -0
- package/dist/config/parsers/url/index.d.ts +1 -0
- package/dist/config/parsers/url/index.js +3 -0
- package/dist/config/parsers/url/index.js.map +1 -1
- package/dist/config/parsers/url/url.parser.d.ts +5 -2
- package/dist/config/parsers/url/url.parser.js +21 -1
- package/dist/config/parsers/url/url.parser.js.map +1 -1
- package/dist/config/sources/base/config-source.abstract.js.map +1 -1
- package/dist/config/sources/implementations/json-file.source.js +2 -2
- package/dist/config/sources/implementations/json-file.source.js.map +1 -1
- package/dist/config/sources/implementations/relodable-json-file.source.js +2 -2
- package/dist/config/sources/implementations/relodable-json-file.source.js.map +1 -1
- package/dist/config/types.d.ts +5 -9
- package/dist/config/vars.class.d.ts +3 -4
- package/dist/config/vars.class.js +4 -6
- package/dist/config/vars.class.js.map +1 -1
- package/dist/logging/global-logger-provider.generator.d.ts +1 -1
- package/dist/rsdk-metadata/constants.d.ts +1 -1
- package/dist/types/metadata.js.map +1 -1
- package/dist/types/options.d.ts +2 -1
- package/package.json +11 -8
- package/src/config/config.module.ts +3 -4
- package/src/config/context/config.context.ts +5 -9
- package/src/config/metadata/decorators/declare-property.decorator.ts +2 -2
- package/src/config/metadata/decorators/property.decorator.ts +1 -2
- package/src/config/parsers/array.parser.ts +3 -9
- package/src/config/parsers/boolean/bool.parser.ts +2 -2
- package/src/config/parsers/enum/enum.parser.ts +2 -2
- package/src/config/parsers/int/int.parser.ts +2 -2
- package/src/config/parsers/number/number.parser.ts +2 -2
- package/src/config/parsers/path/fspath.parser.ts +2 -2
- package/src/config/parsers/size/size.parser.ts +2 -2
- package/src/config/parsers/string/string.parser.ts +2 -2
- package/src/config/parsers/timespan/timespan.parser.ts +2 -2
- package/src/config/parsers/url/exception.ts +21 -0
- package/src/config/parsers/url/index.ts +1 -0
- package/src/config/parsers/url/url.parser.ts +23 -3
- package/src/config/sources/base/config-source.abstract.ts +2 -2
- package/src/config/sources/implementations/json-file.source.ts +1 -1
- package/src/config/sources/implementations/relodable-json-file.source.ts +1 -1
- package/src/config/types.ts +5 -19
- package/src/config/vars.class.ts +8 -19
- package/src/logging/global-logger-provider.generator.ts +1 -1
- package/src/rsdk-metadata/constants.ts +2 -1
- package/src/transport/transport.module.ts +1 -1
- package/src/types/metadata.ts +1 -2
- package/src/types/options.ts +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vars.class.js","sourceRoot":"","sources":["../../src/config/vars.class.ts"],"names":[],"mappings":";;;AAAA,mCAA4C;AAE5C,6CAAiD;
|
|
1
|
+
{"version":3,"file":"vars.class.js","sourceRoot":"","sources":["../../src/config/vars.class.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NestModuleDefinition } from '@rsdk/common';
|
|
1
|
+
import type { NestModuleDefinition } from '@rsdk/common.nestjs';
|
|
2
2
|
import type { RsdkMetadataProvider } from '@rsdk/metadata';
|
|
3
3
|
declare class GlobalLoggerProvidersGenerator {
|
|
4
4
|
generate(rsdkMetadataProvider: RsdkMetadataProvider): NestModuleDefinition;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { NestModuleDefinition } from '@rsdk/common';
|
|
1
|
+
import type { NestModuleDefinition } from '@rsdk/common.nestjs';
|
|
2
2
|
export declare const PLATFORM_RAW_GLOBAL_METADATA_SCOPE = "PLATFORM_RAW_GLOBAL_RSDK_METADATA_SCOPE";
|
|
3
3
|
export type PlatformRawGlobalMetadata = NestModuleDefinition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/types/metadata.ts"],"names":[],"mappings":";;;AACA,yCAAmD;
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/types/metadata.ts"],"names":[],"mappings":";;;AACA,yCAAmD;AAiBnD,SAAS,iBAAiB,CACxB,YAAiB;IAEjB,IAAI,IAAA,oBAAW,EAAC,YAAY,CAAC,EAAE;QAC7B,OAAO,YAAY,CAAC;KACrB;IACD,OAAO,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC;QAChC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAA,oBAAW,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC9D,CAAC,CAAC,YAAY,EAAE,QAAQ,EAAE,CAAC;AAC/B,CAAC;AAEM,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,CAAC,WAAW,EAAE;SAClC;QACD,GAAG,CAAC,IAAA,eAAM,EAAC,QAAQ,EAAE,cAAc,CAAC,IAAI;YACtC,+CAA+C;YAC/C,YAAY,EAAE,iBAAiB,CAAC,YAAY,CAAC;SAC9C,CAAC;KAC6B,CAAC;AACpC,CAAC,CAAC;AAjBW,QAAA,yBAAyB,6BAiBpC;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,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RequiredFields } from '@rsdk/common';
|
|
2
|
+
import type { NestModuleDefinition } from '@rsdk/common.nestjs';
|
|
2
3
|
import type { ConfigModuleOptions } from '../config';
|
|
3
4
|
import type { PlatformAppPlugin } from './plugins';
|
|
4
5
|
import type { IPrimaryTransport, ITransport } from './transports';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdk/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0-next.10",
|
|
4
4
|
"description": "Nestjs based microservice chassis",
|
|
5
5
|
"license": "Apache License 2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"@opentelemetry/sdk-node": "^0.39.1",
|
|
24
24
|
"@opentelemetry/sdk-trace-base": "1.13.0",
|
|
25
25
|
"@opentelemetry/semantic-conventions": "1.13.0",
|
|
26
|
+
"dotenv": "^16.3.1",
|
|
26
27
|
"lodash": "^4.17.21",
|
|
27
28
|
"prom-client": "^14.2.0"
|
|
28
29
|
},
|
|
@@ -30,15 +31,17 @@
|
|
|
30
31
|
"@nestjs/common": "^9.0.0",
|
|
31
32
|
"@nestjs/core": "^9.0.0",
|
|
32
33
|
"@nestjs/microservices": "^9.0.0",
|
|
33
|
-
"@rsdk/autodoc.protocol": "^2.
|
|
34
|
-
"@rsdk/common": "^2.
|
|
35
|
-
"@rsdk/
|
|
36
|
-
"@rsdk/
|
|
37
|
-
"@rsdk/
|
|
38
|
-
"@rsdk/
|
|
34
|
+
"@rsdk/autodoc.protocol": "^2.6.0-next.9",
|
|
35
|
+
"@rsdk/common": "^2.6.0-next.9",
|
|
36
|
+
"@rsdk/common.nestjs": "^2.6.0-next.9",
|
|
37
|
+
"@rsdk/common.node": "^2.6.0-next.10",
|
|
38
|
+
"@rsdk/decorators": "^2.6.0-next.9",
|
|
39
|
+
"@rsdk/logging": "^2.6.0-next.9",
|
|
40
|
+
"@rsdk/metadata": "^2.6.0-next.9",
|
|
41
|
+
"@rsdk/nest-tools": "^2.6.0-next.3",
|
|
39
42
|
"axios": "^1.1.3",
|
|
40
43
|
"reflect-metadata": "^0.1.13",
|
|
41
44
|
"rxjs": "^7.0.0"
|
|
42
45
|
},
|
|
43
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "742e72916c46d5dccc38e0f6c3003f8457921bc4"
|
|
44
47
|
}
|
|
@@ -9,7 +9,6 @@ import { ConfigContext } from './context/config.context';
|
|
|
9
9
|
import type { Config } from './config.abstract';
|
|
10
10
|
import { getPropertyToken } from './metadata';
|
|
11
11
|
import type { ConfigSource } from './sources';
|
|
12
|
-
import type { ConfigValue } from './types';
|
|
13
12
|
|
|
14
13
|
export interface ConfigModuleOptions {
|
|
15
14
|
/**
|
|
@@ -107,9 +106,9 @@ export class PlatformConfigModule {
|
|
|
107
106
|
};
|
|
108
107
|
}
|
|
109
108
|
|
|
110
|
-
private static getPropertyProvider(
|
|
109
|
+
private static getPropertyProvider<T>(
|
|
111
110
|
token: `STANDALONE_CONFIG_PROPERTY_${string}`,
|
|
112
|
-
): FactoryProvider<
|
|
111
|
+
): FactoryProvider<T | undefined> {
|
|
113
112
|
return {
|
|
114
113
|
inject: [
|
|
115
114
|
ConfigContext,
|
|
@@ -119,7 +118,7 @@ export class PlatformConfigModule {
|
|
|
119
118
|
useFactory: async (
|
|
120
119
|
configContext: ConfigContext,
|
|
121
120
|
additionalSourceModuleInitializer?: AdditionalSourceInitializer,
|
|
122
|
-
): Promise<
|
|
121
|
+
): Promise<T | undefined> => {
|
|
123
122
|
await additionalSourceModuleInitializer?.initialize();
|
|
124
123
|
return configContext.resolveProperty(token);
|
|
125
124
|
},
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* 3. динамические source'ы (если сделать последовательно - то в порядке указания)
|
|
8
8
|
*/
|
|
9
9
|
import type { Constructor } from '@rsdk/common';
|
|
10
|
-
import
|
|
10
|
+
import dotenv from 'dotenv';
|
|
11
11
|
import { LoggerFactory } from '@rsdk/logging';
|
|
12
12
|
import type { RsdkMetadataProvider } from '@rsdk/metadata';
|
|
13
13
|
|
|
@@ -18,7 +18,7 @@ import type { PropertyToken } from '../metadata';
|
|
|
18
18
|
import { getPropertyToken } from '../metadata';
|
|
19
19
|
import { ConfigMetadataProvider } from '../metadata/config-metadata.provider';
|
|
20
20
|
import { ReloadEvents } from '../reload';
|
|
21
|
-
import type {
|
|
21
|
+
import type { PropertyMetadata } from '../types';
|
|
22
22
|
import { Vars } from '../vars.class';
|
|
23
23
|
|
|
24
24
|
export class ConfigContext {
|
|
@@ -49,14 +49,12 @@ export class ConfigContext {
|
|
|
49
49
|
* @private
|
|
50
50
|
*/
|
|
51
51
|
private readonly initializedConfigs = new Map<Constructor<Config>, Config>();
|
|
52
|
+
|
|
52
53
|
/**
|
|
53
54
|
* undefined является валидным значением по умолчанию (`defaultValue`)
|
|
54
55
|
* @private
|
|
55
56
|
*/
|
|
56
|
-
private readonly properties = new Map<
|
|
57
|
-
PropertyToken,
|
|
58
|
-
ConfigValue | undefined
|
|
59
|
-
>();
|
|
57
|
+
private readonly properties = new Map<PropertyToken, any>();
|
|
60
58
|
|
|
61
59
|
/**
|
|
62
60
|
* We don't use class as context here because it is undefined if
|
|
@@ -137,9 +135,7 @@ export class ConfigContext {
|
|
|
137
135
|
return instance as T;
|
|
138
136
|
}
|
|
139
137
|
|
|
140
|
-
resolveProperty(
|
|
141
|
-
token: `STANDALONE_CONFIG_PROPERTY_${string}`,
|
|
142
|
-
): ConfigValue | undefined {
|
|
138
|
+
resolveProperty(token: `STANDALONE_CONFIG_PROPERTY_${string}`): any {
|
|
143
139
|
if (this.properties.has(token)) {
|
|
144
140
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
145
141
|
return this.properties.get(token)!;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PropertyOptions, PropertyParser } from '../../types';
|
|
2
2
|
import { ConfigMetadataRegistry } from '../config-metadata.registry';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -16,7 +16,7 @@ import { ConfigMetadataRegistry } from '../config-metadata.registry';
|
|
|
16
16
|
* default value if exists
|
|
17
17
|
* @returns ClassDecorator
|
|
18
18
|
*/
|
|
19
|
-
export const DeclareProperty = <T
|
|
19
|
+
export const DeclareProperty = <T>(
|
|
20
20
|
/**
|
|
21
21
|
* Alias is used not only to declare, but also to inject
|
|
22
22
|
* properties. That's why this string is saved as is, while
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
ConfigValue,
|
|
3
2
|
PropertyOptions,
|
|
4
3
|
PropertyParser,
|
|
5
4
|
SectionMetadata,
|
|
@@ -16,7 +15,7 @@ export const CONFIG_METADATA_KEY = 'CONFIG_METADATA';
|
|
|
16
15
|
* @param options Additional options (default value, description etc.)
|
|
17
16
|
* @returns PropertyDecorator
|
|
18
17
|
*/
|
|
19
|
-
export const Property = <T
|
|
18
|
+
export const Property = <T>(
|
|
20
19
|
key: string,
|
|
21
20
|
parser: PropertyParser<T>,
|
|
22
21
|
options: PropertyOptions<T>,
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { Assert, text } from '@rsdk/common';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
PropertyParser,
|
|
5
|
-
RawConfigValue,
|
|
6
|
-
SingleConfigValue,
|
|
7
|
-
} from '../types';
|
|
3
|
+
import type { PropertyParser } from '../types';
|
|
8
4
|
|
|
9
|
-
export class ArrayParser<T
|
|
10
|
-
implements PropertyParser<T[]>
|
|
11
|
-
{
|
|
5
|
+
export class ArrayParser<T> implements PropertyParser<T[]> {
|
|
12
6
|
constructor(
|
|
13
7
|
private readonly singleValueParser: PropertyParser<T>,
|
|
14
8
|
private readonly options = { separator: ',' },
|
|
@@ -26,7 +20,7 @@ export class ArrayParser<T extends SingleConfigValue>
|
|
|
26
20
|
`;
|
|
27
21
|
}
|
|
28
22
|
|
|
29
|
-
parse(value:
|
|
23
|
+
parse(value: unknown): T[] {
|
|
30
24
|
if (Array.isArray(value)) {
|
|
31
25
|
return value.map((x) => this.singleValueParser.parse(x));
|
|
32
26
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Convert, text } from '@rsdk/common';
|
|
2
2
|
|
|
3
|
-
import type { PropertyParser
|
|
3
|
+
import type { PropertyParser } from '../../types';
|
|
4
4
|
|
|
5
5
|
export class BoolParser implements PropertyParser<boolean> {
|
|
6
6
|
type(): string {
|
|
@@ -14,7 +14,7 @@ export class BoolParser implements PropertyParser<boolean> {
|
|
|
14
14
|
`;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
parse(value:
|
|
17
|
+
parse(value: unknown): boolean {
|
|
18
18
|
return Convert.boolean(value);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EnumLike, EnumValue } from '@rsdk/common';
|
|
2
2
|
import { Convert, Enum, text } from '@rsdk/common';
|
|
3
3
|
|
|
4
|
-
import type { PropertyParser
|
|
4
|
+
import type { PropertyParser } from '../../types';
|
|
5
5
|
|
|
6
6
|
export class EnumParser<E extends EnumValue> implements PropertyParser<E> {
|
|
7
7
|
constructor(private readonly enumeration: EnumLike) {}
|
|
@@ -17,7 +17,7 @@ export class EnumParser<E extends EnumValue> implements PropertyParser<E> {
|
|
|
17
17
|
`;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
parse(value:
|
|
20
|
+
parse(value: unknown): E {
|
|
21
21
|
return Convert.enum<E>(value, this.enumeration);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Convert, text } from '@rsdk/common';
|
|
2
2
|
|
|
3
|
-
import type { PropertyParser
|
|
3
|
+
import type { PropertyParser } from '../../types';
|
|
4
4
|
|
|
5
5
|
export class IntParser implements PropertyParser<number> {
|
|
6
6
|
type(): string {
|
|
@@ -14,7 +14,7 @@ export class IntParser implements PropertyParser<number> {
|
|
|
14
14
|
`;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
parse(value:
|
|
17
|
+
parse(value: unknown): number {
|
|
18
18
|
return Convert.int(value);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Convert, text } from '@rsdk/common';
|
|
2
2
|
|
|
3
|
-
import type { PropertyParser
|
|
3
|
+
import type { PropertyParser } from '../../types';
|
|
4
4
|
|
|
5
5
|
export class NumberParser implements PropertyParser<number> {
|
|
6
6
|
type(): string {
|
|
@@ -17,7 +17,7 @@ export class NumberParser implements PropertyParser<number> {
|
|
|
17
17
|
`;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
parse(value:
|
|
20
|
+
parse(value: unknown): number {
|
|
21
21
|
return Convert.number(value);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -3,7 +3,7 @@ import { accessSync, existsSync, lstatSync } from 'node:fs';
|
|
|
3
3
|
import { isAbsolute, join } from 'node:path';
|
|
4
4
|
import { cwd } from 'node:process';
|
|
5
5
|
|
|
6
|
-
import type { PropertyParser
|
|
6
|
+
import type { PropertyParser } from '../../types';
|
|
7
7
|
|
|
8
8
|
export class FsPathParser implements PropertyParser<string> {
|
|
9
9
|
constructor(private readonly objectType: 'file' | 'dir') {}
|
|
@@ -19,7 +19,7 @@ export class FsPathParser implements PropertyParser<string> {
|
|
|
19
19
|
`;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
parse(value:
|
|
22
|
+
parse(value: unknown): string {
|
|
23
23
|
Assert.isString(value);
|
|
24
24
|
|
|
25
25
|
const wasRelative = !isAbsolute(value);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Assert, Size, SIZE_STRING_PATTERN, text } from '@rsdk/common';
|
|
2
2
|
|
|
3
|
-
import type { PropertyParser
|
|
3
|
+
import type { PropertyParser } from '../../types';
|
|
4
4
|
|
|
5
5
|
export class SizeParser implements PropertyParser<Size> {
|
|
6
6
|
type(): string {
|
|
@@ -14,7 +14,7 @@ export class SizeParser implements PropertyParser<Size> {
|
|
|
14
14
|
`;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
parse(value:
|
|
17
|
+
parse(value: unknown): Size {
|
|
18
18
|
Assert.isString(value);
|
|
19
19
|
|
|
20
20
|
return Size.parse(value);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Assert } from '@rsdk/common';
|
|
2
2
|
|
|
3
|
-
import type { PropertyParser
|
|
3
|
+
import type { PropertyParser } from '../../types';
|
|
4
4
|
|
|
5
5
|
export class StringParser implements PropertyParser<string> {
|
|
6
6
|
type(): string {
|
|
@@ -11,7 +11,7 @@ export class StringParser implements PropertyParser<string> {
|
|
|
11
11
|
return 'Extract arbitrary string.';
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
parse(value:
|
|
14
|
+
parse(value: unknown): string {
|
|
15
15
|
Assert.isString(value);
|
|
16
16
|
|
|
17
17
|
return value;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Assert, text, Timespan, TIMESPAN_STRING_PATTERN } from '@rsdk/common';
|
|
2
2
|
|
|
3
|
-
import type { PropertyParser
|
|
3
|
+
import type { PropertyParser } from '../../types';
|
|
4
4
|
|
|
5
5
|
export class TimespanParser implements PropertyParser<Timespan> {
|
|
6
6
|
type(): string {
|
|
@@ -14,7 +14,7 @@ export class TimespanParser implements PropertyParser<Timespan> {
|
|
|
14
14
|
`;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
parse(value:
|
|
17
|
+
parse(value: unknown): Timespan {
|
|
18
18
|
Assert.isString(value);
|
|
19
19
|
|
|
20
20
|
return Timespan.parse(value);
|
|
@@ -0,0 +1,21 @@
|
|
|
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(expectedProtocol: string, protocol: string, url: URL) {
|
|
13
|
+
super(`Invalid protocol: <${protocol}>, expected: ${expectedProtocol}`, {
|
|
14
|
+
details: {
|
|
15
|
+
protocol,
|
|
16
|
+
url,
|
|
17
|
+
expectedProtocol,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { Assert } from '@rsdk/common';
|
|
2
2
|
|
|
3
|
-
import type { PropertyParser
|
|
3
|
+
import type { PropertyParser } from '../../types';
|
|
4
|
+
|
|
5
|
+
import { InvalidProtocol, InvalidUrl } from './exception';
|
|
4
6
|
|
|
5
7
|
export class UrlParser implements PropertyParser<URL> {
|
|
8
|
+
constructor(readonly protocol?: string) {}
|
|
9
|
+
|
|
6
10
|
type(): string {
|
|
7
11
|
return 'URL';
|
|
8
12
|
}
|
|
@@ -11,9 +15,25 @@ export class UrlParser implements PropertyParser<URL> {
|
|
|
11
15
|
return 'Parses string into instance of URL';
|
|
12
16
|
}
|
|
13
17
|
|
|
14
|
-
parse(value:
|
|
18
|
+
parse(value: unknown): URL {
|
|
15
19
|
Assert.isString(value);
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
try {
|
|
22
|
+
const url = new URL(value);
|
|
23
|
+
|
|
24
|
+
this.assertProtocol(url);
|
|
25
|
+
return url;
|
|
26
|
+
} catch (error) {
|
|
27
|
+
throw new InvalidUrl(value, error);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private assertProtocol(url: URL): void {
|
|
32
|
+
if (!this.protocol) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (url.protocol !== this.protocol) {
|
|
36
|
+
throw new InvalidProtocol(this.protocol, url.protocol, url);
|
|
37
|
+
}
|
|
18
38
|
}
|
|
19
39
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isPrimitive, isRecord } from '@rsdk/common';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { RawValues, SourceType } from '../../types';
|
|
4
4
|
import { ConfigSourceException } from '../exceptions';
|
|
5
5
|
|
|
6
6
|
export abstract class ConfigSource {
|
|
@@ -81,7 +81,7 @@ export abstract class ConfigSource {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
return acc;
|
|
84
|
-
}, new Map<string,
|
|
84
|
+
}, new Map<string, unknown>());
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
abstract name(): string;
|
package/src/config/types.ts
CHANGED
|
@@ -1,25 +1,11 @@
|
|
|
1
|
-
import type { EnumValue, Primitive, Size, Timespan } from '@rsdk/common';
|
|
2
|
-
|
|
3
1
|
export type SourceType = 'static' | 'reloadable';
|
|
4
|
-
export type RawConfigValue = Primitive | Primitive[];
|
|
5
|
-
|
|
6
|
-
export type SingleConfigValue =
|
|
7
|
-
| string
|
|
8
|
-
| number
|
|
9
|
-
| boolean
|
|
10
|
-
| Timespan
|
|
11
|
-
| Size
|
|
12
|
-
| EnumValue
|
|
13
|
-
| URL;
|
|
14
|
-
|
|
15
|
-
export type ConfigValue = SingleConfigValue | SingleConfigValue[];
|
|
16
2
|
|
|
17
3
|
export interface Changes {
|
|
18
4
|
createdKeys: string[];
|
|
19
5
|
updatedKeys: string[];
|
|
20
6
|
}
|
|
21
7
|
|
|
22
|
-
export interface PropertyOptions<T
|
|
8
|
+
export interface PropertyOptions<T> {
|
|
23
9
|
/**
|
|
24
10
|
* Description of configuration property. Will automatically
|
|
25
11
|
* appear in documentation.
|
|
@@ -32,7 +18,7 @@ export interface PropertyOptions<T extends ConfigValue> {
|
|
|
32
18
|
defaultValue?: T | undefined;
|
|
33
19
|
}
|
|
34
20
|
|
|
35
|
-
export interface PropertyMetadata<T
|
|
21
|
+
export interface PropertyMetadata<T = any> {
|
|
36
22
|
key: string;
|
|
37
23
|
parser: PropertyParser<T>;
|
|
38
24
|
description: string;
|
|
@@ -80,10 +66,10 @@ export interface ParserMetadata {
|
|
|
80
66
|
* mostly during decorator factories (such as @Property()) code is
|
|
81
67
|
* executed. Thus output **can** be used in autodoc
|
|
82
68
|
*/
|
|
83
|
-
export interface PropertyParser<T
|
|
69
|
+
export interface PropertyParser<T = any> {
|
|
84
70
|
type(): string;
|
|
85
71
|
description(): string;
|
|
86
|
-
parse(value:
|
|
72
|
+
parse(value: unknown): T;
|
|
87
73
|
}
|
|
88
74
|
|
|
89
|
-
export type RawValues = Map<string,
|
|
75
|
+
export type RawValues = Map<string, unknown>;
|
package/src/config/vars.class.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
+
import { Case } from '@rsdk/common';
|
|
1
2
|
import { cloneDeep, isEqual } from 'lodash';
|
|
2
3
|
|
|
3
4
|
import { PropertyException } from './exceptions';
|
|
4
|
-
import type {
|
|
5
|
-
Changes,
|
|
6
|
-
ConfigValue,
|
|
7
|
-
PropertyMetadata,
|
|
8
|
-
RawConfigValue,
|
|
9
|
-
RawValues,
|
|
10
|
-
} from './types';
|
|
5
|
+
import type { Changes, PropertyMetadata, RawValues } from './types';
|
|
11
6
|
|
|
12
7
|
export enum SetResult {
|
|
13
8
|
CREATED,
|
|
@@ -16,7 +11,7 @@ export enum SetResult {
|
|
|
16
11
|
}
|
|
17
12
|
|
|
18
13
|
export class Vars {
|
|
19
|
-
private readonly values = new Map<string,
|
|
14
|
+
private readonly values = new Map<string, unknown>();
|
|
20
15
|
|
|
21
16
|
/**
|
|
22
17
|
* Expecting prefix is already converted to upper snake case
|
|
@@ -24,8 +19,8 @@ export class Vars {
|
|
|
24
19
|
*/
|
|
25
20
|
constructor(private readonly prefix: string) {}
|
|
26
21
|
|
|
27
|
-
set(key: string, value:
|
|
28
|
-
const preparedKey =
|
|
22
|
+
set(key: string, value: unknown): [SetResult, string] {
|
|
23
|
+
const preparedKey = Case.toUpperSnake(key);
|
|
29
24
|
const preparedValue = Array.isArray(value)
|
|
30
25
|
? cloneDeep(value).sort()
|
|
31
26
|
: value;
|
|
@@ -69,14 +64,12 @@ export class Vars {
|
|
|
69
64
|
return { createdKeys, updatedKeys };
|
|
70
65
|
}
|
|
71
66
|
|
|
72
|
-
extract<T
|
|
73
|
-
propertyMetadata: PropertyMetadata<T>,
|
|
74
|
-
): T | undefined {
|
|
67
|
+
extract<T>(propertyMetadata: PropertyMetadata<T>): T | undefined {
|
|
75
68
|
const { key, parser, defaultValue } = propertyMetadata;
|
|
76
|
-
const preparedKey =
|
|
69
|
+
const preparedKey = Case.toUpperSnake(key);
|
|
77
70
|
|
|
78
71
|
const withPrefix = this.prefix
|
|
79
|
-
? `${
|
|
72
|
+
? `${Case.toUpperSnake(this.prefix)}_${preparedKey}`
|
|
80
73
|
: preparedKey;
|
|
81
74
|
|
|
82
75
|
const raw = this.values.get(withPrefix) ?? this.values.get(preparedKey);
|
|
@@ -102,8 +95,4 @@ export class Vars {
|
|
|
102
95
|
});
|
|
103
96
|
}
|
|
104
97
|
}
|
|
105
|
-
|
|
106
|
-
private toUpperSnakeCase(key: string): string {
|
|
107
|
-
return key.replaceAll(/[^\dA-Za-z]+/g, '_').toUpperCase();
|
|
108
|
-
}
|
|
109
98
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { NestModuleDefinition } from '@rsdk/common';
|
|
1
|
+
import type { NestModuleDefinition } from '@rsdk/common.nestjs';
|
|
2
2
|
|
|
3
3
|
export const PLATFORM_RAW_GLOBAL_METADATA_SCOPE =
|
|
4
4
|
'PLATFORM_RAW_GLOBAL_RSDK_METADATA_SCOPE';
|
|
5
|
+
|
|
5
6
|
export type PlatformRawGlobalMetadata = NestModuleDefinition;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DynamicModule } from '@nestjs/common';
|
|
2
|
-
import type { NestModuleDefinition } from '@rsdk/common';
|
|
2
|
+
import type { NestModuleDefinition } from '@rsdk/common.nestjs';
|
|
3
3
|
import { flatten } from 'lodash';
|
|
4
4
|
|
|
5
5
|
import type { IErrorsFormatter, IErrorsSender } from '../exceptions.handling';
|
package/src/types/metadata.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { Primitive } from '@rsdk/common';
|
|
|
2
2
|
import { hasKey, isPrimitive } from '@rsdk/common';
|
|
3
3
|
|
|
4
4
|
import type {
|
|
5
|
-
ConfigValue,
|
|
6
5
|
ParserMetadata,
|
|
7
6
|
PropertyMetadata,
|
|
8
7
|
SectionMetadata,
|
|
@@ -18,7 +17,7 @@ export type SerializablePropertyMetadata = Omit<
|
|
|
18
17
|
};
|
|
19
18
|
|
|
20
19
|
function parseDefaultValue(
|
|
21
|
-
defaultValue:
|
|
20
|
+
defaultValue: any,
|
|
22
21
|
): Primitive | Primitive[] | undefined {
|
|
23
22
|
if (isPrimitive(defaultValue)) {
|
|
24
23
|
return defaultValue;
|
package/src/types/options.ts
CHANGED