Skip to content

feat: add collection types and item type-specific fields#18

Merged
amrtgaber merged 1 commit intomainfrom
feat/collection-types
Feb 4, 2026
Merged

feat: add collection types and item type-specific fields#18
amrtgaber merged 1 commit intomainfrom
feat/collection-types

Conversation

@amrtgaber
Copy link
Contributor

@amrtgaber amrtgaber commented Feb 4, 2026

Summary

  • Add a type registry (app/type_registry.py) defining collection types (general, stamp) with per-type field schemas
  • Add type column to collections (String(50), default "general") with schema validation against known types
  • Add type_fields JSON column to items for storing type-specific data, validated/stripped against the registry on create and update
  • New GET /collection-types endpoint returning the full type registry for frontend consumption
  • Alembic migration for both new columns

Changes

Area Files
Type registry app/type_registry.py (new)
Models app/models/collection.py, app/models/item.py
Schemas app/schemas/collection.py, app/schemas/item.py
Routers app/routers/collection_types.py (new), collections.py, items.py
Registration app/routers/__init__.py, app/main.py
Migration alembic/versions/62a67799efe0_...py
Tests tests/test_collection_types.py (new), test_collections.py, test_items.py

Test plan

  • 91 tests pass (`uv run pytest`)
  • Lint and format clean (`ruff check . && ruff format --check .`)
  • Verify `GET /collection-types` returns general and stamp types
  • Verify creating a collection with `type: "stamp"` works
  • Verify creating an item with `type_fields` in a stamp collection stores valid fields and strips unknown ones
  • Verify unknown collection type is rejected with 422

@amrtgaber amrtgaber force-pushed the feat/collection-types branch from f60452d to 93efe7f Compare February 4, 2026 05:23
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
@amrtgaber amrtgaber force-pushed the feat/collection-types branch from 93efe7f to 1aba2bf Compare February 4, 2026 05:23
@amrtgaber amrtgaber merged commit b3d18f8 into main Feb 4, 2026
2 checks passed
@amrtgaber amrtgaber deleted the feat/collection-types branch February 6, 2026 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant