docs: add JSDoc headers to all externally exported store functions
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user