Pular para o conteúdo principal

@conexus/client

The typed client of the Hub's operations.

Owner. How a program outside the server calls the Hub: the address, the send, the reply parse and the failure. The operations themselves belong to @conexus/hub-api; this package keeps no second copy of them (code C28).

What it has​

FileOwns
src/client.tscreateHubClient: the injectable transport, the deadline, the send and the reply parse
src/request.tsWhat a call is given and gives, typed from an operation; the address
src/failure.tsHubFailure and how a reply or a Problem body becomes one

What it does not have​

  • No generated code: the types come from the Zod operations.
  • No cache and no query keys. TanStack Query's bindings are the web's, in apps/web/src/platform/hub.ts.
  • No sentence a person reads, no Better Auth client and no sign-in of its own.
  • No retry: a write whose end is not known is the caller's to send again, with the same attempt key (code C37).
  • No @mastra/client-js: a program that talks to Mastra uses that library directly.
  • It is not published: exports points at .ts source 0003.

Exports​

Only .: createHubClient, HubFailure, failureOfProblem, and the types HubClient, HubClientOptions, CallOptions, CallVariables, RequestParts and Output.

const hub = createHubClient({ baseUrl: 'https://hub.example.com', fetch: ownFetch })
const { companies } = await hub.call(listCompanies, { query: {} })

baseUrl is the Hub's origin. fetch is optional and defaults to globalThis.fetch, read at each call. credentials defaults to same-origin. A runtime that signs in without cookies adds its headers in its own fetch.

Consumers​

apps/web, through apps/web/src/platform/hub.ts alone (dependency-cruiser, web-calls-the-client-only-from-hub).

Invariants​

  • A call ends in the operation's success body, parsed by its schema, or in a thrown HubFailure.
  • outcomeUnknown is false only when a whole Hub answer settles what happened: its Problem row says settles.
  • A send does not validate what it is given: the operation's types check it at compile time and the Hub at run time. A number in params or query goes into the address as text.
  • A call has a 10 s deadline over the whole answer unless it names another, or null.