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,137 @@
|
|
|
1
|
+
# Version 13 upgrade plan
|
|
2
|
+
|
|
3
|
+
Ordered, hand-off plan for sequelize-typescript-generator 13.0.0. Decisions were made on the wayfinder map [Sequelize v6 native format and v13 upgrade plan](https://github.com/spinlud/sequelize-typescript-generator/issues/62); each phase links the decision tickets it implements. Progress is tracked in the GitHub milestone [13.0.0](https://github.com/spinlud/sequelize-typescript-generator/milestone/1), one issue per phase, chained by native issue dependencies.
|
|
4
|
+
|
|
5
|
+
## Destination
|
|
6
|
+
|
|
7
|
+
Sequelize v6 only. A new default **native** output format (plain Sequelize classes with `declare` fields and `Model.init`, plus a generated `initModels.ts` wiring file) and the existing **decorators** format behind `--format decorators` with a target-project dependency warning. Automatic association discovery from foreign keys. ESM-only package on Node `>=22.13.0`. A CI matrix over dialect and two database versions per engine.
|
|
8
|
+
|
|
9
|
+
## Standing decisions
|
|
10
|
+
|
|
11
|
+
| Topic | Decision | Ticket |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| Sequelize version | v6 only; v7 out of scope while alpha | map |
|
|
14
|
+
| Output formats | `--format native\|decorators`, native default, hence a new major | map, [#69](https://github.com/spinlud/sequelize-typescript-generator/issues/69) |
|
|
15
|
+
| Programmatic API | `IConfig.format`; single `ModelBuilder` entry; `createDialect`; explicit root re-export list; `build()` throws, never exits | [#82](https://github.com/spinlud/sequelize-typescript-generator/issues/82) |
|
|
16
|
+
| Migration guide | README checklist + `docs/migration/12-to-13.md`; Release notes are the changelog; `12.x` cut in phase 1 | [#83](https://github.com/spinlud/sequelize-typescript-generator/issues/83) |
|
|
17
|
+
| Emitter approach | TypeScript compiler API, structured like `ModelBuilder.ts`; no templates | [#68](https://github.com/spinlud/sequelize-typescript-generator/issues/68) |
|
|
18
|
+
| Module format | ESM-only (dual build revised away); ADR written in phase 2 | [#71](https://github.com/spinlud/sequelize-typescript-generator/issues/71) |
|
|
19
|
+
| Runtime floor | `engines.node >=22.13.0`; single Node version in CI | [#71](https://github.com/spinlud/sequelize-typescript-generator/issues/71), [#72](https://github.com/spinlud/sequelize-typescript-generator/issues/72) |
|
|
20
|
+
| TypeScript | build on 6.0.x; dependency and peer `>=5.7 <6.1` | [#71](https://github.com/spinlud/sequelize-typescript-generator/issues/71) |
|
|
21
|
+
| Lint | ESLint 10 flat config, `@stylistic` rules, legacy eslintrc fails fast, lint stack stays a hard dependency | [#71](https://github.com/spinlud/sequelize-typescript-generator/issues/71) |
|
|
22
|
+
| SQLite driver | `@vscode/sqlite3` via `dialectModule`; `sqlite3` no longer documented or tested | [#71](https://github.com/spinlud/sequelize-typescript-generator/issues/71) |
|
|
23
|
+
| `sequelize-typescript` | optional peer dependency; generator imports only `sequelize` at runtime | [#67](https://github.com/spinlud/sequelize-typescript-generator/issues/67) |
|
|
24
|
+
| Association discovery | on by default in both formats, `--no-associations` disables; 1:1 and 1:N only; associations file kept and applied on top | [#70](https://github.com/spinlud/sequelize-typescript-generator/issues/70) |
|
|
25
|
+
| New features | SQL Server `schema` and `hasTrigger` as unconditional fixes; `--paranoid` opt-in; no allowlist mechanism | [#73](https://github.com/spinlud/sequelize-typescript-generator/issues/73) |
|
|
26
|
+
| Test matrix | format is not a job axis; 8 server jobs + SQLite; PR subset runs latest DB per dialect; weekly and `v*` tags run the full matrix and gate a provenance publish | [#72](https://github.com/spinlud/sequelize-typescript-generator/issues/72) |
|
|
27
|
+
| Package name | kept | map |
|
|
28
|
+
|
|
29
|
+
## Phases
|
|
30
|
+
|
|
31
|
+
Phases run in order; each phase issue is blocked by the previous one. Effort is in dev-days, calibrated against the prototype's measured 11 to 15 dev-days for emitter plus discovery ([#68](https://github.com/spinlud/sequelize-typescript-generator/issues/68)). Total: **26 to 39 dev-days**.
|
|
32
|
+
|
|
33
|
+
| # | Phase | Issue | Dev-days | Publishes |
|
|
34
|
+
|---|---|---|---|---|
|
|
35
|
+
| 1 | Dependency shape | [#75](https://github.com/spinlud/sequelize-typescript-generator/issues/75) | 1 to 2 | |
|
|
36
|
+
| 2 | Toolchain | [#76](https://github.com/spinlud/sequelize-typescript-generator/issues/76) | 4 to 6 | |
|
|
37
|
+
| 3 | Test and CI matrix | [#77](https://github.com/spinlud/sequelize-typescript-generator/issues/77) | 4 to 6 | `13.0.0-beta.1` |
|
|
38
|
+
| 4 | Metadata layer | [#78](https://github.com/spinlud/sequelize-typescript-generator/issues/78) | 4 to 6 | |
|
|
39
|
+
| 5 | Association discovery | [#79](https://github.com/spinlud/sequelize-typescript-generator/issues/79) | 3 to 5 | `13.0.0-beta.2` |
|
|
40
|
+
| 6 | Native emitter | [#80](https://github.com/spinlud/sequelize-typescript-generator/issues/80) | 8 to 11 | `13.0.0-beta.3` |
|
|
41
|
+
| 7 | Release | [#81](https://github.com/spinlud/sequelize-typescript-generator/issues/81) | 2 to 3 | `13.0.0` |
|
|
42
|
+
|
|
43
|
+
### Phase 1: dependency shape
|
|
44
|
+
|
|
45
|
+
Implements [#67](https://github.com/spinlud/sequelize-typescript-generator/issues/67).
|
|
46
|
+
|
|
47
|
+
- Entry: none; unblocked at plan creation.
|
|
48
|
+
- Work: tag the 12.0.1 commit `v12.0.1` and cut branch `12.x` from it; replace the six value imports of `sequelize-typescript` (`createConnection.ts` and the five dialect files) with `Sequelize` and `DataTypes` from `sequelize`; move `sequelize-typescript` to an optional peer dependency, kept in `devDependencies`; keep `reflect-metadata` dev-only; add a guard that fails when shipped source value-imports `sequelize-typescript`.
|
|
49
|
+
- Exit: no `require("sequelize-typescript")` in `build/`; guard active; existing tests green; `v12.0.1` tag and `12.x` branch pushed.
|
|
50
|
+
|
|
51
|
+
### Phase 2: toolchain
|
|
52
|
+
|
|
53
|
+
Implements [#71](https://github.com/spinlud/sequelize-typescript-generator/issues/71), built on research [#64](https://github.com/spinlud/sequelize-typescript-generator/issues/64) and [#65](https://github.com/spinlud/sequelize-typescript-generator/issues/65).
|
|
54
|
+
|
|
55
|
+
- Entry: phase 1 closed.
|
|
56
|
+
- Work: ESM-only build with plain `tsc`, `module: nodenext`, `"type": "module"`, `exports` map with a single root entry plus `./package.json`; `.js` suffix on relative imports; `yargs(hideBin(process.argv))`; `engines.node >=22.13.0`; TypeScript 6.0.x build, peer range `>=5.7 <6.1`, drop `downlevelIteration`; Jest 30 with the ts-jest ESM preset and `jest.config.cjs`; `tsx` for dev scripts; ESLint 10 flat config with `@stylistic/eslint-plugin`, `@typescript-eslint/parser` 8.x; default lint path uses `overrideConfigFile: true` with `baseConfig`; `--lint-file` passes `overrideConfigFile`; legacy eslintrc files and objects fail fast with a pointer to the ESLint migration guide; SQLite dialect resolves `@vscode/sqlite3` from the user's project as `dialectModule`; ADR for ESM-only in `docs/adr/`; glossary term **Driver** in `CONTEXT.md`; programmatic API (#82): root barrel re-exports `Dialect`, `DialectName`, `createDialect`, the `IConfig*`/`Transform*` types and the metadata interfaces, `Builder`/`Linter`/utils stay private, `build()` throws instead of `process.exit`.
|
|
57
|
+
- Exit: builds and runs ESM-only on Node 22.13; suite green under Jest 30; both lint paths tested; legacy eslintrc rejected; ADR committed; root entry loads via `require()` from CommonJS (no top-level await).
|
|
58
|
+
|
|
59
|
+
### Phase 3: test and CI matrix
|
|
60
|
+
|
|
61
|
+
Implements [#72](https://github.com/spinlud/sequelize-typescript-generator/issues/72).
|
|
62
|
+
|
|
63
|
+
- Entry: phase 2 closed.
|
|
64
|
+
- Work: `checks` job then integration jobs; PR subset runs the latest version per dialect plus SQLite; weekly schedule and `v*` tags run the full 8-server matrix plus SQLite and gate a provenance `publish` job; GitHub `services:` containers with minor-pinned tags; dialect-neutral `wait-for-db` script; local `docker-compose.yml` with one profile per dialect and `npm run test:<dialect>`; delete the `docker-*.sh` scripts; `describe.each` over formats in `TestRunner.ts`; strict `tsc --noEmit` test over generated output; one SQLite golden fixture per format with `npm run test:golden:update`; lint `-L` success and fail-fast tests; gitignore generated output.
|
|
65
|
+
- Exit: PR subset and full matrix green; shell scripts removed; golden fixture and compile check running for the decorators format; `13.0.0-beta.1` published on the npm `next` tag.
|
|
66
|
+
|
|
67
|
+
### Phase 4: metadata layer
|
|
68
|
+
|
|
69
|
+
Implements the metadata part of [#70](https://github.com/spinlud/sequelize-typescript-generator/issues/70), [#73](https://github.com/spinlud/sequelize-typescript-generator/issues/73), and the gaps listed by [#68](https://github.com/spinlud/sequelize-typescript-generator/issues/68).
|
|
70
|
+
|
|
71
|
+
- Entry: phase 3 closed.
|
|
72
|
+
- Work: per-dialect foreign key fetch (constraint name, source and target columns, `ON DELETE`/`ON UPDATE`, single-column uniqueness of the source column) on all five dialects; extended `IColumnMetadata.foreignKey` and `IAssociationMetadata`; mapper from database types to `DataTypes.*`; `--paranoid` flag; SQL Server `schema` in table options and `hasTrigger` detection.
|
|
73
|
+
- Exit: foreign key fetch tested per dialect in the matrix; `--paranoid` and SQL Server fixes covered by integration tests; matrix green.
|
|
74
|
+
|
|
75
|
+
### Phase 5: association discovery
|
|
76
|
+
|
|
77
|
+
Implements [#70](https://github.com/spinlud/sequelize-typescript-generator/issues/70).
|
|
78
|
+
|
|
79
|
+
- Entry: phase 4 closed.
|
|
80
|
+
- Work: cardinality rule, hybrid alias rule with `--case`, warnings for composite, cross-schema and excluded-target foreign keys, associations file applied on top, `--no-associations`, `onDelete`/`onUpdate` when not `NO ACTION`; decorators emission through `@ForeignKey`, `@BelongsTo`, `@HasMany`/`@HasOne` with `foreignKey` and `as`.
|
|
81
|
+
- Exit: discovery tests per dialect; decorators golden fixture updated; `13.0.0-beta.2` published on `next`.
|
|
82
|
+
|
|
83
|
+
### Phase 6: native emitter
|
|
84
|
+
|
|
85
|
+
Implements [#69](https://github.com/spinlud/sequelize-typescript-generator/issues/69), [#68](https://github.com/spinlud/sequelize-typescript-generator/issues/68), [#63](https://github.com/spinlud/sequelize-typescript-generator/issues/63), and the native parts of [#70](https://github.com/spinlud/sequelize-typescript-generator/issues/70) and [#73](https://github.com/spinlud/sequelize-typescript-generator/issues/73).
|
|
86
|
+
|
|
87
|
+
- Entry: phase 5 closed **and** [Specify the programmatic API shape for the native format](https://github.com/spinlud/sequelize-typescript-generator/issues/82) closed.
|
|
88
|
+
- Work: `--format native|decorators` with native default; compiler API renderer sharing `ModelBuilder.ts` helpers; one file per model, `initModels.ts`, `index.ts`; flag behaviours per the native specification; decorators dependency warning via `require.resolve` from the output directory, never failing; programmatic API (#82): `IConfig.format` top level defaulting to `native`, `ModelBuilder` dispatches on format internally, `initModel` returns the class, `initModels` contract native-only.
|
|
89
|
+
- Exit: both formats run in every matrix job; native output passes strict `tsc --noEmit` and runtime assertions on all dialects; native golden fixture committed; README documents `--format`; `13.0.0-beta.3` published on `next`.
|
|
90
|
+
|
|
91
|
+
### Phase 7: release
|
|
92
|
+
|
|
93
|
+
Implements the release strategy from [#74](https://github.com/spinlud/sequelize-typescript-generator/issues/74).
|
|
94
|
+
|
|
95
|
+
- Entry: phase 6 closed **and** [Decide the 12.x to 13.x migration guide contents](https://github.com/spinlud/sequelize-typescript-generator/issues/83) closed.
|
|
96
|
+
- Work: README section "Migrating from 12.x" plus `docs/migration/12-to-13.md` per [#83](https://github.com/spinlud/sequelize-typescript-generator/issues/83); GitHub Release notes on the fixed template as breaking-change notice and changelog (no `CHANGELOG.md`, no `npm deprecate`); tag `v13.0.0` so the full matrix publishes with provenance.
|
|
97
|
+
- Exit: `13.0.0` on npm `latest`; GitHub Release published; README section and guide merged.
|
|
98
|
+
|
|
99
|
+
## Release strategy
|
|
100
|
+
|
|
101
|
+
- Pre-releases `13.0.0-beta.1`, `.2`, `.3` on the npm `next` tag after phases 3, 5 and 6. Each exposes one breaking area in turn: ESM-only packaging, discovery on by default, native output as default.
|
|
102
|
+
- Breaking-change notice: GitHub Release notes on a fixed template (summary, breaking changes copied from the README checklist, guide link, install command, auto-generated commits), used for the betas too. No `CHANGELOG.md`, no `npm deprecate` on 12.x.
|
|
103
|
+
- `12.x` branch cut from the retro-tagged `v12.0.1` commit at the start of phase 1; security fixes only until 2027-03-31, stated in the migration guide. No final 12.x pointer patch.
|
|
104
|
+
|
|
105
|
+
## Breaking changes in 13.0.0
|
|
106
|
+
|
|
107
|
+
- Default output format is native; decorators output requires `--format decorators`.
|
|
108
|
+
- ESM-only package; CommonJS consumers load it through `require(esm)` and need TypeScript `module: node20` or `nodenext`.
|
|
109
|
+
- Node `>=22.13.0`.
|
|
110
|
+
- `--lint-file` accepts flat config files only; legacy `.eslintrc*` fails fast.
|
|
111
|
+
- SQLite uses `@vscode/sqlite3`; `sqlite3` is no longer supported.
|
|
112
|
+
- Associations are discovered from foreign keys by default; `--no-associations` restores the previous behaviour.
|
|
113
|
+
- Deep imports under `build/` are closed by the `exports` map.
|
|
114
|
+
|
|
115
|
+
## Decisions still open before implementation reaches them
|
|
116
|
+
|
|
117
|
+
None. Both gates are resolved; see Standing decisions.
|
|
118
|
+
|
|
119
|
+
## Post-13 backlog
|
|
120
|
+
|
|
121
|
+
Ruled out of version 13 but worth keeping in view:
|
|
122
|
+
|
|
123
|
+
- Optional alias column in the associations file.
|
|
124
|
+
- Optional flag adding the `.js` suffix to relative imports in generated files for strict Node ESM consumers.
|
|
125
|
+
- Column-level `unique: true` without duplicating the `--indices` constraint on `sequelize.sync()`.
|
|
126
|
+
- Opt-in `validate.len` (decorators: `@Length`) from declared string column length.
|
|
127
|
+
- Junction table heuristic to discover many-to-many associations.
|
|
128
|
+
- Moving the lint stack to optional peer dependencies.
|
|
129
|
+
- Sequelize v7 support, as a fresh effort if a v7 beta ships.
|
|
130
|
+
- `ModelBuilder.build()` returning the list of written file paths.
|
|
131
|
+
|
|
132
|
+
## Phase plans
|
|
133
|
+
|
|
134
|
+
Detailed, step-by-step implementation plans for the phases that have one:
|
|
135
|
+
|
|
136
|
+
- Phase 5, association discovery (#79): [`docs/plans/v13-phase5-association-discovery.md`](v13-phase5-association-discovery.md).
|
|
137
|
+
- Phase 6, native emitter (#80): [`docs/plans/v13-phase6-native-emitter.md`](v13-phase6-native-emitter.md).
|
package/jest.config.cjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const { createDefaultEsmPreset } = require('ts-jest');
|
|
2
|
+
|
|
3
|
+
/** @type {import('jest').Config} */
|
|
4
|
+
module.exports = {
|
|
5
|
+
...createDefaultEsmPreset({
|
|
6
|
+
// The build uses "module": "nodenext"; ts-jest only warns that hybrid module
|
|
7
|
+
// kinds prefer isolatedModules. Suppress that advisory while keeping type checking.
|
|
8
|
+
diagnostics: { ignoreCodes: [151002] },
|
|
9
|
+
// Generated decorator models import each other circularly. Under ESM, the eager
|
|
10
|
+
// "design:type" reference emitted by emitDecoratorMetadata hits the temporal dead
|
|
11
|
+
// zone. The models declare explicit column types, so the metadata is unused.
|
|
12
|
+
//
|
|
13
|
+
// The decorator models expose plain public class fields without "declare".
|
|
14
|
+
// Target ES2022 turns useDefineForClassFields on, which would emit real fields
|
|
15
|
+
// that shadow Sequelize's attribute getters and setters, so keep it off.
|
|
16
|
+
tsconfig: {
|
|
17
|
+
emitDecoratorMetadata: false,
|
|
18
|
+
useDefineForClassFields: false,
|
|
19
|
+
},
|
|
20
|
+
}),
|
|
21
|
+
roots: ['<rootDir>/src/tests'],
|
|
22
|
+
moduleNameMapper: {
|
|
23
|
+
'^(\\.{1,2}/.*)\\.js$': '$1',
|
|
24
|
+
},
|
|
25
|
+
testPathIgnorePatterns: [
|
|
26
|
+
'environment.ts',
|
|
27
|
+
'testsData.ts',
|
|
28
|
+
'TestRunner.ts',
|
|
29
|
+
],
|
|
30
|
+
verbose: true,
|
|
31
|
+
};
|
package/package.json
CHANGED
|
@@ -1,30 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sequelize-typescript-generator",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"description": "Automatically generates typescript models compatible with sequelize-typescript library (https://www.npmjs.com/package/sequelize-typescript) directly from your source database.",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "build/index.js",
|
|
6
7
|
"types": "build/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./build/index.d.ts",
|
|
11
|
+
"default": "./build/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
7
15
|
"bin": {
|
|
8
16
|
"stg": "build/bin/cli.js"
|
|
9
17
|
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=22.13.0"
|
|
20
|
+
},
|
|
10
21
|
"scripts": {
|
|
11
22
|
"clean": "rm -fr build",
|
|
12
23
|
"lint": "eslint --fix --ext .ts output/*.ts",
|
|
13
|
-
"build": "npm run clean && tsc",
|
|
24
|
+
"build": "npm run clean && tsc && npm run check-deps",
|
|
25
|
+
"check-deps": "node scripts/check-no-sequelize-typescript.cjs",
|
|
14
26
|
"audit": "npm audit",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"test
|
|
21
|
-
"test
|
|
22
|
-
"test
|
|
23
|
-
"
|
|
24
|
-
"test
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"usage": "npx ts-node-dev src/bin/cli.ts --help"
|
|
27
|
+
"test:unit": "NODE_OPTIONS=--experimental-vm-modules jest src/tests/unit",
|
|
28
|
+
"test:sqlite": "NODE_OPTIONS=--experimental-vm-modules jest src/tests/integration/sqlite",
|
|
29
|
+
"test:golden:update": "NODE_OPTIONS=--experimental-vm-modules GOLDEN_UPDATE=1 jest src/tests/integration/sqlite -t 'golden'",
|
|
30
|
+
"test:integration": "NODE_OPTIONS=--experimental-vm-modules jest src/tests/integration/$TEST_DB_DIALECT",
|
|
31
|
+
"test:postgres": "docker compose --profile postgres up -d && TEST_DB_DIALECT=postgres tsx src/tests/integration/wait-for-db.ts && TEST_DB_DIALECT=postgres npm run test:integration; status=$?; docker compose --profile postgres down -v; exit $status",
|
|
32
|
+
"test:mysql": "docker compose --profile mysql up -d && TEST_DB_DIALECT=mysql tsx src/tests/integration/wait-for-db.ts && TEST_DB_DIALECT=mysql npm run test:integration; status=$?; docker compose --profile mysql down -v; exit $status",
|
|
33
|
+
"test:mariadb": "docker compose --profile mariadb up -d && TEST_DB_DIALECT=mariadb tsx src/tests/integration/wait-for-db.ts && TEST_DB_DIALECT=mariadb npm run test:integration; status=$?; docker compose --profile mariadb down -v; exit $status",
|
|
34
|
+
"test:mssql": "docker compose --profile mssql up -d && TEST_DB_DIALECT=mssql tsx src/tests/integration/wait-for-db.ts && TEST_DB_DIALECT=mssql npm run test:integration; status=$?; docker compose --profile mssql down -v; exit $status",
|
|
35
|
+
"pretest": "npm run build",
|
|
36
|
+
"test": "npm run test:unit && npm run test:sqlite",
|
|
37
|
+
"dev": "tsx src/bin/cli.ts -D mysql -u root -x mysql -d dbtest --dialect-options '{\"timezone\": \"local\"}' --case const:camel --clean --logs",
|
|
38
|
+
"usage": "tsx src/bin/cli.ts --help"
|
|
28
39
|
},
|
|
29
40
|
"author": "Ludovico Fabbri",
|
|
30
41
|
"license": "ISC",
|
|
@@ -36,36 +47,42 @@
|
|
|
36
47
|
"devDependencies": {
|
|
37
48
|
"@types/bluebird": "^3.5.42",
|
|
38
49
|
"@types/estree": "^1.0.6",
|
|
39
|
-
"@types/jest": "^
|
|
40
|
-
"@types/node": "^
|
|
50
|
+
"@types/jest": "^30.0.0",
|
|
51
|
+
"@types/node": "^22.13.0",
|
|
41
52
|
"@types/pluralize": "0.0.33",
|
|
42
53
|
"@types/validator": "^13.12.2",
|
|
43
54
|
"@types/yargs": "^17.0.33",
|
|
44
|
-
"jest": "^
|
|
55
|
+
"jest": "^30.5.1",
|
|
45
56
|
"mariadb": "^3.4.0",
|
|
46
57
|
"mysql2": "^3.12.0",
|
|
47
58
|
"pg": "^8.13.1",
|
|
48
59
|
"pg-hstore": "^2.3.4",
|
|
49
60
|
"reflect-metadata": "^0.2.1",
|
|
50
|
-
"
|
|
61
|
+
"sequelize-typescript": "^2.1.6",
|
|
62
|
+
"@vscode/sqlite3": "^5.1.14-vscode",
|
|
51
63
|
"tedious": "^18.6.1",
|
|
52
|
-
"ts-jest": "^29.
|
|
53
|
-
"
|
|
64
|
+
"ts-jest": "^29.4.12",
|
|
65
|
+
"tsx": "^4.23.13",
|
|
54
66
|
"wkx": "^0.5.0"
|
|
55
67
|
},
|
|
56
68
|
"dependencies": {
|
|
57
|
-
"@
|
|
58
|
-
"@typescript-eslint/parser": "^
|
|
69
|
+
"@stylistic/eslint-plugin": "^5.10.0",
|
|
70
|
+
"@typescript-eslint/parser": "^8.70.0",
|
|
59
71
|
"change-case": "^4.1.2",
|
|
60
|
-
"eslint": "^
|
|
72
|
+
"eslint": "^10.10.0",
|
|
61
73
|
"pluralize": "^8.0.0",
|
|
62
74
|
"sequelize": "^6.37.5",
|
|
63
|
-
"
|
|
64
|
-
"typescript": "^5.7.2",
|
|
75
|
+
"typescript": ">=5.7 <6.1",
|
|
65
76
|
"yargs": "^17.7.2"
|
|
66
77
|
},
|
|
67
78
|
"peerDependencies": {
|
|
68
|
-
"typescript": "
|
|
79
|
+
"typescript": ">=5.7 <6.1",
|
|
80
|
+
"sequelize-typescript": "^2.1.6"
|
|
81
|
+
},
|
|
82
|
+
"peerDependenciesMeta": {
|
|
83
|
+
"sequelize-typescript": {
|
|
84
|
+
"optional": true
|
|
85
|
+
}
|
|
69
86
|
},
|
|
70
87
|
"keywords": [
|
|
71
88
|
"sequelize",
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
|
|
8
|
+
const BUILD_DIR = path.resolve(__dirname, '..', 'build');
|
|
9
|
+
|
|
10
|
+
const FORBIDDEN_PATTERNS = [
|
|
11
|
+
'require("sequelize-typescript")',
|
|
12
|
+
"require('sequelize-typescript')",
|
|
13
|
+
'from "sequelize-typescript"',
|
|
14
|
+
"from 'sequelize-typescript'",
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Recursively collect every .js file under a directory.
|
|
19
|
+
* @param {string} directory
|
|
20
|
+
* @returns {string[]}
|
|
21
|
+
*/
|
|
22
|
+
function collectJsFiles(directory) {
|
|
23
|
+
const entries = fs.readdirSync(directory, { withFileTypes: true });
|
|
24
|
+
const files = [];
|
|
25
|
+
|
|
26
|
+
for (const entry of entries) {
|
|
27
|
+
const fullPath = path.join(directory, entry.name);
|
|
28
|
+
|
|
29
|
+
if (entry.isDirectory()) {
|
|
30
|
+
files.push(...collectJsFiles(fullPath));
|
|
31
|
+
} else if (entry.isFile() && entry.name.endsWith('.js')) {
|
|
32
|
+
files.push(fullPath);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return files;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function main() {
|
|
40
|
+
if (!fs.existsSync(BUILD_DIR)) {
|
|
41
|
+
console.error(`check-deps: build directory not found at ${BUILD_DIR}. Run the build first.`);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const offendingFiles = [];
|
|
46
|
+
|
|
47
|
+
for (const file of collectJsFiles(BUILD_DIR)) {
|
|
48
|
+
const content = fs.readFileSync(file, 'utf8');
|
|
49
|
+
|
|
50
|
+
if (FORBIDDEN_PATTERNS.some((pattern) => content.includes(pattern))) {
|
|
51
|
+
offendingFiles.push(file);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (offendingFiles.length > 0) {
|
|
56
|
+
console.error('check-deps: found runtime references to sequelize-typescript in the build output:');
|
|
57
|
+
for (const file of offendingFiles) {
|
|
58
|
+
console.error(` - ${path.relative(process.cwd(), file)}`);
|
|
59
|
+
}
|
|
60
|
+
console.error('sequelize-typescript must remain an optional peer dependency and must not be required at runtime.');
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
console.log('check-deps: no runtime references to sequelize-typescript found in build output.');
|
|
65
|
+
process.exit(0);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
main();
|
package/tsconfig.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
4
|
-
"module": "
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "nodenext",
|
|
5
|
+
"moduleResolution": "nodenext",
|
|
5
6
|
"declaration": true,
|
|
6
7
|
"outDir": "./build",
|
|
7
8
|
"rootDir": "./src",
|
|
8
|
-
"downlevelIteration": true,
|
|
9
9
|
"strict": true,
|
|
10
|
+
"types": ["node", "jest"],
|
|
10
11
|
"esModuleInterop": true,
|
|
11
12
|
"experimentalDecorators": true,
|
|
12
13
|
"emitDecoratorMetadata": true,
|