ts-sql-codegen / GeneratorOpts
Generator options
-
TypeOf
<typeofGeneratorOptsSchema
>↳
GeneratorOpts
- common
- connectionSourcePath
- dryRun
- export
- fieldMappings
- includeDBTypeWhenIsOptional
- naming
- output
- outputDirPath
- rawContent
- removeExtraneous
- schemaPath
- tableMapping
- tables
- typeWrappers
• 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
z.TypeOf.common
• connectionSourcePath: string
Path to module that exports DBConnection object used in table mappers
z.TypeOf.connectionSourcePath
• Optional
dryRun: null
| boolean
Simulate the generation and print the outcome without actually modifying any files
z.TypeOf.dryRun
• 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
z.TypeOf.export
• 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
z.TypeOf.fieldMappings
• 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.
z.TypeOf.includeDBTypeWhenIsOptional
• 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
z.TypeOf.naming
• Optional
output: null
| { import?
: null
| { extension?
: null
| string
} }
Shared options that affect all generated output
z.TypeOf.output
• outputDirPath: string
Path to output directory where a typescript class file will be generated for each table
z.TypeOf.outputDirPath
• 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
z.TypeOf.rawContent
• 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.
z.TypeOf.removeExtraneous
• schemaPath: string
Path to yaml schema dumped by tbls
z.TypeOf.schemaPath
• Optional
tableMapping: null
| { idPrefix?
: null
| string
; useQualifiedTableName?
: null
| boolean
}
Customize how tables are mapped
See
TableMapping
z.TypeOf.tableMapping
• Optional
tables: null
| { exclude?
: null
| (string
| RegExp
)[] ; include?
: null
| (string
| RegExp
)[] }
Restrict the generator to process only a subset of tables available
See
TableInclusion
z.TypeOf.tables
• 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
z.TypeOf.typeWrappers