envapt 6.0.2 → 7.0.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 +25 -0
- package/README.md +5 -8
- package/dist/browser/converters/BuiltInConverters.mjs +1 -1
- package/dist/browser/converters/BuiltInConverters.mjs.map +1 -1
- package/dist/browser/converters/ValueConverter.mjs +1 -1
- package/dist/browser/converters/ValueConverter.mjs.map +1 -1
- package/dist/browser/core/AdvancedMethods.mjs +1 -1
- package/dist/browser/core/AdvancedMethods.mjs.map +1 -1
- package/dist/browser/core/EnvapterBase.mjs +1 -1
- package/dist/browser/core/EnvapterBase.mjs.map +1 -1
- package/dist/browser/core/EnvironmentMethods.mjs +1 -1
- package/dist/browser/core/EnvironmentMethods.mjs.map +1 -1
- package/dist/browser/core/PrimitiveMethods.mjs +1 -1
- package/dist/browser/core/PrimitiveMethods.mjs.map +1 -1
- package/dist/browser/decorators/legacy/Envapt.mjs +2 -0
- package/dist/browser/decorators/legacy/Envapt.mjs.map +1 -0
- package/dist/browser/decorators/legacy/SugarDecorators.mjs +2 -0
- package/dist/browser/decorators/legacy/SugarDecorators.mjs.map +1 -0
- package/dist/browser/decorators/legacy/createPropertyDecorator.mjs +2 -0
- package/dist/browser/decorators/legacy/createPropertyDecorator.mjs.map +1 -0
- package/dist/browser/decorators/modern/Envapt.mjs +2 -0
- package/dist/browser/decorators/modern/Envapt.mjs.map +1 -0
- package/dist/browser/decorators/modern/SugarDecorators.mjs +2 -0
- package/dist/browser/decorators/modern/SugarDecorators.mjs.map +1 -0
- package/dist/browser/decorators/modern/createAccessorDecorator.mjs +2 -0
- package/dist/browser/decorators/modern/createAccessorDecorator.mjs.map +1 -0
- package/dist/browser/decorators/parseEnvaptOptions.mjs +2 -0
- package/dist/browser/decorators/parseEnvaptOptions.mjs.map +1 -0
- package/dist/browser/decorators/resolveDecoratorValue.mjs +2 -0
- package/dist/browser/decorators/resolveDecoratorValue.mjs.map +1 -0
- package/dist/browser/engine/Envapter.mjs +2 -0
- package/dist/browser/engine/Envapter.mjs.map +1 -0
- package/dist/browser/engine/TemplateResolver.mjs +2 -0
- package/dist/browser/engine/TemplateResolver.mjs.map +1 -0
- package/dist/browser/engine/Validators.mjs +2 -0
- package/dist/browser/engine/Validators.mjs.map +1 -0
- package/dist/browser/engine/installFileApiStubs.mjs +2 -0
- package/dist/browser/engine/installFileApiStubs.mjs.map +1 -0
- package/dist/browser/index.mjs +1 -1
- package/dist/browser/index.mjs.map +1 -1
- package/dist/browser/infra/Debug.mjs.map +1 -0
- package/dist/browser/infra/Dotenv.mjs.map +1 -0
- package/dist/browser/infra/Error.mjs.map +1 -0
- package/dist/browser/infra/runtime.mjs.map +1 -0
- package/dist/browser/legacy.mjs +1 -0
- package/dist/browser/sources/UnboundEnvSource.mjs +1 -1
- package/dist/browser/sources/UnboundEnvSource.mjs.map +1 -1
- package/dist/node/config.cjs +1 -1
- package/dist/node/config.cjs.map +1 -1
- package/dist/node/config.mjs +1 -1
- package/dist/node/config.mjs.map +1 -1
- package/dist/node/converters/BuiltInConverters.cjs +1 -1
- package/dist/node/converters/BuiltInConverters.cjs.map +1 -1
- package/dist/node/converters/BuiltInConverters.mjs +1 -1
- package/dist/node/converters/BuiltInConverters.mjs.map +1 -1
- package/dist/node/converters/ValueConverter.cjs +1 -1
- package/dist/node/converters/ValueConverter.cjs.map +1 -1
- package/dist/node/converters/ValueConverter.mjs +1 -1
- package/dist/node/converters/ValueConverter.mjs.map +1 -1
- package/dist/node/core/AdvancedMethods.cjs +1 -1
- package/dist/node/core/AdvancedMethods.cjs.map +1 -1
- package/dist/node/core/AdvancedMethods.mjs +1 -1
- package/dist/node/core/AdvancedMethods.mjs.map +1 -1
- package/dist/node/core/EnvapterBase.cjs +1 -1
- package/dist/node/core/EnvapterBase.cjs.map +1 -1
- package/dist/node/core/EnvapterBase.mjs +1 -1
- package/dist/node/core/EnvapterBase.mjs.map +1 -1
- package/dist/node/core/EnvironmentMethods.cjs +1 -1
- package/dist/node/core/EnvironmentMethods.cjs.map +1 -1
- package/dist/node/core/EnvironmentMethods.mjs +1 -1
- package/dist/node/core/EnvironmentMethods.mjs.map +1 -1
- package/dist/node/core/PrimitiveMethods.cjs +1 -1
- package/dist/node/core/PrimitiveMethods.cjs.map +1 -1
- package/dist/node/core/PrimitiveMethods.mjs +1 -1
- package/dist/node/core/PrimitiveMethods.mjs.map +1 -1
- package/dist/node/decorators/legacy/Envapt.cjs +2 -0
- package/dist/node/decorators/legacy/Envapt.cjs.map +1 -0
- package/dist/node/decorators/legacy/Envapt.mjs +2 -0
- package/dist/node/decorators/legacy/Envapt.mjs.map +1 -0
- package/dist/node/decorators/legacy/SugarDecorators.cjs +2 -0
- package/dist/node/decorators/legacy/SugarDecorators.cjs.map +1 -0
- package/dist/node/decorators/legacy/SugarDecorators.mjs +2 -0
- package/dist/node/decorators/legacy/SugarDecorators.mjs.map +1 -0
- package/dist/node/decorators/legacy/createPropertyDecorator.cjs +2 -0
- package/dist/node/decorators/legacy/createPropertyDecorator.cjs.map +1 -0
- package/dist/node/decorators/legacy/createPropertyDecorator.mjs +2 -0
- package/dist/node/decorators/legacy/createPropertyDecorator.mjs.map +1 -0
- package/dist/node/decorators/modern/Envapt.cjs +2 -0
- package/dist/node/decorators/modern/Envapt.cjs.map +1 -0
- package/dist/node/decorators/modern/Envapt.mjs +2 -0
- package/dist/node/decorators/modern/Envapt.mjs.map +1 -0
- package/dist/node/decorators/modern/SugarDecorators.cjs +2 -0
- package/dist/node/decorators/modern/SugarDecorators.cjs.map +1 -0
- package/dist/node/decorators/modern/SugarDecorators.mjs +2 -0
- package/dist/node/decorators/modern/SugarDecorators.mjs.map +1 -0
- package/dist/node/decorators/modern/createAccessorDecorator.cjs +2 -0
- package/dist/node/decorators/modern/createAccessorDecorator.cjs.map +1 -0
- package/dist/node/decorators/modern/createAccessorDecorator.mjs +2 -0
- package/dist/node/decorators/modern/createAccessorDecorator.mjs.map +1 -0
- package/dist/node/decorators/parseEnvaptOptions.cjs +2 -0
- package/dist/node/decorators/parseEnvaptOptions.cjs.map +1 -0
- package/dist/node/decorators/parseEnvaptOptions.mjs +2 -0
- package/dist/node/decorators/parseEnvaptOptions.mjs.map +1 -0
- package/dist/node/decorators/resolveDecoratorValue.cjs +2 -0
- package/dist/node/decorators/resolveDecoratorValue.cjs.map +1 -0
- package/dist/node/decorators/resolveDecoratorValue.mjs +2 -0
- package/dist/node/decorators/resolveDecoratorValue.mjs.map +1 -0
- package/dist/node/engine/Envapter.cjs +2 -0
- package/dist/node/engine/Envapter.cjs.map +1 -0
- package/dist/node/engine/Envapter.mjs +2 -0
- package/dist/node/engine/Envapter.mjs.map +1 -0
- package/dist/node/engine/NodeEnvapter.cjs +2 -0
- package/dist/node/engine/NodeEnvapter.cjs.map +1 -0
- package/dist/node/engine/NodeEnvapter.mjs +2 -0
- package/dist/node/engine/NodeEnvapter.mjs.map +1 -0
- package/dist/node/engine/TemplateResolver.cjs +2 -0
- package/dist/node/engine/TemplateResolver.cjs.map +1 -0
- package/dist/node/engine/TemplateResolver.mjs +2 -0
- package/dist/node/engine/TemplateResolver.mjs.map +1 -0
- package/dist/node/engine/Validators.cjs +2 -0
- package/dist/node/engine/Validators.cjs.map +1 -0
- package/dist/node/engine/Validators.mjs +2 -0
- package/dist/node/engine/Validators.mjs.map +1 -0
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.mjs +1 -1
- package/dist/node/infra/Debug.cjs.map +1 -0
- package/dist/node/infra/Debug.mjs.map +1 -0
- package/dist/node/infra/Dotenv.cjs.map +1 -0
- package/dist/node/infra/Dotenv.mjs.map +1 -0
- package/dist/node/infra/Error.cjs.map +1 -0
- package/dist/node/infra/Error.mjs.map +1 -0
- package/dist/node/infra/runtime.cjs.map +1 -0
- package/dist/node/infra/runtime.mjs.map +1 -0
- package/dist/node/legacy.cjs +1 -0
- package/dist/node/legacy.mjs +1 -0
- package/dist/node/sources/UnboundEnvSource.cjs +1 -1
- package/dist/node/sources/UnboundEnvSource.cjs.map +1 -1
- package/dist/node/sources/UnboundEnvSource.mjs +1 -1
- package/dist/node/sources/UnboundEnvSource.mjs.map +1 -1
- package/dist/{browser → types}/converters/ValueConverter.d.mts +1 -1
- package/dist/{workerd → types}/core/AdvancedMethods.d.mts +1 -1
- package/dist/{workerd → types}/core/EnvapterBase.d.mts +2 -2
- package/dist/{browser → types}/core/PrimitiveMethods.d.mts +1 -1
- package/dist/{browser/decorators → types/decorators/legacy}/Envapt.d.mts +59 -49
- package/dist/types/decorators/legacy/SugarDecorators.d.mts +40 -0
- package/dist/types/decorators/modern/Envapt.d.mts +218 -0
- package/dist/types/decorators/modern/SugarDecorators.d.mts +40 -0
- package/dist/{browser → types/engine}/Envapter.d.mts +3 -3
- package/dist/{node/NodeEnvapter.d.cts → types/engine/NodeEnvapter.d.mts} +5 -5
- package/dist/{browser → types/engine}/TemplateResolver.d.mts +2 -2
- package/dist/{node → types}/index.d.mts +9 -10
- package/dist/{workerd/index.d.mts → types/index.portable.d.mts} +9 -8
- package/dist/{browser → types/infra}/Debug.d.mts +1 -1
- package/dist/{workerd → types/infra}/Dotenv.d.mts +1 -1
- package/dist/{browser → types/infra}/Error.d.mts +1 -1
- package/dist/{browser → types/infra}/StandardSchema.d.mts +1 -1
- package/dist/types/legacy.d.mts +4 -0
- package/dist/{node/sources/NodeEnvSource.d.cts → types/sources/NodeEnvSource.d.mts} +2 -2
- package/dist/types/types/Decorator.d.mts +26 -0
- package/dist/{browser → types}/types/Schema.d.mts +1 -1
- package/dist/workerd/converters/BuiltInConverters.mjs +1 -1
- package/dist/workerd/converters/BuiltInConverters.mjs.map +1 -1
- package/dist/workerd/converters/ValueConverter.mjs +1 -1
- package/dist/workerd/converters/ValueConverter.mjs.map +1 -1
- package/dist/workerd/core/AdvancedMethods.mjs +1 -1
- package/dist/workerd/core/AdvancedMethods.mjs.map +1 -1
- package/dist/workerd/core/EnvapterBase.mjs +1 -1
- package/dist/workerd/core/EnvapterBase.mjs.map +1 -1
- package/dist/workerd/core/EnvironmentMethods.mjs +1 -1
- package/dist/workerd/core/EnvironmentMethods.mjs.map +1 -1
- package/dist/workerd/core/PrimitiveMethods.mjs +1 -1
- package/dist/workerd/core/PrimitiveMethods.mjs.map +1 -1
- package/dist/workerd/decorators/legacy/Envapt.mjs +2 -0
- package/dist/workerd/decorators/legacy/Envapt.mjs.map +1 -0
- package/dist/workerd/decorators/legacy/SugarDecorators.mjs +2 -0
- package/dist/workerd/decorators/legacy/SugarDecorators.mjs.map +1 -0
- package/dist/workerd/decorators/legacy/createPropertyDecorator.mjs +2 -0
- package/dist/workerd/decorators/legacy/createPropertyDecorator.mjs.map +1 -0
- package/dist/workerd/decorators/modern/Envapt.mjs +2 -0
- package/dist/workerd/decorators/modern/Envapt.mjs.map +1 -0
- package/dist/workerd/decorators/modern/SugarDecorators.mjs +2 -0
- package/dist/workerd/decorators/modern/SugarDecorators.mjs.map +1 -0
- package/dist/workerd/decorators/modern/createAccessorDecorator.mjs +2 -0
- package/dist/workerd/decorators/modern/createAccessorDecorator.mjs.map +1 -0
- package/dist/workerd/decorators/parseEnvaptOptions.mjs +2 -0
- package/dist/workerd/decorators/parseEnvaptOptions.mjs.map +1 -0
- package/dist/workerd/decorators/resolveDecoratorValue.mjs +2 -0
- package/dist/workerd/decorators/resolveDecoratorValue.mjs.map +1 -0
- package/dist/workerd/engine/Envapter.mjs +2 -0
- package/dist/workerd/engine/Envapter.mjs.map +1 -0
- package/dist/workerd/engine/TemplateResolver.mjs +2 -0
- package/dist/workerd/engine/TemplateResolver.mjs.map +1 -0
- package/dist/workerd/engine/Validators.mjs +2 -0
- package/dist/workerd/engine/Validators.mjs.map +1 -0
- package/dist/workerd/engine/installFileApiStubs.mjs +2 -0
- package/dist/workerd/engine/installFileApiStubs.mjs.map +1 -0
- package/dist/workerd/index.mjs +1 -1
- package/dist/workerd/index.mjs.map +1 -1
- package/dist/workerd/infra/Debug.mjs.map +1 -0
- package/dist/workerd/infra/Dotenv.mjs.map +1 -0
- package/dist/workerd/infra/Error.mjs.map +1 -0
- package/dist/workerd/infra/runtime.mjs.map +1 -0
- package/dist/workerd/legacy.mjs +1 -0
- package/dist/workerd/sources/UnboundEnvSource.mjs +1 -1
- package/dist/workerd/sources/UnboundEnvSource.mjs.map +1 -1
- package/package.json +50 -15
- package/dist/browser/Debug.mjs.map +0 -1
- package/dist/browser/Dotenv.d.mts +0 -17
- package/dist/browser/Dotenv.mjs.map +0 -1
- package/dist/browser/Envapter.mjs +0 -2
- package/dist/browser/Envapter.mjs.map +0 -1
- package/dist/browser/Error.mjs.map +0 -1
- package/dist/browser/TemplateResolver.mjs +0 -2
- package/dist/browser/TemplateResolver.mjs.map +0 -1
- package/dist/browser/Validators.mjs +0 -2
- package/dist/browser/Validators.mjs.map +0 -1
- package/dist/browser/core/AdvancedMethods.d.mts +0 -76
- package/dist/browser/core/EnvapterBase.d.mts +0 -75
- package/dist/browser/decorators/Envapt.mjs +0 -2
- package/dist/browser/decorators/Envapt.mjs.map +0 -1
- package/dist/browser/decorators/SugarDecorators.d.mts +0 -34
- package/dist/browser/decorators/SugarDecorators.mjs +0 -2
- package/dist/browser/decorators/SugarDecorators.mjs.map +0 -1
- package/dist/browser/decorators/createPropertyDecorator.mjs +0 -2
- package/dist/browser/decorators/createPropertyDecorator.mjs.map +0 -1
- package/dist/browser/index.d.mts +0 -17
- package/dist/browser/installFileApiStubs.mjs +0 -2
- package/dist/browser/installFileApiStubs.mjs.map +0 -1
- package/dist/browser/runtime.mjs.map +0 -1
- package/dist/node/Debug.cjs.map +0 -1
- package/dist/node/Debug.d.cts +0 -13
- package/dist/node/Debug.d.mts +0 -15
- package/dist/node/Debug.mjs.map +0 -1
- package/dist/node/Dotenv.cjs.map +0 -1
- package/dist/node/Dotenv.d.cts +0 -17
- package/dist/node/Dotenv.d.mts +0 -19
- package/dist/node/Dotenv.mjs.map +0 -1
- package/dist/node/Envapter.cjs +0 -2
- package/dist/node/Envapter.cjs.map +0 -1
- package/dist/node/Envapter.d.cts +0 -70
- package/dist/node/Envapter.d.mts +0 -72
- package/dist/node/Envapter.mjs +0 -2
- package/dist/node/Envapter.mjs.map +0 -1
- package/dist/node/Error.cjs.map +0 -1
- package/dist/node/Error.d.cts +0 -72
- package/dist/node/Error.d.mts +0 -74
- package/dist/node/Error.mjs.map +0 -1
- package/dist/node/NodeEnvapter.cjs +0 -2
- package/dist/node/NodeEnvapter.cjs.map +0 -1
- package/dist/node/NodeEnvapter.d.mts +0 -75
- package/dist/node/NodeEnvapter.mjs +0 -2
- package/dist/node/NodeEnvapter.mjs.map +0 -1
- package/dist/node/StandardSchema.d.cts +0 -59
- package/dist/node/StandardSchema.d.mts +0 -61
- package/dist/node/TemplateResolver.cjs +0 -2
- package/dist/node/TemplateResolver.cjs.map +0 -1
- package/dist/node/TemplateResolver.d.cts +0 -17
- package/dist/node/TemplateResolver.d.mts +0 -19
- package/dist/node/TemplateResolver.mjs +0 -2
- package/dist/node/TemplateResolver.mjs.map +0 -1
- package/dist/node/Validators.cjs +0 -2
- package/dist/node/Validators.cjs.map +0 -1
- package/dist/node/Validators.mjs +0 -2
- package/dist/node/Validators.mjs.map +0 -1
- package/dist/node/config.d.mts +0 -2
- package/dist/node/converters/Converters.d.cts +0 -93
- package/dist/node/converters/Converters.d.mts +0 -95
- package/dist/node/converters/ValueConverter.d.cts +0 -25
- package/dist/node/converters/ValueConverter.d.mts +0 -27
- package/dist/node/core/AdvancedMethods.d.cts +0 -76
- package/dist/node/core/AdvancedMethods.d.mts +0 -78
- package/dist/node/core/EnvapterBase.d.cts +0 -75
- package/dist/node/core/EnvapterBase.d.mts +0 -77
- package/dist/node/core/EnvironmentMethods.d.cts +0 -115
- package/dist/node/core/EnvironmentMethods.d.mts +0 -117
- package/dist/node/core/PrimitiveMethods.d.cts +0 -70
- package/dist/node/core/PrimitiveMethods.d.mts +0 -72
- package/dist/node/decorators/Envapt.cjs +0 -2
- package/dist/node/decorators/Envapt.cjs.map +0 -1
- package/dist/node/decorators/Envapt.d.cts +0 -208
- package/dist/node/decorators/Envapt.d.mts +0 -210
- package/dist/node/decorators/Envapt.mjs +0 -2
- package/dist/node/decorators/Envapt.mjs.map +0 -1
- package/dist/node/decorators/SugarDecorators.cjs +0 -2
- package/dist/node/decorators/SugarDecorators.cjs.map +0 -1
- package/dist/node/decorators/SugarDecorators.d.cts +0 -34
- package/dist/node/decorators/SugarDecorators.d.mts +0 -36
- package/dist/node/decorators/SugarDecorators.mjs +0 -2
- package/dist/node/decorators/SugarDecorators.mjs.map +0 -1
- package/dist/node/decorators/createPropertyDecorator.cjs +0 -2
- package/dist/node/decorators/createPropertyDecorator.cjs.map +0 -1
- package/dist/node/decorators/createPropertyDecorator.mjs +0 -2
- package/dist/node/decorators/createPropertyDecorator.mjs.map +0 -1
- package/dist/node/index.d.cts +0 -18
- package/dist/node/runtime.cjs.map +0 -1
- package/dist/node/runtime.mjs.map +0 -1
- package/dist/node/sources/ManualEnvSource.d.cts +0 -19
- package/dist/node/sources/ManualEnvSource.d.mts +0 -21
- package/dist/node/sources/NodeEnvSource.d.mts +0 -22
- package/dist/node/sources/WorkerEnvSource.d.cts +0 -19
- package/dist/node/sources/WorkerEnvSource.d.mts +0 -21
- package/dist/node/types/Conversion.d.cts +0 -123
- package/dist/node/types/Conversion.d.mts +0 -125
- package/dist/node/types/Env.d.cts +0 -17
- package/dist/node/types/Env.d.mts +0 -19
- package/dist/node/types/Options.d.cts +0 -39
- package/dist/node/types/Options.d.mts +0 -41
- package/dist/node/types/Schema.d.cts +0 -12
- package/dist/node/types/Schema.d.mts +0 -14
- package/dist/node/types/Source.d.cts +0 -44
- package/dist/node/types/Source.d.mts +0 -46
- package/dist/workerd/Debug.d.mts +0 -13
- package/dist/workerd/Debug.mjs.map +0 -1
- package/dist/workerd/Dotenv.mjs.map +0 -1
- package/dist/workerd/Envapter.d.mts +0 -70
- package/dist/workerd/Envapter.mjs +0 -2
- package/dist/workerd/Envapter.mjs.map +0 -1
- package/dist/workerd/Error.d.mts +0 -72
- package/dist/workerd/Error.mjs.map +0 -1
- package/dist/workerd/StandardSchema.d.mts +0 -59
- package/dist/workerd/TemplateResolver.d.mts +0 -17
- package/dist/workerd/TemplateResolver.mjs +0 -2
- package/dist/workerd/TemplateResolver.mjs.map +0 -1
- package/dist/workerd/Validators.mjs +0 -2
- package/dist/workerd/Validators.mjs.map +0 -1
- package/dist/workerd/converters/Converters.d.mts +0 -93
- package/dist/workerd/converters/ValueConverter.d.mts +0 -25
- package/dist/workerd/core/EnvironmentMethods.d.mts +0 -115
- package/dist/workerd/core/PrimitiveMethods.d.mts +0 -70
- package/dist/workerd/decorators/Envapt.d.mts +0 -208
- package/dist/workerd/decorators/Envapt.mjs +0 -2
- package/dist/workerd/decorators/Envapt.mjs.map +0 -1
- package/dist/workerd/decorators/SugarDecorators.d.mts +0 -34
- package/dist/workerd/decorators/SugarDecorators.mjs +0 -2
- package/dist/workerd/decorators/SugarDecorators.mjs.map +0 -1
- package/dist/workerd/decorators/createPropertyDecorator.mjs +0 -2
- package/dist/workerd/decorators/createPropertyDecorator.mjs.map +0 -1
- package/dist/workerd/installFileApiStubs.mjs +0 -2
- package/dist/workerd/installFileApiStubs.mjs.map +0 -1
- package/dist/workerd/runtime.mjs.map +0 -1
- package/dist/workerd/sources/ManualEnvSource.d.mts +0 -19
- package/dist/workerd/sources/WorkerEnvSource.d.mts +0 -19
- package/dist/workerd/types/Conversion.d.mts +0 -123
- package/dist/workerd/types/Env.d.mts +0 -17
- package/dist/workerd/types/Options.d.mts +0 -39
- package/dist/workerd/types/Schema.d.mts +0 -12
- package/dist/workerd/types/Source.d.mts +0 -44
- /package/dist/browser/{Debug.mjs → infra/Debug.mjs} +0 -0
- /package/dist/browser/{Dotenv.mjs → infra/Dotenv.mjs} +0 -0
- /package/dist/browser/{Error.mjs → infra/Error.mjs} +0 -0
- /package/dist/browser/{runtime.mjs → infra/runtime.mjs} +0 -0
- /package/dist/node/{Debug.cjs → infra/Debug.cjs} +0 -0
- /package/dist/node/{Debug.mjs → infra/Debug.mjs} +0 -0
- /package/dist/node/{Dotenv.cjs → infra/Dotenv.cjs} +0 -0
- /package/dist/node/{Dotenv.mjs → infra/Dotenv.mjs} +0 -0
- /package/dist/node/{Error.cjs → infra/Error.cjs} +0 -0
- /package/dist/node/{Error.mjs → infra/Error.mjs} +0 -0
- /package/dist/node/{runtime.cjs → infra/runtime.cjs} +0 -0
- /package/dist/node/{runtime.mjs → infra/runtime.mjs} +0 -0
- /package/dist/{node/config.d.cts → types/config.d.mts} +0 -0
- /package/dist/{browser → types}/converters/Converters.d.mts +0 -0
- /package/dist/{browser → types}/core/EnvironmentMethods.d.mts +0 -0
- /package/dist/{browser → types}/sources/ManualEnvSource.d.mts +0 -0
- /package/dist/{browser → types}/sources/WorkerEnvSource.d.mts +0 -0
- /package/dist/{browser → types}/types/Conversion.d.mts +0 -0
- /package/dist/{browser → types}/types/Env.d.mts +0 -0
- /package/dist/{browser → types}/types/Options.d.mts +0 -0
- /package/dist/{browser → types}/types/Source.d.mts +0 -0
- /package/dist/workerd/{Debug.mjs → infra/Debug.mjs} +0 -0
- /package/dist/workerd/{Dotenv.mjs → infra/Dotenv.mjs} +0 -0
- /package/dist/workerd/{Error.mjs → infra/Error.mjs} +0 -0
- /package/dist/workerd/{runtime.mjs → infra/runtime.mjs} +0 -0
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import __tsdown_shims_path from 'node:path';
|
|
2
|
-
import __tsdown_shims_url from 'node:url';
|
|
3
|
-
import { ConditionalReturn } from "../types/Conversion.mjs";
|
|
4
|
-
import { EnvironmentMethods } from "./EnvironmentMethods.mjs";
|
|
5
|
-
import { EnvKeyInput, EnvapterService } from "../types/Env.mjs";
|
|
6
|
-
import { ValueConverter } from "../converters/ValueConverter.mjs";
|
|
7
|
-
import { TemplateResolver } from "../TemplateResolver.mjs";
|
|
8
|
-
|
|
9
|
-
//#region src/core/PrimitiveMethods.d.ts
|
|
10
|
-
/**
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
declare class PrimitiveMethods extends EnvironmentMethods implements EnvapterService {
|
|
14
|
-
private static readonly service;
|
|
15
|
-
protected static readonly templateResolver: TemplateResolver;
|
|
16
|
-
protected static readonly valueConverter: ValueConverter;
|
|
17
|
-
isStrict(): boolean;
|
|
18
|
-
private static _get;
|
|
19
|
-
/**
|
|
20
|
-
* Get a string environment variable with optional fallback.
|
|
21
|
-
* Supports template variable resolution using `${VAR}` syntax.
|
|
22
|
-
* Accepts a single key or an ordered array of keys (first match wins).
|
|
23
|
-
*/
|
|
24
|
-
static get<Default extends string | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<string, Default>;
|
|
25
|
-
/**
|
|
26
|
-
* @see {@link PrimitiveMethods.get}
|
|
27
|
-
*/
|
|
28
|
-
get<Default extends string | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<string, Default>;
|
|
29
|
-
/**
|
|
30
|
-
* Get a number environment variable with optional fallback.
|
|
31
|
-
* Automatically converts string values to numbers.
|
|
32
|
-
* Accepts a single key or an ordered array of keys (first match wins).
|
|
33
|
-
*/
|
|
34
|
-
static getNumber<Default extends number | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<number, Default>;
|
|
35
|
-
/**
|
|
36
|
-
* @see {@link PrimitiveMethods.getNumber}
|
|
37
|
-
*/
|
|
38
|
-
getNumber<Default extends number | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<number, Default>;
|
|
39
|
-
/**
|
|
40
|
-
* Get a boolean environment variable with optional fallback.
|
|
41
|
-
* Recognizes: `1`, `yes`, `true`, `on` as **true**; `0`, `no`, `false`, `off` as **false** (case-insensitive).
|
|
42
|
-
* Accepts a single key or an ordered array of keys (first match wins).
|
|
43
|
-
*/
|
|
44
|
-
static getBoolean<Default extends boolean | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<boolean, Default>;
|
|
45
|
-
/**
|
|
46
|
-
* @see {@link PrimitiveMethods.getBoolean}
|
|
47
|
-
*/
|
|
48
|
-
getBoolean<Default extends boolean | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<boolean, Default>;
|
|
49
|
-
/**
|
|
50
|
-
* Get a bigint environment variable with optional fallback.
|
|
51
|
-
* Automatically converts string values to bigint.
|
|
52
|
-
* Accepts a single key or an ordered array of keys (first match wins).
|
|
53
|
-
*/
|
|
54
|
-
static getBigInt<Default extends bigint | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<bigint, Default>;
|
|
55
|
-
/**
|
|
56
|
-
* @see {@link PrimitiveMethods.getBigInt}
|
|
57
|
-
*/
|
|
58
|
-
getBigInt<Default extends bigint | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<bigint, Default>;
|
|
59
|
-
/**
|
|
60
|
-
* Get a symbol environment variable with optional fallback.
|
|
61
|
-
* Creates a symbol from the string value.
|
|
62
|
-
* Accepts a single key or an ordered array of keys (first match wins).
|
|
63
|
-
*/
|
|
64
|
-
static getSymbol<Default extends symbol | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<symbol, Default>;
|
|
65
|
-
/**
|
|
66
|
-
* @see {@link PrimitiveMethods.getSymbol}
|
|
67
|
-
*/
|
|
68
|
-
getSymbol<Default extends symbol | undefined = undefined>(key: EnvKeyInput, def?: Default): ConditionalReturn<symbol, Default>;
|
|
69
|
-
}
|
|
70
|
-
//#endregion
|
|
71
|
-
export { PrimitiveMethods };
|
|
72
|
-
//# sourceMappingURL=PrimitiveMethods.d.mts.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"node:path";import"node:url";import.meta.url;const e=require("../Error.cjs"),t=require("../Validators.cjs"),n=require("./createPropertyDecorator.cjs");function r(r,i){let a,o,s,c=!1,l=!1;if(i!==void 0){if(typeof i!=`object`||!i||!(`fallback`in i||`converter`in i||`required`in i||`schema`in i))throw new e.EnvaptError(302,"The positional `@Envapt(key, fallback, converter)` form was removed in v6. Pass an options object instead, like `@Envapt(key, { converter, fallback })`, or use one of the sugar decorators.");let n=i;if(a=n.fallback,o=n.converter,c=`fallback`in n,l=n.required===!0,l&&c&&a!==void 0)throw new e.EnvaptError(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.Validator.isStandardSchema(n.schema))throw new e.EnvaptError(302,"`schema` must be a Standard Schema v1 object (zod, valibot, arktype, or any `~standard`-conformant value).");if(o!==void 0)throw new e.EnvaptError(302,"`schema` and `converter` are mutually exclusive on @Envapt options. Drop one as they both turn a raw env string into a typed value.");s=n.schema}}return n.createPropertyDecorator(r,{fallback:a,converter:o,hasFallback:c,required:l,schema:s})}exports.Envapt=r;
|
|
2
|
-
//# sourceMappingURL=Envapt.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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 InferConverterFallbackType,\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 * 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 * 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 * static readonly apiKey: string;\n * }\n * ```\n */\nexport function Envapt(key: EnvKeyInput, options: { required: true }): PropertyDecorator;\n\n/**\n * No-fallback form. The property resolves from env or `null`.\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 * 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>(key: EnvKeyInput, options?: unknown): PropertyDecorator {\n let fallback: TFallback | undefined;\n let actualConverter: EnvaptConverter<TFallback> | undefined;\n let actualSchema: StandardSchemaV1 | undefined;\n let hasFallback = false;\n let required = false;\n\n if (options !== undefined) {\n if (\n typeof options !== 'object' ||\n options === null ||\n !('fallback' in options || 'converter' in options || 'required' in options || 'schema' in options)\n ) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n 'The positional `@Envapt(key, fallback, converter)` form was removed in v6. Pass an options object instead, like `@Envapt(key, { converter, fallback })`, or use one of the sugar decorators.'\n );\n }\n\n const opts = options as {\n fallback?: TFallback;\n converter?: EnvaptConverter<TFallback>;\n required?: boolean;\n schema?: unknown;\n };\n fallback = opts.fallback;\n actualConverter = opts.converter;\n hasFallback = 'fallback' in opts;\n required = opts.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 opts && opts.schema !== undefined) {\n if (!Validator.isStandardSchema(opts.schema)) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n '`schema` must be a Standard Schema v1 object (zod, valibot, arktype, or any `~standard`-conformant value).'\n );\n }\n if (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 = opts.schema;\n }\n }\n\n return createPropertyDecorator(key, {\n fallback,\n converter: actualConverter,\n hasFallback,\n required,\n schema: actualSchema\n });\n}\n"],"mappings":"6JAwNA,SAAgB,EAA4B,EAAkB,EAAsC,CAChG,IAAI,EACA,EACA,EACA,EAAc,GACd,EAAW,GAEf,GAAI,IAAY,IAAA,GAAW,CACvB,GACI,OAAO,GAAY,WACnB,GACA,EAAE,aAAc,GAAW,cAAe,GAAW,aAAc,GAAW,WAAY,GAE1F,MAAM,IAAIA,EAAAA,YAAAA,IAEN,8LACJ,EAGJ,IAAM,EAAO,EAWb,GALA,EAAW,EAAK,SAChB,EAAkB,EAAK,UACvB,EAAc,aAAc,EAC5B,EAAW,EAAK,WAAa,GAEzB,GAAY,GAAe,IAAa,IAAA,GACxC,MAAM,IAAIA,EAAAA,YAAAA,IAEN,uIACJ,EAGJ,GAAI,WAAY,GAAQ,EAAK,SAAW,IAAA,GAAW,CAC/C,GAAI,CAACC,EAAAA,UAAU,iBAAiB,EAAK,MAAM,EACvC,MAAM,IAAID,EAAAA,YAAAA,IAEN,4GACJ,EAEJ,GAAI,IAAoB,IAAA,GACpB,MAAM,IAAIA,EAAAA,YAAAA,IAEN,qIACJ,EAEJ,EAAe,EAAK,MACxB,CACJ,CAEA,OAAOE,EAAAA,wBAAwB,EAAK,CAChC,WACA,UAAW,EACX,cACA,WACA,OAAQ,CACZ,CAAC,CACL"}
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { ArrayOf } from "../converters/Converters.cjs";
|
|
2
|
-
import { BuiltInConverter, ConverterFunction, InferConverterFallbackType, InferPrimitiveReturnType, PrimitiveConstructor } from "../types/Conversion.cjs";
|
|
3
|
-
import { InferSchemaOutput, StandardSchemaV1 } from "../StandardSchema.cjs";
|
|
4
|
-
import { SchemaConstraint } from "../types/Schema.cjs";
|
|
5
|
-
import { EnvKeyInput } from "../types/Env.cjs";
|
|
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
|
-
* 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
|
-
* 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
|
-
* static readonly apiKey: string;
|
|
169
|
-
* }
|
|
170
|
-
* ```
|
|
171
|
-
*/
|
|
172
|
-
declare function Envapt(key: EnvKeyInput, options: {
|
|
173
|
-
required: true;
|
|
174
|
-
}): PropertyDecorator;
|
|
175
|
-
/**
|
|
176
|
-
* No-fallback form. The property resolves from env or `null`.
|
|
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
|
-
* Usage 6: Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous
|
|
192
|
-
* schemas only; a Promise-returning `validate` triggers a runtime
|
|
193
|
-
* `InvalidUserDefinedConfig` throw. Combining `schema` with `converter` fails to match any
|
|
194
|
-
* overload at compile time; the runtime Validator catches dynamic objects that bypass the
|
|
195
|
-
* types.
|
|
196
|
-
* @public
|
|
197
|
-
*/
|
|
198
|
-
declare function Envapt<Schema extends StandardSchemaV1>(key: EnvKeyInput, options: {
|
|
199
|
-
schema: SchemaConstraint<Schema>;
|
|
200
|
-
fallback?: InferSchemaOutput<Schema>;
|
|
201
|
-
required?: false;
|
|
202
|
-
} | {
|
|
203
|
-
schema: SchemaConstraint<Schema>;
|
|
204
|
-
required: true;
|
|
205
|
-
}): PropertyDecorator;
|
|
206
|
-
//#endregion
|
|
207
|
-
export { Envapt };
|
|
208
|
-
//# sourceMappingURL=Envapt.d.cts.map
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import __tsdown_shims_path from 'node:path';
|
|
2
|
-
import __tsdown_shims_url from 'node:url';
|
|
3
|
-
import { ArrayOf } from "../converters/Converters.mjs";
|
|
4
|
-
import { BuiltInConverter, ConverterFunction, InferConverterFallbackType, InferPrimitiveReturnType, PrimitiveConstructor } from "../types/Conversion.mjs";
|
|
5
|
-
import { InferSchemaOutput, StandardSchemaV1 } from "../StandardSchema.mjs";
|
|
6
|
-
import { SchemaConstraint } from "../types/Schema.mjs";
|
|
7
|
-
import { EnvKeyInput } from "../types/Env.mjs";
|
|
8
|
-
|
|
9
|
-
//#region src/decorators/Envapt.d.ts
|
|
10
|
-
/**
|
|
11
|
-
* Usage 1: Either a custom converter function + fallback (both required), OR a fallback
|
|
12
|
-
* only (no converter).
|
|
13
|
-
*
|
|
14
|
-
* @param key - Environment variable name(s) to load
|
|
15
|
-
* @param options - Configuration options
|
|
16
|
-
* @public
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* class Config extends Envapter {
|
|
20
|
-
* // Custom converter that validates a non-empty API key
|
|
21
|
-
* \@Envapt('API_KEY', {
|
|
22
|
-
* fallback: 'default-key',
|
|
23
|
-
* converter(raw, _fallback) {
|
|
24
|
-
* if (!raw || raw.trim() === '') throw new Error('API_KEY required');
|
|
25
|
-
* return raw.trim();
|
|
26
|
-
* }
|
|
27
|
-
* })
|
|
28
|
-
* static readonly apiKey: string;
|
|
29
|
-
*
|
|
30
|
-
* // Fallback-only (no converter): string fallback
|
|
31
|
-
* \@Envapt('LOG_FILE', { fallback: '/var/log/app.log' })
|
|
32
|
-
* static readonly logFile: string;
|
|
33
|
-
*
|
|
34
|
-
* // Fallback-only: arbitrary object fallback
|
|
35
|
-
* \@Envapt('RETRY_POLICY', { fallback: { retries: 3, backoff: 'exponential' } })
|
|
36
|
-
* static readonly retryPolicy: unknown;
|
|
37
|
-
* }
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
declare function Envapt<TFallback>(key: EnvKeyInput, options: {
|
|
41
|
-
converter: (raw: string | undefined, fallback: TFallback) => TFallback;
|
|
42
|
-
fallback: TFallback;
|
|
43
|
-
} | {
|
|
44
|
-
fallback: TFallback;
|
|
45
|
-
converter?: undefined;
|
|
46
|
-
}): PropertyDecorator;
|
|
47
|
-
/**
|
|
48
|
-
* Usage 2: Custom converter function without fallback. Either omit `required` (returns the
|
|
49
|
-
* converter's output, possibly `undefined`) or pass `required: true` to throw `MissingEnvValue`
|
|
50
|
-
* on missing/empty values.
|
|
51
|
-
*
|
|
52
|
-
* @param key - Environment variable name(s) to load
|
|
53
|
-
* @param options - Configuration options with custom converter only, with optional `required: true`
|
|
54
|
-
* @public
|
|
55
|
-
* @example
|
|
56
|
-
* ```ts
|
|
57
|
-
* class Config extends Envapter {
|
|
58
|
-
* \@Envapt('FEATURE_FLAGS', { converter(raw) {
|
|
59
|
-
* return raw ? raw.split('|').map(s => s.trim()) : [];
|
|
60
|
-
* } })
|
|
61
|
-
* static readonly featureFlags: string[];
|
|
62
|
-
*
|
|
63
|
-
* \@Envapt('JWT_SECRET', {
|
|
64
|
-
* converter: (raw) => Buffer.from(raw ?? '', 'base64'),
|
|
65
|
-
* required: true
|
|
66
|
-
* })
|
|
67
|
-
* static readonly jwtSecret: Buffer;
|
|
68
|
-
* }
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
declare function Envapt<TReturnType>(key: EnvKeyInput, options: {
|
|
72
|
-
converter: ConverterFunction<TReturnType>;
|
|
73
|
-
required?: false;
|
|
74
|
-
} | {
|
|
75
|
-
converter: ConverterFunction<TReturnType>;
|
|
76
|
-
required: true;
|
|
77
|
-
}): PropertyDecorator;
|
|
78
|
-
/**
|
|
79
|
-
* Usage 3: Built-in or array converter with optional fallback OR `required: true`.
|
|
80
|
-
*
|
|
81
|
-
* `InferConverterFallbackType` handles asymmetric cases: scalar `Converters.Time` accepts
|
|
82
|
-
* `TimeFallback`, and `ArrayOf<'time'>` accepts `TimeFallback[]`. Every other converter
|
|
83
|
-
* reduces to `InferConverterReturnType`. The two object-shape branches are mutually
|
|
84
|
-
* exclusive: either provide a `fallback`, or pass `required: true` to throw
|
|
85
|
-
* `MissingEnvValue` on missing/empty values.
|
|
86
|
-
*
|
|
87
|
-
* @param key - Environment variable name(s) to load
|
|
88
|
-
* @param options - Configuration options
|
|
89
|
-
* @public
|
|
90
|
-
* @example
|
|
91
|
-
* ```ts
|
|
92
|
-
* import { Converters } from 'envapt';
|
|
93
|
-
*
|
|
94
|
-
* class Config extends Envapter {
|
|
95
|
-
* // Use built-in Number converter with a numeric fallback
|
|
96
|
-
* \@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })
|
|
97
|
-
* static readonly port: number;
|
|
98
|
-
*
|
|
99
|
-
* // Url converter: the fallback is a URL instance, not a string
|
|
100
|
-
* \@Envapt('APP_URL', { converter: Converters.Url, fallback: new URL('http://localhost:3000') })
|
|
101
|
-
* static readonly url: URL;
|
|
102
|
-
*
|
|
103
|
-
* // Prefer CANARY_URL when present, otherwise fall back to APP_URL
|
|
104
|
-
* \@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })
|
|
105
|
-
* static readonly canaryUrl: URL | null;
|
|
106
|
-
*
|
|
107
|
-
* // `Converters.Time` accepts either a number (milliseconds) or a time-string fallback (`<number><unit>`).
|
|
108
|
-
* \@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })
|
|
109
|
-
* static readonly requestTimeout: number;
|
|
110
|
-
*
|
|
111
|
-
* // Array converter: comma-separated list of origins -> string[]
|
|
112
|
-
* \@Envapt('ALLOWED_ORIGINS', {
|
|
113
|
-
* converter: Converters.array({ of: Converters.String }),
|
|
114
|
-
* fallback: ['https://example.com']
|
|
115
|
-
* })
|
|
116
|
-
* static readonly allowedOrigins: string[];
|
|
117
|
-
*
|
|
118
|
-
* \@Envapt('DATABASE_URL', { converter: Converters.Url, required: true })
|
|
119
|
-
* static readonly databaseUrl: URL;
|
|
120
|
-
* }
|
|
121
|
-
* ```
|
|
122
|
-
*/
|
|
123
|
-
declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
|
|
124
|
-
converter: TConverter;
|
|
125
|
-
fallback?: InferConverterFallbackType<TConverter> | undefined;
|
|
126
|
-
required?: false;
|
|
127
|
-
} | {
|
|
128
|
-
converter: TConverter;
|
|
129
|
-
required: true;
|
|
130
|
-
}): PropertyDecorator;
|
|
131
|
-
/**
|
|
132
|
-
* Usage 4: Primitive constructor with optional fallback
|
|
133
|
-
*
|
|
134
|
-
* @param key - Environment variable name(s) to load
|
|
135
|
-
* @param options - Configuration options with primitive constructor
|
|
136
|
-
* @public
|
|
137
|
-
* @example
|
|
138
|
-
* ```ts
|
|
139
|
-
* // Use primitive constructors to coerce values
|
|
140
|
-
* class Config extends Envapter {
|
|
141
|
-
* \@Envapt('MAX_CONNECTIONS', { converter: Number, fallback: 100 })
|
|
142
|
-
* static readonly maxConnections: number;
|
|
143
|
-
*
|
|
144
|
-
* \@Envapt('FEATURE_ENABLED', { converter: Boolean, fallback: false })
|
|
145
|
-
* static readonly featureEnabled: boolean;
|
|
146
|
-
* }
|
|
147
|
-
* ```
|
|
148
|
-
*/
|
|
149
|
-
declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
|
|
150
|
-
converter: TConstructor;
|
|
151
|
-
fallback?: InferPrimitiveReturnType<TConstructor>;
|
|
152
|
-
required?: false;
|
|
153
|
-
} | {
|
|
154
|
-
converter: TConstructor;
|
|
155
|
-
required: true;
|
|
156
|
-
}): PropertyDecorator;
|
|
157
|
-
/**
|
|
158
|
-
* Usage 5: Required, no converter (raw string). Throws `MissingEnvValue` on first access if
|
|
159
|
-
* the env value is missing or empty (post-trim). Independent of global `Envapter.strict`.
|
|
160
|
-
* Combining `required: true` with `fallback` fails to match any overload at compile time;
|
|
161
|
-
* the runtime Validator catches dynamic objects that bypass the types.
|
|
162
|
-
*
|
|
163
|
-
* @param key - Environment variable name(s) to load
|
|
164
|
-
* @param options - `{ required: true }`
|
|
165
|
-
* @public
|
|
166
|
-
* @example
|
|
167
|
-
* ```ts
|
|
168
|
-
* class Config extends Envapter {
|
|
169
|
-
* \@Envapt('API_KEY', { required: true })
|
|
170
|
-
* static readonly apiKey: string;
|
|
171
|
-
* }
|
|
172
|
-
* ```
|
|
173
|
-
*/
|
|
174
|
-
declare function Envapt(key: EnvKeyInput, options: {
|
|
175
|
-
required: true;
|
|
176
|
-
}): PropertyDecorator;
|
|
177
|
-
/**
|
|
178
|
-
* No-fallback form. The property resolves from env or `null`.
|
|
179
|
-
*
|
|
180
|
-
* @param key - Environment variable name(s) to load
|
|
181
|
-
* @public
|
|
182
|
-
* @example
|
|
183
|
-
* ```ts
|
|
184
|
-
* // Classic API: no fallback — property will resolve from env or be null
|
|
185
|
-
* class Config extends Envapter {
|
|
186
|
-
* \@Envapt('SIMPLE_VALUE')
|
|
187
|
-
* static readonly simple?: string | null;
|
|
188
|
-
* }
|
|
189
|
-
* ```
|
|
190
|
-
*/
|
|
191
|
-
declare function Envapt<_TReturnType = string | null>(key: EnvKeyInput): PropertyDecorator;
|
|
192
|
-
/**
|
|
193
|
-
* Usage 6: Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous
|
|
194
|
-
* schemas only; a Promise-returning `validate` triggers a runtime
|
|
195
|
-
* `InvalidUserDefinedConfig` throw. Combining `schema` with `converter` fails to match any
|
|
196
|
-
* overload at compile time; the runtime Validator catches dynamic objects that bypass the
|
|
197
|
-
* types.
|
|
198
|
-
* @public
|
|
199
|
-
*/
|
|
200
|
-
declare function Envapt<Schema extends StandardSchemaV1>(key: EnvKeyInput, options: {
|
|
201
|
-
schema: SchemaConstraint<Schema>;
|
|
202
|
-
fallback?: InferSchemaOutput<Schema>;
|
|
203
|
-
required?: false;
|
|
204
|
-
} | {
|
|
205
|
-
schema: SchemaConstraint<Schema>;
|
|
206
|
-
required: true;
|
|
207
|
-
}): PropertyDecorator;
|
|
208
|
-
//#endregion
|
|
209
|
-
export { Envapt };
|
|
210
|
-
//# sourceMappingURL=Envapt.d.mts.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"node:path";import"node:url";import.meta.url;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){let a,o,s,c=!1,l=!1;if(i!==void 0){if(typeof i!=`object`||!i||!(`fallback`in i||`converter`in i||`required`in i||`schema`in i))throw new e(302,"The positional `@Envapt(key, fallback, converter)` form was removed in v6. Pass an options object instead, like `@Envapt(key, { converter, fallback })`, or use one of the sugar decorators.");let n=i;if(a=n.fallback,o=n.converter,c=`fallback`in n,l=n.required===!0,l&&c&&a!==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(o!==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.");s=n.schema}}return n(r,{fallback:a,converter:o,hasFallback:c,required:l,schema:s})}export{r as Envapt};
|
|
2
|
-
//# sourceMappingURL=Envapt.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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 InferConverterFallbackType,\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 * 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 * 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 * static readonly apiKey: string;\n * }\n * ```\n */\nexport function Envapt(key: EnvKeyInput, options: { required: true }): PropertyDecorator;\n\n/**\n * No-fallback form. The property resolves from env or `null`.\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 * 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>(key: EnvKeyInput, options?: unknown): PropertyDecorator {\n let fallback: TFallback | undefined;\n let actualConverter: EnvaptConverter<TFallback> | undefined;\n let actualSchema: StandardSchemaV1 | undefined;\n let hasFallback = false;\n let required = false;\n\n if (options !== undefined) {\n if (\n typeof options !== 'object' ||\n options === null ||\n !('fallback' in options || 'converter' in options || 'required' in options || 'schema' in options)\n ) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n 'The positional `@Envapt(key, fallback, converter)` form was removed in v6. Pass an options object instead, like `@Envapt(key, { converter, fallback })`, or use one of the sugar decorators.'\n );\n }\n\n const opts = options as {\n fallback?: TFallback;\n converter?: EnvaptConverter<TFallback>;\n required?: boolean;\n schema?: unknown;\n };\n fallback = opts.fallback;\n actualConverter = opts.converter;\n hasFallback = 'fallback' in opts;\n required = opts.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 opts && opts.schema !== undefined) {\n if (!Validator.isStandardSchema(opts.schema)) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n '`schema` must be a Standard Schema v1 object (zod, valibot, arktype, or any `~standard`-conformant value).'\n );\n }\n if (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 = opts.schema;\n }\n }\n\n return createPropertyDecorator(key, {\n fallback,\n converter: actualConverter,\n hasFallback,\n required,\n schema: actualSchema\n });\n}\n"],"mappings":"oNAwNA,SAAgB,EAA4B,EAAkB,EAAsC,CAChG,IAAI,EACA,EACA,EACA,EAAc,GACd,EAAW,GAEf,GAAI,IAAY,IAAA,GAAW,CACvB,GACI,OAAO,GAAY,WACnB,GACA,EAAE,aAAc,GAAW,cAAe,GAAW,aAAc,GAAW,WAAY,GAE1F,MAAM,IAAI,EAAA,IAEN,8LACJ,EAGJ,IAAM,EAAO,EAWb,GALA,EAAW,EAAK,SAChB,EAAkB,EAAK,UACvB,EAAc,aAAc,EAC5B,EAAW,EAAK,WAAa,GAEzB,GAAY,GAAe,IAAa,IAAA,GACxC,MAAM,IAAI,EAAA,IAEN,uIACJ,EAGJ,GAAI,WAAY,GAAQ,EAAK,SAAW,IAAA,GAAW,CAC/C,GAAI,CAAC,EAAU,iBAAiB,EAAK,MAAM,EACvC,MAAM,IAAI,EAAA,IAEN,4GACJ,EAEJ,GAAI,IAAoB,IAAA,GACpB,MAAM,IAAI,EAAA,IAEN,qIACJ,EAEJ,EAAe,EAAK,MACxB,CACJ,CAEA,OAAO,EAAwB,EAAK,CAChC,WACA,UAAW,EACX,cACA,WACA,OAAQ,CACZ,CAAC,CACL"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"node:path";import"node:url";import.meta.url;const e=require("../converters/Converters.cjs"),t=require("./createPropertyDecorator.cjs");function n(e,n,r){return t.createPropertyDecorator(n,{converter:e,fallback:r,hasFallback:r!==void 0,required:!1,schema:void 0})}function r(t,r){return n(e.Converters.Boolean,t,r)}function i(t,r){return n(e.Converters.Number,t,r)}function a(t,r){return n(e.Converters.String,t,r)}function o(t,r){return n(e.Converters.Time,t,r)}function s(t,r){return n(e.Converters.Url,t,r)}exports.EnvBool=r,exports.EnvNum=i,exports.EnvStr=a,exports.EnvTime=o,exports.EnvUrl=s;
|
|
2
|
-
//# sourceMappingURL=SugarDecorators.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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":"8IAMA,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"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { TimeFallback } from "../types/Conversion.cjs";
|
|
2
|
-
import { EnvKeyInput } from "../types/Env.cjs";
|
|
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.cts.map
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import __tsdown_shims_path from 'node:path';
|
|
2
|
-
import __tsdown_shims_url from 'node:url';
|
|
3
|
-
import { TimeFallback } from "../types/Conversion.mjs";
|
|
4
|
-
import { EnvKeyInput } from "../types/Env.mjs";
|
|
5
|
-
|
|
6
|
-
//#region src/decorators/SugarDecorators.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* Shorthand for `@Envapt(key, { converter: Converters.Boolean, fallback })`.
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
declare function EnvBool(key: EnvKeyInput, fallback?: boolean): PropertyDecorator;
|
|
12
|
-
/**
|
|
13
|
-
* Shorthand for `@Envapt(key, { converter: Converters.Number, fallback })`.
|
|
14
|
-
* @public
|
|
15
|
-
*/
|
|
16
|
-
declare function EnvNum(key: EnvKeyInput, fallback?: number): PropertyDecorator;
|
|
17
|
-
/**
|
|
18
|
-
* Shorthand for `@Envapt(key, { converter: Converters.String, fallback })`.
|
|
19
|
-
* @public
|
|
20
|
-
*/
|
|
21
|
-
declare function EnvStr(key: EnvKeyInput, fallback?: string): PropertyDecorator;
|
|
22
|
-
/**
|
|
23
|
-
* Shorthand for `@Envapt(key, { converter: Converters.Time, fallback })`. The fallback is a
|
|
24
|
-
* millisecond number or a time string (`'15m'`); the resolved value is always milliseconds.
|
|
25
|
-
* @public
|
|
26
|
-
*/
|
|
27
|
-
declare function EnvTime(key: EnvKeyInput, fallback?: TimeFallback): PropertyDecorator;
|
|
28
|
-
/**
|
|
29
|
-
* Shorthand for `@Envapt(key, { converter: Converters.Url, fallback })`. The fallback is a `URL`
|
|
30
|
-
* instance, not a URL string.
|
|
31
|
-
* @public
|
|
32
|
-
*/
|
|
33
|
-
declare function EnvUrl(key: EnvKeyInput, fallback?: URL): PropertyDecorator;
|
|
34
|
-
//#endregion
|
|
35
|
-
export { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl };
|
|
36
|
-
//# sourceMappingURL=SugarDecorators.d.mts.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"node:path";import"node:url";import.meta.url;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
|
|
@@ -1 +0,0 @@
|
|
|
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":"qLAMA,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"}
|