feat: add collection types and item type-specific fields#18
Merged
Conversation
f60452d to
93efe7f
Compare
Introduce a type registry that defines collection types (general, stamp) with per-type field schemas. Items in typed collections can store type-specific data in a JSON column, validated against the registry. - Add `type` column to collections (default "general") - Add `type_fields` JSON column to items - New GET /collection-types endpoint returning the registry - Validate/strip type_fields on item create and update - Schema validators reject unknown collection types - 16 new tests covering types, type_fields, and the endpoint
93efe7f to
1aba2bf
Compare
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
app/type_registry.py) defining collection types (general,stamp) with per-type field schemastypecolumn to collections (String(50), default"general") with schema validation against known typestype_fieldsJSON column to items for storing type-specific data, validated/stripped against the registry on create and updateGET /collection-typesendpoint returning the full type registry for frontend consumptionChanges
app/type_registry.py(new)app/models/collection.py,app/models/item.pyapp/schemas/collection.py,app/schemas/item.pyapp/routers/collection_types.py(new),collections.py,items.pyapp/routers/__init__.py,app/main.pyalembic/versions/62a67799efe0_...pytests/test_collection_types.py(new),test_collections.py,test_items.pyTest plan