@sqb/connect 4.0.2 → 4.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.
@@ -7,11 +7,11 @@ import { SqbConnection } from './SqbConnection';
7
7
  import { Repository } from '../orm/repository.class';
8
8
  declare const inspect: unique symbol;
9
9
  interface SqbClientEvents {
10
- execute: (request: QueryRequest, connection: SqbConnection) => void;
11
- error: (error: Error, connection: SqbConnection) => void;
10
+ execute: (request: QueryRequest) => void;
11
+ error: (error: Error) => void;
12
12
  closing: () => void;
13
13
  close: () => void;
14
- acquire: (connection: SqbConnection) => void;
14
+ acquire: (connection: SqbConnection) => Promise<void>;
15
15
  terminate: () => void;
16
16
  }
17
17
  export declare class SqbClient extends AsyncEventEmitter<SqbClientEvents> {
@@ -100,9 +100,9 @@ class SqbClient extends strict_typed_events_1.AsyncEventEmitter {
100
100
  const adapterConnection = await this._pool.acquire();
101
101
  const opts = { autoCommit: this.defaults.autoCommit, ...options };
102
102
  const connection = new SqbConnection_1.SqbConnection(this, adapterConnection, opts);
103
- this.emit('acquire', connection);
104
- connection.on('execute', (request) => this.emit('execute', request, connection));
105
- connection.on('error', (error) => this.emit('error', error, connection));
103
+ await this.emitAsync({ event: 'acquire', serial: true }, connection);
104
+ connection.on('execute', (request) => this.emit('execute', request));
105
+ connection.on('error', (error) => this.emit('error', error));
106
106
  return connection;
107
107
  }
108
108
  /**
@@ -77,11 +77,11 @@ class SqbConnection extends strict_typed_events_1.AsyncEventEmitter {
77
77
  async close() {
78
78
  if (!this._intlcon)
79
79
  return;
80
- await this.emitAsync('close');
80
+ await this.emitAsync({ event: 'close', serial: true });
81
81
  const intlcon = this._intlcon;
82
82
  this._intlcon = undefined;
83
83
  this.client.pool.release(intlcon)
84
- .catch(e => this.client.emit('error', e, this));
84
+ .catch(e => this.client.emit('error', e));
85
85
  debug('[%s] closed', intlcon.sessionId);
86
86
  }
87
87
  async execute(query, options) {
@@ -64,9 +64,9 @@ export declare namespace Repository {
64
64
  }
65
65
  }
66
66
  interface RepositoryEvents {
67
- execute: (request: QueryRequest, connection: SqbConnection) => void;
68
- error: (error: Error, connection: SqbConnection) => void;
69
- acquire: (connection: SqbConnection) => void;
67
+ execute: (request: QueryRequest) => void;
68
+ error: (error: Error) => void;
69
+ acquire: (connection: SqbConnection) => Promise<void>;
70
70
  }
71
71
  export declare class Repository<T> extends AsyncEventEmitter<RepositoryEvents> {
72
72
  private readonly _executor;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sqb/connect",
3
3
  "description": "Multi-dialect database connection framework written with TypeScript",
4
- "version": "4.0.2",
4
+ "version": "4.0.6",
5
5
  "author": "Panates Ltd.",
6
6
  "contributors": [
7
7
  "Eray Hanoglu <e.hanoglu@panates.com>"
@@ -38,15 +38,15 @@
38
38
  "putil-taskqueue": "^2.5.3",
39
39
  "putil-varhelpers": "^1.6.1",
40
40
  "reflect-metadata": "^0.1.13",
41
- "strict-typed-events": "^1.0.4"
41
+ "strict-typed-events": "^1.0.4",
42
+ "ts-gems": "^0.0.3"
42
43
  },
43
44
  "devDependencies": {
44
45
  "@types/debug": "^4.1.6",
45
- "@types/lodash": "^4.14.171",
46
- "ts-gems": "^0.0.2"
46
+ "@types/lodash": "^4.14.171"
47
47
  },
48
48
  "peerDependencies": {
49
- "@sqb/builder": "^4.0.2"
49
+ "@sqb/builder": "^4.0.6"
50
50
  },
51
51
  "main": "dist/index.js",
52
52
  "types": "dist/index.d.ts",