envapt 7.0.0-next.0 → 7.0.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/browser/index.mjs.map +1 -1
  3. package/dist/{node → types}/engine/NodeEnvapter.d.mts +0 -2
  4. package/dist/{node → types}/index.d.mts +0 -2
  5. package/dist/{node/sources/NodeEnvSource.d.cts → types/sources/NodeEnvSource.d.mts} +2 -2
  6. package/package.json +23 -19
  7. package/dist/node/config.d.mts +0 -2
  8. package/dist/node/converters/Converters.d.cts +0 -93
  9. package/dist/node/converters/Converters.d.mts +0 -95
  10. package/dist/node/converters/ValueConverter.d.cts +0 -25
  11. package/dist/node/converters/ValueConverter.d.mts +0 -27
  12. package/dist/node/core/AdvancedMethods.d.cts +0 -76
  13. package/dist/node/core/AdvancedMethods.d.mts +0 -78
  14. package/dist/node/core/EnvapterBase.d.cts +0 -75
  15. package/dist/node/core/EnvapterBase.d.mts +0 -77
  16. package/dist/node/core/EnvironmentMethods.d.cts +0 -115
  17. package/dist/node/core/EnvironmentMethods.d.mts +0 -117
  18. package/dist/node/core/PrimitiveMethods.d.cts +0 -70
  19. package/dist/node/core/PrimitiveMethods.d.mts +0 -72
  20. package/dist/node/decorators/legacy/Envapt.d.cts +0 -218
  21. package/dist/node/decorators/legacy/Envapt.d.mts +0 -220
  22. package/dist/node/decorators/legacy/SugarDecorators.d.cts +0 -40
  23. package/dist/node/decorators/legacy/SugarDecorators.d.mts +0 -42
  24. package/dist/node/decorators/modern/Envapt.d.cts +0 -218
  25. package/dist/node/decorators/modern/Envapt.d.mts +0 -220
  26. package/dist/node/decorators/modern/SugarDecorators.d.cts +0 -40
  27. package/dist/node/decorators/modern/SugarDecorators.d.mts +0 -42
  28. package/dist/node/engine/Envapter.d.cts +0 -70
  29. package/dist/node/engine/Envapter.d.mts +0 -72
  30. package/dist/node/engine/NodeEnvapter.d.cts +0 -73
  31. package/dist/node/engine/TemplateResolver.d.cts +0 -17
  32. package/dist/node/engine/TemplateResolver.d.mts +0 -19
  33. package/dist/node/index.d.cts +0 -19
  34. package/dist/node/infra/Debug.d.cts +0 -13
  35. package/dist/node/infra/Debug.d.mts +0 -15
  36. package/dist/node/infra/Dotenv.d.cts +0 -17
  37. package/dist/node/infra/Dotenv.d.mts +0 -19
  38. package/dist/node/infra/Error.d.cts +0 -72
  39. package/dist/node/infra/Error.d.mts +0 -74
  40. package/dist/node/infra/StandardSchema.d.cts +0 -59
  41. package/dist/node/infra/StandardSchema.d.mts +0 -61
  42. package/dist/node/legacy.d.cts +0 -4
  43. package/dist/node/legacy.d.mts +0 -6
  44. package/dist/node/sources/ManualEnvSource.d.cts +0 -19
  45. package/dist/node/sources/ManualEnvSource.d.mts +0 -21
  46. package/dist/node/sources/NodeEnvSource.d.mts +0 -22
  47. package/dist/node/sources/WorkerEnvSource.d.cts +0 -19
  48. package/dist/node/sources/WorkerEnvSource.d.mts +0 -21
  49. package/dist/node/types/Conversion.d.cts +0 -123
  50. package/dist/node/types/Conversion.d.mts +0 -125
  51. package/dist/node/types/Decorator.d.cts +0 -26
  52. package/dist/node/types/Decorator.d.mts +0 -28
  53. package/dist/node/types/Env.d.cts +0 -17
  54. package/dist/node/types/Env.d.mts +0 -19
  55. package/dist/node/types/Options.d.cts +0 -39
  56. package/dist/node/types/Options.d.mts +0 -41
  57. package/dist/node/types/Schema.d.cts +0 -12
  58. package/dist/node/types/Schema.d.mts +0 -14
  59. package/dist/node/types/Source.d.cts +0 -44
  60. package/dist/node/types/Source.d.mts +0 -46
  61. package/dist/workerd/converters/Converters.d.mts +0 -93
  62. package/dist/workerd/converters/ValueConverter.d.mts +0 -25
  63. package/dist/workerd/core/AdvancedMethods.d.mts +0 -76
  64. package/dist/workerd/core/EnvapterBase.d.mts +0 -75
  65. package/dist/workerd/core/EnvironmentMethods.d.mts +0 -115
  66. package/dist/workerd/core/PrimitiveMethods.d.mts +0 -70
  67. package/dist/workerd/decorators/legacy/Envapt.d.mts +0 -218
  68. package/dist/workerd/decorators/legacy/SugarDecorators.d.mts +0 -40
  69. package/dist/workerd/decorators/modern/Envapt.d.mts +0 -218
  70. package/dist/workerd/decorators/modern/SugarDecorators.d.mts +0 -40
  71. package/dist/workerd/engine/Envapter.d.mts +0 -70
  72. package/dist/workerd/engine/TemplateResolver.d.mts +0 -17
  73. package/dist/workerd/index.d.mts +0 -18
  74. package/dist/workerd/infra/Debug.d.mts +0 -13
  75. package/dist/workerd/infra/Dotenv.d.mts +0 -17
  76. package/dist/workerd/infra/Error.d.mts +0 -72
  77. package/dist/workerd/infra/StandardSchema.d.mts +0 -59
  78. package/dist/workerd/legacy.d.mts +0 -4
  79. package/dist/workerd/sources/ManualEnvSource.d.mts +0 -19
  80. package/dist/workerd/sources/WorkerEnvSource.d.mts +0 -19
  81. package/dist/workerd/types/Conversion.d.mts +0 -123
  82. package/dist/workerd/types/Decorator.d.mts +0 -26
  83. package/dist/workerd/types/Env.d.mts +0 -17
  84. package/dist/workerd/types/Options.d.mts +0 -39
  85. package/dist/workerd/types/Schema.d.mts +0 -12
  86. package/dist/workerd/types/Source.d.mts +0 -44
  87. /package/dist/{node/config.d.cts → types/config.d.mts} +0 -0
  88. /package/dist/{browser → types}/converters/Converters.d.mts +0 -0
  89. /package/dist/{browser → types}/converters/ValueConverter.d.mts +0 -0
  90. /package/dist/{browser → types}/core/AdvancedMethods.d.mts +0 -0
  91. /package/dist/{browser → types}/core/EnvapterBase.d.mts +0 -0
  92. /package/dist/{browser → types}/core/EnvironmentMethods.d.mts +0 -0
  93. /package/dist/{browser → types}/core/PrimitiveMethods.d.mts +0 -0
  94. /package/dist/{browser → types}/decorators/legacy/Envapt.d.mts +0 -0
  95. /package/dist/{browser → types}/decorators/legacy/SugarDecorators.d.mts +0 -0
  96. /package/dist/{browser → types}/decorators/modern/Envapt.d.mts +0 -0
  97. /package/dist/{browser → types}/decorators/modern/SugarDecorators.d.mts +0 -0
  98. /package/dist/{browser → types}/engine/Envapter.d.mts +0 -0
  99. /package/dist/{browser → types}/engine/TemplateResolver.d.mts +0 -0
  100. /package/dist/{browser/index.d.mts → types/index.portable.d.mts} +0 -0
  101. /package/dist/{browser → types}/infra/Debug.d.mts +0 -0
  102. /package/dist/{browser → types}/infra/Dotenv.d.mts +0 -0
  103. /package/dist/{browser → types}/infra/Error.d.mts +0 -0
  104. /package/dist/{browser → types}/infra/StandardSchema.d.mts +0 -0
  105. /package/dist/{browser → types}/legacy.d.mts +0 -0
  106. /package/dist/{browser → types}/sources/ManualEnvSource.d.mts +0 -0
  107. /package/dist/{browser → types}/sources/WorkerEnvSource.d.mts +0 -0
  108. /package/dist/{browser → types}/types/Conversion.d.mts +0 -0
  109. /package/dist/{browser → types}/types/Decorator.d.mts +0 -0
  110. /package/dist/{browser → types}/types/Env.d.mts +0 -0
  111. /package/dist/{browser → types}/types/Options.d.mts +0 -0
  112. /package/dist/{browser → types}/types/Schema.d.mts +0 -0
  113. /package/dist/{browser → types}/types/Source.d.mts +0 -0
