envapt 8.0.0-next.2 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -33
- package/dist/node/converters/ValueConverter.cjs +1 -1
- package/dist/node/converters/ValueConverter.cjs.map +1 -1
- package/dist/node/converters/ValueConverter.mjs +1 -1
- package/dist/node/converters/ValueConverter.mjs.map +1 -1
- package/dist/node/core/AdvancedMethods.cjs +1 -1
- package/dist/node/core/AdvancedMethods.cjs.map +1 -1
- package/dist/node/core/AdvancedMethods.mjs +1 -1
- package/dist/node/core/AdvancedMethods.mjs.map +1 -1
- package/dist/node/core/missing.cjs +1 -1
- package/dist/node/core/missing.cjs.map +1 -1
- package/dist/node/core/missing.mjs +1 -1
- package/dist/node/core/missing.mjs.map +1 -1
- package/dist/node/decorators/legacy/Envapt.cjs.map +1 -1
- package/dist/node/decorators/legacy/Envapt.mjs.map +1 -1
- package/dist/node/decorators/legacy/SugarDecorators.cjs.map +1 -1
- package/dist/node/decorators/legacy/SugarDecorators.mjs.map +1 -1
- package/dist/node/decorators/modern/Envapt.cjs.map +1 -1
- package/dist/node/decorators/modern/Envapt.mjs.map +1 -1
- package/dist/node/decorators/modern/SugarDecorators.cjs.map +1 -1
- package/dist/node/decorators/modern/SugarDecorators.mjs.map +1 -1
- package/dist/node/decorators/parseEnvaptOptions.cjs +1 -1
- package/dist/node/decorators/parseEnvaptOptions.cjs.map +1 -1
- package/dist/node/decorators/parseEnvaptOptions.mjs +1 -1
- package/dist/node/decorators/parseEnvaptOptions.mjs.map +1 -1
- package/dist/node/decorators/resolveDecoratorValue.cjs.map +1 -1
- package/dist/node/decorators/resolveDecoratorValue.mjs.map +1 -1
- package/dist/portable/converters/ValueConverter.mjs +1 -1
- package/dist/portable/converters/ValueConverter.mjs.map +1 -1
- package/dist/portable/core/AdvancedMethods.mjs +1 -1
- package/dist/portable/core/AdvancedMethods.mjs.map +1 -1
- package/dist/portable/core/missing.mjs +1 -1
- package/dist/portable/core/missing.mjs.map +1 -1
- package/dist/portable/decorators/legacy/Envapt.mjs.map +1 -1
- package/dist/portable/decorators/legacy/SugarDecorators.mjs.map +1 -1
- package/dist/portable/decorators/modern/Envapt.mjs.map +1 -1
- package/dist/portable/decorators/modern/SugarDecorators.mjs.map +1 -1
- package/dist/portable/decorators/parseEnvaptOptions.mjs +1 -1
- package/dist/portable/decorators/parseEnvaptOptions.mjs.map +1 -1
- package/dist/portable/decorators/resolveDecoratorValue.mjs.map +1 -1
- package/dist/types/decorators/legacy/Envapt.d.mts +4 -26
- package/dist/types/decorators/legacy/SugarDecorators.d.mts +5 -5
- package/dist/types/decorators/modern/Envapt.d.mts +4 -26
- package/dist/types/decorators/modern/SugarDecorators.d.mts +5 -5
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Envapt.mjs","names":[],"sources":["../../../../src/decorators/legacy/Envapt.ts"],"sourcesContent":["import { createPropertyDecorator } from './createPropertyDecorator';\nimport { parseEnvaptOptions } from '../parseEnvaptOptions';\n\nimport type { ArrayOf } from '../../converters';\nimport type { InferSchemaOutput, StandardSchemaV1 } from '../../infra/StandardSchema';\nimport type {\n BuiltInConverter,\n ConverterFunction,\n EnvaptFieldDecorator,\n EnvKeyInput,\n InferConverterFallbackType,\n InferConverterReturnType,\n InferPrimitiveReturnType,\n PrimitiveConstructor,\n SchemaConstraint\n} from '../../types';\n\n/**\n * A custom converter function with a fallback (both required), or a fallback only.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('API_KEY', {\n * fallback: 'default-key',\n * converter(raw, _fallback) {\n * if (!raw || raw.trim() === '') throw new Error('API_KEY required');\n * return raw.trim();\n * }\n * })\n * static readonly apiKey: string;\n *\n * \\@Envapt('LOG_FILE', { fallback: '/var/log/app.log' })\n * static readonly logFile: string;\n *\n * \\@Envapt('RETRY_POLICY', { fallback: { retries: 3, backoff: 'exponential' } })\n * static readonly retryPolicy: unknown;\n * }\n * ```\n */\nexport function Envapt(\n key: EnvKeyInput,\n options
|
|
1
|
+
{"version":3,"file":"Envapt.mjs","names":[],"sources":["../../../../src/decorators/legacy/Envapt.ts"],"sourcesContent":["import { createPropertyDecorator } from './createPropertyDecorator';\nimport { parseEnvaptOptions } from '../parseEnvaptOptions';\n\nimport type { ArrayOf } from '../../converters';\nimport type { InferSchemaOutput, StandardSchemaV1 } from '../../infra/StandardSchema';\nimport type {\n BuiltInConverter,\n ConverterFunction,\n EnvaptFieldDecorator,\n EnvKeyInput,\n InferConverterFallbackType,\n InferConverterReturnType,\n InferPrimitiveReturnType,\n PrimitiveConstructor,\n SchemaConstraint\n} from '../../types';\n\n/**\n * A custom converter function with a fallback (both required), or a fallback only.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('API_KEY', {\n * fallback: 'default-key',\n * converter(raw, _fallback) {\n * if (!raw || raw.trim() === '') throw new Error('API_KEY required');\n * return raw.trim();\n * }\n * })\n * static readonly apiKey: string;\n *\n * \\@Envapt('LOG_FILE', { fallback: '/var/log/app.log' })\n * static readonly logFile: string;\n *\n * \\@Envapt('RETRY_POLICY', { fallback: { retries: 3, backoff: 'exponential' } })\n * static readonly retryPolicy: unknown;\n * }\n * ```\n */\nexport function Envapt(\n key: EnvKeyInput,\n options?: { fallback: undefined; converter?: undefined }\n): EnvaptFieldDecorator<string | undefined>;\nexport function Envapt<TFallback>(\n key: EnvKeyInput,\n options:\n | { converter: (raw: string | undefined, fallback: TFallback) => TFallback; fallback: TFallback }\n | { fallback: TFallback; converter?: undefined }\n): EnvaptFieldDecorator<TFallback>;\n\n/**\n * A custom converter function without a fallback. Omit `required` to return the converter's\n * output (possibly `undefined`), or pass `required: true` to throw `MissingEnvValue` on\n * missing or empty values.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('FEATURE_FLAGS', { converter(raw) {\n * return raw ? raw.split('|').map(s => s.trim()) : [];\n * } })\n * static readonly featureFlags: string[];\n *\n * \\@Envapt('JWT_SECRET', {\n * converter: (raw) => Buffer.from(raw ?? '', 'base64'),\n * required: true\n * })\n * static readonly jwtSecret: Buffer;\n * }\n * ```\n */\nexport function Envapt<TReturnType>(\n key: EnvKeyInput,\n options:\n | { converter: ConverterFunction<TReturnType>; required?: false }\n | { converter: ConverterFunction<TReturnType>; required: true }\n): EnvaptFieldDecorator<TReturnType>;\n\n/**\n * A built-in or array converter with a fallback, or `required: true`. The fallback type tracks\n * the converter, so `Converters.Time` takes a number or time-string and `Converters.Url` takes\n * a `URL` instance.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * import { Converters } from 'envapt';\n *\n * class Config extends Envapter {\n * \\@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })\n * static readonly port: number;\n *\n * // the Url fallback is a URL instance, not a string\n * \\@Envapt('APP_URL', { converter: Converters.Url, fallback: new URL('http://localhost:3000') })\n * static readonly url: URL;\n *\n * // prefers CANARY_URL when present, otherwise APP_URL\n * \\@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })\n * static readonly canaryUrl: URL | undefined;\n *\n * // Time takes a number (milliseconds) or a time-string fallback (`<number><unit>`)\n * \\@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })\n * static readonly requestTimeout: number;\n *\n * \\@Envapt('ALLOWED_ORIGINS', {\n * converter: Converters.array({ of: Converters.String }),\n * fallback: ['https://example.com']\n * })\n * static readonly allowedOrigins: string[];\n *\n * \\@Envapt('DATABASE_URL', { converter: Converters.Url, required: true })\n * static readonly databaseUrl: URL;\n * }\n * ```\n */\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options:\n | { converter: TConverter; fallback: InferConverterFallbackType<TConverter>; required?: false }\n | { converter: TConverter; required: true }\n): EnvaptFieldDecorator<InferConverterReturnType<TConverter>>;\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options: { converter: TConverter; fallback?: undefined; required?: false }\n): EnvaptFieldDecorator<InferConverterReturnType<TConverter> | undefined>;\n\n/**\n * A primitive constructor (`Number`, `Boolean`) with an optional fallback.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('MAX_CONNECTIONS', { converter: Number, fallback: 100 })\n * static readonly maxConnections: number;\n *\n * \\@Envapt('FEATURE_ENABLED', { converter: Boolean, fallback: false })\n * static readonly featureEnabled: boolean;\n * }\n * ```\n */\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options:\n | { converter: TConstructor; fallback: InferPrimitiveReturnType<TConstructor>; required?: false }\n | { converter: TConstructor; required: true }\n): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor>>;\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options: { converter: TConstructor; fallback?: undefined; required?: false }\n): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor> | undefined>;\n\n/**\n * Required, no converter (raw string). Throws `MissingEnvValue` on first access when the env\n * value is missing or empty after trimming, independent of the global `Envapter.strict` flag.\n * Pairing `required: true` with `fallback` matches no overload at compile time, and the runtime\n * Validator rejects dynamic objects that bypass the types.\n *\n * @param key - Environment variable name(s) to load\n * @param options - `{ required: true }`\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('API_KEY', { required: true })\n * static readonly apiKey: string;\n * }\n * ```\n */\nexport function Envapt(key: EnvKeyInput, options: { required: true }): EnvaptFieldDecorator<string>;\n\n/**\n * A Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous schemas only,\n * so a Promise-returning `validate` throws `InvalidUserDefinedConfig` at runtime. Pairing\n * `schema` with `converter` matches no overload at compile time, and the runtime Validator\n * rejects dynamic objects that bypass the types.\n * @public\n */\nexport function Envapt<Schema extends StandardSchemaV1>(\n key: EnvKeyInput,\n options:\n | { schema: SchemaConstraint<Schema>; fallback?: InferSchemaOutput<Schema>; required?: false }\n | { schema: SchemaConstraint<Schema>; required: true }\n): EnvaptFieldDecorator<InferSchemaOutput<Schema>>;\n\n/**\n * Instance or static property decorator that loads and converts an environment variable.\n * @see {@link https://envapt.materwelon.dev/docs/decorators#declaring-decorated-fields}\n */\nexport function Envapt<TFallback = unknown>(key: EnvKeyInput, options?: unknown): EnvaptFieldDecorator<unknown> {\n return createPropertyDecorator(key, parseEnvaptOptions<TFallback>(options)) as EnvaptFieldDecorator<unknown>;\n}\n"],"mappings":"uIAwMA,SAAgB,EAA4B,EAAkB,EAAkD,CAC5G,OAAO,EAAwB,EAAK,EAA8B,CAAO,CAAC,CAC9E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SugarDecorators.mjs","names":[],"sources":["../../../../src/decorators/legacy/SugarDecorators.ts"],"sourcesContent":["import { createPropertyDecorator } from './createPropertyDecorator';\nimport { Converters } from '../../converters';\n\nimport type { ConverterToken } from '../../converters';\nimport type { EnvaptFieldDecorator, EnvKeyInput, TimeFallback } from '../../types';\n\nfunction sugar<TFallback>(\n converter: ConverterToken,\n key: EnvKeyInput,\n fallback: TFallback | undefined\n): EnvaptFieldDecorator<TFallback> {\n // the runtime installer is a plain (target, key) decorator, so the cast only adds a\n // compile-time field-type constraint with no runtime counterpart\n return createPropertyDecorator<TFallback>(key, {\n converter,\n fallback,\n hasFallback: fallback !== undefined,\n required: false,\n schema: undefined\n }) as EnvaptFieldDecorator<TFallback>;\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Boolean, fallback })`.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvBool(key: EnvKeyInput, fallback: boolean): EnvaptFieldDecorator<boolean>;\nexport function EnvBool(key: EnvKeyInput): EnvaptFieldDecorator<boolean |
|
|
1
|
+
{"version":3,"file":"SugarDecorators.mjs","names":[],"sources":["../../../../src/decorators/legacy/SugarDecorators.ts"],"sourcesContent":["import { createPropertyDecorator } from './createPropertyDecorator';\nimport { Converters } from '../../converters';\n\nimport type { ConverterToken } from '../../converters';\nimport type { EnvaptFieldDecorator, EnvKeyInput, TimeFallback } from '../../types';\n\nfunction sugar<TFallback>(\n converter: ConverterToken,\n key: EnvKeyInput,\n fallback: TFallback | undefined\n): EnvaptFieldDecorator<TFallback> {\n // the runtime installer is a plain (target, key) decorator, so the cast only adds a\n // compile-time field-type constraint with no runtime counterpart\n return createPropertyDecorator<TFallback>(key, {\n converter,\n fallback,\n hasFallback: fallback !== undefined,\n required: false,\n schema: undefined\n }) as EnvaptFieldDecorator<TFallback>;\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Boolean, fallback })`.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvBool(key: EnvKeyInput, fallback: boolean): EnvaptFieldDecorator<boolean>;\nexport function EnvBool(key: EnvKeyInput): EnvaptFieldDecorator<boolean | undefined>;\nexport function EnvBool(key: EnvKeyInput, fallback?: boolean): EnvaptFieldDecorator<boolean | undefined> {\n return sugar(Converters.Boolean, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Number, fallback })`.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvNum(key: EnvKeyInput, fallback: number): EnvaptFieldDecorator<number>;\nexport function EnvNum(key: EnvKeyInput): EnvaptFieldDecorator<number | undefined>;\nexport function EnvNum(key: EnvKeyInput, fallback?: number): EnvaptFieldDecorator<number | undefined> {\n return sugar(Converters.Number, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.String, fallback })`.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvStr(key: EnvKeyInput, fallback: string): EnvaptFieldDecorator<string>;\nexport function EnvStr(key: EnvKeyInput): EnvaptFieldDecorator<string | undefined>;\nexport function EnvStr(key: EnvKeyInput, fallback?: string): EnvaptFieldDecorator<string | undefined> {\n return sugar(Converters.String, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Time, fallback })`. The fallback is a\n * millisecond number or a time string (`'15m'`), and the resolved value is always milliseconds.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvTime(key: EnvKeyInput, fallback: TimeFallback): EnvaptFieldDecorator<number>;\nexport function EnvTime(key: EnvKeyInput): EnvaptFieldDecorator<number | undefined>;\nexport function EnvTime(key: EnvKeyInput, fallback?: TimeFallback): EnvaptFieldDecorator<number | undefined> {\n return sugar(Converters.Time, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Url, fallback })`. The fallback is a `URL`\n * instance, not a URL string.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvUrl(key: EnvKeyInput, fallback: URL): EnvaptFieldDecorator<URL>;\nexport function EnvUrl(key: EnvKeyInput): EnvaptFieldDecorator<URL | undefined>;\nexport function EnvUrl(key: EnvKeyInput, fallback?: URL): EnvaptFieldDecorator<URL | undefined> {\n return sugar(Converters.Url, key, fallback);\n}\n"],"mappings":"qIAMA,SAAS,EACL,EACA,EACA,EAC+B,CAG/B,OAAO,EAAmC,EAAK,CAC3C,YACA,WACA,YAAa,IAAa,IAAA,GAC1B,SAAU,GACV,OAAQ,IAAA,EACZ,CAAC,CACL,CASA,SAAgB,EAAQ,EAAkB,EAA+D,CACrG,OAAO,EAAM,EAAW,QAAS,EAAK,CAAQ,CAClD,CASA,SAAgB,EAAO,EAAkB,EAA6D,CAClG,OAAO,EAAM,EAAW,OAAQ,EAAK,CAAQ,CACjD,CASA,SAAgB,EAAO,EAAkB,EAA6D,CAClG,OAAO,EAAM,EAAW,OAAQ,EAAK,CAAQ,CACjD,CAUA,SAAgB,EAAQ,EAAkB,EAAmE,CACzG,OAAO,EAAM,EAAW,KAAM,EAAK,CAAQ,CAC/C,CAUA,SAAgB,EAAO,EAAkB,EAAuD,CAC5F,OAAO,EAAM,EAAW,IAAK,EAAK,CAAQ,CAC9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Envapt.mjs","names":[],"sources":["../../../../src/decorators/modern/Envapt.ts"],"sourcesContent":["import { createAccessorDecorator } from './createAccessorDecorator';\nimport { parseEnvaptOptions } from '../parseEnvaptOptions';\n\nimport type { ArrayOf } from '../../converters';\nimport type { InferSchemaOutput, StandardSchemaV1 } from '../../infra/StandardSchema';\nimport type {\n BuiltInConverter,\n ConverterFunction,\n EnvaptAccessorDecorator,\n EnvKeyInput,\n InferConverterFallbackType,\n InferConverterReturnType,\n InferPrimitiveReturnType,\n PrimitiveConstructor,\n SchemaConstraint\n} from '../../types';\n\n/**\n * A custom converter function with a fallback (both required), or a fallback only.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config {\n * \\@Envapt('API_KEY', {\n * fallback: 'default-key',\n * converter(raw, _fallback) {\n * if (!raw || raw.trim() === '') throw new Error('API_KEY required');\n * return raw.trim();\n * }\n * })\n * static accessor apiKey: string;\n *\n * \\@Envapt('LOG_FILE', { fallback: '/var/log/app.log' })\n * static accessor logFile: string;\n *\n * \\@Envapt('RETRY_POLICY', { fallback: { retries: 3, backoff: 'exponential' } })\n * static accessor retryPolicy: unknown;\n * }\n * ```\n */\nexport function Envapt(\n key: EnvKeyInput,\n options
|
|
1
|
+
{"version":3,"file":"Envapt.mjs","names":[],"sources":["../../../../src/decorators/modern/Envapt.ts"],"sourcesContent":["import { createAccessorDecorator } from './createAccessorDecorator';\nimport { parseEnvaptOptions } from '../parseEnvaptOptions';\n\nimport type { ArrayOf } from '../../converters';\nimport type { InferSchemaOutput, StandardSchemaV1 } from '../../infra/StandardSchema';\nimport type {\n BuiltInConverter,\n ConverterFunction,\n EnvaptAccessorDecorator,\n EnvKeyInput,\n InferConverterFallbackType,\n InferConverterReturnType,\n InferPrimitiveReturnType,\n PrimitiveConstructor,\n SchemaConstraint\n} from '../../types';\n\n/**\n * A custom converter function with a fallback (both required), or a fallback only.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config {\n * \\@Envapt('API_KEY', {\n * fallback: 'default-key',\n * converter(raw, _fallback) {\n * if (!raw || raw.trim() === '') throw new Error('API_KEY required');\n * return raw.trim();\n * }\n * })\n * static accessor apiKey: string;\n *\n * \\@Envapt('LOG_FILE', { fallback: '/var/log/app.log' })\n * static accessor logFile: string;\n *\n * \\@Envapt('RETRY_POLICY', { fallback: { retries: 3, backoff: 'exponential' } })\n * static accessor retryPolicy: unknown;\n * }\n * ```\n */\nexport function Envapt(\n key: EnvKeyInput,\n options?: { fallback: undefined; converter?: undefined }\n): EnvaptAccessorDecorator<string | undefined>;\nexport function Envapt<TFallback>(\n key: EnvKeyInput,\n options:\n | { converter: (raw: string | undefined, fallback: TFallback) => TFallback; fallback: TFallback }\n | { fallback: TFallback; converter?: undefined }\n): EnvaptAccessorDecorator<TFallback>;\n\n/**\n * A custom converter function without a fallback. Omit `required` to return the converter's\n * output (possibly `undefined`), or pass `required: true` to throw `MissingEnvValue` on\n * missing or empty values.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config {\n * \\@Envapt('FEATURE_FLAGS', { converter(raw) {\n * return raw ? raw.split('|').map(s => s.trim()) : [];\n * } })\n * static accessor featureFlags: string[];\n *\n * \\@Envapt('JWT_SECRET', {\n * converter: (raw) => Buffer.from(raw ?? '', 'base64'),\n * required: true\n * })\n * static accessor jwtSecret: Buffer;\n * }\n * ```\n */\nexport function Envapt<TReturnType>(\n key: EnvKeyInput,\n options:\n | { converter: ConverterFunction<TReturnType>; required?: false }\n | { converter: ConverterFunction<TReturnType>; required: true }\n): EnvaptAccessorDecorator<TReturnType>;\n\n/**\n * A built-in or array converter with a fallback, or `required: true`. The fallback type tracks\n * the converter, so `Converters.Time` takes a number or time-string and `Converters.Url` takes\n * a `URL` instance.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * import { Converters } from 'envapt';\n *\n * class Config {\n * \\@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })\n * static accessor port: number;\n *\n * // the Url fallback is a URL instance, not a string\n * \\@Envapt('APP_URL', { converter: Converters.Url, fallback: new URL('http://localhost:3000') })\n * static accessor url: URL;\n *\n * // prefers CANARY_URL when present, otherwise APP_URL\n * \\@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })\n * static accessor canaryUrl: URL | undefined;\n *\n * // Time takes a number (milliseconds) or a time-string fallback (`<number><unit>`)\n * \\@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })\n * static accessor requestTimeout: number;\n *\n * \\@Envapt('ALLOWED_ORIGINS', {\n * converter: Converters.array({ of: Converters.String }),\n * fallback: ['https://example.com']\n * })\n * static accessor allowedOrigins: string[];\n *\n * \\@Envapt('DATABASE_URL', { converter: Converters.Url, required: true })\n * static accessor databaseUrl: URL;\n * }\n * ```\n */\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options:\n | { converter: TConverter; fallback: InferConverterFallbackType<TConverter>; required?: false }\n | { converter: TConverter; required: true }\n): EnvaptAccessorDecorator<InferConverterReturnType<TConverter>>;\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options: { converter: TConverter; fallback?: undefined; required?: false }\n): EnvaptAccessorDecorator<InferConverterReturnType<TConverter> | undefined>;\n\n/**\n * A primitive constructor (`Number`, `Boolean`) with an optional fallback.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config {\n * \\@Envapt('MAX_CONNECTIONS', { converter: Number, fallback: 100 })\n * static accessor maxConnections: number;\n *\n * \\@Envapt('FEATURE_ENABLED', { converter: Boolean, fallback: false })\n * static accessor featureEnabled: boolean;\n * }\n * ```\n */\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options:\n | { converter: TConstructor; fallback: InferPrimitiveReturnType<TConstructor>; required?: false }\n | { converter: TConstructor; required: true }\n): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor>>;\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options: { converter: TConstructor; fallback?: undefined; required?: false }\n): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor> | undefined>;\n\n/**\n * Required, no converter (raw string). Throws `MissingEnvValue` on first access when the env\n * value is missing or empty after trimming, independent of the global `Envapter.strict` flag.\n * Pairing `required: true` with `fallback` matches no overload at compile time, and the runtime\n * Validator rejects dynamic objects that bypass the types.\n *\n * @param key - Environment variable name(s) to load\n * @param options - `{ required: true }`\n * @public\n * @example\n * ```ts\n * class Config {\n * \\@Envapt('API_KEY', { required: true })\n * static accessor apiKey: string;\n * }\n * ```\n */\nexport function Envapt(key: EnvKeyInput, options: { required: true }): EnvaptAccessorDecorator<string>;\n\n/**\n * A Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous schemas only,\n * so a Promise-returning `validate` throws `InvalidUserDefinedConfig` at runtime. Pairing\n * `schema` with `converter` matches no overload at compile time, and the runtime Validator\n * rejects dynamic objects that bypass the types.\n * @public\n */\nexport function Envapt<Schema extends StandardSchemaV1>(\n key: EnvKeyInput,\n options:\n | { schema: SchemaConstraint<Schema>; fallback?: InferSchemaOutput<Schema>; required?: false }\n | { schema: SchemaConstraint<Schema>; required: true }\n): EnvaptAccessorDecorator<InferSchemaOutput<Schema>>;\n\n/**\n * Modern (TC39 Stage 3) accessor decorator that loads and converts an environment variable. The\n * decorated property uses the `accessor` keyword and needs no `experimentalDecorators` flag.\n * Instance accessors need the definite-assignment `!`, static accessors do not.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Converter, fallback, `required`, or `schema`. See the overloads.\n * @public\n * @example\n * ```ts\n * import { Envapt, Converters } from 'envapt';\n *\n * class Config {\n * \\@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })\n * static accessor port: number;\n *\n * \\@Envapt('DATABASE_URL', { converter: Converters.Url, required: true })\n * accessor databaseUrl!: URL;\n * }\n * ```\n * @see {@link https://envapt.materwelon.dev/docs/decorators#declaring-decorated-fields}\n */\n/* v8 ignore start -- @preserve oxc (vitest's transform) breaks modern accessor decorators (context.name unset), so the tsc stage3-emit harness covers these, not vitest */\nexport function Envapt<TFallback = unknown>(key: EnvKeyInput, options?: unknown): EnvaptAccessorDecorator<unknown> {\n return createAccessorDecorator(key, parseEnvaptOptions<TFallback>(options)) as EnvaptAccessorDecorator<unknown>;\n}\n/* v8 ignore stop */\n"],"mappings":"uIA2NA,SAAgB,EAA4B,EAAkB,EAAqD,CAC/G,OAAO,EAAwB,EAAK,EAA8B,CAAO,CAAC,CAC9E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SugarDecorators.mjs","names":[],"sources":["../../../../src/decorators/modern/SugarDecorators.ts"],"sourcesContent":["import { createAccessorDecorator } from './createAccessorDecorator';\nimport { Converters } from '../../converters';\n\nimport type { ConverterToken } from '../../converters';\nimport type { EnvaptAccessorDecorator, EnvKeyInput, TimeFallback } from '../../types';\n\n/* v8 ignore start -- @preserve oxc (vitest's transform) breaks modern accessor decorators (context.name unset), so the tsc stage3-emit harness covers these, not vitest */\nfunction sugar<TFallback>(\n converter: ConverterToken,\n key: EnvKeyInput,\n fallback: TFallback | undefined\n): EnvaptAccessorDecorator<TFallback> {\n // the runtime installer is a plain accessor decorator, so the cast only adds a\n // compile-time field-type constraint with no runtime counterpart\n return createAccessorDecorator<TFallback>(key, {\n converter,\n fallback,\n hasFallback: fallback !== undefined,\n required: false,\n schema: undefined\n }) as EnvaptAccessorDecorator<TFallback>;\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Boolean, fallback })`.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvBool(key: EnvKeyInput, fallback: boolean): EnvaptAccessorDecorator<boolean>;\nexport function EnvBool(key: EnvKeyInput): EnvaptAccessorDecorator<boolean |
|
|
1
|
+
{"version":3,"file":"SugarDecorators.mjs","names":[],"sources":["../../../../src/decorators/modern/SugarDecorators.ts"],"sourcesContent":["import { createAccessorDecorator } from './createAccessorDecorator';\nimport { Converters } from '../../converters';\n\nimport type { ConverterToken } from '../../converters';\nimport type { EnvaptAccessorDecorator, EnvKeyInput, TimeFallback } from '../../types';\n\n/* v8 ignore start -- @preserve oxc (vitest's transform) breaks modern accessor decorators (context.name unset), so the tsc stage3-emit harness covers these, not vitest */\nfunction sugar<TFallback>(\n converter: ConverterToken,\n key: EnvKeyInput,\n fallback: TFallback | undefined\n): EnvaptAccessorDecorator<TFallback> {\n // the runtime installer is a plain accessor decorator, so the cast only adds a\n // compile-time field-type constraint with no runtime counterpart\n return createAccessorDecorator<TFallback>(key, {\n converter,\n fallback,\n hasFallback: fallback !== undefined,\n required: false,\n schema: undefined\n }) as EnvaptAccessorDecorator<TFallback>;\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Boolean, fallback })`.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvBool(key: EnvKeyInput, fallback: boolean): EnvaptAccessorDecorator<boolean>;\nexport function EnvBool(key: EnvKeyInput): EnvaptAccessorDecorator<boolean | undefined>;\nexport function EnvBool(key: EnvKeyInput, fallback?: boolean): EnvaptAccessorDecorator<boolean | undefined> {\n return sugar(Converters.Boolean, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Number, fallback })`.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvNum(key: EnvKeyInput, fallback: number): EnvaptAccessorDecorator<number>;\nexport function EnvNum(key: EnvKeyInput): EnvaptAccessorDecorator<number | undefined>;\nexport function EnvNum(key: EnvKeyInput, fallback?: number): EnvaptAccessorDecorator<number | undefined> {\n return sugar(Converters.Number, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.String, fallback })`.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvStr(key: EnvKeyInput, fallback: string): EnvaptAccessorDecorator<string>;\nexport function EnvStr(key: EnvKeyInput): EnvaptAccessorDecorator<string | undefined>;\nexport function EnvStr(key: EnvKeyInput, fallback?: string): EnvaptAccessorDecorator<string | undefined> {\n return sugar(Converters.String, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Time, fallback })`. The fallback is a\n * millisecond number or a time string (`'15m'`), and the resolved value is always milliseconds.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvTime(key: EnvKeyInput, fallback: TimeFallback): EnvaptAccessorDecorator<number>;\nexport function EnvTime(key: EnvKeyInput): EnvaptAccessorDecorator<number | undefined>;\nexport function EnvTime(key: EnvKeyInput, fallback?: TimeFallback): EnvaptAccessorDecorator<number | undefined> {\n return sugar(Converters.Time, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Url, fallback })`. The fallback is a `URL`\n * instance, not a URL string.\n * @public\n * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}\n */\nexport function EnvUrl(key: EnvKeyInput, fallback: URL): EnvaptAccessorDecorator<URL>;\nexport function EnvUrl(key: EnvKeyInput): EnvaptAccessorDecorator<URL | undefined>;\nexport function EnvUrl(key: EnvKeyInput, fallback?: URL): EnvaptAccessorDecorator<URL | undefined> {\n return sugar(Converters.Url, key, fallback);\n}\n/* v8 ignore stop */\n"],"mappings":"qIAOA,SAAS,EACL,EACA,EACA,EACkC,CAGlC,OAAO,EAAmC,EAAK,CAC3C,YACA,WACA,YAAa,IAAa,IAAA,GAC1B,SAAU,GACV,OAAQ,IAAA,EACZ,CAAC,CACL,CASA,SAAgB,EAAQ,EAAkB,EAAkE,CACxG,OAAO,EAAM,EAAW,QAAS,EAAK,CAAQ,CAClD,CASA,SAAgB,EAAO,EAAkB,EAAgE,CACrG,OAAO,EAAM,EAAW,OAAQ,EAAK,CAAQ,CACjD,CASA,SAAgB,EAAO,EAAkB,EAAgE,CACrG,OAAO,EAAM,EAAW,OAAQ,EAAK,CAAQ,CACjD,CAUA,SAAgB,EAAQ,EAAkB,EAAsE,CAC5G,OAAO,EAAM,EAAW,KAAM,EAAK,CAAQ,CAC/C,CAUA,SAAgB,EAAO,EAAkB,EAA0D,CAC/F,OAAO,EAAM,EAAW,IAAK,EAAK,CAAQ,CAC9C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{EnvaptError as e}from"../infra/Error.mjs";import{
|
|
1
|
+
import{EnvaptError as e}from"../infra/Error.mjs";import{hasFallback as t}from"../core/missing.mjs";import{Validator as n}from"../engine/Validators.mjs";function r(r){let i,a,o,s=!1;if(r!==void 0){if(typeof r!=`object`||!r||!(`fallback`in r||`converter`in r||`required`in r||`schema`in r))throw new e(302,"The positional `@Envapt(key, fallback, converter)` form was removed in v6. Pass an options object instead, like `@Envapt(key, { converter, fallback })`, or use one of the sugar decorators.");let c=r;if(i=c.fallback,a=c.converter,s=c.required===!0,s&&t(i))throw new e(302,"`required: true` and `fallback` are mutually exclusive on @Envapt options. Drop the fallback or call `Envapter.require()` separately.");if(`schema`in c&&c.schema!==void 0){if(!n.isStandardSchema(c.schema))throw new e(302,"`schema` must be a Standard Schema v1 object (zod, valibot, arktype, or any `~standard`-conformant value).");if(a!==void 0)throw new e(302,"`schema` and `converter` are mutually exclusive on @Envapt options. Drop one as they both turn a raw env string into a typed value.");o=c.schema}}return{fallback:i,converter:a,hasFallback:t(i),required:s,schema:o}}export{r as parseEnvaptOptions};
|
|
2
2
|
//# sourceMappingURL=parseEnvaptOptions.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseEnvaptOptions.mjs","names":[],"sources":["../../../src/decorators/parseEnvaptOptions.ts"],"sourcesContent":["import { Validator } from '../engine/Validators';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { DecoratorConfig } from './resolveDecoratorValue';\nimport type { StandardSchemaV1 } from '../infra/StandardSchema';\nimport type { EnvaptConverter } from '../types';\n\nexport function parseEnvaptOptions<TFallback>(options: unknown): DecoratorConfig<TFallback> {\n let fallback: TFallback | undefined;\n let converter: EnvaptConverter<TFallback> | undefined;\n let schema: StandardSchemaV1 | undefined;\n let
|
|
1
|
+
{"version":3,"file":"parseEnvaptOptions.mjs","names":[],"sources":["../../../src/decorators/parseEnvaptOptions.ts"],"sourcesContent":["import { hasFallback } from '../core/missing';\nimport { Validator } from '../engine/Validators';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { DecoratorConfig } from './resolveDecoratorValue';\nimport type { StandardSchemaV1 } from '../infra/StandardSchema';\nimport type { EnvaptConverter } from '../types';\n\nexport function parseEnvaptOptions<TFallback>(options: unknown): DecoratorConfig<TFallback> {\n let fallback: TFallback | undefined;\n let converter: EnvaptConverter<TFallback> | undefined;\n let schema: StandardSchemaV1 | undefined;\n let required = false;\n\n if (options !== undefined) {\n if (\n typeof options !== 'object' ||\n options === null ||\n !('fallback' in options || 'converter' in options || 'required' in options || 'schema' in options)\n ) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n 'The positional `@Envapt(key, fallback, converter)` form was removed in v6. Pass an options object instead, like `@Envapt(key, { converter, fallback })`, or use one of the sugar decorators.'\n );\n }\n\n const opts = options as {\n fallback?: TFallback;\n converter?: EnvaptConverter<TFallback>;\n required?: boolean;\n schema?: unknown;\n };\n fallback = opts.fallback;\n converter = opts.converter;\n required = opts.required === true;\n\n if (required && hasFallback(fallback)) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n '`required: true` and `fallback` are mutually exclusive on @Envapt options. Drop the fallback or call `Envapter.require()` separately.'\n );\n }\n\n if ('schema' in opts && opts.schema !== undefined) {\n if (!Validator.isStandardSchema(opts.schema)) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n '`schema` must be a Standard Schema v1 object (zod, valibot, arktype, or any `~standard`-conformant value).'\n );\n }\n if (converter !== undefined) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n '`schema` and `converter` are mutually exclusive on @Envapt options. Drop one as they both turn a raw env string into a typed value.'\n );\n }\n schema = opts.schema;\n }\n }\n\n return { fallback, converter, hasFallback: hasFallback(fallback), required, schema };\n}\n"],"mappings":"wJAQA,SAAgB,EAA8B,EAA8C,CACxF,IAAI,EACA,EACA,EACA,EAAW,GAEf,GAAI,IAAY,IAAA,GAAW,CACvB,GACI,OAAO,GAAY,WACnB,GACA,EAAE,aAAc,GAAW,cAAe,GAAW,aAAc,GAAW,WAAY,GAE1F,MAAM,IAAI,EAAA,IAEN,8LACJ,EAGJ,IAAM,EAAO,EAUb,GAJA,EAAW,EAAK,SAChB,EAAY,EAAK,UACjB,EAAW,EAAK,WAAa,GAEzB,GAAY,EAAY,CAAQ,EAChC,MAAM,IAAI,EAAA,IAEN,uIACJ,EAGJ,GAAI,WAAY,GAAQ,EAAK,SAAW,IAAA,GAAW,CAC/C,GAAI,CAAC,EAAU,iBAAiB,EAAK,MAAM,EACvC,MAAM,IAAI,EAAA,IAEN,4GACJ,EAEJ,GAAI,IAAc,IAAA,GACd,MAAM,IAAI,EAAA,IAEN,qIACJ,EAEJ,EAAS,EAAK,MAClB,CACJ,CAEA,MAAO,CAAE,WAAU,YAAW,YAAa,EAAY,CAAQ,EAAG,WAAU,QAAO,CACvF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveDecoratorValue.mjs","names":[],"sources":["../../../src/decorators/resolveDecoratorValue.ts"],"sourcesContent":["import { ValueConverter } from '../converters';\nimport { isMissing } from '../core/missing';\nimport { cache } from '../core/state';\nimport { Envapter } from '../engine/Envapter';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { StandardSchemaV1 } from '../infra/StandardSchema';\nimport type { EnvaptConverter, EnvKeyInput } from '../types';\n\nexport interface DecoratorConfig<TFallback> {\n fallback: TFallback | undefined;\n converter: EnvaptConverter<TFallback> | undefined;\n hasFallback: boolean;\n required: boolean;\n schema: StandardSchemaV1 | undefined;\n}\n\nfunction formatKeyForError(key: EnvKeyInput): string {\n return Array.isArray(key) ? `[${key.join(', ')}]` : String(key);\n}\n\nconst classIds = new WeakMap<object, number>();\nlet nextClassId = 0;\n\n// keyed on the constructor object
|
|
1
|
+
{"version":3,"file":"resolveDecoratorValue.mjs","names":[],"sources":["../../../src/decorators/resolveDecoratorValue.ts"],"sourcesContent":["import { ValueConverter } from '../converters';\nimport { isMissing } from '../core/missing';\nimport { cache } from '../core/state';\nimport { Envapter } from '../engine/Envapter';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { StandardSchemaV1 } from '../infra/StandardSchema';\nimport type { EnvaptConverter, EnvKeyInput } from '../types';\n\nexport interface DecoratorConfig<TFallback> {\n fallback: TFallback | undefined;\n converter: EnvaptConverter<TFallback> | undefined;\n hasFallback: boolean;\n required: boolean;\n schema: StandardSchemaV1 | undefined;\n}\n\nfunction formatKeyForError(key: EnvKeyInput): string {\n return Array.isArray(key) ? `[${key.join(', ')}]` : String(key);\n}\n\nconst classIds = new WeakMap<object, number>();\nlet nextClassId = 0;\n\n// keyed on the constructor object's identity so two same-named classes (and a same-named\n// static/instance pair) stay in separate cache slots\nexport function decoratorCacheKey(owner: object, isStatic: boolean, prop: string): string {\n let id = classIds.get(owner);\n if (id === undefined) {\n id = nextClassId++;\n classIds.set(owner, id);\n }\n return `${id}.${isStatic ? 'static' : 'instance'}.${prop}`;\n}\n\nexport function resolveDecoratorValue<TFallback>(\n key: EnvKeyInput,\n config: DecoratorConfig<TFallback>,\n cacheKey: string\n): TFallback | undefined {\n const { fallback, converter, hasFallback, required, schema } = config;\n\n // cache.has guards the read so a cached undefined counts as resolved (a converter returning\n // undefined, or a missing no-fallback read) and later accesses skip re-resolving\n if (cache.has(cacheKey)) return cache.get(cacheKey) as TFallback | undefined;\n\n const envapter = new Envapter();\n\n if (required && schema === undefined) {\n const rawValue = envapter.getRaw(key);\n if (isMissing(rawValue)) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Required environment variable \"${formatKeyForError(key)}\" is missing or empty.`\n );\n }\n }\n\n const valueConverter = new ValueConverter(envapter);\n const value =\n schema !== undefined\n ? (valueConverter.convertWithSchema(key, schema, fallback, hasFallback) as TFallback)\n : valueConverter.convertValue(key, fallback, converter, hasFallback);\n\n cache.set(cacheKey, value);\n return value;\n}\n"],"mappings":"+PAiBA,SAAS,EAAkB,EAA0B,CACjD,OAAO,MAAM,QAAQ,CAAG,EAAI,IAAI,EAAI,KAAK,IAAI,EAAE,GAAK,OAAO,CAAG,CAClE,CAEA,MAAM,EAAW,IAAI,QACrB,IAAI,EAAc,EAIlB,SAAgB,EAAkB,EAAe,EAAmB,EAAsB,CACtF,IAAI,EAAK,EAAS,IAAI,CAAK,EAK3B,OAJI,IAAO,IAAA,KACP,EAAK,IACL,EAAS,IAAI,EAAO,CAAE,GAEnB,GAAG,EAAG,GAAG,EAAW,SAAW,WAAW,GAAG,GACxD,CAEA,SAAgB,EACZ,EACA,EACA,EACqB,CACrB,GAAM,CAAE,WAAU,YAAW,cAAa,WAAU,UAAW,EAI/D,GAAI,EAAM,IAAI,CAAQ,EAAG,OAAO,EAAM,IAAI,CAAQ,EAElD,IAAM,EAAW,IAAI,EAErB,GAAI,GAAY,IAAW,IAAA,IAEnB,EADa,EAAS,OAAO,CACZ,CAAC,EAClB,MAAM,IAAI,EAAA,IAEN,kCAAkC,EAAkB,CAAG,EAAE,uBAC7D,EAIR,IAAM,EAAiB,IAAI,EAAe,CAAQ,EAC5C,EACF,IAAW,IAAA,GAEL,EAAe,aAAa,EAAK,EAAU,EAAW,CAAW,EADhE,EAAe,kBAAkB,EAAK,EAAQ,EAAU,CAAW,EAI9E,OADA,EAAM,IAAI,EAAU,CAAK,EAClB,CACX"}
|
|
@@ -32,7 +32,7 @@ import { EnvaptFieldDecorator } from "../../types/Decorator.mjs";
|
|
|
32
32
|
* }
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
|
-
declare function Envapt(key: EnvKeyInput, options
|
|
35
|
+
declare function Envapt(key: EnvKeyInput, options?: {
|
|
36
36
|
fallback: undefined;
|
|
37
37
|
converter?: undefined;
|
|
38
38
|
}): EnvaptFieldDecorator<string | undefined>;
|
|
@@ -96,7 +96,7 @@ declare function Envapt<TReturnType>(key: EnvKeyInput, options: {
|
|
|
96
96
|
*
|
|
97
97
|
* // prefers CANARY_URL when present, otherwise APP_URL
|
|
98
98
|
* \@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })
|
|
99
|
-
* static readonly canaryUrl: URL |
|
|
99
|
+
* static readonly canaryUrl: URL | undefined;
|
|
100
100
|
*
|
|
101
101
|
* // Time takes a number (milliseconds) or a time-string fallback (`<number><unit>`)
|
|
102
102
|
* \@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })
|
|
@@ -123,13 +123,9 @@ declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvK
|
|
|
123
123
|
}): EnvaptFieldDecorator<InferConverterReturnType<TConverter>>;
|
|
124
124
|
declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
|
|
125
125
|
converter: TConverter;
|
|
126
|
-
fallback
|
|
126
|
+
fallback?: undefined;
|
|
127
127
|
required?: false;
|
|
128
128
|
}): EnvaptFieldDecorator<InferConverterReturnType<TConverter> | undefined>;
|
|
129
|
-
declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
|
|
130
|
-
converter: TConverter;
|
|
131
|
-
required?: false;
|
|
132
|
-
}): EnvaptFieldDecorator<InferConverterReturnType<TConverter> | null>;
|
|
133
129
|
/**
|
|
134
130
|
* A primitive constructor (`Number`, `Boolean`) with an optional fallback.
|
|
135
131
|
*
|
|
@@ -157,13 +153,9 @@ declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyIn
|
|
|
157
153
|
}): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor>>;
|
|
158
154
|
declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
|
|
159
155
|
converter: TConstructor;
|
|
160
|
-
fallback
|
|
156
|
+
fallback?: undefined;
|
|
161
157
|
required?: false;
|
|
162
158
|
}): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor> | undefined>;
|
|
163
|
-
declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
|
|
164
|
-
converter: TConstructor;
|
|
165
|
-
required?: false;
|
|
166
|
-
}): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor> | null>;
|
|
167
159
|
/**
|
|
168
160
|
* Required, no converter (raw string). Throws `MissingEnvValue` on first access when the env
|
|
169
161
|
* value is missing or empty after trimming, independent of the global `Envapter.strict` flag.
|
|
@@ -184,20 +176,6 @@ declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyIn
|
|
|
184
176
|
declare function Envapt(key: EnvKeyInput, options: {
|
|
185
177
|
required: true;
|
|
186
178
|
}): EnvaptFieldDecorator<string>;
|
|
187
|
-
/**
|
|
188
|
-
* No-fallback form. The property resolves from env or `null`.
|
|
189
|
-
*
|
|
190
|
-
* @param key - Environment variable name(s) to load
|
|
191
|
-
* @public
|
|
192
|
-
* @example
|
|
193
|
-
* ```ts
|
|
194
|
-
* class Config extends Envapter {
|
|
195
|
-
* \@Envapt('SIMPLE_VALUE')
|
|
196
|
-
* static readonly simple?: string | null;
|
|
197
|
-
* }
|
|
198
|
-
* ```
|
|
199
|
-
*/
|
|
200
|
-
declare function Envapt(key: EnvKeyInput): EnvaptFieldDecorator<string | null>;
|
|
201
179
|
/**
|
|
202
180
|
* A Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous schemas only,
|
|
203
181
|
* so a Promise-returning `validate` throws `InvalidUserDefinedConfig` at runtime. Pairing
|
|
@@ -9,21 +9,21 @@ import { EnvaptFieldDecorator } from "../../types/Decorator.mjs";
|
|
|
9
9
|
* @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
|
|
10
10
|
*/
|
|
11
11
|
declare function EnvBool(key: EnvKeyInput, fallback: boolean): EnvaptFieldDecorator<boolean>;
|
|
12
|
-
declare function EnvBool(key: EnvKeyInput): EnvaptFieldDecorator<boolean |
|
|
12
|
+
declare function EnvBool(key: EnvKeyInput): EnvaptFieldDecorator<boolean | undefined>;
|
|
13
13
|
/**
|
|
14
14
|
* Shorthand for `@Envapt(key, { converter: Converters.Number, fallback })`.
|
|
15
15
|
* @public
|
|
16
16
|
* @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
|
|
17
17
|
*/
|
|
18
18
|
declare function EnvNum(key: EnvKeyInput, fallback: number): EnvaptFieldDecorator<number>;
|
|
19
|
-
declare function EnvNum(key: EnvKeyInput): EnvaptFieldDecorator<number |
|
|
19
|
+
declare function EnvNum(key: EnvKeyInput): EnvaptFieldDecorator<number | undefined>;
|
|
20
20
|
/**
|
|
21
21
|
* Shorthand for `@Envapt(key, { converter: Converters.String, fallback })`.
|
|
22
22
|
* @public
|
|
23
23
|
* @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
|
|
24
24
|
*/
|
|
25
25
|
declare function EnvStr(key: EnvKeyInput, fallback: string): EnvaptFieldDecorator<string>;
|
|
26
|
-
declare function EnvStr(key: EnvKeyInput): EnvaptFieldDecorator<string |
|
|
26
|
+
declare function EnvStr(key: EnvKeyInput): EnvaptFieldDecorator<string | undefined>;
|
|
27
27
|
/**
|
|
28
28
|
* Shorthand for `@Envapt(key, { converter: Converters.Time, fallback })`. The fallback is a
|
|
29
29
|
* millisecond number or a time string (`'15m'`), and the resolved value is always milliseconds.
|
|
@@ -31,7 +31,7 @@ declare function EnvStr(key: EnvKeyInput): EnvaptFieldDecorator<string | null>;
|
|
|
31
31
|
* @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
|
|
32
32
|
*/
|
|
33
33
|
declare function EnvTime(key: EnvKeyInput, fallback: TimeFallback): EnvaptFieldDecorator<number>;
|
|
34
|
-
declare function EnvTime(key: EnvKeyInput): EnvaptFieldDecorator<number |
|
|
34
|
+
declare function EnvTime(key: EnvKeyInput): EnvaptFieldDecorator<number | undefined>;
|
|
35
35
|
/**
|
|
36
36
|
* Shorthand for `@Envapt(key, { converter: Converters.Url, fallback })`. The fallback is a `URL`
|
|
37
37
|
* instance, not a URL string.
|
|
@@ -39,7 +39,7 @@ declare function EnvTime(key: EnvKeyInput): EnvaptFieldDecorator<number | null>;
|
|
|
39
39
|
* @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
|
|
40
40
|
*/
|
|
41
41
|
declare function EnvUrl(key: EnvKeyInput, fallback: URL): EnvaptFieldDecorator<URL>;
|
|
42
|
-
declare function EnvUrl(key: EnvKeyInput): EnvaptFieldDecorator<URL |
|
|
42
|
+
declare function EnvUrl(key: EnvKeyInput): EnvaptFieldDecorator<URL | undefined>;
|
|
43
43
|
//#endregion
|
|
44
44
|
export { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl };
|
|
45
45
|
//# sourceMappingURL=SugarDecorators.d.mts.map
|
|
@@ -32,7 +32,7 @@ import { EnvaptAccessorDecorator } from "../../types/Decorator.mjs";
|
|
|
32
32
|
* }
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
|
-
declare function Envapt(key: EnvKeyInput, options
|
|
35
|
+
declare function Envapt(key: EnvKeyInput, options?: {
|
|
36
36
|
fallback: undefined;
|
|
37
37
|
converter?: undefined;
|
|
38
38
|
}): EnvaptAccessorDecorator<string | undefined>;
|
|
@@ -96,7 +96,7 @@ declare function Envapt<TReturnType>(key: EnvKeyInput, options: {
|
|
|
96
96
|
*
|
|
97
97
|
* // prefers CANARY_URL when present, otherwise APP_URL
|
|
98
98
|
* \@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })
|
|
99
|
-
* static accessor canaryUrl: URL |
|
|
99
|
+
* static accessor canaryUrl: URL | undefined;
|
|
100
100
|
*
|
|
101
101
|
* // Time takes a number (milliseconds) or a time-string fallback (`<number><unit>`)
|
|
102
102
|
* \@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })
|
|
@@ -123,13 +123,9 @@ declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvK
|
|
|
123
123
|
}): EnvaptAccessorDecorator<InferConverterReturnType<TConverter>>;
|
|
124
124
|
declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
|
|
125
125
|
converter: TConverter;
|
|
126
|
-
fallback
|
|
126
|
+
fallback?: undefined;
|
|
127
127
|
required?: false;
|
|
128
128
|
}): EnvaptAccessorDecorator<InferConverterReturnType<TConverter> | undefined>;
|
|
129
|
-
declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
|
|
130
|
-
converter: TConverter;
|
|
131
|
-
required?: false;
|
|
132
|
-
}): EnvaptAccessorDecorator<InferConverterReturnType<TConverter> | null>;
|
|
133
129
|
/**
|
|
134
130
|
* A primitive constructor (`Number`, `Boolean`) with an optional fallback.
|
|
135
131
|
*
|
|
@@ -157,13 +153,9 @@ declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyIn
|
|
|
157
153
|
}): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor>>;
|
|
158
154
|
declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
|
|
159
155
|
converter: TConstructor;
|
|
160
|
-
fallback
|
|
156
|
+
fallback?: undefined;
|
|
161
157
|
required?: false;
|
|
162
158
|
}): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor> | undefined>;
|
|
163
|
-
declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
|
|
164
|
-
converter: TConstructor;
|
|
165
|
-
required?: false;
|
|
166
|
-
}): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor> | null>;
|
|
167
159
|
/**
|
|
168
160
|
* Required, no converter (raw string). Throws `MissingEnvValue` on first access when the env
|
|
169
161
|
* value is missing or empty after trimming, independent of the global `Envapter.strict` flag.
|
|
@@ -184,20 +176,6 @@ declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyIn
|
|
|
184
176
|
declare function Envapt(key: EnvKeyInput, options: {
|
|
185
177
|
required: true;
|
|
186
178
|
}): EnvaptAccessorDecorator<string>;
|
|
187
|
-
/**
|
|
188
|
-
* No-fallback form. The property resolves from env or `null`.
|
|
189
|
-
*
|
|
190
|
-
* @param key - Environment variable name(s) to load
|
|
191
|
-
* @public
|
|
192
|
-
* @example
|
|
193
|
-
* ```ts
|
|
194
|
-
* class Config {
|
|
195
|
-
* \@Envapt('SIMPLE_VALUE')
|
|
196
|
-
* static accessor simple: string | null;
|
|
197
|
-
* }
|
|
198
|
-
* ```
|
|
199
|
-
*/
|
|
200
|
-
declare function Envapt(key: EnvKeyInput): EnvaptAccessorDecorator<string | null>;
|
|
201
179
|
/**
|
|
202
180
|
* A Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous schemas only,
|
|
203
181
|
* so a Promise-returning `validate` throws `InvalidUserDefinedConfig` at runtime. Pairing
|
|
@@ -9,21 +9,21 @@ import { EnvaptAccessorDecorator } from "../../types/Decorator.mjs";
|
|
|
9
9
|
* @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
|
|
10
10
|
*/
|
|
11
11
|
declare function EnvBool(key: EnvKeyInput, fallback: boolean): EnvaptAccessorDecorator<boolean>;
|
|
12
|
-
declare function EnvBool(key: EnvKeyInput): EnvaptAccessorDecorator<boolean |
|
|
12
|
+
declare function EnvBool(key: EnvKeyInput): EnvaptAccessorDecorator<boolean | undefined>;
|
|
13
13
|
/**
|
|
14
14
|
* Shorthand for `@Envapt(key, { converter: Converters.Number, fallback })`.
|
|
15
15
|
* @public
|
|
16
16
|
* @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
|
|
17
17
|
*/
|
|
18
18
|
declare function EnvNum(key: EnvKeyInput, fallback: number): EnvaptAccessorDecorator<number>;
|
|
19
|
-
declare function EnvNum(key: EnvKeyInput): EnvaptAccessorDecorator<number |
|
|
19
|
+
declare function EnvNum(key: EnvKeyInput): EnvaptAccessorDecorator<number | undefined>;
|
|
20
20
|
/**
|
|
21
21
|
* Shorthand for `@Envapt(key, { converter: Converters.String, fallback })`.
|
|
22
22
|
* @public
|
|
23
23
|
* @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
|
|
24
24
|
*/
|
|
25
25
|
declare function EnvStr(key: EnvKeyInput, fallback: string): EnvaptAccessorDecorator<string>;
|
|
26
|
-
declare function EnvStr(key: EnvKeyInput): EnvaptAccessorDecorator<string |
|
|
26
|
+
declare function EnvStr(key: EnvKeyInput): EnvaptAccessorDecorator<string | undefined>;
|
|
27
27
|
/**
|
|
28
28
|
* Shorthand for `@Envapt(key, { converter: Converters.Time, fallback })`. The fallback is a
|
|
29
29
|
* millisecond number or a time string (`'15m'`), and the resolved value is always milliseconds.
|
|
@@ -31,7 +31,7 @@ declare function EnvStr(key: EnvKeyInput): EnvaptAccessorDecorator<string | null
|
|
|
31
31
|
* @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
|
|
32
32
|
*/
|
|
33
33
|
declare function EnvTime(key: EnvKeyInput, fallback: TimeFallback): EnvaptAccessorDecorator<number>;
|
|
34
|
-
declare function EnvTime(key: EnvKeyInput): EnvaptAccessorDecorator<number |
|
|
34
|
+
declare function EnvTime(key: EnvKeyInput): EnvaptAccessorDecorator<number | undefined>;
|
|
35
35
|
/**
|
|
36
36
|
* Shorthand for `@Envapt(key, { converter: Converters.Url, fallback })`. The fallback is a `URL`
|
|
37
37
|
* instance, not a URL string.
|
|
@@ -39,7 +39,7 @@ declare function EnvTime(key: EnvKeyInput): EnvaptAccessorDecorator<number | nul
|
|
|
39
39
|
* @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
|
|
40
40
|
*/
|
|
41
41
|
declare function EnvUrl(key: EnvKeyInput, fallback: URL): EnvaptAccessorDecorator<URL>;
|
|
42
|
-
declare function EnvUrl(key: EnvKeyInput): EnvaptAccessorDecorator<URL |
|
|
42
|
+
declare function EnvUrl(key: EnvKeyInput): EnvaptAccessorDecorator<URL | undefined>;
|
|
43
43
|
//#endregion
|
|
44
44
|
export { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl };
|
|
45
45
|
//# sourceMappingURL=SugarDecorators.d.mts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "envapt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "8.0.0
|
|
4
|
+
"version": "8.0.0",
|
|
5
5
|
"description": "Type-safe config for TypeScript. Read typed values from any source, process.env, .env files, Cloudflare Workers bindings, browser bundles, or any object you supply. Zero runtime dependencies, one API across Node, Bun, Deno, Workers, and the browser. TC39 accessor decorators (legacy decorators at envapt/legacy), converters, and Standard Schema (zod/valibot/arktype) validation.",
|
|
6
6
|
"types": "./dist/types/index.d.mts",
|
|
7
7
|
"exports": {
|
|
@@ -186,14 +186,14 @@
|
|
|
186
186
|
"provenance": true
|
|
187
187
|
},
|
|
188
188
|
"devDependencies": {
|
|
189
|
-
"@cloudflare/vitest-pool-workers": "0.
|
|
190
|
-
"@cloudflare/workers-types": "^
|
|
191
|
-
"@vitest/browser": "4.1.
|
|
192
|
-
"@vitest/browser-playwright": "4.1.
|
|
193
|
-
"arktype": "^2.2.
|
|
189
|
+
"@cloudflare/vitest-pool-workers": "0.18.0",
|
|
190
|
+
"@cloudflare/workers-types": "^5.20260706.1",
|
|
191
|
+
"@vitest/browser": "4.1.10",
|
|
192
|
+
"@vitest/browser-playwright": "4.1.10",
|
|
193
|
+
"arktype": "^2.2.2",
|
|
194
194
|
"esbuild": "^0.28.1",
|
|
195
|
-
"playwright": "1.61.
|
|
196
|
-
"valibot": "^1.4.
|
|
195
|
+
"playwright": "1.61.1",
|
|
196
|
+
"valibot": "^1.4.2",
|
|
197
197
|
"zod": "4.4.3"
|
|
198
198
|
},
|
|
199
199
|
"scripts": {
|