"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.searchEntityCatalogs = searchEntityCatalogs;
const get_with_default_1 = require("../objects/get-with-default");
const searchCatalogs_1 = require("./searchCatalogs");
/**
 * Given an entity, execute a search on all the catalogs, and their associated with the entity
 * If the entity has no catalogs, an empty array is returned
 * If passed an IQuery, only collections using the same targetEntity will be searched
 * If passed a string, a query will be executed on all collections in all catalogs
 * @param entity
 * @param query - string or IQuery
 * @param options - IPagingOptions & ISortOptions - only num is used
 * @param context
 * @returns
 */
async function searchEntityCatalogs(entity, query, options, context) {
    // collect all the catalogs from the entity, and search them
    const catalogs = (0, get_with_default_1.getWithDefault)(entity, "catalogs", []);
    return (0, searchCatalogs_1.searchCatalogs)(catalogs, query, options, context);
}
//# sourceMappingURL=searchEntityCatalogs.js.map