From 080b59d8503d581024193d3f6a994d92989a9bb8 Mon Sep 17 00:00:00 2001 From: Karl Cardenas Date: Wed, 16 Oct 2024 13:52:33 -0700 Subject: [PATCH] chore: fix bug in packs plugin --- plugins/packs-integrations.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/plugins/packs-integrations.js b/plugins/packs-integrations.js index 9db8cb795f..4a9f77c646 100644 --- a/plugins/packs-integrations.js +++ b/plugins/packs-integrations.js @@ -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; @@ -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; @@ -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) => {