diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 381b79d14f..883ad8e25e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: ['16', '18', '19', '20'] + node-version: ['16', '18', '20'] redis-version: ['5', '6.0', '6.2', '7.0', '7.2-rc'] steps: - uses: actions/checkout@v3 @@ -32,9 +32,9 @@ jobs: - name: Install Packages run: npm ci - name: Build - run: npm run build -- ./packages/client ./packages/test-utils/ + run: npm run build -- ./packages/client ./packages/test-utils - name: Run Tests - run: npm run test -w ./packages/client -- --forbid-only --redis-version=${{ matrix.redis-version }} + run: npm run test -ws --if-present -- --forbid-only --redis-version=${{ matrix.redis-version }} - name: Upload to Codecov run: | curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import diff --git a/docs/scan-iterators.md b/docs/scan-iterators.md index f8e317fcef..ead3a346a2 100644 --- a/docs/scan-iterators.md +++ b/docs/scan-iterators.md @@ -22,7 +22,7 @@ You can override the default options by providing a configuration object: ```typescript client.scanIterator({ - cursor: 0, // 0 by default + cursor: '0', // optional, defaults to '0' TYPE: 'string', // `SCAN` only MATCH: 'patter*', COUNT: 100 diff --git a/docs/v4-to-v5.md b/docs/v4-to-v5.md index e4c1b122b5..725b24d9ce 100644 --- a/docs/v4-to-v5.md +++ b/docs/v4-to-v5.md @@ -131,7 +131,7 @@ Some command arguments/replies have changed to align more closely to data types - `LCS IDX`: `length` has been changed to `len`, `matches` has been changed from `Array<{ key1: RangeReply; key2: RangeReply; }>` to `Array<[key1: RangeReply, key2: RangeReply]>` - `HEXISTS`: `boolean` -> `number` [^boolean-to-number] - `HRANDFIELD_COUNT_WITHVALUES`: `Record` -> `Array<{ field: BlobString; value: BlobString; }>` (it can return duplicates). -- `SCAN`, `HSCAN`, `SSCAN`, and `ZSCAN`: cursor type is `string` instead of `number`? +- `SCAN`, `HSCAN`, `SSCAN`, and `ZSCAN`: `cursor` type is `string | Buffer` instead of `number` - `HSETNX`: `boolean` -> `number` [^boolean-to-number] - `ZINTER`: instead of `client.ZINTER('key', { WEIGHTS: [1] })` use `client.ZINTER({ key: 'key', weight: 1 }])` - `ZINTER_WITHSCORES`: instead of `client.ZINTER_WITHSCORES('key', { WEIGHTS: [1] })` use `client.ZINTER_WITHSCORES({ key: 'key', weight: 1 }])` @@ -175,6 +175,7 @@ Some command arguments/replies have changed to align more closely to data types - `XINFO STREAM`: `radixTreeKeys` -> `radix-tree-keys`, `radixTreeNodes` -> `radix-tree-nodes`, `lastGeneratedId` -> `last-generated-id`, `maxDeletedEntryId` -> `max-deleted-entry-id`, `entriesAdded` -> `entries-added`, `recordedFirstEntryId` -> `recorded-first-entry-id`, `firstEntry` -> `first-entry`, `lastEntry` -> `last-entry` - `XAUTOCLAIM`, `XCLAIM`, `XRANGE`, `XREVRANGE`: `Array<{ name: string; messages: Array<{ id: string; message: Record }>; }>` -> `Record }>>` - `FT.SUGDEL`: [^boolean-to-number] +- `TOPK.QUERY`: `Array` -> `Array` [^enum-to-constants]: TODO diff --git a/packages/bloom/lib/commands/bloom/ADD.spec.ts b/packages/bloom/lib/commands/bloom/ADD.spec.ts index e7ec340913..5a14e0c779 100644 --- a/packages/bloom/lib/commands/bloom/ADD.spec.ts +++ b/packages/bloom/lib/commands/bloom/ADD.spec.ts @@ -1,19 +1,19 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './ADD'; +import ADD from './ADD'; -describe('BF ADD', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', 'item'), - ['BF.ADD', 'key', 'item'] - ); - }); +describe('BF.ADD', () => { + it('transformArguments', () => { + assert.deepEqual( + ADD.transformArguments('key', 'item'), + ['BF.ADD', 'key', 'item'] + ); + }); - testUtils.testWithClient('client.bf.add', async client => { - assert.equal( - await client.bf.add('key', 'item'), - true - ); - }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('client.bf.add', async client => { + assert.equal( + await client.bf.add('key', 'item'), + true + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/bloom/ADD.ts b/packages/bloom/lib/commands/bloom/ADD.ts index d8938f4c2b..a965575489 100644 --- a/packages/bloom/lib/commands/bloom/ADD.ts +++ b/packages/bloom/lib/commands/bloom/ADD.ts @@ -1,7 +1,11 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types'; +import { transformBooleanReply } from '@redis/client/dist/lib/commands/generic-transformers'; -export function transformArguments(key: string, item: string): Array { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments(key: RedisArgument, item: RedisArgument) { return ['BF.ADD', key, item]; -} - -export { transformBooleanReply as transformReply } from '@redis/client/dist/lib/commands/generic-transformers'; + }, + transformReply: transformBooleanReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/bloom/CARD.spec.ts b/packages/bloom/lib/commands/bloom/CARD.spec.ts index 4d5620ea19..ed54a43614 100644 --- a/packages/bloom/lib/commands/bloom/CARD.spec.ts +++ b/packages/bloom/lib/commands/bloom/CARD.spec.ts @@ -1,19 +1,19 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './CARD'; +import CARD from './CARD'; -describe('BF CARD', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('bloom'), - ['BF.CARD', 'bloom'] - ); - }); +describe('BF.CARD', () => { + it('transformArguments', () => { + assert.deepEqual( + CARD.transformArguments('bloom'), + ['BF.CARD', 'bloom'] + ); + }); - testUtils.testWithClient('client.bf.card', async client => { - assert.equal( - await client.bf.card('key'), - 0 - ); - }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('client.bf.card', async client => { + assert.equal( + await client.bf.card('key'), + 0 + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/bloom/CARD.ts b/packages/bloom/lib/commands/bloom/CARD.ts index 530284c3f6..ddaa76cc1f 100644 --- a/packages/bloom/lib/commands/bloom/CARD.ts +++ b/packages/bloom/lib/commands/bloom/CARD.ts @@ -1,9 +1,10 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types'; -export const IS_READ_ONLY = true; - -export function transformArguments(key: string): Array { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments(key: RedisArgument) { return ['BF.CARD', key]; -} - -export declare function transformReply(): number; + }, + transformReply: undefined as unknown as () => NumberReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/bloom/EXISTS.spec.ts b/packages/bloom/lib/commands/bloom/EXISTS.spec.ts index 1088e739e6..276607b5d1 100644 --- a/packages/bloom/lib/commands/bloom/EXISTS.spec.ts +++ b/packages/bloom/lib/commands/bloom/EXISTS.spec.ts @@ -1,19 +1,19 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './EXISTS'; +import EXISTS from './EXISTS'; -describe('BF EXISTS', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', 'item'), - ['BF.EXISTS', 'key', 'item'] - ); - }); +describe('BF.EXISTS', () => { + it('transformArguments', () => { + assert.deepEqual( + EXISTS.transformArguments('key', 'item'), + ['BF.EXISTS', 'key', 'item'] + ); + }); - testUtils.testWithClient('client.bf.exists', async client => { - assert.equal( - await client.bf.exists('key', 'item'), - false - ); - }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('client.bf.exists', async client => { + assert.equal( + await client.bf.exists('key', 'item'), + false + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/bloom/EXISTS.ts b/packages/bloom/lib/commands/bloom/EXISTS.ts index d044207e24..9d28d671d6 100644 --- a/packages/bloom/lib/commands/bloom/EXISTS.ts +++ b/packages/bloom/lib/commands/bloom/EXISTS.ts @@ -1,9 +1,11 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types'; +import { transformBooleanReply } from '@redis/client/dist/lib/commands/generic-transformers'; -export const IS_READ_ONLY = true; - -export function transformArguments(key: string, item: string): Array { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments(key: RedisArgument, item: RedisArgument) { return ['BF.EXISTS', key, item]; -} - -export { transformBooleanReply as transformReply } from '@redis/client/dist/lib/commands/generic-transformers'; + }, + transformReply: transformBooleanReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/bloom/INFO.spec.ts b/packages/bloom/lib/commands/bloom/INFO.spec.ts index 7a5e5724c2..7a9f30faa7 100644 --- a/packages/bloom/lib/commands/bloom/INFO.spec.ts +++ b/packages/bloom/lib/commands/bloom/INFO.spec.ts @@ -1,24 +1,24 @@ -import { strict as assert } from 'assert'; -import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './INFO'; +// import { strict as assert } from 'assert'; +// import testUtils, { GLOBAL } from '../../test-utils'; +// import { transformArguments } from './INFO'; -describe('BF INFO', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('bloom'), - ['BF.INFO', 'bloom'] - ); - }); +// describe('BF INFO', () => { +// it('transformArguments', () => { +// assert.deepEqual( +// 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 => { +// await client.bf.reserve('key', 0.01, 100); - 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); -}); +// 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); +// }); diff --git a/packages/bloom/lib/commands/bloom/INFO.ts b/packages/bloom/lib/commands/bloom/INFO.ts index 52e9764640..7954053f0f 100644 --- a/packages/bloom/lib/commands/bloom/INFO.ts +++ b/packages/bloom/lib/commands/bloom/INFO.ts @@ -1,38 +1,57 @@ -export const FIRST_KEY_INDEX = 1; +// // export type InfoRawReply = [ +// // _: string, +// // capacity: number, +// // _: string, +// // size: number, +// // _: string, +// // numberOfFilters: number, +// // _: string, +// // numberOfInsertedItems: number, +// // _: string, +// // expansionRate: number, +// // ]; -export const IS_READ_ONLY = true; +// // export interface InfoReply { +// // capacity: number; +// // size: number; +// // numberOfFilters: number; +// // numberOfInsertedItems: number; +// // expansionRate: number; +// // } -export function transformArguments(key: string): Array { - return ['BF.INFO', key]; -} +// // export function transformReply(reply: InfoRawReply): InfoReply { +// // return { +// // capacity: reply[1], +// // size: reply[3], +// // numberOfFilters: reply[5], +// // numberOfInsertedItems: reply[7], +// // expansionRate: reply[9] +// // }; +// // } -export type InfoRawReply = [ - _: string, - capacity: number, - _: string, - size: number, - _: string, - numberOfFilters: number, - _: string, - numberOfInsertedItems: number, - _: string, - expansionRate: number, -]; +// import { RedisArgument, Command, TuplesToMapReply, BlobStringReply, NumberReply } from '@redis/client/dist/lib/RESP/types'; +// import { transformBooleanArrayReply } from '@redis/client/dist/lib/commands/generic-transformers'; -export interface InfoReply { - capacity: number; - size: number; - numberOfFilters: number; - numberOfInsertedItems: number; - expansionRate: number; -} +// export type BfInfoReply = TuplesToMapReply<[ +// [BlobStringReply<'Capacity'>, NumberReply], +// [BlobStringReply<'Size'>, NumberReply], +// [BlobStringReply<'Number of filters'>, NumberReply], + -export function transformReply(reply: InfoRawReply): InfoReply { - return { - capacity: reply[1], - size: reply[3], - numberOfFilters: reply[5], - numberOfInsertedItems: reply[7], - expansionRate: reply[9] - }; -} +// ]>; + +// export default { +// FIRST_KEY_INDEX: 1, +// IS_READ_ONLY: true, +// transformArguments(key: RedisArgument) { +// return ['BF.INFO', key]; +// }, +// transformReply: { +// 2: () => { + +// }, +// 3: () => { + +// } +// } +// } as const satisfies Command; diff --git a/packages/bloom/lib/commands/bloom/INSERT.spec.ts b/packages/bloom/lib/commands/bloom/INSERT.spec.ts index aff9e6e282..cb18dcd7a1 100644 --- a/packages/bloom/lib/commands/bloom/INSERT.spec.ts +++ b/packages/bloom/lib/commands/bloom/INSERT.spec.ts @@ -1,69 +1,69 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './INSERT'; +import INSERT from './INSERT'; -describe('BF INSERT', () => { - describe('transformArguments', () => { - it('simple', () => { - assert.deepEqual( - transformArguments('key', 'item'), - ['BF.INSERT', 'key', 'ITEMS', 'item'] - ); - }); - - it('with CAPACITY', () => { - assert.deepEqual( - transformArguments('key', 'item', { CAPACITY: 100 }), - ['BF.INSERT', 'key', 'CAPACITY', '100', 'ITEMS', 'item'] - ); - }); - - it('with ERROR', () => { - assert.deepEqual( - transformArguments('key', 'item', { ERROR: 0.01 }), - ['BF.INSERT', 'key', 'ERROR', '0.01', 'ITEMS', 'item'] - ); - }); - - it('with EXPANSION', () => { - assert.deepEqual( - transformArguments('key', 'item', { EXPANSION: 1 }), - ['BF.INSERT', 'key', 'EXPANSION', '1', 'ITEMS', 'item'] - ); - }); - - it('with NOCREATE', () => { - assert.deepEqual( - transformArguments('key', 'item', { NOCREATE: true }), - ['BF.INSERT', 'key', 'NOCREATE', 'ITEMS', 'item'] - ); - }); - - it('with NONSCALING', () => { - assert.deepEqual( - transformArguments('key', 'item', { NONSCALING: true }), - ['BF.INSERT', 'key', 'NONSCALING', 'ITEMS', 'item'] - ); - }); - - it('with CAPACITY, ERROR, EXPANSION, NOCREATE and NONSCALING', () => { - assert.deepEqual( - transformArguments('key', 'item', { - CAPACITY: 100, - ERROR: 0.01, - EXPANSION: 1, - NOCREATE: true, - NONSCALING: true - }), - ['BF.INSERT', 'key', 'CAPACITY', '100', 'ERROR', '0.01', 'EXPANSION', '1', 'NOCREATE', 'NONSCALING', 'ITEMS', 'item'] - ); - }); +describe('BF.INSERT', () => { + describe('transformArguments', () => { + it('simple', () => { + assert.deepEqual( + INSERT.transformArguments('key', 'item'), + ['BF.INSERT', 'key', 'ITEMS', 'item'] + ); }); - testUtils.testWithClient('client.bf.insert', async client => { - assert.deepEqual( - await client.bf.insert('key', 'item'), - [true] - ); - }, GLOBAL.SERVERS.OPEN); + it('with CAPACITY', () => { + assert.deepEqual( + INSERT.transformArguments('key', 'item', { CAPACITY: 100 }), + ['BF.INSERT', 'key', 'CAPACITY', '100', 'ITEMS', 'item'] + ); + }); + + it('with ERROR', () => { + assert.deepEqual( + INSERT.transformArguments('key', 'item', { ERROR: 0.01 }), + ['BF.INSERT', 'key', 'ERROR', '0.01', 'ITEMS', 'item'] + ); + }); + + it('with EXPANSION', () => { + assert.deepEqual( + INSERT.transformArguments('key', 'item', { EXPANSION: 1 }), + ['BF.INSERT', 'key', 'EXPANSION', '1', 'ITEMS', 'item'] + ); + }); + + it('with NOCREATE', () => { + assert.deepEqual( + INSERT.transformArguments('key', 'item', { NOCREATE: true }), + ['BF.INSERT', 'key', 'NOCREATE', 'ITEMS', 'item'] + ); + }); + + it('with NONSCALING', () => { + assert.deepEqual( + INSERT.transformArguments('key', 'item', { NONSCALING: true }), + ['BF.INSERT', 'key', 'NONSCALING', 'ITEMS', 'item'] + ); + }); + + it('with CAPACITY, ERROR, EXPANSION, NOCREATE and NONSCALING', () => { + assert.deepEqual( + INSERT.transformArguments('key', 'item', { + CAPACITY: 100, + ERROR: 0.01, + EXPANSION: 1, + NOCREATE: true, + NONSCALING: true + }), + ['BF.INSERT', 'key', 'CAPACITY', '100', 'ERROR', '0.01', 'EXPANSION', '1', 'NOCREATE', 'NONSCALING', 'ITEMS', 'item'] + ); + }); + }); + + testUtils.testWithClient('client.bf.insert', async client => { + assert.deepEqual( + await client.bf.insert('key', 'item'), + [true] + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/bloom/INSERT.ts b/packages/bloom/lib/commands/bloom/INSERT.ts index 4c3cec0f79..dfeaf5f20d 100644 --- a/packages/bloom/lib/commands/bloom/INSERT.ts +++ b/packages/bloom/lib/commands/bloom/INSERT.ts @@ -1,45 +1,47 @@ -import { pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers'; -import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; +import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types'; +import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers'; +import { transformBooleanArrayReply } from '@redis/client/dist/lib/commands/generic-transformers'; -export const FIRST_KEY_INDEX = 1; - -interface InsertOptions { - CAPACITY?: number; - ERROR?: number; - EXPANSION?: number; - NOCREATE?: true; - NONSCALING?: true; +export interface BfInsertOptions { + CAPACITY?: number; + ERROR?: number; + EXPANSION?: number; + NOCREATE?: boolean; + NONSCALING?: boolean; } -export function transformArguments( - key: string, - items: RedisCommandArgument | Array, - options?: InsertOptions -): RedisCommandArguments { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments( + key: RedisArgument, + items: RedisVariadicArgument, + options?: BfInsertOptions + ) { const args = ['BF.INSERT', key]; - if (options?.CAPACITY) { - args.push('CAPACITY', options.CAPACITY.toString()); + if (options?.CAPACITY !== undefined) { + args.push('CAPACITY', options.CAPACITY.toString()); } - if (options?.ERROR) { - args.push('ERROR', options.ERROR.toString()); + if (options?.ERROR !== undefined) { + args.push('ERROR', options.ERROR.toString()); } - if (options?.EXPANSION) { - args.push('EXPANSION', options.EXPANSION.toString()); + if (options?.EXPANSION !== undefined) { + args.push('EXPANSION', options.EXPANSION.toString()); } if (options?.NOCREATE) { - args.push('NOCREATE'); + args.push('NOCREATE'); } if (options?.NONSCALING) { - args.push('NONSCALING'); + args.push('NONSCALING'); } args.push('ITEMS'); return pushVariadicArguments(args, items); -} - -export { transformBooleanArrayReply as transformReply } from '@redis/client/dist/lib/commands/generic-transformers'; + }, + transformReply: transformBooleanArrayReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/bloom/LOADCHUNK.spec.ts b/packages/bloom/lib/commands/bloom/LOADCHUNK.spec.ts index 19634cb4a7..29a22cbd71 100644 --- a/packages/bloom/lib/commands/bloom/LOADCHUNK.spec.ts +++ b/packages/bloom/lib/commands/bloom/LOADCHUNK.spec.ts @@ -1,28 +1,35 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './LOADCHUNK'; +import LOADCHUNK from './LOADCHUNK'; +import { RESP_TYPES } from '@redis/client'; -describe('BF LOADCHUNK', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', 0, ''), - ['BF.LOADCHUNK', 'key', '0', ''] - ); - }); +describe('BF.LOADCHUNK', () => { + it('transformArguments', () => { + assert.deepEqual( + LOADCHUNK.transformArguments('key', 0, ''), + ['BF.LOADCHUNK', 'key', '0', ''] + ); + }); - testUtils.testWithClient('client.bf.loadChunk', async client => { - const [, { iterator, chunk }] = await Promise.all([ - client.bf.reserve('source', 0.01, 100), - client.bf.scanDump( - client.commandOptions({ returnBuffers: true }), - 'source', - 0 - ) - ]); + testUtils.testWithClient('client.bf.loadChunk', async client => { + const [, { iterator, chunk }] = await Promise.all([ + client.bf.reserve('source', 0.01, 100), + client.bf.scanDump('source', 0) + ]); - assert.equal( - await client.bf.loadChunk('destination', iterator, chunk), - 'OK' - ); - }, GLOBAL.SERVERS.OPEN); + assert.equal( + await client.bf.loadChunk('destination', iterator, chunk), + 'OK' + ); + }, { + ...GLOBAL.SERVERS.OPEN, + clientOptions: { + ...GLOBAL.SERVERS.OPEN.clientOptions, + commandOptions: { + typeMapping: { + [RESP_TYPES.BLOB_STRING]: Buffer + } + } + } + }); }); diff --git a/packages/bloom/lib/commands/bloom/LOADCHUNK.ts b/packages/bloom/lib/commands/bloom/LOADCHUNK.ts index 491f572a49..feade2fac4 100644 --- a/packages/bloom/lib/commands/bloom/LOADCHUNK.ts +++ b/packages/bloom/lib/commands/bloom/LOADCHUNK.ts @@ -1,13 +1,10 @@ -import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; +import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types'; -export const FIRST_KEY_INDEX = 1; - -export function transformArguments( - key: string, - iteretor: number, - chunk: RedisCommandArgument -): RedisCommandArguments { - return ['BF.LOADCHUNK', key, iteretor.toString(), chunk]; -} - -export declare function transformReply(): 'OK'; +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments(key: RedisArgument, iterator: number, chunk: RedisArgument) { + return ['BF.LOADCHUNK', key, iterator.toString(), chunk]; + }, + transformReply: undefined as unknown as () => SimpleStringReply<'OK'> +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/bloom/MADD.spec.ts b/packages/bloom/lib/commands/bloom/MADD.spec.ts index 784f99926f..f4abf6e248 100644 --- a/packages/bloom/lib/commands/bloom/MADD.spec.ts +++ b/packages/bloom/lib/commands/bloom/MADD.spec.ts @@ -1,19 +1,19 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './MADD'; +import MADD from './MADD'; -describe('BF MADD', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', ['1', '2']), - ['BF.MADD', 'key', '1', '2'] - ); - }); +describe('BF.MADD', () => { + it('transformArguments', () => { + assert.deepEqual( + MADD.transformArguments('key', ['1', '2']), + ['BF.MADD', 'key', '1', '2'] + ); + }); - testUtils.testWithClient('client.ts.mAdd', async client => { - assert.deepEqual( - await client.bf.mAdd('key', ['1', '2']), - [true, true] - ); - }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('client.ts.mAdd', async client => { + assert.deepEqual( + await client.bf.mAdd('key', ['1', '2']), + [true, true] + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/bloom/MADD.ts b/packages/bloom/lib/commands/bloom/MADD.ts index 056c4a1c1c..afb122476f 100644 --- a/packages/bloom/lib/commands/bloom/MADD.ts +++ b/packages/bloom/lib/commands/bloom/MADD.ts @@ -1,7 +1,12 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types'; +import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers'; +import { transformBooleanArrayReply } from '@redis/client/dist/lib/commands/generic-transformers'; -export function transformArguments(key: string, items: Array): Array { - return ['BF.MADD', key, ...items]; -} - -export { transformBooleanArrayReply as transformReply } from '@redis/client/dist/lib/commands/generic-transformers'; +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments(key: RedisArgument, items: RedisVariadicArgument) { + return pushVariadicArguments(['BF.MADD', key], items); + }, + transformReply: transformBooleanArrayReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/bloom/MEXISTS.spec.ts b/packages/bloom/lib/commands/bloom/MEXISTS.spec.ts index 027e51d2c4..0023a41e9b 100644 --- a/packages/bloom/lib/commands/bloom/MEXISTS.spec.ts +++ b/packages/bloom/lib/commands/bloom/MEXISTS.spec.ts @@ -1,19 +1,19 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './MEXISTS'; +import MEXISTS from './MEXISTS'; -describe('BF MEXISTS', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', ['1', '2']), - ['BF.MEXISTS', 'key', '1', '2'] - ); - }); +describe('BF.MEXISTS', () => { + it('transformArguments', () => { + assert.deepEqual( + MEXISTS.transformArguments('key', ['1', '2']), + ['BF.MEXISTS', 'key', '1', '2'] + ); + }); - testUtils.testWithClient('client.bf.mExists', async client => { - assert.deepEqual( - await client.bf.mExists('key', ['1', '2']), - [false, false] - ); - }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('client.bf.mExists', async client => { + assert.deepEqual( + await client.bf.mExists('key', ['1', '2']), + [false, false] + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/bloom/MEXISTS.ts b/packages/bloom/lib/commands/bloom/MEXISTS.ts index fb79410155..a23b713b50 100644 --- a/packages/bloom/lib/commands/bloom/MEXISTS.ts +++ b/packages/bloom/lib/commands/bloom/MEXISTS.ts @@ -1,9 +1,12 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types'; +import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers'; +import { transformBooleanArrayReply } from '@redis/client/dist/lib/commands/generic-transformers'; -export const IS_READ_ONLY = true; - -export function transformArguments(key: string, items: Array): Array { - return ['BF.MEXISTS', key, ...items]; -} - -export { transformBooleanArrayReply as transformReply } from '@redis/client/dist/lib/commands/generic-transformers'; +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments(key: RedisArgument, items: RedisVariadicArgument) { + return pushVariadicArguments(['BF.MEXISTS', key], items); + }, + transformReply: transformBooleanArrayReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/bloom/RESERVE.spec.ts b/packages/bloom/lib/commands/bloom/RESERVE.spec.ts index bc872f9c3f..dfb6c820ff 100644 --- a/packages/bloom/lib/commands/bloom/RESERVE.spec.ts +++ b/packages/bloom/lib/commands/bloom/RESERVE.spec.ts @@ -1,49 +1,49 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './RESERVE'; +import RESERVE from './RESERVE'; -describe('BF RESERVE', () => { - describe('transformArguments', () => { - it('simple', () => { - assert.deepEqual( - transformArguments('key', 0.01, 100), - ['BF.RESERVE', 'key', '0.01', '100'] - ); - }); - - it('with EXPANSION', () => { - assert.deepEqual( - transformArguments('key', 0.01, 100, { - EXPANSION: 1 - }), - ['BF.RESERVE', 'key', '0.01', '100', 'EXPANSION', '1'] - ); - }); - - it('with NONSCALING', () => { - assert.deepEqual( - transformArguments('key', 0.01, 100, { - NONSCALING: true - }), - ['BF.RESERVE', 'key', '0.01', '100', 'NONSCALING'] - ); - }); - - it('with EXPANSION and NONSCALING', () => { - assert.deepEqual( - transformArguments('key', 0.01, 100, { - EXPANSION: 1, - NONSCALING: true - }), - ['BF.RESERVE', 'key', '0.01', '100', 'EXPANSION', '1', 'NONSCALING'] - ); - }); +describe('BF.RESERVE', () => { + describe('transformArguments', () => { + it('simple', () => { + assert.deepEqual( + RESERVE.transformArguments('key', 0.01, 100), + ['BF.RESERVE', 'key', '0.01', '100'] + ); }); - testUtils.testWithClient('client.bf.reserve', async client => { - assert.equal( - await client.bf.reserve('bloom', 0.01, 100), - 'OK' - ); - }, GLOBAL.SERVERS.OPEN); + it('with EXPANSION', () => { + assert.deepEqual( + RESERVE.transformArguments('key', 0.01, 100, { + EXPANSION: 1 + }), + ['BF.RESERVE', 'key', '0.01', '100', 'EXPANSION', '1'] + ); + }); + + it('with NONSCALING', () => { + assert.deepEqual( + RESERVE.transformArguments('key', 0.01, 100, { + NONSCALING: true + }), + ['BF.RESERVE', 'key', '0.01', '100', 'NONSCALING'] + ); + }); + + it('with EXPANSION and NONSCALING', () => { + assert.deepEqual( + RESERVE.transformArguments('key', 0.01, 100, { + EXPANSION: 1, + NONSCALING: true + }), + ['BF.RESERVE', 'key', '0.01', '100', 'EXPANSION', '1', 'NONSCALING'] + ); + }); + }); + + testUtils.testWithClient('client.bf.reserve', async client => { + assert.equal( + await client.bf.reserve('bloom', 0.01, 100), + 'OK' + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/bloom/RESERVE.ts b/packages/bloom/lib/commands/bloom/RESERVE.ts index 18d7002f15..c460253523 100644 --- a/packages/bloom/lib/commands/bloom/RESERVE.ts +++ b/packages/bloom/lib/commands/bloom/RESERVE.ts @@ -1,16 +1,20 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types'; +import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers'; -interface ReserveOptions { - EXPANSION?: number; - NONSCALING?: true; +export interface BfReserveOptions { + EXPANSION?: number; + NONSCALING?: boolean; } -export function transformArguments( - key: string, +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments( + key: RedisArgument, errorRate: number, capacity: number, - options?: ReserveOptions -): Array { + options?: BfReserveOptions + ) { const args = ['BF.RESERVE', key, errorRate.toString(), capacity.toString()]; if (options?.EXPANSION) { @@ -22,6 +26,6 @@ export function transformArguments( } return args; -} - -export declare function transformReply(): 'OK'; + }, + transformReply: undefined as unknown as () => SimpleStringReply<'OK'> +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/bloom/SCANDUMP.spec.ts b/packages/bloom/lib/commands/bloom/SCANDUMP.spec.ts index 5011959048..4e5f5c3ccc 100644 --- a/packages/bloom/lib/commands/bloom/SCANDUMP.spec.ts +++ b/packages/bloom/lib/commands/bloom/SCANDUMP.spec.ts @@ -1,22 +1,22 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './SCANDUMP'; +import SCANDUMP from './SCANDUMP'; -describe('BF SCANDUMP', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', 0), - ['BF.SCANDUMP', 'key', '0'] - ); - }); +describe('BF.SCANDUMP', () => { + it('transformArguments', () => { + assert.deepEqual( + SCANDUMP.transformArguments('key', 0), + ['BF.SCANDUMP', 'key', '0'] + ); + }); - testUtils.testWithClient('client.bf.scanDump', async client => { - const [, dump] = await Promise.all([ - client.bf.reserve('key', 0.01, 100), - client.bf.scanDump('key', 0) - ]); - assert.equal(typeof dump, 'object'); - assert.equal(typeof dump.iterator, 'number'); - assert.equal(typeof dump.chunk, 'string'); - }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('client.bf.scanDump', async client => { + const [, dump] = await Promise.all([ + client.bf.reserve('key', 0.01, 100), + client.bf.scanDump('key', 0) + ]); + assert.equal(typeof dump, 'object'); + assert.equal(typeof dump.iterator, 'number'); + assert.equal(typeof dump.chunk, 'string'); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/bloom/SCANDUMP.ts b/packages/bloom/lib/commands/bloom/SCANDUMP.ts index 04b3edc2a1..be5367b872 100644 --- a/packages/bloom/lib/commands/bloom/SCANDUMP.ts +++ b/packages/bloom/lib/commands/bloom/SCANDUMP.ts @@ -1,24 +1,15 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, TuplesReply, NumberReply, BlobStringReply, Command } from '@redis/client/dist/lib/RESP/types'; -export const IS_READ_ONLY = true; - -export function transformArguments(key: string, iterator: number): Array { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments(key: RedisArgument, iterator: number) { return ['BF.SCANDUMP', key, iterator.toString()]; -} - -type ScanDumpRawReply = [ - iterator: number, - chunk: string -]; - -interface ScanDumpReply { - iterator: number; - chunk: string; -} - -export function transformReply([iterator, chunk]: ScanDumpRawReply): ScanDumpReply { + }, + transformReply(reply: TuplesReply<[NumberReply, BlobStringReply]>) { return { - iterator, - chunk + iterator: reply[0], + chunk: reply[1] }; -} + } +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/bloom/index.ts b/packages/bloom/lib/commands/bloom/index.ts index f18b8f7109..7483467d86 100644 --- a/packages/bloom/lib/commands/bloom/index.ts +++ b/packages/bloom/lib/commands/bloom/index.ts @@ -1,33 +1,34 @@ -import * as ADD from './ADD'; -import * as CARD from './CARD'; -import * as EXISTS from './EXISTS'; -import * as INFO from './INFO'; -import * as INSERT from './INSERT'; -import * as LOADCHUNK from './LOADCHUNK'; -import * as MADD from './MADD'; -import * as MEXISTS from './MEXISTS'; -import * as RESERVE from './RESERVE'; -import * as SCANDUMP from './SCANDUMP'; +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 INSERT from './INSERT'; +import LOADCHUNK from './LOADCHUNK'; +import MADD from './MADD'; +import MEXISTS from './MEXISTS'; +import RESERVE from './RESERVE'; +import SCANDUMP from './SCANDUMP'; export default { - ADD, - add: ADD, - CARD, - card: CARD, - EXISTS, - exists: EXISTS, - INFO, - info: INFO, - INSERT, - insert: INSERT, - LOADCHUNK, - loadChunk: LOADCHUNK, - MADD, - mAdd: MADD, - MEXISTS, - mExists: MEXISTS, - RESERVE, - reserve: RESERVE, - SCANDUMP, - scanDump: SCANDUMP -}; + ADD, + add: ADD, + CARD, + card: CARD, + EXISTS, + exists: EXISTS, + // INFO, + // info: INFO, + INSERT, + insert: INSERT, + LOADCHUNK, + loadChunk: LOADCHUNK, + MADD, + mAdd: MADD, + MEXISTS, + mExists: MEXISTS, + RESERVE, + reserve: RESERVE, + SCANDUMP, + scanDump: SCANDUMP +} as const satisfies RedisCommands; diff --git a/packages/bloom/lib/commands/count-min-sketch/INCRBY.spec.ts b/packages/bloom/lib/commands/count-min-sketch/INCRBY.spec.ts index 95bb28e88b..3b77d3b93d 100644 --- a/packages/bloom/lib/commands/count-min-sketch/INCRBY.spec.ts +++ b/packages/bloom/lib/commands/count-min-sketch/INCRBY.spec.ts @@ -1,41 +1,42 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './INCRBY'; +import INCRBY from './INCRBY'; -describe('CMS INCRBY', () => { - describe('transformArguments', () => { - it('single item', () => { - assert.deepEqual( - transformArguments('key', { - item: 'item', - incrementBy: 1 - }), - ['CMS.INCRBY', 'key', 'item', '1'] - ); - }); - - it('multiple items', () => { - assert.deepEqual( - transformArguments('key', [{ - item: 'a', - incrementBy: 1 - }, { - item: 'b', - incrementBy: 2 - }]), - ['CMS.INCRBY', 'key', 'a', '1', 'b', '2'] - ); - }); +describe('CMS.INCRBY', () => { + describe('transformArguments', () => { + it('single item', () => { + assert.deepEqual( + INCRBY.transformArguments('key', { + item: 'item', + incrementBy: 1 + }), + ['CMS.INCRBY', 'key', 'item', '1'] + ); }); - testUtils.testWithClient('client.cms.incrBy', async client => { - await client.cms.initByDim('key', 1000, 5); - assert.deepEqual( - await client.cms.incrBy('key', { - item: 'item', - incrementBy: 1 - }), - [1] - ); - }, GLOBAL.SERVERS.OPEN); + it('multiple items', () => { + assert.deepEqual( + INCRBY.transformArguments('key', [{ + item: 'a', + incrementBy: 1 + }, { + item: 'b', + incrementBy: 2 + }]), + ['CMS.INCRBY', 'key', 'a', '1', 'b', '2'] + ); + }); + }); + + testUtils.testWithClient('client.cms.incrBy', async client => { + const [, reply] = await Promise.all([ + client.cms.initByDim('key', 1000, 5), + client.cms.incrBy('key', { + item: 'item', + incrementBy: 1 + }) + ]); + + assert.deepEqual(reply, [1]); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/count-min-sketch/INCRBY.ts b/packages/bloom/lib/commands/count-min-sketch/INCRBY.ts index e27fb397cd..1dfbabbaa4 100644 --- a/packages/bloom/lib/commands/count-min-sketch/INCRBY.ts +++ b/packages/bloom/lib/commands/count-min-sketch/INCRBY.ts @@ -1,29 +1,32 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, ArrayReply, NumberReply, Command } from '@redis/client/dist/lib/RESP/types'; -interface IncrByItem { - item: string; - incrementBy: number; +export interface BfIncrByItem { + item: RedisArgument; + incrementBy: number; } -export function transformArguments( - key: string, - items: IncrByItem | Array -): Array { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments( + key: RedisArgument, + items: BfIncrByItem | Array + ) { const args = ['CMS.INCRBY', key]; if (Array.isArray(items)) { - for (const item of items) { - pushIncrByItem(args, item); - } + for (const item of items) { + pushIncrByItem(args, item); + } } else { - pushIncrByItem(args, items); + pushIncrByItem(args, items); } return args; -} + }, + transformReply: undefined as unknown as () => ArrayReply +} as const satisfies Command; -function pushIncrByItem(args: Array, { item, incrementBy }: IncrByItem): void { - args.push(item, incrementBy.toString()); +function pushIncrByItem(args: Array, { item, incrementBy }: BfIncrByItem): void { + args.push(item, incrementBy.toString()); } - -export declare function transformReply(): Array; diff --git a/packages/bloom/lib/commands/count-min-sketch/INFO.spec.ts b/packages/bloom/lib/commands/count-min-sketch/INFO.spec.ts index 0db8a48447..ff227cb5be 100644 --- a/packages/bloom/lib/commands/count-min-sketch/INFO.spec.ts +++ b/packages/bloom/lib/commands/count-min-sketch/INFO.spec.ts @@ -1,25 +1,27 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './INFO'; +import INFO from './INFO'; -describe('CMS INFO', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key'), - ['CMS.INFO', 'key'] - ); +describe('CMS.INFO', () => { + it('transformArguments', () => { + assert.deepEqual( + INFO.transformArguments('key'), + ['CMS.INFO', 'key'] + ); + }); + + testUtils.testWithClient('client.cms.info', async client => { + const width = 1000, + depth = 5, + [, reply] = await Promise.all([ + client.cms.initByDim('key', width, depth), + client.cms.info('key') + ]); + + assert.deepEqual(reply, { + width, + depth, + count: 0 }); - - testUtils.testWithClient('client.cms.info', async client => { - await client.cms.initByDim('key', 1000, 5); - - assert.deepEqual( - await client.cms.info('key'), - { - width: 1000, - depth: 5, - count: 0 - } - ); - }, GLOBAL.SERVERS.OPEN); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/count-min-sketch/INFO.ts b/packages/bloom/lib/commands/count-min-sketch/INFO.ts index 6dbfffcb0e..e298efd16a 100644 --- a/packages/bloom/lib/commands/count-min-sketch/INFO.ts +++ b/packages/bloom/lib/commands/count-min-sketch/INFO.ts @@ -1,30 +1,23 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, TuplesToMapReply, BlobStringReply, NumberReply, Resp2Reply, Command } from '@redis/client/dist/lib/RESP/types'; -export const IS_READ_ONLY = true; - -export function transformArguments(key: string): Array { +export type BfInfoReply = TuplesToMapReply<[ + [BlobStringReply<'width'>, NumberReply], + [BlobStringReply<'depth'>, NumberReply], + [BlobStringReply<'count'>, NumberReply] +]>; + +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments(key: RedisArgument) { return ['CMS.INFO', key]; -} - -export type InfoRawReply = [ - _: string, - width: number, - _: string, - depth: number, - _: string, - count: number -]; - -export interface InfoReply { - width: number; - depth: number; - count: number; -} - -export function transformReply(reply: InfoRawReply): InfoReply { - return { - width: reply[1], - depth: reply[3], - count: reply[5] - }; -} + }, + transformReply: { + 2: (reply: Resp2Reply) => ({ + width: reply[1], + depth: reply[3], + count: reply[5] + }), + 3: undefined as unknown as () => BfInfoReply + } +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/count-min-sketch/INITBYDIM.spec.ts b/packages/bloom/lib/commands/count-min-sketch/INITBYDIM.spec.ts index 2a9014b765..0c9a712183 100644 --- a/packages/bloom/lib/commands/count-min-sketch/INITBYDIM.spec.ts +++ b/packages/bloom/lib/commands/count-min-sketch/INITBYDIM.spec.ts @@ -1,19 +1,19 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './INITBYDIM'; +import INITBYDIM from './INITBYDIM'; -describe('CMS INITBYDIM', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', 1000, 5), - ['CMS.INITBYDIM', 'key', '1000', '5'] - ); - }); +describe('CMS.INITBYDIM', () => { + it('transformArguments', () => { + assert.deepEqual( + INITBYDIM.transformArguments('key', 1000, 5), + ['CMS.INITBYDIM', 'key', '1000', '5'] + ); + }); - testUtils.testWithClient('client.cms.initByDim', async client => { - assert.equal( - await client.cms.initByDim('key', 1000, 5), - 'OK' - ); - }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('client.cms.initByDim', async client => { + assert.equal( + await client.cms.initByDim('key', 1000, 5), + 'OK' + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/count-min-sketch/INITBYDIM.ts b/packages/bloom/lib/commands/count-min-sketch/INITBYDIM.ts index 4ec6cedd9e..60790d421e 100644 --- a/packages/bloom/lib/commands/count-min-sketch/INITBYDIM.ts +++ b/packages/bloom/lib/commands/count-min-sketch/INITBYDIM.ts @@ -1,7 +1,10 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types'; -export function transformArguments(key: string, width: number, depth: number): Array { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments(key: RedisArgument, width: number, depth: number) { return ['CMS.INITBYDIM', key, width.toString(), depth.toString()]; -} - -export declare function transformReply(): 'OK'; + }, + transformReply: undefined as unknown as () => SimpleStringReply<'OK'> +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/count-min-sketch/INITBYPROB.spec.ts b/packages/bloom/lib/commands/count-min-sketch/INITBYPROB.spec.ts index 004d3df14e..592be4db6b 100644 --- a/packages/bloom/lib/commands/count-min-sketch/INITBYPROB.spec.ts +++ b/packages/bloom/lib/commands/count-min-sketch/INITBYPROB.spec.ts @@ -1,19 +1,19 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './INITBYPROB'; +import INITBYPROB from './INITBYPROB'; -describe('CMS INITBYPROB', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', 0.001, 0.01), - ['CMS.INITBYPROB', 'key', '0.001', '0.01'] - ); - }); +describe('CMS.INITBYPROB', () => { + it('transformArguments', () => { + assert.deepEqual( + INITBYPROB.transformArguments('key', 0.001, 0.01), + ['CMS.INITBYPROB', 'key', '0.001', '0.01'] + ); + }); - testUtils.testWithClient('client.cms.initByProb', async client => { - assert.equal( - await client.cms.initByProb('key', 0.001, 0.01), - 'OK' - ); - }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('client.cms.initByProb', async client => { + assert.equal( + await client.cms.initByProb('key', 0.001, 0.01), + 'OK' + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/count-min-sketch/INITBYPROB.ts b/packages/bloom/lib/commands/count-min-sketch/INITBYPROB.ts index 7f0256515f..7b21755f17 100644 --- a/packages/bloom/lib/commands/count-min-sketch/INITBYPROB.ts +++ b/packages/bloom/lib/commands/count-min-sketch/INITBYPROB.ts @@ -1,7 +1,10 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types'; -export function transformArguments(key: string, error: number, probability: number): Array { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments(key: RedisArgument, error: number, probability: number) { return ['CMS.INITBYPROB', key, error.toString(), probability.toString()]; -} - -export declare function transformReply(): 'OK'; + }, + transformReply: undefined as unknown as () => SimpleStringReply<'OK'> +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/count-min-sketch/MERGE.spec.ts b/packages/bloom/lib/commands/count-min-sketch/MERGE.spec.ts index cf234e5734..f996f88648 100644 --- a/packages/bloom/lib/commands/count-min-sketch/MERGE.spec.ts +++ b/packages/bloom/lib/commands/count-min-sketch/MERGE.spec.ts @@ -1,36 +1,34 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './MERGE'; +import MERGE from './MERGE'; -describe('CMS MERGE', () => { - describe('transformArguments', () => { - it('without WEIGHTS', () => { - assert.deepEqual( - transformArguments('dest', ['src']), - ['CMS.MERGE', 'dest', '1', 'src'] - ); - }); - - it('with WEIGHTS', () => { - assert.deepEqual( - transformArguments('dest', [{ - name: 'src', - weight: 1 - }]), - ['CMS.MERGE', 'dest', '1', 'src', 'WEIGHTS', '1'] - ); - }); +describe('CMS.MERGE', () => { + describe('transformArguments', () => { + it('without WEIGHTS', () => { + assert.deepEqual( + MERGE.transformArguments('destination', ['source']), + ['CMS.MERGE', 'destination', '1', 'source'] + ); }); - testUtils.testWithClient('client.cms.merge', async client => { - await Promise.all([ - client.cms.initByDim('src', 1000, 5), - client.cms.initByDim('dest', 1000, 5), - ]); + it('with WEIGHTS', () => { + assert.deepEqual( + MERGE.transformArguments('destination', [{ + name: 'source', + weight: 1 + }]), + ['CMS.MERGE', 'destination', '1', 'source', 'WEIGHTS', '1'] + ); + }); + }); - assert.equal( - await client.cms.merge('dest', ['src']), - 'OK' - ); - }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('client.cms.merge', async client => { + const [, , reply] = await Promise.all([ + client.cms.initByDim('source', 1000, 5), + client.cms.initByDim('destination', 1000, 5), + client.cms.merge('destination', ['source']) + ]); + + assert.equal(reply, 'OK'); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/count-min-sketch/MERGE.ts b/packages/bloom/lib/commands/count-min-sketch/MERGE.ts index 6cca4e797c..2e63065d1c 100644 --- a/packages/bloom/lib/commands/count-min-sketch/MERGE.ts +++ b/packages/bloom/lib/commands/count-min-sketch/MERGE.ts @@ -1,37 +1,37 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types'; -interface Sketch { - name: string; - weight: number; +interface BfMergeSketch { + name: RedisArgument; + weight: number; } -type Sketches = Array | Array; +export type BfMergeSketches = Array | Array; -export function transformArguments(dest: string, src: Sketches): Array { - const args = [ - 'CMS.MERGE', - dest, - src.length.toString() - ]; +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments( + destination: RedisArgument, + source: BfMergeSketches + ) { + let args = ['CMS.MERGE', destination, source.length.toString()]; - if (isStringSketches(src)) { - args.push(...src); + if (isPlainSketches(source)) { + args = args.concat(source); } else { - for (const sketch of src) { - args.push(sketch.name); - } - - args.push('WEIGHTS'); - for (const sketch of src) { - args.push(sketch.weight.toString()); - } + const { length } = args; + args[length + source.length] = 'WEIGHTS'; + for (let i = 0; i < source.length; i++) { + args[length + i] = source[i].name; + args[length + source.length + i + 1] = source[i].weight.toString(); + } } return args; -} + }, + transformReply: undefined as unknown as () => SimpleStringReply<'OK'> +} as const satisfies Command; -function isStringSketches(src: Sketches): src is Array { - return typeof src[0] === 'string'; +function isPlainSketches(src: BfMergeSketches): src is Array { + return typeof src[0] === 'string' || src[0] instanceof Buffer; } - -export declare function transformReply(): 'OK'; diff --git a/packages/bloom/lib/commands/count-min-sketch/QUERY.spec.ts b/packages/bloom/lib/commands/count-min-sketch/QUERY.spec.ts index d391ab838b..f321c28a0e 100644 --- a/packages/bloom/lib/commands/count-min-sketch/QUERY.spec.ts +++ b/packages/bloom/lib/commands/count-min-sketch/QUERY.spec.ts @@ -1,22 +1,21 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './QUERY'; +import QUERY from './QUERY'; -describe('CMS QUERY', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', 'item'), - ['CMS.QUERY', 'key', 'item'] - ); - }); +describe('CMS.QUERY', () => { + it('transformArguments', () => { + assert.deepEqual( + QUERY.transformArguments('key', 'item'), + ['CMS.QUERY', 'key', 'item'] + ); + }); - testUtils.testWithClient('client.cms.query', async client => { - await client.cms.initByDim('key', 1000, 5); + testUtils.testWithClient('client.cms.query', async client => { + const [, reply] = await Promise.all([ + client.cms.initByDim('key', 1000, 5), + client.cms.query('key', 'item') + ]); - assert.deepEqual( - await client.cms.query('key', 'item'), - [0] - ); - - }, GLOBAL.SERVERS.OPEN); + assert.deepEqual(reply, [0]); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/count-min-sketch/QUERY.ts b/packages/bloom/lib/commands/count-min-sketch/QUERY.ts index a34a9e9b9a..5d2905300b 100644 --- a/packages/bloom/lib/commands/count-min-sketch/QUERY.ts +++ b/packages/bloom/lib/commands/count-min-sketch/QUERY.ts @@ -1,15 +1,11 @@ -import { RedisCommandArguments } from '@redis/client/dist/lib/commands'; -import { pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers'; +import { ArrayReply, NumberReply, Command, RedisArgument } from '@redis/client/dist/lib/RESP/types'; +import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers'; -export const FIRST_KEY_INDEX = 1; - -export const IS_READ_ONLY = true; - -export function transformArguments( - key: string, - items: string | Array -): RedisCommandArguments { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments(key: RedisArgument, items: RedisVariadicArgument) { return pushVariadicArguments(['CMS.QUERY', key], items); -} - -export declare function transformReply(): Array; + }, + transformReply: undefined as unknown as () => ArrayReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/count-min-sketch/index.ts b/packages/bloom/lib/commands/count-min-sketch/index.ts index 1d61734a8d..4f0f395ca3 100644 --- a/packages/bloom/lib/commands/count-min-sketch/index.ts +++ b/packages/bloom/lib/commands/count-min-sketch/index.ts @@ -1,21 +1,22 @@ -import * as INCRBY from './INCRBY'; -import * as INFO from './INFO'; -import * as INITBYDIM from './INITBYDIM'; -import * as INITBYPROB from './INITBYPROB'; -import * as MERGE from './MERGE'; -import * as QUERY from './QUERY'; +import type { RedisCommands } from '@redis/client/dist/lib/RESP/types'; +import INCRBY from './INCRBY'; +import INFO from './INFO'; +import INITBYDIM from './INITBYDIM'; +import INITBYPROB from './INITBYPROB'; +import MERGE from './MERGE'; +import QUERY from './QUERY'; export default { - INCRBY, - incrBy: INCRBY, - INFO, - info: INFO, - INITBYDIM, - initByDim: INITBYDIM, - INITBYPROB, - initByProb: INITBYPROB, - MERGE, - merge: MERGE, - QUERY, - query: QUERY -}; + INCRBY, + incrBy: INCRBY, + INFO, + info: INFO, + INITBYDIM, + initByDim: INITBYDIM, + INITBYPROB, + initByProb: INITBYPROB, + MERGE, + merge: MERGE, + QUERY, + query: QUERY +} as const satisfies RedisCommands; diff --git a/packages/bloom/lib/commands/cuckoo/ADD.spec.ts b/packages/bloom/lib/commands/cuckoo/ADD.spec.ts index f2c029fad3..d05c1c0e7f 100644 --- a/packages/bloom/lib/commands/cuckoo/ADD.spec.ts +++ b/packages/bloom/lib/commands/cuckoo/ADD.spec.ts @@ -1,19 +1,19 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments, transformReply } from './ADD'; +import ADD from './ADD'; -describe('CF ADD', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', 'item'), - ['CF.ADD', 'key', 'item'] - ); - }); +describe('CF.ADD', () => { + it('transformArguments', () => { + assert.deepEqual( + ADD.transformArguments('key', 'item'), + ['CF.ADD', 'key', 'item'] + ); + }); - testUtils.testWithClient('client.cf.add', async client => { - assert.equal( - await client.cf.add('key', 'item'), - true - ); - }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('client.cf.add', async client => { + assert.equal( + await client.cf.add('key', 'item'), + true + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/cuckoo/ADD.ts b/packages/bloom/lib/commands/cuckoo/ADD.ts index 8d16c0f2ed..52e98a801d 100644 --- a/packages/bloom/lib/commands/cuckoo/ADD.ts +++ b/packages/bloom/lib/commands/cuckoo/ADD.ts @@ -1,7 +1,11 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types'; +import { transformBooleanReply } from '@redis/client/dist/lib/commands/generic-transformers'; -export function transformArguments(key: string, item: string): Array { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments(key: RedisArgument, item: RedisArgument) { return ['CF.ADD', key, item]; -} - -export { transformBooleanReply as transformReply } from '@redis/client/dist/lib/commands/generic-transformers'; + }, + transformReply: transformBooleanReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/cuckoo/ADDNX.spec.ts b/packages/bloom/lib/commands/cuckoo/ADDNX.spec.ts index ddd9f922b1..1a291e7b30 100644 --- a/packages/bloom/lib/commands/cuckoo/ADDNX.spec.ts +++ b/packages/bloom/lib/commands/cuckoo/ADDNX.spec.ts @@ -1,21 +1,19 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './ADDNX'; +import ADDNX from './ADDNX'; -describe('CF ADDNX', () => { - describe('transformArguments', () => { - it('basic add', () => { - assert.deepEqual( - transformArguments('key', 'item'), - ['CF.ADDNX', 'key', 'item'] - ); - }); - }); +describe('CF.ADDNX', () => { + it('transformArguments', () => { + assert.deepEqual( + ADDNX.transformArguments('key', 'item'), + ['CF.ADDNX', 'key', 'item'] + ); + }); - testUtils.testWithClient('client.cf.add', async client => { - assert.equal( - await client.cf.addNX('key', 'item'), - true - ); - }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('client.cf.add', async client => { + assert.equal( + await client.cf.addNX('key', 'item'), + true + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/cuckoo/ADDNX.ts b/packages/bloom/lib/commands/cuckoo/ADDNX.ts index 789003a3a5..c739077ee4 100644 --- a/packages/bloom/lib/commands/cuckoo/ADDNX.ts +++ b/packages/bloom/lib/commands/cuckoo/ADDNX.ts @@ -1,7 +1,11 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types'; +import { transformBooleanReply } from '@redis/client/dist/lib/commands/generic-transformers'; -export function transformArguments(key: string, item: string): Array { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments(key: RedisArgument, item: RedisArgument) { return ['CF.ADDNX', key, item]; -} - -export { transformBooleanReply as transformReply } from '@redis/client/dist/lib/commands/generic-transformers'; + }, + transformReply: transformBooleanReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/cuckoo/COUNT.spec.ts b/packages/bloom/lib/commands/cuckoo/COUNT.spec.ts index 29f5b41593..e3b53cd35a 100644 --- a/packages/bloom/lib/commands/cuckoo/COUNT.spec.ts +++ b/packages/bloom/lib/commands/cuckoo/COUNT.spec.ts @@ -1,19 +1,19 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './COUNT'; +import COUNT from './COUNT'; -describe('CF COUNT', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', 'item'), - ['CF.COUNT', 'key', 'item'] - ); - }); +describe('CF.COUNT', () => { + it('transformArguments', () => { + assert.deepEqual( + COUNT.transformArguments('key', 'item'), + ['CF.COUNT', 'key', 'item'] + ); + }); - testUtils.testWithClient('client.cf.count', async client => { - assert.equal( - await client.cf.count('key', 'item'), - 0 - ); - }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('client.cf.count', async client => { + assert.equal( + await client.cf.count('key', 'item'), + 0 + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/cuckoo/COUNT.ts b/packages/bloom/lib/commands/cuckoo/COUNT.ts index c9f3e28b38..2284edff17 100644 --- a/packages/bloom/lib/commands/cuckoo/COUNT.ts +++ b/packages/bloom/lib/commands/cuckoo/COUNT.ts @@ -1,7 +1,10 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types'; -export function transformArguments(key: string, item: string): Array { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments(key: RedisArgument, item: RedisArgument) { return ['CF.COUNT', key, item]; -} - -export declare function transformReply(): number; + }, + transformReply: undefined as unknown as () => NumberReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/cuckoo/DEL.spec.ts b/packages/bloom/lib/commands/cuckoo/DEL.spec.ts index 03da65881c..eddfe7298d 100644 --- a/packages/bloom/lib/commands/cuckoo/DEL.spec.ts +++ b/packages/bloom/lib/commands/cuckoo/DEL.spec.ts @@ -1,21 +1,21 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './DEL'; +import DEL from './DEL'; -describe('CF DEL', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', 'item'), - ['CF.DEL', 'key', 'item'] - ); - }); +describe('CF.DEL', () => { + it('transformArguments', () => { + assert.deepEqual( + DEL.transformArguments('key', 'item'), + ['CF.DEL', 'key', 'item'] + ); + }); - testUtils.testWithClient('client.cf.del', async client => { - await client.cf.reserve('key', 4); + testUtils.testWithClient('client.cf.del', async client => { + const [, reply] = await Promise.all([ + client.cf.reserve('key', 4), + client.cf.del('key', 'item') + ]); - assert.equal( - await client.cf.del('key', 'item'), - false - ); - }, GLOBAL.SERVERS.OPEN); + assert.equal(reply, false); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/cuckoo/DEL.ts b/packages/bloom/lib/commands/cuckoo/DEL.ts index 1c395a515a..55cefb4a05 100644 --- a/packages/bloom/lib/commands/cuckoo/DEL.ts +++ b/packages/bloom/lib/commands/cuckoo/DEL.ts @@ -1,7 +1,11 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types'; +import { transformBooleanReply } from '@redis/client/dist/lib/commands/generic-transformers'; -export function transformArguments(key: string, item: string): Array { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments(key: RedisArgument, item: RedisArgument) { return ['CF.DEL', key, item]; -} - -export { transformBooleanReply as transformReply } from '@redis/client/dist/lib/commands/generic-transformers'; + }, + transformReply: transformBooleanReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/cuckoo/EXISTS.spec.ts b/packages/bloom/lib/commands/cuckoo/EXISTS.spec.ts index e281bde6d8..08e3c522f4 100644 --- a/packages/bloom/lib/commands/cuckoo/EXISTS.spec.ts +++ b/packages/bloom/lib/commands/cuckoo/EXISTS.spec.ts @@ -1,19 +1,19 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './EXISTS'; +import EXISTS from './EXISTS'; -describe('CF EXISTS', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', 'item'), - ['CF.EXISTS', 'key', 'item'] - ); - }); +describe('CF.EXISTS', () => { + it('transformArguments', () => { + assert.deepEqual( + EXISTS.transformArguments('key', 'item'), + ['CF.EXISTS', 'key', 'item'] + ); + }); - testUtils.testWithClient('client.cf.exists', async client => { - assert.equal( - await client.cf.exists('key', 'item'), - false - ); - }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('client.cf.exists', async client => { + assert.equal( + await client.cf.exists('key', 'item'), + false + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/cuckoo/EXISTS.ts b/packages/bloom/lib/commands/cuckoo/EXISTS.ts index b50a1e25a8..1cb6b4df8f 100644 --- a/packages/bloom/lib/commands/cuckoo/EXISTS.ts +++ b/packages/bloom/lib/commands/cuckoo/EXISTS.ts @@ -1,9 +1,11 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types'; +import { transformBooleanReply } from '@redis/client/dist/lib/commands/generic-transformers'; -export const IS_READ_ONLY = true; - -export function transformArguments(key: string, item: string): Array { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments(key: RedisArgument, item: RedisArgument) { return ['CF.EXISTS', key, item]; -} - -export { transformBooleanReply as transformReply } from '@redis/client/dist/lib/commands/generic-transformers'; + }, + transformReply: transformBooleanReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/cuckoo/INFO.spec.ts b/packages/bloom/lib/commands/cuckoo/INFO.spec.ts index c2ac5de6fe..1663ed0c7c 100644 --- a/packages/bloom/lib/commands/cuckoo/INFO.spec.ts +++ b/packages/bloom/lib/commands/cuckoo/INFO.spec.ts @@ -1,27 +1,27 @@ -import { strict as assert } from 'assert'; -import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './INFO'; +// import { strict as assert } from 'assert'; +// import testUtils, { GLOBAL } from '../../test-utils'; +// import { transformArguments } from './INFO'; -describe('CF INFO', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('cuckoo'), - ['CF.INFO', 'cuckoo'] - ); - }); +// describe('CF INFO', () => { +// it('transformArguments', () => { +// assert.deepEqual( +// 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 => { +// await client.cf.reserve('key', 4); - 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); -}); +// 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); +// }); diff --git a/packages/bloom/lib/commands/cuckoo/INFO.ts b/packages/bloom/lib/commands/cuckoo/INFO.ts index 04d6954e37..be77430ae9 100644 --- a/packages/bloom/lib/commands/cuckoo/INFO.ts +++ b/packages/bloom/lib/commands/cuckoo/INFO.ts @@ -1,50 +1,50 @@ -export const FIRST_KEY_INDEX = 1; +// export const FIRST_KEY_INDEX = 1; -export const IS_READ_ONLY = true; +// export const IS_READ_ONLY = true; -export function transformArguments(key: string): Array { - return ['CF.INFO', key]; -} +// export function transformArguments(key: string): Array { +// return ['CF.INFO', key]; +// } -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 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 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] +// }; +// } diff --git a/packages/bloom/lib/commands/cuckoo/INSERT.spec.ts b/packages/bloom/lib/commands/cuckoo/INSERT.spec.ts index 9b56b86a6b..40571f34cb 100644 --- a/packages/bloom/lib/commands/cuckoo/INSERT.spec.ts +++ b/packages/bloom/lib/commands/cuckoo/INSERT.spec.ts @@ -1,22 +1,22 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './INSERT'; +import INSERT from './INSERT'; -describe('CF INSERT', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', 'item', { - CAPACITY: 100, - NOCREATE: true - }), - ['CF.INSERT', 'key', 'CAPACITY', '100', 'NOCREATE', 'ITEMS', 'item'] - ); - }); +describe('CF.INSERT', () => { + it('transformArguments', () => { + assert.deepEqual( + INSERT.transformArguments('key', 'item', { + CAPACITY: 100, + NOCREATE: true + }), + ['CF.INSERT', 'key', 'CAPACITY', '100', 'NOCREATE', 'ITEMS', 'item'] + ); + }); - testUtils.testWithClient('client.cf.insert', async client => { - assert.deepEqual( - await client.cf.insert('key', 'item'), - [true] - ); - }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('client.cf.insert', async client => { + assert.deepEqual( + await client.cf.insert('key', 'item'), + [true] + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/cuckoo/INSERT.ts b/packages/bloom/lib/commands/cuckoo/INSERT.ts index bcfd4f13a8..d6df64eea1 100644 --- a/packages/bloom/lib/commands/cuckoo/INSERT.ts +++ b/packages/bloom/lib/commands/cuckoo/INSERT.ts @@ -1,18 +1,34 @@ -import { RedisCommandArguments } from '@redis/client/dist/lib/commands'; -import { InsertOptions, pushInsertOptions } from "."; +import { Command, RedisArgument } from '@redis/client/dist/lib/RESP/types'; +import { RedisVariadicArgument, pushVariadicArguments, transformBooleanArrayReply } from '@redis/client/dist/lib/commands/generic-transformers'; -export const FIRST_KEY_INDEX = 1; - -export function transformArguments( - key: string, - items: string | Array, - options?: InsertOptions -): RedisCommandArguments { - return pushInsertOptions( - ['CF.INSERT', key], - items, - options - ); +export interface CfInsertOptions { + CAPACITY?: number; + NOCREATE?: boolean; } -export { transformBooleanArrayReply as transformReply } from '@redis/client/dist/lib/commands/generic-transformers'; +export function transofrmCfInsertArguments( + command: RedisArgument, + key: RedisArgument, + items: RedisVariadicArgument, + options?: CfInsertOptions +) { + const args = [command, key]; + + if (options?.CAPACITY !== undefined) { + args.push('CAPACITY', options.CAPACITY.toString()); + } + + if (options?.NOCREATE) { + args.push('NOCREATE'); + } + + args.push('ITEMS'); + return pushVariadicArguments(args, items); +} + +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments: transofrmCfInsertArguments.bind(undefined, 'CF.INSERT'), + transformReply: transformBooleanArrayReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/cuckoo/INSERTNX.spec.ts b/packages/bloom/lib/commands/cuckoo/INSERTNX.spec.ts index 7b1d974e5a..bca4f90546 100644 --- a/packages/bloom/lib/commands/cuckoo/INSERTNX.spec.ts +++ b/packages/bloom/lib/commands/cuckoo/INSERTNX.spec.ts @@ -1,22 +1,22 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './INSERTNX'; +import INSERTNX from './INSERTNX'; -describe('CF INSERTNX', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', 'item', { - CAPACITY: 100, - NOCREATE: true - }), - ['CF.INSERTNX', 'key', 'CAPACITY', '100', 'NOCREATE', 'ITEMS', 'item'] - ); - }); +describe('CF.INSERTNX', () => { + it('transformArguments', () => { + assert.deepEqual( + INSERTNX.transformArguments('key', 'item', { + CAPACITY: 100, + NOCREATE: true + }), + ['CF.INSERTNX', 'key', 'CAPACITY', '100', 'NOCREATE', 'ITEMS', 'item'] + ); + }); - testUtils.testWithClient('client.cf.insertnx', async client => { - assert.deepEqual( - await client.cf.insertNX('key', 'item'), - [true] - ); - }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('client.cf.insertnx', async client => { + assert.deepEqual( + await client.cf.insertNX('key', 'item'), + [true] + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/cuckoo/INSERTNX.ts b/packages/bloom/lib/commands/cuckoo/INSERTNX.ts index 17009e35a4..5cd56e794f 100644 --- a/packages/bloom/lib/commands/cuckoo/INSERTNX.ts +++ b/packages/bloom/lib/commands/cuckoo/INSERTNX.ts @@ -1,18 +1,9 @@ -import { RedisCommandArguments } from '@redis/client/dist/lib/commands'; -import { InsertOptions, pushInsertOptions } from "."; +import { Command } from '@redis/client/dist/lib/RESP/types'; +import INSERT, { transofrmCfInsertArguments } from './INSERT'; -export const FIRST_KEY_INDEX = 1; - -export function transformArguments( - key: string, - items: string | Array, - options?: InsertOptions -): RedisCommandArguments { - return pushInsertOptions( - ['CF.INSERTNX', key], - items, - options - ); -} - -export { transformBooleanArrayReply as transformReply } from '@redis/client/dist/lib/commands/generic-transformers'; +export default { + FIRST_KEY_INDEX: INSERT.FIRST_KEY_INDEX, + IS_READ_ONLY: INSERT.IS_READ_ONLY, + transformArguments: transofrmCfInsertArguments.bind(undefined, 'CF.INSERTNX'), + transformReply: INSERT.transformReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/cuckoo/LOADCHUNK.spec.ts b/packages/bloom/lib/commands/cuckoo/LOADCHUNK.spec.ts index ca3d6f2f8f..a2292d78bd 100644 --- a/packages/bloom/lib/commands/cuckoo/LOADCHUNK.spec.ts +++ b/packages/bloom/lib/commands/cuckoo/LOADCHUNK.spec.ts @@ -1,31 +1,36 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './LOADCHUNK'; +import LOADCHUNK from './LOADCHUNK'; +import { RESP_TYPES } from '@redis/client'; -describe('CF LOADCHUNK', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('item', 0, ''), - ['CF.LOADCHUNK', 'item', '0', ''] - ); - }); +describe('CF.LOADCHUNK', () => { + it('transformArguments', () => { + assert.deepEqual( + LOADCHUNK.transformArguments('item', 0, ''), + ['CF.LOADCHUNK', 'item', '0', ''] + ); + }); - testUtils.testWithClient('client.cf.loadChunk', async client => { - const [,, { iterator, chunk }] = await Promise.all([ - client.cf.reserve('source', 4), - client.cf.add('source', 'item'), - client.cf.scanDump( - client.commandOptions({ returnBuffers: true }), - 'source', - 0 - ) - ]); + testUtils.testWithClient('client.cf.loadChunk', async client => { + const [, , { iterator, chunk }] = await Promise.all([ + client.cf.reserve('source', 4), + client.cf.add('source', 'item'), + client.cf.scanDump('source', 0) + ]); - assert.ok(Buffer.isBuffer(chunk)); - - assert.equal( - await client.cf.loadChunk('destination', iterator, chunk), - 'OK' - ); - }, GLOBAL.SERVERS.OPEN); + assert.equal( + await client.cf.loadChunk('destination', iterator, chunk), + 'OK' + ); + }, { + ...GLOBAL.SERVERS.OPEN, + clientOptions: { + ...GLOBAL.SERVERS.OPEN.clientOptions, + commandOptions: { + typeMapping: { + [RESP_TYPES.BLOB_STRING]: Buffer + } + } + } + }); }); diff --git a/packages/bloom/lib/commands/cuckoo/LOADCHUNK.ts b/packages/bloom/lib/commands/cuckoo/LOADCHUNK.ts index 6d960c014e..08cb749b59 100644 --- a/packages/bloom/lib/commands/cuckoo/LOADCHUNK.ts +++ b/packages/bloom/lib/commands/cuckoo/LOADCHUNK.ts @@ -1,13 +1,10 @@ -import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; +import { SimpleStringReply, Command, RedisArgument } from '@redis/client/dist/lib/RESP/types'; -export const FIRST_KEY_INDEX = 1; - -export function transformArguments( - key: string, - iterator: number, - chunk: RedisCommandArgument -): RedisCommandArguments { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments(key: RedisArgument, iterator: number, chunk: RedisArgument) { return ['CF.LOADCHUNK', key, iterator.toString(), chunk]; -} - -export declare function transformReply(): 'OK'; + }, + transformReply: undefined as unknown as () => SimpleStringReply<'OK'> +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/cuckoo/RESERVE.spec.ts b/packages/bloom/lib/commands/cuckoo/RESERVE.spec.ts index 3145a222c5..ee4d56af48 100644 --- a/packages/bloom/lib/commands/cuckoo/RESERVE.spec.ts +++ b/packages/bloom/lib/commands/cuckoo/RESERVE.spec.ts @@ -1,48 +1,48 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './RESERVE'; +import RESERVE from './RESERVE'; -describe('CF RESERVE', () => { - describe('transformArguments', () => { - it('simple', () => { - assert.deepEqual( - transformArguments('key', 4), - ['CF.RESERVE', 'key', '4'] - ); - }); - - it('with EXPANSION', () => { - assert.deepEqual( - transformArguments('key', 4, { - EXPANSION: 1 - }), - ['CF.RESERVE', 'key', '4', 'EXPANSION', '1'] - ); - }); - - it('with BUCKETSIZE', () => { - assert.deepEqual( - transformArguments('key', 4, { - BUCKETSIZE: 2 - }), - ['CF.RESERVE', 'key', '4', 'BUCKETSIZE', '2'] - ); - }); - - it('with MAXITERATIONS', () => { - assert.deepEqual( - transformArguments('key', 4, { - MAXITERATIONS: 1 - }), - ['CF.RESERVE', 'key', '4', 'MAXITERATIONS', '1'] - ); - }); +describe('CF.RESERVE', () => { + describe('transformArguments', () => { + it('simple', () => { + assert.deepEqual( + RESERVE.transformArguments('key', 4), + ['CF.RESERVE', 'key', '4'] + ); }); - testUtils.testWithClient('client.cf.reserve', async client => { - assert.equal( - await client.cf.reserve('key', 4), - 'OK' - ); - }, GLOBAL.SERVERS.OPEN); + it('with EXPANSION', () => { + assert.deepEqual( + RESERVE.transformArguments('key', 4, { + EXPANSION: 1 + }), + ['CF.RESERVE', 'key', '4', 'EXPANSION', '1'] + ); + }); + + it('with BUCKETSIZE', () => { + assert.deepEqual( + RESERVE.transformArguments('key', 4, { + BUCKETSIZE: 2 + }), + ['CF.RESERVE', 'key', '4', 'BUCKETSIZE', '2'] + ); + }); + + it('with MAXITERATIONS', () => { + assert.deepEqual( + RESERVE.transformArguments('key', 4, { + MAXITERATIONS: 1 + }), + ['CF.RESERVE', 'key', '4', 'MAXITERATIONS', '1'] + ); + }); + }); + + testUtils.testWithClient('client.cf.reserve', async client => { + assert.equal( + await client.cf.reserve('key', 4), + 'OK' + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/cuckoo/RESERVE.ts b/packages/bloom/lib/commands/cuckoo/RESERVE.ts index 114c1fdf44..bc80daa008 100644 --- a/packages/bloom/lib/commands/cuckoo/RESERVE.ts +++ b/packages/bloom/lib/commands/cuckoo/RESERVE.ts @@ -1,31 +1,34 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types'; -interface ReserveOptions { - BUCKETSIZE?: number; - MAXITERATIONS?: number; - EXPANSION?: number; +export interface CfReserveOptions { + BUCKETSIZE?: number; + MAXITERATIONS?: number; + EXPANSION?: number; } -export function transformArguments( - key: string, +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments( + key: RedisArgument, capacity: number, - options?: ReserveOptions -): Array { + options?: CfReserveOptions + ) { const args = ['CF.RESERVE', key, capacity.toString()]; - if (options?.BUCKETSIZE) { - args.push('BUCKETSIZE', options.BUCKETSIZE.toString()); + if (options?.BUCKETSIZE !== undefined) { + args.push('BUCKETSIZE', options.BUCKETSIZE.toString()); } - if (options?.MAXITERATIONS) { - args.push('MAXITERATIONS', options.MAXITERATIONS.toString()); + if (options?.MAXITERATIONS !== undefined) { + args.push('MAXITERATIONS', options.MAXITERATIONS.toString()); } - if (options?.EXPANSION) { - args.push('EXPANSION', options.EXPANSION.toString()); + if (options?.EXPANSION !== undefined) { + args.push('EXPANSION', options.EXPANSION.toString()); } return args; -} - -export declare function transformReply(): 'OK'; + }, + transformReply: undefined as unknown as () => SimpleStringReply<'OK'> +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/cuckoo/SCANDUMP.spec.ts b/packages/bloom/lib/commands/cuckoo/SCANDUMP.spec.ts index ec269c62aa..e84142b4ae 100644 --- a/packages/bloom/lib/commands/cuckoo/SCANDUMP.spec.ts +++ b/packages/bloom/lib/commands/cuckoo/SCANDUMP.spec.ts @@ -1,23 +1,24 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './SCANDUMP'; +import SCANDUMP from './SCANDUMP'; -describe('CF SCANDUMP', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', 0), - ['CF.SCANDUMP', 'key', '0'] - ); +describe('CF.SCANDUMP', () => { + it('transformArguments', () => { + assert.deepEqual( + SCANDUMP.transformArguments('key', 0), + ['CF.SCANDUMP', 'key', '0'] + ); + }); + + testUtils.testWithClient('client.cf.scanDump', async client => { + const [, reply] = await Promise.all([ + client.cf.reserve('key', 4), + client.cf.scanDump('key', 0) + ]); + + assert.deepEqual(reply, { + iterator: 0, + chunk: null }); - - testUtils.testWithClient('client.cf.scanDump', async client => { - await client.cf.reserve('key', 4); - assert.deepEqual( - await client.cf.scanDump('key', 0), - { - iterator: 0, - chunk: null - } - ); - }, GLOBAL.SERVERS.OPEN); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/cuckoo/SCANDUMP.ts b/packages/bloom/lib/commands/cuckoo/SCANDUMP.ts index 91476b49a7..af33315750 100644 --- a/packages/bloom/lib/commands/cuckoo/SCANDUMP.ts +++ b/packages/bloom/lib/commands/cuckoo/SCANDUMP.ts @@ -1,22 +1,15 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, TuplesReply, NumberReply, BlobStringReply, NullReply, Command } from '@redis/client/dist/lib/RESP/types'; -export function transformArguments(key: string, iterator: number): Array { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments(key: RedisArgument, iterator: number) { return ['CF.SCANDUMP', key, iterator.toString()]; -} - -type ScanDumpRawReply = [ - iterator: number, - chunk: string | null -]; - -interface ScanDumpReply { - iterator: number; - chunk: string | null; -} - -export function transformReply([iterator, chunk]: ScanDumpRawReply): ScanDumpReply { + }, + transformReply(reply: TuplesReply<[NumberReply, BlobStringReply | NullReply]>) { return { - iterator, - chunk + iterator: reply[0], + chunk: reply[1] }; -} + } +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/cuckoo/index.spec.ts b/packages/bloom/lib/commands/cuckoo/index.spec.ts deleted file mode 100644 index 94f3a0ae28..0000000000 --- a/packages/bloom/lib/commands/cuckoo/index.spec.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { strict as assert } from 'assert'; -import { pushInsertOptions } from '.'; - -describe('pushInsertOptions', () => { - describe('single item', () => { - it('single item', () => { - assert.deepEqual( - pushInsertOptions([], 'item'), - ['ITEMS', 'item'] - ); - }); - - it('multiple items', () => { - assert.deepEqual( - pushInsertOptions([], ['1', '2']), - ['ITEMS', '1', '2'] - ); - }); - }); - - it('with CAPACITY', () => { - assert.deepEqual( - pushInsertOptions([], 'item', { - CAPACITY: 100 - }), - ['CAPACITY', '100', 'ITEMS', 'item'] - ); - }); - - it('with NOCREATE', () => { - assert.deepEqual( - pushInsertOptions([], 'item', { - NOCREATE: true - }), - ['NOCREATE', 'ITEMS', 'item'] - ); - }); - - it('with CAPACITY and NOCREATE', () => { - assert.deepEqual( - pushInsertOptions([], 'item', { - CAPACITY: 100, - NOCREATE: true - }), - ['CAPACITY', '100', 'NOCREATE', 'ITEMS', 'item'] - ); - }); -}); diff --git a/packages/bloom/lib/commands/cuckoo/index.ts b/packages/bloom/lib/commands/cuckoo/index.ts index c34bdde503..f8eaed9305 100644 --- a/packages/bloom/lib/commands/cuckoo/index.ts +++ b/packages/bloom/lib/commands/cuckoo/index.ts @@ -1,62 +1,37 @@ - -import * as ADD from './ADD'; -import * as ADDNX from './ADDNX'; -import * as COUNT from './COUNT'; -import * as DEL from './DEL'; -import * as EXISTS from './EXISTS'; -import * as INFO from './INFO'; -import * as INSERT from './INSERT'; -import * as INSERTNX from './INSERTNX'; -import * as LOADCHUNK from './LOADCHUNK'; -import * as RESERVE from './RESERVE'; -import * as SCANDUMP from './SCANDUMP'; -import { pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers'; -import { RedisCommandArguments } from '@redis/client/dist/lib/commands'; +import type { RedisCommands } from '@redis/client/dist/lib/RESP/types'; +import ADD from './ADD'; +import ADDNX from './ADDNX'; +import COUNT from './COUNT'; +import DEL from './DEL'; +import EXISTS from './EXISTS'; +// import INFO from './INFO'; +import INSERT from './INSERT'; +import INSERTNX from './INSERTNX'; +import LOADCHUNK from './LOADCHUNK'; +import RESERVE from './RESERVE'; +import SCANDUMP from './SCANDUMP'; export default { - ADD, - add: ADD, - ADDNX, - addNX: ADDNX, - COUNT, - count: COUNT, - DEL, - del: DEL, - EXISTS, - exists: EXISTS, - INFO, - info: INFO, - INSERT, - insert: INSERT, - INSERTNX, - insertNX: INSERTNX, - LOADCHUNK, - loadChunk: LOADCHUNK, - RESERVE, - reserve: RESERVE, - SCANDUMP, - scanDump: SCANDUMP -}; - -export interface InsertOptions { - CAPACITY?: number; - NOCREATE?: true; -} - -export function pushInsertOptions( - args: RedisCommandArguments, - items: string | Array, - options?: InsertOptions -): RedisCommandArguments { - if (options?.CAPACITY) { - args.push('CAPACITY'); - args.push(options.CAPACITY.toString()); - } - - if (options?.NOCREATE) { - args.push('NOCREATE'); - } - - args.push('ITEMS'); - return pushVariadicArguments(args, items); -} + ADD, + add: ADD, + ADDNX, + addNX: ADDNX, + COUNT, + count: COUNT, + DEL, + del: DEL, + EXISTS, + exists: EXISTS, + // INFO, + // info: INFO, + INSERT, + insert: INSERT, + INSERTNX, + insertNX: INSERTNX, + LOADCHUNK, + loadChunk: LOADCHUNK, + RESERVE, + reserve: RESERVE, + SCANDUMP, + scanDump: SCANDUMP +} as const satisfies RedisCommands; diff --git a/packages/bloom/lib/commands/index.ts b/packages/bloom/lib/commands/index.ts index cea55b2a7c..6f91089460 100644 --- a/packages/bloom/lib/commands/index.ts +++ b/packages/bloom/lib/commands/index.ts @@ -1,3 +1,4 @@ +import { RedisModules } from '@redis/client'; import bf from './bloom'; import cms from './count-min-sketch'; import cf from './cuckoo'; @@ -5,9 +6,9 @@ import tDigest from './t-digest'; import topK from './top-k'; export default { - bf, - cms, - cf, - tDigest, - topK -}; + bf, + cms, + cf, + tDigest, + topK +} as const satisfies RedisModules; diff --git a/packages/bloom/lib/commands/t-digest/ADD.spec.ts b/packages/bloom/lib/commands/t-digest/ADD.spec.ts index 3e1dbff7f2..e77d67cba2 100644 --- a/packages/bloom/lib/commands/t-digest/ADD.spec.ts +++ b/packages/bloom/lib/commands/t-digest/ADD.spec.ts @@ -1,21 +1,21 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './ADD'; +import ADD from './ADD'; describe('TDIGEST.ADD', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', [1, 2]), - ['TDIGEST.ADD', 'key', '1', '2'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + ADD.transformArguments('key', [1, 2]), + ['TDIGEST.ADD', 'key', '1', '2'] + ); + }); - testUtils.testWithClient('client.tDigest.add', async client => { - const [ , reply ] = await Promise.all([ - client.tDigest.create('key'), - client.tDigest.add('key', [1]) - ]); + testUtils.testWithClient('client.tDigest.add', async client => { + const [, reply] = await Promise.all([ + client.tDigest.create('key'), + client.tDigest.add('key', [1]) + ]); - assert.equal(reply, 'OK'); - }, GLOBAL.SERVERS.OPEN); + assert.equal(reply, 'OK'); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/t-digest/ADD.ts b/packages/bloom/lib/commands/t-digest/ADD.ts index 941e853100..e7c6d7c442 100644 --- a/packages/bloom/lib/commands/t-digest/ADD.ts +++ b/packages/bloom/lib/commands/t-digest/ADD.ts @@ -1,17 +1,16 @@ -import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; +import { SimpleStringReply, Command, RedisArgument } from '@redis/client/dist/lib/RESP/types'; -export const FIRST_KEY_INDEX = 1; - -export function transformArguments( - key: RedisCommandArgument, - values: Array -): RedisCommandArguments { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments(key: RedisArgument, values: Array) { const args = ['TDIGEST.ADD', key]; - for (const item of values) { - args.push(item.toString()); + + for (const value of values) { + args.push(value.toString()); } return args; -} - -export declare function transformReply(): 'OK'; + }, + transformReply: undefined as unknown as () => SimpleStringReply<'OK'> +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/t-digest/BYRANK.spec.ts b/packages/bloom/lib/commands/t-digest/BYRANK.spec.ts index 083f09d22a..d6e31f59b4 100644 --- a/packages/bloom/lib/commands/t-digest/BYRANK.spec.ts +++ b/packages/bloom/lib/commands/t-digest/BYRANK.spec.ts @@ -1,21 +1,21 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './BYRANK'; +import BYRANK from './BYRANK'; describe('TDIGEST.BYRANK', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', [1, 2]), - ['TDIGEST.BYRANK', 'key', '1', '2'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + BYRANK.transformArguments('key', [1, 2]), + ['TDIGEST.BYRANK', 'key', '1', '2'] + ); + }); - testUtils.testWithClient('client.tDigest.byRank', async client => { - const [ , reply ] = await Promise.all([ - client.tDigest.create('key'), - client.tDigest.byRank('key', [1]) - ]); + testUtils.testWithClient('client.tDigest.byRank', async client => { + const [, reply] = await Promise.all([ + client.tDigest.create('key'), + client.tDigest.byRank('key', [1]) + ]); - assert.deepEqual(reply, [NaN]); - }, GLOBAL.SERVERS.OPEN); + assert.deepEqual(reply, [NaN]); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/t-digest/BYRANK.ts b/packages/bloom/lib/commands/t-digest/BYRANK.ts index 5684385b4d..8b48acd1b1 100644 --- a/packages/bloom/lib/commands/t-digest/BYRANK.ts +++ b/packages/bloom/lib/commands/t-digest/BYRANK.ts @@ -1,19 +1,24 @@ -import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; +import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types'; +import { transformDoubleArrayReply } from '@redis/client/dist/lib/commands/generic-transformers'; -export const FIRST_KEY_INDEX = 1; +export function transformByRankArguments( + command: RedisArgument, + key: RedisArgument, + ranks: Array +) { + const args = [command, key]; -export const IS_READ_ONLY = true; + for (const rank of ranks) { + args.push(rank.toString()); + } -export function transformArguments( - key: RedisCommandArgument, - ranks: Array -): RedisCommandArguments { - const args = ['TDIGEST.BYRANK', key]; - for (const rank of ranks) { - args.push(rank.toString()); - } - - return args; + return args; } -export { transformDoublesReply as transformReply } from '.'; +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments: transformByRankArguments.bind(undefined, 'TDIGEST.BYRANK'), + transformReply: transformDoubleArrayReply +} as const satisfies Command; + diff --git a/packages/bloom/lib/commands/t-digest/BYREVRANK.spec.ts b/packages/bloom/lib/commands/t-digest/BYREVRANK.spec.ts index c094f36e71..7549ea870c 100644 --- a/packages/bloom/lib/commands/t-digest/BYREVRANK.spec.ts +++ b/packages/bloom/lib/commands/t-digest/BYREVRANK.spec.ts @@ -1,21 +1,21 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './BYREVRANK'; +import BYREVRANK from './BYREVRANK'; describe('TDIGEST.BYREVRANK', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', [1, 2]), - ['TDIGEST.BYREVRANK', 'key', '1', '2'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + BYREVRANK.transformArguments('key', [1, 2]), + ['TDIGEST.BYREVRANK', 'key', '1', '2'] + ); + }); - testUtils.testWithClient('client.tDigest.byRevRank', async client => { - const [ , reply ] = await Promise.all([ - client.tDigest.create('key'), - client.tDigest.byRevRank('key', [1]) - ]); + testUtils.testWithClient('client.tDigest.byRevRank', async client => { + const [, reply] = await Promise.all([ + client.tDigest.create('key'), + client.tDigest.byRevRank('key', [1]) + ]); - assert.deepEqual(reply, [NaN]); - }, GLOBAL.SERVERS.OPEN); + assert.deepEqual(reply, [NaN]); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/t-digest/BYREVRANK.ts b/packages/bloom/lib/commands/t-digest/BYREVRANK.ts index 3dcf3a973c..9f62b42d81 100644 --- a/packages/bloom/lib/commands/t-digest/BYREVRANK.ts +++ b/packages/bloom/lib/commands/t-digest/BYREVRANK.ts @@ -1,19 +1,9 @@ -import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; +import { Command } from '@redis/client/dist/lib/RESP/types'; +import BYRANK, { transformByRankArguments } from './BYRANK'; -export const FIRST_KEY_INDEX = 1; - -export const IS_READ_ONLY = true; - -export function transformArguments( - key: RedisCommandArgument, - ranks: Array -): RedisCommandArguments { - const args = ['TDIGEST.BYREVRANK', key]; - for (const rank of ranks) { - args.push(rank.toString()); - } - - return args; -} - -export { transformDoublesReply as transformReply } from '.'; +export default { + FIRST_KEY_INDEX: BYRANK.FIRST_KEY_INDEX, + IS_READ_ONLY: BYRANK.IS_READ_ONLY, + transformArguments: transformByRankArguments.bind(undefined, 'TDIGEST.BYREVRANK'), + transformReply: BYRANK.transformReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/t-digest/CDF.spec.ts b/packages/bloom/lib/commands/t-digest/CDF.spec.ts index 36d3564f62..7ba56ccda6 100644 --- a/packages/bloom/lib/commands/t-digest/CDF.spec.ts +++ b/packages/bloom/lib/commands/t-digest/CDF.spec.ts @@ -1,21 +1,21 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './CDF'; +import CDF from './CDF'; describe('TDIGEST.CDF', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', [1, 2]), - ['TDIGEST.CDF', 'key', '1', '2'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + CDF.transformArguments('key', [1, 2]), + ['TDIGEST.CDF', 'key', '1', '2'] + ); + }); - testUtils.testWithClient('client.tDigest.cdf', async client => { - const [ , reply ] = await Promise.all([ - client.tDigest.create('key'), - client.tDigest.cdf('key', [1]) - ]); + testUtils.testWithClient('client.tDigest.cdf', async client => { + const [, reply] = await Promise.all([ + client.tDigest.create('key'), + client.tDigest.cdf('key', [1]) + ]); - assert.deepEqual(reply, [NaN]); - }, GLOBAL.SERVERS.OPEN); + assert.deepEqual(reply, [NaN]); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/t-digest/CDF.ts b/packages/bloom/lib/commands/t-digest/CDF.ts index fe7ece59d7..0fbdedb3a4 100644 --- a/packages/bloom/lib/commands/t-digest/CDF.ts +++ b/packages/bloom/lib/commands/t-digest/CDF.ts @@ -1,19 +1,17 @@ -import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; +import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types'; +import { transformDoubleArrayReply } from '@redis/client/dist/lib/commands/generic-transformers'; -export const FIRST_KEY_INDEX = 1; - -export const IS_READ_ONLY = true; - -export function transformArguments( - key: RedisCommandArgument, - values: Array -): RedisCommandArguments { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments(key: RedisArgument, values: Array) { const args = ['TDIGEST.CDF', key]; + for (const item of values) { - args.push(item.toString()); + args.push(item.toString()); } return args; -} - -export { transformDoublesReply as transformReply } from '.'; + }, + transformReply: transformDoubleArrayReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/t-digest/CREATE.spec.ts b/packages/bloom/lib/commands/t-digest/CREATE.spec.ts index 4d329cc81a..f731241ab3 100644 --- a/packages/bloom/lib/commands/t-digest/CREATE.spec.ts +++ b/packages/bloom/lib/commands/t-digest/CREATE.spec.ts @@ -1,30 +1,30 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './CREATE'; +import CREATE from './CREATE'; describe('TDIGEST.CREATE', () => { - describe('transformArguments', () => { - it('without options', () => { - assert.deepEqual( - transformArguments('key'), - ['TDIGEST.CREATE', 'key'] - ); - }); - - it('with COMPRESSION', () => { - assert.deepEqual( - transformArguments('key', { - COMPRESSION: 100 - }), - ['TDIGEST.CREATE', 'key', 'COMPRESSION', '100'] - ); - }); + describe('transformArguments', () => { + it('without options', () => { + assert.deepEqual( + CREATE.transformArguments('key'), + ['TDIGEST.CREATE', 'key'] + ); }); - testUtils.testWithClient('client.tDigest.create', async client => { - assert.equal( - await client.tDigest.create('key'), - 'OK' - ); - }, GLOBAL.SERVERS.OPEN); + it('with COMPRESSION', () => { + assert.deepEqual( + CREATE.transformArguments('key', { + COMPRESSION: 100 + }), + ['TDIGEST.CREATE', 'key', 'COMPRESSION', '100'] + ); + }); + }); + + testUtils.testWithClient('client.tDigest.create', async client => { + assert.equal( + await client.tDigest.create('key'), + 'OK' + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/t-digest/CREATE.ts b/packages/bloom/lib/commands/t-digest/CREATE.ts index 1935d2973d..8b832487da 100644 --- a/packages/bloom/lib/commands/t-digest/CREATE.ts +++ b/packages/bloom/lib/commands/t-digest/CREATE.ts @@ -1,16 +1,20 @@ -import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; -import { CompressionOption, pushCompressionArgument } from '.'; +import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types'; -export const FIRST_KEY_INDEX = 1; - -export function transformArguments( - key: RedisCommandArgument, - options?: CompressionOption -): RedisCommandArguments { - return pushCompressionArgument( - ['TDIGEST.CREATE', key], - options - ); +export interface TDigestCreateOptions { + COMPRESSION?: number; } -export declare function transformReply(): 'OK'; +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments(key: RedisArgument, options?: TDigestCreateOptions) { + const args = ['TDIGEST.CREATE', key]; + + if (options?.COMPRESSION !== undefined) { + args.push('COMPRESSION', options.COMPRESSION.toString()); + } + + return args; + }, + transformReply: undefined as unknown as () => SimpleStringReply<'OK'> +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/t-digest/INFO.spec.ts b/packages/bloom/lib/commands/t-digest/INFO.spec.ts index 992fda6ea0..b3aa1281cd 100644 --- a/packages/bloom/lib/commands/t-digest/INFO.spec.ts +++ b/packages/bloom/lib/commands/t-digest/INFO.spec.ts @@ -1,25 +1,25 @@ -import { strict as assert } from 'assert'; -import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './INFO'; +// import { strict as assert } from 'assert'; +// import testUtils, { GLOBAL } from '../../test-utils'; +// import { transformArguments } from './INFO'; -describe('TDIGEST.INFO', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key'), - ['TDIGEST.INFO', 'key'] - ); - }); +// describe('TDIGEST.INFO', () => { +// it('transformArguments', () => { +// assert.deepEqual( +// transformArguments('key'), +// ['TDIGEST.INFO', 'key'] +// ); +// }); - testUtils.testWithClient('client.tDigest.info', async client => { - await client.tDigest.create('key'); +// testUtils.testWithClient('client.tDigest.info', async client => { +// await client.tDigest.create('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); -}); +// 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); +// }); diff --git a/packages/bloom/lib/commands/t-digest/INFO.ts b/packages/bloom/lib/commands/t-digest/INFO.ts index 44d2083524..7830f71f9d 100644 --- a/packages/bloom/lib/commands/t-digest/INFO.ts +++ b/packages/bloom/lib/commands/t-digest/INFO.ts @@ -1,51 +1,51 @@ -import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; +// import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; -export const FIRST_KEY_INDEX = 1; +// export const FIRST_KEY_INDEX = 1; -export const IS_READ_ONLY = true; +// export const IS_READ_ONLY = true; -export function transformArguments(key: RedisCommandArgument): RedisCommandArguments { - return [ - 'TDIGEST.INFO', - key - ]; -} +// 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 -]; +// 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; -} +// 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] +// }; +// } \ No newline at end of file diff --git a/packages/bloom/lib/commands/t-digest/MAX.spec.ts b/packages/bloom/lib/commands/t-digest/MAX.spec.ts index bf850cbfd8..cd6fc6517d 100644 --- a/packages/bloom/lib/commands/t-digest/MAX.spec.ts +++ b/packages/bloom/lib/commands/t-digest/MAX.spec.ts @@ -1,21 +1,21 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments, transformReply } from './MAX'; +import MAX from './MAX'; describe('TDIGEST.MAX', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key'), - ['TDIGEST.MAX', 'key'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + MAX.transformArguments('key'), + ['TDIGEST.MAX', 'key'] + ); + }); - testUtils.testWithClient('client.tDigest.max', async client => { - const [ , reply ] = await Promise.all([ - client.tDigest.create('key'), - client.tDigest.max('key') - ]); + testUtils.testWithClient('client.tDigest.max', async client => { + const [, reply] = await Promise.all([ + client.tDigest.create('key'), + client.tDigest.max('key') + ]); - assert.deepEqual(reply, NaN); - }, GLOBAL.SERVERS.OPEN); + assert.deepEqual(reply, NaN); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/t-digest/MAX.ts b/packages/bloom/lib/commands/t-digest/MAX.ts index 90c42ec606..ef778f832a 100644 --- a/packages/bloom/lib/commands/t-digest/MAX.ts +++ b/packages/bloom/lib/commands/t-digest/MAX.ts @@ -1,14 +1,11 @@ -import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; +import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types'; +import { transformDoubleReply } from '@redis/client/dist/lib/commands/generic-transformers'; -export const FIRST_KEY_INDEX = 1; - -export const IS_READ_ONLY = true; - -export function transformArguments(key: RedisCommandArgument): RedisCommandArguments { - return [ - 'TDIGEST.MAX', - key - ]; -} - -export { transformDoubleReply as transformReply } from '.'; +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments(key: RedisArgument) { + return ['TDIGEST.MAX', key]; + }, + transformReply: transformDoubleReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/t-digest/MERGE.spec.ts b/packages/bloom/lib/commands/t-digest/MERGE.spec.ts index 1205cdd921..a20bf4626d 100644 --- a/packages/bloom/lib/commands/t-digest/MERGE.spec.ts +++ b/packages/bloom/lib/commands/t-digest/MERGE.spec.ts @@ -1,50 +1,50 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments, transformReply } from './MERGE'; +import MERGE from './MERGE'; describe('TDIGEST.MERGE', () => { - describe('transformArguments', () => { - describe('srcKeys', () => { - it('string', () => { - assert.deepEqual( - transformArguments('dest', 'src'), - ['TDIGEST.MERGE', 'dest', '1', 'src'] - ); - }); + describe('transformArguments', () => { + describe('source', () => { + it('string', () => { + assert.deepEqual( + MERGE.transformArguments('destination', 'source'), + ['TDIGEST.MERGE', 'destination', '1', 'source'] + ); + }); - it('Array', () => { - assert.deepEqual( - transformArguments('dest', ['1', '2']), - ['TDIGEST.MERGE', 'dest', '2', '1', '2'] - ); - }); - }); - - it('with COMPRESSION', () => { - assert.deepEqual( - transformArguments('dest', 'src', { - COMPRESSION: 100 - }), - ['TDIGEST.MERGE', 'dest', '1', 'src', 'COMPRESSION', '100'] - ); - }); - - it('with OVERRIDE', () => { - assert.deepEqual( - transformArguments('dest', 'src', { - OVERRIDE: true - }), - ['TDIGEST.MERGE', 'dest', '1', 'src', 'OVERRIDE'] - ); - }); + it('Array', () => { + assert.deepEqual( + MERGE.transformArguments('destination', ['1', '2']), + ['TDIGEST.MERGE', 'destination', '2', '1', '2'] + ); + }); }); - testUtils.testWithClient('client.tDigest.merge', async client => { - const [ , reply ] = await Promise.all([ - client.tDigest.create('src'), - client.tDigest.merge('dest', 'src') - ]); + it('with COMPRESSION', () => { + assert.deepEqual( + MERGE.transformArguments('destination', 'source', { + COMPRESSION: 100 + }), + ['TDIGEST.MERGE', 'destination', '1', 'source', 'COMPRESSION', '100'] + ); + }); - assert.equal(reply, 'OK'); - }, GLOBAL.SERVERS.OPEN); + it('with OVERRIDE', () => { + assert.deepEqual( + MERGE.transformArguments('destination', 'source', { + OVERRIDE: true + }), + ['TDIGEST.MERGE', 'destination', '1', 'source', 'OVERRIDE'] + ); + }); + }); + + testUtils.testWithClient('client.tDigest.merge', async client => { + const [, reply] = await Promise.all([ + client.tDigest.create('source'), + client.tDigest.merge('destination', 'source') + ]); + + assert.equal(reply, 'OK'); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/t-digest/MERGE.ts b/packages/bloom/lib/commands/t-digest/MERGE.ts index 1aebe6fa47..e9cd99aabf 100644 --- a/packages/bloom/lib/commands/t-digest/MERGE.ts +++ b/packages/bloom/lib/commands/t-digest/MERGE.ts @@ -1,30 +1,30 @@ -import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; -import { pushVariadicArgument } from '@redis/client/dist/lib/commands/generic-transformers'; -import { CompressionOption, pushCompressionArgument } from '.'; +import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types'; +import { RedisVariadicArgument, pushVariadicArgument } from '@redis/client/dist/lib/commands/generic-transformers'; -export const FIRST_KEY_INDEX = 1; - -interface MergeOptions extends CompressionOption { - OVERRIDE?: boolean; +export interface TDigestMergeOptions { + COMPRESSION?: number; + OVERRIDE?: boolean; } -export function transformArguments( - destKey: RedisCommandArgument, - srcKeys: RedisCommandArgument | Array, - options?: MergeOptions -): RedisCommandArguments { - const args = pushVariadicArgument( - ['TDIGEST.MERGE', destKey], - srcKeys - ); +export default { + FIRST_KEY_INDEX: undefined, + IS_READ_ONLY: false, + transformArguments( + destination: RedisArgument, + source: RedisVariadicArgument, + options?: TDigestMergeOptions + ) { + const args = pushVariadicArgument(['TDIGEST.MERGE', destination], source); - pushCompressionArgument(args, options); + if (options?.COMPRESSION !== undefined) { + args.push('COMPRESSION', options.COMPRESSION.toString()); + } if (options?.OVERRIDE) { - args.push('OVERRIDE'); + args.push('OVERRIDE'); } return args; -} - -export declare function transformReply(): 'OK'; + }, + transformReply: undefined as unknown as () => SimpleStringReply<'OK'> +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/t-digest/MIN.spec.ts b/packages/bloom/lib/commands/t-digest/MIN.spec.ts index d48deaca7f..7fac680558 100644 --- a/packages/bloom/lib/commands/t-digest/MIN.spec.ts +++ b/packages/bloom/lib/commands/t-digest/MIN.spec.ts @@ -1,21 +1,21 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments, transformReply } from './MIN'; +import MIN from './MIN'; describe('TDIGEST.MIN', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key'), - ['TDIGEST.MIN', 'key'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + MIN.transformArguments('key'), + ['TDIGEST.MIN', 'key'] + ); + }); - testUtils.testWithClient('client.tDigest.min', async client => { - const [ , reply ] = await Promise.all([ - client.tDigest.create('key'), - client.tDigest.min('key') - ]); + testUtils.testWithClient('client.tDigest.min', async client => { + const [, reply] = await Promise.all([ + client.tDigest.create('key'), + client.tDigest.min('key') + ]); - assert.equal(reply, NaN); - }, GLOBAL.SERVERS.OPEN); + assert.equal(reply, NaN); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/t-digest/MIN.ts b/packages/bloom/lib/commands/t-digest/MIN.ts index d8be8722b6..914998a1ec 100644 --- a/packages/bloom/lib/commands/t-digest/MIN.ts +++ b/packages/bloom/lib/commands/t-digest/MIN.ts @@ -1,14 +1,11 @@ -import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; +import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types'; +import { transformDoubleReply } from '@redis/client/dist/lib/commands/generic-transformers'; -export const FIRST_KEY_INDEX = 1; - -export const IS_READ_ONLY = true; - -export function transformArguments(key: RedisCommandArgument): RedisCommandArguments { - return [ - 'TDIGEST.MIN', - key - ]; -} - -export { transformDoubleReply as transformReply } from '.'; +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments(key: RedisArgument) { + return ['TDIGEST.MIN', key]; + }, + transformReply: transformDoubleReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/t-digest/QUANTILE.spec.ts b/packages/bloom/lib/commands/t-digest/QUANTILE.spec.ts index 7790debf0d..7d96d5c919 100644 --- a/packages/bloom/lib/commands/t-digest/QUANTILE.spec.ts +++ b/packages/bloom/lib/commands/t-digest/QUANTILE.spec.ts @@ -1,24 +1,24 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './QUANTILE'; +import QUANTILE from './QUANTILE'; describe('TDIGEST.QUANTILE', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', [1, 2]), - ['TDIGEST.QUANTILE', 'key', '1', '2'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + QUANTILE.transformArguments('key', [1, 2]), + ['TDIGEST.QUANTILE', 'key', '1', '2'] + ); + }); - testUtils.testWithClient('client.tDigest.quantile', async client => { - const [, reply] = await Promise.all([ - client.tDigest.create('key'), - client.tDigest.quantile('key', [1]) - ]); + testUtils.testWithClient('client.tDigest.quantile', async client => { + const [, reply] = await Promise.all([ + client.tDigest.create('key'), + client.tDigest.quantile('key', [1]) + ]); - assert.deepEqual( - reply, - [NaN] - ); - }, GLOBAL.SERVERS.OPEN); + assert.deepEqual( + reply, + [NaN] + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/t-digest/QUANTILE.ts b/packages/bloom/lib/commands/t-digest/QUANTILE.ts index 2289ffc6f5..f7057a37d1 100644 --- a/packages/bloom/lib/commands/t-digest/QUANTILE.ts +++ b/packages/bloom/lib/commands/t-digest/QUANTILE.ts @@ -1,23 +1,17 @@ -import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; +import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types'; +import { transformDoubleArrayReply } from '@redis/client/dist/lib/commands/generic-transformers'; -export const FIRST_KEY_INDEX = 1; - -export const IS_READ_ONLY = true; - -export function transformArguments( - key: RedisCommandArgument, - quantiles: Array -): RedisCommandArguments { - const args = [ - 'TDIGEST.QUANTILE', - key - ]; +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments(key: RedisArgument, quantiles: Array) { + const args = ['TDIGEST.QUANTILE', key]; for (const quantile of quantiles) { - args.push(quantile.toString()); + args.push(quantile.toString()); } return args; -} - -export { transformDoublesReply as transformReply } from '.'; + }, + transformReply: transformDoubleArrayReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/t-digest/RANK.spec.ts b/packages/bloom/lib/commands/t-digest/RANK.spec.ts index 258bedf349..8cac177ecc 100644 --- a/packages/bloom/lib/commands/t-digest/RANK.spec.ts +++ b/packages/bloom/lib/commands/t-digest/RANK.spec.ts @@ -1,21 +1,21 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './RANK'; +import RANK from './RANK'; describe('TDIGEST.RANK', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', [1, 2]), - ['TDIGEST.RANK', 'key', '1', '2'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + RANK.transformArguments('key', [1, 2]), + ['TDIGEST.RANK', 'key', '1', '2'] + ); + }); - testUtils.testWithClient('client.tDigest.rank', async client => { - const [ , reply ] = await Promise.all([ - client.tDigest.create('key'), - client.tDigest.rank('key', [1]) - ]); + testUtils.testWithClient('client.tDigest.rank', async client => { + const [, reply] = await Promise.all([ + client.tDigest.create('key'), + client.tDigest.rank('key', [1]) + ]); - assert.deepEqual(reply, [-2]); - }, GLOBAL.SERVERS.OPEN); + assert.deepEqual(reply, [-2]); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/t-digest/RANK.ts b/packages/bloom/lib/commands/t-digest/RANK.ts index 1a6c84bbd4..8c18ad1277 100644 --- a/packages/bloom/lib/commands/t-digest/RANK.ts +++ b/packages/bloom/lib/commands/t-digest/RANK.ts @@ -1,19 +1,22 @@ -import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; +import { RedisArgument, ArrayReply, NumberReply, Command } from '@redis/client/dist/lib/RESP/types'; -export const FIRST_KEY_INDEX = 1; +export function transformRankArguments( + command: RedisArgument, + key: RedisArgument, + values: Array +) { + const args = [command, key]; -export const IS_READ_ONLY = true; + for (const value of values) { + args.push(value.toString()); + } -export function transformArguments( - key: RedisCommandArgument, - values: Array -): RedisCommandArguments { - const args = ['TDIGEST.RANK', key]; - for (const item of values) { - args.push(item.toString()); - } - - return args; + return args; } -export declare function transformReply(): Array; +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments: transformRankArguments.bind(undefined, 'TDIGEST.RANK'), + transformReply: undefined as unknown as () => ArrayReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/t-digest/RESET.spec.ts b/packages/bloom/lib/commands/t-digest/RESET.spec.ts index 036fbebc8c..41c4d1491d 100644 --- a/packages/bloom/lib/commands/t-digest/RESET.spec.ts +++ b/packages/bloom/lib/commands/t-digest/RESET.spec.ts @@ -1,21 +1,21 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './RESET'; +import RESET from './RESET'; describe('TDIGEST.RESET', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key'), - ['TDIGEST.RESET', 'key'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + RESET.transformArguments('key'), + ['TDIGEST.RESET', 'key'] + ); + }); - testUtils.testWithClient('client.tDigest.reset', async client => { - const [, reply] = await Promise.all([ - client.tDigest.create('key'), - client.tDigest.reset('key') - ]); + testUtils.testWithClient('client.tDigest.reset', async client => { + const [, reply] = await Promise.all([ + client.tDigest.create('key'), + client.tDigest.reset('key') + ]); - assert.equal(reply, 'OK'); - }, GLOBAL.SERVERS.OPEN); + assert.equal(reply, 'OK'); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/t-digest/RESET.ts b/packages/bloom/lib/commands/t-digest/RESET.ts index 6c700e6b93..372a1efd48 100644 --- a/packages/bloom/lib/commands/t-digest/RESET.ts +++ b/packages/bloom/lib/commands/t-digest/RESET.ts @@ -1,9 +1,10 @@ -import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; +import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types'; -export const FIRST_KEY_INDEX = 1; - -export function transformArguments(key: RedisCommandArgument): RedisCommandArguments { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments(key: RedisArgument) { return ['TDIGEST.RESET', key]; -} - -export declare function transformReply(): 'OK'; + }, + transformReply: undefined as unknown as () => SimpleStringReply<'OK'> +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/t-digest/REVRANK.spec.ts b/packages/bloom/lib/commands/t-digest/REVRANK.spec.ts index 21d16661df..8600ea3645 100644 --- a/packages/bloom/lib/commands/t-digest/REVRANK.spec.ts +++ b/packages/bloom/lib/commands/t-digest/REVRANK.spec.ts @@ -1,21 +1,21 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './REVRANK'; +import REVRANK from './REVRANK'; describe('TDIGEST.REVRANK', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', [1, 2]), - ['TDIGEST.REVRANK', 'key', '1', '2'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + REVRANK.transformArguments('key', [1, 2]), + ['TDIGEST.REVRANK', 'key', '1', '2'] + ); + }); - testUtils.testWithClient('client.tDigest.revRank', async client => { - const [ , reply ] = await Promise.all([ - client.tDigest.create('key'), - client.tDigest.revRank('key', [1]) - ]); + testUtils.testWithClient('client.tDigest.revRank', async client => { + const [, reply] = await Promise.all([ + client.tDigest.create('key'), + client.tDigest.revRank('key', [1]) + ]); - assert.deepEqual(reply, [-2]); - }, GLOBAL.SERVERS.OPEN); + assert.deepEqual(reply, [-2]); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/t-digest/REVRANK.ts b/packages/bloom/lib/commands/t-digest/REVRANK.ts index a246505277..456b2be5a3 100644 --- a/packages/bloom/lib/commands/t-digest/REVRANK.ts +++ b/packages/bloom/lib/commands/t-digest/REVRANK.ts @@ -1,19 +1,9 @@ -import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; +import { Command } from '@redis/client/dist/lib/RESP/types'; +import RANK, { transformRankArguments } from './RANK'; -export const FIRST_KEY_INDEX = 1; - -export const IS_READ_ONLY = true; - -export function transformArguments( - key: RedisCommandArgument, - values: Array -): RedisCommandArguments { - const args = ['TDIGEST.REVRANK', key]; - for (const item of values) { - args.push(item.toString()); - } - - return args; -} - -export declare function transformReply(): Array; +export default { + FIRST_KEY_INDEX: RANK.FIRST_KEY_INDEX, + IS_READ_ONLY: RANK.IS_READ_ONLY, + transformArguments: transformRankArguments.bind(undefined, 'TDIGEST.REVRANK'), + transformReply: RANK.transformReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/t-digest/TRIMMED_MEAN.spec.ts b/packages/bloom/lib/commands/t-digest/TRIMMED_MEAN.spec.ts index dd07f325c8..387a605a18 100644 --- a/packages/bloom/lib/commands/t-digest/TRIMMED_MEAN.spec.ts +++ b/packages/bloom/lib/commands/t-digest/TRIMMED_MEAN.spec.ts @@ -1,21 +1,21 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments, transformReply } from './TRIMMED_MEAN'; +import TRIMMED_MEAN from './TRIMMED_MEAN'; -describe('TDIGEST.RESET', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', 0, 1), - ['TDIGEST.TRIMMED_MEAN', 'key', '0', '1'] - ); - }); +describe('TDIGEST.TRIMMED_MEAN', () => { + it('transformArguments', () => { + assert.deepEqual( + TRIMMED_MEAN.transformArguments('key', 0, 1), + ['TDIGEST.TRIMMED_MEAN', 'key', '0', '1'] + ); + }); - testUtils.testWithClient('client.tDigest.trimmedMean', async client => { - const [, reply] = await Promise.all([ - client.tDigest.create('key'), - client.tDigest.trimmedMean('key', 0, 1) - ]); + testUtils.testWithClient('client.tDigest.trimmedMean', async client => { + const [, reply] = await Promise.all([ + client.tDigest.create('key'), + client.tDigest.trimmedMean('key', 0, 1) + ]); - assert.equal(reply, NaN); - }, GLOBAL.SERVERS.OPEN); + assert.equal(reply, NaN); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/t-digest/TRIMMED_MEAN.ts b/packages/bloom/lib/commands/t-digest/TRIMMED_MEAN.ts index 6de80ba7c7..f91dd7d809 100644 --- a/packages/bloom/lib/commands/t-digest/TRIMMED_MEAN.ts +++ b/packages/bloom/lib/commands/t-digest/TRIMMED_MEAN.ts @@ -1,20 +1,20 @@ -import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; +import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types'; +import { transformDoubleReply } from '@redis/client/dist/lib/commands/generic-transformers'; -export const FIRST_KEY_INDEX = 1; - -export const IS_READ_ONLY = true; - -export function transformArguments( - key: RedisCommandArgument, +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments( + key: RedisArgument, lowCutPercentile: number, highCutPercentile: number -): RedisCommandArguments { + ) { return [ - 'TDIGEST.TRIMMED_MEAN', - key, - lowCutPercentile.toString(), - highCutPercentile.toString() + 'TDIGEST.TRIMMED_MEAN', + key, + lowCutPercentile.toString(), + highCutPercentile.toString() ]; -} - -export { transformDoubleReply as transformReply } from '.'; + }, + transformReply: transformDoubleReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/t-digest/index.spec.ts b/packages/bloom/lib/commands/t-digest/index.spec.ts deleted file mode 100644 index 5bef6df04b..0000000000 --- a/packages/bloom/lib/commands/t-digest/index.spec.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { strict as assert } from 'assert'; -import { pushCompressionArgument, transformDoubleReply, transformDoublesReply } from '.'; - -describe('pushCompressionArgument', () => { - it('undefined', () => { - assert.deepEqual( - pushCompressionArgument([]), - [] - ); - }); - - it('100', () => { - assert.deepEqual( - pushCompressionArgument([], { COMPRESSION: 100 }), - ['COMPRESSION', '100'] - ); - }); -}); - -describe('transformDoubleReply', () => { - it('inf', () => { - assert.equal( - transformDoubleReply('inf'), - Infinity - ); - }); - - it('-inf', () => { - assert.equal( - transformDoubleReply('-inf'), - -Infinity - ); - }); - - it('nan', () => { - assert.equal( - transformDoubleReply('nan'), - NaN - ); - }); - - it('0', () => { - assert.equal( - transformDoubleReply('0'), - 0 - ); - }); -}); - -it('transformDoublesReply', () => { - assert.deepEqual( - transformDoublesReply(['inf', '-inf', 'nan', '0']), - [Infinity, -Infinity, NaN, 0] - ); -}); diff --git a/packages/bloom/lib/commands/t-digest/index.ts b/packages/bloom/lib/commands/t-digest/index.ts index da3b37464d..de3d07bdb7 100644 --- a/packages/bloom/lib/commands/t-digest/index.ts +++ b/packages/bloom/lib/commands/t-digest/index.ts @@ -1,81 +1,46 @@ -import { RedisCommandArguments } from '@redis/client/dist/lib/commands'; -import * as ADD from './ADD'; -import * as BYRANK from './BYRANK'; -import * as BYREVRANK from './BYREVRANK'; -import * as CDF from './CDF'; -import * as CREATE from './CREATE'; -import * as INFO from './INFO'; -import * as MAX from './MAX'; -import * as MERGE from './MERGE'; -import * as MIN from './MIN'; -import * as QUANTILE from './QUANTILE'; -import * as RANK from './RANK'; -import * as RESET from './RESET'; -import * as REVRANK from './REVRANK'; -import * as TRIMMED_MEAN from './TRIMMED_MEAN'; +import type { RedisCommands } from '@redis/client/dist/lib/RESP/types'; +import ADD from './ADD'; +import BYRANK from './BYRANK'; +import BYREVRANK from './BYREVRANK'; +import CDF from './CDF'; +import CREATE from './CREATE'; +// import INFO from './INFO'; +import MAX from './MAX'; +import MERGE from './MERGE'; +import MIN from './MIN'; +import QUANTILE from './QUANTILE'; +import RANK from './RANK'; +import RESET from './RESET'; +import REVRANK from './REVRANK'; +import TRIMMED_MEAN from './TRIMMED_MEAN'; export default { - ADD, - add: ADD, - BYRANK, - byRank: BYRANK, - BYREVRANK, - byRevRank: BYREVRANK, - CDF, - cdf: CDF, - CREATE, - create: CREATE, - INFO, - info: INFO, - MAX, - max: MAX, - MERGE, - merge: MERGE, - MIN, - min: MIN, - QUANTILE, - quantile: QUANTILE, - RANK, - rank: RANK, - RESET, - reset: RESET, - REVRANK, - revRank: REVRANK, - TRIMMED_MEAN, - trimmedMean: TRIMMED_MEAN -}; - -export interface CompressionOption { - COMPRESSION?: number; -} - -export function pushCompressionArgument( - args: RedisCommandArguments, - options?: CompressionOption -): RedisCommandArguments { - if (options?.COMPRESSION) { - args.push('COMPRESSION', options.COMPRESSION.toString()); - } - - return args; -} - -export function transformDoubleReply(reply: string): number { - switch (reply) { - case 'inf': - return Infinity; - - case '-inf': - return -Infinity; - - case 'nan': - return NaN; - - default: - return parseFloat(reply); - } -} - -export function transformDoublesReply(reply: Array): Array { - return reply.map(transformDoubleReply); -} + ADD, + add: ADD, + BYRANK, + byRank: BYRANK, + BYREVRANK, + byRevRank: BYREVRANK, + CDF, + cdf: CDF, + CREATE, + create: CREATE, + // INFO, + // info: INFO, + MAX, + max: MAX, + MERGE, + merge: MERGE, + MIN, + min: MIN, + QUANTILE, + quantile: QUANTILE, + RANK, + rank: RANK, + RESET, + reset: RESET, + REVRANK, + revRank: REVRANK, + TRIMMED_MEAN, + trimmedMean: TRIMMED_MEAN +} as const satisfies RedisCommands; diff --git a/packages/bloom/lib/commands/top-k/ADD.spec.ts b/packages/bloom/lib/commands/top-k/ADD.spec.ts index 149007f81d..dc29aab803 100644 --- a/packages/bloom/lib/commands/top-k/ADD.spec.ts +++ b/packages/bloom/lib/commands/top-k/ADD.spec.ts @@ -1,22 +1,21 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './ADD'; +import ADD from './ADD'; -describe('TOPK ADD', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', 'item'), - ['TOPK.ADD', 'key', 'item'] - ); - }); +describe('TOPK.ADD', () => { + it('transformArguments', () => { + assert.deepEqual( + ADD.transformArguments('key', 'item'), + ['TOPK.ADD', 'key', 'item'] + ); + }); - testUtils.testWithClient('client.topK.add', async client => { - await client.topK.reserve('topK', 3); + testUtils.testWithClient('client.topK.add', async client => { + const [, reply] = await Promise.all([ + client.topK.reserve('topK', 3), + client.topK.add('topK', 'item') + ]); - assert.deepEqual( - await client.topK.add('topK', 'item'), - [null] - ); - - }, GLOBAL.SERVERS.OPEN); + assert.deepEqual(reply, [null]); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/top-k/ADD.ts b/packages/bloom/lib/commands/top-k/ADD.ts index 125c2e71be..4043c86c56 100644 --- a/packages/bloom/lib/commands/top-k/ADD.ts +++ b/packages/bloom/lib/commands/top-k/ADD.ts @@ -1,13 +1,11 @@ -import { RedisCommandArguments } from '@redis/client/dist/lib/commands'; -import { pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers'; +import { ArrayReply, SimpleStringReply, Command, RedisArgument } from '@redis/client/dist/lib/RESP/types'; +import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers'; -export const FIRST_KEY_INDEX = 1; - -export function transformArguments( - key: string, - items: string | Array -): RedisCommandArguments { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments(key: RedisArgument, items: RedisVariadicArgument) { return pushVariadicArguments(['TOPK.ADD', key], items); -} - -export declare function transformReply(): Array; + }, + transformReply: undefined as unknown as () => ArrayReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/top-k/COUNT.spec.ts b/packages/bloom/lib/commands/top-k/COUNT.spec.ts index 318fc74c67..156b6147e9 100644 --- a/packages/bloom/lib/commands/top-k/COUNT.spec.ts +++ b/packages/bloom/lib/commands/top-k/COUNT.spec.ts @@ -1,21 +1,21 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './COUNT'; +import COUNT from './COUNT'; -describe('TOPK COUNT', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', 'item'), - ['TOPK.COUNT', 'key', 'item'] - ); - }); +describe('TOPK.COUNT', () => { + it('transformArguments', () => { + assert.deepEqual( + COUNT.transformArguments('key', 'item'), + ['TOPK.COUNT', 'key', 'item'] + ); + }); - testUtils.testWithClient('client.topK.count', async client => { - await client.topK.reserve('key', 3); + testUtils.testWithClient('client.topK.count', async client => { + const [, reply] = await Promise.all([ + client.topK.reserve('key', 3), + client.topK.count('key', 'item') + ]); - assert.deepEqual( - await client.topK.count('key', 'item'), - [0] - ); - }, GLOBAL.SERVERS.OPEN); + assert.deepEqual(reply, [0]); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/top-k/COUNT.ts b/packages/bloom/lib/commands/top-k/COUNT.ts index cb877ecc25..7e3ccc6dc4 100644 --- a/packages/bloom/lib/commands/top-k/COUNT.ts +++ b/packages/bloom/lib/commands/top-k/COUNT.ts @@ -1,15 +1,11 @@ -import { RedisCommandArguments } from '@redis/client/dist/lib/commands'; -import { pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers'; +import { RedisArgument, ArrayReply, NumberReply, Command } from '@redis/client/dist/lib/RESP/types'; +import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers'; -export const FIRST_KEY_INDEX = 1; - -export const IS_READ_ONLY = true; - -export function transformArguments( - key: string, - items: string | Array -): RedisCommandArguments { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments(key: RedisArgument, items: RedisVariadicArgument) { return pushVariadicArguments(['TOPK.COUNT', key], items); -} - -export declare function transformReply(): Array; + }, + transformReply: undefined as unknown as () => ArrayReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/top-k/INCRBY.spec.ts b/packages/bloom/lib/commands/top-k/INCRBY.spec.ts index b23ca6e0ed..5e14ba49c2 100644 --- a/packages/bloom/lib/commands/top-k/INCRBY.spec.ts +++ b/packages/bloom/lib/commands/top-k/INCRBY.spec.ts @@ -1,42 +1,42 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './INCRBY'; +import INCRBY from './INCRBY'; -describe('TOPK INCRBY', () => { - describe('transformArguments', () => { - it('single item', () => { - assert.deepEqual( - transformArguments('key', { - item: 'item', - incrementBy: 1 - }), - ['TOPK.INCRBY', 'key', 'item', '1'] - ); - }); - - it('multiple items', () => { - assert.deepEqual( - transformArguments('key', [{ - item: 'a', - incrementBy: 1 - }, { - item: 'b', - incrementBy: 2 - }]), - ['TOPK.INCRBY', 'key', 'a', '1', 'b', '2'] - ); - }); +describe('TOPK.INCRBY', () => { + describe('transformArguments', () => { + it('single item', () => { + assert.deepEqual( + INCRBY.transformArguments('key', { + item: 'item', + incrementBy: 1 + }), + ['TOPK.INCRBY', 'key', 'item', '1'] + ); }); - testUtils.testWithClient('client.topK.incrby', async client => { - await client.topK.reserve('key', 5); + it('multiple items', () => { + assert.deepEqual( + INCRBY.transformArguments('key', [{ + item: 'a', + incrementBy: 1 + }, { + item: 'b', + incrementBy: 2 + }]), + ['TOPK.INCRBY', 'key', 'a', '1', 'b', '2'] + ); + }); + }); - assert.deepEqual( - await client.topK.incrBy('key', { - item: 'item', - incrementBy: 1 - }), - [null] - ); - }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('client.topK.incrby', async client => { + const [, reply] = await Promise.all([ + client.topK.reserve('key', 5), + client.topK.incrBy('key', { + item: 'item', + incrementBy: 1 + }) + ]); + + assert.deepEqual(reply, [null]); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/top-k/INCRBY.ts b/packages/bloom/lib/commands/top-k/INCRBY.ts index 2533cb0559..16decf44dc 100644 --- a/packages/bloom/lib/commands/top-k/INCRBY.ts +++ b/packages/bloom/lib/commands/top-k/INCRBY.ts @@ -1,29 +1,32 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, ArrayReply, SimpleStringReply, NullReply, Command } from '@redis/client/dist/lib/RESP/types'; -interface IncrByItem { - item: string; - incrementBy: number; +export interface TopKIncrByItem { + item: string; + incrementBy: number; } -export function transformArguments( - key: string, - items: IncrByItem | Array -): Array { +function pushIncrByItem(args: Array, { item, incrementBy }: TopKIncrByItem) { + args.push(item, incrementBy.toString()); +} + +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments( + key: RedisArgument, + items: TopKIncrByItem | Array + ) { const args = ['TOPK.INCRBY', key]; if (Array.isArray(items)) { - for (const item of items) { - pushIncrByItem(args, item); - } + for (const item of items) { + pushIncrByItem(args, item); + } } else { - pushIncrByItem(args, items); + pushIncrByItem(args, items); } return args; -} - -function pushIncrByItem(args: Array, { item, incrementBy }: IncrByItem): void { - args.push(item, incrementBy.toString()); -} - -export declare function transformReply(): Array; + }, + transformReply: undefined as unknown as () => ArrayReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/top-k/INFO.spec.ts b/packages/bloom/lib/commands/top-k/INFO.spec.ts index 2741a58a8b..d138c90393 100644 --- a/packages/bloom/lib/commands/top-k/INFO.spec.ts +++ b/packages/bloom/lib/commands/top-k/INFO.spec.ts @@ -1,23 +1,26 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './INFO'; +import INFO from './INFO'; describe('TOPK INFO', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key'), - ['TOPK.INFO', 'key'] - ); - }); + it('transformArguments', () => { + assert.deepEqual( + INFO.transformArguments('key'), + ['TOPK.INFO', 'key'] + ); + }); - testUtils.testWithClient('client.topK.info', async client => { - await client.topK.reserve('key', 3); + testUtils.testWithClient('client.topK.info', async client => { + const k = 3, + [, reply] = await Promise.all([ + client.topK.reserve('key', 3), + client.topK.info('key') + ]); - const info = await client.topK.info('key'); - assert.equal(typeof info, 'object'); - assert.equal(info.k, 3); - assert.equal(typeof info.width, 'number'); - assert.equal(typeof info.depth, 'number'); - assert.equal(typeof info.decay, 'number'); - }, GLOBAL.SERVERS.OPEN); + assert.equal(typeof reply, 'object'); + assert.equal(reply.k, k); + assert.equal(typeof reply.width, 'number'); + assert.equal(typeof reply.depth, 'number'); + assert.equal(typeof reply.decay, 'number'); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/top-k/INFO.ts b/packages/bloom/lib/commands/top-k/INFO.ts index 8c9e8d432b..bd694eace2 100644 --- a/packages/bloom/lib/commands/top-k/INFO.ts +++ b/packages/bloom/lib/commands/top-k/INFO.ts @@ -1,34 +1,25 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, TuplesToMapReply, BlobStringReply, NumberReply, DoubleReply, Resp2Reply, Command } from '@redis/client/dist/lib/RESP/types'; -export const IS_READ_ONLY = true; - -export function transformArguments(key: string): Array { +export type TopKInfoReply = TuplesToMapReply<[ + [BlobStringReply<'k'>, NumberReply], + [BlobStringReply<'width'>, NumberReply], + [BlobStringReply<'depth'>, NumberReply], + [BlobStringReply<'decay'>, DoubleReply] +]>; + +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments(key: RedisArgument) { return ['TOPK.INFO', key]; -} - -export type InfoRawReply = [ - _: string, - k: number, - _: string, - width: number, - _: string, - depth: number, - _: string, - decay: string -]; - -export interface InfoReply { - k: number, - width: number; - depth: number; - decay: number; -} - -export function transformReply(reply: InfoRawReply): InfoReply { - return { - k: reply[1], - width: reply[3], - depth: reply[5], - decay: Number(reply[7]) - }; -} + }, + transformReply: { + 2: (reply: Resp2Reply) => ({ + k: reply[1], + width: reply[3], + depth: reply[5], + decay: Number(reply[7]) + }), + 3: undefined as unknown as () => TopKInfoReply + } +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/top-k/LIST.spec.ts b/packages/bloom/lib/commands/top-k/LIST.spec.ts index 709ac7ffc3..b2ba11fcdd 100644 --- a/packages/bloom/lib/commands/top-k/LIST.spec.ts +++ b/packages/bloom/lib/commands/top-k/LIST.spec.ts @@ -1,21 +1,21 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './LIST'; +import LIST from './LIST'; -describe('TOPK LIST', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key'), - ['TOPK.LIST', 'key'] - ); - }); +describe('TOPK.LIST', () => { + it('transformArguments', () => { + assert.deepEqual( + LIST.transformArguments('key'), + ['TOPK.LIST', 'key'] + ); + }); - testUtils.testWithClient('client.topK.list', async client => { - await client.topK.reserve('key', 3); + testUtils.testWithClient('client.topK.list', async client => { + const [, reply] = await Promise.all([ + client.topK.reserve('key', 3), + client.topK.list('key') + ]); - assert.deepEqual( - await client.topK.list('key'), - [] - ); - }, GLOBAL.SERVERS.OPEN); + assert.deepEqual(reply, []); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/top-k/LIST.ts b/packages/bloom/lib/commands/top-k/LIST.ts index 8837b86f83..d4c9f4cce7 100644 --- a/packages/bloom/lib/commands/top-k/LIST.ts +++ b/packages/bloom/lib/commands/top-k/LIST.ts @@ -1,9 +1,10 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, ArrayReply, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types'; -export const IS_READ_ONLY = true; - -export function transformArguments(key: string): Array { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments(key: RedisArgument) { return ['TOPK.LIST', key]; -} - -export declare function transformReply(): Array; + }, + transformReply: undefined as unknown as () => ArrayReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/top-k/LIST_WITHCOUNT.spec.ts b/packages/bloom/lib/commands/top-k/LIST_WITHCOUNT.spec.ts index 1e55239c24..06d40ad37a 100644 --- a/packages/bloom/lib/commands/top-k/LIST_WITHCOUNT.spec.ts +++ b/packages/bloom/lib/commands/top-k/LIST_WITHCOUNT.spec.ts @@ -1,30 +1,27 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './LIST_WITHCOUNT'; +import LIST_WITHCOUNT from './LIST_WITHCOUNT'; -describe('TOPK LIST WITHCOUNT', () => { - testUtils.isVersionGreaterThanHook([2, 2, 9]); - - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key'), - ['TOPK.LIST', 'key', 'WITHCOUNT'] - ); - }); +describe('TOPK.LIST WITHCOUNT', () => { + testUtils.isVersionGreaterThanHook([2, 2, 9]); - testUtils.testWithClient('client.topK.listWithCount', async client => { - const [,, list] = await Promise.all([ - client.topK.reserve('key', 3), - client.topK.add('key', 'item'), - client.topK.listWithCount('key') - ]); + it('transformArguments', () => { + assert.deepEqual( + LIST_WITHCOUNT.transformArguments('key'), + ['TOPK.LIST', 'key', 'WITHCOUNT'] + ); + }); - assert.deepEqual( - list, - [{ - item: 'item', - count: 1 - }] - ); - }, GLOBAL.SERVERS.OPEN); + testUtils.testWithClient('client.topK.listWithCount', async client => { + const [, , list] = await Promise.all([ + client.topK.reserve('key', 3), + client.topK.add('key', 'item'), + client.topK.listWithCount('key') + ]); + + assert.deepEqual(list, [{ + item: 'item', + count: 1 + }]); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/top-k/LIST_WITHCOUNT.ts b/packages/bloom/lib/commands/top-k/LIST_WITHCOUNT.ts index 47b7d3848e..a135e5db46 100644 --- a/packages/bloom/lib/commands/top-k/LIST_WITHCOUNT.ts +++ b/packages/bloom/lib/commands/top-k/LIST_WITHCOUNT.ts @@ -1,26 +1,24 @@ -export const FIRST_KEY_INDEX = 1; +import { RedisArgument, ArrayReply, SimpleStringReply, NumberReply, Command } from '@redis/client/dist/lib/RESP/types'; -export const IS_READ_ONLY = true; - -export function transformArguments(key: string): Array { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments(key: RedisArgument) { return ['TOPK.LIST', key, 'WITHCOUNT']; -} - -type ListWithCountRawReply = Array; - -type ListWithCountReply = Array<{ - item: string, - count: number -}>; - -export function transformReply(rawReply: ListWithCountRawReply): ListWithCountReply { - const reply: ListWithCountReply = []; + }, + transformReply(rawReply: ArrayReply) { + const reply = [] as unknown as ArrayReply<{ + item: SimpleStringReply; + count: NumberReply; + }>; + for (let i = 0; i < rawReply.length; i++) { - reply.push({ - item: rawReply[i] as string, - count: rawReply[++i] as number - }); + reply.push({ + item: rawReply[i] as SimpleStringReply, + count: rawReply[++i] as NumberReply + }); } return reply; -} \ No newline at end of file + } +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/top-k/QUERY.spec.ts b/packages/bloom/lib/commands/top-k/QUERY.spec.ts index ada9e7e2e3..fdaefe91ea 100644 --- a/packages/bloom/lib/commands/top-k/QUERY.spec.ts +++ b/packages/bloom/lib/commands/top-k/QUERY.spec.ts @@ -1,21 +1,21 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './QUERY'; +import QUERY from './QUERY'; -describe('TOPK QUERY', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('key', 'item'), - ['TOPK.QUERY', 'key', 'item'] - ); - }); +describe('TOPK.QUERY', () => { + it('transformArguments', () => { + assert.deepEqual( + QUERY.transformArguments('key', 'item'), + ['TOPK.QUERY', 'key', 'item'] + ); + }); - testUtils.testWithClient('client.cms.query', async client => { - await client.topK.reserve('key', 3); + testUtils.testWithClient('client.topK.query', async client => { + const [, reply] = await Promise.all([ + client.topK.reserve('key', 3), + client.topK.query('key', 'item') + ]); - assert.deepEqual( - await client.topK.query('key', 'item'), - [0] - ); - }, GLOBAL.SERVERS.OPEN); + assert.deepEqual(reply, [false]); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/top-k/QUERY.ts b/packages/bloom/lib/commands/top-k/QUERY.ts index 55451df3d4..5529d4ab83 100644 --- a/packages/bloom/lib/commands/top-k/QUERY.ts +++ b/packages/bloom/lib/commands/top-k/QUERY.ts @@ -1,15 +1,11 @@ -import { RedisCommandArguments } from '@redis/client/dist/lib/commands'; -import { pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers'; +import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types'; +import { RedisVariadicArgument, pushVariadicArguments, transformBooleanArrayReply } from '@redis/client/dist/lib/commands/generic-transformers'; -export const FIRST_KEY_INDEX = 1; - -export const IS_READ_ONLY = true; - -export function transformArguments( - key: string, - items: string | Array -): RedisCommandArguments { +export default { + FIRST_KEY_INDEX: undefined, + IS_READ_ONLY: false, + transformArguments(key: RedisArgument, items: RedisVariadicArgument) { return pushVariadicArguments(['TOPK.QUERY', key], items); -} - -export declare function transformReply(): Array; + }, + transformReply: transformBooleanArrayReply +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/top-k/RESERVE.spec.ts b/packages/bloom/lib/commands/top-k/RESERVE.spec.ts index 54600c0e4f..f58c5b8b33 100644 --- a/packages/bloom/lib/commands/top-k/RESERVE.spec.ts +++ b/packages/bloom/lib/commands/top-k/RESERVE.spec.ts @@ -1,32 +1,32 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../../test-utils'; -import { transformArguments } from './RESERVE'; +import RESERVE from './RESERVE'; -describe('TOPK RESERVE', () => { - describe('transformArguments', () => { - it('simple', () => { - assert.deepEqual( - transformArguments('topK', 3), - ['TOPK.RESERVE', 'topK', '3'] - ); - }); - - it('with options', () => { - assert.deepEqual( - transformArguments('topK', 3, { - width: 8, - depth: 7, - decay: 0.9 - }), - ['TOPK.RESERVE', 'topK', '3', '8', '7', '0.9'] - ); - }); +describe('TOPK.RESERVE', () => { + describe('transformArguments', () => { + it('simple', () => { + assert.deepEqual( + RESERVE.transformArguments('topK', 3), + ['TOPK.RESERVE', 'topK', '3'] + ); }); - testUtils.testWithClient('client.topK.reserve', async client => { - assert.equal( - await client.topK.reserve('topK', 3), - 'OK' - ); - }, GLOBAL.SERVERS.OPEN); + it('with options', () => { + assert.deepEqual( + RESERVE.transformArguments('topK', 3, { + width: 8, + depth: 7, + decay: 0.9 + }), + ['TOPK.RESERVE', 'topK', '3', '8', '7', '0.9'] + ); + }); + }); + + testUtils.testWithClient('client.topK.reserve', async client => { + assert.equal( + await client.topK.reserve('topK', 3), + 'OK' + ); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/bloom/lib/commands/top-k/RESERVE.ts b/packages/bloom/lib/commands/top-k/RESERVE.ts index 350d4cd833..12671728fe 100644 --- a/packages/bloom/lib/commands/top-k/RESERVE.ts +++ b/packages/bloom/lib/commands/top-k/RESERVE.ts @@ -1,29 +1,26 @@ -export const FIRST_KEY_INDEX = 1; +import { SimpleStringReply, Command, RedisArgument } from '@redis/client/dist/lib/RESP/types'; -export const IS_READ_ONLY = true; - -interface ReserveOptions { - width: number; - depth: number; - decay: number; +export interface TopKReserveOptions { + width: number; + depth: number; + decay: number; } -export function transformArguments( - key: string, - topK: number, - options?: ReserveOptions -): Array { +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments(key: RedisArgument, topK: number, options?: TopKReserveOptions) { const args = ['TOPK.RESERVE', key, topK.toString()]; if (options) { - args.push( - options.width.toString(), - options.depth.toString(), - options.decay.toString() - ); + args.push( + options.width.toString(), + options.depth.toString(), + options.decay.toString() + ); } return args; -} - -export declare function transformReply(): 'OK'; + }, + transformReply: undefined as unknown as () => SimpleStringReply<'OK'> +} as const satisfies Command; diff --git a/packages/bloom/lib/commands/top-k/index.ts b/packages/bloom/lib/commands/top-k/index.ts index 750c91dfa8..fb5de543ca 100644 --- a/packages/bloom/lib/commands/top-k/index.ts +++ b/packages/bloom/lib/commands/top-k/index.ts @@ -1,27 +1,28 @@ -import * as ADD from './ADD'; -import * as COUNT from './COUNT'; -import * as INCRBY from './INCRBY'; -import * as INFO from './INFO'; -import * as LIST_WITHCOUNT from './LIST_WITHCOUNT'; -import * as LIST from './LIST'; -import * as QUERY from './QUERY'; -import * as RESERVE from './RESERVE'; +import type { RedisCommands } from '@redis/client/dist/lib/RESP/types'; +import ADD from './ADD'; +import COUNT from './COUNT'; +import INCRBY from './INCRBY'; +import INFO from './INFO'; +import LIST_WITHCOUNT from './LIST_WITHCOUNT'; +import LIST from './LIST'; +import QUERY from './QUERY'; +import RESERVE from './RESERVE'; export default { - ADD, - add: ADD, - COUNT, - count: COUNT, - INCRBY, - incrBy: INCRBY, - INFO, - info: INFO, - LIST_WITHCOUNT, - listWithCount: LIST_WITHCOUNT, - LIST, - list: LIST, - QUERY, - query: QUERY, - RESERVE, - reserve: RESERVE -}; + ADD, + add: ADD, + COUNT, + count: COUNT, + INCRBY, + incrBy: INCRBY, + INFO, + info: INFO, + LIST_WITHCOUNT, + listWithCount: LIST_WITHCOUNT, + LIST, + list: LIST, + QUERY, + query: QUERY, + RESERVE, + reserve: RESERVE +} as const satisfies RedisCommands; diff --git a/packages/bloom/lib/test-utils.ts b/packages/bloom/lib/test-utils.ts index a2e059b3b9..70e8a154d6 100644 --- a/packages/bloom/lib/test-utils.ts +++ b/packages/bloom/lib/test-utils.ts @@ -2,18 +2,18 @@ import TestUtils from '@redis/test-utils'; import RedisBloomModules from '.'; export default new TestUtils({ - dockerImageName: 'redislabs/rebloom', - dockerImageVersionArgument: 'redisbloom-version', - defaultDockerVersion: 'edge' + dockerImageName: 'redislabs/rebloom', + dockerImageVersionArgument: 'redisbloom-version', + defaultDockerVersion: 'edge' }); export const GLOBAL = { - SERVERS: { - OPEN: { - serverArguments: ['--loadmodule /usr/lib/redis/modules/redisbloom.so'], - clientOptions: { - modules: RedisBloomModules - } - } + SERVERS: { + OPEN: { + serverArguments: ['--loadmodule /usr/lib/redis/modules/redisbloom.so'], + clientOptions: { + modules: RedisBloomModules + } } + } }; diff --git a/packages/client/lib/client/index.spec.ts b/packages/client/lib/client/index.spec.ts index 7a259720ef..0312aa9d0c 100644 --- a/packages/client/lib/client/index.spec.ts +++ b/packages/client/lib/client/index.spec.ts @@ -11,6 +11,7 @@ import { once } from 'events'; // import { promisify } from 'util'; import { MATH_FUNCTION, loadMathFunction } from '../commands/FUNCTION_LOAD.spec'; import { RESP_TYPES } from '../RESP/decoder'; +import { SortedSetMember } from '../commands/generic-transformers'; export const SQUARE_SCRIPT = defineScript({ SCRIPT: 'return ARGV[1] * ARGV[1];', @@ -435,84 +436,86 @@ describe('Client', () => { // return client.executeIsolated(isolated => killClient(isolated, client)); // }, GLOBAL.SERVERS.OPEN); -// testUtils.testWithClient('scanIterator', async client => { -// const promises = [], -// keys = new Set(); -// for (let i = 0; i < 100; i++) { -// const key = i.toString(); -// keys.add(key); -// promises.push(client.set(key, '')); -// } + testUtils.testWithClient('scanIterator', async client => { + const entries: Array = [], + keys = new Set(); + for (let i = 0; i < 100; i++) { + const key = i.toString(); + keys.add(key); + entries.push(key, ''); + } -// await Promise.all(promises); + await client.mSet(entries); -// const results = new Set(); -// for await (const key of client.scanIterator()) { -// results.add(key); -// } + const results = new Set(); + for await (const keys of client.scanIterator()) { + for (const key of keys) { + results.add(key); + } + } -// assert.deepEqual(keys, results); -// }, GLOBAL.SERVERS.OPEN); + assert.deepEqual(keys, results); + }, GLOBAL.SERVERS.OPEN); -// testUtils.testWithClient('hScanIterator', async client => { -// const hash: Record = {}; -// for (let i = 0; i < 100; i++) { -// hash[i.toString()] = i.toString(); -// } + testUtils.testWithClient('hScanIterator', async client => { + const hash: Record = {}; + for (let i = 0; i < 100; i++) { + hash[i.toString()] = i.toString(); + } -// await client.hSet('key', hash); + await client.hSet('key', hash); -// const results: Record = {}; -// for await (const { field, value } of client.hScanIterator('key')) { -// results[field] = value; -// } + const results: Record = {}; + for await (const entries of client.hScanIterator('key')) { + for (const { field, value } of entries) { + results[field] = value; + } + } -// assert.deepEqual(hash, results); -// }, GLOBAL.SERVERS.OPEN); + assert.deepEqual(hash, results); + }, GLOBAL.SERVERS.OPEN); -// testUtils.testWithClient('sScanIterator', async client => { -// const members = new Set(); -// for (let i = 0; i < 100; i++) { -// members.add(i.toString()); -// } + testUtils.testWithClient('sScanIterator', async client => { + const members = new Set(); + for (let i = 0; i < 100; i++) { + members.add(i.toString()); + } -// await client.sAdd('key', Array.from(members)); + await client.sAdd('key', Array.from(members)); -// const results = new Set(); -// for await (const key of client.sScanIterator('key')) { -// results.add(key); -// } + const results = new Set(); + for await (const members of client.sScanIterator('key')) { + for (const member of members) { + results.add(member); + } + } -// assert.deepEqual(members, results); -// }, GLOBAL.SERVERS.OPEN); + assert.deepEqual(members, results); + }, GLOBAL.SERVERS.OPEN); -// testUtils.testWithClient('zScanIterator', async client => { -// const members = []; -// for (let i = 0; i < 100; i++) { -// members.push({ -// score: 1, -// value: i.toString() -// }); -// } + testUtils.testWithClient('zScanIterator', async client => { + const members: Array = [], + map = new Map(); + for (let i = 0; i < 100; i++) { + const member = { + value: i.toString(), + score: 1 + }; + map.set(member.value, member.score); + members.push(member); + } -// await client.zAdd('key', members); + await client.zAdd('key', members); -// const map = new Map(); -// for await (const member of client.zScanIterator('key')) { -// map.set(member.value, member.score); -// } + const results = new Map(); + for await (const members of client.zScanIterator('key')) { + for (const { value, score } of members) { + results.set(value, score); + } + } -// type MemberTuple = [string, number]; - -// function sort(a: MemberTuple, b: MemberTuple) { -// return Number(b[0]) - Number(a[0]); -// } - -// assert.deepEqual( -// [...map.entries()].sort(sort), -// members.map(member => [member.value, member.score]).sort(sort) -// ); -// }, GLOBAL.SERVERS.OPEN); + assert.deepEqual(map, results); + }, GLOBAL.SERVERS.OPEN); // describe('PubSub', () => { // testUtils.testWithClient('should be able to publish and subscribe to messages', async publisher => { diff --git a/packages/client/lib/client/index.ts b/packages/client/lib/client/index.ts index d53f8bec60..5a96388b4d 100644 --- a/packages/client/lib/client/index.ts +++ b/packages/client/lib/client/index.ts @@ -141,7 +141,7 @@ type ProxyClient = RedisClient; type NamespaceProxyClient = { self: ProxyClient }; interface ScanIteratorOptions { - cursor?: number; + cursor?: RedisArgument; } export default class RedisClient< @@ -799,12 +799,12 @@ export default class RedisClient< this: RedisClientType, options?: ScanOptions & ScanIteratorOptions ) { - let cursor = options?.cursor ?? 0; + let cursor = options?.cursor ?? '0'; do { const reply = await this.scan(cursor, options); cursor = reply.cursor; yield reply.keys; - } while (cursor !== 0); + } while (cursor !== '0'); } async* hScanIterator( @@ -812,12 +812,12 @@ export default class RedisClient< key: RedisArgument, options?: ScanCommonOptions & ScanIteratorOptions ) { - let cursor = options?.cursor ?? 0; + let cursor = options?.cursor ?? '0'; do { const reply = await this.hScan(key, cursor, options); cursor = reply.cursor; yield reply.entries; - } while (cursor !== 0); + } while (cursor !== '0'); } async* sScanIterator( @@ -825,12 +825,12 @@ export default class RedisClient< key: RedisArgument, options?: ScanCommonOptions & ScanIteratorOptions ) { - let cursor = options?.cursor ?? 0; + let cursor = options?.cursor ?? '0'; do { const reply = await this.sScan(key, cursor, options); cursor = reply.cursor; yield reply.members; - } while (cursor !== 0); + } while (cursor !== '0'); } async* zScanIterator( @@ -838,12 +838,12 @@ export default class RedisClient< key: RedisArgument, options?: ScanCommonOptions & ScanIteratorOptions ) { - let cursor = options?.cursor ?? 0; + let cursor = options?.cursor ?? '0'; do { const reply = await this.zScan(key, cursor, options); cursor = reply.cursor; yield reply.members; - } while (cursor !== 0); + } while (cursor !== '0'); } /** diff --git a/packages/client/lib/commands/BLMOVE.spec.ts b/packages/client/lib/commands/BLMOVE.spec.ts index 3afda7f8a0..27029e6161 100644 --- a/packages/client/lib/commands/BLMOVE.spec.ts +++ b/packages/client/lib/commands/BLMOVE.spec.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'assert'; -import testUtils, { GLOBAL } from '../test-utils'; +import testUtils, { GLOBAL, BLOCKING_MIN_VALUE } from '../test-utils'; import BLMOVE from './BLMOVE'; describe('BLMOVE', () => { @@ -14,7 +14,7 @@ describe('BLMOVE', () => { testUtils.testAll('blMove - null', async client => { assert.equal( - await client.blMove('{tag}source', '{tag}destination', 'LEFT', 'RIGHT', Number.MIN_VALUE), + await client.blMove('{tag}source', '{tag}destination', 'LEFT', 'RIGHT', BLOCKING_MIN_VALUE), null ); }, { @@ -25,7 +25,7 @@ describe('BLMOVE', () => { testUtils.testAll('blMove - with member', async client => { const [, reply] = await Promise.all([ client.lPush('{tag}source', 'element'), - client.blMove('{tag}source', '{tag}destination', 'LEFT', 'RIGHT', Number.MIN_VALUE) + client.blMove('{tag}source', '{tag}destination', 'LEFT', 'RIGHT', BLOCKING_MIN_VALUE) ]); assert.equal(reply, 'element'); }, { diff --git a/packages/client/lib/commands/BLMPOP.spec.ts b/packages/client/lib/commands/BLMPOP.spec.ts index 6e87446ca8..b47fb68ac4 100644 --- a/packages/client/lib/commands/BLMPOP.spec.ts +++ b/packages/client/lib/commands/BLMPOP.spec.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'assert'; -import testUtils, { GLOBAL } from '../test-utils'; +import testUtils, { GLOBAL, BLOCKING_MIN_VALUE } from '../test-utils'; import BLMPOP from './BLMPOP'; describe('BLMPOP', () => { @@ -25,7 +25,7 @@ describe('BLMPOP', () => { testUtils.testAll('blmPop - null', async client => { assert.equal( - await client.blmPop(Number.MIN_VALUE, 'key', 'RIGHT'), + await client.blmPop(BLOCKING_MIN_VALUE, 'key', 'RIGHT'), null ); }, { @@ -36,7 +36,7 @@ describe('BLMPOP', () => { testUtils.testAll('blmPop - with member', async client => { const [, reply] = await Promise.all([ client.lPush('key', 'element'), - client.blmPop(Number.MIN_VALUE, 'key', 'RIGHT') + client.blmPop(BLOCKING_MIN_VALUE, 'key', 'RIGHT') ]); assert.deepEqual(reply, [ 'key', diff --git a/packages/client/lib/commands/BLPOP.spec.ts b/packages/client/lib/commands/BLPOP.spec.ts index 35b9d95396..ca9dd76ce7 100644 --- a/packages/client/lib/commands/BLPOP.spec.ts +++ b/packages/client/lib/commands/BLPOP.spec.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'assert'; -import testUtils, { GLOBAL } from '../test-utils'; +import testUtils, { GLOBAL, BLOCKING_MIN_VALUE } from '../test-utils'; import BLPOP from './BLPOP'; describe('BLPOP', () => { @@ -21,7 +21,7 @@ describe('BLPOP', () => { testUtils.testAll('blPop - null', async client => { assert.equal( - await client.blPop('key', Number.MIN_VALUE), + await client.blPop('key', BLOCKING_MIN_VALUE), null ); }, { diff --git a/packages/client/lib/commands/BRPOP.spec.ts b/packages/client/lib/commands/BRPOP.spec.ts index f484036aca..3e61ff7581 100644 --- a/packages/client/lib/commands/BRPOP.spec.ts +++ b/packages/client/lib/commands/BRPOP.spec.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'assert'; -import testUtils, { GLOBAL } from '../test-utils'; +import testUtils, { GLOBAL, BLOCKING_MIN_VALUE } from '../test-utils'; import BRPOP from './BRPOP'; describe('BRPOP', () => { @@ -21,7 +21,7 @@ describe('BRPOP', () => { testUtils.testAll('brPop - null', async client => { assert.equal( - await client.brPop('key', Number.MIN_VALUE), + await client.brPop('key', BLOCKING_MIN_VALUE), null ); }, { diff --git a/packages/client/lib/commands/BRPOPLPUSH.spec.ts b/packages/client/lib/commands/BRPOPLPUSH.spec.ts index 1c1484868b..d9f433707d 100644 --- a/packages/client/lib/commands/BRPOPLPUSH.spec.ts +++ b/packages/client/lib/commands/BRPOPLPUSH.spec.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'assert'; -import testUtils, { GLOBAL } from '../test-utils'; +import testUtils, { GLOBAL, BLOCKING_MIN_VALUE } from '../test-utils'; import BRPOPLPUSH from './BRPOPLPUSH'; describe('BRPOPLPUSH', () => { @@ -15,7 +15,7 @@ describe('BRPOPLPUSH', () => { await client.brPopLPush( '{tag}source', '{tag}destination', - Number.MIN_VALUE + BLOCKING_MIN_VALUE ), null ); diff --git a/packages/client/lib/commands/BZMPOP.spec.ts b/packages/client/lib/commands/BZMPOP.spec.ts index 60bc3fe471..dcd480c872 100644 --- a/packages/client/lib/commands/BZMPOP.spec.ts +++ b/packages/client/lib/commands/BZMPOP.spec.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'assert'; -import testUtils, { GLOBAL } from '../test-utils'; +import testUtils, { GLOBAL, BLOCKING_MIN_VALUE } from '../test-utils'; import BZMPOP from './BZMPOP'; describe('BZMPOP', () => { @@ -25,7 +25,7 @@ describe('BZMPOP', () => { testUtils.testAll('bzmPop - null', async client => { assert.equal( - await client.bzmPop(Number.MIN_VALUE, 'key', 'MAX'), + await client.bzmPop(BLOCKING_MIN_VALUE, 'key', 'MAX'), null ); }, { @@ -41,7 +41,7 @@ describe('BZMPOP', () => { }, [, reply] = await Promise.all([ client.zAdd(key, member), - client.bzmPop(Number.MIN_VALUE, key, 'MAX') + client.bzmPop(BLOCKING_MIN_VALUE, key, 'MAX') ]); assert.deepEqual(reply, { diff --git a/packages/client/lib/commands/BZPOPMAX.spec.ts b/packages/client/lib/commands/BZPOPMAX.spec.ts index 64fb6b85b7..53c6187e4e 100644 --- a/packages/client/lib/commands/BZPOPMAX.spec.ts +++ b/packages/client/lib/commands/BZPOPMAX.spec.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'assert'; -import testUtils, { GLOBAL } from '../test-utils'; +import testUtils, { GLOBAL, BLOCKING_MIN_VALUE } from '../test-utils'; import BZPOPMAX from './BZPOPMAX'; describe('BZPOPMAX', () => { @@ -21,7 +21,7 @@ describe('BZPOPMAX', () => { testUtils.testAll('bzPopMax - null', async client => { assert.equal( - await client.bzPopMax('key', Number.MIN_VALUE), + await client.bzPopMax('key', BLOCKING_MIN_VALUE), null ); }, { @@ -37,7 +37,7 @@ describe('BZPOPMAX', () => { }, [, reply] = await Promise.all([ client.zAdd(key, member), - client.bzPopMax(key, Number.MIN_VALUE) + client.bzPopMax(key, BLOCKING_MIN_VALUE) ]); assert.deepEqual(reply, { diff --git a/packages/client/lib/commands/BZPOPMIN.spec.ts b/packages/client/lib/commands/BZPOPMIN.spec.ts index 399c8f30b9..96acf25a1e 100644 --- a/packages/client/lib/commands/BZPOPMIN.spec.ts +++ b/packages/client/lib/commands/BZPOPMIN.spec.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'assert'; -import testUtils, { GLOBAL } from '../test-utils'; +import testUtils, { GLOBAL, BLOCKING_MIN_VALUE } from '../test-utils'; import BZPOPMIN from './BZPOPMIN'; describe('BZPOPMIN', () => { @@ -21,7 +21,7 @@ describe('BZPOPMIN', () => { testUtils.testAll('bzPopMin - null', async client => { assert.equal( - await client.bzPopMin('key', Number.MIN_VALUE), + await client.bzPopMin('key', BLOCKING_MIN_VALUE), null ); }, { @@ -37,7 +37,7 @@ describe('BZPOPMIN', () => { }, [, reply] = await Promise.all([ client.zAdd(key, member), - client.bzPopMin(key, Number.MIN_VALUE) + client.bzPopMin(key, BLOCKING_MIN_VALUE) ]); assert.deepEqual(reply, { diff --git a/packages/client/lib/commands/CLIENT_TRACKING.ts b/packages/client/lib/commands/CLIENT_TRACKING.ts index 5eebb8492a..a783ce3589 100644 --- a/packages/client/lib/commands/CLIENT_TRACKING.ts +++ b/packages/client/lib/commands/CLIENT_TRACKING.ts @@ -1,5 +1,6 @@ import { RedisArgument, SimpleStringReply, Command } from '../RESP/types'; import { RedisVariadicArgument } from './generic-transformers'; + interface CommonOptions { REDIRECT?: number; NOLOOP?: boolean; @@ -18,7 +19,7 @@ interface OptOutOptions { OPTOUT?: boolean; } -type ClientTrackingOptions = CommonOptions & ( +export type ClientTrackingOptions = CommonOptions & ( BroadcastOptions | OptInOptions | OptOutOptions diff --git a/packages/client/lib/commands/COMMAND_GETKEYSANDFLAGS.ts b/packages/client/lib/commands/COMMAND_GETKEYSANDFLAGS.ts index d1232d1999..a3581237f4 100644 --- a/packages/client/lib/commands/COMMAND_GETKEYSANDFLAGS.ts +++ b/packages/client/lib/commands/COMMAND_GETKEYSANDFLAGS.ts @@ -1,24 +1,20 @@ -// import { RedisCommandArgument, RedisCommandArguments } from '.'; +import { RedisArgument, ArrayReply, TuplesReply, BlobStringReply, SetReply, Command } from '../RESP/types'; -// export const IS_READ_ONLY = true; +export type CommandGetKeysAndFlagsRawReply = ArrayReply +]>>; -// export function transformArguments(args: Array): RedisCommandArguments { -// return ['COMMAND', 'GETKEYSANDFLAGS', ...args]; -// } - -// type KeysAndFlagsRawReply = Array<[ -// RedisCommandArgument, -// RedisCommandArguments -// ]>; - -// type KeysAndFlagsReply = Array<{ -// key: RedisCommandArgument; -// flags: RedisCommandArguments; -// }>; - -// export function transformReply(reply: KeysAndFlagsRawReply): KeysAndFlagsReply { -// return reply.map(([key, flags]) => ({ -// key, -// flags -// })); -// } +export default { + FIRST_KEY_INDEX: undefined, + IS_READ_ONLY: true, + transformArguments(args: Array) { + return ['COMMAND', 'GETKEYSANDFLAGS', ...args]; + }, + transformReply(reply: CommandGetKeysAndFlagsRawReply) { + return reply.map(([key, flags]) => ({ + key, + flags + })); + } +} 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 fbda163067..61246c4523 100644 --- a/packages/client/lib/commands/FUNCTION_LOAD.spec.ts +++ b/packages/client/lib/commands/FUNCTION_LOAD.spec.ts @@ -9,7 +9,7 @@ export const MATH_FUNCTION = { engine: 'LUA', code: `#!LUA name=math - redis.register_function{ + redis.register_function { function_name = "square", callback = function(keys, args) return args[1] * args[1] end, flags = { "no-writes" } diff --git a/packages/client/lib/commands/HSCAN.spec.ts b/packages/client/lib/commands/HSCAN.spec.ts index c655f5a1a5..0a3dfd19be 100644 --- a/packages/client/lib/commands/HSCAN.spec.ts +++ b/packages/client/lib/commands/HSCAN.spec.ts @@ -6,14 +6,14 @@ describe('HSCAN', () => { describe('transformArguments', () => { it('cusror only', () => { assert.deepEqual( - HSCAN.transformArguments('key', 0), + HSCAN.transformArguments('key', '0'), ['HSCAN', 'key', '0'] ); }); it('with MATCH', () => { assert.deepEqual( - HSCAN.transformArguments('key', 0, { + HSCAN.transformArguments('key', '0', { MATCH: 'pattern' }), ['HSCAN', 'key', '0', 'MATCH', 'pattern'] @@ -22,7 +22,7 @@ describe('HSCAN', () => { it('with COUNT', () => { assert.deepEqual( - HSCAN.transformArguments('key', 0, { + HSCAN.transformArguments('key', '0', { COUNT: 1 }), ['HSCAN', 'key', '0', 'COUNT', '1'] @@ -31,7 +31,7 @@ describe('HSCAN', () => { it('with MATCH & COUNT', () => { assert.deepEqual( - HSCAN.transformArguments('key', 0, { + HSCAN.transformArguments('key', '0', { MATCH: 'pattern', COUNT: 1 }), @@ -41,16 +41,17 @@ describe('HSCAN', () => { }); testUtils.testWithClient('client.hScan', async client => { - await client.hSet('key', 'field', 'value'); - assert.deepEqual( - await client.hScan('key', 0), - { - cursor: 0, - entries: [{ - field: 'field', - value: 'value' - }] - } - ); + const [, reply] = await Promise.all([ + client.hSet('key', 'field', 'value'), + client.hScan('key', '0') + ]); + + assert.deepEqual(reply, { + cursor: '0', + entries: [{ + field: 'field', + value: 'value' + }] + }); }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/client/lib/commands/HSCAN.ts b/packages/client/lib/commands/HSCAN.ts index 2391424eb2..db52db99fe 100644 --- a/packages/client/lib/commands/HSCAN.ts +++ b/packages/client/lib/commands/HSCAN.ts @@ -11,7 +11,7 @@ export default { IS_READ_ONLY: true, transformArguments( key: RedisArgument, - cursor: number, + cursor: RedisArgument, options?: ScanCommonOptions ) { return pushScanArguments(['HSCAN', key], cursor, options); @@ -27,7 +27,7 @@ export default { } return { - cursor: Number(cursor), + cursor, entries }; } diff --git a/packages/client/lib/commands/MEMORY_STATS.spec.ts b/packages/client/lib/commands/MEMORY_STATS.spec.ts index 28caa208b8..d210514d7f 100644 --- a/packages/client/lib/commands/MEMORY_STATS.spec.ts +++ b/packages/client/lib/commands/MEMORY_STATS.spec.ts @@ -18,7 +18,9 @@ describe('MEMORY STATS', () => { assert.equal(typeof memoryStats['replication.backlog'], 'number'); assert.equal(typeof memoryStats['clients.slaves'], 'number'); assert.equal(typeof memoryStats['clients.normal'], 'number'); - assert.equal(typeof memoryStats['cluster.links'], 'number'); + if (testUtils.isVersionGreaterThan([7])) { + assert.equal(typeof memoryStats['cluster.links'], 'number'); + } assert.equal(typeof memoryStats['aof.buffer'], 'number'); assert.equal(typeof memoryStats['lua.caches'], 'number'); assert.equal(typeof memoryStats['functions.caches'], 'number'); diff --git a/packages/client/lib/commands/MEMORY_STATS.ts b/packages/client/lib/commands/MEMORY_STATS.ts index 2d798ccd2c..b15db7fb8f 100644 --- a/packages/client/lib/commands/MEMORY_STATS.ts +++ b/packages/client/lib/commands/MEMORY_STATS.ts @@ -7,6 +7,7 @@ export type MemoryStatsReply = TuplesToMapReply<[ [BlobStringReply<'replication.backlog'>, NumberReply], [BlobStringReply<'clients.slaves'>, NumberReply], [BlobStringReply<'clients.normal'>, NumberReply], + /** added in 7.0 */ [BlobStringReply<'cluster.links'>, NumberReply], [BlobStringReply<'aof.buffer'>, NumberReply], [BlobStringReply<'lua.caches'>, NumberReply], diff --git a/packages/client/lib/commands/SCAN.spec.ts b/packages/client/lib/commands/SCAN.spec.ts index baf3682954..ccffde48d2 100644 --- a/packages/client/lib/commands/SCAN.spec.ts +++ b/packages/client/lib/commands/SCAN.spec.ts @@ -6,14 +6,14 @@ describe('SCAN', () => { describe('transformArguments', () => { it('cusror only', () => { assert.deepEqual( - SCAN.transformArguments(0), + SCAN.transformArguments('0'), ['SCAN', '0'] ); }); it('with MATCH', () => { assert.deepEqual( - SCAN.transformArguments(0, { + SCAN.transformArguments('0', { MATCH: 'pattern' }), ['SCAN', '0', 'MATCH', 'pattern'] @@ -22,7 +22,7 @@ describe('SCAN', () => { it('with COUNT', () => { assert.deepEqual( - SCAN.transformArguments(0, { + SCAN.transformArguments('0', { COUNT: 1 }), ['SCAN', '0', 'COUNT', '1'] @@ -31,7 +31,7 @@ describe('SCAN', () => { it('with TYPE', () => { assert.deepEqual( - SCAN.transformArguments(0, { + SCAN.transformArguments('0', { TYPE: 'stream' }), ['SCAN', '0', 'TYPE', 'stream'] @@ -40,7 +40,7 @@ describe('SCAN', () => { it('with MATCH & COUNT & TYPE', () => { assert.deepEqual( - SCAN.transformArguments(0, { + SCAN.transformArguments('0', { MATCH: 'pattern', COUNT: 1, TYPE: 'stream' @@ -52,9 +52,9 @@ describe('SCAN', () => { testUtils.testAll('scan', async client => { assert.deepEqual( - await client.scan(0), + await client.scan('0'), { - cursor: 0, + cursor: '0', keys: [] } ); diff --git a/packages/client/lib/commands/SCAN.ts b/packages/client/lib/commands/SCAN.ts index da64a7969e..13f5444044 100644 --- a/packages/client/lib/commands/SCAN.ts +++ b/packages/client/lib/commands/SCAN.ts @@ -7,7 +7,7 @@ export interface ScanCommonOptions { export function pushScanArguments( args: CommandArguments, - cursor: number, + cursor: RedisArgument, options?: ScanOptions ): CommandArguments { args.push(cursor.toString()); @@ -30,7 +30,7 @@ export interface ScanOptions extends ScanCommonOptions { export default { FIRST_KEY_INDEX: undefined, IS_READ_ONLY: true, - transformArguments(cursor: number, options?: ScanOptions) { + transformArguments(cursor: RedisArgument, options?: ScanOptions) { const args = pushScanArguments(['SCAN'], cursor, options); if (options?.TYPE) { @@ -41,7 +41,7 @@ export default { }, transformReply([cursor, keys]: [BlobStringReply, ArrayReply]) { return { - cursor: Number(cursor), + cursor, keys }; } diff --git a/packages/client/lib/commands/SSCAN.spec.ts b/packages/client/lib/commands/SSCAN.spec.ts index 3fe9edec8c..2b394511f5 100644 --- a/packages/client/lib/commands/SSCAN.spec.ts +++ b/packages/client/lib/commands/SSCAN.spec.ts @@ -6,14 +6,14 @@ describe('SSCAN', () => { describe('transformArguments', () => { it('cusror only', () => { assert.deepEqual( - SSCAN.transformArguments('key', 0), + SSCAN.transformArguments('key', '0'), ['SSCAN', 'key', '0'] ); }); it('with MATCH', () => { assert.deepEqual( - SSCAN.transformArguments('key', 0, { + SSCAN.transformArguments('key', '0', { MATCH: 'pattern' }), ['SSCAN', 'key', '0', 'MATCH', 'pattern'] @@ -22,7 +22,7 @@ describe('SSCAN', () => { it('with COUNT', () => { assert.deepEqual( - SSCAN.transformArguments('key', 0, { + SSCAN.transformArguments('key', '0', { COUNT: 1 }), ['SSCAN', 'key', '0', 'COUNT', '1'] @@ -31,7 +31,7 @@ describe('SSCAN', () => { it('with MATCH & COUNT', () => { assert.deepEqual( - SSCAN.transformArguments('key', 0, { + SSCAN.transformArguments('key', '0', { MATCH: 'pattern', COUNT: 1 }), @@ -42,9 +42,9 @@ describe('SSCAN', () => { testUtils.testAll('sScan', async client => { assert.deepEqual( - await client.sScan('key', 0), + await client.sScan('key', '0'), { - cursor: 0, + cursor: '0', members: [] } ); diff --git a/packages/client/lib/commands/SSCAN.ts b/packages/client/lib/commands/SSCAN.ts index c36bc52ca1..f47144d834 100644 --- a/packages/client/lib/commands/SSCAN.ts +++ b/packages/client/lib/commands/SSCAN.ts @@ -6,14 +6,14 @@ export default { IS_READ_ONLY: true, transformArguments( key: RedisArgument, - cursor: number, + cursor: RedisArgument, options?: ScanCommonOptions ) { return pushScanArguments(['SSCAN', key], cursor, options); }, transformReply([cursor, members]: [BlobStringReply, Array]) { return { - cursor: Number(cursor), + cursor, members }; } diff --git a/packages/client/lib/commands/XADD_NOMKSTREAM.spec.ts b/packages/client/lib/commands/XADD_NOMKSTREAM.spec.ts index 862b51a4aa..b78b01c37e 100644 --- a/packages/client/lib/commands/XADD_NOMKSTREAM.spec.ts +++ b/packages/client/lib/commands/XADD_NOMKSTREAM.spec.ts @@ -3,6 +3,8 @@ import testUtils, { GLOBAL } from '../test-utils'; import XADD_NOMKSTREAM from './XADD_NOMKSTREAM'; describe('XADD NOMKSTREAM', () => { + testUtils.isVersionGreaterThanHook([6, 2]); + describe('transformArguments', () => { it('single field', () => { assert.deepEqual( diff --git a/packages/client/lib/commands/XINFO_CONSUMERS.spec.ts b/packages/client/lib/commands/XINFO_CONSUMERS.spec.ts index e57ed72d8e..ddfba6f27a 100644 --- a/packages/client/lib/commands/XINFO_CONSUMERS.spec.ts +++ b/packages/client/lib/commands/XINFO_CONSUMERS.spec.ts @@ -15,7 +15,11 @@ describe('XINFO CONSUMERS', () => { client.xGroupCreate('key', 'group', '$', { MKSTREAM: true }), - client.xGroupCreateConsumer('key', 'group', 'consumer'), + // using `XREADGROUP` and not `XGROUP CREATECONSUMER` because the latter was introduced in Redis 6.2 + client.xReadGroup('group', 'consumer', { + key: 'key', + id: '0-0' + }), client.xInfoConsumers('key', 'group') ]); diff --git a/packages/client/lib/commands/XINFO_GROUPS.spec.ts b/packages/client/lib/commands/XINFO_GROUPS.spec.ts index 7ac02972d6..59326898a5 100644 --- a/packages/client/lib/commands/XINFO_GROUPS.spec.ts +++ b/packages/client/lib/commands/XINFO_GROUPS.spec.ts @@ -25,8 +25,8 @@ describe('XINFO GROUPS', () => { consumers: 0, pending: 0, 'last-delivered-id': '0-0', - 'entries-read': null, - lag: 0 + 'entries-read': testUtils.isVersionGreaterThan([7, 0]) ? null : undefined, + lag: testUtils.isVersionGreaterThan([7, 0]) ? 0 : undefined }] ); }, { diff --git a/packages/client/lib/commands/XINFO_STREAM.spec.ts b/packages/client/lib/commands/XINFO_STREAM.spec.ts index 99370fb97f..630d25c396 100644 --- a/packages/client/lib/commands/XINFO_STREAM.spec.ts +++ b/packages/client/lib/commands/XINFO_STREAM.spec.ts @@ -23,9 +23,11 @@ describe('XINFO STREAM', () => { 'radix-tree-keys': 0, 'radix-tree-nodes': 1, 'last-generated-id': '0-0', - 'max-deleted-entry-id': '0-0', - 'entries-added': 0, - 'recorded-first-entry-id': '0-0', + ...testUtils.isVersionGreaterThan([7, 0]) && { + 'max-deleted-entry-id': '0-0', + 'entries-added': 0, + 'recorded-first-entry-id': '0-0', + }, groups: 1, 'first-entry': null, 'last-entry': null diff --git a/packages/client/lib/commands/XINFO_STREAM.ts b/packages/client/lib/commands/XINFO_STREAM.ts index 00b6b0aa4e..93416ae40a 100644 --- a/packages/client/lib/commands/XINFO_STREAM.ts +++ b/packages/client/lib/commands/XINFO_STREAM.ts @@ -1,26 +1,16 @@ import { TuplesToMapReply, BlobStringReply, NumberReply, NullReply, Resp2Reply, Command, RespType, RESP_TYPES, RedisArgument } from '../RESP/types'; import { StreamMessageRawReply, transformStreamMessageReply } from './generic-transformers'; -export type XInfoStreamRawReply = TuplesToMapReply<[ - [BlobStringReply<'length'>, NumberReply], - [BlobStringReply<'radix-tree-keys'>, NumberReply], - [BlobStringReply<'radix-tree-nodes'>, NumberReply], - [BlobStringReply<'last-generated-id'>, BlobStringReply], - [BlobStringReply<'max-deleted-entry-id'>, BlobStringReply], - [BlobStringReply<'entries-added'>, NumberReply], - [BlobStringReply<'recorded-first-entry-id'>, BlobStringReply], - [BlobStringReply<'groups'>, NumberReply], - [BlobStringReply<'first-entry'>, StreamMessageRawReply | NullReply], - [BlobStringReply<'last-entry'>, StreamMessageRawReply | NullReply] -]>; - export type XInfoStreamReply = TuplesToMapReply<[ [BlobStringReply<'length'>, NumberReply], [BlobStringReply<'radix-tree-keys'>, NumberReply], [BlobStringReply<'radix-tree-nodes'>, NumberReply], [BlobStringReply<'last-generated-id'>, BlobStringReply], + /** added in 7.2 */ [BlobStringReply<'max-deleted-entry-id'>, BlobStringReply], + /** added in 7.2 */ [BlobStringReply<'entries-added'>, NumberReply], + /** added in 7.2 */ [BlobStringReply<'recorded-first-entry-id'>, BlobStringReply], [BlobStringReply<'groups'>, NumberReply], [BlobStringReply<'first-entry'>, ReturnType | NullReply], @@ -34,22 +24,27 @@ export default { return ['XINFO', 'STREAM', key]; }, transformReply: { - 2(reply: Resp2Reply) { - return { - length: reply[1], - 'radix-tree-keys': reply[3], - 'radix-tree-nodes': reply[5], - 'last-generated-id': reply[7], - 'max-deleted-entry-id': reply[9], - 'entries-added': reply[11], - 'recorded-first-entry-id': reply[13], - groups: reply[15], - 'first-entry': transformEntry(reply[17]), - 'last-entry': transformEntry(reply[19]) - }; + // TODO: is there a "type safe" way to do it? + 2(reply: any) { + const parsedReply: Partial = {}; + + for (let i = 0; i < reply.length; i += 2) { + switch (reply[i]) { + case 'first-entry': + case 'last-entry': + parsedReply[reply[i] as ('first-entry' | 'last-entry')] = transformEntry(reply[i + 1]) as any; + break; + + default: + parsedReply[reply[i] as keyof typeof parsedReply] = reply[i + 1]; + break; + } + } + + return parsedReply as XInfoStreamReply['DEFAULT']; }, - 3(reply: any) { // TODO: is there a "type safe" way to do it? - if (reply instanceof Map) { + 3(reply: any) { + if (reply instanceof Map) { reply.set( 'first-entry', transformEntry(reply.get('first-entry')) diff --git a/packages/client/lib/commands/XPENDING_RANGE.spec.ts b/packages/client/lib/commands/XPENDING_RANGE.spec.ts index ef25b9840c..586914d7b4 100644 --- a/packages/client/lib/commands/XPENDING_RANGE.spec.ts +++ b/packages/client/lib/commands/XPENDING_RANGE.spec.ts @@ -41,11 +41,10 @@ describe('XPENDING RANGE', () => { }); testUtils.testAll('xPendingRange', async client => { - const [, , id, , reply] = await Promise.all([ + const [, id, , reply] = await Promise.all([ client.xGroupCreate('key', 'group', '$', { MKSTREAM: true }), - client.xGroupCreateConsumer('key', 'group', 'consumer'), client.xAdd('key', '*', { field: 'value' }), client.xReadGroup('group', 'consumer', { key: 'key', diff --git a/packages/client/lib/commands/ZSCAN.spec.ts b/packages/client/lib/commands/ZSCAN.spec.ts index f420fc0806..d4d5f56546 100644 --- a/packages/client/lib/commands/ZSCAN.spec.ts +++ b/packages/client/lib/commands/ZSCAN.spec.ts @@ -6,14 +6,14 @@ describe('ZSCAN', () => { describe('transformArguments', () => { it('cusror only', () => { assert.deepEqual( - ZSCAN.transformArguments('key', 0), + ZSCAN.transformArguments('key', '0'), ['ZSCAN', 'key', '0'] ); }); it('with MATCH', () => { assert.deepEqual( - ZSCAN.transformArguments('key', 0, { + ZSCAN.transformArguments('key', '0', { MATCH: 'pattern' }), ['ZSCAN', 'key', '0', 'MATCH', 'pattern'] @@ -22,7 +22,7 @@ describe('ZSCAN', () => { it('with COUNT', () => { assert.deepEqual( - ZSCAN.transformArguments('key', 0, { + ZSCAN.transformArguments('key', '0', { COUNT: 1 }), ['ZSCAN', 'key', '0', 'COUNT', '1'] @@ -31,7 +31,7 @@ describe('ZSCAN', () => { it('with MATCH & COUNT', () => { assert.deepEqual( - ZSCAN.transformArguments('key', 0, { + ZSCAN.transformArguments('key', '0', { MATCH: 'pattern', COUNT: 1 }), @@ -42,9 +42,9 @@ describe('ZSCAN', () => { testUtils.testWithClient('zScan', async client => { assert.deepEqual( - await client.zScan('key', 0), + await client.zScan('key', '0'), { - cursor: 0, + cursor: '0', members: [] } ); diff --git a/packages/client/lib/commands/ZSCAN.ts b/packages/client/lib/commands/ZSCAN.ts index 1938e67da2..68186afc0e 100644 --- a/packages/client/lib/commands/ZSCAN.ts +++ b/packages/client/lib/commands/ZSCAN.ts @@ -12,14 +12,14 @@ export default { IS_READ_ONLY: true, transformArguments( key: RedisArgument, - cursor: number, + cursor: RedisArgument, options?: ScanCommonOptions ) { return pushScanArguments(['ZSCAN', key], cursor, options); }, transformReply([cursor, rawMembers]: [BlobStringReply, ArrayReply]) { return { - cursor: Number(cursor), + cursor, members: transformSortedSetReply[2](rawMembers) }; } diff --git a/packages/client/lib/commands/generic-transformers.ts b/packages/client/lib/commands/generic-transformers.ts index 8298a966d8..50fa903ea1 100644 --- a/packages/client/lib/commands/generic-transformers.ts +++ b/packages/client/lib/commands/generic-transformers.ts @@ -1,4 +1,14 @@ -import { ArrayReply, BlobStringReply, CommandArguments, DoubleReply, NullReply, RedisArgument, Resp2Reply, TuplesReply } from '../RESP/types'; +import { ArrayReply, BlobStringReply, BooleanReply, CommandArguments, DoubleReply, NullReply, NumberReply, RedisArgument, TuplesReply } from '../RESP/types'; + +export const transformBooleanReply = { + 2: (reply: NumberReply<0 | 1>) => reply === 1, + 3: undefined as unknown as () => BooleanReply +}; + +export const transformBooleanArrayReply = { + 2: (reply: ArrayReply>) => reply.map(transformBooleanReply[2]), + 3: undefined as unknown as () => ArrayReply +}; export type BitValue = 0 | 1; @@ -24,11 +34,15 @@ export function transformStringDoubleArgument(num: RedisArgument | number): Redi export const transformDoubleReply = { 2: (reply: BlobStringReply) => { switch (reply.toString()) { + case 'inf': case '+inf': return Infinity; case '-inf': return -Infinity; + + case 'nan': + return NaN; default: return Number(reply); @@ -37,6 +51,11 @@ export const transformDoubleReply = { 3: undefined as unknown as () => DoubleReply }; +export const transformDoubleArrayReply = { + 2: (reply: Array) => reply.map(transformDoubleReply[2]), + 3: undefined as unknown as () => ArrayReply +} + export const transformNullableDoubleReply = { 2: (reply: BlobStringReply | NullReply) => { if (reply === null) return null; diff --git a/packages/client/lib/commands/index.ts b/packages/client/lib/commands/index.ts index cc98529c59..d8eb66b66a 100644 --- a/packages/client/lib/commands/index.ts +++ b/packages/client/lib/commands/index.ts @@ -1,3 +1,4 @@ +import type { RedisCommands } from '../RESP/types'; import ACL_CAT from './ACL_CAT'; import ACL_DELUSER from './ACL_DELUSER'; import ACL_DRYRUN from './ACL_DRYRUN'; @@ -66,6 +67,12 @@ import CLUSTER_SAVECONFIG from './CLUSTER_SAVECONFIG'; import CLUSTER_SET_CONFIG_EPOCH from './CLUSTER_SET-CONFIG-EPOCH'; import CLUSTER_SETSLOT from './CLUSTER_SETSLOT'; import CLUSTER_SLOTS from './CLUSTER_SLOTS'; +import COMMAND_COUNT from './COMMAND_COUNT'; +import COMMAND_GETKEYS from './COMMAND_GETKEYS'; +import COMMAND_GETKEYSANDFLAGS from './COMMAND_GETKEYSANDFLAGS'; +// import COMMAND_INFO from './COMMAND_INFO'; +// import COMMAND_LIST from './COMMAND_LIST'; +// import COMMAND from './COMMAND'; import CONFIG_GET from './CONFIG_GET'; import CONFIG_RESETASTAT from './CONFIG_RESETSTAT'; import CONFIG_REWRITE from './CONFIG_REWRITE'; @@ -318,973 +325,6 @@ import ZSCORE from './ZSCORE'; import ZUNION_WITHSCORES from './ZUNION_WITHSCORES'; import ZUNION from './ZUNION'; import ZUNIONSTORE from './ZUNIONSTORE'; -import { Command } from '../RESP/types'; - -type ACL_CAT = typeof import('./ACL_CAT').default; -type ACL_DELUSER = typeof import('./ACL_DELUSER').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 BZMPOP = typeof import('./BZMPOP').default; -type BZPOPMAX = typeof import('./BZPOPMAX').default; -type BZPOPMIN = typeof import('./BZPOPMIN').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 CLIENT_TRACKING = typeof import('./CLIENT_TRACKING').default; -type CLIENT_TRACKINGINFO = typeof import('./CLIENT_TRACKINGINFO').default; -type CLIENT_UNPAUSE = typeof import('./CLIENT_UNPAUSE').default; -type CLUSTER_ADDSLOTS = typeof import('./CLUSTER_ADDSLOTS').default; -type CLUSTER_ADDSLOTSRANGE = typeof import('./CLUSTER_ADDSLOTSRANGE').default; -type CLUSTER_BUMPEPOCH = typeof import('./CLUSTER_BUMPEPOCH').default; -type CLUSTER_COUNT_FAILURE_REPORTS = typeof import('./CLUSTER_COUNT-FAILURE-REPORTS').default; -type CLUSTER_COUNTKEYSINSLOT = typeof import('./CLUSTER_COUNTKEYSINSLOT').default; -type CLUSTER_DELSLOTS = typeof import('./CLUSTER_DELSLOTS').default; -type CLUSTER_DELSLOTSRANGE = typeof import('./CLUSTER_DELSLOTSRANGE').default; -type CLUSTER_FAILOVER = typeof import('./CLUSTER_FAILOVER').default; -type CLUSTER_FLUSHSLOTS = typeof import('./CLUSTER_FLUSHSLOTS').default; -type CLUSTER_FORGET = typeof import('./CLUSTER_FORGET').default; -type CLUSTER_GETKEYSINSLOT = typeof import('./CLUSTER_GETKEYSINSLOT').default; -// type CLUSTER_INFO = typeof import('./CLUSTER_INFO').default; -type CLUSTER_KEYSLOT = typeof import('./CLUSTER_KEYSLOT').default; -type CLUSTER_LINKS = typeof import('./CLUSTER_LINKS').default; -type CLUSTER_MEET = typeof import('./CLUSTER_MEET').default; -type CLUSTER_MYID = typeof import('./CLUSTER_MYID').default; -// type CLUSTER_NODES = typeof import('./CLUSTER_NODES').default; -// type CLUSTER_REPLICAS = typeof import('./CLUSTER_REPLICAS').default; -type CLUSTER_REPLICATE = typeof import('./CLUSTER_REPLICATE').default; -type CLUSTER_RESET = typeof import('./CLUSTER_RESET').default; -type CLUSTER_SAVECONFIG = typeof import('./CLUSTER_SAVECONFIG').default; -type CLUSTER_SET_CONFIG_EPOCH = typeof import('./CLUSTER_SET-CONFIG-EPOCH').default; -type CLUSTER_SETSLOT = typeof import('./CLUSTER_SETSLOT').default; -type CLUSTER_SLOTS = typeof import('./CLUSTER_SLOTS').default; -type CONFIG_GET = typeof import('./CONFIG_GET').default; -type CONFIG_RESETASTAT = typeof import('./CONFIG_RESETSTAT').default; -type CONFIG_REWRITE = typeof import('./CONFIG_REWRITE').default; -type CONFIG_SET = typeof import('./CONFIG_SET').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 LATENCY_DOCTOR = typeof import('./LATENCY_DOCTOR').default; -type LATENCY_GRAPH = typeof import('./LATENCY_GRAPH').default; -type LATENCY_LATEST = typeof import('./LATENCY_LATEST').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 ROLE = typeof import('./ROLE').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 SWAPDB = typeof import('./SWAPDB').default; -type TIME = typeof import('./TIME').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 XAUTOCLAIM_JUSTID = typeof import('./XAUTOCLAIM_JUSTID').default; -type XAUTOCLAIM = typeof import('./XAUTOCLAIM').default; -type XCLAIM_JUSTID = typeof import('./XCLAIM_JUSTID').default; -type XCLAIM = typeof import('./XCLAIM').default; -type XDEL = typeof import('./XDEL').default; -type XGROUP_CREATE = typeof import('./XGROUP_CREATE').default; -type XGROUP_CREATECONSUMER = typeof import('./XGROUP_CREATECONSUMER').default; -type XGROUP_DELCONSUMER = typeof import('./XGROUP_DELCONSUMER').default; -type XGROUP_DESTROY = typeof import('./XGROUP_DESTROY').default; -type XGROUP_SETID = typeof import('./XGROUP_SETID').default; -type XINFO_CONSUMERS = typeof import('./XINFO_CONSUMERS').default; -type XINFO_GROUPS = typeof import('./XINFO_GROUPS').default; -type XINFO_STREAM = typeof import('./XINFO_STREAM').default; -type XLEN = typeof import('./XLEN').default; -type XPENDING_RANGE = typeof import('./XPENDING_RANGE').default; -type XPENDING = typeof import('./XPENDING').default; -type XRANGE = typeof import('./XRANGE').default; -type XREAD = typeof import('./XREAD').default; -type XREADGROUP = typeof import('./XREADGROUP').default; -type XREVRANGE = typeof import('./XREVRANGE').default; -type XSETID = typeof import('./XSETID').default; -type XTRIM = typeof import('./XTRIM').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 ZMPOP = typeof import('./ZMPOP').default; -type ZMSCORE = typeof import('./ZMSCORE').default; -type ZPOPMAX_COUNT = typeof import('./ZPOPMAX_COUNT').default; -type ZPOPMAX = typeof import('./ZPOPMAX').default; -type ZPOPMIN_COUNT = typeof import('./ZPOPMIN_COUNT').default; -type ZPOPMIN = typeof import('./ZPOPMIN').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_WITHSCORES = typeof import('./ZRANGE_WITHSCORES').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 ZRANGESTORE = typeof import('./ZRANGESTORE').default; -type ZREMRANGEBYSCORE = typeof import('./ZREMRANGEBYSCORE').default; -type ZRANK_WITHSCORE = typeof import('./ZRANK_WITHSCORE').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_DELUSER: ACL_DELUSER; - aclDelUser: ACL_DELUSER; - 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; - BZMPOP: BZMPOP; - bzmPop: BZMPOP; - BZPOPMAX: BZPOPMAX; - bzPopMax: BZPOPMAX; - BZPOPMIN: BZPOPMIN; - bzPopMin: BZPOPMIN; - 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; - CLIENT_TRACKING: CLIENT_TRACKING; - clientTracking: CLIENT_TRACKING; - CLIENT_TRACKINGINFO: CLIENT_TRACKINGINFO; - clientTrackingInfo: CLIENT_TRACKINGINFO; - CLIENT_UNPAUSE: CLIENT_UNPAUSE; - clientUnpause: CLIENT_UNPAUSE; - CLUSTER_ADDSLOTS: CLUSTER_ADDSLOTS; - clusterAddSlots: CLUSTER_ADDSLOTS; - CLUSTER_ADDSLOTSRANGE: CLUSTER_ADDSLOTSRANGE; - clusterAddSlotsRange: CLUSTER_ADDSLOTSRANGE; - CLUSTER_BUMPEPOCH: CLUSTER_BUMPEPOCH; - clusterBumpEpoch: CLUSTER_BUMPEPOCH; - 'CLUSTER_COUNT-FAILURE-REPORTS': CLUSTER_COUNT_FAILURE_REPORTS; - clusterCountFailureReports: CLUSTER_COUNT_FAILURE_REPORTS; - CLUSTER_COUNTKEYSINSLOT: CLUSTER_COUNTKEYSINSLOT; - clusterCountKeysInSlot: CLUSTER_COUNTKEYSINSLOT; - CLUSTER_DELSLOTS: CLUSTER_DELSLOTS; - clusterDelSlots: CLUSTER_DELSLOTS; - CLUSTER_DELSLOTSRANGE: CLUSTER_DELSLOTSRANGE; - clusterDelSlotsRange: CLUSTER_DELSLOTSRANGE; - CLUSTER_FAILOVER: CLUSTER_FAILOVER; - clusterFailover: CLUSTER_FAILOVER; - CLUSTER_FLUSHSLOTS: CLUSTER_FLUSHSLOTS; - clusterFlushSlots: CLUSTER_FLUSHSLOTS; - CLUSTER_FORGET: CLUSTER_FORGET; - clusterForget: CLUSTER_FORGET; - CLUSTER_GETKEYSINSLOT: CLUSTER_GETKEYSINSLOT; - clusterGetKeysInSlot: CLUSTER_GETKEYSINSLOT; - // CLUSTER_INFO: CLUSTER_INFO; - // clusterInfo: CLUSTER_INFO; - CLUSTER_KEYSLOT: CLUSTER_KEYSLOT; - clusterKeySlot: CLUSTER_KEYSLOT; - CLUSTER_LINKS: CLUSTER_LINKS; - clusterLinks: CLUSTER_LINKS; - CLUSTER_MEET: CLUSTER_MEET; - clusterMeet: CLUSTER_MEET; - CLUSTER_MYID: CLUSTER_MYID; - clusterMyId: CLUSTER_MYID; - // CLUSTER_NODES: CLUSTER_NODES; - // clusterNodes: CLUSTER_NODES; - // CLUSTER_REPLICAS: CLUSTER_REPLICAS; - // clusterReplicas: CLUSTER_REPLICAS; - CLUSTER_REPLICATE: CLUSTER_REPLICATE; - clusterReplicate: CLUSTER_REPLICATE; - CLUSTER_RESET: CLUSTER_RESET; - clusterReset: CLUSTER_RESET; - CLUSTER_SAVECONFIG: CLUSTER_SAVECONFIG; - clusterSaveConfig: CLUSTER_SAVECONFIG; - 'CLUSTER_SET-CONFIG-EPOCH': CLUSTER_SET_CONFIG_EPOCH; - clusterSetConfigEpoch: CLUSTER_SET_CONFIG_EPOCH; - CLUSTER_SETSLOT: CLUSTER_SETSLOT; - clusterSetSlot: CLUSTER_SETSLOT; - CLUSTER_SLOTS: CLUSTER_SLOTS; - clusterSlots: CLUSTER_SLOTS; - CONFIG_GET: CONFIG_GET; - configGet: CONFIG_GET; - CONFIG_RESETASTAT: CONFIG_RESETASTAT; - configResetStat: CONFIG_RESETASTAT; - CONFIG_REWRITE: CONFIG_REWRITE; - configRewrite: CONFIG_REWRITE; - CONFIG_SET: CONFIG_SET; - configSet: CONFIG_SET; - 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; - LATENCY_DOCTOR: LATENCY_DOCTOR; - latencyDoctor: LATENCY_DOCTOR; - LATENCY_GRAPH: LATENCY_GRAPH; - latencyGraph: LATENCY_GRAPH; - LATENCY_LATEST: LATENCY_LATEST; - latencyLatest: LATENCY_LATEST; - 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; - ROLE: ROLE; - role: ROLE; - 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; - SWAPDB: SWAPDB; - swapDb: SWAPDB; - TIME: TIME; - time: TIME; - 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; - XAUTOCLAIM_JUSTID: XAUTOCLAIM_JUSTID; - xAutoClaimJustId: XAUTOCLAIM_JUSTID; - XAUTOCLAIM: XAUTOCLAIM; - xAutoClaim: XAUTOCLAIM; - XCLAIM_JUSTID: XCLAIM_JUSTID; - xClaimJustId: XCLAIM_JUSTID; - XCLAIM: XCLAIM; - xClaim: XCLAIM; - XDEL: XDEL; - xDel: XDEL; - XGROUP_CREATE: XGROUP_CREATE; - xGroupCreate: XGROUP_CREATE; - XGROUP_CREATECONSUMER: XGROUP_CREATECONSUMER; - xGroupCreateConsumer: XGROUP_CREATECONSUMER; - XGROUP_DELCONSUMER: XGROUP_DELCONSUMER; - xGroupDelConsumer: XGROUP_DELCONSUMER; - XGROUP_DESTROY: XGROUP_DESTROY; - xGroupDestroy: XGROUP_DESTROY; - XGROUP_SETID: XGROUP_SETID; - xGroupSetId: XGROUP_SETID; - XINFO_CONSUMERS: XINFO_CONSUMERS; - xInfoConsumers: XINFO_CONSUMERS; - XINFO_GROUPS: XINFO_GROUPS; - xInfoGroups: XINFO_GROUPS; - XINFO_STREAM: XINFO_STREAM; - xInfoStream: XINFO_STREAM; - XLEN: XLEN; - xLen: XLEN; - XPENDING_RANGE: XPENDING_RANGE; - xPendingRange: XPENDING_RANGE; - XPENDING: XPENDING; - xPending: XPENDING; - XRANGE: XRANGE; - xRange: XRANGE; - XREAD: XREAD; - xRead: XREAD; - XREADGROUP: XREADGROUP; - xReadGroup: XREADGROUP; - XREVRANGE: XREVRANGE; - xRevRange: XREVRANGE; - XSETID: XSETID; - xSetId: XSETID; - XTRIM: XTRIM; - xTrim: XTRIM; - 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; - ZMPOP: ZMPOP; - zmPop: ZMPOP; - ZMSCORE: ZMSCORE; - zmScore: ZMSCORE; - ZPOPMAX_COUNT: ZPOPMAX_COUNT; - zPopMaxCount: ZPOPMAX_COUNT; - ZPOPMAX: ZPOPMAX; - zPopMax: ZPOPMAX; - ZPOPMIN_COUNT: ZPOPMIN_COUNT; - zPopMinCount: ZPOPMIN_COUNT; - ZPOPMIN: ZPOPMIN; - zPopMin: ZPOPMIN; - ZRANDMEMBER_COUNT_WITHSCORES: ZRANDMEMBER_COUNT_WITHSCORES; - zRandMemberCountWithScores: ZRANDMEMBER_COUNT_WITHSCORES; - ZRANDMEMBER_COUNT: ZRANDMEMBER_COUNT; - zRandMemberCount: ZRANDMEMBER_COUNT; - ZRANDMEMBER: ZRANDMEMBER; - zRandMember: ZRANDMEMBER; - ZRANGE_WITHSCORES: ZRANGE_WITHSCORES; - zRangeWithScores: ZRANGE_WITHSCORES; - ZRANGE: ZRANGE; - zRange: ZRANGE; - ZRANGEBYLEX: ZRANGEBYLEX; - zRangeByLex: ZRANGEBYLEX; - ZRANGEBYSCORE_WITHSCORES: ZRANGEBYSCORE_WITHSCORES; - zRangeByScoreWithScores: ZRANGEBYSCORE_WITHSCORES; - ZRANGEBYSCORE: ZRANGEBYSCORE; - zRangeByScore: ZRANGEBYSCORE; - ZRANGESTORE: ZRANGESTORE; - zRangeStore: ZRANGESTORE; - ZRANK_WITHSCORE: ZRANK_WITHSCORE; - zRankWithScore: ZRANK_WITHSCORE; - 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, @@ -1423,6 +463,18 @@ export default { clusterSetSlot: CLUSTER_SETSLOT, CLUSTER_SLOTS, clusterSlots: CLUSTER_SLOTS, + COMMAND_COUNT, + commandCount: COMMAND_COUNT, + COMMAND_GETKEYS, + commandGetKeys: COMMAND_GETKEYS, + COMMAND_GETKEYSANDFLAGS, + commandGetKeysAndFlags: COMMAND_GETKEYSANDFLAGS, + // COMMAND_INFO, + // commandInfo: COMMAND_INFO, + // COMMAND_LIST, + // commandList: COMMAND_LIST, + // COMMAND, + // command: COMMAND, CONFIG_GET, configGet: CONFIG_GET, CONFIG_RESETASTAT, @@ -1929,4 +981,4 @@ export default { zUnion: ZUNION, ZUNIONSTORE, zUnionStore: ZUNIONSTORE -} satisfies Record as Commands; +} as const satisfies RedisCommands; diff --git a/packages/client/lib/test-utils.ts b/packages/client/lib/test-utils.ts index 4aca735c92..e4c86c2f4c 100644 --- a/packages/client/lib/test-utils.ts +++ b/packages/client/lib/test-utils.ts @@ -61,3 +61,9 @@ export async function waitTillBeenCalled(spy: SinonSpy): Promise { await setTimeout(50); } while (spy.callCount === calls); } + +export const BLOCKING_MIN_VALUE = ( + utils.isVersionGreaterThan([7]) ? Number.MIN_VALUE : + utils.isVersionGreaterThan([6]) ? 0.01 : + 1 +); diff --git a/packages/client/tsconfig.json b/packages/client/tsconfig.json index 3271cf400a..5e044cbaa1 100644 --- a/packages/client/tsconfig.json +++ b/packages/client/tsconfig.json @@ -11,9 +11,6 @@ "./lib/test-utils.ts", "./lib/**/*.spec.ts" ], - "ts-node": { - "transpileOnly": true - }, "typedocOptions": { "entryPoints": [ "./index.ts", diff --git a/tsconfig.base.json b/tsconfig.base.json index f674e2e5c0..8e9d90d31c 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -6,6 +6,7 @@ "allowJs": true }, "ts-node": { - "files": true + "files": true, + "transpileOnly": true } } diff --git a/tsconfig.json b/tsconfig.json index 53bc24d883..3c2207d4ff 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,10 +3,10 @@ "path": "./packages/client" }, { "path": "./packages/test-utils" + }, { + "path": "./packages/bloom" }], "todo": [{ - "path": "./packages/bloom" - }, { "path": "./packages/graph" }, { "path": "./packages/json"