Rewrite store JSDoc, split quote/order into modules, and generate typed API docs
- 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
This commit is contained in:
@@ -7,22 +7,24 @@ import resolveCategoryAccess from '../category/resolveCategoryAccess.js';
|
||||
import queryBySku from './queryBySku.js';
|
||||
import resolveArticleBySku from './resolveArticleBySku.js';
|
||||
|
||||
/**
|
||||
* Replaces the category membership of an article by its SKU.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that sets the article categories.
|
||||
*
|
||||
* @example
|
||||
* const fn = setCategoryIdsBySku(pool);
|
||||
* const article = await fn(42, 'SKU-1', [5, 9]);
|
||||
* // => { id, sku, name, ... }
|
||||
*/
|
||||
export default function setCategoryIdsBySku(pool) {
|
||||
const resolve = resolveArticleBySku(pool);
|
||||
const categoryAccess = resolveCategoryAccess(pool);
|
||||
const load = queryBySku(pool);
|
||||
|
||||
/**
|
||||
* Replaces the category membership of an article by its SKU.
|
||||
*
|
||||
* @param {number} googleAuthId - The id of the Google auth user.
|
||||
* @param {string} sku - The article SKU.
|
||||
* @param {Array<number>} categoryIds - The category ids the article should belong to (at least one).
|
||||
* @returns {Promise<object>} The updated article.
|
||||
* @throws {Error} If the category ids are invalid or the article is not found.
|
||||
*
|
||||
* @example
|
||||
* const article = await store.article.setCategoryIdsBySku(42, 'SKU-1', [5, 9]);
|
||||
* // => { id, sku, name, ... }
|
||||
*/
|
||||
return async (googleAuthId, sku, categoryIds) => {
|
||||
if (!Array.isArray(categoryIds)) {
|
||||
throw new Error('Invalid categoryIds');
|
||||
|
||||
Reference in New Issue
Block a user