summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-06-11 18:07:50 +0200
committerRory& <root@rory.gay>2026-06-12 17:58:18 +0200
commitd84b8707ee3855440838304245db7140ee17b6c3 (patch)
treed81333f441614ae1d8000bd00150c461ac0fb9fc
parentAllow subpath imports from module aliases (diff)
downloadserver-ts-d84b8707ee3855440838304245db7140ee17b6c3.tar.xz
Allow subpath imports, move extensions to separate module
-rw-r--r--package.json1
-rw-r--r--src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/roles/#role_id/members.ts3
-rw-r--r--src/api/util/handlers/Message.ts4
-rw-r--r--src/api/util/utility/EmbedHandlers.ts3
-rw-r--r--src/cdn/routes/avatars.ts4
-rw-r--r--src/extensions/Array.ts (renamed from src/util/util/extensions/Array.ts)0
-rw-r--r--src/extensions/Math.ts (renamed from src/util/util/extensions/Math.ts)0
-rw-r--r--src/extensions/index.ts (renamed from src/util/util/extensions/index.ts)0
-rw-r--r--src/gateway/opcodes/Identify.ts2
-rw-r--r--src/gateway/opcodes/LazyRequest.ts3
-rw-r--r--src/gateway/util/Utils.ts21
-rw-r--r--src/util/entities/Guild.ts2
-rw-r--r--src/util/util/index.ts2
-rw-r--r--src/util/util/ipc/listener/RabbitMqSingleListener.ts9
-rw-r--r--src/util/util/ipc/listener/UnixSocketListener.ts5
-rw-r--r--src/util/util/ipc/writer/RabbitMqSingleWriter.ts5
-rw-r--r--tsconfig.json9
18 files changed, 53 insertions, 22 deletions
diff --git a/package.json b/package.json

