@magidoc/plugin-starter-variables
Version:
A shared library that contains common Magidoc starter environment variables keys.
24 lines (23 loc) • 709 B
TypeScript
import type { ZodType } from 'zod';
interface MetaEnv {
[key: string]: unknown;
}
export type Variable<T> = {
name: string;
key: string;
asEnv: (value: T) => Record<string, string>;
get: (env: MetaEnv) => T | null;
getOrDefault: (env: MetaEnv, def: T) => T;
zod: ZodVariable<T>;
};
export type ZodTypeProvider<T> = (zod: typeof import('zod')) => ZodType<T | undefined>;
export type ZodVariable<T> = {
type: ZodTypeProvider<T>;
};
export type Converter<T> = {
convert: (target: unknown) => T | null;
asString: (value: T) => string;
type: ZodTypeProvider<T>;
};
export declare function createVariable<T>(key: string, converter: Converter<T>): Variable<T>;
export {};