Some schema fixes

This commit is contained in:
Rory&
2026-09-12 23:48:59 +02:00
parent ee35c377ad
commit 104e2aa016
20 changed files with 180 additions and 20 deletions
Binary file not shown.
Binary file not shown.
-1
View File
@@ -31,7 +31,6 @@
"UpdateRouteResponse",
"MessagesSendAPIResponse",
"APIWebhook",
"WebhookResponse",
"WebhookValidationResponse",
"MessageResponse",
"ConnectionSettingsResponse",
@@ -78,7 +78,7 @@ router.get(
},
responses: {
200: {
body: "PublicMessageArray",
body: "PublicMessageListResponse",
},
400: {
body: "APIErrorResponse",
@@ -165,7 +165,7 @@ router.get(
permission: ["READ_MESSAGE_HISTORY"],
responses: {
200: {
body: "PublicMessageArray",
body: "PublicMessageListResponse",
},
400: {
body: "APIErrorResponse",
+1 -1
View File
@@ -166,7 +166,7 @@ router.get(
permission: ["READ_MESSAGE_HISTORY"],
responses: {
200: {
body: "PublicMessageArray",
body: "PublicMessageListResponse",
},
400: {
body: "APIErrorResponse",
@@ -34,7 +34,7 @@ router.get(
permission: "MANAGE_WEBHOOKS",
responses: {
200: {
body: "WebhookArray",
body: "WebhookListResponse",
},
},
}),
+3 -3
View File
@@ -20,7 +20,7 @@ import { Request, Response, Router } from "express";
import { route } from "@spacebar/api/middlewares";
import { Message } from "@spacebar/database";
import { Config } from "@spacebar/util";
import { PreloadMessagesRequestSchema, PublicMessageArray } from "@spacebar/schemas";
import { PreloadMessagesRequestSchema, PublicMessageListResponse } from "@spacebar/schemas";
const router = Router({ mergeParams: true });
@@ -30,7 +30,7 @@ router.post(
requestBody: "PreloadMessagesRequestSchema",
responses: {
200: {
body: "PublicMessageArray",
body: "PublicMessageListResponse",
},
400: {
body: "APIErrorResponse",
@@ -62,7 +62,7 @@ router.post(
// https://docs.discord.food/resources/message#preload-messages - reactions are not included in the response
x.reactions = undefined;
return x;
}) as unknown as PublicMessageArray;
}) as unknown as PublicMessageListResponse;
return res.status(200).send(filteredMessages);
},
@@ -42,7 +42,7 @@ router.get(
},
responses: {
200: {
body: "PublicMemberArray",
body: "PublicMemberListResponse",
},
403: {
body: "APIErrorResponse",
+1 -1
View File
@@ -31,7 +31,7 @@ router.get(
permission: "MANAGE_WEBHOOKS",
responses: {
200: {
body: "WebhookArray",
body: "WebhookListResponse",
},
},
}),
+1 -1
View File
@@ -27,7 +27,7 @@ router.get(
route({
responses: {
200: {
body: "APIPublicUser",
body: "PublicUser",
},
},
}),
+1 -1
View File
@@ -30,7 +30,7 @@ router.get(
route({
responses: {
200: {
body: "APIPrivateUser",
body: "PrivateUser",
},
},
}),
+1 -1
View File
@@ -29,7 +29,7 @@ export interface WebhookCreateResponse {
hook: WebhookResponse;
}
export type WebhookArray = WebhookResponse[];
export type WebhookListResponse = WebhookResponse[];
export interface WebhookResponse {
id: Snowflake;
type: WebhookType;
+18
View File
@@ -1,3 +1,21 @@
/*
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 <https://www.gnu.org/licenses/>.
*/
import { Snowflake } from "../../Identifiers";
import { PartialUser } from "../users";
@@ -0,0 +1,24 @@
/*
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 <https://www.gnu.org/licenses/>.
*/
import { Snowflake } from "../../Identifiers";
export enum EventPrivacyLevel {
PUBLIC = 1,
GUILD_ONLY = 2,
}
+34 -1
View File
@@ -1,6 +1,6 @@
/*
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2025 Spacebar and Spacebar Contributors
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
@@ -28,3 +28,36 @@ export interface IntegrationGuild {
name: string;
icon: string | null;
}
export enum GuildVerificationLevel {
NONE = 0,
// Verified email
LOW = 1,
// Registered >5min ago
MEDIUM = 2,
// Member for >10min
HIGH = 3,
// Verified phone number
VERY_HIGH = 4,
}
export enum GuildNsfwLevel {
DEFAULT = 0,
EXPLICIT = 1,
SAFE = 2,
AGE_RESTRICTED = 3,
}
// Unlocked boost perk level
export enum GuildPremiumTier {
NONE = 0,
TIER_1 = 1,
TIER_2 = 2,
TIER_3 = 3,
}
export enum GuildHubType {
DEFAULT = 0,
HIGH_SCHOOL = 1,
COLLEGE = 2,
}
+88
View File
@@ -0,0 +1,88 @@
/*
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 <https://www.gnu.org/licenses/>.
*/
import { Snowflake } from "../../Identifiers";
import { PartialUser } from "../users";
import { GuildNsfwLevel, GuildPremiumTier, GuildVerificationLevel } from "./GuildSchema";
import { GuildProfileResponse, PublicChannel, RoleColors } from "@spacebar/schemas";
import { Role } from "@spacebar/database";
export interface Invite {
code: string;
type: number;
channel: PublicChannel | null; // TODO: Figure out what fields this is *supposed* to have as it's labeled as "Partial channel object"
guild_id?: Snowflake;
guild?: InviteGuild;
profile?: GuildProfileResponse;
inviter?: PartialUser;
flags?: number;
target_type?: number;
target_user?: PartialUser;
// target_application?: PartialApplication; // TODO - voice activities
roles?: InviteRole[]; // TODO: This is labeled as "Partial role object", is this used anywhere else?
approximate_member_count?: number;
approximate_presence_count?: number;
expires_at: string | null;
// guild_scheduled_event?: GuildScheduledEvent; //TODO - scheduled events
new_member?: boolean;
show_verification_form?: boolean;
is_nickname_changeable?: boolean;
target_users_job_status?: InviteTargetUsersJob; // TODO
}
export interface InviteTargetUsersJob {
status: InviteTargetUsersJobStatus;
total_users: number;
processed_users: number;
created_at: Date | null;
completed_at: Date | null;
error_message: string | null;
}
export enum InviteTargetUsersJobStatus {
UNSPECIFIED = 0,
PROCESSING = 1,
COMPLETED = 2,
FAILED = 3,
}
export interface InviteGuild {
id: Snowflake;
name: string;
icon: string | null;
description: string | null;
banner: string | null;
splash: string | null;
verification_level: GuildVerificationLevel;
features: string[];
vanity_url_code: string | null;
premium_subscription_count?: number;
premium_tier: GuildPremiumTier;
nsfw: boolean;
nsfw_level: GuildNsfwLevel;
}
export interface InviteRole {
id: Snowflake;
name: string;
position: number;
color: number;
colors: RoleColors;
icon?: string | null;
unicode_emoji?: string | null;
}
+1 -1
View File
@@ -163,7 +163,7 @@ export interface MessageSnapshot {
};
}
export type PublicMessageArray = PublicMessage[];
export type PublicMessageListResponse = PublicMessage[];
export interface PublicMessage {
id: Snowflake;
channel_id: Snowflake;
+1 -1
View File
@@ -116,4 +116,4 @@ export type PublicMember = Omit<Pick<Member, PublicMemberKeys>, "roles"> & {
roles: string[]; // only role ids not objects
};
export type PublicMemberArray = PublicMember[];
export type PublicMemberListResponse = PublicMember[];
+2 -4
View File
@@ -21,17 +21,15 @@ import { GeneralConfiguration, LimitsConfiguration } from "../../util/config/typ
import { DmChannelDTO } from "../../util/dtos";
// TODO: remove entity imports
import { Application, Categories, Channel, Guild, Invite, Template } from "@spacebar/database";
import { GuildCreateResponse, PrivateUser, PublicUser } from "@spacebar/schemas";
import { GuildCreateResponse, PrivateUser } from "@spacebar/schemas";
// TODO: remove this entire file!
// removes internal properties from the guild class
export type APIGuild = Omit<Guild, "afk_channel" | "template" | "owner" | "public_updates_channel" | "rules_channel" | "system_channel" | "widget_channel">;
export type APIPublicUser = PublicUser;
export type APIPrivateUser = PrivateUser;
export type APIGuildArray = APIGuild[];
export type APIDMChannelArray = DmChannelDTO[];
export interface UserUpdateResponse extends APIPrivateUser {
export interface UserUpdateResponse extends PrivateUser {
newToken?: string;
}