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:
@@ -2,6 +2,18 @@ import { ENSURE_TYPE } from '../../sql/numbers.js';
|
||||
import request from '../request.js';
|
||||
|
||||
export default function nextNumber(pool) {
|
||||
/**
|
||||
* Allocates and returns the next number for a company and type, consuming it.
|
||||
*
|
||||
* @param {number} companyId - The id of the company.
|
||||
* @param {string} type - The number type (e.g. `'entity'`, `'sku'`).
|
||||
* @param {object} [tx] - Optional transaction to run within.
|
||||
* @returns {Promise<string>} The allocated number.
|
||||
*
|
||||
* @example
|
||||
* const number = await store.numbers.next(1, 'entity');
|
||||
* // => '1'
|
||||
*/
|
||||
return async (companyId, type, tx) => {
|
||||
await request(pool, tx)
|
||||
.input('companyId', companyId)
|
||||
|
||||
@@ -2,5 +2,16 @@ import nextNumber from './nextNumber.js';
|
||||
|
||||
export default function nextSku(pool) {
|
||||
const allocate = nextNumber(pool);
|
||||
/**
|
||||
* Allocates and returns the next SKU for a company, consuming it.
|
||||
*
|
||||
* @param {number} companyId - The id of the company.
|
||||
* @param {object} [tx] - Optional transaction to run within.
|
||||
* @returns {Promise<string>} The allocated SKU.
|
||||
*
|
||||
* @example
|
||||
* const sku = await store.numbers.nextSku(1);
|
||||
* // => '1'
|
||||
*/
|
||||
return (companyId, tx) => allocate(companyId, 'sku', tx);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,18 @@ import { ENSURE_TYPE } from '../../sql/numbers.js';
|
||||
import request from '../request.js';
|
||||
|
||||
export default function peekNumber(pool) {
|
||||
/**
|
||||
* Returns the next number for a company and type without consuming it.
|
||||
*
|
||||
* @param {number} companyId - The id of the company.
|
||||
* @param {string} type - The number type (e.g. `'entity'`, `'sku'`).
|
||||
* @param {object} [tx] - Optional transaction to run within.
|
||||
* @returns {Promise<string>} The next number.
|
||||
*
|
||||
* @example
|
||||
* const number = await store.numbers.peek(1, 'entity');
|
||||
* // => '1'
|
||||
*/
|
||||
return async (companyId, type, tx) => {
|
||||
await request(pool, tx)
|
||||
.input('companyId', companyId)
|
||||
|
||||
Reference in New Issue
Block a user