@backstage/config-loader 1.1.9 → 1.3.0-next.0
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 +65 -0
- package/dist/index.cjs.js +1168 -377
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +447 -40
- package/package.json +7 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,43 +1,19 @@
|
|
|
1
|
-
import { AppConfig } from '@backstage/config';
|
|
2
1
|
import { JSONSchema7 } from 'json-schema';
|
|
3
|
-
import { JsonObject } from '@backstage/types';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Read runtime configuration from the environment.
|
|
7
|
-
*
|
|
8
|
-
* Only environment variables prefixed with APP_CONFIG_ will be considered.
|
|
9
|
-
*
|
|
10
|
-
* For each variable, the prefix will be removed, and rest of the key will
|
|
11
|
-
* be split by '_'. Each part will then be used as keys to build up a nested
|
|
12
|
-
* config object structure. The treatment of the entire environment variable
|
|
13
|
-
* is case-sensitive.
|
|
14
|
-
*
|
|
15
|
-
* The value of the variable should be JSON serialized, as it will be parsed
|
|
16
|
-
* and the type will be kept intact. For example "true" and true are treated
|
|
17
|
-
* differently, as well as "42" and 42.
|
|
18
|
-
*
|
|
19
|
-
* For example, to set the config app.title to "My Title", use the following:
|
|
20
|
-
*
|
|
21
|
-
* APP_CONFIG_app_title='"My Title"'
|
|
22
|
-
*
|
|
23
|
-
* @public
|
|
24
|
-
*/
|
|
25
|
-
declare function readEnvConfig(env: {
|
|
26
|
-
[name: string]: string | undefined;
|
|
27
|
-
}): AppConfig[];
|
|
2
|
+
import { JsonObject, HumanDuration, Observable } from '@backstage/types';
|
|
3
|
+
import { AppConfig, Config } from '@backstage/config';
|
|
28
4
|
|
|
29
5
|
/**
|
|
30
6
|
* A type representing the possible configuration value visibilities
|
|
31
7
|
*
|
|
32
8
|
* @public
|
|
33
9
|
*/
|
|
34
|
-
|
|
10
|
+
type ConfigVisibility = 'frontend' | 'backend' | 'secret';
|
|
35
11
|
/**
|
|
36
12
|
* A function used to transform primitive configuration values.
|
|
37
13
|
*
|
|
38
14
|
* @public
|
|
39
15
|
*/
|
|
40
|
-
|
|
16
|
+
type TransformFunc<T extends number | string | boolean> = (value: T, context: {
|
|
41
17
|
visibility: ConfigVisibility;
|
|
42
18
|
}) => T | undefined;
|
|
43
19
|
/**
|
|
@@ -45,7 +21,7 @@ declare type TransformFunc<T extends number | string | boolean> = (value: T, con
|
|
|
45
21
|
*
|
|
46
22
|
* @public
|
|
47
23
|
*/
|
|
48
|
-
|
|
24
|
+
type ConfigSchemaProcessingOptions = {
|
|
49
25
|
/**
|
|
50
26
|
* The visibilities that should be included in the output data.
|
|
51
27
|
* If omitted, the data will not be filtered by visibility.
|
|
@@ -80,7 +56,7 @@ declare type ConfigSchemaProcessingOptions = {
|
|
|
80
56
|
*
|
|
81
57
|
* @public
|
|
82
58
|
*/
|
|
83
|
-
|
|
59
|
+
type ConfigSchema = {
|
|
84
60
|
process(appConfigs: AppConfig[], options?: ConfigSchemaProcessingOptions): AppConfig[];
|
|
85
61
|
serialize(): JsonObject;
|
|
86
62
|
};
|
|
@@ -98,7 +74,7 @@ declare function mergeConfigSchemas(schemas: JSONSchema7[]): JSONSchema7;
|
|
|
98
74
|
*
|
|
99
75
|
* @public
|
|
100
76
|
*/
|
|
101
|
-
|
|
77
|
+
type LoadConfigSchemaOptions = {
|
|
102
78
|
dependencies: string[];
|
|
103
79
|
packagePaths?: string[];
|
|
104
80
|
} | {
|
|
@@ -111,14 +87,20 @@ declare type LoadConfigSchemaOptions = {
|
|
|
111
87
|
*/
|
|
112
88
|
declare function loadConfigSchema(options: LoadConfigSchemaOptions): Promise<ConfigSchema>;
|
|
113
89
|
|
|
114
|
-
/**
|
|
115
|
-
|
|
90
|
+
/**
|
|
91
|
+
* @public
|
|
92
|
+
* @deprecated Use {@link ConfigSources.default} instead.
|
|
93
|
+
*/
|
|
94
|
+
type ConfigTarget = {
|
|
116
95
|
path: string;
|
|
117
96
|
} | {
|
|
118
97
|
url: string;
|
|
119
98
|
};
|
|
120
|
-
/**
|
|
121
|
-
|
|
99
|
+
/**
|
|
100
|
+
* @public
|
|
101
|
+
* @deprecated Use {@link ConfigSources.default} instead.
|
|
102
|
+
*/
|
|
103
|
+
type LoadConfigOptionsWatch = {
|
|
122
104
|
/**
|
|
123
105
|
* A listener that is called when a config file is changed.
|
|
124
106
|
*/
|
|
@@ -128,8 +110,11 @@ declare type LoadConfigOptionsWatch = {
|
|
|
128
110
|
*/
|
|
129
111
|
stopSignal?: Promise<void>;
|
|
130
112
|
};
|
|
131
|
-
/**
|
|
132
|
-
|
|
113
|
+
/**
|
|
114
|
+
* @public
|
|
115
|
+
* @deprecated Use {@link ConfigSources.default} instead.
|
|
116
|
+
*/
|
|
117
|
+
type LoadConfigOptionsRemote = {
|
|
133
118
|
/**
|
|
134
119
|
* A remote config reloading period, in seconds
|
|
135
120
|
*/
|
|
@@ -139,8 +124,9 @@ declare type LoadConfigOptionsRemote = {
|
|
|
139
124
|
* Options that control the loading of configuration files in the backend.
|
|
140
125
|
*
|
|
141
126
|
* @public
|
|
127
|
+
* @deprecated Use {@link ConfigSources.default} instead.
|
|
142
128
|
*/
|
|
143
|
-
|
|
129
|
+
type LoadConfigOptions = {
|
|
144
130
|
configRoot: string;
|
|
145
131
|
configTargets: ConfigTarget[];
|
|
146
132
|
/**
|
|
@@ -161,8 +147,9 @@ declare type LoadConfigOptions = {
|
|
|
161
147
|
/**
|
|
162
148
|
* Results of loading configuration files.
|
|
163
149
|
* @public
|
|
150
|
+
* @deprecated Use {@link ConfigSources.default} instead.
|
|
164
151
|
*/
|
|
165
|
-
|
|
152
|
+
type LoadConfigResult = {
|
|
166
153
|
/**
|
|
167
154
|
* Array of all loaded configs.
|
|
168
155
|
*/
|
|
@@ -172,7 +159,427 @@ declare type LoadConfigResult = {
|
|
|
172
159
|
* Load configuration data.
|
|
173
160
|
*
|
|
174
161
|
* @public
|
|
162
|
+
* @deprecated Use {@link ConfigSources.default} instead.
|
|
175
163
|
*/
|
|
176
164
|
declare function loadConfig(options: LoadConfigOptions): Promise<LoadConfigResult>;
|
|
177
165
|
|
|
178
|
-
|
|
166
|
+
/**
|
|
167
|
+
* The data returned by {@link ConfigSource.readConfigData}.
|
|
168
|
+
*
|
|
169
|
+
* @public
|
|
170
|
+
*/
|
|
171
|
+
interface ConfigSourceData extends AppConfig {
|
|
172
|
+
/**
|
|
173
|
+
* The file path that this configuration was loaded from, if it was loaded from a file.
|
|
174
|
+
*/
|
|
175
|
+
path?: string;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Options for {@link ConfigSource.readConfigData}.
|
|
179
|
+
*
|
|
180
|
+
* @public
|
|
181
|
+
*/
|
|
182
|
+
interface ReadConfigDataOptions {
|
|
183
|
+
signal?: AbortSignal;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The the generator returned by {@link ConfigSource.readConfigData}.
|
|
187
|
+
*
|
|
188
|
+
* @public
|
|
189
|
+
*/
|
|
190
|
+
type AsyncConfigSourceGenerator = AsyncGenerator<{
|
|
191
|
+
configs: ConfigSourceData[];
|
|
192
|
+
}, void, void>;
|
|
193
|
+
/**
|
|
194
|
+
* A source of configuration data.
|
|
195
|
+
*
|
|
196
|
+
* @remarks
|
|
197
|
+
*
|
|
198
|
+
* It is recommended to implement the `readConfigData` method as an async generator.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
*
|
|
202
|
+
* ```ts
|
|
203
|
+
* class MyConfigSource implements ConfigSource {
|
|
204
|
+
* async *readConfigData() {
|
|
205
|
+
* yield {
|
|
206
|
+
* config: [{
|
|
207
|
+
* context: 'example',
|
|
208
|
+
* data: { backend: { baseUrl: 'http://localhost' } }
|
|
209
|
+
* }]
|
|
210
|
+
* };
|
|
211
|
+
* }
|
|
212
|
+
* }
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
215
|
+
* @public
|
|
216
|
+
*/
|
|
217
|
+
interface ConfigSource {
|
|
218
|
+
readConfigData(options?: ReadConfigDataOptions): AsyncConfigSourceGenerator;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* A custom function to be used for substitution withing configuration files.
|
|
222
|
+
*
|
|
223
|
+
* @remarks
|
|
224
|
+
*
|
|
225
|
+
* Substitutions use the following syntax: `baseUrl: https://${HOSTNAME}`, where
|
|
226
|
+
* `'HOSTNAME'` is the name of the variable to be substituted.
|
|
227
|
+
*
|
|
228
|
+
* The default substitution function will read the value of the environment.
|
|
229
|
+
*
|
|
230
|
+
* @public
|
|
231
|
+
*/
|
|
232
|
+
type SubstitutionFunc = (name: string) => Promise<string | undefined>;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Options for {@link RemoteConfigSource.create}.
|
|
236
|
+
*
|
|
237
|
+
* @public
|
|
238
|
+
*/
|
|
239
|
+
interface RemoteConfigSourceOptions {
|
|
240
|
+
/**
|
|
241
|
+
* The URL to load the config from.
|
|
242
|
+
*/
|
|
243
|
+
url: string;
|
|
244
|
+
/**
|
|
245
|
+
* How often to reload the config from the remote URL, defaults to 1 minute.
|
|
246
|
+
*
|
|
247
|
+
* Set to Infinity to disable reloading, for example `{ days: Infinity }`.
|
|
248
|
+
*/
|
|
249
|
+
reloadInterval?: HumanDuration;
|
|
250
|
+
/**
|
|
251
|
+
* A substitution function to use instead of the default environment substitution.
|
|
252
|
+
*/
|
|
253
|
+
substitutionFunc?: SubstitutionFunc;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* A config source that loads configuration from a remote URL.
|
|
257
|
+
*
|
|
258
|
+
* @public
|
|
259
|
+
*/
|
|
260
|
+
declare class RemoteConfigSource implements ConfigSource {
|
|
261
|
+
#private;
|
|
262
|
+
/**
|
|
263
|
+
* Creates a new {@link RemoteConfigSource}.
|
|
264
|
+
*
|
|
265
|
+
* @param options - Options for the source.
|
|
266
|
+
* @returns A new remote config source.
|
|
267
|
+
*/
|
|
268
|
+
static create(options: RemoteConfigSourceOptions): ConfigSource;
|
|
269
|
+
private constructor();
|
|
270
|
+
readConfigData(options?: ReadConfigDataOptions | undefined): AsyncConfigSourceGenerator;
|
|
271
|
+
toString(): string;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* A target to read configuration from.
|
|
276
|
+
*
|
|
277
|
+
* @public
|
|
278
|
+
*/
|
|
279
|
+
type ConfigSourceTarget = {
|
|
280
|
+
type: 'path';
|
|
281
|
+
target: string;
|
|
282
|
+
} | {
|
|
283
|
+
type: 'url';
|
|
284
|
+
target: string;
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* A config implementation that can be closed.
|
|
288
|
+
*
|
|
289
|
+
* @remarks
|
|
290
|
+
*
|
|
291
|
+
* Closing the configuration instance will stop the reading from the underlying source.
|
|
292
|
+
*
|
|
293
|
+
* @public
|
|
294
|
+
*/
|
|
295
|
+
interface ClosableConfig extends Config {
|
|
296
|
+
/**
|
|
297
|
+
* Closes the configuration instance.
|
|
298
|
+
*
|
|
299
|
+
* @remarks
|
|
300
|
+
*
|
|
301
|
+
* The configuration instance will still be usable after closing, but it will
|
|
302
|
+
* no longer be updated with new values from the underlying source.
|
|
303
|
+
*/
|
|
304
|
+
close(): void;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Common options for the default Backstage configuration sources.
|
|
308
|
+
*
|
|
309
|
+
* @public
|
|
310
|
+
*/
|
|
311
|
+
interface BaseConfigSourcesOptions {
|
|
312
|
+
rootDir?: string;
|
|
313
|
+
remote?: Pick<RemoteConfigSourceOptions, 'reloadInterval'>;
|
|
314
|
+
substitutionFunc?: SubstitutionFunc;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Options for {@link ConfigSources.defaultForTargets}.
|
|
318
|
+
*
|
|
319
|
+
* @public
|
|
320
|
+
*/
|
|
321
|
+
interface ConfigSourcesDefaultForTargetsOptions extends BaseConfigSourcesOptions {
|
|
322
|
+
targets: ConfigSourceTarget[];
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Options for {@link ConfigSources.default}.
|
|
326
|
+
*
|
|
327
|
+
* @public
|
|
328
|
+
*/
|
|
329
|
+
interface ConfigSourcesDefaultOptions extends BaseConfigSourcesOptions {
|
|
330
|
+
argv?: string[];
|
|
331
|
+
env?: Record<string, string>;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* A collection of utilities for working with and creating {@link ConfigSource}s.
|
|
335
|
+
*
|
|
336
|
+
* @public
|
|
337
|
+
*/
|
|
338
|
+
declare class ConfigSources {
|
|
339
|
+
/**
|
|
340
|
+
* Parses command line arguments and returns the config targets.
|
|
341
|
+
*
|
|
342
|
+
* @param argv - The command line arguments to parse. Defaults to `process.argv`
|
|
343
|
+
* @returns A list of config targets
|
|
344
|
+
*/
|
|
345
|
+
static parseArgs(argv?: string[]): ConfigSourceTarget[];
|
|
346
|
+
/**
|
|
347
|
+
* Creates the default config sources for the provided targets.
|
|
348
|
+
*
|
|
349
|
+
* @remarks
|
|
350
|
+
*
|
|
351
|
+
* This will create {@link FileConfigSource}s and {@link RemoteConfigSource}s
|
|
352
|
+
* for the provided targets, and merge them together to a single source.
|
|
353
|
+
* If no targets are provided it will fall back to `app-config.yaml` and
|
|
354
|
+
* `app-config.local.yaml`.
|
|
355
|
+
*
|
|
356
|
+
* URL targets are only supported if the `remote` option is provided.
|
|
357
|
+
*
|
|
358
|
+
* @param options - Options
|
|
359
|
+
* @returns A config source for the provided targets
|
|
360
|
+
*/
|
|
361
|
+
static defaultForTargets(options: ConfigSourcesDefaultForTargetsOptions): ConfigSource;
|
|
362
|
+
/**
|
|
363
|
+
* Creates the default config source for Backstage.
|
|
364
|
+
*
|
|
365
|
+
* @remarks
|
|
366
|
+
*
|
|
367
|
+
* This will read from `app-config.yaml` and `app-config.local.yaml` by
|
|
368
|
+
* default, as well as environment variables prefixed with `APP_CONFIG_`.
|
|
369
|
+
* If `--config <path|url>` command line arguments are passed, these will
|
|
370
|
+
* override the default configuration file paths. URLs are only supported
|
|
371
|
+
* if the `remote` option is provided.
|
|
372
|
+
*
|
|
373
|
+
* @param options - Options
|
|
374
|
+
* @returns The default Backstage config source
|
|
375
|
+
*/
|
|
376
|
+
static default(options: ConfigSourcesDefaultOptions): ConfigSource;
|
|
377
|
+
/**
|
|
378
|
+
* Merges multiple config sources into a single source that reads from all
|
|
379
|
+
* sources and concatenates the result.
|
|
380
|
+
*
|
|
381
|
+
* @param sources - The config sources to merge
|
|
382
|
+
* @returns A single config source that concatenates the data from the given sources
|
|
383
|
+
*/
|
|
384
|
+
static merge(sources: ConfigSource[]): ConfigSource;
|
|
385
|
+
/**
|
|
386
|
+
* Creates an observable {@link @backstage/config#Config} implementation from a {@link ConfigSource}.
|
|
387
|
+
*
|
|
388
|
+
* @remarks
|
|
389
|
+
*
|
|
390
|
+
* If you only want to read the config once you can close the returned config immediately.
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
*
|
|
394
|
+
* ```ts
|
|
395
|
+
* const sources = ConfigSources.default(...)
|
|
396
|
+
* const config = await ConfigSources.toConfig(source)
|
|
397
|
+
* config.close()
|
|
398
|
+
* const example = config.getString(...)
|
|
399
|
+
* ```
|
|
400
|
+
*
|
|
401
|
+
* @param source - The config source to read from
|
|
402
|
+
* @returns A promise that resolves to a closable config
|
|
403
|
+
*/
|
|
404
|
+
static toConfig(source: ConfigSource): Promise<ClosableConfig>;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Options for {@link EnvConfigSource.create}.
|
|
409
|
+
*
|
|
410
|
+
* @public
|
|
411
|
+
*/
|
|
412
|
+
interface EnvConfigSourceOptions {
|
|
413
|
+
/**
|
|
414
|
+
* The environment variables to use, defaults to `process.env`.
|
|
415
|
+
*/
|
|
416
|
+
env?: Record<string, string | undefined>;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* A config source that reads configuration from the environment.
|
|
420
|
+
*
|
|
421
|
+
* @remarks
|
|
422
|
+
*
|
|
423
|
+
* Only environment variables prefixed with APP_CONFIG_ will be considered.
|
|
424
|
+
*
|
|
425
|
+
* For each variable, the prefix will be removed, and rest of the key will
|
|
426
|
+
* be split by '_'. Each part will then be used as keys to build up a nested
|
|
427
|
+
* config object structure. The treatment of the entire environment variable
|
|
428
|
+
* is case-sensitive.
|
|
429
|
+
*
|
|
430
|
+
* The value of the variable should be JSON serialized, as it will be parsed
|
|
431
|
+
* and the type will be kept intact. For example "true" and true are treated
|
|
432
|
+
* differently, as well as "42" and 42.
|
|
433
|
+
*
|
|
434
|
+
* For example, to set the config app.title to "My Title", use the following:
|
|
435
|
+
*
|
|
436
|
+
* APP_CONFIG_app_title='"My Title"'
|
|
437
|
+
*
|
|
438
|
+
* @public
|
|
439
|
+
*/
|
|
440
|
+
declare class EnvConfigSource implements ConfigSource {
|
|
441
|
+
private readonly env;
|
|
442
|
+
/**
|
|
443
|
+
* Creates a new config source that reads from the environment.
|
|
444
|
+
*
|
|
445
|
+
* @param options - Options for the config source.
|
|
446
|
+
* @returns A new config source that reads from the environment.
|
|
447
|
+
*/
|
|
448
|
+
static create(options: EnvConfigSourceOptions): ConfigSource;
|
|
449
|
+
private constructor();
|
|
450
|
+
readConfigData(): AsyncConfigSourceGenerator;
|
|
451
|
+
toString(): string;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Read runtime configuration from the environment.
|
|
455
|
+
*
|
|
456
|
+
* @remarks
|
|
457
|
+
*
|
|
458
|
+
* Only environment variables prefixed with APP_CONFIG_ will be considered.
|
|
459
|
+
*
|
|
460
|
+
* For each variable, the prefix will be removed, and rest of the key will
|
|
461
|
+
* be split by '_'. Each part will then be used as keys to build up a nested
|
|
462
|
+
* config object structure. The treatment of the entire environment variable
|
|
463
|
+
* is case-sensitive.
|
|
464
|
+
*
|
|
465
|
+
* The value of the variable should be JSON serialized, as it will be parsed
|
|
466
|
+
* and the type will be kept intact. For example "true" and true are treated
|
|
467
|
+
* differently, as well as "42" and 42.
|
|
468
|
+
*
|
|
469
|
+
* For example, to set the config app.title to "My Title", use the following:
|
|
470
|
+
*
|
|
471
|
+
* APP_CONFIG_app_title='"My Title"'
|
|
472
|
+
*
|
|
473
|
+
* @public
|
|
474
|
+
* @deprecated Use {@link EnvConfigSource} instead
|
|
475
|
+
*/
|
|
476
|
+
declare function readEnvConfig(env: {
|
|
477
|
+
[name: string]: string | undefined;
|
|
478
|
+
}): AppConfig[];
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Options for {@link FileConfigSource.create}.
|
|
482
|
+
*
|
|
483
|
+
* @public
|
|
484
|
+
*/
|
|
485
|
+
interface FileConfigSourceOptions {
|
|
486
|
+
/**
|
|
487
|
+
* The path to the config file that should be loaded.
|
|
488
|
+
*/
|
|
489
|
+
path: string;
|
|
490
|
+
/**
|
|
491
|
+
* A substitution function to use instead of the default environment substitution.
|
|
492
|
+
*/
|
|
493
|
+
substitutionFunc?: SubstitutionFunc;
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* A config source that loads configuration from a local file.
|
|
497
|
+
*
|
|
498
|
+
* @public
|
|
499
|
+
*/
|
|
500
|
+
declare class FileConfigSource implements ConfigSource {
|
|
501
|
+
#private;
|
|
502
|
+
/**
|
|
503
|
+
* Creates a new config source that loads configuration from the given path.
|
|
504
|
+
*
|
|
505
|
+
* @remarks
|
|
506
|
+
*
|
|
507
|
+
* The source will watch the file for changes, as well as any referenced files.
|
|
508
|
+
*
|
|
509
|
+
* @param options - Options for the config source.
|
|
510
|
+
* @returns A new config source that loads from the given path.
|
|
511
|
+
*/
|
|
512
|
+
static create(options: FileConfigSourceOptions): ConfigSource;
|
|
513
|
+
private constructor();
|
|
514
|
+
readConfigData(options?: ReadConfigDataOptions): AsyncConfigSourceGenerator;
|
|
515
|
+
toString(): string;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Options for {@link MutableConfigSource.create}.
|
|
520
|
+
*
|
|
521
|
+
* @public
|
|
522
|
+
*/
|
|
523
|
+
interface MutableConfigSourceOptions {
|
|
524
|
+
data?: JsonObject;
|
|
525
|
+
context?: string;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* A config source that can be updated with new data.
|
|
529
|
+
*
|
|
530
|
+
* @public
|
|
531
|
+
*/
|
|
532
|
+
declare class MutableConfigSource implements ConfigSource {
|
|
533
|
+
#private;
|
|
534
|
+
/**
|
|
535
|
+
* Creates a new mutable config source.
|
|
536
|
+
*
|
|
537
|
+
* @param options - Options for the config source.
|
|
538
|
+
* @returns A new mutable config source.
|
|
539
|
+
*/
|
|
540
|
+
static create(options?: MutableConfigSourceOptions): MutableConfigSource;
|
|
541
|
+
private constructor();
|
|
542
|
+
readConfigData(options?: ReadConfigDataOptions | undefined): AsyncConfigSourceGenerator;
|
|
543
|
+
/**
|
|
544
|
+
* Set the data of the config source.
|
|
545
|
+
*
|
|
546
|
+
* @param data - The new data to set
|
|
547
|
+
*/
|
|
548
|
+
setData(data: JsonObject): void;
|
|
549
|
+
/**
|
|
550
|
+
* Close the config source, preventing any further updates.
|
|
551
|
+
*/
|
|
552
|
+
close(): void;
|
|
553
|
+
toString(): string;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Options for {@link StaticConfigSource.create}.
|
|
558
|
+
*
|
|
559
|
+
* @public
|
|
560
|
+
*/
|
|
561
|
+
interface StaticConfigSourceOptions {
|
|
562
|
+
data: JsonObject | Observable<JsonObject> | PromiseLike<JsonObject> | AsyncIterable<JsonObject>;
|
|
563
|
+
context?: string;
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* A configuration source that reads from a static object, promise, iterable, or observable.
|
|
567
|
+
*
|
|
568
|
+
* @public
|
|
569
|
+
*/
|
|
570
|
+
declare class StaticConfigSource implements ConfigSource {
|
|
571
|
+
private readonly promise;
|
|
572
|
+
private readonly context;
|
|
573
|
+
/**
|
|
574
|
+
* Creates a new {@link StaticConfigSource}.
|
|
575
|
+
*
|
|
576
|
+
* @param options - Options for the config source
|
|
577
|
+
* @returns A new static config source
|
|
578
|
+
*/
|
|
579
|
+
static create(options: StaticConfigSourceOptions): ConfigSource;
|
|
580
|
+
private constructor();
|
|
581
|
+
readConfigData(): AsyncConfigSourceGenerator;
|
|
582
|
+
toString(): string;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
export { AsyncConfigSourceGenerator, BaseConfigSourcesOptions, ClosableConfig, ConfigSchema, ConfigSchemaProcessingOptions, ConfigSource, ConfigSourceData, ConfigSourceTarget, ConfigSources, ConfigSourcesDefaultForTargetsOptions, ConfigSourcesDefaultOptions, ConfigTarget, ConfigVisibility, EnvConfigSource, EnvConfigSourceOptions, SubstitutionFunc as EnvFunc, FileConfigSource, FileConfigSourceOptions, LoadConfigOptions, LoadConfigOptionsRemote, LoadConfigOptionsWatch, LoadConfigResult, LoadConfigSchemaOptions, MutableConfigSource, MutableConfigSourceOptions, ReadConfigDataOptions, RemoteConfigSource, RemoteConfigSourceOptions, StaticConfigSource, StaticConfigSourceOptions, TransformFunc, loadConfig, loadConfigSchema, mergeConfigSchemas, readEnvConfig };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/config-loader",
|
|
3
3
|
"description": "Config loading functionality used by Backstage backend, and CLI",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0-next.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"main": "dist/index.cjs.js",
|
|
@@ -44,19 +44,23 @@
|
|
|
44
44
|
"json-schema": "^0.4.0",
|
|
45
45
|
"json-schema-merge-allof": "^0.8.1",
|
|
46
46
|
"json-schema-traverse": "^1.0.0",
|
|
47
|
+
"lodash": "^4.17.21",
|
|
48
|
+
"minimist": "^1.2.5",
|
|
47
49
|
"node-fetch": "^2.6.7",
|
|
48
50
|
"typescript-json-schema": "^0.55.0",
|
|
49
51
|
"yaml": "^2.0.0",
|
|
50
52
|
"yup": "^0.32.9"
|
|
51
53
|
},
|
|
52
54
|
"devDependencies": {
|
|
53
|
-
"@backstage/
|
|
55
|
+
"@backstage/backend-test-utils": "^0.1.37-next.0",
|
|
56
|
+
"@backstage/cli": "^0.22.7-next.0",
|
|
54
57
|
"@types/json-schema-merge-allof": "^0.6.0",
|
|
55
58
|
"@types/mock-fs": "^4.10.0",
|
|
56
59
|
"@types/node": "^16.11.26",
|
|
57
60
|
"@types/yup": "^0.29.13",
|
|
58
61
|
"mock-fs": "^5.1.0",
|
|
59
|
-
"msw": "^1.0.0"
|
|
62
|
+
"msw": "^1.0.0",
|
|
63
|
+
"zen-observable": "^0.10.0"
|
|
60
64
|
},
|
|
61
65
|
"files": [
|
|
62
66
|
"dist"
|