testing/cross_backend/cross_rpc.ts

JSON-RPC call-site primitives for the cross-backend suites.

The stateful suites (the cell verbs, account lifecycle, role grants, tokens, facts, audit reads) POST raw JSON-RPC envelopes over a cross-process FetchTransport, threading ids and auth headers across calls, and parse every success result against the verb's declared Zod output schema — the wire-shape parity gate. A TS↔Rust envelope drift, not just a payload field drift, fails the assertion.

view source

Declarations
#

4 declarations

cross_rpc_call
#

testing/cross_backend/cross_rpc.ts view source

(transport: FetchTransport, path: string, method: string, params: unknown, headers: Record<string, string>): Promise<RpcResult> import {cross_rpc_call} from '@fuzdev/fuz_app/testing/cross_backend/cross_rpc.js';

POST a JSON-RPC call over a cross-process FetchTransport with the given auth headers. Distinct from testing/rpc_helpers.ts's app-based rpc_call: this variant drives the cookie-jar FetchTransport the cross-backend harness spawns against, and returns the slim RpcResult the suites read.

transport

the transport to send on

path

the RPC endpoint path

type string

method

the JSON-RPC method

type string

params

the request params

type unknown

headers

auth and other headers, merged over the JSON defaults

type Record<string, string>

returns

Promise<RpcResult>

the response's HTTP status, ok, result and error

throws

  • Error - when the reply is not a JSON object — naming the method, the HTTP status and the head of the body, so a proxy page or a crash reads as what it is

error_reason
#

expect_output
#

testing/cross_backend/cross_rpc.ts view source

<T>(r: RpcResult, schema: ZodType<T, unknown, $ZodTypeInternals<T, unknown>>): T import {expect_output} from '@fuzdev/fuz_app/testing/cross_backend/cross_rpc.js';

Assert the call succeeded and the result matches the verb's declared output schema — the wire-shape parity gate. Returns the parsed output.

r

schema

type ZodType<T, unknown, $ZodTypeInternals<T, unknown>>

returns

T

generics

expect_output<T>
T

RpcResult
#

testing/cross_backend/cross_rpc.ts view source

RpcResult import type {RpcResult} from '@fuzdev/fuz_app/testing/cross_backend/cross_rpc.js';

Minimal JSON-RPC envelope shape the suites read off responses.

status

The HTTP status the reply carried.

type number

readonly

ok

type boolean

readonly

result?

type unknown

readonly

error?

type { readonly code: number; readonly message: string; readonly data?: unknown; }

readonly

Depends on
#

Imported by
#