Skip to content

Commit 87988c3

Browse files
Clean up various other schemas
1 parent 8f46315 commit 87988c3

11 files changed

Lines changed: 6594 additions & 5787 deletions

File tree

assets/openapi.json

Lines changed: 3198 additions & 2768 deletions
Large diffs are not rendered by default.

assets/schemas.json

Lines changed: 3357 additions & 2976 deletions
Large diffs are not rendered by default.

src/api/routes/channels/preload-messages.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { Request, Response, Router } from "express";
2020
import { route } from "@spacebar/api/util/handlers/route";
2121
import { Message } from "@spacebar/database";
2222
import { Config } from "@spacebar/util";
23-
import { PreloadMessagesRequestSchema, PreloadMessagesResponseSchema } from "@spacebar/schemas";
23+
import { PreloadMessagesRequestSchema, PublicMessageArray } from "@spacebar/schemas";
2424

2525
const router = Router({ mergeParams: true });
2626

@@ -30,7 +30,7 @@ router.post(
3030
requestBody: "PreloadMessagesRequestSchema",
3131
responses: {
3232
200: {
33-
body: "PreloadMessagesResponse",
33+
body: "PublicMessageArray",
3434
},
3535
400: {
3636
body: "APIErrorResponse",
@@ -62,7 +62,7 @@ router.post(
6262
// https://docs.discord.food/resources/message#preload-messages - reactions are not included in the response
6363
x.reactions = undefined;
6464
return x;
65-
}) as unknown as PreloadMessagesResponseSchema;
65+
}) as unknown as PublicMessageArray;
6666

6767
return res.status(200).send(filteredMessages);
6868
},

src/api/routes/interactions/index.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,24 +92,26 @@ router.post("/", route({}), async (req: Request, res: Response) => {
9292
}
9393

9494
if (body.type === InteractionType.MessageComponent || body.data.type === InteractionType.ModalSubmit) {
95-
interactionData.message = await Message.findOneOrFail({
96-
where: { id: body.message_id, flags: undefined },
97-
relations: {
98-
author: true,
99-
webhook: true,
100-
application: true,
101-
mentions: true,
102-
mention_roles: true,
103-
mention_channels: true,
104-
sticker_items: true,
105-
attachments: true,
106-
thread: {
107-
recipients: {
108-
user: true,
95+
interactionData.message = (
96+
await Message.findOneOrFail({
97+
where: { id: body.message_id, flags: undefined },
98+
relations: {
99+
author: true,
100+
webhook: true,
101+
application: true,
102+
mentions: true,
103+
mention_roles: true,
104+
mention_channels: true,
105+
sticker_items: true,
106+
attachments: true,
107+
thread: {
108+
recipients: {
109+
user: true,
110+
},
109111
},
110112
},
111-
},
112-
});
113+
})
114+
).toJSON();
113115
}
114116

115117
await emitEvent({

src/schemas/api/bots/InteractionCreateSchema.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19-
import { PublicMember, PublicUser, Snowflake, InteractionType } from "@spacebar/schemas";
20-
// TODO: remove entity imports
21-
import { Channel, Message } from "@spacebar/database";
19+
import { PublicMember, PublicUser, Snowflake, InteractionType, PublicMessage, PublicChannel } from "@spacebar/schemas";
2220

2321
export interface InteractionCreateSchema {
2422
version: number; // TODO: types?
@@ -30,12 +28,12 @@ export interface InteractionCreateSchema {
3028
guild?: InteractionGuild;
3129
guild_id?: Snowflake;
3230
guild_locale?: string;
33-
channel?: Channel;
31+
channel?: PublicChannel;
3432
channel_id?: Snowflake;
3533
member?: PublicMember;
3634
user?: PublicUser;
3735
locale?: string;
38-
message?: Message;
36+
message?: PublicMessage;
3937
app_permissions: string;
4038
entitlements?: object[]; // TODO: types?
4139
entitlement_sku_ids?: Snowflake[]; // DEPRECATED

src/schemas/api/channels/Webhook.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19-
// TODO: remove dependency on entities
20-
import { User, Webhook } from "@spacebar/database";
21-
import { IntegrationGuild, PartialUser, Snowflake } from "@spacebar/schemas";
19+
import { IntegrationGuild, PartialUser, PublicUser, Snowflake } from "@spacebar/schemas";
2220

2321
export enum WebhookType {
2422
Incoming = 1,
@@ -27,8 +25,8 @@ export enum WebhookType {
2725
}
2826

2927
export interface WebhookCreateResponse {
30-
user: User;
31-
hook: Webhook;
28+
user: PublicUser;
29+
hook: WebhookResponse;
3230
}
3331

3432
export type WebhookArray = WebhookResponse[];

src/schemas/api/messages/Message.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ export interface MessageSnapshot {
163163
};
164164
}
165165

166+
export type PublicMessageArray = PublicMessage[];
166167
export interface PublicMessage {
167168
id: Snowflake;
168169
channel_id: Snowflake;

src/schemas/responses/EmojiSourceResponse.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19-
// TODO: remove entity import
20-
import { Emoji } from "@spacebar/database";
19+
import { EmojiResponse } from "@spacebar/schemas/api/guilds/Emoji";
2120

2221
export interface EmojiSourceResponse {
2322
type: "GUILD" | "APPLICATION";
@@ -32,7 +31,7 @@ export interface EmojiGuild {
3231
icon?: string | null;
3332
description?: string | null;
3433
features: string[];
35-
emojis: Emoji[];
34+
emojis: EmojiResponse[];
3635
premium_tier: number;
3736
premium_subscription_count?: number;
3837
approximate_member_count?: number;

src/schemas/responses/GuildMessagesSearchResponse.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
// TODO: remove dependency on entities
2020
import { Role } from "@spacebar/database";
21-
import { BaseMessageComponents, Embed, MessageType, Poll, PublicUser } from "@spacebar/schemas";
21+
import { BaseMessageComponents, Embed, MessageType, Poll, PublicUser, RoleResponse } from "@spacebar/schemas";
2222
import { PublicAttachment } from "../api/messages/Attachments";
2323

2424
export interface GuildMessagesSearchMessage {
@@ -30,7 +30,7 @@ export interface GuildMessagesSearchMessage {
3030
attachments: PublicAttachment[];
3131
embeds: Embed[];
3232
mentions: PublicUser[];
33-
mention_roles: Role[];
33+
mention_roles: RoleResponse[];
3434
pinned: boolean;
3535
mention_everyone?: boolean;
3636
tts: boolean;

src/schemas/responses/MemberJoinGuildResponse.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616
along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19-
// TODO: remove entity imports
20-
import { Emoji, Role, Sticker } from "@spacebar/database";
21-
import { GuildCreateResponse } from "@spacebar/schemas";
19+
import { GuildCreateResponse, RoleResponse, StickerResponse } from "@spacebar/schemas";
20+
import { EmojiResponse } from "@spacebar/schemas/api/guilds/Emoji";
2221

2322
export interface MemberJoinGuildResponse {
2423
guild: GuildCreateResponse;
25-
emojis: Emoji[];
26-
roles: Role[];
27-
stickers: Sticker[];
24+
emojis: EmojiResponse[];
25+
roles: RoleResponse[];
26+
stickers: StickerResponse[];
2827
}

0 commit comments

Comments
 (0)