690328:1106 Fixing Refactor uuid by Kimi #01
This commit is contained in:
+30
-6
@@ -1,7 +1,7 @@
|
||||
# NAP-DMS Project Context & Rules
|
||||
- For: Windsurf Cascade (and compatible: Codex CLI, opencode, Amp, Amazon Q, AGENTS.md tools)
|
||||
- Version: 1.8.5 (Refactored) | Last synced from repo: 2026-03-27
|
||||
- Repo: [https://git.np-dms.work/np-dms/lcbp3](https://git.np-dms.work/np-dms/lcbp3)
|
||||
- Version: 1.8.5 (Refactored) | Last synced from repo: 2026-03-27
|
||||
- Repo: [https://git.np-dms.work/np-dms/lcbp3](https://git.np-dms.work/np-dms/lcbp3)
|
||||
|
||||
---
|
||||
|
||||
@@ -84,8 +84,29 @@ Spec priority: **`06-Decision-Records`** > **`05-Engineering-Guidelines`** > oth
|
||||
| ---------------- | ------------------------- | ------------------------------------------- |
|
||||
| Internal / DB FK | `INT AUTO_INCREMENT` | Never exposed in API |
|
||||
| Public API / URL | `UUIDv7` (MariaDB native) | Stored as BINARY(16), no transformer needed |
|
||||
| Entity Property | `publicId: string` | Exposed via `@Expose({ name: 'id' })` |
|
||||
| API Response | `id: string` (UUID) | INT `id` has `@Exclude()` — never appears |
|
||||
| Entity Property | `publicId: string` | Exposed directly in API (no transformation) |
|
||||
| API Response | `publicId: string` (UUID) | INT `id` has `@Exclude()` — never appears |
|
||||
|
||||
### ✅ Updated Pattern (March 2026)
|
||||
|
||||
**Backend:** `UuidBaseEntity` exposes `publicId` directly — no `@Expose({ name: 'id' })` transformation
|
||||
|
||||
**Frontend:** Use `publicId` only — no `uuid` or `id` fallbacks:
|
||||
|
||||
```typescript
|
||||
// ✅ CORRECT — Use publicId only
|
||||
type ProjectOption = {
|
||||
publicId?: string; // No uuid, no id fallback
|
||||
projectName?: string;
|
||||
};
|
||||
|
||||
// ❌ WRONG — Multiple identifiers cause confusion
|
||||
type ProjectOption = {
|
||||
publicId?: string;
|
||||
uuid?: string; // Don't do this
|
||||
id?: number; // Don't do this
|
||||
};
|
||||
```
|
||||
|
||||
### ❌ Forbidden UUID Patterns
|
||||
|
||||
@@ -93,8 +114,11 @@ Spec priority: **`06-Decision-Records`** > **`05-Engineering-Guidelines`** > oth
|
||||
// ❌ NEVER use parseInt on UUID
|
||||
parseInt(projectId); // "0195..." → 19 (WRONG!)
|
||||
|
||||
// ✅ CORRECT — Use UUID string directly
|
||||
const id = projectId; // "019505a1-7c3e-7000-8000-abc123def456"
|
||||
// ❌ NEVER use id ?? '' fallback
|
||||
const value = c.publicId ?? c.id ?? ''; // Wrong!
|
||||
|
||||
// ✅ CORRECT — Use publicId only
|
||||
const value = c.publicId; // "019505a1-7c3e-7000-8000-abc123def456"
|
||||
```
|
||||
|
||||
Read `specs/05-Engineering-Guidelines/05-07-hybrid-uuid-implementation-plan.md` before any UUID-related work.
|
||||
|
||||
Reference in New Issue
Block a user