/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import type { ConfigTypes, IConfigProviderBase, ITelemetryBaseLogger } from "@fluidframework/core-interfaces"; import { Lazy } from "@fluidframework/core-utils/internal"; import { createChildLogger } from "./logger.js"; import type { ITelemetryLoggerExt, TelemetryLoggerExt } from "./telemetryTypes.js"; /** * Explicitly typed interface for reading configurations. * * @internal */ export interface IConfigProvider extends IConfigProviderBase { getBoolean(name: string): boolean | undefined; getNumber(name: string): number | undefined; getString(name: string): string | undefined; getBooleanArray(name: string): boolean[] | undefined; getNumberArray(name: string): number[] | undefined; getStringArray(name: string): string[] | undefined; } /** * Creates a base configuration provider based on `sessionStorage` * * @returns A lazy initialized base configuration provider with `sessionStorage` as the underlying config store * * @internal */ export declare const sessionStorageConfigProvider: Lazy; /** * Creates a base configuration provider based on the supplied `Storage` instance * * @param storage - instance of `Storage` to be used as storage media for the config * @returns A base configuration provider with * the supplied `Storage` instance as the underlying config store */ export declare const inMemoryConfigProvider: (storage: Storage | undefined) => IConfigProviderBase; /** * Creates a wrapper on top of an existing config provider which allows for * specifying feature gates if not present in the original provider. * * @param original - the original config provider * @param defaults - default feature gate configs to be used if not specified by the original provider * @returns A config provider that looks for any requested feature gates in the original provider and falls * back to the values specified in the `defaults` feature gates if they're not present in the original. * * @internal */ export declare const wrapConfigProviderWithDefaults: (original: IConfigProviderBase | undefined, defaults: Record) => IConfigProviderBase; /** * Implementation of {@link IConfigProvider} which contains nested {@link IConfigProviderBase} instances */ export declare class CachedConfigProvider implements IConfigProvider { private readonly logger?; private readonly configCache; private readonly orderedBaseProviders; constructor(logger?: ITelemetryBaseLogger | undefined, ...orderedBaseProviders: (IConfigProviderBase | undefined)[]); getBoolean(name: string): boolean | undefined; getNumber(name: string): number | undefined; getString(name: string): string | undefined; getBooleanArray(name: string): boolean[] | undefined; getNumberArray(name: string): number[] | undefined; getStringArray(name: string): string[] | undefined; getRawConfig(name: string): ConfigTypes; private getCacheEntry; } /** * A type containing both a telemetry logger and a configuration provider. * * @internal */ export interface MonitoringContext { config: IConfigProvider; logger: L extends ITelemetryLoggerExt ? TelemetryLoggerExt : L; } /** * Determines whether or not the provided object is a {@link MonitoringContext}. * @remarks Can be used for type-narrowing. * * @internal */ export declare function loggerIsMonitoringContext(obj: L): obj is L & MonitoringContext; /** * Creates a {@link MonitoringContext} from the provided logger, if it isn't already one. * * @internal */ export declare function loggerToMonitoringContext(logger: L): MonitoringContext; /** * Creates a {@link MonitoringContext} from the provided logger. * * @remarks * Assumes that the provided logger is not itself already a {@link MonitoringContext}, and will throw an error if it is. * If you are unsure, use {@link loggerToMonitoringContext} instead. * * @throws If the provided logger is already a {@link MonitoringContext}. * * @internal */ export declare function mixinMonitoringContext(logger: L, ...configs: (IConfigProviderBase | undefined)[]): MonitoringContext; /** * Creates a child logger with a {@link MonitoringContext}. * * @see {@link loggerToMonitoringContext} * @internal */ export declare function createChildMonitoringContext(props: Parameters[0]): MonitoringContext; /** * @internal * */ export type OptionConfigReaders = { [K in keyof T]?: K extends string ? (config: IConfigProvider, name: `Fluid.${string}.${K}`) => T[K] | undefined : undefined; }; /** * Creates a proxy object that allows for reading configuration values from a IConfigProviderBase, * and default to the provided options if the configuration value is not present. * * @param config - the configuration provider to read values from. * @param namespace - the namespace to use when reading configuration values. * @param configReaders - a mapping of option keys to configuration value readers. * @param defaultOptions - the default options to use if the configuration value is not present. * * @internal * */ export declare function createConfigBasedOptionsProxy(config: IConfigProviderBase, namespace: `Fluid.${string}`, configReaders: OptionConfigReaders, defaultOptions?: Partial): Readonly>; //# sourceMappingURL=config.d.ts.map