package dev.inmo.postssystem.features.content.common

import dev.inmo.micro_utils.common.FileName
import dev.inmo.micro_utils.mime_types.MimeType
import dev.inmo.postssystem.features.common.common.SimpleInputProvider
import kotlinx.serialization.PolymorphicSerializer
import kotlinx.serialization.Serializable
import kotlin.jvm.JvmInline

@Serializable
@JvmInline
value class ContentId(val string: String)

/**
 * Content which is planned to be registered in database
 *
 * @see ContentSerializersModuleConfigurator.Element
 * @see ContentSerializersModuleConfigurator
 */
interface Content

/**
 * This type represents some binary data which can be sent with multipart and deserialized from it
 */
data class BinaryContent(
    val filename: FileName,
    val mimeType: MimeType,
    val inputProvider: SimpleInputProvider
) : Content

val ContentSerializer = PolymorphicSerializer(Content::class)

/**
 * Content which is already registered in database. Using its [id] you can retrieve all known
 * [dev.inmo.postssystem.core.post.RegisteredPost]s by using
 * [dev.inmo.postssystem.core.post.repo.ReadPostsRepo.getPostsByContent]
 */
@Serializable
data class RegisteredContent(
    val id: ContentId,
    val content: Content
)
