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.

add schema descriptions

Steven Tey400f042b7917
diff --git a/apps/web/lib/api/partners/transform-partner.ts b/apps/web/lib/api/partners/transform-partner.ts
index 7ee79b9a5b..fc08257eb7 100644
--- a/apps/web/lib/api/partners/transform-partner.ts
+++ b/apps/web/lib/api/partners/transform-partner.ts
@@ -5,6 +5,8 @@ import {
import { getPrettyUrl } from "@dub/utils";
import { z } from "zod";
+// TODO: This is nice to have but ideally response types should be the same
+// across all partners endpoints, so we're not using this for now.
export const transformPartner = (
partner:
| z.infer<typeof EnrolledPartnerSchema>
diff --git a/apps/web/lib/zod/schemas/partners.ts b/apps/web/lib/zod/schemas/partners.ts
index a443c9c37b..c8e2a22e85 100644
--- a/apps/web/lib/zod/schemas/partners.ts
+++ b/apps/web/lib/zod/schemas/partners.ts
@@ -123,20 +123,57 @@ export const PartnerOnlinePresenceSchema = z.object({
export const PartnerSchema = z
.object({
- id: z.string(),
- name: z.string(),
- companyName: z.string().nullable(),
- profileType: z.nativeEnum(PartnerProfileType),
- email: z.string().nullable(),
- image: z.string().nullable(),
- description: z.string().nullish(),
- country: z.string().nullable(),
- status: z.nativeEnum(PartnerStatus),
- stripeConnectId: z.string().nullable(),
- paypalEmail: z.string().nullable(),
- payoutsEnabledAt: z.date().nullable(),
- createdAt: z.date(),
- updatedAt: z.date(),
+ id: z.string().describe("The partner's unique ID on Dub."),
+ name: z.string().max(190).describe("The partner's full legal name."),
+ companyName: z
+ .string()
+ .max(190)
+ .nullable()
+ .describe(
+ "If the partner profile type is a company, this is the partner's legal company name.",
+ ),
+ profileType: z
+ .nativeEnum(PartnerProfileType)
+ .describe("The partner's profile type on Dub."),
+ email: z
+ .string()
+ .max(190)
+ .nullable()
+ .describe(
+ "The partner's email address. Should be a unique value across Dub.",
+ ),
+ image: z.string().nullable().describe("The partner's avatar image."),
+ description: z
+ .string()
+ .max(1000)
+ .nullish()
+ .describe("A brief description of the partner and their background."),
+ country: z
+ .string()
+ .nullable()
+ .describe("The partner's country (required for tax purposes)."),
+ status: z
+ .nativeEnum(PartnerStatus)
+ .describe("The partner's verification status on Dub."),
+ stripeConnectId: z
+ .string()
+ .nullable()
+ .describe(
+ "The partner's Stripe Connect ID (for receiving payouts via Stripe).",
+ ),
+ paypalEmail: z
+ .string()
+ .nullable()
+ .describe(
+ "The partner's PayPal email (for receiving payouts via PayPal).",
+ ),
+ payoutsEnabledAt: z
+ .date()
+ .nullable()
+ .describe("The date when the partner enabled payouts."),
+ createdAt: z
+ .date()
+ .describe("The date when the partner was created on Dub."),
})
.merge(PartnerOnlinePresenceSchema);
@@ -168,14 +205,38 @@ export const EnrolledPartnerSchema = PartnerSchema.pick({
}),
)
.extend({
- clicks: z.number().default(0),
- leads: z.number().default(0),
- sales: z.number().default(0),
- saleAmount: z.number().default(0),
- earnings: z.number().default(0),
+ clicks: z
+ .number()
+ .default(0)
+ .describe("The total number of clicks on the partner's links."),
+ leads: z
+ .number()
+ .default(0)
+ .describe("The total number of leads generated by the partner's links."),
+ sales: z
+ .number()
+ .default(0)
+ .describe("The total number of sales generated by the partner's links."),
+ saleAmount: z
+ .number()
+ .default(0)
+ .describe(
+ "The total amount of sales (in cents) generated by the partner's links.",
+ ),
+ earnings: z
+ .number()
+ .default(0)
+ .describe(
+ "The total earnings/commissions accrued by the partner's links.",
+ ),
})
.extend({
- applicationId: z.string().nullish(),
+ applicationId: z
+ .string()
+ .nullish()
+ .describe(
+ "If the partner submitted an application to join the program, this is the ID of the application.",
+ ),
});
// Used internally in the Dub dashboard for partners table
diff --git a/apps/web/lib/zod/schemas/programs.ts b/apps/web/lib/zod/schemas/programs.ts
index 82ab8cabad..c1479da60d 100644
--- a/apps/web/lib/zod/schemas/programs.ts
+++ b/apps/web/lib/zod/schemas/programs.ts
@@ -85,12 +85,22 @@ export const ProgramPartnerLinkSchema = LinkSchema.pick({
});
export const ProgramEnrollmentSchema = z.object({
- partnerId: z.string(),
- tenantId: z.string().nullable(),
- programId: z.string(),
+ partnerId: z.string().describe("The partner's unique ID on Dub."),
+ tenantId: z
+ .string()
+ .nullable()
+ .describe(
+ "The partner's unique ID within your database. Can be useful for associating the partner with a user in your database and retrieving/update their data in the future.",
+ ),
+ programId: z.string().describe("The program's unique ID on Dub."),
program: ProgramSchema,
- status: z.nativeEnum(ProgramEnrollmentStatus),
- links: z.array(ProgramPartnerLinkSchema).nullable(),
+ status: z
+ .nativeEnum(ProgramEnrollmentStatus)
+ .describe("The status of the partner's enrollment in the program."),
+ links: z
+ .array(ProgramPartnerLinkSchema)
+ .nullable()
+ .describe("The partner's referral links in this program."),
rewards: z.array(RewardSchema).nullish(),
discount: DiscountSchema.nullish(),
createdAt: z.date(),