Skip to content

Commit 85d6bde

Browse files
feat(api): update via SDK Studio
1 parent c75e419 commit 85d6bde

File tree

10 files changed

+197
-139
lines changed

10 files changed

+197
-139
lines changed

api.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,30 @@ Methods:
1212

1313
Types:
1414

15-
- <code><a href="./src/resources/collections.ts">CollectionAddCollectionResponse</a></code>
16-
- <code><a href="./src/resources/collections.ts">CollectionDeleteCollectionResponse</a></code>
15+
- <code><a href="./src/resources/collections.ts">CollectionDeleteResponse</a></code>
16+
- <code><a href="./src/resources/collections.ts">CollectionAddResponse</a></code>
1717
- <code><a href="./src/resources/collections.ts">CollectionGetListResponse</a></code>
1818

1919
Methods:
2020

21-
- <code title="post /collections/add-collection">client.collections.<a href="./src/resources/collections.ts">addCollection</a>({ ...params }) -> CollectionAddCollectionResponse</code>
22-
- <code title="post /collections/delete-collection">client.collections.<a href="./src/resources/collections.ts">deleteCollection</a>({ ...params }) -> CollectionDeleteCollectionResponse</code>
21+
- <code title="post /collections/delete-collection">client.collections.<a href="./src/resources/collections.ts">delete</a>({ ...params }) -> CollectionDeleteResponse</code>
22+
- <code title="post /collections/add-collection">client.collections.<a href="./src/resources/collections.ts">add</a>({ ...params }) -> CollectionAddResponse</code>
2323
- <code title="post /collections/get-collection-list">client.collections.<a href="./src/resources/collections.ts">getList</a>() -> CollectionGetListResponse</code>
2424

2525
# Documents
2626

2727
Types:
2828

29-
- <code><a href="./src/resources/documents.ts">DocumentAddDocumentResponse</a></code>
30-
- <code><a href="./src/resources/documents.ts">DocumentDeleteDocumentResponse</a></code>
29+
- <code><a href="./src/resources/documents.ts">DocumentDeleteResponse</a></code>
30+
- <code><a href="./src/resources/documents.ts">DocumentAddResponse</a></code>
3131
- <code><a href="./src/resources/documents.ts">DocumentGetInfoResponse</a></code>
3232
- <code><a href="./src/resources/documents.ts">DocumentGetInfoListResponse</a></code>
3333
- <code><a href="./src/resources/documents.ts">DocumentGetPageInfoResponse</a></code>
3434

3535
Methods:
3636

37-
- <code title="post /documents/add-document">client.documents.<a href="./src/resources/documents.ts">addDocument</a>({ ...params }) -> DocumentAddDocumentResponse</code>
38-
- <code title="post /documents/delete-document">client.documents.<a href="./src/resources/documents.ts">deleteDocument</a>({ ...params }) -> DocumentDeleteDocumentResponse</code>
37+
- <code title="post /documents/delete-document">client.documents.<a href="./src/resources/documents.ts">delete</a>({ ...params }) -> DocumentDeleteResponse</code>
38+
- <code title="post /documents/add-document">client.documents.<a href="./src/resources/documents.ts">add</a>({ ...params }) -> DocumentAddResponse</code>
3939
- <code title="post /documents/get-document-info">client.documents.<a href="./src/resources/documents.ts">getInfo</a>({ ...params }) -> DocumentGetInfoResponse</code>
4040
- <code title="post /documents/get-document-info-list">client.documents.<a href="./src/resources/documents.ts">getInfoList</a>({ ...params }) -> DocumentGetInfoListResponse</code>
4141
- <code title="post /documents/get-page-info">client.documents.<a href="./src/resources/documents.ts">getPageInfo</a>({ ...params }) -> DocumentGetPageInfoResponse</code>
@@ -58,11 +58,11 @@ Methods:
5858

5959
Types:
6060

61-
- <code><a href="./src/resources/parsers.ts">ParserParseResponse</a></code>
61+
- <code><a href="./src/resources/parsers.ts">ParserParseDocumentResponse</a></code>
6262

6363
Methods:
6464

65-
- <code title="post /parsers/parse-document">client.parsers.<a href="./src/resources/parsers.ts">parse</a>({ ...params }) -> ParserParseResponse</code>
65+
- <code title="post /parsers/parse-document">client.parsers.<a href="./src/resources/parsers.ts">parseDocument</a>({ ...params }) -> ParserParseDocumentResponse</code>
6666

6767
# Models
6868

