feat(journal): add category show/update API routes and MCP tools

This commit is contained in:
Jakub Zych
2026-11-28 15:05:45 +01:00
parent a047d4284f
commit daa29c8aa8
8 changed files with 580 additions and 58 deletions

View File

@@ -25,12 +25,13 @@ import (
var (
postBodyKeys = []string{"categories", "content", "excerpt", "is_pinned", "metadata", "published", "published_at", "slug", "sources", "tags", "title", "translations"}
postQueryKeys = []string{"author", "category", "include_empty", "page", "per_page", "pinned_first", "published", "search", "sort", "tag"}
// maintenanceBodyKeys are the body keys of the settings and content
// fix routes, by path.
// maintenanceBodyKeys are the body keys of the settings, category, and
// content fix routes, by path.
maintenanceBodyKeys = map[string][]string{
"/_journal/api/v1/settings": models.Settings{}.Fillable(),
"/_journal/api/v1/fix-headings": {"dry_run"},
"/_journal/api/v1/images/alt": {"dry_run", "changes"},
"/_journal/api/v1/categories/{id}": {"name", "slug", "description", "content", "translations"},
"/_journal/api/v1/settings": models.Settings{}.Fillable(),
"/_journal/api/v1/fix-headings": {"dry_run"},
"/_journal/api/v1/images/alt": {"dry_run", "changes"},
}
)
@@ -110,7 +111,7 @@ func TestJournalMCP(t *testing.T) {
if !ok {
t.Fatal("pier was not mounted")
}
want := []string{"journal_create_post", "journal_delete_post", "journal_fix_headings", "journal_get_settings", "journal_list_categories", "journal_list_posts", "journal_list_tags", "journal_set_image_alt", "journal_show_post", "journal_update_post", "journal_update_settings"}
want := []string{"journal_create_post", "journal_delete_post", "journal_fix_headings", "journal_get_settings", "journal_list_categories", "journal_list_posts", "journal_list_tags", "journal_set_image_alt", "journal_show_category", "journal_show_post", "journal_update_category", "journal_update_post", "journal_update_settings"}
if got := p.ToolNames(); !slices.Equal(got, want) {
t.Fatalf("compiled tools %v, want %v", got, want)
}