envapt 8.0.0-next.1 → 8.0.0-next.3

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 (65) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/node/converters/BuiltInConverters.cjs +1 -1
  3. package/dist/node/converters/BuiltInConverters.cjs.map +1 -1
  4. package/dist/node/converters/BuiltInConverters.mjs +1 -1
  5. package/dist/node/converters/BuiltInConverters.mjs.map +1 -1
  6. package/dist/node/converters/Converters.cjs +1 -1
  7. package/dist/node/converters/Converters.cjs.map +1 -1
  8. package/dist/node/converters/Converters.mjs +1 -1
  9. package/dist/node/converters/Converters.mjs.map +1 -1
  10. package/dist/node/converters/ListOfBuiltInConverters.cjs +1 -1
  11. package/dist/node/converters/ListOfBuiltInConverters.cjs.map +1 -1
  12. package/dist/node/converters/ListOfBuiltInConverters.mjs +1 -1
  13. package/dist/node/converters/ListOfBuiltInConverters.mjs.map +1 -1
  14. package/dist/node/converters/ValueConverter.cjs +1 -1
  15. package/dist/node/converters/ValueConverter.cjs.map +1 -1
  16. package/dist/node/converters/ValueConverter.mjs +1 -1
  17. package/dist/node/converters/ValueConverter.mjs.map +1 -1
  18. package/dist/node/core/AdvancedMethods.cjs +1 -1
  19. package/dist/node/core/AdvancedMethods.cjs.map +1 -1
  20. package/dist/node/core/AdvancedMethods.mjs +1 -1
  21. package/dist/node/core/AdvancedMethods.mjs.map +1 -1
  22. package/dist/node/core/missing.cjs +1 -1
  23. package/dist/node/core/missing.cjs.map +1 -1
  24. package/dist/node/core/missing.mjs +1 -1
  25. package/dist/node/core/missing.mjs.map +1 -1
  26. package/dist/node/decorators/legacy/Envapt.cjs.map +1 -1
  27. package/dist/node/decorators/legacy/Envapt.mjs.map +1 -1
  28. package/dist/node/decorators/legacy/SugarDecorators.cjs.map +1 -1
  29. package/dist/node/decorators/legacy/SugarDecorators.mjs.map +1 -1
  30. package/dist/node/decorators/modern/Envapt.cjs.map +1 -1
  31. package/dist/node/decorators/modern/Envapt.mjs.map +1 -1
  32. package/dist/node/decorators/modern/SugarDecorators.cjs.map +1 -1
  33. package/dist/node/decorators/modern/SugarDecorators.mjs.map +1 -1
  34. package/dist/node/decorators/parseEnvaptOptions.cjs +1 -1
  35. package/dist/node/decorators/parseEnvaptOptions.cjs.map +1 -1
  36. package/dist/node/decorators/parseEnvaptOptions.mjs +1 -1
  37. package/dist/node/decorators/parseEnvaptOptions.mjs.map +1 -1
  38. package/dist/node/decorators/resolveDecoratorValue.cjs.map +1 -1
  39. package/dist/node/decorators/resolveDecoratorValue.mjs.map +1 -1
  40. package/dist/portable/converters/BuiltInConverters.mjs +1 -1
  41. package/dist/portable/converters/BuiltInConverters.mjs.map +1 -1
  42. package/dist/portable/converters/Converters.mjs +1 -1
  43. package/dist/portable/converters/Converters.mjs.map +1 -1
  44. package/dist/portable/converters/ListOfBuiltInConverters.mjs +1 -1
  45. package/dist/portable/converters/ListOfBuiltInConverters.mjs.map +1 -1
  46. package/dist/portable/converters/ValueConverter.mjs +1 -1
  47. package/dist/portable/converters/ValueConverter.mjs.map +1 -1
  48. package/dist/portable/core/AdvancedMethods.mjs +1 -1
  49. package/dist/portable/core/AdvancedMethods.mjs.map +1 -1
  50. package/dist/portable/core/missing.mjs +1 -1
  51. package/dist/portable/core/missing.mjs.map +1 -1
  52. package/dist/portable/decorators/legacy/Envapt.mjs.map +1 -1
  53. package/dist/portable/decorators/legacy/SugarDecorators.mjs.map +1 -1
  54. package/dist/portable/decorators/modern/Envapt.mjs.map +1 -1
  55. package/dist/portable/decorators/modern/SugarDecorators.mjs.map +1 -1
  56. package/dist/portable/decorators/parseEnvaptOptions.mjs +1 -1
  57. package/dist/portable/decorators/parseEnvaptOptions.mjs.map +1 -1
  58. package/dist/portable/decorators/resolveDecoratorValue.mjs.map +1 -1
  59. package/dist/types/converters/Converters.d.mts +4 -0
  60. package/dist/types/decorators/legacy/Envapt.d.mts +4 -26
  61. package/dist/types/decorators/legacy/SugarDecorators.d.mts +5 -5
  62. package/dist/types/decorators/modern/Envapt.d.mts +4 -26
  63. package/dist/types/decorators/modern/SugarDecorators.d.mts +5 -5
  64. package/dist/types/types/Conversion.d.mts +2 -0
  65. package/package.json +1 -1
@@ -32,7 +32,7 @@ import { EnvaptFieldDecorator } from "../../types/Decorator.mjs";
32
32
  * }
33
33
  * ```
34
34
  */
35
- declare function Envapt(key: EnvKeyInput, options: {
35
+ declare function Envapt(key: EnvKeyInput, options?: {
36
36
  fallback: undefined;
37
37
  converter?: undefined;
38
38
  }): EnvaptFieldDecorator<string | undefined>;
@@ -96,7 +96,7 @@ declare function Envapt<TReturnType>(key: EnvKeyInput, options: {
96
96
  *
97
97
  * // prefers CANARY_URL when present, otherwise APP_URL
98
98
  * \@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })
99
- * static readonly canaryUrl: URL | null;
99
+ * static readonly canaryUrl: URL | undefined;
100
100
  *
101
101
  * // Time takes a number (milliseconds) or a time-string fallback (`<number><unit>`)
102
102
  * \@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })
@@ -123,13 +123,9 @@ declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvK
123
123
  }): EnvaptFieldDecorator<InferConverterReturnType<TConverter>>;
124
124
  declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
125
125
  converter: TConverter;
126
- fallback: undefined;
126
+ fallback?: undefined;
127
127
  required?: false;
128
128
  }): EnvaptFieldDecorator<InferConverterReturnType<TConverter> | undefined>;
129
- declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
130
- converter: TConverter;
131
- required?: false;
132
- }): EnvaptFieldDecorator<InferConverterReturnType<TConverter> | null>;
133
129
  /**
134
130
  * A primitive constructor (`Number`, `Boolean`) with an optional fallback.
135
131
  *
@@ -157,13 +153,9 @@ declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyIn
157
153
  }): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor>>;
158
154
  declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
159
155
  converter: TConstructor;
160
- fallback: undefined;
156
+ fallback?: undefined;
161
157
  required?: false;
162
158
  }): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor> | undefined>;
163
- declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
164
- converter: TConstructor;
165
- required?: false;
166
- }): EnvaptFieldDecorator<InferPrimitiveReturnType<TConstructor> | null>;
167
159
  /**
168
160
  * Required, no converter (raw string). Throws `MissingEnvValue` on first access when the env
169
161
  * value is missing or empty after trimming, independent of the global `Envapter.strict` flag.
@@ -184,20 +176,6 @@ declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyIn
184
176
  declare function Envapt(key: EnvKeyInput, options: {
185
177
  required: true;
186
178
  }): EnvaptFieldDecorator<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 extends Envapter {
195
- * \@Envapt('SIMPLE_VALUE')
196
- * static readonly simple?: string | null;
197
- * }
198
- * ```
199
- */
200
- declare function Envapt(key: EnvKeyInput): EnvaptFieldDecorator<string | null>;
201
179
  /**
202
180
  * A Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous schemas only,
203
181
  * so a Promise-returning `validate` throws `InvalidUserDefinedConfig` at runtime. Pairing
@@ -9,21 +9,21 @@ import { EnvaptFieldDecorator } from "../../types/Decorator.mjs";
9
9
  * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
10
10
  */
11
11
  declare function EnvBool(key: EnvKeyInput, fallback: boolean): EnvaptFieldDecorator<boolean>;
12
- declare function EnvBool(key: EnvKeyInput): EnvaptFieldDecorator<boolean | null>;
12
+ declare function EnvBool(key: EnvKeyInput): EnvaptFieldDecorator<boolean | undefined>;
13
13
  /**
14
14
  * Shorthand for `@Envapt(key, { converter: Converters.Number, fallback })`.
15
15
  * @public
16
16
  * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
17
17
  */
18
18
  declare function EnvNum(key: EnvKeyInput, fallback: number): EnvaptFieldDecorator<number>;
