Skip to content

Commit

Permalink
chore: fix bug in packs plugin (#4293)
Browse files Browse the repository at this point in the history
(cherry picked from commit 1c0cc79)
  • Loading branch information
karl-cardenas-coding committed Oct 16, 2024
1 parent 363713b commit 6492db1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions plugins/packs-integrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,23 @@ function generateRoutes(packsAllData) {
});
}

async function fetchPackListItems(queryParams, packDataArr, counter) {
const payload = { filter: { type: ["spectro", "oci"] } };
async function fetchPackListItems(queryParams, packDataArr, counter, mappedRepos) {
// Loop through the mappedRepos object and extract all the registries provided in the Docusarus config file
const registryUids = [];
for (let i = 0; i < mappedRepos.length; i++) {
registryUids.push(mappedRepos[i].uid);
}
// Provide the registryUids in the payload to fetch the packs ONLY from registries provided in the Docusarus config file
const payload = { filter: { type: ["spectro", "oci"], registryUid: registryUids } };
const response = await callRateLimitAPI(() => api.post(`/v1/packs/search${queryParams}`, payload));
const tempPackArr = packDataArr.concat(response?.data?.items);

if (response?.data?.listmeta?.continue) {
return fetchPackListItems(
`?limit=${filterLimit}&continue=` + response.data.listmeta.continue,
tempPackArr,
counter
counter,
mappedRepos
);
} else {
return tempPackArr;
Expand Down Expand Up @@ -384,6 +392,7 @@ async function pluginPacksAndIntegrationsData(context, options) {
name: "plugin-packs-integrations",
async loadContent() {
const repositories = options.repositories || [];

const mappedRepos = await mapRepositories(repositories);
let apiPackResponse = {};
let isFileExists = false;
Expand All @@ -396,7 +405,7 @@ async function pluginPacksAndIntegrationsData(context, options) {
mkdirSync(dirname, { recursive: true });
}
logger.info("Fetching the list of packs from the Palette API");
let packDataArr = await fetchPackListItems(`?limit=${filterLimit}`, [], 0);
let packDataArr = await fetchPackListItems(`?limit=${filterLimit}`, [], 0, mappedRepos);

// Filter out the packs from the exclude list.
packDataArr = packDataArr.filter((pack) => {
Expand Down

0 comments on commit 6492db1

Please sign in to comment.