- lib/schemas/product-doc.ts: PRODUCT_DOC_FOLDERS/STATUSES + create/update/ toggle/frontmatter schemas (MAX_PRODUCT_DOC_CONTENT_LEN=100k) - lib/product-doc-folder.ts: DB UPPER_SNAKE ↔ API lowercase mapper (spiegel van lib/task-status.ts) - lib/product-doc-slug.ts: pure slugify + suggestSlug (dedupe-suffix) + ADR-sequence helpers (nextAdrPrefix, parseAdrNumber, suggestAdrSlug) - lib/schemas/product-doc-frontmatter-defaults.ts: per-folder UI-templates voor "Nieuwe doc"-dialog (last_updated weggelaten — server normaliseert bij save, zie T-1060) - __tests__: 37 tests groen (Zod-schemas + slug-helpers); de pre-existing worktree-env fail in idea-timeline-merge.test.ts blijft buiten scope Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
// Bidirectionele case-mapper voor de REST API-boundary van ProductDocFolder.
|
|
// DB houdt UPPER_SNAKE; API exposeert lowercase. Spiegel van lib/task-status.ts.
|
|
|
|
import type { ProductDocFolder } from '@prisma/client'
|
|
|
|
import {
|
|
PRODUCT_DOC_FOLDERS,
|
|
type ProductDocFolderApi,
|
|
} from '@/lib/schemas/product-doc'
|
|
|
|
const FOLDER_DB_TO_API = {
|
|
ADR: 'adr',
|
|
ARCHITECTURE: 'architecture',
|
|
PATTERNS: 'patterns',
|
|
PLANS: 'plans',
|
|
RUNBOOKS: 'runbooks',
|
|
SPECS: 'specs',
|
|
MANUAL: 'manual',
|
|
API: 'api',
|
|
} as const satisfies Record<ProductDocFolder, ProductDocFolderApi>
|
|
|
|
const FOLDER_API_TO_DB: Record<string, ProductDocFolder> = {
|
|
adr: 'ADR',
|
|
architecture: 'ARCHITECTURE',
|
|
patterns: 'PATTERNS',
|
|
plans: 'PLANS',
|
|
runbooks: 'RUNBOOKS',
|
|
specs: 'SPECS',
|
|
manual: 'MANUAL',
|
|
api: 'API',
|
|
}
|
|
|
|
export function productDocFolderToApi(f: ProductDocFolder): ProductDocFolderApi {
|
|
return FOLDER_DB_TO_API[f]
|
|
}
|
|
|
|
export function productDocFolderFromApi(s: string): ProductDocFolder | null {
|
|
return FOLDER_API_TO_DB[s.toLowerCase()] ?? null
|
|
}
|
|
|
|
export const PRODUCT_DOC_FOLDER_API_VALUES = PRODUCT_DOC_FOLDERS
|