node-env-resolver 6.5.1 → 6.5.2
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 +708 -400
- package/dist/builder.cjs +1 -1
- package/dist/builder.d.cts +1 -1
- package/dist/builder.d.ts +1 -1
- package/dist/builder.js +1 -1
- package/dist/chunk-3EWCMDFP.js +9 -0
- package/dist/chunk-BFLXBLZ3.cjs +1 -0
- package/dist/chunk-CDXO2XX3.cjs +2 -0
- package/dist/chunk-CTJYBBOB.js +2 -0
- package/dist/chunk-DIJNUFGZ.cjs +15 -0
- package/dist/chunk-DYFRO3NM.cjs +9 -0
- package/dist/chunk-K4NIC5T3.js +9 -0
- package/dist/chunk-WVMDTD6J.cjs +9 -0
- package/dist/chunk-ZMRT37K3.js +1 -0
- package/dist/chunk-ZSM2NDX5.js +15 -0
- package/dist/cli/bin.cjs +74 -0
- package/dist/cli/bin.js +74 -0
- package/dist/cli.d.cts +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +59 -3
- package/dist/index.d.ts +59 -3
- package/dist/index.js +1 -1
- package/dist/resolver.cjs +1 -1
- package/dist/resolver.d.cts +1 -1
- package/dist/resolver.d.ts +1 -1
- package/dist/resolver.js +1 -1
- package/dist/resolvers.cjs +1 -1
- package/dist/resolvers.d.cts +2 -27
- package/dist/resolvers.d.ts +2 -27
- package/dist/resolvers.js +1 -1
- package/dist/runtime/index.cjs +1 -0
- package/dist/runtime/index.d.cts +161 -0
- package/dist/runtime/index.d.ts +161 -0
- package/dist/runtime/index.js +1 -0
- package/dist/types--RcOnfdl.d.cts +284 -0
- package/dist/types--RcOnfdl.d.ts +284 -0
- package/dist/types.cjs +1 -1
- package/dist/types.d.cts +1 -129
- package/dist/types.d.ts +1 -129
- package/dist/types.js +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.cts +56 -12
- package/dist/utils.d.ts +56 -12
- package/dist/utils.js +1 -1
- package/dist/valibot.cjs +1 -1
- package/dist/valibot.d.cts +12 -25
- package/dist/valibot.d.ts +12 -25
- package/dist/valibot.js +1 -1
- package/dist/validators.cjs +2 -2
- package/dist/validators.d.cts +25 -48
- package/dist/validators.d.ts +25 -48
- package/dist/validators.js +2 -2
- package/dist/web.cjs +5 -5
- package/dist/web.d.cts +3 -1
- package/dist/web.d.ts +3 -1
- package/dist/web.js +5 -5
- package/dist/zod.cjs +1 -1
- package/dist/zod.d.cts +12 -25
- package/dist/zod.d.ts +12 -25
- package/dist/zod.js +1 -1
- package/package.json +28 -40
- package/binding.gyp +0 -9
- package/dist/chunk-2IQQVAXA.cjs +0 -9
- package/dist/chunk-46CBATKM.js +0 -1
- package/dist/chunk-C34FGZOG.js +0 -9
- package/dist/chunk-FNF55TN4.cjs +0 -1
- package/dist/chunk-G36OESVW.cjs +0 -1
- package/dist/chunk-I5UKYTX6.js +0 -1
- package/dist/chunk-MFFH2ZXS.js +0 -17
- package/dist/chunk-QCKMQEJP.cjs +0 -17
- package/dist/chunk-S7AB6UX7.cjs +0 -9
- package/dist/chunk-TGIYWWDY.js +0 -9
- package/dist/chunk-VUUPIWFJ.js +0 -9
- package/dist/chunk-ZDRU3RSU.cjs +0 -9
- package/dist/cli-main.cjs +0 -4
- package/dist/cli-main.js +0 -4
- package/dist/redaction.cjs +0 -1
- package/dist/redaction.d.cts +0 -54
- package/dist/redaction.d.ts +0 -54
- package/dist/redaction.js +0 -1
- package/dist/typegen.cjs +0 -1
- package/dist/typegen.d.cts +0 -52
- package/dist/typegen.d.ts +0 -52
- package/dist/typegen.js +0 -1
- package/index.js +0 -1
- /package/dist/{cli-main.d.cts → cli/bin.d.cts} +0 -0
- /package/dist/{cli-main.d.ts → cli/bin.d.ts} +0 -0
package/dist/types.d.cts
CHANGED
|
@@ -1,129 +1 @@
|
|
|
1
|
-
|
|
2
|
-
sensitive?: boolean;
|
|
3
|
-
description?: string;
|
|
4
|
-
type?: string;
|
|
5
|
-
enumValues?: readonly string[];
|
|
6
|
-
}
|
|
7
|
-
type Validator<T> = ((value: string) => T) & {
|
|
8
|
-
optional?: boolean;
|
|
9
|
-
default?: T;
|
|
10
|
-
__meta?: ValidatorMeta;
|
|
11
|
-
};
|
|
12
|
-
type SimpleEnvSchema = Record<string, Validator<unknown> | string | number | boolean | readonly string[]>;
|
|
13
|
-
type InferSimpleValue<V> = V extends Validator<infer R> ? V extends {
|
|
14
|
-
optional: true;
|
|
15
|
-
} ? R | undefined : R : V extends number ? number : V extends boolean ? boolean : V extends readonly (infer U)[] ? V extends {
|
|
16
|
-
__optional: true;
|
|
17
|
-
} ? U | undefined : U : V extends string ? string : never;
|
|
18
|
-
type InferSimpleSchema<T extends SimpleEnvSchema> = {
|
|
19
|
-
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
20
|
-
};
|
|
21
|
-
type InferNestedSchema<T extends SimpleEnvSchema> = InferSimpleSchema<T>;
|
|
22
|
-
type InferResolveResult<T extends SimpleEnvSchema, O extends ResolveOptions | undefined> = O extends {
|
|
23
|
-
nestedDelimiter: string;
|
|
24
|
-
} ? InferNestedSchema<T> : InferSimpleSchema<T>;
|
|
25
|
-
interface SyncResolver {
|
|
26
|
-
loadSync(): Record<string, string>;
|
|
27
|
-
load?(): Promise<Record<string, string>>;
|
|
28
|
-
name?: string;
|
|
29
|
-
metadata?: Record<string, unknown>;
|
|
30
|
-
}
|
|
31
|
-
interface AsyncResolver {
|
|
32
|
-
load(): Promise<Record<string, string>>;
|
|
33
|
-
loadSync?(): Record<string, string>;
|
|
34
|
-
name?: string;
|
|
35
|
-
metadata?: Record<string, unknown>;
|
|
36
|
-
}
|
|
37
|
-
type Resolver = SyncResolver | AsyncResolver;
|
|
38
|
-
declare const isSyncResolver: (resolver: Resolver) => resolver is SyncResolver;
|
|
39
|
-
declare const isAsyncOnlyResolver: (resolver: Resolver) => resolver is AsyncResolver;
|
|
40
|
-
interface ResolveOptions {
|
|
41
|
-
priority?: 'first' | 'last';
|
|
42
|
-
nestedDelimiter?: string;
|
|
43
|
-
validateDefaults?: boolean;
|
|
44
|
-
secretsDir?: string;
|
|
45
|
-
arraySeparator?: string;
|
|
46
|
-
interpolate?: boolean;
|
|
47
|
-
strict?: boolean;
|
|
48
|
-
policies?: Record<string, unknown>;
|
|
49
|
-
enableAudit?: boolean;
|
|
50
|
-
}
|
|
51
|
-
type SafeResolveResultType<T> = {
|
|
52
|
-
success: true;
|
|
53
|
-
data: T;
|
|
54
|
-
} | {
|
|
55
|
-
success: false;
|
|
56
|
-
error: string;
|
|
57
|
-
details?: unknown;
|
|
58
|
-
};
|
|
59
|
-
type ExtractSchema<T> = T extends readonly [unknown, infer S] ? S : never;
|
|
60
|
-
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
61
|
-
type ExtractSchemasUnion<T> = T extends readonly (infer E)[] ? E extends readonly [unknown, infer S] ? S extends SimpleEnvSchema ? S : never : never : never;
|
|
62
|
-
type MergedSchema<T> = UnionToIntersection<ExtractSchemasUnion<T>>;
|
|
63
|
-
type InferMergedSchemaResult<T extends readonly [unknown, SimpleEnvSchema][]> = MergedSchema<T> extends SimpleEnvSchema ? {
|
|
64
|
-
[K in keyof MergedSchema<T>]: InferSimpleValue<MergedSchema<T>[K]>;
|
|
65
|
-
} : Record<string, unknown>;
|
|
66
|
-
type InferMergedSchema<T extends readonly [unknown, SimpleEnvSchema][]> = T extends readonly [
|
|
67
|
-
unknown,
|
|
68
|
-
infer S1,
|
|
69
|
-
...infer Rest
|
|
70
|
-
] ? Rest extends readonly [unknown, SimpleEnvSchema][] ? S1 & InferMergedSchema<Rest> : S1 : T extends readonly [unknown, infer S] ? S : Record<string, never>;
|
|
71
|
-
|
|
72
|
-
interface ResolveConfig<T extends SimpleEnvSchema = SimpleEnvSchema> {
|
|
73
|
-
schema?: T;
|
|
74
|
-
resolvers?: readonly [SyncResolver, SimpleEnvSchema][];
|
|
75
|
-
options?: Partial<ResolveOptions>;
|
|
76
|
-
}
|
|
77
|
-
interface ResolveAsyncConfig<T extends SimpleEnvSchema = SimpleEnvSchema> {
|
|
78
|
-
schema?: T;
|
|
79
|
-
resolvers?: readonly [Resolver, SimpleEnvSchema][];
|
|
80
|
-
options?: Partial<ResolveOptions>;
|
|
81
|
-
}
|
|
82
|
-
interface ResolveConfigWithSchema<T extends SimpleEnvSchema> {
|
|
83
|
-
schema: T;
|
|
84
|
-
options?: Partial<ResolveOptions>;
|
|
85
|
-
}
|
|
86
|
-
interface ResolveConfigWithResolvers<T extends readonly [SyncResolver, SimpleEnvSchema][]> {
|
|
87
|
-
resolvers: T;
|
|
88
|
-
options?: Partial<ResolveOptions>;
|
|
89
|
-
}
|
|
90
|
-
interface ResolveAsyncConfigWithSchema<T extends SimpleEnvSchema> {
|
|
91
|
-
schema: T;
|
|
92
|
-
options?: Partial<ResolveOptions>;
|
|
93
|
-
}
|
|
94
|
-
interface ResolveAsyncConfigWithResolvers<T extends readonly [Resolver, SimpleEnvSchema][]> {
|
|
95
|
-
resolvers: T;
|
|
96
|
-
options?: Partial<ResolveOptions>;
|
|
97
|
-
}
|
|
98
|
-
type Provenance = {
|
|
99
|
-
source: string;
|
|
100
|
-
timestamp: number;
|
|
101
|
-
metadata?: Record<string, unknown>;
|
|
102
|
-
cached?: boolean;
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* Symbol used to attach provenance metadata (key -> source/timestamp) to resolved config objects.
|
|
106
|
-
*/
|
|
107
|
-
declare const PROVENANCE_SYMBOL: unique symbol;
|
|
108
|
-
type PolicyOptions = {
|
|
109
|
-
allowDotenvInProduction?: boolean;
|
|
110
|
-
requireSecretsForSensitive?: boolean;
|
|
111
|
-
blockInsecureProtocols?: boolean;
|
|
112
|
-
enforceAllowedSources?: Record<string, readonly string[]>;
|
|
113
|
-
};
|
|
114
|
-
type SimpleEnvValue = Validator<unknown> | string | number | boolean | readonly string[];
|
|
115
|
-
type EnvSchema = Record<string, unknown>;
|
|
116
|
-
interface EnvDefinition {
|
|
117
|
-
type?: string;
|
|
118
|
-
validator?: (value: string, key?: string) => unknown;
|
|
119
|
-
default?: unknown;
|
|
120
|
-
optional?: boolean;
|
|
121
|
-
secretsDir?: string;
|
|
122
|
-
sensitive?: boolean;
|
|
123
|
-
description?: string;
|
|
124
|
-
}
|
|
125
|
-
declare const SENSITIVE_KEYS_SYMBOL: unique symbol;
|
|
126
|
-
type InferType = unknown;
|
|
127
|
-
type InferSchema = unknown;
|
|
128
|
-
|
|
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 };
|
|
1
|
+
export { A as AsyncResolver, c as EnvDefinition, E as EnvSchema, J as ExtractSchema, H as InferMergedSchema, i as InferMergedSchemaResult, K as InferNestedSchema, r as InferResolveResult, q as InferSchema, I as InferSimpleSchema, g as InferSimpleValue, p as InferType, M as MergedSchema, P as PolicyOptions, n as Provenance, l as ReferenceContext, e as ReferenceHandler, b as ReferenceOptions, m as ReferenceResolution, f as ResolveAsyncConfig, O as ResolveAsyncConfigWithResolvers, h as ResolveAsyncConfigWithSchema, k as ResolveConfig, N as ResolveConfigWithResolvers, j as ResolveConfigWithSchema, R as ResolveOptions, a as Resolver, L as SafeResolveResultType, S as SimpleEnvSchema, o as SimpleEnvValue, d as SyncResolver, U as UnionToIntersection, V as Validator, t as isAsyncOnlyResolver, s as isSyncResolver } from './types--RcOnfdl.cjs';
|
package/dist/types.d.ts
CHANGED
|
@@ -1,129 +1 @@
|
|
|
1
|
-
|
|
2
|
-
sensitive?: boolean;
|
|
3
|
-
description?: string;
|
|
4
|
-
type?: string;
|
|
5
|
-
enumValues?: readonly string[];
|
|
6
|
-
}
|
|
7
|
-
type Validator<T> = ((value: string) => T) & {
|
|
8
|
-
optional?: boolean;
|
|
9
|
-
default?: T;
|
|
10
|
-
__meta?: ValidatorMeta;
|
|
11
|
-
};
|
|
12
|
-
type SimpleEnvSchema = Record<string, Validator<unknown> | string | number | boolean | readonly string[]>;
|
|
13
|
-
type InferSimpleValue<V> = V extends Validator<infer R> ? V extends {
|
|
14
|
-
optional: true;
|
|
15
|
-
} ? R | undefined : R : V extends number ? number : V extends boolean ? boolean : V extends readonly (infer U)[] ? V extends {
|
|
16
|
-
__optional: true;
|
|
17
|
-
} ? U | undefined : U : V extends string ? string : never;
|
|
18
|
-
type InferSimpleSchema<T extends SimpleEnvSchema> = {
|
|
19
|
-
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
20
|
-
};
|
|
21
|
-
type InferNestedSchema<T extends SimpleEnvSchema> = InferSimpleSchema<T>;
|
|
22
|
-
type InferResolveResult<T extends SimpleEnvSchema, O extends ResolveOptions | undefined> = O extends {
|
|
23
|
-
nestedDelimiter: string;
|
|
24
|
-
} ? InferNestedSchema<T> : InferSimpleSchema<T>;
|
|
25
|
-
interface SyncResolver {
|
|
26
|
-
loadSync(): Record<string, string>;
|
|
27
|
-
load?(): Promise<Record<string, string>>;
|
|
28
|
-
name?: string;
|
|
29
|
-
metadata?: Record<string, unknown>;
|
|
30
|
-
}
|
|
31
|
-
interface AsyncResolver {
|
|
32
|
-
load(): Promise<Record<string, string>>;
|
|
33
|
-
loadSync?(): Record<string, string>;
|
|
34
|
-
name?: string;
|
|
35
|
-
metadata?: Record<string, unknown>;
|
|
36
|
-
}
|
|
37
|
-
type Resolver = SyncResolver | AsyncResolver;
|
|
38
|
-
declare const isSyncResolver: (resolver: Resolver) => resolver is SyncResolver;
|
|
39
|
-
declare const isAsyncOnlyResolver: (resolver: Resolver) => resolver is AsyncResolver;
|
|
40
|
-
interface ResolveOptions {
|
|
41
|
-
priority?: 'first' | 'last';
|
|
42
|
-
nestedDelimiter?: string;
|
|
43
|
-
validateDefaults?: boolean;
|
|
44
|
-
secretsDir?: string;
|
|
45
|
-
arraySeparator?: string;
|
|
46
|
-
interpolate?: boolean;
|
|
47
|
-
strict?: boolean;
|
|
48
|
-
policies?: Record<string, unknown>;
|
|
49
|
-
enableAudit?: boolean;
|
|
50
|
-
}
|
|
51
|
-
type SafeResolveResultType<T> = {
|
|
52
|
-
success: true;
|
|
53
|
-
data: T;
|
|
54
|
-
} | {
|
|
55
|
-
success: false;
|
|
56
|
-
error: string;
|
|
57
|
-
details?: unknown;
|
|
58
|
-
};
|
|
59
|
-
type ExtractSchema<T> = T extends readonly [unknown, infer S] ? S : never;
|
|
60
|
-
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
61
|
-
type ExtractSchemasUnion<T> = T extends readonly (infer E)[] ? E extends readonly [unknown, infer S] ? S extends SimpleEnvSchema ? S : never : never : never;
|
|
62
|
-
type MergedSchema<T> = UnionToIntersection<ExtractSchemasUnion<T>>;
|
|
63
|
-
type InferMergedSchemaResult<T extends readonly [unknown, SimpleEnvSchema][]> = MergedSchema<T> extends SimpleEnvSchema ? {
|
|
64
|
-
[K in keyof MergedSchema<T>]: InferSimpleValue<MergedSchema<T>[K]>;
|
|
65
|
-
} : Record<string, unknown>;
|
|
66
|
-
type InferMergedSchema<T extends readonly [unknown, SimpleEnvSchema][]> = T extends readonly [
|
|
67
|
-
unknown,
|
|
68
|
-
infer S1,
|
|
69
|
-
...infer Rest
|
|
70
|
-
] ? Rest extends readonly [unknown, SimpleEnvSchema][] ? S1 & InferMergedSchema<Rest> : S1 : T extends readonly [unknown, infer S] ? S : Record<string, never>;
|
|
71
|
-
|
|
72
|
-
interface ResolveConfig<T extends SimpleEnvSchema = SimpleEnvSchema> {
|
|
73
|
-
schema?: T;
|
|
74
|
-
resolvers?: readonly [SyncResolver, SimpleEnvSchema][];
|
|
75
|
-
options?: Partial<ResolveOptions>;
|
|
76
|
-
}
|
|
77
|
-
interface ResolveAsyncConfig<T extends SimpleEnvSchema = SimpleEnvSchema> {
|
|
78
|
-
schema?: T;
|
|
79
|
-
resolvers?: readonly [Resolver, SimpleEnvSchema][];
|
|
80
|
-
options?: Partial<ResolveOptions>;
|
|
81
|
-
}
|
|
82
|
-
interface ResolveConfigWithSchema<T extends SimpleEnvSchema> {
|
|
83
|
-
schema: T;
|
|
84
|
-
options?: Partial<ResolveOptions>;
|
|
85
|
-
}
|
|
86
|
-
interface ResolveConfigWithResolvers<T extends readonly [SyncResolver, SimpleEnvSchema][]> {
|
|
87
|
-
resolvers: T;
|
|
88
|
-
options?: Partial<ResolveOptions>;
|
|
89
|
-
}
|
|
90
|
-
interface ResolveAsyncConfigWithSchema<T extends SimpleEnvSchema> {
|
|
91
|
-
schema: T;
|
|
92
|
-
options?: Partial<ResolveOptions>;
|
|
93
|
-
}
|
|
94
|
-
interface ResolveAsyncConfigWithResolvers<T extends readonly [Resolver, SimpleEnvSchema][]> {
|
|
95
|
-
resolvers: T;
|
|
96
|
-
options?: Partial<ResolveOptions>;
|
|
97
|
-
}
|
|
98
|
-
type Provenance = {
|
|
99
|
-
source: string;
|
|
100
|
-
timestamp: number;
|
|
101
|
-
metadata?: Record<string, unknown>;
|
|
102
|
-
cached?: boolean;
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* Symbol used to attach provenance metadata (key -> source/timestamp) to resolved config objects.
|
|
106
|
-
*/
|
|
107
|
-
declare const PROVENANCE_SYMBOL: unique symbol;
|
|
108
|
-
type PolicyOptions = {
|
|
109
|
-
allowDotenvInProduction?: boolean;
|
|
110
|
-
requireSecretsForSensitive?: boolean;
|
|
111
|
-
blockInsecureProtocols?: boolean;
|
|
112
|
-
enforceAllowedSources?: Record<string, readonly string[]>;
|
|
113
|
-
};
|
|
114
|
-
type SimpleEnvValue = Validator<unknown> | string | number | boolean | readonly string[];
|
|
115
|
-
type EnvSchema = Record<string, unknown>;
|
|
116
|
-
interface EnvDefinition {
|
|
117
|
-
type?: string;
|
|
118
|
-
validator?: (value: string, key?: string) => unknown;
|
|
119
|
-
default?: unknown;
|
|
120
|
-
optional?: boolean;
|
|
121
|
-
secretsDir?: string;
|
|
122
|
-
sensitive?: boolean;
|
|
123
|
-
description?: string;
|
|
124
|
-
}
|
|
125
|
-
declare const SENSITIVE_KEYS_SYMBOL: unique symbol;
|
|
126
|
-
type InferType = unknown;
|
|
127
|
-
type InferSchema = unknown;
|
|
128
|
-
|
|
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 };
|
|
1
|
+
export { A as AsyncResolver, c as EnvDefinition, E as EnvSchema, J as ExtractSchema, H as InferMergedSchema, i as InferMergedSchemaResult, K as InferNestedSchema, r as InferResolveResult, q as InferSchema, I as InferSimpleSchema, g as InferSimpleValue, p as InferType, M as MergedSchema, P as PolicyOptions, n as Provenance, l as ReferenceContext, e as ReferenceHandler, b as ReferenceOptions, m as ReferenceResolution, f as ResolveAsyncConfig, O as ResolveAsyncConfigWithResolvers, h as ResolveAsyncConfigWithSchema, k as ResolveConfig, N as ResolveConfigWithResolvers, j as ResolveConfigWithSchema, R as ResolveOptions, a as Resolver, L as SafeResolveResultType, S as SimpleEnvSchema, o as SimpleEnvValue, d as SyncResolver, U as UnionToIntersection, V as Validator, t as isAsyncOnlyResolver, s as isSyncResolver } from './types--RcOnfdl.js';
|
package/dist/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{b as isAsyncOnlyResolver,a as isSyncResolver}from'./chunk-ZMRT37K3.js';import'./chunk-I7AUKTXE.js';
|
package/dist/utils.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkDYFRO3NM_cjs=require('./chunk-DYFRO3NM.cjs');require('./chunk-WVMDTD6J.cjs'),require('./chunk-CDXO2XX3.cjs'),require('./chunk-O7NR4K6A.cjs'),require('./chunk-4QOKRJ3F.cjs'),require('./chunk-BFLXBLZ3.cjs');var chunkD6WM53FN_cjs=require('./chunk-D6WM53FN.cjs');function x(e,n={}){let{ttl:r=3e5,maxAge:s=36e5,staleWhileRevalidate:o=false}=n,t=null,a={name:`cached(${e.name})`,metadata:{},async load(){let i=Date.now();if(!t||i-t.timestamp>s){let u=e.load?await e.load():{};return t={data:u,timestamp:i},a.metadata={cached:false},u}if(i-t.timestamp<r)return a.metadata={cached:true},t.data;if(o&&!t.refreshPromise){let u=Promise.resolve(e.load?e.load():Promise.resolve({}));return t.refreshPromise=u.then(d=>(t.data=d,t.timestamp=Date.now(),t.refreshPromise=void 0,d)).catch(()=>(t.refreshPromise=void 0,t.data)),a.metadata={cached:true,stale:true},t.data}let c=e.load?await e.load():{};return t={data:c,timestamp:i},a.metadata={cached:false},c}};return a}var w={short:30*1e3,minute:60*1e3,minutes5:300*1e3,minutes15:900*1e3,hour:3600*1e3,hours6:360*60*1e3,day:1440*60*1e3};function P(e={}){return {ttl:e.ttl??w.minutes5,maxAge:e.maxAge??w.hour,staleWhileRevalidate:e.staleWhileRevalidate??true,key:"aws-secrets"}}function v(e,n=3,r=1e3){return {name:`retry(${e.name})`,async load(){let s;for(let o=0;o<=n;o++)try{return e.load?await e.load():{}}catch(t){s=t instanceof Error?t:new Error(String(t)),o<n&&await new Promise(a=>setTimeout(a,r*Math.pow(2,o)));}throw s}}}function C(e,n){if(Object.is(e,n))return true;try{return JSON.stringify(e)===JSON.stringify(n)}catch{return false}}function O(e,n={}){let{intervalMs:r=1e4,immediate:s=true,onChange:o,onError:t,equals:a=C}=n,i,c=null,u=false,d=false,p=false,l=()=>{u||(c=setTimeout(()=>{c=null,m();},r));},m=async()=>{if(u||d)return i;d=true,c&&(clearTimeout(c),c=null);try{let f=await e(),g=i;return i=f,p&&!a(f,g)&&await o?.(f,g),p=!0,f}catch(f){return t?.(f),i}finally{d=false,u||l();}};return s?m():l(),{getCurrent:()=>i,refresh:()=>m(),stop:()=>{u=true,c&&(clearTimeout(c),c=null);}}}function S(e,n){let r=n.toUpperCase();return {name:`withPrefix(${e.name}, ${n})`,async load(){let s=e.load?await e.load():{},o={};for(let[t,a]of Object.entries(s))if(t.toUpperCase().startsWith(r)){let i=t.slice(n.length);o[i]=a;}else o[t]=a;return o},loadSync(){if(!e.loadSync)throw new Error(`Resolver ${e.name} does not support sync loading`);let s=e.loadSync(),o={};for(let[t,a]of Object.entries(s))if(t.toUpperCase().startsWith(r)){let i=t.slice(n.length);o[i]=a;}else o[t]=a;return o}}}function $(e,n){let r={...e};for(let[s,o]of Object.entries(n))Object.defineProperty(r,s,{get(){return o(e)},enumerable:true,configurable:true});return r}function k(e,n){return {name:`withAliases(${e.name})`,async load(){let r=e.load?await e.load():{};return T(r,n)},loadSync(){if(!e.loadSync)throw new Error(`Resolver ${e.name} does not support sync loading`);let r=e.loadSync();return T(r,n)}}}function T(e,n){let r={...e};for(let[s,o]of Object.entries(n))for(let t of o)if(e[t]!==void 0){r[s]=e[t];break}return r}function E(e,n){return {name:`withTransform(${e.name})`,async load(){let r=e.load?await e.load():{};return R(r,n)},loadSync(){if(!e.loadSync)throw new Error(`Resolver ${e.name} does not support sync loading`);let r=e.loadSync();return R(r,n)}}}function R(e,n){let r={...e};for(let[s,o]of Object.entries(n))if(e[s]!==void 0)try{r[s]=o(e[s]);}catch(t){throw new Error(`Transform failed for ${s}: ${t instanceof Error?t.message:String(t)}`,{cause:t})}return r}function A(e,n){let s=`${n.toUpperCase()}_`;return {name:`withNamespace(${e.name}, ${n})`,async load(){let o=e.load?await e.load():{},t={};for(let[a,i]of Object.entries(o))if(a.toUpperCase().startsWith(s)){let c=a.slice(s.length);t[c]=i;}return t},loadSync(){if(!e.loadSync)throw new Error(`Resolver ${e.name} does not support sync loading`);let o=e.loadSync(),t={};for(let[a,i]of Object.entries(o))if(a.toUpperCase().startsWith(s)){let c=a.slice(s.length);t[c]=i;}return t}}}function j(e,n){let{onChange:r,debounce:s=100,files:o=[".env"]}=n??{},t,a=null,i=[],c=async()=>{try{return await import('./index.cjs'),t=await chunkDYFRO3NM_cjs.d(e),t}catch(l){throw console.error("[watch] Failed to load config:",l),l}},u=()=>{a&&clearTimeout(a),a=setTimeout(async()=>{try{let l=await c();r?.(l);}catch(l){console.error("[watch] Failed to reload config:",l);}},s);},{watch:d}=chunkD6WM53FN_cjs.a("fs"),{join:p}=chunkD6WM53FN_cjs.a("path");for(let l of o)try{let m=d(p(process.cwd(),l),u);i.push(m);}catch{}return c().catch(console.error),{getConfig:()=>t,stop:()=>{a&&clearTimeout(a);for(let l of i)l.close();}}}exports.TTL=w;exports.awsCache=P;exports.cached=x;exports.poll=O;exports.retry=v;exports.watch=j;exports.withAliases=k;exports.withComputed=$;exports.withNamespace=A;exports.withPrefix=S;exports.withTransform=E;
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveAsync } from './index.cjs';
|
|
2
|
-
import { Resolver
|
|
2
|
+
import { a as Resolver } from './types--RcOnfdl.cjs';
|
|
3
3
|
import './validation-types.cjs';
|
|
4
4
|
import './audit.cjs';
|
|
5
5
|
|
|
@@ -99,6 +99,60 @@ declare function awsCache(options?: {
|
|
|
99
99
|
* ```
|
|
100
100
|
*/
|
|
101
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>;
|
|
102
156
|
/**
|
|
103
157
|
* Wrap a resolver to strip a prefix from environment variable names
|
|
104
158
|
* Useful for scoping environment variables (e.g., APP_PORT → PORT)
|
|
@@ -229,16 +283,6 @@ declare function withTransform(resolver: Resolver, transforms: Record<string, (v
|
|
|
229
283
|
* ```
|
|
230
284
|
*/
|
|
231
285
|
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;
|
|
242
286
|
/**
|
|
243
287
|
* Watch configuration files and reload automatically
|
|
244
288
|
* Perfect for development - auto-reload when .env files change
|
|
@@ -280,4 +324,4 @@ declare function watch<T>(config: Parameters<typeof resolveAsync>[0], options?:
|
|
|
280
324
|
stop: () => void;
|
|
281
325
|
};
|
|
282
326
|
|
|
283
|
-
export { type CacheOptions, TTL, awsCache, cached,
|
|
327
|
+
export { type CacheOptions, type PollHandle, type PollOptions, TTL, awsCache, cached, poll, 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
|
|
2
|
+
import { a as Resolver } from './types--RcOnfdl.js';
|
|
3
3
|
import './validation-types.js';
|
|
4
4
|
import './audit.js';
|
|
5
5
|
|
|
@@ -99,6 +99,60 @@ declare function awsCache(options?: {
|
|
|
99
99
|
* ```
|
|
100
100
|
*/
|
|
101
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>;
|
|
102
156
|
/**
|
|
103
157
|
* Wrap a resolver to strip a prefix from environment variable names
|
|
104
158
|
* Useful for scoping environment variables (e.g., APP_PORT → PORT)
|
|
@@ -229,16 +283,6 @@ declare function withTransform(resolver: Resolver, transforms: Record<string, (v
|
|
|
229
283
|
* ```
|
|
230
284
|
*/
|
|
231
285
|
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;
|
|
242
286
|
/**
|
|
243
287
|
* Watch configuration files and reload automatically
|
|
244
288
|
* Perfect for development - auto-reload when .env files change
|
|
@@ -280,4 +324,4 @@ declare function watch<T>(config: Parameters<typeof resolveAsync>[0], options?:
|
|
|
280
324
|
stop: () => void;
|
|
281
325
|
};
|
|
282
326
|
|
|
283
|
-
export { type CacheOptions, TTL, awsCache, cached,
|
|
327
|
+
export { type CacheOptions, type PollHandle, type PollOptions, TTL, awsCache, cached, poll, retry, watch, withAliases, withComputed, withNamespace, withPrefix, withTransform };
|
package/dist/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {d}from'./chunk-3EWCMDFP.js';import'./chunk-K4NIC5T3.js';import'./chunk-CTJYBBOB.js';import'./chunk-6EWR3WHU.js';import'./chunk-WKIPEKF6.js';import'./chunk-ZMRT37K3.js';import {a}from'./chunk-I7AUKTXE.js';function x(e,n={}){let{ttl:r=3e5,maxAge:s=36e5,staleWhileRevalidate:o=false}=n,t=null,a={name:`cached(${e.name})`,metadata:{},async load(){let i=Date.now();if(!t||i-t.timestamp>s){let u=e.load?await e.load():{};return t={data:u,timestamp:i},a.metadata={cached:false},u}if(i-t.timestamp<r)return a.metadata={cached:true},t.data;if(o&&!t.refreshPromise){let u=Promise.resolve(e.load?e.load():Promise.resolve({}));return t.refreshPromise=u.then(d=>(t.data=d,t.timestamp=Date.now(),t.refreshPromise=void 0,d)).catch(()=>(t.refreshPromise=void 0,t.data)),a.metadata={cached:true,stale:true},t.data}let c=e.load?await e.load():{};return t={data:c,timestamp:i},a.metadata={cached:false},c}};return a}var w={short:30*1e3,minute:60*1e3,minutes5:300*1e3,minutes15:900*1e3,hour:3600*1e3,hours6:360*60*1e3,day:1440*60*1e3};function P(e={}){return {ttl:e.ttl??w.minutes5,maxAge:e.maxAge??w.hour,staleWhileRevalidate:e.staleWhileRevalidate??true,key:"aws-secrets"}}function v(e,n=3,r=1e3){return {name:`retry(${e.name})`,async load(){let s;for(let o=0;o<=n;o++)try{return e.load?await e.load():{}}catch(t){s=t instanceof Error?t:new Error(String(t)),o<n&&await new Promise(a=>setTimeout(a,r*Math.pow(2,o)));}throw s}}}function C(e,n){if(Object.is(e,n))return true;try{return JSON.stringify(e)===JSON.stringify(n)}catch{return false}}function O(e,n={}){let{intervalMs:r=1e4,immediate:s=true,onChange:o,onError:t,equals:a=C}=n,i,c=null,u=false,d=false,p=false,l=()=>{u||(c=setTimeout(()=>{c=null,m();},r));},m=async()=>{if(u||d)return i;d=true,c&&(clearTimeout(c),c=null);try{let f=await e(),g=i;return i=f,p&&!a(f,g)&&await o?.(f,g),p=!0,f}catch(f){return t?.(f),i}finally{d=false,u||l();}};return s?m():l(),{getCurrent:()=>i,refresh:()=>m(),stop:()=>{u=true,c&&(clearTimeout(c),c=null);}}}function S(e,n){let r=n.toUpperCase();return {name:`withPrefix(${e.name}, ${n})`,async load(){let s=e.load?await e.load():{},o={};for(let[t,a]of Object.entries(s))if(t.toUpperCase().startsWith(r)){let i=t.slice(n.length);o[i]=a;}else o[t]=a;return o},loadSync(){if(!e.loadSync)throw new Error(`Resolver ${e.name} does not support sync loading`);let s=e.loadSync(),o={};for(let[t,a]of Object.entries(s))if(t.toUpperCase().startsWith(r)){let i=t.slice(n.length);o[i]=a;}else o[t]=a;return o}}}function $(e,n){let r={...e};for(let[s,o]of Object.entries(n))Object.defineProperty(r,s,{get(){return o(e)},enumerable:true,configurable:true});return r}function k(e,n){return {name:`withAliases(${e.name})`,async load(){let r=e.load?await e.load():{};return T(r,n)},loadSync(){if(!e.loadSync)throw new Error(`Resolver ${e.name} does not support sync loading`);let r=e.loadSync();return T(r,n)}}}function T(e,n){let r={...e};for(let[s,o]of Object.entries(n))for(let t of o)if(e[t]!==void 0){r[s]=e[t];break}return r}function E(e,n){return {name:`withTransform(${e.name})`,async load(){let r=e.load?await e.load():{};return R(r,n)},loadSync(){if(!e.loadSync)throw new Error(`Resolver ${e.name} does not support sync loading`);let r=e.loadSync();return R(r,n)}}}function R(e,n){let r={...e};for(let[s,o]of Object.entries(n))if(e[s]!==void 0)try{r[s]=o(e[s]);}catch(t){throw new Error(`Transform failed for ${s}: ${t instanceof Error?t.message:String(t)}`,{cause:t})}return r}function A(e,n){let s=`${n.toUpperCase()}_`;return {name:`withNamespace(${e.name}, ${n})`,async load(){let o=e.load?await e.load():{},t={};for(let[a,i]of Object.entries(o))if(a.toUpperCase().startsWith(s)){let c=a.slice(s.length);t[c]=i;}return t},loadSync(){if(!e.loadSync)throw new Error(`Resolver ${e.name} does not support sync loading`);let o=e.loadSync(),t={};for(let[a,i]of Object.entries(o))if(a.toUpperCase().startsWith(s)){let c=a.slice(s.length);t[c]=i;}return t}}}function j(e,n){let{onChange:r,debounce:s=100,files:o=[".env"]}=n??{},t,a$1=null,i=[],c=async()=>{try{return await import('./index.js'),t=await d(e),t}catch(l){throw console.error("[watch] Failed to load config:",l),l}},u=()=>{a$1&&clearTimeout(a$1),a$1=setTimeout(async()=>{try{let l=await c();r?.(l);}catch(l){console.error("[watch] Failed to reload config:",l);}},s);},{watch:d$1}=a("fs"),{join:p}=a("path");for(let l of o)try{let m=d$1(p(process.cwd(),l),u);i.push(m);}catch{}return c().catch(console.error),{getConfig:()=>t,stop:()=>{a$1&&clearTimeout(a$1);for(let l of i)l.close();}}}export{w as TTL,P as awsCache,x as cached,O as poll,v as retry,j as watch,k as withAliases,$ as withComputed,A as withNamespace,S as withPrefix,E as withTransform};
|
package/dist/valibot.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';require('./chunk-
|
|
1
|
+
'use strict';require('./chunk-DIJNUFGZ.cjs');var chunkCDXO2XX3_cjs=require('./chunk-CDXO2XX3.cjs'),chunk4QOKRJ3F_cjs=require('./chunk-4QOKRJ3F.cjs');require('./chunk-D6WM53FN.cjs');async function v(o,t,e,c){let r={},a={};for(let n of o)try{let s=n.load?await n.load():{};r={...r,...s};for(let[i,u]of Object.entries(s))u!==void 0&&(a[i]={source:n.name||"unknown",timestamp:Date.now()});}catch(s){if(e)throw new Error(`Resolver ${n.name} failed: ${s instanceof Error?s.message:s}`,{cause:s})}if(t)for(let[n,s]of Object.entries(r))r[n]=s.replace(/\$\{([^}]+)\}/g,(i,u)=>r[u]||"");return await chunkCDXO2XX3_cjs.c(r,a,c),{env:r,provenance:a}}function d(o,t,e,c){let r={},a={};for(let n of o)try{if(!n.loadSync){if(e)throw new Error(`Resolver ${n.name} does not support sync loading`);continue}let s=n.loadSync();r={...r,...s};for(let[i,u]of Object.entries(s))u!==void 0&&(a[i]={source:n.name||"unknown",timestamp:Date.now()});}catch(s){if(e)throw new Error(`Resolver ${n.name} failed: ${s instanceof Error?s.message:s}`,{cause:s})}if(t)for(let[n,s]of Object.entries(r))r[n]=s.replace(/\$\{([^}]+)\}/g,(i,u)=>r[u]||"");return chunkCDXO2XX3_cjs.b(r,a,c),{env:r,provenance:a}}function y(o){return !o||!Array.isArray(o)?[{path:[],message:"Validation failed",code:"unknown_error"}]:o.map(t=>{if(!t||typeof t!="object")return {path:[],message:"Validation failed",code:"unknown_error"};let e=t;return {path:e.path?.map(c=>c.key)||[],message:e.message||"Validation failed",code:e.type}})}async function b(o,t={}){let{resolvers:e=[chunk4QOKRJ3F_cjs.a()],interpolate:c=false,strict:r=true,references:a}=t,{env:n}=await v(e,c,r,a);return o.parseAsync(n)}async function w(o,t={}){try{let{resolvers:e=[chunk4QOKRJ3F_cjs.a()],interpolate:c=!1,strict:r=!0,references:a}=t,{env:n}=await v(e,c,r,a),s=await o.safeParseAsync(n);if(s.success)return {success:!0,data:s.output};let i=y(s.issues);return {success:!1,error:i.map(f=>f.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 h(o,t={}){let{resolvers:e=[chunk4QOKRJ3F_cjs.a()],interpolate:c=false,strict:r=true,references:a}=t,{env:n}=d(e,c,r,a);return o.parse(n)}function S(o,t={}){try{let{resolvers:e=[chunk4QOKRJ3F_cjs.a()],interpolate:c=!1,strict:r=!0,references:a}=t,{env:n}=d(e,c,r,a),s=o.safeParse(n);if(s.success)return {success:!0,data:s.output};let i=y(s.issues);return {success:!1,error:i.map(f=>f.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=h;exports.resolveValibot=b;exports.safeResolveSyncValibot=S;exports.safeResolveValibot=w;
|
package/dist/valibot.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Resolver, PolicyOptions } from './types.cjs';
|
|
1
|
+
import { a as Resolver, P as PolicyOptions, b as ReferenceOptions } from './types--RcOnfdl.cjs';
|
|
2
2
|
import { SafeResolveResult } from './validation-types.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -19,6 +19,13 @@ import { SafeResolveResult } from './validation-types.cjs';
|
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
+
type ResolveValibotOptions = {
|
|
23
|
+
resolvers?: Resolver[];
|
|
24
|
+
interpolate?: boolean;
|
|
25
|
+
strict?: boolean;
|
|
26
|
+
policies?: PolicyOptions;
|
|
27
|
+
references?: ReferenceOptions;
|
|
28
|
+
};
|
|
22
29
|
/**
|
|
23
30
|
* Type inference for Valibot schema output
|
|
24
31
|
* Uses Valibot's InferOutput if available, falls back to generic inference
|
|
@@ -49,12 +56,7 @@ type InferValibotOutput<T> = T extends {
|
|
|
49
56
|
*/
|
|
50
57
|
declare function resolveValibot<TSchema extends {
|
|
51
58
|
parseAsync: (input: unknown) => Promise<unknown>;
|
|
52
|
-
}>(valibotSchema: TSchema, options?:
|
|
53
|
-
resolvers?: Resolver[];
|
|
54
|
-
interpolate?: boolean;
|
|
55
|
-
strict?: boolean;
|
|
56
|
-
policies?: PolicyOptions;
|
|
57
|
-
}): Promise<InferValibotOutput<TSchema>>;
|
|
59
|
+
}>(valibotSchema: TSchema, options?: ResolveValibotOptions): Promise<InferValibotOutput<TSchema>>;
|
|
58
60
|
/**
|
|
59
61
|
* Safe version - returns result object instead of throwing (unified error format)
|
|
60
62
|
*
|
|
@@ -86,12 +88,7 @@ declare function safeResolveValibot<TSchema extends {
|
|
|
86
88
|
output?: unknown;
|
|
87
89
|
issues?: unknown;
|
|
88
90
|
}>;
|
|
89
|
-
}>(valibotSchema: TSchema, options?:
|
|
90
|
-
resolvers?: Resolver[];
|
|
91
|
-
interpolate?: boolean;
|
|
92
|
-
strict?: boolean;
|
|
93
|
-
policies?: PolicyOptions;
|
|
94
|
-
}): Promise<SafeResolveResult<InferValibotOutput<TSchema>>>;
|
|
91
|
+
}>(valibotSchema: TSchema, options?: ResolveValibotOptions): Promise<SafeResolveResult<InferValibotOutput<TSchema>>>;
|
|
95
92
|
/**
|
|
96
93
|
* Sync version of resolveValibot (throws on validation error)
|
|
97
94
|
*
|
|
@@ -110,12 +107,7 @@ declare function safeResolveValibot<TSchema extends {
|
|
|
110
107
|
*/
|
|
111
108
|
declare function resolveSyncValibot<TSchema extends {
|
|
112
109
|
parse: (input: unknown) => unknown;
|
|
113
|
-
}>(valibotSchema: TSchema, options?:
|
|
114
|
-
resolvers?: Resolver[];
|
|
115
|
-
interpolate?: boolean;
|
|
116
|
-
strict?: boolean;
|
|
117
|
-
policies?: PolicyOptions;
|
|
118
|
-
}): InferValibotOutput<TSchema>;
|
|
110
|
+
}>(valibotSchema: TSchema, options?: ResolveValibotOptions): InferValibotOutput<TSchema>;
|
|
119
111
|
/**
|
|
120
112
|
* Safe sync version - returns result object instead of throwing (unified error format)
|
|
121
113
|
*
|
|
@@ -146,11 +138,6 @@ declare function safeResolveSyncValibot<TSchema extends {
|
|
|
146
138
|
output?: unknown;
|
|
147
139
|
issues?: unknown;
|
|
148
140
|
};
|
|
149
|
-
}>(valibotSchema: TSchema, options?:
|
|
150
|
-
resolvers?: Resolver[];
|
|
151
|
-
interpolate?: boolean;
|
|
152
|
-
strict?: boolean;
|
|
153
|
-
policies?: PolicyOptions;
|
|
154
|
-
}): SafeResolveResult<InferValibotOutput<TSchema>>;
|
|
141
|
+
}>(valibotSchema: TSchema, options?: ResolveValibotOptions): SafeResolveResult<InferValibotOutput<TSchema>>;
|
|
155
142
|
|
|
156
143
|
export { type InferValibotOutput, resolveSyncValibot, resolveValibot, safeResolveSyncValibot, safeResolveValibot };
|