refactor: separate api types (#71)

* refactor: better api types boundaries

* fix: fmt
This commit is contained in:
Yuzu 2022-07-18 21:18:10 +00:00 committed by GitHub
parent aff4bf2e92
commit 47d20cb6e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 44 additions and 48 deletions

2
mod.ts
View File

@ -5,4 +5,6 @@ export default Session;
export * from './packages/biscuit/mod.ts';
export * from './packages/discordeno/mod.ts';
export * from './packages/cache/mod.ts';
export * from './packages/api-types/discord.ts';
export * from './packages/api-types/shared.ts';
export { default as enableCache } from './packages/cache/mod.ts';

View File

@ -438,7 +438,7 @@ export interface GetWidget {
* /guilds/{guildId}/widget
* @link https://discord.com/developers/docs/resources/guild#get-guild-widget-settings
*/
export function GUILD_WIDGET(guildId: Snowflake, options: GetWidget = {get: 'settings'}): string {
export function GUILD_WIDGET(guildId: Snowflake, options: GetWidget = { get: 'settings' }): string {
let url = `/guilds/${guildId}/widget`;
if (options.get === 'json') {
url += '.json';
@ -446,5 +446,5 @@ export function GUILD_WIDGET(guildId: Snowflake, options: GetWidget = {get: 'set
url += '.png';
}
return url
return url;
}

View File

@ -33,7 +33,7 @@ import ThreadMember from './ThreadMember.ts';
/**
* Abstract class that represents the base for creating a new channel.
*/
*/
export abstract class BaseChannel implements Model {
constructor(session: Session, data: DiscordChannel) {
this.id = data.id;
@ -93,7 +93,7 @@ export abstract class BaseChannel implements Model {
/**
* @link https://discord.com/developers/docs/resources/channel#create-channel-invite-json-params
* Represents the options object to create an invitation
*/
*/
export interface DiscordInviteOptions {
/** duration of invite in seconds before expiry, or 0 for never. between 0 and 604800 (7 days) */
maxAge?: number;
@ -122,7 +122,7 @@ export interface CreateWebhook {
}
/** Available text-channel-types list */
export const textBasedChannels:ChannelTypes[] = [
export const textBasedChannels: ChannelTypes[] = [
ChannelTypes.DM,
ChannelTypes.GroupDm,
ChannelTypes.GuildPrivateThread,

View File

@ -1,5 +1,5 @@
import { DiscordGatewayPayload } from '../../types/discord.ts';
import { GatewayBot, PickPartial } from '../../types/shared.ts';
import { DiscordGatewayPayload } from '../../../api-types/discord.ts';
import { GatewayBot, PickPartial } from '../../../api-types/shared.ts';
import { LeakyBucket } from '../../util/bucket.ts';
import { CreateShard, createShard } from '../shard/createShard.ts';
import { Shard, ShardGatewayConfig } from '../shard/types.ts';

View File

@ -1,5 +1,5 @@
import { DiscordGatewayPayload } from '../../types/discord.ts';
import { PickPartial } from '../../types/shared.ts';
import { DiscordGatewayPayload } from '../../../api-types/discord.ts';
import { PickPartial } from '../../../api-types/shared.ts';
import { CreateShard, createShard } from '../shard/createShard.ts';
import { Shard, ShardGatewayConfig } from '../shard/types.ts';

View File

@ -1,4 +1,4 @@
import { GatewayIntents } from '../../types/shared.ts';
import { GatewayIntents } from '../../../api-types/shared.ts';
import { createLeakyBucket } from '../../util/bucket.ts';
import { createShard } from '../shard/createShard.ts';
import { Shard } from '../shard/types.ts';

View File

@ -1,4 +1,4 @@
import { GatewayIntents } from '../../types/shared.ts';
import { GatewayIntents } from '../../../api-types/shared.ts';
import { createShard } from '../shard/createShard.ts';
import { GatewayManager } from './gatewayManager.ts';

View File

@ -23,8 +23,8 @@ import { connect } from './connect.ts';
import { close } from './close.ts';
import { shutdown } from './shutdown.ts';
import { isOpen } from './isOpen.ts';
import { DiscordGatewayPayload, DiscordStatusUpdate } from '../../types/discord.ts';
import { GatewayIntents, PickPartial } from '../../types/shared.ts';
import { DiscordGatewayPayload, DiscordStatusUpdate } from '../../../api-types/discord.ts';
import { GatewayIntents, PickPartial } from '../../../api-types/shared.ts';
import { API_VERSION } from '../../util/constants.ts';
// TODO: debug

View File

@ -1,4 +1,4 @@
import { GatewayCloseEventCodes } from '../../types/shared.ts';
import { GatewayCloseEventCodes } from '../../../api-types/shared.ts';
import { Shard, ShardSocketCloseCodes, ShardState } from './types.ts';
export async function handleClose(shard: Shard, close: CloseEvent): Promise<void> {

View File

@ -1,5 +1,5 @@
import { DiscordGatewayPayload, DiscordHello, DiscordReady } from '../../types/discord.ts';
import { GatewayOpcodes } from '../../types/shared.ts';
import { DiscordGatewayPayload, DiscordHello, DiscordReady } from '../../../api-types/discord.ts';
import { GatewayOpcodes } from '../../../api-types/shared.ts';
import { createLeakyBucket } from '../../util/bucket.ts';
import { delay } from '../../util/delay.ts';
import { decompressWith } from './deps.ts';

View File

@ -1,4 +1,4 @@
import { GatewayOpcodes } from '../../types/shared.ts';
import { GatewayOpcodes } from '../../../api-types/shared.ts';
import { Shard, ShardSocketCloseCodes, ShardState } from './types.ts';
export async function identify(shard: Shard): Promise<void> {

View File

@ -1,4 +1,4 @@
import { GatewayOpcodes } from '../../types/shared.ts';
import { GatewayOpcodes } from '../../../api-types/shared.ts';
import { Shard, ShardSocketCloseCodes, ShardState } from './types.ts';
export async function resume(shard: Shard): Promise<void> {

View File

@ -1,4 +1,4 @@
import { GatewayOpcodes } from '../../types/shared.ts';
import { GatewayOpcodes } from '../../../api-types/shared.ts';
import { Shard, ShardSocketCloseCodes, ShardState } from './types.ts';
export function startHeartbeating(shard: Shard, interval: number) {

View File

@ -1,5 +1,5 @@
import { DiscordGatewayPayload } from '../../types/discord.ts';
import { GatewayOpcodes } from '../../types/shared.ts';
import { DiscordGatewayPayload } from '../../../api-types/discord.ts';
import { GatewayOpcodes } from '../../../api-types/shared.ts';
import { createShard } from './createShard.ts';
// TODO: think whether we also need an identifiedShard function

View File

@ -1,5 +1,6 @@
export * from './gateway/mod.ts';
export * from './rest/mod.ts';
export * from './types/mod.ts';
export * from './util/constants.ts';
export * from './util/token.ts';
export * from '../api-types/discord.ts';
export * from '../api-types/shared.ts';

View File

@ -1,5 +1,5 @@
import { RestManager } from './restManager.ts';
import { FileContent } from '../types/shared.ts';
import { FileContent } from '../../api-types/shared.ts';
import { USER_AGENT } from '../util/constants.ts';
import { RequestMethod, RestPayload, RestRequest } from './rest.ts';

View File

@ -1,5 +1,5 @@
import { RestManager } from './restManager.ts';
import { HTTPResponseCodes } from '../types/shared.ts';
import { HTTPResponseCodes } from '../../api-types/shared.ts';
export async function processGlobalQueue(rest: RestManager) {
// IF QUEUE IS EMPTY EXIT

View File

@ -1,4 +1,4 @@
import { HTTPResponseCodes } from '../types/shared.ts';
import { HTTPResponseCodes } from '../../api-types/shared.ts';
import { BASE_URL } from '../util/constants.ts';
import { RequestMethod } from './rest.ts';
import { RestManager } from './restManager.ts';

View File

@ -1,2 +0,0 @@
export * from './discord.ts';
export * from './shared.ts';

View File

@ -1,4 +1,4 @@
import { PickPartial } from '../types/shared.ts';
import { PickPartial } from '../../api-types/shared.ts';
import { delay } from './delay.ts';
/** A Leaky Bucket.

View File

@ -1,5 +0,0 @@
export * from './bucket.ts';
export * from './collection.ts';
export * from './constants.ts';
export * from './delay.ts';
export * from './token.ts';