fix(types): make DocumentOption precision fields optional; narrow spec data access
Some checks failed
CI / Unit & Component Tests (pull_request) Failing after 3m0s
CI / OCR Service Tests (pull_request) Successful in 23s
CI / Backend Unit Tests (pull_request) Successful in 4m54s
CI / fail2ban Regex (pull_request) Successful in 47s
SDD Gate / RTM Check (pull_request) Successful in 15s
SDD Gate / Contract Validate (pull_request) Successful in 22s
CI / Semgrep Security Scan (pull_request) Successful in 23s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m8s
SDD Gate / Constitution Impact (pull_request) Successful in 16s
Some checks failed
CI / Unit & Component Tests (pull_request) Failing after 3m0s
CI / OCR Service Tests (pull_request) Successful in 23s
CI / Backend Unit Tests (pull_request) Successful in 4m54s
CI / fail2ban Regex (pull_request) Successful in 47s
SDD Gate / RTM Check (pull_request) Successful in 15s
SDD Gate / Contract Validate (pull_request) Successful in 22s
CI / Semgrep Security Scan (pull_request) Successful in 23s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m8s
SDD Gate / Constitution Impact (pull_request) Successful in 16s
DocumentOption's metaDatePrecision/metaDateEnd are now optional so a TimelineEvent DocumentRef (id/title/documentDate only) maps cleanly into a picker chip — formatDocumentOption already degrades gracefully when precision is absent. The server specs read fail()'s union data via a small failData() cast that TS cannot narrow. svelte-check shows zero new errors in the #781 files. Refs #781 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -5,10 +5,14 @@ import { getLocale } from '$lib/paraglide/runtime.js';
|
||||
|
||||
type DocumentListItem = components['schemas']['DocumentListItem'];
|
||||
|
||||
export type DocumentOption = Pick<
|
||||
DocumentListItem,
|
||||
'id' | 'title' | 'documentDate' | 'metaDatePrecision' | 'metaDateEnd'
|
||||
>;
|
||||
/**
|
||||
* Chip/dedup contract for document pickers. `metaDatePrecision`/`metaDateEnd`
|
||||
* are optional: the typeahead always populates them, but a TimelineEvent's
|
||||
* DocumentRef (#781) carries only id/title/documentDate — formatDocumentOption
|
||||
* degrades gracefully (bare title or plain date) when precision is absent.
|
||||
*/
|
||||
export type DocumentOption = Pick<DocumentListItem, 'id' | 'title' | 'documentDate'> &
|
||||
Partial<Pick<DocumentListItem, 'metaDatePrecision' | 'metaDateEnd'>>;
|
||||
|
||||
export function createDocumentTypeahead() {
|
||||
return createTypeahead<DocumentOption>({
|
||||
|
||||
Reference in New Issue
Block a user