@rosen-bridge/config 0.1.0 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @rosen-bridge/config
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - add field validation for boolean type
8
+
9
+ ## 0.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - added array type support
14
+
3
15
  ## 0.1.0
4
16
 
5
17
  ### Minor Changes
package/dist/config.d.ts CHANGED
@@ -2,130 +2,147 @@ import { IConfig } from 'config';
2
2
  import { ConfigField, ConfigSchema } from './schema/types/fields';
3
3
  import { When } from './schema/types/validations';
4
4
  export declare class ConfigValidator {
5
- private schema;
6
- constructor(schema: ConfigSchema);
7
- /**
8
- * validates the passed config against the instance's schema
9
- *
10
- * @param {Record<string, any>} config
11
- */
12
- validateConfig(config: Record<string, any>): void;
13
- /**
14
- * validates a value in config object
15
- *
16
- * @private
17
- * @param {*} value
18
- * @param {ConfigField} field the field specification in schema
19
- * @param {Record<string, any>} config the config object
20
- */
21
- private validateValue;
22
- /**
23
- * determines if a when clause in validations section of a schema field is
24
- * satisfied
25
- *
26
- * @param {When} when
27
- * @param {Record<string, any>} config
28
- * @return {boolean}
29
- */
30
- isWhenTrue: (when: When, config: Record<string, any>) => boolean;
31
- /**
32
- * returns the value at specified path in config object
33
- *
34
- * @static
35
- * @param {Record<string, any>} config
36
- * @param {string[]} path
37
- * @return {*}
38
- */
39
- static valueAt: (config: Record<string, any>, path: string[]) => any;
40
- /**
41
- * validates this.schema and throws exception if any errors found
42
- */
43
- private validateSchema;
44
- /**
45
- * validates config key name
46
- *
47
- * @param {string} name
48
- */
49
- private validateConfigName;
50
- /**
51
- * validates passed schema field structure
52
- *
53
- * @param {ConfigField} field
54
- */
55
- private validateSchemaField;
56
- /**
57
- * returns a field corresponding to a path in schema tree
58
- *
59
- * @param {string[]} path
60
- * @return {(ConfigField | undefined)} returns undefined if field is not found
61
- */
62
- getSchemaField: (path: string[]) => ConfigField | undefined;
63
- /**
64
- * extracts default values from a schema
65
- *
66
- * @return {Record<string, any>} object of default values
67
- */
68
- generateDefault: () => Record<string, any>;
69
- /**
70
- * generates compatible TypeScript interface for this instance's schema
71
- *
72
- * @param {string} name the name of root type
73
- * @return {string}
74
- */
75
- generateTSTypes: (name: string) => string;
76
- /**
77
- * generates a TypeScript interface definition for passed name and attributes
78
- *
79
- * @param {string} name
80
- * @param {Array<[string, string]>} attributes
81
- * @return {string}
82
- */
83
- private genTSInterface;
84
- /**
85
- * returns a characteristic object for values at a specific node config level
86
- *
87
- * @param {IConfig} config
88
- * @param {string} level
89
- * @return {Record<string, any>}
90
- */
91
- getConfigForLevel(config: IConfig, level: string): Record<string, any>;
92
- /**
93
- *traverses the config schema depth first to produce characteristic object
94
- *
95
- * @private
96
- * @static
97
- * @param {ConfigSchema} schema
98
- * @param {string[]} path
99
- * @param {IConfigSource[]} higherLevelSources
100
- * @param {(IConfigSource | undefined)} currentLevelSource
101
- * @param {IConfigSource[]} lowerLevelSources
102
- * @return {Record<string, any>}
103
- * @memberof ConfigValidator
104
- */
105
- private static processConfigForLevelNode;
106
- /**
107
- * returns a list of config sources used by node config package, ordered from
108
- * the lowest to the highest priority
109
- *
110
- * @static
111
- * @param {IConfig} config
112
- * @return {string[]}
113
- */
114
- private static getNodeConfigLevels;
115
- /**
116
- * validates a config object and writes it to the node-config file
117
- * corresponding to the passed level
118
- *
119
- * @param {Record<string, any>} configObj
120
- * @param {IConfig} config
121
- * @param {string} level output node-config file level
122
- * @param {string} format the format of the output file
123
- */
124
- validateAndWriteConfig: (
125
- configObj: Record<string, any>,
126
- config: IConfig,
127
- level: string,
128
- format: string
129
- ) => void;
5
+ private schema;
6
+ constructor(schema: ConfigSchema);
7
+ /**
8
+ * validates the passed config against the instance's schema
9
+ *
10
+ * @param {Record<string, any>} config
11
+ */
12
+ validateConfig(config: Record<string, any>): void;
13
+ /**
14
+ * traverses and validates a subconfig using the subschema
15
+ *
16
+ * @private
17
+ * @param {Record<string, any>} config
18
+ * @param {Record<string, any>} subConfig
19
+ * @param {ConfigSchema} subSchema
20
+ * @param {string[]} path
21
+ * @memberof ConfigValidator
22
+ */
23
+ private validateSubConfig;
24
+ /**
25
+ * sets an object's specific subtree to the specified value
26
+ *
27
+ * @static
28
+ * @param {Record<string, any>} obj
29
+ * @param {*} newValue
30
+ * @param {string[]} path
31
+ * @return {*}
32
+ * @memberof ConfigValidator
33
+ */
34
+ static modifyObject(obj: Record<string, any>, newValue: any, path: string[]): void;
35
+ /**
36
+ * validates a value in config object
37
+ *
38
+ * @private
39
+ * @param {*} value
40
+ * @param {ConfigField} field the field specification in schema
41
+ * @param {Record<string, any>} config the config object
42
+ */
43
+ private validateValue;
44
+ /**
45
+ * determines if a when clause in validations section of a schema field is
46
+ * satisfied
47
+ *
48
+ * @param {When} when
49
+ * @param {Record<string, any>} config
50
+ * @return {boolean}
51
+ */
52
+ isWhenTrue: (when: When, config: Record<string, any>) => boolean;
53
+ /**
54
+ * returns the value at specified path in config object
55
+ *
56
+ * @static
57
+ * @param {Record<string, any>} config
58
+ * @param {string[]} path
59
+ * @return {*}
60
+ */
61
+ static valueAt: (config: Record<string, any>, path: string[]) => any;
62
+ /**
63
+ * validates this.schema and throws exception if any errors found
64
+ */
65
+ private validateSchema;
66
+ /**
67
+ * validates config key name
68
+ *
69
+ * @param {string} name
70
+ */
71
+ private validateConfigName;
72
+ /**
73
+ * validates passed schema field structure
74
+ *
75
+ * @param {ConfigField} field
76
+ */
77
+ private validateSchemaField;
78
+ /**
79
+ * returns a field corresponding to a path in schema tree
80
+ *
81
+ * @param {string[]} path
82
+ * @return {(ConfigField | undefined)} returns undefined if field is not found
83
+ */
84
+ getSchemaField: (path: string[]) => ConfigField | undefined;
85
+ /**
86
+ * extracts default values from a schema
87
+ *
88
+ * @return {Record<string, any>} object of default values
89
+ */
90
+ generateDefault: () => Record<string, any>;
91
+ /**
92
+ * generates compatible TypeScript interface for this instance's schema
93
+ *
94
+ * @param {string} name the name of root type
95
+ * @return {string}
96
+ */
97
+ generateTSTypes: (name: string) => string;
98
+ /**
99
+ * generates a TypeScript interface definition for passed name and attributes
100
+ *
101
+ * @param {string} name
102
+ * @param {Array<[string, string]>} attributes
103
+ * @return {string}
104
+ */
105
+ private genTSInterface;
106
+ /**
107
+ * returns a characteristic object for values at a specific node config level
108
+ *
109
+ * @param {IConfig} config
110
+ * @param {string} level
111
+ * @return {Record<string, any>}
112
+ */
113
+ getConfigForLevel(config: IConfig, level: string): Record<string, any>;
114
+ /**
115
+ *traverses the config schema depth first to produce characteristic object
116
+ *
117
+ * @private
118
+ * @static
119
+ * @param {ConfigSchema} schema
120
+ * @param {string[]} path
121
+ * @param {IConfigSource[]} higherLevelSources
122
+ * @param {(IConfigSource | undefined)} currentLevelSource
123
+ * @param {IConfigSource[]} lowerLevelSources
124
+ * @return {Record<string, any>}
125
+ * @memberof ConfigValidator
126
+ */
127
+ private static processConfigForLevelNode;
128
+ /**
129
+ * returns a list of config sources used by node config package, ordered from
130
+ * the lowest to the highest priority
131
+ *
132
+ * @static
133
+ * @param {IConfig} config
134
+ * @return {string[]}
135
+ */
136
+ private static getNodeConfigLevels;
137
+ /**
138
+ * validates a config object and writes it to the node-config file
139
+ * corresponding to the passed level
140
+ *
141
+ * @param {Record<string, any>} configObj
142
+ * @param {IConfig} config
143
+ * @param {string} level output node-config file level
144
+ * @param {string} format the format of the output file
145
+ */
146
+ validateAndWriteConfig: (configObj: Record<string, any>, config: IConfig, level: string, format: string) => void;
130
147
  }
131
- //# sourceMappingURL=config.d.ts.map
148
+ //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAiB,MAAM,QAAQ,CAAC;AAShD,OAAO,EAAE,WAAW,EAAE,YAAY,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