The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add support for tenantId
Steven Teyedce145a7fc2
diff --git a/apps/web/lib/zod/schemas/links.ts b/apps/web/lib/zod/schemas/links.tsindex ce8b0ac23c..6c971da502 100644--- a/apps/web/lib/zod/schemas/links.ts+++ b/apps/web/lib/zod/schemas/links.ts@@ -57,6 +57,12 @@ const LinksQuerySchema = z.object({"The search term to filter the links by. The search term will be matched against the short link slug and the destination url.",),userId: z.string().optional().describe("The user ID to filter the links by."),+ tenantId: z+ .string()+ .optional()+ .describe(+ "The ID of the tenant that created the link inside your system. If set, will only return links for the specified tenant.",+ ),showArchived: booleanQuerySchema.optional().default("false")@@ -160,9 +166,15 @@ export const createLinkBodySchema = z.object({.transform((v) => (v?.startsWith("ext_") ? v.slice(4) : v)).nullish().describe(- "This is the ID of the link in your database. If set, it can be used to identify the link in the future. Must be prefixed with `ext_` when passed as a query parameter.",+ "The ID of the link in your database. If set, it can be used to identify the link in future API requests (must be prefixed with 'ext_' when passed as a query parameter). This key is unique across your workspace.",).openapi({ example: "123456" }),+ tenantId: z+ .string()+ .optional()+ .describe(+ "The ID of the tenant that created the link inside your system. If set, it can be used to fetch all links for a tenant.",+ ),prefix: z.string().optional()@@ -392,7 +404,13 @@ export const LinkSchema = z.string().nullable().describe(- "This is the ID of the link in your database that is unique across your workspace. If set, it can be used to identify the link in future API requests. Must be prefixed with 'ext_' when passed as a query parameter.",+ "The ID of the link in your database. If set, it can be used to identify the link in future API requests (must be prefixed with 'ext_' when passed as a query parameter). This key is unique across your workspace.",+ ),+ tenantId: z+ .string()+ .nullable()+ .describe(+ "The ID of the tenant that created the link inside your system. If set, it can be used to fetch all links for a tenant.",),archived: z.boolean()diff --git a/packages/prisma/schema/link.prisma b/packages/prisma/schema/link.prismaindex ec27e44e2a..547d7a2b21 100644--- a/packages/prisma/schema/link.prisma+++ b/packages/prisma/schema/link.prisma@@ -8,7 +8,6 @@ model Link {expiresAt DateTime? // when the link expires – stored on Redis via ttlexpiredUrl String? @db.LongText // URL to redirect the user to when the link is expiredpassword String? // password to access the link- externalId String?trackConversion Boolean @default(false) // whether to track conversions or notproxy Boolean @default(false) // Proxy to use custom OG tags (stored on redis) – if false, will use OG tags from target url@@ -44,6 +43,10 @@ model Link {// Relational reference to the project domainprojectDomain Domain? @relation(fields: [domain], references: [slug], onUpdate: Cascade, onDelete: Cascade)+ // External & tenant IDs (for API usage + multi-tenancy)+ externalId String?+ tenantId String?+publicStats Boolean @default(false) // whether to show public stats or notclicks Int @default(0) // number of clickslastClicked DateTime? // when the link was last clicked@@ -71,7 +74,7 @@ model Link {customers Customer[]@@unique([domain, key])- @@unique([projectId, externalId])+ @@fulltext([key, url])@@index(trackConversion)@@index(proxy)@@index(password)@@ -79,7 +82,8 @@ model Link {@@index(createdAt(sort: Desc))@@index(clicks(sort: Desc))@@index(lastClicked)+ @@index(programId)@@index(userId)- @@index([programId])- @@fulltext([key, url])+ @@unique([projectId, externalId])+ @@index(tenantId)}