@breautek/storm 9.0.4 → 9.0.6

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 (120) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/docs/assets/hierarchy.js +1 -1
  3. package/docs/assets/search.js +1 -1
  4. package/docs/classes/Application.html +45 -45
  5. package/docs/classes/ConfigLoader.html +3 -3
  6. package/docs/classes/Database.html +2 -2
  7. package/docs/classes/DatabaseCastObject.html +2 -2
  8. package/docs/classes/DatabaseConnection.html +21 -21
  9. package/docs/classes/DatabaseQueryError.html +8 -8
  10. package/docs/classes/DeadLockError.html +8 -8
  11. package/docs/classes/DiskSpaceError.html +7 -7
  12. package/docs/classes/DropTemporaryTableQuery.html +7 -7
  13. package/docs/classes/DuplicateEntryError.html +7 -7
  14. package/docs/classes/EntityNotFoundError.html +7 -7
  15. package/docs/classes/ExpiredTokenError.html +7 -7
  16. package/docs/classes/Handler.html +2 -2
  17. package/docs/classes/InternalError.html +7 -7
  18. package/docs/classes/InvalidCredentialsError.html +7 -7
  19. package/docs/classes/InvalidValueError.html +7 -7
  20. package/docs/classes/LineString.html +2 -2
  21. package/docs/classes/LockWaitTimeoutError.html +8 -8
  22. package/docs/classes/ManagedDatabaseConnection.html +5 -5
  23. package/docs/classes/Middleware.html +2 -2
  24. package/docs/classes/MissingConfigError.html +7 -7
  25. package/docs/classes/MissingParameterError.html +7 -7
  26. package/docs/classes/MySQLConnection.html +25 -25
  27. package/docs/classes/MySQLDatabase.html +2 -2
  28. package/docs/classes/NotImplementedError.html +7 -7
  29. package/docs/classes/Point.html +2 -2
  30. package/docs/classes/Polygon.html +2 -2
  31. package/docs/classes/Query.html +7 -7
  32. package/docs/classes/RawError.html +7 -7
  33. package/docs/classes/RawQuery.html +7 -7
  34. package/docs/classes/Request.html +6 -2
  35. package/docs/classes/Response.html +2 -2
  36. package/docs/classes/ResponseData.html +5 -2
  37. package/docs/classes/ServiceProvider.html +2 -2
  38. package/docs/classes/ServiceResponse.html +2 -2
  39. package/docs/classes/SetSessionVariableQuery.html +7 -7
  40. package/docs/classes/StormError.html +7 -7
  41. package/docs/classes/TemporaryTableQuery.html +7 -7
  42. package/docs/classes/TimeoutError.html +7 -7
  43. package/docs/classes/Token.html +2 -2
  44. package/docs/classes/TokenManager.html +2 -2
  45. package/docs/classes/Transaction.html +2 -2
  46. package/docs/classes/UnauthorizedAccessError.html +7 -7
  47. package/docs/enums/ErrorCode.html +2 -2
  48. package/docs/enums/ExitCode.html +2 -2
  49. package/docs/enums/HTTPMethod.html +2 -2
  50. package/docs/enums/IsolationLevel.html +2 -2
  51. package/docs/enums/JWTError.html +2 -2
  52. package/docs/enums/StatusCode.html +2 -2
  53. package/docs/enums/TransactionAccessLevel.html +2 -2
  54. package/docs/functions/getInstance.html +1 -1
  55. package/docs/hierarchy.html +1 -1
  56. package/docs/interfaces/IAdditionalErrorDetails.html +1 -1
  57. package/docs/interfaces/IAuthTokenData.html +2 -2
  58. package/docs/interfaces/ICloudwatchConfig.html +2 -2
  59. package/docs/interfaces/ICloudwatchCredentials.html +2 -2
  60. package/docs/interfaces/ICloudwatchStreamConfig.html +2 -2
  61. package/docs/interfaces/IConfig.html +2 -2
  62. package/docs/interfaces/IDatabaseConfig.html +2 -2
  63. package/docs/interfaces/IDatabaseConnection.html +5 -5
  64. package/docs/interfaces/IDatabasePosition.html +2 -2
  65. package/docs/interfaces/IErrorResponse.html +2 -2
  66. package/docs/interfaces/IFormData.html +2 -2
  67. package/docs/interfaces/IInsertQueryResult.html +2 -2
  68. package/docs/interfaces/IJWTVerifyOptions.html +2 -2
  69. package/docs/interfaces/IOKPacket.html +2 -2
  70. package/docs/interfaces/IParameterMap.html +1 -1
  71. package/docs/interfaces/IQueryable.html +2 -2
  72. package/docs/interfaces/IRequestResponse.html +2 -2
  73. package/docs/interfaces/ISetSessionVariableQueryInput.html +2 -2
  74. package/docs/interfaces/IStormCLIArgs.html +2 -2
  75. package/docs/interfaces/ITemporaryTableQueryInput.html +2 -2
  76. package/docs/interfaces/IUpdateQueryResult.html +2 -2
  77. package/docs/interfaces/formidable.EmitData.html +2 -2
  78. package/docs/interfaces/formidable.EventData.html +2 -2
  79. package/docs/interfaces/formidable.File.html +9 -9
  80. package/docs/interfaces/formidable.FileJSON.html +7 -7
  81. package/docs/interfaces/formidable.Options.html +16 -16
  82. package/docs/interfaces/formidable.Part.html +17 -17
  83. package/docs/types/IDeleteQueryResult.html +1 -1
  84. package/docs/types/IStoredProcedureResult.html +1 -1
  85. package/docs/types/TCoordinate.html +1 -1
  86. package/docs/types/TSerializableResponse.html +1 -1
  87. package/docs/types/TSupportedResponsePrimitives.html +1 -1
  88. package/docs/types/TSupportedResponseTypes.html +1 -1
  89. package/docs/types/formidable.BufferEncoding.html +1 -1
  90. package/docs/types/formidable.DefaultOptions.html +1 -1
  91. package/docs/types/formidable.EnabledPlugins.html +1 -1
  92. package/docs/types/formidable.EventNames.html +1 -1
  93. package/docs/types/formidable.Fields.html +1 -1
  94. package/docs/types/formidable.Files.html +1 -1
  95. package/docs/types/formidable.MappedParsers.html +1 -1
  96. package/docs/types/formidable.Plugin.html +1 -1
  97. package/docs/types/formidable.PluginFunction.html +1 -1
  98. package/docs/types/formidable.Plugins.html +1 -1
  99. package/docs/variables/formidable.html +1 -1
  100. package/jest.config.js +2 -0
  101. package/lib/MySQLDatabase.js +5 -1
  102. package/lib/MySQLDatabase.js.map +1 -1
  103. package/lib/Request.d.ts +10 -1
  104. package/lib/Request.js +29 -0
  105. package/lib/Request.js.map +1 -1
  106. package/lib/ResponseData.d.ts +8 -0
  107. package/lib/ResponseData.js +16 -0
  108. package/lib/ResponseData.js.map +1 -1
  109. package/lib/private/ConnectionReplicationWaiter.js +3 -5
  110. package/lib/private/ConnectionReplicationWaiter.js.map +1 -1
  111. package/lib/private/GetSlavePositionQuery.d.ts +2 -2
  112. package/lib/private/GetSlavePositionQuery.js +3 -3
  113. package/lib/private/GetSlavePositionQuery.js.map +1 -1
  114. package/package.json +4 -4
  115. package/pnpm-workspace.yaml +6 -0
  116. package/src/MySQLDatabase.ts +8 -1
  117. package/src/Request.ts +38 -1
  118. package/src/ResponseData.ts +20 -0
  119. package/src/private/ConnectionReplicationWaiter.ts +3 -5
  120. package/src/private/GetSlavePositionQuery.ts +5 -5
