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:
@@ -1,17 +1,16 @@
|
||||
import { ADD } from '../../sql/google_auth.js';
|
||||
|
||||
/**
|
||||
* Adds a new allowed Google auth email.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that adds an allowed email.
|
||||
*
|
||||
* @example
|
||||
* const fn = add(pool);
|
||||
* const id = await fn('user@example.com');
|
||||
* // => 1
|
||||
*/
|
||||
export default function add(pool) {
|
||||
/**
|
||||
* Adds a new allowed Google auth email.
|
||||
*
|
||||
* @param {string} email - The email address to allow.
|
||||
* @returns {Promise<number>} The id of the created Google auth row.
|
||||
*
|
||||
* @example
|
||||
* const id = await store.google_auth.add('user@example.com');
|
||||
* // => 1
|
||||
*/
|
||||
return async (email) => {
|
||||
const result = await pool
|
||||
.request()
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import { GET_BY_EMAIL } from '../../sql/google_auth.js';
|
||||
|
||||
/**
|
||||
* Returns a Google auth row by email.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that fetches a Google auth row by email.
|
||||
*
|
||||
* @example
|
||||
* const fn = getByEmail(pool);
|
||||
* const auth = await fn('user@example.com');
|
||||
* // => { id, email, ... }
|
||||
*/
|
||||
export default function getByEmail(pool) {
|
||||
/**
|
||||
* Returns a Google auth row by email.
|
||||
*
|
||||
* @param {string} email - The email address.
|
||||
* @returns {Promise<object|undefined>} The Google auth row, or `undefined` if not found.
|
||||
*
|
||||
* @example
|
||||
* const auth = await store.google_auth.getByEmail('user@example.com');
|
||||
* // => { id, email, ... }
|
||||
*/
|
||||
return async (email) => {
|
||||
const result = await pool
|
||||
.request()
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import { GET_BY_ID } from '../../sql/google_auth.js';
|
||||
|
||||
/**
|
||||
* Returns a Google auth row by its id.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that fetches a Google auth row by id.
|
||||
*
|
||||
* @example
|
||||
* const fn = getById(pool);
|
||||
* const auth = await fn(42);
|
||||
* // => { id, email, ... }
|
||||
*/
|
||||
export default function getById(pool) {
|
||||
/**
|
||||
* Returns a Google auth row by its id.
|
||||
*
|
||||
* @param {number} googleAuthId - The id of the Google auth row.
|
||||
* @returns {Promise<object|undefined>} The Google auth row, or `undefined` if not found.
|
||||
*
|
||||
* @example
|
||||
* const auth = await store.google_auth.getById(42);
|
||||
* // => { id, email, ... }
|
||||
*/
|
||||
return async (googleAuthId) => {
|
||||
const result = await pool
|
||||
.request()
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
import { LIST_ALLOWED_EMAILS } from '../../sql/google_auth.js';
|
||||
|
||||
/**
|
||||
* Lists all allowed Google auth emails.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that lists allowed emails.
|
||||
*
|
||||
* @example
|
||||
* const fn = listAllowedEmails(pool);
|
||||
* const emails = await fn();
|
||||
* // => [{ id, email }]
|
||||
*/
|
||||
export default function listAllowedEmails(pool) {
|
||||
/**
|
||||
* Lists all allowed Google auth emails.
|
||||
*
|
||||
* @returns {Promise<Array<{id: number, email: string}>>} The allowed emails.
|
||||
*
|
||||
* @example
|
||||
* const emails = await store.google_auth.listAllowedEmails();
|
||||
* // => [{ id, email }]
|
||||
*/
|
||||
return async () => {
|
||||
const result = await pool.request().query(LIST_ALLOWED_EMAILS);
|
||||
return result.recordset;
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
import { REMOVE_ALLOWED_EMAIL } from '../../sql/google_auth.js';
|
||||
|
||||
/**
|
||||
* Removes an allowed Google auth email.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that removes an allowed email.
|
||||
*
|
||||
* @example
|
||||
* const fn = removeAllowedEmail(pool);
|
||||
* await fn('user@example.com');
|
||||
*/
|
||||
export default function removeAllowedEmail(pool) {
|
||||
/**
|
||||
* Removes an allowed Google auth email.
|
||||
*
|
||||
* @param {string} email - The email address to remove.
|
||||
* @returns {Promise<void>}
|
||||
*
|
||||
* @example
|
||||
* await store.google_auth.removeAllowedEmail('user@example.com');
|
||||
*/
|
||||
return async (email) => {
|
||||
await pool
|
||||
.request()
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
import { SET_PROFILE } from '../../sql/google_auth.js';
|
||||
|
||||
/**
|
||||
* Updates the profile (picture, picture binary, sub) of a Google auth user.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that sets the user profile.
|
||||
*
|
||||
* @example
|
||||
* const fn = setProfile(pool);
|
||||
* await fn(42, { picture: 'url', pictureBinary: buffer, sub: 'sub' });
|
||||
*/
|
||||
export default function setProfile(pool) {
|
||||
/**
|
||||
* Updates the profile (picture, picture binary, sub) of a Google auth user.
|
||||
*
|
||||
* @param {number} googleAuthId - The id of the Google auth user.
|
||||
* @param {object} input - The profile input.
|
||||
* @param {string} [input.picture] - The picture URL.
|
||||
* @param {Buffer} [input.pictureBinary] - The picture binary.
|
||||
* @param {string} [input.sub] - The Google sub identifier.
|
||||
* @returns {Promise<void>}
|
||||
* @throws {Error} If the user is not found or the picture binary is invalid.
|
||||
*
|
||||
* @example
|
||||
* await store.google_auth.setProfile(42, { picture: 'url', pictureBinary: buffer, sub: 'sub' });
|
||||
*/
|
||||
return async (
|
||||
googleAuthId,
|
||||
{ picture = null, pictureBinary = null, sub = null } = {},
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { SET_SELECTED_COMPANY } from '../../sql/google_auth.js';
|
||||
|
||||
/**
|
||||
* Sets the currently selected company for a Google auth user.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that sets the selected company.
|
||||
*
|
||||
* @example
|
||||
* const fn = setSelectedCompany(pool);
|
||||
* await fn(42, 1);
|
||||
*/
|
||||
export default function setSelectedCompany(pool) {
|
||||
/**
|
||||
* Sets the currently selected company for a Google auth user.
|
||||
*
|
||||
* @param {number} googleAuthId - The id of the Google auth user.
|
||||
* @param {number} companyId - The id of the company to select.
|
||||
* @returns {Promise<void>}
|
||||
*
|
||||
* @example
|
||||
* await store.google_auth.setSelectedCompany(42, 1);
|
||||
*/
|
||||
return async (googleAuthId, companyId) => {
|
||||
await pool
|
||||
.request()
|
||||
|
||||
Reference in New Issue
Block a user