Repository navigation
feat: add CategoryStore with contract tests and in-memory implementation - #31
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
The category data layer, following the decisions in ADR 0001. Nothing is wired into the API or UI yet; tasks still use the
categorystring.Changes
lib/categories/types.ts):Category(id,name) and theCategoryStoreinterface.createandrenamereturn aCategoryWriteResult<Reason>discriminated union, so expected failures (name-taken,not-found) are part of the return type rather than thrown.getreturnsCategory | null, anddeletereturnsboolean.lib/categories/schemas.ts): a sharedcategoryNameSchema(trimmed, 1–50 characters, no/, and not the reserved "Uncategorized" label in any case), used by the create and rename input schemas.normalizeCategoryNameis the single place that decides how names are compared.category-store-contract.ts): 18 tests that everyCategoryStoreimplementation must pass, covering case-insensitive uniqueness, two concurrent creates of the same name, case-only renames, names being freed after rename or delete, sorting, and returning copies.in-memory-category-store.ts): passes the full contract. The name check and the save happen with noawaitin between, so concurrent creates can't both succeed.Notes
categoryId.Test plan
vitest: 18/18 category contract tests pass against the in-memory storetscand ESLint are clean onlib/categories/