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,218 +0,0 @@
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
@@ -1,40 +0,0 @@
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
@@ -1,70 +0,0 @@
1
- import { Environment } from "../core/EnvironmentMethods.mjs";
2
- import { AdvancedMethods } from "../core/AdvancedMethods.mjs";
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.mts.map
@@ -1,17 +0,0 @@
1
- import { EnvapterService } from "../types/Env.mjs";
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.mts.map
@@ -1,18 +0,0 @@
1
- import { ArrayElement, ArrayOf, ConverterToken, Converters, CustomElementConverter, isArrayOf } from "./converters/Converters.mjs";
2
- import { AdvancedConverterReturn, BuiltInConverter, BuiltInConverterFunction, ConditionalReturn, ConverterFunction, EnvaptConverter, InferConverterFallbackType, InferConverterReturnType, InferPrimitiveReturnType, JsonValue, MapOfConverterFunctions, PrimitiveConstructor, TimeFallback, TimeUnit } from "./types/Conversion.mjs";
3
- import { InferSchemaInput, InferSchemaOutput, StandardSchemaV1 } from "./infra/StandardSchema.mjs";
4
- import { Err, SchemaConstraint, SchemaMustBeSync } from "./types/Schema.mjs";
5
- import { DebugLevel } from "./infra/Debug.mjs";
6
- import { EnvFileOptions } from "./infra/Dotenv.mjs";
7
- import { Environment } from "./core/EnvironmentMethods.mjs";
8
- import { EnvProfile, EnvaptOptions, ProfilesConfig } from "./types/Options.mjs";
9
- import { EnvKeyInput } from "./types/Env.mjs";
10
- import { BareEnvSource, EnvSource, FileEnvSource } from "./types/Source.mjs";
11
- import { EnvaptAccessorDecorator, EnvaptFieldDecorator } from "./types/Decorator.mjs";
12
- import { Envapter } from "./engine/Envapter.mjs";
13
- import { ManualEnvSource } from "./sources/ManualEnvSource.mjs";
14
- import { WorkerEnvSource } from "./sources/WorkerEnvSource.mjs";
15
- import { EnvaptError, EnvaptErrorCodes } from "./infra/Error.mjs";
16
- import { Envapt } from "./decorators/modern/Envapt.mjs";
17
- import { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl } from "./decorators/modern/SugarDecorators.mjs";
18
- export { type AdvancedConverterReturn, type ArrayElement, type ArrayOf, type BareEnvSource, type BuiltInConverter, type BuiltInConverterFunction, type ConditionalReturn, type ConverterFunction, type ConverterToken, Converters, type CustomElementConverter, type DebugLevel, EnvBool, type EnvFileOptions, type EnvKeyInput, EnvNum, type EnvProfile, type EnvSource, EnvStr, EnvTime, EnvUrl, Envapt, type EnvaptAccessorDecorator, type EnvaptConverter, EnvaptError, EnvaptErrorCodes, type EnvaptFieldDecorator, type EnvaptOptions, Envapter, Environment, type Err, type FileEnvSource, type InferConverterFallbackType, type InferConverterReturnType, type InferPrimitiveReturnType, type InferSchemaInput, type InferSchemaOutput, type JsonValue, ManualEnvSource, type MapOfConverterFunctions, type PrimitiveConstructor, type ProfilesConfig, type SchemaConstraint, type SchemaMustBeSync, type StandardSchemaV1, type TimeFallback, type TimeUnit, WorkerEnvSource, isArrayOf };
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/workerd.ts"],"sourcesContent":["import { installFileApiStubs } from './engine/installFileApiStubs';\n\nexport * from './browser';\n\ninstallFileApiStubs();\n"],"mappings":"6mBAIA,EAAoB"}
@@ -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.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.mts.map
@@ -1,72 +0,0 @@
1
- import { StandardSchemaV1 } from "./StandardSchema.mjs";
2
-
3
- //#region src/infra/Error.d.ts
4
- declare enum EnvaptErrorCodes {
5
- /** Thrown when an invalid fallback value is provided */
6
- InvalidFallback = 101,
7
- /** Thrown when fallback value type doesn't match expected converter type */
8
- InvalidFallbackType = 102,
9
- /** Thrown when array fallback contains elements of wrong type */
10
- ArrayFallbackElementTypeMismatch = 103,
11
- /** Thrown when fallback type doesn't match the specified converter */
12
- FallbackConverterTypeMismatch = 104,
13
- /** Thrown when a time-string fallback is malformed (does not match the required `<number><unit>` format) */
14
- MalformedTimeFallback = 105,
15
- /** Thrown when invalid array converter configuration is provided */
16
- InvalidArrayConverterType = 201,
17
- /** Thrown when an invalid built-in converter is specified */
18
- InvalidBuiltInConverter = 202,
19
- /** Thrown when a custom converter is not a function */
20
- InvalidCustomConverter = 203,
21
- /** Thrown when converter type is not recognized */
22
- InvalidConverterType = 204,
23
- /** Thrown when primitive type coercion on fallback value fails */
24
- PrimitiveCoercionFailed = 205,
25
- /** Thrown when an array element fails to convert to the configured element type */
26
- ArrayElementConversionFailed = 206,
27
- /** Thrown under strict mode when an array element is empty or whitespace only */
28
- EmptyArrayElement = 207,
29
- /** Thrown when a Standard Schema returns issues for a non-empty env value */
30
- SchemaValidationFailed = 208,
31
- /** Thrown when a Standard Schema's `validate` itself throws (e.g. a refinement that crashes) */
32
- SchemaThrew = 209,
33
- /** Thrown when delimiter is missing in array converter configuration */
34
- MissingDelimiter = 301,
35
- /** Thrown when invalid user-defined configuration is provided */
36
- InvalidUserDefinedConfig = 302,
37
- /** Thrown when specified environment files don't exist */
38
- EnvFilesNotFound = 303,
39
- /** Thrown when no valid environment key is provided */
40
- InvalidKeyInput = 304,
41
- /** Thrown when a required environment value is missing or empty (post-trim) */
42
- MissingEnvValue = 305,
43
- /** Thrown when a file-based API (envPaths, baseDir, configureProfiles) is used on a source without filesystem support */
44
- FileApiUnsupported = 306,
45
- /** Thrown when an environment value is read before a source is bound via Envapter.useSource */
46
- NoSourceBound = 307
47
- }
48
- interface EnvaptErrorOptions {
49
- issues?: readonly StandardSchemaV1.Issue[];
50
- cause?: unknown;
51
- }
52
- /**
53
- * Custom error for better DX and debugging when using Envapt.
54
- *
55
- * @example
56
- * ```ts
57
- * throw new EnvaptError(EnvaptErrorCodes.InvalidFallback, "Invalid fallback value provided for environment variable.");
58
- * ```
59
- */
60
- declare class EnvaptError extends Error {
61
- readonly code: EnvaptErrorCodes;
62
- /**
63
- * Populated only for {@link EnvaptErrorCodes.SchemaValidationFailed} (208). For every other
64
- * code this is `undefined`. Lets callers do `if (err.code === 208) err.issues?.forEach(...)`
65
- * without a type cast.
66
- */
67
- readonly issues: readonly StandardSchemaV1.Issue[] | undefined;
68
- constructor(code: EnvaptErrorCodes, message: string, options?: EnvaptErrorOptions);
69
- }
70
- //#endregion
71
- export { EnvaptError, EnvaptErrorCodes };
72
- //# sourceMappingURL=Error.d.mts.map
@@ -1,59 +0,0 @@
1
- //#region src/infra/StandardSchema.d.ts
2
- /**
3
- * Standard Schema V1 interface. Inlined verbatim from the spec at https://standardschema.dev
4
- * so envapt has zero runtime peer dependencies on any specific schema library
5
- * (zod / valibot / arktype / etc).
6
- *
7
- * envapt narrows usage to SYNCHRONOUS schemas only: env loading is boot-time,
8
- * `validate` returning `Promise<Result>` is rejected at the type level (see
9
- * `SchemaMustBeSync` brand in `Types.ts`) and at runtime by the Parser dispatch.
10
- *
11
- * @public
12
- */
13
- interface StandardSchemaV1<Input = unknown, Output = Input> {
14
- readonly '~standard': StandardSchemaV1.Props<Input, Output>;
15
- }
16
- declare namespace StandardSchemaV1 {
17
- interface Props<Input = unknown, Output = Input> {
18
- readonly version: 1;
19
- readonly vendor: string;
20
- readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
21
- readonly types?: Types<Input, Output> | undefined;
22
- }
23
- type Result<Output> = SuccessResult<Output> | FailureResult;
24
- interface SuccessResult<Output> {
25
- readonly value: Output;
26
- readonly issues?: undefined;
27
- }
28
- interface FailureResult {
29
- readonly issues: readonly Issue[];
30
- }
31
- interface Issue {
32
- readonly message: string;
33
- readonly path?: readonly (PropertyKey | PathSegment)[] | undefined;
34
- }
35
- interface PathSegment {
36
- readonly key: PropertyKey;
37
- }
38
- interface Types<Input = unknown, Output = Input> {
39
- readonly input: Input;
40
- readonly output: Output;
41
- }
42
- type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
43
- type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
44
- }
45
- /**
46
- * Envapt-side alias for {@link StandardSchemaV1.InferOutput}. Re-exported under a friendlier
47
- * name so consumers writing `static readonly x: InferSchemaOutput<typeof mySchema>`
48
- * don't need the namespace path.
49
- * @public
50
- */
51
- type InferSchemaOutput<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema>;
52
- /**
53
- * Envapt-side alias for {@link StandardSchemaV1.InferInput}.
54
- * @public
55
- */
56
- type InferSchemaInput<Schema extends StandardSchemaV1> = StandardSchemaV1.InferInput<Schema>;
57
- //#endregion
58
- export { InferSchemaInput, InferSchemaOutput, StandardSchemaV1 };
59
- //# sourceMappingURL=StandardSchema.d.mts.map
@@ -1,4 +0,0 @@
1
- import { EnvaptFieldDecorator } from "./types/Decorator.mjs";
2
- import { Envapt } from "./decorators/legacy/Envapt.mjs";
3
- import { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl } from "./decorators/legacy/SugarDecorators.mjs";
4
- export { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl, Envapt, type EnvaptFieldDecorator };
@@ -1,19 +0,0 @@
1
- import { BareEnvSource } from "../types/Source.mjs";
2
-
3
- //#region src/sources/ManualEnvSource.d.ts
4
- /**
5
- * Environment source seeded from an object you provide: the config your bundler injects into a browser
6
- * build (Vite's `import.meta.env`, a webpack `DefinePlugin` global), a test fixture, or any other plain
7
- * object. Pass it straight through; non-string values are JSON-stringified so the converters still apply.
8
- * It has no filesystem, so the `.env` cascade and file-based APIs do not apply.
9
- * @public
10
- */
11
- declare class ManualEnvSource implements BareEnvSource {
12
- readonly supportsFiles = false;
13
- private readonly vars;
14
- constructor(vars: Record<string, unknown>);
15
- readVars(): Record<string, string>;
16
- }
17
- //#endregion
18
- export { ManualEnvSource };
19
- //# sourceMappingURL=ManualEnvSource.d.mts.map
@@ -1,19 +0,0 @@
1
- import { BareEnvSource } from "../types/Source.mjs";
2
-
3
- //#region src/sources/WorkerEnvSource.d.ts
4
- /**
5
- * Environment source for Cloudflare Workers, seeded from the `env` binding. String bindings pass
6
- * through; non-string bindings are JSON-stringified so the converters still apply, and so must be
7
- * JSON-serializable (a `bigint` or circular value throws). No filesystem, so the `.env` cascade and
8
- * file-based APIs do not apply.
9
- * @public
10
- */
11
- declare class WorkerEnvSource implements BareEnvSource {
12
- readonly supportsFiles = false;
13
- private readonly vars;
14
- constructor(env: Record<string, unknown>);
15
- readVars(): Record<string, string>;
16
- }
17
- //#endregion
18
- export { WorkerEnvSource };
19
- //# sourceMappingURL=WorkerEnvSource.d.mts.map