Move api source code files

This commit is contained in:
daydreamer-json
2026-02-05 09:49:44 +09:00
parent 4dd0978646
commit afa54d0984
12 changed files with 52 additions and 41 deletions

View File

@@ -3,7 +3,7 @@ import CliTable3 from 'cli-table3';
import { HTTPError } from 'ky';
import { DateTime } from 'luxon';
import prompts from 'prompts';
import apiUtils from '../utils/api.js';
import apiUtils from '../utils/api/index.js';
import argvUtils from '../utils/argv.js';
import appConfig from '../utils/config.js';
import exitUtils from '../utils/exit.js';
@@ -40,7 +40,7 @@ async function mainCmdHandler() {
if (needRetrieveToken === false) {
try {
logger.debug('Retrieving account service OAuth 2.0 code ...');
oauth2TokenPreRsp = await apiUtils.apiAkEndfield.accountService.user.oauth2.v2.grant(
oauth2TokenPreRsp = await apiUtils.akEndfield.accountService.user.oauth2.v2.grant(
cfg.appCode.accountService.osWinRel,
argvUtils.getArgv()['token'],
);
@@ -86,7 +86,7 @@ async function mainCmdHandler() {
}
})();
logger.debug('Retrieving account service token ...');
const accSrvTokenRsp = await apiUtils.apiAkEndfield.accountService.user.auth.v1.tokenByEmailPassword(
const accSrvTokenRsp = await apiUtils.akEndfield.accountService.user.auth.v1.tokenByEmailPassword(
argvUtils.getArgv()['email'],
argvUtils.getArgv()['password'],
);
@@ -96,18 +96,18 @@ async function mainCmdHandler() {
oauth2TokenPreRsp === null ? logger.debug('Retrieving account service OAuth 2.0 code ...') : undefined;
const oauth2TokenRsp =
oauth2TokenPreRsp === null
? await apiUtils.apiAkEndfield.accountService.user.oauth2.v2.grant(
? await apiUtils.akEndfield.accountService.user.oauth2.v2.grant(
cfg.appCode.accountService.osWinRel,
argvUtils.getArgv()['token'],
)
: oauth2TokenPreRsp;
const oauth2TokenBindRsp = await apiUtils.apiAkEndfield.accountService.user.oauth2.v2.grant(
const oauth2TokenBindRsp = await apiUtils.akEndfield.accountService.user.oauth2.v2.grant(
cfg.appCode.accountService.binding,
argvUtils.getArgv()['token'],
1,
);
logger.debug('Retrieving u8 access token ...');
const u8TokenRsp = await apiUtils.apiAkEndfield.u8.user.auth.v2.tokenByChToken(
const u8TokenRsp = await apiUtils.akEndfield.u8.user.auth.v2.tokenByChToken(
cfg.appCode.u8.osWinRel,
cfg.channel.osWinRel,
oauth2TokenRsp.data.code,
@@ -119,13 +119,13 @@ async function mainCmdHandler() {
logger.info('Retrieving user information data ...');
logger.debug('Retrieving user account data ...');
const userAccData = await apiUtils.apiAkEndfield.accountService.user.info.v1.basic(
const userAccData = await apiUtils.akEndfield.accountService.user.info.v1.basic(
cfg.appCode.accountService.osWinRel,
argvUtils.getArgv()['token'],
);
logger.debug('Retrieving user game server data ...');
const userGameData = await apiUtils.apiAkEndfield.u8.game.server.v1.serverList(u8TokenRsp.data.token);
const userGameBindingData = await apiUtils.apiAkEndfield.binding.account.binding.v1.bindingList(
const userGameData = await apiUtils.akEndfield.u8.game.server.v1.serverList(u8TokenRsp.data.token);
const userGameBindingData = await apiUtils.akEndfield.binding.account.binding.v1.bindingList(
oauth2TokenBindRsp.data.token,
);
@@ -138,7 +138,7 @@ async function mainCmdHandler() {
if (!selectedServerAccData) throw new Error('Game account not found');
const id = selectedServerAccData.serverId;
logger.debug('Confirming server availability ...');
const confirmServerRsp = await apiUtils.apiAkEndfield.u8.game.role.v1.confirmServer(
const confirmServerRsp = await apiUtils.akEndfield.u8.game.role.v1.confirmServer(
u8TokenRsp.data.token,
parseInt(id),
);
@@ -157,7 +157,7 @@ async function mainCmdHandler() {
for (const poolTypeEntry of poolTypeList) {
let seqId: string | null = null;
while (true) {
const rsp = await apiUtils.apiAkEndfield.webview.record.char(
const rsp = await apiUtils.akEndfield.webview.record.char(
u8TokenRsp.data.token,
parseInt(selectedServerId),
poolTypeEntry,
@@ -179,7 +179,7 @@ async function mainCmdHandler() {
const arr = [];
const poolIdList = [...new Set(gachaRecordRsp.map((e) => e.poolId))];
for (const poolId of poolIdList) {
const rsp = await apiUtils.apiAkEndfield.webview.content(parseInt(selectedServerId), poolId, 'ja-jp');
const rsp = await apiUtils.akEndfield.webview.content(parseInt(selectedServerId), poolId, 'ja-jp');
arr.push({ poolId, ...rsp.data.pool });
}
return arr;

View File

@@ -2,7 +2,7 @@ import path from 'node:path';
import { DateTime } from 'luxon';
import PQueue from 'p-queue';
import semver from 'semver';
import apiUtils from '../utils/api.js';
import apiUtils from '../utils/api/index.js';
import argvUtils from '../utils/argv.js';
import appConfig from '../utils/config.js';
import logger from '../utils/logger.js';
@@ -99,7 +99,7 @@ async function mainCmdHandler() {
for (const target of gameTargets) {
await (async () => {
logger.debug(`Fetching latestGame (${target.name}) ...`);
const rsp = await apiUtils.apiAkEndfield.launcher.latestGame(
const rsp = await apiUtils.akEndfield.launcher.latestGame(
cfg.appCode.game.osWinRel,
target.launcherAppCode,
cfg.channel.osWinRel,
@@ -170,7 +170,7 @@ async function mainCmdHandler() {
const queue = new PQueue({ concurrency: appConfig.threadCount.network });
for (const ver of versionList) {
queue.add(async () => {
const rsp = await apiUtils.apiAkEndfield.launcher.latestGame(
const rsp = await apiUtils.akEndfield.launcher.latestGame(
cfg.appCode.game.osWinRel,
target.launcherAppCode,
cfg.channel.osWinRel,
@@ -244,7 +244,7 @@ async function mainCmdHandler() {
const versionInfoList = (
(await Bun.file(gameAllJsonPath).json()).map((e: any) => e.rsp) as Awaited<
ReturnType<typeof apiUtils.apiAkEndfield.launcher.latestGame>
ReturnType<typeof apiUtils.akEndfield.launcher.latestGame>
>[]
)
.map((e) => ({
@@ -258,7 +258,7 @@ async function mainCmdHandler() {
let isLatestWrote: boolean = false;
for (const versionInfoEntry of versionInfoList) {
if (!versionInfoEntry.randStr) throw new Error('version rand_str not found');
const rsp = await apiUtils.apiAkEndfield.launcher.latestGameResources(
const rsp = await apiUtils.akEndfield.launcher.latestGameResources(
cfg.appCode.game.osWinRel,
versionInfoEntry.versionMinor,
versionInfoEntry.version,
@@ -292,7 +292,7 @@ async function mainCmdHandler() {
logger.debug('Fetching latestLauncher ...');
const launcherTargetAppList = ['EndField', 'official'] as const;
for (const launcherTargetAppEntry of launcherTargetAppList) {
const rsp = await apiUtils.apiAkEndfield.launcher.latestLauncher(
const rsp = await apiUtils.akEndfield.launcher.latestLauncher(
cfg.appCode.launcher.osWinRel,
cfg.channel.osWinRel,
cfg.channel.osWinRel,
@@ -468,7 +468,7 @@ async function mainCmdHandler() {
).json();
const resVersionSet: {
resVersion: string;
rsp: { rsp: Awaited<ReturnType<typeof apiUtils.apiAkEndfield.launcher.latestGameResources>> };
rsp: { rsp: Awaited<ReturnType<typeof apiUtils.akEndfield.launcher.latestGameResources>> };
versions: string[];
}[] = (() => {
const resVersions: string[] = [...new Set(gameAllJson.map((e: any) => e.rsp.res_version))] as string[];

View File

@@ -1,9 +0,0 @@
import accountService from './api/accountService.js';
import binding from './api/binding.js';
import launcher from './api/launcher.js';
import u8 from './api/u8.js';
import webview from './api/webview.js';
export default {
apiAkEndfield: { launcher, accountService, u8, binding, webview },
};

View File

@@ -1,6 +1,6 @@
import ky from 'ky';
import * as TypesApiAkEndfield from '../../types/api/akEndfield/Api.js';
import appConfig from '../config.js';
import * as TypesApiAkEndfield from '../../../types/api/akEndfield/Api.js';
import appConfig from '../../config.js';
import defaultSettings from './defaultSettings.js';
export default {

View File

@@ -1,6 +1,6 @@
import ky from 'ky';
import * as TypesApiAkEndfield from '../../types/api/akEndfield/Api.js';
import appConfig from '../config.js';
import * as TypesApiAkEndfield from '../../../types/api/akEndfield/Api.js';
import appConfig from '../../config.js';
import defaultSettings from './defaultSettings.js';
export default {

View File

@@ -1,4 +1,4 @@
import appConfig from '../config.js';
import appConfig from '../../config.js';
export default {
ky: {

View File

@@ -0,0 +1,15 @@
import accountService from './accountService.js';
import binding from './binding.js';
import launcher from './launcher.js';
import launcherWeb from './launcherWeb.js';
import u8 from './u8.js';
import webview from './webview.js';
export default {
accountService,
binding,
launcher,
launcherWeb,
u8,
webview,
};

View File

@@ -1,7 +1,7 @@
import ky from 'ky';
import semver from 'semver';
import * as TypesApiAkEndfield from '../../types/api/akEndfield/Api.js';
import appConfig from '../config.js';
import * as TypesApiAkEndfield from '../../../types/api/akEndfield/Api.js';
import appConfig from '../../config.js';
import defaultSettings from './defaultSettings.js';
import launcherWeb from './launcherWeb.js';

View File

@@ -1,6 +1,6 @@
import ky from 'ky';
import * as TypesApiAkEndfield from '../../types/api/akEndfield/Api.js';
import appConfig from '../config.js';
import * as TypesApiAkEndfield from '../../../types/api/akEndfield/Api.js';
import appConfig from '../../config.js';
import defaultSettings from './defaultSettings.js';
export default {

View File

@@ -1,6 +1,6 @@
import ky from 'ky';
import * as TypesApiAkEndfield from '../../types/api/akEndfield/Api.js';
import appConfig from '../config.js';
import * as TypesApiAkEndfield from '../../../types/api/akEndfield/Api.js';
import appConfig from '../../config.js';
import defaultSettings from './defaultSettings.js';
export default {

View File

@@ -1,6 +1,6 @@
import ky from 'ky';
import * as TypesApiAkEndfield from '../../types/api/akEndfield/Api.js';
import appConfig from '../config.js';
import * as TypesApiAkEndfield from '../../../types/api/akEndfield/Api.js';
import appConfig from '../../config.js';
import defaultSettings from './defaultSettings.js';
export default {

5
src/utils/api/index.ts Normal file
View File

@@ -0,0 +1,5 @@
import akEndfield from './akEndfield/index.js';
export default {
akEndfield,
};