import { getProp } from "../../objects/get-prop";
/**
 * given a hub entity, this util maps over its typeKeywords,
 * and for each, determines if it is an association typeKeyword
 * by checking whether it has the form ref|<associationType>|<id>.
 * If so, it extracts and returns the id which correspond to the
 * parent entity that this entity is associated with.
 *
 * @param entity - hub entity to extract ids from
 * @param associationType - entity type to extract ids for
 * @returns {string[]}
 */
export const getIdsFromKeywords = (entity, associationType) => {
    return getProp(entity, "typeKeywords").reduce((ids, keyword) => {
        const refKey = associationType ? `ref|${associationType}|` : "ref|";
        if (keyword.startsWith(refKey)) {
            const id = keyword.split("|")[2];
            ids.push(id);
        }
        return ids;
    }, []);
};
//# sourceMappingURL=getIdsFromKeywords.js.map