Generators analyze your TailorDB types, Resolvers, and Executors to automatically generate TypeScript code.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tailor-platform/sdk/llms.txt
Use this file to discover all available pages before exploring further.
Generators have been replaced by the Plugin system. See the migration guide for upgrading. This page documents the legacy generator syntax for backward compatibility.
Overview
When you runtailor-sdk generate, the SDK:
- Loads all TailorDB types, Resolvers, and Executors from your configuration
- Passes each definition to the configured generators
- Aggregates the results and writes output files
@tailor-platform/kysely-type generator produces type-safe database access code from your TailorDB definitions.
Configuration
Define generators intailor.config.ts using defineGenerators():
tailor.config.ts
CLI Commands
Generate Files
Watch Mode
Builtin Generators
The SDK includes four builtin generators for common code generation tasks.@tailor-platform/kysely-type
Generates Kysely type definitions and thegetDB() function for type-safe database access.
| Option | Type | Description |
|---|---|---|
distPath | string | Output file path (required) |
- Type definitions for all TailorDB types
getDB(namespace)function to create Kysely instances- Utility types for Timestamp and Serial fields
resolvers/userQuery.ts
executors/auditLog.ts
workflows/orderProcessing.ts
@tailor-platform/enum-constants
Extracts enum constants from TailorDB type definitions.| Option | Type | Description |
|---|---|---|
distPath | string | Output file path (required) |
generated/enums.ts
resolvers/orderQuery.ts
@tailor-platform/file-utils
Generates utility functions for handling file-type fields in TailorDB.| Option | Type | Description |
|---|---|---|
distPath | string | Output file path (required) |
generated/files.ts
@tailor-platform/seed
Generates seed data configuration files for database initialization.| Option | Type | Description |
|---|---|---|
distPath | string | Output directory path (required) |
machineUserName | string | Default machine user name (can be overridden at runtime) |
The
--machine-user option is required at runtime if machineUserName is not configured in the generator options.Example Configuration
Here’s a complete example from the SDK example project:tailor.config.ts
Workflow
-
Define your TailorDB types:
tailordb/user.ts
-
Configure generators in
tailor.config.ts -
Run generation:
-
Use generated code in resolvers, executors, and workflows:
resolvers/userOperations.ts
Next Steps
- Learn about the Plugin system (recommended replacement for generators)
- Explore TailorDB for database schema definition
- Understand Migrations for schema evolution