@geekmidas/envkit 1.0.4 → 1.0.6
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/CHANGELOG.md +12 -0
- package/dist/{EnvironmentBuilder-BSuHZm0y.mjs → EnvironmentBuilder-CFen3oIg.mjs} +1 -1
- package/dist/{EnvironmentBuilder-BSuHZm0y.mjs.map → EnvironmentBuilder-CFen3oIg.mjs.map} +1 -1
- package/dist/{EnvironmentBuilder-Xuf2Dd9u.d.cts → EnvironmentBuilder-CNgcdzSR.d.cts} +1 -1
- package/dist/{EnvironmentBuilder-Xuf2Dd9u.d.cts.map → EnvironmentBuilder-CNgcdzSR.d.cts.map} +1 -1
- package/dist/{EnvironmentBuilder-Djr1VsWM.cjs → EnvironmentBuilder-DDgLJAAo.cjs} +1 -1
- package/dist/{EnvironmentBuilder-Djr1VsWM.cjs.map → EnvironmentBuilder-DDgLJAAo.cjs.map} +1 -1
- package/dist/{EnvironmentBuilder-jF-b7WQg.d.mts → EnvironmentBuilder-DHfDXJUm.d.mts} +1 -1
- package/dist/{EnvironmentBuilder-jF-b7WQg.d.mts.map → EnvironmentBuilder-DHfDXJUm.d.mts.map} +1 -1
- package/dist/{EnvironmentParser-DtOL86NU.d.cts → EnvironmentParser-BY1oCUsc.d.mts} +3 -3
- package/dist/EnvironmentParser-BY1oCUsc.d.mts.map +1 -0
- package/dist/{EnvironmentParser-DJdW7vOL.cjs → EnvironmentParser-Bzg5yXG2.cjs} +124 -4
- package/dist/EnvironmentParser-Bzg5yXG2.cjs.map +1 -0
- package/dist/{EnvironmentParser-CkLfmn4Y.d.mts → EnvironmentParser-DoooZm8n.d.cts} +3 -3
- package/dist/EnvironmentParser-DoooZm8n.d.cts.map +1 -0
- package/dist/{EnvironmentParser-zMblItla.mjs → EnvironmentParser-taAKfzT7.mjs} +112 -4
- package/dist/EnvironmentParser-taAKfzT7.mjs.map +1 -0
- package/dist/SnifferEnvironmentParser.cjs +19 -4
- package/dist/SnifferEnvironmentParser.cjs.map +1 -1
- package/dist/SnifferEnvironmentParser.d.cts +20 -3
- package/dist/SnifferEnvironmentParser.d.cts.map +1 -1
- package/dist/SnifferEnvironmentParser.d.mts +20 -3
- package/dist/SnifferEnvironmentParser.d.mts.map +1 -1
- package/dist/SnifferEnvironmentParser.mjs +19 -4
- package/dist/SnifferEnvironmentParser.mjs.map +1 -1
- package/dist/index.cjs +4 -5
- package/dist/index.d.cts +52 -4
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +52 -4
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -3
- package/dist/sst.cjs +115 -6
- package/dist/sst.cjs.map +1 -1
- package/dist/sst.d.cts +184 -3
- package/dist/sst.d.cts.map +1 -1
- package/dist/sst.d.mts +184 -3
- package/dist/sst.d.mts.map +1 -1
- package/dist/sst.mjs +111 -2
- package/dist/sst.mjs.map +1 -1
- package/package.json +4 -3
- package/src/SnifferEnvironmentParser.ts +31 -3
- package/src/SstEnvironmentBuilder.ts +1 -0
- package/src/__tests__/SnifferEnvironmentParser.spec.ts +158 -0
- package/src/__tests__/SstEnvironmentBuilder.spec.ts +5 -0
- package/src/__tests__/sst.spec.ts +6 -0
- package/tsdown.config.ts +16 -1
- package/dist/EnvironmentBuilder.cjs +0 -4
- package/dist/EnvironmentBuilder.d.cts +0 -2
- package/dist/EnvironmentBuilder.d.mts +0 -2
- package/dist/EnvironmentBuilder.mjs +0 -3
- package/dist/EnvironmentParser-CkLfmn4Y.d.mts.map +0 -1
- package/dist/EnvironmentParser-DJdW7vOL.cjs.map +0 -1
- package/dist/EnvironmentParser-DtOL86NU.d.cts.map +0 -1
- package/dist/EnvironmentParser-zMblItla.mjs.map +0 -1
- package/dist/EnvironmentParser.cjs +0 -5
- package/dist/EnvironmentParser.d.cts +0 -2
- package/dist/EnvironmentParser.d.mts +0 -2
- package/dist/EnvironmentParser.mjs +0 -4
- package/dist/SstEnvironmentBuilder-BRAcRQp2.d.mts +0 -186
- package/dist/SstEnvironmentBuilder-BRAcRQp2.d.mts.map +0 -1
- package/dist/SstEnvironmentBuilder-D-NGrp7U.cjs +0 -130
- package/dist/SstEnvironmentBuilder-D-NGrp7U.cjs.map +0 -1
- package/dist/SstEnvironmentBuilder-DOu4dVPL.mjs +0 -113
- package/dist/SstEnvironmentBuilder-DOu4dVPL.mjs.map +0 -1
- package/dist/SstEnvironmentBuilder-Dc9nOuuK.d.cts +0 -186
- package/dist/SstEnvironmentBuilder-Dc9nOuuK.d.cts.map +0 -1
- package/dist/SstEnvironmentBuilder.cjs +0 -7
- package/dist/SstEnvironmentBuilder.d.cts +0 -3
- package/dist/SstEnvironmentBuilder.d.mts +0 -3
- package/dist/SstEnvironmentBuilder.mjs +0 -4
- package/dist/formatter-BRRrxQi3.mjs +0 -111
- package/dist/formatter-BRRrxQi3.mjs.map +0 -1
- package/dist/formatter-Cox0NGxT.d.mts +0 -51
- package/dist/formatter-Cox0NGxT.d.mts.map +0 -1
- package/dist/formatter-D85aIkpd.d.cts +0 -51
- package/dist/formatter-D85aIkpd.d.cts.map +0 -1
- package/dist/formatter-HxePpSy2.cjs +0 -123
- package/dist/formatter-HxePpSy2.cjs.map +0 -1
- package/dist/formatter.cjs +0 -4
- package/dist/formatter.d.cts +0 -2
- package/dist/formatter.d.mts +0 -2
- package/dist/formatter.mjs +0 -3
|
@@ -343,6 +343,135 @@ describe('SnifferEnvironmentParser', () => {
|
|
|
343
343
|
});
|
|
344
344
|
});
|
|
345
345
|
|
|
346
|
+
describe('Optional variable tracking', () => {
|
|
347
|
+
it('should track variables accessed with .optional() as optional', () => {
|
|
348
|
+
const sniffer = new SnifferEnvironmentParser();
|
|
349
|
+
|
|
350
|
+
sniffer.create((get) => ({
|
|
351
|
+
required: get('REQUIRED_VAR').string(),
|
|
352
|
+
optional: get('OPTIONAL_VAR').string().optional(),
|
|
353
|
+
}));
|
|
354
|
+
|
|
355
|
+
expect(sniffer.getOptionalVariables()).toEqual(['OPTIONAL_VAR']);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
it('should track variables accessed with .default() as optional', () => {
|
|
359
|
+
const sniffer = new SnifferEnvironmentParser();
|
|
360
|
+
|
|
361
|
+
sniffer.create((get) => ({
|
|
362
|
+
required: get('REQUIRED_VAR').string(),
|
|
363
|
+
withDefault: get('DEFAULT_VAR').string().default('fallback'),
|
|
364
|
+
}));
|
|
365
|
+
|
|
366
|
+
expect(sniffer.getOptionalVariables()).toEqual(['DEFAULT_VAR']);
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it('should track variables with .default() after .transform() as optional', () => {
|
|
370
|
+
const sniffer = new SnifferEnvironmentParser();
|
|
371
|
+
|
|
372
|
+
sniffer.create((get) => ({
|
|
373
|
+
port: get('PORT').string().transform(Number).default(3000),
|
|
374
|
+
}));
|
|
375
|
+
|
|
376
|
+
expect(sniffer.getOptionalVariables()).toEqual(['PORT']);
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
it('should not include required variables in getOptionalVariables()', () => {
|
|
380
|
+
const sniffer = new SnifferEnvironmentParser();
|
|
381
|
+
|
|
382
|
+
sniffer.create((get) => ({
|
|
383
|
+
required: get('DATABASE_URL').string(),
|
|
384
|
+
optional: get('LOG_LEVEL').string().optional(),
|
|
385
|
+
}));
|
|
386
|
+
|
|
387
|
+
expect(sniffer.getOptionalVariables()).toEqual(['LOG_LEVEL']);
|
|
388
|
+
expect(sniffer.getOptionalVariables()).not.toContain('DATABASE_URL');
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
it('getEnvironmentVariables({ markOptional: true }) suffixes optional vars with ?', () => {
|
|
392
|
+
const sniffer = new SnifferEnvironmentParser();
|
|
393
|
+
|
|
394
|
+
sniffer.create((get) => ({
|
|
395
|
+
required: get('DATABASE_URL').string(),
|
|
396
|
+
apiKey: get('API_KEY').string(),
|
|
397
|
+
logLevel: get('LOG_LEVEL').string().optional(),
|
|
398
|
+
port: get('PORT').string().default('3000'),
|
|
399
|
+
}));
|
|
400
|
+
|
|
401
|
+
expect(sniffer.getEnvironmentVariables({ markOptional: true })).toEqual([
|
|
402
|
+
'API_KEY',
|
|
403
|
+
'DATABASE_URL',
|
|
404
|
+
'LOG_LEVEL?',
|
|
405
|
+
'PORT?',
|
|
406
|
+
]);
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
it('getEnvironmentVariables() without option returns plain names', () => {
|
|
410
|
+
const sniffer = new SnifferEnvironmentParser();
|
|
411
|
+
|
|
412
|
+
sniffer.create((get) => ({
|
|
413
|
+
required: get('DATABASE_URL').string(),
|
|
414
|
+
optional: get('PORT').string().default('3000'),
|
|
415
|
+
}));
|
|
416
|
+
|
|
417
|
+
expect(sniffer.getEnvironmentVariables()).toEqual([
|
|
418
|
+
'DATABASE_URL',
|
|
419
|
+
'PORT',
|
|
420
|
+
]);
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
it('getEnvironmentVariables({ markOptional: false }) returns plain names', () => {
|
|
424
|
+
const sniffer = new SnifferEnvironmentParser();
|
|
425
|
+
|
|
426
|
+
sniffer.create((get) => ({
|
|
427
|
+
required: get('DATABASE_URL').string(),
|
|
428
|
+
optional: get('PORT').string().default('3000'),
|
|
429
|
+
}));
|
|
430
|
+
|
|
431
|
+
expect(sniffer.getEnvironmentVariables({ markOptional: false })).toEqual([
|
|
432
|
+
'DATABASE_URL',
|
|
433
|
+
'PORT',
|
|
434
|
+
]);
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
it('should return empty getOptionalVariables() when all vars are required', () => {
|
|
438
|
+
const sniffer = new SnifferEnvironmentParser();
|
|
439
|
+
|
|
440
|
+
sniffer.create((get) => ({
|
|
441
|
+
url: get('DATABASE_URL').string(),
|
|
442
|
+
key: get('API_KEY').string(),
|
|
443
|
+
}));
|
|
444
|
+
|
|
445
|
+
expect(sniffer.getOptionalVariables()).toEqual([]);
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
it('should handle mix of optional and default across nested config', () => {
|
|
449
|
+
const sniffer = new SnifferEnvironmentParser();
|
|
450
|
+
|
|
451
|
+
sniffer.create((get) => ({
|
|
452
|
+
database: {
|
|
453
|
+
url: get('DATABASE_URL').string(),
|
|
454
|
+
poolSize: get('DB_POOL_SIZE').string().transform(Number).default(10),
|
|
455
|
+
},
|
|
456
|
+
cache: {
|
|
457
|
+
url: get('REDIS_URL').string().optional(),
|
|
458
|
+
ttl: get('CACHE_TTL').string(),
|
|
459
|
+
},
|
|
460
|
+
}));
|
|
461
|
+
|
|
462
|
+
expect(sniffer.getOptionalVariables().sort()).toEqual([
|
|
463
|
+
'DB_POOL_SIZE',
|
|
464
|
+
'REDIS_URL',
|
|
465
|
+
]);
|
|
466
|
+
expect(sniffer.getEnvironmentVariables({ markOptional: true })).toEqual([
|
|
467
|
+
'CACHE_TTL',
|
|
468
|
+
'DATABASE_URL',
|
|
469
|
+
'DB_POOL_SIZE?',
|
|
470
|
+
'REDIS_URL?',
|
|
471
|
+
]);
|
|
472
|
+
});
|
|
473
|
+
});
|
|
474
|
+
|
|
346
475
|
describe('Edge cases', () => {
|
|
347
476
|
it('should return empty array when no variables accessed', () => {
|
|
348
477
|
const sniffer = new SnifferEnvironmentParser();
|
|
@@ -483,4 +612,33 @@ describe('sniffWithFireAndForget', () => {
|
|
|
483
612
|
expect(result.error).toBeUndefined();
|
|
484
613
|
expect(result.unhandledRejections).toEqual([]);
|
|
485
614
|
});
|
|
615
|
+
|
|
616
|
+
it('should include optionalEnvVars in result', async () => {
|
|
617
|
+
const sniffer = new SnifferEnvironmentParser();
|
|
618
|
+
|
|
619
|
+
const result = await sniffWithFireAndForget(sniffer, () => {
|
|
620
|
+
sniffer.create((get) => ({
|
|
621
|
+
required: get('DATABASE_URL').string(),
|
|
622
|
+
optional: get('PORT').string().default('3000'),
|
|
623
|
+
alsoOptional: get('LOG_LEVEL').string().optional(),
|
|
624
|
+
}));
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
expect(result.envVars).toEqual(['DATABASE_URL', 'LOG_LEVEL', 'PORT']);
|
|
628
|
+
expect(result.optionalEnvVars).toEqual(['LOG_LEVEL', 'PORT']);
|
|
629
|
+
expect(result.error).toBeUndefined();
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
it('should return empty optionalEnvVars when all vars are required', async () => {
|
|
633
|
+
const sniffer = new SnifferEnvironmentParser();
|
|
634
|
+
|
|
635
|
+
const result = await sniffWithFireAndForget(sniffer, () => {
|
|
636
|
+
sniffer.create((get) => ({
|
|
637
|
+
url: get('DATABASE_URL').string(),
|
|
638
|
+
key: get('API_KEY').string(),
|
|
639
|
+
}));
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
expect(result.optionalEnvVars).toEqual([]);
|
|
643
|
+
});
|
|
486
644
|
});
|
|
@@ -84,6 +84,7 @@ describe('SstEnvironmentBuilder', () => {
|
|
|
84
84
|
DATABASE_PASSWORD: 'password123',
|
|
85
85
|
DATABASE_PORT: 5432,
|
|
86
86
|
DATABASE_USERNAME: 'postgres',
|
|
87
|
+
DATABASE_URL: 'postgresql://postgres:password123@localhost:5432/myapp',
|
|
87
88
|
});
|
|
88
89
|
});
|
|
89
90
|
|
|
@@ -107,6 +108,8 @@ describe('SstEnvironmentBuilder', () => {
|
|
|
107
108
|
MAIN_DB_PASSWORD: 'prod-password',
|
|
108
109
|
MAIN_DB_PORT: 5433,
|
|
109
110
|
MAIN_DB_USERNAME: 'prod_user',
|
|
111
|
+
MAIN_DB_URL:
|
|
112
|
+
'postgresql://prod_user:prod-password@prod.example.com:5433/prod_db',
|
|
110
113
|
});
|
|
111
114
|
});
|
|
112
115
|
});
|
|
@@ -271,6 +274,8 @@ describe('SstEnvironmentBuilder', () => {
|
|
|
271
274
|
DATABASE_PASSWORD: 'db-pass',
|
|
272
275
|
DATABASE_PORT: 5432,
|
|
273
276
|
DATABASE_USERNAME: 'app_user',
|
|
277
|
+
DATABASE_URL:
|
|
278
|
+
'postgresql://app_user:db-pass@db.example.com:5432/app_db',
|
|
274
279
|
JWT_SECRET: 'jwt-secret',
|
|
275
280
|
UPLOADS_NAME: 'uploads-bucket',
|
|
276
281
|
EVENTS_ARN: 'arn:aws:sns:us-east-1:123456789:events',
|
|
@@ -140,6 +140,8 @@ describe('sst', () => {
|
|
|
140
140
|
DATABASE_PASSWORD: 'password123',
|
|
141
141
|
DATABASE_PORT: 5432,
|
|
142
142
|
DATABASE_USERNAME: 'postgres',
|
|
143
|
+
DATABASE_URL:
|
|
144
|
+
'postgresql://postgres:password123@localhost:5432/myapp',
|
|
143
145
|
});
|
|
144
146
|
});
|
|
145
147
|
|
|
@@ -162,6 +164,8 @@ describe('sst', () => {
|
|
|
162
164
|
MAIN_DB_HOST: 'prod.example.com',
|
|
163
165
|
MAIN_DB_PASSWORD: 'prod-password',
|
|
164
166
|
MAIN_DB_PORT: 5433,
|
|
167
|
+
MAIN_DB_URL:
|
|
168
|
+
'postgresql://prod_user:prod-password@prod.example.com:5433/prod_db',
|
|
165
169
|
MAIN_DB_USERNAME: 'prod_user',
|
|
166
170
|
});
|
|
167
171
|
});
|
|
@@ -296,6 +300,8 @@ describe('sst', () => {
|
|
|
296
300
|
DATABASE_HOST: 'db.example.com',
|
|
297
301
|
DATABASE_PASSWORD: 'db-pass',
|
|
298
302
|
DATABASE_PORT: 5432,
|
|
303
|
+
DATABASE_URL:
|
|
304
|
+
'postgresql://app_user:db-pass@db.example.com:5432/app_db',
|
|
299
305
|
DATABASE_USERNAME: 'app_user',
|
|
300
306
|
JWT_SECRET: 'jwt-secret',
|
|
301
307
|
UPLOADS_NAME: 'uploads-bucket',
|
package/tsdown.config.ts
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
1
|
import { defineConfig } from 'tsdown';
|
|
2
2
|
|
|
3
|
-
export default defineConfig({
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
entry: [
|
|
5
|
+
'src/index.ts',
|
|
6
|
+
'src/sst.ts',
|
|
7
|
+
'src/SnifferEnvironmentParser.ts',
|
|
8
|
+
'src/credentials.ts',
|
|
9
|
+
],
|
|
10
|
+
clean: true,
|
|
11
|
+
outDir: 'dist',
|
|
12
|
+
format: ['cjs', 'esm'],
|
|
13
|
+
sourcemap: true,
|
|
14
|
+
dts: true,
|
|
15
|
+
outExtensions: (ctx) => ({
|
|
16
|
+
js: ctx.format === 'es' ? '.mjs' : '.cjs',
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { EnvRecord, EnvValue, EnvironmentBuilder, EnvironmentBuilderOptions, EnvironmentResolver, InputValue, Resolvers, TypedInputValue, TypedResolvers, environmentCase } from "./EnvironmentBuilder-Xuf2Dd9u.cjs";
|
|
2
|
-
export { EnvRecord, EnvValue, EnvironmentBuilder, EnvironmentBuilderOptions, EnvironmentResolver, InputValue, Resolvers, TypedInputValue, TypedResolvers, environmentCase };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { EnvRecord, EnvValue, EnvironmentBuilder, EnvironmentBuilderOptions, EnvironmentResolver, InputValue, Resolvers, TypedInputValue, TypedResolvers, environmentCase } from "./EnvironmentBuilder-jF-b7WQg.mjs";
|
|
2
|
-
export { EnvRecord, EnvValue, EnvironmentBuilder, EnvironmentBuilderOptions, EnvironmentResolver, InputValue, Resolvers, TypedInputValue, TypedResolvers, environmentCase };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EnvironmentParser-CkLfmn4Y.d.mts","names":[],"sources":["../src/EnvironmentParser.ts"],"sourcesContent":[],"mappings":";;;;;;AAWA;;;;AAS4B,cATf,YASe,CAAA,kBATgB,WAShB,CAAA,CAAA;EAAG,iBAMT,MAAA;EAAS,iBAArB,OAAA;EAAW;AA2FrB;;;;;EAiJmC,WAClB,CAAA,MAAA,EApPU,SAoPV,EAAA,OAAA,CAAA,EAnPW,GAmPX,CAAA,MAAA,CAAA;EAAU;;;AACX;EA6BJ,KAAA,CAAA,CAAA,EA3QF,WA2Qa,CA3QD,SA2QC,CAAA;EAAA;;;;;;;;;;;;;;;;EAKjB,uBAAC,CAAA,CAAA,EAAA,MAAA,EAAA;AAAC;AAWR;;;;AAEa;AAUb;;;;;AAEc;AAMd;;;;;;;;cApNa,4BAA4B;;;;;;;;;;;sBAWH;;;;;;;;;;;;;;;;;;;;;;;;yBAsId,4BACP,eAAe,UAC5B,aAAa;;;;;;;;;;;;;;;;;;;;;;KA6BL,sBAAsB,6BACrB,IAAI,EAAE,WAAW,CAAA,CAAE,YAC5B,CAAA,CAAE,MAAM,EAAE,MACV,EAAE,WAAW,0BACZ,YAAY,EAAE,MACd,EAAE;;;;;;;;;KAWK,mDACL,iBACK;;;;;;;;;KAUA,qCAAqC,qBAC3C,eACD;;;;;KAMO,WAAA,GAAc"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EnvironmentParser-DJdW7vOL.cjs","names":["config: TResponse","envVars: Set<string>","errors: z.core.$ZodIssue[]","config: T","path: string[]","result: EmptyObject","z","schema: z.ZodType","name: string","issue: z.core.$ZodIssue","builder: (get: EnvFetcher) => TReturn"],"sources":["../src/EnvironmentParser.ts"],"sourcesContent":["import get from 'lodash.get';\nimport set from 'lodash.set';\nimport { z } from 'zod/v4';\nimport { formatParseError, isDevelopment } from './formatter.js';\n\n/**\n * Parses and validates configuration objects against Zod schemas.\n * Handles nested configurations and aggregates validation errors.\n *\n * @template TResponse - The shape of the configuration object\n */\nexport class ConfigParser<TResponse extends EmptyObject> {\n\t/**\n\t * Creates a new ConfigParser instance.\n\t *\n\t * @param config - The configuration object to parse\n\t * @param envVars - Set of environment variable names that were accessed\n\t */\n\tconstructor(\n\t\tprivate readonly config: TResponse,\n\t\tprivate readonly envVars: Set<string> = new Set(),\n\t) {}\n\t/**\n\t * Parses the config object and validates it against the Zod schemas\n\t * @returns The parsed config object\n\t */\n\tparse(): InferConfig<TResponse> {\n\t\tconst errors: z.core.$ZodIssue[] = [];\n\n\t\tconst parseDeep = <T>(config: T, path: string[] = []) => {\n\t\t\tconst result: EmptyObject = {};\n\n\t\t\tif (config && typeof config !== 'object') {\n\t\t\t\treturn config;\n\t\t\t}\n\n\t\t\tfor (const key in config) {\n\t\t\t\tconst schema = config[key];\n\t\t\t\tconst currentPath = [...path, key];\n\n\t\t\t\tif (schema instanceof z.ZodType) {\n\t\t\t\t\tconst parsed = schema.safeParse(undefined);\n\t\t\t\t\tif (parsed.success) {\n\t\t\t\t\t\tset(result, key, parsed.data);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If the schema is invalid, assign the error\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t...parsed.error.issues.map((issue) => ({\n\t\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\t\tpath: [...currentPath, ...(issue.path as string[])],\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else if (schema) {\n\t\t\t\t\tset(result, key, parseDeep(schema as EmptyObject, currentPath));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn result;\n\t\t};\n\n\t\tconst parsedConfig = parseDeep(\n\t\t\tthis.config,\n\t\t) as unknown as InferConfig<TResponse>;\n\n\t\tif (errors.length > 0) {\n\t\t\tconst zodError = new z.ZodError(errors);\n\t\t\t// In development, log a formatted error message before throwing\n\t\t\tif (isDevelopment()) {\n\t\t\t\tconsole.error(formatParseError(zodError));\n\t\t\t}\n\t\t\tthrow zodError;\n\t\t}\n\n\t\treturn parsedConfig;\n\t}\n\n\t/**\n\t * Returns an array of environment variable names that were accessed during config creation.\n\t * This is useful for deployment and configuration management to know which env vars are required.\n\t *\n\t * @returns Array of environment variable names, sorted alphabetically\n\t *\n\t * @example\n\t * ```typescript\n\t * const config = envParser.create((get) => ({\n\t * dbUrl: get('DATABASE_URL').string(),\n\t * port: get('PORT').number()\n\t * }));\n\t *\n\t * config.getEnvironmentVariables(); // ['DATABASE_URL', 'PORT']\n\t * ```\n\t */\n\tgetEnvironmentVariables(): string[] {\n\t\treturn Array.from(this.envVars).sort();\n\t}\n}\n\n/**\n * Parses environment variables with type-safe validation using Zod schemas.\n * Provides a fluent API for defining environment variable schemas with automatic\n * error context enrichment.\n *\n * @template T - The type of the configuration object (typically process.env)\n *\n * @example\n * ```typescript\n * const config = new EnvironmentParser(process.env)\n * .create((get) => ({\n * port: get('PORT').string().transform(Number).default(3000),\n * database: {\n * url: get('DATABASE_URL').string().url()\n * }\n * }))\n * .parse();\n * ```\n */\nexport class EnvironmentParser<T extends EmptyObject> {\n\t/**\n\t * Set to track which environment variable names have been accessed\n\t */\n\tprivate readonly accessedVars: Set<string> = new Set();\n\n\t/**\n\t * Creates a new EnvironmentParser instance.\n\t *\n\t * @param config - The configuration object to parse (typically process.env)\n\t */\n\tconstructor(private readonly config: T) {}\n\n\t/**\n\t * Wraps a Zod schema to intercept parse/safeParse calls and enrich error messages\n\t * with environment variable context.\n\t *\n\t * @param schema - The Zod schema to wrap\n\t * @param name - The environment variable name for error context\n\t * @returns A wrapped Zod schema with enhanced error reporting\n\t */\n\tprivate wrapSchema = (schema: z.ZodType, name: string): z.ZodType => {\n\t\t// Create a proxy that intercepts all method calls on the schema\n\t\treturn new Proxy(schema, {\n\t\t\tget: (target, prop) => {\n\t\t\t\tif (prop === 'parse') {\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tconst value = get(this.config, name);\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\treturn target.parse(value);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tif (error instanceof z.ZodError) {\n\t\t\t\t\t\t\t\t// Modify the error to include the environment variable name\n\t\t\t\t\t\t\t\tconst modifiedIssues = error.issues.map((issue) => ({\n\t\t\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\t\t\tmessage: `Environment variable \"${name}\": ${issue.message}`,\n\t\t\t\t\t\t\t\t\tpath: [name, ...issue.path],\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\tthrow new z.ZodError(modifiedIssues);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif (prop === 'safeParse') {\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tconst value = get(this.config, name);\n\t\t\t\t\t\tconst result = target.safeParse(value);\n\n\t\t\t\t\t\tif (!result.success) {\n\t\t\t\t\t\t\t// Modify the error to include the environment variable name\n\t\t\t\t\t\t\tconst modifiedIssues = result.error.issues.map(\n\t\t\t\t\t\t\t\t(issue: z.core.$ZodIssue) => ({\n\t\t\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\t\t\tmessage: `Environment variable \"${name}\": ${issue.message}`,\n\t\t\t\t\t\t\t\t\tpath: [name, ...issue.path],\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tsuccess: false as const,\n\t\t\t\t\t\t\t\terror: new z.ZodError(modifiedIssues),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// For any method that returns a new schema (like transform, optional, etc.),\n\t\t\t\t// wrap the result as well\n\t\t\t\tconst originalProp = target[prop as keyof typeof target];\n\t\t\t\tif (typeof originalProp === 'function') {\n\t\t\t\t\treturn (...args: any[]) => {\n\t\t\t\t\t\tconst result = originalProp.apply(target, args);\n\t\t\t\t\t\t// If the result is a ZodType, wrap it too\n\t\t\t\t\t\tif (result && typeof result === 'object' && 'parse' in result) {\n\t\t\t\t\t\t\treturn this.wrapSchema(result, name);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn originalProp;\n\t\t\t},\n\t\t});\n\t};\n\n\t/**\n\t * Creates a proxied version of the Zod object that wraps all schema creators\n\t * to provide enhanced error messages with environment variable context.\n\t *\n\t * @param name - The environment variable name\n\t * @returns A proxied Zod object with wrapped schema creators\n\t */\n\tprivate getZodGetter = (name: string) => {\n\t\t// Track that this environment variable was accessed\n\t\tthis.accessedVars.add(name);\n\n\t\t// Return an object that has all Zod schemas but with our wrapper\n\t\treturn new Proxy(\n\t\t\t{ ...z },\n\t\t\t{\n\t\t\t\tget: (target, prop) => {\n\t\t\t\t\t// deno-lint-ignore ban-ts-comment\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tconst value = target[prop];\n\n\t\t\t\t\tif (typeof value === 'function') {\n\t\t\t\t\t\t// Return a wrapper around each Zod schema creator\n\t\t\t\t\t\treturn (...args: any[]) => {\n\t\t\t\t\t\t\tconst schema = value(...args);\n\t\t\t\t\t\t\treturn this.wrapSchema(schema, name);\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\t// Handle objects like z.coerce\n\t\t\t\t\tif (value && typeof value === 'object') {\n\t\t\t\t\t\treturn new Proxy(value, {\n\t\t\t\t\t\t\tget: (nestedTarget, nestedProp) => {\n\t\t\t\t\t\t\t\tconst nestedValue =\n\t\t\t\t\t\t\t\t\tnestedTarget[nestedProp as keyof typeof nestedTarget];\n\t\t\t\t\t\t\t\tif (typeof nestedValue === 'function') {\n\t\t\t\t\t\t\t\t\treturn (...args: any[]) => {\n\t\t\t\t\t\t\t\t\t\tconst schema = nestedValue(...args);\n\t\t\t\t\t\t\t\t\t\treturn this.wrapSchema(schema, name);\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn nestedValue;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\treturn value;\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t};\n\n\t/**\n\t * Creates a new ConfigParser object that can be used to parse the config object\n\t *\n\t * @param builder - A function that takes a getter function and returns a config object\n\t * @returns A ConfigParser object that can be used to parse the config object\n\t */\n\tcreate<TReturn extends EmptyObject>(\n\t\tbuilder: (get: EnvFetcher) => TReturn,\n\t): ConfigParser<TReturn> {\n\t\tconst config = builder(this.getZodGetter);\n\t\treturn new ConfigParser(config, this.accessedVars);\n\t}\n\n\t/**\n\t * Returns an array of environment variable names that were accessed via the getter.\n\t * This is useful for build-time analysis to determine which env vars a service needs.\n\t *\n\t * @returns Array of environment variable names, sorted alphabetically\n\t *\n\t * @example\n\t * ```typescript\n\t * const sniffer = new EnvironmentParser({});\n\t * service.register(sniffer);\n\t * const envVars = sniffer.getEnvironmentVariables(); // ['DATABASE_URL', 'PORT']\n\t * ```\n\t */\n\tgetEnvironmentVariables(): string[] {\n\t\treturn Array.from(this.accessedVars).sort();\n\t}\n}\n\n/**\n * Infers the TypeScript type of a configuration object based on its Zod schemas.\n * Recursively processes nested objects and extracts types from Zod schemas.\n *\n * @template T - The configuration object type\n */\nexport type InferConfig<T extends EmptyObject> = {\n\t[K in keyof T]: T[K] extends z.ZodSchema\n\t\t? z.infer<T[K]>\n\t\t: T[K] extends Record<string, unknown>\n\t\t\t? InferConfig<T[K]>\n\t\t\t: T[K];\n};\n\n/**\n * Function type for fetching environment variables with Zod validation.\n * Returns a Zod object scoped to a specific environment variable.\n *\n * @template TPath - The environment variable path type\n * @param name - The environment variable name\n * @returns A Zod object for defining the schema\n */\nexport type EnvFetcher<TPath extends string = string> = (\n\tname: TPath,\n) => typeof z;\n\n/**\n * Function type for building environment configuration objects.\n * Takes an EnvFetcher and returns a configuration object with Zod schemas.\n *\n * @template TResponse - The response configuration object type\n * @param get - The environment variable fetcher function\n * @returns The configuration object with Zod schemas\n */\nexport type EnvironmentBuilder<TResponse extends EmptyObject> = (\n\tget: EnvFetcher,\n) => TResponse;\n\n/**\n * Type alias for a generic object with unknown values.\n * Used as a constraint for configuration objects.\n */\nexport type EmptyObject = Record<string | number | symbol, unknown>;\n"],"mappings":";;;;;;;;;;;;;AAWA,IAAa,eAAb,MAAyD;;;;;;;CAOxD,YACkBA,QACAC,0BAAuB,IAAI,OAC3C;EAF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AA,CAAE,MAAM,EAAE,MACV,EAAE,WAAW,0BACZ,YAAY,EAAE,MACd,EAAE;;;;;;;;;KAWK,mDACL,iBACK;;;;;;;;;KAUA,qCAAqC,qBAC3C,eACD;;;;;KAMO,WAAA,GAAc"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EnvironmentParser-zMblItla.mjs","names":["config: TResponse","envVars: Set<string>","errors: z.core.$ZodIssue[]","config: T","path: string[]","result: EmptyObject","schema: z.ZodType","name: string","issue: z.core.$ZodIssue","builder: (get: EnvFetcher) => TReturn"],"sources":["../src/EnvironmentParser.ts"],"sourcesContent":["import get from 'lodash.get';\nimport set from 'lodash.set';\nimport { z } from 'zod/v4';\nimport { formatParseError, isDevelopment } from './formatter.js';\n\n/**\n * Parses and validates configuration objects against Zod schemas.\n * Handles nested configurations and aggregates validation errors.\n *\n * @template TResponse - The shape of the configuration object\n */\nexport class ConfigParser<TResponse extends EmptyObject> {\n\t/**\n\t * Creates a new ConfigParser instance.\n\t *\n\t * @param config - The configuration object to parse\n\t * @param envVars - Set of environment variable names that were accessed\n\t */\n\tconstructor(\n\t\tprivate readonly config: TResponse,\n\t\tprivate readonly envVars: Set<string> = new Set(),\n\t) {}\n\t/**\n\t * Parses the config object and validates it against the Zod schemas\n\t * @returns The parsed config object\n\t */\n\tparse(): InferConfig<TResponse> {\n\t\tconst errors: z.core.$ZodIssue[] = [];\n\n\t\tconst parseDeep = <T>(config: T, path: string[] = []) => {\n\t\t\tconst result: EmptyObject = {};\n\n\t\t\tif (config && typeof config !== 'object') {\n\t\t\t\treturn config;\n\t\t\t}\n\n\t\t\tfor (const key in config) {\n\t\t\t\tconst schema = config[key];\n\t\t\t\tconst currentPath = [...path, key];\n\n\t\t\t\tif (schema instanceof z.ZodType) {\n\t\t\t\t\tconst parsed = schema.safeParse(undefined);\n\t\t\t\t\tif (parsed.success) {\n\t\t\t\t\t\tset(result, key, parsed.data);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If the schema is invalid, assign the error\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t...parsed.error.issues.map((issue) => ({\n\t\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\t\tpath: [...currentPath, ...(issue.path as string[])],\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else if (schema) {\n\t\t\t\t\tset(result, key, parseDeep(schema as EmptyObject, currentPath));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn result;\n\t\t};\n\n\t\tconst parsedConfig = parseDeep(\n\t\t\tthis.config,\n\t\t) as unknown as InferConfig<TResponse>;\n\n\t\tif (errors.length > 0) {\n\t\t\tconst zodError = new z.ZodError(errors);\n\t\t\t// In development, log a formatted error message before throwing\n\t\t\tif (isDevelopment()) {\n\t\t\t\tconsole.error(formatParseError(zodError));\n\t\t\t}\n\t\t\tthrow zodError;\n\t\t}\n\n\t\treturn parsedConfig;\n\t}\n\n\t/**\n\t * Returns an array of environment variable names that were accessed during config creation.\n\t * This is useful for deployment and configuration management to know which env vars are required.\n\t *\n\t * @returns Array of environment variable names, sorted alphabetically\n\t *\n\t * @example\n\t * ```typescript\n\t * const config = envParser.create((get) => ({\n\t * dbUrl: get('DATABASE_URL').string(),\n\t * port: get('PORT').number()\n\t * }));\n\t *\n\t * config.getEnvironmentVariables(); // ['DATABASE_URL', 'PORT']\n\t * ```\n\t */\n\tgetEnvironmentVariables(): string[] {\n\t\treturn Array.from(this.envVars).sort();\n\t}\n}\n\n/**\n * Parses environment variables with type-safe validation using Zod schemas.\n * Provides a fluent API for defining environment variable schemas with automatic\n * error context enrichment.\n *\n * @template T - The type of the configuration object (typically process.env)\n *\n * @example\n * ```typescript\n * const config = new EnvironmentParser(process.env)\n * .create((get) => ({\n * port: get('PORT').string().transform(Number).default(3000),\n * database: {\n * url: get('DATABASE_URL').string().url()\n * }\n * }))\n * .parse();\n * ```\n */\nexport class EnvironmentParser<T extends EmptyObject> {\n\t/**\n\t * Set to track which environment variable names have been accessed\n\t */\n\tprivate readonly accessedVars: Set<string> = new Set();\n\n\t/**\n\t * Creates a new EnvironmentParser instance.\n\t *\n\t * @param config - The configuration object to parse (typically process.env)\n\t */\n\tconstructor(private readonly config: T) {}\n\n\t/**\n\t * Wraps a Zod schema to intercept parse/safeParse calls and enrich error messages\n\t * with environment variable context.\n\t *\n\t * @param schema - The Zod schema to wrap\n\t * @param name - The environment variable name for error context\n\t * @returns A wrapped Zod schema with enhanced error reporting\n\t */\n\tprivate wrapSchema = (schema: z.ZodType, name: string): z.ZodType => {\n\t\t// Create a proxy that intercepts all method calls on the schema\n\t\treturn new Proxy(schema, {\n\t\t\tget: (target, prop) => {\n\t\t\t\tif (prop === 'parse') {\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tconst value = get(this.config, name);\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\treturn target.parse(value);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tif (error instanceof z.ZodError) {\n\t\t\t\t\t\t\t\t// Modify the error to include the environment variable name\n\t\t\t\t\t\t\t\tconst modifiedIssues = error.issues.map((issue) => ({\n\t\t\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\t\t\tmessage: `Environment variable \"${name}\": ${issue.message}`,\n\t\t\t\t\t\t\t\t\tpath: [name, ...issue.path],\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\tthrow new z.ZodError(modifiedIssues);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif (prop === 'safeParse') {\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tconst value = get(this.config, name);\n\t\t\t\t\t\tconst result = target.safeParse(value);\n\n\t\t\t\t\t\tif (!result.success) {\n\t\t\t\t\t\t\t// Modify the error to include the environment variable name\n\t\t\t\t\t\t\tconst modifiedIssues = result.error.issues.map(\n\t\t\t\t\t\t\t\t(issue: z.core.$ZodIssue) => ({\n\t\t\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\t\t\tmessage: `Environment variable \"${name}\": ${issue.message}`,\n\t\t\t\t\t\t\t\t\tpath: [name, ...issue.path],\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tsuccess: false as const,\n\t\t\t\t\t\t\t\terror: new z.ZodError(modifiedIssues),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// For any method that returns a new schema (like transform, optional, etc.),\n\t\t\t\t// wrap the result as well\n\t\t\t\tconst originalProp = target[prop as keyof typeof target];\n\t\t\t\tif (typeof originalProp === 'function') {\n\t\t\t\t\treturn (...args: any[]) => {\n\t\t\t\t\t\tconst result = originalProp.apply(target, args);\n\t\t\t\t\t\t// If the result is a ZodType, wrap it too\n\t\t\t\t\t\tif (result && typeof result === 'object' && 'parse' in result) {\n\t\t\t\t\t\t\treturn this.wrapSchema(result, name);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn originalProp;\n\t\t\t},\n\t\t});\n\t};\n\n\t/**\n\t * Creates a proxied version of the Zod object that wraps all schema creators\n\t * to provide enhanced error messages with environment variable context.\n\t *\n\t * @param name - The environment variable name\n\t * @returns A proxied Zod object with wrapped schema creators\n\t */\n\tprivate getZodGetter = (name: string) => {\n\t\t// Track that this environment variable was accessed\n\t\tthis.accessedVars.add(name);\n\n\t\t// Return an object that has all Zod schemas but with our wrapper\n\t\treturn new Proxy(\n\t\t\t{ ...z },\n\t\t\t{\n\t\t\t\tget: (target, prop) => {\n\t\t\t\t\t// deno-lint-ignore ban-ts-comment\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tconst value = target[prop];\n\n\t\t\t\t\tif (typeof value === 'function') {\n\t\t\t\t\t\t// Return a wrapper around each Zod schema creator\n\t\t\t\t\t\treturn (...args: any[]) => {\n\t\t\t\t\t\t\tconst schema = value(...args);\n\t\t\t\t\t\t\treturn this.wrapSchema(schema, name);\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\t// Handle objects like z.coerce\n\t\t\t\t\tif (value && typeof value === 'object') {\n\t\t\t\t\t\treturn new Proxy(value, {\n\t\t\t\t\t\t\tget: (nestedTarget, nestedProp) => {\n\t\t\t\t\t\t\t\tconst nestedValue =\n\t\t\t\t\t\t\t\t\tnestedTarget[nestedProp as keyof typeof nestedTarget];\n\t\t\t\t\t\t\t\tif (typeof nestedValue === 'function') {\n\t\t\t\t\t\t\t\t\treturn (...args: any[]) => {\n\t\t\t\t\t\t\t\t\t\tconst schema = nestedValue(...args);\n\t\t\t\t\t\t\t\t\t\treturn this.wrapSchema(schema, name);\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn nestedValue;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\treturn value;\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t};\n\n\t/**\n\t * Creates a new ConfigParser object that can be used to parse the config object\n\t *\n\t * @param builder - A function that takes a getter function and returns a config object\n\t * @returns A ConfigParser object that can be used to parse the config object\n\t */\n\tcreate<TReturn extends EmptyObject>(\n\t\tbuilder: (get: EnvFetcher) => TReturn,\n\t): ConfigParser<TReturn> {\n\t\tconst config = builder(this.getZodGetter);\n\t\treturn new ConfigParser(config, this.accessedVars);\n\t}\n\n\t/**\n\t * Returns an array of environment variable names that were accessed via the getter.\n\t * This is useful for build-time analysis to determine which env vars a service needs.\n\t *\n\t * @returns Array of environment variable names, sorted alphabetically\n\t *\n\t * @example\n\t * ```typescript\n\t * const sniffer = new EnvironmentParser({});\n\t * service.register(sniffer);\n\t * const envVars = sniffer.getEnvironmentVariables(); // ['DATABASE_URL', 'PORT']\n\t * ```\n\t */\n\tgetEnvironmentVariables(): string[] {\n\t\treturn Array.from(this.accessedVars).sort();\n\t}\n}\n\n/**\n * Infers the TypeScript type of a configuration object based on its Zod schemas.\n * Recursively processes nested objects and extracts types from Zod schemas.\n *\n * @template T - The configuration object type\n */\nexport type InferConfig<T extends EmptyObject> = {\n\t[K in keyof T]: T[K] extends z.ZodSchema\n\t\t? z.infer<T[K]>\n\t\t: T[K] extends Record<string, unknown>\n\t\t\t? InferConfig<T[K]>\n\t\t\t: T[K];\n};\n\n/**\n * Function type for fetching environment variables with Zod validation.\n * Returns a Zod object scoped to a specific environment variable.\n *\n * @template TPath - The environment variable path type\n * @param name - The environment variable name\n * @returns A Zod object for defining the schema\n */\nexport type EnvFetcher<TPath extends string = string> = (\n\tname: TPath,\n) => typeof z;\n\n/**\n * Function type for building environment configuration objects.\n * Takes an EnvFetcher and returns a configuration object with Zod schemas.\n *\n * @template TResponse - The response configuration object type\n * @param get - The environment variable fetcher function\n * @returns The configuration object with Zod schemas\n */\nexport type EnvironmentBuilder<TResponse extends EmptyObject> = (\n\tget: EnvFetcher,\n) => TResponse;\n\n/**\n * Type alias for a generic object with unknown values.\n * Used as a constraint for configuration objects.\n */\nexport type EmptyObject = Record<string | number | symbol, unknown>;\n"],"mappings":";;;;;;;;;;;;AAWA,IAAa,eAAb,MAAyD;;;;;;;CAOxD,YACkBA,QACAC,0BAAuB,IAAI,OAC3C;EAFgB;EACA;CACd;;;;;CAKJ,QAAgC;EAC/B,MAAMC,SAA6B,CAAE;EAErC,MAAM,YAAY,CAAIC,QAAWC,OAAiB,CAAE,MAAK;GACxD,MAAMC,SAAsB,CAAE;AAE9B,OAAI,iBAAiB,WAAW,SAC/B,QAAO;AAGR,QAAK,MAAM,OAAO,QAAQ;IACzB,MAAM,SAAS,OAAO;IACtB,MAAM,cAAc,CAAC,GAAG,MAAM,GAAI;AAElC,QAAI,kBAAkB,EAAE,SAAS;KAChC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AQD,OACCE,SACwB;EACxB,MAAM,SAAS,QAAQ,KAAK,aAAa;AACzC,SAAO,IAAI,aAAa,QAAQ,KAAK;CACrC;;;;;;;;;;;;;;CAeD,0BAAoC;AACnC,SAAO,MAAM,KAAK,KAAK,aAAa,CAAC,MAAM;CAC3C;AACD"}
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { EnvRecord, EnvironmentBuilderOptions, EnvironmentResolver, InputValue, Resolvers } from "./EnvironmentBuilder-jF-b7WQg.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/SstEnvironmentBuilder.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Enumeration of supported SST (Serverless Stack Toolkit) resource types.
|
|
7
|
-
* Used to identify and process different AWS and SST resources.
|
|
8
|
-
*/
|
|
9
|
-
declare enum ResourceType {
|
|
10
|
-
ApiGatewayV2 = "sst.aws.ApiGatewayV2",
|
|
11
|
-
Postgres = "sst.aws.Postgres",
|
|
12
|
-
Function = "sst.aws.Function",
|
|
13
|
-
Bucket = "sst.aws.Bucket",
|
|
14
|
-
Vpc = "sst.aws.Vpc",
|
|
15
|
-
Secret = "sst.sst.Secret",
|
|
16
|
-
Dynamo = "sst.aws.Dynamo",
|
|
17
|
-
SSTSecret = "sst:sst:Secret",
|
|
18
|
-
SSTFunction = "sst:sst:Function",
|
|
19
|
-
SSTApiGatewayV2 = "sst:aws:ApiGatewayV2",
|
|
20
|
-
SSTPostgres = "sst:aws:Postgres",
|
|
21
|
-
SSTBucket = "sst:aws:Bucket",
|
|
22
|
-
SnsTopic = "sst:aws:SnsTopic",
|
|
23
|
-
SSTDynamo = "sst:aws:Dynamo",
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* AWS API Gateway V2 resource type.
|
|
27
|
-
* Represents an HTTP/WebSocket API.
|
|
28
|
-
*/
|
|
29
|
-
type ApiGatewayV2 = {
|
|
30
|
-
type: ResourceType.ApiGatewayV2 | ResourceType.SSTApiGatewayV2;
|
|
31
|
-
url: string;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* PostgreSQL database resource type.
|
|
35
|
-
* Contains all connection details needed to connect to the database.
|
|
36
|
-
*/
|
|
37
|
-
type Postgres = {
|
|
38
|
-
type: ResourceType.Postgres | ResourceType.SSTPostgres;
|
|
39
|
-
database: string;
|
|
40
|
-
host: string;
|
|
41
|
-
password: string;
|
|
42
|
-
port: number;
|
|
43
|
-
username: string;
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* AWS Lambda Function resource type.
|
|
47
|
-
*/
|
|
48
|
-
type Function = {
|
|
49
|
-
type: ResourceType.Function | ResourceType.SSTFunction;
|
|
50
|
-
name: string;
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* AWS S3 Bucket resource type.
|
|
54
|
-
*/
|
|
55
|
-
type Bucket = {
|
|
56
|
-
type: ResourceType.Bucket | ResourceType.SSTBucket;
|
|
57
|
-
name: string;
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* AWS VPC (Virtual Private Cloud) resource type.
|
|
61
|
-
*/
|
|
62
|
-
type Vpc = {
|
|
63
|
-
type: ResourceType.Vpc;
|
|
64
|
-
bastion: string;
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* Secret resource type for storing sensitive values.
|
|
68
|
-
*/
|
|
69
|
-
type Secret = {
|
|
70
|
-
type: ResourceType.Secret | ResourceType.SSTSecret;
|
|
71
|
-
value: string;
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* AWS SNS Topic resource type.
|
|
75
|
-
*/
|
|
76
|
-
type SnsTopic = {
|
|
77
|
-
type: ResourceType.SnsTopic;
|
|
78
|
-
arn: string;
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* AWS DynamoDB Table resource type.
|
|
82
|
-
*/
|
|
83
|
-
type Dynamo = {
|
|
84
|
-
type: ResourceType.Dynamo | ResourceType.SSTDynamo;
|
|
85
|
-
name: string;
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Union type of all supported SST resource types.
|
|
89
|
-
*/
|
|
90
|
-
type SstResource = ApiGatewayV2 | Postgres | Function | Bucket | Vpc | Secret | SnsTopic | Dynamo;
|
|
91
|
-
/**
|
|
92
|
-
* Function type for processing a specific resource type into environment variables.
|
|
93
|
-
*
|
|
94
|
-
* @template K - The specific resource type (without `type` key)
|
|
95
|
-
* @param name - The resource name
|
|
96
|
-
* @param value - The resource value (without `type` key)
|
|
97
|
-
* @returns Object mapping environment variable names to values
|
|
98
|
-
*/
|
|
99
|
-
type ResourceProcessor<K> = (name: string, value: K) => EnvRecord;
|
|
100
|
-
/**
|
|
101
|
-
* Pre-configured resolvers for all SST resource types.
|
|
102
|
-
*/
|
|
103
|
-
declare const sstResolvers: Resolvers;
|
|
104
|
-
/**
|
|
105
|
-
* All known SST resource type strings.
|
|
106
|
-
*/
|
|
107
|
-
type SstResourceTypeString = `${ResourceType}`;
|
|
108
|
-
/**
|
|
109
|
-
* Extracts the `type` string value from an input value.
|
|
110
|
-
*/
|
|
111
|
-
type ExtractType<T> = T extends {
|
|
112
|
-
type: infer U extends string;
|
|
113
|
-
} ? U : never;
|
|
114
|
-
/**
|
|
115
|
-
* Removes the `type` key from an object type.
|
|
116
|
-
*/
|
|
117
|
-
type OmitType<T> = T extends {
|
|
118
|
-
type: string;
|
|
119
|
-
} ? Omit<T, 'type'> : never;
|
|
120
|
-
/**
|
|
121
|
-
* Extracts all unique `type` values from a record (excluding plain strings).
|
|
122
|
-
*/
|
|
123
|
-
type AllTypeValues<TRecord extends Record<string, InputValue>> = { [K in keyof TRecord]: ExtractType<TRecord[K]> }[keyof TRecord];
|
|
124
|
-
/**
|
|
125
|
-
* Extracts only the custom (non-SST) type values from a record.
|
|
126
|
-
*/
|
|
127
|
-
type CustomTypeValues<TRecord extends Record<string, InputValue>> = Exclude<AllTypeValues<TRecord>, SstResourceTypeString>;
|
|
128
|
-
/**
|
|
129
|
-
* For a given type value, finds the corresponding value type (without `type` key).
|
|
130
|
-
*/
|
|
131
|
-
type ValueForType<TRecord extends Record<string, InputValue>, TType extends string> = { [K in keyof TRecord]: TRecord[K] extends {
|
|
132
|
-
type: TType;
|
|
133
|
-
} ? OmitType<TRecord[K]> : never }[keyof TRecord];
|
|
134
|
-
/**
|
|
135
|
-
* Generates typed resolvers for custom (non-SST) types in the input record.
|
|
136
|
-
*/
|
|
137
|
-
type CustomResolvers<TRecord extends Record<string, InputValue>> = CustomTypeValues<TRecord> extends never ? Resolvers | undefined : { [TType in CustomTypeValues<TRecord>]: EnvironmentResolver<ValueForType<TRecord, TType>> };
|
|
138
|
-
/**
|
|
139
|
-
* SST-specific environment builder with built-in resolvers for all known
|
|
140
|
-
* SST resource types.
|
|
141
|
-
*
|
|
142
|
-
* Wraps the generic EnvironmentBuilder with pre-configured SST resolvers.
|
|
143
|
-
*
|
|
144
|
-
* @template TRecord - The input record type for type inference
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* ```typescript
|
|
148
|
-
* const env = new SstEnvironmentBuilder({
|
|
149
|
-
* database: { type: 'sst:aws:Postgres', host: '...', ... },
|
|
150
|
-
* apiKey: { type: 'sst:sst:Secret', value: 'secret' },
|
|
151
|
-
* appName: 'my-app',
|
|
152
|
-
* }).build();
|
|
153
|
-
*
|
|
154
|
-
* // With custom resolvers (typed based on input)
|
|
155
|
-
* const env = new SstEnvironmentBuilder(
|
|
156
|
-
* {
|
|
157
|
-
* database: postgresResource,
|
|
158
|
-
* custom: { type: 'my-custom' as const, data: 'foo' },
|
|
159
|
-
* },
|
|
160
|
-
* {
|
|
161
|
-
* // TypeScript requires 'my-custom' resolver with typed value
|
|
162
|
-
* 'my-custom': (key, value) => ({ [`${key}Data`]: value.data }),
|
|
163
|
-
* }
|
|
164
|
-
* ).build();
|
|
165
|
-
* ```
|
|
166
|
-
*/
|
|
167
|
-
declare class SstEnvironmentBuilder<TRecord extends Record<string, SstResource | InputValue | string>> {
|
|
168
|
-
private readonly builder;
|
|
169
|
-
/**
|
|
170
|
-
* Create a new SST environment builder.
|
|
171
|
-
*
|
|
172
|
-
* @param record - Object containing SST resources, custom resources, and/or string values
|
|
173
|
-
* @param additionalResolvers - Optional custom resolvers (typed based on custom types in record)
|
|
174
|
-
* @param options - Optional configuration options
|
|
175
|
-
*/
|
|
176
|
-
constructor(record: TRecord, additionalResolvers?: CustomResolvers<TRecord>, options?: EnvironmentBuilderOptions);
|
|
177
|
-
/**
|
|
178
|
-
* Build environment variables from the input record.
|
|
179
|
-
*
|
|
180
|
-
* @returns A record of environment variables
|
|
181
|
-
*/
|
|
182
|
-
build(): EnvRecord;
|
|
183
|
-
}
|
|
184
|
-
//#endregion
|
|
185
|
-
export { ApiGatewayV2, Bucket, Dynamo, Function, Postgres, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, sstResolvers };
|
|
186
|
-
//# sourceMappingURL=SstEnvironmentBuilder-BRAcRQp2.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SstEnvironmentBuilder-BRAcRQp2.d.mts","names":[],"sources":["../src/SstEnvironmentBuilder.ts"],"sourcesContent":[],"mappings":";;;;;;AAaA;AAwBA;AAAwB,aAxBZ,YAAA;EAwBY,YACjB,GAAA,sBAAa;EAAY,QAAG,GAAA,kBAAa;EAAe,QAAA,GAAA,kBAAA;EAQnD,MAAA,GAAA,gBAAQ;EAAA,GAAA,GAAA,aAAA;EAAA,MACb,GAAA,gBAAa;EAAQ,MAAG,GAAA,gBAAa;EAAW,SAAA,GAAA,gBAAA;EAW3C,WAAQ,GAAA,kBAAA;EAAA,eAAA,GAAA,sBAAA;EAAA,WACb,GAAA,kBAAa;EAAQ,SAAG,GAAA,gBAAa;EAAW,QAAA,GAAA,kBAAA;EAO3C,SAAM,GAAA,gBAAA;;;;AACiC;AAOnD;AAQY,KA7CA,YAAA,GA6CM;EAAA,IAAA,EA5CX,YAAA,CAAa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