Generation emits a complete, precompiled npm package. By default it is written to node_modules/.repost/client, and @repost/client re-exports it, so application imports stay stable while the generated code stays out of your repo. This is the same pattern Prisma uses for @prisma/client.
What gets emitted#
| File | Purpose |
|---|---|
package.json | The generated package manifest. Its name is repost-client- followed by a content hash, and it depends on @repost/client. |
index.js, index.mjs | Precompiled CommonJS and ESM entries: enum objects, descriptors, and createRepostClient. |
index.d.ts | The types: model interfaces, enums, the webhooks method tree, and the factory signature. |
default.js, default.d.ts | The shim @repost/client re-exports through. |
schema.repost | A verbatim copy of the schema this package was generated from. |
schemas.json | The JSON Schema catalog for your event types, identical across every generator in the schema. |
The generated code is data and types only. Serialization, retries, and transport live in the @repost/client runtime, which the generated package imports from @repost/client/runtime.
Models become interfaces, optional fields become field?: T | null, and enums become a const object plus a type:
export const Currency: {
readonly USD: "USD";
readonly EUR: "EUR";
};
export type Currency = (typeof Currency)[keyof typeof Currency];
export interface User {
id: string;
email: string;
}Regenerating#
node_modules is not committed, so a fresh clone or a CI job with a restored dependency cache has no generated client yet. @repost/client's install hook leaves a placeholder whose only job is to fail with a clear message instead of a raw module-resolution error:
@repost/client did not initialize yet. Please run "repost schema generate" and try to import it again.Run generation in your build, typically as a postinstall script:
{
"scripts": {
"postinstall": "repost schema generate"
}
}repost schema migrate dev also regenerates as part of recording a migration, and repost schema generate --check verifies in CI that nothing has drifted without writing.
Generation only ever overwrites directories it recognizes as its own output (by the repost-client- package-name prefix or the generation marker), so a mistyped path cannot destroy your code.
Custom output for monorepos#
Set output to write the identical package to a path instead, and import it directly:
generator sdk {
language = "typescript"
output = "../../packages/repost-events/src/generated"
}The package still depends on @repost/client for its runtime. This is the pattern for workspaces where several apps consume one generated client, and for Yarn PnP layouts that have no node_modules to generate into. A schema can carry several TypeScript generators with distinct outputs; see polyglot monorepos.
The version handshake#
The generated package declares descriptor format 2, checked when createRepostClient builds the method tree:
- Generated code older than the runtime: the error tells you to re-run
repost schema generatewith the current CLI. - Generated code newer than the runtime: the error tells you to upgrade
@repost/client. - Generated code that predates versioning: accepted with a one-time console warning asking you to regenerate.
A real mismatch fails at construction, never silently at send time.