@mastra/turbopuffer 0.0.0-switch-to-core-20250424015131 → 0.0.0-taofeeqInngest-20250603090617

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.
@@ -1,5 +1,8 @@
1
1
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
2
  import type { CreateIndexParams } from '@mastra/core/vector';
3
+ import type { DeleteIndexParams } from '@mastra/core/vector';
4
+ import type { DeleteVectorParams } from '@mastra/core/vector';
5
+ import type { DescribeIndexParams } from '@mastra/core/vector';
3
6
  import type { Filters } from '@turbopuffer/turbopuffer';
4
7
  import type { IndexStats } from '@mastra/core/vector';
5
8
  import { MastraVector } from '@mastra/core/vector';
@@ -7,6 +10,7 @@ import type { OperatorSupport } from '@mastra/core/vector/filter';
7
10
  import type { QueryResult } from '@mastra/core/vector';
8
11
  import type { QueryVectorParams } from '@mastra/core/vector';
9
12
  import type { Schema } from '@turbopuffer/turbopuffer';
13
+ import type { UpdateVectorParams } from '@mastra/core/vector';
10
14
  import type { UpsertVectorParams } from '@mastra/core/vector';
11
15
  import type { VectorFilter } from '@mastra/core/vector/filter';
12
16
 
@@ -62,8 +66,33 @@ declare class TurbopufferVector extends MastraVector {
62
66
  upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
63
67
  query({ indexName, queryVector, topK, filter, includeVector }: QueryVectorParams): Promise<QueryResult[]>;
64
68
  listIndexes(): Promise<string[]>;
65
- describeIndex(indexName: string): Promise<IndexStats>;
66
- deleteIndex(indexName: string): Promise<void>;
69
+ /**
70
+ * Retrieves statistics about a vector index.
71
+ *
72
+ * @param {string} indexName - The name of the index to describe
73
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
74
+ */
75
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
76
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
77
+ /**
78
+ * Updates a vector by its ID with the provided vector and/or metadata.
79
+ * @param indexName - The name of the index containing the vector.
80
+ * @param id - The ID of the vector to update.
81
+ * @param update - An object containing the vector and/or metadata to update.
82
+ * @param update.vector - An optional array of numbers representing the new vector.
83
+ * @param update.metadata - An optional record containing the new metadata.
84
+ * @returns A promise that resolves when the update is complete.
85
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
86
+ */
87
+ updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
88
+ /**
89
+ * Deletes a vector by its ID.
90
+ * @param indexName - The name of the index containing the vector.
91
+ * @param id - The ID of the vector to delete.
92
+ * @returns A promise that resolves when the deletion is complete.
93
+ * @throws Will throw an error if the deletion operation fails.
94
+ */
95
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
67
96
  }
68
97
  export { TurbopufferVector }
69
98
  export { TurbopufferVector as TurbopufferVector_alias_1 }
@@ -1,5 +1,8 @@
1
1
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
2
  import type { CreateIndexParams } from '@mastra/core/vector';
3
+ import type { DeleteIndexParams } from '@mastra/core/vector';
4
+ import type { DeleteVectorParams } from '@mastra/core/vector';
5
+ import type { DescribeIndexParams } from '@mastra/core/vector';
3
6
  import type { Filters } from '@turbopuffer/turbopuffer';
4
7
  import type { IndexStats } from '@mastra/core/vector';
5
8
  import { MastraVector } from '@mastra/core/vector';
@@ -7,6 +10,7 @@ import type { OperatorSupport } from '@mastra/core/vector/filter';
7
10
  import type { QueryResult } from '@mastra/core/vector';
8
11
  import type { QueryVectorParams } from '@mastra/core/vector';
9
12
  import type { Schema } from '@turbopuffer/turbopuffer';
13
+ import type { UpdateVectorParams } from '@mastra/core/vector';
10
14
  import type { UpsertVectorParams } from '@mastra/core/vector';
11
15
  import type { VectorFilter } from '@mastra/core/vector/filter';
12
16
 
