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.

empty destination URLs on link response schemas

Pedro Ladeira4c7441be1d0f
diff --git a/apps/web/lib/zod/schemas/customers.ts b/apps/web/lib/zod/schemas/customers.ts
index 96ffbe0ab2..cde8225114 100644
--- a/apps/web/lib/zod/schemas/customers.ts
+++ b/apps/web/lib/zod/schemas/customers.ts
@@ -1,6 +1,6 @@
import * as z from "zod/v4";
import { DiscountSchema } from "./discount";
-import { LinkSchema } from "./links";
+import { LinkSchema, linkUrlSchema } from "./links";
import {
booleanQuerySchema,
getCursorPaginationQuerySchema,
@@ -185,9 +185,12 @@ export const CustomerEnrichedSchema = CustomerSchema.extend({
domain: true,
key: true,
shortLink: true,
- url: true,
programId: true,
- }).nullish(),
+ })
+ .extend({
+ url: linkUrlSchema,
+ })
+ .nullish(),
programId: z.string().nullish(),
partner: PartnerSchema.pick({
id: true,
diff --git a/apps/web/lib/zod/schemas/leads.ts b/apps/web/lib/zod/schemas/leads.ts
index 2d1abdd75a..1705afd38f 100644
--- a/apps/web/lib/zod/schemas/leads.ts
+++ b/apps/web/lib/zod/schemas/leads.ts
@@ -2,7 +2,7 @@ import * as z from "zod/v4";
import { clickEventSchema, clickEventSchemaTB } from "./clicks";
import { CustomerSchema } from "./customers";
import { commonDeprecatedEventFields } from "./deprecated";
-import { linkEventSchema, LinkSchema } from "./links";
+import { linkEventSchema, LinkSchema, linkUrlSchema } from "./links";
export const trackLeadRequestSchema = z.object({
clickId: z
@@ -83,12 +83,15 @@ export const trackLeadResponseSchema = z.object({
domain: true,
key: true,
shortLink: true,
- url: true,
partnerId: true,
programId: true,
tenantId: true,
externalId: true,
- }).nullable(),
+ })
+ .extend({
+ url: linkUrlSchema,
+ })
+ .nullable(),
customer: z.object({
name: z.string().nullable(),
email: z.string().nullable(),
diff --git a/apps/web/lib/zod/schemas/links.ts b/apps/web/lib/zod/schemas/links.ts
index ef8fc55747..b30373e2d2 100644
--- a/apps/web/lib/zod/schemas/links.ts
+++ b/apps/web/lib/zod/schemas/links.ts
@@ -847,9 +847,13 @@ export const getLinkInfoQuerySchemaExtended = getLinkInfoQuerySchema.extend({
includeWebhooks: booleanQuerySchema.default(false),
});
+// Root domain links (`_root`) can have an empty destination URL.
+export const linkUrlSchema = z
+ .string()
+ .describe("The destination URL of the short link.");
+
export const linkEventSchema = LinkSchema.extend({
- // here we use string because url can be empty
- url: z.string(),
+ url: linkUrlSchema,
expiredUrl: z.string().nullable(),
// coerce boolean fields
archived: z.coerce.boolean(),
diff --git a/apps/web/lib/zod/schemas/partner-profile.ts b/apps/web/lib/zod/schemas/partner-profile.ts
index 303279daf9..b0858b139d 100644
--- a/apps/web/lib/zod/schemas/partner-profile.ts
+++ b/apps/web/lib/zod/schemas/partner-profile.ts
@@ -26,7 +26,7 @@ import {
} from "./commissions";
import { customerActivityResponseSchema } from "./customer-activity";
import { CustomerEnrichedSchema } from "./customers";
-import { LinkSchema } from "./links";
+import { LinkSchema, linkUrlSchema } from "./links";
import { getPaginationQuerySchema } from "./misc";
import { payoutsQuerySchema } from "./payouts";
import { submittedLeadFormDataSchema } from "./submitted-lead-form";
@@ -46,8 +46,11 @@ export const PartnerEarningsSchema = CommissionSchema.omit({
link: LinkSchema.pick({
id: true,
shortLink: true,
- url: true,
- }).nullish(),
+ })
+ .extend({
+ url: linkUrlSchema,
+ })
+ .nullish(),
});
export const getPartnerEarningsQuerySchema = getCommissionsQuerySchema
@@ -90,13 +93,13 @@ export const PartnerProfileLinkSchema = LinkSchema.pick({
domain: true,
key: true,
shortLink: true,
- url: true,
clicks: true,
leads: true,
sales: true,
saleAmount: true,
comments: true,
}).extend({
+ url: linkUrlSchema,
createdAt: z.string().or(z.date()),
partnerGroupDefaultLinkId: z.string().nullish(),
discountCode: z.string().nullable().default(null),
diff --git a/apps/web/lib/zod/schemas/programs.ts b/apps/web/lib/zod/schemas/programs.ts
index 0c1a5d1076..eb30aded47 100644
--- a/apps/web/lib/zod/schemas/programs.ts
+++ b/apps/web/lib/zod/schemas/programs.ts
@@ -15,7 +15,7 @@ import {
import * as z from "zod/v4";
import { DiscountSchema } from "./discount";
import { GroupSchema } from "./groups";
-import { LinkSchema } from "./links";
+import { LinkSchema, linkUrlSchema } from "./links";
import { programApplicationFormDataWithValuesSchema } from "./program-application-form";
import { programInviteEmailDataSchema } from "./program-invite-email";
import { RewardSchema } from "./rewards";
@@ -114,12 +114,13 @@ export const ProgramPartnerLinkSchema = LinkSchema.pick({
domain: true,
key: true,
shortLink: true,
- url: true,
clicks: true,
leads: true,
conversions: true,
sales: true,
saleAmount: true,
+}).extend({
+ url: linkUrlSchema,
});
export const ProgramEnrollmentApplicationSchema = z.object({
diff --git a/apps/web/lib/zod/schemas/referrals-embed.ts b/apps/web/lib/zod/schemas/referrals-embed.ts
index d5317d97e9..269d4a6a09 100644
--- a/apps/web/lib/zod/schemas/referrals-embed.ts
+++ b/apps/web/lib/zod/schemas/referrals-embed.ts
@@ -1,16 +1,16 @@
import * as z from "zod/v4";
-import { LinkSchema } from "./links";
+import { LinkSchema, linkUrlSchema } from "./links";
export const ReferralsEmbedLinkSchema = LinkSchema.pick({
id: true,
domain: true,
key: true,
- url: true,
shortLink: true,
clicks: true,
leads: true,
sales: true,
saleAmount: true,
}).extend({
+ url: linkUrlSchema,
partnerGroupDefaultLinkId: z.string().nullish(),
});