@e-n-v/env 0.0.2 → 0.0.5

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 (99) hide show
  1. package/README.md +43 -24
  2. package/dist/BooleanMap-B2eIP3tZ.d.cts +32 -0
  3. package/dist/BooleanMap-DmFnCA-O.d.ts +32 -0
  4. package/dist/EnvChannel-LMIRYvT1.d.cts +16 -0
  5. package/dist/EnvChannel-w27PEm7x.d.ts +16 -0
  6. package/dist/EnvChannelOptions-BPkWDrmr.d.cts +108 -0
  7. package/dist/EnvChannelOptions-CRwDLWjd.d.ts +108 -0
  8. package/dist/EnvModel-CrGclUpJ.d.cts +134 -0
  9. package/dist/EnvModel-D8rt0EJ6.d.ts +134 -0
  10. package/dist/EnvSource-BVnmdHku.cjs +420 -0
  11. package/dist/EnvSource-DA3ZGlES.js +400 -0
  12. package/dist/ProcessEnvChannel-D465c-dp.d.cts +97 -0
  13. package/dist/ProcessEnvChannel-Do4-yiLI.d.ts +97 -0
  14. package/dist/StringEnvVarSchema-B8MT7htU.d.ts +64 -0
  15. package/dist/StringEnvVarSchema-BF6C0nyT.d.cts +64 -0
  16. package/dist/channels.cjs +8 -0
  17. package/dist/channels.d.cts +20 -0
  18. package/dist/channels.d.ts +20 -0
  19. package/dist/channels.js +4 -0
  20. package/dist/chunk-pbleEpgJ.cjs +44 -0
  21. package/dist/cli.cjs +16 -10
  22. package/dist/cli.js +7 -2
  23. package/dist/coerce-DNIuYAx4.js +11028 -0
  24. package/dist/coerce-b7UVodS9.cjs +12365 -0
  25. package/dist/core.cjs +68 -0
  26. package/dist/core.d.cts +6 -0
  27. package/dist/core.d.ts +6 -0
  28. package/dist/core.js +40 -0
  29. package/dist/custom-Bt_wnxIu.js +114 -0
  30. package/dist/custom-D_Rqjm09.cjs +168 -0
  31. package/dist/files.cjs +18 -0
  32. package/dist/files.d.cts +38 -0
  33. package/dist/files.d.ts +38 -0
  34. package/dist/files.js +13 -0
  35. package/dist/index-D8pslhp4.d.cts +170 -0
  36. package/dist/index-Dq_0aeAL.d.ts +170 -0
  37. package/dist/model-Dic8IJsf.d.ts +29 -0
  38. package/dist/model-ft0WhSSS.d.cts +29 -0
  39. package/dist/model.cjs +14 -0
  40. package/dist/model.d.cts +35 -0
  41. package/dist/model.d.ts +35 -0
  42. package/dist/model.js +9 -0
  43. package/dist/parse-BT1QSa5e.d.cts +28 -0
  44. package/dist/parse-DwtLpVhC.d.ts +28 -0
  45. package/dist/parse.cjs +17 -0
  46. package/dist/parse.d.cts +52 -0
  47. package/dist/parse.d.ts +52 -0
  48. package/dist/parse.js +10 -0
  49. package/dist/prompt-C5WudV9x.d.cts +74 -0
  50. package/dist/prompt-yKdccbtZ.d.ts +74 -0
  51. package/dist/prompt.cjs +24 -0
  52. package/dist/prompt.d.cts +17 -0
  53. package/dist/prompt.d.ts +17 -0
  54. package/dist/prompt.js +12 -0
  55. package/dist/redis-CJOpRPjc.js +395 -0
  56. package/dist/redis-EcC7TX3K.cjs +611 -0
  57. package/dist/resolveChannel-CjAuxy3p.cjs +257 -0
  58. package/dist/resolveChannel-v9BDsw-M.js +224 -0
  59. package/dist/root.cjs +36 -0
  60. package/dist/root.d.cts +21 -0
  61. package/dist/root.d.ts +21 -0
  62. package/dist/root.js +21 -0
  63. package/dist/schema-DH4GiW9A.d.cts +18 -0
  64. package/dist/schema-jN4EtvEP.d.ts +18 -0
  65. package/dist/schemas/zod.cjs +629 -0
  66. package/dist/schemas/zod.d.cts +239 -0
  67. package/dist/schemas/zod.d.ts +239 -0
  68. package/dist/schemas/zod.js +550 -0
  69. package/dist/schemas.cjs +133 -0
  70. package/dist/schemas.d.cts +3 -0
  71. package/dist/schemas.d.ts +3 -0
  72. package/dist/schemas.js +6 -0
  73. package/dist/src-B7FG1rak.js +638 -0
  74. package/dist/src-BBwjK5SK.js +127 -0
  75. package/dist/src-CLTURaoo.js +311 -0
  76. package/dist/src-CVdUqK3q.js +850 -0
  77. package/dist/src-Cjo2XA4n.cjs +138 -0
  78. package/dist/{src-oetJm-nZ.cjs → src-DWYoqPX1.cjs} +31 -1964
  79. package/dist/src-DZmpNGrQ.cjs +1411 -0
  80. package/dist/{src-RlCvrI0s.js → src-Dtv7TlJx.js} +14 -1726
  81. package/dist/src-XjL5cyPG.cjs +873 -0
  82. package/dist/src-meUnCASg.cjs +413 -0
  83. package/dist/validate-BxA3a-ns.d.cts +203 -0
  84. package/dist/validate-CyxrRacF.d.ts +203 -0
  85. package/dist/vars-BNVI6k89.d.ts +21 -0
  86. package/dist/vars-CYOaskkK.cjs +27 -0
  87. package/dist/vars-CptZRPX5.d.cts +21 -0
  88. package/dist/vars-DOW0LiiN.js +22 -0
  89. package/dist/vars.cjs +138 -0
  90. package/dist/vars.d.cts +7 -0
  91. package/dist/vars.d.ts +7 -0
  92. package/dist/vars.js +9 -0
  93. package/package.json +58 -9
  94. package/assets/demo.gif +0 -0
  95. package/assets/env-logo.png +0 -0
  96. package/dist/bundle.cjs +0 -1290
  97. package/dist/bundle.d.cts +0 -1057
  98. package/dist/bundle.d.ts +0 -1055
  99. package/dist/bundle.js +0 -1244
