envapt 7.0.0-next.0 → 7.0.0-next.2

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.
Files changed (125) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/browser/engine/PortableEnvapter.mjs +2 -0
  3. package/dist/browser/engine/PortableEnvapter.mjs.map +1 -0
  4. package/dist/browser/engine/installFileApiStubs.mjs +1 -1
  5. package/dist/browser/engine/installFileApiStubs.mjs.map +1 -1
  6. package/dist/browser/index.mjs +1 -2
  7. package/dist/{node → types}/engine/NodeEnvapter.d.mts +0 -2
  8. package/dist/types/engine/PortableEnvapter.d.mts +14 -0
  9. package/dist/{node → types}/index.d.mts +0 -2
  10. package/dist/{browser/index.d.mts → types/index.portable.d.mts} +2 -2
  11. package/dist/{node/sources/NodeEnvSource.d.cts → types/sources/NodeEnvSource.d.mts} +2 -2
  12. package/dist/workerd/engine/PortableEnvapter.mjs +2 -0
  13. package/dist/workerd/engine/PortableEnvapter.mjs.map +1 -0
  14. package/dist/workerd/engine/installFileApiStubs.mjs +1 -1
  15. package/dist/workerd/engine/installFileApiStubs.mjs.map +1 -1
  16. package/dist/workerd/index.mjs +1 -2
  17. package/package.json +25 -22
  18. package/dist/browser/index.mjs.map +0 -1
  19. package/dist/node/config.d.mts +0 -2
  20. package/dist/node/converters/Converters.d.cts +0 -93
  21. package/dist/node/converters/Converters.d.mts +0 -95
  22. package/dist/node/converters/ValueConverter.d.cts +0 -25
  23. package/dist/node/converters/ValueConverter.d.mts +0 -27
  24. package/dist/node/core/AdvancedMethods.d.cts +0 -76
  25. package/dist/node/core/AdvancedMethods.d.mts +0 -78
  26. package/dist/node/core/EnvapterBase.d.cts +0 -75
  27. package/dist/node/core/EnvapterBase.d.mts +0 -77
  28. package/dist/node/core/EnvironmentMethods.d.cts +0 -115
  29. package/dist/node/core/EnvironmentMethods.d.mts +0 -117
  30. package/dist/node/core/PrimitiveMethods.d.cts +0 -70
  31. package/dist/node/core/PrimitiveMethods.d.mts +0 -72
  32. package/dist/node/decorators/legacy/Envapt.d.cts +0 -218
  33. package/dist/node/decorators/legacy/Envapt.d.mts +0 -220
  34. package/dist/node/decorators/legacy/SugarDecorators.d.cts +0 -40
  35. package/dist/node/decorators/legacy/SugarDecorators.d.mts +0 -42
  36. package/dist/node/decorators/modern/Envapt.d.cts +0 -218
  37. package/dist/node/decorators/modern/Envapt.d.mts +0 -220
  38. package/dist/node/decorators/modern/SugarDecorators.d.cts +0 -40
  39. package/dist/node/decorators/modern/SugarDecorators.d.mts +0 -42
  40. package/dist/node/engine/Envapter.d.cts +0 -70
  41. package/dist/node/engine/Envapter.d.mts +0 -72
  42. package/dist/node/engine/NodeEnvapter.d.cts +0 -73
  43. package/dist/node/engine/TemplateResolver.d.cts +0 -17
  44. package/dist/node/engine/TemplateResolver.d.mts +0 -19
  45. package/dist/node/index.d.cts +0 -19
  46. package/dist/node/infra/Debug.d.cts +0 -13
  47. package/dist/node/infra/Debug.d.mts +0 -15
  48. package/dist/node/infra/Dotenv.d.cts +0 -17
  49. package/dist/node/infra/Dotenv.d.mts +0 -19
  50. package/dist/node/infra/Error.d.cts +0 -72
  51. package/dist/node/infra/Error.d.mts +0 -74
  52. package/dist/node/infra/StandardSchema.d.cts +0 -59
  53. package/dist/node/infra/StandardSchema.d.mts +0 -61
  54. package/dist/node/legacy.d.cts +0 -4
  55. package/dist/node/legacy.d.mts +0 -6
  56. package/dist/node/sources/ManualEnvSource.d.cts +0 -19
  57. package/dist/node/sources/ManualEnvSource.d.mts +0 -21
  58. package/dist/node/sources/NodeEnvSource.d.mts +0 -22
  59. package/dist/node/sources/WorkerEnvSource.d.cts +0 -19
  60. package/dist/node/sources/WorkerEnvSource.d.mts +0 -21
  61. package/dist/node/types/Conversion.d.cts +0 -123
  62. package/dist/node/types/Conversion.d.mts +0 -125
  63. package/dist/node/types/Decorator.d.cts +0 -26
  64. package/dist/node/types/Decorator.d.mts +0 -28
  65. package/dist/node/types/Env.d.cts +0 -17
  66. package/dist/node/types/Env.d.mts +0 -19
  67. package/dist/node/types/Options.d.cts +0 -39
  68. package/dist/node/types/Options.d.mts +0 -41
  69. package/dist/node/types/Schema.d.cts +0 -12
  70. package/dist/node/types/Schema.d.mts +0 -14
  71. package/dist/node/types/Source.d.cts +0 -44
  72. package/dist/node/types/Source.d.mts +0 -46
  73. package/dist/workerd/converters/Converters.d.mts +0 -93
  74. package/dist/workerd/converters/ValueConverter.d.mts +0 -25
  75. package/dist/workerd/core/AdvancedMethods.d.mts +0 -76
  76. package/dist/workerd/core/EnvapterBase.d.mts +0 -75
  77. package/dist/workerd/core/EnvironmentMethods.d.mts +0 -115
  78. package/dist/workerd/core/PrimitiveMethods.d.mts +0 -70
  79. package/dist/workerd/decorators/legacy/Envapt.d.mts +0 -218
  80. package/dist/workerd/decorators/legacy/SugarDecorators.d.mts +0 -40
  81. package/dist/workerd/decorators/modern/Envapt.d.mts +0 -218
  82. package/dist/workerd/decorators/modern/SugarDecorators.d.mts +0 -40
  83. package/dist/workerd/engine/Envapter.d.mts +0 -70
  84. package/dist/workerd/engine/TemplateResolver.d.mts +0 -17
  85. package/dist/workerd/index.d.mts +0 -18
  86. package/dist/workerd/index.mjs.map +0 -1
  87. package/dist/workerd/infra/Debug.d.mts +0 -13
  88. package/dist/workerd/infra/Dotenv.d.mts +0 -17
  89. package/dist/workerd/infra/Error.d.mts +0 -72
  90. package/dist/workerd/infra/StandardSchema.d.mts +0 -59
  91. package/dist/workerd/legacy.d.mts +0 -4
  92. package/dist/workerd/sources/ManualEnvSource.d.mts +0 -19
  93. package/dist/workerd/sources/WorkerEnvSource.d.mts +0 -19
  94. package/dist/workerd/types/Conversion.d.mts +0 -123
  95. package/dist/workerd/types/Decorator.d.mts +0 -26
  96. package/dist/workerd/types/Env.d.mts +0 -17
  97. package/dist/workerd/types/Options.d.mts +0 -39
  98. package/dist/workerd/types/Schema.d.mts +0 -12
  99. package/dist/workerd/types/Source.d.mts +0 -44
  100. /package/dist/{node/config.d.cts → types/config.d.mts} +0 -0
  101. /package/dist/{browser → types}/converters/Converters.d.mts +0 -0
  102. /package/dist/{browser → types}/converters/ValueConverter.d.mts +0 -0
  103. /package/dist/{browser → types}/core/AdvancedMethods.d.mts +0 -0
  104. /package/dist/{browser → types}/core/EnvapterBase.d.mts +0 -0
  105. /package/dist/{browser → types}/core/EnvironmentMethods.d.mts +0 -0
  106. /package/dist/{browser → types}/core/PrimitiveMethods.d.mts +0 -0
  107. /package/dist/{browser → types}/decorators/legacy/Envapt.d.mts +0 -0
  108. /package/dist/{browser → types}/decorators/legacy/SugarDecorators.d.mts +0 -0
  109. /package/dist/{browser → types}/decorators/modern/Envapt.d.mts +0 -0
  110. /package/dist/{browser → types}/decorators/modern/SugarDecorators.d.mts +0 -0
  111. /package/dist/{browser → types}/engine/Envapter.d.mts +0 -0
  112. /package/dist/{browser → types}/engine/TemplateResolver.d.mts +0 -0
  113. /package/dist/{browser → types}/infra/Debug.d.mts +0 -0
  114. /package/dist/{browser → types}/infra/Dotenv.d.mts +0 -0
  115. /package/dist/{browser → types}/infra/Error.d.mts +0 -0
  116. /package/dist/{browser → types}/infra/StandardSchema.d.mts +0 -0
  117. /package/dist/{browser → types}/legacy.d.mts +0 -0
  118. /package/dist/{browser → types}/sources/ManualEnvSource.d.mts +0 -0
  119. /package/dist/{browser → types}/sources/WorkerEnvSource.d.mts +0 -0
  120. /package/dist/{browser → types}/types/Conversion.d.mts +0 -0
  121. /package/dist/{browser → types}/types/Decorator.d.mts +0 -0
  122. /package/dist/{browser → types}/types/Env.d.mts +0 -0
  123. /package/dist/{browser → types}/types/Options.d.mts +0 -0
  124. /package/dist/{browser → types}/types/Schema.d.mts +0 -0
  125. /package/dist/{browser → types}/types/Source.d.mts +0 -0
