Add to-do list reposition operation

Merged
JE
4mo ago
+1072-15

Adds a RepositionTodolist operation so every SDK can reorder a to-do list within its to-do set. The generated reposition method lands on the TodolistsService in all six SDKs; Go additionally gets a hand-written TodolistsService.Reposition wrapper as the user-facing entry point.

Addresses basecamp/basecamp-cli#484.

Endpoint

PUT /{accountId}/todosets/todolists/{todolistId}/position.json, body { position }, returns 204 No Content.

position is the 1-based index among the to-do lists the caller can see. Positioning is relative and cascading: the server applies a position_offset for loose to-dos and translates for hidden completed lists, then shifts siblings to make room. The caller sends a simple visible index and the server places the list correctly.

This endpoint is undocumented in both the authoritative BC3 doc/api/ and the public bc3-api mirror — position appears there only as a response field on the todolist/todoset payloads. Follow-up: open the doc PR against the authoritative BC3 doc/api/, then sync the public mirror (not directly against bc3-api).

Why the dedicated route, not the generic recording reposition

An earlier draft targeted the generic PUT /recordings/{id}/position.json (RepositionTool). That is wrong for to-do lists: Recordings::PositionsController#update runs a bare reposition_to with only dock translation and returns 200 — it performs none of the to-do-list position math. It would mis-position lists whenever loose to-dos or hidden completed lists exist. The dedicated Todosets::Todolists::PositionsController#update is the canonical, correct contract and returns 204 (per bc3's own test/api/todosets/todolists/positions_controller_api_test.rb).

Provenance

The route, controller behavior, and bc3 API test all exist at the current pin (spec/api-provenance.json → bc3 ba105ba7, 2026-07-22). This absorbs a contract already live at the current pin — no repin. Registered in spec/api-gaps/todolist-reposition.md as absorbed-in-sdk. The dedicated route landed long ago in BC3 a61b90d00f via PR #9575 (pre-BC5).

Changes

  • spec/basecamp.smithy: RepositionTodolist operation (@idempotent, 204), tagged Todos.
  • Generator sub-service mappings (TS/Ruby/Kotlin/Swift/Python) place it on the Todolists service.
  • Regenerated openapi.json, behavior-model.json, and all six SDKs' generated/**.
  • Go wrapper TodolistsService.Reposition(ctx, todolistID, position) with bounded int → int32 conversion (guards position < 1 and position > MaxInt32).
  • Tests: Go, TypeScript, Ruby, Python (happy path + 404; Go adds both usage-guard cases).
  • Operation-count prose bumped 204 → 205 (idempotent 66 → 67) in AGENTS.md / SPEC.md.

Follow-ups

  • BC3 doc PR documenting the route (authoritative doc/api/, then mirror sync).
  • A todolists position command in basecamp-cli.

Summary by cubic

Adds RepositionTodolist so all SDKs can move a to-do list within its to-do set via the dedicated 204 PUT /{accountId}/todosets/todolists/{todolistId}/position.json route. Exposes reposition on TodolistsService using a 1-based visible position that the server translates correctly.

  • New Features
    • Endpoint: accepts { position } (1-based among visible lists), adjusts for loose to-dos and hidden completed lists, returns 204.
    • SDKs: reposition added to TodolistsService in TypeScript, Ruby, Swift, Kotlin, Python; Go adds TodolistsService.Reposition(ctx, todolistID, position) with guards for < 1 and > MaxInt32. TypeScript now re-exports RepositionTodolistRequest from the package root.
    • Spec/Docs: added RepositionTodolist (@idempotent), updated OpenAPI and behavior model; operation counts now 205 total, 67 idempotent; added spec/api-gaps/todolist-reposition.md (absorbed-in-sdk; references basecamp-cli#484).
    • Tests: success + 404 in Go/TypeScript/Ruby/Python; Go also covers both usage-guard errors; Ruby test now asserts the request body via explicit JSON parse.
    • Routing: binds to Todosets::Todolists::PositionsController#update (correct todolist math); avoids the generic recordings reposition which would misplace lists.