1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00
This commit is contained in:
Leibale
2023-11-09 11:12:41 -05:00
parent 98970fab2e
commit a5a4cb45ea
15 changed files with 222 additions and 261 deletions

View File

@@ -134,7 +134,8 @@ await cluster.multi()
- `CLIENT KILL`: `enum ClientKillFilters` -> `const CLIENT_KILL_FILTERS` [^enum-to-constants] - `CLIENT KILL`: `enum ClientKillFilters` -> `const CLIENT_KILL_FILTERS` [^enum-to-constants]
- `CLUSTER FAILOVER`: `enum FailoverModes` -> `const FAILOVER_MODES` [^enum-to-constants] - `CLUSTER FAILOVER`: `enum FailoverModes` -> `const FAILOVER_MODES` [^enum-to-constants]
- `CLIENT TRACKINGINFO`: `flags` in RESP2 - `Set<string>` -> `Array<string>` (to match RESP3 default type mapping) - `CLIENT TRACKINGINFO`: `flags` in RESP2 - `Set<string>` -> `Array<string>` (to match RESP3 default type mapping)
- `CLUSETER SETSLOT`: `ClusterSlotStates` -> `CLUSTER_SLOT_STATES` [^enum-to-constants] - `CLUSTER INFO`:
- `CLUSTER SETSLOT`: `ClusterSlotStates` -> `CLUSTER_SLOT_STATES` [^enum-to-constants]
- `CLUSTER RESET`: the second argument is `{ mode: string; }` instead of `string` [^future-proofing] - `CLUSTER RESET`: the second argument is `{ mode: string; }` instead of `string` [^future-proofing]
- `CLUSTER FAILOVER`: `enum FailoverModes` -> `const FAILOVER_MODES` [^enum-to-constants], the second argument is `{ mode: string; }` instead of `string` [^future-proofing] - `CLUSTER FAILOVER`: `enum FailoverModes` -> `const FAILOVER_MODES` [^enum-to-constants], the second argument is `{ mode: string; }` instead of `string` [^future-proofing]
- `CLUSTER LINKS`: `createTime` -> `create-time`, `sendBufferAllocated` -> `send-buffer-allocated`, `sendBufferUsed` -> `send-buffer-used` [^map-keys] - `CLUSTER LINKS`: `createTime` -> `create-time`, `sendBufferAllocated` -> `send-buffer-allocated`, `sendBufferUsed` -> `send-buffer-used` [^map-keys]
@@ -145,7 +146,7 @@ await cluster.multi()
- `HEXISTS`: `boolean` -> `number` [^boolean-to-number] - `HEXISTS`: `boolean` -> `number` [^boolean-to-number]
- `HRANDFIELD_COUNT_WITHVALUES`: `Record<BlobString, BlobString>` -> `Array<{ field: BlobString; value: BlobString; }>` (it can return duplicates). - `HRANDFIELD_COUNT_WITHVALUES`: `Record<BlobString, BlobString>` -> `Array<{ field: BlobString; value: BlobString; }>` (it can return duplicates).
- `HSETNX`: `boolean` -> `number` [^boolean-to-number] - `HSETNX`: `boolean` -> `number` [^boolean-to-number]
- `INFO`:
- `LCS IDX`: `length` has been changed to `len`, `matches` has been changed from `Array<{ key1: RangeReply; key2: RangeReply; }>` to `Array<[key1: RangeReply, key2: RangeReply]>` - `LCS IDX`: `length` has been changed to `len`, `matches` has been changed from `Array<{ key1: RangeReply; key2: RangeReply; }>` to `Array<[key1: RangeReply, key2: RangeReply]>`

View File

