import { InvalidResponse } from "./defs"; import { APIPathGen } from "./util/APIPathGen"; import { callSammoAPI, ValidResponse } from "./util/callSammoAPI"; export type { ValidResponse, InvalidResponse }; async function done(args?: Record): Promise; async function done(args: Record | undefined, returnError: false): Promise; async function done(args: Record | undefined, returnError: true): Promise; async function done(args?: Record, returnError = false): Promise { console.error(`Can't directly call. ${args}, ${returnError}. Use auto-generated path API.`); return callSammoAPI([], args, true); } const apiRealPath = { Command: { GetReservedCommand: done, PushCommand: done, RepeatCommand: done, ReserveCommand: done, }, 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?: Record, returnError?: boolean) => { if (returnError) { return callSammoAPI(path.join('/'), args, true); } return callSammoAPI(path.join('/'), args); }; });