Release notes
Read the highlights of each Golem release.
1.2.0
Golem 1.2.0 replaces generated *BaseModel imports with model<T>(), moves every generated model file into .golem/models/, drops TypeScript 6, and compiles model validators directly to validator IR. Breaking marks a change against 1.1.x.
- Breaking: Zero-import
model<T>()HOC. Extendmodel<TTask>()from@exprtlabs/golem/modelinstead of importing a generated*BaseModelclass (export class Task extends model<TTask>() { ... }). Build tools rewritemodel<T>()to a runtime base call plus a side-effect import of the generated codec. Callingmodel<T>()without a build tool throwsLibErrorof kindValidationUnavailable. Clean clones type-check directly without generating first (Define models). - Breaking: No
*BaseModelclasses generated.*BaseModelexports are removed. ForIModeltypes, useWireFormat<TTask>from@exprtlabs/golem/serdeandModelInit<TTask>from@exprtlabs/golem/modelinstead of generated<Alias>JSON,<Alias>Init, or<Alias>Fields(IObjectdeclarations still emit<Alias>Fields,<Alias>Init, and<Alias>JSONin their generated file). - Static convenience methods on model classes. Every class extending
model<T>()exposesTask.parse(text, options?),Task.fromWireFormat(wire, options?),Task.stringify(value, options?),Task.toWireFormat(value, options?),Task.validate(value, options?), andTask.assert(value, options?). Standalone generic calls (parse<Task>(),stringify<Task>(),fromWireFormat<Task>(),toWireFormat<Task>(),validate<Task>(),assertValue<Task>()) continue to work (Runtime API). - Breaking: Centralized
.golem/models/output. Defaultmodel.outputchanges fromsrc/generated/modelsto.golem/models. All generated model files (local models, controller DTOs, shared models, golem-mode SDK codecs, andmodels.validators.generated.ts) are emitted insidemodel.output. Zero*.model.generated.tsor*.controller.generated.tsfiles are written beside source files insrc/. Whenmodel.outputlies outsiderootDir,golem buildemits compiled generated modules under<outDir>/__golem__/models/and rewrites imports automatically (Generated files). - Automatic controller DTO discovery. When
ts-openapi(docsorextensions.nest) is configured besidemodel, Golem automatically discovers inlineIObjectandIModeldeclarations in NestJS controller files (*.controller.tsor configured controllersources/suffixes) and emits their codecs into.golem/models/. You no longer need to add.controller.tstomodel.suffixes(OpenAPI from controllers). - Breaking: TypeScript 7.1+ only. Support for TypeScript 6.x is removed. The
typescriptpeer range is>=7.1.0-0 <8(7.1.0-beta and newer). Loading an older version fails withgolem supports TypeScript 7.1+; found <version> at <path>., and a missing install fails withgolem needs TypeScript 7.1+ installed in <directory>.(Compatibility). - Split tree-shakable standalone SDK validators. A
standaloneSDK emitsvalidators/_shared.generated.tsplus onevalidators/<operation>.generated.tsper operation instead of a single monolithicvalidators.generated.ts, allowing bundlers to tree-shake unused operation validators. - Direct TS-to-IR validator compilation, fast closed-object checks, and streaming serde.
@exprtlabs/golem-modelcompiles TypeScript model descriptors directly to validator IR without a JSON Schema round-trip for supported schemas, validates closed objects in a single zero-allocation pass withoutObject.getPrototypeOf, streams built-inDateandTemporalmodels without intermediate wire objects, and uses zero-copyparse()for identityIObjects. - Error message i18n. Built-in validation and serde issue messages use a keyed English catalog with opt-in field owners,
ModelValidator.messages()overrides, and an optional scan file for translation keys. - Untrusted-input security hardening. Closes TOCTOU JSON injection in
stringifyJsonString, cyclic JS stack overflow invalidateandassert, exponential diamond-DAG DoS, optionalObject.prototypeproperty leaks,Record<string, string>toJSONhijacks, IPv6 format amplification,Datespoofing, and unbounded reflected error messages. - Bug fixes: Includes 10 bug fixes across model generation, validation, and build rewrites.
Migrating from 1.1.x to 1.2.0
- Replace every
import { TTaskBaseModel } from './task.model.generated.js'andextends TTaskBaseModelwithimport { model } from '@exprtlabs/golem/model'andextends model<TTask>(). ReplaceTTaskJSONandTTaskInitreferences forIModeltypes withWireFormat<TTask>andModelInit<TTask>. - Remove old
src/**/*.generated.tsandsrc/generated/models/files. Update.gitignoreto ignore.golem/(plus any configured OpenAPI document or SDK output paths);*.generated.tsglobs insrc/are no longer needed. - Remove
.controller.tsfrommodel.suffixesingolem.yamlif you added it for inline controller DTOs. - Upgrade
typescriptto>=7.1.0-0 <8(npm install --save-dev typescript@~7.1.0-beta). - Update any scripts or paths that assumed
model.outputdefaulted tosrc/generated/modelsto use.golem/models(or setmodel.outputexplicitly ingolem.yaml). - Run
npx golem generateandnpx golem buildto regenerate models and split standalone SDK validators.
1.1.0
Golem 1.1.0 is the first stable release. It brings TypeScript models, NestJS controller contracts and an OpenAPI to TypeScript SDK into one generation workflow. Install the generators on their own, or combine them in one golem.yaml. Breaking marks a change against 1.1.0-rc.0, the pre-release.
- Define models in TypeScript, extend the generated base class with your methods, and convert typed JSON values with
fromWireFormatandtoWireFormat(Serialization). - Validate models with generated TypeScript validators that run without extra packages. Tags add built-in constraints, predicates and conversion pairs.
- Compose nested models with TypeScript utilities such as
PickandOmit(field types). - Generate a typed SDK from OpenAPI with authentication, cancellation, codecs and streaming responses.
- Generate an OpenAPI document from NestJS controllers without starting the application (OpenAPI from controllers). NestJS requests with
NestModelInterceptor. - Build with
golem buildor another build tool (Build tools). - Keep generated files current with
watch, or run the read-onlycheckcommand in CI. - Share models between apps. Each app generates its own copy.
- Enable MobX for reactive fields and nested SDK models.
- The public subpaths of
@exprtlabs/golemfollow semver, and tooling lives underinternal/(public API).@exprtlabs/golemhas 15 public subpaths. The helpers that only generated code calls live ininternal/runtime entries, so generate again after you update (Package subpaths). - Run generation on TypeScript 6.0+ and 7.1+, including 7.1.0-beta (Compatibility).
- TypeScript 7.0 fails at load. Install TypeScript 7.1 or 6 (Generation).
- Each package registers one
golem.yamlblock:model,ts-openapiwithdocs, oropenapi-tswithsdks(Configuration, Register a block). - Golem derives the job order from what each job reads and writes (Job order).
- The
modelblock scans from the folder ofgolem.yaml. - A
ts-openapidocs job scans from the folder ofgolem.yaml, which must lie inside the folder of the tsconfig. Putgolem.yamlin the project that owns the controllers (Configuration). - Import
ModelContextandOpenApiContextfrom@exprtlabs/golem-model/generatorand@exprtlabs/golem-openapi-ts/generator, not from@exprtlabs/golem/generator-api. - NestJS is the only framework of a
ts-openapidocs job (Configuration). - In the
openapi-tsSDK job, a non-emptyremoteHostslist turns on remote references for those hosts only. Without it, the job loads none (Configuration). @exprtlabs/golem-openapi-tsand@exprtlabs/golem-ts-openapitake@exprtlabs/golemas a peer, andtypescriptas an optional peer. Installtypescriptin your project.golem buildchecks and emits inside thegolemprocess and starts notsc. It keeps no.golem/buildstage (Generation).- A
golem.yamlwhose tsconfig is a solution file, with onlyreferences, stopsgolem generateandgolem check. Name the app's tsconfig, such astsconfig.app.json(Generation). - One
golem generatefrom a clean tree passes when a model of acontrollersroot imports the SDK of anopenapijob, and a controller that reaches such a model stops withRUNM1084(Generation). - Golem prints a local file relative to the working directory, not as an absolute path, in errors, warnings and diagnostics (Generation).
- A TypeScript error that stops generation prints in the compiler's plain form,
src/a.ts(3,7): error TS2322: ..., astscprints it without--pretty(Generation). FileRewritefrom@exprtlabs/golem/rewritehas a requiredimportsAt(Generation).- The type of the fields of a generated model is the derived
T<Name>Fieldstype (Generation). getObjectCodecandgetIModelClassfind a model only by its full id (Models).- Breaking:
getIModelClassandnestModelConstructreturnGeneratedModelConstructor | undefined, the class type of@exprtlabs/golem/model. A variable that you typed with the old shapeabstract new (values?: never) => objectstops compiling (Models). - A registered codec holds no JSON Schema. Generated model files are smaller, and a generated parse asks a validation context for
Id#wire(Models). - A model class with
@ApiSchema({ name })is the OpenAPI component of that name (OpenAPI). - A route with no response decorator gets an empty description (
"") on its default response, as Nest Swagger writes (OpenAPI). - An
allOfwith a property typedformat: date-timein one member and as a$refto an object in another stops generation. Give the property one type in every member (OpenAPI). - A
@Body()or@Query()parameter thatNestModelInterceptorcannot convert, such as a union of models whose tag the union does not declare, stops generation withRUNM1081. To keep your own interceptor, setnonModelInputs: warnon thenestextension (Generation). - The NestJS part of the rewrite and its
RUNM1081checks run only when thets-openapiblock ofgolem.yamlholdsextensions: { nest: {} }. Adocsjob alone does not turn them on (Generation). NestModelInterceptorcomes from@exprtlabs/golem-ts-openapi/nest. Install@exprtlabs/golem-ts-openapiindependencies(NestJS requests).- MobX is the
mobxextension of theopenapi-tsblock,extensions: { mobx: {} }.asGenObservableandgetValidatorcome from@exprtlabs/golem-openapi-ts/mobxand@exprtlabs/golem-openapi-ts/mobx-validation. Generated files import the MobX runtime from@exprtlabs/golem-openapi-ts, so list that package independencies(MobX extension). golem buildandgolem checkalso stop withRUNM1081on parameters of one handler thatNestModelInterceptorcannot convert together: an optional one-field parameter or optional whole@Body(), a whole and a one-field parameter of one source, parameters that read the same value as different models, and a whole@Query()array.nonModelInputs: warnon thenestextension makes them warnings (Generation).- Golem reads a decorator named
Body,Query,ApiPropertyorApiPropertyOptionalonly when it comes from@nestjs/commonor@nestjs/swagger, and anestModelCodec,nestModelUnionornestModelReturnonly when it comes from golem. A NestJS decorator imported under another name or re-exported from another file is read (Generation). - A
controllersjob writes only its OpenAPI document (OpenAPI). - A
TSerdedeserializer that throws on wire input makesparseandfromWireFormatthrowLibErrorwithcausedByInput: true. The exception of a serializer that throws reaches the caller unchanged (Models). strip: truein the options ofparse,fromWireFormat,stringifyandtoWireFormatremoves the keys that a closed object does not declare, at every level, before the checks run. An encode strips the plain objects of the model value, also those that a class instance holds, so a handler can return a database row, or a class that holds one, with an extra column. It keeps a map, anAdditionalPropertiestag, pattern properties and an object withexact: false(strip).- A whole
@Headers()parameter typed as a model holds only the declared fields, decoded to their types.NestModelInterceptordecodes them, and your own interceptor can:nestHeadersCodec(...).decode(request.headers)returns the model, andsetNestHeadershands it to the handler. A field with an uppercase letter stops the build withRUNM1092(Header models). - A
TValidationfunction that throws, or returns neither a boolean nor a string, makes every checked call throwLibErrorof kindValidationwith the original error ascause(Models). - A number format such as
Format<'int64'>on astringmodel field stops generation withRUNM1051. Anumberfield takesint32,int64,floatanddouble(Models). - A
MaporSetfield of a Nest DTO needs an@ApiProperty()withtype,schemaoradditionalProperties, or generation stops withRUNM1086(OpenAPI). - A
MaporSetfield of a model stops generation withRUNM1004also with validation off (Models). golem-openapi-tsreads a schema with bothoneOfandanyOfas both keywords (OpenAPI).- A
securityrequirement that names an undeclared scheme stops generation (OpenAPI). - The generated client rejects a numeric response header that is not a plain number (OpenAPI).
parse<T>(...args)of a model class with a spread before the options stops the build withRUNM1079(Generation).- With validation on, an object keyed by a template literal type rejects a key outside the template, and a key type that golem cannot state as one pattern stops generation with
RUNM1004(Models). - With validation on, a tuple with fixed elements after its rest element stops generation with
RUNM1021(Models). - Template index signatures of different value types in one object stop generation with
RUNM1004(Models). - Models of one name and different schemas in files or folders whose names read alike stop generation with
RUNM1005(OpenAPI). - A model union of two or more objects declares its tag key with
Discriminator<'kind'>. Golem never looks for it. An untagged union stops withRUNM1080(Models). - The controllers document writes a union's
discriminatorfrom the tag only, and a Nest union parameter needs the tag (OpenAPI). - A template index signature beside a
stringindex signature of another value type stops generation withRUNM1004(Models). - An OpenAPI 3.1 document with
discriminator.defaultMappingstops generation, because the keyword is OpenAPI 3.2 only (OpenAPI). - Two
@ApiHeader()names of one operation that differ only in case stop generation withNEST1312(OpenAPI). - The
controllersjob documents optional and mixed body and query parameters, such as@Body('payment') payment?: TPaymentand a second whole@Body(), and the build tools report the run-time limits (OpenAPI). - A Nest
@Query()model field that is a tuple, such as[number, string], decodes each position by its own type:?pair=1&pair=2gives[1, '2']. An entry after the listed positions follows the rest type of the tuple, and stays text when the tuple has none. - A
@ApiBody()with norequiredwritesrequired: true, a header parameter namedAccept,Content-TypeorAuthorizationis ignored with a warning, a spread in@Controller({ ... })stops withNEST1201, and amodel.sourcesfile with no alias stops generation (OpenAPI, Generation). - A chained
$ref, a$refto part of a component, an intersection of several data parts, a generic tag alias with a compound base andRecord<number, V>give the right result (Models, OpenAPI). - A
UniqueItemscheck takes one pass, so a list of any length validates in linear time (Models). - A class model decodes about 1.8 to 1.9 times faster (Models).
- Your own Nest interceptor or pipe decodes a
@Query()model or union withnestQueryDecoder. - A required OpenAPI property stops generation with
OPENAPI_COMPOSITION_UNSATISFIABLEwhen the keywords beside itsenumorconst, such asminimum, exclude every value.{ enum: [1, 2, 3], minimum: 2 }is the type2 | 3(OpenAPI). - A job runs again when a file changes that its generator imports from a linked workspace package or from another generator's package (Generation).
- With
dates: temporal,format: durationmeans the Temporal wire form in every position of the document, in a body, a parameter, a header and a keyword such asnotorif. The field accepts the text that Temporal writes, such asPT0.5S(fractional seconds),PT1H30SandP1Y2D. Withouttemporal, adurationstring keeps the RFC 3339 format. - A model constructor that throws while golem decodes makes
parse,fromWireFormatand the Nest interceptor throwLibErrorof kindDeserializationwithcausedByInput: falseand the exception ascause, at the root and in a field, an array item or a record value.NestModelInterceptoranswers HTTP 500. int64andIntegervalues beyondNumber.MAX_SAFE_INTEGERare rejected, andMultipleOfcompares exact decimal values (Models).golemcommands require@exprtlabs/golemat exactly the version of each built-in generator package. An extension package undergeneratorskeeps its own version.@exprtlabs/golem/generator-apistays public as the extension API (Package subpaths).- A model field of an OpenAPI schema with
enum, with or withouttype, accepts only the listed values, and the other keywords of the schema, such asminimum,maxLengthandpattern, apply. A field withtype: ['string', 'null']rejectsnullunless theenumlists it, and an emptyenumaccepts no value. A required property whose schema is an emptyenum,not: trueorfalsestops generation withOPENAPI_COMPOSITION_UNSATISFIABLE(OpenAPI). - A generated client writes a
style: cookiearray or object parameter that sets noexplodeas one cookie for each item or key, as OpenAPI 3.2 setsexplodeto true forstyle: cookie(OpenAPI). - A model cannot turn validation on above its project.
{ validation: true }on a model in a project withvalidation: falsestops generation withRUNM1089, as does'sanity'in a project atfalse(Models). GolemProfile.validationhas the typeboolean | 'sanity', andresolveProfileaccepts'sanity'. A generator must treat'sanity'as a level that validates (Generation).- A
Datefield needs an RFC 3339date-timetext with an offset at every validation level, validation off included. A Temporal field accepts only its wire form too, on write as well:stringifyandtoWireFormatthrowSerializationfor a value outside it (Models). - The model value of a
Dateor Temporal field is checked withinstanceof. A value that fails reports aninstanceissue. ATSerdeclass that a*.model.tsfile declares stops generation withRUNM1065(Models). - A
TSerdefield whose JSON value is a string reads only a string, validation off included (Models). Dateand the Temporal classes are built-inTSerdetypes. A field typedDateorTemporal.Instantconverts with no tag, and aTSerdetag on the type replaces the default (Dates and times).validation: sanitychecks the shape only. It takesgolem.yamland the options of a model, and a call chooses a level withvalidate: true | 'sanity' | falseup to the project level.validate<T>,assertValue<T>andNestModelInterceptortakevalidate: true | 'sanity'(Models, Validation profiles).- A model with
{ validation: false }can use a validation function from its own file. A shared unnamed object type validates for every model that holds it (Models). - A recursive model bounds input nesting with
maxDepth(512 by default). The Nest interceptor answers 400 beyond it (Models). - An untagged
anyOfwhose branches state different JSON types checks a value only with the branches of its type (OpenAPI). - A generated SDK has no model classes, in either mode, and no per-schema functions. The client checks and converts each request and response, and a response body is a plain object of the SDK type with converted dates. Your own
IModel<Charge>gives a class with methods (OpenAPI). - An
openapijob takesmode: standalone | golem. A standalone SDK (the default) runs alone with a bundled copy of the runtime. A golem mode SDK leaves checks and conversions to themodelsjob (SDK modes). - The
mobxextension on a standalone SDK stops generation withOPENAPI_MOBX_NEEDS_GOLEM_MODE. Setmode: golem(OpenAPI). - The generated client takes a
validateoption for each client and each call, with a level for requests and responses apart (Lower the checks). - An OpenAPI
enumorconstkeeps only the values that itstypeadmits, and aconstkeeps the keywords beside it. A required property that itstypeleaves with no value stops generation withOPENAPI_COMPOSITION_UNSATISFIABLE(Diagnostics). - Breaking: a tag inside a hole of a template literal type, such as
`id-${string & MinLength<3>}`, stops generation withRUNM1045. Write the tag beside the type:`id-${string}` & MinLength<3>(Models). - Breaking: with validation on, a field typed by a template literal type, such as
`id-${string}`, accepts only the strings that match it, astscdoes. A hole other thanstring, such as`id-${number}`, stops generation withRUNM1004(Models). - Breaking: an object keyed by a template literal type with a tag in a hole stops generation with
RUNM1045at every validation level (Models). - Breaking: an
exactorallowAnyoption typed as a widebooleanstops withRUNM1089(Models). - Breaking: a variant of a
Discriminatorunion that has aTSerdewhose wire form is not an object, such as a string, stops generation withRUNM1082(Models). - Breaking: the
ModelValidatorconstructor takes its mode as a required option,new ModelValidator(model, { cache: 'attach' })(Models). - Breaking: a Nest route with
@ApiOperation({ hidden: true })stays in the document. Only@ApiExcludeEndpoint()omits a route (OpenAPI). - Breaking: a request body media type with
itemSchemastops generation with the ruleno-request-item-schema. Declare a request body withschema(OpenAPI). - Breaking: two response headers of one response whose names differ only in letter case stop generation with
operation-response-headers-unique(OpenAPI). - Breaking: a property of a Swagger
schemaoverride that is neither an object nor a boolean stops generation withNEST1503(OpenAPI). - Breaking: a
oneOfof a recursive array component and another array stops generation withUnion has ambiguous conversions(OpenAPI). - Breaking: generation type-checks the generated validators module and stops on an error in it (Models).
- Breaking: two functions of one type written in one field, or a function tag that an inferred value holds beside a written function of the same type, stop with
RUNM1040(Models). - Breaking: the string form of
uriVersioningis refused withNEST1203unless it isURIoruri(OpenAPI). - Breaking:
GeneratorSession.shareandGeneratorSession.retaintake aSessionKey<Resource>as their key. Make it withsessionKeyfrom@exprtlabs/golem/generator-api(Generation).
Read the CHANGELOG for every change.
