@mastra/lance 0.0.0-tsconfig-compile-20250703214351 → 0.0.0-workflow-deno-20250616130925
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/CHANGELOG.md +3 -99
- package/dist/_tsup-dts-rollup.d.cts +4 -28
- package/dist/_tsup-dts-rollup.d.ts +4 -28
- package/dist/index.cjs +160 -806
- package/dist/index.js +127 -773
- package/package.json +7 -7
- package/src/storage/index.test.ts +2 -72
- package/src/storage/index.ts +68 -498
- package/src/vector/filter.test.ts +3 -3
- package/src/vector/filter.ts +4 -24
- package/src/vector/index.test.ts +3 -3
- package/src/vector/index.ts +79 -320
|
@@ -13,8 +13,8 @@ describe('LanceFilterTranslator', () => {
|
|
|
13
13
|
describe('basic operations', () => {
|
|
14
14
|
it('handles empty filters', () => {
|
|
15
15
|
expect(translator.translate({})).toEqual('');
|
|
16
|
-
expect(translator.translate(null)).toEqual('');
|
|
17
|
-
expect(translator.translate(undefined)).toEqual('');
|
|
16
|
+
expect(translator.translate(null as any)).toEqual('');
|
|
17
|
+
expect(translator.translate(undefined as any)).toEqual('');
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
it('translates equality operation', () => {
|
|
@@ -244,7 +244,7 @@ describe('LanceFilterTranslator', () => {
|
|
|
244
244
|
});
|
|
245
245
|
|
|
246
246
|
it('throws error for invalid operators at top level', () => {
|
|
247
|
-
const invalidFilters
|
|
247
|
+
const invalidFilters = [{ $gt: 100 }, { $in: ['value1', 'value2'] }, { $like: '%pattern%' }];
|
|
248
248
|
|
|
249
249
|
invalidFilters.forEach(filter => {
|
|
250
250
|
expect(() => translator.translate(filter)).toThrow(/Invalid top-level operator/);
|
package/src/vector/filter.ts
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
|
+
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
1
2
|
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
LogicalOperatorValueMap,
|
|
6
|
-
BlacklistedRootOperators,
|
|
7
|
-
} from '@mastra/core/vector/filter';
|
|
8
|
-
|
|
9
|
-
type LanceOperatorValueMap = OperatorValueMap & {
|
|
10
|
-
$like: string;
|
|
11
|
-
$notLike: string;
|
|
12
|
-
$contains: string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
type LanceBlacklisted = BlacklistedRootOperators | '$like' | '$notLike' | '$contains';
|
|
16
|
-
|
|
17
|
-
export type LanceVectorFilter = VectorFilter<
|
|
18
|
-
keyof LanceOperatorValueMap,
|
|
19
|
-
LanceOperatorValueMap,
|
|
20
|
-
LogicalOperatorValueMap,
|
|
21
|
-
LanceBlacklisted
|
|
22
|
-
>;
|
|
23
|
-
|
|
24
|
-
export class LanceFilterTranslator extends BaseFilterTranslator<LanceVectorFilter, string> {
|
|
25
|
-
translate(filter: LanceVectorFilter): string {
|
|
3
|
+
|
|
4
|
+
export class LanceFilterTranslator extends BaseFilterTranslator {
|
|
5
|
+
translate(filter: VectorFilter): string {
|
|
26
6
|
if (!filter || Object.keys(filter).length === 0) {
|
|
27
7
|
return '';
|
|
28
8
|
}
|
package/src/vector/index.test.ts
CHANGED
|
@@ -220,8 +220,8 @@ describe('Lance vector store tests', () => {
|
|
|
220
220
|
});
|
|
221
221
|
|
|
222
222
|
it('should throw error when no data is provided', async () => {
|
|
223
|
-
await expect(vectorDB.createTable(testTableName, [])).rejects.
|
|
224
|
-
|
|
223
|
+
await expect(vectorDB.createTable(testTableName, [])).rejects.toThrow(
|
|
224
|
+
'Failed to create table: At least one record or a schema needs to be provided',
|
|
225
225
|
);
|
|
226
226
|
});
|
|
227
227
|
|
|
@@ -434,7 +434,7 @@ describe('Lance vector store tests', () => {
|
|
|
434
434
|
columns: ['id', 'vector', 'metadata'],
|
|
435
435
|
queryVector: [0.1, 0.2, 0.3],
|
|
436
436
|
}),
|
|
437
|
-
).rejects.
|
|
437
|
+
).rejects.toThrow(`Failed to query vectors: Table '${nonExistentTable}' was not found`);
|
|
438
438
|
});
|
|
439
439
|
});
|
|
440
440
|
|
package/src/vector/index.ts
CHANGED
|
@@ -12,10 +12,9 @@ import type {
|
|
|
12
12
|
UpdateVectorParams,
|
|
13
13
|
UpsertVectorParams,
|
|
14
14
|
} from '@mastra/core';
|
|
15
|
-
import { ErrorCategory, ErrorDomain, MastraError } from '@mastra/core/error';
|
|
16
15
|
|
|
17
16
|
import { MastraVector } from '@mastra/core/vector';
|
|
18
|
-
import type {
|
|
17
|
+
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
19
18
|
import { LanceFilterTranslator } from './filter';
|
|
20
19
|
import type { IndexConfig } from './types';
|
|
21
20
|
|
|
@@ -33,13 +32,13 @@ interface LanceUpsertVectorParams extends UpsertVectorParams {
|
|
|
33
32
|
tableName: string;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
interface LanceQueryVectorParams extends QueryVectorParams
|
|
35
|
+
interface LanceQueryVectorParams extends QueryVectorParams {
|
|
37
36
|
tableName: string;
|
|
38
37
|
columns?: string[];
|
|
39
38
|
includeAllColumns?: boolean;
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
export class LanceVectorStore extends MastraVector
|
|
41
|
+
export class LanceVectorStore extends MastraVector {
|
|
43
42
|
private lanceClient!: Connection;
|
|
44
43
|
|
|
45
44
|
/**
|
|
@@ -70,15 +69,7 @@ export class LanceVectorStore extends MastraVector<LanceVectorFilter> {
|
|
|
70
69
|
instance.lanceClient = await connect(uri, options);
|
|
71
70
|
return instance;
|
|
72
71
|
} catch (e) {
|
|
73
|
-
throw new
|
|
74
|
-
{
|
|
75
|
-
id: 'STORAGE_LANCE_VECTOR_CONNECT_FAILED',
|
|
76
|
-
domain: ErrorDomain.STORAGE,
|
|
77
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
78
|
-
details: { uri },
|
|
79
|
-
},
|
|
80
|
-
e,
|
|
81
|
-
);
|
|
72
|
+
throw new Error(`Failed to connect to LanceDB: ${e}`);
|
|
82
73
|
}
|
|
83
74
|
}
|
|
84
75
|
|
|
@@ -105,29 +96,16 @@ export class LanceVectorStore extends MastraVector<LanceVectorFilter> {
|
|
|
105
96
|
columns = [],
|
|
106
97
|
includeAllColumns = false,
|
|
107
98
|
}: LanceQueryVectorParams): Promise<QueryResult[]> {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
99
|
+
if (!this.lanceClient) {
|
|
100
|
+
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
101
|
+
}
|
|
112
102
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
103
|
+
if (!tableName) {
|
|
104
|
+
throw new Error('tableName is required');
|
|
105
|
+
}
|
|
116
106
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
} catch (error) {
|
|
121
|
-
throw new MastraError(
|
|
122
|
-
{
|
|
123
|
-
id: 'STORAGE_LANCE_VECTOR_QUERY_FAILED_INVALID_ARGS',
|
|
124
|
-
domain: ErrorDomain.STORAGE,
|
|
125
|
-
category: ErrorCategory.USER,
|
|
126
|
-
text: 'LanceDB client not initialized. Use LanceVectorStore.create() to create an instance',
|
|
127
|
-
details: { tableName },
|
|
128
|
-
},
|
|
129
|
-
error,
|
|
130
|
-
);
|
|
107
|
+
if (!queryVector) {
|
|
108
|
+
throw new Error('queryVector is required');
|
|
131
109
|
}
|
|
132
110
|
|
|
133
111
|
try {
|
|
@@ -192,19 +170,11 @@ export class LanceVectorStore extends MastraVector<LanceVectorFilter> {
|
|
|
192
170
|
};
|
|
193
171
|
});
|
|
194
172
|
} catch (error: any) {
|
|
195
|
-
throw new
|
|
196
|
-
{
|
|
197
|
-
id: 'STORAGE_LANCE_VECTOR_QUERY_FAILED',
|
|
198
|
-
domain: ErrorDomain.STORAGE,
|
|
199
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
200
|
-
details: { tableName, includeVector, columnsCount: columns?.length, includeAllColumns },
|
|
201
|
-
},
|
|
202
|
-
error,
|
|
203
|
-
);
|
|
173
|
+
throw new Error(`Failed to query vectors: ${error.message}`);
|
|
204
174
|
}
|
|
205
175
|
}
|
|
206
176
|
|
|
207
|
-
private filterTranslator(filter:
|
|
177
|
+
private filterTranslator(filter: VectorFilter): string {
|
|
208
178
|
// Add metadata_ prefix to filter keys if they don't already have it
|
|
209
179
|
const processFilterKeys = (filterObj: Record<string, any>): Record<string, any> => {
|
|
210
180
|
const result: Record<string, any> = {};
|
|
@@ -247,29 +217,16 @@ export class LanceVectorStore extends MastraVector<LanceVectorFilter> {
|
|
|
247
217
|
}
|
|
248
218
|
|
|
249
219
|
async upsert({ tableName, vectors, metadata = [], ids = [] }: LanceUpsertVectorParams): Promise<string[]> {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
220
|
+
if (!this.lanceClient) {
|
|
221
|
+
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
222
|
+
}
|
|
254
223
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
224
|
+
if (!tableName) {
|
|
225
|
+
throw new Error('tableName is required');
|
|
226
|
+
}
|
|
258
227
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
} catch (error) {
|
|
263
|
-
throw new MastraError(
|
|
264
|
-
{
|
|
265
|
-
id: 'STORAGE_LANCE_VECTOR_UPSERT_FAILED_INVALID_ARGS',
|
|
266
|
-
domain: ErrorDomain.STORAGE,
|
|
267
|
-
category: ErrorCategory.USER,
|
|
268
|
-
text: 'LanceDB client not initialized. Use LanceVectorStore.create() to create an instance',
|
|
269
|
-
details: { tableName },
|
|
270
|
-
},
|
|
271
|
-
error,
|
|
272
|
-
);
|
|
228
|
+
if (!vectors || !Array.isArray(vectors) || vectors.length === 0) {
|
|
229
|
+
throw new Error('vectors array is required and must not be empty');
|
|
273
230
|
}
|
|
274
231
|
|
|
275
232
|
try {
|
|
@@ -310,15 +267,7 @@ export class LanceVectorStore extends MastraVector<LanceVectorFilter> {
|
|
|
310
267
|
|
|
311
268
|
return vectorIds;
|
|
312
269
|
} catch (error: any) {
|
|
313
|
-
throw new
|
|
314
|
-
{
|
|
315
|
-
id: 'STORAGE_LANCE_VECTOR_UPSERT_FAILED',
|
|
316
|
-
domain: ErrorDomain.STORAGE,
|
|
317
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
318
|
-
details: { tableName, vectorCount: vectors.length, metadataCount: metadata.length, idsCount: ids.length },
|
|
319
|
-
},
|
|
320
|
-
error,
|
|
321
|
-
);
|
|
270
|
+
throw new Error(`Failed to upsert vectors: ${error.message}`);
|
|
322
271
|
}
|
|
323
272
|
}
|
|
324
273
|
|
|
@@ -344,84 +293,34 @@ export class LanceVectorStore extends MastraVector<LanceVectorFilter> {
|
|
|
344
293
|
options?: Partial<CreateTableOptions>,
|
|
345
294
|
): Promise<Table> {
|
|
346
295
|
if (!this.lanceClient) {
|
|
347
|
-
throw new
|
|
348
|
-
id: 'STORAGE_LANCE_VECTOR_CREATE_TABLE_FAILED_INVALID_ARGS',
|
|
349
|
-
domain: ErrorDomain.STORAGE,
|
|
350
|
-
category: ErrorCategory.USER,
|
|
351
|
-
text: 'LanceDB client not initialized. Use LanceVectorStore.create() to create an instance',
|
|
352
|
-
details: { tableName },
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
// Flatten nested objects if data is an array of records
|
|
357
|
-
if (Array.isArray(data)) {
|
|
358
|
-
data = data.map(record => this.flattenObject(record));
|
|
296
|
+
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
359
297
|
}
|
|
360
298
|
|
|
361
299
|
try {
|
|
300
|
+
// Flatten nested objects if data is an array of records
|
|
301
|
+
if (Array.isArray(data)) {
|
|
302
|
+
data = data.map(record => this.flattenObject(record));
|
|
303
|
+
}
|
|
304
|
+
|
|
362
305
|
return await this.lanceClient.createTable(tableName, data, options);
|
|
363
306
|
} catch (error: any) {
|
|
364
|
-
throw new
|
|
365
|
-
{
|
|
366
|
-
id: 'STORAGE_LANCE_VECTOR_CREATE_TABLE_FAILED',
|
|
367
|
-
domain: ErrorDomain.STORAGE,
|
|
368
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
369
|
-
details: { tableName },
|
|
370
|
-
},
|
|
371
|
-
error,
|
|
372
|
-
);
|
|
307
|
+
throw new Error(`Failed to create table: ${error.message}`);
|
|
373
308
|
}
|
|
374
309
|
}
|
|
375
310
|
|
|
376
311
|
async listTables(): Promise<string[]> {
|
|
377
312
|
if (!this.lanceClient) {
|
|
378
|
-
throw new
|
|
379
|
-
id: 'STORAGE_LANCE_VECTOR_LIST_TABLES_FAILED_INVALID_ARGS',
|
|
380
|
-
domain: ErrorDomain.STORAGE,
|
|
381
|
-
category: ErrorCategory.USER,
|
|
382
|
-
text: 'LanceDB client not initialized. Use LanceVectorStore.create() to create an instance',
|
|
383
|
-
details: { methodName: 'listTables' },
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
try {
|
|
387
|
-
return await this.lanceClient.tableNames();
|
|
388
|
-
} catch (error) {
|
|
389
|
-
throw new MastraError(
|
|
390
|
-
{
|
|
391
|
-
id: 'STORAGE_LANCE_VECTOR_LIST_TABLES_FAILED',
|
|
392
|
-
domain: ErrorDomain.STORAGE,
|
|
393
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
394
|
-
},
|
|
395
|
-
error,
|
|
396
|
-
);
|
|
313
|
+
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
397
314
|
}
|
|
315
|
+
return await this.lanceClient.tableNames();
|
|
398
316
|
}
|
|
399
317
|
|
|
400
318
|
async getTableSchema(tableName: string): Promise<any> {
|
|
401
319
|
if (!this.lanceClient) {
|
|
402
|
-
throw new
|
|
403
|
-
id: 'STORAGE_LANCE_VECTOR_GET_TABLE_SCHEMA_FAILED_INVALID_ARGS',
|
|
404
|
-
domain: ErrorDomain.STORAGE,
|
|
405
|
-
category: ErrorCategory.USER,
|
|
406
|
-
text: 'LanceDB client not initialized. Use LanceVectorStore.create() to create an instance',
|
|
407
|
-
details: { tableName },
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
try {
|
|
412
|
-
const table = await this.lanceClient.openTable(tableName);
|
|
413
|
-
return await table.schema();
|
|
414
|
-
} catch (error) {
|
|
415
|
-
throw new MastraError(
|
|
416
|
-
{
|
|
417
|
-
id: 'STORAGE_LANCE_VECTOR_GET_TABLE_SCHEMA_FAILED',
|
|
418
|
-
domain: ErrorDomain.STORAGE,
|
|
419
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
420
|
-
details: { tableName },
|
|
421
|
-
},
|
|
422
|
-
error,
|
|
423
|
-
);
|
|
320
|
+
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
424
321
|
}
|
|
322
|
+
const table = await this.lanceClient.openTable(tableName);
|
|
323
|
+
return await table.schema();
|
|
425
324
|
}
|
|
426
325
|
|
|
427
326
|
/**
|
|
@@ -434,11 +333,11 @@ export class LanceVectorStore extends MastraVector<LanceVectorFilter> {
|
|
|
434
333
|
metric = 'cosine',
|
|
435
334
|
indexConfig = {},
|
|
436
335
|
}: LanceCreateIndexParams): Promise<void> {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
}
|
|
336
|
+
if (!this.lanceClient) {
|
|
337
|
+
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
338
|
+
}
|
|
441
339
|
|
|
340
|
+
try {
|
|
442
341
|
if (!tableName) {
|
|
443
342
|
throw new Error('tableName is required');
|
|
444
343
|
}
|
|
@@ -450,19 +349,7 @@ export class LanceVectorStore extends MastraVector<LanceVectorFilter> {
|
|
|
450
349
|
if (typeof dimension !== 'number' || dimension <= 0) {
|
|
451
350
|
throw new Error('dimension must be a positive number');
|
|
452
351
|
}
|
|
453
|
-
} catch (err) {
|
|
454
|
-
throw new MastraError(
|
|
455
|
-
{
|
|
456
|
-
id: 'STORAGE_LANCE_VECTOR_CREATE_INDEX_FAILED_INVALID_ARGS',
|
|
457
|
-
domain: ErrorDomain.STORAGE,
|
|
458
|
-
category: ErrorCategory.USER,
|
|
459
|
-
details: { tableName: tableName || '', indexName, dimension, metric },
|
|
460
|
-
},
|
|
461
|
-
err,
|
|
462
|
-
);
|
|
463
|
-
}
|
|
464
352
|
|
|
465
|
-
try {
|
|
466
353
|
const tables = await this.lanceClient.tableNames();
|
|
467
354
|
if (!tables.includes(tableName)) {
|
|
468
355
|
throw new Error(
|
|
@@ -503,27 +390,13 @@ export class LanceVectorStore extends MastraVector<LanceVectorFilter> {
|
|
|
503
390
|
});
|
|
504
391
|
}
|
|
505
392
|
} catch (error: any) {
|
|
506
|
-
throw new
|
|
507
|
-
{
|
|
508
|
-
id: 'STORAGE_LANCE_VECTOR_CREATE_INDEX_FAILED',
|
|
509
|
-
domain: ErrorDomain.STORAGE,
|
|
510
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
511
|
-
details: { tableName: tableName || '', indexName, dimension },
|
|
512
|
-
},
|
|
513
|
-
error,
|
|
514
|
-
);
|
|
393
|
+
throw new Error(`Failed to create index: ${error.message}`);
|
|
515
394
|
}
|
|
516
395
|
}
|
|
517
396
|
|
|
518
397
|
async listIndexes(): Promise<string[]> {
|
|
519
398
|
if (!this.lanceClient) {
|
|
520
|
-
throw new
|
|
521
|
-
id: 'STORAGE_LANCE_VECTOR_LIST_INDEXES_FAILED_INVALID_ARGS',
|
|
522
|
-
domain: ErrorDomain.STORAGE,
|
|
523
|
-
category: ErrorCategory.USER,
|
|
524
|
-
text: 'LanceDB client not initialized. Use LanceVectorStore.create() to create an instance',
|
|
525
|
-
details: { methodName: 'listIndexes' },
|
|
526
|
-
});
|
|
399
|
+
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
527
400
|
}
|
|
528
401
|
|
|
529
402
|
try {
|
|
@@ -538,36 +411,17 @@ export class LanceVectorStore extends MastraVector<LanceVectorFilter> {
|
|
|
538
411
|
|
|
539
412
|
return allIndices;
|
|
540
413
|
} catch (error: any) {
|
|
541
|
-
throw new
|
|
542
|
-
{
|
|
543
|
-
id: 'STORAGE_LANCE_VECTOR_LIST_INDEXES_FAILED',
|
|
544
|
-
domain: ErrorDomain.STORAGE,
|
|
545
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
546
|
-
},
|
|
547
|
-
error,
|
|
548
|
-
);
|
|
414
|
+
throw new Error(`Failed to list indexes: ${error.message}`);
|
|
549
415
|
}
|
|
550
416
|
}
|
|
551
417
|
|
|
552
418
|
async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
}
|
|
419
|
+
if (!this.lanceClient) {
|
|
420
|
+
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
421
|
+
}
|
|
557
422
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
}
|
|
561
|
-
} catch (err) {
|
|
562
|
-
throw new MastraError(
|
|
563
|
-
{
|
|
564
|
-
id: 'STORAGE_LANCE_VECTOR_DESCRIBE_INDEX_FAILED_INVALID_ARGS',
|
|
565
|
-
domain: ErrorDomain.STORAGE,
|
|
566
|
-
category: ErrorCategory.USER,
|
|
567
|
-
details: { indexName },
|
|
568
|
-
},
|
|
569
|
-
err,
|
|
570
|
-
);
|
|
423
|
+
if (!indexName) {
|
|
424
|
+
throw new Error('indexName is required');
|
|
571
425
|
}
|
|
572
426
|
|
|
573
427
|
try {
|
|
@@ -603,38 +457,19 @@ export class LanceVectorStore extends MastraVector<LanceVectorFilter> {
|
|
|
603
457
|
|
|
604
458
|
throw new Error(`IndexName: ${indexName} not found`);
|
|
605
459
|
} catch (error: any) {
|
|
606
|
-
throw new
|
|
607
|
-
{
|
|
608
|
-
id: 'STORAGE_LANCE_VECTOR_DESCRIBE_INDEX_FAILED',
|
|
609
|
-
domain: ErrorDomain.STORAGE,
|
|
610
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
611
|
-
details: { indexName },
|
|
612
|
-
},
|
|
613
|
-
error,
|
|
614
|
-
);
|
|
460
|
+
throw new Error(`Failed to describe index: ${error.message}`);
|
|
615
461
|
}
|
|
616
462
|
}
|
|
617
463
|
|
|
618
464
|
async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
}
|
|
465
|
+
if (!this.lanceClient) {
|
|
466
|
+
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
467
|
+
}
|
|
623
468
|
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
}
|
|
627
|
-
} catch (err) {
|
|
628
|
-
throw new MastraError(
|
|
629
|
-
{
|
|
630
|
-
id: 'STORAGE_LANCE_VECTOR_DELETE_INDEX_FAILED_INVALID_ARGS',
|
|
631
|
-
domain: ErrorDomain.STORAGE,
|
|
632
|
-
category: ErrorCategory.USER,
|
|
633
|
-
details: { indexName },
|
|
634
|
-
},
|
|
635
|
-
err,
|
|
636
|
-
);
|
|
469
|
+
if (!indexName) {
|
|
470
|
+
throw new Error('indexName is required');
|
|
637
471
|
}
|
|
472
|
+
|
|
638
473
|
try {
|
|
639
474
|
const tables = await this.lanceClient.tableNames();
|
|
640
475
|
|
|
@@ -651,15 +486,7 @@ export class LanceVectorStore extends MastraVector<LanceVectorFilter> {
|
|
|
651
486
|
|
|
652
487
|
throw new Error(`Index ${indexName} not found`);
|
|
653
488
|
} catch (error: any) {
|
|
654
|
-
throw new
|
|
655
|
-
{
|
|
656
|
-
id: 'STORAGE_LANCE_VECTOR_DELETE_INDEX_FAILED',
|
|
657
|
-
domain: ErrorDomain.STORAGE,
|
|
658
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
659
|
-
details: { indexName },
|
|
660
|
-
},
|
|
661
|
-
error,
|
|
662
|
-
);
|
|
489
|
+
throw new Error(`Failed to delete index: ${error.message}`);
|
|
663
490
|
}
|
|
664
491
|
}
|
|
665
492
|
|
|
@@ -668,79 +495,39 @@ export class LanceVectorStore extends MastraVector<LanceVectorFilter> {
|
|
|
668
495
|
*/
|
|
669
496
|
async deleteAllTables(): Promise<void> {
|
|
670
497
|
if (!this.lanceClient) {
|
|
671
|
-
throw new
|
|
672
|
-
id: 'STORAGE_LANCE_VECTOR_DELETE_ALL_TABLES_FAILED_INVALID_ARGS',
|
|
673
|
-
domain: ErrorDomain.STORAGE,
|
|
674
|
-
category: ErrorCategory.USER,
|
|
675
|
-
details: { methodName: 'deleteAllTables' },
|
|
676
|
-
text: 'LanceDB client not initialized. Use LanceVectorStore.create() to create an instance',
|
|
677
|
-
});
|
|
498
|
+
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
678
499
|
}
|
|
500
|
+
|
|
679
501
|
try {
|
|
680
502
|
await this.lanceClient.dropAllTables();
|
|
681
|
-
} catch (error) {
|
|
682
|
-
throw new
|
|
683
|
-
{
|
|
684
|
-
id: 'STORAGE_LANCE_VECTOR_DELETE_ALL_TABLES_FAILED',
|
|
685
|
-
domain: ErrorDomain.STORAGE,
|
|
686
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
687
|
-
details: { methodName: 'deleteAllTables' },
|
|
688
|
-
},
|
|
689
|
-
error,
|
|
690
|
-
);
|
|
503
|
+
} catch (error: any) {
|
|
504
|
+
throw new Error(`Failed to delete tables: ${error.message}`);
|
|
691
505
|
}
|
|
692
506
|
}
|
|
693
507
|
|
|
694
508
|
async deleteTable(tableName: string): Promise<void> {
|
|
695
509
|
if (!this.lanceClient) {
|
|
696
|
-
throw new
|
|
697
|
-
id: 'STORAGE_LANCE_VECTOR_DELETE_TABLE_FAILED_INVALID_ARGS',
|
|
698
|
-
domain: ErrorDomain.STORAGE,
|
|
699
|
-
category: ErrorCategory.USER,
|
|
700
|
-
details: { tableName },
|
|
701
|
-
text: 'LanceDB client not initialized. Use LanceVectorStore.create() to create an instance',
|
|
702
|
-
});
|
|
510
|
+
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
703
511
|
}
|
|
704
512
|
|
|
705
513
|
try {
|
|
706
514
|
await this.lanceClient.dropTable(tableName);
|
|
707
515
|
} catch (error: any) {
|
|
708
|
-
|
|
709
|
-
throw new MastraError(
|
|
710
|
-
{
|
|
711
|
-
id: 'STORAGE_LANCE_VECTOR_DELETE_TABLE_FAILED',
|
|
712
|
-
domain: ErrorDomain.STORAGE,
|
|
713
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
714
|
-
details: { tableName },
|
|
715
|
-
},
|
|
716
|
-
error,
|
|
717
|
-
);
|
|
516
|
+
throw new Error(`Failed to delete tables: ${error.message}`);
|
|
718
517
|
}
|
|
719
518
|
}
|
|
720
519
|
|
|
721
520
|
async updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void> {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
}
|
|
521
|
+
if (!this.lanceClient) {
|
|
522
|
+
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
523
|
+
}
|
|
726
524
|
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
525
|
+
if (!indexName) {
|
|
526
|
+
throw new Error('indexName is required');
|
|
527
|
+
}
|
|
730
528
|
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
}
|
|
734
|
-
} catch (err) {
|
|
735
|
-
throw new MastraError(
|
|
736
|
-
{
|
|
737
|
-
id: 'STORAGE_LANCE_VECTOR_UPDATE_VECTOR_FAILED_INVALID_ARGS',
|
|
738
|
-
domain: ErrorDomain.STORAGE,
|
|
739
|
-
category: ErrorCategory.USER,
|
|
740
|
-
details: { indexName, id },
|
|
741
|
-
},
|
|
742
|
-
err,
|
|
743
|
-
);
|
|
529
|
+
if (!id) {
|
|
530
|
+
throw new Error('id is required');
|
|
744
531
|
}
|
|
745
532
|
|
|
746
533
|
try {
|
|
@@ -825,41 +612,21 @@ export class LanceVectorStore extends MastraVector<LanceVectorFilter> {
|
|
|
825
612
|
|
|
826
613
|
throw new Error(`No table found with column/index '${indexName}'`);
|
|
827
614
|
} catch (error: any) {
|
|
828
|
-
throw new
|
|
829
|
-
{
|
|
830
|
-
id: 'STORAGE_LANCE_VECTOR_UPDATE_VECTOR_FAILED',
|
|
831
|
-
domain: ErrorDomain.STORAGE,
|
|
832
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
833
|
-
details: { indexName, id, hasVector: !!update.vector, hasMetadata: !!update.metadata },
|
|
834
|
-
},
|
|
835
|
-
error,
|
|
836
|
-
);
|
|
615
|
+
throw new Error(`Failed to update index: ${error.message}`);
|
|
837
616
|
}
|
|
838
617
|
}
|
|
839
618
|
|
|
840
619
|
async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
}
|
|
620
|
+
if (!this.lanceClient) {
|
|
621
|
+
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
622
|
+
}
|
|
845
623
|
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
624
|
+
if (!indexName) {
|
|
625
|
+
throw new Error('indexName is required');
|
|
626
|
+
}
|
|
849
627
|
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
}
|
|
853
|
-
} catch (err) {
|
|
854
|
-
throw new MastraError(
|
|
855
|
-
{
|
|
856
|
-
id: 'STORAGE_LANCE_VECTOR_DELETE_VECTOR_FAILED_INVALID_ARGS',
|
|
857
|
-
domain: ErrorDomain.STORAGE,
|
|
858
|
-
category: ErrorCategory.USER,
|
|
859
|
-
details: { indexName, id },
|
|
860
|
-
},
|
|
861
|
-
err,
|
|
862
|
-
);
|
|
628
|
+
if (!id) {
|
|
629
|
+
throw new Error('id is required');
|
|
863
630
|
}
|
|
864
631
|
|
|
865
632
|
try {
|
|
@@ -890,15 +657,7 @@ export class LanceVectorStore extends MastraVector<LanceVectorFilter> {
|
|
|
890
657
|
|
|
891
658
|
throw new Error(`No table found with column/index '${indexName}'`);
|
|
892
659
|
} catch (error: any) {
|
|
893
|
-
throw new
|
|
894
|
-
{
|
|
895
|
-
id: 'STORAGE_LANCE_VECTOR_DELETE_VECTOR_FAILED',
|
|
896
|
-
domain: ErrorDomain.STORAGE,
|
|
897
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
898
|
-
details: { indexName, id },
|
|
899
|
-
},
|
|
900
|
-
error,
|
|
901
|
-
);
|
|
660
|
+
throw new Error(`Failed to delete index: ${error.message}`);
|
|
902
661
|
}
|
|
903
662
|
}
|
|
904
663
|
|