Polish the pkg/ public API ahead of the v2 freeze - #39
Merged
Merged
Conversation
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.
Summary
Adds sentinel-error contracts, consistent naming, and safer constructors across the pkg/ public API, and moves TUI success-screen rendering out of the domain package into a dumb formatter. Completes the pkg/ API polish ahead of the v2 freeze.
What's new
book.ErrDuplicateURL,book.ErrURLTrashed, andbook.ErrTitleRequiredinpkg/book, plusweb.ErrNotFoundinpkg/web, all package-prefixed and matchable witherrors.Is; the domain package no longer embeds CLI remediation text.book mark restore --id <catalog_id>command, unresolvable titles end withprovide --title, and the 404 quip moves frompkg/webinto the CLI layer where colloquial output belongs.Mark.Nameis nowMark.Title,Mark.UpdateMarkisMark.Update, and the stutteringCollectionsNames/MarksNamesareCollectionNames/MarkNames.Templatableinterface is gone frompkg/book; each completed TUI screen builds aviewDataand the renderer ininternal/modelis a dumb formatter, with the shelf/collection parent section rendered above mark screens.NewShelfandValidateNewShelfNamesharevalidateShelfName, which rejects empty, whitespace-padded, control-character, path-separator, Windows-reserved, and./..names.SoftDeletedByIDandIndex.CollectionwireShelf/Collectionback-pointers like the other finders, andMark.FullDetailrenders empty fields instead of panicking on unwired marks.Behavior changes / guardrails
MarshalCatalogreturns an error for empty or unknown formats instead ofnil.WebsiteTitlewrapsErrNotFoundon HTTP 404 and reports other statuses asfetch title: unexpected status N; HTTP 403 and empty<title>still returnErrTitleUnavailable.ShelfPathtrims and underscorifies names, so a padded name would collide with its trimmed form on disk.EnsureConfigfailure names the remedy again:set --confirm to create it.Testing
internal/model/tea_test.gopin section order, empty-section skipping, and the parent-above-mark layout.TestWebsiteError,TestUniqueURLError, andTestTitleErrorcover the CLI remediation branches anderrors.Ischain preservation.pkg/bookandpkg/websuites.make checkruns fmt, vet, lint, and tests; all green.