Skip to content

Commit 34bf4d9

Browse files
committed
docs(references): regenerate for field-value.zod.ts (gen:docs check)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SHpGw3GBA9aFpfwVArRWfd
1 parent 235de83 commit 34bf4d9

3 files changed

Lines changed: 145 additions & 1 deletion

File tree

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
---
2+
title: Field Value
3+
description: Field Value protocol schemas
4+
---
5+
6+
{/* ⚠️ AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs live in the module folders under content/docs/. */}
7+
8+
Field runtime VALUE-shape contract (ADR-0104 D1).
9+
10+
`FieldSchema` owns what a field *definition* looks like; this module owns
11+
12+
what a field's runtime *value* looks like — the shape the write path
13+
14+
accepts, drivers persist, and an unexpanded API read returns. Before this
15+
16+
module the knowledge lived as private, hand-copied type sets in objectql's
17+
18+
record-validator, rest's import-coerce, driver-sql, and verify; adding one
19+
20+
multi-capable or JSON-shaped type meant updating four lists or silently
21+
22+
corrupting data. Those consumers now derive from the classes below.
23+
24+
Two canonical forms exist per field (ADR-0104 D1):
25+
26+
- `stored` — the storage/wire form (e.g. lookup ⇒ record-id string,
27+
28+
`date``YYYY-MM-DD`, select ⇒ option code).
29+
30+
- `expanded` — the enriched `$expand` read form (lookup ⇒ the related
31+
32+
record object). For types without an expansion,
33+
34+
expanded ≡ stored.
35+
36+
"Reality wins": where the deployed stored shape is coherent, the contract
37+
38+
adopts it — deployed data is a wire contract we don't get to rewrite by
39+
40+
editing Zod. This is why `currency` is a bare number (not the never-consumed
41+
42+
`CurrencyValueSchema` object) and `location` is `\{lat, lng\}` (what field-zoo
43+
44+
stores), not the never-consumed `\{latitude, longitude\}` shape.
45+
46+
Purity: schemas/constants/derivation only — no runtime logic, no caching
47+
48+
(Prime Directive #2). Consumers cache `valueSchemaFor` results per field
49+
50+
definition; building a Zod schema per write is the one performance trap
51+
52+
this contract has (ADR-0104 performance budget).
53+
54+
<Callout type="info">
55+
**Source:** `packages/spec/src/data/field-value.zod.ts`
56+
</Callout>
57+
58+
## TypeScript Usage
59+
60+
```typescript
61+
import { AddressValue, CalendarDateValue, ClockTimeValue, FileLikeValue, InstantValue, LocationValue, ReferenceIdValue } from '@objectstack/spec/data';
62+
import type { AddressValue, CalendarDateValue, ClockTimeValue, FileLikeValue, InstantValue, LocationValue, ReferenceIdValue } from '@objectstack/spec/data';
63+
64+
// Validate data
65+
const result = AddressValue.parse(data);
66+
```
67+
68+
---
69+
70+
## AddressValue
71+
72+
### Properties
73+
74+
| Property | Type | Required | Description |
75+
| :--- | :--- | :--- | :--- |
76+
| **street** | `string` | optional | Street address |
77+
| **city** | `string` | optional | City name |
78+
| **state** | `string` | optional | State/Province |
79+
| **postalCode** | `string` | optional | Postal/ZIP code |
80+
| **country** | `string` | optional | Country name or code |
81+
| **countryCode** | `string` | optional | ISO country code (e.g., US, GB) |
82+
| **formatted** | `string` | optional | Formatted address string |
83+
84+
85+
---
86+
87+
88+
---
89+
90+
91+
---
92+
93+
## FileLikeValue
94+
95+
### Union Options
96+
97+
This schema accepts one of the following structures:
98+
99+
#### Option 1
100+
101+
Type: `string`
102+
103+
---
104+
105+
#### Option 2
106+
107+
### Properties
108+
109+
| Property | Type | Required | Description |
110+
| :--- | :--- | :--- | :--- |
111+
| **url** | `string` | optional | |
112+
| **name** | `string` | optional | |
113+
| **size** | `number` | optional | |
114+
| **alt** | `string` | optional | |
115+
| **duration** | `number` | optional | |
116+
117+
---
118+
119+
120+
---
121+
122+
123+
---
124+
125+
## LocationValue
126+
127+
### Properties
128+
129+
| Property | Type | Required | Description |
130+
| :--- | :--- | :--- | :--- |
131+
| **lat** | `number` || Latitude |
132+
| **lng** | `number` || Longitude |
133+
| **altitude** | `number` | optional | Altitude in meters |
134+
| **accuracy** | `number` | optional | Accuracy in meters |
135+
136+
137+
---
138+
139+
140+
---
141+

content/docs/references/data/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This section contains all protocol schemas for the data layer of ObjectStack.
1818
<Card href="/docs/references/data/external-lookup" title="External Lookup" description="Source: packages/spec/src/data/external-lookup.zod.ts" />
1919
<Card href="/docs/references/data/feed" title="Feed" description="Source: packages/spec/src/data/feed.zod.ts" />
2020
<Card href="/docs/references/data/field" title="Field" description="Source: packages/spec/src/data/field.zod.ts" />
21+
<Card href="/docs/references/data/field-value" title="Field Value" description="Source: packages/spec/src/data/field-value.zod.ts" />
2122
<Card href="/docs/references/data/filter" title="Filter" description="Source: packages/spec/src/data/filter.zod.ts" />
2223
<Card href="/docs/references/data/hook" title="Hook" description="Source: packages/spec/src/data/hook.zod.ts" />
2324
<Card href="/docs/references/data/hook-body" title="Hook Body" description="Source: packages/spec/src/data/hook-body.zod.ts" />

content/docs/references/data/meta.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
"document",
2626
"feed",
2727
"seed",
28-
"seed-loader"
28+
"seed-loader",
29+
"---More---",
30+
"field-value"
2931
]
3032
}

0 commit comments

Comments
 (0)