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.

Format

Kiran Kc92e82c68eb6
diff --git a/apps/web/app/api/links/bulk/route.ts b/apps/web/app/api/links/bulk/route.ts
index 51ab7b8025..af962e57b2 100644
--- a/apps/web/app/api/links/bulk/route.ts
+++ b/apps/web/app/api/links/bulk/route.ts
@@ -1,10 +1,10 @@
import { exceededLimitError } from "@/lib/api/errors";
import { bulkCreateLinks, processLink } from "@/lib/api/links";
import { withAuth } from "@/lib/auth";
-import { NextResponse } from "next/server";
import { DubApiError, handleAndReturnErrorResponse } from "@/lib/errors";
-import { bulkCreateLinksBodySchema } from "@/lib/zod/schemas/links";
import { LinkProps } from "@/lib/types";
+import { bulkCreateLinksBodySchema } from "@/lib/zod/schemas/links";
+import { NextResponse } from "next/server";
// POST /api/links/bulk – bulk create up to 100 links
export const POST = withAuth(
@@ -15,7 +15,7 @@ export const POST = withAuth(
code: "bad_request",
message:
"Missing project. Bulk link creation is only available for custom domain projects.",
- })
+ });
}
const links = bulkCreateLinksBodySchema.parse(await req.json());
if (
@@ -31,38 +31,43 @@ export const POST = withAuth(
}),
});
}
-
+
const processedLinks = await Promise.all(
links.map(async (link) =>
- processLink({ payload: link as LinkProps, project, session, bulk: true }),
+ processLink({
+ payload: link as LinkProps,
+ project,
+ session,
+ bulk: true,
+ }),
),
);
-
+
const validLinks = processedLinks
.filter(({ error }) => !error)
.map(({ link }) => link);
-
+
const errors = processedLinks
.filter(({ error }) => error)
.map(({ link, error }) => ({
link,
error,
}));
-
+
const validLinksResponse =
- validLinks.length > 0 ? await bulkCreateLinks({ links: validLinks }) : [];
-
- // TODO: Kiran
- // Handle error in the response
+ validLinks.length > 0
+ ? await bulkCreateLinks({ links: validLinks })
+ : [];
+
+ // TODO: Kiran
+ // Handle error in the response
return NextResponse.json([...validLinksResponse, ...errors], { headers });
} catch (error) {
return handleAndReturnErrorResponse(error);
}
-
-
},
{
needNotExceededLinks: true,
requiredPlan: ["pro", "business", "enterprise"],
},
-);
\ No newline at end of file
+);
diff --git a/apps/web/app/api/links/route.ts b/apps/web/app/api/links/route.ts
index c1a616f215..5f1d0ca57c 100644
--- a/apps/web/app/api/links/route.ts
+++ b/apps/web/app/api/links/route.ts
@@ -1,37 +1,47 @@
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 { LinkProps } from "@/lib/types";
import { ratelimit } from "@/lib/upstash";
+import {
+ createLinkBodySchema,
+ getLinksQuerySchema,
+} from "@/lib/zod/schemas/links";
import { APP_DOMAIN_WITH_NGROK, LOCALHOST_IP } from "@dub/utils";
import { NextResponse } from "next/server";
-import { getLinksQuerySchema, createLinkBodySchema } from "@/lib/zod/schemas/links";
-import { DubApiError, handleAndReturnErrorResponse } from "@/lib/errors";
-import { LinkProps } from "@/lib/types";
// GET /api/links – get all user links
export const GET = withAuth(async ({ headers, searchParams, project }) => {
- try {
- const { domain, tagId, search, sort, page, userId, showArchived, withTags } = getLinksQuerySchema.parse(
- searchParams,
- );
-
- const response = await getLinksForProject({
- projectId: project.id,
- domain,
- tagId,
- search,
- sort,
- page,
- userId,
- showArchived,
- withTags,
- });
- return NextResponse.json(response, {
- headers,
- });
- } catch (error) {
- return handleAndReturnErrorResponse(error);
- }
+ try {
+ const {
+ domain,
+ tagId,
+ search,
+ sort,
+ page,
+ userId,
+ showArchived,
+ withTags,
+ } = getLinksQuerySchema.parse(searchParams);
+
+ const response = await getLinksForProject({
+ projectId: project.id,
+ domain,
+ tagId,
+ search,
+ sort,
+ page,
+ userId,
+ showArchived,
+ withTags,
+ });
+ return NextResponse.json(response, {
+ headers,
+ });
+ } catch (error) {
+ return handleAndReturnErrorResponse(error);
+ }
});
// POST /api/links – create a new link
@@ -43,34 +53,35 @@ export const POST = withAuth(
if (!session) {
const ip = req.headers.get("x-forwarded-for") || LOCALHOST_IP;
const { success } = await ratelimit(10, "1 d").limit(ip);
-
+
if (!success) {
throw new DubApiError({
code: "rate_limit_exceeded",
- message: "Rate limited – you can only create up to 10 links per day without an account.",
+ message:
+ "Rate limited – you can only create up to 10 links per day without an account.",
});
}
}
-
+
const { link, error, status } = await processLink({
payload: body as LinkProps,
project,
session,
});
-
+
if (error) {
return new Response(error, { status, headers });
}
-
+
const response = await addLink(link);
-
+
if (response === null) {
throw new DubApiError({
code: "conflict",
message: "Duplicate key: This short link already exists.",
});
}
-
+
await qstash.publishJSON({
url: `${APP_DOMAIN_WITH_NGROK}/api/cron/links/event`,
body: {
@@ -78,7 +89,7 @@ export const POST = withAuth(
type: "create",
},
});
-
+
return NextResponse.json(response, { headers });
} catch (error) {
return handleAndReturnErrorResponse(error);
@@ -88,4 +99,4 @@ export const POST = withAuth(
needNotExceededLinks: true,
allowAnonymous: true,
},
-);
\ No newline at end of file
+);
diff --git a/apps/web/app/api/projects/[slug]/route.ts b/apps/web/app/api/projects/[slug]/route.ts
index 383d02fd80..78625b22e1 100644
--- a/apps/web/app/api/projects/[slug]/route.ts
+++ b/apps/web/app/api/projects/[slug]/route.ts
@@ -1,11 +1,11 @@
import { deleteProject } from "@/lib/api/projects";
import { withAuth } from "@/lib/auth";
+import { isReservedKey } from "@/lib/edge-config";
+import { handleAndReturnErrorResponse } from "@/lib/errors";
import prisma from "@/lib/prisma";
import z from "@/lib/zod";
import { DEFAULT_REDIRECTS, validSlugRegex } from "@dub/utils";
-import { isReservedKey } from "@/lib/edge-config";
import { NextResponse } from "next/server";
-import { handleAndReturnErrorResponse } from "@/lib/errors";
const updateProjectSchema = z.object({
name: z.string().max(32).optional(),
@@ -13,13 +13,16 @@ const updateProjectSchema = z.object({
.string()
.max(48, { message: "Slug must be less than 48 characters" })
.regex(validSlugRegex, { message: "Invalid slug" })
- .refine(async (slug) => {
- if ((await isReservedKey(slug)) || DEFAULT_REDIRECTS[slug]) {
- return false;
- }
+ .refine(
+ async (slug) => {
+ if ((await isReservedKey(slug)) || DEFAULT_REDIRECTS[slug]) {
+ return false;
+ }
- return true;
- }, { message: "Cannot use reserved slugs" })
+ return true;
+ },
+ { message: "Cannot use reserved slugs" },
+ )
.optional(),
defaultDomains: z.array(z.string()).optional(),
});
@@ -33,9 +36,8 @@ export const GET = withAuth(async ({ project, headers }) => {
export const PUT = withAuth(
async ({ req, project }) => {
try {
- const { name, slug, defaultDomains } = await updateProjectSchema.parseAsync(
- await req.json(),
- );
+ const { name, slug, defaultDomains } =
+ await updateProjectSchema.parseAsync(await req.json());
const response = await prisma.project.update({
where: {
diff --git a/apps/web/lib/api/links.ts b/apps/web/lib/api/links.ts
index f565bfb8a1..5f498d1d3a 100644
--- a/apps/web/lib/api/links.ts
+++ b/apps/web/lib/api/links.ts
@@ -37,7 +37,9 @@ export async function getLinksForProject({
userId,
showArchived,
withTags,
-}: Omit<z.infer<typeof getLinksQuerySchema>, "projectSlug"> & {projectId: string}): Promise<LinkProps[]> {
+}: Omit<z.infer<typeof getLinksQuerySchema>, "projectSlug"> & {
+ projectId: string;
+}): Promise<LinkProps[]> {
const links = await prisma.link.findMany({
where: {
projectId,
@@ -685,4 +687,4 @@ export async function archiveLink(
archived,
},
});
-}
\ No newline at end of file
+}
diff --git a/apps/web/lib/edge-config.ts b/apps/web/lib/edge-config.ts
index 5dba9df2dd..f28ecb428f 100644
--- a/apps/web/lib/edge-config.ts
+++ b/apps/web/lib/edge-config.ts
@@ -72,7 +72,7 @@ export const isReservedKey = async (key: string) => {
}
let reservedKeys;
try {
- reservedKeys = ["api"]
+ reservedKeys = [];
} catch (e) {
reservedKeys = [];
}
diff --git a/apps/web/lib/openapi/links/get-links.ts b/apps/web/lib/openapi/links/get-links.ts
index 3567b781d0..451516ee6a 100644
--- a/apps/web/lib/openapi/links/get-links.ts
+++ b/apps/web/lib/openapi/links/get-links.ts
@@ -1,7 +1,7 @@
-import { ZodOpenApiOperationObject } from "zod-openapi";
import { openApiErrorResponses } from "@/lib/openapi/responses";
import z from "@/lib/zod";
import { getLinksQuerySchema, LinkSchema } from "@/lib/zod/schemas/links";
+import { ZodOpenApiOperationObject } from "zod-openapi";
export const getLinks: ZodOpenApiOperationObject = {
operationId: "getLinks",
diff --git a/apps/web/prisma/zod/index.ts b/apps/web/prisma/zod/index.ts
index 19d88ae733..af33ad782a 100644
--- a/apps/web/prisma/zod/index.ts
+++ b/apps/web/prisma/zod/index.ts
@@ -1,5 +1,5 @@
-import { z } from 'zod';
-import { Prisma } from '@prisma/client';
+import { Prisma } from "@prisma/client";
+import { z } from "zod";
/////////////////////////////////////////
// HELPER FUNCTIONS
@@ -8,11 +8,17 @@ import { Prisma } from '@prisma/client';
// JSON
//------------------------------------------------------
-export type NullableJsonInput = Prisma.JsonValue | null | 'JsonNull' | 'DbNull' | Prisma.NullTypes.DbNull | Prisma.NullTypes.JsonNull;
+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;
+ if (!v || v === "DbNull") return Prisma.DbNull;
+ if (v === "JsonNull") return Prisma.JsonNull;
return v;
};
@@ -24,113 +30,369 @@ export const JsonValueSchema: z.ZodType<Prisma.JsonValue> = z.lazy(() =>
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')])
+ .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 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>}`
+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
@@ -147,9 +409,9 @@ export const UserSchema = z.object({
emailVerified: z.coerce.date().nullable(),
image: z.string().nullable(),
createdAt: z.coerce.date(),
-})
+});
-export type User = z.infer<typeof UserSchema>
+export type User = z.infer<typeof UserSchema>;
/////////////////////////////////////////
// ACCOUNT SCHEMA
@@ -169,9 +431,9 @@ export const AccountSchema = z.object({
scope: z.string().nullable(),
id_token: z.string().nullable(),
session_state: z.string().nullable(),
-})
+});
-export type Account = z.infer<typeof AccountSchema>
+export type Account = z.infer<typeof AccountSchema>;
/////////////////////////////////////////
// SESSION SCHEMA
@@ -182,9 +444,9 @@ export const SessionSchema = z.object({
sessionToken: z.string(),
userId: z.string(),
expires: z.coerce.date(),
-})
+});
-export type Session = z.infer<typeof SessionSchema>
+export type Session = z.infer<typeof SessionSchema>;
/////////////////////////////////////////
// VERIFICATION TOKEN SCHEMA
@@ -194,9 +456,9 @@ export const VerificationTokenSchema = z.object({
identifier: z.string(),
token: z.string(),
expires: z.coerce.date(),
-})
+});
-export type VerificationToken = z.infer<typeof VerificationTokenSchema>
+export type VerificationToken = z.infer<typeof VerificationTokenSchema>;
/////////////////////////////////////////
// TOKEN SCHEMA
@@ -212,9 +474,9 @@ export const TokenSchema = z.object({
createdAt: z.coerce.date(),
updatedAt: z.coerce.date(),
userId: z.string(),
-})
+});
-export type Token = z.infer<typeof TokenSchema>
+export type Token = z.infer<typeof TokenSchema>;
/////////////////////////////////////////
// PROJECT SCHEMA
@@ -239,9 +501,9 @@ export const ProjectSchema = z.object({
createdAt: z.coerce.date(),
updatedAt: z.coerce.date(),
metadata: JsonValueSchema,
-})
+});
-export type Project = z.infer<typeof ProjectSchema>
+export type Project = z.infer<typeof ProjectSchema>;
/////////////////////////////////////////
// PROJECT INVITE SCHEMA
@@ -252,9 +514,9 @@ export const ProjectInviteSchema = z.object({
expires: z.coerce.date(),
projectId: z.string(),
createdAt: z.coerce.date(),
-})
+});
-export type ProjectInvite = z.infer<typeof ProjectInviteSchema>
+export type ProjectInvite = z.infer<typeof ProjectInviteSchema>;
/////////////////////////////////////////
// PROJECT USERS SCHEMA
@@ -267,9 +529,9 @@ export const ProjectUsersSchema = z.object({
updatedAt: z.coerce.date(),
userId: z.string(),
projectId: z.string(),
-})
+});
-export type ProjectUsers = z.infer<typeof ProjectUsersSchema>
+export type ProjectUsers = z.infer<typeof ProjectUsersSchema>;
/////////////////////////////////////////
// SENT EMAIL SCHEMA
@@ -280,9 +542,9 @@ export const SentEmailSchema = z.object({
type: z.string(),
createdAt: z.coerce.date(),
projectId: z.string().nullable(),
-})
+});
-export type SentEmail = z.infer<typeof SentEmailSchema>
+export type SentEmail = z.infer<typeof SentEmailSchema>;
/////////////////////////////////////////
// DOMAIN SCHEMA
@@ -304,9 +566,9 @@ export const DomainSchema = z.object({
lastChecked: z.coerce.date(),
createdAt: z.coerce.date(),
updatedAt: z.coerce.date(),
-})
+});
-export type Domain = z.infer<typeof DomainSchema>
+export type Domain = z.infer<typeof DomainSchema>;
/////////////////////////////////////////
// LINK SCHEMA
@@ -343,9 +605,9 @@ export const LinkSchema = z.object({
updatedAt: z.coerce.date(),
tagId: z.string().nullable(),
comments: z.string().nullable(),
-})
+});
-export type Link = z.infer<typeof LinkSchema>
+export type Link = z.infer<typeof LinkSchema>;
/////////////////////////////////////////
// TAG SCHEMA
@@ -358,9 +620,9 @@ export const TagSchema = z.object({
createdAt: z.coerce.date(),
updatedAt: z.coerce.date(),
projectId: z.string(),
-})
+});
-export type Tag = z.infer<typeof TagSchema>
+export type Tag = z.infer<typeof TagSchema>;
/////////////////////////////////////////
// JACKSON INDEX SCHEMA
@@ -370,9 +632,9 @@ 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>
+export type jackson_index = z.infer<typeof jackson_indexSchema>;
/////////////////////////////////////////
// JACKSON STORE SCHEMA
@@ -386,9 +648,9 @@ export const jackson_storeSchema = z.object({
namespace: z.string().nullable(),
createdAt: z.coerce.date(),
modifiedAt: z.coerce.date().nullable(),
-})
+});
-export type jackson_store = z.infer<typeof jackson_storeSchema>
+export type jackson_store = z.infer<typeof jackson_storeSchema>;
/////////////////////////////////////////
// JACKSON TTL SCHEMA
@@ -397,6 +659,6 @@ export type jackson_store = z.infer<typeof jackson_storeSchema>
export const jackson_ttlSchema = z.object({
key: z.string(),
expiresAt: z.bigint(),
-})
+});
-export type jackson_ttl = z.infer<typeof jackson_ttlSchema>
+export type jackson_ttl = z.infer<typeof jackson_ttlSchema>;