The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Refactor partner webhook schemas and remove unused fields
Kiran K517e596ff521
diff --git a/apps/web/app/api/partners/route.ts b/apps/web/app/api/partners/route.tsindex 4d1fed2e60..4d89f3dca4 100644--- a/apps/web/app/api/partners/route.ts+++ b/apps/web/app/api/partners/route.ts@@ -135,17 +135,8 @@ export const GET = withWorkspace(// POST /api/partners - add a partner for a programexport const POST = withWorkspace(async ({ workspace, req, session }) => {- const {- programId,- name,- email,- image,- username,- country,- description,- linkProps,- tenantId,- } = createPartnerSchema.parse(await parseRequestBody(req));+ const { programId, name, email, image, username, linkProps, tenantId } =+ createPartnerSchema.parse(await parseRequestBody(req));const program = await getProgramOrThrow({workspaceId: workspace.id,@@ -200,8 +191,6 @@ export const POST = withWorkspace(name,email,image,- // country,- // description,},});diff --git a/apps/web/lib/api/partners/enroll-partner.ts b/apps/web/lib/api/partners/enroll-partner.tsindex 9aba8ff5b3..be252ea4ef 100644--- a/apps/web/lib/api/partners/enroll-partner.ts+++ b/apps/web/lib/api/partners/enroll-partner.ts@@ -5,7 +5,7 @@ import { updateConfig } from "@/lib/edge-config";import { recordLink } from "@/lib/tinybird";import { WorkspaceProps } from "@/lib/types";import { sendWorkspaceWebhook } from "@/lib/webhook/publish";-import { partnerWebhookEventSchema } from "@/lib/webhook/schemas";+import { PartnerSchema } from "@/lib/zod/schemas/partners";import { prisma } from "@dub/prisma";import { Prisma } from "@dub/prisma/client";import { waitUntil } from "@vercel/functions";@@ -120,7 +120,7 @@ export const enrollPartner = async ({sendWorkspaceWebhook({workspace,trigger: "partner.created",- data: partnerWebhookEventSchema.parse(upsertedPartner),+ data: PartnerSchema.parse(upsertedPartner),}),]),);diff --git a/apps/web/lib/webhook/schemas.ts b/apps/web/lib/webhook/schemas.tsindex 14787305fc..af228ec961 100644--- a/apps/web/lib/webhook/schemas.ts+++ b/apps/web/lib/webhook/schemas.ts@@ -32,11 +32,6 @@ export const saleWebhookEventSchema = z.object({sale: saleSchema,});-export const partnerWebhookEventSchema = z.object({- eventName: z.string(),- partner: PartnerSchema,-});-// Schema of the payload sent to the webhook endpoint by Dubexport const webhookPayloadSchema = z.object({id: z.string().describe("Unique identifier for the event."),@@ -109,7 +104,7 @@ export const webhookEventSchema = zid: z.string(),event: z.literal("partner.created"),createdAt: z.string(),- data: partnerWebhookEventSchema,+ data: PartnerSchema,}).openapi({ref: "PartnerCreatedEvent",diff --git a/apps/web/lib/webhook/types.ts b/apps/web/lib/webhook/types.tsindex a48dc3faf7..86095f0b04 100644--- a/apps/web/lib/webhook/types.ts+++ b/apps/web/lib/webhook/types.ts@@ -1,10 +1,10 @@import z from "../zod";import { linkEventSchema } from "../zod/schemas/links";+import { PartnerSchema } from "../zod/schemas/partners";import { WEBHOOK_TRIGGERS } from "./constants";import {clickWebhookEventSchema,leadWebhookEventSchema,- partnerWebhookEventSchema,saleWebhookEventSchema,} from "./schemas";@@ -19,7 +19,7 @@ export type LeadEventDataProps = z.infer<typeof leadWebhookEventSchema>;export type SaleEventDataProps = z.infer<typeof saleWebhookEventSchema>;-export type PartnerEventDataProps = z.infer<typeof partnerWebhookEventSchema>;+export type PartnerEventDataProps = z.infer<typeof PartnerSchema>;export type EventDataProps =| LinkEventDataProps@@ -35,5 +35,3 @@ export type ClickEventWebhookData = z.infer<typeof clickWebhookEventSchema>;export type LeadEventWebhookData = z.infer<typeof leadWebhookEventSchema>;export type SaleEventWebhookData = z.infer<typeof saleWebhookEventSchema>;--export type PartnerEventWebhookData = z.infer<typeof partnerWebhookEventSchema>;