@@ -62,8 +66,33 @@ declare class TurbopufferVector extends MastraVector {
62
66
  upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
63
67
  query({ indexName, queryVector, topK, filter, includeVector }: QueryVectorParams): Promise<QueryResult[]>;
64
68
  listIndexes(): Promise<string[]>;
65
- describeIndex(indexName: string): Promise<IndexStats>;
66
- deleteIndex(indexName: string): Promise<void>;
69
+ /**
70
+ * Retrieves statistics about a vector index.
71
+ *
72
+ * @param {string} indexName - The name of the index to describe
73
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
74
+ */
75
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
76
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
77
+ /**
78
+ * Updates a vector by its ID with the provided vector and/or metadata.
79
+ * @param indexName - The name of the index containing the vector.
80
+ * @param id - The ID of the vector to update.
81
+ * @param update - An object containing the vector and/or metadata to update.
82
+ * @param update.vector - An optional array of numbers representing the new vector.
83
+ * @param update.metadata - An optional record containing the new metadata.
84
+ * @returns A promise that resolves when the update is complete.
85
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
86
+ */
87
+ updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
88
+ /**
89
+ * Deletes a vector by its ID.
90
+ * @param indexName - The name of the index containing the vector.
91
+ * @param id - The ID of the vector to delete.
92
+ * @returns A promise that resolves when the deletion is complete.
93
+ * @throws Will throw an error if the deletion operation fails.
94
+ */
95
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
67
96
  }
68
97
  export { TurbopufferVector }
69
98
  export { TurbopufferVector as TurbopufferVector_alias_1 }
package/dist/index.cjs CHANGED
@@ -303,7 +303,13 @@ var TurbopufferVector = class extends vector.MastraVector {
303
303
  throw new Error(`Failed to list Turbopuffer namespaces: ${error}`);
304
304
  }
305
305
  }
