@ekodb/ekodb-client 0.1.0 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +3 -3
- package/dist/client.js +74 -66
- package/dist/index.d.ts +9 -9
- package/dist/schema.js +2 -1
- package/package.json +1 -1
- package/src/client.ts +241 -115
- package/src/index.ts +28 -13
- package/src/join.ts +21 -11
- package/src/query-builder.ts +1 -1
- package/src/schema.ts +12 -8
- package/src/search.ts +5 -5
package/dist/client.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ekoDB TypeScript Client
|
|
3
3
|
*/
|
|
4
|
-
import { QueryBuilder } from
|
|
5
|
-
import { SearchQuery, SearchQueryBuilder, SearchResponse } from
|
|
6
|
-
import { Schema, SchemaBuilder, CollectionMetadata } from
|
|
4
|
+
import { QueryBuilder } from "./query-builder";
|
|
5
|
+
import { SearchQuery, SearchQueryBuilder, SearchResponse } from "./search";
|
|
6
|
+
import { Schema, SchemaBuilder, CollectionMetadata } from "./schema";
|
|
7
7
|
export interface Record {
|
|
8
8
|
[key: string]: any;
|
|
9
9
|
}
|
package/dist/client.js
CHANGED
|
@@ -47,7 +47,7 @@ class RateLimitError extends Error {
|
|
|
47
47
|
constructor(retryAfterSecs, message) {
|
|
48
48
|
super(message || `Rate limit exceeded. Retry after ${retryAfterSecs} seconds`);
|
|
49
49
|
this.retryAfterSecs = retryAfterSecs;
|
|
50
|
-
this.name =
|
|
50
|
+
this.name = "RateLimitError";
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
exports.RateLimitError = RateLimitError;
|
|
@@ -62,7 +62,7 @@ class EkoDBClient {
|
|
|
62
62
|
this.token = null;
|
|
63
63
|
this.rateLimitInfo = null;
|
|
64
64
|
// Support both old (baseURL, apiKey) and new (config object) signatures
|
|
65
|
-
if (typeof config ===
|
|
65
|
+
if (typeof config === "string") {
|
|
66
66
|
this.baseURL = config;
|
|
67
67
|
this.apiKey = apiKey;
|
|
68
68
|
this.shouldRetry = true;
|
|
@@ -103,23 +103,23 @@ class EkoDBClient {
|
|
|
103
103
|
*/
|
|
104
104
|
async refreshToken() {
|
|
105
105
|
const response = await fetch(`${this.baseURL}/api/auth/token`, {
|
|
106
|
-
method:
|
|
107
|
-
headers: {
|
|
106
|
+
method: "POST",
|
|
107
|
+
headers: { "Content-Type": "application/json" },
|
|
108
108
|
body: JSON.stringify({ api_key: this.apiKey }),
|
|
109
109
|
});
|
|
110
110
|
if (!response.ok) {
|
|
111
111
|
throw new Error(`Auth failed with status: ${response.status}`);
|
|
112
112
|
}
|
|
113
|
-
const result = await response.json();
|
|
113
|
+
const result = (await response.json());
|
|
114
114
|
this.token = result.token;
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* Extract rate limit information from response headers
|
|
118
118
|
*/
|
|
119
119
|
extractRateLimitInfo(response) {
|
|
120
|
-
const limit = response.headers.get(
|
|
121
|
-
const remaining = response.headers.get(
|
|
122
|
-
const reset = response.headers.get(
|
|
120
|
+
const limit = response.headers.get("x-ratelimit-limit");
|
|
121
|
+
const remaining = response.headers.get("x-ratelimit-remaining");
|
|
122
|
+
const reset = response.headers.get("x-ratelimit-reset");
|
|
123
123
|
if (limit && remaining && reset) {
|
|
124
124
|
this.rateLimitInfo = {
|
|
125
125
|
limit: parseInt(limit, 10),
|
|
@@ -136,7 +136,7 @@ class EkoDBClient {
|
|
|
136
136
|
* Sleep for a specified number of seconds
|
|
137
137
|
*/
|
|
138
138
|
sleep(seconds) {
|
|
139
|
-
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
|
|
139
|
+
return new Promise((resolve) => setTimeout(resolve, seconds * 1000));
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
142
|
* Make an HTTP request to the ekoDB API with retry logic
|
|
@@ -148,8 +148,8 @@ class EkoDBClient {
|
|
|
148
148
|
const options = {
|
|
149
149
|
method,
|
|
150
150
|
headers: {
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
Authorization: `Bearer ${this.token}`,
|
|
152
|
+
"Content-Type": "application/json",
|
|
153
153
|
},
|
|
154
154
|
};
|
|
155
155
|
if (data) {
|
|
@@ -164,7 +164,7 @@ class EkoDBClient {
|
|
|
164
164
|
}
|
|
165
165
|
// Handle rate limiting (429)
|
|
166
166
|
if (response.status === 429) {
|
|
167
|
-
const retryAfter = parseInt(response.headers.get(
|
|
167
|
+
const retryAfter = parseInt(response.headers.get("retry-after") || "60", 10);
|
|
168
168
|
if (this.shouldRetry && attempt < this.maxRetries) {
|
|
169
169
|
console.log(`Rate limited. Retrying after ${retryAfter} seconds...`);
|
|
170
170
|
await this.sleep(retryAfter);
|
|
@@ -173,7 +173,9 @@ class EkoDBClient {
|
|
|
173
173
|
throw new RateLimitError(retryAfter);
|
|
174
174
|
}
|
|
175
175
|
// Handle service unavailable (503)
|
|
176
|
-
if (response.status === 503 &&
|
|
176
|
+
if (response.status === 503 &&
|
|
177
|
+
this.shouldRetry &&
|
|
178
|
+
attempt < this.maxRetries) {
|
|
177
179
|
const retryDelay = 10;
|
|
178
180
|
console.log(`Service unavailable. Retrying after ${retryDelay} seconds...`);
|
|
179
181
|
await this.sleep(retryDelay);
|
|
@@ -185,7 +187,9 @@ class EkoDBClient {
|
|
|
185
187
|
}
|
|
186
188
|
catch (error) {
|
|
187
189
|
// Handle network errors with retry
|
|
188
|
-
if (error instanceof TypeError &&
|
|
190
|
+
if (error instanceof TypeError &&
|
|
191
|
+
this.shouldRetry &&
|
|
192
|
+
attempt < this.maxRetries) {
|
|
189
193
|
const retryDelay = 3;
|
|
190
194
|
console.log(`Network error. Retrying after ${retryDelay} seconds...`);
|
|
191
195
|
await this.sleep(retryDelay);
|
|
@@ -202,7 +206,7 @@ class EkoDBClient {
|
|
|
202
206
|
if (ttl) {
|
|
203
207
|
data.ttl_duration = ttl;
|
|
204
208
|
}
|
|
205
|
-
return this.makeRequest(
|
|
209
|
+
return this.makeRequest("POST", `/api/insert/${collection}`, data);
|
|
206
210
|
}
|
|
207
211
|
/**
|
|
208
212
|
* Find documents in a collection
|
|
@@ -228,80 +232,80 @@ class EkoDBClient {
|
|
|
228
232
|
*/
|
|
229
233
|
async find(collection, query = {}) {
|
|
230
234
|
const queryObj = query instanceof query_builder_1.QueryBuilder ? query.build() : query;
|
|
231
|
-
return this.makeRequest(
|
|
235
|
+
return this.makeRequest("POST", `/api/find/${collection}`, queryObj);
|
|
232
236
|
}
|
|
233
237
|
/**
|
|
234
238
|
* Find a document by ID
|
|
235
239
|
*/
|
|
236
240
|
async findByID(collection, id) {
|
|
237
|
-
return this.makeRequest(
|
|
241
|
+
return this.makeRequest("GET", `/api/find/${collection}/${id}`);
|
|
238
242
|
}
|
|
239
243
|
/**
|
|
240
244
|
* Update a document
|
|
241
245
|
*/
|
|
242
246
|
async update(collection, id, record) {
|
|
243
|
-
return this.makeRequest(
|
|
247
|
+
return this.makeRequest("PUT", `/api/update/${collection}/${id}`, record);
|
|
244
248
|
}
|
|
245
249
|
/**
|
|
246
250
|
* Delete a document
|
|
247
251
|
*/
|
|
248
252
|
async delete(collection, id) {
|
|
249
|
-
await this.makeRequest(
|
|
253
|
+
await this.makeRequest("DELETE", `/api/delete/${collection}/${id}`);
|
|
250
254
|
}
|
|
251
255
|
/**
|
|
252
256
|
* Batch insert multiple documents
|
|
253
257
|
*/
|
|
254
258
|
async batchInsert(collection, records) {
|
|
255
|
-
const inserts = records.map(data => ({ data }));
|
|
256
|
-
const result = await this.makeRequest(
|
|
257
|
-
return result.successful.map(id => ({ id }));
|
|
259
|
+
const inserts = records.map((data) => ({ data }));
|
|
260
|
+
const result = await this.makeRequest("POST", `/api/batch/insert/${collection}`, { inserts });
|
|
261
|
+
return result.successful.map((id) => ({ id }));
|
|
258
262
|
}
|
|
259
263
|
/**
|
|
260
264
|
* Batch update multiple documents
|
|
261
265
|
*/
|
|
262
266
|
async batchUpdate(collection, updates) {
|
|
263
|
-
const result = await this.makeRequest(
|
|
264
|
-
return result.successful.map(id => ({ id }));
|
|
267
|
+
const result = await this.makeRequest("PUT", `/api/batch/update/${collection}`, { updates });
|
|
268
|
+
return result.successful.map((id) => ({ id }));
|
|
265
269
|
}
|
|
266
270
|
/**
|
|
267
271
|
* Batch delete multiple documents
|
|
268
272
|
*/
|
|
269
273
|
async batchDelete(collection, ids) {
|
|
270
|
-
const deletes = ids.map(id => ({ id }));
|
|
271
|
-
const result = await this.makeRequest(
|
|
274
|
+
const deletes = ids.map((id) => ({ id }));
|
|
275
|
+
const result = await this.makeRequest("DELETE", `/api/batch/delete/${collection}`, { deletes });
|
|
272
276
|
return result.successful.length;
|
|
273
277
|
}
|
|
274
278
|
/**
|
|
275
279
|
* Set a key-value pair
|
|
276
280
|
*/
|
|
277
281
|
async kvSet(key, value) {
|
|
278
|
-
await this.makeRequest(
|
|
282
|
+
await this.makeRequest("POST", `/api/kv/set/${encodeURIComponent(key)}`, { value });
|
|
279
283
|
}
|
|
280
284
|
/**
|
|
281
285
|
* Get a value by key
|
|
282
286
|
*/
|
|
283
287
|
async kvGet(key) {
|
|
284
|
-
const result = await this.makeRequest(
|
|
288
|
+
const result = await this.makeRequest("GET", `/api/kv/get/${encodeURIComponent(key)}`);
|
|
285
289
|
return result.value;
|
|
286
290
|
}
|
|
287
291
|
/**
|
|
288
292
|
* Delete a key
|
|
289
293
|
*/
|
|
290
294
|
async kvDelete(key) {
|
|
291
|
-
await this.makeRequest(
|
|
295
|
+
await this.makeRequest("DELETE", `/api/kv/delete/${encodeURIComponent(key)}`);
|
|
292
296
|
}
|
|
293
297
|
/**
|
|
294
298
|
* List all collections
|
|
295
299
|
*/
|
|
296
300
|
async listCollections() {
|
|
297
|
-
const result = await this.makeRequest(
|
|
301
|
+
const result = await this.makeRequest("GET", "/api/collections");
|
|
298
302
|
return result.collections;
|
|
299
303
|
}
|
|
300
304
|
/**
|
|
301
305
|
* Delete a collection
|
|
302
306
|
*/
|
|
303
307
|
async deleteCollection(collection) {
|
|
304
|
-
await this.makeRequest(
|
|
308
|
+
await this.makeRequest("DELETE", `/api/collections/${collection}`);
|
|
305
309
|
}
|
|
306
310
|
/**
|
|
307
311
|
* Create a collection with schema
|
|
@@ -321,7 +325,7 @@ class EkoDBClient {
|
|
|
321
325
|
*/
|
|
322
326
|
async createCollection(collection, schema) {
|
|
323
327
|
const schemaObj = schema instanceof schema_1.SchemaBuilder ? schema.build() : schema;
|
|
324
|
-
await this.makeRequest(
|
|
328
|
+
await this.makeRequest("POST", `/api/collections/${collection}`, schemaObj);
|
|
325
329
|
}
|
|
326
330
|
/**
|
|
327
331
|
* Get collection metadata and schema
|
|
@@ -330,7 +334,7 @@ class EkoDBClient {
|
|
|
330
334
|
* @returns Collection metadata including schema and analytics
|
|
331
335
|
*/
|
|
332
336
|
async getCollection(collection) {
|
|
333
|
-
return this.makeRequest(
|
|
337
|
+
return this.makeRequest("GET", `/api/collections/${collection}`);
|
|
334
338
|
}
|
|
335
339
|
/**
|
|
336
340
|
* Get collection schema
|
|
@@ -376,27 +380,29 @@ class EkoDBClient {
|
|
|
376
380
|
* ```
|
|
377
381
|
*/
|
|
378
382
|
async search(collection, searchQuery) {
|
|
379
|
-
const queryObj = searchQuery instanceof search_1.SearchQueryBuilder
|
|
380
|
-
|
|
383
|
+
const queryObj = searchQuery instanceof search_1.SearchQueryBuilder
|
|
384
|
+
? searchQuery.build()
|
|
385
|
+
: searchQuery;
|
|
386
|
+
return this.makeRequest("POST", `/api/search/${collection}`, queryObj);
|
|
381
387
|
}
|
|
382
388
|
// ========== Chat Methods ==========
|
|
383
389
|
/**
|
|
384
390
|
* Create a new chat session
|
|
385
391
|
*/
|
|
386
392
|
async createChatSession(request) {
|
|
387
|
-
return this.makeRequest(
|
|
393
|
+
return this.makeRequest("POST", "/api/chat", request);
|
|
388
394
|
}
|
|
389
395
|
/**
|
|
390
396
|
* Send a message in an existing chat session
|
|
391
397
|
*/
|
|
392
398
|
async chatMessage(sessionId, request) {
|
|
393
|
-
return this.makeRequest(
|
|
399
|
+
return this.makeRequest("POST", `/api/chat/${sessionId}/messages`, request);
|
|
394
400
|
}
|
|
395
401
|
/**
|
|
396
402
|
* Get a chat session by ID
|
|
397
403
|
*/
|
|
398
404
|
async getChatSession(sessionId) {
|
|
399
|
-
return this.makeRequest(
|
|
405
|
+
return this.makeRequest("GET", `/api/chat/${sessionId}`);
|
|
400
406
|
}
|
|
401
407
|
/**
|
|
402
408
|
* List all chat sessions
|
|
@@ -404,14 +410,14 @@ class EkoDBClient {
|
|
|
404
410
|
async listChatSessions(query) {
|
|
405
411
|
const params = new URLSearchParams();
|
|
406
412
|
if (query?.limit)
|
|
407
|
-
params.append(
|
|
413
|
+
params.append("limit", query.limit.toString());
|
|
408
414
|
if (query?.skip)
|
|
409
|
-
params.append(
|
|
415
|
+
params.append("skip", query.skip.toString());
|
|
410
416
|
if (query?.sort)
|
|
411
|
-
params.append(
|
|
417
|
+
params.append("sort", query.sort);
|
|
412
418
|
const queryString = params.toString();
|
|
413
|
-
const path = queryString ? `/api/chat?${queryString}` :
|
|
414
|
-
return this.makeRequest(
|
|
419
|
+
const path = queryString ? `/api/chat?${queryString}` : "/api/chat";
|
|
420
|
+
return this.makeRequest("GET", path);
|
|
415
421
|
}
|
|
416
422
|
/**
|
|
417
423
|
* Get messages from a chat session
|
|
@@ -419,62 +425,64 @@ class EkoDBClient {
|
|
|
419
425
|
async getChatSessionMessages(sessionId, query) {
|
|
420
426
|
const params = new URLSearchParams();
|
|
421
427
|
if (query?.limit)
|
|
422
|
-
params.append(
|
|
428
|
+
params.append("limit", query.limit.toString());
|
|
423
429
|
if (query?.skip)
|
|
424
|
-
params.append(
|
|
430
|
+
params.append("skip", query.skip.toString());
|
|
425
431
|
if (query?.sort)
|
|
426
|
-
params.append(
|
|
432
|
+
params.append("sort", query.sort);
|
|
427
433
|
const queryString = params.toString();
|
|
428
|
-
const path = queryString
|
|
429
|
-
|
|
434
|
+
const path = queryString
|
|
435
|
+
? `/api/chat/${sessionId}/messages?${queryString}`
|
|
436
|
+
: `/api/chat/${sessionId}/messages`;
|
|
437
|
+
return this.makeRequest("GET", path);
|
|
430
438
|
}
|
|
431
439
|
/**
|
|
432
440
|
* Update a chat session
|
|
433
441
|
*/
|
|
434
442
|
async updateChatSession(sessionId, request) {
|
|
435
|
-
return this.makeRequest(
|
|
443
|
+
return this.makeRequest("PUT", `/api/chat/${sessionId}`, request);
|
|
436
444
|
}
|
|
437
445
|
/**
|
|
438
446
|
* Branch a chat session
|
|
439
447
|
*/
|
|
440
448
|
async branchChatSession(request) {
|
|
441
|
-
return this.makeRequest(
|
|
449
|
+
return this.makeRequest("POST", "/api/chat/branch", request);
|
|
442
450
|
}
|
|
443
451
|
/**
|
|
444
452
|
* Delete a chat session
|
|
445
453
|
*/
|
|
446
454
|
async deleteChatSession(sessionId) {
|
|
447
|
-
await this.makeRequest(
|
|
455
|
+
await this.makeRequest("DELETE", `/api/chat/${sessionId}`);
|
|
448
456
|
}
|
|
449
457
|
/**
|
|
450
458
|
* Regenerate an AI response message
|
|
451
459
|
*/
|
|
452
460
|
async regenerateMessage(sessionId, messageId) {
|
|
453
|
-
return this.makeRequest(
|
|
461
|
+
return this.makeRequest("POST", `/api/chat/${sessionId}/messages/${messageId}/regenerate`);
|
|
454
462
|
}
|
|
455
463
|
/**
|
|
456
464
|
* Update a specific message
|
|
457
465
|
*/
|
|
458
466
|
async updateChatMessage(sessionId, messageId, content) {
|
|
459
|
-
await this.makeRequest(
|
|
467
|
+
await this.makeRequest("PUT", `/api/chat/${sessionId}/messages/${messageId}`, { content });
|
|
460
468
|
}
|
|
461
469
|
/**
|
|
462
470
|
* Delete a specific message
|
|
463
471
|
*/
|
|
464
472
|
async deleteChatMessage(sessionId, messageId) {
|
|
465
|
-
await this.makeRequest(
|
|
473
|
+
await this.makeRequest("DELETE", `/api/chat/${sessionId}/messages/${messageId}`);
|
|
466
474
|
}
|
|
467
475
|
/**
|
|
468
476
|
* Toggle the "forgotten" status of a message
|
|
469
477
|
*/
|
|
470
478
|
async toggleForgottenMessage(sessionId, messageId, forgotten) {
|
|
471
|
-
await this.makeRequest(
|
|
479
|
+
await this.makeRequest("PATCH", `/api/chat/${sessionId}/messages/${messageId}/forgotten`, { forgotten });
|
|
472
480
|
}
|
|
473
481
|
/**
|
|
474
482
|
* Merge multiple chat sessions into one
|
|
475
483
|
*/
|
|
476
484
|
async mergeChatSessions(request) {
|
|
477
|
-
return this.makeRequest(
|
|
485
|
+
return this.makeRequest("POST", "/api/chat/merge", request);
|
|
478
486
|
}
|
|
479
487
|
/**
|
|
480
488
|
* Create a WebSocket client
|
|
@@ -500,19 +508,19 @@ class WebSocketClient {
|
|
|
500
508
|
if (this.ws)
|
|
501
509
|
return;
|
|
502
510
|
// Dynamic import for Node.js WebSocket
|
|
503
|
-
const WebSocket = (await Promise.resolve().then(() => __importStar(require(
|
|
511
|
+
const WebSocket = (await Promise.resolve().then(() => __importStar(require("ws")))).default;
|
|
504
512
|
let url = this.wsURL;
|
|
505
|
-
if (!url.endsWith(
|
|
506
|
-
url +=
|
|
513
|
+
if (!url.endsWith("/api/ws")) {
|
|
514
|
+
url += "/api/ws";
|
|
507
515
|
}
|
|
508
516
|
this.ws = new WebSocket(url, {
|
|
509
517
|
headers: {
|
|
510
|
-
|
|
518
|
+
Authorization: `Bearer ${this.token}`,
|
|
511
519
|
},
|
|
512
520
|
});
|
|
513
521
|
return new Promise((resolve, reject) => {
|
|
514
|
-
this.ws.on(
|
|
515
|
-
this.ws.on(
|
|
522
|
+
this.ws.on("open", () => resolve());
|
|
523
|
+
this.ws.on("error", (err) => reject(err));
|
|
516
524
|
});
|
|
517
525
|
}
|
|
518
526
|
/**
|
|
@@ -522,22 +530,22 @@ class WebSocketClient {
|
|
|
522
530
|
await this.connect();
|
|
523
531
|
const messageId = Date.now().toString();
|
|
524
532
|
const request = {
|
|
525
|
-
type:
|
|
533
|
+
type: "FindAll",
|
|
526
534
|
messageId,
|
|
527
535
|
payload: { collection },
|
|
528
536
|
};
|
|
529
537
|
return new Promise((resolve, reject) => {
|
|
530
538
|
this.ws.send(JSON.stringify(request));
|
|
531
|
-
this.ws.once(
|
|
539
|
+
this.ws.once("message", (data) => {
|
|
532
540
|
const response = JSON.parse(data.toString());
|
|
533
|
-
if (response.type ===
|
|
541
|
+
if (response.type === "Error") {
|
|
534
542
|
reject(new Error(response.message));
|
|
535
543
|
}
|
|
536
544
|
else {
|
|
537
545
|
resolve(response.payload?.data || []);
|
|
538
546
|
}
|
|
539
547
|
});
|
|
540
|
-
this.ws.once(
|
|
548
|
+
this.ws.once("error", reject);
|
|
541
549
|
});
|
|
542
550
|
}
|
|
543
551
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { EkoDBClient, WebSocketClient, MergeStrategy, RateLimitError } from
|
|
2
|
-
export { QueryBuilder, SortOrder } from
|
|
3
|
-
export { SearchQueryBuilder } from
|
|
4
|
-
export { SchemaBuilder, FieldTypeSchemaBuilder, VectorIndexAlgorithm, DistanceMetric } from
|
|
5
|
-
export { JoinBuilder } from
|
|
6
|
-
export type { SearchQuery, SearchResult, SearchResponse } from
|
|
7
|
-
export type { Schema, FieldTypeSchema, IndexConfig, CollectionMetadata } from
|
|
8
|
-
export type { JoinConfig } from
|
|
9
|
-
export type { Record, Query, BatchOperationResult, ClientConfig, RateLimitInfo, CollectionConfig, ChatRequest, CreateChatSessionRequest, ChatMessageRequest, TokenUsage, ChatResponse, ChatSession, ChatSessionResponse, ListSessionsQuery, ListSessionsResponse, GetMessagesQuery, GetMessagesResponse, UpdateSessionRequest, MergeSessionsRequest } from
|
|
1
|
+
export { EkoDBClient, WebSocketClient, MergeStrategy, RateLimitError, } from "./client";
|
|
2
|
+
export { QueryBuilder, SortOrder } from "./query-builder";
|
|
3
|
+
export { SearchQueryBuilder } from "./search";
|
|
4
|
+
export { SchemaBuilder, FieldTypeSchemaBuilder, VectorIndexAlgorithm, DistanceMetric, } from "./schema";
|
|
5
|
+
export { JoinBuilder } from "./join";
|
|
6
|
+
export type { SearchQuery, SearchResult, SearchResponse } from "./search";
|
|
7
|
+
export type { Schema, FieldTypeSchema, IndexConfig, CollectionMetadata, } from "./schema";
|
|
8
|
+
export type { JoinConfig } from "./join";
|
|
9
|
+
export type { Record, Query, BatchOperationResult, ClientConfig, RateLimitInfo, CollectionConfig, ChatRequest, CreateChatSessionRequest, ChatMessageRequest, TokenUsage, ChatResponse, ChatSession, ChatSessionResponse, ListSessionsQuery, ListSessionsResponse, GetMessagesQuery, GetMessagesResponse, UpdateSessionRequest, MergeSessionsRequest, } from "./client";
|
package/dist/schema.js
CHANGED
|
@@ -159,7 +159,8 @@ class SchemaBuilder {
|
|
|
159
159
|
* Add a field to the schema
|
|
160
160
|
*/
|
|
161
161
|
addField(name, field) {
|
|
162
|
-
this.schema.fields[name] =
|
|
162
|
+
this.schema.fields[name] =
|
|
163
|
+
field instanceof FieldTypeSchemaBuilder ? field.build() : field;
|
|
163
164
|
return this;
|
|
164
165
|
}
|
|
165
166
|
/**
|