topgg-api-types 0.0.1
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/README.md +73 -0
- package/dist/index-BzCAuhll.d.ts +6 -0
- package/dist/index-Dj7klI6c.d.cts +6 -0
- package/dist/index.cjs +28 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/v0/validators.cjs +176 -0
- package/dist/v0/validators.cjs.map +1 -0
- package/dist/v0/validators.d.cts +605 -0
- package/dist/v0/validators.d.ts +605 -0
- package/dist/v0/validators.js +162 -0
- package/dist/v0/validators.js.map +1 -0
- package/dist/v0.cjs +0 -0
- package/dist/v0.d.cts +407 -0
- package/dist/v0.d.ts +407 -0
- package/dist/v0.js +0 -0
- package/dist/v1/validators.cjs +231 -0
- package/dist/v1/validators.cjs.map +1 -0
- package/dist/v1/validators.d.cts +687 -0
- package/dist/v1/validators.d.ts +687 -0
- package/dist/v1/validators.js +206 -0
- package/dist/v1/validators.js.map +1 -0
- package/dist/v1.cjs +0 -0
- package/dist/v1.d.cts +333 -0
- package/dist/v1.d.ts +333 -0
- package/dist/v1.js +0 -0
- package/dist/validators-B3dxgWHu.cjs +54 -0
- package/dist/validators-B3dxgWHu.cjs.map +1 -0
- package/dist/validators-Mlu16sBg.js +9 -0
- package/dist/validators-Mlu16sBg.js.map +1 -0
- package/package.json +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# topgg-api-types
|
|
2
|
+
|
|
3
|
+
A lightweight collection of TypeScript types and runtime validators for the Top.gg API.
|
|
4
|
+
This package provides type definitions for the various endpoints and data structures used in the Top.gg API,
|
|
5
|
+
making it easier for developers to work with the API in a type-safe manner.
|
|
6
|
+
|
|
7
|
+
> [!NOTE]
|
|
8
|
+
> This package is currently in development and not all comments and documentation are complete. The types and validators should be complete and accurate though.
|
|
9
|
+
> It is not yet uploaded to npm, but you can clone the repository and use it locally in your projects.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install topgg-api-types
|
|
15
|
+
# or
|
|
16
|
+
pnpm add topgg-api-types
|
|
17
|
+
# or
|
|
18
|
+
yarn add topgg-api-types
|
|
19
|
+
# or
|
|
20
|
+
bun add topgg-api-types
|
|
21
|
+
# or
|
|
22
|
+
poop add topgg-api-types
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### TypeScript Types (Recommended for most users)
|
|
28
|
+
|
|
29
|
+
Import TypeScript types for static type checking and IntelliSense:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import type { User, VoteCreateWebhookPayload, GetProjectResponse } from "topgg-api-types/v1";
|
|
33
|
+
|
|
34
|
+
// Use types in your code
|
|
35
|
+
const user: User = {
|
|
36
|
+
id: "1234567890",
|
|
37
|
+
platform_id: "9876543210",
|
|
38
|
+
name: "MyUser",
|
|
39
|
+
avatar_url: "https://example.com/avatar.png",
|
|
40
|
+
};
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Runtime Validators
|
|
44
|
+
|
|
45
|
+
If you need runtime validation with Zod, import from the validators subpath:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { UserSchema, VoteCreateWebhookPayloadSchema } from "topgg-api-types/v1/validators";
|
|
49
|
+
|
|
50
|
+
// Validate incoming webhook data
|
|
51
|
+
try {
|
|
52
|
+
const validatedPayload = VoteCreateWebhookPayloadSchema.parse(req.body);
|
|
53
|
+
console.log("Valid vote webhook:", validatedPayload);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error("Invalid webhook payload:", error);
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The validators are written with zod/mini, which is a lightweight version of Zod that provides basic validation functionality with a smaller bundle size.
|
|
60
|
+
|
|
61
|
+
## Available Exports
|
|
62
|
+
|
|
63
|
+
- `topgg-api-types/v1` - Version 1 types (current)
|
|
64
|
+
- `topgg-api-types/v1/validators` - Version 1 Zod validators
|
|
65
|
+
- `topgg-api-types/v0` - Version 0 types
|
|
66
|
+
- `topgg-api-types/v0/validators` - Version 0 Zod validators
|
|
67
|
+
|
|
68
|
+
## Why Two Approaches?
|
|
69
|
+
|
|
70
|
+
- **Types only**: Smaller bundle size, better IntelliSense, no runtime overhead - perfect for most users
|
|
71
|
+
- **Validators**: Runtime validation with Zod - use when you need to validate API responses or webhook payloads
|
|
72
|
+
|
|
73
|
+
Choose the approach that fits your needs, or use both together!
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require('./validators-B3dxgWHu.cjs');
|
|
2
|
+
const require_v1_validators = require('./v1/validators.cjs');
|
|
3
|
+
|
|
4
|
+
exports.BaseProjectSchema = require_v1_validators.BaseProjectSchema;
|
|
5
|
+
exports.ErrorSchema = require_v1_validators.ErrorSchema;
|
|
6
|
+
exports.GetProjectResponseSchema = require_v1_validators.GetProjectResponseSchema;
|
|
7
|
+
exports.GetProjectVotesQuerySchema = require_v1_validators.GetProjectVotesQuerySchema;
|
|
8
|
+
exports.GetProjectVotesResponseSchema = require_v1_validators.GetProjectVotesResponseSchema;
|
|
9
|
+
exports.GetVoteStatusByUserQuerySchema = require_v1_validators.GetVoteStatusByUserQuerySchema;
|
|
10
|
+
exports.GetVoteStatusByUserResponseSchema = require_v1_validators.GetVoteStatusByUserResponseSchema;
|
|
11
|
+
exports.IntegrationCreateDataSchema = require_v1_validators.IntegrationCreateDataSchema;
|
|
12
|
+
exports.IntegrationCreateResponseSchema = require_v1_validators.IntegrationCreateResponseSchema;
|
|
13
|
+
exports.IntegrationCreateWebhookPayloadSchema = require_v1_validators.IntegrationCreateWebhookPayloadSchema;
|
|
14
|
+
exports.IntegrationDeleteDataSchema = require_v1_validators.IntegrationDeleteDataSchema;
|
|
15
|
+
exports.IntegrationDeleteWebhookPayloadSchema = require_v1_validators.IntegrationDeleteWebhookPayloadSchema;
|
|
16
|
+
exports.IntegrationSupportedWebhookScopesSchema = require_v1_validators.IntegrationSupportedWebhookScopesSchema;
|
|
17
|
+
exports.ProjectPlatformTypeSchema = require_v1_validators.ProjectPlatformTypeSchema;
|
|
18
|
+
exports.ProjectTypeSchema = require_v1_validators.ProjectTypeSchema;
|
|
19
|
+
exports.ProjectVoteSchema = require_v1_validators.ProjectVoteSchema;
|
|
20
|
+
exports.UserSchema = require_v1_validators.UserSchema;
|
|
21
|
+
exports.UserSourceSchema = require_v1_validators.UserSourceSchema;
|
|
22
|
+
exports.VoteCreateDataSchema = require_v1_validators.VoteCreateDataSchema;
|
|
23
|
+
exports.VoteCreateWebhookPayloadSchema = require_v1_validators.VoteCreateWebhookPayloadSchema;
|
|
24
|
+
exports.VoteSchema = require_v1_validators.VoteSchema;
|
|
25
|
+
exports.WebhookEventTypeSchema = require_v1_validators.WebhookEventTypeSchema;
|
|
26
|
+
exports.WebhookPayloadBaseSchema = require_v1_validators.WebhookPayloadBaseSchema;
|
|
27
|
+
exports.WebhookTestDataSchema = require_v1_validators.WebhookTestDataSchema;
|
|
28
|
+
exports.WebhookTestWebhookPayloadSchema = require_v1_validators.WebhookTestWebhookPayloadSchema;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
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 { 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 };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
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 { 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 };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import "./validators-Mlu16sBg.js";
|
|
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
|
+
|
|
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 };
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
const require_validators = require('../validators-B3dxgWHu.cjs');
|
|
2
|
+
let zod_mini = require("zod/mini");
|
|
3
|
+
zod_mini = require_validators.__toESM(zod_mini);
|
|
4
|
+
|
|
5
|
+
//#region src/v0/validators.ts
|
|
6
|
+
/**
|
|
7
|
+
* The type of a webhook event.
|
|
8
|
+
*/
|
|
9
|
+
const WebhookEventTypeSchema = zod_mini.enum(["upvote", "test"]);
|
|
10
|
+
/**
|
|
11
|
+
* Webhook payload for bot votes (deprecated).
|
|
12
|
+
*
|
|
13
|
+
* @deprecated Use `v1` types instead.
|
|
14
|
+
*/
|
|
15
|
+
const BotWebhookPayloadSchema = zod_mini.object({
|
|
16
|
+
bot: require_validators.SnowflakeSchema,
|
|
17
|
+
user: require_validators.SnowflakeSchema,
|
|
18
|
+
type: WebhookEventTypeSchema,
|
|
19
|
+
isWeekend: zod_mini.boolean(),
|
|
20
|
+
query: zod_mini.optional(zod_mini.string())
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Webhook payload for server votes (deprecated).
|
|
24
|
+
*
|
|
25
|
+
* @deprecated Use `v1` types instead.
|
|
26
|
+
*/
|
|
27
|
+
const ServerWebhookPayloadSchema = zod_mini.object({
|
|
28
|
+
guild: require_validators.SnowflakeSchema,
|
|
29
|
+
user: require_validators.SnowflakeSchema,
|
|
30
|
+
type: WebhookEventTypeSchema,
|
|
31
|
+
query: zod_mini.optional(zod_mini.string())
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* A bot listed on Top.gg.
|
|
35
|
+
*/
|
|
36
|
+
const BotSchema = zod_mini.object({
|
|
37
|
+
id: require_validators.SnowflakeSchema,
|
|
38
|
+
username: zod_mini.string(),
|
|
39
|
+
discriminator: zod_mini.string(),
|
|
40
|
+
avatar: zod_mini.optional(zod_mini.string()),
|
|
41
|
+
defAvatar: zod_mini.optional(zod_mini.string()),
|
|
42
|
+
prefix: zod_mini.string(),
|
|
43
|
+
shortdesc: zod_mini.string(),
|
|
44
|
+
longdesc: zod_mini.optional(zod_mini.string()),
|
|
45
|
+
tags: zod_mini.array(zod_mini.string()),
|
|
46
|
+
website: zod_mini.optional(zod_mini.string()),
|
|
47
|
+
support: zod_mini.optional(zod_mini.string()),
|
|
48
|
+
github: zod_mini.optional(zod_mini.string()),
|
|
49
|
+
owners: zod_mini.array(require_validators.SnowflakeSchema),
|
|
50
|
+
guilds: zod_mini.array(require_validators.SnowflakeSchema),
|
|
51
|
+
invite: zod_mini.optional(zod_mini.string()),
|
|
52
|
+
date: require_validators.ISO8601DateSchema,
|
|
53
|
+
server_count: zod_mini.optional(zod_mini.number()),
|
|
54
|
+
shard_count: zod_mini.optional(zod_mini.number()),
|
|
55
|
+
certifiedBot: zod_mini.boolean(),
|
|
56
|
+
vanity: zod_mini.optional(zod_mini.string()),
|
|
57
|
+
points: zod_mini.number(),
|
|
58
|
+
monthlyPoints: zod_mini.number(),
|
|
59
|
+
donatebotguildid: require_validators.SnowflakeSchema
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* Query parameters for searching bots on Top.gg.
|
|
63
|
+
*
|
|
64
|
+
* @see https://docs.top.gg/docs/API/v0/bot#search-bots
|
|
65
|
+
*/
|
|
66
|
+
const GetSearchBotsQuerySchema = zod_mini.object({
|
|
67
|
+
limit: zod_mini.optional(zod_mini.number().check(zod_mini.minimum(1)).check(zod_mini.maximum(500))),
|
|
68
|
+
offset: zod_mini.optional(zod_mini.number().check(zod_mini.minimum(0))),
|
|
69
|
+
sort: zod_mini.string(),
|
|
70
|
+
fields: zod_mini.optional(zod_mini.string())
|
|
71
|
+
});
|
|
72
|
+
/**
|
|
73
|
+
* Response for searching bots on Top.gg.
|
|
74
|
+
*/
|
|
75
|
+
const GetSearchBotsResponseSchema = zod_mini.object({
|
|
76
|
+
results: zod_mini.array(BotSchema),
|
|
77
|
+
total: zod_mini.number(),
|
|
78
|
+
limit: zod_mini.number(),
|
|
79
|
+
offset: zod_mini.number(),
|
|
80
|
+
count: zod_mini.number()
|
|
81
|
+
});
|
|
82
|
+
/**
|
|
83
|
+
* Response for getting a bot.
|
|
84
|
+
*
|
|
85
|
+
* - GET `/bots/:bot_id`
|
|
86
|
+
*/
|
|
87
|
+
const GetBotResponseSchema = BotSchema;
|
|
88
|
+
/**
|
|
89
|
+
* A bot voter.
|
|
90
|
+
*/
|
|
91
|
+
const BotVoterSchema = zod_mini.object({
|
|
92
|
+
id: require_validators.SnowflakeSchema,
|
|
93
|
+
username: zod_mini.string(),
|
|
94
|
+
avatar: zod_mini.optional(zod_mini.string())
|
|
95
|
+
});
|
|
96
|
+
/**
|
|
97
|
+
* Gets the last 1000 voters for your bot.
|
|
98
|
+
*
|
|
99
|
+
* - GET `/bots/:bot_id/votes`
|
|
100
|
+
*/
|
|
101
|
+
const GetLast1000BotVotesResponseSchema = zod_mini.array(BotVoterSchema);
|
|
102
|
+
/**
|
|
103
|
+
* Specific stats about a bot.
|
|
104
|
+
*
|
|
105
|
+
* - GET `/bots/:bot_id/stats`
|
|
106
|
+
*/
|
|
107
|
+
const GetBotStatsResponseSchema = zod_mini.object({
|
|
108
|
+
server_count: zod_mini.optional(zod_mini.number()),
|
|
109
|
+
shards: zod_mini.array(zod_mini.number()),
|
|
110
|
+
shard_count: zod_mini.optional(zod_mini.number())
|
|
111
|
+
});
|
|
112
|
+
/**
|
|
113
|
+
* Query parameters for checking whether or not a user has voted for your bot.
|
|
114
|
+
*
|
|
115
|
+
* - GET `/bots/:bot_id/check`
|
|
116
|
+
*/
|
|
117
|
+
const GetUserVoteCheckQuerySchema = zod_mini.object({ userId: require_validators.SnowflakeSchema });
|
|
118
|
+
/**
|
|
119
|
+
* Response for checking whether or not a user has voted for your bot.
|
|
120
|
+
*
|
|
121
|
+
* - GET `/bots/:bot_id/check`
|
|
122
|
+
*/
|
|
123
|
+
const GetUserVoteCheckResponseSchema = zod_mini.object({ voted: zod_mini.xor([zod_mini.literal(0), zod_mini.literal(1)]) });
|
|
124
|
+
/**
|
|
125
|
+
* Request body for posting bot stats.
|
|
126
|
+
*/
|
|
127
|
+
const PostBotStatsBodySchema = zod_mini.object({
|
|
128
|
+
server_count: zod_mini.xor([zod_mini.number(), zod_mini.array(zod_mini.number())]),
|
|
129
|
+
shards: zod_mini.optional(zod_mini.array(zod_mini.number())),
|
|
130
|
+
shard_id: zod_mini.optional(zod_mini.number()),
|
|
131
|
+
shard_count: zod_mini.optional(zod_mini.number())
|
|
132
|
+
});
|
|
133
|
+
/**
|
|
134
|
+
* A user on Top.gg.
|
|
135
|
+
*
|
|
136
|
+
* - GET `/users/:user_id`
|
|
137
|
+
*/
|
|
138
|
+
const UserSchema = zod_mini.object({
|
|
139
|
+
id: require_validators.SnowflakeSchema,
|
|
140
|
+
username: zod_mini.string(),
|
|
141
|
+
discriminator: zod_mini.string(),
|
|
142
|
+
avatar: zod_mini.optional(zod_mini.string()),
|
|
143
|
+
defAvatar: zod_mini.optional(zod_mini.string()),
|
|
144
|
+
bio: zod_mini.optional(zod_mini.string()),
|
|
145
|
+
banner: zod_mini.optional(zod_mini.string()),
|
|
146
|
+
social: zod_mini.object({
|
|
147
|
+
youtube: zod_mini.optional(zod_mini.string()),
|
|
148
|
+
reddit: zod_mini.optional(zod_mini.string()),
|
|
149
|
+
twitter: zod_mini.optional(zod_mini.string()),
|
|
150
|
+
instagram: zod_mini.optional(zod_mini.string()),
|
|
151
|
+
github: zod_mini.optional(zod_mini.string())
|
|
152
|
+
}),
|
|
153
|
+
color: zod_mini.optional(zod_mini.string()),
|
|
154
|
+
supporter: zod_mini.boolean(),
|
|
155
|
+
certifiedDev: zod_mini.boolean(),
|
|
156
|
+
mod: zod_mini.boolean(),
|
|
157
|
+
webMod: zod_mini.boolean(),
|
|
158
|
+
admin: zod_mini.boolean()
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
//#endregion
|
|
162
|
+
exports.BotSchema = BotSchema;
|
|
163
|
+
exports.BotVoterSchema = BotVoterSchema;
|
|
164
|
+
exports.BotWebhookPayloadSchema = BotWebhookPayloadSchema;
|
|
165
|
+
exports.GetBotResponseSchema = GetBotResponseSchema;
|
|
166
|
+
exports.GetBotStatsResponseSchema = GetBotStatsResponseSchema;
|
|
167
|
+
exports.GetLast1000BotVotesResponseSchema = GetLast1000BotVotesResponseSchema;
|
|
168
|
+
exports.GetSearchBotsQuerySchema = GetSearchBotsQuerySchema;
|
|
169
|
+
exports.GetSearchBotsResponseSchema = GetSearchBotsResponseSchema;
|
|
170
|
+
exports.GetUserVoteCheckQuerySchema = GetUserVoteCheckQuerySchema;
|
|
171
|
+
exports.GetUserVoteCheckResponseSchema = GetUserVoteCheckResponseSchema;
|
|
172
|
+
exports.PostBotStatsBodySchema = PostBotStatsBodySchema;
|
|
173
|
+
exports.ServerWebhookPayloadSchema = ServerWebhookPayloadSchema;
|
|
174
|
+
exports.UserSchema = UserSchema;
|
|
175
|
+
exports.WebhookEventTypeSchema = WebhookEventTypeSchema;
|
|
176
|
+
//# sourceMappingURL=validators.cjs.map
|
|
@@ -0,0 +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,SAA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