tspace-mysql 1.9.0 → 1.9.1
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 +4357 -133
- package/dist/lib/config/index.d.ts +2 -2
- package/dist/lib/config/index.js +24 -16
- package/dist/lib/config/index.js.map +1 -1
- package/dist/lib/constants/index.d.ts +10 -1
- package/dist/lib/constants/index.js +11 -2
- package/dist/lib/constants/index.js.map +1 -1
- package/dist/lib/core/Abstracts/AbstractBuilder.d.ts +11 -7
- package/dist/lib/core/Abstracts/AbstractBuilder.js +11 -13
- package/dist/lib/core/Abstracts/AbstractBuilder.js.map +1 -1
- package/dist/lib/core/Abstracts/AbstractDB.d.ts +4 -1
- package/dist/lib/core/Abstracts/AbstractDB.js.map +1 -1
- package/dist/lib/core/Abstracts/AbstractView.js.map +1 -1
- package/dist/lib/core/Blueprint.d.ts +30 -10
- package/dist/lib/core/Blueprint.js +39 -14
- package/dist/lib/core/Blueprint.js.map +1 -1
- package/dist/lib/core/Builder.d.ts +263 -9
- package/dist/lib/core/Builder.js +610 -347
- package/dist/lib/core/Builder.js.map +1 -1
- package/dist/lib/core/Cache/DBCache.js +19 -20
- package/dist/lib/core/Cache/DBCache.js.map +1 -1
- package/dist/lib/core/Cache/MemoryCache.js +3 -3
- package/dist/lib/core/Cache/MemoryCache.js.map +1 -1
- package/dist/lib/core/Cache/RedisCache.js +27 -17
- package/dist/lib/core/Cache/RedisCache.js.map +1 -1
- package/dist/lib/core/Cache/index.js +5 -4
- package/dist/lib/core/Cache/index.js.map +1 -1
- package/dist/lib/core/Contracts/AlterTable.d.ts +152 -0
- package/dist/lib/core/Contracts/AlterTable.js +243 -0
- package/dist/lib/core/Contracts/AlterTable.js.map +1 -0
- package/dist/lib/core/Contracts/Audit.js +2 -5
- package/dist/lib/core/Contracts/Audit.js.map +1 -1
- package/dist/lib/core/DB.d.ts +101 -9
- package/dist/lib/core/DB.js +168 -29
- package/dist/lib/core/DB.js.map +1 -1
- package/dist/lib/core/Decorator.d.ts +144 -16
- package/dist/lib/core/Decorator.js +156 -14
- package/dist/lib/core/Decorator.js.map +1 -1
- package/dist/lib/core/Driver/index.d.ts +43 -9
- package/dist/lib/core/Driver/index.js +9 -7
- package/dist/lib/core/Driver/index.js.map +1 -1
- package/dist/lib/core/Driver/mariadb/MariadbDriver.js +74 -27
- package/dist/lib/core/Driver/mariadb/MariadbDriver.js.map +1 -1
- package/dist/lib/core/Driver/mariadb/MariadbQueryBuilder.d.ts +45 -9
- package/dist/lib/core/Driver/mariadb/MariadbQueryBuilder.js +165 -21
- package/dist/lib/core/Driver/mariadb/MariadbQueryBuilder.js.map +1 -1
- package/dist/lib/core/Driver/mongodb/MongodbDriver.d.ts +24 -0
- package/dist/lib/core/Driver/mongodb/MongodbDriver.js +255 -0
- package/dist/lib/core/Driver/mongodb/MongodbDriver.js.map +1 -0
- package/dist/lib/core/Driver/mongodb/MongodbQueryBuilder.d.ts +141 -0
- package/dist/lib/core/Driver/mongodb/MongodbQueryBuilder.js +563 -0
- package/dist/lib/core/Driver/mongodb/MongodbQueryBuilder.js.map +1 -0
- package/dist/lib/core/Driver/mysql/MysqlDriver.js +105 -95
- package/dist/lib/core/Driver/mysql/MysqlDriver.js.map +1 -1
- package/dist/lib/core/Driver/mysql/MysqlQueryBuilder.d.ts +45 -9
- package/dist/lib/core/Driver/mysql/MysqlQueryBuilder.js +165 -21
- package/dist/lib/core/Driver/mysql/MysqlQueryBuilder.js.map +1 -1
- package/dist/lib/core/Driver/postgres/PostgresDriver.js +97 -72
- package/dist/lib/core/Driver/postgres/PostgresDriver.js.map +1 -1
- package/dist/lib/core/Driver/postgres/PostgresQueryBuilder.d.ts +50 -9
- package/dist/lib/core/Driver/postgres/PostgresQueryBuilder.js +296 -41
- package/dist/lib/core/Driver/postgres/PostgresQueryBuilder.js.map +1 -1
- package/dist/lib/core/Driver/sqlite/SqliteDriver.d.ts +20 -0
- package/dist/lib/core/Driver/sqlite/SqliteDriver.js +192 -0
- package/dist/lib/core/Driver/sqlite/SqliteDriver.js.map +1 -0
- package/dist/lib/core/Driver/sqlite/SqliteQueryBuilder.d.ts +144 -0
- package/dist/lib/core/Driver/sqlite/SqliteQueryBuilder.js +689 -0
- package/dist/lib/core/Driver/sqlite/SqliteQueryBuilder.js.map +1 -0
- package/dist/lib/core/JoinModel.js +2 -2
- package/dist/lib/core/JoinModel.js.map +1 -1
- package/dist/lib/core/Meta.d.ts +17 -11
- package/dist/lib/core/Meta.js +25 -19
- package/dist/lib/core/Meta.js.map +1 -1
- package/dist/lib/core/Model.d.ts +450 -108
- package/dist/lib/core/Model.js +1031 -587
- package/dist/lib/core/Model.js.map +1 -1
- package/dist/lib/{tools/index.d.ts → core/Package.d.ts} +11 -3
- package/dist/lib/{tools/index.js → core/Package.js} +20 -7
- package/dist/lib/core/Package.js.map +1 -0
- package/dist/lib/core/Pool.js +42 -30
- package/dist/lib/core/Pool.js.map +1 -1
- package/dist/lib/core/Queue.d.ts +240 -0
- package/dist/lib/core/Queue.js +686 -0
- package/dist/lib/core/Queue.js.map +1 -0
- package/dist/lib/core/RelationManager.js +27 -25
- package/dist/lib/core/RelationManager.js.map +1 -1
- package/dist/lib/core/Repository.d.ts +73 -207
- package/dist/lib/core/Repository.js +120 -235
- package/dist/lib/core/Repository.js.map +1 -1
- package/dist/lib/core/Schema.d.ts +218 -0
- package/dist/lib/core/Schema.js +370 -65
- package/dist/lib/core/Schema.js.map +1 -1
- package/dist/lib/core/StateManager.d.ts +25 -12
- package/dist/lib/core/StateManager.js +10 -5
- package/dist/lib/core/StateManager.js.map +1 -1
- package/dist/lib/core/UtilityTypes.d.ts +85 -56
- package/dist/lib/core/UtilityTypes.js.map +1 -1
- package/dist/lib/core/index.d.ts +4 -0
- package/dist/lib/core/index.js +6 -2
- package/dist/lib/core/index.js.map +1 -1
- package/dist/lib/types/decorator/index.d.ts +1 -1
- package/dist/lib/types/index.d.ts +69 -22
- package/dist/lib/types/repository/index.d.ts +68 -37
- package/dist/lib/utils/index.d.ts +11 -1
- package/dist/lib/utils/index.js +58 -2
- package/dist/lib/utils/index.js.map +1 -1
- package/package.json +14 -6
- package/dist/lib/tools/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DBCache.js","sourceRoot":"","sources":["../../../../src/lib/core/Cache/DBCache.ts"],"names":[],"mappings":";;;AAAA,oCAAqC;AACrC,8BAAmC;AACnC,4CAA0C;
|
|
1
|
+
{"version":3,"file":"DBCache.js","sourceRoot":"","sources":["../../../../src/lib/core/Cache/DBCache.ts"],"names":[],"mappings":";;;AAAA,oCAAqC;AACrC,8BAAmC;AACnC,4CAA0C;AAC1C,uCAAyC;AAEzC,MAAM,OAAO;IAED,WAAW,GAAK,cAAc,CAAA;IAC9B,IAAI,GAAY,KAAK,CAAA;IACrB,WAAW,GAAK,EAAE,CAAA;IAClB,UAAU,GAAM,GAAG,CAAA;IACnB,GAAG,GAAa,GAAG,EAAE,CAAC,IAAI,OAAE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAEtD,QAAQ;QACJ,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK,CAAC,GAAG;QAEL,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAA;QAEtC,MAAM,MAAM,GAAW,EAAE,CAAA;QAEzB,KAAI,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAE1B,KAAI,IAAI,CAAC,GAAG,CAAC,EAAG,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC;gBACxC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;gBAC3C,IAAG,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,EAAE;oBAAE,MAAK;gBAErC,IACI,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC;oBAChC,IAA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AAA"}
|
|
@@ -37,20 +37,20 @@ class MemoryCache {
|
|
|
37
37
|
return resolve(cached.value);
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
set(key, value, ms) {
|
|
40
|
+
async set(key, value, ms) {
|
|
41
41
|
return new Promise((resolve) => {
|
|
42
42
|
const expiredAt = Date.now() + ms;
|
|
43
43
|
this.cache.set(key, { value, expiredAt });
|
|
44
44
|
return resolve();
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
clear() {
|
|
47
|
+
async clear() {
|
|
48
48
|
return new Promise((resolve) => {
|
|
49
49
|
this.cache.clear();
|
|
50
50
|
return resolve();
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
-
delete(key) {
|
|
53
|
+
async delete(key) {
|
|
54
54
|
return new Promise((resolve) => {
|
|
55
55
|
this.cache.delete(key);
|
|
56
56
|
return resolve();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryCache.js","sourceRoot":"","sources":["../../../../src/lib/core/Cache/MemoryCache.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"MemoryCache.js","sourceRoot":"","sources":["../../../../src/lib/core/Cache/MemoryCache.ts"],"names":[],"mappings":";;;AAEA,MAAM,WAAW;IACL,KAAK,CAAiD;IAE9D;QACI,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAA;IAC1B,CAAC;IAED,QAAQ;QACJ,OAAO,QAAQ,CAAA;IACnB,CAAC;IAED,KAAK,CAAC,GAAG;QACL,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC3B,MAAM,MAAM,GAAW,EAAE,CAAA;YAEzB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;gBACtC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACtB,CAAC;YAED,OAAO,OAAO,CAAC,MAAM,CAAC,CAAA;QAC1B,CAAC,CAA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AI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACnB,OAAO,OAAO,EAAE,CAAA;QACpB,CAAC,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAW;QACpB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC3B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACvB,OAAO,OAAO,EAAE,CAAA;QACpB,CAAC,CAAC,CAAA;IACN,CAAC;CACJ;AAEQ,kCAAW;AACpB,kBAAe,WAAW,CAAA"}
|
|
@@ -1,32 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RedisCache = void 0;
|
|
4
|
-
const
|
|
4
|
+
const Package_1 = require("../Package");
|
|
5
5
|
class RedisCache {
|
|
6
|
-
_redis =
|
|
6
|
+
_redis = Package_1.Package.redis;
|
|
7
7
|
client;
|
|
8
8
|
constructor(url) {
|
|
9
9
|
this.client = this._redis.createClient({
|
|
10
|
-
|
|
10
|
+
socket: {
|
|
11
|
+
reconnectStrategy: () => false
|
|
12
|
+
},
|
|
13
|
+
url,
|
|
11
14
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
console.log(err);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
try {
|
|
16
|
+
this.client.on("error", (err) => {
|
|
17
|
+
console.log(`\n\x1b[31mERROR: Redis error failed caused by '${err.message}'\x1b[0m`);
|
|
18
|
+
});
|
|
19
|
+
this.client.connect().catch((err) => {
|
|
20
|
+
console.log(`\n\x1b[31mERROR: Redis connection failed caused by '${err.message}'\x1b[0m`);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
console.log(`\n\x1b[31mERROR: Redis catch caused by '${err.message}'. Please try installing the package using : npm install redis@5.6.0 --save\x1b[0m`);
|
|
25
|
+
}
|
|
19
26
|
}
|
|
20
27
|
provider() {
|
|
21
|
-
return
|
|
28
|
+
return "redis";
|
|
22
29
|
}
|
|
23
30
|
async all() {
|
|
24
|
-
const cacheds = await this.client.keys(
|
|
31
|
+
const cacheds = await this.client.keys("*");
|
|
25
32
|
const values = [];
|
|
26
33
|
for (const cached in cacheds) {
|
|
27
|
-
values.push(cached == null
|
|
28
|
-
? null
|
|
29
|
-
: this._safetyJsonParse(cached));
|
|
34
|
+
values.push(cached == null ? null : this._safetyJsonParse(cached));
|
|
30
35
|
}
|
|
31
36
|
return values;
|
|
32
37
|
}
|
|
@@ -53,10 +58,15 @@ class RedisCache {
|
|
|
53
58
|
return;
|
|
54
59
|
}
|
|
55
60
|
_safetyJsonParse(value) {
|
|
61
|
+
if (typeof value !== 'string')
|
|
62
|
+
return value;
|
|
63
|
+
const v = value.trim();
|
|
64
|
+
if (!v || (v[0] !== '{' && v[0] !== '['))
|
|
65
|
+
return value;
|
|
56
66
|
try {
|
|
57
|
-
return JSON.parse(
|
|
67
|
+
return JSON.parse(v);
|
|
58
68
|
}
|
|
59
|
-
catch
|
|
69
|
+
catch {
|
|
60
70
|
return value;
|
|
61
71
|
}
|
|
62
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedisCache.js","sourceRoot":"","sources":["../../../../src/lib/core/Cache/RedisCache.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"RedisCache.js","sourceRoot":"","sources":["../../../../src/lib/core/Cache/RedisCache.ts"],"names":[],"mappings":";;;AAAA,wCAAqC;AAErC,MAAM,UAAU;IACN,MAAM,GAAG,iBAAO,CAAC,KAAK,CAAC;IACvB,MAAM,CASZ;IAEF,YAAY,GAAW;QACrB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;YACrC,MAAM,EAAE;gBACN,iBAAiB,EAAE,GAAG,EAAE,CAAC,KAAK;aAC/B;YACD,GAAG;SACJ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+
return this;
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* The 'all' method is used get all cache
|
|
@@ -101,14 +102,14 @@ class Cache {
|
|
|
101
102
|
_chooseDriver(driver) {
|
|
102
103
|
if (driver === "db") {
|
|
103
104
|
this._driver = new DBCache_1.DBCache();
|
|
104
|
-
return
|
|
105
|
+
return;
|
|
105
106
|
}
|
|
106
107
|
if (driver != null && driver.includes("redis")) {
|
|
107
108
|
this._driver = new RedisCache_1.RedisCache(String(config_1.default.CACHE));
|
|
108
|
-
return
|
|
109
|
+
return;
|
|
109
110
|
}
|
|
110
111
|
this._driver = new MemoryCache_1.MemoryCache();
|
|
111
|
-
return
|
|
112
|
+
return;
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
exports.TCache = Cache;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/core/Cache/index.ts"],"names":[],"mappings":";;;;;;AAAA,+CAA4C;AAC5C,uCAAoC;AACpC,6CAA0C;AAC1C,0DAAmC;AAEnC,MAAM,KAAK;IACD,OAAO,GAAuC,IAAI,yBAAW,EAAE,CAAC;IAExE;QACE,IAAI,CAAC,aAAa,CAAC,gBAAO,CAAC,KAAkC,CAAC,CAAC;QAE/D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,MAAiC;QACtC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/core/Cache/index.ts"],"names":[],"mappings":";;;;;;AAAA,+CAA4C;AAC5C,uCAAoC;AACpC,6CAA0C;AAC1C,0DAAmC;AAEnC,MAAM,KAAK;IACD,OAAO,GAAuC,IAAI,yBAAW,EAAE,CAAC;IAExE;QACE,IAAI,CAAC,aAAa,CAAC,gBAAO,CAAC,KAAkC,CAAC,CAAC;QA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MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,GAAW;QACtB,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC/B,OAAO;IACT,CAAC;IAEO,aAAa,CAAC,MAAiC;QACrD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,IAAI,CAAC,OAAO,GAAG,IAAI,iBAAO,EAAE,CAAC;YAC7B,OAAO;QACT,CAAC;QAED,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/C,IAAI,CAAC,OAAO,GAAG,IAAI,uBAAU,CAAC,MAAM,CAAC,gBAAO,CAAC,KAAK,CAAC,CAAC,CAAC;YACrD,OAAO;QACT,CAAC;QAED,IAAI,CAAC,OAAO,GAAG,IAAI,yBAAW,EAAE,CAAC;QAEjC,OAAO;IACT,CAAC;CACF;AAIyC,uBAAM;AAFhD,MAAM,aAAa,GAAG,IAAI,KAAK,EAAE,CAAC;AAER,8BAAK;AAC/B,kBAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Model } from "../Model";
|
|
2
|
+
import { T } from "../UtilityTypes";
|
|
3
|
+
/**
|
|
4
|
+
* Builder class for altering an existing database table.
|
|
5
|
+
*
|
|
6
|
+
* This class collects schema modification operations (primary key,
|
|
7
|
+
* unique constraints, indexes, etc.) and executes them sequentially
|
|
8
|
+
* when {@link run} is called.
|
|
9
|
+
*
|
|
10
|
+
* @template M - The model type extending Model.
|
|
11
|
+
*/
|
|
12
|
+
declare class AlterTable<M extends Model> {
|
|
13
|
+
private model;
|
|
14
|
+
private table;
|
|
15
|
+
private queries;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new AlterTable builder.
|
|
18
|
+
*
|
|
19
|
+
* @param {new () => M} model - The model constructor used to resolve the table.
|
|
20
|
+
*/
|
|
21
|
+
constructor(model: new () => M);
|
|
22
|
+
/**
|
|
23
|
+
* Dumps debugging information from the underlying model.
|
|
24
|
+
*
|
|
25
|
+
* @returns {this} Returns the current builder instance for chaining.
|
|
26
|
+
*/
|
|
27
|
+
dd(): this;
|
|
28
|
+
/**
|
|
29
|
+
* Adds a primary key constraint to the table.
|
|
30
|
+
*
|
|
31
|
+
* @template C
|
|
32
|
+
* @param {C} columns - Column names that will form the primary key.
|
|
33
|
+
* @returns {this} Returns the current builder instance for chaining.
|
|
34
|
+
*/
|
|
35
|
+
addPrimary<C extends T.ColumnKeys<M>[]>(columns: C): this;
|
|
36
|
+
/**
|
|
37
|
+
* Drops the primary key constraint from the table.
|
|
38
|
+
*
|
|
39
|
+
* @returns {this} Returns the current builder instance for chaining.
|
|
40
|
+
*/
|
|
41
|
+
dropPrimary(): this;
|
|
42
|
+
/**
|
|
43
|
+
* Adds a unique constraint to the table.
|
|
44
|
+
*
|
|
45
|
+
* If no name is provided, a default constraint name will be generated
|
|
46
|
+
* in the format: `ux_{table}_{column1_column2...}`.
|
|
47
|
+
*
|
|
48
|
+
* @template C
|
|
49
|
+
* @param {C} columns - Column names included in the unique constraint.
|
|
50
|
+
* @param {string} [name=""] - Optional unique constraint name.
|
|
51
|
+
* @returns {this} Returns the current builder instance for chaining.
|
|
52
|
+
*/
|
|
53
|
+
addUnique<C extends T.ColumnKeys<M>[]>(columns: C, name?: string): this;
|
|
54
|
+
/**
|
|
55
|
+
* Drops a unique constraint from the table.
|
|
56
|
+
*
|
|
57
|
+
* @param {string} name - The name of the unique constraint to drop.
|
|
58
|
+
* @returns {this} Returns the current builder instance for chaining.
|
|
59
|
+
*/
|
|
60
|
+
dropUnique(name: string): this;
|
|
61
|
+
/**
|
|
62
|
+
* Adds an index to the table.
|
|
63
|
+
*
|
|
64
|
+
* If no name is provided, a default index name will be generated
|
|
65
|
+
* in the format: `idx_{table}_{column1_column2...}`.
|
|
66
|
+
*
|
|
67
|
+
* @template C
|
|
68
|
+
* @param {C} columns - Column names included in the index.
|
|
69
|
+
* @param {string} [name=""] - Optional index name.
|
|
70
|
+
* @returns {this} Returns the current builder instance for chaining.
|
|
71
|
+
*/
|
|
72
|
+
addIndex<C extends T.ColumnKeys<M>[]>(columns: C, name?: string): this;
|
|
73
|
+
/**
|
|
74
|
+
* Drops an index from the table.
|
|
75
|
+
*
|
|
76
|
+
* @param {string} name - The name of the index to drop.
|
|
77
|
+
* @returns {this} Returns the current builder instance for chaining.
|
|
78
|
+
*/
|
|
79
|
+
dropIndex(name: string): this;
|
|
80
|
+
/**
|
|
81
|
+
* Adds a foreign key constraint to the table.
|
|
82
|
+
*
|
|
83
|
+
* This method defines a relationship between a column in the current table
|
|
84
|
+
* and a referenced column in another table. If no constraint name is provided,
|
|
85
|
+
* a deterministic name will be automatically generated based on the table
|
|
86
|
+
* and column names.
|
|
87
|
+
*
|
|
88
|
+
* The generated constraint name follows the format:
|
|
89
|
+
* `fk_{table(column)}_{referencedTable(referencedColumn)}`.
|
|
90
|
+
* If the generated name exceeds the database identifier length limit,
|
|
91
|
+
* a shortened version with a hash suffix will be used.
|
|
92
|
+
*
|
|
93
|
+
* @param {Object} params - Foreign key configuration.
|
|
94
|
+
* @param {string} params.column - The column in the current table that will act as the foreign key.
|
|
95
|
+
* @param {string} [params.constraint] - Optional constraint of the foreign key constraint.
|
|
96
|
+
* @param {string} [params.references] - The referenced column in the foreign table. Defaults to `"id"`.
|
|
97
|
+
* @param {(new () => Model) | string} params.on - The referenced table. This can be a Model constructor or a table name string.
|
|
98
|
+
* @param {"CASCADE" | "NO ACTION" | "RESTRICT" | "SET NULL"} params.onDelete - Action executed when the referenced row is deleted.
|
|
99
|
+
* @param {"CASCADE" | "NO ACTION" | "RESTRICT" | "SET NULL"} params.onUpdate - Action executed when the referenced row is updated.
|
|
100
|
+
*
|
|
101
|
+
* @returns {this} Returns the current builder instance for method chaining.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* await Schema
|
|
105
|
+
* .alterTable(User)
|
|
106
|
+
* .addForeignKey({
|
|
107
|
+
* references: {
|
|
108
|
+
* on : User
|
|
109
|
+
* },
|
|
110
|
+
* onDelete: 'CASCADE',
|
|
111
|
+
* onUpdate: 'CASCADE'
|
|
112
|
+
* })
|
|
113
|
+
* .run();
|
|
114
|
+
*/
|
|
115
|
+
addForeignKey({ column, name, references, onDelete, onUpdate }: {
|
|
116
|
+
column: string;
|
|
117
|
+
name?: string;
|
|
118
|
+
references: {
|
|
119
|
+
on: (new () => Model) | string;
|
|
120
|
+
column?: string;
|
|
121
|
+
};
|
|
122
|
+
onDelete?: "CASCADE" | "NO ACTION" | "RESTRICT" | "SET NULL";
|
|
123
|
+
onUpdate?: "CASCADE" | "NO ACTION" | "RESTRICT" | "SET NULL";
|
|
124
|
+
}): this;
|
|
125
|
+
/**
|
|
126
|
+
* Drops a foreign key constraint from the table.
|
|
127
|
+
*
|
|
128
|
+
* The specified foreign key constraint will be removed from the current table.
|
|
129
|
+
*
|
|
130
|
+
* @param {string} constraint - The name of the foreign key constraint to drop.
|
|
131
|
+
*
|
|
132
|
+
* @returns {this} Returns the current builder instance for method chaining.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* alterTable(User)
|
|
136
|
+
* .dropForeignKey("fk_users_role_id")
|
|
137
|
+
* .run();
|
|
138
|
+
*/
|
|
139
|
+
dropForeignKey(constraint: string): this;
|
|
140
|
+
/**
|
|
141
|
+
* Executes all queued schema modification queries sequentially.
|
|
142
|
+
*
|
|
143
|
+
* If a query fails, the error will be logged but execution will
|
|
144
|
+
* continue with the remaining queries.
|
|
145
|
+
*
|
|
146
|
+
* @async
|
|
147
|
+
* @returns {Promise<void>}
|
|
148
|
+
*/
|
|
149
|
+
run(): Promise<void>;
|
|
150
|
+
}
|
|
151
|
+
export { AlterTable };
|
|
152
|
+
export default AlterTable;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AlterTable = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Builder class for altering an existing database table.
|
|
6
|
+
*
|
|
7
|
+
* This class collects schema modification operations (primary key,
|
|
8
|
+
* unique constraints, indexes, etc.) and executes them sequentially
|
|
9
|
+
* when {@link run} is called.
|
|
10
|
+
*
|
|
11
|
+
* @template M - The model type extending Model.
|
|
12
|
+
*/
|
|
13
|
+
class AlterTable {
|
|
14
|
+
model;
|
|
15
|
+
table;
|
|
16
|
+
queries = [];
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new AlterTable builder.
|
|
19
|
+
*
|
|
20
|
+
* @param {new () => M} model - The model constructor used to resolve the table.
|
|
21
|
+
*/
|
|
22
|
+
constructor(model) {
|
|
23
|
+
this.model = new model().disabledRetry();
|
|
24
|
+
this.table = this.model.getTableName();
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Dumps debugging information from the underlying model.
|
|
28
|
+
*
|
|
29
|
+
* @returns {this} Returns the current builder instance for chaining.
|
|
30
|
+
*/
|
|
31
|
+
dd() {
|
|
32
|
+
this.model.dd();
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Adds a primary key constraint to the table.
|
|
37
|
+
*
|
|
38
|
+
* @template C
|
|
39
|
+
* @param {C} columns - Column names that will form the primary key.
|
|
40
|
+
* @returns {this} Returns the current builder instance for chaining.
|
|
41
|
+
*/
|
|
42
|
+
addPrimary(columns) {
|
|
43
|
+
this.queries.push(() => {
|
|
44
|
+
return this.model.addPrimaryKey({ columns, table: this.table });
|
|
45
|
+
});
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Drops the primary key constraint from the table.
|
|
50
|
+
*
|
|
51
|
+
* @returns {this} Returns the current builder instance for chaining.
|
|
52
|
+
*/
|
|
53
|
+
dropPrimary() {
|
|
54
|
+
this.queries.push(() => {
|
|
55
|
+
return this.model.dropPrimaryKey({ table: this.table });
|
|
56
|
+
});
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Adds a unique constraint to the table.
|
|
61
|
+
*
|
|
62
|
+
* If no name is provided, a default constraint name will be generated
|
|
63
|
+
* in the format: `ux_{table}_{column1_column2...}`.
|
|
64
|
+
*
|
|
65
|
+
* @template C
|
|
66
|
+
* @param {C} columns - Column names included in the unique constraint.
|
|
67
|
+
* @param {string} [name=""] - Optional unique constraint name.
|
|
68
|
+
* @returns {this} Returns the current builder instance for chaining.
|
|
69
|
+
*/
|
|
70
|
+
addUnique(columns, name = "") {
|
|
71
|
+
const n = name || `ux_${this.table}_${columns.join("_")}`;
|
|
72
|
+
this.queries.push(() => {
|
|
73
|
+
return this.model.addUnique({ columns, name: n, table: this.table });
|
|
74
|
+
});
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Drops a unique constraint from the table.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} name - The name of the unique constraint to drop.
|
|
81
|
+
* @returns {this} Returns the current builder instance for chaining.
|
|
82
|
+
*/
|
|
83
|
+
dropUnique(name) {
|
|
84
|
+
this.queries.push(() => {
|
|
85
|
+
return this.model.dropUnique({ name, table: this.table });
|
|
86
|
+
});
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Adds an index to the table.
|
|
91
|
+
*
|
|
92
|
+
* If no name is provided, a default index name will be generated
|
|
93
|
+
* in the format: `idx_{table}_{column1_column2...}`.
|
|
94
|
+
*
|
|
95
|
+
* @template C
|
|
96
|
+
* @param {C} columns - Column names included in the index.
|
|
97
|
+
* @param {string} [name=""] - Optional index name.
|
|
98
|
+
* @returns {this} Returns the current builder instance for chaining.
|
|
99
|
+
*/
|
|
100
|
+
addIndex(columns, name = "") {
|
|
101
|
+
const n = name || `idx_${this.table}_${columns.join("_")}`;
|
|
102
|
+
this.queries.push(() => {
|
|
103
|
+
return this.model.addIndex({ columns, name: n, table: this.table });
|
|
104
|
+
});
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Drops an index from the table.
|
|
109
|
+
*
|
|
110
|
+
* @param {string} name - The name of the index to drop.
|
|
111
|
+
* @returns {this} Returns the current builder instance for chaining.
|
|
112
|
+
*/
|
|
113
|
+
dropIndex(name) {
|
|
114
|
+
this.queries.push(() => {
|
|
115
|
+
return this.model.dropIndex({ name, table: this.table });
|
|
116
|
+
});
|
|
117
|
+
return this;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Adds a foreign key constraint to the table.
|
|
121
|
+
*
|
|
122
|
+
* This method defines a relationship between a column in the current table
|
|
123
|
+
* and a referenced column in another table. If no constraint name is provided,
|
|
124
|
+
* a deterministic name will be automatically generated based on the table
|
|
125
|
+
* and column names.
|
|
126
|
+
*
|
|
127
|
+
* The generated constraint name follows the format:
|
|
128
|
+
* `fk_{table(column)}_{referencedTable(referencedColumn)}`.
|
|
129
|
+
* If the generated name exceeds the database identifier length limit,
|
|
130
|
+
* a shortened version with a hash suffix will be used.
|
|
131
|
+
*
|
|
132
|
+
* @param {Object} params - Foreign key configuration.
|
|
133
|
+
* @param {string} params.column - The column in the current table that will act as the foreign key.
|
|
134
|
+
* @param {string} [params.constraint] - Optional constraint of the foreign key constraint.
|
|
135
|
+
* @param {string} [params.references] - The referenced column in the foreign table. Defaults to `"id"`.
|
|
136
|
+
* @param {(new () => Model) | string} params.on - The referenced table. This can be a Model constructor or a table name string.
|
|
137
|
+
* @param {"CASCADE" | "NO ACTION" | "RESTRICT" | "SET NULL"} params.onDelete - Action executed when the referenced row is deleted.
|
|
138
|
+
* @param {"CASCADE" | "NO ACTION" | "RESTRICT" | "SET NULL"} params.onUpdate - Action executed when the referenced row is updated.
|
|
139
|
+
*
|
|
140
|
+
* @returns {this} Returns the current builder instance for method chaining.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* await Schema
|
|
144
|
+
* .alterTable(User)
|
|
145
|
+
* .addForeignKey({
|
|
146
|
+
* references: {
|
|
147
|
+
* on : User
|
|
148
|
+
* },
|
|
149
|
+
* onDelete: 'CASCADE',
|
|
150
|
+
* onUpdate: 'CASCADE'
|
|
151
|
+
* })
|
|
152
|
+
* .run();
|
|
153
|
+
*/
|
|
154
|
+
addForeignKey({ column, name, references, onDelete, onUpdate }) {
|
|
155
|
+
const onReference = typeof references.on === "string" ? references.on : new references.on();
|
|
156
|
+
const tableRef = typeof onReference === "string"
|
|
157
|
+
? onReference
|
|
158
|
+
: onReference.getTableName();
|
|
159
|
+
const generateConstraintName = ({ modelTable, key, foreignTable, foreignKey }) => {
|
|
160
|
+
const MAX_LENGTH = 64;
|
|
161
|
+
const baseName = [
|
|
162
|
+
"fk",
|
|
163
|
+
`${modelTable}(${key})`,
|
|
164
|
+
`${foreignTable}(${foreignKey})`,
|
|
165
|
+
].join("_");
|
|
166
|
+
if (baseName.length <= MAX_LENGTH) {
|
|
167
|
+
return `\`${baseName}\``;
|
|
168
|
+
}
|
|
169
|
+
const hash = Buffer.from(baseName).toString("base64").slice(0, 8);
|
|
170
|
+
const shortParts = [
|
|
171
|
+
"fk",
|
|
172
|
+
`${modelTable.slice(0, 16)}(${key.slice(0, 16)})`,
|
|
173
|
+
`${foreignTable.slice(0, 16)}(${foreignKey.slice(0, 16)})`,
|
|
174
|
+
hash,
|
|
175
|
+
];
|
|
176
|
+
const shortName = shortParts.join("_").slice(0, MAX_LENGTH);
|
|
177
|
+
return `\`${shortName}\``;
|
|
178
|
+
};
|
|
179
|
+
const constraintName = generateConstraintName({
|
|
180
|
+
modelTable: this.model.getTableName(),
|
|
181
|
+
key: column,
|
|
182
|
+
foreignTable: tableRef,
|
|
183
|
+
foreignKey: references.column ?? "id",
|
|
184
|
+
}).replace(/`/g, "");
|
|
185
|
+
this.queries.push(() => {
|
|
186
|
+
return this.model.addFK({
|
|
187
|
+
table: this.table,
|
|
188
|
+
tableRef,
|
|
189
|
+
key: column,
|
|
190
|
+
constraint: name ?? constraintName,
|
|
191
|
+
foreign: {
|
|
192
|
+
references: references.column ?? "id",
|
|
193
|
+
onDelete: onDelete ?? "CASCADE",
|
|
194
|
+
onUpdate: onUpdate ?? "CASCADE"
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
return this;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Drops a foreign key constraint from the table.
|
|
202
|
+
*
|
|
203
|
+
* The specified foreign key constraint will be removed from the current table.
|
|
204
|
+
*
|
|
205
|
+
* @param {string} constraint - The name of the foreign key constraint to drop.
|
|
206
|
+
*
|
|
207
|
+
* @returns {this} Returns the current builder instance for method chaining.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* alterTable(User)
|
|
211
|
+
* .dropForeignKey("fk_users_role_id")
|
|
212
|
+
* .run();
|
|
213
|
+
*/
|
|
214
|
+
dropForeignKey(constraint) {
|
|
215
|
+
this.queries.push(() => {
|
|
216
|
+
return this.model.dropFK({ constraint, table: this.table });
|
|
217
|
+
});
|
|
218
|
+
return this;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Executes all queued schema modification queries sequentially.
|
|
222
|
+
*
|
|
223
|
+
* If a query fails, the error will be logged but execution will
|
|
224
|
+
* continue with the remaining queries.
|
|
225
|
+
*
|
|
226
|
+
* @async
|
|
227
|
+
* @returns {Promise<void>}
|
|
228
|
+
*/
|
|
229
|
+
async run() {
|
|
230
|
+
for (const query of this.queries) {
|
|
231
|
+
try {
|
|
232
|
+
await query();
|
|
233
|
+
}
|
|
234
|
+
catch (err) {
|
|
235
|
+
console.log(`\n\x1b[31mERROR: Failed to Alter table "${this.table}" caused by "${err.message}"\x1b[0m`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
exports.AlterTable = AlterTable;
|
|
241
|
+
;
|
|
242
|
+
exports.default = AlterTable;
|
|
243
|
+
//# sourceMappingURL=AlterTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AlterTable.js","sourceRoot":"","sources":["../../../../src/lib/core/Contracts/AlterTable.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;GAQG;AACH,MAAM,UAAU;IAEN,KAAK,CAAI;IACT,KAAK,CAAS;IACd,OAAO,GAA4B,EAAE,CAAC;IAE9C;;;;OAIG;IACH,YAAY,KAAkB;QAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC,aAAa,EAAE,CAAC;QACzC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACI,EAAE;QACP,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAA;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACI,UAAU,CAEf,OAAU;QAEV,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE;YACrB,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,KAAK,EAAG,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACI,WAAW;QAChB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE;YACrB,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE,KAAK,EAAG,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;OAUG;IACI,SAAS,CAEd,OAAU,EAAE,OAAe,EAAE;QAE7B,MAAM,CAAC,GAAG,IAAI,IAAI,MAAM,IAAI,CAAC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC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AAM,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjC,IAAI,CAAC;gBACH,MAAM,KAAK,EAAE,CAAC;YAChB,CAAC;YAAC,OAAO,GAAQ,EAAE,CAAC;gBAClB,OAAO,CAAC,GAAG,CACT,2CAA2C,IAAI,CAAC,KAAK,gBAAgB,GAAG,CAAC,OAAO,UAAU,CAC3F,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAEQ,gCAAU;AAFlB,CAAC;AAGF,kBAAe,UAAU,CAAC"}
|
|
@@ -36,6 +36,8 @@ class Audit extends Model_1.Model {
|
|
|
36
36
|
: Number(instance['$state'].get('AUDIT'));
|
|
37
37
|
const metadata = instance['$state'].get('AUDIT_METADATA');
|
|
38
38
|
const modelName = instance['$state'].get("MODEL_NAME");
|
|
39
|
+
instance['$state'].set("AUDIT", null);
|
|
40
|
+
instance['$state'].set("AUDIT_METADATA", null);
|
|
39
41
|
const baseQuery = {
|
|
40
42
|
model: modelName,
|
|
41
43
|
query: sql,
|
|
@@ -55,7 +57,6 @@ class Audit extends Model_1.Model {
|
|
|
55
57
|
.whereIn("id", result.$meta.insertIds)
|
|
56
58
|
.disableVoid()
|
|
57
59
|
.bind(instance['$pool'].get())
|
|
58
|
-
.debug(instance['$state'].get('DEBUG'))
|
|
59
60
|
.get();
|
|
60
61
|
await new this()
|
|
61
62
|
.table(instance['$state'].get("TABLE_AUDIT"))
|
|
@@ -84,7 +85,6 @@ class Audit extends Model_1.Model {
|
|
|
84
85
|
})
|
|
85
86
|
.disableVoid()
|
|
86
87
|
.bind(instance['$pool'].get())
|
|
87
|
-
.debug(instance['$state'].get('DEBUG'))
|
|
88
88
|
.get();
|
|
89
89
|
result = await fn();
|
|
90
90
|
const changed = await new Model_1.Model()
|
|
@@ -96,7 +96,6 @@ class Audit extends Model_1.Model {
|
|
|
96
96
|
.disableSoftDelete()
|
|
97
97
|
.disableVoid()
|
|
98
98
|
.bind(instance['$pool'].get())
|
|
99
|
-
.debug(instance['$state'].get('DEBUG'))
|
|
100
99
|
.get();
|
|
101
100
|
await new this()
|
|
102
101
|
.table(instance['$state'].get("TABLE_AUDIT"))
|
|
@@ -127,7 +126,6 @@ class Audit extends Model_1.Model {
|
|
|
127
126
|
})
|
|
128
127
|
.disableVoid()
|
|
129
128
|
.bind(instance['$pool'].get())
|
|
130
|
-
.debug(instance['$state'].get('DEBUG'))
|
|
131
129
|
.get();
|
|
132
130
|
result = await fn();
|
|
133
131
|
await new this()
|
|
@@ -171,7 +169,6 @@ class Audit extends Model_1.Model {
|
|
|
171
169
|
: null,
|
|
172
170
|
})
|
|
173
171
|
.bind(instance['$pool'].get())
|
|
174
|
-
.debug(instance['$state'].get('DEBUG'))
|
|
175
172
|
.void()
|
|
176
173
|
.save();
|
|
177
174
|
}
|