topgg-api-types 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/index.cjs +3 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -2
- package/dist/v0/validators.cjs +2 -0
- package/dist/v0/validators.cjs.map +1 -1
- package/dist/v0/validators.d.cts +2 -1
- package/dist/v0/validators.d.ts +2 -1
- package/dist/v0/validators.js +1 -1
- package/dist/v0/validators.js.map +1 -1
- package/dist/v1/validators.cjs +2 -0
- package/dist/v1/validators.cjs.map +1 -1
- package/dist/v1/validators.d.cts +2 -1
- package/dist/v1/validators.d.ts +2 -1
- package/dist/v1/validators.js +1 -1
- package/dist/v1/validators.js.map +1 -1
- package/dist/validators-jGzHB8WZ.d.cts +8 -0
- package/dist/validators-kCo2qI41.d.ts +8 -0
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 The-LukeZ
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require('./validators-B3dxgWHu.cjs');
|
|
1
|
+
const require_validators = require('./validators-B3dxgWHu.cjs');
|
|
2
2
|
const require_v1_validators = require('./v1/validators.cjs');
|
|
3
3
|
|
|
4
4
|
exports.BaseProjectSchema = require_v1_validators.BaseProjectSchema;
|
|
@@ -8,6 +8,7 @@ exports.GetProjectVotesQuerySchema = require_v1_validators.GetProjectVotesQueryS
|
|
|
8
8
|
exports.GetProjectVotesResponseSchema = require_v1_validators.GetProjectVotesResponseSchema;
|
|
9
9
|
exports.GetVoteStatusByUserQuerySchema = require_v1_validators.GetVoteStatusByUserQuerySchema;
|
|
10
10
|
exports.GetVoteStatusByUserResponseSchema = require_v1_validators.GetVoteStatusByUserResponseSchema;
|
|
11
|
+
exports.ISO8601DateSchema = require_validators.ISO8601DateSchema;
|
|
11
12
|
exports.IntegrationCreateDataSchema = require_v1_validators.IntegrationCreateDataSchema;
|
|
12
13
|
exports.IntegrationCreateResponseSchema = require_v1_validators.IntegrationCreateResponseSchema;
|
|
13
14
|
exports.IntegrationCreateWebhookPayloadSchema = require_v1_validators.IntegrationCreateWebhookPayloadSchema;
|
|
@@ -17,6 +18,7 @@ exports.IntegrationSupportedWebhookScopesSchema = require_v1_validators.Integrat
|
|
|
17
18
|
exports.ProjectPlatformTypeSchema = require_v1_validators.ProjectPlatformTypeSchema;
|
|
18
19
|
exports.ProjectTypeSchema = require_v1_validators.ProjectTypeSchema;
|
|
19
20
|
exports.ProjectVoteSchema = require_v1_validators.ProjectVoteSchema;
|
|
21
|
+
exports.SnowflakeSchema = require_validators.SnowflakeSchema;
|
|
20
22
|
exports.UserSchema = require_v1_validators.UserSchema;
|
|
21
23
|
exports.UserSourceSchema = require_v1_validators.UserSourceSchema;
|
|
22
24
|
exports.VoteCreateDataSchema = require_v1_validators.VoteCreateDataSchema;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { BaseProject, ErrorResponse, GetProjectResponse, GetProjectVotesQuery, GetProjectVotesResponse, GetVoteStatusByUserQuery, GetVoteStatusByUserResponse, IntegrationCreateData, IntegrationCreateResponse, IntegrationCreateWebhookPayload, IntegrationDeleteData, IntegrationDeleteWebhookPayload, IntegrationWebhookEventType, ProjectPlatformType, ProjectType, ProjectVote, User, UserSource, Vote, VoteCreateData, VoteCreateWebhookPayload, WebhookEventType, WebhookEventTypes, WebhookPayloadBase, WebhookTestData, WebhookTestWebhookPayload } from "./v1.cjs";
|
|
2
|
+
import { n as SnowflakeSchema, t as ISO8601DateSchema } from "./validators-jGzHB8WZ.cjs";
|
|
2
3
|
import { BaseProjectSchema, ErrorSchema, GetProjectResponseSchema, GetProjectVotesQuerySchema, GetProjectVotesResponseSchema, GetVoteStatusByUserQuerySchema, GetVoteStatusByUserResponseSchema, IntegrationCreateDataSchema, IntegrationCreateResponseSchema, IntegrationCreateWebhookPayloadSchema, IntegrationDeleteDataSchema, IntegrationDeleteWebhookPayloadSchema, IntegrationSupportedWebhookScopesSchema, ProjectPlatformTypeSchema, ProjectTypeSchema, ProjectVoteSchema, UserSchema, UserSourceSchema, VoteCreateDataSchema, VoteCreateWebhookPayloadSchema, VoteSchema, WebhookEventTypeSchema, WebhookPayloadBaseSchema, WebhookTestDataSchema, WebhookTestWebhookPayloadSchema } from "./v1/validators.cjs";
|
|
3
|
-
export { BaseProject, BaseProjectSchema, ErrorResponse, ErrorSchema, GetProjectResponse, GetProjectResponseSchema, GetProjectVotesQuery, GetProjectVotesQuerySchema, GetProjectVotesResponse, GetProjectVotesResponseSchema, GetVoteStatusByUserQuery, GetVoteStatusByUserQuerySchema, GetVoteStatusByUserResponse, GetVoteStatusByUserResponseSchema, IntegrationCreateData, IntegrationCreateDataSchema, IntegrationCreateResponse, IntegrationCreateResponseSchema, IntegrationCreateWebhookPayload, IntegrationCreateWebhookPayloadSchema, IntegrationDeleteData, IntegrationDeleteDataSchema, IntegrationDeleteWebhookPayload, IntegrationDeleteWebhookPayloadSchema, IntegrationSupportedWebhookScopesSchema, IntegrationWebhookEventType, ProjectPlatformType, ProjectPlatformTypeSchema, ProjectType, ProjectTypeSchema, ProjectVote, ProjectVoteSchema, User, UserSchema, UserSource, UserSourceSchema, Vote, VoteCreateData, VoteCreateDataSchema, VoteCreateWebhookPayload, VoteCreateWebhookPayloadSchema, VoteSchema, WebhookEventType, WebhookEventTypeSchema, WebhookEventTypes, WebhookPayloadBase, WebhookPayloadBaseSchema, WebhookTestData, WebhookTestDataSchema, WebhookTestWebhookPayload, WebhookTestWebhookPayloadSchema };
|
|
4
|
+
export { BaseProject, BaseProjectSchema, ErrorResponse, ErrorSchema, GetProjectResponse, GetProjectResponseSchema, GetProjectVotesQuery, GetProjectVotesQuerySchema, GetProjectVotesResponse, GetProjectVotesResponseSchema, GetVoteStatusByUserQuery, GetVoteStatusByUserQuerySchema, GetVoteStatusByUserResponse, GetVoteStatusByUserResponseSchema, ISO8601DateSchema, IntegrationCreateData, IntegrationCreateDataSchema, IntegrationCreateResponse, IntegrationCreateResponseSchema, IntegrationCreateWebhookPayload, IntegrationCreateWebhookPayloadSchema, IntegrationDeleteData, IntegrationDeleteDataSchema, IntegrationDeleteWebhookPayload, IntegrationDeleteWebhookPayloadSchema, IntegrationSupportedWebhookScopesSchema, IntegrationWebhookEventType, ProjectPlatformType, ProjectPlatformTypeSchema, ProjectType, ProjectTypeSchema, ProjectVote, ProjectVoteSchema, SnowflakeSchema, User, UserSchema, UserSource, UserSourceSchema, Vote, VoteCreateData, VoteCreateDataSchema, VoteCreateWebhookPayload, VoteCreateWebhookPayloadSchema, VoteSchema, WebhookEventType, WebhookEventTypeSchema, WebhookEventTypes, WebhookPayloadBase, WebhookPayloadBaseSchema, WebhookTestData, WebhookTestDataSchema, WebhookTestWebhookPayload, WebhookTestWebhookPayloadSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { BaseProject, ErrorResponse, GetProjectResponse, GetProjectVotesQuery, GetProjectVotesResponse, GetVoteStatusByUserQuery, GetVoteStatusByUserResponse, IntegrationCreateData, IntegrationCreateResponse, IntegrationCreateWebhookPayload, IntegrationDeleteData, IntegrationDeleteWebhookPayload, IntegrationWebhookEventType, ProjectPlatformType, ProjectType, ProjectVote, User, UserSource, Vote, VoteCreateData, VoteCreateWebhookPayload, WebhookEventType, WebhookEventTypes, WebhookPayloadBase, WebhookTestData, WebhookTestWebhookPayload } from "./v1.js";
|
|
2
|
+
import { n as SnowflakeSchema, t as ISO8601DateSchema } from "./validators-kCo2qI41.js";
|
|
2
3
|
import { BaseProjectSchema, ErrorSchema, GetProjectResponseSchema, GetProjectVotesQuerySchema, GetProjectVotesResponseSchema, GetVoteStatusByUserQuerySchema, GetVoteStatusByUserResponseSchema, IntegrationCreateDataSchema, IntegrationCreateResponseSchema, IntegrationCreateWebhookPayloadSchema, IntegrationDeleteDataSchema, IntegrationDeleteWebhookPayloadSchema, IntegrationSupportedWebhookScopesSchema, ProjectPlatformTypeSchema, ProjectTypeSchema, ProjectVoteSchema, UserSchema, UserSourceSchema, VoteCreateDataSchema, VoteCreateWebhookPayloadSchema, VoteSchema, WebhookEventTypeSchema, WebhookPayloadBaseSchema, WebhookTestDataSchema, WebhookTestWebhookPayloadSchema } from "./v1/validators.js";
|
|
3
|
-
export { BaseProject, BaseProjectSchema, ErrorResponse, ErrorSchema, GetProjectResponse, GetProjectResponseSchema, GetProjectVotesQuery, GetProjectVotesQuerySchema, GetProjectVotesResponse, GetProjectVotesResponseSchema, GetVoteStatusByUserQuery, GetVoteStatusByUserQuerySchema, GetVoteStatusByUserResponse, GetVoteStatusByUserResponseSchema, IntegrationCreateData, IntegrationCreateDataSchema, IntegrationCreateResponse, IntegrationCreateResponseSchema, IntegrationCreateWebhookPayload, IntegrationCreateWebhookPayloadSchema, IntegrationDeleteData, IntegrationDeleteDataSchema, IntegrationDeleteWebhookPayload, IntegrationDeleteWebhookPayloadSchema, IntegrationSupportedWebhookScopesSchema, IntegrationWebhookEventType, ProjectPlatformType, ProjectPlatformTypeSchema, ProjectType, ProjectTypeSchema, ProjectVote, ProjectVoteSchema, User, UserSchema, UserSource, UserSourceSchema, Vote, VoteCreateData, VoteCreateDataSchema, VoteCreateWebhookPayload, VoteCreateWebhookPayloadSchema, VoteSchema, WebhookEventType, WebhookEventTypeSchema, WebhookEventTypes, WebhookPayloadBase, WebhookPayloadBaseSchema, WebhookTestData, WebhookTestDataSchema, WebhookTestWebhookPayload, WebhookTestWebhookPayloadSchema };
|
|
4
|
+
export { BaseProject, BaseProjectSchema, ErrorResponse, ErrorSchema, GetProjectResponse, GetProjectResponseSchema, GetProjectVotesQuery, GetProjectVotesQuerySchema, GetProjectVotesResponse, GetProjectVotesResponseSchema, GetVoteStatusByUserQuery, GetVoteStatusByUserQuerySchema, GetVoteStatusByUserResponse, GetVoteStatusByUserResponseSchema, ISO8601DateSchema, IntegrationCreateData, IntegrationCreateDataSchema, IntegrationCreateResponse, IntegrationCreateResponseSchema, IntegrationCreateWebhookPayload, IntegrationCreateWebhookPayloadSchema, IntegrationDeleteData, IntegrationDeleteDataSchema, IntegrationDeleteWebhookPayload, IntegrationDeleteWebhookPayloadSchema, IntegrationSupportedWebhookScopesSchema, IntegrationWebhookEventType, ProjectPlatformType, ProjectPlatformTypeSchema, ProjectType, ProjectTypeSchema, ProjectVote, ProjectVoteSchema, SnowflakeSchema, User, UserSchema, UserSource, UserSourceSchema, Vote, VoteCreateData, VoteCreateDataSchema, VoteCreateWebhookPayload, VoteCreateWebhookPayloadSchema, VoteSchema, WebhookEventType, WebhookEventTypeSchema, WebhookEventTypes, WebhookPayloadBase, WebhookPayloadBaseSchema, WebhookTestData, WebhookTestDataSchema, WebhookTestWebhookPayload, WebhookTestWebhookPayloadSchema };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./validators-Mlu16sBg.js";
|
|
1
|
+
import { n as SnowflakeSchema, t as ISO8601DateSchema } from "./validators-Mlu16sBg.js";
|
|
2
2
|
import { BaseProjectSchema, ErrorSchema, GetProjectResponseSchema, GetProjectVotesQuerySchema, GetProjectVotesResponseSchema, GetVoteStatusByUserQuerySchema, GetVoteStatusByUserResponseSchema, IntegrationCreateDataSchema, IntegrationCreateResponseSchema, IntegrationCreateWebhookPayloadSchema, IntegrationDeleteDataSchema, IntegrationDeleteWebhookPayloadSchema, IntegrationSupportedWebhookScopesSchema, ProjectPlatformTypeSchema, ProjectTypeSchema, ProjectVoteSchema, UserSchema, UserSourceSchema, VoteCreateDataSchema, VoteCreateWebhookPayloadSchema, VoteSchema, WebhookEventTypeSchema, WebhookPayloadBaseSchema, WebhookTestDataSchema, WebhookTestWebhookPayloadSchema } from "./v1/validators.js";
|
|
3
3
|
|
|
4
|
-
export { BaseProjectSchema, ErrorSchema, GetProjectResponseSchema, GetProjectVotesQuerySchema, GetProjectVotesResponseSchema, GetVoteStatusByUserQuerySchema, GetVoteStatusByUserResponseSchema, IntegrationCreateDataSchema, IntegrationCreateResponseSchema, IntegrationCreateWebhookPayloadSchema, IntegrationDeleteDataSchema, IntegrationDeleteWebhookPayloadSchema, IntegrationSupportedWebhookScopesSchema, ProjectPlatformTypeSchema, ProjectTypeSchema, ProjectVoteSchema, UserSchema, UserSourceSchema, VoteCreateDataSchema, VoteCreateWebhookPayloadSchema, VoteSchema, WebhookEventTypeSchema, WebhookPayloadBaseSchema, WebhookTestDataSchema, WebhookTestWebhookPayloadSchema };
|
|
4
|
+
export { BaseProjectSchema, ErrorSchema, GetProjectResponseSchema, GetProjectVotesQuerySchema, GetProjectVotesResponseSchema, GetVoteStatusByUserQuerySchema, GetVoteStatusByUserResponseSchema, ISO8601DateSchema, IntegrationCreateDataSchema, IntegrationCreateResponseSchema, IntegrationCreateWebhookPayloadSchema, IntegrationDeleteDataSchema, IntegrationDeleteWebhookPayloadSchema, IntegrationSupportedWebhookScopesSchema, ProjectPlatformTypeSchema, ProjectTypeSchema, ProjectVoteSchema, SnowflakeSchema, UserSchema, UserSourceSchema, VoteCreateDataSchema, VoteCreateWebhookPayloadSchema, VoteSchema, WebhookEventTypeSchema, WebhookPayloadBaseSchema, WebhookTestDataSchema, WebhookTestWebhookPayloadSchema };
|
package/dist/v0/validators.cjs
CHANGED
|
@@ -169,8 +169,10 @@ exports.GetSearchBotsQuerySchema = GetSearchBotsQuerySchema;
|
|
|
169
169
|
exports.GetSearchBotsResponseSchema = GetSearchBotsResponseSchema;
|
|
170
170
|
exports.GetUserVoteCheckQuerySchema = GetUserVoteCheckQuerySchema;
|
|
171
171
|
exports.GetUserVoteCheckResponseSchema = GetUserVoteCheckResponseSchema;
|
|
172
|
+
exports.ISO8601DateSchema = require_validators.ISO8601DateSchema;
|
|
172
173
|
exports.PostBotStatsBodySchema = PostBotStatsBodySchema;
|
|
173
174
|
exports.ServerWebhookPayloadSchema = ServerWebhookPayloadSchema;
|
|
175
|
+
exports.SnowflakeSchema = require_validators.SnowflakeSchema;
|
|
174
176
|
exports.UserSchema = UserSchema;
|
|
175
177
|
exports.WebhookEventTypeSchema = WebhookEventTypeSchema;
|
|
176
178
|
//# sourceMappingURL=validators.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.cjs","names":["z","SnowflakeSchema","ISO8601DateSchema"],"sources":["../../src/v0/validators.ts"],"sourcesContent":["import * as z from \"zod/mini\";\nimport { ISO8601DateSchema, SnowflakeSchema } from \"@utils/validators\";\n\n// # Bases and Constants\n\n/**\n * The type of a webhook event.\n */\nexport const WebhookEventTypeSchema = z.enum([\"upvote\", \"test\"]);\n\n// # Webhooks - deprecated\n\n/**\n * Webhook payload for bot votes (deprecated).\n *\n * @deprecated Use `v1` types instead.\n */\nexport const BotWebhookPayloadSchema = z.object({\n /**\n * Discord ID of the bot that received a vote.\n */\n bot: SnowflakeSchema,\n /**\n * Discord ID of the user that voted.\n */\n user: SnowflakeSchema,\n /**\n * The type of the vote (should always be \"upvote\" except when using the test button it's \"test\").\n */\n type: WebhookEventTypeSchema,\n /**\n * Whether the weekend multiplier is in effect, meaning users votes count as two.\n */\n isWeekend: z.boolean(),\n /**\n * Query string params found on the /bot/:ID/vote page.\n *\n * @example\n * \"?a=1&b=2&c=3\"\n */\n query: z.optional(z.string()),\n});\n\n/**\n * Webhook payload for server votes (deprecated).\n *\n * @deprecated Use `v1` types instead.\n */\nexport const ServerWebhookPayloadSchema = z.object({\n /**\n * Discord ID of the server that received a vote.\n */\n guild: SnowflakeSchema,\n /**\n * Discord ID of the user that voted.\n */\n user: SnowflakeSchema,\n /**\n * The type of the vote (should always be \"upvote\" except when using the test button it's \"test\").\n */\n type: WebhookEventTypeSchema,\n /**\n * Whether the weekend multiplier is in effect, meaning users votes count as two.\n */\n query: z.optional(z.string()),\n});\n\n// # Bots\n\n/**\n * A bot listed on Top.gg.\n */\nexport const BotSchema = z.object({\n /**\n * The Discord ID of the bot\n */\n id: SnowflakeSchema,\n /**\n * The username of the bot\n */\n username: z.string(),\n /**\n * The discriminator of the bot (legacy Discord feature)\n */\n discriminator: z.string(),\n /**\n * The avatar hash of the bot's avatar\n */\n avatar: z.optional(z.string()),\n /**\n * The cdn hash of the bot's avatar if the bot has none\n */\n defAvatar: z.optional(z.string()),\n /**\n * The command prefix of the bot\n */\n prefix: z.string(),\n /**\n * The short description of the bot\n */\n shortdesc: z.string(),\n /**\n * The detailed long description of the bot\n */\n longdesc: z.optional(z.string()),\n /**\n * Array of tags associated with the bot\n */\n tags: z.array(z.string()),\n /**\n * The official website URL of the bot\n */\n website: z.optional(z.string()),\n /**\n * The support server URL for the bot\n */\n support: z.optional(z.string()),\n /**\n * The GitHub repository URL of the bot\n */\n github: z.optional(z.string()),\n /**\n * Array of snowflake identifiers of the bot owners\n */\n owners: z.array(SnowflakeSchema),\n /**\n * Array of guild snowflake identifiers where the bot is present\n */\n guilds: z.array(SnowflakeSchema),\n /**\n * The OAuth2 invite URL of the bot\n */\n invite: z.optional(z.string()),\n /**\n * The date when the bot was approved on Top.gg in ISO 8601 format\n */\n date: ISO8601DateSchema,\n /**\n * The amount of servers the bot has according to posted stats.\n */\n server_count: z.optional(z.number()),\n /**\n * The amount of shards the bot has according to posted stats.\n */\n shard_count: z.optional(z.number()),\n /**\n * Whether the bot is certified on Top.gg\n */\n certifiedBot: z.boolean(),\n /**\n * The vanity URL of the bot on Top.gg\n */\n vanity: z.optional(z.string()),\n /**\n * The amount of upvotes the bot has\n */\n points: z.number(),\n /**\n * The amount of upvotes the bot has this month\n */\n monthlyPoints: z.number(),\n /**\n * The guild id for the donatebot setup\n */\n donatebotguildid: SnowflakeSchema,\n});\n\n/**\n * Query parameters for searching bots on Top.gg.\n *\n * @see https://docs.top.gg/docs/API/v0/bot#search-bots\n */\nexport const GetSearchBotsQuerySchema = z.object({\n /**\n * The amount of bots to return.\n *\n * @minimum 1\n * @maximum 500\n * @default 50\n */\n limit: z.optional(z.number().check(z.minimum(1)).check(z.maximum(500))),\n /**\n * The amount of bots to skip (for pagination).\n *\n * @minimum 0\n * @default 0\n */\n offset: z.optional(z.number().check(z.minimum(0))),\n /**\n * The field to sort the bots by. Prefix with `-` for descending order.\n *\n * There is no documented default.\n */\n sort: z.string(),\n /**\n * Comma separated list of fields to include in the response. If not provided, all fields will be included.\n */\n fields: z.optional(z.string()),\n});\n\n/**\n * Response for searching bots on Top.gg.\n */\nexport const GetSearchBotsResponseSchema = z.object({\n /**\n * The array of bots that match the search query.\n */\n results: z.array(BotSchema),\n /**\n * The total number of bots that match the search query.\n */\n total: z.number(),\n /**\n * The limit used in the query.\n */\n limit: z.number(),\n /**\n * The amount of bots skipped (for pagination).\n */\n offset: z.number(),\n /**\n * The amount of items in the current page of results.\n */\n count: z.number(),\n});\n\n/**\n * Response for getting a bot.\n *\n * - GET `/bots/:bot_id`\n */\nexport const GetBotResponseSchema = BotSchema;\n\n/**\n * A bot voter.\n */\nexport const BotVoterSchema = z.object({\n /**\n * The Discord ID of the user that voted.\n */\n id: SnowflakeSchema,\n /**\n * The username of the user that voted, including discriminator (e.g., \"wumpus#0000\").\n */\n username: z.string(),\n /**\n * The avatar hash of the user that voted.\n */\n avatar: z.optional(z.string()),\n});\n\n/**\n * Gets the last 1000 voters for your bot.\n *\n * - GET `/bots/:bot_id/votes`\n */\nexport const GetLast1000BotVotesResponseSchema = z.array(BotVoterSchema);\n\n/**\n * Specific stats about a bot.\n *\n * - GET `/bots/:bot_id/stats`\n */\nexport const GetBotStatsResponseSchema = z.object({\n /**\n * The amount of servers the bot is in\n */\n server_count: z.optional(z.number()),\n /**\n * The amount of servers the bot is in per shard. Always present but can be empty.\n */\n shards: z.array(z.number()),\n /**\n * The amount of shards a bot has according to posted stats.\n */\n shard_count: z.optional(z.number()),\n});\n\n/**\n * Query parameters for checking whether or not a user has voted for your bot.\n *\n * - GET `/bots/:bot_id/check`\n */\nexport const GetUserVoteCheckQuerySchema = z.object({\n /**\n * The Discord ID of the user to check for a vote.\n */\n userId: SnowflakeSchema,\n});\n\n/**\n * Response for checking whether or not a user has voted for your bot.\n *\n * - GET `/bots/:bot_id/check`\n */\nexport const GetUserVoteCheckResponseSchema = z.object({\n /**\n * 0 if the user has not voted for this bot in the last 12 hours, 1 if they have.\n */\n voted: z.xor([z.literal(0), z.literal(1)]),\n});\n\n/**\n * Request body for posting bot stats.\n */\nexport const PostBotStatsBodySchema = z.object({\n /**\n * The amount of servers the bot is in. Required if the bot has less than 100 servers, otherwise optional but recommended.\n *\n * If an Array, it acts like shards.\n */\n server_count: z.xor([z.number(), z.array(z.number())]),\n /**\n * Amount of servers the bot is in per shard.\n */\n shards: z.optional(z.array(z.number())),\n /**\n * The zero-indexed id of the shard posting. Makes server_count set the shard specific server count.\n */\n shard_id: z.optional(z.number()),\n /**\n * The amount of shards the bot has.\n */\n shard_count: z.optional(z.number()),\n});\n\n// # Users\n\n/**\n * A user on Top.gg.\n *\n * - GET `/users/:user_id`\n */\nexport const UserSchema = z.object({\n /**\n * The Discord ID for this user.\n */\n id: SnowflakeSchema,\n /**\n * The username of the user, not including discriminator (e.g., \"wumpus\").\n */\n username: z.string(),\n /**\n * The discriminator of the user (legacy Discord feature, e.g., \"0000\").\n */\n discriminator: z.string(),\n /**\n * The avatar hash of the user's avatar.\n */\n avatar: z.optional(z.string()),\n /**\n * The cdn hash of the user's avatar if the user has none.\n */\n defAvatar: z.optional(z.string()),\n /**\n * The bio of the user. This is a short description that the user can set on their profile. It may be empty or null if the user has not set a bio.\n *\n * This is NOT their in-discord bio.\n */\n bio: z.optional(z.string()),\n /**\n * The banner image URL of the user.\n */\n banner: z.optional(z.string()),\n /**\n * The social usernames of the user\n */\n social: z.object({\n /**\n * The YouTube channel ID of the user. This is not the full URL, just the channel ID (e.g., \"UC_x5XG1OV2P6uZZ5FSM9Ttw\").\n */\n youtube: z.optional(z.string()),\n /**\n * The Reddit username of the user (e.g., \"spez\"). This is not the full URL, just the username.\n */\n reddit: z.optional(z.string()),\n /**\n * The Twitter username of the user (e.g., \"jack\"). This is not the full URL, just the username.\n */\n twitter: z.optional(z.string()),\n /**\n * The Instagram username of the user (e.g., \"instagram\"). This is not the full URL, just the username.\n */\n instagram: z.optional(z.string()),\n /**\n * The GitHub username of the user (e.g., \"torvalds\"). This is not the full URL, just the username.\n */\n github: z.optional(z.string()),\n }),\n /**\n * The custom hex color of the user (not guaranteed to be valid hex). This is a color that the user can set on their profile.\n */\n color: z.optional(z.string()),\n /**\n * The supporter status of the user. This is true if the user has voted for any bot in the last month.\n */\n supporter: z.boolean(),\n /**\n * The certified status of the user.\n */\n certifiedDev: z.boolean(),\n /**\n * The mod status of the user. This is true if the user is a moderator on Top.gg.\n */\n mod: z.boolean(),\n /**\n * The website moderator status of the user. This is true if the user is a website moderator on Top.gg.\n */\n webMod: z.boolean(),\n /**\n * The admin status of the user.\n */\n admin: z.boolean(),\n});\n"],"mappings":";;;;;;;;AAQA,MAAa,yBAAyBA,SAAE,KAAK,CAAC,UAAU,OAAO,CAAC;;;;;;AAShE,MAAa,0BAA0BA,SAAE,OAAO;CAI9C,KAAKC;CAIL,MAAMA;CAIN,MAAM;CAIN,WAAWD,SAAE,SAAS;CAOtB,OAAOA,SAAE,SAASA,SAAE,QAAQ,CAAC;CAC9B,CAAC;;;;;;AAOF,MAAa,6BAA6BA,SAAE,OAAO;CAIjD,OAAOC;CAIP,MAAMA;CAIN,MAAM;CAIN,OAAOD,SAAE,SAASA,SAAE,QAAQ,CAAC;CAC9B,CAAC;;;;AAOF,MAAa,YAAYA,SAAE,OAAO;CAIhC,IAAIC;CAIJ,UAAUD,SAAE,QAAQ;CAIpB,eAAeA,SAAE,QAAQ;CAIzB,QAAQA,SAAE,SAASA,SAAE,QAAQ,CAAC;CAI9B,WAAWA,SAAE,SAASA,SAAE,QAAQ,CAAC;CAIjC,QAAQA,SAAE,QAAQ;CAIlB,WAAWA,SAAE,QAAQ;CAIrB,UAAUA,SAAE,SAASA,SAAE,QAAQ,CAAC;CAIhC,MAAMA,SAAE,MAAMA,SAAE,QAAQ,CAAC;CAIzB,SAASA,SAAE,SAASA,SAAE,QAAQ,CAAC;CAI/B,SAASA,SAAE,SAASA,SAAE,QAAQ,CAAC;CAI/B,QAAQA,SAAE,SAASA,SAAE,QAAQ,CAAC;CAI9B,QAAQA,SAAE,MAAMC,mCAAgB;CAIhC,QAAQD,SAAE,MAAMC,mCAAgB;CAIhC,QAAQD,SAAE,SAASA,SAAE,QAAQ,CAAC;CAI9B,MAAME;CAIN,cAAcF,SAAE,SAASA,SAAE,QAAQ,CAAC;CAIpC,aAAaA,SAAE,SAASA,SAAE,QAAQ,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{ ISO8601DateSchema, SnowflakeSchema } from \"@utils/validators\";\nexport * from \"@utils/validators\";\n\n// # Bases and Constants\n\n/**\n * The type of a webhook event.\n */\nexport const WebhookEventTypeSchema = z.enum([\"upvote\", \"test\"]);\n\n// # Webhooks - deprecated\n\n/**\n * Webhook payload for bot votes (deprecated).\n *\n * @deprecated Use `v1` types instead.\n */\nexport const BotWebhookPayloadSchema = z.object({\n /**\n * Discord ID of the bot that received a vote.\n */\n bot: SnowflakeSchema,\n /**\n * Discord ID of the user that voted.\n */\n user: SnowflakeSchema,\n /**\n * The type of the vote (should always be \"upvote\" except when using the test button it's \"test\").\n */\n type: WebhookEventTypeSchema,\n /**\n * Whether the weekend multiplier is in effect, meaning users votes count as two.\n */\n isWeekend: z.boolean(),\n /**\n * Query string params found on the /bot/:ID/vote page.\n *\n * @example\n * \"?a=1&b=2&c=3\"\n */\n query: z.optional(z.string()),\n});\n\n/**\n * Webhook payload for server votes (deprecated).\n *\n * @deprecated Use `v1` types instead.\n */\nexport const ServerWebhookPayloadSchema = z.object({\n /**\n * Discord ID of the server that received a vote.\n */\n guild: SnowflakeSchema,\n /**\n * Discord ID of the user that voted.\n */\n user: SnowflakeSchema,\n /**\n * The type of the vote (should always be \"upvote\" except when using the test button it's \"test\").\n */\n type: WebhookEventTypeSchema,\n /**\n * Whether the weekend multiplier is in effect, meaning users votes count as two.\n */\n query: z.optional(z.string()),\n});\n\n// # Bots\n\n/**\n * A bot listed on Top.gg.\n */\nexport const BotSchema = z.object({\n /**\n * The Discord ID of the bot\n */\n id: SnowflakeSchema,\n /**\n * The username of the bot\n */\n username: z.string(),\n /**\n * The discriminator of the bot (legacy Discord feature)\n */\n discriminator: z.string(),\n /**\n * The avatar hash of the bot's avatar\n */\n avatar: z.optional(z.string()),\n /**\n * The cdn hash of the bot's avatar if the bot has none\n */\n defAvatar: z.optional(z.string()),\n /**\n * The command prefix of the bot\n */\n prefix: z.string(),\n /**\n * The short description of the bot\n */\n shortdesc: z.string(),\n /**\n * The detailed long description of the bot\n */\n longdesc: z.optional(z.string()),\n /**\n * Array of tags associated with the bot\n */\n tags: z.array(z.string()),\n /**\n * The official website URL of the bot\n */\n website: z.optional(z.string()),\n /**\n * The support server URL for the bot\n */\n support: z.optional(z.string()),\n /**\n * The GitHub repository URL of the bot\n */\n github: z.optional(z.string()),\n /**\n * Array of snowflake identifiers of the bot owners\n */\n owners: z.array(SnowflakeSchema),\n /**\n * Array of guild snowflake identifiers where the bot is present\n */\n guilds: z.array(SnowflakeSchema),\n /**\n * The OAuth2 invite URL of the bot\n */\n invite: z.optional(z.string()),\n /**\n * The date when the bot was approved on Top.gg in ISO 8601 format\n */\n date: ISO8601DateSchema,\n /**\n * The amount of servers the bot has according to posted stats.\n */\n server_count: z.optional(z.number()),\n /**\n * The amount of shards the bot has according to posted stats.\n */\n shard_count: z.optional(z.number()),\n /**\n * Whether the bot is certified on Top.gg\n */\n certifiedBot: z.boolean(),\n /**\n * The vanity URL of the bot on Top.gg\n */\n vanity: z.optional(z.string()),\n /**\n * The amount of upvotes the bot has\n */\n points: z.number(),\n /**\n * The amount of upvotes the bot has this month\n */\n monthlyPoints: z.number(),\n /**\n * The guild id for the donatebot setup\n */\n donatebotguildid: SnowflakeSchema,\n});\n\n/**\n * Query parameters for searching bots on Top.gg.\n *\n * @see https://docs.top.gg/docs/API/v0/bot#search-bots\n */\nexport const GetSearchBotsQuerySchema = z.object({\n /**\n * The amount of bots to return.\n *\n * @minimum 1\n * @maximum 500\n * @default 50\n */\n limit: z.optional(z.number().check(z.minimum(1)).check(z.maximum(500))),\n /**\n * The amount of bots to skip (for pagination).\n *\n * @minimum 0\n * @default 0\n */\n offset: z.optional(z.number().check(z.minimum(0))),\n /**\n * The field to sort the bots by. Prefix with `-` for descending order.\n *\n * There is no documented default.\n */\n sort: z.string(),\n /**\n * Comma separated list of fields to include in the response. If not provided, all fields will be included.\n */\n fields: z.optional(z.string()),\n});\n\n/**\n * Response for searching bots on Top.gg.\n */\nexport const GetSearchBotsResponseSchema = z.object({\n /**\n * The array of bots that match the search query.\n */\n results: z.array(BotSchema),\n /**\n * The total number of bots that match the search query.\n */\n total: z.number(),\n /**\n * The limit used in the query.\n */\n limit: z.number(),\n /**\n * The amount of bots skipped (for pagination).\n */\n offset: z.number(),\n /**\n * The amount of items in the current page of results.\n */\n count: z.number(),\n});\n\n/**\n * Response for getting a bot.\n *\n * - GET `/bots/:bot_id`\n */\nexport const GetBotResponseSchema = BotSchema;\n\n/**\n * A bot voter.\n */\nexport const BotVoterSchema = z.object({\n /**\n * The Discord ID of the user that voted.\n */\n id: SnowflakeSchema,\n /**\n * The username of the user that voted, including discriminator (e.g., \"wumpus#0000\").\n */\n username: z.string(),\n /**\n * The avatar hash of the user that voted.\n */\n avatar: z.optional(z.string()),\n});\n\n/**\n * Gets the last 1000 voters for your bot.\n *\n * - GET `/bots/:bot_id/votes`\n */\nexport const GetLast1000BotVotesResponseSchema = z.array(BotVoterSchema);\n\n/**\n * Specific stats about a bot.\n *\n * - GET `/bots/:bot_id/stats`\n */\nexport const GetBotStatsResponseSchema = z.object({\n /**\n * The amount of servers the bot is in\n */\n server_count: z.optional(z.number()),\n /**\n * The amount of servers the bot is in per shard. Always present but can be empty.\n */\n shards: z.array(z.number()),\n /**\n * The amount of shards a bot has according to posted stats.\n */\n shard_count: z.optional(z.number()),\n});\n\n/**\n * Query parameters for checking whether or not a user has voted for your bot.\n *\n * - GET `/bots/:bot_id/check`\n */\nexport const GetUserVoteCheckQuerySchema = z.object({\n /**\n * The Discord ID of the user to check for a vote.\n */\n userId: SnowflakeSchema,\n});\n\n/**\n * Response for checking whether or not a user has voted for your bot.\n *\n * - GET `/bots/:bot_id/check`\n */\nexport const GetUserVoteCheckResponseSchema = z.object({\n /**\n * 0 if the user has not voted for this bot in the last 12 hours, 1 if they have.\n */\n voted: z.xor([z.literal(0), z.literal(1)]),\n});\n\n/**\n * Request body for posting bot stats.\n */\nexport const PostBotStatsBodySchema = z.object({\n /**\n * The amount of servers the bot is in. Required if the bot has less than 100 servers, otherwise optional but recommended.\n *\n * If an Array, it acts like shards.\n */\n server_count: z.xor([z.number(), z.array(z.number())]),\n /**\n * Amount of servers the bot is in per shard.\n */\n shards: z.optional(z.array(z.number())),\n /**\n * The zero-indexed id of the shard posting. Makes server_count set the shard specific server count.\n */\n shard_id: z.optional(z.number()),\n /**\n * The amount of shards the bot has.\n */\n shard_count: z.optional(z.number()),\n});\n\n// # Users\n\n/**\n * A user on Top.gg.\n *\n * - GET `/users/:user_id`\n */\nexport const UserSchema = z.object({\n /**\n * The Discord ID for this user.\n */\n id: SnowflakeSchema,\n /**\n * The username of the user, not including discriminator (e.g., \"wumpus\").\n */\n username: z.string(),\n /**\n * The discriminator of the user (legacy Discord feature, e.g., \"0000\").\n */\n discriminator: z.string(),\n /**\n * The avatar hash of the user's avatar.\n */\n avatar: z.optional(z.string()),\n /**\n * The cdn hash of the user's avatar if the user has none.\n */\n defAvatar: z.optional(z.string()),\n /**\n * The bio of the user. This is a short description that the user can set on their profile. It may be empty or null if the user has not set a bio.\n *\n * This is NOT their in-discord bio.\n */\n bio: z.optional(z.string()),\n /**\n * The banner image URL of the user.\n */\n banner: z.optional(z.string()),\n /**\n * The social usernames of the user\n */\n social: z.object({\n /**\n * The YouTube channel ID of the user. This is not the full URL, just the channel ID (e.g., \"UC_x5XG1OV2P6uZZ5FSM9Ttw\").\n */\n youtube: z.optional(z.string()),\n /**\n * The Reddit username of the user (e.g., \"spez\"). This is not the full URL, just the username.\n */\n reddit: z.optional(z.string()),\n /**\n * The Twitter username of the user (e.g., \"jack\"). This is not the full URL, just the username.\n */\n twitter: z.optional(z.string()),\n /**\n * The Instagram username of the user (e.g., \"instagram\"). This is not the full URL, just the username.\n */\n instagram: z.optional(z.string()),\n /**\n * The GitHub username of the user (e.g., \"torvalds\"). This is not the full URL, just the username.\n */\n github: z.optional(z.string()),\n }),\n /**\n * The custom hex color of the user (not guaranteed to be valid hex). This is a color that the user can set on their profile.\n */\n color: z.optional(z.string()),\n /**\n * The supporter status of the user. This is true if the user has voted for any bot in the last month.\n */\n supporter: z.boolean(),\n /**\n * The certified status of the user.\n */\n certifiedDev: z.boolean(),\n /**\n * The mod status of the user. This is true if the user is a moderator on Top.gg.\n */\n mod: z.boolean(),\n /**\n * The website moderator status of the user. This is true if the user is a website moderator on Top.gg.\n */\n webMod: z.boolean(),\n /**\n * The admin status of the user.\n */\n admin: z.boolean(),\n});\n"],"mappings":";;;;;;;;AASA,MAAa,yBAAyBA,SAAE,KAAK,CAAC,UAAU,OAAO,CAAC;;;;;;AAShE,MAAa,0BAA0BA,SAAE,OAAO;CAI9C,KAAKC;CAIL,MAAMA;CAIN,MAAM;CAIN,WAAWD,SAAE,SAAS;CAOtB,OAAOA,SAAE,SAASA,SAAE,QAAQ,CAAC;CAC9B,CAAC;;;;;;AAOF,MAAa,6BAA6BA,SAAE,OAAO;CAIjD,OAAOC;CAIP,MAAMA;CAIN,MAAM;CAIN,OAAOD,SAAE,SAASA,SAAE,QAAQ,CAAC;CAC9B,CAAC;;;;AAOF,MAAa,YAAYA,SAAE,OAAO;CAIhC,IAAIC;CAIJ,UAAUD,SAAE,QAAQ;CAIpB,eAAeA,SAAE,QAAQ;CAIzB,QAAQA,SAAE,SAASA,SAAE,QAAQ,CAAC;CAI9B,WAAWA,SAAE,SAASA,SAAE,QAAQ,CAAC;CAIjC,QAAQA,SAAE,QAAQ;CAIlB,WAAWA,SAAE,QAAQ;CAIrB,UAAUA,SAAE,SAASA,SAAE,QAAQ,CAAC;CAIhC,MAAMA,SAAE,MAAMA,SAAE,QAAQ,CAAC;CAIzB,SAASA,SAAE,SAASA,SAAE,QAAQ,CAAC;CAI/B,SAASA,SAAE,SAASA,SAAE,QAAQ,CAAC;CAI/B,QAAQA,SAAE,SAASA,SAAE,QAAQ,CAAC;CAI9B,QAAQA,SAAE,MAAMC,mCAAgB;CAIhC,QAAQD,SAAE,MAAMC,mCAAgB;CAIhC,QAAQD,SAAE,SAASA,SAAE,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0/validators.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { n as SnowflakeSchema, t as ISO8601DateSchema } from "../validators-jGzHB8WZ.cjs";
|
|
1
2
|
import * as z from "zod/mini";
|
|
2
3
|
|
|
3
4
|
//#region src/v0/validators.d.ts
|
|
@@ -601,5 +602,5 @@ declare const UserSchema: z.ZodMiniObject<{
|
|
|
601
602
|
admin: z.ZodMiniBoolean<boolean>;
|
|
602
603
|
}, z.core.$strip>;
|
|
603
604
|
//#endregion
|
|
604
|
-
export { BotSchema, BotVoterSchema, BotWebhookPayloadSchema, GetBotResponseSchema, GetBotStatsResponseSchema, GetLast1000BotVotesResponseSchema, GetSearchBotsQuerySchema, GetSearchBotsResponseSchema, GetUserVoteCheckQuerySchema, GetUserVoteCheckResponseSchema, PostBotStatsBodySchema, ServerWebhookPayloadSchema, UserSchema, WebhookEventTypeSchema };
|
|
605
|
+
export { BotSchema, BotVoterSchema, BotWebhookPayloadSchema, GetBotResponseSchema, GetBotStatsResponseSchema, GetLast1000BotVotesResponseSchema, GetSearchBotsQuerySchema, GetSearchBotsResponseSchema, GetUserVoteCheckQuerySchema, GetUserVoteCheckResponseSchema, ISO8601DateSchema, PostBotStatsBodySchema, ServerWebhookPayloadSchema, SnowflakeSchema, UserSchema, WebhookEventTypeSchema };
|
|
605
606
|
//# sourceMappingURL=validators.d.cts.map
|
package/dist/v0/validators.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { n as SnowflakeSchema, t as ISO8601DateSchema } from "../validators-kCo2qI41.js";
|
|
1
2
|
import * as z from "zod/mini";
|
|
2
3
|
|
|
3
4
|
//#region src/v0/validators.d.ts
|
|
@@ -601,5 +602,5 @@ declare const UserSchema: z.ZodMiniObject<{
|
|
|
601
602
|
admin: z.ZodMiniBoolean<boolean>;
|
|
602
603
|
}, z.core.$strip>;
|
|
603
604
|
//#endregion
|
|
604
|
-
export { BotSchema, BotVoterSchema, BotWebhookPayloadSchema, GetBotResponseSchema, GetBotStatsResponseSchema, GetLast1000BotVotesResponseSchema, GetSearchBotsQuerySchema, GetSearchBotsResponseSchema, GetUserVoteCheckQuerySchema, GetUserVoteCheckResponseSchema, PostBotStatsBodySchema, ServerWebhookPayloadSchema, UserSchema, WebhookEventTypeSchema };
|
|
605
|
+
export { BotSchema, BotVoterSchema, BotWebhookPayloadSchema, GetBotResponseSchema, GetBotStatsResponseSchema, GetLast1000BotVotesResponseSchema, GetSearchBotsQuerySchema, GetSearchBotsResponseSchema, GetUserVoteCheckQuerySchema, GetUserVoteCheckResponseSchema, ISO8601DateSchema, PostBotStatsBodySchema, ServerWebhookPayloadSchema, SnowflakeSchema, UserSchema, WebhookEventTypeSchema };
|
|
605
606
|
//# sourceMappingURL=validators.d.ts.map
|
package/dist/v0/validators.js
CHANGED
|
@@ -158,5 +158,5 @@ const UserSchema = z.object({
|
|
|
158
158
|
});
|
|
159
159
|
|
|
160
160
|
//#endregion
|
|
161
|
-
export { BotSchema, BotVoterSchema, BotWebhookPayloadSchema, GetBotResponseSchema, GetBotStatsResponseSchema, GetLast1000BotVotesResponseSchema, GetSearchBotsQuerySchema, GetSearchBotsResponseSchema, GetUserVoteCheckQuerySchema, GetUserVoteCheckResponseSchema, PostBotStatsBodySchema, ServerWebhookPayloadSchema, UserSchema, WebhookEventTypeSchema };
|
|
161
|
+
export { BotSchema, BotVoterSchema, BotWebhookPayloadSchema, GetBotResponseSchema, GetBotStatsResponseSchema, GetLast1000BotVotesResponseSchema, GetSearchBotsQuerySchema, GetSearchBotsResponseSchema, GetUserVoteCheckQuerySchema, GetUserVoteCheckResponseSchema, ISO8601DateSchema, PostBotStatsBodySchema, ServerWebhookPayloadSchema, SnowflakeSchema, UserSchema, WebhookEventTypeSchema };
|
|
162
162
|
//# sourceMappingURL=validators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.js","names":[],"sources":["../../src/v0/validators.ts"],"sourcesContent":["import * as z from \"zod/mini\";\nimport { ISO8601DateSchema, SnowflakeSchema } from \"@utils/validators\";\n\n// # Bases and Constants\n\n/**\n * The type of a webhook event.\n */\nexport const WebhookEventTypeSchema = z.enum([\"upvote\", \"test\"]);\n\n// # Webhooks - deprecated\n\n/**\n * Webhook payload for bot votes (deprecated).\n *\n * @deprecated Use `v1` types instead.\n */\nexport const BotWebhookPayloadSchema = z.object({\n /**\n * Discord ID of the bot that received a vote.\n */\n bot: SnowflakeSchema,\n /**\n * Discord ID of the user that voted.\n */\n user: SnowflakeSchema,\n /**\n * The type of the vote (should always be \"upvote\" except when using the test button it's \"test\").\n */\n type: WebhookEventTypeSchema,\n /**\n * Whether the weekend multiplier is in effect, meaning users votes count as two.\n */\n isWeekend: z.boolean(),\n /**\n * Query string params found on the /bot/:ID/vote page.\n *\n * @example\n * \"?a=1&b=2&c=3\"\n */\n query: z.optional(z.string()),\n});\n\n/**\n * Webhook payload for server votes (deprecated).\n *\n * @deprecated Use `v1` types instead.\n */\nexport const ServerWebhookPayloadSchema = z.object({\n /**\n * Discord ID of the server that received a vote.\n */\n guild: SnowflakeSchema,\n /**\n * Discord ID of the user that voted.\n */\n user: SnowflakeSchema,\n /**\n * The type of the vote (should always be \"upvote\" except when using the test button it's \"test\").\n */\n type: WebhookEventTypeSchema,\n /**\n * Whether the weekend multiplier is in effect, meaning users votes count as two.\n */\n query: z.optional(z.string()),\n});\n\n// # Bots\n\n/**\n * A bot listed on Top.gg.\n */\nexport const BotSchema = z.object({\n /**\n * The Discord ID of the bot\n */\n id: SnowflakeSchema,\n /**\n * The username of the bot\n */\n username: z.string(),\n /**\n * The discriminator of the bot (legacy Discord feature)\n */\n discriminator: z.string(),\n /**\n * The avatar hash of the bot's avatar\n */\n avatar: z.optional(z.string()),\n /**\n * The cdn hash of the bot's avatar if the bot has none\n */\n defAvatar: z.optional(z.string()),\n /**\n * The command prefix of the bot\n */\n prefix: z.string(),\n /**\n * The short description of the bot\n */\n shortdesc: z.string(),\n /**\n * The detailed long description of the bot\n */\n longdesc: z.optional(z.string()),\n /**\n * Array of tags associated with the bot\n */\n tags: z.array(z.string()),\n /**\n * The official website URL of the bot\n */\n website: z.optional(z.string()),\n /**\n * The support server URL for the bot\n */\n support: z.optional(z.string()),\n /**\n * The GitHub repository URL of the bot\n */\n github: z.optional(z.string()),\n /**\n * Array of snowflake identifiers of the bot owners\n */\n owners: z.array(SnowflakeSchema),\n /**\n * Array of guild snowflake identifiers where the bot is present\n */\n guilds: z.array(SnowflakeSchema),\n /**\n * The OAuth2 invite URL of the bot\n */\n invite: z.optional(z.string()),\n /**\n * The date when the bot was approved on Top.gg in ISO 8601 format\n */\n date: ISO8601DateSchema,\n /**\n * The amount of servers the bot has according to posted stats.\n */\n server_count: z.optional(z.number()),\n /**\n * The amount of shards the bot has according to posted stats.\n */\n shard_count: z.optional(z.number()),\n /**\n * Whether the bot is certified on Top.gg\n */\n certifiedBot: z.boolean(),\n /**\n * The vanity URL of the bot on Top.gg\n */\n vanity: z.optional(z.string()),\n /**\n * The amount of upvotes the bot has\n */\n points: z.number(),\n /**\n * The amount of upvotes the bot has this month\n */\n monthlyPoints: z.number(),\n /**\n * The guild id for the donatebot setup\n */\n donatebotguildid: SnowflakeSchema,\n});\n\n/**\n * Query parameters for searching bots on Top.gg.\n *\n * @see https://docs.top.gg/docs/API/v0/bot#search-bots\n */\nexport const GetSearchBotsQuerySchema = z.object({\n /**\n * The amount of bots to return.\n *\n * @minimum 1\n * @maximum 500\n * @default 50\n */\n limit: z.optional(z.number().check(z.minimum(1)).check(z.maximum(500))),\n /**\n * The amount of bots to skip (for pagination).\n *\n * @minimum 0\n * @default 0\n */\n offset: z.optional(z.number().check(z.minimum(0))),\n /**\n * The field to sort the bots by. Prefix with `-` for descending order.\n *\n * There is no documented default.\n */\n sort: z.string(),\n /**\n * Comma separated list of fields to include in the response. If not provided, all fields will be included.\n */\n fields: z.optional(z.string()),\n});\n\n/**\n * Response for searching bots on Top.gg.\n */\nexport const GetSearchBotsResponseSchema = z.object({\n /**\n * The array of bots that match the search query.\n */\n results: z.array(BotSchema),\n /**\n * The total number of bots that match the search query.\n */\n total: z.number(),\n /**\n * The limit used in the query.\n */\n limit: z.number(),\n /**\n * The amount of bots skipped (for pagination).\n */\n offset: z.number(),\n /**\n * The amount of items in the current page of results.\n */\n count: z.number(),\n});\n\n/**\n * Response for getting a bot.\n *\n * - GET `/bots/:bot_id`\n */\nexport const GetBotResponseSchema = BotSchema;\n\n/**\n * A bot voter.\n */\nexport const BotVoterSchema = z.object({\n /**\n * The Discord ID of the user that voted.\n */\n id: SnowflakeSchema,\n /**\n * The username of the user that voted, including discriminator (e.g., \"wumpus#0000\").\n */\n username: z.string(),\n /**\n * The avatar hash of the user that voted.\n */\n avatar: z.optional(z.string()),\n});\n\n/**\n * Gets the last 1000 voters for your bot.\n *\n * - GET `/bots/:bot_id/votes`\n */\nexport const GetLast1000BotVotesResponseSchema = z.array(BotVoterSchema);\n\n/**\n * Specific stats about a bot.\n *\n * - GET `/bots/:bot_id/stats`\n */\nexport const GetBotStatsResponseSchema = z.object({\n /**\n * The amount of servers the bot is in\n */\n server_count: z.optional(z.number()),\n /**\n * The amount of servers the bot is in per shard. Always present but can be empty.\n */\n shards: z.array(z.number()),\n /**\n * The amount of shards a bot has according to posted stats.\n */\n shard_count: z.optional(z.number()),\n});\n\n/**\n * Query parameters for checking whether or not a user has voted for your bot.\n *\n * - GET `/bots/:bot_id/check`\n */\nexport const GetUserVoteCheckQuerySchema = z.object({\n /**\n * The Discord ID of the user to check for a vote.\n */\n userId: SnowflakeSchema,\n});\n\n/**\n * Response for checking whether or not a user has voted for your bot.\n *\n * - GET `/bots/:bot_id/check`\n */\nexport const GetUserVoteCheckResponseSchema = z.object({\n /**\n * 0 if the user has not voted for this bot in the last 12 hours, 1 if they have.\n */\n voted: z.xor([z.literal(0), z.literal(1)]),\n});\n\n/**\n * Request body for posting bot stats.\n */\nexport const PostBotStatsBodySchema = z.object({\n /**\n * The amount of servers the bot is in. Required if the bot has less than 100 servers, otherwise optional but recommended.\n *\n * If an Array, it acts like shards.\n */\n server_count: z.xor([z.number(), z.array(z.number())]),\n /**\n * Amount of servers the bot is in per shard.\n */\n shards: z.optional(z.array(z.number())),\n /**\n * The zero-indexed id of the shard posting. Makes server_count set the shard specific server count.\n */\n shard_id: z.optional(z.number()),\n /**\n * The amount of shards the bot has.\n */\n shard_count: z.optional(z.number()),\n});\n\n// # Users\n\n/**\n * A user on Top.gg.\n *\n * - GET `/users/:user_id`\n */\nexport const UserSchema = z.object({\n /**\n * The Discord ID for this user.\n */\n id: SnowflakeSchema,\n /**\n * The username of the user, not including discriminator (e.g., \"wumpus\").\n */\n username: z.string(),\n /**\n * The discriminator of the user (legacy Discord feature, e.g., \"0000\").\n */\n discriminator: z.string(),\n /**\n * The avatar hash of the user's avatar.\n */\n avatar: z.optional(z.string()),\n /**\n * The cdn hash of the user's avatar if the user has none.\n */\n defAvatar: z.optional(z.string()),\n /**\n * The bio of the user. This is a short description that the user can set on their profile. It may be empty or null if the user has not set a bio.\n *\n * This is NOT their in-discord bio.\n */\n bio: z.optional(z.string()),\n /**\n * The banner image URL of the user.\n */\n banner: z.optional(z.string()),\n /**\n * The social usernames of the user\n */\n social: z.object({\n /**\n * The YouTube channel ID of the user. This is not the full URL, just the channel ID (e.g., \"UC_x5XG1OV2P6uZZ5FSM9Ttw\").\n */\n youtube: z.optional(z.string()),\n /**\n * The Reddit username of the user (e.g., \"spez\"). This is not the full URL, just the username.\n */\n reddit: z.optional(z.string()),\n /**\n * The Twitter username of the user (e.g., \"jack\"). This is not the full URL, just the username.\n */\n twitter: z.optional(z.string()),\n /**\n * The Instagram username of the user (e.g., \"instagram\"). This is not the full URL, just the username.\n */\n instagram: z.optional(z.string()),\n /**\n * The GitHub username of the user (e.g., \"torvalds\"). This is not the full URL, just the username.\n */\n github: z.optional(z.string()),\n }),\n /**\n * The custom hex color of the user (not guaranteed to be valid hex). This is a color that the user can set on their profile.\n */\n color: z.optional(z.string()),\n /**\n * The supporter status of the user. This is true if the user has voted for any bot in the last month.\n */\n supporter: z.boolean(),\n /**\n * The certified status of the user.\n */\n certifiedDev: z.boolean(),\n /**\n * The mod status of the user. This is true if the user is a moderator on Top.gg.\n */\n mod: z.boolean(),\n /**\n * The website moderator status of the user. This is true if the user is a website moderator on Top.gg.\n */\n webMod: z.boolean(),\n /**\n * The admin status of the user.\n */\n admin: z.boolean(),\n});\n"],"mappings":";;;;;;;AAQA,MAAa,yBAAyB,EAAE,KAAK,CAAC,UAAU,OAAO,CAAC;;;;;;AAShE,MAAa,0BAA0B,EAAE,OAAO;CAI9C,KAAK;CAIL,MAAM;CAIN,MAAM;CAIN,WAAW,EAAE,SAAS;CAOtB,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC;CAC9B,CAAC;;;;;;AAOF,MAAa,6BAA6B,EAAE,OAAO;CAIjD,OAAO;CAIP,MAAM;CAIN,MAAM;CAIN,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC;CAC9B,CAAC;;;;AAOF,MAAa,YAAY,EAAE,OAAO;CAIhC,IAAI;CAIJ,UAAU,EAAE,QAAQ;CAIpB,eAAe,EAAE,QAAQ;CAIzB,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC;CAI9B,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC;CAIjC,QAAQ,EAAE,QAAQ;CAIlB,WAAW,EAAE,QAAQ;CAIrB,UAAU,EAAE,SAAS,EAAE,QAAQ,CAAC;CAIhC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;CAIzB,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC;CAI/B,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC;CAI/B,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC;CAI9B,QAAQ,EAAE,MAAM,gBAAgB;CAIhC,QAAQ,EAAE,MAAM,gBAAgB;CAIhC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC;CAI9B,MAAM;CAIN,cAAc,EA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nowflakeSchema } from \"@utils/validators\";\nexport * from \"@utils/validators\";\n\n// # Bases and Constants\n\n/**\n * The type of a webhook event.\n */\nexport const WebhookEventTypeSchema = z.enum([\"upvote\", \"test\"]);\n\n// # Webhooks - deprecated\n\n/**\n * Webhook payload for bot votes (deprecated).\n *\n * @deprecated Use `v1` types instead.\n */\nexport const BotWebhookPayloadSchema = z.object({\n /**\n * Discord ID of the bot that received a vote.\n */\n bot: SnowflakeSchema,\n /**\n * Discord ID of the user that voted.\n */\n user: SnowflakeSchema,\n /**\n * The type of the vote (should always be \"upvote\" except when using the test button it's \"test\").\n */\n type: WebhookEventTypeSchema,\n /**\n * Whether the weekend multiplier is in effect, meaning users votes count as two.\n */\n isWeekend: z.boolean(),\n /**\n * Query string params found on the /bot/:ID/vote page.\n *\n * @example\n * \"?a=1&b=2&c=3\"\n */\n query: z.optional(z.string()),\n});\n\n/**\n * Webhook payload for server votes (deprecated).\n *\n * @deprecated Use `v1` types instead.\n */\nexport const ServerWebhookPayloadSchema = z.object({\n /**\n * Discord ID of the server that received a vote.\n */\n guild: SnowflakeSchema,\n /**\n * Discord ID of the user that voted.\n */\n user: SnowflakeSchema,\n /**\n * The type of the vote (should always be \"upvote\" except when using the test button it's \"test\").\n */\n type: WebhookEventTypeSchema,\n /**\n * Whether the weekend multiplier is in effect, meaning users votes count as two.\n */\n query: z.optional(z.string()),\n});\n\n// # Bots\n\n/**\n * A bot listed on Top.gg.\n */\nexport const BotSchema = z.object({\n /**\n * The Discord ID of the bot\n */\n id: SnowflakeSchema,\n /**\n * The username of the bot\n */\n username: z.string(),\n /**\n * The discriminator of the bot (legacy Discord feature)\n */\n discriminator: z.string(),\n /**\n * The avatar hash of the bot's avatar\n */\n avatar: z.optional(z.string()),\n /**\n * The cdn hash of the bot's avatar if the bot has none\n */\n defAvatar: z.optional(z.string()),\n /**\n * The command prefix of the bot\n */\n prefix: z.string(),\n /**\n * The short description of the bot\n */\n shortdesc: z.string(),\n /**\n * The detailed long description of the bot\n */\n longdesc: z.optional(z.string()),\n /**\n * Array of tags associated with the bot\n */\n tags: z.array(z.string()),\n /**\n * The official website URL of the bot\n */\n website: z.optional(z.string()),\n /**\n * The support server URL for the bot\n */\n support: z.optional(z.string()),\n /**\n * The GitHub repository URL of the bot\n */\n github: z.optional(z.string()),\n /**\n * Array of snowflake identifiers of the bot owners\n */\n owners: z.array(SnowflakeSchema),\n /**\n * Array of guild snowflake identifiers where the bot is present\n */\n guilds: z.array(SnowflakeSchema),\n /**\n * The OAuth2 invite URL of the bot\n */\n invite: z.optional(z.string()),\n /**\n * The date when the bot was approved on Top.gg in ISO 8601 format\n */\n date: ISO8601DateSchema,\n /**\n * The amount of servers the bot has according to posted stats.\n */\n server_count: z.optional(z.number()),\n /**\n * The amount of shards the bot has according to posted stats.\n */\n shard_count: z.optional(z.number()),\n /**\n * Whether the bot is certified on Top.gg\n */\n certifiedBot: z.boolean(),\n /**\n * The vanity URL of the bot on Top.gg\n */\n vanity: z.optional(z.string()),\n /**\n * The amount of upvotes the bot has\n */\n points: z.number(),\n /**\n * The amount of upvotes the bot has this month\n */\n monthlyPoints: z.number(),\n /**\n * The guild id for the donatebot setup\n */\n donatebotguildid: SnowflakeSchema,\n});\n\n/**\n * Query parameters for searching bots on Top.gg.\n *\n * @see https://docs.top.gg/docs/API/v0/bot#search-bots\n */\nexport const GetSearchBotsQuerySchema = z.object({\n /**\n * The amount of bots to return.\n *\n * @minimum 1\n * @maximum 500\n * @default 50\n */\n limit: z.optional(z.number().check(z.minimum(1)).check(z.maximum(500))),\n /**\n * The amount of bots to skip (for pagination).\n *\n * @minimum 0\n * @default 0\n */\n offset: z.optional(z.number().check(z.minimum(0))),\n /**\n * The field to sort the bots by. Prefix with `-` for descending order.\n *\n * There is no documented default.\n */\n sort: z.string(),\n /**\n * Comma separated list of fields to include in the response. If not provided, all fields will be included.\n */\n fields: z.optional(z.string()),\n});\n\n/**\n * Response for searching bots on Top.gg.\n */\nexport const GetSearchBotsResponseSchema = z.object({\n /**\n * The array of bots that match the search query.\n */\n results: z.array(BotSchema),\n /**\n * The total number of bots that match the search query.\n */\n total: z.number(),\n /**\n * The limit used in the query.\n */\n limit: z.number(),\n /**\n * The amount of bots skipped (for pagination).\n */\n offset: z.number(),\n /**\n * The amount of items in the current page of results.\n */\n count: z.number(),\n});\n\n/**\n * Response for getting a bot.\n *\n * - GET `/bots/:bot_id`\n */\nexport const GetBotResponseSchema = BotSchema;\n\n/**\n * A bot voter.\n */\nexport const BotVoterSchema = z.object({\n /**\n * The Discord ID of the user that voted.\n */\n id: SnowflakeSchema,\n /**\n * The username of the user that voted, including discriminator (e.g., \"wumpus#0000\").\n */\n username: z.string(),\n /**\n * The avatar hash of the user that voted.\n */\n avatar: z.optional(z.string()),\n});\n\n/**\n * Gets the last 1000 voters for your bot.\n *\n * - GET `/bots/:bot_id/votes`\n */\nexport const GetLast1000BotVotesResponseSchema = z.array(BotVoterSchema);\n\n/**\n * Specific stats about a bot.\n *\n * - GET `/bots/:bot_id/stats`\n */\nexport const GetBotStatsResponseSchema = z.object({\n /**\n * The amount of servers the bot is in\n */\n server_count: z.optional(z.number()),\n /**\n * The amount of servers the bot is in per shard. Always present but can be empty.\n */\n shards: z.array(z.number()),\n /**\n * The amount of shards a bot has according to posted stats.\n */\n shard_count: z.optional(z.number()),\n});\n\n/**\n * Query parameters for checking whether or not a user has voted for your bot.\n *\n * - GET `/bots/:bot_id/check`\n */\nexport const GetUserVoteCheckQuerySchema = z.object({\n /**\n * The Discord ID of the user to check for a vote.\n */\n userId: SnowflakeSchema,\n});\n\n/**\n * Response for checking whether or not a user has voted for your bot.\n *\n * - GET `/bots/:bot_id/check`\n */\nexport const GetUserVoteCheckResponseSchema = z.object({\n /**\n * 0 if the user has not voted for this bot in the last 12 hours, 1 if they have.\n */\n voted: z.xor([z.literal(0), z.literal(1)]),\n});\n\n/**\n * Request body for posting bot stats.\n */\nexport const PostBotStatsBodySchema = z.object({\n /**\n * The amount of servers the bot is in. Required if the bot has less than 100 servers, otherwise optional but recommended.\n *\n * If an Array, it acts like shards.\n */\n server_count: z.xor([z.number(), z.array(z.number())]),\n /**\n * Amount of servers the bot is in per shard.\n */\n shards: z.optional(z.array(z.number())),\n /**\n * The zero-indexed id of the shard posting. Makes server_count set the shard specific server count.\n */\n shard_id: z.optional(z.number()),\n /**\n * The amount of shards the bot has.\n */\n shard_count: z.optional(z.number()),\n});\n\n// # Users\n\n/**\n * A user on Top.gg.\n *\n * - GET `/users/:user_id`\n */\nexport const UserSchema = z.object({\n /**\n * The Discord ID for this user.\n */\n id: SnowflakeSchema,\n /**\n * The username of the user, not including discriminator (e.g., \"wumpus\").\n */\n username: z.string(),\n /**\n * The discriminator of the user (legacy Discord feature, e.g., \"0000\").\n */\n discriminator: z.string(),\n /**\n * The avatar hash of the user's avatar.\n */\n avatar: z.optional(z.string()),\n /**\n * The cdn hash of the user's avatar if the user has none.\n */\n defAvatar: z.optional(z.string()),\n /**\n * The bio of the user. This is a short description that the user can set on their profile. It may be empty or null if the user has not set a bio.\n *\n * This is NOT their in-discord bio.\n */\n bio: z.optional(z.string()),\n /**\n * The banner image URL of the user.\n */\n banner: z.optional(z.string()),\n /**\n * The social usernames of the user\n */\n social: z.object({\n /**\n * The YouTube channel ID of the user. This is not the full URL, just the channel ID (e.g., \"UC_x5XG1OV2P6uZZ5FSM9Ttw\").\n */\n youtube: z.optional(z.string()),\n /**\n * The Reddit username of the user (e.g., \"spez\"). This is not the full URL, just the username.\n */\n reddit: z.optional(z.string()),\n /**\n * The Twitter username of the user (e.g., \"jack\"). This is not the full URL, just the username.\n */\n twitter: z.optional(z.string()),\n /**\n * The Instagram username of the user (e.g., \"instagram\"). This is not the full URL, just the username.\n */\n instagram: z.optional(z.string()),\n /**\n * The GitHub username of the user (e.g., \"torvalds\"). This is not the full URL, just the username.\n */\n github: z.optional(z.string()),\n }),\n /**\n * The custom hex color of the user (not guaranteed to be valid hex). This is a color that the user can set on their profile.\n */\n color: z.optional(z.string()),\n /**\n * The supporter status of the user. This is true if the user has voted for any bot in the last month.\n */\n supporter: z.boolean(),\n /**\n * The certified status of the user.\n */\n certifiedDev: z.boolean(),\n /**\n * The mod status of the user. This is true if the user is a moderator on Top.gg.\n */\n mod: z.boolean(),\n /**\n * The website moderator status of the user. This is true if the user is a website moderator on Top.gg.\n */\n webMod: z.boolean(),\n /**\n * The admin status of the user.\n */\n admin: z.boolean(),\n});\n"],"mappings":";;;;;;;AASA,MAAa,yBAAyB,EAAE,KAAK,CAAC,UAAU,OAAO,CAAC;;;;;;AAShE,MAAa,0BAA0B,EAAE,OAAO;CAI9C,KAAK;CAIL,MAAM;CAIN,MAAM;CAIN,WAAW,EAAE,SAAS;CAOtB,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC;CAC9B,CAAC;;;;;;AAOF,MAAa,6BAA6B,EAAE,OAAO;CAIjD,OAAO;CAIP,MAAM;CAIN,MAAM;CAIN,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC;CAC9B,CAAC;;;;AAOF,MAAa,YAAY,EAAE,OAAO;CAIhC,IAAI;CAIJ,UAAU,EAAE,QAAQ;CAIpB,eAAe,EAAE,QAAQ;CAIzB,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC;CAI9B,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC;CAIjC,QAAQ,EAAE,QAAQ;CAIlB,WAAW,EAAE,QAAQ;CAIrB,UAAU,EAAE,SAAS,EAAE,QAAQ,CAAC;CAIhC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;CAIzB,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC;CAI/B,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC;CAI/B,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC;CAI9B,QAAQ,EAAE,MAAM,gBAAgB;CAIhC,QAAQ,EAAE,MAAM,gBAAgB;CAIhC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC;CAI9B,MAAM;CAIN,cAAc,EAA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.GetProjectVotesResponseSchema = GetProjectVotesResponseSchema;
|
|
211
211
|
exports.GetVoteStatusByUserQuerySchema = GetVoteStatusByUserQuerySchema;
|
|
212
212
|
exports.GetVoteStatusByUserResponseSchema = GetVoteStatusByUserResponseSchema;
|
|
213
|
+
exports.ISO8601DateSchema = require_validators.ISO8601DateSchema;
|
|
213
214
|
exports.IntegrationCreateDataSchema = IntegrationCreateDataSchema;
|
|
214
215
|
exports.IntegrationCreateResponseSchema = IntegrationCreateResponseSchema;
|
|
215
216
|
exports.IntegrationCreateWebhookPayloadSchema = IntegrationCreateWebhookPayloadSchema;
|
|
@@ -219,6 +220,7 @@ exports.IntegrationSupportedWebhookScopesSchema = IntegrationSupportedWebhookSco
|
|
|
219
220
|
exports.ProjectPlatformTypeSchema = ProjectPlatformTypeSchema;
|
|
220
221
|
exports.ProjectTypeSchema = ProjectTypeSchema;
|
|
221
222
|
exports.ProjectVoteSchema = ProjectVoteSchema;
|
|
223
|
+
exports.SnowflakeSchema = require_validators.SnowflakeSchema;
|
|
222
224
|
exports.UserSchema = UserSchema;
|
|
223
225
|
exports.UserSourceSchema = UserSourceSchema;
|
|
224
226
|
exports.VoteCreateDataSchema = VoteCreateDataSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.cjs","names":["z","SnowflakeSchema","ISO8601DateSchema"],"sources":["../../src/v1/validators.ts"],"sourcesContent":["import * as z from \"zod/mini\";\nimport { ISO8601DateSchema, SnowflakeSchema } from \"@utils/validators\";\n\n// # General and Base Schemas\n\n// ## Enums and Constants\n\n/**\n * The type of a webhook event. This is used to identify the type of the event that is being delivered to your webhook endpoint.\n *\n * Not all webhook events are allowed to be set by an integration - use the `IntegrationSupportedWebhookScopesSchema` to find out which events you can subscribe to as an integration.\n */\nexport const WebhookEventTypeSchema = z.enum([\n \"webhook.test\",\n \"integration.create\",\n \"integration.delete\",\n \"vote.create\",\n]);\n\n/**\n * The type of a project helps top.gg synchronize features.\n * For example, a discord bot may have a support server, but this would not make any sense for a discord server.\n *\n * You can use this to further find out the specificity of the project.\n */\nexport const ProjectTypeSchema = z.enum([\"bot\", \"server\", \"game\"]);\n\n/**\n * A Platform is used to identify where the corresponding ID links towards.\n */\nexport const ProjectPlatformTypeSchema = z.enum([\"discord\", \"roblox\"]);\n\n/**\n * A User Source is an enum that represents a user account from an external platform that is linked to a Top.gg user account.\n * Each source has a unique identifer type that we might validate against.\n *\n * If none is passed to any endpoint that accepts a source parameter, it will default to topgg.\n */\nexport const UserSourceSchema = z.enum([\"discord\", \"topgg\"]);\n\n/**\n * Webhook scopes that are supported for integrations.\n */\nexport const IntegrationSupportedWebhookScopesSchema = z.enum([\"webhook.test\", \"vote.create\"]);\n\n/**\n * All error responses follow the [`application/problem+json`](https://datatracker.ietf.org/doc/html/rfc7807) specification.\n */\nexport const ErrorSchema = z.object({\n type: z.string(),\n title: z.string(),\n status: z.number(),\n detail: z.string(),\n});\n\n/**\n * Represents a user on Top.gg.\n */\nexport const UserSchema = z.object({\n /**\n * The user's Top.gg ID.\n */\n id: SnowflakeSchema,\n /**\n * The user's platform ID (e.g., Discord ID).\n */\n platform_id: SnowflakeSchema,\n /**\n * The user's username.\n */\n name: z.string(),\n /**\n * The URL of the user's avatar.\n */\n avatar_url: z.url(),\n});\n\n/**\n * Base project information shared across all project-related responses.\n */\nexport const BaseProjectSchema = z.object({\n /**\n * The project's Top.gg ID.\n */\n id: SnowflakeSchema,\n /**\n * The platform the project is on (e.g., \"discord\").\n */\n platform: ProjectPlatformTypeSchema,\n /**\n * The platform-specific ID of the project (e.g., Discord Bot ID).\n */\n platform_id: SnowflakeSchema,\n /**\n * The type of project (e.g., \"bot\").\n */\n type: ProjectTypeSchema,\n});\n\n/**\n * Represents a vote on Top.gg.\n */\nexport const VoteSchema = z.object({\n /**\n * The Top.gg ID of the user who voted.\n */\n user_id: SnowflakeSchema,\n /**\n * The user's ID on the project's platform (e.g., Discord ID).\n */\n platform_id: SnowflakeSchema,\n /**\n * The amount of votes this vote counted for.\n */\n weight: z.number(),\n /**\n * The timestamp of when the user voted.\n */\n created_at: ISO8601DateSchema,\n /**\n * The timestamp of when the vote expires (i.e., when the user can vote again).\n * This is typically 12 hours after the `created_at` timestamp, but may vary based on the user's voting history and other factors.\n */\n expires_at: ISO8601DateSchema,\n});\n\n/**\n * Represents a vote for a specific project.\n */\nexport const ProjectVoteSchema = z.clone(VoteSchema);\n\nexport const WebhookPayloadBaseSchema = <\n T extends z.infer<typeof WebhookEventTypeSchema>,\n Data extends z.ZodMiniObject,\n>(\n type: T,\n data: Data\n) =>\n z.object({\n type: z.literal(type),\n data: data,\n });\n\n// # Specific Schemas\n\n// ## Integration Schemas\n\n/**\n * Data included when an integration connection is created.\n */\nexport const IntegrationCreateDataSchema = z.object({\n /**\n * The unique identifier for this integration connection.\n */\n connection_id: SnowflakeSchema,\n /**\n * The webhook secret used to verify webhook requests from Top.gg for this connection.\n */\n webhook_secret: z.string().check(z.regex(/^whs_[a-zA-Z0-9]+$/, \"Invalid webhook secret\")),\n /**\n * The project this integration is connected to.\n */\n project: BaseProjectSchema,\n /**\n * The user who created this integration connection.\n */\n user: UserSchema,\n});\n\n/**\n * The payload delivered to your webhook endpoint when an integration connection is created.\n * This will be sent if a user clicks \"Connect\" for your integration on the dashboard.\n *\n * @see https://docs.top.gg/docs/API/v1/integrations#2-topgg-sends-integrationcreate\n */\nexport const IntegrationCreateWebhookPayloadSchema = WebhookPayloadBaseSchema(\n \"integration.create\",\n IntegrationCreateDataSchema\n);\n\n/**\n * The response you must return from your webhook endpoint when you receive an `integration.create` event.\n * This tells Top.gg where to deliver webhook events for this integration connection and which events to deliver.\n *\n * @see https://docs.top.gg/docs/API/v1/integrations#3-respond-with-configuration\n */\nexport const IntegrationCreateResponseSchema = z.object({\n /**\n * The URL where Top.gg should deliver webhook events for this connection.\n */\n webhook_url: z.url(),\n /**\n * An array of webhook scopes to subscribe to.\n *\n * @see https://docs.top.gg/docs/API/v1/webhooks#supported-scopes\n */\n routes: z\n .array(IntegrationSupportedWebhookScopesSchema)\n .check(\n z.refine(\n (arr) => arr.length === new Set(arr).size,\n \"Duplicate webhook scopes are not allowed\"\n )\n ),\n});\n\n/**\n * Data included when an integration connection is deleted.\n */\nexport const IntegrationDeleteDataSchema = z.object({\n /**\n * The unique identifier for the integration connection that was deleted.\n */\n connection_id: SnowflakeSchema,\n});\n\n/**\n * The payload delivered to your webhook endpoint when an integration connection is deleted.\n */\nexport const IntegrationDeleteWebhookPayloadSchema = WebhookPayloadBaseSchema(\n \"integration.delete\",\n IntegrationDeleteDataSchema\n);\n\n// ## Vote Schemas\n\n/**\n * Data included when a vote is created.\n */\nexport const VoteCreateDataSchema = z.extend(VoteSchema, {\n /**\n * The project that was voted for.\n */\n project: BaseProjectSchema,\n /**\n * The user who voted.\n */\n user: UserSchema,\n});\n\n/**\n * The payload delivered to your webhook endpoint when a user votes for your project and you have subscribed to the `vote.create` event.\n */\nexport const VoteCreateWebhookPayloadSchema = WebhookPayloadBaseSchema(\n \"vote.create\",\n VoteCreateDataSchema\n);\n\n// ## Webhook Test Schemas\n\n/**\n * Data included in a webhook test event.\n */\nexport const WebhookTestDataSchema = z.object({\n /**\n * A test user.\n */\n user: UserSchema,\n /**\n * A test project.\n */\n project: BaseProjectSchema,\n});\n\n/**\n * The payload delivered to your webhook endpoint when you send a test webhook from the dashboard or via the API.\n */\nexport const WebhookTestWebhookPayloadSchema = WebhookPayloadBaseSchema(\n \"webhook.test\",\n WebhookTestDataSchema\n);\n\n// ## Project Schemas\n\n/**\n * Response schema for getting the authenticated project.\n *\n * - GET `/v1/projects/@me`\n *\n * @see https://docs.top.gg/docs/API/v1/projects#get-current-project\n */\nexport const GetProjectResponseSchema = z.extend(BaseProjectSchema, {\n /**\n * The project's name.\n */\n name: z.string(),\n /**\n * The project's headline/tagline.\n */\n headline: z.string(),\n /**\n * Tags associated with the project.\n */\n tags: z.array(z.string()),\n /**\n * The number of votes this month.\n */\n votes: z.number(),\n /**\n * The total number of votes all time.\n */\n votes_total: z.number(),\n /**\n * The average review score.\n */\n review_score: z.number(),\n /**\n * The number of reviews.\n */\n review_count: z.number(),\n});\n\n/**\n * Query parameters for getting project votes.\n *\n * - GET `/v1/projects/@me/votes`\n *\n * Either `cursor` or `startDate` must be provided.\n *\n * @see https://docs.top.gg/docs/API/v1/projects/#get-votes\n */\nexport const GetProjectVotesQuerySchema = z\n .object({\n /**\n * Pagination cursor for fetching the next page of votes. if provided, `startDate` is ignored.\n *\n * From the previous response.\n */\n cursor: z.optional(z.string()),\n /**\n * The start date for fetching votes. Only votes created after this date will be returned. Required if `cursor` is not provided.\n *\n * Maximum 1 year in the past.\n *\n * ISO 8601 date string.\n */\n startDate: z.optional(ISO8601DateSchema),\n })\n .check(\n z.refine((data) => data.cursor || data.startDate, \"Either cursor or startDate must be provided\")\n );\n\n/**\n * Response schema for the Get Project Votes endpoint.\n *\n * - GET `/v1/projects/@me/votes`\n *\n * @see https://docs.top.gg/docs/API/v1/projects/#get-votes\n */\nexport const GetProjectVotesResponseSchema = z.object({\n /**\n * Cursor for fetching the next page of votes.\n */\n cursor: z.string(),\n /**\n * An array of votes for the project.\n */\n data: z.array(ProjectVoteSchema),\n});\n\n/**\n * Query parameters for getting vote status by user.\n *\n * - GET `/v1/projects/@me/votes/:user_id`\n *\n * @see https://docs.top.gg/docs/API/v1/projects/#get-vote-status-by-user\n */\nexport const GetVoteStatusByUserQuerySchema = z.object({\n /**\n * The source of the user ID. Defaults to \"topgg\".\n */\n source: z.optional(UserSourceSchema),\n});\n\n/**\n * Response schema for the Get Vote Status By User endpoint.\n *\n * - GET `/v1/projects/@me/votes/:user_id`\n *\n * @see https://docs.top.gg/docs/API/v1/projects/#get-vote-status-by-user\n */\nexport const GetVoteStatusByUserResponseSchema = z.object({\n /**\n * The timestamp of when the user last voted.\n */\n created_at: ISO8601DateSchema,\n /**\n * The timestamp of when the user's vote expires (i.e., when they can vote again).\n */\n expires_at: ISO8601DateSchema,\n /**\n * The amount of vot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,CAAC;;;;;;;;AASF,MAAa,oCAAoCA,SAAE,OAAO;CAIxD,YAAYE;CAIZ,YAAYA;CAIZ,QAAQF,SAAE,QAAQ;CACnB,CAAC"}
|
|
1
|
+
{"version":3,"file":"validators.cjs","names":["z","SnowflakeSchema","ISO8601DateSchema"],"sources":["../../src/v1/validators.ts"],"sourcesContent":["import * as z from \"zod/mini\";\nimport { ISO8601DateSchema, SnowflakeSchema } from \"@utils/validators\";\nexport * from \"@utils/validators\";\n\n// # General and Base Schemas\n\n// ## Enums and Constants\n\n/**\n * The type of a webhook event. This is used to identify the type of the event that is being delivered to your webhook endpoint.\n *\n * Not all webhook events are allowed to be set by an integration - use the `IntegrationSupportedWebhookScopesSchema` to find out which events you can subscribe to as an integration.\n */\nexport const WebhookEventTypeSchema = z.enum([\n \"webhook.test\",\n \"integration.create\",\n \"integration.delete\",\n \"vote.create\",\n]);\n\n/**\n * The type of a project helps top.gg synchronize features.\n * For example, a discord bot may have a support server, but this would not make any sense for a discord server.\n *\n * You can use this to further find out the specificity of the project.\n */\nexport const ProjectTypeSchema = z.enum([\"bot\", \"server\", \"game\"]);\n\n/**\n * A Platform is used to identify where the corresponding ID links towards.\n */\nexport const ProjectPlatformTypeSchema = z.enum([\"discord\", \"roblox\"]);\n\n/**\n * A User Source is an enum that represents a user account from an external platform that is linked to a Top.gg user account.\n * Each source has a unique identifer type that we might validate against.\n *\n * If none is passed to any endpoint that accepts a source parameter, it will default to topgg.\n */\nexport const UserSourceSchema = z.enum([\"discord\", \"topgg\"]);\n\n/**\n * Webhook scopes that are supported for integrations.\n */\nexport const IntegrationSupportedWebhookScopesSchema = z.enum([\"webhook.test\", \"vote.create\"]);\n\n/**\n * All error responses follow the [`application/problem+json`](https://datatracker.ietf.org/doc/html/rfc7807) specification.\n */\nexport const ErrorSchema = z.object({\n type: z.string(),\n title: z.string(),\n status: z.number(),\n detail: z.string(),\n});\n\n/**\n * Represents a user on Top.gg.\n */\nexport const UserSchema = z.object({\n /**\n * The user's Top.gg ID.\n */\n id: SnowflakeSchema,\n /**\n * The user's platform ID (e.g., Discord ID).\n */\n platform_id: SnowflakeSchema,\n /**\n * The user's username.\n */\n name: z.string(),\n /**\n * The URL of the user's avatar.\n */\n avatar_url: z.url(),\n});\n\n/**\n * Base project information shared across all project-related responses.\n */\nexport const BaseProjectSchema = z.object({\n /**\n * The project's Top.gg ID.\n */\n id: SnowflakeSchema,\n /**\n * The platform the project is on (e.g., \"discord\").\n */\n platform: ProjectPlatformTypeSchema,\n /**\n * The platform-specific ID of the project (e.g., Discord Bot ID).\n */\n platform_id: SnowflakeSchema,\n /**\n * The type of project (e.g., \"bot\").\n */\n type: ProjectTypeSchema,\n});\n\n/**\n * Represents a vote on Top.gg.\n */\nexport const VoteSchema = z.object({\n /**\n * The Top.gg ID of the user who voted.\n */\n user_id: SnowflakeSchema,\n /**\n * The user's ID on the project's platform (e.g., Discord ID).\n */\n platform_id: SnowflakeSchema,\n /**\n * The amount of votes this vote counted for.\n */\n weight: z.number(),\n /**\n * The timestamp of when the user voted.\n */\n created_at: ISO8601DateSchema,\n /**\n * The timestamp of when the vote expires (i.e., when the user can vote again).\n * This is typically 12 hours after the `created_at` timestamp, but may vary based on the user's voting history and other factors.\n */\n expires_at: ISO8601DateSchema,\n});\n\n/**\n * Represents a vote for a specific project.\n */\nexport const ProjectVoteSchema = z.clone(VoteSchema);\n\nexport const WebhookPayloadBaseSchema = <\n T extends z.infer<typeof WebhookEventTypeSchema>,\n Data extends z.ZodMiniObject,\n>(\n type: T,\n data: Data\n) =>\n z.object({\n type: z.literal(type),\n data: data,\n });\n\n// # Specific Schemas\n\n// ## Integration Schemas\n\n/**\n * Data included when an integration connection is created.\n */\nexport const IntegrationCreateDataSchema = z.object({\n /**\n * The unique identifier for this integration connection.\n */\n connection_id: SnowflakeSchema,\n /**\n * The webhook secret used to verify webhook requests from Top.gg for this connection.\n */\n webhook_secret: z.string().check(z.regex(/^whs_[a-zA-Z0-9]+$/, \"Invalid webhook secret\")),\n /**\n * The project this integration is connected to.\n */\n project: BaseProjectSchema,\n /**\n * The user who created this integration connection.\n */\n user: UserSchema,\n});\n\n/**\n * The payload delivered to your webhook endpoint when an integration connection is created.\n * This will be sent if a user clicks \"Connect\" for your integration on the dashboard.\n *\n * @see https://docs.top.gg/docs/API/v1/integrations#2-topgg-sends-integrationcreate\n */\nexport const IntegrationCreateWebhookPayloadSchema = WebhookPayloadBaseSchema(\n \"integration.create\",\n IntegrationCreateDataSchema\n);\n\n/**\n * The response you must return from your webhook endpoint when you receive an `integration.create` event.\n * This tells Top.gg where to deliver webhook events for this integration connection and which events to deliver.\n *\n * @see https://docs.top.gg/docs/API/v1/integrations#3-respond-with-configuration\n */\nexport const IntegrationCreateResponseSchema = z.object({\n /**\n * The URL where Top.gg should deliver webhook events for this connection.\n */\n webhook_url: z.url(),\n /**\n * An array of webhook scopes to subscribe to.\n *\n * @see https://docs.top.gg/docs/API/v1/webhooks#supported-scopes\n */\n routes: z\n .array(IntegrationSupportedWebhookScopesSchema)\n .check(\n z.refine(\n (arr) => arr.length === new Set(arr).size,\n \"Duplicate webhook scopes are not allowed\"\n )\n ),\n});\n\n/**\n * Data included when an integration connection is deleted.\n */\nexport const IntegrationDeleteDataSchema = z.object({\n /**\n * The unique identifier for the integration connection that was deleted.\n */\n connection_id: SnowflakeSchema,\n});\n\n/**\n * The payload delivered to your webhook endpoint when an integration connection is deleted.\n */\nexport const IntegrationDeleteWebhookPayloadSchema = WebhookPayloadBaseSchema(\n \"integration.delete\",\n IntegrationDeleteDataSchema\n);\n\n// ## Vote Schemas\n\n/**\n * Data included when a vote is created.\n */\nexport const VoteCreateDataSchema = z.extend(VoteSchema, {\n /**\n * The project that was voted for.\n */\n project: BaseProjectSchema,\n /**\n * The user who voted.\n */\n user: UserSchema,\n});\n\n/**\n * The payload delivered to your webhook endpoint when a user votes for your project and you have subscribed to the `vote.create` event.\n */\nexport const VoteCreateWebhookPayloadSchema = WebhookPayloadBaseSchema(\n \"vote.create\",\n VoteCreateDataSchema\n);\n\n// ## Webhook Test Schemas\n\n/**\n * Data included in a webhook test event.\n */\nexport const WebhookTestDataSchema = z.object({\n /**\n * A test user.\n */\n user: UserSchema,\n /**\n * A test project.\n */\n project: BaseProjectSchema,\n});\n\n/**\n * The payload delivered to your webhook endpoint when you send a test webhook from the dashboard or via the API.\n */\nexport const WebhookTestWebhookPayloadSchema = WebhookPayloadBaseSchema(\n \"webhook.test\",\n WebhookTestDataSchema\n);\n\n// ## Project Schemas\n\n/**\n * Response schema for getting the authenticated project.\n *\n * - GET `/v1/projects/@me`\n *\n * @see https://docs.top.gg/docs/API/v1/projects#get-current-project\n */\nexport const GetProjectResponseSchema = z.extend(BaseProjectSchema, {\n /**\n * The project's name.\n */\n name: z.string(),\n /**\n * The project's headline/tagline.\n */\n headline: z.string(),\n /**\n * Tags associated with the project.\n */\n tags: z.array(z.string()),\n /**\n * The number of votes this month.\n */\n votes: z.number(),\n /**\n * The total number of votes all time.\n */\n votes_total: z.number(),\n /**\n * The average review score.\n */\n review_score: z.number(),\n /**\n * The number of reviews.\n */\n review_count: z.number(),\n});\n\n/**\n * Query parameters for getting project votes.\n *\n * - GET `/v1/projects/@me/votes`\n *\n * Either `cursor` or `startDate` must be provided.\n *\n * @see https://docs.top.gg/docs/API/v1/projects/#get-votes\n */\nexport const GetProjectVotesQuerySchema = z\n .object({\n /**\n * Pagination cursor for fetching the next page of votes. if provided, `startDate` is ignored.\n *\n * From the previous response.\n */\n cursor: z.optional(z.string()),\n /**\n * The start date for fetching votes. Only votes created after this date will be returned. Required if `cursor` is not provided.\n *\n * Maximum 1 year in the past.\n *\n * ISO 8601 date string.\n */\n startDate: z.optional(ISO8601DateSchema),\n })\n .check(\n z.refine((data) => data.cursor || data.startDate, \"Either cursor or startDate must be provided\")\n );\n\n/**\n * Response schema for the Get Project Votes endpoint.\n *\n * - GET `/v1/projects/@me/votes`\n *\n * @see https://docs.top.gg/docs/API/v1/projects/#get-votes\n */\nexport const GetProjectVotesResponseSchema = z.object({\n /**\n * Cursor for fetching the next page of votes.\n */\n cursor: z.string(),\n /**\n * An array of votes for the project.\n */\n data: z.array(ProjectVoteSchema),\n});\n\n/**\n * Query parameters for getting vote status by user.\n *\n * - GET `/v1/projects/@me/votes/:user_id`\n *\n * @see https://docs.top.gg/docs/API/v1/projects/#get-vote-status-by-user\n */\nexport const GetVoteStatusByUserQuerySchema = z.object({\n /**\n * The source of the user ID. Defaults to \"topgg\".\n */\n source: z.optional(UserSourceSchema),\n});\n\n/**\n * Response schema for the Get Vote Status By User endpoint.\n *\n * - GET `/v1/projects/@me/votes/:user_id`\n *\n * @see https://docs.top.gg/docs/API/v1/projects/#get-vote-status-by-user\n */\nexport const GetVoteStatusByUserResponseSchema = z.object({\n /**\n * The timestamp of when the user last voted.\n */\n created_at: ISO8601DateSchema,\n /**\n * The timestamp of when the user's vote expires (i.e., when they can vote again).\n */\n expires_at: ISO8601DateSchema,\n /**\n * The amount of votes this vote counted for.\n */\n weight: z.number(),\n});\n"],"mappings":";;;;;;;;;;AAaA,MAAa,yBAAyBA,SAAE,KAAK;CAC3C;CACA;CACA;CACA;CACD,CAAC;;;;;;;AAQF,MAAa,oBAAoBA,SAAE,KAAK;CAAC;CAAO;CAAU;CAAO,CAAC;;;;AAKlE,MAAa,4BAA4BA,SAAE,KAAK,CAAC,WAAW,SAAS,CAAC;;;;;;;AAQtE,MAAa,mBAAmBA,SAAE,KAAK,CAAC,WAAW,QAAQ,CAAC;;;;AAK5D,MAAa,0CAA0CA,SAAE,KAAK,CAAC,gBAAgB,cAAc,CAAC;;;;AAK9F,MAAa,cAAcA,SAAE,OAAO;CAClC,MAAMA,SAAE,QAAQ;CAChB,OAAOA,SAAE,QAAQ;CACjB,QAAQA,SAAE,QAAQ;CAClB,QAAQA,SAAE,QAAQ;CACnB,CAAC;;;;AAKF,MAAa,aAAaA,SAAE,OAAO;CAIjC,IAAIC;CAIJ,aAAaA;CAIb,MAAMD,SAAE,QAAQ;CAIhB,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IhB,UAAUA,SAAE,QAAQ;CAIpB,MAAMA,SAAE,MAAMA,SAAE,QAAQ,CAAC;CAIzB,OAAOA,SAAE,QAAQ;CAIjB,aAAaA,SAAE,QAAQ;CAIvB,cAAcA,SAAE,QAAQ;CAIxB,cAAcA,SAAE,QAAQ;CACzB,CAAC;;;;;;;;;;AAWF,MAAa,6BAA6BA,SACvC,OAAO;CAMN,QAAQA,SAAE,SAASA,SAAE,QAAQ,CAAC;CAQ9B,WAAWA,SAAE,SAASE,qCAAkB;CACzC,CAAC,CACD,MACCF,SAAE,QAAQ,SAAS,KAAK,UAAU,KAAK,WAAW,8CAA8C,CACjG;;;;;;;;AASH,MAAa,gCAAgCA,SAAE,OAAO;CAIpD,QAAQA,SAAE,QAAQ;CAIlB,MAAMA,SAAE,MAAM,kBAAkB;CACjC,CAAC;;;;;;;;AASF,MAAa,iCAAiCA,SAAE,OAAO,EAIrD,QAAQA,SAAE,SAAS,iBAAiB,EACrC,CAAC;;;;;;;;AASF,MAAa,oCAAoCA,SAAE,OAAO;CAIxD,YAAYE;CAIZ,YAAYA;CAIZ,QAAQF,SAAE,QAAQ;CACnB,CAAC"}
|
package/dist/v1/validators.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { n as SnowflakeSchema, t as ISO8601DateSchema } from "../validators-jGzHB8WZ.cjs";
|
|
1
2
|
import * as z from "zod/mini";
|
|
2
3
|
|
|
3
4
|
//#region src/v1/validators.d.ts
|
|
@@ -683,5 +684,5 @@ declare const GetVoteStatusByUserResponseSchema: z.ZodMiniObject<{
|
|
|
683
684
|
weight: z.ZodMiniNumber<number>;
|
|
684
685
|
}, z.core.$strip>;
|
|
685
686
|
//#endregion
|
|
686
|
-
export { BaseProjectSchema, ErrorSchema, GetProjectResponseSchema, GetProjectVotesQuerySchema, GetProjectVotesResponseSchema, GetVoteStatusByUserQuerySchema, GetVoteStatusByUserResponseSchema, IntegrationCreateDataSchema, IntegrationCreateResponseSchema, IntegrationCreateWebhookPayloadSchema, IntegrationDeleteDataSchema, IntegrationDeleteWebhookPayloadSchema, IntegrationSupportedWebhookScopesSchema, ProjectPlatformTypeSchema, ProjectTypeSchema, ProjectVoteSchema, UserSchema, UserSourceSchema, VoteCreateDataSchema, VoteCreateWebhookPayloadSchema, VoteSchema, WebhookEventTypeSchema, WebhookPayloadBaseSchema, WebhookTestDataSchema, WebhookTestWebhookPayloadSchema };
|
|
687
|
+
export { BaseProjectSchema, ErrorSchema, GetProjectResponseSchema, GetProjectVotesQuerySchema, GetProjectVotesResponseSchema, GetVoteStatusByUserQuerySchema, GetVoteStatusByUserResponseSchema, ISO8601DateSchema, IntegrationCreateDataSchema, IntegrationCreateResponseSchema, IntegrationCreateWebhookPayloadSchema, IntegrationDeleteDataSchema, IntegrationDeleteWebhookPayloadSchema, IntegrationSupportedWebhookScopesSchema, ProjectPlatformTypeSchema, ProjectTypeSchema, ProjectVoteSchema, SnowflakeSchema, UserSchema, UserSourceSchema, VoteCreateDataSchema, VoteCreateWebhookPayloadSchema, VoteSchema, WebhookEventTypeSchema, WebhookPayloadBaseSchema, WebhookTestDataSchema, WebhookTestWebhookPayloadSchema };
|
|
687
688
|
//# sourceMappingURL=validators.d.cts.map
|
package/dist/v1/validators.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { n as SnowflakeSchema, t as ISO8601DateSchema } from "../validators-kCo2qI41.js";
|
|
1
2
|
import * as z from "zod/mini";
|
|
2
3
|
|
|
3
4
|
//#region src/v1/validators.d.ts
|
|
@@ -683,5 +684,5 @@ declare const GetVoteStatusByUserResponseSchema: z.ZodMiniObject<{
|
|
|
683
684
|
weight: z.ZodMiniNumber<number>;
|
|
684
685
|
}, z.core.$strip>;
|
|
685
686
|
//#endregion
|
|
686
|
-
export { BaseProjectSchema, ErrorSchema, GetProjectResponseSchema, GetProjectVotesQuerySchema, GetProjectVotesResponseSchema, GetVoteStatusByUserQuerySchema, GetVoteStatusByUserResponseSchema, IntegrationCreateDataSchema, IntegrationCreateResponseSchema, IntegrationCreateWebhookPayloadSchema, IntegrationDeleteDataSchema, IntegrationDeleteWebhookPayloadSchema, IntegrationSupportedWebhookScopesSchema, ProjectPlatformTypeSchema, ProjectTypeSchema, ProjectVoteSchema, UserSchema, UserSourceSchema, VoteCreateDataSchema, VoteCreateWebhookPayloadSchema, VoteSchema, WebhookEventTypeSchema, WebhookPayloadBaseSchema, WebhookTestDataSchema, WebhookTestWebhookPayloadSchema };
|
|
687
|
+
export { BaseProjectSchema, ErrorSchema, GetProjectResponseSchema, GetProjectVotesQuerySchema, GetProjectVotesResponseSchema, GetVoteStatusByUserQuerySchema, GetVoteStatusByUserResponseSchema, ISO8601DateSchema, IntegrationCreateDataSchema, IntegrationCreateResponseSchema, IntegrationCreateWebhookPayloadSchema, IntegrationDeleteDataSchema, IntegrationDeleteWebhookPayloadSchema, IntegrationSupportedWebhookScopesSchema, ProjectPlatformTypeSchema, ProjectTypeSchema, ProjectVoteSchema, SnowflakeSchema, UserSchema, UserSourceSchema, VoteCreateDataSchema, VoteCreateWebhookPayloadSchema, VoteSchema, WebhookEventTypeSchema, WebhookPayloadBaseSchema, WebhookTestDataSchema, WebhookTestWebhookPayloadSchema };
|
|
687
688
|
//# sourceMappingURL=validators.d.ts.map
|
package/dist/v1/validators.js
CHANGED
|
@@ -202,5 +202,5 @@ const GetVoteStatusByUserResponseSchema = z.object({
|
|
|
202
202
|
});
|
|
203
203
|
|
|
204
204
|
//#endregion
|
|
205
|
-
export { BaseProjectSchema, ErrorSchema, GetProjectResponseSchema, GetProjectVotesQuerySchema, GetProjectVotesResponseSchema, GetVoteStatusByUserQuerySchema, GetVoteStatusByUserResponseSchema, IntegrationCreateDataSchema, IntegrationCreateResponseSchema, IntegrationCreateWebhookPayloadSchema, IntegrationDeleteDataSchema, IntegrationDeleteWebhookPayloadSchema, IntegrationSupportedWebhookScopesSchema, ProjectPlatformTypeSchema, ProjectTypeSchema, ProjectVoteSchema, UserSchema, UserSourceSchema, VoteCreateDataSchema, VoteCreateWebhookPayloadSchema, VoteSchema, WebhookEventTypeSchema, WebhookPayloadBaseSchema, WebhookTestDataSchema, WebhookTestWebhookPayloadSchema };
|
|
205
|
+
export { BaseProjectSchema, ErrorSchema, GetProjectResponseSchema, GetProjectVotesQuerySchema, GetProjectVotesResponseSchema, GetVoteStatusByUserQuerySchema, GetVoteStatusByUserResponseSchema, ISO8601DateSchema, IntegrationCreateDataSchema, IntegrationCreateResponseSchema, IntegrationCreateWebhookPayloadSchema, IntegrationDeleteDataSchema, IntegrationDeleteWebhookPayloadSchema, IntegrationSupportedWebhookScopesSchema, ProjectPlatformTypeSchema, ProjectTypeSchema, ProjectVoteSchema, SnowflakeSchema, UserSchema, UserSourceSchema, VoteCreateDataSchema, VoteCreateWebhookPayloadSchema, VoteSchema, WebhookEventTypeSchema, WebhookPayloadBaseSchema, WebhookTestDataSchema, WebhookTestWebhookPayloadSchema };
|
|
206
206
|
//# sourceMappingURL=validators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.js","names":[],"sources":["../../src/v1/validators.ts"],"sourcesContent":["import * as z from \"zod/mini\";\nimport { ISO8601DateSchema, SnowflakeSchema } from \"@utils/validators\";\n\n// # General and Base Schemas\n\n// ## Enums and Constants\n\n/**\n * The type of a webhook event. This is used to identify the type of the event that is being delivered to your webhook endpoint.\n *\n * Not all webhook events are allowed to be set by an integration - use the `IntegrationSupportedWebhookScopesSchema` to find out which events you can subscribe to as an integration.\n */\nexport const WebhookEventTypeSchema = z.enum([\n \"webhook.test\",\n \"integration.create\",\n \"integration.delete\",\n \"vote.create\",\n]);\n\n/**\n * The type of a project helps top.gg synchronize features.\n * For example, a discord bot may have a support server, but this would not make any sense for a discord server.\n *\n * You can use this to further find out the specificity of the project.\n */\nexport const ProjectTypeSchema = z.enum([\"bot\", \"server\", \"game\"]);\n\n/**\n * A Platform is used to identify where the corresponding ID links towards.\n */\nexport const ProjectPlatformTypeSchema = z.enum([\"discord\", \"roblox\"]);\n\n/**\n * A User Source is an enum that represents a user account from an external platform that is linked to a Top.gg user account.\n * Each source has a unique identifer type that we might validate against.\n *\n * If none is passed to any endpoint that accepts a source parameter, it will default to topgg.\n */\nexport const UserSourceSchema = z.enum([\"discord\", \"topgg\"]);\n\n/**\n * Webhook scopes that are supported for integrations.\n */\nexport const IntegrationSupportedWebhookScopesSchema = z.enum([\"webhook.test\", \"vote.create\"]);\n\n/**\n * All error responses follow the [`application/problem+json`](https://datatracker.ietf.org/doc/html/rfc7807) specification.\n */\nexport const ErrorSchema = z.object({\n type: z.string(),\n title: z.string(),\n status: z.number(),\n detail: z.string(),\n});\n\n/**\n * Represents a user on Top.gg.\n */\nexport const UserSchema = z.object({\n /**\n * The user's Top.gg ID.\n */\n id: SnowflakeSchema,\n /**\n * The user's platform ID (e.g., Discord ID).\n */\n platform_id: SnowflakeSchema,\n /**\n * The user's username.\n */\n name: z.string(),\n /**\n * The URL of the user's avatar.\n */\n avatar_url: z.url(),\n});\n\n/**\n * Base project information shared across all project-related responses.\n */\nexport const BaseProjectSchema = z.object({\n /**\n * The project's Top.gg ID.\n */\n id: SnowflakeSchema,\n /**\n * The platform the project is on (e.g., \"discord\").\n */\n platform: ProjectPlatformTypeSchema,\n /**\n * The platform-specific ID of the project (e.g., Discord Bot ID).\n */\n platform_id: SnowflakeSchema,\n /**\n * The type of project (e.g., \"bot\").\n */\n type: ProjectTypeSchema,\n});\n\n/**\n * Represents a vote on Top.gg.\n */\nexport const VoteSchema = z.object({\n /**\n * The Top.gg ID of the user who voted.\n */\n user_id: SnowflakeSchema,\n /**\n * The user's ID on the project's platform (e.g., Discord ID).\n */\n platform_id: SnowflakeSchema,\n /**\n * The amount of votes this vote counted for.\n */\n weight: z.number(),\n /**\n * The timestamp of when the user voted.\n */\n created_at: ISO8601DateSchema,\n /**\n * The timestamp of when the vote expires (i.e., when the user can vote again).\n * This is typically 12 hours after the `created_at` timestamp, but may vary based on the user's voting history and other factors.\n */\n expires_at: ISO8601DateSchema,\n});\n\n/**\n * Represents a vote for a specific project.\n */\nexport const ProjectVoteSchema = z.clone(VoteSchema);\n\nexport const WebhookPayloadBaseSchema = <\n T extends z.infer<typeof WebhookEventTypeSchema>,\n Data extends z.ZodMiniObject,\n>(\n type: T,\n data: Data\n) =>\n z.object({\n type: z.literal(type),\n data: data,\n });\n\n// # Specific Schemas\n\n// ## Integration Schemas\n\n/**\n * Data included when an integration connection is created.\n */\nexport const IntegrationCreateDataSchema = z.object({\n /**\n * The unique identifier for this integration connection.\n */\n connection_id: SnowflakeSchema,\n /**\n * The webhook secret used to verify webhook requests from Top.gg for this connection.\n */\n webhook_secret: z.string().check(z.regex(/^whs_[a-zA-Z0-9]+$/, \"Invalid webhook secret\")),\n /**\n * The project this integration is connected to.\n */\n project: BaseProjectSchema,\n /**\n * The user who created this integration connection.\n */\n user: UserSchema,\n});\n\n/**\n * The payload delivered to your webhook endpoint when an integration connection is created.\n * This will be sent if a user clicks \"Connect\" for your integration on the dashboard.\n *\n * @see https://docs.top.gg/docs/API/v1/integrations#2-topgg-sends-integrationcreate\n */\nexport const IntegrationCreateWebhookPayloadSchema = WebhookPayloadBaseSchema(\n \"integration.create\",\n IntegrationCreateDataSchema\n);\n\n/**\n * The response you must return from your webhook endpoint when you receive an `integration.create` event.\n * This tells Top.gg where to deliver webhook events for this integration connection and which events to deliver.\n *\n * @see https://docs.top.gg/docs/API/v1/integrations#3-respond-with-configuration\n */\nexport const IntegrationCreateResponseSchema = z.object({\n /**\n * The URL where Top.gg should deliver webhook events for this connection.\n */\n webhook_url: z.url(),\n /**\n * An array of webhook scopes to subscribe to.\n *\n * @see https://docs.top.gg/docs/API/v1/webhooks#supported-scopes\n */\n routes: z\n .array(IntegrationSupportedWebhookScopesSchema)\n .check(\n z.refine(\n (arr) => arr.length === new Set(arr).size,\n \"Duplicate webhook scopes are not allowed\"\n )\n ),\n});\n\n/**\n * Data included when an integration connection is deleted.\n */\nexport const IntegrationDeleteDataSchema = z.object({\n /**\n * The unique identifier for the integration connection that was deleted.\n */\n connection_id: SnowflakeSchema,\n});\n\n/**\n * The payload delivered to your webhook endpoint when an integration connection is deleted.\n */\nexport const IntegrationDeleteWebhookPayloadSchema = WebhookPayloadBaseSchema(\n \"integration.delete\",\n IntegrationDeleteDataSchema\n);\n\n// ## Vote Schemas\n\n/**\n * Data included when a vote is created.\n */\nexport const VoteCreateDataSchema = z.extend(VoteSchema, {\n /**\n * The project that was voted for.\n */\n project: BaseProjectSchema,\n /**\n * The user who voted.\n */\n user: UserSchema,\n});\n\n/**\n * The payload delivered to your webhook endpoint when a user votes for your project and you have subscribed to the `vote.create` event.\n */\nexport const VoteCreateWebhookPayloadSchema = WebhookPayloadBaseSchema(\n \"vote.create\",\n VoteCreateDataSchema\n);\n\n// ## Webhook Test Schemas\n\n/**\n * Data included in a webhook test event.\n */\nexport const WebhookTestDataSchema = z.object({\n /**\n * A test user.\n */\n user: UserSchema,\n /**\n * A test project.\n */\n project: BaseProjectSchema,\n});\n\n/**\n * The payload delivered to your webhook endpoint when you send a test webhook from the dashboard or via the API.\n */\nexport const WebhookTestWebhookPayloadSchema = WebhookPayloadBaseSchema(\n \"webhook.test\",\n WebhookTestDataSchema\n);\n\n// ## Project Schemas\n\n/**\n * Response schema for getting the authenticated project.\n *\n * - GET `/v1/projects/@me`\n *\n * @see https://docs.top.gg/docs/API/v1/projects#get-current-project\n */\nexport const GetProjectResponseSchema = z.extend(BaseProjectSchema, {\n /**\n * The project's name.\n */\n name: z.string(),\n /**\n * The project's headline/tagline.\n */\n headline: z.string(),\n /**\n * Tags associated with the project.\n */\n tags: z.array(z.string()),\n /**\n * The number of votes this month.\n */\n votes: z.number(),\n /**\n * The total number of votes all time.\n */\n votes_total: z.number(),\n /**\n * The average review score.\n */\n review_score: z.number(),\n /**\n * The number of reviews.\n */\n review_count: z.number(),\n});\n\n/**\n * Query parameters for getting project votes.\n *\n * - GET `/v1/projects/@me/votes`\n *\n * Either `cursor` or `startDate` must be provided.\n *\n * @see https://docs.top.gg/docs/API/v1/projects/#get-votes\n */\nexport const GetProjectVotesQuerySchema = z\n .object({\n /**\n * Pagination cursor for fetching the next page of votes. if provided, `startDate` is ignored.\n *\n * From the previous response.\n */\n cursor: z.optional(z.string()),\n /**\n * The start date for fetching votes. Only votes created after this date will be returned. Required if `cursor` is not provided.\n *\n * Maximum 1 year in the past.\n *\n * ISO 8601 date string.\n */\n startDate: z.optional(ISO8601DateSchema),\n })\n .check(\n z.refine((data) => data.cursor || data.startDate, \"Either cursor or startDate must be provided\")\n );\n\n/**\n * Response schema for the Get Project Votes endpoint.\n *\n * - GET `/v1/projects/@me/votes`\n *\n * @see https://docs.top.gg/docs/API/v1/projects/#get-votes\n */\nexport const GetProjectVotesResponseSchema = z.object({\n /**\n * Cursor for fetching the next page of votes.\n */\n cursor: z.string(),\n /**\n * An array of votes for the project.\n */\n data: z.array(ProjectVoteSchema),\n});\n\n/**\n * Query parameters for getting vote status by user.\n *\n * - GET `/v1/projects/@me/votes/:user_id`\n *\n * @see https://docs.top.gg/docs/API/v1/projects/#get-vote-status-by-user\n */\nexport const GetVoteStatusByUserQuerySchema = z.object({\n /**\n * The source of the user ID. Defaults to \"topgg\".\n */\n source: z.optional(UserSourceSchema),\n});\n\n/**\n * Response schema for the Get Vote Status By User endpoint.\n *\n * - GET `/v1/projects/@me/votes/:user_id`\n *\n * @see https://docs.top.gg/docs/API/v1/projects/#get-vote-status-by-user\n */\nexport const GetVoteStatusByUserResponseSchema = z.object({\n /**\n * The timestamp of when the user last voted.\n */\n created_at: ISO8601DateSchema,\n /**\n * The timestamp of when the user's vote expires (i.e., when they can vote again).\n */\n expires_at: ISO8601DateSchema,\n /**\n * The amount of votes this vote counted for.\n */\n weight: z.number(),\n});\n"],"mappings":";;;;;;;;;AAYA,MAAa,yBAAyB,EAAE,KAAK;CAC3C;CACA;CACA;CACA;CACD,CAAC;;;;;;;AAQF,MAAa,oBAAoB,EAAE,KAAK;CAAC;CAAO;CA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ema } from \"@utils/validators\";\nexport * from \"@utils/validators\";\n\n// # General and Base Schemas\n\n// ## Enums and Constants\n\n/**\n * The type of a webhook event. This is used to identify the type of the event that is being delivered to your webhook endpoint.\n *\n * Not all webhook events are allowed to be set by an integration - use the `IntegrationSupportedWebhookScopesSchema` to find out which events you can subscribe to as an integration.\n */\nexport const WebhookEventTypeSchema = z.enum([\n \"webhook.test\",\n \"integration.create\",\n \"integration.delete\",\n \"vote.create\",\n]);\n\n/**\n * The type of a project helps top.gg synchronize features.\n * For example, a discord bot may have a support server, but this would not make any sense for a discord server.\n *\n * You can use this to further find out the specificity of the project.\n */\nexport const ProjectTypeSchema = z.enum([\"bot\", \"server\", \"game\"]);\n\n/**\n * A Platform is used to identify where the corresponding ID links towards.\n */\nexport const ProjectPlatformTypeSchema = z.enum([\"discord\", \"roblox\"]);\n\n/**\n * A User Source is an enum that represents a user account from an external platform that is linked to a Top.gg user account.\n * Each source has a unique identifer type that we might validate against.\n *\n * If none is passed to any endpoint that accepts a source parameter, it will default to topgg.\n */\nexport const UserSourceSchema = z.enum([\"discord\", \"topgg\"]);\n\n/**\n * Webhook scopes that are supported for integrations.\n */\nexport const IntegrationSupportedWebhookScopesSchema = z.enum([\"webhook.test\", \"vote.create\"]);\n\n/**\n * All error responses follow the [`application/problem+json`](https://datatracker.ietf.org/doc/html/rfc7807) specification.\n */\nexport const ErrorSchema = z.object({\n type: z.string(),\n title: z.string(),\n status: z.number(),\n detail: z.string(),\n});\n\n/**\n * Represents a user on Top.gg.\n */\nexport const UserSchema = z.object({\n /**\n * The user's Top.gg ID.\n */\n id: SnowflakeSchema,\n /**\n * The user's platform ID (e.g., Discord ID).\n */\n platform_id: SnowflakeSchema,\n /**\n * The user's username.\n */\n name: z.string(),\n /**\n * The URL of the user's avatar.\n */\n avatar_url: z.url(),\n});\n\n/**\n * Base project information shared across all project-related responses.\n */\nexport const BaseProjectSchema = z.object({\n /**\n * The project's Top.gg ID.\n */\n id: SnowflakeSchema,\n /**\n * The platform the project is on (e.g., \"discord\").\n */\n platform: ProjectPlatformTypeSchema,\n /**\n * The platform-specific ID of the project (e.g., Discord Bot ID).\n */\n platform_id: SnowflakeSchema,\n /**\n * The type of project (e.g., \"bot\").\n */\n type: ProjectTypeSchema,\n});\n\n/**\n * Represents a vote on Top.gg.\n */\nexport const VoteSchema = z.object({\n /**\n * The Top.gg ID of the user who voted.\n */\n user_id: SnowflakeSchema,\n /**\n * The user's ID on the project's platform (e.g., Discord ID).\n */\n platform_id: SnowflakeSchema,\n /**\n * The amount of votes this vote counted for.\n */\n weight: z.number(),\n /**\n * The timestamp of when the user voted.\n */\n created_at: ISO8601DateSchema,\n /**\n * The timestamp of when the vote expires (i.e., when the user can vote again).\n * This is typically 12 hours after the `created_at` timestamp, but may vary based on the user's voting history and other factors.\n */\n expires_at: ISO8601DateSchema,\n});\n\n/**\n * Represents a vote for a specific project.\n */\nexport const ProjectVoteSchema = z.clone(VoteSchema);\n\nexport const WebhookPayloadBaseSchema = <\n T extends z.infer<typeof WebhookEventTypeSchema>,\n Data extends z.ZodMiniObject,\n>(\n type: T,\n data: Data\n) =>\n z.object({\n type: z.literal(type),\n data: data,\n });\n\n// # Specific Schemas\n\n// ## Integration Schemas\n\n/**\n * Data included when an integration connection is created.\n */\nexport const IntegrationCreateDataSchema = z.object({\n /**\n * The unique identifier for this integration connection.\n */\n connection_id: SnowflakeSchema,\n /**\n * The webhook secret used to verify webhook requests from Top.gg for this connection.\n */\n webhook_secret: z.string().check(z.regex(/^whs_[a-zA-Z0-9]+$/, \"Invalid webhook secret\")),\n /**\n * The project this integration is connected to.\n */\n project: BaseProjectSchema,\n /**\n * The user who created this integration connection.\n */\n user: UserSchema,\n});\n\n/**\n * The payload delivered to your webhook endpoint when an integration connection is created.\n * This will be sent if a user clicks \"Connect\" for your integration on the dashboard.\n *\n * @see https://docs.top.gg/docs/API/v1/integrations#2-topgg-sends-integrationcreate\n */\nexport const IntegrationCreateWebhookPayloadSchema = WebhookPayloadBaseSchema(\n \"integration.create\",\n IntegrationCreateDataSchema\n);\n\n/**\n * The response you must return from your webhook endpoint when you receive an `integration.create` event.\n * This tells Top.gg where to deliver webhook events for this integration connection and which events to deliver.\n *\n * @see https://docs.top.gg/docs/API/v1/integrations#3-respond-with-configuration\n */\nexport const IntegrationCreateResponseSchema = z.object({\n /**\n * The URL where Top.gg should deliver webhook events for this connection.\n */\n webhook_url: z.url(),\n /**\n * An array of webhook scopes to subscribe to.\n *\n * @see https://docs.top.gg/docs/API/v1/webhooks#supported-scopes\n */\n routes: z\n .array(IntegrationSupportedWebhookScopesSchema)\n .check(\n z.refine(\n (arr) => arr.length === new Set(arr).size,\n \"Duplicate webhook scopes are not allowed\"\n )\n ),\n});\n\n/**\n * Data included when an integration connection is deleted.\n */\nexport const IntegrationDeleteDataSchema = z.object({\n /**\n * The unique identifier for the integration connection that was deleted.\n */\n connection_id: SnowflakeSchema,\n});\n\n/**\n * The payload delivered to your webhook endpoint when an integration connection is deleted.\n */\nexport const IntegrationDeleteWebhookPayloadSchema = WebhookPayloadBaseSchema(\n \"integration.delete\",\n IntegrationDeleteDataSchema\n);\n\n// ## Vote Schemas\n\n/**\n * Data included when a vote is created.\n */\nexport const VoteCreateDataSchema = z.extend(VoteSchema, {\n /**\n * The project that was voted for.\n */\n project: BaseProjectSchema,\n /**\n * The user who voted.\n */\n user: UserSchema,\n});\n\n/**\n * The payload delivered to your webhook endpoint when a user votes for your project and you have subscribed to the `vote.create` event.\n */\nexport const VoteCreateWebhookPayloadSchema = WebhookPayloadBaseSchema(\n \"vote.create\",\n VoteCreateDataSchema\n);\n\n// ## Webhook Test Schemas\n\n/**\n * Data included in a webhook test event.\n */\nexport const WebhookTestDataSchema = z.object({\n /**\n * A test user.\n */\n user: UserSchema,\n /**\n * A test project.\n */\n project: BaseProjectSchema,\n});\n\n/**\n * The payload delivered to your webhook endpoint when you send a test webhook from the dashboard or via the API.\n */\nexport const WebhookTestWebhookPayloadSchema = WebhookPayloadBaseSchema(\n \"webhook.test\",\n WebhookTestDataSchema\n);\n\n// ## Project Schemas\n\n/**\n * Response schema for getting the authenticated project.\n *\n * - GET `/v1/projects/@me`\n *\n * @see https://docs.top.gg/docs/API/v1/projects#get-current-project\n */\nexport const GetProjectResponseSchema = z.extend(BaseProjectSchema, {\n /**\n * The project's name.\n */\n name: z.string(),\n /**\n * The project's headline/tagline.\n */\n headline: z.string(),\n /**\n * Tags associated with the project.\n */\n tags: z.array(z.string()),\n /**\n * The number of votes this month.\n */\n votes: z.number(),\n /**\n * The total number of votes all time.\n */\n votes_total: z.number(),\n /**\n * The average review score.\n */\n review_score: z.number(),\n /**\n * The number of reviews.\n */\n review_count: z.number(),\n});\n\n/**\n * Query parameters for getting project votes.\n *\n * - GET `/v1/projects/@me/votes`\n *\n * Either `cursor` or `startDate` must be provided.\n *\n * @see https://docs.top.gg/docs/API/v1/projects/#get-votes\n */\nexport const GetProjectVotesQuerySchema = z\n .object({\n /**\n * Pagination cursor for fetching the next page of votes. if provided, `startDate` is ignored.\n *\n * From the previous response.\n */\n cursor: z.optional(z.string()),\n /**\n * The start date for fetching votes. Only votes created after this date will be returned. Required if `cursor` is not provided.\n *\n * Maximum 1 year in the past.\n *\n * ISO 8601 date string.\n */\n startDate: z.optional(ISO8601DateSchema),\n })\n .check(\n z.refine((data) => data.cursor || data.startDate, \"Either cursor or startDate must be provided\")\n );\n\n/**\n * Response schema for the Get Project Votes endpoint.\n *\n * - GET `/v1/projects/@me/votes`\n *\n * @see https://docs.top.gg/docs/API/v1/projects/#get-votes\n */\nexport const GetProjectVotesResponseSchema = z.object({\n /**\n * Cursor for fetching the next page of votes.\n */\n cursor: z.string(),\n /**\n * An array of votes for the project.\n */\n data: z.array(ProjectVoteSchema),\n});\n\n/**\n * Query parameters for getting vote status by user.\n *\n * - GET `/v1/projects/@me/votes/:user_id`\n *\n * @see https://docs.top.gg/docs/API/v1/projects/#get-vote-status-by-user\n */\nexport const GetVoteStatusByUserQuerySchema = z.object({\n /**\n * The source of the user ID. Defaults to \"topgg\".\n */\n source: z.optional(UserSourceSchema),\n});\n\n/**\n * Response schema for the Get Vote Status By User endpoint.\n *\n * - GET `/v1/projects/@me/votes/:user_id`\n *\n * @see https://docs.top.gg/docs/API/v1/projects/#get-vote-status-by-user\n */\nexport const GetVoteStatusByUserResponseSchema = z.object({\n /**\n * The timestamp of when the user last voted.\n */\n created_at: ISO8601DateSchema,\n /**\n * The timestamp of when the user's vote expires (i.e., when they can vote again).\n */\n expires_at: ISO8601DateSchema,\n /**\n * The amount of votes this vote counted for.\n */\n weight: z.number(),\n});\n"],"mappings":";;;;;;;;;AAaA,MAAa,yBAAyB,EAAE,KAAK;CAC3C;CACA;CACA;CACA;CACD,CAAC;;;;;;;AAQF,MAAa,oBAAoB,EAAE,KAAK;CAAC;CAAO;CAAU;CAAO,CAAC;;;;AAKlE,MAAa,4BAA4B,EAAE,KAAK,CAAC,WAAW,SAAS,CAAC;;;;;;;AAQtE,MAAa,mBAAmB,EAAE,KAAK,CAAC,WAAW,QAAQ,CAAC;;;;AAK5D,MAAa,0CAA0C,EAAE,KAAK,CAAC,gBAAgB,cAAc,CAAC;;;;AAK9F,MAAa,cAAc,EAAE,OAAO;CAClC,MAAM,EAAE,QAAQ;CAChB,OAAO,EAAE,QAAQ;CACjB,QAAQ,EAAE,QAAQ;CAClB,QAAQ,EAAE,QAAQ;CACnB,CAAC;;;;AAKF,MAAa,aAAa,EAAE,OAAO;CAIjC,IAAI;CAIJ,aAAa;CAIb,MAAM,EAAE,QAAQ;CAIhB,YAAY,EAAE,KAAK;CACpB,CAAC;;;;AAKF,MAAa,oBAAoB,EAAE,OAAO;CAIxC,IAAI;CAIJ,UAAU;CAIV,aAAa;CAIb,MAAM;CACP,CAAC;;;;AAKF,MAAa,aAAa,EAAE,OAAO;CAIjC,SAAS;CAIT,aAAa;CAIb,QAAQ,EAAE,QAAQ;CAIlB,YAAY;CAKZ,YAAY;CACb,CAAC;;;;AAKF,MAAa,oBAAoB,EAAE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;CACzC,CAAC,CACD,MACC,EAAE,QAAQ,SAAS,KAAK,UAAU,KAAK,WAAW,8CAA8C,CACjG;;;;;;;;AASH,MAAa,gCAAgC,EAAE,OAAO;CAIpD,QAAQ,EAAE,QAAQ;CAIlB,MAAM,EAAE,MAAM,kBAAkB;CACjC,CAAC;;;;;;;;AASF,MAAa,iCAAiC,EAAE,OAAO,EAIrD,QAAQ,EAAE,SAAS,iBAAiB,EACrC,CAAC;;;;;;;;AASF,MAAa,oCAAoC,EAAE,OAAO;CAIxD,YAAY;CAIZ,YAAY;CAIZ,QAAQ,EAAE,QAAQ;CACnB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as z from "zod/mini";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/validators.d.ts
|
|
4
|
+
declare const SnowflakeSchema: z.ZodMiniString<string>;
|
|
5
|
+
declare const ISO8601DateSchema: z.iso.ZodMiniISODate;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { SnowflakeSchema as n, ISO8601DateSchema as t };
|
|
8
|
+
//# sourceMappingURL=validators-jGzHB8WZ.d.cts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as z from "zod/mini";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/validators.d.ts
|
|
4
|
+
declare const SnowflakeSchema: z.ZodMiniString<string>;
|
|
5
|
+
declare const ISO8601DateSchema: z.iso.ZodMiniISODate;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { SnowflakeSchema as n, ISO8601DateSchema as t };
|
|
8
|
+
//# sourceMappingURL=validators-kCo2qI41.d.ts.map
|