From d3e2872a615ba14ff24862c0405d1712762ecfdc Mon Sep 17 00:00:00 2001 From: Jaren Goldberg Date: Mon, 2 Jun 2025 21:49:55 -0400 Subject: [PATCH 1/2] WIP on dev --- src/payloads/Channel.ts | 2 +- src/rest/Channel.ts | 5 ----- src/rest/Guild.ts | 15 +++++++++++---- src/rest/User.ts | 6 ++++++ src/utils/base.ts | 9 ++++----- src/utils/codes.ts | 37 ------------------------------------- 6 files changed, 22 insertions(+), 52 deletions(-) delete mode 100644 src/utils/codes.ts diff --git a/src/payloads/Channel.ts b/src/payloads/Channel.ts index 810af77..48b458b 100644 --- a/src/payloads/Channel.ts +++ b/src/payloads/Channel.ts @@ -73,7 +73,7 @@ export interface CountingChannelConfig { /** * The counting mode */ - mode: CountingMode; + mode: string; } export interface CountingChannelNotifications { diff --git a/src/rest/Channel.ts b/src/rest/Channel.ts index f7c3fb0..d29b877 100644 --- a/src/rest/Channel.ts +++ b/src/rest/Channel.ts @@ -31,8 +31,3 @@ export interface RESTGetAPICountingChannel extends BaseAuthRouteOptions extends BaseAuthRouteOptions[]> { - Querystring: { - page?: number; - }; -} diff --git a/src/rest/Guild.ts b/src/rest/Guild.ts index 812dab0..cc9e5a5 100644 --- a/src/rest/Guild.ts +++ b/src/rest/Guild.ts @@ -1,19 +1,26 @@ +import { APICountingChannel } from '../payloads/Channel.js'; import type { APICountingGuild } from '../payloads/Guild.js'; import type { BaseAuthRouteOptions, LanguageCode } from '../utils/index.js'; -export interface RESTGetAPIGuilds extends BaseAuthRouteOptions | null> { +export interface RESTGetAPICountingGuilds extends BaseAuthRouteOptions | null> { Querystring: { guildId?: string; }; } -export interface RESTGetAPIGuild extends BaseAuthRouteOptions | null> { +export interface RESTGetAPICountingGuild extends BaseAuthRouteOptions | null> { Params: { guildId: string; }; } -export interface RESTPatchAPIGuild extends BaseAuthRouteOptions | null> { +export interface RESTGetAPICountingGuildChannels extends BaseAuthRouteOptions[] | null> { + Params: { + guildId: string; + }; +} + +export interface RESTPatchAPICountingGuild extends BaseAuthRouteOptions | null> { Params: { guildId: string; }; @@ -22,7 +29,7 @@ export interface RESTPatchAPIGuild extends BaseAuthRouteOptions extends BaseAuthRouteOptions | null> { +export interface RESTPostAPICountingGuild extends BaseAuthRouteOptions> { Body: { guildId: string; }; diff --git a/src/rest/User.ts b/src/rest/User.ts index 86069a3..ea52803 100644 --- a/src/rest/User.ts +++ b/src/rest/User.ts @@ -14,6 +14,12 @@ export interface RESTGetAPICountingUser extends BaseAuthRouteOptions extends BaseAuthRouteOptions> { + Body: { + userId: string; + }; +} + export interface RESTGetAPICountingUserLeaderboard extends BaseAuthRouteOptions[]> { Querystring: { page?: number; diff --git a/src/utils/base.ts b/src/utils/base.ts index 48711b0..711015c 100644 --- a/src/utils/base.ts +++ b/src/utils/base.ts @@ -1,12 +1,11 @@ -import type { StatusCodePhrases } from './codes.js'; - -export interface BaseAuthRouteOptions { +export interface BaseAuthRouteOptions { Header: { Authorization: string; }; Reply: { error: boolean; - message: StatusCodePhrases; - data: Response; + message: string; + code?: C; + data?: R; }; } diff --git a/src/utils/codes.ts b/src/utils/codes.ts deleted file mode 100644 index b23ee26..0000000 --- a/src/utils/codes.ts +++ /dev/null @@ -1,37 +0,0 @@ -export enum StatusCodePhrases { - Ok = 'Ok', - BadRequest = 'BadRequest', - NotFound = 'NotFound', - ChannelCreated = 'ChannelCreated', - ChannelFound = 'ChannelFound', - ChannelNotFound = 'ChannelNotFound', - ChannelUpdated = 'ChannelUpdated', - ChannelAlreadyExists = 'ChannelAlreadyExists', - GuildAlreadyExists = 'GuildAlreadyExists', - GuildCreated = 'GuildCreated', - GuildFound = 'GuildFound', - GuildNotFound = 'GuildNotFound', - GuildUpdated = 'GuildUpdated', - UserAlreadyExists = 'UserAlreadyExists', - UserCreated = 'UserCreated', - UserFound = 'UserFound', - UserNotFound = 'UserNotFound', - UserUpdated = 'UserUpdated', - RouteNotFound = 'RouteNotFound', - MethodNotAllowed = 'MethodNotAllowed', - Forbidden = 'Forbidden', - Unauthorized = 'Unauthorized', - InternalServerError = 'InternalServerError', - SummaryFound = 'SummaryFound', - SummaryNotFound = 'SummaryNotFound', - InvalidObjectId = 'InvalidObjectId', - PremiumGuildActivated = 'PremiumGuildActivated', - PremiumGuildCancelled = 'PremiumGuildCancelled', - PremiumGuildLifetimeActivated = 'PremiumGuildLifetimeActivated', - PremiumOnly = 'PremiumOnly', - ChannelLeaderboardFound = 'ChannelLeaderboardFound', - UserLeaderboardFound = 'UserLeaderboardFound', - TokenCreated = 'TokenCreated', - TooManyRequests = 'TooManyRequests', - VoteSuccess = 'VoteSuccess', -} From 69ca42b1063628cf4b01d55c5997637a63487ada Mon Sep 17 00:00:00 2001 From: Jaren Goldberg Date: Tue, 3 Jun 2025 19:50:52 -0400 Subject: [PATCH 2/2] V2 Remove rest --- package.json | 2 +- src/index.ts | 1 - src/payloads/Channel.ts | 17 +++++++++- src/payloads/ChannelModifiers.ts | 2 +- src/payloads/UserModifiers.ts | 2 +- src/rest/Channel.ts | 33 ------------------- src/rest/ChannelModifiers.ts | 8 ----- src/rest/Guild.ts | 36 --------------------- src/rest/Status.ts | 4 --- src/rest/Summary.ts | 9 ------ src/rest/User.ts | 33 ------------------- src/rest/UserModifiers.ts | 8 ----- src/rest/index.ts | 7 ---- src/utils/{modifiers.ts => BaseModifier.ts} | 0 src/utils/BaseReply.ts | 5 +++ src/utils/{languages.ts => LanguageCode.ts} | 0 src/utils/ResponseCodes.ts | 22 +++++++++++++ src/utils/base.ts | 11 ------- src/utils/index.ts | 8 ++--- 19 files changed, 50 insertions(+), 158 deletions(-) delete mode 100644 src/rest/Channel.ts delete mode 100644 src/rest/ChannelModifiers.ts delete mode 100644 src/rest/Guild.ts delete mode 100644 src/rest/Status.ts delete mode 100644 src/rest/Summary.ts delete mode 100644 src/rest/User.ts delete mode 100644 src/rest/UserModifiers.ts delete mode 100644 src/rest/index.ts rename src/utils/{modifiers.ts => BaseModifier.ts} (100%) create mode 100644 src/utils/BaseReply.ts rename src/utils/{languages.ts => LanguageCode.ts} (100%) create mode 100644 src/utils/ResponseCodes.ts delete mode 100644 src/utils/base.ts diff --git a/package.json b/package.json index 1495fea..2bbfb22 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@countbot/countbot-api-types", - "version": "1.41.0", + "version": "2.0.0", "description": "API types for CountBot", "author": { "name": "CountBot", diff --git a/src/index.ts b/src/index.ts index da23cb4..0b9f8f9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,2 @@ export * from './payloads/index.js'; -export * from './rest/index.js'; export * from './utils/index.js'; diff --git a/src/payloads/Channel.ts b/src/payloads/Channel.ts index 48b458b..261a29e 100644 --- a/src/payloads/Channel.ts +++ b/src/payloads/Channel.ts @@ -1,4 +1,19 @@ -import type { CountingMode } from '../rest/Channel.js'; +export const CountingModes = [ + 'DEFAULT', + 'EVEN', + 'ODD', + 'THREE', + 'FOUR', + 'FIVE', + 'SIX', + 'SEVEN', + 'EIGHT', + 'NINE', + 'TEN', + 'PRIME', +] as const; + +export type CountingMode = (typeof CountingModes)[number]; export interface CountingChannelGoal { /** diff --git a/src/payloads/ChannelModifiers.ts b/src/payloads/ChannelModifiers.ts index 807db40..196a1f0 100644 --- a/src/payloads/ChannelModifiers.ts +++ b/src/payloads/ChannelModifiers.ts @@ -1,4 +1,4 @@ -import type { Modifiers } from '../utils/modifiers.js'; +import type { Modifiers } from '../utils/BaseModifier.js'; export interface APICountingChannelModifiers { /** diff --git a/src/payloads/UserModifiers.ts b/src/payloads/UserModifiers.ts index 09877a8..acb2f5d 100644 --- a/src/payloads/UserModifiers.ts +++ b/src/payloads/UserModifiers.ts @@ -1,4 +1,4 @@ -import type { Modifiers } from '../utils/modifiers.js'; +import type { Modifiers } from '../utils/BaseModifier.js'; export interface APICountingUserModifiers { /** diff --git a/src/rest/Channel.ts b/src/rest/Channel.ts deleted file mode 100644 index d29b877..0000000 --- a/src/rest/Channel.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { APICountingChannel } from '../payloads/Channel.js'; -import type { BaseAuthRouteOptions } from '../utils/base.js'; - -export const CountingModes = [ - 'DEFAULT', - 'EVEN', - 'ODD', - 'THREE', - 'FOUR', - 'FIVE', - 'SIX', - 'SEVEN', - 'EIGHT', - 'NINE', - 'TEN', - 'PRIME', -] as const; - -export type CountingMode = (typeof CountingModes)[number]; - -export interface RESTGetAPICountingChannels extends BaseAuthRouteOptions | null> { - Querystring: { - channelId?: string; - guildId?: string; - }; -} - -export interface RESTGetAPICountingChannel extends BaseAuthRouteOptions | null> { - Params: { - channelId: string; - }; -} - diff --git a/src/rest/ChannelModifiers.ts b/src/rest/ChannelModifiers.ts deleted file mode 100644 index e3f9e09..0000000 --- a/src/rest/ChannelModifiers.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { APICountingChannelModifiers } from '../payloads/ChannelModifiers.js'; -import { BaseAuthRouteOptions } from '../utils/base.js'; - -export interface RESTGetAPIChannelModifiers extends BaseAuthRouteOptions | null> { - Params: { - channelId: string; - }; -} diff --git a/src/rest/Guild.ts b/src/rest/Guild.ts deleted file mode 100644 index cc9e5a5..0000000 --- a/src/rest/Guild.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { APICountingChannel } from '../payloads/Channel.js'; -import type { APICountingGuild } from '../payloads/Guild.js'; -import type { BaseAuthRouteOptions, LanguageCode } from '../utils/index.js'; - -export interface RESTGetAPICountingGuilds extends BaseAuthRouteOptions | null> { - Querystring: { - guildId?: string; - }; -} - -export interface RESTGetAPICountingGuild extends BaseAuthRouteOptions | null> { - Params: { - guildId: string; - }; -} - -export interface RESTGetAPICountingGuildChannels extends BaseAuthRouteOptions[] | null> { - Params: { - guildId: string; - }; -} - -export interface RESTPatchAPICountingGuild extends BaseAuthRouteOptions | null> { - Params: { - guildId: string; - }; - Body: { - language?: LanguageCode; - }; -} - -export interface RESTPostAPICountingGuild extends BaseAuthRouteOptions> { - Body: { - guildId: string; - }; -} diff --git a/src/rest/Status.ts b/src/rest/Status.ts deleted file mode 100644 index 20a8a56..0000000 --- a/src/rest/Status.ts +++ /dev/null @@ -1,4 +0,0 @@ -import type { APIStatus } from '../payloads/Status.js'; -import type { BaseAuthRouteOptions } from '../utils/base.js'; - -export type RESTGetAPIStatus = BaseAuthRouteOptions; diff --git a/src/rest/Summary.ts b/src/rest/Summary.ts deleted file mode 100644 index ca934ac..0000000 --- a/src/rest/Summary.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { APICountingSummary } from '../payloads/Summary.js'; -import type { BaseAuthRouteOptions } from '../utils/base.js'; - -export type RESTGetAPISummaries = BaseAuthRouteOptions[] | null>; -export interface RESTGetAPIDailySummary extends BaseAuthRouteOptions | null> { - Params: { - summaryId: string; - }; -} diff --git a/src/rest/User.ts b/src/rest/User.ts deleted file mode 100644 index ea52803..0000000 --- a/src/rest/User.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { APIAchievement } from '../payloads/Achievement.js'; -import type { APICountingUser } from '../payloads/User.js'; -import type { BaseAuthRouteOptions } from '../utils/base.js'; - -export interface RESTGetAPICountingUsers extends BaseAuthRouteOptions | null> { - Querystring: { - userId?: string; - }; -} - -export interface RESTGetAPICountingUser extends BaseAuthRouteOptions | null> { - Params: { - userId: string; - }; -} - -export interface RESTPostAPICountingUser extends BaseAuthRouteOptions> { - Body: { - userId: string; - }; -} - -export interface RESTGetAPICountingUserLeaderboard extends BaseAuthRouteOptions[]> { - Querystring: { - page?: number; - }; -} - -export interface RESTGetAPICountingUserAchievements extends BaseAuthRouteOptions[] | null> { - Params: { - userId: string; - }; -} diff --git a/src/rest/UserModifiers.ts b/src/rest/UserModifiers.ts deleted file mode 100644 index a952081..0000000 --- a/src/rest/UserModifiers.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { APICountingUserModifiers } from '../payloads/UserModifiers.js'; -import type { BaseAuthRouteOptions } from '../utils/base.js'; - -export interface RESTGetAPICountingUserModifiers extends BaseAuthRouteOptions | null> { - Params: { - userId: string; - }; -} diff --git a/src/rest/index.ts b/src/rest/index.ts deleted file mode 100644 index 4b03409..0000000 --- a/src/rest/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './Channel.js'; -export * from './ChannelModifiers.js'; -export * from './Guild.js'; -export * from './Status.js'; -export * from './Summary.js'; -export * from './User.js'; -export * from './UserModifiers.js'; diff --git a/src/utils/modifiers.ts b/src/utils/BaseModifier.ts similarity index 100% rename from src/utils/modifiers.ts rename to src/utils/BaseModifier.ts diff --git a/src/utils/BaseReply.ts b/src/utils/BaseReply.ts new file mode 100644 index 0000000..3e6c5e1 --- /dev/null +++ b/src/utils/BaseReply.ts @@ -0,0 +1,5 @@ +export interface BaseReply { + error: boolean; + code?: C; + data?: R; +} diff --git a/src/utils/languages.ts b/src/utils/LanguageCode.ts similarity index 100% rename from src/utils/languages.ts rename to src/utils/LanguageCode.ts diff --git a/src/utils/ResponseCodes.ts b/src/utils/ResponseCodes.ts new file mode 100644 index 0000000..36b8058 --- /dev/null +++ b/src/utils/ResponseCodes.ts @@ -0,0 +1,22 @@ +export enum UserBuyItemCode { + Success, + NotEnoughCoins, + InventoryFull, +} + +export enum UserAddAchievementCode { + Success, + AlreadyHasAchievement, +} + +export enum ChannelTransferCode { + Success, + FailOldChannelNotExists, + FailChannelsEqual, + FailNewChannelAlreadyExists, +} + +export enum ChannelDeleteCode { + Success, + FailChannelNotExists, +} diff --git a/src/utils/base.ts b/src/utils/base.ts deleted file mode 100644 index 711015c..0000000 --- a/src/utils/base.ts +++ /dev/null @@ -1,11 +0,0 @@ -export interface BaseAuthRouteOptions { - Header: { - Authorization: string; - }; - Reply: { - error: boolean; - message: string; - code?: C; - data?: R; - }; -} diff --git a/src/utils/index.ts b/src/utils/index.ts index ca01329..6cdf2ef 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,5 +1,5 @@ -export * from './base.js'; -export * from './codes.js'; +export * from './BaseReply.js'; +export * from './ResponseCodes.js'; export * from './items.js'; -export * from './languages.js'; -export * from './modifiers.js'; +export * from './LanguageCode.js'; +export * from './BaseModifier.js';