sequelize-typescript-generator 13.1.0 → 13.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +274 -20
  2. package/build/bin/cli.js +3 -3
  3. package/build/bin/utils.d.ts +13 -0
  4. package/build/bin/utils.js +25 -0
  5. package/build/builders/ModelBuilder.d.ts +2 -1
  6. package/build/builders/ModelBuilder.js +135 -16
  7. package/build/builders/NativeModelRenderer.d.ts +4 -3
  8. package/build/builders/NativeModelRenderer.js +31 -11
  9. package/build/builders/enumSupport.d.ts +104 -0
  10. package/build/builders/enumSupport.js +323 -0
  11. package/build/builders/generatedFile.d.ts +2 -1
  12. package/build/builders/generatedFile.js +7 -1
  13. package/build/builders/jsonSupport.d.ts +10 -3
  14. package/build/builders/jsonSupport.js +10 -3
  15. package/build/builders/typeOverrides.d.ts +30 -0
  16. package/build/builders/typeOverrides.js +93 -0
  17. package/build/builders/typeOverridesParser.d.ts +48 -0
  18. package/build/builders/typeOverridesParser.js +305 -0
  19. package/build/builders/unmappedTypes.d.ts +50 -0
  20. package/build/builders/unmappedTypes.js +62 -0
  21. package/build/builders/utils.js +3 -0
  22. package/build/config/IConfig.d.ts +22 -0
  23. package/build/dialects/Dialect.d.ts +56 -3
  24. package/build/dialects/DialectMSSQL.d.ts +2 -2
  25. package/build/dialects/DialectMSSQL.js +1 -6
  26. package/build/dialects/DialectMariaDB.d.ts +2 -2
  27. package/build/dialects/DialectMariaDB.js +1 -6
  28. package/build/dialects/DialectMySQL.d.ts +2 -2
  29. package/build/dialects/DialectMySQL.js +1 -6
  30. package/build/dialects/DialectPostgres.d.ts +33 -2
  31. package/build/dialects/DialectPostgres.js +77 -10
  32. package/build/dialects/DialectSQLite.d.ts +2 -2
  33. package/build/dialects/DialectSQLite.js +1 -6
  34. package/build/dialects/dataTypes.d.ts +8 -0
  35. package/build/dialects/dataTypes.js +32 -4
  36. package/build/dialects/utils.d.ts +0 -6
  37. package/build/dialects/utils.js +0 -10
  38. package/build/index.d.ts +2 -2
  39. package/package.json +3 -3
