domain: introduce provider-neutral media model (phase 1)
Establish src-tauri/src/domain/ as the single source of truth for the media model, with all Jellyfin translation isolated in from_jellyfin.rs. Adds MediaKind enum and neutral duration_ms/image_id fields to MediaItem as additive, defaulted dual-carry alongside the legacy Jellyfin-named fields, so nothing breaks while the frontend migrates off them. - domain/media.rs: canonical MediaKind (closed enum, replaces stringly item_type), Default = Other so unknown/defaulted items are inert. - domain/from_jellyfin.rs: total, panic-free item_type -> MediaKind classification (all audited types + person subroles) and ticks->ms. - MediaItem gains kind/duration_ms/image_id, populated at both mapping seams (online to_media_item, offline cached_item_to_media_item) and the synthesized-album/person sites. - Regenerated bindings.ts: frontend now HAS the neutral model available. Phase 1 of docs/specs/frontend-domain-model.md. No frontend behaviour change yet; wire shape is a superset of before. Rust 456 tests, frontend 644 tests, check + check:boundary all green.
This commit is contained in:
@@ -68,10 +68,13 @@ impl OfflineRepository {
|
||||
.and_then(|s| serde_json::from_str::<Vec<String>>(s).ok())
|
||||
.unwrap_or_default();
|
||||
|
||||
let kind = crate::domain::kind_from_jellyfin(&item.item_type, item.is_folder);
|
||||
|
||||
MediaItem {
|
||||
id: item.id.clone(),
|
||||
name: item.name,
|
||||
item_type: item.item_type,
|
||||
kind,
|
||||
is_folder: item.is_folder,
|
||||
server_id: item.server_id,
|
||||
parent_id: item.parent_id,
|
||||
@@ -82,11 +85,13 @@ impl OfflineRepository {
|
||||
.as_ref()
|
||||
.and_then(|s| serde_json::from_str::<Vec<String>>(s).ok()),
|
||||
runtime_ticks: item.runtime_ticks,
|
||||
duration_ms: item.runtime_ticks.map(crate::domain::ticks_to_ms),
|
||||
production_year: item.production_year,
|
||||
premiere_date: item.premiere_date,
|
||||
community_rating: item.community_rating,
|
||||
official_rating: item.official_rating,
|
||||
primary_image_tag: item.primary_image_tag,
|
||||
primary_image_tag: item.primary_image_tag.clone(),
|
||||
image_id: item.primary_image_tag,
|
||||
backdrop_image_tags: item.backdrop_image_tags,
|
||||
parent_backdrop_image_tags: item.parent_backdrop_image_tags,
|
||||
album_id: item.album_id,
|
||||
@@ -1599,6 +1604,7 @@ impl MediaRepository for OfflineRepository {
|
||||
id: person_data.0,
|
||||
name: person_data.1,
|
||||
item_type: "Person".to_string(),
|
||||
kind: crate::domain::MediaKind::Person,
|
||||
is_folder: false,
|
||||
server_id: self.server_id.clone(),
|
||||
parent_id: None,
|
||||
@@ -1606,11 +1612,13 @@ impl MediaRepository for OfflineRepository {
|
||||
overview: person_data.2,
|
||||
genres: None,
|
||||
runtime_ticks: None,
|
||||
duration_ms: None,
|
||||
production_year: None,
|
||||
premiere_date: None,
|
||||
community_rating: None,
|
||||
official_rating: None,
|
||||
primary_image_tag: person_data.3,
|
||||
primary_image_tag: person_data.3.clone(),
|
||||
image_id: person_data.3,
|
||||
backdrop_image_tags: None,
|
||||
parent_backdrop_image_tags: None,
|
||||
album_id: None,
|
||||
@@ -2100,6 +2108,7 @@ mod tests {
|
||||
id: id.to_string(),
|
||||
name: name.to_string(),
|
||||
item_type: "Audio".to_string(),
|
||||
kind: crate::domain::MediaKind::Track,
|
||||
is_folder: false,
|
||||
server_id: "test-server".to_string(),
|
||||
parent_id: parent_id.map(|s| s.to_string()),
|
||||
@@ -2107,11 +2116,13 @@ mod tests {
|
||||
overview: None,
|
||||
genres: None,
|
||||
runtime_ticks: None,
|
||||
duration_ms: None,
|
||||
production_year: None,
|
||||
premiere_date: None,
|
||||
community_rating: None,
|
||||
official_rating: None,
|
||||
primary_image_tag: None,
|
||||
image_id: None,
|
||||
backdrop_image_tags: None,
|
||||
parent_backdrop_image_tags: None,
|
||||
album_id: None,
|
||||
|
||||
Reference in New Issue
Block a user