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