envapt 5.0.2 → 5.1.0

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 (159) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/Debug.cjs +2 -0
  3. package/dist/Debug.cjs.map +1 -0
  4. package/dist/Debug.d.cts +13 -0
  5. package/dist/Debug.d.cts.map +1 -0
  6. package/dist/Debug.d.mts +13 -0
  7. package/dist/Debug.d.mts.map +1 -0
  8. package/dist/Debug.mjs +2 -0
  9. package/dist/Debug.mjs.map +1 -0
  10. package/dist/Dotenv.cjs +3 -0
  11. package/dist/Dotenv.cjs.map +1 -0
  12. package/dist/Dotenv.d.cts +17 -0
  13. package/dist/Dotenv.d.cts.map +1 -0
  14. package/dist/Dotenv.d.mts +17 -0
  15. package/dist/Dotenv.d.mts.map +1 -0
  16. package/dist/Dotenv.mjs +3 -0
  17. package/dist/Dotenv.mjs.map +1 -0
  18. package/dist/Envapter.cjs +2 -0
  19. package/dist/Envapter.cjs.map +1 -0
  20. package/dist/Envapter.d.cts +70 -0
  21. package/dist/Envapter.d.cts.map +1 -0
  22. package/dist/Envapter.d.mts +70 -0
  23. package/dist/Envapter.d.mts.map +1 -0
  24. package/dist/Envapter.mjs +2 -0
  25. package/dist/Envapter.mjs.map +1 -0
  26. package/dist/Error.cjs +2 -0
  27. package/dist/Error.cjs.map +1 -0
  28. package/dist/Error.d.cts +68 -0
  29. package/dist/Error.d.cts.map +1 -0
  30. package/dist/Error.d.mts +68 -0
  31. package/dist/Error.d.mts.map +1 -0
  32. package/dist/Error.mjs +2 -0
  33. package/dist/Error.mjs.map +1 -0
  34. package/dist/StandardSchema.d.cts +59 -0
  35. package/dist/StandardSchema.d.cts.map +1 -0
  36. package/dist/StandardSchema.d.mts +59 -0
  37. package/dist/StandardSchema.d.mts.map +1 -0
  38. package/dist/TemplateResolver.cjs +2 -0
  39. package/dist/TemplateResolver.cjs.map +1 -0
  40. package/dist/TemplateResolver.d.cts +17 -0
  41. package/dist/TemplateResolver.d.cts.map +1 -0
  42. package/dist/TemplateResolver.d.mts +17 -0
  43. package/dist/TemplateResolver.d.mts.map +1 -0
  44. package/dist/TemplateResolver.mjs +2 -0
  45. package/dist/TemplateResolver.mjs.map +1 -0
  46. package/dist/Validators.cjs +2 -0
  47. package/dist/Validators.cjs.map +1 -0
  48. package/dist/Validators.mjs +2 -0
  49. package/dist/Validators.mjs.map +1 -0
  50. package/dist/_virtual/_rolldown/runtime.cjs +1 -0
  51. package/dist/config.cjs +1 -1
  52. package/dist/config.cjs.map +1 -1
  53. package/dist/config.mjs +1 -1
  54. package/dist/config.mjs.map +1 -1
  55. package/dist/converters/BuiltInConverters.cjs +2 -0
  56. package/dist/converters/BuiltInConverters.cjs.map +1 -0
  57. package/dist/converters/BuiltInConverters.mjs +2 -0
  58. package/dist/converters/BuiltInConverters.mjs.map +1 -0
  59. package/dist/converters/Converters.cjs +2 -0
  60. package/dist/converters/Converters.cjs.map +1 -0
  61. package/dist/converters/Converters.d.cts +93 -0
  62. package/dist/converters/Converters.d.cts.map +1 -0
  63. package/dist/converters/Converters.d.mts +93 -0
  64. package/dist/converters/Converters.d.mts.map +1 -0
  65. package/dist/converters/Converters.mjs +2 -0
  66. package/dist/converters/Converters.mjs.map +1 -0
  67. package/dist/converters/ListOfBuiltInConverters.cjs +2 -0
  68. package/dist/converters/ListOfBuiltInConverters.cjs.map +1 -0
  69. package/dist/converters/ListOfBuiltInConverters.mjs +2 -0
  70. package/dist/converters/ListOfBuiltInConverters.mjs.map +1 -0
  71. package/dist/converters/ValueConverter.cjs +2 -0
  72. package/dist/converters/ValueConverter.cjs.map +1 -0
  73. package/dist/converters/ValueConverter.d.cts +25 -0
  74. package/dist/converters/ValueConverter.d.cts.map +1 -0
  75. package/dist/converters/ValueConverter.d.mts +25 -0
  76. package/dist/converters/ValueConverter.d.mts.map +1 -0
  77. package/dist/converters/ValueConverter.mjs +2 -0
  78. package/dist/converters/ValueConverter.mjs.map +1 -0
  79. package/dist/core/AdvancedMethods.cjs +2 -0
  80. package/dist/core/AdvancedMethods.cjs.map +1 -0
  81. package/dist/core/AdvancedMethods.d.cts +76 -0
  82. package/dist/core/AdvancedMethods.d.cts.map +1 -0
  83. package/dist/core/AdvancedMethods.d.mts +76 -0
  84. package/dist/core/AdvancedMethods.d.mts.map +1 -0
  85. package/dist/core/AdvancedMethods.mjs +2 -0
  86. package/dist/core/AdvancedMethods.mjs.map +1 -0
  87. package/dist/core/EnvapterBase.cjs +2 -0
  88. package/dist/core/EnvapterBase.cjs.map +1 -0
  89. package/dist/core/EnvapterBase.d.cts +105 -0
  90. package/dist/core/EnvapterBase.d.cts.map +1 -0
  91. package/dist/core/EnvapterBase.d.mts +105 -0
  92. package/dist/core/EnvapterBase.d.mts.map +1 -0
  93. package/dist/core/EnvapterBase.mjs +2 -0
  94. package/dist/core/EnvapterBase.mjs.map +1 -0
  95. package/dist/core/EnvironmentMethods.cjs +2 -0
  96. package/dist/core/EnvironmentMethods.cjs.map +1 -0
  97. package/dist/core/EnvironmentMethods.d.cts +132 -0
  98. package/dist/core/EnvironmentMethods.d.cts.map +1 -0
  99. package/dist/core/EnvironmentMethods.d.mts +132 -0
  100. package/dist/core/EnvironmentMethods.d.mts.map +1 -0
  101. package/dist/core/EnvironmentMethods.mjs +2 -0
  102. package/dist/core/EnvironmentMethods.mjs.map +1 -0
  103. package/dist/core/PrimitiveMethods.cjs +2 -0
  104. package/dist/core/PrimitiveMethods.cjs.map +1 -0
  105. package/dist/core/PrimitiveMethods.d.cts +70 -0
  106. package/dist/core/PrimitiveMethods.d.cts.map +1 -0
  107. package/dist/core/PrimitiveMethods.d.mts +70 -0
  108. package/dist/core/PrimitiveMethods.d.mts.map +1 -0
  109. package/dist/core/PrimitiveMethods.mjs +2 -0
  110. package/dist/core/PrimitiveMethods.mjs.map +1 -0
  111. package/dist/decorators/Envapt.cjs +2 -0
  112. package/dist/decorators/Envapt.cjs.map +1 -0
  113. package/dist/decorators/Envapt.d.cts +233 -0
  114. package/dist/decorators/Envapt.d.cts.map +1 -0
  115. package/dist/decorators/Envapt.d.mts +233 -0
  116. package/dist/decorators/Envapt.d.mts.map +1 -0
  117. package/dist/decorators/Envapt.mjs +2 -0
  118. package/dist/decorators/Envapt.mjs.map +1 -0
  119. package/dist/decorators/SugarDecorators.cjs +2 -0
  120. package/dist/decorators/SugarDecorators.cjs.map +1 -0
  121. package/dist/decorators/SugarDecorators.d.cts +34 -0
  122. package/dist/decorators/SugarDecorators.d.cts.map +1 -0
  123. package/dist/decorators/SugarDecorators.d.mts +34 -0
  124. package/dist/decorators/SugarDecorators.d.mts.map +1 -0
  125. package/dist/decorators/SugarDecorators.mjs +2 -0
  126. package/dist/decorators/SugarDecorators.mjs.map +1 -0
  127. package/dist/decorators/createPropertyDecorator.cjs +2 -0
  128. package/dist/decorators/createPropertyDecorator.cjs.map +1 -0
  129. package/dist/decorators/createPropertyDecorator.mjs +2 -0
  130. package/dist/decorators/createPropertyDecorator.mjs.map +1 -0
  131. package/dist/index.cjs +1 -2
  132. package/dist/index.d.cts +14 -1127
  133. package/dist/index.d.mts +14 -1127
  134. package/dist/index.mjs +1 -2
  135. package/dist/types/Conversion.d.cts +128 -0
  136. package/dist/types/Conversion.d.cts.map +1 -0
  137. package/dist/types/Conversion.d.mts +128 -0
  138. package/dist/types/Conversion.d.mts.map +1 -0
  139. package/dist/types/Env.d.cts +17 -0
  140. package/dist/types/Env.d.cts.map +1 -0
  141. package/dist/types/Env.d.mts +17 -0
  142. package/dist/types/Env.d.mts.map +1 -0
  143. package/dist/types/Options.d.cts +39 -0
  144. package/dist/types/Options.d.cts.map +1 -0
  145. package/dist/types/Options.d.mts +39 -0
  146. package/dist/types/Options.d.mts.map +1 -0
  147. package/dist/types/Schema.d.cts +12 -0
  148. package/dist/types/Schema.d.cts.map +1 -0
  149. package/dist/types/Schema.d.mts +12 -0
  150. package/dist/types/Schema.d.mts.map +1 -0
  151. package/package.json +2 -2
  152. package/dist/Envapter-CBSM3v-5.cjs +0 -3
  153. package/dist/Envapter-CBSM3v-5.cjs.map +0 -1
  154. package/dist/Envapter-D8FEdzBR.mjs +0 -3
  155. package/dist/Envapter-D8FEdzBR.mjs.map +0 -1
  156. package/dist/index.cjs.map +0 -1
  157. package/dist/index.d.cts.map +0 -1
  158. package/dist/index.d.mts.map +0 -1
  159. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,105 @@
