node-env-resolver 6.5.2 → 6.7.0

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 (115) hide show
  1. package/README.md +186 -11
  2. package/dist/audit.d.ts +7 -8
  3. package/dist/audit.d.ts.map +1 -0
  4. package/dist/builder.cjs +1 -1
  5. package/dist/builder.d.ts +9 -12
  6. package/dist/builder.d.ts.map +1 -0
  7. package/dist/builder.js +1 -1
  8. package/dist/chunk-3TXO5AOZ.cjs +3 -0
  9. package/dist/chunk-4CLWNKB5.js +1 -0
  10. package/dist/chunk-4DUWYBNJ.cjs +6 -0
  11. package/dist/chunk-6NSX37SO.js +6 -0
  12. package/dist/chunk-BITH5LSH.js +3 -0
  13. package/dist/{chunk-DIJNUFGZ.cjs → chunk-G5HNCCR6.cjs} +3 -3
  14. package/dist/chunk-IP6POQCY.cjs +1 -0
  15. package/dist/{chunk-ZSM2NDX5.js → chunk-JVRRDD3Y.js} +3 -3
  16. package/dist/chunk-KHEBSYFP.js +9 -0
  17. package/dist/chunk-NHXSZY2U.cjs +9 -0
  18. package/dist/chunk-NKISCWWB.js +1 -0
  19. package/dist/chunk-UZ7HKTYL.cjs +1 -0
  20. package/dist/cli/bin.cjs +67 -27
  21. package/dist/cli/bin.d.ts +11 -0
  22. package/dist/cli/bin.d.ts.map +1 -0
  23. package/dist/cli/bin.js +67 -27
  24. package/dist/cli/scan.d.ts +24 -0
  25. package/dist/cli/scan.d.ts.map +1 -0
  26. package/dist/cli.d.ts +4 -7
  27. package/dist/cli.d.ts.map +1 -0
  28. package/dist/debug.d.ts +142 -0
  29. package/dist/debug.d.ts.map +1 -0
  30. package/dist/index.cjs +1 -1
  31. package/dist/index.d.ts +19 -61
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +1 -1
  34. package/dist/inspect.d.ts +63 -0
  35. package/dist/inspect.d.ts.map +1 -0
  36. package/dist/process-env.d.ts +32 -0
  37. package/dist/process-env.d.ts.map +1 -0
  38. package/dist/provider-kit.cjs +2 -0
  39. package/dist/provider-kit.d.ts +49 -0
  40. package/dist/provider-kit.d.ts.map +1 -0
  41. package/dist/provider-kit.js +2 -0
  42. package/dist/providers.d.ts +49 -0
  43. package/dist/providers.d.ts.map +1 -0
  44. package/dist/references.d.ts +5 -0
  45. package/dist/references.d.ts.map +1 -0
  46. package/dist/resolver.cjs +1 -1
  47. package/dist/resolver.d.ts +16 -8
  48. package/dist/resolver.d.ts.map +1 -0
  49. package/dist/resolver.js +1 -1
  50. package/dist/resolvers.cjs +1 -1
  51. package/dist/resolvers.d.ts +13 -31
  52. package/dist/resolvers.d.ts.map +1 -0
  53. package/dist/resolvers.js +1 -1
  54. package/dist/runtime/index.cjs +1 -1
  55. package/dist/runtime/index.d.ts +8 -108
  56. package/dist/runtime/index.d.ts.map +1 -0
  57. package/dist/runtime/index.js +1 -1
  58. package/dist/runtime/patch-console.d.ts +23 -0
  59. package/dist/runtime/patch-console.d.ts.map +1 -0
  60. package/dist/runtime/redactor.d.ts +22 -0
  61. package/dist/runtime/redactor.d.ts.map +1 -0
  62. package/dist/runtime/response.d.ts +59 -0
  63. package/dist/runtime/response.d.ts.map +1 -0
  64. package/dist/security.d.ts +49 -0
  65. package/dist/security.d.ts.map +1 -0
  66. package/dist/sensitivity.d.ts +34 -0
  67. package/dist/sensitivity.d.ts.map +1 -0
  68. package/dist/types.d.ts +150 -1
  69. package/dist/types.d.ts.map +1 -0
  70. package/dist/utils.cjs +1 -1
  71. package/dist/utils.d.ts +19 -21
  72. package/dist/utils.d.ts.map +1 -0
  73. package/dist/utils.js +1 -1
  74. package/dist/valibot.cjs +1 -1
  75. package/dist/valibot.d.ts +9 -11
  76. package/dist/valibot.d.ts.map +1 -0
  77. package/dist/valibot.js +1 -1
  78. package/dist/validation-types.d.ts +3 -4
  79. package/dist/validation-types.d.ts.map +1 -0
  80. package/dist/validators.cjs +2 -2
  81. package/dist/validators.d.ts +59 -44
  82. package/dist/validators.d.ts.map +1 -0
  83. package/dist/validators.js +2 -2
  84. package/dist/web.cjs +3 -3
  85. package/dist/web.d.ts +8 -10
  86. package/dist/web.d.ts.map +1 -0
  87. package/dist/web.js +3 -3
  88. package/dist/zod.cjs +1 -1
  89. package/dist/zod.d.ts +9 -11
  90. package/dist/zod.d.ts.map +1 -0
  91. package/dist/zod.js +1 -1
  92. package/package.json +15 -16
  93. package/dist/audit.d.cts +0 -52
  94. package/dist/builder.d.cts +0 -149
  95. package/dist/chunk-3EWCMDFP.js +0 -9
  96. package/dist/chunk-4QOKRJ3F.cjs +0 -1
  97. package/dist/chunk-DYFRO3NM.cjs +0 -9
  98. package/dist/chunk-K4NIC5T3.js +0 -9
  99. package/dist/chunk-WKIPEKF6.js +0 -1
  100. package/dist/chunk-WVMDTD6J.cjs +0 -9
  101. package/dist/cli/bin.d.cts +0 -1
  102. package/dist/cli.d.cts +0 -52
  103. package/dist/index.d.cts +0 -220
  104. package/dist/resolver.d.cts +0 -20
  105. package/dist/resolvers.d.cts +0 -190
  106. package/dist/runtime/index.d.cts +0 -161
  107. package/dist/types--RcOnfdl.d.cts +0 -284
  108. package/dist/types--RcOnfdl.d.ts +0 -284
  109. package/dist/types.d.cts +0 -1
  110. package/dist/utils.d.cts +0 -327
  111. package/dist/valibot.d.cts +0 -143
  112. package/dist/validation-types.d.cts +0 -29
  113. package/dist/validators.d.cts +0 -933
  114. package/dist/web.d.cts +0 -71
  115. package/dist/zod.d.cts +0 -122
