import type { CommandOptions } from "./command"; import { Command } from "./command"; /** * @see https://redis.io/commands/json.get * @see node_modules/@upstash/redis/docs/commands/json/get.mdx */ export class JsonGetCommand< TData extends (unknown | Record) | (unknown | Record)[], > extends Command { constructor( cmd: | [ key: string, opts?: { indent?: string; newline?: string; space?: string }, ...path: string[], ] | [key: string, ...path: string[]], opts?: CommandOptions ) { const command = ["JSON.GET"]; if (typeof cmd[1] === "string") { // @ts-expect-error - we know this is a string command.push(...cmd); } else { command.push(cmd[0]); if (cmd[1]) { if (cmd[1].indent) { command.push("INDENT", cmd[1].indent); } if (cmd[1].newline) { command.push("NEWLINE", cmd[1].newline); } if (cmd[1].space) { command.push("SPACE", cmd[1].space); } } // @ts-expect-error - we know this is a string command.push(...cmd.slice(2)); } super(command, opts); } }