@pi-r/redis 0.5.3 → 0.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.
Files changed (3) hide show
  1. package/LICENSE +1 -1
  2. package/client/index.js +17 -14
  3. package/package.json +3 -3
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023 Haruhi Suzumiya
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/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, _h;
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,22 +113,22 @@ async function setCredential(item) {
111
113
  if (config) {
112
114
  const { min, max, idle, queue_max, queue_idle, timeout } = 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.softIdleTimeoutMillis ?? (poolOptions.softIdleTimeoutMillis = queue_idle);
128
+ (_g = poolOptions.softIdleTimeoutMillis) !== null && _g !== void 0 ? _g : (poolOptions.softIdleTimeoutMillis = queue_idle);
127
129
  }
128
130
  if (timeout > 0) {
129
- poolOptions.acquireTimeoutMillis ?? (poolOptions.acquireTimeoutMillis = timeout);
131
+ (_h = poolOptions.acquireTimeoutMillis) !== null && _h !== void 0 ? _h : (poolOptions.acquireTimeoutMillis = timeout);
130
132
  }
131
133
  }
132
134
  try {
@@ -150,6 +152,7 @@ async function executeQuery(item, options) {
150
152
  }
151
153
  exports.executeQuery = executeQuery;
152
154
  async function executeBatchQuery(batch, options = '', outResult) {
155
+ var _a, _b;
153
156
  const length = batch.length;
154
157
  if (length === 0) {
155
158
  return [];
@@ -177,7 +180,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
177
180
  const caching = this.hasCache("redis", sessionKey);
178
181
  const tasks = new Array(length);
179
182
  const clients = [];
180
- let redisClient, redisCredential, redisCache = 0, onceCredential = connectOnce ? batch[0].options?.client : undefined;
183
+ let redisClient, redisCredential, redisCache = 0, onceCredential = connectOnce ? (_a = batch[0].options) === null || _a === void 0 ? void 0 : _a.client : undefined;
181
184
  const getConnection = async (item, credential) => {
182
185
  item.transactionState = 64;
183
186
  let client;
@@ -226,7 +229,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
226
229
  continue;
227
230
  }
228
231
  item.transactionState = 1;
229
- const uuidKey = (credential.uuidKey || (credential.uuidKey = (onceCredential ? batch[0] : item).credential?.uuidKey));
232
+ const uuidKey = (credential.uuidKey || (credential.uuidKey = (_b = (onceCredential ? batch[0] : item).credential) === null || _b === void 0 ? void 0 : _b.uuidKey));
230
233
  const targetObject = typeof checkObject === 'string' ? this.hasCoerce("redis", 'options', uuidKey) && (0, types_1.asFunction)(checkObject) : checkObject;
231
234
  const renewCache = ignoreCache === 0;
232
235
  const cacheValue = renewCache ? { sessionKey, renewCache } : sessionKey;
@@ -315,11 +318,11 @@ async function executeBatchQuery(batch, options = '', outResult) {
315
318
  const flags = setOptions.set;
316
319
  if (flags) {
317
320
  if ('NX' in flags) {
318
- NX ?? (NX = !!flags.NX);
321
+ NX !== null && NX !== void 0 ? NX : (NX = !!flags.NX);
319
322
  delete flags.NX;
320
323
  }
321
324
  if ('XX' in flags) {
322
- XX ?? (XX = !!flags.XX);
325
+ XX !== null && XX !== void 0 ? XX : (XX = !!flags.XX);
323
326
  delete flags.XX;
324
327
  }
325
328
  if ('EX' in flags) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/redis",
3
- "version": "0.5.3",
3
+ "version": "0.5.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.7.3",
25
- "@e-mc/types": "^0.7.3",
24
+ "@e-mc/db": "^0.7.5",
25
+ "@e-mc/types": "^0.7.5",
26
26
  "redis": "^4.6.13"
27
27
  }
28
28
  }