This commit is contained in:
seb
2026-10-20 23:21:48 +02:00
parent 5a5981dc07
commit b7058df5d2
16 changed files with 345 additions and 1063 deletions

View File

@@ -56,15 +56,8 @@ export function register(app, basePath = '') {
* The attributename id used for the article's variants. Omitting it while
* enabling parent mode returns 400. Must be omitted when `isParent` is `false`.
* responses:
* 200:
* description: Updated article
* content:
* application/json:
* schema:
* type: object
* properties:
* article:
* $ref: '#/components/schemas/Article'
* 204:
* description: Updated
* 400:
* description: |
* Invalid input — `attributeNameId` missing while `isParent` is true, article still
@@ -89,13 +82,13 @@ export function register(app, basePath = '') {
const attributeNameId = req.body?.attributeNameId;
try {
const result = await db.toggleParent(req.user.id, parsed.sku, {
await db.toggleParent(req.user.id, parsed.sku, {
isParent,
attributeNameId,
});
emitArticleSignal(req, parsed.sku);
emitArticlesSignal(req);
res.status(200).json(result);
res.status(204).end();
} catch (error) {
const status = articleErrorStatus(error);
if (status === 500) console.error('Toggle parent failed:', error);
@@ -196,8 +189,8 @@ export function register(app, basePath = '') {
* schema:
* type: object
* properties:
* article:
* $ref: '#/components/schemas/Article'
* sku:
* type: string
* 400:
* description: Parent not configured as parent, missing value, duplicate variant, or sku was provided in body
* put:
@@ -237,14 +230,12 @@ export function register(app, basePath = '') {
* description: Whether to allow re-parenting if child already belongs to another parent
* responses:
* 200:
* description: Attached child article and list of children
* description: List of children after attaching
* content:
* application/json:
* schema:
* type: object
* properties:
* article:
* $ref: '#/components/schemas/Article'
* children:
* type: array
* items:
@@ -275,7 +266,7 @@ export function register(app, basePath = '') {
emitArticleSignal(req, result.article.sku);
}
emitArticlesSignal(req);
res.status(201).json(result);
res.status(201).json({ sku: result.article.sku });
} catch (error) {
const status = articleErrorStatus(error);
if (status === 500) console.error('Add child failed:', error);
@@ -303,7 +294,7 @@ export function register(app, basePath = '') {
emitArticleSignal(req, parsed.sku);
emitArticleSignal(req, childSku);
emitArticlesSignal(req);
res.status(200).json(result);
res.status(200).json({ children: result.children });
} catch (error) {
const status = articleErrorStatus(error);
if (status === 500) console.error('Attach child failed:', error);