@@ -1,24 +1,26 @@
// import { strict as assert } from 'node:assert'; import { strict as assert } from 'node:assert';
// import testUtils, { GLOBAL } from '../../test-utils'; import testUtils, { GLOBAL } from '../../test-utils';
// import { transformArguments } from './INFO'; import INFO from './INFO';
// describe('BF INFO', () => { describe('BF.INFO', () => {
// it('transformArguments', () => { it('transformArguments', () => {
// assert.deepEqual( assert.deepEqual(
// transformArguments('bloom'), INFO.transformArguments('bloom'),
// ['BF.INFO', 'bloom'] ['BF.INFO', 'bloom']
// ); );
// }); });
// testUtils.testWithClient('client.bf.info', async client => { testUtils.testWithClient('client.bf.info', async client => {
// await client.bf.reserve('key', 0.01, 100); const [, reply] = await Promise.all([
client.bf.reserve('key', 0.01, 100),
client.bf.info('key')
]);
// const info = await client.bf.info('key'); assert.equal(typeof reply, 'object');
// assert.equal(typeof info, 'object'); assert.equal(reply.capacity, 100);
// assert.equal(info.capacity, 100); assert.equal(typeof reply.size, 'number');
// assert.equal(typeof info.size, 'number'); assert.equal(typeof reply.numberOfFilters, 'number');
// assert.equal(typeof info.numberOfFilters, 'number'); assert.equal(typeof reply.numberOfInsertedItems, 'number');
// assert.equal(typeof info.numberOfInsertedItems, 'number'); assert.equal(typeof reply.expansionRate, 'number');
// assert.equal(typeof info.expansionRate, 'number'); }, GLOBAL.SERVERS.OPEN);
// }, GLOBAL.SERVERS.OPEN); });
// });

View File

@@ -1,57 +1,11 @@
// // export type InfoRawReply = [ import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
// // _: string,
// // capacity: number,
// // _: string,
// // size: number,
// // _: string,
// // numberOfFilters: number,
// // _: string,
// // numberOfInsertedItems: number,
// // _: string,
// // expansionRate: number,
// // ];
// // export interface InfoReply { export default {
// // capacity: number; FIRST_KEY_INDEX: 1,
// // size: number; IS_READ_ONLY: true,
// // numberOfFilters: number; transformArguments(key: RedisArgument) {
// // numberOfInsertedItems: number; return ['BF.INFO', key];
// // expansionRate: number; },
// // } // TODO
transformReply: undefined as unknown as () => any
// // export function transformReply(reply: InfoRawReply): InfoReply { } as const satisfies Command;
// // return {
// // capacity: reply[1],
// // size: reply[3],
// // numberOfFilters: reply[5],
// // numberOfInsertedItems: reply[7],
// // expansionRate: reply[9]
// // };
// // }
// import { RedisArgument, Command, TuplesToMapReply, BlobStringReply, NumberReply } from '@redis/client/dist/lib/RESP/types';
// import { transformBooleanArrayReply } from '@redis/client/dist/lib/commands/generic-transformers';
// export type BfInfoReply = TuplesToMapReply<[
// [BlobStringReply<'Capacity'>, NumberReply],
// [BlobStringReply<'Size'>, NumberReply],
// [BlobStringReply<'Number of filters'>, NumberReply],
// ]>;
// export default {
// FIRST_KEY_INDEX: 1,
// IS_READ_ONLY: true,
// transformArguments(key: RedisArgument) {
// return ['BF.INFO', key];
// },
// transformReply: {
// 2: () => {
// },
// 3: () => {
// }
// }
// } as const satisfies Command;

View File

