docs: add JSDoc headers to all externally exported store functions
This commit is contained in:
@@ -184,6 +184,13 @@ export default function createManifestDocStore(pool, { type, label }) {
|
||||
const notFound = `${label} not found`;
|
||||
const invalid = `Invalid ${label.toLowerCase()}`;
|
||||
|
||||
/**
|
||||
* Lists the quote/order documents of a company.
|
||||
*
|
||||
* @param {number} googleAuthId - The Google auth user id.
|
||||
* @param {number} companyId - The company id.
|
||||
* @returns {Promise<Array<object>>} The document summaries.
|
||||
*/
|
||||
async function list(googleAuthId, companyId) {
|
||||
await access(googleAuthId, companyId);
|
||||
|
||||
@@ -196,6 +203,14 @@ export default function createManifestDocStore(pool, { type, label }) {
|
||||
return result.recordset.map((row) => shapeSummary(type, row));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a single quote/order document by its id within a company.
|
||||
*
|
||||
* @param {number} googleAuthId - The Google auth user id.
|
||||
* @param {number} companyId - The company id.
|
||||
* @param {number} id - The document id.
|
||||
* @returns {Promise<object|null>} The document with its lines, or null if not found.
|
||||
*/
|
||||
async function getById(googleAuthId, companyId, id) {
|
||||
if (!Number.isFinite(id)) {
|
||||
throw new Error(notFound);
|
||||
@@ -210,6 +225,14 @@ export default function createManifestDocStore(pool, { type, label }) {
|
||||
return doc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new quote/order document with its lines.
|
||||
*
|
||||
* @param {number} googleAuthId - The Google auth user id.
|
||||
* @param {number} companyId - The company id.
|
||||
* @param {object} body - The document payload (`number`, `date`, `entityId`, `lines`).
|
||||
* @returns {Promise<object>} The created document with its lines.
|
||||
*/
|
||||
async function create(googleAuthId, companyId, body = {}) {
|
||||
const number = body.number?.trim?.() ? body.number.trim() : null;
|
||||
const date = parseDate(body.date);
|
||||
@@ -261,6 +284,15 @@ export default function createManifestDocStore(pool, { type, label }) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a quote/order document's header and/or lines.
|
||||
*
|
||||
* @param {number} googleAuthId - The Google auth user id.
|
||||
* @param {number} companyId - The company id.
|
||||
* @param {number} id - The document id.
|
||||
* @param {object} patch - The fields to update (`number`, `date`, `entityId`, `lines`).
|
||||
* @returns {Promise<object>} The updated document with its lines.
|
||||
*/
|
||||
async function update(googleAuthId, companyId, id, patch = {}) {
|
||||
if (!Number.isFinite(id)) {
|
||||
throw new Error(notFound);
|
||||
@@ -360,6 +392,14 @@ export default function createManifestDocStore(pool, { type, label }) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a quote/order document by its id within a company.
|
||||
*
|
||||
* @param {number} googleAuthId - The Google auth user id.
|
||||
* @param {number} companyId - The company id.
|
||||
* @param {number} id - The document id.
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function del(googleAuthId, companyId, id) {
|
||||
if (!Number.isFinite(id)) {
|
||||
throw new Error(notFound);
|
||||
|
||||
Reference in New Issue
Block a user