package com.cameleer.server.core.storage;

import com.cameleer.common.graph.RouteGraph;
import com.cameleer.server.core.ingestion.TaggedDiagram;

import java.util.Map;
import java.util.Optional;

public interface DiagramStore {

    void store(TaggedDiagram diagram);

    Optional<RouteGraph> findByContentHash(String contentHash);

    Optional<String> findContentHashForRoute(String routeId, String instanceId);

    /**
     * Return the most recently stored {@code content_hash} for the given
     * {@code (applicationId, environment, routeId)} triple, regardless of the
     * agent instance that produced it.
     *
     * <p>Unlike {@link #findContentHashForRoute(String, String)}, this lookup
     * is independent of the agent registry — so it keeps working for routes
     * whose publishing agents have since been redeployed or removed.
     */
    Optional<String> findLatestContentHashForAppRoute(String applicationId,
                                                      String routeId,
                                                      String environment);

    Map<String, String> findProcessorRouteMapping(String applicationId, String environment);
}
