UNPKG

ts-sql-codegen

Version:

Generates ts-sql-query table mappings from tbls schema output

1,200 lines (1,199 loc) 57.9 kB
import * as z from "zod"; export declare const TableInclusionSchema: z.ZodObject<{ /** * Tables to be included - identified by qualified table name * or regular expression */ include: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, "many">>>; /** * Tables to be excluded - identified by qualified table name * or regular expression */ exclude: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, "many">>>; }, "strip", z.ZodTypeAny, { include?: (string | RegExp)[] | null | undefined; exclude?: (string | RegExp)[] | null | undefined; }, { include?: (string | RegExp)[] | null | undefined; exclude?: (string | RegExp)[] | null | undefined; }>; export interface TableInclusion extends z.input<typeof TableInclusionSchema> { } export declare const ExportTypesOptionsSchema: z.ZodObject<{ /** * If enabled, instead of type alias we will generate interfaces * * This can make type errors more succinct. */ asInterface: z.ZodBoolean; }, "strip", z.ZodTypeAny, { asInterface: boolean; }, { asInterface: boolean; }>; export interface ExportTypesOptions extends z.input<typeof ExportTypesOptionsSchema> { } export declare const ExportOptionsSchema: z.ZodObject<{ /** * In addition to the table class, also expose instantiated instance of table class * * Example: * export class UserTable extends Table<DBConnection, "User"> { ... } * * export const tUserTable = new UserTable() // <---- */ tableInstances: z.ZodDefault<z.ZodBoolean>; /** * If set to false, prevents the table class from getting exported * * This is useful in conjunction with tableInstances, if you only want to * export the table instance */ tableClasses: z.ZodDefault<z.ZodBoolean>; /** * Additionally export the row types associated with table * * Example: * import { InsertableRow, UpdatableRow, SelectedRow } from "ts-sql-query/extras/types" * * export class UserTable extends Table<DBConnection, "User"> { ... } * * // Type of user row that can be used for insert * // Here computed columns will not be present and columns with defaults will be optional * export type UserIRow = InsertableRow<UserTable> * * // Type of user row that can be used for update * // Here computed columns will not be present and all fields will be optional * export type UserURow = UpdatableRow<UserTable> * * // Type of user row that is returned from select * // Here computed columns will be present, only nullable fields will be optional * export type UserSRow = SelectedRow<UserTable> * */ rowTypes: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{ /** * If enabled, instead of type alias we will generate interfaces * * This can make type errors more succinct. */ asInterface: z.ZodBoolean; }, "strip", z.ZodTypeAny, { asInterface: boolean; }, { asInterface: boolean; }>]>>; /** * Additionally export the value types associated with table * * Example: * import { InsertableValues, UpdatableValues, SelectedValues } from "ts-sql-query/extras/types" * * export class UserTable extends Table<DBConnection, "User"> { ... } * * // Type of user values that can be used for insert * // Here computed columns will not be present and columns with defaults will be optional * export type InsertableUser = InsertableValues<UserTable> * * // Type of user values that can be used for update * // Here computed columns will not be present and all fields will be optional * export type UpdatableUser = UpdatableValues<UserTable> * * // Type of user values that is returned from select * // Here computed columns will be present, only nullable fields will be optional * export type User = SelectedValues<UserTable> * */ valuesTypes: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{ /** * If enabled, instead of type alias we will generate interfaces * * This can make type errors more succinct. */ asInterface: z.ZodBoolean; }, "strip", z.ZodTypeAny, { asInterface: boolean; }, { asInterface: boolean; }>]>>; /** * Additionally export the extracted columns (Useful for select * queries etc.) * * Example: * export const tUserCols = extractColumnsFrom(tUser) */ extractedColumns: z.ZodDefault<z.ZodBoolean>; /** * Additionally export a column types mapping useful for constructing filter type * for dynamic conditions. * * Example: * export type UserCols = { * id: 'int' * name: 'string' * } */ columnTypeMappingInterface: z.ZodDefault<z.ZodBoolean>; /** * Generate a repository class to simplify common single-table CRUD operations * * This is currently only supported for tables having an id column as primary key */ crudRepository: z.ZodDefault<z.ZodBoolean>; }, "strip", z.ZodTypeAny, { tableInstances: boolean; tableClasses: boolean; rowTypes: boolean | { asInterface: boolean; }; valuesTypes: boolean | { asInterface: boolean; }; extractedColumns: boolean; columnTypeMappingInterface: boolean; crudRepository: boolean; }, { tableInstances?: boolean | undefined; tableClasses?: boolean | undefined; rowTypes?: boolean | { asInterface: boolean; } | undefined; valuesTypes?: boolean | { asInterface: boolean; } | undefined; extractedColumns?: boolean | undefined; columnTypeMappingInterface?: boolean | undefined; crudRepository?: boolean | undefined; }>; export interface ExportOptions extends z.input<typeof ExportOptionsSchema> { } export declare const NamingOptionsSchema: z.ZodObject<{ /** * Prefix to be used in the name of the class that reprecents a table */ tableClassNamePrefix: z.ZodDefault<z.ZodString>; /** * Suffix to be used in the name of the class that reprecents a table */ tableClassNameSuffix: z.ZodDefault<z.ZodString>; /** * Prefix to be used in the name of the class that reprecents a view */ viewClassNamePrefix: z.ZodDefault<z.ZodString>; /** * Suffix to be used in the name of the class that reprecents a view */ viewClassNameSuffix: z.ZodDefault<z.ZodString>; /** * Prefix to be used in the name of the instance of the class that reprecents a table */ tableInstanceNamePrefix: z.ZodDefault<z.ZodString>; /** * Suffix to be used in the name of the instance of the class that reprecents a table */ tableInstanceNameSuffix: z.ZodDefault<z.ZodString>; /** * Prefix to be used in the name of the instance of the class that reprecents a view */ viewInstanceNamePrefix: z.ZodDefault<z.ZodString>; /** * Suffix to be used in the name of the the instance of class that reprecents a view */ viewInstanceNameSuffix: z.ZodDefault<z.ZodString>; /** * Prefix to be used in the name of the InsertableRow type */ insertableRowTypeNamePrefix: z.ZodDefault<z.ZodString>; /** * Suffix to be used in the name of the InsertableRow type */ insertableRowTypeNameSuffix: z.ZodDefault<z.ZodString>; /** * Prefix to be used in the name of the UpdatableRow type */ updatableRowTypeNamePrefix: z.ZodDefault<z.ZodString>; /** * Suffix to be used in the name of the UpdatableRow type */ updatableRowTypeNameSuffix: z.ZodDefault<z.ZodString>; /** * Prefix to be used in the name of the SelectedRow type */ selectedRowTypeNamePrefix: z.ZodDefault<z.ZodString>; /** * Suffix to be used in the name of the SelectedRow type */ selectedRowTypeNameSuffix: z.ZodDefault<z.ZodString>; /** * Prefix to be used in the name of the InsertableValues type */ insertableValuesTypeNamePrefix: z.ZodDefault<z.ZodString>; /** * Suffix to be used in the name of the InsertableValues type */ insertableValuesTypeNameSuffix: z.ZodDefault<z.ZodString>; /** * Prefix to be used in the name of the UpdatableValues type */ updatableValuesTypeNamePrefix: z.ZodDefault<z.ZodString>; /** * Suffix to be used in the name of the UpdatableValues type */ updatableValuesTypeNameSuffix: z.ZodDefault<z.ZodString>; /** * Prefix to be used in the name of the SelectedValues type */ selectedValuesTypeNamePrefix: z.ZodDefault<z.ZodString>; /** * Suffix to be used in the name of the SelectedValues type */ selectedValuesTypeNameSuffix: z.ZodDefault<z.ZodString>; /** * Prefix to be used in the name of the const with the column list of a table */ tableColumnsNamePrefix: z.ZodDefault<z.ZodString>; /** * Suffix to be used in the name of the const with the column list of a table */ tableColumnsNameSuffix: z.ZodDefault<z.ZodString>; /** * Prefix to be used in the name of the const with the column list of a view */ viewColumnsNamePrefix: z.ZodDefault<z.ZodString>; /** * Suffix to be used in the name of the const with the column list of a view */ viewColumnsNameSuffix: z.ZodDefault<z.ZodString>; columnTypeMappingInterfaceNameSuffix: z.ZodDefault<z.ZodString>; crudRepositoryClassNamePrefix: z.ZodDefault<z.ZodString>; crudRepositoryClassNameSuffix: z.ZodDefault<z.ZodString>; }, "strip", z.ZodTypeAny, { tableClassNamePrefix: string; tableClassNameSuffix: string; viewClassNamePrefix: string; viewClassNameSuffix: string; tableInstanceNamePrefix: string; tableInstanceNameSuffix: string; viewInstanceNamePrefix: string; viewInstanceNameSuffix: string; insertableRowTypeNamePrefix: string; insertableRowTypeNameSuffix: string; updatableRowTypeNamePrefix: string; updatableRowTypeNameSuffix: string; selectedRowTypeNamePrefix: string; selectedRowTypeNameSuffix: string; insertableValuesTypeNamePrefix: string; insertableValuesTypeNameSuffix: string; updatableValuesTypeNamePrefix: string; updatableValuesTypeNameSuffix: string; selectedValuesTypeNamePrefix: string; selectedValuesTypeNameSuffix: string; tableColumnsNamePrefix: string; tableColumnsNameSuffix: string; viewColumnsNamePrefix: string; viewColumnsNameSuffix: string; columnTypeMappingInterfaceNameSuffix: string; crudRepositoryClassNamePrefix: string; crudRepositoryClassNameSuffix: string; }, { tableClassNamePrefix?: string | undefined; tableClassNameSuffix?: string | undefined; viewClassNamePrefix?: string | undefined; viewClassNameSuffix?: string | undefined; tableInstanceNamePrefix?: string | undefined; tableInstanceNameSuffix?: string | undefined; viewInstanceNamePrefix?: string | undefined; viewInstanceNameSuffix?: string | undefined; insertableRowTypeNamePrefix?: string | undefined; insertableRowTypeNameSuffix?: string | undefined; updatableRowTypeNamePrefix?: string | undefined; updatableRowTypeNameSuffix?: string | undefined; selectedRowTypeNamePrefix?: string | undefined; selectedRowTypeNameSuffix?: string | undefined; insertableValuesTypeNamePrefix?: string | undefined; insertableValuesTypeNameSuffix?: string | undefined; updatableValuesTypeNamePrefix?: string | undefined; updatableValuesTypeNameSuffix?: string | undefined; selectedValuesTypeNamePrefix?: string | undefined; selectedValuesTypeNameSuffix?: string | undefined; tableColumnsNamePrefix?: string | undefined; tableColumnsNameSuffix?: string | undefined; viewColumnsNamePrefix?: string | undefined; viewColumnsNameSuffix?: string | undefined; columnTypeMappingInterfaceNameSuffix?: string | undefined; crudRepositoryClassNamePrefix?: string | undefined; crudRepositoryClassNameSuffix?: string | undefined; }>; export interface NamingOptions extends z.input<typeof NamingOptionsSchema> { } export declare const CommonTypeAdapterOptionsSchema: z.ZodObject<{ /** * Common import path to be used for type adapters * when no specific import path is specified at field level */ importPath: z.ZodString; }, "strip", z.ZodTypeAny, { importPath: string; }, { importPath: string; }>; export interface CommonTypeAdapterOptions extends z.input<typeof CommonTypeAdapterOptionsSchema> { } export declare const TableMappingSchema: z.ZodObject<{ /** * Specify a prefix that will be prepended to the table name passed as generic parameter to Table type * This can be used for disambiguation when there can be multiple tables from different schema etc. */ idPrefix: z.ZodOptional<z.ZodNullable<z.ZodString>>; /** * Include the schema name in the table identifier passed to ts-sql-query */ useQualifiedTableName: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; }, "strip", z.ZodTypeAny, { idPrefix?: string | null | undefined; useQualifiedTableName?: boolean | null | undefined; }, { idPrefix?: string | null | undefined; useQualifiedTableName?: boolean | null | undefined; }>; export interface TableMapping extends z.input<typeof TableMappingSchema> { } export declare const CommonPrimaryKeyOptionsSchema: z.ZodObject<{ /** * Name of primary key column */ name: z.ZodOptional<z.ZodNullable<z.ZodString>>; /** * If primary key column is auto-generated */ isAutoGenerated: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; }, "strip", z.ZodTypeAny, { name?: string | null | undefined; isAutoGenerated?: boolean | null | undefined; }, { name?: string | null | undefined; isAutoGenerated?: boolean | null | undefined; }>; export interface CommonPrimaryKeyOptions extends z.input<typeof CommonPrimaryKeyOptionsSchema> { } export declare const CommonCustomTypesOptionsSchema: z.ZodObject<{ /** * Path from where custom types will be imported by default * * Relative to cwd */ importPath: z.ZodString; }, "strip", z.ZodTypeAny, { importPath: string; }, { importPath: string; }>; export interface CommonCustomTypesOptions extends z.input<typeof CommonCustomTypesOptionsSchema> { } export declare const CommonOptionsSchema: z.ZodObject<{ /** @see CommonCustomTypesOptions */ customTypes: z.ZodOptional<z.ZodNullable<z.ZodObject<{ /** * Path from where custom types will be imported by default * * Relative to cwd */ importPath: z.ZodString; }, "strip", z.ZodTypeAny, { importPath: string; }, { importPath: string; }>>>; /** @see CommonPrimaryKeyOptions */ typeAdapter: z.ZodOptional<z.ZodNullable<z.ZodObject<{ /** * Common import path to be used for type adapters * when no specific import path is specified at field level */ importPath: z.ZodString; }, "strip", z.ZodTypeAny, { importPath: string; }, { importPath: string; }>>>; /** @see CommonCustomTypesOptions */ primaryKey: z.ZodOptional<z.ZodNullable<z.ZodObject<{ /** * Name of primary key column */ name: z.ZodOptional<z.ZodNullable<z.ZodString>>; /** * If primary key column is auto-generated */ isAutoGenerated: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; }, "strip", z.ZodTypeAny, { name?: string | null | undefined; isAutoGenerated?: boolean | null | undefined; }, { name?: string | null | undefined; isAutoGenerated?: boolean | null | undefined; }>>>; }, "strip", z.ZodTypeAny, { customTypes?: { importPath: string; } | null | undefined; typeAdapter?: { importPath: string; } | null | undefined; primaryKey?: { name?: string | null | undefined; isAutoGenerated?: boolean | null | undefined; } | null | undefined; }, { customTypes?: { importPath: string; } | null | undefined; typeAdapter?: { importPath: string; } | null | undefined; primaryKey?: { name?: string | null | undefined; isAutoGenerated?: boolean | null | undefined; } | null | undefined; }>; export interface CommonOptions extends z.input<typeof CommonOptionsSchema> { } export declare const RawContentSchema: z.ZodObject<{ /** Raw content injected before generated code in each file */ before: z.ZodOptional<z.ZodNullable<z.ZodString>>; /** Raw content injected after generated code in each file */ after: z.ZodOptional<z.ZodNullable<z.ZodString>>; }, "strip", z.ZodTypeAny, { before?: string | null | undefined; after?: string | null | undefined; }, { before?: string | null | undefined; after?: string | null | undefined; }>; export interface RawContent extends z.input<typeof RawContentSchema> { } export declare const TypeWrapperSchema: z.ZodObject<{ typeName: z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>; wrapper: z.ZodObject<{ name: z.ZodString; importPath: z.ZodOptional<z.ZodNullable<z.ZodString>>; isDefault: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; isRelative: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; }, "strip", z.ZodTypeAny, { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; }, { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; }>; }, "strip", z.ZodTypeAny, { typeName: string | RegExp; wrapper: { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; }; }, { typeName: string | RegExp; wrapper: { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; }; }>; export declare const OutputImportOptionsSchema: z.ZodObject<{ extension: z.ZodOptional<z.ZodNullable<z.ZodString>>; }, "strip", z.ZodTypeAny, { extension?: string | null | undefined; }, { extension?: string | null | undefined; }>; export declare const OutputOptionsSchema: z.ZodObject<{ import: z.ZodOptional<z.ZodNullable<z.ZodObject<{ extension: z.ZodOptional<z.ZodNullable<z.ZodString>>; }, "strip", z.ZodTypeAny, { extension?: string | null | undefined; }, { extension?: string | null | undefined; }>>>; }, "strip", z.ZodTypeAny, { import?: { extension?: string | null | undefined; } | null | undefined; }, { import?: { extension?: string | null | undefined; } | null | undefined; }>; export declare const ConnectionSourceOptionsSchema: z.ZodObject<{ path: z.ZodOptional<z.ZodNullable<z.ZodString>>; resolveRelative: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; }, "strip", z.ZodTypeAny, { path?: string | null | undefined; resolveRelative?: boolean | null | undefined; }, { path?: string | null | undefined; resolveRelative?: boolean | null | undefined; }>; export interface ConnectionSourceOptions extends z.input<typeof ConnectionSourceOptionsSchema> { } export declare const GeneratorOptsSchema: z.ZodObject<{ /** Root path of module - used for resolving relative paths. If unspecified, assumed to be cwd */ moduleRoot: z.ZodOptional<z.ZodNullable<z.ZodString>>; /** Simulate the generation and print the outcome without actually modifying any files */ dryRun: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; /** Path to yaml schema dumped by tbls */ schemaPath: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string, string | null | undefined>; /** * Path to module that exports DBConnection object used in table mappers * @deprecated * @see connectionSource */ connectionSourcePath: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string, string | null | undefined>; /** * Connection source configuration * @see ConnectionSourceOptions */ connectionSource: z.ZodOptional<z.ZodNullable<z.ZodObject<{ path: z.ZodOptional<z.ZodNullable<z.ZodString>>; resolveRelative: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; }, "strip", z.ZodTypeAny, { path?: string | null | undefined; resolveRelative?: boolean | null | undefined; }, { path?: string | null | undefined; resolveRelative?: boolean | null | undefined; }>>>; /** Path to output directory where a typescript class file will be generated for each table */ outputDirPath: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string, string | null | undefined>; /** * Customize how table columns are mapped to typescript fields * * @see FieldMapping */ fieldMappings: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{ columnName: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>>>; tableName: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>>>; columnType: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>>>; generatedField: z.ZodUnion<[z.ZodObject<{ type: z.ZodOptional<z.ZodNullable<z.ZodObject<{ kind: z.ZodOptional<z.ZodNullable<z.ZodEnum<["custom", "customComparable", "enum", "customInt", "customDouble", "customUuid", "customLocalDate", "customLocalTime", "customLocalDateTime"]>>>; dbType: z.ZodOptional<z.ZodNullable<z.ZodObject<{ name: z.ZodString; }, "strip", z.ZodTypeAny, { name: string; }, { name: string; }>>>; tsType: z.ZodOptional<z.ZodNullable<z.ZodObject<{ name: z.ZodString; importPath: z.ZodOptional<z.ZodNullable<z.ZodString>>; isDefault: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; isRelative: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; }, "strip", z.ZodTypeAny, { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; }, { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; }>>>; adapter: z.ZodOptional<z.ZodNullable<z.ZodObject<{ name: z.ZodString; importPath: z.ZodOptional<z.ZodNullable<z.ZodString>>; isDefault: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; isRelative: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; }, "strip", z.ZodTypeAny, { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; }, { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; }>>>; }, "strip", z.ZodTypeAny, { kind?: "custom" | "customComparable" | "enum" | "customInt" | "customDouble" | "customUuid" | "customLocalDate" | "customLocalTime" | "customLocalDateTime" | null | undefined; dbType?: { name: string; } | null | undefined; tsType?: { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; } | null | undefined; adapter?: { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; } | null | undefined; }, { kind?: "custom" | "customComparable" | "enum" | "customInt" | "customDouble" | "customUuid" | "customLocalDate" | "customLocalTime" | "customLocalDateTime" | null | undefined; dbType?: { name: string; } | null | undefined; tsType?: { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; } | null | undefined; adapter?: { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; } | null | undefined; }>>>; name: z.ZodOptional<z.ZodNullable<z.ZodString>>; isComputed: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; isOptional: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; hasDefault: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; }, "strip", z.ZodTypeAny, { type?: { kind?: "custom" | "customComparable" | "enum" | "customInt" | "customDouble" | "customUuid" | "customLocalDate" | "customLocalTime" | "customLocalDateTime" | null | undefined; dbType?: { name: string; } | null | undefined; tsType?: { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; } | null | undefined; adapter?: { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; } | null | undefined; } | null | undefined; name?: string | null | undefined; isComputed?: boolean | null | undefined; isOptional?: boolean | null | undefined; hasDefault?: boolean | null | undefined; }, { type?: { kind?: "custom" | "customComparable" | "enum" | "customInt" | "customDouble" | "customUuid" | "customLocalDate" | "customLocalTime" | "customLocalDateTime" | null | undefined; dbType?: { name: string; } | null | undefined; tsType?: { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; } | null | undefined; adapter?: { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; } | null | undefined; } | null | undefined; name?: string | null | undefined; isComputed?: boolean | null | undefined; isOptional?: boolean | null | undefined; hasDefault?: boolean | null | undefined; }>, z.ZodLiteral<false>]>; comment: z.ZodOptional<z.ZodNullable<z.ZodString>>; }, "strip", z.ZodTypeAny, { generatedField: false | { type?: { kind?: "custom" | "customComparable" | "enum" | "customInt" | "customDouble" | "customUuid" | "customLocalDate" | "customLocalTime" | "customLocalDateTime" | null | undefined; dbType?: { name: string; } | null | undefined; tsType?: { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; } | null | undefined; adapter?: { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; } | null | undefined; } | null | undefined; name?: string | null | undefined; isComputed?: boolean | null | undefined; isOptional?: boolean | null | undefined; hasDefault?: boolean | null | undefined; }; columnName?: string | RegExp | null | undefined; tableName?: string | RegExp | null | undefined; columnType?: string | RegExp | null | undefined; comment?: string | null | undefined; }, { generatedField: false | { type?: { kind?: "custom" | "customComparable" | "enum" | "customInt" | "customDouble" | "customUuid" | "customLocalDate" | "customLocalTime" | "customLocalDateTime" | null | undefined; dbType?: { name: string; } | null | undefined; tsType?: { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; } | null | undefined; adapter?: { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; } | null | undefined; } | null | undefined; name?: string | null | undefined; isComputed?: boolean | null | undefined; isOptional?: boolean | null | undefined; hasDefault?: boolean | null | undefined; }; columnName?: string | RegExp | null | undefined; tableName?: string | RegExp | null | undefined; columnType?: string | RegExp | null | undefined; comment?: string | null | undefined; }>, "many">>>; /** * Customize how tables are mapped * * @see TableMapping */ tableMapping: z.ZodOptional<z.ZodNullable<z.ZodObject<{ /** * Specify a prefix that will be prepended to the table name passed as generic parameter to Table type * This can be used for disambiguation when there can be multiple tables from different schema etc. */ idPrefix: z.ZodOptional<z.ZodNullable<z.ZodString>>; /** * Include the schema name in the table identifier passed to ts-sql-query */ useQualifiedTableName: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; }, "strip", z.ZodTypeAny, { idPrefix?: string | null | undefined; useQualifiedTableName?: boolean | null | undefined; }, { idPrefix?: string | null | undefined; useQualifiedTableName?: boolean | null | undefined; }>>>; /** * Restrict the generator to process only a subset of tables * available * * @see TableInclusion */ tables: z.ZodOptional<z.ZodNullable<z.ZodObject<{ /** * Tables to be included - identified by qualified table name * or regular expression */ include: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, "many">>>; /** * Tables to be excluded - identified by qualified table name * or regular expression */ exclude: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, "many">>>; }, "strip", z.ZodTypeAny, { include?: (string | RegExp)[] | null | undefined; exclude?: (string | RegExp)[] | null | undefined; }, { include?: (string | RegExp)[] | null | undefined; exclude?: (string | RegExp)[] | null | undefined; }>>>; /** * Shared options that affect all generated output */ output: z.ZodOptional<z.ZodNullable<z.ZodObject<{ import: z.ZodOptional<z.ZodNullable<z.ZodObject<{ extension: z.ZodOptional<z.ZodNullable<z.ZodString>>; }, "strip", z.ZodTypeAny, { extension?: string | null | undefined; }, { extension?: string | null | undefined; }>>>; }, "strip", z.ZodTypeAny, { import?: { extension?: string | null | undefined; } | null | undefined; }, { import?: { extension?: string | null | undefined; } | null | undefined; }>>>; /** * Customize what all entities are exported from generated file * * @see ExportOptions */ export: z.ZodOptional<z.ZodNullable<z.ZodObject<{ tableInstances: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>; tableClasses: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>; rowTypes: z.ZodOptional<z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{ /** * If enabled, instead of type alias we will generate interfaces * * This can make type errors more succinct. */ asInterface: z.ZodBoolean; }, "strip", z.ZodTypeAny, { asInterface: boolean; }, { asInterface: boolean; }>]>>>; valuesTypes: z.ZodOptional<z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{ /** * If enabled, instead of type alias we will generate interfaces * * This can make type errors more succinct. */ asInterface: z.ZodBoolean; }, "strip", z.ZodTypeAny, { asInterface: boolean; }, { asInterface: boolean; }>]>>>; extractedColumns: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>; columnTypeMappingInterface: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>; crudRepository: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>; }, "strip", z.ZodTypeAny, { tableInstances?: boolean | undefined; tableClasses?: boolean | undefined; rowTypes?: boolean | { asInterface: boolean; } | undefined; valuesTypes?: boolean | { asInterface: boolean; } | undefined; extractedColumns?: boolean | undefined; columnTypeMappingInterface?: boolean | undefined; crudRepository?: boolean | undefined; }, { tableInstances?: boolean | undefined; tableClasses?: boolean | undefined; rowTypes?: boolean | { asInterface: boolean; } | undefined; valuesTypes?: boolean | { asInterface: boolean; } | undefined; extractedColumns?: boolean | undefined; columnTypeMappingInterface?: boolean | undefined; crudRepository?: boolean | undefined; }>>>; /** * Convenience utility for common cases where all tables * follow same conventions * * See {@link CommonOptions} */ common: z.ZodOptional<z.ZodNullable<z.ZodObject<{ /** @see CommonCustomTypesOptions */ customTypes: z.ZodOptional<z.ZodNullable<z.ZodObject<{ /** * Path from where custom types will be imported by default * * Relative to cwd */ importPath: z.ZodString; }, "strip", z.ZodTypeAny, { importPath: string; }, { importPath: string; }>>>; /** @see CommonPrimaryKeyOptions */ typeAdapter: z.ZodOptional<z.ZodNullable<z.ZodObject<{ /** * Common import path to be used for type adapters * when no specific import path is specified at field level */ importPath: z.ZodString; }, "strip", z.ZodTypeAny, { importPath: string; }, { importPath: string; }>>>; /** @see CommonCustomTypesOptions */ primaryKey: z.ZodOptional<z.ZodNullable<z.ZodObject<{ /** * Name of primary key column */ name: z.ZodOptional<z.ZodNullable<z.ZodString>>; /** * If primary key column is auto-generated */ isAutoGenerated: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; }, "strip", z.ZodTypeAny, { name?: string | null | undefined; isAutoGenerated?: boolean | null | undefined; }, { name?: string | null | undefined; isAutoGenerated?: boolean | null | undefined; }>>>; }, "strip", z.ZodTypeAny, { customTypes?: { importPath: string; } | null | undefined; typeAdapter?: { importPath: string; } | null | undefined; primaryKey?: { name?: string | null | undefined; isAutoGenerated?: boolean | null | undefined; } | null | undefined; }, { customTypes?: { importPath: string; } | null | undefined; typeAdapter?: { importPath: string; } | null | undefined; primaryKey?: { name?: string | null | undefined; isAutoGenerated?: boolean | null | undefined; } | null | undefined; }>>>; /** * Customize the naming rules of the generated items * * See NamingOptions */ naming: z.ZodOptional<z.ZodNullable<z.ZodObject<{ tableClassNamePrefix: z.ZodOptional<z.ZodDefault<z.ZodString>>; tableClassNameSuffix: z.ZodOptional<z.ZodDefault<z.ZodString>>; viewClassNamePrefix: z.ZodOptional<z.ZodDefault<z.ZodString>>; viewClassNameSuffix: z.ZodOptional<z.ZodDefault<z.ZodString>>; tableInstanceNamePrefix: z.ZodOptional<z.ZodDefault<z.ZodString>>; tableInstanceNameSuffix: z.ZodOptional<z.ZodDefault<z.ZodString>>; viewInstanceNamePrefix: z.ZodOptional<z.ZodDefault<z.ZodString>>; viewInstanceNameSuffix: z.ZodOptional<z.ZodDefault<z.ZodString>>; insertableRowTypeNamePrefix: z.ZodOptional<z.ZodDefault<z.ZodString>>; insertableRowTypeNameSuffix: z.ZodOptional<z.ZodDefault<z.ZodString>>; updatableRowTypeNamePrefix: z.ZodOptional<z.ZodDefault<z.ZodString>>; updatableRowTypeNameSuffix: z.ZodOptional<z.ZodDefault<z.ZodString>>; selectedRowTypeNamePrefix: z.ZodOptional<z.ZodDefault<z.ZodString>>; selectedRowTypeNameSuffix: z.ZodOptional<z.ZodDefault<z.ZodString>>; insertableValuesTypeNamePrefix: z.ZodOptional<z.ZodDefault<z.ZodString>>; insertableValuesTypeNameSuffix: z.ZodOptional<z.ZodDefault<z.ZodString>>; updatableValuesTypeNamePrefix: z.ZodOptional<z.ZodDefault<z.ZodString>>; updatableValuesTypeNameSuffix: z.ZodOptional<z.ZodDefault<z.ZodString>>; selectedValuesTypeNamePrefix: z.ZodOptional<z.ZodDefault<z.ZodString>>; selectedValuesTypeNameSuffix: z.ZodOptional<z.ZodDefault<z.ZodString>>; tableColumnsNamePrefix: z.ZodOptional<z.ZodDefault<z.ZodString>>; tableColumnsNameSuffix: z.ZodOptional<z.ZodDefault<z.ZodString>>; viewColumnsNamePrefix: z.ZodOptional<z.ZodDefault<z.ZodString>>; viewColumnsNameSuffix: z.ZodOptional<z.ZodDefault<z.ZodString>>; columnTypeMappingInterfaceNameSuffix: z.ZodOptional<z.ZodDefault<z.ZodString>>; crudRepositoryClassNamePrefix: z.ZodOptional<z.ZodDefault<z.ZodString>>; crudRepositoryClassNameSuffix: z.ZodOptional<z.ZodDefault<z.ZodString>>; }, "strip", z.ZodTypeAny, { tableClassNamePrefix?: string | undefined; tableClassNameSuffix?: string | undefined; viewClassNamePrefix?: string | undefined; viewClassNameSuffix?: string | undefined; tableInstanceNamePrefix?: string | undefined; tableInstanceNameSuffix?: string | undefined; viewInstanceNamePrefix?: string | undefined; viewInstanceNameSuffix?: string | undefined; insertableRowTypeNamePrefix?: string | undefined; insertableRowTypeNameSuffix?: string | undefined; updatableRowTypeNamePrefix?: string | undefined; updatableRowTypeNameSuffix?: string | undefined; selectedRowTypeNamePrefix?: string | undefined; selectedRowTypeNameSuffix?: string | undefined; insertableValuesTypeNamePrefix?: string | undefined; insertableValuesTypeNameSuffix?: string | undefined; updatableValuesTypeNamePrefix?: string | undefined; updatableValuesTypeNameSuffix?: string | undefined; selectedValuesTypeNamePrefix?: string | undefined; selectedValuesTypeNameSuffix?: string | undefined; tableColumnsNamePrefix?: string | undefined; tableColumnsNameSuffix?: string | undefined; viewColumnsNamePrefix?: string | undefined; viewColumnsNameSuffix?: string | undefined; columnTypeMappingInterfaceNameSuffix?: string | undefined; crudRepositoryClassNamePrefix?: string | undefined; crudRepositoryClassNameSuffix?: string | undefined; }, { tableClassNamePrefix?: string | undefined; tableClassNameSuffix?: string | undefined; viewClassNamePrefix?: string | undefined; viewClassNameSuffix?: string | undefined; tableInstanceNamePrefix?: string | undefined; tableInstanceNameSuffix?: string | undefined; viewInstanceNamePrefix?: string | undefined; viewInstanceNameSuffix?: string | undefined; insertableRowTypeNamePrefix?: string | undefined; insertableRowTypeNameSuffix?: string | undefined; updatableRowTypeNamePrefix?: string | undefined; updatableRowTypeNameSuffix?: string | undefined; selectedRowTypeNamePrefix?: string | undefined; selectedRowTypeNameSuffix?: string | undefined; insertableValuesTypeNamePrefix?: string | undefined; insertableValuesTypeNameSuffix?: string | undefined; updatableValuesTypeNamePrefix?: string | undefined; updatableValuesTypeNameSuffix?: string | undefined; selectedValuesTypeNamePrefix?: string | undefined; selectedValuesTypeNameSuffix?: string | undefined; tableColumnsNamePrefix?: string | undefined; tableColumnsNameSuffix?: string | undefined; viewColumnsNamePrefix?: string | undefined; viewColumnsNameSuffix?: string | undefined; columnTypeMappingInterfaceNameSuffix?: string | undefined; crudRepositoryClassNamePrefix?: string | undefined; crudRepositoryClassNameSuffix?: string | undefined; }>>>; /** * The fields marked as "custom", "customComparable" or "enum" receive a second generic * argument that need to be the same of the db type in the database or redefined for the field * If you set to true this property that second generic argument will be generated. */ includeDBTypeWhenIsOptional: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; /** * Remove extraneous files after code generation completes - this prevents you from * having to manually clean up files after eg. any table has been deleted, but it is * your responsibility to ensure that the outputDir used solely for files generated through * this utility and all files are written as part of single run. * * Defauls to retaining all extraneous files. */ removeExtraneous: z.ZodOptional<z.ZodNullable<z.ZodEnum<["never", "interactively", "all"]>>>; /** * Support injection of raw content in the generated files. * This is useful for adding things like eslint-disable, additional exports etc. * * @see RawContent */ rawContent: z.ZodOptional<z.ZodNullable<z.ZodObject<{ /** Raw content injected before generated code in each file */ before: z.ZodOptional<z.ZodNullable<z.ZodString>>; /** Raw content injected after generated code in each file */ after: z.ZodOptional<z.ZodNullable<z.ZodString>>; }, "strip", z.ZodTypeAny, { before?: string | null | undefined; after?: string | null | undefined; }, { before?: string | null | undefined; after?: string | null | undefined; }>>>; /** * Wrap inferred types before exporting - this is useful to restrict * the types used for insert/update etc. beyond what the database permits. * * Eg. We can hint that updatedAt must be set whenever record is updated * * @see TypeWapper */ typeWrappers: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{ typeName: z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>; wrapper: z.ZodObject<{ name: z.ZodString; importPath: z.ZodOptional<z.ZodNullable<z.ZodString>>; isDefault: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; isRelative: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; }, "strip", z.ZodTypeAny, { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; }, { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; }>; }, "strip", z.ZodTypeAny, { typeName: string | RegExp; wrapper: { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; }; }, { typeName: string | RegExp; wrapper: { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; }; }>, "many">>>; }, "strip", z.ZodTypeAny, { schemaPath: string; connectionSourcePath: string; outputDirPath: string; moduleRoot?: string | null | undefined; dryRun?: boolean | null | undefined; connectionSource?: { path?: string | null | undefined; resolveRelative?: boolean | null | undefined; } | null | undefined; fieldMappings?: { generatedField: false | { type?: { kind?: "custom" | "customComparable" | "enum" | "customInt" | "customDouble" | "customUuid" | "customLocalDate" | "customLocalTime" | "customLocalDateTime" | null | undefined; dbType?: { name: string; } | null | undefined; tsType?: { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; } | null | undefined; adapter?: { name: string; importPath?: string | null | undefined; isDefault?: boolean | null | undefined; isRelative?: boolean | null | undefined; } | null | undefined; } | null | undefined; name?: string | null | undefined; isComputed?: boolean | null | undefined; isOptional?: boolean | null | undefined; hasDefault?: boolean | null | undefined; }; columnName?: string | RegExp | null | undefined; tableName?: string | RegExp | null | undefined; columnType?: string | RegExp | null | undefined; comment?: string | null | undefined; }[] | null | undefined; tableMapping?: { idPrefix?: string | null | undefined; useQualifiedTableName?: boolean | null | undefined; } | null | undefined; tables?: { include?: (string | RegExp)[] | null | undefined; exclude?: (string | RegExp)[] | null | undefined; } | null | undefined; output?: { import?: { extension?: string | null | undefined; } | null | undefined; } | null | undefined; export?: { tableInstances?: boolean | undefined; tableClasses?: boolean | undefined; rowTypes?: boolean | { asInterface: boolean; } | undefined; valuesTypes?: boolean | { asInterface: boolean; } | undefined; extractedColumns?: boolean | undefined; columnTypeMappingInterface?: boolean | undefined;