🎯 MapView v2.0 - Global Deployment Ready

 MAJOR FEATURES:
• Auto-zoom intelligence với smart bounds fitting
• Enhanced 3D GPS markers với pulsing effects
• Professional route display với 6-layer rendering
• Status-based parking icons với availability indicators
• Production-ready build optimizations

🗺️ AUTO-ZOOM FEATURES:
• Smart bounds fitting cho GPS + selected parking
• Adaptive padding (50px) cho visual balance
• Max zoom control (level 16) để tránh quá gần
• Dynamic centering khi không có selection

🎨 ENHANCED VISUALS:
• 3D GPS marker với multi-layer pulse effects
• Advanced parking icons với status colors
• Selection highlighting với animation
• Dimming system cho non-selected items

🛣️ ROUTE SYSTEM:
• OpenRouteService API integration
• Multi-layer route rendering (glow, shadow, main, animated)
• Real-time distance & duration calculation
• Visual route info trong popup

📱 PRODUCTION READY:
• SSR safe với dynamic imports
• Build errors resolved
• Global deployment via Vercel
• Optimized performance

🌍 DEPLOYMENT:
• Vercel: https://whatever-ctk2auuxr-phong12hexdockworks-projects.vercel.app
• Bundle size: 22.8 kB optimized
• Global CDN distribution
• HTTPS enabled

💾 VERSION CONTROL:
• MapView-v2.0.tsx backup created
• MAPVIEW_VERSIONS.md documentation
• Full version history tracking
This commit is contained in:
2025-07-20 19:52:16 +07:00
parent 3203463a6a
commit c65cc97a33
64624 changed files with 7199453 additions and 6462 deletions

3
backend/node_modules/@redis/client/README.md generated vendored Normal file
View File

