project-nomad/admin/types/collections.ts

113 lines
2.7 KiB
TypeScript

export type SpecResource = {
id: string
version: string
title: string
description: string
url: string
size_mb: number
/**
* Resource-type discriminator. Absent == 'zim' so every existing manifest
* entry keeps the current ZIM download path. 'dataset' routes the tier
* installer to the DB-ingested drug pipeline instead.
*/
type?: 'zim' | 'dataset'
}
export type SpecTier = {
name: string
slug: string
description: string
recommended?: boolean
includesTier?: string
resources: SpecResource[]
}
export type SpecCategory = {
name: string
slug: string
icon: string
description: string
language: string
tiers: SpecTier[]
}
export type SpecCollection = {
name: string
slug: string
description: string
icon: string
language: string
resources: SpecResource[]
}
export type ZimCategoriesSpec = {
spec_version: string
categories: SpecCategory[]
}
export type MapsSpec = {
spec_version: string
collections: SpecCollection[]
}
export type WikipediaOption = {
id: string
name: string
description: string
size_mb: number
url: string | null
version: string | null
}
export type WikipediaSpec = {
spec_version: string
options: WikipediaOption[]
}
export type ManifestType = 'zim_categories' | 'maps' | 'wikipedia'
export type ResourceStatus = 'installed' | 'not_installed' | 'update_available'
export type CategoryWithStatus = SpecCategory & {
installedTierSlug?: string
// Highest tier whose every resource is either installed OR has an in-flight
// download. Set only when it differs from installedTierSlug — i.e. the user
// picked something larger and downloads are still running. Lets the UI show
// the user's actual intent during the (often long) download window.
downloadingTierSlug?: string
// True when the in-flight resource for `downloadingTierSlug` is a DB-ingested
// dataset (the FDA drug labels) whose download has finished and the heavy
// ingest is running — so the card can flip "(downloading)" → "(indexing)" at
// the handoff instead of looking stuck. Only meaningful with downloadingTierSlug.
downloadingTierIndexing?: boolean
}
export type CollectionWithStatus = SpecCollection & {
all_installed: boolean
installed_count: number
total_count: number
}
export type ResourceUpdateCheckRequest = {
resources: Array<{
resource_id: string
resource_type: 'zim' | 'map'
installed_version: string
}>
}
export type ResourceUpdateInfo = {
resource_id: string
resource_type: 'zim' | 'map'
installed_version: string
latest_version: string
download_url: string
size_bytes?: number
}
export type ContentUpdateCheckResult = {
updates: ResourceUpdateInfo[]
checked_at: string
error?: string
}