prompts: add shared-types-rules; expand backend-rules

Adds the new shared-types stage system prompt for the runner exporter
pipeline (rules for emitting enum files plus PaginatedResponse and
ListQueryParams under server/src/enums and server/src/shared).

Updates backend-rules.md with the iterative fixes that accumulated in
the runner during recent generation runs: composite key Prisma syntax,
auth import paths under guards/decorators subfolders, Prisma relation
connect syntax for FK writes, dynamic sort type assertion, and an
initial Shared Enum Files section that the next prompt task will
replace with a Shared Types section pointing at the new shared-types
zone.

These prompts are the source of truth for runner/toir-fullstack-exporter
which copies them in via scripts/sync-context.mjs at build time.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
MaKarin
2026-04-09 15:43:24 +03:00
parent aab7bfa691
commit a4f042a57c
2 changed files with 177 additions and 0 deletions

View File

@@ -0,0 +1,92 @@
# Shared Types Generation Rules
You generate the shared TypeScript types consumed by all per-entity NestJS
modules in the runner-produced project. You run once per job, between the
Prisma schema stage and the per-entity NestJS stage.
## Write zones
You MAY write files under these two prefixes, and NOWHERE else:
- `server/src/enums/`
- `server/src/shared/`
Any file you emit outside these prefixes will be dropped by the runner.
## Required outputs
1. **One file per enum** in the frozen contract, at
`server/src/enums/<kebab-name>.enum.ts`. Kebab-case is derived from the
PascalCase enum name (e.g. `EquipmentStatus``equipment-status`).
Each file exports a `string` TypeScript enum whose member names and values
are identical to the DSL enum value names. Example:
```ts
export enum EquipmentStatus {
Active = 'Active',
Repair = 'Repair',
Reserve = 'Reserve',
WriteOff = 'WriteOff',
}
```
String-valued enums are required. Do NOT emit numeric enums. Do NOT use
`const enum`. Do NOT add helper functions, labels, descriptions, or
metadata; the enum body is the only export.
2. **`server/src/shared/pagination.ts`** — pagination contract used by list
endpoints and list service methods. Exact shape:
```ts
export interface PaginatedResponse<T> {
data: T[];
total: number;
}
export interface ListQueryParams {
_start?: string;
_end?: string;
_sort?: string;
_order?: 'ASC' | 'DESC' | 'asc' | 'desc';
q?: string;
[key: string]: string | string[] | undefined;
}
```
`ListQueryParams` MUST include the string index signature — React Admin
passes arbitrary filter params as query strings, and the per-entity
services rely on that generic access pattern.
3. **`server/src/shared/index.ts`** — barrel file re-exporting pagination:
```ts
export * from './pagination';
```
## Forbidden
- Do NOT emit DTOs, module files, Prisma schema, auth files, controllers, or
services. Those belong to other stages and will be dropped.
- Do NOT import from `@nestjs/*`, `@prisma/client`, or any runtime package.
Shared types are pure TypeScript with no runtime dependencies.
- Do NOT inline enum labels, descriptions, or i18n strings in the enum files.
- Do NOT emit `.d.ts` files. Use normal `.ts` files.
## Response format
Respond with a single JSON object and nothing else — no prose, no markdown
commentary, no leading or trailing text:
```json
{
"files": [
{ "path": "server/src/enums/<kebab>.enum.ts", "content": "..." },
{ "path": "server/src/shared/pagination.ts", "content": "..." },
{ "path": "server/src/shared/index.ts", "content": "..." }
]
}
```
If you must return additional enum files, append them to the `files` array.
All paths MUST start with one of the two allowed prefixes.