강력한 API 타입 체크

This commit is contained in:
2023-08-06 09:27:24 +00:00
parent 7352cdbf23
commit 826b4212e5
11 changed files with 266 additions and 445 deletions
+45
View File
@@ -0,0 +1,45 @@
import { type APICallT, GET, POST } from "./defs";
export type LoginResponse = {
result: true,
nextToken: [number, string] | undefined,
}
export type LoginFailed = {
result: false,
reqOTP: boolean,
reason: string,
}
export type AutoLoginNonceResponse = {
result: true,
loginNonce: string,
};
export type AutoLoginResponse = {
result: true,
nextToken: [number, string] | undefined,
}
export type AutoLoginFailed = {
result: false,
silent: boolean,
reason: string,
}
/** @internal */
export const structure = {
Login: {
LoginByID: POST as APICallT<{
username: string,
password: string,
}, LoginResponse, LoginFailed>,
LoginByToken: POST as APICallT<{
hashedToken: string,
token_id: number,
}, AutoLoginResponse, AutoLoginFailed>,
ReqNonce: GET as APICallT<undefined, AutoLoginNonceResponse, AutoLoginFailed>
},
} as const;