sequelize-typescript-generator 13.0.0 → 13.0.1
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.
- package/README.md +7 -7
- package/build/bin/utils.js +1 -1
- package/build/dialects/DialectMySQL.js +1 -1
- package/package.json +5 -2
- package/.github/FUNDING.yml +0 -1
- package/.github/workflows/ci.yml +0 -224
- package/.vscode/launch.json +0 -212
- package/.vscode/tasks.json +0 -95
- package/CHANGELOG.md +0 -47
- package/CLAUDE.md +0 -13
- package/CONTEXT.md +0 -67
- package/docker-compose.yml +0 -65
- package/docs/adr/0001-esm-only-package.md +0 -36
- package/docs/adr/0002-native-default-output-format.md +0 -41
- package/docs/agents/domain.md +0 -51
- package/docs/agents/issue-tracker.md +0 -45
- package/docs/agents/triage-labels.md +0 -15
- package/docs/migration/12-to-13.md +0 -248
- package/docs/plans/v13-phase5-association-discovery.md +0 -168
- package/docs/plans/v13-phase6-native-emitter.md +0 -537
- package/docs/plans/v13-upgrade-plan.md +0 -137
- package/jest.config.cjs +0 -31
- package/scripts/check-no-sequelize-typescript.cjs +0 -68
- package/tsconfig.json +0 -22
package/CONTEXT.md
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# sequelize-typescript-generator
|
|
2
|
-
|
|
3
|
-
Domain glossary for the tool that generates TypeScript Sequelize models directly from an existing database schema.
|
|
4
|
-
|
|
5
|
-
## Language
|
|
6
|
-
|
|
7
|
-
### Source
|
|
8
|
-
|
|
9
|
-
**Dialect**:
|
|
10
|
-
One supported database engine (Postgres, MySQL, MariaDB, SQL Server, SQLite) together with the adapter that inspects its schema metadata: tables, columns, indexes, foreign keys, and views.
|
|
11
|
-
_Avoid_: Engine, database type
|
|
12
|
-
|
|
13
|
-
**Driver**:
|
|
14
|
-
The Node package Sequelize loads to talk to a database (`pg`, `mysql2`, `tedious`, `@vscode/sqlite3`), installed by the user in their own project and never bundled by the generator. For SQLite the generator resolves `@vscode/sqlite3` from the user's project and passes it to Sequelize as `dialectModule`; the `sqlite3` package is no longer documented or tested.
|
|
15
|
-
_Avoid_: Client, connector, dialect module
|
|
16
|
-
|
|
17
|
-
### Output
|
|
18
|
-
|
|
19
|
-
**Model**:
|
|
20
|
-
The generated TypeScript class representing one table or view.
|
|
21
|
-
_Avoid_: Entity, class, DAO
|
|
22
|
-
|
|
23
|
-
**Format**:
|
|
24
|
-
The output style of the generated models. Has exactly two values, native and decorators, selected with the `--format` option.
|
|
25
|
-
_Avoid_: Style, mode, flavour
|
|
26
|
-
|
|
27
|
-
**Native format**:
|
|
28
|
-
Models written as plain Sequelize classes with declared fields and an initialisation call, without any decorator library. Ships with a wiring file. The default format.
|
|
29
|
-
_Avoid_: Plain format, classic format
|
|
30
|
-
|
|
31
|
-
**Decorators format**:
|
|
32
|
-
Models written with sequelize-typescript decorators. Requires the consuming project to install sequelize-typescript.
|
|
33
|
-
_Avoid_: Annotated format, decorator mode
|
|
34
|
-
|
|
35
|
-
**Wiring file**:
|
|
36
|
-
The file generated in native format that initialises every model against a Sequelize instance and declares all associations between them.
|
|
37
|
-
_Avoid_: Index file, bootstrap file, registry
|
|
38
|
-
|
|
39
|
-
**Strict mode**:
|
|
40
|
-
The mode in which a model's attributes are typed by a generated attributes interface. Applies to decorators format only; in native format the class typing already carries the attributes.
|
|
41
|
-
_Avoid_: Typed mode
|
|
42
|
-
|
|
43
|
-
**Case**:
|
|
44
|
-
The naming convention applied to model names and column names: underscore, camel, upper, lower, pascal, or const.
|
|
45
|
-
_Avoid_: Casing, naming style
|
|
46
|
-
|
|
47
|
-
### Associations
|
|
48
|
-
|
|
49
|
-
**Association**:
|
|
50
|
-
A relationship between two models: one-to-one, one-to-many, or many-to-many.
|
|
51
|
-
_Avoid_: Relation, relationship, link
|
|
52
|
-
|
|
53
|
-
**Alias**:
|
|
54
|
-
The name under which an association is exposed on a model, used both as the class property and in queries that include the related model.
|
|
55
|
-
_Avoid_: Association name, relation name, property name
|
|
56
|
-
|
|
57
|
-
**Junction table**:
|
|
58
|
-
A table whose rows link two other tables to express a many-to-many association.
|
|
59
|
-
_Avoid_: Join table, pivot table, through table, bridge table
|
|
60
|
-
|
|
61
|
-
**Associations file**:
|
|
62
|
-
The CSV file a user supplies to declare associations explicitly.
|
|
63
|
-
_Avoid_: Relations file, mapping file
|
|
64
|
-
|
|
65
|
-
**Association discovery**:
|
|
66
|
-
Automatic derivation of one-to-one and one-to-many associations from foreign keys found in the schema.
|
|
67
|
-
_Avoid_: Auto-associations, inference
|
package/docker-compose.yml
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
# Local integration database services, one profile per dialect.
|
|
2
|
-
# Credentials and ports match the defaults in src/tests/environment.ts so the
|
|
3
|
-
# test suites run unchanged. Start a single dialect with, for example:
|
|
4
|
-
# docker compose --profile postgres up -d
|
|
5
|
-
# The npm run test:<dialect> scripts drive these profiles automatically.
|
|
6
|
-
|
|
7
|
-
services:
|
|
8
|
-
postgres:
|
|
9
|
-
profiles: ["postgres"]
|
|
10
|
-
image: postgres:18
|
|
11
|
-
environment:
|
|
12
|
-
POSTGRES_DB: testdb
|
|
13
|
-
POSTGRES_USER: sa
|
|
14
|
-
POSTGRES_PASSWORD: Passw0rd88!
|
|
15
|
-
ports:
|
|
16
|
-
- "1234:5432"
|
|
17
|
-
healthcheck:
|
|
18
|
-
test: ["CMD-SHELL", "pg_isready -U sa -d testdb"]
|
|
19
|
-
interval: 5s
|
|
20
|
-
timeout: 5s
|
|
21
|
-
retries: 20
|
|
22
|
-
|
|
23
|
-
mysql:
|
|
24
|
-
profiles: ["mysql"]
|
|
25
|
-
image: mysql:9.7
|
|
26
|
-
environment:
|
|
27
|
-
MYSQL_DATABASE: testdb
|
|
28
|
-
MYSQL_USER: sa
|
|
29
|
-
MYSQL_PASSWORD: Passw0rd88!
|
|
30
|
-
MYSQL_ROOT_PASSWORD: Passw0rd88!
|
|
31
|
-
ports:
|
|
32
|
-
- "1234:3306"
|
|
33
|
-
healthcheck:
|
|
34
|
-
test: ["CMD-SHELL", "mysqladmin ping -h 127.0.0.1 -u root -pPassw0rd88!"]
|
|
35
|
-
interval: 5s
|
|
36
|
-
timeout: 5s
|
|
37
|
-
retries: 30
|
|
38
|
-
|
|
39
|
-
mariadb:
|
|
40
|
-
profiles: ["mariadb"]
|
|
41
|
-
image: mariadb:12.3
|
|
42
|
-
environment:
|
|
43
|
-
MARIADB_DATABASE: testdb
|
|
44
|
-
MARIADB_USER: sa
|
|
45
|
-
MARIADB_PASSWORD: Passw0rd88!
|
|
46
|
-
MARIADB_ROOT_PASSWORD: Passw0rd88!
|
|
47
|
-
ports:
|
|
48
|
-
- "1234:3306"
|
|
49
|
-
healthcheck:
|
|
50
|
-
test: ["CMD-SHELL", "healthcheck.sh --connect --innodb_initialized"]
|
|
51
|
-
interval: 5s
|
|
52
|
-
timeout: 5s
|
|
53
|
-
retries: 30
|
|
54
|
-
|
|
55
|
-
mssql:
|
|
56
|
-
profiles: ["mssql"]
|
|
57
|
-
image: mcr.microsoft.com/mssql/server:2025-latest
|
|
58
|
-
# The SQL Server image ships amd64 only; on Apple Silicon it runs under Rosetta emulation.
|
|
59
|
-
platform: linux/amd64
|
|
60
|
-
environment:
|
|
61
|
-
ACCEPT_EULA: "Y"
|
|
62
|
-
SA_PASSWORD: Passw0rd88!
|
|
63
|
-
MSSQL_SA_PASSWORD: Passw0rd88!
|
|
64
|
-
ports:
|
|
65
|
-
- "1234:1433"
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# 0001. ESM-only package
|
|
2
|
-
|
|
3
|
-
- Status: Accepted
|
|
4
|
-
- Date: 2026-09-09
|
|
5
|
-
|
|
6
|
-
## Context
|
|
7
|
-
|
|
8
|
-
The package previously shipped CommonJS. Version 13 moves the toolchain to
|
|
9
|
-
TypeScript 6 with `module: nodenext` and raises the runtime floor to Node
|
|
10
|
-
`>=22.13.0`. That Node version supports `require()` of ESM modules that have no
|
|
11
|
-
top-level await, so CommonJS consumers can still load an ESM-only package. The
|
|
12
|
-
surrounding ecosystem is ESM-first: yargs and the ESLint 10 flat-config stack
|
|
13
|
-
are shipped primarily as ES modules.
|
|
14
|
-
|
|
15
|
-
## Decision
|
|
16
|
-
|
|
17
|
-
Ship the package as ESM only:
|
|
18
|
-
|
|
19
|
-
- `"type": "module"` in `package.json`.
|
|
20
|
-
- A single root `exports` entry plus `./package.json`; no other subpaths.
|
|
21
|
-
- A plain `tsc` build to `build/`, with no bundler and no dual CommonJS output.
|
|
22
|
-
- `.js` suffixes on relative imports, as `module: nodenext` requires.
|
|
23
|
-
- No top-level `await` in the shipped entry, so `require()` of the package from
|
|
24
|
-
CommonJS keeps working. A test loads the root entry with `require()` from a
|
|
25
|
-
CommonJS script to verify this.
|
|
26
|
-
|
|
27
|
-
## Consequences
|
|
28
|
-
|
|
29
|
-
- Consumers on Node `<22.13` are unsupported.
|
|
30
|
-
- No dual build to maintain.
|
|
31
|
-
- Deep imports into `build/` are not supported; the `exports` map exposes the
|
|
32
|
-
root entry only.
|
|
33
|
-
- Generated model files are unchanged by this decision. Adding a `.js` suffix to
|
|
34
|
-
relative imports in generated code, for strict Node ESM consumers, is a
|
|
35
|
-
post-13 backlog item in the v13 upgrade plan
|
|
36
|
-
(`docs/plans/v13-upgrade-plan.md`).
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# 0002. Native default output format
|
|
2
|
-
|
|
3
|
-
- Status: Accepted
|
|
4
|
-
- Date: 2026-09-10
|
|
5
|
-
|
|
6
|
-
## Context
|
|
7
|
-
|
|
8
|
-
Every version before 13 emitted a single output style: `sequelize-typescript`
|
|
9
|
-
decorated classes, which require the consuming project to install
|
|
10
|
-
`sequelize-typescript` and `reflect-metadata`. Version 13 (issue #80) adds a
|
|
11
|
-
framework-free native emitter that produces plain `sequelize` classes: attributes
|
|
12
|
-
typed with `InferAttributes` / `InferCreationAttributes`, `declare`d fields wrapped
|
|
13
|
-
with `CreationOptional`, `ForeignKey` and `NonAttribute`, a `static initModel`
|
|
14
|
-
method per model, and an `initModels` wiring file plus an `index.ts` barrel. With
|
|
15
|
-
two formats available the generator needs a default.
|
|
16
|
-
|
|
17
|
-
## Decision
|
|
18
|
-
|
|
19
|
-
Make the native format the default:
|
|
20
|
-
|
|
21
|
-
- `--format native` is the default; `--format decorators` is opt-in.
|
|
22
|
-
- The programmatic `IConfig.format` option defaults to `'native'` when unset.
|
|
23
|
-
- `strict` applies to the decorators format only. It is ignored under native, where
|
|
24
|
-
attributes are always typed with `InferAttributes`; combining `--no-strict` with
|
|
25
|
-
native prints a notice and does nothing else.
|
|
26
|
-
|
|
27
|
-
## Consequences
|
|
28
|
-
|
|
29
|
-
- Breaking change for existing consumers: anyone relying on the previous decorators
|
|
30
|
-
output must now pass `--format decorators` (or set `format: 'decorators'`).
|
|
31
|
-
- Native models depend on `sequelize` alone; `sequelize-typescript` and
|
|
32
|
-
`reflect-metadata` are needed only for the decorators format. When the decorators
|
|
33
|
-
format is selected and `sequelize-typescript` cannot be resolved from the output
|
|
34
|
-
directory, a warning is emitted; the generator never throws for this.
|
|
35
|
-
- SQLite-specific quirk: SQLite reports `notnull=0` for an integer rowid primary
|
|
36
|
-
key, so native types such a primary key as `CreationOptional<number | null>`. The
|
|
37
|
-
init options stay correct (`primaryKey` and `autoIncrement` set, `allowNull`
|
|
38
|
-
omitted). Dialects that report `notnull=1` for their generated primary key emit
|
|
39
|
-
`CreationOptional<number>`.
|
|
40
|
-
|
|
41
|
-
See issue #80 and `docs/plans/v13-phase6-native-emitter.md`.
|
package/docs/agents/domain.md
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# Domain Docs
|
|
2
|
-
|
|
3
|
-
How the engineering skills should consume this repo's domain documentation when exploring the codebase.
|
|
4
|
-
|
|
5
|
-
## Before exploring, read these
|
|
6
|
-
|
|
7
|
-
- **`CONTEXT.md`** at the repo root, or
|
|
8
|
-
- **`CONTEXT-MAP.md`** at the repo root if it exists: it points at one `CONTEXT.md` per context. Read each one relevant to the topic.
|
|
9
|
-
- **`docs/adr/`**: read ADRs that touch the area you're about to work in. In multi-context repos, also check `src/<context>/docs/adr/` for context-scoped decisions.
|
|
10
|
-
|
|
11
|
-
If any of these files don't exist, **proceed silently**. Don't flag their absence; don't suggest creating them upfront. The `/domain-modeling` skill (reached via `/grill-with-docs` and `/improve-codebase-architecture`) creates them lazily when terms or decisions actually get resolved.
|
|
12
|
-
|
|
13
|
-
## File structure
|
|
14
|
-
|
|
15
|
-
Single-context repo (most repos):
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
/
|
|
19
|
-
├── CONTEXT.md
|
|
20
|
-
├── docs/adr/
|
|
21
|
-
│ ├── 0001-event-sourced-orders.md
|
|
22
|
-
│ └── 0002-postgres-for-write-model.md
|
|
23
|
-
└── src/
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Multi-context repo (presence of `CONTEXT-MAP.md` at the root):
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
/
|
|
30
|
-
├── CONTEXT-MAP.md
|
|
31
|
-
├── docs/adr/ ← system-wide decisions
|
|
32
|
-
└── src/
|
|
33
|
-
├── ordering/
|
|
34
|
-
│ ├── CONTEXT.md
|
|
35
|
-
│ └── docs/adr/ ← context-specific decisions
|
|
36
|
-
└── billing/
|
|
37
|
-
├── CONTEXT.md
|
|
38
|
-
└── docs/adr/
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## Use the glossary's vocabulary
|
|
42
|
-
|
|
43
|
-
When your output names a domain concept (in an issue title, a refactor proposal, a hypothesis, a test name), use the term as defined in `CONTEXT.md`. Don't drift to synonyms the glossary explicitly avoids.
|
|
44
|
-
|
|
45
|
-
If the concept you need isn't in the glossary yet, that's a signal: either you're inventing language the project doesn't use (reconsider) or there's a real gap (note it for `/domain-modeling`).
|
|
46
|
-
|
|
47
|
-
## Flag ADR conflicts
|
|
48
|
-
|
|
49
|
-
If your output contradicts an existing ADR, surface it explicitly rather than silently overriding:
|
|
50
|
-
|
|
51
|
-
> _Contradicts ADR-0007 (event-sourced orders), but worth reopening because…_
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# Issue tracker: GitHub
|
|
2
|
-
|
|
3
|
-
Issues and specs for this repo live as GitHub issues. Use the `gh` CLI for all operations.
|
|
4
|
-
|
|
5
|
-
## Conventions
|
|
6
|
-
|
|
7
|
-
- **Create an issue**: `gh issue create --title "..." --body "..."`. Use a heredoc for multi-line bodies.
|
|
8
|
-
- **Read an issue**: `gh issue view <number> --comments`, filtering comments by `jq` and also fetching labels.
|
|
9
|
-
- **List issues**: `gh issue list --state open --json number,title,body,labels,comments --jq '[.[] | {number, title, body, labels: [.labels[].name], comments: [.comments[].body]}]'` with appropriate `--label` and `--state` filters.
|
|
10
|
-
- **Comment on an issue**: `gh issue comment <number> --body "..."`
|
|
11
|
-
- **Apply / remove labels**: `gh issue edit <number> --add-label "..."` / `--remove-label "..."`
|
|
12
|
-
- **Close**: `gh issue close <number> --comment "..."`
|
|
13
|
-
|
|
14
|
-
Infer the repo from `git remote -v`; `gh` does this automatically when run inside a clone.
|
|
15
|
-
|
|
16
|
-
## Pull requests as a triage surface
|
|
17
|
-
|
|
18
|
-
**PRs as a request surface: no.** _(Set to `yes` if this repo treats external PRs as feature requests; `/triage` reads this flag.)_
|
|
19
|
-
|
|
20
|
-
When set to `yes`, PRs run through the same labels and states as issues, using the `gh pr` equivalents:
|
|
21
|
-
|
|
22
|
-
- **Read a PR**: `gh pr view <number> --comments` and `gh pr diff <number>` for the diff.
|
|
23
|
-
- **List external PRs for triage**: `gh pr list --state open --json number,title,body,labels,author,authorAssociation,comments` then keep only `authorAssociation` of `CONTRIBUTOR`, `FIRST_TIME_CONTRIBUTOR`, or `NONE` (drop `OWNER`/`MEMBER`/`COLLABORATOR`).
|
|
24
|
-
- **Comment / label / close**: `gh pr comment`, `gh pr edit --add-label`/`--remove-label`, `gh pr close`.
|
|
25
|
-
|
|
26
|
-
GitHub shares one number space across issues and PRs, so a bare `#42` may be either: resolve with `gh pr view 42` and fall back to `gh issue view 42`.
|
|
27
|
-
|
|
28
|
-
## When a skill says "publish to the issue tracker"
|
|
29
|
-
|
|
30
|
-
Create a GitHub issue.
|
|
31
|
-
|
|
32
|
-
## When a skill says "fetch the relevant ticket"
|
|
33
|
-
|
|
34
|
-
Run `gh issue view <number> --comments`.
|
|
35
|
-
|
|
36
|
-
## Wayfinding operations
|
|
37
|
-
|
|
38
|
-
Used by `/wayfinder`. The **map** is a single issue with **child** issues as tickets.
|
|
39
|
-
|
|
40
|
-
- **Map**: a single issue labelled `wayfinder:map`, holding the Notes / Decisions-so-far / Fog body. `gh issue create --label wayfinder:map`.
|
|
41
|
-
- **Child ticket**: an issue linked to the map as a GitHub sub-issue (`gh api` on the sub-issues endpoint). Where sub-issues aren't enabled, add the child to a task list in the map body and put `Part of #<map>` at the top of the child body. Labels: `wayfinder:<type>` (`research`/`prototype`/`grilling`/`task`). Once claimed, the ticket is assigned to the driving dev.
|
|
42
|
-
- **Blocking**: GitHub's **native issue dependencies**, the canonical, UI-visible representation. Add an edge with `gh api --method POST repos/<owner>/<repo>/issues/<child>/dependencies/blocked_by -F issue_id=<blocker-db-id>`, where `<blocker-db-id>` is the blocker's numeric **database id** (`gh api repos/<owner>/<repo>/issues/<n> --jq .id`, _not_ the `#number` or `node_id`). GitHub reports `issue_dependencies_summary.blocked_by` (open blockers only, the live gate). Where dependencies aren't available, fall back to a `Blocked by: #<n>, #<n>` line at the top of the child body. A ticket is unblocked when every blocker is closed.
|
|
43
|
-
- **Frontier query**: list the map's open children (`gh issue list --state open`, scoped to the map's sub-issues / task list), drop any with an open blocker (`issue_dependencies_summary.blocked_by > 0`, or an open issue in the `Blocked by` line) or an assignee; first in map order wins.
|
|
44
|
-
- **Claim**: `gh issue edit <n> --add-assignee @me`, the session's first write.
|
|
45
|
-
- **Resolve**: `gh issue comment <n> --body "<answer>"`, then `gh issue close <n>`, then append a context pointer (gist + link) to the map's Decisions-so-far.
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# Triage Labels
|
|
2
|
-
|
|
3
|
-
The skills speak in terms of five canonical triage roles. This file maps those roles to the actual label strings used in this repo's issue tracker.
|
|
4
|
-
|
|
5
|
-
| Label in mattpocock/skills | Label in our tracker | Meaning |
|
|
6
|
-
| -------------------------- | -------------------- | ---------------------------------------- |
|
|
7
|
-
| `needs-triage` | `needs-triage` | Maintainer needs to evaluate this issue |
|
|
8
|
-
| `needs-info` | `needs-info` | Waiting on reporter for more information |
|
|
9
|
-
| `ready-for-agent` | `ready-for-agent` | Fully specified, ready for an AFK agent |
|
|
10
|
-
| `ready-for-human` | `ready-for-human` | Requires human implementation |
|
|
11
|
-
| `wontfix` | `wontfix` | Will not be actioned |
|
|
12
|
-
|
|
13
|
-
When a skill mentions a role (e.g. "apply the AFK-ready triage label"), use the corresponding label string from this table.
|
|
14
|
-
|
|
15
|
-
Edit the right-hand column to match whatever vocabulary you actually use.
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
# Migrating from 12.x to 13.0.0
|
|
2
|
-
|
|
3
|
-
Version 13 is a substantial release. The package is now ESM-only, the generator
|
|
4
|
-
emits Sequelize's native output by default, foreign keys become associations
|
|
5
|
-
automatically, and the SQLite driver has changed. This guide walks through each
|
|
6
|
-
breaking change in the order you are likely to hit it while upgrading, with a
|
|
7
|
-
concrete before/after for each, then lists what is new in 13.
|
|
8
|
-
|
|
9
|
-
## Breaking changes
|
|
10
|
-
|
|
11
|
-
### 1. ESM-only package, Node `>=22.13.0`
|
|
12
|
-
|
|
13
|
-
The package now ships as ES modules only (`"type": "module"`, a single root
|
|
14
|
-
`exports` entry, no dual CommonJS build). The runtime floor is raised to Node
|
|
15
|
-
`>=22.13.0`, which is the first version able to `require()` an ESM module that
|
|
16
|
-
has no top-level await. CommonJS consumers can still load the package through
|
|
17
|
-
`require()`, but their TypeScript must resolve modules the modern way.
|
|
18
|
-
|
|
19
|
-
CommonJS/TypeScript consumers need `module: node20` (or `nodenext`) so that
|
|
20
|
-
`require()` of an ESM dependency is allowed:
|
|
21
|
-
|
|
22
|
-
Before (12.x), CommonJS with legacy module resolution worked:
|
|
23
|
-
|
|
24
|
-
```jsonc
|
|
25
|
-
// tsconfig.json (12.x)
|
|
26
|
-
{
|
|
27
|
-
"compilerOptions": {
|
|
28
|
-
"module": "commonjs",
|
|
29
|
-
"moduleResolution": "node"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
After (13), use a Node-aware module setting:
|
|
35
|
-
|
|
36
|
-
```jsonc
|
|
37
|
-
// tsconfig.json (13)
|
|
38
|
-
{
|
|
39
|
-
"compilerOptions": {
|
|
40
|
-
"module": "node20", // or "nodenext"
|
|
41
|
-
"moduleResolution": "nodenext"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
```js
|
|
47
|
-
// CommonJS consumer (13) — require() of the ESM package works on Node >=22.13.0
|
|
48
|
-
const { SequelizeTypescriptGenerator } = require('sequelize-typescript-generator');
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Make sure the runtime is new enough:
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
# Before (12.x): older Node was fine
|
|
55
|
-
node -v # v14+
|
|
56
|
-
|
|
57
|
-
# After (13): Node >=22.13.0 is required
|
|
58
|
-
node -v # v22.13.0 or newer
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
Deep imports into `build/` are closed by the `exports` map as a consequence of
|
|
62
|
-
this change; see section 6.
|
|
63
|
-
|
|
64
|
-
### 2. Native is the default output format
|
|
65
|
-
|
|
66
|
-
The generator now emits Sequelize's native output by default: plain `sequelize`
|
|
67
|
-
model classes with attributes typed via `InferAttributes` /
|
|
68
|
-
`InferCreationAttributes`, `declare`d fields, and a `static initModel` method per
|
|
69
|
-
model. The old `sequelize-typescript` decorator output is still available behind
|
|
70
|
-
the new `--format native|decorators` flag.
|
|
71
|
-
|
|
72
|
-
Native models depend on `sequelize` alone. The decorators format still requires
|
|
73
|
-
`sequelize-typescript` and `reflect-metadata` in the consuming project.
|
|
74
|
-
|
|
75
|
-
Before (12.x) — implicit decorators output:
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
stg -D sqlite -s ./db.sqlite -o ./models
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
```ts
|
|
82
|
-
// models/person.ts (12.x, decorators)
|
|
83
|
-
@Table({ tableName: "person", timestamps: false })
|
|
84
|
-
export class person extends Model<personAttributes, personAttributes> {
|
|
85
|
-
@Column({ type: DataType.STRING })
|
|
86
|
-
name!: string;
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
After (13) — the same command now emits native output:
|
|
91
|
-
|
|
92
|
-
```ts
|
|
93
|
-
// models/person.ts (13, native — default)
|
|
94
|
-
export class person extends Model<InferAttributes<person>, InferCreationAttributes<person>> {
|
|
95
|
-
declare name: string;
|
|
96
|
-
|
|
97
|
-
static initModel(sequelize: Sequelize): typeof person {
|
|
98
|
-
person.init({
|
|
99
|
-
name: { type: DataTypes.STRING, allowNull: false }
|
|
100
|
-
}, { sequelize, tableName: "person", timestamps: false });
|
|
101
|
-
return person;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
To keep the old decorator output, opt in explicitly:
|
|
107
|
-
|
|
108
|
-
```bash
|
|
109
|
-
stg -D sqlite -s ./db.sqlite -o ./models --format decorators
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### 3. Associations discovered by default
|
|
113
|
-
|
|
114
|
-
Foreign keys are now turned into associations automatically. Where 12.x emitted
|
|
115
|
-
plain columns, 13 wires up the corresponding association mixins (and decorators,
|
|
116
|
-
under `--format decorators`). Pass `--no-associations` to restore the previous
|
|
117
|
-
behaviour of emitting foreign-key columns only.
|
|
118
|
-
|
|
119
|
-
Before (12.x) — a foreign key was just a column:
|
|
120
|
-
|
|
121
|
-
```ts
|
|
122
|
-
// person.ts (12.x)
|
|
123
|
-
export interface personAttributes {
|
|
124
|
-
passport_id: number;
|
|
125
|
-
}
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
After (13) — the relationship is materialised:
|
|
129
|
-
|
|
130
|
-
```ts
|
|
131
|
-
// person.ts (13, native)
|
|
132
|
-
declare passport_id: number;
|
|
133
|
-
declare getPassport: HasOneGetAssociationMixin<passport>;
|
|
134
|
-
declare setPassport: HasOneSetAssociationMixin<passport, passport["passport_id"]>;
|
|
135
|
-
declare passport?: NonAttribute<passport>;
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
Restore the old output:
|
|
139
|
-
|
|
140
|
-
```bash
|
|
141
|
-
stg -D sqlite -s ./db.sqlite -o ./models --no-associations
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
### 4. SQLite driver is `@vscode/sqlite3`
|
|
145
|
-
|
|
146
|
-
The SQLite integration now uses `@vscode/sqlite3`. The old `sqlite3` package is
|
|
147
|
-
no longer supported.
|
|
148
|
-
|
|
149
|
-
Before (12.x):
|
|
150
|
-
|
|
151
|
-
```bash
|
|
152
|
-
npm install sqlite3
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
After (13):
|
|
156
|
-
|
|
157
|
-
```bash
|
|
158
|
-
npm uninstall sqlite3
|
|
159
|
-
npm install @vscode/sqlite3
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
### 5. `--lint-file` is flat-config only
|
|
163
|
-
|
|
164
|
-
When you pass `--lint-file`, the generator now expects an ESLint flat config
|
|
165
|
-
(`eslint.config.js`). Legacy `.eslintrc*` files fail fast instead of being read.
|
|
166
|
-
|
|
167
|
-
Before (12.x) — a legacy config was accepted:
|
|
168
|
-
|
|
169
|
-
```bash
|
|
170
|
-
stg -D sqlite -s ./db.sqlite -o ./models --lint-file .eslintrc.js
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
```js
|
|
174
|
-
// .eslintrc.js (12.x)
|
|
175
|
-
module.exports = {
|
|
176
|
-
rules: { semi: ["error", "always"] }
|
|
177
|
-
};
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
After (13) — use a flat config:
|
|
181
|
-
|
|
182
|
-
```bash
|
|
183
|
-
stg -D sqlite -s ./db.sqlite -o ./models --lint-file eslint.config.js
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
```js
|
|
187
|
-
// eslint.config.js (13)
|
|
188
|
-
export default [
|
|
189
|
-
{ rules: { semi: ["error", "always"] } }
|
|
190
|
-
];
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
### 6. `exports` map closes deep imports
|
|
194
|
-
|
|
195
|
-
The package `exports` map exposes only the root entry (plus `./package.json`).
|
|
196
|
-
Deep imports into `build/` no longer resolve. This follows from the ESM-only
|
|
197
|
-
change in section 1.
|
|
198
|
-
|
|
199
|
-
Before (12.x) — reaching into the build tree worked:
|
|
200
|
-
|
|
201
|
-
```ts
|
|
202
|
-
import { SqliteDialect } from 'sequelize-typescript-generator/build/dialects/SqliteDialect';
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
After (13) — import from the package root only:
|
|
206
|
-
|
|
207
|
-
```ts
|
|
208
|
-
import { SqliteDialect } from 'sequelize-typescript-generator';
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
## New in 13
|
|
212
|
-
|
|
213
|
-
These are additive and do not require changes when upgrading.
|
|
214
|
-
|
|
215
|
-
### `--paranoid`
|
|
216
|
-
|
|
217
|
-
Emit paranoid table options for tables that have a `deleted_at` / `deletedAt`
|
|
218
|
-
column. Requires `--timestamps`.
|
|
219
|
-
|
|
220
|
-
```bash
|
|
221
|
-
stg -D sqlite -s ./db.sqlite -o ./models --timestamps --paranoid
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
```ts
|
|
225
|
-
// table option added when a deleted_at column is present
|
|
226
|
-
{ sequelize, tableName: "person", timestamps: true, paranoid: true }
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
### `createDialect` factory
|
|
230
|
-
|
|
231
|
-
A `createDialect` factory is now exported from the package root, to build a
|
|
232
|
-
dialect instance programmatically.
|
|
233
|
-
|
|
234
|
-
```ts
|
|
235
|
-
import { createDialect } from 'sequelize-typescript-generator';
|
|
236
|
-
|
|
237
|
-
const dialect = createDialect('sqlite');
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
### SQL Server `schema` and `hasTrigger`
|
|
241
|
-
|
|
242
|
-
For SQL Server, the generator now sets `schema` in the emitted table options and
|
|
243
|
-
detects `hasTrigger` on tables that have triggers.
|
|
244
|
-
|
|
245
|
-
```ts
|
|
246
|
-
// table options (mssql)
|
|
247
|
-
{ sequelize, tableName: "person", schema: "dbo", hasTrigger: true }
|
|
248
|
-
```
|