node-env-resolver 4.0.0 → 5.0.1
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/README.md +493 -376
- package/dist/audit.d.cts +29 -0
- package/dist/audit.d.ts +8 -7
- package/dist/builder.cjs +1 -1
- package/dist/builder.d.cts +149 -0
- package/dist/builder.d.ts +17 -14
- package/dist/builder.js +1 -1
- package/dist/chunk-4QOKRJ3F.cjs +1 -0
- package/dist/chunk-4YVXFL3I.cjs +9 -0
- package/dist/chunk-6D5APQIG.cjs +1 -0
- package/dist/chunk-DIXI6MUB.js +9 -0
- package/dist/chunk-FH54ESWI.cjs +9 -0
- package/dist/chunk-HHOS5S5T.js +1 -0
- package/dist/chunk-TAX63ALN.js +16 -0
- package/dist/chunk-WKIPEKF6.js +1 -0
- package/dist/chunk-XJLMVSPN.js +9 -0
- package/dist/chunk-XPL5XLTA.cjs +16 -0
- package/dist/cli.d.cts +52 -0
- package/dist/cli.d.ts +9 -6
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +148 -0
- package/dist/index.d.ts +99 -92
- package/dist/index.js +1 -1
- package/dist/resolver.cjs +1 -1
- package/dist/resolver.d.cts +20 -0
- package/dist/resolver.d.ts +8 -5
- package/dist/resolver.js +1 -1
- package/dist/resolvers.cjs +1 -1
- package/dist/resolvers.d.cts +412 -0
- package/dist/resolvers.d.ts +294 -22
- package/dist/resolvers.js +1 -1
- package/dist/types.cjs +1 -1
- package/dist/types.d.cts +106 -0
- package/dist/types.d.ts +90 -172
- package/dist/types.js +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.cts +213 -0
- package/dist/utils.d.ts +28 -26
- package/dist/utils.js +1 -1
- package/dist/valibot.cjs +1 -1
- package/dist/valibot.d.cts +156 -0
- package/dist/valibot.d.ts +11 -8
- package/dist/valibot.js +1 -1
- package/dist/validation-types.d.cts +29 -0
- package/dist/validation-types.d.ts +4 -3
- package/dist/validators.cjs +2 -1
- package/dist/validators.d.cts +116 -0
- package/dist/validators.d.ts +46 -18
- package/dist/validators.js +2 -1
- package/dist/web.cjs +3 -3
- package/dist/web.d.cts +69 -0
- package/dist/web.d.ts +28 -10
- package/dist/web.js +3 -3
- package/dist/zod.cjs +1 -1
- package/dist/zod.d.cts +135 -0
- package/dist/zod.d.ts +11 -8
- package/dist/zod.js +1 -1
- package/package.json +7 -7
- package/dist/advanced-features.test.d.ts +0 -2
- package/dist/advanced-features.test.d.ts.map +0 -1
- package/dist/audit.d.ts.map +0 -1
- package/dist/audit.test.d.ts +0 -2
- package/dist/audit.test.d.ts.map +0 -1
- package/dist/builder.d.ts.map +0 -1
- package/dist/chunk-54OHKWZJ.js +0 -1
- package/dist/chunk-FCFDGYTF.cjs +0 -15
- package/dist/chunk-HCVTYYLE.js +0 -9
- package/dist/chunk-IU5TG3HL.js +0 -15
- package/dist/chunk-J7ZHEMRP.js +0 -9
- package/dist/chunk-NKPXKLF7.js +0 -1
- package/dist/chunk-P3ZWKKKW.cjs +0 -1
- package/dist/chunk-THFGEKYL.cjs +0 -9
- package/dist/chunk-ULL4WKTV.cjs +0 -9
- package/dist/chunk-XPGSWVRT.cjs +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.test.d.ts +0 -2
- package/dist/cli.test.d.ts.map +0 -1
- package/dist/composition.test.d.ts +0 -7
- package/dist/composition.test.d.ts.map +0 -1
- package/dist/computed.test.d.ts +0 -2
- package/dist/computed.test.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.test.d.ts +0 -2
- package/dist/index.test.d.ts.map +0 -1
- package/dist/nested.test.d.ts +0 -2
- package/dist/nested.test.d.ts.map +0 -1
- package/dist/performance.test.d.ts +0 -7
- package/dist/performance.test.d.ts.map +0 -1
- package/dist/priority.test.d.ts +0 -6
- package/dist/priority.test.d.ts.map +0 -1
- package/dist/providers.d.ts +0 -11
- package/dist/providers.d.ts.map +0 -1
- package/dist/resolver.d.ts.map +0 -1
- package/dist/resolvers.d.ts.map +0 -1
- package/dist/resolvers.test.d.ts +0 -2
- package/dist/resolvers.test.d.ts.map +0 -1
- package/dist/sync-resolvers.test.d.ts +0 -2
- package/dist/sync-resolvers.test.d.ts.map +0 -1
- package/dist/type-inference.test.d.ts +0 -2
- package/dist/type-inference.test.d.ts.map +0 -1
- package/dist/type-override.test.d.ts +0 -2
- package/dist/type-override.test.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.test.d.ts +0 -2
- package/dist/utils.test.d.ts.map +0 -1
- package/dist/valibot.d.ts.map +0 -1
- package/dist/validation-types.d.ts.map +0 -1
- package/dist/validators.d.ts.map +0 -1
- package/dist/web.d.ts.map +0 -1
- package/dist/zod.d.ts.map +0 -1
package/dist/cli.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Resolver } from './types.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* CLI argument parser resolver
|
|
3
5
|
* Converts --kebab-case flags to SCREAMING_SNAKE_CASE env vars
|
|
@@ -12,10 +14,10 @@
|
|
|
12
14
|
* import { resolve } from 'node-env-resolver';
|
|
13
15
|
* import { cliArgs } from 'node-env-resolver/cli';
|
|
14
16
|
*
|
|
15
|
-
* const config = await
|
|
17
|
+
* const config = await resolveAsync(
|
|
16
18
|
* [cliArgs(), {
|
|
17
19
|
* PORT: 3000,
|
|
18
|
-
* DATABASE_URL:
|
|
20
|
+
* DATABASE_URL: postgres(),
|
|
19
21
|
* VERBOSE: false
|
|
20
22
|
* }]
|
|
21
23
|
* );
|
|
@@ -24,8 +26,8 @@
|
|
|
24
26
|
* // config.VERBOSE === true
|
|
25
27
|
* ```
|
|
26
28
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
|
|
30
|
+
interface CliArgsOptions {
|
|
29
31
|
/** Arguments to parse (default: process.argv.slice(2)) */
|
|
30
32
|
argv?: string[];
|
|
31
33
|
/** Prefix for flags (default: '--') */
|
|
@@ -45,5 +47,6 @@ export interface CliArgsOptions {
|
|
|
45
47
|
* @param options Configuration options
|
|
46
48
|
* @returns Resolver that parses CLI arguments
|
|
47
49
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
declare function cliArgs(options?: CliArgsOptions): Resolver;
|
|
51
|
+
|
|
52
|
+
export { type CliArgsOptions, cliArgs };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkFH54ESWI_cjs=require('./chunk-FH54ESWI.cjs');require('./chunk-4YVXFL3I.cjs');var chunk4ZOF2PI4_cjs=require('./chunk-4ZOF2PI4.cjs');require('./chunk-4QOKRJ3F.cjs');var chunk6D5APQIG_cjs=require('./chunk-6D5APQIG.cjs');require('./chunk-KIQXH265.cjs');Object.defineProperty(exports,"resolve",{enumerable:true,get:function(){return chunkFH54ESWI_cjs.a}});Object.defineProperty(exports,"resolveAsync",{enumerable:true,get:function(){return chunkFH54ESWI_cjs.b}});Object.defineProperty(exports,"safeResolve",{enumerable:true,get:function(){return chunkFH54ESWI_cjs.c}});Object.defineProperty(exports,"safeResolveAsync",{enumerable:true,get:function(){return chunkFH54ESWI_cjs.d}});Object.defineProperty(exports,"clearAuditLog",{enumerable:true,get:function(){return chunk4ZOF2PI4_cjs.d}});Object.defineProperty(exports,"getAuditLog",{enumerable:true,get:function(){return chunk4ZOF2PI4_cjs.c}});Object.defineProperty(exports,"isAsyncOnlyResolver",{enumerable:true,get:function(){return chunk6D5APQIG_cjs.b}});Object.defineProperty(exports,"isSyncResolver",{enumerable:true,get:function(){return chunk6D5APQIG_cjs.a}});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { SimpleEnvSchema, ResolveAsyncConfig, InferSimpleValue, ResolveAsyncConfigWithSchema, Resolver, ResolveOptions, ResolveConfigWithSchema, SyncResolver, ResolveConfig } from './types.cjs';
|
|
2
|
+
export { AsyncResolver, EnvDefinition, EnvSchema, InferResolveResult, InferSchema, InferSimpleSchema, InferType, PolicyOptions, Provenance, SimpleEnvValue, Validator, isAsyncOnlyResolver, isSyncResolver } from './types.cjs';
|
|
3
|
+
export { SafeResolveResult as SafeResolveResultWithIssues, ValidationIssue } from './validation-types.cjs';
|
|
4
|
+
export { AuditEvent, AuditEventType, clearAuditLog, getAuditLog } from './audit.cjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Type-safe environment variable resolver
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { resolve } from 'node-env-resolver';
|
|
12
|
+
* import { postgres, string } from 'node-env-resolver/resolvers';
|
|
13
|
+
*
|
|
14
|
+
* const config = resolve({
|
|
15
|
+
* PORT: 3000, // number with default
|
|
16
|
+
* DATABASE_URL: postgres(), // required PostgreSQL URL
|
|
17
|
+
* NODE_ENV: ['development', 'production'], // enum
|
|
18
|
+
* DEBUG: false, // boolean with default
|
|
19
|
+
* API_KEY: string({optional: true}), // optional string
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
interface SafeResolveResult<T> {
|
|
25
|
+
success: true;
|
|
26
|
+
data: T;
|
|
27
|
+
}
|
|
28
|
+
interface SafeResolveError {
|
|
29
|
+
success: false;
|
|
30
|
+
error: string;
|
|
31
|
+
errors?: string[];
|
|
32
|
+
}
|
|
33
|
+
type SafeResolveResultType<T> = SafeResolveResult<T> | SafeResolveError;
|
|
34
|
+
declare function resolve<T extends SimpleEnvSchema>(schema: T, options?: Partial<ResolveOptions>): {
|
|
35
|
+
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
36
|
+
};
|
|
37
|
+
declare function resolve<T extends SimpleEnvSchema>(config: ResolveConfigWithSchema<T>): {
|
|
38
|
+
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
39
|
+
};
|
|
40
|
+
declare function resolve<T extends SimpleEnvSchema>(config: {
|
|
41
|
+
resolvers: readonly [[SyncResolver, T]];
|
|
42
|
+
options?: Partial<ResolveOptions>;
|
|
43
|
+
}): {
|
|
44
|
+
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
45
|
+
};
|
|
46
|
+
declare function resolve<T extends SimpleEnvSchema>(config: {
|
|
47
|
+
resolvers: readonly [SyncResolver, SimpleEnvSchema][];
|
|
48
|
+
options?: Partial<ResolveOptions>;
|
|
49
|
+
}): {
|
|
50
|
+
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Resolve environment variables asynchronously (supports all resolver types - both sync and async)
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* import { resolveAsync } from 'node-env-resolver';
|
|
58
|
+
* import { postgres, string } from 'node-env-resolver/resolvers';
|
|
59
|
+
* import { awsSecrets, dotenv } from 'node-env-resolver/resolvers';
|
|
60
|
+
*
|
|
61
|
+
* // Works with async-only resolvers
|
|
62
|
+
* const config = await resolveAsync({
|
|
63
|
+
* resolvers: [
|
|
64
|
+
* [awsSecrets(), { PORT: 3000, DATABASE_URL: postgres(), API_KEY: string() }]
|
|
65
|
+
* ]
|
|
66
|
+
* });
|
|
67
|
+
*
|
|
68
|
+
* // Also works with sync resolvers (automatically wrapped in Promise)
|
|
69
|
+
* const config = await resolveAsync({
|
|
70
|
+
* resolvers: [
|
|
71
|
+
* [processEnv(), { DATABASE_URL: postgres() }]
|
|
72
|
+
* ],
|
|
73
|
+
* options: { strict: true }
|
|
74
|
+
* });
|
|
75
|
+
*
|
|
76
|
+
* // Multiple resolvers - supports unlimited tuples!
|
|
77
|
+
* const config = await resolveAsync({
|
|
78
|
+
* resolvers: [
|
|
79
|
+
* [dotenv(), { PORT: 3000 }],
|
|
80
|
+
* [awsSecrets(), { DATABASE_URL: postgres() }]
|
|
81
|
+
* ],
|
|
82
|
+
* options: { strict: true }
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
declare function resolveAsync<T extends SimpleEnvSchema>(config: ResolveAsyncConfigWithSchema<T>): Promise<{
|
|
87
|
+
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
88
|
+
}>;
|
|
89
|
+
declare function resolveAsync<T extends SimpleEnvSchema>(config: {
|
|
90
|
+
resolvers: readonly [[Resolver, T]];
|
|
91
|
+
options?: Partial<ResolveOptions>;
|
|
92
|
+
}): Promise<{
|
|
93
|
+
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
94
|
+
}>;
|
|
95
|
+
declare function resolveAsync<T extends SimpleEnvSchema>(config: {
|
|
96
|
+
resolvers: readonly [Resolver, SimpleEnvSchema][];
|
|
97
|
+
options?: Partial<ResolveOptions>;
|
|
98
|
+
}): Promise<{
|
|
99
|
+
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
100
|
+
}>;
|
|
101
|
+
declare function safeResolve<T extends SimpleEnvSchema>(arg1: T | ResolveConfig<T>, arg2?: Partial<ResolveOptions>): SafeResolveResultType<{
|
|
102
|
+
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
103
|
+
}>;
|
|
104
|
+
/**
|
|
105
|
+
* Safe async resolve (doesn't throw, returns result object)
|
|
106
|
+
* Supports both sync and async resolvers
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* import { safeResolveAsync } from 'node-env-resolver';
|
|
111
|
+
* import { postgres } from 'node-env-resolver/resolvers';
|
|
112
|
+
* import { awsSecrets, dotenv } from 'node-env-resolver/resolvers';
|
|
113
|
+
*
|
|
114
|
+
* // Works with async resolvers
|
|
115
|
+
* const result = await safeResolveAsync({
|
|
116
|
+
* resolvers: [
|
|
117
|
+
* [awsSecrets({ region: 'us-east-1' }), { PORT: 3000, DATABASE_URL: postgres() }]
|
|
118
|
+
* ]
|
|
119
|
+
* });
|
|
120
|
+
*
|
|
121
|
+
* // Also works with sync resolvers
|
|
122
|
+
* const result = await safeResolveAsync({
|
|
123
|
+
* resolvers: [
|
|
124
|
+
* [processEnv(), { PORT: 3000 }]
|
|
125
|
+
* ]
|
|
126
|
+
* });
|
|
127
|
+
*
|
|
128
|
+
* // Multiple resolvers - supports unlimited tuples!
|
|
129
|
+
* const result = await safeResolveAsync({
|
|
130
|
+
* resolvers: [
|
|
131
|
+
* [dotenv(), { PORT: 3000 }],
|
|
132
|
+
* [awsSecrets(), { DATABASE_URL: postgres() }]
|
|
133
|
+
* ],
|
|
134
|
+
* options: { strict: true }
|
|
135
|
+
* });
|
|
136
|
+
*
|
|
137
|
+
* if (result.success) {
|
|
138
|
+
* console.log(result.data.PORT); // Type-safe access
|
|
139
|
+
* } else {
|
|
140
|
+
* console.error(result.error); // Detailed error message
|
|
141
|
+
* }
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
declare function safeResolveAsync<T extends SimpleEnvSchema>(config: ResolveAsyncConfig<T>): Promise<SafeResolveResultType<{
|
|
145
|
+
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
146
|
+
}>>;
|
|
147
|
+
|
|
148
|
+
export { ResolveAsyncConfig, ResolveConfig, ResolveOptions, Resolver, type SafeResolveError, type SafeResolveResult, type SafeResolveResultType, SimpleEnvSchema, SyncResolver, resolve, resolveAsync, safeResolve, safeResolveAsync };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,132 +1,138 @@
|
|
|
1
|
+
import { SimpleEnvSchema, ResolveAsyncConfig, InferSimpleValue, ResolveAsyncConfigWithSchema, Resolver, ResolveOptions, ResolveConfigWithSchema, SyncResolver, ResolveConfig } from './types.js';
|
|
2
|
+
export { AsyncResolver, EnvDefinition, EnvSchema, InferResolveResult, InferSchema, InferSimpleSchema, InferType, PolicyOptions, Provenance, SimpleEnvValue, Validator, isAsyncOnlyResolver, isSyncResolver } from './types.js';
|
|
3
|
+
export { SafeResolveResult as SafeResolveResultWithIssues, ValidationIssue } from './validation-types.js';
|
|
4
|
+
export { AuditEvent, AuditEventType, clearAuditLog, getAuditLog } from './audit.js';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* Type-safe environment variable resolver
|
|
3
8
|
*
|
|
4
9
|
* @example
|
|
5
10
|
* ```typescript
|
|
6
11
|
* import { resolve } from 'node-env-resolver';
|
|
12
|
+
* import { postgres, string } from 'node-env-resolver/resolvers';
|
|
7
13
|
*
|
|
8
|
-
* const config =
|
|
14
|
+
* const config = resolve({
|
|
9
15
|
* PORT: 3000, // number with default
|
|
10
|
-
* DATABASE_URL:
|
|
16
|
+
* DATABASE_URL: postgres(), // required PostgreSQL URL
|
|
11
17
|
* NODE_ENV: ['development', 'production'], // enum
|
|
12
18
|
* DEBUG: false, // boolean with default
|
|
13
|
-
* API_KEY:
|
|
19
|
+
* API_KEY: string({optional: true}), // optional string
|
|
14
20
|
* });
|
|
15
21
|
* ```
|
|
16
22
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export { isSyncResolver, isAsyncOnlyResolver } from './types';
|
|
20
|
-
export type { ValidationIssue, SafeResolveResult as SafeResolveResultWithIssues } from './validation-types';
|
|
21
|
-
export { getAuditLog, clearAuditLog, type AuditEvent, type AuditEventType } from './audit';
|
|
22
|
-
export declare function processEnv(): SyncResolver;
|
|
23
|
-
export interface SafeResolveResult<T> {
|
|
23
|
+
|
|
24
|
+
interface SafeResolveResult<T> {
|
|
24
25
|
success: true;
|
|
25
26
|
data: T;
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
+
interface SafeResolveError {
|
|
28
29
|
success: false;
|
|
29
30
|
error: string;
|
|
30
31
|
errors?: string[];
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
*
|
|
52
|
-
* // With custom sync resolver and options
|
|
53
|
-
* const config = resolve([
|
|
54
|
-
* dotenv(),
|
|
55
|
-
* { PORT: 3000, DATABASE_URL: 'postgres' }
|
|
56
|
-
* ], { strict: true });
|
|
57
|
-
*
|
|
58
|
-
* // Multiple sync resolvers (NEW!)
|
|
59
|
-
* const config = resolve(
|
|
60
|
-
* [dotenv(), { PORT: 3000 }],
|
|
61
|
-
* [json('config.json'), { DATABASE_URL: 'postgres' }],
|
|
62
|
-
* { strict: true }
|
|
63
|
-
* );
|
|
64
|
-
*
|
|
65
|
-
* // Async resolution with resolve.async()
|
|
66
|
-
* const config = await resolve.async([
|
|
67
|
-
* awsSecrets(),
|
|
68
|
-
* { DATABASE_URL: 'url', API_KEY: 'string' }
|
|
69
|
-
* ]);
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
declare function resolveImpl<T extends SimpleEnvSchema>(arg1: T | [SyncResolver, T], ...rest: ([SyncResolver, T] | Partial<ResolveOptions>)[]): InferSimpleSchema<T>;
|
|
73
|
-
declare namespace resolveImpl {
|
|
74
|
-
var async: typeof resolveAsync;
|
|
75
|
-
}
|
|
33
|
+
type SafeResolveResultType<T> = SafeResolveResult<T> | SafeResolveError;
|
|
34
|
+
declare function resolve<T extends SimpleEnvSchema>(schema: T, options?: Partial<ResolveOptions>): {
|
|
35
|
+
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
36
|
+
};
|
|
37
|
+
declare function resolve<T extends SimpleEnvSchema>(config: ResolveConfigWithSchema<T>): {
|
|
38
|
+
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
39
|
+
};
|
|
40
|
+
declare function resolve<T extends SimpleEnvSchema>(config: {
|
|
41
|
+
resolvers: readonly [[SyncResolver, T]];
|
|
42
|
+
options?: Partial<ResolveOptions>;
|
|
43
|
+
}): {
|
|
44
|
+
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
45
|
+
};
|
|
46
|
+
declare function resolve<T extends SimpleEnvSchema>(config: {
|
|
47
|
+
resolvers: readonly [SyncResolver, SimpleEnvSchema][];
|
|
48
|
+
options?: Partial<ResolveOptions>;
|
|
49
|
+
}): {
|
|
50
|
+
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
51
|
+
};
|
|
76
52
|
/**
|
|
77
53
|
* Resolve environment variables asynchronously (supports all resolver types - both sync and async)
|
|
78
54
|
*
|
|
79
55
|
* @example
|
|
80
56
|
* ```typescript
|
|
57
|
+
* import { resolveAsync } from 'node-env-resolver';
|
|
58
|
+
* import { postgres, string } from 'node-env-resolver/resolvers';
|
|
59
|
+
* import { awsSecrets, dotenv } from 'node-env-resolver/resolvers';
|
|
60
|
+
*
|
|
81
61
|
* // Works with async-only resolvers
|
|
82
|
-
* const config = await
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
62
|
+
* const config = await resolveAsync({
|
|
63
|
+
* resolvers: [
|
|
64
|
+
* [awsSecrets(), { PORT: 3000, DATABASE_URL: postgres(), API_KEY: string() }]
|
|
65
|
+
* ]
|
|
66
|
+
* });
|
|
86
67
|
*
|
|
87
68
|
* // Also works with sync resolvers (automatically wrapped in Promise)
|
|
88
|
-
* const config = await
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
69
|
+
* const config = await resolveAsync({
|
|
70
|
+
* resolvers: [
|
|
71
|
+
* [processEnv(), { DATABASE_URL: postgres() }]
|
|
72
|
+
* ],
|
|
73
|
+
* options: { strict: true }
|
|
74
|
+
* });
|
|
92
75
|
*
|
|
93
|
-
* // Multiple resolvers
|
|
94
|
-
* const config = await
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
76
|
+
* // Multiple resolvers - supports unlimited tuples!
|
|
77
|
+
* const config = await resolveAsync({
|
|
78
|
+
* resolvers: [
|
|
79
|
+
* [dotenv(), { PORT: 3000 }],
|
|
80
|
+
* [awsSecrets(), { DATABASE_URL: postgres() }]
|
|
81
|
+
* ],
|
|
82
|
+
* options: { strict: true }
|
|
83
|
+
* });
|
|
99
84
|
* ```
|
|
100
85
|
*/
|
|
101
|
-
declare function resolveAsync<T extends SimpleEnvSchema>(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
86
|
+
declare function resolveAsync<T extends SimpleEnvSchema>(config: ResolveAsyncConfigWithSchema<T>): Promise<{
|
|
87
|
+
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
88
|
+
}>;
|
|
89
|
+
declare function resolveAsync<T extends SimpleEnvSchema>(config: {
|
|
90
|
+
resolvers: readonly [[Resolver, T]];
|
|
91
|
+
options?: Partial<ResolveOptions>;
|
|
92
|
+
}): Promise<{
|
|
93
|
+
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
94
|
+
}>;
|
|
95
|
+
declare function resolveAsync<T extends SimpleEnvSchema>(config: {
|
|
96
|
+
resolvers: readonly [Resolver, SimpleEnvSchema][];
|
|
97
|
+
options?: Partial<ResolveOptions>;
|
|
98
|
+
}): Promise<{
|
|
99
|
+
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
100
|
+
}>;
|
|
101
|
+
declare function safeResolve<T extends SimpleEnvSchema>(arg1: T | ResolveConfig<T>, arg2?: Partial<ResolveOptions>): SafeResolveResultType<{
|
|
102
|
+
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
103
|
+
}>;
|
|
106
104
|
/**
|
|
107
105
|
* Safe async resolve (doesn't throw, returns result object)
|
|
108
106
|
* Supports both sync and async resolvers
|
|
109
107
|
*
|
|
110
108
|
* @example
|
|
111
109
|
* ```typescript
|
|
110
|
+
* import { safeResolveAsync } from 'node-env-resolver';
|
|
111
|
+
* import { postgres } from 'node-env-resolver/resolvers';
|
|
112
|
+
* import { awsSecrets, dotenv } from 'node-env-resolver/resolvers';
|
|
113
|
+
*
|
|
112
114
|
* // Works with async resolvers
|
|
113
|
-
* const result = await
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
115
|
+
* const result = await safeResolveAsync({
|
|
116
|
+
* resolvers: [
|
|
117
|
+
* [awsSecrets({ region: 'us-east-1' }), { PORT: 3000, DATABASE_URL: postgres() }]
|
|
118
|
+
* ]
|
|
119
|
+
* });
|
|
117
120
|
*
|
|
118
121
|
* // Also works with sync resolvers
|
|
119
|
-
* const result = await
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
122
|
+
* const result = await safeResolveAsync({
|
|
123
|
+
* resolvers: [
|
|
124
|
+
* [processEnv(), { PORT: 3000 }]
|
|
125
|
+
* ]
|
|
126
|
+
* });
|
|
123
127
|
*
|
|
124
|
-
* // Multiple resolvers
|
|
125
|
-
* const result = await
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
128
|
+
* // Multiple resolvers - supports unlimited tuples!
|
|
129
|
+
* const result = await safeResolveAsync({
|
|
130
|
+
* resolvers: [
|
|
131
|
+
* [dotenv(), { PORT: 3000 }],
|
|
132
|
+
* [awsSecrets(), { DATABASE_URL: postgres() }]
|
|
133
|
+
* ],
|
|
134
|
+
* options: { strict: true }
|
|
135
|
+
* });
|
|
130
136
|
*
|
|
131
137
|
* if (result.success) {
|
|
132
138
|
* console.log(result.data.PORT); // Type-safe access
|
|
@@ -135,7 +141,8 @@ declare namespace safeResolveImpl {
|
|
|
135
141
|
* }
|
|
136
142
|
* ```
|
|
137
143
|
*/
|
|
138
|
-
declare function safeResolveAsync<T extends SimpleEnvSchema>(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
144
|
+
declare function safeResolveAsync<T extends SimpleEnvSchema>(config: ResolveAsyncConfig<T>): Promise<SafeResolveResultType<{
|
|
145
|
+
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
146
|
+
}>>;
|
|
147
|
+
|
|
148
|
+
export { ResolveAsyncConfig, ResolveConfig, ResolveOptions, Resolver, type SafeResolveError, type SafeResolveResult, type SafeResolveResultType, SimpleEnvSchema, SyncResolver, resolve, resolveAsync, safeResolve, safeResolveAsync };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as
|
|
1
|
+
export{a as resolve,b as resolveAsync,c as safeResolve,d as safeResolveAsync}from'./chunk-XJLMVSPN.js';import'./chunk-DIXI6MUB.js';export{d as clearAuditLog,c as getAuditLog}from'./chunk-YOHHFBZN.js';import'./chunk-WKIPEKF6.js';export{b as isAsyncOnlyResolver,a as isSyncResolver}from'./chunk-HHOS5S5T.js';import'./chunk-5PELJRUQ.js';
|
package/dist/resolver.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunk4YVXFL3I_cjs=require('./chunk-4YVXFL3I.cjs');require('./chunk-4ZOF2PI4.cjs'),require('./chunk-KIQXH265.cjs');Object.defineProperty(exports,"normalizeSchema",{enumerable:true,get:function(){return chunk4YVXFL3I_cjs.a}});Object.defineProperty(exports,"resolveEnvInternal",{enumerable:true,get:function(){return chunk4YVXFL3I_cjs.b}});Object.defineProperty(exports,"resolveEnvInternalSync",{enumerable:true,get:function(){return chunk4YVXFL3I_cjs.c}});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SimpleEnvSchema, EnvSchema, Resolver, ResolveOptions } from './types.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Internal resolver functions - extracted for use by both old and new APIs
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Convert simplified schema to standard EnvSchema
|
|
9
|
+
*/
|
|
10
|
+
declare function normalizeSchema(schema: SimpleEnvSchema): EnvSchema;
|
|
11
|
+
/**
|
|
12
|
+
* Internal resolver - used by both old resolve() and new env() APIs
|
|
13
|
+
*/
|
|
14
|
+
declare function resolveEnvInternal<T extends EnvSchema>(schema: T, resolvers: Resolver[], options: ResolveOptions): Promise<Record<string, unknown>>;
|
|
15
|
+
/**
|
|
16
|
+
* Internal sync resolver
|
|
17
|
+
*/
|
|
18
|
+
declare function resolveEnvInternalSync<T extends EnvSchema>(schema: T, resolvers: Resolver[], options: ResolveOptions): Record<string, unknown>;
|
|
19
|
+
|
|
20
|
+
export { normalizeSchema, resolveEnvInternal, resolveEnvInternalSync };
|
package/dist/resolver.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
+
import { SimpleEnvSchema, EnvSchema, Resolver, ResolveOptions } from './types.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Internal resolver functions - extracted for use by both old and new APIs
|
|
3
5
|
*/
|
|
4
|
-
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* Convert simplified schema to standard EnvSchema
|
|
7
9
|
*/
|
|
8
|
-
|
|
10
|
+
declare function normalizeSchema(schema: SimpleEnvSchema): EnvSchema;
|
|
9
11
|
/**
|
|
10
12
|
* Internal resolver - used by both old resolve() and new env() APIs
|
|
11
13
|
*/
|
|
12
|
-
|
|
14
|
+
declare function resolveEnvInternal<T extends EnvSchema>(schema: T, resolvers: Resolver[], options: ResolveOptions): Promise<Record<string, unknown>>;
|
|
13
15
|
/**
|
|
14
16
|
* Internal sync resolver
|
|
15
17
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
declare function resolveEnvInternalSync<T extends EnvSchema>(schema: T, resolvers: Resolver[], options: ResolveOptions): Record<string, unknown>;
|
|
19
|
+
|
|
20
|
+
export { normalizeSchema, resolveEnvInternal, resolveEnvInternalSync };
|
package/dist/resolver.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as normalizeSchema,b as resolveEnvInternal,c as resolveEnvInternalSync}from'./chunk-
|
|
1
|
+
export{a as normalizeSchema,b as resolveEnvInternal,c as resolveEnvInternalSync}from'./chunk-DIXI6MUB.js';import'./chunk-YOHHFBZN.js';import'./chunk-5PELJRUQ.js';
|
package/dist/resolvers.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkXPL5XLTA_cjs=require('./chunk-XPL5XLTA.cjs'),chunk4QOKRJ3F_cjs=require('./chunk-4QOKRJ3F.cjs');require('./chunk-KIQXH265.cjs');Object.defineProperty(exports,"boolean",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.j}});Object.defineProperty(exports,"custom",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.z}});Object.defineProperty(exports,"date",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.A}});Object.defineProperty(exports,"dotenv",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.a}});Object.defineProperty(exports,"duration",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.w}});Object.defineProperty(exports,"email",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.l}});Object.defineProperty(exports,"enums",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.v}});Object.defineProperty(exports,"file",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.x}});Object.defineProperty(exports,"http",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.c}});Object.defineProperty(exports,"https",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.r}});Object.defineProperty(exports,"json",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.d}});Object.defineProperty(exports,"mongodb",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.p}});Object.defineProperty(exports,"mysql",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.o}});Object.defineProperty(exports,"number",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.i}});Object.defineProperty(exports,"numberArray",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.t}});Object.defineProperty(exports,"packageJson",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.b}});Object.defineProperty(exports,"port",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.m}});Object.defineProperty(exports,"postgres",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.n}});Object.defineProperty(exports,"redis",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.q}});Object.defineProperty(exports,"secret",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.y}});Object.defineProperty(exports,"secrets",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.e}});Object.defineProperty(exports,"string",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.h}});Object.defineProperty(exports,"stringArray",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.s}});Object.defineProperty(exports,"timestamp",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.B}});Object.defineProperty(exports,"toml",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.g}});Object.defineProperty(exports,"url",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.k}});Object.defineProperty(exports,"urlArray",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.u}});Object.defineProperty(exports,"yaml",{enumerable:true,get:function(){return chunkXPL5XLTA_cjs.f}});Object.defineProperty(exports,"processEnv",{enumerable:true,get:function(){return chunk4QOKRJ3F_cjs.a}});
|