@pi-r/redis 0.2.9 → 0.2.11

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 2020-24 Code Geass
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 Josee + Nunnally
3
+ PEP 402 - Forever
4
4
 
5
5
  ## LICENSE
6
6
 
package/client/index.js CHANGED
@@ -40,13 +40,15 @@ function getClient(db, options, poolKey) {
40
40
  });
41
41
  }
42
42
  function removePoolProperties(options) {
43
+ var _a;
43
44
  if (!options.uuidKey && ('socket' in options || 'isolationPoolOptions' in options)) {
44
- return { ...options, socket: options.socket?.tls ? { tls: true } : undefined, isolationPoolOptions: undefined };
45
+ return { ...options, socket: ((_a = options.socket) === null || _a === void 0 ? void 0 : _a.tls) ? { tls: true } : undefined, isolationPoolOptions: undefined };
45
46
  }
46
47
  return options;
47
48
  }
48
- const getPoolKey = (options) => options.url + '_' + (options.username || '') + '_' + (options.password || '') + '_' + (options.database ?? '') + '_' + (options.socket?.tls ? '1' : '0') + '_' + (options.legacyMode ? '1' : '0');
49
+ 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'); };
49
50
  async function setCredential(item) {
51
+ var _a, _b, _c, _d, _e, _f, _g;
50
52
  if (!REDIS_V4) {
51
53
  throw (0, types_1.errorValue)("Upgrade client to latest version", "redis" + '@' + Db.getPackageVersion("redis"));
52
54
  }
@@ -81,7 +83,7 @@ async function setCredential(item) {
81
83
  if (!uri) {
82
84
  throw (0, types_1.errorMessage)("redis", 'Not defined - uri');
83
85
  }
84
- if (client.socket?.tls) {
86
+ if ((_a = client.socket) === null || _a === void 0 ? void 0 : _a.tls) {
85
87
  this.readTLSConfig(client.socket);
86
88
  }
87
89
  client.url = uri;
@@ -96,7 +98,7 @@ async function setCredential(item) {
96
98
  let pool;
97
99
  username = undefined;
98
100
  password = undefined;
99
- if (typeof usePool === 'string' && (username = client.username || (0, util_1.parseConnectionString)(uri)?.username)) {
101
+ if (typeof usePool === 'string' && (username = client.username || ((_b = (0, util_1.parseConnectionString)(uri)) === null || _b === void 0 ? void 0 : _b.username))) {
100
102
  [password, pool] = DbPool.validateKey(POOL_STATE, username, usePool);
101
103
  if (pool) {
102
104
  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 [];
@@ -175,7 +178,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
175
178
  const caching = this.hasCache("redis", sessionKey);
176
179
  const tasks = new Array(length);
177
180
  const clients = [];
178
- let redisClient, redisCredential, redisCache = 0, onceCredential = connectOnce ? batch[0].options?.client : undefined;
181
+ let redisClient, redisCredential, redisCache = 0, onceCredential = connectOnce ? (_a = batch[0].options) === null || _a === void 0 ? void 0 : _a.client : undefined;
179
182
  const getConnection = async (item, credential) => {
180
183
  item.transactionState = 64;
181
184
  let client;
@@ -224,7 +227,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
224
227
  continue;
225
228
  }
226
229
  item.transactionState = 1;
227
- const uuidKey = (credential.uuidKey || (credential.uuidKey = (onceCredential ? batch[0] : item).credential?.uuidKey));
230
+ const uuidKey = (credential.uuidKey || (credential.uuidKey = (_b = (onceCredential ? batch[0] : item).credential) === null || _b === void 0 ? void 0 : _b.uuidKey));
228
231
  const targetObject = typeof checkObject === 'string' ? this.hasCoerce("redis", 'options', uuidKey) && (0, types_1.asFunction)(checkObject) : checkObject;
229
232
  const renewCache = ignoreCache === 0;
230
233
  const cacheValue = renewCache ? { sessionKey, renewCache } : sessionKey;
@@ -313,11 +316,11 @@ async function executeBatchQuery(batch, options = '', outResult) {
313
316
  const flags = setOptions.set;
314
317
  if (flags) {
315
318
  if ('NX' in flags) {
316
- NX ?? (NX = !!flags.NX);
319
+ NX !== null && NX !== void 0 ? NX : (NX = !!flags.NX);
317
320
  delete flags.NX;
318
321
  }
319
322
  if ('XX' in flags) {
320
- XX ?? (XX = !!flags.XX);
323
+ XX !== null && XX !== void 0 ? XX : (XX = !!flags.XX);
321
324
  delete flags.XX;
322
325
  }
323
326
  if ('EX' in flags) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/redis",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
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.5.5",
25
- "@e-mc/types": "^0.5.5",
24
+ "@e-mc/db": "^0.5.6",
25
+ "@e-mc/types": "^0.5.6",
26
26
  "redis": "^4.6.13"
27
27
  }
28
28
  }