The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix types
Steven Tey695fdcba25f1
diff --git a/apps/web/lib/api/links/create-link.ts b/apps/web/lib/api/links/create-link.tsindex efe2ffd1d7..2e838b94b6 100644--- a/apps/web/lib/api/links/create-link.ts+++ b/apps/web/lib/api/links/create-link.ts@@ -31,7 +31,6 @@ export async function createLink(link: ProcessedLinkProps) {proxy,geo,publicStats,- partnerId,} = link;const combinedTagIds = combineTagIds(link);@@ -39,8 +38,7 @@ export async function createLink(link: ProcessedLinkProps) {const { utm_source, utm_medium, utm_campaign, utm_term, utm_content } =getParamsFromURL(url);- const { tagId, tagIds, tagNames, webhookIds, programId, tenantId, ...rest } =- link;+ const { tagId, tagIds, tagNames, webhookIds, ...rest } = link;const response = await prisma.link.create({data: {@@ -59,9 +57,6 @@ export async function createLink(link: ProcessedLinkProps) {utm_content,expiresAt: expiresAt ? new Date(expiresAt) : null,geo: geo || Prisma.JsonNull,- programId,- tenantId,- partnerId,// Associate tags by tagNames...(tagNames?.length &&diff --git a/apps/web/lib/api/links/process-link.ts b/apps/web/lib/api/links/process-link.tsindex c5c2b236a4..b0ad6327b3 100644--- a/apps/web/lib/api/links/process-link.ts+++ b/apps/web/lib/api/links/process-link.ts@@ -65,9 +65,10 @@ export async function processLink<T extends Record<string, any>>({doIndex,tagNames,externalId,+ tenantId,+ partnerId,programId,webhookIds,- tenantId,} = payload;let expiresAt: string | Date | null | undefined = payload.expiresAt;@@ -372,6 +373,18 @@ export async function processLink<T extends Record<string, any>>({if (programId) {const program = await prisma.program.findUnique({where: { id: programId },+ select: {+ workspaceId: true,+ ...(!partnerId && tenantId+ ? {+ partners: {+ where: {+ tenantId,+ },+ },+ }+ : {}),+ },});if (!program || program.workspaceId !== workspace?.id) {@@ -381,6 +394,11 @@ export async function processLink<T extends Record<string, any>>({code: "not_found",};}++ if (!partnerId) {+ partnerId =+ program.partners.length > 0 ? program.partners[0].partnerId : null;+ }}// Webhook validity checks@@ -450,21 +468,6 @@ export async function processLink<T extends Record<string, any>>({}}- const partner =- programId && tenantId- ? await prisma.programEnrollment.findUnique({- where: {- tenantId_programId: {- tenantId,- programId,- },- },- select: {- partnerId: true,- },- })- : null;-// remove polyfill attributes from payloaddelete payload["shortLink"];delete payload["qrCode"];@@ -482,6 +485,8 @@ export async function processLink<T extends Record<string, any>>({url,expiresAt,expiredUrl,+ // partnerId derived from payload or program enrollment+ partnerId: partnerId || null,// make sure projectId is set to the current workspaceprojectId: workspace?.id || null,// if userId is passed, set it (we don't change the userId if it's already set, e.g. when editing a link)@@ -491,9 +496,6 @@ export async function processLink<T extends Record<string, any>>({...(webhookIds && {webhookIds,}),- ...(partner && {- partnerId: partner.partnerId,- }),},error: null,};diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.tsindex 1615ab8386..3bcb770b12 100644--- a/apps/web/lib/types.ts+++ b/apps/web/lib/types.ts@@ -225,7 +225,6 @@ export type ProcessedLinkProps = Omit<NewLinkProps, ProcessedLinkOverrides> &Pick<LinkProps, ProcessedLinkOverrides> & { userId?: LinkProps["userId"] } & {createdAt?: Date;id?: string;- partnerId?: string;};export const plans = [diff --git a/apps/web/lib/zod/schemas/links.ts b/apps/web/lib/zod/schemas/links.tsindex ac10c5b17a..8d403106aa 100644--- a/apps/web/lib/zod/schemas/links.ts+++ b/apps/web/lib/zod/schemas/links.ts@@ -189,6 +189,10 @@ export const createLinkBodySchema = z.object({.string().nullish().describe("The ID of the program the short link is associated with."),+ partnerId: z+ .string()+ .nullish()+ .describe("The ID of the partner the short link is associated with."),prefix: z.string().optional()