The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Merge branch 'main' into tim/multiple-tags-cleanup
Tim Wilson693468b5cee9
diff --cc apps/web/app/api/links/[linkId]/route.tsindex 3f91ac12e7,0e58921952..6506574813--- a/apps/web/app/api/links/[linkId]/route.ts+++ b/apps/web/app/api/links/[linkId]/route.ts@@@ -2,8 -2,8 +2,8 @@@ import { DubApiError, ErrorCodes } froimport { deleteLink, editLink, processLink } from "@/lib/api/links";import { withAuth } from "@/lib/auth";import prisma from "@/lib/prisma";-import { LinkWithTagIdsProps } from "@/lib/types";+import { NewLinkProps } from "@/lib/types";- import { updateLinkBodySchema } from "@/lib/zod/schemas/links";+ import { updateLinkBodySchema } from "@/lib/zod/schemas";import { NextResponse } from "next/server";// GET /api/links/[linkId] – get a linkdiff --cc apps/web/app/api/links/bulk/route.tsindex 006dd66c01,6b42df5063..66e3b31d8c--- a/apps/web/app/api/links/bulk/route.ts+++ b/apps/web/app/api/links/bulk/route.ts@@@ -2,8 -2,8 +2,8 @@@ import { DubApiError, exceededLimitErroimport { bulkCreateLinks, combineTagIds, processLink } from "@/lib/api/links";import { withAuth } from "@/lib/auth";import prisma from "@/lib/prisma";-import { LinkWithTagIdsProps } from "@/lib/types";+import { ProcessedLinkProps } from "@/lib/types";- import { bulkCreateLinksBodySchema } from "@/lib/zod/schemas/links";+ import { bulkCreateLinksBodySchema } from "@/lib/zod/schemas";import { NextResponse } from "next/server";// POST /api/links/bulk – bulk create up to 100 linksdiff --cc apps/web/app/api/links/route.tsindex 9604d0a9f4,9f4629bb9e..c7d8aaf82b--- a/apps/web/app/api/links/route.ts+++ b/apps/web/app/api/links/route.ts@@@ -1,11 -1,9 +1,8 @@@import { DubApiError, ErrorCodes } from "@/lib/api/errors";import { createLink, getLinksForWorkspace, processLink } from "@/lib/api/links";import { withAuth } from "@/lib/auth";-import { LinkWithTagIdsProps } from "@/lib/types";import { ratelimit } from "@/lib/upstash";- import {- createLinkBodySchema,- getLinksQuerySchema,- } from "@/lib/zod/schemas/links";+ import { createLinkBodySchema, getLinksQuerySchema } from "@/lib/zod/schemas";import { LOCALHOST_IP } from "@dub/utils";import { NextResponse } from "next/server";diff --cc apps/web/lib/api/links/process-link.tsindex 7078d227ed,c5d21a86e6..f7b0a38732--- a/apps/web/lib/api/links/process-link.ts+++ b/apps/web/lib/api/links/process-link.ts@@@ -80,11 -66,24 +80,24 @@@ export async function processLink<T ext(!workspace || workspace.plan === "free") &&(!createdAt || new Date(createdAt) > new Date("2024-01-19"))) {- if (proxy || password || rewrite || expiresAt || ios || android || geo) {+ if (proxy || password || rewrite || expiresAtRaw || ios || android || geo) {+ const proFeaturesString = [+ proxy && "custom social media cards",+ password && "password protection",+ rewrite && "link cloaking",- expiresAt && "link expiration",++ expiresAtRaw && "link expiration",+ ios && "iOS targeting",+ android && "Android targeting",+ geo && "geo targeting",+ ]+ .filter(Boolean)+ .join(", ")+ // final one should be "and" instead of comma+ .replace(/, ([^,]*)$/, " and $1");+return {link: payload,- error:- "You can only use custom social media cards, password-protection, link cloaking, link expiration, device and geo targeting on a Pro plan and above. Upgrade to Pro to use these features.",+ error: `You can only use ${proFeaturesString} on a Pro plan and above. Upgrade to Pro to use these features.`,code: "forbidden",};}diff --cc apps/web/lib/zod/schemas/links.tsindex 64e579a6e2,0f86edb48c..bfe566ae69--- a/apps/web/lib/zod/schemas/links.ts+++ b/apps/web/lib/zod/schemas/links.ts@@@ -132,6 -135,24 +142,31 @@@ export const createLinkBodySchema = z.o.optional().default(false).describe("Whether the short link is archived."),+ publicStats: z+ .boolean()+ .optional()+ .default(false)+ .describe("Whether the short link's stats are publicly accessible."),+ tagId: z+ .string()+ .nullish()+ .describe(+ "The unique ID of the tag assigned to the short link. This field is deprecated – use `tagIds` instead.",+ )+ .openapi({ deprecated: true }),+ tagIds: z+ .union([z.string(), z.array(z.string())])+ .transform((v) => (Array.isArray(v) ? v : v.split(",")))+ .optional()+ .describe("The unique IDs of the tags assigned to the short link."),++ tagNames: z++ .union([z.string(), z.array(z.string())])++ .transform((v) => (Array.isArray(v) ? v : v.split(",")))++ .optional()++ .describe(++ "The unique name of the tags assigned to the short link (case insensitive).",++ ),+ comments: z.string().nullish().describe("The comments for the short link."),expiresAt: z.string().nullish()