Skip to content

Latest commit

 

History

History
318 lines (171 loc) · 10.6 KB

GeneratorOpts.md

File metadata and controls

318 lines (171 loc) · 10.6 KB

ts-sql-codegen / GeneratorOpts

Interface: GeneratorOpts

Generator options

Hierarchy

  • TypeOf<typeof GeneratorOptsSchema>

    GeneratorOpts

Table of contents

Properties

Properties

common

Optional common: null | { customTypes?: null | { importPath: string } ; primaryKey?: null | { isAutoGenerated?: null | boolean ; name?: null | string } ; typeAdapter?: null | { importPath: string } }

Convenience utility for common cases where all tables follow same conventions

See CommonOptions

Inherited from

z.TypeOf.common

Defined in

src/generator-options.ts:381


connectionSourcePath

connectionSourcePath: string

Path to module that exports DBConnection object used in table mappers

Inherited from

z.TypeOf.connectionSourcePath

Defined in

src/generator-options.ts:330

src/generator-options.ts:330


dryRun

Optional dryRun: null | boolean

Simulate the generation and print the outcome without actually modifying any files

Inherited from

z.TypeOf.dryRun

Defined in

src/generator-options.ts:321


export

Optional export: null | { columnTypeMappingInterface?: boolean ; crudRepository?: boolean ; extractedColumns?: boolean ; rowTypes?: boolean | { asInterface: boolean } ; tableClasses?: boolean ; tableInstances?: boolean ; valuesTypes?: boolean | { asInterface: boolean } }

Customize what all entities are exported from generated file

See

ExportOptions

Inherited from

z.TypeOf.export

Defined in

src/generator-options.ts:373


fieldMappings

Optional fieldMappings: null | { columnName?: null | string | RegExp ; columnType?: null | string | RegExp ; comment?: null | string ; generatedField: false | { hasDefault?: null | boolean ; isComputed?: null | boolean ; isOptional?: null | boolean ; name?: null | string ; type?: null | { adapter?: null | { importPath?: null | string ; isDefault?: null | boolean ; isRelative?: null | boolean ; name: string } ; dbType?: null | { name: string } ; kind?: null | "custom" | "customComparable" | "enum" | "customInt" | "customDouble" | "customUuid" | "customLocalDate" | "customLocalTime" | "customLocalDateTime" ; tsType?: null | { importPath?: null | string ; isDefault?: null | boolean ; isRelative?: null | boolean ; name: string } } } & undefined | false | { hasDefault?: null | boolean ; isComputed?: null | boolean ; isOptional?: null | boolean ; name?: null | string ; type?: null | { adapter?: null | { importPath?: null | string ; isDefault?: null | boolean ; isRelative?: null | boolean ; name: string } ; dbType?: null | { name: string } ; kind?: null | "custom" | "customComparable" | "enum" | "customInt" | "customDouble" | "customUuid" | "customLocalDate" | "customLocalTime" | "customLocalDateTime" ; tsType?: null | { importPath?: null | string ; isDefault?: null | boolean ; isRelative?: null | boolean ; name: string } } } ; tableName?: null | string | RegExp }[]

Customize how table columns are mapped to typescript fields

See

FieldMapping

Inherited from

z.TypeOf.fieldMappings

Defined in

src/generator-options.ts:346


includeDBTypeWhenIsOptional

Optional includeDBTypeWhenIsOptional: null | boolean

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.

Inherited from

z.TypeOf.includeDBTypeWhenIsOptional

Defined in

src/generator-options.ts:395


naming

Optional naming: null | { columnTypeMappingInterfaceNameSuffix?: string ; crudRepositoryClassNamePrefix?: string ; crudRepositoryClassNameSuffix?: string ; insertableRowTypeNamePrefix?: string ; insertableRowTypeNameSuffix?: string ; insertableValuesTypeNamePrefix?: string ; insertableValuesTypeNameSuffix?: string ; selectedRowTypeNamePrefix?: string ; selectedRowTypeNameSuffix?: string ; selectedValuesTypeNamePrefix?: string ; selectedValuesTypeNameSuffix?: string ; tableClassNamePrefix?: string ; tableClassNameSuffix?: string ; tableColumnsNamePrefix?: string ; tableColumnsNameSuffix?: string ; tableInstanceNamePrefix?: string ; tableInstanceNameSuffix?: string ; updatableRowTypeNamePrefix?: string ; updatableRowTypeNameSuffix?: string ; updatableValuesTypeNamePrefix?: string ; updatableValuesTypeNameSuffix?: string ; viewClassNamePrefix?: string ; viewClassNameSuffix?: string ; viewColumnsNamePrefix?: string ; viewColumnsNameSuffix?: string ; viewInstanceNamePrefix?: string ; viewInstanceNameSuffix?: string }

Customize the naming rules of the generated items

See NamingOptions

Inherited from

z.TypeOf.naming

Defined in

src/generator-options.ts:388


output

Optional output: null | { import?: null | { extension?: null | string } }

Shared options that affect all generated output

Inherited from

z.TypeOf.output

Defined in

src/generator-options.ts:366


outputDirPath

outputDirPath: string

Path to output directory where a typescript class file will be generated for each table

Inherited from

z.TypeOf.outputDirPath

Defined in

src/generator-options.ts:336

src/generator-options.ts:336


rawContent

Optional rawContent: null | { after?: null | string ; before?: null | string }

Support injection of raw content in the generated files. This is useful for adding things like eslint-disable, additional exports etc.

See

RawContent

Inherited from

z.TypeOf.rawContent

Defined in

src/generator-options.ts:417


removeExtraneous

Optional removeExtraneous: null | "never" | "interactively" | "all"

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.

Inherited from

z.TypeOf.removeExtraneous

Defined in

src/generator-options.ts:405


schemaPath

schemaPath: string

Path to yaml schema dumped by tbls

Inherited from

z.TypeOf.schemaPath

Defined in

src/generator-options.ts:324

src/generator-options.ts:324


tableMapping

Optional tableMapping: null | { idPrefix?: null | string ; useQualifiedTableName?: null | boolean }

Customize how tables are mapped

See

TableMapping

Inherited from

z.TypeOf.tableMapping

Defined in

src/generator-options.ts:353


tables

Optional tables: null | { exclude?: null | (string | RegExp)[] ; include?: null | (string | RegExp)[] }

Restrict the generator to process only a subset of tables available

See

TableInclusion

Inherited from

z.TypeOf.tables

Defined in

src/generator-options.ts:361


typeWrappers

Optional typeWrappers: null | { typeName: string | RegExp & undefined | string | RegExp = StrOrRegExpSchema; wrapper: { importPath?: null | string ; isDefault?: null | boolean ; isRelative?: null | boolean ; name: string } = ImportedItemSchema }[]

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

Inherited from

z.TypeOf.typeWrappers

Defined in

src/generator-options.ts:427