src/index.ts

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@
33
import { type Agent } from './_shims/index';
44
import * as Core from './core';
55
import * as Errors from './error';
6+
import * as Pagination from './pagination';
7+
import { type GetDocumentInfoListCursorParams, GetDocumentInfoListCursorResponse } from './pagination';
68
import * as Uploads from './uploads';
79
import * as API from './resources/index';
810
import {
9-
CollectionAddCollectionParams,
10-
CollectionAddCollectionResponse,
11-
CollectionDeleteCollectionParams,
12-
CollectionDeleteCollectionResponse,
11+
CollectionAddParams,
12+
CollectionAddResponse,
13+
CollectionDeleteParams,
14+
CollectionDeleteResponse,
1315
CollectionGetListParams,
1416
CollectionGetListResponse,
1517
Collections,
1618
} from './resources/collections';
1719
import {
18-
DocumentAddDocumentParams,
19-
DocumentAddDocumentResponse,
20-
DocumentDeleteDocumentParams,
21-
DocumentDeleteDocumentResponse,
20+
DocumentAddParams,
21+
DocumentAddResponse,
22+
DocumentDeleteParams,
23+
DocumentDeleteResponse,
2224
DocumentGetInfoListParams,
2325
DocumentGetInfoListResponse,
2426
DocumentGetInfoParams,
@@ -28,7 +30,7 @@ import {
2830
Documents,
2931
} from './resources/documents';
3032
import { Models, StrJson } from './resources/models';
31-
import { ParserParseParams, ParserParseResponse, Parsers } from './resources/parsers';
33+
import { ParserParseDocumentParams, ParserParseDocumentResponse, Parsers } from './resources/parsers';
3234
import {
3335
Queries,
3436
QueryTopDocumentsParams,
@@ -205,6 +207,12 @@ Zeroentropy.Models = Models;
205207
export declare namespace Zeroentropy {
206208
export type RequestOptions = Core.RequestOptions;
207209

210+
export import GetDocumentInfoListCursor = Pagination.GetDocumentInfoListCursor;
211+
export {
212+
type GetDocumentInfoListCursorParams as GetDocumentInfoListCursorParams,
213+
type GetDocumentInfoListCursorResponse as GetDocumentInfoListCursorResponse,
214+
};
215+
208216
export {
209217
Status as Status,
210218
type StatusGetStatusResponse as StatusGetStatusResponse,
@@ -213,23 +221,23 @@ export declare namespace Zeroentropy {
213221

214222
export {
215223
Collections as Collections,
216-
type CollectionAddCollectionResponse as CollectionAddCollectionResponse,
217-
type CollectionDeleteCollectionResponse as CollectionDeleteCollectionResponse,
224+
type CollectionDeleteResponse as CollectionDeleteResponse,
225+
type CollectionAddResponse as CollectionAddResponse,
218226
type CollectionGetListResponse as CollectionGetListResponse,
219-
type CollectionAddCollectionParams as CollectionAddCollectionParams,
220-
type CollectionDeleteCollectionParams as CollectionDeleteCollectionParams,
227+
type CollectionDeleteParams as CollectionDeleteParams,
228+
type CollectionAddParams as CollectionAddParams,
221229
type CollectionGetListParams as CollectionGetListParams,
222230
};
223231

224232
export {
225233
Documents as Documents,
226-
type DocumentAddDocumentResponse as DocumentAddDocumentResponse,
227-
type DocumentDeleteDocumentResponse as DocumentDeleteDocumentResponse,
234+
type DocumentDeleteResponse as DocumentDeleteResponse,
235+
type DocumentAddResponse as DocumentAddResponse,
228236
type DocumentGetInfoResponse as DocumentGetInfoResponse,
229237
type DocumentGetInfoListResponse as DocumentGetInfoListResponse,
230238
type DocumentGetPageInfoResponse as DocumentGetPageInfoResponse,
231-
type DocumentAddDocumentParams as DocumentAddDocumentParams,
232-
type DocumentDeleteDocumentParams as DocumentDeleteDocumentParams,
239+
type DocumentDeleteParams as DocumentDeleteParams,
240+
type DocumentAddParams as DocumentAddParams,
233241
type DocumentGetInfoParams as DocumentGetInfoParams,
234242
type DocumentGetInfoListParams as DocumentGetInfoListParams,
235243
type DocumentGetPageInfoParams as DocumentGetPageInfoParams,
@@ -247,8 +255,8 @@ export declare namespace Zeroentropy {
247255

248256
export {
249257
Parsers as Parsers,
250-
type ParserParseResponse as ParserParseResponse,
251-
type ParserParseParams as ParserParseParams,
258+
type ParserParseDocumentResponse as ParserParseDocumentResponse,
259+
type ParserParseDocumentParams as ParserParseDocumentParams,
252260
};
253261

254262
export { Models as Models, type StrJson as StrJson };

src/pagination.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { AbstractPage, Response, APIClient, FinalRequestOptions, PageInfo } from './core';
4+
5+
export interface GetDocumentInfoListCursorResponse<Item> {
6+
documents: Array<Item>;
7+
}
8+
9+
export interface GetDocumentInfoListCursorParams {
10+
id_gt?: string;
11+
12+
limit?: number;
13+
}
14+
15+
export class GetDocumentInfoListCursor<Item extends { id: string }>
16+
extends AbstractPage<Item>
17+
implements GetDocumentInfoListCursorResponse<Item>
18+
{
19+
documents: Array<Item>;
20+
21+
constructor(
22+
client: APIClient,
23+
response: Response,
24+
body: GetDocumentInfoListCursorResponse<Item>,
25+
options: FinalRequestOptions,
26+
) {
27+
super(client, response, body, options);
28+
29+
this.documents = body.documents || [];
30+
}
31+
32+
getPaginatedItems(): Item[] {
33+
return this.documents ?? [];
34+
}
35+
36+
// @deprecated Please use `nextPageInfo()` instead
37+
nextPageParams(): Partial<GetDocumentInfoListCursorParams> | null {
38+
const info = this.nextPageInfo();
39+
if (!info) return null;
40+
if ('params' in info) return info.params;
41+
const params = Object.fromEntries(info.url.searchParams);
42+
if (!Object.keys(params).length) return null;
43+
return params;
44+
}
45+
46+
nextPageInfo(): PageInfo | null {
47+
const documents = this.getPaginatedItems();
48+
if (!documents.length) {
49+
return null;
50+
}
51+
52+
const id = documents[documents.length - 1]?.id;
53+
if (!id) {
54+
return null;
55+
}
56+
57+
return { params: { id_gt: id } };
58+
}
59+
}

src/resources/collections.ts

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,25 @@ import * as Core from '../core';
55

66
export class Collections extends APIResource {
77
/**
8-
* Adds a collection.
8+
* Deletes a collection.
99
*
10-
* If the collection already exists, a `409 Conflict` status code will be returned.
10+
* A `404 Not Found` status code will be returned, if the provided collection name
11+
* does not exist.
1112
*/
12-
addCollection(
13-
body: CollectionAddCollectionParams,
13+
delete(
14+
body: CollectionDeleteParams,
1415
options?: Core.RequestOptions,
15-
): Core.APIPromise<CollectionAddCollectionResponse> {
16-
return this._client.post('/collections/add-collection', { body, ...options });
16+
): Core.APIPromise<CollectionDeleteResponse> {
17+
return this._client.post('/collections/delete-collection', { body, ...options });
1718
}
1819

1920
/**
20-
* Deletes a collection.
21+
* Adds a collection.
2122
*
22-
* A `404 Not Found` status code will be returned, if the provided collection name
23-
* does not exist.
23+
* If the collection already exists, a `409 Conflict` status code will be returned.
2424
*/
25-
deleteCollection(
26-
body: CollectionDeleteCollectionParams,
27-
options?: Core.RequestOptions,
28-
): Core.APIPromise<CollectionDeleteCollectionResponse> {
29-
return this._client.post('/collections/delete-collection', { body, ...options });
25+
add(body: CollectionAddParams, options?: Core.RequestOptions): Core.APIPromise<CollectionAddResponse> {
26+
return this._client.post('/collections/add-collection', { body, ...options });
3027
}
3128

3229
/**
@@ -40,14 +37,14 @@ export class Collections extends APIResource {
4037
}
4138
}
4239

43-
export interface CollectionAddCollectionResponse {
40+
export interface CollectionDeleteResponse {
4441
/**
4542
* This string will always be "Success!". This may change in the future.
4643
*/
4744
message?: string;
4845
}
4946

50-
export interface CollectionDeleteCollectionResponse {
47+
export interface CollectionAddResponse {
5148
/**
5249
* This string will always be "Success!". This may change in the future.
5350
*/
@@ -61,18 +58,18 @@ export interface CollectionGetListResponse {
6158
collection_names: Array<string>;
6259
}
6360

64-
export interface CollectionAddCollectionParams {
61+
export interface CollectionDeleteParams {
6562
/**
66-
* The name of the collection to add. The maximum length of this string is 1024
67-
* characters. If special characters are used, then the UTF-8 encoded string cannot
68-
* exceed 1024 bytes.
63+
* The name of the collection to delete.
6964
*/
7065
collection_name: string;
7166
}
7267

73-
export interface CollectionDeleteCollectionParams {
68+
export interface CollectionAddParams {
7469
/**
75-
* The name of the collection to delete.
70+
* The name of the collection to add. The maximum length of this string is 1024
71+
* characters. If special characters are used, then the UTF-8 encoded string cannot
72+
* exceed 1024 bytes.
7673
*/
7774
collection_name: string;
7875
}
@@ -81,11 +78,11 @@ export interface CollectionGetListParams {}
8178

8279
export declare namespace Collections {
8380
export {
84-
type CollectionAddCollectionResponse as CollectionAddCollectionResponse,
85-
type CollectionDeleteCollectionResponse as CollectionDeleteCollectionResponse,
81+
type CollectionDeleteResponse as CollectionDeleteResponse,
82+
type CollectionAddResponse as CollectionAddResponse,
8683
type CollectionGetListResponse as CollectionGetListResponse,
87-
type CollectionAddCollectionParams as CollectionAddCollectionParams,
88-
type CollectionDeleteCollectionParams as CollectionDeleteCollectionParams,
84+
type CollectionDeleteParams as CollectionDeleteParams,
85+
type CollectionAddParams as CollectionAddParams,
8986
type CollectionGetListParams as CollectionGetListParams,
9087
};
9188
}

0 commit comments

Comments
 (0)