This commit is contained in:
seb
2026-10-04 19:38:12 +02:00
parent 067ddc088c
commit c80bfee8e8
7 changed files with 59 additions and 3 deletions

View File

@@ -6,7 +6,7 @@ This document is auto-generated from the JSDoc comments in `src/store` by runnin
*Source: `src/store/article/addChild.js`* *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** **Parameters**
@@ -15,6 +15,7 @@ Adds a child article to a father article.
| `googleAuthId` | `number` | The id of the Google auth user. | | `googleAuthId` | `number` | The id of the Google auth user. |
| `fatherSku` | `string` | The father article SKU. | | `fatherSku` | `string` | The father article SKU. |
| `options` | `object` | | | `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.attributeValueId]` | `number` | Existing attribute value ID for father's attribute. |
| `[options.value]` | `string` | String value to find or create under 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). | | `[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 } // => { 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<object>}>`
## `article.createUnderParent` ## `article.createUnderParent`
*Source: `src/store/article/createUnderParent.js`* *Source: `src/store/article/createUnderParent.js`*

View File

@@ -43,7 +43,7 @@ Lists the properties of an article by its SKU.
*Source: `src/store/articleproperty/setByArticleSku.js`* *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: <name>`.
**Parameters** **Parameters**

View File

@@ -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}>` `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` ## `attributename.delete`
*Source: `src/store/attributename/delete.js`* *Source: `src/store/attributename/delete.js`*
@@ -102,3 +106,7 @@ Updates an attribute name for the user's selected company.
**Returns** **Returns**
`Promise<{id: number, name: string, sort: number, exclusive: boolean, values: Array}>` `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.

View File

@@ -23,6 +23,10 @@ Creates an attribute value under a given attribute.
`Promise<{id: number, attributeId: number, value: string, sort: number}>` `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` ## `attributevalue.delete`
*Source: `src/store/attributevalue/delete.js`* *Source: `src/store/attributevalue/delete.js`*
@@ -103,3 +107,7 @@ Updates an attribute value.
**Returns** **Returns**
`Promise<{id: number, attributeId: number, value: string, sort: number}>` `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.

3
API.md
View File

@@ -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<number>}, tx?: object): Promise<{categoryIds: Array<number>}>` - `order(input: {googleAuthId: number, parentId: number, categoryIds: Array<number>}, tx?: object): Promise<{categoryIds: Array<number>}>`
- `rename(input: {googleAuthId: number, id: number, name: string}, tx?: object): Promise<{id: number, name: string, slug: string}>` - `rename(input: {googleAuthId: number, id: number, name: string}, tx?: object): Promise<{id: number, name: string, slug: string}>`
- [article](API.article.md) - [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<object>` - `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<object>`
- `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}>` - `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<object>}>`
- `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}>` - `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<void>` - `delete(googleAuthId: number, sku: string, optionsOrTx?: object|*, maybeTx?: object): Promise<void>`
- `deleteImage(googleAuthId: number, sku: string, fullHash: string, tx?: object): Promise<void>` - `deleteImage(googleAuthId: number, sku: string, fullHash: string, tx?: object): Promise<void>`

View File

@@ -23,6 +23,10 @@ Creates a property name for the user's selected company.
`Promise<{id: number, name: string, sort: number, exclusive: boolean}>` `Promise<{id: number, name: string, sort: number, exclusive: boolean}>`
**Throws**
`Error` — If the name is missing or already exists for the company.
## `propertyname.delete` ## `propertyname.delete`
*Source: `src/store/propertyname/delete.js`* *Source: `src/store/propertyname/delete.js`*
@@ -102,3 +106,7 @@ Updates a property name for the user's selected company.
**Returns** **Returns**
`Promise<{id: number, name: string, sort: number, exclusive: boolean}>` `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.

View File

@@ -25,6 +25,9 @@ export default function queryCategoryArticles(provider) {
return { return {
...rest, ...rest,
track_stock: Boolean(rest.track_stock ?? 1), 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 brand: brandName
? { ? {
id: brandId ?? null, id: brandId ?? null,