@@ -1,123 +0,0 @@
1
- import { ArrayOf, ConverterToken, CustomElementConverter } from "../converters/Converters.cjs";
2
-
3
- //#region src/types/Conversion.d.ts
4
- /**
5
- * Scalar built-in converter tokens (e.g. `'number'`, `'time'`).
6
- * Excludes the array builder (see {@link ArrayOf}).
7
- * @public
8
- */
9
- type BuiltInConverter = ConverterToken;
10
- /**
11
- * Primitive types supported by Envapter
12
- * @public
13
- */
14
- type PrimitiveConstructor = typeof String | typeof Number | typeof Boolean | typeof BigInt | typeof Symbol;
15
- /**
16
- * String value from a .env file or environment variable
17
- * @public
18
- */
19
- type BaseInput = string | undefined;
20
- /**
21
- * Custom parser function type for environment variables
22
- * @param raw - Raw string value from environment
23
- * @param fallback - Fallback value if parsing fails
24
- * @returns Parsed value of type T
25
- * @public
26
- */
27
- type ConverterFunction<TFallback = unknown> = (raw: BaseInput, fallback?: TFallback) => TFallback;
28
- /**
29
- * Environment variable converter: a primitive constructor, a built-in scalar token, an `ArrayOf<...>`
30
- * produced by {@link Converters.array}, or a custom parser function.
31
- * @public
32
- */
33
- type EnvaptConverter<TFallback> = PrimitiveConstructor | BuiltInConverter | ArrayOf | ConverterFunction<TFallback>;
34
- type JsonPrimitive = string | number | boolean | null;
35
- type JsonArray = JsonValue[];
36
- interface JsonObject {
37
- [key: string]: JsonValue;
38
- }
39
- /**
40
- * JSON value types for custom converters
41
- * @public
42
- */
43
- type JsonValue = JsonPrimitive | JsonArray | JsonObject;
44
- interface ConverterMap {
45
- string: string;
46
- number: number;
47
- boolean: boolean;
48
- bigint: bigint;
49
- symbol: symbol;
50
- integer: number;
51
- float: number;
52
- json: JsonValue;
53
- url: URL;
54
- regexp: RegExp;
55
- date: Date;
56
- time: number;
57
- }
58
- /**
59
- * Type mapping for built-in scalar converters to their return types
60
- * @internal
61
- */
62
- type BuiltInConverterReturnType<ConverterKey extends BuiltInConverter> = ConverterMap[ConverterKey];
63
- /**
64
- * Return type for built-in converter functions
65
- * @internal
66
- */
67
- type ReturnValuesOfConverterFunctions = ConverterMap[BuiltInConverter];
68
- /**
69
- * Function type for built-in converter functions
70
- * @internal
71
- */
72
- type BuiltInConverterFunction = (...args: Parameters<(...args: any[]) => ReturnValuesOfConverterFunctions>) => ReturnValuesOfConverterFunctions | undefined;
73
- /**
74
- * Map of built-in converter functions
75
- * @internal
76
- */
77
- type MapOfConverterFunctions = Record<BuiltInConverter, BuiltInConverterFunction>;
78
- /**
79
- * Time unit types for duration conversions
80
- * @internal
81
- */
82
- type TimeUnit = 'ms' | 's' | 'm' | 'h' | 'd' | 'w';
83
- /**
84
- * Fallback type for time duration conversions
85
- * @public
86
- */
87
- type TimeFallback = number | `${number}${TimeUnit}`;
88
- /**
89
- * Helper type for getter methods that conditionally return undefined based on whether a fallback is provided
90
- * If fallback is provided, return ReturnType. If no fallback (undefined), return ReturnType | undefined.
91
- * @internal
92
- */
93
- type ConditionalReturn<ReturnType, TFallback> = TFallback extends undefined ? ReturnType | undefined : ReturnType;
94
- /**
95
- * Inferred return type for a converter.
96
- *
97
- * - `ArrayOf<E>` resolves to the element type's return as an array. When `E` is a custom
98
- * function, the function's return type drives the array element. When `E` is a scalar
99
- * token, `ConverterMap` provides the element type.
100
- * - Bare scalar tokens resolve through `ConverterMap`.
101
- * @internal
102
- */
103
- type InferConverterReturnType<TConverter> = TConverter extends ArrayOf<infer Element> ? Element extends BuiltInConverter ? ConverterMap[Element][] : Element extends CustomElementConverter<infer Returned> ? Returned[] : never : TConverter extends BuiltInConverter ? BuiltInConverterReturnType<TConverter> : never;
104
- /**
105
- * Type inference for the *fallback* slot of a converter. `Converters.Time` (scalar or array
106
- * element) accepts {@link TimeFallback} / `TimeFallback[]`; everything else mirrors the
107
- * return type. Add future asymmetric fallback/return converters to this conditional.
108
- * @internal
109
- */
110
- type InferConverterFallbackType<TConverter> = TConverter extends 'time' ? TimeFallback : TConverter extends ArrayOf<infer Element> ? Element extends 'time' ? TimeFallback[] : InferConverterReturnType<TConverter> : InferConverterReturnType<TConverter>;
111
- /**
112
- * Complete type inference for advanced converter methods
113
- * @internal
114
- */
115
- type AdvancedConverterReturn<TConverter, TFallback = undefined> = ConditionalReturn<InferConverterReturnType<TConverter>, TFallback>;
116
- /**
117
- * Type inference for primitive constructor return types
118
- * @internal
119
- */
120
- type InferPrimitiveReturnType<TConstructor extends PrimitiveConstructor> = TConstructor extends typeof String ? string : TConstructor extends typeof Number ? number : TConstructor extends typeof Boolean ? boolean : TConstructor extends typeof BigInt ? bigint : TConstructor extends typeof Symbol ? symbol : never;
121
- //#endregion
122
- export type { AdvancedConverterReturn, BuiltInConverter, BuiltInConverterFunction, ConditionalReturn, ConverterFunction, EnvaptConverter, InferConverterFallbackType, InferConverterReturnType, InferPrimitiveReturnType, JsonValue, MapOfConverterFunctions, PrimitiveConstructor, TimeFallback, TimeUnit };
123
- //# sourceMappingURL=Conversion.d.cts.map
@@ -1,125 +0,0 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
- import { ArrayOf, ConverterToken, CustomElementConverter } from "../converters/Converters.mjs";
4
-
5
- //#region src/types/Conversion.d.ts
6
- /**
7
- * Scalar built-in converter tokens (e.g. `'number'`, `'time'`).
8
- * Excludes the array builder (see {@link ArrayOf}).
9
- * @public
10
- */
11
- type BuiltInConverter = ConverterToken;
12
- /**
13
- * Primitive types supported by Envapter
14
- * @public
15
- */
16
- type PrimitiveConstructor = typeof String | typeof Number | typeof Boolean | typeof BigInt | typeof Symbol;
17
- /**
18
- * String value from a .env file or environment variable
19
- * @public
20
- */
21
- type BaseInput = string | undefined;
22
- /**
23
- * Custom parser function type for environment variables
24
- * @param raw - Raw string value from environment
25
- * @param fallback - Fallback value if parsing fails
26
- * @returns Parsed value of type T
27
- * @public
28
- */
29
- type ConverterFunction<TFallback = unknown> = (raw: BaseInput, fallback?: TFallback) => TFallback;
30
- /**
31
- * Environment variable converter: a primitive constructor, a built-in scalar token, an `ArrayOf<...>`
32
- * produced by {@link Converters.array}, or a custom parser function.
33
- * @public
34
- */
35
- type EnvaptConverter<TFallback> = PrimitiveConstructor | BuiltInConverter | ArrayOf | ConverterFunction<TFallback>;
36
- type JsonPrimitive = string | number | boolean | null;
37
- type JsonArray = JsonValue[];
38
- interface JsonObject {
39
- [key: string]: JsonValue;
40
- }
41
- /**
42
- * JSON value types for custom converters
43
- * @public
44
- */
45
- type JsonValue = JsonPrimitive | JsonArray | JsonObject;
46
- interface ConverterMap {
47
- string: string;
48
- number: number;
49
- boolean: boolean;
50
- bigint: bigint;
51
- symbol: symbol;
52
- integer: number;
53
- float: number;
54
- json: JsonValue;
55
- url: URL;
56
- regexp: RegExp;
57
- date: Date;
58
- time: number;
59
- }
60
- /**
61
- * Type mapping for built-in scalar converters to their return types
62
- * @internal
63
- */
64
- type BuiltInConverterReturnType<ConverterKey extends BuiltInConverter> = ConverterMap[ConverterKey];
65
- /**
66
- * Return type for built-in converter functions
67
- * @internal
68
- */
69
- type ReturnValuesOfConverterFunctions = ConverterMap[BuiltInConverter];
70
- /**
71
- * Function type for built-in converter functions
72
- * @internal
73
- */
74
- type BuiltInConverterFunction = (...args: Parameters<(...args: any[]) => ReturnValuesOfConverterFunctions>) => ReturnValuesOfConverterFunctions | undefined;
75
- /**
76
- * Map of built-in converter functions
77
- * @internal
78
- */
79
- type MapOfConverterFunctions = Record<BuiltInConverter, BuiltInConverterFunction>;
80
- /**
81
- * Time unit types for duration conversions
82
- * @internal
83
- */
84
- type TimeUnit = 'ms' | 's' | 'm' | 'h' | 'd' | 'w';
85
- /**
86
- * Fallback type for time duration conversions
87
- * @public
88
- */
89
- type TimeFallback = number | `${number}${TimeUnit}`;
90
- /**
91
- * Helper type for getter methods that conditionally return undefined based on whether a fallback is provided
92
- * If fallback is provided, return ReturnType. If no fallback (undefined), return ReturnType | undefined.
93
- * @internal
94
- */
95
- type ConditionalReturn<ReturnType, TFallback> = TFallback extends undefined ? ReturnType | undefined : ReturnType;
96
- /**
97
- * Inferred return type for a converter.
98
- *
99
- * - `ArrayOf<E>` resolves to the element type's return as an array. When `E` is a custom
100
- * function, the function's return type drives the array element. When `E` is a scalar
101
- * token, `ConverterMap` provides the element type.
102
- * - Bare scalar tokens resolve through `ConverterMap`.
103
- * @internal
104
- */
105
- type InferConverterReturnType<TConverter> = TConverter extends ArrayOf<infer Element> ? Element extends BuiltInConverter ? ConverterMap[Element][] : Element extends CustomElementConverter<infer Returned> ? Returned[] : never : TConverter extends BuiltInConverter ? BuiltInConverterReturnType<TConverter> : never;
106
- /**
107
- * Type inference for the *fallback* slot of a converter. `Converters.Time` (scalar or array
108
- * element) accepts {@link TimeFallback} / `TimeFallback[]`; everything else mirrors the
109
- * return type. Add future asymmetric fallback/return converters to this conditional.
110
- * @internal
111
- */
112
- type InferConverterFallbackType<TConverter> = TConverter extends 'time' ? TimeFallback : TConverter extends ArrayOf<infer Element> ? Element extends 'time' ? TimeFallback[] : InferConverterReturnType<TConverter> : InferConverterReturnType<TConverter>;
113
- /**
114
- * Complete type inference for advanced converter methods
115
- * @internal
116
- */
117
- type AdvancedConverterReturn<TConverter, TFallback = undefined> = ConditionalReturn<InferConverterReturnType<TConverter>, TFallback>;
118
- /**
119
- * Type inference for primitive constructor return types
120
- * @internal
121
- */
122
- type InferPrimitiveReturnType<TConstructor extends PrimitiveConstructor> = TConstructor extends typeof String ? string : TConstructor extends typeof Number ? number : TConstructor extends typeof Boolean ? boolean : TConstructor extends typeof BigInt ? bigint : TConstructor extends typeof Symbol ? symbol : never;
123
- //#endregion
124
- export type { AdvancedConverterReturn, BuiltInConverter, BuiltInConverterFunction, ConditionalReturn, ConverterFunction, EnvaptConverter, InferConverterFallbackType, InferConverterReturnType, InferPrimitiveReturnType, JsonValue, MapOfConverterFunctions, PrimitiveConstructor, TimeFallback, TimeUnit };
125
- //# sourceMappingURL=Conversion.d.mts.map
@@ -1,26 +0,0 @@
1
- //#region src/types/Decorator.d.ts
2
- /**
3
- * A legacy (experimentalDecorators) property decorator that also constrains the decorated field's
4
- * declared type. `Output` is the value the decorator produces. The field must be wide enough to hold
5
- * it, so a field narrower than `Output` fails to compile while a wider or nullable field is accepted.
6
- * The tuple wrap stops `Output` from distributing when it is a union.
7
- * @public
8
- */
9
- type EnvaptFieldDecorator<Output> = <Target, Key extends keyof Target>(target: Target, key: [Output] extends [Target[Key]] ? Key : {
10
- '[envapt] field type must hold the converter output': Output;
11
- }) => void;
12
- /**
13
- * A modern (TC39 Stage 3) accessor decorator that also constrains the decorated `accessor`'s
14
- * declared type. `Output` is the value the decorator produces. The accessor must be wide enough to
15
- * hold it, so an accessor narrower than `Output` fails to compile while a wider or nullable one is
16
- * accepted. The tuple wrap stops `Output` from distributing when it is a union.
17
- * @public
18
- */
19
- type EnvaptAccessorDecorator<Output> = <This, Value>(target: ClassAccessorDecoratorTarget<This, [Output] extends [Value] ? Value : {
20
- '[envapt] field type must hold the converter output': Output;
21
- }>, context: ClassAccessorDecoratorContext<This, [Output] extends [Value] ? Value : {
22
- '[envapt] field type must hold the converter output': Output;
23
- }>) => ClassAccessorDecoratorResult<This, Value>;
24
- //#endregion
25
- export { EnvaptAccessorDecorator, EnvaptFieldDecorator };
26
- //# sourceMappingURL=Decorator.d.cts.map
@@ -1,28 +0,0 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
- //#region src/types/Decorator.d.ts
4
- /**
5
- * A legacy (experimentalDecorators) property decorator that also constrains the decorated field's
6
- * declared type. `Output` is the value the decorator produces. The field must be wide enough to hold
7
- * it, so a field narrower than `Output` fails to compile while a wider or nullable field is accepted.
8
- * The tuple wrap stops `Output` from distributing when it is a union.
9
- * @public
10
- */
11
- type EnvaptFieldDecorator<Output> = <Target, Key extends keyof Target>(target: Target, key: [Output] extends [Target[Key]] ? Key : {
12
- '[envapt] field type must hold the converter output': Output;
13
- }) => void;
14
- /**
15
- * A modern (TC39 Stage 3) accessor decorator that also constrains the decorated `accessor`'s
16
- * declared type. `Output` is the value the decorator produces. The accessor must be wide enough to
17
- * hold it, so an accessor narrower than `Output` fails to compile while a wider or nullable one is
18
- * accepted. The tuple wrap stops `Output` from distributing when it is a union.
19
- * @public
20
- */
21
- type EnvaptAccessorDecorator<Output> = <This, Value>(target: ClassAccessorDecoratorTarget<This, [Output] extends [Value] ? Value : {
22
- '[envapt] field type must hold the converter output': Output;
23
- }>, context: ClassAccessorDecoratorContext<This, [Output] extends [Value] ? Value : {
24
- '[envapt] field type must hold the converter output': Output;
25
- }>) => ClassAccessorDecoratorResult<This, Value>;
26
- //#endregion
27
- export { EnvaptAccessorDecorator, EnvaptFieldDecorator };
28
- //# sourceMappingURL=Decorator.d.mts.map
@@ -1,17 +0,0 @@
1
- //#region src/types/Env.d.ts
2
- /**
3
- * Accepted shape for environment variable lookups. Either a single key or an ordered list of keys.
4
- * @public
5
- */
6
- type EnvKeyInput = string | readonly [string, ...string[]];
7
- /**
8
- * @internal
9
- */
10
- interface EnvapterService {
11
- getRaw(key: EnvKeyInput): string | undefined;
12
- get(key: EnvKeyInput, def?: string): string | undefined;
13
- isStrict(): boolean;
14
- }
15
- //#endregion
16
- export type { EnvKeyInput, EnvapterService };
17
- //# sourceMappingURL=Env.d.cts.map
@@ -1,19 +0,0 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
- //#region src/types/Env.d.ts
4
- /**
5
- * Accepted shape for environment variable lookups. Either a single key or an ordered list of keys.
6
- * @public
7
- */
8
- type EnvKeyInput = string | readonly [string, ...string[]];
9
- /**
10
- * @internal
11
- */
12
- interface EnvapterService {
13
- getRaw(key: EnvKeyInput): string | undefined;
14
- get(key: EnvKeyInput, def?: string): string | undefined;
15
- isStrict(): boolean;
16
- }
17
- //#endregion
18
- export type { EnvKeyInput, EnvapterService };
19
- //# sourceMappingURL=Env.d.mts.map
@@ -1,39 +0,0 @@
1
- import { EnvaptConverter } from "./Conversion.cjs";
2
- import { Environment } from "../core/EnvironmentMethods.cjs";
3
-
4
- //#region src/types/Options.d.ts
5
- /**
6
- * Options for the \@Envapt decorator (modern API). `required: true` is mutually exclusive
7
- * with `fallback`; see the per-converter overloads in `Envapt.ts` for the type-level mutex.
8
- * @public
9
- */
10
- interface EnvaptOptions<TFallback = string> {
11
- fallback?: TFallback;
12
- converter?: EnvaptConverter<TFallback>;
13
- required?: boolean;
14
- }
15
- /**
16
- * Per-environment profile entry passed to `Envapter.configureProfiles`.
17
- * @public
18
- */
19
- interface EnvProfile {
20
- /** One or more `.env` paths to load for this environment. Order matters: earlier paths take precedence. */
21
- paths: string | string[];
22
- }
23
- /**
24
- * Configuration object for `Envapter.configureProfiles`. Maps each `Environment` to an optional
25
- * profile override. Unspecified environments fall through to the default cascade behavior
26
- * (`.env.${env}.local`, `.env.local`, `.env.${env}`, `.env`).
27
- * @public
28
- */
29
- type ProfilesConfig = Partial<Record<Environment, EnvProfile>> & {
30
- /**
31
- * When `false`, disables the default dotenv-flow cascade entirely. Only the explicitly
32
- * configured paths are loaded. Defaults to `true` (cascade still runs, configured paths
33
- * are layered on top with higher precedence).
34
- */
35
- useDefaults?: boolean;
36
- };
37
- //#endregion
38
- export type { EnvProfile, EnvaptOptions, ProfilesConfig };
39
- //# sourceMappingURL=Options.d.cts.map
@@ -1,41 +0,0 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
- import { EnvaptConverter } from "./Conversion.mjs";
4
- import { Environment } from "../core/EnvironmentMethods.mjs";
5
-
6
- //#region src/types/Options.d.ts
7
- /**
8
- * Options for the \@Envapt decorator (modern API). `required: true` is mutually exclusive
9
- * with `fallback`; see the per-converter overloads in `Envapt.ts` for the type-level mutex.
10
- * @public
11
- */
12
- interface EnvaptOptions<TFallback = string> {
13
- fallback?: TFallback;
14
- converter?: EnvaptConverter<TFallback>;
15
- required?: boolean;
16
- }
17
- /**
18
- * Per-environment profile entry passed to `Envapter.configureProfiles`.
19
- * @public
20
- */
21
- interface EnvProfile {
22
- /** One or more `.env` paths to load for this environment. Order matters: earlier paths take precedence. */
23
- paths: string | string[];
24
- }
25
- /**
26
- * Configuration object for `Envapter.configureProfiles`. Maps each `Environment` to an optional
27
- * profile override. Unspecified environments fall through to the default cascade behavior
28
- * (`.env.${env}.local`, `.env.local`, `.env.${env}`, `.env`).
29
- * @public
30
- */
31
- type ProfilesConfig = Partial<Record<Environment, EnvProfile>> & {
32
- /**
33
- * When `false`, disables the default dotenv-flow cascade entirely. Only the explicitly
34
- * configured paths are loaded. Defaults to `true` (cascade still runs, configured paths
35
- * are layered on top with higher precedence).
36
- */
37
- useDefaults?: boolean;
38
- };
39
- //#endregion
40
- export type { EnvProfile, EnvaptOptions, ProfilesConfig };
41
- //# sourceMappingURL=Options.d.mts.map
@@ -1,12 +0,0 @@
1
- import { StandardSchemaV1 } from "../infra/StandardSchema.cjs";
2
-
3
- //#region src/types/Schema.d.ts
4
- declare const _envaptErrBrand: unique symbol;
5
- type Err<Msg extends string> = Msg & {
6
- readonly [_envaptErrBrand]: never;
7
- };
8
- type SchemaMustBeSync = Err<'Schema must be synchronous. envapt is boot-time config loading; async refinements (validate returning `Promise<Result>`) belong outside the env layer.'>;
9
- type SchemaConstraint<Schema extends StandardSchemaV1> = ReturnType<Schema['~standard']['validate']> extends Promise<unknown> ? SchemaMustBeSync : Schema;
10
- //#endregion
11
- export type { Err, SchemaConstraint, SchemaMustBeSync };
12
- //# sourceMappingURL=Schema.d.cts.map
@@ -1,14 +0,0 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
- import { StandardSchemaV1 } from "../infra/StandardSchema.mjs";
4
-
5
- //#region src/types/Schema.d.ts
6
- declare const _envaptErrBrand: unique symbol;
7
- type Err<Msg extends string> = Msg & {
8
- readonly [_envaptErrBrand]: never;
9
- };
10
- type SchemaMustBeSync = Err<'Schema must be synchronous. envapt is boot-time config loading; async refinements (validate returning `Promise<Result>`) belong outside the env layer.'>;
11
- type SchemaConstraint<Schema extends StandardSchemaV1> = ReturnType<Schema['~standard']['validate']> extends Promise<unknown> ? SchemaMustBeSync : Schema;
12
- //#endregion
13
- export type { Err, SchemaConstraint, SchemaMustBeSync };
14
- //# sourceMappingURL=Schema.d.mts.map
@@ -1,44 +0,0 @@
1
- //#region src/types/Source.d.ts
2
- /**
3
- * A source with no filesystem: an injected object on the browser, or the Cloudflare `env` binding on
4
- * Workers. The `.env` cascade, profiles, and the `envPaths`/`baseDir`/`configureProfiles` APIs do not
5
- * apply; only `readVars()` populates the cache.
6
- * @public
7
- */
8
- interface BareEnvSource {
9
- /** Return every variable this source provides, as plain strings. */
10
- readVars(): Record<string, string>;
11
- /** Leave unset (or `false`); a bare source has no filesystem. */
12
- readonly supportsFiles?: false;
13
- }
14
- /**
15
- * A filesystem-backed source, like the default {@link NodeEnvSource}. Setting `supportsFiles` to
16
- * `true` requires all four file capabilities, so the engine can load the `.env` cascade, resolve
17
- * `baseDir`, and mirror loaded keys back to the ambient environment.
18
- * @public
19
- */
20
- interface FileEnvSource {
21
- /** Return every variable this source provides, as plain strings. */
22
- readVars(): Record<string, string>;
23
- /** When `true`, the engine loads the `.env` cascade, profiles, and `envPaths` through the methods below. */
24
- readonly supportsFiles: true;
25
- /** Read a file's text, or `undefined` when it is absent or unreadable. Backs the loader and existence checks. */
26
- readFile(path: string, encoding: string): string | undefined;
27
- /** Join a relative `.env` path onto `baseDir`; absolute paths are returned unchanged. */
28
- resolvePath(baseDir: string, candidate: string): string;
29
- /** Normalize a `baseDir` value (a directory path, or a module / `file:` URL) to an absolute directory path. */
30
- normalizeBaseDir(value: string | URL): string;
31
- /** Mirror loaded keys back to the ambient environment (e.g. `process.env`); backs `Envapter.syncProcessEnv`. */
32
- writeVars(vars: Record<string, string>): void;
33
- }
34
- /**
35
- * A pluggable source of environment variables. The default {@link NodeEnvSource} (a
36
- * {@link FileEnvSource}) reads `process.env` plus the `.env` cascade; a {@link BareEnvSource} lets the
37
- * same engine run where there is no ambient environment (an injected object on the browser, the
38
- * Cloudflare `env` binding on Workers). Bind one with `Envapter.useSource`.
39
- * @public
40
- */
41
- type EnvSource = BareEnvSource | FileEnvSource;
42
- //#endregion
43
- export type { BareEnvSource, EnvSource, FileEnvSource };
44
- //# sourceMappingURL=Source.d.cts.map
@@ -1,46 +0,0 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
- //#region src/types/Source.d.ts
4
- /**
5
- * A source with no filesystem: an injected object on the browser, or the Cloudflare `env` binding on
6
- * Workers. The `.env` cascade, profiles, and the `envPaths`/`baseDir`/`configureProfiles` APIs do not
7
- * apply; only `readVars()` populates the cache.
8
- * @public
9
- */
10
- interface BareEnvSource {
11
- /** Return every variable this source provides, as plain strings. */
12
- readVars(): Record<string, string>;
13
- /** Leave unset (or `false`); a bare source has no filesystem. */
14
- readonly supportsFiles?: false;
15
- }
16
- /**
17
- * A filesystem-backed source, like the default {@link NodeEnvSource}. Setting `supportsFiles` to
18
- * `true` requires all four file capabilities, so the engine can load the `.env` cascade, resolve
19
- * `baseDir`, and mirror loaded keys back to the ambient environment.
20
- * @public
21
- */
22
- interface FileEnvSource {
23
- /** Return every variable this source provides, as plain strings. */
24
- readVars(): Record<string, string>;
25
- /** When `true`, the engine loads the `.env` cascade, profiles, and `envPaths` through the methods below. */
26
- readonly supportsFiles: true;
27
- /** Read a file's text, or `undefined` when it is absent or unreadable. Backs the loader and existence checks. */
28
- readFile(path: string, encoding: string): string | undefined;
29
- /** Join a relative `.env` path onto `baseDir`; absolute paths are returned unchanged. */
30
- resolvePath(baseDir: string, candidate: string): string;
31
- /** Normalize a `baseDir` value (a directory path, or a module / `file:` URL) to an absolute directory path. */
32
- normalizeBaseDir(value: string | URL): string;
33
- /** Mirror loaded keys back to the ambient environment (e.g. `process.env`); backs `Envapter.syncProcessEnv`. */
34
- writeVars(vars: Record<string, string>): void;
35
- }
36
- /**
37
- * A pluggable source of environment variables. The default {@link NodeEnvSource} (a
38
- * {@link FileEnvSource}) reads `process.env` plus the `.env` cascade; a {@link BareEnvSource} lets the
39
- * same engine run where there is no ambient environment (an injected object on the browser, the
40
- * Cloudflare `env` binding on Workers). Bind one with `Envapter.useSource`.
41
- * @public
42
- */
43
- type EnvSource = BareEnvSource | FileEnvSource;
44
- //#endregion
45
- export type { BareEnvSource, EnvSource, FileEnvSource };
46
- //# sourceMappingURL=Source.d.mts.map
@@ -1,93 +0,0 @@
1
- //#region src/converters/Converters.d.ts
2
- declare const SCALAR: {
3
- readonly String: "string";
4
- readonly Number: "number";
5
- readonly Boolean: "boolean";
6
- readonly Bigint: "bigint";
7
- readonly Symbol: "symbol";
8
- readonly Integer: "integer";
9
- readonly Float: "float";
10
- readonly Json: "json";
11
- readonly Url: "url";
12
- readonly Regexp: "regexp";
13
- readonly Date: "date";
14
- readonly Time: "time";
15
- };
16
- /**
17
- * String tokens for every built-in scalar converter.
18
- * @public
19
- */
20
- type ConverterToken = (typeof SCALAR)[keyof typeof SCALAR];
21
- /**
22
- * Custom element converter for use inside {@link Converters.array}. Receives the trimmed,
23
- * non-empty raw string for one array slot and returns the parsed value.
24
- * @public
25
- */
26
- type CustomElementConverter<TReturn = unknown> = (raw: string) => TReturn;
27
- /**
28
- * Valid element converters for {@link Converters.array}: any scalar token except
29
- * `json` and `regexp` (those don't compose as array elements), or a custom function.
30
- * @public
31
- */
32
- type ArrayElement = Exclude<ConverterToken, 'json' | 'regexp'> | CustomElementConverter;
33
- /**
34
- * Phantom-branded token produced by {@link Converters.array}. The `T` type parameter carries
35
- * the element converter through any variable indirection so inference survives. The
36
- * `__envaptKind` discriminant is present at runtime for dispatch.
37
- * @public
38
- */
39
- interface ArrayOf<TElement extends ArrayElement = ArrayElement> {
40
- readonly __envaptKind: 'array';
41
- readonly of: TElement;
42
- readonly delimiter: string;
43
- }
44
- /**
45
- * Runtime type guard for tokens produced by {@link Converters.array}.
46
- * @internal
47
- */
48
- declare function isArrayOf(value: unknown): value is ArrayOf;
49
- type ArrayScalarElement = Exclude<ConverterToken, 'json' | 'regexp'>;
50
- declare function buildArrayConverter<TReturn>(opts: {
51
- of: CustomElementConverter<TReturn>;
52
- delimiter?: string;
53
- }): ArrayOf<CustomElementConverter<TReturn>>;
54
- declare function buildArrayConverter<TToken extends ArrayScalarElement>(opts: {
55
- of: TToken;
56
- delimiter?: string;
57
- }): ArrayOf<TToken>;
58
- declare function buildArrayConverter(opts?: {
59
- delimiter?: string;
60
- }): ArrayOf<'string'>;
61
- /**
62
- * Built-in converters for environment variables. Use the scalar tokens (e.g. `Converters.Number`)
63
- * for primitive types and the {@link Converters.array} builder for delimited lists.
64
- *
65
- * @example
66
- * ```ts
67
- * \@Envapt('PORT', { converter: Converters.Number, fallback: 3000 })
68
- * static readonly port: number;
69
- *
70
- * \@Envapt('TAGS', { converter: Converters.array({ of: Converters.String, delimiter: ' ' }) })
71
- * static readonly tags: string[];
72
- * ```
73
- *
74
- * @public
75
- */
76
- declare const Converters: {
77
- readonly array: typeof buildArrayConverter;
78
- readonly String: "string";
79
- readonly Number: "number";
80
- readonly Boolean: "boolean";
81
- readonly Bigint: "bigint";
82
- readonly Symbol: "symbol";
83
- readonly Integer: "integer";
84
- readonly Float: "float";
85
- readonly Json: "json";
86
- readonly Url: "url";
87
- readonly Regexp: "regexp";
88
- readonly Date: "date";
89
- readonly Time: "time";
90
- };
91
- //#endregion
92
- export { ArrayElement, ArrayOf, ConverterToken, Converters, CustomElementConverter, isArrayOf };
93
- //# sourceMappingURL=Converters.d.mts.map
@@ -1,25 +0,0 @@
1
- import { EnvaptConverter } from "../types/Conversion.mjs";
2
- import { StandardSchemaV1 } from "../infra/StandardSchema.mjs";
3
- import { EnvKeyInput, EnvapterService } from "../types/Env.mjs";
4
-
5
- //#region src/converters/ValueConverter.d.ts
6
- /**
7
- * Convert a resolved environment value to its declared type via built-in, primitive, array,
8
- * custom, or Standard Schema converters.
9
- * @internal
10
- */
11
- declare class ValueConverter {
12
- private readonly envService;
13
- constructor(envService: EnvapterService);
14
- convertValue<TFallback>(key: EnvKeyInput, fallback: TFallback | undefined, converter: EnvaptConverter<TFallback> | undefined, hasFallback: boolean): TFallback | null | undefined;
15
- private processFallbackForConverter;
16
- private convertPrimitiveToString;
17
- private processBuiltInConverter;
18
- private processArrayConverter;
19
- private processCustomConverter;
20
- private resolveConverter;
21
- convertWithSchema(key: EnvKeyInput, schema: StandardSchemaV1, fallback: unknown, hasFallback: boolean): unknown;
22
- }
23
- //#endregion
24
- export { ValueConverter };
25
- //# sourceMappingURL=ValueConverter.d.mts.map