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.
Files changed (111) hide show
  1. package/README.md +493 -376
  2. package/dist/audit.d.cts +29 -0
  3. package/dist/audit.d.ts +8 -7
  4. package/dist/builder.cjs +1 -1
  5. package/dist/builder.d.cts +149 -0
  6. package/dist/builder.d.ts +17 -14
  7. package/dist/builder.js +1 -1
  8. package/dist/chunk-4QOKRJ3F.cjs +1 -0
  9. package/dist/chunk-4YVXFL3I.cjs +9 -0
  10. package/dist/chunk-6D5APQIG.cjs +1 -0
  11. package/dist/chunk-DIXI6MUB.js +9 -0
  12. package/dist/chunk-FH54ESWI.cjs +9 -0
  13. package/dist/chunk-HHOS5S5T.js +1 -0
  14. package/dist/chunk-TAX63ALN.js +16 -0
  15. package/dist/chunk-WKIPEKF6.js +1 -0
  16. package/dist/chunk-XJLMVSPN.js +9 -0
  17. package/dist/chunk-XPL5XLTA.cjs +16 -0
  18. package/dist/cli.d.cts +52 -0
  19. package/dist/cli.d.ts +9 -6
  20. package/dist/index.cjs +1 -1
  21. package/dist/index.d.cts +148 -0
  22. package/dist/index.d.ts +99 -92
  23. package/dist/index.js +1 -1
  24. package/dist/resolver.cjs +1 -1
  25. package/dist/resolver.d.cts +20 -0
  26. package/dist/resolver.d.ts +8 -5
  27. package/dist/resolver.js +1 -1
  28. package/dist/resolvers.cjs +1 -1
  29. package/dist/resolvers.d.cts +412 -0
  30. package/dist/resolvers.d.ts +294 -22
  31. package/dist/resolvers.js +1 -1
  32. package/dist/types.cjs +1 -1
  33. package/dist/types.d.cts +106 -0
  34. package/dist/types.d.ts +90 -172
  35. package/dist/types.js +1 -1
  36. package/dist/utils.cjs +1 -1
  37. package/dist/utils.d.cts +213 -0
  38. package/dist/utils.d.ts +28 -26
  39. package/dist/utils.js +1 -1
  40. package/dist/valibot.cjs +1 -1
  41. package/dist/valibot.d.cts +156 -0
  42. package/dist/valibot.d.ts +11 -8
  43. package/dist/valibot.js +1 -1
  44. package/dist/validation-types.d.cts +29 -0
  45. package/dist/validation-types.d.ts +4 -3
  46. package/dist/validators.cjs +2 -1
  47. package/dist/validators.d.cts +116 -0
  48. package/dist/validators.d.ts +46 -18
  49. package/dist/validators.js +2 -1
  50. package/dist/web.cjs +3 -3
  51. package/dist/web.d.cts +69 -0
  52. package/dist/web.d.ts +28 -10
  53. package/dist/web.js +3 -3
  54. package/dist/zod.cjs +1 -1
  55. package/dist/zod.d.cts +135 -0
  56. package/dist/zod.d.ts +11 -8
  57. package/dist/zod.js +1 -1
  58. package/package.json +7 -7
  59. package/dist/advanced-features.test.d.ts +0 -2
  60. package/dist/advanced-features.test.d.ts.map +0 -1
  61. package/dist/audit.d.ts.map +0 -1
  62. package/dist/audit.test.d.ts +0 -2
  63. package/dist/audit.test.d.ts.map +0 -1
  64. package/dist/builder.d.ts.map +0 -1
  65. package/dist/chunk-54OHKWZJ.js +0 -1
  66. package/dist/chunk-FCFDGYTF.cjs +0 -15
  67. package/dist/chunk-HCVTYYLE.js +0 -9
  68. package/dist/chunk-IU5TG3HL.js +0 -15
  69. package/dist/chunk-J7ZHEMRP.js +0 -9
  70. package/dist/chunk-NKPXKLF7.js +0 -1
  71. package/dist/chunk-P3ZWKKKW.cjs +0 -1
  72. package/dist/chunk-THFGEKYL.cjs +0 -9
  73. package/dist/chunk-ULL4WKTV.cjs +0 -9
  74. package/dist/chunk-XPGSWVRT.cjs +0 -1
  75. package/dist/cli.d.ts.map +0 -1
  76. package/dist/cli.test.d.ts +0 -2
  77. package/dist/cli.test.d.ts.map +0 -1
  78. package/dist/composition.test.d.ts +0 -7
  79. package/dist/composition.test.d.ts.map +0 -1
  80. package/dist/computed.test.d.ts +0 -2
  81. package/dist/computed.test.d.ts.map +0 -1
  82. package/dist/index.d.ts.map +0 -1
  83. package/dist/index.test.d.ts +0 -2
  84. package/dist/index.test.d.ts.map +0 -1
  85. package/dist/nested.test.d.ts +0 -2
  86. package/dist/nested.test.d.ts.map +0 -1
  87. package/dist/performance.test.d.ts +0 -7
  88. package/dist/performance.test.d.ts.map +0 -1
  89. package/dist/priority.test.d.ts +0 -6
  90. package/dist/priority.test.d.ts.map +0 -1
  91. package/dist/providers.d.ts +0 -11
  92. package/dist/providers.d.ts.map +0 -1
  93. package/dist/resolver.d.ts.map +0 -1
  94. package/dist/resolvers.d.ts.map +0 -1
  95. package/dist/resolvers.test.d.ts +0 -2
  96. package/dist/resolvers.test.d.ts.map +0 -1
  97. package/dist/sync-resolvers.test.d.ts +0 -2
  98. package/dist/sync-resolvers.test.d.ts.map +0 -1
  99. package/dist/type-inference.test.d.ts +0 -2
  100. package/dist/type-inference.test.d.ts.map +0 -1
  101. package/dist/type-override.test.d.ts +0 -2
  102. package/dist/type-override.test.d.ts.map +0 -1
  103. package/dist/types.d.ts.map +0 -1
  104. package/dist/utils.d.ts.map +0 -1
  105. package/dist/utils.test.d.ts +0 -2
  106. package/dist/utils.test.d.ts.map +0 -1
  107. package/dist/valibot.d.ts.map +0 -1
  108. package/dist/validation-types.d.ts.map +0 -1
  109. package/dist/validators.d.ts.map +0 -1
  110. package/dist/web.d.ts.map +0 -1
  111. 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 resolve.async(
17
+ * const config = await resolveAsync(
16
18
  * [cliArgs(), {
17
19
  * PORT: 3000,
18
- * DATABASE_URL: 'postgres',
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
- import type { Resolver } from './types';
28
- export interface CliArgsOptions {
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
- export declare function cliArgs(options?: CliArgsOptions): Resolver;
49
- //# sourceMappingURL=cli.d.ts.map
50
+ declare function cliArgs(options?: CliArgsOptions): Resolver;
51
+
52
+ export { type CliArgsOptions, cliArgs };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var chunkTHFGEKYL_cjs=require('./chunk-THFGEKYL.cjs');require('./chunk-ULL4WKTV.cjs'),require('./chunk-XPGSWVRT.cjs');var chunk4ZOF2PI4_cjs=require('./chunk-4ZOF2PI4.cjs'),chunkP3ZWKKKW_cjs=require('./chunk-P3ZWKKKW.cjs');require('./chunk-KIQXH265.cjs');Object.defineProperty(exports,"processEnv",{enumerable:true,get:function(){return chunkTHFGEKYL_cjs.a}});Object.defineProperty(exports,"resolve",{enumerable:true,get:function(){return chunkTHFGEKYL_cjs.b}});Object.defineProperty(exports,"safeResolve",{enumerable:true,get:function(){return chunkTHFGEKYL_cjs.c}});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 chunkP3ZWKKKW_cjs.b}});Object.defineProperty(exports,"isSyncResolver",{enumerable:true,get:function(){return chunkP3ZWKKKW_cjs.a}});
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}});
@@ -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 = await resolve({
14
+ * const config = resolve({
9
15
  * PORT: 3000, // number with default
10
- * DATABASE_URL: 'url', // required secret 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: 'string?', // optional string
19
+ * API_KEY: string({optional: true}), // optional string
14
20
  * });
15
21
  * ```
16
22
  */
17
- import type { Resolver, SyncResolver, ResolveOptions, SimpleEnvSchema, InferSimpleSchema } from './types';
18
- export type { EnvDefinition, EnvSchema, Resolver, SyncResolver, AsyncOnlyResolver, ResolveOptions, Provenance, PolicyOptions, SimpleEnvValue, SimpleEnvSchema, InferType, InferSchema, InferSimpleSchema, } from './types';
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
- export interface SafeResolveError {
28
+ interface SafeResolveError {
28
29
  success: false;
29
30
  error: string;
30
31
  errors?: string[];
31
32
  }
32
- export type SafeResolveResultType<T> = SafeResolveResult<T> | SafeResolveError;
33
- /**
34
- * Resolve environment variables synchronously
35
- *
36
- * @example
37
- * ```typescript
38
- * // Simple usage - process.env only (default)
39
- * const config = resolve({
40
- * PORT: 3000, // number with default
41
- * DATABASE_URL: 'url', // required secret url
42
- * NODE_ENV: ['dev', 'prod'], // enum
43
- * FEATURE_FLAG: 'string?', // optional string
44
- * });
45
- *
46
- * // With custom sync resolver - array syntax
47
- * const config = resolve([
48
- * processEnv(),
49
- * { PORT: 3000, NODE_ENV: ['dev', 'prod'] }
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 resolve.async([
83
- * awsSecrets(),
84
- * { PORT: 3000, DATABASE_URL: 'url', API_KEY: 'string' }
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 resolve.async([
89
- * processEnv(), // Sync resolver works in async context
90
- * { DATABASE_URL: 'postgres' }
91
- * ], { strict: true });
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 resolve.async(
95
- * [dotenv(), { PORT: 3000 }],
96
- * [awsSecrets(), { DATABASE_URL: 'url' }],
97
- * { strict: true }
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>(arg1: [Resolver, T] | Partial<ResolveOptions>, ...rest: ([Resolver, T] | Partial<ResolveOptions>)[]): Promise<InferSimpleSchema<T>>;
102
- declare function safeResolveImpl<T extends SimpleEnvSchema>(arg1: T | [SyncResolver, T], ...rest: ([SyncResolver, T] | Partial<ResolveOptions>)[]): SafeResolveResultType<InferSimpleSchema<T>>;
103
- declare namespace safeResolveImpl {
104
- var async: typeof safeResolveAsync;
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 safeResolve.async([
114
- * awsSecrets({ region: 'us-east-1' }),
115
- * { PORT: 3000, DATABASE_URL: 'url' }
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 safeResolve.async([
120
- * processEnv(), // Sync resolver works fine
121
- * { PORT: 3000 }
122
- * ]);
122
+ * const result = await safeResolveAsync({
123
+ * resolvers: [
124
+ * [processEnv(), { PORT: 3000 }]
125
+ * ]
126
+ * });
123
127
  *
124
- * // Multiple resolvers
125
- * const result = await safeResolve.async(
126
- * [dotenv(), { PORT: 3000 }],
127
- * [awsSecrets(), { DATABASE_URL: 'url' }],
128
- * { strict: true }
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>(arg1: [Resolver, T] | Partial<ResolveOptions>, ...rest: ([Resolver, T] | Partial<ResolveOptions>)[]): Promise<SafeResolveResultType<InferSimpleSchema<T>>>;
139
- export declare const resolve: typeof resolveImpl;
140
- export declare const safeResolve: typeof safeResolveImpl;
141
- //# sourceMappingURL=index.d.ts.map
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 processEnv,b as resolve,c as safeResolve}from'./chunk-HCVTYYLE.js';import'./chunk-J7ZHEMRP.js';import'./chunk-NKPXKLF7.js';export{d as clearAuditLog,c as getAuditLog}from'./chunk-YOHHFBZN.js';export{b as isAsyncOnlyResolver,a as isSyncResolver}from'./chunk-54OHKWZJ.js';import'./chunk-5PELJRUQ.js';
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 chunkULL4WKTV_cjs=require('./chunk-ULL4WKTV.cjs');require('./chunk-XPGSWVRT.cjs'),require('./chunk-4ZOF2PI4.cjs'),require('./chunk-KIQXH265.cjs');Object.defineProperty(exports,"normalizeSchema",{enumerable:true,get:function(){return chunkULL4WKTV_cjs.a}});Object.defineProperty(exports,"resolveEnvInternal",{enumerable:true,get:function(){return chunkULL4WKTV_cjs.b}});Object.defineProperty(exports,"resolveEnvInternalSync",{enumerable:true,get:function(){return chunkULL4WKTV_cjs.c}});
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 };
@@ -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
- import type { Resolver, EnvSchema, SimpleEnvSchema, ResolveOptions } from './types';
6
+
5
7
  /**
6
8
  * Convert simplified schema to standard EnvSchema
7
9
  */
8
- export declare function normalizeSchema(schema: SimpleEnvSchema): EnvSchema;
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
- export declare function resolveEnvInternal<T extends EnvSchema>(schema: T, resolvers: Resolver[], options: ResolveOptions): Promise<Record<string, unknown>>;
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
- export declare function resolveEnvInternalSync<T extends EnvSchema>(schema: T, resolvers: Resolver[], options: ResolveOptions): Record<string, unknown>;
17
- //# sourceMappingURL=resolver.d.ts.map
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-J7ZHEMRP.js';import'./chunk-NKPXKLF7.js';import'./chunk-YOHHFBZN.js';import'./chunk-5PELJRUQ.js';
1
+ export{a as normalizeSchema,b as resolveEnvInternal,c as resolveEnvInternalSync}from'./chunk-DIXI6MUB.js';import'./chunk-YOHHFBZN.js';import'./chunk-5PELJRUQ.js';
@@ -1 +1 @@
1
- 'use strict';var chunkFCFDGYTF_cjs=require('./chunk-FCFDGYTF.cjs');require('./chunk-KIQXH265.cjs');Object.defineProperty(exports,"dotenv",{enumerable:true,get:function(){return chunkFCFDGYTF_cjs.a}});Object.defineProperty(exports,"http",{enumerable:true,get:function(){return chunkFCFDGYTF_cjs.d}});Object.defineProperty(exports,"json",{enumerable:true,get:function(){return chunkFCFDGYTF_cjs.e}});Object.defineProperty(exports,"packageJson",{enumerable:true,get:function(){return chunkFCFDGYTF_cjs.c}});Object.defineProperty(exports,"processEnv",{enumerable:true,get:function(){return chunkFCFDGYTF_cjs.b}});Object.defineProperty(exports,"secrets",{enumerable:true,get:function(){return chunkFCFDGYTF_cjs.f}});Object.defineProperty(exports,"toml",{enumerable:true,get:function(){return chunkFCFDGYTF_cjs.h}});Object.defineProperty(exports,"yaml",{enumerable:true,get:function(){return chunkFCFDGYTF_cjs.g}});
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}});