Skip to content

Commit 996913e

Browse files
committed
feat: indexExists
1 parent d9521de commit 996913e

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bright-client",
3-
"version": "0.6.6",
3+
"version": "0.7.0",
44
"description": "TypeScript client library for Bright search database",
55
"main": "dist/index.cjs",
66
"module": "dist/index.mjs",

src/index.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BrightErrorResponse, createBrightError } from './errors';
1+
import { BrightErrorResponse, createBrightError, NotFoundError } from './errors';
22
import {
33
IndexConfig,
44
SearchParams,
@@ -150,6 +150,20 @@ export class BrightClient {
150150
});
151151
}
152152

153+
async indexExists(id: string): Promise<boolean> {
154+
try {
155+
await this.request<IndexConfig>(`/indexes/${id}`, {
156+
method: 'GET',
157+
});
158+
return true;
159+
} catch (error) {
160+
if (error instanceof NotFoundError) {
161+
return false;
162+
}
163+
throw error;
164+
}
165+
}
166+
153167
// Document Operations
154168

155169
async addDocuments<T = Record<string, unknown>>(

0 commit comments

Comments
 (0)