Files
dashlibstorage/API.category.md
seb af416246b4 feat(article): add article import with V/K compound linking
Add article.importRows to create articles by SKU from CSV-style rows,
running in two passes so fatherSku links to rows later in the file still
resolve. Existing SKUs are skipped, duplicate EANs are dropped, prices and
taxes are ensured, brands are upserted by name, and parent categories are
resolved/created via breadcrumb path.

Also add:
- article.setFatherBySku to link/unlink a child to its father article
- category.ensureByPath to resolve or create categories by path (tx-aware)
- supporting SQL constants (GET_ID_BY_SKU, EAN_EXISTS, father-link helpers,
  GET_BY_PARENT_AND_NAME)
- regenerated API docs
2026-08-11 05:36:07 +02:00

6.7 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.ensureByPath

Source: src/store/category/ensureByPath.js

Resolves a category by breadcrumb path under a given parent, creating any missing categories along the way. Returns the leaf category id.

Parameters

Name Type Description
input object The category resolution input.
input.googleAuthId number The id of the Google auth user.
input.parentId number The id of the parent category to start from.
input.path string The breadcrumb path, e.g. `'Haupt
[tx] object Optional transaction to run within.

Returns

Promise<number> — The id of the leaf category.

Example

const id = await store.category.ensureByPath({ googleAuthId: 42, parentId: 5, path: 'Haupt | Flowers | CBN' });
// => 12

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 }