arkenv 0.9.2 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/core-Byznlywt.cjs +11 -0
  2. package/dist/core-DzT5rjcY.mjs +6 -0
  3. package/dist/core-DzT5rjcY.mjs.map +1 -0
  4. package/dist/core.cjs +8 -0
  5. package/dist/core.d.cts +45 -0
  6. package/dist/core.d.cts.map +1 -0
  7. package/dist/core.d.mts +39 -0
  8. package/dist/core.d.mts.map +1 -0
  9. package/dist/core.mjs +1 -0
  10. package/dist/{create-env-BDbKkDKm.d.mts → index-Cic20SzT.d.mts} +85 -165
  11. package/dist/index-Cic20SzT.d.mts.map +1 -0
  12. package/dist/{create-env-D7N4rUVE.d.cts → index-bSO6Cmhi.d.cts} +85 -165
  13. package/dist/index-bSO6Cmhi.d.cts.map +1 -0
  14. package/dist/index.cjs +1 -1
  15. package/dist/index.d.cts +153 -28
  16. package/dist/index.d.cts.map +1 -1
  17. package/dist/index.d.mts +153 -28
  18. package/dist/index.d.mts.map +1 -1
  19. package/dist/index.mjs +1 -1
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/standard.cjs +8 -0
  22. package/dist/standard.d.cts +70 -0
  23. package/dist/standard.d.cts.map +1 -0
  24. package/dist/standard.d.mts +64 -0
  25. package/dist/standard.d.mts.map +1 -0
  26. package/dist/standard.mjs +3 -0
  27. package/dist/standard.mjs.map +1 -0
  28. package/package.json +22 -10
  29. package/dist/arktype/index.cjs +0 -8
  30. package/dist/arktype/index.d.cts +0 -116
  31. package/dist/arktype/index.d.cts.map +0 -1
  32. package/dist/arktype/index.d.mts +0 -110
  33. package/dist/arktype/index.d.mts.map +0 -1
  34. package/dist/arktype/index.mjs +0 -3
  35. package/dist/arktype/index.mjs.map +0 -1
  36. package/dist/create-env-BDbKkDKm.d.mts.map +0 -1
  37. package/dist/create-env-D7N4rUVE.d.cts.map +0 -1
  38. package/dist/errors-Bi-pULbt.mjs +0 -7
  39. package/dist/errors-Bi-pULbt.mjs.map +0 -1
  40. package/dist/errors-BtUS5QYF.cjs +0 -12
@@ -1,8 +1,90 @@
1
1
  import * as arktype_internal_keywords_string_ts0 from "arktype/internal/keywords/string.ts";
2
2
  import * as arktype_internal_attributes_ts0 from "arktype/internal/attributes.ts";
3
3
  import * as arktype0 from "arktype";
4
- import { Type, distill, type } from "arktype";
4
+ import { Type, type } from "arktype";
5
5
 
6
+ //#region ../internal/scope/dist/index.d.ts
7
+
8
+ //#region src/root.d.ts
9
+ /**
10
+ * The root scope for the ArkEnv library,
11
+ * containing extensions to the ArkType scopes with ArkEnv-specific types
12
+ * like `string.host` and `number.port`.
13
+ */
14
+ declare const $: arktype0.Scope<{
15
+ string: arktype0.Submodule<{
16
+ trim: arktype0.Submodule<arktype_internal_keywords_string_ts0.trim.$ & {
17
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
18
+ }>;
19
+ normalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.normalize.$ & {
20
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
21
+ }>;
22
+ root: string;
23
+ alpha: string;
24
+ alphanumeric: string;
25
+ hex: string;
26
+ base64: arktype0.Submodule<{
27
+ root: string;
28
+ url: string;
29
+ } & {
30
+ " arkInferred": string;
31
+ }>;
32
+ capitalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.capitalize.$ & {
33
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
34
+ }>;
35
+ creditCard: string;
36
+ date: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringDate.$ & {
37
+ " arkInferred": string;
38
+ }>;
39
+ digits: string;
40
+ email: string;
41
+ integer: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringInteger.$ & {
42
+ " arkInferred": string;
43
+ }>;
44
+ ip: arktype0.Submodule<arktype_internal_keywords_string_ts0.ip.$ & {
45
+ " arkInferred": string;
46
+ }>;
47
+ json: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringJson.$ & {
48
+ " arkInferred": string;
49
+ }>;
50
+ lower: arktype0.Submodule<arktype_internal_keywords_string_ts0.lower.$ & {
51
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
52
+ }>;
53
+ numeric: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringNumeric.$ & {
54
+ " arkInferred": string;
55
+ }>;
56
+ regex: string;
57
+ semver: string;
58
+ upper: arktype0.Submodule<{
59
+ root: (In: string) => arktype_internal_attributes_ts0.To<string>;
60
+ preformatted: string;
61
+ } & {
62
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
63
+ }>;
64
+ url: arktype0.Submodule<arktype_internal_keywords_string_ts0.url.$ & {
65
+ " arkInferred": string;
66
+ }>;
67
+ uuid: arktype0.Submodule<arktype_internal_keywords_string_ts0.uuid.$ & {
68
+ " arkInferred": string;
69
+ }>;
70
+ " arkInferred": string;
71
+ host: string;
72
+ }>;
73
+ number: arktype0.Submodule<{
74
+ NaN: number;
75
+ Infinity: number;
76
+ root: number;
77
+ integer: number;
78
+ " arkInferred": number;
79
+ epoch: number;
80
+ safe: number;
81
+ NegativeInfinity: number;
82
+ port: number;
83
+ }>;
84
+ }>;
85
+ type $ = (typeof $)["t"];
86
+ //#endregion
87
+ //#endregion
6
88
  //#region ../internal/types/dist/helpers.d.ts