package/README.md CHANGED
@@ -27,6 +27,17 @@
27
27
  * [One to One](#one-to-one)
28
28
  * [One to Many](#one-to-many)
29
29
  * [Many to Many](#many-to-many)
30
+ * [Type overrides](#type-overrides)
31
+ * [Type overrides file](#type-overrides-file)
32
+ * [Matching and precedence](#matching-and-precedence)
33
+ * [Type keys per dialect](#type-keys-per-dialect)
34
+ * [Validation and warnings](#validation-and-warnings)
35
+ * [Unmapped types](#unmapped-types)
36
+ * [Postgres user-defined types](#postgres-user-defined-types)
37
+ * [Enums](#enums)
38
+ * [Enum type names](#enum-type-names)
39
+ * [Domains, citext and other types](#domains-citext-and-other-types)
40
+ * [Caveats](#caveats)
30
41
  * [Lint](#lint)
31
42
 
32
43
  <!-- toc stop -->
@@ -95,13 +106,14 @@ stg --help
95
106
 
96
107
  ```shell
97
108
  Usage: stg -D <dialect> -d [database] -u [username] -x [password] -h [host] -p
98
- [port] -o [out-dir] -s [schema] -a [associations-file]-t [tables] -T
99
- [skip-tables] -i [indices] -C [case] -S [storage] -L [lint-file] -l [ssl] -r
100
- [protocol] -c [clean] -F [format] --no-associations
109
+ [port] -o [out-dir] -s [schema] -a [associations-file] -y [type-overrides-file]
110
+ -t [tables] -T [skip-tables] -V [no-views] -i [indices] -P [paranoid] -C [case]
111
+ -S [storage] -L [lint-file] -l [ssl] -r [protocol] -n [dialect-options] -c
112
+ [clean] -g [logs] -F [format] --no-associations
101
113
 
102
114
  Options:
103
- --help Show help [boolean]
104
- --version Show version number [boolean]
115
+ --help Show help [boolean]
116
+ --version Show version number [boolean]
105
117
  -h, --host Database IP/hostname [string]
106
118
  -p, --port Database port. Defaults:
107
119
  - MySQL/MariaDB: 3306
@@ -126,9 +138,9 @@ Options:
126
138
  - output-models [string]
127
139
  -c, --clean Clean output directory before running [boolean]
128
140
  -m, --timestamps Add default timestamps to tables [boolean]
129
- -P, --paranoid Emit paranoid table options for tables
130
- with a deleted_at or deletedAt column.
131
- Requires --timestamps. [boolean]
141
+ -P, --paranoid Emit paranoid table options for tables with a
142
+ deleted_at or deletedAt column. Requires
143
+ --timestamps. [boolean]
132
144
  -C, --case Transform tables and fields names
133
145
  with one of the following cases:
134
146
  - underscore
@@ -149,27 +161,31 @@ Options:
149
161
  -r, --protocol Protocol used: Default:
150
162
  - tcp [string]
151
163
  -a, --associations-file Associations file path [string]
164
+ -y, --type-overrides-file Type overrides file path: a JSON file declaring
165
+ the TypeScript type and/or the Sequelize data type
166
+ of database types ("types") or single columns
167
+ ("columns"). Overrides always win over the
168
+ generated types. [string]
152
169
  -g, --logs Enable Sequelize logs [boolean]
153
170
  -n, --dialect-options Dialect native options passed as json string.
154
171
  [string]
155
172
  -f, --dialect-options-file Dialect native options passed as json file path.
156
173
  [string]
174
+ -R, --no-strict Disable strict typescript class declaration
175
+ (decorators format only). [boolean]
157
176
  -F, --format Output format:
158
177
  - native: plain Sequelize classes with declare
159
- fields, Model.init and an initModels wiring
160
- file (default)
178
+ fields, Model.init and an initModels wiring file
179
+ (default)
161
180
  - decorators: sequelize-typescript decorators
162
- (requires sequelize-typescript in the target
163
- project)
164
- [string] [choices: "native",
165
- "decorators"] [default: "native"]
166
- -R, --no-strict Disable strict typescript class declaration
167
- (decorators format only). [boolean]
168
- -V, --no-views Disable view generation. Available for: MySQL and MariaDB.
169
- [boolean]
170
- --associations Discover one-to-one and one-to-many associations
181
+ (requires sequelize-typescript in the target
182
+ project)
183
+ [string] [choices: "native", "decorators"] [default: "native"]
184
+ -V, --no-views Disable views generation. Available for: MySQL and
185
+ MariaDB. [boolean]
186
+ --associations Discover one-to-one and one-to-many associations
171
187
  from foreign keys. Use --no-associations to
172
- disable. [boolean] [default: true]
188
+ disable. [boolean] [default: true]
173
189
  ```
174
190
 
175
191
  Local usage example:
@@ -1424,6 +1440,244 @@ export class authors_books extends Model<authors_booksAttributes, authors_booksA
1424
1440
  }
1425
1441
  ```
1426
1442
 
1443
+ ## Type overrides
1444
+ A type override sets the TypeScript type, the Sequelize data type, or both, of every column of a
1445
+ database type or of a single column. Use it for types the generator cannot map (extension types such
1446
+ as `tsvector`, `vector` or `ltree`) or for columns you want typed differently. Overrides work in every
1447
+ dialect and both output formats, and always win over what the generator derives.
1448
+
1449
+ ### Type overrides file
1450
+ Type overrides live in a JSON file passed with `-y` / `--type-overrides-file`:
1451
+
1452
+ ```shell
1453
+ npx stg -D postgres -d myDatabase -u myUsername -x myPassword --type-overrides-file type-overrides.json
1454
+ ```
1455
+
1456
+ The file has two optional sections; any other top-level key is an error:
1457
+
1458
+ - `types`: keyed by `<type>` or `<schema>.<type>`; the entry applies to every column of that database type.
1459
+ - `columns`: keyed by `<table>.<column>` or `<schema>.<table>.<column>`; the entry applies to one column.
1460
+ Table and column are the database names, not the [transformed](#transform-case) ones.
1461
+
1462
+ Each entry sets `tsType`, `dataType` or both:
1463
+
1464
+ - `tsType`: any TypeScript type expression, including unions, object types and `import('pkg').Type`.
1465
+ It is emitted as written; no import statements are generated, so use an `import()` type for
1466
+ external types.
1467
+ - `dataType`: a Sequelize data type expression, such as `"TSVECTOR"`, `"STRING(80)"` or
1468
+ `"ARRAY(ENUM('a', 'b'))"`, with an optional `DataTypes.` / `DataType.` prefix. Only data type
1469
+ identifiers, calls, and string or number literal arguments are allowed, and every data type must
1470
+ exist in Sequelize `DataTypes`. It is emitted with the namespace of the output format
1471
+ (`DataTypes.` for native, `DataType.` for decorators).
1472
+
1473
+ A side you do not set keeps what the generator would have produced, so a partial override changes only
1474
+ the part that is wrong. Neither side is derived from the other.
1475
+
1476
+ ```json
1477
+ {
1478
+ "types": {
1479
+ "tsvector": { "tsType": "string", "dataType": "TSVECTOR" },
1480
+ "geometry": { "tsType": "import('geojson').Geometry" }
1481
+ },
1482
+ "columns": {
1483
+ "public.places.settings": { "tsType": "{ theme: 'light' | 'dark'; beta?: boolean }" }
1484
+ }
1485
+ }
1486
+ ```
1487
+
1488
+ Here `tsvector` (unmapped by the generator) gets both sides, `geometry` keeps its generated `GEOMETRY`
1489
+ data type, and `settings` (a `jsonb` column) keeps its `JSONB` data type with a precise TypeScript type
1490
+ in place of `Json`. In the native format the `places` model becomes:
1491
+
1492
+ ```ts
1493
+ export class places extends Model<InferAttributes<places>, InferCreationAttributes<places>> {
1494
+
1495
+ // ...
1496
+
1497
+ declare location: import("geojson").Geometry | null;
1498
+
1499
+ declare search: string | null;
1500
+
1501
+ declare settings: {
1502
+ theme: "light" | "dark";
1503
+ beta?: boolean;
1504
+ } | null;
1505
+
1506
+ static initModel(sequelize: Sequelize): typeof places {
1507
+ places.init({
1508
+ // ...
1509
+ location: {
1510
+ type: DataTypes.GEOMETRY,
1511
+ allowNull: true
1512
+ },
1513
+ search: {
1514
+ type: DataTypes.TSVECTOR,
1515
+ allowNull: true
1516
+ },
1517
+ settings: {
1518
+ type: DataTypes.JSONB,
1519
+ allowNull: true
1520
+ }
1521
+ }, {
1522
+ // ...
1523
+ });
1524
+ return places;
1525
+ }
1526
+
1527
+ }
1528
+ ```
1529
+
1530
+ Nullability is still applied to an overridden TypeScript type (`| null` in the native format, an
1531
+ optional property in the decorators format).
1532
+
1533
+ Programmatically, set either `metadata.typeOverridesFile` (a file path) or `metadata.typeOverrides`
1534
+ (an object of the same shape); setting both is a validation error. The `ITypeOverride` and
1535
+ `ITypeOverrides` types are exported from the package:
1536
+
1537
+ ```ts
1538
+ import { IConfig, ITypeOverrides } from 'sequelize-typescript-generator';
1539
+
1540
+ const typeOverrides: ITypeOverrides = {
1541
+ types: {
1542
+ tsvector: { tsType: 'string', dataType: 'TSVECTOR' },
1543
+ },
1544
+ columns: {
1545
+ 'users.status': { tsType: "'active' | 'banned'" },
1546
+ },
1547
+ };
1548
+
1549
+ const config: IConfig = {
1550
+ // ...
1551
+ metadata: {
1552
+ typeOverrides,
1553
+ },
1554
+ };
1555
+ ```
1556
+
1557
+ ### Matching and precedence
1558
+ Keys match case-insensitively, like the table filters; two keys of a section that differ only by case
1559
+ are a validation error. When several entries match a column, the most specific wins:
1560
+
1561
+ 1. `<schema>.<table>.<column>`
1562
+ 2. `<table>.<column>`
1563
+ 3. `<schema>.<type>`
1564
+ 4. `<type>`
1565
+
1566
+ So a column override beats a type override, a schema-qualified key beats an unqualified one, and any
1567
+ override beats the generator. `tsType` and `dataType` are resolved independently: each comes from the
1568
+ most specific matching entry that sets it, and falls back to the generator when none does.
1569
+
1570
+ ### Type keys per dialect
1571
+ A type key matches the raw database type name the dialect reports for the column:
1572
+
1573
+ | Dialect | Type name matched | Schema segment |
1574
+ | --- | --- | --- |
1575
+ | Postgres | `udt_name`, e.g. `int4`, `varchar`, `tsvector` or an enum name; array types are prefixed with `_` (`_int4`, `_plan_tier`); a domain reports its underlying type | The table schema; for an enum column, the schema the enum is defined in |
1576
+ | MySQL / MariaDB | `DATA_TYPE`, e.g. `varchar`, `int` | `connection.schema`, normally unset, so schema-qualified keys do not match |
1577
+ | MSSQL | `DATA_TYPE`, e.g. `nvarchar`, `int` | The table schema, e.g. `dbo` |
1578
+ | SQLite | The full declared type, e.g. `VARCHAR(80)` | None; use unqualified keys |
1579
+
1580
+ The schema segment of a column key follows the same rule as the table schema in the table above.
1581
+
1582
+ ### Validation and warnings
1583
+ Type overrides are read and validated when generation starts, for both the CLI and programmatic usage.
1584
+ The CLI also fails fast if the `-y` path does not exist. Any of the following is a `[ValidationError]`
1585
+ naming the offending entry, and stops generation:
1586
+
1587
+ - the file cannot be read or is not valid JSON;
1588
+ - the root is not an object, or has a section other than `types` and `columns`;
1589
+ - a section or an entry is not an object, or an entry has a field other than `tsType` and `dataType`;
1590
+ - an entry sets neither `tsType` nor `dataType`, or sets one to a non-string;
1591
+ - a key is malformed (wrong number of segments or an empty segment) or duplicates another key of the
1592
+ section case-insensitively;
1593
+ - `tsType` is not a valid TypeScript type;
1594
+ - `dataType` does not parse, uses a disallowed expression, or names an unknown Sequelize data type;
1595
+ - both `typeOverridesFile` and `typeOverrides` are set.
1596
+
1597
+ Entries that matched no column are listed in a single warning, so typos are noticed even when table
1598
+ filters legitimately exclude the tables they target:
1599
+
1600
+ ```
1601
+ [WARNING] Type overrides matched no column: columns["plcaes.name"]. Check them for typos; table filters may exclude the tables they target.
1602
+ ```
1603
+
1604
+ ### Unmapped types
1605
+ A column whose database type the dialect cannot map is typed `unknown` in the native format and `any`
1606
+ in the decorators format, and generation continues. A warning names the column as
1607
+ `schema.table.column` and the type it received:
1608
+
1609
+ ```
1610
+ [WARNING] Unmapped type 'tsvector' for column public.places.search: typed as 'unknown'. Declare a type override with --type-overrides-file to set its type.
1611
+ ```
1612
+
1613
+ Fix it with a type override; columns covered by an override get no unmapped-type warning. In the
1614
+ native format an unmapped column has no `type` in `Model.init`, so set a `dataType` as well as a
1615
+ `tsType`.
1616
+
1617
+ ## Postgres user-defined types
1618
+
1619
+ ### Enums
1620
+ The Postgres dialect detects enum types, including enums defined in another schema than the table.
1621
+ Each enum becomes a shared type named after it, collected in a generated `enums.ts` used by both
1622
+ output formats:
1623
+
1624
+ ```ts
1625
+ export type PlanTier = "free" | "pro" | "enterprise";
1626
+ ```
1627
+
1628
+ Models import the shared types they use with a type-only import (`import type { PlanTier } from "./enums";`)
1629
+ and type enum columns with them. The data type is `ENUM` with the database labels in database order,
1630
+ and enum arrays are typed as arrays of the shared type with an `ARRAY` of `ENUM` data type:
1631
+
1632
+ ```ts
1633
+ declare plan: PlanTier;
1634
+
1635
+ declare previous_plans: PlanTier[] | null;
1636
+
1637
+ // in Model.init
1638
+ plan: {
1639
+ type: DataTypes.ENUM("free", "pro", "enterprise"),
1640
+ allowNull: false
1641
+ },
1642
+ previous_plans: {
1643
+ type: DataTypes.ARRAY(DataTypes.ENUM("free", "pro", "enterprise")),
1644
+ allowNull: true
1645
+ }
1646
+ ```
1647
+
1648
+ An enum used by several tables produces a single shared type. `enums.ts` is generated only when at
1649
+ least one generated column uses an enum shared type: a [type override](#type-overrides) whose `tsType`
1650
+ replaces an enum on every column removes that enum from `enums.ts`. MySQL and MariaDB enums are typed as
1651
+ before (an inline union in the native format, `string` in the decorators format).
1652
+
1653
+ ### Enum type names
1654
+ The shared type name is the Pascal case of the database type name (`plan_tier` → `PlanTier`); a name
1655
+ that does not start with a valid identifier character is prefixed with `Enum`. Clashes rename only the
1656
+ clashing enums, with a warning for each renamed one:
1657
+
1658
+ - when enums of the same name exist in several schemas, an enum from a schema none of the generated
1659
+ tables belong to is prefixed with its Pascal-cased schema (`auth.plan_tier` → `AuthPlanTier`);
1660
+ - a name equal to a generated model name, or to any other identifier a model file declares or imports,
1661
+ gets an `Enum` suffix (`PlanTierEnum`);
1662
+ - names still equal after that are ordered by schema then type name: the first keeps the name, the
1663
+ next ones get `2`, `3`, and so on.
1664
+
1665
+ A warning is also printed if a model would be written to `enums.ts` itself.
1666
+
1667
+ ### Domains, citext and other types
1668
+ - Domain columns are typed as their underlying type.
1669
+ - `citext` columns are typed `string` with the `CITEXT` data type.
1670
+ - Composite types and extension types outside the type map (`vector`, `ltree`, `tsvector`, `hstore`,
1671
+ range types, ...) remain [unmapped types](#unmapped-types); declare a [type override](#type-overrides)
1672
+ for them.
1673
+
1674
+ ### Caveats
1675
+ - Sequelize v6 cannot name the enum type of an attribute, so `sync()` creates its own
1676
+ `enum_<table>_<column>` types instead of reusing your named database enums. The generated models
1677
+ target existing databases; manage the schema's enum types with migrations rather than `sync()`.
1678
+ - Sequelize reads the enum type OIDs once per `Sequelize` instance. If enum types are created after the
1679
+ instance connected, enum array values come back as raw strings until a new instance is created.
1680
+
1427
1681
  ## Lint
1428
1682
  By default each generated model will be linted with a predefined ESLint flat config to improve readability:
1429
1683
 
package/build/bin/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import yargs from 'yargs';
3
3
  import { hideBin } from 'yargs/helpers';
4
4
  import { ModelBuilder } from '../builders/index.js';
5
- import { defaultOutputDir, aliasesMap, validateArgs, buildConfig, buildDialect, } from './utils.js';
5
+ import { defaultOutputDir, aliasesMap, validateArgs, buildConfig, buildDialect, TYPE_OVERRIDES_FILE_FLAG, typeOverridesFileOption, } from './utils.js';
6
6
  import { FORMATS, DEFAULT_FORMAT } from '../config/format.js';
7
7
  process.on('unhandledRejection', (reason, promise) => {
8
8
  console.error(reason, promise);
@@ -10,7 +10,7 @@ process.on('unhandledRejection', (reason, promise) => {
10
10
  });
11
11
  export const cli = async () => {
12
12
  let usage = `Usage: stg -D <dialect> -d [database] -u [username] -x [password] `;
13
- usage += `-h [host] -p [port] -o [out-dir] -s [schema] -a [associations-file]`;
13
+ usage += `-h [host] -p [port] -o [out-dir] -s [schema] -a [associations-file] -y [type-overrides-file] `;
14
14
  usage += `-t [tables] -T [skip-tables] -V [no-views] -i [indices] -P [paranoid] -C [case] -S [storage] -L [lint-file] `;
15
15
  usage += `-l [ssl] -r [protocol] -n [dialect-options] -c [clean] -g [logs] -F [format] --no-associations`;
16
16
  const { argv } = yargs(hideBin(process.argv))
@@ -119,7 +119,7 @@ export const cli = async () => {
119
119
  alias: aliasesMap.ASSOCIATIONS_FILE,
120
120
  string: true,
121
121
  describe: `Associations file path`,
122
- }).option('g', {
122
+ }).option(TYPE_OVERRIDES_FILE_FLAG, typeOverridesFileOption).option('g', {
123
123
  alias: aliasesMap.ENABLE_SEQUELIZE_LOGS,
124
124
  boolean: true,
125
125
  describe: `Enable Sequelize logs`,
@@ -25,6 +25,7 @@ export declare const aliasesMap: {
25
25
  SSL: string;
26
26
  PROTOCOL: string;
27
27
  ASSOCIATIONS_FILE: string;
28
+ TYPE_OVERRIDES_FILE: string;
28
29
  ASSOCIATIONS: string;
29
30
  ENABLE_SEQUELIZE_LOGS: string;
30
31
  DIALECT_OPTIONS: string;
@@ -33,6 +34,18 @@ export declare const aliasesMap: {
33
34
  DISABLE_VIEWS: string;
34
35
  FORMAT: string;
35
36
  };
37
+ /**
38
+ * Short flag of the type overrides file option.
39
+ */
40
+ export declare const TYPE_OVERRIDES_FILE_FLAG = "y";
41
+ /**
42
+ * Definition of the type overrides file option.
43
+ */
44
+ export declare const typeOverridesFileOption: {
45
+ alias: string;
46
+ string: true;
47
+ describe: string;
48
+ };
36
49
  /**
37
50
  * Diplay error message and exit
38
51
  * @param {string} msg
@@ -26,6 +26,7 @@ export const aliasesMap = {
26
26
  SSL: 'ssl',
27
27
  PROTOCOL: 'protocol',
28
28
  ASSOCIATIONS_FILE: 'associations-file',
29
+ TYPE_OVERRIDES_FILE: 'type-overrides-file',
29
30
  ASSOCIATIONS: 'associations',
30
31
  ENABLE_SEQUELIZE_LOGS: 'logs',
31
32
  DIALECT_OPTIONS: 'dialect-options',
@@ -34,6 +35,20 @@ export const aliasesMap = {
34
35
  DISABLE_VIEWS: 'no-views',
35
36
  FORMAT: 'format',
36
37
  };
38
+ /**
39
+ * Short flag of the type overrides file option.
40
+ */
41
+ export const TYPE_OVERRIDES_FILE_FLAG = 'y';
42
+ /**
43
+ * Definition of the type overrides file option.
44
+ */
45
+ export const typeOverridesFileOption = {
46
+ alias: aliasesMap.TYPE_OVERRIDES_FILE,
47
+ string: true,
48
+ describe: `Type overrides file path: a JSON file declaring the TypeScript type and/or the Sequelize ` +
49
+ `data type of database types ("types") or single columns ("columns"). Overrides always win over ` +
50
+ `the generated types.`,
51
+ };
37
52
  /**
38
53
  * Diplay error message and exit
39
54
  * @param {string} msg
@@ -148,6 +163,7 @@ export const buildConfig = (argv) => {
148
163
  paranoid: !!argv[aliasesMap.PARANOID],
149
164
  ...argv[aliasesMap.CASE] && { case: parseCase(argv[aliasesMap.CASE]) },
150
165
  ...argv[aliasesMap.ASSOCIATIONS_FILE] && { associationsFile: argv[aliasesMap.ASSOCIATIONS_FILE] },
166
+ ...argv[aliasesMap.TYPE_OVERRIDES_FILE] && { typeOverridesFile: String(argv[aliasesMap.TYPE_OVERRIDES_FILE]) },
151
167
  ...(argv[aliasesMap.ASSOCIATIONS] === false && { associations: false }),
152
168
  noViews: !!argv[aliasesMap.DISABLE_VIEWS] || argv['views'] === false,
153
169
  },
@@ -239,5 +255,14 @@ export const validateArgs = (argv) => {
239
255
  error(`Argument -a [associations-file] '${argv[aliasesMap.ASSOCIATIONS_FILE]}' is not a valid path`);
240
256
  }
241
257
  }
258
+ // Validate type overrides file
259
+ if (argv[aliasesMap.TYPE_OVERRIDES_FILE]) {
260
+ try {
261
+ fs.accessSync(argv[aliasesMap.TYPE_OVERRIDES_FILE]);
262
+ }
263
+ catch (err) {
264
+ error(`Argument -y [type-overrides-file] '${argv[aliasesMap.TYPE_OVERRIDES_FILE]}' is not a valid path`);
265
+ }
266
+ }
242
267
  // TODO Validate schema if dialect is postgres ?
243
268
  };
@@ -60,7 +60,8 @@ export declare class ModelBuilder extends Builder {
60
60
  */
61
61
  private static buildIndexExports;
62
62
  /**
63
- * Render the decorators output as one file per table plus the index barrel.
63
+ * Render the decorators output as one file per table, the shared type files the
64
+ * models use, and the index barrel.
64
65
  * @param {ITablesMetadata} tablesMetadata
65
66
  * @param {Dialect} dialect
66
67
  * @param {boolean | undefined} strict