@breautek/storm 8.1.4 → 8.3.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.
Files changed (107) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/docs/assets/hierarchy.js +1 -1
  3. package/docs/assets/main.js +4 -4
  4. package/docs/assets/search.js +1 -1
  5. package/docs/assets/style.css +5 -4
  6. package/docs/classes/Application.html +144 -143
  7. package/docs/classes/BackendAuthenticationMiddleware.html +5 -5
  8. package/docs/classes/CORSMiddleware.html +10 -10
  9. package/docs/classes/ConfigLoader.html +5 -5
  10. package/docs/classes/Database.html +13 -13
  11. package/docs/classes/DatabaseCastObject.html +5 -5
  12. package/docs/classes/DatabaseConnection.html +41 -41
  13. package/docs/classes/DatabaseQueryError.html +22 -22
  14. package/docs/classes/DeadLockError.html +23 -23
  15. package/docs/classes/DiskSpaceError.html +22 -22
  16. package/docs/classes/DropTemporaryTableQuery.html +19 -13
  17. package/docs/classes/DuplicateEntryError.html +22 -22
  18. package/docs/classes/EntityNotFoundError.html +22 -22
  19. package/docs/classes/ExpiredTokenError.html +22 -22
  20. package/docs/classes/Handler.html +14 -14
  21. package/docs/classes/InternalError.html +22 -22
  22. package/docs/classes/InvalidCredentialsError.html +22 -22
  23. package/docs/classes/InvalidValueError.html +22 -22
  24. package/docs/classes/LineString.html +5 -5
  25. package/docs/classes/LockWaitTimeoutError.html +23 -23
  26. package/docs/classes/ManagedDatabaseConnection.html +22 -22
  27. package/docs/classes/Middleware.html +4 -4
  28. package/docs/classes/MissingConfigError.html +22 -22
  29. package/docs/classes/MissingParameterError.html +22 -22
  30. package/docs/classes/MySQLConnection.html +46 -46
  31. package/docs/classes/MySQLDatabase.html +14 -14
  32. package/docs/classes/NotImplementedError.html +22 -22
  33. package/docs/classes/Point.html +5 -5
  34. package/docs/classes/Polygon.html +5 -5
  35. package/docs/classes/Query.html +19 -13
  36. package/docs/classes/RawError.html +23 -23
  37. package/docs/classes/RawQuery.html +19 -13
  38. package/docs/classes/Request.html +19 -19
  39. package/docs/classes/Response.html +12 -12
  40. package/docs/classes/ResponseData.html +8 -8
  41. package/docs/classes/ServiceProvider.html +16 -16
  42. package/docs/classes/ServiceResponse.html +6 -6
  43. package/docs/classes/SetSessionVariableQuery.html +19 -13
  44. package/docs/classes/StormError.html +22 -22
  45. package/docs/classes/TemporaryTableQuery.html +19 -13
  46. package/docs/classes/TimeoutError.html +23 -23
  47. package/docs/classes/Token.html +3 -3
  48. package/docs/classes/TokenManager.html +5 -5
  49. package/docs/classes/Transaction.html +9 -8
  50. package/docs/classes/UnauthorizedAccessError.html +22 -22
  51. package/docs/enums/ErrorCode.html +10 -10
  52. package/docs/enums/ExitCode.html +3 -3
  53. package/docs/enums/HTTPMethod.html +5 -5
  54. package/docs/enums/IsolationLevel.html +5 -5
  55. package/docs/enums/JWTError.html +3 -3
  56. package/docs/enums/StatusCode.html +49 -49
  57. package/docs/functions/getInstance.html +2 -2
  58. package/docs/hierarchy.html +1 -1
  59. package/docs/index.html +1 -1
  60. package/docs/interfaces/IAdditionalErrorDetails.html +1 -1
  61. package/docs/interfaces/IAuthTokenData.html +4 -4
  62. package/docs/interfaces/ICloudwatchConfig.html +4 -4
  63. package/docs/interfaces/ICloudwatchCredentials.html +3 -3
  64. package/docs/interfaces/ICloudwatchStreamConfig.html +3 -3
  65. package/docs/interfaces/IConfig.html +10 -10
  66. package/docs/interfaces/IDatabaseConfig.html +7 -7
  67. package/docs/interfaces/IDatabaseConnection.html +17 -17
  68. package/docs/interfaces/IDatabasePosition.html +4 -4
  69. package/docs/interfaces/IErrorResponse.html +6 -6
  70. package/docs/interfaces/IFormData.html +3 -3
  71. package/docs/interfaces/IHandler.html +2 -2
  72. package/docs/interfaces/IInsertQueryResult.html +4 -4
  73. package/docs/interfaces/IJWTVerifyOptions.html +2 -2
  74. package/docs/interfaces/IOKPacket.html +10 -10
  75. package/docs/interfaces/IParameterMap.html +1 -1
  76. package/docs/interfaces/IQueryable.html +7 -6
  77. package/docs/interfaces/IRequestResponse.html +3 -3
  78. package/docs/interfaces/IServiceHeaders.html +1 -1
  79. package/docs/interfaces/ISetSessionVariableQueryInput.html +3 -3
  80. package/docs/interfaces/IStormCLIArgs.html +7 -7
  81. package/docs/interfaces/ITemporaryTableQueryInput.html +3 -3
  82. package/docs/interfaces/IUpdateQueryResult.html +3 -3
  83. package/docs/modules/formidable.html +1 -1
  84. package/docs/types/IDeleteQueryResult.html +1 -1
  85. package/docs/types/IHandlerError.html +2 -2
  86. package/docs/types/IHandlerResponse.html +2 -2
  87. package/docs/types/IStoredProcedureResult.html +3 -3
  88. package/docs/types/TCoordinate.html +1 -1
  89. package/docs/variables/formidable-1.html +1 -1
  90. package/lib/Application.d.ts +1 -0
  91. package/lib/Application.js +3 -0
  92. package/lib/Application.js.map +1 -1
  93. package/lib/DatabaseConnection.js +14 -2
  94. package/lib/DatabaseConnection.js.map +1 -1
  95. package/lib/IQueryable.d.ts +1 -0
  96. package/lib/Query.d.ts +13 -0
  97. package/lib/Query.js +15 -0
  98. package/lib/Query.js.map +1 -1
  99. package/lib/Transaction.d.ts +1 -0
  100. package/lib/Transaction.js +1 -0
  101. package/lib/Transaction.js.map +1 -1
  102. package/package.json +7 -7
  103. package/src/Application.ts +4 -0
  104. package/src/DatabaseConnection.ts +18 -2
  105. package/src/IQueryable.ts +1 -0
  106. package/src/Query.ts +16 -0
  107. package/src/Transaction.ts +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@breautek/storm",
