@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
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const zod_v4 =
|
|
1
|
+
const require_chunk = require('../chunk-CUT6urMc.cjs');
|
|
2
|
+
const require_EnvironmentParser = require('../EnvironmentParser-BDPDLv6i.cjs');
|
|
3
|
+
const zod_v4 = require_chunk.__toESM(require("zod/v4"));
|
|
4
|
+
const vitest = require_chunk.__toESM(require("vitest"));
|
|
4
5
|
|
|
5
6
|
//#region src/__tests__/EnvironmentParser.spec.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
(0, vitest.describe)("EnvironmentParser", () => {
|
|
8
|
+
(0, vitest.describe)("Basic parsing functionality", () => {
|
|
9
|
+
(0, vitest.it)("should parse simple string values", () => {
|
|
9
10
|
const env = { APP_NAME: "Test App" };
|
|
10
11
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
11
12
|
const config = parser.create((get) => ({ appName: get("APP_NAME").string() })).parse();
|
|
12
|
-
|
|
13
|
+
(0, vitest.expect)(config).toEqual({ appName: "Test App" });
|
|
13
14
|
});
|
|
14
|
-
|
|
15
|
+
(0, vitest.it)("should parse with default values when env var is missing", () => {
|
|
15
16
|
const env = {};
|
|
16
17
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
17
18
|
const config = parser.create((get) => ({
|
|
18
19
|
appName: get("APP_NAME").string().default("Default App"),
|
|
19
20
|
port: get("PORT").string().transform(Number).default(3e3)
|
|
20
21
|
})).parse();
|
|
21
|
-
|
|
22
|
+
(0, vitest.expect)(config).toEqual({
|
|
22
23
|
appName: "Default App",
|
|
23
24
|
port: 3e3
|
|
24
25
|
});
|
|
25
26
|
});
|
|
26
|
-
|
|
27
|
+
(0, vitest.it)("should transform string to number", () => {
|
|
27
28
|
const env = { PORT: "8080" };
|
|
28
29
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
29
30
|
const config = parser.create((get) => ({ port: get("PORT").string().transform(Number) })).parse();
|
|
30
|
-
|
|
31
|
+
(0, vitest.expect)(config).toEqual({ port: 8080 });
|
|
31
32
|
});
|
|
32
|
-
|
|
33
|
+
(0, vitest.it)("should transform string to boolean", () => {
|
|
33
34
|
const env = {
|
|
34
35
|
FEATURE_ENABLED: "true",
|
|
35
36
|
FEATURE_DISABLED: "false",
|
|
@@ -41,25 +42,25 @@ require_vi_bdSIJ99Y.describe("EnvironmentParser", () => {
|
|
|
41
42
|
disabled: get("FEATURE_DISABLED").string().transform((v) => v === "true"),
|
|
42
43
|
truthy: get("FEATURE_TRUTHY").string().transform((v) => v === "true")
|
|
43
44
|
})).parse();
|
|
44
|
-
|
|
45
|
+
(0, vitest.expect)(config).toEqual({
|
|
45
46
|
enabled: true,
|
|
46
47
|
disabled: false,
|
|
47
48
|
truthy: false
|
|
48
49
|
});
|
|
49
50
|
});
|
|
50
|
-
|
|
51
|
+
(0, vitest.it)("should handle optional values", () => {
|
|
51
52
|
const env = { REQUIRED: "value" };
|
|
52
53
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
53
54
|
const config = parser.create((get) => ({
|
|
54
55
|
required: get("REQUIRED").string(),
|
|
55
56
|
optional: get("OPTIONAL").string().optional()
|
|
56
57
|
})).parse();
|
|
57
|
-
|
|
58
|
+
(0, vitest.expect)(config).toEqual({
|
|
58
59
|
required: "value",
|
|
59
60
|
optional: void 0
|
|
60
61
|
});
|
|
61
62
|
});
|
|
62
|
-
|
|
63
|
+
(0, vitest.it)("should validate URLs", () => {
|
|
63
64
|
const env = {
|
|
64
65
|
VALID_URL: "https://example.com",
|
|
65
66
|
DATABASE_URL: "postgresql://user:pass@localhost:5432/db"
|
|
@@ -69,18 +70,18 @@ require_vi_bdSIJ99Y.describe("EnvironmentParser", () => {
|
|
|
69
70
|
apiUrl: get("VALID_URL").string().url(),
|
|
70
71
|
dbUrl: get("DATABASE_URL").string().url()
|
|
71
72
|
})).parse();
|
|
72
|
-
|
|
73
|
+
(0, vitest.expect)(config).toEqual({
|
|
73
74
|
apiUrl: "https://example.com",
|
|
74
75
|
dbUrl: "postgresql://user:pass@localhost:5432/db"
|
|
75
76
|
});
|
|
76
77
|
});
|
|
77
|
-
|
|
78
|
+
(0, vitest.it)("should validate email addresses", () => {
|
|
78
79
|
const env = { ADMIN_EMAIL: "admin@example.com" };
|
|
79
80
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
80
81
|
const config = parser.create((get) => ({ adminEmail: get("ADMIN_EMAIL").string().email() })).parse();
|
|
81
|
-
|
|
82
|
+
(0, vitest.expect)(config).toEqual({ adminEmail: "admin@example.com" });
|
|
82
83
|
});
|
|
83
|
-
|
|
84
|
+
(0, vitest.it)("should validate enums", () => {
|
|
84
85
|
const env = { NODE_ENV: "production" };
|
|
85
86
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
86
87
|
const config = parser.create((get) => ({ env: get("NODE_ENV").enum([
|
|
@@ -88,11 +89,11 @@ require_vi_bdSIJ99Y.describe("EnvironmentParser", () => {
|
|
|
88
89
|
"staging",
|
|
89
90
|
"production"
|
|
90
91
|
]) })).parse();
|
|
91
|
-
|
|
92
|
+
(0, vitest.expect)(config).toEqual({ env: "production" });
|
|
92
93
|
});
|
|
93
94
|
});
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
(0, vitest.describe)("Nested configuration", () => {
|
|
96
|
+
(0, vitest.it)("should handle nested objects", () => {
|
|
96
97
|
const env = {
|
|
97
98
|
DB_HOST: "localhost",
|
|
98
99
|
DB_PORT: "5432",
|
|
@@ -112,7 +113,7 @@ require_vi_bdSIJ99Y.describe("EnvironmentParser", () => {
|
|
|
112
113
|
url: get("API_URL").string().url()
|
|
113
114
|
}
|
|
114
115
|
})).parse();
|
|
115
|
-
|
|
116
|
+
(0, vitest.expect)(config).toEqual({
|
|
116
117
|
database: {
|
|
117
118
|
host: "localhost",
|
|
118
119
|
port: 5432,
|
|
@@ -124,7 +125,7 @@ require_vi_bdSIJ99Y.describe("EnvironmentParser", () => {
|
|
|
124
125
|
}
|
|
125
126
|
});
|
|
126
127
|
});
|
|
127
|
-
|
|
128
|
+
(0, vitest.it)("should handle deeply nested objects", () => {
|
|
128
129
|
const env = {
|
|
129
130
|
FEATURE_AUTH_ENABLED: "true",
|
|
130
131
|
FEATURE_AUTH_PROVIDER: "oauth",
|
|
@@ -142,7 +143,7 @@ require_vi_bdSIJ99Y.describe("EnvironmentParser", () => {
|
|
|
142
143
|
ttl: get("FEATURE_CACHE_TTL").string().transform(Number)
|
|
143
144
|
}
|
|
144
145
|
} })).parse();
|
|
145
|
-
|
|
146
|
+
(0, vitest.expect)(config).toEqual({ features: {
|
|
146
147
|
authentication: {
|
|
147
148
|
enabled: true,
|
|
148
149
|
provider: "oauth"
|
|
@@ -153,7 +154,7 @@ require_vi_bdSIJ99Y.describe("EnvironmentParser", () => {
|
|
|
153
154
|
}
|
|
154
155
|
} });
|
|
155
156
|
});
|
|
156
|
-
|
|
157
|
+
(0, vitest.it)("should handle mixed nested objects with defaults", () => {
|
|
157
158
|
const env = {
|
|
158
159
|
DB_HOST: "custom-host",
|
|
159
160
|
REDIS_TTL: "7200"
|
|
@@ -171,7 +172,7 @@ require_vi_bdSIJ99Y.describe("EnvironmentParser", () => {
|
|
|
171
172
|
ttl: get("REDIS_TTL").string().transform(Number)
|
|
172
173
|
} }
|
|
173
174
|
})).parse();
|
|
174
|
-
|
|
175
|
+
(0, vitest.expect)(config).toEqual({
|
|
175
176
|
database: {
|
|
176
177
|
host: "custom-host",
|
|
177
178
|
port: 5432,
|
|
@@ -185,15 +186,15 @@ require_vi_bdSIJ99Y.describe("EnvironmentParser", () => {
|
|
|
185
186
|
});
|
|
186
187
|
});
|
|
187
188
|
});
|
|
188
|
-
|
|
189
|
-
|
|
189
|
+
(0, vitest.describe)("Error handling and validation", () => {
|
|
190
|
+
(0, vitest.it)("should throw ZodError for missing required values", () => {
|
|
190
191
|
const env = {};
|
|
191
192
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
192
|
-
|
|
193
|
+
(0, vitest.expect)(() => {
|
|
193
194
|
parser.create((get) => ({ required: get("REQUIRED_VAR").string() })).parse();
|
|
194
195
|
}).toThrow(zod_v4.z.ZodError);
|
|
195
196
|
});
|
|
196
|
-
|
|
197
|
+
(0, vitest.it)("should throw ZodError with descriptive error messages", () => {
|
|
197
198
|
const env = {};
|
|
198
199
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
199
200
|
try {
|
|
@@ -202,57 +203,57 @@ require_vi_bdSIJ99Y.describe("EnvironmentParser", () => {
|
|
|
202
203
|
dbUrl: get("DATABASE_URL").string().url()
|
|
203
204
|
})).parse();
|
|
204
205
|
} catch (error) {
|
|
205
|
-
|
|
206
|
+
(0, vitest.expect)(error).toBeInstanceOf(zod_v4.z.ZodError);
|
|
206
207
|
const zodError = error;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
(0, vitest.expect)(zodError.issues).toHaveLength(2);
|
|
209
|
+
(0, vitest.expect)(zodError.issues[0].message).toContain("Environment variable \"API_KEY\"");
|
|
210
|
+
(0, vitest.expect)(zodError.issues[1].message).toContain("Environment variable \"DATABASE_URL\"");
|
|
210
211
|
}
|
|
211
212
|
});
|
|
212
|
-
|
|
213
|
+
(0, vitest.it)("should validate minimum string length", () => {
|
|
213
214
|
const env = { API_KEY: "short" };
|
|
214
215
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
215
|
-
|
|
216
|
+
(0, vitest.expect)(() => {
|
|
216
217
|
parser.create((get) => ({ apiKey: get("API_KEY").string().min(32) })).parse();
|
|
217
218
|
}).toThrow(zod_v4.z.ZodError);
|
|
218
219
|
});
|
|
219
|
-
|
|
220
|
+
(0, vitest.it)("should validate maximum string length", () => {
|
|
220
221
|
const env = { SHORT_TEXT: "a".repeat(100) };
|
|
221
222
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
222
|
-
|
|
223
|
+
(0, vitest.expect)(() => {
|
|
223
224
|
parser.create((get) => ({ shortText: get("SHORT_TEXT").string().max(50) })).parse();
|
|
224
225
|
}).toThrow(zod_v4.z.ZodError);
|
|
225
226
|
});
|
|
226
|
-
|
|
227
|
+
(0, vitest.it)("should validate exact string length", () => {
|
|
227
228
|
const env = {
|
|
228
229
|
VALID_KEY: "a".repeat(32),
|
|
229
230
|
INVALID_KEY: "short"
|
|
230
231
|
};
|
|
231
232
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
232
233
|
const validConfig = parser.create((get) => ({ key: get("VALID_KEY").string().length(32) })).parse();
|
|
233
|
-
|
|
234
|
-
|
|
234
|
+
(0, vitest.expect)(validConfig).toEqual({ key: "a".repeat(32) });
|
|
235
|
+
(0, vitest.expect)(() => {
|
|
235
236
|
parser.create((get) => ({ key: get("INVALID_KEY").string().length(32) })).parse();
|
|
236
237
|
}).toThrow(zod_v4.z.ZodError);
|
|
237
238
|
});
|
|
238
|
-
|
|
239
|
+
(0, vitest.it)("should validate invalid URLs", () => {
|
|
239
240
|
const env = { INVALID_URL: "not-a-url" };
|
|
240
241
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
241
|
-
|
|
242
|
+
(0, vitest.expect)(() => {
|
|
242
243
|
parser.create((get) => ({ url: get("INVALID_URL").string().url() })).parse();
|
|
243
244
|
}).toThrow(zod_v4.z.ZodError);
|
|
244
245
|
});
|
|
245
|
-
|
|
246
|
+
(0, vitest.it)("should validate invalid email addresses", () => {
|
|
246
247
|
const env = { INVALID_EMAIL: "not-an-email" };
|
|
247
248
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
248
|
-
|
|
249
|
+
(0, vitest.expect)(() => {
|
|
249
250
|
parser.create((get) => ({ email: get("INVALID_EMAIL").string().email() })).parse();
|
|
250
251
|
}).toThrow(zod_v4.z.ZodError);
|
|
251
252
|
});
|
|
252
|
-
|
|
253
|
+
(0, vitest.it)("should validate invalid enum values", () => {
|
|
253
254
|
const env = { NODE_ENV: "invalid" };
|
|
254
255
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
255
|
-
|
|
256
|
+
(0, vitest.expect)(() => {
|
|
256
257
|
parser.create((get) => ({ env: get("NODE_ENV").enum([
|
|
257
258
|
"development",
|
|
258
259
|
"staging",
|
|
@@ -260,7 +261,7 @@ require_vi_bdSIJ99Y.describe("EnvironmentParser", () => {
|
|
|
260
261
|
]) })).parse();
|
|
261
262
|
}).toThrow(zod_v4.z.ZodError);
|
|
262
263
|
});
|
|
263
|
-
|
|
264
|
+
(0, vitest.it)("should validate number ranges", () => {
|
|
264
265
|
const env = {
|
|
265
266
|
VALID_PORT: "8080",
|
|
266
267
|
INVALID_PORT_LOW: "0",
|
|
@@ -268,18 +269,18 @@ require_vi_bdSIJ99Y.describe("EnvironmentParser", () => {
|
|
|
268
269
|
};
|
|
269
270
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
270
271
|
const validConfig = parser.create((get) => ({ port: get("VALID_PORT").coerce.number().min(1).max(65535) })).parse();
|
|
271
|
-
|
|
272
|
-
|
|
272
|
+
(0, vitest.expect)(validConfig).toEqual({ port: 8080 });
|
|
273
|
+
(0, vitest.expect)(() => {
|
|
273
274
|
parser.create((get) => ({ port: get("INVALID_PORT_LOW").coerce.number().min(1).max(65535) })).parse();
|
|
274
275
|
}).toThrow(zod_v4.z.ZodError);
|
|
275
|
-
|
|
276
|
+
(0, vitest.expect)(() => {
|
|
276
277
|
parser.create((get) => ({ port: get("INVALID_PORT_HIGH").coerce.number().min(1).max(65535) })).parse();
|
|
277
278
|
}).toThrow(zod_v4.z.ZodError);
|
|
278
279
|
});
|
|
279
|
-
|
|
280
|
+
(0, vitest.it)("should handle transformation errors", () => {
|
|
280
281
|
const env = { INVALID_NUMBER: "not-a-number" };
|
|
281
282
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
282
|
-
|
|
283
|
+
(0, vitest.expect)(() => {
|
|
283
284
|
parser.create((get) => ({ number: get("INVALID_NUMBER").string().transform((v) => {
|
|
284
285
|
const num = Number(v);
|
|
285
286
|
if (isNaN(num)) throw new Error("Invalid number");
|
|
@@ -288,8 +289,8 @@ require_vi_bdSIJ99Y.describe("EnvironmentParser", () => {
|
|
|
288
289
|
}).toThrow();
|
|
289
290
|
});
|
|
290
291
|
});
|
|
291
|
-
|
|
292
|
-
|
|
292
|
+
(0, vitest.describe)("Complex scenarios", () => {
|
|
293
|
+
(0, vitest.it)("should handle array transformations", () => {
|
|
293
294
|
const env = {
|
|
294
295
|
ALLOWED_ORIGINS: "http://localhost:3000,https://example.com,https://app.example.com",
|
|
295
296
|
FEATURE_FLAGS: "auth,cache,notifications"
|
|
@@ -299,7 +300,7 @@ require_vi_bdSIJ99Y.describe("EnvironmentParser", () => {
|
|
|
299
300
|
cors: { origins: get("ALLOWED_ORIGINS").string().transform((origins) => origins.split(",").map((o) => o.trim())) },
|
|
300
301
|
features: get("FEATURE_FLAGS").string().transform((flags) => flags.split(",").map((f) => f.trim()))
|
|
301
302
|
})).parse();
|
|
302
|
-
|
|
303
|
+
(0, vitest.expect)(config).toEqual({
|
|
303
304
|
cors: { origins: [
|
|
304
305
|
"http://localhost:3000",
|
|
305
306
|
"https://example.com",
|
|
@@ -312,7 +313,7 @@ require_vi_bdSIJ99Y.describe("EnvironmentParser", () => {
|
|
|
312
313
|
]
|
|
313
314
|
});
|
|
314
315
|
});
|
|
315
|
-
|
|
316
|
+
(0, vitest.it)("should handle JSON parsing", () => {
|
|
316
317
|
const env = {
|
|
317
318
|
FEATURE_CONFIG: "{\"auth\":true,\"cache\":false,\"debug\":true}",
|
|
318
319
|
RATE_LIMITS: "{\"requests\":100,\"window\":60000}"
|
|
@@ -325,7 +326,7 @@ require_vi_bdSIJ99Y.describe("EnvironmentParser", () => {
|
|
|
325
326
|
window: zod_v4.z.number()
|
|
326
327
|
}))
|
|
327
328
|
})).parse();
|
|
328
|
-
|
|
329
|
+
(0, vitest.expect)(config).toEqual({
|
|
329
330
|
features: {
|
|
330
331
|
auth: true,
|
|
331
332
|
cache: false,
|
|
@@ -337,7 +338,7 @@ require_vi_bdSIJ99Y.describe("EnvironmentParser", () => {
|
|
|
337
338
|
}
|
|
338
339
|
});
|
|
339
340
|
});
|
|
340
|
-
|
|
341
|
+
(0, vitest.it)("should handle custom refinements", () => {
|
|
341
342
|
const env = {
|
|
342
343
|
CORS_ORIGINS: "https://example.com,https://app.example.com",
|
|
343
344
|
API_KEYS: "key1234567890123456789012345678901,key2345678901234567890123456789012"
|
|
@@ -347,48 +348,48 @@ require_vi_bdSIJ99Y.describe("EnvironmentParser", () => {
|
|
|
347
348
|
cors: { origins: get("CORS_ORIGINS").string().transform((origins) => origins.split(",").map((o) => o.trim())).refine((origins) => origins.every((o) => o.startsWith("https://")), { message: "All CORS origins must use HTTPS" }) },
|
|
348
349
|
apiKeys: get("API_KEYS").string().transform((keys) => keys.split(",").map((k) => k.trim())).pipe(zod_v4.z.array(zod_v4.z.string().min(32)))
|
|
349
350
|
})).parse();
|
|
350
|
-
|
|
351
|
+
(0, vitest.expect)(config).toEqual({
|
|
351
352
|
cors: { origins: ["https://example.com", "https://app.example.com"] },
|
|
352
353
|
apiKeys: ["key1234567890123456789012345678901", "key2345678901234567890123456789012"]
|
|
353
354
|
});
|
|
354
355
|
});
|
|
355
|
-
|
|
356
|
+
(0, vitest.it)("should fail refinements with descriptive errors", () => {
|
|
356
357
|
const env = { CORS_ORIGINS: "http://example.com,https://app.example.com" };
|
|
357
358
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
358
|
-
|
|
359
|
+
(0, vitest.expect)(() => {
|
|
359
360
|
parser.create((get) => ({ cors: { origins: get("CORS_ORIGINS").string().transform((origins) => origins.split(",").map((o) => o.trim())).refine((origins) => origins.every((o) => o.startsWith("https://")), { message: "All CORS origins must use HTTPS" }) } })).parse();
|
|
360
361
|
}).toThrow(zod_v4.z.ZodError);
|
|
361
362
|
});
|
|
362
363
|
});
|
|
363
|
-
|
|
364
|
-
|
|
364
|
+
(0, vitest.describe)("Type inference", () => {
|
|
365
|
+
(0, vitest.it)("should correctly infer string types", () => {
|
|
365
366
|
const env = { APP_NAME: "Test App" };
|
|
366
367
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
367
368
|
const config = parser.create((get) => ({ appName: get("APP_NAME").string() })).parse();
|
|
368
369
|
const _typeCheck = true;
|
|
369
370
|
const _typeCheck2 = true;
|
|
370
|
-
|
|
371
|
-
|
|
371
|
+
(0, vitest.expect)(_typeCheck).toBe(true);
|
|
372
|
+
(0, vitest.expect)(_typeCheck2).toBe(true);
|
|
372
373
|
});
|
|
373
|
-
|
|
374
|
+
(0, vitest.it)("should correctly infer number types after transformation", () => {
|
|
374
375
|
const env = { PORT: "3000" };
|
|
375
376
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
376
377
|
const config = parser.create((get) => ({ port: get("PORT").string().transform(Number) })).parse();
|
|
377
378
|
const _typeCheck = true;
|
|
378
379
|
const _typeCheck2 = true;
|
|
379
|
-
|
|
380
|
-
|
|
380
|
+
(0, vitest.expect)(_typeCheck).toBe(true);
|
|
381
|
+
(0, vitest.expect)(_typeCheck2).toBe(true);
|
|
381
382
|
});
|
|
382
|
-
|
|
383
|
+
(0, vitest.it)("should correctly infer boolean types after transformation", () => {
|
|
383
384
|
const env = { FEATURE_ENABLED: "true" };
|
|
384
385
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
385
386
|
const config = parser.create((get) => ({ enabled: get("FEATURE_ENABLED").string().transform((v) => v === "true") })).parse();
|
|
386
387
|
const _typeCheck = true;
|
|
387
388
|
const _typeCheck2 = true;
|
|
388
|
-
|
|
389
|
-
|
|
389
|
+
(0, vitest.expect)(_typeCheck).toBe(true);
|
|
390
|
+
(0, vitest.expect)(_typeCheck2).toBe(true);
|
|
390
391
|
});
|
|
391
|
-
|
|
392
|
+
(0, vitest.it)("should correctly infer optional types", () => {
|
|
392
393
|
const env = { REQUIRED: "value" };
|
|
393
394
|
const parser = new require_EnvironmentParser.EnvironmentParser(env);
|
|
394
395
|
const config = parser.create((get) => ({
|
|
@@ -396,7 +397,7 @@ require_vi_bdSIJ99Y.describe("EnvironmentParser", () => {
|
|
|
396
397
|
optional: get("OPTIONAL").string().optional()
|
|
397
398
|
})).parse();
|
|
398
399
|
});
|
|
399
|
-
|
|
400
|
+
(0, vitest.it)("should correctly infer nested object types", () => {
|
|
400
401
|
const env = {
|
|
401
402
|
DB_HOST: "localhost",
|
|
402
403
|
DB_PORT: "5432",
|
|
@@ -412,8 +413,8 @@ require_vi_bdSIJ99Y.describe("EnvironmentParser", () => {
|
|
|
412
413
|
})).parse();
|
|
413
414
|
const _typeCheck = true;
|
|
414
415
|
const _typeCheck2 = true;
|
|
415
|
-
|
|
416
|
-
|
|
416
|
+
(0, vitest.expect)(_typeCheck).toBe(true);
|
|
417
|
+
(0, vitest.expect)(_typeCheck2).toBe(true);
|
|
417
418
|
});
|
|
418
419
|
});
|
|
419
420
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|