refactor: remove hardcoded CATEGORY_NAMES, add missing schema API methods #14
Reference in New Issue
Block a user
Delete Branch "refactor/remove-hardcoded-categories-add-schema-api"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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_NAMESdict — 170 hardcoded category codes that belong in server YAML, not client Pythonsanitize_filename()— filesystem concern, not API concernparse_part_number()— assumesCCC-NNNNformat specific tokindred-rdschemaget_category_folder_name()— filesystem path constructionimport re— only used by removedsanitize_filenameThese utilities should be moved to consumer repos (silo-mod, silo-calc) that need them.
Added (Issue #4)
Five new schema API methods:
list_schemas()GET /api/schemasget_schema_form(name)GET /api/schemas/{name}/formadd_enum_value(schema, segment, code, label)POST /api/schemas/{name}/segments/{segment}/valuesupdate_enum_value(schema, segment, code, **fields)PUT /api/schemas/{name}/segments/{segment}/values/{code}delete_enum_value(schema, segment, code)DELETE /api/schemas/{name}/segments/{segment}/values/{code}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_NAMESfrom silo_client import sanitize_filenamefrom silo_client import parse_part_numberfrom silo_client import get_category_folder_nameThese should be replaced with calls to
client.list_schemas()/client.get_schema(name)to fetch categories dynamically from the server.Net Effect