envapt 8.1.1 → 8.2.1

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.
Files changed (125) hide show
  1. package/CHANGELOG.md +18 -15
  2. package/README.md +5 -6
  3. package/dist/node/config.cjs.map +1 -1
  4. package/dist/node/config.mjs.map +1 -1
  5. package/dist/node/converters/BuiltInConverters.cjs.map +1 -1
  6. package/dist/node/converters/BuiltInConverters.mjs.map +1 -1
  7. package/dist/node/converters/Converters.cjs.map +1 -1
  8. package/dist/node/converters/Converters.mjs.map +1 -1
  9. package/dist/node/converters/ListOfBuiltInConverters.cjs.map +1 -1
  10. package/dist/node/converters/ListOfBuiltInConverters.mjs.map +1 -1
  11. package/dist/node/converters/ValueConverter.cjs.map +1 -1
  12. package/dist/node/converters/ValueConverter.mjs.map +1 -1
  13. package/dist/node/core/AdvancedMethods.cjs.map +1 -1
  14. package/dist/node/core/AdvancedMethods.mjs.map +1 -1
  15. package/dist/node/core/EnvapterBase.cjs.map +1 -1
  16. package/dist/node/core/EnvapterBase.mjs.map +1 -1
  17. package/dist/node/core/EnvironmentMethods.cjs.map +1 -1
  18. package/dist/node/core/EnvironmentMethods.mjs.map +1 -1
  19. package/dist/node/core/PrimitiveMethods.cjs.map +1 -1
  20. package/dist/node/core/PrimitiveMethods.mjs.map +1 -1
  21. package/dist/node/core/engine.cjs.map +1 -1
  22. package/dist/node/core/engine.mjs.map +1 -1
  23. package/dist/node/core/missing.cjs.map +1 -1
  24. package/dist/node/core/missing.mjs.map +1 -1
  25. package/dist/node/core/paths.cjs.map +1 -1
  26. package/dist/node/core/paths.mjs.map +1 -1
  27. package/dist/node/core/state.cjs.map +1 -1
  28. package/dist/node/core/state.mjs.map +1 -1
  29. package/dist/node/decorators/legacy/Envapt.cjs.map +1 -1
  30. package/dist/node/decorators/legacy/Envapt.mjs.map +1 -1
  31. package/dist/node/decorators/legacy/SugarDecorators.cjs.map +1 -1
  32. package/dist/node/decorators/legacy/SugarDecorators.mjs.map +1 -1
  33. package/dist/node/decorators/modern/Envapt.cjs.map +1 -1
  34. package/dist/node/decorators/modern/Envapt.mjs.map +1 -1
  35. package/dist/node/decorators/modern/SugarDecorators.cjs.map +1 -1
  36. package/dist/node/decorators/modern/SugarDecorators.mjs.map +1 -1
  37. package/dist/node/decorators/modern/createAccessorDecorator.cjs.map +1 -1
  38. package/dist/node/decorators/modern/createAccessorDecorator.mjs.map +1 -1
  39. package/dist/node/decorators/resolveDecoratorValue.cjs.map +1 -1
  40. package/dist/node/decorators/resolveDecoratorValue.mjs.map +1 -1
  41. package/dist/node/engine/Envapter.cjs.map +1 -1
  42. package/dist/node/engine/Envapter.mjs.map +1 -1
  43. package/dist/node/engine/NodeEnvapter.cjs.map +1 -1
  44. package/dist/node/engine/NodeEnvapter.mjs.map +1 -1
  45. package/dist/node/engine/TemplateResolver.cjs.map +1 -1
  46. package/dist/node/engine/TemplateResolver.mjs.map +1 -1
  47. package/dist/node/engine/Validators.cjs.map +1 -1
  48. package/dist/node/engine/Validators.mjs.map +1 -1
  49. package/dist/node/infra/Debug.cjs.map +1 -1
  50. package/dist/node/infra/Debug.mjs.map +1 -1
  51. package/dist/node/infra/Dotenv.cjs.map +1 -1
  52. package/dist/node/infra/Dotenv.mjs.map +1 -1
  53. package/dist/node/infra/Error.cjs.map +1 -1
  54. package/dist/node/infra/Error.mjs.map +1 -1
  55. package/dist/node/infra/recase.cjs.map +1 -1
  56. package/dist/node/infra/recase.mjs.map +1 -1
  57. package/dist/node/infra/runtime.cjs.map +1 -1
  58. package/dist/node/infra/runtime.mjs.map +1 -1
  59. package/dist/node/sources/FileSource.cjs.map +1 -1
  60. package/dist/node/sources/FileSource.mjs.map +1 -1
  61. package/dist/node/sources/PortableSource.cjs.map +1 -1
  62. package/dist/node/sources/PortableSource.mjs.map +1 -1
  63. package/dist/node/sources/UnboundSource.cjs.map +1 -1
  64. package/dist/node/sources/UnboundSource.mjs.map +1 -1
  65. package/dist/node/sources/coerce.cjs.map +1 -1
  66. package/dist/node/sources/coerce.mjs.map +1 -1
  67. package/dist/node/sources/merge.cjs.map +1 -1
  68. package/dist/node/sources/merge.mjs.map +1 -1
  69. package/dist/portable/converters/BuiltInConverters.mjs.map +1 -1
  70. package/dist/portable/converters/Converters.mjs.map +1 -1
  71. package/dist/portable/converters/ListOfBuiltInConverters.mjs.map +1 -1
  72. package/dist/portable/converters/ValueConverter.mjs.map +1 -1
  73. package/dist/portable/core/AdvancedMethods.mjs.map +1 -1
  74. package/dist/portable/core/EnvapterBase.mjs.map +1 -1
  75. package/dist/portable/core/EnvironmentMethods.mjs.map +1 -1
  76. package/dist/portable/core/PrimitiveMethods.mjs.map +1 -1
  77. package/dist/portable/core/engine.mjs.map +1 -1
  78. package/dist/portable/core/missing.mjs.map +1 -1
  79. package/dist/portable/core/paths.mjs.map +1 -1
  80. package/dist/portable/core/state.mjs.map +1 -1
  81. package/dist/portable/decorators/legacy/Envapt.mjs.map +1 -1
  82. package/dist/portable/decorators/legacy/SugarDecorators.mjs.map +1 -1
  83. package/dist/portable/decorators/modern/Envapt.mjs.map +1 -1
  84. package/dist/portable/decorators/modern/SugarDecorators.mjs.map +1 -1
  85. package/dist/portable/decorators/modern/createAccessorDecorator.mjs.map +1 -1
  86. package/dist/portable/decorators/resolveDecoratorValue.mjs.map +1 -1
  87. package/dist/portable/engine/Envapter.mjs.map +1 -1
  88. package/dist/portable/engine/PortableEnvapter.mjs.map +1 -1
  89. package/dist/portable/engine/TemplateResolver.mjs.map +1 -1
  90. package/dist/portable/engine/Validators.mjs.map +1 -1
  91. package/dist/portable/engine/fileApiStub.mjs.map +1 -1
  92. package/dist/portable/infra/Debug.mjs.map +1 -1
  93. package/dist/portable/infra/Dotenv.mjs.map +1 -1
  94. package/dist/portable/infra/Error.mjs.map +1 -1
  95. package/dist/portable/infra/recase.mjs.map +1 -1
  96. package/dist/portable/infra/runtime.mjs.map +1 -1
  97. package/dist/portable/sources/PortableSource.mjs.map +1 -1
  98. package/dist/portable/sources/UnboundSource.mjs.map +1 -1
  99. package/dist/portable/sources/coerce.mjs.map +1 -1
  100. package/dist/portable/sources/merge.mjs.map +1 -1
  101. package/dist/types/converters/Converters.d.mts +4 -5
  102. package/dist/types/core/AdvancedMethods.d.mts +6 -12
  103. package/dist/types/core/EnvapterBase.d.mts +9 -12
  104. package/dist/types/core/Environment.d.mts +1 -2
  105. package/dist/types/core/EnvironmentMethods.d.mts +1 -6
  106. package/dist/types/core/PrimitiveMethods.d.mts +1 -5
  107. package/dist/types/decorators/legacy/Envapt.d.mts +17 -19
  108. package/dist/types/decorators/legacy/SugarDecorators.d.mts +12 -13
  109. package/dist/types/decorators/modern/Envapt.d.mts +17 -19
  110. package/dist/types/decorators/modern/SugarDecorators.d.mts +12 -13
  111. package/dist/types/engine/Envapter.d.mts +2 -2
  112. package/dist/types/engine/NodeEnvapter.d.mts +5 -6
  113. package/dist/types/engine/PortableEnvapter.d.mts +5 -7
  114. package/dist/types/infra/Debug.d.mts +3 -5
  115. package/dist/types/infra/Dotenv.d.mts +2 -4
  116. package/dist/types/infra/Error.d.mts +4 -5
  117. package/dist/types/infra/StandardSchema.d.mts +5 -7
  118. package/dist/types/sources/FileSource.d.mts +1 -2
  119. package/dist/types/sources/PortableSource.d.mts +7 -8
  120. package/dist/types/sources/merge.d.mts +1 -2
  121. package/dist/types/types/Conversion.d.mts +0 -4
  122. package/dist/types/types/Decorator.d.mts +2 -3
  123. package/dist/types/types/Options.d.mts +7 -7
  124. package/dist/types/types/Schema.d.mts +1 -1
  125. package/package.json +11 -13
