From b4c676a21ca9b7b499384da190e7c7bea5cdff28 Mon Sep 17 00:00:00 2001 From: ADAMJR Date: Fri, 16 Dec 2022 01:21:28 +0000 Subject: [PATCH] Add types/lib folder. --- .gitignore | 1 - frontend/src/types/lib/auth.types.d.ts | 10 + frontend/src/types/lib/auth.types.js | 3 + frontend/src/types/lib/entity.types.d.ts | 166 ++++++++ frontend/src/types/lib/entity.types.js | 3 + frontend/src/types/lib/main.d.ts | 7 + frontend/src/types/lib/main.js | 24 ++ frontend/src/types/lib/patterns.types.d.ts | 11 + frontend/src/types/lib/patterns.types.js | 15 + frontend/src/types/lib/permissions.types.d.ts | 45 ++ frontend/src/types/lib/permissions.types.js | 56 +++ frontend/src/types/lib/rest.types.d.ts | 56 +++ frontend/src/types/lib/rest.types.js | 3 + frontend/src/types/lib/util.types.d.ts | 5 + frontend/src/types/lib/util.types.js | 3 + frontend/src/types/lib/ws.types.d.ts | 383 ++++++++++++++++++ frontend/src/types/lib/ws.types.js | 3 + 17 files changed, 793 insertions(+), 1 deletion(-) create mode 100644 frontend/src/types/lib/auth.types.d.ts create mode 100644 frontend/src/types/lib/auth.types.js create mode 100644 frontend/src/types/lib/entity.types.d.ts create mode 100644 frontend/src/types/lib/entity.types.js create mode 100644 frontend/src/types/lib/main.d.ts create mode 100644 frontend/src/types/lib/main.js create mode 100644 frontend/src/types/lib/patterns.types.d.ts create mode 100644 frontend/src/types/lib/patterns.types.js create mode 100644 frontend/src/types/lib/permissions.types.d.ts create mode 100644 frontend/src/types/lib/permissions.types.js create mode 100644 frontend/src/types/lib/rest.types.d.ts create mode 100644 frontend/src/types/lib/rest.types.js create mode 100644 frontend/src/types/lib/util.types.d.ts create mode 100644 frontend/src/types/lib/util.types.js create mode 100644 frontend/src/types/lib/ws.types.d.ts create mode 100644 frontend/src/types/lib/ws.types.js diff --git a/.gitignore b/.gitignore index a4269885..2a0226e1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ keys/ node_modules/ -lib/ logs/ upload/ diff --git a/frontend/src/types/lib/auth.types.d.ts b/frontend/src/types/lib/auth.types.d.ts new file mode 100644 index 00000000..5ce4cb54 --- /dev/null +++ b/frontend/src/types/lib/auth.types.d.ts @@ -0,0 +1,10 @@ +export declare namespace Auth { + interface Credentials { + email?: string; + password: string; + username: string; + } + interface Payload { + userId: string; + } +} diff --git a/frontend/src/types/lib/auth.types.js b/frontend/src/types/lib/auth.types.js new file mode 100644 index 00000000..dd019a9c --- /dev/null +++ b/frontend/src/types/lib/auth.types.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0aC50eXBlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9hdXRoLnR5cGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ== \ No newline at end of file diff --git a/frontend/src/types/lib/entity.types.d.ts b/frontend/src/types/lib/entity.types.d.ts new file mode 100644 index 00000000..c746507e --- /dev/null +++ b/frontend/src/types/lib/entity.types.d.ts @@ -0,0 +1,166 @@ +export declare namespace Entity { + interface App { + id: string; + createdAt: Date; + description: string; + name: string; + ownerId: string; + userId: string; + token: string | never; + } + interface Channel { + id: string; + createdAt: Date; + guildId: string; + name: string; + summary?: string; + lastMessageId?: null | string; + type: ChannelTypes.Type; + overrides?: ChannelTypes.Override[]; + position: number; + } + interface Guild { + id: string; + name: string; + createdAt: Date; + iconURL?: string; + ownerId: string; + systemChannelId?: string; + } + interface GuildMember { + /** @deprecated Not the same as user ID. */ + id: string; + createdAt: Date; + guildId: string; + userId: string; + roleIds: string[]; + } + interface Invite { + id: string; + createdAt: Date; + options?: InviteTypes.Options; + inviterId: string; + guildId: string; + uses: number; + } + interface Message { + id: string; + attachmentURLs?: string[]; + authorId: string; + channelId: string; + content?: string; + createdAt: Date; + embed?: MessageTypes.Embed; + type?: MessageTypes.Type; + updatedAt?: Date; + system?: boolean; + } + interface Role { + id: string; + color?: string; + createdAt: Date; + guildId: string; + hoisted: boolean; + mentionable: boolean; + name: string; + permissions: number; + position: number; + } + interface Theme { + id: string; + code: string; + createdAt: Date; + creatorId: string; + iconURL?: string; + styles: string; + name: string; + updatedAt?: Date; + isFeatured?: boolean; + } + interface User { + id: string; + avatarURL: string; + badges: UserTypes.Badge[]; + bot: boolean; + createdAt: Date; + discriminator: number; + guildIds: string[]; + premium: boolean; + status: UserTypes.StatusType; + username: string; + voice: UserTypes.VoiceState; + } +} +export declare namespace ChannelTypes { + type Type = 'TEXT' | 'VOICE'; + interface Text extends Entity.Channel { + type: 'TEXT'; + } + interface Voice extends Entity.Channel { + type: 'VOICE'; + userIds: string[]; + } + interface Override { + roleId: string; + allow: number; + deny: number; + } + interface VoiceConnection { + userId: string; + blob?: any; + } +} +export declare namespace GeneralTypes { + interface SnowflakeEntity { + id: string; + } +} +export declare namespace InviteTypes { + interface Options { + expiresAt?: Date; + maxUses?: number; + } +} +export declare namespace MessageTypes { + interface Attachment { + id: string; + name: string; + size: number; + url: string; + } + interface Embed { + description: string; + imageURL: string; + title: string; + url: string; + } + type Type = undefined | 'GUILD_MEMBER_JOIN' | 'GUILD_MEMBER_LEAVE'; +} +export declare namespace UserTypes { + type Badge = 'BUG_1' | 'BUG_2' | 'BUG_3' | 'PREMIUM' | 'OG' | 'VIEWER' | 'STAFF'; + interface Ignored { + channelIds: string[]; + guildIds: string[]; + userIds: string[]; + } + type StatusType = 'ONLINE' | 'OFFLINE'; + interface Self extends Entity.User { + activeThemeId: string; + email: string; + ignored?: { + channelIds: string[]; + guildIds: string[]; + userIds: string[]; + }; + lastReadMessageIds: { + [k: string]: string; + }; + locked: boolean; + premiumExpiration: Date; + unlockedThemeIds: string[]; + verified: true; + } + interface VoiceState { + channelId?: string; + } +} diff --git a/frontend/src/types/lib/entity.types.js b/frontend/src/types/lib/entity.types.js new file mode 100644 index 00000000..fdafe208 --- /dev/null +++ b/frontend/src/types/lib/entity.types.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW50aXR5LnR5cGVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2VudGl0eS50eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0= \ No newline at end of file diff --git a/frontend/src/types/lib/main.d.ts b/frontend/src/types/lib/main.d.ts new file mode 100644 index 00000000..37b9b668 --- /dev/null +++ b/frontend/src/types/lib/main.d.ts @@ -0,0 +1,7 @@ +export * from './auth.types'; +export * from './entity.types'; +export * from './patterns.types'; +export * from './permissions.types'; +export * from './rest.types'; +export * from './util.types'; +export * from './ws.types'; diff --git a/frontend/src/types/lib/main.js b/frontend/src/types/lib/main.js new file mode 100644 index 00000000..299b6796 --- /dev/null +++ b/frontend/src/types/lib/main.js @@ -0,0 +1,24 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./auth.types"), exports); +__exportStar(require("./entity.types"), exports); +__exportStar(require("./patterns.types"), exports); +__exportStar(require("./permissions.types"), exports); +__exportStar(require("./rest.types"), exports); +__exportStar(require("./util.types"), exports); +__exportStar(require("./ws.types"), exports); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9tYWluLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSwrQ0FBNkI7QUFDN0IsaURBQStCO0FBQy9CLG1EQUFpQztBQUNqQyxzREFBb0M7QUFDcEMsK0NBQTZCO0FBQzdCLCtDQUE2QjtBQUM3Qiw2Q0FBMkIifQ== \ No newline at end of file diff --git a/frontend/src/types/lib/patterns.types.d.ts b/frontend/src/types/lib/patterns.types.d.ts new file mode 100644 index 00000000..187f1a4a --- /dev/null +++ b/frontend/src/types/lib/patterns.types.d.ts @@ -0,0 +1,11 @@ +export declare const patterns: { + email: RegExp; + hexColor: RegExp; + password: RegExp; + snowflake: RegExp; + status: RegExp; + textChannelName: RegExp; + username: RegExp; + roleName: RegExp; + url: RegExp; +}; diff --git a/frontend/src/types/lib/patterns.types.js b/frontend/src/types/lib/patterns.types.js new file mode 100644 index 00000000..0cdc29a5 --- /dev/null +++ b/frontend/src/types/lib/patterns.types.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.patterns = void 0; +exports.patterns = { + email: /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/, + hexColor: /^#(?:[0-9a-fA-F]{3}){1,2}$/, + password: /(?=.*[a-zA-Z0-9!@#$%^&*])/, + snowflake: /^\d{18}$/, + status: /^ONLINE|^BUSY$|^AFK$|^OFFLINE$/, + textChannelName: /^[A-Za-z\-\d]{2,32}$/, + username: /(^(?! |^everyone$|^here$|^me$|^someone$)[A-Za-z\d\-\_ ]{2,32}(? Number.isInteger(+v)) + .find(([k, v]) => k === integer || v === integer)) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '' + : integer.toString(); +} +exports.getPermString = getPermString; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGVybWlzc2lvbnMudHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvcGVybWlzc2lvbnMudHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLG9EQUFvRDs7O0FBRXBELElBQWlCLGVBQWUsQ0E0Qy9CO0FBNUNELFdBQWlCLGVBQWU7SUFDOUIsSUFBWSxPQWFYO0lBYkQsV0FBWSxPQUFPO1FBQ2pCLDBEQUFvQixDQUFBO1FBQ3BCLDJDQUEyQztRQUMzQywwQ0FBMEM7UUFDMUMsMkRBQW9CLENBQUE7UUFDcEIseURBQW1CLENBQUE7UUFDbkIsc0RBQWlCLENBQUE7UUFDakIscUNBQXFDO1FBQ3JDLDREQUFvQixDQUFBO1FBQ3BCLHFEQUFnQixDQUFBO1FBQ2hCLHFEQUFnQixDQUFBO1FBQ2hCLHVDQUF1QztRQUN2Qyx1REFBaUIsQ0FBQTtJQUNuQixDQUFDLEVBYlcsT0FBTyxHQUFQLHVCQUFPLEtBQVAsdUJBQU8sUUFhbEI7SUFDRCxJQUFZLElBTVg7SUFORCxXQUFZLElBQUk7UUFDZCw2QkFBNkI7UUFDN0IsK0JBQStCO1FBQy9CLG9EQUF3QixDQUFBO1FBQ3hCLHdEQUEwQixDQUFBO1FBQzFCLG9EQUFvQixDQUFBO0lBQ3RCLENBQUMsRUFOVyxJQUFJLEdBQUosb0JBQUksS0FBSixvQkFBSSxRQU1mO0lBQ0QsSUFBWSxLQUtYO0lBTEQsV0FBWSxLQUFLO1FBQ2Ysc0RBQXdCLENBQUE7UUFDeEIsc0RBQXdCLENBQUE7UUFDeEIsdUNBQWlCLENBQUE7UUFDakIsMkNBQWUsQ0FBQTtJQUNqQixDQUFDLEVBTFcsS0FBSyxHQUFMLHFCQUFLLEtBQUwscUJBQUssUUFLaEI7SUFDWSxtQkFBRyxpREFDWCxPQUFPLEdBQ1AsSUFBSSxHQUNKLEtBQUssQ0FDVCxDQUFBO0lBSVksa0NBQWtCLEdBQzdCLGVBQWUsQ0FBQyxPQUFPLENBQUMsYUFBYTtVQUNuQyxlQUFlLENBQUMsT0FBTyxDQUFDLGFBQWE7VUFDckMsZUFBZSxDQUFDLElBQUksQ0FBQyxhQUFhO1VBQ2xDLGVBQWUsQ0FBQyxJQUFJLENBQUMsYUFBYTtRQUNwQyx1Q0FBdUM7VUFDckMsZUFBZSxDQUFDLEtBQUssQ0FBQyxPQUFPO1VBQzdCLGVBQWUsQ0FBQyxLQUFLLENBQUMsS0FBSyxDQUFDO0FBQ2xDLENBQUMsRUE1Q2dCLGVBQWUsR0FBZix1QkFBZSxLQUFmLHVCQUFlLFFBNEMvQjtBQUVELFNBQWdCLGFBQWEsQ0FBQyxPQUF3Qjs7SUFDcEQsT0FBTyxDQUFDLE9BQU8sT0FBTyxLQUFLLFFBQVEsQ0FBQztRQUNsQyxDQUFDLENBQUMsTUFBQSxNQUFBLE1BQU07YUFDTCxPQUFPLENBQUMsZUFBZSxDQUFDLEdBQUcsQ0FBQzthQUM1QixNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsRUFBRSxFQUFFLENBQUMsTUFBTSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO2FBQ3hDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FBQyxFQUFFLEVBQUUsQ0FBQyxDQUFDLEtBQUssT0FBTyxJQUFJLENBQUMsS0FBSyxPQUFPLENBQUMsMENBQUcsQ0FBQyxDQUFDLG1DQUFJLEVBQUU7UUFDOUQsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxRQUFRLEVBQUUsQ0FBQztBQUN6QixDQUFDO0FBUEQsc0NBT0MifQ== \ No newline at end of file diff --git a/frontend/src/types/lib/rest.types.d.ts b/frontend/src/types/lib/rest.types.d.ts new file mode 100644 index 00000000..6f206c7e --- /dev/null +++ b/frontend/src/types/lib/rest.types.d.ts @@ -0,0 +1,56 @@ +import { Entity } from './entity.types'; +export declare namespace REST { + namespace To { + interface Post { + '/auth/login': { + email: string; + password: string; + }; + '/auth/register': { + email: string; + username: string; + password: string; + }; + '/auth/change-password': { + email: string; + oldPassword: string; + newPassword: string; + }; + '/themes': Entity.Theme; + } + } + namespace From { + interface Get { + '/channels/:channelId/messages': { + channelId: string; + list: Entity.Message[]; + total: number; + }; + '/users/entities': { + channels: Entity.Channel[]; + guilds: Entity.Guild[]; + members: Entity.GuildMember[]; + roles: Entity.Role[]; + themes: Entity.Theme[]; + users: Entity.User[]; + }; + '/auth/email/verify-email': { + message?: 'Email sent'; + }; + '/auth/verify': { + token?: string; + message?: 'Email verified' | 'Password reset'; + }; + } + interface Post { + '/upload': { + url: string; + hash: string; + }; + '/auth/change-password': { + message: string; + token: string; + }; + } + } +} diff --git a/frontend/src/types/lib/rest.types.js b/frontend/src/types/lib/rest.types.js new file mode 100644 index 00000000..c6575d7d --- /dev/null +++ b/frontend/src/types/lib/rest.types.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVzdC50eXBlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9yZXN0LnR5cGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ== \ No newline at end of file diff --git a/frontend/src/types/lib/util.types.d.ts b/frontend/src/types/lib/util.types.d.ts new file mode 100644 index 00000000..95f8da67 --- /dev/null +++ b/frontend/src/types/lib/util.types.d.ts @@ -0,0 +1,5 @@ +export declare namespace Util { + interface Dictionary { + [k: string]: string; + } +} diff --git a/frontend/src/types/lib/util.types.js b/frontend/src/types/lib/util.types.js new file mode 100644 index 00000000..1142f0da --- /dev/null +++ b/frontend/src/types/lib/util.types.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC50eXBlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy91dGlsLnR5cGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ== \ No newline at end of file diff --git a/frontend/src/types/lib/ws.types.d.ts b/frontend/src/types/lib/ws.types.d.ts new file mode 100644 index 00000000..f3470e6c --- /dev/null +++ b/frontend/src/types/lib/ws.types.d.ts @@ -0,0 +1,383 @@ +import { Entity, ChannelTypes, InviteTypes, MessageTypes, UserTypes } from './entity.types'; +export declare namespace WS { + interface To { + /** Create a channel in a guild. */ + 'CHANNEL_CREATE': Params.ChannelCreate; + /** Delete a channel in a guild. */ + 'CHANNEL_DELETE': Params.ChannelDelete; + /** Update a channel in a guild. */ + 'CHANNEL_UPDATE': Params.ChannelUpdate; + /** Join a voice channel and receive voice events. */ + 'CHANNEL_JOIN': Params.ChannelJoin; + /** Leave the voice channel that the client is in. */ + 'CHANNEL_LEAVE': Params.ChannelLeave; + /** Create a guild. */ + 'GUILD_CREATE': Params.GuildCreate; + /** Delete a guild. */ + 'GUILD_DELETE': Params.GuildDelete; + /** Accept a guild invite. */ + 'GUILD_MEMBER_ADD': Params.GuildMemberAdd; + /** Remove a member from a guild. */ + 'GUILD_MEMBER_REMOVE': Params.GuildMemberRemove; + /** Update a members roles or other properties on a member. */ + 'GUILD_MEMBER_UPDATE': Params.GuildMemberUpdate; + /** Create a role in a guild. */ + 'GUILD_ROLE_CREATE': Params.GuildRoleCreate; + /** Delete a role in a guild. */ + 'GUILD_ROLE_DELETE': Params.GuildRoleDelete; + /** Update a guild role permissions or other properties. */ + 'GUILD_ROLE_UPDATE': Params.GuildRoleUpdate; + /** Update the settings of a guild. */ + 'GUILD_UPDATE': Params.GuildUpdate; + /** Create an invite in a guild */ + 'INVITE_CREATE': Params.InviteCreate; + /** Delete an existing invite in a guild. */ + 'INVITE_DELETE': Params.InviteDelete; + /** Create a message in a text-based channel. */ + 'MESSAGE_CREATE': Params.MessageCreate; + /** Delete an existing message in a text-based channel. */ + 'MESSAGE_DELETE': Params.MessageDelete; + /** Update an existing message in a text-based channel. */ + 'MESSAGE_UPDATE': Params.MessageUpdate; + /** Bootstrap your websocket client to be able to use other websocket events. + * - Associate ws client ID with user ID. + * - Join user rooms. + * - Set online status. */ + 'READY': Params.Ready; + /** Indicate that you are typing in a text-based channel. */ + 'TYPING_START': Params.TypingStart; + /** Delete a user with a given token. */ + 'USER_DELETE': Params.UserDelete; + /** Update a user with a given token. */ + 'USER_UPDATE': Params.UserUpdate; + /** Send voice data to the server. */ + 'VOICE_DATA': Params.VoiceData; + } + interface On { + /** Manually disconnect from the websocket; logout. */ + 'disconnect': any; + } + /** WS Args are what is received from the websocket. */ + interface From { + /** Called when a guild channel is created. */ + 'CHANNEL_CREATE': Args.ChannelCreate; + /** Called when a guild channel is deleted. */ + 'CHANNEL_DELETE': Args.ChannelDelete; + /** Called when a guild channel is updated. */ + 'CHANNEL_UPDATE': Args.ChannelUpdate; + /** Called when a guild is deleted, or the client leaves a guild. */ + 'GUILD_DELETE': Args.GuildDelete; + /** Called when the client joins a guild. */ + 'GUILD_CREATE': Args.GuildCreate; + /** Called when someone joins a guild by an invite, a bot is added, or the client joins guild. */ + 'GUILD_MEMBER_ADD': Args.GuildMemberAdd; + /** Called when a guild member is removed, or leaves the guild. */ + 'GUILD_MEMBER_REMOVE': Args.GuildMemberRemove; + /** Called when member roles are updated, or other properties. */ + 'GUILD_MEMBER_UPDATE': Args.GuildMemberUpdate; + /** Called when a guild role is created. */ + 'GUILD_ROLE_CREATE': Args.GuildRoleCreate; + /** Called when a guild role is deleted. */ + 'GUILD_ROLE_DELETE': Args.GuildRoleDelete; + /** Called when properties on a guild role are updated. */ + 'GUILD_ROLE_UPDATE': Args.GuildRoleUpdate; + /** Called when guild settings are updated. */ + 'GUILD_UPDATE': Args.GuildUpdate; + /** Called when a guild invite is created. */ + 'INVITE_CREATE': Args.InviteCreate; + /** Called when an existing guild invite is deleted. */ + 'INVITE_DELETE': Args.InviteDelete; + /** Called when a message is created in a text-based channel. */ + 'MESSAGE_CREATE': Args.MessageCreate; + /** Called when a message is deleted in a text-based channel. */ + 'MESSAGE_DELETE': Args.MessageDelete; + /** Called when an existing message is updated in a text-based channel. */ + 'MESSAGE_UPDATE': Args.MessageUpdate; + /** Called when a message is sent in a channel you are not ignoring. */ + 'PING': Args.Ping; + /** Called when a user goes online or offline. */ + 'PRESENCE_UPDATE': Args.PresenceUpdate; + /** Called when the websocket accepts that you are ready. */ + 'READY': Args.Ready; + /** Called when someone is typing in a text-based channel. */ + 'TYPING_START': Args.TypingStart; + /** Called the client user is deleted. */ + 'USER_DELETE': {}; + /** Called the client user settings are updated. */ + 'USER_UPDATE': Args.UserUpdate; + /** Receive voice data from the server. */ + 'VOICE_DATA': Args.VoiceData; + /** Called when a user voice state is updated in the client's voice channel. */ + 'VOICE_STATE_UPDATE': Args.VoiceStateUpdate; + 'error': object; + } + namespace Params { + interface AddFriend { + /** Username of user (case insensitive). */ + username: string; + } + interface ChannelCreate { + /** The guild ID that the channel should be created in. */ + guildId: string; + /** Name of the channel to create. */ + name: string; + /** Type of the channel to create. */ + type: ChannelTypes.Type; + } + interface ChannelDelete { + /** ID of the channel to delete. */ + channelId: string; + /** ID of the guild that the channel was in. */ + guildId: string; + } + interface ChannelUpdate { + /** ID of the channel to update. */ + channelId: string; + summary?: string; + name?: string; + overrides?: ChannelTypes.Override[]; + position?: number; + } + interface ChannelJoin { + /** ID of the channel to join. */ + channelId: string; + } + interface ChannelLeave { + } + interface GuildCreate { + /** Name of the guild. */ + name: string; + } + interface GuildDelete { + guildId: string; + } + interface GuildMemberAdd { + inviteCode: string; + } + interface GuildMemberRemove { + /** ID of the guild. */ + guildId: string; + /** ID of the user to kick. */ + userId: string; + } + interface GuildMemberUpdate { + /** ID of the member, not the same as a user ID. */ + memberId: string; + /** List of role IDs to update. */ + roleIds?: string[]; + } + interface GuildRoleCreate { + guildId: string; + } + interface GuildRoleDelete { + roleId: string; + guildId: string; + } + interface GuildRoleUpdate { + roleId: string; + guildId: string; + color?: string; + name?: string; + permissions?: number; + hoisted?: boolean; + } + interface GuildUpdate { + guildId: string; + name?: string; + iconURL?: string; + systemChannelId?: string; + } + interface InviteCreate { + guildId: string; + options: InviteTypes.Options; + } + interface InviteDelete { + inviteCode: string; + } + interface MessageCreate { + channelId: string; + content?: string; + attachmentURLs?: string[]; + embed?: MessageTypes.Embed; + } + interface MessageDelete { + messageId: string; + } + interface MessageUpdate { + messageId: string; + content?: string; + embed?: MessageTypes.Embed; + } + interface MessageCreate { + content?: string; + } + interface Ready { + token: string; + } + interface RemoveFriend { + friendId: string; + } + interface TypingStart { + channelId: string; + } + interface UserDelete { + token: string; + } + interface UserUpdate { + /** Token granted on login. Required to update user. */ + activeThemeId?: string; + avatarURL?: string; + email?: string; + ignored?: UserTypes.Self['ignored']; + token: string; + username?: string; + } + interface VoiceData { + channelId: string; + blob?: any; + } + } + namespace Args { + interface ChannelCreate { + /** ID of guild that the channel is in. */ + guildId: string; + /** The full object fo the channel that was created. */ + channel: Entity.Channel; + /** ID of the user that created the channel. */ + creatorId: string; + } + interface ChannelDelete { + /** ID of guild that the channel is in. */ + guildId: string; + /** The ID of the channel that is deleted. */ + channelId: string; + } + interface ChannelUpdate { + /** ID of the guild that the channel is in. */ + channelId: string; + /** Properties to update a guild. */ + partialChannel: Partial; + } + interface GuildCreate { + /** The full object of the guild that was joined. */ + guild: Entity.Guild; + /** Channels associated with guild. */ + channels: Entity.Channel[]; + /** Roles associated with guild. */ + roles: Entity.Role[]; + /** Guild members associated with guild. */ + members: Entity.GuildMember[]; + /** Users associated with guild. */ + users: Entity.User[]; + } + interface GuildDelete { + /** ID of the guild that was left. */ + guildId: string; + } + /** Called when a member accepts an invite, or a bot was added to a guild. */ + interface GuildMemberAdd { + /** ID of the guild. */ + guildId: string; + /** Full object of the member that was added to the guild. */ + member: Entity.GuildMember; + /** Full object of the member that was added to the guild. */ + user: Entity.User; + } + interface GuildMemberRemove { + /** ID of the member. */ + memberId: string; + } + interface GuildMemberUpdate { + /** Properties of updated guild member. */ + partialMember: Partial; + /** ID of the guild member. Not the same as a user ID. */ + memberId: string; + } + interface GuildRoleCreate { + /** ID of the guild. */ + guildId: string; + /** Full object of the role that was created. */ + role: Entity.Role; + } + interface GuildRoleDelete { + /** ID of the guild. */ + guildId: string; + /** The ID of the role that was deleted. */ + roleId: string; + } + interface GuildRoleUpdate { + /** Guild ID associated with role. */ + guildId: string; + /** Properties to update the role. */ + partialRole: Partial; + /** The ID of the role that was updated. */ + roleId: string; + } + interface GuildUpdate { + /** ID of the guild. */ + guildId: string; + /** Properties to update a guild. */ + partialGuild: Partial; + } + interface InviteCreate { + /** ID of the guild. */ + guildId: string; + /** Full object of the invite. */ + invite: Entity.Invite; + } + /** Called when a guild invite is delted. */ + interface InviteDelete { + /** ID of the guild. */ + guildId: string; + /** The ID or the code of the invite. */ + inviteCode: string; + } + interface MessageCreate { + /** Full object of the message that was created. */ + message: Entity.Message; + } + interface MessageDelete { + /** ID of the channel with the message. */ + channelId: string; + /** The ID of the message that was deleted. */ + messageId: string; + } + interface MessageUpdate { + /** ID of the message that was updated. */ + messageId: string; + /** Objects with updated properties from the updated message. */ + partialMessage: Entity.Message; + } + interface Ping { + channelId: string; + guildId?: string; + } + interface PresenceUpdate { + userId: string; + status: UserTypes.StatusType; + } + interface Ready { + user: UserTypes.Self; + } + interface TypingStart { + channelId: string; + userId: string; + } + interface UserDelete { + userId: string; + } + /** PRIVATE - contains private data */ + interface UserUpdate { + userId: string; + partialUser: Partial; + } + interface VoiceData { + channelId: string; + connections: ChannelTypes.VoiceConnection[]; + } + interface VoiceStateUpdate { + userId: string; + voice: UserTypes.VoiceState; + } + } +} diff --git a/frontend/src/types/lib/ws.types.js b/frontend/src/types/lib/ws.types.js new file mode 100644 index 00000000..55fe811c --- /dev/null +++ b/frontend/src/types/lib/ws.types.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid3MudHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvd3MudHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file