arkenv 0.7.6 → 0.7.7

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 CHANGED
@@ -1,16 +1,18 @@
1
1
  <p align="center">
2
- <a href="https://arkenv.js.org">
3
- <img alt="arkenv - Typesafe Environment Variables" src="https://og.tailgraph.com/og?titleFontFamily=JetBrains+Mono&textFontFamily=Inter&title=ArkEnv&titleTailwind=text-[%23e9eef9]%20font-bold%20relative%20decoration-%5Brgb(180,215,255)%5D%20decoration-wavy%20decoration-[5px]%20underline%20underline-offset-[16px]%20text-5xl%20mb-8&text=Typesafe%20environment%20variables%20powered%20by%20ArkType&textTailwind=text-[%238b9dc1]%20text-3xl&bgTailwind=bg-gradient-to-b%20from-[%23061a3a]%20to-black" width="645px">
4
- </a>
5
- <br />
6
- <a href="https://github.com/yamcodes/arkenv/actions/workflows/tests.yml?query=branch%3Amain"><img alt="Tests Status" src="https://github.com/yamcodes/arkenv/actions/workflows/tests.yml/badge.svg?event=push&branch=main"></a>
2
+ <a href="https://github.com/yamcodes/arkenv/blob/main/apps/www/public/assets/icon.svg"><img alt="ArkEnv Logo" src="https://arkenv.js.org/assets/icon.svg" width="160px" align="center"/></a>
3
+ <h1 align="center">ArkEnv</h1>
4
+ <div align="center">
5
+ <p align="center">Typesafe environment variables <br/>
6
+ powered by <a href="https://github.com/arktypeio/arktype">ArkType</a></p>
7
+ <a href="https://github.com/yamcodes/arkenv/actions/workflows/test.yml?query=branch%3Amain"><img alt="Test Status" src="https://github.com/yamcodes/arkenv/actions/workflows/tests-badge.yml/badge.svg?branch=main"></a>
7
8
  <a href="https://bundlephobia.com/package/arkenv"><img alt="npm bundle size" src="https://img.shields.io/bundlephobia/minzip/arkenv"></a>
8
9
  <a href="https://www.typescriptlang.org/"><img alt="TypeScript" src="https://img.shields.io/badge/TypeScript-3178C6?style=flat&logo=typescript&logoColor=white"></a>
9
10
  <a href="https://arktype.io/"><img alt="Powered By ArkType" src="https://custom-icon-badges.demolab.com/badge/ArkType-0d1526?logo=arktype2&logoColor=e9eef9"></a>
10
11
  <a href="https://nodejs.org/en"><img alt="Node.js" src="https://img.shields.io/badge/Node.js-339933?style=flat&logo=node.js&logoColor=white"></a>
11
12
  <a href="https://bun.com/"><img alt="Bun" src="https://img.shields.io/badge/Bun-14151a?logo=bun&logoColor=fbf0df"></a>
12
13
  <a href="https://vite.dev/"><img alt="Vite" src="https://custom-icon-badges.demolab.com/badge/Vite-2e2742?logo=vite2&logoColor=dfdfd6"></a>
13
- <a href="https://discord.com/channels/957797212103016458/1415373591394127894"><img alt="Chat on Discord" src="https://img.shields.io/discord/957797212103016458?label=Chat&color=5865f4&logo=discord&labelColor=121214"></a>
14
+ <a href="https://discord.gg/zAmUyuxXH9"><img alt="Chat on Discord" src="https://img.shields.io/discord/957797212103016458?label=Chat&color=5865f4&logo=discord&labelColor=121214"></a>
15
+ </div>
14
16
  </p>
15
17
  <h3 align="center">Proud member of the <a href="https://arktype.io/docs/ecosystem#arkenv">ArkType ecosystem</a></h3>
16
18
 
@@ -51,7 +53,7 @@ const nodeEnv = env.NODE_ENV;
51
53
 
52
54
  With ArkEnv, your environment variables are **guaranteed to match your schema**. If any variable is incorrect or missing, the app won't start and a clear error will be thrown:
53
55
 
54
- ```
56
+ ```bash title="Terminal"
55
57
  ArkEnvError: Errors found while validating environment variables
56
58
  HOST must be a string or "localhost" (was missing)
57
59
  PORT must be an integer between 0 and 65535 (was "hello")
@@ -60,12 +62,13 @@ ArkEnvError: Errors found while validating environment variables
60
62
  ## Features
61
63
 
62
64
  - Zero external dependencies
63
- - Works in Node.js and Bun
65
+ - Works in Node.js, Bun, and Vite
64
66
  - Tiny: <1kB gzipped
65
67
  - Build-time and runtime validation
66
68
  - Single import, zero config for most projects
67
69
  - Validated, defaultable, typesafe environment variables
68
70
  - Powered by ArkType, TypeScript's 1:1 validator
71
+ - Compatible with any Standard Schema validator (Zod, Valibot, etc.)
69
72
  - Optimized from editor to runtime
70
73
 
71
74
  ## Installation
@@ -109,15 +112,26 @@ bun add arkenv arktype
109
112
 
110
113
  ## Requirements
111
114
 
