Files
Spike Curtis 9a29aab2ee feat: add include_related option to client.Workspace in codersdk (#29540)
Part of the lite `codersdk.Workspace` work
([GRU-82](https://linear.app/codercom/issue/GRU-82),
[RFC](https://app.notion.com/p/coderhq/Lite-Workspace-API-Requests-3aad579be5928060b5e7cc65c539717f)).
Stacked on #29539, which wired `include_related` into `GET
/api/v2/workspaces/{workspace}`.

Adds `include_related` support to the `codersdk` client, expressed with
the typed selection tree so only supported selections are representable:

- Moves the `wsrelated` package from `coderd/` to `codersdk/` so both
the server and the client can share `wsrelated.Config`. `coderd` already
depends on `codersdk`, so this only changes import paths on the server
side.
- Adds `Config.QueryParam`, which encodes a selection into the
`include_related` value: the dotted path of each selected node that has
no selected descendants. Selecting a node implies its ancestors, so
`Parse` round-trips the result back into an equal `Config` (covered by a
round-trip test).
- `WorkspaceOptions` gains `IncludeRelated *wsrelated.Config`. A nil
value omits the parameter (server returns everything, unchanged); a
non-nil value is encoded via `QueryParam`, and a zero `Config` loads
only the workspace.
- `Client.Workspace` now accepts optional `WorkspaceOptions`, backward
compatible with existing `client.Workspace(ctx, id)` calls.

### Testing

- `codersdk` internal test asserts `WorkspaceOptions.asRequestOption`
sets `include_related` from the selection, following the existing
`WorkspaceFilter` test pattern rather than spinning up a server.
- `wsrelated` tests cover `QueryParam` output and a `Parse`/`QueryParam`
round trip.

`make gen` regenerated the `WorkspaceOptions` TypeScript type. Because
the wire representation of `include_related` is a comma-separated
string, `scripts/apitypings` maps `wsrelated.Config` to `string` in
TypeScript, so `include_related?: string` rather than a nested object
the frontend cannot serialize. `api.getWorkspace` already forwards
`WorkspaceOptions` as query params, and a frontend test in `api.test.ts`
confirms `include_related` is sent through.

---

*Generated by Coder Agents on behalf of @spikecurtis.*
2026-09-21 11:53:11 +02:00
..
…

APITypings

This main.go generates typescript types from the codersdk types in Go.

Uses it's own go.mod to exclude goja deps from the main go.mod.