From deba31ee010f785a9739fd4df8a64a3056c9593d Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Thu, 18 Apr 2024 10:01:45 +0100 Subject: [PATCH] refactor: Move the shared types to the shared package --- apps/cli/commands/bookmarks.ts | 2 +- apps/cli/package.json | 1 + apps/mobile/app/sharing.tsx | 2 +- apps/mobile/components/bookmarks/BookmarkCard.tsx | 2 +- apps/mobile/components/bookmarks/BookmarkList.tsx | 2 +- .../components/bookmarks/UpdatingBookmarkList.tsx | 2 +- apps/mobile/lib/upload.ts | 4 ++-- apps/mobile/package.json | 1 + apps/web/app/api/assets/route.ts | 2 +- apps/web/components/dashboard/UploadDropzone.tsx | 2 +- .../components/dashboard/bookmarks/AssetCard.tsx | 2 +- .../dashboard/bookmarks/BookmarkActionBar.tsx | 2 +- .../bookmarks/BookmarkLayoutAdaptingCard.tsx | 2 +- .../dashboard/bookmarks/BookmarkOptions.tsx | 5 ++++- .../dashboard/bookmarks/BookmarkedTextEditor.tsx | 2 +- .../components/dashboard/bookmarks/Bookmarks.tsx | 2 +- .../dashboard/bookmarks/BookmarksGrid.tsx | 2 +- .../components/dashboard/bookmarks/LinkCard.tsx | 2 +- .../components/dashboard/bookmarks/TagList.tsx | 2 +- .../components/dashboard/bookmarks/TagModal.tsx | 2 +- .../components/dashboard/bookmarks/TagsEditor.tsx | 4 ++-- .../components/dashboard/bookmarks/TextCard.tsx | 2 +- .../bookmarks/UpdatableBookmarksGrid.tsx | 2 +- .../components/dashboard/lists/AllListsView.tsx | 2 +- .../dashboard/lists/DeleteListButton.tsx | 2 +- .../components/dashboard/preview/ActionBar.tsx | 2 +- .../dashboard/preview/AssetContentSection.tsx | 2 +- .../dashboard/preview/BookmarkPreview.tsx | 2 +- .../dashboard/preview/EditableTitle.tsx | 2 +- .../components/dashboard/preview/NoteEditor.tsx | 2 +- .../dashboard/preview/TextContentSection.tsx | 2 +- .../dashboard/settings/ChangePassword.tsx | 2 +- .../web/components/dashboard/sidebar/AllLists.tsx | 2 +- .../web/components/dashboard/tags/AllTagsView.tsx | 2 +- apps/web/components/signin/CredentialsForm.tsx | 2 +- apps/web/lib/bookmarkUtils.tsx | 2 +- .../shared-react/hooks/bookmark-grid-context.tsx | 2 +- packages/shared-react/package.json | 1 + packages/{trpc => shared}/types/bookmarks.ts | 0 packages/{trpc => shared}/types/lists.ts | 1 + packages/{trpc => shared}/types/tags.ts | 0 packages/{trpc => shared}/types/uploads.ts | 0 packages/{trpc => shared}/types/users.ts | 0 packages/trpc/routers/bookmarks.ts | 15 +++++++++------ packages/trpc/routers/lists.ts | 2 +- packages/trpc/routers/tags.ts | 4 ++-- packages/trpc/routers/users.ts | 2 +- pnpm-lock.yaml | 9 +++++++++ 48 files changed, 66 insertions(+), 47 deletions(-) rename packages/{trpc => shared}/types/bookmarks.ts (100%) rename packages/{trpc => shared}/types/lists.ts (92%) rename packages/{trpc => shared}/types/tags.ts (100%) rename packages/{trpc => shared}/types/uploads.ts (100%) rename packages/{trpc => shared}/types/users.ts (100%) diff --git a/apps/cli/commands/bookmarks.ts b/apps/cli/commands/bookmarks.ts index 1727db22..55c87b05 100644 --- a/apps/cli/commands/bookmarks.ts +++ b/apps/cli/commands/bookmarks.ts @@ -3,7 +3,7 @@ import { Command } from "@commander-js/extra-typings"; import chalk from "chalk"; import { getAPIClient } from "lib/trpc"; -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; export const bookmarkCmd = new Command() .name("bookmarks") diff --git a/apps/cli/package.json b/apps/cli/package.json index 44f7e451..05ab0d0f 100644 --- a/apps/cli/package.json +++ b/apps/cli/package.json @@ -6,6 +6,7 @@ "dependencies": { "@commander-js/extra-typings": "^12.0.1", "@hoarder/trpc": "workspace:^0.1.0", + "@hoarder/shared": "workspace:^0.1.0", "@hoarder/tsconfig": "workspace:^0.1.0", "@tsconfig/node21": "^21.0.1", "tsx": "^4.7.1", diff --git a/apps/mobile/app/sharing.tsx b/apps/mobile/app/sharing.tsx index bbeaeeee..7624474a 100644 --- a/apps/mobile/app/sharing.tsx +++ b/apps/mobile/app/sharing.tsx @@ -7,7 +7,7 @@ import { api } from "@/lib/trpc"; import { useUploadAsset } from "@/lib/upload"; import { z } from "zod"; -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; type Mode = | { type: "idle" } diff --git a/apps/mobile/components/bookmarks/BookmarkCard.tsx b/apps/mobile/components/bookmarks/BookmarkCard.tsx index 9e5febe3..6662e76a 100644 --- a/apps/mobile/components/bookmarks/BookmarkCard.tsx +++ b/apps/mobile/components/bookmarks/BookmarkCard.tsx @@ -16,7 +16,7 @@ import { api } from "@/lib/trpc"; import { MenuView } from "@react-native-menu/menu"; import { Ellipsis, Star } from "lucide-react-native"; -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; import { useDeleteBookmark, useUpdateBookmark, diff --git a/apps/mobile/components/bookmarks/BookmarkList.tsx b/apps/mobile/components/bookmarks/BookmarkList.tsx index 3ad23072..f24143a7 100644 --- a/apps/mobile/components/bookmarks/BookmarkList.tsx +++ b/apps/mobile/components/bookmarks/BookmarkList.tsx @@ -3,7 +3,7 @@ import { ActivityIndicator, Keyboard, Text, View } from "react-native"; import Animated, { LinearTransition } from "react-native-reanimated"; import { useScrollToTop } from "@react-navigation/native"; -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; import BookmarkCard from "./BookmarkCard"; diff --git a/apps/mobile/components/bookmarks/UpdatingBookmarkList.tsx b/apps/mobile/components/bookmarks/UpdatingBookmarkList.tsx index efc0d5e7..33ddf5ff 100644 --- a/apps/mobile/components/bookmarks/UpdatingBookmarkList.tsx +++ b/apps/mobile/components/bookmarks/UpdatingBookmarkList.tsx @@ -1,7 +1,7 @@ import { Text } from "react-native"; import { api } from "@/lib/trpc"; -import type { ZGetBookmarksRequest } from "@hoarder/trpc/types/bookmarks"; +import type { ZGetBookmarksRequest } from "@hoarder/shared/types/bookmarks"; import FullPageSpinner from "../ui/FullPageSpinner"; import BookmarkList from "./BookmarkList"; diff --git a/apps/mobile/lib/upload.ts b/apps/mobile/lib/upload.ts index f9d05967..9eb40e01 100644 --- a/apps/mobile/lib/upload.ts +++ b/apps/mobile/lib/upload.ts @@ -1,10 +1,10 @@ import { useMutation } from "@tanstack/react-query"; -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; import { zUploadErrorSchema, zUploadResponseSchema, -} from "@hoarder/trpc/types/uploads"; +} from "@hoarder/shared/types/uploads"; import type { Settings } from "./settings"; import { api } from "./trpc"; diff --git a/apps/mobile/package.json b/apps/mobile/package.json index 248f1f53..ef19bfbf 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -14,6 +14,7 @@ }, "dependencies": { "@hoarder/trpc": "workspace:^0.1.0", + "@hoarder/shared": "workspace:^0.1.0", "@hoarder/shared-react": "workspace:^0.1.0", "@react-native-menu/menu": "^0.9.1", "@tanstack/react-query": "^5.24.8", diff --git a/apps/web/app/api/assets/route.ts b/apps/web/app/api/assets/route.ts index 5b72033a..c77751d3 100644 --- a/apps/web/app/api/assets/route.ts +++ b/apps/web/app/api/assets/route.ts @@ -1,7 +1,7 @@ import { createContextFromRequest } from "@/server/api/client"; import { TRPCError } from "@trpc/server"; -import type { ZUploadResponse } from "@hoarder/trpc/types/uploads"; +import type { ZUploadResponse } from "@hoarder/shared/types/uploads"; import { saveAsset } from "@hoarder/shared/assetdb"; import serverConfig from "@hoarder/shared/config"; diff --git a/apps/web/components/dashboard/UploadDropzone.tsx b/apps/web/components/dashboard/UploadDropzone.tsx index f6243885..be30a77f 100644 --- a/apps/web/components/dashboard/UploadDropzone.tsx +++ b/apps/web/components/dashboard/UploadDropzone.tsx @@ -10,7 +10,7 @@ import { useCreateBookmarkWithPostHook } from "@hoarder/shared-react/hooks/bookm import { zUploadErrorSchema, zUploadResponseSchema, -} from "@hoarder/trpc/types/uploads"; +} from "@hoarder/shared/types/uploads"; import LoadingSpinner from "../ui/spinner"; import { toast } from "../ui/use-toast"; diff --git a/apps/web/components/dashboard/bookmarks/AssetCard.tsx b/apps/web/components/dashboard/bookmarks/AssetCard.tsx index ea0317aa..c9a43575 100644 --- a/apps/web/components/dashboard/bookmarks/AssetCard.tsx +++ b/apps/web/components/dashboard/bookmarks/AssetCard.tsx @@ -7,7 +7,7 @@ import { api } from "@/lib/trpc"; import type { ZBookmark, ZBookmarkTypeAsset, -} from "@hoarder/trpc/types/bookmarks"; +} from "@hoarder/shared/types/bookmarks"; import { BookmarkLayoutAdaptingCard } from "./BookmarkLayoutAdaptingCard"; diff --git a/apps/web/components/dashboard/bookmarks/BookmarkActionBar.tsx b/apps/web/components/dashboard/bookmarks/BookmarkActionBar.tsx index 420fed84..d4e8dfca 100644 --- a/apps/web/components/dashboard/bookmarks/BookmarkActionBar.tsx +++ b/apps/web/components/dashboard/bookmarks/BookmarkActionBar.tsx @@ -3,7 +3,7 @@ import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog"; import { Maximize2 } from "lucide-react"; -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; import BookmarkOptions from "./BookmarkOptions"; import { FavouritedActionIcon } from "./icons"; diff --git a/apps/web/components/dashboard/bookmarks/BookmarkLayoutAdaptingCard.tsx b/apps/web/components/dashboard/bookmarks/BookmarkLayoutAdaptingCard.tsx index 3d7b93f3..42c4db21 100644 --- a/apps/web/components/dashboard/bookmarks/BookmarkLayoutAdaptingCard.tsx +++ b/apps/web/components/dashboard/bookmarks/BookmarkLayoutAdaptingCard.tsx @@ -9,7 +9,7 @@ import { import { cn } from "@/lib/utils"; import dayjs from "dayjs"; -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; import BookmarkActionBar from "./BookmarkActionBar"; import TagList from "./TagList"; diff --git a/apps/web/components/dashboard/bookmarks/BookmarkOptions.tsx b/apps/web/components/dashboard/bookmarks/BookmarkOptions.tsx index a8ec1ab5..6f07107b 100644 --- a/apps/web/components/dashboard/bookmarks/BookmarkOptions.tsx +++ b/apps/web/components/dashboard/bookmarks/BookmarkOptions.tsx @@ -21,7 +21,10 @@ import { Trash2, } from "lucide-react"; -import type { ZBookmark, ZBookmarkedLink } from "@hoarder/trpc/types/bookmarks"; +import type { + ZBookmark, + ZBookmarkedLink, +} from "@hoarder/shared/types/bookmarks"; import { useDeleteBookmark, useRecrawlBookmark, diff --git a/apps/web/components/dashboard/bookmarks/BookmarkedTextEditor.tsx b/apps/web/components/dashboard/bookmarks/BookmarkedTextEditor.tsx index 294f2b5a..db69e1a3 100644 --- a/apps/web/components/dashboard/bookmarks/BookmarkedTextEditor.tsx +++ b/apps/web/components/dashboard/bookmarks/BookmarkedTextEditor.tsx @@ -14,7 +14,7 @@ import { Textarea } from "@/components/ui/textarea"; import { toast } from "@/components/ui/use-toast"; import { api } from "@/lib/trpc"; -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; export function BookmarkedTextEditor({ bookmark, diff --git a/apps/web/components/dashboard/bookmarks/Bookmarks.tsx b/apps/web/components/dashboard/bookmarks/Bookmarks.tsx index 8aa723e9..6a9266b9 100644 --- a/apps/web/components/dashboard/bookmarks/Bookmarks.tsx +++ b/apps/web/components/dashboard/bookmarks/Bookmarks.tsx @@ -3,7 +3,7 @@ import { Separator } from "@/components/ui/separator"; import { api } from "@/server/api/client"; import { getServerAuthSession } from "@/server/auth"; -import type { ZGetBookmarksRequest } from "@hoarder/trpc/types/bookmarks"; +import type { ZGetBookmarksRequest } from "@hoarder/shared/types/bookmarks"; import UpdatableBookmarksGrid from "./UpdatableBookmarksGrid"; diff --git a/apps/web/components/dashboard/bookmarks/BookmarksGrid.tsx b/apps/web/components/dashboard/bookmarks/BookmarksGrid.tsx index 01f18815..b44dea33 100644 --- a/apps/web/components/dashboard/bookmarks/BookmarksGrid.tsx +++ b/apps/web/components/dashboard/bookmarks/BookmarksGrid.tsx @@ -9,7 +9,7 @@ import { Slot } from "@radix-ui/react-slot"; import Masonry from "react-masonry-css"; import resolveConfig from "tailwindcss/resolveConfig"; -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; import AssetCard from "./AssetCard"; import EditorCard from "./EditorCard"; diff --git a/apps/web/components/dashboard/bookmarks/LinkCard.tsx b/apps/web/components/dashboard/bookmarks/LinkCard.tsx index 6d51695d..ef0ae6f2 100644 --- a/apps/web/components/dashboard/bookmarks/LinkCard.tsx +++ b/apps/web/components/dashboard/bookmarks/LinkCard.tsx @@ -7,7 +7,7 @@ import { } from "@/lib/bookmarkUtils"; import { api } from "@/lib/trpc"; -import type { ZBookmarkTypeLink } from "@hoarder/trpc/types/bookmarks"; +import type { ZBookmarkTypeLink } from "@hoarder/shared/types/bookmarks"; import { BookmarkLayoutAdaptingCard } from "./BookmarkLayoutAdaptingCard"; diff --git a/apps/web/components/dashboard/bookmarks/TagList.tsx b/apps/web/components/dashboard/bookmarks/TagList.tsx index e0387bd2..ff63d110 100644 --- a/apps/web/components/dashboard/bookmarks/TagList.tsx +++ b/apps/web/components/dashboard/bookmarks/TagList.tsx @@ -3,7 +3,7 @@ import { badgeVariants } from "@/components/ui/badge"; import { Skeleton } from "@/components/ui/skeleton"; import { cn } from "@/lib/utils"; -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; export default function TagList({ bookmark, diff --git a/apps/web/components/dashboard/bookmarks/TagModal.tsx b/apps/web/components/dashboard/bookmarks/TagModal.tsx index 6bc16a89..00cc40fc 100644 --- a/apps/web/components/dashboard/bookmarks/TagModal.tsx +++ b/apps/web/components/dashboard/bookmarks/TagModal.tsx @@ -9,7 +9,7 @@ import { DialogTitle, } from "@/components/ui/dialog"; -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; import { TagsEditor } from "./TagsEditor"; diff --git a/apps/web/components/dashboard/bookmarks/TagsEditor.tsx b/apps/web/components/dashboard/bookmarks/TagsEditor.tsx index ab7dd754..ec1c3bfa 100644 --- a/apps/web/components/dashboard/bookmarks/TagsEditor.tsx +++ b/apps/web/components/dashboard/bookmarks/TagsEditor.tsx @@ -6,8 +6,8 @@ import { cn } from "@/lib/utils"; import { Sparkles } from "lucide-react"; import CreateableSelect from "react-select/creatable"; -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; -import type { ZAttachedByEnum } from "@hoarder/trpc/types/tags"; +import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; +import type { ZAttachedByEnum } from "@hoarder/shared/types/tags"; import { useUpdateBookmarkTags } from "@hoarder/shared-react/hooks/bookmarks"; interface EditableTag { diff --git a/apps/web/components/dashboard/bookmarks/TextCard.tsx b/apps/web/components/dashboard/bookmarks/TextCard.tsx index e24108d2..9d5c8d8b 100644 --- a/apps/web/components/dashboard/bookmarks/TextCard.tsx +++ b/apps/web/components/dashboard/bookmarks/TextCard.tsx @@ -7,7 +7,7 @@ import { bookmarkLayoutSwitch } from "@/lib/userLocalSettings/bookmarksLayout"; import { cn } from "@/lib/utils"; import Markdown from "react-markdown"; -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; import { BookmarkedTextViewer } from "./BookmarkedTextViewer"; import { BookmarkLayoutAdaptingCard } from "./BookmarkLayoutAdaptingCard"; diff --git a/apps/web/components/dashboard/bookmarks/UpdatableBookmarksGrid.tsx b/apps/web/components/dashboard/bookmarks/UpdatableBookmarksGrid.tsx index fe69201c..53524490 100644 --- a/apps/web/components/dashboard/bookmarks/UpdatableBookmarksGrid.tsx +++ b/apps/web/components/dashboard/bookmarks/UpdatableBookmarksGrid.tsx @@ -6,7 +6,7 @@ import { api } from "@/lib/trpc"; import type { ZGetBookmarksRequest, ZGetBookmarksResponse, -} from "@hoarder/trpc/types/bookmarks"; +} from "@hoarder/shared/types/bookmarks"; import { BookmarkGridContextProvider } from "@hoarder/shared-react/hooks/bookmark-grid-context"; import BookmarksGrid from "./BookmarksGrid"; diff --git a/apps/web/components/dashboard/lists/AllListsView.tsx b/apps/web/components/dashboard/lists/AllListsView.tsx index 4159bc14..00e76a23 100644 --- a/apps/web/components/dashboard/lists/AllListsView.tsx +++ b/apps/web/components/dashboard/lists/AllListsView.tsx @@ -7,7 +7,7 @@ import { api } from "@/lib/trpc"; import { keepPreviousData } from "@tanstack/react-query"; import { Plus } from "lucide-react"; -import type { ZBookmarkList } from "@hoarder/trpc/types/lists"; +import type { ZBookmarkList } from "@hoarder/shared/types/lists"; function ListItem({ name, diff --git a/apps/web/components/dashboard/lists/DeleteListButton.tsx b/apps/web/components/dashboard/lists/DeleteListButton.tsx index ee2a9ec7..774b79ac 100644 --- a/apps/web/components/dashboard/lists/DeleteListButton.tsx +++ b/apps/web/components/dashboard/lists/DeleteListButton.tsx @@ -8,7 +8,7 @@ import { toast } from "@/components/ui/use-toast"; import { api } from "@/lib/trpc"; import { Trash2 } from "lucide-react"; -import type { ZBookmarkList } from "@hoarder/trpc/types/lists"; +import type { ZBookmarkList } from "@hoarder/shared/types/lists"; export default function DeleteListButton({ list }: { list: ZBookmarkList }) { const router = useRouter(); diff --git a/apps/web/components/dashboard/preview/ActionBar.tsx b/apps/web/components/dashboard/preview/ActionBar.tsx index d2048cad..ec659e35 100644 --- a/apps/web/components/dashboard/preview/ActionBar.tsx +++ b/apps/web/components/dashboard/preview/ActionBar.tsx @@ -7,7 +7,7 @@ import { import { toast } from "@/components/ui/use-toast"; import { Trash2 } from "lucide-react"; -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; import { useDeleteBookmark, useUpdateBookmark, diff --git a/apps/web/components/dashboard/preview/AssetContentSection.tsx b/apps/web/components/dashboard/preview/AssetContentSection.tsx index 4a025f9d..94bd16ce 100644 --- a/apps/web/components/dashboard/preview/AssetContentSection.tsx +++ b/apps/web/components/dashboard/preview/AssetContentSection.tsx @@ -1,6 +1,6 @@ import Image from "next/image"; -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; export function AssetContentSection({ bookmark }: { bookmark: ZBookmark }) { if (bookmark.content.type != "asset") { diff --git a/apps/web/components/dashboard/preview/BookmarkPreview.tsx b/apps/web/components/dashboard/preview/BookmarkPreview.tsx index 93f14c64..29e8e39a 100644 --- a/apps/web/components/dashboard/preview/BookmarkPreview.tsx +++ b/apps/web/components/dashboard/preview/BookmarkPreview.tsx @@ -20,7 +20,7 @@ import dayjs from "dayjs"; import relativeTime from "dayjs/plugin/relativeTime"; import { CalendarDays, ExternalLink } from "lucide-react"; -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; import ActionBar from "./ActionBar"; import { AssetContentSection } from "./AssetContentSection"; diff --git a/apps/web/components/dashboard/preview/EditableTitle.tsx b/apps/web/components/dashboard/preview/EditableTitle.tsx index 1500212d..071b3ca3 100644 --- a/apps/web/components/dashboard/preview/EditableTitle.tsx +++ b/apps/web/components/dashboard/preview/EditableTitle.tsx @@ -11,7 +11,7 @@ import { toast } from "@/components/ui/use-toast"; import { Check, Pencil, X } from "lucide-react"; import { useUpdateBookmark } from "@hoarder/shared-react/hooks/bookmarks"; -import { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import { ZBookmark } from "@hoarder/shared/types/bookmarks"; interface Props { bookmarkId: string; diff --git a/apps/web/components/dashboard/preview/NoteEditor.tsx b/apps/web/components/dashboard/preview/NoteEditor.tsx index 6011e89d..67da40cc 100644 --- a/apps/web/components/dashboard/preview/NoteEditor.tsx +++ b/apps/web/components/dashboard/preview/NoteEditor.tsx @@ -2,7 +2,7 @@ import { Textarea } from "@/components/ui/textarea"; import { toast } from "@/components/ui/use-toast"; import { useClientConfig } from "@/lib/clientConfig"; -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; import { useUpdateBookmark } from "@hoarder/shared-react/hooks/bookmarks"; export function NoteEditor({ bookmark }: { bookmark: ZBookmark }) { diff --git a/apps/web/components/dashboard/preview/TextContentSection.tsx b/apps/web/components/dashboard/preview/TextContentSection.tsx index 35ee1b33..a73ad722 100644 --- a/apps/web/components/dashboard/preview/TextContentSection.tsx +++ b/apps/web/components/dashboard/preview/TextContentSection.tsx @@ -1,7 +1,7 @@ import { ScrollArea } from "@radix-ui/react-scroll-area"; import Markdown from "react-markdown"; -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; export function TextContentSection({ bookmark }: { bookmark: ZBookmark }) { let content; diff --git a/apps/web/components/dashboard/settings/ChangePassword.tsx b/apps/web/components/dashboard/settings/ChangePassword.tsx index 5d9324e6..070caee8 100644 --- a/apps/web/components/dashboard/settings/ChangePassword.tsx +++ b/apps/web/components/dashboard/settings/ChangePassword.tsx @@ -17,7 +17,7 @@ import { api } from "@/lib/trpc"; import { zodResolver } from "@hookform/resolvers/zod"; import { useForm } from "react-hook-form"; -import { zChangePasswordSchema } from "@hoarder/trpc/types/users"; +import { zChangePasswordSchema } from "@hoarder/shared/types/users"; export function ChangePassword() { const form = useForm>({ diff --git a/apps/web/components/dashboard/sidebar/AllLists.tsx b/apps/web/components/dashboard/sidebar/AllLists.tsx index 2b38ed46..6ab42851 100644 --- a/apps/web/components/dashboard/sidebar/AllLists.tsx +++ b/apps/web/components/dashboard/sidebar/AllLists.tsx @@ -4,7 +4,7 @@ import Link from "next/link"; import { api } from "@/lib/trpc"; import { Plus } from "lucide-react"; -import type { ZBookmarkList } from "@hoarder/trpc/types/lists"; +import type { ZBookmarkList } from "@hoarder/shared/types/lists"; import NewListModal, { useNewListModal } from "./NewListModal"; import SidebarItem from "./SidebarItem"; diff --git a/apps/web/components/dashboard/tags/AllTagsView.tsx b/apps/web/components/dashboard/tags/AllTagsView.tsx index 0f9ee823..73bfb7e6 100644 --- a/apps/web/components/dashboard/tags/AllTagsView.tsx +++ b/apps/web/components/dashboard/tags/AllTagsView.tsx @@ -5,7 +5,7 @@ import InfoTooltip from "@/components/ui/info-tooltip"; import { Separator } from "@/components/ui/separator"; import { api } from "@/lib/trpc"; -import type { ZGetTagResponse } from "@hoarder/trpc/types/tags"; +import type { ZGetTagResponse } from "@hoarder/shared/types/tags"; function TagPill({ name, count }: { name: string; count: number }) { return ( diff --git a/apps/web/components/signin/CredentialsForm.tsx b/apps/web/components/signin/CredentialsForm.tsx index 8d7136cb..07e08fae 100644 --- a/apps/web/components/signin/CredentialsForm.tsx +++ b/apps/web/components/signin/CredentialsForm.tsx @@ -21,7 +21,7 @@ import { signIn } from "next-auth/react"; import { useForm } from "react-hook-form"; import { z } from "zod"; -import { zSignUpSchema } from "@hoarder/trpc/types/users"; +import { zSignUpSchema } from "@hoarder/shared/types/users"; const signInSchema = z.object({ email: z.string().email(), diff --git a/apps/web/lib/bookmarkUtils.tsx b/apps/web/lib/bookmarkUtils.tsx index fbb7c7df..475ba383 100644 --- a/apps/web/lib/bookmarkUtils.tsx +++ b/apps/web/lib/bookmarkUtils.tsx @@ -1,4 +1,4 @@ -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; const MAX_LOADING_MSEC = 30 * 1000; diff --git a/packages/shared-react/hooks/bookmark-grid-context.tsx b/packages/shared-react/hooks/bookmark-grid-context.tsx index 5814da12..7d71d28c 100644 --- a/packages/shared-react/hooks/bookmark-grid-context.tsx +++ b/packages/shared-react/hooks/bookmark-grid-context.tsx @@ -2,7 +2,7 @@ import { createContext, useContext } from "react"; -import type { ZGetBookmarksRequest } from "@hoarder/trpc/types/bookmarks"; +import type { ZGetBookmarksRequest } from "@hoarder/shared/types/bookmarks"; export const BookmarkGridContext = createContext< ZGetBookmarksRequest | undefined diff --git a/packages/shared-react/package.json b/packages/shared-react/package.json index 5e0a1d23..1c8f4a51 100644 --- a/packages/shared-react/package.json +++ b/packages/shared-react/package.json @@ -5,6 +5,7 @@ "private": true, "dependencies": { "@hoarder/trpc": "workspace:^0.1.0", + "@hoarder/shared": "workspace:^0.1.0", "@tanstack/react-query": "^5.24.8", "superjson": "^2.2.1", "@trpc/client": "11.0.0-next-beta.308" diff --git a/packages/trpc/types/bookmarks.ts b/packages/shared/types/bookmarks.ts similarity index 100% rename from packages/trpc/types/bookmarks.ts rename to packages/shared/types/bookmarks.ts diff --git a/packages/trpc/types/lists.ts b/packages/shared/types/lists.ts similarity index 92% rename from packages/trpc/types/lists.ts rename to packages/shared/types/lists.ts index 4b0ccaca..e9d7eca0 100644 --- a/packages/trpc/types/lists.ts +++ b/packages/shared/types/lists.ts @@ -4,6 +4,7 @@ export const zBookmarkListSchema = z.object({ id: z.string(), name: z.string(), icon: z.string(), + parentId: z.string().nullable(), }); export const zBookmarkListWithBookmarksSchema = zBookmarkListSchema.merge( diff --git a/packages/trpc/types/tags.ts b/packages/shared/types/tags.ts similarity index 100% rename from packages/trpc/types/tags.ts rename to packages/shared/types/tags.ts diff --git a/packages/trpc/types/uploads.ts b/packages/shared/types/uploads.ts similarity index 100% rename from packages/trpc/types/uploads.ts rename to packages/shared/types/uploads.ts diff --git a/packages/trpc/types/users.ts b/packages/shared/types/users.ts similarity index 100% rename from packages/trpc/types/users.ts rename to packages/shared/types/users.ts diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.ts index a447235b..0383d3f2 100644 --- a/packages/trpc/routers/bookmarks.ts +++ b/packages/trpc/routers/bookmarks.ts @@ -3,6 +3,11 @@ import { and, desc, eq, exists, inArray, lte, or } from "drizzle-orm"; import invariant from "tiny-invariant"; import { z } from "zod"; +import type { + ZBookmark, + ZBookmarkContent, +} from "@hoarder/shared/types/bookmarks"; +import type { ZBookmarkTags } from "@hoarder/shared/types/tags"; import { db as DONT_USE_db } from "@hoarder/db"; import { bookmarkAssets, @@ -20,11 +25,6 @@ import { SearchIndexingQueue, } from "@hoarder/shared/queues"; import { getSearchIdxClient } from "@hoarder/shared/search"; - -import type { Context } from "../index"; -import type { ZBookmark, ZBookmarkContent } from "../types/bookmarks"; -import type { ZBookmarkTags } from "../types/tags"; -import { authedProcedure, router } from "../index"; import { DEFAULT_NUM_BOOKMARKS_PER_PAGE, zBareBookmarkSchema, @@ -33,7 +33,10 @@ import { zGetBookmarksResponseSchema, zNewBookmarkRequestSchema, zUpdateBookmarksRequestSchema, -} from "../types/bookmarks"; +} from "@hoarder/shared/types/bookmarks"; + +import type { Context } from "../index"; +import { authedProcedure, router } from "../index"; export const ensureBookmarkOwnership = experimental_trpcMiddleware<{ ctx: Context; diff --git a/packages/trpc/routers/lists.ts b/packages/trpc/routers/lists.ts index fb6d8637..74b4f737 100644 --- a/packages/trpc/routers/lists.ts +++ b/packages/trpc/routers/lists.ts @@ -4,10 +4,10 @@ import { z } from "zod"; import { SqliteError } from "@hoarder/db"; import { bookmarkLists, bookmarksInLists } from "@hoarder/db/schema"; +import { zBookmarkListSchema } from "@hoarder/shared/types/lists"; import type { Context } from "../index"; import { authedProcedure, router } from "../index"; -import { zBookmarkListSchema } from "../types/lists"; import { ensureBookmarkOwnership } from "./bookmarks"; export const ensureListOwnership = experimental_trpcMiddleware<{ diff --git a/packages/trpc/routers/tags.ts b/packages/trpc/routers/tags.ts index 53b72a23..ed4ac7d2 100644 --- a/packages/trpc/routers/tags.ts +++ b/packages/trpc/routers/tags.ts @@ -2,12 +2,12 @@ import { experimental_trpcMiddleware, TRPCError } from "@trpc/server"; import { and, count, eq } from "drizzle-orm"; import { z } from "zod"; +import type { ZAttachedByEnum } from "@hoarder/shared/types/tags"; import { bookmarkTags, tagsOnBookmarks } from "@hoarder/db/schema"; +import { zGetTagResponseSchema } from "@hoarder/shared/types/tags"; import type { Context } from "../index"; -import type { ZAttachedByEnum } from "../types/tags"; import { authedProcedure, router } from "../index"; -import { zGetTagResponseSchema } from "../types/tags"; function conditionFromInput( input: { tagName: string } | { tagId: string }, diff --git a/packages/trpc/routers/users.ts b/packages/trpc/routers/users.ts index e7f0a59d..51f9429e 100644 --- a/packages/trpc/routers/users.ts +++ b/packages/trpc/routers/users.ts @@ -7,6 +7,7 @@ import { SqliteError } from "@hoarder/db"; import { users } from "@hoarder/db/schema"; import { deleteUserAssets } from "@hoarder/shared/assetdb"; import serverConfig from "@hoarder/shared/config"; +import { zSignUpSchema } from "@hoarder/shared/types/users"; import { hashPassword, validatePassword } from "../auth"; import { @@ -15,7 +16,6 @@ import { publicProcedure, router, } from "../index"; -import { zSignUpSchema } from "../types/users"; export const usersAppRouter = router({ create: publicProcedure diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 49d2edde..d5c4915c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -143,6 +143,9 @@ importers: '@commander-js/extra-typings': specifier: ^12.0.1 version: 12.0.1(commander@12.0.0) + '@hoarder/shared': + specifier: workspace:^0.1.0 + version: link:../../packages/shared '@hoarder/trpc': specifier: workspace:^0.1.0 version: link:../../packages/trpc @@ -250,6 +253,9 @@ importers: apps/mobile: dependencies: + '@hoarder/shared': + specifier: workspace:^0.1.0 + version: link:../../packages/shared '@hoarder/shared-react': specifier: workspace:^0.1.0 version: link:../../packages/shared-react @@ -796,6 +802,9 @@ importers: packages/shared-react: dependencies: + '@hoarder/shared': + specifier: workspace:^0.1.0 + version: link:../shared '@hoarder/trpc': specifier: workspace:^0.1.0 version: link:../trpc