@breautek/storm 4.0.0 → 4.2.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 +18 -1
- package/bt-config-sample.jsonc +1 -1
- package/docs/README.md +8 -6
- package/docs/classes/Application.md +30 -30
- 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/DatabaseConnection.md +19 -19
- package/docs/classes/DatabaseQueryError.md +11 -11
- package/docs/classes/DiskSpaceError.md +11 -11
- package/docs/classes/DropTemporaryTableQuery.md +16 -10
- package/docs/classes/DumpStream.md +1 -1
- package/docs/classes/DuplicateEntryError.md +11 -11
- package/docs/classes/EntityNotFoundError.md +11 -11
- package/docs/classes/ExpiredTokenError.md +11 -11
- package/docs/classes/Handler.md +22 -22
- package/docs/classes/InternalError.md +11 -11
- package/docs/classes/InvalidCredentialsError.md +11 -11
- package/docs/classes/InvalidValueError.md +11 -11
- package/docs/classes/ManagedDatabaseConnection.md +19 -19
- package/docs/classes/Middleware.md +3 -3
- package/docs/classes/MissingConfigError.md +11 -11
- package/docs/classes/MissingParameterError.md +11 -11
- package/docs/classes/MySQLConnection.md +20 -20
- package/docs/classes/MySQLDatabase.md +14 -14
- package/docs/classes/NotImplementedError.md +301 -0
- package/docs/classes/Query.md +16 -10
- package/docs/classes/RawError.md +313 -0
- package/docs/classes/RawQuery.md +25 -17
- package/docs/classes/Request.md +18 -18
- package/docs/classes/Response.md +12 -12
- package/docs/classes/ResponseData.md +7 -7
- package/docs/classes/ServiceProvider.md +16 -16
- package/docs/classes/ServiceResponse.md +4 -4
- package/docs/classes/SetSessionVariableQuery.md +16 -10
- package/docs/classes/StormError.md +15 -11
- package/docs/classes/TemporaryTableQuery.md +16 -10
- package/docs/classes/Token.md +2 -2
- package/docs/classes/TokenManager.md +4 -4
- package/docs/classes/UnauthorizedAccessError.md +11 -11
- package/docs/enums/ErrorCode.md +20 -20
- package/docs/enums/ExitCode.md +6 -6
- package/docs/enums/HTTPMethod.md +10 -10
- package/docs/enums/JWTError.md +6 -6
- package/docs/enums/StatusCode.md +98 -98
- package/docs/interfaces/IConfig.md +8 -8
- package/docs/interfaces/IDatabaseConfig.md +6 -6
- package/docs/interfaces/IDatabaseConnection.md +15 -15
- package/docs/interfaces/IErrorResponse.md +4 -4
- 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/docs/interfaces/formidable.EmitData.md +1 -1
- package/docs/modules/formidable.md +2 -2
- package/lib/Application.d.ts +58 -0
- package/lib/Application.js +73 -0
- package/lib/Application.js.map +1 -1
- package/lib/ApplicationEvent.js +15 -0
- package/lib/ApplicationEvent.js.map +1 -1
- package/lib/BackendAuthenticationMiddleware.d.ts +12 -0
- package/lib/BackendAuthenticationMiddleware.js +28 -0
- package/lib/BackendAuthenticationMiddleware.js.map +1 -1
- package/lib/CORSMiddleware.d.ts +14 -0
- package/lib/CORSMiddleware.js +29 -0
- package/lib/CORSMiddleware.js.map +1 -1
- package/lib/ConfigLoader.js +16 -0
- package/lib/ConfigLoader.js.map +1 -1
- package/lib/Database.js +15 -0
- package/lib/Database.js.map +1 -1
- package/lib/DatabaseConnection.d.ts +115 -0
- package/lib/DatabaseConnection.js +71 -0
- package/lib/DatabaseConnection.js.map +1 -1
- package/lib/DatabaseQueryError.js +16 -0
- package/lib/DatabaseQueryError.js.map +1 -1
- package/lib/DiskSpaceError.js +15 -0
- package/lib/DiskSpaceError.js.map +1 -1
- package/lib/DropTemporaryTableQuery.js +15 -0
- package/lib/DropTemporaryTableQuery.js.map +1 -1
- package/lib/DumpStream.js +16 -0
- package/lib/DumpStream.js.map +1 -1
- package/lib/DuplicateEntryError.js +15 -0
- package/lib/DuplicateEntryError.js.map +1 -1
- package/lib/EntityNotFoundError.js +15 -0
- package/lib/EntityNotFoundError.js.map +1 -1
- package/lib/ErrorCode.js +15 -0
- package/lib/ErrorCode.js.map +1 -1
- package/lib/ExitCode.js +15 -0
- package/lib/ExitCode.js.map +1 -1
- package/lib/ExpiredTokenError.js +16 -0
- package/lib/ExpiredTokenError.js.map +1 -1
- package/lib/HTTPMethod.js +15 -0
- package/lib/HTTPMethod.js.map +1 -1
- package/lib/Handler.d.ts +22 -4
- package/lib/Handler.js +22 -6
- package/lib/Handler.js.map +1 -1
- package/lib/IAuthTokenData.js +15 -0
- package/lib/IAuthTokenData.js.map +1 -1
- package/lib/IConfig.js +15 -0
- package/lib/IConfig.js.map +1 -1
- package/lib/IDatabaseConfig.js +15 -0
- package/lib/IDatabaseConfig.js.map +1 -1
- package/lib/IDatabaseConnection.js +15 -0
- package/lib/IDatabaseConnection.js.map +1 -1
- package/lib/IDeleteQueryResult.js +15 -0
- package/lib/IDeleteQueryResult.js.map +1 -1
- package/lib/IFormData.js +15 -0
- package/lib/IFormData.js.map +1 -1
- package/lib/IHandler.js +15 -0
- package/lib/IHandler.js.map +1 -1
- package/lib/IInsertQueryResult.js +15 -0
- package/lib/IInsertQueryResult.js.map +1 -1
- package/lib/IJWTVerifyOptions.js +15 -0
- package/lib/IJWTVerifyOptions.js.map +1 -1
- package/lib/IRequestResponse.js +15 -0
- package/lib/IRequestResponse.js.map +1 -1
- package/lib/IServiceHeaders.js +15 -0
- package/lib/IServiceHeaders.js.map +1 -1
- package/lib/IUpdateQueryResult.js +15 -0
- package/lib/IUpdateQueryResult.js.map +1 -1
- package/lib/InternalError.js +16 -0
- package/lib/InternalError.js.map +1 -1
- package/lib/InvalidConfigError.js +15 -0
- package/lib/InvalidConfigError.js.map +1 -1
- package/lib/InvalidCredentialsError.js +16 -0
- package/lib/InvalidCredentialsError.js.map +1 -1
- package/lib/InvalidValueError.js +16 -0
- package/lib/InvalidValueError.js.map +1 -1
- package/lib/JWTError.js +15 -0
- package/lib/JWTError.js.map +1 -1
- package/lib/JWTVerifyOptionsParser.js +16 -0
- package/lib/JWTVerifyOptionsParser.js.map +1 -1
- package/lib/ManagedDatabaseConnection.d.ts +5 -0
- package/lib/ManagedDatabaseConnection.js +26 -0
- package/lib/ManagedDatabaseConnection.js.map +1 -1
- package/lib/Middleware.js +16 -0
- package/lib/Middleware.js.map +1 -1
- package/lib/MissingConfigError.js +15 -0
- package/lib/MissingConfigError.js.map +1 -1
- package/lib/MissingParameterError.js +15 -0
- package/lib/MissingParameterError.js.map +1 -1
- package/lib/MySQLConnection.js +24 -1
- package/lib/MySQLConnection.js.map +1 -1
- package/lib/MySQLDatabase.js +18 -0
- package/lib/MySQLDatabase.js.map +1 -1
- package/lib/NotImplementedError.d.ts +14 -0
- package/lib/NotImplementedError.js +40 -0
- package/lib/NotImplementedError.js.map +1 -0
- package/lib/Query.d.ts +22 -2
- package/lib/Query.js +37 -0
- package/lib/Query.js.map +1 -1
- package/lib/RawError.d.ts +14 -0
- package/lib/RawError.js +40 -0
- package/lib/RawError.js.map +1 -0
- package/lib/RawQuery.d.ts +1 -1
- package/lib/RawQuery.js +15 -0
- package/lib/RawQuery.js.map +1 -1
- package/lib/Request.d.ts +1 -0
- package/lib/Request.js +15 -0
- package/lib/Request.js.map +1 -1
- package/lib/Response.d.ts +1 -0
- package/lib/Response.js +17 -0
- package/lib/Response.js.map +1 -1
- package/lib/ResponseData.js +15 -0
- package/lib/ResponseData.js.map +1 -1
- package/lib/ServiceProvider.d.ts +1 -2
- package/lib/ServiceProvider.js +20 -0
- package/lib/ServiceProvider.js.map +1 -1
- package/lib/ServiceResponse.d.ts +1 -0
- package/lib/ServiceResponse.js +15 -0
- package/lib/ServiceResponse.js.map +1 -1
- package/lib/SetSessionVariableQuery.d.ts +1 -2
- package/lib/SetSessionVariableQuery.js +1 -0
- package/lib/SetSessionVariableQuery.js.map +1 -1
- package/lib/StatusCode.js +15 -0
- package/lib/StatusCode.js.map +1 -1
- package/lib/StormError.d.ts +7 -0
- package/lib/StormError.js +22 -0
- package/lib/StormError.js.map +1 -1
- package/lib/TemporaryTableQuery.d.ts +1 -2
- package/lib/TemporaryTableQuery.js +15 -0
- package/lib/TemporaryTableQuery.js.map +1 -1
- package/lib/Token.js +15 -0
- package/lib/Token.js.map +1 -1
- package/lib/TokenManager.js +17 -0
- package/lib/TokenManager.js.map +1 -1
- package/lib/UnauthorizedAccessError.js +15 -0
- package/lib/UnauthorizedAccessError.js.map +1 -1
- package/lib/api.d.ts +2 -0
- package/lib/api.js +28 -1
- package/lib/api.js.map +1 -1
- package/lib/instance.js +15 -0
- package/lib/instance.js.map +1 -1
- package/lib/private/CommitQuery.js +15 -0
- package/lib/private/CommitQuery.js.map +1 -1
- package/lib/private/RollbackQuery.js +15 -0
- package/lib/private/RollbackQuery.js.map +1 -1
- package/lib/private/StartTransactionQuery.js +15 -0
- package/lib/private/StartTransactionQuery.js.map +1 -1
- package/package.json +15 -16
- package/src/Database.ts +1 -2
- package/src/DatabaseConnection.ts +2 -3
- package/src/Handler.ts +10 -9
- package/src/NotImplementedError.ts +45 -0
- package/src/Query.ts +9 -2
- package/src/RawError.ts +39 -0
- package/src/RawQuery.ts +1 -1
- package/src/ServiceProvider.ts +1 -2
- package/src/SetSessionVariableQuery.ts +1 -2
- package/src/TemporaryTableQuery.ts +2 -3
- package/src/api.ts +2 -0
- package/tsconfig.json +0 -1
package/lib/TokenManager.js
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
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
|
+
*/
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.TokenManager = void 0;
|
|
4
19
|
const jwt = require("jsonwebtoken");
|
|
5
20
|
const Token_1 = require("./Token");
|
|
6
21
|
const JWTVerifyOptionsParser_1 = require("./JWTVerifyOptionsParser");
|
|
7
22
|
const crypto_1 = require("crypto");
|
|
23
|
+
// const TAG: string = 'TokenManager';
|
|
8
24
|
class TokenManager {
|
|
9
25
|
constructor(secret) {
|
|
10
26
|
this.$secret = secret;
|
|
@@ -30,6 +46,7 @@ class TokenManager {
|
|
|
30
46
|
}
|
|
31
47
|
verify(token, options) {
|
|
32
48
|
return new Promise((resolve, reject) => {
|
|
49
|
+
// placed inside the promise in the event that a reject would be required.
|
|
33
50
|
if (!options) {
|
|
34
51
|
options = {
|
|
35
52
|
enableExpiration: true
|
package/lib/TokenManager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenManager.js","sourceRoot":"","sources":["../src/TokenManager.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"TokenManager.js","sourceRoot":"","sources":["../src/TokenManager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;EAcE;;;AAEF,oCAAoC;AACpC,mCAA8B;AAE9B,qEAAgE;AAChE,mCAAmC;AAGnC,sCAAsC;AAEtC,MAAa,YAAY;IAGrB,YAAmB,MAAc;QAC7B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;IAEM,IAAI,CAAC,OAA6B,EAAE,SAA0B;QACjE,OAAO,IAAI,OAAO,CAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC1C,IAAA,oBAAW,EAAC,EAAE,EAAE,CAAC,GAAU,EAAE,MAAc,EAAE,EAAE;gBAC3C,IAAI,GAAG,EAAE;oBACL,MAAM,CAAC,GAAG,CAAC,CAAC;oBACZ,OAAO;iBACV;gBAED,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAE5C,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE;oBAC5B,SAAS,EAAG,SAAS;iBACxB,EAAE,CAAC,KAAY,EAAE,KAAa,EAAE,EAAE;oBAC/B,IAAI,KAAK,EAAE;wBACP,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;qBACxB;oBAED,OAAO,OAAO,CAAC,IAAI,aAAK,CAAC,KAAK,CAAC,CAAC,CAAC;gBACrC,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,MAAM,CAAC,KAAY,EAAE,OAA2B;QACnD,OAAO,IAAI,OAAO,CAAM,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACxC,0EAA0E;YAC1E,IAAI,CAAC,OAAO,EAAE;gBACV,OAAO,GAAG;oBACN,gBAAgB,EAAE,IAAI;iBACzB,CAAC;aACL;iBACI,IAAI,OAAO,CAAC,gBAAgB,KAAK,SAAS,EAAE;gBAC7C,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;aACnC;YAED,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,+CAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAmB,EAAE,EAAE;gBACjH,IAAI,KAAK,EAAE;oBACP,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;iBACxB;gBAED,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;YAC5B,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,MAAM,CAAC,KAAY;QACtB,OAAO,IAAI,OAAO,CAAM,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACxC,IAAI;gBACA,IAAI,OAAO,GAA2B,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC;gBACvE,OAAO,CAAC,OAAO,CAAC,CAAC;aACpB;YACD,OAAO,EAAE,EAAE;gBACP,MAAM,CAAC,EAAE,CAAC,CAAC;aACd;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AA/DD,oCA+DC"}
|
|
@@ -1,4 +1,19 @@
|
|
|
1
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
|
+
*/
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.UnauthorizedAccessError = void 0;
|
|
4
19
|
const StormError_1 = require("./StormError");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnauthorizedAccessError.js","sourceRoot":"","sources":["../src/UnauthorizedAccessError.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"UnauthorizedAccessError.js","sourceRoot":"","sources":["../src/UnauthorizedAccessError.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;EAcE;;;AAEF,6CAAwC;AACxC,2CAAsC;AACtC,6CAAwC;AAExC,MAAa,uBAAwB,SAAQ,uBAAU;IACnD,YAAmB,SAAiB;QAChC,KAAK,CAAC,SAAS,CAAC,CAAC;IACrB,CAAC;IAEM,UAAU;QACb,OAAO,gBAAgB,CAAC;IAC5B,CAAC;IAEM,OAAO;QACV,OAAO,qBAAS,CAAC,mBAAmB,CAAC;IACzC,CAAC;IAEM,WAAW;QACd,OAAO,uBAAU,CAAC,aAAa,CAAC;IACpC,CAAC;CACJ;AAhBD,0DAgBC"}
|
package/lib/api.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export { IDeleteQueryResult } from './IDeleteQueryResult';
|
|
|
15
15
|
export { IUpdateQueryResult } from './IUpdateQueryResult';
|
|
16
16
|
export { SetSessionVariableQuery, ISetSessionVariableQueryInput } from './SetSessionVariableQuery';
|
|
17
17
|
export { ErrorCode } from './ErrorCode';
|
|
18
|
+
export { RawError } from './RawError';
|
|
18
19
|
export { StormError, IErrorResponse, IAdditionalErrorDetails } from './StormError';
|
|
19
20
|
export { JWTError } from './JWTError';
|
|
20
21
|
export { MissingParameterError } from './MissingParameterError';
|
|
@@ -28,6 +29,7 @@ export { DiskSpaceError } from './DiskSpaceError';
|
|
|
28
29
|
export { DuplicateEntryError } from './DuplicateEntryError';
|
|
29
30
|
export { MissingConfigError } from './MissingConfigError';
|
|
30
31
|
export { DatabaseQueryError } from './DatabaseQueryError';
|
|
32
|
+
export { NotImplementedError } from './NotImplementedError';
|
|
31
33
|
export { StatusCode } from './StatusCode';
|
|
32
34
|
export { Middleware } from './Middleware';
|
|
33
35
|
export { Request, IParameterMap } from './Request';
|
package/lib/api.js
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
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
|
+
*/
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formidable = 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.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.ErrorCode = 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;
|
|
18
|
+
exports.formidable = 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.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.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
|
+
// Application
|
|
4
20
|
var instance_1 = require("./instance");
|
|
5
21
|
Object.defineProperty(exports, "getInstance", { enumerable: true, get: function () { return instance_1.getInstance; } });
|
|
6
22
|
var Application_1 = require("./Application");
|
|
7
23
|
Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return Application_1.Application; } });
|
|
24
|
+
// Config
|
|
8
25
|
var ConfigLoader_1 = require("./ConfigLoader");
|
|
9
26
|
Object.defineProperty(exports, "ConfigLoader", { enumerable: true, get: function () { return ConfigLoader_1.ConfigLoader; } });
|
|
27
|
+
// Database
|
|
10
28
|
var Database_1 = require("./Database");
|
|
11
29
|
Object.defineProperty(exports, "Database", { enumerable: true, get: function () { return Database_1.Database; } });
|
|
12
30
|
var DatabaseConnection_1 = require("./DatabaseConnection");
|
|
@@ -27,8 +45,11 @@ var RawQuery_1 = require("./RawQuery");
|
|
|
27
45
|
Object.defineProperty(exports, "RawQuery", { enumerable: true, get: function () { return RawQuery_1.RawQuery; } });
|
|
28
46
|
var SetSessionVariableQuery_1 = require("./SetSessionVariableQuery");
|
|
29
47
|
Object.defineProperty(exports, "SetSessionVariableQuery", { enumerable: true, get: function () { return SetSessionVariableQuery_1.SetSessionVariableQuery; } });
|
|
48
|
+
// Errors
|
|
30
49
|
var ErrorCode_1 = require("./ErrorCode");
|
|
31
50
|
Object.defineProperty(exports, "ErrorCode", { enumerable: true, get: function () { return ErrorCode_1.ErrorCode; } });
|
|
51
|
+
var RawError_1 = require("./RawError");
|
|
52
|
+
Object.defineProperty(exports, "RawError", { enumerable: true, get: function () { return RawError_1.RawError; } });
|
|
32
53
|
var StormError_1 = require("./StormError");
|
|
33
54
|
Object.defineProperty(exports, "StormError", { enumerable: true, get: function () { return StormError_1.StormError; } });
|
|
34
55
|
var JWTError_1 = require("./JWTError");
|
|
@@ -55,6 +76,9 @@ var MissingConfigError_1 = require("./MissingConfigError");
|
|
|
55
76
|
Object.defineProperty(exports, "MissingConfigError", { enumerable: true, get: function () { return MissingConfigError_1.MissingConfigError; } });
|
|
56
77
|
var DatabaseQueryError_1 = require("./DatabaseQueryError");
|
|
57
78
|
Object.defineProperty(exports, "DatabaseQueryError", { enumerable: true, get: function () { return DatabaseQueryError_1.DatabaseQueryError; } });
|
|
79
|
+
var NotImplementedError_1 = require("./NotImplementedError");
|
|
80
|
+
Object.defineProperty(exports, "NotImplementedError", { enumerable: true, get: function () { return NotImplementedError_1.NotImplementedError; } });
|
|
81
|
+
// HTTP
|
|
58
82
|
var StatusCode_1 = require("./StatusCode");
|
|
59
83
|
Object.defineProperty(exports, "StatusCode", { enumerable: true, get: function () { return StatusCode_1.StatusCode; } });
|
|
60
84
|
var Middleware_1 = require("./Middleware");
|
|
@@ -77,14 +101,17 @@ var ServiceResponse_1 = require("./ServiceResponse");
|
|
|
77
101
|
Object.defineProperty(exports, "ServiceResponse", { enumerable: true, get: function () { return ServiceResponse_1.ServiceResponse; } });
|
|
78
102
|
var BackendAuthenticationMiddleware_1 = require("./BackendAuthenticationMiddleware");
|
|
79
103
|
Object.defineProperty(exports, "BackendAuthenticationMiddleware", { enumerable: true, get: function () { return BackendAuthenticationMiddleware_1.BackendAuthenticationMiddleware; } });
|
|
104
|
+
// Token
|
|
80
105
|
var Token_1 = require("./Token");
|
|
81
106
|
Object.defineProperty(exports, "Token", { enumerable: true, get: function () { return Token_1.Token; } });
|
|
82
107
|
var TokenManager_1 = require("./TokenManager");
|
|
83
108
|
Object.defineProperty(exports, "TokenManager", { enumerable: true, get: function () { return TokenManager_1.TokenManager; } });
|
|
109
|
+
// Utils
|
|
84
110
|
var ExitCode_1 = require("./ExitCode");
|
|
85
111
|
Object.defineProperty(exports, "ExitCode", { enumerable: true, get: function () { return ExitCode_1.ExitCode; } });
|
|
86
112
|
var DumpStream_1 = require("./DumpStream");
|
|
87
113
|
Object.defineProperty(exports, "DumpStream", { enumerable: true, get: function () { return DumpStream_1.DumpStream; } });
|
|
114
|
+
// Third-party
|
|
88
115
|
const formidable = require("formidable");
|
|
89
116
|
exports.formidable = formidable;
|
|
90
117
|
//# sourceMappingURL=api.js.map
|
package/lib/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";;;
|
|
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;AAE/B,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;AAE3B,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;AAElB,cAAc;AACd,yCAAyC;AACjC,gCAAU"}
|
package/lib/instance.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
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
|
+
*/
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.getInstance = exports.setInstance = void 0;
|
|
4
19
|
let instance;
|
package/lib/instance.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instance.js","sourceRoot":"","sources":["../src/instance.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"instance.js","sourceRoot":"","sources":["../src/instance.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;EAcE;;;AAIF,IAAI,QAAqB,CAAC;AAE1B,IAAI,WAAW,GAAG,CAAC,GAAgB,EAAQ,EAAE;IACzC,IAAI,QAAQ,EAAE;QACV,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,qBAAqB,EAAE,uCAAuC,CAAC,CAAC;KAC7F;IACD,QAAQ,GAAG,GAAG,CAAC;AACnB,CAAC,CAAC;AAOE,kCAAW;AALf,IAAI,WAAW,GAAG,GAAgB,EAAE;IAChC,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAC;AAIE,kCAAW"}
|
|
@@ -1,4 +1,19 @@
|
|
|
1
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
|
+
*/
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.CommitQuery = void 0;
|
|
4
19
|
const Query_1 = require("../Query");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommitQuery.js","sourceRoot":"","sources":["../../src/private/CommitQuery.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"CommitQuery.js","sourceRoot":"","sources":["../../src/private/CommitQuery.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;EAcE;;;AAEF,oCAA+B;AAE/B,MAAa,WAAY,SAAQ,aAAiB;IACpC,SAAS;QACf,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ;AAJD,kCAIC"}
|
|
@@ -1,4 +1,19 @@
|
|
|
1
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
|
+
*/
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.RollbackQuery = void 0;
|
|
4
19
|
const Query_1 = require("../Query");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RollbackQuery.js","sourceRoot":"","sources":["../../src/private/RollbackQuery.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"RollbackQuery.js","sourceRoot":"","sources":["../../src/private/RollbackQuery.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;EAcE;;;AAEF,oCAA+B;AAE/B,MAAa,aAAc,SAAQ,aAAiB;IACtC,SAAS;QACf,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ;AAJD,sCAIC"}
|
|
@@ -1,4 +1,19 @@
|
|
|
1
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
|
+
*/
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.StartTransactionQuery = void 0;
|
|
4
19
|
const Query_1 = require("../Query");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StartTransactionQuery.js","sourceRoot":"","sources":["../../src/private/StartTransactionQuery.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"StartTransactionQuery.js","sourceRoot":"","sources":["../../src/private/StartTransactionQuery.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;EAcE;;;AAEF,oCAA+B;AAE/B,MAAa,qBAAsB,SAAQ,aAAiB;IAC9C,SAAS;QACf,OAAO,mBAAmB,CAAC;IAC/B,CAAC;CACJ;AAJD,sDAIC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@breautek/storm",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Object-Oriented REST API framework",
|
|
5
5
|
"main": "lib/api.js",
|
|
6
6
|
"types": "lib/api.d.ts",
|
|
@@ -40,12 +40,11 @@
|
|
|
40
40
|
"node": ">= 12.0.0"
|
|
41
41
|
},
|
|
42
42
|
"author": "norman@normanbreau.com",
|
|
43
|
-
"license": "
|
|
43
|
+
"license": "Apache-2.0",
|
|
44
44
|
"homepage": "https://github.com/breautek/storm.git",
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@arashi/token": "1.0.1",
|
|
47
47
|
"@breautek/merge-change": "1.0.0",
|
|
48
|
-
"@totalpave/interfaces": "3.0.0",
|
|
49
48
|
"@types/body-parser": "1.19.2",
|
|
50
49
|
"@types/express": "4.17.13",
|
|
51
50
|
"@types/formidable": "1.2.3",
|
|
@@ -53,16 +52,16 @@
|
|
|
53
52
|
"@types/mysql": "2.15.21",
|
|
54
53
|
"@types/node": "16.11.26",
|
|
55
54
|
"@types/uuid": "8.3.4",
|
|
56
|
-
"ajv": "8.
|
|
57
|
-
"body-parser": "1.
|
|
55
|
+
"ajv": "8.11.0",
|
|
56
|
+
"body-parser": "1.20.0",
|
|
58
57
|
"commander": "8.3.0",
|
|
59
|
-
"express": "4.
|
|
58
|
+
"express": "4.18.1",
|
|
60
59
|
"form-data": "4.0.0",
|
|
61
60
|
"formidable": "1.2.2",
|
|
62
61
|
"jsonwebtoken": "8.5.1",
|
|
63
62
|
"mysql": "2.18.1",
|
|
64
63
|
"sql-formatter": "4.0.2",
|
|
65
|
-
"tslib": "2.
|
|
64
|
+
"tslib": "2.4.0",
|
|
66
65
|
"uuid": "8.3.2"
|
|
67
66
|
},
|
|
68
67
|
"peerDependencies": {
|
|
@@ -70,17 +69,17 @@
|
|
|
70
69
|
},
|
|
71
70
|
"devDependencies": {
|
|
72
71
|
"@arashi/logger": "2.1.0",
|
|
73
|
-
"@totalpave/eslint-plugin": "6.0.
|
|
74
|
-
"@types/jest": "27.
|
|
75
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
76
|
-
"@typescript-eslint/parser": "5.
|
|
72
|
+
"@totalpave/eslint-plugin": "6.0.2",
|
|
73
|
+
"@types/jest": "27.5.1",
|
|
74
|
+
"@typescript-eslint/eslint-plugin": "5.27.0",
|
|
75
|
+
"@typescript-eslint/parser": "5.27.0",
|
|
77
76
|
"auto-changelog": "2.4.0",
|
|
78
|
-
"eslint": "8.
|
|
77
|
+
"eslint": "8.16.0",
|
|
79
78
|
"jest": "27.5.1",
|
|
80
79
|
"ts-jest": "27.1.3",
|
|
81
|
-
"ts-node": "10.
|
|
82
|
-
"typedoc": "0.22.
|
|
83
|
-
"typedoc-plugin-markdown": "3.
|
|
84
|
-
"typescript": "4.
|
|
80
|
+
"ts-node": "10.8.0",
|
|
81
|
+
"typedoc": "0.22.17",
|
|
82
|
+
"typedoc-plugin-markdown": "3.12.1",
|
|
83
|
+
"typescript": "4.7.2"
|
|
85
84
|
}
|
|
86
85
|
}
|
package/src/Database.ts
CHANGED
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { IDictionary } from '@totalpave/interfaces';
|
|
18
17
|
import * as UUID from 'uuid';
|
|
19
18
|
import {DatabaseConnection} from './DatabaseConnection';
|
|
20
19
|
import { getInstance } from './instance';
|
|
@@ -23,7 +22,7 @@ const MASTER_NAME: string = 'MASTER';
|
|
|
23
22
|
const TAG: string = 'Database';
|
|
24
23
|
|
|
25
24
|
export abstract class Database<TDatabaseConfig, TConnectionAPI> {
|
|
26
|
-
private $clusterConfigMap:
|
|
25
|
+
private $clusterConfigMap: Record<any, any>;
|
|
27
26
|
|
|
28
27
|
constructor() {
|
|
29
28
|
this.$clusterConfigMap = {};
|
|
@@ -21,7 +21,6 @@ import {Readable} from 'stream';
|
|
|
21
21
|
import {IDatabaseConnection} from './IDatabaseConnection';
|
|
22
22
|
import {Query} from './Query';
|
|
23
23
|
import { IConfig } from './IConfig';
|
|
24
|
-
import { IDictionary } from '@totalpave/interfaces';
|
|
25
24
|
|
|
26
25
|
export const LINGER_WARNING: number = 10000;
|
|
27
26
|
export const DEFAULT_QUERY_TIMEOUT: number = 3600000;
|
|
@@ -134,7 +133,7 @@ export abstract class DatabaseConnection<TAPI> implements IDatabaseConnection {
|
|
|
134
133
|
|
|
135
134
|
let queryStr: string = null;
|
|
136
135
|
queryStr = query.getQuery(this);
|
|
137
|
-
let params:
|
|
136
|
+
let params: Record<any, any> = query.getParametersForQuery();
|
|
138
137
|
|
|
139
138
|
await query.onPreQuery(this);
|
|
140
139
|
let results: TQueryResult = await this._query<TQueryResult>(queryStr, params);
|
|
@@ -152,7 +151,7 @@ export abstract class DatabaseConnection<TAPI> implements IDatabaseConnection {
|
|
|
152
151
|
public stream(query: Query, streamOptions?: any): Readable {
|
|
153
152
|
this.$armLingerWarning();
|
|
154
153
|
let queryStr: string = null;
|
|
155
|
-
let params:
|
|
154
|
+
let params: Record<any, any> = query.getParametersForQuery();
|
|
156
155
|
queryStr = query.getQuery(this);
|
|
157
156
|
return this._stream(queryStr, params, streamOptions);
|
|
158
157
|
}
|
package/src/Handler.ts
CHANGED
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {StatusCode} from './StatusCode';
|
|
18
17
|
import {Application} from './Application';
|
|
19
18
|
import {getInstance} from './instance';
|
|
20
19
|
import {Request} from './Request';
|
|
@@ -27,6 +26,8 @@ import { IRequestResponse } from './IRequestResponse';
|
|
|
27
26
|
import { Logger } from '@arashi/logger';
|
|
28
27
|
import { ResponseData } from './ResponseData';
|
|
29
28
|
import { ReadStream } from 'fs';
|
|
29
|
+
import { NotImplementedError } from './NotImplementedError';
|
|
30
|
+
import { HTTPMethod } from './HTTPMethod';
|
|
30
31
|
// import { Stream } from 'stream';
|
|
31
32
|
|
|
32
33
|
const TAG: string = 'Handler';
|
|
@@ -199,19 +200,19 @@ export class Handler<
|
|
|
199
200
|
}
|
|
200
201
|
}
|
|
201
202
|
|
|
202
|
-
protected async _get(request: Request<TGetRequest>): Promise<TGetResponse
|
|
203
|
-
|
|
203
|
+
protected async _get(request: Request<TGetRequest>): Promise<TGetResponse> {
|
|
204
|
+
throw new NotImplementedError(HTTPMethod.GET);
|
|
204
205
|
}
|
|
205
206
|
|
|
206
|
-
protected async _post(request: Request<TPostRequest>): Promise<TPostResponse
|
|
207
|
-
|
|
207
|
+
protected async _post(request: Request<TPostRequest>): Promise<TPostResponse> {
|
|
208
|
+
throw new NotImplementedError(HTTPMethod.POST);
|
|
208
209
|
}
|
|
209
210
|
|
|
210
|
-
protected async _put(request: Request<TPutRequest>): Promise<TPutResponse
|
|
211
|
-
|
|
211
|
+
protected async _put(request: Request<TPutRequest>): Promise<TPutResponse> {
|
|
212
|
+
throw new NotImplementedError(HTTPMethod.PUT);
|
|
212
213
|
}
|
|
213
214
|
|
|
214
|
-
protected async _delete(request: Request<TDeleteRequest>): Promise<TDeleteResponse
|
|
215
|
-
|
|
215
|
+
protected async _delete(request: Request<TDeleteRequest>): Promise<TDeleteResponse> {
|
|
216
|
+
throw new NotImplementedError(HTTPMethod.DELETE);
|
|
216
217
|
}
|
|
217
218
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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 {StormError} from './StormError';
|
|
18
|
+
import {ErrorCode} from './ErrorCode';
|
|
19
|
+
import {StatusCode} from './StatusCode';
|
|
20
|
+
import {HTTPMethod} from './HTTPMethod';
|
|
21
|
+
|
|
22
|
+
interface INotImplementedErrorOptions {
|
|
23
|
+
method: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class NotImplementedError extends StormError<INotImplementedErrorOptions> {
|
|
27
|
+
public constructor(method: HTTPMethod) {
|
|
28
|
+
super({
|
|
29
|
+
method
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public getMessage(): string {
|
|
34
|
+
let details: INotImplementedErrorOptions = this.getPrivateDetails();
|
|
35
|
+
return `Handler does not implement "${details.method}".`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public getCode(): ErrorCode {
|
|
39
|
+
return ErrorCode.INTERNAL;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public getHTTPCode(): StatusCode {
|
|
43
|
+
return StatusCode.INTERNAL_NOT_IMPLEMENTED;
|
|
44
|
+
}
|
|
45
|
+
}
|
package/src/Query.ts
CHANGED
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { IDictionary } from '@totalpave/interfaces';
|
|
18
17
|
import { IDatabaseConnection } from './IDatabaseConnection';
|
|
19
18
|
|
|
20
19
|
export abstract class Query<TQueryParameters = any, TQueryResultSet = any, TQueryPostProcessedResultSet = TQueryResultSet> {
|
|
@@ -24,11 +23,19 @@ export abstract class Query<TQueryParameters = any, TQueryResultSet = any, TQuer
|
|
|
24
23
|
this.$params = parameters;
|
|
25
24
|
}
|
|
26
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @returns parameters that was passed into the constructor.
|
|
28
|
+
*/
|
|
27
29
|
public getParameters(): TQueryParameters {
|
|
28
30
|
return this.$params;
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Query implementations may override this API to augment the parameters.
|
|
35
|
+
*
|
|
36
|
+
* @returns parameters that will be used when this query is ran.
|
|
37
|
+
*/
|
|
38
|
+
public getParametersForQuery(): Record<any, any> {
|
|
32
39
|
return this.$params;
|
|
33
40
|
}
|
|
34
41
|
|
package/src/RawError.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
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 { StormError } from './StormError';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A concrete error that accepts any arbitrary message string and optionally a code.
|
|
21
|
+
* It's not recommended to use this class as it will be hard to differentiate errors by
|
|
22
|
+
* tag name.
|
|
23
|
+
*/
|
|
24
|
+
export class RawError extends StormError<{message: string, code?: number}> {
|
|
25
|
+
public constructor(message: string, code?: number) {
|
|
26
|
+
super({
|
|
27
|
+
message,
|
|
28
|
+
code: code || 0
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public getCode(): number {
|
|
33
|
+
return this.getPrivateDetails().code;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public getMessage(): string {
|
|
37
|
+
return this.getPrivateDetails().message;
|
|
38
|
+
}
|
|
39
|
+
}
|
package/src/RawQuery.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import {Query} from './Query';
|
|
18
18
|
|
|
19
|
-
export class RawQuery<TQueryParameters = any, TQueryResultSet = any> extends Query<TQueryParameters, TQueryResultSet,
|
|
19
|
+
export class RawQuery<TQueryParameters = any, TQueryResultSet = any, TQueryPostProcessedResultSet = TQueryResultSet> extends Query<TQueryParameters, TQueryResultSet, TQueryPostProcessedResultSet> {
|
|
20
20
|
private $query: string;
|
|
21
21
|
|
|
22
22
|
public constructor(query: string, parameters?: TQueryParameters) {
|
package/src/ServiceProvider.ts
CHANGED
|
@@ -19,7 +19,6 @@ import {IServiceHeaders} from './IServiceHeaders';
|
|
|
19
19
|
import {HTTPMethod} from './HTTPMethod';
|
|
20
20
|
import {ServiceResponse} from './ServiceResponse';
|
|
21
21
|
import * as http from 'http';
|
|
22
|
-
import { IDictionary } from '@totalpave/interfaces';
|
|
23
22
|
|
|
24
23
|
const TAG: string = 'ServiceProvider';
|
|
25
24
|
const NO_DATA: string = `|${0x0}|`;
|
|
@@ -62,7 +61,7 @@ export abstract class ServiceProvider {
|
|
|
62
61
|
return 'v1';
|
|
63
62
|
}
|
|
64
63
|
|
|
65
|
-
protected _createURL(url: string, queryParams?:
|
|
64
|
+
protected _createURL(url: string, queryParams?: Record<any, any>): string {
|
|
66
65
|
let queryString: string = '';
|
|
67
66
|
|
|
68
67
|
if (queryParams) {
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import {
|
|
3
3
|
Query
|
|
4
4
|
} from './Query';
|
|
5
|
-
import { IDictionary } from '@totalpave/interfaces';
|
|
6
5
|
|
|
7
6
|
export interface ISetSessionVariableQueryInput {
|
|
8
7
|
name: string;
|
|
@@ -21,7 +20,7 @@ export class SetSessionVariableQuery extends Query<ISetSessionVariableQueryInput
|
|
|
21
20
|
return `SET SESSION ${params.name} = :value`;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
public getParametersForQuery():
|
|
23
|
+
public getParametersForQuery(): Record<any, any> {
|
|
25
24
|
return {
|
|
26
25
|
value: this.getParameters().value
|
|
27
26
|
};
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { IDictionary } from '@totalpave/interfaces';
|
|
18
17
|
import { IDatabaseConnection } from './IDatabaseConnection';
|
|
19
18
|
import {Query} from './Query';
|
|
20
19
|
|
|
@@ -25,8 +24,8 @@ export interface ITemporaryTableQueryInput {
|
|
|
25
24
|
|
|
26
25
|
export class TemporaryTableQuery extends Query<any> {
|
|
27
26
|
|
|
28
|
-
public getParametersForQuery():
|
|
29
|
-
let params:
|
|
27
|
+
public getParametersForQuery(): Record<any, any> {
|
|
28
|
+
let params: Record<any, any> = this.getParameters();
|
|
30
29
|
return {
|
|
31
30
|
...params.selectQuery.getParametersForQuery(),
|
|
32
31
|
tableName: params.tableName
|
package/src/api.ts
CHANGED
|
@@ -38,6 +38,7 @@ export {SetSessionVariableQuery, ISetSessionVariableQueryInput} from './SetSessi
|
|
|
38
38
|
|
|
39
39
|
// Errors
|
|
40
40
|
export {ErrorCode} from './ErrorCode';
|
|
41
|
+
export {RawError} from './RawError';
|
|
41
42
|
export {
|
|
42
43
|
StormError,
|
|
43
44
|
IErrorResponse,
|
|
@@ -55,6 +56,7 @@ export {DiskSpaceError} from './DiskSpaceError';
|
|
|
55
56
|
export {DuplicateEntryError} from './DuplicateEntryError';
|
|
56
57
|
export {MissingConfigError} from './MissingConfigError';
|
|
57
58
|
export {DatabaseQueryError} from './DatabaseQueryError';
|
|
59
|
+
export {NotImplementedError} from './NotImplementedError';
|
|
58
60
|
|
|
59
61
|
// HTTP
|
|
60
62
|
export {StatusCode} from './StatusCode';
|