@@ -2,7 +2,7 @@ import type { RedisCommands } from '@redis/client/dist/lib/RESP/types';
import ADD from './ADD'; import ADD from './ADD';
import CARD from './CARD'; import CARD from './CARD';
import EXISTS from './EXISTS'; import EXISTS from './EXISTS';
// import INFO from './INFO'; import INFO from './INFO';
import INSERT from './INSERT'; import INSERT from './INSERT';
import LOADCHUNK from './LOADCHUNK'; import LOADCHUNK from './LOADCHUNK';
import MADD from './MADD'; import MADD from './MADD';
@@ -17,8 +17,8 @@ export default {
card: CARD, card: CARD,
EXISTS, EXISTS,
exists: EXISTS, exists: EXISTS,
// INFO, INFO,
// info: INFO, info: INFO,
INSERT, INSERT,
insert: INSERT, insert: INSERT,
LOADCHUNK, LOADCHUNK,

View File

@@ -1,27 +1,29 @@
// import { strict as assert } from 'node:assert'; import { strict as assert } from 'node:assert';
// import testUtils, { GLOBAL } from '../../test-utils'; import testUtils, { GLOBAL } from '../../test-utils';
// import { transformArguments } from './INFO'; import INFO from './INFO';
// describe('CF INFO', () => { describe('CF.INFO', () => {
// it('transformArguments', () => { it('transformArguments', () => {
// assert.deepEqual( assert.deepEqual(
// transformArguments('cuckoo'), INFO.transformArguments('cuckoo'),
// ['CF.INFO', 'cuckoo'] ['CF.INFO', 'cuckoo']
// ); );
// }); });
// testUtils.testWithClient('client.cf.info', async client => { testUtils.testWithClient('client.cf.info', async client => {
// await client.cf.reserve('key', 4); const [, reply] = await Promise.all([
client.cf.reserve('key', 4),
client.cf.info('key')
]);
// const info = await client.cf.info('key'); assert.equal(typeof reply, 'object');
// assert.equal(typeof info, 'object'); assert.equal(typeof reply.size, 'number');
// assert.equal(typeof info.size, 'number'); assert.equal(typeof reply.numberOfBuckets, 'number');
// assert.equal(typeof info.numberOfBuckets, 'number'); assert.equal(typeof reply.numberOfFilters, 'number');
// assert.equal(typeof info.numberOfFilters, 'number'); assert.equal(typeof reply.numberOfInsertedItems, 'number');
// assert.equal(typeof info.numberOfInsertedItems, 'number'); assert.equal(typeof reply.numberOfDeletedItems, 'number');
// assert.equal(typeof info.numberOfDeletedItems, 'number'); assert.equal(typeof reply.bucketSize, 'number');
// assert.equal(typeof info.bucketSize, 'number'); assert.equal(typeof reply.expansionRate, 'number');
// assert.equal(typeof info.expansionRate, 'number'); assert.equal(typeof reply.maxIteration, 'number');
// assert.equal(typeof info.maxIteration, 'number'); }, GLOBAL.SERVERS.OPEN);
// }, GLOBAL.SERVERS.OPEN); });
// });

View File

@@ -1,50 +1,53 @@
// export const FIRST_KEY_INDEX = 1; import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
// export const IS_READ_ONLY = true; export default {
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: true,
transformArguments(key: RedisArgument) {
return ['CF.INFO', key];
},
// TODO
// export type InfoRawReply = [
// _: string,
// size: number,
// _: string,
// numberOfBuckets: number,
// _: string,
// numberOfFilters: number,
// _: string,
// numberOfInsertedItems: number,
// _: string,
// numberOfDeletedItems: number,
// _: string,
// bucketSize: number,
// _: string,
// expansionRate: number,
// _: string,
// maxIteration: number
// ];
// export function transformArguments(key: string): Array<string> { // export interface InfoReply {
// return ['CF.INFO', key]; // size: number;
// } // numberOfBuckets: number;
// numberOfFilters: number;
// numberOfInsertedItems: number;
// numberOfDeletedItems: number;
// bucketSize: number;
// expansionRate: number;
// maxIteration: number;
// }
// export type InfoRawReply = [ // export function transformReply(reply: InfoRawReply): InfoReply {
// _: string, // return {
// size: number, // size: reply[1],
// _: string, // numberOfBuckets: reply[3],
// numberOfBuckets: number, // numberOfFilters: reply[5],
// _: string, // numberOfInsertedItems: reply[7],
// numberOfFilters: number, // numberOfDeletedItems: reply[9],
// _: string, // bucketSize: reply[11],
// numberOfInsertedItems: number, // expansionRate: reply[13],
// _: string, // maxIteration: reply[15]
// numberOfDeletedItems: number, // };
// _: string, // }
// bucketSize: number, transformReply: undefined as unknown as () => any
// _: string, } as const satisfies Command;
// expansionRate: number,
// _: string,
// maxIteration: number
// ];
// export interface InfoReply {
// size: number;
// numberOfBuckets: number;
// numberOfFilters: number;
// numberOfInsertedItems: number;
// numberOfDeletedItems: number;
// bucketSize: number;
// expansionRate: number;
// maxIteration: number;
// }
// export function transformReply(reply: InfoRawReply): InfoReply {
// return {
// size: reply[1],
// numberOfBuckets: reply[3],
// numberOfFilters: reply[5],
// numberOfInsertedItems: reply[7],
// numberOfDeletedItems: reply[9],
// bucketSize: reply[11],
// expansionRate: reply[13],
// maxIteration: reply[15]
// };
// }

