sequelize-typescript-generator 9.0.3 → 10.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/CHANGELOG.md +21 -0
- package/build/builders/ModelBuilder.js +4 -4
- package/build/builders/utils.js +17 -3
- package/build/dialects/Dialect.js +1 -1
- package/package.json +16 -15
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
### 10.0.0
|
|
6
|
+
#### Breaking changes:
|
|
7
|
+
* Typescript: `4.9.4` -> `5.0.2`
|
|
8
|
+
* MySQL driver: `mysql2@2.3.3` -> `mysql2@3.2.0`
|
|
9
|
+
|
|
10
|
+
#### Minor changes and bug fixes:
|
|
11
|
+
* Added change log file
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
### 9.0.3
|
|
16
|
+
#### Breaking changes:
|
|
17
|
+
* NA
|
|
18
|
+
#### Minor changes and bug fixes:
|
|
19
|
+
* NA
|
|
20
|
+
|
|
21
|
+
---
|
|
@@ -84,7 +84,7 @@ class ModelBuilder extends Builder_1.Builder {
|
|
|
84
84
|
...(col.indices && col.indices.length ?
|
|
85
85
|
col.indices.map(index => (0, utils_1.generateObjectLiteralDecorator)('Index', buildIndexDecoratorProps(index)))
|
|
86
86
|
: [])
|
|
87
|
-
],
|
|
87
|
+
], col.name, (col.autoIncrement || col.allowNull || col.defaultValue !== undefined) ?
|
|
88
88
|
ts.factory.createToken(ts.SyntaxKind.QuestionToken) : ts.factory.createToken(ts.SyntaxKind.ExclamationToken), ts.factory.createTypeReferenceNode((_a = dialect.mapDbTypeToJs(col.type)) !== null && _a !== void 0 ? _a : 'any', undefined), undefined);
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
@@ -103,7 +103,7 @@ class ModelBuilder extends Builder_1.Builder {
|
|
|
103
103
|
: [
|
|
104
104
|
(0, utils_1.generateArrowDecorator)(associationName, targetModels)
|
|
105
105
|
]),
|
|
106
|
-
],
|
|
106
|
+
], associationName.includes('Many') ?
|
|
107
107
|
pluralize_1.default.plural(targetModel) : pluralize_1.default.singular(targetModel), ts.factory.createToken(ts.SyntaxKind.QuestionToken), associationName.includes('Many') ?
|
|
108
108
|
ts.factory.createArrayTypeNode(ts.factory.createTypeReferenceNode(targetModel, undefined)) :
|
|
109
109
|
ts.factory.createTypeReferenceNode(targetModel, undefined), undefined);
|
|
@@ -148,7 +148,7 @@ class ModelBuilder extends Builder_1.Builder {
|
|
|
148
148
|
const attributesInterfaceName = `${name}Attributes`;
|
|
149
149
|
if (strict) {
|
|
150
150
|
generatedCode += '\n';
|
|
151
|
-
const attributesInterface = ts.factory.createInterfaceDeclaration(
|
|
151
|
+
const attributesInterface = ts.factory.createInterfaceDeclaration([
|
|
152
152
|
ts.factory.createToken(ts.SyntaxKind.ExportKeyword),
|
|
153
153
|
], ts.factory.createIdentifier(attributesInterfaceName), undefined, undefined, [
|
|
154
154
|
...(Object.values(columns).map(c => {
|
|
@@ -168,7 +168,7 @@ class ModelBuilder extends Builder_1.Builder {
|
|
|
168
168
|
timestamps: tableMetadata.timestamps,
|
|
169
169
|
...tableMetadata.comment && { comment: tableMetadata.comment },
|
|
170
170
|
}),
|
|
171
|
-
|
|
171
|
+
// Export modifier
|
|
172
172
|
ts.factory.createToken(ts.SyntaxKind.ExportKeyword),
|
|
173
173
|
], name, undefined, !strict ? [
|
|
174
174
|
ts.factory.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [
|
package/build/builders/utils.js
CHANGED
|
@@ -48,7 +48,7 @@ exports.nodeToString = nodeToString;
|
|
|
48
48
|
* @returns {string} Named import code
|
|
49
49
|
*/
|
|
50
50
|
const generateNamedImports = (importsSpecifier, moduleSpecifier) => {
|
|
51
|
-
return ts.factory.createImportDeclaration(undefined,
|
|
51
|
+
return ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([
|
|
52
52
|
...importsSpecifier
|
|
53
53
|
.map(is => ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier(is)))
|
|
54
54
|
])), ts.factory.createStringLiteral(moduleSpecifier));
|
|
@@ -60,7 +60,7 @@ exports.generateNamedImports = generateNamedImports;
|
|
|
60
60
|
* @returns {ts.ExportDeclaration}
|
|
61
61
|
*/
|
|
62
62
|
const generateIndexExport = (modelFileName) => {
|
|
63
|
-
return ts.factory.createExportDeclaration(undefined,
|
|
63
|
+
return ts.factory.createExportDeclaration(undefined, false, undefined, ts.factory.createStringLiteral(`./${modelFileName}`));
|
|
64
64
|
};
|
|
65
65
|
exports.generateIndexExport = generateIndexExport;
|
|
66
66
|
/**
|
|
@@ -115,7 +115,21 @@ exports.generateObjectLiteralDecorator = generateObjectLiteralDecorator;
|
|
|
115
115
|
const generateArrowDecorator = (decoratorIdentifier, arrowTargetIdentifiers, objectLiteralProps) => {
|
|
116
116
|
const argumentsArray = arrowTargetIdentifiers.map(t => ts.factory.createArrowFunction(undefined, undefined, [], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.factory.createIdentifier(t)));
|
|
117
117
|
objectLiteralProps && argumentsArray.push(ts.factory.createObjectLiteralExpression([
|
|
118
|
-
...Object.entries(objectLiteralProps).map(e =>
|
|
118
|
+
...Object.entries(objectLiteralProps).map(e => {
|
|
119
|
+
let initializer;
|
|
120
|
+
switch (typeof e[1]) {
|
|
121
|
+
case 'number':
|
|
122
|
+
initializer = ts.factory.createNumericLiteral(e[1]);
|
|
123
|
+
break;
|
|
124
|
+
case 'boolean':
|
|
125
|
+
initializer = e[1] ? ts.factory.createTrue() : ts.factory.createFalse();
|
|
126
|
+
break;
|
|
127
|
+
default:
|
|
128
|
+
initializer = ts.factory.createStringLiteral(e[1]);
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
return ts.factory.createPropertyAssignment(e[0], initializer);
|
|
132
|
+
}),
|
|
119
133
|
]));
|
|
120
134
|
return ts.factory.createDecorator(ts.factory.createCallExpression(ts.factory.createIdentifier(decoratorIdentifier), undefined, argumentsArray));
|
|
121
135
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sequelize-typescript-generator",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.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
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -35,36 +35,37 @@
|
|
|
35
35
|
"homepage": "https://github.com/spinlud/sequelize-typescript-generator.git#readme",
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/bluebird": "^3.5.38",
|
|
38
|
+
"@types/estree": "^1.0.0",
|
|
38
39
|
"@types/jest": "^28.1.8",
|
|
39
|
-
"@types/node": "^18.
|
|
40
|
+
"@types/node": "^18.15.3",
|
|
40
41
|
"@types/pluralize": "0.0.29",
|
|
41
|
-
"@types/validator": "^13.7.
|
|
42
|
-
"@types/yargs": "^17.0.
|
|
42
|
+
"@types/validator": "^13.7.14",
|
|
43
|
+
"@types/yargs": "^17.0.22",
|
|
43
44
|
"jest": "^28.1.3",
|
|
44
|
-
"mariadb": "^3.
|
|
45
|
-
"mysql2": "^2.
|
|
46
|
-
"pg": "^8.
|
|
45
|
+
"mariadb": "^3.1.1",
|
|
46
|
+
"mysql2": "^3.2.0",
|
|
47
|
+
"pg": "^8.10.0",
|
|
47
48
|
"pg-hstore": "^2.3.4",
|
|
48
49
|
"reflect-metadata": "^0.1.13",
|
|
49
|
-
"sqlite3": "^5.1.
|
|
50
|
+
"sqlite3": "^5.1.6",
|
|
50
51
|
"tedious": "^14.7.0",
|
|
51
52
|
"ts-jest": "^28.0.8",
|
|
52
53
|
"ts-node-dev": "^2.0.0",
|
|
53
54
|
"wkx": "^0.5.0"
|
|
54
55
|
},
|
|
55
56
|
"dependencies": {
|
|
56
|
-
"@types/eslint": "^8.
|
|
57
|
-
"@typescript-eslint/parser": "^5.
|
|
57
|
+
"@types/eslint": "^8.21.2",
|
|
58
|
+
"@typescript-eslint/parser": "^5.55.0",
|
|
58
59
|
"change-case": "^4.1.2",
|
|
59
|
-
"eslint": "^8.
|
|
60
|
+
"eslint": "^8.36.0",
|
|
60
61
|
"pluralize": "^8.0.0",
|
|
61
|
-
"sequelize": "^6.
|
|
62
|
+
"sequelize": "^6.29.3",
|
|
62
63
|
"sequelize-typescript": "^2.1.5",
|
|
63
|
-
"typescript": "^
|
|
64
|
-
"yargs": "^17.
|
|
64
|
+
"typescript": "^5.0.2",
|
|
65
|
+
"yargs": "^17.7.1"
|
|
65
66
|
},
|
|
66
67
|
"peerDependencies": {
|
|
67
|
-
"typescript": "^
|
|
68
|
+
"typescript": "^5.0.2"
|
|
68
69
|
},
|
|
69
70
|
"keywords": [
|
|
70
71
|
"sequelize",
|