refac: SammoAPI Path 정의에 NumVar, StrVar 추가

This commit is contained in:
2022-03-25 23:29:10 +09:00
parent 11e28b7a87
commit 00ceb3f842
5 changed files with 51 additions and 33 deletions
+1 -10
View File
@@ -1,17 +1,8 @@
import type { InvalidResponse } from "./defs";
import { APIPathGen } from "./util/APIPathGen";
import { callSammoAPI, type ValidResponse } from "./util/callSammoAPI";
import { callSammoAPI, done, type ValidResponse } from "./util/callSammoAPI";
export type { ValidResponse, InvalidResponse };
async function done<ResultType extends ValidResponse>(args?: Record<string, unknown>): Promise<ResultType>;
async function done<ResultType extends ValidResponse>(args: Record<string, unknown> | undefined, returnError: false): Promise<ResultType>;
async function done<ResultType extends ValidResponse, ErrorType extends InvalidResponse>(args: Record<string, unknown> | undefined, returnError: true): Promise<ResultType | ErrorType>;
async function done<ResultType extends ValidResponse, ErrorType extends InvalidResponse>(args?: Record<string, unknown>, returnError = false): Promise<ResultType | ErrorType>{
console.error(`Can't directly call. ${args}, ${returnError}. Use auto-generated path API.`);
return callSammoAPI<ResultType, ErrorType>([], args, true);
}
const apiRealPath = {
Login: {
LoginByID: done,