feat(host-api,host-container): scaffold @parity/truapi migration#175
Draft
pgherveou wants to merge 2 commits into
Draft
feat(host-api,host-container): scaffold @parity/truapi migration#175pgherveou wants to merge 2 commits into
pgherveou wants to merge 2 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft. Companion to paritytech/truapi#77.
Summary
Adds
@parity/truapi(and@parity/truapi-hostforhost-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 inMIGRATION.mdnext to each package.packages/host-api/src/truapi-transport.ts: thin facade exposing a@parity/truapiTrUApiTransportbuilt on the legacyProvider.packages/host-container/src/truapi-container.ts: thin facade callingcreateTrUApiServer(provider, handlers)from@parity/truapi-host. Requires the caller to supply a fully populatedTrUApiHostHandlers; the TypeScript compiler enforces completeness rather than papering over missing implementations with stubs that would throw at runtime (@parity/truapi-hostrequires handlers to express every outcome as a typed return).MIGRATION.mdin both packages: punch list for completing the swap (handshake retry, multiplexer removal, legacy codec re-export, lifting eachhandleXxxslot into a typed handler).Status
npm run build:lib,npm test,npm run lintall green.transport.ts(488 lines) andcreateContainer.ts(1118 lines) are unchanged. The work to lift them onto the new packages is captured inMIGRATION.md.Dependencies
The
@parity/truapi/@parity/truapi-hostdeps currently point at a local truapi worktree viafile:../../../truapi/.claude/worktrees/issue-54-truapi-host/js/packages/..., because:@parity/truapi-hostdoes not exist on npm yet (introduced in feat(truapi-host): add host-side codegen and @parity/truapi-host package truapi#77).@parity/truapi@0.2.0(which exposes the new subpath exports and host-aware codegen output) is also unpublished.Once paritytech/truapi#77 merges and a
0.2.0release ships, these can be flipped to the published versions in a follow-up.Out of scope for this draft
transport.tsandcreateContainer.ts. Both stay untouched here so the change is reviewable and downstream packages keep working unchanged.@novasamatech/host-api@0.7.7.@novasamatech/host-apidep fromhost-container(still in use by the legacy code path).Test plan
npm install(refreshfile:deps)npm run build:lib— all 13 nx projects buildnpm test— 443/443 passnpm run lint— all 14 projects lint cleannpx tsc --noEmitin bothpackages/host-apiandpackages/host-containerRefs paritytech/truapi#54.