7
89
  type Dict<T> = Record<string, T | undefined>;
8
90
  //#endregion
@@ -103,87 +185,6 @@ type InferType<T> = T extends StandardSchemaV1<infer _Input, infer Output> ? Out
103
185
  t: infer U;
104
186
  } ? U : T extends type.Any<infer U, infer _Scope> ? U : never;
105
187
  //#endregion
106
- //#region ../internal/scope/dist/index.d.ts
107
- //#region src/root.d.ts
108
- /**
109
- * The root scope for the ArkEnv library,
110
- * containing extensions to the ArkType scopes with ArkEnv-specific types
111
- * like `string.host` and `number.port`.
112
- */
113
- declare const $: arktype0.Scope<{
114
- string: arktype0.Submodule<{
115
- trim: arktype0.Submodule<arktype_internal_keywords_string_ts0.trim.$ & {
116
- " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
117
- }>;
118
- normalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.normalize.$ & {
119
- " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
120
- }>;
121
- root: string;
122
- alpha: string;
123
- alphanumeric: string;
124
- hex: string;
125
- base64: arktype0.Submodule<{
126
- root: string;
127
- url: string;
128
- } & {
129
- " arkInferred": string;
130
- }>;
131
- capitalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.capitalize.$ & {
132
- " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
133
- }>;
134
- creditCard: string;
135
- date: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringDate.$ & {
136
- " arkInferred": string;
137
- }>;
138
- digits: string;
139
- email: string;
140
- integer: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringInteger.$ & {
141
- " arkInferred": string;
142
- }>;
143
- ip: arktype0.Submodule<arktype_internal_keywords_string_ts0.ip.$ & {
144
- " arkInferred": string;
145
- }>;
146
- json: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringJson.$ & {
147
- " arkInferred": string;
148
- }>;
149
- lower: arktype0.Submodule<arktype_internal_keywords_string_ts0.lower.$ & {
150
- " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
151
- }>;
152
- numeric: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringNumeric.$ & {
153
- " arkInferred": string;
154
- }>;
155
- regex: string;
156
- semver: string;
157
- upper: arktype0.Submodule<{
158
- root: (In: string) => arktype_internal_attributes_ts0.To<string>;
159
- preformatted: string;
160
- } & {
161
- " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
162
- }>;
163
- url: arktype0.Submodule<arktype_internal_keywords_string_ts0.url.$ & {
164
- " arkInferred": string;
165
- }>;
166
- uuid: arktype0.Submodule<arktype_internal_keywords_string_ts0.uuid.$ & {
167
- " arkInferred": string;
168
- }>;
169
- " arkInferred": string;
170
- host: string;
171
- }>;
172
- number: arktype0.Submodule<{
173
- NaN: number;
174
- Infinity: number;
175
- root: number;
176
- integer: number;
177
- " arkInferred": number;
178
- epoch: number;
179
- safe: number;
180
- NegativeInfinity: number;
181
- port: number;
182
- }>;
183
- }>;
184
- type $ = (typeof $)["t"];
185
- //#endregion
186
- //#endregion
187
188
  //#region ../internal/types/dist/schema.d.ts
188
189
  type SchemaShape = Record<string, unknown>;
189
190
  /**
@@ -200,88 +201,7 @@ type SchemaShape = Record<string, unknown>;
200
201
  */
201
202
  type CompiledEnvSchema = Type<SchemaShape, $>;
202
203
  //#endregion
