Skip to content

ConfigProvider

23 exports Added in v2.0.0 Source

Combinators

constantCase

Added in v2.0.0 Source

Returns a new config provider that will automatically convert all property names to constant case. This can be utilized to adapt the names of configuration properties from the default naming convention of camel case to the naming convention of a config provider.

Signature

declare const constantCase: (self: ConfigProvider) => ConfigProvider;

kebabCase

Added in v2.0.0 Source

Returns a new config provider that will automatically convert all property names to kebab case. This can be utilized to adapt the names of configuration properties from the default naming convention of camel case to the naming convention of a config provider.

Signature

declare const kebabCase: (self: ConfigProvider) => ConfigProvider;

lowerCase

Added in v2.0.0 Source

Returns a new config provider that will automatically convert all property names to lower case. This can be utilized to adapt the names of configuration properties from the default naming convention of camel case to the naming convention of a config provider.

Signature

declare const lowerCase: (self: ConfigProvider) => ConfigProvider;

snakeCase

Added in v2.0.0 Source

Returns a new config provider that will automatically convert all property names to upper case. This can be utilized to adapt the names of configuration properties from the default naming convention of camel case to the naming convention of a config provider.

Signature

declare const snakeCase: (self: ConfigProvider) => ConfigProvider;

upperCase

Added in v2.0.0 Source

Returns a new config provider that will automatically convert all property names to upper case. This can be utilized to adapt the names of configuration properties from the default naming convention of camel case to the naming convention of a config provider.

Signature

declare const upperCase: (self: ConfigProvider) => ConfigProvider;

within

Added in v2.0.0 Source

Returns a new config provider that transforms the config provider with the specified function within the specified path.

Signature

declare const within: {
  (path: readonly Array<string>, f: (self: ConfigProvider) => ConfigProvider): (self: ConfigProvider) => ConfigProvider;
  (self: ConfigProvider, path: readonly Array<string>, f: (self: ConfigProvider) => ConfigProvider): ConfigProvider;
}

Constructors

fromEnv

Added in v2.0.0 Source

A config provider that loads configuration from context variables

Options:

- pathDelim: The delimiter for the path segments (default: "_"). - seqDelim: The delimiter for the sequence of values (default: ",").

Signature

declare const fromEnv: (options?: Partial<ConfigProvider.FromEnvConfig>) => ConfigProvider;

fromFlat

Added in v2.0.0 Source

Constructs a new ConfigProvider from a key/value (flat) provider, where nesting is embedded into the string keys.

Signature

declare const fromFlat: (flat: ConfigProvider.Flat) => ConfigProvider;

fromJson

Added in v2.0.0 Source

Constructs a new ConfigProvider from a JSON object.

Signature

declare const fromJson: (json: unknown) => ConfigProvider;

fromMap

Added in v2.0.0 Source

Constructs a ConfigProvider using a map and the specified delimiter string, which determines how to split the keys in the map into path segments.

Signature

declare const fromMap: (
  map: Map<string, string>,
  config?: Partial<ConfigProvider.FromMapConfig>,
) => ConfigProvider;

make

Added in v2.0.0 Source

Creates a new config provider.

Signature

declare const make: (options: {
  readonly flattened: ConfigProvider.Flat;
  readonly load: <A>(config: Config.Config<A>) => Effect.Effect<A, ConfigError.ConfigError>;
}) => ConfigProvider;

makeFlat

Added in v2.0.0 Source

Creates a new flat config provider.

Signature

declare const makeFlat: (options: {
  readonly enumerateChildren: (
    path: ReadonlyArray<string>,
  ) => Effect.Effect<HashSet.HashSet<string>, ConfigError.ConfigError>;
  readonly load: <A>(
    path: ReadonlyArray<string>,
    config: Config.Config.Primitive<A>,
    split: boolean,
  ) => Effect.Effect<Array<A>, ConfigError.ConfigError>;
  readonly patch: PathPatch.PathPatch;
}) => ConfigProvider.Flat;

Context

The service tag for ConfigProvider.

Signature

declare const ConfigProvider: Tag<ConfigProvider, ConfigProvider>;

Models

ConfigProvider interface

Added in v2.0.0 Source

A ConfigProvider is a service that provides configuration given a description of the structure of that configuration.

Signature

interface ConfigProvider extends Proto, Pipeable {
  readonly flattened: Flat;
  load<A>(config: Config<A>): Effect<A, ConfigError>;
}

Other

Symbols

Signature

declare const ConfigProviderTypeId: unique symbol;

ConfigProviderTypeId type

Added in v2.0.0 Source

Signature

type ConfigProviderTypeId = typeof ConfigProviderTypeId;

Signature

declare const FlatConfigProviderTypeId: unique symbol;

Signature

type FlatConfigProviderTypeId = typeof FlatConfigProviderTypeId;

Utils

mapInputPath

Added in v2.0.0 Source

Returns a new config provider that will automatically tranform all path configuration names with the specified function. This can be utilized to adapt the names of configuration properties from one naming convention to another.

Signature

declare const mapInputPath: {
  (f: (path: string) => string): (self: ConfigProvider) => ConfigProvider;
  (self: ConfigProvider, f: (path: string) => string): ConfigProvider;
};

nested

Added in v2.0.0 Source

Returns a new config provider that will automatically nest all configuration under the specified property name. This can be utilized to aggregate separate configuration sources that are all required to load a single configuration value.

Signature

declare const nested: {
  (name: string): (self: ConfigProvider) => ConfigProvider;
  (self: ConfigProvider, name: string): ConfigProvider;
};

orElse

Added in v2.0.0 Source

Returns a new config provider that preferentially loads configuration data from this one, but which will fall back to the specified alternate provider if there are any issues loading the configuration from this provider.

Signature

declare const orElse: {
  (that: LazyArg<ConfigProvider>): (self: ConfigProvider) => ConfigProvider;
  (self: ConfigProvider, that: LazyArg<ConfigProvider>): ConfigProvider;
};

unnested

Added in v2.0.0 Source

Returns a new config provider that will automatically un-nest all configuration under the specified property name. This can be utilized to de-aggregate separate configuration sources that are all required to load a single configuration value.

Signature

declare const unnested: {
  (name: string): (self: ConfigProvider) => ConfigProvider;
  (self: ConfigProvider, name: string): ConfigProvider;
};