@@ -1 +1 @@
1
- {"version":3,"file":"AdvancedMethods.mjs","names":[],"sources":["../../../src/core/AdvancedMethods.ts"],"sourcesContent":["import { resolveKeyInput, templateResolver, valueConverter } from './engine';\nimport { hasFallback, isMissing } from './missing';\nimport { PrimitiveMethods } from './PrimitiveMethods';\nimport { debugWarn } from '../infra/Debug';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\nimport { recase } from '../infra/recase';\n\nimport type { ArrayOf } from '../converters';\nimport type { TemplateResolver } from '../engine/TemplateResolver';\nimport type { InferSchemaOutput, StandardSchemaV1 } from '../infra/StandardSchema';\nimport type {\n AdvancedConverterReturn,\n BuiltInConverter,\n ConditionalReturn,\n ConverterFunction,\n EnvaptConverter,\n EnvKeyInput,\n InferConverterReturnType,\n InferSpecField,\n KeyCasing,\n RecaseKey,\n RequiredSpec,\n SchemaConstraint,\n TimeFallback\n} from '../types';\n\nfunction formatKeyForError(key: EnvKeyInput): string {\n return Array.isArray(key) ? `[${key.join(', ')}]` : String(key);\n}\n\n// missing check runs after template resolution so a value that resolves to blank falls through\n// (empty always, whitespace-only under strict)\nexport function resolveRequired(\n resolved: { key: string; value: string | undefined },\n templateResolver: TemplateResolver\n): { key: string; value: string | undefined } {\n if (resolved.value === undefined) return resolved;\n const value = templateResolver.resolveTemplate(resolved.key, resolved.value);\n return { key: resolved.key, value: isMissing(value) ? undefined : value };\n}\n\n/**\n * Mixin for advanced methods for environment variable conversion using built-in and custom converters\n * @internal\n */\nexport class AdvancedMethods extends PrimitiveMethods {\n /**\n * Get an environment variable using a built-in converter.\n *\n * Supports both scalar tokens (e.g. `Converters.Number`) and `ArrayOf<...>` tokens\n * produced by `Converters.array(...)`. The key can be a single name or an ordered list.\n * The first defined value wins.\n * @see {@link https://envapt.materwelon.dev/docs/envapter#converters}\n * @see {@link https://envapt.materwelon.dev/docs/converters#custom-converters}\n */\n // Time-specific overload must precede the generic BuiltInConverter overload so it wins\n // overload resolution (TimeFallback accepts time-strings like `'10s'`).\n static getUsing<TFallback extends TimeFallback | undefined = undefined>(\n key: EnvKeyInput,\n converter: 'time',\n fallback?: TFallback\n ): ConditionalReturn<number, TFallback>;\n static getUsing<TConverter extends BuiltInConverter | ArrayOf, TFallback = undefined>(\n key: EnvKeyInput,\n converter: TConverter,\n fallback?: TFallback\n ): AdvancedConverterReturn<TConverter, TFallback>;\n static getUsing<TReturn>(key: EnvKeyInput, converter: BuiltInConverter | ArrayOf, fallback?: TReturn): TReturn;\n static getUsing<TConverter extends BuiltInConverter | ArrayOf, TFallback = undefined>(\n key: EnvKeyInput,\n converter: TConverter,\n fallback?: TFallback\n ): AdvancedConverterReturn<TConverter, TFallback> {\n const { key: resolvedKey, value } = resolveKeyInput(key);\n\n // a missing value with a fallback falls through to the parser so asymmetric types\n // (TimeFallback, TimeFallback[] for `of: time`) coerce to the return type\n if (isMissing(value) && !hasFallback(fallback)) {\n debugWarn(`${resolvedKey} is missing or empty`);\n return undefined as AdvancedConverterReturn<TConverter, TFallback>;\n }\n\n const result = valueConverter.convertValue(resolvedKey, fallback, converter, hasFallback(fallback));\n\n return result as AdvancedConverterReturn<TConverter, TFallback>;\n }\n\n /**\n * @see {@link AdvancedMethods.getUsing}\n */\n getUsing<TFallback extends TimeFallback | undefined = undefined>(\n key: EnvKeyInput,\n converter: 'time',\n fallback?: TFallback\n ): ConditionalReturn<number, TFallback>;\n getUsing<TConverter extends BuiltInConverter | ArrayOf, TFallback = undefined>(\n key: EnvKeyInput,\n converter: TConverter,\n fallback?: TFallback\n ): AdvancedConverterReturn<TConverter, TFallback>;\n getUsing<TReturn>(key: EnvKeyInput, converter: BuiltInConverter | ArrayOf, fallback?: TReturn): TReturn;\n getUsing<TConverter extends BuiltInConverter | ArrayOf, TFallback = undefined>(\n key: EnvKeyInput,\n converter: TConverter,\n fallback?: TFallback\n ): AdvancedConverterReturn<TConverter, TFallback> {\n return AdvancedMethods.getUsing(key, converter, fallback);\n }\n\n /**\n * Get an environment variable using a custom converter function.\n * Accepts a single key or an ordered list for automatic fallback.\n * @see {@link https://envapt.materwelon.dev/docs/envapter#converters}\n * @see {@link https://envapt.materwelon.dev/docs/converters#custom-converters}\n */\n static getWith<TReturnType, TFallback extends TReturnType | undefined = undefined>(\n key: EnvKeyInput,\n converter: ConverterFunction<TReturnType>,\n fallback?: TFallback\n ): ConditionalReturn<TReturnType, TFallback> {\n // run the custom converter even on a missing value, with raw as undefined\n const result = valueConverter.convertValue<TReturnType>(key, fallback, converter, hasFallback(fallback));\n\n return result as ConditionalReturn<TReturnType, TFallback>;\n }\n\n /**\n * @see {@link AdvancedMethods.getWith}\n */\n getWith<TReturnType, TFallback extends TReturnType | undefined = undefined>(\n key: EnvKeyInput,\n converter: ConverterFunction<TReturnType>,\n fallback?: TFallback\n ): ConditionalReturn<TReturnType, TFallback> {\n return AdvancedMethods.getWith(key, converter, fallback);\n }\n\n /**\n * Read a required environment variable and convert it, throwing `MissingEnvValue` when the value\n * is missing or empty. Returns the non-undefined converter output. Accepts a built-in or `ArrayOf`\n * token, or a custom parser function. The key can be a single name or an ordered list.\n * @see {@link https://envapt.materwelon.dev/docs/envapter#fail-fast-on-missing-values}\n * @see {@link https://envapt.materwelon.dev/docs/converters#require-a-converted-value}\n */\n static getRequired<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n converter: TConverter\n ): InferConverterReturnType<TConverter>;\n static getRequired<TReturnType>(key: EnvKeyInput, converter: ConverterFunction<TReturnType, string>): TReturnType;\n static getRequired<TConverter extends BuiltInConverter | ArrayOf, TReturnType>(\n key: EnvKeyInput,\n converter: TConverter | ConverterFunction<TReturnType, string>\n ): InferConverterReturnType<TConverter> | TReturnType {\n // a required read treats empty as missing, so an empty value falls through to the next candidate.\n const candidates: readonly string[] = typeof key === 'string' ? [key] : key;\n let resolvedKey = '';\n let value: string | undefined;\n for (const candidate of candidates) {\n const resolved = resolveRequired(resolveKeyInput(candidate), templateResolver);\n resolvedKey = resolved.key;\n if (resolved.value !== undefined) {\n value = resolved.value;\n break;\n }\n }\n if (value === undefined) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Required environment variable \"${formatKeyForError(key)}\" is missing or empty.`\n );\n }\n // cast widens the raw-string parser back to convertValue's ConverterFunction<T> (value proven present above).\n const result = valueConverter.convertValue<TReturnType>(\n resolvedKey,\n undefined,\n converter as EnvaptConverter<TReturnType>,\n false\n );\n // a built-in yields undefined for a present value it cannot convert, a custom converter can return null, both break the non-undefined return\n if (result === undefined || result === null) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Required environment variable \"${formatKeyForError(key)}\" is present but could not be converted.`\n );\n }\n return result;\n }\n\n /**\n * @see {@link AdvancedMethods.getRequired}\n */\n getRequired<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n converter: TConverter\n ): InferConverterReturnType<TConverter>;\n getRequired<TReturnType>(key: EnvKeyInput, converter: ConverterFunction<TReturnType, string>): TReturnType;\n getRequired<TConverter extends BuiltInConverter | ArrayOf, TReturnType>(\n key: EnvKeyInput,\n converter: TConverter | ConverterFunction<TReturnType, string>\n ): InferConverterReturnType<TConverter> | TReturnType {\n return AdvancedMethods.getRequired(key, converter as ConverterFunction<TReturnType, string>);\n }\n\n /**\n * Read a group of required environment variables in one call. Each key in `spec` maps to a\n * converter (a token, an `array()` token, or a custom parser), and the returned record holds\n * every converted value, all non-undefined. Collects every missing or empty key and throws one\n * `MissingEnvValue` listing them all. Pass a `casing` (`'camelCase'`, `'PascalCase'`, or\n * `'kebab-case'`) to rename the record keys, splitting on underscores, which assumes the\n * conventional SCREAMING_SNAKE env-var names. With no casing the keys stay as-is.\n * @see {@link https://envapt.materwelon.dev/docs/envapter#fail-fast-on-missing-values}\n * @see {@link https://envapt.materwelon.dev/docs/converters#require-a-converted-value}\n */\n static getRequiredAll<Spec extends RequiredSpec, Casing extends KeyCasing | undefined = undefined>(\n spec: Spec,\n casing?: Casing\n ): { [K in keyof Spec as RecaseKey<K & string, Casing>]: InferSpecField<Spec[K]> } {\n const keys = Object.keys(spec);\n const missing = keys.filter(\n (key) => resolveRequired(resolveKeyInput(key), templateResolver).value === undefined\n );\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Missing required environment variables: ${missing.join(', ')}.`\n );\n }\n\n const result: Record<string, unknown> = {};\n for (const key of keys) {\n // same widening cast as getRequired, every value was proven present above.\n const converted = valueConverter.convertValue<unknown>(\n key,\n undefined,\n spec[key] as EnvaptConverter<unknown>,\n false\n );\n if (converted === undefined || converted === null) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Required environment variable \"${key}\" is present but could not be converted.`\n );\n }\n result[recase(key, casing)] = converted;\n }\n return result as { [K in keyof Spec as RecaseKey<K & string, Casing>]: InferSpecField<Spec[K]> };\n }\n\n /**\n * @see {@link AdvancedMethods.getRequiredAll}\n */\n getRequiredAll<Spec extends RequiredSpec, Casing extends KeyCasing | undefined = undefined>(\n spec: Spec,\n casing?: Casing\n ): { [K in keyof Spec as RecaseKey<K & string, Casing>]: InferSpecField<Spec[K]> } {\n return AdvancedMethods.getRequiredAll(spec, casing);\n }\n\n /**\n * Validate an environment variable through a {@link StandardSchemaV1}-conformant schema\n * (zod, valibot, arktype, etc). Throws `MissingEnvValue` if the env value is absent and\n * no fallback is provided. The fallback, when provided, is returned as-is on missing.\n * It does NOT pass through the schema, mirroring custom-converter behavior.\n *\n * Synchronous schemas only. A Promise-returning `validate` triggers an\n * `InvalidUserDefinedConfig` throw at the call site.\n *\n * @example\n * ```ts\n * import { z } from 'zod';\n * const port = Envapter.parse('PORT', z.coerce.number().min(1024).max(65535), 3000);\n * ```\n * @see {@link https://envapt.materwelon.dev/docs/standard-schema#any-conformant-validator-or-none}\n */\n static parse<Schema extends StandardSchemaV1>(\n key: EnvKeyInput,\n schema: SchemaConstraint<Schema>,\n fallback?: InferSchemaOutput<Schema>\n ): InferSchemaOutput<Schema> {\n // SchemaConstraint resolves to the unsatisfiable SchemaMustBeSync brand for async\n // schemas, so reaching this body means the input is structurally a sync Schema.\n const result = valueConverter.convertWithSchema(\n key,\n schema as unknown as StandardSchemaV1,\n fallback,\n hasFallback(fallback)\n );\n return result;\n }\n\n /**\n * @see {@link AdvancedMethods.parse}\n */\n parse<Schema extends StandardSchemaV1>(\n key: EnvKeyInput,\n schema: SchemaConstraint<Schema>,\n fallback?: InferSchemaOutput<Schema>\n ): InferSchemaOutput<Schema> {\n const result = valueConverter.convertWithSchema(\n key,\n schema as unknown as StandardSchemaV1,\n fallback,\n hasFallback(fallback)\n );\n return result;\n }\n}\n"],"mappings":"2VA0BA,SAAS,EAAkB,EAA0B,CACjD,OAAO,MAAM,QAAQ,CAAG,EAAI,IAAI,EAAI,KAAK,IAAI,EAAE,GAAK,OAAO,CAAG,CAClE,CAIA,SAAgB,EACZ,EACA,EAC0C,CAC1C,GAAI,EAAS,QAAU,IAAA,GAAW,OAAO,EACzC,IAAM,EAAQ,EAAiB,gBAAgB,EAAS,IAAK,EAAS,KAAK,EAC3E,MAAO,CAAE,IAAK,EAAS,IAAK,MAAO,EAAU,CAAK,EAAI,IAAA,GAAY,CAAM,CAC5E,CAMA,IAAa,EAAb,MAAa,UAAwB,CAAiB,CAuBlD,OAAO,SACH,EACA,EACA,EAC8C,CAC9C,GAAM,CAAE,IAAK,EAAa,SAAU,EAAgB,CAAG,EAIvD,GAAI,EAAU,CAAK,GAAK,CAAC,EAAY,CAAQ,EAAG,CAC5C,EAAU,GAAG,EAAY,qBAAqB,EAC9C,MACJ,CAIA,OAFe,EAAe,aAAa,EAAa,EAAU,EAAW,EAAY,CAAQ,CAErF,CAChB,CAgBA,SACI,EACA,EACA,EAC8C,CAC9C,OAAO,EAAgB,SAAS,EAAK,EAAW,CAAQ,CAC5D,CAQA,OAAO,QACH,EACA,EACA,EACyC,CAIzC,OAFe,EAAe,aAA0B,EAAK,EAAU,EAAW,EAAY,CAAQ,CAE1F,CAChB,CAKA,QACI,EACA,EACA,EACyC,CACzC,OAAO,EAAgB,QAAQ,EAAK,EAAW,CAAQ,CAC3D,CAcA,OAAO,YACH,EACA,EACkD,CAElD,IAAM,EAAgC,OAAO,GAAQ,SAAW,CAAC,CAAG,EAAI,EACpE,EAAc,GACd,EACJ,IAAK,IAAM,KAAa,EAAY,CAChC,IAAM,EAAW,EAAgB,EAAgB,CAAS,EAAG,CAAgB,EAE7E,GADA,EAAc,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ts"],"sourcesContent":["import { resolveKeyInput, templateResolver, valueConverter } from './engine';\nimport { hasFallback, isMissing } from './missing';\nimport { PrimitiveMethods } from './PrimitiveMethods';\nimport { debugWarn } from '../infra/Debug';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\nimport { recase } from '../infra/recase';\n\nimport type { ArrayOf } from '../converters';\nimport type { TemplateResolver } from '../engine/TemplateResolver';\nimport type { InferSchemaOutput, StandardSchemaV1 } from '../infra/StandardSchema';\nimport type {\n AdvancedConverterReturn,\n BuiltInConverter,\n ConditionalReturn,\n ConverterFunction,\n EnvaptConverter,\n EnvKeyInput,\n InferConverterReturnType,\n InferSpecField,\n KeyCasing,\n RecaseKey,\n RequiredSpec,\n SchemaConstraint,\n TimeFallback\n} from '../types';\n\nfunction formatKeyForError(key: EnvKeyInput): string {\n return Array.isArray(key) ? `[${key.join(', ')}]` : String(key);\n}\n\n// check after template resolution because a template can resolve to an empty string\nexport function resolveRequired(\n resolved: { key: string; value: string | undefined },\n templateResolver: TemplateResolver\n): { key: string; value: string | undefined } {\n if (resolved.value === undefined) return resolved;\n const value = templateResolver.resolveTemplate(resolved.key, resolved.value);\n return { key: resolved.key, value: isMissing(value) ? undefined : value };\n}\n\nexport class AdvancedMethods extends PrimitiveMethods {\n /**\n * Get an environment variable using a built-in converter.\n *\n * Supports both scalar tokens (e.g. `Converters.Number`) and `ArrayOf<...>` tokens\n * produced by `Converters.array(...)`. The key can be a single name or an ordered list.\n * The first defined value wins.\n * @see {@link https://envapt.materwelon.dev/docs/envapter#converters}\n * @see {@link https://envapt.materwelon.dev/docs/converters#custom-converters}\n */\n // TypeScript uses the first overload that matches. Keep 'time' above the generic one.\n static getUsing<TFallback extends TimeFallback | undefined = undefined>(\n key: EnvKeyInput,\n converter: 'time',\n fallback?: TFallback\n ): ConditionalReturn<number, TFallback>;\n static getUsing<TConverter extends BuiltInConverter | ArrayOf, TFallback = undefined>(\n key: EnvKeyInput,\n converter: TConverter,\n fallback?: TFallback\n ): AdvancedConverterReturn<TConverter, TFallback>;\n static getUsing<TReturn>(key: EnvKeyInput, converter: BuiltInConverter | ArrayOf, fallback?: TReturn): TReturn;\n static getUsing<TConverter extends BuiltInConverter | ArrayOf, TFallback = undefined>(\n key: EnvKeyInput,\n converter: TConverter,\n fallback?: TFallback\n ): AdvancedConverterReturn<TConverter, TFallback> {\n const { key: resolvedKey, value } = resolveKeyInput(key);\n\n // a time fallback can be a string that still needs converting to a number\n if (isMissing(value) && !hasFallback(fallback)) {\n debugWarn(`${resolvedKey} is missing or empty`);\n return undefined as AdvancedConverterReturn<TConverter, TFallback>;\n }\n\n const result = valueConverter.convertValue(resolvedKey, fallback, converter, hasFallback(fallback));\n\n return result as AdvancedConverterReturn<TConverter, TFallback>;\n }\n\n /**\n * @see {@link AdvancedMethods.getUsing}\n */\n getUsing<TFallback extends TimeFallback | undefined = undefined>(\n key: EnvKeyInput,\n converter: 'time',\n fallback?: TFallback\n ): ConditionalReturn<number, TFallback>;\n getUsing<TConverter extends BuiltInConverter | ArrayOf, TFallback = undefined>(\n key: EnvKeyInput,\n converter: TConverter,\n fallback?: TFallback\n ): AdvancedConverterReturn<TConverter, TFallback>;\n getUsing<TReturn>(key: EnvKeyInput, converter: BuiltInConverter | ArrayOf, fallback?: TReturn): TReturn;\n getUsing<TConverter extends BuiltInConverter | ArrayOf, TFallback = undefined>(\n key: EnvKeyInput,\n converter: TConverter,\n fallback?: TFallback\n ): AdvancedConverterReturn<TConverter, TFallback> {\n return AdvancedMethods.getUsing(key, converter, fallback);\n }\n\n /**\n * Get an environment variable using a custom converter function.\n * Accepts a single key or an ordered list for automatic fallback.\n * @see {@link https://envapt.materwelon.dev/docs/envapter#converters}\n * @see {@link https://envapt.materwelon.dev/docs/converters#custom-converters}\n */\n static getWith<TReturnType, TFallback extends TReturnType | undefined = undefined>(\n key: EnvKeyInput,\n converter: ConverterFunction<TReturnType>,\n fallback?: TFallback\n ): ConditionalReturn<TReturnType, TFallback> {\n // run the custom converter even on a missing value, with raw as undefined\n const result = valueConverter.convertValue<TReturnType>(key, fallback, converter, hasFallback(fallback));\n\n return result as ConditionalReturn<TReturnType, TFallback>;\n }\n\n /**\n * @see {@link AdvancedMethods.getWith}\n */\n getWith<TReturnType, TFallback extends TReturnType | undefined = undefined>(\n key: EnvKeyInput,\n converter: ConverterFunction<TReturnType>,\n fallback?: TFallback\n ): ConditionalReturn<TReturnType, TFallback> {\n return AdvancedMethods.getWith(key, converter, fallback);\n }\n\n /**\n * Read a required environment variable and convert it, throwing `MissingEnvValue` when the value\n * is missing or empty. Returns the non-undefined converter output. Accepts a built-in or `ArrayOf`\n * token, or a custom parser function. The key can be a single name or an ordered list.\n * @see {@link https://envapt.materwelon.dev/docs/envapter#fail-fast-on-missing-values}\n * @see {@link https://envapt.materwelon.dev/docs/converters#require-a-converted-value}\n */\n static getRequired<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n converter: TConverter\n ): InferConverterReturnType<TConverter>;\n static getRequired<TReturnType>(key: EnvKeyInput, converter: ConverterFunction<TReturnType, string>): TReturnType;\n static getRequired<TConverter extends BuiltInConverter | ArrayOf, TReturnType>(\n key: EnvKeyInput,\n converter: TConverter | ConverterFunction<TReturnType, string>\n ): InferConverterReturnType<TConverter> | TReturnType {\n // an empty value falls through to the next key\n const candidates: readonly string[] = typeof key === 'string' ? [key] : key;\n let resolvedKey = '';\n let value: string | undefined;\n for (const candidate of candidates) {\n const resolved = resolveRequired(resolveKeyInput(candidate), templateResolver);\n resolvedKey = resolved.key;\n if (resolved.value !== undefined) {\n value = resolved.value;\n break;\n }\n }\n if (value === undefined) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Required environment variable \"${formatKeyForError(key)}\" is missing or empty.`\n );\n }\n // the string-only parser is safe to widen because the value is present\n const result = valueConverter.convertValue<TReturnType>(\n resolvedKey,\n undefined,\n converter as EnvaptConverter<TReturnType>,\n false\n );\n // a built-in returns undefined when it cannot convert, and a custom converter can return null\n if (result === undefined || result === null) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Required environment variable \"${formatKeyForError(key)}\" is present but could not be converted.`\n );\n }\n return result;\n }\n\n /**\n * @see {@link AdvancedMethods.getRequired}\n */\n getRequired<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n converter: TConverter\n ): InferConverterReturnType<TConverter>;\n getRequired<TReturnType>(key: EnvKeyInput, converter: ConverterFunction<TReturnType, string>): TReturnType;\n getRequired<TConverter extends BuiltInConverter | ArrayOf, TReturnType>(\n key: EnvKeyInput,\n converter: TConverter | ConverterFunction<TReturnType, string>\n ): InferConverterReturnType<TConverter> | TReturnType {\n return AdvancedMethods.getRequired(key, converter as ConverterFunction<TReturnType, string>);\n }\n\n /**\n * Read a group of required environment variables in one call. Each key in `spec` maps to a\n * converter (a token, an `array()` token, or a custom parser), and the returned record holds\n * every converted value, all non-undefined. Collects every missing or empty key and throws one\n * `MissingEnvValue` listing them all. Pass a `casing` (`'camelCase'`, `'PascalCase'`, or\n * `'kebab-case'`) to rename the record keys. The rename splits each key on underscores, as in\n * SCREAMING_SNAKE env-var names. With no casing the keys stay as-is.\n * @see {@link https://envapt.materwelon.dev/docs/envapter#fail-fast-on-missing-values}\n * @see {@link https://envapt.materwelon.dev/docs/converters#require-a-converted-value}\n */\n static getRequiredAll<Spec extends RequiredSpec, Casing extends KeyCasing | undefined = undefined>(\n spec: Spec,\n casing?: Casing\n ): { [K in keyof Spec as RecaseKey<K & string, Casing>]: InferSpecField<Spec[K]> } {\n const keys = Object.keys(spec);\n const missing = keys.filter(\n (key) => resolveRequired(resolveKeyInput(key), templateResolver).value === undefined\n );\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Missing required environment variables: ${missing.join(', ')}.`\n );\n }\n\n const result: Record<string, unknown> = {};\n for (const key of keys) {\n // safe to widen because every value is present by now\n const converted = valueConverter.convertValue<unknown>(\n key,\n undefined,\n spec[key] as EnvaptConverter<unknown>,\n false\n );\n if (converted === undefined || converted === null) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Required environment variable \"${key}\" is present but could not be converted.`\n );\n }\n result[recase(key, casing)] = converted;\n }\n return result as { [K in keyof Spec as RecaseKey<K & string, Casing>]: InferSpecField<Spec[K]> };\n }\n\n /**\n * @see {@link AdvancedMethods.getRequiredAll}\n */\n getRequiredAll<Spec extends RequiredSpec, Casing extends KeyCasing | undefined = undefined>(\n spec: Spec,\n casing?: Casing\n ): { [K in keyof Spec as RecaseKey<K & string, Casing>]: InferSpecField<Spec[K]> } {\n return AdvancedMethods.getRequiredAll(spec, casing);\n }\n\n /**\n * Validate an environment variable through a {@link StandardSchemaV1}-conformant schema\n * (zod, valibot, arktype, etc). Throws `MissingEnvValue` if the env value is absent and\n * no fallback is provided. When the value is missing, the fallback is returned as-is and does\n * not pass through the schema.\n *\n * Synchronous schemas only. A `validate` that returns a Promise throws `InvalidUserDefinedConfig`.\n *\n * @example\n * ```ts\n * import { z } from 'zod';\n * const port = Envapter.parse('PORT', z.coerce.number().min(1024).max(65535), 3000);\n * ```\n * @see {@link https://envapt.materwelon.dev/docs/standard-schema#any-conformant-validator-or-none}\n */\n static parse<Schema extends StandardSchemaV1>(\n key: EnvKeyInput,\n schema: SchemaConstraint<Schema>,\n fallback?: InferSchemaOutput<Schema>\n ): InferSchemaOutput<Schema> {\n // SchemaConstraint rejects async schemas at compile time\n const result = valueConverter.convertWithSchema(\n key,\n schema as unknown as StandardSchemaV1,\n fallback,\n hasFallback(fallback)\n );\n return result;\n }\n\n /**\n * @see {@link AdvancedMethods.parse}\n */\n parse<Schema extends StandardSchemaV1>(\n key: EnvKeyInput,\n schema: SchemaConstraint<Schema>,\n fallback?: InferSchemaOutput<Schema>\n ): InferSchemaOutput<Schema> {\n const result = valueConverter.convertWithSchema(\n key,\n schema as unknown as StandardSchemaV1,\n fallback,\n hasFallback(fallback)\n );\n return result;\n }\n}\n"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AEN,kCAAkC,EAAkB,CAAG,EAAE,uBAC7D,EAGJ,IAAM,EAAS,EAAe,aAC1B,EACA,IAAA,GACA,EACA,EACJ,EAEA,GAAI,GAAmC,KACnC,MAAM,IAAI,EAAA,IAEN,kCAAkC,EAAkB,CAAG,EAAE,yCAC7D,EAEJ,OAAO,CACX,CAUA,YACI,EACA,EACkD,CAClD,OAAO,EAAgB,YAAY,EAAK,CAAmD,CAC/F,CAYA,OAAO,eACH,EACA,EAC+E,CAC/E,IAAM,EAAO,OAAO,KAAK,CAAI,EACvB,EAAU,EAAK,OAChB,GAAQ,EAAgB,EAAgB,CAAG,EAAG,CAAgB,CAAC,CAAC,QAAU,IAAA,EAC/E,EACA,GAAI,EAAQ,OAAS,EACjB,MAAM,IAAI,EAAA,IAEN,2CAA2C,EAAQ,KAAK,IAAI,EAAE,EAClE,EAGJ,IAAM,EAAkC,CAAC,EACzC,IAAK,IAAM,KAAO,EAAM,CAEpB,IAAM,EAAY,EAAe,aAC7B,EACA,IAAA,GACA,EAAK,GACL,EACJ,EACA,GAAI,GAAyC,KACzC,MAAM,IAAI,EAAA,IAEN,kCAAkC,EAAI,yCAC1C,EAEJ,EAAO,EAAO,EAAK,CAAM,GAAK,CAClC,CACA,OAAO,CACX,CAKA,eACI,EACA,EAC+E,CAC/E,OAAO,EAAgB,eAAe,EAAM,CAAM,CACtD,CAiBA,OAAO,MACH,EACA,EACA,EACyB,CAQzB,OANe,EAAe,kBAC1B,EACA,EACA,EACA,EAAY,CAAQ,CAEZ,CAChB,CAKA,MACI,EACA,EACA,EACyB,CAOzB,OANe,EAAe,kBAC1B,EACA,EACA,EACA,EAAY,CAAQ,CAEZ,CAChB,CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"EnvapterBase.cjs","names":["state","getDebugLevel","cache","normalizeSource","resolveKeyInput"],"sources":["../../../src/core/EnvapterBase.ts"],"sourcesContent":["import { ensureLoaded, mirrorToProcessEnv, refreshCache, resolveKeyInput } from './engine';\nimport { cache, state } from './state';\nimport { Validator } from '../engine/Validators';\nimport { getDebugLevel, setDebugLevel } from '../infra/Debug';\nimport { bindRuntimeFromSource } from '../infra/runtime';\nimport { normalizeSource } from '../sources/normalizeSource';\n\nimport type { DebugLevel } from '../infra/Debug';\nimport type { EnvKeyInput, FileApiMode, Source } from '../types';\n\n/** @internal */\nexport abstract class EnvapterBase {\n /**\n * Enable or disable strict mode. Default `false`. Setting refreshes the cache so\n * previously-cached converted values get re-evaluated under the new rule.\n * @see {@link https://envapt.materwelon.dev/docs/strict-mode#what-strict-mode-changes}\n */\n static set strict(value: boolean) {\n state.strict = value;\n refreshCache();\n }\n\n static get strict(): boolean {\n return state.strict;\n }\n\n /**\n * Set the debug log level. Defaults to `silent`. When unset, reads `ENVAPT_DEBUG` from the\n * bound source on first access. The setter overrides any env-var value. Output goes to stderr\n * on Node (the console elsewhere), prefixed with `[envapt]`.\n * @see {@link https://envapt.materwelon.dev/docs/configuration#debug-logging}\n */\n static set debug(level: DebugLevel) {\n setDebugLevel(level);\n }\n\n static get debug(): DebugLevel {\n return getDebugLevel();\n }\n\n /**\n * Opt-in mirror of dotenv-loaded keys back to `process.env`. Default `false`.\n *\n * Only keys the loader actually wrote are mirrored, so collision behavior follows\n * `envFileOptions.override`: with the default `false`, pre-existing `process.env` values\n * are preserved. With `true`, the file value wins in both the cache and the mirror.\n *\n * Flipping `false → true` mirrors the existing tracked delta immediately (no cache\n * refresh). Flipping `true → false` is one-way: previously mirrored keys remain in\n * `process.env` until the process exits.\n * @see {@link https://envapt.materwelon.dev/docs/configuration#mirroring-to-processenv}\n */\n static set syncProcessEnv(value: boolean) {\n Validator.validateSyncProcessEnv(value);\n const previous = state.syncProcessEnv;\n state.syncProcessEnv = value;\n if (!previous && value && cache.size > 0) mirrorToProcessEnv();\n }\n\n static get syncProcessEnv(): boolean {\n return state.syncProcessEnv;\n }\n\n /**\n * On the portable build, this controls the filesystem-only config APIs (`envPaths`, `baseDir`,\n * `envFileOptions`, `configureProfiles`, `resetProfiles`). `'warn'` (the default) warns once and\n * no-ops, `'throw'` throws {@link EnvaptError} `FileApiUnsupported`. The node build runs these\n * APIs normally and this value has no effect there.\n * @see {@link https://envapt.materwelon.dev/docs/compatibility#binding-by-runtime}\n */\n static set fileApiMode(mode: FileApiMode) {\n Validator.validateFileApiMode(mode);\n // no refreshCache, this only gates the portable stubs.\n state.fileApiMode = mode;\n }\n\n static get fileApiMode(): FileApiMode {\n return state.fileApiMode;\n }\n\n /**\n * Eagerly load the `.env` cascade now instead of lazily on the first read. Idempotent: a no-op\n * once the cache is built. Useful before mirroring to `process.env` (see {@link syncProcessEnv}),\n * which is what the `envapt/config` side-effect entry does.\n * @see {@link https://envapt.materwelon.dev/docs/configuration#which-files-load}\n */\n static load(): void {\n ensureLoaded();\n }\n\n /**\n * Bind the environment {@link Source}. On Node the entry binds {@link FileSource} for you\n * (a `process.env` snapshot plus the `.env` cascade). On the browser or Workers, pass a\n * `PortableSource` (or any `Source`) before reading. Pass a `(key) => string | undefined` reader for\n * a source that reads one key at a time and cannot list its keys. Clears and rebuilds the cache.\n * @see {@link https://envapt.materwelon.dev/docs/sources#the-providers}\n */\n static useSource(source: Source | ((key: string) => string | undefined)): void {\n const resolved = normalizeSource(source);\n state.source = resolved;\n bindRuntimeFromSource(resolved);\n refreshCache();\n }\n\n /**\n * Read an environment variable as its raw string, skipping parsing and conversion.\n * @see {@link https://envapt.materwelon.dev/docs/envapter#raw-values}\n */\n getRaw(key: EnvKeyInput): string | undefined {\n return resolveKeyInput(key).value;\n }\n}\n"],"mappings":"6MAWA,IAAsB,EAAtB,KAAmC,CAM/B,WAAW,OAAO,EAAgB,CAC9B,EAAA,MAAM,OAAS,EACf,EAAA,aAAa,CACjB,CAEA,WAAW,QAAkB,CACzB,OAAOA,EAAAA,MAAM,MACjB,CAQA,WAAW,MAAM,EAAmB,CAChC,EAAA,cAAc,CAAK,CACvB,CAEA,WAAW,OAAoB,CAC3B,OAAOC,EAAAA,cAAc,CACzB,CAcA,WAAW,eAAe,EAAgB,CACtC,EAAA,UAAU,uBAAuB,CAAK,EACtC,IAAM,EAAWD,EAAAA,MAAM,eACvB,EAAA,MAAM,eAAiB,EACnB,CAAC,GAAY,GAASE,EAAAA,MAAM,KAAO,GAAG,EAAA,mBAAmB,CACjE,CAEA,WAAW,gBAA0B,CACjC,OAAOF,EAAAA,MAAM,cACjB,CASA,WAAW,YAAY,EAAmB,CACtC,EAAA,UAAU,oBAAoB,CAAI,EAElC,EAAA,MAAM,YAAc,CACxB,CAEA,WAAW,aAA2B,CAClC,OAAOA,EAAAA,MAAM,WACjB,CAQA,OAAO,MAAa,CAChB,EAAA,aAAa,CACjB,CASA,OAAO,UAAU,EAA8D,CAC3E,IAAM,EAAWG,EAAAA,gBAAgB,CAAM,EACvC,EAAA,MAAM,OAAS,EACf,EAAA,sBAAsB,CAAQ,EAC9B,EAAA,aAAa,CACjB,CAMA,OAAO,EAAsC,CACzC,OAAOC,EAAAA,gBAAgB,CAAG,CAAC,CAAC,KAChC,CACJ"}
1
+ {"version":3,"file":"EnvapterBase.cjs","names":["state","getDebugLevel","cache","normalizeSource","resolveKeyInput"],"sources":["../../../src/core/EnvapterBase.ts"],"sourcesContent":["import { ensureLoaded, mirrorToProcessEnv, refreshCache, resolveKeyInput } from './engine';\nimport { cache, state } from './state';\nimport { Validator } from '../engine/Validators';\nimport { getDebugLevel, setDebugLevel } from '../infra/Debug';\nimport { bindRuntimeFromSource } from '../infra/runtime';\nimport { normalizeSource } from '../sources/normalizeSource';\n\nimport type { DebugLevel } from '../infra/Debug';\nimport type { EnvKeyInput, FileApiMode, Source } from '../types';\n\nexport abstract class EnvapterBase {\n /**\n * Enable or disable strict mode. Default `false`. Setting it clears and rebuilds the cache.\n * @see {@link https://envapt.materwelon.dev/docs/strict-mode#what-strict-mode-changes}\n */\n static set strict(value: boolean) {\n state.strict = value;\n refreshCache();\n }\n\n static get strict(): boolean {\n return state.strict;\n }\n\n /**\n * Set the debug log level. Defaults to `silent`. When unset, reads `ENVAPT_DEBUG` from the\n * bound source on first access. The setter overrides any env-var value. Output goes to stderr\n * on Node (the console elsewhere), prefixed with `[envapt]`.\n * @see {@link https://envapt.materwelon.dev/docs/configuration#debug-logging}\n */\n static set debug(level: DebugLevel) {\n setDebugLevel(level);\n }\n\n static get debug(): DebugLevel {\n return getDebugLevel();\n }\n\n /**\n * Opt-in mirror of dotenv-loaded keys back to `process.env`. Default `false`.\n *\n * `envFileOptions.override` controls collisions because only keys the loader wrote are mirrored.\n * With the default `false`, existing `process.env` values stay. With `true`, the file value\n * wins in both the cache and the mirror.\n *\n * Flipping `false → true` mirrors the loaded keys immediately without a cache refresh.\n * Flipping `true → false` does not remove anything. Mirrored keys stay in `process.env`\n * until the process exits.\n * @see {@link https://envapt.materwelon.dev/docs/configuration#mirroring-to-processenv}\n */\n static set syncProcessEnv(value: boolean) {\n Validator.validateSyncProcessEnv(value);\n const previous = state.syncProcessEnv;\n state.syncProcessEnv = value;\n if (!previous && value && cache.size > 0) mirrorToProcessEnv();\n }\n\n static get syncProcessEnv(): boolean {\n return state.syncProcessEnv;\n }\n\n /**\n * On the portable build, this controls the filesystem-only config APIs (`envPaths`, `baseDir`,\n * `envFileOptions`, `configureProfiles`, `resetProfiles`). `'warn'` (the default) warns once and\n * no-ops. `'throw'` throws {@link EnvaptError} `FileApiUnsupported`. The node build runs these\n * APIs normally and this value has no effect there.\n * @see {@link https://envapt.materwelon.dev/docs/compatibility#binding-by-runtime}\n */\n static set fileApiMode(mode: FileApiMode) {\n Validator.validateFileApiMode(mode);\n // only the portable stubs read this\n state.fileApiMode = mode;\n }\n\n static get fileApiMode(): FileApiMode {\n return state.fileApiMode;\n }\n\n /**\n * Eagerly load the `.env` cascade now instead of lazily on the first read. Idempotent: a no-op\n * once the cache is built. Useful before mirroring to `process.env` (see {@link syncProcessEnv}),\n * which is what the `envapt/config` side-effect entry does.\n * @see {@link https://envapt.materwelon.dev/docs/configuration#which-files-load}\n */\n static load(): void {\n ensureLoaded();\n }\n\n /**\n * Bind the environment {@link Source}. On Node the entry binds {@link FileSource} for you\n * (a `process.env` snapshot plus the `.env` cascade). On the browser or Workers, pass a\n * `PortableSource` (or any `Source`) before reading. Pass a `(key) => string | undefined` reader for\n * a source that reads one key at a time and cannot list its keys. Clears and rebuilds the cache.\n * @see {@link https://envapt.materwelon.dev/docs/sources#the-providers}\n */\n static useSource(source: Source | ((key: string) => string | undefined)): void {\n const resolved = normalizeSource(source);\n state.source = resolved;\n bindRuntimeFromSource(resolved);\n refreshCache();\n }\n\n /**\n * Read an environment variable as its raw string, skipping parsing and conversion.\n * @see {@link https://envapt.materwelon.dev/docs/envapter#raw-values}\n */\n getRaw(key: EnvKeyInput): string | undefined {\n return resolveKeyInput(key).value;\n }\n}\n"],"mappings":"6MAUA,IAAsB,EAAtB,KAAmC,CAK/B,WAAW,OAAO,EAAgB,CAC9B,EAAA,MAAM,OAAS,EACf,EAAA,aAAa,CACjB,CAEA,WAAW,QAAkB,CACzB,OAAOA,EAAAA,MAAM,MACjB,CAQA,WAAW,MAAM,EAAmB,CAChC,EAAA,cAAc,CAAK,CACvB,CAEA,WAAW,OAAoB,CAC3B,OAAOC,EAAAA,cAAc,CACzB,CAcA,WAAW,eAAe,EAAgB,CACtC,EAAA,UAAU,uBAAuB,CAAK,EACtC,IAAM,EAAWD,EAAAA,MAAM,eACvB,EAAA,MAAM,eAAiB,EACnB,CAAC,GAAY,GAASE,EAAAA,MAAM,KAAO,GAAG,EAAA,mBAAmB,CACjE,CAEA,WAAW,gBAA0B,CACjC,OAAOF,EAAAA,MAAM,cACjB,CASA,WAAW,YAAY,EAAmB,CACtC,EAAA,UAAU,oBAAoB,CAAI,EAElC,EAAA,MAAM,YAAc,CACxB,CAEA,WAAW,aAA2B,CAClC,OAAOA,EAAAA,MAAM,WACjB,CAQA,OAAO,MAAa,CAChB,EAAA,aAAa,CACjB,CASA,OAAO,UAAU,EAA8D,CAC3E,IAAM,EAAWG,EAAAA,gBAAgB,CAAM,EACvC,EAAA,MAAM,OAAS,EACf,EAAA,sBAAsB,CAAQ,EAC9B,EAAA,aAAa,CACjB,CAMA,OAAO,EAAsC,CACzC,OAAOC,EAAAA,gBAAgB,CAAG,CAAC,CAAC,KAChC,CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"EnvapterBase.mjs","names":[],"sources":["../../../src/core/EnvapterBase.ts"],"sourcesContent":["import { ensureLoaded, mirrorToProcessEnv, refreshCache, resolveKeyInput } from './engine';\nimport { cache, state } from './state';\nimport { Validator } from '../engine/Validators';\nimport { getDebugLevel, setDebugLevel } from '../infra/Debug';\nimport { bindRuntimeFromSource } from '../infra/runtime';\nimport { normalizeSource } from '../sources/normalizeSource';\n\nimport type { DebugLevel } from '../infra/Debug';\nimport type { EnvKeyInput, FileApiMode, Source } from '../types';\n\n/** @internal */\nexport abstract class EnvapterBase {\n /**\n * Enable or disable strict mode. Default `false`. Setting refreshes the cache so\n * previously-cached converted values get re-evaluated under the new rule.\n * @see {@link https://envapt.materwelon.dev/docs/strict-mode#what-strict-mode-changes}\n */\n static set strict(value: boolean) {\n state.strict = value;\n refreshCache();\n }\n\n static get strict(): boolean {\n return state.strict;\n }\n\n /**\n * Set the debug log level. Defaults to `silent`. When unset, reads `ENVAPT_DEBUG` from the\n * bound source on first access. The setter overrides any env-var value. Output goes to stderr\n * on Node (the console elsewhere), prefixed with `[envapt]`.\n * @see {@link https://envapt.materwelon.dev/docs/configuration#debug-logging}\n */\n static set debug(level: DebugLevel) {\n setDebugLevel(level);\n }\n\n static get debug(): DebugLevel {\n return getDebugLevel();\n }\n\n /**\n * Opt-in mirror of dotenv-loaded keys back to `process.env`. Default `false`.\n *\n * Only keys the loader actually wrote are mirrored, so collision behavior follows\n * `envFileOptions.override`: with the default `false`, pre-existing `process.env` values\n * are preserved. With `true`, the file value wins in both the cache and the mirror.\n *\n * Flipping `false → true` mirrors the existing tracked delta immediately (no cache\n * refresh). Flipping `true → false` is one-way: previously mirrored keys remain in\n * `process.env` until the process exits.\n * @see {@link https://envapt.materwelon.dev/docs/configuration#mirroring-to-processenv}\n */\n static set syncProcessEnv(value: boolean) {\n Validator.validateSyncProcessEnv(value);\n const previous = state.syncProcessEnv;\n state.syncProcessEnv = value;\n if (!previous && value && cache.size > 0) mirrorToProcessEnv();\n }\n\n static get syncProcessEnv(): boolean {\n return state.syncProcessEnv;\n }\n\n /**\n * On the portable build, this controls the filesystem-only config APIs (`envPaths`, `baseDir`,\n * `envFileOptions`, `configureProfiles`, `resetProfiles`). `'warn'` (the default) warns once and\n * no-ops, `'throw'` throws {@link EnvaptError} `FileApiUnsupported`. The node build runs these\n * APIs normally and this value has no effect there.\n * @see {@link https://envapt.materwelon.dev/docs/compatibility#binding-by-runtime}\n */\n static set fileApiMode(mode: FileApiMode) {\n Validator.validateFileApiMode(mode);\n // no refreshCache, this only gates the portable stubs.\n state.fileApiMode = mode;\n }\n\n static get fileApiMode(): FileApiMode {\n return state.fileApiMode;\n }\n\n /**\n * Eagerly load the `.env` cascade now instead of lazily on the first read. Idempotent: a no-op\n * once the cache is built. Useful before mirroring to `process.env` (see {@link syncProcessEnv}),\n * which is what the `envapt/config` side-effect entry does.\n * @see {@link https://envapt.materwelon.dev/docs/configuration#which-files-load}\n */\n static load(): void {\n ensureLoaded();\n }\n\n /**\n * Bind the environment {@link Source}. On Node the entry binds {@link FileSource} for you\n * (a `process.env` snapshot plus the `.env` cascade). On the browser or Workers, pass a\n * `PortableSource` (or any `Source`) before reading. Pass a `(key) => string | undefined` reader for\n * a source that reads one key at a time and cannot list its keys. Clears and rebuilds the cache.\n * @see {@link https://envapt.materwelon.dev/docs/sources#the-providers}\n */\n static useSource(source: Source | ((key: string) => string | undefined)): void {\n const resolved = normalizeSource(source);\n state.source = resolved;\n bindRuntimeFromSource(resolved);\n refreshCache();\n }\n\n /**\n * Read an environment variable as its raw string, skipping parsing and conversion.\n * @see {@link https://envapt.materwelon.dev/docs/envapter#raw-values}\n */\n getRaw(key: EnvKeyInput): string | undefined {\n return resolveKeyInput(key).value;\n }\n}\n"],"mappings":"mZAWA,IAAsB,EAAtB,KAAmC,CAM/B,WAAW,OAAO,EAAgB,CAC9B,EAAM,OAAS,EACf,EAAa,CACjB,CAEA,WAAW,QAAkB,CACzB,OAAO,EAAM,MACjB,CAQA,WAAW,MAAM,EAAmB,CAChC,EAAc,CAAK,CACvB,CAEA,WAAW,OAAoB,CAC3B,OAAO,EAAc,CACzB,CAcA,WAAW,eAAe,EAAgB,CACtC,EAAU,uBAAuB,CAAK,EACtC,IAAM,EAAW,EAAM,eACvB,EAAM,eAAiB,EACnB,CAAC,GAAY,GAAS,EAAM,KAAO,GAAG,EAAmB,CACjE,CAEA,WAAW,gBAA0B,CACjC,OAAO,EAAM,cACjB,CASA,WAAW,YAAY,EAAmB,CACtC,EAAU,oBAAoB,CAAI,EAElC,EAAM,YAAc,CACxB,CAEA,WAAW,aAA2B,CAClC,OAAO,EAAM,WACjB,CAQA,OAAO,MAAa,CAChB,EAAa,CACjB,CASA,OAAO,UAAU,EAA8D,CAC3E,IAAM,EAAW,EAAgB,CAAM,EACvC,EAAM,OAAS,EACf,EAAsB,CAAQ,EAC9B,EAAa,CACjB,CAMA,OAAO,EAAsC,CACzC,OAAO,EAAgB,CAAG,CAAC,CAAC,KAChC,CACJ"}
1
+ {"version":3,"file":"EnvapterBase.mjs","names":[],"sources":["../../../src/core/EnvapterBase.ts"],"sourcesContent":["import { ensureLoaded, mirrorToProcessEnv, refreshCache, resolveKeyInput } from './engine';\nimport { cache, state } from './state';\nimport { Validator } from '../engine/Validators';\nimport { getDebugLevel, setDebugLevel } from '../infra/Debug';\nimport { bindRuntimeFromSource } from '../infra/runtime';\nimport { normalizeSource } from '../sources/normalizeSource';\n\nimport type { DebugLevel } from '../infra/Debug';\nimport type { EnvKeyInput, FileApiMode, Source } from '../types';\n\nexport abstract class EnvapterBase {\n /**\n * Enable or disable strict mode. Default `false`. Setting it clears and rebuilds the cache.\n * @see {@link https://envapt.materwelon.dev/docs/strict-mode#what-strict-mode-changes}\n */\n static set strict(value: boolean) {\n state.strict = value;\n refreshCache();\n }\n\n static get strict(): boolean {\n return state.strict;\n }\n\n /**\n * Set the debug log level. Defaults to `silent`. When unset, reads `ENVAPT_DEBUG` from the\n * bound source on first access. The setter overrides any env-var value. Output goes to stderr\n * on Node (the console elsewhere), prefixed with `[envapt]`.\n * @see {@link https://envapt.materwelon.dev/docs/configuration#debug-logging}\n */\n static set debug(level: DebugLevel) {\n setDebugLevel(level);\n }\n\n static get debug(): DebugLevel {\n return getDebugLevel();\n }\n\n /**\n * Opt-in mirror of dotenv-loaded keys back to `process.env`. Default `false`.\n *\n * `envFileOptions.override` controls collisions because only keys the loader wrote are mirrored.\n * With the default `false`, existing `process.env` values stay. With `true`, the file value\n * wins in both the cache and the mirror.\n *\n * Flipping `false → true` mirrors the loaded keys immediately without a cache refresh.\n * Flipping `true → false` does not remove anything. Mirrored keys stay in `process.env`\n * until the process exits.\n * @see {@link https://envapt.materwelon.dev/docs/configuration#mirroring-to-processenv}\n */\n static set syncProcessEnv(value: boolean) {\n Validator.validateSyncProcessEnv(value);\n const previous = state.syncProcessEnv;\n state.syncProcessEnv = value;\n if (!previous && value && cache.size > 0) mirrorToProcessEnv();\n }\n\n static get syncProcessEnv(): boolean {\n return state.syncProcessEnv;\n }\n\n /**\n * On the portable build, this controls the filesystem-only config APIs (`envPaths`, `baseDir`,\n * `envFileOptions`, `configureProfiles`, `resetProfiles`). `'warn'` (the default) warns once and\n * no-ops. `'throw'` throws {@link EnvaptError} `FileApiUnsupported`. The node build runs these\n * APIs normally and this value has no effect there.\n * @see {@link https://envapt.materwelon.dev/docs/compatibility#binding-by-runtime}\n */\n static set fileApiMode(mode: FileApiMode) {\n Validator.validateFileApiMode(mode);\n // only the portable stubs read this\n state.fileApiMode = mode;\n }\n\n static get fileApiMode(): FileApiMode {\n return state.fileApiMode;\n }\n\n /**\n * Eagerly load the `.env` cascade now instead of lazily on the first read. Idempotent: a no-op\n * once the cache is built. Useful before mirroring to `process.env` (see {@link syncProcessEnv}),\n * which is what the `envapt/config` side-effect entry does.\n * @see {@link https://envapt.materwelon.dev/docs/configuration#which-files-load}\n */\n static load(): void {\n ensureLoaded();\n }\n\n /**\n * Bind the environment {@link Source}. On Node the entry binds {@link FileSource} for you\n * (a `process.env` snapshot plus the `.env` cascade). On the browser or Workers, pass a\n * `PortableSource` (or any `Source`) before reading. Pass a `(key) => string | undefined` reader for\n * a source that reads one key at a time and cannot list its keys. Clears and rebuilds the cache.\n * @see {@link https://envapt.materwelon.dev/docs/sources#the-providers}\n */\n static useSource(source: Source | ((key: string) => string | undefined)): void {\n const resolved = normalizeSource(source);\n state.source = resolved;\n bindRuntimeFromSource(resolved);\n refreshCache();\n }\n\n /**\n * Read an environment variable as its raw string, skipping parsing and conversion.\n * @see {@link https://envapt.materwelon.dev/docs/envapter#raw-values}\n */\n getRaw(key: EnvKeyInput): string | undefined {\n return resolveKeyInput(key).value;\n }\n}\n"],"mappings":"mZAUA,IAAsB,EAAtB,KAAmC,CAK/B,WAAW,OAAO,EAAgB,CAC9B,EAAM,OAAS,EACf,EAAa,CACjB,CAEA,WAAW,QAAkB,CACzB,OAAO,EAAM,MACjB,CAQA,WAAW,MAAM,EAAmB,CAChC,EAAc,CAAK,CACvB,CAEA,WAAW,OAAoB,CAC3B,OAAO,EAAc,CACzB,CAcA,WAAW,eAAe,EAAgB,CACtC,EAAU,uBAAuB,CAAK,EACtC,IAAM,EAAW,EAAM,eACvB,EAAM,eAAiB,EACnB,CAAC,GAAY,GAAS,EAAM,KAAO,GAAG,EAAmB,CACjE,CAEA,WAAW,gBAA0B,CACjC,OAAO,EAAM,cACjB,CASA,WAAW,YAAY,EAAmB,CACtC,EAAU,oBAAoB,CAAI,EAElC,EAAM,YAAc,CACxB,CAEA,WAAW,aAA2B,CAClC,OAAO,EAAM,WACjB,CAQA,OAAO,MAAa,CAChB,EAAa,CACjB,CASA,OAAO,UAAU,EAA8D,CAC3E,IAAM,EAAW,EAAgB,CAAM,EACvC,EAAM,OAAS,EACf,EAAsB,CAAQ,EAC9B,EAAa,CACjB,CAMA,OAAO,EAAsC,CACzC,OAAO,EAAgB,CAAG,CAAC,CAAC,KAChC,CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"EnvironmentMethods.cjs","names":["EnvapterBase","state"],"sources":["../../../src/core/EnvironmentMethods.ts"],"sourcesContent":["import { determineEnvironment } from './engine';\nimport { EnvapterBase } from './EnvapterBase';\nimport { Environment } from './Environment';\nimport { state } from './state';\n\n/**\n * Mixin for environment detection and checking methods\n * @internal\n */\nexport class EnvironmentMethods extends EnvapterBase {\n /**\n * Get the current application environment\n * @see {@link https://envapt.materwelon.dev/docs/environment#detecting-the-environment}\n */\n static get environment(): Environment {\n if (state.environment === undefined) {\n determineEnvironment();\n }\n return state.environment as Environment;\n }\n\n /**\n * Set the application environment. Accepts either Environment enum or string value.\n * @see {@link https://envapt.materwelon.dev/docs/environment#detecting-the-environment}\n */\n static set environment(env: string | Environment) {\n determineEnvironment(env);\n }\n\n /**\n * @see {@link EnvironmentMethods.environment}\n */\n get environment(): Environment {\n return EnvironmentMethods.environment;\n }\n\n /**\n * @see {@link EnvironmentMethods.environment}\n */\n set environment(env: string | Environment) {\n determineEnvironment(env);\n }\n\n /**\n * Check if the current environment is production\n * @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}\n */\n static get isProduction(): boolean {\n return this.environment === Environment.Production;\n }\n\n /**\n * @see {@link EnvironmentMethods.isProduction}\n */\n get isProduction(): boolean {\n return EnvironmentMethods.environment === Environment.Production;\n }\n\n /**\n * Check if the current environment is staging\n * @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}\n */\n static get isStaging(): boolean {\n return this.environment === Environment.Staging;\n }\n\n /**\n * @see {@link EnvironmentMethods.isStaging}\n */\n get isStaging(): boolean {\n return EnvironmentMethods.environment === Environment.Staging;\n }\n\n /**\n * Check if the current environment is development\n * @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}\n */\n static get isDevelopment(): boolean {\n return this.environment === Environment.Development;\n }\n\n /**\n * @see {@link EnvironmentMethods.isDevelopment}\n */\n get isDevelopment(): boolean {\n return EnvironmentMethods.environment === Environment.Development;\n }\n\n /**\n * Check if the current environment is test\n * @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}\n */\n static get isTest(): boolean {\n return this.environment === Environment.Test;\n }\n\n /**\n * @see {@link EnvironmentMethods.isTest}\n */\n get isTest(): boolean {\n return EnvironmentMethods.environment === Environment.Test;\n }\n}\n"],"mappings":"4HASA,IAAa,EAAb,MAAa,UAA2BA,EAAAA,YAAa,CAKjD,WAAW,aAA2B,CAIlC,OAHIC,EAAAA,MAAM,cAAgB,IAAA,IACtB,EAAA,qBAAqB,EAElBA,EAAAA,MAAM,WACjB,CAMA,WAAW,YAAY,EAA2B,CAC9C,EAAA,qBAAqB,CAAG,CAC5B,CAKA,IAAI,aAA2B,CAC3B,OAAO,EAAmB,WAC9B,CAKA,IAAI,YAAY,EAA2B,CACvC,EAAA,qBAAqB,CAAG,CAC5B,CAMA,WAAW,cAAwB,CAC/B,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,cAAwB,CACxB,OAAO,EAAmB,cAAA,CAC9B,CAMA,WAAW,WAAqB,CAC5B,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,WAAqB,CACrB,OAAO,EAAmB,cAAA,CAC9B,CAMA,WAAW,eAAyB,CAChC,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,eAAyB,CACzB,OAAO,EAAmB,cAAA,CAC9B,CAMA,WAAW,QAAkB,CACzB,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,QAAkB,CAClB,OAAO,EAAmB,cAAA,CAC9B,CACJ"}
1
+ {"version":3,"file":"EnvironmentMethods.cjs","names":["EnvapterBase","state"],"sources":["../../../src/core/EnvironmentMethods.ts"],"sourcesContent":["import { determineEnvironment } from './engine';\nimport { EnvapterBase } from './EnvapterBase';\nimport { Environment } from './Environment';\nimport { state } from './state';\n\nexport class EnvironmentMethods extends EnvapterBase {\n /**\n * Get the current application environment\n * @see {@link https://envapt.materwelon.dev/docs/environment#detecting-the-environment}\n */\n static get environment(): Environment {\n if (state.environment === undefined) {\n determineEnvironment();\n }\n return state.environment as Environment;\n }\n\n /**\n * Set the application environment. Accepts either Environment enum or string value.\n * @see {@link https://envapt.materwelon.dev/docs/environment#detecting-the-environment}\n */\n static set environment(env: string | Environment) {\n determineEnvironment(env);\n }\n\n /**\n * @see {@link EnvironmentMethods.environment}\n */\n get environment(): Environment {\n return EnvironmentMethods.environment;\n }\n\n /**\n * @see {@link EnvironmentMethods.environment}\n */\n set environment(env: string | Environment) {\n determineEnvironment(env);\n }\n\n /**\n * Check if the current environment is production\n * @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}\n */\n static get isProduction(): boolean {\n return this.environment === Environment.Production;\n }\n\n /**\n * @see {@link EnvironmentMethods.isProduction}\n */\n get isProduction(): boolean {\n return EnvironmentMethods.environment === Environment.Production;\n }\n\n /**\n * Check if the current environment is staging\n * @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}\n */\n static get isStaging(): boolean {\n return this.environment === Environment.Staging;\n }\n\n /**\n * @see {@link EnvironmentMethods.isStaging}\n */\n get isStaging(): boolean {\n return EnvironmentMethods.environment === Environment.Staging;\n }\n\n /**\n * Check if the current environment is development\n * @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}\n */\n static get isDevelopment(): boolean {\n return this.environment === Environment.Development;\n }\n\n /**\n * @see {@link EnvironmentMethods.isDevelopment}\n */\n get isDevelopment(): boolean {\n return EnvironmentMethods.environment === Environment.Development;\n }\n\n /**\n * Check if the current environment is test\n * @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}\n */\n static get isTest(): boolean {\n return this.environment === Environment.Test;\n }\n\n /**\n * @see {@link EnvironmentMethods.isTest}\n */\n get isTest(): boolean {\n return EnvironmentMethods.environment === Environment.Test;\n }\n}\n"],"mappings":"4HAKA,IAAa,EAAb,MAAa,UAA2BA,EAAAA,YAAa,CAKjD,WAAW,aAA2B,CAIlC,OAHIC,EAAAA,MAAM,cAAgB,IAAA,IACtB,EAAA,qBAAqB,EAElBA,EAAAA,MAAM,WACjB,CAMA,WAAW,YAAY,EAA2B,CAC9C,EAAA,qBAAqB,CAAG,CAC5B,CAKA,IAAI,aAA2B,CAC3B,OAAO,EAAmB,WAC9B,CAKA,IAAI,YAAY,EAA2B,CACvC,EAAA,qBAAqB,CAAG,CAC5B,CAMA,WAAW,cAAwB,CAC/B,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,cAAwB,CACxB,OAAO,EAAmB,cAAA,CAC9B,CAMA,WAAW,WAAqB,CAC5B,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,WAAqB,CACrB,OAAO,EAAmB,cAAA,CAC9B,CAMA,WAAW,eAAyB,CAChC,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,eAAyB,CACzB,OAAO,EAAmB,cAAA,CAC9B,CAMA,WAAW,QAAkB,CACzB,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,QAAkB,CAClB,OAAO,EAAmB,cAAA,CAC9B,CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"EnvironmentMethods.mjs","names":[],"sources":["../../../src/core/EnvironmentMethods.ts"],"sourcesContent":["import { determineEnvironment } from './engine';\nimport { EnvapterBase } from './EnvapterBase';\nimport { Environment } from './Environment';\nimport { state } from './state';\n\n/**\n * Mixin for environment detection and checking methods\n * @internal\n */\nexport class EnvironmentMethods extends EnvapterBase {\n /**\n * Get the current application environment\n * @see {@link https://envapt.materwelon.dev/docs/environment#detecting-the-environment}\n */\n static get environment(): Environment {\n if (state.environment === undefined) {\n determineEnvironment();\n }\n return state.environment as Environment;\n }\n\n /**\n * Set the application environment. Accepts either Environment enum or string value.\n * @see {@link https://envapt.materwelon.dev/docs/environment#detecting-the-environment}\n */\n static set environment(env: string | Environment) {\n determineEnvironment(env);\n }\n\n /**\n * @see {@link EnvironmentMethods.environment}\n */\n get environment(): Environment {\n return EnvironmentMethods.environment;\n }\n\n /**\n * @see {@link EnvironmentMethods.environment}\n */\n set environment(env: string | Environment) {\n determineEnvironment(env);\n }\n\n /**\n * Check if the current environment is production\n * @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}\n */\n static get isProduction(): boolean {\n return this.environment === Environment.Production;\n }\n\n /**\n * @see {@link EnvironmentMethods.isProduction}\n */\n get isProduction(): boolean {\n return EnvironmentMethods.environment === Environment.Production;\n }\n\n /**\n * Check if the current environment is staging\n * @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}\n */\n static get isStaging(): boolean {\n return this.environment === Environment.Staging;\n }\n\n /**\n * @see {@link EnvironmentMethods.isStaging}\n */\n get isStaging(): boolean {\n return EnvironmentMethods.environment === Environment.Staging;\n }\n\n /**\n * Check if the current environment is development\n * @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}\n */\n static get isDevelopment(): boolean {\n return this.environment === Environment.Development;\n }\n\n /**\n * @see {@link EnvironmentMethods.isDevelopment}\n */\n get isDevelopment(): boolean {\n return EnvironmentMethods.environment === Environment.Development;\n }\n\n /**\n * Check if the current environment is test\n * @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}\n */\n static get isTest(): boolean {\n return this.environment === Environment.Test;\n }\n\n /**\n * @see {@link EnvironmentMethods.isTest}\n */\n get isTest(): boolean {\n return EnvironmentMethods.environment === Environment.Test;\n }\n}\n"],"mappings":"oKASA,IAAa,EAAb,MAAa,UAA2B,CAAa,CAKjD,WAAW,aAA2B,CAIlC,OAHI,EAAM,cAAgB,IAAA,IACtB,EAAqB,EAElB,EAAM,WACjB,CAMA,WAAW,YAAY,EAA2B,CAC9C,EAAqB,CAAG,CAC5B,CAKA,IAAI,aAA2B,CAC3B,OAAO,EAAmB,WAC9B,CAKA,IAAI,YAAY,EAA2B,CACvC,EAAqB,CAAG,CAC5B,CAMA,WAAW,cAAwB,CAC/B,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,cAAwB,CACxB,OAAO,EAAmB,cAAA,CAC9B,CAMA,WAAW,WAAqB,CAC5B,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,WAAqB,CACrB,OAAO,EAAmB,cAAA,CAC9B,CAMA,WAAW,eAAyB,CAChC,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,eAAyB,CACzB,OAAO,EAAmB,cAAA,CAC9B,CAMA,WAAW,QAAkB,CACzB,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,QAAkB,CAClB,OAAO,EAAmB,cAAA,CAC9B,CACJ"}
1
+ {"version":3,"file":"EnvironmentMethods.mjs","names":[],"sources":["../../../src/core/EnvironmentMethods.ts"],"sourcesContent":["import { determineEnvironment } from './engine';\nimport { EnvapterBase } from './EnvapterBase';\nimport { Environment } from './Environment';\nimport { state } from './state';\n\nexport class EnvironmentMethods extends EnvapterBase {\n /**\n * Get the current application environment\n * @see {@link https://envapt.materwelon.dev/docs/environment#detecting-the-environment}\n */\n static get environment(): Environment {\n if (state.environment === undefined) {\n determineEnvironment();\n }\n return state.environment as Environment;\n }\n\n /**\n * Set the application environment. Accepts either Environment enum or string value.\n * @see {@link https://envapt.materwelon.dev/docs/environment#detecting-the-environment}\n */\n static set environment(env: string | Environment) {\n determineEnvironment(env);\n }\n\n /**\n * @see {@link EnvironmentMethods.environment}\n */\n get environment(): Environment {\n return EnvironmentMethods.environment;\n }\n\n /**\n * @see {@link EnvironmentMethods.environment}\n */\n set environment(env: string | Environment) {\n determineEnvironment(env);\n }\n\n /**\n * Check if the current environment is production\n * @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}\n */\n static get isProduction(): boolean {\n return this.environment === Environment.Production;\n }\n\n /**\n * @see {@link EnvironmentMethods.isProduction}\n */\n get isProduction(): boolean {\n return EnvironmentMethods.environment === Environment.Production;\n }\n\n /**\n * Check if the current environment is staging\n * @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}\n */\n static get isStaging(): boolean {\n return this.environment === Environment.Staging;\n }\n\n /**\n * @see {@link EnvironmentMethods.isStaging}\n */\n get isStaging(): boolean {\n return EnvironmentMethods.environment === Environment.Staging;\n }\n\n /**\n * Check if the current environment is development\n * @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}\n */\n static get isDevelopment(): boolean {\n return this.environment === Environment.Development;\n }\n\n /**\n * @see {@link EnvironmentMethods.isDevelopment}\n */\n get isDevelopment(): boolean {\n return EnvironmentMethods.environment === Environment.Development;\n }\n\n /**\n * Check if the current environment is test\n * @see {@link https://envapt.materwelon.dev/docs/environment#branching-on-the-environment}\n */\n static get isTest(): boolean {\n return this.environment === Environment.Test;\n }\n\n /**\n * @see {@link EnvironmentMethods.isTest}\n */\n get isTest(): boolean {\n return EnvironmentMethods.environment === Environment.Test;\n }\n}\n"],"mappings":"oKAKA,IAAa,EAAb,MAAa,UAA2B,CAAa,CAKjD,WAAW,aAA2B,CAIlC,OAHI,EAAM,cAAgB,IAAA,IACtB,EAAqB,EAElB,EAAM,WACjB,CAMA,WAAW,YAAY,EAA2B,CAC9C,EAAqB,CAAG,CAC5B,CAKA,IAAI,aAA2B,CAC3B,OAAO,EAAmB,WAC9B,CAKA,IAAI,YAAY,EAA2B,CACvC,EAAqB,CAAG,CAC5B,CAMA,WAAW,cAAwB,CAC/B,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,cAAwB,CACxB,OAAO,EAAmB,cAAA,CAC9B,CAMA,WAAW,WAAqB,CAC5B,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,WAAqB,CACrB,OAAO,EAAmB,cAAA,CAC9B,CAMA,WAAW,eAAyB,CAChC,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,eAAyB,CACzB,OAAO,EAAmB,cAAA,CAC9B,CAMA,WAAW,QAAkB,CACzB,OAAO,KAAK,cAAA,CAChB,CAKA,IAAI,QAAkB,CAClB,OAAO,EAAmB,cAAA,CAC9B,CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"PrimitiveMethods.cjs","names":["EnvironmentMethods","readPrimitive"],"sources":["../../../src/core/PrimitiveMethods.ts"],"sourcesContent":["import { Primitive, readPrimitive } from './engine';\nimport { EnvironmentMethods } from './EnvironmentMethods';\n\nimport type { ConditionalReturn, EnvKeyInput } from '../types';\n\n/**\n * @internal\n */\nexport class PrimitiveMethods extends EnvironmentMethods {\n /**\n * Get a string environment variable with optional fallback.\n * Supports template variable resolution using `${VAR}` syntax.\n * Accepts a single key or an ordered array of keys (first match wins).\n * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\n */\n static get<Default extends string | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<string, Default> {\n return readPrimitive(key, Primitive.String, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.get}\n */\n get<Default extends string | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<string, Default> {\n return readPrimitive(key, Primitive.String, def);\n }\n\n /**\n * Get a number environment variable with optional fallback.\n * Automatically converts string values to numbers.\n * Accepts a single key or an ordered array of keys (first match wins).\n * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\n */\n static getNumber<Default extends number | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<number, Default> {\n return readPrimitive(key, Primitive.Number, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getNumber}\n */\n getNumber<Default extends number | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<number, Default> {\n return readPrimitive(key, Primitive.Number, def);\n }\n\n /**\n * Get a boolean environment variable with optional fallback.\n * Recognizes: `1`, `yes`, `true`, `on` as **true**; `0`, `no`, `false`, `off` as **false** (case-insensitive).\n * Accepts a single key or an ordered array of keys (first match wins).\n * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\n */\n static getBoolean<Default extends boolean | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<boolean, Default> {\n return readPrimitive(key, Primitive.Boolean, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getBoolean}\n */\n getBoolean<Default extends boolean | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<boolean, Default> {\n return readPrimitive(key, Primitive.Boolean, def);\n }\n\n /**\n * Get a bigint environment variable with optional fallback.\n * Automatically converts string values to bigint.\n * Accepts a single key or an ordered array of keys (first match wins).\n * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\n */\n static getBigInt<Default extends bigint | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<bigint, Default> {\n return readPrimitive(key, Primitive.BigInt, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getBigInt}\n */\n getBigInt<Default extends bigint | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<bigint, Default> {\n return readPrimitive(key, Primitive.BigInt, def);\n }\n\n /**\n * Get a symbol environment variable with optional fallback.\n * Creates a symbol from the string value.\n * Accepts a single key or an ordered array of keys (first match wins).\n * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\n */\n static getSymbol<Default extends symbol | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<symbol, Default> {\n return readPrimitive(key, Primitive.Symbol, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getSymbol}\n */\n getSymbol<Default extends symbol | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<symbol, Default> {\n return readPrimitive(key, Primitive.Symbol, def);\n }\n}\n"],"mappings":"sEAQA,IAAa,EAAb,cAAsCA,EAAAA,kBAAmB,CAOrD,OAAO,IACH,EACA,EACkC,CAClC,OAAOC,EAAAA,cAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,IACI,EACA,EACkC,CAClC,OAAOA,EAAAA,cAAc,EAAA,EAAuB,CAAG,CACnD,CAQA,OAAO,UACH,EACA,EACkC,CAClC,OAAOA,EAAAA,cAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,UACI,EACA,EACkC,CAClC,OAAOA,EAAAA,cAAc,EAAA,EAAuB,CAAG,CACnD,CAQA,OAAO,WACH,EACA,EACmC,CACnC,OAAOA,EAAAA,cAAc,EAAA,EAAwB,CAAG,CACpD,CAKA,WACI,EACA,EACmC,CACnC,OAAOA,EAAAA,cAAc,EAAA,EAAwB,CAAG,CACpD,CAQA,OAAO,UACH,EACA,EACkC,CAClC,OAAOA,EAAAA,cAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,UACI,EACA,EACkC,CAClC,OAAOA,EAAAA,cAAc,EAAA,EAAuB,CAAG,CACnD,CAQA,OAAO,UACH,EACA,EACkC,CAClC,OAAOA,EAAAA,cAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,UACI,EACA,EACkC,CAClC,OAAOA,EAAAA,cAAc,EAAA,EAAuB,CAAG,CACnD,CACJ"}
1
+ {"version":3,"file":"PrimitiveMethods.cjs","names":["EnvironmentMethods","readPrimitive"],"sources":["../../../src/core/PrimitiveMethods.ts"],"sourcesContent":["import { Primitive, readPrimitive } from './engine';\nimport { EnvironmentMethods } from './EnvironmentMethods';\n\nimport type { ConditionalReturn, EnvKeyInput } from '../types';\n\nexport class PrimitiveMethods extends EnvironmentMethods {\n /**\n * Get a string environment variable with optional fallback.\n * Supports template variable resolution using `${VAR}` syntax.\n * Accepts a single key or an ordered array of keys (first match wins).\n * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\n */\n static get<Default extends string | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<string, Default> {\n return readPrimitive(key, Primitive.String, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.get}\n */\n get<Default extends string | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<string, Default> {\n return readPrimitive(key, Primitive.String, def);\n }\n\n /**\n * Get a number environment variable with optional fallback.\n * Automatically converts string values to numbers.\n * Accepts a single key or an ordered array of keys (first match wins).\n * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\n */\n static getNumber<Default extends number | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<number, Default> {\n return readPrimitive(key, Primitive.Number, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getNumber}\n */\n getNumber<Default extends number | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<number, Default> {\n return readPrimitive(key, Primitive.Number, def);\n }\n\n /**\n * Get a boolean environment variable with optional fallback.\n * Recognizes: `1`, `yes`, `true`, `on` as **true**; `0`, `no`, `false`, `off` as **false** (case-insensitive).\n * Accepts a single key or an ordered array of keys (first match wins).\n * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\n */\n static getBoolean<Default extends boolean | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<boolean, Default> {\n return readPrimitive(key, Primitive.Boolean, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getBoolean}\n */\n getBoolean<Default extends boolean | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<boolean, Default> {\n return readPrimitive(key, Primitive.Boolean, def);\n }\n\n /**\n * Get a bigint environment variable with optional fallback.\n * Automatically converts string values to bigint.\n * Accepts a single key or an ordered array of keys (first match wins).\n * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\n */\n static getBigInt<Default extends bigint | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<bigint, Default> {\n return readPrimitive(key, Primitive.BigInt, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getBigInt}\n */\n getBigInt<Default extends bigint | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<bigint, Default> {\n return readPrimitive(key, Primitive.BigInt, def);\n }\n\n /**\n * Get a symbol environment variable with optional fallback.\n * Creates a symbol from the string value.\n * Accepts a single key or an ordered array of keys (first match wins).\n * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\n */\n static getSymbol<Default extends symbol | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<symbol, Default> {\n return readPrimitive(key, Primitive.Symbol, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getSymbol}\n */\n getSymbol<Default extends symbol | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<symbol, Default> {\n return readPrimitive(key, Primitive.Symbol, def);\n }\n}\n"],"mappings":"sEAKA,IAAa,EAAb,cAAsCA,EAAAA,kBAAmB,CAOrD,OAAO,IACH,EACA,EACkC,CAClC,OAAOC,EAAAA,cAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,IACI,EACA,EACkC,CAClC,OAAOA,EAAAA,cAAc,EAAA,EAAuB,CAAG,CACnD,CAQA,OAAO,UACH,EACA,EACkC,CAClC,OAAOA,EAAAA,cAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,UACI,EACA,EACkC,CAClC,OAAOA,EAAAA,cAAc,EAAA,EAAuB,CAAG,CACnD,CAQA,OAAO,WACH,EACA,EACmC,CACnC,OAAOA,EAAAA,cAAc,EAAA,EAAwB,CAAG,CACpD,CAKA,WACI,EACA,EACmC,CACnC,OAAOA,EAAAA,cAAc,EAAA,EAAwB,CAAG,CACpD,CAQA,OAAO,UACH,EACA,EACkC,CAClC,OAAOA,EAAAA,cAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,UACI,EACA,EACkC,CAClC,OAAOA,EAAAA,cAAc,EAAA,EAAuB,CAAG,CACnD,CAQA,OAAO,UACH,EACA,EACkC,CAClC,OAAOA,EAAAA,cAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,UACI,EACA,EACkC,CAClC,OAAOA,EAAAA,cAAc,EAAA,EAAuB,CAAG,CACnD,CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"PrimitiveMethods.mjs","names":[],"sources":["../../../src/core/PrimitiveMethods.ts"],"sourcesContent":["import { Primitive, readPrimitive } from './engine';\nimport { EnvironmentMethods } from './EnvironmentMethods';\n\nimport type { ConditionalReturn, EnvKeyInput } from '../types';\n\n/**\n * @internal\n */\nexport class PrimitiveMethods extends EnvironmentMethods {\n /**\n * Get a string environment variable with optional fallback.\n * Supports template variable resolution using `${VAR}` syntax.\n * Accepts a single key or an ordered array of keys (first match wins).\n * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\n */\n static get<Default extends string | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<string, Default> {\n return readPrimitive(key, Primitive.String, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.get}\n */\n get<Default extends string | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<string, Default> {\n return readPrimitive(key, Primitive.String, def);\n }\n\n /**\n * Get a number environment variable with optional fallback.\n * Automatically converts string values to numbers.\n * Accepts a single key or an ordered array of keys (first match wins).\n * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\n */\n static getNumber<Default extends number | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<number, Default> {\n return readPrimitive(key, Primitive.Number, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getNumber}\n */\n getNumber<Default extends number | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<number, Default> {\n return readPrimitive(key, Primitive.Number, def);\n }\n\n /**\n * Get a boolean environment variable with optional fallback.\n * Recognizes: `1`, `yes`, `true`, `on` as **true**; `0`, `no`, `false`, `off` as **false** (case-insensitive).\n * Accepts a single key or an ordered array of keys (first match wins).\n * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\n */\n static getBoolean<Default extends boolean | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<boolean, Default> {\n return readPrimitive(key, Primitive.Boolean, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getBoolean}\n */\n getBoolean<Default extends boolean | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<boolean, Default> {\n return readPrimitive(key, Primitive.Boolean, def);\n }\n\n /**\n * Get a bigint environment variable with optional fallback.\n * Automatically converts string values to bigint.\n * Accepts a single key or an ordered array of keys (first match wins).\n * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\n */\n static getBigInt<Default extends bigint | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<bigint, Default> {\n return readPrimitive(key, Primitive.BigInt, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getBigInt}\n */\n getBigInt<Default extends bigint | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<bigint, Default> {\n return readPrimitive(key, Primitive.BigInt, def);\n }\n\n /**\n * Get a symbol environment variable with optional fallback.\n * Creates a symbol from the string value.\n * Accepts a single key or an ordered array of keys (first match wins).\n * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\n */\n static getSymbol<Default extends symbol | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<symbol, Default> {\n return readPrimitive(key, Primitive.Symbol, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getSymbol}\n */\n getSymbol<Default extends symbol | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<symbol, Default> {\n return readPrimitive(key, Primitive.Symbol, def);\n }\n}\n"],"mappings":"2GAQA,IAAa,EAAb,cAAsC,CAAmB,CAOrD,OAAO,IACH,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,IACI,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAQA,OAAO,UACH,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,UACI,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAQA,OAAO,WACH,EACA,EACmC,CACnC,OAAO,EAAc,EAAA,EAAwB,CAAG,CACpD,CAKA,WACI,EACA,EACmC,CACnC,OAAO,EAAc,EAAA,EAAwB,CAAG,CACpD,CAQA,OAAO,UACH,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,UACI,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAQA,OAAO,UACH,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,UACI,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CACJ"}
1
+ {"version":3,"file":"PrimitiveMethods.mjs","names":[],"sources":["../../../src/core/PrimitiveMethods.ts"],"sourcesContent":["import { Primitive, readPrimitive } from './engine';\nimport { EnvironmentMethods } from './EnvironmentMethods';\n\nimport type { ConditionalReturn, EnvKeyInput } from '../types';\n\nexport class PrimitiveMethods extends EnvironmentMethods {\n /**\n * Get a string environment variable with optional fallback.\n * Supports template variable resolution using `${VAR}` syntax.\n * Accepts a single key or an ordered array of keys (first match wins).\n * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\n */\n static get<Default extends string | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<string, Default> {\n return readPrimitive(key, Primitive.String, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.get}\n */\n get<Default extends string | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<string, Default> {\n return readPrimitive(key, Primitive.String, def);\n }\n\n /**\n * Get a number environment variable with optional fallback.\n * Automatically converts string values to numbers.\n * Accepts a single key or an ordered array of keys (first match wins).\n * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\n */\n static getNumber<Default extends number | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<number, Default> {\n return readPrimitive(key, Primitive.Number, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getNumber}\n */\n getNumber<Default extends number | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<number, Default> {\n return readPrimitive(key, Primitive.Number, def);\n }\n\n /**\n * Get a boolean environment variable with optional fallback.\n * Recognizes: `1`, `yes`, `true`, `on` as **true**; `0`, `no`, `false`, `off` as **false** (case-insensitive).\n * Accepts a single key or an ordered array of keys (first match wins).\n * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\n */\n static getBoolean<Default extends boolean | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<boolean, Default> {\n return readPrimitive(key, Primitive.Boolean, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getBoolean}\n */\n getBoolean<Default extends boolean | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<boolean, Default> {\n return readPrimitive(key, Primitive.Boolean, def);\n }\n\n /**\n * Get a bigint environment variable with optional fallback.\n * Automatically converts string values to bigint.\n * Accepts a single key or an ordered array of keys (first match wins).\n * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\n */\n static getBigInt<Default extends bigint | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<bigint, Default> {\n return readPrimitive(key, Primitive.BigInt, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getBigInt}\n */\n getBigInt<Default extends bigint | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<bigint, Default> {\n return readPrimitive(key, Primitive.BigInt, def);\n }\n\n /**\n * Get a symbol environment variable with optional fallback.\n * Creates a symbol from the string value.\n * Accepts a single key or an ordered array of keys (first match wins).\n * @see {@link https://envapt.materwelon.dev/docs/envapter#primitives}\n */\n static getSymbol<Default extends symbol | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<symbol, Default> {\n return readPrimitive(key, Primitive.Symbol, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getSymbol}\n */\n getSymbol<Default extends symbol | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<symbol, Default> {\n return readPrimitive(key, Primitive.Symbol, def);\n }\n}\n"],"mappings":"2GAKA,IAAa,EAAb,cAAsC,CAAmB,CAOrD,OAAO,IACH,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,IACI,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAQA,OAAO,UACH,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,UACI,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAQA,OAAO,WACH,EACA,EACmC,CACnC,OAAO,EAAc,EAAA,EAAwB,CAAG,CACpD,CAKA,WACI,EACA,EACmC,CACnC,OAAO,EAAc,EAAA,EAAwB,CAAG,CACpD,CAQA,OAAO,UACH,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,UACI,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAQA,OAAO,UACH,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CAKA,UACI,EACA,EACkC,CAClC,OAAO,EAAc,EAAA,EAAuB,CAAG,CACnD,CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"engine.cjs","names":["EnvaptError","isMissing","state","resolveEffectivePaths","loadDotenv","cache","parseEnvironment","firstEnvKeyValue","ENV_KEYS","TemplateResolver","ValueConverter","BuiltInConverters"],"sources":["../../../src/core/engine.ts"],"sourcesContent":["import { BuiltInConverters, ValueConverter } from '../converters';\nimport { ENV_KEYS, Environment, firstEnvKeyValue, parseEnvironment } from './Environment';\nimport { isMissing } from './missing';\nimport { resolveEffectivePaths } from './paths';\nimport { cache, state } from './state';\nimport { TemplateResolver } from '../engine/TemplateResolver';\nimport { debugVerbose, debugWarn } from '../infra/Debug';\nimport { loadDotenv } from '../infra/Dotenv';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { ConditionalReturn, EnvKeyInput } from '../types';\nimport type { EnvapterService } from '../types/Env';\n\nexport function resolveKeyInput(keyInput: EnvKeyInput): { key: string; value: string | undefined } {\n const keys = Array.isArray(keyInput) ? keyInput : [keyInput];\n const normalizedKeys = keys as readonly string[];\n\n if (normalizedKeys.length === 0) {\n throw new EnvaptError(EnvaptErrorCodes.InvalidKeyInput, 'At least one environment key must be provided.');\n }\n\n if (normalizedKeys.some((k) => typeof k !== 'string')) {\n throw new EnvaptError(EnvaptErrorCodes.InvalidKeyInput, 'Environment keys must be strings.');\n }\n\n if (normalizedKeys.some((k) => k.trim() === '')) {\n throw new EnvaptError(EnvaptErrorCodes.InvalidKeyInput, 'Environment keys cannot be empty strings.');\n }\n\n // An ordered read keeps trying so a present-but-empty candidate falls through to the next, matching\n // getRequired and firstEnvKeyValue. A single key or an all-empty list resolves to the first present value.\n let firstPresent: { key: string; value: string } | undefined;\n for (const candidate of normalizedKeys) {\n const value = readCached(candidate);\n if (value === undefined) continue;\n if (!isMissing(value)) return { key: candidate, value };\n firstPresent ??= { key: candidate, value };\n }\n\n return firstPresent ?? { key: normalizedKeys[0] as string, value: undefined };\n}\n\nexport function ensureLoaded(): Map<string, unknown> {\n if (!state.cacheBuilt) {\n const source = state.source;\n // Clone so the loader and downstream reads never mutate the source's backing object.\n const isolatedEnv: Record<string, string> = { ...source.readVars() };\n\n let added = new Set<string>();\n // Sources without a filesystem (injected objects on the browser or Workers) skip the .env\n // cascade, profiles, and envPaths. Only the readVars() snapshot populates the cache.\n if (source.supportsFiles) {\n debugVerbose(`base dir: ${state.baseDir ?? 'working directory'}`);\n // Outside the try below so a missing configured profile path surfaces its EnvaptError. Only dotenv parse errors stay caught.\n const effectivePaths = resolveEffectivePaths();\n debugVerbose(`effective .env paths: ${effectivePaths.length === 0 ? '(none)' : effectivePaths.join(', ')}`);\n try {\n added = loadDotenv({\n ...state.userDefinedEnvFileOptions,\n path: effectivePaths,\n processEnv: isolatedEnv,\n readFile: source.readFile.bind(source)\n });\n } catch (error) {\n debugWarn(`failed to load .env: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n state.dotenvAddedKeys = added;\n for (const [key, value] of Object.entries(isolatedEnv)) cache.set(key, value);\n debugVerbose(`cache populated: ${cache.size} keys total`);\n // set before mirroring, whose template expansion reads the cache and would re-enter this build otherwise\n state.cacheBuilt = true;\n if (state.syncProcessEnv) mirrorToProcessEnv();\n }\n\n return cache;\n}\n\nfunction readCached(key: string): string | undefined {\n const c = ensureLoaded();\n // decorator memoization also stores non-string values in this shared cache\n if (c.has(key)) {\n const cached = c.get(key);\n return typeof cached === 'string' ? cached : undefined;\n }\n const source = state.source;\n if (typeof source.readVar !== 'function') return undefined;\n const value = source.readVar(key);\n // cache a miss too, so a later read of an absent key skips the reader\n c.set(key, value);\n return value;\n}\n\nexport function refreshCache(): void {\n // Reset an inferred environment so re-hydration re-determines it from current state. An explicit\n // Envapter.environment = X is preserved through the refresh and used for cascade selection.\n if (!state.environmentExplicitlySet) state.environment = undefined;\n cache.clear();\n state.cacheBuilt = false;\n state.dotenvAddedKeys = new Set<string>();\n debugVerbose('cache cleared, reloading config');\n ensureLoaded();\n}\n\nexport function mirrorToProcessEnv(): void {\n if (state.dotenvAddedKeys.size === 0) return;\n const source = state.source;\n /* v8 ignore next -- @preserve dotenv keys only accumulate under a file source, so the delta implies supportsFiles here */\n if (!source.supportsFiles) return;\n const mirrored: Record<string, string> = {};\n for (const key of state.dotenvAddedKeys) {\n const value = cache.get(key);\n /* v8 ignore next -- @preserve loader only writes strings, defensive against future cache contents */\n if (typeof value !== 'string') continue;\n mirrored[key] = resolveForMirror(key, value);\n debugVerbose(`mirrored ${key} to the ambient environment`);\n }\n source.writeVars(mirrored);\n debugVerbose(`mirrored ${state.dotenvAddedKeys.size} keys to the ambient environment`);\n}\n\nfunction resolveForMirror(key: string, value: string): string {\n return templateResolver.resolveTemplate(key, value);\n}\n\nexport function determineEnvironment(env?: string | Environment): void {\n if (typeof env === 'number') {\n state.environment = env;\n state.environmentExplicitlySet = true;\n return;\n }\n if (typeof env === 'string') {\n state.environment = parseEnvironment(env) ?? Environment.Development;\n state.environmentExplicitlySet = true;\n return;\n }\n\n const raw = firstEnvKeyValue((key) => readCached(key));\n if (raw === undefined) {\n debugWarn(`no environment set (looked for ${ENV_KEYS.join(', ')}); defaulting to development`);\n state.environment = Environment.Development;\n return;\n }\n const parsed = parseEnvironment(raw);\n if (parsed === undefined) {\n debugWarn(`unrecognized environment \"${raw}\"; defaulting to development`);\n state.environment = Environment.Development;\n return;\n }\n state.environment = parsed;\n}\n\n/**\n * @internal\n */\nexport enum Primitive {\n String,\n Number,\n Boolean,\n BigInt,\n Symbol\n}\n\nconst PRIMITIVE_NAMES: Record<Primitive, string> = {\n [Primitive.String]: 'string',\n [Primitive.Number]: 'number',\n [Primitive.Boolean]: 'boolean',\n [Primitive.BigInt]: 'bigint',\n [Primitive.Symbol]: 'symbol'\n};\n\n// getRaw is the raw string lookup, get is the template-resolved string read. Lazy arrows so the\n// resolver singletons below store envService without calling readPrimitive, which reads\n// templateResolver before it is assigned.\nconst envService: EnvapterService = {\n getRaw: (key) => resolveKeyInput(key).value,\n get: (key, def) => readPrimitive<string, string | undefined>(key, Primitive.String, def)\n};\n\nexport const templateResolver: TemplateResolver = new TemplateResolver(envService);\nexport const valueConverter: ValueConverter = new ValueConverter(envService);\n\nexport function readPrimitive<EnvVarReturnType, DefaultType extends EnvVarReturnType | undefined = undefined>(\n key: EnvKeyInput,\n type: Primitive,\n def?: DefaultType\n): ConditionalReturn<EnvVarReturnType, DefaultType> {\n const { key: resolvedKey, value } = resolveKeyInput(key);\n if (isMissing(value)) {\n if (def !== undefined) debugWarn(`${resolvedKey} is missing or empty, using fallback ${String(def)}`);\n else debugWarn(`${resolvedKey} is missing or empty`);\n return def as ConditionalReturn<EnvVarReturnType, DefaultType>;\n }\n\n const parsed = templateResolver.resolveTemplate(resolvedKey, String(value));\n\n let converted: EnvVarReturnType | undefined;\n if (type === Primitive.Number) converted = BuiltInConverters.number(parsed) as EnvVarReturnType | undefined;\n else if (type === Primitive.Boolean) converted = BuiltInConverters.boolean(parsed) as EnvVarReturnType | undefined;\n else if (type === Primitive.BigInt) converted = BuiltInConverters.bigint(parsed) as EnvVarReturnType | undefined;\n else if (type === Primitive.Symbol) converted = BuiltInConverters.symbol(parsed) as EnvVarReturnType | undefined;\n else converted = BuiltInConverters.string(parsed) as EnvVarReturnType | undefined;\n\n if (converted === undefined) {\n // key and type only, no value: env values can be secrets and verbose logs reach stderr\n debugVerbose(\n `could not convert ${resolvedKey} as ${PRIMITIVE_NAMES[type]}${def !== undefined ? ', using the fallback' : ''}`\n );\n return def as ConditionalReturn<EnvVarReturnType, DefaultType>;\n }\n\n return converted;\n}\n"],"mappings":"8VAaA,SAAgB,EAAgB,EAAmE,CAE/F,IAAM,EADO,MAAM,QAAQ,CAAQ,EAAI,EAAW,CAAC,CAAQ,EAG3D,GAAI,EAAe,SAAW,EAC1B,MAAM,IAAIA,EAAAA,YAAAA,IAA8C,gDAAgD,EAG5G,GAAI,EAAe,KAAM,GAAM,OAAO,GAAM,QAAQ,EAChD,MAAM,IAAIA,EAAAA,YAAAA,IAA8C,mCAAmC,EAG/F,GAAI,EAAe,KAAM,GAAM,EAAE,KAAK,IAAM,EAAE,EAC1C,MAAM,IAAIA,EAAAA,YAAAA,IAA8C,2CAA2C,EAKvG,IAAI,EACJ,IAAK,IAAM,KAAa,EAAgB,CACpC,IAAM,EAAQ,EAAW,CAAS,EAC9B,OAAU,IAAA,GACd,IAAI,CAACC,EAAAA,UAAU,CAAK,EAAG,MAAO,CAAE,IAAK,EAAW,OAAM,EACtD,IAAiB,CAAE,IAAK,EAAW,OAAM,CADa,CAE1D,CAEA,OAAO,GAAgB,CAAE,IAAK,EAAe,GAAc,MAAO,IAAA,EAAU,CAChF,CAEA,SAAgB,GAAqC,CACjD,GAAI,CAACC,EAAAA,MAAM,WAAY,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3B,EAAA,SACA,EAAA,SACC,EAAA,UACD,EAAA,SACA,EAAA,QACxB,EAKM,EAA8B,CAChC,OAAS,GAAQ,EAAgB,CAAG,CAAC,CAAC,MACtC,KAAM,EAAK,IAAQ,EAA0C,EAAA,EAAuB,CAAG,CAC3F,EAEa,EAAqC,IAAIG,EAAAA,iBAAiB,CAAU,EACpE,EAAiC,IAAIC,EAAAA,eAAe,CAAU,EAE3E,SAAgB,EACZ,EACA,EACA,EACgD,CAChD,GAAM,CAAE,IAAK,EAAa,SAAU,EAAgB,CAAG,EACvD,GAAIT,EAAAA,UAAU,CAAK,EAGf,OAFI,IAAQ,IAAA,GACP,EAAA,UAAU,GAAG,EAAY,qBAAqB,EAD5B,EAAA,UAAU,GAAG,EAAY,uCAAuC,OAAO,CAAG,GAAG,EAE7F,EAGX,IAAM,EAAS,EAAiB,gBAAgB,EAAa,OAAO,CAAK,CAAC,EAEtE,EAeJ,MAdA,CAIK,EAJD,IAAA,EAAuCU,EAAAA,kBAAkB,OAAO,CAAM,EACjE,IAAA,EAAwCA,EAAAA,kBAAkB,QAAQ,CAAM,EACxE,IAAA,EAAuCA,EAAAA,kBAAkB,OAAO,CAAM,EACtE,IAAA,EAAuCA,EAAAA,kBAAkB,OAAO,CAAM,EAC9DA,EAAAA,kBAAkB,OAAO,CAAM,EAE5C,IAAc,IAAA,IAEd,EAAA,aACI,qBAAqB,EAAY,MAAM,EAAgB,KAAQ,IAAQ,IAAA,GAAqC,GAAzB,wBACvF,EACO,GAGJ,CACX"}
1
+ {"version":3,"file":"engine.cjs","names":["EnvaptError","isMissing","state","resolveEffectivePaths","loadDotenv","cache","parseEnvironment","firstEnvKeyValue","ENV_KEYS","TemplateResolver","ValueConverter","BuiltInConverters"],"sources":["../../../src/core/engine.ts"],"sourcesContent":["import { BuiltInConverters, ValueConverter } from '../converters';\nimport { ENV_KEYS, Environment, firstEnvKeyValue, parseEnvironment } from './Environment';\nimport { isMissing } from './missing';\nimport { resolveEffectivePaths } from './paths';\nimport { cache, state } from './state';\nimport { TemplateResolver } from '../engine/TemplateResolver';\nimport { debugVerbose, debugWarn } from '../infra/Debug';\nimport { loadDotenv } from '../infra/Dotenv';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { ConditionalReturn, EnvKeyInput } from '../types';\nimport type { EnvapterService } from '../types/Env';\n\nexport function resolveKeyInput(keyInput: EnvKeyInput): { key: string; value: string | undefined } {\n const keys = Array.isArray(keyInput) ? keyInput : [keyInput];\n const normalizedKeys = keys as readonly string[];\n\n if (normalizedKeys.length === 0) {\n throw new EnvaptError(EnvaptErrorCodes.InvalidKeyInput, 'At least one environment key must be provided.');\n }\n\n if (normalizedKeys.some((k) => typeof k !== 'string')) {\n throw new EnvaptError(EnvaptErrorCodes.InvalidKeyInput, 'Environment keys must be strings.');\n }\n\n if (normalizedKeys.some((k) => k.trim() === '')) {\n throw new EnvaptError(EnvaptErrorCodes.InvalidKeyInput, 'Environment keys cannot be empty strings.');\n }\n\n // an empty value falls through to the next key and only comes back when every key is empty\n let firstPresent: { key: string; value: string } | undefined;\n for (const candidate of normalizedKeys) {\n const value = readCached(candidate);\n if (value === undefined) continue;\n if (!isMissing(value)) return { key: candidate, value };\n firstPresent ??= { key: candidate, value };\n }\n\n return firstPresent ?? { key: normalizedKeys[0] as string, value: undefined };\n}\n\nexport function ensureLoaded(): Map<string, unknown> {\n if (!state.cacheBuilt) {\n const source = state.source;\n // the loader writes into this object\n const isolatedEnv: Record<string, string> = { ...source.readVars() };\n\n let added = new Set<string>();\n if (source.supportsFiles) {\n debugVerbose(`base dir: ${state.baseDir ?? 'working directory'}`);\n // outside the try because a missing profile path has to throw\n const effectivePaths = resolveEffectivePaths();\n debugVerbose(`effective .env paths: ${effectivePaths.length === 0 ? '(none)' : effectivePaths.join(', ')}`);\n try {\n added = loadDotenv({\n ...state.userDefinedEnvFileOptions,\n path: effectivePaths,\n processEnv: isolatedEnv,\n readFile: source.readFile.bind(source)\n });\n } catch (error) {\n debugWarn(`failed to load .env: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n state.dotenvAddedKeys = added;\n for (const [key, value] of Object.entries(isolatedEnv)) cache.set(key, value);\n debugVerbose(`cache populated: ${cache.size} keys total`);\n // set before mirroring because template expansion reads the cache\n state.cacheBuilt = true;\n if (state.syncProcessEnv) mirrorToProcessEnv();\n }\n\n return cache;\n}\n\nfunction readCached(key: string): string | undefined {\n const c = ensureLoaded();\n // decorator memoization also stores non-string values in this shared cache\n if (c.has(key)) {\n const cached = c.get(key);\n return typeof cached === 'string' ? cached : undefined;\n }\n const source = state.source;\n if (typeof source.readVar !== 'function') return undefined;\n const value = source.readVar(key);\n // caches misses too\n c.set(key, value);\n return value;\n}\n\nexport function refreshCache(): void {\n // an inferred environment can change once the new vars load\n if (!state.environmentExplicitlySet) state.environment = undefined;\n cache.clear();\n state.cacheBuilt = false;\n state.dotenvAddedKeys = new Set<string>();\n debugVerbose('cache cleared, reloading config');\n ensureLoaded();\n}\n\nexport function mirrorToProcessEnv(): void {\n if (state.dotenvAddedKeys.size === 0) return;\n const source = state.source;\n /* v8 ignore next -- @preserve dotenv keys only accumulate under a file source, so the delta implies supportsFiles here */\n if (!source.supportsFiles) return;\n const mirrored: Record<string, string> = {};\n for (const key of state.dotenvAddedKeys) {\n const value = cache.get(key);\n /* v8 ignore next -- @preserve the loader only writes strings */\n if (typeof value !== 'string') continue;\n mirrored[key] = resolveForMirror(key, value);\n debugVerbose(`mirrored ${key} to the ambient environment`);\n }\n source.writeVars(mirrored);\n debugVerbose(`mirrored ${state.dotenvAddedKeys.size} keys to the ambient environment`);\n}\n\nfunction resolveForMirror(key: string, value: string): string {\n return templateResolver.resolveTemplate(key, value);\n}\n\nexport function determineEnvironment(env?: string | Environment): void {\n if (typeof env === 'number') {\n state.environment = env;\n state.environmentExplicitlySet = true;\n return;\n }\n if (typeof env === 'string') {\n state.environment = parseEnvironment(env) ?? Environment.Development;\n state.environmentExplicitlySet = true;\n return;\n }\n\n const raw = firstEnvKeyValue((key) => readCached(key));\n if (raw === undefined) {\n debugWarn(`no environment set (looked for ${ENV_KEYS.join(', ')}); defaulting to development`);\n state.environment = Environment.Development;\n return;\n }\n const parsed = parseEnvironment(raw);\n if (parsed === undefined) {\n debugWarn(`unrecognized environment \"${raw}\"; defaulting to development`);\n state.environment = Environment.Development;\n return;\n }\n state.environment = parsed;\n}\n\nexport enum Primitive {\n String,\n Number,\n Boolean,\n BigInt,\n Symbol\n}\n\nconst PRIMITIVE_NAMES: Record<Primitive, string> = {\n [Primitive.String]: 'string',\n [Primitive.Number]: 'number',\n [Primitive.Boolean]: 'boolean',\n [Primitive.BigInt]: 'bigint',\n [Primitive.Symbol]: 'symbol'\n};\n\n// arrows because readPrimitive reads templateResolver, which is assigned below\nconst envService: EnvapterService = {\n getRaw: (key) => resolveKeyInput(key).value,\n get: (key, def) => readPrimitive<string, string | undefined>(key, Primitive.String, def)\n};\n\nexport const templateResolver: TemplateResolver = new TemplateResolver(envService);\nexport const valueConverter: ValueConverter = new ValueConverter(envService);\n\nexport function readPrimitive<EnvVarReturnType, DefaultType extends EnvVarReturnType | undefined = undefined>(\n key: EnvKeyInput,\n type: Primitive,\n def?: DefaultType\n): ConditionalReturn<EnvVarReturnType, DefaultType> {\n const { key: resolvedKey, value } = resolveKeyInput(key);\n if (isMissing(value)) {\n if (def !== undefined) debugWarn(`${resolvedKey} is missing or empty, using fallback ${String(def)}`);\n else debugWarn(`${resolvedKey} is missing or empty`);\n return def as ConditionalReturn<EnvVarReturnType, DefaultType>;\n }\n\n const parsed = templateResolver.resolveTemplate(resolvedKey, String(value));\n\n let converted: EnvVarReturnType | undefined;\n if (type === Primitive.Number) converted = BuiltInConverters.number(parsed) as EnvVarReturnType | undefined;\n else if (type === Primitive.Boolean) converted = BuiltInConverters.boolean(parsed) as EnvVarReturnType | undefined;\n else if (type === Primitive.BigInt) converted = BuiltInConverters.bigint(parsed) as EnvVarReturnType | undefined;\n else if (type === Primitive.Symbol) converted = BuiltInConverters.symbol(parsed) as EnvVarReturnType | undefined;\n else converted = BuiltInConverters.string(parsed) as EnvVarReturnType | undefined;\n\n if (converted === undefined) {\n // leave the value out because env values can be secrets\n debugVerbose(\n `could not convert ${resolvedKey} as ${PRIMITIVE_NAMES[type]}${def !== undefined ? ', using the fallback' : ''}`\n );\n return def as ConditionalReturn<EnvVarReturnType, DefaultType>;\n }\n\n return converted;\n}\n"],"mappings":"8VAaA,SAAgB,EAAgB,EAAmE,CAE/F,IAAM,EADO,MAAM,QAAQ,CAAQ,EAAI,EAAW,CAAC,CAAQ,EAG3D,GAAI,EAAe,SAAW,EAC1B,MAAM,IAAIA,EAAAA,YAAAA,IAA8C,gDAAgD,EAG5G,GAAI,EAAe,KAAM,GAAM,OAAO,GAAM,QAAQ,EAChD,MAAM,IAAIA,EAAAA,YAAAA,IAA8C,mCAAmC,EAG/F,GAAI,EAAe,KAAM,GAAM,EAAE,KAAK,IAAM,EAAE,EAC1C,MAAM,IAAIA,EAAAA,YAAAA,IAA8C,2CAA2C,EAIvG,IAAI,EACJ,IAAK,IAAM,KAAa,EAAgB,CACpC,IAAM,EAAQ,EAAW,CAAS,EAC9B,OAAU,IAAA,GACd,IAAI,CAACC,EAAAA,UAAU,CAAK,EAAG,MAAO,CAAE,IAAK,EAAW,OAAM,EACtD,IAAiB,CAAE,IAAK,EAAW,OAAM,CADa,CAE1D,CAEA,OAAO,GAAgB,CAAE,IAAK,EAAe,GAAc,MAAO,IAAA,EAAU,CAChF,CAEA,SAAgB,GAAqC,CACjD,GAAI,CAACC,EAAAA,MAAM,WAAY,CACnB,IAAM,EAASA,EAAAA,MAAM,OAEf,EAAsC,CAAE,GAAG,EAAO,SAAS,CAAE,EAE/D,EAAQ,IAAI,IAChB,GAAI,EAAO,cAAe,CACtB,EAAA,aAAa,aAAaA,EAAAA,MAAM,SAAW,qBAAqB,EAEhE,IAAM,EAAiBC,EAAAA,sBAAsB,EAC7C,EAAA,aAAa,yBAAyB,EAAe,SAAW,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,CAAU,EAE3E,SAAgB,EACZ,EACA,EACA,EACgD,CAChD,GAAM,CAAE,IAAK,EAAa,SAAU,EAAgB,CAAG,EACvD,GAAIT,EAAAA,UAAU,CAAK,EAGf,OAFI,IAAQ,IAAA,GACP,EAAA,UAAU,GAAG,EAAY,qBAAqB,EAD5B,EAAA,UAAU,GAAG,EAAY,uCAAuC,OAAO,CAAG,GAAG,EAE7F,EAGX,IAAM,EAAS,EAAiB,gBAAgB,EAAa,OAAO,CAAK,CAAC,EAEtE,EAeJ,MAdA,CAIK,EAJD,IAAA,EAAuCU,EAAAA,kBAAkB,OAAO,CAAM,EACjE,IAAA,EAAwCA,EAAAA,kBAAkB,QAAQ,CAAM,EACxE,IAAA,EAAuCA,EAAAA,kBAAkB,OAAO,CAAM,EACtE,IAAA,EAAuCA,EAAAA,kBAAkB,OAAO,CAAM,EAC9DA,EAAAA,kBAAkB,OAAO,CAAM,EAE5C,IAAc,IAAA,IAEd,EAAA,aACI,qBAAqB,EAAY,MAAM,EAAgB,KAAQ,IAAQ,IAAA,GAAqC,GAAzB,wBACvF,EACO,GAGJ,CACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"engine.mjs","names":[],"sources":["../../../src/core/engine.ts"],"sourcesContent":["import { BuiltInConverters, ValueConverter } from '../converters';\nimport { ENV_KEYS, Environment, firstEnvKeyValue, parseEnvironment } from './Environment';\nimport { isMissing } from './missing';\nimport { resolveEffectivePaths } from './paths';\nimport { cache, state } from './state';\nimport { TemplateResolver } from '../engine/TemplateResolver';\nimport { debugVerbose, debugWarn } from '../infra/Debug';\nimport { loadDotenv } from '../infra/Dotenv';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { ConditionalReturn, EnvKeyInput } from '../types';\nimport type { EnvapterService } from '../types/Env';\n\nexport function resolveKeyInput(keyInput: EnvKeyInput): { key: string; value: string | undefined } {\n const keys = Array.isArray(keyInput) ? keyInput : [keyInput];\n const normalizedKeys = keys as readonly string[];\n\n if (normalizedKeys.length === 0) {\n throw new EnvaptError(EnvaptErrorCodes.InvalidKeyInput, 'At least one environment key must be provided.');\n }\n\n if (normalizedKeys.some((k) => typeof k !== 'string')) {\n throw new EnvaptError(EnvaptErrorCodes.InvalidKeyInput, 'Environment keys must be strings.');\n }\n\n if (normalizedKeys.some((k) => k.trim() === '')) {\n throw new EnvaptError(EnvaptErrorCodes.InvalidKeyInput, 'Environment keys cannot be empty strings.');\n }\n\n // An ordered read keeps trying so a present-but-empty candidate falls through to the next, matching\n // getRequired and firstEnvKeyValue. A single key or an all-empty list resolves to the first present value.\n let firstPresent: { key: string; value: string } | undefined;\n for (const candidate of normalizedKeys) {\n const value = readCached(candidate);\n if (value === undefined) continue;\n if (!isMissing(value)) return { key: candidate, value };\n firstPresent ??= { key: candidate, value };\n }\n\n return firstPresent ?? { key: normalizedKeys[0] as string, value: undefined };\n}\n\nexport function ensureLoaded(): Map<string, unknown> {\n if (!state.cacheBuilt) {\n const source = state.source;\n // Clone so the loader and downstream reads never mutate the source's backing object.\n const isolatedEnv: Record<string, string> = { ...source.readVars() };\n\n let added = new Set<string>();\n // Sources without a filesystem (injected objects on the browser or Workers) skip the .env\n // cascade, profiles, and envPaths. Only the readVars() snapshot populates the cache.\n if (source.supportsFiles) {\n debugVerbose(`base dir: ${state.baseDir ?? 'working directory'}`);\n // Outside the try below so a missing configured profile path surfaces its EnvaptError. Only dotenv parse errors stay caught.\n const effectivePaths = resolveEffectivePaths();\n debugVerbose(`effective .env paths: ${effectivePaths.length === 0 ? '(none)' : effectivePaths.join(', ')}`);\n try {\n added = loadDotenv({\n ...state.userDefinedEnvFileOptions,\n path: effectivePaths,\n processEnv: isolatedEnv,\n readFile: source.readFile.bind(source)\n });\n } catch (error) {\n debugWarn(`failed to load .env: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n state.dotenvAddedKeys = added;\n for (const [key, value] of Object.entries(isolatedEnv)) cache.set(key, value);\n debugVerbose(`cache populated: ${cache.size} keys total`);\n // set before mirroring, whose template expansion reads the cache and would re-enter this build otherwise\n state.cacheBuilt = true;\n if (state.syncProcessEnv) mirrorToProcessEnv();\n }\n\n return cache;\n}\n\nfunction readCached(key: string): string | undefined {\n const c = ensureLoaded();\n // decorator memoization also stores non-string values in this shared cache\n if (c.has(key)) {\n const cached = c.get(key);\n return typeof cached === 'string' ? cached : undefined;\n }\n const source = state.source;\n if (typeof source.readVar !== 'function') return undefined;\n const value = source.readVar(key);\n // cache a miss too, so a later read of an absent key skips the reader\n c.set(key, value);\n return value;\n}\n\nexport function refreshCache(): void {\n // Reset an inferred environment so re-hydration re-determines it from current state. An explicit\n // Envapter.environment = X is preserved through the refresh and used for cascade selection.\n if (!state.environmentExplicitlySet) state.environment = undefined;\n cache.clear();\n state.cacheBuilt = false;\n state.dotenvAddedKeys = new Set<string>();\n debugVerbose('cache cleared, reloading config');\n ensureLoaded();\n}\n\nexport function mirrorToProcessEnv(): void {\n if (state.dotenvAddedKeys.size === 0) return;\n const source = state.source;\n /* v8 ignore next -- @preserve dotenv keys only accumulate under a file source, so the delta implies supportsFiles here */\n if (!source.supportsFiles) return;\n const mirrored: Record<string, string> = {};\n for (const key of state.dotenvAddedKeys) {\n const value = cache.get(key);\n /* v8 ignore next -- @preserve loader only writes strings, defensive against future cache contents */\n if (typeof value !== 'string') continue;\n mirrored[key] = resolveForMirror(key, value);\n debugVerbose(`mirrored ${key} to the ambient environment`);\n }\n source.writeVars(mirrored);\n debugVerbose(`mirrored ${state.dotenvAddedKeys.size} keys to the ambient environment`);\n}\n\nfunction resolveForMirror(key: string, value: string): string {\n return templateResolver.resolveTemplate(key, value);\n}\n\nexport function determineEnvironment(env?: string | Environment): void {\n if (typeof env === 'number') {\n state.environment = env;\n state.environmentExplicitlySet = true;\n return;\n }\n if (typeof env === 'string') {\n state.environment = parseEnvironment(env) ?? Environment.Development;\n state.environmentExplicitlySet = true;\n return;\n }\n\n const raw = firstEnvKeyValue((key) => readCached(key));\n if (raw === undefined) {\n debugWarn(`no environment set (looked for ${ENV_KEYS.join(', ')}); defaulting to development`);\n state.environment = Environment.Development;\n return;\n }\n const parsed = parseEnvironment(raw);\n if (parsed === undefined) {\n debugWarn(`unrecognized environment \"${raw}\"; defaulting to development`);\n state.environment = Environment.Development;\n return;\n }\n state.environment = parsed;\n}\n\n/**\n * @internal\n */\nexport enum Primitive {\n String,\n Number,\n Boolean,\n BigInt,\n Symbol\n}\n\nconst PRIMITIVE_NAMES: Record<Primitive, string> = {\n [Primitive.String]: 'string',\n [Primitive.Number]: 'number',\n [Primitive.Boolean]: 'boolean',\n [Primitive.BigInt]: 'bigint',\n [Primitive.Symbol]: 'symbol'\n};\n\n// getRaw is the raw string lookup, get is the template-resolved string read. Lazy arrows so the\n// resolver singletons below store envService without calling readPrimitive, which reads\n// templateResolver before it is assigned.\nconst envService: EnvapterService = {\n getRaw: (key) => resolveKeyInput(key).value,\n get: (key, def) => readPrimitive<string, string | undefined>(key, Primitive.String, def)\n};\n\nexport const templateResolver: TemplateResolver = new TemplateResolver(envService);\nexport const valueConverter: ValueConverter = new ValueConverter(envService);\n\nexport function readPrimitive<EnvVarReturnType, DefaultType extends EnvVarReturnType | undefined = undefined>(\n key: EnvKeyInput,\n type: Primitive,\n def?: DefaultType\n): ConditionalReturn<EnvVarReturnType, DefaultType> {\n const { key: resolvedKey, value } = resolveKeyInput(key);\n if (isMissing(value)) {\n if (def !== undefined) debugWarn(`${resolvedKey} is missing or empty, using fallback ${String(def)}`);\n else debugWarn(`${resolvedKey} is missing or empty`);\n return def as ConditionalReturn<EnvVarReturnType, DefaultType>;\n }\n\n const parsed = templateResolver.resolveTemplate(resolvedKey, String(value));\n\n let converted: EnvVarReturnType | undefined;\n if (type === Primitive.Number) converted = BuiltInConverters.number(parsed) as EnvVarReturnType | undefined;\n else if (type === Primitive.Boolean) converted = BuiltInConverters.boolean(parsed) as EnvVarReturnType | undefined;\n else if (type === Primitive.BigInt) converted = BuiltInConverters.bigint(parsed) as EnvVarReturnType | undefined;\n else if (type === Primitive.Symbol) converted = BuiltInConverters.symbol(parsed) as EnvVarReturnType | undefined;\n else converted = BuiltInConverters.string(parsed) as EnvVarReturnType | undefined;\n\n if (converted === undefined) {\n // key and type only, no value: env values can be secrets and verbose logs reach stderr\n debugVerbose(\n `could not convert ${resolvedKey} as ${PRIMITIVE_NAMES[type]}${def !== undefined ? ', using the fallback' : ''}`\n );\n return def as ConditionalReturn<EnvVarReturnType, DefaultType>;\n }\n\n return converted;\n}\n"],"mappings":"qlBAaA,SAAgB,EAAgB,EAAmE,CAE/F,IAAM,EADO,MAAM,QAAQ,CAAQ,EAAI,EAAW,CAAC,CAAQ,EAG3D,GAAI,EAAe,SAAW,EAC1B,MAAM,IAAI,EAAA,IAA8C,gDAAgD,EAG5G,GAAI,EAAe,KAAM,GAAM,OAAO,GAAM,QAAQ,EAChD,MAAM,IAAI,EAAA,IAA8C,mCAAmC,EAG/F,GAAI,EAAe,KAAM,GAAM,EAAE,KAAK,IAAM,EAAE,EAC1C,MAAM,IAAI,EAAA,IAA8C,2CAA2C,EAKvG,IAAI,EACJ,IAAK,IAAM,KAAa,EAAgB,CACpC,IAAM,EAAQ,EAAW,CAAS,EAC9B,OAAU,IAAA,GACd,IAAI,CAAC,EAAU,CAAK,EAAG,MAAO,CAAE,IAAK,EAAW,OAAM,EACtD,IAAiB,CAAE,IAAK,EAAW,OAAM,CADa,CAE1D,CAEA,OAAO,GAAgB,CAAE,IAAK,EAAe,GAAc,MAAO,IAAA,EAAU,CAChF,CAEA,SAAgB,GAAqC,CACjD,GAAI,CAAC,EAAM,WAAY,CACnB,IAAM,EAAS,EAAM,OAEf,EAAsC,CAAE,GAAG,EAAO,SAAS,CAAE,EAE/D,EAAQ,IAAI,IAGhB,GAAI,EAAO,cAAe,CACtB,EAAa,aAAa,EAAM,SAAW,qBAAqB,EAEhE,IAAM,EAAiB,EAAsB,EAC7C,EAAa,yBAAyB,EAAe,SAAW,EAAI,SAAW,EAAe,KAAK,IAAI,GAAG,EAC1G,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AAkB,OAAO,CAAM,EACjE,IAAA,EAAwC,EAAkB,QAAQ,CAAM,EACxE,IAAA,EAAuC,EAAkB,OAAO,CAAM,EACtE,IAAA,EAAuC,EAAkB,OAAO,CAAM,EAC9D,EAAkB,OAAO,CAAM,EAE5C,IAAc,IAAA,IAEd,EACI,qBAAqB,EAAY,MAAM,EAAgB,KAAQ,IAAQ,IAAA,GAAqC,GAAzB,wBACvF,EACO,GAGJ,CACX"}
1
+ {"version":3,"file":"engine.mjs","names":[],"sources":["../../../src/core/engine.ts"],"sourcesContent":["import { BuiltInConverters, ValueConverter } from '../converters';\nimport { ENV_KEYS, Environment, firstEnvKeyValue, parseEnvironment } from './Environment';\nimport { isMissing } from './missing';\nimport { resolveEffectivePaths } from './paths';\nimport { cache, state } from './state';\nimport { TemplateResolver } from '../engine/TemplateResolver';\nimport { debugVerbose, debugWarn } from '../infra/Debug';\nimport { loadDotenv } from '../infra/Dotenv';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { ConditionalReturn, EnvKeyInput } from '../types';\nimport type { EnvapterService } from '../types/Env';\n\nexport function resolveKeyInput(keyInput: EnvKeyInput): { key: string; value: string | undefined } {\n const keys = Array.isArray(keyInput) ? keyInput : [keyInput];\n const normalizedKeys = keys as readonly string[];\n\n if (normalizedKeys.length === 0) {\n throw new EnvaptError(EnvaptErrorCodes.InvalidKeyInput, 'At least one environment key must be provided.');\n }\n\n if (normalizedKeys.some((k) => typeof k !== 'string')) {\n throw new EnvaptError(EnvaptErrorCodes.InvalidKeyInput, 'Environment keys must be strings.');\n }\n\n if (normalizedKeys.some((k) => k.trim() === '')) {\n throw new EnvaptError(EnvaptErrorCodes.InvalidKeyInput, 'Environment keys cannot be empty strings.');\n }\n\n // an empty value falls through to the next key and only comes back when every key is empty\n let firstPresent: { key: string; value: string } | undefined;\n for (const candidate of normalizedKeys) {\n const value = readCached(candidate);\n if (value === undefined) continue;\n if (!isMissing(value)) return { key: candidate, value };\n firstPresent ??= { key: candidate, value };\n }\n\n return firstPresent ?? { key: normalizedKeys[0] as string, value: undefined };\n}\n\nexport function ensureLoaded(): Map<string, unknown> {\n if (!state.cacheBuilt) {\n const source = state.source;\n // the loader writes into this object\n const isolatedEnv: Record<string, string> = { ...source.readVars() };\n\n let added = new Set<string>();\n if (source.supportsFiles) {\n debugVerbose(`base dir: ${state.baseDir ?? 'working directory'}`);\n // outside the try because a missing profile path has to throw\n const effectivePaths = resolveEffectivePaths();\n debugVerbose(`effective .env paths: ${effectivePaths.length === 0 ? '(none)' : effectivePaths.join(', ')}`);\n try {\n added = loadDotenv({\n ...state.userDefinedEnvFileOptions,\n path: effectivePaths,\n processEnv: isolatedEnv,\n readFile: source.readFile.bind(source)\n });\n } catch (error) {\n debugWarn(`failed to load .env: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n state.dotenvAddedKeys = added;\n for (const [key, value] of Object.entries(isolatedEnv)) cache.set(key, value);\n debugVerbose(`cache populated: ${cache.size} keys total`);\n // set before mirroring because template expansion reads the cache\n state.cacheBuilt = true;\n if (state.syncProcessEnv) mirrorToProcessEnv();\n }\n\n return cache;\n}\n\nfunction readCached(key: string): string | undefined {\n const c = ensureLoaded();\n // decorator memoization also stores non-string values in this shared cache\n if (c.has(key)) {\n const cached = c.get(key);\n return typeof cached === 'string' ? cached : undefined;\n }\n const source = state.source;\n if (typeof source.readVar !== 'function') return undefined;\n const value = source.readVar(key);\n // caches misses too\n c.set(key, value);\n return value;\n}\n\nexport function refreshCache(): void {\n // an inferred environment can change once the new vars load\n if (!state.environmentExplicitlySet) state.environment = undefined;\n cache.clear();\n state.cacheBuilt = false;\n state.dotenvAddedKeys = new Set<string>();\n debugVerbose('cache cleared, reloading config');\n ensureLoaded();\n}\n\nexport function mirrorToProcessEnv(): void {\n if (state.dotenvAddedKeys.size === 0) return;\n const source = state.source;\n /* v8 ignore next -- @preserve dotenv keys only accumulate under a file source, so the delta implies supportsFiles here */\n if (!source.supportsFiles) return;\n const mirrored: Record<string, string> = {};\n for (const key of state.dotenvAddedKeys) {\n const value = cache.get(key);\n /* v8 ignore next -- @preserve the loader only writes strings */\n if (typeof value !== 'string') continue;\n mirrored[key] = resolveForMirror(key, value);\n debugVerbose(`mirrored ${key} to the ambient environment`);\n }\n source.writeVars(mirrored);\n debugVerbose(`mirrored ${state.dotenvAddedKeys.size} keys to the ambient environment`);\n}\n\nfunction resolveForMirror(key: string, value: string): string {\n return templateResolver.resolveTemplate(key, value);\n}\n\nexport function determineEnvironment(env?: string | Environment): void {\n if (typeof env === 'number') {\n state.environment = env;\n state.environmentExplicitlySet = true;\n return;\n }\n if (typeof env === 'string') {\n state.environment = parseEnvironment(env) ?? Environment.Development;\n state.environmentExplicitlySet = true;\n return;\n }\n\n const raw = firstEnvKeyValue((key) => readCached(key));\n if (raw === undefined) {\n debugWarn(`no environment set (looked for ${ENV_KEYS.join(', ')}); defaulting to development`);\n state.environment = Environment.Development;\n return;\n }\n const parsed = parseEnvironment(raw);\n if (parsed === undefined) {\n debugWarn(`unrecognized environment \"${raw}\"; defaulting to development`);\n state.environment = Environment.Development;\n return;\n }\n state.environment = parsed;\n}\n\nexport enum Primitive {\n String,\n Number,\n Boolean,\n BigInt,\n Symbol\n}\n\nconst PRIMITIVE_NAMES: Record<Primitive, string> = {\n [Primitive.String]: 'string',\n [Primitive.Number]: 'number',\n [Primitive.Boolean]: 'boolean',\n [Primitive.BigInt]: 'bigint',\n [Primitive.Symbol]: 'symbol'\n};\n\n// arrows because readPrimitive reads templateResolver, which is assigned below\nconst envService: EnvapterService = {\n getRaw: (key) => resolveKeyInput(key).value,\n get: (key, def) => readPrimitive<string, string | undefined>(key, Primitive.String, def)\n};\n\nexport const templateResolver: TemplateResolver = new TemplateResolver(envService);\nexport const valueConverter: ValueConverter = new ValueConverter(envService);\n\nexport function readPrimitive<EnvVarReturnType, DefaultType extends EnvVarReturnType | undefined = undefined>(\n key: EnvKeyInput,\n type: Primitive,\n def?: DefaultType\n): ConditionalReturn<EnvVarReturnType, DefaultType> {\n const { key: resolvedKey, value } = resolveKeyInput(key);\n if (isMissing(value)) {\n if (def !== undefined) debugWarn(`${resolvedKey} is missing or empty, using fallback ${String(def)}`);\n else debugWarn(`${resolvedKey} is missing or empty`);\n return def as ConditionalReturn<EnvVarReturnType, DefaultType>;\n }\n\n const parsed = templateResolver.resolveTemplate(resolvedKey, String(value));\n\n let converted: EnvVarReturnType | undefined;\n if (type === Primitive.Number) converted = BuiltInConverters.number(parsed) as EnvVarReturnType | undefined;\n else if (type === Primitive.Boolean) converted = BuiltInConverters.boolean(parsed) as EnvVarReturnType | undefined;\n else if (type === Primitive.BigInt) converted = BuiltInConverters.bigint(parsed) as EnvVarReturnType | undefined;\n else if (type === Primitive.Symbol) converted = BuiltInConverters.symbol(parsed) as EnvVarReturnType | undefined;\n else converted = BuiltInConverters.string(parsed) as EnvVarReturnType | undefined;\n\n if (converted === undefined) {\n // leave the value out because env values can be secrets\n debugVerbose(\n `could not convert ${resolvedKey} as ${PRIMITIVE_NAMES[type]}${def !== undefined ? ', using the fallback' : ''}`\n );\n return def as ConditionalReturn<EnvVarReturnType, DefaultType>;\n }\n\n return converted;\n}\n"],"mappings":"qlBAaA,SAAgB,EAAgB,EAAmE,CAE/F,IAAM,EADO,MAAM,QAAQ,CAAQ,EAAI,EAAW,CAAC,CAAQ,EAG3D,GAAI,EAAe,SAAW,EAC1B,MAAM,IAAI,EAAA,IAA8C,gDAAgD,EAG5G,GAAI,EAAe,KAAM,GAAM,OAAO,GAAM,QAAQ,EAChD,MAAM,IAAI,EAAA,IAA8C,mCAAmC,EAG/F,GAAI,EAAe,KAAM,GAAM,EAAE,KAAK,IAAM,EAAE,EAC1C,MAAM,IAAI,EAAA,IAA8C,2CAA2C,EAIvG,IAAI,EACJ,IAAK,IAAM,KAAa,EAAgB,CACpC,IAAM,EAAQ,EAAW,CAAS,EAC9B,OAAU,IAAA,GACd,IAAI,CAAC,EAAU,CAAK,EAAG,MAAO,CAAE,IAAK,EAAW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KAAM,EAAK,IAAQ,EAA0C,EAAA,EAAuB,CAAG,CAC3F,EAEa,EAAqC,IAAI,EAAiB,CAAU,EACpE,EAAiC,IAAI,EAAe,CAAU,EAE3E,SAAgB,EACZ,EACA,EACA,EACgD,CAChD,GAAM,CAAE,IAAK,EAAa,SAAU,EAAgB,CAAG,EACvD,GAAI,EAAU,CAAK,EAGf,OADK,EADD,IAAQ,IAAA,GACG,GAAG,EAAY,sBADG,GAAG,EAAY,uCAAuC,OAAO,CAAG,GAC9C,EAC5C,EAGX,IAAM,EAAS,EAAiB,gBAAgB,EAAa,OAAO,CAAK,CAAC,EAEtE,EAeJ,MAdA,CAIK,EAJD,IAAA,EAAuC,EAAkB,OAAO,CAAM,EACjE,IAAA,EAAwC,EAAkB,QAAQ,CAAM,EACxE,IAAA,EAAuC,EAAkB,OAAO,CAAM,EACtE,IAAA,EAAuC,EAAkB,OAAO,CAAM,EAC9D,EAAkB,OAAO,CAAM,EAE5C,IAAc,IAAA,IAEd,EACI,qBAAqB,EAAY,MAAM,EAAgB,KAAQ,IAAQ,IAAA,GAAqC,GAAzB,wBACvF,EACO,GAGJ,CACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"missing.cjs","names":["state"],"sources":["../../../src/core/missing.ts"],"sourcesContent":["import { state } from './state';\n\n// the one missing-check, use it everywhere so behavior stays consistent\nexport function isMissing(value: string | undefined): boolean {\n if (value === undefined || value === '') return true;\n if (state.strict && value.trim() === '') return true;\n return false;\n}\n\n// an explicit undefined fallback counts as no fallback, use it everywhere so behavior stays consistent\nexport function hasFallback(fallback: unknown): boolean {\n return fallback !== undefined;\n}\n"],"mappings":"+BAGA,SAAgB,EAAU,EAAoC,CAG1D,MADA,GADI,IAAU,IAAA,IAAa,IAAU,IACjCA,EAAAA,MAAM,QAAU,EAAM,KAAK,IAAM,GAEzC,CAGA,SAAgB,EAAY,EAA4B,CACpD,OAAO,IAAa,IAAA,EACxB"}
1
+ {"version":3,"file":"missing.cjs","names":["state"],"sources":["../../../src/core/missing.ts"],"sourcesContent":["import { state } from './state';\n\n// every missing-value check goes through this\nexport function isMissing(value: string | undefined): boolean {\n if (value === undefined || value === '') return true;\n if (state.strict && value.trim() === '') return true;\n return false;\n}\n\nexport function hasFallback(fallback: unknown): boolean {\n return fallback !== undefined;\n}\n"],"mappings":"+BAGA,SAAgB,EAAU,EAAoC,CAG1D,MADA,GADI,IAAU,IAAA,IAAa,IAAU,IACjCA,EAAAA,MAAM,QAAU,EAAM,KAAK,IAAM,GAEzC,CAEA,SAAgB,EAAY,EAA4B,CACpD,OAAO,IAAa,IAAA,EACxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"missing.mjs","names":[],"sources":["../../../src/core/missing.ts"],"sourcesContent":["import { state } from './state';\n\n// the one missing-check, use it everywhere so behavior stays consistent\nexport function isMissing(value: string | undefined): boolean {\n if (value === undefined || value === '') return true;\n if (state.strict && value.trim() === '') return true;\n return false;\n}\n\n// an explicit undefined fallback counts as no fallback, use it everywhere so behavior stays consistent\nexport function hasFallback(fallback: unknown): boolean {\n return fallback !== undefined;\n}\n"],"mappings":"oCAGA,SAAgB,EAAU,EAAoC,CAG1D,MADA,GADI,IAAU,IAAA,IAAa,IAAU,IACjC,EAAM,QAAU,EAAM,KAAK,IAAM,GAEzC,CAGA,SAAgB,EAAY,EAA4B,CACpD,OAAO,IAAa,IAAA,EACxB"}
1
+ {"version":3,"file":"missing.mjs","names":[],"sources":["../../../src/core/missing.ts"],"sourcesContent":["import { state } from './state';\n\n// every missing-value check goes through this\nexport function isMissing(value: string | undefined): boolean {\n if (value === undefined || value === '') return true;\n if (state.strict && value.trim() === '') return true;\n return false;\n}\n\nexport function hasFallback(fallback: unknown): boolean {\n return fallback !== undefined;\n}\n"],"mappings":"oCAGA,SAAgB,EAAU,EAAoC,CAG1D,MADA,GADI,IAAU,IAAA,IAAa,IAAU,IACjC,EAAM,QAAU,EAAM,KAAK,IAAM,GAEzC,CAEA,SAAgB,EAAY,EAA4B,CACpD,OAAO,IAAa,IAAA,EACxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"paths.cjs","names":["state","EnvaptError","Environment","firstEnvKeyValue","parseEnvironment"],"sources":["../../../src/core/paths.ts"],"sourcesContent":["import { Environment, firstEnvKeyValue, parseEnvironment } from './Environment';\nimport { state } from './state';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { EnvProfile, FileCapableSource, Source } from '../types';\n\n// No baseDir: candidate returned unchanged so the source resolves it against its own default\n// (process.cwd() on Node). Resolution goes through the source to keep this node-free.\nexport function resolveAgainstBase(candidate: string): string {\n const baseDir = state.baseDir;\n if (baseDir === undefined) return candidate;\n const source = state.source;\n /* v8 ignore next -- @preserve callers are all file-gated, so the source is never bare here */\n if (!source.supportsFiles) return candidate;\n return source.resolvePath(baseDir, candidate);\n}\n\n// File-based config (envPaths/baseDir/configureProfiles) is meaningless without a filesystem, and it\n// throws instead of silently ignoring it on the browser or Workers. Narrows the source so callers\n// can use the file capabilities (resolvePath/normalizeBaseDir) after the check.\nexport function assertFileApiSupported(api: string, source: Source): asserts source is FileCapableSource {\n if (!source.supportsFiles) {\n throw new EnvaptError(\n EnvaptErrorCodes.FileApiUnsupported,\n `${api} requires a filesystem-backed source; the bound source does not support .env files.`\n );\n }\n}\n\n// Existence via the bound source instead of fs.existsSync/accessSync: a file \"exists\" when the source\n// can read it.\nexport function sourceFileExists(path: string): boolean {\n const source = state.source;\n /* v8 ignore next -- @preserve every caller is file-gated, so this never sees a bare source */\n if (!source.supportsFiles) return false;\n return source.readFile(path, 'utf8') !== undefined;\n}\n\n// Precedence is most-specific-wins (matches Vite / Astro / Vocs): `.env.${env}.local` > `.env.${env}`\n// > `.env.local` > `.env`. This differs from dotenv-flow / Next.js, which put `.env.local` above\n// `.env.${env}`. Most-specific-wins keeps a committed `.env.production` authoritative regardless of a\n// stray `.env.local`. Missing files are filtered.\nfunction buildCascadePaths(env: Environment): string[] {\n const envName = Environment[env].toLowerCase();\n return [`.env.${envName}.local`, `.env.${envName}`, '.env.local', '.env']\n .map((name) => resolveAgainstBase(name))\n .filter((p) => sourceFileExists(p));\n}\n\nfunction normalizeProfilePaths(profile: EnvProfile | undefined): string[] {\n if (!profile) return [];\n return Array.isArray(profile.paths) ? profile.paths : [profile.paths];\n}\n\n// the cache is not built yet here, so read the reader directly (readCached would re-enter this build)\nfunction getCascadeEnvironment(): Environment {\n if (state.environment !== undefined) return state.environment;\n\n const source = state.source;\n const vars = source.readVars();\n const raw = firstEnvKeyValue((key) => vars[key] ?? source.readVar?.(key));\n return raw === undefined ? Environment.Development : (parseEnvironment(raw) ?? Environment.Development);\n}\n\n/**\n * Resolve the `.env` paths to load. When `envPaths` was explicitly set, only those load. Otherwise\n * layer any `configureProfiles` paths for the active environment (higher precedence) over the\n * dotenv-flow cascade, all in dotenv first-wins order. `useDefaults: false` drops the cascade.\n */\nexport function resolveEffectivePaths(): string[] {\n if (state.envPathsExplicitlySet) return state.envPaths.map((p) => resolveAgainstBase(p));\n\n const env = getCascadeEnvironment();\n const profileEntry = state.profiles?.[env];\n const profilePaths = normalizeProfilePaths(profileEntry);\n\n // Validate that explicitly configured profile paths exist for the active env.\n if (profilePaths.length > 0) {\n const missing = profilePaths.filter((p) => !sourceFileExists(resolveAgainstBase(p)));\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.EnvFilesNotFound,\n `Environment file not found at path: ${missing.join(', ')}`\n );\n }\n }\n\n const cascade = state.profiles?.useDefaults === false ? [] : buildCascadePaths(env);\n return [...profilePaths.map((p) => resolveAgainstBase(p)), ...cascade];\n}\n"],"mappings":"8FAQA,SAAgB,EAAmB,EAA2B,CAC1D,IAAM,EAAUA,EAAAA,MAAM,QACtB,GAAI,IAAY,IAAA,GAAW,OAAO,EAClC,IAAM,EAASA,EAAAA,MAAM,OAGrB,OADK,EAAO,cACL,EAAO,YAAY,EAAS,CAAS,EADV,CAEtC,CAKA,SAAgB,EAAuB,EAAa,EAAqD,CACrG,GAAI,CAA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AuC,EAAQ,KAAK,IAAI,GAC5D,CAER,CAEA,IAAM,EAAUD,EAAAA,MAAM,UAAU,cAAgB,GAAQ,CAAC,EAAI,EAAkB,CAAG,EAClF,MAAO,CAAC,GAAG,EAAa,IAAK,GAAM,EAAmB,CAAC,CAAC,EAAG,GAAG,CAAO,CACzE"}
1
+ {"version":3,"file":"paths.cjs","names":["state","EnvaptError","Environment","firstEnvKeyValue","parseEnvironment"],"sources":["../../../src/core/paths.ts"],"sourcesContent":["import { Environment, firstEnvKeyValue, parseEnvironment } from './Environment';\nimport { state } from './state';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { EnvProfile, FileCapableSource, Source } from '../types';\n\n// without a baseDir the source resolves the path against its own default, process.cwd() on Node\nexport function resolveAgainstBase(candidate: string): string {\n const baseDir = state.baseDir;\n if (baseDir === undefined) return candidate;\n const source = state.source;\n /* v8 ignore next -- @preserve callers are all file-gated, so the source is never bare here */\n if (!source.supportsFiles) return candidate;\n return source.resolvePath(baseDir, candidate);\n}\n\nexport function assertFileApiSupported(api: string, source: Source): asserts source is FileCapableSource {\n if (!source.supportsFiles) {\n throw new EnvaptError(\n EnvaptErrorCodes.FileApiUnsupported,\n `${api} requires a filesystem-backed source; the bound source does not support .env files.`\n );\n }\n}\n\nexport function sourceFileExists(path: string): boolean {\n const source = state.source;\n /* v8 ignore next -- @preserve every caller is file-gated, so this never sees a bare source */\n if (!source.supportsFiles) return false;\n return source.readFile(path, 'utf8') !== undefined;\n}\n\n// most specific first, since the loader keeps the first value per key unless override is on\nfunction buildCascadePaths(env: Environment): string[] {\n const envName = Environment[env].toLowerCase();\n return [`.env.${envName}.local`, `.env.${envName}`, '.env.local', '.env']\n .map((name) => resolveAgainstBase(name))\n .filter((p) => sourceFileExists(p));\n}\n\nfunction normalizeProfilePaths(profile: EnvProfile | undefined): string[] {\n if (!profile) return [];\n return Array.isArray(profile.paths) ? profile.paths : [profile.paths];\n}\n\n// reads the source directly because readCached would re-enter the cache build\nfunction getCascadeEnvironment(): Environment {\n if (state.environment !== undefined) return state.environment;\n\n const source = state.source;\n const vars = source.readVars();\n const raw = firstEnvKeyValue((key) => vars[key] ?? source.readVar?.(key));\n return raw === undefined ? Environment.Development : (parseEnvironment(raw) ?? Environment.Development);\n}\n\nexport function resolveEffectivePaths(): string[] {\n if (state.envPathsExplicitlySet) return state.envPaths.map((p) => resolveAgainstBase(p));\n\n const env = getCascadeEnvironment();\n const profileEntry = state.profiles?.[env];\n const profilePaths = normalizeProfilePaths(profileEntry);\n\n if (profilePaths.length > 0) {\n const missing = profilePaths.filter((p) => !sourceFileExists(resolveAgainstBase(p)));\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.EnvFilesNotFound,\n `Environment file not found at path: ${missing.join(', ')}`\n );\n }\n }\n\n const cascade = state.profiles?.useDefaults === false ? [] : buildCascadePaths(env);\n return [...profilePaths.map((p) => resolveAgainstBase(p)), ...cascade];\n}\n"],"mappings":"8FAOA,SAAgB,EAAmB,EAA2B,CAC1D,IAAM,EAAUA,EAAAA,MAAM,QACtB,GAAI,IAAY,IAAA,GAAW,OAAO,EAClC,IAAM,EAASA,EAAAA,MAAM,OAGrB,OADK,EAAO,cACL,EAAO,YAAY,EAAS,CAAS,EADV,CAEtC,CAEA,SAAgB,EAAuB,EAAa,EAAqD,CACrG,GAAI,CAAC,EAAO,cACR,MAAM,IAAIC,EAAAA,YAAAA,IAEN,GAAG,EAAI,oFACX,CAER,CAEA,SAAgB,EAAiB,EAAuB,CACpD,IAAM,EAASD,EAAAA,MAAM,OAGrB,OADK,EAAO,cACL,EAAO,SAAS,EAAM,MAAM,IAAM,IAAA,GADP,EAEtC,CAGA,SAAS,EAAkB,EAA4B,CACnD,IAAM,EAAUE,EAAAA,YAAY,EAAI,CAAC,YAAY,EAC7C,MAAO,CAAC,QAAQ,EAAQ,QAAS,QAAQ,IAAW,aAAc,MAAM,CAAC,CACpE,IAAK,GAAS,EAAmB,CAAI,CAAC,CAAC,CACvC,OAAQ,GAAM,EAAiB,CAAC,CAAC,CAC1C,CAEA,SAAS,EAAsB,EAA2C,CAEtE,OADK,EACE,MAAM,QAAQ,EAAQ,KAAK,EAAI,EAAQ,MAAQ,CAAC,EAAQ,KAAK,EAD/C,CAAC,CAE1B,CAGA,SAAS,GAAqC,CAC1C,GAAIF,EAAAA,MAAM,cAAgB,IAAA,GAAW,OAAOA,EAAAA,MAAM,YAElD,IAAM,EAASA,EAAAA,MAAM,OACf,EAAO,EAAO,SAAS,EACvB,EAAMG,EAAAA,iBAAkB,GAAQ,EAAK,IAAQ,EAAO,UAAU,CAAG,CAAC,EACxE,OAAO,IAAQ,IAAA,GAAA,EAAuCC,EAAAA,iBAAiB,CAAG,GAAA,CAC9E,CAEA,SAAgB,GAAkC,CAC9C,GAAIJ,EAAAA,MAAM,sBAAuB,OAAOA,EAAAA,MAAM,SAAS,IAAK,GAAM,EAAmB,CAAC,CAAC,EAEvF,IAAM,EAAM,EAAsB,EAC5B,EAAeA,EAAAA,MAAM,WAAW,GAChC,EAAe,EAAsB,CAAY,EAEvD,GAAI,EAAa,OAAS,EAAG,CACzB,IAAM,EAAU,EAAa,OAAQ,GAAM,CAAC,EAAiB,EAAmB,CAAC,CAAC,CAAC,EACnF,GAAI,EAAQ,OAAS,EACjB,MAAM,IAAIC,EAAAA,YAAAA,IAEN,uCAAuC,EAAQ,KAAK,IAAI,GAC5D,CAER,CAEA,IAAM,EAAUD,EAAAA,MAAM,UAAU,cAAgB,GAAQ,CAAC,EAAI,EAAkB,CAAG,EAClF,MAAO,CAAC,GAAG,EAAa,IAAK,GAAM,EAAmB,CAAC,CAAC,EAAG,GAAG,CAAO,CACzE"}
@@ -1 +1 @@
1
- {"version":3,"file":"paths.mjs","names":[],"sources":["../../../src/core/paths.ts"],"sourcesContent":["import { Environment, firstEnvKeyValue, parseEnvironment } from './Environment';\nimport { state } from './state';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { EnvProfile, FileCapableSource, Source } from '../types';\n\n// No baseDir: candidate returned unchanged so the source resolves it against its own default\n// (process.cwd() on Node). Resolution goes through the source to keep this node-free.\nexport function resolveAgainstBase(candidate: string): string {\n const baseDir = state.baseDir;\n if (baseDir === undefined) return candidate;\n const source = state.source;\n /* v8 ignore next -- @preserve callers are all file-gated, so the source is never bare here */\n if (!source.supportsFiles) return candidate;\n return source.resolvePath(baseDir, candidate);\n}\n\n// File-based config (envPaths/baseDir/configureProfiles) is meaningless without a filesystem, and it\n// throws instead of silently ignoring it on the browser or Workers. Narrows the source so callers\n// can use the file capabilities (resolvePath/normalizeBaseDir) after the check.\nexport function assertFileApiSupported(api: string, source: Source): asserts source is FileCapableSource {\n if (!source.supportsFiles) {\n throw new EnvaptError(\n EnvaptErrorCodes.FileApiUnsupported,\n `${api} requires a filesystem-backed source; the bound source does not support .env files.`\n );\n }\n}\n\n// Existence via the bound source instead of fs.existsSync/accessSync: a file \"exists\" when the source\n// can read it.\nexport function sourceFileExists(path: string): boolean {\n const source = state.source;\n /* v8 ignore next -- @preserve every caller is file-gated, so this never sees a bare source */\n if (!source.supportsFiles) return false;\n return source.readFile(path, 'utf8') !== undefined;\n}\n\n// Precedence is most-specific-wins (matches Vite / Astro / Vocs): `.env.${env}.local` > `.env.${env}`\n// > `.env.local` > `.env`. This differs from dotenv-flow / Next.js, which put `.env.local` above\n// `.env.${env}`. Most-specific-wins keeps a committed `.env.production` authoritative regardless of a\n// stray `.env.local`. Missing files are filtered.\nfunction buildCascadePaths(env: Environment): string[] {\n const envName = Environment[env].toLowerCase();\n return [`.env.${envName}.local`, `.env.${envName}`, '.env.local', '.env']\n .map((name) => resolveAgainstBase(name))\n .filter((p) => sourceFileExists(p));\n}\n\nfunction normalizeProfilePaths(profile: EnvProfile | undefined): string[] {\n if (!profile) return [];\n return Array.isArray(profile.paths) ? profile.paths : [profile.paths];\n}\n\n// the cache is not built yet here, so read the reader directly (readCached would re-enter this build)\nfunction getCascadeEnvironment(): Environment {\n if (state.environment !== undefined) return state.environment;\n\n const source = state.source;\n const vars = source.readVars();\n const raw = firstEnvKeyValue((key) => vars[key] ?? source.readVar?.(key));\n return raw === undefined ? Environment.Development : (parseEnvironment(raw) ?? Environment.Development);\n}\n\n/**\n * Resolve the `.env` paths to load. When `envPaths` was explicitly set, only those load. Otherwise\n * layer any `configureProfiles` paths for the active environment (higher precedence) over the\n * dotenv-flow cascade, all in dotenv first-wins order. `useDefaults: false` drops the cascade.\n */\nexport function resolveEffectivePaths(): string[] {\n if (state.envPathsExplicitlySet) return state.envPaths.map((p) => resolveAgainstBase(p));\n\n const env = getCascadeEnvironment();\n const profileEntry = state.profiles?.[env];\n const profilePaths = normalizeProfilePaths(profileEntry);\n\n // Validate that explicitly configured profile paths exist for the active env.\n if (profilePaths.length > 0) {\n const missing = profilePaths.filter((p) => !sourceFileExists(resolveAgainstBase(p)));\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.EnvFilesNotFound,\n `Environment file not found at path: ${missing.join(', ')}`\n );\n }\n }\n\n const cascade = state.profiles?.useDefaults === false ? [] : buildCascadePaths(env);\n return [...profilePaths.map((p) => resolveAgainstBase(p)), ...cascade];\n}\n"],"mappings":"iLAQA,SAAgB,EAAmB,EAA2B,CAC1D,IAAM,EAAU,EAAM,QACtB,GAAI,IAAY,IAAA,GAAW,OAAO,EAClC,IAAM,EAAS,EAAM,OAGrB,OADK,EAAO,cACL,EAAO,YAAY,EAAS,CAAS,EADV,CAEtC,CAKA,SAAgB,EAAuB,EAAa,EAAqD,CACrG,GAAI,CAAC,EAAO,cACR,MAAM,IAAI,EAAA,IAEN,GAAG,EAAI,oFACX,CAER,CAIA,SAAgB,EAAiB,EAAuB,CACpD,IAAM,EAAS,EAAM,OAGrB,OADK,EAAO,cACL,EAAO,SAAS,EAAM,MAAM,IAAM,IAAA,GADP,EAEtC,CAMA,SAAS,EAAkB,EAA4B,CACnD,IAAM,EAAU,EAAY,EAAI,CAAC,YAAY,EAC7C,MAAO,CAAC,QAAQ,EAAQ,QAAS,QAAQ,IAAW,aAAc,MAAM,CAAC,CACpE,IAAK,GAAS,EAAmB,CAAI,CAAC,CAAC,CACvC,OAAQ,GAAM,EAAiB,CAAC,CAAC,CAC1C,CAEA,SAAS,EAAsB,EAA2C,CAEtE,OADK,EACE,MAAM,QAAQ,EAAQ,KAAK,EAAI,EAAQ,MAAQ,CAAC,EAAQ,KAAK,EAD/C,CAAC,CAE1B,CAGA,SAAS,GAAqC,CAC1C,GAAI,EAAM,cAAgB,IAAA,GAAW,OAAO,EAAM,YAElD,IAAM,EAAS,EAAM,OACf,EAAO,EAAO,SAAS,EACvB,EAAM,EAAkB,GAAQ,EAAK,IAAQ,EAAO,UAAU,CAAG,CAAC,EACxE,OAAO,IAAQ,IAAA,GAAA,EAAuC,EAAiB,CAAG,GAAA,CAC9E,CAOA,SAAgB,GAAkC,CAC9C,GAAI,EAAM,sBAAuB,OAAO,EAAM,SAAS,IAAK,GAAM,EAAmB,CAAC,CAAC,EAEvF,IAAM,EAAM,EAAsB,EAC5B,EAAe,EAAM,WAAW,GAChC,EAAe,EAAsB,CAAY,EAGvD,GAAI,EAAa,OAAS,EAAG,CACzB,IAAM,EAAU,EAAa,OAAQ,GAAM,CAAC,EAAiB,EAAmB,CAAC,CAAC,CAAC,EACnF,GAAI,EAAQ,OAAS,EACjB,MAAM,IAAI,EAAA,IAEN,uCAAuC,EAAQ,KAAK,IAAI,GAC5D,CAER,CAEA,IAAM,EAAU,EAAM,UAAU,cAAgB,GAAQ,CAAC,EAAI,EAAkB,CAAG,EAClF,MAAO,CAAC,GAAG,EAAa,IAAK,GAAM,EAAmB,CAAC,CAAC,EAAG,GAAG,CAAO,CACzE"}
1
+ {"version":3,"file":"paths.mjs","names":[],"sources":["../../../src/core/paths.ts"],"sourcesContent":["import { Environment, firstEnvKeyValue, parseEnvironment } from './Environment';\nimport { state } from './state';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { EnvProfile, FileCapableSource, Source } from '../types';\n\n// without a baseDir the source resolves the path against its own default, process.cwd() on Node\nexport function resolveAgainstBase(candidate: string): string {\n const baseDir = state.baseDir;\n if (baseDir === undefined) return candidate;\n const source = state.source;\n /* v8 ignore next -- @preserve callers are all file-gated, so the source is never bare here */\n if (!source.supportsFiles) return candidate;\n return source.resolvePath(baseDir, candidate);\n}\n\nexport function assertFileApiSupported(api: string, source: Source): asserts source is FileCapableSource {\n if (!source.supportsFiles) {\n throw new EnvaptError(\n EnvaptErrorCodes.FileApiUnsupported,\n `${api} requires a filesystem-backed source; the bound source does not support .env files.`\n );\n }\n}\n\nexport function sourceFileExists(path: string): boolean {\n const source = state.source;\n /* v8 ignore next -- @preserve every caller is file-gated, so this never sees a bare source */\n if (!source.supportsFiles) return false;\n return source.readFile(path, 'utf8') !== undefined;\n}\n\n// most specific first, since the loader keeps the first value per key unless override is on\nfunction buildCascadePaths(env: Environment): string[] {\n const envName = Environment[env].toLowerCase();\n return [`.env.${envName}.local`, `.env.${envName}`, '.env.local', '.env']\n .map((name) => resolveAgainstBase(name))\n .filter((p) => sourceFileExists(p));\n}\n\nfunction normalizeProfilePaths(profile: EnvProfile | undefined): string[] {\n if (!profile) return [];\n return Array.isArray(profile.paths) ? profile.paths : [profile.paths];\n}\n\n// reads the source directly because readCached would re-enter the cache build\nfunction getCascadeEnvironment(): Environment {\n if (state.environment !== undefined) return state.environment;\n\n const source = state.source;\n const vars = source.readVars();\n const raw = firstEnvKeyValue((key) => vars[key] ?? source.readVar?.(key));\n return raw === undefined ? Environment.Development : (parseEnvironment(raw) ?? Environment.Development);\n}\n\nexport function resolveEffectivePaths(): string[] {\n if (state.envPathsExplicitlySet) return state.envPaths.map((p) => resolveAgainstBase(p));\n\n const env = getCascadeEnvironment();\n const profileEntry = state.profiles?.[env];\n const profilePaths = normalizeProfilePaths(profileEntry);\n\n if (profilePaths.length > 0) {\n const missing = profilePaths.filter((p) => !sourceFileExists(resolveAgainstBase(p)));\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.EnvFilesNotFound,\n `Environment file not found at path: ${missing.join(', ')}`\n );\n }\n }\n\n const cascade = state.profiles?.useDefaults === false ? [] : buildCascadePaths(env);\n return [...profilePaths.map((p) => resolveAgainstBase(p)), ...cascade];\n}\n"],"mappings":"iLAOA,SAAgB,EAAmB,EAA2B,CAC1D,IAAM,EAAU,EAAM,QACtB,GAAI,IAAY,IAAA,GAAW,OAAO,EAClC,IAAM,EAAS,EAAM,OAGrB,OADK,EAAO,cACL,EAAO,YAAY,EAAS,CAAS,EADV,CAEtC,CAEA,SAAgB,EAAuB,EAAa,EAAqD,CACrG,GAAI,CAAC,EAAO,cACR,MAAM,IAAI,EAAA,IAEN,GAAG,EAAI,oFACX,CAER,CAEA,SAAgB,EAAiB,EAAuB,CACpD,IAAM,EAAS,EAAM,OAGrB,OADK,EAAO,cACL,EAAO,SAAS,EAAM,MAAM,IAAM,IAAA,GADP,EAEtC,CAGA,SAAS,EAAkB,EAA4B,CACnD,IAAM,EAAU,EAAY,EAAI,CAAC,YAAY,EAC7C,MAAO,CAAC,QAAQ,EAAQ,QAAS,QAAQ,IAAW,aAAc,MAAM,CAAC,CACpE,IAAK,GAAS,EAAmB,CAAI,CAAC,CAAC,CACvC,OAAQ,GAAM,EAAiB,CAAC,CAAC,CAC1C,CAEA,SAAS,EAAsB,EAA2C,CAEtE,OADK,EACE,MAAM,QAAQ,EAAQ,KAAK,EAAI,EAAQ,MAAQ,CAAC,EAAQ,KAAK,EAD/C,CAAC,CAE1B,CAGA,SAAS,GAAqC,CAC1C,GAAI,EAAM,cAAgB,IAAA,GAAW,OAAO,EAAM,YAElD,IAAM,EAAS,EAAM,OACf,EAAO,EAAO,SAAS,EACvB,EAAM,EAAkB,GAAQ,EAAK,IAAQ,EAAO,UAAU,CAAG,CAAC,EACxE,OAAO,IAAQ,IAAA,GAAA,EAAuC,EAAiB,CAAG,GAAA,CAC9E,CAEA,SAAgB,GAAkC,CAC9C,GAAI,EAAM,sBAAuB,OAAO,EAAM,SAAS,IAAK,GAAM,EAAmB,CAAC,CAAC,EAEvF,IAAM,EAAM,EAAsB,EAC5B,EAAe,EAAM,WAAW,GAChC,EAAe,EAAsB,CAAY,EAEvD,GAAI,EAAa,OAAS,EAAG,CACzB,IAAM,EAAU,EAAa,OAAQ,GAAM,CAAC,EAAiB,EAAmB,CAAC,CAAC,CAAC,EACnF,GAAI,EAAQ,OAAS,EACjB,MAAM,IAAI,EAAA,IAEN,uCAAuC,EAAQ,KAAK,IAAI,GAC5D,CAER,CAEA,IAAM,EAAU,EAAM,UAAU,cAAgB,GAAQ,CAAC,EAAI,EAAkB,CAAG,EAClF,MAAO,CAAC,GAAG,EAAa,IAAK,GAAM,EAAmB,CAAC,CAAC,EAAG,GAAG,CAAO,CACzE"}
@@ -1 +1 @@
1
- {"version":3,"file":"state.cjs","names":["UnboundSource"],"sources":["../../../src/core/state.ts"],"sourcesContent":["import { UnboundSource } from '../sources/UnboundSource';\n\nimport type { Environment } from './Environment';\nimport type { EnvFileOptions } from '../infra/Dotenv';\nimport type { FileApiMode, ProfilesConfig, Source } from '../types';\n\n// The engine's mutable state that should not be exposed in the package exports map.\nexport const state = {\n envPaths: ['.env'] as string[],\n envPathsExplicitlySet: false,\n baseDir: undefined as string | undefined,\n userDefinedEnvFileOptions: {} as EnvFileOptions,\n strict: false,\n syncProcessEnv: false,\n fileApiMode: 'warn' as FileApiMode,\n // loader-written keys only (collisions skipped), refilled on every cache rebuild.\n dotenvAddedKeys: new Set<string>(),\n // cache.size can't tell built-and-empty from not-built, so a source resolving to no keys would rebuild on every read without this.\n cacheBuilt: false,\n // unbound by default so non-Node builds throw NoSourceBound on read until useSource() runs.\n source: new UnboundSource() as Source,\n environment: undefined as Environment | undefined,\n environmentExplicitlySet: false,\n profiles: undefined as ProfilesConfig | undefined\n};\n\nexport const cache = new Map<string, unknown>();\n"],"mappings":"gDAOa,EAAQ,CACjB,SAAU,CAAC,MAAM,EACjB,sBAAuB,GACvB,QAAS,IAAA,GACT,0BAA2B,CAAC,EAC5B,OAAQ,GACR,eAAgB,GAChB,YAAa,OAEb,gBAAiB,IAAI,IAErB,WAAY,GAEZ,OAAQ,IAAIA,EAAAA,cACZ,YAAa,IAAA,GACb,yBAA0B,GAC1B,SAAU,IAAA,EACd,EAEa,EAAQ,IAAI"}
1
+ {"version":3,"file":"state.cjs","names":["UnboundSource"],"sources":["../../../src/core/state.ts"],"sourcesContent":["import { UnboundSource } from '../sources/UnboundSource';\n\nimport type { Environment } from './Environment';\nimport type { EnvFileOptions } from '../infra/Dotenv';\nimport type { FileApiMode, ProfilesConfig, Source } from '../types';\n\n// keep this out of the package exports map\nexport const state = {\n envPaths: ['.env'] as string[],\n envPathsExplicitlySet: false,\n baseDir: undefined as string | undefined,\n userDefinedEnvFileOptions: {} as EnvFileOptions,\n strict: false,\n syncProcessEnv: false,\n fileApiMode: 'warn' as FileApiMode,\n // loader-written keys only (collisions skipped), refilled on every cache rebuild.\n dotenvAddedKeys: new Set<string>(),\n // cache.size is 0 both before the build and after a build that found no keys\n cacheBuilt: false,\n // unbound by default so non-Node builds throw NoSourceBound on read until useSource() runs.\n source: new UnboundSource() as Source,\n environment: undefined as Environment | undefined,\n environmentExplicitlySet: false,\n profiles: undefined as ProfilesConfig | undefined\n};\n\nexport const cache = new Map<string, unknown>();\n"],"mappings":"gDAOa,EAAQ,CACjB,SAAU,CAAC,MAAM,EACjB,sBAAuB,GACvB,QAAS,IAAA,GACT,0BAA2B,CAAC,EAC5B,OAAQ,GACR,eAAgB,GAChB,YAAa,OAEb,gBAAiB,IAAI,IAErB,WAAY,GAEZ,OAAQ,IAAIA,EAAAA,cACZ,YAAa,IAAA,GACb,yBAA0B,GAC1B,SAAU,IAAA,EACd,EAEa,EAAQ,IAAI"}
@@ -1 +1 @@
1
- {"version":3,"file":"state.mjs","names":[],"sources":["../../../src/core/state.ts"],"sourcesContent":["import { UnboundSource } from '../sources/UnboundSource';\n\nimport type { Environment } from './Environment';\nimport type { EnvFileOptions } from '../infra/Dotenv';\nimport type { FileApiMode, ProfilesConfig, Source } from '../types';\n\n// The engine's mutable state that should not be exposed in the package exports map.\nexport const state = {\n envPaths: ['.env'] as string[],\n envPathsExplicitlySet: false,\n baseDir: undefined as string | undefined,\n userDefinedEnvFileOptions: {} as EnvFileOptions,\n strict: false,\n syncProcessEnv: false,\n fileApiMode: 'warn' as FileApiMode,\n // loader-written keys only (collisions skipped), refilled on every cache rebuild.\n dotenvAddedKeys: new Set<string>(),\n // cache.size can't tell built-and-empty from not-built, so a source resolving to no keys would rebuild on every read without this.\n cacheBuilt: false,\n // unbound by default so non-Node builds throw NoSourceBound on read until useSource() runs.\n source: new UnboundSource() as Source,\n environment: undefined as Environment | undefined,\n environmentExplicitlySet: false,\n profiles: undefined as ProfilesConfig | undefined\n};\n\nexport const cache = new Map<string, unknown>();\n"],"mappings":"6DAOA,MAAa,EAAQ,CACjB,SAAU,CAAC,MAAM,EACjB,sBAAuB,GACvB,QAAS,IAAA,GACT,0BAA2B,CAAC,EAC5B,OAAQ,GACR,eAAgB,GAChB,YAAa,OAEb,gBAAiB,IAAI,IAErB,WAAY,GAEZ,OAAQ,IAAI,EACZ,YAAa,IAAA,GACb,yBAA0B,GAC1B,SAAU,IAAA,EACd,EAEa,EAAQ,IAAI"}
1
+ {"version":3,"file":"state.mjs","names":[],"sources":["../../../src/core/state.ts"],"sourcesContent":["import { UnboundSource } from '../sources/UnboundSource';\n\nimport type { Environment } from './Environment';\nimport type { EnvFileOptions } from '../infra/Dotenv';\nimport type { FileApiMode, ProfilesConfig, Source } from '../types';\n\n// keep this out of the package exports map\nexport const state = {\n envPaths: ['.env'] as string[],\n envPathsExplicitlySet: false,\n baseDir: undefined as string | undefined,\n userDefinedEnvFileOptions: {} as EnvFileOptions,\n strict: false,\n syncProcessEnv: false,\n fileApiMode: 'warn' as FileApiMode,\n // loader-written keys only (collisions skipped), refilled on every cache rebuild.\n dotenvAddedKeys: new Set<string>(),\n // cache.size is 0 both before the build and after a build that found no keys\n cacheBuilt: false,\n // unbound by default so non-Node builds throw NoSourceBound on read until useSource() runs.\n source: new UnboundSource() as Source,\n environment: undefined as Environment | undefined,\n environmentExplicitlySet: false,\n profiles: undefined as ProfilesConfig | undefined\n};\n\nexport const cache = new Map<string, unknown>();\n"],"mappings":"6DAOA,MAAa,EAAQ,CACjB,SAAU,CAAC,MAAM,EACjB,sBAAuB,GACvB,QAAS,IAAA,GACT,0BAA2B,CAAC,EAC5B,OAAQ,GACR,eAAgB,GAChB,YAAa,OAEb,gBAAiB,IAAI,IAErB,WAAY,GAEZ,OAAQ,IAAI,EACZ,YAAa,IAAA,GACb,yBAA0B,GAC1B,SAAU,IAAA,EACd,EAEa,EAAQ,IAAI"}
@@ -1 +1 @@
1
- {"version":3,"file":"Envapt.cjs","names":["createPropertyDecorator","parseEnvaptOptions"],"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":"wFAwMA,SAAgB,EAA4B,EAAkB,EAAkD,CAC5G,OAAOA,EAAAA,wBAAwB,EAAKC,EAAAA,mBAA8B,CAAO,CAAC,CAC9E"}
1
+ {"version":3,"file":"Envapt.cjs","names":["createPropertyDecorator","parseEnvaptOptions"],"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\n * \\@Envapt('APP_URL', { converter: Converters.Url, fallback: new URL('http://localhost:3000') })\n * static readonly url: URL;\n *\n * // reads 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. Pairing `required: true` with `fallback` matches no overload at\n * compile time, and a call that bypasses the types throws `InvalidUserDefinedConfig` at runtime.\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 * A `validate` that returns a Promise throws `InvalidUserDefinedConfig` at runtime. Pairing\n * `schema` with `converter` matches no overload at compile time, and a call that bypasses the\n * types throws `InvalidUserDefinedConfig` at runtime.\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":"wFAuMA,SAAgB,EAA4B,EAAkB,EAAkD,CAC5G,OAAOA,EAAAA,wBAAwB,EAAKC,EAAAA,mBAA8B,CAAO,CAAC,CAC9E"}
@@ -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?: { 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
+ {"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\n * \\@Envapt('APP_URL', { converter: Converters.Url, fallback: new URL('http://localhost:3000') })\n * static readonly url: URL;\n *\n * // reads 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. Pairing `required: true` with `fallback` matches no overload at\n * compile time, and a call that bypasses the types throws `InvalidUserDefinedConfig` at runtime.\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 * A `validate` that returns a Promise throws `InvalidUserDefinedConfig` at runtime. Pairing\n * `schema` with `converter` matches no overload at compile time, and a call that bypasses the\n * types throws `InvalidUserDefinedConfig` at runtime.\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":"uIAuMA,SAAgB,EAA4B,EAAkB,EAAkD,CAC5G,OAAO,EAAwB,EAAK,EAA8B,CAAO,CAAC,CAC9E"}