203
- //#region src/create-env.d.ts
204
- /**
205
- * Declarative environment schema definition accepted by ArkEnv.
206
- *
207
- * Represents a declarative schema object mapping environment
208
- * variable names to schema definitions (e.g. ArkType DSL strings
209
- * or Standard Schema validators).
210
- *
211
- * This type is used to validate that a schema object is compatible with
212
- * ArkEnv’s validator scope before being compiled or parsed.
213
- *
214
- * Most users will provide schemas in this form.
215
- *
216
- * @template def - The schema shape object
217
- */
218
- type EnvSchema<def> = type.validate<def, $>;
219
- type RuntimeEnvironment = Dict<string>;
220
- /**
221
- * Configuration options for `createEnv`
222
- */
223
- type ArkEnvConfig = {
224
- /**
225
- * The environment variables to parse. Defaults to `process.env`
226
- */
227
- env?: RuntimeEnvironment;
228
- /**
229
- * Whether to coerce environment variables to their defined types. Defaults to `true`
230
- */
231
- coerce?: boolean;
232
- /**
233
- * Control how ArkEnv handles environment variables that are not defined in your schema.
234
- *
235
- * Defaults to `'delete'` to ensure your output object only contains
236
- * keys you've explicitly declared. This differs from ArkType's standard behavior, which
237
- * mirrors TypeScript by defaulting to `'ignore'`.
238
- *
239
- * - `delete` (ArkEnv default): Undeclared keys are allowed on input but stripped from the output.
240
- * - `ignore` (ArkType default): Undeclared keys are allowed and preserved in the output.
241
- * - `reject`: Undeclared keys will cause validation to fail.
242
- *
243
- * @default "delete"
244
- * @see https://arktype.io/docs/configuration#onundeclaredkey
245
- */
246
- onUndeclaredKey?: "ignore" | "delete" | "reject";
247
- /**
248
- * The format to use for array parsing when coercion is enabled.
249
- *
250
- * - `comma` (default): Strings are split by comma and trimmed.
251
- * - `json`: Strings are parsed as JSON.
252
- *
253
- * @default "comma"
254
- */
255
- arrayFormat?: "comma" | "json";
256
- /**
257
- * Choose the validator engine to use.
258
- *
259
- * - `arktype` (default): Uses ArkType for all validation and coercion.
260
- * - `standard`: Uses Standard Schema 1.0 directly for validation. Coercion is not supported in this mode.
261
- *
262
- * @default "arktype"
263
- */
264
- validator?: "arktype" | "standard";
265
- };
266
- /**
267
- * TODO: `SchemaShape` is basically `Record<string, unknown>`.
268
- * If possible, find a better type than "const T extends Record<string, unknown>",
269
- * and be as close as possible to the type accepted by ArkType's `type`.
270
- */
271
- /**
272
- * Utility to parse environment variables using ArkType or Standard Schema
273
- * @param def - The schema definition
274
- * @param config - The evaluation configuration
275
- * @returns The parsed environment variables
276
- * @throws An {@link ArkEnvError | error} if the environment variables are invalid.
277
- */
278
- declare function createEnv<const T extends Record<string, StandardSchemaV1>>(def: T, config: ArkEnvConfig & {
279
- validator: "standard";
280
- }): { [K in keyof T]: StandardSchemaV1.InferOutput<T[K]> };
281
- declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T>, config?: ArkEnvConfig): distill.Out<type.infer<T, $>>;
282
- declare function createEnv<T extends CompiledEnvSchema>(def: T, config?: ArkEnvConfig): InferType<T>;
283
- //#endregion
284
- export { SchemaShape as i, EnvSchema as n, createEnv as r, ArkEnvConfig as t };
204
+ export { Dict as a, StandardSchemaV1 as i, SchemaShape as n, $ as o, InferType as r, CompiledEnvSchema as t };
285
205
 
286
206
  // CJS Interop Shim
