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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkerEnvSource.cjs","names":["coerceToStringRecord"],"sources":["../../../src/sources/WorkerEnvSource.ts"],"sourcesContent":["import { coerceToStringRecord } from './coerce';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * Environment source for Cloudflare Workers, seeded from the `env` binding. String bindings pass\n * through; non-string bindings are JSON-stringified so the converters still apply, and so must be\n * JSON-serializable (a `bigint` or circular value throws). No filesystem, so the `.env` cascade and\n * file-based APIs do not apply.\n * @public\n */\nexport class WorkerEnvSource implements BareEnvSource {\n readonly supportsFiles = false;\n private readonly vars: Record<string, string>;\n\n constructor(env: Record<string, unknown>) {\n this.vars = coerceToStringRecord(env);\n }\n\n readVars(): Record<string, string> {\n return { ...this.vars };\n }\n}\n"],"mappings":"gCAWA,IAAa,EAAb,KAAsD,CAClD,cAAyB,GACzB,KAEA,YAAY,EAA8B,CACtC,KAAK,KAAOA,EAAAA,qBAAqB,CAAG,CACxC,CAEA,UAAmC,CAC/B,MAAO,CAAE,GAAG,KAAK,IAAK,CAC1B,CACJ"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BareEnvSource } from "../types/Source.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/sources/WorkerEnvSource.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Environment source for Cloudflare Workers, seeded from the `env` binding. String bindings pass
|
|
6
|
+
* through; non-string bindings are JSON-stringified so the converters still apply, and so must be
|
|
7
|
+
* JSON-serializable (a `bigint` or circular value throws). No filesystem, so the `.env` cascade and
|
|
8
|
+
* file-based APIs do not apply.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
declare class WorkerEnvSource implements BareEnvSource {
|
|
12
|
+
readonly supportsFiles = false;
|
|
13
|
+
private readonly vars;
|
|
14
|
+
constructor(env: Record<string, unknown>);
|
|
15
|
+
readVars(): Record<string, string>;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { WorkerEnvSource };
|
|
19
|
+
//# sourceMappingURL=WorkerEnvSource.d.cts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BareEnvSource } from "../types/Source.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/sources/WorkerEnvSource.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Environment source for Cloudflare Workers, seeded from the `env` binding. String bindings pass
|
|
6
|
+
* through; non-string bindings are JSON-stringified so the converters still apply, and so must be
|
|
7
|
+
* JSON-serializable (a `bigint` or circular value throws). No filesystem, so the `.env` cascade and
|
|
8
|
+
* file-based APIs do not apply.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
declare class WorkerEnvSource implements BareEnvSource {
|
|
12
|
+
readonly supportsFiles = false;
|
|
13
|
+
private readonly vars;
|
|
14
|
+
constructor(env: Record<string, unknown>);
|
|
15
|
+
readVars(): Record<string, string>;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { WorkerEnvSource };
|
|
19
|
+
//# sourceMappingURL=WorkerEnvSource.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkerEnvSource.mjs","names":[],"sources":["../../../src/sources/WorkerEnvSource.ts"],"sourcesContent":["import { coerceToStringRecord } from './coerce';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * Environment source for Cloudflare Workers, seeded from the `env` binding. String bindings pass\n * through; non-string bindings are JSON-stringified so the converters still apply, and so must be\n * JSON-serializable (a `bigint` or circular value throws). No filesystem, so the `.env` cascade and\n * file-based APIs do not apply.\n * @public\n */\nexport class WorkerEnvSource implements BareEnvSource {\n readonly supportsFiles = false;\n private readonly vars: Record<string, string>;\n\n constructor(env: Record<string, unknown>) {\n this.vars = coerceToStringRecord(env);\n }\n\n readVars(): Record<string, string> {\n return { ...this.vars };\n }\n}\n"],"mappings":"oDAWA,IAAa,EAAb,KAAsD,CAClD,cAAyB,GACzB,KAEA,YAAY,EAA8B,CACtC,KAAK,KAAO,EAAqB,CAAG,CACxC,CAEA,UAAmC,CAC/B,MAAO,CAAE,GAAG,KAAK,IAAK,CAC1B,CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce.cjs","names":[],"sources":["../../../src/sources/coerce.ts"],"sourcesContent":["// Shared by ManualEnvSource and WorkerEnvSource. The returned record is fresh, so a caller mutating its\n// object later can't leak into the source; non-string values are JSON-stringified.\nexport function coerceToStringRecord(env: Record<string, unknown>): Record<string, string> {\n const snapshot: Record<string, string> = {};\n for (const [key, value] of Object.entries(env)) {\n if (typeof value === 'string') {\n snapshot[key] = value;\n continue;\n }\n const encoded = JSON.stringify(value);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- TS lib mistypes JSON.stringify's return as always-string; it is string | undefined at runtime\n if (encoded !== undefined) snapshot[key] = encoded;\n }\n return snapshot;\n}\n"],"mappings":"AAEA,SAAgB,EAAqB,EAAsD,CACvF,IAAM,EAAmC,CAAC,EAC1C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAG,EAAG,CAC5C,GAAI,OAAO,GAAU,SAAU,CAC3B,EAAS,GAAO,EAChB,QACJ,CACA,IAAM,EAAU,KAAK,UAAU,CAAK,EAEhC,IAAY,IAAA,KAAW,EAAS,GAAO,EAC/C,CACA,OAAO,CACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce.mjs","names":[],"sources":["../../../src/sources/coerce.ts"],"sourcesContent":["// Shared by ManualEnvSource and WorkerEnvSource. The returned record is fresh, so a caller mutating its\n// object later can't leak into the source; non-string values are JSON-stringified.\nexport function coerceToStringRecord(env: Record<string, unknown>): Record<string, string> {\n const snapshot: Record<string, string> = {};\n for (const [key, value] of Object.entries(env)) {\n if (typeof value === 'string') {\n snapshot[key] = value;\n continue;\n }\n const encoded = JSON.stringify(value);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- TS lib mistypes JSON.stringify's return as always-string; it is string | undefined at runtime\n if (encoded !== undefined) snapshot[key] = encoded;\n }\n return snapshot;\n}\n"],"mappings":"AAEA,SAAgB,EAAqB,EAAsD,CACvF,IAAM,EAAmC,CAAC,EAC1C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAG,EAAG,CAC5C,GAAI,OAAO,GAAU,SAAU,CAC3B,EAAS,GAAO,EAChB,QACJ,CACA,IAAM,EAAU,KAAK,UAAU,CAAK,EAEhC,IAAY,IAAA,KAAW,EAAS,GAAO,EAC/C,CACA,OAAO,CACX"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { ArrayOf, ConverterToken, CustomElementConverter } from "../converters/Converters.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/types/Conversion.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Scalar built-in converter tokens (e.g. `'number'`, `'time'`).
|
|
6
|
+
* Excludes the array builder (see {@link ArrayOf}).
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
type BuiltInConverter = ConverterToken;
|
|
10
|
+
/**
|
|
11
|
+
* Primitive types supported by Envapter
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
type PrimitiveConstructor = typeof String | typeof Number | typeof Boolean | typeof BigInt | typeof Symbol;
|
|
15
|
+
/**
|
|
16
|
+
* String value from a .env file or environment variable
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
type BaseInput = string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Custom parser function type for environment variables
|
|
22
|
+
* @param raw - Raw string value from environment
|
|
23
|
+
* @param fallback - Fallback value if parsing fails
|
|
24
|
+
* @returns Parsed value of type T
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
type ConverterFunction<TFallback = unknown> = (raw: BaseInput, fallback?: TFallback) => TFallback;
|
|
28
|
+
/**
|
|
29
|
+
* Environment variable converter: a primitive constructor, a built-in scalar token, an `ArrayOf<...>`
|
|
30
|
+
* produced by {@link Converters.array}, or a custom parser function.
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
type EnvaptConverter<TFallback> = PrimitiveConstructor | BuiltInConverter | ArrayOf | ConverterFunction<TFallback>;
|
|
34
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
35
|
+
type JsonArray = JsonValue[];
|
|
36
|
+
interface JsonObject {
|
|
37
|
+
[key: string]: JsonValue;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* JSON value types for custom converters
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
type JsonValue = JsonPrimitive | JsonArray | JsonObject;
|
|
44
|
+
interface ConverterMap {
|
|
45
|
+
string: string;
|
|
46
|
+
number: number;
|
|
47
|
+
boolean: boolean;
|
|
48
|
+
bigint: bigint;
|
|
49
|
+
symbol: symbol;
|
|
50
|
+
integer: number;
|
|
51
|
+
float: number;
|
|
52
|
+
json: JsonValue;
|
|
53
|
+
url: URL;
|
|
54
|
+
regexp: RegExp;
|
|
55
|
+
date: Date;
|
|
56
|
+
time: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Type mapping for built-in scalar converters to their return types
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
|
+
type BuiltInConverterReturnType<ConverterKey extends BuiltInConverter> = ConverterMap[ConverterKey];
|
|
63
|
+
/**
|
|
64
|
+
* Return type for built-in converter functions
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
type ReturnValuesOfConverterFunctions = ConverterMap[BuiltInConverter];
|
|
68
|
+
/**
|
|
69
|
+
* Function type for built-in converter functions
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
type BuiltInConverterFunction = (...args: Parameters<(...args: any[]) => ReturnValuesOfConverterFunctions>) => ReturnValuesOfConverterFunctions | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Map of built-in converter functions
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
type MapOfConverterFunctions = Record<BuiltInConverter, BuiltInConverterFunction>;
|
|
78
|
+
/**
|
|
79
|
+
* Time unit types for duration conversions
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
type TimeUnit = 'ms' | 's' | 'm' | 'h' | 'd' | 'w';
|
|
83
|
+
/**
|
|
84
|
+
* Fallback type for time duration conversions
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
type TimeFallback = number | `${number}${TimeUnit}`;
|
|
88
|
+
/**
|
|
89
|
+
* Helper type for getter methods that conditionally return undefined based on whether a fallback is provided
|
|
90
|
+
* If fallback is provided, return ReturnType. If no fallback (undefined), return ReturnType | undefined.
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
type ConditionalReturn<ReturnType, TFallback> = TFallback extends undefined ? ReturnType | undefined : ReturnType;
|
|
94
|
+
/**
|
|
95
|
+
* Inferred return type for a converter.
|
|
96
|
+
*
|
|
97
|
+
* - `ArrayOf<E>` resolves to the element type's return as an array. When `E` is a custom
|
|
98
|
+
* function, the function's return type drives the array element. When `E` is a scalar
|
|
99
|
+
* token, `ConverterMap` provides the element type.
|
|
100
|
+
* - Bare scalar tokens resolve through `ConverterMap`.
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
type InferConverterReturnType<TConverter> = TConverter extends ArrayOf<infer Element> ? Element extends BuiltInConverter ? ConverterMap[Element][] : Element extends CustomElementConverter<infer Returned> ? Returned[] : never : TConverter extends BuiltInConverter ? BuiltInConverterReturnType<TConverter> : never;
|
|
104
|
+
/**
|
|
105
|
+
* Type inference for the *fallback* slot of a converter. `Converters.Time` (scalar or array
|
|
106
|
+
* element) accepts {@link TimeFallback} / `TimeFallback[]`; everything else mirrors the
|
|
107
|
+
* return type. Add future asymmetric fallback/return converters to this conditional.
|
|
108
|
+
* @internal
|
|
109
|
+
*/
|
|
110
|
+
type InferConverterFallbackType<TConverter> = TConverter extends 'time' ? TimeFallback : TConverter extends ArrayOf<infer Element> ? Element extends 'time' ? TimeFallback[] : InferConverterReturnType<TConverter> : InferConverterReturnType<TConverter>;
|
|
111
|
+
/**
|
|
112
|
+
* Complete type inference for advanced converter methods
|
|
113
|
+
* @internal
|
|
114
|
+
*/
|
|
115
|
+
type AdvancedConverterReturn<TConverter, TFallback = undefined> = ConditionalReturn<InferConverterReturnType<TConverter>, TFallback>;
|
|
116
|
+
/**
|
|
117
|
+
* Type inference for primitive constructor return types
|
|
118
|
+
* @internal
|
|
119
|
+
*/
|
|
120
|
+
type InferPrimitiveReturnType<TConstructor extends PrimitiveConstructor> = TConstructor extends typeof String ? string : TConstructor extends typeof Number ? number : TConstructor extends typeof Boolean ? boolean : TConstructor extends typeof BigInt ? bigint : TConstructor extends typeof Symbol ? symbol : never;
|
|
121
|
+
/**
|
|
122
|
+
* Type inference for primitive fallback values
|
|
123
|
+
* @internal
|
|
124
|
+
*/
|
|
125
|
+
type InferPrimitiveFallbackType<TFallback extends string | number | boolean | bigint | symbol | undefined> = TFallback extends string ? string : TFallback extends number ? number : TFallback extends boolean ? boolean : TFallback extends bigint ? bigint : TFallback extends symbol ? symbol : undefined;
|
|
126
|
+
//#endregion
|
|
127
|
+
export type { AdvancedConverterReturn, BuiltInConverter, BuiltInConverterFunction, ConditionalReturn, ConverterFunction, EnvaptConverter, InferConverterFallbackType, InferConverterReturnType, InferPrimitiveFallbackType, InferPrimitiveReturnType, JsonValue, MapOfConverterFunctions, PrimitiveConstructor, TimeFallback, TimeUnit };
|
|
128
|
+
//# sourceMappingURL=Conversion.d.mts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/types/Env.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Accepted shape for environment variable lookups. Either a single key or an ordered list of keys.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
type EnvKeyInput = string | readonly [string, ...string[]];
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
interface EnvapterService {
|
|
11
|
+
getRaw(key: EnvKeyInput): string | undefined;
|
|
12
|
+
get(key: EnvKeyInput, def?: string): string | undefined;
|
|
13
|
+
isStrict(): boolean;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export type { EnvKeyInput, EnvapterService };
|
|
17
|
+
//# sourceMappingURL=Env.d.mts.map
|
|
@@ -13,7 +13,7 @@ interface EnvaptOptions<TFallback = string> {
|
|
|
13
13
|
required?: boolean;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* Per-environment profile entry passed to
|
|
16
|
+
* Per-environment profile entry passed to `Envapter.configureProfiles`.
|
|
17
17
|
* @public
|
|
18
18
|
*/
|
|
19
19
|
interface EnvProfile {
|
|
@@ -21,7 +21,7 @@ interface EnvProfile {
|
|
|
21
21
|
paths: string | string[];
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* Configuration object for
|
|
24
|
+
* Configuration object for `Envapter.configureProfiles`. Maps each `Environment` to an optional
|
|
25
25
|
* profile override. Unspecified environments fall through to the default cascade behavior
|
|
26
26
|
* (`.env.${env}.local`, `.env.local`, `.env.${env}`, `.env`).
|
|
27
27
|
* @public
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { EnvaptConverter } from "./Conversion.mjs";
|
|
2
|
+
import { Environment } from "../core/EnvironmentMethods.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/types/Options.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Options for the \@Envapt decorator (modern API). `required: true` is mutually exclusive
|
|
7
|
+
* with `fallback`; see the per-converter overloads in `Envapt.ts` for the type-level mutex.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
interface EnvaptOptions<TFallback = string> {
|
|
11
|
+
fallback?: TFallback;
|
|
12
|
+
converter?: EnvaptConverter<TFallback>;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Per-environment profile entry passed to `Envapter.configureProfiles`.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
interface EnvProfile {
|
|
20
|
+
/** One or more `.env` paths to load for this environment. Order matters: earlier paths take precedence. */
|
|
21
|
+
paths: string | string[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Configuration object for `Envapter.configureProfiles`. Maps each `Environment` to an optional
|
|
25
|
+
* profile override. Unspecified environments fall through to the default cascade behavior
|
|
26
|
+
* (`.env.${env}.local`, `.env.local`, `.env.${env}`, `.env`).
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
type ProfilesConfig = Partial<Record<Environment, EnvProfile>> & {
|
|
30
|
+
/**
|
|
31
|
+
* When `false`, disables the default dotenv-flow cascade entirely. Only the explicitly
|
|
32
|
+
* configured paths are loaded. Defaults to `true` (cascade still runs, configured paths
|
|
33
|
+
* are layered on top with higher precedence).
|
|
34
|
+
*/
|
|
35
|
+
useDefaults?: boolean;
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export type { EnvProfile, EnvaptOptions, ProfilesConfig };
|
|
39
|
+
//# sourceMappingURL=Options.d.mts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from "../StandardSchema.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/types/Schema.d.ts
|
|
4
|
+
declare const _envaptErrBrand: unique symbol;
|
|
5
|
+
type Err<Msg extends string> = Msg & {
|
|
6
|
+
readonly [_envaptErrBrand]: never;
|
|
7
|
+
};
|
|
8
|
+
type SchemaMustBeSync = Err<'Schema must be synchronous. envapt is boot-time config loading; async refinements (validate returning `Promise<Result>`) belong outside the env layer.'>;
|
|
9
|
+
type SchemaConstraint<Schema extends StandardSchemaV1> = ReturnType<Schema['~standard']['validate']> extends Promise<unknown> ? SchemaMustBeSync : Schema;
|
|
10
|
+
//#endregion
|
|
11
|
+
export type { Err, SchemaConstraint, SchemaMustBeSync };
|
|
12
|
+
//# sourceMappingURL=Schema.d.mts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//#region src/types/Source.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A source with no filesystem: an injected object on the browser, or the Cloudflare `env` binding on
|
|
4
|
+
* Workers. The `.env` cascade, profiles, and the `envPaths`/`baseDir`/`configureProfiles` APIs do not
|
|
5
|
+
* apply; only `readVars()` populates the cache.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
interface BareEnvSource {
|
|
9
|
+
/** Return every variable this source provides, as plain strings. */
|
|
10
|
+
readVars(): Record<string, string>;
|
|
11
|
+
/** Leave unset (or `false`); a bare source has no filesystem. */
|
|
12
|
+
readonly supportsFiles?: false;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A filesystem-backed source, like the default {@link NodeEnvSource}. Setting `supportsFiles` to
|
|
16
|
+
* `true` requires all four file capabilities, so the engine can load the `.env` cascade, resolve
|
|
17
|
+
* `baseDir`, and mirror loaded keys back to the ambient environment.
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
interface FileEnvSource {
|
|
21
|
+
/** Return every variable this source provides, as plain strings. */
|
|
22
|
+
readVars(): Record<string, string>;
|
|
23
|
+
/** When `true`, the engine loads the `.env` cascade, profiles, and `envPaths` through the methods below. */
|
|
24
|
+
readonly supportsFiles: true;
|
|
25
|
+
/** Read a file's text, or `undefined` when it is absent or unreadable. Backs the loader and existence checks. */
|
|
26
|
+
readFile(path: string, encoding: string): string | undefined;
|
|
27
|
+
/** Join a relative `.env` path onto `baseDir`; absolute paths are returned unchanged. */
|
|
28
|
+
resolvePath(baseDir: string, candidate: string): string;
|
|
29
|
+
/** Normalize a `baseDir` value (a directory path, or a module / `file:` URL) to an absolute directory path. */
|
|
30
|
+
normalizeBaseDir(value: string | URL): string;
|
|
31
|
+
/** Mirror loaded keys back to the ambient environment (e.g. `process.env`); backs `Envapter.syncProcessEnv`. */
|
|
32
|
+
writeVars(vars: Record<string, string>): void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A pluggable source of environment variables. The default {@link NodeEnvSource} (a
|
|
36
|
+
* {@link FileEnvSource}) reads `process.env` plus the `.env` cascade; a {@link BareEnvSource} lets the
|
|
37
|
+
* same engine run where there is no ambient environment (an injected object on the browser, the
|
|
38
|
+
* Cloudflare `env` binding on Workers). Bind one with `Envapter.useSource`.
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
type EnvSource = BareEnvSource | FileEnvSource;
|
|
42
|
+
//#endregion
|
|
43
|
+
export type { BareEnvSource, EnvSource, FileEnvSource };
|
|
44
|
+
//# sourceMappingURL=Source.d.cts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//#region src/types/Source.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A source with no filesystem: an injected object on the browser, or the Cloudflare `env` binding on
|
|
4
|
+
* Workers. The `.env` cascade, profiles, and the `envPaths`/`baseDir`/`configureProfiles` APIs do not
|
|
5
|
+
* apply; only `readVars()` populates the cache.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
interface BareEnvSource {
|
|
9
|
+
/** Return every variable this source provides, as plain strings. */
|
|
10
|
+
readVars(): Record<string, string>;
|
|
11
|
+
/** Leave unset (or `false`); a bare source has no filesystem. */
|
|
12
|
+
readonly supportsFiles?: false;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A filesystem-backed source, like the default {@link NodeEnvSource}. Setting `supportsFiles` to
|
|
16
|
+
* `true` requires all four file capabilities, so the engine can load the `.env` cascade, resolve
|
|
17
|
+
* `baseDir`, and mirror loaded keys back to the ambient environment.
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
interface FileEnvSource {
|
|
21
|
+
/** Return every variable this source provides, as plain strings. */
|
|
22
|
+
readVars(): Record<string, string>;
|
|
23
|
+
/** When `true`, the engine loads the `.env` cascade, profiles, and `envPaths` through the methods below. */
|
|
24
|
+
readonly supportsFiles: true;
|
|
25
|
+
/** Read a file's text, or `undefined` when it is absent or unreadable. Backs the loader and existence checks. */
|
|
26
|
+
readFile(path: string, encoding: string): string | undefined;
|
|
27
|
+
/** Join a relative `.env` path onto `baseDir`; absolute paths are returned unchanged. */
|
|
28
|
+
resolvePath(baseDir: string, candidate: string): string;
|
|
29
|
+
/** Normalize a `baseDir` value (a directory path, or a module / `file:` URL) to an absolute directory path. */
|
|
30
|
+
normalizeBaseDir(value: string | URL): string;
|
|
31
|
+
/** Mirror loaded keys back to the ambient environment (e.g. `process.env`); backs `Envapter.syncProcessEnv`. */
|
|
32
|
+
writeVars(vars: Record<string, string>): void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A pluggable source of environment variables. The default {@link NodeEnvSource} (a
|
|
36
|
+
* {@link FileEnvSource}) reads `process.env` plus the `.env` cascade; a {@link BareEnvSource} lets the
|
|
37
|
+
* same engine run where there is no ambient environment (an injected object on the browser, the
|
|
38
|
+
* Cloudflare `env` binding on Workers). Bind one with `Envapter.useSource`.
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
type EnvSource = BareEnvSource | FileEnvSource;
|
|
42
|
+
//#endregion
|
|
43
|
+
export type { BareEnvSource, EnvSource, FileEnvSource };
|
|
44
|
+
//# sourceMappingURL=Source.d.mts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/Debug.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Debug log levels for {@link Envapter.debug}. `silent` (default) emits nothing.
|
|
4
|
+
* `warn` covers signals that might indicate misconfiguration: failed file reads,
|
|
5
|
+
* unresolved templates (when not strict), fallback values used in place of missing
|
|
6
|
+
* env. `verbose` adds every loaded file, per-file key count, per-key load lines, and
|
|
7
|
+
* effective-paths / cache-rebuild notices.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
type DebugLevel = 'silent' | 'warn' | 'verbose';
|
|
11
|
+
//#endregion
|
|
12
|
+
export { DebugLevel };
|
|
13
|
+
//# sourceMappingURL=Debug.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{EnvaptError as e}from"./Error.mjs";import{readRuntimeEnv as t,writeRuntimeLine as n}from"./runtime.mjs";const r=new Set([`silent`,`warn`,`verbose`]);let i=`silent`,a=!1;function o(e){return e!==void 0&&r.has(e)}function s(){if(!a){let e=t().ENVAPT_DEBUG;i=o(e)?e:`silent`,a=!0}return i}function c(t){if(!o(t))throw new e(302,`Invalid debug level "${String(t)}". Expected 'silent' | 'warn' | 'verbose'.`);i=t,a=!0}function l(){return s()}function u(e){let t=s();(t===`warn`||t===`verbose`)&&n(`[envapt] ${e}`)}function d(e){s()===`verbose`&&n(`[envapt] ${e}`)}export{d as debugVerbose,u as debugWarn,l as getDebugLevel,c as setDebugLevel};
|
|
2
|
+
//# sourceMappingURL=Debug.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Debug.mjs","names":[],"sources":["../../src/Debug.ts"],"sourcesContent":["import { EnvaptError, EnvaptErrorCodes } from './Error';\nimport { readRuntimeEnv, writeRuntimeLine } from './runtime';\n\n/**\n * Debug log levels for {@link Envapter.debug}. `silent` (default) emits nothing.\n * `warn` covers signals that might indicate misconfiguration: failed file reads,\n * unresolved templates (when not strict), fallback values used in place of missing\n * env. `verbose` adds every loaded file, per-file key count, per-key load lines, and\n * effective-paths / cache-rebuild notices.\n * @public\n */\nexport type DebugLevel = 'silent' | 'warn' | 'verbose';\n\nconst VALID_LEVELS: ReadonlySet<string> = new Set<DebugLevel>(['silent', 'warn', 'verbose']);\n\nlet currentLevel: DebugLevel = 'silent';\nlet initialized = false;\n\nfunction isDebugLevel(value: string | undefined): value is DebugLevel {\n return value !== undefined && VALID_LEVELS.has(value);\n}\n\n// Reads `ENVAPT_DEBUG` lazily on first access. Setter wins after that.\nfunction resolveLevel(): DebugLevel {\n if (!initialized) {\n const fromEnv = readRuntimeEnv().ENVAPT_DEBUG;\n currentLevel = isDebugLevel(fromEnv) ? fromEnv : 'silent';\n initialized = true;\n }\n return currentLevel;\n}\n\n/** @internal */\nexport function setDebugLevel(level: DebugLevel): void {\n if (!isDebugLevel(level)) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n `Invalid debug level \"${String(level)}\". Expected 'silent' | 'warn' | 'verbose'.`\n );\n }\n currentLevel = level;\n initialized = true;\n}\n\n/** @internal */\nexport function getDebugLevel(): DebugLevel {\n return resolveLevel();\n}\n\n/** @internal */\nexport function resetDebugForTesting(): void {\n currentLevel = 'silent';\n initialized = false;\n}\n\n/** @internal */\nexport function debugWarn(message: string): void {\n const level = resolveLevel();\n if (level === 'warn' || level === 'verbose') {\n writeRuntimeLine(`[envapt] ${message}`);\n }\n}\n\n/** @internal */\nexport function debugVerbose(message: string): void {\n if (resolveLevel() === 'verbose') {\n writeRuntimeLine(`[envapt] ${message}`);\n }\n}\n"],"mappings":"+GAaA,MAAM,EAAoC,IAAI,IAAgB,CAAC,SAAU,OAAQ,SAAS,CAAC,EAE3F,IAAI,EAA2B,SAC3B,EAAc,GAElB,SAAS,EAAa,EAAgD,CAClE,OAAO,IAAU,IAAA,IAAa,EAAa,IAAI,CAAK,CACxD,CAGA,SAAS,GAA2B,CAChC,GAAI,CAAC,EAAa,CACd,IAAM,EAAU,EAAe,EAAE,aACjC,EAAe,EAAa,CAAO,EAAI,EAAU,SACjD,EAAc,EAClB,CACA,OAAO,CACX,CAGA,SAAgB,EAAc,EAAyB,CACnD,GAAI,CAAC,EAAa,CAAK,EACnB,MAAM,IAAI,EAAA,IAEN,wBAAwB,OAAO,CAAK,EAAE,2CAC1C,EAEJ,EAAe,EACf,EAAc,EAClB,CAGA,SAAgB,GAA4B,CACxC,OAAO,EAAa,CACxB,CASA,SAAgB,EAAU,EAAuB,CAC7C,IAAM,EAAQ,EAAa,GACvB,IAAU,QAAU,IAAU,YAC9B,EAAiB,YAAY,GAAS,CAE9C,CAGA,SAAgB,EAAa,EAAuB,CAC5C,EAAa,IAAM,WACnB,EAAiB,YAAY,GAAS,CAE9C"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/Dotenv.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Public options for the internal `.env` loader. Mirrors the subset of dotenv's
|
|
4
|
+
* `config()` options that envapt actually supports (no DOTENV_KEY, no quiet).
|
|
5
|
+
* For debug output, use `Envapter.debug` (or the `ENVAPT_DEBUG` env var).
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
interface EnvFileOptions {
|
|
10
|
+
/** Encoding for reading .env files. Defaults to 'utf8'. */
|
|
11
|
+
encoding?: string;
|
|
12
|
+
/** When true, later files override earlier ones (and existing processEnv values). Default false (first-wins). */
|
|
13
|
+
override?: boolean;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { EnvFileOptions };
|
|
17
|
+
//# sourceMappingURL=Dotenv.d.mts.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{debugVerbose as e,debugWarn as t}from"./Debug.mjs";const n=/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=(.*)$/u;function r(e){let t=new Map,n=e.split(/\r?\n/u);for(let e=0;e<n.length;e++){let r=i(n,e);e=r.endLine,r.entry&&t.set(r.entry.key,r.entry.value)}return t}function i(e,t){let r=e[t]??``,i=r.trim();if(i===``||i.startsWith(`#`))return{entry:void 0,endLine:t};let s=r.match(n);if(!s)return{entry:void 0,endLine:t};let c=s[1],l=(s[2]??``).replace(/^\s+/u,``),u=l[0];if(u===`"`||u===`'`||u==="`"){let n=a(l,e,t,u);return{entry:{key:c,value:n.value},endLine:n.endLine}}return{entry:{key:c,value:o(l)},endLine:t}}function a(e,t,n,r){let i=e,a=n,o=c(i,r);for(;o<0&&a<t.length-1;)a++,i+=`\n${t[a]??``}`,o=c(i,r);let s=o>0?i.slice(1,o):i.slice(1);return{value:r===`"`?l(s):s,endLine:a}}function o(e){let t=s(e);return(t===-1?e:e.slice(0,t)).trimEnd()}function s(e){for(let t=0;t<e.length;t++)if(e[t]===`#`&&(t===0||/\s/u.test(e[t-1])))return t;return-1}function c(e,t){for(let n=e.length-1;n>0;n--)if(e[n]===t){if(t===`"`){let t=0,r=n-1;for(;r>=0&&e[r]===`\\`;)t++,r--;if(t%2==1)continue}return n}return-1}function l(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(r!==`\\`||n===e.length-1){t+=r;continue}let i=e[n+1];switch(n++,i){case`n`:t+=`
|
|
2
|
+
`;break;case`r`:t+=`\r`;break;case`t`:t+=` `;break;case`\\`:t+=`\\`;break;case`"`:t+=`"`;break;default:t+=`\\${i??``}`}}return t}function u(n){let i=Array.isArray(n.path)?n.path:[n.path],a=n.encoding??`utf8`,o=n.override??!1,s=new Set;for(let c of i){let i=n.readFile(c,a);if(i===void 0){t(`could not read ${c}`);continue}let l=r(i);e(`loaded ${c}: ${l.size} ${l.size===1?`key`:`keys`}`);for(let[t,r]of l)(!Object.prototype.hasOwnProperty.call(n.processEnv,t)||o)&&(n.processEnv[t]=r,s.add(t),e(`${c} -> ${t}`))}return s}export{u as loadDotenv};
|
|
3
|
+
//# sourceMappingURL=Dotenv.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dotenv.mjs","names":[],"sources":["../../src/Dotenv.ts"],"sourcesContent":["import { debugVerbose, debugWarn } from './Debug';\n\n/**\n * Public options for the internal `.env` loader. Mirrors the subset of dotenv's\n * `config()` options that envapt actually supports (no DOTENV_KEY, no quiet).\n * For debug output, use `Envapter.debug` (or the `ENVAPT_DEBUG` env var).\n *\n * @public\n */\nexport interface EnvFileOptions {\n /** Encoding for reading .env files. Defaults to 'utf8'. */\n encoding?: string;\n /** When true, later files override earlier ones (and existing processEnv values). Default false (first-wins). */\n override?: boolean;\n}\n\n/**\n * Internal call signature used by `EnvapterBase`. The `path` and `processEnv`\n * fields are managed by envapt and never user-supplied.\n * @internal\n */\nexport interface LoadDotenvInput extends EnvFileOptions {\n path: string | string[];\n processEnv: Record<string, string>;\n // Injected so the loader stays free of `node:fs`. Returns `undefined` when the file is absent.\n readFile(path: string, encoding: string): string | undefined;\n}\n\n// Matches: optional `export`, KEY name, optional whitespace, `=`, optional whitespace, value tail.\n// Multi-line quoted values are handled by re-buffering subsequent lines below.\n// Bounded by anchors with linear-time quantifiers; no catastrophic backtracking risk -- justified\n// eslint-disable-next-line security/detect-unsafe-regex\nconst KEY_LINE_RE = /^\\s*(?:export\\s+)?([A-Za-z_][A-Za-z0-9_]*)\\s*=(.*)$/u;\n\n/**\n * Parse a `.env` text blob into a `Map<string, string>`.\n *\n * Supported syntax:\n * - `KEY=value` and `export KEY=value`\n * - blank lines and full-line `# comments`\n * - single-quoted `'literal'` values (no escape interpretation)\n * - double-quoted `\"value\"` values (interprets `\\n`, `\\r`, `\\t`, `\\\\`, `\\\"`)\n * - backtick-quoted values (literal, like single quotes)\n * - quoted values may span multiple lines\n * - inline `# comment` after an unquoted value (requires whitespace before `#`)\n * - empty values resolve to `\"\"`\n *\n * Mirrors dotenv's quirk where unescaped inner quotes inside a quoted value\n * are tolerated by greedy-matching to the rightmost matching quote on the\n * (possibly multi-line) value buffer. This is what lets a value like\n * `JSON=\"{\"name\":\"x\"}\"` round-trip without escaping.\n *\n * Does NOT perform `${VAR}` expansion — envapt's `Parser` handles that downstream.\n * @internal\n */\nexport function parseDotenv(src: string): Map<string, string> {\n const out = new Map<string, string>();\n const lines = src.split(/\\r?\\n/u);\n\n for (let i = 0; i < lines.length; i++) {\n const consumed = parseEntry(lines, i);\n i = consumed.endLine;\n if (consumed.entry) out.set(consumed.entry.key, consumed.entry.value);\n }\n\n return out;\n}\n\ninterface ParsedEntry {\n key: string;\n value: string;\n}\n\nfunction parseEntry(lines: string[], start: number): { entry: ParsedEntry | undefined; endLine: number } {\n /* v8 ignore next -- @preserve caller bounds-checks start so this never falls back */\n const line = lines[start] ?? '';\n const trimmedLine = line.trim();\n if (trimmedLine === '' || trimmedLine.startsWith('#')) return { entry: undefined, endLine: start };\n\n const match = line.match(KEY_LINE_RE);\n if (!match) return { entry: undefined, endLine: start };\n\n const key = match[1] as string;\n // Drop only leading whitespace before the value; trailing whitespace and inline comments\n // are dealt with below depending on whether the value is quoted.\n /* v8 ignore next -- @preserve regex group 2 always matches via `(.*)`, fallback is defensive */\n const rest = (match[2] ?? '').replace(/^\\s+/u, '');\n const firstChar = rest[0];\n\n if (firstChar === '\"' || firstChar === \"'\" || firstChar === '`') {\n const consumed = consumeQuotedValue(rest, lines, start, firstChar);\n return { entry: { key, value: consumed.value }, endLine: consumed.endLine };\n }\n\n return { entry: { key, value: stripInlineComment(rest) }, endLine: start };\n}\n\nfunction consumeQuotedValue(\n firstLineRest: string,\n lines: string[],\n startLine: number,\n quote: string\n): { value: string; endLine: number } {\n let buffer = firstLineRest;\n let cursor = startLine;\n let closeIdx = findLastUnescapedQuote(buffer, quote);\n\n while (closeIdx < 0 && cursor < lines.length - 1) {\n cursor++;\n /* v8 ignore next -- @preserve cursor is bounded by the while condition above */\n buffer += `\\n${lines[cursor] ?? ''}`;\n closeIdx = findLastUnescapedQuote(buffer, quote);\n }\n\n const inner = closeIdx > 0 ? buffer.slice(1, closeIdx) : buffer.slice(1);\n return { value: quote === '\"' ? unescapeDouble(inner) : inner, endLine: cursor };\n}\n\nfunction stripInlineComment(value: string): string {\n const hashIdx = findInlineCommentStart(value);\n const stripped = hashIdx === -1 ? value : value.slice(0, hashIdx);\n return stripped.trimEnd();\n}\n\nfunction findInlineCommentStart(value: string): number {\n for (let i = 0; i < value.length; i++) {\n if (value[i] === '#' && (i === 0 || /\\s/u.test(value[i - 1] as string))) return i;\n }\n return -1;\n}\n\n/**\n * Find the rightmost matching closing quote in `buffer` (skipping index 0 which is the\n * opening quote). For `\"`, a quote preceded by an odd number of backslashes is escaped\n * and ignored. Single and backtick quotes do not unescape.\n */\nfunction findLastUnescapedQuote(buffer: string, quote: string): number {\n for (let i = buffer.length - 1; i > 0; i--) {\n if (buffer[i] !== quote) continue;\n if (quote === '\"') {\n let backslashes = 0;\n let k = i - 1;\n while (k >= 0 && buffer[k] === '\\\\') {\n backslashes++;\n k--;\n }\n if (backslashes % 2 === 1) continue; // escaped\n }\n return i;\n }\n return -1;\n}\n\nfunction unescapeDouble(raw: string): string {\n let out = '';\n for (let i = 0; i < raw.length; i++) {\n const ch = raw[i];\n if (ch !== '\\\\' || i === raw.length - 1) {\n out += ch;\n continue;\n }\n const next = raw[i + 1];\n i++;\n switch (next) {\n case 'n':\n out += '\\n';\n break;\n case 'r':\n out += '\\r';\n break;\n case 't':\n out += '\\t';\n break;\n case '\\\\':\n out += '\\\\';\n break;\n case '\"':\n out += '\"';\n break;\n default:\n /* v8 ignore next -- @preserve `next` is always defined when this branch is reached (guarded above) */\n out += `\\\\${next ?? ''}`;\n }\n }\n return out;\n}\n\n/**\n * Load one or more `.env` files into a target `processEnv` map. Mirrors the\n * subset of dotenv's `config()` semantics that envapt depends on: first-wins\n * across multiple paths by default, optional `override: true`, optional\n * non-UTF8 encoding, missing files are skipped silently.\n *\n * Returns the set of keys actually written into `input.processEnv`. Skipped\n * collisions (under default `override: false`) are NOT included.\n * @internal\n */\nexport function loadDotenv(input: LoadDotenvInput): Set<string> {\n const paths = Array.isArray(input.path) ? input.path : [input.path];\n const encoding = input.encoding ?? 'utf8';\n const override = input.override ?? false;\n const written = new Set<string>();\n\n for (const filePath of paths) {\n const src = input.readFile(filePath, encoding);\n if (src === undefined) {\n debugWarn(`could not read ${filePath}`);\n continue;\n }\n\n const parsed = parseDotenv(src);\n debugVerbose(`loaded ${filePath}: ${parsed.size} ${parsed.size === 1 ? 'key' : 'keys'}`);\n for (const [key, value] of parsed) {\n const exists = Object.prototype.hasOwnProperty.call(input.processEnv, key);\n if (!exists || override) {\n input.processEnv[key] = value;\n written.add(key);\n debugVerbose(`${filePath} -> ${key}`);\n }\n }\n }\n\n return written;\n}\n"],"mappings":"0DAgCA,MAAM,EAAc,uDAuBpB,SAAgB,EAAY,EAAkC,CAC1D,IAAM,EAAM,IAAI,IACV,EAAQ,EAAI,MAAM,QAAQ,EAEhC,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAQ,IAAK,CACnC,IAAM,EAAW,EAAW,EAAO,CAAC,EACpC,EAAI,EAAS,QACT,EAAS,OAAO,EAAI,IAAI,EAAS,MAAM,IAAK,EAAS,MAAM,KAAK,CACxE,CAEA,OAAO,CACX,CAOA,SAAS,EAAW,EAAiB,EAAoE,CAErG,IAAM,EAAO,EAAM,IAAU,GACvB,EAAc,EAAK,KAAK,EAC9B,GAAI,IAAgB,IAAM,EAAY,WAAW,GAAG,EAAG,MAAO,CAAE,MAAO,IAAA,GAAW,QAAS,CAAM,EAEjG,IAAM,EAAQ,EAAK,MAAM,CAAW,EACpC,GAAI,CAAC,EAAO,MAAO,CAAE,MAAO,IAAA,GAAW,QAAS,CAAM,EAEtD,IAAM,EAAM,EAAM,GAIZ,GAAQ,EAAM,IAAM,IAAI,QAAQ,QAAS,EAAE,EAC3C,EAAY,EAAK,GAEvB,GAAI,IAAc,KAAO,IAAc,KAAO,IAAc,IAAK,CAC7D,IAAM,EAAW,EAAmB,EAAM,EAAO,EAAO,CAAS,EACjE,MAAO,CAAE,MAAO,CAAE,MAAK,MAAO,EAAS,KAAM,EAAG,QAAS,EAAS,OAAQ,CAC9E,CAEA,MAAO,CAAE,MAAO,CAAE,MAAK,MAAO,EAAmB,CAAI,CAAE,EAAG,QAAS,CAAM,CAC7E,CAEA,SAAS,EACL,EACA,EACA,EACA,EACkC,CAClC,IAAI,EAAS,EACT,EAAS,EACT,EAAW,EAAuB,EAAQ,CAAK,EAEnD,KAAO,EAAW,GAAK,EAAS,EAAM,OAAS,GAC3C,IAEA,GAAU,KAAK,EAAM,IAAW,KAChC,EAAW,EAAuB,EAAQ,CAAK,EAGnD,IAAM,EAAQ,EAAW,EAAI,EAAO,MAAM,EAAG,CAAQ,EAAI,EAAO,MAAM,CAAC,EACvE,MAAO,CAAE,MAAO,IAAU,IAAM,EAAe,CAAK,EAAI,EAAO,QAAS,CAAO,CACnF,CAEA,SAAS,EAAmB,EAAuB,CAC/C,IAAM,EAAU,EAAuB,CAAK,EAE5C,OADiB,IAAY,GAAK,EAAQ,EAAM,MAAM,EAAG,CAAO,GAChD,QAAQ,CAC5B,CAEA,SAAS,EAAuB,EAAuB,CACnD,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAQ,IAC9B,GAAI,EAAM,KAAO,MAAQ,IAAM,GAAK,MAAM,KAAK,EAAM,EAAI,EAAY,GAAI,OAAO,EAEpF,MAAO,EACX,CAOA,SAAS,EAAuB,EAAgB,EAAuB,CACnE,IAAK,IAAI,EAAI,EAAO,OAAS,EAAG,EAAI,EAAG,IAC/B,KAAO,KAAO,EAClB,IAAI,IAAU,IAAK,CACf,IAAI,EAAc,EACd,EAAI,EAAI,EACZ,KAAO,GAAK,GAAK,EAAO,KAAO,MAC3B,IACA,IAEJ,GAAI,EAAc,GAAM,EAAG,QAC/B,CACA,OAAO,CADP,CAGJ,MAAO,EACX,CAEA,SAAS,EAAe,EAAqB,CACzC,IAAI,EAAM,GACV,IAAK,IAAI,EAAI,EAAG,EAAI,EAAI,OAAQ,IAAK,CACjC,IAAM,EAAK,EAAI,GACf,GAAI,IAAO,MAAQ,IAAM,EAAI,OAAS,EAAG,CACrC,GAAO,EACP,QACJ,CACA,IAAM,EAAO,EAAI,EAAI,GAErB,OADA,IACQ,EAAR,CACI,IAAK,IACD,GAAO;EACP,MACJ,IAAK,IACD,GAAO,KACP,MACJ,IAAK,IACD,GAAO,IACP,MACJ,IAAK,KACD,GAAO,KACP,MACJ,IAAK,IACD,GAAO,IACP,MACJ,QAEI,GAAO,KAAK,GAAQ,IAC5B,CACJ,CACA,OAAO,CACX,CAYA,SAAgB,EAAW,EAAqC,CAC5D,IAAM,EAAQ,MAAM,QAAQ,EAAM,IAAI,EAAI,EAAM,KAAO,CAAC,EAAM,IAAI,EAC5D,EAAW,EAAM,UAAY,OAC7B,EAAW,EAAM,UAAY,GAC7B,EAAU,IAAI,IAEpB,IAAK,IAAM,KAAY,EAAO,CAC1B,IAAM,EAAM,EAAM,SAAS,EAAU,CAAQ,EAC7C,GAAI,IAAQ,IAAA,GAAW,CACnB,EAAU,kBAAkB,GAAU,EACtC,QACJ,CAEA,IAAM,EAAS,EAAY,CAAG,EAC9B,EAAa,UAAU,EAAS,IAAI,EAAO,KAAK,GAAG,EAAO,OAAS,EAAI,MAAQ,QAAQ,EACvF,IAAK,GAAM,CAAC,EAAK,KAAU,GAEnB,CADW,OAAO,UAAU,eAAe,KAAK,EAAM,WAAY,CAC5D,GAAK,KACX,EAAM,WAAW,GAAO,EACxB,EAAQ,IAAI,CAAG,EACf,EAAa,GAAG,EAAS,MAAM,GAAK,EAGhD,CAEA,OAAO,CACX"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Environment } from "./core/EnvironmentMethods.mjs";
|
|
2
|
+
import { AdvancedMethods } from "./core/AdvancedMethods.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/Envapter.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Main configuration class for environment variable management.
|
|
7
|
+
*
|
|
8
|
+
* Provides both static and instance methods for retrieving typed environment variables
|
|
9
|
+
* with support for template resolution, multiple .env files, and environment detection.
|
|
10
|
+
*
|
|
11
|
+
* Extend your own classes from this to define properties with \@Envapt decorators and get access to environment-variable methods.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* // Static usage
|
|
16
|
+
* const port = Envapter.getNumber('PORT', 3000);
|
|
17
|
+
* const url = Envapter.get('API_URL', 'http://localhost');
|
|
18
|
+
* const replica = Envapter.get(['READONLY_URL', 'DATABASE_URL'], 'sqlite://memory');
|
|
19
|
+
*
|
|
20
|
+
* // Instance usage
|
|
21
|
+
* const env = new Envapter();
|
|
22
|
+
* const dbUrl = env.get('DATABASE_URL', 'sqlite://memory');
|
|
23
|
+
* const primaryHost = env.get(['PRIMARY_HOST', 'SECONDARY_HOST']);
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
declare class Envapter extends AdvancedMethods {
|
|
29
|
+
/**
|
|
30
|
+
* Tagged template literal for resolving environment variables in template strings.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* // Given API_HOST=api.example.com and API_PORT=8080 in environment
|
|
35
|
+
* const endpoint = Envapter.resolve`Connecting to ${'API_HOST'}:${'API_PORT'}`;
|
|
36
|
+
* // Returns: "Connecting to api.example.com:8080"
|
|
37
|
+
*
|
|
38
|
+
* // Works with template variables in .env too:
|
|
39
|
+
* // API_URL=https://${API_HOST}:${API_PORT}
|
|
40
|
+
* const message = Envapter.resolve`Service endpoint: ${'API_URL'}`;
|
|
41
|
+
* // Returns: "Service endpoint: https://api.example.com:8080"
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
static resolve(strings: TemplateStringsArray, ...keys: string[]): string;
|
|
45
|
+
/**
|
|
46
|
+
* @see {@link Envapter.resolve}
|
|
47
|
+
*/
|
|
48
|
+
resolve(strings: TemplateStringsArray, ...keys: string[]): string;
|
|
49
|
+
/**
|
|
50
|
+
* Assert that one or more environment variables are present and non-empty (post-trim,
|
|
51
|
+
* after template resolution). Throws `MissingEnvValue` listing every missing key.
|
|
52
|
+
*
|
|
53
|
+
* For typed fail-fast in functional code, use `Envapter.getUsing(key, { converter, required: true })`.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* Envapter.require('DATABASE_URL');
|
|
58
|
+
* Envapter.require('DATABASE_URL', 'API_KEY', 'SENTRY_DSN');
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
static require(...keys: [string, ...string[]]): void;
|
|
62
|
+
private static resolveAndValidate;
|
|
63
|
+
/**
|
|
64
|
+
* @see {@link Envapter.require}
|
|
65
|
+
*/
|
|
66
|
+
require(...keys: [string, ...string[]]): void;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { Envapter };
|
|
70
|
+
//# sourceMappingURL=Envapter.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{EnvaptError as e}from"./Error.mjs";import"./core/EnvapterBase.mjs";import"./core/EnvironmentMethods.mjs";import{AdvancedMethods as t}from"./core/AdvancedMethods.mjs";var n=class n extends t{static resolve(t,...r){let i=n.strict;return t.reduce((t,n,a)=>{let o=r[a];if(!o)return t+n;let s=super.get(o,``);if(i&&s.trim()===``)throw new e(305,`Cannot resolve template variable "\${${o}}": value is missing or empty.`);return t+n+s},``)}resolve(e,...t){return n.resolve(e,...t)}static require(...t){let r=[];for(let e of t)n.resolveAndValidate(e)===void 0&&r.push(e);if(r.length>0)throw new e(305,`Missing required environment variables: ${r.join(`, `)}.`)}static resolveAndValidate(e){let{value:t}=this.resolveKeyInput(e);if(t===void 0)return;let n=this.templateResolver.resolveTemplate(e,t);if(n.trim()!==``)return n}require(...e){n.require(...e)}};export{n as Envapter};
|
|
2
|
+
//# sourceMappingURL=Envapter.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Envapter.mjs","names":[],"sources":["../../src/Envapter.ts"],"sourcesContent":["import { AdvancedMethods } from './core';\nimport { EnvaptError, EnvaptErrorCodes } from './Error';\n\nexport { EnvaptCache, Environment } from './core';\n\n/**\n * Main configuration class for environment variable management.\n *\n * Provides both static and instance methods for retrieving typed environment variables\n * with support for template resolution, multiple .env files, and environment detection.\n *\n * Extend your own classes from this to define properties with \\@Envapt decorators and get access to environment-variable methods.\n *\n * @example\n * ```ts\n * // Static usage\n * const port = Envapter.getNumber('PORT', 3000);\n * const url = Envapter.get('API_URL', 'http://localhost');\n * const replica = Envapter.get(['READONLY_URL', 'DATABASE_URL'], 'sqlite://memory');\n *\n * // Instance usage\n * const env = new Envapter();\n * const dbUrl = env.get('DATABASE_URL', 'sqlite://memory');\n * const primaryHost = env.get(['PRIMARY_HOST', 'SECONDARY_HOST']);\n * ```\n *\n * @public\n */\nexport class Envapter extends AdvancedMethods {\n /**\n * Tagged template literal for resolving environment variables in template strings.\n *\n * @example\n * ```ts\n * // Given API_HOST=api.example.com and API_PORT=8080 in environment\n * const endpoint = Envapter.resolve`Connecting to ${'API_HOST'}:${'API_PORT'}`;\n * // Returns: \"Connecting to api.example.com:8080\"\n *\n * // Works with template variables in .env too:\n * // API_URL=https://${API_HOST}:${API_PORT}\n * const message = Envapter.resolve`Service endpoint: ${'API_URL'}`;\n * // Returns: \"Service endpoint: https://api.example.com:8080\"\n * ```\n */\n static resolve(strings: TemplateStringsArray, ...keys: string[]): string {\n const strict = Envapter.strict;\n return strings.reduce((result, string, i) => {\n const envKey = keys[i];\n if (!envKey) return result + string;\n const raw = super.get(envKey, '');\n if (strict && raw.trim() === '') {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Cannot resolve template variable \"\\${${envKey}}\": value is missing or empty.`\n );\n }\n return result + string + raw;\n }, '');\n }\n\n /**\n * @see {@link Envapter.resolve}\n */\n resolve(strings: TemplateStringsArray, ...keys: string[]): string {\n return Envapter.resolve(strings, ...keys);\n }\n\n /**\n * Assert that one or more environment variables are present and non-empty (post-trim,\n * after template resolution). Throws `MissingEnvValue` listing every missing key.\n *\n * For typed fail-fast in functional code, use `Envapter.getUsing(key, { converter, required: true })`.\n *\n * @example\n * ```ts\n * Envapter.require('DATABASE_URL');\n * Envapter.require('DATABASE_URL', 'API_KEY', 'SENTRY_DSN');\n * ```\n */\n static require(...keys: [string, ...string[]]): void {\n const missing: string[] = [];\n for (const k of keys) {\n if (Envapter.resolveAndValidate(k) === undefined) missing.push(k);\n }\n\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Missing required environment variables: ${missing.join(', ')}.`\n );\n }\n }\n\n private static resolveAndValidate(key: string): string | undefined {\n const { value } = this.resolveKeyInput(key);\n if (value === undefined) return undefined;\n const resolved = this.templateResolver.resolveTemplate(key, value);\n if (resolved.trim() === '') return undefined;\n return resolved;\n }\n\n /**\n * @see {@link Envapter.require}\n */\n require(...keys: [string, ...string[]]): void {\n Envapter.require(...keys);\n }\n}\n"],"mappings":"6KA4BA,IAAa,EAAb,MAAa,UAAiB,CAAgB,CAgB1C,OAAO,QAAQ,EAA+B,GAAG,EAAwB,CACrE,IAAM,EAAS,EAAS,OACxB,OAAO,EAAQ,QAAQ,EAAQ,EAAQ,IAAM,CACzC,IAAM,EAAS,EAAK,GACpB,GAAI,CAAC,EAAQ,OAAO,EAAS,EAC7B,IAAM,EAAM,MAAM,IAAI,EAAQ,EAAE,EAChC,GAAI,GAAU,EAAI,KAAK,IAAM,GACzB,MAAM,IAAI,EAAA,IAEN,wCAAwC,EAAO,+BACnD,EAEJ,OAAO,EAAS,EAAS,CAC7B,EAAG,EAAE,CACT,CAKA,QAAQ,EAA+B,GAAG,EAAwB,CAC9D,OAAO,EAAS,QAAQ,EAAS,GAAG,CAAI,CAC5C,CAcA,OAAO,QAAQ,GAAG,EAAmC,CACjD,IAAM,EAAoB,CAAC,EAC3B,IAAK,IAAM,KAAK,EACR,EAAS,mBAAmB,CAAC,IAAM,IAAA,IAAW,EAAQ,KAAK,CAAC,EAGpE,GAAI,EAAQ,OAAS,EACjB,MAAM,IAAI,EAAA,IAEN,2CAA2C,EAAQ,KAAK,IAAI,EAAE,EAClE,CAER,CAEA,OAAe,mBAAmB,EAAiC,CAC/D,GAAM,CAAE,SAAU,KAAK,gBAAgB,CAAG,EAC1C,GAAI,IAAU,IAAA,GAAW,OACzB,IAAM,EAAW,KAAK,iBAAiB,gBAAgB,EAAK,CAAK,EAC7D,KAAS,KAAK,IAAM,GACxB,OAAO,CACX,CAKA,QAAQ,GAAG,EAAmC,CAC1C,EAAS,QAAQ,GAAG,CAAI,CAC5B,CACJ"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from "./StandardSchema.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/Error.d.ts
|
|
4
|
+
declare enum EnvaptErrorCodes {
|
|
5
|
+
/** Thrown when an invalid fallback value is provided */
|
|
6
|
+
InvalidFallback = 101,
|
|
7
|
+
/** Thrown when fallback value type doesn't match expected converter type */
|
|
8
|
+
InvalidFallbackType = 102,
|
|
9
|
+
/** Thrown when array fallback contains elements of wrong type */
|
|
10
|
+
ArrayFallbackElementTypeMismatch = 103,
|
|
11
|
+
/** Thrown when fallback type doesn't match the specified converter */
|
|
12
|
+
FallbackConverterTypeMismatch = 104,
|
|
13
|
+
/** Thrown when a time-string fallback is malformed (does not match the required `<number><unit>` format) */
|
|
14
|
+
MalformedTimeFallback = 105,
|
|
15
|
+
/** Thrown when invalid array converter configuration is provided */
|
|
16
|
+
InvalidArrayConverterType = 201,
|
|
17
|
+
/** Thrown when an invalid built-in converter is specified */
|
|
18
|
+
InvalidBuiltInConverter = 202,
|
|
19
|
+
/** Thrown when a custom converter is not a function */
|
|
20
|
+
InvalidCustomConverter = 203,
|
|
21
|
+
/** Thrown when converter type is not recognized */
|
|
22
|
+
InvalidConverterType = 204,
|
|
23
|
+
/** Thrown when primitive type coercion on fallback value fails */
|
|
24
|
+
PrimitiveCoercionFailed = 205,
|
|
25
|
+
/** Thrown when an array element fails to convert to the configured element type */
|
|
26
|
+
ArrayElementConversionFailed = 206,
|
|
27
|
+
/** Thrown under strict mode when an array element is empty or whitespace only */
|
|
28
|
+
EmptyArrayElement = 207,
|
|
29
|
+
/** Thrown when a Standard Schema returns issues for a non-empty env value */
|
|
30
|
+
SchemaValidationFailed = 208,
|
|
31
|
+
/** Thrown when a Standard Schema's `validate` itself throws (e.g. a refinement that crashes) */
|
|
32
|
+
SchemaThrew = 209,
|
|
33
|
+
/** Thrown when delimiter is missing in array converter configuration */
|
|
34
|
+
MissingDelimiter = 301,
|
|
35
|
+
/** Thrown when invalid user-defined configuration is provided */
|
|
36
|
+
InvalidUserDefinedConfig = 302,
|
|
37
|
+
/** Thrown when specified environment files don't exist */
|
|
38
|
+
EnvFilesNotFound = 303,
|
|
39
|
+
/** Thrown when no valid environment key is provided */
|
|
40
|
+
InvalidKeyInput = 304,
|
|
41
|
+
/** Thrown when a required environment value is missing or empty (post-trim) */
|
|
42
|
+
MissingEnvValue = 305,
|
|
43
|
+
/** Thrown when a file-based API (envPaths, baseDir, configureProfiles) is used on a source without filesystem support */
|
|
44
|
+
FileApiUnsupported = 306,
|
|
45
|
+
/** Thrown when an environment value is read before a source is bound via Envapter.useSource */
|
|
46
|
+
NoSourceBound = 307
|
|
47
|
+
}
|
|
48
|
+
interface EnvaptErrorOptions {
|
|
49
|
+
issues?: readonly StandardSchemaV1.Issue[];
|
|
50
|
+
cause?: unknown;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Custom error for better DX and debugging when using Envapt.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* throw new EnvaptError(EnvaptErrorCodes.InvalidFallback, "Invalid fallback value provided for environment variable.");
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare class EnvaptError extends Error {
|
|
61
|
+
readonly code: EnvaptErrorCodes;
|
|
62
|
+
/**
|
|
63
|
+
* Populated only for {@link EnvaptErrorCodes.SchemaValidationFailed} (208). For every other
|
|
64
|
+
* code this is `undefined`. Lets callers do `if (err.code === 208) err.issues?.forEach(...)`
|
|
65
|
+
* without a type cast.
|
|
66
|
+
*/
|
|
67
|
+
readonly issues: readonly StandardSchemaV1.Issue[] | undefined;
|
|
68
|
+
constructor(code: EnvaptErrorCodes, message: string, options?: EnvaptErrorOptions);
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { EnvaptError, EnvaptErrorCodes };
|
|
72
|
+
//# sourceMappingURL=Error.d.mts.map
|