@geekmidas/envkit 0.0.3 → 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.
- package/dist/EnvironmentParser-BD6NmvPR.d.mts +108 -0
- package/dist/{EnvironmentParser-Bz9IoLJs.cjs → EnvironmentParser-BDPDLv6i.cjs} +56 -43
- package/dist/{EnvironmentParser-Boj5EFmL.mjs → EnvironmentParser-CQUOGqc0.mjs} +52 -2
- package/dist/EnvironmentParser-X4h2Vp4r.d.cts +108 -0
- package/dist/EnvironmentParser.cjs +1 -1
- package/dist/EnvironmentParser.d.cts +2 -0
- package/dist/EnvironmentParser.d.mts +2 -0
- package/dist/EnvironmentParser.mjs +1 -1
- package/dist/__tests__/ConfigParser.spec.cjs +53 -52
- package/dist/__tests__/ConfigParser.spec.d.cts +1 -0
- package/dist/__tests__/ConfigParser.spec.d.mts +1 -0
- package/dist/__tests__/ConfigParser.spec.mjs +27 -27
- package/dist/__tests__/EnvironmentParser.spec.cjs +79 -78
- package/dist/__tests__/EnvironmentParser.spec.d.cts +1 -0
- package/dist/__tests__/EnvironmentParser.spec.d.mts +1 -0
- package/dist/__tests__/EnvironmentParser.spec.mjs +41 -41
- package/dist/chunk-CUT6urMc.cjs +30 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -1
- package/dist/sst.cjs +131 -0
- package/dist/sst.d.cts +107 -0
- package/dist/sst.d.mts +107 -0
- package/dist/sst.mjs +128 -0
- package/package.json +12 -5
- package/src/EnvironmentParser.ts +80 -3
- package/src/sst.ts +221 -0
- package/dist/magic-string.es-BrLHy2bw.cjs +0 -1015
- package/dist/magic-string.es-u4lFXMgd.mjs +0 -1014
- package/dist/vi.bdSIJ99Y-CT9xbG7X.cjs +0 -14895
- package/dist/vi.bdSIJ99Y-CkiV-M6Y.mjs +0 -14903
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
|
|
3
|
+
//#region src/EnvironmentParser.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Parses and validates configuration objects against Zod schemas.
|
|
7
|
+
* Handles nested configurations and aggregates validation errors.
|
|
8
|
+
*
|
|
9
|
+
* @template TResponse - The shape of the configuration object
|
|
10
|
+
*/
|
|
11
|
+
declare class ConfigParser<TResponse extends EmptyObject> {
|
|
12
|
+
private readonly config;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new ConfigParser instance.
|
|
15
|
+
*
|
|
16
|
+
* @param config - The configuration object to parse
|
|
17
|
+
*/
|
|
18
|
+
constructor(config: TResponse);
|
|
19
|
+
/**
|
|
20
|
+
* Parses the config object and validates it against the Zod schemas
|
|
21
|
+
* @returns The parsed config object
|
|
22
|
+
*/
|
|
23
|
+
parse(): InferConfig<TResponse>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Parses environment variables with type-safe validation using Zod schemas.
|
|
27
|
+
* Provides a fluent API for defining environment variable schemas with automatic
|
|
28
|
+
* error context enrichment.
|
|
29
|
+
*
|
|
30
|
+
* @template T - The type of the configuration object (typically process.env)
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const config = new EnvironmentParser(process.env)
|
|
35
|
+
* .create((get) => ({
|
|
36
|
+
* port: get('PORT').string().transform(Number).default(3000),
|
|
37
|
+
* database: {
|
|
38
|
+
* url: get('DATABASE_URL').string().url()
|
|
39
|
+
* }
|
|
40
|
+
* }))
|
|
41
|
+
* .parse();
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
declare class EnvironmentParser<T extends EmptyObject> {
|
|
45
|
+
private readonly config;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new EnvironmentParser instance.
|
|
48
|
+
*
|
|
49
|
+
* @param config - The configuration object to parse (typically process.env)
|
|
50
|
+
*/
|
|
51
|
+
constructor(config: T);
|
|
52
|
+
/**
|
|
53
|
+
* Wraps a Zod schema to intercept parse/safeParse calls and enrich error messages
|
|
54
|
+
* with environment variable context.
|
|
55
|
+
*
|
|
56
|
+
* @param schema - The Zod schema to wrap
|
|
57
|
+
* @param name - The environment variable name for error context
|
|
58
|
+
* @returns A wrapped Zod schema with enhanced error reporting
|
|
59
|
+
*/
|
|
60
|
+
private wrapSchema;
|
|
61
|
+
/**
|
|
62
|
+
* Creates a proxied version of the Zod object that wraps all schema creators
|
|
63
|
+
* to provide enhanced error messages with environment variable context.
|
|
64
|
+
*
|
|
65
|
+
* @param name - The environment variable name
|
|
66
|
+
* @returns A proxied Zod object with wrapped schema creators
|
|
67
|
+
*/
|
|
68
|
+
private getZodGetter;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new ConfigParser object that can be used to parse the config object
|
|
71
|
+
*
|
|
72
|
+
* @param builder - A function that takes a getter function and returns a config object
|
|
73
|
+
* @returns A ConfigParser object that can be used to parse the config object
|
|
74
|
+
*/
|
|
75
|
+
create<TReturn extends EmptyObject>(builder: (get: EnvFetcher) => TReturn): ConfigParser<TReturn>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Infers the TypeScript type of a configuration object based on its Zod schemas.
|
|
79
|
+
* Recursively processes nested objects and extracts types from Zod schemas.
|
|
80
|
+
*
|
|
81
|
+
* @template T - The configuration object type
|
|
82
|
+
*/
|
|
83
|
+
type InferConfig<T extends EmptyObject> = { [K in keyof T]: T[K] extends z.ZodSchema ? z.infer<T[K]> : T[K] extends Record<string, unknown> ? InferConfig<T[K]> : T[K] };
|
|
84
|
+
/**
|
|
85
|
+
* Function type for fetching environment variables with Zod validation.
|
|
86
|
+
* Returns a Zod object scoped to a specific environment variable.
|
|
87
|
+
*
|
|
88
|
+
* @template TPath - The environment variable path type
|
|
89
|
+
* @param name - The environment variable name
|
|
90
|
+
* @returns A Zod object for defining the schema
|
|
91
|
+
*/
|
|
92
|
+
type EnvFetcher<TPath extends string = string> = (name: TPath) => typeof z;
|
|
93
|
+
/**
|
|
94
|
+
* Function type for building environment configuration objects.
|
|
95
|
+
* Takes an EnvFetcher and returns a configuration object with Zod schemas.
|
|
96
|
+
*
|
|
97
|
+
* @template TResponse - The response configuration object type
|
|
98
|
+
* @param get - The environment variable fetcher function
|
|
99
|
+
* @returns The configuration object with Zod schemas
|
|
100
|
+
*/
|
|
101
|
+
type EnvironmentBuilder<TResponse extends EmptyObject> = (get: EnvFetcher) => TResponse;
|
|
102
|
+
/**
|
|
103
|
+
* Type alias for a generic object with unknown values.
|
|
104
|
+
* Used as a constraint for configuration objects.
|
|
105
|
+
*/
|
|
106
|
+
type EmptyObject = Record<string | number | symbol, unknown>;
|
|
107
|
+
//#endregion
|
|
108
|
+
export { ConfigParser, EmptyObject, EnvFetcher, EnvironmentBuilder, EnvironmentParser, InferConfig };
|
|
@@ -1,35 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJS = (cb, mod) => function() {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
13
|
-
key = keys[i];
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
-
get: ((k) => from[k]).bind(null, key),
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
-
value: mod,
|
|
23
|
-
enumerable: true
|
|
24
|
-
}) : target, mod));
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
const lodash_get = __toESM(require("lodash.get"));
|
|
28
|
-
const lodash_set = __toESM(require("lodash.set"));
|
|
29
|
-
const zod_v4 = __toESM(require("zod/v4"));
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
const lodash_get = require_chunk.__toESM(require("lodash.get"));
|
|
3
|
+
const lodash_set = require_chunk.__toESM(require("lodash.set"));
|
|
4
|
+
const zod_v4 = require_chunk.__toESM(require("zod/v4"));
|
|
30
5
|
|
|
31
6
|
//#region src/EnvironmentParser.ts
|
|
7
|
+
/**
|
|
8
|
+
* Parses and validates configuration objects against Zod schemas.
|
|
9
|
+
* Handles nested configurations and aggregates validation errors.
|
|
10
|
+
*
|
|
11
|
+
* @template TResponse - The shape of the configuration object
|
|
12
|
+
*/
|
|
32
13
|
var ConfigParser = class {
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new ConfigParser instance.
|
|
16
|
+
*
|
|
17
|
+
* @param config - The configuration object to parse
|
|
18
|
+
*/
|
|
33
19
|
constructor(config) {
|
|
34
20
|
this.config = config;
|
|
35
21
|
}
|
|
@@ -61,10 +47,42 @@ var ConfigParser = class {
|
|
|
61
47
|
return parsedConfig;
|
|
62
48
|
}
|
|
63
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* Parses environment variables with type-safe validation using Zod schemas.
|
|
52
|
+
* Provides a fluent API for defining environment variable schemas with automatic
|
|
53
|
+
* error context enrichment.
|
|
54
|
+
*
|
|
55
|
+
* @template T - The type of the configuration object (typically process.env)
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const config = new EnvironmentParser(process.env)
|
|
60
|
+
* .create((get) => ({
|
|
61
|
+
* port: get('PORT').string().transform(Number).default(3000),
|
|
62
|
+
* database: {
|
|
63
|
+
* url: get('DATABASE_URL').string().url()
|
|
64
|
+
* }
|
|
65
|
+
* }))
|
|
66
|
+
* .parse();
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
64
69
|
var EnvironmentParser = class {
|
|
70
|
+
/**
|
|
71
|
+
* Creates a new EnvironmentParser instance.
|
|
72
|
+
*
|
|
73
|
+
* @param config - The configuration object to parse (typically process.env)
|
|
74
|
+
*/
|
|
65
75
|
constructor(config) {
|
|
66
76
|
this.config = config;
|
|
67
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Wraps a Zod schema to intercept parse/safeParse calls and enrich error messages
|
|
80
|
+
* with environment variable context.
|
|
81
|
+
*
|
|
82
|
+
* @param schema - The Zod schema to wrap
|
|
83
|
+
* @param name - The environment variable name for error context
|
|
84
|
+
* @returns A wrapped Zod schema with enhanced error reporting
|
|
85
|
+
*/
|
|
68
86
|
wrapSchema = (schema, name) => {
|
|
69
87
|
return new Proxy(schema, { get: (target, prop) => {
|
|
70
88
|
if (prop === "parse") return () => {
|
|
@@ -108,6 +126,13 @@ var EnvironmentParser = class {
|
|
|
108
126
|
return originalProp;
|
|
109
127
|
} });
|
|
110
128
|
};
|
|
129
|
+
/**
|
|
130
|
+
* Creates a proxied version of the Zod object that wraps all schema creators
|
|
131
|
+
* to provide enhanced error messages with environment variable context.
|
|
132
|
+
*
|
|
133
|
+
* @param name - The environment variable name
|
|
134
|
+
* @returns A proxied Zod object with wrapped schema creators
|
|
135
|
+
*/
|
|
111
136
|
getZodGetter = (name) => {
|
|
112
137
|
return new Proxy({ ...zod_v4.z }, { get: (target, prop) => {
|
|
113
138
|
const value = target[prop];
|
|
@@ -127,10 +152,10 @@ var EnvironmentParser = class {
|
|
|
127
152
|
} });
|
|
128
153
|
};
|
|
129
154
|
/**
|
|
130
|
-
* Creates a new
|
|
155
|
+
* Creates a new ConfigParser object that can be used to parse the config object
|
|
131
156
|
*
|
|
132
157
|
* @param builder - A function that takes a getter function and returns a config object
|
|
133
|
-
* @returns A
|
|
158
|
+
* @returns A ConfigParser object that can be used to parse the config object
|
|
134
159
|
*/
|
|
135
160
|
create(builder) {
|
|
136
161
|
const config = builder(this.getZodGetter);
|
|
@@ -150,16 +175,4 @@ Object.defineProperty(exports, 'EnvironmentParser', {
|
|
|
150
175
|
get: function () {
|
|
151
176
|
return EnvironmentParser;
|
|
152
177
|
}
|
|
153
|
-
});
|
|
154
|
-
Object.defineProperty(exports, '__commonJS', {
|
|
155
|
-
enumerable: true,
|
|
156
|
-
get: function () {
|
|
157
|
-
return __commonJS;
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
Object.defineProperty(exports, '__toESM', {
|
|
161
|
-
enumerable: true,
|
|
162
|
-
get: function () {
|
|
163
|
-
return __toESM;
|
|
164
|
-
}
|
|
165
178
|
});
|
|
@@ -3,7 +3,18 @@ import set from "lodash.set";
|
|
|
3
3
|
import { z } from "zod/v4";
|
|
4
4
|
|
|
5
5
|
//#region src/EnvironmentParser.ts
|
|
6
|
+
/**
|
|
7
|
+
* Parses and validates configuration objects against Zod schemas.
|
|
8
|
+
* Handles nested configurations and aggregates validation errors.
|
|
9
|
+
*
|
|
10
|
+
* @template TResponse - The shape of the configuration object
|
|
11
|
+
*/
|
|
6
12
|
var ConfigParser = class {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new ConfigParser instance.
|
|
15
|
+
*
|
|
16
|
+
* @param config - The configuration object to parse
|
|
17
|
+
*/
|
|
7
18
|
constructor(config) {
|
|
8
19
|
this.config = config;
|
|
9
20
|
}
|
|
@@ -35,10 +46,42 @@ var ConfigParser = class {
|
|
|
35
46
|
return parsedConfig;
|
|
36
47
|
}
|
|
37
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* Parses environment variables with type-safe validation using Zod schemas.
|
|
51
|
+
* Provides a fluent API for defining environment variable schemas with automatic
|
|
52
|
+
* error context enrichment.
|
|
53
|
+
*
|
|
54
|
+
* @template T - The type of the configuration object (typically process.env)
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const config = new EnvironmentParser(process.env)
|
|
59
|
+
* .create((get) => ({
|
|
60
|
+
* port: get('PORT').string().transform(Number).default(3000),
|
|
61
|
+
* database: {
|
|
62
|
+
* url: get('DATABASE_URL').string().url()
|
|
63
|
+
* }
|
|
64
|
+
* }))
|
|
65
|
+
* .parse();
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
38
68
|
var EnvironmentParser = class {
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new EnvironmentParser instance.
|
|
71
|
+
*
|
|
72
|
+
* @param config - The configuration object to parse (typically process.env)
|
|
73
|
+
*/
|
|
39
74
|
constructor(config) {
|
|
40
75
|
this.config = config;
|
|
41
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Wraps a Zod schema to intercept parse/safeParse calls and enrich error messages
|
|
79
|
+
* with environment variable context.
|
|
80
|
+
*
|
|
81
|
+
* @param schema - The Zod schema to wrap
|
|
82
|
+
* @param name - The environment variable name for error context
|
|
83
|
+
* @returns A wrapped Zod schema with enhanced error reporting
|
|
84
|
+
*/
|
|
42
85
|
wrapSchema = (schema, name) => {
|
|
43
86
|
return new Proxy(schema, { get: (target, prop) => {
|
|
44
87
|
if (prop === "parse") return () => {
|
|
@@ -82,6 +125,13 @@ var EnvironmentParser = class {
|
|
|
82
125
|
return originalProp;
|
|
83
126
|
} });
|
|
84
127
|
};
|
|
128
|
+
/**
|
|
129
|
+
* Creates a proxied version of the Zod object that wraps all schema creators
|
|
130
|
+
* to provide enhanced error messages with environment variable context.
|
|
131
|
+
*
|
|
132
|
+
* @param name - The environment variable name
|
|
133
|
+
* @returns A proxied Zod object with wrapped schema creators
|
|
134
|
+
*/
|
|
85
135
|
getZodGetter = (name) => {
|
|
86
136
|
return new Proxy({ ...z }, { get: (target, prop) => {
|
|
87
137
|
const value = target[prop];
|
|
@@ -101,10 +151,10 @@ var EnvironmentParser = class {
|
|
|
101
151
|
} });
|
|
102
152
|
};
|
|
103
153
|
/**
|
|
104
|
-
* Creates a new
|
|
154
|
+
* Creates a new ConfigParser object that can be used to parse the config object
|
|
105
155
|
*
|
|
106
156
|
* @param builder - A function that takes a getter function and returns a config object
|
|
107
|
-
* @returns A
|
|
157
|
+
* @returns A ConfigParser object that can be used to parse the config object
|
|
108
158
|
*/
|
|
109
159
|
create(builder) {
|
|
110
160
|
const config = builder(this.getZodGetter);
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
|
|
3
|
+
//#region src/EnvironmentParser.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Parses and validates configuration objects against Zod schemas.
|
|
7
|
+
* Handles nested configurations and aggregates validation errors.
|
|
8
|
+
*
|
|
9
|
+
* @template TResponse - The shape of the configuration object
|
|
10
|
+
*/
|
|
11
|
+
declare class ConfigParser<TResponse extends EmptyObject> {
|
|
12
|
+
private readonly config;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new ConfigParser instance.
|
|
15
|
+
*
|
|
16
|
+
* @param config - The configuration object to parse
|
|
17
|
+
*/
|
|
18
|
+
constructor(config: TResponse);
|
|
19
|
+
/**
|
|
20
|
+
* Parses the config object and validates it against the Zod schemas
|
|
21
|
+
* @returns The parsed config object
|
|
22
|
+
*/
|
|
23
|
+
parse(): InferConfig<TResponse>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Parses environment variables with type-safe validation using Zod schemas.
|
|
27
|
+
* Provides a fluent API for defining environment variable schemas with automatic
|
|
28
|
+
* error context enrichment.
|
|
29
|
+
*
|
|
30
|
+
* @template T - The type of the configuration object (typically process.env)
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const config = new EnvironmentParser(process.env)
|
|
35
|
+
* .create((get) => ({
|
|
36
|
+
* port: get('PORT').string().transform(Number).default(3000),
|
|
37
|
+
* database: {
|
|
38
|
+
* url: get('DATABASE_URL').string().url()
|
|
39
|
+
* }
|
|
40
|
+
* }))
|
|
41
|
+
* .parse();
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
declare class EnvironmentParser<T extends EmptyObject> {
|
|
45
|
+
private readonly config;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new EnvironmentParser instance.
|
|
48
|
+
*
|
|
49
|
+
* @param config - The configuration object to parse (typically process.env)
|
|
50
|
+
*/
|
|
51
|
+
constructor(config: T);
|
|
52
|
+
/**
|
|
53
|
+
* Wraps a Zod schema to intercept parse/safeParse calls and enrich error messages
|
|
54
|
+
* with environment variable context.
|
|
55
|
+
*
|
|
56
|
+
* @param schema - The Zod schema to wrap
|
|
57
|
+
* @param name - The environment variable name for error context
|
|
58
|
+
* @returns A wrapped Zod schema with enhanced error reporting
|
|
59
|
+
*/
|
|
60
|
+
private wrapSchema;
|
|
61
|
+
/**
|
|
62
|
+
* Creates a proxied version of the Zod object that wraps all schema creators
|
|
63
|
+
* to provide enhanced error messages with environment variable context.
|
|
64
|
+
*
|
|
65
|
+
* @param name - The environment variable name
|
|
66
|
+
* @returns A proxied Zod object with wrapped schema creators
|
|
67
|
+
*/
|
|
68
|
+
private getZodGetter;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new ConfigParser object that can be used to parse the config object
|
|
71
|
+
*
|
|
72
|
+
* @param builder - A function that takes a getter function and returns a config object
|
|
73
|
+
* @returns A ConfigParser object that can be used to parse the config object
|
|
74
|
+
*/
|
|
75
|
+
create<TReturn extends EmptyObject>(builder: (get: EnvFetcher) => TReturn): ConfigParser<TReturn>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Infers the TypeScript type of a configuration object based on its Zod schemas.
|
|
79
|
+
* Recursively processes nested objects and extracts types from Zod schemas.
|
|
80
|
+
*
|
|
81
|
+
* @template T - The configuration object type
|
|
82
|
+
*/
|
|
83
|
+
type InferConfig<T extends EmptyObject> = { [K in keyof T]: T[K] extends z.ZodSchema ? z.infer<T[K]> : T[K] extends Record<string, unknown> ? InferConfig<T[K]> : T[K] };
|
|
84
|
+
/**
|
|
85
|
+
* Function type for fetching environment variables with Zod validation.
|
|
86
|
+
* Returns a Zod object scoped to a specific environment variable.
|
|
87
|
+
*
|
|
88
|
+
* @template TPath - The environment variable path type
|
|
89
|
+
* @param name - The environment variable name
|
|
90
|
+
* @returns A Zod object for defining the schema
|
|
91
|
+
*/
|
|
92
|
+
type EnvFetcher<TPath extends string = string> = (name: TPath) => typeof z;
|
|
93
|
+
/**
|
|
94
|
+
* Function type for building environment configuration objects.
|
|
95
|
+
* Takes an EnvFetcher and returns a configuration object with Zod schemas.
|
|
96
|
+
*
|
|
97
|
+
* @template TResponse - The response configuration object type
|
|
98
|
+
* @param get - The environment variable fetcher function
|
|
99
|
+
* @returns The configuration object with Zod schemas
|
|
100
|
+
*/
|
|
101
|
+
type EnvironmentBuilder<TResponse extends EmptyObject> = (get: EnvFetcher) => TResponse;
|
|
102
|
+
/**
|
|
103
|
+
* Type alias for a generic object with unknown values.
|
|
104
|
+
* Used as a constraint for configuration objects.
|
|
105
|
+
*/
|
|
106
|
+
type EmptyObject = Record<string | number | symbol, unknown>;
|
|
107
|
+
//#endregion
|
|
108
|
+
export { ConfigParser, EmptyObject, EnvFetcher, EnvironmentBuilder, EnvironmentParser, InferConfig };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_EnvironmentParser = require('./EnvironmentParser-
|
|
1
|
+
const require_EnvironmentParser = require('./EnvironmentParser-BDPDLv6i.cjs');
|
|
2
2
|
|
|
3
3
|
exports.ConfigParser = require_EnvironmentParser.ConfigParser;
|
|
4
4
|
exports.EnvironmentParser = require_EnvironmentParser.EnvironmentParser;
|