refactor: move types to types.ts
parent
daca9cfb1c
commit
5113a0db04
|
|
@ -1,3 +1,6 @@
|
||||||
|
export const S3SI_VERSION = "0.1.0";
|
||||||
|
export const NSOAPP_VERSION = "2.3.1";
|
||||||
|
export const USERAGENT = `s3si.ts/${S3SI_VERSION}`;
|
||||||
export const DEFAULT_APP_USER_AGENT =
|
export const DEFAULT_APP_USER_AGENT =
|
||||||
"Mozilla/5.0 (Linux; Android 11; Pixel 5) " +
|
"Mozilla/5.0 (Linux; Android 11; Pixel 5) " +
|
||||||
"AppleWebKit/537.36 (KHTML, like Gecko) " +
|
"AppleWebKit/537.36 (KHTML, like Gecko) " +
|
||||||
|
|
|
||||||
1
deps.ts
1
deps.ts
|
|
@ -6,3 +6,4 @@ export {
|
||||||
export * as base64 from "https://deno.land/std@0.160.0/encoding/base64.ts";
|
export * as base64 from "https://deno.land/std@0.160.0/encoding/base64.ts";
|
||||||
export * as flags from "https://deno.land/std@0.160.0/flags/mod.ts";
|
export * as flags from "https://deno.land/std@0.160.0/flags/mod.ts";
|
||||||
export * as io from "https://deno.land/std@0.160.0/io/mod.ts";
|
export * as io from "https://deno.land/std@0.160.0/io/mod.ts";
|
||||||
|
export * as uuid from "https://deno.land/std@0.160.0/uuid/mod.ts";
|
||||||
|
|
|
||||||
8
iksm.ts
8
iksm.ts
|
|
@ -1,7 +1,11 @@
|
||||||
import { CookieJar, wrapFetch } from "./deps.ts";
|
import { CookieJar, wrapFetch } from "./deps.ts";
|
||||||
import { cache, readline, retry, urlBase64Encode } from "./utils.ts";
|
import { cache, readline, retry, urlBase64Encode } from "./utils.ts";
|
||||||
import { NSOAPP_VERSION, USERAGENT } from "./version.ts";
|
import {
|
||||||
import { DEFAULT_APP_USER_AGENT, SPLATNET3_URL } from "./constant.ts";
|
DEFAULT_APP_USER_AGENT,
|
||||||
|
NSOAPP_VERSION,
|
||||||
|
SPLATNET3_URL,
|
||||||
|
USERAGENT,
|
||||||
|
} from "./constant.ts";
|
||||||
import { APIError } from "./APIError.ts";
|
import { APIError } from "./APIError.ts";
|
||||||
|
|
||||||
export async function loginManually(): Promise<string> {
|
export async function loginManually(): Promise<string> {
|
||||||
|
|
|
||||||
75
splatnet3.ts
75
splatnet3.ts
|
|
@ -2,69 +2,13 @@ import { getWebViewVer } from "./iksm.ts";
|
||||||
import { State } from "./state.ts";
|
import { State } from "./state.ts";
|
||||||
import { DEFAULT_APP_USER_AGENT, SPLATNET3_ENDPOINT } from "./constant.ts";
|
import { DEFAULT_APP_USER_AGENT, SPLATNET3_ENDPOINT } from "./constant.ts";
|
||||||
import { APIError } from "./APIError.ts";
|
import { APIError } from "./APIError.ts";
|
||||||
|
import {
|
||||||
enum Queries {
|
BattleType,
|
||||||
HomeQuery = "dba47124d5ec3090c97ba17db5d2f4b3",
|
GraphQLResponse,
|
||||||
LatestBattleHistoriesQuery = "7d8b560e31617e981cf7c8aa1ca13a00",
|
Queries,
|
||||||
RegularBattleHistoriesQuery = "f6e7e0277e03ff14edfef3b41f70cd33",
|
RespMap,
|
||||||
BankaraBattleHistoriesQuery = "c1553ac75de0a3ea497cdbafaa93e95b",
|
VarsMap,
|
||||||
PrivateBattleHistoriesQuery = "38e0529de8bc77189504d26c7a14e0b8",
|
} from "./types.ts";
|
||||||
VsHistoryDetailQuery = "2b085984f729cd51938fc069ceef784a",
|
|
||||||
CoopHistoryQuery = "817618ce39bcf5570f52a97d73301b30",
|
|
||||||
CoopHistoryDetailQuery = "f3799a033f0a7ad4b1b396f9a3bafb1e",
|
|
||||||
}
|
|
||||||
type VarsMap = {
|
|
||||||
[Queries.HomeQuery]: Record<never, never>;
|
|
||||||
[Queries.LatestBattleHistoriesQuery]: Record<never, never>;
|
|
||||||
[Queries.RegularBattleHistoriesQuery]: Record<never, never>;
|
|
||||||
[Queries.BankaraBattleHistoriesQuery]: Record<never, never>;
|
|
||||||
[Queries.PrivateBattleHistoriesQuery]: Record<never, never>;
|
|
||||||
[Queries.VsHistoryDetailQuery]: {
|
|
||||||
vsResultId: string;
|
|
||||||
};
|
|
||||||
[Queries.CoopHistoryQuery]: Record<never, never>;
|
|
||||||
[Queries.CoopHistoryDetailQuery]: {
|
|
||||||
coopHistoryDetailId: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
type Image = {
|
|
||||||
url: string;
|
|
||||||
width?: number;
|
|
||||||
height?: number;
|
|
||||||
};
|
|
||||||
type RespMap = {
|
|
||||||
[Queries.HomeQuery]: {
|
|
||||||
currentPlayer: {
|
|
||||||
weapon: {
|
|
||||||
image: Image;
|
|
||||||
id: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
banners: { image: Image; message: string; jumpTo: string }[];
|
|
||||||
friends: {
|
|
||||||
nodes: {
|
|
||||||
id: number;
|
|
||||||
nickname: string;
|
|
||||||
userIcon: Image;
|
|
||||||
}[];
|
|
||||||
totalCount: number;
|
|
||||||
};
|
|
||||||
footerMessages: unknown[];
|
|
||||||
};
|
|
||||||
[Queries.LatestBattleHistoriesQuery]: Record<never, never>;
|
|
||||||
[Queries.RegularBattleHistoriesQuery]: Record<never, never>;
|
|
||||||
[Queries.BankaraBattleHistoriesQuery]: Record<never, never>;
|
|
||||||
[Queries.PrivateBattleHistoriesQuery]: Record<never, never>;
|
|
||||||
[Queries.VsHistoryDetailQuery]: Record<never, never>;
|
|
||||||
[Queries.CoopHistoryQuery]: Record<never, never>;
|
|
||||||
[Queries.CoopHistoryDetailQuery]: Record<never, never>;
|
|
||||||
};
|
|
||||||
type GraphQLResponse<T> = {
|
|
||||||
data: T;
|
|
||||||
} | {
|
|
||||||
errors: unknown[];
|
|
||||||
};
|
|
||||||
|
|
||||||
async function request<Q extends Queries>(
|
async function request<Q extends Queries>(
|
||||||
state: State,
|
state: State,
|
||||||
|
|
@ -110,7 +54,7 @@ async function request<Q extends Queries>(
|
||||||
throw new APIError({
|
throw new APIError({
|
||||||
response: resp,
|
response: resp,
|
||||||
json,
|
json,
|
||||||
message: "Splatnet3 request failed",
|
message: `Splatnet3 request failed(${json.errors?.[0].message})`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return json.data;
|
return json.data;
|
||||||
|
|
@ -128,3 +72,6 @@ export async function checkToken(state: State) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getBattleList(params: BattleType) {
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,123 @@
|
||||||
|
export enum Queries {
|
||||||
|
HomeQuery = "dba47124d5ec3090c97ba17db5d2f4b3",
|
||||||
|
LatestBattleHistoriesQuery = "7d8b560e31617e981cf7c8aa1ca13a00",
|
||||||
|
RegularBattleHistoriesQuery = "f6e7e0277e03ff14edfef3b41f70cd33",
|
||||||
|
BankaraBattleHistoriesQuery = "c1553ac75de0a3ea497cdbafaa93e95b",
|
||||||
|
PrivateBattleHistoriesQuery = "38e0529de8bc77189504d26c7a14e0b8",
|
||||||
|
VsHistoryDetailQuery = "2b085984f729cd51938fc069ceef784a",
|
||||||
|
CoopHistoryQuery = "817618ce39bcf5570f52a97d73301b30",
|
||||||
|
CoopHistoryDetailQuery = "f3799a033f0a7ad4b1b396f9a3bafb1e",
|
||||||
|
}
|
||||||
|
export type VarsMap = {
|
||||||
|
[Queries.HomeQuery]: Record<never, never>;
|
||||||
|
[Queries.LatestBattleHistoriesQuery]: Record<never, never>;
|
||||||
|
[Queries.RegularBattleHistoriesQuery]: Record<never, never>;
|
||||||
|
[Queries.BankaraBattleHistoriesQuery]: Record<never, never>;
|
||||||
|
[Queries.PrivateBattleHistoriesQuery]: Record<never, never>;
|
||||||
|
[Queries.VsHistoryDetailQuery]: {
|
||||||
|
vsResultId: string;
|
||||||
|
};
|
||||||
|
[Queries.CoopHistoryQuery]: Record<never, never>;
|
||||||
|
[Queries.CoopHistoryDetailQuery]: {
|
||||||
|
coopHistoryDetailId: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Image = {
|
||||||
|
url: string;
|
||||||
|
width?: number;
|
||||||
|
height?: number;
|
||||||
|
};
|
||||||
|
export type RespMap = {
|
||||||
|
[Queries.HomeQuery]: {
|
||||||
|
currentPlayer: {
|
||||||
|
weapon: {
|
||||||
|
image: Image;
|
||||||
|
id: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
banners: { image: Image; message: string; jumpTo: string }[];
|
||||||
|
friends: {
|
||||||
|
nodes: {
|
||||||
|
id: number;
|
||||||
|
nickname: string;
|
||||||
|
userIcon: Image;
|
||||||
|
}[];
|
||||||
|
totalCount: number;
|
||||||
|
};
|
||||||
|
footerMessages: unknown[];
|
||||||
|
};
|
||||||
|
[Queries.LatestBattleHistoriesQuery]: Record<never, never>;
|
||||||
|
[Queries.RegularBattleHistoriesQuery]: Record<never, never>;
|
||||||
|
[Queries.BankaraBattleHistoriesQuery]: {
|
||||||
|
bankaraBattleHistories: {
|
||||||
|
summary: {
|
||||||
|
assistAverage: number;
|
||||||
|
deathAverage: number;
|
||||||
|
killAverage: number;
|
||||||
|
lose: number;
|
||||||
|
perUnitTimeMinute: number;
|
||||||
|
specialAverage: number;
|
||||||
|
win: number;
|
||||||
|
};
|
||||||
|
historyGroups: {
|
||||||
|
nodes: {
|
||||||
|
bankaraMatchChallenge: null | {
|
||||||
|
winCount: number;
|
||||||
|
loseCount: number;
|
||||||
|
maxWinCount: number;
|
||||||
|
maxLoseCount: number;
|
||||||
|
state: "Failed";
|
||||||
|
isPromo: boolean;
|
||||||
|
isUdemaeUp: boolean;
|
||||||
|
udemaeAfter: string;
|
||||||
|
earnedUdemaePoint: number;
|
||||||
|
};
|
||||||
|
historyDetails: {
|
||||||
|
nodes: {
|
||||||
|
id: string;
|
||||||
|
vsMode: {
|
||||||
|
mode: "BANKARA";
|
||||||
|
id: string;
|
||||||
|
};
|
||||||
|
vsRule: {
|
||||||
|
name: string;
|
||||||
|
id: string;
|
||||||
|
};
|
||||||
|
vsStage: {
|
||||||
|
name: string;
|
||||||
|
id: string;
|
||||||
|
image: Image;
|
||||||
|
};
|
||||||
|
judgement: "LOSE";
|
||||||
|
player: unknown;
|
||||||
|
}[];
|
||||||
|
};
|
||||||
|
}[];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
[Queries.PrivateBattleHistoriesQuery]: Record<never, never>;
|
||||||
|
[Queries.VsHistoryDetailQuery]: Record<never, never>;
|
||||||
|
[Queries.CoopHistoryQuery]: Record<never, never>;
|
||||||
|
[Queries.CoopHistoryDetailQuery]: Record<never, never>;
|
||||||
|
};
|
||||||
|
export type GraphQLResponse<T> = {
|
||||||
|
data: T;
|
||||||
|
} | {
|
||||||
|
errors: {
|
||||||
|
message: string;
|
||||||
|
}[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export enum BattleType {
|
||||||
|
Regular,
|
||||||
|
Bankara,
|
||||||
|
Private,
|
||||||
|
}
|
||||||
|
|
||||||
|
export const BATTLE_QUERY_MAP: Record<BattleType, Queries> = {
|
||||||
|
[BattleType.Regular]: Queries.RegularBattleHistoriesQuery,
|
||||||
|
[BattleType.Bankara]: Queries.BankaraBattleHistoriesQuery,
|
||||||
|
[BattleType.Private]: Queries.PrivateBattleHistoriesQuery,
|
||||||
|
};
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
export const S3SI_VERSION = "0.1.0";
|
|
||||||
export const NSOAPP_VERSION = "2.3.1";
|
|
||||||
export const USERAGENT = `s3si.ts/${S3SI_VERSION}`;
|
|
||||||
Loading…
Reference in New Issue