11import { execSync } from "child_process"
22import repl from "repl"
33import { Client } from "typesense"
4- import yargs from "yargs"
4+ import yargs , { Arguments } from "yargs"
55import { hideBin } from "yargs/helpers"
66import { createClient } from "../functions/src/search/client"
77
@@ -21,13 +21,13 @@ const envs: Record<string, { url: string; key?: string; alias?: string }> = {
2121 }
2222}
2323
24- type Args = { url ?: string ; key ?: string ; env ?: string }
24+ type Args = Arguments < { url ?: string ; key ?: string ; env ?: string } >
2525yargs ( hideBin ( process . argv ) )
2626 . scriptName ( "typesense-admin" )
2727 . command (
2828 "console" ,
2929 "start a node repl with an initialized client" ,
30- ( ) => { } ,
30+ { } ,
3131 ( args : Args ) => {
3232 globalThis . client = resolveClient ( args )
3333 repl . start ( { } ) . setupHistory ( "typesense-admin.history" , ( ) => { } )
@@ -36,7 +36,7 @@ yargs(hideBin(process.argv))
3636 . command (
3737 "create-search-key" ,
3838 "create a new search key" ,
39- ( ) => { } ,
39+ { } ,
4040 async ( args : Args ) => {
4141 const client = resolveClient ( args )
4242 const key = await client . keys ( ) . create ( {
@@ -50,7 +50,7 @@ yargs(hideBin(process.argv))
5050 . command (
5151 "list-keys" ,
5252 "list keys" ,
53- ( ) => { } ,
53+ { } ,
5454 async ( args : Args ) => {
5555 const client = resolveClient ( args )
5656 console . log ( await client . keys ( ) . retrieve ( ) )
@@ -59,8 +59,8 @@ yargs(hideBin(process.argv))
5959 . command (
6060 "delete-key <id>" ,
6161 "list keys" ,
62- ( ) => { } ,
63- async ( args : Args & { id : string } ) => {
62+ { } ,
63+ async ( args : Args & { id ? : string } ) => {
6464 const client = resolveClient ( args )
6565 console . log ( await client . keys ( Number ( args . id ) ) . delete ( ) )
6666 }
0 commit comments