1
+ import { DebugLevel } from "../Debug.cjs";
2
+ import { EnvFileOptions } from "../Dotenv.cjs";
3
+ import { EnvKeyInput } from "../types/Env.cjs";
4
+
5
+ //#region src/core/EnvapterBase.d.ts
6
+ /**
7
+ * Base class for environment variable management
8
+ * Handles configuration, caching, and basic environment loading
9
+ * @internal
10
+ */
11
+ declare abstract class EnvapterBase {
12
+ protected static _envPaths: string[];
13
+ protected static _envPathsExplicitlySet: boolean;
14
+ protected static _baseDir: string | undefined;
15
+ protected static _userDefinedEnvFileOptions: EnvFileOptions;
16
+ protected static _strict: boolean;
17
+ protected static _syncProcessEnv: boolean;
18
+ protected static _dotenvAddedKeys: Set<string>;
19
+ /**
20
+ * Enable or disable strict mode. Default `false`. Setting refreshes the cache so
21
+ * previously-cached converted values get re-evaluated under the new rule.
22
+ */
23
+ static set strict(value: boolean);
24
+ static get strict(): boolean;
25
+ /**
26
+ * Set the debug log level. Defaults to `silent`. When unset, reads `ENVAPT_DEBUG` from
27
+ * `process.env` on first access; the setter overrides any env-var value. Output goes
28
+ * to stderr prefixed with `[envapt]`.
29
+ */
30
+ static set debug(level: DebugLevel);
31
+ static get debug(): DebugLevel;
32
+ /**
33
+ * Opt-in mirror of dotenv-loaded keys back to `process.env`. Default `false`.
34
+ *
35
+ * Only keys the loader actually wrote are mirrored, so collision behavior follows
36
+ * `envFileOptions.override`: with the default `false`, pre-existing `process.env` values
37
+ * are preserved; with `true`, the file value wins in both the cache and the mirror.
38
+ *
39
+ * Flipping `false → true` mirrors the existing tracked delta immediately (no cache
40
+ * refresh). Flipping `true → false` is one-way: previously mirrored keys remain in
41
+ * `process.env` until the process exits.
42
+ */
43
+ static set syncProcessEnv(value: boolean);
44
+ static get syncProcessEnv(): boolean;
45
+ protected static treatAsMissing(value: string | undefined): boolean;
46
+ /**
47
+ * Set custom .env file paths. Accepts either a single path or array of paths.
48
+ * Setting new paths clears the cache and reloads environment variables.
49
+ *
50
+ * When set, this takes absolute precedence. The dotenv-flow auto-cascade and any
51
+ * {@link configureProfiles} configuration are ignored.
52
+ */
53
+ static set envPaths(paths: string[] | string);
54
+ /**
55
+ * Get currently configured .env file paths
56
+ */
57
+ static get envPaths(): string[];
58
+ /**
59
+ * Set a base directory that relative `.env` paths resolve against instead of
60
+ * `process.cwd()`: the auto-cascade, {@link configureProfiles} paths, and relative
61
+ * `envPaths`. Absolute paths always bypass it. Pass a directory, or a module URL
62
+ * (`import.meta.url`, ESM) / `import.meta.dirname` / `__dirname` (CJS) to anchor
63
+ * resolution next to the calling file regardless of launch directory.
64
+ *
65
+ * Set this before `envPaths` so relative `envPaths` validate against the right directory.
66
+ * Unset (`undefined`) restores `process.cwd()` resolution.
67
+ */
68
+ static set baseDir(value: string | URL | undefined);
69
+ static get baseDir(): string | undefined;
70
+ private static normalizeBaseDir;
71
+ protected static resolveAgainstBase(candidate: string): string;
72
+ static set envFileOptions(config: EnvFileOptions);
73
+ /**
74
+ * Get current dotenv configuration options
75
+ */
76
+ static get envFileOptions(): EnvFileOptions;
77
+ protected static refreshCache(): void;
78
+ protected static mirrorToProcessEnv(): void;
79
+ /**
80
+ * Resolve the effective `.env` paths to load. Default implementation just returns the
81
+ * explicit `_envPaths` array; subclasses (`EnvironmentMethods`) override to layer in the
82
+ * dotenv-flow cascade and any {@link configureProfiles} overrides when `envPaths` was
83
+ * never explicitly set.
84
+ * @internal
85
+ */
86
+ protected static resolveEffectivePaths(): string[];
87
+ protected static resolveKeyInput(keyInput: EnvKeyInput): {
88
+ key: string;
89
+ value: string | undefined;
90
+ };
91
+ protected static get config(): Map<string, unknown>;
92
+ /**
93
+ * Eagerly load the `.env` cascade now instead of lazily on the first read. Idempotent: a no-op
94
+ * once the cache is built. Useful before mirroring to `process.env` (see {@link syncProcessEnv}),
95
+ * which is what the `envapt/config` side-effect entry does.
96
+ */
97
+ static load(): void;
98
+ /**
99
+ * Read an environment variable as its raw string, skipping parsing and conversion.
100
+ */
101
+ getRaw(key: EnvKeyInput): string | undefined;
102
+ }
103
+ //#endregion
104
+ export { EnvapterBase };
105
+ //# sourceMappingURL=EnvapterBase.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvapterBase.d.cts","names":[],"sources":["../../src/core/EnvapterBase.ts"],"mappings":";;;;;;;;;;uBAwBsB,YAAA;EAAA,iBACD,SAAA;EAAA,iBACA,sBAAA;EAAA,iBACA,QAAA;EAAA,iBACA,0BAAA,EAA4B,cAAA;EAAA,iBAC5B,OAAA;EAAA,iBACA,eAAA;EAAA,iBAEA,gBAAA,EAAkB,GAAA;EANlB;;;;EAAA,WAYN,MAAA,CAAO,KAAA;EAAA,WAOP,MAAA,CAAA;EAbM;;;;;EAAA,WAsBN,KAAA,CAAM,KAAA,EAAO,UAAA;EAAA,WAIb,KAAA,CAAA,GAAS,UAAA;EAJH;;;;;;;;;;;EAAA,WAmBN,cAAA,CAAe,KAAA;EAAA,WAQf,cAAA,CAAA;EAAA,iBAIM,cAAA,CAAe,KAAA;EA4CrB;;;;;;;EAAA,WA/BA,QAAA,CAAS,KAAA;EA0DS;;;EAAA,WA9ClB,QAAA,CAAA;EAiFM;;;;;;;;;;EAAA,WAnEN,OAAA,CAAQ,KAAA,WAAgB,GAAA;EAAA,WAKxB,OAAA,CAAA;EAAA,eAKI,gBAAA;EAAA,iBAOE,kBAAA,CAAmB,SAAA;EAAA,WAMzB,cAAA,CAAe,MAAA,EAAQ,cAAA;;;;aASvB,cAAA,CAAA,GAAkB,cAAA;EAAA,iBAIZ,YAAA,CAAA;EAAA,iBAOA,kBAAA,CAAA;;;;;;;;mBAmBA,qBAAA,CAAA;EAAA,iBAKA,eAAA,CAAgB,QAAA,EAAU,WAAA;IAAgB,GAAA;IAAa,KAAA;EAAA;EAAA,qBA0BnD,MAAA,CAAA,GAAU,GAAA;;;;;;SA+BxB,IAAA,CAAA;;;;EAOP,MAAA,CAAO,GAAA,EAAK,WAAA;AAAA"}
@@ -0,0 +1,105 @@
1
+ import { DebugLevel } from "../Debug.mjs";
2
+ import { EnvFileOptions } from "../Dotenv.mjs";
3
+ import { EnvKeyInput } from "../types/Env.mjs";
4
+
5
+ //#region src/core/EnvapterBase.d.ts
6
+ /**
7
+ * Base class for environment variable management
8
+ * Handles configuration, caching, and basic environment loading
9
+ * @internal
10
+ */
11
+ declare abstract class EnvapterBase {
12
+ protected static _envPaths: string[];
13
+ protected static _envPathsExplicitlySet: boolean;
14
+ protected static _baseDir: string | undefined;
15
+ protected static _userDefinedEnvFileOptions: EnvFileOptions;
16
+ protected static _strict: boolean;
17
+ protected static _syncProcessEnv: boolean;
18
+ protected static _dotenvAddedKeys: Set<string>;
19
+ /**
20
+ * Enable or disable strict mode. Default `false`. Setting refreshes the cache so
21
+ * previously-cached converted values get re-evaluated under the new rule.
22
+ */
23
+ static set strict(value: boolean);
24
+ static get strict(): boolean;
25
+ /**
26
+ * Set the debug log level. Defaults to `silent`. When unset, reads `ENVAPT_DEBUG` from
27
+ * `process.env` on first access; the setter overrides any env-var value. Output goes
28
+ * to stderr prefixed with `[envapt]`.
29
+ */
30
+ static set debug(level: DebugLevel);
31
+ static get debug(): DebugLevel;
32
+ /**
33
+ * Opt-in mirror of dotenv-loaded keys back to `process.env`. Default `false`.
34
+ *
35
+ * Only keys the loader actually wrote are mirrored, so collision behavior follows
36
+ * `envFileOptions.override`: with the default `false`, pre-existing `process.env` values
37
+ * are preserved; with `true`, the file value wins in both the cache and the mirror.
38
+ *
39
+ * Flipping `false → true` mirrors the existing tracked delta immediately (no cache
40
+ * refresh). Flipping `true → false` is one-way: previously mirrored keys remain in
41
+ * `process.env` until the process exits.
42
+ */
43
+ static set syncProcessEnv(value: boolean);
44
+ static get syncProcessEnv(): boolean;
45
+ protected static treatAsMissing(value: string | undefined): boolean;
46
+ /**
47
+ * Set custom .env file paths. Accepts either a single path or array of paths.
48
+ * Setting new paths clears the cache and reloads environment variables.
49
+ *
50
+ * When set, this takes absolute precedence. The dotenv-flow auto-cascade and any
51
+ * {@link configureProfiles} configuration are ignored.
52
+ */
53
+ static set envPaths(paths: string[] | string);
54
+ /**
55
+ * Get currently configured .env file paths
56
+ */
57
+ static get envPaths(): string[];
58
+ /**
59
+ * Set a base directory that relative `.env` paths resolve against instead of
60
+ * `process.cwd()`: the auto-cascade, {@link configureProfiles} paths, and relative
61
+ * `envPaths`. Absolute paths always bypass it. Pass a directory, or a module URL
62
+ * (`import.meta.url`, ESM) / `import.meta.dirname` / `__dirname` (CJS) to anchor
63
+ * resolution next to the calling file regardless of launch directory.
64
+ *
65
+ * Set this before `envPaths` so relative `envPaths` validate against the right directory.
66
+ * Unset (`undefined`) restores `process.cwd()` resolution.
67
+ */
68
+ static set baseDir(value: string | URL | undefined);
69
+ static get baseDir(): string | undefined;
70
+ private static normalizeBaseDir;
71
+ protected static resolveAgainstBase(candidate: string): string;
72
+ static set envFileOptions(config: EnvFileOptions);
73
+ /**
74
+ * Get current dotenv configuration options
75
+ */
76
+ static get envFileOptions(): EnvFileOptions;
77
+ protected static refreshCache(): void;
78
+ protected static mirrorToProcessEnv(): void;
79
+ /**
80
+ * Resolve the effective `.env` paths to load. Default implementation just returns the
81
+ * explicit `_envPaths` array; subclasses (`EnvironmentMethods`) override to layer in the
82
+ * dotenv-flow cascade and any {@link configureProfiles} overrides when `envPaths` was
83
+ * never explicitly set.
84
+ * @internal
85
+ */
86
+ protected static resolveEffectivePaths(): string[];
87
+ protected static resolveKeyInput(keyInput: EnvKeyInput): {
88
+ key: string;
89
+ value: string | undefined;
90
+ };
91
+ protected static get config(): Map<string, unknown>;
92
+ /**
93
+ * Eagerly load the `.env` cascade now instead of lazily on the first read. Idempotent: a no-op
94
+ * once the cache is built. Useful before mirroring to `process.env` (see {@link syncProcessEnv}),
95
+ * which is what the `envapt/config` side-effect entry does.
96
+ */
97
+ static load(): void;
98
+ /**
99
+ * Read an environment variable as its raw string, skipping parsing and conversion.
100
+ */
101
+ getRaw(key: EnvKeyInput): string | undefined;
102
+ }
103
+ //#endregion
104
+ export { EnvapterBase };
105
+ //# sourceMappingURL=EnvapterBase.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvapterBase.d.mts","names":[],"sources":["../../src/core/EnvapterBase.ts"],"mappings":";;;;;;;;;;uBAwBsB,YAAA;EAAA,iBACD,SAAA;EAAA,iBACA,sBAAA;EAAA,iBACA,QAAA;EAAA,iBACA,0BAAA,EAA4B,cAAA;EAAA,iBAC5B,OAAA;EAAA,iBACA,eAAA;EAAA,iBAEA,gBAAA,EAAkB,GAAA;EANlB;;;;EAAA,WAYN,MAAA,CAAO,KAAA;EAAA,WAOP,MAAA,CAAA;EAbM;;;;;EAAA,WAsBN,KAAA,CAAM,KAAA,EAAO,UAAA;EAAA,WAIb,KAAA,CAAA,GAAS,UAAA;EAJH;;;;;;;;;;;EAAA,WAmBN,cAAA,CAAe,KAAA;EAAA,WAQf,cAAA,CAAA;EAAA,iBAIM,cAAA,CAAe,KAAA;EA4CrB;;;;;;;EAAA,WA/BA,QAAA,CAAS,KAAA;EA0DS;;;EAAA,WA9ClB,QAAA,CAAA;EAiFM;;;;;;;;;;EAAA,WAnEN,OAAA,CAAQ,KAAA,WAAgB,GAAA;EAAA,WAKxB,OAAA,CAAA;EAAA,eAKI,gBAAA;EAAA,iBAOE,kBAAA,CAAmB,SAAA;EAAA,WAMzB,cAAA,CAAe,MAAA,EAAQ,cAAA;;;;aASvB,cAAA,CAAA,GAAkB,cAAA;EAAA,iBAIZ,YAAA,CAAA;EAAA,iBAOA,kBAAA,CAAA;;;;;;;;mBAmBA,qBAAA,CAAA;EAAA,iBAKA,eAAA,CAAgB,QAAA,EAAU,WAAA;IAAgB,GAAA;IAAa,KAAA;EAAA;EAAA,qBA0BnD,MAAA,CAAA,GAAU,GAAA;;;;;;SA+BxB,IAAA,CAAA;;;;EAOP,MAAA,CAAO,GAAA,EAAK,WAAA;AAAA"}
@@ -0,0 +1,2 @@
1
+ import{EnvaptError as e}from"../Error.mjs";import{Validator as t}from"../Validators.mjs";import{debugVerbose as n,getDebugLevel as r,setDebugLevel as i}from"../Debug.mjs";import{loadDotenv as a}from"../Dotenv.mjs";import{dirname as o,isAbsolute as s,join as c,resolve as l}from"node:path";import u from"node:process";import{fileURLToPath as d}from"node:url";const f=new Map;var p=class p{static _envPaths=[`.env`];static _envPathsExplicitlySet=!1;static _baseDir=void 0;static _userDefinedEnvFileOptions={};static _strict=!1;static _syncProcessEnv=!1;static _dotenvAddedKeys=new Set;static set strict(e){p._strict=e,this.refreshCache()}static get strict(){return p._strict}static set debug(e){i(e)}static get debug(){return r()}static set syncProcessEnv(e){t.validateSyncProcessEnv(e);let n=p._syncProcessEnv;p._syncProcessEnv=e,!n&&e&&f.size>0&&this.mirrorToProcessEnv()}static get syncProcessEnv(){return p._syncProcessEnv}static treatAsMissing(e){return!!(e===void 0||e===``||p._strict&&e.trim()===``)}static set envPaths(e){let n=Array.isArray(e)?e:[e];t.validateEnvFilesExist(n.map(e=>this.resolveAgainstBase(e))),this._envPaths=n,this._envPathsExplicitlySet=!0,this.refreshCache()}static get envPaths(){return this._envPaths}static set baseDir(e){p._baseDir=e===void 0?void 0:this.normalizeBaseDir(e),this.refreshCache()}static get baseDir(){return p._baseDir}static normalizeBaseDir(e){return e instanceof URL||e.startsWith(`file:`)?o(d(e)):l(e)}static resolveAgainstBase(e){return p._baseDir===void 0||s(e)?e:c(p._baseDir,e)}static set envFileOptions(e){t.validateEnvFileOptions(e),this._userDefinedEnvFileOptions=e,this.refreshCache()}static get envFileOptions(){return this._userDefinedEnvFileOptions}static refreshCache(){f.clear(),p._dotenvAddedKeys=new Set,n(`cache cleared, reloading config`),this.config}static mirrorToProcessEnv(){if(p._dotenvAddedKeys.size!==0){for(let e of p._dotenvAddedKeys){let t=f.get(e);typeof t==`string`&&(u.env[e]=t,n(`mirrored ${e} to process.env`))}n(`mirrored ${p._dotenvAddedKeys.size} keys to process.env`)}}static resolveEffectivePaths(){return this._envPaths.map(e=>this.resolveAgainstBase(e))}static resolveKeyInput(t){let n=Array.isArray(t)?t:[t];if(n.length===0)throw new e(304,`At least one environment key must be provided.`);if(n.some(e=>typeof e!=`string`))throw new e(304,`Environment keys must be strings.`);if(n.some(e=>e.trim()===``))throw new e(304,`Environment keys cannot be empty strings.`);for(let e of n){let t=this.config.get(e);if(t!==void 0)return{key:e,value:t}}return{key:n[0],value:void 0}}static get config(){if(f.size===0){let e={...u.env},t=this.resolveEffectivePaths();n(`effective .env paths: ${t.length===0?`(none)`:t.join(`, `)}`);let r=new Set;try{r=a({...this._userDefinedEnvFileOptions,path:t,processEnv:e})}catch{}p._dotenvAddedKeys=r;for(let[t,n]of Object.entries(e))f.set(t,n);n(`cache populated: ${f.size} keys total`),p._syncProcessEnv&&this.mirrorToProcessEnv()}return f}static load(){this.config}getRaw(e){return p.resolveKeyInput(e).value}};export{f as EnvaptCache,p as EnvapterBase};
2
+ //# sourceMappingURL=EnvapterBase.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvapterBase.mjs","names":[],"sources":["../../src/core/EnvapterBase.ts"],"sourcesContent":["import { dirname, isAbsolute, join, resolve } from 'node:path';\nimport process from 'node:process';\nimport { fileURLToPath } from 'node:url';\n\nimport { debugVerbose, getDebugLevel, setDebugLevel } from '../Debug';\nimport { loadDotenv } from '../Dotenv';\nimport { EnvaptError, EnvaptErrorCodes } from '../Error';\nimport { Validator } from '../Validators';\n\nimport type { DebugLevel } from '../Debug';\nimport type { EnvFileOptions } from '../Dotenv';\nimport type { EnvKeyInput } from '../types';\n\n/**\n * Base cache for environment variables and computed values\n * @internal\n */\nexport const EnvaptCache = new Map<string, unknown>();\n\n/**\n * Base class for environment variable management\n * Handles configuration, caching, and basic environment loading\n * @internal\n */\nexport abstract class EnvapterBase {\n protected static _envPaths: string[] = ['.env'];\n protected static _envPathsExplicitlySet = false;\n protected static _baseDir: string | undefined = undefined;\n protected static _userDefinedEnvFileOptions: EnvFileOptions = {};\n protected static _strict = false;\n protected static _syncProcessEnv = false;\n // Loader-written keys only (collisions skipped). Refilled on every cache rebuild.\n protected static _dotenvAddedKeys: Set<string> = new Set<string>();\n\n /**\n * Enable or disable strict mode. Default `false`. Setting refreshes the cache so\n * previously-cached converted values get re-evaluated under the new rule.\n */\n static set strict(value: boolean) {\n // Anchored to EnvapterBase: `this._strict` would write an own-property on the subclass that base readers miss.\n EnvapterBase._strict = value;\n // `this`, not EnvapterBase: rebuild via the subclass so its `resolveEffectivePaths` override is honored.\n this.refreshCache();\n }\n\n static get strict(): boolean {\n return EnvapterBase._strict;\n }\n\n /**\n * Set the debug log level. Defaults to `silent`. When unset, reads `ENVAPT_DEBUG` from\n * `process.env` on first access; the setter overrides any env-var value. Output goes\n * to stderr prefixed with `[envapt]`.\n */\n static set debug(level: DebugLevel) {\n setDebugLevel(level);\n }\n\n static get debug(): DebugLevel {\n return getDebugLevel();\n }\n\n /**\n * Opt-in mirror of dotenv-loaded keys back to `process.env`. Default `false`.\n *\n * Only keys the loader actually wrote are mirrored, so collision behavior follows\n * `envFileOptions.override`: with the default `false`, pre-existing `process.env` values\n * are preserved; with `true`, the file value wins in both the cache and the mirror.\n *\n * Flipping `false → true` mirrors the existing tracked delta immediately (no cache\n * refresh). Flipping `true → false` is one-way: previously mirrored keys remain in\n * `process.env` until the process exits.\n */\n static set syncProcessEnv(value: boolean) {\n Validator.validateSyncProcessEnv(value);\n const previous = EnvapterBase._syncProcessEnv;\n // Anchored to EnvapterBase: `this._syncProcessEnv` would write an own-property on the subclass that base readers miss.\n EnvapterBase._syncProcessEnv = value;\n if (!previous && value && EnvaptCache.size > 0) this.mirrorToProcessEnv();\n }\n\n static get syncProcessEnv(): boolean {\n return EnvapterBase._syncProcessEnv;\n }\n\n protected static treatAsMissing(value: string | undefined): boolean {\n if (value === undefined || value === '') return true;\n if (EnvapterBase._strict && value.trim() === '') return true;\n return false;\n }\n\n /**\n * Set custom .env file paths. Accepts either a single path or array of paths.\n * Setting new paths clears the cache and reloads environment variables.\n *\n * When set, this takes absolute precedence. The dotenv-flow auto-cascade and any\n * {@link configureProfiles} configuration are ignored.\n */\n static set envPaths(paths: string[] | string) {\n const newPaths = Array.isArray(paths) ? paths : [paths];\n Validator.validateEnvFilesExist(newPaths.map((p) => this.resolveAgainstBase(p)));\n\n this._envPaths = newPaths;\n this._envPathsExplicitlySet = true;\n this.refreshCache();\n }\n\n /**\n * Get currently configured .env file paths\n */\n static get envPaths(): string[] {\n return this._envPaths;\n }\n\n /**\n * Set a base directory that relative `.env` paths resolve against instead of\n * `process.cwd()`: the auto-cascade, {@link configureProfiles} paths, and relative\n * `envPaths`. Absolute paths always bypass it. Pass a directory, or a module URL\n * (`import.meta.url`, ESM) / `import.meta.dirname` / `__dirname` (CJS) to anchor\n * resolution next to the calling file regardless of launch directory.\n *\n * Set this before `envPaths` so relative `envPaths` validate against the right directory.\n * Unset (`undefined`) restores `process.cwd()` resolution.\n */\n static set baseDir(value: string | URL | undefined) {\n EnvapterBase._baseDir = value === undefined ? undefined : this.normalizeBaseDir(value);\n this.refreshCache();\n }\n\n static get baseDir(): string | undefined {\n return EnvapterBase._baseDir;\n }\n\n // `file:` URLs resolve to their containing directory; plain paths (`import.meta.dirname`, `__dirname`) are taken as the directory.\n private static normalizeBaseDir(value: string | URL): string {\n if (value instanceof URL) return dirname(fileURLToPath(value));\n if (value.startsWith('file:')) return dirname(fileURLToPath(value));\n return resolve(value);\n }\n\n // No baseDir: path is returned unchanged so Node resolves it against process.cwd() (the historical default).\n protected static resolveAgainstBase(candidate: string): string {\n if (EnvapterBase._baseDir === undefined) return candidate;\n if (isAbsolute(candidate)) return candidate;\n return join(EnvapterBase._baseDir, candidate);\n }\n\n static set envFileOptions(config: EnvFileOptions) {\n Validator.validateEnvFileOptions(config);\n this._userDefinedEnvFileOptions = config;\n this.refreshCache();\n }\n\n /**\n * Get current dotenv configuration options\n */\n static get envFileOptions(): EnvFileOptions {\n return this._userDefinedEnvFileOptions;\n }\n\n protected static refreshCache(): void {\n EnvaptCache.clear();\n EnvapterBase._dotenvAddedKeys = new Set();\n debugVerbose('cache cleared, reloading config');\n void this.config; // getter rebuilds the cache as a side effect\n }\n\n protected static mirrorToProcessEnv(): void {\n if (EnvapterBase._dotenvAddedKeys.size === 0) return;\n for (const key of EnvapterBase._dotenvAddedKeys) {\n const value = EnvaptCache.get(key);\n /* v8 ignore next -- @preserve loader only writes strings; defensive against future cache contents */\n if (typeof value !== 'string') continue;\n process.env[key] = value;\n debugVerbose(`mirrored ${key} to process.env`);\n }\n debugVerbose(`mirrored ${EnvapterBase._dotenvAddedKeys.size} keys to process.env`);\n }\n\n /**\n * Resolve the effective `.env` paths to load. Default implementation just returns the\n * explicit `_envPaths` array; subclasses (`EnvironmentMethods`) override to layer in the\n * dotenv-flow cascade and any {@link configureProfiles} overrides when `envPaths` was\n * never explicitly set.\n * @internal\n */\n protected static resolveEffectivePaths(): string[] {\n /* v8 ignore next -- @preserve */\n return this._envPaths.map((p) => this.resolveAgainstBase(p));\n }\n\n protected static resolveKeyInput(keyInput: EnvKeyInput): { key: string; value: string | undefined } {\n const keys = Array.isArray(keyInput) ? keyInput : [keyInput];\n const normalizedKeys = keys as readonly string[];\n\n if (normalizedKeys.length === 0) {\n throw new EnvaptError(EnvaptErrorCodes.InvalidKeyInput, 'At least one environment key must be provided.');\n }\n\n if (normalizedKeys.some((k) => typeof k !== 'string')) {\n throw new EnvaptError(EnvaptErrorCodes.InvalidKeyInput, 'Environment keys must be strings.');\n }\n\n if (normalizedKeys.some((k) => k.trim() === '')) {\n throw new EnvaptError(EnvaptErrorCodes.InvalidKeyInput, 'Environment keys cannot be empty strings.');\n }\n\n for (const candidate of normalizedKeys) {\n const value = this.config.get(candidate) as string | undefined;\n if (value !== undefined) {\n return { key: candidate, value };\n }\n }\n\n return { key: normalizedKeys[0] as string, value: undefined };\n }\n\n protected static get config(): Map<string, unknown> {\n if (EnvaptCache.size === 0) {\n // Clone so the loader and downstream reads never mutate process.env.\n const isolatedEnv: Record<string, string> = { ...(process.env as Record<string, string>) };\n\n // Outside the try below so a missing configured profile path surfaces its EnvaptError; only dotenv parse errors stay caught.\n const effectivePaths = this.resolveEffectivePaths();\n debugVerbose(`effective .env paths: ${effectivePaths.length === 0 ? '(none)' : effectivePaths.join(', ')}`);\n\n let added = new Set<string>();\n try {\n added = loadDotenv({\n ...this._userDefinedEnvFileOptions,\n path: effectivePaths,\n processEnv: isolatedEnv\n });\n } catch {}\n EnvapterBase._dotenvAddedKeys = added;\n for (const [key, value] of Object.entries(isolatedEnv)) EnvaptCache.set(key, value);\n debugVerbose(`cache populated: ${EnvaptCache.size} keys total`);\n if (EnvapterBase._syncProcessEnv) this.mirrorToProcessEnv();\n }\n\n return EnvaptCache;\n }\n\n /**\n * Eagerly load the `.env` cascade now instead of lazily on the first read. Idempotent: a no-op\n * once the cache is built. Useful before mirroring to `process.env` (see {@link syncProcessEnv}),\n * which is what the `envapt/config` side-effect entry does.\n */\n static load(): void {\n void this.config;\n }\n\n /**\n * Read an environment variable as its raw string, skipping parsing and conversion.\n */\n getRaw(key: EnvKeyInput): string | undefined {\n return EnvapterBase.resolveKeyInput(key).value;\n }\n}\n"],"mappings":"sWAiBA,MAAa,EAAc,IAAI,IAO/B,IAAsB,EAAtB,MAAsB,CAAa,CAC/B,OAAiB,UAAsB,CAAC,MAAM,EAC9C,OAAiB,uBAAyB,GAC1C,OAAiB,SAA+B,IAAA,GAChD,OAAiB,2BAA6C,CAAC,EAC/D,OAAiB,QAAU,GAC3B,OAAiB,gBAAkB,GAEnC,OAAiB,iBAAgC,IAAI,IAMrD,WAAW,OAAO,EAAgB,CAE9B,EAAa,QAAU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,EAAe,SAAW,EAAI,SAAW,EAAe,KAAK,IAAI,GAAG,EAE1G,IAAI,EAAQ,IAAI,IAChB,GAAI,CACA,EAAQ,EAAW,CACf,GAAG,KAAK,2BACR,KAAM,EACN,WAAY,CAChB,CAAC,CACL,MAAQ,CAAC,CACT,EAAa,iBAAmB,EAChC,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAW,EAAG,EAAY,IAAI,EAAK,CAAK,EAClF,EAAa,oBAAoB,EAAY,KAAK,YAAY,EAC1D,EAAa,iBAAiB,KAAK,mBAAmB,CAC9D,CAEA,OAAO,CACX,CAOA,OAAO,MAAa,CAChB,KAAU,MACd,CAKA,OAAO,EAAsC,CACzC,OAAO,EAAa,gBAAgB,CAAG,EAAE,KAC7C,CACJ"}
@@ -0,0 +1,2 @@
1
+ const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("../Error.cjs"),n=require("./EnvapterBase.cjs");let r=require("node:fs");r=e.__toESM(r,1);let i=require("node:process");i=e.__toESM(i,1);let a=function(e){return e[e.Development=0]=`Development`,e[e.Staging=1]=`Staging`,e[e.Production=2]=`Production`,e}({});var o=class e extends n.EnvapterBase{static _environment;static _environmentExplicitlySet=!1;static _profiles;static determineEnvironment(e){let t=e??this.getRawValue(`ENVIRONMENT`,this.getRawValue(`ENV`,this.getRawValue(`NODE_ENV`,`development`)));typeof t==`string`?this._environment=t.toLowerCase()===`production`?2:+(t===`staging`):this._environment=t,e!==void 0&&(this._environmentExplicitlySet=!0)}static getRawValue(e,t){return this.config.get(e)||t}static get environment(){return this._environment===void 0&&this.determineEnvironment(),this._environment}static set environment(e){this.determineEnvironment(e)}get environment(){return e.environment}set environment(t){e.determineEnvironment(t)}static get isProduction(){return this.environment===2}get isProduction(){return e.environment===2}static get isStaging(){return this.environment===1}get isStaging(){return e.environment===1}static get isDevelopment(){return this.environment===0}get isDevelopment(){return e.environment===0}static refreshCache(){this._environmentExplicitlySet||(this._environment=void 0),super.refreshCache()}static configureProfiles(e){this._profiles=e,this.refreshCache()}static resetProfiles(){this._profiles=void 0,this._envPaths=[`.env`],this._envPathsExplicitlySet=!1,this._environmentExplicitlySet=!1,this._environment=void 0,this.refreshCache()}static getCascadeEnvironment(){if(this._environment!==void 0)return this._environment;let e=(i.default.env.ENVIRONMENT??i.default.env.ENV??i.default.env.NODE_ENV??`development`).toLowerCase();return e===`production`?2:+(e===`staging`)}static buildCascadePaths(e){let t=a[e].toLowerCase();return[`.env.${t}.local`,`.env.${t}`,`.env.local`,`.env`].map(e=>this.resolveAgainstBase(e)).filter(e=>r.default.existsSync(e))}static normalizeProfilePaths(e){return e?Array.isArray(e.paths)?e.paths:[e.paths]:[]}static resolveEffectivePaths(){if(this._envPathsExplicitlySet)return this._envPaths.map(e=>this.resolveAgainstBase(e));let e=this.getCascadeEnvironment(),n=this._profiles?.[e],i=this.normalizeProfilePaths(n);if(i.length>0){let e=i.filter(e=>!r.default.existsSync(this.resolveAgainstBase(e)));if(e.length>0)throw new t.EnvaptError(303,`Environment file not found at path: ${e.join(`, `)}`)}let a=this._profiles?.useDefaults===!1?[]:this.buildCascadePaths(e);return[...i.map(e=>this.resolveAgainstBase(e)),...a]}};exports.Environment=a,exports.EnvironmentMethods=o;
2
+ //# sourceMappingURL=EnvironmentMethods.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvironmentMethods.cjs","names":["EnvapterBase","process","fs","EnvaptError"],"sources":["../../src/core/EnvironmentMethods.ts"],"sourcesContent":["import fs from 'node:fs';\nimport process from 'node:process';\n\nimport { EnvaptError, EnvaptErrorCodes } from '../Error';\nimport { EnvapterBase } from './EnvapterBase';\n\nimport type { EnvProfile, ProfilesConfig } from '../types';\n\n/**\n * Environment types supported by Envapter\n * @public\n */\nexport enum Environment {\n Development,\n Staging,\n Production\n}\n\n/**\n * Mixin for environment detection and checking methods\n * @internal\n */\nexport class EnvironmentMethods extends EnvapterBase {\n protected static _environment: Environment | undefined;\n protected static _environmentExplicitlySet = false;\n protected static _profiles: ProfilesConfig | undefined;\n\n protected static determineEnvironment(env?: string | Environment): void {\n const environment =\n env ??\n this.getRawValue('ENVIRONMENT', this.getRawValue('ENV', this.getRawValue('NODE_ENV', 'development')));\n\n if (typeof environment === 'string') {\n this._environment =\n environment.toLowerCase() === 'production'\n ? Environment.Production\n : environment === 'staging'\n ? Environment.Staging\n : Environment.Development;\n } else {\n this._environment = environment;\n }\n if (env !== undefined) this._environmentExplicitlySet = true;\n }\n\n private static getRawValue(key: string, fallback: string): string {\n return (this.config.get(key) as string) || fallback;\n }\n\n /**\n * Get the current application environment\n */\n static get environment(): Environment {\n if (this._environment === undefined) {\n this.determineEnvironment();\n }\n return this._environment as Environment;\n }\n\n /**\n * Set the application environment. Accepts either Environment enum or string value.\n */\n static set environment(env: string | Environment) {\n this.determineEnvironment(env);\n }\n\n /**\n * @see {@link EnvironmentMethods.environment}\n */\n get environment(): Environment {\n return EnvironmentMethods.environment;\n }\n\n /**\n * @see {@link EnvironmentMethods.environment}\n */\n set environment(env: string | Environment) {\n EnvironmentMethods.determineEnvironment(env);\n }\n\n /**\n * Check if the current environment is production\n */\n static get isProduction(): boolean {\n return this.environment === Environment.Production;\n }\n\n /**\n * @see {@link EnvironmentMethods.isProduction}\n */\n get isProduction(): boolean {\n return EnvironmentMethods.environment === Environment.Production;\n }\n\n /**\n * Check if the current environment is staging\n */\n static get isStaging(): boolean {\n return this.environment === Environment.Staging;\n }\n\n /**\n * @see {@link EnvironmentMethods.isStaging}\n */\n get isStaging(): boolean {\n return EnvironmentMethods.environment === Environment.Staging;\n }\n\n /**\n * Check if the current environment is development\n */\n static get isDevelopment(): boolean {\n return this.environment === Environment.Development;\n }\n\n /**\n * @see {@link EnvironmentMethods.isDevelopment}\n */\n get isDevelopment(): boolean {\n return EnvironmentMethods.environment === Environment.Development;\n }\n\n protected static override refreshCache(): void {\n // If the env was inferred (not user-set), reset it so re-hydration re-determines\n // from current state. If the user explicitly set Envapter.environment = X, preserve\n // that value through the refresh. The immediate re-hydration inside super.refreshCache()\n // will use it for cascade selection.\n if (!this._environmentExplicitlySet) this._environment = undefined;\n super.refreshCache();\n }\n\n /**\n * Configure per-environment `.env` path overrides on top of the dotenv-flow auto-cascade.\n *\n * When set, each `Environment` key's `paths` are loaded at higher precedence than the\n * cascade for that environment. Unspecified environments still use the cascade as-is.\n * Set `useDefaults: false` to disable the cascade entirely (load only the configured paths).\n *\n * Setting an explicit `Envapter.envPaths` value at any point overrides this configuration.\n *\n * @example\n * ```ts\n * Envapter.configureProfiles({\n * [Environment.Staging]: { paths: 'config/staging.env' },\n * [Environment.Production]: { paths: ['config/prod.env', 'secrets/prod.env'] }\n * });\n * ```\n */\n static configureProfiles(config: ProfilesConfig): void {\n this._profiles = config;\n this.refreshCache();\n }\n\n /**\n * Reset all path-resolution configuration to defaults: clears any prior\n * {@link configureProfiles} call AND any explicit `Envapter.envPaths` assignment.\n * Returns the resolver to the pure dotenv-flow cascade.\n */\n static resetProfiles(): void {\n this._profiles = undefined;\n this._envPaths = ['.env'];\n this._envPathsExplicitlySet = false;\n // Also clear the explicit-env flag so the next refresh re-determines env from\n // process.env / loaded files. resetProfiles is a \"back to defaults\" call.\n // Any user-set environment is wiped along with paths and profiles.\n this._environmentExplicitlySet = false;\n this._environment = undefined;\n this.refreshCache();\n }\n\n /**\n * Determine the current environment for cascade-file selection by reading `process.env`\n * directly. Bypassing `this.config` to avoid a circular dependency (cascade selection\n * happens before `.env` files are loaded). The post-load `Envapter.environment` value\n * may differ if a loaded `.env` file declares its own `ENVIRONMENT`/`ENV`/`NODE_ENV`.\n * @internal\n */\n protected static getCascadeEnvironment(): Environment {\n if (this._environment !== undefined) return this._environment;\n\n const raw = process.env.ENVIRONMENT ?? process.env.ENV ?? process.env.NODE_ENV ?? 'development';\n const lower = raw.toLowerCase();\n if (lower === 'production') return Environment.Production;\n if (lower === 'staging') return Environment.Staging;\n return Environment.Development;\n }\n\n /**\n * Build the dotenv-flow cascade for a given environment, in dotenv first-wins precedence\n * order (highest precedence first). Missing files are silently filtered.\n *\n * Precedence is **most-specific-wins** (matches Vite / Astro / Vocs):\n * `.env.${env}.local` \\> `.env.${env}` \\> `.env.local` \\> `.env`\n *\n * This differs from dotenv-flow / Next.js convention which puts `.env.local` above\n * `.env.${env}`. We chose the most-specific-wins order so committed env-specific files\n * (`.env.production`) are authoritative for that environment regardless of whether a\n * stray `.env.local` is present.\n * @internal\n */\n protected static buildCascadePaths(env: Environment): string[] {\n const envName = Environment[env].toLowerCase();\n return [`.env.${envName}.local`, `.env.${envName}`, '.env.local', '.env']\n .map((name) => this.resolveAgainstBase(name))\n .filter((p) => fs.existsSync(p));\n }\n\n private static normalizeProfilePaths(profile: EnvProfile | undefined): string[] {\n if (!profile) return [];\n return Array.isArray(profile.paths) ? profile.paths : [profile.paths];\n }\n\n /**\n * Override the base implementation to layer the dotenv-flow cascade + any\n * {@link configureProfiles} overrides on top of `_envPaths` when the user has NOT\n * explicitly set `envPaths`.\n *\n * Precedence (passed to dotenv with first-wins semantics):\n * 1. profile-configured paths for the current env (if any)\n * 2. `.env.${env}.local`\n * 3. `.env.${env}`\n * 4. `.env.local`\n * 5. `.env`\n *\n * If `useDefaults: false` is set on the profiles config, only (1) is loaded — no cascade.\n * If `envPaths` was explicitly set, only `envPaths` is loaded (everything else ignored).\n * @internal\n */\n protected static override resolveEffectivePaths(): string[] {\n if (this._envPathsExplicitlySet) return this._envPaths.map((p) => this.resolveAgainstBase(p));\n\n const env = this.getCascadeEnvironment();\n const profileEntry = this._profiles?.[env];\n const profilePaths = this.normalizeProfilePaths(profileEntry);\n\n // Validate that explicitly configured profile paths exist for the active env.\n if (profilePaths.length > 0) {\n const missing = profilePaths.filter((p) => !fs.existsSync(this.resolveAgainstBase(p)));\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.EnvFilesNotFound,\n `Environment file not found at path: ${missing.join(', ')}`\n );\n }\n }\n\n const cascade = this._profiles?.useDefaults === false ? [] : this.buildCascadePaths(env);\n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EAAQ,OAAS,EACjB,MAAM,IAAIC,EAAAA,YAAAA,IAEN,uCAAuC,EAAQ,KAAK,IAAI,GAC5D,CAER,CAEA,IAAM,EAAU,KAAK,WAAW,cAAgB,GAAQ,CAAC,EAAI,KAAK,kBAAkB,CAAG,EACvF,MAAO,CAAC,GAAG,EAAa,IAAK,GAAM,KAAK,mBAAmB,CAAC,CAAC,EAAG,GAAG,CAAO,CAC9E,CACJ"}
@@ -0,0 +1,132 @@
1
+ import { EnvapterBase } from "./EnvapterBase.cjs";
2
+ import { ProfilesConfig } from "../types/Options.cjs";
3
+
4
+ //#region src/core/EnvironmentMethods.d.ts
5
+ /**
6
+ * Environment types supported by Envapter
7
+ * @public
8
+ */
9
+ declare enum Environment {
10
+ Development = 0,
11
+ Staging = 1,
12
+ Production = 2
13
+ }
14
+ /**
15
+ * Mixin for environment detection and checking methods
16
+ * @internal
17
+ */
18
+ declare class EnvironmentMethods extends EnvapterBase {
19
+ protected static _environment: Environment | undefined;
20
+ protected static _environmentExplicitlySet: boolean;
21
+ protected static _profiles: ProfilesConfig | undefined;
22
+ protected static determineEnvironment(env?: string | Environment): void;
23
+ private static getRawValue;
24
+ /**
25
+ * Get the current application environment
26
+ */
27
+ static get environment(): Environment;
28
+ /**
29
+ * Set the application environment. Accepts either Environment enum or string value.
30
+ */
31
+ static set environment(env: string | Environment);
32
+ /**
33
+ * @see {@link EnvironmentMethods.environment}
34
+ */
35
+ get environment(): Environment;
36
+ /**
37
+ * @see {@link EnvironmentMethods.environment}
38
+ */
39
+ set environment(env: string | Environment);
40
+ /**
41
+ * Check if the current environment is production
42
+ */
43
+ static get isProduction(): boolean;
44
+ /**
45
+ * @see {@link EnvironmentMethods.isProduction}
46
+ */
47
+ get isProduction(): boolean;
48
+ /**
49
+ * Check if the current environment is staging
50
+ */
51
+ static get isStaging(): boolean;
52
+ /**
53
+ * @see {@link EnvironmentMethods.isStaging}
54
+ */
55
+ get isStaging(): boolean;
56
+ /**
57
+ * Check if the current environment is development
58
+ */
59
+ static get isDevelopment(): boolean;
60
+ /**
61
+ * @see {@link EnvironmentMethods.isDevelopment}
62
+ */
63
+ get isDevelopment(): boolean;
64
+ protected static refreshCache(): void;
65
+ /**
66
+ * Configure per-environment `.env` path overrides on top of the dotenv-flow auto-cascade.
67
+ *
68
+ * When set, each `Environment` key's `paths` are loaded at higher precedence than the
69
+ * cascade for that environment. Unspecified environments still use the cascade as-is.
70
+ * Set `useDefaults: false` to disable the cascade entirely (load only the configured paths).
71
+ *
72
+ * Setting an explicit `Envapter.envPaths` value at any point overrides this configuration.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * Envapter.configureProfiles({
77
+ * [Environment.Staging]: { paths: 'config/staging.env' },
78
+ * [Environment.Production]: { paths: ['config/prod.env', 'secrets/prod.env'] }
79
+ * });
80
+ * ```
81
+ */
82
+ static configureProfiles(config: ProfilesConfig): void;
83
+ /**
84
+ * Reset all path-resolution configuration to defaults: clears any prior
85
+ * {@link configureProfiles} call AND any explicit `Envapter.envPaths` assignment.
86
+ * Returns the resolver to the pure dotenv-flow cascade.
87
+ */
88
+ static resetProfiles(): void;
89
+ /**
90
+ * Determine the current environment for cascade-file selection by reading `process.env`
91
+ * directly. Bypassing `this.config` to avoid a circular dependency (cascade selection
92
+ * happens before `.env` files are loaded). The post-load `Envapter.environment` value
93
+ * may differ if a loaded `.env` file declares its own `ENVIRONMENT`/`ENV`/`NODE_ENV`.
94
+ * @internal
95
+ */
96
+ protected static getCascadeEnvironment(): Environment;
97
+ /**
98
+ * Build the dotenv-flow cascade for a given environment, in dotenv first-wins precedence
99
+ * order (highest precedence first). Missing files are silently filtered.
100
+ *
101
+ * Precedence is **most-specific-wins** (matches Vite / Astro / Vocs):
102
+ * `.env.${env}.local` \> `.env.${env}` \> `.env.local` \> `.env`
103
+ *
104
+ * This differs from dotenv-flow / Next.js convention which puts `.env.local` above
105
+ * `.env.${env}`. We chose the most-specific-wins order so committed env-specific files
106
+ * (`.env.production`) are authoritative for that environment regardless of whether a
107
+ * stray `.env.local` is present.
108
+ * @internal
109
+ */
110
+ protected static buildCascadePaths(env: Environment): string[];
111
+ private static normalizeProfilePaths;
112
+ /**
113
+ * Override the base implementation to layer the dotenv-flow cascade + any
114
+ * {@link configureProfiles} overrides on top of `_envPaths` when the user has NOT
115
+ * explicitly set `envPaths`.
116
+ *
117
+ * Precedence (passed to dotenv with first-wins semantics):
118
+ * 1. profile-configured paths for the current env (if any)
119
+ * 2. `.env.${env}.local`
120
+ * 3. `.env.${env}`
121
+ * 4. `.env.local`
122
+ * 5. `.env`
123
+ *
124
+ * If `useDefaults: false` is set on the profiles config, only (1) is loaded — no cascade.
125
+ * If `envPaths` was explicitly set, only `envPaths` is loaded (everything else ignored).
126
+ * @internal
127
+ */
128
+ protected static resolveEffectivePaths(): string[];
129
+ }
130
+ //#endregion
131
+ export { Environment, EnvironmentMethods };
132
+ //# sourceMappingURL=EnvironmentMethods.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvironmentMethods.d.cts","names":[],"sources":["../../src/core/EnvironmentMethods.ts"],"mappings":";;;;;;AAYA;;aAAY,WAAA;EACR,WAAA;EACA,OAAA;EACA,UAAA;AAAA;;AAAU;AAOd;;cAAa,kBAAA,SAA2B,YAAA;EAAA,iBACnB,YAAA,EAAc,WAAA;EAAA,iBACd,yBAAA;EAAA,iBACA,SAAA,EAAW,cAAA;EAAA,iBAEX,oBAAA,CAAqB,GAAA,YAAe,WAAA;EAAA,eAkBtC,WAAA;EAwBI;;;EAAA,WAjBR,WAAA,CAAA,GAAe,WAAA;EAoJc;;;EAAA,WA1I7B,WAAA,CAAY,GAAA,WAAc,WAAA;EAxCD;;;EAAA,IA+ChC,WAAA,CAAA,GAAe,WAAA;EA5CF;;;EAAA,IAmDb,WAAA,CAAY,GAAA,WAAc,WAAA;EAjDQ;;;EAAA,WAwD3B,YAAA,CAAA;EArBA;;;EAAA,IA4BP,YAAA,CAAA;EArBe;;;EAAA,WA4BR,SAAA,CAAA;EAdA;;;EAAA,IAqBP,SAAA,CAAA;EAOO;;;EAAA,WAAA,aAAA,CAAA;EAqCsB;;;EAAA,IA9B7B,aAAA,CAAA;EAAA,iBAIsB,YAAA,CAAA;EA8ET;;;;;;AA4B8B;;;;;;;;;;;EA5B9B,OApDV,iBAAA,CAAkB,MAAA,EAAQ,cAAA;;;;;;SAU1B,aAAA,CAAA;;;;;;;;mBAmBU,qBAAA,CAAA,GAAyB,WAAA;;;;;;;;;;;;;;mBAuBzB,iBAAA,CAAkB,GAAA,EAAK,WAAA;EAAA,eAOzB,qBAAA;;;;;;;;;;;;;;;;;mBAqBW,qBAAA,CAAA;AAAA"}
@@ -0,0 +1,132 @@
1
+ import { EnvapterBase } from "./EnvapterBase.mjs";
2
+ import { ProfilesConfig } from "../types/Options.mjs";
3
+
4
+ //#region src/core/EnvironmentMethods.d.ts
5
+ /**
6
+ * Environment types supported by Envapter
7
+ * @public
8
+ */
9
+ declare enum Environment {
10
+ Development = 0,
11
+ Staging = 1,
12
+ Production = 2
13
+ }
14
+ /**
15
+ * Mixin for environment detection and checking methods
16
+ * @internal
17
+ */
18
+ declare class EnvironmentMethods extends EnvapterBase {
19
+ protected static _environment: Environment | undefined;
20
+ protected static _environmentExplicitlySet: boolean;
21
+ protected static _profiles: ProfilesConfig | undefined;
22
+ protected static determineEnvironment(env?: string | Environment): void;
23
+ private static getRawValue;
24
+ /**
25
+ * Get the current application environment
26
+ */
27
+ static get environment(): Environment;
28
+ /**
29
+ * Set the application environment. Accepts either Environment enum or string value.
30
+ */
31
+ static set environment(env: string | Environment);
32
+ /**
33
+ * @see {@link EnvironmentMethods.environment}
34
+ */
35
+ get environment(): Environment;
36
+ /**
37
+ * @see {@link EnvironmentMethods.environment}
38
+ */
39
+ set environment(env: string | Environment);
40
+ /**
41
+ * Check if the current environment is production
42
+ */
43
+ static get isProduction(): boolean;
44
+ /**
45
+ * @see {@link EnvironmentMethods.isProduction}
46
+ */
47
+ get isProduction(): boolean;
48
+ /**
49
+ * Check if the current environment is staging
50
+ */
51
+ static get isStaging(): boolean;
52
+ /**
53
+ * @see {@link EnvironmentMethods.isStaging}
54
+ */
55
+ get isStaging(): boolean;
56
+ /**
57
+ * Check if the current environment is development
58
+ */
59
+ static get isDevelopment(): boolean;
60
+ /**
61
+ * @see {@link EnvironmentMethods.isDevelopment}
62
+ */
63
+ get isDevelopment(): boolean;
64
+ protected static refreshCache(): void;
65
+ /**
66
+ * Configure per-environment `.env` path overrides on top of the dotenv-flow auto-cascade.
67
+ *
68
+ * When set, each `Environment` key's `paths` are loaded at higher precedence than the
69
+ * cascade for that environment. Unspecified environments still use the cascade as-is.
70
+ * Set `useDefaults: false` to disable the cascade entirely (load only the configured paths).
71
+ *
72
+ * Setting an explicit `Envapter.envPaths` value at any point overrides this configuration.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * Envapter.configureProfiles({
77
+ * [Environment.Staging]: { paths: 'config/staging.env' },
78
+ * [Environment.Production]: { paths: ['config/prod.env', 'secrets/prod.env'] }
79
+ * });
80
+ * ```
81
+ */
82
+ static configureProfiles(config: ProfilesConfig): void;
83
+ /**
84
+ * Reset all path-resolution configuration to defaults: clears any prior
85
+ * {@link configureProfiles} call AND any explicit `Envapter.envPaths` assignment.
86
+ * Returns the resolver to the pure dotenv-flow cascade.
87
+ */
88
+ static resetProfiles(): void;
89
+ /**
90
+ * Determine the current environment for cascade-file selection by reading `process.env`
91
+ * directly. Bypassing `this.config` to avoid a circular dependency (cascade selection
92
+ * happens before `.env` files are loaded). The post-load `Envapter.environment` value
93
+ * may differ if a loaded `.env` file declares its own `ENVIRONMENT`/`ENV`/`NODE_ENV`.
94
+ * @internal
95
+ */
96
+ protected static getCascadeEnvironment(): Environment;
97
+ /**
98
+ * Build the dotenv-flow cascade for a given environment, in dotenv first-wins precedence
99
+ * order (highest precedence first). Missing files are silently filtered.
100
+ *
101
+ * Precedence is **most-specific-wins** (matches Vite / Astro / Vocs):
102
+ * `.env.${env}.local` \> `.env.${env}` \> `.env.local` \> `.env`
103
+ *
104
+ * This differs from dotenv-flow / Next.js convention which puts `.env.local` above
105
+ * `.env.${env}`. We chose the most-specific-wins order so committed env-specific files
106
+ * (`.env.production`) are authoritative for that environment regardless of whether a
107
+ * stray `.env.local` is present.
108
+ * @internal
109
+ */
110
+ protected static buildCascadePaths(env: Environment): string[];
111
+ private static normalizeProfilePaths;
112
+ /**
113
+ * Override the base implementation to layer the dotenv-flow cascade + any
114
+ * {@link configureProfiles} overrides on top of `_envPaths` when the user has NOT
115
+ * explicitly set `envPaths`.
116
+ *
117
+ * Precedence (passed to dotenv with first-wins semantics):
118
+ * 1. profile-configured paths for the current env (if any)
119
+ * 2. `.env.${env}.local`
120
+ * 3. `.env.${env}`
121
+ * 4. `.env.local`
122
+ * 5. `.env`
123
+ *
124
+ * If `useDefaults: false` is set on the profiles config, only (1) is loaded — no cascade.
125
+ * If `envPaths` was explicitly set, only `envPaths` is loaded (everything else ignored).
126
+ * @internal
127
+ */
128
+ protected static resolveEffectivePaths(): string[];
129
+ }
130
+ //#endregion
131
+ export { Environment, EnvironmentMethods };
132
+ //# sourceMappingURL=EnvironmentMethods.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvironmentMethods.d.mts","names":[],"sources":["../../src/core/EnvironmentMethods.ts"],"mappings":";;;;;;AAYA;;aAAY,WAAA;EACR,WAAA;EACA,OAAA;EACA,UAAA;AAAA;;AAAU;AAOd;;cAAa,kBAAA,SAA2B,YAAA;EAAA,iBACnB,YAAA,EAAc,WAAA;EAAA,iBACd,yBAAA;EAAA,iBACA,SAAA,EAAW,cAAA;EAAA,iBAEX,oBAAA,CAAqB,GAAA,YAAe,WAAA;EAAA,eAkBtC,WAAA;EAwBI;;;EAAA,WAjBR,WAAA,CAAA,GAAe,WAAA;EAoJc;;;EAAA,WA1I7B,WAAA,CAAY,GAAA,WAAc,WAAA;EAxCD;;;EAAA,IA+ChC,WAAA,CAAA,GAAe,WAAA;EA5CF;;;EAAA,IAmDb,WAAA,CAAY,GAAA,WAAc,WAAA;EAjDQ;;;EAAA,WAwD3B,YAAA,CAAA;EArBA;;;EAAA,IA4BP,YAAA,CAAA;EArBe;;;EAAA,WA4BR,SAAA,CAAA;EAdA;;;EAAA,IAqBP,SAAA,CAAA;EAOO;;;EAAA,WAAA,aAAA,CAAA;EAqCsB;;;EAAA,IA9B7B,aAAA,CAAA;EAAA,iBAIsB,YAAA,CAAA;EA8ET;;;;;;AA4B8B;;;;;;;;;;;EA5B9B,OApDV,iBAAA,CAAkB,MAAA,EAAQ,cAAA;;;;;;SAU1B,aAAA,CAAA;;;;;;;;mBAmBU,qBAAA,CAAA,GAAyB,WAAA;;;;;;;;;;;;;;mBAuBzB,iBAAA,CAAkB,GAAA,EAAK,WAAA;EAAA,eAOzB,qBAAA;;;;;;;;;;;;;;;;;mBAqBW,qBAAA,CAAA;AAAA"}
@@ -0,0 +1,2 @@
1
+ import{EnvaptError as e}from"../Error.mjs";import{EnvapterBase as t}from"./EnvapterBase.mjs";import n from"node:fs";import r from"node:process";let i=function(e){return e[e.Development=0]=`Development`,e[e.Staging=1]=`Staging`,e[e.Production=2]=`Production`,e}({});var a=class a extends t{static _environment;static _environmentExplicitlySet=!1;static _profiles;static determineEnvironment(e){let t=e??this.getRawValue(`ENVIRONMENT`,this.getRawValue(`ENV`,this.getRawValue(`NODE_ENV`,`development`)));typeof t==`string`?this._environment=t.toLowerCase()===`production`?2:+(t===`staging`):this._environment=t,e!==void 0&&(this._environmentExplicitlySet=!0)}static getRawValue(e,t){return this.config.get(e)||t}static get environment(){return this._environment===void 0&&this.determineEnvironment(),this._environment}static set environment(e){this.determineEnvironment(e)}get environment(){return a.environment}set environment(e){a.determineEnvironment(e)}static get isProduction(){return this.environment===2}get isProduction(){return a.environment===2}static get isStaging(){return this.environment===1}get isStaging(){return a.environment===1}static get isDevelopment(){return this.environment===0}get isDevelopment(){return a.environment===0}static refreshCache(){this._environmentExplicitlySet||(this._environment=void 0),super.refreshCache()}static configureProfiles(e){this._profiles=e,this.refreshCache()}static resetProfiles(){this._profiles=void 0,this._envPaths=[`.env`],this._envPathsExplicitlySet=!1,this._environmentExplicitlySet=!1,this._environment=void 0,this.refreshCache()}static getCascadeEnvironment(){if(this._environment!==void 0)return this._environment;let e=(r.env.ENVIRONMENT??r.env.ENV??r.env.NODE_ENV??`development`).toLowerCase();return e===`production`?2:+(e===`staging`)}static buildCascadePaths(e){let t=i[e].toLowerCase();return[`.env.${t}.local`,`.env.${t}`,`.env.local`,`.env`].map(e=>this.resolveAgainstBase(e)).filter(e=>n.existsSync(e))}static normalizeProfilePaths(e){return e?Array.isArray(e.paths)?e.paths:[e.paths]:[]}static resolveEffectivePaths(){if(this._envPathsExplicitlySet)return this._envPaths.map(e=>this.resolveAgainstBase(e));let t=this.getCascadeEnvironment(),r=this._profiles?.[t],i=this.normalizeProfilePaths(r);if(i.length>0){let t=i.filter(e=>!n.existsSync(this.resolveAgainstBase(e)));if(t.length>0)throw new e(303,`Environment file not found at path: ${t.join(`, `)}`)}let a=this._profiles?.useDefaults===!1?[]:this.buildCascadePaths(t);return[...i.map(e=>this.resolveAgainstBase(e)),...a]}};export{i as Environment,a as EnvironmentMethods};
2
+ //# sourceMappingURL=EnvironmentMethods.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvironmentMethods.mjs","names":[],"sources":["../../src/core/EnvironmentMethods.ts"],"sourcesContent":["import fs from 'node:fs';\nimport process from 'node:process';\n\nimport { EnvaptError, EnvaptErrorCodes } from '../Error';\nimport { EnvapterBase } from './EnvapterBase';\n\nimport type { EnvProfile, ProfilesConfig } from '../types';\n\n/**\n * Environment types supported by Envapter\n * @public\n */\nexport enum Environment {\n Development,\n Staging,\n Production\n}\n\n/**\n * Mixin for environment detection and checking methods\n * @internal\n */\nexport class EnvironmentMethods extends EnvapterBase {\n protected static _environment: Environment | undefined;\n protected static _environmentExplicitlySet = false;\n protected static _profiles: ProfilesConfig | undefined;\n\n protected static determineEnvironment(env?: string | Environment): void {\n const environment =\n env ??\n this.getRawValue('ENVIRONMENT', this.getRawValue('ENV', this.getRawValue('NODE_ENV', 'development')));\n\n if (typeof environment === 'string') {\n this._environment =\n environment.toLowerCase() === 'production'\n ? Environment.Production\n : environment === 'staging'\n ? Environment.Staging\n : Environment.Development;\n } else {\n this._environment = environment;\n }\n if (env !== undefined) this._environmentExplicitlySet = true;\n }\n\n private static getRawValue(key: string, fallback: string): string {\n return (this.config.get(key) as string) || fallback;\n }\n\n /**\n * Get the current application environment\n */\n static get environment(): Environment {\n if (this._environment === undefined) {\n this.determineEnvironment();\n }\n return this._environment as Environment;\n }\n\n /**\n * Set the application environment. Accepts either Environment enum or string value.\n */\n static set environment(env: string | Environment) {\n this.determineEnvironment(env);\n }\n\n /**\n * @see {@link EnvironmentMethods.environment}\n */\n get environment(): Environment {\n return EnvironmentMethods.environment;\n }\n\n /**\n * @see {@link EnvironmentMethods.environment}\n */\n set environment(env: string | Environment) {\n EnvironmentMethods.determineEnvironment(env);\n }\n\n /**\n * Check if the current environment is production\n */\n static get isProduction(): boolean {\n return this.environment === Environment.Production;\n }\n\n /**\n * @see {@link EnvironmentMethods.isProduction}\n */\n get isProduction(): boolean {\n return EnvironmentMethods.environment === Environment.Production;\n }\n\n /**\n * Check if the current environment is staging\n */\n static get isStaging(): boolean {\n return this.environment === Environment.Staging;\n }\n\n /**\n * @see {@link EnvironmentMethods.isStaging}\n */\n get isStaging(): boolean {\n return EnvironmentMethods.environment === Environment.Staging;\n }\n\n /**\n * Check if the current environment is development\n */\n static get isDevelopment(): boolean {\n return this.environment === Environment.Development;\n }\n\n /**\n * @see {@link EnvironmentMethods.isDevelopment}\n */\n get isDevelopment(): boolean {\n return EnvironmentMethods.environment === Environment.Development;\n }\n\n protected static override refreshCache(): void {\n // If the env was inferred (not user-set), reset it so re-hydration re-determines\n // from current state. If the user explicitly set Envapter.environment = X, preserve\n // that value through the refresh. The immediate re-hydration inside super.refreshCache()\n // will use it for cascade selection.\n if (!this._environmentExplicitlySet) this._environment = undefined;\n super.refreshCache();\n }\n\n /**\n * Configure per-environment `.env` path overrides on top of the dotenv-flow auto-cascade.\n *\n * When set, each `Environment` key's `paths` are loaded at higher precedence than the\n * cascade for that environment. Unspecified environments still use the cascade as-is.\n * Set `useDefaults: false` to disable the cascade entirely (load only the configured paths).\n *\n * Setting an explicit `Envapter.envPaths` value at any point overrides this configuration.\n *\n * @example\n * ```ts\n * Envapter.configureProfiles({\n * [Environment.Staging]: { paths: 'config/staging.env' },\n * [Environment.Production]: { paths: ['config/prod.env', 'secrets/prod.env'] }\n * });\n * ```\n */\n static configureProfiles(config: ProfilesConfig): void {\n this._profiles = config;\n this.refreshCache();\n }\n\n /**\n * Reset all path-resolution configuration to defaults: clears any prior\n * {@link configureProfiles} call AND any explicit `Envapter.envPaths` assignment.\n * Returns the resolver to the pure dotenv-flow cascade.\n */\n static resetProfiles(): void {\n this._profiles = undefined;\n this._envPaths = ['.env'];\n this._envPathsExplicitlySet = false;\n // Also clear the explicit-env flag so the next refresh re-determines env from\n // process.env / loaded files. resetProfiles is a \"back to defaults\" call.\n // Any user-set environment is wiped along with paths and profiles.\n this._environmentExplicitlySet = false;\n this._environment = undefined;\n this.refreshCache();\n }\n\n /**\n * Determine the current environment for cascade-file selection by reading `process.env`\n * directly. Bypassing `this.config` to avoid a circular dependency (cascade selection\n * happens before `.env` files are loaded). The post-load `Envapter.environment` value\n * may differ if a loaded `.env` file declares its own `ENVIRONMENT`/`ENV`/`NODE_ENV`.\n * @internal\n */\n protected static getCascadeEnvironment(): Environment {\n if (this._environment !== undefined) return this._environment;\n\n const raw = process.env.ENVIRONMENT ?? process.env.ENV ?? process.env.NODE_ENV ?? 'development';\n const lower = raw.toLowerCase();\n if (lower === 'production') return Environment.Production;\n if (lower === 'staging') return Environment.Staging;\n return Environment.Development;\n }\n\n /**\n * Build the dotenv-flow cascade for a given environment, in dotenv first-wins precedence\n * order (highest precedence first). Missing files are silently filtered.\n *\n * Precedence is **most-specific-wins** (matches Vite / Astro / Vocs):\n * `.env.${env}.local` \\> `.env.${env}` \\> `.env.local` \\> `.env`\n *\n * This differs from dotenv-flow / Next.js convention which puts `.env.local` above\n * `.env.${env}`. We chose the most-specific-wins order so committed env-specific files\n * (`.env.production`) are authoritative for that environment regardless of whether a\n * stray `.env.local` is present.\n * @internal\n */\n protected static buildCascadePaths(env: Environment): string[] {\n const envName = Environment[env].toLowerCase();\n return [`.env.${envName}.local`, `.env.${envName}`, '.env.local', '.env']\n .map((name) => this.resolveAgainstBase(name))\n .filter((p) => fs.existsSync(p));\n }\n\n private static normalizeProfilePaths(profile: EnvProfile | undefined): string[] {\n if (!profile) return [];\n return Array.isArray(profile.paths) ? profile.paths : [profile.paths];\n }\n\n /**\n * Override the base implementation to layer the dotenv-flow cascade + any\n * {@link configureProfiles} overrides on top of `_envPaths` when the user has NOT\n * explicitly set `envPaths`.\n *\n * Precedence (passed to dotenv with first-wins semantics):\n * 1. profile-configured paths for the current env (if any)\n * 2. `.env.${env}.local`\n * 3. `.env.${env}`\n * 4. `.env.local`\n * 5. `.env`\n *\n * If `useDefaults: false` is set on the profiles config, only (1) is loaded — no cascade.\n * If `envPaths` was explicitly set, only `envPaths` is loaded (everything else ignored).\n * @internal\n */\n protected static override resolveEffectivePaths(): string[] {\n if (this._envPathsExplicitlySet) return this._envPaths.map((p) => this.resolveAgainstBase(p));\n\n const env = this.getCascadeEnvironment();\n const profileEntry = this._profiles?.[env];\n const profilePaths = this.normalizeProfilePaths(profileEntry);\n\n // Validate that explicitly configured profile paths exist for the active env.\n if (profilePaths.length > 0) {\n const missing = profilePaths.filter((p) => !fs.existsSync(this.resolveAgainstBase(p)));\n if (missing.length > 0) {\n throw new EnvaptError(\n EnvaptErrorCodes.EnvFilesNotFound,\n `Environment file not found at path: ${missing.join(', ')}`\n );\n }\n }\n\n const cascade = this._profiles?.useDefaults === false ? [] : this.buildCascadePaths(env);\n return [...profilePaths.map((p) => this.resolveAgainstBase(p)), ...c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,IAAM,EAAU,KAAK,WAAW,cAAgB,GAAQ,CAAC,EAAI,KAAK,kBAAkB,CAAG,EACvF,MAAO,CAAC,GAAG,EAAa,IAAK,GAAM,KAAK,mBAAmB,CAAC,CAAC,EAAG,GAAG,CAAO,CAC9E,CACJ"}
@@ -0,0 +1,2 @@
1
+ const e=require("../converters/BuiltInConverters.cjs"),t=require("../converters/ValueConverter.cjs"),n=require("../Debug.cjs"),r=require("./EnvapterBase.cjs"),i=require("./EnvironmentMethods.cjs"),a=require("../TemplateResolver.cjs");var o=class o extends i.EnvironmentMethods{static service=new o;static templateResolver=new a.TemplateResolver(o.service);static valueConverter=new t.ValueConverter(o.service);isStrict(){return r.EnvapterBase.strict}static _get(t,r,i){let{key:a,value:o}=this.resolveKeyInput(t);if(this.treatAsMissing(o))return i!==void 0&&n.debugWarn(`${a} not found, using fallback ${String(i)}`),i;let s=o,c=this.templateResolver.resolveTemplate(a,String(s)),l;return l=r===1?e.BuiltInConverters.number(c,i):r===2?e.BuiltInConverters.boolean(c,i):r===3?e.BuiltInConverters.bigint(c,i):r===4?e.BuiltInConverters.symbol(c,i):e.BuiltInConverters.string(c,i),l}static get(e,t){return this._get(e,0,t)}get(e,t){return o._get(e,0,t)}static getNumber(e,t){return this._get(e,1,t)}getNumber(e,t){return o._get(e,1,t)}static getBoolean(e,t){return this._get(e,2,t)}getBoolean(e,t){return o._get(e,2,t)}static getBigInt(e,t){return this._get(e,3,t)}getBigInt(e,t){return o._get(e,3,t)}static getSymbol(e,t){return this._get(e,4,t)}getSymbol(e,t){return o._get(e,4,t)}};exports.PrimitiveMethods=o;
2
+ //# sourceMappingURL=PrimitiveMethods.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrimitiveMethods.cjs","names":["EnvironmentMethods","TemplateResolver","ValueConverter","EnvapterBase","BuiltInConverters"],"sources":["../../src/core/PrimitiveMethods.ts"],"sourcesContent":["import { BuiltInConverters, ValueConverter } from '../converters';\nimport { debugWarn } from '../Debug';\nimport { TemplateResolver } from '../TemplateResolver';\nimport { EnvapterBase } from './EnvapterBase';\nimport { EnvironmentMethods } from './EnvironmentMethods';\n\nimport type { ConditionalReturn, EnvKeyInput } from '../types';\nimport type { EnvapterService } from '../types/Env';\n\n/**\n * @internal\n */\nenum Primitive {\n String,\n Number,\n Boolean,\n BigInt,\n Symbol\n}\n\n/**\n * @internal\n */\nexport class PrimitiveMethods extends EnvironmentMethods implements EnvapterService {\n private static readonly service = new PrimitiveMethods();\n protected static readonly templateResolver: TemplateResolver = new TemplateResolver(PrimitiveMethods.service);\n protected static readonly valueConverter: ValueConverter = new ValueConverter(PrimitiveMethods.service);\n\n // Read `EnvapterBase.strict` directly: `PrimitiveMethods._strict` would resolve to the\n // BaseClass default because a `Envapter.strict = true` write lands as an own-property\n // on `Envapter`, which is a descendant of `PrimitiveMethods`, not an ancestor.\n isStrict(): boolean {\n return EnvapterBase.strict;\n }\n\n private static _get<EnvVarReturnType, DefaultType extends EnvVarReturnType | undefined = undefined>(\n key: EnvKeyInput,\n type: Primitive,\n def?: DefaultType\n ): ConditionalReturn<EnvVarReturnType, DefaultType> {\n const { key: resolvedKey, value } = this.resolveKeyInput(key);\n if (this.treatAsMissing(value)) {\n if (def !== undefined) debugWarn(`${resolvedKey} not found, using fallback ${String(def)}`);\n return def as ConditionalReturn<EnvVarReturnType, DefaultType>;\n }\n const rawVal = value as string | number | boolean | undefined;\n\n const parsed = this.templateResolver.resolveTemplate(resolvedKey, String(rawVal));\n\n let result: EnvVarReturnType;\n if (type === Primitive.Number) result = BuiltInConverters.number(parsed, def as number) as EnvVarReturnType;\n else if (type === Primitive.Boolean)\n result = BuiltInConverters.boolean(parsed, def as boolean) as EnvVarReturnType;\n else if (type === Primitive.BigInt)\n result = BuiltInConverters.bigint(parsed, def as bigint) as EnvVarReturnType;\n else if (type === Primitive.Symbol)\n result = BuiltInConverters.symbol(parsed, def as symbol) as EnvVarReturnType;\n else result = BuiltInConverters.string(parsed, def as string) as EnvVarReturnType;\n\n return result as ConditionalReturn<EnvVarReturnType, DefaultType>;\n }\n\n /**\n * Get a string environment variable with optional fallback.\n * Supports template variable resolution using `${VAR}` syntax.\n * Accepts a single key or an ordered array of keys (first match wins).\n */\n static get<Default extends string | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<string, Default> {\n return this._get(key, Primitive.String, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.get}\n */\n get<Default extends string | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<string, Default> {\n return PrimitiveMethods._get(key, Primitive.String, def);\n }\n\n /**\n * Get a number environment variable with optional fallback.\n * Automatically converts string values to numbers.\n * Accepts a single key or an ordered array of keys (first match wins).\n */\n static getNumber<Default extends number | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<number, Default> {\n return this._get(key, Primitive.Number, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getNumber}\n */\n getNumber<Default extends number | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<number, Default> {\n return PrimitiveMethods._get(key, Primitive.Number, def);\n }\n\n /**\n * Get a boolean environment variable with optional fallback.\n * Recognizes: `1`, `yes`, `true`, `on` as **true**; `0`, `no`, `false`, `off` as **false** (case-insensitive).\n * Accepts a single key or an ordered array of keys (first match wins).\n */\n static getBoolean<Default extends boolean | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<boolean, Default> {\n return this._get(key, Primitive.Boolean, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getBoolean}\n */\n getBoolean<Default extends boolean | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<boolean, Default> {\n return PrimitiveMethods._get(key, Primitive.Boolean, def);\n }\n\n /**\n * Get a bigint environment variable with optional fallback.\n * Automatically converts string values to bigint.\n * Accepts a single key or an ordered array of keys (first match wins).\n */\n static getBigInt<Default extends bigint | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<bigint, Default> {\n return this._get(key, Primitive.BigInt, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getBigInt}\n */\n getBigInt<Default extends bigint | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<bigint, Default> {\n return PrimitiveMethods._get(key, Primitive.BigInt, def);\n }\n\n /**\n * Get a symbol environment variable with optional fallback.\n * Creates a symbol from the string value.\n * Accepts a single key or an ordered array of keys (first match wins).\n */\n static getSymbol<Default extends symbol | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<symbol, Default> {\n return this._get(key, Primitive.Symbol, def);\n }\n\n /**\n * @see {@link PrimitiveMethods.getSymbol}\n */\n getSymbol<Default extends symbol | undefined = undefined>(\n key: EnvKeyInput,\n def?: Default\n ): ConditionalReturn<symbol, Default> {\n return PrimitiveMethods._get(key, Primitive.Symbol, def);\n }\n}\n"],"mappings":"0OAuBA,IAAa,EAAb,MAAa,UAAyBA,EAAAA,kBAA8C,CAChF,OAAwB,QAAU,IAAI,EACtC,OAA0B,iBAAqC,IAAIC,EAAAA,iBAAiB,EAAiB,OAAO,EAC5G,OAA0B,eAAiC,IAAIC,EAAAA,eAAe,EAAiB,OAAO,EAKtG,UAAoB,CAChB,OAAOC,EAAAA,aAAa,MACxB,CAEA,OAAe,KACX,EACA,EACA,EACgD,CAChD,GAAM,CAAE,IAAK,EAAa,SAAU,KAAK,gBAAgB,CAAG,EAC5D,GAAI,KAAK,eAAe,CAAK,EAEzB,OADI,IAAQ,IAAA,IAAW,EAAA,UAAU,GAAG,EAAY,6BAA6B,OAAO,CAAG,GAAG,EACnF,EAEX,IAAM,EAAS,EAET,EAAS,KAAK,iBAAiB,gBAAgB,EAAa,OAAO,CAAM,CAAC,EAE5E,EAUJ,MATA,CAOK,EAPD,IAAA,EAAoCC,EAAAA,kBAAkB,OAAO,EAAQ,CAAa,EAC7E,IAAA,EACIA,EAAAA,kBAAkB,QAAQ,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