import type { CommandOptions } from "./command"; import { Command } from "./command"; /** * @see https://redis.io/commands/xclaim * @see node_modules/@upstash/redis/docs/commands/stream/xclaim.mdx */ export class XClaimCommand extends Command { constructor( [key, group, consumer, minIdleTime, id, options]: [ key: string, group: string, consumer: string, minIdleTime: number, id: string | string[], options?: { idleMS?: number; timeMS?: number; retryCount?: number; force?: boolean; justId?: boolean; lastId?: number; }, ], opts?: CommandOptions ) { const ids = Array.isArray(id) ? [...id] : [id]; const commands: unknown[] = []; if (options?.idleMS !== undefined) { commands.push("IDLE", options.idleMS); } if (options?.timeMS !== undefined) { commands.push("TIME", options.timeMS); } if (options?.retryCount !== undefined) { commands.push("RETRYCOUNT", options.retryCount); } if (options?.force) { commands.push("FORCE"); } if (options?.justId) { commands.push("JUSTID"); } if (options?.lastId) { commands.push("LASTID", options.lastId); } super(["XCLAIM", key, group, consumer, minIdleTime, ...ids, ...commands], opts); } }