From b077cf3ac058ff5fa7e29d537a36bc18099170d1 Mon Sep 17 00:00:00 2001 From: hanpuliu-charles <26217378+hanpuliu-charles@users.noreply.github.com> Date: Fri, 14 Jun 2024 15:41:10 +0800 Subject: [PATCH] ISOM-1147: feat: read folder dto (#154) * added read folder dto * Made explicit that the endpoint can read both folder and top level folder content * Fix typo --- apps/studio/src/schemas/folder.ts | 7 +++++++ .../src/server/modules/folder/folder.router.ts | 17 +++++++++++++++++ package-lock.json | 3 +++ 3 files changed, 27 insertions(+) create mode 100644 apps/studio/src/schemas/folder.ts create mode 100644 apps/studio/src/server/modules/folder/folder.router.ts diff --git a/apps/studio/src/schemas/folder.ts b/apps/studio/src/schemas/folder.ts new file mode 100644 index 0000000000..8243e72f9a --- /dev/null +++ b/apps/studio/src/schemas/folder.ts @@ -0,0 +1,7 @@ +import { z } from 'zod' + +export const readFolderOrTopLevelFolderSchema = z.object({ + // Null resourceId indicates reading of top level folder in a site. + siteId: z.string(), + resourceId: z.string().nullable() +}) \ No newline at end of file diff --git a/apps/studio/src/server/modules/folder/folder.router.ts b/apps/studio/src/server/modules/folder/folder.router.ts new file mode 100644 index 0000000000..182bfa3940 --- /dev/null +++ b/apps/studio/src/server/modules/folder/folder.router.ts @@ -0,0 +1,17 @@ +import { readFolderOrTopLevelFolderSchema } from "~/schemas/folder"; +import { protectedProcedure, router } from '~/server/trpc' + + +export const folderRouter = router({ + readFolderOrTopLevelFolder: protectedProcedure.input(readFolderOrTopLevelFolderSchema).query(async ({ input, ctx }) => { + // TODO: Fill these in later + const folderName: string = "" + const children: {id: string, name: string, type: 'page' | 'folder'}[] = [] + // Not sure if a backpointer is needed here + const parentId: string = "" + return { + folderName, children, parentId + } + }) + +}) \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index c09655f614..e59fd4dc49 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,9 @@ "apps/*", "packages/*" ], + "dependencies": { + "zod": "^3.23.8" + }, "devDependencies": { "turbo": "^1.13.3" }