Repository navigation
Add delete-success, list-query and include-subset overrides - #68
Merged
thomasfosterau merged 3 commits intoAug 15, 2026
Merged
Conversation
`deleteEndpoint` bound its response unconditionally to
`HttpApiSchema.NoContent`, so every delete — hand-written or generated — was
a 204 with an empty body, and `DeleteConfig` was `{ name, path, errors }`
only. Apis whose deletion is a soft delete have something to return: the
tombstone resource document, so a viewer can render what was removed. A
forced 204 breaks that contract on every delete endpoint.
Add an optional `success` schema (and a `status`, for the rare non-200 case)
to `Endpoint.delete`, defaulting to today's `NoContent`. An override is
served as `application/vnd.api+json`, like every other body in the package.
Thread both through `Endpoint.resource` / `Group.resource`'s per-endpoint
`delete` config. Only the response changes; path, params, errors and
middleware are untouched.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HfZHAjtAcZXHMhjvPjCCdS
`list` hard-wired its query to the `Query.schema` composition of its
`include` / `fields` / `sort` / `page` / `filter` options, and `ListConfig`
exposed those features but no way out of the composition. `Query.schema`
nests everything it decodes — `page: { offset, limit }`, `filter: { … }` —
so an api whose list input is a flat struct, or that carries a parameter
JSON:API has no query family for, had no route but `filter[<name>]`: a wire
break on every list endpoint.
Add an optional `query` schema to `Endpoint.list`, defaulting to today's
composition (the feature options are ignored once it is given), mirroring
the `payload` override on create/update. Thread it through
`Endpoint.resource` / `Group.resource`'s per-endpoint `list` config. Only
the query changes; path, success document, errors and middleware are
untouched.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HfZHAjtAcZXHMhjvPjCCdS
`Query.Include` derived `Schema.Literals(dedupe(toResources(r).flatMap((r) => includePaths(r, 2))))` — a boolean over the resource's complete relationship graph — so `?include=` advertised every path the graph reaches at depth 2, including ones the endpoint's resolver was never written for. A to-one relationship on a related resource is enough to surface such a path. Advertising it answers 200 with an empty `included`: worse than the 400 an unknown path already produces. Add `Query.IncludeOptions` — `paths` (an explicit allow-list) and/or `depth` (1/2/3, `paths` winning when both are given) — accepted by `Query.Include` and anywhere `include` was a boolean: `Endpoint.get` / `list` / `related` / `collection` / `polymorphic`, `Query.schema`, and `Endpoint.resource` / `Group.resource` top-level and per endpoint. The literal path type narrows with the runtime set, so an unlisted path fails to compile as well as to decode. `include: true` still derives today's full graph at depth 2. The relationship endpoints' paths are their target's graph rather than the configured resource's, so a constrained top-level `include` reaches them as a plain "on" — constrain those with `Endpoint.related` directly. Adds `Resource.IncludeDepth` and `Resource.IncludePathsTo`, the type-level mirror of `includePaths`' `maxDepth`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HfZHAjtAcZXHMhjvPjCCdS
This was referenced Aug 16, 2026
thomasfosterau
deleted the
claude/effect-jsonapi-handler-overrides-s13y1t
branch
September 15, 2026 07:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three handler-layer overrides for consumers whose contract doesn't match the package's defaults — the follow-on to #61. Each is opt-in, defaults to today's behaviour, threads through
Group.resource's per-endpoint config, and is pinned by a regression test.All three gaps were re-verified against current
main(0.8.0) before implementing.1.
successoverride onEndpoint.delete(fc6c707)deleteEndpointbound its response unconditionally toHttpApiSchema.NoContent, andDeleteConfigwas{ name, path, errors }only — so a soft delete that returns the tombstone resource had no way to say so.The override is served as
application/vnd.api+jsonlike every other body in the package. Without it the endpoint is the 204 it always was.2.
queryoverride onEndpoint.list(aa7784b)listhard-wiredquery: Query.schema(resource, …), which always nests what it decodes (page: { offset, limit },filter: { … }). An api whose list input is a flat struct, or that carries a parameter JSON:API has no query family for, had no route but a bracketedfilter[…]key.page[limit]/page[offset]stay spec-canonical on the wire; the handler sees{ limit, offset, … }flat. Theinclude/fields/sort/page/filteroptions are ignored oncequeryis given. Mirrors thepayloadoverride from #61.3. Constrainable
includepaths (58956ac)Query.Includederived the resource's whole relationship graph at depth 2, so?include=advertised paths whose resolver was never written — answering 200 with an emptyincluded, worse than the 400 an unknown path already gives.pathsand/ordepth(1/2/3;pathswins when both are given), accepted anywhereincludewas a boolean —Endpoint.get/list/related/collection/polymorphic,Query.schema, andEndpoint.resource/Group.resourcetop-level and per endpoint. The literal path type narrows with the runtime set, so an unlisted path fails to compile as well as to decode.include: truestill derives the full depth-2 graph.The relationship endpoints' paths are their target's graph rather than the configured resource's, so a constrained top-level
includereaches them as a plain "on"; constrain those withEndpoint.relateddirectly.New type-level surface —
Resource.IncludeDepth,Resource.IncludePathsTo(over a resource and a depth), andQuery.IncludeOptions/Query.IncludeOption/Query.IncludePathsOf:Query.Includegains a defaulted second parameter for its path set, andEndpoint.GetConfiga defaulted second parameter for the resource it configures — both source-compatible.Verification
pnpm run check(typecheck incl. type-level tests, lint, format, 424 package tests + all three example workspaces) andpnpm run docgen(type-checks and runs every JSDoc example) pass locally. Threeminorchangesets, one per override.🤖 Generated with Claude Code
https://claude.ai/code/session_01HfZHAjtAcZXHMhjvPjCCdS