Skip to content

Commit d1d5960

Browse files
committed
docs(cli): improve JSDoc and clarify API key usage
- Added JSDoc to key exported functions (generateAllReports, getInvalidIndexes, etc.) - Clarified API key dual-send pattern in checkup-api.ts (header for gateway, body for RPC) - Documents defense-in-depth security pattern for API authentication
1 parent 739ce0a commit d1d5960

1 file changed

Lines changed: 26 additions & 7 deletions

File tree

cli/lib/checkup.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,12 @@ export async function getClusterInfo(client: Client, pgMajorVersion: number = 16
561561
}
562562

563563
/**
564-
* Get invalid indexes (H001)
565-
* SQL loaded from config/pgwatch-prometheus/metrics.yml (pg_invalid_indexes)
564+
* Get invalid indexes from the database (H001).
565+
* Invalid indexes are indexes that failed to build (e.g., due to CONCURRENTLY failure).
566+
*
567+
* @param client - Connected PostgreSQL client
568+
* @param pgMajorVersion - PostgreSQL major version (default: 16)
569+
* @returns Array of invalid index entries with size and FK support info
566570
*/
567571
export async function getInvalidIndexes(client: Client, pgMajorVersion: number = 16): Promise<InvalidIndex[]> {
568572
const sql = getMetricSql(METRIC_NAMES.H001, pgMajorVersion);
@@ -583,8 +587,12 @@ export async function getInvalidIndexes(client: Client, pgMajorVersion: number =
583587
}
584588

585589
/**
586-
* Get unused indexes (H002)
587-
* SQL loaded from config/pgwatch-prometheus/metrics.yml (unused_indexes)
590+
* Get unused indexes from the database (H002).
591+
* Unused indexes have zero scans since stats were last reset.
592+
*
593+
* @param client - Connected PostgreSQL client
594+
* @param pgMajorVersion - PostgreSQL major version (default: 16)
595+
* @returns Array of unused index entries with scan counts and FK support info
588596
*/
589597
export async function getUnusedIndexes(client: Client, pgMajorVersion: number = 16): Promise<UnusedIndex[]> {
590598
const sql = getMetricSql(METRIC_NAMES.H002, pgMajorVersion);
@@ -695,8 +703,12 @@ function isValidRedundantToItem(item: unknown): item is Record<string, unknown>
695703
}
696704

697705
/**
698-
* Get redundant indexes (H004)
699-
* SQL loaded from config/pgwatch-prometheus/metrics.yml (redundant_indexes)
706+
* Get redundant indexes from the database (H004).
707+
* Redundant indexes are covered by other indexes (same leading columns).
708+
*
709+
* @param client - Connected PostgreSQL client
710+
* @param pgMajorVersion - PostgreSQL major version (default: 16)
711+
* @returns Array of redundant index entries with covering index info
700712
*/
701713
export async function getRedundantIndexes(client: Client, pgMajorVersion: number = 16): Promise<RedundantIndex[]> {
702714
const sql = getMetricSql(METRIC_NAMES.H004, pgMajorVersion);
@@ -1344,7 +1356,14 @@ export const CHECK_INFO: Record<string, string> = {
13441356
};
13451357

13461358
/**
1347-
* Generate all available reports
1359+
* Generate all available health check reports.
1360+
* This is the main entry point for express mode checkup generation.
1361+
*
1362+
* @param client - Connected PostgreSQL client
1363+
* @param nodeName - Node identifier for the report (default: "node-01")
1364+
* @param onProgress - Optional callback for progress updates during generation
1365+
* @returns Object mapping check IDs (e.g., "H001", "A002") to their reports
1366+
* @throws {Error} If any critical report generation fails
13481367
*/
13491368
export async function generateAllReports(
13501369
client: Client,

0 commit comments

Comments
 (0)