You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/developer-guide/contributing.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -109,6 +109,7 @@ bun run lint:fix
109
109
110
110
- Use `<script setup lang="ts">` for all components
111
111
- Import types from `@/types/utils` — never define local type aliases
112
+
- Import Zod schemas as `z<SchemaName>` from `@/types/zod.gen`, and use `toTypedSchema` from `@/utils/zodAdapter` (not `@vee-validate/zod`, which is Zod v3 only)
112
113
- Stores delegate API calls to services (stores manage state only)
113
114
- Use `loading` (not `isLoading`) for loading state variables
114
115
- Use composables (`usePagination`, `useModalWithData`) for common patterns
If a type isn't exported yet, add it to `utils.ts`.
117
+
If a type isn't re-exported yet, add the name to the `export type { … } from './types.gen'` block in `utils.ts`.
118
+
119
+
### Form Validation
120
+
121
+
Forms use [vee-validate](https://vee-validate.logaretm.com/) with the auto-generated Zod schemas. Each schema is exported individually with a `z` prefix (`zUserBase`, `zAssessmentBase`, …) — there is no `schemas` namespace.
`toTypedSchema` is a small local adapter (`utils/zodAdapter.ts`) that bridges Zod v4 schemas to vee-validate's `TypedSchema` interface — the published `@vee-validate/zod` package only supports Zod v3.
134
+
135
+
Validation runs **only on form submit** (configured globally in `main.ts`). After a failed submit, vee-validate auto-revalidates each field as the user edits it, so errors clear live once they've been surfaced. The default Zod v4 message for missing required fields (`"Invalid input: expected string, received undefined"`) is overridden to `"Required"` via a global `z.config({ customError })` — see `main.ts`.
116
136
117
137
### Composables
118
138
@@ -128,16 +148,23 @@ All components use `<script setup lang="ts">`. UI primitives come from shadcn-vu
128
148
129
149
## Type Generation
130
150
151
+
Frontend types are generated from the backend's OpenAPI schema using [`@hey-api/openapi-ts`](https://heyapi.dev/). Configuration lives in `frontend/openapi-ts.config.ts`.
152
+
131
153
After any backend API change, regenerate the frontend types:
132
154
133
155
```bash
134
156
bun run update:api # Requires backend running on localhost:8000
135
157
```
136
158
137
-
This runs three steps: fetch the OpenAPI schema, generate TypeScript types (`schema.ts`), and generate Zod schemas (`zod.ts`).
159
+
This runs two steps:
160
+
161
+
1.`fetch:openapi` — downloads `openapi.json` from the running backend
162
+
2.`gen:api` — runs `@hey-api/openapi-ts` to produce `src/types/types.gen.ts` (TypeScript types) and `src/types/zod.gen.ts` (Zod schemas)
163
+
164
+
Each script can also be run individually.
138
165
139
166
!!! warning
140
-
Never edit `schema.ts` or `zod.ts` manually — they are overwritten on each generation.
167
+
Never edit `types.gen.ts` or `zod.gen.ts` manually — they are overwritten on each generation. Add re-exports to `utils.ts` instead.
Copy file name to clipboardExpand all lines: docs/docs/developer-guide/index.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,13 +63,13 @@ Stores manage reactive state but **delegate all API calls to services**. Types a
63
63
64
64
### Frontend ↔ Backend Contract
65
65
66
-
The OpenAPI schema is the contract between frontend and backend. After any backend API change:
66
+
The OpenAPI schema is the contract between frontend and backend. Code generation is handled by [`@hey-api/openapi-ts`](https://heyapi.dev/), configured in `frontend/openapi-ts.config.ts`. After any backend API change:
67
67
68
68
```bash
69
69
bun run update:api # Fetches OpenAPI schema and regenerates TypeScript types + Zod schemas (requires running backend service at localhost:8000)
70
70
```
71
71
72
-
This generates `src/types/schema.ts` (TypeScript types) and `src/types/zod.ts` (Zod validation schemas) from the running backend.
72
+
This generates `src/types/types.gen.ts` (TypeScript types) and `src/types/zod.gen.ts` (Zod validation schemas) from the running backend. Forms validate against the generated `z<SchemaName>` exports through a small Zod v4 adapter at `src/utils/zodAdapter.ts`.
0 commit comments