The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
add validation to routes and zod description
Kiran K89557488333e
diff --git a/apps/web/app/api/links/[linkId]/route.ts b/apps/web/app/api/links/[linkId]/route.tsindex 6f5fa6cd38..9a67df7c4d 100644--- a/apps/web/app/api/links/[linkId]/route.ts+++ b/apps/web/app/api/links/[linkId]/route.ts@@ -1,7 +1,7 @@import { deleteLink, editLink, processLink } from "@/lib/api/links";import { withAuth } from "@/lib/auth";import { qstash } from "@/lib/cron";-import { DubApiError, handleAndReturnErrorResponse } from "@/lib/errors";+import { DubApiError, ErrorCodes, handleAndReturnErrorResponse } from "@/lib/errors";import { LinkProps } from "@/lib/types";import { createLinkBodySchema } from "@/lib/zod/schemas/links";import { APP_DOMAIN_WITH_NGROK } from "@dub/utils";@@ -35,16 +35,17 @@ export const PUT = withAuth(async ({ req, headers, project, link }) => {const {link: processedLink,error,- status,+ code,} = await processLink({payload: updatedLink as LinkProps,project,});- // TODO: Kiran- // Handle error and statusif (error) {- return new Response(error, { status, headers });+ throw new DubApiError({+ code: code as ErrorCodes,+ message: error,+ });}const [response, _] = await Promise.allSettled([diff --git a/apps/web/app/api/links/route.ts b/apps/web/app/api/links/route.tsindex 5f1d0ca57c..84d40dff50 100644--- a/apps/web/app/api/links/route.ts+++ b/apps/web/app/api/links/route.ts@@ -1,7 +1,11 @@import { addLink, getLinksForProject, processLink } from "@/lib/api/links";import { withAuth } from "@/lib/auth";import { qstash } from "@/lib/cron";-import { DubApiError, handleAndReturnErrorResponse } from "@/lib/errors";+import {+ DubApiError,+ ErrorCodes,+ handleAndReturnErrorResponse,+} from "@/lib/errors";import { LinkProps } from "@/lib/types";import { ratelimit } from "@/lib/upstash";import {@@ -63,14 +67,17 @@ export const POST = withAuth(}}- const { link, error, status } = await processLink({+ const { link, error, code } = await processLink({payload: body as LinkProps,project,session,});if (error) {- return new Response(error, { status, headers });+ throw new DubApiError({+ code: code as ErrorCodes,+ message: error,+ });}const response = await addLink(link);diff --git a/apps/web/lib/api/links.ts b/apps/web/lib/api/links.tsindex 6b8be93ff6..3feba35456 100644--- a/apps/web/lib/api/links.ts+++ b/apps/web/lib/api/links.ts@@ -237,6 +237,7 @@ export async function processLink({link: payload,error: "Missing destination url.",status: 400,+ code: "bad_request",};}const processedUrl = getUrlFromString(url);@@ -245,6 +246,7 @@ export async function processLink({link: payload,error: "Invalid destination url.",status: 422,+ code: "unprocessable_entity",};}@@ -256,6 +258,7 @@ export async function processLink({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.",status: 403,+ code: "forbidden",};}// can't use `/` in key on free plan@@ -265,6 +268,7 @@ export async function processLink({error:"Key cannot contain '/'. You can only use this on a Pro plan and above. Upgrade to Pro to use this feature.",status: 422,+ code: "unprocessable_entity",};}}@@ -282,6 +286,7 @@ export async function processLink({link: payload,error: "Invalid key.",status: 422,+ code: "unprocessable_entity",};}const domainBlacklisted = await isBlacklistedDomain(url);@@ -290,6 +295,7 @@ export async function processLink({link: payload,error: "Invalid url.",status: 422,+ code: "unprocessable_entity",};}@@ -305,6 +311,7 @@ export async function processLink({.map((d) => `\`${d}\``).join(", ")}.`,status: 422,+ code: "unprocessable_entity",};}@@ -314,6 +321,7 @@ export async function processLink({link: payload,error: "Domain does not belong to project.",status: 403,+ code: "forbidden",};}@@ -327,6 +335,7 @@ export async function processLink({link: payload,error: "You cannot set custom social cards with bulk link creation.",status: 422,+ code: "unprocessable_entity",};}if (rewrite) {@@ -334,6 +343,7 @@ export async function processLink({link: payload,error: "You cannot use link cloaking with bulk link creation.",status: 422,+ code: "unprocessable_entity",};}const exists = await checkIfKeyExists(domain, key);@@ -342,6 +352,7 @@ export async function processLink({link: payload,error: `Link already exists.`,status: 409,+ code: "conflict",};}}@@ -353,6 +364,7 @@ export async function processLink({link: payload,error: "Missing Cloudinary environment variable.",status: 400,+ code: "bad_request",};}@@ -364,6 +376,7 @@ export async function processLink({link: payload,error: "Invalid expiry date. Expiry date must be in ISO-8601 format.",status: 422,+ code: "unprocessable_entity",};}// check if expiresAt is in the future@@ -372,6 +385,7 @@ export async function processLink({link: payload,error: "Expiry date must be in the future.",status: 422,+ code: "unprocessable_entity",};}}diff --git a/apps/web/lib/errors.ts b/apps/web/lib/errors.tsindex 36f780a174..2f8019a779 100644--- a/apps/web/lib/errors.ts+++ b/apps/web/lib/errors.ts@@ -5,7 +5,7 @@ import { generateErrorMessage } from "zod-error";import z from "./zod";-const ErrorCode = z.enum([+export const ErrorCode = z.enum(["bad_request","not_found","internal_server_error",@@ -16,7 +16,7 @@ const ErrorCode = z.enum(["invite_pending","exceeded_limit","conflict",- "unprocessible_entity",+ "unprocessable_entity",]);const errorCodeToHttpStatus: Record<z.infer<typeof ErrorCode>, number> = {@@ -28,7 +28,7 @@ const errorCodeToHttpStatus: Record<z.infer<typeof ErrorCode>, number> = {conflict: 409,invite_pending: 409,invite_expired: 410,- unprocessible_entity: 422,+ unprocessable_entity: 422,rate_limit_exceeded: 429,internal_server_error: 500,};@@ -59,6 +59,7 @@ const ErrorSchema = z.object({});export type ErrorResponse = z.infer<typeof ErrorSchema>;+export type ErrorCodes = z.infer<typeof ErrorCode>;export class DubApiError extends Error {public readonly code: z.infer<typeof ErrorCode>;diff --git a/apps/web/lib/openapi/responses.ts b/apps/web/lib/openapi/responses.tsindex 3bd3e05f53..6683cf24b3 100644--- a/apps/web/lib/openapi/responses.ts+++ b/apps/web/lib/openapi/responses.ts@@ -64,7 +64,7 @@ export const openApiErrorResponses = {"The request was well-formed but was unable to be followed due to semantic errors.",content: {"application/json": {- schema: errorSchemaFactory("unprocessible_entity"),+ schema: errorSchemaFactory("unprocessable_entity"),},},},diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.tsindex fbe0ac9330..85989c1d5b 100644--- a/apps/web/lib/types.ts+++ b/apps/web/lib/types.ts@@ -1,7 +1,6 @@import { DirectorySyncProviders } from "@boxyhq/saml-jackson";import z from "@/lib/zod";-import { PlanSchema } from "prisma/zod";import { createLinkBodySchema } from "./zod/schemas/links";import { tagColorSchema } from "./zod/schemas/tags";@@ -56,7 +55,7 @@ export interface TagProps {export type TagColorProps = z.infer<typeof tagColorSchema>;-export type PlanProps = z.infer<typeof PlanSchema>;+export type PlanProps = "free" | "pro" | "business" | "enterprise";export interface ProjectProps {id: string;diff --git a/apps/web/lib/zod/schemas/index.ts b/apps/web/lib/zod/schemas/index.tsnew file mode 100644index 0000000000..5aeef0c703--- /dev/null+++ b/apps/web/lib/zod/schemas/index.ts@@ -0,0 +1,22 @@+import z from "@/lib/zod";++export enum Plan {+ "free",+ "pro",+ "business",+ "enterprise",+}++export enum Role {+ "owner",+ "member",+}++export const PlanSchema = z+ .nativeEnum(Plan)+ .default(Plan.free)+ .describe("The plan of the project.");++export const RoleSchema = z+ .nativeEnum(Role)+ .describe("The role of the authenticated user in the project.");diff --git a/apps/web/lib/zod/schemas/links.ts b/apps/web/lib/zod/schemas/links.tsindex 646a98ee0d..30fad8bd0c 100644--- a/apps/web/lib/zod/schemas/links.ts+++ b/apps/web/lib/zod/schemas/links.ts@@ -1,5 +1,4 @@import z from "@/lib/zod";-import { LinkSchema as Link } from "prisma/zod";export const getLinksQuerySchema = z.object({projectSlug: z@@ -170,12 +169,6 @@ export const bulkCreateLinksBodySchema = z.array(createLinkBodySchema).max(100, "You can only create up to 100 links at a time.");-// TODO: Add description for each field-// TODO: Add proper type for geo-export const LinkSchema = Link.extend({- geo: z.record(z.string()).optional().nullable(),-}).openapi({ title: "Link" });-export const getLinksCountParamsSchema = z.object({userId: z.string().optional(),tagId: z.string().optional(),@@ -183,4 +176,133 @@ export const getLinksCountParamsSchema = z.object({showArchived: z.coerce.boolean().optional(),search: z.string().optional(),groupBy: z.union([z.literal("domain"), z.literal("tagId")]).optional(),-});\ No newline at end of file+});++export const LinkSchema = z.object({+ id: z.string().describe("The unique ID of the short link."),+ domain: z+ .string()+ .describe(+ "The domain of the short link. If not provided, the primary domain for the project will be used (or `dub.sh` if the project has no domains).",+ ),+ key: z+ .string()+ .describe(+ "The short link slug. If not provided, a random 7-character slug will be generated.",+ ),+ url: z.string().url().describe("The destination URL of the short link."),+ archived: z+ .boolean()+ .default(false)+ .describe("Whether the short link is archived."),+ expiresAt: z+ .string()+ .nullable()+ .describe(+ "The date and time when the short link will expire in ISO-8601 format. Must be in the future.",+ ),+ password: z+ .string()+ .nullable()+ .describe(+ "The password required to access the destination URL of the short link.",+ ),+ proxy: z+ .boolean()+ .default(false)+ .describe("Whether the short link uses Custom Social Media Cards feature."),+ title: z+ .string()+ .nullable()+ .describe(+ "The title of the short link generated via `api.dub.co/metatags`. Will be used for Custom Social Media Cards if `proxy` is true.",+ ),+ description: z+ .string()+ .nullable()+ .describe(+ "The description of the short link generated via `api.dub.co/metatags`. Will be used for Custom Social Media Cards if `proxy` is true.",+ ),+ image: z+ .string()+ .nullable()+ .describe(+ "The image of the short link generated via `api.dub.co/metatags`. Will be used for Custom Social Media Cards if `proxy` is true.",+ ),+ rewrite: z+ .boolean()+ .default(false)+ .describe("Whether the short link uses link cloaking."),+ ios: z+ .string()+ .nullable()+ .describe(+ "The iOS destination URL for the short link for iOS device targeting.",+ ),+ android: z+ .string()+ .nullable()+ .describe(+ "The Android destination URL for the short link for Android device targeting.",+ ),+ geo: z+ .record(z.string())+ .nullable()+ .describe(+ "Geo targeting information for the short link in JSON format `{[COUNTRY]: https://example.com }`. Learn more: https://dub.sh/geo",+ ),+ publicStats: z+ .boolean()+ .default(false)+ .describe("Whether the short link's stats are publicly accessible."),+ tagId: z+ .string()+ .nullable()+ .describe("The unique id of the tag assigned to the short link."),+ comments: z.string().nullable().describe("The comments for the short link."),+ shortLink: z+ .string()+ .url()+ .describe(+ "The full URL of the short link, including the https protocol (e.g. `https://dub.sh/try`).",+ ),+ qrCode: z+ .string()+ .url()+ .describe(+ "The full URL of the QR code for the short link (e.g. `https://api.dub.co/qr?url=https://dub.sh/try`).",+ ),+ utm_source: z+ .string()+ .nullable()+ .describe("The UTM source of the short link."),+ utm_medium: z+ .string()+ .nullable()+ .describe("The UTM medium of the short link."),+ utm_campaign: z+ .string()+ .nullable()+ .describe("The UTM campaign of the short link."),+ utm_term: z.string().nullable().describe("The UTM term of the short link."),+ utm_content: z+ .string()+ .nullable()+ .describe("The UTM content of the short link."),+ userId: z.string().describe("The user ID of the creator of the short link."),+ projectId: z.string().describe("The project ID of the short link."),+ clicks: z+ .number()+ .default(0)+ .describe("The number of clicks on the short link."),+ lastClicked: z+ .string()+ .nullable()+ .describe("The date and time when the short link was last clicked."),+ createdAt: z+ .string()+ .describe("The date and time when the short link was created."),+ updatedAt: z+ .string()+ .describe("The date and time when the short link was last updated."),+}).openapi({ title: "Link" });diff --git a/apps/web/lib/zod/schemas/projects.ts b/apps/web/lib/zod/schemas/projects.tsindex fab8a3d055..11ac1117f6 100644--- a/apps/web/lib/zod/schemas/projects.ts+++ b/apps/web/lib/zod/schemas/projects.ts@@ -1,5 +1,5 @@import z from "@/lib/zod";-import { PlanSchema, RoleSchema } from "prisma/zod";+import { PlanSchema, RoleSchema } from ".";export const projectSchema = z.object({@@ -18,7 +18,7 @@ export const projectSchema = zdomainsLimit: z.number().describe("The domains limit of the project."),tagsLimit: z.number().describe("The tags limit of the project."),usersLimit: z.number().describe("The users limit of the project."),- plan: PlanSchema.describe("The plan of the project."),+ plan: PlanSchema,stripeId: z.string().nullable().describe("The Stripe ID of the project."),billingCycleStart: z.number()@@ -31,9 +31,7 @@ export const projectSchema = zusers: z.array(z.object({- role: RoleSchema.describe(- "The role of the authenticated user in the project.",- ),+ role: RoleSchema,}),).describe("The role of the authenticated user in the project."),diff --git a/apps/web/package.json b/apps/web/package.jsonindex 05dc00e11a..117bfb9d6d 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -89,8 +89,7 @@"vaul": "^0.6.8","zod": "^3.22.4","zod-error": "^1.5.0",- "zod-openapi": "^2.12.0",- "zod-prisma-types": "^3.1.6"+ "zod-openapi": "^2.12.0"},"devDependencies": {"@types/dotenv-flow": "^3.3.2",diff --git a/apps/web/prisma/schema.prisma b/apps/web/prisma/schema.prismaindex 7843f186ad..608c6f4152 100644--- a/apps/web/prisma/schema.prisma+++ b/apps/web/prisma/schema.prisma@@ -12,16 +12,6 @@ generator client {previewFeatures = ["fullTextSearch", "fullTextIndex"]}-generator zod {- provider = "zod-prisma-types"- output = "./zod"- addSelectType = false- addIncludeType = false- addInputTypeValidation = false- createInputTypes = false- validateWhereUniqueInput = false-}-model User {id String @id @default(cuid())name String?@@ -29,28 +19,28 @@ model User {emailVerified DateTime?image String?- accounts Account[]- sessions Session[]- projects ProjectUsers[]- links Link[]- tokens Token[]- createdAt DateTime @default(now())+ accounts Account[]+ sessions Session[]+ projects ProjectUsers[]+ links Link[]+ tokens Token[]+ createdAt DateTime @default(now())}model Account {- id String @id @default(cuid())- userId String- type String- provider String- providerAccountId String- refresh_token String? @db.Text- refresh_token_expires_in Int?- access_token String? @db.Text- expires_at Int?- token_type String?- scope String?- id_token String? @db.Text- session_state String?+ id String @id @default(cuid())+ userId String+ type String+ provider String+ providerAccountId String+ refresh_token String? @db.Text+ refresh_token_expires_in Int?+ access_token String? @db.Text+ expires_at Int?+ token_type String?+ scope String?+ id_token String? @db.Text+ session_state String?user User @relation(fields: [userId], references: [id], onDelete: Cascade)@@ -77,48 +67,48 @@ model VerificationToken {}model Token {- id String @id @default(cuid())- name String- hashedKey String @unique+ id String @id @default(cuid())+ name String+ hashedKey String @uniquepartialKey String- expires DateTime?- lastUsed DateTime?- createdAt DateTime @default(now())- updatedAt DateTime @updatedAt- user User @relation(fields: [userId], references: [id], onDelete: Cascade)- userId String+ expires DateTime?+ lastUsed DateTime?+ createdAt DateTime @default(now())+ updatedAt DateTime @updatedAt+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)+ userId String@@index([userId])}model Project {- id String @id @default(cuid())- name String- slug String @unique- logo String?-- plan String @default("free")- stripeId String? @unique // Stripe subscription ID- billingCycleStart Int // day of the month when the billing cycle starts- usage Int @default(0)- usageLimit Int @default(1000)- linksUsage Int @default(0)- linksLimit Int @default(25)- domainsLimit Int @default(3)- tagsLimit Int @default(5)- usersLimit Int @default(1)- monitoringId String? @unique // cron job ID for monitoring-- users ProjectUsers[]- invites ProjectInvite[]- sentEmails SentEmail[]- links Link[]- domains Domain[]- tags Tag[]-- createdAt DateTime @default(now())- updatedAt DateTime @updatedAt- metadata Json? @default("{\"defaultDomains\":[\"dub.sh\",\"chatg.pt\",\"spti.fi\",\"amzn.id\"]}")+ id String @id @default(cuid())+ name String+ slug String @unique+ logo String?++ plan String @default("free")+ stripeId String? @unique // Stripe subscription ID+ billingCycleStart Int // day of the month when the billing cycle starts+ usage Int @default(0)+ usageLimit Int @default(1000)+ linksUsage Int @default(0)+ linksLimit Int @default(25)+ domainsLimit Int @default(3)+ tagsLimit Int @default(5)+ usersLimit Int @default(1)+ monitoringId String? @unique // cron job ID for monitoring++ users ProjectUsers[]+ invites ProjectInvite[]+ sentEmails SentEmail[]+ links Link[]+ domains Domain[]+ tags Tag[]++ createdAt DateTime @default(now())+ updatedAt DateTime @updatedAt+ metadata Json? @default("{\"defaultDomains\":[\"dub.sh\",\"chatg.pt\",\"spti.fi\",\"amzn.id\"]}")}model ProjectInvite {@@ -137,16 +127,9 @@ enum Role {member}-enum Plan {- free- pro- business- enterprise-}-model ProjectUsers {id String @id @default(cuid())- role Role @default(member)+ role Role @default(member)createdAt DateTime @default(now())updatedAt DateTime @updatedAtuser User @relation(fields: [userId], references: [id], onDelete: Cascade)@@ -159,33 +142,33 @@ model ProjectUsers {}model SentEmail {- id String @id @default(cuid())+ id String @id @default(cuid())type String- createdAt DateTime @default(now())- project Project? @relation(fields: [projectId], references: [id], onDelete: Cascade)+ createdAt DateTime @default(now())+ project Project? @relation(fields: [projectId], references: [id], onDelete: Cascade)projectId String?@@index([projectId])}model Domain {- id String @id @default(cuid())- slug String @unique- verified Boolean @default(false)- target String?- type String @default("redirect")- placeholder String @default("https://dub.co/help/article/what-is-dub")- description String?- project Project? @relation(fields: [projectId], references: [id], onDelete: Cascade)- projectId String?- primary Boolean @default(false)- archived Boolean @default(false)- links Link[]- clicks Int @default(0)- lastClicked DateTime? // when the link was last clicked- lastChecked DateTime @default(now())- createdAt DateTime @default(now())- updatedAt DateTime @updatedAt+ id String @id @default(cuid())+ slug String @unique+ verified Boolean @default(false)+ target String?+ type String @default("redirect")+ placeholder String @default("https://dub.co/help/article/what-is-dub")+ description String?+ project Project? @relation(fields: [projectId], references: [id], onDelete: Cascade)+ projectId String?+ primary Boolean @default(false)+ archived Boolean @default(false)+ links Link[]+ clicks Int @default(0)+ lastClicked DateTime? // when the link was last clicked+ lastChecked DateTime @default(now())+ createdAt DateTime @default(now())+ updatedAt DateTime @updatedAt@@index(projectId)@@index(clicks(sort: Desc))@@ -215,12 +198,12 @@ model Link {utm_content String? // UTM content for the link (e.g. description)// Link cloaking/masking via rewrite- rewrite Boolean @default(false) // whether to rewrite the link or not+ rewrite Boolean @default(false) // whether to rewrite the link or not// Custom device targetingios String? @db.LongText // custom link for iOS devicesandroid String? @db.LongText // custom link for Android devices- geo Json? @db.Json // custom link for specific countries+ geo Json? @db.Json // custom link for specific countries// User who created the linkuser User? @relation(fields: [userId], references: [id])@@ -232,19 +215,19 @@ model Link {// Relational reference to the project domainprojectDomain Domain? @relation(fields: [domain], references: [slug], onUpdate: Cascade, onDelete: Cascade)- publicStats Boolean @default(false) // whether to show public stats or not- clicks Int @default(0) // number of clicks+ publicStats Boolean @default(false) // whether to show public stats or not+ clicks Int @default(0) // number of clickslastClicked DateTime? // when the link was last clicked- checkDisabled Boolean @default(false) // disable 404 checking- createdAt DateTime @default(now())- updatedAt DateTime @updatedAt+ checkDisabled Boolean @default(false) // disable 404 checking+ createdAt DateTime @default(now())+ updatedAt DateTime @updatedAt// Link tagstag Tag? @relation(fields: [tagId], references: [id])tagId String?// Comments on the particular shortlink- comments String? @db.LongText+ comments String? @db.LongText// TODO: might wanna add indices for utm_source, utm_medium, utm_campaign@@ -286,13 +269,13 @@ model jackson_index {}model jackson_store {- key String @id @db.VarChar(250)- value String @db.Text- iv String? @db.VarChar(64)- tag String? @db.VarChar(64)- namespace String? @db.VarChar(64)- createdAt DateTime @default(now()) @db.Timestamp(0)- modifiedAt DateTime? @db.Timestamp(0)+ key String @id @db.VarChar(250)+ value String @db.Text+ iv String? @db.VarChar(64)+ tag String? @db.VarChar(64)+ namespace String? @db.VarChar(64)+ createdAt DateTime @default(now()) @db.Timestamp(0)+ modifiedAt DateTime? @db.Timestamp(0)@@index([namespace], map: "_jackson_store_namespace")}@@ -302,4 +285,4 @@ model jackson_ttl {expiresAt BigInt@@index([expiresAt], map: "_jackson_ttl_expires_at")-}+}\ No newline at end of filediff --git a/apps/web/prisma/zod/index.ts b/apps/web/prisma/zod/index.tsdeleted file mode 100644index 19d88ae733..0000000000--- a/apps/web/prisma/zod/index.ts+++ /dev/null@@ -1,402 +0,0 @@-import { z } from 'zod';-import { Prisma } from '@prisma/client';--/////////////////////////////////////////-// HELPER FUNCTIONS-/////////////////////////////////////////--// JSON-//--------------------------------------------------------export type NullableJsonInput = Prisma.JsonValue | null | 'JsonNull' | 'DbNull' | Prisma.NullTypes.DbNull | Prisma.NullTypes.JsonNull;--export const transformJsonNull = (v?: NullableJsonInput) => {- if (!v || v === 'DbNull') return Prisma.DbNull;- if (v === 'JsonNull') return Prisma.JsonNull;- return v;-};--export const JsonValueSchema: z.ZodType<Prisma.JsonValue> = z.lazy(() =>- z.union([- z.string(),- z.number(),- z.boolean(),- z.literal(null),- z.record(z.lazy(() => JsonValueSchema.optional())),- z.array(z.lazy(() => JsonValueSchema)),- ])-);--export type JsonValueType = z.infer<typeof JsonValueSchema>;--export const NullableJsonValue = z- .union([JsonValueSchema, z.literal('DbNull'), z.literal('JsonNull')])- .nullable()- .transform((v) => transformJsonNull(v));--export type NullableJsonValueType = z.infer<typeof NullableJsonValue>;--export const InputJsonValueSchema: z.ZodType<Prisma.InputJsonValue> = z.lazy(() =>- z.union([- z.string(),- z.number(),- z.boolean(),- z.object({ toJSON: z.function(z.tuple([]), z.any()) }),- z.record(z.lazy(() => z.union([InputJsonValueSchema, z.literal(null)]))),- z.array(z.lazy(() => z.union([InputJsonValueSchema, z.literal(null)]))),- ])-);--export type InputJsonValueType = z.infer<typeof InputJsonValueSchema>;---/////////////////////////////////////////-// ENUMS-/////////////////////////////////////////--export const TransactionIsolationLevelSchema = z.enum(['ReadUncommitted','ReadCommitted','RepeatableRead','Serializable']);--export const UserScalarFieldEnumSchema = z.enum(['id','name','email','emailVerified','image','createdAt']);--export const AccountScalarFieldEnumSchema = z.enum(['id','userId','type','provider','providerAccountId','refresh_token','refresh_token_expires_in','access_token','expires_at','token_type','scope','id_token','session_state']);--export const SessionScalarFieldEnumSchema = z.enum(['id','sessionToken','userId','expires']);--export const VerificationTokenScalarFieldEnumSchema = z.enum(['identifier','token','expires']);--export const TokenScalarFieldEnumSchema = z.enum(['id','name','hashedKey','partialKey','expires','lastUsed','createdAt','updatedAt','userId']);--export const ProjectScalarFieldEnumSchema = z.enum(['id','name','slug','logo','plan','stripeId','billingCycleStart','usage','usageLimit','linksUsage','linksLimit','domainsLimit','tagsLimit','usersLimit','monitoringId','createdAt','updatedAt','metadata']);--export const ProjectInviteScalarFieldEnumSchema = z.enum(['email','expires','projectId','createdAt']);--export const ProjectUsersScalarFieldEnumSchema = z.enum(['id','role','createdAt','updatedAt','userId','projectId']);--export const SentEmailScalarFieldEnumSchema = z.enum(['id','type','createdAt','projectId']);--export const DomainScalarFieldEnumSchema = z.enum(['id','slug','verified','target','type','placeholder','description','projectId','primary','archived','clicks','lastClicked','lastChecked','createdAt','updatedAt']);--export const LinkScalarFieldEnumSchema = z.enum(['id','domain','key','url','archived','expiresAt','password','proxy','title','description','image','utm_source','utm_medium','utm_campaign','utm_term','utm_content','rewrite','ios','android','geo','userId','projectId','publicStats','clicks','lastClicked','checkDisabled','createdAt','updatedAt','tagId','comments']);--export const TagScalarFieldEnumSchema = z.enum(['id','name','color','createdAt','updatedAt','projectId']);--export const Jackson_indexScalarFieldEnumSchema = z.enum(['id','key','storeKey']);--export const Jackson_storeScalarFieldEnumSchema = z.enum(['key','value','iv','tag','namespace','createdAt','modifiedAt']);--export const Jackson_ttlScalarFieldEnumSchema = z.enum(['key','expiresAt']);--export const SortOrderSchema = z.enum(['asc','desc']);--export const NullableJsonNullValueInputSchema = z.enum(['DbNull','JsonNull',]).transform((value) => value === 'JsonNull' ? Prisma.JsonNull : value === 'DbNull' ? Prisma.DbNull : value);--export const NullsOrderSchema = z.enum(['first','last']);--export const UserOrderByRelevanceFieldEnumSchema = z.enum(['id','name','email','image']);--export const AccountOrderByRelevanceFieldEnumSchema = z.enum(['id','userId','type','provider','providerAccountId','refresh_token','access_token','token_type','scope','id_token','session_state']);--export const SessionOrderByRelevanceFieldEnumSchema = z.enum(['id','sessionToken','userId']);--export const VerificationTokenOrderByRelevanceFieldEnumSchema = z.enum(['identifier','token']);--export const TokenOrderByRelevanceFieldEnumSchema = z.enum(['id','name','hashedKey','partialKey','userId']);--export const JsonNullValueFilterSchema = z.enum(['DbNull','JsonNull','AnyNull',]).transform((value) => value === 'JsonNull' ? Prisma.JsonNull : value === 'DbNull' ? Prisma.JsonNull : value === 'AnyNull' ? Prisma.AnyNull : value);--export const ProjectOrderByRelevanceFieldEnumSchema = z.enum(['id','name','slug','logo','plan','stripeId','monitoringId']);--export const ProjectInviteOrderByRelevanceFieldEnumSchema = z.enum(['email','projectId']);--export const ProjectUsersOrderByRelevanceFieldEnumSchema = z.enum(['id','userId','projectId']);--export const SentEmailOrderByRelevanceFieldEnumSchema = z.enum(['id','type','projectId']);--export const DomainOrderByRelevanceFieldEnumSchema = z.enum(['id','slug','target','type','placeholder','description','projectId']);--export const LinkOrderByRelevanceFieldEnumSchema = z.enum(['id','domain','key','url','password','title','description','image','utm_source','utm_medium','utm_campaign','utm_term','utm_content','ios','android','userId','projectId','tagId','comments']);--export const TagOrderByRelevanceFieldEnumSchema = z.enum(['id','name','color','projectId']);--export const jackson_indexOrderByRelevanceFieldEnumSchema = z.enum(['key','storeKey']);--export const jackson_storeOrderByRelevanceFieldEnumSchema = z.enum(['key','value','iv','tag','namespace']);--export const jackson_ttlOrderByRelevanceFieldEnumSchema = z.enum(['key']);--export const RoleSchema = z.enum(['owner','member']);--export type RoleType = `${z.infer<typeof RoleSchema>}`--export const PlanSchema = z.enum(['free','pro','business','enterprise']);--export type PlanType = `${z.infer<typeof PlanSchema>}`--/////////////////////////////////////////-// MODELS-/////////////////////////////////////////--/////////////////////////////////////////-// USER SCHEMA-/////////////////////////////////////////--export const UserSchema = z.object({- id: z.string().cuid(),- name: z.string().nullable(),- email: z.string().nullable(),- emailVerified: z.coerce.date().nullable(),- image: z.string().nullable(),- createdAt: z.coerce.date(),-})--export type User = z.infer<typeof UserSchema>--/////////////////////////////////////////-// ACCOUNT SCHEMA-/////////////////////////////////////////--export const AccountSchema = z.object({- id: z.string().cuid(),- userId: z.string(),- type: z.string(),- provider: z.string(),- providerAccountId: z.string(),- refresh_token: z.string().nullable(),- refresh_token_expires_in: z.number().int().nullable(),- access_token: z.string().nullable(),- expires_at: z.number().int().nullable(),- token_type: z.string().nullable(),- scope: z.string().nullable(),- id_token: z.string().nullable(),- session_state: z.string().nullable(),-})--export type Account = z.infer<typeof AccountSchema>--/////////////////////////////////////////-// SESSION SCHEMA-/////////////////////////////////////////--export const SessionSchema = z.object({- id: z.string().cuid(),- sessionToken: z.string(),- userId: z.string(),- expires: z.coerce.date(),-})--export type Session = z.infer<typeof SessionSchema>--/////////////////////////////////////////-// VERIFICATION TOKEN SCHEMA-/////////////////////////////////////////--export const VerificationTokenSchema = z.object({- identifier: z.string(),- token: z.string(),- expires: z.coerce.date(),-})--export type VerificationToken = z.infer<typeof VerificationTokenSchema>--/////////////////////////////////////////-// TOKEN SCHEMA-/////////////////////////////////////////--export const TokenSchema = z.object({- id: z.string().cuid(),- name: z.string(),- hashedKey: z.string(),- partialKey: z.string(),- expires: z.coerce.date().nullable(),- lastUsed: z.coerce.date().nullable(),- createdAt: z.coerce.date(),- updatedAt: z.coerce.date(),- userId: z.string(),-})--export type Token = z.infer<typeof TokenSchema>--/////////////////////////////////////////-// PROJECT SCHEMA-/////////////////////////////////////////--export const ProjectSchema = z.object({- id: z.string().cuid(),- name: z.string(),- slug: z.string(),- logo: z.string().nullable(),- plan: z.string(),- stripeId: z.string().nullable(),- billingCycleStart: z.number().int(),- usage: z.number().int(),- usageLimit: z.number().int(),- linksUsage: z.number().int(),- linksLimit: z.number().int(),- domainsLimit: z.number().int(),- tagsLimit: z.number().int(),- usersLimit: z.number().int(),- monitoringId: z.string().nullable(),- createdAt: z.coerce.date(),- updatedAt: z.coerce.date(),- metadata: JsonValueSchema,-})--export type Project = z.infer<typeof ProjectSchema>--/////////////////////////////////////////-// PROJECT INVITE SCHEMA-/////////////////////////////////////////--export const ProjectInviteSchema = z.object({- email: z.string(),- expires: z.coerce.date(),- projectId: z.string(),- createdAt: z.coerce.date(),-})--export type ProjectInvite = z.infer<typeof ProjectInviteSchema>--/////////////////////////////////////////-// PROJECT USERS SCHEMA-/////////////////////////////////////////--export const ProjectUsersSchema = z.object({- role: RoleSchema,- id: z.string().cuid(),- createdAt: z.coerce.date(),- updatedAt: z.coerce.date(),- userId: z.string(),- projectId: z.string(),-})--export type ProjectUsers = z.infer<typeof ProjectUsersSchema>--/////////////////////////////////////////-// SENT EMAIL SCHEMA-/////////////////////////////////////////--export const SentEmailSchema = z.object({- id: z.string().cuid(),- type: z.string(),- createdAt: z.coerce.date(),- projectId: z.string().nullable(),-})--export type SentEmail = z.infer<typeof SentEmailSchema>--/////////////////////////////////////////-// DOMAIN SCHEMA-/////////////////////////////////////////--export const DomainSchema = z.object({- id: z.string().cuid(),- slug: z.string(),- verified: z.boolean(),- target: z.string().nullable(),- type: z.string(),- placeholder: z.string(),- description: z.string().nullable(),- projectId: z.string().nullable(),- primary: z.boolean(),- archived: z.boolean(),- clicks: z.number().int(),- lastClicked: z.coerce.date().nullable(),- lastChecked: z.coerce.date(),- createdAt: z.coerce.date(),- updatedAt: z.coerce.date(),-})--export type Domain = z.infer<typeof DomainSchema>--/////////////////////////////////////////-// LINK SCHEMA-/////////////////////////////////////////--export const LinkSchema = z.object({- id: z.string().cuid(),- domain: z.string(),- key: z.string(),- url: z.string(),- archived: z.boolean(),- expiresAt: z.coerce.date().nullable(),- password: z.string().nullable(),- proxy: z.boolean(),- title: z.string().nullable(),- description: z.string().nullable(),- image: z.string().nullable(),- utm_source: z.string().nullable(),- utm_medium: z.string().nullable(),- utm_campaign: z.string().nullable(),- utm_term: z.string().nullable(),- utm_content: z.string().nullable(),- rewrite: z.boolean(),- ios: z.string().nullable(),- android: z.string().nullable(),- geo: JsonValueSchema,- userId: z.string().nullable(),- projectId: z.string().nullable(),- publicStats: z.boolean(),- clicks: z.number().int(),- lastClicked: z.coerce.date().nullable(),- checkDisabled: z.boolean(),- createdAt: z.coerce.date(),- updatedAt: z.coerce.date(),- tagId: z.string().nullable(),- comments: z.string().nullable(),-})--export type Link = z.infer<typeof LinkSchema>--/////////////////////////////////////////-// TAG SCHEMA-/////////////////////////////////////////--export const TagSchema = z.object({- id: z.string().cuid(),- name: z.string(),- color: z.string(),- createdAt: z.coerce.date(),- updatedAt: z.coerce.date(),- projectId: z.string(),-})--export type Tag = z.infer<typeof TagSchema>--/////////////////////////////////////////-// JACKSON INDEX SCHEMA-/////////////////////////////////////////--export const jackson_indexSchema = z.object({- id: z.number().int(),- key: z.string(),- storeKey: z.string(),-})--export type jackson_index = z.infer<typeof jackson_indexSchema>--/////////////////////////////////////////-// JACKSON STORE SCHEMA-/////////////////////////////////////////--export const jackson_storeSchema = z.object({- key: z.string(),- value: z.string(),- iv: z.string().nullable(),- tag: z.string().nullable(),- namespace: z.string().nullable(),- createdAt: z.coerce.date(),- modifiedAt: z.coerce.date().nullable(),-})--export type jackson_store = z.infer<typeof jackson_storeSchema>--/////////////////////////////////////////-// JACKSON TTL SCHEMA-/////////////////////////////////////////--export const jackson_ttlSchema = z.object({- key: z.string(),- expiresAt: z.bigint(),-})--export type jackson_ttl = z.infer<typeof jackson_ttlSchema>diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex ae61047184..b37d6115de 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -271,9 +271,6 @@ importers:zod-openapi:specifier: ^2.12.0version: 2.12.0([email protected])- zod-prisma-types:- specifier: ^3.1.6- version: 3.1.6devDependencies:'@types/dotenv-flow':specifier: ^3.3.2@@ -4027,10 +4024,6 @@ packages:prisma: 5.2.0dev: false- /@prisma/[email protected]:- resolution: {integrity: sha512-yAHFSFCg8KVoL0oRUno3m60GAjsUKYUDkQ+9BA2X2JfVR3kRVSJFc/GpQ2fSORi4pSHZR9orfM4UC9OVXIFFTA==}- dev: false-/@prisma/engines-version@5.2.0-25.2804dc98259d2ea960602aca6b8e7fdc03c1758f:resolution: {integrity: sha512-jsnKT5JIDIE01lAeCj2ghY9IwxkedhKNvxQeoyLs6dr4ZXynetD0vTy7u6wMJt8vVPv8I5DPy/I4CFaoXAgbtg==}dev: false@@ -4040,12 +4033,6 @@ packages:requiresBuild: truedev: false- /@prisma/[email protected]:- resolution: {integrity: sha512-WMdEUPpPYxUGruRQM6e6IVTWXFjt1hHdF/m2TO7pWxhPo7/ZeoTOF9fH8JsvVSV78DYLOQkx9osjFLXZu447Kw==}- dependencies:- '@prisma/debug': 5.9.1- dev: false-/@protobufjs/[email protected]:resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==}dev: false@@ -8364,10 +8351,6 @@ packages:phenomenon: 1.6.0dev: false- resolution: {integrity: sha512-q4dMFMlXtKR3XNBHyMHt/3pwYNA69EDk00lloMOaaUMKPUXBw6lpXtbu3MMVG6/uOihGnRDOlkyqsONEUj60+w==}- dev: false-resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==}dependencies:@@ -13115,7 +13098,7 @@ packages:optional: truedependencies:prettier: 3.2.5- prettier-plugin-organize-imports: 3.2.4([email protected])([email protected])+ prettier-plugin-organize-imports: 3.2.4([email protected])([email protected])dev: true@@ -15978,16 +15961,6 @@ packages:zod: 3.22.4dev: false- resolution: {integrity: sha512-ySaG91RraTm4J19zfvuX6S3OxhDMlK4dTfYWM4rS+4AlEGqDqGu5BbIn2trjTDt8OiCMBHoIjZmRXPKQCyNApA==}- hasBin: true- dependencies:- '@prisma/generator-helper': 5.9.1- code-block-writer: 12.0.0- lodash: 4.17.21- zod: 3.22.4- dev: false-resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==}dev: false