Config
Constructors
Signature
declare const all: <Arg extends Iterable<Config<any>> | Record<string, Config<any>>>(
arg: Arg,
) => Config<
[Arg] extends [ReadonlyArray<Config<any>>]
? { [K in keyof Arg]: [Arg[K]] extends [Config<infer A>] ? A : never }
: [Arg] extends [Iterable<Config<infer A>>]
? Array<A>
: [Arg] extends [Record<string, Config<any>>]
? { [K in keyof Arg]: [Arg[K]] extends [Config<infer A>] ? A : never }
: never
>;Constructs a config for an array of values.
Signature
declare const array: <A>(config: Config<A>, name?: string) => Config<Array<A>>;Constructs a config for a boolean value.
Signature
declare const boolean: (name?: string) => Config<boolean>;Constructs a config for a branded value.
Signature
declare const branded: {
<A, B extends Brand<any>>(constructor: Constructor<B>): (config: Config<A>) => Config<B>;
<B extends Branded<string, any>>(
name: string | undefined,
constructor: Constructor<B>,
): Config<B>;
<A, B extends Brand<any>>(config: Config<A>, constructor: Constructor<B>): Config<B>;
};Constructs a config for a sequence of values.
Signature
declare const chunk: <A>(config: Config<A>, name?: string) => Config<Chunk.Chunk<A>>;Constructs a config for a date value.
Signature
declare const date: (name?: string) => Config<Date>;Constructs a config for a duration value.
Signature
declare const duration: (name?: string) => Config<Duration.Duration>;Constructs a config that fails with the specified message.
Signature
declare const fail: (message: string) => Config<never>;Constructs a config for a sequence of values.
Signature
declare const hashMap: <A>(config: Config<A>, name?: string) => Config<HashMap.HashMap<string, A>>;Constructs a config for a sequence of values.
Signature
declare const hashSet: <A>(config: Config<A>, name?: string) => Config<HashSet.HashSet<A>>;Constructs a config for a integer value.
Signature
declare const integer: (name?: string) => Config<number>;Constructs a config for a literal value.
Signature
declare const literal: <Literals extends ReadonlyArray<LiteralValue>>(
...literals: Literals
) => (name?: string) => Config<Literals[number]>;Example
import { Config } from "effect"
const config = Config.literal("http", "https")("PROTOCOL")Constructs a config for a LogLevel value.
Signature
declare const logLevel: (name?: string) => Config<LogLevel.LogLevel>;nonEmptyString
Constructs a config for a non-empty string value.
Signature
declare const nonEmptyString: (name?: string) => Config<string>;Constructs a config for a float value.
Signature
declare const number: (name?: string) => Config<number>;Constructs a config for a network port [1, 65535].
Signature
declare const port: (name?: string) => Config<number>;Constructs a new primitive config.
Signature
declare const primitive: <A>(
description: string,
parse: (text: string) => Either.Either<A, ConfigError.ConfigError>,
) => Config<A>;Constructs a config for a redacted value.
Signature
declare const redacted: {
(name?: string): Config<Redacted<string>>;
<A>(config: Config<A>): Config<Redacted<A>>;
};Constructs a config for a secret value.
Signature
declare const secret: (name?: string) => Config<Secret.Secret>;Constructs a config for a string value.
Signature
declare const string: (name?: string) => Config<string>;Constructs a config which contains the specified value.
Signature
declare const succeed: <A>(value: A) => Config<A>;Lazily constructs a config.
Signature
declare const suspend: <A>(config: LazyArg<Config<A>>) => Config<A>;Constructs a config which contains the specified lazy value.
Signature
declare const sync: <A>(value: LazyArg<A>) => Config<A>;Constructs a config from some configuration wrapped with the Wrap<A> utility type.
For example:
Signature
declare const unwrap: <A>(wrapped: Config.Wrap<A>) => Config<A>;Example
import { Config, unwrap } from "./Config"
interface Options {
key: string
}
const makeConfig = (config: Config.Wrap<Options>): Config<Options> => unwrap(config)Constructs a config for an URL value.
Signature
declare const url: (name?: string) => Config<URL>;Mapping
Returns a config whose structure is the same as this one, but which produces a different value, constructed using the specified function.
Signature
declare const map: {
<A, B>(f: (a: A) => B): (self: Config<A>) => Config<B>;
<A, B>(self: Config<A>, f: (a: A) => B): Config<B>;
};Models
A Config describes the structure of some configuration data.
Signature
interface Config<out A> extends Variance<A>, Effect<A, ConfigError.ConfigError> {}LiteralValue type
Signature
type LiteralValue = string | number | boolean | null | bigint;Other
Refinements
This function returns true if the specified value is an Config value, false otherwise.
This function can be useful for checking the type of a value before attempting to operate on it as an Config value. For example, you could use isConfig to check the type of a value before using it as an argument to a function that expects an Config value.
Signature
declare const isConfig: (u: unknown) => u is Config<unknown>;Symbols
ConfigTypeId
Signature
declare const ConfigTypeId: unique symbol;ConfigTypeId type
Signature
type ConfigTypeId = typeof ConfigTypeId;Utils
mapAttempt
Returns a config whose structure is the same as this one, but which may produce a different value, constructed using the specified function, which may throw exceptions that will be translated into validation errors.
Signature
declare const mapAttempt: {
<A, B>(f: (a: A) => B): (self: Config<A>) => Config<B>;
<A, B>(self: Config<A>, f: (a: A) => B): Config<B>;
};Returns a new config whose structure is the samea as this one, but which may produce a different value, constructed using the specified fallible function.
Signature
declare const mapOrFail: {
<A, B>(f: (a: A) => Either<B, ConfigError>): (self: Config<A>) => Config<B>;
<A, B>(self: Config<A>, f: (a: A) => Either<B, ConfigError>): Config<B>;
};Returns a config that has this configuration nested as a property of the specified name.
Signature
declare const nested: {
(name: string): <A>(self: Config<A>) => Config<A>;
<A>(self: Config<A>, name: string): Config<A>;
};Returns an optional version of this config, which will be None if the data is missing from configuration, and Some otherwise.
Signature
declare const option: <A>(self: Config<A>) => Config<Option.Option<A>>;Returns a config whose structure is preferentially described by this config, but which falls back to the specified config if there is an issue reading from this config.
Signature
declare const orElse: {
<A2>(that: LazyArg<Config<A2>>): <A>(self: Config<A>) => Config<A2 | A>;
<A, A2>(self: Config<A>, that: LazyArg<Config<A2>>): Config<A | A2>;
};Returns configuration which reads from this configuration, but which falls back to the specified configuration if reading from this configuration fails with an error satisfying the specified predicate.
Signature
declare const orElseIf: {
<A2>(options: {
readonly if: Predicate<ConfigError.ConfigError>;
readonly orElse: LazyArg<Config<A2>>;
}): <A>(self: Config<A>) => Config<A2 | A>;
<A, A2>(
self: Config<A>,
options: {
readonly if: Predicate<ConfigError.ConfigError>;
readonly orElse: LazyArg<Config<A2>>;
},
): Config<A | A2>;
};Returns a config that describes a sequence of values, each of which has the structure of this config.
Signature
declare const repeat: <A>(self: Config<A>) => Config<Array<A>>;Returns a config that describes the same structure as this one, but which performs validation during loading.
Signature
declare const validate: {
<A, B>(options: {
readonly message: string;
readonly validation: Refinement<A, B>;
}): (self: Config<A>) => Config<B>;
<A>(options: {
readonly message: string;
readonly validation: Predicate<A>;
}): (self: Config<A>) => Config<A>;
<A, B>(
self: Config<A>,
options: {
readonly message: string;
readonly validation: Refinement<A, B>;
},
): Config<B>;
<A>(
self: Config<A>,
options: {
readonly message: string;
readonly validation: Predicate<A>;
},
): Config<A>;
};withDefault
Returns a config that describes the same structure as this one, but has the specified default value in case the information cannot be found.
Signature
declare const withDefault: {
<A2>(def: A2): <A>(self: Config<A>) => Config<A2 | A>;
<A, A2>(self: Config<A>, def: A2): Config<A | A2>;
};withDescription
Adds a description to this configuration, which is intended for humans.
Signature
declare const withDescription: {
(description: string): <A>(self: Config<A>) => Config<A>;
<A>(self: Config<A>, description: string): Config<A>;
};Zipping
Returns a config that is the composition of this config and the specified config.
Signature
declare const zip: {
<B>(that: Config<B>): <A>(self: Config<A>) => Config<[A, B]>;
<A, B>(self: Config<A>, that: Config<B>): Config<[A, B]>;
};Returns a config that is the composes this config and the specified config using the provided function.
Signature
declare const zipWith: {
<B, A, C>(that: Config<B>, f: (a: A, b: B) => C): (self: Config<A>) => Config<C>;
<A, B, C>(self: Config<A>, that: Config<B>, f: (a: A, b: B) => C): Config<C>;
};
Constructs a config from a tuple / struct / arguments of configs.