@pi-r/redis 0.6.2 → 0.6.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.
package/client/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { RedisDataSource } from '@e-mc/types/lib/db';
2
-
3
1
  import type { IDbSourceClient } from '@e-mc/db/types';
4
2
 
3
+ import type { RedisDataSource } from '../types';
4
+
5
5
  declare const Redis: IDbSourceClient<RedisDataSource>;
6
6
 
7
7
  export = Redis;
package/client/index.js CHANGED
@@ -6,7 +6,6 @@ const util_1 = require("@e-mc/db/util");
6
6
  const types_1 = require("@e-mc/types");
7
7
  const Db = require("@e-mc/db");
8
8
  const DbPool = require('@e-mc/db/pool');
9
- const REDIS_V4 = Db.checkSemVer("redis" /* STRINGS.MODULE_NAME */, 4);
10
9
  class RedisPool extends DbPool {
11
10
  async getConnection() {
12
11
  return this.client;
@@ -22,6 +21,7 @@ class RedisPool extends DbPool {
22
21
  }
23
22
  }
24
23
  const POOL_STATE = {};
24
+ const POOL_ACTIVE = new WeakSet();
25
25
  async function getClient(db, options, poolKey) {
26
26
  const socket = options.socket || (options.socket = {});
27
27
  if (!poolKey) {
@@ -41,16 +41,13 @@ async function getClient(db, options, poolKey) {
41
41
  });
42
42
  }
43
43
  function removePoolProperties(options) {
44
- if (!options.uuidKey && ('socket' in options || 'isolationPoolOptions' in options)) {
44
+ if (!options.uuidKey && ('socket' in options || 'isolationPoolOptions' in options) && POOL_ACTIVE.has(options)) {
45
45
  return { ...options, socket: options.socket?.tls ? { tls: true } : undefined, isolationPoolOptions: undefined };
46
46
  }
47
47
  return options;
48
48
  }
49
49
  const getPoolKey = (options) => options.url && JSON.stringify(options);
50
50
  async function setCredential(item) {
51
- if (!REDIS_V4) {
52
- throw (0, types_1.errorValue)("Upgrade client to latest version" /* ERR_DB.UPGRADE */, "redis" /* STRINGS.MODULE_NAME */ + '@' + Db.getPackageVersion("redis" /* STRINGS.MODULE_NAME */));
53
- }
54
51
  const credential = this.getCredential(item);
55
52
  const options = item.options || (item.options = {});
56
53
  const client = (0, types_1.isPlainObject)(options.client) ? options.client : options.client = {};
@@ -192,6 +189,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
192
189
  if (pool) {
193
190
  client = pool.client;
194
191
  pool.connected = true;
192
+ POOL_ACTIVE.add(credential);
195
193
  }
196
194
  }
197
195
  if (!client) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/redis",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "Redis client driver for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "types": "client/index.d.ts",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "https://github.com/anpham6/pi-r.git",
12
+ "url": "git+https://github.com/anpham6/pi-r.git",
13
13
  "directory": "src/db/redis"
14
14
  },
15
15
  "keywords": [
@@ -21,8 +21,8 @@
21
21
  "license": "MIT",
22
22
  "homepage": "https://github.com/anpham6/pi-r#readme",
23
23
  "dependencies": {
24
- "@e-mc/db": "^0.8.2",
25
- "@e-mc/types": "^0.8.2",
26
- "redis": "^4.6.12"
24
+ "@e-mc/db": "^0.8.4",
25
+ "@e-mc/types": "^0.8.4",
26
+ "redis": "^4.6.13"
27
27
  }
28
28
  }
package/types/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import type { ClientCommandOptions } from '@redis/client/dist/lib/client';
7
7
  import type { RedisClientOptions } from '@redis/client';
8
8
  import type { RedisCommandArgument } from '@redis/client/dist/lib/commands';
9
9
  import type { RedisJSON } from '@redis/json/dist/commands';
10
- import type { AggregateOptions, RediSearchSchema, SearchOptions, SetOptions } from 'redis';
10
+ import type { RediSearchSchema, SearchOptions, SetOptions } from 'redis';
11
11
 
12
12
  export interface RedisDataSource extends DbDataSource<string, PlainObject, ArrayOf<RedisSetValue> | ArrayOf<RedisJSONValue>, string | RedisCredential, string>, AuthValue, CascadeAction {
13
13
  source: "redis";
@@ -22,7 +22,7 @@ export interface RedisDataSource extends DbDataSource<string, PlainObject, Array
22
22
  command?: RedisCommandOptions;
23
23
  get?: PlainObject;
24
24
  search?: SearchOptions;
25
- aggregate?: AggregateOptions;
25
+ aggregate?: PlainObject;
26
26
  };
27
27
  database?: number;
28
28
  }