diff --git a/docs/v4-to-v5.md b/docs/v4-to-v5.md index 4841ab5569..83dde28c7c 100644 --- a/docs/v4-to-v5.md +++ b/docs/v4-to-v5.md @@ -134,7 +134,8 @@ await cluster.multi() - `CLIENT KILL`: `enum ClientKillFilters` -> `const CLIENT_KILL_FILTERS` [^enum-to-constants] - `CLUSTER FAILOVER`: `enum FailoverModes` -> `const FAILOVER_MODES` [^enum-to-constants] - `CLIENT TRACKINGINFO`: `flags` in RESP2 - `Set` -> `Array` (to match RESP3 default type mapping) -- `CLUSETER SETSLOT`: `ClusterSlotStates` -> `CLUSTER_SLOT_STATES` [^enum-to-constants] +- `CLUSTER INFO`: +- `CLUSTER SETSLOT`: `ClusterSlotStates` -> `CLUSTER_SLOT_STATES` [^enum-to-constants] - `CLUSTER RESET`: the second argument is `{ mode: string; }` instead of `string` [^future-proofing] - `CLUSTER FAILOVER`: `enum FailoverModes` -> `const FAILOVER_MODES` [^enum-to-constants], the second argument is `{ mode: string; }` instead of `string` [^future-proofing] - `CLUSTER LINKS`: `createTime` -> `create-time`, `sendBufferAllocated` -> `send-buffer-allocated`, `sendBufferUsed` -> `send-buffer-used` [^map-keys] @@ -145,7 +146,7 @@ await cluster.multi() - `HEXISTS`: `boolean` -> `number` [^boolean-to-number] - `HRANDFIELD_COUNT_WITHVALUES`: `Record` -> `Array<{ field: BlobString; value: BlobString; }>` (it can return duplicates). - `HSETNX`: `boolean` -> `number` [^boolean-to-number] - +- `INFO`: - `LCS IDX`: `length` has been changed to `len`, `matches` has been changed from `Array<{ key1: RangeReply; key2: RangeReply; }>` to `Array<[key1: RangeReply, key2: RangeReply]>` diff --git a/packages/bloom/lib/commands/bloom/INFO.spec.ts b/packages/bloom/lib/commands/bloom/INFO.spec.ts index 77b6a589ba..9a8cb8bdf1 100644 --- a/packages/bloom/lib/commands/bloom/INFO.spec.ts +++ b/packages/bloom/lib/commands/bloom/INFO.spec.ts @@ -1,24 +1,26 @@ -// import { strict as assert } from 'node:assert'; -// import testUtils, { GLOBAL } from '../../test-utils'; -// import { transformArguments } from './INFO'; +import { strict as assert } from 'node:assert'; +import testUtils, { GLOBAL } from '../../test-utils'; +import INFO from './INFO'; -// describe('BF INFO', () => { -// it('transformArguments', () => { -// assert.deepEqual( -// transformArguments('bloom'), -// ['BF.INFO', 'bloom'] -// ); -// }); +describe('BF.INFO', () => { + it('transformArguments', () => { + assert.deepEqual( + INFO.transformArguments('bloom'), + ['BF.INFO', 'bloom'] + ); + }); -// testUtils.testWithClient('client.bf.info', async client => { -// await client.bf.reserve('key', 0.01, 100); + testUtils.testWithClient('client.bf.info', async client => { + const [, reply] = await Promise.all([ + client.bf.reserve('key', 0.01, 100), + client.bf.info('key') + ]); -// const info = await client.bf.info('key'); -// assert.equal(typeof info, 'object'); -// assert.equal(info.capacity, 100); -// assert.equal(typeof info.size, 'number'); -// assert.equal(typeof info.numberOfFilters, 'number'); -// assert.equal(typeof info.numberOfInsertedItems, 'number'); -// assert.equal(typeof info.expansionRate, 'number'); -// }, GLOBAL.SERVERS.OPEN); -// }); + assert.equal(typeof reply, 'object'); + assert.equal(reply.capacity, 100); + assert.equal(typeof reply.size, 'number'); + assert.equal(typeof reply.numberOfFilters, 'number'); + assert.equal(typeof reply.numberOfInsertedItems, 'number'); + assert.equal(typeof reply.expansionRate, 'number'); + }, GLOBAL.SERVERS.OPEN); +}); diff --git a/packages/bloom/lib/commands/bloom/INFO.ts b/packages/bloom/lib/commands/bloom/INFO.ts index 7954053f0f..d5055b1c03 100644 --- a/packages/bloom/lib/commands/bloom/INFO.ts +++ b/packages/bloom/lib/commands/bloom/INFO.ts @@ -1,57 +1,11 @@ -// // export type InfoRawReply = [ -// // _: string, -// // capacity: number, -// // _: string, -// // size: number, -// // _: string, -// // numberOfFilters: number, -// // _: string, -// // numberOfInsertedItems: number, -// // _: string, -// // expansionRate: number, -// // ]; +import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types'; -// // export interface InfoReply { -// // capacity: number; -// // size: number; -// // numberOfFilters: number; -// // numberOfInsertedItems: number; -// // expansionRate: number; -// // } - -// // export function transformReply(reply: InfoRawReply): InfoReply { -// // return { -// // capacity: reply[1], -// // size: reply[3], -// // numberOfFilters: reply[5], -// // numberOfInsertedItems: reply[7], -// // expansionRate: reply[9] -// // }; -// // } - -// import { RedisArgument, Command, TuplesToMapReply, BlobStringReply, NumberReply } from '@redis/client/dist/lib/RESP/types'; -// import { transformBooleanArrayReply } from '@redis/client/dist/lib/commands/generic-transformers'; - -// export type BfInfoReply = TuplesToMapReply<[ -// [BlobStringReply<'Capacity'>, NumberReply], -// [BlobStringReply<'Size'>, NumberReply], -// [BlobStringReply<'Number of filters'>, NumberReply], - - -// ]>; - -// export default { -// FIRST_KEY_INDEX: 1, -// IS_READ_ONLY: true, -// transformArguments(key: RedisArgument) { -// return ['BF.INFO', key]; -// }, -// transformReply: { -// 2: () => { - -// }, -// 3: () => { - -// } -// } -// } as const satisfies Command; +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments(key: RedisArgument) { + return ['BF.INFO', key]; + }, + // TODO + transformReply: undefined as unknown as () => any +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/bloom/index.ts b/packages/bloom/lib/commands/bloom/index.ts index 7483467d86..e61f4709a4 100644 --- a/packages/bloom/lib/commands/bloom/index.ts +++ b/packages/bloom/lib/commands/bloom/index.ts @@ -2,7 +2,7 @@ import type { RedisCommands } from '@redis/client/dist/lib/RESP/types'; import ADD from './ADD'; import CARD from './CARD'; import EXISTS from './EXISTS'; -// import INFO from './INFO'; +import INFO from './INFO'; import INSERT from './INSERT'; import LOADCHUNK from './LOADCHUNK'; import MADD from './MADD'; @@ -17,8 +17,8 @@ export default { card: CARD, EXISTS, exists: EXISTS, - // INFO, - // info: INFO, + INFO, + info: INFO, INSERT, insert: INSERT, LOADCHUNK, diff --git a/packages/bloom/lib/commands/cuckoo/INFO.spec.ts b/packages/bloom/lib/commands/cuckoo/INFO.spec.ts index e92e32f125..e4276e941b 100644 --- a/packages/bloom/lib/commands/cuckoo/INFO.spec.ts +++ b/packages/bloom/lib/commands/cuckoo/INFO.spec.ts @@ -1,27 +1,29 @@ -// import { strict as assert } from 'node:assert'; -// import testUtils, { GLOBAL } from '../../test-utils'; -// import { transformArguments } from './INFO'; +import { strict as assert } from 'node:assert'; +import testUtils, { GLOBAL } from '../../test-utils'; +import INFO from './INFO'; -// describe('CF INFO', () => { -// it('transformArguments', () => { -// assert.deepEqual( -// transformArguments('cuckoo'), -// ['CF.INFO', 'cuckoo'] -// ); -// }); +describe('CF.INFO', () => { + it('transformArguments', () => { + assert.deepEqual( + INFO.transformArguments('cuckoo'), + ['CF.INFO', 'cuckoo'] + ); + }); -// testUtils.testWithClient('client.cf.info', async client => { -// await client.cf.reserve('key', 4); + testUtils.testWithClient('client.cf.info', async client => { + const [, reply] = await Promise.all([ + client.cf.reserve('key', 4), + client.cf.info('key') + ]); -// const info = await client.cf.info('key'); -// assert.equal(typeof info, 'object'); -// assert.equal(typeof info.size, 'number'); -// assert.equal(typeof info.numberOfBuckets, 'number'); -// assert.equal(typeof info.numberOfFilters, 'number'); -// assert.equal(typeof info.numberOfInsertedItems, 'number'); -// assert.equal(typeof info.numberOfDeletedItems, 'number'); -// assert.equal(typeof info.bucketSize, 'number'); -// assert.equal(typeof info.expansionRate, 'number'); -// assert.equal(typeof info.maxIteration, 'number'); -// }, GLOBAL.SERVERS.OPEN); -// }); + assert.equal(typeof reply, 'object'); + assert.equal(typeof reply.size, 'number'); + assert.equal(typeof reply.numberOfBuckets, 'number'); + assert.equal(typeof reply.numberOfFilters, 'number'); + assert.equal(typeof reply.numberOfInsertedItems, 'number'); + assert.equal(typeof reply.numberOfDeletedItems, 'number'); + assert.equal(typeof reply.bucketSize, 'number'); + assert.equal(typeof reply.expansionRate, 'number'); + assert.equal(typeof reply.maxIteration, 'number'); + }, GLOBAL.SERVERS.OPEN); +}); diff --git a/packages/bloom/lib/commands/cuckoo/INFO.ts b/packages/bloom/lib/commands/cuckoo/INFO.ts index be77430ae9..f7a789712d 100644 --- a/packages/bloom/lib/commands/cuckoo/INFO.ts +++ b/packages/bloom/lib/commands/cuckoo/INFO.ts @@ -1,50 +1,53 @@ -// export const FIRST_KEY_INDEX = 1; +import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types'; -// export const IS_READ_ONLY = true; +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments(key: RedisArgument) { + return ['CF.INFO', key]; + }, + // TODO + // export type InfoRawReply = [ + // _: string, + // size: number, + // _: string, + // numberOfBuckets: number, + // _: string, + // numberOfFilters: number, + // _: string, + // numberOfInsertedItems: number, + // _: string, + // numberOfDeletedItems: number, + // _: string, + // bucketSize: number, + // _: string, + // expansionRate: number, + // _: string, + // maxIteration: number + // ]; -// export function transformArguments(key: string): Array { -// return ['CF.INFO', key]; -// } + // export interface InfoReply { + // size: number; + // numberOfBuckets: number; + // numberOfFilters: number; + // numberOfInsertedItems: number; + // numberOfDeletedItems: number; + // bucketSize: number; + // expansionRate: number; + // maxIteration: number; + // } -// export type InfoRawReply = [ -// _: string, -// size: number, -// _: string, -// numberOfBuckets: number, -// _: string, -// numberOfFilters: number, -// _: string, -// numberOfInsertedItems: number, -// _: string, -// numberOfDeletedItems: number, -// _: string, -// bucketSize: number, -// _: string, -// expansionRate: number, -// _: string, -// maxIteration: number -// ]; - -// export interface InfoReply { -// size: number; -// numberOfBuckets: number; -// numberOfFilters: number; -// numberOfInsertedItems: number; -// numberOfDeletedItems: number; -// bucketSize: number; -// expansionRate: number; -// maxIteration: number; -// } - -// export function transformReply(reply: InfoRawReply): InfoReply { -// return { -// size: reply[1], -// numberOfBuckets: reply[3], -// numberOfFilters: reply[5], -// numberOfInsertedItems: reply[7], -// numberOfDeletedItems: reply[9], -// bucketSize: reply[11], -// expansionRate: reply[13], -// maxIteration: reply[15] -// }; -// } + // export function transformReply(reply: InfoRawReply): InfoReply { + // return { + // size: reply[1], + // numberOfBuckets: reply[3], + // numberOfFilters: reply[5], + // numberOfInsertedItems: reply[7], + // numberOfDeletedItems: reply[9], + // bucketSize: reply[11], + // expansionRate: reply[13], + // maxIteration: reply[15] + // }; + // } + transformReply: undefined as unknown as () => any +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/cuckoo/index.ts b/packages/bloom/lib/commands/cuckoo/index.ts index f8eaed9305..62c63fe8d1 100644 --- a/packages/bloom/lib/commands/cuckoo/index.ts +++ b/packages/bloom/lib/commands/cuckoo/index.ts @@ -4,7 +4,7 @@ import ADDNX from './ADDNX'; import COUNT from './COUNT'; import DEL from './DEL'; import EXISTS from './EXISTS'; -// import INFO from './INFO'; +import INFO from './INFO'; import INSERT from './INSERT'; import INSERTNX from './INSERTNX'; import LOADCHUNK from './LOADCHUNK'; @@ -22,8 +22,8 @@ export default { del: DEL, EXISTS, exists: EXISTS, - // INFO, - // info: INFO, + INFO, + info: INFO, INSERT, insert: INSERT, INSERTNX, diff --git a/packages/bloom/lib/commands/t-digest/INFO.spec.ts b/packages/bloom/lib/commands/t-digest/INFO.spec.ts index 7845c49804..0d50406a3a 100644 --- a/packages/bloom/lib/commands/t-digest/INFO.spec.ts +++ b/packages/bloom/lib/commands/t-digest/INFO.spec.ts @@ -1,25 +1,27 @@ -// import { strict as assert } from 'node:assert'; -// import testUtils, { GLOBAL } from '../../test-utils'; -// import { transformArguments } from './INFO'; +import { strict as assert } from 'node:assert'; +import testUtils, { GLOBAL } from '../../test-utils'; +import INFO from './INFO'; -// describe('TDIGEST.INFO', () => { -// it('transformArguments', () => { -// assert.deepEqual( -// transformArguments('key'), -// ['TDIGEST.INFO', 'key'] -// ); -// }); +describe('TDIGEST.INFO', () => { + it('transformArguments', () => { + assert.deepEqual( + INFO.transformArguments('key'), + ['TDIGEST.INFO', 'key'] + ); + }); -// testUtils.testWithClient('client.tDigest.info', async client => { -// await client.tDigest.create('key'); + testUtils.testWithClient('client.tDigest.info', async client => { + const [, reply] = await Promise.all([ + client.tDigest.create('key'), + client.tDigest.info('key') + ]); -// const info = await client.tDigest.info('key'); -// assert(typeof info.capacity, 'number'); -// assert(typeof info.mergedNodes, 'number'); -// assert(typeof info.unmergedNodes, 'number'); -// assert(typeof info.mergedWeight, 'number'); -// assert(typeof info.unmergedWeight, 'number'); -// assert(typeof info.totalCompression, 'number'); -// assert(typeof info.totalCompression, 'number'); -// }, GLOBAL.SERVERS.OPEN); -// }); + assert(typeof reply.capacity, 'number'); + assert(typeof reply.mergedNodes, 'number'); + assert(typeof reply.unmergedNodes, 'number'); + assert(typeof reply.mergedWeight, 'number'); + assert(typeof reply.unmergedWeight, 'number'); + assert(typeof reply.totalCompression, 'number'); + assert(typeof reply.totalCompression, 'number'); + }, GLOBAL.SERVERS.OPEN); +}); diff --git a/packages/bloom/lib/commands/t-digest/INFO.ts b/packages/bloom/lib/commands/t-digest/INFO.ts index 7830f71f9d..5286f9742b 100644 --- a/packages/bloom/lib/commands/t-digest/INFO.ts +++ b/packages/bloom/lib/commands/t-digest/INFO.ts @@ -1,51 +1,49 @@ -// import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; +import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types'; -// export const FIRST_KEY_INDEX = 1; +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments(key: RedisArgument) { + return ['TDIGEST.INFO', key]; + }, + // TODO + // type InfoRawReply = [ + // 'Compression', + // number, + // 'Capacity', + // number, + // 'Merged nodes', + // number, + // 'Unmerged nodes', + // number, + // 'Merged weight', + // string, + // 'Unmerged weight', + // string, + // 'Total compressions', + // number + // ]; -// export const IS_READ_ONLY = true; + // interface InfoReply { + // comperssion: number; + // capacity: number; + // mergedNodes: number; + // unmergedNodes: number; + // mergedWeight: number; + // unmergedWeight: number; + // totalCompression: number; + // } -// export function transformArguments(key: RedisCommandArgument): RedisCommandArguments { -// return [ -// 'TDIGEST.INFO', -// key -// ]; -// } - -// type InfoRawReply = [ -// 'Compression', -// number, -// 'Capacity', -// number, -// 'Merged nodes', -// number, -// 'Unmerged nodes', -// number, -// 'Merged weight', -// string, -// 'Unmerged weight', -// string, -// 'Total compressions', -// number -// ]; - -// interface InfoReply { -// comperssion: number; -// capacity: number; -// mergedNodes: number; -// unmergedNodes: number; -// mergedWeight: number; -// unmergedWeight: number; -// totalCompression: number; -// } - -// export function transformReply(reply: InfoRawReply): InfoReply { -// return { -// comperssion: reply[1], -// capacity: reply[3], -// mergedNodes: reply[5], -// unmergedNodes: reply[7], -// mergedWeight: Number(reply[9]), -// unmergedWeight: Number(reply[11]), -// totalCompression: reply[13] -// }; -// } \ No newline at end of file + // export function transformReply(reply: InfoRawReply): InfoReply { + // return { + // comperssion: reply[1], + // capacity: reply[3], + // mergedNodes: reply[5], + // unmergedNodes: reply[7], + // mergedWeight: Number(reply[9]), + // unmergedWeight: Number(reply[11]), + // totalCompression: reply[13] + // }; + // } + transformReply: undefined as unknown as () => any +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/t-digest/index.ts b/packages/bloom/lib/commands/t-digest/index.ts index de3d07bdb7..d180911dbf 100644 --- a/packages/bloom/lib/commands/t-digest/index.ts +++ b/packages/bloom/lib/commands/t-digest/index.ts @@ -4,7 +4,7 @@ import BYRANK from './BYRANK'; import BYREVRANK from './BYREVRANK'; import CDF from './CDF'; import CREATE from './CREATE'; -// import INFO from './INFO'; +import INFO from './INFO'; import MAX from './MAX'; import MERGE from './MERGE'; import MIN from './MIN'; @@ -25,8 +25,8 @@ export default { cdf: CDF, CREATE, create: CREATE, - // INFO, - // info: INFO, + INFO, + info: INFO, MAX, max: MAX, MERGE, diff --git a/packages/client/lib/commands/CLUSTER_INFO.spec.ts b/packages/client/lib/commands/CLUSTER_INFO.spec.ts index e20b90a301..f7c708663f 100644 --- a/packages/client/lib/commands/CLUSTER_INFO.spec.ts +++ b/packages/client/lib/commands/CLUSTER_INFO.spec.ts @@ -1,11 +1,11 @@ import { strict as assert } from 'node:assert'; import testUtils, { GLOBAL } from '../test-utils'; -import { transformArguments, transformReply } from './CLUSTER_INFO'; +import CLUSTER_INFO from './CLUSTER_INFO'; describe('CLUSTER INFO', () => { it('transformArguments', () => { assert.deepEqual( - transformArguments(), + CLUSTER_INFO.transformArguments(), ['CLUSTER', 'INFO'] ); }); diff --git a/packages/client/lib/commands/INFO.spec.ts b/packages/client/lib/commands/INFO.spec.ts index f59ce26168..c455577872 100644 --- a/packages/client/lib/commands/INFO.spec.ts +++ b/packages/client/lib/commands/INFO.spec.ts @@ -1,20 +1,28 @@ import { strict as assert } from 'node:assert'; -import { transformArguments } from './INFO'; +import testUtils, { GLOBAL } from '../test-utils'; +import INFO from './INFO'; describe('INFO', () => { - describe('transformArguments', () => { - it('simple', () => { - assert.deepEqual( - transformArguments(), - ['INFO'] - ); - }); - - it('server section', () => { - assert.deepEqual( - transformArguments('server'), - ['INFO', 'server'] - ); - }); + describe('transformArguments', () => { + it('simple', () => { + assert.deepEqual( + INFO.transformArguments(), + ['INFO'] + ); }); + + it('server section', () => { + assert.deepEqual( + INFO.transformArguments('server'), + ['INFO', 'server'] + ); + }); + }); + + testUtils.testWithClient('client.info', async client => { + assert.equal( + typeof await client.info(), + 'string' + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/client/lib/commands/KEYS.spec.ts b/packages/client/lib/commands/KEYS.spec.ts index 46f8a3cb0b..8100559a7e 100644 --- a/packages/client/lib/commands/KEYS.spec.ts +++ b/packages/client/lib/commands/KEYS.spec.ts @@ -2,13 +2,10 @@ import { strict as assert } from 'node:assert'; import testUtils, { GLOBAL } from '../test-utils'; describe('KEYS', () => { - testUtils.testAll('keys', async client => { + testUtils.testWithClient('keys', async client => { assert.deepEqual( await client.keys('pattern'), [] ); - }, { - client: GLOBAL.SERVERS.OPEN, - cluster: GLOBAL.CLUSTERS.OPEN - }); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/client/lib/commands/SCAN.spec.ts b/packages/client/lib/commands/SCAN.spec.ts index 908c57ffee..f4dd865d11 100644 --- a/packages/client/lib/commands/SCAN.spec.ts +++ b/packages/client/lib/commands/SCAN.spec.ts @@ -50,7 +50,7 @@ describe('SCAN', () => { }); }); - testUtils.testAll('scan', async client => { + testUtils.testWithClient('client.scan', async client => { assert.deepEqual( await client.scan('0'), { @@ -58,8 +58,5 @@ describe('SCAN', () => { keys: [] } ); - }, { - client: GLOBAL.SERVERS.OPEN, - cluster: GLOBAL.CLUSTERS.OPEN - }); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/client/lib/commands/WAIT.spec.ts b/packages/client/lib/commands/WAIT.spec.ts index ff91f4ed51..61b197c90b 100644 --- a/packages/client/lib/commands/WAIT.spec.ts +++ b/packages/client/lib/commands/WAIT.spec.ts @@ -10,13 +10,10 @@ describe('WAIT', () => { ); }); - testUtils.testAll('wait', async client => { + testUtils.testWithClient('client.wait', async client => { assert.equal( await client.wait(0, 1), 0 ); - }, { - client: GLOBAL.SERVERS.OPEN, - cluster: GLOBAL.CLUSTERS.OPEN - }); + }, GLOBAL.SERVERS.OPEN); });