@@ -0,0 +1,3 @@
# @redis/client
The source code and documentation for this package are in the main [node-redis](https://github.com/redis/node-redis) repo.

13
backend/node_modules/@redis/client/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import RedisClient from './lib/client';
import RedisCluster from './lib/cluster';
export { RedisClientType, RedisClientOptions } from './lib/client';
export { RedisModules, RedisFunctions, RedisScripts } from './lib/commands';
export declare const createClient: typeof RedisClient.create;
export declare const commandOptions: typeof RedisClient.commandOptions;
export { RedisClusterType, RedisClusterOptions } from './lib/cluster';
export declare const createCluster: typeof RedisCluster.create;
export { defineScript } from './lib/lua-script';
export * from './lib/errors';
export { GeoReplyWith } from './lib/commands/generic-transformers';
export { SetOptions } from './lib/commands/SET';
export { RedisFlushModes } from './lib/commands/FLUSHALL';

29
backend/node_modules/@redis/client/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RedisFlushModes = exports.GeoReplyWith = exports.defineScript = exports.createCluster = exports.commandOptions = exports.createClient = void 0;
const client_1 = require("./lib/client");
const cluster_1 = require("./lib/cluster");
exports.createClient = client_1.default.create;
exports.commandOptions = client_1.default.commandOptions;
exports.createCluster = cluster_1.default.create;
var lua_script_1 = require("./lib/lua-script");
Object.defineProperty(exports, "defineScript", { enumerable: true, get: function () { return lua_script_1.defineScript; } });
__exportStar(require("./lib/errors"), exports);
var generic_transformers_1 = require("./lib/commands/generic-transformers");
Object.defineProperty(exports, "GeoReplyWith", { enumerable: true, get: function () { return generic_transformers_1.GeoReplyWith; } });
var FLUSHALL_1 = require("./lib/commands/FLUSHALL");
Object.defineProperty(exports, "RedisFlushModes", { enumerable: true, get: function () { return FLUSHALL_1.RedisFlushModes; } });

View File

@@ -0,0 +1,8 @@
/// <reference types="node" />
import { Composer } from './interface';
export default class BufferComposer implements Composer<Buffer> {
private chunks;
write(buffer: Buffer): void;
end(buffer: Buffer): Buffer;
reset(): void;
}

View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class BufferComposer {
constructor() {
Object.defineProperty(this, "chunks", {
enumerable: true,
configurable: true,
writable: true,
value: []
});
}
write(buffer) {
this.chunks.push(buffer);
}
end(buffer) {
this.write(buffer);
return Buffer.concat(this.chunks.splice(0));
}
reset() {
this.chunks = [];
}
}
exports.default = BufferComposer;

View File

@@ -0,0 +1,6 @@
/// <reference types="node" />
export interface Composer<T> {
write(buffer: Buffer): void;
end(buffer: Buffer): T;
reset(): void;
}

View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -0,0 +1,9 @@
/// <reference types="node" />
import { Composer } from './interface';
export default class StringComposer implements Composer<string> {
private decoder;
private string;
write(buffer: Buffer): void;
end(buffer: Buffer): string;
reset(): void;
}

View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const string_decoder_1 = require("string_decoder");
class StringComposer {
constructor() {
Object.defineProperty(this, "decoder", {
enumerable: true,
configurable: true,
writable: true,
value: new string_decoder_1.StringDecoder()
});
Object.defineProperty(this, "string", {
enumerable: true,
configurable: true,
writable: true,
value: ''
});
}
write(buffer) {
this.string += this.decoder.write(buffer);
}
end(buffer) {
const string = this.string + this.decoder.end(buffer);
this.string = '';
return string;
}
reset() {
this.string = '';
}
}
exports.default = StringComposer;

View File

@@ -0,0 +1,35 @@
/// <reference types="node" />
import { ErrorReply } from '../../errors';
export type Reply = string | Buffer | ErrorReply | number | null | Array<Reply>;
export type ReturnStringsAsBuffers = () => boolean;
interface RESP2Options {
returnStringsAsBuffers: ReturnStringsAsBuffers;
onReply(reply: Reply): unknown;
}
export default class RESP2Decoder {
private options;
constructor(options: RESP2Options);
private cursor;
private type?;
private bufferComposer;
private stringComposer;
private currentStringComposer;
reset(): void;
write(chunk: Buffer): void;
private parseType;
private compose;
private parseSimpleString;
private parseError;
private integer;
private isNegativeInteger?;
private parseInteger;
private bulkStringRemainingLength?;
private parseBulkString;
private arraysInProcess;
private initializeArray;
private arrayItemType?;
private parseArray;
private returnArrayReply;
private pushArrayItem;
}
export {};

View File

@@ -0,0 +1,250 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const errors_1 = require("../../errors");
const buffer_1 = require("./composers/buffer");
const string_1 = require("./composers/string");
// RESP2 specification
// https://redis.io/topics/protocol
var Types;
(function (Types) {
Types[Types["SIMPLE_STRING"] = 43] = "SIMPLE_STRING";
Types[Types["ERROR"] = 45] = "ERROR";
Types[Types["INTEGER"] = 58] = "INTEGER";
Types[Types["BULK_STRING"] = 36] = "BULK_STRING";
Types[Types["ARRAY"] = 42] = "ARRAY"; // *
})(Types || (Types = {}));
var ASCII;
(function (ASCII) {
ASCII[ASCII["CR"] = 13] = "CR";
ASCII[ASCII["ZERO"] = 48] = "ZERO";
ASCII[ASCII["MINUS"] = 45] = "MINUS";
})(ASCII || (ASCII = {}));
// Using TypeScript `private` and not the build-in `#` to avoid __classPrivateFieldGet and __classPrivateFieldSet
class RESP2Decoder {
constructor(options) {
Object.defineProperty(this, "options", {
enumerable: true,
configurable: true,
writable: true,
value: options
});
Object.defineProperty(this, "cursor", {
enumerable: true,
configurable: true,
writable: true,
value: 0
});
Object.defineProperty(this, "type", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "bufferComposer", {
enumerable: true,
configurable: true,
writable: true,
value: new buffer_1.default()
});
Object.defineProperty(this, "stringComposer", {
enumerable: true,
configurable: true,
writable: true,
value: new string_1.default()
});
Object.defineProperty(this, "currentStringComposer", {
enumerable: true,
configurable: true,
writable: true,
value: this.stringComposer
});
Object.defineProperty(this, "integer", {
enumerable: true,
configurable: true,
writable: true,
value: 0
});
Object.defineProperty(this, "isNegativeInteger", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "bulkStringRemainingLength", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "arraysInProcess", {
enumerable: true,
configurable: true,
writable: true,
value: []
});
Object.defineProperty(this, "initializeArray", {
enumerable: true,
configurable: true,
writable: true,
value: false
});
Object.defineProperty(this, "arrayItemType", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
}
reset() {
this.cursor = 0;
this.type = undefined;
this.bufferComposer.reset();
this.stringComposer.reset();
this.currentStringComposer = this.stringComposer;
}
write(chunk) {
while (this.cursor < chunk.length) {
if (!this.type) {
this.currentStringComposer = this.options.returnStringsAsBuffers() ?
this.bufferComposer :
this.stringComposer;
this.type = chunk[this.cursor];
if (++this.cursor >= chunk.length)
break;
}
const reply = this.parseType(chunk, this.type);
if (reply === undefined)
break;
this.type = undefined;
this.options.onReply(reply);
}
this.cursor -= chunk.length;
}
parseType(chunk, type, arraysToKeep) {
switch (type) {
case Types.SIMPLE_STRING:
return this.parseSimpleString(chunk);
case Types.ERROR:
return this.parseError(chunk);
case Types.INTEGER:
return this.parseInteger(chunk);
case Types.BULK_STRING:
return this.parseBulkString(chunk);
case Types.ARRAY:
return this.parseArray(chunk, arraysToKeep);
}
}
compose(chunk, composer) {
for (let i = this.cursor; i < chunk.length; i++) {
if (chunk[i] === ASCII.CR) {
const reply = composer.end(chunk.subarray(this.cursor, i));
this.cursor = i + 2;
return reply;
}
}
const toWrite = chunk.subarray(this.cursor);
composer.write(toWrite);
this.cursor = chunk.length;
}
parseSimpleString(chunk) {
return this.compose(chunk, this.currentStringComposer);
}
parseError(chunk) {
const message = this.compose(chunk, this.stringComposer);
if (message !== undefined) {
return new errors_1.ErrorReply(message);
}
}
parseInteger(chunk) {
if (this.isNegativeInteger === undefined) {
this.isNegativeInteger = chunk[this.cursor] === ASCII.MINUS;
if (this.isNegativeInteger && ++this.cursor === chunk.length)
return;
}
do {
const byte = chunk[this.cursor];
if (byte === ASCII.CR) {
const integer = this.isNegativeInteger ? -this.integer : this.integer;
this.integer = 0;
this.isNegativeInteger = undefined;
this.cursor += 2;
return integer;
}
this.integer = this.integer * 10 + byte - ASCII.ZERO;
} while (++this.cursor < chunk.length);
}
parseBulkString(chunk) {
if (this.bulkStringRemainingLength === undefined) {
const length = this.parseInteger(chunk);
if (length === undefined)
return;
if (length === -1)
return null;
this.bulkStringRemainingLength = length;
if (this.cursor >= chunk.length)
return;
}
const end = this.cursor + this.bulkStringRemainingLength;
if (chunk.length >= end) {
const reply = this.currentStringComposer.end(chunk.subarray(this.cursor, end));
this.bulkStringRemainingLength = undefined;
this.cursor = end + 2;
return reply;
}
const toWrite = chunk.subarray(this.cursor);
this.currentStringComposer.write(toWrite);
this.bulkStringRemainingLength -= toWrite.length;
this.cursor = chunk.length;
}
parseArray(chunk, arraysToKeep = 0) {
if (this.initializeArray || this.arraysInProcess.length === arraysToKeep) {
const length = this.parseInteger(chunk);
if (length === undefined) {
this.initializeArray = true;
return undefined;
}
this.initializeArray = false;
this.arrayItemType = undefined;
if (length === -1) {
return this.returnArrayReply(null, arraysToKeep, chunk);
}
else if (length === 0) {
return this.returnArrayReply([], arraysToKeep, chunk);
}
this.arraysInProcess.push({
array: new Array(length),
pushCounter: 0
});
}
while (this.cursor < chunk.length) {
if (!this.arrayItemType) {
this.arrayItemType = chunk[this.cursor];
if (++this.cursor >= chunk.length)
break;
}
const item = this.parseType(chunk, this.arrayItemType, arraysToKeep + 1);
if (item === undefined)
break;
this.arrayItemType = undefined;
const reply = this.pushArrayItem(item, arraysToKeep);
if (reply !== undefined)
return reply;
}
}
returnArrayReply(reply, arraysToKeep, chunk) {
if (this.arraysInProcess.length <= arraysToKeep)
return reply;
return this.pushArrayItem(reply, arraysToKeep, chunk);
}
pushArrayItem(item, arraysToKeep, chunk) {
const to = this.arraysInProcess[this.arraysInProcess.length - 1];
to.array[to.pushCounter] = item;
if (++to.pushCounter === to.array.length) {
return this.returnArrayReply(this.arraysInProcess.pop().array, arraysToKeep, chunk);
}
else if (chunk && chunk.length > this.cursor) {
return this.parseArray(chunk, arraysToKeep);
}
}
}
exports.default = RESP2Decoder;

View File

@@ -0,0 +1,2 @@
import { RedisCommandArgument, RedisCommandArguments } from '../../commands';
export default function encodeCommand(args: RedisCommandArguments): Array<RedisCommandArgument>;

View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const CRLF = '\r\n';
function encodeCommand(args) {
const toWrite = [];
let strings = '*' + args.length + CRLF;
for (let i = 0; i < args.length; i++) {
const arg = args[i];
if (typeof arg === 'string') {
strings += '$' + Buffer.byteLength(arg) + CRLF + arg + CRLF;
}
else if (arg instanceof Buffer) {
toWrite.push(strings + '$' + arg.length.toString() + CRLF, arg);
strings = CRLF;
}
else {
throw new TypeError('Invalid argument type');
}
}
toWrite.push(strings);
return toWrite;
}
exports.default = encodeCommand;

View File

@@ -0,0 +1,42 @@
/// <reference types="node" />
/// <reference types="node" />
import { RedisCommandArguments, RedisCommandRawReply } from '../commands';
import { ChannelListeners, PubSubListener, PubSubType, PubSubTypeListeners } from './pub-sub';
export interface QueueCommandOptions {
asap?: boolean;
chainId?: symbol;
signal?: AbortSignal;
returnBuffers?: boolean;
}
export interface CommandWaitingToBeSent extends CommandWaitingForReply {
args: RedisCommandArguments;
chainId?: symbol;
abort?: {
signal: AbortSignal;
listener(): void;
};
}
interface CommandWaitingForReply {
resolve(reply?: unknown): void;
reject(err: unknown): void;
channelsCounter?: number;
returnBuffers?: boolean;
}
export type OnShardedChannelMoved = (channel: string, listeners: ChannelListeners) => void;
export default class RedisCommandsQueue {
#private;
get isPubSubActive(): boolean;
constructor(maxLength: number | null | undefined, onShardedChannelMoved: OnShardedChannelMoved);
addCommand<T = RedisCommandRawReply>(args: RedisCommandArguments, options?: QueueCommandOptions): Promise<T>;
subscribe<T extends boolean>(type: PubSubType, channels: string | Array<string>, listener: PubSubListener<T>, returnBuffers?: T): Promise<void> | undefined;
unsubscribe<T extends boolean>(type: PubSubType, channels?: string | Array<string>, listener?: PubSubListener<T>, returnBuffers?: T): Promise<void> | undefined;
resubscribe(): Promise<any> | undefined;
extendPubSubChannelListeners(type: PubSubType, channel: string, listeners: ChannelListeners): Promise<void> | undefined;
extendPubSubListeners(type: PubSubType, listeners: PubSubTypeListeners): Promise<void> | undefined;
getPubSubListeners(type: PubSubType): PubSubTypeListeners;
getCommandToSend(): RedisCommandArguments | undefined;
onReplyChunk(chunk: Buffer): void;
flushWaitingForReply(err: Error): void;
flushAll(err: Error): void;
}
export {};

View File

@@ -0,0 +1,197 @@
"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _RedisCommandsQueue_instances, _a, _RedisCommandsQueue_flushQueue, _RedisCommandsQueue_maxLength, _RedisCommandsQueue_waitingToBeSent, _RedisCommandsQueue_waitingForReply, _RedisCommandsQueue_onShardedChannelMoved, _RedisCommandsQueue_pubSub, _RedisCommandsQueue_chainInExecution, _RedisCommandsQueue_decoder, _RedisCommandsQueue_pushPubSubCommand;
Object.defineProperty(exports, "__esModule", { value: true });
const LinkedList = require("yallist");
const errors_1 = require("../errors");
const decoder_1 = require("./RESP2/decoder");
const encoder_1 = require("./RESP2/encoder");
const pub_sub_1 = require("./pub-sub");
const PONG = Buffer.from('pong');
class RedisCommandsQueue {
get isPubSubActive() {
return __classPrivateFieldGet(this, _RedisCommandsQueue_pubSub, "f").isActive;
}
constructor(maxLength, onShardedChannelMoved) {
_RedisCommandsQueue_instances.add(this);
_RedisCommandsQueue_maxLength.set(this, void 0);
_RedisCommandsQueue_waitingToBeSent.set(this, new LinkedList());
_RedisCommandsQueue_waitingForReply.set(this, new LinkedList());
_RedisCommandsQueue_onShardedChannelMoved.set(this, void 0);
_RedisCommandsQueue_pubSub.set(this, new pub_sub_1.PubSub());
_RedisCommandsQueue_chainInExecution.set(this, void 0);
_RedisCommandsQueue_decoder.set(this, new decoder_1.default({
returnStringsAsBuffers: () => {
return !!__classPrivateFieldGet(this, _RedisCommandsQueue_waitingForReply, "f").head?.value.returnBuffers ||
__classPrivateFieldGet(this, _RedisCommandsQueue_pubSub, "f").isActive;
},
onReply: reply => {
if (__classPrivateFieldGet(this, _RedisCommandsQueue_pubSub, "f").isActive && Array.isArray(reply)) {
if (__classPrivateFieldGet(this, _RedisCommandsQueue_pubSub, "f").handleMessageReply(reply))
return;
const isShardedUnsubscribe = pub_sub_1.PubSub.isShardedUnsubscribe(reply);
if (isShardedUnsubscribe && !__classPrivateFieldGet(this, _RedisCommandsQueue_waitingForReply, "f").length) {
const channel = reply[1].toString();
__classPrivateFieldGet(this, _RedisCommandsQueue_onShardedChannelMoved, "f").call(this, channel, __classPrivateFieldGet(this, _RedisCommandsQueue_pubSub, "f").removeShardedListeners(channel));
return;
}
else if (isShardedUnsubscribe || pub_sub_1.PubSub.isStatusReply(reply)) {
const head = __classPrivateFieldGet(this, _RedisCommandsQueue_waitingForReply, "f").head.value;
if ((Number.isNaN(head.channelsCounter) && reply[2] === 0) ||
--head.channelsCounter === 0) {
__classPrivateFieldGet(this, _RedisCommandsQueue_waitingForReply, "f").shift().resolve();
}
return;
}
if (PONG.equals(reply[0])) {
const { resolve, returnBuffers } = __classPrivateFieldGet(this, _RedisCommandsQueue_waitingForReply, "f").shift(), buffer = (reply[1].length === 0 ? reply[0] : reply[1]);
resolve(returnBuffers ? buffer : buffer.toString());
return;
}
}
const { resolve, reject } = __classPrivateFieldGet(this, _RedisCommandsQueue_waitingForReply, "f").shift();
if (reply instanceof errors_1.ErrorReply) {
reject(reply);
}
else {
resolve(reply);
}
}
}));
__classPrivateFieldSet(this, _RedisCommandsQueue_maxLength, maxLength, "f");
__classPrivateFieldSet(this, _RedisCommandsQueue_onShardedChannelMoved, onShardedChannelMoved, "f");
}
addCommand(args, options) {
if (__classPrivateFieldGet(this, _RedisCommandsQueue_maxLength, "f") && __classPrivateFieldGet(this, _RedisCommandsQueue_waitingToBeSent, "f").length + __classPrivateFieldGet(this, _RedisCommandsQueue_waitingForReply, "f").length >= __classPrivateFieldGet(this, _RedisCommandsQueue_maxLength, "f")) {
return Promise.reject(new Error('The queue is full'));
}
else if (options?.signal?.aborted) {
return Promise.reject(new errors_1.AbortError());
}
return new Promise((resolve, reject) => {
const node = new LinkedList.Node({
args,
chainId: options?.chainId,
returnBuffers: options?.returnBuffers,
resolve,
reject
});
if (options?.signal) {
const listener = () => {
__classPrivateFieldGet(this, _RedisCommandsQueue_waitingToBeSent, "f").removeNode(node);
node.value.reject(new errors_1.AbortError());
};
node.value.abort = {
signal: options.signal,
listener
};
// AbortSignal type is incorrent
options.signal.addEventListener('abort', listener, {
once: true
});
}
if (options?.asap) {
__classPrivateFieldGet(this, _RedisCommandsQueue_waitingToBeSent, "f").unshiftNode(node);
}
else {
__classPrivateFieldGet(this, _RedisCommandsQueue_waitingToBeSent, "f").pushNode(node);
}
});
}
subscribe(type, channels, listener, returnBuffers) {
return __classPrivateFieldGet(this, _RedisCommandsQueue_instances, "m", _RedisCommandsQueue_pushPubSubCommand).call(this, __classPrivateFieldGet(this, _RedisCommandsQueue_pubSub, "f").subscribe(type, channels, listener, returnBuffers));
}
unsubscribe(type, channels, listener, returnBuffers) {
return __classPrivateFieldGet(this, _RedisCommandsQueue_instances, "m", _RedisCommandsQueue_pushPubSubCommand).call(this, __classPrivateFieldGet(this, _RedisCommandsQueue_pubSub, "f").unsubscribe(type, channels, listener, returnBuffers));
}
resubscribe() {
const commands = __classPrivateFieldGet(this, _RedisCommandsQueue_pubSub, "f").resubscribe();
if (!commands.length)
return;
return Promise.all(commands.map(command => __classPrivateFieldGet(this, _RedisCommandsQueue_instances, "m", _RedisCommandsQueue_pushPubSubCommand).call(this, command)));
}
extendPubSubChannelListeners(type, channel, listeners) {
return __classPrivateFieldGet(this, _RedisCommandsQueue_instances, "m", _RedisCommandsQueue_pushPubSubCommand).call(this, __classPrivateFieldGet(this, _RedisCommandsQueue_pubSub, "f").extendChannelListeners(type, channel, listeners));
}
extendPubSubListeners(type, listeners) {
return __classPrivateFieldGet(this, _RedisCommandsQueue_instances, "m", _RedisCommandsQueue_pushPubSubCommand).call(this, __classPrivateFieldGet(this, _RedisCommandsQueue_pubSub, "f").extendTypeListeners(type, listeners));
}
getPubSubListeners(type) {
return __classPrivateFieldGet(this, _RedisCommandsQueue_pubSub, "f").getTypeListeners(type);
}
getCommandToSend() {
const toSend = __classPrivateFieldGet(this, _RedisCommandsQueue_waitingToBeSent, "f").shift();
if (!toSend)
return;
let encoded;
try {
encoded = (0, encoder_1.default)(toSend.args);
}
catch (err) {
toSend.reject(err);
return;
}
__classPrivateFieldGet(this, _RedisCommandsQueue_waitingForReply, "f").push({
resolve: toSend.resolve,
reject: toSend.reject,
channelsCounter: toSend.channelsCounter,
returnBuffers: toSend.returnBuffers
});
__classPrivateFieldSet(this, _RedisCommandsQueue_chainInExecution, toSend.chainId, "f");
return encoded;
}
onReplyChunk(chunk) {
__classPrivateFieldGet(this, _RedisCommandsQueue_decoder, "f").write(chunk);
}
flushWaitingForReply(err) {
__classPrivateFieldGet(this, _RedisCommandsQueue_decoder, "f").reset();
__classPrivateFieldGet(this, _RedisCommandsQueue_pubSub, "f").reset();
__classPrivateFieldGet(_a, _a, "m", _RedisCommandsQueue_flushQueue).call(_a, __classPrivateFieldGet(this, _RedisCommandsQueue_waitingForReply, "f"), err);
if (!__classPrivateFieldGet(this, _RedisCommandsQueue_chainInExecution, "f"))
return;
while (__classPrivateFieldGet(this, _RedisCommandsQueue_waitingToBeSent, "f").head?.value.chainId === __classPrivateFieldGet(this, _RedisCommandsQueue_chainInExecution, "f")) {
__classPrivateFieldGet(this, _RedisCommandsQueue_waitingToBeSent, "f").shift();
}
__classPrivateFieldSet(this, _RedisCommandsQueue_chainInExecution, undefined, "f");
}
flushAll(err) {
__classPrivateFieldGet(this, _RedisCommandsQueue_decoder, "f").reset();
__classPrivateFieldGet(this, _RedisCommandsQueue_pubSub, "f").reset();
__classPrivateFieldGet(_a, _a, "m", _RedisCommandsQueue_flushQueue).call(_a, __classPrivateFieldGet(this, _RedisCommandsQueue_waitingForReply, "f"), err);
__classPrivateFieldGet(_a, _a, "m", _RedisCommandsQueue_flushQueue).call(_a, __classPrivateFieldGet(this, _RedisCommandsQueue_waitingToBeSent, "f"), err);
}
}
_a = RedisCommandsQueue, _RedisCommandsQueue_maxLength = new WeakMap(), _RedisCommandsQueue_waitingToBeSent = new WeakMap(), _RedisCommandsQueue_waitingForReply = new WeakMap(), _RedisCommandsQueue_onShardedChannelMoved = new WeakMap(), _RedisCommandsQueue_pubSub = new WeakMap(), _RedisCommandsQueue_chainInExecution = new WeakMap(), _RedisCommandsQueue_decoder = new WeakMap(), _RedisCommandsQueue_instances = new WeakSet(), _RedisCommandsQueue_flushQueue = function _RedisCommandsQueue_flushQueue(queue, err) {
while (queue.length) {
queue.shift().reject(err);
}
}, _RedisCommandsQueue_pushPubSubCommand = function _RedisCommandsQueue_pushPubSubCommand(command) {
if (command === undefined)
return;
return new Promise((resolve, reject) => {
__classPrivateFieldGet(this, _RedisCommandsQueue_waitingToBeSent, "f").push({
args: command.args,
channelsCounter: command.channelsCounter,
returnBuffers: true,
resolve: () => {
command.resolve();
resolve();
},
reject: err => {
command.reject?.();
reject(err);
}
});
});
};
exports.default = RedisCommandsQueue;

View File

@@ -0,0 +1,816 @@
import * as ACL_CAT from '../commands/ACL_CAT';
import * as ACL_DELUSER from '../commands/ACL_DELUSER';
import * as ACL_DRYRUN from '../commands/ACL_DRYRUN';
import * as ACL_GENPASS from '../commands/ACL_GENPASS';
import * as ACL_GETUSER from '../commands/ACL_GETUSER';
import * as ACL_LIST from '../commands/ACL_LIST';
import * as ACL_LOAD from '../commands/ACL_LOAD';
import * as ACL_LOG_RESET from '../commands/ACL_LOG_RESET';
import * as ACL_LOG from '../commands/ACL_LOG';
import * as ACL_SAVE from '../commands/ACL_SAVE';
import * as ACL_SETUSER from '../commands/ACL_SETUSER';
import * as ACL_USERS from '../commands/ACL_USERS';
import * as ACL_WHOAMI from '../commands/ACL_WHOAMI';
import * as ASKING from '../commands/ASKING';
import * as AUTH from '../commands/AUTH';
import * as BGREWRITEAOF from '../commands/BGREWRITEAOF';
import * as BGSAVE from '../commands/BGSAVE';
import * as CLIENT_CACHING from '../commands/CLIENT_CACHING';
import * as CLIENT_GETNAME from '../commands/CLIENT_GETNAME';
import * as CLIENT_GETREDIR from '../commands/CLIENT_GETREDIR';
import * as CLIENT_ID from '../commands/CLIENT_ID';
import * as CLIENT_KILL from '../commands/CLIENT_KILL';
import * as CLIENT_LIST from '../commands/CLIENT_LIST';
import * as CLIENT_NO_EVICT from '../commands/CLIENT_NO-EVICT';
import * as CLIENT_NO_TOUCH from '../commands/CLIENT_NO-TOUCH';
import * as CLIENT_PAUSE from '../commands/CLIENT_PAUSE';
import * as CLIENT_SETNAME from '../commands/CLIENT_SETNAME';
import * as CLIENT_TRACKING from '../commands/CLIENT_TRACKING';
import * as CLIENT_TRACKINGINFO from '../commands/CLIENT_TRACKINGINFO';
import * as CLIENT_UNPAUSE from '../commands/CLIENT_UNPAUSE';
import * as CLIENT_INFO from '../commands/CLIENT_INFO';
import * as CLUSTER_ADDSLOTS from '../commands/CLUSTER_ADDSLOTS';
import * as CLUSTER_ADDSLOTSRANGE from '../commands/CLUSTER_ADDSLOTSRANGE';
import * as CLUSTER_BUMPEPOCH from '../commands/CLUSTER_BUMPEPOCH';
import * as CLUSTER_COUNT_FAILURE_REPORTS from '../commands/CLUSTER_COUNT-FAILURE-REPORTS';
import * as CLUSTER_COUNTKEYSINSLOT from '../commands/CLUSTER_COUNTKEYSINSLOT';
import * as CLUSTER_DELSLOTS from '../commands/CLUSTER_DELSLOTS';
import * as CLUSTER_DELSLOTSRANGE from '../commands/CLUSTER_DELSLOTSRANGE';
import * as CLUSTER_FAILOVER from '../commands/CLUSTER_FAILOVER';
import * as CLUSTER_FLUSHSLOTS from '../commands/CLUSTER_FLUSHSLOTS';
import * as CLUSTER_FORGET from '../commands/CLUSTER_FORGET';
import * as CLUSTER_GETKEYSINSLOT from '../commands/CLUSTER_GETKEYSINSLOT';
import * as CLUSTER_INFO from '../commands/CLUSTER_INFO';
import * as CLUSTER_KEYSLOT from '../commands/CLUSTER_KEYSLOT';
import * as CLUSTER_LINKS from '../commands/CLUSTER_LINKS';
import * as CLUSTER_MEET from '../commands/CLUSTER_MEET';
import * as CLUSTER_MYID from '../commands/CLUSTER_MYID';
import * as CLUSTER_MYSHARDID from '../commands/CLUSTER_MYSHARDID';
import * as CLUSTER_NODES from '../commands/CLUSTER_NODES';
import * as CLUSTER_REPLICAS from '../commands/CLUSTER_REPLICAS';
import * as CLUSTER_REPLICATE from '../commands/CLUSTER_REPLICATE';
import * as CLUSTER_RESET from '../commands/CLUSTER_RESET';
import * as CLUSTER_SAVECONFIG from '../commands/CLUSTER_SAVECONFIG';
import * as CLUSTER_SET_CONFIG_EPOCH from '../commands/CLUSTER_SET-CONFIG-EPOCH';
import * as CLUSTER_SETSLOT from '../commands/CLUSTER_SETSLOT';
import * as CLUSTER_SLOTS from '../commands/CLUSTER_SLOTS';
import * as COMMAND_COUNT from '../commands/COMMAND_COUNT';
import * as COMMAND_GETKEYS from '../commands/COMMAND_GETKEYS';
import * as COMMAND_GETKEYSANDFLAGS from '../commands/COMMAND_GETKEYSANDFLAGS';
import * as COMMAND_INFO from '../commands/COMMAND_INFO';
import * as COMMAND_LIST from '../commands/COMMAND_LIST';
import * as COMMAND from '../commands/COMMAND';
import * as CONFIG_GET from '../commands/CONFIG_GET';
import * as CONFIG_RESETASTAT from '../commands/CONFIG_RESETSTAT';
import * as CONFIG_REWRITE from '../commands/CONFIG_REWRITE';
import * as CONFIG_SET from '../commands/CONFIG_SET';
import * as DBSIZE from '../commands/DBSIZE';
import * as DISCARD from '../commands/DISCARD';
import * as ECHO from '../commands/ECHO';
import * as FAILOVER from '../commands/FAILOVER';
import * as FLUSHALL from '../commands/FLUSHALL';
import * as FLUSHDB from '../commands/FLUSHDB';
import * as FUNCTION_DELETE from '../commands/FUNCTION_DELETE';
import * as FUNCTION_DUMP from '../commands/FUNCTION_DUMP';
import * as FUNCTION_FLUSH from '../commands/FUNCTION_FLUSH';
import * as FUNCTION_KILL from '../commands/FUNCTION_KILL';
import * as FUNCTION_LIST_WITHCODE from '../commands/FUNCTION_LIST_WITHCODE';
import * as FUNCTION_LIST from '../commands/FUNCTION_LIST';
import * as FUNCTION_LOAD from '../commands/FUNCTION_LOAD';
import * as FUNCTION_RESTORE from '../commands/FUNCTION_RESTORE';
import * as FUNCTION_STATS from '../commands/FUNCTION_STATS';
import * as HELLO from '../commands/HELLO';
import * as INFO from '../commands/INFO';
import * as KEYS from '../commands/KEYS';
import * as LASTSAVE from '../commands/LASTSAVE';
import * as LATENCY_DOCTOR from '../commands/LATENCY_DOCTOR';
import * as LATENCY_GRAPH from '../commands/LATENCY_GRAPH';
import * as LATENCY_HISTORY from '../commands/LATENCY_HISTORY';
import * as LATENCY_LATEST from '../commands/LATENCY_LATEST';
import * as LOLWUT from '../commands/LOLWUT';
import * as MEMORY_DOCTOR from '../commands/MEMORY_DOCTOR';
import * as MEMORY_MALLOC_STATS from '../commands/MEMORY_MALLOC-STATS';
import * as MEMORY_PURGE from '../commands/MEMORY_PURGE';
import * as MEMORY_STATS from '../commands/MEMORY_STATS';
import * as MEMORY_USAGE from '../commands/MEMORY_USAGE';
import * as MODULE_LIST from '../commands/MODULE_LIST';
import * as MODULE_LOAD from '../commands/MODULE_LOAD';
import * as MODULE_UNLOAD from '../commands/MODULE_UNLOAD';
import * as MOVE from '../commands/MOVE';
import * as PING from '../commands/PING';
import * as PUBSUB_CHANNELS from '../commands/PUBSUB_CHANNELS';
import * as PUBSUB_NUMPAT from '../commands/PUBSUB_NUMPAT';
import * as PUBSUB_NUMSUB from '../commands/PUBSUB_NUMSUB';
import * as PUBSUB_SHARDCHANNELS from '../commands/PUBSUB_SHARDCHANNELS';
import * as PUBSUB_SHARDNUMSUB from '../commands/PUBSUB_SHARDNUMSUB';
import * as RANDOMKEY from '../commands/RANDOMKEY';
import * as READONLY from '../commands/READONLY';
import * as READWRITE from '../commands/READWRITE';
import * as REPLICAOF from '../commands/REPLICAOF';
import * as RESTORE_ASKING from '../commands/RESTORE-ASKING';
import * as ROLE from '../commands/ROLE';
import * as SAVE from '../commands/SAVE';
import * as SCAN from '../commands/SCAN';
import * as SCRIPT_DEBUG from '../commands/SCRIPT_DEBUG';
import * as SCRIPT_EXISTS from '../commands/SCRIPT_EXISTS';
import * as SCRIPT_FLUSH from '../commands/SCRIPT_FLUSH';
import * as SCRIPT_KILL from '../commands/SCRIPT_KILL';
import * as SCRIPT_LOAD from '../commands/SCRIPT_LOAD';
import * as SHUTDOWN from '../commands/SHUTDOWN';
import * as SWAPDB from '../commands/SWAPDB';
import * as TIME from '../commands/TIME';
import * as UNWATCH from '../commands/UNWATCH';
import * as WAIT from '../commands/WAIT';
declare const _default: {
ACL_CAT: typeof ACL_CAT;
aclCat: typeof ACL_CAT;
ACL_DELUSER: typeof ACL_DELUSER;
aclDelUser: typeof ACL_DELUSER;
ACL_DRYRUN: typeof ACL_DRYRUN;
aclDryRun: typeof ACL_DRYRUN;
ACL_GENPASS: typeof ACL_GENPASS;
aclGenPass: typeof ACL_GENPASS;
ACL_GETUSER: typeof ACL_GETUSER;
aclGetUser: typeof ACL_GETUSER;
ACL_LIST: typeof ACL_LIST;
aclList: typeof ACL_LIST;
ACL_LOAD: typeof ACL_LOAD;
aclLoad: typeof ACL_LOAD;
ACL_LOG_RESET: typeof ACL_LOG_RESET;
aclLogReset: typeof ACL_LOG_RESET;
ACL_LOG: typeof ACL_LOG;
aclLog: typeof ACL_LOG;
ACL_SAVE: typeof ACL_SAVE;
aclSave: typeof ACL_SAVE;
ACL_SETUSER: typeof ACL_SETUSER;
aclSetUser: typeof ACL_SETUSER;
ACL_USERS: typeof ACL_USERS;
aclUsers: typeof ACL_USERS;
ACL_WHOAMI: typeof ACL_WHOAMI;
aclWhoAmI: typeof ACL_WHOAMI;
ASKING: typeof ASKING;
asking: typeof ASKING;
AUTH: typeof AUTH;
auth: typeof AUTH;
BGREWRITEAOF: typeof BGREWRITEAOF;
bgRewriteAof: typeof BGREWRITEAOF;
BGSAVE: typeof BGSAVE;
bgSave: typeof BGSAVE;
CLIENT_CACHING: typeof CLIENT_CACHING;
clientCaching: typeof CLIENT_CACHING;
CLIENT_GETNAME: typeof CLIENT_GETNAME;
clientGetName: typeof CLIENT_GETNAME;
CLIENT_GETREDIR: typeof CLIENT_GETREDIR;
clientGetRedir: typeof CLIENT_GETREDIR;
CLIENT_ID: typeof CLIENT_ID;
clientId: typeof CLIENT_ID;
CLIENT_KILL: typeof CLIENT_KILL;
clientKill: typeof CLIENT_KILL;
'CLIENT_NO-EVICT': typeof CLIENT_NO_EVICT;
clientNoEvict: typeof CLIENT_NO_EVICT;
'CLIENT_NO-TOUCH': typeof CLIENT_NO_TOUCH;
clientNoTouch: typeof CLIENT_NO_TOUCH;
CLIENT_LIST: typeof CLIENT_LIST;
clientList: typeof CLIENT_LIST;
CLIENT_PAUSE: typeof CLIENT_PAUSE;
clientPause: typeof CLIENT_PAUSE;
CLIENT_SETNAME: typeof CLIENT_SETNAME;
clientSetName: typeof CLIENT_SETNAME;
CLIENT_TRACKING: typeof CLIENT_TRACKING;
clientTracking: typeof CLIENT_TRACKING;
CLIENT_TRACKINGINFO: typeof CLIENT_TRACKINGINFO;
clientTrackingInfo: typeof CLIENT_TRACKINGINFO;
CLIENT_UNPAUSE: typeof CLIENT_UNPAUSE;
clientUnpause: typeof CLIENT_UNPAUSE;
CLIENT_INFO: typeof CLIENT_INFO;
clientInfo: typeof CLIENT_INFO;
CLUSTER_ADDSLOTS: typeof CLUSTER_ADDSLOTS;
clusterAddSlots: typeof CLUSTER_ADDSLOTS;
CLUSTER_ADDSLOTSRANGE: typeof CLUSTER_ADDSLOTSRANGE;
clusterAddSlotsRange: typeof CLUSTER_ADDSLOTSRANGE;
CLUSTER_BUMPEPOCH: typeof CLUSTER_BUMPEPOCH;
clusterBumpEpoch: typeof CLUSTER_BUMPEPOCH;
CLUSTER_COUNT_FAILURE_REPORTS: typeof CLUSTER_COUNT_FAILURE_REPORTS;
clusterCountFailureReports: typeof CLUSTER_COUNT_FAILURE_REPORTS;
CLUSTER_COUNTKEYSINSLOT: typeof CLUSTER_COUNTKEYSINSLOT;
clusterCountKeysInSlot: typeof CLUSTER_COUNTKEYSINSLOT;
CLUSTER_DELSLOTS: typeof CLUSTER_DELSLOTS;
clusterDelSlots: typeof CLUSTER_DELSLOTS;
CLUSTER_DELSLOTSRANGE: typeof CLUSTER_DELSLOTSRANGE;
clusterDelSlotsRange: typeof CLUSTER_DELSLOTSRANGE;
CLUSTER_FAILOVER: typeof CLUSTER_FAILOVER;
clusterFailover: typeof CLUSTER_FAILOVER;
CLUSTER_FLUSHSLOTS: typeof CLUSTER_FLUSHSLOTS;
clusterFlushSlots: typeof CLUSTER_FLUSHSLOTS;
CLUSTER_FORGET: typeof CLUSTER_FORGET;
clusterForget: typeof CLUSTER_FORGET;
CLUSTER_GETKEYSINSLOT: typeof CLUSTER_GETKEYSINSLOT;
clusterGetKeysInSlot: typeof CLUSTER_GETKEYSINSLOT;
CLUSTER_INFO: typeof CLUSTER_INFO;
clusterInfo: typeof CLUSTER_INFO;
CLUSTER_KEYSLOT: typeof CLUSTER_KEYSLOT;
clusterKeySlot: typeof CLUSTER_KEYSLOT;
CLUSTER_LINKS: typeof CLUSTER_LINKS;
clusterLinks: typeof CLUSTER_LINKS;
CLUSTER_MEET: typeof CLUSTER_MEET;
clusterMeet: typeof CLUSTER_MEET;
CLUSTER_MYID: typeof CLUSTER_MYID;
clusterMyId: typeof CLUSTER_MYID;
CLUSTER_MYSHARDID: typeof CLUSTER_MYSHARDID;
clusterMyShardId: typeof CLUSTER_MYSHARDID;
CLUSTER_NODES: typeof CLUSTER_NODES;
clusterNodes: typeof CLUSTER_NODES;
CLUSTER_REPLICAS: typeof CLUSTER_REPLICAS;
clusterReplicas: typeof CLUSTER_REPLICAS;
CLUSTER_REPLICATE: typeof CLUSTER_REPLICATE;
clusterReplicate: typeof CLUSTER_REPLICATE;
CLUSTER_RESET: typeof CLUSTER_RESET;
clusterReset: typeof CLUSTER_RESET;
CLUSTER_SAVECONFIG: typeof CLUSTER_SAVECONFIG;
clusterSaveConfig: typeof CLUSTER_SAVECONFIG;
CLUSTER_SET_CONFIG_EPOCH: typeof CLUSTER_SET_CONFIG_EPOCH;
clusterSetConfigEpoch: typeof CLUSTER_SET_CONFIG_EPOCH;
CLUSTER_SETSLOT: typeof CLUSTER_SETSLOT;
clusterSetSlot: typeof CLUSTER_SETSLOT;
CLUSTER_SLOTS: typeof CLUSTER_SLOTS;
clusterSlots: typeof CLUSTER_SLOTS;
COMMAND_COUNT: typeof COMMAND_COUNT;
commandCount: typeof COMMAND_COUNT;
COMMAND_GETKEYS: typeof COMMAND_GETKEYS;
commandGetKeys: typeof COMMAND_GETKEYS;
COMMAND_GETKEYSANDFLAGS: typeof COMMAND_GETKEYSANDFLAGS;
commandGetKeysAndFlags: typeof COMMAND_GETKEYSANDFLAGS;
COMMAND_INFO: typeof COMMAND_INFO;
commandInfo: typeof COMMAND_INFO;
COMMAND_LIST: typeof COMMAND_LIST;
commandList: typeof COMMAND_LIST;
COMMAND: typeof COMMAND;
command: typeof COMMAND;
CONFIG_GET: typeof CONFIG_GET;
configGet: typeof CONFIG_GET;
CONFIG_RESETASTAT: typeof CONFIG_RESETASTAT;
configResetStat: typeof CONFIG_RESETASTAT;
CONFIG_REWRITE: typeof CONFIG_REWRITE;
configRewrite: typeof CONFIG_REWRITE;
CONFIG_SET: typeof CONFIG_SET;
configSet: typeof CONFIG_SET;
DBSIZE: typeof DBSIZE;
dbSize: typeof DBSIZE;
DISCARD: typeof DISCARD;
discard: typeof DISCARD;
ECHO: typeof ECHO;
echo: typeof ECHO;
FAILOVER: typeof FAILOVER;
failover: typeof FAILOVER;
FLUSHALL: typeof FLUSHALL;
flushAll: typeof FLUSHALL;
FLUSHDB: typeof FLUSHDB;
flushDb: typeof FLUSHDB;
FUNCTION_DELETE: typeof FUNCTION_DELETE;
functionDelete: typeof FUNCTION_DELETE;
FUNCTION_DUMP: typeof FUNCTION_DUMP;
functionDump: typeof FUNCTION_DUMP;
FUNCTION_FLUSH: typeof FUNCTION_FLUSH;
functionFlush: typeof FUNCTION_FLUSH;
FUNCTION_KILL: typeof FUNCTION_KILL;
functionKill: typeof FUNCTION_KILL;
FUNCTION_LIST_WITHCODE: typeof FUNCTION_LIST_WITHCODE;
functionListWithCode: typeof FUNCTION_LIST_WITHCODE;
FUNCTION_LIST: typeof FUNCTION_LIST;
functionList: typeof FUNCTION_LIST;
FUNCTION_LOAD: typeof FUNCTION_LOAD;
functionLoad: typeof FUNCTION_LOAD;
FUNCTION_RESTORE: typeof FUNCTION_RESTORE;
functionRestore: typeof FUNCTION_RESTORE;
FUNCTION_STATS: typeof FUNCTION_STATS;
functionStats: typeof FUNCTION_STATS;
HELLO: typeof HELLO;
hello: typeof HELLO;
INFO: typeof INFO;
info: typeof INFO;
KEYS: typeof KEYS;
keys: typeof KEYS;
LASTSAVE: typeof LASTSAVE;
lastSave: typeof LASTSAVE;
LATENCY_DOCTOR: typeof LATENCY_DOCTOR;
latencyDoctor: typeof LATENCY_DOCTOR;
LATENCY_GRAPH: typeof LATENCY_GRAPH;
latencyGraph: typeof LATENCY_GRAPH;
LATENCY_HISTORY: typeof LATENCY_HISTORY;
latencyHistory: typeof LATENCY_HISTORY;
LATENCY_LATEST: typeof LATENCY_LATEST;
latencyLatest: typeof LATENCY_LATEST;
LOLWUT: typeof LOLWUT;
lolwut: typeof LOLWUT;
MEMORY_DOCTOR: typeof MEMORY_DOCTOR;
memoryDoctor: typeof MEMORY_DOCTOR;
'MEMORY_MALLOC-STATS': typeof MEMORY_MALLOC_STATS;
memoryMallocStats: typeof MEMORY_MALLOC_STATS;
MEMORY_PURGE: typeof MEMORY_PURGE;
memoryPurge: typeof MEMORY_PURGE;
MEMORY_STATS: typeof MEMORY_STATS;
memoryStats: typeof MEMORY_STATS;
MEMORY_USAGE: typeof MEMORY_USAGE;
memoryUsage: typeof MEMORY_USAGE;
MODULE_LIST: typeof MODULE_LIST;
moduleList: typeof MODULE_LIST;
MODULE_LOAD: typeof MODULE_LOAD;
moduleLoad: typeof MODULE_LOAD;
MODULE_UNLOAD: typeof MODULE_UNLOAD;
moduleUnload: typeof MODULE_UNLOAD;
MOVE: typeof MOVE;
move: typeof MOVE;
PING: typeof PING;
ping: typeof PING;
PUBSUB_CHANNELS: typeof PUBSUB_CHANNELS;
pubSubChannels: typeof PUBSUB_CHANNELS;
PUBSUB_NUMPAT: typeof PUBSUB_NUMPAT;
pubSubNumPat: typeof PUBSUB_NUMPAT;
PUBSUB_NUMSUB: typeof PUBSUB_NUMSUB;
pubSubNumSub: typeof PUBSUB_NUMSUB;
PUBSUB_SHARDCHANNELS: typeof PUBSUB_SHARDCHANNELS;
pubSubShardChannels: typeof PUBSUB_SHARDCHANNELS;
PUBSUB_SHARDNUMSUB: typeof PUBSUB_SHARDNUMSUB;
pubSubShardNumSub: typeof PUBSUB_SHARDNUMSUB;
RANDOMKEY: typeof RANDOMKEY;
randomKey: typeof RANDOMKEY;
READONLY: typeof READONLY;
readonly: typeof READONLY;
READWRITE: typeof READWRITE;
readwrite: typeof READWRITE;
REPLICAOF: typeof REPLICAOF;
replicaOf: typeof REPLICAOF;
'RESTORE-ASKING': typeof RESTORE_ASKING;
restoreAsking: typeof RESTORE_ASKING;
ROLE: typeof ROLE;
role: typeof ROLE;
SAVE: typeof SAVE;
save: typeof SAVE;
SCAN: typeof SCAN;
scan: typeof SCAN;
SCRIPT_DEBUG: typeof SCRIPT_DEBUG;
scriptDebug: typeof SCRIPT_DEBUG;
SCRIPT_EXISTS: typeof SCRIPT_EXISTS;
scriptExists: typeof SCRIPT_EXISTS;
SCRIPT_FLUSH: typeof SCRIPT_FLUSH;
scriptFlush: typeof SCRIPT_FLUSH;
SCRIPT_KILL: typeof SCRIPT_KILL;
scriptKill: typeof SCRIPT_KILL;
SCRIPT_LOAD: typeof SCRIPT_LOAD;
scriptLoad: typeof SCRIPT_LOAD;
SHUTDOWN: typeof SHUTDOWN;
shutdown: typeof SHUTDOWN;
SWAPDB: typeof SWAPDB;
swapDb: typeof SWAPDB;
TIME: typeof TIME;
time: typeof TIME;
UNWATCH: typeof UNWATCH;
unwatch: typeof UNWATCH;
WAIT: typeof WAIT;
wait: typeof WAIT;
APPEND: typeof import("../commands/APPEND");
append: typeof import("../commands/APPEND");
BITCOUNT: typeof import("../commands/BITCOUNT");
bitCount: typeof import("../commands/BITCOUNT");
BITFIELD_RO: typeof import("../commands/BITFIELD_RO");
bitFieldRo: typeof import("../commands/BITFIELD_RO");
BITFIELD: typeof import("../commands/BITFIELD");
bitField: typeof import("../commands/BITFIELD");
BITOP: typeof import("../commands/BITOP");
bitOp: typeof import("../commands/BITOP");
BITPOS: typeof import("../commands/BITPOS");
bitPos: typeof import("../commands/BITPOS");
BLMOVE: typeof import("../commands/BLMOVE");
blMove: typeof import("../commands/BLMOVE");
BLMPOP: typeof import("../commands/BLMPOP");
blmPop: typeof import("../commands/BLMPOP");
BLPOP: typeof import("../commands/BLPOP");
blPop: typeof import("../commands/BLPOP");
BRPOP: typeof import("../commands/BRPOP");
brPop: typeof import("../commands/BRPOP");
BRPOPLPUSH: typeof import("../commands/BRPOPLPUSH");
brPopLPush: typeof import("../commands/BRPOPLPUSH");
BZMPOP: typeof import("../commands/BZMPOP");
bzmPop: typeof import("../commands/BZMPOP");
BZPOPMAX: typeof import("../commands/BZPOPMAX");
bzPopMax: typeof import("../commands/BZPOPMAX");
BZPOPMIN: typeof import("../commands/BZPOPMIN");
bzPopMin: typeof import("../commands/BZPOPMIN");
COPY: typeof import("../commands/COPY");
copy: typeof import("../commands/COPY");
DECR: typeof import("../commands/DECR");
decr: typeof import("../commands/DECR");
DECRBY: typeof import("../commands/DECRBY");
decrBy: typeof import("../commands/DECRBY");
DEL: typeof import("../commands/DEL");
del: typeof import("../commands/DEL");
DUMP: typeof import("../commands/DUMP");
dump: typeof import("../commands/DUMP");
EVAL_RO: typeof import("../commands/EVAL_RO");
evalRo: typeof import("../commands/EVAL_RO");
EVAL: typeof import("../commands/EVAL");
eval: typeof import("../commands/EVAL");
EVALSHA: typeof import("../commands/EVALSHA");
evalSha: typeof import("../commands/EVALSHA");
EVALSHA_RO: typeof import("../commands/EVALSHA_RO");
evalShaRo: typeof import("../commands/EVALSHA_RO");
EXISTS: typeof import("../commands/EXISTS");
exists: typeof import("../commands/EXISTS");
EXPIRE: typeof import("../commands/EXPIRE");
expire: typeof import("../commands/EXPIRE");
EXPIREAT: typeof import("../commands/EXPIREAT");
expireAt: typeof import("../commands/EXPIREAT");
EXPIRETIME: typeof import("../commands/EXPIRETIME");
expireTime: typeof import("../commands/EXPIRETIME");
FCALL_RO: typeof import("../commands/FCALL_RO");
fCallRo: typeof import("../commands/FCALL_RO");
FCALL: typeof import("../commands/FCALL");
fCall: typeof import("../commands/FCALL");
GEOADD: typeof import("../commands/GEOADD");
geoAdd: typeof import("../commands/GEOADD");
GEODIST: typeof import("../commands/GEODIST");
geoDist: typeof import("../commands/GEODIST");
GEOHASH: typeof import("../commands/GEOHASH");
geoHash: typeof import("../commands/GEOHASH");
GEOPOS: typeof import("../commands/GEOPOS");
geoPos: typeof import("../commands/GEOPOS");
GEORADIUS_RO_WITH: typeof import("../commands/GEORADIUS_RO_WITH");
geoRadiusRoWith: typeof import("../commands/GEORADIUS_RO_WITH");
GEORADIUS_RO: typeof import("../commands/GEORADIUS_RO");
geoRadiusRo: typeof import("../commands/GEORADIUS_RO");
GEORADIUS_WITH: typeof import("../commands/GEORADIUS_WITH");
geoRadiusWith: typeof import("../commands/GEORADIUS_WITH");
GEORADIUS: typeof import("../commands/GEORADIUS");
geoRadius: typeof import("../commands/GEORADIUS");
GEORADIUSBYMEMBER_RO_WITH: typeof import("../commands/GEORADIUSBYMEMBER_RO_WITH");
geoRadiusByMemberRoWith: typeof import("../commands/GEORADIUSBYMEMBER_RO_WITH");
GEORADIUSBYMEMBER_RO: typeof import("../commands/GEORADIUSBYMEMBER_RO");
geoRadiusByMemberRo: typeof import("../commands/GEORADIUSBYMEMBER_RO");
GEORADIUSBYMEMBER_WITH: typeof import("../commands/GEORADIUSBYMEMBER_WITH");
geoRadiusByMemberWith: typeof import("../commands/GEORADIUSBYMEMBER_WITH");
GEORADIUSBYMEMBER: typeof import("../commands/GEORADIUSBYMEMBER");
geoRadiusByMember: typeof import("../commands/GEORADIUSBYMEMBER");
GEORADIUSBYMEMBERSTORE: typeof import("../commands/GEORADIUSBYMEMBERSTORE");
geoRadiusByMemberStore: typeof import("../commands/GEORADIUSBYMEMBERSTORE");
GEORADIUSSTORE: typeof import("../commands/GEORADIUSSTORE");
geoRadiusStore: typeof import("../commands/GEORADIUSSTORE");
GEOSEARCH_WITH: typeof import("../commands/GEOSEARCH_WITH");
geoSearchWith: typeof import("../commands/GEOSEARCH_WITH");
GEOSEARCH: typeof import("../commands/GEOSEARCH");
geoSearch: typeof import("../commands/GEOSEARCH");
GEOSEARCHSTORE: typeof import("../commands/GEOSEARCHSTORE");
geoSearchStore: typeof import("../commands/GEOSEARCHSTORE");
GET: typeof import("../commands/GET");
get: typeof import("../commands/GET");
GETBIT: typeof import("../commands/GETBIT");
getBit: typeof import("../commands/GETBIT");
GETDEL: typeof import("../commands/GETDEL");
getDel: typeof import("../commands/GETDEL");
GETEX: typeof import("../commands/GETEX");
getEx: typeof import("../commands/GETEX");
GETRANGE: typeof import("../commands/GETRANGE");
getRange: typeof import("../commands/GETRANGE");
GETSET: typeof import("../commands/GETSET");
getSet: typeof import("../commands/GETSET");
HDEL: typeof import("../commands/HDEL");
hDel: typeof import("../commands/HDEL");
HEXISTS: typeof import("../commands/HEXISTS");
hExists: typeof import("../commands/HEXISTS");
HEXPIRE: typeof import("../commands/HEXPIRE");
hExpire: typeof import("../commands/HEXPIRE");
HEXPIREAT: typeof import("../commands/HEXPIREAT");
hExpireAt: typeof import("../commands/HEXPIREAT");
HEXPIRETIME: typeof import("../commands/HEXPIRETIME");
hExpireTime: typeof import("../commands/HEXPIRETIME");
HGET: typeof import("../commands/HGET");
hGet: typeof import("../commands/HGET");
HGETALL: typeof import("../commands/HGETALL");
hGetAll: typeof import("../commands/HGETALL");
HINCRBY: typeof import("../commands/HINCRBY");
hIncrBy: typeof import("../commands/HINCRBY");
HINCRBYFLOAT: typeof import("../commands/HINCRBYFLOAT");
hIncrByFloat: typeof import("../commands/HINCRBYFLOAT");
HKEYS: typeof import("../commands/HKEYS");
hKeys: typeof import("../commands/HKEYS");
HLEN: typeof import("../commands/HLEN");
hLen: typeof import("../commands/HLEN");
HMGET: typeof import("../commands/HMGET");
hmGet: typeof import("../commands/HMGET");
HPERSIST: typeof import("../commands/HPERSIST");
hPersist: typeof import("../commands/HPERSIST");
HPEXPIRE: typeof import("../commands/HPEXPIRE");
hpExpire: typeof import("../commands/HPEXPIRE");
HPEXPIREAT: typeof import("../commands/HPEXPIREAT");
hpExpireAt: typeof import("../commands/HPEXPIREAT");
HPEXPIRETIME: typeof import("../commands/HPEXPIRETIME");
hpExpireTime: typeof import("../commands/HPEXPIRETIME");
HPTTL: typeof import("../commands/HPTTL");
hpTTL: typeof import("../commands/HPTTL");
HRANDFIELD_COUNT_WITHVALUES: typeof import("../commands/HRANDFIELD_COUNT_WITHVALUES");
hRandFieldCountWithValues: typeof import("../commands/HRANDFIELD_COUNT_WITHVALUES");
HRANDFIELD_COUNT: typeof import("../commands/HRANDFIELD_COUNT");
hRandFieldCount: typeof import("../commands/HRANDFIELD_COUNT");
HRANDFIELD: typeof import("../commands/HRANDFIELD");
hRandField: typeof import("../commands/HRANDFIELD");
HSCAN: typeof import("../commands/HSCAN");
hScan: typeof import("../commands/HSCAN");
HSCAN_NOVALUES: typeof import("../commands/HSCAN_NOVALUES");
hScanNoValues: typeof import("../commands/HSCAN_NOVALUES");
HSET: typeof import("../commands/HSET");
hSet: typeof import("../commands/HSET");
HSETNX: typeof import("../commands/HSETNX");
hSetNX: typeof import("../commands/HSETNX");
HSTRLEN: typeof import("../commands/HSTRLEN");
hStrLen: typeof import("../commands/HSTRLEN");
HTTL: typeof import("../commands/HTTL");
hTTL: typeof import("../commands/HTTL");
HVALS: typeof import("../commands/HVALS");
hVals: typeof import("../commands/HVALS");
INCR: typeof import("../commands/INCR");
incr: typeof import("../commands/INCR");
INCRBY: typeof import("../commands/INCRBY");
incrBy: typeof import("../commands/INCRBY");
INCRBYFLOAT: typeof import("../commands/INCRBYFLOAT");
incrByFloat: typeof import("../commands/INCRBYFLOAT");
LCS_IDX_WITHMATCHLEN: typeof import("../commands/LCS_IDX_WITHMATCHLEN");
lcsIdxWithMatchLen: typeof import("../commands/LCS_IDX_WITHMATCHLEN");
LCS_IDX: typeof import("../commands/LCS_IDX");
lcsIdx: typeof import("../commands/LCS_IDX");
LCS_LEN: typeof import("../commands/LCS_LEN");
lcsLen: typeof import("../commands/LCS_LEN");
LCS: typeof import("../commands/LCS");
lcs: typeof import("../commands/LCS");
LINDEX: typeof import("../commands/LINDEX");
lIndex: typeof import("../commands/LINDEX");
LINSERT: typeof import("../commands/LINSERT");
lInsert: typeof import("../commands/LINSERT");
LLEN: typeof import("../commands/LLEN");
lLen: typeof import("../commands/LLEN");
LMOVE: typeof import("../commands/LMOVE");
lMove: typeof import("../commands/LMOVE");
LMPOP: typeof import("../commands/LMPOP");
lmPop: typeof import("../commands/LMPOP");
LPOP_COUNT: typeof import("../commands/LPOP_COUNT");
lPopCount: typeof import("../commands/LPOP_COUNT");
LPOP: typeof import("../commands/LPOP");
lPop: typeof import("../commands/LPOP");
LPOS_COUNT: typeof import("../commands/LPOS_COUNT");
lPosCount: typeof import("../commands/LPOS_COUNT");
LPOS: typeof import("../commands/LPOS");
lPos: typeof import("../commands/LPOS");
LPUSH: typeof import("../commands/LPUSH");
lPush: typeof import("../commands/LPUSH");
LPUSHX: typeof import("../commands/LPUSHX");
lPushX: typeof import("../commands/LPUSHX");
LRANGE: typeof import("../commands/LRANGE");
lRange: typeof import("../commands/LRANGE");
LREM: typeof import("../commands/LREM");
lRem: typeof import("../commands/LREM");
LSET: typeof import("../commands/LSET");
lSet: typeof import("../commands/LSET");
LTRIM: typeof import("../commands/LTRIM");
lTrim: typeof import("../commands/LTRIM");
MGET: typeof import("../commands/MGET");
mGet: typeof import("../commands/MGET");
MIGRATE: typeof import("../commands/MIGRATE");
migrate: typeof import("../commands/MIGRATE");
MSET: typeof import("../commands/MSET");
mSet: typeof import("../commands/MSET");
MSETNX: typeof import("../commands/MSETNX");
mSetNX: typeof import("../commands/MSETNX");
OBJECT_ENCODING: typeof import("../commands/OBJECT_ENCODING");
objectEncoding: typeof import("../commands/OBJECT_ENCODING");
OBJECT_FREQ: typeof import("../commands/OBJECT_FREQ");
objectFreq: typeof import("../commands/OBJECT_FREQ");
OBJECT_IDLETIME: typeof import("../commands/OBJECT_IDLETIME");
objectIdleTime: typeof import("../commands/OBJECT_IDLETIME");
OBJECT_REFCOUNT: typeof import("../commands/OBJECT_REFCOUNT");
objectRefCount: typeof import("../commands/OBJECT_REFCOUNT");
PERSIST: typeof import("../commands/PERSIST");
persist: typeof import("../commands/PERSIST");
PEXPIRE: typeof import("../commands/PEXPIRE");
pExpire: typeof import("../commands/PEXPIRE");
PEXPIREAT: typeof import("../commands/PEXPIREAT");
pExpireAt: typeof import("../commands/PEXPIREAT");
PEXPIRETIME: typeof import("../commands/PEXPIRETIME");
pExpireTime: typeof import("../commands/PEXPIRETIME");
PFADD: typeof import("../commands/PFADD");
pfAdd: typeof import("../commands/PFADD");
PFCOUNT: typeof import("../commands/PFCOUNT");
pfCount: typeof import("../commands/PFCOUNT");
PFMERGE: typeof import("../commands/PFMERGE");
pfMerge: typeof import("../commands/PFMERGE");
PSETEX: typeof import("../commands/PSETEX");
pSetEx: typeof import("../commands/PSETEX");
PTTL: typeof import("../commands/PTTL");
pTTL: typeof import("../commands/PTTL");
PUBLISH: typeof import("../commands/PUBLISH");
publish: typeof import("../commands/PUBLISH");
RENAME: typeof import("../commands/RENAME");
rename: typeof import("../commands/RENAME");
RENAMENX: typeof import("../commands/RENAMENX");
renameNX: typeof import("../commands/RENAMENX");
RESTORE: typeof import("../commands/RESTORE");
restore: typeof import("../commands/RESTORE");
RPOP_COUNT: typeof import("../commands/RPOP_COUNT");
rPopCount: typeof import("../commands/RPOP_COUNT");
RPOP: typeof import("../commands/RPOP");
rPop: typeof import("../commands/RPOP");
RPOPLPUSH: typeof import("../commands/RPOPLPUSH");
rPopLPush: typeof import("../commands/RPOPLPUSH");
RPUSH: typeof import("../commands/RPUSH");
rPush: typeof import("../commands/RPUSH");
RPUSHX: typeof import("../commands/RPUSHX");
rPushX: typeof import("../commands/RPUSHX");
SADD: typeof import("../commands/SADD");
sAdd: typeof import("../commands/SADD");
SCARD: typeof import("../commands/SCARD");
sCard: typeof import("../commands/SCARD");
SDIFF: typeof import("../commands/SDIFF");
sDiff: typeof import("../commands/SDIFF");
SDIFFSTORE: typeof import("../commands/SDIFFSTORE");
sDiffStore: typeof import("../commands/SDIFFSTORE");
SINTER: typeof import("../commands/SINTER");
sInter: typeof import("../commands/SINTER");
SINTERCARD: typeof import("../commands/SINTERCARD");
sInterCard: typeof import("../commands/SINTERCARD");
SINTERSTORE: typeof import("../commands/SINTERSTORE");
sInterStore: typeof import("../commands/SINTERSTORE");
SET: typeof import("../commands/SET");
set: typeof import("../commands/SET");
SETBIT: typeof import("../commands/SETBIT");
setBit: typeof import("../commands/SETBIT");
SETEX: typeof import("../commands/SETEX");
setEx: typeof import("../commands/SETEX");
SETNX: typeof import("../commands/SETNX");
setNX: typeof import("../commands/SETNX");
SETRANGE: typeof import("../commands/SETRANGE");
setRange: typeof import("../commands/SETRANGE");
SISMEMBER: typeof import("../commands/SISMEMBER");
sIsMember: typeof import("../commands/SISMEMBER");
SMEMBERS: typeof import("../commands/SMEMBERS");
sMembers: typeof import("../commands/SMEMBERS");
SMISMEMBER: typeof import("../commands/SMISMEMBER");
smIsMember: typeof import("../commands/SMISMEMBER");
SMOVE: typeof import("../commands/SMOVE");
sMove: typeof import("../commands/SMOVE");
SORT_RO: typeof import("../commands/SORT_RO");
sortRo: typeof import("../commands/SORT_RO");
SORT_STORE: typeof import("../commands/SORT_STORE");
sortStore: typeof import("../commands/SORT_STORE");
SORT: typeof import("../commands/SORT");
sort: typeof import("../commands/SORT");
SPOP: typeof import("../commands/SPOP");
sPop: typeof import("../commands/SPOP");
SPUBLISH: typeof import("../commands/SPUBLISH");
sPublish: typeof import("../commands/SPUBLISH");
SRANDMEMBER_COUNT: typeof import("../commands/SRANDMEMBER_COUNT");
sRandMemberCount: typeof import("../commands/SRANDMEMBER_COUNT");
SRANDMEMBER: typeof import("../commands/SRANDMEMBER");
sRandMember: typeof import("../commands/SRANDMEMBER");
SREM: typeof import("../commands/SREM");
sRem: typeof import("../commands/SREM");
SSCAN: typeof import("../commands/SSCAN");
sScan: typeof import("../commands/SSCAN");
STRLEN: typeof import("../commands/STRLEN");
strLen: typeof import("../commands/STRLEN");
SUNION: typeof import("../commands/SUNION");
sUnion: typeof import("../commands/SUNION");
SUNIONSTORE: typeof import("../commands/SUNIONSTORE");
sUnionStore: typeof import("../commands/SUNIONSTORE");
TOUCH: typeof import("../commands/TOUCH");
touch: typeof import("../commands/TOUCH");
TTL: typeof import("../commands/TTL");
ttl: typeof import("../commands/TTL");
TYPE: typeof import("../commands/TYPE");
type: typeof import("../commands/TYPE");
UNLINK: typeof import("../commands/UNLINK");
unlink: typeof import("../commands/UNLINK");
WATCH: typeof import("../commands/WATCH");
watch: typeof import("../commands/WATCH");
XACK: typeof import("../commands/XACK");
xAck: typeof import("../commands/XACK");
XADD: typeof import("../commands/XADD");
xAdd: typeof import("../commands/XADD");
XAUTOCLAIM_JUSTID: typeof import("../commands/XAUTOCLAIM_JUSTID");
xAutoClaimJustId: typeof import("../commands/XAUTOCLAIM_JUSTID");
XAUTOCLAIM: typeof import("../commands/XAUTOCLAIM");
xAutoClaim: typeof import("../commands/XAUTOCLAIM");
XCLAIM: typeof import("../commands/XCLAIM");
xClaim: typeof import("../commands/XCLAIM");
XCLAIM_JUSTID: typeof import("../commands/XCLAIM_JUSTID");
xClaimJustId: typeof import("../commands/XCLAIM_JUSTID");
XDEL: typeof import("../commands/XDEL");
xDel: typeof import("../commands/XDEL");
XGROUP_CREATE: typeof import("../commands/XGROUP_CREATE");
xGroupCreate: typeof import("../commands/XGROUP_CREATE");
XGROUP_CREATECONSUMER: typeof import("../commands/XGROUP_CREATECONSUMER");
xGroupCreateConsumer: typeof import("../commands/XGROUP_CREATECONSUMER");
XGROUP_DELCONSUMER: typeof import("../commands/XGROUP_DELCONSUMER");
xGroupDelConsumer: typeof import("../commands/XGROUP_DELCONSUMER");
XGROUP_DESTROY: typeof import("../commands/XGROUP_DESTROY");
xGroupDestroy: typeof import("../commands/XGROUP_DESTROY");
XGROUP_SETID: typeof import("../commands/XGROUP_SETID");
xGroupSetId: typeof import("../commands/XGROUP_SETID");
XINFO_CONSUMERS: typeof import("../commands/XINFO_CONSUMERS");
xInfoConsumers: typeof import("../commands/XINFO_CONSUMERS");
XINFO_GROUPS: typeof import("../commands/XINFO_GROUPS");
xInfoGroups: typeof import("../commands/XINFO_GROUPS");
XINFO_STREAM: typeof import("../commands/XINFO_STREAM");
xInfoStream: typeof import("../commands/XINFO_STREAM");
XLEN: typeof import("../commands/XLEN");
xLen: typeof import("../commands/XLEN");
XPENDING_RANGE: typeof import("../commands/XPENDING_RANGE");
xPendingRange: typeof import("../commands/XPENDING_RANGE");
XPENDING: typeof import("../commands/XPENDING");
xPending: typeof import("../commands/XPENDING");
XRANGE: typeof import("../commands/XRANGE");
xRange: typeof import("../commands/XRANGE");
XREAD: typeof import("../commands/XREAD");
xRead: typeof import("../commands/XREAD");
XREADGROUP: typeof import("../commands/XREADGROUP");
xReadGroup: typeof import("../commands/XREADGROUP");
XREVRANGE: typeof import("../commands/XREVRANGE");
xRevRange: typeof import("../commands/XREVRANGE");
XSETID: typeof import("../commands/XSETID");
xSetId: typeof import("../commands/XSETID");
XTRIM: typeof import("../commands/XTRIM");
xTrim: typeof import("../commands/XTRIM");
ZADD: typeof import("../commands/ZADD");
zAdd: typeof import("../commands/ZADD");
ZCARD: typeof import("../commands/ZCARD");
zCard: typeof import("../commands/ZCARD");
ZCOUNT: typeof import("../commands/ZCOUNT");
zCount: typeof import("../commands/ZCOUNT");
ZDIFF_WITHSCORES: typeof import("../commands/ZDIFF_WITHSCORES");
zDiffWithScores: typeof import("../commands/ZDIFF_WITHSCORES");
ZDIFF: typeof import("../commands/ZDIFF");
zDiff: typeof import("../commands/ZDIFF");
ZDIFFSTORE: typeof import("../commands/ZDIFFSTORE");
zDiffStore: typeof import("../commands/ZDIFFSTORE");
ZINCRBY: typeof import("../commands/ZINCRBY");
zIncrBy: typeof import("../commands/ZINCRBY");
ZINTER_WITHSCORES: typeof import("../commands/ZINTER_WITHSCORES");
zInterWithScores: typeof import("../commands/ZINTER_WITHSCORES");
ZINTER: typeof import("../commands/ZINTER");
zInter: typeof import("../commands/ZINTER");
ZINTERCARD: typeof import("../commands/ZINTERCARD");
zInterCard: typeof import("../commands/ZINTERCARD");
ZINTERSTORE: typeof import("../commands/ZINTERSTORE");
zInterStore: typeof import("../commands/ZINTERSTORE");
ZLEXCOUNT: typeof import("../commands/ZLEXCOUNT");
zLexCount: typeof import("../commands/ZLEXCOUNT");
ZMPOP: typeof import("../commands/ZMPOP");
zmPop: typeof import("../commands/ZMPOP");
ZMSCORE: typeof import("../commands/ZMSCORE");
zmScore: typeof import("../commands/ZMSCORE");
ZPOPMAX_COUNT: typeof import("../commands/ZPOPMAX_COUNT");
zPopMaxCount: typeof import("../commands/ZPOPMAX_COUNT");
ZPOPMAX: typeof import("../commands/ZPOPMAX");
zPopMax: typeof import("../commands/ZPOPMAX");
ZPOPMIN_COUNT: typeof import("../commands/ZPOPMIN_COUNT");
zPopMinCount: typeof import("../commands/ZPOPMIN_COUNT");
ZPOPMIN: typeof import("../commands/ZPOPMIN");
zPopMin: typeof import("../commands/ZPOPMIN");
ZRANDMEMBER_COUNT_WITHSCORES: typeof import("../commands/ZRANDMEMBER_COUNT_WITHSCORES");
zRandMemberCountWithScores: typeof import("../commands/ZRANDMEMBER_COUNT_WITHSCORES");
ZRANDMEMBER_COUNT: typeof import("../commands/ZRANDMEMBER_COUNT");
zRandMemberCount: typeof import("../commands/ZRANDMEMBER_COUNT");
ZRANDMEMBER: typeof import("../commands/ZRANDMEMBER");
zRandMember: typeof import("../commands/ZRANDMEMBER");
ZRANGE_WITHSCORES: typeof import("../commands/ZRANGE_WITHSCORES");
zRangeWithScores: typeof import("../commands/ZRANGE_WITHSCORES");
ZRANGE: typeof import("../commands/ZRANGE");
zRange: typeof import("../commands/ZRANGE");
ZRANGEBYLEX: typeof import("../commands/ZRANGEBYLEX");
zRangeByLex: typeof import("../commands/ZRANGEBYLEX");
ZRANGEBYSCORE_WITHSCORES: typeof import("../commands/ZRANGEBYSCORE_WITHSCORES");
zRangeByScoreWithScores: typeof import("../commands/ZRANGEBYSCORE_WITHSCORES");
ZRANGEBYSCORE: typeof import("../commands/ZRANGEBYSCORE");
zRangeByScore: typeof import("../commands/ZRANGEBYSCORE");
ZRANGESTORE: typeof import("../commands/ZRANGESTORE");
zRangeStore: typeof import("../commands/ZRANGESTORE");
ZRANK: typeof import("../commands/ZRANK");
zRank: typeof import("../commands/ZRANK");
ZREM: typeof import("../commands/ZREM");
zRem: typeof import("../commands/ZREM");
ZREMRANGEBYLEX: typeof import("../commands/ZREMRANGEBYLEX");
zRemRangeByLex: typeof import("../commands/ZREMRANGEBYLEX");
ZREMRANGEBYRANK: typeof import("../commands/ZREMRANGEBYRANK");
zRemRangeByRank: typeof import("../commands/ZREMRANGEBYRANK");
ZREMRANGEBYSCORE: typeof import("../commands/ZREMRANGEBYSCORE");
zRemRangeByScore: typeof import("../commands/ZREMRANGEBYSCORE");
ZREVRANK: typeof import("../commands/ZREVRANK");
zRevRank: typeof import("../commands/ZREVRANK");
ZSCAN: typeof import("../commands/ZSCAN");
zScan: typeof import("../commands/ZSCAN");
ZSCORE: typeof import("../commands/ZSCORE");
zScore: typeof import("../commands/ZSCORE");
ZUNION_WITHSCORES: typeof import("../commands/ZUNION_WITHSCORES");
zUnionWithScores: typeof import("../commands/ZUNION_WITHSCORES");
ZUNION: typeof import("../commands/ZUNION");
zUnion: typeof import("../commands/ZUNION");
ZUNIONSTORE: typeof import("../commands/ZUNIONSTORE");
zUnionStore: typeof import("../commands/ZUNIONSTORE");
};
export default _default;

View File

@@ -0,0 +1,375 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const commands_1 = require("../cluster/commands");
const ACL_CAT = require("../commands/ACL_CAT");
const ACL_DELUSER = require("../commands/ACL_DELUSER");
const ACL_DRYRUN = require("../commands/ACL_DRYRUN");
const ACL_GENPASS = require("../commands/ACL_GENPASS");
const ACL_GETUSER = require("../commands/ACL_GETUSER");
const ACL_LIST = require("../commands/ACL_LIST");
const ACL_LOAD = require("../commands/ACL_LOAD");
const ACL_LOG_RESET = require("../commands/ACL_LOG_RESET");
const ACL_LOG = require("../commands/ACL_LOG");
const ACL_SAVE = require("../commands/ACL_SAVE");
const ACL_SETUSER = require("../commands/ACL_SETUSER");
const ACL_USERS = require("../commands/ACL_USERS");
const ACL_WHOAMI = require("../commands/ACL_WHOAMI");
const ASKING = require("../commands/ASKING");
const AUTH = require("../commands/AUTH");
const BGREWRITEAOF = require("../commands/BGREWRITEAOF");
const BGSAVE = require("../commands/BGSAVE");
const CLIENT_CACHING = require("../commands/CLIENT_CACHING");
const CLIENT_GETNAME = require("../commands/CLIENT_GETNAME");
const CLIENT_GETREDIR = require("../commands/CLIENT_GETREDIR");
const CLIENT_ID = require("../commands/CLIENT_ID");
const CLIENT_KILL = require("../commands/CLIENT_KILL");
const CLIENT_LIST = require("../commands/CLIENT_LIST");
const CLIENT_NO_EVICT = require("../commands/CLIENT_NO-EVICT");
const CLIENT_NO_TOUCH = require("../commands/CLIENT_NO-TOUCH");
const CLIENT_PAUSE = require("../commands/CLIENT_PAUSE");
const CLIENT_SETNAME = require("../commands/CLIENT_SETNAME");
const CLIENT_TRACKING = require("../commands/CLIENT_TRACKING");
const CLIENT_TRACKINGINFO = require("../commands/CLIENT_TRACKINGINFO");
const CLIENT_UNPAUSE = require("../commands/CLIENT_UNPAUSE");
const CLIENT_INFO = require("../commands/CLIENT_INFO");
const CLUSTER_ADDSLOTS = require("../commands/CLUSTER_ADDSLOTS");
const CLUSTER_ADDSLOTSRANGE = require("../commands/CLUSTER_ADDSLOTSRANGE");
const CLUSTER_BUMPEPOCH = require("../commands/CLUSTER_BUMPEPOCH");
const CLUSTER_COUNT_FAILURE_REPORTS = require("../commands/CLUSTER_COUNT-FAILURE-REPORTS");
const CLUSTER_COUNTKEYSINSLOT = require("../commands/CLUSTER_COUNTKEYSINSLOT");
const CLUSTER_DELSLOTS = require("../commands/CLUSTER_DELSLOTS");
const CLUSTER_DELSLOTSRANGE = require("../commands/CLUSTER_DELSLOTSRANGE");
const CLUSTER_FAILOVER = require("../commands/CLUSTER_FAILOVER");
const CLUSTER_FLUSHSLOTS = require("../commands/CLUSTER_FLUSHSLOTS");
const CLUSTER_FORGET = require("../commands/CLUSTER_FORGET");
const CLUSTER_GETKEYSINSLOT = require("../commands/CLUSTER_GETKEYSINSLOT");
const CLUSTER_INFO = require("../commands/CLUSTER_INFO");
const CLUSTER_KEYSLOT = require("../commands/CLUSTER_KEYSLOT");
const CLUSTER_LINKS = require("../commands/CLUSTER_LINKS");
const CLUSTER_MEET = require("../commands/CLUSTER_MEET");
const CLUSTER_MYID = require("../commands/CLUSTER_MYID");
const CLUSTER_MYSHARDID = require("../commands/CLUSTER_MYSHARDID");
const CLUSTER_NODES = require("../commands/CLUSTER_NODES");
const CLUSTER_REPLICAS = require("../commands/CLUSTER_REPLICAS");
const CLUSTER_REPLICATE = require("../commands/CLUSTER_REPLICATE");
const CLUSTER_RESET = require("../commands/CLUSTER_RESET");
const CLUSTER_SAVECONFIG = require("../commands/CLUSTER_SAVECONFIG");
const CLUSTER_SET_CONFIG_EPOCH = require("../commands/CLUSTER_SET-CONFIG-EPOCH");
const CLUSTER_SETSLOT = require("../commands/CLUSTER_SETSLOT");
const CLUSTER_SLOTS = require("../commands/CLUSTER_SLOTS");
const COMMAND_COUNT = require("../commands/COMMAND_COUNT");
const COMMAND_GETKEYS = require("../commands/COMMAND_GETKEYS");
const COMMAND_GETKEYSANDFLAGS = require("../commands/COMMAND_GETKEYSANDFLAGS");
const COMMAND_INFO = require("../commands/COMMAND_INFO");
const COMMAND_LIST = require("../commands/COMMAND_LIST");
const COMMAND = require("../commands/COMMAND");
const CONFIG_GET = require("../commands/CONFIG_GET");
const CONFIG_RESETASTAT = require("../commands/CONFIG_RESETSTAT");
const CONFIG_REWRITE = require("../commands/CONFIG_REWRITE");
const CONFIG_SET = require("../commands/CONFIG_SET");
const DBSIZE = require("../commands/DBSIZE");
const DISCARD = require("../commands/DISCARD");
const ECHO = require("../commands/ECHO");
const FAILOVER = require("../commands/FAILOVER");
const FLUSHALL = require("../commands/FLUSHALL");
const FLUSHDB = require("../commands/FLUSHDB");
const FUNCTION_DELETE = require("../commands/FUNCTION_DELETE");
const FUNCTION_DUMP = require("../commands/FUNCTION_DUMP");
const FUNCTION_FLUSH = require("../commands/FUNCTION_FLUSH");
const FUNCTION_KILL = require("../commands/FUNCTION_KILL");
const FUNCTION_LIST_WITHCODE = require("../commands/FUNCTION_LIST_WITHCODE");
const FUNCTION_LIST = require("../commands/FUNCTION_LIST");
const FUNCTION_LOAD = require("../commands/FUNCTION_LOAD");
const FUNCTION_RESTORE = require("../commands/FUNCTION_RESTORE");
const FUNCTION_STATS = require("../commands/FUNCTION_STATS");
const HELLO = require("../commands/HELLO");
const INFO = require("../commands/INFO");
const KEYS = require("../commands/KEYS");
const LASTSAVE = require("../commands/LASTSAVE");
const LATENCY_DOCTOR = require("../commands/LATENCY_DOCTOR");
const LATENCY_GRAPH = require("../commands/LATENCY_GRAPH");
const LATENCY_HISTORY = require("../commands/LATENCY_HISTORY");
const LATENCY_LATEST = require("../commands/LATENCY_LATEST");
const LOLWUT = require("../commands/LOLWUT");
const MEMORY_DOCTOR = require("../commands/MEMORY_DOCTOR");
const MEMORY_MALLOC_STATS = require("../commands/MEMORY_MALLOC-STATS");
const MEMORY_PURGE = require("../commands/MEMORY_PURGE");
const MEMORY_STATS = require("../commands/MEMORY_STATS");
const MEMORY_USAGE = require("../commands/MEMORY_USAGE");
const MODULE_LIST = require("../commands/MODULE_LIST");
const MODULE_LOAD = require("../commands/MODULE_LOAD");
const MODULE_UNLOAD = require("../commands/MODULE_UNLOAD");
const MOVE = require("../commands/MOVE");
const PING = require("../commands/PING");
const PUBSUB_CHANNELS = require("../commands/PUBSUB_CHANNELS");
const PUBSUB_NUMPAT = require("../commands/PUBSUB_NUMPAT");
const PUBSUB_NUMSUB = require("../commands/PUBSUB_NUMSUB");
const PUBSUB_SHARDCHANNELS = require("../commands/PUBSUB_SHARDCHANNELS");
const PUBSUB_SHARDNUMSUB = require("../commands/PUBSUB_SHARDNUMSUB");
const RANDOMKEY = require("../commands/RANDOMKEY");
const READONLY = require("../commands/READONLY");
const READWRITE = require("../commands/READWRITE");
const REPLICAOF = require("../commands/REPLICAOF");
const RESTORE_ASKING = require("../commands/RESTORE-ASKING");
const ROLE = require("../commands/ROLE");
const SAVE = require("../commands/SAVE");
const SCAN = require("../commands/SCAN");
const SCRIPT_DEBUG = require("../commands/SCRIPT_DEBUG");
const SCRIPT_EXISTS = require("../commands/SCRIPT_EXISTS");
const SCRIPT_FLUSH = require("../commands/SCRIPT_FLUSH");
const SCRIPT_KILL = require("../commands/SCRIPT_KILL");
const SCRIPT_LOAD = require("../commands/SCRIPT_LOAD");
const SHUTDOWN = require("../commands/SHUTDOWN");
const SWAPDB = require("../commands/SWAPDB");
const TIME = require("../commands/TIME");
const UNWATCH = require("../commands/UNWATCH");
const WAIT = require("../commands/WAIT");
exports.default = {
...commands_1.default,
ACL_CAT,
aclCat: ACL_CAT,
ACL_DELUSER,
aclDelUser: ACL_DELUSER,
ACL_DRYRUN,
aclDryRun: ACL_DRYRUN,
ACL_GENPASS,
aclGenPass: ACL_GENPASS,
ACL_GETUSER,
aclGetUser: ACL_GETUSER,
ACL_LIST,
aclList: ACL_LIST,
ACL_LOAD,
aclLoad: ACL_LOAD,
ACL_LOG_RESET,
aclLogReset: ACL_LOG_RESET,
ACL_LOG,
aclLog: ACL_LOG,
ACL_SAVE,
aclSave: ACL_SAVE,
ACL_SETUSER,
aclSetUser: ACL_SETUSER,
ACL_USERS,
aclUsers: ACL_USERS,
ACL_WHOAMI,
aclWhoAmI: ACL_WHOAMI,
ASKING,
asking: ASKING,
AUTH,
auth: AUTH,
BGREWRITEAOF,
bgRewriteAof: BGREWRITEAOF,
BGSAVE,
bgSave: BGSAVE,
CLIENT_CACHING,
clientCaching: CLIENT_CACHING,
CLIENT_GETNAME,
clientGetName: CLIENT_GETNAME,
CLIENT_GETREDIR,
clientGetRedir: CLIENT_GETREDIR,
CLIENT_ID,
clientId: CLIENT_ID,
CLIENT_KILL,
clientKill: CLIENT_KILL,
'CLIENT_NO-EVICT': CLIENT_NO_EVICT,
clientNoEvict: CLIENT_NO_EVICT,
'CLIENT_NO-TOUCH': CLIENT_NO_TOUCH,
clientNoTouch: CLIENT_NO_TOUCH,
CLIENT_LIST,
clientList: CLIENT_LIST,
CLIENT_PAUSE,
clientPause: CLIENT_PAUSE,
CLIENT_SETNAME,
clientSetName: CLIENT_SETNAME,
CLIENT_TRACKING,
clientTracking: CLIENT_TRACKING,
CLIENT_TRACKINGINFO,
clientTrackingInfo: CLIENT_TRACKINGINFO,
CLIENT_UNPAUSE,
clientUnpause: CLIENT_UNPAUSE,
CLIENT_INFO,
clientInfo: CLIENT_INFO,
CLUSTER_ADDSLOTS,
clusterAddSlots: CLUSTER_ADDSLOTS,
CLUSTER_ADDSLOTSRANGE,
clusterAddSlotsRange: CLUSTER_ADDSLOTSRANGE,
CLUSTER_BUMPEPOCH,
clusterBumpEpoch: CLUSTER_BUMPEPOCH,
CLUSTER_COUNT_FAILURE_REPORTS,
clusterCountFailureReports: CLUSTER_COUNT_FAILURE_REPORTS,
CLUSTER_COUNTKEYSINSLOT,
clusterCountKeysInSlot: CLUSTER_COUNTKEYSINSLOT,
CLUSTER_DELSLOTS,
clusterDelSlots: CLUSTER_DELSLOTS,
CLUSTER_DELSLOTSRANGE,
clusterDelSlotsRange: CLUSTER_DELSLOTSRANGE,
CLUSTER_FAILOVER,
clusterFailover: CLUSTER_FAILOVER,
CLUSTER_FLUSHSLOTS,
clusterFlushSlots: CLUSTER_FLUSHSLOTS,
CLUSTER_FORGET,
clusterForget: CLUSTER_FORGET,
CLUSTER_GETKEYSINSLOT,
clusterGetKeysInSlot: CLUSTER_GETKEYSINSLOT,
CLUSTER_INFO,
clusterInfo: CLUSTER_INFO,
CLUSTER_KEYSLOT,
clusterKeySlot: CLUSTER_KEYSLOT,
CLUSTER_LINKS,
clusterLinks: CLUSTER_LINKS,
CLUSTER_MEET,
clusterMeet: CLUSTER_MEET,
CLUSTER_MYID,
clusterMyId: CLUSTER_MYID,
CLUSTER_MYSHARDID,
clusterMyShardId: CLUSTER_MYSHARDID,
CLUSTER_NODES,
clusterNodes: CLUSTER_NODES,
CLUSTER_REPLICAS,
clusterReplicas: CLUSTER_REPLICAS,
CLUSTER_REPLICATE,
clusterReplicate: CLUSTER_REPLICATE,
CLUSTER_RESET,
clusterReset: CLUSTER_RESET,
CLUSTER_SAVECONFIG,
clusterSaveConfig: CLUSTER_SAVECONFIG,
CLUSTER_SET_CONFIG_EPOCH,
clusterSetConfigEpoch: CLUSTER_SET_CONFIG_EPOCH,
CLUSTER_SETSLOT,
clusterSetSlot: CLUSTER_SETSLOT,
CLUSTER_SLOTS,
clusterSlots: CLUSTER_SLOTS,
COMMAND_COUNT,
commandCount: COMMAND_COUNT,
COMMAND_GETKEYS,
commandGetKeys: COMMAND_GETKEYS,
COMMAND_GETKEYSANDFLAGS,
commandGetKeysAndFlags: COMMAND_GETKEYSANDFLAGS,
COMMAND_INFO,
commandInfo: COMMAND_INFO,
COMMAND_LIST,
commandList: COMMAND_LIST,
COMMAND,
command: COMMAND,
CONFIG_GET,
configGet: CONFIG_GET,
CONFIG_RESETASTAT,
configResetStat: CONFIG_RESETASTAT,
CONFIG_REWRITE,
configRewrite: CONFIG_REWRITE,
CONFIG_SET,
configSet: CONFIG_SET,
DBSIZE,
dbSize: DBSIZE,
DISCARD,
discard: DISCARD,
ECHO,
echo: ECHO,
FAILOVER,
failover: FAILOVER,
FLUSHALL,
flushAll: FLUSHALL,
FLUSHDB,
flushDb: FLUSHDB,
FUNCTION_DELETE,
functionDelete: FUNCTION_DELETE,
FUNCTION_DUMP,
functionDump: FUNCTION_DUMP,
FUNCTION_FLUSH,
functionFlush: FUNCTION_FLUSH,
FUNCTION_KILL,
functionKill: FUNCTION_KILL,
FUNCTION_LIST_WITHCODE,
functionListWithCode: FUNCTION_LIST_WITHCODE,
FUNCTION_LIST,
functionList: FUNCTION_LIST,
FUNCTION_LOAD,
functionLoad: FUNCTION_LOAD,
FUNCTION_RESTORE,
functionRestore: FUNCTION_RESTORE,
FUNCTION_STATS,
functionStats: FUNCTION_STATS,
HELLO,
hello: HELLO,
INFO,
info: INFO,
KEYS,
keys: KEYS,
LASTSAVE,
lastSave: LASTSAVE,
LATENCY_DOCTOR,
latencyDoctor: LATENCY_DOCTOR,
LATENCY_GRAPH,
latencyGraph: LATENCY_GRAPH,
LATENCY_HISTORY,
latencyHistory: LATENCY_HISTORY,
LATENCY_LATEST,
latencyLatest: LATENCY_LATEST,
LOLWUT,
lolwut: LOLWUT,
MEMORY_DOCTOR,
memoryDoctor: MEMORY_DOCTOR,
'MEMORY_MALLOC-STATS': MEMORY_MALLOC_STATS,
memoryMallocStats: MEMORY_MALLOC_STATS,
MEMORY_PURGE,
memoryPurge: MEMORY_PURGE,
MEMORY_STATS,
memoryStats: MEMORY_STATS,
MEMORY_USAGE,
memoryUsage: MEMORY_USAGE,
MODULE_LIST,
moduleList: MODULE_LIST,
MODULE_LOAD,
moduleLoad: MODULE_LOAD,
MODULE_UNLOAD,
moduleUnload: MODULE_UNLOAD,
MOVE,
move: MOVE,
PING,
ping: PING,
PUBSUB_CHANNELS,
pubSubChannels: PUBSUB_CHANNELS,
PUBSUB_NUMPAT,
pubSubNumPat: PUBSUB_NUMPAT,
PUBSUB_NUMSUB,
pubSubNumSub: PUBSUB_NUMSUB,
PUBSUB_SHARDCHANNELS,
pubSubShardChannels: PUBSUB_SHARDCHANNELS,
PUBSUB_SHARDNUMSUB,
pubSubShardNumSub: PUBSUB_SHARDNUMSUB,
RANDOMKEY,
randomKey: RANDOMKEY,
READONLY,
readonly: READONLY,
READWRITE,
readwrite: READWRITE,
REPLICAOF,
replicaOf: REPLICAOF,
'RESTORE-ASKING': RESTORE_ASKING,
restoreAsking: RESTORE_ASKING,
ROLE,
role: ROLE,
SAVE,
save: SAVE,
SCAN,
scan: SCAN,
SCRIPT_DEBUG,
scriptDebug: SCRIPT_DEBUG,
SCRIPT_EXISTS,
scriptExists: SCRIPT_EXISTS,
SCRIPT_FLUSH,
scriptFlush: SCRIPT_FLUSH,
SCRIPT_KILL,
scriptKill: SCRIPT_KILL,
SCRIPT_LOAD,
scriptLoad: SCRIPT_LOAD,
SHUTDOWN,
shutdown: SHUTDOWN,
SWAPDB,
swapDb: SWAPDB,
TIME,
time: TIME,
UNWATCH,
unwatch: UNWATCH,
WAIT,
wait: WAIT
};

View File

@@ -0,0 +1,148 @@
/// <reference types="node" />
import COMMANDS from './commands';
import { RedisCommand, RedisCommandArgument, RedisCommandArguments, RedisCommandRawReply, RedisCommandReply, RedisFunctions, RedisModules, RedisExtensions, RedisScript, RedisScripts, RedisCommandSignature, ConvertArgumentType, RedisFunction, ExcludeMappedString } from '../commands';
import { RedisSocketOptions } from './socket';
import { QueueCommandOptions } from './commands-queue';
import { RedisClientMultiCommandType } from './multi-command';
import { RedisMultiQueuedCommand } from '../multi-command';
import { EventEmitter } from 'events';
import { CommandOptions } from '../command-options';
import { ScanOptions, ZMember } from '../commands/generic-transformers';
import { ScanCommandOptions } from '../commands/SCAN';
import { HScanTuple } from '../commands/HSCAN';
import { Options as PoolOptions } from 'generic-pool';
import { PubSubType, PubSubListener, PubSubTypeListeners, ChannelListeners } from './pub-sub';
export interface RedisClientOptions<M extends RedisModules = RedisModules, F extends RedisFunctions = RedisFunctions, S extends RedisScripts = RedisScripts> extends RedisExtensions<M, F, S> {
/**
* `redis[s]://[[username][:password]@][host][:port][/db-number]`
* See [`redis`](https://www.iana.org/assignments/uri-schemes/prov/redis) and [`rediss`](https://www.iana.org/assignments/uri-schemes/prov/rediss) IANA registration for more details
*/
url?: string;
/**
* Socket connection properties
*/
socket?: RedisSocketOptions;
/**
* ACL username ([see ACL guide](https://redis.io/topics/acl))
*/
username?: string;
/**
* ACL password or the old "--requirepass" password
*/
password?: string;
/**
* Client name ([see `CLIENT SETNAME`](https://redis.io/commands/client-setname))
*/
name?: string;
/**
* Redis database number (see [`SELECT`](https://redis.io/commands/select) command)
*/
database?: number;
/**
* Maximum length of the client's internal command queue
*/
commandsQueueMaxLength?: number;
/**
* When `true`, commands are rejected when the client is reconnecting.
* When `false`, commands are queued for execution after reconnection.
*/
disableOfflineQueue?: boolean;
/**
* Connect in [`READONLY`](https://redis.io/commands/readonly) mode
*/
readonly?: boolean;
legacyMode?: boolean;
isolationPoolOptions?: PoolOptions;
/**
* Send `PING` command at interval (in ms).
* Useful with Redis deployments that do not use TCP Keep-Alive.
*/
pingInterval?: number;
/**
* If set to true, disables sending client identifier (user-agent like message) to the redis server
*/
disableClientInfo?: boolean;
/**
* Tag to append to library name that is sent to the Redis server
*/
clientInfoTag?: string;
}
type WithCommands = {
[P in keyof typeof COMMANDS]: RedisCommandSignature<(typeof COMMANDS)[P]>;
};
export type WithModules<M extends RedisModules> = {
[P in keyof M as ExcludeMappedString<P>]: {
[C in keyof M[P] as ExcludeMappedString<C>]: RedisCommandSignature<M[P][C]>;
};
};
export type WithFunctions<F extends RedisFunctions> = {
[P in keyof F as ExcludeMappedString<P>]: {
[FF in keyof F[P] as ExcludeMappedString<FF>]: RedisCommandSignature<F[P][FF]>;
};
};
export type WithScripts<S extends RedisScripts> = {
[P in keyof S as ExcludeMappedString<P>]: RedisCommandSignature<S[P]>;
};
export type RedisClientType<M extends RedisModules = Record<string, never>, F extends RedisFunctions = Record<string, never>, S extends RedisScripts = Record<string, never>> = RedisClient<M, F, S> & WithCommands & WithModules<M> & WithFunctions<F> & WithScripts<S>;
export type InstantiableRedisClient<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> = new (options?: RedisClientOptions<M, F, S>) => RedisClientType<M, F, S>;
export interface ClientCommandOptions extends QueueCommandOptions {
isolated?: boolean;
}
export default class RedisClient<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> extends EventEmitter {
#private;
static commandOptions<T extends ClientCommandOptions>(options: T): CommandOptions<T>;
commandOptions: typeof RedisClient.commandOptions;
static extend<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts>(extensions?: RedisExtensions<M, F, S>): InstantiableRedisClient<M, F, S>;
static create<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts>(options?: RedisClientOptions<M, F, S>): RedisClientType<M, F, S>;
static parseURL(url: string): RedisClientOptions;
get options(): RedisClientOptions<M, F, S> | undefined;
get isOpen(): boolean;
get isReady(): boolean;
get isPubSubActive(): boolean;
get v4(): Record<string, any>;
constructor(options?: RedisClientOptions<M, F, S>);
duplicate(overrides?: Partial<RedisClientOptions<M, F, S>>): RedisClientType<M, F, S>;
connect(): Promise<RedisClientType<M, F, S>>;
commandsExecutor<C extends RedisCommand>(command: C, args: Array<unknown>): Promise<RedisCommandReply<C>>;
sendCommand<T = RedisCommandRawReply>(args: RedisCommandArguments, options?: ClientCommandOptions): Promise<T>;
functionsExecuter<F extends RedisFunction>(fn: F, args: Array<unknown>, name: string): Promise<RedisCommandReply<F>>;
executeFunction(name: string, fn: RedisFunction, args: RedisCommandArguments, options?: ClientCommandOptions): Promise<RedisCommandRawReply>;
scriptsExecuter<S extends RedisScript>(script: S, args: Array<unknown>): Promise<RedisCommandReply<S>>;
executeScript(script: RedisScript, args: RedisCommandArguments, options?: ClientCommandOptions): Promise<RedisCommandRawReply>;
SELECT(db: number): Promise<void>;
SELECT(options: CommandOptions<ClientCommandOptions>, db: number): Promise<void>;
select: {
(db: number): Promise<void>;
(options: CommandOptions<ClientCommandOptions>, db: number): Promise<void>;
};
SUBSCRIBE<T extends boolean = false>(channels: string | Array<string>, listener: PubSubListener<T>, bufferMode?: T): Promise<void>;
subscribe: <T extends boolean = false>(channels: string | Array<string>, listener: PubSubListener<T>, bufferMode?: T | undefined) => Promise<void>;
UNSUBSCRIBE<T extends boolean = false>(channels?: string | Array<string>, listener?: PubSubListener<T>, bufferMode?: T): Promise<void>;
unsubscribe: <T extends boolean = false>(channels?: string | Array<string>, listener?: PubSubListener<T> | undefined, bufferMode?: T | undefined) => Promise<void>;
PSUBSCRIBE<T extends boolean = false>(patterns: string | Array<string>, listener: PubSubListener<T>, bufferMode?: T): Promise<void>;
pSubscribe: <T extends boolean = false>(patterns: string | Array<string>, listener: PubSubListener<T>, bufferMode?: T | undefined) => Promise<void>;
PUNSUBSCRIBE<T extends boolean = false>(patterns?: string | Array<string>, listener?: PubSubListener<T>, bufferMode?: T): Promise<void>;
pUnsubscribe: <T extends boolean = false>(patterns?: string | Array<string>, listener?: PubSubListener<T> | undefined, bufferMode?: T | undefined) => Promise<void>;
SSUBSCRIBE<T extends boolean = false>(channels: string | Array<string>, listener: PubSubListener<T>, bufferMode?: T): Promise<void>;
sSubscribe: <T extends boolean = false>(channels: string | Array<string>, listener: PubSubListener<T>, bufferMode?: T | undefined) => Promise<void>;
SUNSUBSCRIBE<T extends boolean = false>(channels?: string | Array<string>, listener?: PubSubListener<T>, bufferMode?: T): Promise<void>;
sUnsubscribe: <T extends boolean = false>(channels?: string | Array<string>, listener?: PubSubListener<T> | undefined, bufferMode?: T | undefined) => Promise<void>;
getPubSubListeners(type: PubSubType): PubSubTypeListeners;
extendPubSubChannelListeners(type: PubSubType, channel: string, listeners: ChannelListeners): Promise<void>;
extendPubSubListeners(type: PubSubType, listeners: PubSubTypeListeners): Promise<void>;
QUIT(): Promise<string>;
quit: () => Promise<string>;
executeIsolated<T>(fn: (client: RedisClientType<M, F, S>) => T | Promise<T>): Promise<T>;
MULTI(): RedisClientMultiCommandType<M, F, S>;
multi: () => RedisClientMultiCommandType<M, F, S>;
multiExecutor(commands: Array<RedisMultiQueuedCommand>, selectedDB?: number, chainId?: symbol): Promise<Array<RedisCommandRawReply>>;
scanIterator(options?: ScanCommandOptions): AsyncIterable<string>;
hScanIterator(key: string, options?: ScanOptions): AsyncIterable<ConvertArgumentType<HScanTuple, string>>;
hScanNoValuesIterator(key: string, options?: ScanOptions): AsyncIterable<ConvertArgumentType<RedisCommandArgument, string>>;
sScanIterator(key: string, options?: ScanOptions): AsyncIterable<string>;
zScanIterator(key: string, options?: ScanOptions): AsyncIterable<ConvertArgumentType<ZMember, string>>;
disconnect(): Promise<void>;
ref(): void;
unref(): void;
}
export {};

View File

@@ -0,0 +1,563 @@
"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _RedisClient_instances, _a, _RedisClient_options, _RedisClient_socket, _RedisClient_queue, _RedisClient_isolationPool, _RedisClient_v4, _RedisClient_selectedDB, _RedisClient_initiateOptions, _RedisClient_initiateQueue, _RedisClient_initiateSocket, _RedisClient_initiateIsolationPool, _RedisClient_legacyMode, _RedisClient_legacySendCommand, _RedisClient_defineLegacyCommand, _RedisClient_pingTimer, _RedisClient_setPingTimer, _RedisClient_sendCommand, _RedisClient_pubSubCommand, _RedisClient_tick, _RedisClient_addMultiCommands, _RedisClient_destroyIsolationPool;
Object.defineProperty(exports, "__esModule", { value: true });
const commands_1 = require("./commands");
const socket_1 = require("./socket");
const commands_queue_1 = require("./commands-queue");
const multi_command_1 = require("./multi-command");
const events_1 = require("events");
const command_options_1 = require("../command-options");
const commander_1 = require("../commander");
const generic_pool_1 = require("generic-pool");
const errors_1 = require("../errors");
const url_1 = require("url");
const pub_sub_1 = require("./pub-sub");
const package_json_1 = require("../../package.json");
class RedisClient extends events_1.EventEmitter {
static commandOptions(options) {
return (0, command_options_1.commandOptions)(options);
}
static extend(extensions) {
const Client = (0, commander_1.attachExtensions)({
BaseClass: _a,
modulesExecutor: _a.prototype.commandsExecutor,
modules: extensions?.modules,
functionsExecutor: _a.prototype.functionsExecuter,
functions: extensions?.functions,
scriptsExecutor: _a.prototype.scriptsExecuter,
scripts: extensions?.scripts
});
if (Client !== _a) {
Client.prototype.Multi = multi_command_1.default.extend(extensions);
}
return Client;
}
static create(options) {
return new (_a.extend(options))(options);
}
static parseURL(url) {
// https://www.iana.org/assignments/uri-schemes/prov/redis
const { hostname, port, protocol, username, password, pathname } = new url_1.URL(url), parsed = {
socket: {
host: hostname
}
};
if (protocol === 'rediss:') {
parsed.socket.tls = true;
}
else if (protocol !== 'redis:') {
throw new TypeError('Invalid protocol');
}
if (port) {
parsed.socket.port = Number(port);
}
if (username) {
parsed.username = decodeURIComponent(username);
}
if (password) {
parsed.password = decodeURIComponent(password);
}
if (pathname.length > 1) {
const database = Number(pathname.substring(1));
if (isNaN(database)) {
throw new TypeError('Invalid pathname');
}
parsed.database = database;
}
return parsed;
}
get options() {
return __classPrivateFieldGet(this, _RedisClient_options, "f");
}
get isOpen() {
return __classPrivateFieldGet(this, _RedisClient_socket, "f").isOpen;
}
get isReady() {
return __classPrivateFieldGet(this, _RedisClient_socket, "f").isReady;
}
get isPubSubActive() {
return __classPrivateFieldGet(this, _RedisClient_queue, "f").isPubSubActive;
}
get v4() {
if (!__classPrivateFieldGet(this, _RedisClient_options, "f")?.legacyMode) {
throw new Error('the client is not in "legacy mode"');
}
return __classPrivateFieldGet(this, _RedisClient_v4, "f");
}
constructor(options) {
super();
_RedisClient_instances.add(this);
Object.defineProperty(this, "commandOptions", {
enumerable: true,
configurable: true,
writable: true,
value: _a.commandOptions
});
_RedisClient_options.set(this, void 0);
_RedisClient_socket.set(this, void 0);
_RedisClient_queue.set(this, void 0);
_RedisClient_isolationPool.set(this, void 0);
_RedisClient_v4.set(this, {});
_RedisClient_selectedDB.set(this, 0);
_RedisClient_pingTimer.set(this, void 0);
Object.defineProperty(this, "select", {
enumerable: true,
configurable: true,
writable: true,
value: this.SELECT
});
Object.defineProperty(this, "subscribe", {
enumerable: true,
configurable: true,
writable: true,
value: this.SUBSCRIBE
});
Object.defineProperty(this, "unsubscribe", {
enumerable: true,
configurable: true,
writable: true,
value: this.UNSUBSCRIBE
});
Object.defineProperty(this, "pSubscribe", {
enumerable: true,
configurable: true,
writable: true,
value: this.PSUBSCRIBE
});
Object.defineProperty(this, "pUnsubscribe", {
enumerable: true,
configurable: true,
writable: true,
value: this.PUNSUBSCRIBE
});
Object.defineProperty(this, "sSubscribe", {
enumerable: true,
configurable: true,
writable: true,
value: this.SSUBSCRIBE
});
Object.defineProperty(this, "sUnsubscribe", {
enumerable: true,
configurable: true,
writable: true,
value: this.SUNSUBSCRIBE
});
Object.defineProperty(this, "quit", {
enumerable: true,
configurable: true,
writable: true,
value: this.QUIT
});
Object.defineProperty(this, "multi", {
enumerable: true,
configurable: true,
writable: true,
value: this.MULTI
});
__classPrivateFieldSet(this, _RedisClient_options, __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_initiateOptions).call(this, options), "f");
__classPrivateFieldSet(this, _RedisClient_queue, __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_initiateQueue).call(this), "f");
__classPrivateFieldSet(this, _RedisClient_socket, __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_initiateSocket).call(this), "f");
// should be initiated in connect, not here
// TODO: consider breaking in v5
__classPrivateFieldSet(this, _RedisClient_isolationPool, __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_initiateIsolationPool).call(this), "f");
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_legacyMode).call(this);
}
duplicate(overrides) {
return new (Object.getPrototypeOf(this).constructor)({
...__classPrivateFieldGet(this, _RedisClient_options, "f"),
...overrides
});
}
async connect() {
// see comment in constructor
__classPrivateFieldSet(this, _RedisClient_isolationPool, __classPrivateFieldGet(this, _RedisClient_isolationPool, "f") ?? __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_initiateIsolationPool).call(this), "f");
await __classPrivateFieldGet(this, _RedisClient_socket, "f").connect();
return this;
}
async commandsExecutor(command, args) {
const { args: redisArgs, options } = (0, commander_1.transformCommandArguments)(command, args);
return (0, commander_1.transformCommandReply)(command, await __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_sendCommand).call(this, redisArgs, options), redisArgs.preserve);
}
sendCommand(args, options) {
return __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_sendCommand).call(this, args, options);
}
async functionsExecuter(fn, args, name) {
const { args: redisArgs, options } = (0, commander_1.transformCommandArguments)(fn, args);
return (0, commander_1.transformCommandReply)(fn, await this.executeFunction(name, fn, redisArgs, options), redisArgs.preserve);
}
executeFunction(name, fn, args, options) {
return __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_sendCommand).call(this, (0, commander_1.fCallArguments)(name, fn, args), options);
}
async scriptsExecuter(script, args) {
const { args: redisArgs, options } = (0, commander_1.transformCommandArguments)(script, args);
return (0, commander_1.transformCommandReply)(script, await this.executeScript(script, redisArgs, options), redisArgs.preserve);
}
async executeScript(script, args, options) {
const redisArgs = ['EVALSHA', script.SHA1];
if (script.NUMBER_OF_KEYS !== undefined) {
redisArgs.push(script.NUMBER_OF_KEYS.toString());
}
redisArgs.push(...args);
try {
return await __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_sendCommand).call(this, redisArgs, options);
}
catch (err) {
if (!err?.message?.startsWith?.('NOSCRIPT')) {
throw err;
}
redisArgs[0] = 'EVAL';
redisArgs[1] = script.SCRIPT;
return __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_sendCommand).call(this, redisArgs, options);
}
}
async SELECT(options, db) {
if (!(0, command_options_1.isCommandOptions)(options)) {
db = options;
options = null;
}
await __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_sendCommand).call(this, ['SELECT', db.toString()], options);
__classPrivateFieldSet(this, _RedisClient_selectedDB, db, "f");
}
SUBSCRIBE(channels, listener, bufferMode) {
return __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_pubSubCommand).call(this, __classPrivateFieldGet(this, _RedisClient_queue, "f").subscribe(pub_sub_1.PubSubType.CHANNELS, channels, listener, bufferMode));
}
UNSUBSCRIBE(channels, listener, bufferMode) {
return __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_pubSubCommand).call(this, __classPrivateFieldGet(this, _RedisClient_queue, "f").unsubscribe(pub_sub_1.PubSubType.CHANNELS, channels, listener, bufferMode));
}
PSUBSCRIBE(patterns, listener, bufferMode) {
return __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_pubSubCommand).call(this, __classPrivateFieldGet(this, _RedisClient_queue, "f").subscribe(pub_sub_1.PubSubType.PATTERNS, patterns, listener, bufferMode));
}
PUNSUBSCRIBE(patterns, listener, bufferMode) {
return __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_pubSubCommand).call(this, __classPrivateFieldGet(this, _RedisClient_queue, "f").unsubscribe(pub_sub_1.PubSubType.PATTERNS, patterns, listener, bufferMode));
}
SSUBSCRIBE(channels, listener, bufferMode) {
return __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_pubSubCommand).call(this, __classPrivateFieldGet(this, _RedisClient_queue, "f").subscribe(pub_sub_1.PubSubType.SHARDED, channels, listener, bufferMode));
}
SUNSUBSCRIBE(channels, listener, bufferMode) {
return __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_pubSubCommand).call(this, __classPrivateFieldGet(this, _RedisClient_queue, "f").unsubscribe(pub_sub_1.PubSubType.SHARDED, channels, listener, bufferMode));
}
getPubSubListeners(type) {
return __classPrivateFieldGet(this, _RedisClient_queue, "f").getPubSubListeners(type);
}
extendPubSubChannelListeners(type, channel, listeners) {
return __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_pubSubCommand).call(this, __classPrivateFieldGet(this, _RedisClient_queue, "f").extendPubSubChannelListeners(type, channel, listeners));
}
extendPubSubListeners(type, listeners) {
return __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_pubSubCommand).call(this, __classPrivateFieldGet(this, _RedisClient_queue, "f").extendPubSubListeners(type, listeners));
}
QUIT() {
return __classPrivateFieldGet(this, _RedisClient_socket, "f").quit(async () => {
if (__classPrivateFieldGet(this, _RedisClient_pingTimer, "f"))
clearTimeout(__classPrivateFieldGet(this, _RedisClient_pingTimer, "f"));
const quitPromise = __classPrivateFieldGet(this, _RedisClient_queue, "f").addCommand(['QUIT']);
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_tick).call(this);
const [reply] = await Promise.all([
quitPromise,
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_destroyIsolationPool).call(this)
]);
return reply;
});
}
executeIsolated(fn) {
if (!__classPrivateFieldGet(this, _RedisClient_isolationPool, "f"))
return Promise.reject(new errors_1.ClientClosedError());
return __classPrivateFieldGet(this, _RedisClient_isolationPool, "f").use(fn);
}
MULTI() {
return new this.Multi(this.multiExecutor.bind(this), __classPrivateFieldGet(this, _RedisClient_options, "f")?.legacyMode);
}
async multiExecutor(commands, selectedDB, chainId) {
if (!__classPrivateFieldGet(this, _RedisClient_socket, "f").isOpen) {
return Promise.reject(new errors_1.ClientClosedError());
}
const promise = chainId ?
// if `chainId` has a value, it's a `MULTI` (and not "pipeline") - need to add the `MULTI` and `EXEC` commands
Promise.all([
__classPrivateFieldGet(this, _RedisClient_queue, "f").addCommand(['MULTI'], { chainId }),
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_addMultiCommands).call(this, commands, chainId),
__classPrivateFieldGet(this, _RedisClient_queue, "f").addCommand(['EXEC'], { chainId })
]) :
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_addMultiCommands).call(this, commands);
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_tick).call(this);
const results = await promise;
if (selectedDB !== undefined) {
__classPrivateFieldSet(this, _RedisClient_selectedDB, selectedDB, "f");
}
return results;
}
async *scanIterator(options) {
let cursor = 0;
do {
const reply = await this.scan(cursor, options);
cursor = reply.cursor;
for (const key of reply.keys) {
yield key;
}
} while (cursor !== 0);
}
async *hScanIterator(key, options) {
let cursor = 0;
do {
const reply = await this.hScan(key, cursor, options);
cursor = reply.cursor;
for (const tuple of reply.tuples) {
yield tuple;
}
} while (cursor !== 0);
}
async *hScanNoValuesIterator(key, options) {
let cursor = 0;
do {
const reply = await this.hScanNoValues(key, cursor, options);
cursor = reply.cursor;
for (const k of reply.keys) {
yield k;
}
} while (cursor !== 0);
}
async *sScanIterator(key, options) {
let cursor = 0;
do {
const reply = await this.sScan(key, cursor, options);
cursor = reply.cursor;
for (const member of reply.members) {
yield member;
}
} while (cursor !== 0);
}
async *zScanIterator(key, options) {
let cursor = 0;
do {
const reply = await this.zScan(key, cursor, options);
cursor = reply.cursor;
for (const member of reply.members) {
yield member;
}
} while (cursor !== 0);
}
async disconnect() {
if (__classPrivateFieldGet(this, _RedisClient_pingTimer, "f"))
clearTimeout(__classPrivateFieldGet(this, _RedisClient_pingTimer, "f"));
__classPrivateFieldGet(this, _RedisClient_queue, "f").flushAll(new errors_1.DisconnectsClientError());
__classPrivateFieldGet(this, _RedisClient_socket, "f").disconnect();
await __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_destroyIsolationPool).call(this);
}
ref() {
__classPrivateFieldGet(this, _RedisClient_socket, "f").ref();
}
unref() {
__classPrivateFieldGet(this, _RedisClient_socket, "f").unref();
}
}
_a = RedisClient, _RedisClient_options = new WeakMap(), _RedisClient_socket = new WeakMap(), _RedisClient_queue = new WeakMap(), _RedisClient_isolationPool = new WeakMap(), _RedisClient_v4 = new WeakMap(), _RedisClient_selectedDB = new WeakMap(), _RedisClient_pingTimer = new WeakMap(), _RedisClient_instances = new WeakSet(), _RedisClient_initiateOptions = function _RedisClient_initiateOptions(options) {
if (options?.url) {
const parsed = _a.parseURL(options.url);
if (options.socket) {
parsed.socket = Object.assign(options.socket, parsed.socket);
}
Object.assign(options, parsed);
}
if (options?.database) {
__classPrivateFieldSet(this, _RedisClient_selectedDB, options.database, "f");
}
return options;
}, _RedisClient_initiateQueue = function _RedisClient_initiateQueue() {
return new commands_queue_1.default(__classPrivateFieldGet(this, _RedisClient_options, "f")?.commandsQueueMaxLength, (channel, listeners) => this.emit('sharded-channel-moved', channel, listeners));
}, _RedisClient_initiateSocket = function _RedisClient_initiateSocket() {
const socketInitiator = async () => {
const promises = [];
if (__classPrivateFieldGet(this, _RedisClient_selectedDB, "f") !== 0) {
promises.push(__classPrivateFieldGet(this, _RedisClient_queue, "f").addCommand(['SELECT', __classPrivateFieldGet(this, _RedisClient_selectedDB, "f").toString()], { asap: true }));
}
if (__classPrivateFieldGet(this, _RedisClient_options, "f")?.readonly) {
promises.push(__classPrivateFieldGet(this, _RedisClient_queue, "f").addCommand(commands_1.default.READONLY.transformArguments(), { asap: true }));
}
if (!__classPrivateFieldGet(this, _RedisClient_options, "f")?.disableClientInfo) {
promises.push(__classPrivateFieldGet(this, _RedisClient_queue, "f").addCommand(['CLIENT', 'SETINFO', 'LIB-VER', package_json_1.version], { asap: true }).catch(err => {
if (!(err instanceof errors_1.ErrorReply)) {
throw err;
}
}));
promises.push(__classPrivateFieldGet(this, _RedisClient_queue, "f").addCommand([
'CLIENT', 'SETINFO', 'LIB-NAME',
__classPrivateFieldGet(this, _RedisClient_options, "f")?.clientInfoTag ? `node-redis(${__classPrivateFieldGet(this, _RedisClient_options, "f").clientInfoTag})` : 'node-redis'
], { asap: true }).catch(err => {
if (!(err instanceof errors_1.ErrorReply)) {
throw err;
}
}));
}
if (__classPrivateFieldGet(this, _RedisClient_options, "f")?.name) {
promises.push(__classPrivateFieldGet(this, _RedisClient_queue, "f").addCommand(commands_1.default.CLIENT_SETNAME.transformArguments(__classPrivateFieldGet(this, _RedisClient_options, "f").name), { asap: true }));
}
if (__classPrivateFieldGet(this, _RedisClient_options, "f")?.username || __classPrivateFieldGet(this, _RedisClient_options, "f")?.password) {
promises.push(__classPrivateFieldGet(this, _RedisClient_queue, "f").addCommand(commands_1.default.AUTH.transformArguments({
username: __classPrivateFieldGet(this, _RedisClient_options, "f").username,
password: __classPrivateFieldGet(this, _RedisClient_options, "f").password ?? ''
}), { asap: true }));
}
const resubscribePromise = __classPrivateFieldGet(this, _RedisClient_queue, "f").resubscribe();
if (resubscribePromise) {
promises.push(resubscribePromise);
}
if (promises.length) {
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_tick).call(this, true);
await Promise.all(promises);
}
};
return new socket_1.default(socketInitiator, __classPrivateFieldGet(this, _RedisClient_options, "f")?.socket)
.on('data', chunk => __classPrivateFieldGet(this, _RedisClient_queue, "f").onReplyChunk(chunk))
.on('error', err => {
this.emit('error', err);
if (__classPrivateFieldGet(this, _RedisClient_socket, "f").isOpen && !__classPrivateFieldGet(this, _RedisClient_options, "f")?.disableOfflineQueue) {
__classPrivateFieldGet(this, _RedisClient_queue, "f").flushWaitingForReply(err);
}
else {
__classPrivateFieldGet(this, _RedisClient_queue, "f").flushAll(err);
}
})
.on('connect', () => {
this.emit('connect');
})
.on('ready', () => {
this.emit('ready');
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_setPingTimer).call(this);
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_tick).call(this);
})
.on('reconnecting', () => this.emit('reconnecting'))
.on('drain', () => __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_tick).call(this))
.on('end', () => this.emit('end'));
}, _RedisClient_initiateIsolationPool = function _RedisClient_initiateIsolationPool() {
return (0, generic_pool_1.createPool)({
create: async () => {
const duplicate = this.duplicate({
isolationPoolOptions: undefined
}).on('error', err => this.emit('error', err));
await duplicate.connect();
return duplicate;
},
destroy: client => client.disconnect()
}, __classPrivateFieldGet(this, _RedisClient_options, "f")?.isolationPoolOptions);
}, _RedisClient_legacyMode = function _RedisClient_legacyMode() {
var _b, _c;
if (!__classPrivateFieldGet(this, _RedisClient_options, "f")?.legacyMode)
return;
__classPrivateFieldGet(this, _RedisClient_v4, "f").sendCommand = __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_sendCommand).bind(this);
this.sendCommand = (...args) => {
const result = __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_legacySendCommand).call(this, ...args);
if (result) {
result.promise
.then(reply => result.callback(null, reply))
.catch(err => result.callback(err));
}
};
for (const [name, command] of Object.entries(commands_1.default)) {
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_defineLegacyCommand).call(this, name, command);
(_b = this)[_c = name.toLowerCase()] ?? (_b[_c] = this[name]);
}
// hard coded commands
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_defineLegacyCommand).call(this, 'SELECT');
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_defineLegacyCommand).call(this, 'select');
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_defineLegacyCommand).call(this, 'SUBSCRIBE');
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_defineLegacyCommand).call(this, 'subscribe');
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_defineLegacyCommand).call(this, 'PSUBSCRIBE');
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_defineLegacyCommand).call(this, 'pSubscribe');
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_defineLegacyCommand).call(this, 'UNSUBSCRIBE');
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_defineLegacyCommand).call(this, 'unsubscribe');
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_defineLegacyCommand).call(this, 'PUNSUBSCRIBE');
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_defineLegacyCommand).call(this, 'pUnsubscribe');
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_defineLegacyCommand).call(this, 'QUIT');
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_defineLegacyCommand).call(this, 'quit');
}, _RedisClient_legacySendCommand = function _RedisClient_legacySendCommand(...args) {
const callback = typeof args[args.length - 1] === 'function' ?
args.pop() :
undefined;
const promise = __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_sendCommand).call(this, (0, commander_1.transformLegacyCommandArguments)(args));
if (callback)
return {
promise,
callback
};
promise.catch(err => this.emit('error', err));
}, _RedisClient_defineLegacyCommand = function _RedisClient_defineLegacyCommand(name, command) {
__classPrivateFieldGet(this, _RedisClient_v4, "f")[name] = this[name].bind(this);
this[name] = command && command.TRANSFORM_LEGACY_REPLY && command.transformReply ?
(...args) => {
const result = __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_legacySendCommand).call(this, name, ...args);
if (result) {
result.promise
.then(reply => result.callback(null, command.transformReply(reply)))
.catch(err => result.callback(err));
}
} :
(...args) => this.sendCommand(name, ...args);
}, _RedisClient_setPingTimer = function _RedisClient_setPingTimer() {
if (!__classPrivateFieldGet(this, _RedisClient_options, "f")?.pingInterval || !__classPrivateFieldGet(this, _RedisClient_socket, "f").isReady)
return;
clearTimeout(__classPrivateFieldGet(this, _RedisClient_pingTimer, "f"));
__classPrivateFieldSet(this, _RedisClient_pingTimer, setTimeout(() => {
if (!__classPrivateFieldGet(this, _RedisClient_socket, "f").isReady)
return;
// using #sendCommand to support legacy mode
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_sendCommand).call(this, ['PING'])
.then(reply => this.emit('ping-interval', reply))
.catch(err => this.emit('error', err))
.finally(() => __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_setPingTimer).call(this));
}, __classPrivateFieldGet(this, _RedisClient_options, "f").pingInterval), "f");
}, _RedisClient_sendCommand = function _RedisClient_sendCommand(args, options) {
if (!__classPrivateFieldGet(this, _RedisClient_socket, "f").isOpen) {
return Promise.reject(new errors_1.ClientClosedError());
}
else if (options?.isolated) {
return this.executeIsolated(isolatedClient => isolatedClient.sendCommand(args, {
...options,
isolated: false
}));
}
else if (!__classPrivateFieldGet(this, _RedisClient_socket, "f").isReady && __classPrivateFieldGet(this, _RedisClient_options, "f")?.disableOfflineQueue) {
return Promise.reject(new errors_1.ClientOfflineError());
}
const promise = __classPrivateFieldGet(this, _RedisClient_queue, "f").addCommand(args, options);
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_tick).call(this);
return promise;
}, _RedisClient_pubSubCommand = function _RedisClient_pubSubCommand(promise) {
if (promise === undefined)
return Promise.resolve();
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_tick).call(this);
return promise;
}, _RedisClient_tick = function _RedisClient_tick(force = false) {
if (__classPrivateFieldGet(this, _RedisClient_socket, "f").writableNeedDrain || (!force && !__classPrivateFieldGet(this, _RedisClient_socket, "f").isReady)) {
return;
}
__classPrivateFieldGet(this, _RedisClient_socket, "f").cork();
while (!__classPrivateFieldGet(this, _RedisClient_socket, "f").writableNeedDrain) {
const args = __classPrivateFieldGet(this, _RedisClient_queue, "f").getCommandToSend();
if (args === undefined)
break;
__classPrivateFieldGet(this, _RedisClient_socket, "f").writeCommand(args);
}
}, _RedisClient_addMultiCommands = function _RedisClient_addMultiCommands(commands, chainId) {
return Promise.all(commands.map(({ args }) => __classPrivateFieldGet(this, _RedisClient_queue, "f").addCommand(args, { chainId })));
}, _RedisClient_destroyIsolationPool = async function _RedisClient_destroyIsolationPool() {
await __classPrivateFieldGet(this, _RedisClient_isolationPool, "f").drain();
await __classPrivateFieldGet(this, _RedisClient_isolationPool, "f").clear();
__classPrivateFieldSet(this, _RedisClient_isolationPool, undefined, "f");
};
exports.default = RedisClient;
(0, commander_1.attachCommands)({
BaseClass: RedisClient,
commands: commands_1.default,
executor: RedisClient.prototype.commandsExecutor
});
RedisClient.prototype.Multi = multi_command_1.default;

