Skip to content

Commit f380179

Browse files
yamcodescursoragentautofix-ci[bot]
authored
feat: Document ArkEnv keywords (#1413)
Fixes #1406 ## Summary - Add `/docs/arkenv/keywords` documenting ArkEnv-only `string.host` and `number.port` with `TypeTable` catalogs - Reorder API nav to Keywords → Options → Coercion → arkenv/standard - Wire `TypeTable` into the www MDX component map and cross-link from landing, quickstart, standard, coercion, and reuse-schemas ## Test plan - [ ] Visit `/docs/arkenv/keywords` and confirm API nav order - [ ] Confirm TypeTable catalogs expand and show equivalents - [ ] Check cross-links from landing, quickstart, and arkenv/standard footnote Made with [Cursor](https://cursor.com) --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 1537a01 commit f380179

8 files changed

Lines changed: 87 additions & 8 deletions

File tree

apps/www/content/docs/arkenv/coercion.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Coercion in [arkenv/standard](/docs/arkenv/standard) only works with:
1717

1818
## Numbers
1919

20-
Any field defined as a `number` or a numeric subtype (like `number.integer` or `number.port`) will be automatically parsed.
20+
Any field defined as a `number` or a numeric subtype (like `number.integer` or [`number.port`](/docs/arkenv/keywords#number)) will be automatically parsed.
2121

2222
```ts twoslash
2323
import arkenv from "arkenv";

apps/www/content/docs/arkenv/how-to/reuse-schemas.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: How to reuse your schema
33
description: Define your schema once and reuse it across your application.
44
---
55

6-
ArkEnv supports both raw schema objects and type definitions created with ArkType's `type()` function. Use type definitions when you need to validate the same environment variables in multiple places.
6+
ArkEnv supports both raw schema objects and type definitions created with ArkType's `type()` function - including ArkEnv [Keywords](/docs/arkenv/keywords) like `string.host` and `number.port`. Use type definitions when you need to validate the same environment variables in multiple places.
77

88
Recall that with ArkEnv, defining your schema is done at the same time as you parse the environment variables:
99

apps/www/content/docs/arkenv/index.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ At its core, ArkEnv is a single export that creates a ready-to-use, typesafe env
1010
import arkenv from "arkenv";
1111

1212
const env = arkenv({
13-
HOST: "string.ip | 'localhost'",
14-
PORT: "0 <= number.integer <= 65535",
13+
HOST: "string.host",
14+
PORT: "number.port",
1515
NODE_ENV: "'development' | 'production' | 'test' = 'development'",
1616
DEBUGGING: "boolean = false",
1717
});
@@ -26,7 +26,7 @@ const debugging = env.
2626
// ^|
2727
```
2828

29-
> ArkEnv defaults to [ArkType](https://arktype.io/) notation, the closest match to TypeScript syntax for editor-to-runtime typesafety. You can also use any [Standard Schema](https://standardschema.dev/schema) validator, including Zod, Valibot, and Typia.
29+
> ArkEnv defaults to [ArkType](https://arktype.io/) notation, the closest match to TypeScript syntax for editor-to-runtime typesafety. Keywords like `string.host` and `number.port` are [ArkEnv additions](/docs/arkenv/keywords) - you can also use any [Standard Schema](https://standardschema.dev/schema) validator, including Zod, Valibot, and Typia.
3030
3131
We consider the resulting `env` object "typesafe from editor to runtime": at every step in the app's lifecycle, you are getting a guarantee about your environment variables.
3232

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: Keywords
3+
description: ArkEnv keywords that extend ArkType for common environment-variable shapes.
4+
---
5+
6+
<Callout title="Only works with ArkType">
7+
This feature is only available with ArkEnv + ArkType and is *not* a part of [arkenv/standard](/docs/arkenv/standard).
8+
</Callout>
9+
10+
ArkEnv adds a small set of env-oriented keywords on top of [ArkType's keyword set](https://arktype.io/docs/primitives). You can reference them in any ArkEnv schema or `type` definition.
11+
12+
## string
13+
14+
### keywords
15+
16+
The following aliases can be referenced in any definition, e.g.:
17+
18+
<Tabs items={['arkenv', 'type']}>
19+
<Tab value="arkenv">
20+
```ts twoslash
21+
import arkenv from "arkenv";
22+
23+
// Hover to see the inferred type
24+
const env = arkenv({
25+
HOST: "string.host",
26+
});
27+
```
28+
</Tab>
29+
30+
<Tab value="type">
31+
```ts twoslash
32+
import { type } from "arkenv";
33+
34+
const Host = type("string.host");
35+
36+
// Hover to see the inferred type
37+
type Host = typeof Host.infer;
38+
```
39+
</Tab>
40+
</Tabs>
41+
42+
<TypeTable expandAll type={{ "string.host": { type: "string.ip | 'localhost'", description: 'An IP address (string.ip) or "localhost".' } }} />
43+
44+
## number
45+
46+
### keywords
47+
48+
The following aliases can be referenced in any definition, e.g.:
49+
50+
<Tabs items={['arkenv', 'type']}>
51+
<Tab value="arkenv">
52+
```ts twoslash
53+
import arkenv from "arkenv";
54+
55+
// Hover to see the inferred type
56+
const env = arkenv({
57+
PORT: "number.port",
58+
});
59+
```
60+
</Tab>
61+
62+
<Tab value="type">
63+
```ts twoslash
64+
import { type } from "arkenv";
65+
66+
const Port = type("number.port");
67+
68+
// Hover to see the inferred type
69+
type Port = typeof Port.infer;
70+
```
71+
</Tab>
72+
</Tabs>
73+
74+
<TypeTable expandAll type={{ "number.port": { type: "0 <= number.integer <= 65535", description: "An integer port in the range 0–65535." } }} />

apps/www/content/docs/arkenv/meta.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
"---Integrations---",
1414
"...integrations",
1515
"---API---",
16-
"[arkenv/standard](/docs/arkenv/standard)",
17-
"coercion",
16+
"keywords",
1817
"options",
18+
"coercion",
19+
"[arkenv/standard](/docs/arkenv/standard)",
1920
"---How-to---",
2021
"[Load environment variables](/docs/arkenv/how-to/load-environment-variables)",
2122
"[Reuse your schema](/docs/arkenv/how-to/reuse-schemas)",

apps/www/content/docs/arkenv/quickstart.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ npx @arkenv/cli@latest init
7575

7676
Your `env.ts` file is where the ✨magic✨ happens – variables referenced from this object are guaranteed to match the schema defined here.
7777

78+
ArkEnv extends ArkType with env-oriented [Keywords](/docs/arkenv/keywords) such as `string.host` and `number.port`:
79+
7880
```ts title="env.ts" twoslash
7981
import arkenv, { type } from 'arkenv';
8082

apps/www/content/docs/arkenv/standard.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Already using ArkType? You can still use Zod, Valibot, and other Standard Schema
2020
| **Standard Schema** |||
2121
| **Works without ArkType** |||
2222

23-
¹ ArkEnv extends ArkType with custom keywords like `string.host` and `number.port`
23+
¹ ArkEnv extends ArkType with custom keywords like `string.host` and `number.port` - see [Keywords](/docs/arkenv/keywords)
2424

2525
² Only works with Standard JSON Schema validators like Zod 4, Zod Mini and Valibot - see [Coercion](/docs/arkenv/coercion)
2626

apps/www/mdx-components.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { TypeTable } from "@arkenv/fumadocs-ui/components";
12
import { arkenvComponents } from "@arkenv/fumadocs-ui/mdx";
23
import * as twoslashComponents from "fumadocs-twoslash/ui";
34
import {
@@ -25,6 +26,7 @@ export function getMDXComponents(components: MDXComponents): MDXComponents {
2526
CalloutTitle,
2627
Card,
2728
AutoTypeTable,
29+
TypeTable,
2830
Cards,
2931
Files,
3032
Folder,

0 commit comments

Comments
 (0)