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

export const tiktokOperations: readonly UnifapiOperationDefinition[] = [
  {
    name: "get_tiktok_recommended_feed",
    operationId: "postTiktokFeedRecommended",
    description: "Get TikTok recommendation videos.",
    method: "POST",
    path: "/tiktok/feed/recommended",
    pathFields: [],
    queryFields: [],
    bodyFields: ["cookie", "region", "limit"],
    inputSchema: {
      type: "object",
      properties: {
        cookie: {
          type: "string",
          description: "The cookie value.",
        },
        region: {
          type: "string",
          minLength: 2,
          maxLength: 2,
          default: "US",
          description: "The region value.",
        },
        limit: {
          type: "integer",
          minimum: 1,
          maximum: 50,
          default: 20,
          description: "The limit value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for Get TikTok recommendation videos.",
    },
    paginated: false,
  },
  {
    name: "get_tiktok_hashtag",
    operationId: "getTiktokHashtagsById",
    description: "Get a TikTok hashtag by ID.",
    method: "GET",
    path: "/tiktok/hashtags/{id}",
    pathFields: ["id"],
    queryFields: [],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        id: {
          type: "string",
          pattern: "^\\d+$",
          description: "The id value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for Get a TikTok hashtag by ID.",
      required: ["id"],
    },
    paginated: false,
  },
  {
    name: "list_tiktok_hashtag_videos",
    operationId: "getTiktokHashtagsByIdVideos",
    description: "List videos tagged with a TikTok hashtag.",
    method: "GET",
    path: "/tiktok/hashtags/{id}/videos",
    pathFields: ["id"],
    queryFields: ["cursor", "limit"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        id: {
          type: "string",
          pattern: "^\\d+$",
          description: "The id value.",
        },
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
        limit: {
          type: "integer",
          minimum: 1,
          maximum: 50,
          default: 20,
          description: "The limit value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for List videos tagged with a TikTok hashtag.",
      required: ["id"],
    },
    paginated: true,
  },
  {
    name: "get_tiktok_music",
    operationId: "getTiktokMusicById",
    description: "Get a TikTok music track by ID.",
    method: "GET",
    path: "/tiktok/music/{id}",
    pathFields: ["id"],
    queryFields: [],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        id: {
          type: "string",
          pattern: "^\\d+$",
          description: "The id value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for Get a TikTok music track by ID.",
      required: ["id"],
    },
    paginated: false,
  },
  {
    name: "list_tiktok_music_videos",
    operationId: "getTiktokMusicByIdVideos",
    description: "List videos using a TikTok music track.",
    method: "GET",
    path: "/tiktok/music/{id}/videos",
    pathFields: ["id"],
    queryFields: ["cursor", "limit"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        id: {
          type: "string",
          pattern: "^\\d+$",
          description: "The id value.",
        },
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
        limit: {
          type: "integer",
          minimum: 1,
          maximum: 50,
          default: 20,
          description: "The limit value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for List videos using a TikTok music track.",
      required: ["id"],
    },
    paginated: true,
  },
  {
    name: "search_tiktok_hashtags",
    operationId: "getTiktokSearchHashtags",
    description: "Search TikTok hashtags by keyword.",
    method: "GET",
    path: "/tiktok/search/hashtags",
    pathFields: [],
    queryFields: ["cursor", "limit", "q"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
        limit: {
          type: "integer",
          minimum: 1,
          maximum: 50,
          default: 20,
          description: "The limit value.",
        },
        q: {
          type: "string",
          minLength: 1,
          description: "Search keyword",
        },
      },
      additionalProperties: false,
      description: "The input payload for Search TikTok hashtags by keyword.",
      required: ["q"],
    },
    paginated: true,
  },
  {
    name: "search_tiktok",
    operationId: "getTiktokSearch",
    description: "General TikTok search (returns videos).",
    method: "GET",
    path: "/tiktok/search",
    pathFields: [],
    queryFields: ["cursor", "limit", "q"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
        limit: {
          type: "integer",
          minimum: 1,
          maximum: 50,
          default: 20,
          description: "The limit value.",
        },
        q: {
          type: "string",
          minLength: 1,
          description: "Search keyword",
        },
      },
      additionalProperties: false,
      description: "The input payload for General TikTok search (returns videos).",
      required: ["q"],
    },
    paginated: true,
  },
  {
    name: "search_tiktok_users",
    operationId: "getTiktokSearchUsers",
    description: "Search TikTok users by keyword.",
    method: "GET",
    path: "/tiktok/search/users",
    pathFields: [],
    queryFields: ["cursor", "limit", "q"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
        limit: {
          type: "integer",
          minimum: 1,
          maximum: 50,
          default: 20,
          description: "The limit value.",
        },
        q: {
          type: "string",
          minLength: 1,
          description: "Search keyword",
        },
      },
      additionalProperties: false,
      description: "The input payload for Search TikTok users by keyword.",
      required: ["q"],
    },
    paginated: true,
  },
  {
    name: "search_tiktok_videos",
    operationId: "getTiktokSearchVideos",
    description: "Search TikTok videos by keyword.",
    method: "GET",
    path: "/tiktok/search/videos",
    pathFields: [],
    queryFields: ["cursor", "limit", "q"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
        limit: {
          type: "integer",
          minimum: 1,
          maximum: 50,
          default: 20,
          description: "The limit value.",
        },
        q: {
          type: "string",
          minLength: 1,
          description: "Search keyword",
        },
      },
      additionalProperties: false,
      description: "The input payload for Search TikTok videos by keyword.",
      required: ["q"],
    },
    paginated: true,
  },
  {
    name: "list_tiktok_user_followers",
    operationId: "getTiktokUsersByIdFollowers",
    description: "List a TikTok user's followers.",
    method: "GET",
    path: "/tiktok/users/{id}/followers",
    pathFields: ["id"],
    queryFields: ["cursor", "limit"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        id: {
          type: "string",
          minLength: 1,
          description: "TikTok sec_uid, numeric user id, or public handle.",
        },
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
        limit: {
          type: "integer",
          minimum: 1,
          maximum: 50,
          default: 20,
          description: "The limit value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for List a TikTok user's followers.",
      required: ["id"],
    },
    paginated: true,
  },
  {
    name: "list_tiktok_user_following",
    operationId: "getTiktokUsersByIdFollowing",
    description: "List users a TikTok user is following.",
    method: "GET",
    path: "/tiktok/users/{id}/following",
    pathFields: ["id"],
    queryFields: ["cursor", "limit"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        id: {
          type: "string",
          minLength: 1,
          description: "TikTok sec_uid, numeric user id, or public handle.",
        },
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
        limit: {
          type: "integer",
          minimum: 1,
          maximum: 50,
          default: 20,
          description: "The limit value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for List users a TikTok user is following.",
      required: ["id"],
    },
    paginated: true,
  },
  {
    name: "list_tiktok_user_likes",
    operationId: "getTiktokUsersByIdLikes",
    description: "List videos liked by a TikTok user.",
    method: "GET",
    path: "/tiktok/users/{id}/likes",
    pathFields: ["id"],
    queryFields: ["cursor", "limit"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        id: {
          type: "string",
          minLength: 1,
          description: "TikTok sec_uid, numeric user id, or public handle.",
        },
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
        limit: {
          type: "integer",
          minimum: 1,
          maximum: 50,
          default: 20,
          description: "The limit value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for List videos liked by a TikTok user.",
      required: ["id"],
    },
    paginated: true,
  },
  {
    name: "get_tiktok_user",
    operationId: "getTiktokUsersById",
    description: "Get a TikTok user profile.",
    method: "GET",
    path: "/tiktok/users/{id}",
    pathFields: ["id"],
    queryFields: [],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        id: {
          type: "string",
          minLength: 1,
          description: "TikTok sec_uid, numeric user id, or public handle.",
        },
      },
      additionalProperties: false,
      description: "The input payload for Get a TikTok user profile.",
      required: ["id"],
    },
    paginated: false,
  },
  {
    name: "list_tiktok_user_videos",
    operationId: "getTiktokUsersByIdVideos",
    description: "List videos posted by a TikTok user.",
    method: "GET",
    path: "/tiktok/users/{id}/videos",
    pathFields: ["id"],
    queryFields: ["cursor", "limit"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        id: {
          type: "string",
          minLength: 1,
          description: "TikTok sec_uid, numeric user id, or public handle.",
        },
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
        limit: {
          type: "integer",
          minimum: 1,
          maximum: 50,
          default: 20,
          description: "The limit value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for List videos posted by a TikTok user.",
      required: ["id"],
    },
    paginated: true,
  },
  {
    name: "resolve_tiktok_user",
    operationId: "getTiktokUsersResolve",
    description: "Resolve a TikTok username to a user id.",
    method: "GET",
    path: "/tiktok/users/resolve",
    pathFields: [],
    queryFields: ["username"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        username: {
          type: "string",
          minLength: 1,
          description: "Public TikTok handle, e.g. 'jennmelon'",
        },
      },
      additionalProperties: false,
      description: "The input payload for Resolve a TikTok username to a user id.",
      required: ["username"],
    },
    paginated: false,
  },
  {
    name: "list_tiktok_video_comment_replies",
    operationId: "getTiktokVideosByIdCommentsByCommentIdReplies",
    description: "List replies to a TikTok comment.",
    method: "GET",
    path: "/tiktok/videos/{id}/comments/{comment_id}/replies",
    pathFields: ["id", "comment_id"],
    queryFields: ["cursor", "limit"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        id: {
          type: "string",
          pattern: "^\\d+$",
          description: "The id value.",
        },
        comment_id: {
          type: "string",
          pattern: "^\\d+$",
          description: "The comment_id value.",
        },
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
        limit: {
          type: "integer",
          minimum: 1,
          maximum: 50,
          default: 20,
          description: "The limit value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for List replies to a TikTok comment.",
      required: ["id", "comment_id"],
    },
    paginated: true,
  },
  {
    name: "list_tiktok_video_comments",
    operationId: "getTiktokVideosByIdComments",
    description: "List top-level comments on a TikTok video.",
    method: "GET",
    path: "/tiktok/videos/{id}/comments",
    pathFields: ["id"],
    queryFields: ["cursor", "limit"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        id: {
          type: "string",
          pattern: "^\\d+$",
          description: "The id value.",
        },
        cursor: {
          type: "string",
          description: "The cursor value.",
        },
        limit: {
          type: "integer",
          minimum: 1,
          maximum: 50,
          default: 20,
          description: "The limit value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for List top-level comments on a TikTok video.",
      required: ["id"],
    },
    paginated: true,
  },
  {
    name: "get_tiktok_video",
    operationId: "getTiktokVideosById",
    description: "Get a TikTok video by ID.",
    method: "GET",
    path: "/tiktok/videos/{id}",
    pathFields: ["id"],
    queryFields: [],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        id: {
          type: "string",
          pattern: "^\\d+$",
          description: "The id value.",
        },
      },
      additionalProperties: false,
      description: "The input payload for Get a TikTok video by ID.",
      required: ["id"],
    },
    paginated: false,
  },
  {
    name: "batch_get_tiktok_videos",
    operationId: "postTiktokVideosBatch",
    description: "Batch-fetch TikTok videos by ID.",
    method: "POST",
    path: "/tiktok/videos/batch",
    pathFields: [],
    queryFields: [],
    bodyFields: ["ids"],
    inputSchema: {
      type: "object",
      properties: {
        ids: {
          type: "array",
          items: {
            type: "string",
            pattern: "^\\d+$",
            description: "One item in the array.",
          },
          minItems: 1,
          maxItems: 20,
          description: "Up to 20 numeric TikTok video ids",
        },
      },
      additionalProperties: false,
      description: "The input payload for Batch-fetch TikTok videos by ID.",
      required: ["ids"],
    },
    paginated: false,
  },
  {
    name: "resolve_tiktok_video",
    operationId: "getTiktokVideosResolve",
    description: "Resolve a TikTok share URL to a video.",
    method: "GET",
    path: "/tiktok/videos/resolve",
    pathFields: [],
    queryFields: ["url"],
    bodyFields: [],
    inputSchema: {
      type: "object",
      properties: {
        url: {
          type: "string",
          format: "uri",
          description: "TikTok share URL (long or short form)",
        },
      },
      additionalProperties: false,
      description: "The input payload for Resolve a TikTok share URL to a video.",
      required: ["url"],
    },
    paginated: false,
  },
];
