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.

types cleanup

Kiran K0b62d71185b6
diff --git a/apps/web/lib/openapi/tags/index.ts b/apps/web/lib/openapi/tags/index.ts
index 222029caa2..2e52a289f2 100644
--- a/apps/web/lib/openapi/tags/index.ts
+++ b/apps/web/lib/openapi/tags/index.ts
@@ -4,7 +4,7 @@ import { createTag } from "./create-tag";
import { getTags } from "./get-tags";
export const tagsPaths: ZodOpenApiPathsObject = {
- "/projects/{projectSlug}/tags": {
+ "/tags": {
post: createTag,
get: getTags,
},
diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.ts
index 85989c1d5b..8116d7c94c 100644
--- a/apps/web/lib/types.ts
+++ b/apps/web/lib/types.ts
@@ -2,7 +2,6 @@ import { DirectorySyncProviders } from "@boxyhq/saml-jackson";
import z from "@/lib/zod";
import { createLinkBodySchema } from "./zod/schemas/links";
-import { tagColorSchema } from "./zod/schemas/tags";
export { type Link as LinkProps } from "@prisma/client";
export interface SimpleLinkProps {
@@ -53,9 +52,9 @@ export interface TagProps {
color: TagColorProps;
}
-export type TagColorProps = z.infer<typeof tagColorSchema>;
+export type TagColorProps = keyof typeof TagColor
-export type PlanProps = "free" | "pro" | "business" | "enterprise";
+export type PlanProps = keyof typeof Plan;
export interface ProjectProps {
id: string;
@@ -153,3 +152,25 @@ export interface SAMLProviderProps {
}
export type NewLinkProps = z.infer<typeof createLinkBodySchema>;
+
+export enum Plan {
+ "free",
+ "pro",
+ "business",
+ "enterprise",
+}
+
+export enum Role {
+ "owner",
+ "member",
+}
+
+export enum TagColor {
+ "red",
+ "yellow",
+ "green",
+ "blue",
+ "purple",
+ "pink",
+ "brown",
+}
\ No newline at end of file
diff --git a/apps/web/lib/zod/schemas/index.ts b/apps/web/lib/zod/schemas/index.ts
index 5aeef0c703..be8a333e28 100644
--- a/apps/web/lib/zod/schemas/index.ts
+++ b/apps/web/lib/zod/schemas/index.ts
@@ -1,22 +1,15 @@
+import { Plan, Role, TagColor } from "@/lib/types";
import z from "@/lib/zod";
-export enum Plan {
- "free",
- "pro",
- "business",
- "enterprise",
-}
-
-export enum Role {
- "owner",
- "member",
-}
-
-export const PlanSchema = z
+export const planSchema = z
.nativeEnum(Plan)
.default(Plan.free)
.describe("The plan of the project.");
-export const RoleSchema = z
+export const roleSchema = z
.nativeEnum(Role)
.describe("The role of the authenticated user in the project.");
+
+export const tagColorSchema = z
+ .nativeEnum(TagColor)
+ .describe("The color of the tag.");
diff --git a/apps/web/lib/zod/schemas/projects.ts b/apps/web/lib/zod/schemas/projects.ts
index 11ac1117f6..49a76f69ba 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 ".";
+import { planSchema, roleSchema } from ".";
export const projectSchema = z
.object({
@@ -18,7 +18,7 @@ export const projectSchema = z
domainsLimit: 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,
+ plan: planSchema,
stripeId: z.string().nullable().describe("The Stripe ID of the project."),
billingCycleStart: z
.number()
@@ -31,7 +31,7 @@ export const projectSchema = z
users: z
.array(
z.object({
- role: RoleSchema,
+ role: roleSchema,
}),
)
.describe("The role of the authenticated user in the project."),
diff --git a/apps/web/lib/zod/schemas/tags.ts b/apps/web/lib/zod/schemas/tags.ts
index ed529222ca..26e0cc8ab6 100644
--- a/apps/web/lib/zod/schemas/tags.ts
+++ b/apps/web/lib/zod/schemas/tags.ts
@@ -13,13 +13,3 @@ export const tagSchema = z
.openapi({
title: "Tag",
});
-
-export const tagColorSchema = z.enum([
- "red",
- "yellow",
- "green",
- "blue",
- "purple",
- "pink",
- "brown",
-]);