sequelize-typescript-generator 13.0.0 → 13.1.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/README.md +7 -7
- package/build/bin/utils.js +1 -1
- package/build/builders/ModelBuilder.js +26 -5
- package/build/builders/NativeModelRenderer.js +10 -2
- package/build/builders/generatedFile.js +5 -0
- package/build/builders/jsonSupport.d.ts +62 -0
- package/build/builders/jsonSupport.js +82 -0
- package/build/builders/utils.d.ts +20 -2
- package/build/builders/utils.js +39 -5
- package/build/dialects/Dialect.d.ts +1 -0
- package/build/dialects/DialectMariaDB.d.ts +11 -0
- package/build/dialects/DialectMariaDB.js +45 -0
- package/build/dialects/DialectMySQL.js +2 -1
- package/build/dialects/DialectPostgres.d.ts +3 -1
- package/build/dialects/DialectPostgres.js +38 -7
- package/build/dialects/dataTypes.d.ts +18 -4
- package/build/dialects/dataTypes.js +21 -4
- package/build/dialects/mariadbJson.d.ts +39 -0
- package/build/dialects/mariadbJson.js +52 -0
- 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
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import { DataTypes } from 'sequelize';
|
|
2
2
|
import type { AbstractDataTypeConstructor } from 'sequelize';
|
|
3
3
|
export type SequelizeDataTypeKey = keyof typeof DataTypes;
|
|
4
|
-
export type DataTypeArgument = string | number;
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* A single argument of a Sequelize data type. A scalar argument is a number
|
|
6
|
+
* (precision, length) or a string (ENUM value); a nested argument is itself a
|
|
7
|
+
* data type, so an argument list can carry another data type such as the element
|
|
8
|
+
* type of `ARRAY(INTEGER)`.
|
|
9
|
+
*/
|
|
10
|
+
export type DataTypeArgument = string | number | ISequelizeDataType;
|
|
11
|
+
/**
|
|
12
|
+
* Format-neutral Sequelize data type: a DataTypes key plus its arguments. Scalar
|
|
13
|
+
* arguments render bare (numbers) or single-quoted (strings, for ENUM values); a
|
|
14
|
+
* nested data type argument renders as its own data type expression.
|
|
8
15
|
*/
|
|
9
16
|
export interface ISequelizeDataType {
|
|
10
17
|
key: SequelizeDataTypeKey;
|
|
11
18
|
args: DataTypeArgument[];
|
|
12
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Type guard for a nested data type argument.
|
|
22
|
+
* @param {DataTypeArgument} arg
|
|
23
|
+
* @returns {boolean}
|
|
24
|
+
*/
|
|
25
|
+
export declare const isNestedDataType: (arg: DataTypeArgument) => arg is ISequelizeDataType;
|
|
13
26
|
/**
|
|
14
27
|
* Namespaces under which a data type expression is rendered.
|
|
15
28
|
*/
|
|
@@ -43,7 +56,8 @@ export declare const resolveSequelizeDataTypeKey: (ctor: AbstractDataTypeConstru
|
|
|
43
56
|
*/
|
|
44
57
|
export declare const buildSequelizeDataType: (ctor: AbstractDataTypeConstructor, args: Array<DataTypeArgument | null | undefined>) => ISequelizeDataType | undefined;
|
|
45
58
|
/**
|
|
46
|
-
* Render a data type expression, e.g. DataType.DECIMAL(7,3)
|
|
59
|
+
* Render a data type expression, e.g. DataType.DECIMAL(7,3), DataTypes.ENUM('AA','BB')
|
|
60
|
+
* or DataTypes.ARRAY(DataTypes.INTEGER).
|
|
47
61
|
* @param {ISequelizeDataType} dataType
|
|
48
62
|
* @param {DataTypeNamespace} namespace
|
|
49
63
|
* @returns {string}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { DataTypes } from 'sequelize';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard for a nested data type argument.
|
|
4
|
+
* @param {DataTypeArgument} arg
|
|
5
|
+
* @returns {boolean}
|
|
6
|
+
*/
|
|
7
|
+
export const isNestedDataType = (arg) => typeof arg === 'object' && arg !== null && 'key' in arg && 'args' in arg;
|
|
2
8
|
/**
|
|
3
9
|
* Namespaces under which a data type expression is rendered.
|
|
4
10
|
*/
|
|
@@ -47,20 +53,31 @@ export const buildSequelizeDataType = (ctor, args) => {
|
|
|
47
53
|
};
|
|
48
54
|
/**
|
|
49
55
|
* Render a single data type argument. Numbers render bare; strings render
|
|
50
|
-
* single-quoted with internal single quotes doubled
|
|
56
|
+
* single-quoted with internal single quotes doubled; a nested data type renders
|
|
57
|
+
* as its own expression under the same namespace.
|
|
51
58
|
* @param {DataTypeArgument} arg
|
|
59
|
+
* @param {DataTypeNamespace} namespace
|
|
52
60
|
* @returns {string}
|
|
53
61
|
*/
|
|
54
|
-
const renderDataTypeArgument = (arg) =>
|
|
62
|
+
const renderDataTypeArgument = (arg, namespace) => {
|
|
63
|
+
if (typeof arg === 'number') {
|
|
64
|
+
return String(arg);
|
|
65
|
+
}
|
|
66
|
+
if (typeof arg === 'string') {
|
|
67
|
+
return `'${arg.replace(/'/g, "''")}'`;
|
|
68
|
+
}
|
|
69
|
+
return renderDataTypeExpression(arg, namespace);
|
|
70
|
+
};
|
|
55
71
|
/**
|
|
56
|
-
* Render a data type expression, e.g. DataType.DECIMAL(7,3)
|
|
72
|
+
* Render a data type expression, e.g. DataType.DECIMAL(7,3), DataTypes.ENUM('AA','BB')
|
|
73
|
+
* or DataTypes.ARRAY(DataTypes.INTEGER).
|
|
57
74
|
* @param {ISequelizeDataType} dataType
|
|
58
75
|
* @param {DataTypeNamespace} namespace
|
|
59
76
|
* @returns {string}
|
|
60
77
|
*/
|
|
61
78
|
export const renderDataTypeExpression = (dataType, namespace) => {
|
|
62
79
|
const signature = dataType.args.length
|
|
63
|
-
? `(${dataType.args.map(renderDataTypeArgument).join(',')})`
|
|
80
|
+
? `(${dataType.args.map(arg => renderDataTypeArgument(arg, namespace)).join(',')})`
|
|
64
81
|
: '';
|
|
65
82
|
return `${namespace}.${dataType.key}${signature}`;
|
|
66
83
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MariaDB stores a `JSON` column as `longtext` with a `CHECK (json_valid(<col>))`
|
|
3
|
+
* constraint. These helpers recover the JSON columns of a table from the check
|
|
4
|
+
* clauses (information_schema.CHECK_CONSTRAINTS) or, as a fallback for MariaDB
|
|
5
|
+
* versions without that view, from the `SHOW CREATE TABLE` statement.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* A row of information_schema.CHECK_CONSTRAINTS relevant to JSON detection.
|
|
9
|
+
*/
|
|
10
|
+
export interface ICheckConstraintRow {
|
|
11
|
+
CHECK_CLAUSE: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A row of `SHOW CREATE TABLE`, whose second column holds the create statement.
|
|
15
|
+
*/
|
|
16
|
+
export interface IShowCreateTableRow {
|
|
17
|
+
'Create Table'?: string;
|
|
18
|
+
'CREATE TABLE'?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Extract the column names guarded by a `json_valid(...)` check from a set of
|
|
22
|
+
* check clauses.
|
|
23
|
+
* @param {ICheckConstraintRow[]} rows
|
|
24
|
+
* @returns {Set<string>}
|
|
25
|
+
*/
|
|
26
|
+
export declare const extractJsonColumnsFromCheckConstraints: (rows: ICheckConstraintRow[]) => Set<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Extract the column names guarded by a `json_valid(...)` check from a
|
|
29
|
+
* `SHOW CREATE TABLE` statement.
|
|
30
|
+
* @param {string} createTableStatement
|
|
31
|
+
* @returns {Set<string>}
|
|
32
|
+
*/
|
|
33
|
+
export declare const extractJsonColumnsFromCreateTable: (createTableStatement: string) => Set<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Read the create statement out of a `SHOW CREATE TABLE` result row.
|
|
36
|
+
* @param {IShowCreateTableRow | undefined} row
|
|
37
|
+
* @returns {string}
|
|
38
|
+
*/
|
|
39
|
+
export declare const getCreateTableStatement: (row: IShowCreateTableRow | undefined) => string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MariaDB stores a `JSON` column as `longtext` with a `CHECK (json_valid(<col>))`
|
|
3
|
+
* constraint. These helpers recover the JSON columns of a table from the check
|
|
4
|
+
* clauses (information_schema.CHECK_CONSTRAINTS) or, as a fallback for MariaDB
|
|
5
|
+
* versions without that view, from the `SHOW CREATE TABLE` statement.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Match a `json_valid(<column>)` call, capturing the column name with its
|
|
9
|
+
* optional surrounding backticks stripped. Case-insensitive and global so every
|
|
10
|
+
* occurrence in a statement can be scanned.
|
|
11
|
+
*/
|
|
12
|
+
const JSON_VALID_PATTERN = /json_valid\(\s*`?([^`()\s]+)`?\s*\)/gi;
|
|
13
|
+
/**
|
|
14
|
+
* Extract the column names guarded by a `json_valid(...)` check from a set of
|
|
15
|
+
* check clauses.
|
|
16
|
+
* @param {ICheckConstraintRow[]} rows
|
|
17
|
+
* @returns {Set<string>}
|
|
18
|
+
*/
|
|
19
|
+
export const extractJsonColumnsFromCheckConstraints = (rows) => {
|
|
20
|
+
const columns = new Set();
|
|
21
|
+
for (const row of rows) {
|
|
22
|
+
for (const columnName of matchJsonValidColumns(row.CHECK_CLAUSE ?? '')) {
|
|
23
|
+
columns.add(columnName);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return columns;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Extract the column names guarded by a `json_valid(...)` check from a
|
|
30
|
+
* `SHOW CREATE TABLE` statement.
|
|
31
|
+
* @param {string} createTableStatement
|
|
32
|
+
* @returns {Set<string>}
|
|
33
|
+
*/
|
|
34
|
+
export const extractJsonColumnsFromCreateTable = (createTableStatement) => new Set(matchJsonValidColumns(createTableStatement));
|
|
35
|
+
/**
|
|
36
|
+
* Read the create statement out of a `SHOW CREATE TABLE` result row.
|
|
37
|
+
* @param {IShowCreateTableRow | undefined} row
|
|
38
|
+
* @returns {string}
|
|
39
|
+
*/
|
|
40
|
+
export const getCreateTableStatement = (row) => row?.['Create Table'] ?? row?.['CREATE TABLE'] ?? '';
|
|
41
|
+
/**
|
|
42
|
+
* Collect every column name captured by a `json_valid(...)` call in a string.
|
|
43
|
+
* @param {string} value
|
|
44
|
+
* @returns {string[]}
|
|
45
|
+
*/
|
|
46
|
+
const matchJsonValidColumns = (value) => {
|
|
47
|
+
const columns = [];
|
|
48
|
+
for (const match of value.matchAll(JSON_VALID_PATTERN)) {
|
|
49
|
+
columns.push(match[1]);
|
|
50
|
+
}
|
|
51
|
+
return columns;
|
|
52
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sequelize-typescript-generator",
|
|
3
|
-
"version": "13.
|
|
4
|
-
"description": "Automatically
|
|
3
|
+
"version": "13.1.0",
|
|
4
|
+
"description": "Automatically generate type-safe Sequelize models from your source database via the TypeScript compiler API — native or sequelize-typescript (decorators) format.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/index.js",
|
|
7
7
|
"types": "build/index.d.ts",
|
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">=22.13.0"
|
|
20
20
|
},
|
|
21
|
+
"files": [
|
|
22
|
+
"build"
|
|
23
|
+
],
|
|
21
24
|
"scripts": {
|
|
22
25
|
"clean": "rm -fr build",
|
|
23
26
|
"lint": "eslint --fix --ext .ts output/*.ts",
|
package/.github/FUNDING.yml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
github: [spinlud]
|
package/.github/workflows/ci.yml
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
name: ci
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
push:
|
|
6
|
-
branches:
|
|
7
|
-
- master
|
|
8
|
-
tags:
|
|
9
|
-
- "v*"
|
|
10
|
-
schedule:
|
|
11
|
-
# Weekly full matrix, Mondays at 04:00 UTC.
|
|
12
|
-
- cron: "0 4 * * 1"
|
|
13
|
-
workflow_dispatch:
|
|
14
|
-
|
|
15
|
-
env:
|
|
16
|
-
NODE_VERSION: "22.13"
|
|
17
|
-
|
|
18
|
-
jobs:
|
|
19
|
-
checks:
|
|
20
|
-
runs-on: ubuntu-latest
|
|
21
|
-
steps:
|
|
22
|
-
- uses: actions/checkout@v4
|
|
23
|
-
|
|
24
|
-
- uses: actions/setup-node@v4
|
|
25
|
-
with:
|
|
26
|
-
node-version: ${{ env.NODE_VERSION }}
|
|
27
|
-
cache: npm
|
|
28
|
-
|
|
29
|
-
- name: Install
|
|
30
|
-
run: npm ci
|
|
31
|
-
|
|
32
|
-
# Type check stands in for lint: the repo has no ESLint config for its own source.
|
|
33
|
-
- name: Lint (type check)
|
|
34
|
-
run: npx tsc --noEmit
|
|
35
|
-
|
|
36
|
-
- name: Build
|
|
37
|
-
run: npm run build
|
|
38
|
-
|
|
39
|
-
- name: Unit tests
|
|
40
|
-
run: npm run test:unit
|
|
41
|
-
|
|
42
|
-
sqlite:
|
|
43
|
-
runs-on: ubuntu-latest
|
|
44
|
-
needs: checks
|
|
45
|
-
steps:
|
|
46
|
-
- uses: actions/checkout@v4
|
|
47
|
-
|
|
48
|
-
- uses: actions/setup-node@v4
|
|
49
|
-
with:
|
|
50
|
-
node-version: ${{ env.NODE_VERSION }}
|
|
51
|
-
cache: npm
|
|
52
|
-
|
|
53
|
-
- name: Install
|
|
54
|
-
run: npm ci
|
|
55
|
-
|
|
56
|
-
- name: SQLite tests
|
|
57
|
-
run: npm run test:sqlite
|
|
58
|
-
|
|
59
|
-
set-matrix:
|
|
60
|
-
runs-on: ubuntu-latest
|
|
61
|
-
needs: checks
|
|
62
|
-
outputs:
|
|
63
|
-
latest: ${{ steps.matrix.outputs.latest }}
|
|
64
|
-
full: ${{ steps.matrix.outputs.full }}
|
|
65
|
-
steps:
|
|
66
|
-
- name: Build matrices
|
|
67
|
-
id: matrix
|
|
68
|
-
run: |
|
|
69
|
-
latest='[
|
|
70
|
-
{"dialect":"postgres","image":"postgres:18","container_port":5432},
|
|
71
|
-
{"dialect":"mysql","image":"mysql:9.7","container_port":3306},
|
|
72
|
-
{"dialect":"mariadb","image":"mariadb:12.3","container_port":3306},
|
|
73
|
-
{"dialect":"mssql","image":"mcr.microsoft.com/mssql/server:2025-latest","container_port":1433}
|
|
74
|
-
]'
|
|
75
|
-
full='[
|
|
76
|
-
{"dialect":"postgres","image":"postgres:18","container_port":5432},
|
|
77
|
-
{"dialect":"postgres","image":"postgres:16","container_port":5432},
|
|
78
|
-
{"dialect":"mysql","image":"mysql:9.7","container_port":3306},
|
|
79
|
-
{"dialect":"mysql","image":"mysql:8.4","container_port":3306},
|
|
80
|
-
{"dialect":"mariadb","image":"mariadb:12.3","container_port":3306},
|
|
81
|
-
{"dialect":"mariadb","image":"mariadb:11.4","container_port":3306},
|
|
82
|
-
{"dialect":"mssql","image":"mcr.microsoft.com/mssql/server:2025-latest","container_port":1433},
|
|
83
|
-
{"dialect":"mssql","image":"mcr.microsoft.com/mssql/server:2022-latest","container_port":1433}
|
|
84
|
-
]'
|
|
85
|
-
echo "latest=$(echo "$latest" | jq -c .)" >> "$GITHUB_OUTPUT"
|
|
86
|
-
echo "full=$(echo "$full" | jq -c .)" >> "$GITHUB_OUTPUT"
|
|
87
|
-
|
|
88
|
-
integration-latest:
|
|
89
|
-
runs-on: ubuntu-latest
|
|
90
|
-
needs: set-matrix
|
|
91
|
-
strategy:
|
|
92
|
-
fail-fast: false
|
|
93
|
-
matrix:
|
|
94
|
-
include: ${{ fromJson(needs.set-matrix.outputs.latest) }}
|
|
95
|
-
services:
|
|
96
|
-
db:
|
|
97
|
-
image: ${{ matrix.image }}
|
|
98
|
-
env:
|
|
99
|
-
POSTGRES_DB: testdb
|
|
100
|
-
POSTGRES_USER: sa
|
|
101
|
-
POSTGRES_PASSWORD: Passw0rd88!
|
|
102
|
-
MYSQL_DATABASE: testdb
|
|
103
|
-
MYSQL_USER: sa
|
|
104
|
-
MYSQL_PASSWORD: Passw0rd88!
|
|
105
|
-
MYSQL_ROOT_PASSWORD: Passw0rd88!
|
|
106
|
-
MARIADB_DATABASE: testdb
|
|
107
|
-
MARIADB_USER: sa
|
|
108
|
-
MARIADB_PASSWORD: Passw0rd88!
|
|
109
|
-
MARIADB_ROOT_PASSWORD: Passw0rd88!
|
|
110
|
-
ACCEPT_EULA: "Y"
|
|
111
|
-
SA_PASSWORD: Passw0rd88!
|
|
112
|
-
MSSQL_SA_PASSWORD: Passw0rd88!
|
|
113
|
-
ports:
|
|
114
|
-
- 1234:${{ matrix.container_port }}
|
|
115
|
-
env:
|
|
116
|
-
TEST_DB_DIALECT: ${{ matrix.dialect }}
|
|
117
|
-
TEST_DB_HOST: localhost
|
|
118
|
-
TEST_DB_PORT: 1234
|
|
119
|
-
steps:
|
|
120
|
-
- uses: actions/checkout@v4
|
|
121
|
-
|
|
122
|
-
- uses: actions/setup-node@v4
|
|
123
|
-
with:
|
|
124
|
-
node-version: ${{ env.NODE_VERSION }}
|
|
125
|
-
cache: npm
|
|
126
|
-
|
|
127
|
-
- name: Install
|
|
128
|
-
run: npm ci
|
|
129
|
-
|
|
130
|
-
- name: Wait for database
|
|
131
|
-
run: npx tsx src/tests/integration/wait-for-db.ts
|
|
132
|
-
|
|
133
|
-
- name: Integration tests (${{ matrix.image }})
|
|
134
|
-
run: npm run test:integration
|
|
135
|
-
|
|
136
|
-
integration-full:
|
|
137
|
-
runs-on: ubuntu-latest
|
|
138
|
-
needs: set-matrix
|
|
139
|
-
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v')
|
|
140
|
-
strategy:
|
|
141
|
-
fail-fast: false
|
|
142
|
-
matrix:
|
|
143
|
-
include: ${{ fromJson(needs.set-matrix.outputs.full) }}
|
|
144
|
-
services:
|
|
145
|
-
db:
|
|
146
|
-
image: ${{ matrix.image }}
|
|
147
|
-
env:
|
|
148
|
-
POSTGRES_DB: testdb
|
|
149
|
-
POSTGRES_USER: sa
|
|
150
|
-
POSTGRES_PASSWORD: Passw0rd88!
|
|
151
|
-
MYSQL_DATABASE: testdb
|
|
152
|
-
MYSQL_USER: sa
|
|
153
|
-
MYSQL_PASSWORD: Passw0rd88!
|
|
154
|
-
MYSQL_ROOT_PASSWORD: Passw0rd88!
|
|
155
|
-
MARIADB_DATABASE: testdb
|
|
156
|
-
MARIADB_USER: sa
|
|
157
|
-
MARIADB_PASSWORD: Passw0rd88!
|
|
158
|
-
MARIADB_ROOT_PASSWORD: Passw0rd88!
|
|
159
|
-
ACCEPT_EULA: "Y"
|
|
160
|
-
SA_PASSWORD: Passw0rd88!
|
|
161
|
-
MSSQL_SA_PASSWORD: Passw0rd88!
|
|
162
|
-
ports:
|
|
163
|
-
- 1234:${{ matrix.container_port }}
|
|
164
|
-
env:
|
|
165
|
-
TEST_DB_DIALECT: ${{ matrix.dialect }}
|
|
166
|
-
TEST_DB_HOST: localhost
|
|
167
|
-
TEST_DB_PORT: 1234
|
|
168
|
-
steps:
|
|
169
|
-
- uses: actions/checkout@v4
|
|
170
|
-
|
|
171
|
-
- uses: actions/setup-node@v4
|
|
172
|
-
with:
|
|
173
|
-
node-version: ${{ env.NODE_VERSION }}
|
|
174
|
-
cache: npm
|
|
175
|
-
|
|
176
|
-
- name: Install
|
|
177
|
-
run: npm ci
|
|
178
|
-
|
|
179
|
-
- name: Wait for database
|
|
180
|
-
run: npx tsx src/tests/integration/wait-for-db.ts
|
|
181
|
-
|
|
182
|
-
- name: Integration tests (${{ matrix.image }})
|
|
183
|
-
run: npm run test:integration
|
|
184
|
-
|
|
185
|
-
publish:
|
|
186
|
-
runs-on: ubuntu-latest
|
|
187
|
-
if: startsWith(github.ref, 'refs/tags/v')
|
|
188
|
-
needs:
|
|
189
|
-
- sqlite
|
|
190
|
-
- integration-latest
|
|
191
|
-
- integration-full
|
|
192
|
-
permissions:
|
|
193
|
-
id-token: write
|
|
194
|
-
contents: read
|
|
195
|
-
steps:
|
|
196
|
-
- uses: actions/checkout@v4
|
|
197
|
-
|
|
198
|
-
- uses: actions/setup-node@v4
|
|
199
|
-
with:
|
|
200
|
-
node-version: ${{ env.NODE_VERSION }}
|
|
201
|
-
cache: npm
|
|
202
|
-
registry-url: "https://registry.npmjs.org"
|
|
203
|
-
|
|
204
|
-
- name: Upgrade npm for trusted publishing
|
|
205
|
-
# npm 11.x provides OIDC trusted publishing and supports Node 22.13
|
|
206
|
-
run: npm install -g npm@11
|
|
207
|
-
|
|
208
|
-
- name: Install
|
|
209
|
-
run: npm ci
|
|
210
|
-
|
|
211
|
-
- name: Build
|
|
212
|
-
run: npm run build
|
|
213
|
-
|
|
214
|
-
- name: Resolve npm dist-tag
|
|
215
|
-
id: dist_tag
|
|
216
|
-
run: |
|
|
217
|
-
if [[ "${GITHUB_REF_NAME}" == *-* ]]; then
|
|
218
|
-
echo "tag=next" >> "$GITHUB_OUTPUT"
|
|
219
|
-
else
|
|
220
|
-
echo "tag=latest" >> "$GITHUB_OUTPUT"
|
|
221
|
-
fi
|
|
222
|
-
|
|
223
|
-
- name: Publish
|
|
224
|
-
run: npm publish --provenance --access public --tag ${{ steps.dist_tag.outputs.tag }}
|
package/.vscode/launch.json
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// Use IntelliSense to learn about possible attributes.
|
|
3
|
-
// Hover to view descriptions of existing attributes.
|
|
4
|
-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
-
"version": "0.2.0",
|
|
6
|
-
"configurations": [
|
|
7
|
-
{
|
|
8
|
-
// Run the CLI from source (tsx) against a sqlite DB, emitting native models.
|
|
9
|
-
// Point -S at your own sqlite file (create .scratch/local.sqlite first).
|
|
10
|
-
"type": "node",
|
|
11
|
-
"request": "launch",
|
|
12
|
-
"name": "CLI: sqlite → native",
|
|
13
|
-
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/tsx",
|
|
14
|
-
"program": "${workspaceFolder}/src/bin/cli.ts",
|
|
15
|
-
"args": [
|
|
16
|
-
"-D", "sqlite",
|
|
17
|
-
"-S", "${workspaceFolder}/.scratch/local.sqlite",
|
|
18
|
-
"-o", "${workspaceFolder}/output-models",
|
|
19
|
-
"-F", "native",
|
|
20
|
-
"--clean"
|
|
21
|
-
],
|
|
22
|
-
"console": "integratedTerminal",
|
|
23
|
-
"skipFiles": ["<node_internals>/**"]
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
// Same as above but emitting sequelize-typescript decorator models.
|
|
27
|
-
"type": "node",
|
|
28
|
-
"request": "launch",
|
|
29
|
-
"name": "CLI: sqlite → decorators",
|
|
30
|
-
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/tsx",
|
|
31
|
-
"program": "${workspaceFolder}/src/bin/cli.ts",
|
|
32
|
-
"args": [
|
|
33
|
-
"-D", "sqlite",
|
|
34
|
-
"-S", "${workspaceFolder}/.scratch/local.sqlite",
|
|
35
|
-
"-o", "${workspaceFolder}/output-models",
|
|
36
|
-
"-F", "decorators",
|
|
37
|
-
"--clean"
|
|
38
|
-
],
|
|
39
|
-
"console": "integratedTerminal",
|
|
40
|
-
"skipFiles": ["<node_internals>/**"]
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
// Print CLI usage.
|
|
44
|
-
"type": "node",
|
|
45
|
-
"request": "launch",
|
|
46
|
-
"name": "CLI: --help",
|
|
47
|
-
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/tsx",
|
|
48
|
-
"program": "${workspaceFolder}/src/bin/cli.ts",
|
|
49
|
-
"args": ["--help"],
|
|
50
|
-
"console": "integratedTerminal",
|
|
51
|
-
"skipFiles": ["<node_internals>/**"]
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
// Run the CLI against a sqlite DB whose path and output format you choose at launch.
|
|
55
|
-
"type": "node",
|
|
56
|
-
"request": "launch",
|
|
57
|
-
"name": "CLI: sqlite (prompt path + format)",
|
|
58
|
-
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/tsx",
|
|
59
|
-
"program": "${workspaceFolder}/src/bin/cli.ts",
|
|
60
|
-
"args": [
|
|
61
|
-
"-D", "sqlite",
|
|
62
|
-
"-S", "${input:sqliteStorage}",
|
|
63
|
-
"-o", "${workspaceFolder}/output-models",
|
|
64
|
-
"-F", "${input:format}",
|
|
65
|
-
"--clean"
|
|
66
|
-
],
|
|
67
|
-
"console": "integratedTerminal",
|
|
68
|
-
"skipFiles": ["<node_internals>/**"]
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
// Run all unit tests under the Node debugger.
|
|
72
|
-
"type": "node",
|
|
73
|
-
"request": "launch",
|
|
74
|
-
"name": "Jest: unit (all)",
|
|
75
|
-
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
|
|
76
|
-
"args": ["src/tests/unit", "--runInBand"],
|
|
77
|
-
"env": {
|
|
78
|
-
"NODE_OPTIONS": "--experimental-vm-modules"
|
|
79
|
-
},
|
|
80
|
-
"console": "integratedTerminal",
|
|
81
|
-
"skipFiles": ["<node_internals>/**"]
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
// Run all sqlite integration tests under the Node debugger.
|
|
85
|
-
"type": "node",
|
|
86
|
-
"request": "launch",
|
|
87
|
-
"name": "Jest: sqlite integration (all)",
|
|
88
|
-
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
|
|
89
|
-
"args": ["src/tests/integration/sqlite", "--runInBand"],
|
|
90
|
-
"env": {
|
|
91
|
-
"NODE_OPTIONS": "--experimental-vm-modules"
|
|
92
|
-
},
|
|
93
|
-
"console": "integratedTerminal",
|
|
94
|
-
"skipFiles": ["<node_internals>/**"]
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
// Run the currently open test file under the Node debugger.
|
|
98
|
-
"type": "node",
|
|
99
|
-
"request": "launch",
|
|
100
|
-
"name": "Jest: current file",
|
|
101
|
-
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
|
|
102
|
-
"args": ["${relativeFile}", "--runInBand"],
|
|
103
|
-
"env": {
|
|
104
|
-
"NODE_OPTIONS": "--experimental-vm-modules"
|
|
105
|
-
},
|
|
106
|
-
"console": "integratedTerminal",
|
|
107
|
-
"skipFiles": ["<node_internals>/**"]
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
// Regenerate sqlite golden fixtures for the golden tests.
|
|
111
|
-
"type": "node",
|
|
112
|
-
"request": "launch",
|
|
113
|
-
"name": "Jest: sqlite golden update",
|
|
114
|
-
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
|
|
115
|
-
"args": ["src/tests/integration/sqlite", "-t", "golden", "--runInBand"],
|
|
116
|
-
"env": {
|
|
117
|
-
"NODE_OPTIONS": "--experimental-vm-modules",
|
|
118
|
-
"GOLDEN_UPDATE": "1"
|
|
119
|
-
},
|
|
120
|
-
"console": "integratedTerminal",
|
|
121
|
-
"skipFiles": ["<node_internals>/**"]
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
// Debug the postgres integration tests. preLaunchTask brings the DB up and waits;
|
|
125
|
-
// the container is left running afterwards — run the "db: down (all)" task to stop it.
|
|
126
|
-
"type": "node",
|
|
127
|
-
"request": "launch",
|
|
128
|
-
"name": "Integration: postgres (debug)",
|
|
129
|
-
"preLaunchTask": "db: postgres (up + wait)",
|
|
130
|
-
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
|
|
131
|
-
"args": ["src/tests/integration/postgres", "--runInBand"],
|
|
132
|
-
"env": {
|
|
133
|
-
"NODE_OPTIONS": "--experimental-vm-modules",
|
|
134
|
-
"TEST_DB_DIALECT": "postgres",
|
|
135
|
-
"TEST_DB_HOST": "localhost",
|
|
136
|
-
"TEST_DB_PORT": "1234"
|
|
137
|
-
},
|
|
138
|
-
"console": "integratedTerminal",
|
|
139
|
-
"skipFiles": ["<node_internals>/**"]
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
// Debug the mysql integration tests. preLaunchTask brings the DB up and waits;
|
|
143
|
-
// the container is left running afterwards — run the "db: down (all)" task to stop it.
|
|
144
|
-
"type": "node",
|
|
145
|
-
"request": "launch",
|
|
146
|
-
"name": "Integration: mysql (debug)",
|
|
147
|
-
"preLaunchTask": "db: mysql (up + wait)",
|
|
148
|
-
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
|
|
149
|
-
"args": ["src/tests/integration/mysql", "--runInBand"],
|
|
150
|
-
"env": {
|
|
151
|
-
"NODE_OPTIONS": "--experimental-vm-modules",
|
|
152
|
-
"TEST_DB_DIALECT": "mysql",
|
|
153
|
-
"TEST_DB_HOST": "localhost",
|
|
154
|
-
"TEST_DB_PORT": "1234"
|
|
155
|
-
},
|
|
156
|
-
"console": "integratedTerminal",
|
|
157
|
-
"skipFiles": ["<node_internals>/**"]
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
// Debug the mariadb integration tests. preLaunchTask brings the DB up and waits;
|
|
161
|
-
// the container is left running afterwards — run the "db: down (all)" task to stop it.
|
|
162
|
-
"type": "node",
|
|
163
|
-
"request": "launch",
|
|
164
|
-
"name": "Integration: mariadb (debug)",
|
|
165
|
-
"preLaunchTask": "db: mariadb (up + wait)",
|
|
166
|
-
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
|
|
167
|
-
"args": ["src/tests/integration/mariadb", "--runInBand"],
|
|
168
|
-
"env": {
|
|
169
|
-
"NODE_OPTIONS": "--experimental-vm-modules",
|
|
170
|
-
"TEST_DB_DIALECT": "mariadb",
|
|
171
|
-
"TEST_DB_HOST": "localhost",
|
|
172
|
-
"TEST_DB_PORT": "1234"
|
|
173
|
-
},
|
|
174
|
-
"console": "integratedTerminal",
|
|
175
|
-
"skipFiles": ["<node_internals>/**"]
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
// Debug the mssql integration tests. preLaunchTask brings the DB up and waits;
|
|
179
|
-
// the container is left running afterwards — run the "db: down (all)" task to stop it.
|
|
180
|
-
// Requires Node <= 23 locally (tedious/SlowBuffer broken on Node >= 24).
|
|
181
|
-
"type": "node",
|
|
182
|
-
"request": "launch",
|
|
183
|
-
"name": "Integration: mssql (debug)",
|
|
184
|
-
"preLaunchTask": "db: mssql (up + wait)",
|
|
185
|
-
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
|
|
186
|
-
"args": ["src/tests/integration/mssql", "--runInBand"],
|
|
187
|
-
"env": {
|
|
188
|
-
"NODE_OPTIONS": "--experimental-vm-modules",
|
|
189
|
-
"TEST_DB_DIALECT": "mssql",
|
|
190
|
-
"TEST_DB_HOST": "localhost",
|
|
191
|
-
"TEST_DB_PORT": "1234"
|
|
192
|
-
},
|
|
193
|
-
"console": "integratedTerminal",
|
|
194
|
-
"skipFiles": ["<node_internals>/**"]
|
|
195
|
-
}
|
|
196
|
-
],
|
|
197
|
-
"inputs": [
|
|
198
|
-
{
|
|
199
|
-
"id": "sqliteStorage",
|
|
200
|
-
"type": "promptString",
|
|
201
|
-
"description": "Path to the sqlite database file",
|
|
202
|
-
"default": "${workspaceFolder}/.scratch/local.sqlite"
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
"id": "format",
|
|
206
|
-
"type": "pickString",
|
|
207
|
-
"description": "Output format",
|
|
208
|
-
"options": ["native", "decorators"],
|
|
209
|
-
"default": "native"
|
|
210
|
-
}
|
|
211
|
-
]
|
|
212
|
-
}
|