mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-16 06:58:46 +00:00
/api/category/[id], /api/category/create Endpoint 구현
This commit is contained in:
28
src/lib/server/schemas/category.ts
Normal file
28
src/lib/server/schemas/category.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const categoryIdSchema = z.union([z.enum(["root"]), z.number().int().positive()]);
|
||||
|
||||
export const categoryInfoResponse = z.object({
|
||||
metadata: z
|
||||
.object({
|
||||
parent: categoryIdSchema,
|
||||
mekVersion: z.number().int().positive(),
|
||||
dek: z.string().base64().nonempty(),
|
||||
dekVersion: z.string().datetime(),
|
||||
name: z.string().base64().nonempty(),
|
||||
nameIv: z.string().base64().nonempty(),
|
||||
})
|
||||
.optional(),
|
||||
subCategories: z.number().int().positive().array(),
|
||||
});
|
||||
export type CategoryInfoResponse = z.infer<typeof categoryInfoResponse>;
|
||||
|
||||
export const categoryCreateRequest = z.object({
|
||||
parent: categoryIdSchema,
|
||||
mekVersion: z.number().int().positive(),
|
||||
dek: z.string().base64().nonempty(),
|
||||
dekVersion: z.string().datetime(),
|
||||
name: z.string().base64().nonempty(),
|
||||
nameIv: z.string().base64().nonempty(),
|
||||
});
|
||||
export type CategoryCreateRequest = z.infer<typeof categoryCreateRequest>;
|
||||
@@ -1,9 +1,11 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const directoryIdSchema = z.union([z.enum(["root"]), z.number().int().positive()]);
|
||||
|
||||
export const directoryInfoResponse = z.object({
|
||||
metadata: z
|
||||
.object({
|
||||
parent: z.union([z.enum(["root"]), z.number().int().positive()]),
|
||||
parent: directoryIdSchema,
|
||||
mekVersion: z.number().int().positive(),
|
||||
dek: z.string().base64().nonempty(),
|
||||
dekVersion: z.string().datetime(),
|
||||
@@ -29,7 +31,7 @@ export const directoryRenameRequest = z.object({
|
||||
export type DirectoryRenameRequest = z.infer<typeof directoryRenameRequest>;
|
||||
|
||||
export const directoryCreateRequest = z.object({
|
||||
parent: z.union([z.enum(["root"]), z.number().int().positive()]),
|
||||
parent: directoryIdSchema,
|
||||
mekVersion: z.number().int().positive(),
|
||||
dek: z.string().base64().nonempty(),
|
||||
dekVersion: z.string().datetime(),
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import mime from "mime";
|
||||
import { z } from "zod";
|
||||
import { directoryIdSchema } from "./directory";
|
||||
|
||||
export const fileInfoResponse = z.object({
|
||||
parent: z.union([z.enum(["root"]), z.number().int().positive()]),
|
||||
parent: directoryIdSchema,
|
||||
mekVersion: z.number().int().positive(),
|
||||
dek: z.string().base64().nonempty(),
|
||||
dekVersion: z.string().datetime(),
|
||||
@@ -39,7 +40,7 @@ export const duplicateFileScanResponse = z.object({
|
||||
export type DuplicateFileScanResponse = z.infer<typeof duplicateFileScanResponse>;
|
||||
|
||||
export const fileUploadRequest = z.object({
|
||||
parent: z.union([z.enum(["root"]), z.number().int().positive()]),
|
||||
parent: directoryIdSchema,
|
||||
mekVersion: z.number().int().positive(),
|
||||
dek: z.string().base64().nonempty(),
|
||||
dekVersion: z.string().datetime(),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export * from "./auth";
|
||||
export * from "./category";
|
||||
export * from "./client";
|
||||
export * from "./directory";
|
||||
export * from "./file";
|
||||
|
||||
Reference in New Issue
Block a user