@mastra/turbopuffer 0.0.15-alpha.1 → 0.0.15-alpha.3

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.
@@ -64,6 +64,28 @@ declare class TurbopufferVector extends MastraVector {
64
64
  listIndexes(): Promise<string[]>;
65
65
  describeIndex(indexName: string): Promise<IndexStats>;
66
66
  deleteIndex(indexName: string): Promise<void>;
67
+ /**
68
+ * Updates a vector by its ID with the provided vector and/or metadata.
69
+ * @param indexName - The name of the index containing the vector.
70
+ * @param id - The ID of the vector to update.
71
+ * @param update - An object containing the vector and/or metadata to update.
72
+ * @param update.vector - An optional array of numbers representing the new vector.
73
+ * @param update.metadata - An optional record containing the new metadata.
74
+ * @returns A promise that resolves when the update is complete.
75
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
76
+ */
77
+ updateVector(indexName: string, id: string, updates: {
78
+ vector?: number[];
79
+ metadata?: Record<string, any>;
80
+ }): Promise<void>;
81
+ /**
82
+ * Deletes a vector by its ID.
83
+ * @param indexName - The name of the index containing the vector.
84
+ * @param id - The ID of the vector to delete.
85
+ * @returns A promise that resolves when the deletion is complete.
86
+ * @throws Will throw an error if the deletion operation fails.
87
+ */
88
+ deleteVector(indexName: string, id: string): Promise<void>;
67
89
  }
68
90
  export { TurbopufferVector }
69
91
  export { TurbopufferVector as TurbopufferVector_alias_1 }
@@ -64,6 +64,28 @@ declare class TurbopufferVector extends MastraVector {
64
64
  listIndexes(): Promise<string[]>;
65
65
  describeIndex(indexName: string): Promise<IndexStats>;
66
66
  deleteIndex(indexName: string): Promise<void>;
67
+ /**
68
+ * Updates a vector by its ID with the provided vector and/or metadata.
69
+ * @param indexName - The name of the index containing the vector.
70
+ * @param id - The ID of the vector to update.
71
+ * @param update - An object containing the vector and/or metadata to update.
72
+ * @param update.vector - An optional array of numbers representing the new vector.
73
+ * @param update.metadata - An optional record containing the new metadata.
74
+ * @returns A promise that resolves when the update is complete.
75
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
76
+ */
77
+ updateVector(indexName: string, id: string, updates: {
78
+ vector?: number[];
79
+ metadata?: Record<string, any>;
80
+ }): Promise<void>;
81
+ /**
82
+ * Deletes a vector by its ID.
83
+ * @param indexName - The name of the index containing the vector.
84
+ * @param id - The ID of the vector to delete.
85
+ * @returns A promise that resolves when the deletion is complete.
86
+ * @throws Will throw an error if the deletion operation fails.
87
+ */
88
+ deleteVector(indexName: string, id: string): Promise<void>;
67
89
  }
68
90
  export { TurbopufferVector }
69
91
  export { TurbopufferVector as TurbopufferVector_alias_1 }
package/dist/index.cjs CHANGED
@@ -331,6 +331,50 @@ var TurbopufferVector = class extends vector.MastraVector {
331
331
  throw new Error(`Failed to delete Turbopuffer namespace ${indexName}: ${error.message}`);
332
332
  }
333
333
  }
