tspace-mysql 1.1.2 → 1.1.3
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/dist/cli/index.js +23 -24
- package/dist/cli/migrate/make.js +18 -41
- package/dist/cli/models/make.js +18 -18
- package/dist/cli/models/model.js +27 -2
- package/dist/cli/tables/make.js +10 -10
- package/dist/cli/tables/table.js +22 -2
- package/dist/lib/config/env.d.ts +6 -0
- package/dist/lib/config/env.js +16 -10
- package/dist/lib/connection/index.d.ts +29 -8
- package/dist/lib/connection/index.js +111 -55
- package/dist/lib/constants/index.js +7 -5
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +2 -2
- package/dist/lib/tspace/AbstractDB.js +3 -23
- package/dist/lib/tspace/AbstractDatabase.d.ts +9 -4
- package/dist/lib/tspace/AbstractDatabase.js +28 -31
- package/dist/lib/tspace/AbstractModel.d.ts +30 -16
- package/dist/lib/tspace/AbstractModel.js +3 -23
- package/dist/lib/tspace/Blueprint.d.ts +92 -21
- package/dist/lib/tspace/Blueprint.js +171 -140
- package/dist/lib/tspace/DB.d.ts +27 -4
- package/dist/lib/tspace/DB.js +66 -158
- package/dist/lib/tspace/Database.d.ts +100 -51
- package/dist/lib/tspace/Database.js +1335 -1911
- package/dist/lib/tspace/Interface.d.ts +8 -8
- package/dist/lib/tspace/Logger.js +19 -19
- package/dist/lib/tspace/Model.d.ts +168 -132
- package/dist/lib/tspace/Model.js +1467 -2081
- package/dist/lib/tspace/ProxyHandler.js +15 -26
- package/dist/lib/tspace/Schema.js +25 -117
- package/dist/lib/tspace/index.js +4 -4
- package/dist/lib/utils/index.d.ts +4 -3
- package/dist/lib/utils/index.js +87 -112
- package/package.json +1 -1
package/dist/lib/index.d.ts
CHANGED
package/dist/lib/index.js
CHANGED
|
@@ -30,7 +30,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
30
30
|
* The entry point.
|
|
31
31
|
*
|
|
32
32
|
* @module tspace-mysql
|
|
33
|
-
*/
|
|
34
|
-
|
|
33
|
+
*/
|
|
34
|
+
const tspace = __importStar(require("./tspace"));
|
|
35
35
|
__exportStar(require("./tspace"), exports);
|
|
36
36
|
exports.default = tspace;
|
|
@@ -1,31 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
4
|
};
|
|
20
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
6
|
exports.AbstractDB = void 0;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
function AbstractDB() {
|
|
26
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
27
|
-
}
|
|
28
|
-
return AbstractDB;
|
|
29
|
-
}(Database_1.default));
|
|
7
|
+
const Database_1 = __importDefault(require("./Database"));
|
|
8
|
+
class AbstractDB extends Database_1.default {
|
|
9
|
+
}
|
|
30
10
|
exports.AbstractDB = AbstractDB;
|
|
31
11
|
exports.default = AbstractDB;
|
|
@@ -8,10 +8,12 @@ declare abstract class AbstractDatabase {
|
|
|
8
8
|
protected $db: {
|
|
9
9
|
get: Function;
|
|
10
10
|
set: Function;
|
|
11
|
+
clone: Function;
|
|
11
12
|
};
|
|
12
13
|
protected $pool: {
|
|
13
14
|
get: Function;
|
|
14
15
|
set: Function;
|
|
16
|
+
load: Function;
|
|
15
17
|
};
|
|
16
18
|
protected $logger: {
|
|
17
19
|
get: Function;
|
|
@@ -33,10 +35,7 @@ declare abstract class AbstractDatabase {
|
|
|
33
35
|
abstract whereId(id: number): void;
|
|
34
36
|
abstract whereUser(id: number): void;
|
|
35
37
|
abstract whereEmail(value: string): void;
|
|
36
|
-
abstract
|
|
37
|
-
abstract whereGroupEnd(column: string, operator: string, value: string): void;
|
|
38
|
-
abstract orWhereGroupStart(column: string, operator: string, value: string): void;
|
|
39
|
-
abstract orWhereGroupEnd(column: string, operator: string, value: string): void;
|
|
38
|
+
abstract whereQuery(callback: Function): void;
|
|
40
39
|
abstract orWhere(column: string, operator: string, value: string): void;
|
|
41
40
|
abstract whereIn(column: string, arrayValues: Array<any>): void;
|
|
42
41
|
abstract orWhereIn(column: string, arrayValues: Array<any>): void;
|
|
@@ -82,6 +81,12 @@ declare abstract class AbstractDatabase {
|
|
|
82
81
|
page: number;
|
|
83
82
|
}): Promise<Pagination>;
|
|
84
83
|
abstract first(): Promise<any>;
|
|
84
|
+
abstract firstOrError(message: string, options?: {
|
|
85
|
+
[key: string]: any;
|
|
86
|
+
}): Promise<any>;
|
|
87
|
+
abstract findOneOrError(message: string, options?: {
|
|
88
|
+
[key: string]: any;
|
|
89
|
+
}): Promise<any>;
|
|
85
90
|
abstract get(): Promise<any>;
|
|
86
91
|
abstract findOne(): Promise<any>;
|
|
87
92
|
abstract findMany(): Promise<any>;
|
|
@@ -1,34 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
return AbstractDatabase;
|
|
33
|
-
}());
|
|
3
|
+
class AbstractDatabase {
|
|
4
|
+
$setters = [
|
|
5
|
+
'$attributes',
|
|
6
|
+
'$logger',
|
|
7
|
+
'$utils',
|
|
8
|
+
'$constants',
|
|
9
|
+
'$pool',
|
|
10
|
+
'$db'
|
|
11
|
+
];
|
|
12
|
+
$utils = {};
|
|
13
|
+
$constants = (name) => { };
|
|
14
|
+
$db = {
|
|
15
|
+
get: (key) => { },
|
|
16
|
+
set: (key, value) => { },
|
|
17
|
+
clone: (data) => { }
|
|
18
|
+
};
|
|
19
|
+
$pool = {
|
|
20
|
+
get: (sql) => { },
|
|
21
|
+
set: (pool) => { },
|
|
22
|
+
load: () => { }
|
|
23
|
+
};
|
|
24
|
+
$logger = {
|
|
25
|
+
get: () => { },
|
|
26
|
+
set: (value) => { },
|
|
27
|
+
check: (value) => true || false
|
|
28
|
+
};
|
|
29
|
+
$attributes = {};
|
|
30
|
+
}
|
|
34
31
|
exports.default = AbstractDatabase;
|
|
@@ -1,21 +1,35 @@
|
|
|
1
|
-
import { Relation } from './Interface';
|
|
1
|
+
import { Relation, RelationQuery } from './Interface';
|
|
2
2
|
import Database from './Database';
|
|
3
3
|
declare abstract class AbstractModel extends Database {
|
|
4
|
-
abstract
|
|
5
|
-
abstract
|
|
6
|
-
abstract
|
|
7
|
-
abstract
|
|
8
|
-
abstract
|
|
9
|
-
abstract
|
|
10
|
-
abstract
|
|
11
|
-
abstract
|
|
12
|
-
abstract
|
|
13
|
-
abstract
|
|
14
|
-
abstract
|
|
15
|
-
abstract
|
|
16
|
-
abstract
|
|
17
|
-
abstract
|
|
18
|
-
abstract
|
|
4
|
+
abstract useUUID(): this;
|
|
5
|
+
abstract usePrimaryKey(primaryKey: string): this;
|
|
6
|
+
abstract useRegistry(): this;
|
|
7
|
+
abstract useDebug(): this;
|
|
8
|
+
abstract useTable(table: string): this;
|
|
9
|
+
abstract useTablePlural(): this;
|
|
10
|
+
abstract useTableSingular(): this;
|
|
11
|
+
abstract useTimestamp(): this;
|
|
12
|
+
abstract useSoftDelete(): this;
|
|
13
|
+
abstract usePattern(pattern: string): this;
|
|
14
|
+
abstract onlyTrashed(): Promise<any>;
|
|
15
|
+
abstract trashed(): Promise<any>;
|
|
16
|
+
abstract restore(): Promise<any>;
|
|
17
|
+
abstract ignoreSoftDelete(): this;
|
|
18
|
+
abstract disableSoftDelete(): this;
|
|
19
|
+
abstract registry(func: {
|
|
20
|
+
[key: string]: Function;
|
|
21
|
+
}): this;
|
|
22
|
+
abstract with(...nameRelations: string[]): this;
|
|
23
|
+
abstract withQuery(nameRelations: string, callback: Function): this;
|
|
24
|
+
abstract withExists(...nameRelations: string[]): this;
|
|
25
|
+
abstract hasOne({ name, model, localKey, foreignKey, freezeTable, as }: Relation): this;
|
|
26
|
+
abstract hasMany({ name, model, localKey, foreignKey, freezeTable, as }: Relation): this;
|
|
27
|
+
abstract belongsTo({ name, model, localKey, foreignKey, freezeTable, as }: Relation): this;
|
|
28
|
+
abstract belongsToMany({ name, model, localKey, foreignKey, freezeTable, as }: Relation): this;
|
|
29
|
+
abstract hasOneQuery({ name, model, localKey, foreignKey, freezeTable, as }: RelationQuery, callback: Function): this;
|
|
30
|
+
abstract hasManyQuery({ name, model, localKey, foreignKey, freezeTable, as }: RelationQuery, callback: Function): this;
|
|
31
|
+
abstract belongsToQuery({ name, model, localKey, foreignKey, freezeTable, as }: RelationQuery, callback: Function): this;
|
|
32
|
+
abstract belongsToManyQuery({ name, model, localKey, foreignKey, freezeTable, as }: RelationQuery, callback: Function): this;
|
|
19
33
|
}
|
|
20
34
|
export { AbstractModel };
|
|
21
35
|
export default AbstractModel;
|
|
@@ -1,31 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
4
|
};
|
|
20
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
6
|
exports.AbstractModel = void 0;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
function AbstractModel() {
|
|
26
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
27
|
-
}
|
|
28
|
-
return AbstractModel;
|
|
29
|
-
}(Database_1.default));
|
|
7
|
+
const Database_1 = __importDefault(require("./Database"));
|
|
8
|
+
class AbstractModel extends Database_1.default {
|
|
9
|
+
}
|
|
30
10
|
exports.AbstractModel = AbstractModel;
|
|
31
11
|
exports.default = AbstractModel;
|
|
@@ -1,65 +1,136 @@
|
|
|
1
1
|
declare class Blueprint {
|
|
2
2
|
protected type: string;
|
|
3
3
|
protected attrbuites: Array<string>;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Assign type 'int' in table
|
|
6
|
+
* @return {this} this
|
|
7
|
+
*/
|
|
6
8
|
int(): this;
|
|
7
9
|
/**
|
|
8
|
-
* Assign type
|
|
9
|
-
* @param {number}
|
|
10
|
+
* Assign type 'TINYINT' in table
|
|
11
|
+
* @param {number} number
|
|
12
|
+
* @return {this} this
|
|
10
13
|
*/
|
|
11
|
-
tinyInt(
|
|
14
|
+
tinyInt(number?: number): this;
|
|
12
15
|
/**
|
|
13
|
-
* Assign type
|
|
14
|
-
* @param {number}
|
|
16
|
+
* Assign type 'BIGINT' in table
|
|
17
|
+
* @param {number} number [number = 10]
|
|
18
|
+
* @return {this} this
|
|
15
19
|
*/
|
|
16
|
-
bigInt(
|
|
20
|
+
bigInt(number?: number): this;
|
|
17
21
|
/**
|
|
18
|
-
* Assign type
|
|
22
|
+
* Assign type 'DOUBLE' in table
|
|
19
23
|
* @param {number} length between 1-255
|
|
20
24
|
* @param {number} decimal 0.000...n
|
|
25
|
+
* @return {this} this
|
|
21
26
|
*/
|
|
22
27
|
double(length?: number, decimal?: number): this;
|
|
23
28
|
/**
|
|
24
|
-
* Assign type
|
|
29
|
+
* Assign type 'FLOAT' in table
|
|
25
30
|
* @param {number} length between 1-255
|
|
26
31
|
* @param {number} decimal 0.000...n
|
|
32
|
+
* @return {this} this
|
|
27
33
|
*/
|
|
28
34
|
float(length?: number, decimal?: number): this;
|
|
29
35
|
/**
|
|
30
|
-
* Assign type
|
|
31
|
-
* @param {number} length
|
|
36
|
+
* Assign type 'VARCHAR' in table
|
|
37
|
+
* @param {number} length [length = 100] length of string
|
|
38
|
+
* @return {this} this
|
|
32
39
|
*/
|
|
33
|
-
varchar(
|
|
40
|
+
varchar(length?: number): this;
|
|
34
41
|
/**
|
|
35
|
-
* Assign type
|
|
36
|
-
* @param {number} length
|
|
42
|
+
* Assign type 'CHAR' in table
|
|
43
|
+
* @param {number} length [length = 1] length of string
|
|
44
|
+
* @return {this} this
|
|
45
|
+
*/
|
|
46
|
+
char(length?: number): this;
|
|
47
|
+
/**
|
|
48
|
+
* Assign type 'LONGTEXT' in table
|
|
49
|
+
* @return {this} this
|
|
37
50
|
*/
|
|
38
|
-
char(n?: number): this;
|
|
39
51
|
longText(): this;
|
|
52
|
+
/**
|
|
53
|
+
* Assign type 'MEDIUMTEXT' in table
|
|
54
|
+
* @param {number} length [length = 1] length of string
|
|
55
|
+
* @return {this} this
|
|
56
|
+
*/
|
|
40
57
|
mediumText(): this;
|
|
58
|
+
/**
|
|
59
|
+
* Assign type 'TINYTEXT' in table
|
|
60
|
+
* @param {number} length [length = 1] length of string
|
|
61
|
+
* @return {this} this
|
|
62
|
+
*/
|
|
41
63
|
tinyText(): this;
|
|
64
|
+
/**
|
|
65
|
+
* Assign type 'TEXT' in table
|
|
66
|
+
* @param {number} length [length = 1] length of string
|
|
67
|
+
* @return {this} this
|
|
68
|
+
*/
|
|
42
69
|
text(): this;
|
|
43
70
|
/**
|
|
44
|
-
* Assign type
|
|
45
|
-
* @param {...string}
|
|
71
|
+
* Assign type 'ENUM'
|
|
72
|
+
* @param {...string} enums n1, n2, n3, ...n
|
|
73
|
+
* @return {this} this
|
|
46
74
|
*/
|
|
47
75
|
enum(...enums: Array<string>): this;
|
|
76
|
+
/**
|
|
77
|
+
* Assign type 'DATE' in table
|
|
78
|
+
* @return {this} this
|
|
79
|
+
*/
|
|
48
80
|
date(): this;
|
|
81
|
+
/**
|
|
82
|
+
* Assign type 'DATETIME' in table
|
|
83
|
+
* @return {this} this
|
|
84
|
+
*/
|
|
49
85
|
dateTime(): this;
|
|
86
|
+
/**
|
|
87
|
+
* Assign type 'TIMESTAMP' in table
|
|
88
|
+
* @return {this} this
|
|
89
|
+
*/
|
|
50
90
|
timestamp(): this;
|
|
91
|
+
/**
|
|
92
|
+
* Assign type 'UNSIGNED' in table
|
|
93
|
+
* @return {this} this
|
|
94
|
+
*/
|
|
51
95
|
unsigned(): this;
|
|
96
|
+
/**
|
|
97
|
+
* Assign type 'UNIQUE' in table
|
|
98
|
+
* @return {this} this
|
|
99
|
+
*/
|
|
52
100
|
unique(): this;
|
|
101
|
+
/**
|
|
102
|
+
* Assign type 'NULL' in table
|
|
103
|
+
* @return {this} this
|
|
104
|
+
*/
|
|
53
105
|
null(): this;
|
|
106
|
+
/**
|
|
107
|
+
* Assign type 'NOT NULL' in table
|
|
108
|
+
* @return {this} this
|
|
109
|
+
*/
|
|
54
110
|
notNull(): this;
|
|
111
|
+
/**
|
|
112
|
+
* Assign type 'PRIMARY KEY' in table
|
|
113
|
+
* @return {this} this
|
|
114
|
+
*/
|
|
55
115
|
primary(): this;
|
|
56
116
|
/**
|
|
57
|
-
* Assign attrbuites
|
|
58
|
-
* @param {string | number} default value
|
|
117
|
+
* Assign attrbuites 'default' in table
|
|
118
|
+
* @param {string | number} n default value
|
|
119
|
+
* @return {this} this
|
|
59
120
|
*/
|
|
60
121
|
default(n: string | number): this;
|
|
61
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Assign attrbuites 'default currentTimestamp' in table
|
|
124
|
+
* @return {this} this
|
|
125
|
+
*/
|
|
126
|
+
currentTimestamp(): this;
|
|
127
|
+
/**
|
|
128
|
+
* Assign attrbuites 'autoIncrement' in table
|
|
129
|
+
* @return {this} this
|
|
130
|
+
*/
|
|
62
131
|
autoIncrement(): this;
|
|
132
|
+
private _addAssignType;
|
|
133
|
+
private _addAssignAttrbuite;
|
|
63
134
|
}
|
|
64
135
|
export { Blueprint };
|
|
65
136
|
export default Blueprint;
|