Skip to content

docs(api): type-check the endpoint examples against typed fixtures - #199

Merged
truthixify merged 3 commits into
wraith-protocol:developfrom
aratass:docs/191-typed-api-endpoint-examples
Oct 17, 2026
Merged

truthixify merged 3 commits into
wraith-protocol:developfrom
aratass:docs/191-typed-api-endpoint-examples

Conversation

@aratass

@aratass aratass commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Closes #191.

Summary

check-snippets.ts renders every fence with // @ts-nocheck, so the endpoint examples were only syntax-checked, and five of them were skipped with no-check. The shape fences without no-check only passed because TypeScript parsed { id: string; ... } as a block of labelled statements.

  • Page. Every TypeScript fence in api-reference/endpoints.mdx is now real TypeScript. Request and response shapes are named interfaces (CreateAgentRequest, AgentInfo, ChatResponse, Message, NotificationList, ApiError, ...), and the error samples are typed ApiError values. No no-check fence is left on the page.

  • Examples. New copy-paste examples for authentication (a fetch client that sends Authorization: Bearer and the optional BYOM headers), requests (create agent with a Stellar-signed ownership message, chat with conversationId), pagination and error handling (WraithApiError with statusCode, a 404 name lookup). They build on each other in page order. The list endpoints take no page or cursor parameters (none are documented, the SDK client sends none, and the spectre controllers return full arrays), so the pagination example pages on the client instead of inventing query parameters.

  • Gate. scripts/check-api-examples.ts, chained into check:snippets so the existing CI job runs it:

    1. Compiles all of the page's TypeScript fences, in page order, as one module with strict: true against the installed SDK, Stellar SDK and Node types. No @ts-nocheck, no any prelude.
    2. Compiles each fixture in scripts/fixtures/api-endpoint-responses.json with satisfies <type> against the interface the page declares for that response.
    3. Runs the examples offline against a fetch stub that serves those fixtures. Each request must hit a route documented on the page, send the bearer header, and consume the next fixture for its method and path. Every fixture must be used.

    Failures point back to the MDX line or the fixture entry. docs/CONTRIBUTING.md documents the check.

Verification

  • pnpm check:snippets (TS fences skipped with no-check drop from 14 to 9), check:api-examples, check:snippets-extended, check:placeholders, check:nav-coverage, check:contract-registry, check:compatibility-matrix, check:redirects-and-anchors, test:redirects-and-anchors and node localization-qa.cjs all pass.
  • Negative runs, each failing with a mapped location: a wrong property in an example (agent.chains), a fixture missing metaAddress or carrying an extra field, a role outside the Message union, an undocumented path, a dropped Authorization header, an unused fixture, and a no-check fence on the page.

Note

The wire AgentInfo on this page (chain, address, metaAddress) matches what the spectre controllers return. The SDK's exported AgentInfo type uses chains, addresses and metaAddresses. This PR keeps the documented wire shape and does not touch the SDK.

Every TypeScript fence in api-reference/endpoints.mdx now compiles as one strict
module, in page order, through scripts/check-api-examples.ts (chained into
check:snippets, so CI runs it). The shape fences become named interfaces, and
the page gains authentication, request, chat, pagination and error-handling
examples. The examples run offline against typed response fixtures in
scripts/fixtures/api-endpoint-responses.json, compiled with `satisfies <type>`.
No no-check fences remain on the page.

Closes wraith-protocol#191
@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@aratass Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@truthixify truthixify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API example checker compiles 21 strict TypeScript fences and validates all typed fixtures. Approved.

@truthixify
truthixify merged commit 3d5f66c into wraith-protocol:develop Oct 17, 2026
7 checks passed
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.

[Wave 10] Type-check the API endpoint examples

3 participants