Skip to main content Link Search Menu Expand Document (external link)

ConfigProvider overview

Added in v1.0.0


Table of contents


combinators

constantCase

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

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

Added in v1.0.0

kebabCase

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

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

Added in v1.0.0

lowerCase

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

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

Added in v1.0.0

snakeCase

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

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

Added in v1.0.0

upperCase

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

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

Added in v1.0.0

within

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

Signature

export declare const within: {
  (path: ReadonlyArray<string>, f: (self: ConfigProvider) => ConfigProvider): (self: ConfigProvider) => ConfigProvider
  (self: ConfigProvider, path: ReadonlyArray<string>, f: (self: ConfigProvider) => ConfigProvider): ConfigProvider
}

Added in v1.0.0

constructors

fromEnv

A config provider that loads configuration from context variables, using the default System service.

Signature

export declare const fromEnv: (config?: ConfigProvider.FromEnvConfig) => ConfigProvider

Added in v1.0.0

fromFlat

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

Signature

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

Added in v1.0.0

fromMap

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

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

Added in v1.0.0

make

Creates a new config provider.

Signature

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

Added in v1.0.0

makeFlat

Creates a new flat config provider.

Signature

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

Added in v1.0.0

context

ConfigProvider

The service tag for ConfigProvider.

Signature

export declare const ConfigProvider: Context.Tag<ConfigProvider, ConfigProvider>

Added in v1.0.0

models

ConfigProvider (interface)

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

Signature

export interface ConfigProvider extends ConfigProvider.Proto, Pipeable {
  /**
   * Loads the specified configuration, or fails with a config error.
   */
  load<A>(config: Config.Config<A>): Effect.Effect<never, ConfigError.ConfigError, A>
  /**
   * Flattens this config provider into a simplified config provider that knows
   * only how to deal with flat (key/value) properties.
   */
  flattened: ConfigProvider.Flat
}

Added in v1.0.0

symbols

ConfigProviderTypeId

Signature

export declare const ConfigProviderTypeId: typeof ConfigProviderTypeId

Added in v1.0.0

ConfigProviderTypeId (type alias)

Signature

export type ConfigProviderTypeId = typeof ConfigProviderTypeId

Added in v1.0.0

FlatConfigProviderTypeId

Signature

export declare const FlatConfigProviderTypeId: typeof FlatConfigProviderTypeId

Added in v1.0.0

FlatConfigProviderTypeId (type alias)

Signature

export type FlatConfigProviderTypeId = typeof FlatConfigProviderTypeId

Added in v1.0.0

utils

ConfigProvider (namespace)

Added in v1.0.0

Flat (interface)

A simplified config provider that knows only how to deal with flat (key/value) properties. Because these providers are common, there is special support for implementing them.

Signature

export interface Flat {
  readonly [FlatConfigProviderTypeId]: FlatConfigProviderTypeId
  patch: PathPatch.PathPatch
  load<A>(
    path: ReadonlyArray<string>,
    config: Config.Config.Primitive<A>,
    split?: boolean
  ): Effect.Effect<never, ConfigError.ConfigError, ReadonlyArray<A>>
  enumerateChildren(path: ReadonlyArray<string>): Effect.Effect<never, ConfigError.ConfigError, HashSet.HashSet<string>>
}

Added in v1.0.0

FromEnvConfig (interface)

Signature

export interface FromEnvConfig {
  readonly pathDelim: string
  readonly seqDelim: string
}

Added in v1.0.0

FromMapConfig (interface)

Signature

export interface FromMapConfig {
  readonly pathDelim: string
  readonly seqDelim: string
}

Added in v1.0.0

Proto (interface)

Signature

export interface Proto {
  readonly [ConfigProviderTypeId]: ConfigProviderTypeId
}

Added in v1.0.0

mapInputPath

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

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

Added in v1.0.0

nested

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

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

Added in v1.0.0

orElse

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

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

Added in v1.0.0

unnested

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

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

Added in v1.0.0