From c80bfee8e8fc43e8171daae801af268b125e605c Mon Sep 17 00:00:00 2001 From: seb Date: Sun, 4 Oct 2026 19:38:12 +0200 Subject: [PATCH] u --- API.article.md | 30 ++++++++++++++++++++- API.articleproperty.md | 2 +- API.attributename.md | 8 ++++++ API.attributevalue.md | 8 ++++++ API.md | 3 ++- API.propertyname.md | 8 ++++++ src/store/category/queryCategoryArticles.js | 3 +++ 7 files changed, 59 insertions(+), 3 deletions(-) diff --git a/API.article.md b/API.article.md index 4d8dd1f..45e6a63 100644 --- a/API.article.md +++ b/API.article.md @@ -6,7 +6,7 @@ This document is auto-generated from the JSDoc comments in `src/store` by runnin *Source: `src/store/article/addChild.js`* -Adds a child article to a father article. +Adds a child article to a father article (creates and attaches with auto-generated SKU). **Parameters** @@ -15,6 +15,7 @@ Adds a child article to a father article. | `googleAuthId` | `number` | The id of the Google auth user. | | `fatherSku` | `string` | The father article SKU. | | `options` | `object` | | +| `[options.attach=false]` | `boolean` | If true, attaches an existing article instead of creating. | | `[options.attributeValueId]` | `number` | Existing attribute value ID for father's attribute. | | `[options.value]` | `string` | String value to find or create under father's attribute. | | `[options.name]` | `string` | Custom name for child article (defaults to father name + value). | @@ -53,6 +54,33 @@ const result = await store.article.addImage(42, 'SKU-1', imageBuffer); // => { picId, sort, full: { w, h, size }, thumb: { w, h }, fullHash, thumbHash } ``` +## `article.attachChild` + +*Source: `src/store/article/attachChild.js`* + +Attaches an existing article as a child to a father article. + +**Parameters** + +| Name | Type | Description | +| --- | --- | --- | +| `googleAuthId` | `number` | The id of the Google auth user. | +| `fatherSku` | `string` | The father article SKU. | +| `options` | `object` | | +| `options.sku` | `string` | The child article SKU to attach. | +| `[options.childSku]` | `string` | Alias for options.sku. | +| `[options.attributeValueId]` | `number` | Existing attribute value ID for father's attribute. | +| `[options.value]` | `string` | String value to find or create under father's attribute. | +| `[options.reparent=false]` | `boolean` | Whether to allow re-parenting if child belongs to another father. | +| `[options.unitamount]` | `number` | Optional unitamount override. | +| `[options.weight]` | `number` | Optional weight override. | +| `[options.track_stock]` | `boolean|number` | Optional track_stock override. | +| `[tx]` | `object` | Optional transaction. | + +**Returns** + +`Promise<{article: object, children: Array}>` + ## `article.createUnderParent` *Source: `src/store/article/createUnderParent.js`* diff --git a/API.articleproperty.md b/API.articleproperty.md index c0161d2..10fb793 100644 --- a/API.articleproperty.md +++ b/API.articleproperty.md @@ -43,7 +43,7 @@ Lists the properties of an article by its SKU. *Source: `src/store/articleproperty/setByArticleSku.js`* -Replaces all properties for an article by its SKU. Enforces exclusive flag on property names. +Replaces all properties for an article by its SKU. Enforces exclusive flag on property names. An exclusive property that already has a value is never overwritten: a different value throws `Exclusive property cannot be overwritten: `. **Parameters** diff --git a/API.attributename.md b/API.attributename.md index 5fba52c..c5a1dbe 100644 --- a/API.attributename.md +++ b/API.attributename.md @@ -23,6 +23,10 @@ Creates an attribute name for the user's selected company. `Promise<{id: number, name: string, sort: number, exclusive: boolean, values: Array}>` +**Throws** + +`Error` — If the name is missing or already exists for the company. + ## `attributename.delete` *Source: `src/store/attributename/delete.js`* @@ -102,3 +106,7 @@ Updates an attribute name for the user's selected company. **Returns** `Promise<{id: number, name: string, sort: number, exclusive: boolean, values: Array}>` + +**Throws** + +`Error` — If the attribute name is unknown, the name is missing, or the name is already taken. diff --git a/API.attributevalue.md b/API.attributevalue.md index 3df3164..0dd9a61 100644 --- a/API.attributevalue.md +++ b/API.attributevalue.md @@ -23,6 +23,10 @@ Creates an attribute value under a given attribute. `Promise<{id: number, attributeId: number, value: string, sort: number}>` +**Throws** + +`Error` — If the value is missing, the attribute is unknown, or the value already exists for the attribute. + ## `attributevalue.delete` *Source: `src/store/attributevalue/delete.js`* @@ -103,3 +107,7 @@ Updates an attribute value. **Returns** `Promise<{id: number, attributeId: number, value: string, sort: number}>` + +**Throws** + +`Error` — If the attribute value is unknown, the value is missing, or the value is already taken. diff --git a/API.md b/API.md index 1c6e75a..95eb1c1 100644 --- a/API.md +++ b/API.md @@ -86,8 +86,9 @@ The store is exposed as a `LibDashStore` instance (see `src/index.js`). Each met - `order(input: {googleAuthId: number, parentId: number, categoryIds: Array}, tx?: object): Promise<{categoryIds: Array}>` - `rename(input: {googleAuthId: number, id: number, name: string}, tx?: object): Promise<{id: number, name: string, slug: string}>` - [article](API.article.md) - - `addChild(googleAuthId: number, fatherSku: string, options: {attributeValueId?: number, value?: string, name?: string, unitamount?: number, weight?: number, track_stock?: boolean|number}, tx?: object): Promise` + - `addChild(googleAuthId: number, fatherSku: string, options: {attach?: boolean, attributeValueId?: number, value?: string, name?: string, unitamount?: number, weight?: number, track_stock?: boolean|number}, tx?: object): Promise` - `addImage(googleAuthId: number, sku: string, image: Buffer, tx?: object): Promise<{picId: number, sort: number, full: {w: number, h: number, size: number}, thumb: {w: number, h: number}, fullHash: string, thumbHash: string}>` + - `attachChild(googleAuthId: number, fatherSku: string, options: {sku: string, childSku?: string, attributeValueId?: number, value?: string, reparent?: boolean, unitamount?: number, weight?: number, track_stock?: boolean|number}, tx?: object): Promise<{article: object, children: Array}>` - `createUnderParent(input: {googleAuthId: number, parentId: number, name: string, track_stock?: boolean|number}, tx?: object): Promise<{id: number, parentId: number, name: string, sku: string, track_stock: boolean}>` - `delete(googleAuthId: number, sku: string, optionsOrTx?: object|*, maybeTx?: object): Promise` - `deleteImage(googleAuthId: number, sku: string, fullHash: string, tx?: object): Promise` diff --git a/API.propertyname.md b/API.propertyname.md index 498555e..225bb6a 100644 --- a/API.propertyname.md +++ b/API.propertyname.md @@ -23,6 +23,10 @@ Creates a property name for the user's selected company. `Promise<{id: number, name: string, sort: number, exclusive: boolean}>` +**Throws** + +`Error` — If the name is missing or already exists for the company. + ## `propertyname.delete` *Source: `src/store/propertyname/delete.js`* @@ -102,3 +106,7 @@ Updates a property name for the user's selected company. **Returns** `Promise<{id: number, name: string, sort: number, exclusive: boolean}>` + +**Throws** + +`Error` — If the property name is unknown, the name is missing, or the name is already taken. diff --git a/src/store/category/queryCategoryArticles.js b/src/store/category/queryCategoryArticles.js index 366b0b6..951bc1b 100644 --- a/src/store/category/queryCategoryArticles.js +++ b/src/store/category/queryCategoryArticles.js @@ -25,6 +25,9 @@ export default function queryCategoryArticles(provider) { return { ...rest, track_stock: Boolean(rest.track_stock ?? 1), + // MSSQL returns BIT as boolean, SQLite as 0/1 integer. Normalize so both + // dialects expose isFather as a real boolean, matching article/getBySku. + isFather: Boolean(rest.isFather), brand: brandName ? { id: brandId ?? null,