Skip to content

Example: a Transport over axios, run through the conformance suite - #64

Merged
jallers merged 2 commits into
masterfrom
claude/axios-example
Nov 26, 2026
Merged

jallers merged 2 commits into
masterfrom
claude/axios-example

Conversation

@jallers

@jallers jallers commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

One commit. Nothing in the published package changes: examples/ is not shipped, and axios is a dev dependency of the repository, used by this example alone. The package still has no runtime dependency.

What it adds

examples/11-axios-transport.ts, for an app that already talks HTTP through an axios instance and wants the SDK to use the same one. Two parts, each meant to be copied:

  • createAxiosTransport(http): the SDK's Transport over an axios instance whose baseURL is the Agility instance. It sends a body in the shape the SDK's rules give it (not axios's own guess), reads the response as asked, reports a refusal with apiErrorFromResponse so its errors are word for word the built-in transport's, and maps a cancel, a lost connection and a timeout to ABORTED, NETWORK_ERROR and TIMEOUT.
  • adapterFor(server): an axios adapter that makes the conformance suite's server axios's network, so the checks exercise axios itself (its header handling, its URL building, validateStatus) rather than a mock of it. It settles the response itself by validateStatus; without that, a 304 and a refusal would pass the suite for the wrong reason.

The example then runs transportConformance against the transport and prints the count. In a test file the last lines become for (const check of checks) it(check.name, check.run).

The adapter is a consumer's, contributed after the suite caught a real bug in that consumer's own axios transport on its first run (an empty body under responseType: "json" must resolve undefined). The transport here is written for this example.

Also: AGENTS.md names client.search and client.deleted among the client's reads, which the alpha.9 pull request did not add.

Things a reviewer should know

  • The first dev dependency that is not build or test tooling. It is confined to one example; publicTree, layers and the packaging tests are unaffected, and package.json's files still ships dist and the changelog only.
  • The example needs no instance and no credentials, so it also runs in the integration tier's examples suite wherever that runs.
  • The suite has no check for a timeout. What a custom transport owes about timing is an open design question, not settled here; this transport reports axios's own timeout as TIMEOUT so the client's resend rule recognises it.

Verification

  • npm run verify: 249 unit tests in 32 files, all passing; the type-check compiles the example against the source.
  • node examples/11-axios-transport.ts: 9 of 9 conformance checks pass (axios 1.21.1).
  • The examples suite of the integration tier, against the API-testing instance: 12 passed (eleven examples and the listing check).

Generated by Claude Code

createAxiosTransport is the SDK's Transport over an axios instance;
adapterFor makes the suite's server axios's network, so the nine checks
exercise axios itself. axios is a dev dependency for this example only.
AGENTS.md names client.search and client.deleted among the reads.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rgicmffzzwb2CzyeDSEhBm
@jallers
jallers merged commit 4678a95 into master Nov 26, 2026
4 checks passed
@jallers
jallers deleted the claude/axios-example branch November 26, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants