Model external links (doors) as a Doors service

Merged
JO
1mo ago
+8232-295

Depends on basecamp/bc3#14314 (Doors API)

Adds external links (doors) as a resource of their own: five operations on a new Doors service (tag Dock), a Door shape, and every client generated from them. bc3#14314 serves them as JSON. Before it, create answered a 302 with no body and there was no JSON update path.

bc3#14314 is merged and deployed to production. This PR repins bc3 to its merge commit, 6ceece6f69b, so the four new routes are in the vendored route table at the pin and need no waivers. The range triage is in spec/api-gaps/README.md.

The operations

OperationRouteAnswers
ListDoorsGET /{accountId}/buckets/{bucketId}/dock/doors.json200, the project's active links in section order, unpaginated
GetDoorGET /{accountId}/dock/doors/{doorId}200 Door; 404 for an unknown id, a non-door, or a link hidden from a client
CreateDoorPOST /{accountId}/buckets/{bucketId}/dock/doors.json201 Door; 422 for an unusable url, with Rails' default error body (no field-keyed errors), mapped to validation; non-idempotent, attempted once
UpdateDoorPUT /{accountId}/dock/doors/{doorId}200 Door; a partial update; idempotent
DeleteDoorDELETE /{accountId}/dock/doors/{doorId}204; status becomes "deleted"

Request bodies follow bc3's contract:

  • The link's fields go under door: service, url, title and description. visible_to_clients sits beside door, not inside it.
  • Writes need permission to edit the project. Without it, they answer 403.

Visibility default: a create that leaves out visible_to_clients makes a private link, visible to the team only, whatever the project's other tools do. No SDK sends a default of its own; the field is omitted unless the caller sets it. An update that leaves out door changes only the visibility. An update that leaves out visible_to_clients keeps the current visibility.

GetDoor is the flat JSON show, which is a separate action from the bucket-scoped GET /buckets/:b/dock/doors/:id. That route stays a 302 redirector to the outside address, and it stays out of scope. The door[image] thumbnail is multipart-only and is not modelled.

Per language

LanguageAPI
Goclient.ForAccount(id).Doors(): List(ctx, bucketID int64) (*DoorListResult, error), Get(ctx, doorID int64) (*Door, error), Create(ctx, bucketID int64, req *CreateDoorRequest) (*Door, error), Update(ctx, doorID int64, req *UpdateDoorRequest) (*Door, error), Delete(ctx, doorID int64) error. CreateDoorRequest{Service, URL, Title, Description string; VisibleToClients *bool}: an empty URL or Service is an ErrUsage before any request. UpdateDoorRequest{Service, URL, Title string; Description *string; VisibleToClients *bool}: an empty string is left unchanged, and Description takes &"" to clear it. The door wrapper is sent only when a door field is set.
TypeScriptclient.doors.list(bucketId), get(doorId), create(bucketId, {door, visibleToClients?}), update(doorId, {door?, visibleToClients?}), delete(doorId); Door, CreateDoorRequest, UpdateDoorRequest exported from the root
Rubydoors.list(bucket_id:), get(door_id:), create(bucket_id:, door:, visible_to_clients: nil), update(door_id:, door: nil, visible_to_clients: nil), delete(door_id:)
Pythonthe same keyword shape as Ruby, sync and async
Kotlindoors.list(bucketId), get(doorId), create(bucketId, CreateDoorBody(door, visibleToClients)), update(doorId, UpdateDoorBody(door, visibleToClients)), delete(doorId)
Swiftdoors.list(bucketId:), get(doorId:), create(bucketId:req: CreateDoorRequest(door: CreateDoorPayload(...), visibleToClients:)), update(doorId:req: UpdateDoorRequest(...)), delete(doorId:)
Rustdoors().list(bucket_id), get(door_id), create(bucket_id, &CreateDoorRequestContent { door, visible_to_clients }), update(door_id, &UpdateDoorRequestContent { .. }), delete(door_id)

Also in this PR

  • The shared fixtures in spec/fixtures/doors/ are bc3#14314's documented examples. Door is covered in the fixture manifest.
  • conformance/tests/doors.json has 10 cases, dispatched in all seven runners:
    • every path;
    • the documented create and update requests, asserted as exact whole bodies;
    • a create without visibility;
    • an update of visibility alone;
    • a 404 and a 422 mapped to their codes;
    • a create not retried on 503;
    • a 204 delete.
  • spec/bc3-route-allowlist.yml and spec/bucket-scoped-allowlist.txt:
    • no door waivers: the repin to bc3 6ceece6f69b put the routes in the table;
    • the stale POST /dock/doors registry entry and GET /dock/doors/:id out-of-scope entry are removed, with the redirector's reasoning kept as a comment;
    • the bucket-only list is justified.
  • spec/api-gaps/external-links-doors.md stays partial-coverage:
    • create (now 201 JSON) and update are absorbed;
    • the multipart door[image] thumbnail is the one residual;
    • the redirector stays closed.
  • The new operations are recorded in MIGRATING.md under # Unreleased, and the operation counts are updated in SECURITY.md, SPEC.md and the Rust route-table guarantee.

BREAKING CHANGE (Go only): the generated ClientInterface and ClientWithResponsesInterface gain the five door operations. A hand-written implementation must add them.

Tests, red then green

Each new test was run against origin/main (70c3047d), with only the tests and fixtures copied in, and then on this branch:

LanguageTestsOn origin/mainOn this branch
Go12 in doors_test.gobuild fails: undefined: UpdateDoorRequest (and the rest)12 pass
TypeScript12 in doors.test.ts (13 after review)12 failed13 pass
Ruby11 in doors_service_test.rb (12 after review)NoMethodError: undefined method 'doors'pass
Python12 in test_doors_service.py (13 after review)12 failed13 pass
Kotlin6 in DoorsTest.ktUnresolved reference 'doors' / CreateDoorBody6 pass
Rust4 in tests/services.rsunresolved imports ... CreateDoorPayload, no method named doors4 pass
Swift5 in DoorTests.swiftnot run locally (macOS only); CI runs themCI

A wire-level mutation as well. If the Go wrapper is made to send door on every update (if true { in place of the any-field-set guard), TestDoorsService_UpdateVisibilityAlone goes red with body = map[door:map[] visible_to_clients:true], want only visible_to_clients. Against bc3 that empty wrapper would hit params.require(:door). With the guard restored, the test is green again.

Conformance: the 10 door cases pass in the Go, TypeScript, Ruby, Python, Kotlin and Rust runners. Each runner passes its full suite, with no failures and no door case skipped. The Swift runner is macOS-only, so CI runs it.