UNPKG

drizzle-zero

Version:

Generate Zero schemas from Drizzle ORM schemas

598 lines (592 loc) 26.8 kB
import { Table, Relations, One } from 'drizzle-orm'; import { ReadonlyJSONValue, ColumnBuilder, TableBuilderWithColumns } from '@rocicorp/zero'; export { ColumnBuilder, ReadonlyJSONValue, TableBuilderWithColumns } from '@rocicorp/zero'; /** * Maps Drizzle data types to their corresponding Zero schema types. * This is a constant mapping that ensures type safety when converting between the two systems. */ declare const drizzleDataTypeToZeroType: { readonly number: "number"; readonly bigint: "number"; readonly boolean: "boolean"; readonly date: "number"; }; /** * Type representation of the Drizzle to Zero type mapping. * Extracts the type information from the drizzleDataTypeToZeroType constant. */ type DrizzleDataTypeToZeroType = typeof drizzleDataTypeToZeroType; /** * Maps Postgres-specific Drizzle column types to their corresponding Zero schema types. * Handles special cases where Postgres types need specific Zero type representations. */ declare const drizzleColumnTypeToZeroType: { readonly PgText: "string"; readonly PgChar: "string"; readonly PgVarchar: "string"; readonly PgUUID: "string"; readonly PgEnumColumn: "string"; readonly PgJsonb: "json"; readonly PgJson: "json"; readonly PgNumeric: "number"; readonly PgDateString: "number"; readonly PgTimestampString: "number"; }; /** * Type representation of the Postgres-specific Drizzle to Zero type mapping. * Extracts the type information from the drizzleColumnTypeToZeroType constant. */ type DrizzleColumnTypeToZeroType = typeof drizzleColumnTypeToZeroType; /** * Maps Zero schema types to their corresponding TypeScript types. */ type ZeroTypeToTypescriptType = { number: number; boolean: boolean; date: string; string: string; json: ReadonlyJSONValue; }; /** * Gets the keys of columns that can be used as indexes. * @template TTable - The table to get index keys from */ type ColumnIndexKeys<TTable extends Table> = { [K in keyof Columns<TTable>]: K; }[keyof Columns<TTable>]; /** * Configuration type for specifying which tables and columns to include in the Zero schema. * @template TDrizzleSchema - The complete Drizzle schema */ type TableColumnsConfig<TDrizzleSchema extends Record<string, unknown>> = Flatten<{ /** * The columns to include in the Zero schema. */ readonly [K in keyof TDrizzleSchema as TDrizzleSchema[K] extends Table<any> ? K : never]: TDrizzleSchema[K] extends Table<any> ? ColumnsConfig<TDrizzleSchema[K]> : never; }>; /** * A default config type which includes all tables in the Drizzle schema. * @template TDrizzleSchema - The complete Drizzle schema */ type DefaultTableColumnsConfig<TDrizzleSchema extends Record<string, unknown>> = Flatten<{ readonly [K in keyof TDrizzleSchema as TDrizzleSchema[K] extends Table<any> ? K : never]: TDrizzleSchema[K] extends Table<any> ? DefaultColumnsConfig<TDrizzleSchema[K]> : never; }>; /** * A default config type which includes all columns in a Drizzle table. * @template TTable - The Drizzle table type */ type DefaultColumnsConfig<TTable extends Table> = { readonly [K in ColumnNames<TTable>]: true; }; /** * Extracts the table name from a Drizzle table type. * @template TTable The Drizzle table type */ type TableName<TTable extends Table> = TTable["_"]["name"]; /** * Gets all columns from a Drizzle table type. * @template TTable The Drizzle table type */ type Columns<TTable extends Table> = TTable["_"]["columns"]; /** * Gets all column names from a Drizzle table type. * @template TTable The Drizzle table type */ type ColumnNames<TTable extends Table> = keyof Columns<TTable>; /** * Helper type that extracts primary key columns from a table. * @template T The Drizzle table type */ type PrimaryKeyColumns<T extends Table> = { [K in keyof Columns<T>]: Columns<T>[K]["_"]["isPrimaryKey"] extends true ? K extends string ? K : never : never; }[keyof Columns<T>]; /** * Finds the primary key(s) from a table. * @template T The Drizzle table type */ type FindPrimaryKeyFromTable<T extends Table> = [ PrimaryKeyColumns<T> ] extends [never] ? [never] : [PrimaryKeyColumns<T>]; /** * Finds relations defined for a specific table in the Drizzle schema. * @template TDrizzleSchema The complete Drizzle schema * @template TTable The table to find relations for */ type FindRelationsForTable<TDrizzleSchema extends { [K in string]: unknown; }, TTable extends Table> = Extract<TDrizzleSchema[{ [P in keyof TDrizzleSchema]: TDrizzleSchema[P] extends Relations<TableName<TTable>> ? P : never; }[keyof TDrizzleSchema]], Relations<TableName<TTable>>>; /** * Type guard that checks if a type is a Table with a specific name. * @template T The type to check * @template Name The name to check for */ type IsTableWithName<T, Name extends string> = T extends { _: { name: Name; }; } ? T extends Table<any> ? true : false : false; /** * Finds a table in the schema by its name. * @template TDrizzleSchema The complete Drizzle schema * @template Name The name of the table to find */ type FindTableByName<TDrizzleSchema extends Record<string, unknown>, Name extends string> = Extract<{ [P in keyof TDrizzleSchema]: IsTableWithName<TDrizzleSchema[P], Name> extends true ? TDrizzleSchema[P] : never; }[keyof TDrizzleSchema], Table<any>>; /** * Finds a table in the schema by its key. * @template TDrizzleSchema The complete Drizzle schema * @template Key The key of the table to find in the schema */ type FindTableByKey<TDrizzleSchema extends Record<string, unknown>, Key extends keyof TDrizzleSchema> = TDrizzleSchema[Key] extends Table<any> ? TDrizzleSchema[Key] : never; /** * Finds the key of a table in the schema by its name. * @template TDrizzleSchema The complete Drizzle schema * @template Name The name of the table to find in the schema */ type FindTableKeyByTableName<TDrizzleSchema extends Record<string, unknown>, Name extends string> = keyof { [K in keyof TDrizzleSchema as TDrizzleSchema[K] extends Table<any> ? TDrizzleSchema[K]["_"]["name"] extends Name ? K : never : never]: any; }; /** * Extracts the configuration type from a Relations type. * @template T The Relations type to extract config from */ type RelationsConfig<T extends Relations> = ReturnType<T["config"]>; /** * Type guard that checks if a string has a capital letter. * @template S The string to check */ type HasCapital<S extends string> = S extends `${infer First}${infer Rest}` ? First extends Uppercase<First> ? First extends Lowercase<First> ? HasCapital<Rest> : true : HasCapital<Rest> : false; /** * Utility type that flattens an object type by removing any intermediate interfaces. * @template T The type to flatten */ type Flatten<T> = { [K in keyof T]: T[K]; } & {}; /** * Represents a column definition from a Drizzle table, filtered by column name. * @template TTable The Drizzle table type * @template K The column name to filter by */ type ColumnDefinition<TTable extends Table, K extends ColumnNames<TTable>> = { [C in keyof Columns<TTable>]: C extends K ? Columns<TTable>[C] : never; }[keyof Columns<TTable>]; /** * The type override for a column. * Used to customize how a Drizzle column is mapped to a Zero schema. * @template TCustomType The TypeScript type that corresponds to the Zero type */ type TypeOverride<TCustomType> = { readonly type: "string" | "number" | "boolean" | "json"; readonly optional: boolean; readonly customType: TCustomType; readonly kind?: "enum"; }; /** * Configuration for specifying which columns to include in the Zero schema and how to map them. * @template TTable The Drizzle table type */ type ColumnsConfig<TTable extends Table> = false | Flatten<{ /** * The columns to include in the Zero schema. * Set to true to use default mapping, or provide a TypeOverride for custom mapping. */ readonly [KColumn in ColumnNames<TTable>]: boolean | ColumnBuilder<TypeOverride<ZeroTypeToTypescriptType[DrizzleDataTypeToZeroType[Columns<TTable>[KColumn]["dataType"]]]>>; }>; /** * Maps a Drizzle column type to its corresponding Zero type. * @template TTable The Drizzle table type * @template KColumn The column name * @template CD The column definition type */ type ZeroMappedColumnType<TTable extends Table, KColumn extends ColumnNames<TTable>, CD extends ColumnDefinition<TTable, KColumn>["_"] = ColumnDefinition<TTable, KColumn>["_"]> = CD extends { columnType: keyof DrizzleColumnTypeToZeroType; } ? DrizzleColumnTypeToZeroType[CD["columnType"]] : DrizzleDataTypeToZeroType[CD["dataType"]]; /** * Maps a Drizzle column to its corresponding TypeScript type in Zero. * Handles special cases like enums and custom types. * @template TTable The Drizzle table type * @template KColumn The column name * @template CD The column definition type */ type ZeroMappedCustomType<TTable extends Table, KColumn extends ColumnNames<TTable>, CD extends ColumnDefinition<TTable, KColumn>["_"] = ColumnDefinition<TTable, KColumn>["_"]> = CD extends { columnType: "PgEnumColumn"; } ? CD["data"] : CD extends { columnType: "PgText"; data: string; } ? CD["data"] : CD extends { $type: any; } ? CD["$type"] : ZeroTypeToTypescriptType[ZeroMappedColumnType<TTable, KColumn>]; /** * Defines the structure of a column in the Zero schema. * @template TTable The Drizzle table type * @template KColumn The column name * @template CD The column definition type */ type ZeroColumnDefinition<TTable extends Table, KColumn extends ColumnNames<TTable>, TCasing extends ZeroTableCasing, CD extends ColumnDefinition<TTable, KColumn>["_"] = ColumnDefinition<TTable, KColumn>["_"], BaseDefinition extends { optional: false; type: ZeroMappedColumnType<TTable, KColumn>; customType: ZeroMappedCustomType<TTable, KColumn>; } = { optional: false; type: ZeroMappedColumnType<TTable, KColumn>; customType: ZeroMappedCustomType<TTable, KColumn>; }, BaseOptional extends Omit<BaseDefinition, "optional"> & { optional: true; } = Omit<BaseDefinition, "optional"> & { optional: true; }> = (CD extends { hasDefault: true; hasRuntimeDefault: false; } ? BaseOptional : CD extends { notNull: true; } ? BaseDefinition : Omit<BaseDefinition, "optional"> & { optional: true; }) & (CD extends { name: KColumn; } ? TCasing extends "snake_case" ? HasCapital<CD["name"]> extends true ? { serverName: string; } : {} : TCasing extends "camelCase" ? HasCapital<CD["name"]> extends false ? { serverName: string; } : {} : {} : { serverName: string; }); /** * Maps the columns configuration to their Zero schema definitions. * @template TTable The Drizzle table type * @template TColumnConfig The columns configuration */ type ZeroColumns<TTable extends Table, TColumnConfig extends ColumnsConfig<TTable>, TCasing extends ZeroTableCasing> = { [KColumn in keyof TColumnConfig as TColumnConfig[KColumn] extends true | ColumnBuilder<any> ? KColumn : never]: KColumn extends ColumnNames<TTable> ? TColumnConfig[KColumn] extends ColumnBuilder<any> ? TColumnConfig[KColumn]["schema"] : TColumnConfig[KColumn] extends true ? Flatten<ZeroColumnDefinition<TTable, KColumn, TCasing>> : never : never; }; /** * Represents the underlying schema for a Zero table. * @template TTableName The name of the table * @template TTable The Drizzle table type * @template TColumnConfig The columns configuration */ type ZeroTableBuilderSchema<TTableName extends string, TTable extends Table, TColumnConfig extends ColumnsConfig<TTable>, TCasing extends ZeroTableCasing> = { name: TTableName; primaryKey: FindPrimaryKeyFromTable<TTable> extends [never] ? readonly [string, ...string[]] : readonly [string, ...string[]] & FindPrimaryKeyFromTable<TTable>; columns: Flatten<ZeroColumns<TTable, TColumnConfig, TCasing>>; }; /** * Represents the complete Zero schema for a Drizzle table. * @template TTableName The name of the table * @template TTable The Drizzle table type * @template TColumnConfig The columns configuration */ type ZeroTableBuilder<TTableName extends string, TTable extends Table, TColumnConfig extends ColumnsConfig<TTable>, TCasing extends ZeroTableCasing> = TableBuilderWithColumns<Readonly<ZeroTableBuilderSchema<TTableName, TTable, TColumnConfig, TCasing>>>; /** * Casing for the Zero table builder. */ type ZeroTableCasing = "snake_case" | "camelCase" | undefined; /** * Creates a Zero schema from a Drizzle table definition. * * @returns A Zero schema definition for the table * @throws {Error} If primary key configuration is invalid or column types are unsupported */ declare const createZeroTableBuilder: <TTableName extends string, TTable extends Table, TColumnConfig extends ColumnsConfig<TTable>, TCasing extends ZeroTableCasing = ZeroTableCasing>( /** * The mapped name of the table */ tableName: TTableName, /** * The Drizzle table instance */ table: TTable, /** * Configuration specifying which columns to include and how to map them */ columns?: TColumnConfig, /** * Whether to enable debug mode. */ debug?: boolean, /** * The casing to use for the table name. */ casing?: TCasing) => ZeroTableBuilder<TTableName, TTable, TColumnConfig, TCasing>; /** * Get the key of a column in the schema from the column name. * @param columnName - The name of the column to get the key for * @param table - The table to get the column key from * @returns The key of the column in the schema */ declare const getDrizzleColumnKeyFromColumnName: ({ columnName, table, }: { columnName: string; table: Table; }) => string; /** * Type utility to get the Drizzle custom type for a table and column. * * @template ZeroSchema - The complete Zero schema * @template TableName - The name of the table * @template ColumnName - The name of the column */ type ZeroCustomType<ZeroSchema extends any, TableName extends string, ColumnName extends string> = ZeroSchema extends { tables: { [K in TableName]: { columns: { [L in ColumnName]: { customType: infer T; }; }; }; }; } ? T & {} : unknown; /** * Extracts the table name from a configuration object or string. * @template TTableConfig - The configuration object or string */ type ExtractTableConfigName<TTableConfig> = TTableConfig extends { readonly destTable: string; } ? TTableConfig["destTable"] : TTableConfig extends string ? TTableConfig : never; /** * Represents the structure of a many-to-many relationship through a junction table. * @template TDrizzleSchema - The complete Drizzle schema * @template TColumnConfig - Configuration for the tables * @template TManyConfig - Configuration for many-to-many relationships * @template TTableName extends keyof TColumnConfig & keyof TManyConfig */ type ManyToManyRelationship<TDrizzleSchema extends { [K in string]: unknown; }, TColumnConfig extends TableColumnsConfig<TDrizzleSchema>, TManyConfig extends ManyConfig<TDrizzleSchema, TColumnConfig> | undefined, TTableName extends keyof TColumnConfig & keyof TManyConfig> = TManyConfig extends undefined ? {} : TTableName extends keyof TColumnConfig & keyof TManyConfig ? TManyConfig[TTableName] extends ManyTableConfig<TDrizzleSchema, TColumnConfig, TTableName> ? { [K in keyof TManyConfig[TTableName]]: [ { readonly sourceField: string[]; readonly destField: ColumnIndexKeys<FindTableByKey<TDrizzleSchema, ExtractTableConfigName<TManyConfig[TTableName][K][0]>>>[]; readonly destSchema: ExtractTableConfigName<TManyConfig[TTableName][K][0]>; readonly cardinality: "many"; }, { readonly sourceField: string[]; readonly destField: ColumnIndexKeys<FindTableByKey<TDrizzleSchema, ExtractTableConfigName<TManyConfig[TTableName][K][1]>>>[]; readonly destSchema: ExtractTableConfigName<TManyConfig[TTableName][K][1]>; readonly cardinality: "many"; } ]; } : {} : {}; /** * Gets the valid direct relation keys for a table that have corresponding table configurations. * @template TDrizzleSchema - The complete Drizzle schema * @template TColumnConfig - Configuration for the tables * @template TCurrentTableRelations - Relations defined for the current table */ type ValidDirectRelationKeys<TDrizzleSchema extends Record<string, unknown>, TColumnConfig extends TableColumnsConfig<TDrizzleSchema>, TCurrentTableRelations extends Relations> = keyof RelationsConfig<TCurrentTableRelations> & { [K in keyof RelationsConfig<TCurrentTableRelations>]: RelationsConfig<TCurrentTableRelations>[K]["referencedTable"] extends Table<any> ? { [SchemaKey in keyof TDrizzleSchema]: TDrizzleSchema[SchemaKey] extends RelationsConfig<TCurrentTableRelations>[K]["referencedTable"] ? TColumnConfig[SchemaKey & keyof TColumnConfig] extends object ? K : never : never; }[keyof TDrizzleSchema] : never; }[keyof RelationsConfig<TCurrentTableRelations>]; /** * Represents a direct relationship between tables. * @template TDrizzleSchema - The complete Drizzle schema * @template TColumnConfig - Configuration for the tables * @template TManyConfig - Configuration for many-to-many relationships * @template TCurrentTable - The current table being processed * @template TCurrentTableRelations - Relations defined for the current table */ type DirectRelationships<TDrizzleSchema extends Record<string, unknown>, TColumnConfig extends TableColumnsConfig<TDrizzleSchema>, TCurrentTableRelations extends Relations> = [TCurrentTableRelations] extends [never] ? {} : { [K in ValidDirectRelationKeys<TDrizzleSchema, TColumnConfig, TCurrentTableRelations>]: [ { readonly sourceField: string[]; readonly destField: ColumnIndexKeys<FindTableByName<TDrizzleSchema, RelationsConfig<TCurrentTableRelations>[K]["referencedTableName"]>>[]; readonly destSchema: FindTableKeyByTableName<TDrizzleSchema, RelationsConfig<TCurrentTableRelations>[K]["referencedTableName"]>; readonly cardinality: RelationsConfig<TCurrentTableRelations>[K] extends One ? "one" : "many"; } ]; }; /** * Configuration type for many-to-many relationships for a specific table. * @template TDrizzleSchema - The complete Drizzle schema * @template TColumnConfig - Configuration for the tables * @template TSourceTableName - The name of the source table */ type ManyTableConfig<TDrizzleSchema extends Record<string, unknown>, TColumnConfig extends TableColumnsConfig<TDrizzleSchema>, TSourceTableName extends keyof TColumnConfig> = { readonly [TRelationName: string]: readonly [keyof TColumnConfig, keyof TColumnConfig] | { [K in keyof TColumnConfig]: { [L in keyof TColumnConfig]: readonly [ { readonly destTable: K; readonly sourceField: (keyof TColumnConfig[TSourceTableName])[]; readonly destField: (keyof TColumnConfig[K])[]; }, { readonly destTable: L; readonly sourceField: (keyof TColumnConfig[K])[]; readonly destField: (keyof TColumnConfig[L])[]; } ]; }[keyof TColumnConfig]; }[keyof TColumnConfig]; }; /** * Configuration for many-to-many relationships across all tables. * Organized by source table, with each relationship specifying a tuple of [junction table name, destination table name]. * The junction table and destination table must be different from the source table and each other. */ type ManyConfig<TDrizzleSchema extends Record<string, unknown>, TColumnConfig extends TableColumnsConfig<TDrizzleSchema>> = [keyof TColumnConfig] extends [never] ? never : { readonly [TSourceTableName in keyof TColumnConfig]?: ManyTableConfig<TDrizzleSchema, TColumnConfig, TSourceTableName>; }; /** * Represents all referenced Zero schemas for a table, including both direct and many-to-many relationships. * @template TDrizzleSchema - The complete Drizzle schema * @template TColumnConfig - Configuration for the tables * @template TManyConfig - Configuration for many-to-many relationships * @template TTableName extends keyof TColumnConfig & keyof TManyConfig * @template TTable extends Table<any> */ type ReferencedZeroSchemas<TDrizzleSchema extends Record<string, unknown>, TColumnConfig extends TableColumnsConfig<TDrizzleSchema>, TManyConfig extends ManyConfig<TDrizzleSchema, TColumnConfig> | undefined, TTableName extends keyof TColumnConfig & keyof TManyConfig, TTable extends Table<any>> = DirectRelationships<TDrizzleSchema, TColumnConfig, FindRelationsForTable<TDrizzleSchema, TTable>> & ManyToManyRelationship<TDrizzleSchema, TColumnConfig, TManyConfig, TTableName>; /** * The mapped Zero schema from a Drizzle schema with version and tables. * * @template TDrizzleSchema - The complete Drizzle schema * @template TCasing - The casing to use for the table name * @template TColumnConfig - Configuration for the tables * @template TManyConfig - Configuration for many-to-many relationships */ type DrizzleToZeroSchema<TDrizzleSchema extends { [K in string]: unknown; }, TCasing extends ZeroTableCasing = undefined, TColumnConfig extends TableColumnsConfig<TDrizzleSchema> = DefaultTableColumnsConfig<TDrizzleSchema>, TManyConfig extends ManyConfig<TDrizzleSchema, TColumnConfig> | undefined = undefined> = { readonly tables: { readonly [K in keyof TDrizzleSchema & keyof TColumnConfig as TDrizzleSchema[K] extends Table<any> ? TColumnConfig[K] extends object ? K : never : never]: TDrizzleSchema[K] extends Table<any> ? Flatten<ZeroTableBuilderSchema<K & string, TDrizzleSchema[K], TColumnConfig[K], TCasing>> : never; }; readonly relationships: { readonly [K in keyof TDrizzleSchema & keyof TColumnConfig as TDrizzleSchema[K] extends Table<any> ? TColumnConfig[K] extends object ? [ ReferencedZeroSchemas<TDrizzleSchema, TColumnConfig, TManyConfig, K & keyof TManyConfig & keyof TColumnConfig, TDrizzleSchema[K]> ] extends [never] ? never : keyof ReferencedZeroSchemas<TDrizzleSchema, TColumnConfig, TManyConfig, K & keyof TManyConfig & keyof TColumnConfig, TDrizzleSchema[K]> extends never ? never : K : never : never]: TDrizzleSchema[K] extends Table<any> ? ReferencedZeroSchemas<TDrizzleSchema, TColumnConfig, TManyConfig, K & keyof TManyConfig & keyof TColumnConfig, TDrizzleSchema[K]> : never; }; }; /** * Configuration for the Zero schema generator. This defines how your Drizzle ORM schema * is transformed into a Zero schema format, handling both direct relationships and many-to-many relationships. * * This allows you to: * - Select which tables to include in the Zero schema * - Configure column types and transformations * - Define many-to-many relationships through junction tables * * @param schema - The Drizzle schema to create a Zero schema from. This should be your complete Drizzle schema object * containing all your table definitions and relationships. * @param config - Configuration object for the Zero schema generation * @param config.tables - Specify which tables and columns to include in sync * @param config.manyToMany - Optional configuration for many-to-many relationships through junction tables * @param config.casing - The casing to use for the table name. * @param config.debug - Whether to enable debug mode. * * @returns A configuration object for the Zero schema CLI. * * @example * ```typescript * import { integer, pgTable, serial, text, varchar } from 'drizzle-orm/pg-core'; * import { relations } from 'drizzle-orm'; * import { drizzleZeroConfig } from 'drizzle-zero'; * * // Define Drizzle schema * const users = pgTable('users', { * id: serial('id').primaryKey(), * name: text('name'), * }); * * const posts = pgTable('posts', { * id: serial('id').primaryKey(), * title: varchar('title'), * authorId: integer('author_id').references(() => users.id), * }); * * const usersRelations = relations(users, ({ one }) => ({ * posts: one(posts, { * fields: [users.id], * references: [posts.authorId], * }), * })); * * // Export the configuration for the Zero schema CLI * export default drizzleZeroConfig( * { users, posts, usersRelations }, * { * tables: { * users: { * id: true, * name: true, * }, * posts: { * id: true, * title: true, * authorId: true, * }, * }, * } * ); * ``` */ declare const drizzleZeroConfig: <const TDrizzleSchema extends { [K in string]: unknown; }, const TColumnConfig extends TableColumnsConfig<TDrizzleSchema> = DefaultTableColumnsConfig<TDrizzleSchema>, const TManyConfig extends ManyConfig<TDrizzleSchema, TColumnConfig> | undefined = undefined, const TCasing extends ZeroTableCasing = undefined>( /** * The Drizzle schema to create a Zero schema from. */ schema: TDrizzleSchema, /** * The configuration for the Zero schema. * * @param config.tables - The tables to include in the Zero schema. * @param config.many - Configuration for many-to-many relationships. */ config?: { /** * Specify the tables to include in the Zero schema. * This can include type overrides for columns, using `column.json()` for example. * * @example * ```ts * { * user: { * id: true, * name: true, * }, * profile_info: { * id: true, * user_id: true, * metadata: column.json(), * }, * } * ``` */ readonly tables?: TColumnConfig; /** * Configuration for many-to-many relationships. * Organized by source table, with each relationship specifying a tuple of [junction table name, destination table name]. * * @example * ```ts * { * user: { * comments: ['message', 'comment'] * } * } * ``` */ readonly manyToMany?: TManyConfig; /** * The casing to use for the table name. * * @example * ```ts * { casing: 'snake_case' } * ``` */ readonly casing?: TCasing; /** * Whether to enable debug mode. * * @example * ```ts * { debug: true } * ``` */ readonly debug?: boolean; }) => Flatten<DrizzleToZeroSchema<TDrizzleSchema, TCasing, TColumnConfig, TManyConfig>>; export { type ColumnsConfig, type DrizzleToZeroSchema, type ZeroColumns, type ZeroCustomType, type ZeroTableBuilder, type ZeroTableBuilderSchema, type ZeroTableCasing, createZeroTableBuilder, drizzleZeroConfig, getDrizzleColumnKeyFromColumnName };