You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
WIP
This commit is contained in:
@@ -1,40 +1,40 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { RedisArgument, TuplesToMapReply, BlobStringReply, ArrayReply, Resp2Reply, Command } from '../RESP/types';
|
||||
|
||||
export function transformArguments(username: RedisCommandArgument): RedisCommandArguments {
|
||||
type AclUser = TuplesToMapReply<[
|
||||
[BlobStringReply<'flags'>, ArrayReply<BlobStringReply>],
|
||||
[BlobStringReply<'passwords'>, ArrayReply<BlobStringReply>],
|
||||
[BlobStringReply<'commands'>, BlobStringReply],
|
||||
/** changed to BlobStringReply in 7.0 */
|
||||
[BlobStringReply<'keys'>, ArrayReply<BlobStringReply> | BlobStringReply],
|
||||
/** added in 6.2, changed to BlobStringReply in 7.0 */
|
||||
[BlobStringReply<'channels'>, ArrayReply<BlobStringReply> | BlobStringReply],
|
||||
/** added in 7.0 */
|
||||
[BlobStringReply<'selectors'>, ArrayReply<TuplesToMapReply<[
|
||||
[BlobStringReply<'commands'>, BlobStringReply],
|
||||
[BlobStringReply<'keys'>, BlobStringReply],
|
||||
[BlobStringReply<'channels'>, BlobStringReply]
|
||||
]>>],
|
||||
]>;
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(username: RedisArgument) {
|
||||
return ['ACL', 'GETUSER', username];
|
||||
}
|
||||
|
||||
type AclGetUserRawReply = [
|
||||
'flags',
|
||||
Array<RedisCommandArgument>,
|
||||
'passwords',
|
||||
Array<RedisCommandArgument>,
|
||||
'commands',
|
||||
RedisCommandArgument,
|
||||
'keys',
|
||||
Array<RedisCommandArgument> | RedisCommandArgument,
|
||||
'channels',
|
||||
Array<RedisCommandArgument> | RedisCommandArgument,
|
||||
'selectors' | undefined,
|
||||
Array<Array<string>> | undefined
|
||||
];
|
||||
|
||||
interface AclUser {
|
||||
flags: Array<RedisCommandArgument>;
|
||||
passwords: Array<RedisCommandArgument>;
|
||||
commands: RedisCommandArgument;
|
||||
keys: Array<RedisCommandArgument> | RedisCommandArgument;
|
||||
channels: Array<RedisCommandArgument> | RedisCommandArgument;
|
||||
selectors?: Array<Array<string>>;
|
||||
}
|
||||
|
||||
export function transformReply(reply: AclGetUserRawReply): AclUser {
|
||||
return {
|
||||
flags: reply[1],
|
||||
passwords: reply[3],
|
||||
commands: reply[5],
|
||||
keys: reply[7],
|
||||
channels: reply[9],
|
||||
selectors: reply[11]
|
||||
};
|
||||
}
|
||||
},
|
||||
transformReply: {
|
||||
2: (reply: Resp2Reply<AclUser>) => ({
|
||||
flags: reply[1],
|
||||
passwords: reply[3],
|
||||
commands: reply[5],
|
||||
keys: reply[7],
|
||||
channels: reply[9],
|
||||
selectors: reply[11]?.map(selector => ({
|
||||
commands: selector[1],
|
||||
keys: selector[3],
|
||||
channels: selector[5]
|
||||
}))
|
||||
}),
|
||||
3: undefined as unknown as () => AclUser
|
||||
}
|
||||
} as const satisfies Command;
|
||||
|
Reference in New Issue
Block a user