From 6fa525812c3d89fec29c6cb23134302bb49de2ec Mon Sep 17 00:00:00 2001 From: Eunjae Lee Date: Tue, 6 Jan 2026 19:02:55 +0100 Subject: [PATCH] docs: add DTO location and naming conventions to knowledge base (#26478) * docs: add DTO location and naming conventions to knowledge base Co-Authored-By: eunjae@cal.com * docs: clarify DTO location rules for new features vs refactored code Co-Authored-By: eunjae@cal.com * docs: simplify DTO location - all DTOs go in packages/lib/dto/ Co-Authored-By: eunjae@cal.com --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- agents/knowledge-base.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/agents/knowledge-base.md b/agents/knowledge-base.md index af6abfc2a2..13bfe08e7c 100644 --- a/agents/knowledge-base.md +++ b/agents/knowledge-base.md @@ -420,6 +420,28 @@ export interface BookingDTO { } ``` +### DTO Location and Naming + +**Location**: All DTOs go in `packages/lib/dto/` + +**Naming conventions**: +- Base entity: `{Entity}Dto` (e.g., `BookingDto`) +- With relations: `{Entity}With{Relations}Dto` (e.g., `BookingWithAttendeesDto`) +- For specific projections: `{Entity}For{Purpose}Dto` (e.g., `BookingForConfirmationDto`) +- Avoid: `{Entity}Dto2`, `{Entity}DtoForHandler`, or other use-case-specific names + +**Enum/union pattern** – use string literal unions to stay ORM-agnostic: + +```typescript +// ✅ Good - ORM-agnostic string literal union +export type BookingStatusDto = "CANCELLED" | "ACCEPTED" | "REJECTED" | "PENDING"; + +// ❌ Bad - importing Prisma enum +import { BookingStatus } from "@calcom/prisma/client"; +``` + +**Type safety** – never use `as any` in DTO mapping functions. If types don't align, fix the mapping explicitly. + ### Prisma boundaries - **Allowed**: `packages/prisma`, repository implementations (`packages/features/**/repositories/*Repository.ts`), and low-level data access infrastructure.