refactor: remove hardcoded CATEGORY_NAMES, add missing schema API methods #14

Merged
forbes merged 1 commits from refactor/remove-hardcoded-categories-add-schema-api into main 2026-02-16 17:24:49 +00:00
Owner

Summary

Resolves #3 and #4.

Makes the client schema-agnostic by removing hardcoded Kindred-specific category data and adding the missing schema API methods so consumers can fetch everything dynamically from the server.

Changes

Removed (Issue #3)

  • CATEGORY_NAMES dict — 170 hardcoded category codes that belong in server YAML, not client Python
  • sanitize_filename() — filesystem concern, not API concern
  • parse_part_number() — assumes CCC-NNNN format specific to kindred-rd schema
  • get_category_folder_name() — filesystem path construction
  • import re — only used by removed sanitize_filename

These utilities should be moved to consumer repos (silo-mod, silo-calc) that need them.

Added (Issue #4)

Five new schema API methods:

Method Endpoint Description
list_schemas() GET /api/schemas List all available schemas
get_schema_form(name) GET /api/schemas/{name}/form Form descriptor (field groups, widgets, category picker)
add_enum_value(schema, segment, code, label) POST /api/schemas/{name}/segments/{segment}/values Add enum value
update_enum_value(schema, segment, code, **fields) PUT /api/schemas/{name}/segments/{segment}/values/{code} Update enum value
delete_enum_value(schema, segment, code) DELETE /api/schemas/{name}/segments/{segment}/values/{code} Delete enum value

Version

0.1.0 -> 0.2.0 (minor bump: breaking removal + new features)

Breaking Changes

Consumers importing any of the following will need to update:

  • from silo_client import CATEGORY_NAMES
  • from silo_client import sanitize_filename
  • from silo_client import parse_part_number
  • from silo_client import get_category_folder_name

These should be replaced with calls to client.list_schemas() / client.get_schema(name) to fetch categories dynamically from the server.

Net Effect

  • 264 lines removed, 53 lines added
  • File: 1,025 -> 814 lines
## Summary Resolves #3 and #4. Makes the client schema-agnostic by removing hardcoded Kindred-specific category data and adding the missing schema API methods so consumers can fetch everything dynamically from the server. ## Changes ### Removed (Issue #3) - `CATEGORY_NAMES` dict — 170 hardcoded category codes that belong in server YAML, not client Python - `sanitize_filename()` — filesystem concern, not API concern - `parse_part_number()` — assumes `CCC-NNNN` format specific to `kindred-rd` schema - `get_category_folder_name()` — filesystem path construction - `import re` — only used by removed `sanitize_filename` These utilities should be moved to consumer repos (silo-mod, silo-calc) that need them. ### Added (Issue #4) Five new schema API methods: | Method | Endpoint | Description | |---|---|---| | `list_schemas()` | `GET /api/schemas` | List all available schemas | | `get_schema_form(name)` | `GET /api/schemas/{name}/form` | Form descriptor (field groups, widgets, category picker) | | `add_enum_value(schema, segment, code, label)` | `POST /api/schemas/{name}/segments/{segment}/values` | Add enum value | | `update_enum_value(schema, segment, code, **fields)` | `PUT /api/schemas/{name}/segments/{segment}/values/{code}` | Update enum value | | `delete_enum_value(schema, segment, code)` | `DELETE /api/schemas/{name}/segments/{segment}/values/{code}` | Delete enum value | ### Version `0.1.0` -> `0.2.0` (minor bump: breaking removal + new features) ## Breaking Changes Consumers importing any of the following will need to update: - `from silo_client import CATEGORY_NAMES` - `from silo_client import sanitize_filename` - `from silo_client import parse_part_number` - `from silo_client import get_category_folder_name` These should be replaced with calls to `client.list_schemas()` / `client.get_schema(name)` to fetch categories dynamically from the server. ## Net Effect - 264 lines removed, 53 lines added - File: 1,025 -> 814 lines
forbes added 1 commit 2026-02-16 17:24:08 +00:00
Issues #3 and #4.

Remove:
- CATEGORY_NAMES dict (170 Kindred-specific category codes)
- sanitize_filename(), parse_part_number(), get_category_folder_name()
- import re (only used by removed sanitize_filename)

These are consumer-side concerns (filesystem path construction) that
don't belong in a generic HTTP client. Categories should be fetched
dynamically from the server via the schema API.

Add schema methods:
- list_schemas() — GET /api/schemas
- get_schema_form(name) — GET /api/schemas/{name}/form
- add_enum_value(schema, segment, code, label) — POST enum value
- update_enum_value(schema, segment, code, **fields) — PUT enum value
- delete_enum_value(schema, segment, code) — DELETE enum value

Bump version 0.1.0 -> 0.2.0.
forbes merged commit 5276ff26fa into main 2026-02-16 17:24:49 +00:00
forbes deleted branch refactor/remove-hardcoded-categories-add-schema-api 2026-02-16 17:24:50 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/silo-client#14