19
- declare function EnvNum(key: EnvKeyInput): EnvaptFieldDecorator<number | null>;
19
+ declare function EnvNum(key: EnvKeyInput): EnvaptFieldDecorator<number | undefined>;
20
20
  /**
21
21
  * Shorthand for `@Envapt(key, { converter: Converters.String, fallback })`.
22
22
  * @public
23
23
  * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
24
24
  */
25
25
  declare function EnvStr(key: EnvKeyInput, fallback: string): EnvaptFieldDecorator<string>;
26
- declare function EnvStr(key: EnvKeyInput): EnvaptFieldDecorator<string | null>;
26
+ declare function EnvStr(key: EnvKeyInput): EnvaptFieldDecorator<string | undefined>;
27
27
  /**
28
28
  * Shorthand for `@Envapt(key, { converter: Converters.Time, fallback })`. The fallback is a
29
29
  * millisecond number or a time string (`'15m'`), and the resolved value is always milliseconds.
@@ -31,7 +31,7 @@ declare function EnvStr(key: EnvKeyInput): EnvaptFieldDecorator<string | null>;
31
31
  * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
32
32
  */
33
33
  declare function EnvTime(key: EnvKeyInput, fallback: TimeFallback): EnvaptFieldDecorator<number>;
34
- declare function EnvTime(key: EnvKeyInput): EnvaptFieldDecorator<number | null>;
34
+ declare function EnvTime(key: EnvKeyInput): EnvaptFieldDecorator<number | undefined>;
35
35
  /**
36
36
  * Shorthand for `@Envapt(key, { converter: Converters.Url, fallback })`. The fallback is a `URL`
37
37
  * instance, not a URL string.
@@ -39,7 +39,7 @@ declare function EnvTime(key: EnvKeyInput): EnvaptFieldDecorator<number | null>;
39
39
  * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
40
40
  */
41
41
  declare function EnvUrl(key: EnvKeyInput, fallback: URL): EnvaptFieldDecorator<URL>;
42
- declare function EnvUrl(key: EnvKeyInput): EnvaptFieldDecorator<URL | null>;
42
+ declare function EnvUrl(key: EnvKeyInput): EnvaptFieldDecorator<URL | undefined>;
43
43
  //#endregion
44
44
  export { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl };
45
45
  //# sourceMappingURL=SugarDecorators.d.mts.map
@@ -32,7 +32,7 @@ import { EnvaptAccessorDecorator } from "../../types/Decorator.mjs";
32
32
  * }