306
- async describeIndex(indexName) {
306
+ /**
307
+ * Retrieves statistics about a vector index.
308
+ *
309
+ * @param {string} indexName - The name of the index to describe
310
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
311
+ */
312
+ async describeIndex({ indexName }) {
307
313
  try {
308
314
  const namespace = this.client.namespace(indexName);
309
315
  const metadata = await namespace.metadata();
@@ -322,7 +328,7 @@ var TurbopufferVector = class extends vector.MastraVector {
322
328
  throw new Error(`Failed to describe Turbopuffer namespace ${indexName}: ${error}`);
323
329
  }
324
330
  }
325
- async deleteIndex(indexName) {
331
+ async deleteIndex({ indexName }) {
326
332
  try {
327
333
  const namespace = this.client.namespace(indexName);
328
334
  await namespace.deleteAll();
@@ -331,6 +337,50 @@ var TurbopufferVector = class extends vector.MastraVector {
331
337
  throw new Error(`Failed to delete Turbopuffer namespace ${indexName}: ${error.message}`);
332
338
  }
333
339
  }
340
+ /**
341
+ * Updates a vector by its ID with the provided vector and/or metadata.
342
+ * @param indexName - The name of the index containing the vector.
343
+ * @param id - The ID of the vector to update.
344
+ * @param update - An object containing the vector and/or metadata to update.
345
+ * @param update.vector - An optional array of numbers representing the new vector.
346
+ * @param update.metadata - An optional record containing the new metadata.
347
+ * @returns A promise that resolves when the update is complete.
348
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
349
+ */
350
+ async updateVector({ indexName, id, update }) {
351
+ try {
352
+ const namespace = this.client.namespace(indexName);
353
+ const createIndex = this.createIndexCache.get(indexName);
354
+ if (!createIndex) {
355
+ throw new Error(`createIndex() not called for this index`);
356
+ }
357
+ const distanceMetric = createIndex.tpufDistanceMetric;
358
+ const record = { id };
359
+ if (update.vector) record.vector = update.vector;
360
+ if (update.metadata) record.attributes = update.metadata;
361
+ await namespace.upsert({
362
+ vectors: [record],
363
+ distance_metric: distanceMetric
364
+ });
365
+ } catch (error) {
366
+ throw new Error(`Failed to update Turbopuffer namespace ${indexName}: ${error.message}`);
367
+ }
368
+ }
369
+ /**
370
+ * Deletes a vector by its ID.
371
+ * @param indexName - The name of the index containing the vector.
372
+ * @param id - The ID of the vector to delete.
373
+ * @returns A promise that resolves when the deletion is complete.
374
+ * @throws Will throw an error if the deletion operation fails.
375
+ */
376
+ async deleteVector({ indexName, id }) {
377
+ try {
378
+ const namespace = this.client.namespace(indexName);
379
+ await namespace.delete({ ids: [id] });
380
+ } catch (error) {
381
+ throw new Error(`Failed to delete Turbopuffer namespace ${indexName}: ${error.message}`);
382
+ }
383
+ }
334
384
  };
335
385
 
336
386
  exports.TurbopufferVector = TurbopufferVector;
package/dist/index.js CHANGED
@@ -301,7 +301,13 @@ var TurbopufferVector = class extends MastraVector {
301
301
  throw new Error(`Failed to list Turbopuffer namespaces: ${error}`);
302
302
  }
303
303
  }
304
- async describeIndex(indexName) {
304
+ /**
305
+ * Retrieves statistics about a vector index.
306
+ *
307
+ * @param {string} indexName - The name of the index to describe
308
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
309
+ */
310
+ async describeIndex({ indexName }) {
305
311
  try {
306
312
  const namespace = this.client.namespace(indexName);
307
313
  const metadata = await namespace.metadata();
@@ -320,7 +326,7 @@ var TurbopufferVector = class extends MastraVector {
320
326
  throw new Error(`Failed to describe Turbopuffer namespace ${indexName}: ${error}`);
321
327
  }
322
328
  }
323
- async deleteIndex(indexName) {
329
+ async deleteIndex({ indexName }) {
324
330
  try {
325
331
  const namespace = this.client.namespace(indexName);
326
332
  await namespace.deleteAll();
@@ -329,6 +335,50 @@ var TurbopufferVector = class extends MastraVector {
329
335
  throw new Error(`Failed to delete Turbopuffer namespace ${indexName}: ${error.message}`);
330
336
  }
331
337
  }
338
+ /**
339
+ * Updates a vector by its ID with the provided vector and/or metadata.
340
+ * @param indexName - The name of the index containing the vector.
341
+ * @param id - The ID of the vector to update.
342
+ * @param update - An object containing the vector and/or metadata to update.
343
+ * @param update.vector - An optional array of numbers representing the new vector.
344
+ * @param update.metadata - An optional record containing the new metadata.
345
+ * @returns A promise that resolves when the update is complete.
346
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
347
+ */
348
+ async updateVector({ indexName, id, update }) {
349
+ try {
350
+ const namespace = this.client.namespace(indexName);
351
+ const createIndex = this.createIndexCache.get(indexName);
352
+ if (!createIndex) {
353
+ throw new Error(`createIndex() not called for this index`);
354
+ }
355
+ const distanceMetric = createIndex.tpufDistanceMetric;
356
+ const record = { id };
357
+ if (update.vector) record.vector = update.vector;
358
+ if (update.metadata) record.attributes = update.metadata;
359
+ await namespace.upsert({
360
+ vectors: [record],
361
+ distance_metric: distanceMetric
362
+ });
363
+ } catch (error) {
364
+ throw new Error(`Failed to update Turbopuffer namespace ${indexName}: ${error.message}`);
365
+ }
366
+ }
367
+ /**
368
+ * Deletes a vector by its ID.
369
+ * @param indexName - The name of the index containing the vector.
370
+ * @param id - The ID of the vector to delete.
371
+ * @returns A promise that resolves when the deletion is complete.
372
+ * @throws Will throw an error if the deletion operation fails.
373
+ */
374
+ async deleteVector({ indexName, id }) {
375
+ try {
376
+ const namespace = this.client.namespace(indexName);
377
+ await namespace.delete({ ids: [id] });
378
+ } catch (error) {
379
+ throw new Error(`Failed to delete Turbopuffer namespace ${indexName}: ${error.message}`);
380
+ }
381
+ }
332
382
  };
333
383
 
334
384
  export { TurbopufferVector };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/turbopuffer",
3
- "version": "0.0.0-switch-to-core-20250424015131",
3
+ "version": "0.0.0-taofeeqInngest-20250603090617",
4
4
  "description": "Turbopuffer vector store provider for Mastra",
5
5
  "type": "module",
6
6
  "files": [
@@ -23,18 +23,21 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
- "@turbopuffer/turbopuffer": "^0.6.4",
27
- "@mastra/core": "0.0.0-switch-to-core-20250424015131"
26
+ "@turbopuffer/turbopuffer": "^0.6.4"
28
27
  },
29
28
  "devDependencies": {
30
- "@microsoft/api-extractor": "^7.52.1",
29
+ "@microsoft/api-extractor": "^7.52.5",
31
30
  "@types/node": "^20.17.27",
32
31
  "dotenv": "^16.4.7",
33
32
  "eslint": "^9.23.0",
34
33
  "tsup": "^8.4.0",
35
34
  "typescript": "^5.8.2",
36
- "vitest": "^3.0.9",
37
- "@internal/lint": "0.0.2"
35
+ "vitest": "^3.1.2",
36
+ "@internal/lint": "0.0.0-taofeeqInngest-20250603090617",
37
+ "@mastra/core": "0.0.0-taofeeqInngest-20250603090617"
38
+ },
39
+ "peerDependencies": {
40
+ "@mastra/core": "^0.10.0-alpha.0"
38
41
  },
39
42
  "scripts": {
40
43
  "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",