From 25f66be16a3bb98bd5b14ede27d84bd385121e81 Mon Sep 17 00:00:00 2001 From: edmand46 Date: Thu, 13 Aug 2026 12:10:07 +0300 Subject: [PATCH] quests: reportProgress on QuestsService + regenerated DTOs --- src/generated/api.ts | 8 +++++++- src/generated/quests.ts | 9 +++++++++ src/quests/QuestsService.ts | 6 ++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/generated/api.ts b/src/generated/api.ts index 4b6f6a1..ec439f3 100644 --- a/src/generated/api.ts +++ b/src/generated/api.ts @@ -7,7 +7,7 @@ import type { GetInventoryResponse } from './inventory.js'; import type { GetRankingResponse, SubmitScoreRequest } from './leaderboards.js'; import type { PlayerProfile } from './player.js'; import type { GetProjectStorageResponse, UpdateProjectStorageRequest } from './project-storage.js'; -import type { ClaimQuestRequest, ClaimQuestResponse, ListQuestsRequest, ListQuestsResponse } from './quests.js'; +import type { ClaimQuestRequest, ClaimQuestResponse, ListQuestsRequest, ListQuestsResponse, ReportQuestProgressRequest, ReportQuestProgressResponse } from './quests.js'; import type { ListRemoteConfigsResponse, RemoteConfig } from './remote-config.js'; import type { GetScenarioRunRequest, GetScenarioRunResponse, HandleScenarioCallbackRequest, HandleScenarioCallbackResponse, TriggerScenarioRequest, TriggerScenarioResponse, UpdateScenarioCounterRequest, UpdateScenarioCounterResponse } from './scenarios.js'; import type { GetStorageResponse, UpdateStorageRequest } from './storage.js'; @@ -201,6 +201,12 @@ export const api = { ): Promise => t.request('POST', '/sdk/v1/authorization/refresh', body), + reportQuestProgress: ( + t: Transport, + body: ReportQuestProgressRequest, + ): Promise => + t.request('POST', '/sdk/v1/quests/progress', body), + submitScore: ( t: Transport, path: { slug: string }, diff --git a/src/generated/quests.ts b/src/generated/quests.ts index fbb7f4e..7f50342 100644 --- a/src/generated/quests.ts +++ b/src/generated/quests.ts @@ -40,3 +40,12 @@ export interface QuestReward { "itemId"?: string; } +export interface ReportQuestProgressRequest { + "amount"?: number; + "metric"?: string; +} + +export interface ReportQuestProgressResponse { + "completedQuestIds"?: string[]; +} + diff --git a/src/quests/QuestsService.ts b/src/quests/QuestsService.ts index de7987f..159fd84 100644 --- a/src/quests/QuestsService.ts +++ b/src/quests/QuestsService.ts @@ -23,4 +23,10 @@ export class QuestsService { claim(questId: string): Promise { return api.claimQuest(this.ctx, { questId }); } + + /** Reports metric progress; returns ids of quests completed by this report. */ + async reportProgress(metric: string, amount: number): Promise { + const response = await api.reportQuestProgress(this.ctx, { metric, amount }); + return response.completedQuestIds ?? []; + } }