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 schemas

Tim Wilson5dc22e61f6f6
diff --git a/apps/web/lib/actions/partners/update-partner-profile.ts b/apps/web/lib/actions/partners/update-partner-profile.ts
index a55641c123..72087e4e9e 100644
--- a/apps/web/lib/actions/partners/update-partner-profile.ts
+++ b/apps/web/lib/actions/partners/update-partner-profile.ts
@@ -3,6 +3,7 @@
import { confirmEmailChange } from "@/lib/auth/confirm-email-change";
import { qstash } from "@/lib/cron";
import { storage } from "@/lib/storage";
+import { PartnerProfileSchema } from "@/lib/zod/schemas/partners";
import { prisma } from "@dub/prisma";
import {
APP_DOMAIN_WITH_NGROK,
@@ -28,6 +29,7 @@ const updatePartnerProfileSchema = z
profileType: z.nativeEnum(PartnerProfileType),
companyName: z.string().nullable(),
})
+ .merge(PartnerProfileSchema.partial())
.refine(
(data) => {
if (data.profileType === "company") {
diff --git a/apps/web/lib/zod/schemas/partners.ts b/apps/web/lib/zod/schemas/partners.ts
index ca1adfc412..ac871e095b 100644
--- a/apps/web/lib/zod/schemas/partners.ts
+++ b/apps/web/lib/zod/schemas/partners.ts
@@ -1,9 +1,14 @@
import { ALLOWED_MIN_WITHDRAWAL_AMOUNTS } from "@/lib/partners/constants";
import {
+ AudienceLocation,
+ IndustryInterest,
+ MonthlyTraffic,
PartnerBannedReason,
PartnerProfileType,
PartnerStatus,
+ PreferredEarningStructure,
ProgramEnrollmentStatus,
+ SalesChannel,
} from "@dub/prisma/client";
import {
COUNTRY_CODES,
@@ -236,6 +241,24 @@ export const PartnerOnlinePresenceSchema = z.object({
tiktokVerifiedAt: z.date().nullish(),
});
+export const PartnerProfileSchema = z.object({
+ monthlyTraffic: z
+ .nativeEnum(MonthlyTraffic)
+ .describe("The partner's monthly traffic."),
+ industryInterests: z
+ .array(z.nativeEnum(IndustryInterest))
+ .describe("The partner's industry interests."),
+ audienceLocations: z
+ .array(z.nativeEnum(AudienceLocation))
+ .describe("The partner's audience locations."),
+ preferredEarningStructure: z
+ .nativeEnum(PreferredEarningStructure)
+ .describe("The partner's preferred earning structure."),
+ salesChannels: z
+ .array(z.nativeEnum(SalesChannel))
+ .describe("The partner's sales channels."),
+});
+
export const PartnerSchema = z
.object({
id: z.string().describe("The partner's unique ID on Dub."),
@@ -300,7 +323,11 @@ export const PartnerSchema = z
.date()
.describe("The date when the partner was created on Dub."),
})
- .merge(PartnerOnlinePresenceSchema);
+ .merge(PartnerOnlinePresenceSchema)
+ .merge(PartnerProfileSchema.partial());
+
+export const PartnerWithProfileSchema =
+ PartnerSchema.merge(PartnerProfileSchema);
// Used externally by GET+POST /api/partners and partner.enrolled webhook
export const EnrolledPartnerSchema = PartnerSchema.pick({
diff --git a/packages/prisma/client.ts b/packages/prisma/client.ts
index 81766f1178..b3d5fcb74b 100644
--- a/packages/prisma/client.ts
+++ b/packages/prisma/client.ts
@@ -1,6 +1,7 @@
export * from "@prisma/client";
export {
+ AudienceLocation,
BountyPerformanceScope,
BountySubmissionRejectionReason,
BountySubmissionStatus,
@@ -10,7 +11,9 @@ export {
EventType,
FolderType,
FolderUserRole,
+ IndustryInterest,
InvoiceStatus,
+ MonthlyTraffic,
NotificationEmailType,
PartnerBannedReason,
PartnerLinkStructure,
@@ -18,10 +21,12 @@ export {
PartnerRole,
PartnerStatus,
PayoutStatus,
+ PreferredEarningStructure,
Prisma,
ProgramEnrollmentStatus,
RewardStructure,
Role,
+ SalesChannel,
WebhookReceiver,
WorkflowTrigger,
WorkflowTriggerType,
diff --git a/packages/prisma/schema/partner.prisma b/packages/prisma/schema/partner.prisma
index 72b7735545..1b4b4f4f51 100644
--- a/packages/prisma/schema/partner.prisma
+++ b/packages/prisma/schema/partner.prisma
@@ -14,6 +14,14 @@ enum PartnerProfileType {
company
}
+enum MonthlyTraffic {
+ ZeroToOneThousand
+ OneThousandToTenThousand
+ TenThousandToFiftyThousand
+ FiftyThousandToOneHundredThousand
+ OneHundredThousandPlus
+}
+
model Partner {
id String @id @default(cuid())
name String
@@ -49,6 +57,7 @@ model Partner {
tiktok String?
tiktokVerifiedAt DateTime?
invoiceSettings Json?
+ monthlyTraffic MonthlyTraffic?
programs ProgramEnrollment[]
users PartnerUser[]
@@ -59,6 +68,11 @@ model Partner {
messages Message[]
sentMessages Message[] @relation("SenderPartner")
comments PartnerComment[]
+
+ industryInterests PartnerIndustryInterest[]
+ audienceLocations PartnerAudienceLocation[]
+ preferredEarningStructure PartnerPreferredEarningStructure[]
+ salesChannels PartnerSalesChannel[]
}
model PartnerInvite {
@@ -100,4 +114,98 @@ model PartnerNotificationPreferences {
newMessageFromProgram Boolean @default(true)
partnerUser PartnerUser @relation(fields: [partnerUserId], references: [id], onDelete: Cascade)
+}
+
+enum IndustryInterest {
+ SaaS
+ DevTool
+ AI
+ Creative_And_Design
+ Productivity_Software
+ Marketing
+ Gaming
+ Finance
+ Sales
+ Ecommerce
+ Customer_Service_And_Support
+ Content_Management
+ Human_Resources
+ Security
+ Analytics_And_Data
+ Social_Media
+ Consumer_Tech
+ Education_And_Learning
+ Health_And_Fitness
+ Food_And_Beverage
+ Travel_And_Lifestyle
+ Entertainment_And_Media
+ Sports
+ Science_And_Engineering
+}
+
+model PartnerIndustryInterest {
+ partnerId String
+ industryInterest IndustryInterest
+
+ partner Partner @relation(fields: [partnerId], references: [id], onDelete: Cascade)
+
+ @@unique([partnerId, industryInterest])
+ @@index(partnerId)
+}
+
+enum AudienceLocation {
+ North_America
+ South_America
+ Africa
+ Asia
+ Europe
+ Oceania
+}
+
+model PartnerAudienceLocation {
+ partnerId String
+ audienceLocation AudienceLocation
+
+ partner Partner @relation(fields: [partnerId], references: [id], onDelete: Cascade)
+
+ @@unique([partnerId, audienceLocation])
+ @@index(partnerId)
+}
+
+enum PreferredEarningStructure {
+ Revenue_Share
+ Per_Lead
+ Per_Sale
+ Per_Click
+ One_Time_Payment
+}
+
+model PartnerPreferredEarningStructure {
+ partnerId String
+ preferredEarningStructure PreferredEarningStructure
+
+ partner Partner @relation(fields: [partnerId], references: [id], onDelete: Cascade)
+
+ @@unique([partnerId, preferredEarningStructure])
+ @@index(partnerId)
+}
+
+enum SalesChannel {
+ Blogs
+ Coupons
+ Direct_Reselling
+ Newsletters
+ Social_Media
+ Events
+ Company_Referrals
+}
+
+model PartnerSalesChannel {
+ partnerId String
+ salesChannel SalesChannel
+
+ partner Partner @relation(fields: [partnerId], references: [id], onDelete: Cascade)
+
+ @@unique([partnerId, salesChannel])
+ @@index(partnerId)
}
\ No newline at end of file