// Auto-generated types for discover module
import type { SuccessResponse } from "../../types"

// Discover feed/list request
export interface DiscoverRequest {
  keyword: string
  target?: "feeds" | "lists"
}

// Feed discovery result
export interface FeedDiscoveryResult {
  type: "feed"
  id: string
  url: string
  title: string | null
  description: string | null
  siteUrl: string | null
  image: string | null
  ownerUserId?: string
  owner?: {
    id: string
    name: string
    handle: string
    avatar: string | null
  }
}

// List discovery result
export interface ListDiscoveryResult {
  type: "list"
  id: string
  title: string
  description: string | null
  image: string | null
  view: number
  fee: number
  ownerUserId: string
}

// Entry data for feed preview
export interface EntryData {
  id: string
  title: string | null
  content: string | null
  description: string | null
  publishedAt: string
  url: string | null
  author: string | null
  feedId: string
}

// Analytics data
export interface FeedAnalyticsData {
  feedId: string
  subscriptionCount: number
  updatesPerWeek: number
  totalSubscriptions: number
  weeklyGrowth: number
}

// Discovery item result
export interface DiscoveryItem {
  feed?: FeedDiscoveryResult
  list?: ListDiscoveryResult
  docs?: string // Documentation URL for RSSHub routes
  entries?: EntryData[]
  subscriptionCount?: number
  updatesPerWeek?: number
  analytics?: FeedAnalyticsData
}

export type DiscoverResponse = SuccessResponse<DiscoveryItem[]>

// RSSHub routes - no query parameters needed

export interface RSSHubRoute {
  path: string
  name: string
  description: string
  parameters?: Record<string, string>
  example?: string
}

export type RSSHubResponse = SuccessResponse<RSSHubRoute[]>

export interface RSSHubRouteQuery {
  route: string
}

export interface RSSHubRouteData {
  route: string
  name: string
  description: string
  parameters: Record<string, any>
  examples: string[]
  documentation: string
}

export type RSSHubRouteResponse = SuccessResponse<RSSHubRouteData>

// RSSHub analytics
export interface RSSHubAnalyticsQuery {
  period?: "day" | "week" | "month"
}

export interface RSSHubAnalyticsData {
  totalRoutes: number
  activeRoutes: number
  totalRequests: number
  popularRoutes: Array<{
    route: string
    requests: number
    name: string
  }>
  usage: Array<{
    date: string
    requests: number
  }>
}

export type RSSHubAnalyticsResponse = SuccessResponse<RSSHubAnalyticsData>
