Skip to content

feat(host-api,host-container): scaffold @parity/truapi migration#175

Draft
pgherveou wants to merge 2 commits into
mainfrom
feat/truapi-migration
Draft

feat(host-api,host-container): scaffold @parity/truapi migration#175
pgherveou wants to merge 2 commits into
mainfrom
feat/truapi-migration

Conversation

@pgherveou
Copy link
Copy Markdown
Collaborator

Draft. Companion to paritytech/truapi#77.

Summary

Adds @parity/truapi (and @parity/truapi-host for host-container) as dependencies and introduces directional facade files alongside the existing transport and container code. The existing surfaces remain in place to avoid breaking downstream consumers; the migration is staged in MIGRATION.md next to each package.

  • packages/host-api/src/truapi-transport.ts: thin facade exposing a @parity/truapi TrUApiTransport built on the legacy Provider.
  • packages/host-container/src/truapi-container.ts: thin facade calling createTrUApiServer(provider, handlers) from @parity/truapi-host. Requires the caller to supply a fully populated TrUApiHostHandlers; the TypeScript compiler enforces completeness rather than papering over missing implementations with stubs that would throw at runtime (@parity/truapi-host requires handlers to express every outcome as a typed return).
  • MIGRATION.md in both packages: punch list for completing the swap (handshake retry, multiplexer removal, legacy codec re-export, lifting each handleXxx slot into a typed handler).

Status

  • All 443 existing tests pass.
  • npm run build:lib, npm test, npm run lint all green.
  • The existing transport.ts (488 lines) and createContainer.ts (1118 lines) are unchanged. The work to lift them onto the new packages is captured in MIGRATION.md.

Dependencies

The @parity/truapi / @parity/truapi-host deps currently point at a local truapi worktree via file:../../../truapi/.claude/worktrees/issue-54-truapi-host/js/packages/..., because:

Once paritytech/truapi#77 merges and a 0.2.0 release ships, these can be flipped to the published versions in a follow-up.

Out of scope for this draft

  • The actual rewrite of transport.ts and createContainer.ts. Both stay untouched here so the change is reviewable and downstream packages keep working unchanged.
  • Byte-equivalence fixtures against @novasamatech/host-api@0.7.7.
  • Removing the @novasamatech/host-api dep from host-container (still in use by the legacy code path).

Test plan

  • npm install (refresh file: deps)
  • npm run build:lib — all 13 nx projects build
  • npm test — 443/443 pass
  • npm run lint — all 14 projects lint clean
  • npx tsc --noEmit in both packages/host-api and packages/host-container

Refs paritytech/truapi#54.

pgherveou added 2 commits May 14, 2026 16:15
Adds `@parity/truapi` (and `@parity/truapi-host` for `host-container`)
as dependencies and introduces directional facade files alongside the
existing transport and container code. The existing surfaces remain in
place to avoid breaking downstream consumers; the migration is staged
in `MIGRATION.md` next to each package.

- packages/host-api/src/truapi-transport.ts: thin facade exposing a
  `@parity/truapi` `TrUApiTransport` built on the legacy `Provider`.
- packages/host-container/src/truapi-container.ts: thin facade calling
  `createTrUApiServer(provider, handlers)` from `@parity/truapi-host`,
  with "Not Implemented" defaults until each `handleXxx` slot is lifted
  across.
- MIGRATION.md in both packages: punch list for completing the swap
  (handshake retry, multiplexer removal, legacy codec re-export, etc.).

Dependencies are pinned via `file:` paths to a local truapi worktree
while `@parity/truapi@0.2.0` is unreleased; switch to the published
version once it ships.

Refs paritytech/truapi#54.
`@parity/truapi-host` now requires handlers to express every outcome
as a typed return value, including unsupported wire versions and
missing implementations, and exposes `ObservableLike<Item, Reason>` as
the subscription handler return type (the previous `SubscriptionSink`
parameter shape is gone).

The `defaultHandlers()` Proxy in this file produced throwing stubs
that satisfied the type system via `any` but would have broken the
runtime contract: throwing out of a request handler hangs the client,
and a throwing subscription handler doesn't return an `ObservableLike`
for the dispatcher to subscribe to.

Drop the defaults entirely and require the caller to supply a full
`TrUApiHostHandlers`. The TypeScript compiler now flags any missing
service at the call site, which is the right enforcement point for a
migration that lifts each `handleXxx` slot across one at a time.
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