tspace-mysql 1.8.2 → 1.8.4
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 +443 -68
- package/build/cli/generate/model.js +3 -3
- package/build/cli/generate/model.js.map +1 -1
- package/build/lib/constants/index.d.ts +7 -1
- package/build/lib/constants/index.js +7 -1
- package/build/lib/constants/index.js.map +1 -1
- package/build/lib/core/Abstracts/AbstractBuilder.d.ts +1 -1
- package/build/lib/core/Abstracts/AbstractBuilder.js.map +1 -1
- package/build/lib/core/Abstracts/AbstractDB.d.ts +2 -2
- package/build/lib/core/Abstracts/AbstractDB.js.map +1 -1
- package/build/lib/core/Abstracts/AbstractView.d.ts +10 -0
- package/build/lib/core/Abstracts/AbstractView.js +9 -0
- package/build/lib/core/Abstracts/AbstractView.js.map +1 -0
- package/build/lib/core/Blueprint.d.ts +24 -4
- package/build/lib/core/Blueprint.js +78 -87
- package/build/lib/core/Blueprint.js.map +1 -1
- package/build/lib/core/Builder.d.ts +39 -30
- package/build/lib/core/Builder.js +1094 -1044
- package/build/lib/core/Builder.js.map +1 -1
- package/build/lib/core/Cache/DBCache.js +15 -16
- package/build/lib/core/Cache/DBCache.js.map +1 -1
- package/build/lib/core/DB.d.ts +38 -38
- package/build/lib/core/DB.js +119 -115
- package/build/lib/core/DB.js.map +1 -1
- package/build/lib/core/Decorator.d.ts +1 -1
- package/build/lib/core/Decorator.js.map +1 -1
- package/build/lib/core/Handlers/Relation.d.ts +2 -1
- package/build/lib/core/Handlers/Relation.js +60 -15
- package/build/lib/core/Handlers/Relation.js.map +1 -1
- package/build/lib/core/Handlers/State.d.ts +1 -0
- package/build/lib/core/Handlers/State.js +1 -1
- package/build/lib/core/Handlers/State.js.map +1 -1
- package/build/lib/core/JoinModel.d.ts +1 -1
- package/build/lib/core/JoinModel.js.map +1 -1
- package/build/lib/core/Meta.d.ts +55 -0
- package/build/lib/core/Meta.js +175 -0
- package/build/lib/core/Meta.js.map +1 -0
- package/build/lib/core/Model.d.ts +158 -94
- package/build/lib/core/Model.js +1586 -1203
- package/build/lib/core/Model.js.map +1 -1
- package/build/lib/core/Nest/index.d.ts +3 -1
- package/build/lib/core/Nest/index.js +4 -2
- package/build/lib/core/Nest/index.js.map +1 -1
- package/build/lib/{connection/index.d.ts → core/Pool.d.ts} +2 -1
- package/build/lib/{connection/index.js → core/Pool.js} +74 -6
- package/build/lib/core/Pool.js.map +1 -0
- package/build/lib/core/Repository.d.ts +16 -16
- package/build/lib/core/Repository.js +73 -45
- package/build/lib/core/Repository.js.map +1 -1
- package/build/lib/core/Schema.d.ts +2 -2
- package/build/lib/core/Schema.js +113 -78
- package/build/lib/core/Schema.js.map +1 -1
- package/build/lib/core/SqlLike.js.map +1 -1
- package/build/lib/core/StoredProcedure.d.ts +120 -0
- package/build/lib/core/StoredProcedure.js +161 -0
- package/build/lib/core/StoredProcedure.js.map +1 -0
- package/build/lib/core/UtilityTypes.d.ts +25 -44
- package/build/lib/core/View.d.ts +96 -0
- package/build/lib/core/View.js +141 -0
- package/build/lib/core/View.js.map +1 -0
- package/build/lib/core/index.d.ts +17 -12
- package/build/lib/core/index.js +9 -4
- package/build/lib/core/index.js.map +1 -1
- package/build/lib/types/index.d.ts +23 -3
- package/build/lib/utils/index.js +5 -2
- package/build/lib/utils/index.js.map +1 -1
- package/build/tests/01-Pool.test.js +0 -10
- package/build/tests/01-Pool.test.js.map +1 -1
- package/build/tests/04-Model-pattern.test.js +1 -1
- package/build/tests/04-Model-pattern.test.js.map +1 -1
- package/build/tests/05-View.test.d.ts +1 -0
- package/build/tests/05-View.test.js +83 -0
- package/build/tests/05-View.test.js.map +1 -0
- package/build/tests/06-Meta.test.d.ts +1 -0
- package/build/tests/06-Meta.test.js +103 -0
- package/build/tests/06-Meta.test.js.map +1 -0
- package/build/tests/07-Virtual-column.test.d.ts +1 -0
- package/build/tests/07-Virtual-column.test.js +160 -0
- package/build/tests/07-Virtual-column.test.js.map +1 -0
- package/build/tests/schema-spec.js +25 -25
- package/build/tests/schema-spec.js.map +1 -1
- package/package.json +1 -1
- package/build/lib/connection/index.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const Model = (model, npm, schema) => {
|
|
4
|
-
return `import { Model , Blueprint ,
|
|
4
|
+
return `import { Model , Blueprint , type T } from '${npm}'
|
|
5
5
|
|
|
6
6
|
const schema = ${schema}
|
|
7
7
|
|
|
8
|
-
type TS =
|
|
8
|
+
type TS = T.Schema<typeof schema>
|
|
9
9
|
|
|
10
|
-
type TR =
|
|
10
|
+
type TR = T.Relation<{
|
|
11
11
|
// ... name your relationship
|
|
12
12
|
}>
|
|
13
13
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/cli/generate/model.ts"],"names":[],"mappings":";;AAAA,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,GAAW,EAAE,MAAe,EAAE,EAAE;IAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/cli/generate/model.ts"],"names":[],"mappings":";;AAAA,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,GAAW,EAAE,MAAe,EAAE,EAAE;IAC9D,OAAO,+CAA+C,GAAG;;iBAExC,MAAM;;;;;;;;QAQf,KAAK;;;;;;;;;;;;WAYF,KAAK;iBACC,KAAK;CACrB,CAAA;AACD,CAAC,CAAA;AAED,kBAAe,KAAK,CAAA"}
|
|
@@ -36,10 +36,12 @@ declare const CONSTANTS: Readonly<{
|
|
|
36
36
|
MAX: "MAX";
|
|
37
37
|
MIN: "MIN";
|
|
38
38
|
AS: "AS";
|
|
39
|
+
EQ: "=";
|
|
40
|
+
NOT_EQ: "!=";
|
|
39
41
|
IN: "IN";
|
|
42
|
+
NOT_IN: "NOT IN";
|
|
40
43
|
ALL: "ALL";
|
|
41
44
|
ANY: "ANY";
|
|
42
|
-
NOT_IN: "NOT IN";
|
|
43
45
|
SET: "SET";
|
|
44
46
|
NOT: "NOT";
|
|
45
47
|
DUPLICATE: "DUPLICATE";
|
|
@@ -61,8 +63,10 @@ declare const CONSTANTS: Readonly<{
|
|
|
61
63
|
DELETE: "DELETE";
|
|
62
64
|
INSERT: "INSERT INTO";
|
|
63
65
|
DROP_TABLE: "DROP TABLE";
|
|
66
|
+
DROP_VIEW: "DROP VIEW IF EXISTS";
|
|
64
67
|
TRUNCATE_TABLE: "TRUNCATE TABLE";
|
|
65
68
|
CREATE_DATABASE: "CREATE DATABASE";
|
|
69
|
+
CREATE_VIEW: "CREATE VIEW";
|
|
66
70
|
SHOW_DATABASES: "SHOW DATABASES";
|
|
67
71
|
SHOW_TABLES: "SHOW TABLES";
|
|
68
72
|
CREATE_DATABASE_NOT_EXISTS: "CREATE DATABASE IF NOT EXISTS";
|
|
@@ -70,7 +74,9 @@ declare const CONSTANTS: Readonly<{
|
|
|
70
74
|
CREATE_TABLE_NOT_EXISTS: "CREATE TABLE IF NOT EXISTS";
|
|
71
75
|
CREATE_INDEX: "CREATE INDEX";
|
|
72
76
|
ENGINE: "ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4";
|
|
77
|
+
DEFAULT: "DEFAULT";
|
|
73
78
|
RAND: "RAND()";
|
|
79
|
+
PRIMARY_KEY: "PRIMARY KEY";
|
|
74
80
|
FOREIGN_KEY: "FOREIGN KEY";
|
|
75
81
|
REFERENCES: "REFERENCES";
|
|
76
82
|
ON_DELETE: "ON DELETE";
|
|
@@ -39,10 +39,12 @@ const CONSTANTS = Object.freeze({
|
|
|
39
39
|
MAX: 'MAX',
|
|
40
40
|
MIN: 'MIN',
|
|
41
41
|
AS: 'AS',
|
|
42
|
+
EQ: '=',
|
|
43
|
+
NOT_EQ: '!=',
|
|
42
44
|
IN: 'IN',
|
|
45
|
+
NOT_IN: 'NOT IN',
|
|
43
46
|
ALL: 'ALL',
|
|
44
47
|
ANY: 'ANY',
|
|
45
|
-
NOT_IN: 'NOT IN',
|
|
46
48
|
SET: 'SET',
|
|
47
49
|
NOT: 'NOT',
|
|
48
50
|
DUPLICATE: 'DUPLICATE',
|
|
@@ -64,8 +66,10 @@ const CONSTANTS = Object.freeze({
|
|
|
64
66
|
DELETE: 'DELETE',
|
|
65
67
|
INSERT: 'INSERT INTO',
|
|
66
68
|
DROP_TABLE: 'DROP TABLE',
|
|
69
|
+
DROP_VIEW: 'DROP VIEW IF EXISTS',
|
|
67
70
|
TRUNCATE_TABLE: 'TRUNCATE TABLE',
|
|
68
71
|
CREATE_DATABASE: 'CREATE DATABASE',
|
|
72
|
+
CREATE_VIEW: 'CREATE VIEW',
|
|
69
73
|
SHOW_DATABASES: 'SHOW DATABASES',
|
|
70
74
|
SHOW_TABLES: 'SHOW TABLES',
|
|
71
75
|
CREATE_DATABASE_NOT_EXISTS: 'CREATE DATABASE IF NOT EXISTS',
|
|
@@ -73,7 +77,9 @@ const CONSTANTS = Object.freeze({
|
|
|
73
77
|
CREATE_TABLE_NOT_EXISTS: 'CREATE TABLE IF NOT EXISTS',
|
|
74
78
|
CREATE_INDEX: 'CREATE INDEX',
|
|
75
79
|
ENGINE: 'ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4',
|
|
80
|
+
DEFAULT: 'DEFAULT',
|
|
76
81
|
RAND: 'RAND()',
|
|
82
|
+
PRIMARY_KEY: 'PRIMARY KEY',
|
|
77
83
|
FOREIGN_KEY: 'FOREIGN KEY',
|
|
78
84
|
REFERENCES: 'REFERENCES',
|
|
79
85
|
ON_DELETE: 'ON DELETE',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/constants/index.ts"],"names":[],"mappings":";;;AAAA,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5B,EAAE,EAAG,IAAI;IACT,IAAI,EAAG,MAAM;IACb,MAAM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AAM,EAAG,QAAQ;IACjB,MAAM,EAAG,QAAQ;IACjB,MAAM,EAAG,aAAa;IACtB,UAAU,EAAG,YAAY;IACzB,SAAS,EAAE,qBAAqB;IAChC,cAAc,EAAG,gBAAgB;IACjC,eAAe,EAAG,iBAAiB;IACnC,WAAW,EAAE,aAAa;IAC1B,cAAc,EAAI,gBAAgB;IAClC,WAAW,EAAG,aAAa;IAC3B,0BAA0B,EAAG,+BAA+B;IAC5D,YAAY,EAAG,cAAc;IAC7B,uBAAuB,EAAG,4BAA4B;IACtD,YAAY,EAAG,cAAc;IAC7B,MAAM,EAAC,wDAAwD;IAC/D,OAAO,EAAE,SAAS;IAClB,IAAI,EAAG,QAAQ;IACf,WAAW,EAAG,aAAa;IAC3B,WAAW,EAAG,aAAa;IAC3B,UAAU,EAAG,YAAY;IACzB,SAAS,EAAG,WAAW;IACvB,SAAS,EAAG,WAAW;IACvB,GAAG,EAAG,KAAK;IACX,MAAM,EAAG,QAAQ;IACjB,cAAc,EAAG,gBAAgB;IACjC,KAAK,EAAG,OAAO;IACf,WAAW,EAAG,aAAa;IAC3B,MAAM,EAAG,QAAQ;IACjB,UAAU,EAAG,YAAY;IACzB,aAAa,EAAG,eAAe;IAC/B,WAAW,EAAG,aAAa;IAC3B,YAAY,EAAG;QACX,MAAM,EAAG,QAAQ;QACjB,OAAO,EAAG,SAAS;QACnB,SAAS,EAAG,WAAW;QACvB,aAAa,EAAG,eAAe;KAClC;IACD,OAAO,EAAG;QACN,UAAU,EAAG,YAAY;QACzB,SAAS,EAAG,WAAW;KAC1B;CACJ,CAAC,CAAA;AAEO,8BAAS;AAClB,kBAAe,SAAS,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { TPagination, TConstant } from '../../types';
|
|
2
1
|
import { StateHandler } from '../Handlers/State';
|
|
3
2
|
import { TUtils } from '../../utils';
|
|
4
3
|
import { Join } from '../Join';
|
|
4
|
+
import type { TPagination, TConstant } from '../../types';
|
|
5
5
|
declare abstract class AbstractBuilder {
|
|
6
6
|
protected $setters: string[];
|
|
7
7
|
protected $utils: TUtils;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractBuilder.js","sourceRoot":"","sources":["../../../../src/lib/core/Abstracts/AbstractBuilder.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"AbstractBuilder.js","sourceRoot":"","sources":["../../../../src/lib/core/Abstracts/AbstractBuilder.ts"],"names":[],"mappings":";;;AAOA,MAAe,eAAe;IAA9B;QAEc,aAAQ,GAAG;YACjB,aAAa;YACb,SAAS;YACT,QAAQ;YACR,YAAY;YACZ,OAAO;YACP,QAAQ;YACR,WAAW;SACd,CAAA;QAQS,UAAK,GAA2D;YACtE,KAAK,EAAE,CAAC,GAAW,EAAE,EAAE,GAAE,CAAC;YAC1B,GAAG,EAAE,CAAC,IAAU,EAAE,EAAE,GAAE,CAAC;YACvB,GAAG,EAAE,GAAG,EAAE,GAAE,CAAC;SAChB,CAAA;QAES,YAAO,GAA8G;YAC3H,GAAG,EAAE,GAAG,EAAE,GAAE,CAAC;YACb,GAAG,EAAE,CAAC,KAAc,EAAE,EAAE,GAAE,CAAC;YAC3B,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;YACf,KAAK,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,IAAI,IAAI,KAAK;SAC3C,CAAA;IA4FL,CAAC;CAAA;AAES,0CAAe;AACzB,kBAAe,eAAe,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Builder from '../Builder';
|
|
2
|
-
import { TConnection, TConnectionOptions } from '../../types';
|
|
2
|
+
import type { TConnection, TConnectionOptions, TConnectionTransaction } from '../../types';
|
|
3
3
|
declare abstract class AbstractDB extends Builder {
|
|
4
|
-
abstract beginTransaction(): Promise<
|
|
4
|
+
abstract beginTransaction(): Promise<TConnectionTransaction>;
|
|
5
5
|
abstract generateUUID(): string;
|
|
6
6
|
abstract raw(sql: string): string;
|
|
7
7
|
abstract escape(sql: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractDB.js","sourceRoot":"","sources":["../../../../src/lib/core/Abstracts/AbstractDB.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"AbstractDB.js","sourceRoot":"","sources":["../../../../src/lib/core/Abstracts/AbstractDB.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAmC;AAOnC,MAAe,UAAW,SAAQ,iBAAO;CAcxC;AAEQ,gCAAU;AACnB,kBAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Model } from '../Model';
|
|
2
|
+
declare abstract class AbstractView<TS extends Record<string, any> = any, TR = unknown> extends Model<TS, TR> {
|
|
3
|
+
protected abstract createView({ name, expression, synchronize }: {
|
|
4
|
+
name?: string;
|
|
5
|
+
expression: string;
|
|
6
|
+
synchronize?: boolean;
|
|
7
|
+
}): void;
|
|
8
|
+
}
|
|
9
|
+
export { AbstractView };
|
|
10
|
+
export default AbstractView;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbstractView = void 0;
|
|
4
|
+
const Model_1 = require("../Model");
|
|
5
|
+
class AbstractView extends Model_1.Model {
|
|
6
|
+
}
|
|
7
|
+
exports.AbstractView = AbstractView;
|
|
8
|
+
exports.default = AbstractView;
|
|
9
|
+
//# sourceMappingURL=AbstractView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractView.js","sourceRoot":"","sources":["../../../../src/lib/core/Abstracts/AbstractView.ts"],"names":[],"mappings":";;;AAAA,oCAAgC;AAEhC,MAAe,YAAgE,SAAQ,aAAY;CAMlG;AAEQ,oCAAY;AACrB,kBAAe,YAAY,CAAA"}
|
|
@@ -3,6 +3,7 @@ import { Model } from "./Model";
|
|
|
3
3
|
* Class 'Blueprint' is used to make the schema for table
|
|
4
4
|
* @example
|
|
5
5
|
* import { Schema , Blueprint } from 'tspace-mysql'
|
|
6
|
+
import sql from '../../../build/lib/core/SqlLike';
|
|
6
7
|
* await new Schema().table('users',{
|
|
7
8
|
* id : Blueprint.int().notNull().primary().autoIncrement(),
|
|
8
9
|
* name : Blueprint.varchar(255).default('my name'),
|
|
@@ -20,7 +21,20 @@ declare class Blueprint<T = any> {
|
|
|
20
21
|
private _foreignKey;
|
|
21
22
|
private _index;
|
|
22
23
|
private _column;
|
|
24
|
+
private _sql;
|
|
23
25
|
private _valueType;
|
|
26
|
+
static virtual(sql: string | {
|
|
27
|
+
select?: string;
|
|
28
|
+
where?: string;
|
|
29
|
+
orderBy?: string;
|
|
30
|
+
groupBy?: string;
|
|
31
|
+
}): Blueprint<unknown>;
|
|
32
|
+
virtual(sql: string | {
|
|
33
|
+
select?: string;
|
|
34
|
+
where?: string;
|
|
35
|
+
orderBy?: string;
|
|
36
|
+
groupBy?: string;
|
|
37
|
+
}): Blueprint<unknown>;
|
|
24
38
|
/**
|
|
25
39
|
* Assign type 'serial' in table
|
|
26
40
|
* @static
|
|
@@ -390,11 +404,11 @@ declare class Blueprint<T = any> {
|
|
|
390
404
|
* @property {string?} property.onUpdate
|
|
391
405
|
* @return {Blueprint<T>} Blueprint
|
|
392
406
|
*/
|
|
393
|
-
foreign({ references, on, onDelete, onUpdate }: {
|
|
407
|
+
foreign({ references, on, onDelete, onUpdate, }: {
|
|
394
408
|
references?: string;
|
|
395
409
|
on: (new () => Model) | string;
|
|
396
|
-
onDelete?:
|
|
397
|
-
onUpdate?:
|
|
410
|
+
onDelete?: "CASCADE" | "NO ACTION" | "RESTRICT" | "SET NULL";
|
|
411
|
+
onUpdate?: "CASCADE" | "NO ACTION" | "RESTRICT" | "SET NULL";
|
|
398
412
|
}): Blueprint<T>;
|
|
399
413
|
/**
|
|
400
414
|
* Assign attributes 'index' in table
|
|
@@ -403,12 +417,18 @@ declare class Blueprint<T = any> {
|
|
|
403
417
|
*/
|
|
404
418
|
index(name?: string): Blueprint<T>;
|
|
405
419
|
bindColumn(column: string): this;
|
|
420
|
+
get sql(): {
|
|
421
|
+
select?: string | undefined;
|
|
422
|
+
where?: string | undefined;
|
|
423
|
+
orderBy?: string | undefined;
|
|
424
|
+
groupBy?: string | undefined;
|
|
425
|
+
} | null;
|
|
406
426
|
get column(): string | null;
|
|
407
427
|
get type(): string;
|
|
408
428
|
get attributes(): string[];
|
|
409
429
|
get foreignKey(): Record<string, any> | null;
|
|
410
430
|
get indexKey(): string | null;
|
|
411
|
-
get valueType():
|
|
431
|
+
get valueType(): DateConstructor | StringConstructor | NumberConstructor | BooleanConstructor;
|
|
412
432
|
private _addAssignType;
|
|
413
433
|
private _addAssignAttribute;
|
|
414
434
|
}
|