The @tupaia/types package represents the typings for all Tupaia models for reuse across the monorepo.
Models are generated from the db schema, run yarn generate:models
to update this after changes to the db schema.
Json type columns (typically named "config" in Tupaia) need to be specified manually:
- Write the Type Definition and place it under models-extra e.g. ReportConfig for column report.config
- Override the type in
./config/models/config.json
undertypeOverrides
e.g."public.report.config": "ReportConfig"
- Import the type at the top of
models.ts
by specifying the import in config undercustom
>imports
e.g."ReportConfig": "./models-extra"
Geography type columns, for example, 'bounds', 'region' etc are set to generate as strings, otherwise they become 'any' which meeds to be overwritten in individual packages. This is handled in typeMap
All config options here: https://rmp135.github.io/sql-ts
Json schemas are automatically generated for all exported types. Run yarn generate:schemas
to update this after a type is changed.