1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-09 00:22:08 +03:00
This commit is contained in:
Leibale
2023-06-19 18:04:31 -04:00
parent 9c1f2a0f86
commit f150e86f95
47 changed files with 2490 additions and 1798 deletions

View File

@@ -1,16 +1,45 @@
// import { RedisCommandArguments } from '.';
// import { FunctionListItemReply, FunctionListRawItemReply, transformFunctionListItemReply } from './generic-transformers';
import { RedisArgument, TuplesToMapReply, BlobStringReply, ArrayReply, NullReply, SetReply, Resp2Reply, CommandArguments, Command } from '../RESP/types';
// export function transformArguments(pattern?: string): RedisCommandArguments {
// const args = ['FUNCTION', 'LIST'];
export interface FunctionListOptions {
LIBRARYNAME?: RedisArgument;
}
// if (pattern) {
// args.push(pattern);
// }
export type FunctionListReplyItem = [
[BlobStringReply<'library_name'>, BlobStringReply],
[BlobStringReply<'engine'>, BlobStringReply],
[BlobStringReply<'functions'>, ArrayReply<TuplesToMapReply<[
[BlobStringReply<'name'>, BlobStringReply],
[BlobStringReply<'description'>, BlobStringReply | NullReply],
[BlobStringReply<'flags'>, SetReply<BlobStringReply>],
]>>]
]
// return args;
// }
export type FunctionListReply = ArrayReply<TuplesToMapReply<FunctionListReplyItem>>;
// export function transformReply(reply: Array<FunctionListRawItemReply>): Array<FunctionListItemReply> {
// return reply.map(transformFunctionListItemReply);
// }
export default {
FIRST_KEY_INDEX: undefined,
IS_READ_ONLY: false,
transformArguments(options?: FunctionListOptions) {
const args: CommandArguments = ['FUNCTION', 'LIST'];
if (options?.LIBRARYNAME) {
args.push('LIBRARYNAME', options.LIBRARYNAME);
}
return args;
},
transformReply: {
2: (reply: Resp2Reply<FunctionListReply>) => {
return reply.map(library => ({
library_name: library[1],
engine: library[3],
functions: library[5].map(fn => ({
name: fn[1],
description: fn[3],
flags: fn[5]
}))
}));
},
3: undefined as unknown as () => FunctionListReply
}
} as const satisfies Command;