diff --git a/assets/openapi.json b/assets/openapi.json index 1d1e8dfa1..95a8807f5 100644 Binary files a/assets/openapi.json and b/assets/openapi.json differ diff --git a/assets/schemas.json b/assets/schemas.json index 426a8776b..9506fab1c 100644 Binary files a/assets/schemas.json and b/assets/schemas.json differ diff --git a/scripts/schema.js b/scripts/schema.js index 54d9335d0..369498307 100644 --- a/scripts/schema.js +++ b/scripts/schema.js @@ -256,7 +256,7 @@ async function main() { process.stdout.write( "Done in " + yellowBright(elapsed.totalMilliseconds + "." + elapsed.microseconds) + " ms, " + yellowBright(JSON.stringify(part).length) + " bytes (unformatted) ", ); - if (elapsed.totalMilliseconds >= 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",