Skip to content

Latest commit

 

History

History
356 lines (191 loc) · 11 KB

File metadata and controls

356 lines (191 loc) · 11 KB

ts-sql-codegen / GeneratorOpts

Interface: GeneratorOpts

Generator options

Hierarchy

  • input<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.input.common

Defined in

src/generator-options.ts:401


connectionSource

• Optional connectionSource: null | { path?: null | string ; resolveRelative?: null | boolean }

Connection source configuration

See

ConnectionSourceOptions

Inherited from

z.input.connectionSource

Defined in

src/generator-options.ts:353


connectionSourcePath

• Optional connectionSourcePath: null | string

Path to module that exports DBConnection object used in table mappers

Deprecated

See

connectionSource

Inherited from

z.input.connectionSourcePath

Defined in

src/generator-options.ts:344


dryRun

• Optional dryRun: null | boolean

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

Inherited from

z.input.dryRun

Defined in

src/generator-options.ts:331


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.input.export

Defined in

src/generator-options.ts:393


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 } } } ; tableName?: null | string | RegExp }[]

Customize how table columns are mapped to typescript fields

See

FieldMapping

Inherited from

z.input.fieldMappings

Defined in

src/generator-options.ts:366


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.input.includeDBTypeWhenIsOptional

Defined in

src/generator-options.ts:415


moduleRoot

• Optional moduleRoot: null | string

Root path of module - used for resolving relative paths. If unspecified, assumed to be cwd

Inherited from

z.input.moduleRoot

Defined in

src/generator-options.ts:328


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.input.naming

Defined in

src/generator-options.ts:408


output

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

Shared options that affect all generated output

Inherited from

z.input.output

Defined in

src/generator-options.ts:386


outputDirPath

• Optional outputDirPath: null | string

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

Inherited from

z.input.outputDirPath

Defined in

src/generator-options.ts:356


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.input.rawContent

Defined in

src/generator-options.ts:437


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.input.removeExtraneous

Defined in

src/generator-options.ts:425


schemaPath

• Optional schemaPath: null | string

Path to yaml schema dumped by tbls

Inherited from

z.input.schemaPath

Defined in

src/generator-options.ts:334


tableMapping

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

Customize how tables are mapped

See

TableMapping

Inherited from

z.input.tableMapping

Defined in

src/generator-options.ts:373


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.input.tables

Defined in

src/generator-options.ts:381


typeWrappers

• Optional typeWrappers: null | { typeName: 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.input.typeWrappers

Defined in

src/generator-options.ts:447