import type { InvalidResponse, ReserveBulkCommandResponse } from "./defs"; import type { Args } from "./processing/args"; import { callSammoAPI, type ValidResponse } from "./util/callSammoAPI"; export type { ValidResponse, InvalidResponse }; import { APIPathGen } from "./util/APIPathGen.js"; type RawArgType = Record|Record[]; interface CallbackT{ (args?: ArgType): Promise; (args: ArgType | undefined, returnError: false): Promise; (args: ArgType | undefined, returnError: true): Promise; } async function done(args?: RawArgType): Promise; async function done(args: RawArgType | undefined, returnError: false): Promise; async function done(args: RawArgType | undefined, returnError: true): Promise; async function done(args?: RawArgType, returnError = false): Promise { console.error(`Can't directly call. ${args}, ${returnError}. Use auto-generated path API.`); return callSammoAPI([], args, true); } const apiRealPath = { Betting: { Bet: done, GetBettingDetail: done, GetBettingList: done, }, Command: { GetReservedCommand: done, PushCommand: done, RepeatCommand: done, ReserveCommand: done, ReserveBulkCommand: done as CallbackT, }, General: { Join: done, }, InheritAction: { BuyHiddenBuff: done, BuyRandomUnique: done, BuySpecificUnique: done, ResetSpecialWar: done, ResetTurnTime: done, SetNextSpecialWar: done, }, Misc: { UploadImage: done }, NationCommand: { GetReservedCommand: done, PushCommand: done, RepeatCommand: done, ReserveCommand: done, }, Nation: { SetNotice: done, SetScoutMsg: done, SetBill: done, SetRate: done, SetSecretLimit: done, SetBlockWar: done, SetBlockScout: done, }, } as const; export const SammoAPI = APIPathGen(apiRealPath, (path: string[]) => { return (args?: RawArgType, returnError?: boolean) => { if (returnError) { return callSammoAPI(path.join('/'), args, true); } return callSammoAPI(path.join('/'), args); }; }) as typeof apiRealPath;