package/README.md CHANGED
@@ -1,67 +1,61 @@
1
1
  <!-- markdownlint-disable-next-line -->
2
- <img src="./assets/env-logo.png" alt="e-n-v Logo" height="55"/>
2
+ <img src="https://raw.githubusercontent.com/agorischek/e-n-v/main/static/logos/e-n-v.png" alt="e-n-v Logo" height="55"/>
3
3
 
4
4
  > Environments, niftily? Very!
5
5
 
6
6
  e·n·v is a suite of handy stuff for working with environment variables and `.env` files, including interactive setup and runtime validation.
7
7
 
8
8
  ```ts
9
- // Define environment variables
10
- const model = define({
11
- schemas: { NODE_ENV, DATABASE_URL, PORT },
12
- });
9
+ /* 1. Define environment variables */
10
+ const model = vars({ PORT, NODE_ENV, API_KEY });
13
11
  ```
14
12
 
15
13
  ```ts
16
- // Set up during development
17
- await prompt(model); // or use `e-n-v setup`
14
+ /* 2. Validate at runtime */
15
+ const env = parse(process.env, model);
18
16
  ```
19
17
 
20
18
  ```ts
21
- // Validate at runtime
22
- const env = parse(process.env, model);
19
+ /* 3. Set up during development */
20
+ await prompt(model); // or use `e-n-v setup`
23
21
  ```
24
22
 
25
23
  <!-- markdownlint-disable-next-line -->
26
- <img src="./assets/demo.gif" alt="Demo" width="500"/>
24
+ <img src="https://vhs.charm.sh/vhs-5fQTwW2FbZA42LNteIXA38.gif" alt="Demo" width="500"/>
27
25
 
28
26
  ## Usage
29
27
 
30
- ### 1. Define your model
28
+ ### Define your model
31
29
 
