from typing import List
from typing import Dict


def get_entity_dictionary(archive_entities_list: List[Dict]) -> Dict:
    """
    Given a list of ingest's archiveEntities, return a dictionary mapping UUIDs to the archiveEntities

    :param archive_entities_list: List of archiveEntities
    :return: Map of ingest UUIDs to archiveEntities metadata
    """

    entity_dictionary = {}

    for entity in archive_entities_list:
        # A single entity may refer to multiple files (e.g. 1 SequencingRun -> 3 data files)
        for accessionedMetadata in entity.get('accessionedMetadataUuids', []):
            entity_dictionary[accessionedMetadata] = entity

    return entity_dictionary