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,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,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
@@ -1,123 +0,0 @@
1
- import { ArrayOf, ConverterToken, CustomElementConverter } from "../converters/Converters.mjs";
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.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.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.mts.map
@@ -1,39 +0,0 @@
1
- import { EnvaptConverter } from "./Conversion.mjs";
2
- import { Environment } from "../core/EnvironmentMethods.mjs";
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.mts.map
@@ -1,12 +0,0 @@
1
- import { StandardSchemaV1 } from "../infra/StandardSchema.mjs";
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.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.mts.map
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes