package dev.inmo.postssystem.features.users.common

import kotlinx.serialization.*
import kotlin.jvm.JvmInline

@Serializable
@JvmInline
value class UserId(val long: Long) {
    override fun toString(): String = long.toString()
}
val Long.userId: UserId
    get() = UserId(this)

@Serializable
@JvmInline
value class Username(val string: String) {
    override fun toString(): String = string
}
val String.username: Username
    get() = Username(this)

sealed interface NewUser {
    val firstName: String
    val lastName: String
    val username: Username
}

@Serializable
sealed class User : NewUser {
    abstract val id: UserId
}

@Serializable
data class DefaultUser(
    override val id: UserId,
    override val firstName: String,
    override val lastName: String,
    override val username: Username,
) : User()

@Serializable
data class DefaultNewUser(
    override val firstName: String,
    override val lastName: String,
    override val username: Username,
) : NewUser