View File

@@ -0,0 +1,39 @@
import COMMANDS from './commands';
import { RedisCommand, RedisCommandArguments, RedisCommandRawReply, RedisFunctions, RedisModules, RedisExtensions, RedisScript, RedisScripts, ExcludeMappedString, RedisFunction } from '../commands';
import { RedisMultiQueuedCommand } from '../multi-command';
type CommandSignature<C extends RedisCommand, M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> = (...args: Parameters<C['transformArguments']>) => RedisClientMultiCommandType<M, F, S>;
type WithCommands<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> = {
[P in keyof typeof COMMANDS]: CommandSignature<(typeof COMMANDS)[P], M, F, S>;
};
type WithModules<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> = {
[P in keyof M as ExcludeMappedString<P>]: {
[C in keyof M[P] as ExcludeMappedString<C>]: CommandSignature<M[P][C], M, F, S>;
};
};
type WithFunctions<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> = {
[P in keyof F as ExcludeMappedString<P>]: {
[FF in keyof F[P] as ExcludeMappedString<FF>]: CommandSignature<F[P][FF], M, F, S>;
};
};
type WithScripts<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> = {
[P in keyof S as ExcludeMappedString<P>]: CommandSignature<S[P], M, F, S>;
};
export type RedisClientMultiCommandType<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> = RedisClientMultiCommand & WithCommands<M, F, S> & WithModules<M, F, S> & WithFunctions<M, F, S> & WithScripts<M, F, S>;
type InstantiableRedisMultiCommand<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> = new (...args: ConstructorParameters<typeof RedisClientMultiCommand>) => RedisClientMultiCommandType<M, F, S>;
export type RedisClientMultiExecutor = (queue: Array<RedisMultiQueuedCommand>, selectedDB?: number, chainId?: symbol) => Promise<Array<RedisCommandRawReply>>;
export default class RedisClientMultiCommand {
#private;
static extend<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts>(extensions?: RedisExtensions<M, F, S>): InstantiableRedisMultiCommand<M, F, S>;
readonly v4: Record<string, any>;
constructor(executor: RedisClientMultiExecutor, legacyMode?: boolean);
commandsExecutor(command: RedisCommand, args: Array<unknown>): this;
SELECT(db: number, transformReply?: RedisCommand['transformReply']): this;
select: (db: number, transformReply?: RedisCommand['transformReply']) => this;
addCommand(args: RedisCommandArguments, transformReply?: RedisCommand['transformReply']): this;
functionsExecutor(fn: RedisFunction, args: Array<unknown>, name: string): this;
scriptsExecutor(script: RedisScript, args: Array<unknown>): this;
exec(execAsPipeline?: boolean): Promise<Array<RedisCommandRawReply>>;
EXEC: (execAsPipeline?: boolean) => Promise<Array<RedisCommandRawReply>>;
execAsPipeline(): Promise<Array<RedisCommandRawReply>>;
}
export {};