View File

@@ -4,7 +4,7 @@ import ADDNX from './ADDNX';
import COUNT from './COUNT'; import COUNT from './COUNT';
import DEL from './DEL'; import DEL from './DEL';
import EXISTS from './EXISTS'; import EXISTS from './EXISTS';
// import INFO from './INFO'; import INFO from './INFO';
import INSERT from './INSERT'; import INSERT from './INSERT';
import INSERTNX from './INSERTNX'; import INSERTNX from './INSERTNX';
import LOADCHUNK from './LOADCHUNK'; import LOADCHUNK from './LOADCHUNK';
@@ -22,8 +22,8 @@ export default {
del: DEL, del: DEL,
EXISTS, EXISTS,
exists: EXISTS, exists: EXISTS,
// INFO, INFO,
// info: INFO, info: INFO,
INSERT, INSERT,
insert: INSERT, insert: INSERT,
INSERTNX, INSERTNX,

View File

@@ -1,25 +1,27 @@
// import { strict as assert } from 'node:assert'; import { strict as assert } from 'node:assert';
// import testUtils, { GLOBAL } from '../../test-utils'; import testUtils, { GLOBAL } from '../../test-utils';
// import { transformArguments } from './INFO'; import INFO from './INFO';
// describe('TDIGEST.INFO', () => { describe('TDIGEST.INFO', () => {
// it('transformArguments', () => { it('transformArguments', () => {
// assert.deepEqual( assert.deepEqual(
// transformArguments('key'), INFO.transformArguments('key'),
// ['TDIGEST.INFO', 'key'] ['TDIGEST.INFO', 'key']
// ); );
// }); });
// testUtils.testWithClient('client.tDigest.info', async client => { testUtils.testWithClient('client.tDigest.info', async client => {
// await client.tDigest.create('key'); const [, reply] = await Promise.all([
client.tDigest.create('key'),
client.tDigest.info('key')
]);
// const info = await client.tDigest.info('key'); assert(typeof reply.capacity, 'number');
// assert(typeof info.capacity, 'number'); assert(typeof reply.mergedNodes, 'number');
// assert(typeof info.mergedNodes, 'number'); assert(typeof reply.unmergedNodes, 'number');
// assert(typeof info.unmergedNodes, 'number'); assert(typeof reply.mergedWeight, 'number');
// assert(typeof info.mergedWeight, 'number'); assert(typeof reply.unmergedWeight, 'number');
// assert(typeof info.unmergedWeight, 'number'); assert(typeof reply.totalCompression, 'number');
// assert(typeof info.totalCompression, 'number'); assert(typeof reply.totalCompression, 'number');
// assert(typeof info.totalCompression, 'number'); }, GLOBAL.SERVERS.OPEN);
// }, GLOBAL.SERVERS.OPEN); });
// });

View File

@@ -1,51 +1,49 @@
// import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
// export const FIRST_KEY_INDEX = 1; export default {
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: true,
transformArguments(key: RedisArgument) {
return ['TDIGEST.INFO', key];
},
// TODO
// type InfoRawReply = [
// 'Compression',
// number,
// 'Capacity',
// number,
// 'Merged nodes',
// number,
// 'Unmerged nodes',
// number,
// 'Merged weight',
// string,
// 'Unmerged weight',
// string,
// 'Total compressions',
// number
// ];
// export const IS_READ_ONLY = true; // interface InfoReply {
// comperssion: number;
// capacity: number;
// mergedNodes: number;
// unmergedNodes: number;
// mergedWeight: number;
// unmergedWeight: number;
// totalCompression: number;
// }
// export function transformArguments(key: RedisCommandArgument): RedisCommandArguments { // export function transformReply(reply: InfoRawReply): InfoReply {
// return [ // return {
// 'TDIGEST.INFO', // comperssion: reply[1],
// key // capacity: reply[3],
// ]; // mergedNodes: reply[5],
// } // unmergedNodes: reply[7],
// mergedWeight: Number(reply[9]),
// type InfoRawReply = [ // unmergedWeight: Number(reply[11]),
// 'Compression', // totalCompression: reply[13]
// number, // };
// 'Capacity', // }
// number, transformReply: undefined as unknown as () => any
// 'Merged nodes', } as const satisfies Command;
// number,
// 'Unmerged nodes',
// number,
// 'Merged weight',
// string,
// 'Unmerged weight',
// string,
// 'Total compressions',
// number
// ];
// interface InfoReply {
// comperssion: number;
// capacity: number;
// mergedNodes: number;
// unmergedNodes: number;
// mergedWeight: number;
// unmergedWeight: number;
// totalCompression: number;
// }
// export function transformReply(reply: InfoRawReply): InfoReply {
// return {
// comperssion: reply[1],
// capacity: reply[3],
// mergedNodes: reply[5],
// unmergedNodes: reply[7],
// mergedWeight: Number(reply[9]),
// unmergedWeight: Number(reply[11]),
// totalCompression: reply[13]
// };
// }

