envapt 6.0.2 → 7.0.0-next.0
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 +19 -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.d.mts +1 -1
- package/dist/browser/converters/ValueConverter.mjs +1 -1
- package/dist/browser/converters/ValueConverter.mjs.map +1 -1
- package/dist/browser/core/AdvancedMethods.d.mts +1 -1
- package/dist/browser/core/AdvancedMethods.mjs +1 -1
- package/dist/browser/core/AdvancedMethods.mjs.map +1 -1
- package/dist/browser/core/EnvapterBase.d.mts +2 -2
- 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.d.mts +1 -1
- package/dist/browser/core/PrimitiveMethods.mjs +1 -1
- package/dist/browser/core/PrimitiveMethods.mjs.map +1 -1
- package/dist/browser/decorators/{Envapt.d.mts → legacy/Envapt.d.mts} +59 -49
- 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.d.mts +40 -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.d.mts +218 -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.d.mts +40 -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/{Envapter.d.mts → engine/Envapter.d.mts} +3 -3
- package/dist/browser/engine/Envapter.mjs +2 -0
- package/dist/browser/engine/Envapter.mjs.map +1 -0
- package/dist/browser/{TemplateResolver.d.mts → engine/TemplateResolver.d.mts} +2 -2
- 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.d.mts +9 -8
- package/dist/browser/index.mjs +1 -1
- package/dist/browser/index.mjs.map +1 -1
- package/dist/browser/{Debug.d.mts → infra/Debug.d.mts} +1 -1
- package/dist/browser/infra/Debug.mjs.map +1 -0
- package/dist/{workerd → browser/infra}/Dotenv.d.mts +1 -1
- package/dist/browser/infra/Dotenv.mjs.map +1 -0
- package/dist/browser/{Error.d.mts → infra/Error.d.mts} +1 -1
- package/dist/browser/infra/Error.mjs.map +1 -0
- package/dist/browser/{StandardSchema.d.mts → infra/StandardSchema.d.mts} +1 -1
- package/dist/browser/infra/runtime.mjs.map +1 -0
- package/dist/browser/legacy.d.mts +4 -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/browser/types/Decorator.d.mts +26 -0
- package/dist/browser/types/Schema.d.mts +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.d.cts +1 -1
- package/dist/node/converters/ValueConverter.d.mts +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.d.cts +1 -1
- package/dist/node/core/AdvancedMethods.d.mts +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.d.cts +2 -2
- package/dist/node/core/EnvapterBase.d.mts +2 -2
- 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.d.cts +1 -1
- package/dist/node/core/EnvironmentMethods.d.mts +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.d.cts +1 -1
- package/dist/node/core/PrimitiveMethods.d.mts +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/{Envapt.d.cts → legacy/Envapt.d.cts} +59 -49
- package/dist/node/decorators/{Envapt.d.mts → legacy/Envapt.d.mts} +59 -49
- 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.d.cts +40 -0
- package/dist/node/decorators/legacy/SugarDecorators.d.mts +42 -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.d.cts +218 -0
- package/dist/node/decorators/modern/Envapt.d.mts +220 -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.d.cts +40 -0
- package/dist/node/decorators/modern/SugarDecorators.d.mts +42 -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/{Envapter.d.cts → engine/Envapter.d.cts} +3 -3
- package/dist/node/{Envapter.d.mts → engine/Envapter.d.mts} +3 -3
- 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/{NodeEnvapter.d.cts → engine/NodeEnvapter.d.cts} +3 -3
- package/dist/node/{NodeEnvapter.d.mts → engine/NodeEnvapter.d.mts} +3 -3
- 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/{TemplateResolver.d.cts → engine/TemplateResolver.d.cts} +2 -2
- package/dist/node/{TemplateResolver.d.mts → engine/TemplateResolver.d.mts} +2 -2
- 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.d.cts +9 -8
- package/dist/node/index.d.mts +9 -8
- package/dist/node/index.mjs +1 -1
- package/dist/node/infra/Debug.cjs.map +1 -0
- package/dist/node/{Debug.d.cts → infra/Debug.d.cts} +1 -1
- package/dist/node/{Debug.d.mts → infra/Debug.d.mts} +1 -1
- package/dist/node/infra/Debug.mjs.map +1 -0
- package/dist/node/infra/Dotenv.cjs.map +1 -0
- package/dist/node/{Dotenv.d.cts → infra/Dotenv.d.cts} +1 -1
- package/dist/node/{Dotenv.d.mts → infra/Dotenv.d.mts} +1 -1
- package/dist/node/infra/Dotenv.mjs.map +1 -0
- package/dist/node/infra/Error.cjs.map +1 -0
- package/dist/node/{Error.d.cts → infra/Error.d.cts} +1 -1
- package/dist/node/{Error.d.mts → infra/Error.d.mts} +1 -1
- package/dist/node/infra/Error.mjs.map +1 -0
- package/dist/node/{StandardSchema.d.cts → infra/StandardSchema.d.cts} +1 -1
- package/dist/node/{StandardSchema.d.mts → infra/StandardSchema.d.mts} +1 -1
- 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.d.cts +4 -0
- package/dist/node/legacy.d.mts +6 -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/node/types/Decorator.d.cts +26 -0
- package/dist/node/types/Decorator.d.mts +28 -0
- package/dist/node/types/Schema.d.cts +1 -1
- package/dist/node/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.d.mts +1 -1
- package/dist/workerd/converters/ValueConverter.mjs +1 -1
- package/dist/workerd/converters/ValueConverter.mjs.map +1 -1
- package/dist/workerd/core/AdvancedMethods.d.mts +1 -1
- package/dist/workerd/core/AdvancedMethods.mjs +1 -1
- package/dist/workerd/core/AdvancedMethods.mjs.map +1 -1
- package/dist/workerd/core/EnvapterBase.d.mts +2 -2
- package/dist/workerd/core/EnvapterBase.mjs +1 -1
- package/dist/workerd/core/EnvapterBase.mjs.map +1 -1
- package/dist/workerd/core/EnvironmentMethods.d.mts +1 -1
- package/dist/workerd/core/EnvironmentMethods.mjs +1 -1
- package/dist/workerd/core/EnvironmentMethods.mjs.map +1 -1
- package/dist/workerd/core/PrimitiveMethods.d.mts +1 -1
- package/dist/workerd/core/PrimitiveMethods.mjs +1 -1
- package/dist/workerd/core/PrimitiveMethods.mjs.map +1 -1
- package/dist/workerd/decorators/{Envapt.d.mts → legacy/Envapt.d.mts} +59 -49
- 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.d.mts +40 -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.d.mts +218 -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.d.mts +40 -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/{Envapter.d.mts → engine/Envapter.d.mts} +3 -3
- package/dist/workerd/engine/Envapter.mjs +2 -0
- package/dist/workerd/engine/Envapter.mjs.map +1 -0
- package/dist/workerd/{TemplateResolver.d.mts → engine/TemplateResolver.d.mts} +2 -2
- 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.d.mts +9 -8
- package/dist/workerd/index.mjs +1 -1
- package/dist/workerd/index.mjs.map +1 -1
- package/dist/workerd/{Debug.d.mts → infra/Debug.d.mts} +1 -1
- package/dist/workerd/infra/Debug.mjs.map +1 -0
- package/dist/{browser → workerd/infra}/Dotenv.d.mts +1 -1
- package/dist/workerd/infra/Dotenv.mjs.map +1 -0
- package/dist/workerd/{Error.d.mts → infra/Error.d.mts} +1 -1
- package/dist/workerd/infra/Error.mjs.map +1 -0
- package/dist/workerd/{StandardSchema.d.mts → infra/StandardSchema.d.mts} +1 -1
- package/dist/workerd/infra/runtime.mjs.map +1 -0
- package/dist/workerd/legacy.d.mts +4 -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/dist/workerd/types/Decorator.d.mts +26 -0
- package/dist/workerd/types/Schema.d.mts +1 -1
- package/package.json +34 -3
- package/dist/browser/Debug.mjs.map +0 -1
- 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/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/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.mjs.map +0 -1
- package/dist/node/Dotenv.cjs.map +0 -1
- 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.mjs +0 -2
- package/dist/node/Envapter.mjs.map +0 -1
- package/dist/node/Error.cjs.map +0 -1
- 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.mjs +0 -2
- package/dist/node/NodeEnvapter.mjs.map +0 -1
- package/dist/node/TemplateResolver.cjs +0 -2
- package/dist/node/TemplateResolver.cjs.map +0 -1
- 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/decorators/Envapt.cjs +0 -2
- package/dist/node/decorators/Envapt.cjs.map +0 -1
- 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/runtime.cjs.map +0 -1
- package/dist/node/runtime.mjs.map +0 -1
- package/dist/workerd/Debug.mjs.map +0 -1
- package/dist/workerd/Dotenv.mjs.map +0 -1
- package/dist/workerd/Envapter.mjs +0 -2
- package/dist/workerd/Envapter.mjs.map +0 -1
- package/dist/workerd/Error.mjs.map +0 -1
- 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/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/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/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,13 +1,13 @@
|
|
|
1
|
-
import { ArrayOf } from "
|
|
2
|
-
import { BuiltInConverter, ConverterFunction, InferConverterFallbackType, InferPrimitiveReturnType, PrimitiveConstructor } from "
|
|
3
|
-
import { InferSchemaOutput, StandardSchemaV1 } from "
|
|
4
|
-
import { SchemaConstraint } from "
|
|
5
|
-
import { EnvKeyInput } from "
|
|
1
|
+
import { ArrayOf } from "../../converters/Converters.mjs";
|
|
2
|
+
import { BuiltInConverter, ConverterFunction, InferConverterFallbackType, InferConverterReturnType, InferPrimitiveReturnType, PrimitiveConstructor } from "../../types/Conversion.mjs";
|
|
3
|
+
import { InferSchemaOutput, StandardSchemaV1 } from "../../infra/StandardSchema.mjs";
|
|
4
|
+
import { SchemaConstraint } from "../../types/Schema.mjs";
|
|
5
|
+
import { EnvKeyInput } from "../../types/Env.mjs";
|
|
6
|
+
import { EnvaptFieldDecorator } from "../../types/Decorator.mjs";
|
|
6
7
|
|
|
7
|
-
//#region src/decorators/Envapt.d.ts
|
|
8
|
+
//#region src/decorators/legacy/Envapt.d.ts
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
-
* only (no converter).
|
|
10
|
+
* A custom converter function with a fallback (both required), or a fallback only.
|
|
11
11
|
*
|
|
12
12
|
* @param key - Environment variable name(s) to load
|
|
13
13
|
* @param options - Configuration options
|
|
@@ -15,7 +15,6 @@ import { EnvKeyInput } from "../types/Env.mjs";
|
|
|
15
15
|
* @example
|
|
16
16
|
* ```ts
|
|
17
17
|
* class Config extends Envapter {
|
|
18
|
-
* // Custom converter that validates a non-empty API key
|
|
19
18
|
* \@Envapt('API_KEY', {
|
|
20
19
|
* fallback: 'default-key',
|
|
21
20
|
* converter(raw, _fallback) {
|
|
@@ -25,30 +24,32 @@ import { EnvKeyInput } from "../types/Env.mjs";
|
|
|
25
24
|
* })
|
|
26
25
|
* static readonly apiKey: string;
|
|
27
26
|
*
|
|
28
|
-
* // Fallback-only (no converter): string fallback
|
|
29
27
|
* \@Envapt('LOG_FILE', { fallback: '/var/log/app.log' })
|
|
30
28
|
* static readonly logFile: string;
|
|
31
29
|
*
|
|
32
|
-
* // Fallback-only: arbitrary object fallback
|
|
33
30
|
* \@Envapt('RETRY_POLICY', { fallback: { retries: 3, backoff: 'exponential' } })
|
|
34
31
|
* static readonly retryPolicy: unknown;
|
|
35
32
|
* }
|
|
36
33
|
* ```
|
|
37
34
|
*/
|
|
35
|
+
declare function Envapt(key: EnvKeyInput, options: {
|
|
36
|
+
fallback: undefined;
|
|
37
|
+
converter?: undefined;
|
|
38
|
+
}): EnvaptFieldDecorator<string | undefined>;
|
|
38
39
|
declare function Envapt<TFallback>(key: EnvKeyInput, options: {
|
|
39
40
|
converter: (raw: string | undefined, fallback: TFallback) => TFallback;
|
|
40
41
|
fallback: TFallback;
|
|
41
42
|
} | {
|
|
42
43
|
fallback: TFallback;
|
|
43
44
|
converter?: undefined;
|
|
44
|
-
}):
|
|
45
|
+
}): EnvaptFieldDecorator<TFallback>;
|
|
45
46
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
47
|
+
* A custom converter function without a fallback. Omit `required` to return the converter's
|
|
48
|
+
* output (possibly `undefined`), or pass `required: true` to throw `MissingEnvValue` on
|
|
49
|
+
* missing or empty values.
|
|
49
50
|
*
|
|
50
51
|
* @param key - Environment variable name(s) to load
|
|
51
|
-
* @param options - Configuration options
|
|
52
|
+
* @param options - Configuration options
|
|
52
53
|
* @public
|
|
53
54
|
* @example
|
|
54
55
|
* ```ts
|
|
@@ -72,15 +73,11 @@ declare function Envapt<TReturnType>(key: EnvKeyInput, options: {
|
|
|
72
73
|
} | {
|
|
73
74
|
converter: ConverterFunction<TReturnType>;
|
|
74
75
|
required: true;
|
|
75
|
-
}):
|
|
76
|
+
}): EnvaptFieldDecorator<TReturnType>;
|
|
76
77
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* `
|
|
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.
|
|
78
|
+
* A built-in or array converter with a fallback, or `required: true`. The fallback type tracks
|
|
79
|
+
* the converter, so `Converters.Time` takes a number or time-string and `Converters.Url` takes
|
|
80
|
+
* a `URL` instance.
|
|
84
81
|
*
|
|
85
82
|
* @param key - Environment variable name(s) to load
|
|
86
83
|
* @param options - Configuration options
|
|
@@ -90,23 +87,21 @@ declare function Envapt<TReturnType>(key: EnvKeyInput, options: {
|
|
|
90
87
|
* import { Converters } from 'envapt';
|
|
91
88
|
*
|
|
92
89
|
* class Config extends Envapter {
|
|
93
|
-
* // Use built-in Number converter with a numeric fallback
|
|
94
90
|
* \@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })
|
|
95
91
|
* static readonly port: number;
|
|
96
92
|
*
|
|
97
|
-
* // Url
|
|
93
|
+
* // the Url fallback is a URL instance, not a string
|
|
98
94
|
* \@Envapt('APP_URL', { converter: Converters.Url, fallback: new URL('http://localhost:3000') })
|
|
99
95
|
* static readonly url: URL;
|
|
100
96
|
*
|
|
101
|
-
* //
|
|
97
|
+
* // prefers CANARY_URL when present, otherwise APP_URL
|
|
102
98
|
* \@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })
|
|
103
99
|
* static readonly canaryUrl: URL | null;
|
|
104
100
|
*
|
|
105
|
-
* //
|
|
101
|
+
* // Time takes a number (milliseconds) or a time-string fallback (`<number><unit>`)
|
|
106
102
|
* \@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })
|
|
107
103
|
* static readonly requestTimeout: number;
|
|
108
104
|
*
|
|
109
|
-
* // Array converter: comma-separated list of origins -> string[]
|
|
110
105
|
* \@Envapt('ALLOWED_ORIGINS', {
|
|
111
106
|
* converter: Converters.array({ of: Converters.String }),
|
|
112
107
|
* fallback: ['https://example.com']
|
|
@@ -120,21 +115,29 @@ declare function Envapt<TReturnType>(key: EnvKeyInput, options: {
|
|
|
120
115
|
*/
|
|
121
116
|
declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
|
|
122
117
|
converter: TConverter;
|
|
123
|
-
fallback
|
|
118
|
+
fallback: InferConverterFallbackType<TConverter>;
|
|
124
119
|
required?: false;
|
|
125
120
|
} | {
|
|
126
121
|
converter: TConverter;
|
|
127
122
|
required: true;
|
|
128
|
-
}):
|
|
123
|
+
}): EnvaptFieldDecorator<InferConverterReturnType<TConverter>>;
|
|
124
|
+
declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
|
|
125
|
+
converter: TConverter;
|
|
126
|
+
fallback: undefined;
|
|
127
|
+
required?: false;
|
|
128
|
+
}): EnvaptFieldDecorator<InferConverterReturnType<TConverter> | undefined>;
|
|
129
|
+
declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
|
|
130
|
+
converter: TConverter;
|
|
131
|
+
required?: false;
|
|
132
|
+
}): EnvaptFieldDecorator<InferConverterReturnType<TConverter> | null>;
|
|
129
133
|
/**
|
|
130
|
-
*
|
|
134
|
+
* A primitive constructor (`Number`, `Boolean`) with an optional fallback.
|
|
131
135
|
*
|
|
132
136
|
* @param key - Environment variable name(s) to load
|
|
133
|
-
* @param options - Configuration options
|
|
137
|
+
* @param options - Configuration options
|
|
134
138
|
* @public
|
|
135
139
|
* @example
|
|
136
140
|
* ```ts
|
|
137
|
-
* // Use primitive constructors to coerce values
|
|
138
141
|
* class Config extends Envapter {
|
|
139
142
|
* \@Envapt('MAX_CONNECTIONS', { converter: Number, fallback: 100 })
|
|
140
143
|
* static readonly maxConnections: number;
|
|
@@ -146,17 +149,26 @@ declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvK
|
|
|
146
149
|
*/
|
|
147
150
|
declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
|
|
148
151
|
converter: TConstructor;
|
|
149
|
-
fallback
|
|
152
|
+
fallback: InferPrimitiveReturnType<TConstructor>;
|
|
150
153
|
required?: false;
|
|
151
154
|
} | {
|
|
152
155
|
converter: TConstructor;
|
|
153
156
|
required: true;
|
|
154
|
-
}):
|
|
157
|
+
}): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor>>;
|
|
158
|
+
declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
|
|
159
|
+
converter: TConstructor;
|
|
160
|
+
fallback: undefined;
|
|
161
|
+
required?: false;
|
|
162
|
+
}): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor> | undefined>;
|
|
163
|
+
declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
|
|
164
|
+
converter: TConstructor;
|
|
165
|
+
required?: false;
|
|
166
|
+
}): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor> | null>;
|
|
155
167
|
/**
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
168
|
+
* Required, no converter (raw string). Throws `MissingEnvValue` on first access when the env
|
|
169
|
+
* value is missing or empty after trimming, independent of the global `Envapter.strict` flag.
|
|
170
|
+
* Pairing `required: true` with `fallback` matches no overload at compile time, and the runtime
|
|
171
|
+
* Validator rejects dynamic objects that bypass the types.
|
|
160
172
|
*
|
|
161
173
|
* @param key - Environment variable name(s) to load
|
|
162
174
|
* @param options - `{ required: true }`
|
|
@@ -171,7 +183,7 @@ declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyIn
|
|
|
171
183
|
*/
|
|
172
184
|
declare function Envapt(key: EnvKeyInput, options: {
|
|
173
185
|
required: true;
|
|
174
|
-
}):
|
|
186
|
+
}): EnvaptFieldDecorator<string>;
|
|
175
187
|
/**
|
|
176
188
|
* No-fallback form. The property resolves from env or `null`.
|
|
177
189
|
*
|
|
@@ -179,20 +191,18 @@ declare function Envapt(key: EnvKeyInput, options: {
|
|
|
179
191
|
* @public
|
|
180
192
|
* @example
|
|
181
193
|
* ```ts
|
|
182
|
-
* // Classic API: no fallback — property will resolve from env or be null
|
|
183
194
|
* class Config extends Envapter {
|
|
184
195
|
* \@Envapt('SIMPLE_VALUE')
|
|
185
196
|
* static readonly simple?: string | null;
|
|
186
197
|
* }
|
|
187
198
|
* ```
|
|
188
199
|
*/
|
|
189
|
-
declare function Envapt
|
|
200
|
+
declare function Envapt(key: EnvKeyInput): EnvaptFieldDecorator<string | null>;
|
|
190
201
|
/**
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
* `
|
|
194
|
-
*
|
|
195
|
-
* types.
|
|
202
|
+
* A Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous schemas only,
|
|
203
|
+
* so a Promise-returning `validate` throws `InvalidUserDefinedConfig` at runtime. Pairing
|
|
204
|
+
* `schema` with `converter` matches no overload at compile time, and the runtime Validator
|
|
205
|
+
* rejects dynamic objects that bypass the types.
|
|
196
206
|
* @public
|
|
197
207
|
*/
|
|
198
208
|
declare function Envapt<Schema extends StandardSchemaV1>(key: EnvKeyInput, options: {
|
|
@@ -202,7 +212,7 @@ declare function Envapt<Schema extends StandardSchemaV1>(key: EnvKeyInput, optio
|
|
|
202
212
|
} | {
|
|
203
213
|
schema: SchemaConstraint<Schema>;
|
|
204
214
|
required: true;
|
|
205
|
-
}):
|
|
215
|
+
}): EnvaptFieldDecorator<InferSchemaOutput<Schema>>;
|
|
206
216
|
//#endregion
|
|
207
217
|
export { Envapt };
|
|
208
218
|
//# sourceMappingURL=Envapt.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Envapt.mjs","names":[],"sources":["../../../../src/decorators/legacy/Envapt.ts"],"sourcesContent":["import { createPropertyDecorator } from './createPropertyDecorator';\nimport { parseEnvaptOptions } from '../parseEnvaptOptions';\n\nimport type { ArrayOf } from '../../converters';\nimport type { InferSchemaOutput, StandardSchemaV1 } from '../../infra/StandardSchema';\nimport type {\n BuiltInConverter,\n ConverterFunction,\n EnvaptFieldDecorator,\n EnvKeyInput,\n InferConverterFallbackType,\n InferConverterReturnType,\n InferPrimitiveReturnType,\n PrimitiveConstructor,\n SchemaConstraint\n} from '../../types';\n\n/**\n * A custom converter function with a fallback (both required), or a fallback only.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('API_KEY', {\n * fallback: 'default-key',\n * converter(raw, _fallback) {\n * if (!raw || raw.trim() === '') throw new Error('API_KEY required');\n * return raw.trim();\n * }\n * })\n * static readonly apiKey: string;\n *\n * \\@Envapt('LOG_FILE', { fallback: '/var/log/app.log' })\n * static readonly logFile: string;\n *\n * \\@Envapt('RETRY_POLICY', { fallback: { retries: 3, backoff: 'exponential' } })\n * static readonly retryPolicy: unknown;\n * }\n * ```\n */\nexport function Envapt(\n key: EnvKeyInput,\n options: { fallback: undefined; converter?: undefined }\n): EnvaptFieldDecorator<string | undefined>;\nexport function Envapt<TFallback>(\n key: EnvKeyInput,\n options:\n | { converter: (raw: string | undefined, fallback: TFallback) => TFallback; fallback: TFallback }\n | { fallback: TFallback; converter?: undefined }\n): EnvaptFieldDecorator<TFallback>;\n\n/**\n * A custom converter function without a fallback. Omit `required` to return the converter's\n * output (possibly `undefined`), or pass `required: true` to throw `MissingEnvValue` on\n * missing or empty values.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('FEATURE_FLAGS', { converter(raw) {\n * return raw ? raw.split('|').map(s => s.trim()) : [];\n * } })\n * static readonly featureFlags: string[];\n *\n * \\@Envapt('JWT_SECRET', {\n * converter: (raw) => Buffer.from(raw ?? '', 'base64'),\n * required: true\n * })\n * static readonly jwtSecret: Buffer;\n * }\n * ```\n */\nexport function Envapt<TReturnType>(\n key: EnvKeyInput,\n options:\n | { converter: ConverterFunction<TReturnType>; required?: false }\n | { converter: ConverterFunction<TReturnType>; required: true }\n): EnvaptFieldDecorator<TReturnType>;\n\n/**\n * A built-in or array converter with a fallback, or `required: true`. The fallback type tracks\n * the converter, so `Converters.Time` takes a number or time-string and `Converters.Url` takes\n * a `URL` instance.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * import { Converters } from 'envapt';\n *\n * class Config extends Envapter {\n * \\@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })\n * static readonly port: number;\n *\n * // the Url fallback is a URL instance, not a string\n * \\@Envapt('APP_URL', { converter: Converters.Url, fallback: new URL('http://localhost:3000') })\n * static readonly url: URL;\n *\n * // prefers CANARY_URL when present, otherwise APP_URL\n * \\@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })\n * static readonly canaryUrl: URL | null;\n *\n * // Time takes a number (milliseconds) or a time-string fallback (`<number><unit>`)\n * \\@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })\n * static readonly requestTimeout: number;\n *\n * \\@Envapt('ALLOWED_ORIGINS', {\n * converter: Converters.array({ of: Converters.String }),\n * fallback: ['https://example.com']\n * })\n * static readonly allowedOrigins: string[];\n *\n * \\@Envapt('DATABASE_URL', { converter: Converters.Url, required: true })\n * static readonly databaseUrl: URL;\n * }\n * ```\n */\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options:\n | { converter: TConverter; fallback: InferConverterFallbackType<TConverter>; required?: false }\n | { converter: TConverter; required: true }\n): EnvaptFieldDecorator<InferConverterReturnType<TConverter>>;\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options: { converter: TConverter; fallback: undefined; required?: false }\n): EnvaptFieldDecorator<InferConverterReturnType<TConverter> | undefined>;\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options: { converter: TConverter; required?: false }\n): EnvaptFieldDecorator<InferConverterReturnType<TConverter> | null>;\n\n/**\n * A primitive constructor (`Number`, `Boolean`) with an optional fallback.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('MAX_CONNECTIONS', { converter: Number, fallback: 100 })\n * static readonly maxConnections: number;\n *\n * \\@Envapt('FEATURE_ENABLED', { converter: Boolean, fallback: false })\n * static readonly featureEnabled: boolean;\n * }\n * ```\n */\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options:\n | { converter: TConstructor; fallback: InferPrimitiveReturnType<TConstructor>; required?: false }\n | { converter: TConstructor; required: true }\n): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor>>;\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options: { converter: TConstructor; fallback: undefined; required?: false }\n): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor> | undefined>;\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options: { converter: TConstructor; required?: false }\n): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor> | null>;\n\n/**\n * Required, no converter (raw string). Throws `MissingEnvValue` on first access when the env\n * value is missing or empty after trimming, independent of the global `Envapter.strict` flag.\n * Pairing `required: true` with `fallback` matches no overload at compile time, and the runtime\n * Validator rejects dynamic objects that bypass the types.\n *\n * @param key - Environment variable name(s) to load\n * @param options - `{ required: true }`\n * @public\n * @example\n * ```ts\n * class Config extends Envapter {\n * \\@Envapt('API_KEY', { required: true })\n * static readonly apiKey: string;\n * }\n * ```\n */\nexport function Envapt(key: EnvKeyInput, options: { required: true }): EnvaptFieldDecorator<string>;\n\n/**\n * 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 * class Config extends Envapter {\n * \\@Envapt('SIMPLE_VALUE')\n * static readonly simple?: string | null;\n * }\n * ```\n */\nexport function Envapt(key: EnvKeyInput): EnvaptFieldDecorator<string | null>;\n\n/**\n * A Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous schemas only,\n * so a Promise-returning `validate` throws `InvalidUserDefinedConfig` at runtime. Pairing\n * `schema` with `converter` matches no overload at compile time, and the runtime Validator\n * rejects dynamic objects that bypass the types.\n * @public\n */\nexport function Envapt<Schema extends StandardSchemaV1>(\n key: EnvKeyInput,\n options:\n | { schema: SchemaConstraint<Schema>; fallback?: InferSchemaOutput<Schema>; required?: false }\n | { schema: SchemaConstraint<Schema>; required: true }\n): EnvaptFieldDecorator<InferSchemaOutput<Schema>>;\n\n/**\n * Instance or static property decorator that loads and converts an environment variable.\n */\nexport function Envapt<TFallback = unknown>(key: EnvKeyInput, options?: unknown): EnvaptFieldDecorator<unknown> {\n return createPropertyDecorator(key, parseEnvaptOptions<TFallback>(options)) as EnvaptFieldDecorator<unknown>;\n}\n"],"mappings":"uIA8NA,SAAgB,EAA4B,EAAkB,EAAkD,CAC5G,OAAO,EAAwB,EAAK,EAA8B,CAAO,CAAC,CAC9E"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TimeFallback } from "../../types/Conversion.mjs";
|
|
2
|
+
import { EnvKeyInput } from "../../types/Env.mjs";
|
|
3
|
+
import { EnvaptFieldDecorator } from "../../types/Decorator.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/decorators/legacy/SugarDecorators.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Shorthand for `@Envapt(key, { converter: Converters.Boolean, fallback })`.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
declare function EnvBool(key: EnvKeyInput, fallback: boolean): EnvaptFieldDecorator<boolean>;
|
|
11
|
+
declare function EnvBool(key: EnvKeyInput): EnvaptFieldDecorator<boolean | null>;
|
|
12
|
+
/**
|
|
13
|
+
* Shorthand for `@Envapt(key, { converter: Converters.Number, fallback })`.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
declare function EnvNum(key: EnvKeyInput, fallback: number): EnvaptFieldDecorator<number>;
|
|
17
|
+
declare function EnvNum(key: EnvKeyInput): EnvaptFieldDecorator<number | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Shorthand for `@Envapt(key, { converter: Converters.String, fallback })`.
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
declare function EnvStr(key: EnvKeyInput, fallback: string): EnvaptFieldDecorator<string>;
|
|
23
|
+
declare function EnvStr(key: EnvKeyInput): EnvaptFieldDecorator<string | null>;
|
|
24
|
+
/**
|
|
25
|
+
* Shorthand for `@Envapt(key, { converter: Converters.Time, fallback })`. The fallback is a
|
|
26
|
+
* millisecond number or a time string (`'15m'`), and the resolved value is always milliseconds.
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
declare function EnvTime(key: EnvKeyInput, fallback: TimeFallback): EnvaptFieldDecorator<number>;
|
|
30
|
+
declare function EnvTime(key: EnvKeyInput): EnvaptFieldDecorator<number | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Shorthand for `@Envapt(key, { converter: Converters.Url, fallback })`. The fallback is a `URL`
|
|
33
|
+
* instance, not a URL string.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
declare function EnvUrl(key: EnvKeyInput, fallback: URL): EnvaptFieldDecorator<URL>;
|
|
37
|
+
declare function EnvUrl(key: EnvKeyInput): EnvaptFieldDecorator<URL | null>;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl };
|
|
40
|
+
//# 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/legacy/SugarDecorators.ts"],"sourcesContent":["import { createPropertyDecorator } from './createPropertyDecorator';\nimport { Converters } from '../../converters';\n\nimport type { ConverterToken } from '../../converters';\nimport type { EnvaptFieldDecorator, EnvKeyInput, TimeFallback } from '../../types';\n\nfunction sugar<TFallback>(\n converter: ConverterToken,\n key: EnvKeyInput,\n fallback: TFallback | undefined\n): EnvaptFieldDecorator<TFallback> {\n // the runtime installer is a plain (target, key) decorator, so the cast only adds a\n // compile-time field-type constraint with no runtime counterpart\n return createPropertyDecorator<TFallback>(key, {\n converter,\n fallback,\n hasFallback: fallback !== undefined,\n required: false,\n schema: undefined\n }) as EnvaptFieldDecorator<TFallback>;\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Boolean, fallback })`.\n * @public\n */\nexport function EnvBool(key: EnvKeyInput, fallback: boolean): EnvaptFieldDecorator<boolean>;\nexport function EnvBool(key: EnvKeyInput): EnvaptFieldDecorator<boolean | null>;\nexport function EnvBool(key: EnvKeyInput, fallback?: boolean): EnvaptFieldDecorator<boolean | null> {\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): EnvaptFieldDecorator<number>;\nexport function EnvNum(key: EnvKeyInput): EnvaptFieldDecorator<number | null>;\nexport function EnvNum(key: EnvKeyInput, fallback?: number): EnvaptFieldDecorator<number | null> {\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): EnvaptFieldDecorator<string>;\nexport function EnvStr(key: EnvKeyInput): EnvaptFieldDecorator<string | null>;\nexport function EnvStr(key: EnvKeyInput, fallback?: string): EnvaptFieldDecorator<string | null> {\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'`), and the resolved value is always milliseconds.\n * @public\n */\nexport function EnvTime(key: EnvKeyInput, fallback: TimeFallback): EnvaptFieldDecorator<number>;\nexport function EnvTime(key: EnvKeyInput): EnvaptFieldDecorator<number | null>;\nexport function EnvTime(key: EnvKeyInput, fallback?: TimeFallback): EnvaptFieldDecorator<number | null> {\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): EnvaptFieldDecorator<URL>;\nexport function EnvUrl(key: EnvKeyInput): EnvaptFieldDecorator<URL | null>;\nexport function EnvUrl(key: EnvKeyInput, fallback?: URL): EnvaptFieldDecorator<URL | null> {\n return sugar(Converters.Url, key, fallback);\n}\n"],"mappings":"qIAMA,SAAS,EACL,EACA,EACA,EAC+B,CAG/B,OAAO,EAAmC,EAAK,CAC3C,YACA,WACA,YAAa,IAAa,IAAA,GAC1B,SAAU,GACV,OAAQ,IAAA,EACZ,CAAC,CACL,CAQA,SAAgB,EAAQ,EAAkB,EAA0D,CAChG,OAAO,EAAM,EAAW,QAAS,EAAK,CAAQ,CAClD,CAQA,SAAgB,EAAO,EAAkB,EAAwD,CAC7F,OAAO,EAAM,EAAW,OAAQ,EAAK,CAAQ,CACjD,CAQA,SAAgB,EAAO,EAAkB,EAAwD,CAC7F,OAAO,EAAM,EAAW,OAAQ,EAAK,CAAQ,CACjD,CASA,SAAgB,EAAQ,EAAkB,EAA8D,CACpG,OAAO,EAAM,EAAW,KAAM,EAAK,CAAQ,CAC/C,CASA,SAAgB,EAAO,EAAkB,EAAkD,CACvF,OAAO,EAAM,EAAW,IAAK,EAAK,CAAQ,CAC9C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{EnvaptError as e}from"../../infra/Error.mjs";import{decoratorCacheKey as t,resolveDecoratorValue as n}from"../resolveDecoratorValue.mjs";function r(r,i){return function(a,o){let s=String(o),c=typeof a==`function`,l=t(c?a:a.constructor,c,s);Object.defineProperty(a,s,{get:function(){return n(r,i,l)},set(){throw new e(302,`Cannot assign to "${s}". @Envapt properties resolve from the environment and are read-only.`)},configurable:!1,enumerable:!0})}}export{r as createPropertyDecorator};
|
|
2
|
+
//# sourceMappingURL=createPropertyDecorator.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPropertyDecorator.mjs","names":[],"sources":["../../../../src/decorators/legacy/createPropertyDecorator.ts"],"sourcesContent":["import { EnvaptError, EnvaptErrorCodes } from '../../infra/Error';\nimport { decoratorCacheKey, resolveDecoratorValue } from '../resolveDecoratorValue';\n\nimport type { EnvKeyInput } from '../../types';\nimport type { DecoratorConfig } from '../resolveDecoratorValue';\n\nexport function createPropertyDecorator<TFallback>(\n key: EnvKeyInput,\n config: DecoratorConfig<TFallback>\n): PropertyDecorator {\n return function (target: object, prop: string | symbol): void {\n const propKey = String(prop);\n const isStatic = typeof target === 'function';\n const owner = isStatic ? target : target.constructor;\n const cacheKey = decoratorCacheKey(owner, isStatic, propKey);\n\n Object.defineProperty(target, propKey, {\n get: function () {\n return resolveDecoratorValue(key, config, cacheKey);\n },\n set(): void {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n `Cannot assign to \"${propKey}\". @Envapt properties resolve from the environment and are read-only.`\n );\n },\n configurable: false,\n enumerable: true\n });\n };\n}\n"],"mappings":"gJAMA,SAAgB,EACZ,EACA,EACiB,CACjB,OAAO,SAAU,EAAgB,EAA6B,CAC1D,IAAM,EAAU,OAAO,CAAI,EACrB,EAAW,OAAO,GAAW,WAE7B,EAAW,EADH,EAAW,EAAS,EAAO,YACC,EAAU,CAAO,EAE3D,OAAO,eAAe,EAAQ,EAAS,CACnC,IAAK,UAAY,CACb,OAAO,EAAsB,EAAK,EAAQ,CAAQ,CACtD,EACA,KAAY,CACR,MAAM,IAAI,EAAA,IAEN,qBAAqB,EAAQ,sEACjC,CACJ,EACA,aAAc,GACd,WAAY,EAChB,CAAC,CACL,CACJ"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { ArrayOf } from "../../converters/Converters.mjs";
|
|
2
|
+
import { BuiltInConverter, ConverterFunction, InferConverterFallbackType, InferConverterReturnType, InferPrimitiveReturnType, PrimitiveConstructor } from "../../types/Conversion.mjs";
|
|
3
|
+
import { InferSchemaOutput, StandardSchemaV1 } from "../../infra/StandardSchema.mjs";
|
|
4
|
+
import { SchemaConstraint } from "../../types/Schema.mjs";
|
|
5
|
+
import { EnvKeyInput } from "../../types/Env.mjs";
|
|
6
|
+
import { EnvaptAccessorDecorator } from "../../types/Decorator.mjs";
|
|
7
|
+
|
|
8
|
+
//#region src/decorators/modern/Envapt.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* A custom converter function with a fallback (both required), or a fallback only.
|
|
11
|
+
*
|
|
12
|
+
* @param key - Environment variable name(s) to load
|
|
13
|
+
* @param options - Configuration options
|
|
14
|
+
* @public
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* class Config {
|
|
18
|
+
* \@Envapt('API_KEY', {
|
|
19
|
+
* fallback: 'default-key',
|
|
20
|
+
* converter(raw, _fallback) {
|
|
21
|
+
* if (!raw || raw.trim() === '') throw new Error('API_KEY required');
|
|
22
|
+
* return raw.trim();
|
|
23
|
+
* }
|
|
24
|
+
* })
|
|
25
|
+
* static accessor apiKey: string;
|
|
26
|
+
*
|
|
27
|
+
* \@Envapt('LOG_FILE', { fallback: '/var/log/app.log' })
|
|
28
|
+
* static accessor logFile: string;
|
|
29
|
+
*
|
|
30
|
+
* \@Envapt('RETRY_POLICY', { fallback: { retries: 3, backoff: 'exponential' } })
|
|
31
|
+
* static accessor retryPolicy: unknown;
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare function Envapt(key: EnvKeyInput, options: {
|
|
36
|
+
fallback: undefined;
|
|
37
|
+
converter?: undefined;
|
|
38
|
+
}): EnvaptAccessorDecorator<string | undefined>;
|
|
39
|
+
declare function Envapt<TFallback>(key: EnvKeyInput, options: {
|
|
40
|
+
converter: (raw: string | undefined, fallback: TFallback) => TFallback;
|
|
41
|
+
fallback: TFallback;
|
|
42
|
+
} | {
|
|
43
|
+
fallback: TFallback;
|
|
44
|
+
converter?: undefined;
|
|
45
|
+
}): EnvaptAccessorDecorator<TFallback>;
|
|
46
|
+
/**
|
|
47
|
+
* A custom converter function without a fallback. Omit `required` to return the converter's
|
|
48
|
+
* output (possibly `undefined`), or pass `required: true` to throw `MissingEnvValue` on
|
|
49
|
+
* missing or empty values.
|
|
50
|
+
*
|
|
51
|
+
* @param key - Environment variable name(s) to load
|
|
52
|
+
* @param options - Configuration options
|
|
53
|
+
* @public
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* class Config {
|
|
57
|
+
* \@Envapt('FEATURE_FLAGS', { converter(raw) {
|
|
58
|
+
* return raw ? raw.split('|').map(s => s.trim()) : [];
|
|
59
|
+
* } })
|
|
60
|
+
* static accessor featureFlags: string[];
|
|
61
|
+
*
|
|
62
|
+
* \@Envapt('JWT_SECRET', {
|
|
63
|
+
* converter: (raw) => Buffer.from(raw ?? '', 'base64'),
|
|
64
|
+
* required: true
|
|
65
|
+
* })
|
|
66
|
+
* static accessor jwtSecret: Buffer;
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
declare function Envapt<TReturnType>(key: EnvKeyInput, options: {
|
|
71
|
+
converter: ConverterFunction<TReturnType>;
|
|
72
|
+
required?: false;
|
|
73
|
+
} | {
|
|
74
|
+
converter: ConverterFunction<TReturnType>;
|
|
75
|
+
required: true;
|
|
76
|
+
}): EnvaptAccessorDecorator<TReturnType>;
|
|
77
|
+
/**
|
|
78
|
+
* A built-in or array converter with a fallback, or `required: true`. The fallback type tracks
|
|
79
|
+
* the converter, so `Converters.Time` takes a number or time-string and `Converters.Url` takes
|
|
80
|
+
* a `URL` instance.
|
|
81
|
+
*
|
|
82
|
+
* @param key - Environment variable name(s) to load
|
|
83
|
+
* @param options - Configuration options
|
|
84
|
+
* @public
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* import { Converters } from 'envapt';
|
|
88
|
+
*
|
|
89
|
+
* class Config {
|
|
90
|
+
* \@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })
|
|
91
|
+
* static accessor port: number;
|
|
92
|
+
*
|
|
93
|
+
* // the Url fallback is a URL instance, not a string
|
|
94
|
+
* \@Envapt('APP_URL', { converter: Converters.Url, fallback: new URL('http://localhost:3000') })
|
|
95
|
+
* static accessor url: URL;
|
|
96
|
+
*
|
|
97
|
+
* // prefers CANARY_URL when present, otherwise APP_URL
|
|
98
|
+
* \@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })
|
|
99
|
+
* static accessor canaryUrl: URL | null;
|
|
100
|
+
*
|
|
101
|
+
* // Time takes a number (milliseconds) or a time-string fallback (`<number><unit>`)
|
|
102
|
+
* \@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })
|
|
103
|
+
* static accessor requestTimeout: number;
|
|
104
|
+
*
|
|
105
|
+
* \@Envapt('ALLOWED_ORIGINS', {
|
|
106
|
+
* converter: Converters.array({ of: Converters.String }),
|
|
107
|
+
* fallback: ['https://example.com']
|
|
108
|
+
* })
|
|
109
|
+
* static accessor allowedOrigins: string[];
|
|
110
|
+
*
|
|
111
|
+
* \@Envapt('DATABASE_URL', { converter: Converters.Url, required: true })
|
|
112
|
+
* static accessor databaseUrl: URL;
|
|
113
|
+
* }
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
|
|
117
|
+
converter: TConverter;
|
|
118
|
+
fallback: InferConverterFallbackType<TConverter>;
|
|
119
|
+
required?: false;
|
|
120
|
+
} | {
|
|
121
|
+
converter: TConverter;
|
|
122
|
+
required: true;
|
|
123
|
+
}): EnvaptAccessorDecorator<InferConverterReturnType<TConverter>>;
|
|
124
|
+
declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
|
|
125
|
+
converter: TConverter;
|
|
126
|
+
fallback: undefined;
|
|
127
|
+
required?: false;
|
|
128
|
+
}): EnvaptAccessorDecorator<InferConverterReturnType<TConverter> | undefined>;
|
|
129
|
+
declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
|
|
130
|
+
converter: TConverter;
|
|
131
|
+
required?: false;
|
|
132
|
+
}): EnvaptAccessorDecorator<InferConverterReturnType<TConverter> | null>;
|
|
133
|
+
/**
|
|
134
|
+
* A primitive constructor (`Number`, `Boolean`) with an optional fallback.
|
|
135
|
+
*
|
|
136
|
+
* @param key - Environment variable name(s) to load
|
|
137
|
+
* @param options - Configuration options
|
|
138
|
+
* @public
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* class Config {
|
|
142
|
+
* \@Envapt('MAX_CONNECTIONS', { converter: Number, fallback: 100 })
|
|
143
|
+
* static accessor maxConnections: number;
|
|
144
|
+
*
|
|
145
|
+
* \@Envapt('FEATURE_ENABLED', { converter: Boolean, fallback: false })
|
|
146
|
+
* static accessor featureEnabled: boolean;
|
|
147
|
+
* }
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
|
|
151
|
+
converter: TConstructor;
|
|
152
|
+
fallback: InferPrimitiveReturnType<TConstructor>;
|
|
153
|
+
required?: false;
|
|
154
|
+
} | {
|
|
155
|
+
converter: TConstructor;
|
|
156
|
+
required: true;
|
|
157
|
+
}): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor>>;
|
|
158
|
+
declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
|
|
159
|
+
converter: TConstructor;
|
|
160
|
+
fallback: undefined;
|
|
161
|
+
required?: false;
|
|
162
|
+
}): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor> | undefined>;
|
|
163
|
+
declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
|
|
164
|
+
converter: TConstructor;
|
|
165
|
+
required?: false;
|
|
166
|
+
}): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor> | null>;
|
|
167
|
+
/**
|
|
168
|
+
* Required, no converter (raw string). Throws `MissingEnvValue` on first access when the env
|
|
169
|
+
* value is missing or empty after trimming, independent of the global `Envapter.strict` flag.
|
|
170
|
+
* Pairing `required: true` with `fallback` matches no overload at compile time, and the runtime
|
|
171
|
+
* Validator rejects dynamic objects that bypass the types.
|
|
172
|
+
*
|
|
173
|
+
* @param key - Environment variable name(s) to load
|
|
174
|
+
* @param options - `{ required: true }`
|
|
175
|
+
* @public
|
|
176
|
+
* @example
|
|
177
|
+
* ```ts
|
|
178
|
+
* class Config {
|
|
179
|
+
* \@Envapt('API_KEY', { required: true })
|
|
180
|
+
* static accessor apiKey: string;
|
|
181
|
+
* }
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
declare function Envapt(key: EnvKeyInput, options: {
|
|
185
|
+
required: true;
|
|
186
|
+
}): EnvaptAccessorDecorator<string>;
|
|
187
|
+
/**
|
|
188
|
+
* No-fallback form. The property resolves from env or `null`.
|
|
189
|
+
*
|
|
190
|
+
* @param key - Environment variable name(s) to load
|
|
191
|
+
* @public
|
|
192
|
+
* @example
|
|
193
|
+
* ```ts
|
|
194
|
+
* class Config {
|
|
195
|
+
* \@Envapt('SIMPLE_VALUE')
|
|
196
|
+
* static accessor simple: string | null;
|
|
197
|
+
* }
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
declare function Envapt(key: EnvKeyInput): EnvaptAccessorDecorator<string | null>;
|
|
201
|
+
/**
|
|
202
|
+
* A Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous schemas only,
|
|
203
|
+
* so a Promise-returning `validate` throws `InvalidUserDefinedConfig` at runtime. Pairing
|
|
204
|
+
* `schema` with `converter` matches no overload at compile time, and the runtime Validator
|
|
205
|
+
* rejects dynamic objects that bypass the types.
|
|
206
|
+
* @public
|
|
207
|
+
*/
|
|
208
|
+
declare function Envapt<Schema extends StandardSchemaV1>(key: EnvKeyInput, options: {
|
|
209
|
+
schema: SchemaConstraint<Schema>;
|
|
210
|
+
fallback?: InferSchemaOutput<Schema>;
|
|
211
|
+
required?: false;
|
|
212
|
+
} | {
|
|
213
|
+
schema: SchemaConstraint<Schema>;
|
|
214
|
+
required: true;
|
|
215
|
+
}): EnvaptAccessorDecorator<InferSchemaOutput<Schema>>;
|
|
216
|
+
//#endregion
|
|
217
|
+
export { Envapt };
|
|
218
|
+
//# sourceMappingURL=Envapt.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Envapt.mjs","names":[],"sources":["../../../../src/decorators/modern/Envapt.ts"],"sourcesContent":["import { createAccessorDecorator } from './createAccessorDecorator';\nimport { parseEnvaptOptions } from '../parseEnvaptOptions';\n\nimport type { ArrayOf } from '../../converters';\nimport type { InferSchemaOutput, StandardSchemaV1 } from '../../infra/StandardSchema';\nimport type {\n BuiltInConverter,\n ConverterFunction,\n EnvaptAccessorDecorator,\n EnvKeyInput,\n InferConverterFallbackType,\n InferConverterReturnType,\n InferPrimitiveReturnType,\n PrimitiveConstructor,\n SchemaConstraint\n} from '../../types';\n\n/**\n * A custom converter function with a fallback (both required), or a fallback only.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config {\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 accessor apiKey: string;\n *\n * \\@Envapt('LOG_FILE', { fallback: '/var/log/app.log' })\n * static accessor logFile: string;\n *\n * \\@Envapt('RETRY_POLICY', { fallback: { retries: 3, backoff: 'exponential' } })\n * static accessor retryPolicy: unknown;\n * }\n * ```\n */\nexport function Envapt(\n key: EnvKeyInput,\n options: { fallback: undefined; converter?: undefined }\n): EnvaptAccessorDecorator<string | undefined>;\nexport function Envapt<TFallback>(\n key: EnvKeyInput,\n options:\n | { converter: (raw: string | undefined, fallback: TFallback) => TFallback; fallback: TFallback }\n | { fallback: TFallback; converter?: undefined }\n): EnvaptAccessorDecorator<TFallback>;\n\n/**\n * A custom converter function without a fallback. Omit `required` to return the converter's\n * output (possibly `undefined`), or pass `required: true` to throw `MissingEnvValue` on\n * missing or empty values.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config {\n * \\@Envapt('FEATURE_FLAGS', { converter(raw) {\n * return raw ? raw.split('|').map(s => s.trim()) : [];\n * } })\n * static accessor featureFlags: string[];\n *\n * \\@Envapt('JWT_SECRET', {\n * converter: (raw) => Buffer.from(raw ?? '', 'base64'),\n * required: true\n * })\n * static accessor 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): EnvaptAccessorDecorator<TReturnType>;\n\n/**\n * A built-in or array converter with a fallback, or `required: true`. The fallback type tracks\n * the converter, so `Converters.Time` takes a number or time-string and `Converters.Url` takes\n * a `URL` instance.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * import { Converters } from 'envapt';\n *\n * class Config {\n * \\@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })\n * static accessor port: number;\n *\n * // the Url fallback is a URL instance, not a string\n * \\@Envapt('APP_URL', { converter: Converters.Url, fallback: new URL('http://localhost:3000') })\n * static accessor url: URL;\n *\n * // prefers CANARY_URL when present, otherwise APP_URL\n * \\@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })\n * static accessor canaryUrl: URL | null;\n *\n * // Time takes a number (milliseconds) or a time-string fallback (`<number><unit>`)\n * \\@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })\n * static accessor requestTimeout: number;\n *\n * \\@Envapt('ALLOWED_ORIGINS', {\n * converter: Converters.array({ of: Converters.String }),\n * fallback: ['https://example.com']\n * })\n * static accessor allowedOrigins: string[];\n *\n * \\@Envapt('DATABASE_URL', { converter: Converters.Url, required: true })\n * static accessor databaseUrl: URL;\n * }\n * ```\n */\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options:\n | { converter: TConverter; fallback: InferConverterFallbackType<TConverter>; required?: false }\n | { converter: TConverter; required: true }\n): EnvaptAccessorDecorator<InferConverterReturnType<TConverter>>;\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options: { converter: TConverter; fallback: undefined; required?: false }\n): EnvaptAccessorDecorator<InferConverterReturnType<TConverter> | undefined>;\nexport function Envapt<TConverter extends BuiltInConverter | ArrayOf>(\n key: EnvKeyInput,\n options: { converter: TConverter; required?: false }\n): EnvaptAccessorDecorator<InferConverterReturnType<TConverter> | null>;\n\n/**\n * A primitive constructor (`Number`, `Boolean`) with an optional fallback.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Configuration options\n * @public\n * @example\n * ```ts\n * class Config {\n * \\@Envapt('MAX_CONNECTIONS', { converter: Number, fallback: 100 })\n * static accessor maxConnections: number;\n *\n * \\@Envapt('FEATURE_ENABLED', { converter: Boolean, fallback: false })\n * static accessor 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): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor>>;\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options: { converter: TConstructor; fallback: undefined; required?: false }\n): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor> | undefined>;\nexport function Envapt<TConstructor extends PrimitiveConstructor>(\n key: EnvKeyInput,\n options: { converter: TConstructor; required?: false }\n): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor> | null>;\n\n/**\n * Required, no converter (raw string). Throws `MissingEnvValue` on first access when the env\n * value is missing or empty after trimming, independent of the global `Envapter.strict` flag.\n * Pairing `required: true` with `fallback` matches no overload at compile time, and the runtime\n * Validator rejects dynamic objects that bypass the types.\n *\n * @param key - Environment variable name(s) to load\n * @param options - `{ required: true }`\n * @public\n * @example\n * ```ts\n * class Config {\n * \\@Envapt('API_KEY', { required: true })\n * static accessor apiKey: string;\n * }\n * ```\n */\nexport function Envapt(key: EnvKeyInput, options: { required: true }): EnvaptAccessorDecorator<string>;\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 * class Config {\n * \\@Envapt('SIMPLE_VALUE')\n * static accessor simple: string | null;\n * }\n * ```\n */\nexport function Envapt(key: EnvKeyInput): EnvaptAccessorDecorator<string | null>;\n\n/**\n * A Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous schemas only,\n * so a Promise-returning `validate` throws `InvalidUserDefinedConfig` at runtime. Pairing\n * `schema` with `converter` matches no overload at compile time, and the runtime Validator\n * rejects dynamic objects that bypass the types.\n * @public\n */\nexport function Envapt<Schema extends StandardSchemaV1>(\n key: EnvKeyInput,\n options:\n | { schema: SchemaConstraint<Schema>; fallback?: InferSchemaOutput<Schema>; required?: false }\n | { schema: SchemaConstraint<Schema>; required: true }\n): EnvaptAccessorDecorator<InferSchemaOutput<Schema>>;\n\n/**\n * Modern (TC39 Stage 3) accessor decorator that loads and converts an environment variable. The\n * decorated property uses the `accessor` keyword and needs no `experimentalDecorators` flag.\n * Instance accessors need the definite-assignment `!`, static accessors do not.\n *\n * @param key - Environment variable name(s) to load\n * @param options - Converter, fallback, `required`, or `schema`. See the overloads.\n * @public\n * @example\n * ```ts\n * import { Envapt, Converters } from 'envapt';\n *\n * class Config {\n * \\@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })\n * static accessor port: number;\n *\n * \\@Envapt('DATABASE_URL', { converter: Converters.Url, required: true })\n * accessor databaseUrl!: URL;\n * }\n * ```\n */\n/* v8 ignore start -- @preserve oxc (vitest's transform) breaks modern accessor decorators (context.name unset), so the tsc stage3-emit harness covers these, not vitest */\nexport function Envapt<TFallback = unknown>(key: EnvKeyInput, options?: unknown): EnvaptAccessorDecorator<unknown> {\n return createAccessorDecorator(key, parseEnvaptOptions<TFallback>(options)) as EnvaptAccessorDecorator<unknown>;\n}\n/* v8 ignore stop */\n"],"mappings":"uIAiPA,SAAgB,EAA4B,EAAkB,EAAqD,CAC/G,OAAO,EAAwB,EAAK,EAA8B,CAAO,CAAC,CAC9E"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TimeFallback } from "../../types/Conversion.mjs";
|
|
2
|
+
import { EnvKeyInput } from "../../types/Env.mjs";
|
|
3
|
+
import { EnvaptAccessorDecorator } from "../../types/Decorator.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/decorators/modern/SugarDecorators.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Shorthand for `@Envapt(key, { converter: Converters.Boolean, fallback })`.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
declare function EnvBool(key: EnvKeyInput, fallback: boolean): EnvaptAccessorDecorator<boolean>;
|
|
11
|
+
declare function EnvBool(key: EnvKeyInput): EnvaptAccessorDecorator<boolean | null>;
|
|
12
|
+
/**
|
|
13
|
+
* Shorthand for `@Envapt(key, { converter: Converters.Number, fallback })`.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
declare function EnvNum(key: EnvKeyInput, fallback: number): EnvaptAccessorDecorator<number>;
|
|
17
|
+
declare function EnvNum(key: EnvKeyInput): EnvaptAccessorDecorator<number | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Shorthand for `@Envapt(key, { converter: Converters.String, fallback })`.
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
declare function EnvStr(key: EnvKeyInput, fallback: string): EnvaptAccessorDecorator<string>;
|
|
23
|
+
declare function EnvStr(key: EnvKeyInput): EnvaptAccessorDecorator<string | null>;
|
|
24
|
+
/**
|
|
25
|
+
* Shorthand for `@Envapt(key, { converter: Converters.Time, fallback })`. The fallback is a
|
|
26
|
+
* millisecond number or a time string (`'15m'`), and the resolved value is always milliseconds.
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
declare function EnvTime(key: EnvKeyInput, fallback: TimeFallback): EnvaptAccessorDecorator<number>;
|
|
30
|
+
declare function EnvTime(key: EnvKeyInput): EnvaptAccessorDecorator<number | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Shorthand for `@Envapt(key, { converter: Converters.Url, fallback })`. The fallback is a `URL`
|
|
33
|
+
* instance, not a URL string.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
declare function EnvUrl(key: EnvKeyInput, fallback: URL): EnvaptAccessorDecorator<URL>;
|
|
37
|
+
declare function EnvUrl(key: EnvKeyInput): EnvaptAccessorDecorator<URL | null>;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl };
|
|
40
|
+
//# sourceMappingURL=SugarDecorators.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Converters as e}from"../../converters/Converters.mjs";import{createAccessorDecorator as t}from"./createAccessorDecorator.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/modern/SugarDecorators.ts"],"sourcesContent":["import { createAccessorDecorator } from './createAccessorDecorator';\nimport { Converters } from '../../converters';\n\nimport type { ConverterToken } from '../../converters';\nimport type { EnvaptAccessorDecorator, EnvKeyInput, TimeFallback } from '../../types';\n\n/* v8 ignore start -- @preserve oxc (vitest's transform) breaks modern accessor decorators (context.name unset), so the tsc stage3-emit harness covers these, not vitest */\nfunction sugar<TFallback>(\n converter: ConverterToken,\n key: EnvKeyInput,\n fallback: TFallback | undefined\n): EnvaptAccessorDecorator<TFallback> {\n // the runtime installer is a plain accessor decorator, so the cast only adds a\n // compile-time field-type constraint with no runtime counterpart\n return createAccessorDecorator<TFallback>(key, {\n converter,\n fallback,\n hasFallback: fallback !== undefined,\n required: false,\n schema: undefined\n }) as EnvaptAccessorDecorator<TFallback>;\n}\n\n/**\n * Shorthand for `@Envapt(key, { converter: Converters.Boolean, fallback })`.\n * @public\n */\nexport function EnvBool(key: EnvKeyInput, fallback: boolean): EnvaptAccessorDecorator<boolean>;\nexport function EnvBool(key: EnvKeyInput): EnvaptAccessorDecorator<boolean | null>;\nexport function EnvBool(key: EnvKeyInput, fallback?: boolean): EnvaptAccessorDecorator<boolean | null> {\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): EnvaptAccessorDecorator<number>;\nexport function EnvNum(key: EnvKeyInput): EnvaptAccessorDecorator<number | null>;\nexport function EnvNum(key: EnvKeyInput, fallback?: number): EnvaptAccessorDecorator<number | null> {\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): EnvaptAccessorDecorator<string>;\nexport function EnvStr(key: EnvKeyInput): EnvaptAccessorDecorator<string | null>;\nexport function EnvStr(key: EnvKeyInput, fallback?: string): EnvaptAccessorDecorator<string | null> {\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'`), and the resolved value is always milliseconds.\n * @public\n */\nexport function EnvTime(key: EnvKeyInput, fallback: TimeFallback): EnvaptAccessorDecorator<number>;\nexport function EnvTime(key: EnvKeyInput): EnvaptAccessorDecorator<number | null>;\nexport function EnvTime(key: EnvKeyInput, fallback?: TimeFallback): EnvaptAccessorDecorator<number | null> {\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): EnvaptAccessorDecorator<URL>;\nexport function EnvUrl(key: EnvKeyInput): EnvaptAccessorDecorator<URL | null>;\nexport function EnvUrl(key: EnvKeyInput, fallback?: URL): EnvaptAccessorDecorator<URL | null> {\n return sugar(Converters.Url, key, fallback);\n}\n/* v8 ignore stop */\n"],"mappings":"qIAOA,SAAS,EACL,EACA,EACA,EACkC,CAGlC,OAAO,EAAmC,EAAK,CAC3C,YACA,WACA,YAAa,IAAa,IAAA,GAC1B,SAAU,GACV,OAAQ,IAAA,EACZ,CAAC,CACL,CAQA,SAAgB,EAAQ,EAAkB,EAA6D,CACnG,OAAO,EAAM,EAAW,QAAS,EAAK,CAAQ,CAClD,CAQA,SAAgB,EAAO,EAAkB,EAA2D,CAChG,OAAO,EAAM,EAAW,OAAQ,EAAK,CAAQ,CACjD,CAQA,SAAgB,EAAO,EAAkB,EAA2D,CAChG,OAAO,EAAM,EAAW,OAAQ,EAAK,CAAQ,CACjD,CASA,SAAgB,EAAQ,EAAkB,EAAiE,CACvG,OAAO,EAAM,EAAW,KAAM,EAAK,CAAQ,CAC/C,CASA,SAAgB,EAAO,EAAkB,EAAqD,CAC1F,OAAO,EAAM,EAAW,IAAK,EAAK,CAAQ,CAC9C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{EnvaptError as e}from"../../infra/Error.mjs";import{decoratorCacheKey as t,resolveDecoratorValue as n}from"../resolveDecoratorValue.mjs";function r(r,i){return function(a,o){let s=o.name;if(s===void 0)throw new e(302,`The runtime did not provide the accessor name to @Envapt, this Stage 3 decorator transform is unsupported.`);let c=String(s);return{get(){let e=this,a=typeof e==`function`;return n(r,i,t(a?e:e.constructor,a,c))},set(){throw new e(302,`Cannot assign to "${c}". @Envapt accessor properties resolve from the environment and are read-only.`)}}}}export{r as createAccessorDecorator};
|
|
2
|
+
//# sourceMappingURL=createAccessorDecorator.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAccessorDecorator.mjs","names":[],"sources":["../../../../src/decorators/modern/createAccessorDecorator.ts"],"sourcesContent":["import { EnvaptError, EnvaptErrorCodes } from '../../infra/Error';\nimport { decoratorCacheKey, resolveDecoratorValue } from '../resolveDecoratorValue';\n\nimport type { EnvKeyInput } from '../../types';\nimport type { DecoratorConfig } from '../resolveDecoratorValue';\n\n/* v8 ignore start -- @preserve oxc (vitest's transform) breaks modern accessor decorators (context.name unset), so the tsc stage3-emit harness covers these, not vitest */\nexport function createAccessorDecorator<TFallback>(key: EnvKeyInput, config: DecoratorConfig<TFallback>) {\n return function <This, Value>(\n _target: ClassAccessorDecoratorTarget<This, Value>,\n context: ClassAccessorDecoratorContext<This, Value>\n ): ClassAccessorDecoratorResult<This, Value> {\n const name: string | symbol | undefined = context.name;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- a broken Stage 3 transform can leave context.name unset, which would collapse every accessor to one cache key\n if (name === undefined) {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n 'The runtime did not provide the accessor name to @Envapt, this Stage 3 decorator transform is unsupported.'\n );\n }\n const propKey = String(name);\n\n return {\n get(this: This): Value {\n const self = this as object;\n // derive static-ness from `this` (the class is a function, an instance is not) rather than\n // context.static, which some transformers (oxc) leave unset, collapsing every owner to Function\n const isStatic = typeof self === 'function';\n const owner = isStatic ? self : self.constructor;\n const cacheKey = decoratorCacheKey(owner, isStatic, propKey);\n return resolveDecoratorValue(key, config, cacheKey) as Value;\n },\n set(): void {\n throw new EnvaptError(\n EnvaptErrorCodes.InvalidUserDefinedConfig,\n `Cannot assign to \"${propKey}\". @Envapt accessor properties resolve from the environment and are read-only.`\n );\n }\n };\n };\n}\n/* v8 ignore stop */\n"],"mappings":"gJAOA,SAAgB,EAAmC,EAAkB,EAAoC,CACrG,OAAO,SACH,EACA,EACyC,CACzC,IAAM,EAAoC,EAAQ,KAElD,GAAI,IAAS,IAAA,GACT,MAAM,IAAI,EAAA,IAEN,4GACJ,EAEJ,IAAM,EAAU,OAAO,CAAI,EAE3B,MAAO,CACH,KAAuB,CACnB,IAAM,EAAO,KAGP,EAAW,OAAO,GAAS,WAGjC,OAAO,EAAsB,EAAK,EADjB,EADH,EAAW,EAAO,EAAK,YACK,EAAU,CACH,CAAC,CACtD,EACA,KAAY,CACR,MAAM,IAAI,EAAA,IAEN,qBAAqB,EAAQ,+EACjC,CACJ,CACJ,CACJ,CACJ"}
|