Skip to content
Effect 4.0 is here. One ecosystem. Zero dependencies.

ConfigProvider

23 exports Since v2.0.0 Source

Combinators

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

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

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

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

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
Since v2.0.0

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

Since v2.0.0

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
Since v2.0.0

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
Since v2.0.0

Constructs a new ConfigProvider from a JSON object.

Signature

declare const fromJson: (json: unknown) => ConfigProvider
Since v2.0.0

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
Since v2.0.0

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
Since v2.0.0

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

Since v2.0.0

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

Signature

type ConfigProviderTypeId = typeof ConfigProviderTypeId

Signature

declare const FlatConfigProviderTypeId: unique symbol

Signature

type FlatConfigProviderTypeId = typeof FlatConfigProviderTypeId

Utils

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;
}
Since v2.0.0

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;
}
Since v2.0.0

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;
}
Since v2.0.0

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;
}