@@ -12,15 +12,27 @@ export const InArray = Symbol('InArray');
12
12
/** The property being visited is the root object */
13
13
export const Root = Symbol ( 'Root' ) ;
14
14
15
+ /** Descriptor for what "key" that a value was defined under within JSON */
15
16
export type ParsingExtensionKey =
16
17
| [ typeof InObject , string ]
17
18
| [ typeof InArray , number ]
18
19
| [ typeof Root ] ;
19
20
21
+ /**
22
+ * Arbitrary context that's passed through the hierachy during parsing, only downwards.
23
+ *
24
+ * This is used for environment overrides and other options, so that parsing below some
25
+ * level in an object tree can override what the current environment is.
26
+ */
20
27
export interface ParsingContext {
21
28
[ k : string ] : string | string [ ] | undefined | ParsingContext ;
22
29
}
23
30
31
+ /**
32
+ * Performs transformations on raw values that were read.
33
+ *
34
+ * See https://app-config.dev/guide/intro/extensions.html
35
+ */
24
36
export interface ParsingExtension {
25
37
(
26
38
value : Json ,
@@ -37,6 +49,9 @@ export interface ParsingExtension {
37
49
extensionName ?: string ;
38
50
}
39
51
52
+ /**
53
+ * Callback that will process and potentially transform a value.
54
+ */
40
55
export type ParsingExtensionTransform = (
41
56
parse : (
42
57
value : Json ,
@@ -51,6 +66,7 @@ export type ParsingExtensionTransform = (
51
66
root : Json ,
52
67
) => Promise < ParsedValue > | ParsedValue ;
53
68
69
+ /** Values associated with a ParsedValue */
54
70
export interface ParsedValueMetadata {
55
71
[ key : string ] : any ;
56
72
}
@@ -195,7 +211,7 @@ export class ParsedValue {
195
211
return this ;
196
212
}
197
213
198
- /** Lookup property by nested key */
214
+ /** Lookup property by nested key name(s) */
199
215
property ( [ key , ...rest ] : string [ ] ) : ParsedValue | undefined {
200
216
if ( key === '' ) return this . property ( rest ) ;
201
217
@@ -350,6 +366,7 @@ function literalParsedValue(raw: Json, source: ConfigSource): ParsedValue {
350
366
return new ParsedValue ( source , raw , transformed ) ;
351
367
}
352
368
369
+ /** Same as ParsedValue.parse */
353
370
export async function parseValue (
354
371
value : Json ,
355
372
source : ConfigSource ,
0 commit comments