node-red-contrib-redis-variable 1.5.2 → 1.5.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-redis-variable",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "A comprehensive Node-RED node for Redis operations with universal payload-based configuration, automatic JSON handling, SSL/TLS support, and advanced pattern matching with pagination",
5
5
  "keywords": [
6
6
  "node-red",
@@ -265,6 +265,7 @@ module.exports = function (RED) {
265
265
  retryDelayOnFailover: 100,
266
266
  enableReadyCheck: false,
267
267
  maxRetriesPerRequest: null,
268
+ enableOfflineQueue: false,
268
269
  ...additionalOptions
269
270
  };
270
271
 
@@ -391,11 +392,13 @@ module.exports = function (RED) {
391
392
  enableReadyCheck: false,
392
393
  lazyConnect: true,
393
394
  maxRetriesPerRequest: 3,
395
+ enableOfflineQueue: false,
394
396
  redisOptions: {
395
397
  username: options.username || undefined,
396
398
  password: options.password || undefined,
397
399
  db: 0,
398
400
  connectTimeout: connectionOptions.connectTimeout || 5000,
401
+ commandTimeout: connectionOptions.commandTimeout || 3000,
399
402
  tls: connectionOptions.tls || undefined,
400
403
  },
401
404
  };
package/redis-variable.js CHANGED
@@ -372,6 +372,11 @@ module.exports = function (RED) {
372
372
  if (client.status !== 'ready' && client.status !== 'connect') {
373
373
  const CONNECT_WAIT_MS = 15000;
374
374
  const waitForReady = () => new Promise((resolve, reject) => {
375
+ // If connection already established, resolve immediately
376
+ if (client.status === 'ready' || client.status === 'connect') {
377
+ resolve();
378
+ return;
379
+ }
375
380
  const timeout = setTimeout(() => reject(new Error('Connection timeout')), CONNECT_WAIT_MS);
376
381
  const onReady = () => { clearTimeout(timeout); cleanup(); resolve(); };
377
382
  const onError = (e) => { clearTimeout(timeout); cleanup(); reject(e); };
@@ -423,8 +428,33 @@ module.exports = function (RED) {
423
428
  try {
424
429
  switch (node.operation) {
425
430
  case "get":
426
- let getKey = payload.key || payload;
427
- if (!getKey || typeof getKey !== 'string') {
431
+ let getKey;
432
+ if (typeof payload === 'string' && isJsonString(payload)) {
433
+ try {
434
+ const parsed = JSON.parse(payload);
435
+ getKey = parsed.key !== undefined ? parsed.key : parsed.Key;
436
+ } catch (e) {
437
+ getKey = payload;
438
+ }
439
+ } else if (Buffer.isBuffer(payload)) {
440
+ getKey = payload.toString();
441
+ } else if (payload && typeof payload === 'object' && !Array.isArray(payload)) {
442
+ if (payload.key !== undefined || payload.Key !== undefined) {
443
+ getKey = payload.key !== undefined ? payload.key : payload.Key;
444
+ } else if (payload.payload && typeof payload.payload === 'object') {
445
+ const nested = payload.payload;
446
+ if (nested.key !== undefined || nested.Key !== undefined) {
447
+ getKey = nested.key !== undefined ? nested.key : nested.Key;
448
+ }
449
+ }
450
+ } else {
451
+ getKey = payload;
452
+ }
453
+ if (getKey === undefined || getKey === null) {
454
+ throw new Error("Missing or invalid key for GET operation. Use payload.key or payload as string");
455
+ }
456
+ getKey = String(getKey).trim();
457
+ if (!getKey) {
428
458
  throw new Error("Missing or invalid key for GET operation. Use payload.key or payload as string");
429
459
  }
430
460
  response = await client.get(getKey);