feat(domain): Rust sheet index and loaded sheet (bundle payload → document, migration map, positions)
Lookups follow the TypeScript index: by-id maps keep the last duplicate as new Map does, spine annotations and finding paths take the first match as Array.find does; a document without a main view cannot be indexed.
This commit is contained in:
1 parent
ee0700887f
commit
22fea8736d
4 files changed
+320
-1
No files matched your search
@@ -24,3 +24,32 @@ fn the_curated_draft_prints_as_zod_outputs_it() {
|
||||
fn the_legacy_import_baseline_prints_as_zod_outputs_it() {
|
||||
assert_like_zod("sheet.legacy-import.json");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_bundled_payload_loads_and_indexes_the_draft() {
|
||||
use faunosteo_core::domain::sheet::{BundledSheetData, LoadedSheet};
|
||||
let seed = "supabase/seed/anatomical-sheets/equine/draft";
|
||||
let payload = serde_json::json!({
|
||||
"status": "draft",
|
||||
"ref": {
|
||||
"sheet_id": "s", "version_id": null, "document_sha256": "0".repeat(64),
|
||||
"schema_version": 2, "species_id": "equine"
|
||||
},
|
||||
"document": parse_json(&common::repo_file(&format!("{seed}/document.json"))).unwrap(),
|
||||
"migrationMap": parse_json(&common::repo_file(&format!("{seed}/report-migration-map.json"))).unwrap(),
|
||||
"assets": {}, "assetHashes": {}
|
||||
});
|
||||
let data: BundledSheetData = serde_json::from_value(payload).unwrap();
|
||||
let sheet = LoadedSheet::from_bundle(data).unwrap();
|
||||
let indexed = sheet.indexed();
|
||||
assert_eq!(indexed.main_view().id(), "main");
|
||||
assert!(
|
||||
indexed.is_spine("c7-t1")
|
||||
|| indexed
|
||||
.document
|
||||
.annotations
|
||||
.iter()
|
||||
.any(|a| indexed.is_spine(a.id()))
|
||||
);
|
||||
assert!(indexed.annotation("hip").is_some());
|
||||
}
|
||||
Reference in new issue
Block a user