This commit is contained in:
seb
2026-10-09 17:55:45 +02:00
parent de7afbcbe9
commit 848ca0aff5
13 changed files with 331 additions and 48 deletions

View File

@@ -4,7 +4,7 @@ Protected. Requires a valid session cookie (`credentials: 'include'`).
Delete brand image
Removes the brand's image. Sets thumbW, thumbH, thumbHash back to null.
Removes the brand's image. Sets thumbW, thumbH, thumbHash back to null. Emits SSE signal `brand` with payload `{ sender, brandId }`.
## Path parameters
@@ -12,6 +12,10 @@ Removes the brand's image. Sets thumbW, thumbH, thumbHash back to null.
|-------|----------|------|-------------|
| `id` | yes | integer | Brand id |
## Signals
On success, emits SSE signal: `brand` (see [`GET /events`](../events.md)).
## Response `200`
Image removed

View File

@@ -5,7 +5,8 @@ Protected. Requires a valid session cookie (`credentials: 'include'`).
Add or replace brand image
Uploads an image for the brand (AVIF, WebP, or octet-stream). Converted to AVIF full and thumbnail.
Replaces any existing image for this brand.
Replaces any existing image for this brand. Emits SSE signal `brand`
with payload `{ sender, brandId }`.
## Path parameters
@@ -22,6 +23,10 @@ Raw binary (`image/webp`).
Raw binary (`application/octet-stream`).
## Signals
On success, emits SSE signal: `brand` (see [`GET /events`](../events.md)).
## Response `201`
Image stored and linked

View File

@@ -1,10 +1,12 @@
# `PUT /brand`
# `POST /brand`
Protected. Requires a valid session cookie (`credentials: 'include'`).
Upsert brand
Create brand
Insert or update brand by `name` for the selected company. `gsprpinfo` optional.
Creates a brand for the selected company. Fails with `Brand already exists`
if the name is taken. Emits SSE signal `brand` with payload
`{ sender, brandId }` (`sender` echoes the caller's `x-client-id`).
## Body (JSON)
@@ -21,9 +23,13 @@ Insert or update brand by `name` for the selected company. `gsprpinfo` optional.
}
```
## Response `200`
## Signals
Upserted brand
On success, emits SSE signal: `brand` (see [`GET /events`](../events.md)).
## Response `201`
Created brand
```json
{
@@ -53,6 +59,7 @@ Upserted brand
| 401 | Unauthorized — `{"error":"…"}` |
| 403 | Not authorized — `{"error":"…"}` |
| 404 | Company not found — `{"error":"…"}` |
| 409 | Brand already exists — `{"error":"…"}` |
---

View File

@@ -5,7 +5,8 @@ Protected. Requires a valid session cookie (`credentials: 'include'`).
Delete brand
Deletes the brand for the selected company. Fails with `Brand in use`
if any article still references it.
if any article still references it. Emits SSE signal `brand`
with payload `{ sender, brandId }`.
## Path parameters
@@ -14,6 +15,10 @@ if any article still references it.
|-------|----------|------|-------------|
| `id` | yes | integer | |
## Signals
On success, emits SSE signal: `brand` (see [`GET /events`](../events.md)).
## Response `204`
Deleted

View File

@@ -0,0 +1,65 @@
# `PATCH /brand/{id}`
Protected. Requires a valid session cookie (`credentials: 'include'`).
Rename brand
Renames/updates a brand by id for the selected company. Fails with
`Brand already exists` if the name is taken by another brand.
When the name changes, linked articles (`brand_id`) get their
`updated_at` bumped; the response reports `touchedArticleCount`.
Emits SSE signal `brand` with payload `{ sender, brandId }`
(`sender` echoes the caller's `x-client-id`).
## Path parameters
| Param | Required | Type | Description |
|-------|----------|------|-------------|
| `id` | yes | integer | |
## Body (JSON)
| Field | Required | Type | Description |
|-------|----------|------|-------------|
| `name` | no | string | |
| `gsprpinfo` | no | string | |
```json
{
"name": "Acme GmbH"
}
```
## Signals
On success, emits SSE signal: `brand` (see [`GET /events`](../events.md)).
## Response `200`
Updated brand
```json
{
"brand": {
"id": 1,
"name": "…",
"gsprpinfo": "…",
"touchedArticleCount": 1
}
}
```
## Errors
| Status | Description |
|--------|-------------|
| 400 | Invalid brand, invalid id, or no company selected — `{"error":"…"}` |
| 401 | Unauthorized — `{"error":"…"}` |
| 403 | Not authorized — `{"error":"…"}` |
| 404 | Brand or company not found — `{"error":"…"}` |
| 409 | Brand already exists — `{"error":"…"}` |
---
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._

View File

@@ -29,6 +29,12 @@ to the company at connect time).
| `category` | `POST /category`, `PATCH /category/{id}`, `PUT /category/order`, `DELETE /category/{id}`, `POST /category/{id}/image`, `DELETE /category/{id}/image` |
| `articles` | `POST /article`, `PATCH /article/{sku}`, `DELETE /article/{sku}` |
| `article-<sku>` | `PUT /article/{sku}/weight`, `PUT /article/{sku}/prices`, `PUT /article/{sku}/eans`, `PUT /article/{sku}/categories`, `PUT /article/{sku}/brand`, `PUT /article/{sku}/images/order`, `POST /article/{sku}/image`, `DELETE /article/{sku}/image/{fullHash}` |
| `brand` | `POST /brand`, `PATCH /brand/{id}`, `DELETE /brand/{id}`, `POST /brand/{id}/image`, `DELETE /brand/{id}/image` |
The `brand` signal carries a JSON payload `{ sender, brandId }`:
`sender` echoes the caller's `x-client-id` header (empty string if
absent) so the sender can ignore its own event; `brandId` is the
affected brand id (`null` only if unknown). Other signals send `{}`.
Signals are only sent when the mutation actually succeeds (2xx).
Failed or no-op validation errors do not emit. The `article-<sku>`
@@ -38,7 +44,8 @@ event name uses the concrete SKU (e.g. `article-42000045`).
## Response `200`
SSE stream (`text/event-stream`). Each signal is an SSE event
whose name is the signal id and whose data is `{}`.
whose name is the signal id. Most signals send `{}` as data;
`brand` sends `{ "sender": "<x-client-id>", "brandId": 12 }`.
## Errors