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

@@ -1,6 +1,17 @@
import { CREATE } from '../../sql/tax.js';
import request from '../request.js';
/**
* Creates a new tax rate.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that creates a tax rate.
*
* @example
* const fn = create(pool);
* const id = await fn(19);
* // => 1
*/
export default function create(pool) {
return async (rate, tx) => {
const result = await request(pool, tx)

View File

@@ -1,6 +1,17 @@
import getByRate from './getByRate.js';
import create from './create.js';
/**
* Returns the id of a tax rate, creating it if it does not exist.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that ensures a tax rate exists.
*
* @example
* const fn = ensure(pool);
* const id = await fn(19);
* // => 1
*/
export default function ensure(pool) {
const get = getByRate(pool);
const add = create(pool);

View File

@@ -1,6 +1,17 @@
import { GET_BY_RATE } from '../../sql/tax.js';
import request from '../request.js';
/**
* Returns a tax row by its rate.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that fetches a tax rate.
*
* @example
* const fn = getByRate(pool);
* const tax = await fn(19);
* // => { id, rate }
*/
export default function getByRate(pool) {
return async (rate, tx) => {
const result = await request(pool, tx)

View File

@@ -1,5 +1,16 @@
import { LIST } from '../../sql/tax.js';
/**
* Lists all tax rates.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that lists tax rates.
*
* @example
* const fn = list(pool);
* const taxes = await fn();
* // => [{ id, rate }]
*/
export default function list(pool) {
return async () => {
const result = await pool.request().query(LIST);