diff --git a/.lintstagedrc.mjs b/.lintstagedrc.mjs
index 909a105..f5686b7 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 178e208..095d60d 100644
--- a/assets/openapi.json
+++ b/assets/openapi.json
@@ -146,40 +146,6 @@
"version"
]
},
- "RouteResponse": {
- "type": "object",
- "properties": {
- "status": {
- "type": "integer"
- },
- "body": {
- "type": "string",
- "pattern": "^.*Response$"
- },
- "headers": {
- "$ref": "#/components/schemas/Record%3Cstring%2Cstring%3E"
- }
- }
- },
- "FieldErrorResponse": {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer"
- },
- "message": {
- "type": "string"
- },
- "errors": {
- "$ref": "#/components/schemas/ErrorList"
- }
- },
- "required": [
- "code",
- "errors",
- "message"
- ]
- },
"InteractionSchema": {
"type": "object",
"properties": {
@@ -239,6 +205,7 @@
"type"
]
},
+<<<<<<< HEAD
"AckBulkSchema": {
"type": "object",
"properties": {
@@ -268,6 +235,40 @@
},
"required": [
"read_states"
+=======
+ "RouteResponse": {
+ "type": "object",
+ "properties": {
+ "status": {
+ "type": "integer"
+ },
+ "body": {
+ "type": "string",
+ "pattern": "^.*Response$"
+ },
+ "headers": {
+ "$ref": "#/components/schemas/Record%3Cstring%2Cstring%3E"
+ }
+ }
+ },
+ "FieldErrorResponse": {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer"
+ },
+ "message": {
+ "type": "string"
+ },
+ "errors": {
+ "$ref": "#/components/schemas/ErrorList"
+ }
+ },
+ "required": [
+ "code",
+ "errors",
+ "message"
+>>>>>>> 288a50d8d (Clean up imports in schemas/api/bots)
]
},
"ActivitySchema": {
@@ -3028,7 +3029,8 @@
"type": "object",
"properties": {
"id": {
- "$ref": "#/components/schemas/Snowflake"
+ "description": "A Twitter-like snowflake, except the epoch is 2015-01-01T00:00:00.000Z\n```\nIf we have a snowflake '266241948824764416' we can represent it as binary:\n\n64 22 17 12 0\n 000000111011000111100001101001000101000000 00001 00000 000000000000\n number of ms since Discord epoch worker pid increment\n```",
+ "type": "string"
},
"type": {
"enum": [
@@ -3043,7 +3045,8 @@
"type": "string"
},
"version": {
- "$ref": "#/components/schemas/Snowflake"
+ "description": "A Twitter-like snowflake, except the epoch is 2015-01-01T00:00:00.000Z\n```\nIf we have a snowflake '266241948824764416' we can represent it as binary:\n\n64 22 17 12 0\n 000000111011000111100001101001000101000000 00001 00000 000000000000\n number of ms since Discord epoch worker pid increment\n```",
+ "type": "string"
},
"application_command": {
"type": "object",
@@ -3057,8 +3060,8 @@
}
},
"target_id": {
- "description": "A container for useful snowflake-related methods.",
- "$ref": "#/components/schemas/Snowflake"
+ "description": "A Twitter-like snowflake, except the epoch is 2015-01-01T00:00:00.000Z\n```\nIf we have a snowflake '266241948824764416' we can represent it as binary:\n\n64 22 17 12 0\n 000000111011000111100001101001000101000000 00001 00000 000000000000\n number of ms since Discord epoch worker pid increment\n```",
+ "type": "string"
},
"attachments": {
"type": "array",
@@ -3118,20 +3121,10 @@
"type": "string"
},
"values": {
- "anyOf": [
- {
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Snowflake"
- }
- }
- ]
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
}
},
"required": [
@@ -3142,7 +3135,8 @@
"type": "object",
"properties": {
"id": {
- "$ref": "#/components/schemas/Snowflake"
+ "description": "A Twitter-like snowflake, except the epoch is 2015-01-01T00:00:00.000Z\n```\nIf we have a snowflake '266241948824764416' we can represent it as binary:\n\n64 22 17 12 0\n 000000111011000111100001101001000101000000 00001 00000 000000000000\n number of ms since Discord epoch worker pid increment\n```",
+ "type": "string"
},
"custom_id": {
"type": "string"
@@ -7517,9 +7511,6 @@
2
]
},
- "ErrorList": {
- "type": "object"
- },
"InteractionType": {
"type": "number",
"enum": [
@@ -7597,6 +7588,9 @@
"filename"
]
},
+ "ErrorList": {
+ "type": "object"
+ },
"Status": {
"enum": [
"dnd",
diff --git a/assets/schemas.json b/assets/schemas.json
index 65b6edb..7de8774 100644
--- a/assets/schemas.json
+++ b/assets/schemas.json
@@ -125,44 +125,6 @@
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
- "RouteResponse": {
- "type": "object",
- "properties": {
- "status": {
- "type": "integer"
- },
- "body": {
- "type": "string",
- "pattern": "^.*Response$"
- },
- "headers": {
- "$ref": "#/definitions/Record%3Cstring%2Cstring%3E"
- }
- },
- "additionalProperties": false,
- "$schema": "http://json-schema.org/draft-07/schema#"
- },
- "FieldErrorResponse": {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer"
- },
- "message": {
- "type": "string"
- },
- "errors": {
- "$ref": "#/definitions/ErrorList"
- }
- },
- "additionalProperties": false,
- "required": [
- "code",
- "errors",
- "message"
- ],
- "$schema": "http://json-schema.org/draft-07/schema#"
- },
"InteractionSchema": {
"type": "object",
"properties": {
@@ -224,6 +186,7 @@
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
+<<<<<<< HEAD
"AckBulkSchema": {
"type": "object",
"properties": {
@@ -249,11 +212,47 @@
"read_state_type"
]
}
+=======
+ "RouteResponse": {
+ "type": "object",
+ "properties": {
+ "status": {
+ "type": "integer"
+ },
+ "body": {
+ "type": "string",
+ "pattern": "^.*Response$"
+ },
+ "headers": {
+ "$ref": "#/definitions/Record%3Cstring%2Cstring%3E"
+ }
+ },
+ "additionalProperties": false,
+ "$schema": "http://json-schema.org/draft-07/schema#"
+ },
+ "FieldErrorResponse": {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer"
+ },
+ "message": {
+ "type": "string"
+ },
+ "errors": {
+ "$ref": "#/definitions/ErrorList"
+>>>>>>> 288a50d8d (Clean up imports in schemas/api/bots)
}
},
"additionalProperties": false,
"required": [
+<<<<<<< HEAD
"read_states"
+=======
+ "code",
+ "errors",
+ "message"
+>>>>>>> 288a50d8d (Clean up imports in schemas/api/bots)
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
@@ -3222,7 +3221,8 @@
"type": "object",
"properties": {
"id": {
- "$ref": "#/definitions/Snowflake"
+ "description": "A Twitter-like snowflake, except the epoch is 2015-01-01T00:00:00.000Z\n```\nIf we have a snowflake '266241948824764416' we can represent it as binary:\n\n64 22 17 12 0\n 000000111011000111100001101001000101000000 00001 00000 000000000000\n number of ms since Discord epoch worker pid increment\n```",
+ "type": "string"
},
"type": {
"enum": [
@@ -3237,7 +3237,8 @@
"type": "string"
},
"version": {
- "$ref": "#/definitions/Snowflake"
+ "description": "A Twitter-like snowflake, except the epoch is 2015-01-01T00:00:00.000Z\n```\nIf we have a snowflake '266241948824764416' we can represent it as binary:\n\n64 22 17 12 0\n 000000111011000111100001101001000101000000 00001 00000 000000000000\n number of ms since Discord epoch worker pid increment\n```",
+ "type": "string"
},
"application_command": {
"type": "object",
@@ -3251,8 +3252,8 @@
}
},
"target_id": {
- "description": "A container for useful snowflake-related methods.",
- "$ref": "#/definitions/Snowflake"
+ "description": "A Twitter-like snowflake, except the epoch is 2015-01-01T00:00:00.000Z\n```\nIf we have a snowflake '266241948824764416' we can represent it as binary:\n\n64 22 17 12 0\n 000000111011000111100001101001000101000000 00001 00000 000000000000\n number of ms since Discord epoch worker pid increment\n```",
+ "type": "string"
},
"attachments": {
"type": "array",
@@ -3314,20 +3315,10 @@
"type": "string"
},
"values": {
- "anyOf": [
- {
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- {
- "type": "array",
- "items": {
- "$ref": "#/definitions/Snowflake"
- }
- }
- ]
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
}
},
"additionalProperties": false,
@@ -3340,7 +3331,8 @@
"type": "object",
"properties": {
"id": {
- "$ref": "#/definitions/Snowflake"
+ "description": "A Twitter-like snowflake, except the epoch is 2015-01-01T00:00:00.000Z\n```\nIf we have a snowflake '266241948824764416' we can represent it as binary:\n\n64 22 17 12 0\n 000000111011000111100001101001000101000000 00001 00000 000000000000\n number of ms since Discord epoch worker pid increment\n```",
+ "type": "string"
},
"custom_id": {
"type": "string"
@@ -8001,11 +7993,6 @@
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
- "ErrorList": {
- "type": "object",
- "additionalProperties": false,
- "$schema": "http://json-schema.org/draft-07/schema#"
- },
"InteractionType": {
"type": "number",
"enum": [
@@ -8088,6 +8075,11 @@
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
+ "ErrorList": {
+ "type": "object",
+ "additionalProperties": false,
+ "$schema": "http://json-schema.org/draft-07/schema#"
+ },
"Status": {
"enum": [
"dnd",
diff --git a/src/api/routes/interactions/index.ts b/src/api/routes/interactions/index.ts
index 599a364..fd42050 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 dd09fb9..ab0d7ca 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 44e7e65..5a6d1c3 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 9e79df5..47c0f11 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 @@
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 e559abe..31a1abd 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 0ad37cc..7237af4 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 f898c0c..7c30563 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 fba2677..4c1a780 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 b9fb8c3..efa0f5f 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 5afbfe2..ad1efc6 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 c35b3f6..153e086 100644
--- a/src/util/entities/Message.ts
+++ b/src/util/entities/Message.ts
@@ -20,7 +20,6 @@
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 @@
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 304241c..7c3bbd3 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 63e206f..96d04a5 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 {
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 8c9c752..0000000
--- 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 6620ba3..63a3dc6 100644
--- a/src/util/interfaces/index.ts
+++ b/src/util/interfaces/index.ts
@@ -20,6 +20,5 @@
export * from "./ConnectedAccount";
export * from "./Event";
export * from "./GuildWelcomeScreen";
-export * from "./Interaction";
export * from "./Presence";
export * from "./Status";