This commit is contained in:
seb
2026-09-29 13:45:13 +02:00
parent 4cb050c285
commit 43e1ab98b7
7 changed files with 193 additions and 91 deletions

View File

@@ -327,11 +327,11 @@ export class ApiClient {
delete: (id) => this.#empty('DELETE', `/api/category/${enc(id)}`),
/** PUT /api/category/order */
order: (body) => this.#json('PUT', '/api/category/order', { body }),
/** POST /api/category/{id}/image — raw AVIF body */
addImage: (id, avifBytes) =>
/** POST /api/category/{id}/image — raw image body */
addImage: (id, imageBytes) =>
this.#json('POST', `/api/category/${enc(id)}/image`, {
body: avifBytes,
contentType: 'image/avif',
body: imageBytes,
contentType: imageBytes?.type || 'image/webp',
raw: true,
}),
/** DELETE /api/category/{id}/image */
@@ -380,11 +380,11 @@ export class ApiClient {
delete: (sku) => this.#empty('DELETE', `/api/article/${enc(sku)}`),
/** PUT /api/article/{sku}/prices */
setPrices: (sku, body) => this.#json('PUT', `/api/article/${enc(sku)}/prices`, { body }),
/** POST /api/article/{sku}/image — raw AVIF body */
addImage: (sku, avifBytes) =>
/** POST /api/article/{sku}/image — raw image body */
addImage: (sku, imageBytes) =>
this.#json('POST', `/api/article/${enc(sku)}/image`, {
body: avifBytes,
contentType: 'image/avif',
body: imageBytes,
contentType: imageBytes?.type || 'image/webp',
raw: true,
}),
/** DELETE /api/article/{sku}/image/{fullHash} */

View File

@@ -265,13 +265,13 @@ export const article = {
/**
* POST /api/article/:sku/image
* Body: raw AVIF bytes (Content-Type: image/avif, max 1000×1000, prepared client-side via WASM)
* Body: raw image bytes (Content-Type: image/webp, max 1000×1000)
* → 201 { image: { picId, sort, full, thumb, fullHash, thumbHash } }
*/
uploadImage(sku, file) {
return httpBinary(`/api/article/${encodeURIComponent(sku)}/image`, {
method: 'POST',
contentType: 'image/avif',
contentType: file?.type || 'image/webp',
body: file,
});
},
@@ -598,13 +598,13 @@ export const category = {
/**
* POST /api/category/:id/image
* Body: raw AVIF bytes (Content-Type: image/avif)
* Body: raw image bytes (Content-Type: image/webp)
* → 201 { category: { id, fullHash, thumbW, thumbH, thumbHash } }
*/
uploadImage(categoryId, file) {
return httpBinary(`/api/category/${categoryId}/image`, {
method: 'POST',
contentType: 'image/avif',
contentType: file?.type || 'image/webp',
body: file,
});
},
@@ -659,13 +659,13 @@ export const brand = {
/**
* POST /api/brand/:id/image
* Accepts full-size AVIF body (Content-Type: image/avif).
* Accepts full-size image body (Content-Type: image/webp).
* → 201 { brand: { id, fullHash, thumbW, thumbH, thumbHash, pics } }
*/
addImage(brandId, file) {
return httpBinary(`/api/brand/${brandId}/image`, {
method: 'POST',
contentType: 'image/avif',
contentType: file?.type || 'image/webp',
body: file,
});
},