334
+ /**
335
+ * Updates a vector by its ID with the provided vector and/or metadata.
336
+ * @param indexName - The name of the index containing the vector.
337
+ * @param id - The ID of the vector to update.
338
+ * @param update - An object containing the vector and/or metadata to update.
339
+ * @param update.vector - An optional array of numbers representing the new vector.
340
+ * @param update.metadata - An optional record containing the new metadata.
341
+ * @returns A promise that resolves when the update is complete.
342
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
343
+ */
344
+ async updateVector(indexName, id, updates) {
345
+ try {
346
+ const namespace = this.client.namespace(indexName);
347
+ const createIndex = this.createIndexCache.get(indexName);
348
+ if (!createIndex) {
349
+ throw new Error(`createIndex() not called for this index`);
350
+ }
351
+ const distanceMetric = createIndex.tpufDistanceMetric;
352
+ const record = { id };
353
+ if (updates.vector) record.vector = updates.vector;
354
+ if (updates.metadata) record.attributes = updates.metadata;
355
+ await namespace.upsert({
356
+ vectors: [record],
357
+ distance_metric: distanceMetric
358
+ });
359
+ } catch (error) {
360
+ throw new Error(`Failed to update Turbopuffer namespace ${indexName}: ${error.message}`);
361
+ }
362
+ }
363
+ /**
364
+ * Deletes a vector by its ID.
365
+ * @param indexName - The name of the index containing the vector.
366
+ * @param id - The ID of the vector to delete.
367
+ * @returns A promise that resolves when the deletion is complete.
368
+ * @throws Will throw an error if the deletion operation fails.
369
+ */
370
+ async deleteVector(indexName, id) {
371
+ try {
372
+ const namespace = this.client.namespace(indexName);
373
+ await namespace.delete({ ids: [id] });
374
+ } catch (error) {
375
+ throw new Error(`Failed to delete Turbopuffer namespace ${indexName}: ${error.message}`);
376
+ }
377
+ }
334
378
  };
335
379
 
336
380
  exports.TurbopufferVector = TurbopufferVector;
package/dist/index.js CHANGED
@@ -329,6 +329,50 @@ var TurbopufferVector = class extends MastraVector {
329
329
  throw new Error(`Failed to delete Turbopuffer namespace ${indexName}: ${error.message}`);
330
330
  }
331
331
  }
332
+ /**
333
+ * Updates a vector by its ID with the provided vector and/or metadata.
334
+ * @param indexName - The name of the index containing the vector.
335
+ * @param id - The ID of the vector to update.
336
+ * @param update - An object containing the vector and/or metadata to update.
337
+ * @param update.vector - An optional array of numbers representing the new vector.
338
+ * @param update.metadata - An optional record containing the new metadata.
339
+ * @returns A promise that resolves when the update is complete.
340
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
341
+ */
342
+ async updateVector(indexName, id, updates) {
343
+ try {
344
+ const namespace = this.client.namespace(indexName);
345
+ const createIndex = this.createIndexCache.get(indexName);
346
+ if (!createIndex) {
347
+ throw new Error(`createIndex() not called for this index`);
348
+ }
349
+ const distanceMetric = createIndex.tpufDistanceMetric;
350
+ const record = { id };
351
+ if (updates.vector) record.vector = updates.vector;
352
+ if (updates.metadata) record.attributes = updates.metadata;
353
+ await namespace.upsert({
354
+ vectors: [record],
355
+ distance_metric: distanceMetric
356
+ });
357
+ } catch (error) {
358
+ throw new Error(`Failed to update Turbopuffer namespace ${indexName}: ${error.message}`);
359
+ }
360
+ }
361
+ /**
362
+ * Deletes a vector by its ID.
363
+ * @param indexName - The name of the index containing the vector.
364
+ * @param id - The ID of the vector to delete.
365
+ * @returns A promise that resolves when the deletion is complete.
366
+ * @throws Will throw an error if the deletion operation fails.
367
+ */
368
+ async deleteVector(indexName, id) {
369
+ try {
370
+ const namespace = this.client.namespace(indexName);
371
+ await namespace.delete({ ids: [id] });
372
+ } catch (error) {
373
+ throw new Error(`Failed to delete Turbopuffer namespace ${indexName}: ${error.message}`);
374
+ }
375
+ }
332
376
  };
333
377
 
334
378
  export { TurbopufferVector };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/turbopuffer",
3
- "version": "0.0.15-alpha.1",
3
+ "version": "0.0.15-alpha.3",
4
4
  "description": "Turbopuffer vector store provider for Mastra",
5
5
  "type": "module",
6
6
  "files": [
@@ -24,7 +24,7 @@
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
26
  "@turbopuffer/turbopuffer": "^0.6.4",
27
- "@mastra/core": "^0.9.4-alpha.1"
27
+ "@mastra/core": "^0.9.4-alpha.3"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@microsoft/api-extractor": "^7.52.5",