@breautek/storm 4.4.1 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/docs/README.md +20 -4
- package/docs/classes/Application.md +26 -26
- package/docs/classes/BackendAuthenticationMiddleware.md +2 -2
- package/docs/classes/CORSMiddleware.md +6 -6
- package/docs/classes/ConfigLoader.md +1 -1
- package/docs/classes/Database.md +12 -12
- package/docs/classes/DatabaseCastObject.md +79 -0
- package/docs/classes/DatabaseConnection.md +26 -20
- package/docs/classes/DatabaseQueryError.md +10 -10
- package/docs/classes/DeadLockError.md +10 -10
- package/docs/classes/DiskSpaceError.md +10 -10
- package/docs/classes/DropTemporaryTableQuery.md +8 -8
- package/docs/classes/DumpStream.md +1 -1
- package/docs/classes/DuplicateEntryError.md +10 -10
- package/docs/classes/EntityNotFoundError.md +10 -10
- package/docs/classes/ExpiredTokenError.md +10 -10
- package/docs/classes/Handler.md +14 -14
- package/docs/classes/InternalError.md +10 -10
- package/docs/classes/InvalidCredentialsError.md +10 -10
- package/docs/classes/InvalidValueError.md +10 -10
- package/docs/classes/LineString.md +101 -0
- package/docs/classes/ManagedDatabaseConnection.md +19 -19
- package/docs/classes/Middleware.md +3 -3
- package/docs/classes/MissingConfigError.md +10 -10
- package/docs/classes/MissingParameterError.md +10 -10
- package/docs/classes/MySQLConnection.md +27 -21
- package/docs/classes/MySQLDatabase.md +13 -13
- package/docs/classes/NotImplementedError.md +10 -10
- package/docs/classes/Point.md +102 -0
- package/docs/classes/Polygon.md +101 -0
- package/docs/classes/Query.md +8 -8
- package/docs/classes/RawError.md +10 -10
- package/docs/classes/RawQuery.md +8 -8
- package/docs/classes/Request.md +18 -18
- package/docs/classes/Response.md +11 -11
- package/docs/classes/ResponseData.md +7 -7
- package/docs/classes/ServiceProvider.md +15 -15
- package/docs/classes/ServiceResponse.md +4 -4
- package/docs/classes/SetSessionVariableQuery.md +8 -8
- package/docs/classes/StormError.md +10 -10
- package/docs/classes/TemporaryTableQuery.md +8 -8
- package/docs/classes/Token.md +2 -2
- package/docs/classes/TokenManager.md +4 -4
- package/docs/classes/UnauthorizedAccessError.md +10 -10
- package/docs/enums/ErrorCode.md +9 -9
- package/docs/enums/ExitCode.md +2 -2
- package/docs/enums/HTTPMethod.md +4 -4
- package/docs/enums/IsolationLevel.md +52 -0
- package/docs/enums/JWTError.md +2 -2
- package/docs/enums/StatusCode.md +48 -48
- package/docs/interfaces/IConfig.md +8 -8
- package/docs/interfaces/IDatabaseConfig.md +6 -6
- package/docs/interfaces/IDatabaseConnection.md +14 -14
- package/docs/interfaces/IErrorResponse.md +5 -5
- package/docs/interfaces/IFormData.md +2 -2
- package/docs/interfaces/IHandler.md +1 -1
- package/docs/interfaces/IInsertQueryResult.md +3 -3
- package/docs/interfaces/IJWTVerifyOptions.md +1 -1
- package/docs/interfaces/IRequestResponse.md +2 -2
- package/docs/interfaces/ISetSessionVariableQueryInput.md +2 -2
- package/docs/interfaces/ITemporaryTableQueryInput.md +2 -2
- package/docs/interfaces/IUpdateQueryResult.md +2 -2
- package/jest.config.js +5 -1
- package/lib/DatabaseCastObject.d.ts +5 -0
- package/lib/DatabaseCastObject.js +29 -0
- package/lib/DatabaseCastObject.js.map +1 -0
- package/lib/DatabaseConnection.d.ts +2 -1
- package/lib/DatabaseConnection.js.map +1 -1
- package/lib/IsolationLevel.d.ts +6 -0
- package/lib/IsolationLevel.js +26 -0
- package/lib/IsolationLevel.js.map +1 -0
- package/lib/LineString.d.ts +7 -0
- package/lib/LineString.js +41 -0
- package/lib/LineString.js.map +1 -0
- package/lib/MySQLConnection.d.ts +2 -1
- package/lib/MySQLConnection.js +15 -12
- package/lib/MySQLConnection.js.map +1 -1
- package/lib/Point.d.ts +7 -0
- package/lib/Point.js +31 -0
- package/lib/Point.js.map +1 -0
- package/lib/Polygon.d.ts +7 -0
- package/lib/Polygon.js +52 -0
- package/lib/Polygon.js.map +1 -0
- package/lib/TCoordinate.d.ts +1 -0
- package/lib/TCoordinate.js +18 -0
- package/lib/TCoordinate.js.map +1 -0
- package/lib/api.d.ts +6 -0
- package/lib/api.js +12 -1
- package/lib/api.js.map +1 -1
- package/lib/private/SetIsolationLevelQuery.d.ts +5 -0
- package/lib/private/SetIsolationLevelQuery.js +42 -0
- package/lib/private/SetIsolationLevelQuery.js.map +1 -0
- package/package.json +1 -1
- package/src/DatabaseCastObject.ts +29 -0
- package/src/DatabaseConnection.ts +2 -1
- package/src/IsolationLevel.ts +22 -0
- package/src/LineString.ts +47 -0
- package/src/MySQLConnection.ts +16 -12
- package/src/Point.ts +33 -0
- package/src/Polygon.ts +60 -0
- package/src/TCoordinate.ts +17 -0
- package/src/api.ts +8 -0
- package/src/private/SetIsolationLevelQuery.ts +39 -0
package/lib/Point.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Point.js","sourceRoot":"","sources":["../src/Point.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;EAcE;;;AAEF,6DAAwD;AAExD,MAAa,KAAM,SAAQ,uCAAkB;IAIzC,YAAmB,CAAU,EAAE,CAAU;QACrC,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IAES,YAAY;QAClB,OAAO,SAAS,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC;IACrE,CAAC;CACJ;AAdD,sBAcC"}
|
package/lib/Polygon.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DatabaseCastObject } from './DatabaseCastObject';
|
|
2
|
+
import { TCoordinate } from './TCoordinate';
|
|
3
|
+
export declare class Polygon extends DatabaseCastObject {
|
|
4
|
+
private $rings;
|
|
5
|
+
constructor(coordinates?: Array<Array<TCoordinate>>);
|
|
6
|
+
protected _toSQLString(): string;
|
|
7
|
+
}
|
package/lib/Polygon.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2017-2022 Norman Breau
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.Polygon = void 0;
|
|
19
|
+
const DatabaseCastObject_1 = require("./DatabaseCastObject");
|
|
20
|
+
class Polygon extends DatabaseCastObject_1.DatabaseCastObject {
|
|
21
|
+
constructor(coordinates) {
|
|
22
|
+
super();
|
|
23
|
+
this.$rings = coordinates || [];
|
|
24
|
+
}
|
|
25
|
+
_toSQLString() {
|
|
26
|
+
let str = 'POLYGON(';
|
|
27
|
+
for (let i = 0; i < this.$rings.length; i++) {
|
|
28
|
+
let ring = this.$rings[i];
|
|
29
|
+
let strRing = '(';
|
|
30
|
+
for (let y = 0; y < ring.length; y++) {
|
|
31
|
+
let coord = ring[y];
|
|
32
|
+
if (strRing === '(') {
|
|
33
|
+
strRing += `${this.escape(coord[0])} ${this.escape(coord[1])}`;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
strRing += `, ${this.escape(coord[0])} ${this.escape(coord[1])}`;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
strRing += ')';
|
|
40
|
+
if (str === 'POLYGON(') {
|
|
41
|
+
str += strRing;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
str += ', ' + strRing;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
str += ')';
|
|
48
|
+
return str;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.Polygon = Polygon;
|
|
52
|
+
//# sourceMappingURL=Polygon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Polygon.js","sourceRoot":"","sources":["../src/Polygon.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;EAcE;;;AAEF,6DAAwD;AAGxD,MAAa,OAAQ,SAAQ,uCAAkB;IAG3C,YAAmB,WAAuC;QACtD,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,GAAG,WAAW,IAAI,EAAE,CAAC;IACpC,CAAC;IAES,YAAY;QAClB,IAAI,GAAG,GAAW,UAAU,CAAC;QAE7B,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACjD,IAAI,IAAI,GAAuB,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC9C,IAAI,OAAO,GAAW,GAAG,CAAC;YAE1B,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAC1C,IAAI,KAAK,GAAgB,IAAI,CAAC,CAAC,CAAC,CAAC;gBACjC,IAAI,OAAO,KAAK,GAAG,EAAE;oBACjB,OAAO,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;iBAClE;qBACI;oBACD,OAAO,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;iBACpE;aACJ;YAED,OAAO,IAAI,GAAG,CAAC;YAEf,IAAI,GAAG,KAAK,UAAU,EAAE;gBACpB,GAAG,IAAI,OAAO,CAAC;aAClB;iBACI;gBACD,GAAG,IAAI,IAAI,GAAG,OAAO,CAAC;aACzB;SACJ;QAED,GAAG,IAAI,GAAG,CAAC;QAEX,OAAO,GAAG,CAAC;IACf,CAAC;CACJ;AAxCD,0BAwCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type TCoordinate = [x: number, y: number];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2017-2022 Norman Breau
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
//# sourceMappingURL=TCoordinate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TCoordinate.js","sourceRoot":"","sources":["../src/TCoordinate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;EAcE"}
|
package/lib/api.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export { IInsertQueryResult } from './IInsertQueryResult';
|
|
|
14
14
|
export { IDeleteQueryResult } from './IDeleteQueryResult';
|
|
15
15
|
export { IUpdateQueryResult } from './IUpdateQueryResult';
|
|
16
16
|
export { SetSessionVariableQuery, ISetSessionVariableQueryInput } from './SetSessionVariableQuery';
|
|
17
|
+
export { IsolationLevel } from './IsolationLevel';
|
|
17
18
|
export { ErrorCode } from './ErrorCode';
|
|
18
19
|
export { RawError } from './RawError';
|
|
19
20
|
export { StormError, IErrorResponse, IAdditionalErrorDetails } from './StormError';
|
|
@@ -55,5 +56,10 @@ export { Token } from './Token';
|
|
|
55
56
|
export { TokenManager } from './TokenManager';
|
|
56
57
|
export { ExitCode } from './ExitCode';
|
|
57
58
|
export { DumpStream } from './DumpStream';
|
|
59
|
+
export { TCoordinate } from './TCoordinate';
|
|
60
|
+
export { DatabaseCastObject } from './DatabaseCastObject';
|
|
61
|
+
export { Point } from './Point';
|
|
62
|
+
export { LineString } from './LineString';
|
|
63
|
+
export { Polygon } from './Polygon';
|
|
58
64
|
import * as formidable from 'formidable';
|
|
59
65
|
export { formidable };
|
package/lib/api.js
CHANGED
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
18
|
+
exports.Polygon = exports.LineString = exports.Point = exports.DatabaseCastObject = exports.DumpStream = exports.ExitCode = exports.TokenManager = exports.Token = exports.BackendAuthenticationMiddleware = exports.ServiceResponse = exports.HTTPMethod = exports.ServiceProvider = exports.CORSMiddleware = exports.Handler = exports.ResponseData = exports.Response = exports.Request = exports.Middleware = exports.StatusCode = exports.DeadLockError = exports.NotImplementedError = exports.DatabaseQueryError = exports.MissingConfigError = exports.DuplicateEntryError = exports.DiskSpaceError = exports.EntityNotFoundError = exports.UnauthorizedAccessError = exports.InvalidValueError = exports.ExpiredTokenError = exports.InternalError = exports.InvalidCredentialsError = exports.MissingParameterError = exports.JWTError = exports.StormError = exports.RawError = exports.ErrorCode = exports.IsolationLevel = exports.SetSessionVariableQuery = exports.RawQuery = exports.DropTemporaryTableQuery = exports.TemporaryTableQuery = exports.Query = exports.ManagedDatabaseConnection = exports.MySQLConnection = exports.MySQLDatabase = exports.DatabaseConnection = exports.Database = exports.ConfigLoader = exports.Application = exports.getInstance = void 0;
|
|
19
|
+
exports.formidable = void 0;
|
|
19
20
|
// Application
|
|
20
21
|
var instance_1 = require("./instance");
|
|
21
22
|
Object.defineProperty(exports, "getInstance", { enumerable: true, get: function () { return instance_1.getInstance; } });
|
|
@@ -45,6 +46,8 @@ var RawQuery_1 = require("./RawQuery");
|
|
|
45
46
|
Object.defineProperty(exports, "RawQuery", { enumerable: true, get: function () { return RawQuery_1.RawQuery; } });
|
|
46
47
|
var SetSessionVariableQuery_1 = require("./SetSessionVariableQuery");
|
|
47
48
|
Object.defineProperty(exports, "SetSessionVariableQuery", { enumerable: true, get: function () { return SetSessionVariableQuery_1.SetSessionVariableQuery; } });
|
|
49
|
+
var IsolationLevel_1 = require("./IsolationLevel");
|
|
50
|
+
Object.defineProperty(exports, "IsolationLevel", { enumerable: true, get: function () { return IsolationLevel_1.IsolationLevel; } });
|
|
48
51
|
// Errors
|
|
49
52
|
var ErrorCode_1 = require("./ErrorCode");
|
|
50
53
|
Object.defineProperty(exports, "ErrorCode", { enumerable: true, get: function () { return ErrorCode_1.ErrorCode; } });
|
|
@@ -113,6 +116,14 @@ var ExitCode_1 = require("./ExitCode");
|
|
|
113
116
|
Object.defineProperty(exports, "ExitCode", { enumerable: true, get: function () { return ExitCode_1.ExitCode; } });
|
|
114
117
|
var DumpStream_1 = require("./DumpStream");
|
|
115
118
|
Object.defineProperty(exports, "DumpStream", { enumerable: true, get: function () { return DumpStream_1.DumpStream; } });
|
|
119
|
+
var DatabaseCastObject_1 = require("./DatabaseCastObject");
|
|
120
|
+
Object.defineProperty(exports, "DatabaseCastObject", { enumerable: true, get: function () { return DatabaseCastObject_1.DatabaseCastObject; } });
|
|
121
|
+
var Point_1 = require("./Point");
|
|
122
|
+
Object.defineProperty(exports, "Point", { enumerable: true, get: function () { return Point_1.Point; } });
|
|
123
|
+
var LineString_1 = require("./LineString");
|
|
124
|
+
Object.defineProperty(exports, "LineString", { enumerable: true, get: function () { return LineString_1.LineString; } });
|
|
125
|
+
var Polygon_1 = require("./Polygon");
|
|
126
|
+
Object.defineProperty(exports, "Polygon", { enumerable: true, get: function () { return Polygon_1.Polygon; } });
|
|
116
127
|
// Third-party
|
|
117
128
|
const formidable = require("formidable");
|
|
118
129
|
exports.formidable = formidable;
|
package/lib/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;EAcE
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;EAcE;;;;AAEF,cAAc;AACd,uCAAuC;AAA/B,uGAAA,WAAW,OAAA;AACnB,6CAA0C;AAAlC,0GAAA,WAAW,OAAA;AAEnB,SAAS;AACT,+CAA4C;AAApC,4GAAA,YAAY,OAAA;AAEpB,WAAW;AACX,uCAAoC;AAA5B,oGAAA,QAAQ,OAAA;AAChB,2DAAwD;AAAhD,wHAAA,kBAAkB,OAAA;AAC1B,iDAA8C;AAAtC,8GAAA,aAAa,OAAA;AACrB,qDAAkD;AAA1C,kHAAA,eAAe,OAAA;AACvB,yEAAsE;AAA9D,sIAAA,yBAAyB,OAAA;AACjC,iCAA8B;AAAtB,8FAAA,KAAK,OAAA;AACb,6DAAqF;AAA7E,0HAAA,mBAAmB,OAAA;AAC3B,qEAAkE;AAA1D,kIAAA,uBAAuB,OAAA;AAC/B,uCAAoC;AAA5B,oGAAA,QAAQ,OAAA;AAIhB,qEAAiG;AAAzF,kIAAA,uBAAuB,OAAA;AAC/B,mDAAgD;AAAxC,gHAAA,cAAc,OAAA;AAEtB,SAAS;AACT,yCAAsC;AAA9B,sGAAA,SAAS,OAAA;AACjB,uCAAoC;AAA5B,oGAAA,QAAQ,OAAA;AAChB,2CAIsB;AAHlB,wGAAA,UAAU,OAAA;AAId,uCAAoC;AAA5B,oGAAA,QAAQ,OAAA;AAChB,iEAA8D;AAAtD,8HAAA,qBAAqB,OAAA;AAC7B,qEAAkE;AAA1D,kIAAA,uBAAuB,OAAA;AAC/B,iDAA8C;AAAtC,8GAAA,aAAa,OAAA;AACrB,yDAAsD;AAA9C,sHAAA,iBAAiB,OAAA;AACzB,yDAAsD;AAA9C,sHAAA,iBAAiB,OAAA;AACzB,qEAAkE;AAA1D,kIAAA,uBAAuB,OAAA;AAC/B,6DAA0D;AAAlD,0HAAA,mBAAmB,OAAA;AAC3B,mDAAgD;AAAxC,gHAAA,cAAc,OAAA;AACtB,6DAA0D;AAAlD,0HAAA,mBAAmB,OAAA;AAC3B,2DAAwD;AAAhD,wHAAA,kBAAkB,OAAA;AAC1B,2DAAwD;AAAhD,wHAAA,kBAAkB,OAAA;AAC1B,6DAA0D;AAAlD,0HAAA,mBAAmB,OAAA;AAC3B,iDAA8C;AAAtC,8GAAA,aAAa,OAAA;AAErB,OAAO;AACP,2CAAwC;AAAhC,wGAAA,UAAU,OAAA;AAClB,2CAAwC;AAAhC,wGAAA,UAAU,OAAA;AAClB,qCAAiD;AAAzC,kGAAA,OAAO,OAAA;AACf,uCAAoC;AAA5B,oGAAA,QAAQ,OAAA;AAChB,+CAA4C;AAApC,4GAAA,YAAY,OAAA;AACpB,qCAAmE;AAA3D,kGAAA,OAAO,OAAA;AACf,mDAAgD;AAAxC,gHAAA,cAAc,OAAA;AACtB,qDAAkD;AAA1C,kHAAA,eAAe,OAAA;AACvB,2CAAwC;AAAhC,wGAAA,UAAU,OAAA;AAClB,qDAAkD;AAA1C,kHAAA,eAAe,OAAA;AACvB,qFAAkF;AAA1E,kJAAA,+BAA+B,OAAA;AAavC,QAAQ;AACR,iCAA8B;AAAtB,8FAAA,KAAK,OAAA;AACb,+CAA4C;AAApC,4GAAA,YAAY,OAAA;AAEpB,QAAQ;AACR,uCAAoC;AAA5B,oGAAA,QAAQ,OAAA;AAChB,2CAAwC;AAAhC,wGAAA,UAAU,OAAA;AAIlB,2DAAwD;AAAhD,wHAAA,kBAAkB,OAAA;AAC1B,iCAA8B;AAAtB,8FAAA,KAAK,OAAA;AACb,2CAAwC;AAAhC,wGAAA,UAAU,OAAA;AAClB,qCAAkC;AAA1B,kGAAA,OAAO,OAAA;AAEf,cAAc;AACd,yCAAyC;AACjC,gCAAU"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2017-2021 Norman Breau
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.SetIsolationLevelQuery = void 0;
|
|
19
|
+
const IsolationLevel_1 = require("../IsolationLevel");
|
|
20
|
+
const Query_1 = require("../Query");
|
|
21
|
+
class SetIsolationLevelQuery extends Query_1.Query {
|
|
22
|
+
_getQuery() {
|
|
23
|
+
let level;
|
|
24
|
+
switch (this.getParameters()) {
|
|
25
|
+
case IsolationLevel_1.IsolationLevel.READ_COMMITTED:
|
|
26
|
+
level = 'READ COMMITTED';
|
|
27
|
+
break;
|
|
28
|
+
case IsolationLevel_1.IsolationLevel.READ_UNCOMMITTED:
|
|
29
|
+
level = 'READ UNCOMMITTED';
|
|
30
|
+
break;
|
|
31
|
+
case IsolationLevel_1.IsolationLevel.REPEATABLE_READ:
|
|
32
|
+
level = 'REPEATABLE READ';
|
|
33
|
+
break;
|
|
34
|
+
case IsolationLevel_1.IsolationLevel.SERIALIZABLE:
|
|
35
|
+
level = 'SERIALIZABLE';
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
return `SET TRANSACTION ISOLATION LEVEL ${level}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.SetIsolationLevelQuery = SetIsolationLevelQuery;
|
|
42
|
+
//# sourceMappingURL=SetIsolationLevelQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SetIsolationLevelQuery.js","sourceRoot":"","sources":["../../src/private/SetIsolationLevelQuery.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;EAcE;;;AAEF,sDAAmD;AACnD,oCAA+B;AAE/B,MAAa,sBAAuB,SAAQ,aAA2B;IACzD,SAAS;QACf,IAAI,KAAa,CAAC;QAClB,QAAQ,IAAI,CAAC,aAAa,EAAE,EAAE;YAC1B,KAAK,+BAAc,CAAC,cAAc;gBAC9B,KAAK,GAAG,gBAAgB,CAAC;gBACzB,MAAM;YACV,KAAK,+BAAc,CAAC,gBAAgB;gBAChC,KAAK,GAAG,kBAAkB,CAAC;gBAC3B,MAAM;YACV,KAAK,+BAAc,CAAC,eAAe;gBAC/B,KAAK,GAAG,iBAAiB,CAAC;gBAC1B,MAAM;YACV,KAAK,+BAAc,CAAC,YAAY;gBAC5B,KAAK,GAAG,cAAc,CAAC;gBACvB,MAAM;SACb;QACD,OAAO,mCAAmC,KAAK,EAAE,CAAC;IACtD,CAAC;CACJ;AAnBD,wDAmBC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2017-2022 Norman Breau
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import * as MySQL from 'mysql';
|
|
18
|
+
|
|
19
|
+
export abstract class DatabaseCastObject {
|
|
20
|
+
public toSqlString(): string {
|
|
21
|
+
return this._toSQLString();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public escape(value: any): string {
|
|
25
|
+
return MySQL.escape(value);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
protected abstract _toSQLString(): string;
|
|
29
|
+
}
|
|
@@ -21,6 +21,7 @@ import {Readable} from 'stream';
|
|
|
21
21
|
import {IDatabaseConnection} from './IDatabaseConnection';
|
|
22
22
|
import {Query} from './Query';
|
|
23
23
|
import { IConfig } from './IConfig';
|
|
24
|
+
import { IsolationLevel } from './IsolationLevel';
|
|
24
25
|
|
|
25
26
|
export const LINGER_WARNING: number = 10000;
|
|
26
27
|
export const DEFAULT_QUERY_TIMEOUT: number = 3600000;
|
|
@@ -189,7 +190,7 @@ export abstract class DatabaseConnection<TAPI> implements IDatabaseConnection {
|
|
|
189
190
|
* @async
|
|
190
191
|
* @returns Promise<void>
|
|
191
192
|
*/
|
|
192
|
-
public abstract startTransaction(): Promise<void>;
|
|
193
|
+
public abstract startTransaction(isolationLevel?: IsolationLevel): Promise<void>;
|
|
193
194
|
|
|
194
195
|
/**
|
|
195
196
|
* Implementation method to determine if the connection is in an active transaction.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2017-2022 Norman Breau
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export enum IsolationLevel {
|
|
18
|
+
REPEATABLE_READ = 1,
|
|
19
|
+
READ_COMMITTED,
|
|
20
|
+
READ_UNCOMMITTED,
|
|
21
|
+
SERIALIZABLE
|
|
22
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2017-2022 Norman Breau
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import {DatabaseCastObject} from './DatabaseCastObject';
|
|
18
|
+
import {TCoordinate} from './TCoordinate';
|
|
19
|
+
|
|
20
|
+
export class LineString extends DatabaseCastObject {
|
|
21
|
+
private $coords: Array<TCoordinate>;
|
|
22
|
+
|
|
23
|
+
public constructor(coordinates?: Array<TCoordinate>) {
|
|
24
|
+
super();
|
|
25
|
+
|
|
26
|
+
this.$coords = coordinates || [];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
protected _toSQLString(): string {
|
|
30
|
+
let str: string = 'LINESTRING(';
|
|
31
|
+
|
|
32
|
+
for (let i: number = 0; i < this.$coords.length; i++) {
|
|
33
|
+
let coord: TCoordinate = this.$coords[i];
|
|
34
|
+
|
|
35
|
+
if (str === 'LINESTRING(') {
|
|
36
|
+
str += `${this.escape(coord[0])} ${this.escape(coord[1])}`;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
str += `, ${this.escape(coord[0])} ${this.escape(coord[1])}`;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
str += ')';
|
|
44
|
+
|
|
45
|
+
return str;
|
|
46
|
+
}
|
|
47
|
+
}
|
package/src/MySQLConnection.ts
CHANGED
|
@@ -27,6 +27,8 @@ import * as SQLFormatter from 'sql-formatter';
|
|
|
27
27
|
import { Logger, LogLevel } from '@arashi/logger';
|
|
28
28
|
import { StormError } from './StormError';
|
|
29
29
|
import { DeadLockError } from './DeadLockError';
|
|
30
|
+
import { IsolationLevel } from './IsolationLevel';
|
|
31
|
+
import {SetIsolationLevelQuery} from './private/SetIsolationLevelQuery';
|
|
30
32
|
|
|
31
33
|
const DEFAULT_HIGH_WATERMARK: number = 512; // in number of result objects
|
|
32
34
|
const TAG: string = 'MySQLConnection';
|
|
@@ -141,26 +143,28 @@ export class MySQLConnection extends DatabaseConnection<MySQL.PoolConnection> {
|
|
|
141
143
|
return queryObject.stream(streamOptions);
|
|
142
144
|
}
|
|
143
145
|
|
|
144
|
-
public startTransaction(): Promise<void> {
|
|
146
|
+
public override async startTransaction(isolationLevel?: IsolationLevel): Promise<void> {
|
|
145
147
|
if (this.isReadOnly()) {
|
|
146
|
-
|
|
148
|
+
throw new Error('A readonly connection cannot start a transaction.')
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
if (this.isTransaction()) {
|
|
150
|
-
|
|
152
|
+
throw new Error('Connection is already in a transaction.');
|
|
151
153
|
}
|
|
152
154
|
|
|
153
155
|
this.$transaction = true;
|
|
154
156
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
157
|
+
try {
|
|
158
|
+
if (isolationLevel) {
|
|
159
|
+
await new SetIsolationLevelQuery(isolationLevel).execute(this);
|
|
160
|
+
}
|
|
161
|
+
await startTransactionQuery.execute(this);
|
|
162
|
+
}
|
|
163
|
+
catch (ex) {
|
|
164
|
+
this.$transaction = false;
|
|
165
|
+
getInstance().getLogger().error(TAG, ex);
|
|
166
|
+
throw ex;
|
|
167
|
+
}
|
|
164
168
|
}
|
|
165
169
|
|
|
166
170
|
public endTransaction(requiresRollback: boolean = false): Promise<void> {
|
package/src/Point.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2017-2022 Norman Breau
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import {DatabaseCastObject} from './DatabaseCastObject';
|
|
18
|
+
|
|
19
|
+
export class Point extends DatabaseCastObject {
|
|
20
|
+
private $x: number;
|
|
21
|
+
private $y: number;
|
|
22
|
+
|
|
23
|
+
public constructor(x?: number, y?: number) {
|
|
24
|
+
super();
|
|
25
|
+
|
|
26
|
+
this.$x = x || 0;
|
|
27
|
+
this.$y = y || 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
protected _toSQLString(): string {
|
|
31
|
+
return `POINT(${this.escape(this.$x)}, ${this.escape(this.$y)})`;
|
|
32
|
+
}
|
|
33
|
+
}
|
package/src/Polygon.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2017-2022 Norman Breau
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import {DatabaseCastObject} from './DatabaseCastObject';
|
|
18
|
+
import {TCoordinate} from './TCoordinate';
|
|
19
|
+
|
|
20
|
+
export class Polygon extends DatabaseCastObject {
|
|
21
|
+
private $rings: Array<Array<TCoordinate>>;
|
|
22
|
+
|
|
23
|
+
public constructor(coordinates?: Array<Array<TCoordinate>>) {
|
|
24
|
+
super();
|
|
25
|
+
|
|
26
|
+
this.$rings = coordinates || [];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
protected _toSQLString(): string {
|
|
30
|
+
let str: string = 'POLYGON(';
|
|
31
|
+
|
|
32
|
+
for (let i: number = 0; i < this.$rings.length; i++) {
|
|
33
|
+
let ring: Array<TCoordinate> = this.$rings[i];
|
|
34
|
+
let strRing: string = '(';
|
|
35
|
+
|
|
36
|
+
for (let y: number = 0; y < ring.length; y++) {
|
|
37
|
+
let coord: TCoordinate = ring[y];
|
|
38
|
+
if (strRing === '(') {
|
|
39
|
+
strRing += `${this.escape(coord[0])} ${this.escape(coord[1])}`;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
strRing += `, ${this.escape(coord[0])} ${this.escape(coord[1])}`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
strRing += ')';
|
|
47
|
+
|
|
48
|
+
if (str === 'POLYGON(') {
|
|
49
|
+
str += strRing;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
str += ', ' + strRing;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
str += ')';
|
|
57
|
+
|
|
58
|
+
return str;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2017-2022 Norman Breau
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export type TCoordinate = [x: number, y: number];
|
package/src/api.ts
CHANGED
|
@@ -35,6 +35,7 @@ export {IInsertQueryResult} from './IInsertQueryResult';
|
|
|
35
35
|
export {IDeleteQueryResult} from './IDeleteQueryResult';
|
|
36
36
|
export {IUpdateQueryResult} from './IUpdateQueryResult';
|
|
37
37
|
export {SetSessionVariableQuery, ISetSessionVariableQueryInput} from './SetSessionVariableQuery';
|
|
38
|
+
export {IsolationLevel} from './IsolationLevel';
|
|
38
39
|
|
|
39
40
|
// Errors
|
|
40
41
|
export {ErrorCode} from './ErrorCode';
|
|
@@ -91,6 +92,13 @@ export {TokenManager} from './TokenManager';
|
|
|
91
92
|
export {ExitCode} from './ExitCode';
|
|
92
93
|
export {DumpStream} from './DumpStream';
|
|
93
94
|
|
|
95
|
+
// Database Objects
|
|
96
|
+
export {TCoordinate} from './TCoordinate';
|
|
97
|
+
export {DatabaseCastObject} from './DatabaseCastObject';
|
|
98
|
+
export {Point} from './Point';
|
|
99
|
+
export {LineString} from './LineString';
|
|
100
|
+
export {Polygon} from './Polygon';
|
|
101
|
+
|
|
94
102
|
// Third-party
|
|
95
103
|
import * as formidable from 'formidable';
|
|
96
104
|
export {formidable};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2017-2021 Norman Breau
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { IsolationLevel } from '../IsolationLevel';
|
|
18
|
+
import {Query} from '../Query';
|
|
19
|
+
|
|
20
|
+
export class SetIsolationLevelQuery extends Query<IsolationLevel, void> {
|
|
21
|
+
protected _getQuery(): string {
|
|
22
|
+
let level: string;
|
|
23
|
+
switch (this.getParameters()) {
|
|
24
|
+
case IsolationLevel.READ_COMMITTED:
|
|
25
|
+
level = 'READ COMMITTED';
|
|
26
|
+
break;
|
|
27
|
+
case IsolationLevel.READ_UNCOMMITTED:
|
|
28
|
+
level = 'READ UNCOMMITTED';
|
|
29
|
+
break;
|
|
30
|
+
case IsolationLevel.REPEATABLE_READ:
|
|
31
|
+
level = 'REPEATABLE READ';
|
|
32
|
+
break;
|
|
33
|
+
case IsolationLevel.SERIALIZABLE:
|
|
34
|
+
level = 'SERIALIZABLE';
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
return `SET TRANSACTION ISOLATION LEVEL ${level}`;
|
|
38
|
+
}
|
|
39
|
+
}
|