UNPKG

wj-config

Version:

Javascript configuration module for NodeJS and browser frameworks such as React that works like ASP.net configuration where data sources are specified (usually JSON files) and environment variables can contribute/overwrite values by following a naming con

19 lines 2.55 kB
import type { ConfigurationValue, IBuilder, IDataSource, IEnvironment, IncludeEnvironment, InflateDictionary, InflateKey, MergeResult, Predicate, ProcessFetchResponse, UrlBuilderSectionWithCheck } from "../wj-config.js"; import { EnvAwareBuilder } from "./EnvAwareBuilder.js"; export declare class Builder<T extends Record<string, any> = {}> implements IBuilder<T> { #private; add<NewT extends Record<string, any>>(dataSource: IDataSource<NewT>): IBuilder<MergeResult<T, NewT>>; addObject<NewT extends Record<string, any>>(obj: NewT | (() => Promise<NewT>)): IBuilder<MergeResult<T, NewT>>; addDictionary<TDic extends Record<string, ConfigurationValue>, TSep extends string = ':'>(dictionary: TDic | (() => Promise<TDic>), hierarchySeparator?: TSep, prefixOrPredicate?: string | Predicate<string | number>): IBuilder<MergeResult<T, Exclude<InflateDictionary<TDic, TSep>, unknown>>>; addEnvironment<TDic extends Record<string, ConfigurationValue>, TPrefix extends string = 'OPT_'>(env: TDic | (() => Promise<TDic>), prefix?: string): IBuilder<MergeResult<T, InflateDictionary<TDic, "__", TPrefix>>>; addFetched<NewT extends Record<string, any>>(input: URL | RequestInfo | (() => Promise<URL | RequestInfo>), required?: boolean, init?: RequestInit, procesFn?: ProcessFetchResponse<NewT>): IBuilder<MergeResult<T, NewT>>; addJson<NewT extends Record<string, any>>(json: string | (() => Promise<string>), jsonParser?: JSON, reviver?: (this: any, key: string, value: any) => any): IBuilder<MergeResult<T, NewT>>; addSingleValue<TKey extends string, TValue extends ConfigurationValue, TSep extends string = ':'>(path: TKey | (() => Promise<[TKey, TValue]>), valueOrHierarchySeparator?: TValue | TSep, hierarchySeparator?: TSep): IBuilder<MergeResult<T, InflateKey<TKey, TValue, TSep>>>; postMerge<U extends Record<string, any> = T>(fn: (config: T) => U | Promise<U>): IBuilder<U>; name(name: string): this; when(predicate: () => boolean, dataSourceName?: string): this; includeEnvironment<TEnvironments extends string, TEnvironmentKey extends string = "environment">(env: IEnvironment<TEnvironments>, propertyName?: TEnvironmentKey): EnvAwareBuilder<TEnvironments, Omit<T, TEnvironmentKey> & IncludeEnvironment<TEnvironments, TEnvironmentKey>>; createUrlFunctions<TUrl extends keyof T>(wsPropertyNames: TUrl | TUrl[], routeValuesRegExp?: RegExp): IBuilder<Omit<T, TUrl> & UrlBuilderSectionWithCheck<T, TUrl>>; build(traceValueSources?: boolean): Promise<T>; } //# sourceMappingURL=Builder.d.ts.map