mirror of
https://gitea.tendokyu.moe/ppc/amnet.git
synced 2026-10-01 19:28:05 +03:00
64 lines
2.0 KiB
TypeScript
64 lines
2.0 KiB
TypeScript
/**
|
|
* The latest version of the AMNet API this library supports
|
|
*/
|
|
declare const AMNET_API_VERSION = 1;
|
|
interface AMCardInRequest {
|
|
cardId: string;
|
|
}
|
|
/**
|
|
* Information needed to perform a request against an AMNet server
|
|
*/
|
|
interface AMServerConnectionInfo {
|
|
apiVersion: number;
|
|
serverAddress: string;
|
|
}
|
|
/**
|
|
* Received metadata from an AMNet server
|
|
*/
|
|
interface AMServerInfoResponse extends AMServerConnectionInfo {
|
|
serverName: string;
|
|
gameId?: string | null | undefined;
|
|
}
|
|
/**
|
|
* Performs the card-in request to the specified server
|
|
* @param server The server to perform the request against
|
|
* @param request The card-in request to send
|
|
* @param signal The abort signal to use for the request
|
|
*/
|
|
declare function performCardIn(server: AMServerConnectionInfo, request: AMCardInRequest, signal: AbortSignal): Promise<boolean>;
|
|
/**
|
|
* Attempts to connect to the specified server and fetch its info
|
|
* @param serverAddress The origin address of the server to connect to
|
|
* @param abort The abort signal to use for the request (for cancellation)
|
|
*/
|
|
declare function fetchServerInfo(serverAddress: string, abort: AbortSignal): Promise<AMServerInfoResponse | null>;
|
|
|
|
declare const CARD_ID_REGEX: RegExp;
|
|
declare function generateCardNumber(): string;
|
|
/**
|
|
* Validates the provided card id by known parameters
|
|
* @param id The card id to validate
|
|
*/
|
|
declare function validateCardId(id: string): boolean;
|
|
|
|
declare enum GameId {
|
|
/**
|
|
* Initial D The Arcade
|
|
*/
|
|
IDAC = "SDGT",
|
|
/**
|
|
* Chunithm (Paradise Lost)
|
|
*/
|
|
Chuni = "SDBT",
|
|
/**
|
|
* Chunithm NEW onwards
|
|
*/
|
|
Chusan = "SDHD",
|
|
ONGEKI = "SDDT",
|
|
maimaiDX = "SDEZ",
|
|
DivaFT = "SBZV"
|
|
}
|
|
declare function getGameName(id: GameId): "Initial D The Arcade" | "CHUNITHM" | "CHUNITHM (Paradise Lost)" | "O.N.G.E.K.I" | "maimai DX" | "Project DIVA Future Tone";
|
|
|
|
export { type AMCardInRequest, AMNET_API_VERSION, type AMServerConnectionInfo, type AMServerInfoResponse, CARD_ID_REGEX, GameId, fetchServerInfo, generateCardNumber, getGameName, performCardIn, validateCardId };
|