envapt 5.1.1 → 5.2.0-next.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.
- package/CHANGELOG.md +46 -0
- package/README.md +23 -5
- package/dist/browser/Debug.mjs +2 -0
- package/dist/browser/Debug.mjs.map +1 -0
- package/dist/{Dotenv.d.mts → browser/Dotenv.d.mts} +1 -1
- package/dist/browser/Dotenv.mjs +3 -0
- package/dist/browser/Dotenv.mjs.map +1 -0
- package/dist/browser/Envapter.mjs.map +1 -0
- package/dist/{Error.d.mts → browser/Error.d.mts} +6 -2
- package/dist/{Error.mjs → browser/Error.mjs} +1 -1
- package/dist/browser/Error.mjs.map +1 -0
- package/dist/browser/TemplateResolver.mjs.map +1 -0
- package/dist/browser/Validators.mjs +2 -0
- package/dist/browser/Validators.mjs.map +1 -0
- package/dist/browser/converters/BuiltInConverters.mjs +2 -0
- package/dist/browser/converters/BuiltInConverters.mjs.map +1 -0
- package/dist/browser/converters/Converters.mjs.map +1 -0
- package/dist/browser/converters/ListOfBuiltInConverters.mjs.map +1 -0
- package/dist/browser/converters/ValueConverter.mjs +2 -0
- package/dist/browser/converters/ValueConverter.mjs.map +1 -0
- package/dist/browser/core/AdvancedMethods.mjs.map +1 -0
- package/dist/{core → browser/core}/EnvapterBase.d.mts +15 -45
- package/dist/browser/core/EnvapterBase.mjs +2 -0
- package/dist/browser/core/EnvapterBase.mjs.map +1 -0
- package/dist/{core → browser/core}/EnvironmentMethods.d.mts +13 -30
- package/dist/browser/core/EnvironmentMethods.mjs +2 -0
- package/dist/browser/core/EnvironmentMethods.mjs.map +1 -0
- package/dist/browser/core/PrimitiveMethods.mjs +2 -0
- package/dist/browser/core/PrimitiveMethods.mjs.map +1 -0
- package/dist/{decorators → browser/decorators}/Envapt.d.mts +1 -1
- package/dist/browser/decorators/Envapt.mjs.map +1 -0
- package/dist/browser/decorators/SugarDecorators.mjs.map +1 -0
- package/dist/browser/decorators/createPropertyDecorator.mjs +2 -0
- package/dist/browser/decorators/createPropertyDecorator.mjs.map +1 -0
- package/dist/{index.d.mts → browser/index.d.mts} +7 -4
- package/dist/browser/index.mjs +2 -0
- package/dist/browser/index.mjs.map +1 -0
- package/dist/browser/installFileApiStubs.mjs +2 -0
- package/dist/browser/installFileApiStubs.mjs.map +1 -0
- package/dist/browser/runtime.mjs +2 -0
- package/dist/browser/runtime.mjs.map +1 -0
- package/dist/browser/sources/ManualEnvSource.d.mts +19 -0
- package/dist/browser/sources/ManualEnvSource.mjs +2 -0
- package/dist/browser/sources/ManualEnvSource.mjs.map +1 -0
- package/dist/browser/sources/UnboundEnvSource.mjs +2 -0
- package/dist/browser/sources/UnboundEnvSource.mjs.map +1 -0
- package/dist/browser/sources/WorkerEnvSource.d.mts +19 -0
- package/dist/browser/sources/WorkerEnvSource.mjs +2 -0
- package/dist/browser/sources/WorkerEnvSource.mjs.map +1 -0
- package/dist/browser/sources/coerce.mjs +2 -0
- package/dist/browser/sources/coerce.mjs.map +1 -0
- package/dist/{types → browser/types}/Options.d.mts +2 -2
- package/dist/browser/types/Source.d.mts +44 -0
- package/dist/node/Debug.cjs +2 -0
- package/dist/node/Debug.cjs.map +1 -0
- package/dist/node/Debug.d.mts +13 -0
- package/dist/node/Debug.mjs +2 -0
- package/dist/node/Debug.mjs.map +1 -0
- package/dist/node/Dotenv.cjs +3 -0
- package/dist/node/Dotenv.cjs.map +1 -0
- package/dist/{Dotenv.d.cts → node/Dotenv.d.cts} +1 -1
- package/dist/node/Dotenv.d.mts +17 -0
- package/dist/node/Dotenv.mjs +3 -0
- package/dist/node/Dotenv.mjs.map +1 -0
- package/dist/node/Envapter.cjs.map +1 -0
- package/dist/node/Envapter.d.mts +70 -0
- package/dist/node/Envapter.mjs +2 -0
- package/dist/node/Envapter.mjs.map +1 -0
- package/dist/node/Error.cjs +2 -0
- package/dist/node/Error.cjs.map +1 -0
- package/dist/{Error.d.cts → node/Error.d.cts} +6 -2
- package/dist/node/Error.d.mts +72 -0
- package/dist/{Error.cjs → node/Error.mjs} +2 -2
- package/dist/node/Error.mjs.map +1 -0
- package/dist/node/NodeEnvapter.cjs +2 -0
- package/dist/node/NodeEnvapter.cjs.map +1 -0
- package/dist/node/NodeEnvapter.d.cts +73 -0
- package/dist/node/NodeEnvapter.d.mts +73 -0
- package/dist/node/NodeEnvapter.mjs +2 -0
- package/dist/node/NodeEnvapter.mjs.map +1 -0
- package/dist/node/StandardSchema.d.mts +59 -0
- package/dist/node/TemplateResolver.cjs.map +1 -0
- package/dist/node/TemplateResolver.d.mts +17 -0
- package/dist/node/TemplateResolver.mjs +2 -0
- package/dist/node/TemplateResolver.mjs.map +1 -0
- package/dist/node/Validators.cjs +2 -0
- package/dist/node/Validators.cjs.map +1 -0
- package/dist/node/Validators.mjs +2 -0
- package/dist/node/Validators.mjs.map +1 -0
- package/dist/node/config.cjs +2 -0
- package/dist/node/config.cjs.map +1 -0
- package/dist/node/config.mjs +2 -0
- package/dist/node/config.mjs.map +1 -0
- package/dist/node/converters/BuiltInConverters.cjs +2 -0
- package/dist/node/converters/BuiltInConverters.cjs.map +1 -0
- package/dist/node/converters/BuiltInConverters.mjs +2 -0
- package/dist/node/converters/BuiltInConverters.mjs.map +1 -0
- package/dist/node/converters/Converters.cjs.map +1 -0
- package/dist/node/converters/Converters.d.mts +93 -0
- package/dist/node/converters/Converters.mjs +2 -0
- package/dist/node/converters/Converters.mjs.map +1 -0
- package/dist/node/converters/ListOfBuiltInConverters.cjs.map +1 -0
- package/dist/node/converters/ListOfBuiltInConverters.mjs +2 -0
- package/dist/node/converters/ListOfBuiltInConverters.mjs.map +1 -0
- package/dist/node/converters/ValueConverter.cjs.map +1 -0
- package/dist/node/converters/ValueConverter.d.mts +25 -0
- package/dist/node/converters/ValueConverter.mjs.map +1 -0
- package/dist/node/core/AdvancedMethods.cjs.map +1 -0
- package/dist/node/core/AdvancedMethods.d.mts +76 -0
- package/dist/node/core/AdvancedMethods.mjs +2 -0
- package/dist/node/core/AdvancedMethods.mjs.map +1 -0
- package/dist/node/core/EnvapterBase.cjs +2 -0
- package/dist/node/core/EnvapterBase.cjs.map +1 -0
- package/dist/{core → node/core}/EnvapterBase.d.cts +15 -45
- package/dist/node/core/EnvapterBase.d.mts +75 -0
- package/dist/node/core/EnvapterBase.mjs +2 -0
- package/dist/node/core/EnvapterBase.mjs.map +1 -0
- package/dist/node/core/EnvironmentMethods.cjs +2 -0
- package/dist/node/core/EnvironmentMethods.cjs.map +1 -0
- package/dist/{core → node/core}/EnvironmentMethods.d.cts +12 -29
- package/dist/node/core/EnvironmentMethods.d.mts +115 -0
- package/dist/node/core/EnvironmentMethods.mjs +2 -0
- package/dist/node/core/EnvironmentMethods.mjs.map +1 -0
- package/dist/node/core/PrimitiveMethods.cjs.map +1 -0
- package/dist/node/core/PrimitiveMethods.d.mts +70 -0
- package/dist/node/core/PrimitiveMethods.mjs.map +1 -0
- package/dist/node/decorators/Envapt.cjs.map +1 -0
- package/dist/{decorators → node/decorators}/Envapt.d.cts +1 -1
- package/dist/node/decorators/Envapt.d.mts +233 -0
- package/dist/node/decorators/Envapt.mjs +2 -0
- package/dist/node/decorators/Envapt.mjs.map +1 -0
- package/dist/node/decorators/SugarDecorators.cjs.map +1 -0
- package/dist/node/decorators/SugarDecorators.d.mts +34 -0
- package/dist/node/decorators/SugarDecorators.mjs +2 -0
- package/dist/node/decorators/SugarDecorators.mjs.map +1 -0
- package/dist/node/decorators/createPropertyDecorator.cjs.map +1 -0
- package/dist/node/decorators/createPropertyDecorator.mjs.map +1 -0
- package/dist/node/index.cjs +1 -0
- package/dist/node/index.d.cts +18 -0
- package/dist/node/index.d.mts +18 -0
- package/dist/node/index.mjs +1 -0
- package/dist/node/runtime.cjs +2 -0
- package/dist/node/runtime.cjs.map +1 -0
- package/dist/node/runtime.mjs +2 -0
- package/dist/node/runtime.mjs.map +1 -0
- package/dist/node/sources/ManualEnvSource.cjs +2 -0
- package/dist/node/sources/ManualEnvSource.cjs.map +1 -0
- package/dist/node/sources/ManualEnvSource.d.cts +19 -0
- package/dist/node/sources/ManualEnvSource.d.mts +19 -0
- package/dist/node/sources/ManualEnvSource.mjs +2 -0
- package/dist/node/sources/ManualEnvSource.mjs.map +1 -0
- package/dist/node/sources/NodeEnvSource.cjs +2 -0
- package/dist/node/sources/NodeEnvSource.cjs.map +1 -0
- package/dist/node/sources/NodeEnvSource.d.cts +20 -0
- package/dist/node/sources/NodeEnvSource.d.mts +20 -0
- package/dist/node/sources/NodeEnvSource.mjs +2 -0
- package/dist/node/sources/NodeEnvSource.mjs.map +1 -0
- package/dist/node/sources/UnboundEnvSource.cjs +2 -0
- package/dist/node/sources/UnboundEnvSource.cjs.map +1 -0
- package/dist/node/sources/UnboundEnvSource.mjs +2 -0
- package/dist/node/sources/UnboundEnvSource.mjs.map +1 -0
- package/dist/node/sources/WorkerEnvSource.cjs +2 -0
- package/dist/node/sources/WorkerEnvSource.cjs.map +1 -0
- package/dist/node/sources/WorkerEnvSource.d.cts +19 -0
- package/dist/node/sources/WorkerEnvSource.d.mts +19 -0
- package/dist/node/sources/WorkerEnvSource.mjs +2 -0
- package/dist/node/sources/WorkerEnvSource.mjs.map +1 -0
- package/dist/node/sources/coerce.cjs +2 -0
- package/dist/node/sources/coerce.cjs.map +1 -0
- package/dist/node/sources/coerce.mjs +2 -0
- package/dist/node/sources/coerce.mjs.map +1 -0
- package/dist/node/types/Conversion.d.mts +128 -0
- package/dist/node/types/Env.d.mts +17 -0
- package/dist/{types → node/types}/Options.d.cts +2 -2
- package/dist/node/types/Options.d.mts +39 -0
- package/dist/node/types/Schema.d.mts +12 -0
- package/dist/node/types/Source.d.cts +44 -0
- package/dist/node/types/Source.d.mts +44 -0
- package/dist/workerd/Debug.d.mts +13 -0
- package/dist/workerd/Debug.mjs +2 -0
- package/dist/workerd/Debug.mjs.map +1 -0
- package/dist/workerd/Dotenv.d.mts +17 -0
- package/dist/workerd/Dotenv.mjs +3 -0
- package/dist/workerd/Dotenv.mjs.map +1 -0
- package/dist/workerd/Envapter.d.mts +70 -0
- package/dist/workerd/Envapter.mjs +2 -0
- package/dist/workerd/Envapter.mjs.map +1 -0
- package/dist/workerd/Error.d.mts +72 -0
- package/dist/workerd/Error.mjs +2 -0
- package/dist/workerd/Error.mjs.map +1 -0
- package/dist/workerd/StandardSchema.d.mts +59 -0
- package/dist/workerd/TemplateResolver.d.mts +17 -0
- package/dist/workerd/TemplateResolver.mjs +2 -0
- package/dist/workerd/TemplateResolver.mjs.map +1 -0
- package/dist/workerd/Validators.mjs +2 -0
- package/dist/workerd/Validators.mjs.map +1 -0
- package/dist/workerd/converters/BuiltInConverters.mjs +2 -0
- package/dist/workerd/converters/BuiltInConverters.mjs.map +1 -0
- package/dist/workerd/converters/Converters.d.mts +93 -0
- package/dist/workerd/converters/Converters.mjs +2 -0
- package/dist/workerd/converters/Converters.mjs.map +1 -0
- package/dist/workerd/converters/ListOfBuiltInConverters.mjs +2 -0
- package/dist/workerd/converters/ListOfBuiltInConverters.mjs.map +1 -0
- package/dist/workerd/converters/ValueConverter.d.mts +25 -0
- package/dist/workerd/converters/ValueConverter.mjs +2 -0
- package/dist/workerd/converters/ValueConverter.mjs.map +1 -0
- package/dist/workerd/core/AdvancedMethods.d.mts +76 -0
- package/dist/workerd/core/AdvancedMethods.mjs +2 -0
- package/dist/workerd/core/AdvancedMethods.mjs.map +1 -0
- package/dist/workerd/core/EnvapterBase.d.mts +75 -0
- package/dist/workerd/core/EnvapterBase.mjs +2 -0
- package/dist/workerd/core/EnvapterBase.mjs.map +1 -0
- package/dist/workerd/core/EnvironmentMethods.d.mts +115 -0
- package/dist/workerd/core/EnvironmentMethods.mjs +2 -0
- package/dist/workerd/core/EnvironmentMethods.mjs.map +1 -0
- package/dist/workerd/core/PrimitiveMethods.d.mts +70 -0
- package/dist/workerd/core/PrimitiveMethods.mjs +2 -0
- package/dist/workerd/core/PrimitiveMethods.mjs.map +1 -0
- package/dist/workerd/decorators/Envapt.d.mts +233 -0
- package/dist/workerd/decorators/Envapt.mjs +2 -0
- package/dist/workerd/decorators/Envapt.mjs.map +1 -0
- package/dist/workerd/decorators/SugarDecorators.d.mts +34 -0
- package/dist/workerd/decorators/SugarDecorators.mjs +2 -0
- package/dist/workerd/decorators/SugarDecorators.mjs.map +1 -0
- package/dist/workerd/decorators/createPropertyDecorator.mjs +2 -0
- package/dist/workerd/decorators/createPropertyDecorator.mjs.map +1 -0
- package/dist/workerd/index.d.mts +17 -0
- package/dist/workerd/index.mjs +2 -0
- package/dist/workerd/index.mjs.map +1 -0
- package/dist/workerd/installFileApiStubs.mjs +2 -0
- package/dist/workerd/installFileApiStubs.mjs.map +1 -0
- package/dist/workerd/runtime.mjs +2 -0
- package/dist/workerd/runtime.mjs.map +1 -0
- package/dist/workerd/sources/ManualEnvSource.d.mts +19 -0
- package/dist/workerd/sources/ManualEnvSource.mjs +2 -0
- package/dist/workerd/sources/ManualEnvSource.mjs.map +1 -0
- package/dist/workerd/sources/UnboundEnvSource.mjs +2 -0
- package/dist/workerd/sources/UnboundEnvSource.mjs.map +1 -0
- package/dist/workerd/sources/WorkerEnvSource.d.mts +19 -0
- package/dist/workerd/sources/WorkerEnvSource.mjs +2 -0
- package/dist/workerd/sources/WorkerEnvSource.mjs.map +1 -0
- package/dist/workerd/sources/coerce.mjs +2 -0
- package/dist/workerd/sources/coerce.mjs.map +1 -0
- package/dist/workerd/types/Conversion.d.mts +128 -0
- package/dist/workerd/types/Env.d.mts +17 -0
- package/dist/workerd/types/Options.d.mts +39 -0
- package/dist/workerd/types/Schema.d.mts +12 -0
- package/dist/workerd/types/Source.d.mts +44 -0
- package/package.json +63 -20
- package/dist/Debug.cjs +0 -2
- package/dist/Debug.cjs.map +0 -1
- package/dist/Debug.d.cts.map +0 -1
- package/dist/Debug.d.mts.map +0 -1
- package/dist/Debug.mjs +0 -2
- package/dist/Debug.mjs.map +0 -1
- package/dist/Dotenv.cjs +0 -3
- package/dist/Dotenv.cjs.map +0 -1
- package/dist/Dotenv.d.cts.map +0 -1
- package/dist/Dotenv.d.mts.map +0 -1
- package/dist/Dotenv.mjs +0 -3
- package/dist/Dotenv.mjs.map +0 -1
- package/dist/Envapter.cjs.map +0 -1
- package/dist/Envapter.d.cts.map +0 -1
- package/dist/Envapter.d.mts.map +0 -1
- package/dist/Envapter.mjs.map +0 -1
- package/dist/Error.cjs.map +0 -1
- package/dist/Error.d.cts.map +0 -1
- package/dist/Error.d.mts.map +0 -1
- package/dist/Error.mjs.map +0 -1
- package/dist/StandardSchema.d.cts.map +0 -1
- package/dist/StandardSchema.d.mts.map +0 -1
- package/dist/TemplateResolver.cjs.map +0 -1
- package/dist/TemplateResolver.d.cts.map +0 -1
- package/dist/TemplateResolver.d.mts.map +0 -1
- package/dist/TemplateResolver.mjs.map +0 -1
- package/dist/Validators.cjs +0 -2
- package/dist/Validators.cjs.map +0 -1
- package/dist/Validators.mjs +0 -2
- package/dist/Validators.mjs.map +0 -1
- package/dist/config.cjs +0 -2
- package/dist/config.cjs.map +0 -1
- package/dist/config.mjs +0 -2
- package/dist/config.mjs.map +0 -1
- package/dist/converters/BuiltInConverters.cjs +0 -2
- package/dist/converters/BuiltInConverters.cjs.map +0 -1
- package/dist/converters/BuiltInConverters.mjs +0 -2
- package/dist/converters/BuiltInConverters.mjs.map +0 -1
- package/dist/converters/Converters.cjs.map +0 -1
- package/dist/converters/Converters.d.cts.map +0 -1
- package/dist/converters/Converters.d.mts.map +0 -1
- package/dist/converters/Converters.mjs.map +0 -1
- package/dist/converters/ListOfBuiltInConverters.cjs.map +0 -1
- package/dist/converters/ListOfBuiltInConverters.mjs.map +0 -1
- package/dist/converters/ValueConverter.cjs.map +0 -1
- package/dist/converters/ValueConverter.d.cts.map +0 -1
- package/dist/converters/ValueConverter.d.mts.map +0 -1
- package/dist/converters/ValueConverter.mjs.map +0 -1
- package/dist/core/AdvancedMethods.cjs.map +0 -1
- package/dist/core/AdvancedMethods.d.cts.map +0 -1
- package/dist/core/AdvancedMethods.d.mts.map +0 -1
- package/dist/core/AdvancedMethods.mjs.map +0 -1
- package/dist/core/EnvapterBase.cjs +0 -2
- package/dist/core/EnvapterBase.cjs.map +0 -1
- package/dist/core/EnvapterBase.d.cts.map +0 -1
- package/dist/core/EnvapterBase.d.mts.map +0 -1
- package/dist/core/EnvapterBase.mjs +0 -2
- package/dist/core/EnvapterBase.mjs.map +0 -1
- package/dist/core/EnvironmentMethods.cjs +0 -2
- package/dist/core/EnvironmentMethods.cjs.map +0 -1
- package/dist/core/EnvironmentMethods.d.cts.map +0 -1
- package/dist/core/EnvironmentMethods.d.mts.map +0 -1
- package/dist/core/EnvironmentMethods.mjs +0 -2
- package/dist/core/EnvironmentMethods.mjs.map +0 -1
- package/dist/core/PrimitiveMethods.cjs.map +0 -1
- package/dist/core/PrimitiveMethods.d.cts.map +0 -1
- package/dist/core/PrimitiveMethods.d.mts.map +0 -1
- package/dist/core/PrimitiveMethods.mjs.map +0 -1
- package/dist/decorators/Envapt.cjs.map +0 -1
- package/dist/decorators/Envapt.d.cts.map +0 -1
- package/dist/decorators/Envapt.d.mts.map +0 -1
- package/dist/decorators/Envapt.mjs.map +0 -1
- package/dist/decorators/SugarDecorators.cjs.map +0 -1
- package/dist/decorators/SugarDecorators.d.cts.map +0 -1
- package/dist/decorators/SugarDecorators.d.mts.map +0 -1
- package/dist/decorators/SugarDecorators.mjs.map +0 -1
- package/dist/decorators/createPropertyDecorator.cjs.map +0 -1
- package/dist/decorators/createPropertyDecorator.mjs.map +0 -1
- package/dist/index.cjs +0 -1
- package/dist/index.d.cts +0 -14
- package/dist/index.mjs +0 -1
- package/dist/types/Conversion.d.cts.map +0 -1
- package/dist/types/Conversion.d.mts.map +0 -1
- package/dist/types/Env.d.cts.map +0 -1
- package/dist/types/Env.d.mts.map +0 -1
- package/dist/types/Options.d.cts.map +0 -1
- package/dist/types/Options.d.mts.map +0 -1
- package/dist/types/Schema.d.cts.map +0 -1
- package/dist/types/Schema.d.mts.map +0 -1
- /package/dist/{Debug.d.mts → browser/Debug.d.mts} +0 -0
- /package/dist/{Envapter.d.mts → browser/Envapter.d.mts} +0 -0
- /package/dist/{Envapter.mjs → browser/Envapter.mjs} +0 -0
- /package/dist/{StandardSchema.d.mts → browser/StandardSchema.d.mts} +0 -0
- /package/dist/{TemplateResolver.d.mts → browser/TemplateResolver.d.mts} +0 -0
- /package/dist/{TemplateResolver.mjs → browser/TemplateResolver.mjs} +0 -0
- /package/dist/{converters → browser/converters}/Converters.d.mts +0 -0
- /package/dist/{converters → browser/converters}/Converters.mjs +0 -0
- /package/dist/{converters → browser/converters}/ListOfBuiltInConverters.mjs +0 -0
- /package/dist/{converters → browser/converters}/ValueConverter.d.mts +0 -0
- /package/dist/{core → browser/core}/AdvancedMethods.d.mts +0 -0
- /package/dist/{core → browser/core}/AdvancedMethods.mjs +0 -0
- /package/dist/{core → browser/core}/PrimitiveMethods.d.mts +0 -0
- /package/dist/{decorators → browser/decorators}/Envapt.mjs +0 -0
- /package/dist/{decorators → browser/decorators}/SugarDecorators.d.mts +0 -0
- /package/dist/{decorators → browser/decorators}/SugarDecorators.mjs +0 -0
- /package/dist/{types → browser/types}/Conversion.d.mts +0 -0
- /package/dist/{types → browser/types}/Env.d.mts +0 -0
- /package/dist/{types → browser/types}/Schema.d.mts +0 -0
- /package/dist/{Debug.d.cts → node/Debug.d.cts} +0 -0
- /package/dist/{Envapter.cjs → node/Envapter.cjs} +0 -0
- /package/dist/{Envapter.d.cts → node/Envapter.d.cts} +0 -0
- /package/dist/{StandardSchema.d.cts → node/StandardSchema.d.cts} +0 -0
- /package/dist/{TemplateResolver.cjs → node/TemplateResolver.cjs} +0 -0
- /package/dist/{TemplateResolver.d.cts → node/TemplateResolver.d.cts} +0 -0
- /package/dist/{_virtual → node/_virtual}/_rolldown/runtime.cjs +0 -0
- /package/dist/{config.d.cts → node/config.d.cts} +0 -0
- /package/dist/{config.d.mts → node/config.d.mts} +0 -0
- /package/dist/{converters → node/converters}/Converters.cjs +0 -0
- /package/dist/{converters → node/converters}/Converters.d.cts +0 -0
- /package/dist/{converters → node/converters}/ListOfBuiltInConverters.cjs +0 -0
- /package/dist/{converters → node/converters}/ValueConverter.cjs +0 -0
- /package/dist/{converters → node/converters}/ValueConverter.d.cts +0 -0
- /package/dist/{converters → node/converters}/ValueConverter.mjs +0 -0
- /package/dist/{core → node/core}/AdvancedMethods.cjs +0 -0
- /package/dist/{core → node/core}/AdvancedMethods.d.cts +0 -0
- /package/dist/{core → node/core}/PrimitiveMethods.cjs +0 -0
- /package/dist/{core → node/core}/PrimitiveMethods.d.cts +0 -0
- /package/dist/{core → node/core}/PrimitiveMethods.mjs +0 -0
- /package/dist/{decorators → node/decorators}/Envapt.cjs +0 -0
- /package/dist/{decorators → node/decorators}/SugarDecorators.cjs +0 -0
- /package/dist/{decorators → node/decorators}/SugarDecorators.d.cts +0 -0
- /package/dist/{decorators → node/decorators}/createPropertyDecorator.cjs +0 -0
- /package/dist/{decorators → node/decorators}/createPropertyDecorator.mjs +0 -0
- /package/dist/{types → node/types}/Conversion.d.cts +0 -0
- /package/dist/{types → node/types}/Env.d.cts +0 -0
- /package/dist/{types → node/types}/Schema.d.cts +0 -0
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { DebugLevel } from "../Debug.cjs";
|
|
2
2
|
import { EnvFileOptions } from "../Dotenv.cjs";
|
|
3
3
|
import { EnvKeyInput } from "../types/Env.cjs";
|
|
4
|
+
import { EnvSource, FileEnvSource } from "../types/Source.cjs";
|
|
4
5
|
|
|
5
6
|
//#region src/core/EnvapterBase.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Base class for environment variable management
|
|
8
|
-
* Handles configuration, caching, and basic environment loading
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
7
|
+
/** @internal */
|
|
11
8
|
declare abstract class EnvapterBase {
|
|
12
9
|
protected static _envPaths: string[];
|
|
13
10
|
protected static _envPathsExplicitlySet: boolean;
|
|
@@ -16,6 +13,7 @@ declare abstract class EnvapterBase {
|
|
|
16
13
|
protected static _strict: boolean;
|
|
17
14
|
protected static _syncProcessEnv: boolean;
|
|
18
15
|
protected static _dotenvAddedKeys: Set<string>;
|
|
16
|
+
protected static _source: EnvSource;
|
|
19
17
|
/**
|
|
20
18
|
* Enable or disable strict mode. Default `false`. Setting refreshes the cache so
|
|
21
19
|
* previously-cached converted values get re-evaluated under the new rule.
|
|
@@ -23,9 +21,9 @@ declare abstract class EnvapterBase {
|
|
|
23
21
|
static set strict(value: boolean);
|
|
24
22
|
static get strict(): boolean;
|
|
25
23
|
/**
|
|
26
|
-
* Set the debug log level. Defaults to `silent`. When unset, reads `ENVAPT_DEBUG` from
|
|
27
|
-
*
|
|
28
|
-
*
|
|
24
|
+
* Set the debug log level. Defaults to `silent`. When unset, reads `ENVAPT_DEBUG` from the
|
|
25
|
+
* bound source on first access; the setter overrides any env-var value. Output goes to stderr
|
|
26
|
+
* on Node (the console elsewhere), prefixed with `[envapt]`.
|
|
29
27
|
*/
|
|
30
28
|
static set debug(level: DebugLevel);
|
|
31
29
|
static get debug(): DebugLevel;
|
|
@@ -43,46 +41,11 @@ declare abstract class EnvapterBase {
|
|
|
43
41
|
static set syncProcessEnv(value: boolean);
|
|
44
42
|
static get syncProcessEnv(): boolean;
|
|
45
43
|
protected static treatAsMissing(value: string | undefined): boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Set custom .env file paths. Accepts either a single path or array of paths.
|
|
48
|
-
* Setting new paths clears the cache and reloads environment variables.
|
|
49
|
-
*
|
|
50
|
-
* When set, this takes absolute precedence. The dotenv-flow auto-cascade and any
|
|
51
|
-
* {@link configureProfiles} configuration are ignored.
|
|
52
|
-
*/
|
|
53
|
-
static set envPaths(paths: string[] | string);
|
|
54
|
-
/**
|
|
55
|
-
* Get currently configured .env file paths
|
|
56
|
-
*/
|
|
57
|
-
static get envPaths(): string[];
|
|
58
|
-
/**
|
|
59
|
-
* Set a base directory that relative `.env` paths resolve against instead of
|
|
60
|
-
* `process.cwd()`: the auto-cascade, {@link configureProfiles} paths, and relative
|
|
61
|
-
* `envPaths`. Absolute paths always bypass it. Pass a directory, or a module URL
|
|
62
|
-
* (`import.meta.url`, ESM) / `import.meta.dirname` / `__dirname` (CJS) to anchor
|
|
63
|
-
* resolution next to the calling file regardless of launch directory.
|
|
64
|
-
*
|
|
65
|
-
* Set this before `envPaths` so relative `envPaths` validate against the right directory.
|
|
66
|
-
* Unset (`undefined`) restores `process.cwd()` resolution.
|
|
67
|
-
*/
|
|
68
|
-
static set baseDir(value: string | URL | undefined);
|
|
69
|
-
static get baseDir(): string | undefined;
|
|
70
|
-
private static normalizeBaseDir;
|
|
71
44
|
protected static resolveAgainstBase(candidate: string): string;
|
|
72
|
-
static
|
|
73
|
-
|
|
74
|
-
* Get current dotenv configuration options
|
|
75
|
-
*/
|
|
76
|
-
static get envFileOptions(): EnvFileOptions;
|
|
45
|
+
protected static assertFileApiSupported(api: string, source: EnvSource): asserts source is FileEnvSource;
|
|
46
|
+
protected static sourceFileExists(path: string): boolean;
|
|
77
47
|
protected static refreshCache(): void;
|
|
78
48
|
protected static mirrorToProcessEnv(): void;
|
|
79
|
-
/**
|
|
80
|
-
* Resolve the effective `.env` paths to load. Default implementation just returns the
|
|
81
|
-
* explicit `_envPaths` array; subclasses (`EnvironmentMethods`) override to layer in the
|
|
82
|
-
* dotenv-flow cascade and any {@link configureProfiles} overrides when `envPaths` was
|
|
83
|
-
* never explicitly set.
|
|
84
|
-
* @internal
|
|
85
|
-
*/
|
|
86
49
|
protected static resolveEffectivePaths(): string[];
|
|
87
50
|
protected static resolveKeyInput(keyInput: EnvKeyInput): {
|
|
88
51
|
key: string;
|
|
@@ -95,6 +58,13 @@ declare abstract class EnvapterBase {
|
|
|
95
58
|
* which is what the `envapt/config` side-effect entry does.
|
|
96
59
|
*/
|
|
97
60
|
static load(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Bind the environment {@link EnvSource}. On Node the entry binds {@link NodeEnvSource} for you
|
|
63
|
+
* (a `process.env` snapshot plus the `.env` cascade); on the browser or Workers, pass a
|
|
64
|
+
* `ManualEnvSource` / `WorkerEnvSource` (or any `EnvSource`) before reading. Clears and rebuilds
|
|
65
|
+
* the cache.
|
|
66
|
+
*/
|
|
67
|
+
static useSource(source: EnvSource): void;
|
|
98
68
|
/**
|
|
99
69
|
* Read an environment variable as its raw string, skipping parsing and conversion.
|
|
100
70
|
*/
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { DebugLevel } from "../Debug.mjs";
|
|
2
|
+
import { EnvFileOptions } from "../Dotenv.mjs";
|
|
3
|
+
import { EnvKeyInput } from "../types/Env.mjs";
|
|
4
|
+
import { EnvSource, FileEnvSource } from "../types/Source.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/core/EnvapterBase.d.ts
|
|
7
|
+
/** @internal */
|
|
8
|
+
declare abstract class EnvapterBase {
|
|
9
|
+
protected static _envPaths: string[];
|
|
10
|
+
protected static _envPathsExplicitlySet: boolean;
|
|
11
|
+
protected static _baseDir: string | undefined;
|
|
12
|
+
protected static _userDefinedEnvFileOptions: EnvFileOptions;
|
|
13
|
+
protected static _strict: boolean;
|
|
14
|
+
protected static _syncProcessEnv: boolean;
|
|
15
|
+
protected static _dotenvAddedKeys: Set<string>;
|
|
16
|
+
protected static _source: EnvSource;
|
|
17
|
+
/**
|
|
18
|
+
* Enable or disable strict mode. Default `false`. Setting refreshes the cache so
|
|
19
|
+
* previously-cached converted values get re-evaluated under the new rule.
|
|
20
|
+
*/
|
|
21
|
+
static set strict(value: boolean);
|
|
22
|
+
static get strict(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Set the debug log level. Defaults to `silent`. When unset, reads `ENVAPT_DEBUG` from the
|
|
25
|
+
* bound source on first access; the setter overrides any env-var value. Output goes to stderr
|
|
26
|
+
* on Node (the console elsewhere), prefixed with `[envapt]`.
|
|
27
|
+
*/
|
|
28
|
+
static set debug(level: DebugLevel);
|
|
29
|
+
static get debug(): DebugLevel;
|
|
30
|
+
/**
|
|
31
|
+
* Opt-in mirror of dotenv-loaded keys back to `process.env`. Default `false`.
|
|
32
|
+
*
|
|
33
|
+
* Only keys the loader actually wrote are mirrored, so collision behavior follows
|
|
34
|
+
* `envFileOptions.override`: with the default `false`, pre-existing `process.env` values
|
|
35
|
+
* are preserved; with `true`, the file value wins in both the cache and the mirror.
|
|
36
|
+
*
|
|
37
|
+
* Flipping `false → true` mirrors the existing tracked delta immediately (no cache
|
|
38
|
+
* refresh). Flipping `true → false` is one-way: previously mirrored keys remain in
|
|
39
|
+
* `process.env` until the process exits.
|
|
40
|
+
*/
|
|
41
|
+
static set syncProcessEnv(value: boolean);
|
|
42
|
+
static get syncProcessEnv(): boolean;
|
|
43
|
+
protected static treatAsMissing(value: string | undefined): boolean;
|
|
44
|
+
protected static resolveAgainstBase(candidate: string): string;
|
|
45
|
+
protected static assertFileApiSupported(api: string, source: EnvSource): asserts source is FileEnvSource;
|
|
46
|
+
protected static sourceFileExists(path: string): boolean;
|
|
47
|
+
protected static refreshCache(): void;
|
|
48
|
+
protected static mirrorToProcessEnv(): void;
|
|
49
|
+
protected static resolveEffectivePaths(): string[];
|
|
50
|
+
protected static resolveKeyInput(keyInput: EnvKeyInput): {
|
|
51
|
+
key: string;
|
|
52
|
+
value: string | undefined;
|
|
53
|
+
};
|
|
54
|
+
protected static get config(): Map<string, unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* Eagerly load the `.env` cascade now instead of lazily on the first read. Idempotent: a no-op
|
|
57
|
+
* once the cache is built. Useful before mirroring to `process.env` (see {@link syncProcessEnv}),
|
|
58
|
+
* which is what the `envapt/config` side-effect entry does.
|
|
59
|
+
*/
|
|
60
|
+
static load(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Bind the environment {@link EnvSource}. On Node the entry binds {@link NodeEnvSource} for you
|
|
63
|
+
* (a `process.env` snapshot plus the `.env` cascade); on the browser or Workers, pass a
|
|
64
|
+
* `ManualEnvSource` / `WorkerEnvSource` (or any `EnvSource`) before reading. Clears and rebuilds
|
|
65
|
+
* the cache.
|
|
66
|
+
*/
|
|
67
|
+
static useSource(source: EnvSource): void;
|
|
68
|
+
/**
|
|
69
|
+
* Read an environment variable as its raw string, skipping parsing and conversion.
|
|
70
|
+
*/
|
|
71
|
+
getRaw(key: EnvKeyInput): string | undefined;
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
export { EnvapterBase };
|
|
75
|
+
//# sourceMappingURL=EnvapterBase.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{EnvaptError as e}from"../Error.mjs";import{Validator as t}from"../Validators.mjs";import{bindRuntimeFromSource as n}from"../runtime.mjs";import{debugVerbose as r,getDebugLevel as i,setDebugLevel as a}from"../Debug.mjs";import{loadDotenv as o}from"../Dotenv.mjs";import{UnboundEnvSource as s}from"../sources/UnboundEnvSource.mjs";const c=new Map;var l=class l{static _envPaths=[`.env`];static _envPathsExplicitlySet=!1;static _baseDir=void 0;static _userDefinedEnvFileOptions={};static _strict=!1;static _syncProcessEnv=!1;static _dotenvAddedKeys=new Set;static _source=new s;static set strict(e){l._strict=e,this.refreshCache()}static get strict(){return l._strict}static set debug(e){a(e)}static get debug(){return i()}static set syncProcessEnv(e){t.validateSyncProcessEnv(e);let n=l._syncProcessEnv;l._syncProcessEnv=e,!n&&e&&c.size>0&&this.mirrorToProcessEnv()}static get syncProcessEnv(){return l._syncProcessEnv}static treatAsMissing(e){return!!(e===void 0||e===``||l._strict&&e.trim()===``)}static resolveAgainstBase(e){let t=l._baseDir;if(t===void 0)return e;let n=l._source;return n.supportsFiles?n.resolvePath(t,e):e}static assertFileApiSupported(t,n){if(!n.supportsFiles)throw new e(306,`${t} requires a filesystem-backed source; the bound source does not support .env files.`)}static sourceFileExists(e){let t=l._source;return t.supportsFiles?t.readFile(e,`utf8`)!==void 0:!1}static refreshCache(){c.clear(),l._dotenvAddedKeys=new Set,r(`cache cleared, reloading config`),this.config}static mirrorToProcessEnv(){if(l._dotenvAddedKeys.size===0)return;let e=l._source;if(!e.supportsFiles)return;let t={};for(let e of l._dotenvAddedKeys){let n=c.get(e);typeof n==`string`&&(t[e]=n,r(`mirrored ${e} to the ambient environment`))}e.writeVars(t),r(`mirrored ${l._dotenvAddedKeys.size} keys to the ambient environment`)}static resolveEffectivePaths(){return this._envPaths.map(e=>this.resolveAgainstBase(e))}static resolveKeyInput(t){let n=Array.isArray(t)?t:[t];if(n.length===0)throw new e(304,`At least one environment key must be provided.`);if(n.some(e=>typeof e!=`string`))throw new e(304,`Environment keys must be strings.`);if(n.some(e=>e.trim()===``))throw new e(304,`Environment keys cannot be empty strings.`);for(let e of n){let t=this.config.get(e);if(t!==void 0)return{key:e,value:t}}return{key:n[0],value:void 0}}static get config(){if(c.size===0){let e=l._source,t={...e.readVars()},n=new Set;if(e.supportsFiles){let i=this.resolveEffectivePaths();r(`effective .env paths: ${i.length===0?`(none)`:i.join(`, `)}`);try{n=o({...this._userDefinedEnvFileOptions,path:i,processEnv:t,readFile:e.readFile.bind(e)})}catch{}}l._dotenvAddedKeys=n;for(let[e,n]of Object.entries(t))c.set(e,n);r(`cache populated: ${c.size} keys total`),l._syncProcessEnv&&this.mirrorToProcessEnv()}return c}static load(){this.config}static useSource(e){l._source=e,n(e),this.refreshCache()}getRaw(e){return l.resolveKeyInput(e).value}};export{c as EnvaptCache,l as EnvapterBase};
|
|
2
|
+
//# sourceMappingURL=EnvapterBase.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnvapterBase.mjs","names":[],"sources":["../../../src/core/EnvapterBase.ts"],"sourcesContent":["import { debugVerbose, getDebugLevel, setDebugLevel } from '../Debug';\nimport { loadDotenv } from '../Dotenv';\nimport { EnvaptError, EnvaptErrorCodes } from '../Error';\nimport { bindRuntimeFromSource } from '../runtime';\nimport { UnboundEnvSource } from '../sources/UnboundEnvSource';\nimport { Validator } from '../Validators';\n\nimport type { DebugLevel } from '../Debug';\nimport type { EnvFileOptions } from '../Dotenv';\nimport type { EnvKeyInput, EnvSource, FileEnvSource } from '../types';\n\n/** @internal */\nexport const EnvaptCache = new Map<string, unknown>();\n\n/** @internal */\nexport abstract class EnvapterBase {\n protected static _envPaths: string[] = ['.env'];\n protected static _envPathsExplicitlySet = false;\n protected static _baseDir: string | undefined = undefined;\n protected static _userDefinedEnvFileOptions: EnvFileOptions = {};\n protected static _strict = false;\n protected static _syncProcessEnv = false;\n // Loader-written keys only (collisions skipped). Refilled on every cache rebuild.\n protected static _dotenvAddedKeys: Set<string> = new Set<string>();\n // Unbound by default so non-Node builds throw NoSourceBound on read until useSource() is called.\n // NodeEnvapter's static block binds NodeEnvSource when referenced, so `import 'envapt'` needs no setup.\n protected static _source: EnvSource = new UnboundEnvSource();\n\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 */\n static set strict(value: boolean) {\n // Anchored to EnvapterBase: `this._strict` would write an own-property on the subclass that base readers miss.\n EnvapterBase._strict = value;\n // `this`, not EnvapterBase: rebuild via the subclass so its `resolveEffectivePaths` override is honored.\n this.refreshCache();\n }\n\n static get strict(): boolean {\n return EnvapterBase._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 */\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 */\n static set syncProcessEnv(value: boolean) {\n Validator.validateSyncProcessEnv(value);\n const previous = EnvapterBase._syncProcessEnv;\n // Anchored to EnvapterBase: `this._syncProcessEnv` would write an own-property on the subclass that base readers miss.\n EnvapterBase._syncProcessEnv = value;\n if (!previous && value && EnvaptCache.size > 0) this.mirrorToProcessEnv();\n }\n\n static get syncProcessEnv(): boolean {\n return EnvapterBase._syncProcessEnv;\n }\n\n protected static treatAsMissing(value: string | undefined): boolean {\n if (value === undefined || value === '') return true;\n if (EnvapterBase._strict && value.trim() === '') return true;\n return false;\n }\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 class node-free.\n protected static resolveAgainstBase(candidate: string): string {\n const baseDir = EnvapterBase._baseDir;\n if (baseDir === undefined) return candidate;\n const source = EnvapterBase._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;\n // throw instead of silently ignoring it on the browser or Workers. Narrows the source so callers\n // can reach the file capabilities (resolvePath/normalizeBaseDir) after the check.\n protected static assertFileApiSupported(api: string, source: EnvSource): asserts source is FileEnvSource {\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\n // source can read it.\n protected static sourceFileExists(path: string): boolean {\n const source = EnvapterBase._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 protected static refreshCache(): void {\n EnvaptCache.clear();\n EnvapterBase._dotenvAddedKeys = new Set();\n debugVerbose('cache cleared, reloading config');\n void this.config; // getter rebuilds the cache as a side effect\n }\n\n protected static mirrorToProcessEnv(): void {\n if (EnvapterBase._dotenvAddedKeys.size === 0) return;\n const source = EnvapterBase._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 EnvapterBase._dotenvAddedKeys) {\n const value = EnvaptCache.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] = value;\n debugVerbose(`mirrored ${key} to the ambient environment`);\n }\n source.writeVars(mirrored);\n debugVerbose(`mirrored ${EnvapterBase._dotenvAddedKeys.size} keys to the ambient environment`);\n }\n\n // Default returns the explicit `_envPaths`; EnvironmentMethods overrides to layer the dotenv-flow\n // cascade + configureProfiles when envPaths was never explicitly set.\n protected static resolveEffectivePaths(): string[] {\n /* v8 ignore next -- @preserve */\n return this._envPaths.map((p) => this.resolveAgainstBase(p));\n }\n\n protected static 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 for (const candidate of normalizedKeys) {\n const value = this.config.get(candidate) as string | undefined;\n if (value !== undefined) {\n return { key: candidate, value };\n }\n }\n\n return { key: normalizedKeys[0] as string, value: undefined };\n }\n\n protected static get config(): Map<string, unknown> {\n if (EnvaptCache.size === 0) {\n const source = EnvapterBase._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\n // .env cascade, profiles, and envPaths; only the readVars() snapshot populates the cache.\n if (source.supportsFiles) {\n // Outside the try below so a missing configured profile path surfaces its EnvaptError; only dotenv parse errors stay caught.\n const effectivePaths = this.resolveEffectivePaths();\n debugVerbose(\n `effective .env paths: ${effectivePaths.length === 0 ? '(none)' : effectivePaths.join(', ')}`\n );\n try {\n added = loadDotenv({\n ...this._userDefinedEnvFileOptions,\n path: effectivePaths,\n processEnv: isolatedEnv,\n readFile: source.readFile.bind(source)\n });\n } catch {}\n }\n EnvapterBase._dotenvAddedKeys = added;\n for (const [key, value] of Object.entries(isolatedEnv)) EnvaptCache.set(key, value);\n debugVerbose(`cache populated: ${EnvaptCache.size} keys total`);\n if (EnvapterBase._syncProcessEnv) this.mirrorToProcessEnv();\n }\n\n return EnvaptCache;\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 */\n static load(): void {\n void this.config;\n }\n\n /**\n * Bind the environment {@link EnvSource}. On Node the entry binds {@link NodeEnvSource} for you\n * (a `process.env` snapshot plus the `.env` cascade); on the browser or Workers, pass a\n * `ManualEnvSource` / `WorkerEnvSource` (or any `EnvSource`) before reading. Clears and rebuilds\n * the cache.\n */\n static useSource(source: EnvSource): void {\n EnvapterBase._source = source;\n bindRuntimeFromSource(source);\n this.refreshCache();\n }\n\n /**\n * Read an environment variable as its raw string, skipping parsing and conversion.\n */\n getRaw(key: EnvKeyInput): string | undefined {\n return EnvapterBase.resolveKeyInput(key).value;\n }\n}\n"],"mappings":"gVAYA,MAAa,EAAc,IAAI,IAG/B,IAAsB,EAAtB,MAAsB,CAAa,CAC/B,OAAiB,UAAsB,CAAC,MAAM,EAC9C,OAAiB,uBAAyB,GAC1C,OAAiB,SAA+B,IAAA,GAChD,OAAiB,2BAA6C,CAAC,EAC/D,OAAiB,QAAU,GAC3B,OAAiB,gBAAkB,GAE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AAS,KAAK,CAAM,CACzC,CAAC,CACL,MAAQ,CAAC,CACb,CACA,EAAa,iBAAmB,EAChC,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAW,EAAG,EAAY,IAAI,EAAK,CAAK,EAClF,EAAa,oBAAoB,EAAY,KAAK,YAAY,EAC1D,EAAa,iBAAiB,KAAK,mBAAmB,CAC9D,CAEA,OAAO,CACX,CAOA,OAAO,MAAa,CAChB,KAAU,MACd,CAQA,OAAO,UAAU,EAAyB,CACtC,EAAa,QAAU,EACvB,EAAsB,CAAM,EAC5B,KAAK,aAAa,CACtB,CAKA,OAAO,EAAsC,CACzC,OAAO,EAAa,gBAAgB,CAAG,EAAE,KAC7C,CACJ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../Error.cjs"),t=require("../Debug.cjs"),n=require("./EnvapterBase.cjs");let r=function(e){return e[e.Development=0]=`Development`,e[e.Staging=1]=`Staging`,e[e.Production=2]=`Production`,e[e.Test=3]=`Test`,e}({});const i=[`ENVIRONMENT`,`ENV`,`NODE_ENV`,`MODE`];function a(e){switch(e.toLowerCase()){case`production`:return 2;case`staging`:return 1;case`test`:return 3;case`development`:return 0;default:return}}var o=class o extends n.EnvapterBase{static _environment;static _environmentExplicitlySet=!1;static _profiles;static determineEnvironment(e){if(typeof e==`number`){this._environment=e,this._environmentExplicitlySet=!0;return}if(typeof e==`string`){this._environment=a(e)??0,this._environmentExplicitlySet=!0;return}let n=this.firstEnvKeyValue(e=>{let t=this.config.get(e);return typeof t==`string`?t:void 0});if(n===void 0){t.debugWarn(`no environment set (looked for ${i.join(`, `)}); defaulting to development`),this._environment=0;return}let r=a(n);if(r===void 0){t.debugWarn(`unrecognized environment "${n}"; defaulting to development`),this._environment=0;return}this._environment=r}static firstEnvKeyValue(e){for(let t of i){let n=e(t);if(n!==void 0&&n.length>0)return n}}static get environment(){return this._environment===void 0&&this.determineEnvironment(),this._environment}static set environment(e){this.determineEnvironment(e)}get environment(){return o.environment}set environment(e){o.determineEnvironment(e)}static get isProduction(){return this.environment===2}get isProduction(){return o.environment===2}static get isStaging(){return this.environment===1}get isStaging(){return o.environment===1}static get isDevelopment(){return this.environment===0}get isDevelopment(){return o.environment===0}static get isTest(){return this.environment===3}get isTest(){return o.environment===3}static refreshCache(){this._environmentExplicitlySet||(this._environment=void 0),super.refreshCache()}static getCascadeEnvironment(){if(this._environment!==void 0)return this._environment;let e=n.EnvapterBase._source.readVars(),t=this.firstEnvKeyValue(t=>e[t]);return t===void 0?0:a(t)??0}static buildCascadePaths(e){let t=r[e].toLowerCase();return[`.env.${t}.local`,`.env.${t}`,`.env.local`,`.env`].map(e=>this.resolveAgainstBase(e)).filter(e=>this.sourceFileExists(e))}static normalizeProfilePaths(e){return e?Array.isArray(e.paths)?e.paths:[e.paths]:[]}static resolveEffectivePaths(){if(this._envPathsExplicitlySet)return this._envPaths.map(e=>this.resolveAgainstBase(e));let t=this.getCascadeEnvironment(),n=this._profiles?.[t],r=this.normalizeProfilePaths(n);if(r.length>0){let t=r.filter(e=>!this.sourceFileExists(this.resolveAgainstBase(e)));if(t.length>0)throw new e.EnvaptError(303,`Environment file not found at path: ${t.join(`, `)}`)}let i=this._profiles?.useDefaults===!1?[]:this.buildCascadePaths(t);return[...r.map(e=>this.resolveAgainstBase(e)),...i]}};exports.Environment=r,exports.EnvironmentMethods=o;
|
|
2
|
+
//# sourceMappingURL=EnvironmentMethods.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnvironmentMethods.cjs","names":["EnvapterBase","EnvaptError"],"sources":["../../../src/core/EnvironmentMethods.ts"],"sourcesContent":["import { debugWarn } from '../Debug';\nimport { EnvaptError, EnvaptErrorCodes } from '../Error';\nimport { EnvapterBase } from './EnvapterBase';\n\nimport type { EnvProfile, ProfilesConfig } from '../types';\n\n/**\n * Environment types supported by Envapter\n * @public\n */\nexport enum Environment {\n Development,\n Staging,\n Production,\n Test\n}\n\n// Keys carrying the environment name, highest precedence first. Checked in order until the first with a non-empty value is found, or defaulting to development if none are set.\nconst ENV_KEYS = ['ENVIRONMENT', 'ENV', 'NODE_ENV', 'MODE'] as const;\n\nfunction parseEnvironment(raw: string): Environment | undefined {\n switch (raw.toLowerCase()) {\n case 'production':\n return Environment.Production;\n case 'staging':\n return Environment.Staging;\n case 'test':\n return Environment.Test;\n case 'development':\n return Environment.Development;\n default:\n return undefined;\n }\n}\n\n/**\n * Mixin for environment detection and checking methods\n * @internal\n */\nexport class EnvironmentMethods extends EnvapterBase {\n protected static _environment: Environment | undefined;\n protected static _environmentExplicitlySet = false;\n protected static _profiles: ProfilesConfig | undefined;\n\n protected static determineEnvironment(env?: string | Environment): void {\n if (typeof env === 'number') {\n this._environment = env;\n this._environmentExplicitlySet = true;\n return;\n }\n if (typeof env === 'string') {\n this._environment = parseEnvironment(env) ?? Environment.Development;\n this._environmentExplicitlySet = true;\n return;\n }\n\n const raw = this.firstEnvKeyValue((key) => {\n const value = this.config.get(key);\n return typeof value === 'string' ? value : undefined;\n });\n if (raw === undefined) {\n debugWarn(`no environment set (looked for ${ENV_KEYS.join(', ')}); defaulting to development`);\n this._environment = Environment.Development;\n return;\n }\n const parsed = parseEnvironment(raw);\n if (parsed === undefined) {\n debugWarn(`unrecognized environment \"${raw}\"; defaulting to development`);\n this._environment = Environment.Development;\n return;\n }\n this._environment = parsed;\n }\n\n private static firstEnvKeyValue(read: (key: string) => string | undefined): string | undefined {\n for (const key of ENV_KEYS) {\n const value = read(key);\n if (value !== undefined && value.length > 0) return value;\n }\n return undefined;\n }\n\n /**\n * Get the current application environment\n */\n static get environment(): Environment {\n if (this._environment === undefined) {\n this.determineEnvironment();\n }\n return this._environment as Environment;\n }\n\n /**\n * Set the application environment. Accepts either Environment enum or string value.\n */\n static set environment(env: string | Environment) {\n this.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 EnvironmentMethods.determineEnvironment(env);\n }\n\n /**\n * Check if the current environment is production\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 */\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 */\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 */\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 protected static override refreshCache(): void {\n // If the env was inferred (not user-set), reset it so re-hydration re-determines\n // from current state. If the user explicitly set Envapter.environment = X, preserve\n // that value through the refresh. The immediate re-hydration inside super.refreshCache()\n // will use it for cascade selection.\n if (!this._environmentExplicitlySet) this._environment = undefined;\n super.refreshCache();\n }\n\n /**\n * Reads the source's raw vars (not `this.config`, which would recurse: cascade selection runs\n * before the `.env` load). `Envapter.environment` may differ post-load if a file sets `ENVIRONMENT`.\n * @internal\n */\n protected static getCascadeEnvironment(): Environment {\n if (this._environment !== undefined) return this._environment;\n\n const vars = EnvapterBase._source.readVars();\n const raw = this.firstEnvKeyValue((key) => vars[key]);\n return raw === undefined ? Environment.Development : (parseEnvironment(raw) ?? Environment.Development);\n }\n\n /**\n * Build the dotenv-flow cascade for a given environment, in dotenv first-wins precedence\n * order (highest precedence first). Missing files are silently filtered.\n *\n * Precedence is **most-specific-wins** (matches Vite / Astro / Vocs):\n * `.env.${env}.local` \\> `.env.${env}` \\> `.env.local` \\> `.env`\n *\n * This differs from dotenv-flow / Next.js convention which puts `.env.local` above\n * `.env.${env}`. We chose the most-specific-wins order so committed env-specific files\n * (`.env.production`) are authoritative for that environment regardless of whether a\n * stray `.env.local` is present.\n * @internal\n */\n protected static buildCascadePaths(env: Environment): string[] {\n const envName = Environment[env].toLowerCase();\n return [`.env.${envName}.local`, `.env.${envName}`, '.env.local', '.env']\n .map((name) => this.resolveAgainstBase(name))\n .filter((p) => this.sourceFileExists(p));\n }\n\n private static normalizeProfilePaths(profile: EnvProfile | undefined): string[] {\n if (!profile) return [];\n return Array.isArray(profile.paths) ? profile.paths : [profile.paths];\n }\n\n /**\n * Override the base implementation to layer the dotenv-flow cascade + any\n * `Envapter.configureProfiles` overrides on top of `_envPaths` when the user has NOT\n * explicitly set `envPaths`.\n *\n * Precedence (passed to dotenv with first-wins semantics):\n * 1. profile-configured paths for the current env (if any)\n * 2. `.env.${env}.local`\n * 3. `.env.${env}`\n * 4. `.env.local`\n * 5. `.env`\n *\n * If `useDefaults: false` is set on the profiles config, only (1) is loaded, no cascade.\n * If `envPaths` was explicitly set, only `envPaths` is loaded (everything else ignored).\n * @internal\n */\n protected static override resolveEffectivePaths(): string[] {\n if (this._envPathsExplicitlySet) return this._envPaths.map((p) => this.resolveAgainstBase(p));\n\n const env = this.getCascadeEnvironment();\n const profileEntry = this._profiles?.[env];\n const profilePaths = this.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) => !this.sourceFileExists(this.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 = this._profiles?.useDefaults === false ? [] : this.buildCascadePaths(env);\n return [...profilePaths.map((p) => this.resolveAgainstBase(p)), ...cascade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AK,iBAAiB,CAAC,CAAC,CAC/C,CAEA,OAAe,sBAAsB,EAA2C,CAE5E,OADK,EACE,MAAM,QAAQ,EAAQ,KAAK,EAAI,EAAQ,MAAQ,CAAC,EAAQ,KAAK,EAD/C,CAAC,CAE1B,CAkBA,OAA0B,uBAAkC,CACxD,GAAI,KAAK,uBAAwB,OAAO,KAAK,UAAU,IAAK,GAAM,KAAK,mBAAmB,CAAC,CAAC,EAE5F,IAAM,EAAM,KAAK,sBAAsB,EACjC,EAAe,KAAK,YAAY,GAChC,EAAe,KAAK,sBAAsB,CAAY,EAG5D,GAAI,EAAa,OAAS,EAAG,CACzB,IAAM,EAAU,EAAa,OAAQ,GAAM,CAAC,KAAK,iBAAiB,KAAK,mBAAmB,CAAC,CAAC,CAAC,EAC7F,GAAI,EAAQ,OAAS,EACjB,MAAM,IAAIC,EAAAA,YAAAA,IAEN,uCAAuC,EAAQ,KAAK,IAAI,GAC5D,CAER,CAEA,IAAM,EAAU,KAAK,WAAW,cAAgB,GAAQ,CAAC,EAAI,KAAK,kBAAkB,CAAG,EACvF,MAAO,CAAC,GAAG,EAAa,IAAK,GAAM,KAAK,mBAAmB,CAAC,CAAC,EAAG,GAAG,CAAO,CAC9E,CACJ"}
|
|
@@ -9,7 +9,8 @@ import { ProfilesConfig } from "../types/Options.cjs";
|
|
|
9
9
|
declare enum Environment {
|
|
10
10
|
Development = 0,
|
|
11
11
|
Staging = 1,
|
|
12
|
-
Production = 2
|
|
12
|
+
Production = 2,
|
|
13
|
+
Test = 3
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* Mixin for environment detection and checking methods
|
|
@@ -20,7 +21,7 @@ declare class EnvironmentMethods extends EnvapterBase {
|
|
|
20
21
|
protected static _environmentExplicitlySet: boolean;
|
|
21
22
|
protected static _profiles: ProfilesConfig | undefined;
|
|
22
23
|
protected static determineEnvironment(env?: string | Environment): void;
|
|
23
|
-
private static
|
|
24
|
+
private static firstEnvKeyValue;
|
|
24
25
|
/**
|
|
25
26
|
* Get the current application environment
|
|
26
27
|
*/
|
|
@@ -61,36 +62,18 @@ declare class EnvironmentMethods extends EnvapterBase {
|
|
|
61
62
|
* @see {@link EnvironmentMethods.isDevelopment}
|
|
62
63
|
*/
|
|
63
64
|
get isDevelopment(): boolean;
|
|
64
|
-
protected static refreshCache(): void;
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* When set, each `Environment` key's `paths` are loaded at higher precedence than the
|
|
69
|
-
* cascade for that environment. Unspecified environments still use the cascade as-is.
|
|
70
|
-
* Set `useDefaults: false` to disable the cascade entirely (load only the configured paths).
|
|
71
|
-
*
|
|
72
|
-
* Setting an explicit `Envapter.envPaths` value at any point overrides this configuration.
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```ts
|
|
76
|
-
* Envapter.configureProfiles({
|
|
77
|
-
* [Environment.Staging]: { paths: 'config/staging.env' },
|
|
78
|
-
* [Environment.Production]: { paths: ['config/prod.env', 'secrets/prod.env'] }
|
|
79
|
-
* });
|
|
80
|
-
* ```
|
|
66
|
+
* Check if the current environment is test
|
|
81
67
|
*/
|
|
82
|
-
static
|
|
68
|
+
static get isTest(): boolean;
|
|
83
69
|
/**
|
|
84
|
-
*
|
|
85
|
-
* {@link configureProfiles} call AND any explicit `Envapter.envPaths` assignment.
|
|
86
|
-
* Returns the resolver to the pure dotenv-flow cascade.
|
|
70
|
+
* @see {@link EnvironmentMethods.isTest}
|
|
87
71
|
*/
|
|
88
|
-
|
|
72
|
+
get isTest(): boolean;
|
|
73
|
+
protected static refreshCache(): void;
|
|
89
74
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* happens before `.env` files are loaded). The post-load `Envapter.environment` value
|
|
93
|
-
* may differ if a loaded `.env` file declares its own `ENVIRONMENT`/`ENV`/`NODE_ENV`.
|
|
75
|
+
* Reads the source's raw vars (not `this.config`, which would recurse: cascade selection runs
|
|
76
|
+
* before the `.env` load). `Envapter.environment` may differ post-load if a file sets `ENVIRONMENT`.
|
|
94
77
|
* @internal
|
|
95
78
|
*/
|
|
96
79
|
protected static getCascadeEnvironment(): Environment;
|
|
@@ -111,7 +94,7 @@ declare class EnvironmentMethods extends EnvapterBase {
|
|
|
111
94
|
private static normalizeProfilePaths;
|
|
112
95
|
/**
|
|
113
96
|
* Override the base implementation to layer the dotenv-flow cascade + any
|
|
114
|
-
*
|
|
97
|
+
* `Envapter.configureProfiles` overrides on top of `_envPaths` when the user has NOT
|
|
115
98
|
* explicitly set `envPaths`.
|
|
116
99
|
*
|
|
117
100
|
* Precedence (passed to dotenv with first-wins semantics):
|
|
@@ -121,7 +104,7 @@ declare class EnvironmentMethods extends EnvapterBase {
|
|
|
121
104
|
* 4. `.env.local`
|
|
122
105
|
* 5. `.env`
|
|
123
106
|
*
|
|
124
|
-
* If `useDefaults: false` is set on the profiles config, only (1) is loaded
|
|
107
|
+
* If `useDefaults: false` is set on the profiles config, only (1) is loaded, no cascade.
|
|
125
108
|
* If `envPaths` was explicitly set, only `envPaths` is loaded (everything else ignored).
|
|
126
109
|
* @internal
|
|
127
110
|
*/
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { EnvapterBase } from "./EnvapterBase.mjs";
|
|
2
|
+
import { ProfilesConfig } from "../types/Options.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/core/EnvironmentMethods.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Environment types supported by Envapter
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
declare enum Environment {
|
|
10
|
+
Development = 0,
|
|
11
|
+
Staging = 1,
|
|
12
|
+
Production = 2,
|
|
13
|
+
Test = 3
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Mixin for environment detection and checking methods
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
declare class EnvironmentMethods extends EnvapterBase {
|
|
20
|
+
protected static _environment: Environment | undefined;
|
|
21
|
+
protected static _environmentExplicitlySet: boolean;
|
|
22
|
+
protected static _profiles: ProfilesConfig | undefined;
|
|
23
|
+
protected static determineEnvironment(env?: string | Environment): void;
|
|
24
|
+
private static firstEnvKeyValue;
|
|
25
|
+
/**
|
|
26
|
+
* Get the current application environment
|
|
27
|
+
*/
|
|
28
|
+
static get environment(): Environment;
|
|
29
|
+
/**
|
|
30
|
+
* Set the application environment. Accepts either Environment enum or string value.
|
|
31
|
+
*/
|
|
32
|
+
static set environment(env: string | Environment);
|
|
33
|
+
/**
|
|
34
|
+
* @see {@link EnvironmentMethods.environment}
|
|
35
|
+
*/
|
|
36
|
+
get environment(): Environment;
|
|
37
|
+
/**
|
|
38
|
+
* @see {@link EnvironmentMethods.environment}
|
|
39
|
+
*/
|
|
40
|
+
set environment(env: string | Environment);
|
|
41
|
+
/**
|
|
42
|
+
* Check if the current environment is production
|
|
43
|
+
*/
|
|
44
|
+
static get isProduction(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* @see {@link EnvironmentMethods.isProduction}
|
|
47
|
+
*/
|
|
48
|
+
get isProduction(): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Check if the current environment is staging
|
|
51
|
+
*/
|
|
52
|
+
static get isStaging(): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* @see {@link EnvironmentMethods.isStaging}
|
|
55
|
+
*/
|
|
56
|
+
get isStaging(): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Check if the current environment is development
|
|
59
|
+
*/
|
|
60
|
+
static get isDevelopment(): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* @see {@link EnvironmentMethods.isDevelopment}
|
|
63
|
+
*/
|
|
64
|
+
get isDevelopment(): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Check if the current environment is test
|
|
67
|
+
*/
|
|
68
|
+
static get isTest(): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* @see {@link EnvironmentMethods.isTest}
|
|
71
|
+
*/
|
|
72
|
+
get isTest(): boolean;
|
|
73
|
+
protected static refreshCache(): void;
|
|
74
|
+
/**
|
|
75
|
+
* Reads the source's raw vars (not `this.config`, which would recurse: cascade selection runs
|
|
76
|
+
* before the `.env` load). `Envapter.environment` may differ post-load if a file sets `ENVIRONMENT`.
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
protected static getCascadeEnvironment(): Environment;
|
|
80
|
+
/**
|
|
81
|
+
* Build the dotenv-flow cascade for a given environment, in dotenv first-wins precedence
|
|
82
|
+
* order (highest precedence first). Missing files are silently filtered.
|
|
83
|
+
*
|
|
84
|
+
* Precedence is **most-specific-wins** (matches Vite / Astro / Vocs):
|
|
85
|
+
* `.env.${env}.local` \> `.env.${env}` \> `.env.local` \> `.env`
|
|
86
|
+
*
|
|
87
|
+
* This differs from dotenv-flow / Next.js convention which puts `.env.local` above
|
|
88
|
+
* `.env.${env}`. We chose the most-specific-wins order so committed env-specific files
|
|
89
|
+
* (`.env.production`) are authoritative for that environment regardless of whether a
|
|
90
|
+
* stray `.env.local` is present.
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
protected static buildCascadePaths(env: Environment): string[];
|
|
94
|
+
private static normalizeProfilePaths;
|
|
95
|
+
/**
|
|
96
|
+
* Override the base implementation to layer the dotenv-flow cascade + any
|
|
97
|
+
* `Envapter.configureProfiles` overrides on top of `_envPaths` when the user has NOT
|
|
98
|
+
* explicitly set `envPaths`.
|
|
99
|
+
*
|
|
100
|
+
* Precedence (passed to dotenv with first-wins semantics):
|
|
101
|
+
* 1. profile-configured paths for the current env (if any)
|
|
102
|
+
* 2. `.env.${env}.local`
|
|
103
|
+
* 3. `.env.${env}`
|
|
104
|
+
* 4. `.env.local`
|
|
105
|
+
* 5. `.env`
|
|
106
|
+
*
|
|
107
|
+
* If `useDefaults: false` is set on the profiles config, only (1) is loaded, no cascade.
|
|
108
|
+
* If `envPaths` was explicitly set, only `envPaths` is loaded (everything else ignored).
|
|
109
|
+
* @internal
|
|
110
|
+
*/
|
|
111
|
+
protected static resolveEffectivePaths(): string[];
|
|
112
|
+
}
|
|
113
|
+
//#endregion
|
|
114
|
+
export { Environment, EnvironmentMethods };
|
|
115
|
+
//# sourceMappingURL=EnvironmentMethods.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{EnvaptError as e}from"../Error.mjs";import{debugWarn as t}from"../Debug.mjs";import{EnvapterBase as n}from"./EnvapterBase.mjs";let r=function(e){return e[e.Development=0]=`Development`,e[e.Staging=1]=`Staging`,e[e.Production=2]=`Production`,e[e.Test=3]=`Test`,e}({});const i=[`ENVIRONMENT`,`ENV`,`NODE_ENV`,`MODE`];function a(e){switch(e.toLowerCase()){case`production`:return 2;case`staging`:return 1;case`test`:return 3;case`development`:return 0;default:return}}var o=class o extends n{static _environment;static _environmentExplicitlySet=!1;static _profiles;static determineEnvironment(e){if(typeof e==`number`){this._environment=e,this._environmentExplicitlySet=!0;return}if(typeof e==`string`){this._environment=a(e)??0,this._environmentExplicitlySet=!0;return}let n=this.firstEnvKeyValue(e=>{let t=this.config.get(e);return typeof t==`string`?t:void 0});if(n===void 0){t(`no environment set (looked for ${i.join(`, `)}); defaulting to development`),this._environment=0;return}let r=a(n);if(r===void 0){t(`unrecognized environment "${n}"; defaulting to development`),this._environment=0;return}this._environment=r}static firstEnvKeyValue(e){for(let t of i){let n=e(t);if(n!==void 0&&n.length>0)return n}}static get environment(){return this._environment===void 0&&this.determineEnvironment(),this._environment}static set environment(e){this.determineEnvironment(e)}get environment(){return o.environment}set environment(e){o.determineEnvironment(e)}static get isProduction(){return this.environment===2}get isProduction(){return o.environment===2}static get isStaging(){return this.environment===1}get isStaging(){return o.environment===1}static get isDevelopment(){return this.environment===0}get isDevelopment(){return o.environment===0}static get isTest(){return this.environment===3}get isTest(){return o.environment===3}static refreshCache(){this._environmentExplicitlySet||(this._environment=void 0),super.refreshCache()}static getCascadeEnvironment(){if(this._environment!==void 0)return this._environment;let e=n._source.readVars(),t=this.firstEnvKeyValue(t=>e[t]);return t===void 0?0:a(t)??0}static buildCascadePaths(e){let t=r[e].toLowerCase();return[`.env.${t}.local`,`.env.${t}`,`.env.local`,`.env`].map(e=>this.resolveAgainstBase(e)).filter(e=>this.sourceFileExists(e))}static normalizeProfilePaths(e){return e?Array.isArray(e.paths)?e.paths:[e.paths]:[]}static resolveEffectivePaths(){if(this._envPathsExplicitlySet)return this._envPaths.map(e=>this.resolveAgainstBase(e));let t=this.getCascadeEnvironment(),n=this._profiles?.[t],r=this.normalizeProfilePaths(n);if(r.length>0){let t=r.filter(e=>!this.sourceFileExists(this.resolveAgainstBase(e)));if(t.length>0)throw new e(303,`Environment file not found at path: ${t.join(`, `)}`)}let i=this._profiles?.useDefaults===!1?[]:this.buildCascadePaths(t);return[...r.map(e=>this.resolveAgainstBase(e)),...i]}};export{r as Environment,o as EnvironmentMethods};
|
|
2
|
+
//# sourceMappingURL=EnvironmentMethods.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnvironmentMethods.mjs","names":[],"sources":["../../../src/core/EnvironmentMethods.ts"],"sourcesContent":["import { debugWarn } from '../Debug';\nimport { EnvaptError, EnvaptErrorCodes } from '../Error';\nimport { EnvapterBase } from './EnvapterBase';\n\nimport type { EnvProfile, ProfilesConfig } from '../types';\n\n/**\n * Environment types supported by Envapter\n * @public\n */\nexport enum Environment {\n Development,\n Staging,\n Production,\n Test\n}\n\n// Keys carrying the environment name, highest precedence first. Checked in order until the first with a non-empty value is found, or defaulting to development if none are set.\nconst ENV_KEYS = ['ENVIRONMENT', 'ENV', 'NODE_ENV', 'MODE'] as const;\n\nfunction parseEnvironment(raw: string): Environment | undefined {\n switch (raw.toLowerCase()) {\n case 'production':\n return Environment.Production;\n case 'staging':\n return Environment.Staging;\n case 'test':\n return Environment.Test;\n case 'development':\n return Environment.Development;\n default:\n return undefined;\n }\n}\n\n/**\n * Mixin for environment detection and checking methods\n * @internal\n */\nexport class EnvironmentMethods extends EnvapterBase {\n protected static _environment: Environment | undefined;\n protected static _environmentExplicitlySet = false;\n protected static _profiles: ProfilesConfig | undefined;\n\n protected static determineEnvironment(env?: string | Environment): void {\n if (typeof env === 'number') {\n this._environment = env;\n this._environmentExplicitlySet = true;\n return;\n }\n if (typeof env === 'string') {\n this._environment = parseEnvironment(env) ?? Environment.Development;\n this._environmentExplicitlySet = true;\n return;\n }\n\n const raw = this.firstEnvKeyValue((key) => {\n const value = this.config.get(key);\n return typeof value === 'string' ? value : undefined;\n });\n if (raw === undefined) {\n debugWarn(`no environment set (looked for ${ENV_KEYS.join(', ')}); defaulting to development`);\n this._environment = Environment.Development;\n return;\n }\n const parsed = parseEnvironment(raw);\n if (parsed === undefined) {\n debugWarn(`unrecognized environment \"${raw}\"; defaulting to development`);\n this._environment = Environment.Development;\n return;\n }\n this._environment = parsed;\n }\n\n private static firstEnvKeyValue(read: (key: string) => string | undefined): string | undefined {\n for (const key of ENV_KEYS) {\n const value = read(key);\n if (value !== undefined && value.length > 0) return value;\n }\n return undefined;\n }\n\n /**\n * Get the current application environment\n */\n static get environment(): Environment {\n if (this._environment === undefined) {\n this.determineEnvironment();\n }\n return this._environment as Environment;\n }\n\n /**\n * Set the application environment. Accepts either Environment enum or string value.\n */\n static set environment(env: string | Environment) {\n this.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 EnvironmentMethods.determineEnvironment(env);\n }\n\n /**\n * Check if the current environment is production\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 */\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 */\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 */\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 protected static override refreshCache(): void {\n // If the env was inferred (not user-set), reset it so re-hydration re-determines\n // from current state. If the user explicitly set Envapter.environment = X, preserve\n // that value through the refresh. The immediate re-hydration inside super.refreshCache()\n // will use it for cascade selection.\n if (!this._environmentExplicitlySet) this._environment = undefined;\n super.refreshCache();\n }\n\n /**\n * Reads the source's raw vars (not `this.config`, which would recurse: cascade selection runs\n * before the `.env` load). `Envapter.environment` may differ post-load if a file sets `ENVIRONMENT`.\n * @internal\n */\n protected static getCascadeEnvironment(): Environment {\n if (this._environment !== undefined) return this._environment;\n\n const vars = EnvapterBase._source.readVars();\n const raw = this.firstEnvKeyValue((key) => vars[key]);\n return raw === undefined ? Environment.Development : (parseEnvironment(raw) ?? Environment.Development);\n }\n\n /**\n * Build the dotenv-flow cascade for a given environment, in dotenv first-wins precedence\n * order (highest precedence first). Missing files are silently filtered.\n *\n * Precedence is **most-specific-wins** (matches Vite / Astro / Vocs):\n * `.env.${env}.local` \\> `.env.${env}` \\> `.env.local` \\> `.env`\n *\n * This differs from dotenv-flow / Next.js convention which puts `.env.local` above\n * `.env.${env}`. We chose the most-specific-wins order so committed env-specific files\n * (`.env.production`) are authoritative for that environment regardless of whether a\n * stray `.env.local` is present.\n * @internal\n */\n protected static buildCascadePaths(env: Environment): string[] {\n const envName = Environment[env].toLowerCase();\n return [`.env.${envName}.local`, `.env.${envName}`, '.env.local', '.env']\n .map((name) => this.resolveAgainstBase(name))\n .filter((p) => this.sourceFileExists(p));\n }\n\n private static normalizeProfilePaths(profile: EnvProfile | undefined): string[] {\n if (!profile) return [];\n return Array.isArray(profile.paths) ? profile.paths : [profile.paths];\n }\n\n /**\n * Override the base implementation to layer the dotenv-flow cascade + any\n * `Envapter.configureProfiles` overrides on top of `_envPaths` when the user has NOT\n * explicitly set `envPaths`.\n *\n * Precedence (passed to dotenv with first-wins semantics):\n * 1. profile-configured paths for the current env (if any)\n * 2. `.env.${env}.local`\n * 3. `.env.${env}`\n * 4. `.env.local`\n * 5. `.env`\n *\n * If `useDefaults: false` is set on the profiles config, only (1) is loaded, no cascade.\n * If `envPaths` was explicitly set, only `envPaths` is loaded (everything else ignored).\n * @internal\n */\n protected static override resolveEffectivePaths(): string[] {\n if (this._envPathsExplicitlySet) return this._envPaths.map((p) => this.resolveAgainstBase(p));\n\n const env = this.getCascadeEnvironment();\n const profileEntry = this._profiles?.[env];\n const profilePaths = this.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) => !this.sourceFileExists(this.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 = this._profiles?.useDefaults === false ? [] : this.buildCascadePaths(env);\n return [...profilePaths.map((p) => this.resolveAgainstBase(p)), ...cascade];\n }\n}\n"],"mappings":"sIAUA,IAAY,EAAL,SAAA,EAAA,OACH,GAAA,EAAA,YAAA,GAAA,cACA,EAAA,EAAA,QAAA,GAAA,UACA,EAAA,EAAA,WAAA,GAAA,aACA,EAAA,EAAA,KAAA,GAAA,QACJ,EAAA,CAAA,CAAA,EAGA,MAAM,EAAW,CAAC,cAAe,MAAO,WAAY,MAAM,EAE1D,SAAS,EAAiB,EAAsC,CAC5D,OAAQ,EAAI,YAAY,EAAxB,CACI,IAAK,aACD,MAAA,GACJ,IAAK,UACD,MAAA,GACJ,IAAK,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AG,CACzB,IAAM,EAAU,EAAa,OAAQ,GAAM,CAAC,KAAK,iBAAiB,KAAK,mBAAmB,CAAC,CAAC,CAAC,EAC7F,GAAI,EAAQ,OAAS,EACjB,MAAM,IAAI,EAAA,IAEN,uCAAuC,EAAQ,KAAK,IAAI,GAC5D,CAER,CAEA,IAAM,EAAU,KAAK,WAAW,cAAgB,GAAQ,CAAC,EAAI,KAAK,kBAAkB,CAAG,EACvF,MAAO,CAAC,GAAG,EAAa,IAAK,GAAM,KAAK,mBAAmB,CAAC,CAAC,EAAG,GAAG,CAAO,CAC9E,CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrimitiveMethods.cjs","names":["EnvironmentMethods","TemplateResolver","ValueConverter","EnvapterBase","BuiltInConverters"],"sources":["../../../src/core/PrimitiveMethods.ts"],"sourcesContent":["import { BuiltInConverters, ValueConverter } from '../converters';\nimport { debugWarn } from '../Debug';\nimport { TemplateResolver } from '../TemplateResolver';\nimport { EnvapterBase } from './EnvapterBase';\nimport { EnvironmentMethods } from './EnvironmentMethods';\n\nimport type { ConditionalReturn, EnvKeyInput } from '../types';\nimport type { EnvapterService } from '../types/Env';\n\n/**\n * @internal\n */\nenum Primitive {\n String,\n Number,\n Boolean,\n BigInt,\n Symbol\n}\n\n/**\n * @internal\n */\nexport class PrimitiveMethods extends EnvironmentMethods implements EnvapterService {\n private static readonly service = new PrimitiveMethods();\n protected static readonly templateResolver: TemplateResolver = new TemplateResolver(PrimitiveMethods.service);\n protected static readonly valueConverter: ValueConverter = new ValueConverter(PrimitiveMethods.service);\n\n // Read `EnvapterBase.strict` directly: `PrimitiveMethods._strict` would resolve to the\n // BaseClass default because a `Envapter.strict = true` write lands as an own-property\n // on `Envapter`, which is a descendant of `PrimitiveMethods`, not an ancestor.\n isStrict(): boolean {\n return EnvapterBase.strict;\n }\n\n private static _get<EnvVarReturnType, DefaultType extends EnvVarReturnType | undefined = undefined>(\n key: EnvKeyInput,\n type: Primitive,\n def?: DefaultType\n ): ConditionalReturn<EnvVarReturnType, DefaultType> {\n const { key: resolvedKey, value } = this.resolveKeyInput(key);\n if (this.treatAsMissing(value)) {\n if (def !== undefined) debugWarn(`${resolvedKey} not found, using fallback ${String(def)}`);\n return def as ConditionalReturn<EnvVarReturnType, DefaultType>;\n }\n const rawVal = value as string | number | boolean | undefined;\n\n const parsed = this.templateResolver.resolveTemplate(resolvedKey, String(rawVal));\n\n let result: EnvVarReturnType;\n if (type === Primitive.Number) result = BuiltInConverters.number(parsed, def as number) as EnvVarReturnType;\n else if (type === Primitive.Boolean)\n result = BuiltInConverters.boolean(parsed, def as boolean) as EnvVarReturnType;\n else if (type === Primitive.BigInt)\n result = BuiltInConverters.bigint(parsed, def as bigint) as EnvVarReturnType;\n else if (type === Primitive.Symbol)\n result = BuiltInConverters.symbol(parsed, def as symbol) as EnvVarReturnType;\n else result = BuiltInConverters.string(parsed, def as string) as EnvVarReturnType;\n\n return result;\n }\n\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 */\n static get<Default extends string | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<string, Default> {\n return this._get(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 PrimitiveMethods._get(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 */\n static getNumber<Default extends number | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<number, Default> {\n return this._get(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 PrimitiveMethods._get(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 */\n static getBoolean<Default extends boolean | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<boolean, Default> {\n return this._get(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 PrimitiveMethods._get(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 */\n static getBigInt<Default extends bigint | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<bigint, Default> {\n return this._get(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 PrimitiveMethods._get(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 */\n static getSymbol<Default extends symbol | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<symbol, Default> {\n return this._get(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 PrimitiveMethods._get(key, Primitive.Symbol, def);\n }\n}\n"],"mappings":"0OAuBA,IAAa,EAAb,MAAa,UAAyBA,EAAAA,kBAA8C,CAChF,OAAwB,QAAU,IAAI,EACtC,OAA0B,i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AAA,EAAuB,CAAG,CAC/C,CAKA,UACI,EACA,EACkC,CAClC,OAAO,EAAiB,KAAK,EAAA,EAAuB,CAAG,CAC3D,CAOA,OAAO,UACH,EACA,EACkC,CAClC,OAAO,KAAK,KAAK,EAAA,EAAuB,CAAG,CAC/C,CAKA,UACI,EACA,EACkC,CAClC,OAAO,EAAiB,KAAK,EAAA,EAAuB,CAAG,CAC3D,CACJ"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ConditionalReturn } from "../types/Conversion.mjs";
|
|
2
|
+
import { EnvironmentMethods } from "./EnvironmentMethods.mjs";
|
|
3
|
+
import { EnvKeyInput, EnvapterService } from "../types/Env.mjs";
|
|
4
|
+
import { ValueConverter } from "../converters/ValueConverter.mjs";
|
|
5
|
+
import { TemplateResolver } from "../TemplateResolver.mjs";
|
|
6
|
+
|
|
7
|
+
//#region src/core/PrimitiveMethods.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
declare class PrimitiveMethods extends EnvironmentMethods implements EnvapterService {
|
|
12
|
+
private static readonly service;
|
|
13
|
+
protected static readonly templateResolver: TemplateResolver;
|
|
14
|
+
protected static readonly valueConverter: ValueConverter;
|
|
15
|
+
isStrict(): boolean;
|
|
16
|
+
private static _get;
|
|
17
|
+
/**
|
|
18
|
+
* Get a string environment variable with optional fallback.
|
|
19
|
+
* Supports template variable resolution using `${VAR}` syntax.
|
|
20
|
+
* Accepts a single key or an ordered array of keys (first match wins).
|
|
21
|
+
*/
|
|
22
|
+
static get<Default extends string | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<string, Default>;
|
|
23
|
+
/**
|
|
24
|
+
* @see {@link PrimitiveMethods.get}
|
|
25
|
+
*/
|
|
26
|
+
get<Default extends string | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<string, Default>;
|
|
27
|
+
/**
|
|
28
|
+
* Get a number environment variable with optional fallback.
|
|
29
|
+
* Automatically converts string values to numbers.
|
|
30
|
+
* Accepts a single key or an ordered array of keys (first match wins).
|
|
31
|
+
*/
|
|
32
|
+
static getNumber<Default extends number | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<number, Default>;
|
|
33
|
+
/**
|
|
34
|
+
* @see {@link PrimitiveMethods.getNumber}
|
|
35
|
+
*/
|
|
36
|
+
getNumber<Default extends number | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<number, Default>;
|
|
37
|
+
/**
|
|
38
|
+
* Get a boolean environment variable with optional fallback.
|
|
39
|
+
* Recognizes: `1`, `yes`, `true`, `on` as **true**; `0`, `no`, `false`, `off` as **false** (case-insensitive).
|
|
40
|
+
* Accepts a single key or an ordered array of keys (first match wins).
|
|
41
|
+
*/
|
|
42
|
+
static getBoolean<Default extends boolean | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<boolean, Default>;
|
|
43
|
+
/**
|
|
44
|
+
* @see {@link PrimitiveMethods.getBoolean}
|
|
45
|
+
*/
|
|
46
|
+
getBoolean<Default extends boolean | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<boolean, Default>;
|
|
47
|
+
/**
|
|
48
|
+
* Get a bigint environment variable with optional fallback.
|
|
49
|
+
* Automatically converts string values to bigint.
|
|
50
|
+
* Accepts a single key or an ordered array of keys (first match wins).
|
|
51
|
+
*/
|
|
52
|
+
static getBigInt<Default extends bigint | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<bigint, Default>;
|
|
53
|
+
/**
|
|
54
|
+
* @see {@link PrimitiveMethods.getBigInt}
|
|
55
|
+
*/
|
|
56
|
+
getBigInt<Default extends bigint | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<bigint, Default>;
|
|
57
|
+
/**
|
|
58
|
+
* Get a symbol environment variable with optional fallback.
|
|
59
|
+
* Creates a symbol from the string value.
|
|
60
|
+
* Accepts a single key or an ordered array of keys (first match wins).
|
|
61
|
+
*/
|
|
62
|
+
static getSymbol<Default extends symbol | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<symbol, Default>;
|
|
63
|
+
/**
|
|
64
|
+
* @see {@link PrimitiveMethods.getSymbol}
|
|
65
|
+
*/
|
|
66
|
+
getSymbol<Default extends symbol | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<symbol, Default>;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { PrimitiveMethods };
|
|
70
|
+
//# sourceMappingURL=PrimitiveMethods.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrimitiveMethods.mjs","names":[],"sources":["../../../src/core/PrimitiveMethods.ts"],"sourcesContent":["import { BuiltInConverters, ValueConverter } from '../converters';\nimport { debugWarn } from '../Debug';\nimport { TemplateResolver } from '../TemplateResolver';\nimport { EnvapterBase } from './EnvapterBase';\nimport { EnvironmentMethods } from './EnvironmentMethods';\n\nimport type { ConditionalReturn, EnvKeyInput } from '../types';\nimport type { EnvapterService } from '../types/Env';\n\n/**\n * @internal\n */\nenum Primitive {\n String,\n Number,\n Boolean,\n BigInt,\n Symbol\n}\n\n/**\n * @internal\n */\nexport class PrimitiveMethods extends EnvironmentMethods implements EnvapterService {\n private static readonly service = new PrimitiveMethods();\n protected static readonly templateResolver: TemplateResolver = new TemplateResolver(PrimitiveMethods.service);\n protected static readonly valueConverter: ValueConverter = new ValueConverter(PrimitiveMethods.service);\n\n // Read `EnvapterBase.strict` directly: `PrimitiveMethods._strict` would resolve to the\n // BaseClass default because a `Envapter.strict = true` write lands as an own-property\n // on `Envapter`, which is a descendant of `PrimitiveMethods`, not an ancestor.\n isStrict(): boolean {\n return EnvapterBase.strict;\n }\n\n private static _get<EnvVarReturnType, DefaultType extends EnvVarReturnType | undefined = undefined>(\n key: EnvKeyInput,\n type: Primitive,\n def?: DefaultType\n ): ConditionalReturn<EnvVarReturnType, DefaultType> {\n const { key: resolvedKey, value } = this.resolveKeyInput(key);\n if (this.treatAsMissing(value)) {\n if (def !== undefined) debugWarn(`${resolvedKey} not found, using fallback ${String(def)}`);\n return def as ConditionalReturn<EnvVarReturnType, DefaultType>;\n }\n const rawVal = value as string | number | boolean | undefined;\n\n const parsed = this.templateResolver.resolveTemplate(resolvedKey, String(rawVal));\n\n let result: EnvVarReturnType;\n if (type === Primitive.Number) result = BuiltInConverters.number(parsed, def as number) as EnvVarReturnType;\n else if (type === Primitive.Boolean)\n result = BuiltInConverters.boolean(parsed, def as boolean) as EnvVarReturnType;\n else if (type === Primitive.BigInt)\n result = BuiltInConverters.bigint(parsed, def as bigint) as EnvVarReturnType;\n else if (type === Primitive.Symbol)\n result = BuiltInConverters.symbol(parsed, def as symbol) as EnvVarReturnType;\n else result = BuiltInConverters.string(parsed, def as string) as EnvVarReturnType;\n\n return result;\n }\n\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 */\n static get<Default extends string | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<string, Default> {\n return this._get(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 PrimitiveMethods._get(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 */\n static getNumber<Default extends number | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<number, Default> {\n return this._get(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 PrimitiveMethods._get(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 */\n static getBoolean<Default extends boolean | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<boolean, Default> {\n return this._get(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 PrimitiveMethods._get(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 */\n static getBigInt<Default extends bigint | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<bigint, Default> {\n return this._get(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 PrimitiveMethods._get(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 */\n static getSymbol<Default extends symbol | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<symbol, Default> {\n return this._get(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 PrimitiveMethods._get(key, Primitive.Symbol, def);\n }\n}\n"],"mappings":"8VAuBA,IAAa,EAAb,MAAa,UAAyB,CAA8C,CAChF,OAAwB,QAAU,IAAI,EACtC,OAA0B,iBAAqC,IAAI,EAAiB,EAAiB,OAAO,EAC5G,OAA0B,eAAiC,IAAI,EAAe,EAAiB,OAAO,EAKtG,UAAoB,CAChB,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