The union of all environment types in the registry
Adds a new environment to the registry.
This method ensures type safety by preventing duplicate environment names and maintaining the union type of all environments.
The name of the environment (must be unique)
The data structure for this environment
The union of all resolution types for this environment
The unique name for this environment
Type definition for the environment data (used for type inference)
Function that configures the environment with its resolutions
A new EnvironmentRegistry with the added environment
const envReg = createEnvironmentRegistry()
.addEnv("local", defineType<{ env: Record<string, string> }>(), (env) => env
.addResolution("hardcoded", defineType<string>(), (data) => data.payload)
.addResolution("from-env", defineType<undefined>(), (data) =>
data.envData.env[data.variableName]))
Static
createInternal
Creates a new empty EnvironmentRegistry.
A new EnvironmentRegistry with no environments
Creates a VariableRegistry that can define variables for this environment registry.
The VariableRegistry will have full type safety for all environments and resolutions defined in this registry.
A new VariableRegistry configured for this environment registry
Registry for managing multiple environments with their resolutions.
This class provides a fluent API for building environment configurations. Each environment can have multiple resolution methods (hardcoded, from-env, etc.) and the registry ensures type safety across all environments.
Example