🎨 rewrite imports
This commit is contained in:
parent
16a3d1b334
commit
912d1c31d8
BIN
api/package-lock.json
generated
BIN
api/package-lock.json
generated
Binary file not shown.
@ -46,6 +46,7 @@
|
||||
"@types/express": "^4.17.9",
|
||||
"@types/i18next-node-fs-backend": "^2.1.0",
|
||||
"@types/jest": "^27.0.1",
|
||||
"@types/jest-expect-message": "^1.0.3",
|
||||
"@types/jsonwebtoken": "^8.5.0",
|
||||
"@types/mongodb": "^3.6.9",
|
||||
"@types/mongoose": "^5.10.5",
|
||||
@ -61,6 +62,8 @@
|
||||
"caxa": "^2.1.0",
|
||||
"image-size": "^1.0.0",
|
||||
"jest": "^26.6.3",
|
||||
"jest-expect-message": "^1.0.2",
|
||||
"jest-runtime": "^27.2.1",
|
||||
"saslprep": "^1.0.3",
|
||||
"ts-node": "^9.1.1",
|
||||
"ts-node-dev": "^1.1.6",
|
||||
@ -85,7 +88,7 @@
|
||||
"express": "^4.17.1",
|
||||
"express-validator": "^6.9.2",
|
||||
"form-data": "^3.0.0",
|
||||
"i18next": "^19.8.5",
|
||||
"i18next": "^19.9.2",
|
||||
"i18next-http-middleware": "^3.1.3",
|
||||
"i18next-node-fs-backend": "^2.1.3",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
@ -106,6 +109,9 @@
|
||||
"setupFiles": [
|
||||
"<rootDir>/jest/setup.js"
|
||||
],
|
||||
"setupFilesAfterEnv": [
|
||||
"jest-expect-message"
|
||||
],
|
||||
"globalSetup": "<rootDir>/jest/globalSetup.js",
|
||||
"verbose": true
|
||||
}
|
||||
|
||||
BIN
bundle/package-lock.json
generated
BIN
bundle/package-lock.json
generated
Binary file not shown.
@ -45,6 +45,7 @@
|
||||
"@types/ws": "^7.4.0",
|
||||
"@zerollup/ts-transform-paths": "^1.7.18",
|
||||
"ts-node": "^10.2.1",
|
||||
"ts-patch": "^1.4.4",
|
||||
"typescript": "^4.3.5"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
BIN
cdn/package-lock.json
generated
BIN
cdn/package-lock.json
generated
Binary file not shown.
@ -36,6 +36,7 @@
|
||||
"@types/node": "^14.17.0",
|
||||
"@types/node-fetch": "^2.5.7",
|
||||
"@types/uuid": "^8.3.0",
|
||||
"@zerollup/ts-transform-paths": "^1.7.18",
|
||||
"ts-patch": "^1.4.4"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@ -68,7 +68,7 @@
|
||||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@fosscord/cdn/": ["src/index.ts"],
|
||||
"@fosscord/cdn/": ["src/index"],
|
||||
"@fosscord/cdn/*": ["src/*"]
|
||||
},
|
||||
"plugins": [{ "transform": "@zerollup/ts-transform-paths" }]
|
||||
|
||||
BIN
gateway/package-lock.json
generated
BIN
gateway/package-lock.json
generated
Binary file not shown.
@ -23,6 +23,7 @@
|
||||
"@types/node-fetch": "^2.5.12",
|
||||
"@types/uuid": "^8.3.0",
|
||||
"@types/ws": "^7.4.0",
|
||||
"@zerollup/ts-transform-paths": "^1.7.18",
|
||||
"ts-node-dev": "^1.1.6",
|
||||
"ts-patch": "^1.4.4",
|
||||
"typescript": "^4.2.3"
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import WebSocket from "@fosscord/gateway/util/WebSocket";
|
||||
import { WebSocket } from "@fosscord/gateway";
|
||||
import { Message } from "./Message";
|
||||
import { Session } from "@fosscord/util";
|
||||
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
import WS from "ws";
|
||||
import WebSocket from "@fosscord/gateway/util/WebSocket";
|
||||
import {
|
||||
setHeartbeat,
|
||||
Send,
|
||||
CLOSECODES,
|
||||
OPCODES,
|
||||
WebSocket,
|
||||
} from "@fosscord/gateway";
|
||||
import { IncomingMessage } from "http";
|
||||
import { Close } from "./Close";
|
||||
import { Message } from "./Message";
|
||||
import { setHeartbeat } from "@fosscord/gateway/util/setHeartbeat";
|
||||
import { Send } from "@fosscord/gateway/util/Send";
|
||||
import { CLOSECODES, OPCODES } from "@fosscord/gateway/util/Constants";
|
||||
import { createDeflate } from "zlib";
|
||||
import { URL } from "url";
|
||||
import { Session } from "@fosscord/util";
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
import WebSocket from "@fosscord/gateway/util/WebSocket";
|
||||
import { WebSocket, Payload, CLOSECODES, OPCODES } from "@fosscord/gateway";
|
||||
var erlpack: any;
|
||||
try {
|
||||
erlpack = require("erlpack");
|
||||
} catch (error) {}
|
||||
import OPCodeHandlers from "../opcodes";
|
||||
import { Payload, CLOSECODES, OPCODES } from "@fosscord/gateway/util/Constants";
|
||||
import { instanceOf, Tuple } from "lambert-server";
|
||||
import { check } from "../opcodes/instanceOf";
|
||||
import WS from "ws";
|
||||
|
||||
@ -9,12 +9,9 @@ import {
|
||||
ListenEventOpts,
|
||||
Member,
|
||||
} from "@fosscord/util";
|
||||
import { OPCODES } from "@fosscord/gateway/util/Constants";
|
||||
import { Send } from "@fosscord/gateway/util/Send";
|
||||
import WebSocket from "@fosscord/gateway/util/WebSocket";
|
||||
import { OPCODES, WebSocket, Send } from "@fosscord/gateway";
|
||||
import "missing-native-js-functions";
|
||||
import { Channel as AMQChannel } from "amqplib";
|
||||
import { In, Like } from "typeorm";
|
||||
import { Recipient } from "@fosscord/util";
|
||||
|
||||
// TODO: close connection on Invalidated Token
|
||||
@ -116,7 +113,7 @@ async function consume(this: WebSocket, opts: EventOpts) {
|
||||
.has("VIEW_CHANNEL")
|
||||
)
|
||||
return;
|
||||
//No break needed here, we need to call the listenEvent function below
|
||||
//No break needed here, we need to call the listenEvent function below
|
||||
case "GUILD_CREATE":
|
||||
this.events[id] = await listenEvent(id, consumer, listenOpts);
|
||||
break;
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
import { CLOSECODES, Payload } from "@fosscord/gateway/util/Constants";
|
||||
import { Send } from "@fosscord/gateway/util/Send";
|
||||
import { setHeartbeat } from "@fosscord/gateway/util/setHeartbeat";
|
||||
import WebSocket from "@fosscord/gateway/util/WebSocket";
|
||||
import { Payload, Send, setHeartbeat, WebSocket } from "@fosscord/gateway";
|
||||
|
||||
export async function onHeartbeat(this: WebSocket, data: Payload) {
|
||||
// TODO: validate payload
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
import { CLOSECODES, Payload, OPCODES } from "@fosscord/gateway/util/Constants";
|
||||
import WebSocket from "@fosscord/gateway/util/WebSocket";
|
||||
import {
|
||||
WebSocket,
|
||||
CLOSECODES,
|
||||
Payload,
|
||||
OPCODES,
|
||||
genSessionId,
|
||||
} from "@fosscord/gateway";
|
||||
import {
|
||||
Channel,
|
||||
checkToken,
|
||||
@ -24,7 +29,6 @@ import { Send } from "@fosscord/gateway/util/Send";
|
||||
const experiments: any = [];
|
||||
import { check } from "./instanceOf";
|
||||
import { Recipient } from "@fosscord/util";
|
||||
import { genSessionId } from "@fosscord/gateway/util/SessionUtils";
|
||||
|
||||
// TODO: bot sharding
|
||||
// TODO: check priviliged intents
|
||||
@ -98,7 +102,9 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
||||
//TODO is this needed? check if users in group dm that are not friends are sent in the READY event
|
||||
//users = users.concat(x.channel.recipients);
|
||||
if (x.channel.isDm()) {
|
||||
x.channel.recipients = x.channel.recipients!.filter((x) => x.id !== this.user_id);
|
||||
x.channel.recipients = x.channel.recipients!.filter(
|
||||
(x) => x.id !== this.user_id
|
||||
);
|
||||
}
|
||||
return x.channel;
|
||||
});
|
||||
@ -109,7 +115,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
||||
if (!user) return this.close(CLOSECODES.Authentication_failed);
|
||||
|
||||
for (let relation of user.relationships) {
|
||||
const related_user = relation.to
|
||||
const related_user = relation.to;
|
||||
const public_related_user = {
|
||||
username: related_user.username,
|
||||
discriminator: related_user.discriminator,
|
||||
|
||||
@ -2,13 +2,10 @@ import {
|
||||
getPermission,
|
||||
Member,
|
||||
PublicMemberProjection,
|
||||
PublicUserProjection,
|
||||
Role,
|
||||
} from "@fosscord/util";
|
||||
import { LazyRequest } from "../schema/LazyRequest";
|
||||
import { OPCODES, Payload } from "@fosscord/gateway/util/Constants";
|
||||
import { Send } from "@fosscord/gateway/util/Send";
|
||||
import WebSocket from "@fosscord/gateway/util/WebSocket";
|
||||
import { WebSocket, Send, OPCODES, Payload } from "@fosscord/gateway";
|
||||
import { check } from "./instanceOf";
|
||||
import "missing-native-js-functions";
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { CLOSECODES, Payload } from "@fosscord/gateway/util/Constants";
|
||||
import WebSocket from "@fosscord/gateway/util/WebSocket";
|
||||
import { WebSocket, Payload } from "@fosscord/gateway";
|
||||
|
||||
export function onPresenceUpdate(this: WebSocket, data: Payload) {
|
||||
// return this.close(CLOSECODES.Unknown_error);
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
import { CLOSECODES, Payload } from "@fosscord/gateway/util/Constants";
|
||||
|
||||
import WebSocket from "@fosscord/gateway/util/WebSocket";
|
||||
import { Payload, WebSocket } from "@fosscord/gateway";
|
||||
|
||||
export function onRequestGuildMembers(this: WebSocket, data: Payload) {
|
||||
// return this.close(CLOSECODES.Unknown_error);
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
import { CLOSECODES, Payload } from "@fosscord/gateway/util/Constants";
|
||||
import { Send } from "@fosscord/gateway/util/Send";
|
||||
|
||||
import WebSocket from "@fosscord/gateway/util/WebSocket";
|
||||
import { WebSocket, Payload, Send } from "@fosscord/gateway";
|
||||
|
||||
export async function onResume(this: WebSocket, data: Payload) {
|
||||
console.log("Got Resume -> cancel not implemented");
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { VoiceStateUpdateSchema } from "../schema/VoiceStateUpdateSchema";
|
||||
import { Payload } from "@fosscord/gateway/util/Constants";
|
||||
import WebSocket from "@fosscord/gateway/util/WebSocket";
|
||||
import { Payload, WebSocket, genVoiceToken } from "@fosscord/gateway";
|
||||
import { check } from "./instanceOf";
|
||||
import {
|
||||
Config,
|
||||
@ -12,7 +11,6 @@ import {
|
||||
VoiceState,
|
||||
VoiceStateUpdateEvent,
|
||||
} from "@fosscord/util";
|
||||
import { genVoiceToken } from "@fosscord/gateway/util/SessionUtils";
|
||||
// TODO: check if a voice server is setup
|
||||
// Notice: Bot users respect the voice channel's user limit, if set. When the voice channel is full, you will not receive the Voice State Update or Voice Server Update events in response to your own Voice State Update. Having MANAGE_CHANNELS permission bypasses this limit and allows you to join regardless of the channel being full or not.
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { Payload } from "@fosscord/gateway/util/Constants";
|
||||
import WebSocket from "@fosscord/gateway/util/WebSocket";
|
||||
import { WebSocket, Payload } from "@fosscord/gateway";
|
||||
import { onHeartbeat } from "./Heartbeat";
|
||||
import { onIdentify } from "./Identify";
|
||||
import { onLazyRequest } from "./LazyRequest";
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { instanceOf } from "lambert-server";
|
||||
import { CLOSECODES } from "@fosscord/gateway/util/Constants";
|
||||
import WebSocket from "@fosscord/gateway/util/WebSocket";
|
||||
import { WebSocket, CLOSECODES } from "@fosscord/gateway";
|
||||
|
||||
export function check(this: WebSocket, schema: any, data: any) {
|
||||
try {
|
||||
|
||||
@ -2,9 +2,7 @@ var erlpack: any;
|
||||
try {
|
||||
erlpack = require("erlpack");
|
||||
} catch (error) {}
|
||||
import { Payload } from "@fosscord/gateway/util/Constants";
|
||||
|
||||
import WebSocket from "./WebSocket";
|
||||
import { Payload, WebSocket } from "@fosscord/gateway";
|
||||
|
||||
export async function Send(socket: WebSocket, data: Payload) {
|
||||
let buffer: Buffer | string;
|
||||
@ -20,7 +18,7 @@ export async function Send(socket: WebSocket, data: Payload) {
|
||||
}
|
||||
|
||||
return new Promise((res, rej) => {
|
||||
socket.send(buffer, (err) => {
|
||||
socket.send(buffer, (err: any) => {
|
||||
if (err) return rej(err);
|
||||
return res(null);
|
||||
});
|
||||
|
||||
@ -3,7 +3,7 @@ import WS from "ws";
|
||||
import { Deflate } from "zlib";
|
||||
import { Channel } from "amqplib";
|
||||
|
||||
interface WebSocket extends WS {
|
||||
export interface WebSocket extends WS {
|
||||
version: number;
|
||||
user_id: string;
|
||||
session_id: string;
|
||||
@ -19,5 +19,3 @@ interface WebSocket extends WS {
|
||||
permissions: Record<string, Permissions>;
|
||||
events: Record<string, Function>;
|
||||
}
|
||||
|
||||
export default WebSocket;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { CLOSECODES } from "./Constants";
|
||||
import WebSocket from "./WebSocket";
|
||||
import { WebSocket } from "./WebSocket";
|
||||
|
||||
// TODO: make heartbeat timeout configurable
|
||||
export function setHeartbeat(socket: WebSocket) {
|
||||
|
||||
@ -70,6 +70,7 @@
|
||||
"resolveJsonModule": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@fosscord/gateway": ["src/index"],
|
||||
"@fosscord/gateway/*": ["src/*"],
|
||||
"@fosscord/util/*": ["../util/src/*"]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user