@sqb/connect 4.5.2 → 4.5.4

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.
@@ -52,10 +52,7 @@ class SqbClient extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict
52
52
  const poolFactory = {
53
53
  create: () => adapter.connect(cfg),
54
54
  destroy: instance => instance.close(),
55
- reset: async (instance) => {
56
- await this.emitAsyncSerial('connection-return').catch();
57
- return instance.reset();
58
- },
55
+ reset: async (instance) => instance.reset(),
59
56
  validate: instance => instance.test()
60
57
  };
61
58
  this._pool = (0, lightning_pool_1.createPool)(poolFactory, poolOptions);
@@ -107,6 +104,7 @@ class SqbClient extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict
107
104
  await this.emitAsyncSerial('acquire', connection);
108
105
  connection.on('execute', (request) => this.emit('execute', request));
109
106
  connection.on('error', (error) => this.emit('error', error));
107
+ connection.on('close', () => this.emitAsyncSerial('connection-return', connection));
110
108
  return connection;
111
109
  }
112
110
  /**
@@ -81,8 +81,10 @@ class SqbConnection extends (0, strict_typed_events_1.TypedEventEmitterClass)(st
81
81
  await this.emitAsyncSerial('close');
82
82
  const intlcon = this._intlcon;
83
83
  this._intlcon = undefined;
84
- this.client.pool.release(intlcon)
85
- .catch(e => this.client.emit('error', e));
84
+ this.client.pool.release(intlcon, (e) => {
85
+ if (e)
86
+ this.client.emit('error', e);
87
+ });
86
88
  debug('[%s] closed', intlcon.sessionId);
87
89
  }
88
90
  async execute(query, options) {
@@ -12,7 +12,7 @@ interface SqbClientEvents {
12
12
  close: () => void;
13
13
  acquire: (connection: SqbConnection) => Promise<void>;
14
14
  terminate: () => void;
15
- 'connection-return': () => Promise<void>;
15
+ 'connection-return': (connection: SqbConnection) => Promise<void>;
16
16
  }
17
17
  declare const SqbClient_base: Type<import("strict-typed-events").TypedEventEmitter<any, SqbClientEvents, SqbClientEvents>>;
18
18
  export declare class SqbClient extends SqbClient_base {
@@ -48,10 +48,7 @@ export class SqbClient extends TypedEventEmitterClass(AsyncEventEmitter) {
48
48
  const poolFactory = {
49
49
  create: () => adapter.connect(cfg),
50
50
  destroy: instance => instance.close(),
51
- reset: async (instance) => {
52
- await this.emitAsyncSerial('connection-return').catch();
53
- return instance.reset();
54
- },
51
+ reset: async (instance) => instance.reset(),
55
52
  validate: instance => instance.test()
56
53
  };
57
54
  this._pool = createPool(poolFactory, poolOptions);
@@ -103,6 +100,7 @@ export class SqbClient extends TypedEventEmitterClass(AsyncEventEmitter) {
103
100
  await this.emitAsyncSerial('acquire', connection);
104
101
  connection.on('execute', (request) => this.emit('execute', request));
105
102
  connection.on('error', (error) => this.emit('error', error));
103
+ connection.on('close', () => this.emitAsyncSerial('connection-return', connection));
106
104
  return connection;
107
105
  }
108
106
  /**
@@ -77,8 +77,10 @@ export class SqbConnection extends TypedEventEmitterClass(AsyncEventEmitter) {
77
77
  await this.emitAsyncSerial('close');
78
78
  const intlcon = this._intlcon;
79
79
  this._intlcon = undefined;
80
- this.client.pool.release(intlcon)
81
- .catch(e => this.client.emit('error', e));
80
+ this.client.pool.release(intlcon, (e) => {
81
+ if (e)
82
+ this.client.emit('error', e);
83
+ });
82
84
  debug('[%s] closed', intlcon.sessionId);
83
85
  }
84
86
  async execute(query, options) {
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.5.2",
4
+ "version": "4.5.4",
5
5
  "author": "Panates",
6
6
  "contributors": [
7
7
  "Eray Hanoglu <e.hanoglu@panates.com>",
@@ -30,27 +30,25 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "debug": "^4.3.4",
33
- "lightning-pool": "^4.0.0",
33
+ "lightning-pool": "^4.2.0",
34
34
  "lodash": "^4.17.21",
35
35
  "putil-isplainobject": "^1.1.4",
36
- "putil-merge": "^3.8.0",
36
+ "putil-merge": "^3.9.0",
37
37
  "putil-promisify": "^1.8.5",
38
38
  "putil-taskqueue": "^2.5.4",
39
39
  "putil-varhelpers": "^1.6.4",
40
40
  "reflect-metadata": "^0.1.13",
41
- "strict-typed-events": "^2.2.0",
42
- "ts-gems": "^2.2.0"
41
+ "strict-typed-events": "^2.3.1",
42
+ "ts-gems": "^2.2.1"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/debug": "^4.1.7",
46
- "@types/lodash": "^4.14.185"
46
+ "@types/lodash": "^4.14.186"
47
47
  },
48
48
  "peerDependencies": {
49
- "@sqb/builder": "^4.5.0"
49
+ "@sqb/builder": "^4.5.4"
50
50
  },
51
51
  "type": "module",
52
- "main": "cjs/index.js",
53
- "module": "esm/index.js",
54
52
  "types": "esm/index.d.ts",
55
53
  "exports": {
56
54
  ".": {
@@ -86,4 +84,4 @@
86
84
  "sqlite",
87
85
  "mysql"
88
86
  ]
89
- }
87
+ }