package cloud.nstart.terravault.ordinis.restapi.dto.schemaworkflow;

import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.validation.constraints.NotBlank;

/**
 * Publish approved draft → live HEAD.
 *
 * <p>Endpoint: {@code POST /api/v1/dictionaries/{name}/drafts/{draftId}/publish}.
 *
 * <p>{@code expectedHeadVersion} — optimistic lock против текущего
 * {@code DictionaryDefinition.schemaVersion}. Если кто-то другой опубликовал
 * свой draft пока этот approved'ил → 409 ({@code version_mismatch}, refetch
 * + re-publish).
 *
 * <p>Default bump: minor (1.4.0 → 1.5.0). Если schema diff содержит breaking
 * keys (type/format/required removed/x-references changed) — backend bump'нет
 * major (1.4.0 → 2.0.0). Detection в SchemaDraftService.computeNextVersion.
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public record PublishDraftRequest(
    @NotBlank String expectedHeadVersion,
    /** Optional release note shown в changelog. */
    String publishNote) {}
