Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix bug in packs plugin #4293

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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