3
- "version": "8.1.4",
3
+ "version": "8.3.0",
4
4
  "description": "Object-Oriented REST API framework",
5
5
  "main": "lib/api.js",
6
6
  "types": "lib/api.d.ts",
@@ -51,17 +51,17 @@
51
51
  "@types/formidable": "3.4.5",
52
52
  "@types/jsonwebtoken": "9.0.7",
53
53
  "@types/mysql": "2.15.26",
54
- "@types/node": "22.10.1",
54
+ "@types/node": "22.13.4",
55
55
  "@types/uuid": "10.0.0",
56
56
  "ajv": "8.17.1",
57
57
  "body-parser": "1.20.3",
58
58
  "commander": "12.1.0",
59
59
  "express": "4.21.2",
60
- "form-data": "4.0.1",
60
+ "form-data": "4.0.2",
61
61
  "formidable": "3.5.2",
62
62
  "jsonwebtoken": "9.0.2",
63
63
  "mysql": "2.18.1",
64
- "sql-formatter": "15.4.6",
64
+ "sql-formatter": "15.4.10",
65
65
  "tslib": "2.8.1",
66
66
  "uuid": "11.0.3"
67
67
  },
@@ -71,7 +71,7 @@
71
71
  },
72
72
  "devDependencies": {
73
73
  "@arashi/interfaces": "1.2.1",
74
- "@arashi/logger": "4.0.7",
74
+ "@arashi/logger": "4.1.3",
75
75
  "@totalpave/eslint-plugin": "6.3.2",
76
76
  "@types/jest": "29.5.14",
77
77
  "@typescript-eslint/eslint-plugin": "7.18.0",
@@ -82,8 +82,8 @@
82
82
  "jest-jasmine2": "29.7.0",
83
83
  "ts-jest": "29.2.5",
84
84
  "ts-node": "10.9.2",
85
- "typedoc": "0.27.4",
86
- "typedoc-plugin-markdown": "4.3.2",
85
+ "typedoc": "0.27.7",
86
+ "typedoc-plugin-markdown": "4.4.2",
87
87
  "typescript": "5.6.3"
88
88
  }