287
207
  if (module.exports && module.exports.default) {
@@ -289,4 +209,4 @@ if (module.exports && module.exports.default) {
289
209
  module.exports = module.exports.default;
290
210
  }
291
211
 
292
- //# sourceMappingURL=create-env-D7N4rUVE.d.cts.map
212
+ //# sourceMappingURL=index-bSO6Cmhi.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-bSO6Cmhi.d.cts","names":["arktype0","arktype_internal_keywords_string_ts0","arktype_internal_attributes_ts0","$","trim","To","Submodule","normalize","capitalize","stringDate","stringInteger","ip","stringJson","lower","stringNumeric","url","uuid","Scope","Dict","T","Record","StandardTypedV1","Input","Output","Props","Schema","Types","NonNullable","StandardSchemaV1","Options","Result","Promise","SuccessResult","FailureResult","Record","Issue","ReadonlyArray","PropertyKey","PathSegment","InferInput","InferOutput","StandardJSONSchemaV1","Converter","Target","type","StandardSchemaV1","InferType","T","Record","errors","Any","$","Type","SchemaShape","Record","CompiledEnvSchema"],"sources":["../../internal/scope/dist/index.d.ts","../../internal/types/dist/helpers.d.ts","../../internal/types/dist/standard-schema.d.ts","../../internal/types/dist/infer-type.d.ts","../../internal/types/dist/schema.d.ts"],"sourcesContent":["import * as arktype0 from \"arktype\";\nimport * as arktype_internal_keywords_string_ts0 from \"arktype/internal/keywords/string.ts\";\nimport * as arktype_internal_attributes_ts0 from \"arktype/internal/attributes.ts\";\n\n//#region src/root.d.ts\n/**\n * The root scope for the ArkEnv library,\n * containing extensions to the ArkType scopes with ArkEnv-specific types\n * like `string.host` and `number.port`.\n */\ndeclare const $: arktype0.Scope<{\n string: arktype0.Submodule<{\n trim: arktype0.Submodule<arktype_internal_keywords_string_ts0.trim.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n normalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.normalize.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n root: string;\n alpha: string;\n alphanumeric: string;\n hex: string;\n base64: arktype0.Submodule<{\n root: string;\n url: string;\n } & {\n \" arkInferred\": string;\n }>;\n capitalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.capitalize.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n creditCard: string;\n date: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringDate.$ & {\n \" arkInferred\": string;\n }>;\n digits: string;\n email: string;\n integer: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringInteger.$ & {\n \" arkInferred\": string;\n }>;\n ip: arktype0.Submodule<arktype_internal_keywords_string_ts0.ip.$ & {\n \" arkInferred\": string;\n }>;\n json: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringJson.$ & {\n \" arkInferred\": string;\n }>;\n lower: arktype0.Submodule<arktype_internal_keywords_string_ts0.lower.$ & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n numeric: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringNumeric.$ & {\n \" arkInferred\": string;\n }>;\n regex: string;\n semver: string;\n upper: arktype0.Submodule<{\n root: (In: string) => arktype_internal_attributes_ts0.To<string>;\n preformatted: string;\n } & {\n \" arkInferred\": (In: string) => arktype_internal_attributes_ts0.To<string>;\n }>;\n url: arktype0.Submodule<arktype_internal_keywords_string_ts0.url.$ & {\n \" arkInferred\": string;\n }>;\n uuid: arktype0.Submodule<arktype_internal_keywords_string_ts0.uuid.$ & {\n \" arkInferred\": string;\n }>;\n \" arkInferred\": string;\n host: string;\n }>;\n number: arktype0.Submodule<{\n NaN: number;\n Infinity: number;\n root: number;\n integer: number;\n \" arkInferred\": number;\n epoch: number;\n safe: number;\n NegativeInfinity: number;\n port: number;\n }>;\n}>;\ntype $ = (typeof $)[\"t\"];\n//#endregion\nexport { $ };\n//# sourceMappingURL=index.d.ts.map","export type Dict<T> = Record<string, T | undefined>;\n//# sourceMappingURL=helpers.d.ts.map","/**\n * @see https://github.com/standard-schema/standard-schema/tree/3130ce43fdd848d9ab49dbb0458d04f18459961c/packages/spec\n *\n * Copied from standard-schema (MIT License)\n * Copyright (c) 2024 Colin McDannell\n */\n/** The Standard Typed interface. This is a base type extended by other specs. */\nexport interface StandardTypedV1<Input = unknown, Output = Input> {\n /** The Standard properties. */\n readonly \"~standard\": StandardTypedV1.Props<Input, Output>;\n}\nexport declare namespace StandardTypedV1 {\n /** The Standard Typed properties interface. */\n interface Props<Input = unknown, Output = Input> {\n /** The version number of the standard. */\n readonly version: 1;\n /** The vendor name of the schema library. */\n readonly vendor: string;\n /** Inferred types associated with the schema. */\n readonly types?: Types<Input, Output> | undefined;\n }\n /** The Standard Typed types interface. */\n interface Types<Input = unknown, Output = Input> {\n /** The input type of the schema. */\n readonly input: Input;\n /** The output type of the schema. */\n readonly output: Output;\n }\n /** Infers the input type of a Standard Typed. */\n type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema[\"~standard\"][\"types\"]>[\"input\"];\n /** Infers the output type of a Standard Typed. */\n type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema[\"~standard\"][\"types\"]>[\"output\"];\n}\n/** The Standard Schema interface. */\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n /** The Standard Schema properties. */\n readonly \"~standard\": StandardSchemaV1.Props<Input, Output>;\n}\nexport declare namespace StandardSchemaV1 {\n /** The Standard Schema properties interface. */\n interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {\n /** Validates unknown input values. */\n readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;\n }\n /** The result interface of the validate function. */\n type Result<Output> = SuccessResult<Output> | FailureResult;\n /** The result interface if validation succeeds. */\n interface SuccessResult<Output> {\n /** The typed output value. */\n readonly value: Output;\n /** A falsy value for `issues` indicates success. */\n readonly issues?: undefined;\n }\n interface Options {\n /** Explicit support for additional vendor-specific parameters, if needed. */\n readonly libraryOptions?: Record<string, unknown> | undefined;\n }\n /** The result interface if validation fails. */\n interface FailureResult {\n /** The issues of failed validation. */\n readonly issues: ReadonlyArray<Issue>;\n }\n /** The issue interface of the failure output. */\n interface Issue {\n /** The error message of the issue. */\n readonly message: string;\n /** The path of the issue, if any. */\n readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;\n }\n /** The path segment interface of the issue. */\n interface PathSegment {\n /** The key representing a path segment. */\n readonly key: PropertyKey;\n }\n /** The Standard types interface. */\n interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {\n }\n /** Infers the input type of a Standard. */\n type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;\n /** Infers the output type of a Standard. */\n type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;\n}\n/** The Standard JSON Schema interface. */\nexport interface StandardJSONSchemaV1<Input = unknown, Output = Input> {\n /** The Standard JSON Schema properties. */\n readonly \"~standard\": StandardJSONSchemaV1.Props<Input, Output>;\n}\nexport declare namespace StandardJSONSchemaV1 {\n /** The Standard JSON Schema properties interface. */\n interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {\n /** Methods for generating the input/output JSON Schema. */\n readonly jsonSchema: StandardJSONSchemaV1.Converter;\n }\n /** The Standard JSON Schema converter interface. */\n interface Converter {\n /** Converts the input type to JSON Schema. May throw if conversion is not supported. */\n readonly input: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;\n /** Converts the output type to JSON Schema. May throw if conversion is not supported. */\n readonly output: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;\n }\n /**\n * The target version of the generated JSON Schema.\n *\n * It is *strongly recommended* that implementers support `\"draft-2020-12\"` and `\"draft-07\"`, as they are both in wide use. All other targets can be implemented on a best-effort basis. Libraries should throw if they don't support a specified target.\n *\n * The `\"openapi-3.0\"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `\"draft-04\"`.\n */\n type Target = \"draft-2020-12\" | \"draft-07\" | \"openapi-3.0\" | ({} & string);\n /** The options for the input/output methods. */\n interface Options {\n /** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */\n readonly target: Target;\n /** Explicit support for additional vendor-specific parameters, if needed. */\n readonly libraryOptions?: Record<string, unknown> | undefined;\n }\n /** The Standard types interface. */\n interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {\n }\n /** Infers the input type of a Standard. */\n type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;\n /** Infers the output type of a Standard. */\n type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;\n}\n//# sourceMappingURL=standard-schema.d.ts.map","import type { type } from \"arktype\";\nimport type { StandardSchemaV1 } from \"./standard-schema\";\n/**\n * Extract the inferred type from a schema definition.\n * Supports both ArkType type definitions and Standard Schema 1.0 validators.\n *\n * For Standard Schema validators (e.g., Zod, Valibot), extracts the output type.\n * For ArkType definitions, checks the call signature or type properties.\n *\n * @template T - The schema definition to infer from\n */\nexport type InferType<T> = T extends StandardSchemaV1<infer _Input, infer Output> ? Output : T extends (value: Record<string, string | undefined>) => infer R ? R extends type.errors ? never : R : T extends {\n t: infer U;\n} ? U : T extends type.Any<infer U, infer _Scope> ? U : never;\n//# sourceMappingURL=infer-type.d.ts.map","import type { $ } from \"@repo/scope\";\nimport type { Type } from \"arktype\";\nexport type SchemaShape = Record<string, unknown>;\n/**\n * @internal\n *\n * Compiled ArkType schema accepted by ArkEnv.\n * Produced by `arktype.type(...)` or `scope(...)`.\n *\n * Represents an already-constructed ArkType `Type` instance that\n * defines the full environment schema.\n *\n * This form bypasses schema validation and is intended for advanced\n * or programmatic use cases where schemas are constructed dynamically.\n */\nexport type CompiledEnvSchema = Type<SchemaShape, $>;\n//# sourceMappingURL=schema.d.ts.map"],"mappings":";;;;;;;;;AAEkF;;;;cAQpEG,CAKoBF,EALjBD,QAAAA,CAASiB,KAKQhB,CAAAA;EACIC,MAAAA,EAL5BF,QAAAA,CAASM,SAKmBJ,CAAAA;IADvBF,IAAAA,EAHLA,QAAAA,CAASM,SAGKA,CAHKL,oCAAAA,CAAqCG,IAAAA,CAAKD,CAG/CG,GAAAA;MAOZN,cAASM,EAAAA,CAAAA,EAAAA,EAAAA,MAAAA,EAAAA,GATiBJ,+BAAAA,CAAgCG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CHSI/C,SGTM4C,IAAAA,CAAKM,GHSF5C,CAAAA,KAAAA,EAAAA,EAAAA,KAAAA,OAAAA,CAAAA,GAAAA,CAAAA,GAAAA,KAAAA;;;KIpBT+C,WAAAA,GAAcC;;;;AJAwD;;;;;;;;;AA2B5CpD,KId1BqD,iBAAAA,GAAoBH,IJcsC/C,CIdjCgD,WJciChD,EIdpB8C,CJcoB9C,CAAAA"}
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./errors-BtUS5QYF.cjs`);let t=require(`node:module`);function n(t,n){let{env:r=process.env,onUndeclaredKey:i=`delete`}=n,a={},o=[],s=new Set(Object.keys(r));for(let e in t){let n=t[e],i=r[e];if(!n||typeof n!=`object`||!(`~standard`in n))throw Error(`Invalid schema for key "${e}": expected a Standard Schema 1.0 validator (e.g. Zod, Valibot) in "standard" mode.`);let c=n[`~standard`].validate(i);if(c instanceof Promise)throw Error(`Async validation is not supported for key "${e}". ArkEnv is synchronous.`);if(c.issues)for(let t of c.issues)o.push({path:e,message:t.message});else a[e]=c.value;s.delete(e)}if(i!==`delete`)for(let e of s)i===`reject`?o.push({path:e,message:`Undeclared key`}):i===`ignore`&&(a[e]=r[e]);if(o.length>0)throw new e.t(o);return a}function r(e){return typeof e==`object`&&!!e&&`message`in e&&typeof e.message==`string`}function i(){let e=(()=>{try{let e={};if(e?.url)return(0,t.createRequire)(e.url)}catch{}try{let e=typeof module<`u`?module:void 0;if(e?.require)return e.require.bind(e)}catch{}try{return(0,t.createRequire)(`${process.cwd()}/index.js`)}catch{}})();if(!e)throw Error(`ArkEnv was unable to load the ArkType validator because neither 'createRequire' nor 'require' are available in this environment.`);let n=[`arkenv/arktype`,`./arktype.cjs`,`../arktype.cjs`,`./arktype/index.cjs`,`../arktype/index.cjs`,`./arktype`,`../arktype`,`./arktype/index.ts`,`../arktype/index.ts`],i;for(let t of n)try{return e(t)}catch(e){if(i=e,r(e)&&e.code===`MODULE_NOT_FOUND`){let n=e.message||``;if((n.includes(`'arktype'`)||n.includes(`"arktype"`)||n.includes(`Cannot find module 'arktype'`))&&!n.includes(t))break}}let a=r(i)?i.message:``;throw r(i)&&i.code===`MODULE_NOT_FOUND`&&(a.includes(`'arktype'`)||a.includes(`"arktype"`)||a.includes(`Cannot find module 'arktype'`))&&!a.includes(`./arktype`)&&!a.includes(`../arktype`)?Error(`The 'arktype' package is required when using the default validator mode. Please install it (npm install arktype) or set 'validator: "standard"' in your config if you only intend to use Standard Schema validators (like Zod or Valibot).`):i}function a(t,r={}){if((r.validator??`arktype`)===`standard`){if(!t||typeof t!=`object`||Array.isArray(t))throw new e.t([{path:``,message:`Invalid schema: expected an object mapping in "standard" mode.`}]);for(let n in t){let r=t[n];if(typeof r==`string`)throw new e.t([{path:n,message:`ArkType DSL strings are not supported in "standard" mode. Use a Standard Schema validator (e.g., Zod, Valibot) or set validator: "arktype".`}]);if(!r||typeof r!=`object`||!(`~standard`in r))throw new e.t([{path:n,message:`Invalid validator: expected a Standard Schema 1.0 validator (must have "~standard" property). ArkType validators are not supported in "standard" mode. Use validator: "arktype" for ArkType schemas.`}])}return n(t,r)}let{parse:a}=i();return a(t,r)}const o=a;var s=o;exports.ArkEnvError=e.t,exports.createEnv=a,exports.default=s;
1
+ Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./core-Byznlywt.cjs`);let t=require(`arktype`);const n=(0,t.type)(`0 <= number.integer <= 65535`),r=(0,t.type)(`string.ip | 'localhost'`),i=(0,t.scope)({string:t.type.module({...t.type.keywords.string,host:r}),number:t.type.module({...t.type.keywords.number,port:n})}),a=e=>{if(typeof e==`number`||typeof e!=`string`)return e;let t=e.trim();if(t===``)return e;if(t===`NaN`)return NaN;let n=Number(t);return Number.isNaN(n)?e:n},o=e=>e===`true`?!0:e===`false`?!1:e,s=e=>{if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}},c=`*`,l=(e,t=[])=>{let n=[];if(typeof e==`boolean`)return n;if(`const`in e&&(typeof e.const==`number`||typeof e.const==`boolean`)&&n.push({path:[...t],type:`primitive`}),`enum`in e&&e.enum&&e.enum.some(e=>typeof e==`number`||typeof e==`boolean`)&&n.push({path:[...t],type:`primitive`}),`type`in e)if(e.type===`number`||e.type===`integer`)n.push({path:[...t],type:`primitive`});else if(e.type===`boolean`)n.push({path:[...t],type:`primitive`});else if(e.type===`object`){if(`properties`in e&&e.properties&&Object.keys(e.properties).length>0&&n.push({path:[...t],type:`object`}),`properties`in e&&e.properties)for(let[r,i]of Object.entries(e.properties))n.push(...l(i,[...t,r]))}else e.type===`array`&&(n.push({path:[...t],type:`array`}),`items`in e&&e.items&&(Array.isArray(e.items)?e.items.forEach((e,r)=>{n.push(...l(e,[...t,`${r}`]))}):n.push(...l(e.items,[...t,`*`]))));if(`anyOf`in e&&e.anyOf)for(let r of e.anyOf)n.push(...l(r,t));if(`allOf`in e&&e.allOf)for(let r of e.allOf)n.push(...l(r,t));if(`oneOf`in e&&e.oneOf)for(let r of e.oneOf)n.push(...l(r,t));let r=new Set;return n.filter(e=>{let t=JSON.stringify(e.path)+e.type;return r.has(t)?!1:(r.add(t),!0)})},u=(e,t,n={})=>{let{arrayFormat:r=`comma`}=n,i=e=>{if(r===`json`)try{return JSON.parse(e)}catch{return e}return e.trim()?e.split(`,`).map(e=>e.trim()):[]};if(typeof e!=`object`||!e){if(t.some(e=>e.path.length===0)){let n=t.find(e=>e.path.length===0);if(n?.type===`object`&&typeof e==`string`)return s(e);if(n?.type===`array`&&typeof e==`string`)return i(e);let r=a(e);return typeof r==`number`?r:o(e)}return e}let c=[...t].sort((e,t)=>e.path.length-t.path.length),l=(e,t,n)=>{if(!e||typeof e!=`object`||t.length===0)return;if(t.length===1){let r=t[0];if(r===`*`){if(Array.isArray(e))for(let t=0;t<e.length;t++){let r=e[t];if(n===`primitive`){let n=a(r);typeof n==`number`?e[t]=n:e[t]=o(r)}else n===`object`&&(e[t]=s(r))}return}let c=e;if(Object.prototype.hasOwnProperty.call(c,r)){let e=c[r];if(n===`array`&&typeof e==`string`){c[r]=i(e);return}if(n===`object`&&typeof e==`string`){c[r]=s(e);return}if(Array.isArray(e)){if(n===`primitive`)for(let t=0;t<e.length;t++){let n=e[t],r=a(n);typeof r==`number`?e[t]=r:e[t]=o(n)}}else if(n===`primitive`){let t=a(e);typeof t==`number`?c[r]=t:c[r]=o(e)}}return}let[r,...c]=t;if(r===`*`){if(Array.isArray(e))for(let t of e)l(t,c,n);return}l(e[r],c,n)};for(let t of c)l(e,t.path,t.type);return e};function d(e,t,n){let r=l(t.in.toJsonSchema({fallback:e=>e.base}));return r.length===0?t:e(`unknown`).pipe(e=>u(e,r,n)).pipe(t)}function f(t){return Object.entries(t.byPath).map(([t,n])=>{let r=n.message,i=r.trimStart();if(i.length>0&&`:.-`.includes(i[0])&&(i=i.slice(1).trimStart()),i.toLowerCase().startsWith(t.toLowerCase())){let e=i.slice(t.length).trimStart();e.length>0&&`:.-`.includes(e[0])&&(e=e.slice(1)),r=e.trimStart()}let a=r.match(/\(was (.*)\)/);if(a?.[1]){let t=a[1];t.includes(`\x1B[`)||(r=r.replace(`(was ${t})`,`(was ${e.r(`cyan`,t)})`))}return{path:t,message:r}})}function p(n,r){let{env:a=process.env,coerce:o=!0,onUndeclaredKey:s=`delete`,arrayFormat:c=`comma`}=r,l=(typeof n==`function`&&`assert`in n?n:i.type.raw(n)).onUndeclaredKey(s),u=l;o&&(u=d(i.type,l,{arrayFormat:c}));let p=u(a);if(p instanceof t.ArkErrors)throw new e.t(f(p));return p}function m(e,t={}){return p(e,t)}const h=i.type,g=m;var _=g;exports.ArkEnvError=e.t,exports.createEnv=m,exports.default=_,exports.type=h;
2
2
 