33
33
  * ```
34
34
  */
35
- declare function Envapt(key: EnvKeyInput, options: {
35
+ declare function Envapt(key: EnvKeyInput, options?: {
36
36
  fallback: undefined;
37
37
  converter?: undefined;
38
38
  }): EnvaptAccessorDecorator<string | undefined>;
@@ -96,7 +96,7 @@ declare function Envapt<TReturnType>(key: EnvKeyInput, options: {
96
96
  *
97
97
  * // prefers CANARY_URL when present, otherwise APP_URL
98
98
  * \@Envapt(['CANARY_URL', 'APP_URL'], { converter: Converters.Url })
99
- * static accessor canaryUrl: URL | null;
99
+ * static accessor canaryUrl: URL | undefined;
100
100
  *
101
101
  * // Time takes a number (milliseconds) or a time-string fallback (`<number><unit>`)
102
102
  * \@Envapt('REQUEST_TIMEOUT', { converter: Converters.Time, fallback: '10s' })
@@ -123,13 +123,9 @@ declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvK
123
123
  }): EnvaptAccessorDecorator<InferConverterReturnType<TConverter>>;
124
124
  declare function Envapt<TConverter extends BuiltInConverter | ArrayOf>(key: EnvKeyInput, options: {
125
125
  converter: TConverter;
126
- fallback: undefined;
126
+ fallback?: undefined;
127
127
  required?: false;
128
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
129
  /**
134
130
  * A primitive constructor (`Number`, `Boolean`) with an optional fallback.
135
131
  *
@@ -157,13 +153,9 @@ declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyIn
157
153
  }): EnvaptAccessorDecorator<InferPrimitiveReturnType<TConstructor>>;
158
154
  declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyInput, options: {
159
155
  converter: TConstructor;
160
- fallback: undefined;
156
+ fallback?: undefined;
161
157
  required?: false;
162
158
  }): 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
159
  /**
168
160
  * Required, no converter (raw string). Throws `MissingEnvValue` on first access when the env
169
161
  * value is missing or empty after trimming, independent of the global `Envapter.strict` flag.
@@ -184,20 +176,6 @@ declare function Envapt<TConstructor extends PrimitiveConstructor>(key: EnvKeyIn
184
176
  declare function Envapt(key: EnvKeyInput, options: {
185
177
  required: true;
186
178
  }): 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
179
  /**
202
180
  * A Standard Schema v1 adapter (zod, valibot, arktype, hand-rolled). Synchronous schemas only,
203
181
  * so a Promise-returning `validate` throws `InvalidUserDefinedConfig` at runtime. Pairing
@@ -9,21 +9,21 @@ import { EnvaptAccessorDecorator } from "../../types/Decorator.mjs";
9
9
  * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
10
10
  */
11
11
  declare function EnvBool(key: EnvKeyInput, fallback: boolean): EnvaptAccessorDecorator<boolean>;
12
- declare function EnvBool(key: EnvKeyInput): EnvaptAccessorDecorator<boolean | null>;
12
+ declare function EnvBool(key: EnvKeyInput): EnvaptAccessorDecorator<boolean | undefined>;
13
13
  /**
14
14
  * Shorthand for `@Envapt(key, { converter: Converters.Number, fallback })`.
15
15
  * @public
16
16
  * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
17
17
  */
18
18
  declare function EnvNum(key: EnvKeyInput, fallback: number): EnvaptAccessorDecorator<number>;
19
- declare function EnvNum(key: EnvKeyInput): EnvaptAccessorDecorator<number | null>;
19
+ declare function EnvNum(key: EnvKeyInput): EnvaptAccessorDecorator<number | undefined>;
20
20
  /**
21
21
  * Shorthand for `@Envapt(key, { converter: Converters.String, fallback })`.
22
22
  * @public
23
23
  * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
24
24
  */
25
25
  declare function EnvStr(key: EnvKeyInput, fallback: string): EnvaptAccessorDecorator<string>;
26
- declare function EnvStr(key: EnvKeyInput): EnvaptAccessorDecorator<string | null>;
26
+ declare function EnvStr(key: EnvKeyInput): EnvaptAccessorDecorator<string | undefined>;
27
27
  /**
28
28
  * Shorthand for `@Envapt(key, { converter: Converters.Time, fallback })`. The fallback is a
29
29
  * millisecond number or a time string (`'15m'`), and the resolved value is always milliseconds.
@@ -31,7 +31,7 @@ declare function EnvStr(key: EnvKeyInput): EnvaptAccessorDecorator<string | null
31
31
  * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
32
32
  */
33
33
  declare function EnvTime(key: EnvKeyInput, fallback: TimeFallback): EnvaptAccessorDecorator<number>;
34
- declare function EnvTime(key: EnvKeyInput): EnvaptAccessorDecorator<number | null>;
34
+ declare function EnvTime(key: EnvKeyInput): EnvaptAccessorDecorator<number | undefined>;
35
35
  /**
36
36
  * Shorthand for `@Envapt(key, { converter: Converters.Url, fallback })`. The fallback is a `URL`
37
37
  * instance, not a URL string.
@@ -39,7 +39,7 @@ declare function EnvTime(key: EnvKeyInput): EnvaptAccessorDecorator<number | nul
39
39
  * @see {@link https://envapt.materwelon.dev/docs/decorators#shorthand-decorators}
40
40
  */
41
41
  declare function EnvUrl(key: EnvKeyInput, fallback: URL): EnvaptAccessorDecorator<URL>;
42
- declare function EnvUrl(key: EnvKeyInput): EnvaptAccessorDecorator<URL | null>;
42
+ declare function EnvUrl(key: EnvKeyInput): EnvaptAccessorDecorator<URL | undefined>;
43
43
  //#endregion
44
44
  export { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl };
45
45
  //# sourceMappingURL=SugarDecorators.d.mts.map
@@ -39,6 +39,8 @@ interface ConverterMap {
39
39
  regexp: RegExp;
40
40
  date: Date;
41
41
  time: number;
42
+ port: number;
43
+ email: string;
42
44
  }
43
45
  type BuiltInConverterReturnType<ConverterKey extends BuiltInConverter> = ConverterMap[ConverterKey];
44
46
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "envapt",
3
3
  "type": "module",
4
- "version": "8.0.0-next.1",
4
+ "version": "8.0.0-next.3",
5
5
  "description": "Type-safe config for TypeScript. Read typed values from any source, process.env, .env files, Cloudflare Workers bindings, browser bundles, or any object you supply. Zero runtime dependencies, one API across Node, Bun, Deno, Workers, and the browser. TC39 accessor decorators (legacy decorators at envapt/legacy), converters, and Standard Schema (zod/valibot/arktype) validation.",
6
6
  "types": "./dist/types/index.d.mts",
7
7
  "exports": {