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,23 +7,25 @@ import nextSku from '../numbers/nextSku.js';
|
||||
import request from '../request.js';
|
||||
import slugify from '../slugify.js';
|
||||
|
||||
/**
|
||||
* Creates a new article under a given parent category, allocating a SKU and
|
||||
* a default unit.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that creates an article.
|
||||
*
|
||||
* @example
|
||||
* const fn = createUnderParent(pool);
|
||||
* const article = await fn({ googleAuthId: 42, parentId: 5, name: 'Cola' });
|
||||
* // => { id, parentId, name, sku }
|
||||
*/
|
||||
export default function createUnderParent(pool) {
|
||||
const access = resolveCategoryAccess(pool);
|
||||
const ensureUnit = ensureDefaultUnit(pool);
|
||||
const allocateSku = nextSku(pool);
|
||||
|
||||
/**
|
||||
* Creates a new article under a given parent category, allocating a SKU and
|
||||
* a default unit.
|
||||
*
|
||||
* @param {object} input - The article creation input.
|
||||
* @param {number} input.googleAuthId - The id of the Google auth user.
|
||||
* @param {number} input.parentId - The id of the parent category.
|
||||
* @param {string} input.name - The article name.
|
||||
* @returns {Promise<{id: number, parentId: number, name: string, sku: string}>} The created article.
|
||||
*
|
||||
* @example
|
||||
* const article = await store.article.createUnderParent({ googleAuthId: 42, parentId: 5, name: 'Cola' });
|
||||
* // => { id, parentId, name, sku }
|
||||
*/
|
||||
return async ({ googleAuthId, parentId, name }) => {
|
||||
const { companyId, languageId } = await access(googleAuthId, parentId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user