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

@@ -11,6 +11,24 @@ import langEnsure from '../lang/ensure.js';
import taxEnsure from '../tax/ensure.js';
import request from '../request.js';
/**
* Creates a new company together with its root category, POS customer group,
* default language and tax rates, and links it to the given Google auth user.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that creates a company.
*
* @example
* const fn = create(pool);
* const company = await fn({
* iso639: 'de',
* name: 'Acme',
* taxrate: 19,
* reducedtaxrate: 7,
* googleAuthId: 42,
* });
* // => { id, rootCategoryId, languageId, taxrateId, reducedtaxrateId, taxfreerateId, posCustomerGroupId }
*/
export default function create(pool) {
const nameTaken = getByName(pool);
const ensureLang = langEnsure(pool);

View File

@@ -1,5 +1,15 @@
import { DELETE } from '../../sql/company.js';
/**
* Deletes a company by its id.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that deletes a company.
*
* @example
* const fn = del(pool);
* await fn(1);
*/
export default function del(pool) {
return async (companyId) => {
await pool

View File

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

View File

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

View File

@@ -1,5 +1,16 @@
import { LIST } from '../../sql/company.js';
/**
* Lists the companies accessible to the given Google auth user.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that lists companies.
*
* @example
* const fn = list(pool);
* const companies = await fn(42);
* // => [{ id, name, ... }]
*/
export default function list(pool) {
return async (googleAuthId) => {
const result = await pool

View File

@@ -5,6 +5,17 @@ import langEnsure from '../lang/ensure.js';
import taxEnsure from '../tax/ensure.js';
import request from '../request.js';
/**
* Updates an existing company's name, language and tax rates.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that updates a company.
*
* @example
* const fn = update(pool);
* const result = await fn(1, { iso639: 'de', name: 'Acme', taxrate: 19, reducedtaxrate: 7 });
* // => { id, rootCategoryId, languageId, taxrateId, reducedtaxrateId, taxfreerateId }
*/
export default function update(pool) {
const byId = getById(pool);
const byName = getByName(pool);