diff --git a/packages/config-loader/api-report.md b/packages/config-loader/api-report.md index 4ed409e3ce..3b61b67d7b 100644 --- a/packages/config-loader/api-report.md +++ b/packages/config-loader/api-report.md @@ -46,8 +46,8 @@ export type LoadConfigOptions = { configTargets: ConfigTarget[]; env?: string; experimentalEnvFunc?: (name: string) => Promise; - remote?: Remote; - watch?: Watch; + remote?: LoadConfigOptionsRemote; + watch?: LoadConfigOptionsWatch; }; // @public @@ -73,10 +73,10 @@ export function readEnvConfig(env: { [name: string]: string | undefined; }): AppConfig[]; -// Warning: (ae-missing-release-tag) "Remote" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// Warning: (ae-missing-release-tag) "LoadConfigOptionsRemote" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export type Remote = { +export type LoadConfigOptionsRemote = { reloadIntervalSeconds: number; }; @@ -88,10 +88,10 @@ export type TransformFunc = ( }, ) => T | undefined; -// Warning: (ae-missing-release-tag) "Watch" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// Warning: (ae-missing-release-tag) "LoadConfigOptionsWatch" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export type Watch = { +export type LoadConfigOptionsWatch = { onChange: (configs: AppConfig[]) => void; stopSignal?: Promise; }; diff --git a/packages/config-loader/src/index.ts b/packages/config-loader/src/index.ts index ee3e6413ad..97f0d301a3 100644 --- a/packages/config-loader/src/index.ts +++ b/packages/config-loader/src/index.ts @@ -29,4 +29,9 @@ export type { TransformFunc, } from './lib'; export { loadConfig } from './loader'; -export type { ConfigTarget, LoadConfigOptions, Watch, Remote } from './loader'; +export type { + ConfigTarget, + LoadConfigOptions, + LoadConfigOptionsWatch, + LoadConfigOptionsRemote, +} from './loader'; diff --git a/packages/config-loader/src/loader.ts b/packages/config-loader/src/loader.ts index c35b742f92..8c4bbae9d6 100644 --- a/packages/config-loader/src/loader.ts +++ b/packages/config-loader/src/loader.ts @@ -32,7 +32,7 @@ import { isValidUrl } from '@backstage/integration'; export type ConfigTarget = { path: string } | { url: string }; -export type Watch = { +export type LoadConfigOptionsWatch = { /** * A listener that is called when a config file is changed. */ @@ -44,12 +44,7 @@ export type Watch = { stopSignal?: Promise; }; -/** - * Options that control the loading of configuration files in the backend. - * - * @public - */ -export type Remote = { +export type LoadConfigOptionsRemote = { /** * An optional remote config reloading period, in seconds */ @@ -104,12 +99,12 @@ export type LoadConfigOptions = { /** * An optional remote config */ - remote?: Remote; + remote?: LoadConfigOptionsRemote; /** * An optional configuration that enables watching of config files. */ - watch?: Watch; + watch?: LoadConfigOptionsWatch; }; /** @@ -222,13 +217,13 @@ export async function loadConfig( try { remoteConfigs = await loadRemoteConfigFiles(); } catch (error) { - throw new Error(`Failed to read remote configuration file, ${error}`); + throw new ForwardedError(`Failed to read remote configuration file, ${error}`); } } const envConfigs = await readEnvConfig(process.env); - const watchConfigFile = (watchProp: Watch) => { + const watchConfigFile = (watchProp: LoadConfigOptionsWatch) => { const watcher = chokidar.watch(configPaths, { usePolling: process.env.NODE_ENV === 'test', }); @@ -257,7 +252,10 @@ export async function loadConfig( } }; - const watchRemoteConfig = (watchProp: Watch, remoteProp: Remote) => { + const watchRemoteConfig = ( + watchProp: LoadConfigOptionsWatch, + remoteProp: LoadConfigOptionsRemote, + ) => { const hasConfigChanged = async ( oldRemoteConfigs: AppConfig[], newRemoteConfigs: AppConfig[],