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

@@ -15,6 +15,17 @@ function shape(row) {
};
}
/**
* Creates a new entity (customer) in a customer group, recording history.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that creates an entity.
*
* @example
* const fn = create(pool);
* const entity = await fn(42, 1, { customergroupId: 5, name: 'Doe', firstName: 'John' });
* // => { id, customergroupId, firstName, name, createdAt, updatedAt }
*/
export default function create(pool) {
const access = resolveCompanyAccess(pool);
const groupAccess = resolveCustomerGroupAccess(pool);

View File

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

View File

@@ -12,6 +12,17 @@ function shape(row) {
};
}
/**
* Returns a single entity by its id within a company.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that fetches an entity by id.
*
* @example
* const fn = getById(pool);
* const entity = await fn(42, 1, 5);
* // => { id, customergroupId, firstName, name, createdAt, updatedAt }
*/
export default function getById(pool) {
const access = resolveCompanyAccess(pool);

View File

@@ -19,6 +19,18 @@ function shape(row) {
};
}
/**
* Lists the entities (customers) of a company, optionally filtered by customer
* group or restricted to the 'customer' role.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that lists entities.
*
* @example
* const fn = list(pool);
* const entities = await fn(42, 1, { customergroupId: 5 });
* // => [{ id, customergroupId, firstName, name, createdAt, updatedAt }]
*/
export default function list(pool) {
const access = resolveCompanyAccess(pool);
const groupAccess = resolveCustomerGroupAccess(pool);

View File

@@ -14,6 +14,17 @@ function shape(row) {
};
}
/**
* Updates the name and/or first name of an entity, recording history.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that updates an entity.
*
* @example
* const fn = update(pool);
* const entity = await fn(42, 1, 5, { name: 'Doe', firstName: 'Jane' });
* // => { id, customergroupId, firstName, name, createdAt, updatedAt }
*/
export default function update(pool) {
const access = resolveCompanyAccess(pool);