package com.r35157.nenjim.service.journal;

import com.r35157.libs.valuetypes.basic.SemanticVersion;
import com.r35157.nenjim.service.journal.model.ArtifactRelease;
import com.r35157.nenjim.service.journal.model.Journal;
import com.r35157.nenjim.service.journal.valuetypes.ArtifactCoordinate;
import com.r35157.nenjim.service.journal.valuetypes.JournalVersion;

import java.util.List;
import java.util.Optional;
import java.util.Set;

/** Filesystem-independent, read-only access to current and historical Journal knowledge. */
public interface JournalService {
    /** Lists known artifact coordinates in stable lexical order. */
    Set<ArtifactCoordinate> artifactCoordinates();

    /** Lists complete revisions in ascending Journal-version order. */
    List<Journal> revisions(ArtifactCoordinate coordinate);

    /** Returns the current complete worldview for an artifact. */
    Optional<Journal> latest(ArtifactCoordinate coordinate);

    /** Returns one exact historical complete worldview. */
    Optional<Journal> revision(ArtifactCoordinate coordinate, JournalVersion journalVersion);

    /** Returns the newest complete worldview published no later than the requested Journal version. */
    Optional<Journal> revisionAtOrBefore(ArtifactCoordinate coordinate, JournalVersion journalVersion);

    /** Returns an exact release from one selected Journal worldview. */
    Optional<ArtifactRelease> release(
            ArtifactCoordinate coordinate,
            JournalVersion journalVersion,
            SemanticVersion releaseVersion);
}
