diff --git a/packages/client/lib/client/commands-queue.ts b/packages/client/lib/client/commands-queue.ts index 9628097c28..b3ede1ccd6 100644 --- a/packages/client/lib/client/commands-queue.ts +++ b/packages/client/lib/client/commands-queue.ts @@ -285,9 +285,10 @@ export default class RedisCommandsQueue { } private _flushWaitingForReply(err: Error): void { - while (this._waitingForReply.head) { - this._waitingForReply.shift()!.reject(err); + for (const node of this._waitingForReply) { + node.reject(err); } + this._waitingForReply.reset(); } private static _removeAbortListener(command: CommandWaitingToBeSent) { @@ -324,12 +325,10 @@ export default class RedisCommandsQueue { this.decoder.reset(); this._pubSub.reset(); this._flushWaitingForReply(err); - while (this._waitingToBeSent.head) { - RedisCommandsQueue._flushWaitingToBeSent( - this._waitingToBeSent.shift()!, - err - ); + for (const node of this._waitingToBeSent) { + RedisCommandsQueue._flushWaitingToBeSent(node, err); } + this._waitingToBeSent.reset(); } isEmpty() { diff --git a/packages/client/lib/client/index.spec.ts b/packages/client/lib/client/index.spec.ts index 9ffcf815ed..f1e88bb140 100644 --- a/packages/client/lib/client/index.spec.ts +++ b/packages/client/lib/client/index.spec.ts @@ -3,12 +3,14 @@ import testUtils, { GLOBAL, waitTillBeenCalled } from '../test-utils'; import RedisClient, { RedisClientType } from '.'; // import { RedisClientMultiCommandType } from './multi-command'; // import { RedisCommandRawReply, RedisModules, RedisFunctions, RedisScripts } from '../commands'; -// import { AbortError, ClientClosedError, ClientOfflineError, ConnectionTimeoutError, DisconnectsClientError, SocketClosedUnexpectedlyError, WatchError } from '../errors'; +import { AbortError, ClientClosedError, ClientOfflineError, ConnectionTimeoutError, DisconnectsClientError, SocketClosedUnexpectedlyError, WatchError } from '../errors'; import { defineScript } from '../lua-script'; // import { spy } from 'sinon'; -// import { once } from 'events'; +import { once } from 'events'; // import { ClientKillFilters } from '../commands/CLIENT_KILL'; // import { promisify } from 'util'; +import { MATH_FUNCTION, loadMathFunction } from '../commands/FUNCTION_LOAD.spec'; +import { RESP_TYPES } from '../RESP/decoder'; export const SQUARE_SCRIPT = defineScript({ SCRIPT: 'return ARGV[1] * ARGV[1];', @@ -113,470 +115,244 @@ describe('Client', () => { } }); -// describe('legacyMode', () => { -// testUtils.testWithClient('client.sendCommand should call the callback', async client => { -// assert.equal( -// await promisify(client.sendCommand).call(client, 'PING'), -// 'PONG' -// ); -// }, { -// ...GLOBAL.SERVERS.OPEN, -// clientOptions: { -// legacyMode: true -// } -// }); + testUtils.testWithClient('connect, ready and end events', async client => { + await Promise.all([ + once(client, 'connect'), + once(client, 'ready'), + client.connect() + ]); -// testUtils.testWithClient('client.sendCommand should work without callback', async client => { -// client.sendCommand(['PING']); -// await client.v4.ping(); // make sure the first command was replied -// }, { -// ...GLOBAL.SERVERS.OPEN, -// clientOptions: { -// legacyMode: true -// } -// }); + const promise = once(client, 'end'); + console.log('listen to end', client.listeners('end')); + client.close(); + await promise; + }, { + ...GLOBAL.SERVERS.OPEN, + disableClientSetup: true + }); -// testUtils.testWithClient('client.sendCommand should reply with error', async client => { -// await assert.rejects( -// promisify(client.sendCommand).call(client, '1', '2') -// ); -// }, { -// ...GLOBAL.SERVERS.OPEN, -// clientOptions: { -// legacyMode: true -// } -// }); + describe('sendCommand', () => { + testUtils.testWithClient('PING', async client => { + assert.equal(await client.sendCommand(['PING']), 'PONG'); + }, GLOBAL.SERVERS.OPEN); -// testUtils.testWithClient('client.hGetAll should reply with error', async client => { -// await assert.rejects( -// promisify(client.hGetAll).call(client) -// ); -// }, { -// ...GLOBAL.SERVERS.OPEN, -// clientOptions: { -// legacyMode: true -// } -// }); + describe('AbortController', () => { + before(function () { + if (!global.AbortController) { + this.skip(); + } + }); -// testUtils.testWithClient('client.v4.sendCommand should return a promise', async client => { -// assert.equal( -// await client.v4.sendCommand(['PING']), -// 'PONG' -// ); -// }, { -// ...GLOBAL.SERVERS.OPEN, -// clientOptions: { -// legacyMode: true -// } -// }); + testUtils.testWithClient('success', async client => { + await client.sendCommand(['PING'], { + abortSignal: new AbortController().signal + }); + }, GLOBAL.SERVERS.OPEN); -// testUtils.testWithClient('client.v4.{command} should return a promise', async client => { -// assert.equal( -// await client.v4.ping(), -// 'PONG' -// ); -// }, { -// ...GLOBAL.SERVERS.OPEN, -// clientOptions: { -// legacyMode: true -// } -// }); + testUtils.testWithClient('AbortError', client => { + const controller = new AbortController(); + controller.abort(); -// testUtils.testWithClient('client.{command} should accept vardict arguments', async client => { -// assert.equal( -// await promisify(client.set).call(client, 'a', 'b'), -// 'OK' -// ); -// }, { -// ...GLOBAL.SERVERS.OPEN, -// clientOptions: { -// legacyMode: true -// } -// }); + return assert.rejects( + client.sendCommand(['PING'], { + abortSignal: controller.signal + }), + AbortError + ); + }, GLOBAL.SERVERS.OPEN); + }); -// testUtils.testWithClient('client.{command} should accept arguments array', async client => { -// assert.equal( -// await promisify(client.set).call(client, ['a', 'b']), -// 'OK' -// ); -// }, { -// ...GLOBAL.SERVERS.OPEN, -// clientOptions: { -// legacyMode: true -// } -// }); + testUtils.testWithClient('undefined and null should not break the client', async client => { + await assert.rejects( + client.sendCommand([null as any, undefined as any]), + TypeError + ); -// testUtils.testWithClient('client.{command} should accept mix of arrays and arguments', async client => { -// assert.equal( -// await promisify(client.set).call(client, ['a'], 'b', ['EX', 1]), -// 'OK' -// ); -// }, { -// ...GLOBAL.SERVERS.OPEN, -// clientOptions: { -// legacyMode: true -// } -// }); + assert.equal( + await client.ping(), + 'PONG' + ); + }, GLOBAL.SERVERS.OPEN); + }); -// testUtils.testWithClient('client.hGetAll should return object', async client => { -// await client.v4.hSet('key', 'field', 'value'); + describe('multi', () => { + testUtils.testWithClient('simple', async client => { + assert.deepEqual( + await client.multi() + .ping() + .set('key', 'value') + .get('key') + .exec(), + ['PONG', 'OK', 'value'] + ); + }, GLOBAL.SERVERS.OPEN); -// assert.deepEqual( -// await promisify(client.hGetAll).call(client, 'key'), -// Object.create(null, { -// field: { -// value: 'value', -// configurable: true, -// enumerable: true -// } -// }) -// ); -// }, { -// ...GLOBAL.SERVERS.OPEN, -// clientOptions: { -// legacyMode: true -// } -// }); + testUtils.testWithClient('should reject the whole chain on error', client => { + return assert.rejects( + client.multi() + .ping() + .addCommand(['INVALID COMMAND']) + .ping() + .exec() + ); + }, GLOBAL.SERVERS.OPEN); -// function multiExecAsync< -// M extends RedisModules, -// F extends RedisFunctions, -// S extends RedisScripts -// >(multi: RedisClientMultiCommandType): Promise> { -// return new Promise((resolve, reject) => { -// (multi as any).exec((err: Error | undefined, replies: Array) => { -// if (err) return reject(err); + testUtils.testWithClient('should reject the whole chain upon client disconnect', async client => { + await client.close(); -// resolve(replies); -// }); -// }); -// } + return assert.rejects( + client.multi() + .ping() + .set('key', 'value') + .get('key') + .exec(), + ClientClosedError + ); + }, GLOBAL.SERVERS.OPEN); -// testUtils.testWithClient('client.multi.ping.exec should call the callback', async client => { -// assert.deepEqual( -// await multiExecAsync( -// client.multi().ping() -// ), -// ['PONG'] -// ); -// }, { -// ...GLOBAL.SERVERS.OPEN, -// clientOptions: { -// legacyMode: true -// } -// }); + testUtils.testWithClient('with script', async client => { + assert.deepEqual( + await client.multi() + .square(2) + .exec(), + [4] + ); + }, { + ...GLOBAL.SERVERS.OPEN, + clientOptions: { + scripts: { + square: SQUARE_SCRIPT + } + } + }); -// testUtils.testWithClient('client.multi.ping.exec should call the callback', async client => { -// client.multi() -// .ping() -// .exec(); -// await client.v4.ping(); // make sure the first command was replied -// }, { -// ...GLOBAL.SERVERS.OPEN, -// clientOptions: { -// legacyMode: true -// } -// }); + // testUtils.testWithClient('WatchError', async client => { + // await client.watch('key'); -// testUtils.testWithClient('client.multi.ping.v4.ping.v4.exec should return a promise', async client => { -// assert.deepEqual( -// await client.multi() -// .ping() -// .v4.ping() -// .v4.exec(), -// ['PONG', 'PONG'] -// ); -// }, { -// ...GLOBAL.SERVERS.OPEN, -// clientOptions: { -// legacyMode: true -// } -// }); + // await client.set( + // RedisClient.commandOptions({ + // isolated: true + // }), + // 'key', + // '1' + // ); -// testUtils.testWithClient('client.{script} should return a promise', async client => { -// assert.equal( -// await client.square(2), -// 4 -// ); -// }, { -// ...GLOBAL.SERVERS.OPEN, -// clientOptions: { -// legacyMode: true, -// scripts: { -// square: SQUARE_SCRIPT -// } -// } -// }); + // await assert.rejects( + // client.multi() + // .decr('key') + // .exec(), + // WatchError + // ); + // }, GLOBAL.SERVERS.OPEN); -// testUtils.testWithClient('client.multi.{command}.exec should flatten array arguments', async client => { -// assert.deepEqual( -// await client.multi() -// .sAdd('a', ['b', 'c']) -// .v4.exec(), -// [2] -// ); -// }, { -// ...GLOBAL.SERVERS.OPEN, -// clientOptions: { -// legacyMode: true -// } -// }); + describe('execAsPipeline', () => { + testUtils.testWithClient('exec(true)', async client => { + assert.deepEqual( + await client.multi() + .ping() + .exec(true), + ['PONG'] + ); + }, GLOBAL.SERVERS.OPEN); -// testUtils.testWithClient('client.multi.hGetAll should return object', async client => { -// assert.deepEqual( -// await multiExecAsync( -// client.multi() -// .hSet('key', 'field', 'value') -// .hGetAll('key') -// ), -// [ -// 1, -// Object.create(null, { -// field: { -// value: 'value', -// configurable: true, -// enumerable: true -// } -// }) -// ] -// ); -// }, { -// ...GLOBAL.SERVERS.OPEN, -// clientOptions: { -// legacyMode: true -// } -// }); -// }); + testUtils.testWithClient('empty execAsPipeline', async client => { + assert.deepEqual( + await client.multi().execAsPipeline(), + [] + ); + }, GLOBAL.SERVERS.OPEN); + }); -// describe('events', () => { -// testUtils.testWithClient('connect, ready, end', async client => { -// await Promise.all([ -// once(client, 'connect'), -// once(client, 'ready'), -// client.connect() -// ]); + // testUtils.testWithClient('should remember selected db', async client => { + // await client.multi() + // .select(1) + // .exec(); + // await killClient(client); + // assert.equal( + // (await client.clientInfo()).db, + // 1 + // ); + // }, { + // ...GLOBAL.SERVERS.OPEN, + // minimumDockerVersion: [6, 2] // CLIENT INFO + // }); + }); -// await Promise.all([ -// once(client, 'end'), -// client.disconnect() -// ]); -// }, { -// ...GLOBAL.SERVERS.OPEN, -// disableClientSetup: true -// }); -// }); + testUtils.testWithClient('scripts', async client => { + assert.equal( + await client.square(2), + 4 + ); + }, { + ...GLOBAL.SERVERS.OPEN, + clientOptions: { + scripts: { + square: SQUARE_SCRIPT + } + } + }); -// describe('sendCommand', () => { -// testUtils.testWithClient('PING', async client => { -// assert.equal(await client.sendCommand(['PING']), 'PONG'); -// }, GLOBAL.SERVERS.OPEN); + const module = { + echo: { + transformArguments(message: string): Array { + return ['ECHO', message]; + }, + transformReply(reply: string): string { + return reply; + } + } + }; -// testUtils.testWithClient('returnBuffers', async client => { -// assert.deepEqual( -// await client.sendCommand(['PING'], { -// returnBuffers: true -// }), -// Buffer.from('PONG') -// ); -// }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('modules', async client => { + assert.equal( + await client.module.echo('message'), + 'message' + ); + }, { + ...GLOBAL.SERVERS.OPEN, + clientOptions: { + modules: { + module + } + } + }); -// describe('AbortController', () => { -// before(function () { -// if (!global.AbortController) { -// this.skip(); -// } -// }); + testUtils.testWithClient('functions', async client => { + await loadMathFunction(client); -// testUtils.testWithClient('success', async client => { -// await client.sendCommand(['PING'], { -// signal: new AbortController().signal -// }); -// }, GLOBAL.SERVERS.OPEN); + assert.equal( + await client.math.square(2), + 4 + ); + }, { + ...GLOBAL.SERVERS.OPEN, + minimumDockerVersion: [7, 0], + clientOptions: { + functions: { + math: MATH_FUNCTION.library + } + } + }); -// testUtils.testWithClient('AbortError', client => { -// const controller = new AbortController(); -// controller.abort(); + testUtils.testWithClient('duplicate should reuse command options', async client => { + const duplicate = client.withTypeMapping({ + [RESP_TYPES.SIMPLE_STRING]: Buffer + }).duplicate(); -// return assert.rejects( -// client.sendCommand(['PING'], { -// signal: controller.signal -// }), -// AbortError -// ); -// }, GLOBAL.SERVERS.OPEN); -// }); + await duplicate.connect(); -// testUtils.testWithClient('undefined and null should not break the client', async client => { -// await assert.rejects( -// client.sendCommand([null as any, undefined as any]), -// TypeError -// ); - -// assert.equal( -// await client.ping(), -// 'PONG' -// ); -// }, GLOBAL.SERVERS.OPEN); -// }); - -// describe('multi', () => { -// testUtils.testWithClient('simple', async client => { -// assert.deepEqual( -// await client.multi() -// .ping() -// .set('key', 'value') -// .get('key') -// .exec(), -// ['PONG', 'OK', 'value'] -// ); -// }, GLOBAL.SERVERS.OPEN); - -// testUtils.testWithClient('should reject the whole chain on error', client => { -// return assert.rejects( -// client.multi() -// .ping() -// .addCommand(['INVALID COMMAND']) -// .ping() -// .exec() -// ); -// }, GLOBAL.SERVERS.OPEN); - -// testUtils.testWithClient('should reject the whole chain upon client disconnect', async client => { -// await client.disconnect(); - -// return assert.rejects( -// client.multi() -// .ping() -// .set('key', 'value') -// .get('key') -// .exec(), -// ClientClosedError -// ); -// }, GLOBAL.SERVERS.OPEN); - -// testUtils.testWithClient('with script', async client => { -// assert.deepEqual( -// await client.multi() -// .square(2) -// .exec(), -// [4] -// ); -// }, { -// ...GLOBAL.SERVERS.OPEN, -// clientOptions: { -// scripts: { -// square: SQUARE_SCRIPT -// } -// } -// }); - -// testUtils.testWithClient('WatchError', async client => { -// await client.watch('key'); - -// await client.set( -// RedisClient.commandOptions({ -// isolated: true -// }), -// 'key', -// '1' -// ); - -// await assert.rejects( -// client.multi() -// .decr('key') -// .exec(), -// WatchError -// ); -// }, GLOBAL.SERVERS.OPEN); - -// describe('execAsPipeline', () => { -// testUtils.testWithClient('exec(true)', async client => { -// assert.deepEqual( -// await client.multi() -// .ping() -// .exec(true), -// ['PONG'] -// ); -// }, GLOBAL.SERVERS.OPEN); - -// testUtils.testWithClient('empty execAsPipeline', async client => { -// assert.deepEqual( -// await client.multi().execAsPipeline(), -// [] -// ); -// }, GLOBAL.SERVERS.OPEN); -// }); - -// testUtils.testWithClient('should remember selected db', async client => { -// await client.multi() -// .select(1) -// .exec(); -// await killClient(client); -// assert.equal( -// (await client.clientInfo()).db, -// 1 -// ); -// }, { -// ...GLOBAL.SERVERS.OPEN, -// minimumDockerVersion: [6, 2] // CLIENT INFO -// }); -// }); - -// testUtils.testWithClient('scripts', async client => { -// assert.equal( -// await client.square(2), -// 4 -// ); -// }, { -// ...GLOBAL.SERVERS.OPEN, -// clientOptions: { -// scripts: { -// square: SQUARE_SCRIPT -// } -// } -// }); - -// const module = { -// echo: { -// transformArguments(message: string): Array { -// return ['ECHO', message]; -// }, -// transformReply(reply: string): string { -// return reply; -// } -// } -// }; - -// testUtils.testWithClient('modules', async client => { -// assert.equal( -// await client.module.echo('message'), -// 'message' -// ); -// }, { -// ...GLOBAL.SERVERS.OPEN, -// clientOptions: { -// modules: { -// module -// } -// } -// }); - -// testUtils.testWithClient('functions', async client => { -// await loadMathFunction(client); - -// assert.equal( -// await client.math.square(2), -// 4 -// ); -// }, { -// ...GLOBAL.SERVERS.OPEN, -// minimumDockerVersion: [7, 0], -// clientOptions: { -// functions: { -// math: MATH_FUNCTION.library -// } -// } -// }); + try { + assert.deepEqual( + await duplicate.ping(), + Buffer.from('PONG') + ); + } finally { + duplicate.close(); + } + }, { + ...GLOBAL.SERVERS.OPEN, + disableClientSetup: true, + }); // describe('isolationPool', () => { // testUtils.testWithClient('executeIsolated', async client => { diff --git a/packages/client/lib/client/index.ts b/packages/client/lib/client/index.ts index 4e6700d3fb..75f94333f7 100644 --- a/packages/client/lib/client/index.ts +++ b/packages/client/lib/client/index.ts @@ -68,7 +68,7 @@ export interface RedisClientOptions< pingInterval?: number; } -interface TypeMappingOption { +export interface TypeMappingOption { /** * Maps bettwen RESP types to JavaScript types */ @@ -532,11 +532,24 @@ export default class RedisClient< // ); // } - duplicate(overrides?: Partial>) { - return new (Object.getPrototypeOf(this).constructor)({ + duplicate< + _M extends RedisModules = M, + _F extends RedisFunctions = F, + _S extends RedisScripts = S, + _RESP extends RespVersions = RESP, + _TYPE_MAPPING extends TypeMapping = TYPE_MAPPING + >(overrides?: Partial>) { + const client = new (Object.getPrototypeOf(this).constructor)({ ...this._options, ...overrides - }) as RedisClientType; + }) as RedisClientType<_M, _F, _S, _RESP, _TYPE_MAPPING>; + + const { commandOptions } = this as ProxyClient; + if (commandOptions) { + return client.withCommandOptions(commandOptions); + } + + return client; } connect() { diff --git a/packages/client/lib/client/linked-list.ts b/packages/client/lib/client/linked-list.ts index ec59e67224..1a68e1c2f3 100644 --- a/packages/client/lib/client/linked-list.ts +++ b/packages/client/lib/client/linked-list.ts @@ -91,6 +91,11 @@ export class DoublyLinkedList { node.next = undefined; } + reset() { + this._length = 0; + this._head = this._tail = undefined; + } + *[Symbol.iterator]() { let node = this._head; while (node !== undefined) { @@ -152,6 +157,11 @@ export class SinglyLinkedList { return node.value; } + reset() { + this._length = 0; + this._head = this._tail = undefined; + } + *[Symbol.iterator]() { let node = this._head; while (node !== undefined) { diff --git a/packages/client/lib/cluster/cluster-slots.ts b/packages/client/lib/cluster/cluster-slots.ts index 6dc9101644..39d463bad5 100644 --- a/packages/client/lib/cluster/cluster-slots.ts +++ b/packages/client/lib/cluster/cluster-slots.ts @@ -46,6 +46,7 @@ export interface ShardNode< S extends RedisScripts, RESP extends RespVersions > extends Node { + id: string; host: string; port: number; readonly: boolean; @@ -173,7 +174,6 @@ export default class RedisClusterSlots< promises: Array> = [], eagerConnect = this._options.minimizeConnections !== true; - type a = typeof shards; for (const { from, to, master, replicas } of shards) { const shard: Shard = { master: this._initiateSlotNode(master, false, eagerConnect, addressesInUse, promises) @@ -294,19 +294,19 @@ export default class RedisClusterSlots< } private _initiateSlotNode( - slotAddress: NodeAddress, + shard: NodeAddress & { id: string; }, readonly: boolean, eagerConnent: boolean, addressesInUse: Set, promises: Array> ) { - const address = `${slotAddress.host}:${slotAddress.port}`; + const address = `${shard.host}:${shard.port}`; addressesInUse.add(address); let node = this.nodeByAddress.get(address); if (!node) { node = { - ...slotAddress, + ...shard, address, readonly, client: undefined diff --git a/packages/client/lib/commands/CLIENT_GETNAME.spec.ts b/packages/client/lib/commands/CLIENT_GETNAME.spec.ts index cbd6576891..bb9c24cd6f 100644 --- a/packages/client/lib/commands/CLIENT_GETNAME.spec.ts +++ b/packages/client/lib/commands/CLIENT_GETNAME.spec.ts @@ -1,4 +1,5 @@ import { strict as assert } from 'assert'; +import testUtils, { GLOBAL } from '../test-utils'; import CLIENT_GETNAME from './CLIENT_GETNAME'; describe('CLIENT GETNAME', () => { @@ -8,4 +9,11 @@ describe('CLIENT GETNAME', () => { ['CLIENT', 'GETNAME'] ); }); + + testUtils.testWithClient('client.clientGetName', async client => { + assert.equal( + await client.clientGetName(), + null + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/client/lib/commands/CLIENT_KILL.spec.ts b/packages/client/lib/commands/CLIENT_KILL.spec.ts index 4a64cb2c6e..28be6e1272 100644 --- a/packages/client/lib/commands/CLIENT_KILL.spec.ts +++ b/packages/client/lib/commands/CLIENT_KILL.spec.ts @@ -1,12 +1,12 @@ import { strict as assert } from 'assert'; -import { ClientKillFilters, transformArguments } from './CLIENT_KILL'; +import CLIENT_KILL, { CLIENT_KILL_FILTERS } from './CLIENT_KILL'; describe('CLIENT KILL', () => { describe('transformArguments', () => { it('ADDRESS', () => { assert.deepEqual( - transformArguments({ - filter: ClientKillFilters.ADDRESS, + CLIENT_KILL.transformArguments({ + filter: CLIENT_KILL_FILTERS.ADDRESS, address: 'ip:6379' }), ['CLIENT', 'KILL', 'ADDR', 'ip:6379'] @@ -15,8 +15,8 @@ describe('CLIENT KILL', () => { it('LOCAL_ADDRESS', () => { assert.deepEqual( - transformArguments({ - filter: ClientKillFilters.LOCAL_ADDRESS, + CLIENT_KILL.transformArguments({ + filter: CLIENT_KILL_FILTERS.LOCAL_ADDRESS, localAddress: 'ip:6379' }), ['CLIENT', 'KILL', 'LADDR', 'ip:6379'] @@ -26,8 +26,8 @@ describe('CLIENT KILL', () => { describe('ID', () => { it('string', () => { assert.deepEqual( - transformArguments({ - filter: ClientKillFilters.ID, + CLIENT_KILL.transformArguments({ + filter: CLIENT_KILL_FILTERS.ID, id: '1' }), ['CLIENT', 'KILL', 'ID', '1'] @@ -36,8 +36,8 @@ describe('CLIENT KILL', () => { it('number', () => { assert.deepEqual( - transformArguments({ - filter: ClientKillFilters.ID, + CLIENT_KILL.transformArguments({ + filter: CLIENT_KILL_FILTERS.ID, id: 1 }), ['CLIENT', 'KILL', 'ID', '1'] @@ -47,8 +47,8 @@ describe('CLIENT KILL', () => { it('TYPE', () => { assert.deepEqual( - transformArguments({ - filter: ClientKillFilters.TYPE, + CLIENT_KILL.transformArguments({ + filter: CLIENT_KILL_FILTERS.TYPE, type: 'master' }), ['CLIENT', 'KILL', 'TYPE', 'master'] @@ -57,8 +57,8 @@ describe('CLIENT KILL', () => { it('USER', () => { assert.deepEqual( - transformArguments({ - filter: ClientKillFilters.USER, + CLIENT_KILL.transformArguments({ + filter: CLIENT_KILL_FILTERS.USER, username: 'username' }), ['CLIENT', 'KILL', 'USER', 'username'] @@ -68,15 +68,15 @@ describe('CLIENT KILL', () => { describe('SKIP_ME', () => { it('undefined', () => { assert.deepEqual( - transformArguments(ClientKillFilters.SKIP_ME), + CLIENT_KILL.transformArguments(CLIENT_KILL_FILTERS.SKIP_ME), ['CLIENT', 'KILL', 'SKIPME'] ); }); it('true', () => { assert.deepEqual( - transformArguments({ - filter: ClientKillFilters.SKIP_ME, + CLIENT_KILL.transformArguments({ + filter: CLIENT_KILL_FILTERS.SKIP_ME, skipMe: true }), ['CLIENT', 'KILL', 'SKIPME', 'yes'] @@ -85,8 +85,8 @@ describe('CLIENT KILL', () => { it('false', () => { assert.deepEqual( - transformArguments({ - filter: ClientKillFilters.SKIP_ME, + CLIENT_KILL.transformArguments({ + filter: CLIENT_KILL_FILTERS.SKIP_ME, skipMe: false }), ['CLIENT', 'KILL', 'SKIPME', 'no'] @@ -96,12 +96,12 @@ describe('CLIENT KILL', () => { it('TYPE & SKIP_ME', () => { assert.deepEqual( - transformArguments([ + CLIENT_KILL.transformArguments([ { - filter: ClientKillFilters.TYPE, + filter: CLIENT_KILL_FILTERS.TYPE, type: 'master' }, - ClientKillFilters.SKIP_ME + CLIENT_KILL_FILTERS.SKIP_ME ]), ['CLIENT', 'KILL', 'TYPE', 'master', 'SKIPME'] ); diff --git a/packages/client/lib/commands/CLIENT_NO-EVICT.spec.ts b/packages/client/lib/commands/CLIENT_NO-EVICT.spec.ts index df8903f064..e87025a3b6 100644 --- a/packages/client/lib/commands/CLIENT_NO-EVICT.spec.ts +++ b/packages/client/lib/commands/CLIENT_NO-EVICT.spec.ts @@ -1,30 +1,30 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; -import { transformArguments } from './CLIENT_NO-EVICT'; +import CLIENT_NO_EVICT from './CLIENT_NO-EVICT'; describe('CLIENT NO-EVICT', () => { - testUtils.isVersionGreaterThanHook([7]); + testUtils.isVersionGreaterThanHook([7]); - describe('transformArguments', () => { - it('true', () => { - assert.deepEqual( - transformArguments(true), - ['CLIENT', 'NO-EVICT', 'ON'] - ); - }); - - it('false', () => { - assert.deepEqual( - transformArguments(false), - ['CLIENT', 'NO-EVICT', 'OFF'] - ); - }); + describe('transformArguments', () => { + it('true', () => { + assert.deepEqual( + CLIENT_NO_EVICT.transformArguments(true), + ['CLIENT', 'NO-EVICT', 'ON'] + ); }); - testUtils.testWithClient('client.clientNoEvict', async client => { - assert.equal( - await client.clientNoEvict(true), - 'OK' - ); - }, GLOBAL.SERVERS.OPEN); + it('false', () => { + assert.deepEqual( + CLIENT_NO_EVICT.transformArguments(false), + ['CLIENT', 'NO-EVICT', 'OFF'] + ); + }); + }); + + testUtils.testWithClient('client.clientNoEvict', async client => { + assert.equal( + await client.clientNoEvict(true), + 'OK' + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/client/lib/commands/CLIENT_PAUSE.spec.ts b/packages/client/lib/commands/CLIENT_PAUSE.spec.ts index 1376ff41ee..8cf414410f 100644 --- a/packages/client/lib/commands/CLIENT_PAUSE.spec.ts +++ b/packages/client/lib/commands/CLIENT_PAUSE.spec.ts @@ -1,28 +1,28 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; -import { transformArguments } from './CLIENT_PAUSE'; +import CLIENT_PAUSE from './CLIENT_PAUSE'; describe('CLIENT PAUSE', () => { - describe('transformArguments', () => { - it('simple', () => { - assert.deepEqual( - transformArguments(0), - ['CLIENT', 'PAUSE', '0'] - ); - }); - - it('with mode', () => { - assert.deepEqual( - transformArguments(0, 'ALL'), - ['CLIENT', 'PAUSE', '0', 'ALL'] - ); - }); + describe('transformArguments', () => { + it('simple', () => { + assert.deepEqual( + CLIENT_PAUSE.transformArguments(0), + ['CLIENT', 'PAUSE', '0'] + ); }); - testUtils.testWithClient('client.clientPause', async client => { - assert.equal( - await client.clientPause(0), - 'OK' - ); - }, GLOBAL.SERVERS.OPEN); + it('with mode', () => { + assert.deepEqual( + CLIENT_PAUSE.transformArguments(0, 'ALL'), + ['CLIENT', 'PAUSE', '0', 'ALL'] + ); + }); + }); + + testUtils.testWithClient('client.clientPause', async client => { + assert.equal( + await client.clientPause(0), + 'OK' + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/client/lib/commands/CLIENT_SETNAME.spec.ts b/packages/client/lib/commands/CLIENT_SETNAME.spec.ts index 96618f3f79..d9af526bb4 100644 --- a/packages/client/lib/commands/CLIENT_SETNAME.spec.ts +++ b/packages/client/lib/commands/CLIENT_SETNAME.spec.ts @@ -1,11 +1,20 @@ import { strict as assert } from 'assert'; -import { transformArguments } from './CLIENT_SETNAME'; +import testUtils, { GLOBAL } from '../test-utils'; + +import CLIENT_SETNAME from './CLIENT_SETNAME'; describe('CLIENT SETNAME', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('name'), - ['CLIENT', 'SETNAME', 'name'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + CLIENT_SETNAME.transformArguments('name'), + ['CLIENT', 'SETNAME', 'name'] + ); + }); + + testUtils.testWithClient('client.clientSetName', async client => { + assert.equal( + await client.clientSetName('name'), + 'OK' + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/client/lib/commands/CLUSTER_MYID.spec.ts b/packages/client/lib/commands/CLUSTER_MYID.spec.ts index f427d7058e..01282fadd8 100644 --- a/packages/client/lib/commands/CLUSTER_MYID.spec.ts +++ b/packages/client/lib/commands/CLUSTER_MYID.spec.ts @@ -1,21 +1,21 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; -import { transformArguments } from './CLUSTER_MYID'; +import CLUSTER_MYID from './CLUSTER_MYID'; describe('CLUSTER MYID', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments(), - ['CLUSTER', 'MYID'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + CLUSTER_MYID.transformArguments(), + ['CLUSTER', 'MYID'] + ); + }); - testUtils.testWithCluster('clusterNode.clusterMyId', async cluster => { - const [master] = cluster.masters, - client = await cluster.nodeClient(master); - assert.equal( - await client.clusterMyId(), - master.id - ); - }, GLOBAL.CLUSTERS.OPEN); + testUtils.testWithCluster('clusterNode.clusterMyId', async cluster => { + const [master] = cluster.masters, + client = await cluster.nodeClient(master); + assert.equal( + await client.clusterMyId(), + master.id + ); + }, GLOBAL.CLUSTERS.OPEN); }); diff --git a/packages/client/lib/commands/COMMAND.spec.ts b/packages/client/lib/commands/COMMAND.spec.ts index baad79845a..ed82d5c5ec 100644 --- a/packages/client/lib/commands/COMMAND.spec.ts +++ b/packages/client/lib/commands/COMMAND.spec.ts @@ -1,17 +1,17 @@ -import { strict as assert } from 'assert'; -import testUtils, { GLOBAL } from '../test-utils'; -import { transformArguments } from './COMMAND'; -import { assertPingCommand } from './COMMAND_INFO.spec'; +// import { strict as assert } from 'assert'; +// import testUtils, { GLOBAL } from '../test-utils'; +// import { transformArguments } from './COMMAND'; +// import { assertPingCommand } from './COMMAND_INFO.spec'; -describe('COMMAND', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments(), - ['COMMAND'] - ); - }); +// describe('COMMAND', () => { +// it('transformArguments', () => { +// assert.deepEqual( +// transformArguments(), +// ['COMMAND'] +// ); +// }); - testUtils.testWithClient('client.command', async client => { - assertPingCommand((await client.command()).find(command => command.name === 'ping')); - }, GLOBAL.SERVERS.OPEN); -}); +// testUtils.testWithClient('client.command', async client => { +// assertPingCommand((await client.command()).find(command => command.name === 'ping')); +// }, GLOBAL.SERVERS.OPEN); +// }); diff --git a/packages/client/lib/commands/COMMAND_COUNT.spec.ts b/packages/client/lib/commands/COMMAND_COUNT.spec.ts index 71482382f6..ca03e96ae8 100644 --- a/packages/client/lib/commands/COMMAND_COUNT.spec.ts +++ b/packages/client/lib/commands/COMMAND_COUNT.spec.ts @@ -1,19 +1,19 @@ -import { strict as assert } from 'assert'; -import testUtils, { GLOBAL } from '../test-utils'; -import { transformArguments } from './COMMAND_COUNT'; +// import { strict as assert } from 'assert'; +// import testUtils, { GLOBAL } from '../test-utils'; +// import { transformArguments } from './COMMAND_COUNT'; -describe('COMMAND COUNT', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments(), - ['COMMAND', 'COUNT'] - ); - }); +// describe('COMMAND COUNT', () => { +// it('transformArguments', () => { +// assert.deepEqual( +// transformArguments(), +// ['COMMAND', 'COUNT'] +// ); +// }); - testUtils.testWithClient('client.commandCount', async client => { - assert.equal( - typeof await client.commandCount(), - 'number' - ); - }, GLOBAL.SERVERS.OPEN); -}); +// testUtils.testWithClient('client.commandCount', async client => { +// assert.equal( +// typeof await client.commandCount(), +// 'number' +// ); +// }, GLOBAL.SERVERS.OPEN); +// }); diff --git a/packages/client/lib/commands/COMMAND_GETKEYS.spec.ts b/packages/client/lib/commands/COMMAND_GETKEYS.spec.ts index a92d032c5d..e17566e0df 100644 --- a/packages/client/lib/commands/COMMAND_GETKEYS.spec.ts +++ b/packages/client/lib/commands/COMMAND_GETKEYS.spec.ts @@ -1,19 +1,19 @@ -import { strict as assert } from 'assert'; -import testUtils, { GLOBAL } from '../test-utils'; -import { transformArguments } from './COMMAND_GETKEYS'; +// import { strict as assert } from 'assert'; +// import testUtils, { GLOBAL } from '../test-utils'; +// import { transformArguments } from './COMMAND_GETKEYS'; -describe('COMMAND GETKEYS', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments(['GET', 'key']), - ['COMMAND', 'GETKEYS', 'GET', 'key'] - ); - }); +// describe('COMMAND GETKEYS', () => { +// it('transformArguments', () => { +// assert.deepEqual( +// transformArguments(['GET', 'key']), +// ['COMMAND', 'GETKEYS', 'GET', 'key'] +// ); +// }); - testUtils.testWithClient('client.commandGetKeys', async client => { - assert.deepEqual( - await client.commandGetKeys(['GET', 'key']), - ['key'] - ); - }, GLOBAL.SERVERS.OPEN); -}); +// testUtils.testWithClient('client.commandGetKeys', async client => { +// assert.deepEqual( +// await client.commandGetKeys(['GET', 'key']), +// ['key'] +// ); +// }, GLOBAL.SERVERS.OPEN); +// }); diff --git a/packages/client/lib/commands/COMMAND_GETKEYSANDFLAGS.spec.ts b/packages/client/lib/commands/COMMAND_GETKEYSANDFLAGS.spec.ts index d568ed0e50..8d16ad501c 100644 --- a/packages/client/lib/commands/COMMAND_GETKEYSANDFLAGS.spec.ts +++ b/packages/client/lib/commands/COMMAND_GETKEYSANDFLAGS.spec.ts @@ -1,24 +1,24 @@ -import { strict as assert } from 'assert'; -import testUtils, { GLOBAL } from '../test-utils'; -import { transformArguments } from './COMMAND_GETKEYSANDFLAGS'; +// import { strict as assert } from 'assert'; +// import testUtils, { GLOBAL } from '../test-utils'; +// import { transformArguments } from './COMMAND_GETKEYSANDFLAGS'; -describe('COMMAND GETKEYSANDFLAGS', () => { - testUtils.isVersionGreaterThanHook([7]); +// describe('COMMAND GETKEYSANDFLAGS', () => { +// testUtils.isVersionGreaterThanHook([7]); - it('transformArguments', () => { - assert.deepEqual( - transformArguments(['GET', 'key']), - ['COMMAND', 'GETKEYSANDFLAGS', 'GET', 'key'] - ); - }); +// it('transformArguments', () => { +// assert.deepEqual( +// transformArguments(['GET', 'key']), +// ['COMMAND', 'GETKEYSANDFLAGS', 'GET', 'key'] +// ); +// }); - testUtils.testWithClient('client.commandGetKeysAndFlags', async client => { - assert.deepEqual( - await client.commandGetKeysAndFlags(['GET', 'key']), - [{ - key: 'key', - flags: ['RO', 'access'] - }] - ); - }, GLOBAL.SERVERS.OPEN); -}); +// testUtils.testWithClient('client.commandGetKeysAndFlags', async client => { +// assert.deepEqual( +// await client.commandGetKeysAndFlags(['GET', 'key']), +// [{ +// key: 'key', +// flags: ['RO', 'access'] +// }] +// ); +// }, GLOBAL.SERVERS.OPEN); +// }); diff --git a/packages/client/lib/commands/COMMAND_INFO.spec.ts b/packages/client/lib/commands/COMMAND_INFO.spec.ts index c54a5d0aeb..fb9603ea96 100644 --- a/packages/client/lib/commands/COMMAND_INFO.spec.ts +++ b/packages/client/lib/commands/COMMAND_INFO.spec.ts @@ -1,49 +1,49 @@ -import { strict as assert } from 'assert'; -import testUtils, { GLOBAL } from '../test-utils'; -import { transformArguments } from './COMMAND_INFO'; -import { CommandCategories, CommandFlags, CommandReply } from './generic-transformers'; +// import { strict as assert } from 'assert'; +// import testUtils, { GLOBAL } from '../test-utils'; +// import { transformArguments } from './COMMAND_INFO'; +// import { CommandCategories, CommandFlags, CommandReply } from './generic-transformers'; -export function assertPingCommand(commandInfo: CommandReply | null | undefined): void { - assert.deepEqual( - commandInfo, - { - name: 'ping', - arity: -1, - flags: new Set( - testUtils.isVersionGreaterThan([7]) ? - [CommandFlags.FAST] : - [CommandFlags.STALE, CommandFlags.FAST] - ), - firstKeyIndex: 0, - lastKeyIndex: 0, - step: 0, - categories: new Set( - testUtils.isVersionGreaterThan([6]) ? - [CommandCategories.FAST, CommandCategories.CONNECTION] : - [] - ) - } - ); -} +// export function assertPingCommand(commandInfo: CommandReply | null | undefined): void { +// assert.deepEqual( +// commandInfo, +// { +// name: 'ping', +// arity: -1, +// flags: new Set( +// testUtils.isVersionGreaterThan([7]) ? +// [CommandFlags.FAST] : +// [CommandFlags.STALE, CommandFlags.FAST] +// ), +// firstKeyIndex: 0, +// lastKeyIndex: 0, +// step: 0, +// categories: new Set( +// testUtils.isVersionGreaterThan([6]) ? +// [CommandCategories.FAST, CommandCategories.CONNECTION] : +// [] +// ) +// } +// ); +// } -describe('COMMAND INFO', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments(['PING']), - ['COMMAND', 'INFO', 'PING'] - ); - }); +// describe('COMMAND INFO', () => { +// it('transformArguments', () => { +// assert.deepEqual( +// transformArguments(['PING']), +// ['COMMAND', 'INFO', 'PING'] +// ); +// }); - describe('client.commandInfo', () => { - testUtils.testWithClient('PING', async client => { - assertPingCommand((await client.commandInfo(['PING']))[0]); - }, GLOBAL.SERVERS.OPEN); +// describe('client.commandInfo', () => { +// testUtils.testWithClient('PING', async client => { +// assertPingCommand((await client.commandInfo(['PING']))[0]); +// }, GLOBAL.SERVERS.OPEN); - testUtils.testWithClient('DOSE_NOT_EXISTS', async client => { - assert.deepEqual( - await client.commandInfo(['DOSE_NOT_EXISTS']), - [null] - ); - }, GLOBAL.SERVERS.OPEN); - }); -}); +// testUtils.testWithClient('DOSE_NOT_EXISTS', async client => { +// assert.deepEqual( +// await client.commandInfo(['DOSE_NOT_EXISTS']), +// [null] +// ); +// }, GLOBAL.SERVERS.OPEN); +// }); +// }); diff --git a/packages/client/lib/commands/COMMAND_LIST.spec.ts b/packages/client/lib/commands/COMMAND_LIST.spec.ts index eef747d937..0cf0cd3b60 100644 --- a/packages/client/lib/commands/COMMAND_LIST.spec.ts +++ b/packages/client/lib/commands/COMMAND_LIST.spec.ts @@ -1,56 +1,56 @@ -import { strict as assert } from 'assert'; -import testUtils, { GLOBAL } from '../test-utils'; -import { transformArguments, FilterBy } from './COMMAND_LIST'; +// import { strict as assert } from 'assert'; +// import testUtils, { GLOBAL } from '../test-utils'; +// import { transformArguments, FilterBy } from './COMMAND_LIST'; -describe('COMMAND LIST', () => { - testUtils.isVersionGreaterThanHook([7]); +// describe('COMMAND LIST', () => { +// testUtils.isVersionGreaterThanHook([7]); - describe('transformArguments', () => { - it('simple', () => { - assert.deepEqual( - transformArguments(), - ['COMMAND', 'LIST'] - ); - }); +// describe('transformArguments', () => { +// it('simple', () => { +// assert.deepEqual( +// transformArguments(), +// ['COMMAND', 'LIST'] +// ); +// }); - describe('with FILTERBY', () => { - it('MODULE', () => { - assert.deepEqual( - transformArguments({ - filterBy: FilterBy.MODULE, - value: 'json' - }), - ['COMMAND', 'LIST', 'FILTERBY', 'MODULE', 'json'] - ); - }); +// describe('with FILTERBY', () => { +// it('MODULE', () => { +// assert.deepEqual( +// transformArguments({ +// filterBy: FilterBy.MODULE, +// value: 'json' +// }), +// ['COMMAND', 'LIST', 'FILTERBY', 'MODULE', 'json'] +// ); +// }); - it('ACLCAT', () => { - assert.deepEqual( - transformArguments({ - filterBy: FilterBy.ACLCAT, - value: 'admin' - }), - ['COMMAND', 'LIST', 'FILTERBY', 'ACLCAT', 'admin'] - ); - }); +// it('ACLCAT', () => { +// assert.deepEqual( +// transformArguments({ +// filterBy: FilterBy.ACLCAT, +// value: 'admin' +// }), +// ['COMMAND', 'LIST', 'FILTERBY', 'ACLCAT', 'admin'] +// ); +// }); - it('PATTERN', () => { - assert.deepEqual( - transformArguments({ - filterBy: FilterBy.PATTERN, - value: 'a*' - }), - ['COMMAND', 'LIST', 'FILTERBY', 'PATTERN', 'a*'] - ); - }); - }); - }); +// it('PATTERN', () => { +// assert.deepEqual( +// transformArguments({ +// filterBy: FilterBy.PATTERN, +// value: 'a*' +// }), +// ['COMMAND', 'LIST', 'FILTERBY', 'PATTERN', 'a*'] +// ); +// }); +// }); +// }); - testUtils.testWithClient('client.commandList', async client => { - const commandList = await client.commandList(); - assert.ok(Array.isArray(commandList)); - for (const command of commandList) { - assert.ok(typeof command === 'string'); - } - }, GLOBAL.SERVERS.OPEN); -}); +// testUtils.testWithClient('client.commandList', async client => { +// const commandList = await client.commandList(); +// assert.ok(Array.isArray(commandList)); +// for (const command of commandList) { +// assert.ok(typeof command === 'string'); +// } +// }, GLOBAL.SERVERS.OPEN); +// }); diff --git a/packages/client/lib/commands/CONFIG_GET.spec.ts b/packages/client/lib/commands/CONFIG_GET.spec.ts index 83b5c410cf..8077a093d8 100644 --- a/packages/client/lib/commands/CONFIG_GET.spec.ts +++ b/packages/client/lib/commands/CONFIG_GET.spec.ts @@ -1,11 +1,11 @@ import { strict as assert } from 'assert'; -import { transformArguments } from './CONFIG_GET'; +import CONFIG_GET from './CONFIG_GET'; describe('CONFIG GET', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('*'), - ['CONFIG', 'GET', '*'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + CONFIG_GET.transformArguments('*'), + ['CONFIG', 'GET', '*'] + ); + }); }); diff --git a/packages/client/lib/commands/CONFIG_RESETSTAT.spec.ts b/packages/client/lib/commands/CONFIG_RESETSTAT.spec.ts index d3f3048b94..00336dcf51 100644 --- a/packages/client/lib/commands/CONFIG_RESETSTAT.spec.ts +++ b/packages/client/lib/commands/CONFIG_RESETSTAT.spec.ts @@ -1,11 +1,11 @@ import { strict as assert } from 'assert'; -import { transformArguments } from './CONFIG_RESETSTAT'; +import CONFIG_RESETSTAT from './CONFIG_RESETSTAT'; describe('CONFIG RESETSTAT', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments(), - ['CONFIG', 'RESETSTAT'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + CONFIG_RESETSTAT.transformArguments(), + ['CONFIG', 'RESETSTAT'] + ); + }); }); diff --git a/packages/client/lib/commands/CONFIG_REWRITE.spec.ts b/packages/client/lib/commands/CONFIG_REWRITE.spec.ts index cbc3e5b59d..a7a0af85e6 100644 --- a/packages/client/lib/commands/CONFIG_REWRITE.spec.ts +++ b/packages/client/lib/commands/CONFIG_REWRITE.spec.ts @@ -1,11 +1,11 @@ import { strict as assert } from 'assert'; -import { transformArguments } from './CONFIG_REWRITE'; +import CONFIG_REWRITE from './CONFIG_REWRITE'; describe('CONFIG REWRITE', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments(), - ['CONFIG', 'REWRITE'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + CONFIG_REWRITE.transformArguments(), + ['CONFIG', 'REWRITE'] + ); + }); }); diff --git a/packages/client/lib/commands/CONFIG_SET.spec.ts b/packages/client/lib/commands/CONFIG_SET.spec.ts index 93a7a6ff25..fac5e1dbe9 100644 --- a/packages/client/lib/commands/CONFIG_SET.spec.ts +++ b/packages/client/lib/commands/CONFIG_SET.spec.ts @@ -1,24 +1,24 @@ import { strict as assert } from 'assert'; -import { transformArguments } from './CONFIG_SET'; +import CONFIG_SET from './CONFIG_SET'; describe('CONFIG SET', () => { - describe('transformArguments', () => { - it('set one parameter (old version)', () => { - assert.deepEqual( - transformArguments('parameter', 'value'), - ['CONFIG', 'SET', 'parameter', 'value'] - ); - }); - - it('set muiltiple parameters', () => { - assert.deepEqual( - transformArguments({ - 1: 'a', - 2: 'b', - 3: 'c' - }), - ['CONFIG', 'SET', '1', 'a', '2', 'b', '3', 'c'] - ); - }); + describe('transformArguments', () => { + it('set one parameter (old version)', () => { + assert.deepEqual( + CONFIG_SET.transformArguments('parameter', 'value'), + ['CONFIG', 'SET', 'parameter', 'value'] + ); }); + + it('set muiltiple parameters', () => { + assert.deepEqual( + CONFIG_SET.transformArguments({ + 1: 'a', + 2: 'b', + 3: 'c' + }), + ['CONFIG', 'SET', '1', 'a', '2', 'b', '3', 'c'] + ); + }); + }); }); diff --git a/packages/client/lib/commands/DISCARD.spec.ts b/packages/client/lib/commands/DISCARD.spec.ts index b01f9d650d..b08daecea6 100644 --- a/packages/client/lib/commands/DISCARD.spec.ts +++ b/packages/client/lib/commands/DISCARD.spec.ts @@ -1,11 +1,11 @@ import { strict as assert } from 'assert'; -import { transformArguments } from './DISCARD'; +import DISCARD from './DISCARD'; describe('DISCARD', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments(), - ['DISCARD'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + DISCARD.transformArguments(), + ['DISCARD'] + ); + }); }); diff --git a/packages/client/lib/commands/FAILOVER.spec.ts b/packages/client/lib/commands/FAILOVER.spec.ts index 16094a0dbc..f97663e419 100644 --- a/packages/client/lib/commands/FAILOVER.spec.ts +++ b/packages/client/lib/commands/FAILOVER.spec.ts @@ -1,72 +1,72 @@ import { strict as assert } from 'assert'; -import { transformArguments } from './FAILOVER'; +import FAILOVER from './FAILOVER'; describe('FAILOVER', () => { - describe('transformArguments', () => { - it('simple', () => { - assert.deepEqual( - transformArguments(), - ['FAILOVER'] - ); - }); - - describe('with TO', () => { - it('simple', () => { - assert.deepEqual( - transformArguments({ - TO: { - host: 'host', - port: 6379 - } - }), - ['FAILOVER', 'TO', 'host', '6379'] - ); - }); - - it('with FORCE', () => { - assert.deepEqual( - transformArguments({ - TO: { - host: 'host', - port: 6379, - FORCE: true - } - }), - ['FAILOVER', 'TO', 'host', '6379', 'FORCE'] - ); - }); - }); - - it('with ABORT', () => { - assert.deepEqual( - transformArguments({ - ABORT: true - }), - ['FAILOVER', 'ABORT'] - ); - }); - - it('with TIMEOUT', () => { - assert.deepEqual( - transformArguments({ - TIMEOUT: 1 - }), - ['FAILOVER', 'TIMEOUT', '1'] - ); - }); - - it('with TO, ABORT, TIMEOUT', () => { - assert.deepEqual( - transformArguments({ - TO: { - host: 'host', - port: 6379 - }, - ABORT: true, - TIMEOUT: 1 - }), - ['FAILOVER', 'TO', 'host', '6379', 'ABORT', 'TIMEOUT', '1'] - ); - }); + describe('transformArguments', () => { + it('simple', () => { + assert.deepEqual( + FAILOVER.transformArguments(), + ['FAILOVER'] + ); }); + + describe('with TO', () => { + it('simple', () => { + assert.deepEqual( + FAILOVER.transformArguments({ + TO: { + host: 'host', + port: 6379 + } + }), + ['FAILOVER', 'TO', 'host', '6379'] + ); + }); + + it('with FORCE', () => { + assert.deepEqual( + FAILOVER.transformArguments({ + TO: { + host: 'host', + port: 6379, + FORCE: true + } + }), + ['FAILOVER', 'TO', 'host', '6379', 'FORCE'] + ); + }); + }); + + it('with ABORT', () => { + assert.deepEqual( + FAILOVER.transformArguments({ + ABORT: true + }), + ['FAILOVER', 'ABORT'] + ); + }); + + it('with TIMEOUT', () => { + assert.deepEqual( + FAILOVER.transformArguments({ + TIMEOUT: 1 + }), + ['FAILOVER', 'TIMEOUT', '1'] + ); + }); + + it('with TO, ABORT, TIMEOUT', () => { + assert.deepEqual( + FAILOVER.transformArguments({ + TO: { + host: 'host', + port: 6379 + }, + ABORT: true, + TIMEOUT: 1 + }), + ['FAILOVER', 'TO', 'host', '6379', 'ABORT', 'TIMEOUT', '1'] + ); + }); + }); }); diff --git a/packages/client/lib/commands/FCALL.spec.ts b/packages/client/lib/commands/FCALL.spec.ts index fd29f07527..45016e2702 100644 --- a/packages/client/lib/commands/FCALL.spec.ts +++ b/packages/client/lib/commands/FCALL.spec.ts @@ -1,29 +1,29 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; -import { MATH_FUNCTION, loadMathFunction } from '../client/index.spec'; -import { transformArguments } from './FCALL'; +import { MATH_FUNCTION, loadMathFunction } from './FUNCTION_LOAD.spec'; +import FCALL from './FCALL'; describe('FCALL', () => { - testUtils.isVersionGreaterThanHook([7]); + testUtils.isVersionGreaterThanHook([7]); - it('transformArguments', () => { - assert.deepEqual( - transformArguments('function', { - keys: ['key'], - arguments: ['argument'] - }), - ['FCALL', 'function', '1', 'key', 'argument'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + FCALL.transformArguments('function', { + keys: ['key'], + arguments: ['argument'] + }), + ['FCALL', 'function', '1', 'key', 'argument'] + ); + }); - testUtils.testWithClient('client.fCall', async client => { - await loadMathFunction(client); + testUtils.testWithClient('client.fCall', async client => { + await loadMathFunction(client); - assert.equal( - await client.fCall(MATH_FUNCTION.library.square.NAME, { - arguments: ['2'] - }), - 4 - ); - }, GLOBAL.SERVERS.OPEN); + assert.equal( + await client.fCall(MATH_FUNCTION.library.square.NAME, { + arguments: ['2'] + }), + 4 + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/client/lib/commands/FCALL.ts b/packages/client/lib/commands/FCALL.ts index a2411f62dc..57b9f65231 100644 --- a/packages/client/lib/commands/FCALL.ts +++ b/packages/client/lib/commands/FCALL.ts @@ -1,19 +1,9 @@ -import { evalFirstKeyIndex, EvalOptions, pushEvalArguments } from './generic-transformers'; - -export const FIRST_KEY_INDEX = evalFirstKeyIndex; - -export function transformArguments(fn: string, options?: EvalOptions): Array { - return pushEvalArguments(['FCALL', fn], options); -} - -import { SimpleStringReply, Command } from '../RESP/types'; +import { Command } from '../RESP/types'; +import EVAL, { EvalOptions, transformEvalArguments } from './EVAL'; export default { - FIRST_KEY_INDEX: undefined, + FIRST_KEY_INDEX: EVAL.FIRST_KEY_INDEX, IS_READ_ONLY: false, - transformArguments() { - return ['FCALL']; - }, - transformReply: undefined as unknown as () => SimpleStringReply + transformArguments: transformEvalArguments.bind(undefined, 'FCALL'), + transformReply: EVAL.transformReply } as const satisfies Command; - diff --git a/packages/client/lib/commands/FCALL_RO.spec.ts b/packages/client/lib/commands/FCALL_RO.spec.ts index 18665f92aa..ec43a97c6c 100644 --- a/packages/client/lib/commands/FCALL_RO.spec.ts +++ b/packages/client/lib/commands/FCALL_RO.spec.ts @@ -1,29 +1,29 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; -import { MATH_FUNCTION, loadMathFunction } from '../client/index.spec'; -import { transformArguments } from './FCALL_RO'; +import { MATH_FUNCTION, loadMathFunction } from './FUNCTION_LOAD.spec'; +import FCALL_RO from './FCALL_RO'; describe('FCALL_RO', () => { - testUtils.isVersionGreaterThanHook([7]); + testUtils.isVersionGreaterThanHook([7]); - it('transformArguments', () => { - assert.deepEqual( - transformArguments('function', { - keys: ['key'], - arguments: ['argument'] - }), - ['FCALL_RO', 'function', '1', 'key', 'argument'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + FCALL_RO.transformArguments('function', { + keys: ['key'], + arguments: ['argument'] + }), + ['FCALL_RO', 'function', '1', 'key', 'argument'] + ); + }); - testUtils.testWithClient('client.fCallRo', async client => { - await loadMathFunction(client); + testUtils.testWithClient('client.fCallRo', async client => { + await loadMathFunction(client); - assert.equal( - await client.fCallRo(MATH_FUNCTION.library.square.NAME, { - arguments: ['2'] - }), - 4 - ); - }, GLOBAL.SERVERS.OPEN); + assert.equal( + await client.fCallRo(MATH_FUNCTION.library.square.NAME, { + arguments: ['2'] + }), + 4 + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/client/lib/commands/FCALL_RO.ts b/packages/client/lib/commands/FCALL_RO.ts index 66b79aa883..700b25e5f7 100644 --- a/packages/client/lib/commands/FCALL_RO.ts +++ b/packages/client/lib/commands/FCALL_RO.ts @@ -1,9 +1,9 @@ -import { evalFirstKeyIndex, EvalOptions, pushEvalArguments } from './generic-transformers'; +import { Command } from '../RESP/types'; +import EVAL, { EvalOptions, transformEvalArguments } from './EVAL'; -export const FIRST_KEY_INDEX = evalFirstKeyIndex; - -export const IS_READ_ONLY = true; - -export function transformArguments(fn: string, options?: EvalOptions): Array { - return pushEvalArguments(['FCALL_RO', fn], options); -} +export default { + FIRST_KEY_INDEX: EVAL.FIRST_KEY_INDEX, + IS_READ_ONLY: false, + transformArguments: transformEvalArguments.bind(undefined, 'FCALL_RO'), + transformReply: EVAL.transformReply +} as const satisfies Command; diff --git a/packages/client/lib/commands/FUNCTION_DELETE.spec.ts b/packages/client/lib/commands/FUNCTION_DELETE.spec.ts index 563b9aa0a5..a763686d15 100644 --- a/packages/client/lib/commands/FUNCTION_DELETE.spec.ts +++ b/packages/client/lib/commands/FUNCTION_DELETE.spec.ts @@ -1,24 +1,24 @@ import { strict as assert } from 'assert'; -import { MATH_FUNCTION, loadMathFunction } from '../client/index.spec'; import testUtils, { GLOBAL } from '../test-utils'; -import { transformArguments } from './FUNCTION_DELETE'; +import FUNCTION_DELETE from './FUNCTION_DELETE'; +import { MATH_FUNCTION, loadMathFunction } from './FUNCTION_LOAD.spec'; describe('FUNCTION DELETE', () => { - testUtils.isVersionGreaterThanHook([7]); + testUtils.isVersionGreaterThanHook([7]); - it('transformArguments', () => { - assert.deepEqual( - transformArguments('library'), - ['FUNCTION', 'DELETE', 'library'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + FUNCTION_DELETE.transformArguments('library'), + ['FUNCTION', 'DELETE', 'library'] + ); + }); - testUtils.testWithClient('client.functionDelete', async client => { - await loadMathFunction(client); + testUtils.testWithClient('client.functionDelete', async client => { + await loadMathFunction(client); - assert.equal( - await client.functionDelete(MATH_FUNCTION.name), - 'OK' - ); - }, GLOBAL.SERVERS.OPEN); + assert.equal( + await client.functionDelete(MATH_FUNCTION.name), + 'OK' + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/client/lib/commands/FUNCTION_DELETE.ts b/packages/client/lib/commands/FUNCTION_DELETE.ts index c0f8794d98..1061cded17 100644 --- a/packages/client/lib/commands/FUNCTION_DELETE.ts +++ b/packages/client/lib/commands/FUNCTION_DELETE.ts @@ -2,7 +2,7 @@ import { RedisArgument, SimpleStringReply, Command } from '../RESP/types'; export default { FIRST_KEY_INDEX: undefined, - IS_READ_ONLY: true, + IS_READ_ONLY: false, transformArguments(library: RedisArgument) { return ['FUNCTION', 'DELETE', library]; }, diff --git a/packages/client/lib/commands/FUNCTION_DUMP.spec.ts b/packages/client/lib/commands/FUNCTION_DUMP.spec.ts index 360ec6b745..fe6a44c676 100644 --- a/packages/client/lib/commands/FUNCTION_DUMP.spec.ts +++ b/packages/client/lib/commands/FUNCTION_DUMP.spec.ts @@ -1,21 +1,21 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; -import { transformArguments } from './FUNCTION_DUMP'; +import FUNCTION_DUMP from './FUNCTION_DUMP'; describe('FUNCTION DUMP', () => { - testUtils.isVersionGreaterThanHook([7]); + testUtils.isVersionGreaterThanHook([7]); - it('transformArguments', () => { - assert.deepEqual( - transformArguments(), - ['FUNCTION', 'DUMP'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + FUNCTION_DUMP.transformArguments(), + ['FUNCTION', 'DUMP'] + ); + }); - testUtils.testWithClient('client.functionDump', async client => { - assert.equal( - typeof await client.functionDump(), - 'string' - ); - }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('client.functionDump', async client => { + assert.equal( + typeof await client.functionDump(), + 'string' + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/client/lib/commands/FUNCTION_FLUSH.spec.ts b/packages/client/lib/commands/FUNCTION_FLUSH.spec.ts index 12009d0336..0f3c64cf7c 100644 --- a/packages/client/lib/commands/FUNCTION_FLUSH.spec.ts +++ b/packages/client/lib/commands/FUNCTION_FLUSH.spec.ts @@ -1,30 +1,30 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; -import { transformArguments } from './FUNCTION_FLUSH'; +import FUNCTION_FLUSH from './FUNCTION_FLUSH'; describe('FUNCTION FLUSH', () => { - testUtils.isVersionGreaterThanHook([7]); + testUtils.isVersionGreaterThanHook([7]); - describe('transformArguments', () => { - it('simple', () => { - assert.deepEqual( - transformArguments(), - ['FUNCTION', 'FLUSH'] - ); - }); - - it('with mode', () => { - assert.deepEqual( - transformArguments('SYNC'), - ['FUNCTION', 'FLUSH', 'SYNC'] - ); - }); + describe('transformArguments', () => { + it('simple', () => { + assert.deepEqual( + FUNCTION_FLUSH.transformArguments(), + ['FUNCTION', 'FLUSH'] + ); }); - testUtils.testWithClient('client.functionFlush', async client => { - assert.equal( - await client.functionFlush(), - 'OK' - ); - }, GLOBAL.SERVERS.OPEN); + it('with mode', () => { + assert.deepEqual( + FUNCTION_FLUSH.transformArguments('SYNC'), + ['FUNCTION', 'FLUSH', 'SYNC'] + ); + }); + }); + + testUtils.testWithClient('client.functionFlush', async client => { + assert.equal( + await client.functionFlush(), + 'OK' + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/client/lib/commands/FUNCTION_FLUSH.ts b/packages/client/lib/commands/FUNCTION_FLUSH.ts index ab238a5eb5..010e9b8108 100644 --- a/packages/client/lib/commands/FUNCTION_FLUSH.ts +++ b/packages/client/lib/commands/FUNCTION_FLUSH.ts @@ -3,7 +3,7 @@ import { RedisFlushModes } from './FLUSHALL'; export default { FIRST_KEY_INDEX: undefined, - IS_READ_ONLY: true, + IS_READ_ONLY: false, transformArguments(mode?: RedisFlushModes) { const args = ['FUNCTION', 'FLUSH']; @@ -13,5 +13,5 @@ export default { return args; }, - transformReply: undefined as unknown as () => SimpleStringReply + transformReply: undefined as unknown as () => SimpleStringReply<'OK'> } as const satisfies Command; diff --git a/packages/client/lib/commands/FUNCTION_KILL.spec.ts b/packages/client/lib/commands/FUNCTION_KILL.spec.ts index df4848fc82..a79ae9515c 100644 --- a/packages/client/lib/commands/FUNCTION_KILL.spec.ts +++ b/packages/client/lib/commands/FUNCTION_KILL.spec.ts @@ -1,14 +1,14 @@ import { strict as assert } from 'assert'; import testUtils from '../test-utils'; -import { transformArguments } from './FUNCTION_KILL'; +import FUNCTION_KILL from './FUNCTION_KILL'; describe('FUNCTION KILL', () => { - testUtils.isVersionGreaterThanHook([7]); + testUtils.isVersionGreaterThanHook([7]); - it('transformArguments', () => { - assert.deepEqual( - transformArguments(), - ['FUNCTION', 'KILL'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + FUNCTION_KILL.transformArguments(), + ['FUNCTION', 'KILL'] + ); + }); }); diff --git a/packages/client/lib/commands/FUNCTION_LIST.spec.ts b/packages/client/lib/commands/FUNCTION_LIST.spec.ts index 80723d070d..c630b3aa52 100644 --- a/packages/client/lib/commands/FUNCTION_LIST.spec.ts +++ b/packages/client/lib/commands/FUNCTION_LIST.spec.ts @@ -1,41 +1,43 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; -import { MATH_FUNCTION, loadMathFunction } from '../client/index.spec'; -import { transformArguments } from './FUNCTION_LIST'; +import FUNCTION_LIST from './FUNCTION_LIST'; +import { MATH_FUNCTION, loadMathFunction } from './FUNCTION_LOAD.spec'; describe('FUNCTION LIST', () => { - testUtils.isVersionGreaterThanHook([7]); + testUtils.isVersionGreaterThanHook([7]); - describe('transformArguments', () => { - it('simple', () => { - assert.deepEqual( - transformArguments(), - ['FUNCTION', 'LIST'] - ); - }); - - it('with pattern', () => { - assert.deepEqual( - transformArguments('patter*'), - ['FUNCTION', 'LIST', 'patter*'] - ); - }); + describe('transformArguments', () => { + it('simple', () => { + assert.deepEqual( + FUNCTION_LIST.transformArguments(), + ['FUNCTION', 'LIST'] + ); }); - testUtils.testWithClient('client.functionList', async client => { - await loadMathFunction(client); + it('with LIBRARYNAME', () => { + assert.deepEqual( + FUNCTION_LIST.transformArguments({ + LIBRARYNAME: 'patter*' + }), + ['FUNCTION', 'LIST', 'LIBRARYNAME', 'patter*'] + ); + }); + }); - assert.deepEqual( - await client.functionList(), - [{ - libraryName: MATH_FUNCTION.name, - engine: MATH_FUNCTION.engine, - functions: [{ - name: MATH_FUNCTION.library.square.NAME, - description: null, - flags: ['no-writes'] - }] - }] - ); - }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('client.functionList', async client => { + await loadMathFunction(client); + + assert.deepEqual( + await client.functionList(), + [{ + library_name: MATH_FUNCTION.name, + engine: MATH_FUNCTION.engine, + functions: [{ + name: MATH_FUNCTION.library.square.NAME, + description: null, + flags: ['no-writes'] + }] + }] + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/client/lib/commands/FUNCTION_LIST.ts b/packages/client/lib/commands/FUNCTION_LIST.ts index c607513915..7150499e6d 100644 --- a/packages/client/lib/commands/FUNCTION_LIST.ts +++ b/packages/client/lib/commands/FUNCTION_LIST.ts @@ -1,16 +1,45 @@ -// import { RedisCommandArguments } from '.'; -// import { FunctionListItemReply, FunctionListRawItemReply, transformFunctionListItemReply } from './generic-transformers'; +import { RedisArgument, TuplesToMapReply, BlobStringReply, ArrayReply, NullReply, SetReply, Resp2Reply, CommandArguments, Command } from '../RESP/types'; -// export function transformArguments(pattern?: string): RedisCommandArguments { -// const args = ['FUNCTION', 'LIST']; +export interface FunctionListOptions { + LIBRARYNAME?: RedisArgument; +} -// if (pattern) { -// args.push(pattern); -// } +export type FunctionListReplyItem = [ + [BlobStringReply<'library_name'>, BlobStringReply], + [BlobStringReply<'engine'>, BlobStringReply], + [BlobStringReply<'functions'>, ArrayReply, BlobStringReply], + [BlobStringReply<'description'>, BlobStringReply | NullReply], + [BlobStringReply<'flags'>, SetReply], + ]>>] +] -// return args; -// } +export type FunctionListReply = ArrayReply>; -// export function transformReply(reply: Array): Array { -// return reply.map(transformFunctionListItemReply); -// } +export default { + FIRST_KEY_INDEX: undefined, + IS_READ_ONLY: false, + transformArguments(options?: FunctionListOptions) { + const args: CommandArguments = ['FUNCTION', 'LIST']; + + if (options?.LIBRARYNAME) { + args.push('LIBRARYNAME', options.LIBRARYNAME); + } + + return args; + }, + transformReply: { + 2: (reply: Resp2Reply) => { + return reply.map(library => ({ + library_name: library[1], + engine: library[3], + functions: library[5].map(fn => ({ + name: fn[1], + description: fn[3], + flags: fn[5] + })) + })); + }, + 3: undefined as unknown as () => FunctionListReply + } +} as const satisfies Command; diff --git a/packages/client/lib/commands/FUNCTION_LIST_WITHCODE.spec.ts b/packages/client/lib/commands/FUNCTION_LIST_WITHCODE.spec.ts index 56e6102a4b..3c8342ab50 100644 --- a/packages/client/lib/commands/FUNCTION_LIST_WITHCODE.spec.ts +++ b/packages/client/lib/commands/FUNCTION_LIST_WITHCODE.spec.ts @@ -1,42 +1,44 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; -import { MATH_FUNCTION, loadMathFunction } from '../client/index.spec'; -import { transformArguments } from './FUNCTION_LIST_WITHCODE'; +import FUNCTION_LIST_WITHCODE from './FUNCTION_LIST_WITHCODE'; +import { MATH_FUNCTION, loadMathFunction } from './FUNCTION_LOAD.spec'; describe('FUNCTION LIST WITHCODE', () => { - testUtils.isVersionGreaterThanHook([7]); + testUtils.isVersionGreaterThanHook([7]); - describe('transformArguments', () => { - it('simple', () => { - assert.deepEqual( - transformArguments(), - ['FUNCTION', 'LIST', 'WITHCODE'] - ); - }); - - it('with pattern', () => { - assert.deepEqual( - transformArguments('patter*'), - ['FUNCTION', 'LIST', 'patter*', 'WITHCODE'] - ); - }); + describe('transformArguments', () => { + it('simple', () => { + assert.deepEqual( + FUNCTION_LIST_WITHCODE.transformArguments(), + ['FUNCTION', 'LIST', 'WITHCODE'] + ); }); - testUtils.testWithClient('client.functionListWithCode', async client => { - await loadMathFunction(client); + it('with LIBRARYNAME', () => { + assert.deepEqual( + FUNCTION_LIST_WITHCODE.transformArguments({ + LIBRARYNAME: 'patter*' + }), + ['FUNCTION', 'LIST', 'LIBRARYNAME', 'patter*', 'WITHCODE'] + ); + }); + }); - assert.deepEqual( - await client.functionListWithCode(), - [{ - libraryName: MATH_FUNCTION.name, - engine: MATH_FUNCTION.engine, - functions: [{ - name: MATH_FUNCTION.library.square.NAME, - description: null, - flags: ['no-writes'] - }], - libraryCode: MATH_FUNCTION.code - }] - ); - }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('client.functionListWithCode', async client => { + await loadMathFunction(client); + + assert.deepEqual( + await client.functionListWithCode(), + [{ + library_name: MATH_FUNCTION.name, + engine: MATH_FUNCTION.engine, + functions: [{ + name: MATH_FUNCTION.library.square.NAME, + description: null, + flags: ['no-writes'] + }], + library_code: MATH_FUNCTION.code + }] + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/client/lib/commands/FUNCTION_LIST_WITHCODE.ts b/packages/client/lib/commands/FUNCTION_LIST_WITHCODE.ts index 41fdae90ad..6aa83d1d6a 100644 --- a/packages/client/lib/commands/FUNCTION_LIST_WITHCODE.ts +++ b/packages/client/lib/commands/FUNCTION_LIST_WITHCODE.ts @@ -1,26 +1,32 @@ -// import { RedisCommandArguments } from '.'; -// import { transformArguments as transformFunctionListArguments } from './FUNCTION_LIST'; -// import { FunctionListItemReply, FunctionListRawItemReply, transformFunctionListItemReply } from './generic-transformers'; +import { TuplesToMapReply, BlobStringReply, ArrayReply, Command, Resp2Reply } from '../RESP/types'; +import FUNCTION_LIST, { FunctionListReplyItem } from './FUNCTION_LIST'; -// export function transformArguments(pattern?: string): RedisCommandArguments { -// const args = transformFunctionListArguments(pattern); -// args.push('WITHCODE'); -// return args; -// } +export type FunctionListWithCodeReply = ArrayReply, BlobStringReply], +]>>; -// type FunctionListWithCodeRawItemReply = [ -// ...FunctionListRawItemReply, -// 'library_code', -// string -// ]; - -// interface FunctionListWithCodeItemReply extends FunctionListItemReply { -// libraryCode: string; -// } - -// export function transformReply(reply: Array): Array { -// return reply.map(library => ({ -// ...transformFunctionListItemReply(library as unknown as FunctionListRawItemReply), -// libraryCode: library[7] -// })); -// } +export default { + FIRST_KEY_INDEX: FUNCTION_LIST.FIRST_KEY_INDEX, + IS_READ_ONLY: FUNCTION_LIST.IS_READ_ONLY, + transformArguments(...args: Parameters) { + const redisArgs = FUNCTION_LIST.transformArguments(...args); + redisArgs.push('WITHCODE'); + return redisArgs; + }, + transformReply: { + 2: (reply: Resp2Reply) => { + return reply.map((library: any) => ({ + library_name: library[1], + engine: library[3], + functions: library[5].map((fn: any) => ({ + name: fn[1], + description: fn[3], + flags: fn[5] + })), + library_code: library[7] + })) as unknown as number; + }, + 3: undefined as unknown as () => FunctionListWithCodeReply + } +} as const satisfies Command; diff --git a/packages/client/lib/commands/FUNCTION_LOAD.spec.ts b/packages/client/lib/commands/FUNCTION_LOAD.spec.ts index 7be371c6b9..fbda163067 100644 --- a/packages/client/lib/commands/FUNCTION_LOAD.spec.ts +++ b/packages/client/lib/commands/FUNCTION_LOAD.spec.ts @@ -1,36 +1,71 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; -import { MATH_FUNCTION } from '../client/index.spec'; -import { transformArguments } from './FUNCTION_LOAD'; +import FUNCTION_LOAD from './FUNCTION_LOAD'; +import { RedisClientType } from '../client'; +import { NumberReply, RedisFunctions, RedisModules, RedisScripts, RespVersions } from '../RESP/types'; + +export const MATH_FUNCTION = { + name: 'math', + engine: 'LUA', + code: + `#!LUA name=math + redis.register_function{ + function_name = "square", + callback = function(keys, args) return args[1] * args[1] end, + flags = { "no-writes" } + }`, + library: { + square: { + NAME: 'square', + IS_READ_ONLY: true, + NUMBER_OF_KEYS: 0, + transformArguments(number: number) { + return [number.toString()]; + }, + transformReply: undefined as unknown as () => NumberReply + } + } +}; + +export function loadMathFunction< + M extends RedisModules, + F extends RedisFunctions, + S extends RedisScripts, + RESP extends RespVersions +>( + client: RedisClientType +) { + return client.functionLoad( + MATH_FUNCTION.code, + { REPLACE: true } + ); +} describe('FUNCTION LOAD', () => { - testUtils.isVersionGreaterThanHook([7]); + testUtils.isVersionGreaterThanHook([7]); - describe('transformArguments', () => { - it('simple', () => { - assert.deepEqual( - transformArguments( 'code'), - ['FUNCTION', 'LOAD', 'code'] - ); - }); - - it('with REPLACE', () => { - assert.deepEqual( - transformArguments('code', { - REPLACE: true - }), - ['FUNCTION', 'LOAD', 'REPLACE', 'code'] - ); - }); + describe('transformArguments', () => { + it('simple', () => { + assert.deepEqual( + FUNCTION_LOAD.transformArguments('code'), + ['FUNCTION', 'LOAD', 'code'] + ); }); - testUtils.testWithClient('client.functionLoad', async client => { - assert.equal( - await client.functionLoad( - MATH_FUNCTION.code, - { REPLACE: true } - ), - MATH_FUNCTION.name - ); - }, GLOBAL.SERVERS.OPEN); + it('with REPLACE', () => { + assert.deepEqual( + FUNCTION_LOAD.transformArguments('code', { + REPLACE: true + }), + ['FUNCTION', 'LOAD', 'REPLACE', 'code'] + ); + }); + }); + + testUtils.testWithClient('client.functionLoad', async client => { + assert.equal( + await loadMathFunction(client), + MATH_FUNCTION.name + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/client/lib/commands/FUNCTION_LOAD.ts b/packages/client/lib/commands/FUNCTION_LOAD.ts index c24ee0e9f8..32b030909a 100644 --- a/packages/client/lib/commands/FUNCTION_LOAD.ts +++ b/packages/client/lib/commands/FUNCTION_LOAD.ts @@ -1,22 +1,22 @@ -// import { RedisCommandArguments } from '.'; +import { RedisArgument, CommandArguments, BlobStringReply, Command } from '../RESP/types'; -// interface FunctionLoadOptions { -// REPLACE?: boolean; -// } +export interface FunctionLoadOptions { + REPLACE?: boolean; +} -// export function transformArguments( -// code: string, -// options?: FunctionLoadOptions -// ): RedisCommandArguments { -// const args = ['FUNCTION', 'LOAD']; +export default { + FIRST_KEY_INDEX: undefined, + IS_READ_ONLY: false, + transformArguments(code: RedisArgument, options?: FunctionLoadOptions) { + const args: CommandArguments = ['FUNCTION', 'LOAD']; -// if (options?.REPLACE) { -// args.push('REPLACE'); -// } + if (options?.REPLACE) { + args.push('REPLACE'); + } -// args.push(code); + args.push(code); -// return args; -// } - -// export declare function transformReply(): string; + return args; + }, + transformReply: undefined as unknown as () => BlobStringReply +} as const satisfies Command; diff --git a/packages/client/lib/commands/FUNCTION_RESTORE.spec.ts b/packages/client/lib/commands/FUNCTION_RESTORE.spec.ts index a5c2e2dcc7..546bc4a363 100644 --- a/packages/client/lib/commands/FUNCTION_RESTORE.spec.ts +++ b/packages/client/lib/commands/FUNCTION_RESTORE.spec.ts @@ -1,37 +1,38 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; -import { transformArguments } from './FUNCTION_RESTORE'; +import FUNCTION_RESTORE from './FUNCTION_RESTORE'; +import { RESP_TYPES } from '../RESP/decoder'; describe('FUNCTION RESTORE', () => { - testUtils.isVersionGreaterThanHook([7]); + testUtils.isVersionGreaterThanHook([7]); - describe('transformArguments', () => { - it('simple', () => { - assert.deepEqual( - transformArguments('dump'), - ['FUNCTION', 'RESTORE', 'dump'] - ); - }); - - it('with mode', () => { - assert.deepEqual( - transformArguments('dump', 'APPEND'), - ['FUNCTION', 'RESTORE', 'dump', 'APPEND'] - ); - }); + describe('transformArguments', () => { + it('simple', () => { + assert.deepEqual( + FUNCTION_RESTORE.transformArguments('dump'), + ['FUNCTION', 'RESTORE', 'dump'] + ); }); - testUtils.testWithClient('client.functionRestore', async client => { - assert.equal( - await client.functionRestore( - await client.functionDump( - client.commandOptions({ - returnBuffers: true - }) - ), - 'FLUSH' - ), - 'OK' - ); - }, GLOBAL.SERVERS.OPEN); + it('with mode', () => { + assert.deepEqual( + FUNCTION_RESTORE.transformArguments('dump', { + mode: 'APPEND' + }), + ['FUNCTION', 'RESTORE', 'dump', 'APPEND'] + ); + }); + }); + + testUtils.testWithClient('client.functionRestore', async client => { + assert.equal( + await client.functionRestore( + await client.withTypeMapping({ + [RESP_TYPES.BLOB_STRING]: Buffer + }).functionDump(), + 'FLUSH' + ), + 'OK' + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/client/lib/commands/FUNCTION_RESTORE.ts b/packages/client/lib/commands/FUNCTION_RESTORE.ts index 92f87288c3..8c87553056 100644 --- a/packages/client/lib/commands/FUNCTION_RESTORE.ts +++ b/packages/client/lib/commands/FUNCTION_RESTORE.ts @@ -1,16 +1,20 @@ -// import { RedisCommandArgument, RedisCommandArguments } from '.'; +import { SimpleStringReply, Command, RedisArgument } from '../RESP/types'; -// export function transformArguments( -// dump: RedisCommandArgument, -// mode?: 'FLUSH' | 'APPEND' | 'REPLACE' -// ): RedisCommandArguments { -// const args = ['FUNCTION', 'RESTORE', dump]; +export interface FunctionRestoreOptions { + mode?: 'FLUSH' | 'APPEND' | 'REPLACE'; +} -// if (mode) { -// args.push(mode); -// } +export default { + FIRST_KEY_INDEX: undefined, + IS_READ_ONLY: false, + transformArguments(dump: RedisArgument, options?: FunctionRestoreOptions) { + const args = ['FUNCTION', 'RESTORE', dump]; -// return args; -// } + if (options?.mode) { + args.push(options.mode); + } -// export declare function transformReply(): 'OK'; + return args; + }, + transformReply: undefined as unknown as () => SimpleStringReply<'OK'> +} as const satisfies Command; diff --git a/packages/client/lib/commands/FUNCTION_STATS.spec.ts b/packages/client/lib/commands/FUNCTION_STATS.spec.ts index a5e26b5fec..c67175a622 100644 --- a/packages/client/lib/commands/FUNCTION_STATS.spec.ts +++ b/packages/client/lib/commands/FUNCTION_STATS.spec.ts @@ -1,25 +1,25 @@ -import { strict as assert } from 'assert'; -import testUtils, { GLOBAL } from '../test-utils'; -import { transformArguments } from './FUNCTION_STATS'; +// import { strict as assert } from 'assert'; +// import testUtils, { GLOBAL } from '../test-utils'; +// import { transformArguments } from './FUNCTION_STATS'; -describe('FUNCTION STATS', () => { - testUtils.isVersionGreaterThanHook([7]); +// describe('FUNCTION STATS', () => { +// testUtils.isVersionGreaterThanHook([7]); - it('transformArguments', () => { - assert.deepEqual( - transformArguments(), - ['FUNCTION', 'STATS'] - ); - }); +// it('transformArguments', () => { +// assert.deepEqual( +// transformArguments(), +// ['FUNCTION', 'STATS'] +// ); +// }); - testUtils.testWithClient('client.functionStats', async client => { - const stats = await client.functionStats(); - assert.equal(stats.runningScript, null); - assert.equal(typeof stats.engines, 'object'); - for (const [engine, { librariesCount, functionsCount }] of Object.entries(stats.engines)) { - assert.equal(typeof engine, 'string'); - assert.equal(typeof librariesCount, 'number'); - assert.equal(typeof functionsCount, 'number'); - } - }, GLOBAL.SERVERS.OPEN); -}); +// testUtils.testWithClient('client.functionStats', async client => { +// const stats = await client.functionStats(); +// assert.equal(stats.runningScript, null); +// assert.equal(typeof stats.engines, 'object'); +// for (const [engine, { librariesCount, functionsCount }] of Object.entries(stats.engines)) { +// assert.equal(typeof engine, 'string'); +// assert.equal(typeof librariesCount, 'number'); +// assert.equal(typeof functionsCount, 'number'); +// } +// }, GLOBAL.SERVERS.OPEN); +// }); diff --git a/packages/client/lib/commands/generic-transformers.spec.ts b/packages/client/lib/commands/generic-transformers.spec.ts index 0c64a2175f..6bd1bcc801 100644 --- a/packages/client/lib/commands/generic-transformers.spec.ts +++ b/packages/client/lib/commands/generic-transformers.spec.ts @@ -1,685 +1,685 @@ -import { strict as assert } from 'assert'; -import { - transformBooleanReply, - transformBooleanArrayReply, - pushScanArguments, - transformNumberInfinityReply, - transformNumberInfinityNullReply, - transformNumberInfinityArgument, - transformStringNumberInfinityArgument, - transformTuplesReply, - transformStreamMessagesReply, - transformStreamsMessagesReply, - transformSortedSetWithScoresReply, - pushGeoCountArgument, - pushGeoSearchArguments, - GeoReplyWith, - transformGeoMembersWithReply, - transformEXAT, - transformPXAT, - pushEvalArguments, - pushVariadicArguments, - pushVariadicNumberArguments, - pushVariadicArgument, - pushOptionalVariadicArgument, - transformCommandReply, - CommandFlags, - CommandCategories, - pushSlotRangesArguments -} from './generic-transformers'; +// import { strict as assert } from 'assert'; +// import { +// transformBooleanReply, +// transformBooleanArrayReply, +// pushScanArguments, +// transformNumberInfinityReply, +// transformNumberInfinityNullReply, +// transformNumberInfinityArgument, +// transformStringNumberInfinityArgument, +// transformTuplesReply, +// transformStreamMessagesReply, +// transformStreamsMessagesReply, +// transformSortedSetWithScoresReply, +// pushGeoCountArgument, +// pushGeoSearchArguments, +// GeoReplyWith, +// transformGeoMembersWithReply, +// transformEXAT, +// transformPXAT, +// pushEvalArguments, +// pushVariadicArguments, +// pushVariadicNumberArguments, +// pushVariadicArgument, +// pushOptionalVariadicArgument, +// transformCommandReply, +// CommandFlags, +// CommandCategories, +// pushSlotRangesArguments +// } from './generic-transformers'; -describe('Generic Transformers', () => { - describe('transformBooleanReply', () => { - it('0', () => { - assert.equal( - transformBooleanReply(0), - false - ); - }); +// describe('Generic Transformers', () => { +// describe('transformBooleanReply', () => { +// it('0', () => { +// assert.equal( +// transformBooleanReply(0), +// false +// ); +// }); - it('1', () => { - assert.equal( - transformBooleanReply(1), - true - ); - }); - }); +// it('1', () => { +// assert.equal( +// transformBooleanReply(1), +// true +// ); +// }); +// }); - describe('transformBooleanArrayReply', () => { - it('empty array', () => { - assert.deepEqual( - transformBooleanArrayReply([]), - [] - ); - }); +// describe('transformBooleanArrayReply', () => { +// it('empty array', () => { +// assert.deepEqual( +// transformBooleanArrayReply([]), +// [] +// ); +// }); - it('0, 1', () => { - assert.deepEqual( - transformBooleanArrayReply([0, 1]), - [false, true] - ); - }); - }); +// it('0, 1', () => { +// assert.deepEqual( +// transformBooleanArrayReply([0, 1]), +// [false, true] +// ); +// }); +// }); - describe('pushScanArguments', () => { - it('cusror only', () => { - assert.deepEqual( - pushScanArguments([], 0), - ['0'] - ); - }); +// describe('pushScanArguments', () => { +// it('cusror only', () => { +// assert.deepEqual( +// pushScanArguments([], 0), +// ['0'] +// ); +// }); - it('with MATCH', () => { - assert.deepEqual( - pushScanArguments([], 0, { - MATCH: 'pattern' - }), - ['0', 'MATCH', 'pattern'] - ); - }); +// it('with MATCH', () => { +// assert.deepEqual( +// pushScanArguments([], 0, { +// MATCH: 'pattern' +// }), +// ['0', 'MATCH', 'pattern'] +// ); +// }); - it('with COUNT', () => { - assert.deepEqual( - pushScanArguments([], 0, { - COUNT: 1 - }), - ['0', 'COUNT', '1'] - ); - }); +// it('with COUNT', () => { +// assert.deepEqual( +// pushScanArguments([], 0, { +// COUNT: 1 +// }), +// ['0', 'COUNT', '1'] +// ); +// }); - it('with MATCH & COUNT', () => { - assert.deepEqual( - pushScanArguments([], 0, { - MATCH: 'pattern', - COUNT: 1 - }), - ['0', 'MATCH', 'pattern', 'COUNT', '1'] - ); - }); - }); +// it('with MATCH & COUNT', () => { +// assert.deepEqual( +// pushScanArguments([], 0, { +// MATCH: 'pattern', +// COUNT: 1 +// }), +// ['0', 'MATCH', 'pattern', 'COUNT', '1'] +// ); +// }); +// }); - describe('transformNumberInfinityReply', () => { - it('0.5', () => { - assert.equal( - transformNumberInfinityReply('0.5'), - 0.5 - ); - }); +// describe('transformNumberInfinityReply', () => { +// it('0.5', () => { +// assert.equal( +// transformNumberInfinityReply('0.5'), +// 0.5 +// ); +// }); - it('+inf', () => { - assert.equal( - transformNumberInfinityReply('+inf'), - Infinity - ); - }); +// it('+inf', () => { +// assert.equal( +// transformNumberInfinityReply('+inf'), +// Infinity +// ); +// }); - it('-inf', () => { - assert.equal( - transformNumberInfinityReply('-inf'), - -Infinity - ); - }); - }); +// it('-inf', () => { +// assert.equal( +// transformNumberInfinityReply('-inf'), +// -Infinity +// ); +// }); +// }); - describe('transformNumberInfinityNullReply', () => { - it('null', () => { - assert.equal( - transformNumberInfinityNullReply(null), - null - ); - }); +// describe('transformNumberInfinityNullReply', () => { +// it('null', () => { +// assert.equal( +// transformNumberInfinityNullReply(null), +// null +// ); +// }); - it('1', () => { - assert.equal( - transformNumberInfinityNullReply('1'), - 1 - ); - }); - }); +// it('1', () => { +// assert.equal( +// transformNumberInfinityNullReply('1'), +// 1 +// ); +// }); +// }); - describe('transformNumberInfinityArgument', () => { - it('0.5', () => { - assert.equal( - transformNumberInfinityArgument(0.5), - '0.5' - ); - }); +// describe('transformNumberInfinityArgument', () => { +// it('0.5', () => { +// assert.equal( +// transformNumberInfinityArgument(0.5), +// '0.5' +// ); +// }); - it('Infinity', () => { - assert.equal( - transformNumberInfinityArgument(Infinity), - '+inf' - ); - }); +// it('Infinity', () => { +// assert.equal( +// transformNumberInfinityArgument(Infinity), +// '+inf' +// ); +// }); - it('-Infinity', () => { - assert.equal( - transformNumberInfinityArgument(-Infinity), - '-inf' - ); - }); - }); +// it('-Infinity', () => { +// assert.equal( +// transformNumberInfinityArgument(-Infinity), +// '-inf' +// ); +// }); +// }); - describe('transformStringNumberInfinityArgument', () => { - it("'0.5'", () => { - assert.equal( - transformStringNumberInfinityArgument('0.5'), - '0.5' - ); - }); +// describe('transformStringNumberInfinityArgument', () => { +// it("'0.5'", () => { +// assert.equal( +// transformStringNumberInfinityArgument('0.5'), +// '0.5' +// ); +// }); - it('0.5', () => { - assert.equal( - transformStringNumberInfinityArgument(0.5), - '0.5' - ); - }); - }); +// it('0.5', () => { +// assert.equal( +// transformStringNumberInfinityArgument(0.5), +// '0.5' +// ); +// }); +// }); - it('transformTuplesReply', () => { - assert.deepEqual( - transformTuplesReply(['key1', 'value1', 'key2', 'value2']), - Object.create(null, { - key1: { - value: 'value1', - configurable: true, - enumerable: true - }, - key2: { - value: 'value2', - configurable: true, - enumerable: true - } - }) - ); - }); +// it('transformTuplesReply', () => { +// assert.deepEqual( +// transformTuplesReply(['key1', 'value1', 'key2', 'value2']), +// Object.create(null, { +// key1: { +// value: 'value1', +// configurable: true, +// enumerable: true +// }, +// key2: { +// value: 'value2', +// configurable: true, +// enumerable: true +// } +// }) +// ); +// }); - it('transformStreamMessagesReply', () => { - assert.deepEqual( - transformStreamMessagesReply([['0-0', ['0key', '0value']], ['1-0', ['1key', '1value']]]), - [{ - id: '0-0', - message: Object.create(null, { - '0key': { - value: '0value', - configurable: true, - enumerable: true - } - }) - }, { - id: '1-0', - message: Object.create(null, { - '1key': { - value: '1value', - configurable: true, - enumerable: true - } - }) - }] - ); - }); +// it('transformStreamMessagesReply', () => { +// assert.deepEqual( +// transformStreamMessagesReply([['0-0', ['0key', '0value']], ['1-0', ['1key', '1value']]]), +// [{ +// id: '0-0', +// message: Object.create(null, { +// '0key': { +// value: '0value', +// configurable: true, +// enumerable: true +// } +// }) +// }, { +// id: '1-0', +// message: Object.create(null, { +// '1key': { +// value: '1value', +// configurable: true, +// enumerable: true +// } +// }) +// }] +// ); +// }); - describe('transformStreamsMessagesReply', () => { - it('null', () => { - assert.equal( - transformStreamsMessagesReply(null), - null - ); - }); +// describe('transformStreamsMessagesReply', () => { +// it('null', () => { +// assert.equal( +// transformStreamsMessagesReply(null), +// null +// ); +// }); - it('with messages', () => { - assert.deepEqual( - transformStreamsMessagesReply([['stream1', [['0-1', ['11key', '11value']], ['1-1', ['12key', '12value']]]], ['stream2', [['0-2', ['2key1', '2value1', '2key2', '2value2']]]]]), - [{ - name: 'stream1', - messages: [{ - id: '0-1', - message: Object.create(null, { - '11key': { - value: '11value', - configurable: true, - enumerable: true - } - }) - }, { - id: '1-1', - message: Object.create(null, { - '12key': { - value: '12value', - configurable: true, - enumerable: true - } - }) - }] - }, { - name: 'stream2', - messages: [{ - id: '0-2', - message: Object.create(null, { - '2key1': { - value: '2value1', - configurable: true, - enumerable: true - }, - '2key2': { - value: '2value2', - configurable: true, - enumerable: true - } - }) - }] - }] - ); - }); - }); +// it('with messages', () => { +// assert.deepEqual( +// transformStreamsMessagesReply([['stream1', [['0-1', ['11key', '11value']], ['1-1', ['12key', '12value']]]], ['stream2', [['0-2', ['2key1', '2value1', '2key2', '2value2']]]]]), +// [{ +// name: 'stream1', +// messages: [{ +// id: '0-1', +// message: Object.create(null, { +// '11key': { +// value: '11value', +// configurable: true, +// enumerable: true +// } +// }) +// }, { +// id: '1-1', +// message: Object.create(null, { +// '12key': { +// value: '12value', +// configurable: true, +// enumerable: true +// } +// }) +// }] +// }, { +// name: 'stream2', +// messages: [{ +// id: '0-2', +// message: Object.create(null, { +// '2key1': { +// value: '2value1', +// configurable: true, +// enumerable: true +// }, +// '2key2': { +// value: '2value2', +// configurable: true, +// enumerable: true +// } +// }) +// }] +// }] +// ); +// }); +// }); - it('transformSortedSetWithScoresReply', () => { - assert.deepEqual( - transformSortedSetWithScoresReply(['member1', '0.5', 'member2', '+inf', 'member3', '-inf']), - [{ - value: 'member1', - score: 0.5 - }, { - value: 'member2', - score: Infinity - }, { - value: 'member3', - score: -Infinity - }] - ); - }); +// it('transformSortedSetWithScoresReply', () => { +// assert.deepEqual( +// transformSortedSetWithScoresReply(['member1', '0.5', 'member2', '+inf', 'member3', '-inf']), +// [{ +// value: 'member1', +// score: 0.5 +// }, { +// value: 'member2', +// score: Infinity +// }, { +// value: 'member3', +// score: -Infinity +// }] +// ); +// }); - describe('pushGeoCountArgument', () => { - it('undefined', () => { - assert.deepEqual( - pushGeoCountArgument([], undefined), - [] - ); - }); +// describe('pushGeoCountArgument', () => { +// it('undefined', () => { +// assert.deepEqual( +// pushGeoCountArgument([], undefined), +// [] +// ); +// }); - it('number', () => { - assert.deepEqual( - pushGeoCountArgument([], 1), - ['COUNT', '1'] - ); - }); +// it('number', () => { +// assert.deepEqual( +// pushGeoCountArgument([], 1), +// ['COUNT', '1'] +// ); +// }); - describe('with COUNT', () => { - it('number', () => { - assert.deepEqual( - pushGeoCountArgument([], 1), - ['COUNT', '1'] - ); - }); +// describe('with COUNT', () => { +// it('number', () => { +// assert.deepEqual( +// pushGeoCountArgument([], 1), +// ['COUNT', '1'] +// ); +// }); - describe('object', () => { - it('value', () => { - assert.deepEqual( - pushGeoCountArgument([], { value: 1 }), - ['COUNT', '1'] - ); - }); +// describe('object', () => { +// it('value', () => { +// assert.deepEqual( +// pushGeoCountArgument([], { value: 1 }), +// ['COUNT', '1'] +// ); +// }); - it('value, ANY', () => { - assert.deepEqual( - pushGeoCountArgument([], { - value: 1, - ANY: true - }), - ['COUNT', '1', 'ANY'] - ); - }); - }); - }); - }); +// it('value, ANY', () => { +// assert.deepEqual( +// pushGeoCountArgument([], { +// value: 1, +// ANY: true +// }), +// ['COUNT', '1', 'ANY'] +// ); +// }); +// }); +// }); +// }); - describe('pushGeoSearchArguments', () => { - it('FROMMEMBER, BYRADIUS', () => { - assert.deepEqual( - pushGeoSearchArguments([], 'key', 'member', { - radius: 1, - unit: 'm' - }), - ['key', 'FROMMEMBER', 'member', 'BYRADIUS', '1', 'm'] - ); - }); +// describe('pushGeoSearchArguments', () => { +// it('FROMMEMBER, BYRADIUS', () => { +// assert.deepEqual( +// pushGeoSearchArguments([], 'key', 'member', { +// radius: 1, +// unit: 'm' +// }), +// ['key', 'FROMMEMBER', 'member', 'BYRADIUS', '1', 'm'] +// ); +// }); - it('FROMLONLAT, BYBOX', () => { - assert.deepEqual( - pushGeoSearchArguments([], 'key', { - longitude: 1, - latitude: 2 - }, { - width: 1, - height: 2, - unit: 'm' - }), - ['key', 'FROMLONLAT', '1', '2', 'BYBOX', '1', '2', 'm'] - ); - }); +// it('FROMLONLAT, BYBOX', () => { +// assert.deepEqual( +// pushGeoSearchArguments([], 'key', { +// longitude: 1, +// latitude: 2 +// }, { +// width: 1, +// height: 2, +// unit: 'm' +// }), +// ['key', 'FROMLONLAT', '1', '2', 'BYBOX', '1', '2', 'm'] +// ); +// }); - it('with SORT', () => { - assert.deepEqual( - pushGeoSearchArguments([], 'key', 'member', { - radius: 1, - unit: 'm' - }, { - SORT: 'ASC' - }), - ['key', 'FROMMEMBER', 'member', 'BYRADIUS', '1', 'm', 'ASC'] - ); - }); - }); +// it('with SORT', () => { +// assert.deepEqual( +// pushGeoSearchArguments([], 'key', 'member', { +// radius: 1, +// unit: 'm' +// }, { +// SORT: 'ASC' +// }), +// ['key', 'FROMMEMBER', 'member', 'BYRADIUS', '1', 'm', 'ASC'] +// ); +// }); +// }); - describe('transformGeoMembersWithReply', () => { - it('DISTANCE', () => { - assert.deepEqual( - transformGeoMembersWithReply([ - [ - '1', - '2' - ], - [ - '3', - '4' - ] - ], [GeoReplyWith.DISTANCE]), - [{ - member: '1', - distance: '2' - }, { - member: '3', - distance: '4' - }] - ); - }); +// describe('transformGeoMembersWithReply', () => { +// it('DISTANCE', () => { +// assert.deepEqual( +// transformGeoMembersWithReply([ +// [ +// '1', +// '2' +// ], +// [ +// '3', +// '4' +// ] +// ], [GeoReplyWith.DISTANCE]), +// [{ +// member: '1', +// distance: '2' +// }, { +// member: '3', +// distance: '4' +// }] +// ); +// }); - it('HASH', () => { - assert.deepEqual( - transformGeoMembersWithReply([ - [ - '1', - 2 - ], - [ - '3', - 4 - ] - ], [GeoReplyWith.HASH]), - [{ - member: '1', - hash: 2 - }, { - member: '3', - hash: 4 - }] - ); - }); +// it('HASH', () => { +// assert.deepEqual( +// transformGeoMembersWithReply([ +// [ +// '1', +// 2 +// ], +// [ +// '3', +// 4 +// ] +// ], [GeoReplyWith.HASH]), +// [{ +// member: '1', +// hash: 2 +// }, { +// member: '3', +// hash: 4 +// }] +// ); +// }); - it('COORDINATES', () => { - assert.deepEqual( - transformGeoMembersWithReply([ - [ - '1', - [ - '2', - '3' - ] - ], - [ - '4', - [ - '5', - '6' - ] - ] - ], [GeoReplyWith.COORDINATES]), - [{ - member: '1', - coordinates: { - longitude: '2', - latitude: '3' - } - }, { - member: '4', - coordinates: { - longitude: '5', - latitude: '6' - } - }] - ); - }); +// it('COORDINATES', () => { +// assert.deepEqual( +// transformGeoMembersWithReply([ +// [ +// '1', +// [ +// '2', +// '3' +// ] +// ], +// [ +// '4', +// [ +// '5', +// '6' +// ] +// ] +// ], [GeoReplyWith.COORDINATES]), +// [{ +// member: '1', +// coordinates: { +// longitude: '2', +// latitude: '3' +// } +// }, { +// member: '4', +// coordinates: { +// longitude: '5', +// latitude: '6' +// } +// }] +// ); +// }); - it('DISTANCE, HASH, COORDINATES', () => { - assert.deepEqual( - transformGeoMembersWithReply([ - [ - '1', - '2', - 3, - [ - '4', - '5' - ] - ], - [ - '6', - '7', - 8, - [ - '9', - '10' - ] - ] - ], [GeoReplyWith.DISTANCE, GeoReplyWith.HASH, GeoReplyWith.COORDINATES]), - [{ - member: '1', - distance: '2', - hash: 3, - coordinates: { - longitude: '4', - latitude: '5' - } - }, { - member: '6', - distance: '7', - hash: 8, - coordinates: { - longitude: '9', - latitude: '10' - } - }] - ); - }); - }); +// it('DISTANCE, HASH, COORDINATES', () => { +// assert.deepEqual( +// transformGeoMembersWithReply([ +// [ +// '1', +// '2', +// 3, +// [ +// '4', +// '5' +// ] +// ], +// [ +// '6', +// '7', +// 8, +// [ +// '9', +// '10' +// ] +// ] +// ], [GeoReplyWith.DISTANCE, GeoReplyWith.HASH, GeoReplyWith.COORDINATES]), +// [{ +// member: '1', +// distance: '2', +// hash: 3, +// coordinates: { +// longitude: '4', +// latitude: '5' +// } +// }, { +// member: '6', +// distance: '7', +// hash: 8, +// coordinates: { +// longitude: '9', +// latitude: '10' +// } +// }] +// ); +// }); +// }); - describe('transformEXAT', () => { - it('number', () => { - assert.equal( - transformEXAT(1), - '1' - ); - }); +// describe('transformEXAT', () => { +// it('number', () => { +// assert.equal( +// transformEXAT(1), +// '1' +// ); +// }); - it('date', () => { - const d = new Date(); - assert.equal( - transformEXAT(d), - Math.floor(d.getTime() / 1000).toString() - ); - }); - }); +// it('date', () => { +// const d = new Date(); +// assert.equal( +// transformEXAT(d), +// Math.floor(d.getTime() / 1000).toString() +// ); +// }); +// }); - describe('transformPXAT', () => { - it('number', () => { - assert.equal( - transformPXAT(1), - '1' - ); - }); +// describe('transformPXAT', () => { +// it('number', () => { +// assert.equal( +// transformPXAT(1), +// '1' +// ); +// }); - it('date', () => { - const d = new Date(); - assert.equal( - transformPXAT(d), - d.getTime().toString() - ); - }); - }); +// it('date', () => { +// const d = new Date(); +// assert.equal( +// transformPXAT(d), +// d.getTime().toString() +// ); +// }); +// }); - describe('pushEvalArguments', () => { - it('empty', () => { - assert.deepEqual( - pushEvalArguments([]), - ['0'] - ); - }); +// describe('pushEvalArguments', () => { +// it('empty', () => { +// assert.deepEqual( +// pushEvalArguments([]), +// ['0'] +// ); +// }); - it('with keys', () => { - assert.deepEqual( - pushEvalArguments([], { - keys: ['key'] - }), - ['1', 'key'] - ); - }); +// it('with keys', () => { +// assert.deepEqual( +// pushEvalArguments([], { +// keys: ['key'] +// }), +// ['1', 'key'] +// ); +// }); - it('with arguments', () => { - assert.deepEqual( - pushEvalArguments([], { - arguments: ['argument'] - }), - ['0', 'argument'] - ); - }); +// it('with arguments', () => { +// assert.deepEqual( +// pushEvalArguments([], { +// arguments: ['argument'] +// }), +// ['0', 'argument'] +// ); +// }); - it('with keys and arguments', () => { - assert.deepEqual( - pushEvalArguments([], { - keys: ['key'], - arguments: ['argument'] - }), - ['1', 'key', 'argument'] - ); - }); - }); +// it('with keys and arguments', () => { +// assert.deepEqual( +// pushEvalArguments([], { +// keys: ['key'], +// arguments: ['argument'] +// }), +// ['1', 'key', 'argument'] +// ); +// }); +// }); - describe('pushVariadicArguments', () => { - it('string', () => { - assert.deepEqual( - pushVariadicArguments([], 'string'), - ['string'] - ); - }); +// describe('pushVariadicArguments', () => { +// it('string', () => { +// assert.deepEqual( +// pushVariadicArguments([], 'string'), +// ['string'] +// ); +// }); - it('array', () => { - assert.deepEqual( - pushVariadicArguments([], ['1', '2']), - ['1', '2'] - ); - }); - }); +// it('array', () => { +// assert.deepEqual( +// pushVariadicArguments([], ['1', '2']), +// ['1', '2'] +// ); +// }); +// }); - describe('pushVariadicNumberArguments', () => { - it('number', () => { - assert.deepEqual( - pushVariadicNumberArguments([], 0), - ['0'] - ); - }); +// describe('pushVariadicNumberArguments', () => { +// it('number', () => { +// assert.deepEqual( +// pushVariadicNumberArguments([], 0), +// ['0'] +// ); +// }); - it('array', () => { - assert.deepEqual( - pushVariadicNumberArguments([], [0, 1]), - ['0', '1'] - ); - }); - }); +// it('array', () => { +// assert.deepEqual( +// pushVariadicNumberArguments([], [0, 1]), +// ['0', '1'] +// ); +// }); +// }); - describe('pushVariadicArgument', () => { - it('string', () => { - assert.deepEqual( - pushVariadicArgument([], 'string'), - ['1', 'string'] - ); - }); +// describe('pushVariadicArgument', () => { +// it('string', () => { +// assert.deepEqual( +// pushVariadicArgument([], 'string'), +// ['1', 'string'] +// ); +// }); - it('array', () => { - assert.deepEqual( - pushVariadicArgument([], ['1', '2']), - ['2', '1', '2'] - ); - }); - }); +// it('array', () => { +// assert.deepEqual( +// pushVariadicArgument([], ['1', '2']), +// ['2', '1', '2'] +// ); +// }); +// }); - describe('pushOptionalVariadicArgument', () => { - it('undefined', () => { - assert.deepEqual( - pushOptionalVariadicArgument([], 'name', undefined), - [] - ); - }); +// describe('pushOptionalVariadicArgument', () => { +// it('undefined', () => { +// assert.deepEqual( +// pushOptionalVariadicArgument([], 'name', undefined), +// [] +// ); +// }); - it('string', () => { - assert.deepEqual( - pushOptionalVariadicArgument([], 'name', 'string'), - ['name', '1', 'string'] - ); - }); +// it('string', () => { +// assert.deepEqual( +// pushOptionalVariadicArgument([], 'name', 'string'), +// ['name', '1', 'string'] +// ); +// }); - it('array', () => { - assert.deepEqual( - pushOptionalVariadicArgument([], 'name', ['1', '2']), - ['name', '2', '1', '2'] - ); - }); - }); +// it('array', () => { +// assert.deepEqual( +// pushOptionalVariadicArgument([], 'name', ['1', '2']), +// ['name', '2', '1', '2'] +// ); +// }); +// }); - it('transformCommandReply', () => { - assert.deepEqual( - transformCommandReply([ - 'ping', - -1, - [CommandFlags.STALE, CommandFlags.FAST], - 0, - 0, - 0, - [CommandCategories.FAST, CommandCategories.CONNECTION] - ]), - { - name: 'ping', - arity: -1, - flags: new Set([CommandFlags.STALE, CommandFlags.FAST]), - firstKeyIndex: 0, - lastKeyIndex: 0, - step: 0, - categories: new Set([CommandCategories.FAST, CommandCategories.CONNECTION]) - } - ); - }); +// it('transformCommandReply', () => { +// assert.deepEqual( +// transformCommandReply([ +// 'ping', +// -1, +// [CommandFlags.STALE, CommandFlags.FAST], +// 0, +// 0, +// 0, +// [CommandCategories.FAST, CommandCategories.CONNECTION] +// ]), +// { +// name: 'ping', +// arity: -1, +// flags: new Set([CommandFlags.STALE, CommandFlags.FAST]), +// firstKeyIndex: 0, +// lastKeyIndex: 0, +// step: 0, +// categories: new Set([CommandCategories.FAST, CommandCategories.CONNECTION]) +// } +// ); +// }); - describe('pushSlotRangesArguments', () => { - it('single range', () => { - assert.deepEqual( - pushSlotRangesArguments([], { - start: 0, - end: 1 - }), - ['0', '1'] - ); - }); +// describe('pushSlotRangesArguments', () => { +// it('single range', () => { +// assert.deepEqual( +// pushSlotRangesArguments([], { +// start: 0, +// end: 1 +// }), +// ['0', '1'] +// ); +// }); - it('multiple ranges', () => { - assert.deepEqual( - pushSlotRangesArguments([], [{ - start: 0, - end: 1 - }, { - start: 2, - end: 3 - }]), - ['0', '1', '2', '3'] - ); - }); - }); -}); +// it('multiple ranges', () => { +// assert.deepEqual( +// pushSlotRangesArguments([], [{ +// start: 0, +// end: 1 +// }, { +// start: 2, +// end: 3 +// }]), +// ['0', '1', '2', '3'] +// ); +// }); +// }); +// }); diff --git a/packages/client/lib/commands/generic-transformers.ts b/packages/client/lib/commands/generic-transformers.ts index ee72bb0004..25b602c844 100644 --- a/packages/client/lib/commands/generic-transformers.ts +++ b/packages/client/lib/commands/generic-transformers.ts @@ -1,13 +1,5 @@ import { ArrayReply, BlobStringReply, CommandArguments, DoubleReply, NullReply, RedisArgument, Resp2Reply } from '../RESP/types'; -// export function transformBooleanReply(reply: number): boolean { -// return reply === 1; -// } - -// export function transformBooleanArrayReply(reply: Array): Array { -// return reply.map(transformBooleanReply); -// } - export type BitValue = 0 | 1; export function transformDoubleReply(reply: BlobStringReply): number { diff --git a/packages/client/lib/commands/index.ts b/packages/client/lib/commands/index.ts index 4e41be07c1..299b805905 100644 --- a/packages/client/lib/commands/index.ts +++ b/packages/client/lib/commands/index.ts @@ -41,6 +41,7 @@ import CLUSTER_MEET from './CLUSTER_MEET'; import CLUSTER_MYID from './CLUSTER_MYID'; import CLUSTER_REPLICATE from './CLUSTER_REPLICATE'; import COPY from './COPY'; +import DBSIZE from './DBSIZE'; import DECR from './DECR'; import DECRBY from './DECRBY'; import DEL from './DEL'; @@ -79,6 +80,17 @@ import EXPIREAT from './EXPIREAT'; import EXPIRETIME from './EXPIRETIME'; import FLUSHALL from './FLUSHALL'; import FLUSHDB from './FLUSHDB'; +import FCALL from './FCALL'; +import FCALL_RO from './FCALL_RO'; +import FUNCTION_DELETE from './FUNCTION_DELETE'; +import FUNCTION_DUMP from './FUNCTION_DUMP'; +import FUNCTION_FLUSH from './FUNCTION_FLUSH'; +import FUNCTION_KILL from './FUNCTION_KILL'; +import FUNCTION_LIST_WITHCODE from './FUNCTION_LIST_WITHCODE'; +import FUNCTION_LIST from './FUNCTION_LIST'; +import FUNCTION_LOAD from './FUNCTION_LOAD'; +// import FUNCTION_RESTORE from './FUNCTION_RESTORE'; +// import FUNCTION_STATS from './FUNCTION_STATS'; import HDEL from './HDEL'; import HELLO from './HELLO'; import HEXISTS from './HEXISTS'; @@ -246,6 +258,786 @@ import ZUNION from './ZUNION'; import ZUNIONSTORE from './ZUNIONSTORE'; import { Command } from '../RESP/types'; +type ACL_CAT = typeof import('./ACL_CAT').default; +type ACL_DRYRUN = typeof import('./ACL_DRYRUN').default; +type ACL_GENPASS = typeof import('./ACL_GENPASS').default; +type ACL_GETUSER = typeof import('./ACL_GETUSER').default; +type ACL_LIST = typeof import('./ACL_LIST').default; +type ACL_LOAD = typeof import('./ACL_LOAD').default; +type ACL_LOG_RESET = typeof import('./ACL_LOG_RESET').default; +type ACL_LOG = typeof import('./ACL_LOG').default; +type ACL_SAVE = typeof import('./ACL_SAVE').default; +type ACL_SETUSER = typeof import('./ACL_SETUSER').default; +type ACL_USERS = typeof import('./ACL_USERS').default; +type ACL_WHOAMI = typeof import('./ACL_WHOAMI').default; +type APPEND = typeof import('./APPEND').default; +type ASKING = typeof import('./ASKING').default; +type AUTH = typeof import('./AUTH').default; +type BGREWRITEAOF = typeof import('./BGREWRITEAOF').default; +type BGSAVE = typeof import('./BGSAVE').default; +type BITCOUNT = typeof import('./BITCOUNT').default; +type BITFIELD_RO = typeof import('./BITFIELD_RO').default; +type BITFIELD = typeof import('./BITFIELD').default; +type BITOP = typeof import('./BITOP').default; +type BITPOS = typeof import('./BITPOS').default; +type BLMOVE = typeof import('./BLMOVE').default; +type BLMPOP = typeof import('./BLMPOP').default; +type BLPOP = typeof import('./BLPOP').default; +type BRPOP = typeof import('./BRPOP').default; +type BRPOPLPUSH = typeof import('./BRPOPLPUSH').default; +type CLIENT_CACHING = typeof import('./CLIENT_CACHING').default; +type CLIENT_GETNAME = typeof import('./CLIENT_GETNAME').default; +type CLIENT_GETREDIR = typeof import('./CLIENT_GETREDIR').default; +type CLIENT_ID = typeof import('./CLIENT_ID').default; +type CLIENT_INFO = typeof import('./CLIENT_INFO').default; +type CLIENT_KILL = typeof import('./CLIENT_KILL').default; +type CLIENT_LIST = typeof import('./CLIENT_LIST').default; +type CLIENT_NO_EVICT = typeof import('./CLIENT_NO-EVICT').default; +type CLIENT_PAUSE = typeof import('./CLIENT_PAUSE').default; +type CLIENT_SETNAME = typeof import('./CLIENT_SETNAME').default; +type CLUSTER_ADDSLOTS = typeof import('./CLUSTER_ADDSLOTS').default; +type CLUSTER_SLOTS = typeof import('./CLUSTER_SLOTS').default; +type CLUSTER_MEET = typeof import('./CLUSTER_MEET').default; +type CLUSTER_MYID = typeof import('./CLUSTER_MYID').default; +type CLUSTER_REPLICATE = typeof import('./CLUSTER_REPLICATE').default; +type COPY = typeof import('./COPY').default; +type DBSIZE = typeof DBSIZE; +type DECR = typeof import('./DECR').default; +type DECRBY = typeof import('./DECRBY').default; +type DEL = typeof import('./DEL').default; +type DUMP = typeof import('./DUMP').default; +type ECHO = typeof import('./ECHO').default; +type EVAL_RO = typeof import('./EVAL_RO').default; +type EVAL = typeof import('./EVAL').default; +type EVALSHA_RO = typeof import('./EVALSHA_RO').default; +type EVALSHA = typeof import('./EVALSHA').default; +type GEOADD = typeof import('./GEOADD').default; +type GEODIST = typeof import('./GEODIST').default; +type GEOHASH = typeof import('./GEOHASH').default; +type GEOPOS = typeof import('./GEOPOS').default; +type GEORADIUS_RO_WITH = typeof import('./GEORADIUS_RO_WITH').default; +type GEORADIUS_RO = typeof import('./GEORADIUS_RO').default; +type GEORADIUS_STORE = typeof import('./GEORADIUS_STORE').default; +type GEORADIUS_WITH = typeof import('./GEORADIUS_WITH').default; +type GEORADIUS = typeof import('./GEORADIUS').default; +type GEORADIUSBYMEMBER_RO_WITH = typeof import('./GEORADIUSBYMEMBER_RO_WITH').default; +type GEORADIUSBYMEMBER_RO = typeof import('./GEORADIUSBYMEMBER_RO').default; +type GEORADIUSBYMEMBER_STORE = typeof import('./GEORADIUSBYMEMBER_STORE').default; +type GEORADIUSBYMEMBER_WITH = typeof import('./GEORADIUSBYMEMBER_WITH').default; +type GEORADIUSBYMEMBER = typeof import('./GEORADIUSBYMEMBER').default; +type GEOSEARCH_WITH = typeof import('./GEOSEARCH_WITH').default; +type GEOSEARCH = typeof import('./GEOSEARCH').default; +type GEOSEARCHSTORE = typeof import('./GEOSEARCHSTORE').default; +type GET = typeof import('./GET').default; +type GETBIT = typeof import('./GETBIT').default; +type GETDEL = typeof import('./GETDEL').default; +type GETEX = typeof import('./GETEX').default; +type GETRANGE = typeof import('./GETRANGE').default; +type GETSET = typeof import('./GETSET').default; +type EXISTS = typeof import('./EXISTS').default; +type EXPIRE = typeof import('./EXPIRE').default; +type EXPIREAT = typeof import('./EXPIREAT').default; +type EXPIRETIME = typeof import('./EXPIRETIME').default; +type FLUSHALL = typeof import('./FLUSHALL').default; +type FLUSHDB = typeof import('./FLUSHDB').default; +type FCALL = typeof import('./FCALL').default; +type FCALL_RO = typeof import('./FCALL_RO').default; +type FUNCTION_DELETE = typeof import('./FUNCTION_DELETE').default; +type FUNCTION_DUMP = typeof import('./FUNCTION_DUMP').default; +type FUNCTION_FLUSH = typeof import('./FUNCTION_FLUSH').default; +type FUNCTION_KILL = typeof import('./FUNCTION_KILL').default; +type FUNCTION_LIST_WITHCODE = typeof import('./FUNCTION_LIST_WITHCODE').default; +type FUNCTION_LIST = typeof import('./FUNCTION_LIST').default; +type FUNCTION_LOAD = typeof import('./FUNCTION_LOAD').default; +// type FUNCTION_RESTORE = typeof import('./FUNCTION_RESTORE').default; +// type FUNCTION_STATS = typeof import('./FUNCTION_STATS').default; +type HDEL = typeof import('./HDEL').default; +type HELLO = typeof import('./HELLO').default; +type HEXISTS = typeof import('./HEXISTS').default; +type HGET = typeof import('./HGET').default; +type HGETALL = typeof import('./HGETALL').default; +type HINCRBY = typeof import('./HINCRBY').default; +type HINCRBYFLOAT = typeof import('./HINCRBYFLOAT').default; +type HKEYS = typeof import('./HKEYS').default; +type HLEN = typeof import('./HLEN').default; +type HMGET = typeof import('./HMGET').default; +type HRANDFIELD_COUNT_WITHVALUES = typeof import('./HRANDFIELD_COUNT_WITHVALUES').default; +type HRANDFIELD_COUNT = typeof import('./HRANDFIELD_COUNT').default; +type HRANDFIELD = typeof import('./HRANDFIELD').default; +type HSCAN = typeof import('./HSCAN').default; +type HSET = typeof import('./HSET').default; +type HSETNX = typeof import('./HSETNX').default; +type HSTRLEN = typeof import('./HSTRLEN').default; +type HVALS = typeof import('./HVALS').default; +type INCR = typeof import('./INCR').default; +type INCRBY = typeof import('./INCRBY').default; +type INCRBYFLOAT = typeof import('./INCRBYFLOAT').default; +type INFO = typeof import('./INFO').default; +type KEYS = typeof import('./KEYS').default; +type LASTSAVE = typeof import('./LASTSAVE').default; +type LCS_IDX_WITHMATCHLEN = typeof import('./LCS_IDX_WITHMATCHLEN').default; +type LCS_IDX = typeof import('./LCS_IDX').default; +type LCS_LEN = typeof import('./LCS_LEN').default; +type LCS = typeof import('./LCS').default; +type LINDEX = typeof import('./LINDEX').default; +type LINSERT = typeof import('./LINSERT').default; +type LLEN = typeof import('./LLEN').default; +type LMOVE = typeof import('./LMOVE').default; +type LMPOP = typeof import('./LMPOP').default; +type LOLWUT = typeof import('./LOLWUT').default; +type LPOP_COUNT = typeof import('./LPOP_COUNT').default; +type LPOP = typeof import('./LPOP').default; +type LPOS_COUNT = typeof import('./LPOS_COUNT').default; +type LPOS = typeof import('./LPOS').default; +type LPUSH = typeof import('./LPUSH').default; +type LPUSHX = typeof import('./LPUSHX').default; +type LRANGE = typeof import('./LRANGE').default; +type LREM = typeof import('./LREM').default; +type LSET = typeof import('./LSET').default; +type LTRIM = typeof import('./LTRIM').default; +type MEMORY_DOCTOR = typeof import('./MEMORY_DOCTOR').default; +type MEMORY_MALLOC_STATS = typeof import('./MEMORY_MALLOC-STATS').default; +type MEMORY_PURGE = typeof import('./MEMORY_PURGE').default; +// type MEMORY_STATS = typeof import('./MEMORY_STATS').default; +type MEMORY_USAGE = typeof import('./MEMORY_USAGE').default; +type MGET = typeof import('./MGET').default; +type MODULE_LIST = typeof import('./MODULE_LIST').default; +type MODULE_LOAD = typeof import('./MODULE_LOAD').default; +type MODULE_UNLOAD = typeof import('./MODULE_UNLOAD').default; +type MOVE = typeof import('./MOVE').default; +type MSET = typeof import('./MSET').default; +type MSETNX = typeof import('./MSETNX').default; +type OBJECT_ENCODING = typeof import('./OBJECT_ENCODING').default; +type OBJECT_FREQ = typeof import('./OBJECT_FREQ').default; +type OBJECT_IDLETIME = typeof import('./OBJECT_IDLETIME').default; +type OBJECT_REFCOUNT = typeof import('./OBJECT_REFCOUNT').default; +type PERSIST = typeof import('./PERSIST').default; +type PEXPIRE = typeof import('./PEXPIRE').default; +type PEXPIREAT = typeof import('./PEXPIREAT').default; +type PEXPIRETIME = typeof import('./PEXPIRETIME').default; +type PFADD = typeof import('./PFADD').default; +type PFCOUNT = typeof import('./PFCOUNT').default; +type PFMERGE = typeof import('./PFMERGE').default; +type PING = typeof import('./PING').default; +type PSETEX = typeof import('./PSETEX').default; +type PTTL = typeof import('./PTTL').default; +type PUBLISH = typeof import('./PUBLISH').default; +type PUBSUB_CHANNELS = typeof import('./PUBSUB_CHANNELS').default; +type PUBSUB_NUMPAT = typeof import('./PUBSUB_NUMPAT').default; +type PUBSUB_NUMSUB = typeof import('./PUBSUB_NUMSUB').default; +type PUBSUB_SHARDCHANNELS = typeof import('./PUBSUB_SHARDCHANNELS').default; +type RANDOMKEY = typeof import('./RANDOMKEY').default; +type READONLY = typeof import('./READONLY').default; +type RENAME = typeof import('./RENAME').default; +type RENAMENX = typeof import('./RENAMENX').default; +type RPOP_COUNT = typeof import('./RPOP_COUNT').default; +type RPOP = typeof import('./RPOP').default; +type RPOPLPUSH = typeof import('./RPOPLPUSH').default; +type RPUSH = typeof import('./RPUSH').default; +type RPUSHX = typeof import('./RPUSHX').default; +type SADD = typeof import('./SADD').default; +type SCAN = typeof import('./SCAN').default; +type SCARD = typeof import('./SCARD').default; +type SCRIPT_DEBUG = typeof import('./SCRIPT_DEBUG').default; +type SCRIPT_EXISTS = typeof import('./SCRIPT_EXISTS').default; +type SCRIPT_FLUSH = typeof import('./SCRIPT_FLUSH').default; +type SCRIPT_KILL = typeof import('./SCRIPT_KILL').default; +type SCRIPT_LOAD = typeof import('./SCRIPT_LOAD').default; +type SDIFF = typeof import('./SDIFF').default; +type SDIFFSTORE = typeof import('./SDIFFSTORE').default; +type SET = typeof import('./SET').default; +type SETBIT = typeof import('./SETBIT').default; +type SETEX = typeof import('./SETEX').default; +type SETNX = typeof import('./SETNX').default; +type SETRANGE = typeof import('./SETRANGE').default; +type SINTER = typeof import('./SINTER').default; +type SINTERCARD = typeof import('./SINTERCARD').default; +type SINTERSTORE = typeof import('./SINTERSTORE').default; +type SISMEMBER = typeof import('./SISMEMBER').default; +type SMEMBERS = typeof import('./SMEMBERS').default; +type SMISMEMBER = typeof import('./SMISMEMBER').default; +type SMOVE = typeof import('./SMOVE').default; +type SORT_RO = typeof import('./SORT_RO').default; +type SORT_STORE = typeof import('./SORT_STORE').default; +type SORT = typeof import('./SORT').default; +type SPOP_COUNT = typeof import('./SPOP_COUNT').default; +type SPOP = typeof import('./SPOP').default; +type SPUBLISH = typeof import('./SPUBLISH').default; +type SRANDMEMBER_COUNT = typeof import('./SRANDMEMBER_COUNT').default; +type SRANDMEMBER = typeof import('./SRANDMEMBER').default; +type SREM = typeof import('./SREM').default; +type SSCAN = typeof import('./SSCAN').default; +type STRLEN = typeof import('./STRLEN').default; +type SUNION = typeof import('./SUNION').default; +type SUNIONSTORE = typeof import('./SUNIONSTORE').default; +type TOUCH = typeof import('./TOUCH').default; +type TTL = typeof import('./TTL').default; +type TYPE = typeof import('./TYPE').default; +type UNLINK = typeof import('./UNLINK').default; +type UNWATCH = typeof import('./UNWATCH').default; +type WAIT = typeof import('./WAIT').default; +type WATCH = typeof import('./WATCH').default; +type XACK = typeof import('./XACK').default; +type XADD_NOMKSTREAM = typeof import('./XADD_NOMKSTREAM').default; +type XADD = typeof import('./XADD').default; +type XDEL = typeof import('./XDEL').default; +type XSETID = typeof import('./XSETID').default; +type XTRIM = typeof import('./XTRIM').default; +type XLEN = typeof import('./XLEN').default; +type ZADD_INCR = typeof import('./ZADD_INCR').default; +type ZADD = typeof import('./ZADD').default; +type ZCARD = typeof import('./ZCARD').default; +type ZCOUNT = typeof import('./ZCOUNT').default; +type ZDIFF_WITHSCORES = typeof import('./ZDIFF_WITHSCORES').default; +type ZDIFF = typeof import('./ZDIFF').default; +type ZDIFFSTORE = typeof import('./ZDIFFSTORE').default; +type ZINCRBY = typeof import('./ZINCRBY').default; +type ZINTER_WITHSCORES = typeof import('./ZINTER_WITHSCORES').default; +type ZINTER = typeof import('./ZINTER').default; +type ZINTERCARD = typeof import('./ZINTERCARD').default; +type ZINTERSTORE = typeof import('./ZINTERSTORE').default; +type ZLEXCOUNT = typeof import('./ZLEXCOUNT').default; +type ZMSCORE = typeof import('./ZMSCORE').default; +type ZRANDMEMBER_COUNT_WITHSCORES = typeof import('./ZRANDMEMBER_COUNT_WITHSCORES').default; +type ZRANDMEMBER_COUNT = typeof import('./ZRANDMEMBER_COUNT').default; +type ZRANDMEMBER = typeof import('./ZRANDMEMBER').default; +type ZRANGE = typeof import('./ZRANGE').default; +type ZRANGEBYLEX = typeof import('./ZRANGEBYLEX').default; +type ZRANGEBYSCORE_WITHSCORES = typeof import('./ZRANGEBYSCORE_WITHSCORES').default; +type ZRANGEBYSCORE = typeof import('./ZRANGEBYSCORE').default; +type ZREMRANGEBYSCORE = typeof import('./ZREMRANGEBYSCORE').default; +type ZRANK = typeof import('./ZRANK').default; +type ZREM = typeof import('./ZREM').default; +type ZREMRANGEBYLEX = typeof import('./ZREMRANGEBYLEX').default; +type ZREMRANGEBYRANK = typeof import('./ZREMRANGEBYRANK').default; +type ZREVRANK = typeof import('./ZREVRANK').default; +type ZSCAN = typeof import('./ZSCAN').default; +type ZSCORE = typeof import('./ZSCORE').default; +type ZUNION_WITHSCORES = typeof import('./ZUNION_WITHSCORES').default; +type ZUNION = typeof import('./ZUNION').default; +type ZUNIONSTORE = typeof import('./ZUNIONSTORE').default; + +type Commands = { + ACL_CAT: ACL_CAT; + aclCat: ACL_CAT; + ACL_DRYRUN: ACL_DRYRUN; + aclDryRun: ACL_DRYRUN; + ACL_GENPASS: ACL_GENPASS; + aclGenPass: ACL_GENPASS; + ACL_GETUSER: ACL_GETUSER; + aclGetUser: ACL_GETUSER; + ACL_LIST: ACL_LIST; + aclList: ACL_LIST; + ACL_LOAD: ACL_LOAD; + aclLoad: ACL_LOAD; + ACL_LOG_RESET: ACL_LOG_RESET; + aclLogReset: ACL_LOG_RESET; + ACL_LOG: ACL_LOG; + aclLog: ACL_LOG; + ACL_SAVE: ACL_SAVE; + aclSave: ACL_SAVE; + ACL_SETUSER: ACL_SETUSER; + aclSetUser: ACL_SETUSER; + ACL_USERS: ACL_USERS; + aclUsers: ACL_USERS; + ACL_WHOAMI: ACL_WHOAMI; + aclWhoAmI: ACL_WHOAMI; + APPEND: APPEND; + append: APPEND; + ASKING: ASKING; + asking: ASKING; + AUTH: AUTH; + auth: AUTH; + BGREWRITEAOF: BGREWRITEAOF; + bgRewriteAof: BGREWRITEAOF; + BGSAVE: BGSAVE; + bgSave: BGSAVE; + BITCOUNT: BITCOUNT; + bitCount: BITCOUNT; + BITFIELD_RO: BITFIELD_RO; + bitFieldRo: BITFIELD_RO; + BITFIELD: BITFIELD; + bitField: BITFIELD; + BITOP: BITOP; + bitOp: BITOP; + BITPOS: BITPOS; + bitPos: BITPOS; + BLMOVE: BLMOVE; + blMove: BLMOVE; + BLMPOP: BLMPOP; + blmPop: BLMPOP; + BLPOP: BLPOP; + blPop: BLPOP; + BRPOP: BRPOP; + brPop: BRPOP; + BRPOPLPUSH: BRPOPLPUSH; + brPopLPush: BRPOPLPUSH; + CLIENT_CACHING: CLIENT_CACHING; + clientCaching: CLIENT_CACHING; + CLIENT_GETNAME: CLIENT_GETNAME; + clientGetName: CLIENT_GETNAME; + CLIENT_GETREDIR: CLIENT_GETREDIR; + clientGetRedir: CLIENT_GETREDIR; + CLIENT_ID: CLIENT_ID; + clientId: CLIENT_ID; + CLIENT_INFO: CLIENT_INFO; + clientInfo: CLIENT_INFO; + CLIENT_KILL: CLIENT_KILL; + clientKill: CLIENT_KILL; + CLIENT_LIST: CLIENT_LIST; + clientList: CLIENT_LIST; + 'CLIENT_NO-EVICT': CLIENT_NO_EVICT; + clientNoEvict: CLIENT_NO_EVICT; + CLIENT_PAUSE: CLIENT_PAUSE; + clientPause: CLIENT_PAUSE; + CLIENT_SETNAME: CLIENT_SETNAME; + clientSetName: CLIENT_SETNAME; + CLUSTER_ADDSLOTS: CLUSTER_ADDSLOTS; + clusterAddSlots: CLUSTER_ADDSLOTS; + CLUSTER_SLOTS: CLUSTER_SLOTS; + clusterSlots: CLUSTER_SLOTS; + CLUSTER_MEET: CLUSTER_MEET; + clusterMeet: CLUSTER_MEET; + CLUSTER_MYID: CLUSTER_MYID; + clusterMyId: CLUSTER_MYID; + CLUSTER_REPLICATE: CLUSTER_REPLICATE; + clusterReplicate: CLUSTER_REPLICATE; + COPY: COPY; + copy: COPY; + DBSIZE: DBSIZE; + dbSize: DBSIZE; + DECR: DECR; + decr: DECR; + DECRBY: DECRBY; + decrBy: DECRBY; + DEL: DEL; + del: DEL; + DUMP: DUMP; + dump: DUMP; + ECHO: ECHO; + echo: ECHO; + EVAL_RO: EVAL_RO; + evalRo: EVAL_RO; + EVAL: EVAL; + eval: EVAL; + EVALSHA_RO: EVALSHA_RO; + evalShaRo: EVALSHA_RO; + EVALSHA: EVALSHA; + evalSha: EVALSHA; + EXISTS: EXISTS; + exists: EXISTS; + EXPIRE: EXPIRE; + expire: EXPIRE; + EXPIREAT: EXPIREAT; + expireAt: EXPIREAT; + EXPIRETIME: EXPIRETIME; + expireTime: EXPIRETIME; + FLUSHALL: FLUSHALL; + flushAll: FLUSHALL; + FLUSHDB: FLUSHDB; + flushDb: FLUSHDB; + FCALL: FCALL; + fCall: FCALL; + FCALL_RO: FCALL_RO; + fCallRo: FCALL_RO; + FUNCTION_DELETE: FUNCTION_DELETE; + functionDelete: FUNCTION_DELETE; + FUNCTION_DUMP: FUNCTION_DUMP; + functionDump: FUNCTION_DUMP; + FUNCTION_FLUSH: FUNCTION_FLUSH; + functionFlush: FUNCTION_FLUSH; + FUNCTION_KILL: FUNCTION_KILL; + functionKill: FUNCTION_KILL; + FUNCTION_LIST_WITHCODE: FUNCTION_LIST_WITHCODE; + functionListWithCode: FUNCTION_LIST_WITHCODE; + FUNCTION_LIST: FUNCTION_LIST; + functionList: FUNCTION_LIST; + FUNCTION_LOAD: FUNCTION_LOAD; + functionLoad: FUNCTION_LOAD; + // FUNCTION_RESTORE: FUNCTION_RESTORE; + // functionRestore: FUNCTION_RESTORE; + // FUNCTION_STATS: FUNCTION_STATS; + // functionStats: FUNCTION_STATS; + GEOADD: GEOADD; + geoAdd: GEOADD; + GEODIST: GEODIST; + geoDist: GEODIST; + GEOHASH: GEOHASH; + geoHash: GEOHASH; + GEOPOS: GEOPOS; + geoPos: GEOPOS; + GEORADIUS_RO_WITH: GEORADIUS_RO_WITH; + geoRadiusRoWith: GEORADIUS_RO_WITH; + GEORADIUS_RO: GEORADIUS_RO; + geoRadiusRo: GEORADIUS_RO + GEORADIUS_STORE: GEORADIUS_STORE; + geoRadiusStore: GEORADIUS_STORE; + GEORADIUS_WITH: GEORADIUS_WITH; + geoRadiusWith: GEORADIUS_WITH; + GEORADIUS: GEORADIUS; + geoRadius: GEORADIUS; + GEORADIUSBYMEMBER_RO_WITH: GEORADIUSBYMEMBER_RO_WITH; + geoRadiusByMemberRoWith: GEORADIUSBYMEMBER_RO_WITH; + GEORADIUSBYMEMBER_RO: GEORADIUSBYMEMBER_RO; + geoRadiusByMemberRo: GEORADIUSBYMEMBER_RO; + GEORADIUSBYMEMBER_STORE: GEORADIUSBYMEMBER_STORE; + geoRadiusByMemberStore: GEORADIUSBYMEMBER_STORE; + GEORADIUSBYMEMBER_WITH: GEORADIUSBYMEMBER_WITH; + geoRadiusByMemberWith: GEORADIUSBYMEMBER_WITH; + GEORADIUSBYMEMBER: GEORADIUSBYMEMBER; + geoRadiusByMember: GEORADIUSBYMEMBER; + GEOSEARCH_WITH: GEOSEARCH_WITH; + geoSearchWith: GEOSEARCH_WITH; + GEOSEARCH: GEOSEARCH; + geoSearch: GEOSEARCH; + GEOSEARCHSTORE: GEOSEARCHSTORE; + geoSearchStore: GEOSEARCHSTORE; + GET: GET; + get: GET; + GETBIT: GETBIT; + getBit: GETBIT; + GETDEL: GETDEL; + getDel: GETDEL; + GETEX: GETEX; + getEx: GETEX; + GETRANGE: GETRANGE; + getRange: GETRANGE; + GETSET: GETSET; + getSet: GETSET; + HDEL: HDEL; + hDel: HDEL; + HELLO: HELLO; + hello: HELLO; + HEXISTS: HEXISTS; + hExists: HEXISTS; + HGET: HGET; + hGet: HGET; + HGETALL: HGETALL; + hGetAll: HGETALL; + HINCRBY: HINCRBY; + hIncrBy: HINCRBY; + HINCRBYFLOAT: HINCRBYFLOAT; + hIncrByFloat: HINCRBYFLOAT; + HKEYS: HKEYS; + hKeys: HKEYS; + HLEN: HLEN; + hLen: HLEN; + HMGET: HMGET; + hmGet: HMGET; + HRANDFIELD_COUNT_WITHVALUES: HRANDFIELD_COUNT_WITHVALUES; + hRandFieldCountWithValues: HRANDFIELD_COUNT_WITHVALUES; + HRANDFIELD_COUNT: HRANDFIELD_COUNT; + hRandFieldCount: HRANDFIELD_COUNT; + HRANDFIELD: HRANDFIELD; + hRandField: HRANDFIELD; + HSCAN: HSCAN; + hScan: HSCAN; + HSET: HSET; + hSet: HSET; + HSETNX: HSETNX; + hSetNX: HSETNX; + HSTRLEN: HSTRLEN; + hStrLen: HSTRLEN; + HVALS: HVALS; + hVals: HVALS; + INCR: INCR; + incr: INCR; + INCRBY: INCRBY; + incrBy: INCRBY; + INCRBYFLOAT: INCRBYFLOAT; + incrByFloat: INCRBYFLOAT; + INFO: INFO; + info: INFO; + KEYS: KEYS; + keys: KEYS; + LASTSAVE: LASTSAVE; + lastSave: LASTSAVE; + LCS_IDX_WITHMATCHLEN: LCS_IDX_WITHMATCHLEN; + lcsIdxWithMatchLen: LCS_IDX_WITHMATCHLEN; + LCS_IDX: LCS_IDX; + lcsIdx: LCS_IDX; + LCS_LEN: LCS_LEN; + lcsLen: LCS_LEN; + LCS: LCS; + lcs: LCS; + LINDEX: LINDEX; + lIndex: LINDEX; + LINSERT: LINSERT; + lInsert: LINSERT; + LLEN: LLEN; + lLen: LLEN; + LMOVE: LMOVE; + lMove: LMOVE; + LMPOP: LMPOP; + lmPop: LMPOP; + LOLWUT: LOLWUT; + LPOP_COUNT: LPOP_COUNT; + lPopCount: LPOP_COUNT; + LPOP: LPOP; + lPop: LPOP; + LPOS_COUNT: LPOS_COUNT; + lPosCount: LPOS_COUNT; + LPOS: LPOS; + lPos: LPOS; + LPUSH: LPUSH; + lPush: LPUSH; + LPUSHX: LPUSHX; + lPushX: LPUSHX; + LRANGE: LRANGE; + lRange: LRANGE; + LREM: LREM; + lRem: LREM; + LSET: LSET; + lSet: LSET; + LTRIM: LTRIM; + lTrim: LTRIM; + MEMORY_DOCTOR: MEMORY_DOCTOR; + memoryDoctor: MEMORY_DOCTOR; + 'MEMORY_MALLOC-STATS': MEMORY_MALLOC_STATS; + memoryMallocStats: MEMORY_MALLOC_STATS; + MEMORY_PURGE: MEMORY_PURGE; + memoryPurge: MEMORY_PURGE; + // MEMORY_STATS: MEMORY_STATS; + // memoryStats: MEMORY_STATS; + MEMORY_USAGE: MEMORY_USAGE; + memoryUsage: MEMORY_USAGE; + MGET: MGET; + mGet: MGET; + MODULE_LIST: MODULE_LIST; + moduleList: MODULE_LIST; + MODULE_LOAD: MODULE_LOAD; + moduleLoad: MODULE_LOAD; + MODULE_UNLOAD: MODULE_UNLOAD; + moduleUnload: MODULE_UNLOAD; + MOVE: MOVE; + move: MOVE; + MSET: MSET; + mSet: MSET; + MSETNX: MSETNX; + mSetNX: MSETNX; + OBJECT_ENCODING: OBJECT_ENCODING; + objectEncoding: OBJECT_ENCODING; + OBJECT_FREQ: OBJECT_FREQ; + objectFreq: OBJECT_FREQ; + OBJECT_IDLETIME: OBJECT_IDLETIME; + objectIdleTime: OBJECT_IDLETIME; + OBJECT_REFCOUNT: OBJECT_REFCOUNT + objectRefCount: OBJECT_REFCOUNT; + PERSIST: PERSIST; + persist: PERSIST; + PEXPIRE: PEXPIRE; + pExpire: PEXPIRE; + PEXPIREAT: PEXPIREAT; + pExpireAt: PEXPIREAT; + PEXPIRETIME: PEXPIRETIME; + pExpireTime: PEXPIRETIME; + PFADD: PFADD; + pfAdd: PFADD; + PFCOUNT: PFCOUNT; + pfCount: PFCOUNT; + PFMERGE: PFMERGE; + pfMerge: PFMERGE; + PING: PING; + /** + * ping jsdoc + */ + ping: PING; + PSETEX: PSETEX; + pSetEx: PSETEX; + PTTL: PTTL; + pTTL: PTTL; + PUBLISH: PUBLISH; + publish: PUBLISH; + PUBSUB_CHANNELS: PUBSUB_CHANNELS; + pubSubChannels: PUBSUB_CHANNELS; + PUBSUB_NUMPAT: PUBSUB_NUMPAT; + pubSubNumPat: PUBSUB_NUMPAT; + PUBSUB_NUMSUB: PUBSUB_NUMSUB; + pubSubNumSub: PUBSUB_NUMSUB; + PUBSUB_SHARDCHANNELS: PUBSUB_SHARDCHANNELS; + pubSubShardChannels: PUBSUB_SHARDCHANNELS; + RANDOMKEY: RANDOMKEY; + randomKey: RANDOMKEY; + READONLY: READONLY; + readonly: READONLY; + RENAME: RENAME; + rename: RENAME; + RENAMENX: RENAMENX; + renameNX: RENAMENX; + RPOP_COUNT: RPOP_COUNT; + rPopCount: RPOP_COUNT; + RPOP: RPOP; + rPop: RPOP; + RPOPLPUSH: RPOPLPUSH; + rPopLPush: RPOPLPUSH; + RPUSH: RPUSH; + rPush: RPUSH; + RPUSHX: RPUSHX; + rPushX: RPUSHX; + SADD: SADD; + sAdd: SADD; + SCAN: SCAN; + scan: SCAN; + SCARD: SCARD; + sCard: SCARD; + SCRIPT_DEBUG: SCRIPT_DEBUG; + scriptDebug: SCRIPT_DEBUG; + SCRIPT_EXISTS: SCRIPT_EXISTS; + scriptExists: SCRIPT_EXISTS; + SCRIPT_FLUSH: SCRIPT_FLUSH; + scriptFlush: SCRIPT_FLUSH; + SCRIPT_KILL: SCRIPT_KILL; + scriptKill: SCRIPT_KILL; + SCRIPT_LOAD: SCRIPT_LOAD; + scriptLoad: SCRIPT_LOAD; + SDIFF: SDIFF; + sDiff: SDIFF; + SDIFFSTORE: SDIFFSTORE; + sDiffStore: SDIFFSTORE; + SET: SET; + set: SET; + SETBIT: SETBIT; + setBit: SETBIT; + SETEX: SETEX; + setEx: SETEX; + SETNX: SETNX; + setNX: SETNX; + SETRANGE: SETRANGE; + setRange: SETRANGE; + SINTER: SINTER; + sInter: SINTER; + SINTERCARD: SINTERCARD; + sInterCard: SINTERCARD; + SINTERSTORE: SINTERSTORE; + sInterStore: SINTERSTORE; + SISMEMBER: SISMEMBER; + sIsMember: SISMEMBER; + SMEMBERS: SMEMBERS; + sMembers: SMEMBERS; + SMISMEMBER: SMISMEMBER; + smIsMember: SMISMEMBER; + SMOVE: SMOVE; + sMove: SMOVE; + SORT_RO: SORT_RO; + sortRo: SORT_RO; + SORT_STORE: SORT_STORE; + sortStore: SORT_STORE; + SORT: SORT; + sort: SORT; + SPOP_COUNT: SPOP_COUNT; + sPopCount: SPOP_COUNT; + SPOP: SPOP; + sPop: SPOP; + SPUBLISH: SPUBLISH; + sPublish: SPUBLISH; + SRANDMEMBER_COUNT: SRANDMEMBER_COUNT; + sRandMemberCount: SRANDMEMBER_COUNT; + SRANDMEMBER: SRANDMEMBER; + sRandMember: SRANDMEMBER; + SREM: SREM; + sRem: SREM; + SSCAN: SSCAN; + sScan: SSCAN; + STRLEN: STRLEN; + strLen: STRLEN; + SUNION: SUNION; + sUnion: SUNION; + SUNIONSTORE: SUNIONSTORE; + sUnionStore: SUNIONSTORE; + TOUCH: TOUCH; + touch: TOUCH; + TTL: TTL; + ttl: TTL; + TYPE: TYPE; + type: TYPE; + UNLINK: UNLINK; + unlink: UNLINK; + UNWATCH: UNWATCH; + unwatch: UNWATCH; + WAIT: WAIT; + wait: WAIT; + WATCH: WATCH; + watch: WATCH; + XACK: XACK; + xAck: XACK; + XADD_NOMKSTREAM: XADD_NOMKSTREAM; + xAddNoMkStream: XADD_NOMKSTREAM; + XADD: XADD; + xAdd: XADD; + XDEL: XDEL; + xDel: XDEL; + XSETID: XSETID; + xSetId: XSETID; + XTRIM: XTRIM; + xTrim: XTRIM; + XLEN: XLEN; + xLen: XLEN; + ZADD_INCR: ZADD_INCR; + zAddIncr: ZADD_INCR; + ZADD: ZADD; + zAdd: ZADD; + ZCARD: ZCARD; + zCard: ZCARD; + ZCOUNT: ZCOUNT; + zCount: ZCOUNT; + ZDIFF_WITHSCORES: ZDIFF_WITHSCORES; + zDiffWithScores: ZDIFF_WITHSCORES; + ZDIFF: ZDIFF; + zDiff: ZDIFF; + ZDIFFSTORE: ZDIFFSTORE; + zDiffStore: ZDIFFSTORE; + ZINCRBY: ZINCRBY; + zIncrBy: ZINCRBY; + ZINTER_WITHSCORES: ZINTER_WITHSCORES; + zInterWithScores: ZINTER_WITHSCORES; + ZINTER: ZINTER; + zInter: ZINTER; + ZINTERCARD: ZINTERCARD; + zInterCard: ZINTERCARD; + ZINTERSTORE: ZINTERSTORE; + zInterStore: ZINTERSTORE; + ZLEXCOUNT: ZLEXCOUNT; + zLexCount: ZLEXCOUNT; + ZMSCORE: ZMSCORE; + zmScore: ZMSCORE; + ZRANDMEMBER_COUNT_WITHSCORES: ZRANDMEMBER_COUNT_WITHSCORES; + zRandMemberCountWithScores: ZRANDMEMBER_COUNT_WITHSCORES; + ZRANDMEMBER_COUNT: ZRANDMEMBER_COUNT; + zRandMemberCount: ZRANDMEMBER_COUNT; + ZRANDMEMBER: ZRANDMEMBER; + zRandMember: ZRANDMEMBER; + ZRANGE: ZRANGE; + zRange: ZRANGE; + ZRANGEBYLEX: ZRANGEBYLEX; + zRangeByLex: ZRANGEBYLEX; + ZRANGEBYSCORE_WITHSCORES: ZRANGEBYSCORE_WITHSCORES; + zRangeByScoreWithScores: ZRANGEBYSCORE_WITHSCORES; + ZRANGEBYSCORE: ZRANGEBYSCORE; + zRangeByScore: ZRANGEBYSCORE; + ZRANK: ZRANK; + zRank: ZRANK; + ZREM: ZREM; + zRem: ZREM; + ZREMRANGEBYLEX: ZREMRANGEBYLEX; + zRemRangeByLex: ZREMRANGEBYLEX; + ZREMRANGEBYRANK: ZREMRANGEBYRANK; + zRemRangeByRank: ZREMRANGEBYRANK; + ZREMRANGEBYSCORE: ZREMRANGEBYSCORE; + zRemRangeByScore: ZREMRANGEBYSCORE; + ZREVRANK: ZREVRANK; + zRevRank: ZREVRANK; + ZSCAN: ZSCAN; + zScan: ZSCAN; + ZSCORE: ZSCORE; + zScore: ZSCORE; + ZUNION_WITHSCORES: ZUNION_WITHSCORES; + zUnionWithScores: ZUNION_WITHSCORES; + ZUNION: ZUNION; + zUnion: ZUNION; + ZUNIONSTORE: ZUNIONSTORE; + zUnionStore: ZUNIONSTORE; +}; + export default { ACL_CAT, aclCat: ACL_CAT, @@ -333,6 +1125,8 @@ export default { clusterReplicate: CLUSTER_REPLICATE, COPY, copy: COPY, + DBSIZE, + dbSize: DBSIZE, DECR, decr: DECR, DECRBY, @@ -363,6 +1157,28 @@ export default { flushAll: FLUSHALL, FLUSHDB, flushDb: FLUSHDB, + FCALL, + fCall: FCALL, + FCALL_RO, + fCallRo: FCALL_RO, + 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, GEOADD, geoAdd: GEOADD, GEODIST, @@ -740,5 +1556,5 @@ export default { ZUNION, zUnion: ZUNION, ZUNIONSTORE, - zUnionStore: ZUNIONSTORE, -} as const satisfies Record; + zUnionStore: ZUNIONSTORE +} as const satisfies Record as Commands; diff --git a/packages/test-utils/lib/dockers.ts b/packages/test-utils/lib/dockers.ts index a6abde4495..917bd2992e 100644 --- a/packages/test-utils/lib/dockers.ts +++ b/packages/test-utils/lib/dockers.ts @@ -1,6 +1,6 @@ import { createConnection } from 'net'; import { once } from 'events'; -import { createClient } from '@redis/client'; +import { createClient } from '@redis/client/index'; import { setTimeout } from 'timers/promises'; // import { ClusterSlotsReply } from '@redis/client/dist/lib/commands/CLUSTER_SLOTS'; import * as path from 'path'; diff --git a/packages/test-utils/lib/index.ts b/packages/test-utils/lib/index.ts index 009f94a43e..f424535297 100644 --- a/packages/test-utils/lib/index.ts +++ b/packages/test-utils/lib/index.ts @@ -9,7 +9,7 @@ import { createCluster, RedisClusterOptions, RedisClusterType -} from '@redis/client'; +} from '@redis/client/index'; import { RedisServerDockerConfig, spawnRedisServer, spawnRedisCluster } from './dockers'; import yargs from 'yargs'; import { hideBin } from 'yargs/helpers';