Basic Principles
Generated Files are Read-Only
Never modify
*.generated.* files Changes lost on auto-regenerationCustomize Through Extension
Wrap or extend in separate files Safe and maintainable
Control at Source
Adjust in Entity, Model, Types Preserved across regenerations
Leverage Templates
Control generation with custom templates Reflect project requirements
Modifiable vs Non-Modifiable Files
❌ Non-Modifiable Files
Never modify these files. They are overwritten on regeneration.| File Pattern | Regeneration Trigger | Example |
|---|---|---|
*.generated.ts | Entity/Model changes | sonamu.generated.ts |
*.generated.sso.ts | Entity changes | sonamu.generated.sso.ts |
*.generated.tsx | Model changes | entry-server.generated.tsx |
*.generated.http | Model changes | sonamu.generated.http |
services.generated.ts | Model changes | services.generated.ts |
queries.generated.ts | Model changes | queries.generated.ts |
sd.generated.ts | Entity/i18n changes | sd.generated.ts |
✅ Modifiable Files
These files can be modified after initial generation.| File Pattern | Regeneration | Example |
|---|---|---|
{entity}.types.ts | Not after first creation | user.types.ts |
{entity}.model.ts | Not after scaffold | user.model.ts |
{Entity}List.tsx | Not after scaffold | UserList.tsx |
{Entity}Form.tsx | Not after scaffold | UserForm.tsx |
| Custom files | Never regenerated | user.custom.ts |
Customizing API Clients
Don’t modifyservices.generated.ts directly—wrap it instead.
❌ Wrong Approach
services.generated.ts
✅ Correct Approach 1: Wrapper Functions
- No modification to generated files
- Reuses original functions
- Maintains type safety
✅ Correct Approach 2: Axios Interceptor
services/axios-config.ts (create new)
- Automatically applies to all APIs
- Eliminates duplicate code
- Centralized configuration
✅ Correct Approach 3: TanStack Query Customization
hooks/useUserQuery.ts (create new)
- Centralized management of common options
- Per-component customization possible
- Leverages TanStack Query features
Customizing Types
{entity}.types.ts is not regenerated, so you can modify it freely.
Adding Custom Types
api/src/application/user/user.types.ts
{entity}.types.ts is copied to targets, so changes are automatically synchronized.
Enhanced Validation
user.types.ts
Customizing Models
Model files can be freely modified after scaffolding.Adding Methods
api/src/application/user/user.model.ts
login(),me()functions added toservices.generated.ts- Test cases added to
sonamu.generated.http
Separating Helper Methods
api/src/application/user/user.helpers.ts (create new)
Usage in user.model.ts
Customizing React Components
Components generated via scaffold can be freely modified.Customizing Form Components
web/src/pages/user/UserForm.tsx
Customizing List Components
web/src/pages/user/UserList.tsx
Customizing Enums
To add or modify enums, adjust them in the Entity.Modifying Enums in Entity
Extending Enums (Separate File)
user.types.ts
Customizing Subsets
To modify subsets, adjust them in the Entity.Adding/Removing Subset Fields
Next Steps
When Files Regenerate
Understand file regeneration timing
Syncer
Deep dive into the Syncer system
Templates
Create custom templates
Testing
Test your customized code