import {z} from 'zod'

import {CrumbSchema} from './crumbs'
import {TrailSchema} from './trails'

// the one free-text search term shape, shared by every searchable endpoint
export const searchTermShape = {
  q: z.string().trim().min(1).max(100),
}

export const SearchQuerySchema = z.object(searchTermShape)

export const SearchResponseSchema = z.object({
  crumbs: z.array(CrumbSchema),
  trails: z.array(TrailSchema),
})

export type SearchResponse = z.infer<typeof SearchResponseSchema>