3
3
  // CJS Interop Shim
4
4
  if (module.exports && module.exports.default) {
package/dist/index.d.cts CHANGED
@@ -1,38 +1,163 @@
1
- import { n as EnvSchema, r as createEnv, t as ArkEnvConfig } from "./create-env-D7N4rUVE.cjs";
2
- import { ArkErrors } from "arktype";
1
+ import { ArkEnvError } from "./core.cjs";
2
+ import { a as Dict, n as SchemaShape, o as $, r as InferType, t as CompiledEnvSchema } from "./index-bSO6Cmhi.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 arktype0 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/create-env.d.ts
3
10
 
4
- //#region src/errors.d.ts
5
- type InternalValidationError = {
6
- path: string;
7
- message: string;
8
- };
9
11
  /**
10
- * Error thrown when environment variable validation fails.
12
+ * Declarative environment schema definition accepted by ArkEnv.
11
13
  *
12
- * This error extends the native `Error` class and provides formatted error messages
13
- * that clearly indicate which environment variables are invalid and why.
14
+ * Represents a declarative schema object mapping environment
15
+ * variable names to schema definitions (e.g. ArkType DSL strings
16
+ * or Standard Schema validators).
14
17
  *
15
- * @example
16
- * ```ts
17
- * import { createEnv, ArkEnvError } from 'arkenv';
18
+ * This type is used to validate that a schema object is compatible with
19
+ * ArkEnv’s validator scope before being compiled or parsed.
18
20
  *
19
- * try {
20
- * const env = createEnv({
21
- * PORT: 'number.port',
22
- * HOST: 'string.host',
23
- * });
24
- * } catch (error) {
25
- * if (error instanceof ArkEnvError) {
26
- * console.error('Environment validation failed:', error.message);
27
- * }
28
- * }
29
- * ```
21
+ * Most users will provide schemas in this form.
22
+ *
23
+ * @template def - The schema shape object
30
24
  */
31
- declare class ArkEnvError extends Error {
32
- constructor(errors: ArkErrors | InternalValidationError[], message?: string);
33
- }
25
+ type EnvSchema<def$1> = type$1.validate<def$1, $>;
26
+ type RuntimeEnvironment = Dict<string>;
27
+ /**
28
+ * Configuration options for `createEnv`
29
+ */
30
+ type ArkEnvConfig = {
31
+ /**
32
+ * The environment variables to parse. Defaults to `process.env`
33
+ */
34
+ env?: RuntimeEnvironment;
35
+ /**
36
+ * Whether to coerce environment variables to their defined types. Defaults to `true`
37
+ */
38
+ coerce?: boolean;
39
+ /**
40
+ * Control how ArkEnv handles environment variables that are not defined in your schema.
41
+ *
42
+ * Defaults to `'delete'` to ensure your output object only contains
43
+ * keys you've explicitly declared. This differs from ArkType's standard behavior, which
44
+ * mirrors TypeScript by defaulting to `'ignore'`.
45
+ *
46
+ * - `delete` (ArkEnv default): Undeclared keys are allowed on input but stripped from the output.
47
+ * - `ignore` (ArkType default): Undeclared keys are allowed and preserved in the output.
48
+ * - `reject`: Undeclared keys will cause validation to fail.
49
+ *
50
+ * @default "delete"
51
+ * @see https://arktype.io/docs/configuration#onundeclaredkey
52
+ */
53
+ onUndeclaredKey?: "ignore" | "delete" | "reject";
54
+ /**
55
+ * The format to use for array parsing when coercion is enabled.
56
+ *
57
+ * - `comma` (default): Strings are split by comma and trimmed.
58
+ * - `json`: Strings are parsed as JSON.
59
+ *
60
+ * @default "comma"
61
+ */
62
+ arrayFormat?: "comma" | "json";
63
+ };
64
+ /**
65
+ * TODO: `SchemaShape` is basically `Record<string, unknown>`.
66
+ * If possible, find a better type than "const T extends Record<string, unknown>",
67
+ * and be as close as possible to the type accepted by ArkType's `type`.
68
+ */
69
+ /**
70
+ * Utility to parse environment variables using ArkType or Standard Schema
71
+ * @param def - The schema definition
72
+ * @param config - The evaluation configuration
73
+ * @returns The parsed environment variables
74
+ * @throws An {@link ArkEnvError | error} if the environment variables are invalid.
75
+ */
76
+ declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T>, config?: ArkEnvConfig): distill.Out<type$1.infer<T, $>>;
77
+ declare function createEnv<T extends CompiledEnvSchema>(def: T, config?: ArkEnvConfig): InferType<T>;
78
+ declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T> | CompiledEnvSchema, config?: ArkEnvConfig): distill.Out<type$1.infer<T, $>> | InferType<typeof def>;
34
79
  //#endregion
