node-env-resolver 6.4.0 → 6.5.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.
- package/README.md +73 -0
- package/dist/builder.cjs +1 -1
- package/dist/builder.js +1 -1
- package/dist/chunk-2IQQVAXA.cjs +9 -0
- package/dist/chunk-46CBATKM.js +1 -0
- package/dist/{chunk-4TODB2KY.js → chunk-C34FGZOG.js} +1 -1
- package/dist/chunk-FNF55TN4.cjs +1 -0
- package/dist/chunk-G36OESVW.cjs +1 -0
- package/dist/chunk-I5UKYTX6.js +1 -0
- package/dist/chunk-MFFH2ZXS.js +17 -0
- package/dist/chunk-QCKMQEJP.cjs +17 -0
- package/dist/{chunk-OX54K5J5.cjs → chunk-S7AB6UX7.cjs} +3 -3
- package/dist/chunk-TGIYWWDY.js +9 -0
- package/dist/chunk-VUUPIWFJ.js +9 -0
- package/dist/chunk-ZDRU3RSU.cjs +9 -0
- package/dist/cli-main.cjs +4 -0
- package/dist/cli-main.d.cts +1 -0
- package/dist/cli-main.d.ts +1 -0
- package/dist/cli-main.js +4 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/redaction.cjs +1 -0
- package/dist/redaction.d.cts +54 -0
- package/dist/redaction.d.ts +54 -0
- package/dist/redaction.js +1 -0
- package/dist/resolver.cjs +1 -1
- package/dist/resolver.js +1 -1
- package/dist/resolvers.cjs +1 -1
- package/dist/resolvers.d.cts +26 -1
- package/dist/resolvers.d.ts +26 -1
- package/dist/resolvers.js +1 -1
- package/dist/typegen.cjs +1 -0
- package/dist/typegen.d.cts +52 -0
- package/dist/typegen.d.ts +52 -0
- package/dist/typegen.js +1 -0
- package/dist/types.cjs +1 -1
- package/dist/types.d.cts +16 -2
- package/dist/types.d.ts +16 -2
- package/dist/types.js +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.cts +12 -2
- package/dist/utils.d.ts +12 -2
- package/dist/utils.js +1 -1
- package/dist/valibot.cjs +1 -1
- package/dist/valibot.js +1 -1
- package/dist/validators.cjs +2 -2
- package/dist/validators.d.cts +47 -24
- package/dist/validators.d.ts +47 -24
- package/dist/validators.js +2 -2
- package/dist/web.cjs +3 -3
- package/dist/web.js +1 -1
- package/dist/zod.cjs +1 -1
- package/dist/zod.js +1 -1
- package/package.json +30 -6
- package/dist/chunk-4KFQR5TJ.js +0 -9
- package/dist/chunk-6D5APQIG.cjs +0 -1
- package/dist/chunk-DCAD54W2.js +0 -15
- package/dist/chunk-GMN7ADP3.cjs +0 -9
- package/dist/chunk-HHOS5S5T.js +0 -1
- package/dist/chunk-UQW24J5O.cjs +0 -15
package/dist/resolvers.d.cts
CHANGED
|
@@ -186,5 +186,30 @@ interface TomlOptions {
|
|
|
186
186
|
* ```
|
|
187
187
|
*/
|
|
188
188
|
declare function toml(options?: string | TomlOptions): Resolver;
|
|
189
|
+
interface ExecResolverOptions {
|
|
190
|
+
/**
|
|
191
|
+
* Output format to parse from stdout.
|
|
192
|
+
* - 'env': KEY=VALUE lines
|
|
193
|
+
* - 'json': JSON object (optionally nested)
|
|
194
|
+
*
|
|
195
|
+
* Default: 'env'
|
|
196
|
+
*/
|
|
197
|
+
format?: 'env' | 'json';
|
|
198
|
+
/**
|
|
199
|
+
* Maximum time in milliseconds before killing the process.
|
|
200
|
+
* Default: 5000ms
|
|
201
|
+
*/
|
|
202
|
+
timeout?: number;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Execute a shell command and load configuration from its stdout.
|
|
206
|
+
*
|
|
207
|
+
* Supports two formats:
|
|
208
|
+
* - 'env': KEY=VALUE lines (one per line)
|
|
209
|
+
* - 'json': JSON object (optionally nested, flattened to UPPER_SNAKE_CASE)
|
|
210
|
+
*
|
|
211
|
+
* Both async and sync modes are supported via exec/execSync.
|
|
212
|
+
*/
|
|
213
|
+
declare function exec(command: string, options?: ExecResolverOptions): SyncResolver;
|
|
189
214
|
|
|
190
|
-
export { type DotenvOptions, type TomlOptions, type YamlOptions, dotenv, http, json, packageJson, processEnv, secrets, toml, yaml };
|
|
215
|
+
export { type DotenvOptions, type ExecResolverOptions, type TomlOptions, type YamlOptions, dotenv, exec, http, json, packageJson, processEnv, secrets, toml, yaml };
|
package/dist/resolvers.d.ts
CHANGED
|
@@ -186,5 +186,30 @@ interface TomlOptions {
|
|
|
186
186
|
* ```
|
|
187
187
|
*/
|
|
188
188
|
declare function toml(options?: string | TomlOptions): Resolver;
|
|
189
|
+
interface ExecResolverOptions {
|
|
190
|
+
/**
|
|
191
|
+
* Output format to parse from stdout.
|
|
192
|
+
* - 'env': KEY=VALUE lines
|
|
193
|
+
* - 'json': JSON object (optionally nested)
|
|
194
|
+
*
|
|
195
|
+
* Default: 'env'
|
|
196
|
+
*/
|
|
197
|
+
format?: 'env' | 'json';
|
|
198
|
+
/**
|
|
199
|
+
* Maximum time in milliseconds before killing the process.
|
|
200
|
+
* Default: 5000ms
|
|
201
|
+
*/
|
|
202
|
+
timeout?: number;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Execute a shell command and load configuration from its stdout.
|
|
206
|
+
*
|
|
207
|
+
* Supports two formats:
|
|
208
|
+
* - 'env': KEY=VALUE lines (one per line)
|
|
209
|
+
* - 'json': JSON object (optionally nested, flattened to UPPER_SNAKE_CASE)
|
|
210
|
+
*
|
|
211
|
+
* Both async and sync modes are supported via exec/execSync.
|
|
212
|
+
*/
|
|
213
|
+
declare function exec(command: string, options?: ExecResolverOptions): SyncResolver;
|
|
189
214
|
|
|
190
|
-
export { type DotenvOptions, type TomlOptions, type YamlOptions, dotenv, http, json, packageJson, processEnv, secrets, toml, yaml };
|
|
215
|
+
export { type DotenvOptions, type ExecResolverOptions, type TomlOptions, type YamlOptions, dotenv, exec, http, json, packageJson, processEnv, secrets, toml, yaml };
|
package/dist/resolvers.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as dotenv,c as http,d as json,b as packageJson,e as secrets,g as toml,f as yaml}from'./chunk-
|
|
1
|
+
export{a as dotenv,h as exec,c as http,d as json,b as packageJson,e as secrets,g as toml,f as yaml}from'./chunk-MFFH2ZXS.js';export{a as processEnv}from'./chunk-WKIPEKF6.js';import'./chunk-I7AUKTXE.js';
|
package/dist/typegen.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkZDRU3RSU_cjs=require('./chunk-ZDRU3RSU.cjs');require('./chunk-D6WM53FN.cjs');Object.defineProperty(exports,"generateTypes",{enumerable:true,get:function(){return chunkZDRU3RSU_cjs.a}});Object.defineProperty(exports,"writeTypes",{enumerable:true,get:function(){return chunkZDRU3RSU_cjs.b}});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { SimpleEnvSchema } from './types.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Best-effort TypeScript type generation from env schemas.
|
|
5
|
+
*
|
|
6
|
+
* Generated types represent the **coerced output schema** (what resolve() returns).
|
|
7
|
+
* process.env augmentations remain string-ish at runtime — these are convenience,
|
|
8
|
+
* not enforcement. Edge cases (custom validators, complex compositions) fall back
|
|
9
|
+
* to `string`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { generateTypes, writeTypes } from 'node-env-resolver/typegen';
|
|
14
|
+
* import { string, number, oneOf, sensitive } from 'node-env-resolver/validators';
|
|
15
|
+
*
|
|
16
|
+
* const schema = {
|
|
17
|
+
* PORT: number({ default: 3000, description: 'Server port' }),
|
|
18
|
+
* API_KEY: sensitive(string({ description: 'API key for external service' })),
|
|
19
|
+
* NODE_ENV: oneOf(['development', 'production', 'test'] as const),
|
|
20
|
+
* };
|
|
21
|
+
*
|
|
22
|
+
* const types = generateTypes(schema);
|
|
23
|
+
* writeTypes(schema, './env.d.ts');
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
interface TypegenOptions {
|
|
28
|
+
/** Augment global process.env types (default: true) */
|
|
29
|
+
augmentProcessEnv?: boolean;
|
|
30
|
+
/** Augment global import.meta.env types (default: true) */
|
|
31
|
+
augmentImportMetaEnv?: boolean;
|
|
32
|
+
/** Custom banner comment at the top of the file */
|
|
33
|
+
banner?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Generate TypeScript type definitions from a schema.
|
|
37
|
+
*
|
|
38
|
+
* @param schema - The env schema definition
|
|
39
|
+
* @param options - Generation options
|
|
40
|
+
* @returns The generated .d.ts file content as a string
|
|
41
|
+
*/
|
|
42
|
+
declare function generateTypes(schema: SimpleEnvSchema, options?: TypegenOptions): string;
|
|
43
|
+
/**
|
|
44
|
+
* Generate TypeScript type definitions and write them to a file.
|
|
45
|
+
*
|
|
46
|
+
* @param schema - The env schema definition
|
|
47
|
+
* @param outputPath - Path to write the .d.ts file
|
|
48
|
+
* @param options - Generation options
|
|
49
|
+
*/
|
|
50
|
+
declare function writeTypes(schema: SimpleEnvSchema, outputPath: string, options?: TypegenOptions): void;
|
|
51
|
+
|
|
52
|
+
export { type TypegenOptions, generateTypes, writeTypes };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { SimpleEnvSchema } from './types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Best-effort TypeScript type generation from env schemas.
|
|
5
|
+
*
|
|
6
|
+
* Generated types represent the **coerced output schema** (what resolve() returns).
|
|
7
|
+
* process.env augmentations remain string-ish at runtime — these are convenience,
|
|
8
|
+
* not enforcement. Edge cases (custom validators, complex compositions) fall back
|
|
9
|
+
* to `string`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { generateTypes, writeTypes } from 'node-env-resolver/typegen';
|
|
14
|
+
* import { string, number, oneOf, sensitive } from 'node-env-resolver/validators';
|
|
15
|
+
*
|
|
16
|
+
* const schema = {
|
|
17
|
+
* PORT: number({ default: 3000, description: 'Server port' }),
|
|
18
|
+
* API_KEY: sensitive(string({ description: 'API key for external service' })),
|
|
19
|
+
* NODE_ENV: oneOf(['development', 'production', 'test'] as const),
|
|
20
|
+
* };
|
|
21
|
+
*
|
|
22
|
+
* const types = generateTypes(schema);
|
|
23
|
+
* writeTypes(schema, './env.d.ts');
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
interface TypegenOptions {
|
|
28
|
+
/** Augment global process.env types (default: true) */
|
|
29
|
+
augmentProcessEnv?: boolean;
|
|
30
|
+
/** Augment global import.meta.env types (default: true) */
|
|
31
|
+
augmentImportMetaEnv?: boolean;
|
|
32
|
+
/** Custom banner comment at the top of the file */
|
|
33
|
+
banner?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Generate TypeScript type definitions from a schema.
|
|
37
|
+
*
|
|
38
|
+
* @param schema - The env schema definition
|
|
39
|
+
* @param options - Generation options
|
|
40
|
+
* @returns The generated .d.ts file content as a string
|
|
41
|
+
*/
|
|
42
|
+
declare function generateTypes(schema: SimpleEnvSchema, options?: TypegenOptions): string;
|
|
43
|
+
/**
|
|
44
|
+
* Generate TypeScript type definitions and write them to a file.
|
|
45
|
+
*
|
|
46
|
+
* @param schema - The env schema definition
|
|
47
|
+
* @param outputPath - Path to write the .d.ts file
|
|
48
|
+
* @param options - Generation options
|
|
49
|
+
*/
|
|
50
|
+
declare function writeTypes(schema: SimpleEnvSchema, outputPath: string, options?: TypegenOptions): void;
|
|
51
|
+
|
|
52
|
+
export { type TypegenOptions, generateTypes, writeTypes };
|
package/dist/typegen.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as generateTypes,b as writeTypes}from'./chunk-TGIYWWDY.js';import'./chunk-I7AUKTXE.js';
|
package/dist/types.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkG36OESVW_cjs=require('./chunk-G36OESVW.cjs');require('./chunk-D6WM53FN.cjs');Object.defineProperty(exports,"PROVENANCE_SYMBOL",{enumerable:true,get:function(){return chunkG36OESVW_cjs.c}});Object.defineProperty(exports,"SENSITIVE_KEYS_SYMBOL",{enumerable:true,get:function(){return chunkG36OESVW_cjs.d}});Object.defineProperty(exports,"isAsyncOnlyResolver",{enumerable:true,get:function(){return chunkG36OESVW_cjs.b}});Object.defineProperty(exports,"isSyncResolver",{enumerable:true,get:function(){return chunkG36OESVW_cjs.a}});
|
package/dist/types.d.cts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
interface ValidatorMeta {
|
|
2
|
+
sensitive?: boolean;
|
|
3
|
+
description?: string;
|
|
4
|
+
type?: string;
|
|
5
|
+
enumValues?: readonly string[];
|
|
6
|
+
}
|
|
1
7
|
type Validator<T> = ((value: string) => T) & {
|
|
2
8
|
optional?: boolean;
|
|
3
9
|
default?: T;
|
|
10
|
+
__meta?: ValidatorMeta;
|
|
4
11
|
};
|
|
5
12
|
type SimpleEnvSchema = Record<string, Validator<unknown> | string | number | boolean | readonly string[]>;
|
|
6
13
|
type InferSimpleValue<V> = V extends Validator<infer R> ? V extends {
|
|
@@ -94,11 +101,15 @@ type Provenance = {
|
|
|
94
101
|
metadata?: Record<string, unknown>;
|
|
95
102
|
cached?: boolean;
|
|
96
103
|
};
|
|
104
|
+
/**
|
|
105
|
+
* Symbol used to attach provenance metadata (key -> source/timestamp) to resolved config objects.
|
|
106
|
+
*/
|
|
107
|
+
declare const PROVENANCE_SYMBOL: unique symbol;
|
|
97
108
|
type PolicyOptions = {
|
|
98
109
|
allowDotenvInProduction?: boolean;
|
|
99
110
|
requireSecretsForSensitive?: boolean;
|
|
100
111
|
blockInsecureProtocols?: boolean;
|
|
101
|
-
enforceAllowedSources?:
|
|
112
|
+
enforceAllowedSources?: Record<string, readonly string[]>;
|
|
102
113
|
};
|
|
103
114
|
type SimpleEnvValue = Validator<unknown> | string | number | boolean | readonly string[];
|
|
104
115
|
type EnvSchema = Record<string, unknown>;
|
|
@@ -108,8 +119,11 @@ interface EnvDefinition {
|
|
|
108
119
|
default?: unknown;
|
|
109
120
|
optional?: boolean;
|
|
110
121
|
secretsDir?: string;
|
|
122
|
+
sensitive?: boolean;
|
|
123
|
+
description?: string;
|
|
111
124
|
}
|
|
125
|
+
declare const SENSITIVE_KEYS_SYMBOL: unique symbol;
|
|
112
126
|
type InferType = unknown;
|
|
113
127
|
type InferSchema = unknown;
|
|
114
128
|
|
|
115
|
-
export { type AsyncResolver, type EnvDefinition, type EnvSchema, type ExtractSchema, type InferMergedSchema, type InferMergedSchemaResult, type InferNestedSchema, type InferResolveResult, type InferSchema, type InferSimpleSchema, type InferSimpleValue, type InferType, type MergedSchema, type PolicyOptions, type Provenance, type ResolveAsyncConfig, type ResolveAsyncConfigWithResolvers, type ResolveAsyncConfigWithSchema, type ResolveConfig, type ResolveConfigWithResolvers, type ResolveConfigWithSchema, type ResolveOptions, type Resolver, type SafeResolveResultType, type SimpleEnvSchema, type SimpleEnvValue, type SyncResolver, type UnionToIntersection, type Validator, isAsyncOnlyResolver, isSyncResolver };
|
|
129
|
+
export { type AsyncResolver, type EnvDefinition, type EnvSchema, type ExtractSchema, type InferMergedSchema, type InferMergedSchemaResult, type InferNestedSchema, type InferResolveResult, type InferSchema, type InferSimpleSchema, type InferSimpleValue, type InferType, type MergedSchema, PROVENANCE_SYMBOL, type PolicyOptions, type Provenance, type ResolveAsyncConfig, type ResolveAsyncConfigWithResolvers, type ResolveAsyncConfigWithSchema, type ResolveConfig, type ResolveConfigWithResolvers, type ResolveConfigWithSchema, type ResolveOptions, type Resolver, SENSITIVE_KEYS_SYMBOL, type SafeResolveResultType, type SimpleEnvSchema, type SimpleEnvValue, type SyncResolver, type UnionToIntersection, type Validator, type ValidatorMeta, isAsyncOnlyResolver, isSyncResolver };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
interface ValidatorMeta {
|
|
2
|
+
sensitive?: boolean;
|
|
3
|
+
description?: string;
|
|
4
|
+
type?: string;
|
|
5
|
+
enumValues?: readonly string[];
|
|
6
|
+
}
|
|
1
7
|
type Validator<T> = ((value: string) => T) & {
|
|
2
8
|
optional?: boolean;
|
|
3
9
|
default?: T;
|
|
10
|
+
__meta?: ValidatorMeta;
|
|
4
11
|
};
|
|
5
12
|
type SimpleEnvSchema = Record<string, Validator<unknown> | string | number | boolean | readonly string[]>;
|
|
6
13
|
type InferSimpleValue<V> = V extends Validator<infer R> ? V extends {
|
|
@@ -94,11 +101,15 @@ type Provenance = {
|
|
|
94
101
|
metadata?: Record<string, unknown>;
|
|
95
102
|
cached?: boolean;
|
|
96
103
|
};
|
|
104
|
+
/**
|
|
105
|
+
* Symbol used to attach provenance metadata (key -> source/timestamp) to resolved config objects.
|
|
106
|
+
*/
|
|
107
|
+
declare const PROVENANCE_SYMBOL: unique symbol;
|
|
97
108
|
type PolicyOptions = {
|
|
98
109
|
allowDotenvInProduction?: boolean;
|
|
99
110
|
requireSecretsForSensitive?: boolean;
|
|
100
111
|
blockInsecureProtocols?: boolean;
|
|
101
|
-
enforceAllowedSources?:
|
|
112
|
+
enforceAllowedSources?: Record<string, readonly string[]>;
|
|
102
113
|
};
|
|
103
114
|
type SimpleEnvValue = Validator<unknown> | string | number | boolean | readonly string[];
|
|
104
115
|
type EnvSchema = Record<string, unknown>;
|
|
@@ -108,8 +119,11 @@ interface EnvDefinition {
|
|
|
108
119
|
default?: unknown;
|
|
109
120
|
optional?: boolean;
|
|
110
121
|
secretsDir?: string;
|
|
122
|
+
sensitive?: boolean;
|
|
123
|
+
description?: string;
|
|
111
124
|
}
|
|
125
|
+
declare const SENSITIVE_KEYS_SYMBOL: unique symbol;
|
|
112
126
|
type InferType = unknown;
|
|
113
127
|
type InferSchema = unknown;
|
|
114
128
|
|
|
115
|
-
export { type AsyncResolver, type EnvDefinition, type EnvSchema, type ExtractSchema, type InferMergedSchema, type InferMergedSchemaResult, type InferNestedSchema, type InferResolveResult, type InferSchema, type InferSimpleSchema, type InferSimpleValue, type InferType, type MergedSchema, type PolicyOptions, type Provenance, type ResolveAsyncConfig, type ResolveAsyncConfigWithResolvers, type ResolveAsyncConfigWithSchema, type ResolveConfig, type ResolveConfigWithResolvers, type ResolveConfigWithSchema, type ResolveOptions, type Resolver, type SafeResolveResultType, type SimpleEnvSchema, type SimpleEnvValue, type SyncResolver, type UnionToIntersection, type Validator, isAsyncOnlyResolver, isSyncResolver };
|
|
129
|
+
export { type AsyncResolver, type EnvDefinition, type EnvSchema, type ExtractSchema, type InferMergedSchema, type InferMergedSchemaResult, type InferNestedSchema, type InferResolveResult, type InferSchema, type InferSimpleSchema, type InferSimpleValue, type InferType, type MergedSchema, PROVENANCE_SYMBOL, type PolicyOptions, type Provenance, type ResolveAsyncConfig, type ResolveAsyncConfigWithResolvers, type ResolveAsyncConfigWithSchema, type ResolveConfig, type ResolveConfigWithResolvers, type ResolveConfigWithSchema, type ResolveOptions, type Resolver, SENSITIVE_KEYS_SYMBOL, type SafeResolveResultType, type SimpleEnvSchema, type SimpleEnvValue, type SyncResolver, type UnionToIntersection, type Validator, type ValidatorMeta, isAsyncOnlyResolver, isSyncResolver };
|
package/dist/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{b as isAsyncOnlyResolver,a as isSyncResolver}from'./chunk-
|
|
1
|
+
export{c as PROVENANCE_SYMBOL,d as SENSITIVE_KEYS_SYMBOL,b as isAsyncOnlyResolver,a as isSyncResolver}from'./chunk-46CBATKM.js';import'./chunk-I7AUKTXE.js';
|
package/dist/utils.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkS7AB6UX7_cjs=require('./chunk-S7AB6UX7.cjs');require('./chunk-2IQQVAXA.cjs'),require('./chunk-O7NR4K6A.cjs'),require('./chunk-G36OESVW.cjs'),require('./chunk-4QOKRJ3F.cjs');var chunkD6WM53FN_cjs=require('./chunk-D6WM53FN.cjs');function T(e,s={}){let{ttl:o=3e5,maxAge:r=36e5,staleWhileRevalidate:n=false}=s,t=null,a={name:`cached(${e.name})`,metadata:{},async load(){let i=Date.now();if(!t||i-t.timestamp>r){let l=e.load?await e.load():{};return t={data:l,timestamp:Date.now()},a.metadata={cached:false},l}if(i-t.timestamp<o)return a.metadata={cached:true},t.data;if(n&&!t.refreshPromise){let l=Promise.resolve(e.load?e.load():Promise.resolve({}));return t.refreshPromise=l.then(u=>(t.data=u,t.timestamp=Date.now(),t.refreshPromise=void 0,u)).catch(()=>(t.refreshPromise=void 0,t.data)),a.metadata={cached:true,stale:true},t.data}let d=e.load?await e.load():{};return t={data:d,timestamp:Date.now()},a.metadata={cached:false},d}};return a}var p={short:30*1e3,minute:60*1e3,minutes5:300*1e3,minutes15:900*1e3,hour:3600*1e3,hours6:360*60*1e3,day:1440*60*1e3};function C(e={}){return {ttl:e.ttl??p.minutes5,maxAge:e.maxAge??p.hour,staleWhileRevalidate:e.staleWhileRevalidate??true,key:"aws-secrets"}}function b(e,s=3,o=1e3){return {name:`retry(${e.name})`,async load(){let r;for(let n=0;n<=s;n++)try{return e.load?await e.load():{}}catch(t){r=t instanceof Error?t:new Error(String(t)),n<s&&await new Promise(a=>setTimeout(a,o*Math.pow(2,n)));}throw r}}}function v(e,s){let o=s.toUpperCase();return {name:`withPrefix(${e.name}, ${s})`,async load(){let r=e.load?await e.load():{},n={};for(let[t,a]of Object.entries(r))if(t.toUpperCase().startsWith(o)){let i=t.slice(s.length);n[i]=a;}else n[t]=a;return n},loadSync(){if(!e.loadSync)throw new Error(`Resolver ${e.name} does not support sync loading`);let r=e.loadSync(),n={};for(let[t,a]of Object.entries(r))if(t.toUpperCase().startsWith(o)){let i=t.slice(s.length);n[i]=a;}else n[t]=a;return n}}}function x(e,s){let o={...e};for(let[r,n]of Object.entries(s))Object.defineProperty(o,r,{get(){return n(e)},enumerable:true,configurable:true});return o}function S(e,s){return {name:`withAliases(${e.name})`,async load(){let o=e.load?await e.load():{};return g(o,s)},loadSync(){if(!e.loadSync)throw new Error(`Resolver ${e.name} does not support sync loading`);let o=e.loadSync();return g(o,s)}}}function g(e,s){let o={...e};for(let[r,n]of Object.entries(s))for(let t of n)if(e[t]!==void 0){o[r]=e[t];break}return o}function k(e,s){return {name:`withTransform(${e.name})`,async load(){let o=e.load?await e.load():{};return h(o,s)},loadSync(){if(!e.loadSync)throw new Error(`Resolver ${e.name} does not support sync loading`);let o=e.loadSync();return h(o,s)}}}function h(e,s){let o={...e};for(let[r,n]of Object.entries(s))if(e[r]!==void 0)try{o[r]=n(e[r]);}catch(t){throw new Error(`Transform failed for ${r}: ${t instanceof Error?t.message:String(t)}`,{cause:t})}return o}function $(e,s){let r=`${s.toUpperCase()}_`;return {name:`withNamespace(${e.name}, ${s})`,async load(){let n=e.load?await e.load():{},t={};for(let[a,i]of Object.entries(n))if(a.toUpperCase().startsWith(r)){let d=a.slice(r.length);t[d]=i;}return t},loadSync(){if(!e.loadSync)throw new Error(`Resolver ${e.name} does not support sync loading`);let n=e.loadSync(),t={};for(let[a,i]of Object.entries(n))if(a.toUpperCase().startsWith(r)){let d=a.slice(r.length);t[d]=i;}return t}}}function P(...e){return {name:`fallback(${e.map(o=>o.name).join(", ")})`,async load(){let o=[];for(let n of e){let t=n.load?await n.load():{};o.push(t);}let r={};for(let n of o)for(let[t,a]of Object.entries(n))a!==void 0&&r[t]===void 0&&(r[t]=a);return r},loadSync(){let o=[];for(let n of e){if(!n.loadSync)throw new Error(`Resolver '${n.name}' does not support synchronous loading`);let t=n.loadSync();o.push(t);}let r={};for(let n of o)for(let[t,a]of Object.entries(n))a!==void 0&&r[t]===void 0&&(r[t]=a);return r}}}function A(e,s){let{onChange:o,debounce:r=100,files:n=[".env"]}=s??{},t,a=null,i=[],d=async()=>{try{return await import('./index.cjs'),t=await chunkS7AB6UX7_cjs.b(e),t}catch(c){throw console.error("[watch] Failed to load config:",c),c}},l=()=>{a&&clearTimeout(a),a=setTimeout(async()=>{try{let c=await d();o?.(c);}catch(c){console.error("[watch] Failed to reload config:",c);}},r);},{watch:u}=chunkD6WM53FN_cjs.a("fs"),{join:y}=chunkD6WM53FN_cjs.a("path");for(let c of n)try{let w=u(y(process.cwd(),c),l);i.push(w);}catch{}return d().catch(console.error),{getConfig:()=>t,stop:()=>{a&&clearTimeout(a);for(let c of i)c.close();}}}exports.TTL=p;exports.awsCache=C;exports.cached=T;exports.fallback=P;exports.retry=b;exports.watch=A;exports.withAliases=S;exports.withComputed=x;exports.withNamespace=$;exports.withPrefix=v;exports.withTransform=k;
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveAsync } from './index.cjs';
|
|
2
|
-
import { Resolver } from './types.cjs';
|
|
2
|
+
import { Resolver, SyncResolver } from './types.cjs';
|
|
3
3
|
import './validation-types.cjs';
|
|
4
4
|
import './audit.cjs';
|
|
5
5
|
|
|
@@ -229,6 +229,16 @@ declare function withTransform(resolver: Resolver, transforms: Record<string, (v
|
|
|
229
229
|
* ```
|
|
230
230
|
*/
|
|
231
231
|
declare function withNamespace(resolver: Resolver, namespace: string): Resolver;
|
|
232
|
+
/**
|
|
233
|
+
* Combine multiple resolvers, using the first non-undefined value for each key.
|
|
234
|
+
*
|
|
235
|
+
* This is useful when you have a chain of potential sources (e.g. process.env,
|
|
236
|
+
* secrets manager, local overrides) and want a simple "first one wins" policy.
|
|
237
|
+
*
|
|
238
|
+
* Both async and sync modes are supported; sync mode requires that all
|
|
239
|
+
* underlying resolvers implement loadSync().
|
|
240
|
+
*/
|
|
241
|
+
declare function fallback(...resolvers: SyncResolver[]): SyncResolver;
|
|
232
242
|
/**
|
|
233
243
|
* Watch configuration files and reload automatically
|
|
234
244
|
* Perfect for development - auto-reload when .env files change
|
|
@@ -270,4 +280,4 @@ declare function watch<T>(config: Parameters<typeof resolveAsync>[0], options?:
|
|
|
270
280
|
stop: () => void;
|
|
271
281
|
};
|
|
272
282
|
|
|
273
|
-
export { type CacheOptions, TTL, awsCache, cached, retry, watch, withAliases, withComputed, withNamespace, withPrefix, withTransform };
|
|
283
|
+
export { type CacheOptions, TTL, awsCache, cached, fallback, retry, watch, withAliases, withComputed, withNamespace, withPrefix, withTransform };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveAsync } from './index.js';
|
|
2
|
-
import { Resolver } from './types.js';
|
|
2
|
+
import { Resolver, SyncResolver } from './types.js';
|
|
3
3
|
import './validation-types.js';
|
|
4
4
|
import './audit.js';
|
|
5
5
|
|
|
@@ -229,6 +229,16 @@ declare function withTransform(resolver: Resolver, transforms: Record<string, (v
|
|
|
229
229
|
* ```
|
|
230
230
|
*/
|
|
231
231
|
declare function withNamespace(resolver: Resolver, namespace: string): Resolver;
|
|
232
|
+
/**
|
|
233
|
+
* Combine multiple resolvers, using the first non-undefined value for each key.
|
|
234
|
+
*
|
|
235
|
+
* This is useful when you have a chain of potential sources (e.g. process.env,
|
|
236
|
+
* secrets manager, local overrides) and want a simple "first one wins" policy.
|
|
237
|
+
*
|
|
238
|
+
* Both async and sync modes are supported; sync mode requires that all
|
|
239
|
+
* underlying resolvers implement loadSync().
|
|
240
|
+
*/
|
|
241
|
+
declare function fallback(...resolvers: SyncResolver[]): SyncResolver;
|
|
232
242
|
/**
|
|
233
243
|
* Watch configuration files and reload automatically
|
|
234
244
|
* Perfect for development - auto-reload when .env files change
|
|
@@ -270,4 +280,4 @@ declare function watch<T>(config: Parameters<typeof resolveAsync>[0], options?:
|
|
|
270
280
|
stop: () => void;
|
|
271
281
|
};
|
|
272
282
|
|
|
273
|
-
export { type CacheOptions, TTL, awsCache, cached, retry, watch, withAliases, withComputed, withNamespace, withPrefix, withTransform };
|
|
283
|
+
export { type CacheOptions, TTL, awsCache, cached, fallback, retry, watch, withAliases, withComputed, withNamespace, withPrefix, withTransform };
|
package/dist/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b as b$1}from'./chunk-
|
|
1
|
+
import {b as b$1}from'./chunk-C34FGZOG.js';import'./chunk-VUUPIWFJ.js';import'./chunk-6EWR3WHU.js';import'./chunk-46CBATKM.js';import'./chunk-WKIPEKF6.js';import {a}from'./chunk-I7AUKTXE.js';function T(e,s={}){let{ttl:o=3e5,maxAge:r=36e5,staleWhileRevalidate:n=false}=s,t=null,a={name:`cached(${e.name})`,metadata:{},async load(){let i=Date.now();if(!t||i-t.timestamp>r){let l=e.load?await e.load():{};return t={data:l,timestamp:Date.now()},a.metadata={cached:false},l}if(i-t.timestamp<o)return a.metadata={cached:true},t.data;if(n&&!t.refreshPromise){let l=Promise.resolve(e.load?e.load():Promise.resolve({}));return t.refreshPromise=l.then(u=>(t.data=u,t.timestamp=Date.now(),t.refreshPromise=void 0,u)).catch(()=>(t.refreshPromise=void 0,t.data)),a.metadata={cached:true,stale:true},t.data}let d=e.load?await e.load():{};return t={data:d,timestamp:Date.now()},a.metadata={cached:false},d}};return a}var p={short:30*1e3,minute:60*1e3,minutes5:300*1e3,minutes15:900*1e3,hour:3600*1e3,hours6:360*60*1e3,day:1440*60*1e3};function C(e={}){return {ttl:e.ttl??p.minutes5,maxAge:e.maxAge??p.hour,staleWhileRevalidate:e.staleWhileRevalidate??true,key:"aws-secrets"}}function b(e,s=3,o=1e3){return {name:`retry(${e.name})`,async load(){let r;for(let n=0;n<=s;n++)try{return e.load?await e.load():{}}catch(t){r=t instanceof Error?t:new Error(String(t)),n<s&&await new Promise(a=>setTimeout(a,o*Math.pow(2,n)));}throw r}}}function v(e,s){let o=s.toUpperCase();return {name:`withPrefix(${e.name}, ${s})`,async load(){let r=e.load?await e.load():{},n={};for(let[t,a]of Object.entries(r))if(t.toUpperCase().startsWith(o)){let i=t.slice(s.length);n[i]=a;}else n[t]=a;return n},loadSync(){if(!e.loadSync)throw new Error(`Resolver ${e.name} does not support sync loading`);let r=e.loadSync(),n={};for(let[t,a]of Object.entries(r))if(t.toUpperCase().startsWith(o)){let i=t.slice(s.length);n[i]=a;}else n[t]=a;return n}}}function x(e,s){let o={...e};for(let[r,n]of Object.entries(s))Object.defineProperty(o,r,{get(){return n(e)},enumerable:true,configurable:true});return o}function S(e,s){return {name:`withAliases(${e.name})`,async load(){let o=e.load?await e.load():{};return g(o,s)},loadSync(){if(!e.loadSync)throw new Error(`Resolver ${e.name} does not support sync loading`);let o=e.loadSync();return g(o,s)}}}function g(e,s){let o={...e};for(let[r,n]of Object.entries(s))for(let t of n)if(e[t]!==void 0){o[r]=e[t];break}return o}function k(e,s){return {name:`withTransform(${e.name})`,async load(){let o=e.load?await e.load():{};return h(o,s)},loadSync(){if(!e.loadSync)throw new Error(`Resolver ${e.name} does not support sync loading`);let o=e.loadSync();return h(o,s)}}}function h(e,s){let o={...e};for(let[r,n]of Object.entries(s))if(e[r]!==void 0)try{o[r]=n(e[r]);}catch(t){throw new Error(`Transform failed for ${r}: ${t instanceof Error?t.message:String(t)}`,{cause:t})}return o}function $(e,s){let r=`${s.toUpperCase()}_`;return {name:`withNamespace(${e.name}, ${s})`,async load(){let n=e.load?await e.load():{},t={};for(let[a,i]of Object.entries(n))if(a.toUpperCase().startsWith(r)){let d=a.slice(r.length);t[d]=i;}return t},loadSync(){if(!e.loadSync)throw new Error(`Resolver ${e.name} does not support sync loading`);let n=e.loadSync(),t={};for(let[a,i]of Object.entries(n))if(a.toUpperCase().startsWith(r)){let d=a.slice(r.length);t[d]=i;}return t}}}function P(...e){return {name:`fallback(${e.map(o=>o.name).join(", ")})`,async load(){let o=[];for(let n of e){let t=n.load?await n.load():{};o.push(t);}let r={};for(let n of o)for(let[t,a]of Object.entries(n))a!==void 0&&r[t]===void 0&&(r[t]=a);return r},loadSync(){let o=[];for(let n of e){if(!n.loadSync)throw new Error(`Resolver '${n.name}' does not support synchronous loading`);let t=n.loadSync();o.push(t);}let r={};for(let n of o)for(let[t,a]of Object.entries(n))a!==void 0&&r[t]===void 0&&(r[t]=a);return r}}}function A(e,s){let{onChange:o,debounce:r=100,files:n=[".env"]}=s??{},t,a$1=null,i=[],d=async()=>{try{return await import('./index.js'),t=await b$1(e),t}catch(c){throw console.error("[watch] Failed to load config:",c),c}},l=()=>{a$1&&clearTimeout(a$1),a$1=setTimeout(async()=>{try{let c=await d();o?.(c);}catch(c){console.error("[watch] Failed to reload config:",c);}},r);},{watch:u}=a("fs"),{join:y}=a("path");for(let c of n)try{let w=u(y(process.cwd(),c),l);i.push(w);}catch{}return d().catch(console.error),{getConfig:()=>t,stop:()=>{a$1&&clearTimeout(a$1);for(let c of i)c.close();}}}export{p as TTL,C as awsCache,T as cached,P as fallback,b as retry,A as watch,S as withAliases,x as withComputed,$ as withNamespace,v as withPrefix,k as withTransform};
|
package/dist/valibot.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';require('./chunk-
|
|
1
|
+
'use strict';require('./chunk-QCKMQEJP.cjs');var chunk4QOKRJ3F_cjs=require('./chunk-4QOKRJ3F.cjs');require('./chunk-D6WM53FN.cjs');async function u(t,n,e){let r={};for(let o of t)try{let s=o.load?await o.load():{};r={...r,...s};}catch(s){if(e)throw new Error(`Resolver ${o.name} failed: ${s instanceof Error?s.message:s}`,{cause:s})}if(n)for(let[o,s]of Object.entries(r))r[o]=s.replace(/\$\{([^}]+)\}/g,(a,i)=>r[i]||"");return r}function p(t,n,e){let r={};for(let o of t)try{if(!o.loadSync){if(e)throw new Error(`Resolver ${o.name} does not support sync loading`);continue}let s=o.loadSync();r={...r,...s};}catch(s){if(e)throw new Error(`Resolver ${o.name} failed: ${s instanceof Error?s.message:s}`,{cause:s})}if(n)for(let[o,s]of Object.entries(r))r[o]=s.replace(/\$\{([^}]+)\}/g,(a,i)=>r[i]||"");return r}function f(t){return !t||!Array.isArray(t)?[{path:[],message:"Validation failed",code:"unknown_error"}]:t.map(n=>{if(!n||typeof n!="object")return {path:[],message:"Validation failed",code:"unknown_error"};let e=n;return {path:e.path?.map(r=>r.key)||[],message:e.message||"Validation failed",code:e.type}})}async function d(t,n={}){let{resolvers:e=[chunk4QOKRJ3F_cjs.a()],interpolate:r=false,strict:o=true}=n,s=await u(e,r,o);return t.parseAsync(s)}async function y(t,n={}){try{let{resolvers:e=[chunk4QOKRJ3F_cjs.a()],interpolate:r=!1,strict:o=!0}=n,s=await u(e,r,o),a=await t.safeParseAsync(s);if(a.success)return {success:!0,data:a.output};let i=f(a.issues);return {success:!1,error:i.map(l=>l.message).join(", "),issues:i}}catch(e){return {success:false,error:e instanceof Error?e.message:String(e),issues:[{path:[],message:e instanceof Error?e.message:String(e),code:"resolver_error"}]}}}function g(t,n={}){let{resolvers:e=[chunk4QOKRJ3F_cjs.a()],interpolate:r=false,strict:o=true}=n,s=p(e,r,o);return t.parse(s)}function b(t,n={}){try{let{resolvers:e=[chunk4QOKRJ3F_cjs.a()],interpolate:r=!1,strict:o=!0}=n,s=p(e,r,o),a=t.safeParse(s);if(a.success)return {success:!0,data:a.output};let i=f(a.issues);return {success:!1,error:i.map(l=>l.message).join(", "),issues:i}}catch(e){return {success:false,error:e instanceof Error?e.message:String(e),issues:[{path:[],message:e instanceof Error?e.message:String(e),code:"resolver_error"}]}}}exports.resolveSyncValibot=g;exports.resolveValibot=d;exports.safeResolveSyncValibot=b;exports.safeResolveValibot=y;
|
package/dist/valibot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import'./chunk-
|
|
1
|
+
import'./chunk-MFFH2ZXS.js';import {a}from'./chunk-WKIPEKF6.js';import'./chunk-I7AUKTXE.js';async function u(t,n,e){let r={};for(let o of t)try{let s=o.load?await o.load():{};r={...r,...s};}catch(s){if(e)throw new Error(`Resolver ${o.name} failed: ${s instanceof Error?s.message:s}`,{cause:s})}if(n)for(let[o,s]of Object.entries(r))r[o]=s.replace(/\$\{([^}]+)\}/g,(a,i)=>r[i]||"");return r}function p(t,n,e){let r={};for(let o of t)try{if(!o.loadSync){if(e)throw new Error(`Resolver ${o.name} does not support sync loading`);continue}let s=o.loadSync();r={...r,...s};}catch(s){if(e)throw new Error(`Resolver ${o.name} failed: ${s instanceof Error?s.message:s}`,{cause:s})}if(n)for(let[o,s]of Object.entries(r))r[o]=s.replace(/\$\{([^}]+)\}/g,(a,i)=>r[i]||"");return r}function f(t){return !t||!Array.isArray(t)?[{path:[],message:"Validation failed",code:"unknown_error"}]:t.map(n=>{if(!n||typeof n!="object")return {path:[],message:"Validation failed",code:"unknown_error"};let e=n;return {path:e.path?.map(r=>r.key)||[],message:e.message||"Validation failed",code:e.type}})}async function d(t,n={}){let{resolvers:e=[a()],interpolate:r=false,strict:o=true}=n,s=await u(e,r,o);return t.parseAsync(s)}async function y(t,n={}){try{let{resolvers:e=[a()],interpolate:r=!1,strict:o=!0}=n,s=await u(e,r,o),a$1=await t.safeParseAsync(s);if(a$1.success)return {success:!0,data:a$1.output};let i=f(a$1.issues);return {success:!1,error:i.map(l=>l.message).join(", "),issues:i}}catch(e){return {success:false,error:e instanceof Error?e.message:String(e),issues:[{path:[],message:e instanceof Error?e.message:String(e),code:"resolver_error"}]}}}function g(t,n={}){let{resolvers:e=[a()],interpolate:r=false,strict:o=true}=n,s=p(e,r,o);return t.parse(s)}function b(t,n={}){try{let{resolvers:e=[a()],interpolate:r=!1,strict:o=!0}=n,s=p(e,r,o),a$1=t.safeParse(s);if(a$1.success)return {success:!0,data:a$1.output};let i=f(a$1.issues);return {success:!1,error:i.map(l=>l.message).join(", "),issues:i}}catch(e){return {success:false,error:e instanceof Error?e.message:String(e),issues:[{path:[],message:e instanceof Error?e.message:String(e),code:"resolver_error"}]}}}export{g as resolveSyncValibot,d as resolveValibot,b as safeResolveSyncValibot,y as safeResolveValibot};
|
package/dist/validators.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var chunkD6WM53FN_cjs=require('./chunk-D6WM53FN.cjs');function
|
|
2
|
-
exports.boolean=
|
|
1
|
+
'use strict';var chunkD6WM53FN_cjs=require('./chunk-D6WM53FN.cjs');function i(t,n,r,e){let a={type:n};r?.sensitive!==void 0&&(a.sensitive=r.sensitive),r?.description!==void 0&&(a.description=r.description),e&&Object.assign(a,e),t.__meta=a;}function p(t){if(!/^postgres(ql)?:\/\/.+/.test(t))return {valid:false,error:"Invalid PostgreSQL URL"};try{return new URL(t),{valid:!0}}catch{return {valid:false,error:"Invalid PostgreSQL URL"}}}function f(t){if(!/^mysql:\/\/.+/.test(t))return {valid:false,error:"Invalid MySQL URL"};try{return new URL(t),{valid:!0}}catch{return {valid:false,error:"Invalid MySQL URL"}}}function c(t){return /^mongodb(\+srv)?:\/\/.+/.test(t)?/^mongodb(\+srv)?:\/\/([^@]+@)?[^/]+(\/[^?]*)?(\\?.*)?$/.test(t)?{valid:true}:{valid:false,error:"Invalid MongoDB URL"}:{valid:false,error:"Invalid MongoDB URL"}}function g(t){if(!/^rediss?:\/\/.+/.test(t))return {valid:false,error:"Invalid Redis URL"};try{return new URL(t),{valid:!0}}catch{return {valid:false,error:"Invalid Redis URL"}}}function m(t){try{let n=new URL(t);return ["http:","https:","ws:","wss:","ftp:","ftps:","file:","postgres:","postgresql:","mysql:","mongodb:","redis:","rediss:"].includes(n.protocol)?{valid:!0}:{valid:!1,error:`URL protocol '${n.protocol}' is not allowed`}}catch{return {valid:false,error:"Invalid URL"}}}function O(t){return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(t)?t.length>254?{valid:false,error:"Invalid email"}:{valid:true}:{valid:false,error:"Invalid email"}}function w(t){let n=Number(t);return n!==n||n<1||n>65535?{valid:false,error:"Invalid port"}:{valid:true}}function R(t){let n=Number(t);return n!==n?{valid:false,error:"Invalid number"}:{valid:true}}function v(t){let n=t.toLowerCase();return ["true","1","yes","on","false","0","no","off",""].includes(n)?{valid:true}:{valid:false,error:"Invalid boolean"}}function x(t){let n=new Date(t);if(isNaN(n.getTime()))return {valid:false,error:"Invalid date - cannot parse date value"};if(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{1,3})?(Z|[+-]\d{2}:\d{2})?)?$/.test(t)){if(/^\d{4}-\d{2}-\d{2}$/.test(t)){let[e,a,o]=t.split("-").map(Number);if(n.getUTCFullYear()!==e||n.getUTCMonth()+1!==a||n.getUTCDate()!==o)return {valid:false,error:"Invalid date value"}}return {valid:true}}return {valid:false,error:"Date must be in ISO 8601 format (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss.sssZ)"}}function b(t){if(!/^\d+$/.test(t))return {valid:false,error:"Invalid timestamp"};let n=Number(t);return isNaN(n)||n<0?{valid:false,error:"Invalid timestamp"}:n>253402300799?{valid:false,error:"Timestamp too large"}:{valid:true}}function V(t){let n=/^(\d+(?:\.\d+)?)(ms|s|m|h|d)$/,r=/^(?:(\d+(?:\.\d+)?)h)?(?:(\d+(?:\.\d+)?)m)?(?:(\d+(?:\.\d+)?)s)?(?:(\d+(?:\.\d+)?)ms)?$/,e=t.match(n);if(e){let o=parseFloat(e[1]),s=e[2],d={ms:1,s:1e3,m:60*1e3,h:3600*1e3,d:1440*60*1e3};return {valid:true,value:Math.floor(o*d[s])}}let a=t.match(r);if(a&&a[0]){let o=0;if(a[1]&&(o+=parseFloat(a[1])*60*60*1e3),a[2]&&(o+=parseFloat(a[2])*60*1e3),a[3]&&(o+=parseFloat(a[3])*1e3),a[4]&&(o+=parseFloat(a[4])),o>0)return {valid:true,value:Math.floor(o)}}return {valid:false,error:"Duration must be in format: 5s, 2h, 30m, 1h30m, etc."}}function k(t,n){try{let r=chunkD6WM53FN_cjs.a("fs"),{resolve:e}=chunkD6WM53FN_cjs.a("path"),a=e(process.cwd(),t);return {valid:!0,value:r.readFileSync(a,"utf8").trim()}}catch(r){return {valid:false,error:`Failed to read file${n?` for ${n}`:""}: ${r instanceof Error?r.message:String(r)}`}}}function h(t){let n=(r=>{if(!r.startsWith("http://")&&!r.startsWith("https://"))throw new Error(`Invalid HTTP URL: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),i(n,"string",t),n}function y(t){let n=(r=>{try{return JSON.parse(r)}catch{throw new Error(`Invalid JSON: "${r}"`)}});return t&&(n.default=t.default,n.optional=t.optional),i(n,"json",t),n}function $(t){let n=((r,e)=>{if(r===""&&!t?.allowEmpty)throw new Error("String cannot be empty");if(t?.min!==void 0&&r.length<t.min)throw new Error(`String too short (min: ${t.min})`);if(t?.max!==void 0&&r.length>t.max)throw new Error(`String too long (max: ${t.max})`);if(t?.pattern&&!new RegExp(t.pattern).test(r)){let a=e?`${e} does not match required pattern`:"String does not match pattern";throw new Error(a)}return r});return t&&(n.default=t.default,n.optional=t.optional),i(n,"string",t),n}function I(t){let n=(r=>{let e=Number(r);if(isNaN(e))throw new Error(`Invalid number: "${r}"`);if(t?.min!==void 0&&e<t.min)throw new Error(`Number too small (min: ${t.min})`);if(t?.max!==void 0&&e>t.max)throw new Error(`Number too large (max: ${t.max})`);return e});return t&&(n.default=t.default,n.optional=t.optional),i(n,"number",t),n}function T(t){let n=(r=>{let e=r.toLowerCase();if(["true","1","yes","on"].includes(e))return true;if(["false","0","no","off",""].includes(e))return false;throw new Error(`Invalid boolean: "${r}"`)});return t&&(n.default=t.default,n.optional=t.optional),i(n,"boolean",t),n}function E(t){let n=(r=>{try{return new URL(r),r}catch{throw new Error(`Invalid URL: "${r}"`)}});return t&&(n.default=t.default,n.optional=t.optional),i(n,"url",t),n}function L(t){let n=(r=>{if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r))throw new Error(`Invalid email: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),i(n,"email",t),n}function B(t){let n=(r=>{let e=Number(r);if(isNaN(e)||e<1||e>65535)throw new Error(`Invalid port: "${r}"`);return e});return t&&(n.default=t.default,n.optional=t.optional),i(n,"port",t),n}function N(t){let n=(r=>{if(!r.startsWith("postgres://")&&!r.startsWith("postgresql://"))throw new Error(`Invalid PostgreSQL URL: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),i(n,"string",t),n}function U(t){let n=(r=>{if(!r.startsWith("mysql://"))throw new Error(`Invalid MySQL URL: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),i(n,"string",t),n}function M(t){let n=(r=>{if(!r.startsWith("mongodb://")&&!r.startsWith("mongodb+srv://"))throw new Error(`Invalid MongoDB URL: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),i(n,"string",t),n}function D(t){let n=(r=>{if(!r.startsWith("redis://")&&!r.startsWith("rediss://"))throw new Error(`Invalid Redis URL: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),i(n,"string",t),n}function P(t){let n=(r=>{if(!r.startsWith("https://"))throw new Error(`Invalid HTTPS URL: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),i(n,"string",t),n}function S(t){let n=(r=>{let e=t?.separator||",";return r.split(e).map(a=>a.trim()).filter(a=>a.length>0)});return t&&(n.default=t.default,n.optional=t.optional),i(n,"string[]",t),n}function _(t){let n=(r=>{let e=t?.separator||",";return r.split(e).map(a=>{let o=Number(a.trim());if(isNaN(o))throw new Error(`Invalid number in array: "${a}"`);return o})});return t&&(n.default=t.default,n.optional=t.optional),i(n,"number[]",t),n}function q(t){let n=(r=>{let e=t?.separator||",",a=r.split(e).map(o=>o.trim()).filter(o=>o.length>0);for(let o of a)try{new URL(o);}catch{throw new Error(`Invalid URL in array: "${o}"`)}return a});return t&&(n.default=t.default,n.optional=t.optional),i(n,"string[]",t),n}function u(t,n){let r=(e=>{if(!t.includes(e))throw new Error(`Invalid value: "${e}". Allowed values: ${t.join(", ")}`);return e});return n&&(r.default=n.default,r.optional=n.optional),i(r,"oneOf",n,{enumValues:t}),r}function F(t,n){return u(t,n)}function A(t){let n=[...t];return n.__optional=true,n}function W(t){let n=(r=>{let e=r.match(/^(\d+)([smhd])$/);if(!e)throw new Error(`Invalid duration: "${r}". Use format like "5s", "2m", "1h", "1d"`);let[,a,o]=e,d={s:1e3,m:6e4,h:36e5,d:864e5}[o];return Number(a)*d});return t&&(n.default=t.default,n.optional=t.optional),i(n,"number",t),n}function Z(t){let n=(r=>{try{let e=chunkD6WM53FN_cjs.a("fs"),{resolve:a}=chunkD6WM53FN_cjs.a("path"),o=a(process.cwd(),r);return e.readFileSync(o,"utf8").trim()}catch(e){throw new Error(`Failed to read file: ${e instanceof Error?e.message:String(e)}`,{cause:e})}});return t&&(n.default=t.default,n.optional=t.optional,n.secretsDir=t.secretsDir),n.__isFileValidator=true,i(n,"string",t),n}function Y(t){let n=(r=>r);return t&&(n.default=t.default,n.optional=t.optional),i(n,"string",{...t,sensitive:true}),n}function z(t,n){let r=t;return n&&(r.default=n.default,r.optional=n.optional),i(r,"custom",n),r}function C(t){let n=(r=>{if(!/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?)?$/.test(r))throw new Error(`Date must be in ISO 8601 format: "${r}"`);let a=new Date(r);if(isNaN(a.getTime()))throw new Error(`Cannot parse date value: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),i(n,"string",t),n}function Q(t){let n=(r=>{let e=Number(r);if(isNaN(e)||!Number.isInteger(e))throw new Error(`Invalid timestamp: "${r}"`);if(e<0)throw new Error(`Invalid timestamp: "${r}"`);if(e>253402300799)throw new Error(`Timestamp too large: "${r}"`);return e});return t&&(n.default=t.default,n.optional=t.optional),i(n,"number",t),n}function j(t){let n=(o=>t(o)),r=t,e=n;for(let[o,s]of Object.entries(r))o!=="__meta"&&(e[o]=s);let a=r.__meta??{};return e.__meta={...a||{},sensitive:true},n}
|
|
2
|
+
exports.boolean=T;exports.custom=z;exports.date=C;exports.duration=W;exports.email=L;exports.enumOf=F;exports.file=Z;exports.http=h;exports.https=P;exports.json=y;exports.mongodb=M;exports.mysql=U;exports.number=I;exports.numberArray=_;exports.oneOf=u;exports.optional=A;exports.port=B;exports.postgres=N;exports.redis=D;exports.secret=Y;exports.sensitive=j;exports.string=$;exports.stringArray=S;exports.timestamp=Q;exports.url=E;exports.urlArray=q;exports.validateBoolean=v;exports.validateDate=x;exports.validateDuration=V;exports.validateEmail=O;exports.validateFile=k;exports.validateMongodb=c;exports.validateMysql=f;exports.validateNumber=R;exports.validatePort=w;exports.validatePostgres=p;exports.validateRedis=g;exports.validateTimestamp=b;exports.validateUrl=m;
|