"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchContent = void 0;
const checkPermission_1 = require("../permissions/checkPermission");
const fetchContentHubIndex_1 = require("./fetchContentHubIndex/fetchContentHubIndex");
const fetchContentPortal_1 = require("./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
 */
const fetchContent = async (identifier, options) => {
    let codePath = "hubIndexer";
    if (options === null || options === void 0 ? void 0 : options.context) {
        const chk = (0, checkPermission_1.checkPermission)("hub:content:fetch:portal", options.context);
        if (chk.access) {
            codePath = "portal";
        }
    }
    if (codePath === "portal") {
        return (0, fetchContentPortal_1.fetchContentPortal)(identifier, options);
    }
    else {
        return (0, fetchContentHubIndex_1.fetchContentHubIndex)(identifier, options);
    }
};
exports.fetchContent = fetchContent;
//# sourceMappingURL=fetchContent.js.map