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