From f3f895ebd67243ca645e1ece3928f05cc7576164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20L=C3=B3pez=20Guimaraes?= Date: Sun, 9 Nov 2025 21:20:39 +0000 Subject: [PATCH] chore: Update pretendonetwork/grpc to 2.3.5 --- package-lock.json | 14 +++++++------- package.json | 2 +- src/cli/files-3ds.cmd.ts | 12 ++++++++++-- src/cli/files.cmd.ts | 12 ++++++++++-- src/cli/seed.cmd.ts | 11 +---------- src/cli/tasks.cmd.ts | 9 ++++++--- src/database.ts | 20 ++++++++++++++------ src/services/grpc/boss/v1/register-task.ts | 2 +- src/services/grpc/boss/v2/list-files-ctr.ts | 5 +++-- src/services/grpc/boss/v2/list-files-wup.ts | 3 ++- src/services/grpc/boss/v2/register-task.ts | 7 ++++++- src/services/grpc/boss/v2/update-task.ts | 2 +- src/types/mongoose/task.ts | 2 +- 13 files changed, 63 insertions(+), 38 deletions(-) diff --git a/package-lock.json b/package-lock.json index 233d95f..e8d3d58 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@aws-sdk/client-s3": "^3.723.0", "@pretendonetwork/boss-crypto": "^1.1.3", - "@pretendonetwork/grpc": "^2.3.4", + "@pretendonetwork/grpc": "^2.3.5", "@typegoose/auto-increment": "^4.13.1", "commander": "^14.0.0", "cron": "^4.3.3", @@ -2072,9 +2072,9 @@ } }, "node_modules/@pretendonetwork/grpc": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/@pretendonetwork/grpc/-/grpc-2.3.4.tgz", - "integrity": "sha512-Ajtk8nHR2Auaks6SKUkm0cDVivjuIhitz6xaaxmVfb0hyVdZZO4EfjEtQdsRLmfbA+SWDxdszBPRD+LBsIdjxQ==", + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@pretendonetwork/grpc/-/grpc-2.3.5.tgz", + "integrity": "sha512-FU0uvhZr8gFgiIi+gBtD6+5or34bHcd9X+ZVpRdc7IiupW5V+uxiXigJKX4Vd46QC412y+BEGofCjM1bBlTJhg==", "license": "AGPL-3.0-only", "dependencies": { "@bufbuild/protobuf": "^2.2.2", @@ -11320,9 +11320,9 @@ } }, "@pretendonetwork/grpc": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/@pretendonetwork/grpc/-/grpc-2.3.4.tgz", - "integrity": "sha512-Ajtk8nHR2Auaks6SKUkm0cDVivjuIhitz6xaaxmVfb0hyVdZZO4EfjEtQdsRLmfbA+SWDxdszBPRD+LBsIdjxQ==", + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@pretendonetwork/grpc/-/grpc-2.3.5.tgz", + "integrity": "sha512-FU0uvhZr8gFgiIi+gBtD6+5or34bHcd9X+ZVpRdc7IiupW5V+uxiXigJKX4Vd46QC412y+BEGofCjM1bBlTJhg==", "requires": { "@bufbuild/protobuf": "^2.2.2", "nice-grpc-common": "^2.0.2", diff --git a/package.json b/package.json index dd4bf9a..e538f21 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "dependencies": { "@aws-sdk/client-s3": "^3.723.0", "@pretendonetwork/boss-crypto": "^1.1.3", - "@pretendonetwork/grpc": "^2.3.4", + "@pretendonetwork/grpc": "^2.3.5", "@typegoose/auto-increment": "^4.13.1", "commander": "^14.0.0", "cron": "^4.3.3", diff --git a/src/cli/files-3ds.cmd.ts b/src/cli/files-3ds.cmd.ts index a5d42e7..b634cf1 100644 --- a/src/cli/files-3ds.cmd.ts +++ b/src/cli/files-3ds.cmd.ts @@ -12,12 +12,19 @@ const listCmd = new Command('ls') .description('List all task files in BOSS') .argument('', 'BOSS app to search in') .argument('', 'Task to search in') + .option('-c, --country [country]', 'Country to filter with') + .option('-l, --language [language]', 'Language to filter with') + .option('-a, --any', 'Shows any file regardless of country and language requirements') .action(commandHandler<[string, string]>(async (cmd): Promise => { const [appId, taskId] = cmd.args; + const opts = cmd.opts<{ country?: string; language?: string; any: boolean }>(); const ctx = getCliContext(); const { files } = await ctx.grpc.listFilesCTR({ bossAppId: appId, - taskId: taskId + taskId: taskId, + country: opts.country, + language: opts.language, + any: opts.any }); logOutputList(files, { format: cmd.format, @@ -40,7 +47,8 @@ const viewCmd = new Command('view') const ctx = getCliContext(); const { files } = await ctx.grpc.listFilesCTR({ bossAppId: appId, - taskId: taskId + taskId: taskId, + any: true }); const file = files.find(v => v.dataId === dataId); if (!file) { diff --git a/src/cli/files.cmd.ts b/src/cli/files.cmd.ts index 99469ac..9fd1553 100644 --- a/src/cli/files.cmd.ts +++ b/src/cli/files.cmd.ts @@ -12,12 +12,19 @@ const listCmd = new Command('ls') .description('List all task files in BOSS') .argument('', 'BOSS app to search in') .argument('', 'Task to search in') + .option('-c, --country [country]', 'Country to filter with') + .option('-l, --language [language]', 'Language to filter with') + .option('-a, --any', 'Shows any file regardless of country and language requirements') .action(commandHandler<[string, string]>(async (cmd): Promise => { const [appId, taskId] = cmd.args; + const opts = cmd.opts<{ country?: string; language?: string; any: boolean }>(); const ctx = getCliContext(); const { files } = await ctx.grpc.listFilesWUP({ bossAppId: appId, - taskId: taskId + taskId: taskId, + country: opts.country, + language: opts.language, + any: opts.any }); logOutputList(files, { format: cmd.format, @@ -41,7 +48,8 @@ const viewCmd = new Command('view') const ctx = getCliContext(); const { files } = await ctx.grpc.listFilesWUP({ bossAppId: appId, - taskId: taskId + taskId: taskId, + any: true }); const file = files.find(v => v.dataId === dataId); if (!file) { diff --git a/src/cli/seed.cmd.ts b/src/cli/seed.cmd.ts index 98d5473..967e0d9 100644 --- a/src/cli/seed.cmd.ts +++ b/src/cli/seed.cmd.ts @@ -81,19 +81,10 @@ export async function processTasksheet(ctx: CliContext, taskFiles: string[], fil bossAppId: bossAppId, id: taskName, titleId: BigInt(parseInt(xmlContents.TaskSheet.TitleId._text, 16)), - country: 'This value isnt used' + status: xmlContents.TaskSheet.ServiceStatus._text }); console.log(`${filename}: Created task`); } - await ctx.grpc.updateTask({ - bossAppId: bossAppId, - id: taskName, - updateData: { - titleId: BigInt(parseInt(xmlContents.TaskSheet.TitleId._text, 16)), - status: xmlContents.TaskSheet.ServiceStatus._text - } - }); - console.log(`${filename}: Updated title ID and status`); let xmlFiles = xmlContents.TaskSheet.Files?.File ?? []; if (!Array.isArray(xmlFiles)) { diff --git a/src/cli/tasks.cmd.ts b/src/cli/tasks.cmd.ts index 5b7ac21..da4c115 100644 --- a/src/cli/tasks.cmd.ts +++ b/src/cli/tasks.cmd.ts @@ -54,17 +54,20 @@ const createCmd = new Command('create') .argument('', 'BOSS app to store the task in') .requiredOption('--id ', 'Id of the task') .requiredOption('--title-id ', 'Title ID for the task') + .option('--status [status]', 'Initial status of the task') + .option('--interval [interval]', 'Interval of the task') .option('--desc [desc]', 'Description of the task') .action(commandHandler<[string]>(async (cmd): Promise => { const [appId] = cmd.args; const ctx = getCliContext(); - const opts = cmd.opts<{ id: string; titleId: string; desc?: string }>(); + const opts = cmd.opts<{ id: string; titleId: string; status?: string; interval?: string; desc?: string }>(); const { task } = await ctx.grpc.registerTask({ bossAppId: appId, id: opts.id, titleId: BigInt(parseInt(opts.titleId, 16)), - description: opts.desc ?? '', - country: 'This value isnt used' + status: opts.status ?? 'open', + interval: Number(opts.interval ?? 0), + description: opts.desc ?? '' }); if (!task) { console.log(`Failed to create task!`); diff --git a/src/database.ts b/src/database.ts index 9cf306e..fa8762e 100644 --- a/src/database.ts +++ b/src/database.ts @@ -54,7 +54,7 @@ export function getTask(bossAppID: string, taskID: string): Promise { +export function getCTRTaskFiles(allowDeleted: boolean, bossAppID: string, taskID: string, country?: string, language?: string, any: boolean = false): Promise { verifyConnected(); const filter: mongoose.FilterQuery = { @@ -74,7 +74,7 @@ export function getCTRTaskFiles(allowDeleted: boolean, bossAppID: string, taskID { supported_countries: country } ] }); - } else { + } else if (!any) { filter.$and?.push({ supported_countries: { $eq: [] } }); @@ -87,16 +87,20 @@ export function getCTRTaskFiles(allowDeleted: boolean, bossAppID: string, taskID { supported_languages: language } ] }); - } else { + } else if (!any) { filter.$and?.push({ supported_languages: { $eq: [] } }); } + if (filter.$and?.length === 0) { + delete filter.$and; + } + return FileCTR.find(filter); } -export function getWUPTaskFiles(allowDeleted: boolean, bossAppID: string, taskID: string, country?: string, language?: string): Promise { +export function getWUPTaskFiles(allowDeleted: boolean, bossAppID: string, taskID: string, country?: string, language?: string, any: boolean = false): Promise { verifyConnected(); const filter: mongoose.FilterQuery = { @@ -116,7 +120,7 @@ export function getWUPTaskFiles(allowDeleted: boolean, bossAppID: string, taskID { supported_countries: country } ] }); - } else { + } else if (!any) { filter.$and?.push({ supported_countries: { $eq: [] } }); @@ -129,12 +133,16 @@ export function getWUPTaskFiles(allowDeleted: boolean, bossAppID: string, taskID { supported_languages: language } ] }); - } else { + } else if (!any) { filter.$and?.push({ supported_languages: { $eq: [] } }); } + if (filter.$and?.length === 0) { + delete filter.$and; + } + return FileWUP.find(filter); } diff --git a/src/services/grpc/boss/v1/register-task.ts b/src/services/grpc/boss/v1/register-task.ts index 884c033..aabc29b 100644 --- a/src/services/grpc/boss/v1/register-task.ts +++ b/src/services/grpc/boss/v1/register-task.ts @@ -53,7 +53,7 @@ export async function registerTask(request: RegisterTaskRequest, context: CallCo in_game_id: taskID, boss_app_id: bossAppID, creator_pid: context.user?.pid, - status: 'open', // TODO - Make this configurable + status: 'open', title_id: titleID, description: description, created: Date.now(), diff --git a/src/services/grpc/boss/v2/list-files-ctr.ts b/src/services/grpc/boss/v2/list-files-ctr.ts index 00328ff..dd03ee7 100644 --- a/src/services/grpc/boss/v2/list-files-ctr.ts +++ b/src/services/grpc/boss/v2/list-files-ctr.ts @@ -10,6 +10,7 @@ export async function listFilesCTR(request: ListFilesCTRRequest): Promise ({ deleted: file.deleted, - dataId: file.serial_number, // TODO - Is this okay? + dataId: file.serial_number, taskId: file.task_id, bossAppId: file.boss_app_id, supportedCountries: file.supported_countries, diff --git a/src/services/grpc/boss/v2/list-files-wup.ts b/src/services/grpc/boss/v2/list-files-wup.ts index 5b8522a..a537561 100644 --- a/src/services/grpc/boss/v2/list-files-wup.ts +++ b/src/services/grpc/boss/v2/list-files-wup.ts @@ -10,6 +10,7 @@ export async function listFilesWUP(request: ListFilesWUPRequest): Promise ({ diff --git a/src/services/grpc/boss/v2/register-task.ts b/src/services/grpc/boss/v2/register-task.ts index e39df3e..30c67f4 100644 --- a/src/services/grpc/boss/v2/register-task.ts +++ b/src/services/grpc/boss/v2/register-task.ts @@ -16,6 +16,7 @@ export async function registerTask(request: RegisterTaskRequest, context: CallCo const taskID = request.id.trim(); const bossAppID = request.bossAppId.trim(); const titleID = request.titleId.toString(16).toLowerCase().padStart(16, '0'); + const status = request.status; const description = request.description.trim(); if (!taskID) { @@ -38,6 +39,10 @@ export async function registerTask(request: RegisterTaskRequest, context: CallCo throw new ServerError(Status.ALREADY_EXISTS, `Task ${taskID} already exists for BOSS app ${bossAppID}`); } + if (status !== 'open' && status !== 'close') { + throw new ServerError(Status.INVALID_ARGUMENT, `Status ${status} is invalid`); + } + // * BOSS tasks have 2 IDs // * - 1: The ID which is registered in-game // * - 2: The ID which is registered on the server @@ -53,7 +58,7 @@ export async function registerTask(request: RegisterTaskRequest, context: CallCo in_game_id: taskID, boss_app_id: bossAppID, creator_pid: context.user?.pid, - status: 'open', // TODO - Make this configurable + status, title_id: titleID, description: description, created: Date.now(), diff --git a/src/services/grpc/boss/v2/update-task.ts b/src/services/grpc/boss/v2/update-task.ts index 34cd712..be2413b 100644 --- a/src/services/grpc/boss/v2/update-task.ts +++ b/src/services/grpc/boss/v2/update-task.ts @@ -33,7 +33,7 @@ export async function updateTask(request: UpdateTaskRequest, context: CallContex throw new ServerError(Status.INVALID_ARGUMENT, `Task ${taskID} not found for BOSS app ${bossAppID}`); } - if (updateData.status !== 'open') { + if (updateData.status !== 'open' && updateData.status !== 'close') { throw new ServerError(Status.INVALID_ARGUMENT, `Status ${updateData.status} is invalid`); } diff --git a/src/types/mongoose/task.ts b/src/types/mongoose/task.ts index 9204472..d50e362 100644 --- a/src/types/mongoose/task.ts +++ b/src/types/mongoose/task.ts @@ -6,7 +6,7 @@ export interface ITask { in_game_id: string; boss_app_id: string; creator_pid: number; - status: 'open'; // TODO - Make this a union. What else is there? + status: 'open' | 'close'; // TODO - Make this a union. What else is there? title_id: string; description: string; created: bigint;