index f20e31d4..c06a6f1b 100644 --- a/package.json +++ b/package.json
@@ -126,6 +126,7 @@ "_moduleAliases": { "@spacebar/api": "dist/api", "@spacebar/cdn": "dist/cdn", + "@spacebar/extensions": "dist/extensions", "@spacebar/gateway": "dist/gateway", "@spacebar/util": "dist/util", "@spacebar/webrtc": "dist/webrtc", diff --git a/src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts b/src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts
index 305f81fc..839ae6ee 100644 --- a/src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts +++ b/src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts
@@ -17,6 +17,7 @@ */ import { route } from "@spacebar/api"; +import { arrayRemove } from "@spacebar/extensions"; import { Channel, emitEvent, @@ -29,7 +30,6 @@ import { MessageReactionRemoveEmojiEvent, MessageReactionRemoveEvent, User, - arrayRemove, ReactionType, } from "@spacebar/util"; import { Request, Response, Router } from "express"; diff --git a/src/api/routes/guilds/#guild_id/roles/#role_id/members.ts b/src/api/routes/guilds/#guild_id/roles/#role_id/members.ts
index aea54b1d..5a55c731 100644 --- a/src/api/routes/guilds/#guild_id/roles/#role_id/members.ts +++ b/src/api/routes/guilds/#guild_id/roles/#role_id/members.ts
@@ -17,7 +17,8 @@ */ import { Router, Request, Response } from "express"; -import { DiscordApiErrors, Member, arrayPartition } from "@spacebar/util"; +import { arrayPartition } from "@spacebar/extensions"; +import { DiscordApiErrors, Member } from "@spacebar/util"; import { route } from "@spacebar/api"; const router = Router({ mergeParams: true }); diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts
index acfe7f31..74c2d6d0 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts
@@ -17,10 +17,9 @@ */ import { fillMessageUrlEmbeds, randomString } from "@spacebar/api"; +import { mathLogBase, arrayDistributeSequentially } from "@spacebar/extensions"; import { Application, - arrayDistributeSequentially, - arrayPartition, Attachment, Channel, CloudAttachment, @@ -35,7 +34,6 @@ import { Guild, handleFile, HERE_MENTION, - mathLogBase, Member, Message, MessageCreateEvent, diff --git a/src/api/util/utility/EmbedHandlers.ts b/src/api/util/utility/EmbedHandlers.ts
index f242d686..fa3d74f0 100644 --- a/src/api/util/utility/EmbedHandlers.ts +++ b/src/api/util/utility/EmbedHandlers.ts
@@ -16,7 +16,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import { arrayDistinctBy, arrayGroupBy, Config, EmbedCache, emitEvent, Message, MessageUpdateEvent, normalizeUrl, OrmUtils, sleep } from "@spacebar/util"; +import { sleep, arrayDistinctBy, arrayGroupBy } from "@spacebar/extensions"; +import { Config, EmbedCache, emitEvent, Message, MessageUpdateEvent, normalizeUrl, OrmUtils } from "@spacebar/util"; import { Embed, EmbedImage, EmbedType } from "@spacebar/schemas"; import * as cheerio from "cheerio"; import crypto from "node:crypto"; diff --git a/src/cdn/routes/avatars.ts b/src/cdn/routes/avatars.ts
index bf2ab437..6685ef7f 100644 --- a/src/cdn/routes/avatars.ts +++ b/src/cdn/routes/avatars.ts
@@ -16,12 +16,12 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ +import crypto from "node:crypto"; import { Router, Response, Request } from "express"; +import { fileTypeFromBuffer } from "file-type"; import { Config } from "@spacebar/util"; import { storage } from "@spacebar/cdn"; -import { fileTypeFromBuffer } from "file-type"; import { HTTPError } from "lambert-server"; -import crypto from "node:crypto"; import { multer } from "../util/multer"; import { cache } from "../util/cache"; diff --git a/src/util/util/extensions/Array.ts b/src/extensions/Array.ts
index c95328b5..c95328b5 100644 --- a/src/util/util/extensions/Array.ts +++ b/src/extensions/Array.ts
diff --git a/src/util/util/extensions/Math.ts b/src/extensions/Math.ts
index 0a34aaab..0a34aaab 100644 --- a/src/util/util/extensions/Math.ts +++ b/src/extensions/Math.ts
diff --git a/src/util/util/extensions/index.ts b/src/extensions/index.ts
index 53bd443c..53bd443c 100644 --- a/src/util/util/extensions/index.ts +++ b/src/extensions/index.ts
diff --git a/src/gateway/opcodes/Identify.ts b/src/gateway/opcodes/Identify.ts
index 91fdcd88..74907f45 100644 --- a/src/gateway/opcodes/Identify.ts +++ b/src/gateway/opcodes/Identify.ts
@@ -17,9 +17,9 @@ */ import { Capabilities, CLOSECODES, OPCODES, Payload, Send, setupListener, WebSocket } from "@spacebar/gateway"; +import { arrayGroupBy } from "@spacebar/extensions"; import { Application, - arrayGroupBy, Channel, checkToken, Config, diff --git a/src/gateway/opcodes/LazyRequest.ts b/src/gateway/opcodes/LazyRequest.ts
index 74b941ac..0080e589 100644 --- a/src/gateway/opcodes/LazyRequest.ts +++ b/src/gateway/opcodes/LazyRequest.ts
@@ -16,7 +16,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import { getDatabase, getPermission, listenEvent, Member, Role, Session, User, Presence, Channel, Permissions, arrayPartition, getMostRelevantSession } from "@spacebar/util"; +import { arrayPartition } from "@spacebar/extensions"; +import { getDatabase, getPermission, listenEvent, Member, Role, Session, User, Presence, Channel, Permissions, getMostRelevantSession } from "@spacebar/util"; import { WebSocket, Payload, handlePresenceUpdate, OPCODES, Send } from "@spacebar/gateway"; import murmur from "murmurhash-js/murmurhash3_gc"; import { check } from "./instanceOf"; diff --git a/src/gateway/util/Utils.ts b/src/gateway/util/Utils.ts
index ebf7ae02..20880622 100644 --- a/src/gateway/util/Utils.ts +++ b/src/gateway/util/Utils.ts
@@ -1,4 +1,23 @@ -import { Event, Session, sleep, TimeSpan, VoiceState } 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 <https://www.gnu.org/licenses/>. +*/ + +import { sleep } from "@spacebar/extensions"; +import { Event, Session, TimeSpan, VoiceState } from "@spacebar/util"; import { WebSocket } from "./WebSocket"; import { OPCODES } from "./Constants"; import { Send } from "./Send"; diff --git a/src/util/entities/Guild.ts b/src/util/entities/Guild.ts
index aea911eb..0cea637e 100644 --- a/src/util/entities/Guild.ts +++ b/src/util/entities/Guild.ts
@@ -17,6 +17,7 @@ */ import { Column, Entity, JoinColumn, ManyToOne, OneToMany, RelationId } from "typeorm"; +import { arrayRemove } from "@spacebar/extensions"; import { Config, GuildWelcomeScreen, Snowflake, handleFile } from ".."; import { Ban } from "./Ban"; import { BaseClass } from "./BaseClass"; @@ -30,7 +31,6 @@ import { Template } from "./Template"; import { User } from "./User"; import { VoiceState } from "./VoiceState"; import { Webhook } from "./Webhook"; -import { arrayRemove } from "@spacebar/util"; // TODO: application_command_count, application_command_counts: {1: 0, 2: 0, 3: 0} // TODO: guild_scheduled_events // TODO: stage_instances diff --git a/src/util/util/index.ts b/src/util/util/index.ts
index f6de6a95..2c028e1d 100644 --- a/src/util/util/index.ts +++ b/src/util/util/index.ts
@@ -17,7 +17,6 @@ */ export * from "./ApiError"; -export * from "./extensions/Array"; export * from "./BitField"; //export * from "./Categories"; export * from "./cdn"; @@ -52,7 +51,6 @@ export * from "./Gifs"; export * from "./Application"; export * from "./NameValidation"; export * from "../../schemas/HelperTypes"; -export * from "./extensions"; export * from "./Random"; export * from "./Url"; export * from "./Version"; diff --git a/src/util/util/ipc/listener/RabbitMqSingleListener.ts b/src/util/util/ipc/listener/RabbitMqSingleListener.ts
index 7e5867ac..d221cbb8 100644 --- a/src/util/util/ipc/listener/RabbitMqSingleListener.ts +++ b/src/util/util/ipc/listener/RabbitMqSingleListener.ts
@@ -18,12 +18,13 @@ import EventEmitter from "node:events"; import { randomUUID } from "node:crypto"; -import { BaseEventListener } from "./BaseEventListener"; -import { arraySum, EVENT, Event, EventOpts, sleep } from "@spacebar/util"; import amqp, { Channel, ChannelModel } from "amqplib"; -import { ProcessLifecycle } from "../../ProcessLifecycle"; -import { Monitoring } from "../../../monitoring/Monitoring"; import { Gauge } from "prom-client"; +import { sleep, arraySum } from "@spacebar/extensions"; +import { EVENT, Event, EventOpts } from "@spacebar/util"; +import { Monitoring } from "../../../monitoring/Monitoring"; +import { ProcessLifecycle } from "../../ProcessLifecycle"; +import { BaseEventListener } from "./BaseEventListener"; export class RabbitMqSingleListener extends BaseEventListener { static openListenersMetric: Gauge; diff --git a/src/util/util/ipc/listener/UnixSocketListener.ts b/src/util/util/ipc/listener/UnixSocketListener.ts
index 50ffe2b0..cb9ea96b 100644 --- a/src/util/util/ipc/listener/UnixSocketListener.ts +++ b/src/util/util/ipc/listener/UnixSocketListener.ts
@@ -19,10 +19,11 @@ import EventEmitter from "node:events"; import fs from "node:fs"; import net, { Server } from "node:net"; +import { Gauge } from "prom-client"; +import { arraySum } from "@spacebar/extensions"; +import { EVENT, Event, EventOpts } from "@spacebar/util"; import { BaseEventListener } from "./BaseEventListener"; -import { arraySum, EVENT, Event, EventOpts } from "@spacebar/util"; import { ProcessLifecycle } from "../../ProcessLifecycle"; -import { Gauge } from "prom-client"; import { Monitoring } from "../../../monitoring/Monitoring"; export class UnixSocketListener extends BaseEventListener { diff --git a/src/util/util/ipc/writer/RabbitMqSingleWriter.ts b/src/util/util/ipc/writer/RabbitMqSingleWriter.ts
index ad00aa2b..96e82036 100644 --- a/src/util/util/ipc/writer/RabbitMqSingleWriter.ts +++ b/src/util/util/ipc/writer/RabbitMqSingleWriter.ts
@@ -16,10 +16,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import { BaseEventWriter } from "./BaseEventWriter"; import amqp, { Channel, ChannelModel } from "amqplib"; -import { Event, sleep } from "@spacebar/util"; +import { sleep } from "@spacebar/extensions"; +import { Event } from "@spacebar/util"; import { ProcessLifecycle } from "../../ProcessLifecycle"; +import { BaseEventWriter } from "./BaseEventWriter"; export class RabbitMqSingleWriter extends BaseEventWriter { private readonly host: string; diff --git a/tsconfig.json b/tsconfig.json
index f7648dbb..19e71deb 100644 --- a/tsconfig.json +++ b/tsconfig.json
@@ -32,12 +32,21 @@ // "baseUrl": "./src/", //deprecated "paths": { //"*": ["./src/*"], + "@spacebar/api": ["./src/api"], // Required for stable tsc, typescript-go doesn't need this "@spacebar/api*": ["./src/api*"], + "@spacebar/extensions": ["./src/extensions"], // Required for stable tsc, typescript-go doesn't need this + "@spacebar/extensions*": ["./src/extensions*"], + "@spacebar/gateway": ["./src/gateway"], // Required for stable tsc, typescript-go doesn't need this "@spacebar/gateway*": ["./src/gateway*"], + "@spacebar/cdn": ["./src/cdn"], // Required for stable tsc, typescript-go doesn't need this "@spacebar/cdn*": ["./src/cdn*"], + "@spacebar/util": ["./src/util"], // Required for stable tsc, typescript-go doesn't need this "@spacebar/util*": ["./src/util*"], + "@spacebar/webrtc": ["./src/webrtc"], // Required for stable tsc, typescript-go doesn't need this "@spacebar/webrtc*": ["./src/webrtc*"], + "@spacebar/schemas": ["./src/schemas"], // Required for stable tsc, typescript-go doesn't need this "@spacebar/schemas*": ["./src/schemas*"], + "lambert-server": ["./src/util/util/lambert-server"], // Required for stable tsc, typescript-go doesn't need this "lambert-server*": ["./src/util/util/lambert-server*"], } /* Specify a set of entries that re-map imports to additional lookup locations. */, "rootDir": "./src", // Required as of TypeScript 7