Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Install and setup zod-prisma-types

Kiran K5664ba4aa396
diff --git a/apps/web/app/api/projects/[slug]/tags/route.ts b/apps/web/app/api/projects/[slug]/tags/route.ts
index 77ea93014c..975eb97e80 100644
--- a/apps/web/app/api/projects/[slug]/tags/route.ts
+++ b/apps/web/app/api/projects/[slug]/tags/route.ts
@@ -4,7 +4,7 @@ import prisma from "@/lib/prisma";
import { randomBadgeColor } from "@/ui/links/tag-badge";
import { NextResponse } from "next/server";
import { DubApiError, ErrorResponse, handleApiError } from "@/lib/errors";
-import { createTagSchema, Tag } from "@/lib/zod/schemas/tags";
+import { CreateTagSchema, Tag } from "@/lib/zod/schemas/tags";
// GET /api/projects/[slug]/tags - get all tags for a project
export const GET = withAuth(async ({ project, headers }) => {
@@ -49,7 +49,7 @@ export const POST = withAuth(async ({ req, project, headers }) => {
});
}
- const { tag } = createTagSchema.parse(await req.json());
+ const { tag } = CreateTagSchema.parse(await req.json());
const existingTag = await prisma.tag.findFirst({
where: {
diff --git a/apps/web/lib/zod/schemas/tags.ts b/apps/web/lib/zod/schemas/tags.ts
index ce1089aede..2e70184a58 100644
--- a/apps/web/lib/zod/schemas/tags.ts
+++ b/apps/web/lib/zod/schemas/tags.ts
@@ -1,25 +1,35 @@
-import { z } from "@/lib/zod";
import { ZodOpenApiOperationObject, ZodOpenApiPathsObject } from "zod-openapi";
-export const tagSchema = z
- .object({
- id: z.string().openapi({ description: "The unique ID of the tag." }),
- name: z.string().openapi({ description: "The name of the tag." }),
- color: z.string().openapi({ description: "The color of the tag." }),
- })
- .openapi({
- title: "Tag",
- description: "A tag schema",
- });
+import { z } from "@/lib/zod";
+import { TagSchema } from "prisma/zod";
+
+export const TagSchemaOpenApi = TagSchema.pick({
+ id: true,
+ name: true,
+ color: true,
+}).openapi({
+ title: "Tag",
+ properties: {
+ id: {
+ description: "The unique ID of the tag.",
+ },
+ name: {
+ description: "The name of the tag.",
+ },
+ color: {
+ description: "The color of the tag.",
+ },
+ },
+});
-export const createTagSchema = z.object({
+export const CreateTagSchema = z.object({
tag: z.string().min(1).openapi({
description: "The name of the tag to create.",
example: "news",
}),
});
-export type Tag = z.infer<typeof tagSchema>;
+export type Tag = z.infer<typeof TagSchemaOpenApi>;
export const createTag: ZodOpenApiOperationObject = {
operationId: "createTag",
@@ -37,7 +47,7 @@ export const createTag: ZodOpenApiOperationObject = {
requestBody: {
content: {
"application/json": {
- schema: createTagSchema,
+ schema: CreateTagSchema,
},
},
},
@@ -47,7 +57,7 @@ export const createTag: ZodOpenApiOperationObject = {
content: {
"application/json": {
schema: z.object({
- data: tagSchema,
+ data: TagSchemaOpenApi,
}),
},
},
@@ -74,7 +84,7 @@ export const getTags: ZodOpenApiOperationObject = {
content: {
"application/json": {
schema: z.object({
- data: z.array(tagSchema),
+ data: z.array(TagSchemaOpenApi),
}),
},
},
diff --git a/apps/web/prisma/schema.prisma b/apps/web/prisma/schema.prisma
index 3b8c1613b1..ca035b45bb 100644
--- a/apps/web/prisma/schema.prisma
+++ b/apps/web/prisma/schema.prisma
@@ -12,6 +12,16 @@ 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?
@@ -19,12 +29,12 @@ 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 {
@@ -66,48 +76,48 @@ model VerificationToken {
}
model Token {
- id String @id @default(cuid())
- name String
- hashedKey String @unique
+ id String @id @default(cuid())
+ name String
+ hashedKey String @unique
partialKey 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 {
@@ -128,7 +138,7 @@ enum Role {
model ProjectUsers {
id String @id @default(cuid())
- role Role @default(member)
+ role Role @default(member)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@ -141,33 +151,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))
@@ -197,12 +207,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 targeting
ios String? @db.LongText // custom link for iOS devices
android 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 link
user User? @relation(fields: [userId], references: [id])
@@ -214,19 +224,19 @@ model Link {
// Relational reference to the project domain
projectDomain 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 clicks
lastClicked 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 tags
tag 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
@@ -268,13 +278,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")
}
@@ -284,4 +294,4 @@ model jackson_ttl {
expiresAt BigInt
@@index([expiresAt], map: "_jackson_ttl_expires_at")
-}
\ No newline at end of file
+}
diff --git a/apps/web/prisma/zod/index.ts b/apps/web/prisma/zod/index.ts
new file mode 100644
index 0000000000..67723c8c42
--- /dev/null
+++ b/apps/web/prisma/zod/index.ts
@@ -0,0 +1,397 @@
+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','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>}`
+
+/////////////////////////////////////////
+// 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(),
+ 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.yaml
index f1cecaf481..ecbfcae553 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -338,6 +338,9 @@ importers:
typescript:
specifier: ^5.1.6
version: 5.1.6
+ zod-prisma-types:
+ specifier: ^3.1.6
+ version: 3.1.6
packages/tailwind-config:
dependencies:
@@ -489,7 +492,7 @@ importers:
version: link:../tsconfig
tsup:
specifier: ^6.1.3
- version: 6.1.3([email protected])
typescript:
specifier: ^5.1.6
version: 5.1.6
@@ -4685,6 +4688,10 @@ packages:
prisma: 5.2.0
dev: false
+ /@prisma/[email protected]:
+ resolution: {integrity: sha512-yAHFSFCg8KVoL0oRUno3m60GAjsUKYUDkQ+9BA2X2JfVR3kRVSJFc/GpQ2fSORi4pSHZR9orfM4UC9OVXIFFTA==}
+ dev: true
+
/@prisma/engines-version@5.2.0-25.2804dc98259d2ea960602aca6b8e7fdc03c1758f:
resolution: {integrity: sha512-jsnKT5JIDIE01lAeCj2ghY9IwxkedhKNvxQeoyLs6dr4ZXynetD0vTy7u6wMJt8vVPv8I5DPy/I4CFaoXAgbtg==}
dev: false
@@ -4694,6 +4701,12 @@ packages:
requiresBuild: true
dev: false
+ /@prisma/[email protected]:
+ resolution: {integrity: sha512-WMdEUPpPYxUGruRQM6e6IVTWXFjt1hHdF/m2TO7pWxhPo7/ZeoTOF9fH8JsvVSV78DYLOQkx9osjFLXZu447Kw==}
+ dependencies:
+ '@prisma/debug': 5.9.1
+ dev: true
+
/@protobufjs/[email protected]:
resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==}
dev: false
@@ -9115,6 +9128,10 @@ packages:
phenomenon: 1.6.0
dev: false
+ resolution: {integrity: sha512-q4dMFMlXtKR3XNBHyMHt/3pwYNA69EDk00lloMOaaUMKPUXBw6lpXtbu3MMVG6/uOihGnRDOlkyqsONEUj60+w==}
+ dev: true
+
resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==}
dependencies:
@@ -13864,6 +13881,7 @@ packages:
lilconfig: 2.1.0
postcss: 8.4.21
yaml: 1.10.2
+ dev: false
resolution: {integrity: sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg==}
@@ -13978,6 +13996,7 @@ packages:
nanoid: 3.3.6
picocolors: 1.0.0
source-map-js: 1.0.2
+ dev: false
resolution: {integrity: sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==}
@@ -16056,42 +16075,6 @@ packages:
- ts-node
dev: true
- resolution: {integrity: sha512-eRpBnbfpDFng+EJNTQ90N7QAf4HAGGC7O3buHIjroKWK7D1ibk9/YnR/3cS8HsMU5T+6Oi+cnF+yU5WmCnB//Q==}
- engines: {node: '>=14'}
- hasBin: true
- peerDependencies:
- '@swc/core': ^1
- postcss: ^8.4.12
- typescript: ^4.1.0
- peerDependenciesMeta:
- '@swc/core':
- optional: true
- postcss:
- optional: true
- typescript:
- optional: true
- dependencies:
- bundle-require: 3.1.2([email protected])
- cac: 6.7.14
- chokidar: 3.5.3
- debug: 4.3.4
- esbuild: 0.14.54
- execa: 5.1.1
- globby: 11.1.0
- joycon: 3.1.1
- postcss-load-config: 3.1.4([email protected])
- resolve-from: 5.0.0
- rollup: 2.79.1
- source-map: 0.8.0-beta.0
- sucrase: 3.34.0
- tree-kill: 1.2.2
- typescript: 5.1.6
- transitivePeerDependencies:
- - supports-color
- - ts-node
- dev: true
-
resolution: {integrity: sha512-xHtFaKtHxM9LOklMmJdI3BEnQq/D5F73Of2E1GDrITi9sgoVkvIsrQUTY1G8FlmGtA+awCI4EBlTRRYxkL2sRg==}
hasBin: true
@@ -17101,9 +17084,18 @@ packages:
zod: 3.22.4
dev: 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: true
+
resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==}
- dev: false
resolution: {integrity: sha512-PIJDIZKtokhof+9+60cpockVOq05sJzHCriyvaLBmEJixseQ1a5Kdov6fWZfWOu5SK9c+FhH1jU0tntLxRJYMA==}