View File

@@ -0,0 +1,130 @@
"use strict";
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _RedisClientMultiCommand_instances, _RedisClientMultiCommand_multi, _RedisClientMultiCommand_executor, _RedisClientMultiCommand_selectedDB, _RedisClientMultiCommand_legacyMode, _RedisClientMultiCommand_defineLegacyCommand;
Object.defineProperty(exports, "__esModule", { value: true });
const commands_1 = require("./commands");
const multi_command_1 = require("../multi-command");
const commander_1 = require("../commander");
class RedisClientMultiCommand {
static extend(extensions) {
return (0, commander_1.attachExtensions)({
BaseClass: RedisClientMultiCommand,
modulesExecutor: RedisClientMultiCommand.prototype.commandsExecutor,
modules: extensions?.modules,
functionsExecutor: RedisClientMultiCommand.prototype.functionsExecutor,
functions: extensions?.functions,
scriptsExecutor: RedisClientMultiCommand.prototype.scriptsExecutor,
scripts: extensions?.scripts
});
}
constructor(executor, legacyMode = false) {
_RedisClientMultiCommand_instances.add(this);
_RedisClientMultiCommand_multi.set(this, new multi_command_1.default());
_RedisClientMultiCommand_executor.set(this, void 0);
Object.defineProperty(this, "v4", {
enumerable: true,
configurable: true,
writable: true,
value: {}
});
_RedisClientMultiCommand_selectedDB.set(this, void 0);
Object.defineProperty(this, "select", {
enumerable: true,
configurable: true,
writable: true,
value: this.SELECT
});
Object.defineProperty(this, "EXEC", {
enumerable: true,
configurable: true,
writable: true,
value: this.exec
});
__classPrivateFieldSet(this, _RedisClientMultiCommand_executor, executor, "f");
if (legacyMode) {
__classPrivateFieldGet(this, _RedisClientMultiCommand_instances, "m", _RedisClientMultiCommand_legacyMode).call(this);
}
}
commandsExecutor(command, args) {
return this.addCommand(command.transformArguments(...args), command.transformReply);
}
SELECT(db, transformReply) {
__classPrivateFieldSet(this, _RedisClientMultiCommand_selectedDB, db, "f");
return this.addCommand(['SELECT', db.toString()], transformReply);
}
addCommand(args, transformReply) {
__classPrivateFieldGet(this, _RedisClientMultiCommand_multi, "f").addCommand(args, transformReply);
return this;
}
functionsExecutor(fn, args, name) {
__classPrivateFieldGet(this, _RedisClientMultiCommand_multi, "f").addFunction(name, fn, args);
return this;
}
scriptsExecutor(script, args) {
__classPrivateFieldGet(this, _RedisClientMultiCommand_multi, "f").addScript(script, args);
return this;
}
async exec(execAsPipeline = false) {
if (execAsPipeline) {
return this.execAsPipeline();
}
return __classPrivateFieldGet(this, _RedisClientMultiCommand_multi, "f").handleExecReplies(await __classPrivateFieldGet(this, _RedisClientMultiCommand_executor, "f").call(this, __classPrivateFieldGet(this, _RedisClientMultiCommand_multi, "f").queue, __classPrivateFieldGet(this, _RedisClientMultiCommand_selectedDB, "f"), multi_command_1.default.generateChainId()));
}
async execAsPipeline() {
if (__classPrivateFieldGet(this, _RedisClientMultiCommand_multi, "f").queue.length === 0)
return [];
return __classPrivateFieldGet(this, _RedisClientMultiCommand_multi, "f").transformReplies(await __classPrivateFieldGet(this, _RedisClientMultiCommand_executor, "f").call(this, __classPrivateFieldGet(this, _RedisClientMultiCommand_multi, "f").queue, __classPrivateFieldGet(this, _RedisClientMultiCommand_selectedDB, "f")));
}
}
_RedisClientMultiCommand_multi = new WeakMap(), _RedisClientMultiCommand_executor = new WeakMap(), _RedisClientMultiCommand_selectedDB = new WeakMap(), _RedisClientMultiCommand_instances = new WeakSet(), _RedisClientMultiCommand_legacyMode = function _RedisClientMultiCommand_legacyMode() {
var _a, _b;
this.v4.addCommand = this.addCommand.bind(this);
this.addCommand = (...args) => {
__classPrivateFieldGet(this, _RedisClientMultiCommand_multi, "f").addCommand((0, commander_1.transformLegacyCommandArguments)(args));
return this;
};
this.v4.exec = this.exec.bind(this);
this.exec = (callback) => {
this.v4.exec()
.then((reply) => {
if (!callback)
return;
callback(null, reply);
})
.catch((err) => {
if (!callback) {
// this.emit('error', err);
return;
}
callback(err);
});
};
for (const [name, command] of Object.entries(commands_1.default)) {
__classPrivateFieldGet(this, _RedisClientMultiCommand_instances, "m", _RedisClientMultiCommand_defineLegacyCommand).call(this, name, command);
(_a = this)[_b = name.toLowerCase()] ?? (_a[_b] = this[name]);
}
}, _RedisClientMultiCommand_defineLegacyCommand = function _RedisClientMultiCommand_defineLegacyCommand(name, command) {
this.v4[name] = this[name].bind(this.v4);
this[name] = command && command.TRANSFORM_LEGACY_REPLY && command.transformReply ?
(...args) => {
__classPrivateFieldGet(this, _RedisClientMultiCommand_multi, "f").addCommand([name, ...(0, commander_1.transformLegacyCommandArguments)(args)], command.transformReply);
return this;
} :
(...args) => this.addCommand(name, ...args);
};
exports.default = RedisClientMultiCommand;
(0, commander_1.attachCommands)({
BaseClass: RedisClientMultiCommand,
commands: commands_1.default,
executor: RedisClientMultiCommand.prototype.commandsExecutor
});

View File

@@ -0,0 +1,50 @@
/// <reference types="node" />
import { RedisCommandArgument } from "../commands";
export declare enum PubSubType {
CHANNELS = "CHANNELS",
PATTERNS = "PATTERNS",
SHARDED = "SHARDED"
}
export type PubSubListener<RETURN_BUFFERS extends boolean = false> = <T extends RETURN_BUFFERS extends true ? Buffer : string>(message: T, channel: T) => unknown;
export interface ChannelListeners {
unsubscribing: boolean;
buffers: Set<PubSubListener<true>>;
strings: Set<PubSubListener<false>>;
}
export type PubSubTypeListeners = Map<string, ChannelListeners>;
export type PubSubCommand = ReturnType<typeof PubSub.prototype.subscribe | typeof PubSub.prototype.unsubscribe | typeof PubSub.prototype.extendTypeListeners>;
export declare class PubSub {
#private;
static isStatusReply(reply: Array<Buffer>): boolean;
static isShardedUnsubscribe(reply: Array<Buffer>): boolean;
get isActive(): boolean;
subscribe<T extends boolean>(type: PubSubType, channels: string | Array<string>, listener: PubSubListener<T>, returnBuffers?: T): {
args: RedisCommandArgument[];
channelsCounter: number;
resolve: () => void;
reject: () => void;
} | undefined;
extendChannelListeners(type: PubSubType, channel: string, listeners: ChannelListeners): {
args: (string | Buffer)[];
channelsCounter: number;
resolve: () => number;
reject: () => void;
} | undefined;
extendTypeListeners(type: PubSubType, listeners: PubSubTypeListeners): {
args: RedisCommandArgument[];
channelsCounter: number;
resolve: () => number;
reject: () => void;
} | undefined;
unsubscribe<T extends boolean>(type: PubSubType, channels?: string | Array<string>, listener?: PubSubListener<T>, returnBuffers?: T): {
args: RedisCommandArgument[];
channelsCounter: number;
resolve: () => void;
reject: undefined;
} | undefined;
reset(): void;
resubscribe(): Array<PubSubCommand>;
handleMessageReply(reply: Array<Buffer>): boolean;
removeShardedListeners(channel: string): ChannelListeners;
getTypeListeners(type: PubSubType): PubSubTypeListeners;
}

View File

@@ -0,0 +1,306 @@
"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _PubSub_instances, _a, _PubSub_channelsArray, _PubSub_listenersSet, _PubSub_subscribing, _PubSub_isActive, _PubSub_listeners, _PubSub_extendChannelListeners, _PubSub_unsubscribeCommand, _PubSub_updateIsActive, _PubSub_emitPubSubMessage;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PubSub = exports.PubSubType = void 0;
var PubSubType;
(function (PubSubType) {
PubSubType["CHANNELS"] = "CHANNELS";
PubSubType["PATTERNS"] = "PATTERNS";
PubSubType["SHARDED"] = "SHARDED";
})(PubSubType || (exports.PubSubType = PubSubType = {}));
const COMMANDS = {
[PubSubType.CHANNELS]: {
subscribe: Buffer.from('subscribe'),
unsubscribe: Buffer.from('unsubscribe'),
message: Buffer.from('message')
},
[PubSubType.PATTERNS]: {
subscribe: Buffer.from('psubscribe'),
unsubscribe: Buffer.from('punsubscribe'),
message: Buffer.from('pmessage')
},
[PubSubType.SHARDED]: {
subscribe: Buffer.from('ssubscribe'),
unsubscribe: Buffer.from('sunsubscribe'),
message: Buffer.from('smessage')
}
};
class PubSub {
constructor() {
_PubSub_instances.add(this);
_PubSub_subscribing.set(this, 0);
_PubSub_isActive.set(this, false);
_PubSub_listeners.set(this, {
[PubSubType.CHANNELS]: new Map(),
[PubSubType.PATTERNS]: new Map(),
[PubSubType.SHARDED]: new Map()
});
}
static isStatusReply(reply) {
return (COMMANDS[PubSubType.CHANNELS].subscribe.equals(reply[0]) ||
COMMANDS[PubSubType.CHANNELS].unsubscribe.equals(reply[0]) ||
COMMANDS[PubSubType.PATTERNS].subscribe.equals(reply[0]) ||
COMMANDS[PubSubType.PATTERNS].unsubscribe.equals(reply[0]) ||
COMMANDS[PubSubType.SHARDED].subscribe.equals(reply[0]));
}
static isShardedUnsubscribe(reply) {
return COMMANDS[PubSubType.SHARDED].unsubscribe.equals(reply[0]);
}
get isActive() {
return __classPrivateFieldGet(this, _PubSub_isActive, "f");
}
subscribe(type, channels, listener, returnBuffers) {
var _b;
const args = [COMMANDS[type].subscribe], channelsArray = __classPrivateFieldGet(_a, _a, "m", _PubSub_channelsArray).call(_a, channels);
for (const channel of channelsArray) {
let channelListeners = __classPrivateFieldGet(this, _PubSub_listeners, "f")[type].get(channel);
if (!channelListeners || channelListeners.unsubscribing) {
args.push(channel);
}
}
if (args.length === 1) {
// all channels are already subscribed, add listeners without issuing a command
for (const channel of channelsArray) {
__classPrivateFieldGet(_a, _a, "m", _PubSub_listenersSet).call(_a, __classPrivateFieldGet(this, _PubSub_listeners, "f")[type].get(channel), returnBuffers).add(listener);
}
return;
}
__classPrivateFieldSet(this, _PubSub_isActive, true, "f");
__classPrivateFieldSet(this, _PubSub_subscribing, (_b = __classPrivateFieldGet(this, _PubSub_subscribing, "f"), _b++, _b), "f");
return {
args,
channelsCounter: args.length - 1,
resolve: () => {
var _b;
__classPrivateFieldSet(this, _PubSub_subscribing, (_b = __classPrivateFieldGet(this, _PubSub_subscribing, "f"), _b--, _b), "f");
for (const channel of channelsArray) {
let listeners = __classPrivateFieldGet(this, _PubSub_listeners, "f")[type].get(channel);
if (!listeners) {
listeners = {
unsubscribing: false,
buffers: new Set(),
strings: new Set()
};
__classPrivateFieldGet(this, _PubSub_listeners, "f")[type].set(channel, listeners);
}
__classPrivateFieldGet(_a, _a, "m", _PubSub_listenersSet).call(_a, listeners, returnBuffers).add(listener);
}
},
reject: () => {
var _b;
__classPrivateFieldSet(this, _PubSub_subscribing, (_b = __classPrivateFieldGet(this, _PubSub_subscribing, "f"), _b--, _b), "f");
__classPrivateFieldGet(this, _PubSub_instances, "m", _PubSub_updateIsActive).call(this);
}
};
}
extendChannelListeners(type, channel, listeners) {
var _b;
if (!__classPrivateFieldGet(this, _PubSub_instances, "m", _PubSub_extendChannelListeners).call(this, type, channel, listeners))
return;
__classPrivateFieldSet(this, _PubSub_isActive, true, "f");
__classPrivateFieldSet(this, _PubSub_subscribing, (_b = __classPrivateFieldGet(this, _PubSub_subscribing, "f"), _b++, _b), "f");
return {
args: [
COMMANDS[type].subscribe,
channel
],
channelsCounter: 1,
resolve: () => { var _b, _c; return __classPrivateFieldSet(this, _PubSub_subscribing, (_c = __classPrivateFieldGet(this, _PubSub_subscribing, "f"), _b = _c--, _c), "f"), _b; },
reject: () => {
var _b;
__classPrivateFieldSet(this, _PubSub_subscribing, (_b = __classPrivateFieldGet(this, _PubSub_subscribing, "f"), _b--, _b), "f");
__classPrivateFieldGet(this, _PubSub_instances, "m", _PubSub_updateIsActive).call(this);
}
};
}
extendTypeListeners(type, listeners) {
var _b;
const args = [COMMANDS[type].subscribe];
for (const [channel, channelListeners] of listeners) {
if (__classPrivateFieldGet(this, _PubSub_instances, "m", _PubSub_extendChannelListeners).call(this, type, channel, channelListeners)) {
args.push(channel);
}
}
if (args.length === 1)
return;
__classPrivateFieldSet(this, _PubSub_isActive, true, "f");
__classPrivateFieldSet(this, _PubSub_subscribing, (_b = __classPrivateFieldGet(this, _PubSub_subscribing, "f"), _b++, _b), "f");
return {
args,
channelsCounter: args.length - 1,
resolve: () => { var _b, _c; return __classPrivateFieldSet(this, _PubSub_subscribing, (_c = __classPrivateFieldGet(this, _PubSub_subscribing, "f"), _b = _c--, _c), "f"), _b; },
reject: () => {
var _b;
__classPrivateFieldSet(this, _PubSub_subscribing, (_b = __classPrivateFieldGet(this, _PubSub_subscribing, "f"), _b--, _b), "f");
__classPrivateFieldGet(this, _PubSub_instances, "m", _PubSub_updateIsActive).call(this);
}
};
}
unsubscribe(type, channels, listener, returnBuffers) {
const listeners = __classPrivateFieldGet(this, _PubSub_listeners, "f")[type];
if (!channels) {
return __classPrivateFieldGet(this, _PubSub_instances, "m", _PubSub_unsubscribeCommand).call(this, [COMMANDS[type].unsubscribe],
// cannot use `this.#subscribed` because there might be some `SUBSCRIBE` commands in the queue
// cannot use `this.#subscribed + this.#subscribing` because some `SUBSCRIBE` commands might fail
NaN, () => listeners.clear());
}
const channelsArray = __classPrivateFieldGet(_a, _a, "m", _PubSub_channelsArray).call(_a, channels);
if (!listener) {
return __classPrivateFieldGet(this, _PubSub_instances, "m", _PubSub_unsubscribeCommand).call(this, [COMMANDS[type].unsubscribe, ...channelsArray], channelsArray.length, () => {
for (const channel of channelsArray) {
listeners.delete(channel);
}
});
}
const args = [COMMANDS[type].unsubscribe];
for (const channel of channelsArray) {
const sets = listeners.get(channel);
if (sets) {
let current, other;
if (returnBuffers) {
current = sets.buffers;
other = sets.strings;
}
else {
current = sets.strings;
other = sets.buffers;
}
const currentSize = current.has(listener) ? current.size - 1 : current.size;
if (currentSize !== 0 || other.size !== 0)
continue;
sets.unsubscribing = true;
}
args.push(channel);
}
if (args.length === 1) {
// all channels has other listeners,
// delete the listeners without issuing a command
for (const channel of channelsArray) {
__classPrivateFieldGet(_a, _a, "m", _PubSub_listenersSet).call(_a, listeners.get(channel), returnBuffers).delete(listener);
}
return;
}
return __classPrivateFieldGet(this, _PubSub_instances, "m", _PubSub_unsubscribeCommand).call(this, args, args.length - 1, () => {
for (const channel of channelsArray) {
const sets = listeners.get(channel);
if (!sets)
continue;
(returnBuffers ? sets.buffers : sets.strings).delete(listener);
if (sets.buffers.size === 0 && sets.strings.size === 0) {
listeners.delete(channel);
}
}
});
}
reset() {
__classPrivateFieldSet(this, _PubSub_isActive, false, "f");
__classPrivateFieldSet(this, _PubSub_subscribing, 0, "f");
}
resubscribe() {
var _b;
const commands = [];
for (const [type, listeners] of Object.entries(__classPrivateFieldGet(this, _PubSub_listeners, "f"))) {
if (!listeners.size)
continue;
__classPrivateFieldSet(this, _PubSub_isActive, true, "f");
__classPrivateFieldSet(this, _PubSub_subscribing, (_b = __classPrivateFieldGet(this, _PubSub_subscribing, "f"), _b++, _b), "f");
const callback = () => { var _b, _c; return __classPrivateFieldSet(this, _PubSub_subscribing, (_c = __classPrivateFieldGet(this, _PubSub_subscribing, "f"), _b = _c--, _c), "f"), _b; };
commands.push({
args: [
COMMANDS[type].subscribe,
...listeners.keys()
],
channelsCounter: listeners.size,
resolve: callback,
reject: callback
});
}
return commands;
}
handleMessageReply(reply) {
if (COMMANDS[PubSubType.CHANNELS].message.equals(reply[0])) {
__classPrivateFieldGet(this, _PubSub_instances, "m", _PubSub_emitPubSubMessage).call(this, PubSubType.CHANNELS, reply[2], reply[1]);
return true;
}
else if (COMMANDS[PubSubType.PATTERNS].message.equals(reply[0])) {
__classPrivateFieldGet(this, _PubSub_instances, "m", _PubSub_emitPubSubMessage).call(this, PubSubType.PATTERNS, reply[3], reply[2], reply[1]);
return true;
}
else if (COMMANDS[PubSubType.SHARDED].message.equals(reply[0])) {
__classPrivateFieldGet(this, _PubSub_instances, "m", _PubSub_emitPubSubMessage).call(this, PubSubType.SHARDED, reply[2], reply[1]);
return true;
}
return false;
}
removeShardedListeners(channel) {
const listeners = __classPrivateFieldGet(this, _PubSub_listeners, "f")[PubSubType.SHARDED].get(channel);
__classPrivateFieldGet(this, _PubSub_listeners, "f")[PubSubType.SHARDED].delete(channel);
__classPrivateFieldGet(this, _PubSub_instances, "m", _PubSub_updateIsActive).call(this);
return listeners;
}
getTypeListeners(type) {
return __classPrivateFieldGet(this, _PubSub_listeners, "f")[type];
}
}
exports.PubSub = PubSub;
_a = PubSub, _PubSub_subscribing = new WeakMap(), _PubSub_isActive = new WeakMap(), _PubSub_listeners = new WeakMap(), _PubSub_instances = new WeakSet(), _PubSub_channelsArray = function _PubSub_channelsArray(channels) {
return (Array.isArray(channels) ? channels : [channels]);
}, _PubSub_listenersSet = function _PubSub_listenersSet(listeners, returnBuffers) {
return (returnBuffers ? listeners.buffers : listeners.strings);
}, _PubSub_extendChannelListeners = function _PubSub_extendChannelListeners(type, channel, listeners) {
const existingListeners = __classPrivateFieldGet(this, _PubSub_listeners, "f")[type].get(channel);
if (!existingListeners) {
__classPrivateFieldGet(this, _PubSub_listeners, "f")[type].set(channel, listeners);
return true;
}
for (const listener of listeners.buffers) {
existingListeners.buffers.add(listener);
}
for (const listener of listeners.strings) {
existingListeners.strings.add(listener);
}
return false;
}, _PubSub_unsubscribeCommand = function _PubSub_unsubscribeCommand(args, channelsCounter, removeListeners) {
return {
args,
channelsCounter,
resolve: () => {
removeListeners();
__classPrivateFieldGet(this, _PubSub_instances, "m", _PubSub_updateIsActive).call(this);
},
reject: undefined // use the same structure as `subscribe`
};
}, _PubSub_updateIsActive = function _PubSub_updateIsActive() {
__classPrivateFieldSet(this, _PubSub_isActive, (__classPrivateFieldGet(this, _PubSub_listeners, "f")[PubSubType.CHANNELS].size !== 0 ||
__classPrivateFieldGet(this, _PubSub_listeners, "f")[PubSubType.PATTERNS].size !== 0 ||
__classPrivateFieldGet(this, _PubSub_listeners, "f")[PubSubType.SHARDED].size !== 0 ||
__classPrivateFieldGet(this, _PubSub_subscribing, "f") !== 0), "f");
}, _PubSub_emitPubSubMessage = function _PubSub_emitPubSubMessage(type, message, channel, pattern) {
const keyString = (pattern ?? channel).toString(), listeners = __classPrivateFieldGet(this, _PubSub_listeners, "f")[type].get(keyString);
if (!listeners)
return;
for (const listener of listeners.buffers) {
listener(message, channel);
}
if (!listeners.strings.size)
return;
const channelString = pattern ? channel.toString() : keyString, messageString = channelString === '__redis__:invalidate' ?
// https://github.com/redis/redis/pull/7469
// https://github.com/redis/redis/issues/7463
(message === null ? null : message.map(x => x.toString())) :
message.toString();
for (const listener of listeners.strings) {
listener(messageString, channelString);
}
};

