docs: add JSDoc headers to all externally exported store functions

This commit is contained in:
seb
2026-08-07 03:58:48 +02:00
parent c290fe8f4b
commit 4833acd680
101 changed files with 1134 additions and 0 deletions

View File

@@ -9,6 +9,17 @@ import {
} from './helpers.js';
import { assertSupplier, insertLines } from './writeLines.js';
/**
* Creates a new delivery for a company with its lines.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that creates a delivery.
*
* @example
* const fn = create(pool);
* const delivery = await fn(42, 1, { number: 'D-1', date: '2026-01-01', supplierId: 5, lines: [...] });
* // => { id, number, type, entityId, date, lines: [...] }
*/
export default function create(pool) {
const access = resolveCompanyAccess(pool);
const ensureTax = taxEnsure(pool);

View File

@@ -1,6 +1,16 @@
import { DELETE_MANIFEST, DELIVERY_TYPE } from '../../sql/delivery.js';
import resolveCompanyAccess from '../companyuser/resolveCompanyAccess.js';
/**
* Deletes a delivery by its id within a company.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that deletes a delivery.
*
* @example
* const fn = del(pool);
* await fn(42, 1, 5);
*/
export default function del(pool) {
const access = resolveCompanyAccess(pool);

View File

@@ -1,6 +1,17 @@
import resolveCompanyAccess from '../companyuser/resolveCompanyAccess.js';
import { loadDelivery } from './helpers.js';
/**
* Returns a single delivery by its id within a company.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that fetches a delivery by id.
*
* @example
* const fn = getById(pool);
* const delivery = await fn(42, 1, 5);
* // => { id, number, type, entityId, date, lines: [...] }
*/
export default function getById(pool) {
const access = resolveCompanyAccess(pool);

View File

@@ -2,6 +2,17 @@ import { DELIVERY_TYPE, LIST_DELIVERIES } from '../../sql/delivery.js';
import resolveCompanyAccess from '../companyuser/resolveCompanyAccess.js';
import { shapeSummary } from './helpers.js';
/**
* Lists the deliveries of a company.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that lists deliveries.
*
* @example
* const fn = list(pool);
* const deliveries = await fn(42, 1);
* // => [{ id, number, type, entityId, date }]
*/
export default function list(pool) {
const access = resolveCompanyAccess(pool);

View File

@@ -15,6 +15,17 @@ import {
} from './helpers.js';
import { assertSupplier, insertLines } from './writeLines.js';
/**
* Updates a delivery's header and/or lines.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that updates a delivery.
*
* @example
* const fn = update(pool);
* const delivery = await fn(42, 1, 5, { number: 'D-2', lines: [...] });
* // => { id, number, type, entityId, date, lines: [...] }
*/
export default function update(pool) {
const access = resolveCompanyAccess(pool);
const ensureTax = taxEnsure(pool);