This commit is contained in:
seb
2026-10-09 16:44:18 +02:00
parent 56274ecb1d
commit 5e62be468f
9 changed files with 175 additions and 71 deletions

View File

@@ -9,6 +9,15 @@ const WHITE_THRESHOLD = 240; // Pixels with R,G,B >= 240 are considered near-whi
let encodeAvif;
function clientIdHeaders() {
try {
const cid = window.sessionStorage.getItem('sse.cid');
return cid ? { 'X-Client-Id': cid } : {};
} catch {
return {};
}
}
async function getAvifEncoder() {
if (!encodeAvif) {
const { default: encode } = await import('@jsquash/avif/encode');
@@ -319,7 +328,10 @@ export async function downloadAndPrepareLogoAvif(url, fallbackDataUrl) {
try {
const resp = await fetch('/api/serper/image', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
headers: {
'Content-Type': 'application/json',
...clientIdHeaders(),
},
credentials: 'include',
body: JSON.stringify({ url }),
});

View File

@@ -5,7 +5,7 @@
*
* Everything is created through the existing dashback API:
* - categories: POST /api/category ({ parentId, name })
* - brands: PUT /api/brand ({ name }) → { brand: { id } }
* - brands: POST /api/brand ({ name }) → { brand: { id } }
* - articles: POST /api/article ({ categoryId, name }) → { article: { sku } }
* - price: PUT /api/article/:sku/prices ({ prices: [{ price, tax }] })
* - brand: PUT /api/article/:sku/brand ({ brandId })
@@ -111,8 +111,8 @@ function createEnsureCategory(cache) {
}
/**
* Upsert a brand by name → brandId.
* PUT /api/brand upserts by name (same name ⇒ update, otherwise create).
* Ensure a brand by name → brandId.
* POST /api/brand inserts (409 Brand already exists on duplicate).
*/
function createEnsureBrand(cache) {
return async function ensureBrand(name) {
@@ -121,8 +121,8 @@ function createEnsureBrand(cache) {
const key = clean.toLowerCase();
if (cache.brandByKey.has(key)) return cache.brandByKey.get(key);
const res = await brand.upsert({ name: clean });
requireObject(res, 'PUT /api/brand');
const res = await brand.create({ name: clean });
requireObject(res, 'POST /api/brand');
requireObject(res.brand, 'brand');
requireDefined(res.brand.id, 'brand.id');
cache.brandByKey.set(key, res.brand.id);

View File

@@ -7,7 +7,7 @@
*
* All work is done through the existing dashback API:
* - categories → POST /api/category
* - brands → PUT /api/brand
* - brands → POST /api/brand
* - articles → POST /api/article (+ price / brand / ean / categories PUTs)
*/