sequelize-typescript-generator 7.1.3 → 7.5.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 +3 -1
- package/build/bin/cli.js +5 -1
- package/build/bin/utils.d.ts +1 -0
- package/build/bin/utils.js +2 -0
- package/build/builders/utils.js +1 -1
- package/build/config/IConfig.d.ts +1 -0
- package/build/dialects/DialectMariaDB.js +3 -1
- package/build/dialects/DialectMySQL.js +4 -2
- package/package.json +17 -17
- package/tsconfig.json +2 -2
package/README.md
CHANGED
|
@@ -137,7 +137,9 @@ Options:
|
|
|
137
137
|
-f, --dialect-options-file Dialect native options passed as json file path.
|
|
138
138
|
[string]
|
|
139
139
|
-R, --no-strict Disable strict typescript class declaration.
|
|
140
|
-
[boolean]
|
|
140
|
+
[boolean]
|
|
141
|
+
-V, --no-views Disable view generation. Available for: MySQL and MariaDB.
|
|
142
|
+
[boolean]
|
|
141
143
|
```
|
|
142
144
|
|
|
143
145
|
Local usage example:
|
package/build/bin/cli.js
CHANGED
|
@@ -15,7 +15,7 @@ process.on('unhandledRejection', (reason, promise) => {
|
|
|
15
15
|
const cli = async () => {
|
|
16
16
|
let usage = `Usage: stg -D <dialect> -d [database] -u [username] -x [password] `;
|
|
17
17
|
usage += `-h [host] -p [port] -o [out-dir] -s [schema] -a [associations-file]`;
|
|
18
|
-
usage += `-t [tables] -T [skip-tables] -i [indices] -C [case] -S [storage] -L [lint-file] `;
|
|
18
|
+
usage += `-t [tables] -T [skip-tables] -V [no-views] -i [indices] -C [case] -S [storage] -L [lint-file] `;
|
|
19
19
|
usage += `-l [ssl] -r [protocol] -n [dialect-options] -c [clean] -g [logs]`;
|
|
20
20
|
const { argv } = yargs_1.default
|
|
21
21
|
.usage(usage)
|
|
@@ -134,6 +134,10 @@ const cli = async () => {
|
|
|
134
134
|
alias: utils_1.aliasesMap.DISABLE_STRICT,
|
|
135
135
|
boolean: true,
|
|
136
136
|
describe: `Disable strict typescript class declaration.`,
|
|
137
|
+
}).option('V', {
|
|
138
|
+
alias: utils_1.aliasesMap.DISABLE_VIEWS,
|
|
139
|
+
boolean: true,
|
|
140
|
+
describe: `Disable views generation. Available for: MySQL and MariaDB.`,
|
|
137
141
|
});
|
|
138
142
|
(0, utils_1.validateArgs)(argv);
|
|
139
143
|
const config = (0, utils_1.buildConfig)(argv);
|
package/build/bin/utils.d.ts
CHANGED
package/build/bin/utils.js
CHANGED
|
@@ -34,6 +34,7 @@ exports.aliasesMap = {
|
|
|
34
34
|
DIALECT_OPTIONS: 'dialect-options',
|
|
35
35
|
DIALECT_OPTIONS_FILE: 'dialect-options-file',
|
|
36
36
|
DISABLE_STRICT: 'no-strict',
|
|
37
|
+
DISABLE_VIEWS: 'no-views',
|
|
37
38
|
};
|
|
38
39
|
/**
|
|
39
40
|
* Diplay error message and exit
|
|
@@ -151,6 +152,7 @@ const buildConfig = (argv) => {
|
|
|
151
152
|
timestamps: !!argv[exports.aliasesMap.TIMESTAMPS],
|
|
152
153
|
...argv[exports.aliasesMap.CASE] && { case: (0, exports.parseCase)(argv[exports.aliasesMap.CASE]) },
|
|
153
154
|
...argv[exports.aliasesMap.ASSOCIATIONS_FILE] && { associationsFile: argv[exports.aliasesMap.ASSOCIATIONS_FILE] },
|
|
155
|
+
noViews: !!argv[exports.aliasesMap.DISABLE_VIEWS],
|
|
154
156
|
},
|
|
155
157
|
output: {
|
|
156
158
|
outDir: argv[exports.aliasesMap.OUTPUT_DIR] ?
|
package/build/builders/utils.js
CHANGED
|
@@ -43,7 +43,7 @@ const generateNamedImports = (importsSpecifier, moduleSpecifier) => {
|
|
|
43
43
|
/* decorators */ undefined,
|
|
44
44
|
/* modifiers */ undefined, ts.createImportClause(undefined, ts.createNamedImports([
|
|
45
45
|
...importsSpecifier
|
|
46
|
-
.map(is => ts.createImportSpecifier(undefined, ts.createIdentifier(is)))
|
|
46
|
+
.map(is => ts.createImportSpecifier(false, undefined, ts.createIdentifier(is)))
|
|
47
47
|
])), ts.createLiteral(moduleSpecifier));
|
|
48
48
|
};
|
|
49
49
|
exports.generateNamedImports = generateNamedImports;
|
|
@@ -124,12 +124,14 @@ class DialectMariaDB extends Dialect_1.Dialect {
|
|
|
124
124
|
* @returns {Promise<string[]>}
|
|
125
125
|
*/
|
|
126
126
|
async fetchTables(connection, config) {
|
|
127
|
+
var _a;
|
|
127
128
|
const query = `
|
|
128
129
|
SELECT
|
|
129
130
|
table_name AS table_name,
|
|
130
131
|
table_comment AS table_comment
|
|
131
132
|
FROM information_schema.tables
|
|
132
|
-
WHERE table_schema = '${config.connection.database}'
|
|
133
|
+
WHERE table_schema = '${config.connection.database}'
|
|
134
|
+
${((_a = config.metadata) === null || _a === void 0 ? void 0 : _a.noViews) ? 'AND table_type <> \'VIEW\'' : ''};
|
|
133
135
|
`;
|
|
134
136
|
const tables = (await connection.query(query, {
|
|
135
137
|
type: sequelize_1.QueryTypes.SELECT,
|
|
@@ -139,12 +139,14 @@ class DialectMySQL extends Dialect_1.Dialect {
|
|
|
139
139
|
* @returns {Promise<ITable[]>}
|
|
140
140
|
*/
|
|
141
141
|
async fetchTables(connection, config) {
|
|
142
|
+
var _a;
|
|
142
143
|
const query = `
|
|
143
144
|
SELECT
|
|
144
145
|
table_name AS table_name,
|
|
145
146
|
table_comment AS table_comment
|
|
146
147
|
FROM information_schema.tables
|
|
147
|
-
WHERE table_schema = '${config.connection.database}'
|
|
148
|
+
WHERE table_schema = '${config.connection.database}'
|
|
149
|
+
${((_a = config.metadata) === null || _a === void 0 ? void 0 : _a.noViews) ? 'AND table_type <> \'VIEW\'' : ''};
|
|
148
150
|
`;
|
|
149
151
|
const tables = (await connection.query(query, {
|
|
150
152
|
type: sequelize_1.QueryTypes.SELECT,
|
|
@@ -188,7 +190,7 @@ class DialectMySQL extends Dialect_1.Dialect {
|
|
|
188
190
|
FROM information_schema.columns c
|
|
189
191
|
INNER JOIN information_schema.tables t
|
|
190
192
|
ON c.TABLE_SCHEMA = t.TABLE_SCHEMA AND c.TABLE_NAME = t.TABLE_NAME
|
|
191
|
-
WHERE c.TABLE_SCHEMA='${config.connection.database}' AND c.TABLE_NAME = '${table}'
|
|
193
|
+
WHERE c.TABLE_SCHEMA = '${config.connection.database}' AND c.TABLE_NAME = '${table}'
|
|
192
194
|
ORDER BY c.ORDINAL_POSITION;
|
|
193
195
|
`;
|
|
194
196
|
const columns = await connection.query(query, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sequelize-typescript-generator",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.5.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
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -35,33 +35,33 @@
|
|
|
35
35
|
"homepage": "https://github.com/spinlud/sequelize-typescript-generator.git#readme",
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/bluebird": "^3.5.36",
|
|
38
|
-
"@types/jest": "^27.0
|
|
39
|
-
"@types/node": "^
|
|
38
|
+
"@types/jest": "^27.4.0",
|
|
39
|
+
"@types/node": "^17.0.12",
|
|
40
40
|
"@types/pluralize": "0.0.29",
|
|
41
|
-
"@types/validator": "^13.
|
|
42
|
-
"@types/yargs": "^17.0.
|
|
43
|
-
"jest": "^27.
|
|
44
|
-
"mariadb": "^2.5.
|
|
45
|
-
"mysql2": "^2.3.
|
|
41
|
+
"@types/validator": "^13.7.1",
|
|
42
|
+
"@types/yargs": "^17.0.8",
|
|
43
|
+
"jest": "^27.4.7",
|
|
44
|
+
"mariadb": "^2.5.5",
|
|
45
|
+
"mysql2": "^2.3.3",
|
|
46
46
|
"pg": "^8.7.1",
|
|
47
47
|
"pg-hstore": "^2.3.4",
|
|
48
48
|
"reflect-metadata": "^0.1.13",
|
|
49
49
|
"sqlite3": "^4.2.0",
|
|
50
|
-
"tedious": "^
|
|
51
|
-
"ts-jest": "^27.
|
|
50
|
+
"tedious": "^14.1.0",
|
|
51
|
+
"ts-jest": "^27.1.3",
|
|
52
52
|
"ts-node-dev": "^1.1.8",
|
|
53
|
-
"typescript": "^4.
|
|
53
|
+
"typescript": "^4.5.5",
|
|
54
54
|
"wkx": "^0.5.0"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@types/eslint": "^
|
|
58
|
-
"@typescript-eslint/parser": "^5.1
|
|
57
|
+
"@types/eslint": "^8.4.1",
|
|
58
|
+
"@typescript-eslint/parser": "^5.10.1",
|
|
59
59
|
"change-case": "^4.1.2",
|
|
60
|
-
"eslint": "^8.0
|
|
60
|
+
"eslint": "^8.7.0",
|
|
61
61
|
"pluralize": "^8.0.0",
|
|
62
|
-
"sequelize": "^6.
|
|
63
|
-
"sequelize-typescript": "^2.1.
|
|
64
|
-
"yargs": "^17.
|
|
62
|
+
"sequelize": "^6.14.1",
|
|
63
|
+
"sequelize-typescript": "^2.1.2",
|
|
64
|
+
"yargs": "^17.3.1"
|
|
65
65
|
},
|
|
66
66
|
"keywords": [
|
|
67
67
|
"sequelize",
|
package/tsconfig.json
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// "removeComments": true, /* Do not emit comments to output. */
|
|
20
20
|
// "noEmit": true, /* Do not emit outputs. */
|
|
21
21
|
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
22
|
-
|
|
22
|
+
"downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
23
23
|
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
24
24
|
|
|
25
25
|
/* Strict Type-Checking Options */
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
62
62
|
|
|
63
63
|
/* Advanced Options */
|
|
64
|
-
"forceConsistentCasingInFileNames": false /* Disallow inconsistently-cased references to the same file. */
|
|
64
|
+
"forceConsistentCasingInFileNames": false, /* Disallow inconsistently-cased references to the same file. */
|
|
65
65
|
},
|
|
66
66
|
"exclude": [
|
|
67
67
|
"src/tests",
|