- Rewrite JSDoc across all store methods to document the actual async methods (real params, returns, throws) instead of the internal wrappers - Split quote/order into individual module files backed by shared manifestDoc helpers; remove the createStore factory and thin wrappers - Deduplicate manifest line helpers into src/store/manifestLines.js - Extend generate-api-doc.js to render parameter/return/throws types and emit per-namespace API.<module>.md files with an API.md index - Regenerate all API docs
5.9 KiB
category
This document is auto-generated from the JSDoc comments in src/store by running npm run api-doc.
category.addImage
Source: src/store/category/addImage.js
Adds an image to a category, processing it into AVIF full and thumb variants.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
categoryId |
number |
The id of the category. |
image |
Buffer |
The source image buffer. |
Returns
Promise<{id: number, fullHash: string, thumbW: number, thumbH: number, thumbHash: string}> — The added image info.
Example
const result = await store.category.addImage(42, 5, imageBuffer);
// => { id, fullHash, thumbW, thumbH, thumbHash }
category.createUnderParent
Source: src/store/category/createUnderParent.js
Creates a new category under a given parent category.
Parameters
| Name | Type | Description |
|---|---|---|
input |
object |
The category creation input. |
input.googleAuthId |
number |
The id of the Google auth user. |
input.parentId |
number |
The id of the parent category. |
input.name |
string |
The category name. |
Returns
Promise<{id: number, parentId: number, sort: number, name: string, slug: string}> — The created category.
Example
const category = await store.category.createUnderParent({ googleAuthId: 42, parentId: 5, name: 'Drinks' });
// => { id, parentId, sort, name, slug }
category.delete
Source: src/store/category/delete.js
Deletes a category, refusing to delete the company's root category.
Parameters
| Name | Type | Description |
|---|---|---|
input |
object |
The delete input. |
input.googleAuthId |
number |
The id of the Google auth user. |
input.id |
number |
The id of the category to delete. |
Returns
Promise<void>
Throws
Error — If the category is the root category.
Example
await store.category.delete({ googleAuthId: 42, id: 5 });
category.deleteImage
Source: src/store/category/deleteImage.js
Deletes the image of a category.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
categoryId |
number |
The id of the category. |
Returns
Promise<{id: number, thumbW: null, thumbH: null, thumbHash: null}> — The cleared image info.
Throws
Error — If the image is not found.
Example
const result = await store.category.deleteImage(42, 5);
// => { id: 5, thumbW: null, thumbH: null, thumbHash: null }
category.getCategoryArticles
Source: src/store/category/getCategoryArticles.js
Returns the articles belonging to a single category.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
categoryId |
number |
The id of the category. |
Returns
Promise<Array<object>> — The articles in the category.
Example
const articles = await store.category.getCategoryArticles(42, 5);
// => [{ id, sku, name, ... }]
category.getTreeForCompany
Source: src/store/category/getTreeForCompany.js
Returns the full category tree for the user's selected company together with its articles and the posterminal ids assigned to each category.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
Returns
Promise<{languageId: number, tree: Array<object>, articles: Array<object>}> — The category tree, articles and language.
Example
const tree = await store.category.getTreeForCompany(42);
// => { languageId, tree: [{ id, posterminalIds, ... }], articles: [...] }
category.move
Source: src/store/category/move.js
Moves a category to a new parent, preventing cycles and cross-company moves.
Parameters
| Name | Type | Description |
|---|---|---|
input |
object |
The move input. |
input.googleAuthId |
number |
The id of the Google auth user. |
input.id |
number |
The id of the category to move. |
input.parentId |
number |
The id of the new parent category. |
Returns
Promise<{id: number, parentId: number, sort: number}> — The moved category.
Throws
Error — If the move would create a cycle or cross companies.
Example
const result = await store.category.move({ googleAuthId: 42, id: 5, parentId: 9 });
// => { id, parentId, sort }
category.order
Source: src/store/category/order.js
Reorders the child categories of a given parent.
Parameters
| Name | Type | Description |
|---|---|---|
input |
object |
The reorder input. |
input.googleAuthId |
number |
The id of the Google auth user. |
input.parentId |
number |
The id of the parent category. |
input.categoryIds |
Array<number> |
The child category ids in their new order. |
Returns
Promise<{categoryIds: Array<number>}> — The applied order.
Throws
Error — If the order is invalid.
Example
const result = await store.category.order({ googleAuthId: 42, parentId: 5, categoryIds: [3, 1, 2] });
// => { categoryIds: [3, 1, 2] }
category.rename
Source: src/store/category/rename.js
Renames a category and updates its slug.
Parameters
| Name | Type | Description |
|---|---|---|
input |
object |
The rename input. |
input.googleAuthId |
number |
The id of the Google auth user. |
input.id |
number |
The id of the category to rename. |
input.name |
string |
The new category name. |
Returns
Promise<{id: number, name: string, slug: string}> — The renamed category.
Throws
Error — If the name is empty or the category is not found.
Example
const result = await store.category.rename({ googleAuthId: 42, id: 5, name: 'Soft Drinks' });
// => { id, name, slug }