Skip to content
This repository was archived by the owner on Sep 23, 2026. It is now read-only.

Support GitHub-shaped resources: array pagination, PATCH updates, configurable identity - #7

Merged
michielbdejong merged 1 commit into
mainfrom
claude/github-shape-support
Aug 18, 2026
Merged

michielbdejong merged 1 commit into
mainfrom
claude/github-shape-support

Conversation

@michielbdejong

Copy link
Copy Markdown
Contributor

What

Three changes so a generic, document-driven client can sync a GitHub-shaped API (issues + comments), each closing one of the feature requests filed earlier. All are backward compatible — the existing id-keyed, PUT-updating, enveloped-list behaviour is unchanged.

1. Top-level-array list responses paginate correctly — closes #6

fetchAllItems only extracted items from an envelope when a scheme applied, so a bare-array response ([ {...}, {...} ]) collected zero items even while walking Link-header pages. It now treats a top-level array body as the page's items, mirroring the non-paginated path. This is the shape of GitHub's GET /…/issues and …/comments.

2. Updates use PUT or PATCH per the document — closes #5

attemptWrite hardcoded PUT. ResourceRoute now carries an updateMethod derived at discovery time: PUT when the item path declares a put (replace), otherwise PATCH. GitHub exposes no PUT for issues/comments; Google Calendar (which declares put) is unchanged.

3. Configurable identity field — closes #4

New identityField client option (default id), used for local storage keys, create-response reconciliation, and the item-URL path value. GitHub issues are addressed by number, not the global id in the payload. Reflector already derives this field from its crud-causality overlay and can now pass it through.

Tests

  • New __tests__/unit/client/github-shape.test.ts — a GitHub-shaped document + fake fetch proving: a bare-array list paginates across a Link header keyed by number; a create reconciles onto the server-assigned number; an update is sent as PATCH and never PUT.
  • discover tests for PUT-vs-PATCH selection.
  • Full suite green (103 tests), lint and prettier clean.

Follow-on

Unblocks Reflector pointing its generic flow at GitHub issue trackers (localthought/reflector#23, #25, #27, #28). Reflector will bump its pinned syncables dependency to include this and pass identityField from the overlay's identity binding.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BdadF8jAvK2e8Fmis3hLJF


Generated by Claude Code

…figurable identity

Three changes a GitHub Issues client needs that the generic path didn't cover:

- Paginated reads now treat a top-level-array response body as the page's
  items (mirroring the non-paginated path), instead of only looking inside an
  envelope — so a bare-array list with Link-header pagination collects items
  across pages instead of coming back empty. (#6)

- Background updates send the method the item path declares: PUT when the path
  offers a put (replace), otherwise PATCH. GitHub exposes no PUT for issues or
  comments, so updates must be PATCH. Derived from the document at discovery
  time; PUT-declaring resources (e.g. Google Calendar) are unchanged. (#5)

- A resource's identity field is configurable via `identityField`
  (default `id`), used for local storage keys, create reconciliation, and the
  item-URL path value. GitHub issues are addressed by `number`, not the global
  `id` the payload also carries. (#4)

Adds a GitHub-shaped end-to-end test covering all three, plus discover tests
for PUT/PATCH selection. Existing behaviour (id-keyed, PUT updates, enveloped
lists) is unchanged; full suite green (103 tests), lint and prettier clean.

Closes #4
Closes #5
Closes #6

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BdadF8jAvK2e8Fmis3hLJF
@michielbdejong
michielbdejong merged commit fbb8f19 into main Aug 18, 2026
2 checks passed
@michielbdejong
michielbdejong deleted the claude/github-shape-support branch September 21, 2026 15:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

2 participants