sequelize-typescript-generator 12.0.1 → 13.0.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.
- package/.github/workflows/ci.yml +175 -150
- package/.vscode/launch.json +212 -0
- package/.vscode/tasks.json +95 -0
- package/CHANGELOG.md +17 -0
- package/CLAUDE.md +13 -0
- package/CONTEXT.md +67 -0
- package/README.md +827 -199
- package/build/bin/cli.js +65 -47
- package/build/bin/utils.d.ts +5 -2
- package/build/bin/utils.js +87 -104
- package/build/builders/Builder.d.ts +2 -2
- package/build/builders/Builder.js +3 -5
- package/build/builders/ModelBuilder.d.ts +43 -8
- package/build/builders/ModelBuilder.js +120 -122
- package/build/builders/NativeModelRenderer.d.ts +98 -0
- package/build/builders/NativeModelRenderer.js +353 -0
- package/build/builders/associationNaming.d.ts +9 -0
- package/build/builders/associationNaming.js +15 -0
- package/build/builders/decoratorsDependency.d.ts +27 -0
- package/build/builders/decoratorsDependency.js +45 -0
- package/build/builders/defaultValues.d.ts +40 -0
- package/build/builders/defaultValues.js +56 -0
- package/build/builders/generatedFile.d.ts +23 -0
- package/build/builders/generatedFile.js +31 -0
- package/build/builders/index.d.ts +1 -1
- package/build/builders/index.js +1 -5
- package/build/builders/nativeAssociations.d.ts +109 -0
- package/build/builders/nativeAssociations.js +308 -0
- package/build/builders/nativeAttributes.d.ts +96 -0
- package/build/builders/nativeAttributes.js +174 -0
- package/build/builders/nativeWiring.d.ts +51 -0
- package/build/builders/nativeWiring.js +108 -0
- package/build/builders/utils.d.ts +75 -0
- package/build/builders/utils.js +142 -48
- package/build/config/IConfig.d.ts +11 -2
- package/build/config/IConfig.js +4 -6
- package/build/config/format.d.ts +27 -0
- package/build/config/format.js +26 -0
- package/build/config/index.d.ts +1 -1
- package/build/config/index.js +1 -2
- package/build/connection/createConnection.d.ts +8 -1
- package/build/connection/createConnection.js +30 -7
- package/build/connection/index.d.ts +1 -1
- package/build/connection/index.js +1 -17
- package/build/dialects/AssociationsParser.d.ts +10 -2
- package/build/dialects/AssociationsParser.js +16 -19
- package/build/dialects/Dialect.d.ts +52 -9
- package/build/dialects/Dialect.js +93 -57
- package/build/dialects/DialectMSSQL.d.ts +22 -3
- package/build/dialects/DialectMSSQL.js +169 -75
- package/build/dialects/DialectMariaDB.d.ts +13 -3
- package/build/dialects/DialectMariaDB.js +98 -79
- package/build/dialects/DialectMySQL.d.ts +13 -3
- package/build/dialects/DialectMySQL.js +101 -83
- package/build/dialects/DialectPostgres.d.ts +14 -3
- package/build/dialects/DialectPostgres.js +129 -75
- package/build/dialects/DialectSQLite.d.ts +41 -3
- package/build/dialects/DialectSQLite.js +166 -24
- package/build/dialects/associationDiscovery.d.ts +64 -0
- package/build/dialects/associationDiscovery.js +275 -0
- package/build/dialects/associationsFileMerge.d.ts +21 -0
- package/build/dialects/associationsFileMerge.js +107 -0
- package/build/dialects/createDialect.d.ts +8 -0
- package/build/dialects/createDialect.js +24 -0
- package/build/dialects/dataTypes.d.ts +58 -0
- package/build/dialects/dataTypes.js +108 -0
- package/build/dialects/foreignKeys.d.ts +115 -0
- package/build/dialects/foreignKeys.js +198 -0
- package/build/dialects/index.d.ts +5 -5
- package/build/dialects/index.js +5 -13
- package/build/dialects/paranoid.d.ts +24 -0
- package/build/dialects/paranoid.js +29 -0
- package/build/dialects/utils.d.ts +2 -8
- package/build/dialects/utils.js +61 -58
- package/build/index.d.ts +11 -3
- package/build/index.js +5 -19
- package/build/lint/Linter.d.ts +14 -3
- package/build/lint/Linter.js +114 -14
- package/build/lint/eslintDefaultConfig.d.ts +2 -2
- package/build/lint/eslintDefaultConfig.js +28 -23
- package/build/lint/index.d.ts +1 -1
- package/build/lint/index.js +1 -5
- package/build/utils/errors.d.ts +6 -0
- package/build/utils/errors.js +6 -0
- package/docker-compose.yml +65 -0
- package/docs/adr/0001-esm-only-package.md +36 -0
- package/docs/adr/0002-native-default-output-format.md +41 -0
- package/docs/agents/domain.md +51 -0
- package/docs/agents/issue-tracker.md +45 -0
- package/docs/agents/triage-labels.md +15 -0
- package/docs/migration/12-to-13.md +248 -0
- package/docs/plans/v13-phase5-association-discovery.md +168 -0
- package/docs/plans/v13-phase6-native-emitter.md +537 -0
- package/docs/plans/v13-upgrade-plan.md +137 -0
- package/jest.config.cjs +31 -0
- package/package.json +44 -27
- package/scripts/check-no-sequelize-typescript.cjs +68 -0
- package/tsconfig.json +4 -3
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "2.0.0",
|
|
3
|
+
"tasks": [
|
|
4
|
+
{
|
|
5
|
+
// Bring the postgres container up (idempotent) and wait until it accepts connections.
|
|
6
|
+
"label": "db: postgres (up + wait)",
|
|
7
|
+
"type": "shell",
|
|
8
|
+
"command": "docker compose --profile postgres up -d && TEST_DB_DIALECT=postgres TEST_DB_HOST=localhost TEST_DB_PORT=1234 npx tsx src/tests/integration/wait-for-db.ts",
|
|
9
|
+
"problemMatcher": []
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
// Bring the mysql container up (idempotent) and wait until it accepts connections.
|
|
13
|
+
"label": "db: mysql (up + wait)",
|
|
14
|
+
"type": "shell",
|
|
15
|
+
"command": "docker compose --profile mysql up -d && TEST_DB_DIALECT=mysql TEST_DB_HOST=localhost TEST_DB_PORT=1234 npx tsx src/tests/integration/wait-for-db.ts",
|
|
16
|
+
"problemMatcher": []
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
// Bring the mariadb container up (idempotent) and wait until it accepts connections.
|
|
20
|
+
"label": "db: mariadb (up + wait)",
|
|
21
|
+
"type": "shell",
|
|
22
|
+
"command": "docker compose --profile mariadb up -d && TEST_DB_DIALECT=mariadb TEST_DB_HOST=localhost TEST_DB_PORT=1234 npx tsx src/tests/integration/wait-for-db.ts",
|
|
23
|
+
"problemMatcher": []
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
// Bring the mssql container up (idempotent) and wait until it accepts connections.
|
|
27
|
+
"label": "db: mssql (up + wait)",
|
|
28
|
+
"type": "shell",
|
|
29
|
+
"command": "docker compose --profile mssql up -d && TEST_DB_DIALECT=mssql TEST_DB_HOST=localhost TEST_DB_PORT=1234 npx tsx src/tests/integration/wait-for-db.ts",
|
|
30
|
+
"problemMatcher": []
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
// Tear down every dialect container and remove its volumes.
|
|
34
|
+
"label": "db: down (all)",
|
|
35
|
+
"type": "shell",
|
|
36
|
+
"command": "docker compose --profile postgres --profile mysql --profile mariadb --profile mssql down -v",
|
|
37
|
+
"problemMatcher": []
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
// Full postgres integration cycle: up, wait, jest, down.
|
|
41
|
+
"label": "Integration: postgres (like CI)",
|
|
42
|
+
"type": "npm",
|
|
43
|
+
"script": "test:postgres",
|
|
44
|
+
"problemMatcher": []
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
// Full mysql integration cycle: up, wait, jest, down.
|
|
48
|
+
"label": "Integration: mysql (like CI)",
|
|
49
|
+
"type": "npm",
|
|
50
|
+
"script": "test:mysql",
|
|
51
|
+
"problemMatcher": []
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
// Full mariadb integration cycle: up, wait, jest, down.
|
|
55
|
+
"label": "Integration: mariadb (like CI)",
|
|
56
|
+
"type": "npm",
|
|
57
|
+
"script": "test:mariadb",
|
|
58
|
+
"problemMatcher": []
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
// Full mssql integration cycle: up, wait, jest, down.
|
|
62
|
+
// Requires Node <= 23 locally — tedious/SlowBuffer is broken on Node >= 24.
|
|
63
|
+
"label": "Integration: mssql (like CI)",
|
|
64
|
+
"type": "npm",
|
|
65
|
+
"script": "test:mssql",
|
|
66
|
+
"problemMatcher": []
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
// Run every dialect SEQUENTIALLY: all Docker dialects share host port 1234, and each
|
|
70
|
+
// wrapper tears its container down before the next starts, so they cannot overlap.
|
|
71
|
+
"label": "Integration: all dialects (like CI)",
|
|
72
|
+
"type": "shell",
|
|
73
|
+
"command": "npm run test:postgres && npm run test:mysql && npm run test:mariadb && npm run test:mssql && npm run test:sqlite",
|
|
74
|
+
"group": {
|
|
75
|
+
"kind": "test",
|
|
76
|
+
"isDefault": true
|
|
77
|
+
},
|
|
78
|
+
"problemMatcher": []
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
// Run the unit test suite.
|
|
82
|
+
"label": "Test: unit",
|
|
83
|
+
"type": "npm",
|
|
84
|
+
"script": "test:unit",
|
|
85
|
+
"problemMatcher": []
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
// Run the sqlite integration suite (no container needed).
|
|
89
|
+
"label": "Test: sqlite",
|
|
90
|
+
"type": "npm",
|
|
91
|
+
"script": "test:sqlite",
|
|
92
|
+
"problemMatcher": []
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
### 13.0.0
|
|
6
|
+
#### Breaking changes:
|
|
7
|
+
* Native is now the default output format; pass `--format decorators` for the old `sequelize-typescript` decorators output.
|
|
8
|
+
* ESM-only package; Node `>=22.13.0` required.
|
|
9
|
+
* SQLite driver switched to `@vscode/sqlite3` (`sqlite3` is no longer supported).
|
|
10
|
+
* Associations are discovered from foreign keys by default; `--no-associations` restores the old behaviour.
|
|
11
|
+
* `--lint-file` accepts flat config files only; legacy `.eslintrc*` files fail fast.
|
|
12
|
+
* Deep imports under `build/` are closed by the package `exports` map (root entry only).
|
|
13
|
+
|
|
14
|
+
#### Minor changes and bug fixes:
|
|
15
|
+
* New `--paranoid` flag: emit paranoid table options for tables with a `deleted_at`/`deletedAt` column (requires `--timestamps`).
|
|
16
|
+
* `createDialect` factory exported from the package root.
|
|
17
|
+
* SQL Server `schema` in table options and `hasTrigger` detection.
|
|
18
|
+
* See `docs/migration/12-to-13.md` for the full migration guide.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
5
22
|
### 10.1.0
|
|
6
23
|
#### Breaking changes:
|
|
7
24
|
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## Agent skills
|
|
2
|
+
|
|
3
|
+
### Issue tracker
|
|
4
|
+
|
|
5
|
+
Issues are tracked in this repo's GitHub Issues via the `gh` CLI. See `docs/agents/issue-tracker.md`.
|
|
6
|
+
|
|
7
|
+
### Triage labels
|
|
8
|
+
|
|
9
|
+
Default triage vocabulary (`needs-triage`, `needs-info`, `ready-for-agent`, `ready-for-human`, `wontfix`). See `docs/agents/triage-labels.md`.
|
|
10
|
+
|
|
11
|
+
### Domain docs
|
|
12
|
+
|
|
13
|
+
Single-context: `CONTEXT.md` + `docs/adr/` at the repo root. See `docs/agents/domain.md`.
|
package/CONTEXT.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
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
|