From 6995aa7f74e78be9cff90fde3d1c913bce834aac Mon Sep 17 00:00:00 2001 From: Rory& Date: Sat, 13 Jun 2026 01:57:19 +0200 Subject: [PATCH] Split config/response voice regions, remove APIVoiceRegion alias --- assets/openapi.json | Bin 972137 -> 972276 bytes assets/schemas.json | Bin 439501 -> 439600 bytes scripts/schema.js | 2 +- src/api/routes/guilds/#guild_id/regions.ts | 2 +- src/api/routes/voice/regions.ts | 2 +- src/gateway/opcodes/VoiceStateUpdate.ts | 4 +-- src/schemas/responses/TypedResponses.ts | 1 - .../webrtc/{Region.ts => VoiceRegion.ts} | 24 +++++++++++++----- src/schemas/webrtc/index.ts | 2 +- src/util/config/types/RegionConfiguration.ts | 4 +-- 10 files changed, 26 insertions(+), 15 deletions(-) rename src/schemas/webrtc/{Region.ts => VoiceRegion.ts} (70%) diff --git a/assets/openapi.json b/assets/openapi.json index 1d1e8dfa10b23be70f9b30af2bf5f4c8bf6c9cd2..95a8807f5a6b4a7a8781fd84ed76e48585c4922a 100644 GIT binary patch delta 374 zcmaF4%KFP{>kYrvH~-XhXWIN*{U2kqgHF4H4&!zQ9i}@v++q2d$*Do9>6!U?lNq0- zOs`wX&N01i1-tX~1Vy%($pYHqlOIfsV=SAVV8W^~eSaB=1`iv;SE1OlCeIS#U((a)g~8YN=$#hmdSRy|1B0)W}uzZ z6TdQ9ZZsqIb(86K&UEgl%o)=cY-N_*ZY9qg$2jd4Gt2gO%FJ6Crw4Ger%q3h zU^zW~gBUaS^m-9yndt}YfQAKJVoscXU@a^A^gLKfw*5dH`ziP72~U|=w(nfYURDiu3me4$(>Hi=E}AaD&MDXaO_c+PIf0mK o`!`kY9U|!JYNso(^15$VNaPA(Za-_s4a7V^%)9-p9p9X305yG(fdBvi delta 332 zcmeye+WO@x>kYrvH#=$lW8C~(-JPk~L8sk8hjF`u4$~c-?Gs{|I_kOIOEYs)!tyhd zQ-db|UoSO%LpHPG^bMkH^3w}GvdT?w&}L*~2g|0WPi{OdI$a@`S#G=NU8Z|E+n*^h zCooQbP{YQ$eXct57RKoxgjf=$D?DXq-TuLsnO|i3flBs_=>;xq5^YJ$ZAmO`Nvv&2 zY}=C9Ej*@Kva_)wEN%G8w0QD^iE+~}EMa4t&K=FPa&m#L`1I~bChzG9`x$+w2Yawe zOy|AC$36Wk6TA5I4ODmM^a*vG&h52o96-zo#9Z5J)wp+vV5;ohUXae!#M~ZX&ke*pK+L;6!k%x=Gysf8 BeA)m2 diff --git a/assets/schemas.json b/assets/schemas.json index 426a8776b934f15dee1d76ffc73c575b883ec6bd..9506fab1c452f0243d49dfc6ba3c011fdd8bba08 100644 GIT binary patch delta 214 zcmX^6Qfk91sSTUuH&0jOW!k)1{t4sshIz~!&1;mmuTf^SdB72tpP8H*l$t)>poPhQ z`ngUv>**J2SoJ3_$Wob}u!O~psVsB4;$v3%$ro;^PA}NY$Tr=sldW<3hIZDN>8V|8 z5kfj#3P?byEVE#8p=}sH%-qcUJfFH4QMG)a{5MB z#<=Y-n3){2wtvfGx)wV}JTFu866Nhnlo?$fY`?(H{#pU!K;!rt!im= 20) console.log(bgRedBright("\x1b[5m[SLOW]\x1b[25m")); + if (elapsed.totalMilliseconds >= 100) console.log(bgRedBright("\x1b[5m[SLOW]\x1b[25m")); else console.log(); definitions = { ...definitions, [name]: { ...part } }; diff --git a/src/api/routes/guilds/#guild_id/regions.ts b/src/api/routes/guilds/#guild_id/regions.ts index 4edf582c4..12fb33df5 100644 --- a/src/api/routes/guilds/#guild_id/regions.ts +++ b/src/api/routes/guilds/#guild_id/regions.ts @@ -27,7 +27,7 @@ router.get( route({ responses: { 200: { - body: "APIGuildVoiceRegion", + body: "VoiceRegionListResponse", }, 404: { body: "APIErrorResponse", diff --git a/src/api/routes/voice/regions.ts b/src/api/routes/voice/regions.ts index a6759b553..d23a0cb7a 100644 --- a/src/api/routes/voice/regions.ts +++ b/src/api/routes/voice/regions.ts @@ -26,7 +26,7 @@ router.get( route({ responses: { 200: { - body: "APIGuildVoiceRegion", + body: "VoiceRegionListResponse", }, }, }), diff --git a/src/gateway/opcodes/VoiceStateUpdate.ts b/src/gateway/opcodes/VoiceStateUpdate.ts index e6975358f..bcde7ed6c 100644 --- a/src/gateway/opcodes/VoiceStateUpdate.ts +++ b/src/gateway/opcodes/VoiceStateUpdate.ts @@ -19,7 +19,7 @@ import { Guild, Member, VoiceState } from "@spacebar/database"; import { Payload, WebSocket, genVoiceToken } from "@spacebar/gateway"; import { Config, emitEvent, VoiceServerUpdateEvent, VoiceStateUpdateEvent } from "@spacebar/util"; -import { Region, VoiceStateUpdateSchema } from "@spacebar/schemas"; +import { ConfigVoiceRegion, VoiceStateUpdateSchema } from "@spacebar/schemas"; import { check } from "./instanceOf"; // TODO: check if a voice server is setup @@ -127,7 +127,7 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) { where: { id: voiceState.guild_id }, }); const regions = Config.get().regions; - let guildRegion: Region | undefined; + let guildRegion: ConfigVoiceRegion | undefined; const defaultRegion = regions.available.find((r) => r.id === regions.default); diff --git a/src/schemas/responses/TypedResponses.ts b/src/schemas/responses/TypedResponses.ts index 9b7d64ee2..692487b0a 100644 --- a/src/schemas/responses/TypedResponses.ts +++ b/src/schemas/responses/TypedResponses.ts @@ -56,7 +56,6 @@ export interface APIGuildWithJoinedAt extends GuildCreateResponse { export type APIRoleArray = Role[]; export type APITemplateArray = Template[]; -export type APIGuildVoiceRegion = GuildVoiceRegion[]; export type APILimitsConfiguration = LimitsConfiguration; export type APIConnectionsConfiguration = Record< diff --git a/src/schemas/webrtc/Region.ts b/src/schemas/webrtc/VoiceRegion.ts similarity index 70% rename from src/schemas/webrtc/Region.ts rename to src/schemas/webrtc/VoiceRegion.ts index 57f1602ec..0f98a30cf 100644 --- a/src/schemas/webrtc/Region.ts +++ b/src/schemas/webrtc/VoiceRegion.ts @@ -16,15 +16,27 @@ along with this program. If not, see . */ -export interface Region { +export interface BaseVoiceRegion { id: string; name: string; - endpoint: string; - location?: { - latitude: number; - longitude: number; - }; vip: boolean; custom: boolean; deprecated: boolean; } + +export interface ConfigVoiceRegion extends BaseVoiceRegion { + endpoint: string; // not spec, used for config + location?: { + latitude: number; + longitude: number; + }; // not spec, used for config + vip: boolean; + custom: boolean; + deprecated: boolean; +} + +export interface VoiceRegionResponse extends BaseVoiceRegion { + optimal: boolean; +} + +export type VoiceRegionListResponse = VoiceRegionResponse[]; diff --git a/src/schemas/webrtc/index.ts b/src/schemas/webrtc/index.ts index b4c023a44..a9e47e6bb 100644 --- a/src/schemas/webrtc/index.ts +++ b/src/schemas/webrtc/index.ts @@ -18,4 +18,4 @@ export * from "./VoiceIdentifySchema"; export * from "./VoiceVideoSchema"; -export * from "./Region"; +export * from "./VoiceRegion"; diff --git a/src/util/config/types/RegionConfiguration.ts b/src/util/config/types/RegionConfiguration.ts index bf953688c..1cac1104e 100644 --- a/src/util/config/types/RegionConfiguration.ts +++ b/src/util/config/types/RegionConfiguration.ts @@ -16,12 +16,12 @@ along with this program. If not, see . */ -import { Region } from "@spacebar/schemas"; +import { ConfigVoiceRegion } from "@spacebar/schemas"; export class RegionConfiguration { default: string = "spacebar"; useDefaultAsOptimal: boolean = true; - available: Region[] = [ + available: ConfigVoiceRegion[] = [ { id: "spacebar", name: "spacebar",