View File

@@ -0,0 +1,52 @@
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import { EventEmitter } from 'events';
import * as net from 'net';
import * as tls from 'tls';
import { RedisCommandArguments } from '../commands';
export interface RedisSocketCommonOptions {
/**
* Connection Timeout (in milliseconds)
*/
connectTimeout?: number;
/**
* Toggle [`Nagle's algorithm`](https://nodejs.org/api/net.html#net_socket_setnodelay_nodelay)
*/
noDelay?: boolean;
/**
* Toggle [`keep-alive`](https://nodejs.org/api/net.html#net_socket_setkeepalive_enable_initialdelay)
*/
keepAlive?: number | false;
/**
* When the socket closes unexpectedly (without calling `.quit()`/`.disconnect()`), the client uses `reconnectStrategy` to decide what to do. The following values are supported:
* 1. `false` -> do not reconnect, close the client and flush the command queue.
* 2. `number` -> wait for `X` milliseconds before reconnecting.
* 3. `(retries: number, cause: Error) => false | number | Error` -> `number` is the same as configuring a `number` directly, `Error` is the same as `false`, but with a custom error.
* Defaults to `retries => Math.min(retries * 50, 500)`
*/
reconnectStrategy?: false | number | ((retries: number, cause: Error) => false | Error | number);
}
type RedisNetSocketOptions = Partial<net.SocketConnectOpts> & {
tls?: false;
};
export interface RedisTlsSocketOptions extends tls.ConnectionOptions {
tls: true;
}
export type RedisSocketOptions = RedisSocketCommonOptions & (RedisNetSocketOptions | RedisTlsSocketOptions);
export type RedisSocketInitiator = () => Promise<void>;
export default class RedisSocket extends EventEmitter {
#private;
get isOpen(): boolean;
get isReady(): boolean;
get writableNeedDrain(): boolean;
constructor(initiator: RedisSocketInitiator, options?: RedisSocketOptions);
connect(): Promise<void>;
writeCommand(args: RedisCommandArguments): void;
disconnect(): void;
quit<T>(fn: () => Promise<T>): Promise<T>;
cork(): void;
ref(): void;
unref(): void;
}
export {};

View File

@@ -0,0 +1,233 @@
"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _RedisSocket_instances, _a, _RedisSocket_initiateOptions, _RedisSocket_isTlsSocket, _RedisSocket_initiator, _RedisSocket_options, _RedisSocket_socket, _RedisSocket_isOpen, _RedisSocket_isReady, _RedisSocket_writableNeedDrain, _RedisSocket_isSocketUnrefed, _RedisSocket_reconnectStrategy, _RedisSocket_shouldReconnect, _RedisSocket_connect, _RedisSocket_createSocket, _RedisSocket_createNetSocket, _RedisSocket_createTlsSocket, _RedisSocket_onSocketError, _RedisSocket_disconnect, _RedisSocket_isCorked;
Object.defineProperty(exports, "__esModule", { value: true });
const events_1 = require("events");
const net = require("net");
const tls = require("tls");
const errors_1 = require("../errors");
const utils_1 = require("../utils");
class RedisSocket extends events_1.EventEmitter {
get isOpen() {
return __classPrivateFieldGet(this, _RedisSocket_isOpen, "f");
}
get isReady() {
return __classPrivateFieldGet(this, _RedisSocket_isReady, "f");
}
get writableNeedDrain() {
return __classPrivateFieldGet(this, _RedisSocket_writableNeedDrain, "f");
}
constructor(initiator, options) {
super();
_RedisSocket_instances.add(this);
_RedisSocket_initiator.set(this, void 0);
_RedisSocket_options.set(this, void 0);
_RedisSocket_socket.set(this, void 0);
_RedisSocket_isOpen.set(this, false);
_RedisSocket_isReady.set(this, false);
// `writable.writableNeedDrain` was added in v15.2.0 and therefore can't be used
// https://nodejs.org/api/stream.html#stream_writable_writableneeddrain
_RedisSocket_writableNeedDrain.set(this, false);
_RedisSocket_isSocketUnrefed.set(this, false);
_RedisSocket_isCorked.set(this, false);
__classPrivateFieldSet(this, _RedisSocket_initiator, initiator, "f");
__classPrivateFieldSet(this, _RedisSocket_options, __classPrivateFieldGet(_a, _a, "m", _RedisSocket_initiateOptions).call(_a, options), "f");
}
async connect() {
if (__classPrivateFieldGet(this, _RedisSocket_isOpen, "f")) {
throw new Error('Socket already opened');
}
__classPrivateFieldSet(this, _RedisSocket_isOpen, true, "f");
return __classPrivateFieldGet(this, _RedisSocket_instances, "m", _RedisSocket_connect).call(this);
}
writeCommand(args) {
if (!__classPrivateFieldGet(this, _RedisSocket_socket, "f")) {
throw new errors_1.ClientClosedError();
}
for (const toWrite of args) {
__classPrivateFieldSet(this, _RedisSocket_writableNeedDrain, !__classPrivateFieldGet(this, _RedisSocket_socket, "f").write(toWrite), "f");
}
}
disconnect() {
if (!__classPrivateFieldGet(this, _RedisSocket_isOpen, "f")) {
throw new errors_1.ClientClosedError();
}
__classPrivateFieldSet(this, _RedisSocket_isOpen, false, "f");
__classPrivateFieldGet(this, _RedisSocket_instances, "m", _RedisSocket_disconnect).call(this);
}
async quit(fn) {
if (!__classPrivateFieldGet(this, _RedisSocket_isOpen, "f")) {
throw new errors_1.ClientClosedError();
}
__classPrivateFieldSet(this, _RedisSocket_isOpen, false, "f");
const reply = await fn();
__classPrivateFieldGet(this, _RedisSocket_instances, "m", _RedisSocket_disconnect).call(this);
return reply;
}
cork() {
if (!__classPrivateFieldGet(this, _RedisSocket_socket, "f") || __classPrivateFieldGet(this, _RedisSocket_isCorked, "f")) {
return;
}
__classPrivateFieldGet(this, _RedisSocket_socket, "f").cork();
__classPrivateFieldSet(this, _RedisSocket_isCorked, true, "f");
setImmediate(() => {
__classPrivateFieldGet(this, _RedisSocket_socket, "f")?.uncork();
__classPrivateFieldSet(this, _RedisSocket_isCorked, false, "f");
});
}
ref() {
__classPrivateFieldSet(this, _RedisSocket_isSocketUnrefed, false, "f");
__classPrivateFieldGet(this, _RedisSocket_socket, "f")?.ref();
}
unref() {
__classPrivateFieldSet(this, _RedisSocket_isSocketUnrefed, true, "f");
__classPrivateFieldGet(this, _RedisSocket_socket, "f")?.unref();
}
}
_a = RedisSocket, _RedisSocket_initiator = new WeakMap(), _RedisSocket_options = new WeakMap(), _RedisSocket_socket = new WeakMap(), _RedisSocket_isOpen = new WeakMap(), _RedisSocket_isReady = new WeakMap(), _RedisSocket_writableNeedDrain = new WeakMap(), _RedisSocket_isSocketUnrefed = new WeakMap(), _RedisSocket_isCorked = new WeakMap(), _RedisSocket_instances = new WeakSet(), _RedisSocket_initiateOptions = function _RedisSocket_initiateOptions(options) {
var _b, _c;
options ?? (options = {});
if (!options.path) {
(_b = options).port ?? (_b.port = 6379);
(_c = options).host ?? (_c.host = 'localhost');
}
options.connectTimeout ?? (options.connectTimeout = 5000);
options.keepAlive ?? (options.keepAlive = 5000);
options.noDelay ?? (options.noDelay = true);
return options;
}, _RedisSocket_isTlsSocket = function _RedisSocket_isTlsSocket(options) {
return options.tls === true;
}, _RedisSocket_reconnectStrategy = function _RedisSocket_reconnectStrategy(retries, cause) {
if (__classPrivateFieldGet(this, _RedisSocket_options, "f").reconnectStrategy === false) {
return false;
}
else if (typeof __classPrivateFieldGet(this, _RedisSocket_options, "f").reconnectStrategy === 'number') {
return __classPrivateFieldGet(this, _RedisSocket_options, "f").reconnectStrategy;
}
else if (__classPrivateFieldGet(this, _RedisSocket_options, "f").reconnectStrategy) {
try {
const retryIn = __classPrivateFieldGet(this, _RedisSocket_options, "f").reconnectStrategy(retries, cause);
if (retryIn !== false && !(retryIn instanceof Error) && typeof retryIn !== 'number') {
throw new TypeError(`Reconnect strategy should return \`false | Error | number\`, got ${retryIn} instead`);
}
return retryIn;
}
catch (err) {
this.emit('error', err);
}
}
return Math.min(retries * 50, 500);
}, _RedisSocket_shouldReconnect = function _RedisSocket_shouldReconnect(retries, cause) {
const retryIn = __classPrivateFieldGet(this, _RedisSocket_instances, "m", _RedisSocket_reconnectStrategy).call(this, retries, cause);
if (retryIn === false) {
__classPrivateFieldSet(this, _RedisSocket_isOpen, false, "f");
this.emit('error', cause);
return cause;
}
else if (retryIn instanceof Error) {
__classPrivateFieldSet(this, _RedisSocket_isOpen, false, "f");
this.emit('error', cause);
return new errors_1.ReconnectStrategyError(retryIn, cause);
}
return retryIn;
}, _RedisSocket_connect = async function _RedisSocket_connect() {
let retries = 0;
do {
try {
__classPrivateFieldSet(this, _RedisSocket_socket, await __classPrivateFieldGet(this, _RedisSocket_instances, "m", _RedisSocket_createSocket).call(this), "f");
__classPrivateFieldSet(this, _RedisSocket_writableNeedDrain, false, "f");
this.emit('connect');
try {
await __classPrivateFieldGet(this, _RedisSocket_initiator, "f").call(this);
}
catch (err) {
__classPrivateFieldGet(this, _RedisSocket_socket, "f").destroy();
__classPrivateFieldSet(this, _RedisSocket_socket, undefined, "f");
throw err;
}
__classPrivateFieldSet(this, _RedisSocket_isReady, true, "f");
this.emit('ready');
}
catch (err) {
const retryIn = __classPrivateFieldGet(this, _RedisSocket_instances, "m", _RedisSocket_shouldReconnect).call(this, retries++, err);
if (typeof retryIn !== 'number') {
throw retryIn;
}
this.emit('error', err);
await (0, utils_1.promiseTimeout)(retryIn);
this.emit('reconnecting');
}
} while (__classPrivateFieldGet(this, _RedisSocket_isOpen, "f") && !__classPrivateFieldGet(this, _RedisSocket_isReady, "f"));
}, _RedisSocket_createSocket = function _RedisSocket_createSocket() {
return new Promise((resolve, reject) => {
const { connectEvent, socket } = __classPrivateFieldGet(_a, _a, "m", _RedisSocket_isTlsSocket).call(_a, __classPrivateFieldGet(this, _RedisSocket_options, "f")) ?
__classPrivateFieldGet(this, _RedisSocket_instances, "m", _RedisSocket_createTlsSocket).call(this) :
__classPrivateFieldGet(this, _RedisSocket_instances, "m", _RedisSocket_createNetSocket).call(this);
if (__classPrivateFieldGet(this, _RedisSocket_options, "f").connectTimeout) {
socket.setTimeout(__classPrivateFieldGet(this, _RedisSocket_options, "f").connectTimeout, () => socket.destroy(new errors_1.ConnectionTimeoutError()));
}
if (__classPrivateFieldGet(this, _RedisSocket_isSocketUnrefed, "f")) {
socket.unref();
}
socket
.setNoDelay(__classPrivateFieldGet(this, _RedisSocket_options, "f").noDelay)
.once('error', reject)
.once(connectEvent, () => {
socket
.setTimeout(0)
// https://github.com/nodejs/node/issues/31663
.setKeepAlive(__classPrivateFieldGet(this, _RedisSocket_options, "f").keepAlive !== false, __classPrivateFieldGet(this, _RedisSocket_options, "f").keepAlive || 0)
.off('error', reject)
.once('error', (err) => __classPrivateFieldGet(this, _RedisSocket_instances, "m", _RedisSocket_onSocketError).call(this, err))
.once('close', hadError => {
if (!hadError && __classPrivateFieldGet(this, _RedisSocket_isOpen, "f") && __classPrivateFieldGet(this, _RedisSocket_socket, "f") === socket) {
__classPrivateFieldGet(this, _RedisSocket_instances, "m", _RedisSocket_onSocketError).call(this, new errors_1.SocketClosedUnexpectedlyError());
}
})
.on('drain', () => {
__classPrivateFieldSet(this, _RedisSocket_writableNeedDrain, false, "f");
this.emit('drain');
})
.on('data', data => this.emit('data', data));
resolve(socket);
});
});
}, _RedisSocket_createNetSocket = function _RedisSocket_createNetSocket() {
return {
connectEvent: 'connect',
socket: net.connect(__classPrivateFieldGet(this, _RedisSocket_options, "f")) // TODO
};
}, _RedisSocket_createTlsSocket = function _RedisSocket_createTlsSocket() {
return {
connectEvent: 'secureConnect',
socket: tls.connect(__classPrivateFieldGet(this, _RedisSocket_options, "f")) // TODO
};
}, _RedisSocket_onSocketError = function _RedisSocket_onSocketError(err) {
const wasReady = __classPrivateFieldGet(this, _RedisSocket_isReady, "f");
__classPrivateFieldSet(this, _RedisSocket_isReady, false, "f");
this.emit('error', err);
if (!wasReady || !__classPrivateFieldGet(this, _RedisSocket_isOpen, "f") || typeof __classPrivateFieldGet(this, _RedisSocket_instances, "m", _RedisSocket_shouldReconnect).call(this, 0, err) !== 'number')
return;
this.emit('reconnecting');
__classPrivateFieldGet(this, _RedisSocket_instances, "m", _RedisSocket_connect).call(this).catch(() => {
// the error was already emitted, silently ignore it
});
}, _RedisSocket_disconnect = function _RedisSocket_disconnect() {
__classPrivateFieldSet(this, _RedisSocket_isReady, false, "f");
if (__classPrivateFieldGet(this, _RedisSocket_socket, "f")) {
__classPrivateFieldGet(this, _RedisSocket_socket, "f").destroy();
__classPrivateFieldSet(this, _RedisSocket_socket, undefined, "f");
}
this.emit('end');
};
exports.default = RedisSocket;

View File

@@ -0,0 +1,60 @@
/// <reference types="node" />
import { RedisClientType } from '../client';
import { RedisClusterOptions } from '.';
import { RedisCommandArgument, RedisFunctions, RedisModules, RedisScripts } from '../commands';
import { ChannelListeners } from '../client/pub-sub';
import { EventEmitter } from 'stream';
interface NodeAddress {
host: string;
port: number;
}
export type NodeAddressMap = {
[address: string]: NodeAddress;
} | ((address: string) => NodeAddress | undefined);
type ValueOrPromise<T> = T | Promise<T>;
type ClientOrPromise<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> = ValueOrPromise<RedisClientType<M, F, S>>;
export interface Node<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> {
address: string;
client?: ClientOrPromise<M, F, S>;
}
export interface ShardNode<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> extends Node<M, F, S> {
id: string;
host: string;
port: number;
readonly: boolean;
}
export interface MasterNode<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> extends ShardNode<M, F, S> {
pubSubClient?: ClientOrPromise<M, F, S>;
}
export interface Shard<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> {
master: MasterNode<M, F, S>;
replicas?: Array<ShardNode<M, F, S>>;
nodesIterator?: IterableIterator<ShardNode<M, F, S>>;
}
export type PubSubNode<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> = Required<Node<M, F, S>>;
export type OnShardedChannelMovedError = (err: unknown, channel: string, listeners?: ChannelListeners) => void;
export default class RedisClusterSlots<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> {
#private;
slots: Shard<M, F, S>[];
shards: Shard<M, F, S>[];
masters: ShardNode<M, F, S>[];
replicas: ShardNode<M, F, S>[];
readonly nodeByAddress: Map<string, ShardNode<M, F, S> | MasterNode<M, F, S>>;
pubSubNode?: PubSubNode<M, F, S>;
get isOpen(): boolean;
constructor(options: RedisClusterOptions<M, F, S>, emit: EventEmitter['emit']);
connect(): Promise<void>;
nodeClient(node: ShardNode<M, F, S>): ClientOrPromise<M, F, S>;
rediscover(startWith: RedisClientType<M, F, S>): Promise<void>;
quit(): Promise<void>;
disconnect(): Promise<void>;
getClient(firstKey: RedisCommandArgument | undefined, isReadonly: boolean | undefined): ClientOrPromise<M, F, S>;
getRandomNode(): ShardNode<M, F, S>;
getSlotRandomNode(slotNumber: number): ShardNode<M, F, S>;
getMasterByAddress(address: string): ClientOrPromise<M, F, S> | undefined;
getPubSubClient(): ClientOrPromise<M, F, S>;
executeUnsubscribeCommand(unsubscribe: (client: RedisClientType<M, F, S>) => Promise<void>): Promise<void>;
getShardedPubSubClient(channel: string): ClientOrPromise<M, F, S>;
executeShardedUnsubscribeCommand(channel: string, unsubscribe: (client: RedisClientType<M, F, S>) => Promise<void>): Promise<void>;
}
export {};

View File

@@ -0,0 +1,434 @@
"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _RedisClusterSlots_instances, _a, _RedisClusterSlots_SLOTS, _RedisClusterSlots_options, _RedisClusterSlots_Client, _RedisClusterSlots_emit, _RedisClusterSlots_isOpen, _RedisClusterSlots_discoverWithRootNodes, _RedisClusterSlots_resetSlots, _RedisClusterSlots_discover, _RedisClusterSlots_getShards, _RedisClusterSlots_getNodeAddress, _RedisClusterSlots_clientOptionsDefaults, _RedisClusterSlots_initiateSlotNode, _RedisClusterSlots_createClient, _RedisClusterSlots_createNodeClient, _RedisClusterSlots_runningRediscoverPromise, _RedisClusterSlots_rediscover, _RedisClusterSlots_destroy, _RedisClusterSlots_execOnNodeClient, _RedisClusterSlots_iterateAllNodes, _RedisClusterSlots_randomNodeIterator, _RedisClusterSlots_slotNodesIterator, _RedisClusterSlots_initiatePubSubClient, _RedisClusterSlots_initiateShardedPubSubClient;
Object.defineProperty(exports, "__esModule", { value: true });
const client_1 = require("../client");
const errors_1 = require("../errors");
const util_1 = require("util");
const pub_sub_1 = require("../client/pub-sub");
// We need to use 'require', because it's not possible with Typescript to import
// function that are exported as 'module.exports = function`, without esModuleInterop
// set to true.
const calculateSlot = require('cluster-key-slot');
class RedisClusterSlots {
get isOpen() {
return __classPrivateFieldGet(this, _RedisClusterSlots_isOpen, "f");
}
constructor(options, emit) {
_RedisClusterSlots_instances.add(this);
_RedisClusterSlots_options.set(this, void 0);
_RedisClusterSlots_Client.set(this, void 0);
_RedisClusterSlots_emit.set(this, void 0);
Object.defineProperty(this, "slots", {
enumerable: true,
configurable: true,
writable: true,
value: new Array(__classPrivateFieldGet(_a, _a, "f", _RedisClusterSlots_SLOTS))
});
Object.defineProperty(this, "shards", {
enumerable: true,
configurable: true,
writable: true,
value: new Array()
});
Object.defineProperty(this, "masters", {
enumerable: true,
configurable: true,
writable: true,
value: new Array()
});
Object.defineProperty(this, "replicas", {
enumerable: true,
configurable: true,
writable: true,
value: new Array()
});
Object.defineProperty(this, "nodeByAddress", {
enumerable: true,
configurable: true,
writable: true,
value: new Map()
});
Object.defineProperty(this, "pubSubNode", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
_RedisClusterSlots_isOpen.set(this, false);
_RedisClusterSlots_runningRediscoverPromise.set(this, void 0);
_RedisClusterSlots_randomNodeIterator.set(this, void 0);
__classPrivateFieldSet(this, _RedisClusterSlots_options, options, "f");
__classPrivateFieldSet(this, _RedisClusterSlots_Client, client_1.default.extend(options), "f");
__classPrivateFieldSet(this, _RedisClusterSlots_emit, emit, "f");
}
async connect() {
if (__classPrivateFieldGet(this, _RedisClusterSlots_isOpen, "f")) {
throw new Error('Cluster already open');
}
__classPrivateFieldSet(this, _RedisClusterSlots_isOpen, true, "f");
try {
await __classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_discoverWithRootNodes).call(this);
}
catch (err) {
__classPrivateFieldSet(this, _RedisClusterSlots_isOpen, false, "f");
throw err;
}
}
nodeClient(node) {
return node.client ?? __classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_createNodeClient).call(this, node);
}
async rediscover(startWith) {
__classPrivateFieldSet(this, _RedisClusterSlots_runningRediscoverPromise, __classPrivateFieldGet(this, _RedisClusterSlots_runningRediscoverPromise, "f") ?? __classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_rediscover).call(this, startWith)
.finally(() => __classPrivateFieldSet(this, _RedisClusterSlots_runningRediscoverPromise, undefined, "f")), "f");
return __classPrivateFieldGet(this, _RedisClusterSlots_runningRediscoverPromise, "f");
}
quit() {
return __classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_destroy).call(this, client => client.quit());
}
disconnect() {
return __classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_destroy).call(this, client => client.disconnect());
}
getClient(firstKey, isReadonly) {
if (!firstKey) {
return this.nodeClient(this.getRandomNode());
}
const slotNumber = calculateSlot(firstKey);
if (!isReadonly) {
return this.nodeClient(this.slots[slotNumber].master);
}
return this.nodeClient(this.getSlotRandomNode(slotNumber));
}
getRandomNode() {
__classPrivateFieldSet(this, _RedisClusterSlots_randomNodeIterator, __classPrivateFieldGet(this, _RedisClusterSlots_randomNodeIterator, "f") ?? __classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_iterateAllNodes).call(this), "f");
return __classPrivateFieldGet(this, _RedisClusterSlots_randomNodeIterator, "f").next().value;
}
getSlotRandomNode(slotNumber) {
const slot = this.slots[slotNumber];
if (!slot.replicas?.length) {
return slot.master;
}
slot.nodesIterator ?? (slot.nodesIterator = __classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_slotNodesIterator).call(this, slot));
return slot.nodesIterator.next().value;
}
getMasterByAddress(address) {
const master = this.nodeByAddress.get(address);
if (!master)
return;
return this.nodeClient(master);
}
getPubSubClient() {
return this.pubSubNode ?
this.pubSubNode.client :
__classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_initiatePubSubClient).call(this);
}
async executeUnsubscribeCommand(unsubscribe) {
const client = await this.getPubSubClient();
await unsubscribe(client);
if (!client.isPubSubActive && client.isOpen) {
await client.disconnect();
this.pubSubNode = undefined;
}
}
getShardedPubSubClient(channel) {
const { master } = this.slots[calculateSlot(channel)];
return master.pubSubClient ?? __classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_initiateShardedPubSubClient).call(this, master);
}
async executeShardedUnsubscribeCommand(channel, unsubscribe) {
const { master } = this.slots[calculateSlot(channel)];
if (!master.pubSubClient)
return Promise.resolve();
const client = await master.pubSubClient;
await unsubscribe(client);
if (!client.isPubSubActive && client.isOpen) {
await client.disconnect();
master.pubSubClient = undefined;
}
}
}
_a = RedisClusterSlots, _RedisClusterSlots_options = new WeakMap(), _RedisClusterSlots_Client = new WeakMap(), _RedisClusterSlots_emit = new WeakMap(), _RedisClusterSlots_isOpen = new WeakMap(), _RedisClusterSlots_runningRediscoverPromise = new WeakMap(), _RedisClusterSlots_randomNodeIterator = new WeakMap(), _RedisClusterSlots_instances = new WeakSet(), _RedisClusterSlots_discoverWithRootNodes = async function _RedisClusterSlots_discoverWithRootNodes() {
let start = Math.floor(Math.random() * __classPrivateFieldGet(this, _RedisClusterSlots_options, "f").rootNodes.length);
for (let i = start; i < __classPrivateFieldGet(this, _RedisClusterSlots_options, "f").rootNodes.length; i++) {
if (await __classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_discover).call(this, __classPrivateFieldGet(this, _RedisClusterSlots_options, "f").rootNodes[i]))
return;
}
for (let i = 0; i < start; i++) {
if (await __classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_discover).call(this, __classPrivateFieldGet(this, _RedisClusterSlots_options, "f").rootNodes[i]))
return;
}
throw new errors_1.RootNodesUnavailableError();
}, _RedisClusterSlots_resetSlots = function _RedisClusterSlots_resetSlots() {
this.slots = new Array(__classPrivateFieldGet(_a, _a, "f", _RedisClusterSlots_SLOTS));
this.shards = [];
this.masters = [];
this.replicas = [];
__classPrivateFieldSet(this, _RedisClusterSlots_randomNodeIterator, undefined, "f");
}, _RedisClusterSlots_discover = async function _RedisClusterSlots_discover(rootNode) {
const addressesInUse = new Set();
try {
const shards = await __classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_getShards).call(this, rootNode), promises = [], eagerConnect = __classPrivateFieldGet(this, _RedisClusterSlots_options, "f").minimizeConnections !== true;
__classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_resetSlots).call(this);
for (const { from, to, master, replicas } of shards) {
const shard = {
master: __classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_initiateSlotNode).call(this, master, false, eagerConnect, addressesInUse, promises)
};
if (__classPrivateFieldGet(this, _RedisClusterSlots_options, "f").useReplicas) {
shard.replicas = replicas.map(replica => __classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_initiateSlotNode).call(this, replica, true, eagerConnect, addressesInUse, promises));
}
this.shards.push(shard);
for (let i = from; i <= to; i++) {
this.slots[i] = shard;
}
}
if (this.pubSubNode && !addressesInUse.has(this.pubSubNode.address)) {
if (util_1.types.isPromise(this.pubSubNode.client)) {
promises.push(this.pubSubNode.client.then(client => client.disconnect()));
this.pubSubNode = undefined;
}
else {
promises.push(this.pubSubNode.client.disconnect());
const channelsListeners = this.pubSubNode.client.getPubSubListeners(pub_sub_1.PubSubType.CHANNELS), patternsListeners = this.pubSubNode.client.getPubSubListeners(pub_sub_1.PubSubType.PATTERNS);
if (channelsListeners.size || patternsListeners.size) {
promises.push(__classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_initiatePubSubClient).call(this, {
[pub_sub_1.PubSubType.CHANNELS]: channelsListeners,
[pub_sub_1.PubSubType.PATTERNS]: patternsListeners
}));
}
}
}
for (const [address, node] of this.nodeByAddress.entries()) {
if (addressesInUse.has(address))
continue;
if (node.client) {
promises.push(__classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_execOnNodeClient).call(this, node.client, client => client.disconnect()));
}
const { pubSubClient } = node;
if (pubSubClient) {
promises.push(__classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_execOnNodeClient).call(this, pubSubClient, client => client.disconnect()));
}
this.nodeByAddress.delete(address);
}
await Promise.all(promises);
return true;
}
catch (err) {
__classPrivateFieldGet(this, _RedisClusterSlots_emit, "f").call(this, 'error', err);
return false;
}
}, _RedisClusterSlots_getShards = async function _RedisClusterSlots_getShards(rootNode) {
const client = new (__classPrivateFieldGet(this, _RedisClusterSlots_Client, "f"))(__classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_clientOptionsDefaults).call(this, rootNode, true));
client.on('error', err => __classPrivateFieldGet(this, _RedisClusterSlots_emit, "f").call(this, 'error', err));
await client.connect();
try {
// using `CLUSTER SLOTS` and not `CLUSTER SHARDS` to support older versions
return await client.clusterSlots();
}
finally {
await client.disconnect();
}
}, _RedisClusterSlots_getNodeAddress = function _RedisClusterSlots_getNodeAddress(address) {
switch (typeof __classPrivateFieldGet(this, _RedisClusterSlots_options, "f").nodeAddressMap) {
case 'object':
return __classPrivateFieldGet(this, _RedisClusterSlots_options, "f").nodeAddressMap[address];
case 'function':
return __classPrivateFieldGet(this, _RedisClusterSlots_options, "f").nodeAddressMap(address);
}
}, _RedisClusterSlots_clientOptionsDefaults = function _RedisClusterSlots_clientOptionsDefaults(options, disableReconnect) {
let result;
if (__classPrivateFieldGet(this, _RedisClusterSlots_options, "f").defaults) {
let socket;
if (__classPrivateFieldGet(this, _RedisClusterSlots_options, "f").defaults.socket) {
socket = {
...__classPrivateFieldGet(this, _RedisClusterSlots_options, "f").defaults.socket,
...options?.socket
};
}
else {
socket = options?.socket;
}
result = {
...__classPrivateFieldGet(this, _RedisClusterSlots_options, "f").defaults,
...options,
socket
};
}
else {
result = options;
}
if (disableReconnect) {
result ?? (result = {});
result.socket ?? (result.socket = {});
result.socket.reconnectStrategy = false;
}
return result;
}, _RedisClusterSlots_initiateSlotNode = function _RedisClusterSlots_initiateSlotNode({ id, ip, port }, readonly, eagerConnent, addressesInUse, promises) {
const address = `${ip}:${port}`;
addressesInUse.add(address);
let node = this.nodeByAddress.get(address);
if (!node) {
node = {
id,
host: ip,
port,
address,
readonly,
client: undefined
};
if (eagerConnent) {
promises.push(__classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_createNodeClient).call(this, node));
}
this.nodeByAddress.set(address, node);
}
(readonly ? this.replicas : this.masters).push(node);
return node;
}, _RedisClusterSlots_createClient = async function _RedisClusterSlots_createClient(node, readonly = node.readonly) {
const client = new (__classPrivateFieldGet(this, _RedisClusterSlots_Client, "f"))(__classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_clientOptionsDefaults).call(this, {
socket: __classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_getNodeAddress).call(this, node.address) ?? {
host: node.host,
port: node.port
},
readonly
}));
client.on('error', err => __classPrivateFieldGet(this, _RedisClusterSlots_emit, "f").call(this, 'error', err));
await client.connect();
return client;
}, _RedisClusterSlots_createNodeClient = function _RedisClusterSlots_createNodeClient(node) {
const promise = __classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_createClient).call(this, node)
.then(client => {
node.client = client;
return client;
})
.catch(err => {
node.client = undefined;
throw err;
});
node.client = promise;
return promise;
}, _RedisClusterSlots_rediscover = async function _RedisClusterSlots_rediscover(startWith) {
if (await __classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_discover).call(this, startWith.options))
return;
return __classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_discoverWithRootNodes).call(this);
}, _RedisClusterSlots_destroy = async function _RedisClusterSlots_destroy(fn) {
__classPrivateFieldSet(this, _RedisClusterSlots_isOpen, false, "f");
const promises = [];
for (const { master, replicas } of this.shards) {
if (master.client) {
promises.push(__classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_execOnNodeClient).call(this, master.client, fn));
}
if (master.pubSubClient) {
promises.push(__classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_execOnNodeClient).call(this, master.pubSubClient, fn));
}
if (replicas) {
for (const { client } of replicas) {
if (client) {
promises.push(__classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_execOnNodeClient).call(this, client, fn));
}
}
}
}
if (this.pubSubNode) {
promises.push(__classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_execOnNodeClient).call(this, this.pubSubNode.client, fn));
this.pubSubNode = undefined;
}
__classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_resetSlots).call(this);
this.nodeByAddress.clear();
await Promise.allSettled(promises);
}, _RedisClusterSlots_execOnNodeClient = function _RedisClusterSlots_execOnNodeClient(client, fn) {
return util_1.types.isPromise(client) ?
client.then(fn) :
fn(client);
}, _RedisClusterSlots_iterateAllNodes = function* _RedisClusterSlots_iterateAllNodes() {
let i = Math.floor(Math.random() * (this.masters.length + this.replicas.length));
if (i < this.masters.length) {
do {
yield this.masters[i];
} while (++i < this.masters.length);
for (const replica of this.replicas) {
yield replica;
}
}
else {
i -= this.masters.length;
do {
yield this.replicas[i];
} while (++i < this.replicas.length);
}
while (true) {
for (const master of this.masters) {
yield master;
}
for (const replica of this.replicas) {
yield replica;
}
}
}, _RedisClusterSlots_slotNodesIterator = function* _RedisClusterSlots_slotNodesIterator(slot) {
let i = Math.floor(Math.random() * (1 + slot.replicas.length));
if (i < slot.replicas.length) {
do {
yield slot.replicas[i];
} while (++i < slot.replicas.length);
}
while (true) {
yield slot.master;
for (const replica of slot.replicas) {
yield replica;
}
}
}, _RedisClusterSlots_initiatePubSubClient = async function _RedisClusterSlots_initiatePubSubClient(toResubscribe) {
const index = Math.floor(Math.random() * (this.masters.length + this.replicas.length)), node = index < this.masters.length ?
this.masters[index] :
this.replicas[index - this.masters.length];
this.pubSubNode = {
address: node.address,
client: __classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_createClient).call(this, node, false)
.then(async (client) => {
if (toResubscribe) {
await Promise.all([
client.extendPubSubListeners(pub_sub_1.PubSubType.CHANNELS, toResubscribe[pub_sub_1.PubSubType.CHANNELS]),
client.extendPubSubListeners(pub_sub_1.PubSubType.PATTERNS, toResubscribe[pub_sub_1.PubSubType.PATTERNS])
]);
}
this.pubSubNode.client = client;
return client;
})
.catch(err => {
this.pubSubNode = undefined;
throw err;
})
};
return this.pubSubNode.client;
}, _RedisClusterSlots_initiateShardedPubSubClient = function _RedisClusterSlots_initiateShardedPubSubClient(master) {
const promise = __classPrivateFieldGet(this, _RedisClusterSlots_instances, "m", _RedisClusterSlots_createClient).call(this, master, false)
.then(client => {
client.on('server-sunsubscribe', async (channel, listeners) => {
try {
await this.rediscover(client);
const redirectTo = await this.getShardedPubSubClient(channel);
redirectTo.extendPubSubChannelListeners(pub_sub_1.PubSubType.SHARDED, channel, listeners);
}
catch (err) {
__classPrivateFieldGet(this, _RedisClusterSlots_emit, "f").call(this, 'sharded-shannel-moved-error', err, channel, listeners);
}
});
master.pubSubClient = client;
return client;
})
.catch(err => {
master.pubSubClient = undefined;
throw err;
});
master.pubSubClient = promise;
return promise;
};
_RedisClusterSlots_SLOTS = { value: 16384 };
exports.default = RedisClusterSlots;

