Skip to main content
Sonamu automatically generates TypeScript types, Zod schemas, API clients, React components, and more from Entity definitions. This document describes the types and purposes of all generated files.

Generated Files Overview

Types & Schemas

TypeScript types and Zod schemas *.types.ts, sonamu.generated.ts

API Clients

HTTP client functions services.generated.ts

Query Helpers

Subset query functions sonamu.generated.sso.ts

React Components

Form, List, Select components view_*.tsx

Core Generated Files

1. Entity Types ({entity}.types.ts)

TypeScript types and Zod schemas are generated per Entity.
api/src/application/user/user.types.ts (auto-generated)
Generated when: Entity save or pnpm sonamu sync Editable: ❌ Auto-regenerated (custom types in separate file)

2. Generated Base (sonamu.generated.ts)

Base types and Enums for the entire project.
api/src/application/sonamu.generated.ts (auto-generated)
Generated when: Entity save or pnpm sonamu sync Editable: ❌ Auto-regenerated

3. Subset Queries (sonamu.generated.sso.ts)

Query functions per Subset.
api/src/application/sonamu.generated.sso.ts (auto-generated)
Generated when: Entity Subset changes Editable: ❌ Auto-regenerated

4. API Services (services.generated.ts)

API client functions.
web/src/services/services.generated.ts (auto-generated)
Generated when: Model’s @api decorator changes Editable: ❌ Auto-regenerated
Target-specific generation: Copied to each target specified in sync.targets in sonamu.config.ts (web, app, etc.).

5. HTTP Test File (sonamu.generated.http)

HTTP test file for REST Client.
api/sonamu.generated.http (auto-generated)
Generated when: Model file changes Editable: ❌ Auto-regenerated Usage: Install VS Code’s REST Client extension and execute requests

React Components

React UI components can be generated via Scaffold.

6. List Component

Generated when: pnpm sonamu generate view_list --entity User Editable: ✅ Editable after initial generation

7. Form Component

web/src/pages/user/UserForm.tsx
Generated when: pnpm sonamu generate view_form --entity User Editable: ✅ Editable after initial generation

8. Select Components

Files for Server-Side Rendering are auto-generated.

9. Queries (queries.generated.ts)

For APIs with the tanstack-query client enabled, this file exports SSR-side descriptors (SSRQuery) grouped by model namespace. The api-side ssr/routes.ts uses these descriptors via registerSSR(...) to compose preload configs.
api/src/application/queries.generated.ts (auto-generated)
Generated when: Model file changes Editable: ❌ Auto-regenerated Location: An api-only asset. It is not copied into target (web/app) and is never imported directly from target code. The SSR renderer executes the descriptor server-side and only the result is hydrated on the client.

10. Entry Server (entry-server.generated.tsx)

TanStack Router-based SSR entry point. It exports a render(url, preloadedData) function called by the web side, not a per-route loader. Data prefetched during SSR (preloadedData) is injected via queryClient.setQueryData(queryKey, data), then dehydrated for client hydration.
web/src/entry-server.generated.tsx (auto-generated)
Generated when: Once on first sync (static bootstrap asset, does not depend on inputs) Editable: ❌ Auto-regenerated

Internationalization Files

Generated when i18n configuration exists.

11. Sonamu Dictionary (sd.generated.ts)

api/src/sd.generated.ts (auto-generated)
Generated when: Entity or i18n file changes Editable: ❌ Auto-regenerated Targets: Generated for api, web, app each

Generated Files Summary Table

Auto-regenerated files: Never modify *.generated.* files. Changes will be automatically overwritten.

Next Steps

Syncer

Understanding the core Syncer system

When Files Regenerate

Learn when files are regenerated

Customizing Generated Code

How to customize generated code

Creating Entities

Define Entities and generate files