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:
seb
2026-08-07 06:23:17 +02:00
parent 396389457f
commit aefd97a171
127 changed files with 3956 additions and 1684 deletions

View File

@@ -24,21 +24,32 @@ function optionalString(value) {
return s || null;
}
/**
* Creates a new address for an entity.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that creates an entity address.
*
* @example
* const fn = create(pool);
* const address = await fn(42, 5, { addressType: 'billing', street: 'Main St', city: 'Berlin' });
* // => { id, entityId, firstName, name, street, streetNumber, zip, city, county, addressType, sort }
*/
export default function create(pool) {
const access = resolveSelectedCompanyAccess(pool);
const entityAccess = resolveEntityAccess(pool);
/**
* Creates a new address for an entity.
*
* @param {number} googleAuthId - The id of the Google auth user.
* @param {number} entityId - The id of the entity.
* @param {object} input - The address input.
* @param {string} input.addressType - The address type (e.g. `'billing'`).
* @param {string} [input.firstName] - The first name.
* @param {string} [input.name] - The name.
* @param {string} [input.street] - The street.
* @param {string} [input.streetNumber] - The street number.
* @param {string} [input.zip] - The zip code.
* @param {string} [input.city] - The city.
* @param {string} [input.county] - The county.
* @param {number} [input.sort] - Optional sort order.
* @returns {Promise<object>} The created address.
* @throws {Error} If the address type is missing.
*
* @example
* const address = await store.entityaddress.create(42, 5, { addressType: 'billing', street: 'Main St', city: 'Berlin' });
* // => { id, entityId, firstName, name, street, streetNumber, zip, city, county, addressType, sort }
*/
return async (googleAuthId, entityId, input = {}) => {
const addressType = input.addressType?.trim?.()
? input.addressType.trim()

View File

@@ -2,20 +2,22 @@ import { DELETE_BY_ENTITY_AND_ID } from '../../sql/entityaddress.js';
import resolveSelectedCompanyAccess from '../companyuser/resolveSelectedCompanyAccess.js';
import resolveEntityAccess from '../entity/resolveEntityAccess.js';
/**
* Deletes an address of an entity.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that deletes an entity address.
*
* @example
* const fn = del(pool);
* await fn(42, 5, 9);
*/
export default function del(pool) {
const access = resolveSelectedCompanyAccess(pool);
const entityAccess = resolveEntityAccess(pool);
/**
* Deletes an address of an entity.
*
* @param {number} googleAuthId - The id of the Google auth user.
* @param {number} entityId - The id of the entity.
* @param {number} id - The id of the address to delete.
* @returns {Promise<void>}
* @throws {Error} If the address is not found.
*
* @example
* await store.entityaddress.delete(42, 5, 9);
*/
return async (googleAuthId, entityId, id) => {
if (!Number.isFinite(id)) {
throw new Error('Address not found');

View File

@@ -18,21 +18,21 @@ function shape(row) {
};
}
/**
* Lists the addresses of an entity.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that lists entity addresses.
*
* @example
* const fn = list(pool);
* const addresses = await fn(42, 5);
* // => [{ id, entityId, firstName, name, street, streetNumber, zip, city, county, addressType, sort }]
*/
export default function list(pool) {
const access = resolveSelectedCompanyAccess(pool);
const entityAccess = resolveEntityAccess(pool);
/**
* Lists the addresses of an entity.
*
* @param {number} googleAuthId - The id of the Google auth user.
* @param {number} entityId - The id of the entity.
* @returns {Promise<Array<object>>} The addresses.
*
* @example
* const addresses = await store.entityaddress.list(42, 5);
* // => [{ id, entityId, firstName, name, street, streetNumber, zip, city, county, addressType, sort }]
*/
return async (googleAuthId, entityId) => {
const { companyId } = await access(googleAuthId);
await entityAccess(companyId, entityId);

View File

@@ -24,21 +24,24 @@ function optionalString(value) {
return s || null;
}
/**
* Updates an address of an entity.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that updates an entity address.
*
* @example
* const fn = update(pool);
* const address = await fn(42, 5, 9, { city: 'Hamburg' });
* // => { id, entityId, firstName, name, street, streetNumber, zip, city, county, addressType, sort }
*/
export default function update(pool) {
const access = resolveSelectedCompanyAccess(pool);
const entityAccess = resolveEntityAccess(pool);
/**
* Updates an address of an entity.
*
* @param {number} googleAuthId - The id of the Google auth user.
* @param {number} entityId - The id of the entity.
* @param {number} id - The id of the address to update.
* @param {object} patch - The update patch (any subset of address fields).
* @returns {Promise<object>} The updated address.
* @throws {Error} If the address is not found.
*
* @example
* const address = await store.entityaddress.update(42, 5, 9, { city: 'Hamburg' });
* // => { id, entityId, firstName, name, street, streetNumber, zip, city, county, addressType, sort }
*/
return async (googleAuthId, entityId, id, patch = {}) => {
if (!Number.isFinite(id)) {
throw new Error('Address not found');