32
- An env model defines the structure of your environment variables, including names, schemas, and any preprocessing (e.g. converting `1`/`0` to boolean). This model is used both for development-time setup and runtime validation. e·n·v provides built-in schemas for common variables, and custom schemas can be authored using Zod.
30
+ An env model defines the structure of your environment variables. e·n·v provides built-in schemas for common variables, and custom schemas can be authored using Zod.
33
31
 
34
32
  ```ts
35
33
  // env.model.js
36
34
 
37
- import { define, schemas } from "e-n-v";
38
-
39
- const { NODE_ENV, DATABASE_URL, PORT } = schemas;
35
+ import vars, { NODE_ENV, PORT, DATABASE_URL } from "@e-n-v/env/vars";
40
36
 
41
- export default define({
42
- schemas: { NODE_ENV, DATABASE_URL, PORT },
43
- });
37
+ export default vars({ NODE_ENV, PORT, DATABASE_URL });
44
38
  ```
45
39
 
46
- ### 2. Set up for development
40
+ ### Set up for development
47
41
 
48
42
  Run `e-n-v setup` to interactively author your local `.env` file during development. This can be wrapped in a package script, e.g. `npm run env`. (Alternatively, a `prompt` method is available for programmatic use.)
49
43
 
50
- ### 3. Parse at runtime
44
+ ### Parse at runtime
51
45
 
52
46
  In your app, load your environment variables as usual, parse them, and export them for use. A combined error is thrown if any variables fail validation. Reference these exports throughout your code rather than using `process.env` directly.
53
47
 
54
48
  ```ts
55
- // env.vars.js
49
+ // env.js
56
50
 
57
51
  import "dotenv/config";
58
- import { parse } from "e-n-v";
52
+ import parse from "@e-n-v/env/parse";
59
53
  import model from "./env.model";
60
54
 
61
55
  export const { NODE_ENV, PORT, DATABASE_URL } = parse(process.env, model);
62
56
  ```
63
57
 
64
- ### 4. Customize
58
+ ### Customize
65
59
 
66
60
  e·n·v provides a variety of customization options, including:
67
61
 
@@ -69,4 +63,29 @@ e·n·v provides a variety of customization options, including:
69
63
  2. Reading and writing variables via other libraries, e.g. `dotenvx`.
70
64
  3. Changing the setup CLI behavior, such as what variables are treated as secrets.
71
65
 
