5.7 KiB
5.7 KiB
Frontend Rules
Use this document during the E. Parallel Specialized Generation stage
defined in prompts/general-prompt.md.
Purpose
Generate React Admin resources that stay aligned with the DSL contract, the backend contract, and the repository auth/data provider seams.
Ownership rule:
- this stage belongs to
generator_react_admin_resourcesafter contract freeze - parent retains ownership of shared auth strategy, global data-access architecture, runtime, and deploy seams
- resource generation must stay compatible with the frozen data-access and auth contracts rather than redesigning them
Mandatory Inputs
prompts/general-prompt.md- the active
api API.<Entity>block fromdomain/toir.api.dsl - referenced DTOs and enums from
domain/toir.api.dsl - an intact or repaired official Vite React TypeScript scaffold under
client/
Expected Outputs
Per entity:
client/src/resources/<kebab>/<Entity>List.tsxclient/src/resources/<kebab>/<Entity>Create.tsxclient/src/resources/<kebab>/<Entity>Edit.tsxclient/src/resources/<kebab>/<Entity>Show.tsx
Repository-wide:
client/src/App.tsxresource registrations
Scaffold Baseline
- Start frontend initialization and repair from the official Vite React TypeScript scaffold, not from a hand-written shell.
- Preserve workspace essentials:
client/index.htmlclient/tsconfig.jsonclient/vite.config.*client/src/main.tsxclient/src/vite-env.d.ts
- Repair the scaffold before generating resources if it is degraded.
- Do not delete
client/src/vite-env.d.ts. The official Vite React TypeScript scaffold creates it, and its absence means the scaffold was not preserved or was later overwritten.
Approved Frontend Dependency Baseline
When the frontend workspace is created or repaired, pin the frontend package manifest to these exact versions before continuing:
react:19.2.4react-dom:19.2.4react-admin:5.14.5ra-data-simple-rest:5.14.5@mui/material:7.3.9@mui/icons-material:7.3.9@emotion/react:11.14.0@emotion/styled:11.14.1vite:8.0.3@vitejs/plugin-react:6.0.1- frontend
typescript:5.9.3 keycloak-js:26.2.3
Pinning rules:
- Use exact versions, not
latestand not caret ranges. - Keep
reactandreact-domon the same exact version. - Keep
react-adminandra-data-simple-reston the same exact version line. - Keep
@mui/materialand@mui/icons-materialon the same exact version.
Resource Contract
- Use the shared entity-to-resource naming convention from
prompts/general-prompt.md. - Every entity becomes a React Admin resource with
list,create,edit, andshow. Resourceregistration inclient/src/App.tsxmust includeshow={...}.- Every frontend record must work with React Admin's
idcontract, including natural-key entities.
DTO-driven view rules:
- List and Show views use fields from
DTO.<Entity> - Create view uses fields from
DTO.<Entity>Create - Edit view uses fields from
DTO.<Entity>Update - Do not derive form fields directly from model attributes when the DTO contract is narrower
Input And Field Mapping
Form inputs:
integer,number,decimal->NumberInputdate->DateInput- required
boolean->BooleanInput - nullable
boolean->NullableBooleanInput - enum ->
SelectInput - FK reference ->
ReferenceInput+AutocompleteInput
Display fields:
integer,number,decimal->NumberFielddate->DateFieldboolean->BooleanField- enum ->
SelectField - FK reference ->
ReferenceField
Hard failure rule:
- using plain
TextInputforinteger,number,decimal,date, orbooleanis a generation failure
Filter And Reference Contract
- Lists must expose filters and include a toolbar with
FilterButton. - Enum multi-select filters use
SelectArrayInput. - Reference filters and form selectors use
ReferenceInput+AutocompleteInputwithfilterToQuery={(searchText) => ({ q: searchText })}. - FK list/show rendering must use
ReferenceField link=\"show\". dataProviderquery serialization must preserve repeated params for array filters.
Reference display expression priority:
- if
inventoryNumberexists:(record) => `${record.inventoryNumber} — ${record.name ?? record.inventoryNumber} - else if
codeexists:(record) => `${record.code} — ${record.name ?? record.code} - else if
numberexists:(record) => `${record.number} — ${record.name ?? record.number} - else if
nameexists:(record) => record.name ?? record.id - else:
(record) => record.id
Auth And Provider Seams
client/src/dataProvider.tsremains the single authenticated request seam.client/src/auth/authProvider.tsremains the single React Admin auth seam.- Resource components must not embed auth logic.
getIdentity()resolves from token claims.getPermissions()may expose realm roles for UI awareness, but backend enforcement stays authoritative.
Natural-Key Compatibility
- Frontend requests and routes must continue to work when the real primary key is not named
id. - Edit/show/delete flows must preserve compatibility with backend natural-key handling.
- Sorting and filtering assumptions must not regress to a fake physical
id.
Completion Expectations
Frontend generation is incomplete if any of the following is true:
- required Vite scaffold files are missing
- Create/Edit inputs are type-incorrect
- filter UI is missing or incomplete
- reference fields stop linking to
show - resource registration omits
show={...}