@exprtlabs/golemRuntime, CLI and build tools
Every generated model and client imports it. It holds parse, stringify, the CLI, the build tools and the optional integrations.
One toolchain for a TypeScript app's API contract, end to end. Models, validation, JSON conversion, OpenAPI documents and a typed SDK come from the types you already write.
export type TTask = IModel<{ title: string & MinLength<1>; done: boolean; priority: number & TSerde<typeof toPriorityWord, typeof fromPriorityWord>;}>;Start from what you have: TypeScript types, an OpenAPI document or server controllers. Each generator installs on its own. All of them run through the same golem command and read the same golem.yaml.
@exprtlabs/golemEvery generated model and client imports it. It holds parse, stringify, the CLI, the build tools and the optional integrations.
@exprtlabs/golem-modelYou get validation and JSON conversion for your models. Your class extends model<T>() and keeps its methods.
@exprtlabs/golem-openapi-tsYou get typed operations and request and response models. The client checks what it sends and what it receives.
devDependencies; dependencies with MobX@exprtlabs/golem-ts-openapiYou get an OpenAPI document from controller routes and types. It reads NestJS 11 controllers without starting the app.
devDependencies; dependencies with NestJSWhich package you need · Quick start
Tags on a field type set its validation and its JSON form. You write no decorators, no schema language and no second copy of the fields. Your code sees the plain type.
name: string & MinLength<2>Golem compiles validators directly into TypeScript files under .golem/models/. Nothing reads decorator metadata at runtime. Validation is on by default, and a valid value takes the fast path.
validation: true # defaultGolem rejects bad input and never coerces it. A model refuses unknown fields and any. A format that Golem cannot check stops generation.
LibError { causedByInput: true }A serde tag ties a field to two functions. Your code keeps a number, a Temporal date or minor units. The JSON holds a word, an ISO string or decimal text.
TSerde<typeof to, typeof from>Golem writes generated files into .golem/models/, leaving src/ clean. Your class extends model<T>() with zero imports from generated files.
class Task extends model<TTask>()Server controllers produce the OpenAPI document. The client generator turns that document back into typed operations and models for the web app.
controllers → openapi → clientA job writes over a file only when it owns that file. Any other file at that path stops the run. golem check writes nothing and fails on stale output.
npx golem checkA build tool rewrites model<T>(), parse<T>() and the other serde calls to generated code. Use golem build, the Vite plugin, the esbuild plugin or the Node loader.
npx golem buildDefine models · Validation tags · Serialization · Build tools
Every integration is optional. Golem works with any mix of them, or with none. Each one is a subpath of the runtime package or a job in golem.yaml.
@exprtlabs/golem-ts-openapi/nestThe model interceptor converts and checks @Body() and @Query() models, and answers bad input with HTTP 400 (a default; your own interceptor can answer otherwise). A docs job writes the OpenAPI document, and the nest extension turns on the build rewrite that the interceptor needs.
@exprtlabs/golem-openapi-ts/mobxWith the mobx extension, validators keep observable form state, and client operations have an observable loading. asGenObservable makes generated fields observable.
@exprtlabs/golem/viteAdd golem() to plugins. The plugin rewrites serde calls in the dev server and in the build.
@exprtlabs/golem/esbuildAdd golem() to plugins. The plugin rewrites serde calls when esbuild bundles your app.
node --import @exprtlabs/golem/registerRun TypeScript files directly. The loader rewrites serde calls as Node.js loads each file.
"golem": { "block": "…" }A package exports generate(context) and returns files. Golem writes them. Your package registers its own golem.yaml block.
NestJS · MobX and React · Build tools · Write a generator
A generated client and your server share one contract. Each side checks the data that crosses to it. On any server, parse<T> and validate<T> do the server check. With NestJS, the model interceptor does it for you.
server/api/openapi.yaml. The web app generates its client from that file, with MobX on. Amounts travel as decimal strings, so no float carries money.Install the runtime and the generator for your starting point:
npm install @exprtlabs/golem
npm install --save-dev @exprtlabs/golem-model typescript@~7.1.0-betanpm install @exprtlabs/golem
npm install --save-dev @exprtlabs/golem-openapi-ts typescript@~7.1.0-betanpm install @exprtlabs/golem
npm install --save-dev @exprtlabs/golem-ts-openapi typescript@~7.1.0-betaThen add its job to golem.yaml:
version: 1
model: {}- input: provider/provider.yaml
output: provider/sdk
name: Providerts-openapi:
docs:
- output: ./api/openapi.yaml
info:
title: Payments API
version: '1'
globalPrefix: api
extensions:
nest: {}Run npx golem generate for your editor, then npx golem build to compile. The quick start takes one model from declaration to a running app.
Each tag is a TypeScript type. Golem turns it into a check in the validator, a constraint in the OpenAPI document and a check in the client.
Validation tags · Validate models
Golem reads the types you already write and generates each piece from them. You keep one declaration for each model.
| Job | How Golem does it |
|---|---|
| Classes from JSON | parse<Task>(text) |
| Validation | tags on the field type |
| Your own JSON forms | a serde tag on the field type |
| OpenAPI from NestJS | read from the controller's types |
| OpenAPI to TypeScript SDK | typed operations with validated models |
The configuration format and the public subpaths of @exprtlabs/golem follow semver (Compatibility).