/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 */
package com.runicgateway.app.data.api.dto

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
 * Wiki DTOs (website `wiki.model.js` / `wiki.db.js`). The list route returns
 * lighter summary rows (no body); the detail route returns the full page plus
 * its tags, backlinks, and unresolved ("red") link targets.
 */

/** `GET /public/wiki` — a summary row (body omitted). */
@Serializable
data class WikiSummaryDto(
    val id: Long,
    val slug: String = "",
    val title: String = "",
    val excerpt: String? = null,
    @SerialName("category_slug") val categorySlug: String? = null,
    @SerialName("category_title") val categoryTitle: String? = null,
    @SerialName("updated_at") val updatedAt: String? = null,
    @SerialName("published_at") val publishedAt: String? = null,
)

/** `GET /public/wiki/:slug` — full page + tags/backlinks. */
@Serializable
data class WikiPageDto(
    val id: Long,
    val slug: String = "",
    val title: String = "",
    val body: String? = null,
    val excerpt: String? = null,
    @SerialName("category_slug") val categorySlug: String? = null,
    @SerialName("category_title") val categoryTitle: String? = null,
    @SerialName("updated_at") val updatedAt: String? = null,
    @SerialName("published_at") val publishedAt: String? = null,
    val tags: List<WikiTagRefDto> = emptyList(),
    val backlinks: List<WikiBacklinkDto> = emptyList(),
    @SerialName("missing_links") val missingLinks: List<String> = emptyList(),
)

/** A tag as attached to a page (slug + label only). */
@Serializable
data class WikiTagRefDto(
    val slug: String = "",
    val label: String = "",
)

/** A page that links to the current page. */
@Serializable
data class WikiBacklinkDto(
    val slug: String = "",
    val title: String = "",
)

/** `GET /public/wiki/categories`. */
@Serializable
data class WikiCategoryDto(
    val id: Long,
    val slug: String = "",
    val title: String = "",
    val description: String? = null,
    @SerialName("published_count") val publishedCount: Long = 0,
)

/** `GET /public/wiki/tags`. */
@Serializable
data class WikiTagDto(
    val id: Long,
    val slug: String = "",
    val label: String = "",
    @SerialName("published_count") val publishedCount: Long = 0,
)
