package io.cameleer.server.core.storage;

import java.util.UUID;

/**
 * Opaque coordinate that addresses one stored JAR. Designed so a future
 * OCI-backed store can reuse the same coordinate without schema changes —
 * see issue #158 (Zot follow-up).
 */
public record ArtifactCoordinates(String tenantId, UUID appId, int version) {
    public ArtifactCoordinates {
        if (tenantId == null) throw new IllegalArgumentException("tenantId must not be null");
        if (appId == null) throw new IllegalArgumentException("appId must not be null");
        if (version <= 0) throw new IllegalArgumentException("version must be > 0, got " + version);
    }

    /** Path-fragment used by FilesystemArtifactStore. Mirrors today's layout. */
    public String filesystemKey() {
        return appId + "/v" + version + "/app.jar";
    }

    /** OCI reference used by a future registry-backed store. Stable so coordinates
     * survive a backend swap. */
    public String ociRef() {
        return tenantId + "/" + appId + ":v" + version;
    }
}
