@pi-r/redis 0.3.2 → 0.3.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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023 Studio Trigger
1
+ Copyright 2024 An Pham
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @pi-r/redis
2
2
 
3
- PEP 402 - Forever Aina
3
+ PEP 402 - Forever
4
4
 
5
5
  ## LICENSE
6
6
 
package/client/index.js CHANGED
@@ -41,13 +41,15 @@ function getClient(db, options, poolKey) {
41
41
  });
42
42
  }
43
43
  function removePoolProperties(options) {
44
+ var _a;
44
45
  if (!options.uuidKey && ('socket' in options || 'isolationPoolOptions' in options)) {
45
- return { ...options, socket: options.socket?.tls ? { tls: true } : undefined, isolationPoolOptions: undefined };
46
+ return { ...options, socket: ((_a = options.socket) === null || _a === void 0 ? void 0 : _a.tls) ? { tls: true } : undefined, isolationPoolOptions: undefined };
46
47
  }
47
48
  return options;
48
49
  }
49
- const getPoolKey = (options) => options.url + '_' + (options.username || '') + '_' + (options.password || '') + '_' + (options.database ?? '') + '_' + (options.socket?.tls ? '1' : '0') + '_' + (options.legacyMode ? '1' : '0');
50
+ const getPoolKey = (options) => { var _a, _b; return options.url + '_' + (options.username || '') + '_' + (options.password || '') + '_' + ((_a = options.database) !== null && _a !== void 0 ? _a : '') + '_' + (((_b = options.socket) === null || _b === void 0 ? void 0 : _b.tls) ? '1' : '0') + '_' + (options.legacyMode ? '1' : '0'); };
50
51
  async function setCredential(item) {
52
+ var _a, _b, _c, _d, _e, _f, _g;
51
53
  if (!REDIS_V4) {
52
54
  throw (0, types_1.errorValue)("Upgrade client to latest version", "redis" + '@' + Db.getPackageVersion("redis"));
53
55
  }
@@ -82,7 +84,7 @@ async function setCredential(item) {
82
84
  if (!uri) {
83
85
  throw (0, types_1.errorMessage)("redis", 'Not defined - uri');
84
86
  }
85
- if (client.socket?.tls) {
87
+ if ((_a = client.socket) === null || _a === void 0 ? void 0 : _a.tls) {
86
88
  this.readTLSConfig(client.socket);
87
89
  }
88
90
  client.url = uri;
@@ -97,7 +99,7 @@ async function setCredential(item) {
97
99
  let pool;
98
100
  username = undefined;
99
101
  password = undefined;
100
- if (typeof usePool === 'string' && (username = client.username || (0, util_1.parseConnectionString)(uri)?.username)) {
102
+ if (typeof usePool === 'string' && (username = client.username || ((_b = (0, util_1.parseConnectionString)(uri)) === null || _b === void 0 ? void 0 : _b.username))) {
101
103
  [password, pool] = DbPool.validateKey(POOL_STATE, username, usePool);
102
104
  if (pool) {
103
105
  pool.add(item, password);
@@ -111,19 +113,19 @@ async function setCredential(item) {
111
113
  if (config) {
112
114
  const { min, max, idle, queue_max, queue_idle } = config;
113
115
  if (min >= 0) {
114
- poolOptions.min ?? (poolOptions.min = min);
116
+ (_c = poolOptions.min) !== null && _c !== void 0 ? _c : (poolOptions.min = min);
115
117
  }
116
118
  if (max > 0) {
117
- poolOptions.max ?? (poolOptions.max = max);
119
+ (_d = poolOptions.max) !== null && _d !== void 0 ? _d : (poolOptions.max = max);
118
120
  }
119
121
  if (idle > 0) {
120
- poolOptions.idleTimeoutMillis ?? (poolOptions.idleTimeoutMillis = idle);
122
+ (_e = poolOptions.idleTimeoutMillis) !== null && _e !== void 0 ? _e : (poolOptions.idleTimeoutMillis = idle);
121
123
  }
122
124
  if (queue_max >= 0) {
123
- poolOptions.maxWaitingClients ?? (poolOptions.maxWaitingClients = queue_max);
125
+ (_f = poolOptions.maxWaitingClients) !== null && _f !== void 0 ? _f : (poolOptions.maxWaitingClients = queue_max);
124
126
  }
125
127
  if (queue_idle > 0) {
126
- poolOptions.acquireTimeoutMillis ?? (poolOptions.acquireTimeoutMillis = queue_idle);
128
+ (_g = poolOptions.acquireTimeoutMillis) !== null && _g !== void 0 ? _g : (poolOptions.acquireTimeoutMillis = queue_idle);
127
129
  }
128
130
  }
129
131
  try {
@@ -147,6 +149,7 @@ async function executeQuery(item, options) {
147
149
  }
148
150
  exports.executeQuery = executeQuery;
149
151
  async function executeBatchQuery(batch, options = '', outResult) {
152
+ var _a, _b;
150
153
  const length = batch.length;
151
154
  if (length === 0) {
152
155
  return [];
@@ -174,7 +177,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
174
177
  const caching = this.hasCache("redis", sessionKey);
175
178
  const tasks = new Array(length);
176
179
  const clients = [];
177
- let redisClient, redisCredential, redisCache = 0, onceCredential = connectOnce ? batch[0].options?.client : undefined;
180
+ let redisClient, redisCredential, redisCache = 0, onceCredential = connectOnce ? (_a = batch[0].options) === null || _a === void 0 ? void 0 : _a.client : undefined;
178
181
  const getConnection = async (item, credential) => {
179
182
  item.transactionState = 64;
180
183
  let client;
@@ -223,7 +226,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
223
226
  continue;
224
227
  }
225
228
  item.transactionState = 1;
226
- const uuidKey = (credential.uuidKey || (credential.uuidKey = (onceCredential ? batch[0] : item).credential?.uuidKey));
229
+ const uuidKey = (credential.uuidKey || (credential.uuidKey = (_b = (onceCredential ? batch[0] : item).credential) === null || _b === void 0 ? void 0 : _b.uuidKey));
227
230
  const targetObject = typeof checkObject === 'string' ? this.hasCoerce("redis", 'options', uuidKey) && (0, types_1.asFunction)(checkObject) : checkObject;
228
231
  const renewCache = ignoreCache === 0;
229
232
  const cacheValue = renewCache ? { sessionKey, renewCache } : sessionKey;
@@ -312,11 +315,11 @@ async function executeBatchQuery(batch, options = '', outResult) {
312
315
  const flags = setOptions.set;
313
316
  if (flags) {
314
317
  if ('NX' in flags) {
315
- NX ?? (NX = !!flags.NX);
318
+ NX !== null && NX !== void 0 ? NX : (NX = !!flags.NX);
316
319
  delete flags.NX;
317
320
  }
318
321
  if ('XX' in flags) {
319
- XX ?? (XX = !!flags.XX);
322
+ XX !== null && XX !== void 0 ? XX : (XX = !!flags.XX);
320
323
  delete flags.XX;
321
324
  }
322
325
  if ('EX' in flags) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/redis",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Redis client driver for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "types": "client/index.d.ts",
@@ -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.6.1",
25
- "@e-mc/types": "^0.6.1",
24
+ "@e-mc/db": "^0.6.3",
25
+ "@e-mc/types": "^0.6.3",
26
26
  "redis": "^4.6.13"
27
27
  }
28
28
  }