The plain-JS frontend re-declares two backend enum value-sets by hand: download-event statuses (downloadStatus.js) and platform keys (platformColor.js). With no TS codegen, drift is silent — the same class as the last_verified_at field mismatch. tests/test_fe_be_contract.py parses both JS mirrors and asserts they equal the backend canon (downloads._ALLOWED_STATUSES, platforms.known_platform_keys()) so a change on either side fails CI on whichever moved. Backend is the source of truth. Documented the invariant in both JS file headers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
23 lines
1.2 KiB
JavaScript
23 lines
1.2 KiB
JavaScript
// Single source of truth for the download-event status enum -> display
|
|
// metadata (label/color/icon). Mirrors the backend ENUM
|
|
// (pending|running|ok|error|skipped). Used by the stat chips, the filter
|
|
// dropdown, and the event rows so they never drift apart. The value set is
|
|
// pinned against backend _ALLOWED_STATUSES by tests/test_fe_be_contract.py.
|
|
|
|
export const DOWNLOAD_STATUSES = [
|
|
{ value: 'pending', label: 'Queued', color: 'grey', icon: 'mdi-clock-outline' },
|
|
{ value: 'running', label: 'Running', color: 'info', icon: 'mdi-progress-clock' },
|
|
{ value: 'ok', label: 'Completed', color: 'success', icon: 'mdi-check-circle' },
|
|
{ value: 'error', label: 'Failed', color: 'error', icon: 'mdi-alert-circle' },
|
|
{ value: 'skipped', label: 'Skipped', color: 'warning', icon: 'mdi-skip-next' },
|
|
]
|
|
|
|
const _BY_VALUE = Object.fromEntries(DOWNLOAD_STATUSES.map((s) => [s.value, s]))
|
|
|
|
export function downloadStatusMeta(value) {
|
|
return _BY_VALUE[value] || { value, label: value, color: 'grey', icon: 'mdi-help-circle' }
|
|
}
|
|
export const downloadStatusLabel = (v) => downloadStatusMeta(v).label
|
|
export const downloadStatusColor = (v) => downloadStatusMeta(v).color
|
|
export const downloadStatusIcon = (v) => downloadStatusMeta(v).icon
|