View File

@@ -0,0 +1,669 @@
import * as APPEND from '../commands/APPEND';
import * as BITCOUNT from '../commands/BITCOUNT';
import * as BITFIELD_RO from '../commands/BITFIELD_RO';
import * as BITFIELD from '../commands/BITFIELD';
import * as BITOP from '../commands/BITOP';
import * as BITPOS from '../commands/BITPOS';
import * as BLMOVE from '../commands/BLMOVE';
import * as BLMPOP from '../commands/BLMPOP';
import * as BLPOP from '../commands/BLPOP';
import * as BRPOP from '../commands/BRPOP';
import * as BRPOPLPUSH from '../commands/BRPOPLPUSH';
import * as BZMPOP from '../commands/BZMPOP';
import * as BZPOPMAX from '../commands/BZPOPMAX';
import * as BZPOPMIN from '../commands/BZPOPMIN';
import * as COPY from '../commands/COPY';
import * as DECR from '../commands/DECR';
import * as DECRBY from '../commands/DECRBY';
import * as DEL from '../commands/DEL';
import * as DUMP from '../commands/DUMP';
import * as EVAL_RO from '../commands/EVAL_RO';
import * as EVAL from '../commands/EVAL';
import * as EVALSHA_RO from '../commands/EVALSHA_RO';
import * as EVALSHA from '../commands/EVALSHA';
import * as EXISTS from '../commands/EXISTS';
import * as EXPIRE from '../commands/EXPIRE';
import * as EXPIREAT from '../commands/EXPIREAT';
import * as EXPIRETIME from '../commands/EXPIRETIME';
import * as FCALL_RO from '../commands/FCALL_RO';
import * as FCALL from '../commands/FCALL';
import * as GEOADD from '../commands/GEOADD';
import * as GEODIST from '../commands/GEODIST';
import * as GEOHASH from '../commands/GEOHASH';
import * as GEOPOS from '../commands/GEOPOS';
import * as GEORADIUS_RO_WITH from '../commands/GEORADIUS_RO_WITH';
import * as GEORADIUS_RO from '../commands/GEORADIUS_RO';
import * as GEORADIUS_WITH from '../commands/GEORADIUS_WITH';
import * as GEORADIUS from '../commands/GEORADIUS';
import * as GEORADIUSBYMEMBER_RO_WITH from '../commands/GEORADIUSBYMEMBER_RO_WITH';
import * as GEORADIUSBYMEMBER_RO from '../commands/GEORADIUSBYMEMBER_RO';
import * as GEORADIUSBYMEMBER_WITH from '../commands/GEORADIUSBYMEMBER_WITH';
import * as GEORADIUSBYMEMBER from '../commands/GEORADIUSBYMEMBER';
import * as GEORADIUSBYMEMBERSTORE from '../commands/GEORADIUSBYMEMBERSTORE';
import * as GEORADIUSSTORE from '../commands/GEORADIUSSTORE';
import * as GEOSEARCH_WITH from '../commands/GEOSEARCH_WITH';
import * as GEOSEARCH from '../commands/GEOSEARCH';
import * as GEOSEARCHSTORE from '../commands/GEOSEARCHSTORE';
import * as GET from '../commands/GET';
import * as GETBIT from '../commands/GETBIT';
import * as GETDEL from '../commands/GETDEL';
import * as GETEX from '../commands/GETEX';
import * as GETRANGE from '../commands/GETRANGE';
import * as GETSET from '../commands/GETSET';
import * as HDEL from '../commands/HDEL';
import * as HEXISTS from '../commands/HEXISTS';
import * as HEXPIRE from '../commands/HEXPIRE';
import * as HEXPIREAT from '../commands/HEXPIREAT';
import * as HEXPIRETIME from '../commands/HEXPIRETIME';
import * as HGET from '../commands/HGET';
import * as HGETALL from '../commands/HGETALL';
import * as HINCRBY from '../commands/HINCRBY';
import * as HINCRBYFLOAT from '../commands/HINCRBYFLOAT';
import * as HKEYS from '../commands/HKEYS';
import * as HLEN from '../commands/HLEN';
import * as HMGET from '../commands/HMGET';
import * as HPERSIST from '../commands/HPERSIST';
import * as HPEXPIRE from '../commands/HPEXPIRE';
import * as HPEXPIREAT from '../commands/HPEXPIREAT';
import * as HPEXPIRETIME from '../commands/HPEXPIRETIME';
import * as HPTTL from '../commands/HPTTL';
import * as HRANDFIELD_COUNT_WITHVALUES from '../commands/HRANDFIELD_COUNT_WITHVALUES';
import * as HRANDFIELD_COUNT from '../commands/HRANDFIELD_COUNT';
import * as HRANDFIELD from '../commands/HRANDFIELD';
import * as HSCAN from '../commands/HSCAN';
import * as HSCAN_NOVALUES from '../commands/HSCAN_NOVALUES';
import * as HSET from '../commands/HSET';
import * as HSETNX from '../commands/HSETNX';
import * as HSTRLEN from '../commands/HSTRLEN';
import * as HTTL from '../commands/HTTL';
import * as HVALS from '../commands/HVALS';
import * as INCR from '../commands/INCR';
import * as INCRBY from '../commands/INCRBY';
import * as INCRBYFLOAT from '../commands/INCRBYFLOAT';
import * as LCS_IDX_WITHMATCHLEN from '../commands/LCS_IDX_WITHMATCHLEN';
import * as LCS_IDX from '../commands/LCS_IDX';
import * as LCS_LEN from '../commands/LCS_LEN';
import * as LCS from '../commands/LCS';
import * as LINDEX from '../commands/LINDEX';
import * as LINSERT from '../commands/LINSERT';
import * as LLEN from '../commands/LLEN';
import * as LMOVE from '../commands/LMOVE';
import * as LMPOP from '../commands/LMPOP';
import * as LPOP_COUNT from '../commands/LPOP_COUNT';
import * as LPOP from '../commands/LPOP';
import * as LPOS_COUNT from '../commands/LPOS_COUNT';
import * as LPOS from '../commands/LPOS';
import * as LPUSH from '../commands/LPUSH';
import * as LPUSHX from '../commands/LPUSHX';
import * as LRANGE from '../commands/LRANGE';
import * as LREM from '../commands/LREM';
import * as LSET from '../commands/LSET';
import * as LTRIM from '../commands/LTRIM';
import * as MGET from '../commands/MGET';
import * as MIGRATE from '../commands/MIGRATE';
import * as MSET from '../commands/MSET';
import * as MSETNX from '../commands/MSETNX';
import * as OBJECT_ENCODING from '../commands/OBJECT_ENCODING';
import * as OBJECT_FREQ from '../commands/OBJECT_FREQ';
import * as OBJECT_IDLETIME from '../commands/OBJECT_IDLETIME';
import * as OBJECT_REFCOUNT from '../commands/OBJECT_REFCOUNT';
import * as PERSIST from '../commands/PERSIST';
import * as PEXPIRE from '../commands/PEXPIRE';
import * as PEXPIREAT from '../commands/PEXPIREAT';
import * as PEXPIRETIME from '../commands/PEXPIRETIME';
import * as PFADD from '../commands/PFADD';
import * as PFCOUNT from '../commands/PFCOUNT';
import * as PFMERGE from '../commands/PFMERGE';
import * as PSETEX from '../commands/PSETEX';
import * as PTTL from '../commands/PTTL';
import * as PUBLISH from '../commands/PUBLISH';
import * as RENAME from '../commands/RENAME';
import * as RENAMENX from '../commands/RENAMENX';
import * as RESTORE from '../commands/RESTORE';
import * as RPOP_COUNT from '../commands/RPOP_COUNT';
import * as RPOP from '../commands/RPOP';
import * as RPOPLPUSH from '../commands/RPOPLPUSH';
import * as RPUSH from '../commands/RPUSH';
import * as RPUSHX from '../commands/RPUSHX';
import * as SADD from '../commands/SADD';
import * as SCARD from '../commands/SCARD';
import * as SDIFF from '../commands/SDIFF';
import * as SDIFFSTORE from '../commands/SDIFFSTORE';
import * as SET from '../commands/SET';
import * as SETBIT from '../commands/SETBIT';
import * as SETEX from '../commands/SETEX';
import * as SETNX from '../commands/SETNX';
import * as SETRANGE from '../commands/SETRANGE';
import * as SINTER from '../commands/SINTER';
import * as SINTERCARD from '../commands/SINTERCARD';
import * as SINTERSTORE from '../commands/SINTERSTORE';
import * as SISMEMBER from '../commands/SISMEMBER';
import * as SMEMBERS from '../commands/SMEMBERS';
import * as SMISMEMBER from '../commands/SMISMEMBER';
import * as SMOVE from '../commands/SMOVE';
import * as SORT_RO from '../commands/SORT_RO';
import * as SORT_STORE from '../commands/SORT_STORE';
import * as SORT from '../commands/SORT';
import * as SPOP from '../commands/SPOP';
import * as SPUBLISH from '../commands/SPUBLISH';
import * as SRANDMEMBER_COUNT from '../commands/SRANDMEMBER_COUNT';
import * as SRANDMEMBER from '../commands/SRANDMEMBER';
import * as SREM from '../commands/SREM';
import * as SSCAN from '../commands/SSCAN';
import * as STRLEN from '../commands/STRLEN';
import * as SUNION from '../commands/SUNION';
import * as SUNIONSTORE from '../commands/SUNIONSTORE';
import * as TOUCH from '../commands/TOUCH';
import * as TTL from '../commands/TTL';
import * as TYPE from '../commands/TYPE';
import * as UNLINK from '../commands/UNLINK';
import * as WATCH from '../commands/WATCH';
import * as XACK from '../commands/XACK';
import * as XADD from '../commands/XADD';
import * as XAUTOCLAIM_JUSTID from '../commands/XAUTOCLAIM_JUSTID';
import * as XAUTOCLAIM from '../commands/XAUTOCLAIM';
import * as XCLAIM_JUSTID from '../commands/XCLAIM_JUSTID';
import * as XCLAIM from '../commands/XCLAIM';
import * as XDEL from '../commands/XDEL';
import * as XGROUP_CREATE from '../commands/XGROUP_CREATE';
import * as XGROUP_CREATECONSUMER from '../commands/XGROUP_CREATECONSUMER';
import * as XGROUP_DELCONSUMER from '../commands/XGROUP_DELCONSUMER';
import * as XGROUP_DESTROY from '../commands/XGROUP_DESTROY';
import * as XGROUP_SETID from '../commands/XGROUP_SETID';
import * as XINFO_CONSUMERS from '../commands/XINFO_CONSUMERS';
import * as XINFO_GROUPS from '../commands/XINFO_GROUPS';
import * as XINFO_STREAM from '../commands/XINFO_STREAM';
import * as XLEN from '../commands/XLEN';
import * as XPENDING_RANGE from '../commands/XPENDING_RANGE';
import * as XPENDING from '../commands/XPENDING';
import * as XRANGE from '../commands/XRANGE';
import * as XREAD from '../commands/XREAD';
import * as XREADGROUP from '../commands/XREADGROUP';
import * as XREVRANGE from '../commands/XREVRANGE';
import * as XSETID from '../commands/XSETID';
import * as XTRIM from '../commands/XTRIM';
import * as ZADD from '../commands/ZADD';
import * as ZCARD from '../commands/ZCARD';
import * as ZCOUNT from '../commands/ZCOUNT';
import * as ZDIFF_WITHSCORES from '../commands/ZDIFF_WITHSCORES';
import * as ZDIFF from '../commands/ZDIFF';
import * as ZDIFFSTORE from '../commands/ZDIFFSTORE';
import * as ZINCRBY from '../commands/ZINCRBY';
import * as ZINTER_WITHSCORES from '../commands/ZINTER_WITHSCORES';
import * as ZINTER from '../commands/ZINTER';
import * as ZINTERCARD from '../commands/ZINTERCARD';
import * as ZINTERSTORE from '../commands/ZINTERSTORE';
import * as ZLEXCOUNT from '../commands/ZLEXCOUNT';
import * as ZMPOP from '../commands/ZMPOP';
import * as ZMSCORE from '../commands/ZMSCORE';
import * as ZPOPMAX_COUNT from '../commands/ZPOPMAX_COUNT';
import * as ZPOPMAX from '../commands/ZPOPMAX';
import * as ZPOPMIN_COUNT from '../commands/ZPOPMIN_COUNT';
import * as ZPOPMIN from '../commands/ZPOPMIN';
import * as ZRANDMEMBER_COUNT_WITHSCORES from '../commands/ZRANDMEMBER_COUNT_WITHSCORES';
import * as ZRANDMEMBER_COUNT from '../commands/ZRANDMEMBER_COUNT';
import * as ZRANDMEMBER from '../commands/ZRANDMEMBER';
import * as ZRANGE_WITHSCORES from '../commands/ZRANGE_WITHSCORES';
import * as ZRANGE from '../commands/ZRANGE';
import * as ZRANGEBYLEX from '../commands/ZRANGEBYLEX';
import * as ZRANGEBYSCORE_WITHSCORES from '../commands/ZRANGEBYSCORE_WITHSCORES';
import * as ZRANGEBYSCORE from '../commands/ZRANGEBYSCORE';
import * as ZRANGESTORE from '../commands/ZRANGESTORE';
import * as ZRANK from '../commands/ZRANK';
import * as ZREM from '../commands/ZREM';
import * as ZREMRANGEBYLEX from '../commands/ZREMRANGEBYLEX';
import * as ZREMRANGEBYRANK from '../commands/ZREMRANGEBYRANK';
import * as ZREMRANGEBYSCORE from '../commands/ZREMRANGEBYSCORE';
import * as ZREVRANK from '../commands/ZREVRANK';
import * as ZSCAN from '../commands/ZSCAN';
import * as ZSCORE from '../commands/ZSCORE';
import * as ZUNION_WITHSCORES from '../commands/ZUNION_WITHSCORES';
import * as ZUNION from '../commands/ZUNION';
import * as ZUNIONSTORE from '../commands/ZUNIONSTORE';
declare const _default: {
APPEND: typeof APPEND;
append: typeof APPEND;
BITCOUNT: typeof BITCOUNT;
bitCount: typeof BITCOUNT;
BITFIELD_RO: typeof BITFIELD_RO;
bitFieldRo: typeof BITFIELD_RO;
BITFIELD: typeof BITFIELD;
bitField: typeof BITFIELD;
BITOP: typeof BITOP;
bitOp: typeof BITOP;
BITPOS: typeof BITPOS;
bitPos: typeof BITPOS;
BLMOVE: typeof BLMOVE;
blMove: typeof BLMOVE;
BLMPOP: typeof BLMPOP;
blmPop: typeof BLMPOP;
BLPOP: typeof BLPOP;
blPop: typeof BLPOP;
BRPOP: typeof BRPOP;
brPop: typeof BRPOP;
BRPOPLPUSH: typeof BRPOPLPUSH;
brPopLPush: typeof BRPOPLPUSH;
BZMPOP: typeof BZMPOP;
bzmPop: typeof BZMPOP;
BZPOPMAX: typeof BZPOPMAX;
bzPopMax: typeof BZPOPMAX;
BZPOPMIN: typeof BZPOPMIN;
bzPopMin: typeof BZPOPMIN;
COPY: typeof COPY;
copy: typeof COPY;
DECR: typeof DECR;
decr: typeof DECR;
DECRBY: typeof DECRBY;
decrBy: typeof DECRBY;
DEL: typeof DEL;
del: typeof DEL;
DUMP: typeof DUMP;
dump: typeof DUMP;
EVAL_RO: typeof EVAL_RO;
evalRo: typeof EVAL_RO;
EVAL: typeof EVAL;
eval: typeof EVAL;
EVALSHA: typeof EVALSHA;
evalSha: typeof EVALSHA;
EVALSHA_RO: typeof EVALSHA_RO;
evalShaRo: typeof EVALSHA_RO;
EXISTS: typeof EXISTS;
exists: typeof EXISTS;
EXPIRE: typeof EXPIRE;
expire: typeof EXPIRE;
EXPIREAT: typeof EXPIREAT;
expireAt: typeof EXPIREAT;
EXPIRETIME: typeof EXPIRETIME;
expireTime: typeof EXPIRETIME;
FCALL_RO: typeof FCALL_RO;
fCallRo: typeof FCALL_RO;
FCALL: typeof FCALL;
fCall: typeof FCALL;
GEOADD: typeof GEOADD;
geoAdd: typeof GEOADD;
GEODIST: typeof GEODIST;
geoDist: typeof GEODIST;
GEOHASH: typeof GEOHASH;
geoHash: typeof GEOHASH;
GEOPOS: typeof GEOPOS;
geoPos: typeof GEOPOS;
GEORADIUS_RO_WITH: typeof GEORADIUS_RO_WITH;
geoRadiusRoWith: typeof GEORADIUS_RO_WITH;
GEORADIUS_RO: typeof GEORADIUS_RO;
geoRadiusRo: typeof GEORADIUS_RO;
GEORADIUS_WITH: typeof GEORADIUS_WITH;
geoRadiusWith: typeof GEORADIUS_WITH;
GEORADIUS: typeof GEORADIUS;
geoRadius: typeof GEORADIUS;
GEORADIUSBYMEMBER_RO_WITH: typeof GEORADIUSBYMEMBER_RO_WITH;
geoRadiusByMemberRoWith: typeof GEORADIUSBYMEMBER_RO_WITH;
GEORADIUSBYMEMBER_RO: typeof GEORADIUSBYMEMBER_RO;
geoRadiusByMemberRo: typeof GEORADIUSBYMEMBER_RO;
GEORADIUSBYMEMBER_WITH: typeof GEORADIUSBYMEMBER_WITH;
geoRadiusByMemberWith: typeof GEORADIUSBYMEMBER_WITH;
GEORADIUSBYMEMBER: typeof GEORADIUSBYMEMBER;
geoRadiusByMember: typeof GEORADIUSBYMEMBER;
GEORADIUSBYMEMBERSTORE: typeof GEORADIUSBYMEMBERSTORE;
geoRadiusByMemberStore: typeof GEORADIUSBYMEMBERSTORE;
GEORADIUSSTORE: typeof GEORADIUSSTORE;
geoRadiusStore: typeof GEORADIUSSTORE;
GEOSEARCH_WITH: typeof GEOSEARCH_WITH;
geoSearchWith: typeof GEOSEARCH_WITH;
GEOSEARCH: typeof GEOSEARCH;
geoSearch: typeof GEOSEARCH;
GEOSEARCHSTORE: typeof GEOSEARCHSTORE;
geoSearchStore: typeof GEOSEARCHSTORE;
GET: typeof GET;
get: typeof GET;
GETBIT: typeof GETBIT;
getBit: typeof GETBIT;
GETDEL: typeof GETDEL;
getDel: typeof GETDEL;
GETEX: typeof GETEX;
getEx: typeof GETEX;
GETRANGE: typeof GETRANGE;
getRange: typeof GETRANGE;
GETSET: typeof GETSET;
getSet: typeof GETSET;
HDEL: typeof HDEL;
hDel: typeof HDEL;
HEXISTS: typeof HEXISTS;
hExists: typeof HEXISTS;
HEXPIRE: typeof HEXPIRE;
hExpire: typeof HEXPIRE;
HEXPIREAT: typeof HEXPIREAT;
hExpireAt: typeof HEXPIREAT;
HEXPIRETIME: typeof HEXPIRETIME;
hExpireTime: typeof HEXPIRETIME;
HGET: typeof HGET;
hGet: typeof HGET;
HGETALL: typeof HGETALL;
hGetAll: typeof HGETALL;
HINCRBY: typeof HINCRBY;
hIncrBy: typeof HINCRBY;
HINCRBYFLOAT: typeof HINCRBYFLOAT;
hIncrByFloat: typeof HINCRBYFLOAT;
HKEYS: typeof HKEYS;
hKeys: typeof HKEYS;
HLEN: typeof HLEN;
hLen: typeof HLEN;
HMGET: typeof HMGET;
hmGet: typeof HMGET;
HPERSIST: typeof HPERSIST;
hPersist: typeof HPERSIST;
HPEXPIRE: typeof HPEXPIRE;
hpExpire: typeof HPEXPIRE;
HPEXPIREAT: typeof HPEXPIREAT;
hpExpireAt: typeof HPEXPIREAT;
HPEXPIRETIME: typeof HPEXPIRETIME;
hpExpireTime: typeof HPEXPIRETIME;
HPTTL: typeof HPTTL;
hpTTL: typeof HPTTL;
HRANDFIELD_COUNT_WITHVALUES: typeof HRANDFIELD_COUNT_WITHVALUES;
hRandFieldCountWithValues: typeof HRANDFIELD_COUNT_WITHVALUES;
HRANDFIELD_COUNT: typeof HRANDFIELD_COUNT;
hRandFieldCount: typeof HRANDFIELD_COUNT;
HRANDFIELD: typeof HRANDFIELD;
hRandField: typeof HRANDFIELD;
HSCAN: typeof HSCAN;
hScan: typeof HSCAN;
HSCAN_NOVALUES: typeof HSCAN_NOVALUES;
hScanNoValues: typeof HSCAN_NOVALUES;
HSET: typeof HSET;
hSet: typeof HSET;
HSETNX: typeof HSETNX;
hSetNX: typeof HSETNX;
HSTRLEN: typeof HSTRLEN;
hStrLen: typeof HSTRLEN;
HTTL: typeof HTTL;
hTTL: typeof HTTL;
HVALS: typeof HVALS;
hVals: typeof HVALS;
INCR: typeof INCR;
incr: typeof INCR;
INCRBY: typeof INCRBY;
incrBy: typeof INCRBY;
INCRBYFLOAT: typeof INCRBYFLOAT;
incrByFloat: typeof INCRBYFLOAT;
LCS_IDX_WITHMATCHLEN: typeof LCS_IDX_WITHMATCHLEN;
lcsIdxWithMatchLen: typeof LCS_IDX_WITHMATCHLEN;
LCS_IDX: typeof LCS_IDX;
lcsIdx: typeof LCS_IDX;
LCS_LEN: typeof LCS_LEN;
lcsLen: typeof LCS_LEN;
LCS: typeof LCS;
lcs: typeof LCS;
LINDEX: typeof LINDEX;
lIndex: typeof LINDEX;
LINSERT: typeof LINSERT;
lInsert: typeof LINSERT;
LLEN: typeof LLEN;
lLen: typeof LLEN;
LMOVE: typeof LMOVE;
lMove: typeof LMOVE;
LMPOP: typeof LMPOP;
lmPop: typeof LMPOP;
LPOP_COUNT: typeof LPOP_COUNT;
lPopCount: typeof LPOP_COUNT;
LPOP: typeof LPOP;
lPop: typeof LPOP;
LPOS_COUNT: typeof LPOS_COUNT;
lPosCount: typeof LPOS_COUNT;
LPOS: typeof LPOS;
lPos: typeof LPOS;
LPUSH: typeof LPUSH;
lPush: typeof LPUSH;
LPUSHX: typeof LPUSHX;
lPushX: typeof LPUSHX;
LRANGE: typeof LRANGE;
lRange: typeof LRANGE;
LREM: typeof LREM;
lRem: typeof LREM;
LSET: typeof LSET;
lSet: typeof LSET;
LTRIM: typeof LTRIM;
lTrim: typeof LTRIM;
MGET: typeof MGET;
mGet: typeof MGET;
MIGRATE: typeof MIGRATE;
migrate: typeof MIGRATE;
MSET: typeof MSET;
mSet: typeof MSET;
MSETNX: typeof MSETNX;
mSetNX: typeof MSETNX;
OBJECT_ENCODING: typeof OBJECT_ENCODING;
objectEncoding: typeof OBJECT_ENCODING;
OBJECT_FREQ: typeof OBJECT_FREQ;
objectFreq: typeof OBJECT_FREQ;
OBJECT_IDLETIME: typeof OBJECT_IDLETIME;
objectIdleTime: typeof OBJECT_IDLETIME;
OBJECT_REFCOUNT: typeof OBJECT_REFCOUNT;
objectRefCount: typeof OBJECT_REFCOUNT;
PERSIST: typeof PERSIST;
persist: typeof PERSIST;
PEXPIRE: typeof PEXPIRE;
pExpire: typeof PEXPIRE;
PEXPIREAT: typeof PEXPIREAT;
pExpireAt: typeof PEXPIREAT;
PEXPIRETIME: typeof PEXPIRETIME;
pExpireTime: typeof PEXPIRETIME;
PFADD: typeof PFADD;
pfAdd: typeof PFADD;
PFCOUNT: typeof PFCOUNT;
pfCount: typeof PFCOUNT;
PFMERGE: typeof PFMERGE;
pfMerge: typeof PFMERGE;
PSETEX: typeof PSETEX;
pSetEx: typeof PSETEX;
PTTL: typeof PTTL;
pTTL: typeof PTTL;
PUBLISH: typeof PUBLISH;
publish: typeof PUBLISH;
RENAME: typeof RENAME;
rename: typeof RENAME;
RENAMENX: typeof RENAMENX;
renameNX: typeof RENAMENX;
RESTORE: typeof RESTORE;
restore: typeof RESTORE;
RPOP_COUNT: typeof RPOP_COUNT;
rPopCount: typeof RPOP_COUNT;
RPOP: typeof RPOP;
rPop: typeof RPOP;
RPOPLPUSH: typeof RPOPLPUSH;
rPopLPush: typeof RPOPLPUSH;
RPUSH: typeof RPUSH;
rPush: typeof RPUSH;
RPUSHX: typeof RPUSHX;
rPushX: typeof RPUSHX;
SADD: typeof SADD;
sAdd: typeof SADD;
SCARD: typeof SCARD;
sCard: typeof SCARD;
SDIFF: typeof SDIFF;
sDiff: typeof SDIFF;
SDIFFSTORE: typeof SDIFFSTORE;
sDiffStore: typeof SDIFFSTORE;
SINTER: typeof SINTER;
sInter: typeof SINTER;
SINTERCARD: typeof SINTERCARD;
sInterCard: typeof SINTERCARD;
SINTERSTORE: typeof SINTERSTORE;
sInterStore: typeof SINTERSTORE;
SET: typeof SET;
set: typeof SET;
SETBIT: typeof SETBIT;
setBit: typeof SETBIT;
SETEX: typeof SETEX;
setEx: typeof SETEX;
SETNX: typeof SETNX;
setNX: typeof SETNX;
SETRANGE: typeof SETRANGE;
setRange: typeof SETRANGE;
SISMEMBER: typeof SISMEMBER;
sIsMember: typeof SISMEMBER;
SMEMBERS: typeof SMEMBERS;
sMembers: typeof SMEMBERS;
SMISMEMBER: typeof SMISMEMBER;
smIsMember: typeof SMISMEMBER;
SMOVE: typeof SMOVE;
sMove: typeof SMOVE;
SORT_RO: typeof SORT_RO;
sortRo: typeof SORT_RO;
SORT_STORE: typeof SORT_STORE;
sortStore: typeof SORT_STORE;
SORT: typeof SORT;
sort: typeof SORT;
SPOP: typeof SPOP;
sPop: typeof SPOP;
SPUBLISH: typeof SPUBLISH;
sPublish: typeof SPUBLISH;
SRANDMEMBER_COUNT: typeof SRANDMEMBER_COUNT;
sRandMemberCount: typeof SRANDMEMBER_COUNT;
SRANDMEMBER: typeof SRANDMEMBER;
sRandMember: typeof SRANDMEMBER;
SREM: typeof SREM;
sRem: typeof SREM;
SSCAN: typeof SSCAN;
sScan: typeof SSCAN;
STRLEN: typeof STRLEN;
strLen: typeof STRLEN;
SUNION: typeof SUNION;
sUnion: typeof SUNION;
SUNIONSTORE: typeof SUNIONSTORE;
sUnionStore: typeof SUNIONSTORE;
TOUCH: typeof TOUCH;
touch: typeof TOUCH;
TTL: typeof TTL;
ttl: typeof TTL;
TYPE: typeof TYPE;
type: typeof TYPE;
UNLINK: typeof UNLINK;
unlink: typeof UNLINK;
WATCH: typeof WATCH;
watch: typeof WATCH;
XACK: typeof XACK;
xAck: typeof XACK;
XADD: typeof XADD;
xAdd: typeof XADD;
XAUTOCLAIM_JUSTID: typeof XAUTOCLAIM_JUSTID;
xAutoClaimJustId: typeof XAUTOCLAIM_JUSTID;
XAUTOCLAIM: typeof XAUTOCLAIM;
xAutoClaim: typeof XAUTOCLAIM;
XCLAIM: typeof XCLAIM;
xClaim: typeof XCLAIM;
XCLAIM_JUSTID: typeof XCLAIM_JUSTID;
xClaimJustId: typeof XCLAIM_JUSTID;
XDEL: typeof XDEL;
xDel: typeof XDEL;
XGROUP_CREATE: typeof XGROUP_CREATE;
xGroupCreate: typeof XGROUP_CREATE;
XGROUP_CREATECONSUMER: typeof XGROUP_CREATECONSUMER;
xGroupCreateConsumer: typeof XGROUP_CREATECONSUMER;
XGROUP_DELCONSUMER: typeof XGROUP_DELCONSUMER;
xGroupDelConsumer: typeof XGROUP_DELCONSUMER;
XGROUP_DESTROY: typeof XGROUP_DESTROY;
xGroupDestroy: typeof XGROUP_DESTROY;
XGROUP_SETID: typeof XGROUP_SETID;
xGroupSetId: typeof XGROUP_SETID;
XINFO_CONSUMERS: typeof XINFO_CONSUMERS;
xInfoConsumers: typeof XINFO_CONSUMERS;
XINFO_GROUPS: typeof XINFO_GROUPS;
xInfoGroups: typeof XINFO_GROUPS;
XINFO_STREAM: typeof XINFO_STREAM;
xInfoStream: typeof XINFO_STREAM;
XLEN: typeof XLEN;
xLen: typeof XLEN;
XPENDING_RANGE: typeof XPENDING_RANGE;
xPendingRange: typeof XPENDING_RANGE;
XPENDING: typeof XPENDING;
xPending: typeof XPENDING;
XRANGE: typeof XRANGE;
xRange: typeof XRANGE;
XREAD: typeof XREAD;
xRead: typeof XREAD;
XREADGROUP: typeof XREADGROUP;
xReadGroup: typeof XREADGROUP;
XREVRANGE: typeof XREVRANGE;
xRevRange: typeof XREVRANGE;
XSETID: typeof XSETID;
xSetId: typeof XSETID;
XTRIM: typeof XTRIM;
xTrim: typeof XTRIM;
ZADD: typeof ZADD;
zAdd: typeof ZADD;
ZCARD: typeof ZCARD;
zCard: typeof ZCARD;
ZCOUNT: typeof ZCOUNT;
zCount: typeof ZCOUNT;
ZDIFF_WITHSCORES: typeof ZDIFF_WITHSCORES;
zDiffWithScores: typeof ZDIFF_WITHSCORES;
ZDIFF: typeof ZDIFF;
zDiff: typeof ZDIFF;
ZDIFFSTORE: typeof ZDIFFSTORE;
zDiffStore: typeof ZDIFFSTORE;
ZINCRBY: typeof ZINCRBY;
zIncrBy: typeof ZINCRBY;
ZINTER_WITHSCORES: typeof ZINTER_WITHSCORES;
zInterWithScores: typeof ZINTER_WITHSCORES;
ZINTER: typeof ZINTER;
zInter: typeof ZINTER;
ZINTERCARD: typeof ZINTERCARD;
zInterCard: typeof ZINTERCARD;
ZINTERSTORE: typeof ZINTERSTORE;
zInterStore: typeof ZINTERSTORE;
ZLEXCOUNT: typeof ZLEXCOUNT;
zLexCount: typeof ZLEXCOUNT;
ZMPOP: typeof ZMPOP;
zmPop: typeof ZMPOP;
ZMSCORE: typeof ZMSCORE;
zmScore: typeof ZMSCORE;
ZPOPMAX_COUNT: typeof ZPOPMAX_COUNT;
zPopMaxCount: typeof ZPOPMAX_COUNT;
ZPOPMAX: typeof ZPOPMAX;
zPopMax: typeof ZPOPMAX;
ZPOPMIN_COUNT: typeof ZPOPMIN_COUNT;
zPopMinCount: typeof ZPOPMIN_COUNT;
ZPOPMIN: typeof ZPOPMIN;
zPopMin: typeof ZPOPMIN;
ZRANDMEMBER_COUNT_WITHSCORES: typeof ZRANDMEMBER_COUNT_WITHSCORES;
zRandMemberCountWithScores: typeof ZRANDMEMBER_COUNT_WITHSCORES;
ZRANDMEMBER_COUNT: typeof ZRANDMEMBER_COUNT;
zRandMemberCount: typeof ZRANDMEMBER_COUNT;
ZRANDMEMBER: typeof ZRANDMEMBER;
zRandMember: typeof ZRANDMEMBER;
ZRANGE_WITHSCORES: typeof ZRANGE_WITHSCORES;
zRangeWithScores: typeof ZRANGE_WITHSCORES;
ZRANGE: typeof ZRANGE;
zRange: typeof ZRANGE;
ZRANGEBYLEX: typeof ZRANGEBYLEX;
zRangeByLex: typeof ZRANGEBYLEX;
ZRANGEBYSCORE_WITHSCORES: typeof ZRANGEBYSCORE_WITHSCORES;
zRangeByScoreWithScores: typeof ZRANGEBYSCORE_WITHSCORES;
ZRANGEBYSCORE: typeof ZRANGEBYSCORE;
zRangeByScore: typeof ZRANGEBYSCORE;
ZRANGESTORE: typeof ZRANGESTORE;
zRangeStore: typeof ZRANGESTORE;
ZRANK: typeof ZRANK;
zRank: typeof ZRANK;
ZREM: typeof ZREM;
zRem: typeof ZREM;
ZREMRANGEBYLEX: typeof ZREMRANGEBYLEX;
zRemRangeByLex: typeof ZREMRANGEBYLEX;
ZREMRANGEBYRANK: typeof ZREMRANGEBYRANK;
zRemRangeByRank: typeof ZREMRANGEBYRANK;
ZREMRANGEBYSCORE: typeof ZREMRANGEBYSCORE;
zRemRangeByScore: typeof ZREMRANGEBYSCORE;
ZREVRANK: typeof ZREVRANK;
zRevRank: typeof ZREVRANK;
ZSCAN: typeof ZSCAN;
zScan: typeof ZSCAN;
ZSCORE: typeof ZSCORE;
zScore: typeof ZSCORE;
ZUNION_WITHSCORES: typeof ZUNION_WITHSCORES;
zUnionWithScores: typeof ZUNION_WITHSCORES;
ZUNION: typeof ZUNION;
zUnion: typeof ZUNION;
ZUNIONSTORE: typeof ZUNIONSTORE;
zUnionStore: typeof ZUNIONSTORE;
};
export default _default;

View File

