@rosen-bridge/config 2.0.0 → 2.1.0-411c498c
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/config.d.ts +28 -15
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +343 -130
- package/dist/schema/Validators/fieldProperties.d.ts +3 -0
- package/dist/schema/Validators/fieldProperties.d.ts.map +1 -1
- package/dist/schema/Validators/fieldProperties.js +11 -1
- package/dist/schema/types/fields.d.ts +9 -2
- package/dist/schema/types/fields.d.ts.map +1 -1
- package/dist/schema/types/fields.js +1 -1
- package/dist/value/validators.d.ts.map +1 -1
- package/dist/value/validators.js +22 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/config.d.ts
CHANGED
|
@@ -5,19 +5,12 @@ export declare class ConfigValidator {
|
|
|
5
5
|
private schema;
|
|
6
6
|
private constructor();
|
|
7
7
|
/**
|
|
8
|
-
* Builds the final configuration object
|
|
8
|
+
* Builds and returns the final configuration object by transforming and validating
|
|
9
9
|
*
|
|
10
|
-
*
|
|
10
|
+
* T - The type of the final normalized configuration object.
|
|
11
|
+
* @returns {T} The normalized configuration object
|
|
11
12
|
*/
|
|
12
|
-
buildConfigs: () =>
|
|
13
|
-
/**
|
|
14
|
-
* Recursively transforms a configuration object based on the provided schema.
|
|
15
|
-
* @param {any} data
|
|
16
|
-
* @param {any} schema
|
|
17
|
-
*
|
|
18
|
-
* @returns {Record<string, any>} A new object with transformed and normalized values
|
|
19
|
-
*/
|
|
20
|
-
private transformBySchema;
|
|
13
|
+
buildConfigs: <T>() => T;
|
|
21
14
|
/**
|
|
22
15
|
* create ConfigValidator from schema file path
|
|
23
16
|
*/
|
|
@@ -38,13 +31,30 @@ export declare class ConfigValidator {
|
|
|
38
31
|
* traverses and validates a subconfig using the subschema
|
|
39
32
|
*
|
|
40
33
|
* @private
|
|
41
|
-
* @param {Record<string, any>} config
|
|
42
|
-
* @param {Record<string, any>} subConfig
|
|
34
|
+
* @param {Record<string, any>} config - The full root configuration object
|
|
35
|
+
* @param {Record<string, any>} subConfig - The slice of config currently being
|
|
36
|
+
* validated
|
|
43
37
|
* @param {ConfigSchema} subSchema
|
|
44
38
|
* @param {string[]} path
|
|
39
|
+
* @param {Record<string, any>} context - he local scope object for
|
|
40
|
+
* resolving `when` conditions.
|
|
45
41
|
* @memberof ConfigValidator
|
|
46
42
|
*/
|
|
47
43
|
private validateSubConfig;
|
|
44
|
+
/**
|
|
45
|
+
* traverses and validates a union subconfig using the subschema
|
|
46
|
+
*
|
|
47
|
+
* @private
|
|
48
|
+
* @param {any} value
|
|
49
|
+
* @param {string} name
|
|
50
|
+
* @param {UnionField} field
|
|
51
|
+
* @param {Record<string, any>} config
|
|
52
|
+
* @param {string[]} childPath
|
|
53
|
+
*
|
|
54
|
+
* @param {Record<string, any>} context - he local scope object for
|
|
55
|
+
* resolving `when` conditions.
|
|
56
|
+
*/
|
|
57
|
+
private validateUnionValue;
|
|
48
58
|
/**
|
|
49
59
|
* sets an object's specific subtree to the specified value
|
|
50
60
|
*
|
|
@@ -63,6 +73,8 @@ export declare class ConfigValidator {
|
|
|
63
73
|
* @param {*} value
|
|
64
74
|
* @param {ConfigField} field the field specification in schema
|
|
65
75
|
* @param {Record<string, any>} config the config object
|
|
76
|
+
* @param {string[]} path
|
|
77
|
+
* @param {Record<string, any> | undefined} context
|
|
66
78
|
*/
|
|
67
79
|
private validateValue;
|
|
68
80
|
/**
|
|
@@ -71,9 +83,10 @@ export declare class ConfigValidator {
|
|
|
71
83
|
*
|
|
72
84
|
* @param {When} when
|
|
73
85
|
* @param {Record<string, any>} config
|
|
86
|
+
* @param {Record<string, any>} context
|
|
74
87
|
* @return {boolean}
|
|
75
88
|
*/
|
|
76
|
-
isWhenTrue: (when: When, config: Record<string, any>) => boolean;
|
|
89
|
+
isWhenTrue: (when: When, config: Record<string, any>, context?: Record<string, any>) => boolean;
|
|
77
90
|
/**
|
|
78
91
|
* returns the value at specified path in config object
|
|
79
92
|
*
|
|
@@ -82,7 +95,7 @@ export declare class ConfigValidator {
|
|
|
82
95
|
* @param {string[]} path
|
|
83
96
|
* @return {*}
|
|
84
97
|
*/
|
|
85
|
-
static valueAt: (config:
|
|
98
|
+
static valueAt: (config: any, path: string[]) => any;
|
|
86
99
|
/**
|
|
87
100
|
* validates this.schema and throws exception if any errors found
|
|
88
101
|
*/
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAiB,MAAM,QAAQ,CAAC;AAQhD,OAAO,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAiB,MAAM,QAAQ,CAAC;AAQhD,OAAO,EACL,WAAW,EACX,YAAY,EAEZ,SAAS,EACV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAYlD,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAe;IAE7B,OAAO;IAKP;;;;;OAKG;IACH,YAAY,GAAI,CAAC,OAAK,CAAC,CAIrB;IAEF;;OAEG;IACH,MAAM,CAAC,QAAQ,GAAI,YAAY,MAAM,KAAG,eAAe,CAUrD;IAEF;;;;OAIG;IACH,MAAM,CAAC,UAAU,GAAI,QAAQ,YAAY,KAAG,eAAe,CAEzD;IAEF;;;;OAIG;IAEI,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAWjD;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,iBAAiB;IAyDzB;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,kBAAkB;IAsE1B;;;;;;;;;OASG;IACH,MAAM,CAAC,YAAY,CAEjB,GAAG,EAAE,MAAM,C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