- lib/idea-code.ts: pure formatIdeaCode helper (client-safe, no prisma) - lib/idea-code-server.ts: atomic nextIdeaCode via Prisma row-lock, accepts optional TransactionClient for combining with idea.create - lib/idea-plan-parser.ts: parsePlanMd extracts ---yaml---/body, runs yaml.parse + ideaPlanMdFrontmatterSchema, returns line-info on failure; CRLF-tolerant - adds yaml@^2.8.4 dependency - 8 unit tests (parser happy/missing/yaml-error/zod-error/empty-stories/CRLF; formatIdeaCode pad-3 + overflow) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
8 lines
318 B
TypeScript
8 lines
318 B
TypeScript
// Pure helpers voor IDEA-codes. Geen DB-imports — daarom client-safe.
|
|
// De DB-mutating nextIdeaCode staat in lib/idea-code-server.ts.
|
|
|
|
const PAD = 3 // "IDEA-001". Bumps to 4 digits at counter 1000 organically.
|
|
|
|
export function formatIdeaCode(n: number): string {
|
|
return `IDEA-${String(n).padStart(PAD, '0')}`
|
|
}
|