Skip to content

Commit d599038

Browse files
feat(api): update via SDK Studio (#10)
1 parent 113b9a4 commit d599038

File tree

1 file changed

+48
-18
lines changed

1 file changed

+48
-18
lines changed

README.md

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ const client = new Zeroentropy({
5050
});
5151

5252
async function main() {
53-
const response: Zeroentropy.StatusGetStatusResponse = await client.status.getStatus();
53+
const params: Zeroentropy.DocumentAddParams = {
54+
collection_name: 'example_collection',
55+
content: { type: 'text', text: 'Example Content' },
56+
path: 'my_document.txt',
57+
};
58+
const response: Zeroentropy.DocumentAddResponse = await client.documents.add(params);
5459
}
5560

5661
main();
@@ -67,15 +72,21 @@ a subclass of `APIError` will be thrown:
6772
<!-- prettier-ignore -->
6873
```ts
6974
async function main() {
70-
const response = await client.status.getStatus().catch(async (err) => {
71-
if (err instanceof Zeroentropy.APIError) {
72-
console.log(err.status); // 400
73-
console.log(err.name); // BadRequestError
74-
console.log(err.headers); // {server: 'nginx', ...}
75-
} else {
76-
throw err;
77-
}
78-
});
75+
const response = await client.documents
76+
.add({
77+
collection_name: 'example_collection',
78+
content: { type: 'text', text: 'Example Content' },
79+
path: 'my_document.txt',
80+
})
81+
.catch(async (err) => {
82+
if (err instanceof Zeroentropy.APIError) {
83+
console.log(err.status); // 400
84+
console.log(err.name); // BadRequestError
85+
console.log(err.headers); // {server: 'nginx', ...}
86+
} else {
87+
throw err;
88+
}
89+
});
7990
}
8091

8192
main();
@@ -110,7 +121,7 @@ const client = new Zeroentropy({
110121
});
111122

112123
// Or, configure per-request:
113-
await client.status.getStatus({
124+
await client.documents.add({ collection_name: 'example_collection', content: { type: 'text', text: 'Example Content' }, path: 'my_document.txt' }, {
114125
maxRetries: 5,
115126
});
116127
```
@@ -127,7 +138,7 @@ const client = new Zeroentropy({
127138
});
128139

129140
// Override per-request:
130-
await client.status.getStatus({
141+
await client.documents.add({ collection_name: 'example_collection', content: { type: 'text', text: 'Example Content' }, path: 'my_document.txt' }, {
131142
timeout: 5 * 1000,
132143
});
133144
```
@@ -181,13 +192,25 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
181192
```ts
182193
const client = new Zeroentropy();
183194

184-
const response = await client.status.getStatus().asResponse();
195+
const response = await client.documents
196+
.add({
197+
collection_name: 'example_collection',
198+
content: { type: 'text', text: 'Example Content' },
199+
path: 'my_document.txt',
200+
})
201+
.asResponse();
185202
console.log(response.headers.get('X-My-Header'));
186203
console.log(response.statusText); // access the underlying Response object
187204

188-
const { data: response, response: raw } = await client.status.getStatus().withResponse();
205+
const { data: response, response: raw } = await client.documents
206+
.add({
207+
collection_name: 'example_collection',
208+
content: { type: 'text', text: 'Example Content' },
209+
path: 'my_document.txt',
210+
})
211+
.withResponse();
189212
console.log(raw.headers.get('X-My-Header'));
190-
console.log(response.num_documents);
213+
console.log(response.message);
191214
```
192215

193216
### Making custom/undocumented requests
@@ -291,9 +314,16 @@ const client = new Zeroentropy({
291314
});
292315

293316
// Override per-request:
294-
await client.status.getStatus({
295-
httpAgent: new http.Agent({ keepAlive: false }),
296-
});
317+
await client.documents.add(
318+
{
319+
collection_name: 'example_collection',
320+
content: { type: 'text', text: 'Example Content' },
321+
path: 'my_document.txt',
322+
},
323+
{
324+
httpAgent: new http.Agent({ keepAlive: false }),
325+
},
326+
);
297327
```
298328

299329
## Semantic versioning

0 commit comments

Comments
 (0)