The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
improve webhook schema
Steven Teye5414973988e
diff --git a/apps/web/lib/openapi/index.ts b/apps/web/lib/openapi/index.tsindex 0c4cd752c3..0277effc62 100644--- a/apps/web/lib/openapi/index.ts+++ b/apps/web/lib/openapi/index.ts@@ -4,6 +4,11 @@ import { LinkSchema } from "@/lib/zod/schemas/links";import { TagSchema } from "@/lib/zod/schemas/tags";import { WorkspaceSchema } from "@/lib/zod/schemas/workspaces";import { createDocument } from "zod-openapi";+import {+ clickWebhookEventSchema,+ leadWebhookEventSchema,+ saleWebhookEventSchema,+} from "../webhook/schemas";import { analyticsPath } from "./analytics";import { domainsPaths } from "./domains";import { eventsPath } from "./events";@@ -12,7 +17,6 @@ import { metatagsPath } from "./metatags";import { qrCodePaths } from "./qr";import { tagsPaths } from "./tags";import { trackPaths } from "./track";-import { LeadCreatedEvent, SaleCreatedEvent } from "./webhooks";import { workspacesPaths } from "./workspaces";export const document = createDocument({@@ -55,8 +59,9 @@ export const document = createDocument({WorkspaceSchema,TagSchema,DomainSchema,- LeadCreatedEvent,- SaleCreatedEvent,+ clickWebhookEventSchema,+ leadWebhookEventSchema,+ saleWebhookEventSchema,},securitySchemes: {token: {diff --git a/apps/web/lib/openapi/webhooks/index.ts b/apps/web/lib/openapi/webhooks/index.tsdeleted file mode 100644index fb11cdd5de..0000000000--- a/apps/web/lib/openapi/webhooks/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from "./lead-created";-export * from "./sale-created";diff --git a/apps/web/lib/openapi/webhooks/lead-created.ts b/apps/web/lib/openapi/webhooks/lead-created.tsdeleted file mode 100644index 579ec7d267..0000000000--- a/apps/web/lib/openapi/webhooks/lead-created.ts+++ /dev/null@@ -1,22 +0,0 @@-import { leadWebhookEventSchema } from "@/lib/webhook/schemas";-import { ZodOpenApiOperationObject } from "zod-openapi";--export const LeadCreatedEvent: ZodOpenApiOperationObject = {- "x-speakeasy-include": true,- "x-speakeasy-name-override": "LeadCreatedEvent",- summary: "Lead created event",- description: "A webhook that is called when a lead is created.",- requestBody: {- description: "Details about the lead that was created.",- content: {- "application/json": {- schema: leadWebhookEventSchema,- },- },- },- responses: {- "200": {- description: "The webhook was processed successfully.",- },- },-};diff --git a/apps/web/lib/openapi/webhooks/sale-created.ts b/apps/web/lib/openapi/webhooks/sale-created.tsdeleted file mode 100644index 268e8ac397..0000000000--- a/apps/web/lib/openapi/webhooks/sale-created.ts+++ /dev/null@@ -1,22 +0,0 @@-import { saleWebhookEventSchema } from "@/lib/webhook/schemas";-import { ZodOpenApiOperationObject } from "zod-openapi";--export const SaleCreatedEvent: ZodOpenApiOperationObject = {- "x-speakeasy-include": true,- "x-speakeasy-name-override": "SaleCreatedEvent",- summary: "Sale created",- description: "A webhook that is called when a sale is created.",- requestBody: {- description: "Details about the sale that was created.",- content: {- "application/json": {- schema: saleWebhookEventSchema,- },- },- },- responses: {- "200": {- description: "The webhook was processed successfully.",- },- },-};diff --git a/apps/web/lib/webhook/schemas.ts b/apps/web/lib/webhook/schemas.tsindex 1fc9ff2e20..b20fe74170 100644--- a/apps/web/lib/webhook/schemas.ts+++ b/apps/web/lib/webhook/schemas.ts@@ -17,25 +17,37 @@ const saleSchema = z.object({invoiceId: z.string().nullable(),});-export const clickWebhookEventSchema = z.object({- click: clickEventSchema,- link: linkEventSchema,-});+export const clickWebhookEventSchema = z+ .object({+ click: clickEventSchema,+ link: linkEventSchema,+ })+ .openapi({+ title: "ClickWebhookEvent",+ });-export const leadWebhookEventSchema = z.object({- eventName: z.string(),- customer: customerSchema,- click: clickEventSchema,- link: linkEventSchema,-});+export const leadWebhookEventSchema = z+ .object({+ eventName: z.string(),+ customer: customerSchema,+ click: clickEventSchema,+ link: linkEventSchema,+ })+ .openapi({+ title: "LeadWebhookEvent",+ });-export const saleWebhookEventSchema = z.object({- eventName: z.string(),- customer: customerSchema,- click: clickEventSchema,- link: linkEventSchema,- sale: saleSchema,-});+export const saleWebhookEventSchema = z+ .object({+ eventName: z.string(),+ customer: customerSchema,+ click: clickEventSchema,+ link: linkEventSchema,+ sale: saleSchema,+ })+ .openapi({+ title: "SaleWebhookEvent",+ });// Schema of the payload sent to the webhook endpoint by Dubexport const webhookPayloadSchema = z.object({