@breautek/storm 4.1.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 +8 -1
- package/docs/README.md +6 -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/DatabaseConnection.md +19 -19
- package/docs/classes/DatabaseQueryError.md +8 -8
- package/docs/classes/DiskSpaceError.md +8 -8
- package/docs/classes/DropTemporaryTableQuery.md +14 -8
- package/docs/classes/DumpStream.md +1 -1
- package/docs/classes/DuplicateEntryError.md +8 -8
- package/docs/classes/EntityNotFoundError.md +8 -8
- package/docs/classes/ExpiredTokenError.md +8 -8
- package/docs/classes/Handler.md +22 -22
- package/docs/classes/InternalError.md +8 -8
- package/docs/classes/InvalidCredentialsError.md +8 -8
- package/docs/classes/InvalidValueError.md +8 -8
- package/docs/classes/ManagedDatabaseConnection.md +19 -19
- package/docs/classes/Middleware.md +3 -3
- package/docs/classes/MissingConfigError.md +8 -8
- package/docs/classes/MissingParameterError.md +8 -8
- package/docs/classes/MySQLConnection.md +20 -20
- package/docs/classes/MySQLDatabase.md +13 -13
- package/docs/classes/NotImplementedError.md +301 -0
- package/docs/classes/Query.md +14 -8
- package/docs/classes/RawError.md +313 -0
- package/docs/classes/RawQuery.md +14 -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 +14 -8
- package/docs/classes/StormError.md +12 -8
- package/docs/classes/TemporaryTableQuery.md +14 -8
- package/docs/classes/Token.md +2 -2
- package/docs/classes/TokenManager.md +4 -4
- package/docs/classes/UnauthorizedAccessError.md +8 -8
- package/docs/enums/ErrorCode.md +9 -9
- package/docs/enums/ExitCode.md +2 -2
- package/docs/enums/HTTPMethod.md +4 -4
- 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 +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/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 +21 -0
- 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.js +15 -0
- package/lib/RawQuery.js.map +1 -1
- package/lib/Request.js +15 -0
- package/lib/Request.js.map +1 -1
- 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.js +20 -0
- package/lib/ServiceProvider.js.map +1 -1
- package/lib/ServiceResponse.js +15 -0
- package/lib/ServiceResponse.js.map +1 -1
- 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.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 +1 -1
- package/src/Handler.ts +10 -9
- package/src/NotImplementedError.ts +45 -0
- package/src/Query.ts +8 -0
- package/src/RawError.ts +39 -0
- package/src/api.ts +2 -0
- package/tsconfig.json +0 -1
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
|
@@ -23,10 +23,18 @@ export abstract class Query<TQueryParameters = any, TQueryResultSet = any, TQuer
|
|
|
23
23
|
this.$params = parameters;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @returns parameters that was passed into the constructor.
|
|
28
|
+
*/
|
|
26
29
|
public getParameters(): TQueryParameters {
|
|
27
30
|
return this.$params;
|
|
28
31
|
}
|
|
29
32
|
|
|
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
|
+
*/
|
|
30
38
|
public getParametersForQuery(): Record<any, any> {
|
|
31
39
|
return this.$params;
|
|
32
40
|
}
|
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/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';
|