@@ -1,3 +1,4 @@
1
+ import { IDatabasePosition } from './IDatabasePosition';
1
2
  import { StatusCode } from './StatusCode';
2
3
  export declare class ResponseData<TData = any> {
3
4
  private $status;
@@ -5,6 +6,13 @@ export declare class ResponseData<TData = any> {
5
6
  private $headers;
6
7
  private $redirect;
7
8
  constructor(status: StatusCode, data?: TData);
9
+ /**
10
+ * Sets the DB position response headers
11
+ *
12
+ * @since 9.1.0
13
+ * @param pos
14
+ */
15
+ setDatabasePosition(pos: IDatabasePosition | null): void;
8
16
  setHeader(name: string, value: string): void;
9
17
  getHeaders(): Map<string, string>;
10
18
  getStatus(): StatusCode;
@@ -23,6 +23,22 @@ class ResponseData {
23
23
  this.$data = data;
24
24
  this.$redirect = null;
25
25
  }
26
+ /**
27
+ * Sets the DB position response headers
28
+ *
29
+ * @since 9.1.0
30
+ * @param pos
31
+ */
32
+ setDatabasePosition(pos) {
33
+ let page = '0';
34
+ let position = '0';
35
+ if (pos) {
36
+ page = pos.page.toString();
37
+ position = pos.position.toString();
38
+ }
39
+ this.setHeader('X-DATABASE-PAGE', page);
40
+ this.setHeader('X-DATABASE-POSITION', position);
41
+ }
26
42
  setHeader(name, value) {
27
43
  this.$headers.set(name, value);
28
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ResponseData.js","sourceRoot":"","sources":["../src/ResponseData.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;EAcE;;;AAIF,MAAa,YAAY;IAMrB,YAAmB,MAAkB,EAAE,IAAY;QAC/C,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,I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AAI,CAAC,CAAC;QACxC,IAAI,CAAC,SAAS,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAAC;IACpD,CAAC;IAEM,SAAS,CAAC,IAAY,EAAE,KAAa;QACxC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;IAEM,UAAU;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAEM,SAAS;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAEM,OAAO;QACV,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAEM,QAAQ,CAAC,GAAW;QACvB,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC;IACzB,CAAC;IAEM,WAAW;QACd,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;CACJ;AAvDD,oCAuDC"}
@@ -16,7 +16,6 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.ConnectionReplicationWaiter = void 0;
19
- const InternalError_1 = require("../InternalError");
20
19
  const TimeoutError_1 = require("../TimeoutError");
21
20
  class ConnectionReplicationWaiter {
22
21
  constructor(conn, retryDelay = ConnectionReplicationWaiter.DEFAULT_RETRY_DELAY) {
@@ -45,10 +44,9 @@ class ConnectionReplicationWaiter {
45
44
  break;
46
45
  }
47
46
  let currentPos = await this.$conn.getCurrentDatabasePosition();
48
- // TODO: I have no idea what my intent is here, but it's obviously wrong
49
- // eslint-disable-next-line no-constant-binary-expression
50
- if (currentPos === null || (currentPos && !currentPos.page === null) || (currentPos && !currentPos.position === null)) {
51
- throw new InternalError_1.InternalError('Database Position not supported');
47
+ if (!currentPos) {
48
+ // Replication not supported... just continue
49
+ break;
52
50
  }
53
51
  // If the current page is greater than the target page,
54
52
  // then the position doesn't matter, we are ahead of the
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectionReplicationWaiter.js","sourceRoot":"","sources":["../../src/private/ConnectionRe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AAY,CAAC,YAAY,CAAC,CAAC;IAC/B,CAAC;;AArFL,kEAsFC;AArFG;;;;;GAKG;AACoB,+CAAmB,GAAW,IAAI,CAAC;AAE1D;;;;;;GAMG;AACoB,2CAAe,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC,oBAAoB"}
@@ -1,7 +1,7 @@
1
1
  import { GetBinLogPositionQuery } from './GetBinLogPositionQuery';
2
2
  interface IStatus {
3
- Master_Log_File: string;
4
- Read_Master_Log_Pos: string;
3
+ Relay_Source_Log_File: string;
4
+ Exec_Source_Log_Pos: string;
5
5
  }
6
6
  export declare class GetSlavePositionQuery extends GetBinLogPositionQuery<IStatus> {
7
7
  protected _getQuery(): string;
@@ -19,13 +19,13 @@ exports.GetSlavePositionQuery = void 0;
19
19
  const GetBinLogPositionQuery_1 = require("./GetBinLogPositionQuery");
20
20
  class GetSlavePositionQuery extends GetBinLogPositionQuery_1.GetBinLogPositionQuery {
21
21
  _getQuery() {
22
- return 'SHOW SLAVE STATUS';
22
+ return 'SHOW REPLICA STATUS';
23
23
  }
24
24
  _getFile(row) {
25
- return row.Master_Log_File;
25
+ return row.Relay_Source_Log_File;
26
26
  }
27
27
  _getPosition(row) {
28
- return row.Read_Master_Log_Pos;
28
+ return row.Exec_Source_Log_Pos;
29
29
  }
30
30
  }
31
31
  exports.GetSlavePositionQuery = GetSlavePositionQuery;
@@ -1 +1 @@
1
- {"version":3,"file":"GetSlavePositionQuery.js","sourceRoot":"","sources":["../../src/private/GetSlavePositionQuery.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;EAcE;;;AAEF,qEAAkE;AAOlE,MAAa,qBAAsB,SAAQ,+CAA+B;IAEnD,SAAS;QACxB,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEkB,QAAQ,CAAC,GAAY;QACpC,OAAO,GAAG,CAAC,eAAe,CAAC;IAC/B,CAAC;IAEkB,YAAY,CAAC,GAAY;QACxC,OAAO,GAAG,CAAC,mBAAmB,CAAC;IACnC,CAAC;CACJ;AAbD,sDAaC"}
1
+ {"version":3,"file":"GetSlavePositionQuery.js","sourceRoot":"","sources":["../../src/private/GetSlavePositionQuery.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;EAcE;;;AAEF,qEAAkE;AAOlE,MAAa,qBAAsB,SAAQ,+CAA+B;IAEnD,SAAS;QACxB,OAAO,qBAAqB,CAAC;IACjC,CAAC;IAEkB,QAAQ,CAAC,GAAY;QACpC,OAAO,GAAG,CAAC,qBAAqB,CAAC;IACrC,CAAC;IAEkB,YAAY,CAAC,GAAY;QACxC,OAAO,GAAG,CAAC,mBAAmB,CAAC;IACnC,CAAC;CACJ;AAbD,sDAaC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@breautek/storm",
3
- "version": "9.0.4",
3
+ "version": "9.0.6",
4
4
  "description": "Object-Oriented REST API framework",
5
5
  "main": "lib/api.js",
6
6
  "types": "lib/api.d.ts",
@@ -51,13 +51,13 @@
51
51
  "@types/formidable": "3.4.5",
52
52
  "@types/jsonwebtoken": "9.0.10",
53
53
  "@types/mysql": "2.15.27",
54
- "@types/node": "24.0.10",
54
+ "@types/node": "24.0.14",
55
55
  "@types/uuid": "10.0.0",
56
56
  "ajv": "8.17.1",
57
57
  "body-parser": "2.2.0",
58
58
  "commander": "14.0.0",
59
59
  "express": "5.1.0",
60
- "form-data": "4.0.3",
60
+ "form-data": "4.0.4",
61
61
  "formidable": "3.5.4",
62
62
  "jsonwebtoken": "9.0.2",
63
63
  "mysql": "2.18.1",
@@ -72,7 +72,7 @@
72
72
  "devDependencies": {
73
73
  "@arashi/interfaces": "1.2.1",
74
74
  "@arashi/logger": "4.1.3",
75
- "@totalpave/eslint-plugin": "7.0.11",
75
+ "@totalpave/eslint-plugin": "7.0.13",
76
76
  "@types/jest": "30.0.0",
77
77
  "@types/ms": "2.1.0",
78
78
  "auto-changelog": "2.5.0",
@@ -0,0 +1,6 @@
1
+ onlyBuiltDependencies:
2
+ - unrs-resolver
3
+
4
+ publicHoistPattern:
5
+ - eslint
6
+
@@ -20,6 +20,7 @@ import * as MySQL from 'mysql';
20
20
  import {getInstance} from './instance';
21
21
  import { IDatabasePosition } from './IDatabasePosition';
22
22
  import { ConnectionReplicationWaiter } from './private/ConnectionReplicationWaiter';
23
+ import { ILogger } from '@arashi/interfaces';
23
24
 
24
25
  const TAG: string = 'MySQLDatabase';
25
26
 
@@ -83,13 +84,19 @@ export class MySQLDatabase extends Database<MySQL.PoolConfig, MySQL.PoolConnecti
83
84
  }
84
85
 
85
86
  protected override async _getConnection(query: string, requireWriteAccess: boolean, position?: IDatabasePosition): Promise<MySQLConnection> {
86
- getInstance().getLogger().trace(TAG, `Querying connection pool for "${query}".`);
87
+ let logger: ILogger = getInstance().getLogger();
88
+ logger.trace(TAG, `Querying connection pool for "${query}".`);
87
89
  let instantationStack: string = new Error().stack;
88
90
 
89
91
  let conn: MySQLConnection = await this.$getConnectionFromPool(query, requireWriteAccess, instantationStack);
90
92
  await conn.__internal_init();
91
93
 
94
+ logger.trace(TAG, `Replication Enabled: ${conn.hasReplicationEnabled() ? 'true' : 'false'}`);
95
+ logger.trace(TAG, `Connection Replicating: ${conn.isReplication() ? 'true' : 'false'}`);
96
+
97
+
92
98
  if (conn.hasReplicationEnabled() && conn.isReplication() && position && position.page && position.position) {
99
+ logger.trace(TAG, 'Connection is waiting on Replication');
93
100
  // master connections will not wait on database positions
94
101
  // they are guarenteed to be at the tip.
95
102
  // readonly, or otherwise known as replication connections
package/src/Request.ts CHANGED
@@ -32,6 +32,7 @@ import {StatusCode} from './StatusCode';
32
32
  import { InternalError } from './InternalError';
33
33
  // eslint-disable-next-line @typescript-eslint/no-require-imports
34
34
  import IncomingForm = require('formidable/Formidable');
35
+ import { IDatabasePosition } from './IDatabasePosition';
35
36
 
36
37
  export interface IParameterMap {
37
38
  [key: string]: string;
@@ -118,7 +119,7 @@ export class Request<TBody = any, TAuthToken extends IAuthTokenData = IAuthToken
118
119
  return this.$request.secure;
119
120
  }
120
121
 
121
- public pipe(destination: Writable): any {
122
+ public pipe(destination: Writable): Writable {
122
123
  return this.$request.pipe(destination);
123
124
  }
124
125
 
@@ -130,6 +131,42 @@ export class Request<TBody = any, TAuthToken extends IAuthTokenData = IAuthToken
130
131
  return this.$request;
131
132
  }
132
133
 
134
+ /**
135
+ * Reads the Page/Position DB headers if present
136
+ * Will return null if headers are not parseable.
137
+ *
138
+ * @since 9.1.0
139
+ * @returns {IDatabasePosition}
140
+ */
141
+ public getDatabasePosition(): IDatabasePosition {
142
+ let pageStr: string = this.getHeader('X-DATABASE-PAGE');
143
+ let positionStr: string = this.getHeader('X-DATABASE-POSITION');
144
+
145
+ let page: number = null;
146
+ let position: number = null;
147
+
148
+ let out: IDatabasePosition = null;
149
+
150
+ if (pageStr && positionStr) {
151
+ page = parseInt(pageStr);
152
+ position = parseInt(positionStr);
153
+
154
+ if (isNaN(page) || isNaN(position)) {
155
+ page = null;
156
+ position = null;
157
+ }
158
+ }
159
+
160
+ if (page && position) {
161
+ out = {
162
+ page,
163
+ position
164
+ };
165
+ }
166
+
167
+ return out;
168
+ }
169
+
133
170
  public async getAuthenticationToken(): Promise<TAuthToken> {
134
171
  let authHeader: string = getInstance().getConfig().authentication_header;
135
172
  let tdata: TAuthToken = null;
@@ -14,6 +14,7 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
+ import { IDatabasePosition } from './IDatabasePosition';
17
18
  import {StatusCode} from './StatusCode';
18
19
 
19
20
  export class ResponseData<TData = any> {
@@ -29,6 +30,25 @@ export class ResponseData<TData = any> {
29
30
  this.$redirect = null;
30
31
  }
31
32
 
33
+ /**
34
+ * Sets the DB position response headers
35
+ *
36
+ * @since 9.1.0
37
+ * @param pos
38
+ */
39
+ public setDatabasePosition(pos: IDatabasePosition | null): void {
40
+ let page: string = '0';
41
+ let position: string = '0';
42
+
43
+ if (pos) {
44
+ page = pos.page.toString();
45
+ position = pos.position.toString();
46
+ }
47
+
48
+ this.setHeader('X-DATABASE-PAGE', page);
49
+ this.setHeader('X-DATABASE-POSITION', position);
50
+ }
51
+
32
52
  public setHeader(name: string, value: string): void {
33
53
  this.$headers.set(name, value);
34
54
  }
@@ -17,7 +17,6 @@
17
17
 
18
18
  import { IDatabaseConnection } from '../IDatabaseConnection';
19
19
  import { IDatabasePosition } from '../IDatabasePosition';
20
- import { InternalError } from '../InternalError';
21
20
  import { TimeoutError } from '../TimeoutError';
22
21
 
23
22
  export class ConnectionReplicationWaiter {
@@ -74,10 +73,9 @@ export class ConnectionReplicationWaiter {
74
73
 
75
74
  let currentPos: IDatabasePosition = await this.$conn.getCurrentDatabasePosition();
76
75
 
77
- // TODO: I have no idea what my intent is here, but it's obviously wrong
78
- // eslint-disable-next-line no-constant-binary-expression
79
- if (currentPos === null || (currentPos && !currentPos.page === null) || (currentPos && !currentPos.position === null)) {
80
- throw new InternalError('Database Position not supported');
76
+ if (!currentPos) {
77
+ // Replication not supported... just continue
78
+ break;
81
79
  }
82
80
 
83
81
  // If the current page is greater than the target page,
@@ -17,21 +17,21 @@
17
17
  import { GetBinLogPositionQuery } from './GetBinLogPositionQuery';
18
18
 
19
19
  interface IStatus {
20
- Master_Log_File: string;
21
- Read_Master_Log_Pos: string;
20
+ Relay_Source_Log_File: string;
21
+ Exec_Source_Log_Pos: string;
22
22
  }
23
23
 
24
24
  export class GetSlavePositionQuery extends GetBinLogPositionQuery<IStatus> {
25
25
 
26
26
  protected override _getQuery(): string {
27
- return 'SHOW SLAVE STATUS';
27
+ return 'SHOW REPLICA STATUS';
28
28
  }
29
29
 
30
30
  protected override _getFile(row: IStatus): string {
31
- return row.Master_Log_File;
31
+ return row.Relay_Source_Log_File;
32
32
  }
33
33
 
34
34
  protected override _getPosition(row: IStatus): string {
35
- return row.Read_Master_Log_Pos;
35
+ return row.Exec_Source_Log_Pos;
36
36
  }
37
37
  }