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.
@@ -0,0 +1,206 @@
1
+ import { n as SnowflakeSchema, t as ISO8601DateSchema } from "../validators-Mlu16sBg.js";
2
+ import * as z from "zod/mini";
3
+
4
+ //#region src/v1/validators.ts
5
+ /**
6
+ * The type of a webhook event. This is used to identify the type of the event that is being delivered to your webhook endpoint.
7
+ *
8
+ * 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.
9
+ */
10
+ const WebhookEventTypeSchema = z.enum([
11
+ "webhook.test",
12
+ "integration.create",
13
+ "integration.delete",
14
+ "vote.create"
15
+ ]);
16
+ /**
17
+ * The type of a project helps top.gg synchronize features.
18
+ * For example, a discord bot may have a support server, but this would not make any sense for a discord server.
19
+ *
20
+ * You can use this to further find out the specificity of the project.
21
+ */
22
+ const ProjectTypeSchema = z.enum([
23
+ "bot",
24
+ "server",
25
+ "game"
26
+ ]);
27
+ /**
28
+ * A Platform is used to identify where the corresponding ID links towards.
29
+ */
30
+ const ProjectPlatformTypeSchema = z.enum(["discord", "roblox"]);
31
+ /**
32
+ * A User Source is an enum that represents a user account from an external platform that is linked to a Top.gg user account.
33
+ * Each source has a unique identifer type that we might validate against.
34
+ *
35
+ * If none is passed to any endpoint that accepts a source parameter, it will default to topgg.
36
+ */
37
+ const UserSourceSchema = z.enum(["discord", "topgg"]);
38
+ /**
39
+ * Webhook scopes that are supported for integrations.
40
+ */
41
+ const IntegrationSupportedWebhookScopesSchema = z.enum(["webhook.test", "vote.create"]);
42
+ /**
43
+ * All error responses follow the [`application/problem+json`](https://datatracker.ietf.org/doc/html/rfc7807) specification.
44
+ */
45
+ const ErrorSchema = z.object({
46
+ type: z.string(),
47
+ title: z.string(),
48
+ status: z.number(),
49
+ detail: z.string()
50
+ });
51
+ /**
52
+ * Represents a user on Top.gg.
53
+ */
54
+ const UserSchema = z.object({
55
+ id: SnowflakeSchema,
56
+ platform_id: SnowflakeSchema,
57
+ name: z.string(),
58
+ avatar_url: z.url()
59
+ });
60
+ /**
61
+ * Base project information shared across all project-related responses.
62
+ */
63
+ const BaseProjectSchema = z.object({
64
+ id: SnowflakeSchema,
65
+ platform: ProjectPlatformTypeSchema,
66
+ platform_id: SnowflakeSchema,
67
+ type: ProjectTypeSchema
68
+ });
69
+ /**
70
+ * Represents a vote on Top.gg.
71
+ */
72
+ const VoteSchema = z.object({
73
+ user_id: SnowflakeSchema,
74
+ platform_id: SnowflakeSchema,
75
+ weight: z.number(),
76
+ created_at: ISO8601DateSchema,
77
+ expires_at: ISO8601DateSchema
78
+ });
79
+ /**
80
+ * Represents a vote for a specific project.
81
+ */
82
+ const ProjectVoteSchema = z.clone(VoteSchema);
83
+ const WebhookPayloadBaseSchema = (type, data) => z.object({
84
+ type: z.literal(type),
85
+ data
86
+ });
87
+ /**
88
+ * Data included when an integration connection is created.
89
+ */
90
+ const IntegrationCreateDataSchema = z.object({
91
+ connection_id: SnowflakeSchema,
92
+ webhook_secret: z.string().check(z.regex(/^whs_[a-zA-Z0-9]+$/, "Invalid webhook secret")),
93
+ project: BaseProjectSchema,
94
+ user: UserSchema
95
+ });
96
+ /**
97
+ * The payload delivered to your webhook endpoint when an integration connection is created.
98
+ * This will be sent if a user clicks "Connect" for your integration on the dashboard.
99
+ *
100
+ * @see https://docs.top.gg/docs/API/v1/integrations#2-topgg-sends-integrationcreate
101
+ */
102
+ const IntegrationCreateWebhookPayloadSchema = WebhookPayloadBaseSchema("integration.create", IntegrationCreateDataSchema);
103
+ /**
104
+ * The response you must return from your webhook endpoint when you receive an `integration.create` event.
105
+ * This tells Top.gg where to deliver webhook events for this integration connection and which events to deliver.
106
+ *
107
+ * @see https://docs.top.gg/docs/API/v1/integrations#3-respond-with-configuration
108
+ */
109
+ const IntegrationCreateResponseSchema = z.object({
110
+ webhook_url: z.url(),
111
+ routes: z.array(IntegrationSupportedWebhookScopesSchema).check(z.refine((arr) => arr.length === new Set(arr).size, "Duplicate webhook scopes are not allowed"))
112
+ });
113
+ /**
114
+ * Data included when an integration connection is deleted.
115
+ */
116
+ const IntegrationDeleteDataSchema = z.object({ connection_id: SnowflakeSchema });
117
+ /**
118
+ * The payload delivered to your webhook endpoint when an integration connection is deleted.
119
+ */
120
+ const IntegrationDeleteWebhookPayloadSchema = WebhookPayloadBaseSchema("integration.delete", IntegrationDeleteDataSchema);
121
+ /**
122
+ * Data included when a vote is created.
123
+ */
124
+ const VoteCreateDataSchema = z.extend(VoteSchema, {
125
+ project: BaseProjectSchema,
126
+ user: UserSchema
127
+ });
128
+ /**
129
+ * The payload delivered to your webhook endpoint when a user votes for your project and you have subscribed to the `vote.create` event.
130
+ */
131
+ const VoteCreateWebhookPayloadSchema = WebhookPayloadBaseSchema("vote.create", VoteCreateDataSchema);
132
+ /**
133
+ * Data included in a webhook test event.
134
+ */
135
+ const WebhookTestDataSchema = z.object({
136
+ user: UserSchema,
137
+ project: BaseProjectSchema
138
+ });
139
+ /**
140
+ * The payload delivered to your webhook endpoint when you send a test webhook from the dashboard or via the API.
141
+ */
142
+ const WebhookTestWebhookPayloadSchema = WebhookPayloadBaseSchema("webhook.test", WebhookTestDataSchema);
143
+ /**
144
+ * Response schema for getting the authenticated project.
145
+ *
146
+ * - GET `/v1/projects/@me`
147
+ *
148
+ * @see https://docs.top.gg/docs/API/v1/projects#get-current-project
149
+ */
150
+ const GetProjectResponseSchema = z.extend(BaseProjectSchema, {
151
+ name: z.string(),
152
+ headline: z.string(),
153
+ tags: z.array(z.string()),
154
+ votes: z.number(),
155
+ votes_total: z.number(),
156
+ review_score: z.number(),
157
+ review_count: z.number()
158
+ });
159
+ /**
160
+ * Query parameters for getting project votes.
161
+ *
162
+ * - GET `/v1/projects/@me/votes`
163
+ *
164
+ * Either `cursor` or `startDate` must be provided.
165
+ *
166
+ * @see https://docs.top.gg/docs/API/v1/projects/#get-votes
167
+ */
168
+ const GetProjectVotesQuerySchema = z.object({
169
+ cursor: z.optional(z.string()),
170
+ startDate: z.optional(ISO8601DateSchema)
171
+ }).check(z.refine((data) => data.cursor || data.startDate, "Either cursor or startDate must be provided"));
172
+ /**
173
+ * Response schema for the Get Project Votes endpoint.
174
+ *
175
+ * - GET `/v1/projects/@me/votes`
176
+ *
177
+ * @see https://docs.top.gg/docs/API/v1/projects/#get-votes
178
+ */
179
+ const GetProjectVotesResponseSchema = z.object({
180
+ cursor: z.string(),
181
+ data: z.array(ProjectVoteSchema)
182
+ });
183
+ /**
184
+ * Query parameters for getting vote status by user.
185
+ *
186
+ * - GET `/v1/projects/@me/votes/:user_id`
187
+ *
188
+ * @see https://docs.top.gg/docs/API/v1/projects/#get-vote-status-by-user
189
+ */
190
+ const GetVoteStatusByUserQuerySchema = z.object({ source: z.optional(UserSourceSchema) });
191
+ /**
192
+ * Response schema for the Get Vote Status By User endpoint.
193
+ *
194
+ * - GET `/v1/projects/@me/votes/:user_id`
195
+ *
196
+ * @see https://docs.top.gg/docs/API/v1/projects/#get-vote-status-by-user
197
+ */
198
+ const GetVoteStatusByUserResponseSchema = z.object({
199
+ created_at: ISO8601DateSchema,
200
+ expires_at: ISO8601DateSchema,
201
+ weight: z.number()
202
+ });
203
+
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 };
206
+ //# sourceMappingURL=validators.js.map
@@ -0,0 +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":"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"}
package/dist/v1.cjs ADDED
File without changes
package/dist/v1.d.cts ADDED
@@ -0,0 +1,333 @@
1
+ import { n as Snowflake, t as ISO8601Date } from "./index-Dj7klI6c.cjs";
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.cts.map