import { checkPermission } from "../permissions/checkPermission";
import { fetchContentHubIndex } from "./fetchContentHubIndex/fetchContentHubIndex";
import { fetchContentPortal } from "./fetchContentPortal";
/**
 * Fetch Content by identifier, using either the Hub Indexer or Portal APIs
 *
 * Temporary facade while we transition to using the Portal API for content fetching.
 * Depending on the gating permission, use either the Hub Indexer or Portal code path.
 * @param identifier
 * @param options
 * @returns
 */
export const fetchContent = async (identifier, options) => {
    let codePath = "hubIndexer";
    if (options === null || options === void 0 ? void 0 : options.context) {
        const chk = checkPermission("hub:content:fetch:portal", options.context);
        if (chk.access) {
            codePath = "portal";
        }
    }
    if (codePath === "portal") {
        return fetchContentPortal(identifier, options);
    }
    else {
        return fetchContentHubIndex(identifier, options);
    }
};
//# sourceMappingURL=fetchContent.js.map