@@ -1,220 +0,0 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
- import { ArrayOf } from "../../converters/Converters.mjs";
4
- import { BuiltInConverter, ConverterFunction, InferConverterFallbackType, InferConverterReturnType, InferPrimitiveReturnType, PrimitiveConstructor } from "../../types/Conversion.mjs";
5
- import { InferSchemaOutput, StandardSchemaV1 } from "../../infra/StandardSchema.mjs";
6
- import { SchemaConstraint } from "../../types/Schema.mjs";
7
- import { EnvKeyInput } from "../../types/Env.mjs";
8
- import { EnvaptAccessorDecorator } from "../../types/Decorator.mjs";
9
-
10
- //#region src/decorators/modern/Envapt.d.ts
11
- /**
12
- * A custom converter function with a fallback (both required), or a fallback only.
13
- *
14
- * @param key - Environment variable name(s) to load
15
- * @param options - Configuration options
16
- * @public
17
- * @example
18
- * ```ts
19
- * class Config {
20
- * \@Envapt('API_KEY', {
21
- * fallback: 'default-key',
22
- * converter(raw, _fallback) {
23
- * if (!raw || raw.trim() === '') throw new Error('API_KEY required');
24
- * return raw.trim();
25
- * }
26
- * })
27
- * static accessor apiKey: string;
28
- *
29
- * \@Envapt('LOG_FILE', { fallback: '/var/log/app.log' })
30
- * static accessor logFile: string;
31
- *
32
- * \@Envapt('RETRY_POLICY', { fallback: { retries: 3, backoff: 'exponential' } })
33
- * static accessor retryPolicy: unknown;
34
- * }
35
- * ```
36
- */
37
- declare function Envapt(key: EnvKeyInput, options: {
38
- fallback: undefined;
39
- converter?: undefined;
40
- }): EnvaptAccessorDecorator<string | undefined>;
41
- declare function Envapt<TFallback>(key: EnvKeyInput, options: {
42
- converter: (raw: string | undefined, fallback: TFallback) => TFallback;
43
- fallback: TFallback;
44
- } | {
45
- fallback: TFallback;
46
- converter?: undefined;
47
- }): EnvaptAccessorDecorator<TFallback>;
48
- /**
49
- * A custom converter function without a fallback. Omit `required` to return the converter's
50
- * output (possibly `undefined`), or pass `required: true` to throw `MissingEnvValue` on
51
- * missing or empty values.
52
- *
53
- * @param key - Environment variable name(s) to load
54
- * @param options - Configuration options
55
- * @public
56
- * @example
57
- * ```ts
58
- * class Config {
59
- * \@Envapt('FEATURE_FLAGS', { converter(raw) {
60
- * return raw ? raw.split('|').map(s => s.trim()) : [];
61
- * } })
62
- * static accessor featureFlags: string[];
63
- *
64
- * \@Envapt('JWT_SECRET', {
65
- * converter: (raw) => Buffer.from(raw ?? '', 'base64'),
66
- * required: true
67
- * })
68
- * static accessor jwtSecret: Buffer;
69
- * }
70
- * ```
71
- */
72
- declare function Envapt<TReturnType>(key: EnvKeyInput, options: {
73
- converter: ConverterFunction<TReturnType>;
74
- required?: false;
75
- } | {
76
- converter: ConverterFunction<TReturnType>;
77
- required: true;
78
- }): EnvaptAccessorDecorator<TReturnType>;
79
- /**
80
- * A built-in or array converter with a fallback, or `required: true`. The fallback type tracks
81
- * the converter, so `Converters.Time` takes a number or time-string and `Converters.Url` takes
82
- * a `URL` instance.
83
- *
84
- * @param key - Environment variable name(s) to load
85
- * @param options - Configuration options
86
- * @public
87
- * @example
88
- * ```ts
89
- * import { Converters } from 'envapt';
90
- *
91
- * class Config {
92
- * \@Envapt('APP_PORT', { converter: Converters.Number, fallback: 3000 })
93
- * static accessor port: number;
94
- *
95
- * // the Url fallback is a URL instance, not a string
96
- * \@Envapt('APP_URL', { converter: Converters.Url, fallback: new URL('http://localhost:3000') })
97
- * static accessor url: URL;
98
- *
99
- * // prefers CANARY_URL when present, otherwise APP_URL
100
- * \@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })
101
- * static accessor canaryUrl: URL | null;
102
- *
103
- * // Time takes a number (milliseconds) or a time-string fallback (`<number><unit>`)
104
- * \@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })
105
- * static accessor requestTimeout: number;
106
- *
107
- * \@Envapt('ALLOWED_ORIGINS', {
108
- * converter: Converters.array({ of: Converters.String }),
109
- * fallback: ['https://example.com']
110
- * })
111
- * static accessor allowedOrigins: string[];
112
- *
113
- * \@Envapt('DATABASE_URL', { converter: Converters.Url, required: true })
114
- * static accessor databaseUrl: URL;
115
- * }
116
- * ```
117
- */
118
- declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
119
- converter: TConverter;
120
- fallback: InferConverterFallbackType<TConverter>;
121
- required?: false;
122
- } | {
123
- converter: TConverter;
124
- required: true;
125
- }): EnvaptAccessorDecorator<InferConverterReturnType<TConverter>>;
126
- declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
127
- converter: TConverter;
128
- fallback: undefined;
129
- required?: false;
130
- }): EnvaptAccessorDecorator<InferConverterReturnType<TConverter> | undefined>;
131
- declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
132
- converter: TConverter;
133
- required?: false;
134
- }): EnvaptAccessorDecorator<InferConverterReturnType<TConverter> | null>;
135
- /**
136
- * A primitive constructor (`Number`, `Boolean`) with an optional fallback.
137
- *
138
- * @param key - Environment variable name(s) to load
139
- * @param options - Configuration options
140
- * @public
141
- * @example
142
- * ```ts
143
- * class Config {
144
- * \@Envapt('MAX_CONNECTIONS', { converter: Number, fallback: 100 })
145
- * static accessor maxConnections: number;
146
- *
147
- * \@Envapt('FEATURE_ENABLED', { converter: Boolean, fallback: false })
148
- * static accessor featureEnabled: boolean;
149
- * }
150
- * ```
151
- */
152
- declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
153
- converter: TConstructor;
154
- fallback: InferPrimitiveReturnType<TConstructor>;
155
- required?: false;
156
- } | {
157
- converter: TConstructor;
158
- required: true;
159
- }): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor>>;
160
- declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
161
- converter: TConstructor;
162
- fallback: undefined;
163
- required?: false;
164
- }): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor> | undefined>;
165
- declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
166
- converter: TConstructor;
167
- required?: false;
168
- }): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor> | null>;
169
- /**
170
- * Required, no converter (raw string). Throws `MissingEnvValue` on first access when the env
171
- * value is missing or empty after trimming, independent of the global `Envapter.strict` flag.
172
- * Pairing `required: true` with `fallback` matches no overload at compile time, and the runtime
173
- * Validator rejects dynamic objects that bypass the types.
174
- *
175
- * @param key - Environment variable name(s) to load
176
- * @param options - `{ required: true }`
177
- * @public
178
- * @example
179
- * ```ts
180
- * class Config {
181
- * \@Envapt('API_KEY', { required: true })
182
- * static accessor apiKey: string;
183
- * }
184
- * ```
185
- */
186
- declare function Envapt(key: EnvKeyInput, options: {
187
- required: true;
188
- }): EnvaptAccessorDecorator<string>;
189
- /**
190
- * No-fallback form. The property resolves from env or `null`.
191
- *
192
- * @param key - Environment variable name(s) to load
193
- * @public
194
- * @example
195
- * ```ts
196
- * class Config {
197
- * \@Envapt('SIMPLE_VALUE')
198
- * static accessor simple: string | null;
199
- * }
200
- * ```
201
- */
202
- declare function Envapt(key: EnvKeyInput): EnvaptAccessorDecorator<string | null>;
203
- /**
204
- * A Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous schemas only,
205
- * so a Promise-returning `validate` throws `InvalidUserDefinedConfig` at runtime. Pairing
206
- * `schema` with `converter` matches no overload at compile time, and the runtime Validator
207
- * rejects dynamic objects that bypass the types.
208
- * @public
209
- */
210
- declare function Envapt<Schema extends StandardSchemaV1>(key: EnvKeyInput, options: {
211
- schema: SchemaConstraint<Schema>;
212
- fallback?: InferSchemaOutput<Schema>;
213
- required?: false;
214
- } | {
215
- schema: SchemaConstraint<Schema>;
216
- required: true;
217
- }): EnvaptAccessorDecorator<InferSchemaOutput<Schema>>;
218
- //#endregion
219
- export { Envapt };
220
- //# sourceMappingURL=Envapt.d.mts.map
@@ -1,40 +0,0 @@
1
- import { TimeFallback } from "../../types/Conversion.cjs";
2
- import { EnvKeyInput } from "../../types/Env.cjs";
3
- import { EnvaptAccessorDecorator } from "../../types/Decorator.cjs";
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.cts.map
@@ -1,42 +0,0 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
- import { TimeFallback } from "../../types/Conversion.mjs";
4
- import { EnvKeyInput } from "../../types/Env.mjs";
5
- import { EnvaptAccessorDecorator } from "../../types/Decorator.mjs";
6
-
7
- //#region src/decorators/modern/SugarDecorators.d.ts
8
- /**
9
- * Shorthand for `@Envapt(key, { converter: Converters.Boolean, fallback })`.
10
- * @public
11
- */
12
- declare function EnvBool(key: EnvKeyInput, fallback: boolean): EnvaptAccessorDecorator<boolean>;
13
- declare function EnvBool(key: EnvKeyInput): EnvaptAccessorDecorator<boolean | null>;
14
- /**
15
- * Shorthand for `@Envapt(key, { converter: Converters.Number, fallback })`.
16
- * @public
17
- */
18
- declare function EnvNum(key: EnvKeyInput, fallback: number): EnvaptAccessorDecorator<number>;
19
- declare function EnvNum(key: EnvKeyInput): EnvaptAccessorDecorator<number | null>;
20
- /**
21
- * Shorthand for `@Envapt(key, { converter: Converters.String, fallback })`.
22
- * @public
23
- */
24
- declare function EnvStr(key: EnvKeyInput, fallback: string): EnvaptAccessorDecorator<string>;
25
- declare function EnvStr(key: EnvKeyInput): EnvaptAccessorDecorator<string | null>;
26
- /**
27
- * Shorthand for `@Envapt(key, { converter: Converters.Time, fallback })`. The fallback is a
28
- * millisecond number or a time string (`'15m'`), and the resolved value is always milliseconds.
29
- * @public
30
- */
31
- declare function EnvTime(key: EnvKeyInput, fallback: TimeFallback): EnvaptAccessorDecorator<number>;
32
- declare function EnvTime(key: EnvKeyInput): EnvaptAccessorDecorator<number | null>;
33
- /**
34
- * Shorthand for `@Envapt(key, { converter: Converters.Url, fallback })`. The fallback is a `URL`
35
- * instance, not a URL string.
36
- * @public
37
- */
38
- declare function EnvUrl(key: EnvKeyInput, fallback: URL): EnvaptAccessorDecorator<URL>;
39
- declare function EnvUrl(key: EnvKeyInput): EnvaptAccessorDecorator<URL | null>;
40
- //#endregion
41
- export { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl };
42
- //# sourceMappingURL=SugarDecorators.d.mts.map
@@ -1,70 +0,0 @@
1
- import { Environment } from "../core/EnvironmentMethods.cjs";
2
- import { AdvancedMethods } from "../core/AdvancedMethods.cjs";
3
-
4
- //#region src/engine/Envapter.d.ts
5
- /**
6
- * Main configuration class for environment variable management.
7
- *
8
- * Provides both static and instance methods for retrieving typed environment variables
9
- * with support for template resolution, multiple .env files, and environment detection.
10
- *
11
- * Extend your own classes from this to define properties with \@Envapt decorators and get access to environment-variable methods.
12
- *
13
- * @example
14
- * ```ts
15
- * // Static usage
16
- * const port = Envapter.getNumber('PORT', 3000);
17
- * const url = Envapter.get('API_URL', 'http://localhost');
18
- * const replica = Envapter.get(['READONLY_URL', 'DATABASE_URL'], 'sqlite://memory');
19
- *
20
- * // Instance usage
21
- * const env = new Envapter();
22
- * const dbUrl = env.get('DATABASE_URL', 'sqlite://memory');
23
- * const primaryHost = env.get(['PRIMARY_HOST', 'SECONDARY_HOST']);
24
- * ```
25
- *
26
- * @public
27
- */
28
- declare class Envapter extends AdvancedMethods {
29
- /**
30
- * Tagged template literal for resolving environment variables in template strings.
31
- *
32
- * @example
33
- * ```ts
34
- * // Given API_HOST=api.example.com and API_PORT=8080 in environment
35
- * const endpoint = Envapter.resolve`Connecting to ${'API_HOST'}:${'API_PORT'}`;
36
- * // Returns: "Connecting to api.example.com:8080"
37
- *
38
- * // Works with template variables in .env too:
39
- * // API_URL=https://${API_HOST}:${API_PORT}
40
- * const message = Envapter.resolve`Service endpoint: ${'API_URL'}`;
41
- * // Returns: "Service endpoint: https://api.example.com:8080"
42
- * ```
43
- */
44
- static resolve(strings: TemplateStringsArray, ...keys: string[]): string;
45
- /**
46
- * @see {@link Envapter.resolve}
47
- */
48
- resolve(strings: TemplateStringsArray, ...keys: string[]): string;
49
- /**
50
- * Assert that one or more environment variables are present and non-empty (post-trim,
51
- * after template resolution). Throws `MissingEnvValue` listing every missing key.
52
- *
53
- * For typed fail-fast in functional code, use `Envapter.getUsing(key, { converter, required: true })`.
54
- *
55
- * @example
56
- * ```ts
57
- * Envapter.require('DATABASE_URL');
58
- * Envapter.require('DATABASE_URL', 'API_KEY', 'SENTRY_DSN');
59
- * ```
60
- */
61
- static require(...keys: [string, ...string[]]): void;
62
- private static resolveAndValidate;
63
- /**
64
- * @see {@link Envapter.require}
65
- */
66
- require(...keys: [string, ...string[]]): void;
67
- }
68
- //#endregion
69
- export { Envapter };
70
- //# sourceMappingURL=Envapter.d.cts.map
@@ -1,72 +0,0 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
- import { Environment } from "../core/EnvironmentMethods.mjs";
4
- import { AdvancedMethods } from "../core/AdvancedMethods.mjs";
5
-
6
- //#region src/engine/Envapter.d.ts
7
- /**
8
- * Main configuration class for environment variable management.
9
- *
10
- * Provides both static and instance methods for retrieving typed environment variables
11
- * with support for template resolution, multiple .env files, and environment detection.
12
- *
13
- * Extend your own classes from this to define properties with \@Envapt decorators and get access to environment-variable methods.
14
- *
15
- * @example
16
- * ```ts
17
- * // Static usage
18
- * const port = Envapter.getNumber('PORT', 3000);
19
- * const url = Envapter.get('API_URL', 'http://localhost');
20
- * const replica = Envapter.get(['READONLY_URL', 'DATABASE_URL'], 'sqlite://memory');
21
- *
22
- * // Instance usage
23
- * const env = new Envapter();
24
- * const dbUrl = env.get('DATABASE_URL', 'sqlite://memory');
25
- * const primaryHost = env.get(['PRIMARY_HOST', 'SECONDARY_HOST']);
26
- * ```
27
- *
28
- * @public
29
- */
30
- declare class Envapter extends AdvancedMethods {
31
- /**
32
- * Tagged template literal for resolving environment variables in template strings.
33
- *
34
- * @example
35
- * ```ts
36
- * // Given API_HOST=api.example.com and API_PORT=8080 in environment
37
- * const endpoint = Envapter.resolve`Connecting to ${'API_HOST'}:${'API_PORT'}`;
38
- * // Returns: "Connecting to api.example.com:8080"
39
- *
40
- * // Works with template variables in .env too:
41
- * // API_URL=https://${API_HOST}:${API_PORT}
42
- * const message = Envapter.resolve`Service endpoint: ${'API_URL'}`;
43
- * // Returns: "Service endpoint: https://api.example.com:8080"
44
- * ```
45
- */
46
- static resolve(strings: TemplateStringsArray, ...keys: string[]): string;
47
- /**
48
- * @see {@link Envapter.resolve}
49
- */
50
- resolve(strings: TemplateStringsArray, ...keys: string[]): string;
51
- /**
52
- * Assert that one or more environment variables are present and non-empty (post-trim,
53
- * after template resolution). Throws `MissingEnvValue` listing every missing key.
54
- *
55
- * For typed fail-fast in functional code, use `Envapter.getUsing(key, { converter, required: true })`.
56
- *
57
- * @example
58
- * ```ts
59
- * Envapter.require('DATABASE_URL');
60
- * Envapter.require('DATABASE_URL', 'API_KEY', 'SENTRY_DSN');
61
- * ```
62
- */
63
- static require(...keys: [string, ...string[]]): void;
64
- private static resolveAndValidate;
65
- /**
66
- * @see {@link Envapter.require}
67
- */
68
- require(...keys: [string, ...string[]]): void;
69
- }
70
- //#endregion
71
- export { Envapter };
72
- //# sourceMappingURL=Envapter.d.mts.map
@@ -1,73 +0,0 @@
1
- import { EnvFileOptions } from "../infra/Dotenv.cjs";
2
- import { ProfilesConfig } from "../types/Options.cjs";
3
- import { Envapter } from "./Envapter.cjs";
4
-
5
- //#region src/engine/NodeEnvapter.d.ts
6
- /**
7
- * The Node/Bun/Deno facade: {@link Envapter} plus the filesystem-only configuration APIs (`.env`
8
- * path selection, base directory, dotenv options, and per-environment profiles). The browser and
9
- * Workers builds export the base {@link Envapter} without these, so calling one where there is no
10
- * filesystem is a compile error (and a thrown {@link EnvaptError} when types are bypassed).
11
- *
12
- * Writes target the state-owning class (`EnvapterBase`/`EnvironmentMethods`), not `this`: the engine
13
- * reads that state through `EnvapterBase`-anchored paths, so a subclass own-property would be invisible.
14
- * @public
15
- */
16
- declare class NodeEnvapter extends Envapter {
17
- /**
18
- * Set custom .env file paths. Accepts either a single path or array of paths.
19
- * Setting new paths clears the cache and reloads environment variables.
20
- *
21
- * When set, this takes absolute precedence. The dotenv-flow auto-cascade and any
22
- * `Envapter.configureProfiles` configuration are ignored.
23
- */
24
- static set envPaths(paths: string[] | string);
25
- /**
26
- * Get currently configured .env file paths
27
- */
28
- static get envPaths(): string[];
29
- /**
30
- * Set a base directory that relative `.env` paths resolve against instead of
31
- * `process.cwd()`: the auto-cascade, `Envapter.configureProfiles` paths, and relative
32
- * `envPaths`. Absolute paths always bypass it. Pass a directory, or a module URL
33
- * (`import.meta.url`, ESM) / `import.meta.dirname` / `__dirname` (CJS) to anchor
34
- * resolution next to the calling file regardless of launch directory.
35
- *
36
- * Set this before `envPaths` so relative `envPaths` validate against the right directory.
37
- * Unset (`undefined`) restores `process.cwd()` resolution.
38
- */
39
- static set baseDir(value: string | URL | undefined);
40
- static get baseDir(): string | undefined;
41
- static set envFileOptions(config: EnvFileOptions);
42
- /**
43
- * Get current dotenv configuration options
44
- */
45
- static get envFileOptions(): EnvFileOptions;
46
- /**
47
- * Configure per-environment `.env` path overrides on top of the dotenv-flow auto-cascade.
48
- *
49
- * When set, each `Environment` key's `paths` are loaded at higher precedence than the
50
- * cascade for that environment. Unspecified environments still use the cascade as-is.
51
- * Set `useDefaults: false` to disable the cascade entirely (load only the configured paths).
52
- *
53
- * Setting an explicit `Envapter.envPaths` value at any point overrides this configuration.
54
- *
55
- * @example
56
- * ```ts
57
- * Envapter.configureProfiles({
58
- * [Environment.Staging]: { paths: 'config/staging.env' },
59
- * [Environment.Production]: { paths: ['config/prod.env', 'secrets/prod.env'] }
60
- * });
61
- * ```
62
- */
63
- static configureProfiles(config: ProfilesConfig): void;
64
- /**
65
- * Reset all path-resolution configuration to defaults: clears any prior
66
- * `Envapter.configureProfiles` call AND any explicit `Envapter.envPaths` assignment.
67
- * Returns the resolver to the pure dotenv-flow cascade.
68
- */
69
- static resetProfiles(): void;
70
- }
71
- //#endregion
72
- export { NodeEnvapter };
73
- //# sourceMappingURL=NodeEnvapter.d.cts.map
@@ -1,17 +0,0 @@
1
- import { EnvapterService } from "../types/Env.cjs";
2
-
3
- //#region src/engine/TemplateResolver.d.ts
4
- /**
5
- * Resolve `${VAR}` template references in environment values, guarding against circular
6
- * references and missing variables.
7
- * @internal
8
- */
9
- declare class TemplateResolver {
10
- private readonly envService;
11
- private readonly TEMPLATE_REGEX;
12
- constructor(envService: EnvapterService);
13
- resolveTemplate(key: string, value: string, stack?: Set<string>): string;
14
- }
15
- //#endregion
16
- export { TemplateResolver };
17
- //# sourceMappingURL=TemplateResolver.d.cts.map
@@ -1,19 +0,0 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
- import { EnvapterService } from "../types/Env.mjs";
4
-
5
- //#region src/engine/TemplateResolver.d.ts
6
- /**
7
- * Resolve `${VAR}` template references in environment values, guarding against circular
8
- * references and missing variables.
9
- * @internal
10
- */
11
- declare class TemplateResolver {
12
- private readonly envService;
13
- private readonly TEMPLATE_REGEX;
14
- constructor(envService: EnvapterService);
15
- resolveTemplate(key: string, value: string, stack?: Set<string>): string;
16
- }
17
- //#endregion
18
- export { TemplateResolver };
19
- //# sourceMappingURL=TemplateResolver.d.mts.map
@@ -1,19 +0,0 @@
1
- import { DebugLevel } from "./infra/Debug.cjs";
2
- import { EnvFileOptions } from "./infra/Dotenv.cjs";
3
- import { ArrayElement, ArrayOf, ConverterToken, Converters, CustomElementConverter, isArrayOf } from "./converters/Converters.cjs";
4
- import { AdvancedConverterReturn, BuiltInConverter, BuiltInConverterFunction, ConditionalReturn, ConverterFunction, EnvaptConverter, InferConverterFallbackType, InferConverterReturnType, InferPrimitiveReturnType, JsonValue, MapOfConverterFunctions, PrimitiveConstructor, TimeFallback, TimeUnit } from "./types/Conversion.cjs";
5
- import { InferSchemaInput, InferSchemaOutput, StandardSchemaV1 } from "./infra/StandardSchema.cjs";
6
- import { Err, SchemaConstraint, SchemaMustBeSync } from "./types/Schema.cjs";
7
- import { Environment } from "./core/EnvironmentMethods.cjs";
8
- import { EnvProfile, EnvaptOptions, ProfilesConfig } from "./types/Options.cjs";
9
- import { EnvKeyInput } from "./types/Env.cjs";
10
- import { BareEnvSource, EnvSource, FileEnvSource } from "./types/Source.cjs";
11
- import { EnvaptAccessorDecorator, EnvaptFieldDecorator } from "./types/Decorator.cjs";
12
- import { ManualEnvSource } from "./sources/ManualEnvSource.cjs";
13
- import { WorkerEnvSource } from "./sources/WorkerEnvSource.cjs";
14
- import { EnvaptError, EnvaptErrorCodes } from "./infra/Error.cjs";
15
- import { Envapt } from "./decorators/modern/Envapt.cjs";
16
- import { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl } from "./decorators/modern/SugarDecorators.cjs";
17
- import { NodeEnvapter } from "./engine/NodeEnvapter.cjs";
18
- import { NodeEnvSource } from "./sources/NodeEnvSource.cjs";
19
- export { type AdvancedConverterReturn, type ArrayElement, type ArrayOf, type BareEnvSource, type BuiltInConverter, type BuiltInConverterFunction, type ConditionalReturn, type ConverterFunction, type ConverterToken, Converters, type CustomElementConverter, type DebugLevel, EnvBool, type EnvFileOptions, type EnvKeyInput, EnvNum, type EnvProfile, type EnvSource, EnvStr, EnvTime, EnvUrl, Envapt, type EnvaptAccessorDecorator, type EnvaptConverter, EnvaptError, EnvaptErrorCodes, type EnvaptFieldDecorator, type EnvaptOptions, NodeEnvapter as Envapter, Environment, type Err, type FileEnvSource, type InferConverterFallbackType, type InferConverterReturnType, type InferPrimitiveReturnType, type InferSchemaInput, type InferSchemaOutput, type JsonValue, ManualEnvSource, type MapOfConverterFunctions, NodeEnvSource, type PrimitiveConstructor, type ProfilesConfig, type SchemaConstraint, type SchemaMustBeSync, type StandardSchemaV1, type TimeFallback, type TimeUnit, WorkerEnvSource, isArrayOf };
@@ -1,13 +0,0 @@
1
- //#region src/infra/Debug.d.ts
2
- /**
3
- * Debug log levels for {@link Envapter.debug}. `silent` (default) emits nothing.
4
- * `warn` covers signals that might indicate misconfiguration: failed file reads,
5
- * unresolved templates (when not strict), fallback values used in place of missing
6
- * env. `verbose` adds every loaded file, per-file key count, per-key load lines, and
7
- * effective-paths / cache-rebuild notices.
8
- * @public
9
- */
10
- type DebugLevel = 'silent' | 'warn' | 'verbose';
11
- //#endregion
12
- export { DebugLevel };
13
- //# sourceMappingURL=Debug.d.cts.map
@@ -1,15 +0,0 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
- //#region src/infra/Debug.d.ts
4
- /**
5
- * Debug log levels for {@link Envapter.debug}. `silent` (default) emits nothing.
6
- * `warn` covers signals that might indicate misconfiguration: failed file reads,
7
- * unresolved templates (when not strict), fallback values used in place of missing
8
- * env. `verbose` adds every loaded file, per-file key count, per-key load lines, and
9
- * effective-paths / cache-rebuild notices.
10
- * @public
11
- */
12
- type DebugLevel = 'silent' | 'warn' | 'verbose';
13
- //#endregion
14
- export { DebugLevel };
15
- //# sourceMappingURL=Debug.d.mts.map
@@ -1,17 +0,0 @@
1
- //#region src/infra/Dotenv.d.ts
2
- /**
3
- * Public options for the internal `.env` loader. Mirrors the subset of dotenv's
4
- * `config()` options that envapt actually supports (no DOTENV_KEY, no quiet).
5
- * For debug output, use `Envapter.debug` (or the `ENVAPT_DEBUG` env var).
6
- *
7
- * @public
8
- */
9
- interface EnvFileOptions {
10
- /** Encoding for reading .env files. Defaults to 'utf8'. */
11
- encoding?: string;
12
- /** When true, later files override earlier ones (and existing processEnv values). Default false (first-wins). */
13
- override?: boolean;
14
- }
15
- //#endregion
16
- export { EnvFileOptions };
17
- //# sourceMappingURL=Dotenv.d.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/infra/Dotenv.d.ts
4
- /**
5
- * Public options for the internal `.env` loader. Mirrors the subset of dotenv's
6
- * `config()` options that envapt actually supports (no DOTENV_KEY, no quiet).
7
- * For debug output, use `Envapter.debug` (or the `ENVAPT_DEBUG` env var).
8
- *
9
- * @public
10
- */
11
- interface EnvFileOptions {
12
- /** Encoding for reading .env files. Defaults to 'utf8'. */
13
- encoding?: string;
14
- /** When true, later files override earlier ones (and existing processEnv values). Default false (first-wins). */
15
- override?: boolean;
16
- }
17
- //#endregion
18
- export { EnvFileOptions };
19
- //# sourceMappingURL=Dotenv.d.mts.map