package dev.ulfrx.recipe.shared.dto

import kotlinx.serialization.Serializable

/**
 * Wire-format DTO for `GET /api/v1/me` (D-27).
 *
 * Mirrors [User] verbatim today; kept as a separate type so Phase 3 can extend the
 * response with `householdId` (and any future fields) without changing the client
 * domain model. Decoders MUST be configured with `ignoreUnknownKeys = true` so a
 * Phase 2 client keeps parsing Phase 3+ responses (see
 * `MeResponseSerializationTest.decoder ignores future fields like householdId without failing`).
 *
 * Wire keys are camelCase to stay consistent with kotlinx.serialization defaults;
 * `sub` is left raw because it's an opaque OIDC claim and renaming it on the wire
 * is a recipe for drift.
 */
@Serializable
public data class MeResponse(
    public val id: String,
    public val sub: String,
    public val email: String,
    public val displayName: String,
) {
    /** One-to-one mapping to the client domain [User]; no fallback / coercion. */
    public fun toUser(): User =
        User(
            id = id,
            sub = sub,
            email = email,
            displayName = displayName,
        )
}
