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":"Envapt.cjs","names":["EnvaptError","Validator","createPropertyDecorator"],"sources":["../../../src/decorators/Envapt.ts"],"sourcesContent":["import { createPropertyDecorator } from './createPropertyDecorator';\nimport { EnvaptError, EnvaptErrorCodes } from '../Error';\nimport { Validator } from '../Validators';\n\nimport type { ArrayOf } from '../converters';\nimport type { InferSchemaOutput, StandardSchemaV1 } from '../StandardSchema';\nimport type {\n BuiltInConverter,\n ConverterFunction,\n EnvKeyInput,\n EnvaptConverter,\n EnvaptOptions,\n InferConverterFallbackType,\n InferPrimitiveFallbackType,\n InferPrimitiveReturnType,\n PrimitiveConstructor,\n SchemaConstraint\n} from '../types';\n\n/**\n * Usage 1: Either a custom converter function + fallback (both required), OR a fallback\n * only (no converter).\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * // Custom converter that validates a non-empty API key\n * \\@Envapt('API_KEY', {\n * fallback: 'default-key',\n * converter(raw, _fallback) {\n * if (!raw || raw.trim() === '') throw new Error('API_KEY required');\n * return raw.trim();\n * }\n * })\n * static readonly apiKey: string;\n *\n * // Fallback-only (no converter): string fallback\n * \\@Envapt('LOG_FILE', { fallback: '/var/log/app.log' })\n * static readonly logFile: string;\n *\n * // Fallback-only: arbitrary object fallback\n * \\@Envapt('RETRY_POLICY', { fallback: { retries: 3, backoff: 'exponential' } })\n * static readonly retryPolicy: unknown;\n * }\n * ```\n */\nexport function Envapt<TFallback>(\n key: EnvKeyInput,\n options:\n | { converter: (raw: string | undefined, fallback: TFallback) => TFallback; fallback: TFallback }\n | { fallback: TFallback; converter?: undefined }\n): PropertyDecorator;\n\n/**\n * Usage 2: Custom converter function without fallback. Either omit `required` (returns the\n * converter's output, possibly `undefined`) or pass `required: true` to throw `MissingEnvValue`\n * on missing/empty values.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options with custom converter only, with optional `required: true`\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('FEATURE_FLAGS', { converter(raw) {\n * return raw ? raw.split('|').map(s => s.trim()) : [];\n * } })\n * static readonly featureFlags: string[];\n *\n * \\@Envapt('JWT_SECRET', {\n * converter: (raw) => Buffer.from(raw ?? '', 'base64'),\n * required: true\n * })\n * declare static readonly jwtSecret: Buffer;\n * }\n * ```\n */\nexport function Envapt<TReturnType>(\n key: EnvKeyInput,\n options:\n | { converter: ConverterFunction<TReturnType>; required?: false }\n | { converter: ConverterFunction<TReturnType>; required: true }\n): PropertyDecorator;\n\n/**\n * Usage 3: Built-in or array converter with optional fallback OR `required: true`.\n *\n * `InferConverterFallbackType` handles asymmetric cases: scalar `Converters.Time` accepts\n * `TimeFallback`, and `ArrayOf<'time'>` accepts `TimeFallback[]`. Every other converter\n * reduces to `InferConverterReturnType`. The two object-shape branches are mutually\n * exclusive: either provide a `fallback`, or pass `required: true` to throw\n * `MissingEnvValue` on missing/empty values.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * import { Converters } from 'envapt';\n *\n * class Config extends Envapter {\n * // Use built-in Number converter with a numeric fallback\n * \\@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })\n * static readonly port: number;\n *\n * // Url converter: the fallback is a URL instance, not a string\n * \\@Envapt('APP_URL', { converter: Converters.Url, fallback: new URL('http://localhost:3000') })\n * static readonly url: URL;\n *\n * // Prefer CANARY_URL when present, otherwise fall back to APP_URL\n * \\@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })\n * static readonly canaryUrl: URL | null;\n *\n * // `Converters.Time` accepts either a number (milliseconds) or a time-string fallback (`<number><unit>`).\n * \\@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })\n * static readonly requestTimeout: number;\n *\n * // Array converter: comma-separated list of origins -> string[]\n * \\@Envapt('ALLOWED_ORIGINS', {\n * converter: Converters.array({ of: Converters.String }),\n * fallback: ['https://example.com']\n * })\n * static readonly allowedOrigins: string[];\n *\n * \\@Envapt('DATABASE_URL', { converter: Converters.Url, required: true })\n * declare static readonly databaseUrl: URL;\n * }\n * ```\n */\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options:\n | { converter: TConverter; fallback?: InferConverterFallbackType<TConverter> | undefined; required?: false }\n | { converter: TConverter; required: true }\n): PropertyDecorator;\n\n/**\n * Usage 4: Primitive constructor with optional fallback\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options with primitive constructor\n * @public\n * @example\n * ```ts\n * // Use primitive constructors to coerce values\n * class Config extends Envapter {\n * \\@Envapt('MAX_CONNECTIONS', { converter: Number, fallback: 100 })\n * static readonly maxConnections: number;\n *\n * \\@Envapt('FEATURE_ENABLED', { converter: Boolean, fallback: false })\n * static readonly featureEnabled: boolean;\n * }\n * ```\n */\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options:\n | { converter: TConstructor; fallback?: InferPrimitiveReturnType<TConstructor>; required?: false }\n | { converter: TConstructor; required: true }\n): PropertyDecorator;\n\n/**\n * Usage 5: Required, no converter (raw string). Throws `MissingEnvValue` on first access if\n * the env value is missing or empty (post-trim). Independent of global `Envapter.strict`.\n * Combining `required: true` with `fallback` fails to match any overload at compile time;\n * the runtime Validator catches dynamic objects that bypass the types.\n *\n * @param key - Environment variable name(s) to load\n * @param options - `{ required: true }`\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('API_KEY', { required: true })\n * declare static readonly apiKey: string;\n * }\n * ```\n */\nexport function Envapt(key: EnvKeyInput, options: { required: true }): PropertyDecorator;\n\n/**\n * Classic API: No fallback\n *\n * @param key - Environment variable name(s) to load\n * @public\n * @example\n * ```ts\n * // Classic API: no fallback — property will resolve from env or be null\n * class Config extends Envapter {\n * \\@Envapt('SIMPLE_VALUE')\n * static readonly simple?: string | null;\n * }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function Envapt<_TReturnType = string | null>(key: EnvKeyInput): PropertyDecorator;\n\n/**\n * Classic API: Primitive fallback only\n *\n * @param key - Environment variable name(s) to load\n * @param fallback - Default primitive value\n * @param converter - Optional primitive constructor (String, Number, etc.)\n * @public\n * @deprecated - Use the options object: `@Envapt('KEY', { converter, fallback })`. The positional\n * form only accepts primitive constructors and cannot express built-in tokens, array/custom\n * converters, `schema`, or `required`. Deprecated in v5, removed in v6.\n * @example\n * ```ts\n * // Classic API with primitive fallback and optional primitive converter\n * class Config extends Envapter {\n * // Provide fallback only\n * \\@Envapt('HOST', 'localhost')\n * static readonly host: string;\n *\n * // Provide fallback and converter\n * \\@Envapt('PORT', 8080, Number)\n * static readonly port: number;\n * }\n * ```\n */\nexport function Envapt<TFallback extends string | number | boolean | bigint | symbol | undefined>(\n key: EnvKeyInput,\n fallback: InferPrimitiveFallbackType<TFallback>,\n converter?: PrimitiveConstructor\n): PropertyDecorator;\n\n/**\n * Usage 6: Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous\n * schemas only; a Promise-returning `validate` triggers a runtime\n * `InvalidUserDefinedConfig` throw. Combining `schema` with `converter` fails to match any\n * overload at compile time; the runtime Validator catches dynamic objects that bypass the\n * types.\n * @public\n */\nexport function Envapt<Schema extends StandardSchemaV1>(\n key: EnvKeyInput,\n options:\n | { schema: SchemaConstraint<Schema>; fallback?: InferSchemaOutput<Schema>; required?: false }\n | { schema: SchemaConstraint<Schema>; required: true }\n): PropertyDecorator;\n\n/**\n * Instance/Static Property decorator that automatically loads and converts environment variables.\n */\nexport function Envapt<TFallback = unknown>(\n key: EnvKeyInput,\n fallbackOrOptions?: TFallback | EnvaptOptions<TFallback>,\n converter?: EnvaptConverter<TFallback>\n): PropertyDecorator {\n // Determine if using new options API or classic API\n let fallback: TFallback | undefined;\n let actualConverter: EnvaptConverter<TFallback> | undefined;\n let actualSchema: StandardSchemaV1 | undefined;\n let hasFallback = true;\n let required = false;\n\n if (\n fallbackOrOptions &&\n typeof fallbackOrOptions === 'object' &&\n ('fallback' in fallbackOrOptions ||\n 'converter' in fallbackOrOptions ||\n 'required' in fallbackOrOptions ||\n 'schema' in fallbackOrOptions)\n ) {\n const options = fallbackOrOptions as {\n fallback?: TFallback;\n converter?: EnvaptConverter<TFallback>;\n required?: boolean;\n schema?: unknown;\n };\n fallback = options.fallback;\n actualConverter = options.converter;\n hasFallback = 'fallback' in options;\n required = options.required === true;\n\n if (required && hasFallback && fallback !== undefined) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n '`required: true` and `fallback` are mutually exclusive on @Envapt options. Drop the fallback or call `Envapter.require()` separately.'\n );\n }\n\n if ('schema' in options && options.schema !== undefined) {\n if (!Validator.isStandardSchema(options.schema)) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n '`schema` must be a Standard Schema v1 object (zod, valibot, arktype, or any `~standard`-conformant value).'\n );\n }\n if (actualConverter !== undefined) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n '`schema` and `converter` are mutually exclusive on @Envapt options. Drop one as they both turn a raw env string into a typed value.'\n );\n }\n actualSchema = options.schema;\n }\n } else {\n // Classic API\n fallback = fallbackOrOptions as TFallback;\n actualConverter = converter;\n hasFallback = arguments.length > 1;\n }\n\n return createPropertyDecorator(key, {\n fallback,\n converter: actualConverter,\n hasFallback,\n required,\n schema: actualSchema\n });\n}\n"],"mappings":"0GAwPA,SAAgB,EACZ,EACA,EACA,EACiB,CAEjB,IAAI,EACA,EACA,EACA,EAAc,GACd,EAAW,GAEf,GACI,GACA,OAAO,GAAsB,WAC5B,aAAc,GACX,cAAe,GACf,aAAc,GACd,WAAY,GAClB,CACE,IAAM,EAAU,EAWhB,GALA,EAAW,EAAQ,SACnB,EAAkB,EAAQ,UAC1B,EAAc,aAAc,EAC5B,EAAW,EAAQ,WAAa,GAE5B,GAAY,GAAe,IAAa,IAAA,GACxC,MAAM,IAAIA,EAAAA,YAAAA,IAEN,uIACJ,EAGJ,GAAI,WAAY,GAAW,EAAQ,SAAW,IAAA,GAAW,CACrD,GAAI,CAACC,EAAAA,UAAU,iBAAiB,EAAQ,MAAM,EAC1C,MAAM,IAAID,EAAAA,YAAAA,IAEN,4GACJ,EAEJ,GAAI,IAAoB,IAAA,GACpB,MAAM,IAAIA,EAAAA,YAAAA,IAEN,qIACJ,EAEJ,EAAe,EAAQ,MAC3B,CACJ,MAEI,EAAW,EACX,EAAkB,EAClB,EAAc,UAAU,OAAS,EAGrC,OAAOE,EAAAA,wBAAwB,EAAK,CAChC,WACA,UAAW,EACX,cACA,WACA,OAAQ,CACZ,CAAC,CACL"}
|
|
@@ -102,7 +102,7 @@ declare function Envapt<TReturnType>(key: EnvKeyInput, options: {
|
|
|
102
102
|
* \@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })
|
|
103
103
|
* static readonly canaryUrl: URL | null;
|
|
104
104
|
*
|
|
105
|
-
* // `Converters.Time` accepts either a number (milliseconds) or a time-string fallback (`<
|
|
105
|
+
* // `Converters.Time` accepts either a number (milliseconds) or a time-string fallback (`<number><unit>`).
|
|
106
106
|
* \@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })
|
|
107
107
|
* static readonly requestTimeout: number;
|
|
108
108
|
*
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { ArrayOf } from "../converters/Converters.mjs";
|
|
2
|
+
import { BuiltInConverter, ConverterFunction, InferConverterFallbackType, InferPrimitiveFallbackType, InferPrimitiveReturnType, PrimitiveConstructor } from "../types/Conversion.mjs";
|
|
3
|
+
import { InferSchemaOutput, StandardSchemaV1 } from "../StandardSchema.mjs";
|
|
4
|
+
import { SchemaConstraint } from "../types/Schema.mjs";
|
|
5
|
+
import { EnvKeyInput } from "../types/Env.mjs";
|
|
6
|
+
|
|
7
|
+
//#region src/decorators/Envapt.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Usage 1: Either a custom converter function + fallback (both required), OR a fallback
|
|
10
|
+
* only (no converter).
|
|
11
|
+
*
|
|
12
|
+
* @param key - Environment variable name(s) to load
|
|
13
|
+
* @param options - Configuration options
|
|
14
|
+
* @public
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* class Config extends Envapter {
|
|
18
|
+
* // Custom converter that validates a non-empty API key
|
|
19
|
+
* \@Envapt('API_KEY', {
|
|
20
|
+
* fallback: 'default-key',
|
|
21
|
+
* converter(raw, _fallback) {
|
|
22
|
+
* if (!raw || raw.trim() === '') throw new Error('API_KEY required');
|
|
23
|
+
* return raw.trim();
|
|
24
|
+
* }
|
|
25
|
+
* })
|
|
26
|
+
* static readonly apiKey: string;
|
|
27
|
+
*
|
|
28
|
+
* // Fallback-only (no converter): string fallback
|
|
29
|
+
* \@Envapt('LOG_FILE', { fallback: '/var/log/app.log' })
|
|
30
|
+
* static readonly logFile: string;
|
|
31
|
+
*
|
|
32
|
+
* // Fallback-only: arbitrary object fallback
|
|
33
|
+
* \@Envapt('RETRY_POLICY', { fallback: { retries: 3, backoff: 'exponential' } })
|
|
34
|
+
* static readonly retryPolicy: unknown;
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare function Envapt<TFallback>(key: EnvKeyInput, options: {
|
|
39
|
+
converter: (raw: string | undefined, fallback: TFallback) => TFallback;
|
|
40
|
+
fallback: TFallback;
|
|
41
|
+
} | {
|
|
42
|
+
fallback: TFallback;
|
|
43
|
+
converter?: undefined;
|
|
44
|
+
}): PropertyDecorator;
|
|
45
|
+
/**
|
|
46
|
+
* Usage 2: Custom converter function without fallback. Either omit `required` (returns the
|
|
47
|
+
* converter's output, possibly `undefined`) or pass `required: true` to throw `MissingEnvValue`
|
|
48
|
+
* on missing/empty values.
|
|
49
|
+
*
|
|
50
|
+
* @param key - Environment variable name(s) to load
|
|
51
|
+
* @param options - Configuration options with custom converter only, with optional `required: true`
|
|
52
|
+
* @public
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* class Config extends Envapter {
|
|
56
|
+
* \@Envapt('FEATURE_FLAGS', { converter(raw) {
|
|
57
|
+
* return raw ? raw.split('|').map(s => s.trim()) : [];
|
|
58
|
+
* } })
|
|
59
|
+
* static readonly featureFlags: string[];
|
|
60
|
+
*
|
|
61
|
+
* \@Envapt('JWT_SECRET', {
|
|
62
|
+
* converter: (raw) => Buffer.from(raw ?? '', 'base64'),
|
|
63
|
+
* required: true
|
|
64
|
+
* })
|
|
65
|
+
* declare static readonly jwtSecret: Buffer;
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
declare function Envapt<TReturnType>(key: EnvKeyInput, options: {
|
|
70
|
+
converter: ConverterFunction<TReturnType>;
|
|
71
|
+
required?: false;
|
|
72
|
+
} | {
|
|
73
|
+
converter: ConverterFunction<TReturnType>;
|
|
74
|
+
required: true;
|
|
75
|
+
}): PropertyDecorator;
|
|
76
|
+
/**
|
|
77
|
+
* Usage 3: Built-in or array converter with optional fallback OR `required: true`.
|
|
78
|
+
*
|
|
79
|
+
* `InferConverterFallbackType` handles asymmetric cases: scalar `Converters.Time` accepts
|
|
80
|
+
* `TimeFallback`, and `ArrayOf<'time'>` accepts `TimeFallback[]`. Every other converter
|
|
81
|
+
* reduces to `InferConverterReturnType`. The two object-shape branches are mutually
|
|
82
|
+
* exclusive: either provide a `fallback`, or pass `required: true` to throw
|
|
83
|
+
* `MissingEnvValue` on missing/empty values.
|
|
84
|
+
*
|
|
85
|
+
* @param key - Environment variable name(s) to load
|
|
86
|
+
* @param options - Configuration options
|
|
87
|
+
* @public
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* import { Converters } from 'envapt';
|
|
91
|
+
*
|
|
92
|
+
* class Config extends Envapter {
|
|
93
|
+
* // Use built-in Number converter with a numeric fallback
|
|
94
|
+
* \@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })
|
|
95
|
+
* static readonly port: number;
|
|
96
|
+
*
|
|
97
|
+
* // Url converter: the fallback is a URL instance, not a string
|
|
98
|
+
* \@Envapt('APP_URL', { converter: Converters.Url, fallback: new URL('http://localhost:3000') })
|
|
99
|
+
* static readonly url: URL;
|
|
100
|
+
*
|
|
101
|
+
* // Prefer CANARY_URL when present, otherwise fall back to APP_URL
|
|
102
|
+
* \@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })
|
|
103
|
+
* static readonly canaryUrl: URL | null;
|
|
104
|
+
*
|
|
105
|
+
* // `Converters.Time` accepts either a number (milliseconds) or a time-string fallback (`<number><unit>`).
|
|
106
|
+
* \@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })
|
|
107
|
+
* static readonly requestTimeout: number;
|
|
108
|
+
*
|
|
109
|
+
* // Array converter: comma-separated list of origins -> string[]
|
|
110
|
+
* \@Envapt('ALLOWED_ORIGINS', {
|
|
111
|
+
* converter: Converters.array({ of: Converters.String }),
|
|
112
|
+
* fallback: ['https://example.com']
|
|
113
|
+
* })
|
|
114
|
+
* static readonly allowedOrigins: string[];
|
|
115
|
+
*
|
|
116
|
+
* \@Envapt('DATABASE_URL', { converter: Converters.Url, required: true })
|
|
117
|
+
* declare static readonly databaseUrl: URL;
|
|
118
|
+
* }
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
|
|
122
|
+
converter: TConverter;
|
|
123
|
+
fallback?: InferConverterFallbackType<TConverter> | undefined;
|
|
124
|
+
required?: false;
|
|
125
|
+
} | {
|
|
126
|
+
converter: TConverter;
|
|
127
|
+
required: true;
|
|
128
|
+
}): PropertyDecorator;
|
|
129
|
+
/**
|
|
130
|
+
* Usage 4: Primitive constructor with optional fallback
|
|
131
|
+
*
|
|
132
|
+
* @param key - Environment variable name(s) to load
|
|
133
|
+
* @param options - Configuration options with primitive constructor
|
|
134
|
+
* @public
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* // Use primitive constructors to coerce values
|
|
138
|
+
* class Config extends Envapter {
|
|
139
|
+
* \@Envapt('MAX_CONNECTIONS', { converter: Number, fallback: 100 })
|
|
140
|
+
* static readonly maxConnections: number;
|
|
141
|
+
*
|
|
142
|
+
* \@Envapt('FEATURE_ENABLED', { converter: Boolean, fallback: false })
|
|
143
|
+
* static readonly featureEnabled: boolean;
|
|
144
|
+
* }
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
|
|
148
|
+
converter: TConstructor;
|
|
149
|
+
fallback?: InferPrimitiveReturnType<TConstructor>;
|
|
150
|
+
required?: false;
|
|
151
|
+
} | {
|
|
152
|
+
converter: TConstructor;
|
|
153
|
+
required: true;
|
|
154
|
+
}): PropertyDecorator;
|
|
155
|
+
/**
|
|
156
|
+
* Usage 5: Required, no converter (raw string). Throws `MissingEnvValue` on first access if
|
|
157
|
+
* the env value is missing or empty (post-trim). Independent of global `Envapter.strict`.
|
|
158
|
+
* Combining `required: true` with `fallback` fails to match any overload at compile time;
|
|
159
|
+
* the runtime Validator catches dynamic objects that bypass the types.
|
|
160
|
+
*
|
|
161
|
+
* @param key - Environment variable name(s) to load
|
|
162
|
+
* @param options - `{ required: true }`
|
|
163
|
+
* @public
|
|
164
|
+
* @example
|
|
165
|
+
* ```ts
|
|
166
|
+
* class Config extends Envapter {
|
|
167
|
+
* \@Envapt('API_KEY', { required: true })
|
|
168
|
+
* declare static readonly apiKey: string;
|
|
169
|
+
* }
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
declare function Envapt(key: EnvKeyInput, options: {
|
|
173
|
+
required: true;
|
|
174
|
+
}): PropertyDecorator;
|
|
175
|
+
/**
|
|
176
|
+
* Classic API: No fallback
|
|
177
|
+
*
|
|
178
|
+
* @param key - Environment variable name(s) to load
|
|
179
|
+
* @public
|
|
180
|
+
* @example
|
|
181
|
+
* ```ts
|
|
182
|
+
* // Classic API: no fallback — property will resolve from env or be null
|
|
183
|
+
* class Config extends Envapter {
|
|
184
|
+
* \@Envapt('SIMPLE_VALUE')
|
|
185
|
+
* static readonly simple?: string | null;
|
|
186
|
+
* }
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
declare function Envapt<_TReturnType = string | null>(key: EnvKeyInput): PropertyDecorator;
|
|
190
|
+
/**
|
|
191
|
+
* Classic API: Primitive fallback only
|
|
192
|
+
*
|
|
193
|
+
* @param key - Environment variable name(s) to load
|
|
194
|
+
* @param fallback - Default primitive value
|
|
195
|
+
* @param converter - Optional primitive constructor (String, Number, etc.)
|
|
196
|
+
* @public
|
|
197
|
+
* @deprecated - Use the options object: `@Envapt('KEY', { converter, fallback })`. The positional
|
|
198
|
+
* form only accepts primitive constructors and cannot express built-in tokens, array/custom
|
|
199
|
+
* converters, `schema`, or `required`. Deprecated in v5, removed in v6.
|
|
200
|
+
* @example
|
|
201
|
+
* ```ts
|
|
202
|
+
* // Classic API with primitive fallback and optional primitive converter
|
|
203
|
+
* class Config extends Envapter {
|
|
204
|
+
* // Provide fallback only
|
|
205
|
+
* \@Envapt('HOST', 'localhost')
|
|
206
|
+
* static readonly host: string;
|
|
207
|
+
*
|
|
208
|
+
* // Provide fallback and converter
|
|
209
|
+
* \@Envapt('PORT', 8080, Number)
|
|
210
|
+
* static readonly port: number;
|
|
211
|
+
* }
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
declare function Envapt<TFallback extends string | number | boolean | bigint | symbol | undefined>(key: EnvKeyInput, fallback: InferPrimitiveFallbackType<TFallback>, converter?: PrimitiveConstructor): PropertyDecorator;
|
|
215
|
+
/**
|
|
216
|
+
* Usage 6: Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous
|
|
217
|
+
* schemas only; a Promise-returning `validate` triggers a runtime
|
|
218
|
+
* `InvalidUserDefinedConfig` throw. Combining `schema` with `converter` fails to match any
|
|
219
|
+
* overload at compile time; the runtime Validator catches dynamic objects that bypass the
|
|
220
|
+
* types.
|
|
221
|
+
* @public
|
|
222
|
+
*/
|
|
223
|
+
declare function Envapt<Schema extends StandardSchemaV1>(key: EnvKeyInput, options: {
|
|
224
|
+
schema: SchemaConstraint<Schema>;
|
|
225
|
+
fallback?: InferSchemaOutput<Schema>;
|
|
226
|
+
required?: false;
|
|
227
|
+
} | {
|
|
228
|
+
schema: SchemaConstraint<Schema>;
|
|
229
|
+
required: true;
|
|
230
|
+
}): PropertyDecorator;
|
|
231
|
+
//#endregion
|
|
232
|
+
export { Envapt };
|
|
233
|
+
//# sourceMappingURL=Envapt.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{EnvaptError as e}from"../Error.mjs";import{Validator as t}from"../Validators.mjs";import{createPropertyDecorator as n}from"./createPropertyDecorator.mjs";function r(r,i,a){let o,s,c,l=!0,u=!1;if(i&&typeof i==`object`&&(`fallback`in i||`converter`in i||`required`in i||`schema`in i)){let n=i;if(o=n.fallback,s=n.converter,l=`fallback`in n,u=n.required===!0,u&&l&&o!==void 0)throw new e(302,"`required: true` and `fallback` are mutually exclusive on @Envapt options. Drop the fallback or call `Envapter.require()` separately.");if(`schema`in n&&n.schema!==void 0){if(!t.isStandardSchema(n.schema))throw new e(302,"`schema` must be a Standard Schema v1 object (zod, valibot, arktype, or any `~standard`-conformant value).");if(s!==void 0)throw new e(302,"`schema` and `converter` are mutually exclusive on @Envapt options. Drop one as they both turn a raw env string into a typed value.");c=n.schema}}else o=i,s=a,l=arguments.length>1;return n(r,{fallback:o,converter:s,hasFallback:l,required:u,schema:c})}export{r as Envapt};
|
|
2
|
+
//# sourceMappingURL=Envapt.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Envapt.mjs","names":[],"sources":["../../../src/decorators/Envapt.ts"],"sourcesContent":["import { createPropertyDecorator } from './createPropertyDecorator';\nimport { EnvaptError, EnvaptErrorCodes } from '../Error';\nimport { Validator } from '../Validators';\n\nimport type { ArrayOf } from '../converters';\nimport type { InferSchemaOutput, StandardSchemaV1 } from '../StandardSchema';\nimport type {\n BuiltInConverter,\n ConverterFunction,\n EnvKeyInput,\n EnvaptConverter,\n EnvaptOptions,\n InferConverterFallbackType,\n InferPrimitiveFallbackType,\n InferPrimitiveReturnType,\n PrimitiveConstructor,\n SchemaConstraint\n} from '../types';\n\n/**\n * Usage 1: Either a custom converter function + fallback (both required), OR a fallback\n * only (no converter).\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * // Custom converter that validates a non-empty API key\n * \\@Envapt('API_KEY', {\n * fallback: 'default-key',\n * converter(raw, _fallback) {\n * if (!raw || raw.trim() === '') throw new Error('API_KEY required');\n * return raw.trim();\n * }\n * })\n * static readonly apiKey: string;\n *\n * // Fallback-only (no converter): string fallback\n * \\@Envapt('LOG_FILE', { fallback: '/var/log/app.log' })\n * static readonly logFile: string;\n *\n * // Fallback-only: arbitrary object fallback\n * \\@Envapt('RETRY_POLICY', { fallback: { retries: 3, backoff: 'exponential' } })\n * static readonly retryPolicy: unknown;\n * }\n * ```\n */\nexport function Envapt<TFallback>(\n key: EnvKeyInput,\n options:\n | { converter: (raw: string | undefined, fallback: TFallback) => TFallback; fallback: TFallback }\n | { fallback: TFallback; converter?: undefined }\n): PropertyDecorator;\n\n/**\n * Usage 2: Custom converter function without fallback. Either omit `required` (returns the\n * converter's output, possibly `undefined`) or pass `required: true` to throw `MissingEnvValue`\n * on missing/empty values.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options with custom converter only, with optional `required: true`\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('FEATURE_FLAGS', { converter(raw) {\n * return raw ? raw.split('|').map(s => s.trim()) : [];\n * } })\n * static readonly featureFlags: string[];\n *\n * \\@Envapt('JWT_SECRET', {\n * converter: (raw) => Buffer.from(raw ?? '', 'base64'),\n * required: true\n * })\n * declare static readonly jwtSecret: Buffer;\n * }\n * ```\n */\nexport function Envapt<TReturnType>(\n key: EnvKeyInput,\n options:\n | { converter: ConverterFunction<TReturnType>; required?: false }\n | { converter: ConverterFunction<TReturnType>; required: true }\n): PropertyDecorator;\n\n/**\n * Usage 3: Built-in or array converter with optional fallback OR `required: true`.\n *\n * `InferConverterFallbackType` handles asymmetric cases: scalar `Converters.Time` accepts\n * `TimeFallback`, and `ArrayOf<'time'>` accepts `TimeFallback[]`. Every other converter\n * reduces to `InferConverterReturnType`. The two object-shape branches are mutually\n * exclusive: either provide a `fallback`, or pass `required: true` to throw\n * `MissingEnvValue` on missing/empty values.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * import { Converters } from 'envapt';\n *\n * class Config extends Envapter {\n * // Use built-in Number converter with a numeric fallback\n * \\@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })\n * static readonly port: number;\n *\n * // Url converter: the fallback is a URL instance, not a string\n * \\@Envapt('APP_URL', { converter: Converters.Url, fallback: new URL('http://localhost:3000') })\n * static readonly url: URL;\n *\n * // Prefer CANARY_URL when present, otherwise fall back to APP_URL\n * \\@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })\n * static readonly canaryUrl: URL | null;\n *\n * // `Converters.Time` accepts either a number (milliseconds) or a time-string fallback (`<number><unit>`).\n * \\@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })\n * static readonly requestTimeout: number;\n *\n * // Array converter: comma-separated list of origins -> string[]\n * \\@Envapt('ALLOWED_ORIGINS', {\n * converter: Converters.array({ of: Converters.String }),\n * fallback: ['https://example.com']\n * })\n * static readonly allowedOrigins: string[];\n *\n * \\@Envapt('DATABASE_URL', { converter: Converters.Url, required: true })\n * declare static readonly databaseUrl: URL;\n * }\n * ```\n */\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options:\n | { converter: TConverter; fallback?: InferConverterFallbackType<TConverter> | undefined; required?: false }\n | { converter: TConverter; required: true }\n): PropertyDecorator;\n\n/**\n * Usage 4: Primitive constructor with optional fallback\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options with primitive constructor\n * @public\n * @example\n * ```ts\n * // Use primitive constructors to coerce values\n * class Config extends Envapter {\n * \\@Envapt('MAX_CONNECTIONS', { converter: Number, fallback: 100 })\n * static readonly maxConnections: number;\n *\n * \\@Envapt('FEATURE_ENABLED', { converter: Boolean, fallback: false })\n * static readonly featureEnabled: boolean;\n * }\n * ```\n */\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options:\n | { converter: TConstructor; fallback?: InferPrimitiveReturnType<TConstructor>; required?: false }\n | { converter: TConstructor; required: true }\n): PropertyDecorator;\n\n/**\n * Usage 5: Required, no converter (raw string). Throws `MissingEnvValue` on first access if\n * the env value is missing or empty (post-trim). Independent of global `Envapter.strict`.\n * Combining `required: true` with `fallback` fails to match any overload at compile time;\n * the runtime Validator catches dynamic objects that bypass the types.\n *\n * @param key - Environment variable name(s) to load\n * @param options - `{ required: true }`\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('API_KEY', { required: true })\n * declare static readonly apiKey: string;\n * }\n * ```\n */\nexport function Envapt(key: EnvKeyInput, options: { required: true }): PropertyDecorator;\n\n/**\n * Classic API: No fallback\n *\n * @param key - Environment variable name(s) to load\n * @public\n * @example\n * ```ts\n * // Classic API: no fallback — property will resolve from env or be null\n * class Config extends Envapter {\n * \\@Envapt('SIMPLE_VALUE')\n * static readonly simple?: string | null;\n * }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function Envapt<_TReturnType = string | null>(key: EnvKeyInput): PropertyDecorator;\n\n/**\n * Classic API: Primitive fallback only\n *\n * @param key - Environment variable name(s) to load\n * @param fallback - Default primitive value\n * @param converter - Optional primitive constructor (String, Number, etc.)\n * @public\n * @deprecated - Use the options object: `@Envapt('KEY', { converter, fallback })`. The positional\n * form only accepts primitive constructors and cannot express built-in tokens, array/custom\n * converters, `schema`, or `required`. Deprecated in v5, removed in v6.\n * @example\n * ```ts\n * // Classic API with primitive fallback and optional primitive converter\n * class Config extends Envapter {\n * // Provide fallback only\n * \\@Envapt('HOST', 'localhost')\n * static readonly host: string;\n *\n * // Provide fallback and converter\n * \\@Envapt('PORT', 8080, Number)\n * static readonly port: number;\n * }\n * ```\n */\nexport function Envapt<TFallback extends string | number | boolean | bigint | symbol | undefined>(\n key: EnvKeyInput,\n fallback: InferPrimitiveFallbackType<TFallback>,\n converter?: PrimitiveConstructor\n): PropertyDecorator;\n\n/**\n * Usage 6: Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous\n * schemas only; a Promise-returning `validate` triggers a runtime\n * `InvalidUserDefinedConfig` throw. Combining `schema` with `converter` fails to match any\n * overload at compile time; the runtime Validator catches dynamic objects that bypass the\n * types.\n * @public\n */\nexport function Envapt<Schema extends StandardSchemaV1>(\n key: EnvKeyInput,\n options:\n | { schema: SchemaConstraint<Schema>; fallback?: InferSchemaOutput<Schema>; required?: false }\n | { schema: SchemaConstraint<Schema>; required: true }\n): PropertyDecorator;\n\n/**\n * Instance/Static Property decorator that automatically loads and converts environment variables.\n */\nexport function Envapt<TFallback = unknown>(\n key: EnvKeyInput,\n fallbackOrOptions?: TFallback | EnvaptOptions<TFallback>,\n converter?: EnvaptConverter<TFallback>\n): PropertyDecorator {\n // Determine if using new options API or classic API\n let fallback: TFallback | undefined;\n let actualConverter: EnvaptConverter<TFallback> | undefined;\n let actualSchema: StandardSchemaV1 | undefined;\n let hasFallback = true;\n let required = false;\n\n if (\n fallbackOrOptions &&\n typeof fallbackOrOptions === 'object' &&\n ('fallback' in fallbackOrOptions ||\n 'converter' in fallbackOrOptions ||\n 'required' in fallbackOrOptions ||\n 'schema' in fallbackOrOptions)\n ) {\n const options = fallbackOrOptions as {\n fallback?: TFallback;\n converter?: EnvaptConverter<TFallback>;\n required?: boolean;\n schema?: unknown;\n };\n fallback = options.fallback;\n actualConverter = options.converter;\n hasFallback = 'fallback' in options;\n required = options.required === true;\n\n if (required && hasFallback && fallback !== undefined) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n '`required: true` and `fallback` are mutually exclusive on @Envapt options. Drop the fallback or call `Envapter.require()` separately.'\n );\n }\n\n if ('schema' in options && options.schema !== undefined) {\n if (!Validator.isStandardSchema(options.schema)) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n '`schema` must be a Standard Schema v1 object (zod, valibot, arktype, or any `~standard`-conformant value).'\n );\n }\n if (actualConverter !== undefined) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n '`schema` and `converter` are mutually exclusive on @Envapt options. Drop one as they both turn a raw env string into a typed value.'\n );\n }\n actualSchema = options.schema;\n }\n } else {\n // Classic API\n fallback = fallbackOrOptions as TFallback;\n actualConverter = converter;\n hasFallback = arguments.length > 1;\n }\n\n return createPropertyDecorator(key, {\n fallback,\n converter: actualConverter,\n hasFallback,\n required,\n schema: actualSchema\n });\n}\n"],"mappings":"iKAwPA,SAAgB,EACZ,EACA,EACA,EACiB,CAEjB,IAAI,EACA,EACA,EACA,EAAc,GACd,EAAW,GAEf,GACI,GACA,OAAO,GAAsB,WAC5B,aAAc,GACX,cAAe,GACf,aAAc,GACd,WAAY,GAClB,CACE,IAAM,EAAU,EAWhB,GALA,EAAW,EAAQ,SACnB,EAAkB,EAAQ,UAC1B,EAAc,aAAc,EAC5B,EAAW,EAAQ,WAAa,GAE5B,GAAY,GAAe,IAAa,IAAA,GACxC,MAAM,IAAI,EAAA,IAEN,uIACJ,EAGJ,GAAI,WAAY,GAAW,EAAQ,SAAW,IAAA,GAAW,CACrD,GAAI,CAAC,EAAU,iBAAiB,EAAQ,MAAM,EAC1C,MAAM,IAAI,EAAA,IAEN,4GACJ,EAEJ,GAAI,IAAoB,IAAA,GACpB,MAAM,IAAI,EAAA,IAEN,qIACJ,EAEJ,EAAe,EAAQ,MAC3B,CACJ,MAEI,EAAW,EACX,EAAkB,EAClB,EAAc,UAAU,OAAS,EAGrC,OAAO,EAAwB,EAAK,CAChC,WACA,UAAW,EACX,cACA,WACA,OAAQ,CACZ,CAAC,CACL"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SugarDecorators.cjs","names":["createPropertyDecorator","Converters"],"sources":["../../../src/decorators/SugarDecorators.ts"],"sourcesContent":["import { createPropertyDecorator } from './createPropertyDecorator';\nimport { Converters } from '../converters';\n\nimport type { ConverterToken } from '../converters';\nimport type { EnvKeyInput, TimeFallback } from '../types';\n\nfunction sugar<TFallback>(\n converter: ConverterToken,\n key: EnvKeyInput,\n fallback: TFallback | undefined\n): PropertyDecorator {\n return createPropertyDecorator<TFallback>(key, {\n converter,\n fallback,\n hasFallback: fallback !== undefined,\n required: false,\n schema: undefined\n });\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Boolean, fallback })`.\n * @public\n */\nexport function EnvBool(key: EnvKeyInput, fallback?: boolean): PropertyDecorator {\n return sugar(Converters.Boolean, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Number, fallback })`.\n * @public\n */\nexport function EnvNum(key: EnvKeyInput, fallback?: number): PropertyDecorator {\n return sugar(Converters.Number, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.String, fallback })`.\n * @public\n */\nexport function EnvStr(key: EnvKeyInput, fallback?: string): PropertyDecorator {\n return sugar(Converters.String, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Time, fallback })`. The fallback is a\n * millisecond number or a time string (`'15m'`); the resolved value is always milliseconds.\n * @public\n */\nexport function EnvTime(key: EnvKeyInput, fallback?: TimeFallback): PropertyDecorator {\n return sugar(Converters.Time, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Url, fallback })`. The fallback is a `URL`\n * instance, not a URL string.\n * @public\n */\nexport function EnvUrl(key: EnvKeyInput, fallback?: URL): PropertyDecorator {\n return sugar(Converters.Url, key, fallback);\n}\n"],"mappings":"2FAMA,SAAS,EACL,EACA,EACA,EACiB,CACjB,OAAOA,EAAAA,wBAAmC,EAAK,CAC3C,YACA,WACA,YAAa,IAAa,IAAA,GAC1B,SAAU,GACV,OAAQ,IAAA,EACZ,CAAC,CACL,CAMA,SAAgB,EAAQ,EAAkB,EAAuC,CAC7E,OAAO,EAAMC,EAAAA,WAAW,QAAS,EAAK,CAAQ,CAClD,CAMA,SAAgB,EAAO,EAAkB,EAAsC,CAC3E,OAAO,EAAMA,EAAAA,WAAW,OAAQ,EAAK,CAAQ,CACjD,CAMA,SAAgB,EAAO,EAAkB,EAAsC,CAC3E,OAAO,EAAMA,EAAAA,WAAW,OAAQ,EAAK,CAAQ,CACjD,CAOA,SAAgB,EAAQ,EAAkB,EAA4C,CAClF,OAAO,EAAMA,EAAAA,WAAW,KAAM,EAAK,CAAQ,CAC/C,CAOA,SAAgB,EAAO,EAAkB,EAAmC,CACxE,OAAO,EAAMA,EAAAA,WAAW,IAAK,EAAK,CAAQ,CAC9C"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TimeFallback } from "../types/Conversion.mjs";
|
|
2
|
+
import { EnvKeyInput } from "../types/Env.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/decorators/SugarDecorators.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Shorthand for `@Envapt(key, { converter: Converters.Boolean, fallback })`.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
declare function EnvBool(key: EnvKeyInput, fallback?: boolean): PropertyDecorator;
|
|
10
|
+
/**
|
|
11
|
+
* Shorthand for `@Envapt(key, { converter: Converters.Number, fallback })`.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
declare function EnvNum(key: EnvKeyInput, fallback?: number): PropertyDecorator;
|
|
15
|
+
/**
|
|
16
|
+
* Shorthand for `@Envapt(key, { converter: Converters.String, fallback })`.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
declare function EnvStr(key: EnvKeyInput, fallback?: string): PropertyDecorator;
|
|
20
|
+
/**
|
|
21
|
+
* Shorthand for `@Envapt(key, { converter: Converters.Time, fallback })`. The fallback is a
|
|
22
|
+
* millisecond number or a time string (`'15m'`); the resolved value is always milliseconds.
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
declare function EnvTime(key: EnvKeyInput, fallback?: TimeFallback): PropertyDecorator;
|
|
26
|
+
/**
|
|
27
|
+
* Shorthand for `@Envapt(key, { converter: Converters.Url, fallback })`. The fallback is a `URL`
|
|
28
|
+
* instance, not a URL string.
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
declare function EnvUrl(key: EnvKeyInput, fallback?: URL): PropertyDecorator;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl };
|
|
34
|
+
//# sourceMappingURL=SugarDecorators.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Converters as e}from"../converters/Converters.mjs";import{createPropertyDecorator as t}from"./createPropertyDecorator.mjs";function n(e,n,r){return t(n,{converter:e,fallback:r,hasFallback:r!==void 0,required:!1,schema:void 0})}function r(t,r){return n(e.Boolean,t,r)}function i(t,r){return n(e.Number,t,r)}function a(t,r){return n(e.String,t,r)}function o(t,r){return n(e.Time,t,r)}function s(t,r){return n(e.Url,t,r)}export{r as EnvBool,i as EnvNum,a as EnvStr,o as EnvTime,s as EnvUrl};
|
|
2
|
+
//# sourceMappingURL=SugarDecorators.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SugarDecorators.mjs","names":[],"sources":["../../../src/decorators/SugarDecorators.ts"],"sourcesContent":["import { createPropertyDecorator } from './createPropertyDecorator';\nimport { Converters } from '../converters';\n\nimport type { ConverterToken } from '../converters';\nimport type { EnvKeyInput, TimeFallback } from '../types';\n\nfunction sugar<TFallback>(\n converter: ConverterToken,\n key: EnvKeyInput,\n fallback: TFallback | undefined\n): PropertyDecorator {\n return createPropertyDecorator<TFallback>(key, {\n converter,\n fallback,\n hasFallback: fallback !== undefined,\n required: false,\n schema: undefined\n });\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Boolean, fallback })`.\n * @public\n */\nexport function EnvBool(key: EnvKeyInput, fallback?: boolean): PropertyDecorator {\n return sugar(Converters.Boolean, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Number, fallback })`.\n * @public\n */\nexport function EnvNum(key: EnvKeyInput, fallback?: number): PropertyDecorator {\n return sugar(Converters.Number, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.String, fallback })`.\n * @public\n */\nexport function EnvStr(key: EnvKeyInput, fallback?: string): PropertyDecorator {\n return sugar(Converters.String, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Time, fallback })`. The fallback is a\n * millisecond number or a time string (`'15m'`); the resolved value is always milliseconds.\n * @public\n */\nexport function EnvTime(key: EnvKeyInput, fallback?: TimeFallback): PropertyDecorator {\n return sugar(Converters.Time, key, fallback);\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Url, fallback })`. The fallback is a `URL`\n * instance, not a URL string.\n * @public\n */\nexport function EnvUrl(key: EnvKeyInput, fallback?: URL): PropertyDecorator {\n return sugar(Converters.Url, key, fallback);\n}\n"],"mappings":"kIAMA,SAAS,EACL,EACA,EACA,EACiB,CACjB,OAAO,EAAmC,EAAK,CAC3C,YACA,WACA,YAAa,IAAa,IAAA,GAC1B,SAAU,GACV,OAAQ,IAAA,EACZ,CAAC,CACL,CAMA,SAAgB,EAAQ,EAAkB,EAAuC,CAC7E,OAAO,EAAM,EAAW,QAAS,EAAK,CAAQ,CAClD,CAMA,SAAgB,EAAO,EAAkB,EAAsC,CAC3E,OAAO,EAAM,EAAW,OAAQ,EAAK,CAAQ,CACjD,CAMA,SAAgB,EAAO,EAAkB,EAAsC,CAC3E,OAAO,EAAM,EAAW,OAAQ,EAAK,CAAQ,CACjD,CAOA,SAAgB,EAAQ,EAAkB,EAA4C,CAClF,OAAO,EAAM,EAAW,KAAM,EAAK,CAAQ,CAC/C,CAOA,SAAgB,EAAO,EAAkB,EAAmC,CACxE,OAAO,EAAM,EAAW,IAAK,EAAK,CAAQ,CAC9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPropertyDecorator.cjs","names":["EnvaptCache","Envapter","EnvaptError","ValueConverter"],"sources":["../../../src/decorators/createPropertyDecorator.ts"],"sourcesContent":["import { ValueConverter } from '../converters';\nimport { EnvaptCache } from '../core';\nimport { Envapter } from '../Envapter';\nimport { EnvaptError, EnvaptErrorCodes } from '../Error';\n\nimport type { StandardSchemaV1 } from '../StandardSchema';\nimport type { EnvaptConverter, EnvKeyInput } from '../types';\n\nfunction formatKeyForError(key: EnvKeyInput): string {\n return Array.isArray(key) ? `[${key.join(', ')}]` : String(key);\n}\n\ninterface DecoratorConfig<TFallback> {\n fallback: TFallback | undefined;\n converter: EnvaptConverter<TFallback> | undefined;\n hasFallback: boolean;\n required: boolean;\n schema: StandardSchemaV1 | undefined;\n}\n\nexport function createPropertyDecorator<TFallback>(\n key: EnvKeyInput,\n config: DecoratorConfig<TFallback>\n): PropertyDecorator {\n const { fallback, converter, hasFallback, required, schema } = config;\n return function (target: object, prop: string | symbol): void {\n const propKey = String(prop);\n // Distinguishing constructor (static) from prototype (instance) keeps same-named static and instance properties from colliding in the cache.\n const className = typeof target === 'function' ? target.name : target.constructor.name;\n const cacheKey = `${className}.${propKey}`;\n\n Object.defineProperty(target, propKey, {\n get: function () {\n let value = EnvaptCache.get(cacheKey) as TFallback | null | undefined;\n\n if (value === undefined) {\n const envapter = new Envapter();\n\n if (required && schema === undefined) {\n const rawValue = envapter.getRaw(key);\n if (rawValue === undefined || rawValue.trim() === '') {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Required environment variable \"${formatKeyForError(key)}\" is missing or empty.`\n );\n }\n }\n\n const valueConverter = new ValueConverter(envapter);\n if (schema !== undefined) {\n value = valueConverter.convertWithSchema(key, schema, fallback, hasFallback) as TFallback;\n } else {\n value = valueConverter.convertValue(key, fallback, converter, hasFallback);\n }\n EnvaptCache.set(cacheKey, value);\n }\n\n return value;\n },\n configurable: false,\n enumerable: true\n });\n };\n}\n"],"mappings":"iJAQA,SAAS,EAAkB,EAA0B,CACjD,OAAO,MAAM,QAAQ,CAAG,EAAI,IAAI,EAAI,KAAK,IAAI,EAAE,GAAK,OAAO,CAAG,CAClE,CAUA,SAAgB,EACZ,EACA,EACiB,CACjB,GAAM,CAAE,WAAU,YAAW,cAAa,WAAU,UAAW,EAC/D,OAAO,SAAU,EAAgB,EAA6B,CAC1D,IAAM,EAAU,OAAO,CAAI,EAGrB,EAAW,GADC,OAAO,GAAW,WAAa,EAAO,KAAO,EAAO,YAAY,KACpD,GAAG,IAEjC,OAAO,eAAe,EAAQ,EAAS,CACnC,IAAK,UAAY,CACb,IAAI,EAAQA,EAAAA,YAAY,IAAI,CAAQ,EAEpC,GAAI,IAAU,IAAA,GAAW,CACrB,IAAM,EAAW,IAAIC,EAAAA,SAErB,GAAI,GAAY,IAAW,IAAA,GAAW,CAClC,IAAM,EAAW,EAAS,OAAO,CAAG,EACpC,GAAI,IAAa,IAAA,IAAa,EAAS,KAAK,IAAM,GAC9C,MAAM,IAAIC,EAAAA,YAAAA,IAEN,kCAAkC,EAAkB,CAAG,EAAE,uBAC7D,CAER,CAEA,IAAM,EAAiB,IAAIC,EAAAA,eAAe,CAAQ,EAClD,AACI,EADA,IAAW,IAAA,GAGH,EAAe,aAAa,EAAK,EAAU,EAAW,CAAW,EAFjE,EAAe,kBAAkB,EAAK,EAAQ,EAAU,CAAW,EAI/E,EAAA,YAAY,IAAI,EAAU,CAAK,CACnC,CAEA,OAAO,CACX,EACA,aAAc,GACd,WAAY,EAChB,CAAC,CACL,CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPropertyDecorator.mjs","names":[],"sources":["../../../src/decorators/createPropertyDecorator.ts"],"sourcesContent":["import { ValueConverter } from '../converters';\nimport { EnvaptCache } from '../core';\nimport { Envapter } from '../Envapter';\nimport { EnvaptError, EnvaptErrorCodes } from '../Error';\n\nimport type { StandardSchemaV1 } from '../StandardSchema';\nimport type { EnvaptConverter, EnvKeyInput } from '../types';\n\nfunction formatKeyForError(key: EnvKeyInput): string {\n return Array.isArray(key) ? `[${key.join(', ')}]` : String(key);\n}\n\ninterface DecoratorConfig<TFallback> {\n fallback: TFallback | undefined;\n converter: EnvaptConverter<TFallback> | undefined;\n hasFallback: boolean;\n required: boolean;\n schema: StandardSchemaV1 | undefined;\n}\n\nexport function createPropertyDecorator<TFallback>(\n key: EnvKeyInput,\n config: DecoratorConfig<TFallback>\n): PropertyDecorator {\n const { fallback, converter, hasFallback, required, schema } = config;\n return function (target: object, prop: string | symbol): void {\n const propKey = String(prop);\n // Distinguishing constructor (static) from prototype (instance) keeps same-named static and instance properties from colliding in the cache.\n const className = typeof target === 'function' ? target.name : target.constructor.name;\n const cacheKey = `${className}.${propKey}`;\n\n Object.defineProperty(target, propKey, {\n get: function () {\n let value = EnvaptCache.get(cacheKey) as TFallback | null | undefined;\n\n if (value === undefined) {\n const envapter = new Envapter();\n\n if (required && schema === undefined) {\n const rawValue = envapter.getRaw(key);\n if (rawValue === undefined || rawValue.trim() === '') {\n throw new EnvaptError(\n EnvaptErrorCodes.MissingEnvValue,\n `Required environment variable \"${formatKeyForError(key)}\" is missing or empty.`\n );\n }\n }\n\n const valueConverter = new ValueConverter(envapter);\n if (schema !== undefined) {\n value = valueConverter.convertWithSchema(key, schema, fallback, hasFallback) as TFallback;\n } else {\n value = valueConverter.convertValue(key, fallback, converter, hasFallback);\n }\n EnvaptCache.set(cacheKey, value);\n }\n\n return value;\n },\n configurable: false,\n enumerable: true\n });\n };\n}\n"],"mappings":"+MAQA,SAAS,EAAkB,EAA0B,CACjD,OAAO,MAAM,QAAQ,CAAG,EAAI,IAAI,EAAI,KAAK,IAAI,EAAE,GAAK,OAAO,CAAG,CAClE,CAUA,SAAgB,EACZ,EACA,EACiB,CACjB,GAAM,CAAE,WAAU,YAAW,cAAa,WAAU,UAAW,EAC/D,OAAO,SAAU,EAAgB,EAA6B,CAC1D,IAAM,EAAU,OAAO,CAAI,EAGrB,EAAW,GADC,OAAO,GAAW,WAAa,EAAO,KAAO,EAAO,YAAY,KACpD,GAAG,IAEjC,OAAO,eAAe,EAAQ,EAAS,CACnC,IAAK,UAAY,CACb,IAAI,EAAQ,EAAY,IAAI,CAAQ,EAEpC,GAAI,IAAU,IAAA,GAAW,CACrB,IAAM,EAAW,IAAI,EAErB,GAAI,GAAY,IAAW,IAAA,GAAW,CAClC,IAAM,EAAW,EAAS,OAAO,CAAG,EACpC,GAAI,IAAa,IAAA,IAAa,EAAS,KAAK,IAAM,GAC9C,MAAM,IAAI,EAAA,IAEN,kCAAkC,EAAkB,CAAG,EAAE,uBAC7D,CAER,CAEA,IAAM,EAAiB,IAAI,EAAe,CAAQ,EAClD,AACI,EADA,IAAW,IAAA,GAGH,EAAe,aAAa,EAAK,EAAU,EAAW,CAAW,EAFjE,EAAe,kBAAkB,EAAK,EAAQ,EAAU,CAAW,EAI/E,EAAY,IAAI,EAAU,CAAK,CACnC,CAEA,OAAO,CACX,EACA,aAAc,GACd,WAAY,EAChB,CAAC,CACL,CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./converters/Converters.cjs"),t=require("./Error.cjs"),n=require("./core/EnvironmentMethods.cjs"),r=require("./decorators/Envapt.cjs"),i=require("./decorators/SugarDecorators.cjs"),a=require("./sources/ManualEnvSource.cjs"),o=require("./sources/WorkerEnvSource.cjs"),s=require("./sources/NodeEnvSource.cjs"),c=require("./NodeEnvapter.cjs");exports.Converters=e.Converters,exports.EnvBool=i.EnvBool,exports.EnvNum=i.EnvNum,exports.EnvStr=i.EnvStr,exports.EnvTime=i.EnvTime,exports.EnvUrl=i.EnvUrl,exports.Envapt=r.Envapt,exports.EnvaptError=t.EnvaptError,exports.EnvaptErrorCodes=t.EnvaptErrorCodes,exports.Envapter=c.NodeEnvapter,exports.Environment=n.Environment,exports.ManualEnvSource=a.ManualEnvSource,exports.NodeEnvSource=s.NodeEnvSource,exports.WorkerEnvSource=o.WorkerEnvSource,exports.isArrayOf=e.isArrayOf;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ArrayElement, ArrayOf, ConverterToken, Converters, CustomElementConverter, isArrayOf } from "./converters/Converters.cjs";
|
|
2
|
+
import { AdvancedConverterReturn, BuiltInConverter, BuiltInConverterFunction, ConditionalReturn, ConverterFunction, EnvaptConverter, InferConverterFallbackType, InferConverterReturnType, InferPrimitiveFallbackType, InferPrimitiveReturnType, JsonValue, MapOfConverterFunctions, PrimitiveConstructor, TimeFallback, TimeUnit } from "./types/Conversion.cjs";
|
|
3
|
+
import { InferSchemaInput, InferSchemaOutput, StandardSchemaV1 } from "./StandardSchema.cjs";
|
|
4
|
+
import { Err, SchemaConstraint, SchemaMustBeSync } from "./types/Schema.cjs";
|
|
5
|
+
import { DebugLevel } from "./Debug.cjs";
|
|
6
|
+
import { EnvFileOptions } from "./Dotenv.cjs";
|
|
7
|
+
import { Environment } from "./core/EnvironmentMethods.cjs";
|
|
8
|
+
import { EnvProfile, EnvaptOptions, ProfilesConfig } from "./types/Options.cjs";
|
|
9
|
+
import { EnvKeyInput } from "./types/Env.cjs";
|
|
10
|
+
import { BareEnvSource, EnvSource, FileEnvSource } from "./types/Source.cjs";
|
|
11
|
+
import { Envapt } from "./decorators/Envapt.cjs";
|
|
12
|
+
import { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl } from "./decorators/SugarDecorators.cjs";
|
|
13
|
+
import { ManualEnvSource } from "./sources/ManualEnvSource.cjs";
|
|
14
|
+
import { WorkerEnvSource } from "./sources/WorkerEnvSource.cjs";
|
|
15
|
+
import { EnvaptError, EnvaptErrorCodes } from "./Error.cjs";
|
|
16
|
+
import { NodeEnvapter } from "./NodeEnvapter.cjs";
|
|
17
|
+
import { NodeEnvSource } from "./sources/NodeEnvSource.cjs";
|
|
18
|
+
export { type AdvancedConverterReturn, type ArrayElement, type ArrayOf, type BareEnvSource, type BuiltInConverter, type BuiltInConverterFunction, type ConditionalReturn, type ConverterFunction, type ConverterToken, Converters, type CustomElementConverter, type DebugLevel, EnvBool, type EnvFileOptions, type EnvKeyInput, EnvNum, type EnvProfile, type EnvSource, EnvStr, EnvTime, EnvUrl, Envapt, type EnvaptConverter, EnvaptError, EnvaptErrorCodes, type EnvaptOptions, NodeEnvapter as Envapter, Environment, type Err, type FileEnvSource, type InferConverterFallbackType, type InferConverterReturnType, type InferPrimitiveFallbackType, type InferPrimitiveReturnType, type InferSchemaInput, type InferSchemaOutput, type JsonValue, ManualEnvSource, type MapOfConverterFunctions, NodeEnvSource, type PrimitiveConstructor, type ProfilesConfig, type SchemaConstraint, type SchemaMustBeSync, type StandardSchemaV1, type TimeFallback, type TimeUnit, WorkerEnvSource, isArrayOf };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ArrayElement, ArrayOf, ConverterToken, Converters, CustomElementConverter, isArrayOf } from "./converters/Converters.mjs";
|
|
2
|
+
import { AdvancedConverterReturn, BuiltInConverter, BuiltInConverterFunction, ConditionalReturn, ConverterFunction, EnvaptConverter, InferConverterFallbackType, InferConverterReturnType, InferPrimitiveFallbackType, InferPrimitiveReturnType, JsonValue, MapOfConverterFunctions, PrimitiveConstructor, TimeFallback, TimeUnit } from "./types/Conversion.mjs";
|
|
3
|
+
import { InferSchemaInput, InferSchemaOutput, StandardSchemaV1 } from "./StandardSchema.mjs";
|
|
4
|
+
import { Err, SchemaConstraint, SchemaMustBeSync } from "./types/Schema.mjs";
|
|
5
|
+
import { DebugLevel } from "./Debug.mjs";
|
|
6
|
+
import { EnvFileOptions } from "./Dotenv.mjs";
|
|
7
|
+
import { Environment } from "./core/EnvironmentMethods.mjs";
|
|
8
|
+
import { EnvProfile, EnvaptOptions, ProfilesConfig } from "./types/Options.mjs";
|
|
9
|
+
import { EnvKeyInput } from "./types/Env.mjs";
|
|
10
|
+
import { BareEnvSource, EnvSource, FileEnvSource } from "./types/Source.mjs";
|
|
11
|
+
import { Envapt } from "./decorators/Envapt.mjs";
|
|
12
|
+
import { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl } from "./decorators/SugarDecorators.mjs";
|
|
13
|
+
import { ManualEnvSource } from "./sources/ManualEnvSource.mjs";
|
|
14
|
+
import { WorkerEnvSource } from "./sources/WorkerEnvSource.mjs";
|
|
15
|
+
import { EnvaptError, EnvaptErrorCodes } from "./Error.mjs";
|
|
16
|
+
import { NodeEnvapter } from "./NodeEnvapter.mjs";
|
|
17
|
+
import { NodeEnvSource } from "./sources/NodeEnvSource.mjs";
|
|
18
|
+
export { type AdvancedConverterReturn, type ArrayElement, type ArrayOf, type BareEnvSource, type BuiltInConverter, type BuiltInConverterFunction, type ConditionalReturn, type ConverterFunction, type ConverterToken, Converters, type CustomElementConverter, type DebugLevel, EnvBool, type EnvFileOptions, type EnvKeyInput, EnvNum, type EnvProfile, type EnvSource, EnvStr, EnvTime, EnvUrl, Envapt, type EnvaptConverter, EnvaptError, EnvaptErrorCodes, type EnvaptOptions, NodeEnvapter as Envapter, Environment, type Err, type FileEnvSource, type InferConverterFallbackType, type InferConverterReturnType, type InferPrimitiveFallbackType, type InferPrimitiveReturnType, type InferSchemaInput, type InferSchemaOutput, type JsonValue, ManualEnvSource, type MapOfConverterFunctions, NodeEnvSource, type PrimitiveConstructor, type ProfilesConfig, type SchemaConstraint, type SchemaMustBeSync, type StandardSchemaV1, type TimeFallback, type TimeUnit, WorkerEnvSource, isArrayOf };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Converters as e,isArrayOf as t}from"./converters/Converters.mjs";import{EnvaptError as n,EnvaptErrorCodes as r}from"./Error.mjs";import{Environment as i}from"./core/EnvironmentMethods.mjs";import{Envapt as a}from"./decorators/Envapt.mjs";import{EnvBool as o,EnvNum as s,EnvStr as c,EnvTime as l,EnvUrl as u}from"./decorators/SugarDecorators.mjs";import{ManualEnvSource as d}from"./sources/ManualEnvSource.mjs";import{WorkerEnvSource as f}from"./sources/WorkerEnvSource.mjs";import{NodeEnvSource as p}from"./sources/NodeEnvSource.mjs";import{NodeEnvapter as m}from"./NodeEnvapter.mjs";export{e as Converters,o as EnvBool,s as EnvNum,c as EnvStr,l as EnvTime,u as EnvUrl,a as Envapt,n as EnvaptError,r as EnvaptErrorCodes,m as Envapter,i as Environment,d as ManualEnvSource,p as NodeEnvSource,f as WorkerEnvSource,t as isArrayOf};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
let e=e=>{console.error(e)},t=()=>({});function n(t){e=t}function r(t){e(t)}function i(){return t()}function a(e){t=()=>e.readVars()}exports.bindRuntimeFromSource=a,exports.readRuntimeEnv=i,exports.setRuntimeSink=n,exports.writeRuntimeLine=r;
|
|
2
|
+
//# sourceMappingURL=runtime.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.cjs","names":[],"sources":["../../src/runtime.ts"],"sourcesContent":["import type { EnvSource } from './types';\n\n// EnvapterBase imports Debug; importing it back would cycle, so the source/sink are injected via the setters below.\n/* v8 ignore start -- @preserve replaced at load on Node; the Node suite never runs these defaults */\nlet sink: (line: string) => void = (line) => {\n // eslint-disable-next-line no-console -- the off-Node fallback log sink\n console.error(line);\n};\nlet envReader: () => Record<string, string> = () => ({});\n/* v8 ignore stop */\n\nexport function setRuntimeSink(fn: (line: string) => void): void {\n sink = fn;\n}\n\nexport function writeRuntimeLine(line: string): void {\n sink(line);\n}\n\nexport function readRuntimeEnv(): Record<string, string> {\n return envReader();\n}\n\nexport function bindRuntimeFromSource(source: EnvSource): void {\n envReader = (): Record<string, string> => source.readVars();\n}\n"],"mappings":"AAIA,IAAI,EAAgC,GAAS,CAEzC,QAAQ,MAAM,CAAI,CACtB,EACI,OAAiD,CAAC,GAGtD,SAAgB,EAAe,EAAkC,CAC7D,EAAO,CACX,CAEA,SAAgB,EAAiB,EAAoB,CACjD,EAAK,CAAI,CACb,CAEA,SAAgB,GAAyC,CACrD,OAAO,EAAU,CACrB,CAEA,SAAgB,EAAsB,EAAyB,CAC3D,MAA0C,EAAO,SAAS,CAC9D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../src/runtime.ts"],"sourcesContent":["import type { EnvSource } from './types';\n\n// EnvapterBase imports Debug; importing it back would cycle, so the source/sink are injected via the setters below.\n/* v8 ignore start -- @preserve replaced at load on Node; the Node suite never runs these defaults */\nlet sink: (line: string) => void = (line) => {\n // eslint-disable-next-line no-console -- the off-Node fallback log sink\n console.error(line);\n};\nlet envReader: () => Record<string, string> = () => ({});\n/* v8 ignore stop */\n\nexport function setRuntimeSink(fn: (line: string) => void): void {\n sink = fn;\n}\n\nexport function writeRuntimeLine(line: string): void {\n sink(line);\n}\n\nexport function readRuntimeEnv(): Record<string, string> {\n return envReader();\n}\n\nexport function bindRuntimeFromSource(source: EnvSource): void {\n envReader = (): Record<string, string> => source.readVars();\n}\n"],"mappings":"AAIA,IAAI,EAAgC,GAAS,CAEzC,QAAQ,MAAM,CAAI,CACtB,EACI,OAAiD,CAAC,GAGtD,SAAgB,EAAe,EAAkC,CAC7D,EAAO,CACX,CAEA,SAAgB,EAAiB,EAAoB,CACjD,EAAK,CAAI,CACb,CAEA,SAAgB,GAAyC,CACrD,OAAO,EAAU,CACrB,CAEA,SAAgB,EAAsB,EAAyB,CAC3D,MAA0C,EAAO,SAAS,CAC9D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ManualEnvSource.cjs","names":["coerceToStringRecord"],"sources":["../../../src/sources/ManualEnvSource.ts"],"sourcesContent":["import { coerceToStringRecord } from './coerce';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * Environment source seeded from an object you provide: the config your bundler injects into a browser\n * build (Vite's `import.meta.env`, a webpack `DefinePlugin` global), a test fixture, or any other plain\n * object. Pass it straight through; non-string values are JSON-stringified so the converters still apply.\n * It has no filesystem, so the `.env` cascade and file-based APIs do not apply.\n * @public\n */\nexport class ManualEnvSource implements BareEnvSource {\n readonly supportsFiles = false;\n private readonly vars: Record<string, string>;\n\n constructor(vars: Record<string, unknown>) {\n this.vars = coerceToStringRecord(vars);\n }\n\n readVars(): Record<string, string> {\n return { ...this.vars };\n }\n}\n"],"mappings":"gCAWA,IAAa,EAAb,KAAsD,CAClD,cAAyB,GACzB,KAEA,YAAY,EAA+B,CACvC,KAAK,KAAOA,EAAAA,qBAAqB,CAAI,CACzC,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/ManualEnvSource.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Environment source seeded from an object you provide: the config your bundler injects into a browser
|
|
6
|
+
* build (Vite's `import.meta.env`, a webpack `DefinePlugin` global), a test fixture, or any other plain
|
|
7
|
+
* object. Pass it straight through; non-string values are JSON-stringified so the converters still apply.
|
|
8
|
+
* It has no filesystem, so the `.env` cascade and file-based APIs do not apply.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
declare class ManualEnvSource implements BareEnvSource {
|
|
12
|
+
readonly supportsFiles = false;
|
|
13
|
+
private readonly vars;
|
|
14
|
+
constructor(vars: Record<string, unknown>);
|
|
15
|
+
readVars(): Record<string, string>;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { ManualEnvSource };
|
|
19
|
+
//# sourceMappingURL=ManualEnvSource.d.cts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BareEnvSource } from "../types/Source.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/sources/ManualEnvSource.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Environment source seeded from an object you provide: the config your bundler injects into a browser
|
|
6
|
+
* build (Vite's `import.meta.env`, a webpack `DefinePlugin` global), a test fixture, or any other plain
|
|
7
|
+
* object. Pass it straight through; non-string values are JSON-stringified so the converters still apply.
|
|
8
|
+
* It has no filesystem, so the `.env` cascade and file-based APIs do not apply.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
declare class ManualEnvSource implements BareEnvSource {
|
|
12
|
+
readonly supportsFiles = false;
|
|
13
|
+
private readonly vars;
|
|
14
|
+
constructor(vars: Record<string, unknown>);
|
|
15
|
+
readVars(): Record<string, string>;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { ManualEnvSource };
|
|
19
|
+
//# sourceMappingURL=ManualEnvSource.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ManualEnvSource.mjs","names":[],"sources":["../../../src/sources/ManualEnvSource.ts"],"sourcesContent":["import { coerceToStringRecord } from './coerce';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * Environment source seeded from an object you provide: the config your bundler injects into a browser\n * build (Vite's `import.meta.env`, a webpack `DefinePlugin` global), a test fixture, or any other plain\n * object. Pass it straight through; non-string values are JSON-stringified so the converters still apply.\n * It has no filesystem, so the `.env` cascade and file-based APIs do not apply.\n * @public\n */\nexport class ManualEnvSource implements BareEnvSource {\n readonly supportsFiles = false;\n private readonly vars: Record<string, string>;\n\n constructor(vars: Record<string, unknown>) {\n this.vars = coerceToStringRecord(vars);\n }\n\n readVars(): Record<string, string> {\n return { ...this.vars };\n }\n}\n"],"mappings":"oDAWA,IAAa,EAAb,KAAsD,CAClD,cAAyB,GACzB,KAEA,YAAY,EAA+B,CACvC,KAAK,KAAO,EAAqB,CAAI,CACzC,CAEA,UAAmC,CAC/B,MAAO,CAAE,GAAG,KAAK,IAAK,CAC1B,CACJ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../_virtual/_rolldown/runtime.cjs");let t=require("node:process");t=e.__toESM(t,1);let n=require("node:fs");n=e.__toESM(n,1);let r=require("node:path"),i=require("node:url");var a=class{supportsFiles=!0;readVars(){return{...t.default.env}}readFile(e,t){try{return n.default.readFileSync(e,t)}catch{return}}normalizeBaseDir(e){return e instanceof URL||e.startsWith(`file:`)?(0,r.dirname)((0,i.fileURLToPath)(e)):(0,r.resolve)(e)}resolvePath(e,t){return(0,r.isAbsolute)(t)?t:(0,r.join)(e,t)}writeVars(e){for(let[n,r]of Object.entries(e))t.default.env[n]=r}};exports.NodeEnvSource=a;
|
|
2
|
+
//# sourceMappingURL=NodeEnvSource.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeEnvSource.cjs","names":["process","fs"],"sources":["../../../src/sources/NodeEnvSource.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { dirname, isAbsolute, join, resolve } from 'node:path';\nimport process from 'node:process';\nimport { fileURLToPath } from 'node:url';\n\nimport type { FileEnvSource } from '../types';\n\n/**\n * Default environment source on Node, Bun, and Deno: a snapshot of `process.env`. Its\n * `supportsFiles` is `true`, so the engine also layers the `.env` cascade on top, resolves\n * `baseDir`, and can mirror loaded keys back to `process.env`.\n * @public\n */\nexport class NodeEnvSource implements FileEnvSource {\n readonly supportsFiles = true;\n\n readVars(): Record<string, string> {\n // Clone so the loader and downstream reads never mutate process.env.\n return { ...(process.env as Record<string, string>) };\n }\n\n readFile(path: string, encoding: string): string | undefined {\n try {\n // justified: our public encoding type is `string`; fs needs the BufferEncoding subset.\n return fs.readFileSync(path, encoding as BufferEncoding);\n } catch {\n return undefined;\n }\n }\n\n // `file:` URLs resolve to their containing directory; plain paths (`import.meta.dirname`, `__dirname`) are taken as the directory.\n normalizeBaseDir(value: string | URL): string {\n if (value instanceof URL) return dirname(fileURLToPath(value));\n if (value.startsWith('file:')) return dirname(fileURLToPath(value));\n return resolve(value);\n }\n\n resolvePath(baseDir: string, candidate: string): string {\n if (isAbsolute(candidate)) return candidate;\n return join(baseDir, candidate);\n }\n\n writeVars(vars: Record<string, string>): void {\n for (const [key, value] of Object.entries(vars)) {\n process.env[key] = value;\n }\n }\n}\n"],"mappings":"+LAaA,IAAa,EAAb,KAAoD,CAChD,cAAyB,GAEzB,UAAmC,CAE/B,MAAO,CAAE,GAAIA,EAAAA,QAAQ,GAA+B,CACxD,CAEA,SAAS,EAAc,EAAsC,CACzD,GAAI,CAEA,OAAOC,EAAAA,QAAG,aAAa,EAAM,CAA0B,CAC3D,MAAQ,CACJ,MACJ,CACJ,CAGA,iBAAiB,EAA6B,CAG1C,OAFI,aAAiB,KACjB,EAAM,WAAW,OAAO,GAAG,EAAA,EAAA,UAAA,EAAA,EAAA,eAA6B,CAAK,CAAC,GAClE,EAAA,EAAA,SAAe,CAAK,CACxB,CAEA,YAAY,EAAiB,EAA2B,CAEpD,OADA,EAAA,EAAA,YAAe,CAAS,EAAU,GAClC,EAAA,EAAA,MAAY,EAAS,CAAS,CAClC,CAEA,UAAU,EAAoC,CAC1C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAI,EAC1C,EAAA,QAAQ,IAAI,GAAO,CAE3B,CACJ"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FileEnvSource } from "../types/Source.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/sources/NodeEnvSource.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Default environment source on Node, Bun, and Deno: a snapshot of `process.env`. Its
|
|
6
|
+
* `supportsFiles` is `true`, so the engine also layers the `.env` cascade on top, resolves
|
|
7
|
+
* `baseDir`, and can mirror loaded keys back to `process.env`.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
declare class NodeEnvSource implements FileEnvSource {
|
|
11
|
+
readonly supportsFiles = true;
|
|
12
|
+
readVars(): Record<string, string>;
|
|
13
|
+
readFile(path: string, encoding: string): string | undefined;
|
|
14
|
+
normalizeBaseDir(value: string | URL): string;
|
|
15
|
+
resolvePath(baseDir: string, candidate: string): string;
|
|
16
|
+
writeVars(vars: Record<string, string>): void;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { NodeEnvSource };
|
|
20
|
+
//# sourceMappingURL=NodeEnvSource.d.cts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FileEnvSource } from "../types/Source.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/sources/NodeEnvSource.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Default environment source on Node, Bun, and Deno: a snapshot of `process.env`. Its
|
|
6
|
+
* `supportsFiles` is `true`, so the engine also layers the `.env` cascade on top, resolves
|
|
7
|
+
* `baseDir`, and can mirror loaded keys back to `process.env`.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
declare class NodeEnvSource implements FileEnvSource {
|
|
11
|
+
readonly supportsFiles = true;
|
|
12
|
+
readVars(): Record<string, string>;
|
|
13
|
+
readFile(path: string, encoding: string): string | undefined;
|
|
14
|
+
normalizeBaseDir(value: string | URL): string;
|
|
15
|
+
resolvePath(baseDir: string, candidate: string): string;
|
|
16
|
+
writeVars(vars: Record<string, string>): void;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { NodeEnvSource };
|
|
20
|
+
//# sourceMappingURL=NodeEnvSource.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import e from"node:process";import t from"node:fs";import{dirname as n,isAbsolute as r,join as i,resolve as a}from"node:path";import{fileURLToPath as o}from"node:url";var s=class{supportsFiles=!0;readVars(){return{...e.env}}readFile(e,n){try{return t.readFileSync(e,n)}catch{return}}normalizeBaseDir(e){return e instanceof URL||e.startsWith(`file:`)?n(o(e)):a(e)}resolvePath(e,t){return r(t)?t:i(e,t)}writeVars(t){for(let[n,r]of Object.entries(t))e.env[n]=r}};export{s as NodeEnvSource};
|
|
2
|
+
//# sourceMappingURL=NodeEnvSource.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeEnvSource.mjs","names":[],"sources":["../../../src/sources/NodeEnvSource.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { dirname, isAbsolute, join, resolve } from 'node:path';\nimport process from 'node:process';\nimport { fileURLToPath } from 'node:url';\n\nimport type { FileEnvSource } from '../types';\n\n/**\n * Default environment source on Node, Bun, and Deno: a snapshot of `process.env`. Its\n * `supportsFiles` is `true`, so the engine also layers the `.env` cascade on top, resolves\n * `baseDir`, and can mirror loaded keys back to `process.env`.\n * @public\n */\nexport class NodeEnvSource implements FileEnvSource {\n readonly supportsFiles = true;\n\n readVars(): Record<string, string> {\n // Clone so the loader and downstream reads never mutate process.env.\n return { ...(process.env as Record<string, string>) };\n }\n\n readFile(path: string, encoding: string): string | undefined {\n try {\n // justified: our public encoding type is `string`; fs needs the BufferEncoding subset.\n return fs.readFileSync(path, encoding as BufferEncoding);\n } catch {\n return undefined;\n }\n }\n\n // `file:` URLs resolve to their containing directory; plain paths (`import.meta.dirname`, `__dirname`) are taken as the directory.\n normalizeBaseDir(value: string | URL): string {\n if (value instanceof URL) return dirname(fileURLToPath(value));\n if (value.startsWith('file:')) return dirname(fileURLToPath(value));\n return resolve(value);\n }\n\n resolvePath(baseDir: string, candidate: string): string {\n if (isAbsolute(candidate)) return candidate;\n return join(baseDir, candidate);\n }\n\n writeVars(vars: Record<string, string>): void {\n for (const [key, value] of Object.entries(vars)) {\n process.env[key] = value;\n }\n }\n}\n"],"mappings":"uKAaA,IAAa,EAAb,KAAoD,CAChD,cAAyB,GAEzB,UAAmC,CAE/B,MAAO,CAAE,GAAI,EAAQ,GAA+B,CACxD,CAEA,SAAS,EAAc,EAAsC,CACzD,GAAI,CAEA,OAAO,EAAG,aAAa,EAAM,CAA0B,CAC3D,MAAQ,CACJ,MACJ,CACJ,CAGA,iBAAiB,EAA6B,CAG1C,OAFI,aAAiB,KACjB,EAAM,WAAW,OAAO,EAAU,EAAQ,EAAc,CAAK,CAAC,EAC3D,EAAQ,CAAK,CACxB,CAEA,YAAY,EAAiB,EAA2B,CAEpD,OADI,EAAW,CAAS,EAAU,EAC3B,EAAK,EAAS,CAAS,CAClC,CAEA,UAAU,EAAoC,CAC1C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAI,EAC1C,EAAQ,IAAI,GAAO,CAE3B,CACJ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../Error.cjs");var t=class{supportsFiles=!1;readVars(){throw new e.EnvaptError(307,`No environment source is bound. Call Envapter.useSource(...) with a source such as new ManualEnvSource({...}) or new WorkerEnvSource(env) before reading.`)}};exports.UnboundEnvSource=t;
|
|
2
|
+
//# sourceMappingURL=UnboundEnvSource.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnboundEnvSource.cjs","names":["EnvaptError"],"sources":["../../../src/sources/UnboundEnvSource.ts"],"sourcesContent":["import { EnvaptError, EnvaptErrorCodes } from '../Error';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * The default source until one is bound. Every read throws NoSourceBound so a forgotten `useSource`\n * surfaces at read time instead of silently yielding nothing. The Node entry binds {@link NodeEnvSource}\n * at load; browser and Workers bundles must call `Envapter.useSource(...)` before reading.\n * @internal\n */\nexport class UnboundEnvSource implements BareEnvSource {\n readonly supportsFiles = false;\n\n readVars(): Record<string, string> {\n throw new EnvaptError(\n EnvaptErrorCodes.NoSourceBound,\n 'No environment source is bound. Call Envapter.useSource(...) with a source such as new ManualEnvSource({...}) or new WorkerEnvSource(env) before reading.'\n );\n }\n}\n"],"mappings":"gCAUA,IAAa,EAAb,KAAuD,CACnD,cAAyB,GAEzB,UAAmC,CAC/B,MAAM,IAAIA,EAAAA,YAAAA,IAEN,2JACJ,CACJ,CACJ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{EnvaptError as e}from"../Error.mjs";var t=class{supportsFiles=!1;readVars(){throw new e(307,`No environment source is bound. Call Envapter.useSource(...) with a source such as new ManualEnvSource({...}) or new WorkerEnvSource(env) before reading.`)}};export{t as UnboundEnvSource};
|
|
2
|
+
//# sourceMappingURL=UnboundEnvSource.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnboundEnvSource.mjs","names":[],"sources":["../../../src/sources/UnboundEnvSource.ts"],"sourcesContent":["import { EnvaptError, EnvaptErrorCodes } from '../Error';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * The default source until one is bound. Every read throws NoSourceBound so a forgotten `useSource`\n * surfaces at read time instead of silently yielding nothing. The Node entry binds {@link NodeEnvSource}\n * at load; browser and Workers bundles must call `Envapter.useSource(...)` before reading.\n * @internal\n */\nexport class UnboundEnvSource implements BareEnvSource {\n readonly supportsFiles = false;\n\n readVars(): Record<string, string> {\n throw new EnvaptError(\n EnvaptErrorCodes.NoSourceBound,\n 'No environment source is bound. Call Envapter.useSource(...) with a source such as new ManualEnvSource({...}) or new WorkerEnvSource(env) before reading.'\n );\n }\n}\n"],"mappings":"2CAUA,IAAa,EAAb,KAAuD,CACnD,cAAyB,GAEzB,UAAmC,CAC/B,MAAM,IAAI,EAAA,IAEN,2JACJ,CACJ,CACJ"}
|