From 14146759e128453495ceb112dbc8db906d48e0ca Mon Sep 17 00:00:00 2001 From: Karl Cardenas <29551334+karl-cardenas-coding@users.noreply.github.com> Date: Wed, 16 Oct 2024 14:30:17 -0700 Subject: [PATCH] chore: fix bug in packs plugin (#4293) (cherry picked from commit 1c0cc7950cf69b496bd485f0b7c550a3a7ef8946) --- 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) => {