diff --git a/src/commands/getQuests.ts b/src/commands/getQuest.ts similarity index 61% rename from src/commands/getQuests.ts rename to src/commands/getQuest.ts index f90ec822..c3b2c76d 100644 --- a/src/commands/getQuests.ts +++ b/src/commands/getQuest.ts @@ -1,4 +1,4 @@ import {Command} from '../generated/schemas'; import {schemaCommandFactory} from '../utils/commandFactory'; -export const getQuests = schemaCommandFactory(Command.GET_QUESTS); +export const getQuest = schemaCommandFactory(Command.GET_QUEST); diff --git a/src/commands/index.ts b/src/commands/index.ts index 1fc90c26..9ceb3b4d 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -19,7 +19,7 @@ import {userSettingsGetLocale} from './userSettingsGetLocale'; // START-GENERATED-SECTION import {authenticate} from './authenticate'; import {getActivityInstanceConnectedParticipants} from './getActivityInstanceConnectedParticipants'; -import {getQuests} from './getQuests'; +import {getQuest} from './getQuest'; import {getQuestEnrollmentStatus} from './getQuestEnrollmentStatus'; import {getRelationships} from './getRelationships'; import {getUser} from './getUser'; @@ -56,7 +56,7 @@ function commands(sendCommand: TSendCommand) { // START-GENERATED-SECTION authenticate: authenticate(sendCommand), getActivityInstanceConnectedParticipants: getActivityInstanceConnectedParticipants(sendCommand), - getQuests: getQuests(sendCommand), + getQuest: getQuest(sendCommand), getQuestEnrollmentStatus: getQuestEnrollmentStatus(sendCommand), getRelationships: getRelationships(sendCommand), getUser: getUser(sendCommand), diff --git a/src/generated/schema.json b/src/generated/schema.json index 1924057b..7a9cad8a 100644 --- a/src/generated/schema.json +++ b/src/generated/schema.json @@ -459,27 +459,18 @@ "additionalProperties": false } }, - "GET_QUESTS": { + "GET_QUEST": { "request": null, "response": { "type": "object", - "description": "Response for \"GET_QUESTS\" Command", + "description": "Response for \"GET_QUEST\" Command", "properties": { - "quests": { - "type": "array", - "items": { - "type": "object", - "properties": { - "quest_id": {"type": "string"}, - "enrolled_at": {"type": ["string", "null"]}, - "external_cta_url": {"type": "string"} - }, - "required": ["quest_id", "external_cta_url"], - "additionalProperties": false - } - } + "quest_id": {"type": "string"}, + "enrolled_at": {"type": ["string", "null"]}, + "completed_at": {"type": ["string", "null"]}, + "external_cta_url": {"type": "string"} }, - "required": ["quests"], + "required": ["quest_id", "external_cta_url"], "additionalProperties": false } }, diff --git a/src/generated/schemas.ts b/src/generated/schemas.ts index 71c66387..dd9fd8ce 100644 --- a/src/generated/schemas.ts +++ b/src/generated/schemas.ts @@ -334,19 +334,16 @@ export const QuestStartTimerResponseSchema = z .describe('Response for "QUEST_START_TIMER" Command'); export type QuestStartTimerResponse = zInfer; -// GET_QUESTS -export const GetQuestsResponseSchema = z +// GET_QUEST +export const GetQuestResponseSchema = z .object({ - quests: z.array( - z.object({ - quest_id: z.string(), - enrolled_at: z.union([z.string(), z.null()]).optional(), - external_cta_url: z.string(), - }), - ), + quest_id: z.string(), + enrolled_at: z.union([z.string(), z.null()]).optional(), + completed_at: z.union([z.string(), z.null()]).optional(), + external_cta_url: z.string(), }) - .describe('Response for "GET_QUESTS" Command'); -export type GetQuestsResponse = zInfer; + .describe('Response for "GET_QUEST" Command'); +export type GetQuestResponse = zInfer; // REQUEST_PROXY_TICKET_REFRESH export const RequestProxyTicketRefreshResponseSchema = z @@ -369,7 +366,7 @@ export enum Command { GET_USER = 'GET_USER', GET_QUEST_ENROLLMENT_STATUS = 'GET_QUEST_ENROLLMENT_STATUS', QUEST_START_TIMER = 'QUEST_START_TIMER', - GET_QUESTS = 'GET_QUESTS', + GET_QUEST = 'GET_QUEST', REQUEST_PROXY_TICKET_REFRESH = 'REQUEST_PROXY_TICKET_REFRESH', } @@ -424,9 +421,9 @@ export const Schemas = { request: QuestStartTimerRequestSchema, response: QuestStartTimerResponseSchema, }, - [Command.GET_QUESTS]: { + [Command.GET_QUEST]: { request: emptyRequestSchema, - response: GetQuestsResponseSchema, + response: GetQuestResponseSchema, }, [Command.REQUEST_PROXY_TICKET_REFRESH]: { request: emptyRequestSchema, diff --git a/src/mock.ts b/src/mock.ts index 9b887727..224f3e95 100644 --- a/src/mock.ts +++ b/src/mock.ts @@ -202,16 +202,13 @@ export const commandsMockDefault: IDiscordSDK['commands'] = { questStartTimer: () => Promise.resolve({success: true}), getActivityInstanceConnectedParticipants: () => Promise.resolve({participants: []}), shareInteraction: () => Promise.resolve({success: false}), - getQuests: () => + requestProxyTicketRefresh: () => Promise.resolve({ticket: 'mock_ticket'}), + getQuest: () => Promise.resolve({ - quests: [ - { - quest_id: 'mock_quest_id', - external_cta_url: 'mock_external_cta_url', - enrolled_at: null, - }, - ], + quest_id: 'mock_quest_id', + external_cta_url: 'mock_external_cta_url', + enrolled_at: null, + completed_at: null, }), - requestProxyTicketRefresh: () => Promise.resolve({ticket: 'mock_ticket'}), // END-GENERATED-SECTION }; diff --git a/src/schema/common.ts b/src/schema/common.ts index ffa42b38..b238e561 100644 --- a/src/schema/common.ts +++ b/src/schema/common.ts @@ -35,7 +35,7 @@ export enum Commands { // START-GENERATED-SECTION AUTHENTICATE = 'AUTHENTICATE', GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS = 'GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS', - GET_QUESTS = 'GET_QUESTS', + GET_QUEST = 'GET_QUEST', GET_QUEST_ENROLLMENT_STATUS = 'GET_QUEST_ENROLLMENT_STATUS', GET_RELATIONSHIPS = 'GET_RELATIONSHIPS', GET_USER = 'GET_USER', diff --git a/src/schema/responses.ts b/src/schema/responses.ts index a46fd3de..53cbc80c 100644 --- a/src/schema/responses.ts +++ b/src/schema/responses.ts @@ -180,7 +180,7 @@ function parseResponseData({cmd, data}: zod.infer) { // START-GENERATED-SECTION case Commands.AUTHENTICATE: case Commands.GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS: - case Commands.GET_QUESTS: + case Commands.GET_QUEST: case Commands.GET_QUEST_ENROLLMENT_STATUS: case Commands.GET_RELATIONSHIPS: case Commands.GET_USER: