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,16 @@
import { DELETE_BY_COMPANY_AND_ID } from '../../sql/posterminal.js';
import resolveCompanyAccess from '../companyuser/resolveCompanyAccess.js';
/**
* Deletes a posterminal by its id within a company.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that deletes a posterminal.
*
* @example
* const fn = del(pool);
* await fn(42, 1, 5);
*/
export default function del(pool) {
const access = resolveCompanyAccess(pool);

View File

@@ -1,5 +1,17 @@
import { POSTERMINAL_IDS_BY_COMPANY } from '../../sql/posterminal.js';
/**
* Returns a map of category id to the posterminal ids assigned to it for a
* company.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that builds the category→posterminal map.
*
* @example
* const fn = getCategoryPosterminalIds(pool);
* const map = await fn(1);
* // => { 5: [1, 2], 9: [1] }
*/
export default function getCategoryPosterminalIds(pool) {
return async (companyId) => {
const result = await pool

View File

@@ -1,6 +1,17 @@
import { LIST_BY_COMPANY } from '../../sql/posterminal.js';
import resolveCompanyAccess from '../companyuser/resolveCompanyAccess.js';
/**
* Lists the posterminals of a company.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that lists posterminals.
*
* @example
* const fn = list(pool);
* const terminals = await fn(42, 1);
* // => [{ id, name, token, pairingpin }]
*/
export default function list(pool) {
const access = resolveCompanyAccess(pool);

View File

@@ -1,6 +1,17 @@
import { GET_BY_ID, SET_OFF, LIST_CATEGORY_IDS } from '../../sql/posterminal.js';
import resolveCompanyAccess from '../companyuser/resolveCompanyAccess.js';
/**
* Removes a category assignment from a posterminal (turns it off).
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that removes a category from a posterminal.
*
* @example
* const fn = setOff(pool);
* const result = await fn(42, 1, 5, 9);
* // => { id, categoryIds: [...] }
*/
export default function setOff(pool) {
const access = resolveCompanyAccess(pool);

View File

@@ -1,6 +1,17 @@
import { GET_BY_ID, SET_OFF_ALL, LIST_CATEGORY_IDS } from '../../sql/posterminal.js';
import resolveCompanyAccess from '../companyuser/resolveCompanyAccess.js';
/**
* Removes all category assignments from a posterminal.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that clears all categories from a posterminal.
*
* @example
* const fn = setOffAll(pool);
* const result = await fn(42, 1, 5);
* // => { id, categoryIds: [] }
*/
export default function setOffAll(pool) {
const access = resolveCompanyAccess(pool);

View File

@@ -1,6 +1,17 @@
import { GET_BY_ID, SET_ON, LIST_CATEGORY_IDS } from '../../sql/posterminal.js';
import resolveCompanyAccess from '../companyuser/resolveCompanyAccess.js';
/**
* Assigns a category to a posterminal (turns it on for that category).
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that assigns a category to a posterminal.
*
* @example
* const fn = setOn(pool);
* const result = await fn(42, 1, 5, 9);
* // => { id, categoryIds: [9, ...] }
*/
export default function setOn(pool) {
const access = resolveCompanyAccess(pool);

View File

@@ -2,6 +2,17 @@ import { GET_BY_ID, SET_ON_ALL, LIST_CATEGORY_IDS } from '../../sql/posterminal.
import resolveCompanyAccess from '../companyuser/resolveCompanyAccess.js';
import { GET_COMPANY_ROOT_CATEGORY } from '../../sql/company.js';
/**
* Assigns all categories of a company to a posterminal.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that assigns all categories to a posterminal.
*
* @example
* const fn = setOnAll(pool);
* const result = await fn(42, 1, 5);
* // => { id, categoryIds: [...] }
*/
export default function setOnAll(pool) {
const access = resolveCompanyAccess(pool);

View File

@@ -1,6 +1,17 @@
import { GET_BY_ID, CREATE, UPDATE } from '../../sql/posterminal.js';
import resolveCompanyAccess from '../companyuser/resolveCompanyAccess.js';
/**
* Creates or updates a posterminal for a company.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that upserts a posterminal.
*
* @example
* const fn = upsert(pool);
* const terminal = await fn(42, 1, { name: 'Kasse 1', pairingpin: '1234', token: 'abc' });
* // => { id, name, token, pairingpin }
*/
export default function upsert(pool) {
const access = resolveCompanyAccess(pool);