What is Golem
Choose the Golem package you need and see how the parts work together.
Which package you need
Each generator installs on its own and runs through the same golem command and golem.yaml file. The command and its configuration file are named golem. The packages are published under @exprtlabs.
| You have | Feature and package | You get |
|---|---|---|
| TypeScript fields and app behavior | Objects and models: @exprtlabs/golem-model | Validation, JSON conversion and a model<T>() base for your class |
| An OpenAPI document | OpenAPI to TypeScript SDK: @exprtlabs/golem-openapi-ts | Typed operations, request and response models |
| TypeScript controllers, with NestJS as the supported framework | TypeScript to OpenAPI: @exprtlabs/golem-ts-openapi | An OpenAPI document from routes and types |
| An OpenAPI document and app models | golem-openapi-ts and golem-model | App models that reuse the SDK's types |
NestJS is not required. Every generated model and client imports the runtime package @exprtlabs/golem (packages).
IObject or IModel
An IObject declares fields whose values stay plain objects. An IModel is an IObject whose class extends model<T>() from @exprtlabs/golem/model to add methods (Define models).
How it works
task.model.ts
export type TTask = IModel<{ title: string & MinLength<1>; due: Date;}>;Generated check
typeof v.title === "string" && codePointLength(v.title) >= 1typeof v.due === "string" && isDateTime(v.due)→ .golem/models/models.validators.generated.tsYour code, after a build tool
parse<TTask>(text)requireObjectCodec("TTask_…").parse(text)- The TypeScript type checker reads your
IObjectandIModeldeclarations, including tags such asMinLength<3>,TValidationandTSerde. - Golem compiles each type and its tags directly to validator IR and writes TypeScript validators in
models.validators.generated.tsinside theoutputfolder of themodelblock (default.golem/models/). - Golem writes all generated codec files inside
.golem/models/, keeping yoursrc/folder free of generated files. - When you build or load your code, a build tool rewrites
model<T>()and calls such asparse<T>to that generated code:golem build, the Vite or esbuild plugin, or the Node loader (Build tools).
How each generator uses these steps
| Generator | Reads | Then |
|---|---|---|
@exprtlabs/golem-model | Your IObject and IModel declarations | Runs steps 1 to 3. A build tool runs step 4. |
@exprtlabs/golem-openapi-ts | An OpenAPI 3.1 or 3.2 document | Resolves its $refs across local files and the HTTPS hosts you allow, and checks it against the official OpenAPI schema and the cross-field rules of the specification. It reads the rules from the document's schemas, not from TypeScript types, and writes the typed SDK in its own output folder. A standalone SDK also gets its own validators. For a golem SDK, the models job writes them with your models (SDK modes). |
@exprtlabs/golem-ts-openapi | TypeScript controllers, with NestJS as the supported framework, and their types, without starting the app | Runs step 1 on the types of each route, then writes an OpenAPI document. With the nest extension, step 4 also adds the decorators that NestModelInterceptor reads to convert bodies, queries and returns. |
What you need
Golem supports the Node.js and TypeScript versions in Compatibility. Validation is on and MobX is off by default.
