arkenv 1.0.0-alpha.2 → 1.0.0-alpha.21

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/dist/index.d.cts DELETED
@@ -1,235 +0,0 @@
1
- import { a as SafeArkEnvResult } from "./core-7-JO-N-w.cjs";
2
- import { a as Dict, n as SchemaShape, o as $, r as InferType, t as CompiledEnvSchema } from "./index-Do-2CL1V.cjs";
3
- import * as _$arktype_internal_keywords_string_ts0 from "arktype/internal/keywords/string.ts";
4
- import * as _$arktype_internal_attributes_ts0 from "arktype/internal/attributes.ts";
5
- import * as _$arktype from "arktype";
6
- import { distill, type as type$1 } from "arktype";
7
- import * as _$arktype_internal_type_ts0 from "arktype/internal/type.ts";
8
-
9
- //#region src/arkenv.d.ts
10
- /**
11
- * Declarative environment schema definition accepted by ArkEnv.
12
- *
13
- * Represents a declarative schema object mapping environment
14
- * variable names to schema definitions (e.g. ArkType DSL strings
15
- * or Standard Schema validators).
16
- *
17
- * This type is used to validate that a schema object is compatible with
18
- * ArkEnv’s validator scope before being compiled or parsed.
19
- *
20
- * Most users will provide schemas in this form.
21
- *
22
- * @template def - The schema shape object
23
- */
24
- type EnvSchema<def> = type$1.validate<def, $>;
25
- /**
26
- * Infer the validated and coerced environment object type from a schema.
27
- * Supports declarative schema shapes, compiled ArkType schemas, and Standard Schema validators.
28
- *
29
- * @template T - The schema type
30
- */
31
- type Infer<T> = T extends SchemaShape ? distill.Out<type$1.infer<T, $>> : InferType<T>;
32
- /**
33
- * The environment variables passed to `arkenv`.
34
- * Uses `Dict<string>` to enforce
35
- * compile-time safety: all input environment variables must be strings
36
- * (or undefined), matching `process.env` semantics.
37
- */
38
- type RuntimeEnvironment = Dict<string>;
39
- /**
40
- * Configuration options for `arkenv`
41
- */
42
- type ArkEnvConfig = {
43
- /**
44
- * The environment variables to parse. Defaults to `process.env`
45
- */
46
- env?: RuntimeEnvironment;
47
- /**
48
- * Whether to coerce environment variables to their defined types. Defaults to `true`
49
- */
50
- coerce?: boolean;
51
- /**
52
- * Control how ArkEnv handles environment variables that are not defined in your schema.
53
- *
54
- * Defaults to `'delete'` to ensure your output object only contains
55
- * keys you've explicitly declared. This differs from ArkType's standard behavior, which
56
- * mirrors TypeScript by defaulting to `'ignore'`.
57
- *
58
- * - `delete` (ArkEnv default): Undeclared keys are allowed on input but stripped from the output.
59
- * - `ignore` (ArkType default): Undeclared keys are allowed and preserved in the output.
60
- * - `reject`: Undeclared keys will cause validation to fail.
61
- *
62
- * @default "delete"
63
- * @see https://arktype.io/docs/configuration#onundeclaredkey
64
- */
65
- onUndeclaredKey?: "ignore" | "delete" | "reject";
66
- /**
67
- * The format to use for array parsing when coercion is enabled.
68
- *
69
- * - `comma` (default): Strings are split by comma and trimmed.
70
- * - `json`: Strings are parsed as JSON.
71
- *
72
- * @default "comma"
73
- */
74
- arrayFormat?: "comma" | "json";
75
- /**
76
- * Whether to bypass secret redaction and print raw sensitive values during debugging.
77
- * Defaults to checking `process.env.ARKENV_DEBUG_SECRETS === "true"` or `"1"`.
78
- */
79
- debugSecrets?: boolean;
80
- /**
81
- * Whether to treat empty strings (`""`) as `undefined` before validation.
82
- *
83
- * When enabled, an environment variable set to an empty value (e.g. `PORT=`)
84
- * will be treated as if it were missing, allowing defaults to apply and
85
- * preventing validation errors for numeric or boolean types.
86
- *
87
- * @default false
88
- */
89
- emptyAsUndefined?: boolean;
90
- /**
91
- * Whether to return a safe result object instead of throwing an error on validation failure.
92
- *
93
- * When enabled, the function returns an object with `{ success: true, data }` or `{ success: false, issues }`.
94
- *
95
- * @default false
96
- */
97
- safe?: boolean;
98
- };
99
- /**
100
- * Helper type to represent the output of parsing either an EnvSchema or CompiledEnvSchema.
101
- */
102
- type ArkenvOutput<T extends SchemaShape, D> = distill.Out<type$1.infer<T, $>> | InferType<D>;
103
- /**
104
- * Utility to parse environment variables using ArkType or Standard Schema
105
- *
106
- * Naming convention: the main function is lowercase (`arkenv`) following the
107
- * JavaScript convention for functions (e.g. `zod`, `joi`). Classes and types
108
- * use PascalCase with the full product name (`ArkEnvError`, `SafeArkEnvResult`).
109
- *
110
- * @param def The schema definition
111
- * @param config The evaluation configuration
112
- * @returns The parsed environment variables, or a SafeArkEnvResult if `{ safe: true }` is configured
113
- * @throws An {@link ArkEnvError | error} if the environment variables are invalid and `safe` is not enabled
114
- */
115
- declare function arkenv<const T extends SchemaShape>(def: EnvSchema<T>, config?: ArkEnvConfig & {
116
- safe?: false;
117
- }): distill.Out<type$1.infer<T, $>>;
118
- declare function arkenv<T extends CompiledEnvSchema>(def: T, config?: ArkEnvConfig & {
119
- safe?: false;
120
- }): InferType<T>;
121
- declare function arkenv<const T extends SchemaShape, const D extends EnvSchema<T> | CompiledEnvSchema>(def: D, config?: ArkEnvConfig & {
122
- safe?: false;
123
- }): ArkenvOutput<T, D>;
124
- declare function arkenv<const T extends SchemaShape>(def: EnvSchema<T>, config: ArkEnvConfig & {
125
- safe: true;
126
- }): SafeArkEnvResult<distill.Out<type$1.infer<T, $>>>;
127
- declare function arkenv<T extends CompiledEnvSchema>(def: T, config: ArkEnvConfig & {
128
- safe: true;
129
- }): SafeArkEnvResult<InferType<T>>;
130
- declare function arkenv<const T extends SchemaShape, const D extends EnvSchema<T> | CompiledEnvSchema>(def: D, config: ArkEnvConfig & {
131
- safe: true;
132
- }): SafeArkEnvResult<ArkenvOutput<T, D>>;
133
- //#endregion
134
- //#region src/schema.d.ts
135
- /**
136
- * Extract the keys from a schema definition dynamically.
137
- * Supports plain objects, ArkType schemas, and Standard Schema validators.
138
- *
139
- * @param schema The schema definition to extract keys from
140
- * @returns An array of extracted key names
141
- * @internal
142
- */
143
- declare function getSchemaKeys(schema: any): string[];
144
- //#endregion
145
- //#region src/index.d.ts
146
- /**
147
- * Like ArkType's `type`, but with ArkEnv's extra keywords, such as:
148
- *
149
- * - `string.host` – a hostname (e.g. `"localhost"`, `"127.0.0.1"`)
150
- * - `number.port` – a port number (e.g. `8080`)
151
- *
152
- * See ArkType's docs for the full API:
153
- * https://arktype.io/docs/type-api
154
- */
155
- declare const type: _$arktype_internal_type_ts0.TypeParser<{
156
- string: _$arktype.Submodule<{
157
- trim: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.trim.$ & {
158
- " arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
159
- }>;
160
- normalize: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.normalize.$ & {
161
- " arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
162
- }>;
163
- root: string;
164
- alpha: string;
165
- alphanumeric: string;
166
- hex: string;
167
- base64: _$arktype.Submodule<{
168
- root: string;
169
- url: string;
170
- } & {
171
- " arkInferred": string;
172
- }>;
173
- capitalize: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.capitalize.$ & {
174
- " arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
175
- }>;
176
- creditCard: string;
177
- date: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.stringDate.$ & {
178
- " arkInferred": string;
179
- }>;
180
- digits: string;
181
- email: string;
182
- integer: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.stringInteger.$ & {
183
- " arkInferred": string;
184
- }>;
185
- ip: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.ip.$ & {
186
- " arkInferred": string;
187
- }>;
188
- json: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.stringJson.$ & {
189
- " arkInferred": string;
190
- }>;
191
- lower: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.lower.$ & {
192
- " arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
193
- }>;
194
- numeric: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.stringNumeric.$ & {
195
- " arkInferred": string;
196
- }>;
197
- regex: string;
198
- semver: string;
199
- upper: _$arktype.Submodule<{
200
- root: (In: string) => _$arktype_internal_attributes_ts0.To<string>;
201
- preformatted: string;
202
- } & {
203
- " arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
204
- }>;
205
- url: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.url.$ & {
206
- " arkInferred": string;
207
- }>;
208
- uuid: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.uuid.$ & {
209
- " arkInferred": string;
210
- }>;
211
- " arkInferred": string;
212
- host: string;
213
- }>;
214
- number: _$arktype.Submodule<{
215
- NaN: number;
216
- Infinity: number;
217
- root: number;
218
- integer: number;
219
- " arkInferred": number;
220
- epoch: number;
221
- safe: number;
222
- NegativeInfinity: number;
223
- port: number;
224
- }>;
225
- }>;
226
- //#endregion
227
- export { type ArkEnvConfig, type EnvSchema, type Infer, type SafeArkEnvResult, arkenv, arkenv as default, getSchemaKeys, type };
228
-
229
- // CJS Interop Shim
230
- if (module.exports && module.exports.default) {
231
- Object.assign(module.exports.default, module.exports);
232
- module.exports = module.exports.default;
233
- }
234
-
235
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/arkenv.ts","../src/schema.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;;AA0BA;;;;;;;;;KAAY,SAAA,QAAiB,MAAA,CAAG,QAAA,CAAS,GAAA,EAAK,CAAA;;;;;;AAQ9C;KAAY,KAAA,MAAW,CAAA,SAAU,WAAA,GAC9B,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,CAAA,EAAG,CAAA,KACxB,SAAA,CAAU,CAAA;;;;;;;KAQR,kBAAA,GAAqB,IAAA;;;;KAKd,YAAA;EAfM;;;EAmBjB,GAAA,GAAM,kBAAA;EAlBI;;;EAsBV,MAAA;EAtB0B;;;;;AACX;;;;;AAahB;;;;EAuBC,eAAA;EAnBM;;;;;;;;EA6BN,WAAA;EAkCW;;;;EA5BX,YAAA;EA6B0B;;;;;;;;;EAlB1B,gBAAA;EAkBE;;;;;;;EATF,IAAA;AAAA;AAwBD;;;AAAA,KAhBY,YAAA,WAAuB,W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AI,UAAA"}
package/dist/index.d.mts DELETED
@@ -1,229 +0,0 @@
1
- import { a as SafeArkEnvResult } from "./core-BaGd9k2K.mjs";
2
- import { a as Dict, n as SchemaShape, o as $, r as InferType, t as CompiledEnvSchema } from "./index-NbQAnciD.mjs";
3
- import * as _$arktype from "arktype";
4
- import { distill, type as type$1 } from "arktype";
5
- import * as _$arktype_internal_keywords_string_ts0 from "arktype/internal/keywords/string.ts";
6
- import * as _$arktype_internal_attributes_ts0 from "arktype/internal/attributes.ts";
7
- import * as _$arktype_internal_type_ts0 from "arktype/internal/type.ts";
8
-
9
- //#region src/arkenv.d.ts
10
- /**
11
- * Declarative environment schema definition accepted by ArkEnv.
12
- *
13
- * Represents a declarative schema object mapping environment
14
- * variable names to schema definitions (e.g. ArkType DSL strings
15
- * or Standard Schema validators).
16
- *
17
- * This type is used to validate that a schema object is compatible with
18
- * ArkEnv’s validator scope before being compiled or parsed.
19
- *
20
- * Most users will provide schemas in this form.
21
- *
22
- * @template def - The schema shape object
23
- */
24
- type EnvSchema<def> = type$1.validate<def, $>;
25
- /**
26
- * Infer the validated and coerced environment object type from a schema.
27
- * Supports declarative schema shapes, compiled ArkType schemas, and Standard Schema validators.
28
- *
29
- * @template T - The schema type
30
- */
31
- type Infer<T> = T extends SchemaShape ? distill.Out<type$1.infer<T, $>> : InferType<T>;
32
- /**
33
- * The environment variables passed to `arkenv`.
34
- * Uses `Dict<string>` to enforce
35
- * compile-time safety: all input environment variables must be strings
36
- * (or undefined), matching `process.env` semantics.
37
- */
38
- type RuntimeEnvironment = Dict<string>;
39
- /**
40
- * Configuration options for `arkenv`
41
- */
42
- type ArkEnvConfig = {
43
- /**
44
- * The environment variables to parse. Defaults to `process.env`
45
- */
46
- env?: RuntimeEnvironment;
47
- /**
48
- * Whether to coerce environment variables to their defined types. Defaults to `true`
49
- */
50
- coerce?: boolean;
51
- /**
52
- * Control how ArkEnv handles environment variables that are not defined in your schema.
53
- *
54
- * Defaults to `'delete'` to ensure your output object only contains
55
- * keys you've explicitly declared. This differs from ArkType's standard behavior, which
56
- * mirrors TypeScript by defaulting to `'ignore'`.
57
- *
58
- * - `delete` (ArkEnv default): Undeclared keys are allowed on input but stripped from the output.
59
- * - `ignore` (ArkType default): Undeclared keys are allowed and preserved in the output.
60
- * - `reject`: Undeclared keys will cause validation to fail.
61
- *
62
- * @default "delete"
63
- * @see https://arktype.io/docs/configuration#onundeclaredkey
64
- */
65
- onUndeclaredKey?: "ignore" | "delete" | "reject";
66
- /**
67
- * The format to use for array parsing when coercion is enabled.
68
- *
69
- * - `comma` (default): Strings are split by comma and trimmed.
70
- * - `json`: Strings are parsed as JSON.
71
- *
72
- * @default "comma"
73
- */
74
- arrayFormat?: "comma" | "json";
75
- /**
76
- * Whether to bypass secret redaction and print raw sensitive values during debugging.
77
- * Defaults to checking `process.env.ARKENV_DEBUG_SECRETS === "true"` or `"1"`.
78
- */
79
- debugSecrets?: boolean;
80
- /**
81
- * Whether to treat empty strings (`""`) as `undefined` before validation.
82
- *
83
- * When enabled, an environment variable set to an empty value (e.g. `PORT=`)
84
- * will be treated as if it were missing, allowing defaults to apply and
85
- * preventing validation errors for numeric or boolean types.
86
- *
87
- * @default false
88
- */
89
- emptyAsUndefined?: boolean;
90
- /**
91
- * Whether to return a safe result object instead of throwing an error on validation failure.
92
- *
93
- * When enabled, the function returns an object with `{ success: true, data }` or `{ success: false, issues }`.
94
- *
95
- * @default false
96
- */
97
- safe?: boolean;
98
- };
99
- /**
100
- * Helper type to represent the output of parsing either an EnvSchema or CompiledEnvSchema.
101
- */
102
- type ArkenvOutput<T extends SchemaShape, D> = distill.Out<type$1.infer<T, $>> | InferType<D>;
103
- /**
104
- * Utility to parse environment variables using ArkType or Standard Schema
105
- *
106
- * Naming convention: the main function is lowercase (`arkenv`) following the
107
- * JavaScript convention for functions (e.g. `zod`, `joi`). Classes and types
108
- * use PascalCase with the full product name (`ArkEnvError`, `SafeArkEnvResult`).
109
- *
110
- * @param def The schema definition
111
- * @param config The evaluation configuration
112
- * @returns The parsed environment variables, or a SafeArkEnvResult if `{ safe: true }` is configured
113
- * @throws An {@link ArkEnvError | error} if the environment variables are invalid and `safe` is not enabled
114
- */
115
- declare function arkenv<const T extends SchemaShape>(def: EnvSchema<T>, config?: ArkEnvConfig & {
116
- safe?: false;
117
- }): distill.Out<type$1.infer<T, $>>;
118
- declare function arkenv<T extends CompiledEnvSchema>(def: T, config?: ArkEnvConfig & {
119
- safe?: false;
120
- }): InferType<T>;
121
- declare function arkenv<const T extends SchemaShape, const D extends EnvSchema<T> | CompiledEnvSchema>(def: D, config?: ArkEnvConfig & {
122
- safe?: false;
123
- }): ArkenvOutput<T, D>;
124
- declare function arkenv<const T extends SchemaShape>(def: EnvSchema<T>, config: ArkEnvConfig & {
125
- safe: true;
126
- }): SafeArkEnvResult<distill.Out<type$1.infer<T, $>>>;
127
- declare function arkenv<T extends CompiledEnvSchema>(def: T, config: ArkEnvConfig & {
128
- safe: true;
129
- }): SafeArkEnvResult<InferType<T>>;
130
- declare function arkenv<const T extends SchemaShape, const D extends EnvSchema<T> | CompiledEnvSchema>(def: D, config: ArkEnvConfig & {
131
- safe: true;
132
- }): SafeArkEnvResult<ArkenvOutput<T, D>>;
133
- //#endregion
134
- //#region src/schema.d.ts
135
- /**
136
- * Extract the keys from a schema definition dynamically.
137
- * Supports plain objects, ArkType schemas, and Standard Schema validators.
138
- *
139
- * @param schema The schema definition to extract keys from
140
- * @returns An array of extracted key names
141
- * @internal
142
- */
143
- declare function getSchemaKeys(schema: any): string[];
144
- //#endregion
145
- //#region src/index.d.ts
146
- /**
147
- * Like ArkType's `type`, but with ArkEnv's extra keywords, such as:
148
- *
149
- * - `string.host` – a hostname (e.g. `"localhost"`, `"127.0.0.1"`)
150
- * - `number.port` – a port number (e.g. `8080`)
151
- *
152
- * See ArkType's docs for the full API:
153
- * https://arktype.io/docs/type-api
154
- */
155
- declare const type: _$arktype_internal_type_ts0.TypeParser<{
156
- string: _$arktype.Submodule<{
157
- trim: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.trim.$ & {
158
- " arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
159
- }>;
160
- normalize: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.normalize.$ & {
161
- " arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
162
- }>;
163
- root: string;
164
- alpha: string;
165
- alphanumeric: string;
166
- hex: string;
167
- base64: _$arktype.Submodule<{
168
- root: string;
169
- url: string;
170
- } & {
171
- " arkInferred": string;
172
- }>;
173
- capitalize: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.capitalize.$ & {
174
- " arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
175
- }>;
176
- creditCard: string;
177
- date: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.stringDate.$ & {
178
- " arkInferred": string;
179
- }>;
180
- digits: string;
181
- email: string;
182
- integer: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.stringInteger.$ & {
183
- " arkInferred": string;
184
- }>;
185
- ip: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.ip.$ & {
186
- " arkInferred": string;
187
- }>;
188
- json: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.stringJson.$ & {
189
- " arkInferred": string;
190
- }>;
191
- lower: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.lower.$ & {
192
- " arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
193
- }>;
194
- numeric: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.stringNumeric.$ & {
195
- " arkInferred": string;
196
- }>;
197
- regex: string;
198
- semver: string;
199
- upper: _$arktype.Submodule<{
200
- root: (In: string) => _$arktype_internal_attributes_ts0.To<string>;
201
- preformatted: string;
202
- } & {
203
- " arkInferred": (In: string) => _$arktype_internal_attributes_ts0.To<string>;
204
- }>;
205
- url: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.url.$ & {
206
- " arkInferred": string;
207
- }>;
208
- uuid: _$arktype.Submodule<_$arktype_internal_keywords_string_ts0.uuid.$ & {
209
- " arkInferred": string;
210
- }>;
211
- " arkInferred": string;
212
- host: string;
213
- }>;
214
- number: _$arktype.Submodule<{
215
- NaN: number;
216
- Infinity: number;
217
- root: number;
218
- integer: number;
219
- " arkInferred": number;
220
- epoch: number;
221
- safe: number;
222
- NegativeInfinity: number;
223
- port: number;
224
- }>;
225
- }>;
226
- //#endregion
227
- export { type ArkEnvConfig, type EnvSchema, type Infer, type SafeArkEnvResult, arkenv, arkenv as default, getSchemaKeys, type };
228
-
229
- //# sourceMappingURL=index.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/arkenv.ts","../src/schema.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;;AA0BA;;;;;;;;;KAAY,SAAA,QAAiB,MAAA,CAAG,QAAA,CAAS,GAAA,EAAK,CAAA;;;;;;AAQ9C;KAAY,KAAA,MAAW,CAAA,SAAU,WAAA,GAC9B,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,CAAA,EAAG,CAAA,KACxB,SAAA,CAAU,CAAA;;;;;;;KAQR,kBAAA,GAAqB,IAAA;;;;KAKd,YAAA;EAfM;;;EAmBjB,GAAA,GAAM,kBAAA;EAlBI;;;EAsBV,MAAA;EAtB0B;;;;;AACX;;;;;AAahB;;;;EAuBC,eAAA;EAnBM;;;;;;;;EA6BN,WAAA;EAkCW;;;;EA5BX,YAAA;EA6B0B;;;;;;;;;EAlB1B,gBAAA;EAkBE;;;;;;;EATF,IAAA;AAAA;AAwBD;;;AAAA,KAhBY,YAAA,WAAuB,WAAA,OAChC,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,CAAA,EAAG,CAAA,KACxB,SAAA,CAAU,CAAA;;;;;;;;;;;;;iBAcG,MAAA,iBAAuB,WAAA,CAAA,CACtC,GAAA,EAAK,SAAA,CAAU,CAAA,GACf,MAAA,GAAS,YAAA;EAAiB,IAAA;AAAA,IACxB,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,CAAA,EAAG,CAAA;AAAA,iBACX,MAAA,WAAiB,iBAAA,CAAA,CAChC,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,YAAA;EAAiB,IAAA;AAAA,IACxB,SAAA,CAAU,CAAA;AAAA,iBACG,MAAA,iBACC,WAAA,kBACA,SAAA,CAAU,CAAA,IAAK,iBAAA,CAAA,CAC9B,GAAA,EAAK,CAAA,EAAG,MAAA,GAAS,YAAA;EAAiB,IAAA;AAAA,IAAiB,YAAA,CAAa,CAAA,EAAG,CAAA;AAAA,iBACrD,MAAA,iBAAuB,WAAA,CAAA,CACtC,GAAA,EAAK,SAAA,CAAU,CAAA,GACf,MAAA,EAAQ,YAAA;EAAiB,IAAA;AAAA,IACvB,gBAAA,CAAiB,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,CAAA,EAAG,CAAA;AAAA,iBAC5B,MAAA,WAAiB,iBAAA,CAAA,CAChC,GAAA,EAAK,CAAA,EACL,MAAA,EAAQ,YAAA;EAAiB,IAAA;AAAA,IACvB,gBAAA,CAAiB,SAAA,CAAU,CAAA;AAAA,iBACd,MAAA,iBACC,WAAA,kBACA,SAAA,CAAU,CAAA,IAAK,iBAAA,CAAA,CAE/B,GAAA,EAAK,CAAA,EACL,MAAA,EAAQ,YAAA;EAAiB,IAAA;AAAA,IACvB,gBAAA,CAAiB,YAAA,CAAa,CAAA,EAAG,CAAA;;;;;;;;;;;iBCrJpB,aAAA,CAAc,MAAA;;;;;;;;;ADiB9B;;;cEZa,IAAA,8BAAI,UAAA"}
package/dist/index.mjs DELETED
@@ -1,3 +0,0 @@
1
- import{a as e,c as t,l as n,r,s as i,t as a}from"./errors-C_uh86xh.mjs";import{t as o}from"./core-A65KioHX.mjs";import{ArkErrors as s,scope as c,type as l}from"arktype";const u=l(`0 <= number.integer <= 65535`),d=l(`string.ip | 'localhost'`),f=c({string:l.module({...l.keywords.string,host:d}),number:l.module({...l.keywords.number,port:u})});function p(t,n){return Object.entries(t.byPath).map(([t,o])=>{let s=o.message,c=s.trimStart();if(c.length>0&&`:.-`.includes(c[0])&&(c=c.slice(1).trimStart()),c.toLowerCase().startsWith(t.toLowerCase())){let e=c.slice(t.length).trimStart();e.length>0&&`:.-`.includes(e[0])&&(e=e.slice(1)),s=e.trimStart()}s=i(s,t,n?.debugSecrets);let l=e(o.code),u={...r(o)};return a(t,s,l,u,o.expected,o.code===`required`?void 0:o.data)})}function m(e,t){let{env:r=process.env,coerce:i=!0,onUndeclaredKey:a=`delete`,arrayFormat:c=`comma`,emptyAsUndefined:l=!1}=t,u=(typeof e==`function`&&`assert`in e?e:f.type.raw(e)).onUndeclaredKey(a),{coercedEnv:d}=n(r,l,c,i?()=>({schema:u.in.toJsonSchema({fallback:e=>e.base}),hasSchema:!0}):void 0),m=u(d);if(m instanceof s)throw new o(p(m,t));return m}function h(e,n={}){return n.safe?t(()=>m(e,n)):m(e,n)}function g(e){if(!e||typeof e!=`object`&&typeof e!=`function`)return[];if(e.json&&typeof e.json==`object`&&e.json.domain===`object`){let t=[];if(Array.isArray(e.json.required))for(let n of e.json.required)n&&typeof n==`object`&&`key`in n&&t.push(n.key);if(Array.isArray(e.json.optional))for(let n of e.json.optional)n&&typeof n==`object`&&`key`in n&&t.push(n.key);return t}let t=e[`~standard`],n=typeof t?.jsonSchema?.input==`function`&&t.jsonSchema.input||typeof e.jsonSchema?.input==`function`&&e.jsonSchema.input;if(n)try{let e=n({target:`draft-07`});if(e&&typeof e==`object`&&e.properties)return Object.keys(e.properties)}catch{}if(typeof e.toJSONSchema==`function`)try{let t=e.toJSONSchema();if(t&&typeof t==`object`&&t.properties)return Object.keys(t.properties)}catch{}if(typeof e.toStandardJSONSchema?.v1==`function`)try{let t=e.toStandardJSONSchema.v1();if(t&&typeof t==`object`&&t.properties)return Object.keys(t.properties)}catch{}return Object.keys(e)}const _=f.type;var v=h;export{h as arkenv,v as default,g as getSchemaKeys,_ as type};
2
-
3
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":["t","e","$","$"],"sources":["../../internal/scope/dist/index.js","../src/arktype/index.ts","../src/arkenv.ts","../src/schema.ts","../src/index.ts"],"sourcesContent":["import{scope as e,type as t}from\"arktype\";const n=t(`0 <= number.integer <= 65535`),r=t(`string.ip | 'localhost'`),i=e({string:t.module({...t.keywords.string,host:r}),number:t.module({...t.keywords.number,port:n})});export{i as $};\n//# sourceMappingURL=index.js.map","import { $ } from \"@repo/scope\";\nimport type { SchemaShape } from \"@repo/types\";\nimport type { distill } from \"arktype\";\nimport { ArkErrors } from \"arktype\";\nimport type { ArkEnvConfig, EnvSchema } from \"@/arkenv\";\nimport { coerceEnvironment } from \"@/coercion\";\nimport { ArkEnvError, type EnvIssue, type EnvIssueMeta } from \"@/core\";\nimport {\n\tbuildEnvIssue,\n\tgetArkTypeMeta,\n\tmapArkTypeCode,\n\tredactMessageWasValue,\n} from \"@/utils/errors\";\n\n/**\n * Re-export of ArkType's `distill` utilities.\n *\n * Exposed for internal use cases and type-level integrations.\n * ArkEnv does not add behavior or guarantees beyond what ArkType provides.\n *\n * @internal\n * @see https://github.com/arktypeio/arktype\n */\nexport type { distill };\n\n/**\n * Convert ArkType's `ArkErrors` (keyed by path) into a flat `EnvIssue[]`\n * suitable for `ArkEnvError`.\n *\n * @param errors The ArkType errors object to convert\n * @param config Optional ArkEnvConfig to read debugSecrets options\n * @returns An array of flattened validation issues\n *\n * @internal\n */\nfunction arkErrorsToIssues(\n\terrors: ArkErrors,\n\tconfig?: ArkEnvConfig,\n): EnvIssue[] {\n\treturn Object.entries(errors.byPath).map(([path, error]) => {\n\t\tlet message = error.message;\n\n\t\t// Strip leading path reference if ArkType included it in the message\n\t\tlet trimmed = message.trimStart();\n\t\tif (trimmed.length > 0 && \":.-\".includes(trimmed[0])) {\n\t\t\ttrimmed = trimmed.slice(1).trimStart();\n\t\t}\n\t\tif (trimmed.toLowerCase().startsWith(path.toLowerCase())) {\n\t\t\tlet rest = trimmed.slice(path.length).trimStart();\n\t\t\tif (rest.length > 0 && \":.-\".includes(rest[0])) {\n\t\t\t\trest = rest.slice(1);\n\t\t\t}\n\t\t\tmessage = rest.trimStart();\n\t\t}\n\n\t\t// Redact and style (was ...) inline values\n\t\tmessage = redactMessageWasValue(message, path, config?.debugSecrets);\n\n\t\t// Map code and metadata using centralized helpers\n\t\tconst code = mapArkTypeCode(error.code);\n\t\tconst bounds = getArkTypeMeta(error);\n\t\tconst meta: EnvIssueMeta = {\n\t\t\t...bounds,\n\t\t};\n\n\t\treturn buildEnvIssue(\n\t\t\tpath,\n\t\t\tmessage,\n\t\t\tcode,\n\t\t\tmeta,\n\t\t\terror.expected,\n\t\t\terror.code === \"required\" ? undefined : error.data,\n\t\t);\n\t});\n}\n\n/**\n * Parse and validate environment variables using ArkEnv's schema rules.\n *\n * This applies:\n * - schema validation\n * - optional coercion (strings → numbers, booleans, arrays)\n * - undeclared key handling\n *\n * On success, returns the validated environment object.\n * On failure, throws an {@link ArkEnvError}.\n *\n * This is a low-level utility used internally by ArkEnv.\n * Most users should prefer the default `arkenv()` export.\n *\n * @param def The ArkType schema definition to validate against\n * @param config The configuration object for parsing and coercion\n * @returns The parsed and validated environment variables\n * @throws {@link ArkEnvError} if validation fails\n *\n * @internal\n */\nexport function parse<const T extends SchemaShape>(\n\tdef: EnvSchema<T>,\n\tconfig: ArkEnvConfig,\n) {\n\tconst {\n\t\tenv = process.env,\n\t\tcoerce: shouldCoerce = true,\n\t\tonUndeclaredKey = \"delete\",\n\t\tarrayFormat = \"comma\",\n\t\temptyAsUndefined = false,\n\t} = config;\n\n\t// If def is a type definition (has assert method), use it directly\n\t// Otherwise, use raw() to convert the schema definition\n\tconst isCompiledType = typeof def === \"function\" && \"assert\" in def;\n\tconst schema = (isCompiledType ? def : $.type.raw(def)) as any;\n\n\t// Apply the `onUndeclaredKey` option\n\tconst schemaWithKeys = schema.onUndeclaredKey(onUndeclaredKey);\n\n\t// Optionally strip empty strings and apply coercion\n\tconst { coercedEnv } = coerceEnvironment(\n\t\tenv,\n\t\temptyAsUndefined,\n\t\tarrayFormat,\n\t\tshouldCoerce\n\t\t\t? () => {\n\t\t\t\t\tconst json = schemaWithKeys.in.toJsonSchema({\n\t\t\t\t\t\tfallback: (ctx: { base: unknown }) => ctx.base,\n\t\t\t\t\t});\n\t\t\t\t\treturn { schema: json, hasSchema: true };\n\t\t\t\t}\n\t\t\t: undefined,\n\t);\n\n\t// Validate the environment variables\n\tconst validatedEnv = schemaWithKeys(coercedEnv);\n\n\t// In ArkType 2.x, calling a type as a function returns the validated data or ArkErrors\n\tif (validatedEnv instanceof ArkErrors) {\n\t\tthrow new ArkEnvError(arkErrorsToIssues(validatedEnv, config));\n\t}\n\n\treturn validatedEnv;\n}\n","import type { $ } from \"@repo/scope\";\nimport type {\n\tCompiledEnvSchema,\n\tDict,\n\tInferType,\n\tSchemaShape,\n} from \"@repo/types\";\nimport type { type as at, distill } from \"arktype\";\nimport { parse } from \"./arktype\";\nimport { ArkEnvError, type SafeArkEnvResult } from \"./core\";\nimport { safeExecute } from \"./utils/errors\";\n\n/**\n * Declarative environment schema definition accepted by ArkEnv.\n *\n * Represents a declarative schema object mapping environment\n * variable names to schema definitions (e.g. ArkType DSL strings\n * or Standard Schema validators).\n *\n * This type is used to validate that a schema object is compatible with\n * ArkEnv’s validator scope before being compiled or parsed.\n *\n * Most users will provide schemas in this form.\n *\n * @template def - The schema shape object\n */\nexport type EnvSchema<def> = at.validate<def, $>;\n\n/**\n * Infer the validated and coerced environment object type from a schema.\n * Supports declarative schema shapes, compiled ArkType schemas, and Standard Schema validators.\n *\n * @template T - The schema type\n */\nexport type Infer<T> = T extends SchemaShape\n\t? distill.Out<at.infer<T, $>>\n\t: InferType<T>;\n\n/**\n * The environment variables passed to `arkenv`.\n * Uses `Dict<string>` to enforce\n * compile-time safety: all input environment variables must be strings\n * (or undefined), matching `process.env` semantics.\n */\ntype RuntimeEnvironment = Dict<string>;\n\n/**\n * Configuration options for `arkenv`\n */\nexport type ArkEnvConfig = {\n\t/**\n\t * The environment variables to parse. Defaults to `process.env`\n\t */\n\tenv?: RuntimeEnvironment;\n\t/**\n\t * Whether to coerce environment variables to their defined types. Defaults to `true`\n\t */\n\tcoerce?: boolean;\n\t/**\n\t * Control how ArkEnv handles environment variables that are not defined in your schema.\n\t *\n\t * Defaults to `'delete'` to ensure your output object only contains\n\t * keys you've explicitly declared. This differs from ArkType's standard behavior, which\n\t * mirrors TypeScript by defaulting to `'ignore'`.\n\t *\n\t * - `delete` (ArkEnv default): Undeclared keys are allowed on input but stripped from the output.\n\t * - `ignore` (ArkType default): Undeclared keys are allowed and preserved in the output.\n\t * - `reject`: Undeclared keys will cause validation to fail.\n\t *\n\t * @default \"delete\"\n\t * @see https://arktype.io/docs/configuration#onundeclaredkey\n\t */\n\tonUndeclaredKey?: \"ignore\" | \"delete\" | \"reject\";\n\n\t/**\n\t * The format to use for array parsing when coercion is enabled.\n\t *\n\t * - `comma` (default): Strings are split by comma and trimmed.\n\t * - `json`: Strings are parsed as JSON.\n\t *\n\t * @default \"comma\"\n\t */\n\tarrayFormat?: \"comma\" | \"json\";\n\n\t/**\n\t * Whether to bypass secret redaction and print raw sensitive values during debugging.\n\t * Defaults to checking `process.env.ARKENV_DEBUG_SECRETS === \"true\"` or `\"1\"`.\n\t */\n\tdebugSecrets?: boolean;\n\n\t/**\n\t * Whether to treat empty strings (`\"\"`) as `undefined` before validation.\n\t *\n\t * When enabled, an environment variable set to an empty value (e.g. `PORT=`)\n\t * will be treated as if it were missing, allowing defaults to apply and\n\t * preventing validation errors for numeric or boolean types.\n\t *\n\t * @default false\n\t */\n\temptyAsUndefined?: boolean;\n\n\t/**\n\t * Whether to return a safe result object instead of throwing an error on validation failure.\n\t *\n\t * When enabled, the function returns an object with `{ success: true, data }` or `{ success: false, issues }`.\n\t *\n\t * @default false\n\t */\n\tsafe?: boolean;\n};\n\nexport type { SafeArkEnvResult };\n\n/**\n * Helper type to represent the output of parsing either an EnvSchema or CompiledEnvSchema.\n */\nexport type ArkenvOutput<T extends SchemaShape, D> =\n\t| distill.Out<at.infer<T, $>>\n\t| InferType<D>;\n\n/**\n * Utility to parse environment variables using ArkType or Standard Schema\n *\n * Naming convention: the main function is lowercase (`arkenv`) following the\n * JavaScript convention for functions (e.g. `zod`, `joi`). Classes and types\n * use PascalCase with the full product name (`ArkEnvError`, `SafeArkEnvResult`).\n *\n * @param def The schema definition\n * @param config The evaluation configuration\n * @returns The parsed environment variables, or a SafeArkEnvResult if `{ safe: true }` is configured\n * @throws An {@link ArkEnvError | error} if the environment variables are invalid and `safe` is not enabled\n */\nexport function arkenv<const T extends SchemaShape>(\n\tdef: EnvSchema<T>,\n\tconfig?: ArkEnvConfig & { safe?: false },\n): distill.Out<at.infer<T, $>>;\nexport function arkenv<T extends CompiledEnvSchema>(\n\tdef: T,\n\tconfig?: ArkEnvConfig & { safe?: false },\n): InferType<T>;\nexport function arkenv<\n\tconst T extends SchemaShape,\n\tconst D extends EnvSchema<T> | CompiledEnvSchema,\n>(def: D, config?: ArkEnvConfig & { safe?: false }): ArkenvOutput<T, D>;\nexport function arkenv<const T extends SchemaShape>(\n\tdef: EnvSchema<T>,\n\tconfig: ArkEnvConfig & { safe: true },\n): SafeArkEnvResult<distill.Out<at.infer<T, $>>>;\nexport function arkenv<T extends CompiledEnvSchema>(\n\tdef: T,\n\tconfig: ArkEnvConfig & { safe: true },\n): SafeArkEnvResult<InferType<T>>;\nexport function arkenv<\n\tconst T extends SchemaShape,\n\tconst D extends EnvSchema<T> | CompiledEnvSchema,\n>(\n\tdef: D,\n\tconfig: ArkEnvConfig & { safe: true },\n): SafeArkEnvResult<ArkenvOutput<T, D>>;\nexport function arkenv<\n\tconst T extends SchemaShape,\n\tconst D extends EnvSchema<T> | CompiledEnvSchema,\n>(\n\tdef: D,\n\tconfig: ArkEnvConfig = {},\n): ArkenvOutput<T, D> | SafeArkEnvResult<ArkenvOutput<T, D>> {\n\tif (config.safe) {\n\t\treturn safeExecute(() => parse(def as any, config));\n\t}\n\t// biome-ignore lint/suspicious/noExplicitAny: parse handles both EnvSchema<T> and CompiledEnvSchema at runtime\n\treturn parse(def as any, config);\n}\n","/**\n * Extract the keys from a schema definition dynamically.\n * Supports plain objects, ArkType schemas, and Standard Schema validators.\n *\n * @param schema The schema definition to extract keys from\n * @returns An array of extracted key names\n * @internal\n */\n// biome-ignore lint/suspicious/noExplicitAny: Need to handle various schema formats\nexport function getSchemaKeys(schema: any): string[] {\n\tif (!schema || (typeof schema !== \"object\" && typeof schema !== \"function\")) {\n\t\treturn [];\n\t}\n\n\t// ArkType Type\n\tif (\n\t\tschema.json &&\n\t\ttypeof schema.json === \"object\" &&\n\t\tschema.json.domain === \"object\"\n\t) {\n\t\tconst keys: string[] = [];\n\t\tif (Array.isArray(schema.json.required)) {\n\t\t\tfor (const r of schema.json.required) {\n\t\t\t\tif (r && typeof r === \"object\" && \"key\" in r) {\n\t\t\t\t\tkeys.push(r.key);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (Array.isArray(schema.json.optional)) {\n\t\t\tfor (const o of schema.json.optional) {\n\t\t\t\tif (o && typeof o === \"object\" && \"key\" in o) {\n\t\t\t\t\tkeys.push(o.key);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn keys;\n\t}\n\n\t// Standard Schema / JSON Schema fallback\n\tconst std = schema[\"~standard\"];\n\tconst jsonSchemaInput =\n\t\t(typeof std?.jsonSchema?.input === \"function\" && std.jsonSchema.input) ||\n\t\t(typeof schema.jsonSchema?.input === \"function\" && schema.jsonSchema.input);\n\n\tif (jsonSchemaInput) {\n\t\ttry {\n\t\t\tconst json = jsonSchemaInput({ target: \"draft-07\" });\n\t\t\tif (json && typeof json === \"object\" && json.properties) {\n\t\t\t\treturn Object.keys(json.properties);\n\t\t\t}\n\t\t} catch {}\n\t}\n\n\tif (typeof schema.toJSONSchema === \"function\") {\n\t\ttry {\n\t\t\tconst json = schema.toJSONSchema();\n\t\t\tif (json && typeof json === \"object\" && json.properties) {\n\t\t\t\treturn Object.keys(json.properties);\n\t\t\t}\n\t\t} catch {}\n\t}\n\n\tif (typeof schema.toStandardJSONSchema?.v1 === \"function\") {\n\t\ttry {\n\t\t\tconst json = schema.toStandardJSONSchema.v1();\n\t\t\tif (json && typeof json === \"object\" && json.properties) {\n\t\t\t\treturn Object.keys(json.properties);\n\t\t\t}\n\t\t} catch {}\n\t}\n\n\t// Plain object schema\n\treturn Object.keys(schema);\n}\n","import { $ } from \"@repo/scope\";\nimport { arkenv } from \"./arkenv\";\nimport { getSchemaKeys } from \"./schema\";\n\nexport { arkenv, getSchemaKeys };\n/**\n * Like ArkType's `type`, but with ArkEnv's extra keywords, such as:\n *\n * - `string.host` – a hostname (e.g. `\"localhost\"`, `\"127.0.0.1\"`)\n * - `number.port` – a port number (e.g. `8080`)\n *\n * See ArkType's docs for the full API:\n * https://arktype.io/docs/type-api\n */\nexport const type = $.type;\nexport type {\n\tArkEnvConfig,\n\tEnvSchema,\n\tInfer,\n\tSafeArkEnvResult,\n} from \"./arkenv\";\n\n/**\n * ArkEnv's main export, an alias for {@link arkenv}\n *\n * {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables validator from editor to runtime.\n */\nexport default arkenv;\n"],"mappings":"yKAA0C,MAAM,EAAEA,EAAE,+BAA+B,CAAC,EAAEA,EAAE,0BAA0B,CAAC,EAAEC,EAAE,CAAC,OAAOD,EAAE,OAAO,CAAC,GAAGA,EAAE,SAAS,OAAO,KAAK,EAAE,CAAC,CAAC,OAAOA,EAAE,OAAO,CAAC,GAAGA,EAAE,SAAS,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,CCmCvN,SAAS,EACR,EACA,EACa,CACb,OAAO,OAAO,QAAQ,EAAO,OAAO,CAAC,KAAK,CAAC,EAAM,KAAW,CAC3D,IAAI,EAAU,EAAM,Q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require(`./errors-Dn6WQ2pP.cjs`),t=require(`./core-CA13n2Iu.cjs`);function n(e,n){if(typeof n==`string`)throw new t.t([{path:e,message:`ArkType DSL strings are not supported in "standard" mode. Use a Standard Schema validator (e.g., Zod, Valibot) or import from "arkenv" for ArkType schemas.`,code:`INVALID_SCHEMA`}])}function r(e,n){let r=n&&typeof n==`object`&&`~standard`in n&&n[`~standard`];if(!r||typeof r!=`object`||!(`validate`in r)||typeof r.validate!=`function`)throw new t.t([{path:e,message:`Invalid validator: expected a Standard Schema 1.0 validator (must have "~standard" property). Import from "arkenv" to use ArkType schemas.`,code:`INVALID_SCHEMA`}])}function i(e){if(!e||typeof e!=`object`||Array.isArray(e))throw new t.t([{path:``,message:`Invalid schema: expected an object mapping in "standard" mode.`,code:`INVALID_SCHEMA`}])}function a(e){let t={type:`object`,properties:{}},n=!1,r=[];for(let i in e){let a=e[i];if(!a){r.push(i);continue}let o=a[`~standard`];if(typeof o?.jsonSchema?.input==`function`)try{let e=o.jsonSchema.input({target:`draft-07`});if(e){t.properties[i]=e,n=!0;continue}}catch{}if(typeof a.jsonSchema?.input==`function`)try{let e=a.jsonSchema.input({target:`draft-07`});if(e){t.properties[i]=e,n=!0;continue}}catch{}if(typeof a.toJSONSchema==`function`)try{let e=a.toJSONSchema();if(e){t.properties[i]=e,n=!0;continue}}catch{}if(typeof a.toStandardJSONSchema?.v1==`function`)try{let e=a.toStandardJSONSchema.v1();if(e){t.properties[i]=e,n=!0;continue}}catch{}r.push(i)}return{jsonSchema:t,hasJsonSchema:n,missingKeys:r}}function o(e){return typeof e==`object`&&e&&`key`in e?String(e.key):String(e)}function s(e,t){return!t||t.length===0?e:[e,...t.map(o)].join(`.`)}function c(e,t){let n=e,r;try{let i=e,a=e.trim();if(a[0]===`{`||a[0]===`[`)try{i=JSON.parse(e)}catch(e){r=`[Unparseable JSON: ${e.message}]`}if(!r){for(let e of t)i=i?.[o(e)];n=i}}catch(e){r=`[Traversal error: ${e.message}]`}return{receivedVal:n,traversalError:r}}function l(n,r){let{env:i=process.env,onUndeclaredKey:o=`delete`,coerce:l=!0,arrayFormat:u=`comma`,emptyAsUndefined:d=!1}=r,f={},p=[],{processedEnv:m,coercedEnv:h,missingKeys:g}=e.l(i,d,u,l?()=>{let{jsonSchema:e,hasJsonSchema:t,missingKeys:r}=a(n);return{schema:e,hasSchema:t,missingKeys:r}}:void 0),_=new Set(Object.keys(m));for(let i in n){let a=n[i],o=h[i];if(!a||typeof a!=`object`||!(`~standard`in a))throw new t.t([e.t(i,`Invalid schema: expected a Standard Schema 1.0 validator (e.g. Zod, Valibot) in 'standard' mode.`,`INVALID_SCHEMA`)]);let u=a[`~standard`].validate(o);if(u instanceof Promise)throw new t.t([e.t(i,`Async validation is not supported. ArkEnv is synchronous.`,`INVALID_SCHEMA`)]);if(u.issues)for(let t of u.issues){let n=s(i,t.path),a,o;if(i in m){let e=m[i];if(typeof e==`string`&&t.path?.length){let n=c(e,t.path);a=n.receivedVal,o=n.traversalError}else a=e}else a=t.received;let u=e.o(t.code||`invalid_type`,t.message||``,a),d=t.expected||void 0,f={...e.i(t)},h=t;h.validation!==void 0&&(f.validation=h.validation),o!==void 0&&(f.traversalError=o);let _=e.n(t.message||``,u,d,a,n,r);l&&g.includes(i)&&(_+=` (Hint: coercion is enabled by default, but the validator for '${i}' lacks Standard JSON Schema support.)`),p.push(e.t(n,_,u,f,d,a))}else f[i]=u.value;_.delete(i)}if(o!==`delete`)for(let t of _)o===`reject`?p.push(e.t(t,`Undeclared key`,`UNDECLARED_KEY`)):o===`ignore`&&(f[t]=h[t]);if(p.length>0)throw new t.t(p);return f}function u(t,a={}){i(t);for(let e in t){let i=t[e];n(e,i),r(e,i)}return a.safe?e.c(()=>l(t,a)):l(t,a)}exports.arkenv=u,exports.default=u;
2
-
3
- // CJS Interop Shim
4
- if (module.exports && module.exports.default) {
5
- Object.assign(module.exports.default, module.exports);
6
- module.exports = module.exports.default;
7
- }
8
-
@@ -1,111 +0,0 @@
1
- import { a as SafeArkEnvResult } from "./core-7-JO-N-w.cjs";
2
- import { a as Dict, i as StandardSchemaV1 } from "./index-Do-2CL1V.cjs";
3
-
4
- //#region src/parse-standard.d.ts
5
- /**
6
- * Configuration options for {@link parseStandard}.
7
- */
8
- type ParseStandardConfig = {
9
- /**
10
- * The environment variables to parse. Defaults to `process.env`
11
- */
12
- env?: Dict<string>;
13
- /**
14
- * Control how ArkEnv handles environment variables that are not defined in your schema.
15
- *
16
- * Defaults to `'delete'` to ensure your output object only contains
17
- * keys you've explicitly declared.
18
- *
19
- * - `delete` (ArkEnv default): Undeclared keys are allowed on input but stripped from the output.
20
- * - `ignore`: Undeclared keys are allowed and preserved in the output.
21
- * - `reject`: Undeclared keys will cause validation to fail.
22
- *
23
- * @default "delete"
24
- */
25
- onUndeclaredKey?: "ignore" | "delete" | "reject";
26
- /**
27
- * Whether to bypass secret redaction and print raw sensitive values during debugging.
28
- * Defaults to checking `process.env.ARKENV_DEBUG_SECRETS === "true"` or `"1"`.
29
- */
30
- debugSecrets?: boolean;
31
- /**
32
- * Whether to perform best-effort coercion on the environment variables.
33
- * Coercion requires validators that implement the StandardJSONSchemaV1 spec
34
- * (e.g. Zod, Valibot).
35
- *
36
- * @see https://standard-schema.dev
37
- * @default true
38
- */
39
- coerce?: boolean;
40
- /**
41
- * The format to use for array parsing when coercion is enabled.
42
- *
43
- * - `comma` (default): Strings are split by comma and trimmed.
44
- * - `json`: Strings are parsed as JSON.
45
- *
46
- * @default "comma"
47
- */
48
- arrayFormat?: "comma" | "json";
49
- /**
50
- * Whether to treat empty strings (`""`) as `undefined` before validation.
51
- *
52
- * When enabled, an environment variable set to an empty value (e.g. `PORT=`)
53
- * will be treated as if it were missing, allowing defaults to apply and
54
- * preventing validation errors for numeric or boolean types.
55
- *
56
- * @default false
57
- */
58
- emptyAsUndefined?: boolean;
59
- /**
60
- * Whether to return a safe result object instead of throwing an error on validation failure.
61
- *
62
- * When enabled, the function returns an object with `{ success: true, data }` or `{ success: false, issues }`.
63
- *
64
- * @default false
65
- */
66
- safe?: boolean;
67
- };
68
- //#endregion
69
- //#region src/standard.d.ts
70
- /**
71
- * Configuration options for the `arkenv/standard` entry's `arkenv`.
72
- */
73
- type StandardEnvConfig = ParseStandardConfig;
74
- /**
75
- * Parse and validate environment variables using Standard Schema 1.0 validators (e.g. Zod, Valibot).
76
- *
77
- * This entry is ArkType-free - ArkType is never imported, even transitively.
78
- * Use this when your project must not depend on ArkType.
79
- *
80
- * @param def An object mapping variable names to Standard Schema validators
81
- * @param config Optional configuration
82
- * @returns The validated environment variables, or a SafeArkEnvResult if `{ safe: true }` is configured
83
- * @throws An {@link ArkEnvError} if validation fails and `safe` is not enabled
84
- *
85
- * @example
86
- * ```ts
87
- * import arkenv from "arkenv/standard";
88
- * import { z } from "zod";
89
- *
90
- * const env = arkenv({
91
- * PORT: z.coerce.number(),
92
- * HOST: z.string(),
93
- * });
94
- * ```
95
- */
96
- declare function arkenv<const T extends Record<string, StandardSchemaV1>>(def: T, config?: StandardEnvConfig & {
97
- safe?: false;
98
- }): { [K in keyof T]: StandardSchemaV1.InferOutput<T[K]> };
99
- declare function arkenv<const T extends Record<string, StandardSchemaV1>>(def: T, config: StandardEnvConfig & {
100
- safe: true;
101
- }): SafeArkEnvResult<{ [K in keyof T]: StandardSchemaV1.InferOutput<T[K]> }>;
102
- //#endregion
103
- export { StandardEnvConfig, arkenv, arkenv as default };
104
-
105
- // CJS Interop Shim
106
- if (module.exports && module.exports.default) {
107
- Object.assign(module.exports.default, module.exports);
108
- module.exports = module.exports.default;
109
- }
110
-
111
- //# sourceMappingURL=standard.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"standard.d.cts","names":[],"sources":["../src/parse-standard.ts","../src/standard.ts"],"mappings":";;;;;;;KAqCY,mBAAA;EAAmB;;;EAI9B,GAAA,GAAM,IAAA;EAAA;;;;;;;;;;;;EAaN,eAAA;ECzC4B;;;;ED8C5B,YAAA;ECtBqB;;;;;;;;EDgCrB,MAAA;EC7BoB;;;;;;;;EDuCpB,WAAA;ECxC+B;;;;;;;;;EDmD/B,gBAAA;ECjDe;;;;;;;ED0Df,IAAA;AAAA;;;;AA9DD;;KCxBY,iBAAA,GAAoB,mBAAA;;;;;;;;;;;;;;;AAAhC;;;;;AAwBA;;;iBAAgB,MAAA,iBAAuB,MAAA,SAAe,gBAAA,EAAA,CACrD,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,iBAAA;EAAsB,IAAA;AAAA,kBACf,CAAA,GAAI,gBAAA,CAAiB,WAAA,CAAY,CAAA,CAAE,CAAA;AAAA,iBACpC,MAAA,iBAAuB,MAAA,SAAe,gBAAA,EAAA,CACrD,GAAA,EAAK,CAAA,EACL,MAAA,EAAQ,iBAAA;EAAsB,IAAA;AAAA,IAC5B,gBAAA,eAA+B,CAAA,GAAI,gBAAA,CAAiB,WAAA,CAAY,CAAA,CAAE,CAAA"}