Add task routes, bug fixes
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user