diff --git a/.stats.yml b/.stats.yml index b113da20..adad7ca0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 3 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-fedf39540580ba6568142c9d98c783c00dd6c0aa46222e69c319cdff832fc9aa.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-d975cb3c41e7b2790db4938b1de2b89c4005825a6347ae29ca4998f2c5b1a1be.yml diff --git a/src/resources/documents.ts b/src/resources/documents.ts index 9515ff18..6c58b833 100644 --- a/src/resources/documents.ts +++ b/src/resources/documents.ts @@ -15,8 +15,9 @@ export class Documents extends APIResource { * This endpoint allows you to paginate through all documents in the index. You can * filter the documents by title, date, metadata, etc. */ - list(body: DocumentListParams, options?: Core.RequestOptions): Core.APIPromise { - return this._client.post('/documents/list', { body, ...options }); + list(params: DocumentListParams, options?: Core.RequestOptions): Core.APIPromise { + const { collection, cursor, size } = params; + return this._client.post('/documents/list', { query: { collection, cursor, size }, ...options }); } } @@ -38,6 +39,8 @@ export interface Document { sections?: Array; + sections_count?: number | null; + source?: | 'generic' | 'generic_chat' @@ -78,56 +81,28 @@ export namespace Document { } export interface DocumentListResponse { - count: number; - - documents: Array; + items: Array; - has_more: boolean; - - page: number; + next_cursor: string | null; } -export interface DocumentListParams { - /** - * The collections to filter documents by. - */ - collections: Array; +export namespace DocumentListResponse { + export interface Item { + id: number | null; - /** - * Filter the query results. - */ - filter?: DocumentListParams.Filter; + created_at: string | null; - /** - * Number of documents to return per page. - */ - limit?: number; + ingested_at: string | null; - /** - * Page number to return. - */ - page?: number; -} + metadata: unknown; -export namespace DocumentListParams { - /** - * Filter the query results. - */ - export interface Filter { - /** - * Only query chunks of these types. - */ - chunk_type?: Array<'text' | 'markdown' | 'table' | 'image' | 'messages' | 'message'>; + resource_id: string; - /** - * Only query documents before this date. - */ - end_date?: string | null; + sections_count: number | null; - /** - * Only query documents of these types. - */ - source?: Array< + title: string | null; + + source?: | 'generic' | 'generic_chat' | 'generic_email' @@ -138,16 +113,20 @@ export namespace DocumentListParams { | 's3' | 'gmail' | 'notion' - | 'google_docs' - >; + | 'google_docs'; - /** - * Only query documents on or after this date. - */ - start_date?: string | null; + status?: 'pending' | 'processing' | 'completed' | 'failed'; } } +export interface DocumentListParams { + collection: string; + + cursor?: string | null; + + size?: number; +} + export declare namespace Documents { export { type Document as Document, diff --git a/tests/api-resources/documents.test.ts b/tests/api-resources/documents.test.ts index a510005a..6eb4ae9e 100644 --- a/tests/api-resources/documents.test.ts +++ b/tests/api-resources/documents.test.ts @@ -28,7 +28,7 @@ describe('resource documents', () => { }); test('list: only required params', async () => { - const responsePromise = client.documents.list({ collections: [0] }); + const responsePromise = client.documents.list({ collection: 'collection' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -39,16 +39,6 @@ describe('resource documents', () => { }); test('list: required and optional params', async () => { - const response = await client.documents.list({ - collections: [0], - filter: { - chunk_type: ['text'], - end_date: '2019-12-27T18:11:19.117Z', - source: ['generic'], - start_date: '2019-12-27T18:11:19.117Z', - }, - limit: 0, - page: 2, - }); + const response = await client.documents.list({ collection: 'collection', cursor: 'cursor', size: 0 }); }); });