Expand description
bynk client (#3508, slice BC1): the typed TypeScript client for a project’s
from http services, one module a front end imports.
The command in bynk/src/http_client.rs reads each route’s facts from the
checked project (the wire-contract peek bynk openapi reads) and hands them
over as an HttpClientInput; this module turns them into the module’s text.
§One codec, one source of truth
Nothing here is a second implementation of the boundary. The codecs are the
ones a Bynk consumer generates for a callee’s types
(serialisation::emit_helpers_for_owner_qualified under a qualifier, which
inlines a transparent refinement’s check and casts an opaque one), and each
call site names them through serialise_expr_via / deserialise_ref_via,
exactly as the foreign-caller client (client.rs, #1970) does. What differs is
the half the codec does not own:
- Optional values are
T | nullin the generated types (the maintainer’s decision on #3508), not Bynk’s taggedOption. The codecs still speakOption, so each boundary type is declared twice: the wire type (__Wire_Order, what a codec produces and consumes) and the public type (Order, what a caller sees), with a generated function per type between them. A type with noOptionreachable has no conversion, and the two are the same shape. - Refinements are checked on the way out by running the decoder over the
value just encoded, so the predicates are the server’s own and a violation is
returned as
CallFailurebefore anything is sent. On the way in the response is decoded by the same codecs. - A route’s answer is a union keyed by status, built from the response set
bynk openapidocuments, and never thrown.
The runtime half is http_client_runtime.ts (generated from runtime/src/client/http_client.ts
by bundle.mjs), inlined: a browser-safe subset
with no signing and no Workers types, plus the runtime’s own result, bytes,
decimal and keys modules for just the names the codecs use.
Structs§
- Client
Error - Why a client cannot be generated.
- Emitted
- The client, and the routes it leaves out with why.
- Http
Client Input - What the command hands the generator.
- Reply
Input - One answer a route can make, in
bynk openapi’s terms. - Route
Input - One route of a service.
- Service
Input - One
from httpservice.
Enums§
- Body
Kind - How a route reads its
body. - Layout
- How the client is laid out.
- Param
Input - What a route takes.
- Reply
Payload - What an answer’s body carries.
Constants§
- DIR_
FILES - The files of a directory layout, in the order they are written.
- SINGLE_
FILE - The file name a single-file client has in
Emitted::files: the caller writes it wherever--outsays.
Functions§
- emit_
http_ client - The module for
input. A route whose types have noT | nullform (anOptioninside aMap,SetorResult, or anOption[Option[T]]) is left out and named, never emitted wrong. - function_
name GET /orders/:idisgetOrderById;POST /ordersispostOrders. A static segment before a parameter is singular (orders/:idreads “order by id”). A route has no name of its own to use (#3508 open question 4).