The pre-tree rules machinery is deleted: no row ever carried a rules array or a non-default match mode (verified in the dev DB), the web never read the envelope keys, and the Android app consumes none of it. Dead code gets no documentation. Removed: - PUT /api/collections/:id/match-mode — endpoint, route, and the UpdateCollectionMatchMode query. The tree's root mode owns any|all. - auto_assign_rules / rule_match_mode from every envelope (create/list/detail/update), from the create/update request shapes, and from the schema: both columns DROPPED (schema.sql carries idempotent DROP COLUMN IF EXISTS heals for existing DBs; sqlc regenerated). - The rules CRUD service layer (AddRule/SetRuleEnabled/RemoveRule + validateRule + UpdateCollectionRulesJSON), ParseRules / EnabledRules / IsSmartCollection, RulesToFilterTree (+ the SSR preload branch), the legacy branch of EvaluateSmartMembership, and SmartEvalOptions.MatchMode. IsCollectionSmart = tree presence; create-path isSmart = collection_type=smart OR a filter_tree. Kept (live consumers): POST /api/collections/preview still evaluates rules payloads in memory (the custom-section builder's preview), and include_auto stays on the list (the Android app sends it). The custom-section builder's SAVE was already broken — its stringified auto_assign_rules payload failed request binding (probed live: 400 invalid request). Create now rejects that payload loudly with a 400 naming the retirement, instead of silently creating a hollow static section; custom-section-builder.md carries the flag. The builder's tree migration remains the flagged follow-up. Test-side (asymmetry rule — deleted behavior, deleted tests): TestPodcastSmartCollections rewritten onto trees (mode lives in the tree root), match-mode subtests and tree_wins_over_legacy_rules deleted, TestRulesToFilterTree deleted, contract-pin envelope keys retracted per the contract_pins 2026-10-31 retirement entry. Mirrors hand-synced: openapi.yaml, bruno create/update, docs/api/*.md, docs/schema.go, api.d.ts. Full container suite green (155s).
38 lines
1.8 KiB
Go
38 lines
1.8 KiB
Go
package router
|
|
|
|
func registerCollectionsRoutes(cfg *Config) {
|
|
e := cfg.Echo
|
|
|
|
// JWT middleware for protected routes
|
|
jwtMiddleware := createJWTMiddleware(cfg)
|
|
protected := e.Group("/api", jwtMiddleware)
|
|
|
|
// Collections API routes
|
|
collections := protected.Group("/collections")
|
|
collections.GET("", cfg.CollectionHandler.GetCollections)
|
|
collections.POST("", cfg.CollectionHandler.CreateCollection)
|
|
collections.GET("/:id", cfg.CollectionHandler.GetCollection)
|
|
collections.PUT("/:id", cfg.CollectionHandler.UpdateCollection)
|
|
collections.DELETE("/:id", cfg.CollectionHandler.DeleteCollection)
|
|
collections.GET("/:id/books", cfg.CollectionHandler.GetBookCollections)
|
|
collections.POST("/:id/books", cfg.CollectionHandler.AddBooks)
|
|
collections.PUT("/:id/items/order", cfg.CollectionHandler.ReorderItems)
|
|
// The chain's listening order lives ON the collection (plan §10 R2):
|
|
// merges into view_settings; the episode chain producer honors it.
|
|
collections.PUT("/:id/view-settings", cfg.CollectionHandler.SetCollectionChainOrder)
|
|
collections.DELETE("/:id/books/:bookId", cfg.CollectionHandler.RemoveBook)
|
|
collections.POST("/:id/books/bulk-remove", cfg.CollectionHandler.BulkRemoveBooks)
|
|
collections.POST("/bulk-add-books", cfg.CollectionHandler.HandleBulkAddBooks)
|
|
collections.POST("/preview", cfg.CollectionHandler.PreviewCollection)
|
|
|
|
// Smart collection rule CRUD (the rules builder persists through
|
|
// these; type follows rules presence — first rule = smart).
|
|
|
|
// Device shelf mapping routes
|
|
deviceCollections := protected.Group("/devices/:id/collections")
|
|
deviceCollections.GET("", cfg.CollectionHandler.GetDeviceMappings)
|
|
deviceCollections.POST("", cfg.CollectionHandler.CreateDeviceMapping)
|
|
deviceCollections.PUT("/:collectionId", cfg.CollectionHandler.UpdateDeviceMapping)
|
|
deviceCollections.DELETE("/:collectionId", cfg.CollectionHandler.DeleteDeviceMapping)
|
|
}
|