import { defineModule, defineRoute } from "../../shared/define-module"
import type {
  FeedAnalyticsRequest,
  FeedAnalyticsResponse,
  FeedClaimChallengeRequest,
  FeedClaimChallengeResponse,
  FeedClaimListResponse,
  FeedClaimMessageQuery,
  FeedClaimMessageResponse,
  FeedGetQuery,
  FeedGetResponse,
  FeedRefreshQuery,
  FeedRefreshResponse,
  FeedResetQuery,
  FeedResetResponse,
} from "./types"

/**
 * Feeds module definition with nested routes
 */
export const feedsModule = defineModule({
  name: "feeds",
  prefix: "/feeds",
  routes: {
    // Basic feed operations
    get: defineRoute<FeedGetQuery, FeedGetResponse>("GET", "/"),

    refresh: defineRoute<FeedRefreshQuery, FeedRefreshResponse>(
      "GET",
      "/refresh",
    ),

    reset: defineRoute<FeedResetQuery, FeedResetResponse>("GET", "/reset"),

    analytics: defineRoute<FeedAnalyticsRequest, FeedAnalyticsResponse>(
      "POST",
      "/analytics",
    ),

    // Feed claiming operations (nested)
    claim: {
      challenge: defineRoute<
        FeedClaimChallengeRequest,
        FeedClaimChallengeResponse
      >("POST", "/claim/challenge"),

      // eslint-disable-next-line @typescript-eslint/no-empty-object-type
      list: defineRoute<{}, FeedClaimListResponse>(
        "GET",
        "/claim/list",
      ),

      message: defineRoute<FeedClaimMessageQuery, FeedClaimMessageResponse>(
        "GET",
        "/claim/message",
      ),
    },
  },
})

// Export the API type
export type FeedsAPI = typeof feedsModule.api

// Re-export types for external consumption
export type * from "./types"