35
80
  //#region src/index.d.ts
81
+ /**
82
+ * Like ArkType's `type`, but with ArkEnv's extra keywords, such as:
83
+ *
84
+ * - `string.host` – a hostname (e.g. `"localhost"`, `"127.0.0.1"`)
85
+ * - `number.port` – a port number (e.g. `8080`)
86
+ *
87
+ * See ArkType's docs for the full API:
88
+ * https://arktype.io/docs/type-api
89
+ */
90
+ declare const type: arktype_internal_type_ts0.TypeParser<{
91
+ string: arktype0.Submodule<{
92
+ trim: arktype0.Submodule<arktype_internal_keywords_string_ts0.trim.$ & {
93
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
94
+ }>;
95
+ normalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.normalize.$ & {
96
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
97
+ }>;
98
+ root: string;
99
+ alpha: string;
100
+ alphanumeric: string;
101
+ hex: string;
102
+ base64: arktype0.Submodule<{
103
+ root: string;
104
+ url: string;
105
+ } & {
106
+ " arkInferred": string;
107
+ }>;
108
+ capitalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.capitalize.$ & {
109
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
110
+ }>;
111
+ creditCard: string;
112
+ date: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringDate.$ & {
113
+ " arkInferred": string;
114
+ }>;
115
+ digits: string;
116
+ email: string;
117
+ integer: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringInteger.$ & {
118
+ " arkInferred": string;
119
+ }>;
120
+ ip: arktype0.Submodule<arktype_internal_keywords_string_ts0.ip.$ & {
121
+ " arkInferred": string;
122
+ }>;
123
+ json: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringJson.$ & {
124
+ " arkInferred": string;
125
+ }>;
126
+ lower: arktype0.Submodule<arktype_internal_keywords_string_ts0.lower.$ & {
127
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
128
+ }>;
129
+ numeric: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringNumeric.$ & {
130
+ " arkInferred": string;
131
+ }>;
132
+ regex: string;
133
+ semver: string;
134
+ upper: arktype0.Submodule<{
135
+ root: (In: string) => arktype_internal_attributes_ts0.To<string>;
136
+ preformatted: string;
137
+ } & {
138
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
139
+ }>;
140
+ url: arktype0.Submodule<arktype_internal_keywords_string_ts0.url.$ & {
141
+ " arkInferred": string;
142
+ }>;
143
+ uuid: arktype0.Submodule<arktype_internal_keywords_string_ts0.uuid.$ & {
144
+ " arkInferred": string;
145
+ }>;
146
+ " arkInferred": string;
147
+ host: string;
148
+ }>;
149
+ number: arktype0.Submodule<{
150
+ NaN: number;
151
+ Infinity: number;
152
+ root: number;
153
+ integer: number;
154
+ " arkInferred": number;
155
+ epoch: number;
156
+ safe: number;
157
+ NegativeInfinity: number;
158
+ port: number;
159
+ }>;
160
+ }>;
36
161
  /**
37
162
  * ArkEnv's main export, an alias for {@link createEnv}
38
163
  *
@@ -40,7 +165,7 @@ declare class ArkEnvError extends Error {
40
165
  */
41
166
  declare const arkenv: typeof createEnv;
42
167
  //#endregion
43
- export { type ArkEnvConfig, ArkEnvError, type EnvSchema, createEnv, arkenv as default };
168
+ export { type ArkEnvConfig, ArkEnvError, type EnvSchema, createEnv, arkenv as default, type };
44
169
 
45
170
  // CJS Interop Shim
46
171
  if (module.exports && module.exports.default) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/errors.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;KAIY,uBAAA;;;AAAZ,CAAA;;ACA0C;;;;;;;;;;;;;;;;;;;;;cDyF7B,WAAA,SAAoB,KAAA;sBAEvB,YAAY;;;;AA3FtB;AAyFA;;;;cClFM,MDkFgC,EAAA,OClF1B,SDkF0B"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/create-env.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;AAyBA;;;;;AAAiD;AAMjD;AAiDA;A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