@travetto/config 4.1.2 → 5.0.0-rc.1
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/LICENSE +1 -1
- package/README.md +12 -2
- package/package.json +4 -4
- package/src/parser/parser.ts +1 -1
- package/src/parser/yaml.ts +3 -3
- package/src/service.ts +3 -3
- package/src/source/file.ts +2 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npm install @travetto/config
|
|
|
13
13
|
yarn add @travetto/config
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
The config module provides support for loading application config on startup. Configuration values support the common [YAML](https://en.wikipedia.org/wiki/YAML) constructs as defined in [
|
|
16
|
+
The config module provides support for loading application config on startup. Configuration values support the common [YAML](https://en.wikipedia.org/wiki/YAML) constructs as defined in [yaml](https://github.com/eemeli/yaml). Additionally, the configuration is built upon the [Schema](https://github.com/travetto/travetto/tree/main/module/schema#readme "Data type registry for runtime validation, reflection and binding.") module, to enforce type correctness, and allow for validation of configuration as an entrypoint into the application. Given that all [@Config](https://github.com/travetto/travetto/tree/main/module/config/src/decorator.ts#L13) classes are [@Schema](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/schema.ts#L14)-based classes, all the standard [@Schema](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/schema.ts#L14) and [@Field](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L31) functionality applies.
|
|
17
17
|
|
|
18
18
|
## Resolution
|
|
19
19
|
The configuration information is comprised of:
|
|
@@ -76,6 +76,11 @@ Config {
|
|
|
76
76
|
{
|
|
77
77
|
priority: 100,
|
|
78
78
|
source: 'file://application',
|
|
79
|
+
detail: 'resources/application.yaml'
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
priority: 101,
|
|
83
|
+
source: 'file://application',
|
|
79
84
|
detail: 'module/config/doc/resources/application.yml'
|
|
80
85
|
},
|
|
81
86
|
{
|
|
@@ -198,7 +203,7 @@ $ trv main doc/dbconfig-run.ts
|
|
|
198
203
|
message: 'Failed to construct @travetto/config:doc/dbconfig○DBConfig as validation errors have occurred',
|
|
199
204
|
category: 'data',
|
|
200
205
|
type: 'ValidationResultError',
|
|
201
|
-
at: 2029-03-14T04:00:00.618Z,
|
|
206
|
+
at: '2029-03-14T04:00:00.618Z',
|
|
202
207
|
details: {
|
|
203
208
|
class: '@travetto/config:doc/dbconfig○DBConfig',
|
|
204
209
|
file: './doc/dbconfig.ts',
|
|
@@ -229,6 +234,11 @@ Config {
|
|
|
229
234
|
{
|
|
230
235
|
priority: 100,
|
|
231
236
|
source: 'file://application',
|
|
237
|
+
detail: 'resources/application.yaml'
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
priority: 101,
|
|
241
|
+
source: 'file://application',
|
|
232
242
|
detail: 'module/config/doc/resources/application.yml'
|
|
233
243
|
},
|
|
234
244
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-rc.1",
|
|
4
4
|
"description": "Configuration support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yaml",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"directory": "module/config"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@travetto/di": "^
|
|
30
|
-
"@travetto/schema": "^
|
|
31
|
-
"
|
|
29
|
+
"@travetto/di": "^5.0.0-rc.0",
|
|
30
|
+
"@travetto/schema": "^5.0.0-rc.0",
|
|
31
|
+
"yaml": "^2.4.5"
|
|
32
32
|
},
|
|
33
33
|
"travetto": {
|
|
34
34
|
"displayName": "Configuration"
|
package/src/parser/parser.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
2
3
|
|
|
3
4
|
import { DependencyRegistry, Injectable } from '@travetto/di';
|
|
4
5
|
import { AppError } from '@travetto/base';
|
|
5
|
-
import { path } from '@travetto/manifest';
|
|
6
6
|
|
|
7
7
|
import { ConfigParserTarget } from '../internal/types';
|
|
8
8
|
import { ConfigData, ConfigParser } from './types';
|
package/src/parser/yaml.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Injectable } from '@travetto/di';
|
|
2
|
-
import {
|
|
2
|
+
import { parse as parseYaml } from 'yaml';
|
|
3
3
|
|
|
4
|
-
import { ConfigParser } from './types';
|
|
4
|
+
import { ConfigData, ConfigParser } from './types';
|
|
5
5
|
|
|
6
6
|
@Injectable()
|
|
7
7
|
export class YAMLConfigParser implements ConfigParser {
|
|
8
8
|
ext = ['.yaml', '.yml'];
|
|
9
|
-
parse =
|
|
9
|
+
parse = (input: string): ConfigData => parseYaml(input) ?? {};
|
|
10
10
|
}
|
package/src/service.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import util from 'node:util';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { RuntimeIndex } from '@travetto/manifest';
|
|
4
|
+
import { AppError, Class, ClassInstance, Env, RuntimeContext, RuntimeResources } from '@travetto/base';
|
|
4
5
|
import { DependencyRegistry, Injectable } from '@travetto/di';
|
|
5
|
-
import { RuntimeIndex, RuntimeContext } from '@travetto/manifest';
|
|
6
6
|
import { BindUtil, DataUtil, SchemaRegistry, SchemaValidator, ValidationResultError } from '@travetto/schema';
|
|
7
7
|
|
|
8
8
|
import { ConfigSourceTarget, ConfigTarget } from './internal/types';
|
|
@@ -22,7 +22,7 @@ export class ConfigurationService {
|
|
|
22
22
|
|
|
23
23
|
#storage: Record<string, unknown> = {}; // Lowered, and flattened
|
|
24
24
|
#specs: ConfigSpecSimple[] = [];
|
|
25
|
-
#secrets: (RegExp | string)[] = [/secure(-|_|[a-z])|password|private|secret|salt|(api(-|_)?key)/i];
|
|
25
|
+
#secrets: (RegExp | string)[] = [/secure(-|_|[a-z])|password|private|secret|salt|(\bkey|key\b)|serviceAccount|(api(-|_)?key)/i];
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Get a sub tree of the config, or everything if namespace is not passed
|
package/src/source/file.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
2
3
|
|
|
3
|
-
import { Env, RuntimeResources } from '@travetto/base';
|
|
4
|
-
import { RuntimeContext, path } from '@travetto/manifest';
|
|
4
|
+
import { Env, RuntimeContext, RuntimeResources } from '@travetto/base';
|
|
5
5
|
|
|
6
6
|
import { ConfigSource, ConfigSpec } from './types';
|
|
7
7
|
import { ParserManager } from '../parser/parser';
|