Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/commands/getQuests.ts → src/commands/getQuest.ts
Original file line number Diff line number Diff line change
@@ -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);
4 changes: 2 additions & 2 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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),
Expand Down
23 changes: 7 additions & 16 deletions src/generated/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
},
Expand Down
25 changes: 11 additions & 14 deletions src/generated/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,19 +334,16 @@ export const QuestStartTimerResponseSchema = z
.describe('Response for "QUEST_START_TIMER" Command');
export type QuestStartTimerResponse = zInfer<typeof QuestStartTimerResponseSchema>;

// 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<typeof GetQuestsResponseSchema>;
.describe('Response for "GET_QUEST" Command');
export type GetQuestResponse = zInfer<typeof GetQuestResponseSchema>;

// REQUEST_PROXY_TICKET_REFRESH
export const RequestProxyTicketRefreshResponseSchema = z
Expand All @@ -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',
}

Expand Down Expand Up @@ -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,
Expand Down
15 changes: 6 additions & 9 deletions src/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
2 changes: 1 addition & 1 deletion src/schema/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/schema/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function parseResponseData({cmd, data}: zod.infer<typeof ResponseFrame>) {
// 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:
Expand Down