@valkey/client
Version:
The source code and documentation for this package are in the main [node-redis](https://github.com/redis/node-redis) repo.
37 lines (36 loc) • 3.1 kB
TypeScript
import COMMANDS from "./commands";
import { ValkeyCommand, ValkeyCommandArgument, ValkeyCommandArguments, ValkeyCommandRawReply, ValkeyFunctions, ValkeyModules, ValkeyExtensions, ValkeyScript, ValkeyScripts, ExcludeMappedString, ValkeyFunction } from "../commands";
import { ValkeyMultiQueuedCommand } from "../multi-command";
type ValkeyClusterMultiCommandSignature<C extends ValkeyCommand, M extends ValkeyModules, F extends ValkeyFunctions, S extends ValkeyScripts> = (...args: Parameters<C["transformArguments"]>) => ValkeyClusterMultiCommandType<M, F, S>;
type WithCommands<M extends ValkeyModules, F extends ValkeyFunctions, S extends ValkeyScripts> = {
[P in keyof typeof COMMANDS]: ValkeyClusterMultiCommandSignature<(typeof COMMANDS)[P], M, F, S>;
};
type WithModules<M extends ValkeyModules, F extends ValkeyFunctions, S extends ValkeyScripts> = {
[P in keyof M as ExcludeMappedString<P>]: {
[C in keyof M[P] as ExcludeMappedString<C>]: ValkeyClusterMultiCommandSignature<M[P][C], M, F, S>;
};
};
type WithFunctions<M extends ValkeyModules, F extends ValkeyFunctions, S extends ValkeyScripts> = {
[P in keyof F as ExcludeMappedString<P>]: {
[FF in keyof F[P] as ExcludeMappedString<FF>]: ValkeyClusterMultiCommandSignature<F[P][FF], M, F, S>;
};
};
type WithScripts<M extends ValkeyModules, F extends ValkeyFunctions, S extends ValkeyScripts> = {
[P in keyof S as ExcludeMappedString<P>]: ValkeyClusterMultiCommandSignature<S[P], M, F, S>;
};
export type ValkeyClusterMultiCommandType<M extends ValkeyModules, F extends ValkeyFunctions, S extends ValkeyScripts> = ValkeyClusterMultiCommand & WithCommands<M, F, S> & WithModules<M, F, S> & WithFunctions<M, F, S> & WithScripts<M, F, S>;
export type InstantiableValkeyClusterMultiCommandType<M extends ValkeyModules, F extends ValkeyFunctions, S extends ValkeyScripts> = new (...args: ConstructorParameters<typeof ValkeyClusterMultiCommand>) => ValkeyClusterMultiCommandType<M, F, S>;
export type ValkeyClusterMultiExecutor = (queue: Array<ValkeyMultiQueuedCommand>, firstKey?: ValkeyCommandArgument, chainId?: symbol) => Promise<Array<ValkeyCommandRawReply>>;
export default class ValkeyClusterMultiCommand {
#private;
static extend<M extends ValkeyModules, F extends ValkeyFunctions, S extends ValkeyScripts>(extensions?: ValkeyExtensions<M, F, S>): InstantiableValkeyClusterMultiCommandType<M, F, S>;
constructor(executor: ValkeyClusterMultiExecutor, firstKey?: ValkeyCommandArgument);
commandsExecutor(command: ValkeyCommand, args: Array<unknown>): this;
addCommand(firstKey: ValkeyCommandArgument | undefined, args: ValkeyCommandArguments, transformReply?: ValkeyCommand["transformReply"]): this;
functionsExecutor(fn: ValkeyFunction, args: Array<unknown>, name: string): this;
scriptsExecutor(script: ValkeyScript, args: Array<unknown>): this;
exec(execAsPipeline?: boolean): Promise<Array<ValkeyCommandRawReply>>;
EXEC: (execAsPipeline?: boolean) => Promise<Array<ValkeyCommandRawReply>>;
execAsPipeline(): Promise<Array<ValkeyCommandRawReply>>;
}
export {};