fastypest 1.3.9 → 1.4.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/.yarnrc.yml +1 -1
- package/CHANGELOG.md +45 -36
- package/LICENSE +674 -674
- package/README.md +42 -42
- package/dist/core/config.d.ts +2 -0
- package/dist/core/config.js +8 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/fastypest.d.ts +16 -11
- package/dist/core/fastypest.js +133 -45
- package/dist/core/fastypest.js.map +1 -1
- package/dist/core/sql-script/queries/cockroachdb.json +5 -2
- package/dist/core/sql-script/queries/index.d.ts +12 -0
- package/dist/core/sql-script/queries/mysql.query.json +4 -1
- package/dist/core/sql-script/queries/postgres.query.json +7 -4
- package/dist/core/sql-script/sql-script.d.ts +6 -5
- package/dist/core/sql-script/sql-script.js +7 -4
- package/dist/core/sql-script/sql-script.js.map +1 -1
- package/dist/core/types.d.ts +28 -0
- package/dist/core/types.js +3 -0
- package/dist/core/types.js.map +1 -0
- package/eslint.config.mjs +29 -28
- package/package.json +81 -81
- package/.pnp.loader.mjs +0 -2110
- package/.yarn/releases/yarn-4.2.2.cjs +0 -894
- package/.yarn/sdks/eslint/bin/eslint.js +0 -20
- package/.yarn/sdks/eslint/lib/api.js +0 -20
- package/.yarn/sdks/eslint/lib/unsupported-api.js +0 -20
- package/.yarn/sdks/eslint/package.json +0 -14
- package/.yarn/sdks/integrations.yml +0 -5
- package/.yarn/sdks/typescript/bin/tsc +0 -20
- package/.yarn/sdks/typescript/bin/tsserver +0 -20
- package/.yarn/sdks/typescript/lib/tsc.js +0 -20
- package/.yarn/sdks/typescript/lib/tsserver.js +0 -232
- package/.yarn/sdks/typescript/lib/tsserverlibrary.js +0 -232
- package/.yarn/sdks/typescript/lib/typescript.js +0 -20
- package/.yarn/sdks/typescript/package.json +0 -10
package/README.md
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
<h1 align="center">FASTYPEST</h1>
|
|
2
|
-
<p align="center">
|
|
3
|
-
<a href="https://www.npmjs.com/fastypest" target="_blank"><img alt="GitHub package.json version" src="https://img.shields.io/github/package-json/v/juanjoGonDev/fastypest?logo=github&logoColor=fff&label=GitHub+package"></a>
|
|
4
|
-
<a href="https://www.npmjs.com/fastypest" target="_blank"><img alt="npm" src="https://img.shields.io/npm/v/fastypest?logo=npm&logoColor=fff&label=NPM+package"></a>
|
|
5
|
-
<a href="https://www.npmjs.com/fastypest" target="_blank"><img alt="npm peer dependency version" src="https://img.shields.io/npm/dependency-version/fastypest/peer/typeorm"></a>
|
|
6
|
-
<a href="https://www.npmjs.com/fastypest" target="_blank"><img alt="Node version" src="https://img.shields.io/node/v/fastypest"></a>
|
|
7
|
-
<a href="https://www.npmjs.com/fastypest" target="_blank"><img src="https://img.shields.io/npm/l/fastypest" alt="Package License" /></a>
|
|
8
|
-
<a href="https://www.npmjs.com/fastypest" target="_blank"><img src="https://img.shields.io/npm/dm/fastypest" alt="NPM Downloads" /></a>
|
|
9
|
-
</p>
|
|
10
|
-
|
|
11
|
-
With this library, you can run your test suites without having to stop and restore the database in between them.
|
|
12
|
-
|
|
13
|
-
Currently compatible with:
|
|
14
|
-
|
|
15
|
-
- <a href="https://www.npmjs.com/fastypest"><img alt="MySQL >= v5.7 supported" src="https://img.shields.io/badge/MySQL-%3E%3D5.7-informational"></a>
|
|
16
|
-
- <a href="https://www.npmjs.com/fastypest"><img alt="MariaDB >= v10.0 supported" src="https://img.shields.io/badge/MariaDB-%3E%3D10.0-yellowgreen"></a>
|
|
17
|
-
- <a href="https://www.npmjs.com/fastypest"><img alt="Postgres >= v9.0 supported" src="https://img.shields.io/badge/Postgres-%3E%3D9.0-green"></a>
|
|
18
|
-
- <a href="https://www.npmjs.com/fastypest"><img alt="cockroachDB >= v22.2.0 supported" src="https://img.shields.io/badge/CockroachDB-%3E%3D22.2.0-blue"></a>
|
|
19
|
-
|
|
20
|
-
Install with npm
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
npm i -D fastypest
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
To use it, you must have inserted all the seeds beforehand, and before starting the tests, you must initialize it by indicating the typeorm connection configuration. You must execute restoreData after each test, so that the database is returned to its initial state.
|
|
27
|
-
|
|
28
|
-
Example of use with jest
|
|
29
|
-
|
|
30
|
-
> **Note**
|
|
31
|
-
> (I recommend using it in a [setupFilesAfterEnv](https://jestjs.io/es-ES/docs/configuration#setupfilesafterenv-array) file):
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
beforeAll(async () => {
|
|
35
|
-
fastypest = new Fastypest(connection);
|
|
36
|
-
await fastypest.init();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
afterEach(async () => {
|
|
40
|
-
await fastypest.restoreData();
|
|
41
|
-
});
|
|
42
|
-
```
|
|
1
|
+
<h1 align="center">FASTYPEST</h1>
|
|
2
|
+
<p align="center">
|
|
3
|
+
<a href="https://www.npmjs.com/fastypest" target="_blank"><img alt="GitHub package.json version" src="https://img.shields.io/github/package-json/v/juanjoGonDev/fastypest?logo=github&logoColor=fff&label=GitHub+package"></a>
|
|
4
|
+
<a href="https://www.npmjs.com/fastypest" target="_blank"><img alt="npm" src="https://img.shields.io/npm/v/fastypest?logo=npm&logoColor=fff&label=NPM+package"></a>
|
|
5
|
+
<a href="https://www.npmjs.com/fastypest" target="_blank"><img alt="npm peer dependency version" src="https://img.shields.io/npm/dependency-version/fastypest/peer/typeorm"></a>
|
|
6
|
+
<a href="https://www.npmjs.com/fastypest" target="_blank"><img alt="Node version" src="https://img.shields.io/node/v/fastypest"></a>
|
|
7
|
+
<a href="https://www.npmjs.com/fastypest" target="_blank"><img src="https://img.shields.io/npm/l/fastypest" alt="Package License" /></a>
|
|
8
|
+
<a href="https://www.npmjs.com/fastypest" target="_blank"><img src="https://img.shields.io/npm/dm/fastypest" alt="NPM Downloads" /></a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
With this library, you can run your test suites without having to stop and restore the database in between them.
|
|
12
|
+
|
|
13
|
+
Currently compatible with:
|
|
14
|
+
|
|
15
|
+
- <a href="https://www.npmjs.com/fastypest"><img alt="MySQL >= v5.7 supported" src="https://img.shields.io/badge/MySQL-%3E%3D5.7-informational"></a>
|
|
16
|
+
- <a href="https://www.npmjs.com/fastypest"><img alt="MariaDB >= v10.0 supported" src="https://img.shields.io/badge/MariaDB-%3E%3D10.0-yellowgreen"></a>
|
|
17
|
+
- <a href="https://www.npmjs.com/fastypest"><img alt="Postgres >= v9.0 supported" src="https://img.shields.io/badge/Postgres-%3E%3D9.0-green"></a>
|
|
18
|
+
- <a href="https://www.npmjs.com/fastypest"><img alt="cockroachDB >= v22.2.0 supported" src="https://img.shields.io/badge/CockroachDB-%3E%3D22.2.0-blue"></a>
|
|
19
|
+
|
|
20
|
+
Install with npm
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
npm i -D fastypest
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
To use it, you must have inserted all the seeds beforehand, and before starting the tests, you must initialize it by indicating the typeorm connection configuration. You must execute restoreData after each test, so that the database is returned to its initial state.
|
|
27
|
+
|
|
28
|
+
Example of use with jest
|
|
29
|
+
|
|
30
|
+
> **Note**
|
|
31
|
+
> (I recommend using it in a [setupFilesAfterEnv](https://jestjs.io/es-ES/docs/configuration#setupfilesafterenv-array) file):
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
beforeAll(async () => {
|
|
35
|
+
fastypest = new Fastypest(connection);
|
|
36
|
+
await fastypest.init();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
afterEach(async () => {
|
|
40
|
+
await fastypest.restoreData();
|
|
41
|
+
});
|
|
42
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":";;;AAEa,QAAA,mBAAmB,GAAoC;IAClE,QAAQ,EAAE,CAAC;IACX,WAAW,EAAE,CAAC;CACf,CAAC"}
|
package/dist/core/fastypest.d.ts
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import { Connection, DataSource, EntityManager } from "typeorm";
|
|
2
2
|
import { SQLScript } from "./sql-script";
|
|
3
|
-
|
|
4
|
-
foreignKey: {
|
|
5
|
-
disable: () => Promise<string | object>;
|
|
6
|
-
enable: () => Promise<string | object>;
|
|
7
|
-
};
|
|
8
|
-
dependencyTree: () => Promise<Set<string> | undefined>;
|
|
9
|
-
}
|
|
3
|
+
import { Manager } from "./types";
|
|
10
4
|
export declare class Fastypest extends SQLScript {
|
|
11
5
|
private manager;
|
|
12
6
|
private tables;
|
|
7
|
+
private tablesWithAutoIncrement;
|
|
8
|
+
private restoreInOder;
|
|
13
9
|
constructor(connection: DataSource | Connection);
|
|
14
10
|
init(): Promise<void>;
|
|
15
|
-
|
|
11
|
+
private createTempTable;
|
|
12
|
+
private detectTablesWithAutoIncrement;
|
|
13
|
+
private processTable;
|
|
14
|
+
private getColumnsWithAutoIncrement;
|
|
15
|
+
private processColumn;
|
|
16
|
+
private getMaxColumnIndex;
|
|
17
|
+
private getSequenceName;
|
|
18
|
+
private updateTablesWithAutoIncrement;
|
|
16
19
|
restoreData(): Promise<void>;
|
|
20
|
+
protected restoreManager(em: EntityManager): Promise<Manager>;
|
|
21
|
+
private calculateDependencyTables;
|
|
22
|
+
private detectTables;
|
|
17
23
|
private restoreOrder;
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
private recreateData;
|
|
25
|
+
private resetAutoIncrementColumns;
|
|
20
26
|
}
|
|
21
|
-
export {};
|
package/dist/core/fastypest.js
CHANGED
|
@@ -10,60 +10,104 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Fastypest = void 0;
|
|
13
|
+
const config_1 = require("./config");
|
|
13
14
|
const sql_script_1 = require("./sql-script");
|
|
14
15
|
class Fastypest extends sql_script_1.SQLScript {
|
|
15
16
|
constructor(connection) {
|
|
16
17
|
super(connection.options.type);
|
|
17
18
|
this.tables = new Set();
|
|
19
|
+
this.tablesWithAutoIncrement = new Map();
|
|
20
|
+
this.restoreInOder = false;
|
|
18
21
|
this.manager = connection.manager;
|
|
19
22
|
}
|
|
20
23
|
init() {
|
|
21
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
25
|
yield this.manager.transaction((em) => __awaiter(this, void 0, void 0, function* () {
|
|
23
26
|
yield this.detectTables(em);
|
|
24
|
-
yield
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
yield this.calculateDependencyTables(em);
|
|
28
|
+
const tables = [...this.tables];
|
|
29
|
+
yield Promise.all([
|
|
30
|
+
this.createTempTable(em, tables),
|
|
31
|
+
this.detectTablesWithAutoIncrement(em, tables),
|
|
32
|
+
]);
|
|
27
33
|
}));
|
|
28
34
|
});
|
|
29
35
|
}
|
|
30
|
-
|
|
36
|
+
createTempTable(em, tables) {
|
|
31
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
|
|
33
|
-
this.
|
|
38
|
+
yield Promise.all(tables.map((tableName) => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
yield this.execQuery(em, "createTempTable", { tableName });
|
|
40
|
+
})));
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
detectTablesWithAutoIncrement(em, tables) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
for (const tableName of tables) {
|
|
46
|
+
yield this.processTable(em, tableName);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
processTable(em, tableName) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const columns = yield this.getColumnsWithAutoIncrement(em, tableName);
|
|
53
|
+
if (!columns)
|
|
54
|
+
return;
|
|
55
|
+
for (const column of columns) {
|
|
56
|
+
yield this.processColumn(em, tableName, column);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
getColumnsWithAutoIncrement(em, tableName) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
const columns = yield this.execQuery(em, "getColumnsWithAutoIncrement", { tableName });
|
|
63
|
+
return Array.isArray(columns) ? columns : null;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
processColumn(em, tableName, column) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
var _a;
|
|
69
|
+
const stat = yield this.getMaxColumnIndex(em, tableName, column.column_name);
|
|
70
|
+
const sequenceName = this.getSequenceName(column.column_default);
|
|
71
|
+
if (!sequenceName)
|
|
72
|
+
return;
|
|
73
|
+
const index = Number(stat === null || stat === void 0 ? void 0 : stat.maxindex) || 0;
|
|
74
|
+
this.updateTablesWithAutoIncrement(tableName, {
|
|
75
|
+
column: column.column_name,
|
|
76
|
+
sequenceName,
|
|
77
|
+
index: String(index + ((_a = config_1.INDEX_OFFSET_CONFIG[this.getType()]) !== null && _a !== void 0 ? _a : 0)),
|
|
34
78
|
});
|
|
35
79
|
});
|
|
36
80
|
}
|
|
81
|
+
getMaxColumnIndex(em, tableName, columnName) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
const [stat] = yield this.execQuery(em, "getMaxColumnIndex", {
|
|
84
|
+
tableName,
|
|
85
|
+
column_name: columnName,
|
|
86
|
+
});
|
|
87
|
+
return stat || null;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
getSequenceName(columnDefault) {
|
|
91
|
+
var _a;
|
|
92
|
+
return ((_a = columnDefault.match(/'([^']+)'/)) === null || _a === void 0 ? void 0 : _a[1]) || null;
|
|
93
|
+
}
|
|
94
|
+
updateTablesWithAutoIncrement(tableName, data) {
|
|
95
|
+
var _a;
|
|
96
|
+
if (!this.tablesWithAutoIncrement.has(tableName)) {
|
|
97
|
+
this.tablesWithAutoIncrement.set(tableName, []);
|
|
98
|
+
}
|
|
99
|
+
(_a = this.tablesWithAutoIncrement.get(tableName)) === null || _a === void 0 ? void 0 : _a.push(data);
|
|
100
|
+
}
|
|
37
101
|
restoreData() {
|
|
38
102
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
103
|
yield this.manager.transaction((em) => __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
const
|
|
41
|
-
yield
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
yield this.restoreOrder(em, tables, dependencyTree ? "sorted" : "random");
|
|
45
|
-
yield restoreManager.foreignKey.enable();
|
|
104
|
+
const { foreignKey, restoreOrder } = yield this.restoreManager(em);
|
|
105
|
+
yield foreignKey.disable();
|
|
106
|
+
yield restoreOrder();
|
|
107
|
+
yield foreignKey.enable();
|
|
46
108
|
}));
|
|
47
109
|
});
|
|
48
110
|
}
|
|
49
|
-
restoreOrder(em_1, tables_1) {
|
|
50
|
-
return __awaiter(this, arguments, void 0, function* (em, tables, type = "random") {
|
|
51
|
-
switch (type) {
|
|
52
|
-
case "sorted":
|
|
53
|
-
for (const tableName of tables) {
|
|
54
|
-
yield em.query(this.getQuery("truncateTable", { tableName }));
|
|
55
|
-
yield em.query(this.getQuery("restoreData", { tableName }));
|
|
56
|
-
}
|
|
57
|
-
break;
|
|
58
|
-
default:
|
|
59
|
-
yield Promise.all(tables.map((tableName) => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
yield em.query(this.getQuery("truncateTable", { tableName }));
|
|
61
|
-
yield em.query(this.getQuery("restoreData", { tableName }));
|
|
62
|
-
})));
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
111
|
restoreManager(em) {
|
|
68
112
|
return __awaiter(this, void 0, void 0, function* () {
|
|
69
113
|
if (this.tables.size === 0) {
|
|
@@ -71,29 +115,73 @@ class Fastypest extends sql_script_1.SQLScript {
|
|
|
71
115
|
}
|
|
72
116
|
const manager = {
|
|
73
117
|
foreignKey: {
|
|
74
|
-
disable: () => __awaiter(this, void 0, void 0, function* () { return Promise.resolve(
|
|
75
|
-
enable: () => __awaiter(this, void 0, void 0, function* () { return Promise.resolve(
|
|
118
|
+
disable: () => __awaiter(this, void 0, void 0, function* () { return Promise.resolve(); }),
|
|
119
|
+
enable: () => __awaiter(this, void 0, void 0, function* () { return Promise.resolve(); }),
|
|
76
120
|
},
|
|
77
|
-
|
|
121
|
+
restoreOrder: () => __awaiter(this, void 0, void 0, function* () { return Promise.resolve(); }),
|
|
78
122
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return new Set(dependencyTree.map((row) => row.table_name));
|
|
84
|
-
});
|
|
85
|
-
break;
|
|
86
|
-
case "mariadb":
|
|
87
|
-
case "mysql":
|
|
88
|
-
manager.foreignKey.disable = () => __awaiter(this, void 0, void 0, function* () { return em.query(this.getQuery("foreignKey.disable")); });
|
|
89
|
-
manager.foreignKey.enable = () => __awaiter(this, void 0, void 0, function* () { return em.query(this.getQuery("foreignKey.enable")); });
|
|
123
|
+
const typesWithForeignKey = ["postgres", "mariadb", "mysql"];
|
|
124
|
+
if (typesWithForeignKey.includes(this.getType())) {
|
|
125
|
+
manager.foreignKey.disable = () => __awaiter(this, void 0, void 0, function* () { return this.execQuery(em, "foreignKey.disable"); });
|
|
126
|
+
manager.foreignKey.enable = () => __awaiter(this, void 0, void 0, function* () { return this.execQuery(em, "foreignKey.enable"); });
|
|
90
127
|
}
|
|
128
|
+
manager.restoreOrder = () => this.restoreOrder(em);
|
|
91
129
|
return manager;
|
|
92
130
|
});
|
|
93
131
|
}
|
|
94
|
-
|
|
132
|
+
calculateDependencyTables(em) {
|
|
95
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
const dependencyTree = yield this.execQuery(em, "dependencyTree");
|
|
135
|
+
if (!dependencyTree.length) {
|
|
136
|
+
this.restoreInOder = false;
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const sortedTables = new Set(dependencyTree.map((row) => row.table_name));
|
|
96
140
|
this.tables.clear();
|
|
141
|
+
this.tables = sortedTables;
|
|
142
|
+
this.restoreInOder = true;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
detectTables(em) {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
const tables = yield this.execQuery(em, "getTables");
|
|
148
|
+
tables.forEach((row) => {
|
|
149
|
+
this.tables.add(row.name);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
restoreOrder(em) {
|
|
154
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
if (this.restoreInOder) {
|
|
156
|
+
for (const tableName of this.tables) {
|
|
157
|
+
yield this.recreateData(em, tableName);
|
|
158
|
+
}
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const tables = [...this.tables];
|
|
162
|
+
yield Promise.all(tables.map((tableName) => this.recreateData(em, tableName)));
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
recreateData(em, tableName) {
|
|
166
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
yield this.execQuery(em, "truncateTable", { tableName });
|
|
168
|
+
yield this.execQuery(em, "restoreData", { tableName });
|
|
169
|
+
yield this.resetAutoIncrementColumns(em, tableName);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
resetAutoIncrementColumns(em, tableName) {
|
|
173
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
174
|
+
const tables = this.tablesWithAutoIncrement.get(tableName);
|
|
175
|
+
if (!tables)
|
|
176
|
+
return;
|
|
177
|
+
for (const { column, sequenceName, index } of tables) {
|
|
178
|
+
yield this.execQuery(em, "resetAutoIncrementColumn", {
|
|
179
|
+
tableName,
|
|
180
|
+
column,
|
|
181
|
+
sequenceName,
|
|
182
|
+
index,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
97
185
|
});
|
|
98
186
|
}
|
|
99
187
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastypest.js","sourceRoot":"","sources":["../../src/core/fastypest.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,6CAAyC;AAUzC,MAAa,SAAU,SAAQ,sBAAS;
|
|
1
|
+
{"version":3,"file":"fastypest.js","sourceRoot":"","sources":["../../src/core/fastypest.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qCAA+C;AAC/C,6CAAyC;AAUzC,MAAa,SAAU,SAAQ,sBAAS;IAMtC,YAAY,UAAmC;QAC7C,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QALzB,WAAM,GAAgB,IAAI,GAAG,EAAE,CAAC;QAChC,4BAAuB,GAAmC,IAAI,GAAG,EAAE,CAAC;QACpE,kBAAa,GAAY,KAAK,CAAC;QAIrC,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;IACpC,CAAC;IAEY,IAAI;;YACf,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAO,EAAiB,EAAE,EAAE;gBACzD,MAAM,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;gBAC5B,MAAM,IAAI,CAAC,yBAAyB,CAAC,EAAE,CAAC,CAAC;gBACzC,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;gBAChC,MAAM,OAAO,CAAC,GAAG,CAAC;oBAChB,IAAI,CAAC,eAAe,CAAC,EAAE,EAAE,MAAM,CAAC;oBAChC,IAAI,CAAC,6BAA6B,CAAC,EAAE,EAAE,MAAM,CAAC;iBAC/C,CAAC,CAAC;YACL,CAAC,CAAA,CAAC,CAAC;QACL,CAAC;KAAA;IAEa,eAAe,CAC3B,EAAiB,EACjB,MAAgB;;YAEhB,MAAM,OAAO,CAAC,GAAG,CACf,MAAM,CAAC,GAAG,CAAC,CAAO,SAAS,EAAE,EAAE;gBAC7B,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE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,CACxB,EAAiB,EACjB,SAAiB;;YAEjB,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,eAAe,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;YACzD,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,aAAa,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;YACvD,MAAM,IAAI,CAAC,yBAAyB,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;QACtD,CAAC;KAAA;IAEa,yBAAyB,CACrC,EAAiB,EACjB,SAAiB;;YAEjB,MAAM,MAAM,GAAG,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC3D,IAAI,CAAC,MAAM;gBAAE,OAAO;YAEpB,KAAK,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,MAAM,EAAE,CAAC;gBACrD,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,0BAA0B,EAAE;oBACnD,SAAS;oBACT,MAAM;oBACN,YAAY;oBACZ,KAAK;iBACN,CAAC,CAAC;YACL,CAAC;QACH,CAAC;KAAA;CACF;AAvND,8BAuNC"}
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
"getTables": "SELECT table_name AS name FROM information_schema.tables WHERE table_catalog = CURRENT_DATABASE() AND table_schema = 'public' AND table_type = 'BASE TABLE'",
|
|
8
8
|
"createTempTable": "SET experimental_enable_temp_tables=on; CREATE TEMPORARY TABLE \"{{tableName}}_temp\" AS SELECT * FROM \"{{tableName}}\"",
|
|
9
9
|
"dropTempTable": "DROP TABLE IF EXISTS \"{{tableName}}_temp\"",
|
|
10
|
-
"restoreData": "INSERT INTO \"{{tableName}}\" SELECT * FROM \"{{tableName}}_temp\";
|
|
11
|
-
"truncateTable": "TRUNCATE TABLE \"{{tableName}}\" CASCADE;
|
|
10
|
+
"restoreData": "INSERT INTO \"{{tableName}}\" SELECT * FROM \"{{tableName}}_temp\";",
|
|
11
|
+
"truncateTable": "TRUNCATE TABLE \"{{tableName}}\" CASCADE;",
|
|
12
|
+
"getColumnsWithAutoIncrement": "SELECT column_name, column_default FROM information_schema.columns WHERE table_schema = 'public' AND column_default LIKE 'nextval%' AND table_name = '{{tableName}}'",
|
|
13
|
+
"resetAutoIncrementColumn": "SELECT setval('{{sequenceName}}',{{index}});",
|
|
14
|
+
"getMaxColumnIndex": "SELECT MAX({{column_name}}) AS maxindex FROM \"{{tableName}}\""
|
|
12
15
|
}
|
|
@@ -10,6 +10,9 @@ export declare const DB_QUERIES: {
|
|
|
10
10
|
dropTempTable: string;
|
|
11
11
|
restoreData: string;
|
|
12
12
|
truncateTable: string;
|
|
13
|
+
getColumnsWithAutoIncrement: string;
|
|
14
|
+
resetAutoIncrementColumn: string;
|
|
15
|
+
getMaxColumnIndex: string;
|
|
13
16
|
};
|
|
14
17
|
mariadb: {
|
|
15
18
|
dependencyTree: string;
|
|
@@ -22,6 +25,9 @@ export declare const DB_QUERIES: {
|
|
|
22
25
|
dropTempTable: string;
|
|
23
26
|
restoreData: string;
|
|
24
27
|
truncateTable: string;
|
|
28
|
+
getColumnsWithAutoIncrement: string;
|
|
29
|
+
resetAutoIncrementColumn: string;
|
|
30
|
+
getMaxColumnIndex: string;
|
|
25
31
|
};
|
|
26
32
|
postgres: {
|
|
27
33
|
dependencyTree: string;
|
|
@@ -34,6 +40,9 @@ export declare const DB_QUERIES: {
|
|
|
34
40
|
dropTempTable: string;
|
|
35
41
|
restoreData: string;
|
|
36
42
|
truncateTable: string;
|
|
43
|
+
getColumnsWithAutoIncrement: string;
|
|
44
|
+
resetAutoIncrementColumn: string;
|
|
45
|
+
getMaxColumnIndex: string;
|
|
37
46
|
};
|
|
38
47
|
cockroachdb: {
|
|
39
48
|
dependencyTree: string;
|
|
@@ -46,6 +55,9 @@ export declare const DB_QUERIES: {
|
|
|
46
55
|
dropTempTable: string;
|
|
47
56
|
restoreData: string;
|
|
48
57
|
truncateTable: string;
|
|
58
|
+
getColumnsWithAutoIncrement: string;
|
|
59
|
+
resetAutoIncrementColumn: string;
|
|
60
|
+
getMaxColumnIndex: string;
|
|
49
61
|
};
|
|
50
62
|
};
|
|
51
63
|
export type AllowedDataBases = keyof typeof DB_QUERIES;
|
|
@@ -8,5 +8,8 @@
|
|
|
8
8
|
"createTempTable": "CREATE TEMPORARY TABLE {{tableName}}_temp AS SELECT * FROM {{tableName}}",
|
|
9
9
|
"dropTempTable": "DROP TEMPORARY TABLE {{tableName}}_temp",
|
|
10
10
|
"restoreData": "INSERT INTO {{tableName}} SELECT * FROM {{tableName}}_temp",
|
|
11
|
-
"truncateTable": "TRUNCATE TABLE {{tableName}}"
|
|
11
|
+
"truncateTable": "TRUNCATE TABLE {{tableName}}",
|
|
12
|
+
"getColumnsWithAutoIncrement": "-- NOT USED",
|
|
13
|
+
"resetAutoIncrementColumn": "-- NOT USED",
|
|
14
|
+
"getMaxColumnIndex": "-- NOT USED"
|
|
12
15
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencyTree": "-- NOT USED",
|
|
3
3
|
"foreignKey": {
|
|
4
|
-
"disable": "
|
|
5
|
-
"enable": "
|
|
4
|
+
"disable": "DO $$ DECLARE table_name text; BEGIN FOR table_name IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP EXECUTE 'ALTER TABLE \"' || table_name || '\" DISABLE TRIGGER ALL;'; END LOOP; END $$;",
|
|
5
|
+
"enable": "DO $$ DECLARE table_name text; BEGIN FOR table_name IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP EXECUTE 'ALTER TABLE \"' || table_name || '\" ENABLE TRIGGER ALL;'; END LOOP; END $$;"
|
|
6
6
|
},
|
|
7
7
|
"getTables": "SELECT table_name AS name FROM information_schema.tables WHERE table_schema = CURRENT_SCHEMA() AND table_type = 'BASE TABLE'",
|
|
8
8
|
"createTempTable": "CREATE TEMPORARY TABLE \"{{tableName}}_temp\" AS SELECT * FROM \"{{tableName}}\"",
|
|
9
9
|
"dropTempTable": "DROP TABLE IF EXISTS \"{{tableName}}_temp\"",
|
|
10
|
-
"restoreData": "INSERT INTO \"{{tableName}}\" SELECT * FROM \"{{tableName}}_temp\";
|
|
11
|
-
"truncateTable": "TRUNCATE TABLE \"{{tableName}}\" RESTART IDENTITY CASCADE"
|
|
10
|
+
"restoreData": "INSERT INTO \"{{tableName}}\" SELECT * FROM \"{{tableName}}_temp\";",
|
|
11
|
+
"truncateTable": "TRUNCATE TABLE \"{{tableName}}\" RESTART IDENTITY CASCADE",
|
|
12
|
+
"getColumnsWithAutoIncrement": "SELECT column_name, column_default FROM information_schema.columns WHERE table_schema = 'public' AND column_default LIKE 'nextval%' AND table_name = '{{tableName}}'",
|
|
13
|
+
"resetAutoIncrementColumn": "ALTER SEQUENCE \"{{sequenceName}}\" RESTART WITH {{index}};",
|
|
14
|
+
"getMaxColumnIndex": "SELECT MAX({{column_name}}) AS maxindex FROM \"{{tableName}}\""
|
|
12
15
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { DataSourceOptions } from "typeorm";
|
|
1
|
+
import { DataSourceOptions, EntityManager } from "typeorm";
|
|
2
2
|
import { Queries } from "./queries";
|
|
3
3
|
import { QueryPath } from "./types";
|
|
4
4
|
type DBTypes = DataSourceOptions["type"];
|
|
5
5
|
export declare class SQLScript {
|
|
6
|
-
readonly type
|
|
7
|
-
queries
|
|
8
|
-
constructor(type: DBTypes);
|
|
9
|
-
|
|
6
|
+
private readonly type;
|
|
7
|
+
private queries;
|
|
8
|
+
protected constructor(type: DBTypes);
|
|
9
|
+
protected getType(): DBTypes;
|
|
10
|
+
protected execQuery<T = void>(em: EntityManager, queryPath: QueryPath<Queries>, values?: Record<string, string>): T extends void ? Promise<void> : Promise<T[]>;
|
|
10
11
|
}
|
|
11
12
|
export {};
|
|
@@ -10,15 +10,18 @@ class SQLScript {
|
|
|
10
10
|
}
|
|
11
11
|
this.queries = queries_1.DB_QUERIES[this.type];
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
getType() {
|
|
14
|
+
return this.type;
|
|
15
|
+
}
|
|
16
|
+
execQuery(em, queryPath, values) {
|
|
14
17
|
const queryObj = queryPath
|
|
15
18
|
.split(".")
|
|
16
19
|
.reduce((obj, key) => obj[key], this.queries);
|
|
17
|
-
let
|
|
20
|
+
let query = queryObj;
|
|
18
21
|
for (const key in values) {
|
|
19
|
-
|
|
22
|
+
query = query.replace(new RegExp(`{{\\s*${key}\\s*}}`, "g"), values[key]);
|
|
20
23
|
}
|
|
21
|
-
return
|
|
24
|
+
return em.query(query);
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
27
|
exports.SQLScript = SQLScript;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql-script.js","sourceRoot":"","sources":["../../../src/core/sql-script/sql-script.ts"],"names":[],"mappings":";;;AACA,uCAAkE;AAKlE,MAAa,SAAS;
|
|
1
|
+
{"version":3,"file":"sql-script.js","sourceRoot":"","sources":["../../../src/core/sql-script/sql-script.ts"],"names":[],"mappings":";;;AACA,uCAAkE;AAKlE,MAAa,SAAS;IAGpB,YAAuC,IAAa;QAAb,SAAI,GAAJ,IAAI,CAAS;QAClD,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,oBAAU,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CACb,kFAAkF,MAAM,CAAC,IAAI,CAC3F,oBAAU,CACX,EAAE,CACJ,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,OAAO,GAAG,oBAAU,CAAC,IAAI,CAAC,IAAwB,CAAC,CAAC;IAC3D,CAAC;IAES,OAAO;QACf,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAES,SAAS,CACjB,EAAiB,EACjB,SAA6B,EAC7B,MAA+B;QAE/B,MAAM,QAAQ,GAAG,SAAS;aACvB,KAAK,CAAC,GAAG,CAAC;aACV,MAAM,CAAC,CAAC,GAAQ,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAErD,IAAI,KAAK,GAAG,QAAQ,CAAC;QAErB,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YACzB,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,SAAS,GAAG,QAAQ,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5E,CAAC;QAED,OAAO,EAAE,CAAC,KAAK,CAAC,KAAK,CAAkD,CAAC;IAC1E,CAAC;CACF;AApCD,8BAoCC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DataSourceOptions } from "typeorm";
|
|
2
|
+
export type Table = {
|
|
3
|
+
name: string;
|
|
4
|
+
};
|
|
5
|
+
export type DependencyTreeQueryOut = {
|
|
6
|
+
table_name: string;
|
|
7
|
+
level: number;
|
|
8
|
+
};
|
|
9
|
+
export type ColumnsWithAutoIncrement = {
|
|
10
|
+
column_name: string;
|
|
11
|
+
column_default: string;
|
|
12
|
+
};
|
|
13
|
+
export type Manager = {
|
|
14
|
+
foreignKey: {
|
|
15
|
+
disable: () => Promise<void>;
|
|
16
|
+
enable: () => Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
restoreOrder: () => Promise<void>;
|
|
19
|
+
};
|
|
20
|
+
export type ColumnStat = {
|
|
21
|
+
maxindex: string | null;
|
|
22
|
+
};
|
|
23
|
+
export type DBType = DataSourceOptions["type"];
|
|
24
|
+
export type IncrementDetail = {
|
|
25
|
+
column: string;
|
|
26
|
+
sequenceName: string;
|
|
27
|
+
index: string;
|
|
28
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":""}
|
package/eslint.config.mjs
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import pluginJs from "@eslint/js";
|
|
2
|
-
import globals from "globals";
|
|
3
|
-
import tseslint from "typescript-eslint";
|
|
4
|
-
|
|
5
|
-
const common = {
|
|
6
|
-
files: ["src/**/*.ts"],
|
|
7
|
-
ignores: ["**/dist/*", "**/node_modules/*"],
|
|
8
|
-
rules: {
|
|
9
|
-
"no-case-declarations": "off",
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
...
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
...
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
import pluginJs from "@eslint/js";
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
import tseslint from "typescript-eslint";
|
|
4
|
+
|
|
5
|
+
const common = {
|
|
6
|
+
files: ["src/**/*.ts"],
|
|
7
|
+
ignores: ["**/dist/*", "**/node_modules/*"],
|
|
8
|
+
rules: {
|
|
9
|
+
"no-case-declarations": "off",
|
|
10
|
+
"@typescript-eslint/explicit-function-return-type": "error",
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const tsRecommended = tseslint.configs.recommended.map((config) => ({
|
|
15
|
+
...config,
|
|
16
|
+
...common,
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
export default [
|
|
20
|
+
{
|
|
21
|
+
languageOptions: { globals: globals.node },
|
|
22
|
+
...common,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
...pluginJs.configs.recommended,
|
|
26
|
+
...common,
|
|
27
|
+
},
|
|
28
|
+
...tsRecommended,
|
|
29
|
+
];
|