112
- - TypeScript >= 5.1 and [anything else required by ArkType](https://arktype.io/docs/intro/setup#installation)
113
- - [Modern TypeScript module resolution](https://www.typescriptlang.org/tsconfig/#moduleResolution). One of the following is required in your `tsconfig.json`:
114
- - `"moduleResolution": "bundler"` - Recommended for modern bundlers (Vite, Next.js, etc.). Supplied by default when using `"module": "Preserve"`.
115
+ ArkEnv is tested on [**Node.js LTS** and **Current**](https://github.com/yamcodes/arkenv/tree/main/examples/basic), [**Bun 1.3.2**](https://github.com/yamcodes/arkenv/tree/main/examples/with-bun), and [**Vite** from **2.9.18** to **7.x**](https://github.com/yamcodes/arkenv/tree/main/examples/with-vite-react-ts). Older versions may work but are not officially supported.
116
+
117
+ ### TypeScript setup
118
+
119
+ While ArkEnv works with plain JavaScript, *TypeScript is highly recommended* to get the full typesafety benefits. To get ArkEnv to work with TypeScript, we require:
120
+
121
+ - [**Modern TypeScript module resolution**](https://www.typescriptlang.org/tsconfig/#moduleResolution). One of the following is required in your `tsconfig.json`:
122
+ - `"moduleResolution": "bundler"` - Recommended for modern bundlers (Vite, Next.js, etc.). Supplied by default when using `"module": "Preserve"` (Introduced in TypeScript v5.4).
115
123
  - `"moduleResolution": "node16"` or `"nodenext"` - For Node.js projects. Supplied by default when using a matching `"module"` value.
116
- - Tested on [Node.js **LTS** and **Current** (22 and 25 at the time of this writing, respectively)](https://github.com/yamcodes/arkenv/tree/main/examples/basic) and [Bun **1.2**](https://github.com/yamcodes/arkenv/tree/main/examples/with-bun). Older versions may work but are not officially supported
124
+ - **TypeScript >= 5.1** and [anything else required by ArkType](https://arktype.io/docs/intro/setup#installation)
125
+
126
+ > [!NOTE]
127
+ > Without TypeScript, runtime validation still works, but you lose build-time type checking and, in some cases, editor autocomplete. Try our [examples](https://arkenv.js.org/docs/examples) to see this in action!
117
128
 
118
129
  ## Plugins
119
130
 
120
- - [@arkenv/vite-plugin](https://github.com/yamcodes/arkenv/tree/main/packages/vite-plugin) (currently under development) - Vite plugin to validate environment variables at build-time. Requires [Vite from **2.9.18** to **7.x**](https://github.com/yamcodes/arkenv/tree/main/apps/playgrounds/vite).
131
+ Beyond [the core package](https://arkenv.js.org/docs/arkenv), we also provide plugins for frameworks that require a specific implementation to adhere to best practices.
132
+
133
+ - [@arkenv/vite-plugin](https://arkenv.js.org/docs/vite-plugin)
134
+ - [@arkenv/bun-plugin](https://arkenv.js.org/docs/bun-plugin)
121
135
 
122
136
  ## Supporting ArkEnv
123
137
 
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,`__esModule`,{value:!0});let e=require(`arktype`);const t={red:`\x1B[31m`,yellow:`\x1B[33m`,cyan:`\x1B[36m`,reset:`\x1B[0m`},n=()=>typeof process<`u`&&process.versions!=null&&process.versions.node!=null,r=()=>!!(!n()||process.env.NO_COLOR!==void 0||process.env.CI!==void 0||process.stdout&&!process.stdout.isTTY),i=(e,i)=>n()&&!r()?`${t[e]}${i}${t.reset}`:i,a=(e,t=2,{dontDetectNewlines:n=!1}={})=>n?`${` `.repeat(t)}${e}`:e.split(`
1
+ Object.defineProperty(exports,`__esModule`,{value:!0});let e=require(`arktype`);const t=(0,e.type)(`string`,`=>`,(e,t)=>{let n=Number.parseInt(e,10);return(!Number.isInteger(n)||!(0<=n&&n<=65535))&&t.mustBe(`an integer between 0 and 65535`),n}),n=(0,e.type)(`string.ip | 'localhost'`),r=(0,e.type)(`'true' | 'false' | true | false`,`=>`,e=>e===`true`||e===!0),i=(0,e.scope)({string:e.type.module({...e.type.keywords.string,host:n}),number:e.type.module({...e.type.keywords.number,port:t}),boolean:r}),a=(e,t=2,{dontDetectNewlines:n=!1}={})=>n?`${` `.repeat(t)}${e}`:e.split(`
2
2
  `).map(e=>`${` `.repeat(t)}${e}`).join(`
3
- `),o=e=>Object.entries(e.byPath).map(([e,t])=>{let n=t.message.startsWith(e)?t.message.slice(e.length):t.message,r=n.match(/\(was "([^"]+)"\)/),a=r?n.replace(`(was "${r[1]}")`,`(was ${i(`cyan`,`"${r[1]}"`)})`):n;return`${i(`yellow`,e)}${a}`}).join(`
4
- `);var s=class extends Error{constructor(e,t=`Errors found while validating environment variables`){super(`${i(`red`,t)}\n${a(o(e))}\n`),this.name=`ArkEnvError`}};const c=(0,e.type)(`string`,`=>`,(e,t)=>{let n=Number.parseInt(e,10);return(!Number.isInteger(n)||!(0<=n&&n<=65535))&&t.mustBe(`an integer between 0 and 65535`),n}),l=(0,e.type)(`string.ip | 'localhost'`),u=(0,e.type)(`'true' | 'false' | true | false`,`=>`,e=>e===`true`||e===!0),d=(0,e.scope)({string:e.type.module({...e.type.keywords.string,host:l}),number:e.type.module({...e.type.keywords.number,port:c}),boolean:u});function f(t,n=process.env){let r=(typeof t==`function`&&`assert`in t?t:d.type.raw(t))(n);if(r instanceof e.type.errors)throw new s(r);return r}const p=d.type,m=f;var h=m;exports.ArkEnvError=s,exports.createEnv=f,exports.default=h,exports.type=p;
3
+ `),o={red:`\x1B[31m`,yellow:`\x1B[33m`,cyan:`\x1B[36m`,reset:`\x1B[0m`},s=()=>typeof process<`u`&&process.versions!=null&&process.versions.node!=null,c=()=>!!(!s()||process.env.NO_COLOR!==void 0||process.env.CI!==void 0||process.stdout&&!process.stdout.isTTY),l=(e,t)=>s()&&!c()?`${o[e]}${t}${o.reset}`:t,u=e=>Object.entries(e.byPath).map(([e,t])=>{let n=t.message.startsWith(e)?t.message.slice(e.length):t.message,r=n.match(/\(was "([^"]+)"\)/),i=r?n.replace(`(was "${r[1]}")`,`(was ${l(`cyan`,`"${r[1]}"`)})`):n;return`${l(`yellow`,e)}${i}`}).join(`
4
+ `);var d=class extends Error{constructor(e,t=`Errors found while validating environment variables`){super(`${l(`red`,t)}\n${a(u(e))}\n`),this.name=`ArkEnvError`}};const f=i.type;function p(e,t=process.env){let n=(typeof e==`function`&&`assert`in e?e:i.type.raw(e))(t);if(n instanceof f.errors)throw new d(n);return n}const m=p;var h=m;exports.ArkEnvError=d,exports.createEnv=p,exports.default=h,exports.type=f;
package/dist/index.d.cts CHANGED
@@ -1,73 +1,75 @@
1
- import * as arktype16 from "arktype";
2
- import { ArkErrors, distill, type as type$1 } from "arktype";
3
- import * as arktype_internal_keywords_string_ts10 from "arktype/internal/keywords/string.ts";
4
- import * as arktype_internal_attributes_ts5 from "arktype/internal/attributes.ts";
1
+ import * as arktype0 from "arktype";
2
+ import { ArkErrors, Type, distill, type as type$1 } from "arktype";
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_internal_variants_object_ts0 from "arktype/internal/variants/object.ts";
5
6
  import * as arktype_internal_type_ts0 from "arktype/internal/type.ts";
6
7
 
7
- //#region src/scope.d.ts
8
+ //#region ../internal/scope/dist/index.d.ts
9
+ //#region src/index.d.ts
8
10
  /**
9
11
  * The root scope for the ArkEnv library, containing extensions to the ArkType scopes with ArkEnv-specific types like `string.host` and `number.port`.
10
12
  */
11
- declare const $: arktype16.Scope<{
12
- string: arktype16.Submodule<{
13
- trim: arktype16.Submodule<arktype_internal_keywords_string_ts10.trim.$ & {
14
- " arkInferred": (In: string) => arktype_internal_attributes_ts5.To<string>;
13
+ declare const $: arktype0.Scope<{
14
+ string: arktype0.Submodule<{
15
+ trim: arktype0.Submodule<arktype_internal_keywords_string_ts0.trim.$ & {
16
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
15
17
  }>;
16
- normalize: arktype16.Submodule<arktype_internal_keywords_string_ts10.normalize.$ & {
17
- " arkInferred": (In: string) => arktype_internal_attributes_ts5.To<string>;
18
+ normalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.normalize.$ & {
19
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
18
20
  }>;
19
21
  root: string;
20
22
  alpha: string;
21
23
  alphanumeric: string;
22
24
  hex: string;
23
- base64: arktype16.Submodule<{
25
+ base64: arktype0.Submodule<{
24
26
  root: string;
25
27
  url: string;
26
28
  } & {
27
29
  " arkInferred": string;
28
30
  }>;
29
- capitalize: arktype16.Submodule<arktype_internal_keywords_string_ts10.capitalize.$ & {
30
- " arkInferred": (In: string) => arktype_internal_attributes_ts5.To<string>;
31
+ capitalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.capitalize.$ & {
32
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
31
33
  }>;
32
34
  creditCard: string;
33
- date: arktype16.Submodule<arktype_internal_keywords_string_ts10.stringDate.$ & {
35
+ date: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringDate.$ & {
34
36
  " arkInferred": string;
35
37
  }>;
36
38
  digits: string;
37
39
  email: string;
38
- integer: arktype16.Submodule<arktype_internal_keywords_string_ts10.stringInteger.$ & {
40
+ integer: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringInteger.$ & {
39
41
  " arkInferred": string;
40
42
  }>;
41
- ip: arktype16.Submodule<arktype_internal_keywords_string_ts10.ip.$ & {
43
+ ip: arktype0.Submodule<arktype_internal_keywords_string_ts0.ip.$ & {
42
44
  " arkInferred": string;
43
45
  }>;
44
- json: arktype16.Submodule<arktype_internal_keywords_string_ts10.stringJson.$ & {
46
+ json: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringJson.$ & {
45
47
  " arkInferred": string;
46
48
  }>;
47
- lower: arktype16.Submodule<arktype_internal_keywords_string_ts10.lower.$ & {
48
- " arkInferred": (In: string) => arktype_internal_attributes_ts5.To<string>;
49
+ lower: arktype0.Submodule<arktype_internal_keywords_string_ts0.lower.$ & {
50
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
49
51
  }>;
50
- numeric: arktype16.Submodule<arktype_internal_keywords_string_ts10.stringNumeric.$ & {
52
+ numeric: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringNumeric.$ & {
51
53
  " arkInferred": string;
52
54
  }>;
53
55
  regex: string;
54
56
  semver: string;
55
- upper: arktype16.Submodule<{
56
- root: (In: string) => arktype_internal_attributes_ts5.To<string>;
57
+ upper: arktype0.Submodule<{
58
+ root: (In: string) => arktype_internal_attributes_ts0.To<string>;
57
59
  preformatted: string;
58
60
  } & {
59
- " arkInferred": (In: string) => arktype_internal_attributes_ts5.To<string>;
61
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
60
62
  }>;
61
- url: arktype16.Submodule<arktype_internal_keywords_string_ts10.url.$ & {
63
+ url: arktype0.Submodule<arktype_internal_keywords_string_ts0.url.$ & {
62
64
  " arkInferred": string;
63
65
  }>;
64
- uuid: arktype16.Submodule<arktype_internal_keywords_string_ts10.uuid.$ & {
66
+ uuid: arktype0.Submodule<arktype_internal_keywords_string_ts0.uuid.$ & {
65
67
  " arkInferred": string;
66
68
  }>;
67
69
  " arkInferred": string;
68
70
  host: string;
69
71
  }>;
70
- number: arktype16.Submodule<{
72
+ number: arktype0.Submodule<{
71
73
  NaN: number;
72
74
  Infinity: number;
73
75
  root: number;
@@ -76,21 +78,34 @@ declare const $: arktype16.Scope<{
76
78
  epoch: number;
77
79
  safe: number;
78
80
  NegativeInfinity: number;
79
- port: (In: string) => arktype16.Out<number>;
81
+ port: (In: string) => arktype0.Out<number>;
80
82
  }>;
81
- boolean: (In: boolean | "false" | "true") => arktype16.Out<boolean>;
83
+ boolean: (In: boolean | "false" | "true") => arktype0.Out<boolean>;
82
84
  }>;
83
85
  //#endregion
84
- //#region src/create-env.d.ts
85
- type RuntimeEnvironment = Record<string, string | undefined>;
86
- type EnvSchema<def$1> = type$1.validate<def$1, (typeof $)["t"]>;
86
+ //#endregion
87
+ //#region ../internal/types/dist/infer-type.d.ts
87
88
  /**
88
- * Extract the inferred type from an ArkType type definition by checking its call signature
89
- * When a type definition is called, it returns either the validated value or type.errors
89
+ * Extract the inferred type from an ArkType type definition by checking its call signature.
90
+ * When a type definition is called, it returns either the validated value or type.errors.
91
+ *
92
+ * @template T - The ArkType type definition to infer from
90
93
  */
91
94
  type InferType<T> = T extends ((value: Record<string, string | undefined>) => infer R) ? R extends type$1.errors ? never : R : T extends type$1.Any<infer U, infer _Scope> ? U : never;
95
+ //#endregion
96
+ //#region ../internal/types/dist/schema.d.ts
97
+ declare const SchemaShape: arktype_internal_variants_object_ts0.ObjectType<{
98
+ [x: string]: unknown;
99
+ }, {}>;
100
+ type SchemaShape = typeof SchemaShape.infer;
101
+ type EnvSchemaWithType = Type<SchemaShape, (typeof $)["t"]>;
102
+ //#endregion
103
+ //#region src/create-env.d.ts
104
+ type EnvSchema<def$1> = type$1.validate<def$1, (typeof $)["t"]>;
105
+ type RuntimeEnvironment = Record<string, string | undefined>;
92
106
  /**
93
- * TODO: If possible, find a better type than "const T extends Record<string, unknown>",
107
+ * TODO: `SchemaShape` is basically `Record<string, unknown>`.
108
+ * If possible, find a better type than "const T extends Record<string, unknown>",
94
109
  * and be as close as possible to the type accepted by ArkType's `type`.
95
110
  */
96
111
  /**
@@ -100,71 +115,71 @@ type InferType<T> = T extends ((value: Record<string, string | undefined>) => in
100
115
  * @returns The validated environment variable schema
101
116
  * @throws An {@link ArkEnvError | error} if the environment variables are invalid.
102
117
  */
103
- declare function createEnv<const T extends Record<string, unknown>>(def: EnvSchema<T>, env?: RuntimeEnvironment): distill.Out<type$1.infer<T, (typeof $)["t"]>>;
104
- declare function createEnv<T extends type$1.Any>(def: T, env?: RuntimeEnvironment): InferType<T>;
105
- declare function createEnv<const T extends Record<string, unknown>>(def: EnvSchema<T> | type$1.Any, env?: RuntimeEnvironment): distill.Out<type$1.infer<T, (typeof $)["t"]>> | InferType<typeof def>;
118
+ declare function createEnv<T extends EnvSchemaWithType>(def: T, env?: RuntimeEnvironment): InferType<T>;
119
+ declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T>, env?: RuntimeEnvironment): distill.Out<type$1.infer<T, (typeof $)["t"]>>;
120
+ declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T> | EnvSchemaWithType, env?: RuntimeEnvironment): distill.Out<type$1.infer<T, (typeof $)["t"]>> | InferType<typeof def>;
106
121
  //#endregion
107
122
  //#region src/type.d.ts
108
123
  declare const type: arktype_internal_type_ts0.TypeParser<{
109
- string: arktype16.Submodule<{
110
- trim: arktype16.Submodule<arktype_internal_keywords_string_ts10.trim.$ & {
111
- " arkInferred": (In: string) => arktype_internal_attributes_ts5.To<string>;
124
+ string: arktype0.Submodule<{
125
+ trim: arktype0.Submodule<arktype_internal_keywords_string_ts0.trim.$ & {
126
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
112
127
  }>;
113
- normalize: arktype16.Submodule<arktype_internal_keywords_string_ts10.normalize.$ & {
114
- " arkInferred": (In: string) => arktype_internal_attributes_ts5.To<string>;
128
+ normalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.normalize.$ & {
129
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
115
130
  }>;
116
131
  root: string;
117
132
  alpha: string;
118
133
  alphanumeric: string;
119
134
  hex: string;
120
- base64: arktype16.Submodule<{
135
+ base64: arktype0.Submodule<{
121
136
  root: string;
122
137
  url: string;
123
138
  } & {
124
139
  " arkInferred": string;
125
140
  }>;
126
- capitalize: arktype16.Submodule<arktype_internal_keywords_string_ts10.capitalize.$ & {
127
- " arkInferred": (In: string) => arktype_internal_attributes_ts5.To<string>;
141
+ capitalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.capitalize.$ & {
142
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
128
143
  }>;
129
144
  creditCard: string;
130
- date: arktype16.Submodule<arktype_internal_keywords_string_ts10.stringDate.$ & {
145
+ date: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringDate.$ & {
131
146
  " arkInferred": string;
132
147
  }>;
133
148
  digits: string;
134
149
  email: string;
135
- integer: arktype16.Submodule<arktype_internal_keywords_string_ts10.stringInteger.$ & {
150
+ integer: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringInteger.$ & {
136
151
  " arkInferred": string;
137
152
  }>;
138
- ip: arktype16.Submodule<arktype_internal_keywords_string_ts10.ip.$ & {
153
+ ip: arktype0.Submodule<arktype_internal_keywords_string_ts0.ip.$ & {
139
154
  " arkInferred": string;
140
155
  }>;
141
- json: arktype16.Submodule<arktype_internal_keywords_string_ts10.stringJson.$ & {
156
+ json: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringJson.$ & {
142
157
  " arkInferred": string;
143
158
  }>;
144
- lower: arktype16.Submodule<arktype_internal_keywords_string_ts10.lower.$ & {
145
- " arkInferred": (In: string) => arktype_internal_attributes_ts5.To<string>;
159
+ lower: arktype0.Submodule<arktype_internal_keywords_string_ts0.lower.$ & {
160
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
146
161
  }>;
147
- numeric: arktype16.Submodule<arktype_internal_keywords_string_ts10.stringNumeric.$ & {
162
+ numeric: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringNumeric.$ & {
148
163
  " arkInferred": string;
149
164
  }>;
150
165
  regex: string;
151
166
  semver: string;
152
- upper: arktype16.Submodule<{
153
- root: (In: string) => arktype_internal_attributes_ts5.To<string>;
167
+ upper: arktype0.Submodule<{
168
+ root: (In: string) => arktype_internal_attributes_ts0.To<string>;
154
169
  preformatted: string;
155
170
  } & {
156
- " arkInferred": (In: string) => arktype_internal_attributes_ts5.To<string>;
171
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
157
172
  }>;
158
- url: arktype16.Submodule<arktype_internal_keywords_string_ts10.url.$ & {
173
+ url: arktype0.Submodule<arktype_internal_keywords_string_ts0.url.$ & {
159
174
  " arkInferred": string;
160
175
  }>;
161
- uuid: arktype16.Submodule<arktype_internal_keywords_string_ts10.uuid.$ & {
176
+ uuid: arktype0.Submodule<arktype_internal_keywords_string_ts0.uuid.$ & {
162
177
  " arkInferred": string;
163
178
  }>;
164
179
  " arkInferred": string;
165
180
  host: string;
166
181
  }>;
167
- number: arktype16.Submodule<{
182
+ number: arktype0.Submodule<{
168
183
  NaN: number;
169
184
  Infinity: number;
170
185
  root: number;
@@ -173,9 +188,9 @@ declare const type: arktype_internal_type_ts0.TypeParser<{
173
188
  epoch: number;
174
189
  safe: number;
175
190
  NegativeInfinity: number;
176
- port: (In: string) => arktype16.Out<number>;
191
+ port: (In: string) => arktype0.Out<number>;
177
192
  }>;
178
- boolean: (In: boolean | "false" | "true") => arktype16.Out<boolean>;
193
+ boolean: (In: boolean | "false" | "true") => arktype0.Out<boolean>;
179
194
  }>;
180
195
  //#endregion
181
196
  //#region src/errors.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/scope.ts","../src/create-env.ts","../src/type.ts","../src/errors.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAQa,aAAC;;;;IAUZ,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAVY,qBAAA,yDAAA;MAAA,cAAA,EAAA,MAAA;;;;ICJT,KAAA,qBAAqB,CAAM;MAEpB,IAAS,EAAA,CAAA,EAAA,EAAA,MAAA,EAAA,qCAAA,CAAA,MAAA,CAAA;MAAsB,YAAA,EAAA,MAAA;IAAa,CAAA,GAAA;MAAtB,cAAA,EAAA,CAAA,EAAA,EAAA,MAAA,EAAA,qCAAA,CAAA,MAAA,CAAA;IAAQ,CAAA,CAAA;IAMrC,GAAA,qBAAS,+CAAA;MAAM,cAAA,EAAA,MAAA;IACZ,CAAA,CAAA;IAEL,IAAA,qBAAA,gDAAA;MAAe,cAAA,EAAA,MAAA;IAEd,CAAA,CAAA;IACD,cAAA,EAAA,MAAA;IAAe,IAAA,EAAA,MAAA;EACd,CAAA,CAAA;EAAC,MAAA,qBAAA,CAAA;IAeW,GAAA,EAAA,MAAS;IAAiB,QAAA,EAAA,MAAA;IAC1B,IAAA,EAAA,MAAA;IAAV,OAAA,EAAA,MAAA;IACC,cAAA,EAAA,MAAA;IACmB,KA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IAeW,OAAA,EAAS,MAAA;IAAiB,cAAA,EAAA,MAAA;IAC1B,KAAA,EAAA,MAAA;IAAV,IAAA,EAAA,MAAA;IACC,gBAAA,EAAA,MAAA;IACmB,IAAA,EAAA,CAAA,EAAA,EAAA,MAAA,EAAA,gBAAA,CAAA,MAAA,CAAA;EAAW,CAAA,CAAA;EAAtB,OAAK,EAAA,CAAA,EAAA,EAAA,OAAA,GAAA,OAAA,GAAA,MAAA,EAAA,gBAAA,CAAA,OAAA,CAAA;CAAjB,CAAA;;;AD7BU,cGqBA,WAAA,SAAoB,KAAA,CHX/B;sBGaQ;;;;;;;;;AHvBV,cICM,MJSJ,EAAA,OITU,SJSV"}
1
+ {"version":3,"file":"index.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","Out","Scope","type","InferType","T","Record","R","errors","Any","U","$","Type","SchemaShape","arktype_internal_variants_object_ts0","ObjectType","infer","EnvSchemaWithType"],"sources":["../../internal/scope/dist/index.d.ts","../../internal/types/dist/infer-type.d.ts","../../internal/types/dist/schema.d.ts","../src/create-env.ts","../src/type.ts","../src/errors.ts","../src/index.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/index.d.ts\n/**\n * The root scope for the ArkEnv library, containing extensions to the ArkType scopes with ArkEnv-specific types 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: (In: string) => arktype0.Out<number>;\n }>;\n boolean: (In: boolean | \"false\" | \"true\") => arktype0.Out<boolean>;\n}>;\n//#endregion\nexport { $ };\n//# sourceMappingURL=index.d.ts.map","import type { type } from \"arktype\";\n/**\n * Extract the inferred type from an ArkType type definition by checking its call signature.\n * When a type definition is called, it returns either the validated value or type.errors.\n *\n * @template T - The ArkType type definition to infer from\n */\nexport type InferType<T> = T extends (value: Record<string, string | undefined>) => infer R ? R extends type.errors ? never : R : 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 declare const SchemaShape: import(\"arktype/internal/variants/object.ts\").ObjectType<{\n [x: string]: unknown;\n}, {}>;\nexport type SchemaShape = typeof SchemaShape.infer;\nexport type EnvSchemaWithType = Type<SchemaShape, (typeof $)[\"t\"]>;\n//# sourceMappingURL=schema.d.ts.map"],"mappings":";;;;;;;;;;;;AAEkF,cAMpEG,CAuEZ,EAvEeH,QAAAA,CAASkB,KAuExB,CAAA;EArE2BjB,MAAAA,EADnBD,QAAAA,CAASM,SACUL,CAAAA;IACSC,IAAAA,EAD5BF,QAAAA,CAASM,SACmBJ,CADTD,oCAAAA,CAAqCG,IAAAA,CAAKD,CACDE,GAAAA;MAD5DL,cAASM,EAAAA,CAAAA,EAAAA,EAAAA,MAAAA,EAAAA,GACmBJ,+BAAAA,CAAgCG,EADnDC,CAAAA,MAAAA,CAAAA;IAGeL,CAAAA,CAAAA;IACIC,SAAAA,EADvBF,QAAAA,CAASM,SAC8CD,CADpCJ,oCAAAA,CAAqCM,SAAAA,CAAUJ,CACXE,GAAAA;MADvDL,cAASM,EAAAA,CAAAA,EAAAA,EAAAA,MAAAA,EAAAA,GACcJ,+BAAAA,CAAgCG,EAD9CC,CAAAA,MAAAA,CAAAA;IAOZN,CAAAA,CAAAA;IAMuBC,IAAAA,EAAAA,MAAAA;IACGC,KAAAA,EAAAA,MAAAA;IADtBF,YAASM,EAAAA,MAAAA;IAIIL,GAAAA,EAAAA,MAAAA;IAAnBD,MAASM,EAVPN,QAAAA,CAASM,SAUFA,CAAAA;MAKaL,IAAAA,EAAAA,MAAAA;MAAnBD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AA,+CAAAA;MAAIF,cAAAA,EAAAA,MAAAA;IAAeI,CAAAA,CAAAA;IAA6BC,cAAAA,EAAAA,MAAAA;IAAC,IAAA,EAAA,MAAA;;;;ICL1JG,QAAAA,EAEf,MAAA;IACMA,IAAAA,EAAAA,MAAW;IACXI,OAAAA,EAAAA,MAAAA;IAAyBJ,cAAAA,EAAAA,MAAAA;IAAqBF,KAAAA,EAAAA,MAAAA;IAA1BC,IAAAA,EAAAA,MAAAA;IAAI,gBAAA,EAAA,MAAA;;;;ACApC,CAAA,CAAA;;;cEsBa,WAAA,SAAoB,KAAA;ELpBnBzB,WAuEZ,CAAA,MAAA,EKjDQ,SLiDR,EAAA,OAAA,CAAA,EAAA,MAAA;;;;;;;;;cMtEI,eAAM"}
package/dist/index.d.ts CHANGED
@@ -1,73 +1,75 @@
1
- import * as arktype16 from "arktype";
2
- import { ArkErrors, distill, type as type$1 } from "arktype";
3
- import * as arktype_internal_keywords_string_ts10 from "arktype/internal/keywords/string.ts";
4
- import * as arktype_internal_attributes_ts5 from "arktype/internal/attributes.ts";
1
+ import * as arktype0 from "arktype";
2
+ import { ArkErrors, Type, distill, type as type$1 } from "arktype";
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_internal_variants_object_ts0 from "arktype/internal/variants/object.ts";
5
6
  import * as arktype_internal_type_ts0 from "arktype/internal/type.ts";
6
7
 
7
- //#region src/scope.d.ts
8
+ //#region ../internal/scope/dist/index.d.ts
9
+ //#region src/index.d.ts
8
10
  /**
9
11
  * The root scope for the ArkEnv library, containing extensions to the ArkType scopes with ArkEnv-specific types like `string.host` and `number.port`.
10
12
  */
11
- declare const $: arktype16.Scope<{
12
- string: arktype16.Submodule<{
13
- trim: arktype16.Submodule<arktype_internal_keywords_string_ts10.trim.$ & {
14
- " arkInferred": (In: string) => arktype_internal_attributes_ts5.To<string>;
13
+ declare const $: arktype0.Scope<{
14
+ string: arktype0.Submodule<{
15
+ trim: arktype0.Submodule<arktype_internal_keywords_string_ts0.trim.$ & {
16
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
15
17
  }>;
16
- normalize: arktype16.Submodule<arktype_internal_keywords_string_ts10.normalize.$ & {
17
- " arkInferred": (In: string) => arktype_internal_attributes_ts5.To<string>;
18
+ normalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.normalize.$ & {
19
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
18
20
  }>;
19
21
  root: string;
20
22
  alpha: string;
21
23
  alphanumeric: string;
22
24
  hex: string;
23
- base64: arktype16.Submodule<{
25
+ base64: arktype0.Submodule<{
24
26
  root: string;
25
27
  url: string;
26
28
  } & {
27
29
  " arkInferred": string;
28
30
  }>;
29
- capitalize: arktype16.Submodule<arktype_internal_keywords_string_ts10.capitalize.$ & {
30
- " arkInferred": (In: string) => arktype_internal_attributes_ts5.To<string>;
31
+ capitalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.capitalize.$ & {
32
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
31
33
  }>;
32
34
  creditCard: string;
33
- date: arktype16.Submodule<arktype_internal_keywords_string_ts10.stringDate.$ & {
35
+ date: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringDate.$ & {
34
36
  " arkInferred": string;
35
37
  }>;
36
38
  digits: string;
37
39
  email: string;
38
- integer: arktype16.Submodule<arktype_internal_keywords_string_ts10.stringInteger.$ & {
40
+ integer: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringInteger.$ & {
39
41
  " arkInferred": string;
40
42
  }>;
41
- ip: arktype16.Submodule<arktype_internal_keywords_string_ts10.ip.$ & {
43
+ ip: arktype0.Submodule<arktype_internal_keywords_string_ts0.ip.$ & {
42
44
  " arkInferred": string;
43
45
  }>;
44
- json: arktype16.Submodule<arktype_internal_keywords_string_ts10.stringJson.$ & {
46
+ json: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringJson.$ & {
45
47
  " arkInferred": string;
46
48
  }>;
47
- lower: arktype16.Submodule<arktype_internal_keywords_string_ts10.lower.$ & {
48
- " arkInferred": (In: string) => arktype_internal_attributes_ts5.To<string>;
49
+ lower: arktype0.Submodule<arktype_internal_keywords_string_ts0.lower.$ & {
50
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
49
51
  }>;
50
- numeric: arktype16.Submodule<arktype_internal_keywords_string_ts10.stringNumeric.$ & {
52
+ numeric: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringNumeric.$ & {
51
53
  " arkInferred": string;
52
54
  }>;
53
55
  regex: string;
54
56
  semver: string;
55
- upper: arktype16.Submodule<{
56
- root: (In: string) => arktype_internal_attributes_ts5.To<string>;
57
+ upper: arktype0.Submodule<{
58
+ root: (In: string) => arktype_internal_attributes_ts0.To<string>;
57
59
  preformatted: string;
58
60
  } & {
59
- " arkInferred": (In: string) => arktype_internal_attributes_ts5.To<string>;
61
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
60
62
  }>;
61
- url: arktype16.Submodule<arktype_internal_keywords_string_ts10.url.$ & {
63
+ url: arktype0.Submodule<arktype_internal_keywords_string_ts0.url.$ & {
62
64
  " arkInferred": string;
63
65
  }>;
64
- uuid: arktype16.Submodule<arktype_internal_keywords_string_ts10.uuid.$ & {
66
+ uuid: arktype0.Submodule<arktype_internal_keywords_string_ts0.uuid.$ & {
65
67
  " arkInferred": string;
66
68
  }>;
67
69
  " arkInferred": string;
68
70
  host: string;
69
71
  }>;
70
- number: arktype16.Submodule<{
72
+ number: arktype0.Submodule<{
71
73
  NaN: number;
72
74
  Infinity: number;
73
75
  root: number;
@@ -76,21 +78,34 @@ declare const $: arktype16.Scope<{
76
78
  epoch: number;
77
79
  safe: number;
78
80
  NegativeInfinity: number;
79
- port: (In: string) => arktype16.Out<number>;
81
+ port: (In: string) => arktype0.Out<number>;
80
82
  }>;
81
- boolean: (In: boolean | "false" | "true") => arktype16.Out<boolean>;
83
+ boolean: (In: boolean | "false" | "true") => arktype0.Out<boolean>;
82
84
  }>;
83
85
  //#endregion
84
- //#region src/create-env.d.ts
85
- type RuntimeEnvironment = Record<string, string | undefined>;
86
- type EnvSchema<def$1> = type$1.validate<def$1, (typeof $)["t"]>;
86
+ //#endregion
87
+ //#region ../internal/types/dist/infer-type.d.ts
87
88
  /**
88
- * Extract the inferred type from an ArkType type definition by checking its call signature
89
- * When a type definition is called, it returns either the validated value or type.errors
89
+ * Extract the inferred type from an ArkType type definition by checking its call signature.
90
+ * When a type definition is called, it returns either the validated value or type.errors.
91
+ *
92
+ * @template T - The ArkType type definition to infer from
90
93
  */
91
94
  type InferType<T> = T extends ((value: Record<string, string | undefined>) => infer R) ? R extends type$1.errors ? never : R : T extends type$1.Any<infer U, infer _Scope> ? U : never;
95
+ //#endregion
96
+ //#region ../internal/types/dist/schema.d.ts
97
+ declare const SchemaShape: arktype_internal_variants_object_ts0.ObjectType<{
98
+ [x: string]: unknown;
99
+ }, {}>;
100
+ type SchemaShape = typeof SchemaShape.infer;
101
+ type EnvSchemaWithType = Type<SchemaShape, (typeof $)["t"]>;
102
+ //#endregion
103
+ //#region src/create-env.d.ts
104
+ type EnvSchema<def$1> = type$1.validate<def$1, (typeof $)["t"]>;
105
+ type RuntimeEnvironment = Record<string, string | undefined>;
92
106
  /**
93
- * TODO: If possible, find a better type than "const T extends Record<string, unknown>",
107
+ * TODO: `SchemaShape` is basically `Record<string, unknown>`.
108
+ * If possible, find a better type than "const T extends Record<string, unknown>",
94
109
  * and be as close as possible to the type accepted by ArkType's `type`.
95
110
  */
96
111
  /**
@@ -100,71 +115,71 @@ type InferType<T> = T extends ((value: Record<string, string | undefined>) => in
100
115
  * @returns The validated environment variable schema
101
116
  * @throws An {@link ArkEnvError | error} if the environment variables are invalid.
102
117
  */
103
- declare function createEnv<const T extends Record<string, unknown>>(def: EnvSchema<T>, env?: RuntimeEnvironment): distill.Out<type$1.infer<T, (typeof $)["t"]>>;
104
- declare function createEnv<T extends type$1.Any>(def: T, env?: RuntimeEnvironment): InferType<T>;
105
- declare function createEnv<const T extends Record<string, unknown>>(def: EnvSchema<T> | type$1.Any, env?: RuntimeEnvironment): distill.Out<type$1.infer<T, (typeof $)["t"]>> | InferType<typeof def>;
118
+ declare function createEnv<T extends EnvSchemaWithType>(def: T, env?: RuntimeEnvironment): InferType<T>;
119
+ declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T>, env?: RuntimeEnvironment): distill.Out<type$1.infer<T, (typeof $)["t"]>>;
120
+ declare function createEnv<const T extends SchemaShape>(def: EnvSchema<T> | EnvSchemaWithType, env?: RuntimeEnvironment): distill.Out<type$1.infer<T, (typeof $)["t"]>> | InferType<typeof def>;
106
121
  //#endregion
107
122
  //#region src/type.d.ts
108
123
  declare const type: arktype_internal_type_ts0.TypeParser<{
109
- string: arktype16.Submodule<{
110
- trim: arktype16.Submodule<arktype_internal_keywords_string_ts10.trim.$ & {
111
- " arkInferred": (In: string) => arktype_internal_attributes_ts5.To<string>;
124
+ string: arktype0.Submodule<{
125
+ trim: arktype0.Submodule<arktype_internal_keywords_string_ts0.trim.$ & {
126
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
112
127
  }>;
113
- normalize: arktype16.Submodule<arktype_internal_keywords_string_ts10.normalize.$ & {
114
- " arkInferred": (In: string) => arktype_internal_attributes_ts5.To<string>;
128
+ normalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.normalize.$ & {
129
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
115
130
  }>;
116
131
  root: string;
117
132
  alpha: string;
118
133
  alphanumeric: string;
119
134
  hex: string;
120
- base64: arktype16.Submodule<{
135
+ base64: arktype0.Submodule<{
121
136
  root: string;
122
137
  url: string;
123
138
  } & {
124
139
  " arkInferred": string;
125
140
  }>;
126
- capitalize: arktype16.Submodule<arktype_internal_keywords_string_ts10.capitalize.$ & {
127
- " arkInferred": (In: string) => arktype_internal_attributes_ts5.To<string>;
141
+ capitalize: arktype0.Submodule<arktype_internal_keywords_string_ts0.capitalize.$ & {
142
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
128
143
  }>;
129
144
  creditCard: string;
130
- date: arktype16.Submodule<arktype_internal_keywords_string_ts10.stringDate.$ & {
145
+ date: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringDate.$ & {
131
146
  " arkInferred": string;
132
147
  }>;
133
148
  digits: string;
134
149
  email: string;
135
- integer: arktype16.Submodule<arktype_internal_keywords_string_ts10.stringInteger.$ & {
150
+ integer: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringInteger.$ & {
136
151
  " arkInferred": string;
137
152
  }>;
138
- ip: arktype16.Submodule<arktype_internal_keywords_string_ts10.ip.$ & {
153
+ ip: arktype0.Submodule<arktype_internal_keywords_string_ts0.ip.$ & {
139
154
  " arkInferred": string;
140
155
  }>;
141
- json: arktype16.Submodule<arktype_internal_keywords_string_ts10.stringJson.$ & {
156
+ json: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringJson.$ & {
142
157
  " arkInferred": string;
143
158
  }>;
144
- lower: arktype16.Submodule<arktype_internal_keywords_string_ts10.lower.$ & {
145
- " arkInferred": (In: string) => arktype_internal_attributes_ts5.To<string>;
159
+ lower: arktype0.Submodule<arktype_internal_keywords_string_ts0.lower.$ & {
160
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
146
161
  }>;
147
- numeric: arktype16.Submodule<arktype_internal_keywords_string_ts10.stringNumeric.$ & {
162
+ numeric: arktype0.Submodule<arktype_internal_keywords_string_ts0.stringNumeric.$ & {
148
163
  " arkInferred": string;
149
164
  }>;
150
165
  regex: string;
151
166
  semver: string;
152
- upper: arktype16.Submodule<{
153
- root: (In: string) => arktype_internal_attributes_ts5.To<string>;
167
+ upper: arktype0.Submodule<{
168
+ root: (In: string) => arktype_internal_attributes_ts0.To<string>;
154
169
  preformatted: string;
155
170
  } & {
156
- " arkInferred": (In: string) => arktype_internal_attributes_ts5.To<string>;
171
+ " arkInferred": (In: string) => arktype_internal_attributes_ts0.To<string>;
157
172
  }>;
158
- url: arktype16.Submodule<arktype_internal_keywords_string_ts10.url.$ & {
173
+ url: arktype0.Submodule<arktype_internal_keywords_string_ts0.url.$ & {
159
174
  " arkInferred": string;
160
175
  }>;
161
- uuid: arktype16.Submodule<arktype_internal_keywords_string_ts10.uuid.$ & {
176
+ uuid: arktype0.Submodule<arktype_internal_keywords_string_ts0.uuid.$ & {
162
177
  " arkInferred": string;
163
178
  }>;
164
179
  " arkInferred": string;
165
180
  host: string;
166
181
  }>;
167
- number: arktype16.Submodule<{
182
+ number: arktype0.Submodule<{
168
183
  NaN: number;
169
184
  Infinity: number;
170
185
  root: number;
@@ -173,9 +188,9 @@ declare const type: arktype_internal_type_ts0.TypeParser<{
173
188
  epoch: number;
174
189
  safe: number;
175
190
  NegativeInfinity: number;
176
- port: (In: string) => arktype16.Out<number>;
191
+ port: (In: string) => arktype0.Out<number>;
177
192
  }>;
178
- boolean: (In: boolean | "false" | "true") => arktype16.Out<boolean>;
193
+ boolean: (In: boolean | "false" | "true") => arktype0.Out<boolean>;
179
194
  }>;
180
195
  //#endregion
181
196
  //#region src/errors.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/scope.ts","../src/create-env.ts","../src/type.ts","../src/errors.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAQa,aAAC;;;;IAUZ,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAVY,qBAAA,yDAAA;MAAA,cAAA,EAAA,MAAA;;;;ICJT,KAAA,qBAAqB,CAAM;MAEpB,IAAS,EAAA,CAAA,EAAA,EAAA,MAAA,EAAA,qCAAA,CAAA,MAAA,CAAA;MAAsB,YAAA,EAAA,MAAA;IAAa,CAAA,GAAA;MAAtB,cAAA,EAAA,CAAA,EAAA,EAAA,MAAA,EAAA,qCAAA,C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AEO,cAAS,EAAA,CAAA,EAAA,EAAA,MAAA,EAAA,qCAAA,CAAA,MAAA,CAAA;IAAsB,CAAA,CAAA;IAAa,GAAA,qBAAA,+CAAA;MAAtB,cAAA,EAAA,MAAA;IAAQ,CAAA,CAAA;IAMrC,IAAA,qBAAS,gDAAA;MAAM,cAAA,EAAA,MAAA;IACZ,CAAA,CAAA;IAEL,cAAA,EAAA,MAAA;IAAe,IAAA,EAAA,MAAA;EAEd,CAAA,CAAA;EACD,MAAA,qBAAA,CAAA;IAAe,GAAA,EAAA,MAAA;IACd,QAAA,EAAA,MAAA;IAAC,IAAA,EAAA,MAAA;IAeW,OAAA,EAAS,MAAA;IAAiB,cAAA,EAAA,MAAA;IAC1B,KAAA,EAAA,MAAA;IAAV,IAAA,EAAA,MAAA;IACC,gBAAA,EAAA,MAAA;IACmB,IAAA,EAAA,CAAA,EAAA,EAAA,MAAA,EAAA,gBAAA,CAAA,MAAA,CAAA;EAAW,CAAA,CAAA;EAAtB,OAAK,EAAA,CAAA,EAAA,EAAA,OAAA,GAAA,OAAA,GAAA,MAAA,EAAA,gBAAA,CAAA,OAAA,CAAA;CAAjB,CAAA;;;AD7BU,cGqBA,WAAA,SAAoB,KAAA,CHX/B;sBGaQ;;;;;;;;;AHvBV,cICM,MJSJ,EAAA,OITU,SJSV"}
1
+ {"version":3,"file":"index.d.ts","names":["arktype0","arktype_internal_keywords_string_ts0","arktype_internal_attributes_ts0","$","trim","To","Submodule","normalize","capitalize","stringDate","stringInteger","ip","stringJson","lower","stringNumeric","url","uuid","Out","Scope","type","InferType","T","Record","R","errors","Any","U","$","Type","SchemaShape","arktype_internal_variants_object_ts0","ObjectType","infer","EnvSchemaWithType"],"sources":["../../internal/scope/dist/index.d.ts","../../internal/types/dist/infer-type.d.ts","../../internal/types/dist/schema.d.ts","../src/create-env.ts","../src/type.ts","../src/errors.ts","../src/index.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/index.d.ts\n/**\n * The root scope for the ArkEnv library, containing extensions to the ArkType scopes with ArkEnv-specific types 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: (In: string) => arktype0.Out<number>;\n }>;\n boolean: (In: boolean | \"false\" | \"true\") => arktype0.Out<boolean>;\n}>;\n//#endregion\nexport { $ };\n//# sourceMappingURL=index.d.ts.map","import type { type } from \"arktype\";\n/**\n * Extract the inferred type from an ArkType type definition by checking its call signature.\n * When a type definition is called, it returns either the validated value or type.errors.\n *\n * @template T - The ArkType type definition to infer from\n */\nexport type InferType<T> = T extends (value: Record<string, string | undefined>) => infer R ? R extends type.errors ? never : R : 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 declare const SchemaShape: import(\"arktype/internal/variants/object.ts\").ObjectType<{\n [x: string]: unknown;\n}, {}>;\nexport type SchemaShape = typeof SchemaShape.infer;\nexport type EnvSchemaWithType = Type<SchemaShape, (typeof $)[\"t\"]>;\n//# sourceMappingURL=schema.d.ts.map"],"mappings":";;;;;;;;;;;;AAEkF,cAMpEG,CAuEZ,EAvEeH,QAAAA,CAASkB,KAuExB,CAAA;EArE2BjB,MAAAA,EADnBD,QAAAA,CAASM,SACUL,CAAAA;IACSC,IAAAA,EAD5BF,QAAAA,CAASM,SACmBJ,CADTD,oCAAAA,CAAqCG,IAAAA,CAAKD,CACDE,GAAAA;MAD5DL,cAASM,EAAAA,CAAAA,EAAAA,EAAAA,MAAAA,EAAAA,GACmBJ,+BAAAA,CAAgCG,EADnDC,CAAAA,MAAAA,CAAAA;IAGeL,CAAAA,CAAAA;IACIC,SAAAA,EADvBF,QAAAA,CAASM,S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DH,CAAAA,CAASM;IApDTN,OAASM,oBAAAA,wDAAAA;MAmEgBW,cAAAA,EAAAA,MAAAA;IATzBjB,CAAAA,CAASM;IAW4BN,KAASiB,EAAAA,MAAAA;IAtEvCjB,MAASkB,EAAAA,MAAAA;IAAK,KAAA,oBAAA,CAAA;;;;MCDnBE,cAASC,EAAA,CAAA,EAAA,EAAA,MAAA,EAAA,qCAAA,CAAA,MAAA,CAAA;IAAMA,CAAAA,CAAAA;IAAkBC,GAAAA,oBAAAA,8CAAAA;MAAiDC,cAAAA,EAAAA,MAAAA;IAAeC,CAAAA,CAAAA;IAAiBD,IAAAA,oBAAAA,+CAAAA;MAAIF,cAAAA,EAAAA,MAAAA;IAAeI,CAAAA,CAAAA;IAA6BC,cAAAA,EAAAA,MAAAA;IAAC,IAAA,EAAA,MAAA;;;;ICL1JG,QAAAA,EAEf,MAAA;IACMA,IAAAA,EAAAA,MAAW;IACXI,OAAAA,EAAAA,MAAAA;IAAyBJ,cAAAA,EAAAA,MAAAA;IAAqBF,KAAAA,EAAAA,MAAAA;IAA1BC,IAAAA,EAAAA,MAAAA;IAAI,gBAAA,EAAA,MAAA;;;;ACApC,CAAA,CAAA;;;cEsBa,WAAA,SAAoB,KAAA;ELpBnBzB,WAuEZ,CAAA,MAAA,EKjDQ,SLiDR,EAAA,OAAA,CAAA,EAAA,MAAA;;;;;;;;;cMtEI,eAAM"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import{scope as e,type as t}from"arktype";const n={red:`\x1B[31m`,yellow:`\x1B[33m`,cyan:`\x1B[36m`,reset:`\x1B[0m`},r=()=>typeof process<`u`&&process.versions!=null&&process.versions.node!=null,i=()=>!!(!r()||process.env.NO_COLOR!==void 0||process.env.CI!==void 0||process.stdout&&!process.stdout.isTTY),a=(e,t)=>r()&&!i()?`${n[e]}${t}${n.reset}`:t,o=(e,t=2,{dontDetectNewlines:n=!1}={})=>n?`${` `.repeat(t)}${e}`:e.split(`
1
+ import{scope as e,type as t}from"arktype";const n=t(`string`,`=>`,(e,t)=>{let n=Number.parseInt(e,10);return(!Number.isInteger(n)||!(0<=n&&n<=65535))&&t.mustBe(`an integer between 0 and 65535`),n}),r=t(`string.ip | 'localhost'`),i=t(`'true' | 'false' | true | false`,`=>`,e=>e===`true`||e===!0),a=e({string:t.module({...t.keywords.string,host:r}),number:t.module({...t.keywords.number,port:n}),boolean:i}),o=(e,t=2,{dontDetectNewlines:n=!1}={})=>n?`${` `.repeat(t)}${e}`:e.split(`
2
2
  `).map(e=>`${` `.repeat(t)}${e}`).join(`
3
- `),s=e=>Object.entries(e.byPath).map(([e,t])=>{let n=t.message.startsWith(e)?t.message.slice(e.length):t.message,r=n.match(/\(was "([^"]+)"\)/),i=r?n.replace(`(was "${r[1]}")`,`(was ${a(`cyan`,`"${r[1]}"`)})`):n;return`${a(`yellow`,e)}${i}`}).join(`
4
- `);var c=class extends Error{constructor(e,t=`Errors found while validating environment variables`){super(`${a(`red`,t)}\n${o(s(e))}\n`),this.name=`ArkEnvError`}};const l=t(`string`,`=>`,(e,t)=>{let n=Number.parseInt(e,10);return(!Number.isInteger(n)||!(0<=n&&n<=65535))&&t.mustBe(`an integer between 0 and 65535`),n}),u=t(`string.ip | 'localhost'`),d=t(`'true' | 'false' | true | false`,`=>`,e=>e===`true`||e===!0),f=e({string:t.module({...t.keywords.string,host:u}),number:t.module({...t.keywords.number,port:l}),boolean:d});function p(e,n=process.env){let r=(typeof e==`function`&&`assert`in e?e:f.type.raw(e))(n);if(r instanceof t.errors)throw new c(r);return r}const m=f.type;var h=p;export{c as ArkEnvError,p as createEnv,h as default,m as type};
3
+ `),s={red:`\x1B[31m`,yellow:`\x1B[33m`,cyan:`\x1B[36m`,reset:`\x1B[0m`},c=()=>typeof process<`u`&&process.versions!=null&&process.versions.node!=null,l=()=>!!(!c()||process.env.NO_COLOR!==void 0||process.env.CI!==void 0||process.stdout&&!process.stdout.isTTY),u=(e,t)=>c()&&!l()?`${s[e]}${t}${s.reset}`:t,d=e=>Object.entries(e.byPath).map(([e,t])=>{let n=t.message.startsWith(e)?t.message.slice(e.length):t.message,r=n.match(/\(was "([^"]+)"\)/),i=r?n.replace(`(was "${r[1]}")`,`(was ${u(`cyan`,`"${r[1]}"`)})`):n;return`${u(`yellow`,e)}${i}`}).join(`
4
+ `);var f=class extends Error{constructor(e,t=`Errors found while validating environment variables`){super(`${u(`red`,t)}\n${o(d(e))}\n`),this.name=`ArkEnvError`}};const p=a.type;function m(e,t=process.env){let n=(typeof e==`function`&&`assert`in e?e:a.type.raw(e))(t);if(n instanceof p.errors)throw new f(n);return n}var h=m;export{f as ArkEnvError,m as createEnv,h as default,p as type};
5
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["type","type","type"],"sources":["../src/lib/style-text.ts","../src/utils.ts","../src/errors.ts","../src/types.ts","../src/scope.ts","../src/create-env.ts","../src/type.ts","../src/index.ts"],"sourcesContent":["/**\n * Cross-platform text styling utility\n * Uses ANSI colors in Node environments, plain text in browsers\n * Respects NO_COLOR, CI environment variables, and TTY detection\n */\n\n// ANSI color codes for Node environments\nconst colors = {\n\tred: \"\\x1b[31m\",\n\tyellow: \"\\x1b[33m\",\n\tcyan: \"\\x1b[36m\",\n\treset: \"\\x1b[0m\",\n} as const;\n\n/**\n * Check if we're in a Node environment (not browser)\n * Checked dynamically to allow for testing with mocked globals\n */\nconst isNode = (): boolean =>\n\ttypeof process !== \"undefined\" &&\n\tprocess.versions != null &&\n\tprocess.versions.node != null;\n\n/**\n * Check if colors should be disabled based on environment\n * Respects NO_COLOR, CI environment variables, and TTY detection\n */\nconst shouldDisableColors = (): boolean => {\n\tif (!isNode()) return true;\n\n\t// Respect NO_COLOR environment variable (https://no-color.org/)\n\tif (process.env.NO_COLOR !== undefined) return true;\n\n\t// Disable colors in CI environments by default\n\tif (process.env.CI !== undefined) return true;\n\n\t// Disable colors if not writing to a TTY\n\tif (process.stdout && !process.stdout.isTTY) return true;\n\n\treturn false;\n};\n\n/**\n * Style text with color. Uses ANSI codes in Node, plain text in browsers.\n * @param color - The color to apply\n * @param text - The text to style\n * @returns Styled text in Node (if colors enabled), plain text otherwise\n */\nexport const styleText = (\n\tcolor: \"red\" | \"yellow\" | \"cyan\",\n\ttext: string,\n): string => {\n\t// Use ANSI colors only in Node environments with colors enabled\n\tif (isNode() && !shouldDisableColors()) {\n\t\treturn `${colors[color]}${text}${colors.reset}`;\n\t}\n\t// Fall back to plain text in browsers or when colors are disabled\n\treturn text;\n};\n","/**\n * Options for the `indent` function\n */\ntype IndentOptions = {\n\t/**\n\t * Whether to detect newlines and indent each line individually, defaults to false (indenting the whole string)\n\t */\n\tdontDetectNewlines?: boolean;\n};\n\n/**\n * Indent a string by a given amount\n * @param str - The string to indent\n * @param amt - The amount to indent by, defaults to 2\n * @param options - {@link IndentOptions}\n * @returns The indented string\n */\nexport const indent = (\n\tstr: string,\n\tamt = 2,\n\t{ dontDetectNewlines = false }: IndentOptions = {},\n) => {\n\tconst detectNewlines = !dontDetectNewlines;\n\tif (detectNewlines) {\n\t\treturn str\n\t\t\t.split(\"\\n\")\n\t\t\t.map((line) => `${\" \".repeat(amt)}${line}`)\n\t\t\t.join(\"\\n\");\n\t}\n\n\treturn `${\" \".repeat(amt)}${str}`;\n};\n","import type { ArkErrors } from \"arktype\";\nimport { styleText } from \"./lib/style-text\";\nimport { indent } from \"./utils\";\n\n/**\n * Format the errors returned by ArkType to be more readable\n * @param errors - The errors returned by ArkType\n * @returns A string of the formatted errors\n */\nexport const formatErrors = (errors: ArkErrors): string =>\n\tObject.entries(errors.byPath)\n\t\t.map(([path, error]) => {\n\t\t\tconst messageWithoutPath = error.message.startsWith(path)\n\t\t\t\t? error.message.slice(path.length)\n\t\t\t\t: error.message;\n\n\t\t\t// Extract the value in parentheses if it exists\n\t\t\tconst valueMatch = messageWithoutPath.match(/\\(was \"([^\"]+)\"\\)/);\n\t\t\tconst formattedMessage = valueMatch\n\t\t\t\t? messageWithoutPath.replace(\n\t\t\t\t\t\t`(was \"${valueMatch[1]}\")`,\n\t\t\t\t\t\t`(was ${styleText(\"cyan\", `\"${valueMatch[1]}\"`)})`,\n\t\t\t\t\t)\n\t\t\t\t: messageWithoutPath;\n\n\t\t\treturn `${styleText(\"yellow\", path)}${formattedMessage}`;\n\t\t})\n\t\t.join(\"\\n\");\n\nexport class ArkEnvError extends Error {\n\tconstructor(\n\t\terrors: ArkErrors,\n\t\tmessage = \"Errors found while validating environment variables\",\n\t) {\n\t\tsuper(`${styleText(\"red\", message)}\\n${indent(formatErrors(errors))}\\n`);\n\t\tthis.name = \"ArkEnvError\";\n\t}\n}\n","import { type } from \"arktype\";\n\n/**\n * A `string` that can be parsed into a number between 0 and 65535\n */\nexport const port = type(\"string\", \"=>\", (data, ctx) => {\n\tconst asNumber = Number.parseInt(data, 10);\n\tconst isInteger = Number.isInteger(asNumber);\n\tconst isBetween = 0 <= asNumber && asNumber <= 65535;\n\tif (!isInteger || !isBetween) {\n\t\tctx.mustBe(\"an integer between 0 and 65535\");\n\t}\n\treturn asNumber;\n});\n\n/**\n * An IP address or `\"localhost\"`\n */\nexport const host = type(\"string.ip | 'localhost'\");\n\n/**\n * A boolean that accepts string values and converts them to boolean\n * Accepts \"true\" or \"false\" strings and converts them to actual boolean values\n */\nexport const boolean = type(\n\t\"'true' | 'false' | true | false\",\n\t\"=>\",\n\t(str) => str === \"true\" || str === true,\n);\n","import { scope, type } from \"arktype\";\nimport { boolean, host, port } from \"./types\";\n\n// For an explanation of the `$` variable naming convention, see: https://discord.com/channels/957797212103016458/1414659167008063588/1414670282756587581\n\n/**\n * The root scope for the ArkEnv library, containing extensions to the ArkType scopes with ArkEnv-specific types like `string.host` and `number.port`.\n */\nexport const $ = scope({\n\tstring: type.module({\n\t\t...type.keywords.string,\n\t\thost,\n\t}),\n\tnumber: type.module({\n\t\t...type.keywords.number,\n\t\tport,\n\t}),\n\tboolean,\n});\n","import { type distill, type } from \"arktype\";\nimport { ArkEnvError } from \"./errors\";\nimport { $ } from \"./scope\";\n\ntype RuntimeEnvironment = Record<string, string | undefined>;\n\nexport type EnvSchema<def> = type.validate<def, (typeof $)[\"t\"]>;\n\n/**\n * Extract the inferred type from an ArkType type definition by checking its call signature\n * When a type definition is called, it returns either the validated value or type.errors\n */\ntype InferType<T> = T extends (\n\tvalue: Record<string, string | undefined>,\n) => infer R\n\t? R extends type.errors\n\t\t? never\n\t\t: R\n\t: T extends type.Any<infer U, infer _Scope>\n\t\t? U\n\t\t: never;\n\n/**\n * TODO: If possible, find a better type than \"const T extends Record<string, unknown>\",\n * and be as close as possible to the type accepted by ArkType's `type`.\n */\n\n/**\n * Create an environment variables object from a schema and an environment\n * @param def - The environment variable schema (raw object or type definition created with `type()`)\n * @param env - The environment variables to validate, defaults to `process.env`\n * @returns The validated environment variable schema\n * @throws An {@link ArkEnvError | error} if the environment variables are invalid.\n */\nexport function createEnv<const T extends Record<string, unknown>>(\n\tdef: EnvSchema<T>,\n\tenv?: RuntimeEnvironment,\n): distill.Out<type.infer<T, (typeof $)[\"t\"]>>;\nexport function createEnv<T extends type.Any>(\n\tdef: T,\n\tenv?: RuntimeEnvironment,\n): InferType<T>;\nexport function createEnv<const T extends Record<string, unknown>>(\n\tdef: EnvSchema<T> | type.Any,\n\tenv?: RuntimeEnvironment,\n): distill.Out<type.infer<T, (typeof $)[\"t\"]>> | InferType<typeof def>;\nexport function createEnv<const T extends Record<string, unknown>>(\n\tdef: EnvSchema<T> | type.Any,\n\tenv: RuntimeEnvironment = process.env,\n): distill.Out<type.infer<T, (typeof $)[\"t\"]>> | InferType<typeof def> {\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 schema =\n\t\ttypeof def === \"function\" && \"assert\" in def\n\t\t\t? def\n\t\t\t: $.type.raw(def as EnvSchema<T>);\n\n\tconst validatedEnv = schema(env);\n\n\tif (validatedEnv instanceof type.errors) {\n\t\tthrow new ArkEnvError(validatedEnv);\n\t}\n\n\treturn validatedEnv;\n}\n","import { $ } from \"./scope\";\n\nexport const type = $.type;\n","export type { EnvSchema } from \"./create-env\";\n\nimport { createEnv } from \"./create-env\";\n\n/**\n * `arkenv`'s main export, an alias for {@link createEnv}\n *\n * {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables parser powered by {@link https://arktype.io | ArkType}, TypeScript's 1:1 validator.\n */\nconst arkenv = createEnv;\nexport default arkenv;\nexport { type } from \"./type\";\nexport { createEnv };\nexport { ArkEnvError } from \"./errors\";\n"],"mappings":"0CAOA,MAAM,EAAS,CACd,IAAK,WACL,OAAQ,WACR,KAAM,WACN,MAAO,UACP,CAMK,MACL,OAAO,QAAY,KACnB,QAAQ,UAAY,MACpB,QAAQ,SAAS,MAAQ,KAMpB,MAUL,GATI,CAAC,GAAQ,EAGT,QAAQ,IAAI,WAAa,IAAA,IAGzB,QAAQ,IAAI,KAAO,IAAA,IAGnB,QAAQ,QAAU,CAAC,QAAQ,OAAO,OAW1B,GACZ,EACA,IAGI,GAAQ,EAAI,CAAC,GAAqB,CAC9B,GAAG,EAAO,KAAS,IAAO,EAAO,QAGlC,ECxCK,GACZ,EACA,EAAM,EACN,CAAE,qBAAqB,IAAyB,EAAE,GAE1B,EAQjB,GAAG,IAAI,OAAO,EAAI,GAAG,IANpB,EACL,MAAM;EAAK,CACX,IAAK,GAAS,GAAG,IAAI,OAAO,EAAI,GAAG,IAAO,CAC1C,KAAK;EAAK,CClBD,EAAgB,GAC5B,OAAO,QAAQ,EAAO,OAAO,CAC3B,KAAK,CAAC,EAAM,KAAW,CACvB,IAAM,EAAqB,EAAM,QAAQ,WAAW,EAAK,CACtD,EAAM,QAAQ,MAAM,EAAK,OAAO,CAChC,EAAM,QAGH,EAAa,EAAmB,MAAM,oBAAoB,CAC1D,EAAmB,EACtB,EAAmB,QACnB,SAAS,EAAW,GAAG,IACvB,QAAQ,EAAU,OAAQ,IAAI,EAAW,GAAG,GAAG,CAAC,GAChD,CACA,EAEH,MAAO,GAAG,EAAU,SAAU,EAAK,GAAG,KACrC,CACD,KAAK;EAAK,CAEb,IAAa,EAAb,cAAiC,KAAM,CACtC,YACC,EACA,EAAU,sDACT,CACD,MAAM,GAAG,EAAU,MAAO,EAAQ,CAAC,IAAI,EAAO,EAAa,EAAO,CAAC,CAAC,IAAI,CACxE,KAAK,KAAO,gBC9Bd,MAAa,EAAOA,EAAK,SAAU,MAAO,EAAM,IAAQ,CACvD,IAAM,EAAW,OAAO,SAAS,EAAM,GAAG,CAM1C,OAHI,CAFc,OAAO,UAAU,EAAS,EAE1B,EADA,GAAK,GAAY,GAAY,SAE9C,EAAI,OAAO,iCAAiC,CAEtC,GACN,CAKW,EAAOA,EAAK,0BAA0B,CAMtC,EAAUA,EACtB,kCACA,KACC,GAAQ,IAAQ,QAAU,IAAQ,GACnC,CCpBY,EAAI,EAAM,CACtB,OAAQC,EAAK,OAAO,CACnB,GAAGA,EAAK,SAAS,OACjB,OACA,CAAC,CACF,OAAQA,EAAK,OAAO,CACnB,GAAGA,EAAK,SAAS,OACjB,OACA,CAAC,CACF,UACA,CAAC,CC4BF,SAAgB,EACf,EACA,EAA0B,QAAQ,IACoC,CAQtE,IAAM,GAJL,OAAO,GAAQ,YAAc,WAAY,EACtC,EACA,EAAE,KAAK,IAAI,EAAoB,EAEP,EAAI,CAEhC,GAAI,aAAwBC,EAAK,OAChC,MAAM,IAAI,EAAY,EAAa,CAGpC,OAAO,EC7DR,MAAa,EAAO,EAAE,KCQtB,IAAA,EADe"}
1
+ {"version":3,"file":"index.js","names":["e","n","t","r","i","t","n","e","$","$"],"sources":["../../internal/keywords/dist/index.js","../../internal/scope/dist/index.js","../src/utils/indent.ts","../src/utils/style-text.ts","../src/errors.ts","../src/type.ts","../src/create-env.ts","../src/index.ts"],"sourcesContent":["import{type as e}from\"arktype\";const t=e(`string`,`=>`,(e,t)=>{let n=Number.parseInt(e,10);return(!Number.isInteger(n)||!(0<=n&&n<=65535))&&t.mustBe(`an integer between 0 and 65535`),n}),n=e(`string.ip | 'localhost'`),r=e(`'true' | 'false' | true | false`,`=>`,e=>e===`true`||e===!0);export{r as boolean,n as host,t as port};\n//# sourceMappingURL=index.js.map","import{boolean as e,host as t,port as n}from\"@repo/keywords\";import{scope as r,type as i}from\"arktype\";const a=r({string:i.module({...i.keywords.string,host:t}),number:i.module({...i.keywords.number,port:n}),boolean:e});export{a as $};\n//# sourceMappingURL=index.js.map","/**\n * Options for the `indent` function\n */\ntype IndentOptions = {\n\t/**\n\t * Whether to detect newlines and indent each line individually, defaults to false (indenting the whole string)\n\t */\n\tdontDetectNewlines?: boolean;\n};\n\n/**\n * Indent a string by a given amount\n * @param str - The string to indent\n * @param amt - The amount to indent by, defaults to 2\n * @param options - {@link IndentOptions}\n * @returns The indented string\n */\nexport const indent = (\n\tstr: string,\n\tamt = 2,\n\t{ dontDetectNewlines = false }: IndentOptions = {},\n) => {\n\tconst detectNewlines = !dontDetectNewlines;\n\tif (detectNewlines) {\n\t\treturn str\n\t\t\t.split(\"\\n\")\n\t\t\t.map((line) => `${\" \".repeat(amt)}${line}`)\n\t\t\t.join(\"\\n\");\n\t}\n\n\treturn `${\" \".repeat(amt)}${str}`;\n};\n","/**\n * Cross-platform text styling utility\n * Uses ANSI colors in Node environments, plain text in browsers\n * Respects NO_COLOR, CI environment variables, and TTY detection\n */\n\n// ANSI color codes for Node environments\nconst colors = {\n\tred: \"\\x1b[31m\",\n\tyellow: \"\\x1b[33m\",\n\tcyan: \"\\x1b[36m\",\n\treset: \"\\x1b[0m\",\n} as const;\n\n/**\n * Check if we're in a Node environment (not browser)\n * Checked dynamically to allow for testing with mocked globals\n */\nconst isNode = (): boolean =>\n\ttypeof process !== \"undefined\" &&\n\tprocess.versions != null &&\n\tprocess.versions.node != null;\n\n/**\n * Check if colors should be disabled based on environment\n * Respects NO_COLOR, CI environment variables, and TTY detection\n */\nconst shouldDisableColors = (): boolean => {\n\tif (!isNode()) return true;\n\n\t// Respect NO_COLOR environment variable (https://no-color.org/)\n\tif (process.env.NO_COLOR !== undefined) return true;\n\n\t// Disable colors in CI environments by default\n\tif (process.env.CI !== undefined) return true;\n\n\t// Disable colors if not writing to a TTY\n\tif (process.stdout && !process.stdout.isTTY) return true;\n\n\treturn false;\n};\n\n/**\n * Style text with color. Uses ANSI codes in Node, plain text in browsers.\n * @param color - The color to apply\n * @param text - The text to style\n * @returns Styled text in Node (if colors enabled), plain text otherwise\n */\nexport const styleText = (\n\tcolor: \"red\" | \"yellow\" | \"cyan\",\n\ttext: string,\n): string => {\n\t// Use ANSI colors only in Node environments with colors enabled\n\tif (isNode() && !shouldDisableColors()) {\n\t\treturn `${colors[color]}${text}${colors.reset}`;\n\t}\n\t// Fall back to plain text in browsers or when colors are disabled\n\treturn text;\n};\n","import type { ArkErrors } from \"arktype\";\nimport { indent, styleText } from \"./utils\";\n\n/**\n * Format the errors returned by ArkType to be more readable\n * @param errors - The errors returned by ArkType\n * @returns A string of the formatted errors\n */\nexport const formatErrors = (errors: ArkErrors): string =>\n\tObject.entries(errors.byPath)\n\t\t.map(([path, error]) => {\n\t\t\tconst messageWithoutPath = error.message.startsWith(path)\n\t\t\t\t? error.message.slice(path.length)\n\t\t\t\t: error.message;\n\n\t\t\t// Extract the value in parentheses if it exists\n\t\t\tconst valueMatch = messageWithoutPath.match(/\\(was \"([^\"]+)\"\\)/);\n\t\t\tconst formattedMessage = valueMatch\n\t\t\t\t? messageWithoutPath.replace(\n\t\t\t\t\t\t`(was \"${valueMatch[1]}\")`,\n\t\t\t\t\t\t`(was ${styleText(\"cyan\", `\"${valueMatch[1]}\"`)})`,\n\t\t\t\t\t)\n\t\t\t\t: messageWithoutPath;\n\n\t\t\treturn `${styleText(\"yellow\", path)}${formattedMessage}`;\n\t\t})\n\t\t.join(\"\\n\");\n\nexport class ArkEnvError extends Error {\n\tconstructor(\n\t\terrors: ArkErrors,\n\t\tmessage = \"Errors found while validating environment variables\",\n\t) {\n\t\tsuper(`${styleText(\"red\", message)}\\n${indent(formatErrors(errors))}\\n`);\n\t\tthis.name = \"ArkEnvError\";\n\t}\n}\n","import { $ } from \"@repo/scope\";\n\nexport const type = $.type;\n","import { $ } from \"@repo/scope\";\nimport type { EnvSchemaWithType, InferType, SchemaShape } from \"@repo/types\";\nimport type { type as at, distill } from \"arktype\";\nimport { ArkEnvError } from \"./errors\";\nimport { type } from \"./type\";\n\nexport type EnvSchema<def> = at.validate<def, (typeof $)[\"t\"]>;\ntype RuntimeEnvironment = Record<string, string | undefined>;\n\n/**\n * TODO: `SchemaShape` is basically `Record<string, unknown>`.\n * If possible, find a better type than \"const T extends Record<string, unknown>\",\n * and be as close as possible to the type accepted by ArkType's `type`.\n */\n\n/**\n * Create an environment variables object from a schema and an environment\n * @param def - The environment variable schema (raw object or type definition created with `type()`)\n * @param env - The environment variables to validate, defaults to `process.env`\n * @returns The validated environment variable schema\n * @throws An {@link ArkEnvError | error} if the environment variables are invalid.\n */\nexport function createEnv<T extends EnvSchemaWithType>(\n\tdef: T,\n\tenv?: RuntimeEnvironment,\n): InferType<T>;\nexport function createEnv<const T extends SchemaShape>(\n\tdef: EnvSchema<T>,\n\tenv?: RuntimeEnvironment,\n): distill.Out<at.infer<T, (typeof $)[\"t\"]>>;\nexport function createEnv<const T extends SchemaShape>(\n\tdef: EnvSchema<T> | EnvSchemaWithType,\n\tenv?: RuntimeEnvironment,\n): distill.Out<at.infer<T, (typeof $)[\"t\"]>> | InferType<typeof def>;\nexport function createEnv<const T extends SchemaShape>(\n\tdef: EnvSchema<T> | EnvSchemaWithType,\n\tenv: RuntimeEnvironment = process.env,\n): distill.Out<at.infer<T, (typeof $)[\"t\"]>> | InferType<typeof def> {\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 schema =\n\t\ttypeof def === \"function\" && \"assert\" in def\n\t\t\t? def\n\t\t\t: $.type.raw(def as EnvSchema<T>);\n\n\tconst validatedEnv = schema(env);\n\n\tif (validatedEnv instanceof type.errors) {\n\t\tthrow new ArkEnvError(validatedEnv);\n\t}\n\n\treturn validatedEnv;\n}\n","export type { EnvSchema } from \"./create-env\";\n\nimport { createEnv } from \"./create-env\";\n\n/**\n * `arkenv`'s main export, an alias for {@link createEnv}\n *\n * {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables parser powered by {@link https://arktype.io | ArkType}, TypeScript's 1:1 validator.\n */\nconst arkenv = createEnv;\nexport default arkenv;\nexport { type } from \"./type\";\nexport { createEnv };\nexport { ArkEnvError } from \"./errors\";\n"],"mappings":"0CAA+B,MAAM,EAAEA,EAAE,SAAS,MAAM,EAAE,IAAI,CAAC,IAAIC,EAAE,OAAO,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,UAAUA,EAAE,EAAE,EAAE,GAAGA,GAAGA,GAAG,SAASC,EAAE,OAAO,iCAAiC,CAACD,GAAG,CAAC,EAAED,EAAE,0BAA0B,CAAC,EAAEA,EAAE,kCAAkC,KAAK,GAAG,IAAI,QAAQ,IAAI,CAAC,EAAE,CCA9K,EAAEG,EAAE,CAAC,OAAOC,EAAE,OAAO,CAAC,GAAGA,EAAE,SAAS,OAAO,KAAKC,EAAE,CAAC,CAAC,OAAOD,EAAE,OAAO,CAAC,GAAGA,EAAE,SAAS,OAAO,KAAKE,EAAE,CAAC,CAAC,QAAQC,EAAE,CAAC,CCiB9M,GACZ,EACA,EAAM,EACN,CAAE,qBAAqB,IAAyB,EAAE,GAE1B,EAQjB,GAAG,IAAI,OAAO,EAAI,GAAG,IANpB,EACL,MAAM;EAAK,CACX,IAAK,GAAS,GAAG,IAAI,OAAO,EAAI,GAAG,IAAO,CAC1C,KAAK;EAAK,CCpBR,EAAS,CACd,IAAK,WACL,OAAQ,WACR,KAAM,WACN,MAAO,UACP,CAMK,MACL,OAAO,QAAY,KACnB,QAAQ,UAAY,MACpB,QAAQ,SAAS,MAAQ,KAMpB,MAUL,GATI,CAAC,GAAQ,EAGT,QAAQ,IAAI,WAAa,IAAA,IAGzB,QAAQ,IAAI,KAAO,IAAA,IAGnB,QAAQ,QAAU,CAAC,QAAQ,OAAO,OAW1B,GACZ,EACA,IAGI,GAAQ,EAAI,CAAC,GAAqB,CAC9B,GAAG,EAAO,KAAS,IAAO,EAAO,QAGlC,ECjDK,EAAgB,GAC5B,OAAO,QAAQ,EAAO,OAAO,CAC3B,KAAK,CAAC,EAAM,KAAW,CACvB,IAAM,EAAqB,EAAM,QAAQ,WAAW,EAAK,CACtD,EAAM,QAAQ,MAAM,EAAK,OAAO,CAChC,EAAM,QAGH,EAAa,EAAmB,MAAM,oBAAoB,CAC1D,EAAmB,EACtB,EAAmB,QACnB,SAAS,EAAW,GAAG,IACvB,QAAQ,EAAU,OAAQ,IAAI,EAAW,GAAG,GAAG,CAAC,GAChD,CACA,EAEH,MAAO,GAAG,EAAU,SAAU,EAAK,GAAG,KACrC,CACD,KAAK;EAAK,CAEb,IAAa,EAAb,cAAiC,KAAM,CACtC,YACC,EACA,EAAU,sDACT,CACD,MAAM,GAAG,EAAU,MAAO,EAAQ,CAAC,IAAI,EAAO,EAAa,EAAO,CAAC,CAAC,IAAI,CACxE,KAAK,KAAO,gBChCd,MAAa,EAAOC,EAAE,KCgCtB,SAAgB,EACf,EACA,EAA0B,QAAQ,IACkC,CAQpE,IAAM,GAJL,OAAO,GAAQ,YAAc,WAAY,EACtC,EACAC,EAAE,KAAK,IAAI,EAAoB,EAEP,EAAI,CAEhC,GAAI,aAAwB,EAAK,OAChC,MAAM,IAAI,EAAY,EAAa,CAGpC,OAAO,ECzCR,IAAA,EADe"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arkenv",
3
3
  "type": "module",
4
- "version": "0.7.6",
4
+ "version": "0.7.7",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -31,15 +31,18 @@
31
31
  "bugs": "https://github.com/yamcodes/arkenv/labels/arkenv",
32
32
  "author": "Yam Borodetsky <yam@yam.codes>",
33
33
  "devDependencies": {
34
- "@ark/schema": "0.53.0",
35
34
  "@size-limit/esbuild-why": "11.2.0",
36
35
  "@size-limit/preset-small-lib": "11.2.0",
37
36
  "@types/node": "24.10.1",
38
- "arktype": "2.1.26",
37
+ "arktype": "2.1.28",
38
+ "rimraf": "6.1.2",
39
39
  "size-limit": "11.2.0",
40
- "tsdown": "0.16.1",
40
+ "tsdown": "0.16.8",
41
41
  "typescript": "5.9.3",
42
- "vitest": "4.0.9"
42
+ "vitest": "4.0.15",
43
+ "@repo/scope": "0.0.0",
44
+ "@repo/keywords": "0.0.0",
45
+ "@repo/types": "0.0.1"
43
46
  },
44
47
  "peerDependencies": {
45
48
  "arktype": "^2.1.22"
@@ -48,7 +51,10 @@
48
51
  {
49
52
  "path": "dist/index.js",
50
53
  "limit": "2 kB",
51
- "import": "*"
54
+ "import": "*",
55
+ "ignore": [
56
+ "arktype"
57
+ ]
52
58
  }
53
59
  ],
54
60
  "scripts": {