feat(trucks): site_id column and site/truck helpers

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-15 11:44:37 +08:00
co-authored by Claude Sonnet 5.5
parent fd7a55337f
commit 867b725262
9 changed files with 105 additions and 1 deletions
+11
View File
@@ -0,0 +1,11 @@
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
export type SiteIdInput = { ok: true; value: string | null | undefined } | { ok: false }
// undefined = field not sent, null/'' = clear the link, uuid string = set it.
export function parseSiteId(raw: unknown): SiteIdInput {
if (raw === undefined) return { ok: true, value: undefined }
if (raw === null || raw === '') return { ok: true, value: null }
if (typeof raw === 'string' && UUID_RE.test(raw)) return { ok: true, value: raw }
return { ok: false }
}