@@ -0,0 +1,670 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const APPEND = require("../commands/APPEND");
const BITCOUNT = require("../commands/BITCOUNT");
const BITFIELD_RO = require("../commands/BITFIELD_RO");
const BITFIELD = require("../commands/BITFIELD");
const BITOP = require("../commands/BITOP");
const BITPOS = require("../commands/BITPOS");
const BLMOVE = require("../commands/BLMOVE");
const BLMPOP = require("../commands/BLMPOP");
const BLPOP = require("../commands/BLPOP");
const BRPOP = require("../commands/BRPOP");
const BRPOPLPUSH = require("../commands/BRPOPLPUSH");
const BZMPOP = require("../commands/BZMPOP");
const BZPOPMAX = require("../commands/BZPOPMAX");
const BZPOPMIN = require("../commands/BZPOPMIN");
const COPY = require("../commands/COPY");
const DECR = require("../commands/DECR");
const DECRBY = require("../commands/DECRBY");
const DEL = require("../commands/DEL");
const DUMP = require("../commands/DUMP");
const EVAL_RO = require("../commands/EVAL_RO");
const EVAL = require("../commands/EVAL");
const EVALSHA_RO = require("../commands/EVALSHA_RO");
const EVALSHA = require("../commands/EVALSHA");
const EXISTS = require("../commands/EXISTS");
const EXPIRE = require("../commands/EXPIRE");
const EXPIREAT = require("../commands/EXPIREAT");
const EXPIRETIME = require("../commands/EXPIRETIME");
const FCALL_RO = require("../commands/FCALL_RO");
const FCALL = require("../commands/FCALL");
const GEOADD = require("../commands/GEOADD");
const GEODIST = require("../commands/GEODIST");
const GEOHASH = require("../commands/GEOHASH");
const GEOPOS = require("../commands/GEOPOS");
const GEORADIUS_RO_WITH = require("../commands/GEORADIUS_RO_WITH");
const GEORADIUS_RO = require("../commands/GEORADIUS_RO");
const GEORADIUS_WITH = require("../commands/GEORADIUS_WITH");
const GEORADIUS = require("../commands/GEORADIUS");
const GEORADIUSBYMEMBER_RO_WITH = require("../commands/GEORADIUSBYMEMBER_RO_WITH");
const GEORADIUSBYMEMBER_RO = require("../commands/GEORADIUSBYMEMBER_RO");
const GEORADIUSBYMEMBER_WITH = require("../commands/GEORADIUSBYMEMBER_WITH");
const GEORADIUSBYMEMBER = require("../commands/GEORADIUSBYMEMBER");
const GEORADIUSBYMEMBERSTORE = require("../commands/GEORADIUSBYMEMBERSTORE");
const GEORADIUSSTORE = require("../commands/GEORADIUSSTORE");
const GEOSEARCH_WITH = require("../commands/GEOSEARCH_WITH");
const GEOSEARCH = require("../commands/GEOSEARCH");
const GEOSEARCHSTORE = require("../commands/GEOSEARCHSTORE");
const GET = require("../commands/GET");
const GETBIT = require("../commands/GETBIT");
const GETDEL = require("../commands/GETDEL");
const GETEX = require("../commands/GETEX");
const GETRANGE = require("../commands/GETRANGE");
const GETSET = require("../commands/GETSET");
const HDEL = require("../commands/HDEL");
const HEXISTS = require("../commands/HEXISTS");
const HEXPIRE = require("../commands/HEXPIRE");
const HEXPIREAT = require("../commands/HEXPIREAT");
const HEXPIRETIME = require("../commands/HEXPIRETIME");
const HGET = require("../commands/HGET");
const HGETALL = require("../commands/HGETALL");
const HINCRBY = require("../commands/HINCRBY");
const HINCRBYFLOAT = require("../commands/HINCRBYFLOAT");
const HKEYS = require("../commands/HKEYS");
const HLEN = require("../commands/HLEN");
const HMGET = require("../commands/HMGET");
const HPERSIST = require("../commands/HPERSIST");
const HPEXPIRE = require("../commands/HPEXPIRE");
const HPEXPIREAT = require("../commands/HPEXPIREAT");
const HPEXPIRETIME = require("../commands/HPEXPIRETIME");
const HPTTL = require("../commands/HPTTL");
const HRANDFIELD_COUNT_WITHVALUES = require("../commands/HRANDFIELD_COUNT_WITHVALUES");
const HRANDFIELD_COUNT = require("../commands/HRANDFIELD_COUNT");
const HRANDFIELD = require("../commands/HRANDFIELD");
const HSCAN = require("../commands/HSCAN");
const HSCAN_NOVALUES = require("../commands/HSCAN_NOVALUES");
const HSET = require("../commands/HSET");
const HSETNX = require("../commands/HSETNX");
const HSTRLEN = require("../commands/HSTRLEN");
const HTTL = require("../commands/HTTL");
const HVALS = require("../commands/HVALS");
const INCR = require("../commands/INCR");
const INCRBY = require("../commands/INCRBY");
const INCRBYFLOAT = require("../commands/INCRBYFLOAT");
const LCS_IDX_WITHMATCHLEN = require("../commands/LCS_IDX_WITHMATCHLEN");
const LCS_IDX = require("../commands/LCS_IDX");
const LCS_LEN = require("../commands/LCS_LEN");
const LCS = require("../commands/LCS");
const LINDEX = require("../commands/LINDEX");
const LINSERT = require("../commands/LINSERT");
const LLEN = require("../commands/LLEN");
const LMOVE = require("../commands/LMOVE");
const LMPOP = require("../commands/LMPOP");
const LPOP_COUNT = require("../commands/LPOP_COUNT");
const LPOP = require("../commands/LPOP");
const LPOS_COUNT = require("../commands/LPOS_COUNT");
const LPOS = require("../commands/LPOS");
const LPUSH = require("../commands/LPUSH");
const LPUSHX = require("../commands/LPUSHX");
const LRANGE = require("../commands/LRANGE");
const LREM = require("../commands/LREM");
const LSET = require("../commands/LSET");
const LTRIM = require("../commands/LTRIM");
const MGET = require("../commands/MGET");
const MIGRATE = require("../commands/MIGRATE");
const MSET = require("../commands/MSET");
const MSETNX = require("../commands/MSETNX");
const OBJECT_ENCODING = require("../commands/OBJECT_ENCODING");
const OBJECT_FREQ = require("../commands/OBJECT_FREQ");
const OBJECT_IDLETIME = require("../commands/OBJECT_IDLETIME");
const OBJECT_REFCOUNT = require("../commands/OBJECT_REFCOUNT");
const PERSIST = require("../commands/PERSIST");
const PEXPIRE = require("../commands/PEXPIRE");
const PEXPIREAT = require("../commands/PEXPIREAT");
const PEXPIRETIME = require("../commands/PEXPIRETIME");
const PFADD = require("../commands/PFADD");
const PFCOUNT = require("../commands/PFCOUNT");
const PFMERGE = require("../commands/PFMERGE");
const PSETEX = require("../commands/PSETEX");
const PTTL = require("../commands/PTTL");
const PUBLISH = require("../commands/PUBLISH");
const RENAME = require("../commands/RENAME");
const RENAMENX = require("../commands/RENAMENX");
const RESTORE = require("../commands/RESTORE");
const RPOP_COUNT = require("../commands/RPOP_COUNT");
const RPOP = require("../commands/RPOP");
const RPOPLPUSH = require("../commands/RPOPLPUSH");
const RPUSH = require("../commands/RPUSH");
const RPUSHX = require("../commands/RPUSHX");
const SADD = require("../commands/SADD");
const SCARD = require("../commands/SCARD");
const SDIFF = require("../commands/SDIFF");
const SDIFFSTORE = require("../commands/SDIFFSTORE");
const SET = require("../commands/SET");
const SETBIT = require("../commands/SETBIT");
const SETEX = require("../commands/SETEX");
const SETNX = require("../commands/SETNX");
const SETRANGE = require("../commands/SETRANGE");
const SINTER = require("../commands/SINTER");
const SINTERCARD = require("../commands/SINTERCARD");
const SINTERSTORE = require("../commands/SINTERSTORE");
const SISMEMBER = require("../commands/SISMEMBER");
const SMEMBERS = require("../commands/SMEMBERS");
const SMISMEMBER = require("../commands/SMISMEMBER");
const SMOVE = require("../commands/SMOVE");
const SORT_RO = require("../commands/SORT_RO");
const SORT_STORE = require("../commands/SORT_STORE");
const SORT = require("../commands/SORT");
const SPOP = require("../commands/SPOP");
const SPUBLISH = require("../commands/SPUBLISH");
const SRANDMEMBER_COUNT = require("../commands/SRANDMEMBER_COUNT");
const SRANDMEMBER = require("../commands/SRANDMEMBER");
const SREM = require("../commands/SREM");
const SSCAN = require("../commands/SSCAN");
const STRLEN = require("../commands/STRLEN");
const SUNION = require("../commands/SUNION");
const SUNIONSTORE = require("../commands/SUNIONSTORE");
const TOUCH = require("../commands/TOUCH");
const TTL = require("../commands/TTL");
const TYPE = require("../commands/TYPE");
const UNLINK = require("../commands/UNLINK");
const WATCH = require("../commands/WATCH");
const XACK = require("../commands/XACK");
const XADD = require("../commands/XADD");
const XAUTOCLAIM_JUSTID = require("../commands/XAUTOCLAIM_JUSTID");
const XAUTOCLAIM = require("../commands/XAUTOCLAIM");
const XCLAIM_JUSTID = require("../commands/XCLAIM_JUSTID");
const XCLAIM = require("../commands/XCLAIM");
const XDEL = require("../commands/XDEL");
const XGROUP_CREATE = require("../commands/XGROUP_CREATE");
const XGROUP_CREATECONSUMER = require("../commands/XGROUP_CREATECONSUMER");
const XGROUP_DELCONSUMER = require("../commands/XGROUP_DELCONSUMER");
const XGROUP_DESTROY = require("../commands/XGROUP_DESTROY");
const XGROUP_SETID = require("../commands/XGROUP_SETID");
const XINFO_CONSUMERS = require("../commands/XINFO_CONSUMERS");
const XINFO_GROUPS = require("../commands/XINFO_GROUPS");
const XINFO_STREAM = require("../commands/XINFO_STREAM");
const XLEN = require("../commands/XLEN");
const XPENDING_RANGE = require("../commands/XPENDING_RANGE");
const XPENDING = require("../commands/XPENDING");
const XRANGE = require("../commands/XRANGE");
const XREAD = require("../commands/XREAD");
const XREADGROUP = require("../commands/XREADGROUP");
const XREVRANGE = require("../commands/XREVRANGE");
const XSETID = require("../commands/XSETID");
const XTRIM = require("../commands/XTRIM");
const ZADD = require("../commands/ZADD");
const ZCARD = require("../commands/ZCARD");
const ZCOUNT = require("../commands/ZCOUNT");
const ZDIFF_WITHSCORES = require("../commands/ZDIFF_WITHSCORES");
const ZDIFF = require("../commands/ZDIFF");
const ZDIFFSTORE = require("../commands/ZDIFFSTORE");
const ZINCRBY = require("../commands/ZINCRBY");
const ZINTER_WITHSCORES = require("../commands/ZINTER_WITHSCORES");
const ZINTER = require("../commands/ZINTER");
const ZINTERCARD = require("../commands/ZINTERCARD");
const ZINTERSTORE = require("../commands/ZINTERSTORE");
const ZLEXCOUNT = require("../commands/ZLEXCOUNT");
const ZMPOP = require("../commands/ZMPOP");
const ZMSCORE = require("../commands/ZMSCORE");
const ZPOPMAX_COUNT = require("../commands/ZPOPMAX_COUNT");
const ZPOPMAX = require("../commands/ZPOPMAX");
const ZPOPMIN_COUNT = require("../commands/ZPOPMIN_COUNT");
const ZPOPMIN = require("../commands/ZPOPMIN");
const ZRANDMEMBER_COUNT_WITHSCORES = require("../commands/ZRANDMEMBER_COUNT_WITHSCORES");
const ZRANDMEMBER_COUNT = require("../commands/ZRANDMEMBER_COUNT");
const ZRANDMEMBER = require("../commands/ZRANDMEMBER");
const ZRANGE_WITHSCORES = require("../commands/ZRANGE_WITHSCORES");
const ZRANGE = require("../commands/ZRANGE");
const ZRANGEBYLEX = require("../commands/ZRANGEBYLEX");
const ZRANGEBYSCORE_WITHSCORES = require("../commands/ZRANGEBYSCORE_WITHSCORES");
const ZRANGEBYSCORE = require("../commands/ZRANGEBYSCORE");
const ZRANGESTORE = require("../commands/ZRANGESTORE");
const ZRANK = require("../commands/ZRANK");
const ZREM = require("../commands/ZREM");
const ZREMRANGEBYLEX = require("../commands/ZREMRANGEBYLEX");
const ZREMRANGEBYRANK = require("../commands/ZREMRANGEBYRANK");
const ZREMRANGEBYSCORE = require("../commands/ZREMRANGEBYSCORE");
const ZREVRANK = require("../commands/ZREVRANK");
const ZSCAN = require("../commands/ZSCAN");
const ZSCORE = require("../commands/ZSCORE");
const ZUNION_WITHSCORES = require("../commands/ZUNION_WITHSCORES");
const ZUNION = require("../commands/ZUNION");
const ZUNIONSTORE = require("../commands/ZUNIONSTORE");
exports.default = {
APPEND,
append: APPEND,
BITCOUNT,
bitCount: BITCOUNT,
BITFIELD_RO,
bitFieldRo: BITFIELD_RO,
BITFIELD,
bitField: BITFIELD,
BITOP,
bitOp: BITOP,
BITPOS,
bitPos: BITPOS,
BLMOVE,
blMove: BLMOVE,
BLMPOP,
blmPop: BLMPOP,
BLPOP,
blPop: BLPOP,
BRPOP,
brPop: BRPOP,
BRPOPLPUSH,
brPopLPush: BRPOPLPUSH,
BZMPOP,
bzmPop: BZMPOP,
BZPOPMAX,
bzPopMax: BZPOPMAX,
BZPOPMIN,
bzPopMin: BZPOPMIN,
COPY,
copy: COPY,
DECR,
decr: DECR,
DECRBY,
decrBy: DECRBY,
DEL,
del: DEL,
DUMP,
dump: DUMP,
EVAL_RO,
evalRo: EVAL_RO,
EVAL,
eval: EVAL,
EVALSHA,
evalSha: EVALSHA,
EVALSHA_RO,
evalShaRo: EVALSHA_RO,
EXISTS,
exists: EXISTS,
EXPIRE,
expire: EXPIRE,
EXPIREAT,
expireAt: EXPIREAT,
EXPIRETIME,
expireTime: EXPIRETIME,
FCALL_RO,
fCallRo: FCALL_RO,
FCALL,
fCall: FCALL,
GEOADD,
geoAdd: GEOADD,
GEODIST,
geoDist: GEODIST,
GEOHASH,
geoHash: GEOHASH,
GEOPOS,
geoPos: GEOPOS,
GEORADIUS_RO_WITH,
geoRadiusRoWith: GEORADIUS_RO_WITH,
GEORADIUS_RO,
geoRadiusRo: GEORADIUS_RO,
GEORADIUS_WITH,
geoRadiusWith: GEORADIUS_WITH,
GEORADIUS,
geoRadius: GEORADIUS,
GEORADIUSBYMEMBER_RO_WITH,
geoRadiusByMemberRoWith: GEORADIUSBYMEMBER_RO_WITH,
GEORADIUSBYMEMBER_RO,
geoRadiusByMemberRo: GEORADIUSBYMEMBER_RO,
GEORADIUSBYMEMBER_WITH,
geoRadiusByMemberWith: GEORADIUSBYMEMBER_WITH,
GEORADIUSBYMEMBER,
geoRadiusByMember: GEORADIUSBYMEMBER,
GEORADIUSBYMEMBERSTORE,
geoRadiusByMemberStore: GEORADIUSBYMEMBERSTORE,
GEORADIUSSTORE,
geoRadiusStore: GEORADIUSSTORE,
GEOSEARCH_WITH,
geoSearchWith: GEOSEARCH_WITH,
GEOSEARCH,
geoSearch: GEOSEARCH,
GEOSEARCHSTORE,
geoSearchStore: GEOSEARCHSTORE,
GET,
get: GET,
GETBIT,
getBit: GETBIT,
GETDEL,
getDel: GETDEL,
GETEX,
getEx: GETEX,
GETRANGE,
getRange: GETRANGE,
GETSET,
getSet: GETSET,
HDEL,
hDel: HDEL,
HEXISTS,
hExists: HEXISTS,
HEXPIRE,
hExpire: HEXPIRE,
HEXPIREAT,
hExpireAt: HEXPIREAT,
HEXPIRETIME,
hExpireTime: HEXPIRETIME,
HGET,
hGet: HGET,
HGETALL,
hGetAll: HGETALL,
HINCRBY,
hIncrBy: HINCRBY,
HINCRBYFLOAT,
hIncrByFloat: HINCRBYFLOAT,
HKEYS,
hKeys: HKEYS,
HLEN,
hLen: HLEN,
HMGET,
hmGet: HMGET,
HPERSIST,
hPersist: HPERSIST,
HPEXPIRE,
hpExpire: HPEXPIRE,
HPEXPIREAT,
hpExpireAt: HPEXPIREAT,
HPEXPIRETIME,
hpExpireTime: HPEXPIRETIME,
HPTTL,
hpTTL: HPTTL,
HRANDFIELD_COUNT_WITHVALUES,
hRandFieldCountWithValues: HRANDFIELD_COUNT_WITHVALUES,
HRANDFIELD_COUNT,
hRandFieldCount: HRANDFIELD_COUNT,
HRANDFIELD,
hRandField: HRANDFIELD,
HSCAN,
hScan: HSCAN,
HSCAN_NOVALUES,
hScanNoValues: HSCAN_NOVALUES,
HSET,
hSet: HSET,
HSETNX,
hSetNX: HSETNX,
HSTRLEN,
hStrLen: HSTRLEN,
HTTL,
hTTL: HTTL,
HVALS,
hVals: HVALS,
INCR,
incr: INCR,
INCRBY,
incrBy: INCRBY,
INCRBYFLOAT,
incrByFloat: INCRBYFLOAT,
LCS_IDX_WITHMATCHLEN,
lcsIdxWithMatchLen: LCS_IDX_WITHMATCHLEN,
LCS_IDX,
lcsIdx: LCS_IDX,
LCS_LEN,
lcsLen: LCS_LEN,
LCS,
lcs: LCS,
LINDEX,
lIndex: LINDEX,
LINSERT,
lInsert: LINSERT,
LLEN,
lLen: LLEN,
LMOVE,
lMove: LMOVE,
LMPOP,
lmPop: LMPOP,
LPOP_COUNT,
lPopCount: LPOP_COUNT,
LPOP,
lPop: LPOP,
LPOS_COUNT,
lPosCount: LPOS_COUNT,
LPOS,
lPos: LPOS,
LPUSH,
lPush: LPUSH,
LPUSHX,
lPushX: LPUSHX,
LRANGE,
lRange: LRANGE,
LREM,
lRem: LREM,
LSET,
lSet: LSET,
LTRIM,
lTrim: LTRIM,
MGET,
mGet: MGET,
MIGRATE,
migrate: MIGRATE,
MSET,
mSet: MSET,
MSETNX,
mSetNX: MSETNX,
OBJECT_ENCODING,
objectEncoding: OBJECT_ENCODING,
OBJECT_FREQ,
objectFreq: OBJECT_FREQ,
OBJECT_IDLETIME,
objectIdleTime: OBJECT_IDLETIME,
OBJECT_REFCOUNT,
objectRefCount: OBJECT_REFCOUNT,
PERSIST,
persist: PERSIST,
PEXPIRE,
pExpire: PEXPIRE,
PEXPIREAT,
pExpireAt: PEXPIREAT,
PEXPIRETIME,
pExpireTime: PEXPIRETIME,
PFADD,
pfAdd: PFADD,
PFCOUNT,
pfCount: PFCOUNT,
PFMERGE,
pfMerge: PFMERGE,
PSETEX,
pSetEx: PSETEX,
PTTL,
pTTL: PTTL,
PUBLISH,
publish: PUBLISH,
RENAME,
rename: RENAME,
RENAMENX,
renameNX: RENAMENX,
RESTORE,
restore: RESTORE,
RPOP_COUNT,
rPopCount: RPOP_COUNT,
RPOP,
rPop: RPOP,
RPOPLPUSH,
rPopLPush: RPOPLPUSH,
RPUSH,
rPush: RPUSH,
RPUSHX,
rPushX: RPUSHX,
SADD,
sAdd: SADD,
SCARD,
sCard: SCARD,
SDIFF,
sDiff: SDIFF,
SDIFFSTORE,
sDiffStore: SDIFFSTORE,
SINTER,
sInter: SINTER,
SINTERCARD,
sInterCard: SINTERCARD,
SINTERSTORE,
sInterStore: SINTERSTORE,
SET,
set: SET,
SETBIT,
setBit: SETBIT,
SETEX,
setEx: SETEX,
SETNX,
setNX: SETNX,
SETRANGE,
setRange: SETRANGE,
SISMEMBER,
sIsMember: SISMEMBER,
SMEMBERS,
sMembers: SMEMBERS,
SMISMEMBER,
smIsMember: SMISMEMBER,
SMOVE,
sMove: SMOVE,
SORT_RO,
sortRo: SORT_RO,
SORT_STORE,
sortStore: SORT_STORE,
SORT,
sort: SORT,
SPOP,
sPop: SPOP,
SPUBLISH,
sPublish: SPUBLISH,
SRANDMEMBER_COUNT,
sRandMemberCount: SRANDMEMBER_COUNT,
SRANDMEMBER,
sRandMember: SRANDMEMBER,
SREM,
sRem: SREM,
SSCAN,
sScan: SSCAN,
STRLEN,
strLen: STRLEN,
SUNION,
sUnion: SUNION,
SUNIONSTORE,
sUnionStore: SUNIONSTORE,
TOUCH,
touch: TOUCH,
TTL,
ttl: TTL,
TYPE,
type: TYPE,
UNLINK,
unlink: UNLINK,
WATCH,
watch: WATCH,
XACK,
xAck: XACK,
XADD,
xAdd: XADD,
XAUTOCLAIM_JUSTID,
xAutoClaimJustId: XAUTOCLAIM_JUSTID,
XAUTOCLAIM,
xAutoClaim: XAUTOCLAIM,
XCLAIM,
xClaim: XCLAIM,
XCLAIM_JUSTID,
xClaimJustId: XCLAIM_JUSTID,
XDEL,
xDel: XDEL,
XGROUP_CREATE,
xGroupCreate: XGROUP_CREATE,
XGROUP_CREATECONSUMER,
xGroupCreateConsumer: XGROUP_CREATECONSUMER,
XGROUP_DELCONSUMER,
xGroupDelConsumer: XGROUP_DELCONSUMER,
XGROUP_DESTROY,
xGroupDestroy: XGROUP_DESTROY,
XGROUP_SETID,
xGroupSetId: XGROUP_SETID,
XINFO_CONSUMERS,
xInfoConsumers: XINFO_CONSUMERS,
XINFO_GROUPS,
xInfoGroups: XINFO_GROUPS,
XINFO_STREAM,
xInfoStream: XINFO_STREAM,
XLEN,
xLen: XLEN,
XPENDING_RANGE,
xPendingRange: XPENDING_RANGE,
XPENDING,
xPending: XPENDING,
XRANGE,
xRange: XRANGE,
XREAD,
xRead: XREAD,
XREADGROUP,
xReadGroup: XREADGROUP,
XREVRANGE,
xRevRange: XREVRANGE,
XSETID,
xSetId: XSETID,
XTRIM,
xTrim: XTRIM,
ZADD,
zAdd: ZADD,
ZCARD,
zCard: ZCARD,
ZCOUNT,
zCount: ZCOUNT,
ZDIFF_WITHSCORES,
zDiffWithScores: ZDIFF_WITHSCORES,
ZDIFF,
zDiff: ZDIFF,
ZDIFFSTORE,
zDiffStore: ZDIFFSTORE,
ZINCRBY,
zIncrBy: ZINCRBY,
ZINTER_WITHSCORES,
zInterWithScores: ZINTER_WITHSCORES,
ZINTER,
zInter: ZINTER,
ZINTERCARD,
zInterCard: ZINTERCARD,
ZINTERSTORE,
zInterStore: ZINTERSTORE,
ZLEXCOUNT,
zLexCount: ZLEXCOUNT,
ZMPOP,
zmPop: ZMPOP,
ZMSCORE,
zmScore: ZMSCORE,
ZPOPMAX_COUNT,
zPopMaxCount: ZPOPMAX_COUNT,
ZPOPMAX,
zPopMax: ZPOPMAX,
ZPOPMIN_COUNT,
zPopMinCount: ZPOPMIN_COUNT,
ZPOPMIN,
zPopMin: ZPOPMIN,
ZRANDMEMBER_COUNT_WITHSCORES,
zRandMemberCountWithScores: ZRANDMEMBER_COUNT_WITHSCORES,
ZRANDMEMBER_COUNT,
zRandMemberCount: ZRANDMEMBER_COUNT,
ZRANDMEMBER,
zRandMember: ZRANDMEMBER,
ZRANGE_WITHSCORES,
zRangeWithScores: ZRANGE_WITHSCORES,
ZRANGE,
zRange: ZRANGE,
ZRANGEBYLEX,
zRangeByLex: ZRANGEBYLEX,
ZRANGEBYSCORE_WITHSCORES,
zRangeByScoreWithScores: ZRANGEBYSCORE_WITHSCORES,
ZRANGEBYSCORE,
zRangeByScore: ZRANGEBYSCORE,
ZRANGESTORE,
zRangeStore: ZRANGESTORE,
ZRANK,
zRank: ZRANK,
ZREM,
zRem: ZREM,
ZREMRANGEBYLEX,
zRemRangeByLex: ZREMRANGEBYLEX,
ZREMRANGEBYRANK,
zRemRangeByRank: ZREMRANGEBYRANK,
ZREMRANGEBYSCORE,
zRemRangeByScore: ZREMRANGEBYSCORE,
ZREVRANK,
zRevRank: ZREVRANK,
ZSCAN,
zScan: ZSCAN,
ZSCORE,
zScore: ZSCORE,
ZUNION_WITHSCORES,
zUnionWithScores: ZUNION_WITHSCORES,
ZUNION,
zUnion: ZUNION,
ZUNIONSTORE,
zUnionStore: ZUNIONSTORE
};

View File

@@ -0,0 +1,93 @@
/// <reference types="node" />
import COMMANDS from './commands';
import { RedisCommand, RedisCommandArgument, RedisCommandArguments, RedisCommandRawReply, RedisCommandReply, RedisFunctions, RedisModules, RedisExtensions, RedisScript, RedisScripts, RedisCommandSignature, RedisFunction } from '../commands';
import { ClientCommandOptions, RedisClientOptions, RedisClientType, WithFunctions, WithModules, WithScripts } from '../client';
import { NodeAddressMap, ShardNode } from './cluster-slots';
import { EventEmitter } from 'events';
import { RedisClusterMultiCommandType } from './multi-command';
import { PubSubListener } from '../client/pub-sub';
export type RedisClusterClientOptions = Omit<RedisClientOptions, 'modules' | 'functions' | 'scripts' | 'database'>;
export interface RedisClusterOptions<M extends RedisModules = Record<string, never>, F extends RedisFunctions = Record<string, never>, S extends RedisScripts = Record<string, never>> extends RedisExtensions<M, F, S> {
/**
* Should contain details for some of the cluster nodes that the client will use to discover
* the "cluster topology". We recommend including details for at least 3 nodes here.
*/
rootNodes: Array<RedisClusterClientOptions>;
/**
* Default values used for every client in the cluster. Use this to specify global values,
* for example: ACL credentials, timeouts, TLS configuration etc.
*/
defaults?: Partial<RedisClusterClientOptions>;
/**
* When `true`, `.connect()` will only discover the cluster topology, without actually connecting to all the nodes.
* Useful for short-term or PubSub-only connections.
*/
minimizeConnections?: boolean;
/**
* When `true`, distribute load by executing readonly commands (such as `GET`, `GEOSEARCH`, etc.) across all cluster nodes. When `false`, only use master nodes.
*/
useReplicas?: boolean;
/**
* The maximum number of times a command will be redirected due to `MOVED` or `ASK` errors.
*/
maxCommandRedirections?: number;
/**
* Mapping between the addresses in the cluster (see `CLUSTER SHARDS`) and the addresses the client should connect to
* Useful when the cluster is running on another network
*
*/
nodeAddressMap?: NodeAddressMap;
}
type WithCommands = {
[P in keyof typeof COMMANDS]: RedisCommandSignature<(typeof COMMANDS)[P]>;
};
export type RedisClusterType<M extends RedisModules = Record<string, never>, F extends RedisFunctions = Record<string, never>, S extends RedisScripts = Record<string, never>> = RedisCluster<M, F, S> & WithCommands & WithModules<M> & WithFunctions<F> & WithScripts<S>;
export default class RedisCluster<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> extends EventEmitter {
#private;
static extractFirstKey(command: RedisCommand, originalArgs: Array<unknown>, redisArgs: RedisCommandArguments): RedisCommandArgument | undefined;
static create<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts>(options?: RedisClusterOptions<M, F, S>): RedisClusterType<M, F, S>;
get slots(): import("./cluster-slots").Shard<M, F, S>[];
get shards(): import("./cluster-slots").Shard<M, F, S>[];
get masters(): ShardNode<M, F, S>[];
get replicas(): ShardNode<M, F, S>[];
get nodeByAddress(): Map<string, ShardNode<M, F, S> | import("./cluster-slots").MasterNode<M, F, S>>;
get pubSubNode(): Required<import("./cluster-slots").Node<M, F, S>> | undefined;
get isOpen(): boolean;
constructor(options: RedisClusterOptions<M, F, S>);
duplicate(overrides?: Partial<RedisClusterOptions<M, F, S>>): RedisClusterType<M, F, S>;
connect(): Promise<void>;
commandsExecutor<C extends RedisCommand>(command: C, args: Array<unknown>): Promise<RedisCommandReply<C>>;
sendCommand<T = RedisCommandRawReply>(firstKey: RedisCommandArgument | undefined, isReadonly: boolean | undefined, args: RedisCommandArguments, options?: ClientCommandOptions): Promise<T>;
functionsExecutor<F extends RedisFunction>(fn: F, args: Array<unknown>, name: string): Promise<RedisCommandReply<F>>;
executeFunction(name: string, fn: RedisFunction, originalArgs: Array<unknown>, redisArgs: RedisCommandArguments, options?: ClientCommandOptions): Promise<RedisCommandRawReply>;
scriptsExecutor<S extends RedisScript>(script: S, args: Array<unknown>): Promise<RedisCommandReply<S>>;
executeScript(script: RedisScript, originalArgs: Array<unknown>, redisArgs: RedisCommandArguments, options?: ClientCommandOptions): Promise<RedisCommandRawReply>;
MULTI(routing?: RedisCommandArgument): RedisClusterMultiCommandType<M, F, S>;
multi: (routing?: RedisCommandArgument) => RedisClusterMultiCommandType<M, F, S>;
SUBSCRIBE<T extends boolean = false>(channels: string | Array<string>, listener: PubSubListener<T>, bufferMode?: T): Promise<void>;
subscribe: <T extends boolean = false>(channels: string | Array<string>, listener: PubSubListener<T>, bufferMode?: T | undefined) => Promise<void>;
UNSUBSCRIBE<T extends boolean = false>(channels?: string | Array<string>, listener?: PubSubListener<boolean>, bufferMode?: T): Promise<void>;
unsubscribe: <T extends boolean = false>(channels?: string | Array<string>, listener?: PubSubListener<boolean>, bufferMode?: T | undefined) => Promise<void>;
PSUBSCRIBE<T extends boolean = false>(patterns: string | Array<string>, listener: PubSubListener<T>, bufferMode?: T): Promise<void>;
pSubscribe: <T extends boolean = false>(patterns: string | Array<string>, listener: PubSubListener<T>, bufferMode?: T | undefined) => Promise<void>;
PUNSUBSCRIBE<T extends boolean = false>(patterns?: string | Array<string>, listener?: PubSubListener<T>, bufferMode?: T): Promise<void>;
pUnsubscribe: <T extends boolean = false>(patterns?: string | Array<string>, listener?: PubSubListener<T> | undefined, bufferMode?: T | undefined) => Promise<void>;
SSUBSCRIBE<T extends boolean = false>(channels: string | Array<string>, listener: PubSubListener<T>, bufferMode?: T): Promise<void>;
sSubscribe: <T extends boolean = false>(channels: string | Array<string>, listener: PubSubListener<T>, bufferMode?: T | undefined) => Promise<void>;
SUNSUBSCRIBE<T extends boolean = false>(channels: string | Array<string>, listener?: PubSubListener<T>, bufferMode?: T): Promise<void>;
sUnsubscribe: <T extends boolean = false>(channels: string | Array<string>, listener?: PubSubListener<T> | undefined, bufferMode?: T | undefined) => Promise<void>;
quit(): Promise<void>;
disconnect(): Promise<void>;
nodeClient(node: ShardNode<M, F, S>): RedisClientType<M, F, S> | Promise<RedisClientType<M, F, S>>;
getRandomNode(): ShardNode<M, F, S>;
getSlotRandomNode(slot: number): ShardNode<M, F, S>;
/**
* @deprecated use `.masters` instead
*/
getMasters(): ShardNode<M, F, S>[];
/**
* @deprecated use `.slots[<SLOT>]` instead
*/
getSlotMaster(slot: number): import("./cluster-slots").MasterNode<M, F, S>;
}
export {};

View File

