The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fixed a bunch of stuff
Steven Tey751a025facd6
diff --git a/apps/web/app/api/analytics/edge/[endpoint]/route.ts b/apps/web/app/api/analytics/edge/[endpoint]/route.tsindex 0f5090ce9a..1a851016a3 100644--- a/apps/web/app/api/analytics/edge/[endpoint]/route.ts+++ b/apps/web/app/api/analytics/edge/[endpoint]/route.ts@@ -5,7 +5,7 @@ import {handleAndReturnErrorResponse,} from "@/lib/api/errors";import { getIdentityHash } from "@/lib/edge";-import { getDomainOrLink, getProjectViaEdge } from "@/lib/planetscale";+import { getDomainOrLink, getWorkspaceViaEdge } from "@/lib/planetscale";import { ratelimit } from "@/lib/upstash";import {analyticsEndpointSchema,@@ -62,10 +62,10 @@ export const GET = async (message: "Analytics for this link are not public",});}- const project =- link?.projectId && (await getProjectViaEdge(link.projectId));+ const workspace =+ link?.projectId && (await getWorkspaceViaEdge(link.projectId));if (- (!project || project.plan === "free") &&+ (!workspace || workspace.plan === "free") &&(interval === "all" || interval === "90d")) {throw new DubApiError({@@ -73,12 +73,12 @@ export const GET = async (message: "Need higher plan",});}- if (project && project.usage > project.usageLimit) {+ if (workspace && workspace.usage > workspace.usageLimit) {throw new DubApiError({code: "forbidden",message: exceededLimitError({- plan: project.plan,- limit: project.usageLimit,+ plan: workspace.plan,+ limit: workspace.usageLimit,type: "clicks",}),});@@ -86,7 +86,7 @@ export const GET = async (}const response = await getAnalytics({- // projectId can be undefined (for public links that haven't been claimed/synced to a project)+ // projectId can be undefined (for public links that haven't been claimed/synced to a workspace)...(link.projectId && { projectId: link.projectId }),linkId: link.id,endpoint,diff --git a/apps/web/app/api/cron/domains/route.ts b/apps/web/app/api/cron/domains/route.tsindex bf955ef6a5..56cde228cf 100644--- a/apps/web/app/api/cron/domains/route.ts+++ b/apps/web/app/api/cron/domains/route.ts@@ -11,8 +11,8 @@ import { handleDomainUpdates } from "./utils";/*** Cron to check if domains are verified.- * If a domain is invalid for more than 14 days, we send a reminder email to the project owner.- * If a domain is invalid for more than 28 days, we send a second and final reminder email to the project owner.+ * If a domain is invalid for more than 14 days, we send a reminder email to the workspace owner.+ * If a domain is invalid for more than 28 days, we send a second and final reminder email to the workspace owner.* If a domain is invalid for more than 30 days, we delete it from the database.**/// Runs every 3 hours (0 */3 * * *)diff --git a/apps/web/app/api/cron/domains/utils.ts b/apps/web/app/api/cron/domains/utils.tsindex 1046ee203f..abcea0b5e8 100644--- a/apps/web/app/api/cron/domains/utils.ts+++ b/apps/web/app/api/cron/domains/utils.ts@@ -40,7 +40,7 @@ export const handleDomainUpdates = async ({// do nothing if domain is invalid for less than 14 daysif (invalidDays < 14) return;- const project = await prisma.project.findFirst({+ const workspace = await prisma.project.findFirst({where: {domains: {some: {@@ -65,17 +65,17 @@ export const handleDomainUpdates = async ({},},});- if (!project) {+ if (!workspace) {await log({- message: `Domain *${domain}* is invalid but not associated with any project, skipping.`,+ message: `Domain *${domain}* is invalid but not associated with any workspace, skipping.`,type: "cron",mention: true,});return;}- const workspaceSlug = project.slug;- const sentEmails = project.sentEmails.map((email) => email.type);- const emails = project.users.map((user) => user.user.email) as string[];+ const workspaceSlug = workspace.slug;+ const sentEmails = workspace.sentEmails.map((email) => email.type);+ const emails = workspace.users.map((user) => user.user.email) as string[];// if domain is invalid for more than 30 days, check if we can delete itif (invalidDays >= 30) {@@ -106,13 +106,13 @@ export const handleDomainUpdates = async ({// else, delete the domainreturn await Promise.allSettled([deleteDomainAndLinks(domain).then(async () => {- // check if there are any domains left for the project+ // check if there are any domains left for the workspaceconst remainingDomains = await prisma.domain.count({where: {- projectId: project.id,+ projectId: workspace.id,},});- // if the deleted domain was the only domain, delete the project as well+ // if the deleted domain was the only domain, delete the workspace as wellif (remainingDomains === 0) {return prisma.project.delete({where: {@@ -123,7 +123,7 @@ export const handleDomainUpdates = async ({} else if (primary) {const anotherDomain = await prisma.domain.findFirst({where: {- projectId: project.id,+ projectId: workspace.id,},});if (!anotherDomain) return;diff --git a/apps/web/app/api/cron/links/event/route.ts b/apps/web/app/api/cron/links/event/route.tsindex 7dfbb1f33c..5b32667445 100644--- a/apps/web/app/api/cron/links/event/route.ts+++ b/apps/web/app/api/cron/links/event/route.ts@@ -80,7 +80,7 @@ export async function POST(req: Request) {// increment links usage and send alert if neededif (type === "create" && link.projectId) {- const project = await prisma.project.update({+ const workspace = await prisma.project.update({where: {id: link.projectId,},@@ -92,7 +92,7 @@ export async function POST(req: Request) {});const percentage = Math.round(- (project.linksUsage / project.linksLimit) * 100,+ (workspace.linksUsage / workspace.linksLimit) * 100,);if (percentage === 80 || percentage === 100) {@@ -100,7 +100,7 @@ export async function POST(req: Request) {where: {projects: {some: {- projectId: project.id,+ projectId: workspace.id,},},},@@ -116,30 +116,30 @@ export async function POST(req: Request) {limiter.schedule(() =>sendEmail({subject: `${process.env.NEXT_PUBLIC_APP_NAME} Alert: ${- project.name+ workspace.name} has used ${percentage.toString()}% of its links limit for the month.`,email,react: LinksLimitAlert({email,- project: project as Partial<WorkspaceProps>,+ workspace: workspace as Partial<WorkspaceProps>,}),}),);}),log({message: `*${- project.slug+ workspace.slug}* has used ${percentage.toString()}% of its links limit for the month.`,- type: project.plan === "free" ? "cron" : "alerts",- mention: project.plan !== "free",+ type: workspace.plan === "free" ? "cron" : "alerts",+ mention: workspace.plan !== "free",}),]);}}if (type === "transfer") {- const oldProjectId = await redis.get<string>(- `transfer:${linkId}:oldProjectId`,+ const oldWorkspaceId = await redis.get<string>(+ `transfer:${linkId}:oldWorkspaceId`,);const linkClicks = await getAnalytics({@@ -150,10 +150,10 @@ export async function POST(req: Request) {// update old and new project usageawait Promise.all([- oldProjectId &&+ oldWorkspaceId &&prisma.project.update({where: {- id: oldProjectId,+ id: oldWorkspaceId,},data: {usage: {diff --git a/apps/web/app/api/cron/usage/route.ts b/apps/web/app/api/cron/usage/route.tsindex 61b0fa9d37..db588295ee 100644--- a/apps/web/app/api/cron/usage/route.ts+++ b/apps/web/app/api/cron/usage/route.ts@@ -3,7 +3,7 @@ import { getSearchParams, log } from "@dub/utils";import { NextResponse } from "next/server";import { updateUsage } from "./utils";-// Cron to update the usage stats of each project.+// Cron to update the usage stats of each workspace.// Runs once every day at 7AM PST (0 14 * * *)export async function GET(req: Request) {diff --git a/apps/web/app/api/cron/usage/utils.ts b/apps/web/app/api/cron/usage/utils.tsindex ef6f9edd27..edb84baba0 100644--- a/apps/web/app/api/cron/usage/utils.ts+++ b/apps/web/app/api/cron/usage/utils.ts@@ -16,7 +16,7 @@ import ClicksSummary from "emails/clicks-summary";const limit = 250;export const updateUsage = async (skip?: number) => {- const projects = await prisma.project.findMany({+ const workspaces = await prisma.project.findMany({where: {domains: {some: {@@ -51,28 +51,28 @@ export const updateUsage = async (skip?: number) => {take: limit,});- // if no projects left, meaning cron is complete- if (projects.length === 0) {+ // if no workspaces left, meaning cron is complete+ if (workspaces.length === 0) {return;}- // Reset billing cycles for projects that have+ // Reset billing cycles for workspaces that have// adjustedBillingCycleStart that matches today's date- const billingReset = projects.filter(+ const billingReset = workspaces.filter(({ billingCycleStart }) =>getAdjustedBillingCycleStart(billingCycleStart as number) ===new Date().getDate(),);- // Get all projects that have exceeded usage- const exceedingUsage = projects.filter(+ // Get all workspaces that have exceeded usage+ const exceedingUsage = workspaces.filter(({ usage, usageLimit }) => usage > usageLimit,);// Send email to notify overagesawait Promise.allSettled(- exceedingUsage.map(async (project) => {- const { slug, plan, usage, usageLimit, users, sentEmails } = project;+ exceedingUsage.map(async (workspace) => {+ const { slug, plan, usage, usageLimit, users, sentEmails } = workspace;const emails = users.map((user) => user.user.email) as string[];await log({@@ -89,7 +89,7 @@ export const updateUsage = async (skip?: number) => {);if (!sentFirstUsageLimitEmail) {// @ts-ignore- sendUsageLimitEmail(emails, project, "first");+ sendUsageLimitEmail(emails, workspace, "first");} else {const sentSecondUsageLimitEmail = sentEmails.some((email) => email.type === "secondUsageLimitEmail",@@ -102,26 +102,26 @@ export const updateUsage = async (skip?: number) => {);if (daysSinceFirstEmail >= 3) {// @ts-ignore- sendUsageLimitEmail(emails, project, "second");+ sendUsageLimitEmail(emails, workspace, "second");}}}}),);- // Reset usage for projects that have billingCycleStart today- // also delete sentEmails for those projects+ // Reset usage for workspaces that have billingCycleStart today+ // also delete sentEmails for those workspacesawait Promise.allSettled(- billingReset.map(async (project) => {- // Only send the 30-day summary email if the project was created more than 30 days ago+ billingReset.map(async (workspace) => {+ // Only send the 30-day summary email if the workspace was created more than 30 days agoif (- project.createdAt.getTime() <+ workspace.createdAt.getTime() <new Date().getTime() - 30 * 24 * 60 * 60 * 1000) {const topLinks =- project.usage > 0+ workspace.usage > 0? await getAnalytics({- projectId: project.id,+ projectId: workspace.id,endpoint: "top_links",interval: "30d",excludeRoot: true,@@ -160,22 +160,24 @@ export const updateUsage = async (skip?: number) => {}): [];- const emails = project.users.map((user) => user.user.email) as string[];+ const emails = workspace.users.map(+ (user) => user.user.email,+ ) as string[];await Promise.allSettled(emails.map((email) => {limiter.schedule(() =>sendEmail({- subject: `Your 30-day ${process.env.NEXT_PUBLIC_APP_NAME} summary for ${project.name}`,+ subject: `Your 30-day ${process.env.NEXT_PUBLIC_APP_NAME} summary for ${workspace.name}`,email,react: ClicksSummary({email,appName: process.env.NEXT_PUBLIC_APP_NAME as string,appDomain: process.env.NEXT_PUBLIC_APP_DOMAIN as string,- workspaceName: project.name,- workspaceSlug: project.slug,- totalClicks: project.usage,- createdLinks: project.linksUsage,+ workspaceName: workspace.name,+ workspaceSlug: workspace.slug,+ totalClicks: workspace.usage,+ createdLinks: workspace.linksUsage,topLinks,}),}),@@ -184,7 +186,7 @@ export const updateUsage = async (skip?: number) => {);}- const { plan, usage, usageLimit } = project;+ const { plan, usage, usageLimit } = workspace;// only reset clicks usage if it's not over usageLimit by:// 2x for free plan (2K clicks)@@ -202,7 +204,7 @@ export const updateUsage = async (skip?: number) => {return await prisma.project.update({where: {- id: project.id,+ id: workspace.id,},data: {...(resetUsage && {@@ -232,7 +234,7 @@ export const updateUsage = async (skip?: number) => {const sendUsageLimitEmail = async (emails: string[],- project: WorkspaceProps,+ workspace: WorkspaceProps,type: "first" | "second",) => {return await Promise.allSettled([@@ -243,7 +245,7 @@ const sendUsageLimitEmail = async (email,react: ClicksExceeded({email,- project,+ workspace,type,}),}),@@ -253,7 +255,7 @@ const sendUsageLimitEmail = async (data: {project: {connect: {- slug: project.slug,+ slug: workspace.slug,},},type: `${type}UsageLimitEmail`,diff --git a/apps/web/app/api/links/[linkId]/route.ts b/apps/web/app/api/links/[linkId]/route.tsindex 4d5d0fb1a1..bf0fa43542 100644--- a/apps/web/app/api/links/[linkId]/route.ts+++ b/apps/web/app/api/links/[linkId]/route.ts@@ -62,7 +62,8 @@ export const PUT = withAuth(async ({ req, headers, workspace, link }) => {if (updatedLink.projectId !== link?.projectId) {throw new DubApiError({code: "forbidden",- message: "Transferring links to another workspace is not yet supported.",+ message:+ "Transferring links to another workspace is only allowed via the /links/[linkId]transfer endpoint.",});}diff --git a/apps/web/app/api/links/[linkId]/transfer/route.ts b/apps/web/app/api/links/[linkId]/transfer/route.tsindex 8acd6c782c..2b954bb3ff 100644--- a/apps/web/app/api/links/[linkId]/transfer/route.ts+++ b/apps/web/app/api/links/[linkId]/transfer/route.ts@@ -20,7 +20,7 @@ const transferLinkBodySchema = z.object({export const POST = withAuth(async ({ req, headers, session, link }) => {const { newWorkspaceId } = transferLinkBodySchema.parse(await req.json());- const newProject = await prisma.project.findUnique({+ const newWorkspace = await prisma.project.findUnique({where: { id: newWorkspaceId },select: {linksUsage: true,@@ -36,14 +36,14 @@ export const POST = withAuth(async ({ req, headers, session, link }) => {},});- if (!newProject || newProject.users.length === 0) {+ if (!newWorkspace || newWorkspace.users.length === 0) {throw new DubApiError({code: "not_found",message: "New workspace not found.",});}- if (newProject.linksUsage >= newProject.linksLimit) {+ if (newWorkspace.linksUsage >= newWorkspace.linksLimit) {throw new DubApiError({code: "forbidden",message: "New workspace has reached its link limit.",@@ -56,7 +56,7 @@ export const POST = withAuth(async ({ req, headers, session, link }) => {newWorkspaceId,}),// set this in redis so we can use it in the event cron job- redis.set(`transfer:${link!.id}:oldProjectId`, link!.projectId),+ redis.set(`transfer:${link!.id}:oldWorkspaceId`, link!.projectId),]);await qstash.publishJSON({diff --git a/apps/web/app/api/links/bulk/route.ts b/apps/web/app/api/links/bulk/route.tsindex dc77529750..d5b5621c13 100644--- a/apps/web/app/api/links/bulk/route.ts+++ b/apps/web/app/api/links/bulk/route.ts@@ -72,7 +72,7 @@ export const POST = withAuth(}));// filter out tags that don't belong to the workspace- const projectTags = await prisma.tag.findMany({+ const workspaceTags = await prisma.tag.findMany({where: {projectId: workspace.id,},@@ -80,14 +80,14 @@ export const POST = withAuth(id: true,},});- const projectTagIds = projectTags.map(({ id }) => id);+ const workspaceTagIds = workspaceTags.map(({ id }) => id);validLinks.forEach((link, index) => {const combinedTagIds = combineTagIds({tagId: link.tagId,tagIds: link.tagIds,});const invalidTagIds = combinedTagIds.filter(- (id) => !projectTagIds.includes(id),+ (id) => !workspaceTagIds.includes(id),);if (invalidTagIds.length > 0) {// remove link from validLinks and add error to errorLinksdiff --git a/apps/web/app/api/scim/v2.0/[...directory]/route.ts b/apps/web/app/api/scim/v2.0/[...directory]/route.tsindex f4a216b6ad..6e87fe7b50 100644--- a/apps/web/app/api/scim/v2.0/[...directory]/route.ts+++ b/apps/web/app/api/scim/v2.0/[...directory]/route.ts@@ -56,11 +56,11 @@ export { handler as DELETE, handler as GET, handler as POST, handler as PUT };// Handle the SCIM eventsconst handleEvents = async (event: DirectorySyncEvent) => {- const { event: action, tenant: projectId, data } = event;+ const { event: action, tenant: workspaceId, data } = event;const workspace = (await prisma.project.findUnique({where: {- id: projectId,+ id: workspaceId,},})) as unknown as WorkspaceProps;@@ -68,13 +68,13 @@ const handleEvents = async (event: DirectorySyncEvent) => {return;}- const [userInProject, userInvited] = await Promise.all([+ const [userInWorkspace, userInvited] = await Promise.all([prisma.user.findFirst({where: {email: data.email,projects: {some: {- projectId,+ projectId: workspaceId,},},},@@ -83,14 +83,14 @@ const handleEvents = async (event: DirectorySyncEvent) => {where: {email_projectId: {email: data.email,- projectId,+ projectId: workspaceId,},},}),]);// User has been activated for the first time- if (action === "user.created" && !userInProject && !userInvited) {+ if (action === "user.created" && !userInWorkspace && !userInvited) {await inviteUser({email: data.email,workspace,@@ -103,7 +103,7 @@ const handleEvents = async (event: DirectorySyncEvent) => {// @ts-ignore – data.active can be a string (from Azure AD)(data.active === true || data.active === "True")) {- if (!userInProject && !userInvited) {+ if (!userInWorkspace && !userInvited) {await inviteUser({email: data.email,workspace,@@ -118,12 +118,12 @@ const handleEvents = async (event: DirectorySyncEvent) => {(data.active === false || data.active === "False")) ||action === "user.deleted") {- if (userInProject) {+ if (userInWorkspace) {await prisma.projectUsers.delete({where: {userId_projectId: {- userId: userInProject.id,- projectId,+ userId: userInWorkspace.id,+ projectId: workspaceId,},},});@@ -133,7 +133,7 @@ const handleEvents = async (event: DirectorySyncEvent) => {where: {email_projectId: {email: data.email,- projectId,+ projectId: workspaceId,},},});diff --git a/apps/web/app/api/tags/[id]/route.ts b/apps/web/app/api/tags/[id]/route.tsindex c045109989..640e29a077 100644--- a/apps/web/app/api/tags/[id]/route.ts+++ b/apps/web/app/api/tags/[id]/route.ts@@ -5,7 +5,7 @@ import { recordLink } from "@/lib/tinybird";import { updateTagBodySchema } from "@/lib/zod/schemas/tags";import { NextResponse } from "next/server";-// PUT /api/workspaces/[idOrSlug]/tags/[id] – update a tag for a project+// PUT /api/workspaces/[idOrSlug]/tags/[id] – update a tag for a workspaceexport const PUT = withAuth(async ({ req, params }) => {const { id } = params;const { name, color } = updateTagBodySchema.parse(await req.json());@@ -46,7 +46,7 @@ export const PUT = withAuth(async ({ req, params }) => {}});-// DELETE /api/workspaces/[idOrSlug]/tags/[id] – delete a tag for a project+// DELETE /api/workspaces/[idOrSlug]/tags/[id] – delete a tag for a workspaceexport const DELETE = withAuth(async ({ params }) => {const { id } = params;try {diff --git a/apps/web/app/api/user/route.ts b/apps/web/app/api/user/route.tsindex 6de68eef6e..0508850826 100644--- a/apps/web/app/api/user/route.ts+++ b/apps/web/app/api/user/route.ts@@ -9,18 +9,18 @@ import { z } from "zod";// GET /api/user – get a specific userexport const GET = withSession(async ({ session }) => {- const migratedProject = await redis.hget(+ const migratedWorkspace = await redis.hget("migrated_links_users",session.user.id,);- if (migratedProject) {+ if (migratedWorkspace) {await redis.hdel("migrated_links_users", session.user.id);}return NextResponse.json({...session.user,- migratedProject,+ migratedWorkspace,});});@@ -62,13 +62,13 @@ export const PUT = withSession(async ({ req, session }) => {// DELETE /api/user – delete a specific userexport const DELETE = withSession(async ({ session }) => {- const userIsOwnerOfProjects = await prisma.projectUsers.findMany({+ const userIsOwnerOfWorkspaces = await prisma.projectUsers.findMany({where: {userId: session.user.id,role: "owner",},});- if (userIsOwnerOfProjects.length > 0) {+ if (userIsOwnerOfWorkspaces.length > 0) {return new Response("You must transfer ownership of your workspaces or delete them before you can delete your account.",{ status: 422 },diff --git a/apps/web/app/api/workspaces/[idOrSlug]/invites/accept/route.ts b/apps/web/app/api/workspaces/[idOrSlug]/invites/accept/route.tsindex a6a3bcb0ff..f4df6cfb9c 100644--- a/apps/web/app/api/workspaces/[idOrSlug]/invites/accept/route.ts+++ b/apps/web/app/api/workspaces/[idOrSlug]/invites/accept/route.ts@@ -4,7 +4,7 @@ import prisma from "@/lib/prisma";import { PlanProps } from "@/lib/types";import { NextResponse } from "next/server";-// POST /api/workspaces/[idOrSlug]/invites/accept – accept a project invite+// POST /api/workspaces/[idOrSlug]/invites/accept – accept a workspace inviteexport const POST = withSession(async ({ session, params }) => {const invite = await prisma.projectInvite.findFirst({where: {@@ -37,13 +37,13 @@ export const POST = withSession(async ({ session, params }) => {return new Response("Invite expired", { status: 410 });}- const project = invite.project;+ const workspace = invite.project;- if (project._count.users >= project.usersLimit) {+ if (workspace._count.users >= workspace.usersLimit) {return new Response(exceededLimitError({- plan: project.plan as PlanProps,- limit: project.usersLimit,+ plan: workspace.plan as PlanProps,+ limit: workspace.usersLimit,type: "users",}),{@@ -57,14 +57,14 @@ export const POST = withSession(async ({ session, params }) => {data: {userId: session.user.id,role: "member",- projectId: project.id,+ projectId: workspace.id,},}),prisma.projectInvite.delete({where: {email_projectId: {email: session.user.email,- projectId: project.id,+ projectId: workspace.id,},},}),diff --git a/apps/web/app/api/workspaces/[idOrSlug]/invites/route.tsx b/apps/web/app/api/workspaces/[idOrSlug]/invites/route.tsxindex 5bc146448b..e6b119a636 100644--- a/apps/web/app/api/workspaces/[idOrSlug]/invites/route.tsx+++ b/apps/web/app/api/workspaces/[idOrSlug]/invites/route.tsx@@ -28,7 +28,7 @@ export const POST = withAuth(async ({ req, workspace, session }) => {const { email } = emailInviteSchema.parse(await req.json());- const [alreadyInTeam, projectUserCount, projectInviteCount] =+ const [alreadyInWorkspace, workspaceUserCount, workspaceInviteCount] =await Promise.all([prisma.projectUsers.findFirst({where: {@@ -50,14 +50,14 @@ export const POST = withAuth(}),]);- if (alreadyInTeam) {+ if (alreadyInWorkspace) {throw new DubApiError({code: "bad_request",message: "User already exists in this workspace.",});}- if (projectUserCount + projectInviteCount >= workspace.usersLimit) {+ if (workspaceUserCount + workspaceInviteCount >= workspace.usersLimit) {throw new DubApiError({code: "exceeded_limit",message: exceededLimitError({diff --git a/apps/web/app/api/workspaces/route.ts b/apps/web/app/api/workspaces/route.tsindex db6fa183fa..d20cf1ccf2 100644--- a/apps/web/app/api/workspaces/route.ts+++ b/apps/web/app/api/workspaces/route.ts@@ -10,7 +10,7 @@ import prisma from "@/lib/prisma";import z from "@/lib/zod";import {DEFAULT_REDIRECTS,- FREE_PROJECTS_LIMIT,+ FREE_WORKSPACES_LIMIT,nanoid,validDomainRegex,validSlugRegex,@@ -80,10 +80,10 @@ export const POST = withSession(async ({ req, session }) => {},});- if (freeProjects >= FREE_PROJECTS_LIMIT) {+ if (freeProjects >= FREE_WORKSPACES_LIMIT) {throw new DubApiError({code: "exceeded_limit",- message: `You can only create up to ${FREE_PROJECTS_LIMIT} free workspaces. Additional workspaces require a paid plan.`,+ message: `You can only create up to ${FREE_WORKSPACES_LIMIT} free workspaces. Additional workspaces require a paid plan.`,});}diff --git a/apps/web/app/app.dub.co/(auth)/invites/[code]/page.tsx b/apps/web/app/app.dub.co/(auth)/invites/[code]/page.tsxindex 2444c92294..9909deaf05 100644--- a/apps/web/app/app.dub.co/(auth)/invites/[code]/page.tsx+++ b/apps/web/app/app.dub.co/(auth)/invites/[code]/page.tsx@@ -52,7 +52,7 @@ async function VerifyInvite({ code }: { code: string }) {redirect("/login");}- const project = await prisma.project.findUnique({+ const workspace = await prisma.project.findUnique({where: {inviteCode: code,},@@ -76,7 +76,7 @@ async function VerifyInvite({ code }: { code: string }) {},});- if (!project) {+ if (!workspace) {return (<><PageCopy@@ -87,12 +87,12 @@ async function VerifyInvite({ code }: { code: string }) {);}- // check if user is already in the project- if (project.users.length > 0) {- redirect(`/${project.slug}`);+ // check if user is already in the workspace+ if (workspace.users.length > 0) {+ redirect(`/${workspace.slug}`);}- if (project._count.users >= project.usersLimit) {+ if (workspace._count.users >= workspace.usersLimit) {return (<PageCopytitle="User Limit Reached"@@ -104,9 +104,9 @@ async function VerifyInvite({ code }: { code: string }) {await prisma.projectUsers.create({data: {userId: session.user.id,- projectId: project.id,+ projectId: workspace.id,},});- redirect(`/${project.slug}`);+ redirect(`/${workspace.slug}`);}diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/domains/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/domains/page-client.tsxindex 2805acfff6..19783bf517 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/domains/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/domains/page-client.tsx@@ -21,16 +21,16 @@ import { ChevronDown } from "lucide-react";import { useEffect, useState } from "react";import { toast } from "sonner";-export default function ProjectDomainsClient() {- const { id: projectId } = useWorkspace();+export default function WorkspaceDomainsClient() {+ const { id: workspaceId } = useWorkspace();const { AddEditDomainModal, AddDomainButton } = useAddEditDomainModal();- const { activeProjectDomains, archivedProjectDomains } = useDomains();+ const { activeWorkspaceDomains, archivedWorkspaceDomains } = useDomains();const [showArchivedDomains, setShowArchivedDomains] = useState(false);return (<>- {projectId && <AddEditDomainModal />}+ {workspaceId && <AddEditDomainModal />}<div className="flex h-36 items-center border-b border-gray-200 bg-white"><MaxWidthWrapper><div className="flex items-center justify-between">@@ -55,10 +55,10 @@ export default function ProjectDomainsClient() {</MaxWidthWrapper></div><MaxWidthWrapper className="py-10">- {activeProjectDomains ? (- activeProjectDomains.length > 0 ? (+ {activeWorkspaceDomains ? (+ activeWorkspaceDomains.length > 0 ? (<ul className="grid grid-cols-1 gap-3">- {activeProjectDomains.map((domain) => (+ {activeWorkspaceDomains.map((domain) => (<li key={domain.slug}><DomainCard props={domain} /></li>@@ -70,17 +70,17 @@ export default function ProjectDomainsClient() {) : (<DomainCardPlaceholder />)}- {archivedProjectDomains && archivedProjectDomains.length > 0 && (+ {archivedWorkspaceDomains && archivedWorkspaceDomains.length > 0 && (<ul className="mt-3 grid grid-cols-1 gap-3">{showArchivedDomains &&- archivedProjectDomains?.map((domain) => (+ archivedWorkspaceDomains?.map((domain) => (<li key={domain.slug}><DomainCard props={domain} /></li>))}<Buttontext={`${showArchivedDomains ? "Hide" : "Show"} ${- archivedProjectDomains.length+ archivedWorkspaceDomains.length} archived domains`}variant="secondary"onClick={() => setShowArchivedDomains(!showArchivedDomains)}diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/domains/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/domains/page.tsxindex 213525b730..34d57e17bc 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/domains/page.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/domains/page.tsx@@ -1,5 +1,5 @@-import ProjectDomainsClient from "./page-client";+import WorkspaceDomainsClient from "./page-client";-export default function ProjectDomains() {- return <ProjectDomainsClient />;+export default function WorkspaceDomains() {+ return <WorkspaceDomainsClient />;}diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/layout.tsxindex 2aa1329429..4ca82bd06a 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/layout.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/layout.tsx@@ -1,6 +1,6 @@import { ReactNode } from "react";import WorkspaceAuth from "./auth";-export default function ProjectLayout({ children }: { children: ReactNode }) {+export default function WorkspaceLayout({ children }: { children: ReactNode }) {return <WorkspaceAuth>{children}</WorkspaceAuth>;}diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/page-client.tsxindex a9063c3645..191d0db99c 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/page-client.tsx@@ -15,7 +15,7 @@ import { ChevronDown, FilePlus2, Sheet } from "lucide-react";import { useRouter } from "next/navigation";import { useState } from "react";-export default function ProjectLinksClient() {+export default function WorkspaceLinksClient() {const { AddEditLinkModal, AddEditLinkButton } = useAddEditLinkModal();return (diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/page.tsxindex 91243daa9f..266c676560 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/page.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/page.tsx@@ -1,5 +1,5 @@-import ProjectLinksClient from "./page-client";+import WorkspaceLinksClient from "./page-client";-export default function ProjectLinks() {- return <ProjectLinksClient />;+export default function WorkspaceLinks() {+ return <WorkspaceLinksClient />;}diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/layout.tsxindex 5347df3215..29cf308545 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/layout.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/layout.tsx@@ -1,7 +1,7 @@import SettingsLayout from "@/ui/layout/settings-layout";import { ReactNode } from "react";-export default function ProjectSettingsLayout({+export default function WorkspaceSettingsLayout({children,}: {children: ReactNode;diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/page-client.tsxindex 19f5f39f11..16cf5b1620 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/page-client.tsx@@ -9,7 +9,7 @@ import { useRouter } from "next/navigation";import { toast } from "sonner";import { mutate } from "swr";-export default function ProjectSettingsClient() {+export default function WorkspaceSettingsClient() {const router = useRouter();const { id, name, slug, isOwner } = useWorkspace();diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/page.tsxindex 1e6a553e2b..290e38c0dd 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/page.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/page.tsx@@ -1,5 +1,5 @@-import ProjectSettingsClient from "./page-client";+import WorkspaceSettingsClient from "./page-client";-export default function ProjectSettings() {- return <ProjectSettingsClient />;+export default function WorkspaceSettings() {+ return <WorkspaceSettingsClient />;}diff --git a/apps/web/emails/clicks-exceeded.tsx b/apps/web/emails/clicks-exceeded.tsxindex 1f0c48482e..a29f0830d7 100644--- a/apps/web/emails/clicks-exceeded.tsx+++ b/apps/web/emails/clicks-exceeded.tsx@@ -17,7 +17,7 @@ import Footer from "./components/footer";export default function ClicksExceeded({email = "[email protected]",- project = {+ workspace = {id: "ckqf1q3xw0000gk5u2q1q2q1q",name: "Acme",slug: "acme",@@ -28,10 +28,10 @@ export default function ClicksExceeded({type = "first",}: {email: string;- project: Partial<WorkspaceProps>;+ workspace: Partial<WorkspaceProps>;type: "first" | "second";}) {- const { slug, name, usage, usageLimit, plan } = project;+ const { slug, name, usage, usageLimit, plan } = workspace;const nextPlan = getNextPlan(plan as string);return (diff --git a/apps/web/emails/links-limit.tsx b/apps/web/emails/links-limit.tsxindex 88ef58d755..1690655003 100644--- a/apps/web/emails/links-limit.tsx+++ b/apps/web/emails/links-limit.tsx@@ -17,7 +17,7 @@ import Footer from "./components/footer";export default function LinksLimitAlert({email = "[email protected]",- project = {+ workspace = {id: "ckqf1q3xw0000gk5u2q1q2q1q",name: "Acme",slug: "acme",@@ -27,9 +27,9 @@ export default function LinksLimitAlert({},}: {email: string;- project: Partial<WorkspaceProps>;+ workspace: Partial<WorkspaceProps>;}) {- const { slug, name, linksUsage, linksLimit, plan } = project as {+ const { slug, name, linksUsage, linksLimit, plan } = workspace as {slug: string;name: string;linksUsage: number;@@ -43,8 +43,8 @@ export default function LinksLimitAlert({<Html><Head /><Preview>- Your Dub project, {name} has used {percentage.toString()}% of its links- limit for the month.+ Your Dub workspace, {name} has used {percentage.toString()}% of its+ links limit for the month.</Preview><Tailwind><Body className="mx-auto my-auto bg-white font-sans">diff --git a/apps/web/lib/planetscale.ts b/apps/web/lib/planetscale.tsindex de6ae1bce9..e100958a8e 100644--- a/apps/web/lib/planetscale.ts+++ b/apps/web/lib/planetscale.ts@@ -11,11 +11,11 @@ export const pscale_config = {export const conn = connect(pscale_config);-export const getProjectViaEdge = async (projectId: string) => {+export const getWorkspaceViaEdge = async (workspaceId: string) => {if (!DATABASE_URL) return null;const { rows } =- (await conn.execute("SELECT * FROM Project WHERE id = ?", [projectId])) ||+ (await conn.execute("SELECT * FROM Project WHERE id = ?", [workspaceId])) ||{};return rows && Array.isArray(rows) && rows.length > 0diff --git a/apps/web/lib/swr/use-domains.ts b/apps/web/lib/swr/use-domains.tsindex 9870f63c29..73bc841d5b 100644--- a/apps/web/lib/swr/use-domains.ts+++ b/apps/web/lib/swr/use-domains.ts@@ -28,44 +28,44 @@ export default function useDomains({dedupingInterval: 60000,},);- const { defaultDomains: projectDefaultDomains } = useDefaultDomains();+ const { defaultDomains: workspaceDefaultDomains } = useDefaultDomains();- const allProjectDomains = data || [];- const activeProjectDomains = data?.filter((domain) => !domain.archived);- const archivedProjectDomains = data?.filter((domain) => domain.archived);+ const allWorkspaceDomains = data || [];+ const activeWorkspaceDomains = data?.filter((domain) => !domain.archived);+ const archivedWorkspaceDomains = data?.filter((domain) => domain.archived);const activeDefaultDomains =- (projectDefaultDomains &&- DUB_DOMAINS.filter((d) => projectDefaultDomains?.includes(d.slug))) ||+ (workspaceDefaultDomains &&+ DUB_DOMAINS.filter((d) => workspaceDefaultDomains?.includes(d.slug))) ||DUB_DOMAINS;const allDomains = [- ...allProjectDomains,+ ...allWorkspaceDomains,...(id === `ws_${DUB_WORKSPACE_ID}` ? [] : DUB_DOMAINS),];const allActiveDomains = [- ...(activeProjectDomains || []),+ ...(activeWorkspaceDomains || []),...(id === `ws_${DUB_WORKSPACE_ID}` ? [] : activeDefaultDomains),];const primaryDomain =- activeProjectDomains?.find((domain) => domain.primary)?.slug ||+ activeWorkspaceDomains?.find((domain) => domain.primary)?.slug ||activeDefaultDomains.find((domain) => domain.primary)?.slug ||SHORT_DOMAIN;const verified = domain? // If a domain is passed, check if it's verifiedallDomains.find((d) => d.slug === domain)?.verified- : // If no domain is passed, check if any of the project domains are verified- activeProjectDomains?.some((d) => d.verified);+ : // If no domain is passed, check if any of the workspace domains are verified+ activeWorkspaceDomains?.some((d) => d.verified);return {- activeProjectDomains, // active project domains- archivedProjectDomains, // archived project domains+ activeWorkspaceDomains, // active workspace domains+ archivedWorkspaceDomains, // archived workspace domainsactiveDefaultDomains, // active default Dub domains- allProjectDomains, // all project domains (active + archived)- allActiveDomains, // all active domains (active project domains + active default Dub domains)- allDomains, // all domains (all project domains + all default Dub domains)+ allWorkspaceDomains, // all workspace domains (active + archived)+ allActiveDomains, // all active domains (active workspace domains + active default Dub domains)+ allDomains, // all domains (all workspace domains + all default Dub domains)primaryDomain,verified,loading: !data && !error,diff --git a/apps/web/ui/workspaces/create-workspace-button.tsx b/apps/web/ui/workspaces/create-workspace-button.tsxindex 33cf39617d..dd48234201 100644--- a/apps/web/ui/workspaces/create-workspace-button.tsx+++ b/apps/web/ui/workspaces/create-workspace-button.tsx@@ -4,7 +4,7 @@ import useWorkspaces from "@/lib/swr/use-workspaces";import { ModalContext } from "@/ui/modals/provider";import { Button } from "@dub/ui";import { TooltipContent } from "@dub/ui/src/tooltip";-import { FREE_PROJECTS_LIMIT, HOME_DOMAIN } from "@dub/utils";+import { FREE_WORKSPACES_LIMIT, HOME_DOMAIN } from "@dub/utils";import { useContext } from "react";export default function CreateWorkspaceButton() {@@ -18,7 +18,7 @@ export default function CreateWorkspaceButton() {disabledTooltip={exceedingFreeWorkspaces ? (<TooltipContent- title={`You can only create up to ${FREE_PROJECTS_LIMIT} free workspaces. Additional workspaces require a paid plan.`}+ title={`You can only create up to ${FREE_WORKSPACES_LIMIT} free workspaces. Additional workspaces require a paid plan.`}cta="Upgrade to Pro"href={freeWorkspacesdiff --git a/apps/web/ui/workspaces/workspace-card.tsx b/apps/web/ui/workspaces/workspace-card.tsxindex 97e7451e94..e0c38ef07e 100644--- a/apps/web/ui/workspaces/workspace-card.tsx+++ b/apps/web/ui/workspaces/workspace-card.tsx@@ -41,7 +41,7 @@ export default function WorkspaceCard({plan,}: WorkspaceProps) {const {- allProjectDomains: domains,+ allWorkspaceDomains: domains,primaryDomain,verified,loading,diff --git a/packages/utils/src/constants/pricing.tsx b/packages/utils/src/constants/pricing.tsxindex 194148f13a..b032d2d66f 100644--- a/packages/utils/src/constants/pricing.tsx+++ b/packages/utils/src/constants/pricing.tsx@@ -303,7 +303,7 @@ export const SELF_SERVE_PAID_PLANS = PLANS.filter((p) => p.name !== "Free" && p.name !== "Enterprise",);-export const FREE_PROJECTS_LIMIT = 2;+export const FREE_WORKSPACES_LIMIT = 2;export const getPlanFromPriceId = (priceId: string) => {return PLANS.find((plan) => plan.price.ids?.includes(priceId)) || null;