Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

Split types to separate entrypoint. (#353)

Anthony Shew858e150e5517
diff --git a/apps/web/src/app/admin/challenge/[challengeId]/challenge-review.action.ts b/apps/web/src/app/admin/challenge/[challengeId]/challenge-review.action.ts
index 825db8b3..20a1c326 100644
--- a/apps/web/src/app/admin/challenge/[challengeId]/challenge-review.action.ts
+++ b/apps/web/src/app/admin/challenge/[challengeId]/challenge-review.action.ts
@@ -1,6 +1,7 @@
'use server';
-import { RoleTypes, prisma } from '@repo/db';
+import { RoleTypes } from '@repo/db/types';
+import { prisma } from '@repo/db';
export async function approveChallenge(
challengeId: number,
diff --git a/apps/web/src/app/admin/page.tsx b/apps/web/src/app/admin/page.tsx
index f068e01c..6da7666c 100644
--- a/apps/web/src/app/admin/page.tsx
+++ b/apps/web/src/app/admin/page.tsx
@@ -1,5 +1,5 @@
'use server';
-import { RoleTypes } from '@repo/db';
+import { RoleTypes } from '@repo/db/types';
import { Lock } from 'lucide-react';
import React from 'react';
import { getServerAuthSession } from '@repo/auth/server';
diff --git a/apps/web/src/app/admin/report/[id]/actions.tsx b/apps/web/src/app/admin/report/[id]/actions.tsx
index b6f081aa..a59968cd 100644
--- a/apps/web/src/app/admin/report/[id]/actions.tsx
+++ b/apps/web/src/app/admin/report/[id]/actions.tsx
@@ -1,6 +1,6 @@
'use client';
-import { type User } from '@repo/db';
+import { type User } from '@repo/db/types';
import { useRouter } from 'next/navigation';
import { useMemo, useState } from 'react';
import { type ReportWithInfo } from './report.action';
diff --git a/apps/web/src/components/admin/admin.actions.tsx b/apps/web/src/components/admin/admin.actions.tsx
index 39f59642..e88d761b 100644
--- a/apps/web/src/components/admin/admin.actions.tsx
+++ b/apps/web/src/components/admin/admin.actions.tsx
@@ -1,6 +1,6 @@
'use server';
-import { type Report, type Prisma } from '@repo/db';
+import { type Report, type Prisma } from '@repo/db/types';
import { prisma } from '@repo/db';
import { getServerAuthSession } from '@repo/auth/server';
diff --git a/apps/web/src/components/admin/challenge-reviews/columns.tsx b/apps/web/src/components/admin/challenge-reviews/columns.tsx
index 9cc3640b..0494f5f7 100644
--- a/apps/web/src/components/admin/challenge-reviews/columns.tsx
+++ b/apps/web/src/components/admin/challenge-reviews/columns.tsx
@@ -1,6 +1,6 @@
'use client';
-import type { Challenge } from '@repo/db';
+import type { Challenge } from '@repo/db/types';
import { type ColumnDef } from '@tanstack/react-table';
export const columns: ColumnDef<Challenge>[] = [
diff --git a/apps/web/src/components/admin/challenge-reviews/data-table.tsx b/apps/web/src/components/admin/challenge-reviews/data-table.tsx
index dd8a9c2c..7df07f06 100644
--- a/apps/web/src/components/admin/challenge-reviews/data-table.tsx
+++ b/apps/web/src/components/admin/challenge-reviews/data-table.tsx
@@ -1,6 +1,6 @@
'use client';
-import type { Challenge } from '@repo/db';
+import type { Challenge } from '@repo/db/types';
import { useQuery } from '@tanstack/react-query';
import {
type PaginationState,
diff --git a/apps/web/src/components/challenge/challenge-store.ts b/apps/web/src/components/challenge/challenge-store.ts
index cc6c77b6..1c2366e4 100644
--- a/apps/web/src/components/challenge/challenge-store.ts
+++ b/apps/web/src/components/challenge/challenge-store.ts
@@ -1,4 +1,4 @@
-import type { Difficulty } from '@repo/db';
+import type { Difficulty } from '@repo/db/types';
import { create } from 'zustand';
import { persist } from 'zustand/middleware';
diff --git a/apps/web/src/components/challenge/comments/comment.action.ts b/apps/web/src/components/challenge/comments/comment.action.ts
index 99de7971..c7b5e4d9 100644
--- a/apps/web/src/components/challenge/comments/comment.action.ts
+++ b/apps/web/src/components/challenge/comments/comment.action.ts
@@ -1,6 +1,6 @@
'use server';
-import type { CommentRoot } from '@repo/db';
+import type { CommentRoot } from '@repo/db/types';
import { prisma } from '@repo/db';
import { getServerAuthSession } from '@repo/auth/server';
diff --git a/apps/web/src/components/challenge/comments/comment.tsx b/apps/web/src/components/challenge/comments/comment.tsx
index 5b831168..793073a0 100644
--- a/apps/web/src/components/challenge/comments/comment.tsx
+++ b/apps/web/src/components/challenge/comments/comment.tsx
@@ -1,6 +1,6 @@
'use client';
-import { type CommentRoot } from '@repo/db';
+import { type CommentRoot } from '@repo/db/types';
import { useInfiniteQuery, useQueryClient } from '@tanstack/react-query';
import { ChevronDown, ChevronUp, Pencil, Reply, Share, Trash2 } from 'lucide-react';
import { useSession } from '@repo/auth/react';
diff --git a/apps/web/src/components/challenge/comments/getCommentRouteData.ts b/apps/web/src/components/challenge/comments/getCommentRouteData.ts
index 78851c40..16087603 100644
--- a/apps/web/src/components/challenge/comments/getCommentRouteData.ts
+++ b/apps/web/src/components/challenge/comments/getCommentRouteData.ts
@@ -1,5 +1,5 @@
'use server';
-import type { CommentRoot } from '@repo/db';
+import type { CommentRoot } from '@repo/db/types';
import { prisma } from '@repo/db';
const PAGESIZE = 10;
diff --git a/apps/web/src/components/challenge/comments/index.tsx b/apps/web/src/components/challenge/comments/index.tsx
index 1d9e6c0e..ff0ef6b2 100644
--- a/apps/web/src/components/challenge/comments/index.tsx
+++ b/apps/web/src/components/challenge/comments/index.tsx
@@ -1,6 +1,6 @@
'use client';
-import type { CommentRoot } from '@repo/db';
+import type { CommentRoot } from '@repo/db/types';
import { useQuery, useQueryClient } from '@tanstack/react-query';
import clsx from 'clsx';
import { ChevronDown, ChevronLeft, ChevronRight, MessageCircle } from 'lucide-react';
diff --git a/apps/web/src/components/challenge/submissions/index.tsx b/apps/web/src/components/challenge/submissions/index.tsx
index 65e5b7ee..046f2e2b 100644
--- a/apps/web/src/components/challenge/submissions/index.tsx
+++ b/apps/web/src/components/challenge/submissions/index.tsx
@@ -1,6 +1,6 @@
'use client';
-import type { Submission } from '@repo/db';
+import type { Submission } from '@repo/db/types';
import clsx from 'clsx';
import Link from 'next/link';
import { useMemo, useState } from 'react';
diff --git a/apps/web/src/components/create/explore-card-inputs.tsx b/apps/web/src/components/create/explore-card-inputs.tsx
index 7b2ed645..3c5c9675 100644
--- a/apps/web/src/components/create/explore-card-inputs.tsx
+++ b/apps/web/src/components/create/explore-card-inputs.tsx
@@ -1,7 +1,7 @@
'use client';
// TODO: unify this with the explore card into single component (maybe? idk how that'd work, too many changes)
import { MessageCircle, ThumbsUp } from 'lucide-react';
-import { type Difficulty } from '@repo/db';
+import { type Difficulty } from '@repo/db/types';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../ui/card';
import { Button } from '../ui/button';
import { DifficultyBadge } from '../ui/difficulty-badge';
diff --git a/apps/web/src/components/explore/section-carousel.tsx b/apps/web/src/components/explore/section-carousel.tsx
index dc951432..a90d6a14 100644
--- a/apps/web/src/components/explore/section-carousel.tsx
+++ b/apps/web/src/components/explore/section-carousel.tsx
@@ -1,6 +1,6 @@
'use client';
import Link from 'next/link';
-import type { Difficulty } from '@repo/db';
+import type { Difficulty } from '@repo/db/types';
import { useEffect, useRef, useState } from 'react';
import { ChevronRight } from 'lucide-react';
import { ExploreCard } from './explore-card';
diff --git a/apps/web/src/components/landing/hero-challenge-card.tsx b/apps/web/src/components/landing/hero-challenge-card.tsx
index 845ddbee..60bc7526 100644
--- a/apps/web/src/components/landing/hero-challenge-card.tsx
+++ b/apps/web/src/components/landing/hero-challenge-card.tsx
@@ -1,4 +1,4 @@
-import type { Difficulty } from '@repo/db';
+import type { Difficulty } from '@repo/db/types';
import { clsx } from 'clsx';
import { motion, type SVGMotionProps } from 'framer-motion';
import type { ReactNode } from 'react';
diff --git a/apps/web/src/components/report/index.tsx b/apps/web/src/components/report/index.tsx
index a441e3dd..ca6fffae 100644
--- a/apps/web/src/components/report/index.tsx
+++ b/apps/web/src/components/report/index.tsx
@@ -1,4 +1,4 @@
-import { type IssueType } from '@repo/db';
+import { type IssueType } from '@repo/db/types';
import React from 'react';
import { useForm } from 'react-hook-form';
import {
diff --git a/apps/web/src/components/report/report.action.ts b/apps/web/src/components/report/report.action.ts
index 312294f4..42011d4e 100644
--- a/apps/web/src/components/report/report.action.ts
+++ b/apps/web/src/components/report/report.action.ts
@@ -1,6 +1,6 @@
'use server';
-import { type Prisma, type Report } from '@repo/db';
+import { type Prisma, type Report } from '@repo/db/types';
import { prisma } from '@repo/db';
import { getServerAuthSession } from '@repo/auth/server';
diff --git a/apps/web/src/components/ui/difficulty-badge.tsx b/apps/web/src/components/ui/difficulty-badge.tsx
index 7f9acb72..32a78b94 100644
--- a/apps/web/src/components/ui/difficulty-badge.tsx
+++ b/apps/web/src/components/ui/difficulty-badge.tsx
@@ -1,4 +1,4 @@
-import { type Difficulty } from '@repo/db';
+import { type Difficulty } from '@repo/db/types';
import { Badge } from './badge';
interface Props {
diff --git a/apps/web/src/components/ui/navigation.tsx b/apps/web/src/components/ui/navigation.tsx
index 9f00984b..87158bc8 100644
--- a/apps/web/src/components/ui/navigation.tsx
+++ b/apps/web/src/components/ui/navigation.tsx
@@ -1,7 +1,7 @@
'use client';
import { useTheme } from 'next-themes';
-import { RoleTypes } from '@repo/db';
+import { RoleTypes } from '@repo/db/types';
import { Loader2, LogIn, Moon, Plus, Settings, Settings2, Sun, User } from 'lucide-react';
import { signIn, signOut, useSession } from '@repo/auth/react';
import Link from 'next/link';
diff --git a/apps/web/src/components/user/dashboard/index.tsx b/apps/web/src/components/user/dashboard/index.tsx
index b2914c2e..8eded737 100644
--- a/apps/web/src/components/user/dashboard/index.tsx
+++ b/apps/web/src/components/user/dashboard/index.tsx
@@ -1,5 +1,5 @@
import Image from 'next/image';
-import type { User } from '@repo/db';
+import type { User } from '@repo/db/types';
import Link from 'next/link';
import { getServerAuthSession } from '@repo/auth/server';
import { ReactMarkdown } from 'react-markdown/lib/react-markdown';
diff --git a/apps/web/src/components/user/dashboard/user-header.tsx b/apps/web/src/components/user/dashboard/user-header.tsx
index c54dccd0..d086998c 100644
--- a/apps/web/src/components/user/dashboard/user-header.tsx
+++ b/apps/web/src/components/user/dashboard/user-header.tsx
@@ -1,6 +1,6 @@
'use client';
-import { type User } from '@repo/db';
+import { type User } from '@repo/db/types';
import { Flag } from 'lucide-react';
import Text from '~/components/ui/typography/typography';
import ReportDialog from '~/components/report';
diff --git a/packages/auth/src/react.ts b/packages/auth/src/react.ts
index 95ba4e9f..e7aa4cfe 100644
--- a/packages/auth/src/react.ts
+++ b/packages/auth/src/react.ts
@@ -1,5 +1,5 @@
import type { DefaultSession } from 'next-auth';
-import type { RoleTypes } from '@repo/db/*';
+import type { RoleTypes } from '@repo/db/types';
import type { SessionContextValue } from 'next-auth/react';
import { useSession as useAuthSession } from 'next-auth/react';
diff --git a/packages/auth/src/server.ts b/packages/auth/src/server.ts
index 1bfc4981..e4819275 100644
--- a/packages/auth/src/server.ts
+++ b/packages/auth/src/server.ts
@@ -1,5 +1,5 @@
import { PrismaAdapter } from '@next-auth/prisma-adapter';
-import type { Role, RoleTypes } from '@repo/db';
+import type { Role, RoleTypes } from '@repo/db/types';
import { getServerSession, type DefaultSession, type NextAuthOptions } from 'next-auth';
import GitHubProvider from 'next-auth/providers/github';
import { prisma } from '@repo/db';
@@ -96,8 +96,8 @@ export const authOptions: NextAuthOptions = {
adapter: PrismaAdapter(prisma),
providers: [
GitHubProvider({
- clientId: process.env.GITHUB_ID,
- clientSecret: process.env.GITHUB_SECRET,
+ clientId: process.env.GITHUB_ID!,
+ clientSecret: process.env.GITHUB_SECRET!,
}),
],
};
diff --git a/packages/db/package.json b/packages/db/package.json
index 4dd9cac4..4f43c35f 100644
--- a/packages/db/package.json
+++ b/packages/db/package.json
@@ -4,12 +4,16 @@
"private": true,
"type": "module",
"exports": {
- ".": "./src/index.ts"
+ ".": "./src/index.ts",
+ "./types": "./src/types.ts"
},
"typesVersions": {
"*": {
"*": [
"./src/index.ts"
+ ],
+ "types": [
+ "./src/types.ts"
]
}
},
diff --git a/packages/db/src/index.ts b/packages/db/src/index.ts
index b9bf5022..33c4c2b7 100644
--- a/packages/db/src/index.ts
+++ b/packages/db/src/index.ts
@@ -11,5 +11,3 @@ export const prisma =
});
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma;
-
-export * from '@prisma/client';
diff --git a/packages/db/src/types.ts b/packages/db/src/types.ts
new file mode 100644
index 00000000..b329db54
--- /dev/null
+++ b/packages/db/src/types.ts
@@ -0,0 +1 @@
+export * from '@prisma/client';