Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

simplify partner object in CommissionEnrichedSchema

Steven Tey94bc4514203f
diff --git a/apps/web/lib/zod/schemas/commissions.ts b/apps/web/lib/zod/schemas/commissions.ts
index 346501a7d0..a50ff45edf 100644
--- a/apps/web/lib/zod/schemas/commissions.ts
+++ b/apps/web/lib/zod/schemas/commissions.ts
@@ -4,7 +4,6 @@ import { z } from "zod";
import { CustomerSchema } from "./customers";
import { getPaginationQuerySchema } from "./misc";
import { PartnerSchema } from "./partners";
-import { ProgramEnrollmentSchema } from "./programs";
import { parseDateSchema } from "./utils";
export const CommissionSchema = z.object({
@@ -30,11 +29,14 @@ export const CommissionSchema = z.object({
// Represents the commission object used in webhook and API responses (/api/commissions/**)
export const CommissionEnrichedSchema = CommissionSchema.merge(
z.object({
- partner: PartnerSchema.merge(
- ProgramEnrollmentSchema.pick({
- status: true,
- }),
- ),
+ partner: PartnerSchema.pick({
+ id: true,
+ name: true,
+ email: true,
+ image: true,
+ payoutsEnabledAt: true,
+ country: true,
+ }),
customer: CustomerSchema.nullish(), // customer can be null for click-based / custom commissions
}),
);
diff --git a/apps/web/lib/zod/schemas/customers.ts b/apps/web/lib/zod/schemas/customers.ts
index eb13d166a9..0daf28cf5d 100644
--- a/apps/web/lib/zod/schemas/customers.ts
+++ b/apps/web/lib/zod/schemas/customers.ts
@@ -103,6 +103,7 @@ export const createCustomerBodySchema = z.object({
export const updateCustomerBodySchema = createCustomerBodySchema.partial();
+// used in webhook responses + regular /customers endpoints (without expanded fields)
export const CustomerSchema = z.object({
id: z
.string()