23 lines
587 B
TypeScript
23 lines
587 B
TypeScript
import { z } from "zod";
|
|
import { fileType } from "./file";
|
|
|
|
const baseItem = z.object({
|
|
path: z.string(),
|
|
parent: z.string(),
|
|
title: z.string(),
|
|
type: fileType,
|
|
navigable: z.boolean(),
|
|
private: z.boolean(),
|
|
order: z.number().finite(),
|
|
});
|
|
export const item: z.ZodType<ProjectItem> = baseItem.extend({
|
|
children: z.lazy(() => item.array().optional()),
|
|
});
|
|
export const project = z.object({
|
|
items: z.array(item),
|
|
});
|
|
|
|
export type Project = z.infer<typeof project>;
|
|
export type ProjectItem = z.infer<typeof baseItem> & {
|
|
children?: ProjectItem[]
|
|
};
|