package/dist/utils.d.cts DELETED
@@ -1,327 +0,0 @@
1
- import { resolveAsync } from './index.cjs';
2
- import { a as Resolver } from './types--RcOnfdl.cjs';
3
- import './validation-types.cjs';
4
- import './audit.cjs';
5
-
6
- interface CacheOptions {
7
- /** Time to live in milliseconds (default: 5 minutes) */
8
- ttl?: number;
9
- /** Maximum age in milliseconds before forcing refresh (default: 1 hour) */
10
- maxAge?: number;
11
- /** Enable stale-while-revalidate: serve stale data while refreshing in background */
12
- staleWhileRevalidate?: boolean;
13
- /** Custom cache key (useful for debugging or manual cache invalidation) */
14
- key?: string;
15
- }
16
- /**
17
- * Wrap a resolver with caching functionality
18
- * Provides TTL-based caching with stale-while-revalidate support
19
- *
20
- * @param resolver - Resolver to wrap with caching
21
- * @param options - Cache configuration options
22
- * @returns Cached resolver that implements the same interface
23
- *
24
- * @example
25
- * ```ts
26
- * import { cached, TTL } from 'node-env-resolver/utils';
27
- * import { awsSecrets } from 'node-env-resolver-aws';
28
- *
29
- * // Cache AWS secrets for 5 minutes
30
- * const cachedResolver = cached(
31
- * awsSecrets({ secretId: 'prod/config' }),
32
- * { ttl: TTL.minutes5 }
33
- * );
34
- *
35
- * // With stale-while-revalidate
36
- * const resilientResolver = cached(awsSecrets(), {
37
- * ttl: TTL.minutes5,
38
- * maxAge: TTL.hour,
39
- * staleWhileRevalidate: true
40
- * });
41
- * ```
42
- */
43
- declare function cached(resolver: Resolver, options?: CacheOptions): Resolver;
44
- declare const TTL: {
45
- /** 30 seconds */
46
- readonly short: number;
47
- /** 1 minute */
48
- readonly minute: number;
49
- /** 5 minutes */
50
- readonly minutes5: number;
51
- /** 15 minutes */
52
- readonly minutes15: number;
53
- /** 1 hour */
54
- readonly hour: number;
55
- /** 6 hours */
56
- readonly hours6: number;
57
- /** 24 hours */
58
- readonly day: number;
59
- };
60
- /**
61
- * Helper function to create AWS-friendly cache configuration
62
- * Provides sensible defaults for AWS services (5min TTL, 1hr maxAge, stale-while-revalidate enabled)
63
- *
64
- * @param options - Cache configuration options
65
- * @returns Cache options optimized for AWS services
66
- *
67
- * @example
68
- * ```ts
69
- * import { awsCache } from 'node-env-resolver/utils';
70
- * import { awsSecrets } from 'node-env-resolver-aws';
71
- *
72
- * const resolver = cached(awsSecrets(), awsCache({ ttl: 10 * 60 * 1000 }));
73
- * ```
74
- */
75
- declare function awsCache(options?: {
76
- /** Cache duration for AWS secrets/parameters (default: 5 minutes) */
77
- ttl?: number;
78
- /** Maximum age before forcing refresh (default: 1 hour) */
79
- maxAge?: number;
80
- /** Enable stale-while-revalidate for better performance (default: true) */
81
- staleWhileRevalidate?: boolean;
82
- }): CacheOptions;
83
- /**
84
- * Wrap a resolver with retry functionality
85
- * Automatically retries failed requests with exponential backoff
86
- *
87
- * @param resolver - Resolver to wrap with retry logic
88
- * @param maxRetries - Maximum number of retry attempts (default: 3)
89
- * @param delayMs - Initial delay between retries in milliseconds (default: 1000)
90
- * @returns Resolver with retry functionality
91
- *
92
- * @example
93
- * ```ts
94
- * import { retry } from 'node-env-resolver/utils';
95
- * import { awsSecrets } from 'node-env-resolver-aws';
96
- *
97
- * // Retry up to 5 times with 2 second initial delay
98
- * const resilientResolver = retry(awsSecrets(), 5, 2000);
99
- * ```
100
- */
101
- declare function retry(resolver: Resolver, maxRetries?: number, delayMs?: number): Resolver;
102
- interface PollOptions<T> {
103
- /** Interval between checks in milliseconds (default: 10 seconds) */
104
- intervalMs?: number;
105
- /** Run immediately on start instead of waiting for the first interval */
106
- immediate?: boolean;
107
- /** Called when the value changes after the initial load */
108
- onChange?: (next: T, previous: T | undefined) => void | Promise<void>;
109
- /** Called when polling fails */
110
- onError?: (error: unknown) => void;
111
- /** Custom equality check for change detection */
112
- equals?: (a: T, b: T) => boolean;
113
- }
114
- interface PollHandle<T> {
115
- /** Latest successfully loaded value, if any */
116
- getCurrent: () => T | undefined;
117
- /** Manually trigger a refresh */
118
- refresh: () => Promise<T | undefined>;
119
- /** Stop polling */
120
- stop: () => void;
121
- }
122
- /**
123
- * Poll an async value source and notify when it changes.
124
- * Useful for periodically re-reading remote config such as AWS Secrets Manager.
125
- *
126
- * @param getValue Async function that returns the latest value
127
- * @param options Polling configuration
128
- * @returns Handle for reading the current value and stopping the poller
129
- *
130
- * @example
131
- * ```ts
132
- * import { poll, cached, TTL } from 'node-env-resolver/utils';
133
- * import { awsSecrets } from 'node-env-resolver-aws';
134
- * import { resolveAsync } from 'node-env-resolver';
135
- *
136
- * const getConfig = () => resolveAsync({
137
- * resolvers: [
138
- * [
139
- * cached(awsSecrets({ secretId: 'app/secrets' }), { ttl: TTL.minutes5 }),
140
- * { DATABASE_URL: postgres(), API_KEY: string() }
141
- * ]
142
- * ]
143
- * });
144
- *
145
- * const watcher = poll(getConfig, {
146
- * intervalMs: 10_000,
147
- * onChange: (next, previous) => {
148
- * console.log('Config changed', { previous, next });
149
- * }
150
- * });
151
- *
152
- * process.on('SIGINT', () => watcher.stop());
153
- * ```
154
- */
155
- declare function poll<T>(getValue: () => Promise<T>, options?: PollOptions<T>): PollHandle<T>;
156
- /**
157
- * Wrap a resolver to strip a prefix from environment variable names
158
- * Useful for scoping environment variables (e.g., APP_PORT → PORT)
159
- *
160
- * @param resolver The resolver to wrap
161
- * @param prefix The prefix to strip (case-insensitive)
162
- * @returns Wrapped resolver that strips the prefix
163
- *
164
- * @example
165
- * ```ts
166
- * import { resolve, processEnv } from 'node-env-resolver';
167
- * import { withPrefix } from 'node-env-resolver/utils';
168
- *
169
- * // Maps APP_PORT → PORT, APP_DATABASE_URL → DATABASE_URL
170
- * const config = await resolveAsync(
171
- * [withPrefix(processEnv(), 'APP_'), { PORT: 3000, DATABASE_URL: postgres() }]
172
- * );
173
- * ```
174
- */
175
- declare function withPrefix(resolver: Resolver, prefix: string): Resolver;
176
- /**
177
- * Add computed/derived properties to resolved config
178
- *
179
- * Useful for deriving values from multiple config fields (e.g., building URLs,
180
- * computing feature flags, creating connection objects).
181
- *
182
- * @param config Resolved configuration object
183
- * @param computed Map of computed property names to functions that derive values
184
- * @returns Config with computed properties as getters
185
- *
186
- * @example
187
- * ```ts
188
- * import { resolve } from 'node-env-resolver';
189
- * import { withComputed } from 'node-env-resolver/utils';
190
- *
191
- * const config = withComputed(
192
- * resolve({ HOST: 'localhost', PORT: 3000, NODE_ENV: 'development' }),
193
- * {
194
- * url: (c) => `http://${c.HOST}:${c.PORT}`,
195
- * isDev: (c) => c.NODE_ENV === 'development',
196
- * isSecure: (c) => c.HOST !== 'localhost'
197
- * }
198
- * );
199
- *
200
- * console.log(config.url); // 'http://localhost:3000'
201
- * console.log(config.isDev); // true
202
- * console.log(config.isSecure); // false
203
- * ```
204
- */
205
- declare function withComputed<TConfig extends Record<string, unknown>, TComputed extends Record<string, (config: TConfig) => unknown>>(config: TConfig, computed: TComputed): TConfig & {
206
- [K in keyof TComputed]: ReturnType<TComputed[K]>;
207
- };
208
- /**
209
- * Wrap a resolver to support field aliases (multiple possible names for a config value)
210
- * Tries each alias in order and uses the first one found
211
- *
212
- * @param resolver The resolver to wrap
213
- * @param aliases Map of canonical key to array of possible aliases
214
- * @returns Wrapped resolver that supports aliases
215
- *
216
- * @example
217
- * ```ts
218
- * import { resolve, processEnv } from 'node-env-resolver';
219
- * import { withAliases } from 'node-env-resolver/utils';
220
- *
221
- * // Tries PORT, then HTTP_PORT, then SERVER_PORT (first found wins)
222
- * const config = await resolveAsync(
223
- * [withAliases(processEnv(), {
224
- * PORT: ['PORT', 'HTTP_PORT', 'SERVER_PORT'],
225
- * DATABASE_URL: ['DATABASE_URL', 'DB_URL', 'POSTGRES_URL']
226
- * }), { PORT: 3000, DATABASE_URL: postgres() }]
227
- * );
228
- * ```
229
- */
230
- declare function withAliases(resolver: Resolver, aliases: Record<string, string[]>): Resolver;
231
- /**
232
- * Wrap a resolver to apply custom transformations to values
233
- * Powerful utility for parsing, coercing, or enriching config values
234
- *
235
- * @param resolver The resolver to wrap
236
- * @param transforms Map of keys to transformation functions
237
- * @returns Wrapped resolver that applies transforms
238
- *
239
- * @example
240
- * ```ts
241
- * import { resolve, processEnv } from 'node-env-resolver';
242
- * import { withTransform } from 'node-env-resolver/utils';
243
- *
244
- * const config = await resolveAsync(
245
- * [withTransform(processEnv(), {
246
- * // Parse comma-separated values
247
- * TAGS: (val) => val.split(',').map(s => s.trim()),
248
- * // Convert to URL object
249
- * API_URL: (val) => new URL(val),
250
- * // Custom parsing
251
- * MAX_RETRIES: (val) => Math.min(parseInt(val, 10), 10)
252
- * }), {
253
- * TAGS: string(),
254
- * API_URL: url(),
255
- * MAX_RETRIES: 'number'
256
- * }]
257
- * );
258
- * ```
259
- */
260
- declare function withTransform(resolver: Resolver, transforms: Record<string, (value: string) => string>): Resolver;
261
- /**
262
- * Wrap a resolver to scope all keys to a namespace/prefix
263
- * Similar to withPrefix but adds the namespace instead of removing it
264
- *
265
- * @param resolver The resolver to wrap
266
- * @param namespace The namespace to scope keys under
267
- * @returns Wrapped resolver with scoped keys
268
- *
269
- * @example
270
- * ```ts
271
- * import { resolve, processEnv } from 'node-env-resolver';
272
- * import { withNamespace } from 'node-env-resolver/utils';
273
- *
274
- * // Reads DATABASE_HOST, DATABASE_PORT from env
275
- * // But schema only needs HOST, PORT
276
- * const dbConfig = await resolveAsync(
277
- * [withNamespace(processEnv(), 'DATABASE'), {
278
- * HOST: string(),
279
- * PORT: 'port'
280
- * }]
281
- * );
282
- * // dbConfig: { HOST: '...', PORT: ... }
283
- * ```
284
- */
285
- declare function withNamespace(resolver: Resolver, namespace: string): Resolver;
286
- /**
287
- * Watch configuration files and reload automatically
288
- * Perfect for development - auto-reload when .env files change
289
- *
290
- * @param schema Environment schema definition
291
- * @param resolvers Array of resolvers to use
292
- * @param options Watch options
293
- * @returns Function to get current config + cleanup function
294
- *
295
- * @example
296
- * ```ts
297
- * import { watch } from 'node-env-resolver/utils';
298
- * import { dotenv, processEnv } from 'node-env-resolver/resolvers';
299
- *
300
- * const { getConfig, stop } = watch(
301
- * { PORT: 3000, API_KEY: string() },
302
- * [processEnv(), dotenv()],
303
- * {
304
- * onChange: (config) => console.log('Config reloaded!', config)
305
- * }
306
- * );
307
- *
308
- * // Use in your app
309
- * app.get('/config', () => getConfig());
310
- *
311
- * // Cleanup when done
312
- * process.on('SIGINT', () => stop());
313
- * ```
314
- */
315
- declare function watch<T>(config: Parameters<typeof resolveAsync>[0], options?: {
316
- /** Callback when config changes */
317
- onChange?: (config: T) => void;
318
- /** Debounce delay in ms (default: 100) */
319
- debounce?: number;
320
- /** Files to watch (default: ['.env']) */
321
- files?: string[];
322
- }): {
323
- getConfig: () => T;
324
- stop: () => void;
325
- };
326
-
327
- export { type CacheOptions, type PollHandle, type PollOptions, TTL, awsCache, cached, poll, retry, watch, withAliases, withComputed, withNamespace, withPrefix, withTransform };
@@ -1,143 +0,0 @@
1
- import { a as Resolver, P as PolicyOptions, b as ReferenceOptions } from './types--RcOnfdl.cjs';
2
- import { SafeResolveResult } from './validation-types.cjs';
3
-
4
- /**
5
- * Valibot integration for node-env-resolver
6
- * Import from 'node-env-resolver/valibot' to use this
7
- *
8
- * @example
9
- * ```ts
10
- * import { resolveValibot } from 'node-env-resolver/valibot';
11
- * import * as v from 'valibot';
12
- *
13
- * const schema = v.object({
14
- * PORT: v.pipe(v.string(), v.transform(Number)),
15
- * DATABASE_URL: v.pipe(v.string(), v.url())
16
- * });
17
- *
18
- * const config = await resolveValibot(schema);
19
- * ```
20
- */
21
-
22
- type ResolveValibotOptions = {
23
- resolvers?: Resolver[];
24
- interpolate?: boolean;
25
- strict?: boolean;
26
- policies?: PolicyOptions;
27
- references?: ReferenceOptions;
28
- };
29
- /**
30
- * Type inference for Valibot schema output
31
- * Uses Valibot's InferOutput if available, falls back to generic inference
32
- */
33
- type InferValibotOutput<T> = T extends {
34
- _types?: {
35
- output: infer O;
36
- };
37
- } ? O : T extends {
38
- parse: (input: unknown) => infer R;
39
- } ? R : unknown;
40
- /**
41
- * Resolve environment variables using Valibot schema (throws on validation error)
42
- *
43
- * @example
44
- * ```ts
45
- * import { resolveValibot } from 'node-env-resolver/valibot';
46
- * import * as v from 'valibot';
47
- *
48
- * const schema = v.object({
49
- * PORT: v.pipe(v.string(), v.transform(Number)),
50
- * DATABASE_URL: v.pipe(v.string(), v.url())
51
- * });
52
- *
53
- * const env = await resolveValibot(schema);
54
- * console.log(env.PORT); // number
55
- * ```
56
- */
57
- declare function resolveValibot<TSchema extends {
58
- parseAsync: (input: unknown) => Promise<unknown>;
59
- }>(valibotSchema: TSchema, options?: ResolveValibotOptions): Promise<InferValibotOutput<TSchema>>;
60
- /**
61
- * Safe version - returns result object instead of throwing (unified error format)
62
- *
63
- * @example
64
- * ```ts
65
- * import { safeResolveValibot } from 'node-env-resolver/valibot';
66
- * import * as v from 'valibot';
67
- *
68
- * const schema = v.object({
69
- * PORT: v.pipe(v.string(), v.transform(Number)),
70
- * DATABASE_URL: v.pipe(v.string(), v.url())
71
- * });
72
- *
73
- * const result = await safeResolveValibot(schema);
74
- *
75
- * if (result.success) {
76
- * console.log(result.data.PORT);
77
- * } else {
78
- * console.error(result.error);
79
- * result.issues.forEach(issue => {
80
- * console.log(`${issue.path.join('.')}: ${issue.message}`);
81
- * });
82
- * }
83
- * ```
84
- */
85
- declare function safeResolveValibot<TSchema extends {
86
- safeParseAsync: (input: unknown) => Promise<{
87
- success: boolean;
88
- output?: unknown;
89
- issues?: unknown;
90
- }>;
91
- }>(valibotSchema: TSchema, options?: ResolveValibotOptions): Promise<SafeResolveResult<InferValibotOutput<TSchema>>>;
92
- /**
93
- * Sync version of resolveValibot (throws on validation error)
94
- *
95
- * @example
96
- * ```ts
97
- * import { resolveSyncValibot } from 'node-env-resolver/valibot';
98
- * import * as v from 'valibot';
99
- *
100
- * const schema = v.object({
101
- * PORT: v.pipe(v.string(), v.transform(Number))
102
- * });
103
- *
104
- * const env = resolveSyncValibot(schema);
105
- * console.log(env.PORT);
106
- * ```
107
- */
108
- declare function resolveSyncValibot<TSchema extends {
109
- parse: (input: unknown) => unknown;
110
- }>(valibotSchema: TSchema, options?: ResolveValibotOptions): InferValibotOutput<TSchema>;
111
- /**
112
- * Safe sync version - returns result object instead of throwing (unified error format)
113
- *
114
- * @example
115
- * ```ts
116
- * import { safeResolveSyncValibot } from 'node-env-resolver/valibot';
117
- * import * as v from 'valibot';
118
- *
119
- * const schema = v.object({
120
- * PORT: v.pipe(v.string(), v.transform(Number))
121
- * });
122
- *
123
- * const result = safeResolveSyncValibot(schema);
124
- *
125
- * if (result.success) {
126
- * console.log(result.data.PORT);
127
- * } else {
128
- * console.error(result.error);
129
- * result.issues.forEach(issue => {
130
- * console.log(`${issue.path.join('.')}: ${issue.message}`);
131
- * });
132
- * }
133
- * ```
134
- */
135
- declare function safeResolveSyncValibot<TSchema extends {
136
- safeParse: (input: unknown) => {
137
- success: boolean;
138
- output?: unknown;
139
- issues?: unknown;
140
- };
141
- }>(valibotSchema: TSchema, options?: ResolveValibotOptions): SafeResolveResult<InferValibotOutput<TSchema>>;
142
-
143
- export { type InferValibotOutput, resolveSyncValibot, resolveValibot, safeResolveSyncValibot, safeResolveValibot };
@@ -1,29 +0,0 @@
1
- /**
2
- * Unified validation types for all integrations (Zod, Valibot, etc.)
3
- * These types compile away at runtime (0 bytes)
4
- */
5
- /**
6
- * Represents a single validation issue with field-level details
7
- */
8
- interface ValidationIssue {
9
- /** Path to the field that failed validation, e.g. ['DATABASE_URL'] or ['user', 'email'] */
10
- path: (string | number)[];
11
- /** Human-readable error message */
12
- message: string;
13
- /** Optional error code for programmatic handling, e.g. 'invalid_url', 'required' */
14
- code?: string;
15
- }
16
- /**
17
- * Result type for safe resolve functions
18
- * Consistent across all validators (Zod, Valibot, built-in)
19
- */
20
- type SafeResolveResult<T> = {
21
- success: true;
22
- data: T;
23
- } | {
24
- success: false;
25
- error: string;
26
- issues: ValidationIssue[];
27
- };
28
-
29
- export type { SafeResolveResult, ValidationIssue };