72
- Happy configuration!
66
+ Happy configuring!
67
+
68
+ ## Models
69
+
70
+ Models define the structure of your environment variables, including names, schemas, and any preprocessing (e.g. converting `1`/`0` to boolean). The `vars` method defines a model with only variable schemas.
71
+
72
+ ```ts
73
+ import vars, { NODE_ENV } from "@e-n-v/env/vars";
74
+
75
+ export default vars({ NODE_ENV });
76
+ ```
77
+
78
+ If you also want to define custom preprocessing, use `define` instead. Preprocessors are run before values are submitted to schemas for validation.
79
+
80
+ ```ts
81
+ import { define, schemas } from "@e-n-v/env";
82
+
83
+ const { NODE_ENV } = schemas;
84
+
85
+ export default define({
86
+ schemas: { NODE_ENV },
87
+ preprocess: {
88
+ boolean: (value) => value === "true",
89
+ },
90
+ });
91
+ ```
@@ -0,0 +1,32 @@
1
+ import { a as EnumEnvVarSchema, r as NumberEnvVarSchema, s as BooleanEnvVarSchema, t as StringEnvVarSchema } from "./StringEnvVarSchema-BF6C0nyT.cjs";
2
+
3
+ //#region ../core/src/schemas/EnvVarSchema.d.ts
4
+
5
+ type EnvVarSchema = StringEnvVarSchema | NumberEnvVarSchema | BooleanEnvVarSchema | EnumEnvVarSchema<any>;
6
+ /**
7
+ * Type guard to check if a value is a EnvVarSchema instance
8
+ */
9
+ declare function isEnvVarSchema(value: unknown): value is EnvVarSchema;
10
+ //#endregion
11
+ //#region ../core/src/processing/types/Preprocessor.d.ts
12
+ /**
13
+ * Custom preprocessing functions to preprocess values before submitting to schema processors.
14
+ * Provide `false` to skip preprocessing, `true` to use the built-in default, or a function/options object for custom logic.
15
+ * These functions do not guarantee type casting and can be bypassed to skip preprocessing entirely.
16
+ */
17
+ type Preprocessor<T> = (value: string) => T | string;
18
+ type PreprocessorToggle<T> = Preprocessor<T> | boolean | undefined;
19
+ //#endregion
20
+ //#region ../core/src/processing/options/BooleanMap.d.ts
21
+ /**
22
+ * Shared boolean coercion configuration.
23
+ * These values are recognized as boolean strings across processors and preprocessors.
24
+ */
25
+ interface BooleanMap {
26
+ /** Values that map to true */
27
+ true: readonly string[];
28
+ /** Values that map to false */
29
+ false: readonly string[];
30
+ }
31
+ //#endregion
32
+ export { isEnvVarSchema as a, EnvVarSchema as i, Preprocessor as n, PreprocessorToggle as r, BooleanMap as t };
@@ -0,0 +1,32 @@
1
+ import { a as EnumEnvVarSchema, r as NumberEnvVarSchema, s as BooleanEnvVarSchema, t as StringEnvVarSchema } from "./StringEnvVarSchema-B8MT7htU.js";
2
+
3
+ //#region ../core/src/schemas/EnvVarSchema.d.ts
4
+
5
+ type EnvVarSchema = StringEnvVarSchema | NumberEnvVarSchema | BooleanEnvVarSchema | EnumEnvVarSchema<any>;
6
+ /**
7
+ * Type guard to check if a value is a EnvVarSchema instance
8
+ */
9
+ declare function isEnvVarSchema(value: unknown): value is EnvVarSchema;
10
+ //#endregion
11
+ //#region ../core/src/processing/types/Preprocessor.d.ts
12
+ /**
13
+ * Custom preprocessing functions to preprocess values before submitting to schema processors.
14
+ * Provide `false` to skip preprocessing, `true` to use the built-in default, or a function/options object for custom logic.
15
+ * These functions do not guarantee type casting and can be bypassed to skip preprocessing entirely.
16
+ */
17
+ type Preprocessor<T> = (value: string) => T | string;
18
+ type PreprocessorToggle<T> = Preprocessor<T> | boolean | undefined;
19
+ //#endregion
20
+ //#region ../core/src/processing/options/BooleanMap.d.ts
21
+ /**
22
+ * Shared boolean coercion configuration.
23
+ * These values are recognized as boolean strings across processors and preprocessors.
24
+ */
25
+ interface BooleanMap {
26
+ /** Values that map to true */
27
+ true: readonly string[];
28
+ /** Values that map to false */
29
+ false: readonly string[];
30
+ }
31
+ //#endregion
32
+ export { isEnvVarSchema as a, EnvVarSchema as i, Preprocessor as n, PreprocessorToggle as r, BooleanMap as t };
@@ -0,0 +1,16 @@
1
+ //#region ../core/src/types/EnvChannel.d.ts
2
+ /**
3
+ * Interface for accessing and modifying environment variables
4
+ */
5
+ interface EnvChannel {
6
+ /**
7
+ * Get environment variables
8
+ */
9
+ get(keys?: string[]): Promise<Record<string, string>>;
10
+ /**
11
+ * Set environment variables
12
+ */
13
+ set(values: Record<string, string>): Promise<void>;
14
+ }
15
+ //#endregion
16
+ export { EnvChannel as t };
@@ -0,0 +1,16 @@
1
+ //#region ../core/src/types/EnvChannel.d.ts
2
+ /**
3
+ * Interface for accessing and modifying environment variables
4
+ */
5
+ interface EnvChannel {
6
+ /**
7
+ * Get environment variables
8
+ */
9
+ get(keys?: string[]): Promise<Record<string, string>>;
10
+ /**
11
+ * Set environment variables
12
+ */
13
+ set(values: Record<string, string>): Promise<void>;
14
+ }
15
+ //#endregion
16
+ export { EnvChannel as t };
@@ -0,0 +1,108 @@
1
+ import { DotenvConfigOptions, DotenvConfigOutput, GetOptions, SetOptions } from "@dotenvx/dotenvx";
2
+
3
+ //#region ../channels/src/channels/dotenv/DotEnvInstance.d.ts
4
+ interface DotEnvConfigOptions {
5
+ path?: string;
6
+ encoding?: string;
7
+ debug?: boolean;
8
+ override?: boolean;
9
+ [key: string]: unknown;
10
+ }
11
+ interface DotEnvConfigOutput {
12
+ parsed?: Record<string, string>;
13
+ error?: Error;
14
+ }
15
+ interface DotEnvParseOptions {
16
+ debug?: boolean;
17
+ [key: string]: unknown;
18
+ }
19
+ interface DotEnvInstance {
20
+ parse(src: string | Buffer, options?: DotEnvParseOptions): Record<string, string | undefined>;
21
+ config?(options?: DotEnvConfigOptions): DotEnvConfigOutput;
22
+ }
23
+ //#endregion
24
+ //#region ../channels/src/channels/dotenv/DotEnvChannelConfig.d.ts
25
+ interface DotEnvChannelConfig {
26
+ dotenv: DotEnvInstance;
27
+ path?: string;
28
+ get?: DotEnvConfigOptions & {
29
+ [key: string]: unknown;
30
+ };
31
+ parse?: DotEnvParseOptions & {
32
+ [key: string]: unknown;
33
+ };
34
+ }
35
+ //#endregion
36
+ //#region ../channels/src/channels/dotenvx/DotEnvXInstance.d.ts
37
+ /**
38
+ * Minimal interface for dotenvx functionality used in ask-env.
39
+ */
40
+ interface DotEnvXInstance {
41
+ get(key: string, options?: GetOptions): string;
42
+ set(key: string, value: string, options?: SetOptions): unknown;
43
+ config(options?: DotenvConfigOptions): DotenvConfigOutput;
44
+ }
45
+ //#endregion
46
+ //#region ../channels/src/channels/dotenvx/DotEnvXGetOptions.d.ts
47
+ /**
48
+ * Get options without envKeysFile since we manage that ourselves
49
+ */
50
+ type DotEnvXGetOptions = Omit<GetOptions, "envKeysFile">;
51
+ //#endregion
52
+ //#region ../channels/src/channels/dotenvx/DotEnvXSetOptions.d.ts
53
+ /**
54
+ * Set options without envKeysFile since we manage that ourselves
55
+ */
56
+ type DotEnvXSetOptions = Omit<SetOptions, "envKeysFile">;
57
+ //#endregion
58
+ //#region ../channels/src/channels/dotenvx/DotEnvXChannelConfig.d.ts
59
+ /**
60
+ * DotEnvX channel configuration
61
+ */
62
+ interface DotEnvXChannelConfig {
63
+ dotenvx: DotEnvXInstance;
64
+ get?: DotEnvXGetOptions & {
65
+ [key: string]: unknown;
66
+ };
67
+ set?: DotEnvXSetOptions & {
68
+ [key: string]: unknown;
69
+ };
70
+ }
71
+ //#endregion
72
+ //#region ../channels/src/channels/default/DefaultChannelConfig.d.ts
73
+ /**
74
+ * Default channel configuration
75
+ */
76
+ interface DefaultChannelConfig {
77
+ name: "default";
78
+ }
79
+ //#endregion
80
+ //#region ../channels/src/channels/processenv/ProcessEnvChannelConfig.d.ts
81
+ /**
82
+ * Configuration for ProcessEnv channel using name
83
+ */
84
+ interface ProcessEnvChannelConfig {
85
+ name: "processenv";
86
+ }
87
+ /**
88
+ * Configuration for ProcessEnv channel using process shorthand
89
+ */
90
+ interface ProcessChannelConfig {
91
+ process: NodeJS.Process;
92
+ }
93
+ //#endregion
94
+ //#region ../channels/src/EnvChannelOptions.d.ts
95
+ /**
96
+ * Channel options can be:
97
+ * - undefined (uses default channel)
98
+ * - "default" string (uses default channel)
99
+ * - "processenv" string (uses process.env channel)
100
+ * - dotenvx instance (uses dotenvx with default options)
101
+ * - DotEnvXChannelConfig (uses dotenvx with custom options)
102
+ * - DefaultChannelConfig (uses default with custom options)
103
+ * - ProcessEnvChannelConfig (uses process.env with config options)
104
+ * - ProcessChannelConfig (uses process.env with { process } notation)
105
+ */
106
+ type EnvChannelOptions = undefined | "default" | "processenv" | DotEnvChannelConfig | DotEnvXChannelConfig | DefaultChannelConfig | ProcessEnvChannelConfig | ProcessChannelConfig;
107
+ //#endregion
108
+ export { DotEnvXChannelConfig as a, DotEnvXInstance as c, DotEnvConfigOutput as d, DotEnvInstance as f, DefaultChannelConfig as i, DotEnvChannelConfig as l, ProcessChannelConfig as n, DotEnvXSetOptions as o, DotEnvParseOptions as p, ProcessEnvChannelConfig as r, DotEnvXGetOptions as s, EnvChannelOptions as t, DotEnvConfigOptions as u };
@@ -0,0 +1,108 @@
1
+ import { DotenvConfigOptions, DotenvConfigOutput, GetOptions, SetOptions } from "@dotenvx/dotenvx";
2
+
3
+ //#region ../channels/src/channels/dotenv/DotEnvInstance.d.ts
4
+ interface DotEnvConfigOptions {
5
+ path?: string;
6
+ encoding?: string;
7
+ debug?: boolean;
8
+ override?: boolean;
9
+ [key: string]: unknown;
10
+ }
11
+ interface DotEnvConfigOutput {
12
+ parsed?: Record<string, string>;
13
+ error?: Error;
14
+ }
15
+ interface DotEnvParseOptions {
16
+ debug?: boolean;
17
+ [key: string]: unknown;
18
+ }
19
+ interface DotEnvInstance {
20
+ parse(src: string | Buffer, options?: DotEnvParseOptions): Record<string, string | undefined>;
21
+ config?(options?: DotEnvConfigOptions): DotEnvConfigOutput;
22
+ }
23
+ //#endregion
24
+ //#region ../channels/src/channels/dotenv/DotEnvChannelConfig.d.ts
25
+ interface DotEnvChannelConfig {
26
+ dotenv: DotEnvInstance;
27
+ path?: string;
28
+ get?: DotEnvConfigOptions & {
29
+ [key: string]: unknown;
30
+ };
31
+ parse?: DotEnvParseOptions & {
32
+ [key: string]: unknown;
33
+ };
34
+ }
35
+ //#endregion
36
+ //#region ../channels/src/channels/dotenvx/DotEnvXInstance.d.ts
37
+ /**
38
+ * Minimal interface for dotenvx functionality used in ask-env.
39
+ */
40
+ interface DotEnvXInstance {
41
+ get(key: string, options?: GetOptions): string;
42
+ set(key: string, value: string, options?: SetOptions): unknown;
43
+ config(options?: DotenvConfigOptions): DotenvConfigOutput;
44
+ }
45
+ //#endregion
46
+ //#region ../channels/src/channels/dotenvx/DotEnvXGetOptions.d.ts
47
+ /**
48
+ * Get options without envKeysFile since we manage that ourselves
49
+ */
50
+ type DotEnvXGetOptions = Omit<GetOptions, "envKeysFile">;
51
+ //#endregion
52
+ //#region ../channels/src/channels/dotenvx/DotEnvXSetOptions.d.ts
53
+ /**
54
+ * Set options without envKeysFile since we manage that ourselves
55
+ */
56
+ type DotEnvXSetOptions = Omit<SetOptions, "envKeysFile">;
57
+ //#endregion
58
+ //#region ../channels/src/channels/dotenvx/DotEnvXChannelConfig.d.ts
59
+ /**
60
+ * DotEnvX channel configuration
61
+ */
62
+ interface DotEnvXChannelConfig {
63
+ dotenvx: DotEnvXInstance;
64
+ get?: DotEnvXGetOptions & {
65
+ [key: string]: unknown;
66
+ };
67
+ set?: DotEnvXSetOptions & {
68
+ [key: string]: unknown;
69
+ };
70
+ }
71
+ //#endregion
72
+ //#region ../channels/src/channels/default/DefaultChannelConfig.d.ts
73
+ /**
74
+ * Default channel configuration
75
+ */
76
+ interface DefaultChannelConfig {
77
+ name: "default";
78
+ }
79
+ //#endregion
80
+ //#region ../channels/src/channels/processenv/ProcessEnvChannelConfig.d.ts
81
+ /**
82
+ * Configuration for ProcessEnv channel using name
83
+ */
84
+ interface ProcessEnvChannelConfig {
85
+ name: "processenv";
86
+ }
87
+ /**
88
+ * Configuration for ProcessEnv channel using process shorthand
89
+ */
90
+ interface ProcessChannelConfig {
91
+ process: NodeJS.Process;
92
+ }
93
+ //#endregion
94
+ //#region ../channels/src/EnvChannelOptions.d.ts
95
+ /**
96
+ * Channel options can be:
97
+ * - undefined (uses default channel)
98
+ * - "default" string (uses default channel)
99
+ * - "processenv" string (uses process.env channel)
100
+ * - dotenvx instance (uses dotenvx with default options)
101
+ * - DotEnvXChannelConfig (uses dotenvx with custom options)
102
+ * - DefaultChannelConfig (uses default with custom options)
103
+ * - ProcessEnvChannelConfig (uses process.env with config options)
104
+ * - ProcessChannelConfig (uses process.env with { process } notation)
105
+ */
106
+ type EnvChannelOptions = undefined | "default" | "processenv" | DotEnvChannelConfig | DotEnvXChannelConfig | DefaultChannelConfig | ProcessEnvChannelConfig | ProcessChannelConfig;
107
+ //#endregion
108
+ export { DotEnvXChannelConfig as a, DotEnvXInstance as c, DotEnvConfigOutput as d, DotEnvInstance as f, DefaultChannelConfig as i, DotEnvChannelConfig as l, ProcessChannelConfig as n, DotEnvXSetOptions as o, DotEnvParseOptions as p, ProcessEnvChannelConfig as r, DotEnvXGetOptions as s, EnvChannelOptions as t, DotEnvConfigOptions as u };
@@ -0,0 +1,134 @@
1
+ import { a as EnumEnvVarSchema, l as EnvVarSchemaBase, r as NumberEnvVarSchema, s as BooleanEnvVarSchema, t as StringEnvVarSchema } from "./StringEnvVarSchema-BF6C0nyT.cjs";
2
+ import { i as EnvVarSchema, n as Preprocessor, t as BooleanMap } from "./BooleanMap-B2eIP3tZ.cjs";
3
+ import { AnySchema } from "joi";
4
+ import { ZodTypeAny } from "zod";
5
+ import { $ZodType } from "zod/v4/core";
6
+ import { Struct } from "superstruct";
7
+
8
+ //#region ../models/src/schemas.d.ts
9
+ type JoiSchema = AnySchema;
10
+ type ZodV3Schema = ZodTypeAny;
11
+ type ZodV4Schema = $ZodType;
12
+ type SuperstructSchema = Struct<any, any>;
13
+ type Schema = ZodV3Schema | ZodV4Schema | JoiSchema | SuperstructSchema | EnvVarSchema;
14
+ //#endregion
15
+ //#region ../models/src/types.d.ts
16
+ /**
17
+ * Supported schema types - local definition to avoid circular dependencies
18
+ */
19
+ type SupportedSchema = Schema;
20
+ type InferZodOutput<T> = T extends {
21
+ _output: infer Output;
22
+ } ? Output : T extends {
23
+ _type: infer LegacyOutput;
24
+ } ? LegacyOutput : never;
25
+ type InferJoiOutput<T> = T extends {
26
+ validate: (...args: any[]) => infer Result;
27
+ } ? Result extends {
28
+ value: infer Value;
29
+ } ? Value : Result extends Promise<infer AsyncResult> ? AsyncResult extends {
30
+ value: infer AsyncValue;
31
+ } ? AsyncValue : unknown : unknown : T extends {
32
+ validateAsync: (...args: any[]) => Promise<infer AsyncValue>;
33
+ } ? AsyncValue : unknown;
34
+ /**
35
+ * Infer the TypeScript type from an EnvVarSchema instance
36
+ * Uses the schema's type property and values to determine the correct TypeScript type
37
+ */
38
+ type InferSchemaType<T> = T extends {
39
+ readonly type: "string";
40
+ } ? string : T extends {
41
+ readonly type: "number";
42
+ } ? number : T extends {
43
+ readonly type: "boolean";
44
+ } ? boolean : T extends {
45
+ readonly type: "enum";
46
+ readonly values: readonly (infer U)[];
47
+ } ? U : T extends EnumEnvVarSchema<infer U> ? U : T extends NumberEnvVarSchema ? number : T extends StringEnvVarSchema ? string : T extends BooleanEnvVarSchema ? boolean : T extends EnvVarSchemaBase<infer U> ? U : T extends AnySchema ? InferJoiOutput<T> : T extends ZodTypeAny ? InferZodOutput<T> : T extends $ZodType ? InferZodOutput<T> : unknown;
48
+ /**
49
+ * Infer whether a schema field is optional based on its required property
50
+ */
51
+ type InferOptional<T> = T extends {
52
+ required: false;
53
+ } ? true : T extends {
54
+ required: true;
55
+ } ? false : T extends {
56
+ required: boolean;
57
+ } ? boolean : false;
58
+ /**
59
+ * Utility type to flatten complex generic types for better IDE display
60
+ */
61
+ type Simplify<T> = { [K in keyof T]: T[K] } & {};
62
+ /**
63
+ * Infer the complete environment type from a schemas record
64
+ * Handles optional vs required fields properly
65
+ * Uses Simplify to flatten the type display in IDEs
66
+ */
67
+ type InferEnvType<T extends Record<string, SupportedSchema>> = Simplify<{ [K in keyof T]: InferOptional<T[K]> extends true ? InferSchemaType<T[K]> | undefined : InferSchemaType<T[K]> }>;
68
+ //#endregion
69
+ //#region ../models/src/EnvModelOptions.d.ts
70
+ type PreprocessorToggle<T> = Preprocessor<T> | boolean | undefined;
71
+ interface Preprocessors {
72
+ /**
73
+ * Custom string preprocessing function
74
+ */
75
+ string?: PreprocessorToggle<string>;
76
+ /**
77
+ * Custom number preprocessing function
78
+ */
79
+ number?: PreprocessorToggle<number>;
80
+ /**
81
+ * Custom boolean preprocessing function
82
+ */
83
+ boolean?: boolean | Preprocessor<boolean> | BooleanMap | undefined;
84
+ /**
85
+ * Custom enum preprocessing function
86
+ */
87
+ enum?: PreprocessorToggle<string>;
88
+ }
89
+ /**
90
+ * Options for creating an EnvModel instance
91
+ */
92
+ interface EnvModelOptions<T extends Record<string, SupportedSchema> = Record<string, SupportedSchema>> {
93
+ /**
94
+ * Environment variable schemas
95
+ * Map of variable names to their schema definitions
96
+ */
97
+ schemas: T;
98
+ /**
99
+ * Preprocessing configuration
100
+ * - `true`: Use default preprocessors for all types
101
+ * - `false`: Disable all preprocessing
102
+ * - Partial object: Customize specific type preprocessors
103
+ */
104
+ preprocess?: true | false | Partial<Preprocessors>;
105
+ }
106
+ //#endregion
107
+ //#region ../models/src/EnvModel.d.ts
108
+ /**
109
+ * Environment variable specification container
110
+ * Encapsulates schemas and preprocessor configuration
111
+ */
112
+ declare class EnvModel<T extends Record<string, SupportedSchema> = Record<string, SupportedSchema>> {
113
+ /**
114
+ * Resolved environment variable schemas
115
+ */
116
+ readonly schemas: Record<string, EnvVarSchema>;
117
+ /**
118
+ * Preprocessing configuration for environment variable types
119
+ */
120
+ readonly preprocess: Preprocessors;
121
+ /**
122
+ * Create an EnvModel instance from options
123
+ * @param options - Specification options
124
+ */
125
+ constructor(options: EnvModelOptions<T>);
126
+ /**
127
+ * Resolve preprocessor configuration from options
128
+ * @param config - Preprocessor configuration (true, false, or partial object)
129
+ * @returns Resolved preprocessors object
130
+ */
131
+ private resolvePreprocessors;
132
+ }
133
+ //#endregion
134
+ export { SupportedSchema as a, InferSchemaType as i, EnvModelOptions as n, Schema as o, InferEnvType as r, EnvModel as t };