Rewrite store JSDoc, split quote/order into modules, and generate typed API docs
- Rewrite JSDoc across all store methods to document the actual async methods (real params, returns, throws) instead of the internal wrappers - Split quote/order into individual module files backed by shared manifestDoc helpers; remove the createStore factory and thin wrappers - Deduplicate manifest line helpers into src/store/manifestLines.js - Extend generate-api-doc.js to render parameter/return/throws types and emit per-namespace API.<module>.md files with an API.md index - Regenerate all API docs
This commit is contained in:
64
src/store/manifestDoc/helpers.js
Normal file
64
src/store/manifestDoc/helpers.js
Normal file
@@ -0,0 +1,64 @@
|
||||
import {
|
||||
GET_MANIFEST_HEADER,
|
||||
GET_MANIFEST_LINES,
|
||||
} from '../../sql/manifestDoc.js';
|
||||
import {
|
||||
GET_CUSTOMER_BY_ID,
|
||||
POS_GROUP_NAME,
|
||||
SUPPLIER_GROUP_NAME,
|
||||
} from '../../sql/entity.js';
|
||||
import request from '../request.js';
|
||||
import { shapeLine } from '../manifestLines.js';
|
||||
|
||||
export function shapeSummary(type, row) {
|
||||
return {
|
||||
id: row.id,
|
||||
number: row.number,
|
||||
type,
|
||||
entityId: row.entityId ?? null,
|
||||
date: row.date,
|
||||
};
|
||||
}
|
||||
|
||||
export async function assertCustomerEntity(pool, tx, companyId, entityId) {
|
||||
if (entityId == null) {
|
||||
return null;
|
||||
}
|
||||
if (!Number.isFinite(entityId)) {
|
||||
throw new Error('Entity not found');
|
||||
}
|
||||
|
||||
const result = await request(pool, tx)
|
||||
.input('id', entityId)
|
||||
.input('companyId', companyId)
|
||||
.input('supplierGroupName', SUPPLIER_GROUP_NAME)
|
||||
.input('posGroupName', POS_GROUP_NAME)
|
||||
.query(GET_CUSTOMER_BY_ID);
|
||||
|
||||
if (!result.recordset[0]) {
|
||||
throw new Error('Entity not found');
|
||||
}
|
||||
return entityId;
|
||||
}
|
||||
|
||||
export async function loadDoc(pool, tx, { type, companyId, id }) {
|
||||
const header = await request(pool, tx)
|
||||
.input('id', id)
|
||||
.input('companyId', companyId)
|
||||
.input('type', type)
|
||||
.query(GET_MANIFEST_HEADER);
|
||||
|
||||
const row = header.recordset[0];
|
||||
if (!row) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const lines = await request(pool, tx)
|
||||
.input('manifestId', id)
|
||||
.query(GET_MANIFEST_LINES);
|
||||
|
||||
return {
|
||||
...shapeSummary(type, row),
|
||||
lines: lines.recordset.map(shapeLine),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user