forked from devsam/core
- ag-grid 기반 - 컬럼 사용자 정의 기능 제공 - 컬럼 재정렬, 고정, 정렬 기능 - 컬럼 상태 저장, 불러오기 - 마지막 컬럼 재 사용 - 아이콘, 장수명 클릭 시 특수 기능 제공 - 기본 세력 장수/암행부에서는 '감찰부' - 추가 컬럼 - 최근 전투 - 전투 수 - 승리 수 - 살상률 - API/Nation/GeneralList 추가 Co-authored-by: hide_d <hided62@gmail.com> Reviewed-on: https://storage.hided.net/gitea/devsam/core/pulls/213
132 lines
4.4 KiB
TypeScript
132 lines
4.4 KiB
TypeScript
import type { Args } from "./processing/args";
|
|
import {
|
|
callSammoAPI, extractHttpMethod, GET, PATCH, POST, PUT,
|
|
type APITail, type APICallT, type RawArgType, type ValidResponse, type InvalidResponse
|
|
} from "./util/callSammoAPI";
|
|
export type { ValidResponse, InvalidResponse };
|
|
import { APIPathGen, NumVar } from "./util/APIPathGen.js";
|
|
import type { BettingDetailResponse, BettingListResponse } from "./defs/API/Betting";
|
|
import type { ReserveBulkCommandResponse, ReserveCommandResponse, ReservedCommandResponse } from "./defs/API/Command";
|
|
import type { ChiefResponse } from "./defs/API/NationCommand";
|
|
import type { inheritBuffType } from "./defs/API/InheritAction";
|
|
import type { SetBlockWarResponse, GeneralListResponse as NationGeneralListResponse } from "./defs/API/Nation";
|
|
import type { UploadImageResponse } from "./defs/API/Misc";
|
|
import type { JoinArgs } from "./defs/API/General";
|
|
import type { GetConstResponse } from "./defs/API/Global";
|
|
import type { GeneralListResponse } from "./defs";
|
|
|
|
const apiRealPath = {
|
|
Betting: {
|
|
Bet: PUT as APICallT<{
|
|
bettingID: number,
|
|
bettingType: number[],
|
|
amount: number,
|
|
}>,
|
|
GetBettingDetail: NumVar('betting_id',
|
|
GET as APICallT<undefined, BettingDetailResponse>
|
|
),
|
|
GetBettingList: GET as APICallT<undefined, BettingListResponse>,
|
|
},
|
|
Command: {
|
|
GetReservedCommand: GET as APICallT<undefined, ReservedCommandResponse>,
|
|
PushCommand: PUT as APICallT<{
|
|
amount: number
|
|
}>,
|
|
RepeatCommand: PUT as APICallT<{
|
|
amount: number
|
|
}>,
|
|
ReserveCommand: PUT as APICallT<{
|
|
turnList: number[],
|
|
action: string,
|
|
arg?: Args
|
|
}, ReserveCommandResponse>,
|
|
ReserveBulkCommand: PUT as APICallT<{
|
|
turnList: number[],
|
|
action: string,
|
|
arg?: Args
|
|
}[], ReserveBulkCommandResponse>,
|
|
},
|
|
General: {
|
|
Join: POST as APICallT<JoinArgs>,
|
|
},
|
|
Global: {
|
|
GeneralList: GET as APICallT<{
|
|
with_token?: boolean
|
|
}, GeneralListResponse>,
|
|
GetConst: GET as APICallT<undefined, GetConstResponse>,
|
|
},
|
|
InheritAction: {
|
|
BuyHiddenBuff: PUT as APICallT<{
|
|
type: inheritBuffType,
|
|
level: number
|
|
}>,
|
|
BuyRandomUnique: PUT as APICallT<undefined>,
|
|
BuySpecificUnique: PUT as APICallT<{
|
|
item: string,
|
|
amount: number,
|
|
}>,
|
|
ResetSpecialWar: PUT as APICallT<undefined>,
|
|
ResetTurnTime: PUT as APICallT<undefined>,
|
|
SetNextSpecialWar: PUT as APICallT<{
|
|
type: string,
|
|
}>,
|
|
},
|
|
Misc: {
|
|
UploadImage: POST as APICallT<{
|
|
imageData: string,
|
|
}, UploadImageResponse>
|
|
},
|
|
NationCommand: {
|
|
GetReservedCommand: GET as APICallT<undefined, ChiefResponse>,
|
|
PushCommand: PUT as APICallT<{
|
|
amount: number
|
|
}>,
|
|
RepeatCommand: PUT as APICallT<{
|
|
amount: number
|
|
}>,
|
|
ReserveCommand: PUT as APICallT<{
|
|
turnList: number[],
|
|
action: string,
|
|
arg?: Args
|
|
}, ReserveCommandResponse>,
|
|
ReserveBulkCommand: PUT as APICallT<{
|
|
turnList: number[],
|
|
action: string,
|
|
arg?: Args
|
|
}[], ReserveBulkCommandResponse>,
|
|
},
|
|
Nation: {
|
|
GeneralList: GET as APICallT<undefined, NationGeneralListResponse>,
|
|
SetNotice: PUT as APICallT<{
|
|
msg: string,
|
|
}>,
|
|
SetScoutMsg: PUT as APICallT<{
|
|
msg: string,
|
|
}>,
|
|
SetBill: PATCH as APICallT<{
|
|
amount: number,
|
|
}>,
|
|
SetRate: PATCH as APICallT<{
|
|
amount: number,
|
|
}>,
|
|
SetSecretLimit: PATCH as APICallT<{
|
|
amount: number,
|
|
}>,
|
|
SetBlockWar: PATCH as APICallT<{
|
|
value: boolean,
|
|
}, SetBlockWarResponse>,
|
|
SetBlockScout: PATCH as APICallT<{
|
|
value: boolean,
|
|
}>,
|
|
},
|
|
} as const;
|
|
|
|
export const SammoAPI = APIPathGen(apiRealPath, (path: string[], tail: APITail, pathParam) => {
|
|
const method = extractHttpMethod(tail);
|
|
return (args?: RawArgType, returnError?: boolean) => {
|
|
if (returnError) {
|
|
return callSammoAPI(method, path.join('/'), args, pathParam, true);
|
|
}
|
|
return callSammoAPI(method, path.join('/'), args, pathParam);
|
|
};
|
|
}); |