Skip to content

docs: verify and update README examples for latest releases #387#391

Closed
NiKrause wants to merge 6 commits intostoracha:mainfrom
NiKrause:clean/readme-examples-387
Closed

docs: verify and update README examples for latest releases #387#391
NiKrause wants to merge 6 commits intostoracha:mainfrom
NiKrause:clean/readme-examples-387

Conversation

@NiKrause
Copy link
Contributor

@NiKrause NiKrause commented Oct 8, 2025

Fixes the #387 Issue with:

  • Test all examples and code snippets in READMEs.
  • Check if they are updated as per latest version.
  • If not, update them to reflect current API.
  • Add any missing examples and improve the documentation.

The examples in the Readme (main, client, server README) were updated to latest API version and tests added accordingly
Test coverage should be 100% and Readme was restructured starting with client implementation

Comments from this PR were respected: #388
e.g. "Note: in tests, you don't even need a HTTP server running - a Ucanto server is a channel, so you can pass it to the client as the channel to use." and

"IMHO the README should shown how to use the library against an already running server - i.e. just the code you'd need to use the client. I'd link to the server README for actually setting up and running a server component."

Fixes #387

- Update ed25519.Signer.parse/ed25519.Verifier.parse to ed25519.parse()
- Fix capability invocation structure to use nb: { link: ... } format
- Fix typos and variable name inconsistencies
- Add missing proofs parameter to invocations
- Fix server reference in HTTP listener example
- Add missing await keyword for async operations
- Update service handler to properly access context.store

All examples now work with:
- @ucanto/server v11.0.0
- @ucanto/client v9.0.1
- Latest @ucanto/principal API

Verified with successful build and test runs.
Addresses issue #387 by adding tests for README code snippets.

Tests verify that:
- README examples use correct ed25519.parse() API (not deprecated APIs)
- Capability definitions work with current API
- Service definitions with provide() work correctly
- Client invocations have correct structure

These tests ensure README examples stay up-to-date with API changes
and prevent regressions in documentation code.
- Add packages/server/test/readme-full-integration.spec.js with full end-to-end tests
- Test 1: Complete workflow integration with server-as-channel pattern
  * Capability definition with custom file/link capability
  * Service handler using Server.provide() pattern
  * Server setup with CAR codec and authorization
  * Client connection using recommended server-as-channel approach
  * Full invocation execution and result validation
  * Data store verification to ensure handler execution
- Test 2: Delegation example with proof-based invocations
  * Capability delegation between users (Alice → Bob)
  * Proof-based invocation workflow
  * URI path hierarchy validation
  * Complete delegation and execution flow
- Uses proper Schema.struct() for nb field validation
- Implements correct derives function with URI path constraints
- Includes canIssue authorization logic for DID-based file access
- Validates complete data flow from definition to storage
- Achieves 100% README example coverage

Resolves #387: test all examples and code snippets in READMEs
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.

1 participant