import type { UnifapiOperationDefinition } from "../operations.ts";

export const hackerNewsOperations: readonly UnifapiOperationDefinition[] = [
  {
    name: "get_hacker_news_item",
    operationId: "getHackerNewsItemsById",
    description: "Get Hacker News item by ID.",
    method: "GET",
    path: "/hacker-news/items/{id}",
    pathFields: ["id"],
    queryFields: [],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        id: {
          type: "integer",
          exclusiveMinimum: 0,
          description: "Hacker News item id.",
        },
      },
      additionalProperties: false,
      description: "The input payload for Get Hacker News item by ID.",
      required: ["id"],
    },
    paginated: false,
  },
  {
    name: "get_hacker_news_max_item",
    operationId: "getHackerNewsMaxItem",
    description: "Get largest Hacker News item ID.",
    method: "GET",
    path: "/hacker-news/max-item",
    pathFields: [],
    queryFields: [],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {},
      additionalProperties: false,
      description: "The input payload for Get largest Hacker News item ID.",
    },
    paginated: false,
  },
  {
    name: "list_hacker_news_story_items",
    operationId: "getHackerNewsStoriesByFeedItems",
    description: "List Hacker News story items.",
    method: "GET",
    path: "/hacker-news/stories/{feed}/items",
    pathFields: ["feed"],
    queryFields: ["cursor", "limit"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        feed: {
          type: "string",
          enum: ["top", "new", "best", "ask", "show", "jobs"],
          description: "Story feed: top, new, best, ask, show, or jobs.",
        },
        cursor: {
          type: "string",
          description: "Zero-based offset cursor returned as `next_cursor`.",
        },
        limit: {
          type: "integer",
          minimum: 1,
          maximum: 50,
          default: 20,
          description: "The limit value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for List Hacker News story items.",
      required: ["feed"],
    },
    paginated: true,
  },
  {
    name: "list_hacker_news_story_ids",
    operationId: "getHackerNewsStoriesByFeed",
    description: "List Hacker News story IDs.",
    method: "GET",
    path: "/hacker-news/stories/{feed}",
    pathFields: ["feed"],
    queryFields: ["cursor", "limit"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        feed: {
          type: "string",
          enum: ["top", "new", "best", "ask", "show", "jobs"],
          description: "Story feed: top, new, best, ask, show, or jobs.",
        },
        cursor: {
          type: "string",
          description: "Zero-based offset cursor returned as `next_cursor`.",
        },
        limit: {
          type: "integer",
          minimum: 1,
          maximum: 500,
          default: 100,
          description: "The limit value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for List Hacker News story IDs.",
      required: ["feed"],
    },
    paginated: true,
  },
  {
    name: "get_hacker_news_updates",
    operationId: "getHackerNewsUpdates",
    description: "Get changed Hacker News items and profiles.",
    method: "GET",
    path: "/hacker-news/updates",
    pathFields: [],
    queryFields: [],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {},
      additionalProperties: false,
      description: "The input payload for Get changed Hacker News items and profiles.",
    },
    paginated: false,
  },
  {
    name: "get_hacker_news_user",
    operationId: "getHackerNewsUsersById",
    description: "Get Hacker News user by ID.",
    method: "GET",
    path: "/hacker-news/users/{id}",
    pathFields: ["id"],
    queryFields: [],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        id: {
          type: "string",
          minLength: 1,
          description: "Case-sensitive Hacker News username.",
        },
      },
      additionalProperties: false,
      description: "The input payload for Get Hacker News user by ID.",
      required: ["id"],
    },
    paginated: false,
  },
];
