refactor(core): extract LibraryBook DTOs + injectable cover/file URL layer#133
Merged
phildenhoff merged 1 commit intoJun 30, 2026
Merged
Conversation
libcalibre Test Coverage ReportOverall coverage: 81.63% Coverage breakdown available in the artifacts. |
…layer
Move the frontend-facing DTOs (LibraryBook, LibraryAuthor, LocalOrRemoteUrl,
the file list, Identifier) and the libcalibre->DTO conversion out of the Tauri
crate into a new platform-agnostic `citadel-core` crate, so a future
citadel-server can serialize the same shapes over HTTP.
The cover/file URL scheme is now injected via a `BookUrlBuilder` trait instead
of being hardcoded to Tauri's asset:// protocol:
- AssetUrlBuilder reproduces the desktop app's asset://localhost/... output
byte-for-byte, including the ?v=<mtime_ms> cache-bust and has_cover trust.
- HttpUrlBuilder adds the Remote { url } path (https://.../api/books/<id>/...)
for a future HTTP caller.
citadel-core depends only on libcalibre/serde/specta/urlencoding -- no tauri.
The Tauri shell re-exports LibraryBook/LibraryAuthor from citadel-core, injects
AssetUrlBuilder, and cover_thumbs now shares citadel_core::path_to_asset_url
(libs/util.rs removed). A unit test exercises both builders over the same Book.
bindings.ts is unchanged (specta emits identical names/shapes).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
c6ce4e4 to
20fb218
Compare
Contributor
libcalibre Test Coverage ReportOverall coverage: 81.63% Coverage breakdown available in the artifacts. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A future client/server build of Citadel needs to serialize a
LibraryBookto JSON with HTTP cover/file URLs. Today the frontend-facing DTOs and all cover/file URL-building live in the Tauri crate, hardcoded to Tauri'sasset://protocol —libcalibrehands over the data model but not the serialized, URL-bearing shape the frontend consumes. This pulls that platform-agnostic layer out of the Tauri shell.What changed
New crate
crates/citadel-coreowns the frontend-facing DTOs and thelibcalibre→ DTO conversion, with the URL scheme injected rather than hardcoded:book.rs/author.rs):LibraryBook,LibraryAuthor,LocalOrRemoteUrl,BookFile/LocalFile/RemoteFile,Identifier, plusfrom_library_book/from_author.BookUrlBuildertrait (url.rs) with two impls:AssetUrlBuilder— reproduces the desktop app'sasset://localhost/…output byte-for-byte, including the?v=<mtime_ms>cache-bust and thehas_covertrust.HttpUrlBuilder— the newRemote { url }path (https://…/api/books/<id>/cover,…/files/<name>.<ext>) for a future HTTP caller.path_to_asset_urlis shared here;cover_thumbsnow imports it from the core crate (single source of truth), andsrc-tauri/libs/util.rsis removed.citadel-coredepends only onlibcalibre/serde/specta/urlencoding— notauri. The Tauri shell re-exportsLibraryBook/LibraryAuthorfrom it and injects&AssetUrlBuilder, so call sites andbindings.tsare unchanged.Out of scope (follow-ups)
The server crate itself, HTTP routes, and the remote frontend client. Cover-thumbnail generation stays in Tauri for now (it just shares
path_to_asset_url).