Open source candidates with configured browser

This commit is contained in:
2026-08-05 21:20:06 +02:00
parent d90e6c6dd8
commit fe329cd19b
5 changed files with 105 additions and 20 deletions
+25
View File
@@ -240,6 +240,31 @@ export async function getProductPictures(
};
}
export async function openProductSource(config, { manufacturerId, sourceKey, url }) {
const sourceUrl = normalizeSourceUrl(url);
const mapping = await listMappingSources(config, { manufacturerId });
const source = mapping.items.find(
(item) => item.enabled && String(item.key ?? "").toLowerCase() === String(sourceKey ?? "").toLowerCase(),
);
if (!source) {
throw new Error("Source mapping was not found for selected manufacturer.");
}
await openInBrowser(sourceUrl, { engine: source.browserEngine });
return {
configured: mapping.configured,
opened: true,
source: {
key: source.key,
name: source.name,
browserEngine: source.browserEngine,
},
url: sourceUrl,
};
}
async function findSourceCandidates(source, product, { includePictures = false } = {}) {
const searchAttempts = buildAdapterSearchUrls(source, product);
let lastSearchUrl = searchAttempts[0]?.url || normalizeSourceUrl(source.url);