feat(ts): protocol RPC shape — IR_HASH, params, error unions, async - #5
Merged
Conversation
The TypeScript `code` generator moves past bare method stubs toward the
Rust generator's surface (no runtime to link against yet, so this is the
typed layer only):
- `export const IR_HASH` (bigint) per file with a protocol — the same
canonical `schema_ir_hash` digest the Rust side emits, so a TS peer
and a Rust peer agree.
- `error` declarations -> `export interface`.
- `<Proto><Fn>Params` interface per function that takes arguments; the
method takes one `params` object.
- Discriminated-union error types from each `!` — per function
(`<Proto><Fn>Error`) and a per-protocol `<Proto>Error` — every arm
`{ code: <ordinal>; name; data }`, keyed by the schema-global error
ordinal. `@throws` in the method's JSDoc. A `!` on a one-way call is
dropped.
- Every method returns `Promise<T>`; a one-way / `-> ()` call is
`Promise<void>`.
- `u128` / `i128` / `s128` -> `bigint` (were leaking through unmapped);
`KindValue::Unit` -> `void`.
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.
Moves the TypeScript
codegenerator past bare method stubs toward the Rust generator's surface. No TS runtime to link against yet, so this is the typed layer only:export const IR_HASH(bigint) per file with a protocol — the same canonicalschema_ir_hashdigest the Rust side emits (theprotocolconformance fixture's value now matches the Rust golden's exactly).errordeclarations →export interface.<Proto><Fn>Paramsinterface per function with arguments; the method takes oneparamsobject.!— per function and a per-protocol union — every arm{ code: <ordinal>; name; data }, keyed by the schema-global error ordinal;@throwsin the method JSDoc. A!on a one-way call is dropped.Promise<T>; one-way /-> ()→Promise<void>.u128/i128/s128→bigint(were leaking through unmapped);Unit→void.Goldens re-blessed in a companion generation PR. Next increments: a TS runtime package, then
<Proto>Client/ dispatcher, thenlibmode.