topgg-api-types 0.0.4 → 0.0.6
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/index.cjs +1 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/v1/validators.cjs +7 -0
- package/dist/v1/validators.cjs.map +1 -1
- package/dist/v1/validators.d.cts +176 -1
- package/dist/v1/validators.d.ts +176 -1
- package/dist/v1/validators.js +7 -1
- package/dist/v1/validators.js.map +1 -1
- package/dist/v1.d.cts +4 -1
- package/dist/v1.d.ts +4 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -26,5 +26,6 @@ exports.VoteCreateWebhookPayloadSchema = require_v1_validators.VoteCreateWebhook
|
|
|
26
26
|
exports.VoteSchema = require_v1_validators.VoteSchema;
|
|
27
27
|
exports.WebhookEventTypeSchema = require_v1_validators.WebhookEventTypeSchema;
|
|
28
28
|
exports.WebhookPayloadBaseSchema = require_v1_validators.WebhookPayloadBaseSchema;
|
|
29
|
+
exports.WebhookPayloadSchema = require_v1_validators.WebhookPayloadSchema;
|
|
29
30
|
exports.WebhookTestDataSchema = require_v1_validators.WebhookTestDataSchema;
|
|
30
31
|
exports.WebhookTestWebhookPayloadSchema = require_v1_validators.WebhookTestWebhookPayloadSchema;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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";
|
|
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, WebhookPayload, WebhookPayloadBase, WebhookTestData, WebhookTestWebhookPayload } from "./v1.cjs";
|
|
2
2
|
import { n as SnowflakeSchema, t as ISO8601DateSchema } from "./validators-jGzHB8WZ.cjs";
|
|
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";
|
|
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 };
|
|
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, WebhookPayloadSchema, WebhookTestDataSchema, WebhookTestWebhookPayloadSchema } from "./v1/validators.cjs";
|
|
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, WebhookPayload, WebhookPayloadBase, WebhookPayloadBaseSchema, WebhookPayloadSchema, WebhookTestData, WebhookTestDataSchema, WebhookTestWebhookPayload, WebhookTestWebhookPayloadSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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";
|
|
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, WebhookPayload, WebhookPayloadBase, WebhookTestData, WebhookTestWebhookPayload } from "./v1.js";
|
|
2
2
|
import { n as SnowflakeSchema, t as ISO8601DateSchema } from "./validators-kCo2qI41.js";
|
|
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";
|
|
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 };
|
|
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, WebhookPayloadSchema, WebhookTestDataSchema, WebhookTestWebhookPayloadSchema } from "./v1/validators.js";
|
|
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, WebhookPayload, WebhookPayloadBase, WebhookPayloadBaseSchema, WebhookPayloadSchema, WebhookTestData, WebhookTestDataSchema, WebhookTestWebhookPayload, WebhookTestWebhookPayloadSchema };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { n as SnowflakeSchema, t as ISO8601DateSchema } from "./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";
|
|
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, WebhookPayloadSchema, WebhookTestDataSchema, WebhookTestWebhookPayloadSchema } from "./v1/validators.js";
|
|
3
3
|
|
|
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 };
|
|
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, WebhookPayloadSchema, WebhookTestDataSchema, WebhookTestWebhookPayloadSchema };
|
package/dist/v1/validators.cjs
CHANGED
|
@@ -141,6 +141,12 @@ const WebhookTestDataSchema = zod_mini.object({
|
|
|
141
141
|
* The payload delivered to your webhook endpoint when you send a test webhook from the dashboard or via the API.
|
|
142
142
|
*/
|
|
143
143
|
const WebhookTestWebhookPayloadSchema = WebhookPayloadBaseSchema("webhook.test", WebhookTestDataSchema);
|
|
144
|
+
const WebhookPayloadSchema = zod_mini.discriminatedUnion("type", [
|
|
145
|
+
IntegrationCreateWebhookPayloadSchema,
|
|
146
|
+
IntegrationDeleteWebhookPayloadSchema,
|
|
147
|
+
VoteCreateWebhookPayloadSchema,
|
|
148
|
+
WebhookTestWebhookPayloadSchema
|
|
149
|
+
]);
|
|
144
150
|
/**
|
|
145
151
|
* Response schema for getting the authenticated project.
|
|
146
152
|
*
|
|
@@ -228,6 +234,7 @@ exports.VoteCreateWebhookPayloadSchema = VoteCreateWebhookPayloadSchema;
|
|
|
228
234
|
exports.VoteSchema = VoteSchema;
|
|
229
235
|
exports.WebhookEventTypeSchema = WebhookEventTypeSchema;
|
|
230
236
|
exports.WebhookPayloadBaseSchema = WebhookPayloadBaseSchema;
|
|
237
|
+
exports.WebhookPayloadSchema = WebhookPayloadSchema;
|
|
231
238
|
exports.WebhookTestDataSchema = WebhookTestDataSchema;
|
|
232
239
|
exports.WebhookTestWebhookPayloadSchema = WebhookTestWebhookPayloadSchema;
|
|
233
240
|
//# sourceMappingURL=validators.cjs.map
|
|
@@ -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\";\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,K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AAwC,yBACnD,sBACA,4BACD;;;;AAOD,MAAa,uBAAuBD,SAAE,OAAO,YAAY;CAIvD,SAAS;CAIT,MAAM;CACP,CAAC;;;;AAKF,MAAa,iCAAiC,yBAC5C,eACA,qBACD;;;;AAOD,MAAa,wBAAwBA,SAAE,OAAO;CAI5C,MAAM;CAIN,SAAS;CACV,CAAC;;;;AAKF,MAAa,kCAAkC,yBAC7C,gBACA,sBACD;;;;;;;;AAWD,MAAa,2BAA2BA,SAAE,OAAO,mBAAmB;CAIlE,MAAMA,SAAE,QAAQ;CAIhB,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"}
|
|
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 Schema\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// ## Webhook\n\nexport const WebhookPayloadSchema = z.discriminatedUnion(\"type\", [\n IntegrationCreateWebhookPayloadSchema,\n IntegrationDeleteWebhookPayloadSchema,\n VoteCreateWebhookPayloadSchema,\n WebhookTestWebhookPayloadSchema,\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,YAAYA,SAAE,KAAK;CACpB,CAAC;;;;AAKF,MAAa,oBAAoBA,SAAE,OAAO;CAIxC,IAAIC;CAIJ,UAAU;CAIV,aAAaA;CAIb,MAAM;CACP,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,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
|
@@ -555,6 +555,181 @@ declare const WebhookTestWebhookPayloadSchema: z.ZodMiniObject<{
|
|
|
555
555
|
}, z.core.$strip>;
|
|
556
556
|
}, z.core.$strip>;
|
|
557
557
|
}, z.core.$strip>;
|
|
558
|
+
declare const WebhookPayloadSchema: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
559
|
+
type: z.ZodMiniLiteral<"integration.create">;
|
|
560
|
+
data: z.ZodMiniObject<{
|
|
561
|
+
/**
|
|
562
|
+
* The unique identifier for this integration connection.
|
|
563
|
+
*/
|
|
564
|
+
connection_id: z.ZodMiniString<string>;
|
|
565
|
+
/**
|
|
566
|
+
* The webhook secret used to verify webhook requests from Top.gg for this connection.
|
|
567
|
+
*/
|
|
568
|
+
webhook_secret: z.ZodMiniString<string>;
|
|
569
|
+
/**
|
|
570
|
+
* The project this integration is connected to.
|
|
571
|
+
*/
|
|
572
|
+
project: z.ZodMiniObject<{
|
|
573
|
+
/**
|
|
574
|
+
* The project's Top.gg ID.
|
|
575
|
+
*/
|
|
576
|
+
id: z.ZodMiniString<string>;
|
|
577
|
+
/**
|
|
578
|
+
* The platform the project is on (e.g., "discord").
|
|
579
|
+
*/
|
|
580
|
+
platform: z.ZodMiniEnum<{
|
|
581
|
+
discord: "discord";
|
|
582
|
+
roblox: "roblox";
|
|
583
|
+
}>;
|
|
584
|
+
/**
|
|
585
|
+
* The platform-specific ID of the project (e.g., Discord Bot ID).
|
|
586
|
+
*/
|
|
587
|
+
platform_id: z.ZodMiniString<string>;
|
|
588
|
+
/**
|
|
589
|
+
* The type of project (e.g., "bot").
|
|
590
|
+
*/
|
|
591
|
+
type: z.ZodMiniEnum<{
|
|
592
|
+
bot: "bot";
|
|
593
|
+
server: "server";
|
|
594
|
+
game: "game";
|
|
595
|
+
}>;
|
|
596
|
+
}, z.core.$strip>;
|
|
597
|
+
/**
|
|
598
|
+
* The user who created this integration connection.
|
|
599
|
+
*/
|
|
600
|
+
user: z.ZodMiniObject<{
|
|
601
|
+
/**
|
|
602
|
+
* The user's Top.gg ID.
|
|
603
|
+
*/
|
|
604
|
+
id: z.ZodMiniString<string>;
|
|
605
|
+
/**
|
|
606
|
+
* The user's platform ID (e.g., Discord ID).
|
|
607
|
+
*/
|
|
608
|
+
platform_id: z.ZodMiniString<string>;
|
|
609
|
+
/**
|
|
610
|
+
* The user's username.
|
|
611
|
+
*/
|
|
612
|
+
name: z.ZodMiniString<string>;
|
|
613
|
+
/**
|
|
614
|
+
* The URL of the user's avatar.
|
|
615
|
+
*/
|
|
616
|
+
avatar_url: z.ZodMiniURL;
|
|
617
|
+
}, z.core.$strip>;
|
|
618
|
+
}, z.core.$strip>;
|
|
619
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
620
|
+
type: z.ZodMiniLiteral<"integration.delete">;
|
|
621
|
+
data: z.ZodMiniObject<{
|
|
622
|
+
/**
|
|
623
|
+
* The unique identifier for the integration connection that was deleted.
|
|
624
|
+
*/
|
|
625
|
+
connection_id: z.ZodMiniString<string>;
|
|
626
|
+
}, z.core.$strip>;
|
|
627
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
628
|
+
type: z.ZodMiniLiteral<"vote.create">;
|
|
629
|
+
data: z.ZodMiniObject<{
|
|
630
|
+
user_id: z.ZodMiniString<string>;
|
|
631
|
+
platform_id: z.ZodMiniString<string>;
|
|
632
|
+
weight: z.ZodMiniNumber<number>;
|
|
633
|
+
created_at: z.iso.ZodMiniISODate;
|
|
634
|
+
expires_at: z.iso.ZodMiniISODate;
|
|
635
|
+
project: z.ZodMiniObject<{
|
|
636
|
+
/**
|
|
637
|
+
* The project's Top.gg ID.
|
|
638
|
+
*/
|
|
639
|
+
id: z.ZodMiniString<string>;
|
|
640
|
+
/**
|
|
641
|
+
* The platform the project is on (e.g., "discord").
|
|
642
|
+
*/
|
|
643
|
+
platform: z.ZodMiniEnum<{
|
|
644
|
+
discord: "discord";
|
|
645
|
+
roblox: "roblox";
|
|
646
|
+
}>;
|
|
647
|
+
/**
|
|
648
|
+
* The platform-specific ID of the project (e.g., Discord Bot ID).
|
|
649
|
+
*/
|
|
650
|
+
platform_id: z.ZodMiniString<string>;
|
|
651
|
+
/**
|
|
652
|
+
* The type of project (e.g., "bot").
|
|
653
|
+
*/
|
|
654
|
+
type: z.ZodMiniEnum<{
|
|
655
|
+
bot: "bot";
|
|
656
|
+
server: "server";
|
|
657
|
+
game: "game";
|
|
658
|
+
}>;
|
|
659
|
+
}, z.core.$strip>;
|
|
660
|
+
user: z.ZodMiniObject<{
|
|
661
|
+
/**
|
|
662
|
+
* The user's Top.gg ID.
|
|
663
|
+
*/
|
|
664
|
+
id: z.ZodMiniString<string>;
|
|
665
|
+
/**
|
|
666
|
+
* The user's platform ID (e.g., Discord ID).
|
|
667
|
+
*/
|
|
668
|
+
platform_id: z.ZodMiniString<string>;
|
|
669
|
+
/**
|
|
670
|
+
* The user's username.
|
|
671
|
+
*/
|
|
672
|
+
name: z.ZodMiniString<string>;
|
|
673
|
+
/**
|
|
674
|
+
* The URL of the user's avatar.
|
|
675
|
+
*/
|
|
676
|
+
avatar_url: z.ZodMiniURL;
|
|
677
|
+
}, z.core.$strip>;
|
|
678
|
+
}, z.core.$strip>;
|
|
679
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
680
|
+
type: z.ZodMiniLiteral<"webhook.test">;
|
|
681
|
+
data: z.ZodMiniObject<{
|
|
682
|
+
/**
|
|
683
|
+
* A test user.
|
|
684
|
+
*/
|
|
685
|
+
user: z.ZodMiniObject<{
|
|
686
|
+
/**
|
|
687
|
+
* The user's Top.gg ID.
|
|
688
|
+
*/
|
|
689
|
+
id: z.ZodMiniString<string>;
|
|
690
|
+
/**
|
|
691
|
+
* The user's platform ID (e.g., Discord ID).
|
|
692
|
+
*/
|
|
693
|
+
platform_id: z.ZodMiniString<string>;
|
|
694
|
+
/**
|
|
695
|
+
* The user's username.
|
|
696
|
+
*/
|
|
697
|
+
name: z.ZodMiniString<string>;
|
|
698
|
+
/**
|
|
699
|
+
* The URL of the user's avatar.
|
|
700
|
+
*/
|
|
701
|
+
avatar_url: z.ZodMiniURL;
|
|
702
|
+
}, z.core.$strip>;
|
|
703
|
+
/**
|
|
704
|
+
* A test project.
|
|
705
|
+
*/
|
|
706
|
+
project: z.ZodMiniObject<{
|
|
707
|
+
/**
|
|
708
|
+
* The project's Top.gg ID.
|
|
709
|
+
*/
|
|
710
|
+
id: z.ZodMiniString<string>;
|
|
711
|
+
/**
|
|
712
|
+
* The platform the project is on (e.g., "discord").
|
|
713
|
+
*/
|
|
714
|
+
platform: z.ZodMiniEnum<{
|
|
715
|
+
discord: "discord";
|
|
716
|
+
roblox: "roblox";
|
|
717
|
+
}>;
|
|
718
|
+
/**
|
|
719
|
+
* The platform-specific ID of the project (e.g., Discord Bot ID).
|
|
720
|
+
*/
|
|
721
|
+
platform_id: z.ZodMiniString<string>;
|
|
722
|
+
/**
|
|
723
|
+
* The type of project (e.g., "bot").
|
|
724
|
+
*/
|
|
725
|
+
type: z.ZodMiniEnum<{
|
|
726
|
+
bot: "bot";
|
|
727
|
+
server: "server";
|
|
728
|
+
game: "game";
|
|
729
|
+
}>;
|
|
730
|
+
}, z.core.$strip>;
|
|
731
|
+
}, z.core.$strip>;
|
|
732
|
+
}, z.core.$strip>], "type">;
|
|
558
733
|
/**
|
|
559
734
|
* Response schema for getting the authenticated project.
|
|
560
735
|
*
|
|
@@ -684,5 +859,5 @@ declare const GetVoteStatusByUserResponseSchema: z.ZodMiniObject<{
|
|
|
684
859
|
weight: z.ZodMiniNumber<number>;
|
|
685
860
|
}, z.core.$strip>;
|
|
686
861
|
//#endregion
|
|
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 };
|
|
862
|
+
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, WebhookPayloadSchema, WebhookTestDataSchema, WebhookTestWebhookPayloadSchema };
|
|
688
863
|
//# sourceMappingURL=validators.d.cts.map
|
package/dist/v1/validators.d.ts
CHANGED
|
@@ -555,6 +555,181 @@ declare const WebhookTestWebhookPayloadSchema: z.ZodMiniObject<{
|
|
|
555
555
|
}, z.core.$strip>;
|
|
556
556
|
}, z.core.$strip>;
|
|
557
557
|
}, z.core.$strip>;
|
|
558
|
+
declare const WebhookPayloadSchema: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
559
|
+
type: z.ZodMiniLiteral<"integration.create">;
|
|
560
|
+
data: z.ZodMiniObject<{
|
|
561
|
+
/**
|
|
562
|
+
* The unique identifier for this integration connection.
|
|
563
|
+
*/
|
|
564
|
+
connection_id: z.ZodMiniString<string>;
|
|
565
|
+
/**
|
|
566
|
+
* The webhook secret used to verify webhook requests from Top.gg for this connection.
|
|
567
|
+
*/
|
|
568
|
+
webhook_secret: z.ZodMiniString<string>;
|
|
569
|
+
/**
|
|
570
|
+
* The project this integration is connected to.
|
|
571
|
+
*/
|
|
572
|
+
project: z.ZodMiniObject<{
|
|
573
|
+
/**
|
|
574
|
+
* The project's Top.gg ID.
|
|
575
|
+
*/
|
|
576
|
+
id: z.ZodMiniString<string>;
|
|
577
|
+
/**
|
|
578
|
+
* The platform the project is on (e.g., "discord").
|
|
579
|
+
*/
|
|
580
|
+
platform: z.ZodMiniEnum<{
|
|
581
|
+
discord: "discord";
|
|
582
|
+
roblox: "roblox";
|
|
583
|
+
}>;
|
|
584
|
+
/**
|
|
585
|
+
* The platform-specific ID of the project (e.g., Discord Bot ID).
|
|
586
|
+
*/
|
|
587
|
+
platform_id: z.ZodMiniString<string>;
|
|
588
|
+
/**
|
|
589
|
+
* The type of project (e.g., "bot").
|
|
590
|
+
*/
|
|
591
|
+
type: z.ZodMiniEnum<{
|
|
592
|
+
bot: "bot";
|
|
593
|
+
server: "server";
|
|
594
|
+
game: "game";
|
|
595
|
+
}>;
|
|
596
|
+
}, z.core.$strip>;
|
|
597
|
+
/**
|
|
598
|
+
* The user who created this integration connection.
|
|
599
|
+
*/
|
|
600
|
+
user: z.ZodMiniObject<{
|
|
601
|
+
/**
|
|
602
|
+
* The user's Top.gg ID.
|
|
603
|
+
*/
|
|
604
|
+
id: z.ZodMiniString<string>;
|
|
605
|
+
/**
|
|
606
|
+
* The user's platform ID (e.g., Discord ID).
|
|
607
|
+
*/
|
|
608
|
+
platform_id: z.ZodMiniString<string>;
|
|
609
|
+
/**
|
|
610
|
+
* The user's username.
|
|
611
|
+
*/
|
|
612
|
+
name: z.ZodMiniString<string>;
|
|
613
|
+
/**
|
|
614
|
+
* The URL of the user's avatar.
|
|
615
|
+
*/
|
|
616
|
+
avatar_url: z.ZodMiniURL;
|
|
617
|
+
}, z.core.$strip>;
|
|
618
|
+
}, z.core.$strip>;
|
|
619
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
620
|
+
type: z.ZodMiniLiteral<"integration.delete">;
|
|
621
|
+
data: z.ZodMiniObject<{
|
|
622
|
+
/**
|
|
623
|
+
* The unique identifier for the integration connection that was deleted.
|
|
624
|
+
*/
|
|
625
|
+
connection_id: z.ZodMiniString<string>;
|
|
626
|
+
}, z.core.$strip>;
|
|
627
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
628
|
+
type: z.ZodMiniLiteral<"vote.create">;
|
|
629
|
+
data: z.ZodMiniObject<{
|
|
630
|
+
user_id: z.ZodMiniString<string>;
|
|
631
|
+
platform_id: z.ZodMiniString<string>;
|
|
632
|
+
weight: z.ZodMiniNumber<number>;
|
|
633
|
+
created_at: z.iso.ZodMiniISODate;
|
|
634
|
+
expires_at: z.iso.ZodMiniISODate;
|
|
635
|
+
project: z.ZodMiniObject<{
|
|
636
|
+
/**
|
|
637
|
+
* The project's Top.gg ID.
|
|
638
|
+
*/
|
|
639
|
+
id: z.ZodMiniString<string>;
|
|
640
|
+
/**
|
|
641
|
+
* The platform the project is on (e.g., "discord").
|
|
642
|
+
*/
|
|
643
|
+
platform: z.ZodMiniEnum<{
|
|
644
|
+
discord: "discord";
|
|
645
|
+
roblox: "roblox";
|
|
646
|
+
}>;
|
|
647
|
+
/**
|
|
648
|
+
* The platform-specific ID of the project (e.g., Discord Bot ID).
|
|
649
|
+
*/
|
|
650
|
+
platform_id: z.ZodMiniString<string>;
|
|
651
|
+
/**
|
|
652
|
+
* The type of project (e.g., "bot").
|
|
653
|
+
*/
|
|
654
|
+
type: z.ZodMiniEnum<{
|
|
655
|
+
bot: "bot";
|
|
656
|
+
server: "server";
|
|
657
|
+
game: "game";
|
|
658
|
+
}>;
|
|
659
|
+
}, z.core.$strip>;
|
|
660
|
+
user: z.ZodMiniObject<{
|
|
661
|
+
/**
|
|
662
|
+
* The user's Top.gg ID.
|
|
663
|
+
*/
|
|
664
|
+
id: z.ZodMiniString<string>;
|
|
665
|
+
/**
|
|
666
|
+
* The user's platform ID (e.g., Discord ID).
|
|
667
|
+
*/
|
|
668
|
+
platform_id: z.ZodMiniString<string>;
|
|
669
|
+
/**
|
|
670
|
+
* The user's username.
|
|
671
|
+
*/
|
|
672
|
+
name: z.ZodMiniString<string>;
|
|
673
|
+
/**
|
|
674
|
+
* The URL of the user's avatar.
|
|
675
|
+
*/
|
|
676
|
+
avatar_url: z.ZodMiniURL;
|
|
677
|
+
}, z.core.$strip>;
|
|
678
|
+
}, z.core.$strip>;
|
|
679
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
680
|
+
type: z.ZodMiniLiteral<"webhook.test">;
|
|
681
|
+
data: z.ZodMiniObject<{
|
|
682
|
+
/**
|
|
683
|
+
* A test user.
|
|
684
|
+
*/
|
|
685
|
+
user: z.ZodMiniObject<{
|
|
686
|
+
/**
|
|
687
|
+
* The user's Top.gg ID.
|
|
688
|
+
*/
|
|
689
|
+
id: z.ZodMiniString<string>;
|
|
690
|
+
/**
|
|
691
|
+
* The user's platform ID (e.g., Discord ID).
|
|
692
|
+
*/
|
|
693
|
+
platform_id: z.ZodMiniString<string>;
|
|
694
|
+
/**
|
|
695
|
+
* The user's username.
|
|
696
|
+
*/
|
|
697
|
+
name: z.ZodMiniString<string>;
|
|
698
|
+
/**
|
|
699
|
+
* The URL of the user's avatar.
|
|
700
|
+
*/
|
|
701
|
+
avatar_url: z.ZodMiniURL;
|
|
702
|
+
}, z.core.$strip>;
|
|
703
|
+
/**
|
|
704
|
+
* A test project.
|
|
705
|
+
*/
|
|
706
|
+
project: z.ZodMiniObject<{
|
|
707
|
+
/**
|
|
708
|
+
* The project's Top.gg ID.
|
|
709
|
+
*/
|
|
710
|
+
id: z.ZodMiniString<string>;
|
|
711
|
+
/**
|
|
712
|
+
* The platform the project is on (e.g., "discord").
|
|
713
|
+
*/
|
|
714
|
+
platform: z.ZodMiniEnum<{
|
|
715
|
+
discord: "discord";
|
|
716
|
+
roblox: "roblox";
|
|
717
|
+
}>;
|
|
718
|
+
/**
|
|
719
|
+
* The platform-specific ID of the project (e.g., Discord Bot ID).
|
|
720
|
+
*/
|
|
721
|
+
platform_id: z.ZodMiniString<string>;
|
|
722
|
+
/**
|
|
723
|
+
* The type of project (e.g., "bot").
|
|
724
|
+
*/
|
|
725
|
+
type: z.ZodMiniEnum<{
|
|
726
|
+
bot: "bot";
|
|
727
|
+
server: "server";
|
|
728
|
+
game: "game";
|
|
729
|
+
}>;
|
|
730
|
+
}, z.core.$strip>;
|
|
731
|
+
}, z.core.$strip>;
|
|
732
|
+
}, z.core.$strip>], "type">;
|
|
558
733
|
/**
|
|
559
734
|
* Response schema for getting the authenticated project.
|
|
560
735
|
*
|
|
@@ -684,5 +859,5 @@ declare const GetVoteStatusByUserResponseSchema: z.ZodMiniObject<{
|
|
|
684
859
|
weight: z.ZodMiniNumber<number>;
|
|
685
860
|
}, z.core.$strip>;
|
|
686
861
|
//#endregion
|
|
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 };
|
|
862
|
+
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, WebhookPayloadSchema, WebhookTestDataSchema, WebhookTestWebhookPayloadSchema };
|
|
688
863
|
//# sourceMappingURL=validators.d.ts.map
|
package/dist/v1/validators.js
CHANGED
|
@@ -140,6 +140,12 @@ const WebhookTestDataSchema = z.object({
|
|
|
140
140
|
* The payload delivered to your webhook endpoint when you send a test webhook from the dashboard or via the API.
|
|
141
141
|
*/
|
|
142
142
|
const WebhookTestWebhookPayloadSchema = WebhookPayloadBaseSchema("webhook.test", WebhookTestDataSchema);
|
|
143
|
+
const WebhookPayloadSchema = z.discriminatedUnion("type", [
|
|
144
|
+
IntegrationCreateWebhookPayloadSchema,
|
|
145
|
+
IntegrationDeleteWebhookPayloadSchema,
|
|
146
|
+
VoteCreateWebhookPayloadSchema,
|
|
147
|
+
WebhookTestWebhookPayloadSchema
|
|
148
|
+
]);
|
|
143
149
|
/**
|
|
144
150
|
* Response schema for getting the authenticated project.
|
|
145
151
|
*
|
|
@@ -202,5 +208,5 @@ const GetVoteStatusByUserResponseSchema = z.object({
|
|
|
202
208
|
});
|
|
203
209
|
|
|
204
210
|
//#endregion
|
|
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 };
|
|
211
|
+
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, WebhookPayloadSchema, WebhookTestDataSchema, WebhookTestWebhookPayloadSchema };
|
|
206
212
|
//# 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\";\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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;CAIjB,aAAa,EAAE,QAAQ;CAIvB,cAAc,EAAE,QAAQ;CAIxB,cAAc,EAAE,QAAQ;CACzB,CAAC;;;;;;;;;;AAWF,MAAa,6BAA6B,EACvC,OAAO;CAMN,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC;CAQ9B,WAAW,EAAE,SAAS,kBAAkB;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"}
|
|
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\";\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 Schema\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// ## Webhook\n\nexport const WebhookPayloadSchema = z.discriminatedUnion(\"type\", [\n IntegrationCreateWebhookPayloadSchema,\n IntegrationDeleteWebhookPayloadSchema,\n VoteCreateWebhookPayloadSchema,\n WebhookTestWebhookPayloadSchema,\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: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;;;;;;;;AASF,MAAa,oCAAoC,EAAE,OAAO;CAIxD,YAAY;CAIZ,YAAY;CAIZ,QAAQ,EAAE,QAAQ;CACnB,CAAC"}
|
package/dist/v1.d.cts
CHANGED
|
@@ -215,6 +215,9 @@ interface WebhookTestData {
|
|
|
215
215
|
* The payload delivered to your webhook endpoint when you send a test webhook from the dashboard or via the API.
|
|
216
216
|
*/
|
|
217
217
|
type WebhookTestWebhookPayload = WebhookPayloadBase<"webhook.test", WebhookTestData>;
|
|
218
|
+
type WebhookPayload<T extends WebhookEventTypes = WebhookEventTypes> = Extract<IntegrationCreateWebhookPayload | IntegrationDeleteWebhookPayload | VoteCreateWebhookPayload | WebhookTestWebhookPayload, {
|
|
219
|
+
type: T;
|
|
220
|
+
}>;
|
|
218
221
|
/**
|
|
219
222
|
* Response for getting the authenticated project.
|
|
220
223
|
*
|
|
@@ -329,5 +332,5 @@ interface GetVoteStatusByUserResponse {
|
|
|
329
332
|
weight: number;
|
|
330
333
|
}
|
|
331
334
|
//#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 };
|
|
335
|
+
export { BaseProject, ErrorResponse, GetProjectResponse, GetProjectVotesQuery, GetProjectVotesResponse, GetVoteStatusByUserQuery, GetVoteStatusByUserResponse, IntegrationCreateData, IntegrationCreateResponse, IntegrationCreateWebhookPayload, IntegrationDeleteData, IntegrationDeleteWebhookPayload, IntegrationWebhookEventType, ProjectPlatformType, ProjectType, ProjectVote, User, UserSource, Vote, VoteCreateData, VoteCreateWebhookPayload, WebhookEventType, WebhookEventTypes, WebhookPayload, WebhookPayloadBase, WebhookTestData, WebhookTestWebhookPayload };
|
|
333
336
|
//# sourceMappingURL=v1.d.cts.map
|
package/dist/v1.d.ts
CHANGED
|
@@ -215,6 +215,9 @@ interface WebhookTestData {
|
|
|
215
215
|
* The payload delivered to your webhook endpoint when you send a test webhook from the dashboard or via the API.
|
|
216
216
|
*/
|
|
217
217
|
type WebhookTestWebhookPayload = WebhookPayloadBase<"webhook.test", WebhookTestData>;
|
|
218
|
+
type WebhookPayload<T extends WebhookEventTypes = WebhookEventTypes> = Extract<IntegrationCreateWebhookPayload | IntegrationDeleteWebhookPayload | VoteCreateWebhookPayload | WebhookTestWebhookPayload, {
|
|
219
|
+
type: T;
|
|
220
|
+
}>;
|
|
218
221
|
/**
|
|
219
222
|
* Response for getting the authenticated project.
|
|
220
223
|
*
|
|
@@ -329,5 +332,5 @@ interface GetVoteStatusByUserResponse {
|
|
|
329
332
|
weight: number;
|
|
330
333
|
}
|
|
331
334
|
//#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 };
|
|
335
|
+
export { BaseProject, ErrorResponse, GetProjectResponse, GetProjectVotesQuery, GetProjectVotesResponse, GetVoteStatusByUserQuery, GetVoteStatusByUserResponse, IntegrationCreateData, IntegrationCreateResponse, IntegrationCreateWebhookPayload, IntegrationDeleteData, IntegrationDeleteWebhookPayload, IntegrationWebhookEventType, ProjectPlatformType, ProjectType, ProjectVote, User, UserSource, Vote, VoteCreateData, VoteCreateWebhookPayload, WebhookEventType, WebhookEventTypes, WebhookPayload, WebhookPayloadBase, WebhookTestData, WebhookTestWebhookPayload };
|
|
333
336
|
//# sourceMappingURL=v1.d.ts.map
|