From ae064aea1b9ba9b39bf4c2e320691efd90d7ba0d Mon Sep 17 00:00:00 2001 From: Rory& Date: Sun, 19 Apr 2026 23:38:19 +0200 Subject: [PATCH] Clean up imports in schemas/api/bots --- .lintstagedrc.mjs | 2 +- assets/openapi.json | Bin 968774 -> 969886 bytes assets/schemas.json | Bin 436219 -> 437368 bytes src/api/routes/interactions/index.ts | 4 +- .../api/bots/InteractionCallbackSchema.ts | 3 +- .../api/bots/InteractionCreateSchema.ts | 5 +- src/schemas/api/bots/InteractionSchema.ts | 38 +++++++++++- .../SendableApplicationCommandDataSchema.ts | 2 +- .../SendableMessageComponentDataSchema.ts | 2 +- .../api/bots/SendableModalSubmitDataSchema.ts | 2 +- src/schemas/api/bots/index.ts | 1 + src/schemas/api/channels/Channel.ts | 22 ++++++- .../uncategorised/MessageCreateSchema.ts | 4 +- src/util/entities/Message.ts | 2 +- src/util/imports/Interactions.ts | 4 +- src/util/interfaces/Event.ts | 3 +- src/util/interfaces/Interaction.ts | 54 ------------------ src/util/interfaces/index.ts | 1 - 18 files changed, 73 insertions(+), 76 deletions(-) delete mode 100644 src/util/interfaces/Interaction.ts diff --git a/.lintstagedrc.mjs b/.lintstagedrc.mjs index 909a1050c..f5686b79e 100644 --- a/.lintstagedrc.mjs +++ b/.lintstagedrc.mjs @@ -1,4 +1,4 @@ export default { - "*.{j,t}s": ["eslint --concurrency 4" /* sweet spot it seems */, "prettier --write"], + "*.{j,t}s": [() => "npm run build:src:tsgo", "eslint --concurrency 4" /* sweet spot it seems */, "prettier --write"], "src/schemas/{*,**/*}.ts": [() => "tsc -b -v", () => "node scripts/schema.js", () => "node scripts/openapi.js", () => "git add assets/schemas.json assets/openapi.json"], }; diff --git a/assets/openapi.json b/assets/openapi.json index 178e208afdb45d913060e9bd74ea2c280a003e8d..095d60d3386423cfccdc0bb22af08a60d1d18dee 100644 GIT binary patch delta 373 zcmX>$!Ft|I>kVpB)Bklba&In^+sn&i0|5#iu8uC7jdW^R*li(Ty1^!PkW z@F$yo^Ie1OcMTZNR&8#OzsI=UAedQFHpZ?$~Gtc(#YZ+fN zZVuo+%Q*c)C>z&w0~MD1X^o7U(?7_tvP~CIVbq!Kf1A~GxmVR}Fc zyU6qnu8eBaf9i1xPOoWZ7M;97RK9)MUPd5h+CFVBvuw)te~K(iIHzw`Wbtlaq|E}v gtU$~L#Oy%K0mPg@%mu{UK+FTgyxSLP^DUVJ0MrzSJ^%m! delta 266 zcmbO?)B4y1>kVpBn|pM`S*E{NXVja%pp>0^daDd`()0;mSd}Jk5Y^axS4xm~x`HDU z-)2sYJeKLp?KtJ9)iVk-a~p2wHe@_gHC>^dO>X)JC1&&K4f9zPr#~oSbKU--o{^Vv zy1^nwj_H2=jIwYwX44BeIJmc)Z)AMKIK5qodH(hfTNu6Aw@(mcc4VBMAkSDj{k;;i z{PY4FMxN;oQd}0(KZG;JPxn8_$T?kVFXIV>LG1_jGXgQw_5=Hwz0;?=K*jOfCT`fhv6^-_x&Fj>+uTy87?zQ=Y^fAWC4Ovo?^N-3-&%4GneR@DK zV=`EH`-fu235?qfq8PU^PFLt=PMG{bp?z8$Q`q!=W+tKS0p*PSEYl4-8S|$X%wq|k zzM+qmbNY{3#&clJ)7SU0a!o%_$LcuU;WN6lrSd4CDo?K_c1S>-q6HaJUyV9Sz_{gZiC4ematDxs9@Bb zetR8L;q(U~Oaj~Os~GRGP8aB8b(}t79jnLm3+2q3(;E&k`GdG|(;ut>+U0PPk!N~? zJG0pI2TNFErytN^l%Bqzjg@oyn+C>n2piiQni+wZX?sI6^E%GyDN~tefW5ZevX@z# Vqy5iRW*}w(V%F_{rn1$D0RSkvaY+CG diff --git a/src/api/routes/interactions/index.ts b/src/api/routes/interactions/index.ts index 599a364e5..fd42050c7 100644 --- a/src/api/routes/interactions/index.ts +++ b/src/api/routes/interactions/index.ts @@ -17,10 +17,10 @@ */ import { randomBytes } from "node:crypto"; -import { InteractionFailureReason, InteractionSchema } from "@spacebar/schemas"; +import { InteractionFailureReason, InteractionSchema, InteractionType } from "@spacebar/schemas"; import { route } from "@spacebar/api"; import { Request, Response, Router } from "express"; -import { Config, emitEvent, getPermission, Guild, InteractionCreateEvent, InteractionFailureEvent, InteractionType, Member, Message, Snowflake } from "@spacebar/util"; +import { Config, emitEvent, getPermission, Guild, InteractionCreateEvent, InteractionFailureEvent, Member, Message, Snowflake } from "@spacebar/util"; import { pendingInteractions } from "@spacebar/util/imports/Interactions"; import { InteractionCreateSchema } from "@spacebar/schemas/api/bots/InteractionCreateSchema"; diff --git a/src/schemas/api/bots/InteractionCallbackSchema.ts b/src/schemas/api/bots/InteractionCallbackSchema.ts index dd09fb90a..ab0d7ca41 100644 --- a/src/schemas/api/bots/InteractionCallbackSchema.ts +++ b/src/schemas/api/bots/InteractionCallbackSchema.ts @@ -16,9 +16,8 @@ along with this program. If not, see . */ -import { Message } from "@spacebar/util"; import { InteractionCallbackType } from "./InteractionCallbackType"; -import { AllowedMentions, BaseMessageComponents, Embed, MessageComponentType } from "../messages"; +import { AllowedMentions, BaseMessageComponents, Embed } from "../messages"; import { MessageCreateAttachment, MessageCreateCloudAttachment, PollCreationSchema } from "#schemas/uncategorised"; export interface InteractionCallbackSchema { diff --git a/src/schemas/api/bots/InteractionCreateSchema.ts b/src/schemas/api/bots/InteractionCreateSchema.ts index 44e7e651d..5a6d1c3f4 100644 --- a/src/schemas/api/bots/InteractionCreateSchema.ts +++ b/src/schemas/api/bots/InteractionCreateSchema.ts @@ -16,8 +16,9 @@ along with this program. If not, see . */ -import { PublicMember, PublicUser, Snowflake } from "@spacebar/schemas"; -import { Channel, InteractionType, Message } from "@spacebar/util"; +import { PublicMember, PublicUser, Snowflake, InteractionType } from "@spacebar/schemas"; +// TODO: remove entity imports +import { Channel, Message } from "@spacebar/util"; export interface InteractionCreateSchema { version: number; // TODO: types? diff --git a/src/schemas/api/bots/InteractionSchema.ts b/src/schemas/api/bots/InteractionSchema.ts index 9e79df526..47c0f1140 100644 --- a/src/schemas/api/bots/InteractionSchema.ts +++ b/src/schemas/api/bots/InteractionSchema.ts @@ -16,8 +16,7 @@ along with this program. If not, see . */ -import { ApplicationCommandOption, Snowflake, UploadAttachmentRequestSchema } from "@spacebar/schemas"; -import { InteractionType } from "@spacebar/util"; +import { AllowedMentions, ApplicationCommandOption, Embed, Snowflake, UploadAttachmentRequestSchema } from "@spacebar/schemas"; export interface InteractionSchema { type: InteractionType; @@ -44,3 +43,38 @@ interface InteractionData { type: number; version: string; } + +export interface Interaction { + id: string; + type: InteractionType; + data?: object; // TODO typing + guild_id: string; + channel_id: string; + member_id: string; + token: string; + version: number; +} + +export enum InteractionType { + Ping = 1, + ApplicationCommand = 2, + MessageComponent = 3, + ApplicationCommandAutocomplete = 4, + ModalSubmit = 5, +} + +export enum InteractionResponseType { + SelfCommandResponse = 0, + Pong = 1, + Acknowledge = 2, + ChannelMessage = 3, + ChannelMessageWithSource = 4, + AcknowledgeWithSource = 5, +} + +export interface InteractionApplicationCommandCallbackData { + tts?: boolean; + content: string; + embeds?: Embed[]; + allowed_mentions?: AllowedMentions; +} diff --git a/src/schemas/api/bots/SendableApplicationCommandDataSchema.ts b/src/schemas/api/bots/SendableApplicationCommandDataSchema.ts index e559abe02..31a1abdd8 100644 --- a/src/schemas/api/bots/SendableApplicationCommandDataSchema.ts +++ b/src/schemas/api/bots/SendableApplicationCommandDataSchema.ts @@ -16,7 +16,7 @@ along with this program. If not, see . */ -import { Snowflake } from "@spacebar/util"; +import { Snowflake } from "../../Identifiers"; import { ApplicationCommandOption } from "../developers"; import { ApplicationCommandType } from "./ApplicationCommandSchema"; diff --git a/src/schemas/api/bots/SendableMessageComponentDataSchema.ts b/src/schemas/api/bots/SendableMessageComponentDataSchema.ts index 0ad37cc6e..7237af42b 100644 --- a/src/schemas/api/bots/SendableMessageComponentDataSchema.ts +++ b/src/schemas/api/bots/SendableMessageComponentDataSchema.ts @@ -16,7 +16,7 @@ along with this program. If not, see . */ -import { Snowflake } from "@spacebar/util"; +import { Snowflake } from "../../Identifiers"; import { MessageComponentType } from "../messages"; import { ApplicationCommandType } from "./ApplicationCommandSchema"; diff --git a/src/schemas/api/bots/SendableModalSubmitDataSchema.ts b/src/schemas/api/bots/SendableModalSubmitDataSchema.ts index f898c0cae..7c3056323 100644 --- a/src/schemas/api/bots/SendableModalSubmitDataSchema.ts +++ b/src/schemas/api/bots/SendableModalSubmitDataSchema.ts @@ -17,7 +17,7 @@ */ import { UploadAttachmentRequestSchema } from "@spacebar/schemas"; -import { Snowflake } from "@spacebar/util"; +import { Snowflake } from "../../Identifiers"; export interface SendableModalSubmitDataSchema { id: Snowflake; diff --git a/src/schemas/api/bots/index.ts b/src/schemas/api/bots/index.ts index fba2677a9..4c1a78043 100644 --- a/src/schemas/api/bots/index.ts +++ b/src/schemas/api/bots/index.ts @@ -15,6 +15,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ + export * from "./ApplicationCommandCreateSchema"; export * from "./ApplicationCommandSchema"; export * from "./InteractionSchema"; diff --git a/src/schemas/api/channels/Channel.ts b/src/schemas/api/channels/Channel.ts index b9fb8c37b..efa0f5f53 100644 --- a/src/schemas/api/channels/Channel.ts +++ b/src/schemas/api/channels/Channel.ts @@ -1,6 +1,24 @@ -import { Channel, Guild, Invite, Message, ReadState, Recipient, Tag, ThreadMember, User, VoiceState, Webhook } from "@spacebar/util"; +/* + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2026 Spacebar and Spacebar Contributors + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +// TODO: remove entity imports +import { Channel, Recipient, Tag, ThreadMember } from "@spacebar/util"; import { HTTPError } from "lambert-server"; -import { Column, JoinColumn, ManyToOne, OneToMany, RelationId } from "typeorm"; import { Snowflake } from "../../Identifiers"; import { PartialUser, PublicMember } from "../users"; diff --git a/src/schemas/uncategorised/MessageCreateSchema.ts b/src/schemas/uncategorised/MessageCreateSchema.ts index 5afbfe2ad..ad1efc683 100644 --- a/src/schemas/uncategorised/MessageCreateSchema.ts +++ b/src/schemas/uncategorised/MessageCreateSchema.ts @@ -16,8 +16,8 @@ along with this program. If not, see . */ -import { InteractionType, Snowflake } from "@spacebar/util"; -import { AllowedMentions, MessageReference, ApplicationCommandType, BaseMessageComponents, Embed, PollAnswer, PollMedia, PublicUser } from "@spacebar/schemas"; +import { Snowflake } from "@spacebar/util"; +import { InteractionType, AllowedMentions, MessageReference, ApplicationCommandType, BaseMessageComponents, Embed, PollAnswer, PollMedia, PublicUser } from "@spacebar/schemas"; export type MessageCreateAttachment = { id: string; diff --git a/src/util/entities/Message.ts b/src/util/entities/Message.ts index c35b3f60c..153e086d4 100644 --- a/src/util/entities/Message.ts +++ b/src/util/entities/Message.ts @@ -20,7 +20,6 @@ import { User } from "./User"; import { Member } from "./Member"; import { Role } from "./Role"; import { Channel } from "./Channel"; -import { InteractionType } from "../interfaces"; import { Application } from "./Application"; import { Column, CreateDateColumn, Entity, Index, JoinColumn, JoinTable, ManyToMany, ManyToOne, OneToMany, RelationId, FindOneOptions, Raw, Not, BaseEntity, In } from "typeorm"; import { BaseClass } from "./BaseClass"; @@ -42,6 +41,7 @@ import { Reaction, UnfurledMediaItem, PartialUser, + InteractionType, } from "@spacebar/schemas"; import { MessageFlags } from "@spacebar/util"; import { JsonRemoveEmpty } from "../util/Decorators"; diff --git a/src/util/imports/Interactions.ts b/src/util/imports/Interactions.ts index 304241cdd..7c3bbd3db 100644 --- a/src/util/imports/Interactions.ts +++ b/src/util/imports/Interactions.ts @@ -16,8 +16,8 @@ along with this program. If not, see . */ -import { ApplicationCommandType } from "@spacebar/schemas"; -import { InteractionType, Snowflake } from "@spacebar/util"; +import { ApplicationCommandType, InteractionType } from "@spacebar/schemas"; +import { Snowflake } from "@spacebar/util"; interface PendingInteraction { timeout: NodeJS.Timeout; diff --git a/src/util/interfaces/Event.ts b/src/util/interfaces/Event.ts index 63e206f37..96d04a556 100644 --- a/src/util/interfaces/Event.ts +++ b/src/util/interfaces/Event.ts @@ -18,8 +18,6 @@ import { ConnectedAccount, - Interaction, - Message, Invite, Role, Emoji, @@ -42,6 +40,7 @@ import { JsonValue } from "@protobuf-ts/runtime"; import { ApplicationCommand, GuildCreateResponse, + Interaction, InteractionFailureReason, PartialEmoji, PublicChannel, diff --git a/src/util/interfaces/Interaction.ts b/src/util/interfaces/Interaction.ts deleted file mode 100644 index 8c9c752db..000000000 --- a/src/util/interfaces/Interaction.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* - Spacebar: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Spacebar and Spacebar Contributors - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -import { Embed, AllowedMentions } from "@spacebar/schemas"; - -export interface Interaction { - id: string; - type: InteractionType; - data?: object; // TODO typing - guild_id: string; - channel_id: string; - member_id: string; - token: string; - version: number; -} - -export enum InteractionType { - Ping = 1, - ApplicationCommand = 2, - MessageComponent = 3, - ApplicationCommandAutocomplete = 4, - ModalSubmit = 5, -} - -export enum InteractionResponseType { - SelfCommandResponse = 0, - Pong = 1, - Acknowledge = 2, - ChannelMessage = 3, - ChannelMessageWithSource = 4, - AcknowledgeWithSource = 5, -} - -export interface InteractionApplicationCommandCallbackData { - tts?: boolean; - content: string; - embeds?: Embed[]; - allowed_mentions?: AllowedMentions; -} diff --git a/src/util/interfaces/index.ts b/src/util/interfaces/index.ts index 6620ba32d..63a3dc6ca 100644 --- a/src/util/interfaces/index.ts +++ b/src/util/interfaces/index.ts @@ -20,6 +20,5 @@ export * from "./Activity"; export * from "./ConnectedAccount"; export * from "./Event"; export * from "./GuildWelcomeScreen"; -export * from "./Interaction"; export * from "./Presence"; export * from "./Status";