89
89
  }
@@ -290,6 +290,10 @@ export abstract class Application
290
290
  return port;
291
291
  }
292
292
 
293
+ public getVersion(): string {
294
+ return this._getVersion();
295
+ }
296
+
293
297
  protected _getVersion(): string {
294
298
  console.warn(TAG, `_getVersion will be an abstract method in the next major release. Override this method and pass a version string.`);
295
299
  return '0.0.0';
@@ -138,8 +138,24 @@ export abstract class DatabaseConnection<TAPI> implements IDatabaseConnection {
138
138
  let params: Record<string, any> = query.getParametersForQuery();
139
139
 
140
140
  await query.onPreQuery(this);
141
- let results: TQueryResult = await this._query<TQueryResult>(queryStr, params);
142
- return await (<any>query.onPostProcess(this, <any>results));
141
+
142
+ let out: TQueryResult = null;
143
+ let e: unknown = null;
144
+ try {
145
+ let results: TQueryResult = await this._query<TQueryResult>(queryStr, params);
146
+ out = await (<any>query.onPostProcess(this, <any>results));
147
+ }
148
+ catch (ex) {
149
+ e = ex;
150
+ }
151
+
152
+ await query.onPostQuery(this);
153
+
154
+ if (e !== null) {
155
+ throw e;
156
+ }
157
+
158
+ return out;
143
159
  }
144
160
 
145
161
  /**
package/src/IQueryable.ts CHANGED
@@ -18,6 +18,7 @@ import { IDatabaseConnection } from './IDatabaseConnection';
18
18
 
19
19
  export interface IQueryable<T> {
20
20
  onPreQuery(connection: IDatabaseConnection): Promise<void>;
21
+ onPostQuery(connection: IDatabaseConnection): Promise<void>;
21
22
  getQuery(connection: IDatabaseConnection): string;
22
23
  execute(connection: IDatabaseConnection): Promise<T>;
23
24
  getParametersForQuery(): Record<string, any>;
package/src/Query.ts CHANGED
@@ -57,6 +57,22 @@ export abstract class Query<TQueryParameters = any, TQueryResultSet = any, TQuer
57
57
  return Promise.resolve();
58
58
  }
59
59
 
60
+ /**
61
+ * Overridable to execute statements after the main query.
62
+ * Can be used to clean up session variables or temporary tables, etc
63
+ *
64
+ * Unlike {@link onPostProcess}, this hook does not provide the result set,
65
+ * and will be invoked even if the main query produces an error.
66
+ *
67
+ * @since 8.3.0
68
+ *
69
+ * @param connection
70
+ * @returns {void}
71
+ */
72
+ public onPostQuery(connection: IDatabaseConnection): Promise<void> {
73
+ return Promise.resolve();
74
+ }
75
+
60
76
  /**
61
77
  * Override to augment/manipulate the returned result set.
62
78
  *
@@ -60,6 +60,7 @@ export class Transaction implements IQueryable<void> {
60
60
  }
61
61
 
62
62
  public async onPreQuery(connection: IDatabaseConnection): Promise<void> {}
63
+ public async onPostQuery(connection: IDatabaseConnection): Promise<void> {}
63
64
 
64
65
  public getQuery(connection: IDatabaseConnection): string {
65
66
  return null;