View File

@@ -4,7 +4,7 @@ import BYRANK from './BYRANK';
import BYREVRANK from './BYREVRANK'; import BYREVRANK from './BYREVRANK';
import CDF from './CDF'; import CDF from './CDF';
import CREATE from './CREATE'; import CREATE from './CREATE';
// import INFO from './INFO'; import INFO from './INFO';
import MAX from './MAX'; import MAX from './MAX';
import MERGE from './MERGE'; import MERGE from './MERGE';
import MIN from './MIN'; import MIN from './MIN';
@@ -25,8 +25,8 @@ export default {
cdf: CDF, cdf: CDF,
CREATE, CREATE,
create: CREATE, create: CREATE,
// INFO, INFO,
// info: INFO, info: INFO,
MAX, MAX,
max: MAX, max: MAX,
MERGE, MERGE,

View File

@@ -1,11 +1,11 @@
import { strict as assert } from 'node:assert'; import { strict as assert } from 'node:assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './CLUSTER_INFO'; import CLUSTER_INFO from './CLUSTER_INFO';
describe('CLUSTER INFO', () => { describe('CLUSTER INFO', () => {
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(), CLUSTER_INFO.transformArguments(),
['CLUSTER', 'INFO'] ['CLUSTER', 'INFO']
); );
}); });

View File

@@ -1,20 +1,28 @@
import { strict as assert } from 'node:assert'; import { strict as assert } from 'node:assert';
import { transformArguments } from './INFO'; import testUtils, { GLOBAL } from '../test-utils';
import INFO from './INFO';
describe('INFO', () => { describe('INFO', () => {
describe('transformArguments', () => { describe('transformArguments', () => {
it('simple', () => { it('simple', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(), INFO.transformArguments(),
['INFO'] ['INFO']
); );
}); });
it('server section', () => { it('server section', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('server'), INFO.transformArguments('server'),
['INFO', 'server'] ['INFO', 'server']
); );
}); });
}); });
testUtils.testWithClient('client.info', async client => {
assert.equal(
typeof await client.info(),
'string'
);
}, GLOBAL.SERVERS.OPEN);
}); });

View File

@@ -2,13 +2,10 @@ import { strict as assert } from 'node:assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
describe('KEYS', () => { describe('KEYS', () => {
testUtils.testAll('keys', async client => { testUtils.testWithClient('keys', async client => {
assert.deepEqual( assert.deepEqual(
await client.keys('pattern'), await client.keys('pattern'),
[] []
); );
}, { }, GLOBAL.SERVERS.OPEN);
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
}); });

View File

@@ -50,7 +50,7 @@ describe('SCAN', () => {
}); });
}); });
testUtils.testAll('scan', async client => { testUtils.testWithClient('client.scan', async client => {
assert.deepEqual( assert.deepEqual(
await client.scan('0'), await client.scan('0'),
{ {
@@ -58,8 +58,5 @@ describe('SCAN', () => {
keys: [] keys: []
} }
); );
}, { }, GLOBAL.SERVERS.OPEN);
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
}); });

View File

@@ -10,13 +10,10 @@ describe('WAIT', () => {
); );
}); });
testUtils.testAll('wait', async client => { testUtils.testWithClient('client.wait', async client => {
assert.equal( assert.equal(
await client.wait(0, 1), await client.wait(0, 1),
0 0
); );
}, { }, GLOBAL.SERVERS.OPEN);
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
}); });