import { z } from 'zod';

import type { components } from './openapi/schema';
import { paginationQuerySchema, stringArrayCoerce } from './common';

export type Library = components['schemas']['LibraryRead'];

export const libraryQuerySchema = paginationQuerySchema.extend({
	ids: stringArrayCoerce
});

export const libraryCreateSchema = z.object({
	name: z.string().min(1, 'Library must have a name'),
	description: z.string().optional(),
	root_path: z.string().min(1, 'Must specify a root path'),
	path_template: z.string().optional().default('/{author}/{title}')
});

export type LibraryQuerySchema = typeof libraryQuerySchema;
export type LibraryCreateSchema = typeof libraryCreateSchema;
