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/dist/v1.d.ts ADDED
@@ -0,0 +1,333 @@
1
+ import { n as Snowflake, t as ISO8601Date } from "./index-BzCAuhll.js";
2
+
3
+ //#region src/v1/index.d.ts
4
+
5
+ /**
6
+ * The type of a webhook event sent by Top.gg to your integration webhook endpoint.
7
+ *
8
+ * These are for events related to the integration connection itself (e.g., when it's created or deleted).
9
+ */
10
+ type IntegrationWebhookEventType = "integration.create" | "integration.delete";
11
+ /**
12
+ * The type of a project helps top.gg synchronize features.
13
+ * For example, a discord bot may have a support server, but this would not make any sense for a discord server.
14
+ *
15
+ * You can use this to further find out the specificity of the project.
16
+ */
17
+ type ProjectType = "bot" | "server" | "game";
18
+ /**
19
+ * A Platform is used to identify where the corresponding ID links towards.
20
+ */
21
+ type ProjectPlatformType = "discord" | "roblox";
22
+ /**
23
+ * A User Source is an enum that represents a user account from an external platform that is linked to a Top.gg user account.
24
+ * Each source has a unique identifer type that we might validate against.
25
+ *
26
+ * If none is passed to any endpoint that accepts a source parameter, it will default to topgg.
27
+ */
28
+ type UserSource = "discord" | "topgg";
29
+ /**
30
+ * Webhook scopes that are supported for integrations.
31
+ *
32
+ * These differ from integration webhook event types - these are the events that a user or you can subscribe to for an integration connection,
33
+ * while the integration webhook event types are the events that are sent to your webhook endpoint when something happens with your integration connection (e.g., it's created or deleted).
34
+ */
35
+ type WebhookEventType = "webhook.test" | "vote.create";
36
+ type WebhookEventTypes = WebhookEventType | IntegrationWebhookEventType;
37
+ /**
38
+ * All error responses follow the [`application/problem+json`](https://datatracker.ietf.org/doc/html/rfc7807) specification.
39
+ */
40
+ interface ErrorResponse {
41
+ type: string;
42
+ title: string;
43
+ status: number;
44
+ detail: string;
45
+ }
46
+ /**
47
+ * Represents a user on Top.gg.
48
+ */
49
+ interface User {
50
+ /**
51
+ * The user's Top.gg ID.
52
+ */
53
+ id: Snowflake;
54
+ /**
55
+ * The user's platform ID (e.g., Discord ID).
56
+ */
57
+ platform_id: Snowflake;
58
+ /**
59
+ * The user's username.
60
+ */
61
+ name: string;
62
+ /**
63
+ * The URL of the user's avatar.
64
+ */
65
+ avatar_url: string;
66
+ }
67
+ /**
68
+ * Base project information shared across all project-related responses.
69
+ */
70
+ interface BaseProject {
71
+ /**
72
+ * The project's Top.gg ID.
73
+ */
74
+ id: Snowflake;
75
+ /**
76
+ * The platform the project is on (e.g., "discord").
77
+ */
78
+ platform: ProjectPlatformType;
79
+ /**
80
+ * The platform-specific ID of the project (e.g., Discord Bot ID).
81
+ */
82
+ platform_id: Snowflake;
83
+ /**
84
+ * The type of project (e.g., "bot").
85
+ */
86
+ type: ProjectType;
87
+ }
88
+ /**
89
+ * Represents a vote on Top.gg.
90
+ */
91
+ interface Vote {
92
+ /**
93
+ * The Top.gg ID of the user who voted.
94
+ */
95
+ user_id: Snowflake;
96
+ /**
97
+ * The user's ID on the project's platform (e.g., Discord ID).
98
+ */
99
+ platform_id: Snowflake;
100
+ /**
101
+ * The amount of votes this vote counted for.
102
+ */
103
+ weight: number;
104
+ /**
105
+ * The timestamp of when the user voted.
106
+ */
107
+ created_at: ISO8601Date;
108
+ /**
109
+ * The timestamp of when the vote expires (i.e., when the user can vote again).
110
+ * This is typically 12 hours after the `created_at` timestamp, but may vary based on the user's voting history and other factors.
111
+ */
112
+ expires_at: ISO8601Date;
113
+ }
114
+ /**
115
+ * Represents a vote for a specific project.
116
+ */
117
+ type ProjectVote = Vote;
118
+ /**
119
+ * Base structure for webhook payloads.
120
+ */
121
+ interface WebhookPayloadBase<T extends WebhookEventTypes, Data extends object> {
122
+ type: T;
123
+ data: Data;
124
+ }
125
+ /**
126
+ * Data included when an integration connection is created.
127
+ */
128
+ interface IntegrationCreateData {
129
+ /**
130
+ * The unique identifier for this integration connection.
131
+ */
132
+ connection_id: string;
133
+ /**
134
+ * The webhook secret used to verify webhook requests from Top.gg for this connection.
135
+ */
136
+ webhook_secret: string;
137
+ /**
138
+ * The project this integration is connected to.
139
+ */
140
+ project: BaseProject;
141
+ /**
142
+ * The user who created this integration connection.
143
+ */
144
+ user: User;
145
+ }
146
+ /**
147
+ * The payload delivered to your webhook endpoint when an integration connection is created.
148
+ * This will be sent if a user clicks "Connect" for your integration on the dashboard.
149
+ *
150
+ * @see https://docs.top.gg/docs/API/v1/integrations#2-topgg-sends-integrationcreate
151
+ */
152
+ type IntegrationCreateWebhookPayload = WebhookPayloadBase<"integration.create", IntegrationCreateData>;
153
+ /**
154
+ * The response you must return from your webhook endpoint when you receive an `integration.create` event.
155
+ * This tells Top.gg where to deliver webhook events for this integration connection and which events to deliver.
156
+ *
157
+ * @see https://docs.top.gg/docs/API/v1/integrations#3-respond-with-configuration
158
+ */
159
+ interface IntegrationCreateResponse {
160
+ /**
161
+ * The URL where Top.gg should deliver webhook events for this connection.
162
+ */
163
+ webhook_url: string;
164
+ /**
165
+ * An array of webhook scopes to subscribe to.
166
+ *
167
+ * @see https://docs.top.gg/docs/API/v1/webhooks#supported-scopes
168
+ */
169
+ routes: WebhookEventTypes[];
170
+ }
171
+ /**
172
+ * Data included when an integration connection is deleted.
173
+ */
174
+ interface IntegrationDeleteData {
175
+ /**
176
+ * The unique identifier for the integration connection that was deleted.
177
+ */
178
+ connection_id: string;
179
+ }
180
+ /**
181
+ * The payload delivered to your webhook endpoint when an integration connection is deleted.
182
+ */
183
+ type IntegrationDeleteWebhookPayload = WebhookPayloadBase<"integration.delete", IntegrationDeleteData>;
184
+ /**
185
+ * Data included when a vote is created.
186
+ */
187
+ interface VoteCreateData extends Vote {
188
+ /**
189
+ * The project that was voted for.
190
+ */
191
+ project: BaseProject;
192
+ /**
193
+ * The user who voted.
194
+ */
195
+ user: User;
196
+ }
197
+ /**
198
+ * The payload delivered to your webhook endpoint when a user votes for your project and you have subscribed to the `vote.create` event.
199
+ */
200
+ type VoteCreateWebhookPayload = WebhookPayloadBase<"vote.create", VoteCreateData>;
201
+ /**
202
+ * Data included in a webhook test event.
203
+ */
204
+ interface WebhookTestData {
205
+ /**
206
+ * A test user.
207
+ */
208
+ user: User;
209
+ /**
210
+ * A test project.
211
+ */
212
+ project: BaseProject;
213
+ }
214
+ /**
215
+ * The payload delivered to your webhook endpoint when you send a test webhook from the dashboard or via the API.
216
+ */
217
+ type WebhookTestWebhookPayload = WebhookPayloadBase<"webhook.test", WebhookTestData>;
218
+ /**
219
+ * Response for getting the authenticated project.
220
+ *
221
+ * - GET `/v1/projects/@me`
222
+ *
223
+ * @see https://docs.top.gg/docs/API/v1/projects#get-current-project
224
+ */
225
+ interface GetProjectResponse extends BaseProject {
226
+ /**
227
+ * The project's name.
228
+ */
229
+ name: string;
230
+ /**
231
+ * The project's headline/tagline.
232
+ */
233
+ headline: string;
234
+ /**
235
+ * Tags associated with the project.
236
+ */
237
+ tags: string[];
238
+ /**
239
+ * The number of votes this month.
240
+ */
241
+ votes: number;
242
+ /**
243
+ * The total number of votes all time.
244
+ */
245
+ votes_total: number;
246
+ /**
247
+ * The average review score.
248
+ */
249
+ review_score: number;
250
+ /**
251
+ * The number of reviews.
252
+ */
253
+ review_count: number;
254
+ }
255
+ /**
256
+ * Query parameters for getting project votes.
257
+ *
258
+ * - GET `/v1/projects/@me/votes`
259
+ *
260
+ * Either `cursor` or `startDate` must be provided.
261
+ *
262
+ * @see https://docs.top.gg/docs/API/v1/projects/#get-votes
263
+ */
264
+ interface GetProjectVotesQuery {
265
+ /**
266
+ * Pagination cursor for fetching the next page of votes. if provided, `startDate` is ignored.
267
+ *
268
+ * From the previous response.
269
+ */
270
+ cursor?: string;
271
+ /**
272
+ * The start date for fetching votes. Only votes created after this date will be returned. Required if `cursor` is not provided.
273
+ *
274
+ * Maximum 1 year in the past.
275
+ *
276
+ * ISO 8601 date string.
277
+ */
278
+ startDate?: string;
279
+ }
280
+ /**
281
+ * Response for the Get Project Votes endpoint.
282
+ *
283
+ * - GET `/v1/projects/@me/votes`
284
+ *
285
+ * @see https://docs.top.gg/docs/API/v1/projects/#get-votes
286
+ */
287
+ interface GetProjectVotesResponse {
288
+ /**
289
+ * Cursor for fetching the next page of votes.
290
+ */
291
+ cursor: string;
292
+ /**
293
+ * An array of votes for the project.
294
+ */
295
+ data: ProjectVote[];
296
+ }
297
+ /**
298
+ * Query parameters for getting vote status by user.
299
+ *
300
+ * - GET `/v1/projects/@me/votes/:user_id`
301
+ *
302
+ * @see https://docs.top.gg/docs/API/v1/projects/#get-vote-status-by-user
303
+ */
304
+ interface GetVoteStatusByUserQuery {
305
+ /**
306
+ * The source of the user ID. Defaults to "topgg".
307
+ */
308
+ source?: UserSource;
309
+ }
310
+ /**
311
+ * Response for the Get Vote Status By User endpoint.
312
+ *
313
+ * - GET `/v1/projects/@me/votes/:user_id`
314
+ *
315
+ * @see https://docs.top.gg/docs/API/v1/projects/#get-vote-status-by-user
316
+ */
317
+ interface GetVoteStatusByUserResponse {
318
+ /**
319
+ * The timestamp of when the user last voted.
320
+ */
321
+ created_at: ISO8601Date;
322
+ /**
323
+ * The timestamp of when the user's vote expires (i.e., when they can vote again).
324
+ */
325
+ expires_at: ISO8601Date;
326
+ /**
327
+ * The amount of votes this vote counted for.
328
+ */
329
+ weight: number;
330
+ }
331
+ //#endregion
332
+ export { 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 };
333
+ //# sourceMappingURL=v1.d.ts.map
package/dist/v1.js ADDED
File without changes
@@ -0,0 +1,54 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+ let zod_mini = require("zod/mini");
29
+ zod_mini = __toESM(zod_mini);
30
+
31
+ //#region src/utils/validators.ts
32
+ const SnowflakeSchema = zod_mini.string().check(zod_mini.regex(/^\d{17,21}$/, "Invalid Snowflake ID"));
33
+ const ISO8601DateSchema = zod_mini.iso.date();
34
+
35
+ //#endregion
36
+ Object.defineProperty(exports, 'ISO8601DateSchema', {
37
+ enumerable: true,
38
+ get: function () {
39
+ return ISO8601DateSchema;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, 'SnowflakeSchema', {
43
+ enumerable: true,
44
+ get: function () {
45
+ return SnowflakeSchema;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, '__toESM', {
49
+ enumerable: true,
50
+ get: function () {
51
+ return __toESM;
52
+ }
53
+ });
54
+ //# sourceMappingURL=validators-B3dxgWHu.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators-B3dxgWHu.cjs","names":["z"],"sources":["../src/utils/validators.ts"],"sourcesContent":["import * as z from \"zod/mini\";\n\nexport const SnowflakeSchema = z.string().check(z.regex(/^\\d{17,21}$/, \"Invalid Snowflake ID\"));\nexport const ISO8601DateSchema = z.iso.date();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAa,kBAAkBA,SAAE,QAAQ,CAAC,MAAMA,SAAE,MAAM,eAAe,uBAAuB,CAAC;AAC/F,MAAa,oBAAoBA,SAAE,IAAI,MAAM"}
@@ -0,0 +1,9 @@
1
+ import * as z from "zod/mini";
2
+
3
+ //#region src/utils/validators.ts
4
+ const SnowflakeSchema = z.string().check(z.regex(/^\d{17,21}$/, "Invalid Snowflake ID"));
5
+ const ISO8601DateSchema = z.iso.date();
6
+
7
+ //#endregion
8
+ export { SnowflakeSchema as n, ISO8601DateSchema as t };
9
+ //# sourceMappingURL=validators-Mlu16sBg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators-Mlu16sBg.js","names":[],"sources":["../src/utils/validators.ts"],"sourcesContent":["import * as z from \"zod/mini\";\n\nexport const SnowflakeSchema = z.string().check(z.regex(/^\\d{17,21}$/, \"Invalid Snowflake ID\"));\nexport const ISO8601DateSchema = z.iso.date();\n"],"mappings":";;;AAEA,MAAa,kBAAkB,EAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,eAAe,uBAAuB,CAAC;AAC/F,MAAa,oBAAoB,EAAE,IAAI,MAAM"}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "topgg-api-types",
3
+ "author": {
4
+ "name": "The-LukeZ",
5
+ "email": "contact.lukez@proton.me",
6
+ "url": "https://github.com/The-LukeZ"
7
+ },
8
+ "type": "module",
9
+ "version": "0.0.1",
10
+ "license": "MIT",
11
+ "description": "Top.gg API types and validators for TypeScript",
12
+ "repository": {
13
+ "url": "https://github.com/The-LukeZ/topgg-api-types"
14
+ },
15
+ "main": "./dist/index.cjs",
16
+ "module": "./dist/index.js",
17
+ "types": "./dist/index.d.cts",
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "exports": {
22
+ ".": {
23
+ "require": "./dist/index.cjs",
24
+ "import": "./dist/index.js"
25
+ },
26
+ "./v0": {
27
+ "require": "./dist/v0.cjs",
28
+ "import": "./dist/v0.js"
29
+ },
30
+ "./v0/validators": {
31
+ "require": "./dist/v0/validators.cjs",
32
+ "import": "./dist/v0/validators.js"
33
+ },
34
+ "./v1": {
35
+ "require": "./dist/v1.cjs",
36
+ "import": "./dist/v1.js"
37
+ },
38
+ "./v1/validators": {
39
+ "require": "./dist/v1/validators.cjs",
40
+ "import": "./dist/v1/validators.js"
41
+ },
42
+ "./package.json": "./package.json"
43
+ },
44
+ "keywords": [
45
+ "topgg",
46
+ "types",
47
+ "typescript",
48
+ "api"
49
+ ],
50
+ "devDependencies": {
51
+ "prettier": "3.8.1",
52
+ "tsdown": "^0.18.1",
53
+ "typescript": "^5.9.3"
54
+ },
55
+ "dependencies": {
56
+ "zod": "^4.3.6"
57
+ },
58
+ "scripts": {
59
+ "build": "tsdown",
60
+ "dev": "tsdown --watch",
61
+ "format": "prettier --write .",
62
+ "lint": "prettier --check ."
63
+ }
64
+ }