covenix / generateTypeScriptClient
Function: generateTypeScriptClient()
generateTypeScriptClient(
contract,options?):string
Defined in: src/generator/contract-client.ts:55
Generates a standalone TypeScript client from a CovenixContract. The output is a single self-contained module — types reconstructed from the contract's schema nodes plus a small inlined fetch runtime — so a frontend imports one file with no covenix dependency.
Operations are grouped by their first tag (api.users.get(...)); untagged operations sit at the client root. Each method returns the success body and throws a CovenixClientError on a non-2xx response; method.raw(...) returns a status-discriminated { status, body, headers } union (the headers is a standard Headers object) for exhaustive handling and response-header access.
Descriptions (.describe() / .meta({ description })) and operation summaries become JSDoc on interfaces, fields, and methods. By default the client is types-only; pass { validate: 'zod' } for a client that validates and parses requests/responses at runtime (and revives z.date() to Date).
Parameters
contract
The contract to generate from (e.g. from generateContract).
covenixContract
"0.1" = ...
info
{[key: string]: unknown; title: string; version: string; } = ...
info.title
string = ...
info.version
string = ...
operations
object[] = ...
schemas
Record<string, SchemaNode> = ...
options?
Generation options (e.g. { validate: 'zod' }).
Returns
string
TypeScript source for the client module.
