Add task routes, bug fixes

This commit is contained in:
2025-01-29 15:44:24 +05:30
parent 405338c314
commit a157cb3fed
10 changed files with 413 additions and 29 deletions

View File

@@ -31,6 +31,33 @@ const downloadFileResponse = z.object({
url: z.string().url(),
});
export const files = z
.object({
pid: z.string().optional(),
name: z.string(),
type: z.enum(["folder", "file"]),
size: z.number().optional(),
files: z.array(z.lazy(() => files)).optional(),
})
.superRefine((data, ctx) => {
const validateRecursive = (file: any) => {
if (file.type === "file" && !file.pid) {
ctx.addIssue({
path: ["pid"],
message: 'pid is required when type is "file"',
code: z.ZodIssueCode.custom,
});
}
if (file.files) {
file.files.forEach((nestedFile: any) => {
validateRecursive(nestedFile);
});
}
};
validateRecursive(data);
});
export const { schemas: fileSchemas, $ref: $file } = buildJsonSchemas(
{
uploadFileResponse,