@@ -0,0 +1,254 @@
"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _RedisCluster_instances, _RedisCluster_options, _RedisCluster_slots, _RedisCluster_Multi, _RedisCluster_execute;
Object.defineProperty(exports, "__esModule", { value: true });
const commands_1 = require("./commands");
const cluster_slots_1 = require("./cluster-slots");
const commander_1 = require("../commander");
const events_1 = require("events");
const multi_command_1 = require("./multi-command");
const errors_1 = require("../errors");
class RedisCluster extends events_1.EventEmitter {
static extractFirstKey(command, originalArgs, redisArgs) {
if (command.FIRST_KEY_INDEX === undefined) {
return undefined;
}
else if (typeof command.FIRST_KEY_INDEX === 'number') {
return redisArgs[command.FIRST_KEY_INDEX];
}
return command.FIRST_KEY_INDEX(...originalArgs);
}
static create(options) {
return new ((0, commander_1.attachExtensions)({
BaseClass: RedisCluster,
modulesExecutor: RedisCluster.prototype.commandsExecutor,
modules: options?.modules,
functionsExecutor: RedisCluster.prototype.functionsExecutor,
functions: options?.functions,
scriptsExecutor: RedisCluster.prototype.scriptsExecutor,
scripts: options?.scripts
}))(options);
}
get slots() {
return __classPrivateFieldGet(this, _RedisCluster_slots, "f").slots;
}
get shards() {
return __classPrivateFieldGet(this, _RedisCluster_slots, "f").shards;
}
get masters() {
return __classPrivateFieldGet(this, _RedisCluster_slots, "f").masters;
}
get replicas() {
return __classPrivateFieldGet(this, _RedisCluster_slots, "f").replicas;
}
get nodeByAddress() {
return __classPrivateFieldGet(this, _RedisCluster_slots, "f").nodeByAddress;
}
get pubSubNode() {
return __classPrivateFieldGet(this, _RedisCluster_slots, "f").pubSubNode;
}
get isOpen() {
return __classPrivateFieldGet(this, _RedisCluster_slots, "f").isOpen;
}
constructor(options) {
super();
_RedisCluster_instances.add(this);
_RedisCluster_options.set(this, void 0);
_RedisCluster_slots.set(this, void 0);
_RedisCluster_Multi.set(this, void 0);
Object.defineProperty(this, "multi", {
enumerable: true,
configurable: true,
writable: true,
value: this.MULTI
});
Object.defineProperty(this, "subscribe", {
enumerable: true,
configurable: true,
writable: true,
value: this.SUBSCRIBE
});
Object.defineProperty(this, "unsubscribe", {
enumerable: true,
configurable: true,
writable: true,
value: this.UNSUBSCRIBE
});
Object.defineProperty(this, "pSubscribe", {
enumerable: true,
configurable: true,
writable: true,
value: this.PSUBSCRIBE
});
Object.defineProperty(this, "pUnsubscribe", {
enumerable: true,
configurable: true,
writable: true,
value: this.PUNSUBSCRIBE
});
Object.defineProperty(this, "sSubscribe", {
enumerable: true,
configurable: true,
writable: true,
value: this.SSUBSCRIBE
});
Object.defineProperty(this, "sUnsubscribe", {
enumerable: true,
configurable: true,
writable: true,
value: this.SUNSUBSCRIBE
});
__classPrivateFieldSet(this, _RedisCluster_options, options, "f");
__classPrivateFieldSet(this, _RedisCluster_slots, new cluster_slots_1.default(options, this.emit.bind(this)), "f");
__classPrivateFieldSet(this, _RedisCluster_Multi, multi_command_1.default.extend(options), "f");
}
duplicate(overrides) {
return new (Object.getPrototypeOf(this).constructor)({
...__classPrivateFieldGet(this, _RedisCluster_options, "f"),
...overrides
});
}
connect() {
return __classPrivateFieldGet(this, _RedisCluster_slots, "f").connect();
}
async commandsExecutor(command, args) {
const { jsArgs, args: redisArgs, options } = (0, commander_1.transformCommandArguments)(command, args);
return (0, commander_1.transformCommandReply)(command, await this.sendCommand(RedisCluster.extractFirstKey(command, jsArgs, redisArgs), command.IS_READ_ONLY, redisArgs, options), redisArgs.preserve);
}
async sendCommand(firstKey, isReadonly, args, options) {
return __classPrivateFieldGet(this, _RedisCluster_instances, "m", _RedisCluster_execute).call(this, firstKey, isReadonly, client => client.sendCommand(args, options));
}
async functionsExecutor(fn, args, name) {
const { args: redisArgs, options } = (0, commander_1.transformCommandArguments)(fn, args);
return (0, commander_1.transformCommandReply)(fn, await this.executeFunction(name, fn, args, redisArgs, options), redisArgs.preserve);
}
async executeFunction(name, fn, originalArgs, redisArgs, options) {
return __classPrivateFieldGet(this, _RedisCluster_instances, "m", _RedisCluster_execute).call(this, RedisCluster.extractFirstKey(fn, originalArgs, redisArgs), fn.IS_READ_ONLY, client => client.executeFunction(name, fn, redisArgs, options));
}
async scriptsExecutor(script, args) {
const { args: redisArgs, options } = (0, commander_1.transformCommandArguments)(script, args);
return (0, commander_1.transformCommandReply)(script, await this.executeScript(script, args, redisArgs, options), redisArgs.preserve);
}
async executeScript(script, originalArgs, redisArgs, options) {
return __classPrivateFieldGet(this, _RedisCluster_instances, "m", _RedisCluster_execute).call(this, RedisCluster.extractFirstKey(script, originalArgs, redisArgs), script.IS_READ_ONLY, client => client.executeScript(script, redisArgs, options));
}
MULTI(routing) {
return new (__classPrivateFieldGet(this, _RedisCluster_Multi, "f"))((commands, firstKey, chainId) => {
return __classPrivateFieldGet(this, _RedisCluster_instances, "m", _RedisCluster_execute).call(this, firstKey, false, client => client.multiExecutor(commands, undefined, chainId));
}, routing);
}
async SUBSCRIBE(channels, listener, bufferMode) {
return (await __classPrivateFieldGet(this, _RedisCluster_slots, "f").getPubSubClient())
.SUBSCRIBE(channels, listener, bufferMode);
}
async UNSUBSCRIBE(channels, listener, bufferMode) {
return __classPrivateFieldGet(this, _RedisCluster_slots, "f").executeUnsubscribeCommand(client => client.UNSUBSCRIBE(channels, listener, bufferMode));
}
async PSUBSCRIBE(patterns, listener, bufferMode) {
return (await __classPrivateFieldGet(this, _RedisCluster_slots, "f").getPubSubClient())
.PSUBSCRIBE(patterns, listener, bufferMode);
}
async PUNSUBSCRIBE(patterns, listener, bufferMode) {
return __classPrivateFieldGet(this, _RedisCluster_slots, "f").executeUnsubscribeCommand(client => client.PUNSUBSCRIBE(patterns, listener, bufferMode));
}
async SSUBSCRIBE(channels, listener, bufferMode) {
const maxCommandRedirections = __classPrivateFieldGet(this, _RedisCluster_options, "f").maxCommandRedirections ?? 16, firstChannel = Array.isArray(channels) ? channels[0] : channels;
let client = await __classPrivateFieldGet(this, _RedisCluster_slots, "f").getShardedPubSubClient(firstChannel);
for (let i = 0;; i++) {
try {
return await client.SSUBSCRIBE(channels, listener, bufferMode);
}
catch (err) {
if (++i > maxCommandRedirections || !(err instanceof errors_1.ErrorReply)) {
throw err;
}
if (err.message.startsWith('MOVED')) {
await __classPrivateFieldGet(this, _RedisCluster_slots, "f").rediscover(client);
client = await __classPrivateFieldGet(this, _RedisCluster_slots, "f").getShardedPubSubClient(firstChannel);
continue;
}
throw err;
}
}
}
SUNSUBSCRIBE(channels, listener, bufferMode) {
return __classPrivateFieldGet(this, _RedisCluster_slots, "f").executeShardedUnsubscribeCommand(Array.isArray(channels) ? channels[0] : channels, client => client.SUNSUBSCRIBE(channels, listener, bufferMode));
}
quit() {
return __classPrivateFieldGet(this, _RedisCluster_slots, "f").quit();
}
disconnect() {
return __classPrivateFieldGet(this, _RedisCluster_slots, "f").disconnect();
}
nodeClient(node) {
return __classPrivateFieldGet(this, _RedisCluster_slots, "f").nodeClient(node);
}
getRandomNode() {
return __classPrivateFieldGet(this, _RedisCluster_slots, "f").getRandomNode();
}
getSlotRandomNode(slot) {
return __classPrivateFieldGet(this, _RedisCluster_slots, "f").getSlotRandomNode(slot);
}
/**
* @deprecated use `.masters` instead
*/
getMasters() {
return this.masters;
}
/**
* @deprecated use `.slots[<SLOT>]` instead
*/
getSlotMaster(slot) {
return this.slots[slot].master;
}
}
_RedisCluster_options = new WeakMap(), _RedisCluster_slots = new WeakMap(), _RedisCluster_Multi = new WeakMap(), _RedisCluster_instances = new WeakSet(), _RedisCluster_execute = async function _RedisCluster_execute(firstKey, isReadonly, executor) {
const maxCommandRedirections = __classPrivateFieldGet(this, _RedisCluster_options, "f").maxCommandRedirections ?? 16;
let client = await __classPrivateFieldGet(this, _RedisCluster_slots, "f").getClient(firstKey, isReadonly);
for (let i = 0;; i++) {
try {
return await executor(client);
}
catch (err) {
if (++i > maxCommandRedirections || !(err instanceof errors_1.ErrorReply)) {
throw err;
}
if (err.message.startsWith('ASK')) {
const address = err.message.substring(err.message.lastIndexOf(' ') + 1);
let redirectTo = await __classPrivateFieldGet(this, _RedisCluster_slots, "f").getMasterByAddress(address);
if (!redirectTo) {
await __classPrivateFieldGet(this, _RedisCluster_slots, "f").rediscover(client);
redirectTo = await __classPrivateFieldGet(this, _RedisCluster_slots, "f").getMasterByAddress(address);
}
if (!redirectTo) {
throw new Error(`Cannot find node ${address}`);
}
await redirectTo.asking();
client = redirectTo;
continue;
}
else if (err.message.startsWith('MOVED')) {
await __classPrivateFieldGet(this, _RedisCluster_slots, "f").rediscover(client);
client = await __classPrivateFieldGet(this, _RedisCluster_slots, "f").getClient(firstKey, isReadonly);
continue;
}
throw err;
}
}
};
exports.default = RedisCluster;
(0, commander_1.attachCommands)({
BaseClass: RedisCluster,
commands: commands_1.default,
executor: RedisCluster.prototype.commandsExecutor
});

View File

@@ -0,0 +1,36 @@
import COMMANDS from './commands';
import { RedisCommand, RedisCommandArgument, RedisCommandArguments, RedisCommandRawReply, RedisFunctions, RedisModules, RedisExtensions, RedisScript, RedisScripts, ExcludeMappedString, RedisFunction } from '../commands';
import { RedisMultiQueuedCommand } from '../multi-command';
type RedisClusterMultiCommandSignature<C extends RedisCommand, M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> = (...args: Parameters<C['transformArguments']>) => RedisClusterMultiCommandType<M, F, S>;
type WithCommands<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> = {
[P in keyof typeof COMMANDS]: RedisClusterMultiCommandSignature<(typeof COMMANDS)[P], M, F, S>;
};
type WithModules<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> = {
[P in keyof M as ExcludeMappedString<P>]: {
[C in keyof M[P] as ExcludeMappedString<C>]: RedisClusterMultiCommandSignature<M[P][C], M, F, S>;
};
};
type WithFunctions<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> = {
[P in keyof F as ExcludeMappedString<P>]: {
[FF in keyof F[P] as ExcludeMappedString<FF>]: RedisClusterMultiCommandSignature<F[P][FF], M, F, S>;
};
};
type WithScripts<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> = {
[P in keyof S as ExcludeMappedString<P>]: RedisClusterMultiCommandSignature<S[P], M, F, S>;
};
export type RedisClusterMultiCommandType<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> = RedisClusterMultiCommand & WithCommands<M, F, S> & WithModules<M, F, S> & WithFunctions<M, F, S> & WithScripts<M, F, S>;
export type InstantiableRedisClusterMultiCommandType<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts> = new (...args: ConstructorParameters<typeof RedisClusterMultiCommand>) => RedisClusterMultiCommandType<M, F, S>;
export type RedisClusterMultiExecutor = (queue: Array<RedisMultiQueuedCommand>, firstKey?: RedisCommandArgument, chainId?: symbol) => Promise<Array<RedisCommandRawReply>>;
export default class RedisClusterMultiCommand {
#private;
static extend<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts>(extensions?: RedisExtensions<M, F, S>): InstantiableRedisClusterMultiCommandType<M, F, S>;
constructor(executor: RedisClusterMultiExecutor, firstKey?: RedisCommandArgument);
commandsExecutor(command: RedisCommand, args: Array<unknown>): this;
addCommand(firstKey: RedisCommandArgument | undefined, args: RedisCommandArguments, transformReply?: RedisCommand['transformReply']): this;
functionsExecutor(fn: RedisFunction, args: Array<unknown>, name: string): this;
scriptsExecutor(script: RedisScript, args: Array<unknown>): this;
exec(execAsPipeline?: boolean): Promise<Array<RedisCommandRawReply>>;
EXEC: (execAsPipeline?: boolean) => Promise<Array<RedisCommandRawReply>>;
execAsPipeline(): Promise<Array<RedisCommandRawReply>>;
}
export {};

View File

@@ -0,0 +1,80 @@
"use strict";
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _RedisClusterMultiCommand_multi, _RedisClusterMultiCommand_executor, _RedisClusterMultiCommand_firstKey;
Object.defineProperty(exports, "__esModule", { value: true });
const commands_1 = require("./commands");
const multi_command_1 = require("../multi-command");
const commander_1 = require("../commander");
const _1 = require(".");
class RedisClusterMultiCommand {
static extend(extensions) {
return (0, commander_1.attachExtensions)({
BaseClass: RedisClusterMultiCommand,
modulesExecutor: RedisClusterMultiCommand.prototype.commandsExecutor,
modules: extensions?.modules,
functionsExecutor: RedisClusterMultiCommand.prototype.functionsExecutor,
functions: extensions?.functions,
scriptsExecutor: RedisClusterMultiCommand.prototype.scriptsExecutor,
scripts: extensions?.scripts
});
}
constructor(executor, firstKey) {
_RedisClusterMultiCommand_multi.set(this, new multi_command_1.default());
_RedisClusterMultiCommand_executor.set(this, void 0);
_RedisClusterMultiCommand_firstKey.set(this, void 0);
Object.defineProperty(this, "EXEC", {
enumerable: true,
configurable: true,
writable: true,
value: this.exec
});
__classPrivateFieldSet(this, _RedisClusterMultiCommand_executor, executor, "f");
__classPrivateFieldSet(this, _RedisClusterMultiCommand_firstKey, firstKey, "f");
}
commandsExecutor(command, args) {
const transformedArguments = command.transformArguments(...args);
__classPrivateFieldSet(this, _RedisClusterMultiCommand_firstKey, __classPrivateFieldGet(this, _RedisClusterMultiCommand_firstKey, "f") ?? _1.default.extractFirstKey(command, args, transformedArguments), "f");
return this.addCommand(undefined, transformedArguments, command.transformReply);
}
addCommand(firstKey, args, transformReply) {
__classPrivateFieldSet(this, _RedisClusterMultiCommand_firstKey, __classPrivateFieldGet(this, _RedisClusterMultiCommand_firstKey, "f") ?? firstKey, "f");
__classPrivateFieldGet(this, _RedisClusterMultiCommand_multi, "f").addCommand(args, transformReply);
return this;
}
functionsExecutor(fn, args, name) {
const transformedArguments = __classPrivateFieldGet(this, _RedisClusterMultiCommand_multi, "f").addFunction(name, fn, args);
__classPrivateFieldSet(this, _RedisClusterMultiCommand_firstKey, __classPrivateFieldGet(this, _RedisClusterMultiCommand_firstKey, "f") ?? _1.default.extractFirstKey(fn, args, transformedArguments), "f");
return this;
}
scriptsExecutor(script, args) {
const transformedArguments = __classPrivateFieldGet(this, _RedisClusterMultiCommand_multi, "f").addScript(script, args);
__classPrivateFieldSet(this, _RedisClusterMultiCommand_firstKey, __classPrivateFieldGet(this, _RedisClusterMultiCommand_firstKey, "f") ?? _1.default.extractFirstKey(script, args, transformedArguments), "f");
return this;
}
async exec(execAsPipeline = false) {
if (execAsPipeline) {
return this.execAsPipeline();
}
return __classPrivateFieldGet(this, _RedisClusterMultiCommand_multi, "f").handleExecReplies(await __classPrivateFieldGet(this, _RedisClusterMultiCommand_executor, "f").call(this, __classPrivateFieldGet(this, _RedisClusterMultiCommand_multi, "f").queue, __classPrivateFieldGet(this, _RedisClusterMultiCommand_firstKey, "f"), multi_command_1.default.generateChainId()));
}
async execAsPipeline() {
return __classPrivateFieldGet(this, _RedisClusterMultiCommand_multi, "f").transformReplies(await __classPrivateFieldGet(this, _RedisClusterMultiCommand_executor, "f").call(this, __classPrivateFieldGet(this, _RedisClusterMultiCommand_multi, "f").queue, __classPrivateFieldGet(this, _RedisClusterMultiCommand_firstKey, "f")));
}
}
_RedisClusterMultiCommand_multi = new WeakMap(), _RedisClusterMultiCommand_executor = new WeakMap(), _RedisClusterMultiCommand_firstKey = new WeakMap();
exports.default = RedisClusterMultiCommand;
(0, commander_1.attachCommands)({
BaseClass: RedisClusterMultiCommand,
commands: commands_1.default,
executor: RedisClusterMultiCommand.prototype.commandsExecutor
});

View File

@@ -0,0 +1,7 @@
declare const symbol: unique symbol;
export type CommandOptions<T> = T & {
readonly [symbol]: true;
};
export declare function commandOptions<T>(options: T): CommandOptions<T>;
export declare function isCommandOptions<T>(options: any): options is CommandOptions<T>;
export {};

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isCommandOptions = exports.commandOptions = void 0;
const symbol = Symbol('Command Options');
function commandOptions(options) {
options[symbol] = true;
return options;
}
exports.commandOptions = commandOptions;
function isCommandOptions(options) {
return options?.[symbol] === true;
}
exports.isCommandOptions = isCommandOptions;

View File

@@ -0,0 +1,30 @@
import { ClientCommandOptions } from './client';
import { CommandOptions } from './command-options';
import { RedisCommand, RedisCommandArgument, RedisCommandArguments, RedisCommandReply, RedisFunction, RedisFunctions, RedisModules, RedisScript, RedisScripts } from './commands';
type Instantiable<T = any> = new (...args: Array<any>) => T;
type CommandsExecutor<C extends RedisCommand = RedisCommand> = (command: C, args: Array<unknown>, name: string) => unknown;
interface AttachCommandsConfig<C extends RedisCommand> {
BaseClass: Instantiable;
commands: Record<string, C>;
executor: CommandsExecutor<C>;
}
export declare function attachCommands<C extends RedisCommand>({ BaseClass, commands, executor }: AttachCommandsConfig<C>): void;
interface AttachExtensionsConfig<T extends Instantiable = Instantiable> {
BaseClass: T;
modulesExecutor: CommandsExecutor;
modules?: RedisModules;
functionsExecutor: CommandsExecutor<RedisFunction>;
functions?: RedisFunctions;
scriptsExecutor: CommandsExecutor<RedisScript>;
scripts?: RedisScripts;
}
export declare function attachExtensions(config: AttachExtensionsConfig): any;
export declare function transformCommandArguments<T = ClientCommandOptions>(command: RedisCommand, args: Array<unknown>): {
jsArgs: Array<unknown>;
args: RedisCommandArguments;
options: CommandOptions<T> | undefined;
};
export declare function transformLegacyCommandArguments(args: Array<any>): Array<any>;
export declare function transformCommandReply<C extends RedisCommand>(command: C, rawReply: unknown, preserved: unknown): RedisCommandReply<C>;
export declare function fCallArguments(name: RedisCommandArgument, fn: RedisFunction, args: RedisCommandArguments): RedisCommandArguments;
export {};

View File

@@ -0,0 +1,103 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fCallArguments = exports.transformCommandReply = exports.transformLegacyCommandArguments = exports.transformCommandArguments = exports.attachExtensions = exports.attachCommands = void 0;
const command_options_1 = require("./command-options");
function attachCommands({ BaseClass, commands, executor }) {
for (const [name, command] of Object.entries(commands)) {
BaseClass.prototype[name] = function (...args) {
return executor.call(this, command, args, name);
};
}
}
exports.attachCommands = attachCommands;
function attachExtensions(config) {
let Commander;
if (config.modules) {
Commander = attachWithNamespaces({
BaseClass: config.BaseClass,
namespaces: config.modules,
executor: config.modulesExecutor
});
}
if (config.functions) {
Commander = attachWithNamespaces({
BaseClass: Commander ?? config.BaseClass,
namespaces: config.functions,
executor: config.functionsExecutor
});
}
if (config.scripts) {
Commander ?? (Commander = class extends config.BaseClass {
});
attachCommands({
BaseClass: Commander,
commands: config.scripts,
executor: config.scriptsExecutor
});
}
return Commander ?? config.BaseClass;
}
exports.attachExtensions = attachExtensions;
function attachWithNamespaces({ BaseClass, namespaces, executor }) {
const Commander = class extends BaseClass {
constructor(...args) {
super(...args);
for (const namespace of Object.keys(namespaces)) {
this[namespace] = Object.create(this[namespace], {
self: {
value: this
}
});
}
}
};
for (const [namespace, commands] of Object.entries(namespaces)) {
Commander.prototype[namespace] = {};
for (const [name, command] of Object.entries(commands)) {
Commander.prototype[namespace][name] = function (...args) {
return executor.call(this.self, command, args, name);
};
}
}
return Commander;
}
function transformCommandArguments(command, args) {
let options;
if ((0, command_options_1.isCommandOptions)(args[0])) {
options = args[0];
args = args.slice(1);
}
return {
jsArgs: args,
args: command.transformArguments(...args),
options
};
}
exports.transformCommandArguments = transformCommandArguments;
function transformLegacyCommandArguments(args) {
return args.flat().map(arg => {
return typeof arg === 'number' || arg instanceof Date ?
arg.toString() :
arg;
});
}
exports.transformLegacyCommandArguments = transformLegacyCommandArguments;
function transformCommandReply(command, rawReply, preserved) {
if (!command.transformReply) {
return rawReply;
}
return command.transformReply(rawReply, preserved);
}
exports.transformCommandReply = transformCommandReply;
function fCallArguments(name, fn, args) {
const actualArgs = [
fn.IS_READ_ONLY ? 'FCALL_RO' : 'FCALL',
name
];
if (fn.NUMBER_OF_KEYS !== undefined) {
actualArgs.push(fn.NUMBER_OF_KEYS.toString());
}
actualArgs.push(...args);
return actualArgs;
}
exports.fCallArguments = fCallArguments;

View File

@@ -0,0 +1,3 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare function transformArguments(categoryName?: RedisCommandArgument): RedisCommandArguments;
export declare function transformReply(): Array<RedisCommandArgument>;

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments(categoryName) {
const args = ['ACL', 'CAT'];
if (categoryName) {
args.push(categoryName);
}
return args;
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,3 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare function transformArguments(username: RedisCommandArgument | Array<RedisCommandArgument>): RedisCommandArguments;
export declare function transformReply(): number;

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
const generic_transformers_1 = require("./generic-transformers");
function transformArguments(username) {
return (0, generic_transformers_1.pushVerdictArguments)(['ACL', 'DELUSER'], username);
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,4 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare const IS_READ_ONLY = true;
export declare function transformArguments(username: RedisCommandArgument, command: Array<RedisCommandArgument>): RedisCommandArguments;
export declare function transformReply(): RedisCommandArgument;

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = exports.IS_READ_ONLY = void 0;
exports.IS_READ_ONLY = true;
function transformArguments(username, command) {
return [
'ACL',
'DRYRUN',
username,
...command
];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,3 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare function transformArguments(bits?: number): RedisCommandArguments;
export declare function transformReply(): RedisCommandArgument;

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments(bits) {
const args = ['ACL', 'GENPASS'];
if (bits) {
args.push(bits.toString());
}
return args;
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,26 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare function transformArguments(username: RedisCommandArgument): RedisCommandArguments;
type AclGetUserRawReply = [
'flags',
Array<RedisCommandArgument>,
'passwords',
Array<RedisCommandArgument>,
'commands',
RedisCommandArgument,
'keys',
Array<RedisCommandArgument> | RedisCommandArgument,
'channels',
Array<RedisCommandArgument> | RedisCommandArgument,
'selectors' | undefined,
Array<Array<string>> | undefined
];
interface AclUser {
flags: Array<RedisCommandArgument>;
passwords: Array<RedisCommandArgument>;
commands: RedisCommandArgument;
keys: Array<RedisCommandArgument> | RedisCommandArgument;
channels: Array<RedisCommandArgument> | RedisCommandArgument;
selectors?: Array<Array<string>>;
}
export declare function transformReply(reply: AclGetUserRawReply): AclUser;
export {};

View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = void 0;
function transformArguments(username) {
return ['ACL', 'GETUSER', username];
}
exports.transformArguments = transformArguments;
function transformReply(reply) {
return {
flags: reply[1],
passwords: reply[3],
commands: reply[5],
keys: reply[7],
channels: reply[9],
selectors: reply[11]
};
}
exports.transformReply = transformReply;

View File

@@ -0,0 +1,3 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare function transformArguments(): RedisCommandArguments;
export declare function transformReply(): Array<RedisCommandArgument>;

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments() {
return ['ACL', 'LIST'];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,3 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare function transformArguments(): RedisCommandArguments;
export declare function transformReply(): RedisCommandArgument;

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments() {
return ['ACL', 'LOAD'];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,29 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare function transformArguments(count?: number): RedisCommandArguments;
type AclLogRawReply = [
_: RedisCommandArgument,
count: number,
_: RedisCommandArgument,
reason: RedisCommandArgument,
_: RedisCommandArgument,
context: RedisCommandArgument,
_: RedisCommandArgument,
object: RedisCommandArgument,
_: RedisCommandArgument,
username: RedisCommandArgument,
_: RedisCommandArgument,
ageSeconds: RedisCommandArgument,
_: RedisCommandArgument,
clientInfo: RedisCommandArgument
];
interface AclLog {
count: number;
reason: RedisCommandArgument;
context: RedisCommandArgument;
object: RedisCommandArgument;
username: RedisCommandArgument;
ageSeconds: number;
clientInfo: RedisCommandArgument;
}
export declare function transformReply(reply: Array<AclLogRawReply>): Array<AclLog>;
export {};

View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = void 0;
function transformArguments(count) {
const args = ['ACL', 'LOG'];
if (count) {
args.push(count.toString());
}
return args;
}
exports.transformArguments = transformArguments;
function transformReply(reply) {
return reply.map(log => ({
count: log[1],
reason: log[3],
context: log[5],
object: log[7],
username: log[9],
ageSeconds: Number(log[11]),
clientInfo: log[13]
}));
}
exports.transformReply = transformReply;

View File

@@ -0,0 +1,3 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare function transformArguments(): RedisCommandArguments;
export declare function transformReply(): RedisCommandArgument;

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments() {
return ['ACL', 'LOG', 'RESET'];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,3 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare function transformArguments(): RedisCommandArguments;
export declare function transformReply(): RedisCommandArgument;

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments() {
return ['ACL', 'SAVE'];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,3 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare function transformArguments(username: RedisCommandArgument, rule: RedisCommandArgument | Array<RedisCommandArgument>): RedisCommandArguments;
export declare function transformReply(): RedisCommandArgument;

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
const generic_transformers_1 = require("./generic-transformers");
function transformArguments(username, rule) {
return (0, generic_transformers_1.pushVerdictArguments)(['ACL', 'SETUSER', username], rule);
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,3 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare function transformArguments(): RedisCommandArguments;
export declare function transformReply(): Array<RedisCommandArgument>;

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments() {
return ['ACL', 'USERS'];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,3 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare function transformArguments(): RedisCommandArguments;
export declare function transformReply(): RedisCommandArgument;

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments() {
return ['ACL', 'WHOAMI'];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,4 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare const FIRST_KEY_INDEX = 1;
export declare function transformArguments(key: RedisCommandArgument, value: RedisCommandArgument): RedisCommandArguments;
export declare function transformReply(): number;

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = exports.FIRST_KEY_INDEX = void 0;
exports.FIRST_KEY_INDEX = 1;
function transformArguments(key, value) {
return ['APPEND', key, value];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,3 @@
import { RedisCommandArguments, RedisCommandArgument } from '.';
export declare function transformArguments(): RedisCommandArguments;
export declare function transformReply(): RedisCommandArgument;

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments() {
return ['ASKING'];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,7 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export interface AuthOptions {
username?: RedisCommandArgument;
password: RedisCommandArgument;
}
export declare function transformArguments({ username, password }: AuthOptions): RedisCommandArguments;
export declare function transformReply(): RedisCommandArgument;

View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments({ username, password }) {
if (!username) {
return ['AUTH', password];
}
return ['AUTH', username, password];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,3 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare function transformArguments(): RedisCommandArguments;
export declare function transformReply(): RedisCommandArgument;

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments() {
return ['BGREWRITEAOF'];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,7 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
interface BgSaveOptions {
SCHEDULE?: true;
}
export declare function transformArguments(options?: BgSaveOptions): RedisCommandArguments;
export declare function transformReply(): RedisCommandArgument;
export {};

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments(options) {
const args = ['BGSAVE'];
if (options?.SCHEDULE) {
args.push('SCHEDULE');
}
return args;
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,11 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare const FIRST_KEY_INDEX = 1;
export declare const IS_READ_ONLY = true;
interface BitCountRange {
start: number;
end: number;
mode?: 'BYTE' | 'BIT';
}
export declare function transformArguments(key: RedisCommandArgument, range?: BitCountRange): RedisCommandArguments;
export declare function transformReply(): number;
export {};

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = exports.IS_READ_ONLY = exports.FIRST_KEY_INDEX = void 0;
exports.FIRST_KEY_INDEX = 1;
exports.IS_READ_ONLY = true;
function transformArguments(key, range) {
const args = ['BITCOUNT', key];
if (range) {
args.push(range.start.toString(), range.end.toString());
if (range.mode) {
args.push(range.mode);
}
}
return args;
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,26 @@
export declare const FIRST_KEY_INDEX = 1;
export type BitFieldEncoding = `${'i' | 'u'}${number}`;
export interface BitFieldOperation<S extends string> {
operation: S;
}
export interface BitFieldGetOperation extends BitFieldOperation<'GET'> {
encoding: BitFieldEncoding;
offset: number | string;
}
interface BitFieldSetOperation extends BitFieldOperation<'SET'> {
encoding: BitFieldEncoding;
offset: number | string;
value: number;
}
interface BitFieldIncrByOperation extends BitFieldOperation<'INCRBY'> {
encoding: BitFieldEncoding;
offset: number | string;
increment: number;
}
interface BitFieldOverflowOperation extends BitFieldOperation<'OVERFLOW'> {
behavior: string;
}
type BitFieldOperations = Array<BitFieldGetOperation | BitFieldSetOperation | BitFieldIncrByOperation | BitFieldOverflowOperation>;
export declare function transformArguments(key: string, operations: BitFieldOperations): Array<string>;
export declare function transformReply(): Array<number | null>;
export {};

View File

@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = exports.FIRST_KEY_INDEX = void 0;
exports.FIRST_KEY_INDEX = 1;
function transformArguments(key, operations) {
const args = ['BITFIELD', key];
for (const options of operations) {
switch (options.operation) {
case 'GET':
args.push('GET', options.encoding, options.offset.toString());
break;
case 'SET':
args.push('SET', options.encoding, options.offset.toString(), options.value.toString());
break;
case 'INCRBY':
args.push('INCRBY', options.encoding, options.offset.toString(), options.increment.toString());
break;
case 'OVERFLOW':
args.push('OVERFLOW', options.behavior);
break;
}
}
return args;
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,7 @@
import { BitFieldGetOperation } from './BITFIELD';
export declare const FIRST_KEY_INDEX = 1;
export declare const IS_READ_ONLY = true;
type BitFieldRoOperations = Array<Omit<BitFieldGetOperation, 'operation'> & Partial<Pick<BitFieldGetOperation, 'operation'>>>;
export declare function transformArguments(key: string, operations: BitFieldRoOperations): Array<string>;
export declare function transformReply(): Array<number | null>;
export {};

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = exports.IS_READ_ONLY = exports.FIRST_KEY_INDEX = void 0;
exports.FIRST_KEY_INDEX = 1;
exports.IS_READ_ONLY = true;
function transformArguments(key, operations) {
const args = ['BITFIELD_RO', key];
for (const operation of operations) {
args.push('GET', operation.encoding, operation.offset.toString());
}
return args;
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,6 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare const FIRST_KEY_INDEX = 2;
type BitOperations = 'AND' | 'OR' | 'XOR' | 'NOT';
export declare function transformArguments(operation: BitOperations, destKey: RedisCommandArgument, key: RedisCommandArgument | Array<RedisCommandArgument>): RedisCommandArguments;
export declare function transformReply(): number;
export {};

View File

@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = exports.FIRST_KEY_INDEX = void 0;
const generic_transformers_1 = require("./generic-transformers");
exports.FIRST_KEY_INDEX = 2;
function transformArguments(operation, destKey, key) {
return (0, generic_transformers_1.pushVerdictArguments)(['BITOP', operation, destKey], key);
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,6 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
import { BitValue } from './generic-transformers';
export declare const FIRST_KEY_INDEX = 1;
export declare const IS_READ_ONLY = true;
export declare function transformArguments(key: RedisCommandArgument, bit: BitValue, start?: number, end?: number, mode?: 'BYTE' | 'BIT'): RedisCommandArguments;
export declare function transformReply(): number;

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = exports.IS_READ_ONLY = exports.FIRST_KEY_INDEX = void 0;
exports.FIRST_KEY_INDEX = 1;
exports.IS_READ_ONLY = true;
function transformArguments(key, bit, start, end, mode) {
const args = ['BITPOS', key, bit.toString()];
if (typeof start === 'number') {
args.push(start.toString());
}
if (typeof end === 'number') {
args.push(end.toString());
}
if (mode) {
args.push(mode);
}
return args;
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,5 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
import { ListSide } from './generic-transformers';
export declare const FIRST_KEY_INDEX = 1;
export declare function transformArguments(source: RedisCommandArgument, destination: RedisCommandArgument, sourceDirection: ListSide, destinationDirection: ListSide, timeout: number): RedisCommandArguments;
export declare function transformReply(): RedisCommandArgument | null;

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = exports.FIRST_KEY_INDEX = void 0;
exports.FIRST_KEY_INDEX = 1;
function transformArguments(source, destination, sourceDirection, destinationDirection, timeout) {
return [
'BLMOVE',
source,
destination,
sourceDirection,
destinationDirection,
timeout.toString()
];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,5 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
import { LMPopOptions, ListSide } from './generic-transformers';
export declare const FIRST_KEY_INDEX = 3;
export declare function transformArguments(timeout: number, keys: RedisCommandArgument | Array<RedisCommandArgument>, side: ListSide, options?: LMPopOptions): RedisCommandArguments;
export { transformReply } from './LMPOP';

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.FIRST_KEY_INDEX = void 0;
const generic_transformers_1 = require("./generic-transformers");
exports.FIRST_KEY_INDEX = 3;
function transformArguments(timeout, keys, side, options) {
return (0, generic_transformers_1.transformLMPopArguments)(['BLMPOP', timeout.toString()], keys, side, options);
}
exports.transformArguments = transformArguments;
var LMPOP_1 = require("./LMPOP");
Object.defineProperty(exports, "transformReply", { enumerable: true, get: function () { return LMPOP_1.transformReply; } });

View File

@@ -0,0 +1,10 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare const FIRST_KEY_INDEX = 1;
export declare function transformArguments(keys: RedisCommandArgument | Array<RedisCommandArgument>, timeout: number): RedisCommandArguments;
type BLPopRawReply = null | [RedisCommandArgument, RedisCommandArgument];
type BLPopReply = null | {
key: RedisCommandArgument;
element: RedisCommandArgument;
};
export declare function transformReply(reply: BLPopRawReply): BLPopReply;
export {};

View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.FIRST_KEY_INDEX = void 0;
const generic_transformers_1 = require("./generic-transformers");
exports.FIRST_KEY_INDEX = 1;
function transformArguments(keys, timeout) {
const args = (0, generic_transformers_1.pushVerdictArguments)(['BLPOP'], keys);
args.push(timeout.toString());
return args;
}
exports.transformArguments = transformArguments;
function transformReply(reply) {
if (reply === null)
return null;
return {
key: reply[0],
element: reply[1]
};
}
exports.transformReply = transformReply;

View File

@@ -0,0 +1,4 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare const FIRST_KEY_INDEX = 1;
export declare function transformArguments(key: RedisCommandArgument | Array<RedisCommandArgument>, timeout: number): RedisCommandArguments;
export { transformReply } from './BLPOP';

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.FIRST_KEY_INDEX = void 0;
const generic_transformers_1 = require("./generic-transformers");
exports.FIRST_KEY_INDEX = 1;
function transformArguments(key, timeout) {
const args = (0, generic_transformers_1.pushVerdictArguments)(['BRPOP'], key);
args.push(timeout.toString());
return args;
}
exports.transformArguments = transformArguments;
var BLPOP_1 = require("./BLPOP");
Object.defineProperty(exports, "transformReply", { enumerable: true, get: function () { return BLPOP_1.transformReply; } });

View File

@@ -0,0 +1,4 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare const FIRST_KEY_INDEX = 1;
export declare function transformArguments(source: RedisCommandArgument, destination: RedisCommandArgument, timeout: number): RedisCommandArguments;
export declare function transformReply(): RedisCommandArgument | null;

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = exports.FIRST_KEY_INDEX = void 0;
exports.FIRST_KEY_INDEX = 1;
function transformArguments(source, destination, timeout) {
return ['BRPOPLPUSH', source, destination, timeout.toString()];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,5 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
import { SortedSetSide, ZMPopOptions } from './generic-transformers';
export declare const FIRST_KEY_INDEX = 3;
export declare function transformArguments(timeout: number, keys: RedisCommandArgument | Array<RedisCommandArgument>, side: SortedSetSide, options?: ZMPopOptions): RedisCommandArguments;
export { transformReply } from './ZMPOP';

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.FIRST_KEY_INDEX = void 0;
const generic_transformers_1 = require("./generic-transformers");
exports.FIRST_KEY_INDEX = 3;
function transformArguments(timeout, keys, side, options) {
return (0, generic_transformers_1.transformZMPopArguments)(['BZMPOP', timeout.toString()], keys, side, options);
}
exports.transformArguments = transformArguments;
var ZMPOP_1 = require("./ZMPOP");
Object.defineProperty(exports, "transformReply", { enumerable: true, get: function () { return ZMPOP_1.transformReply; } });

View File

@@ -0,0 +1,10 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
import { ZMember } from './generic-transformers';
export declare const FIRST_KEY_INDEX = 1;
export declare function transformArguments(key: RedisCommandArgument | Array<RedisCommandArgument>, timeout: number): RedisCommandArguments;
type ZMemberRawReply = [key: RedisCommandArgument, value: RedisCommandArgument, score: RedisCommandArgument] | null;
type BZPopMaxReply = (ZMember & {
key: RedisCommandArgument;
}) | null;
export declare function transformReply(reply: ZMemberRawReply): BZPopMaxReply | null;
export {};

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.FIRST_KEY_INDEX = void 0;
const generic_transformers_1 = require("./generic-transformers");
exports.FIRST_KEY_INDEX = 1;
function transformArguments(key, timeout) {
const args = (0, generic_transformers_1.pushVerdictArguments)(['BZPOPMAX'], key);
args.push(timeout.toString());
return args;
}
exports.transformArguments = transformArguments;
function transformReply(reply) {
if (!reply)
return null;
return {
key: reply[0],
value: reply[1],
score: (0, generic_transformers_1.transformNumberInfinityReply)(reply[2])
};
}
exports.transformReply = transformReply;

View File

@@ -0,0 +1,4 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export declare const FIRST_KEY_INDEX = 1;
export declare function transformArguments(key: RedisCommandArgument | Array<RedisCommandArgument>, timeout: number): RedisCommandArguments;
export { transformReply } from './BZPOPMAX';

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.FIRST_KEY_INDEX = void 0;
const generic_transformers_1 = require("./generic-transformers");
exports.FIRST_KEY_INDEX = 1;
function transformArguments(key, timeout) {
const args = (0, generic_transformers_1.pushVerdictArguments)(['BZPOPMIN'], key);
args.push(timeout.toString());
return args;
}
exports.transformArguments = transformArguments;
var BZPOPMAX_1 = require("./BZPOPMAX");
Object.defineProperty(exports, "transformReply", { enumerable: true, get: function () { return BZPOPMAX_1.transformReply; } });

View File

@@ -0,0 +1,4 @@
/// <reference types="node" />
import { RedisCommandArguments } from '.';
export declare function transformArguments(value: boolean): RedisCommandArguments;
export declare function transformReply(): 'OK' | Buffer;

Some files were not shown because too many files have changed in this diff Show More