diff --git a/README.md b/README.md index 76189b4..da75584 100644 --- a/README.md +++ b/README.md @@ -138,39 +138,6 @@ On timeout, an `APIConnectionTimeoutError` is thrown. Note that requests which time out will be [retried twice by default](#retries). -## Auto-pagination - -List methods in the ZeroEntropy API are paginated. -You can use the `for await … of` syntax to iterate through items across all pages: - -```ts -async function fetchAllDocuments(params) { - const allDocuments = []; - // Automatically fetches more pages as needed. - for await (const documentGetInfoListResponse of client.documents.getInfoList({ - collection_name: 'example_collection', - })) { - allDocuments.push(documentGetInfoListResponse); - } - return allDocuments; -} -``` - -Alternatively, you can request a single page at a time: - -```ts -let page = await client.documents.getInfoList({ collection_name: 'example_collection' }); -for (const documentGetInfoListResponse of page.documents) { - console.log(documentGetInfoListResponse); -} - -// Convenience methods are provided for manually paginating: -while (page.hasNextPage()) { - page = await page.getNextPage(); - // ... -} -``` - ## Advanced Usage ### Accessing raw Response data (e.g., headers) diff --git a/api.md b/api.md index dc39621..23dc689 100644 --- a/api.md +++ b/api.md @@ -49,7 +49,7 @@ Methods: - client.documents.delete({ ...params }) -> DocumentDeleteResponse - client.documents.add({ ...params }) -> DocumentAddResponse - client.documents.getInfo({ ...params }) -> DocumentGetInfoResponse -- client.documents.getInfoList({ ...params }) -> DocumentGetInfoListResponsesGetDocumentInfoListCursor +- client.documents.getInfoList({ ...params }) -> DocumentGetInfoListResponse - client.documents.getPageInfo({ ...params }) -> DocumentGetPageInfoResponse # Queries diff --git a/src/index.ts b/src/index.ts index 5fa5cbb..254837f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,7 +24,6 @@ import { DocumentDeleteResponse, DocumentGetInfoListParams, DocumentGetInfoListResponse, - DocumentGetInfoListResponsesGetDocumentInfoListCursor, DocumentGetInfoParams, DocumentGetInfoResponse, DocumentGetPageInfoParams, @@ -205,8 +204,6 @@ ZeroEntropy.Admin = Admin; ZeroEntropy.Status = Status; ZeroEntropy.Collections = Collections; ZeroEntropy.Documents = Documents; -ZeroEntropy.DocumentGetInfoListResponsesGetDocumentInfoListCursor = - DocumentGetInfoListResponsesGetDocumentInfoListCursor; ZeroEntropy.Queries = Queries; ZeroEntropy.Parsers = Parsers; export declare namespace ZeroEntropy { @@ -248,7 +245,6 @@ export declare namespace ZeroEntropy { type DocumentGetInfoResponse as DocumentGetInfoResponse, type DocumentGetInfoListResponse as DocumentGetInfoListResponse, type DocumentGetPageInfoResponse as DocumentGetPageInfoResponse, - DocumentGetInfoListResponsesGetDocumentInfoListCursor as DocumentGetInfoListResponsesGetDocumentInfoListCursor, type DocumentUpdateParams as DocumentUpdateParams, type DocumentDeleteParams as DocumentDeleteParams, type DocumentAddParams as DocumentAddParams, diff --git a/src/resources/documents.ts b/src/resources/documents.ts index cee81ce..3a6457a 100644 --- a/src/resources/documents.ts +++ b/src/resources/documents.ts @@ -2,7 +2,6 @@ import { APIResource } from '../resource'; import * as Core from '../core'; -import { GetDocumentInfoListCursor, type GetDocumentInfoListCursorParams } from '../pagination'; export class Documents extends APIResource { /** @@ -80,12 +79,8 @@ export class Documents extends APIResource { getInfoList( body: DocumentGetInfoListParams, options?: Core.RequestOptions, - ): Core.PagePromise { - return this._client.getAPIList( - '/documents/get-document-info-list', - DocumentGetInfoListResponsesGetDocumentInfoListCursor, - { body, method: 'post', ...options }, - ); + ): Core.APIPromise { + return this._client.post('/documents/get-document-info-list', { body, ...options }); } /** @@ -103,8 +98,6 @@ export class Documents extends APIResource { } } -export class DocumentGetInfoListResponsesGetDocumentInfoListCursor extends GetDocumentInfoListCursor {} - export interface DocumentUpdateResponse { new_id: string; @@ -163,29 +156,35 @@ export namespace DocumentGetInfoResponse { } export interface DocumentGetInfoListResponse { - id: string; + documents: Array; +} - collection_name: string; +export namespace DocumentGetInfoListResponse { + export interface Document { + id: string; - index_status: - | 'not_parsed' - | 'parsing' - | 'not_indexed' - | 'indexing' - | 'indexed' - | 'parsing_failed' - | 'indexing_failed'; + collection_name: string; - metadata: Record>; + index_status: + | 'not_parsed' + | 'parsing' + | 'not_indexed' + | 'indexing' + | 'indexed' + | 'parsing_failed' + | 'indexing_failed'; - /** - * The number of pages in this document. This will be `null` if the document is - * parsing or failed to parse. It can also be `null` if the document is a filetype - * that does not support pages. - */ - num_pages: number | null; + metadata: Record>; - path: string; + /** + * The number of pages in this document. This will be `null` if the document is + * parsing or failed to parse. It can also be `null` if the document is a filetype + * that does not support pages. + */ + num_pages: number | null; + + path: string; + } } export interface DocumentGetPageInfoResponse { @@ -369,11 +368,23 @@ export interface DocumentGetInfoParams { include_content?: boolean; } -export interface DocumentGetInfoListParams extends GetDocumentInfoListCursorParams { +export interface DocumentGetInfoListParams { /** * The name of the collection. */ collection_name: string; + + /** + * All documents returned will have a UUID strictly greater than the provided UUID. + * (Comparison will be on the binary representations of the UUIDs) + */ + id_gt?: string | null; + + /** + * The maximum number of documents to return. This field is by default 1024, and + * cannot be set larger than 1024 + */ + limit?: number; } export interface DocumentGetPageInfoParams { @@ -404,9 +415,6 @@ export interface DocumentGetPageInfoParams { include_content?: boolean; } -Documents.DocumentGetInfoListResponsesGetDocumentInfoListCursor = - DocumentGetInfoListResponsesGetDocumentInfoListCursor; - export declare namespace Documents { export { type DocumentUpdateResponse as DocumentUpdateResponse, @@ -415,7 +423,6 @@ export declare namespace Documents { type DocumentGetInfoResponse as DocumentGetInfoResponse, type DocumentGetInfoListResponse as DocumentGetInfoListResponse, type DocumentGetPageInfoResponse as DocumentGetPageInfoResponse, - DocumentGetInfoListResponsesGetDocumentInfoListCursor as DocumentGetInfoListResponsesGetDocumentInfoListCursor, type DocumentUpdateParams as DocumentUpdateParams, type DocumentDeleteParams as DocumentDeleteParams, type DocumentAddParams as DocumentAddParams, diff --git a/src/resources/index.ts b/src/resources/index.ts index 46063e4..9956798 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -11,7 +11,6 @@ export { type CollectionGetListParams, } from './collections'; export { - DocumentGetInfoListResponsesGetDocumentInfoListCursor, Documents, type DocumentUpdateResponse, type DocumentDeleteResponse,