Add convenience helpers and improve documentation

- Add isInProduction() helper for checking status 3 or 4
- Add getErrorSummary() helper for extracting error messages
- Add fetchAllPages() pagination helper for auto-pagination
- Add comprehensive JSDoc to ListResponse interface
- Create ADR-001 documenting decision not to add listAll() method

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-16 22:30:36 +01:00
parent 6b2b26f3ea
commit 397cd10a09
4 changed files with 241 additions and 2 deletions

View File

@@ -313,12 +313,35 @@ export interface Document {
}
/**
* List response wrapper
* Response structure for paginated list operations.
*
* @remarks
* The actual data is in the `items` array, not `data` or `results`.
*
* @example
* ```typescript
* const response = await client.documents.list();
*
* // Access the documents array via `items`
* for (const doc of response.items) {
* console.log(doc.filename, doc.status.text);
* }
*
* // Pagination information
* console.log(`Showing ${response.items.length} of ${response.total} documents`);
*
* // Check if more pages exist
* const hasMore = response.offset + response.items.length < response.total;
* ```
*/
export interface ListResponse<T> {
/** Array of items returned by the query */
items: T[];
/** Total number of items matching the query (across all pages) */
total: number;
/** Maximum number of items per page */
limit: number;
/** Number of items skipped (for pagination) */
offset: number;
}