mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-03-21 18:04:10 -05:00
Update splatnet3-types
This commit is contained in:
parent
205f01ebf0
commit
2ab832f6b6
14
package-lock.json
generated
14
package-lock.json
generated
|
|
@ -23,7 +23,7 @@
|
|||
"node-notifier": "^10.0.1",
|
||||
"node-persist": "^3.1.0",
|
||||
"read": "^1.0.7",
|
||||
"splatnet3-types": "^0.1.20221202224136",
|
||||
"splatnet3-types": "^0.2.20221212221842",
|
||||
"supports-color": "^8.1.1",
|
||||
"tslib": "^2.4.1",
|
||||
"uuid": "^8.3.2",
|
||||
|
|
@ -4065,9 +4065,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"node_modules/splatnet3-types": {
|
||||
"version": "0.1.20221202224136",
|
||||
"resolved": "https://registry.npmjs.org/splatnet3-types/-/splatnet3-types-0.1.20221202224136.tgz",
|
||||
"integrity": "sha512-2C9ZynJQPcESAndxn/lbRxNH2l0vOSfykXtz1oVnR2yCqiiiR8kRXpqbI0mvJSNHzYlLz3KWSXATNYgYBw/0OQ=="
|
||||
"version": "0.2.20221212221842",
|
||||
"resolved": "https://registry.npmjs.org/splatnet3-types/-/splatnet3-types-0.2.20221212221842.tgz",
|
||||
"integrity": "sha512-A/fs/0mUBpdH2q2ye7z5fbUFOFJdmD9t0j36RZ0fpTm8hiA0orjZ15l8FJ1gZTo8xVtzYbA9cQWjq/dth0nPmw=="
|
||||
},
|
||||
"node_modules/sprintf-js": {
|
||||
"version": "1.1.2",
|
||||
|
|
@ -7769,9 +7769,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"splatnet3-types": {
|
||||
"version": "0.1.20221202224136",
|
||||
"resolved": "https://registry.npmjs.org/splatnet3-types/-/splatnet3-types-0.1.20221202224136.tgz",
|
||||
"integrity": "sha512-2C9ZynJQPcESAndxn/lbRxNH2l0vOSfykXtz1oVnR2yCqiiiR8kRXpqbI0mvJSNHzYlLz3KWSXATNYgYBw/0OQ=="
|
||||
"version": "0.2.20221212221842",
|
||||
"resolved": "https://registry.npmjs.org/splatnet3-types/-/splatnet3-types-0.2.20221212221842.tgz",
|
||||
"integrity": "sha512-A/fs/0mUBpdH2q2ye7z5fbUFOFJdmD9t0j36RZ0fpTm8hiA0orjZ15l8FJ1gZTo8xVtzYbA9cQWjq/dth0nPmw=="
|
||||
},
|
||||
"sprintf-js": {
|
||||
"version": "1.1.2",
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
"node-notifier": "^10.0.1",
|
||||
"node-persist": "^3.1.0",
|
||||
"read": "^1.0.7",
|
||||
"splatnet3-types": "^0.1.20221202224136",
|
||||
"splatnet3-types": "^0.2.20221212221842",
|
||||
"supports-color": "^8.1.1",
|
||||
"tslib": "^2.4.1",
|
||||
"uuid": "^8.3.2",
|
||||
|
|
|
|||
|
|
@ -57,8 +57,11 @@ export async function handler(argv: ArgumentsCamelCase<Arguments>) {
|
|||
|
||||
console.warn('Downloading summaries for device %s (%s)', device.label, device.deviceId);
|
||||
|
||||
await dumpMonthlySummariesForDevice(moon, directory, device.deviceId);
|
||||
await dumpDailySummariesForDevice(moon, directory, device.deviceId);
|
||||
const monthly = await dumpMonthlySummariesForDevice(moon, directory, device.deviceId);
|
||||
const daily = await dumpDailySummariesForDevice(moon, directory, device.deviceId);
|
||||
|
||||
console.warn('Downloaded %d monthly and %d daily summaries for device %s (%s)',
|
||||
monthly.length, daily.length, device.label, device.deviceId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -66,22 +69,35 @@ async function dumpMonthlySummariesForDevice(moon: MoonApi, directory: string, d
|
|||
debug('Fetching monthly summaries for device %s', device);
|
||||
const monthlySummaries = await moon.getMonthlySummaries(device);
|
||||
|
||||
const downloaded = [];
|
||||
const skipped = [];
|
||||
|
||||
for (const item of monthlySummaries.items) {
|
||||
const filename = 'pctl-monthly-' + item.deviceId + '-' + item.month + '.json';
|
||||
const file = path.join(directory, filename);
|
||||
|
||||
try {
|
||||
await fs.stat(file);
|
||||
debug('Skipping monthly summary %s for device %s, file already exists', item.month, item.deviceId);
|
||||
skipped.push(item.month);
|
||||
continue;
|
||||
} catch (err) {}
|
||||
|
||||
debug('Fetching monthly summary %s for device %s', item.month, item.deviceId);
|
||||
console.warn('Fetching monthly summary %s for device %s', item.month, item.deviceId);
|
||||
const summary = await moon.getMonthlySummary(item.deviceId, item.month);
|
||||
|
||||
debug('Writing %s', filename);
|
||||
await fs.writeFile(file, JSON.stringify(summary, null, 4) + '\n', 'utf-8');
|
||||
|
||||
downloaded.push(item.month);
|
||||
}
|
||||
|
||||
if (skipped.length) {
|
||||
if (skipped.length === 1) debug('Skipped monthly summary %s for device %s, file already exists', skipped[0], device);
|
||||
else debug('Skipped monthly summaries %s for device %s, files already exist', skipped.join(', '), device);
|
||||
}
|
||||
|
||||
return downloaded;
|
||||
}
|
||||
|
||||
async function dumpDailySummariesForDevice(moon: MoonApi, directory: string, device: string) {
|
||||
|
|
@ -89,6 +105,9 @@ async function dumpDailySummariesForDevice(moon: MoonApi, directory: string, dev
|
|||
const summaries = await moon.getDailySummaries(device);
|
||||
const timestamp = Date.now();
|
||||
|
||||
const downloaded = [];
|
||||
const skipped = [];
|
||||
|
||||
for (const summary of summaries.items) {
|
||||
const filename = 'pctl-daily-' + summary.deviceId + '-' + summary.date +
|
||||
(summary.result === DailySummaryResult.ACHIEVED ? '' : '-' + timestamp) + '.json';
|
||||
|
|
@ -96,11 +115,20 @@ async function dumpDailySummariesForDevice(moon: MoonApi, directory: string, dev
|
|||
|
||||
try {
|
||||
await fs.stat(file);
|
||||
debug('Skipping daily summary %s for device %s, file already exists', summary.date, summary.deviceId);
|
||||
skipped.push(summary.date);
|
||||
continue;
|
||||
} catch (err) {}
|
||||
|
||||
debug('Writing %s', filename);
|
||||
await fs.writeFile(file, JSON.stringify(summary, null, 4) + '\n', 'utf-8');
|
||||
|
||||
downloaded.push(summary.date);
|
||||
}
|
||||
|
||||
if (skipped.length) {
|
||||
if (skipped.length === 1) debug('Skipped daily summary %s for device %s, file already exists', skipped[0], device);
|
||||
else debug('Skipped daily summaries %s for device %s, files already exist', skipped.join(', '), device);
|
||||
}
|
||||
|
||||
return downloaded;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import * as net from 'node:net';
|
|||
import createDebug from 'debug';
|
||||
import express, { Request, Response } from 'express';
|
||||
import * as persist from 'node-persist';
|
||||
import { BankaraMatchMode, BankaraMatchSetting, CoopSetting, DetailVotingStatusResult, FestMatchSetting, FestState, FestTeam_schedule, FestTeam_votingStatus, FestVoteState, Fest_schedule, FriendListResult, FriendOnlineState, Friend_friendList, GraphQLSuccessResponse, LeagueMatchSetting, RegularMatchSetting, StageScheduleResult, VsMode, XMatchSetting } from 'splatnet3-types/splatnet3';
|
||||
import { BankaraMatchMode, BankaraMatchSetting_schedule, CoopSetting_schedule, DetailVotingStatusResult, FestMatchSetting_schedule, FestState, FestTeam_schedule, FestTeam_votingStatus, FestVoteState, Fest_schedule, FriendListResult, FriendOnlineState, Friend_friendList, GraphQLSuccessResponse, LeagueMatchSetting_schedule, RegularMatchSetting_schedule, StageScheduleResult, VsMode, XMatchSetting_schedule } from 'splatnet3-types/splatnet3';
|
||||
import type { Arguments as ParentArguments } from '../cli.js';
|
||||
import { ArgumentsCamelCase, Argv, YargsArguments } from '../util/yargs.js';
|
||||
import { initStorage } from '../util/storage.js';
|
||||
|
|
@ -19,8 +19,6 @@ import { getTitleIdFromEcUrl } from '../util/misc.js';
|
|||
|
||||
const debug = createDebug('cli:presence-server');
|
||||
|
||||
type CoopSetting_schedule = Pick<CoopSetting, '__typename' | 'coopStage' | 'weapons'>;
|
||||
|
||||
interface AllUsersResult extends Friend {
|
||||
splatoon3?: Friend_friendList | null;
|
||||
splatoon3_fest_team?: FestTeam_votingStatus | null;
|
||||
|
|
@ -30,8 +28,8 @@ interface PresenceResponse {
|
|||
splatoon3?: Friend_friendList | null;
|
||||
splatoon3_fest_team?: (FestTeam_schedule & FestTeam_votingStatus) | null;
|
||||
splatoon3_vs_setting?:
|
||||
RegularMatchSetting | BankaraMatchSetting | FestMatchSetting |
|
||||
LeagueMatchSetting | XMatchSetting | null;
|
||||
RegularMatchSetting_schedule | BankaraMatchSetting_schedule | FestMatchSetting_schedule |
|
||||
LeagueMatchSetting_schedule | XMatchSetting_schedule | null;
|
||||
splatoon3_coop_setting?: CoopSetting_schedule | null;
|
||||
splatoon3_fest?: Fest_schedule | null;
|
||||
}
|
||||
|
|
@ -465,7 +463,7 @@ class Server extends HttpServer {
|
|||
friend.onlineState === FriendOnlineState.COOP_MODE_FIGHTING
|
||||
) {
|
||||
const schedules = await user.getSchedules();
|
||||
const coop_schedules = friend.coopMode === 'BIG_RUN' ?
|
||||
const coop_schedules = friend.coopRule === 'BIG_RUN' ?
|
||||
schedules.coopGroupingSchedule.bigRunSchedules :
|
||||
schedules.coopGroupingSchedule.regularSchedules;
|
||||
const coop_setting = getSchedule(coop_schedules)?.setting;
|
||||
|
|
@ -624,7 +622,6 @@ function createFestVoteTeam(
|
|||
url: getSplatoon3inkUrl(team.image.url),
|
||||
},
|
||||
color: team.color,
|
||||
myVoteState: state,
|
||||
votes: {nodes: []},
|
||||
preVotes: {nodes: []},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -108,28 +108,28 @@ export async function dumpResults(
|
|||
result: battles.data.latestBattleHistories,
|
||||
fest: battles.data.currentFest,
|
||||
player: 'currentPlayer' in battles.data ?
|
||||
(battles.data as LatestBattleHistoriesRefetchResult).currentPlayer : undefined,
|
||||
(battles.data as LatestBattleHistoriesRefetchResult<true>).currentPlayer : undefined,
|
||||
query: refresh ? RequestId.LatestBattleHistoriesRefetchQuery : RequestId.LatestBattleHistoriesQuery,
|
||||
be_version: battles[ResponseSymbol].headers.get('x-be-version'),
|
||||
},
|
||||
regularBattleHistories: {
|
||||
result: battles_regular.data.regularBattleHistories,
|
||||
player: 'currentPlayer' in battles_regular.data ?
|
||||
(battles_regular.data as RegularBattleHistoriesRefetchResult).currentPlayer : undefined,
|
||||
(battles_regular.data as RegularBattleHistoriesRefetchResult<true>).currentPlayer : undefined,
|
||||
query: refresh ? RequestId.RegularBattleHistoriesRefetchQuery : RequestId.RegularBattleHistoriesQuery,
|
||||
be_version: battles_regular[ResponseSymbol].headers.get('x-be-version'),
|
||||
},
|
||||
bankaraBattleHistories: {
|
||||
result: battles_anarchy.data.bankaraBattleHistories,
|
||||
player: 'currentPlayer' in battles_anarchy.data ?
|
||||
(battles_anarchy.data as BankaraBattleHistoriesRefetchResult).currentPlayer : undefined,
|
||||
(battles_anarchy.data as BankaraBattleHistoriesRefetchResult<true>).currentPlayer : undefined,
|
||||
query: refresh ? RequestId.BankaraBattleHistoriesRefetchQuery : RequestId.BankaraBattleHistoriesQuery,
|
||||
be_version: battles_anarchy[ResponseSymbol].headers.get('x-be-version'),
|
||||
},
|
||||
privateBattleHistories: {
|
||||
result: battles_private.data.privateBattleHistories,
|
||||
player: 'currentPlayer' in battles_private.data ?
|
||||
(battles_private.data as PrivateBattleHistoriesRefetchResult).currentPlayer : undefined,
|
||||
(battles_private.data as PrivateBattleHistoriesRefetchResult<true>).currentPlayer : undefined,
|
||||
query: refresh ? RequestId.PrivateBattleHistoriesRefetchQuery : RequestId.PrivateBattleHistoriesQuery,
|
||||
be_version: battles_private[ResponseSymbol].headers.get('x-be-version'),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ export async function handler(argv: ArgumentsCamelCase<Arguments>) {
|
|||
friend.nickname,
|
||||
getStateDescription(friend.onlineState,
|
||||
getVsModeDescription(friend.vsMode) ?? friend.vsMode?.name,
|
||||
getCoopModeDescription(friend.coopMode) ?? undefined),
|
||||
getCoopModeDescription(friend.coopRule) ?? undefined),
|
||||
typeof friend.isLocked === 'boolean' ? friend.isLocked ? 'Yes' : 'No' : '-',
|
||||
typeof friend.isVcEnabled === 'boolean' ? friend.isVcEnabled ? 'Yes' : 'No' : '-',
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -1,20 +1,18 @@
|
|||
import createDebug from 'debug';
|
||||
import persist from 'node-persist';
|
||||
import DiscordRPC from 'discord-rpc';
|
||||
import { BankaraMatchMode, BankaraMatchSetting, CoopSchedule, CoopSetting, DetailVotingStatusResult, FestMatchSetting, FestState, FestTeamRole, FestTeam_schedule, FestTeam_votingStatus, Fest_schedule, FriendListResult, FriendOnlineState, GraphQLSuccessResponse, LeagueMatchSetting, RegularMatchSetting, StageScheduleResult, VsSchedule_bankara, VsSchedule_fest, VsSchedule_league, VsSchedule_regular, VsSchedule_xMatch, XMatchSetting } from 'splatnet3-types/splatnet3';
|
||||
import { BankaraMatchMode, BankaraMatchSetting, CoopSchedule, CoopSchedule_schedule, CoopSetting, DetailVotingStatusResult, FestMatchSetting, FestState, FestTeamRole, FestTeam_schedule, FestTeam_votingStatus, Fest_schedule, FriendListResult, FriendOnlineState, GraphQLSuccessResponse, LeagueMatchSetting, RegularMatchSetting, StageScheduleResult, VsSchedule_bankara, VsSchedule_fest, VsSchedule_league, VsSchedule_regular, VsSchedule_xMatch, XMatchSetting } from 'splatnet3-types/splatnet3';
|
||||
import { Game } from '../../api/coral-types.js';
|
||||
import SplatNet3Api from '../../api/splatnet3.js';
|
||||
import { DiscordPresenceExternalMonitorsConfiguration } from '../../app/common/types.js';
|
||||
import { Arguments } from '../../cli/nso/presence.js';
|
||||
import { getBulletToken, SavedBulletToken } from '../../common/auth/splatnet3.js';
|
||||
import { ExternalMonitorPresenceInterface, ZncProxyDiscordPresence } from '../../common/presence.js';
|
||||
import { ExternalMonitorPresenceInterface } from '../../common/presence.js';
|
||||
import { EmbeddedLoop, LoopResult } from '../../util/loop.js';
|
||||
import { ArgumentsCamelCase } from '../../util/yargs.js';
|
||||
import { DiscordPresenceContext, ErrorResult } from '../types.js';
|
||||
import { product } from '../../util/product.js';
|
||||
|
||||
type CoopSchedule_schedule = Pick<CoopSchedule, 'startTime' | 'endTime' | 'setting'>;
|
||||
|
||||
const debug = createDebug('nxapi:discord:splatnet3');
|
||||
|
||||
export default class SplatNet3Monitor extends EmbeddedLoop {
|
||||
|
|
@ -323,7 +321,7 @@ export function callback(activity: DiscordRPC.Presence, game: Game, context?: Di
|
|||
presence_proxy_data && 'splatoon3_coop_setting' in presence_proxy_data ?
|
||||
presence_proxy_data.splatoon3_coop_setting :
|
||||
monitor ?
|
||||
friend.coopMode === 'BIG_RUN' ?
|
||||
friend.coopRule === 'BIG_RUN' ?
|
||||
monitor.coop_big_run_schedule?.setting :
|
||||
monitor.coop_regular_schedule?.setting :
|
||||
null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user