@mastra/turbopuffer 0.0.15 → 0.0.16-alpha.0

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,12 +1,17 @@
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';
6
9
  import type { OperatorSupport } from '@mastra/core/vector/filter';
10
+ import type { ParamsToArgs } from '@mastra/core/vector';
7
11
  import type { QueryResult } from '@mastra/core/vector';
8
12
  import type { QueryVectorParams } from '@mastra/core/vector';
9
13
  import type { Schema } from '@turbopuffer/turbopuffer';
14
+ import type { UpdateVectorParams } from '@mastra/core/vector';
10
15
  import type { UpsertVectorParams } from '@mastra/core/vector';
11
16
  import type { VectorFilter } from '@mastra/core/vector/filter';
12
17
 
@@ -62,8 +67,15 @@ declare class TurbopufferVector extends MastraVector {
62
67
  upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
63
68
  query({ indexName, queryVector, topK, filter, includeVector }: QueryVectorParams): Promise<QueryResult[]>;
64
69
  listIndexes(): Promise<string[]>;
65
- describeIndex(indexName: string): Promise<IndexStats>;
66
- deleteIndex(indexName: string): Promise<void>;
70
+ /**
71
+ * Retrieves statistics about a vector index.
72
+ *
73
+ * @param params - The parameters for describing an index
74
+ * @param params.indexName - The name of the index to describe
75
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
76
+ */
77
+ describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats>;
78
+ deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
67
79
  /**
68
80
  * Updates a vector by its ID with the provided vector and/or metadata.
69
81
  * @param indexName - The name of the index containing the vector.
@@ -74,10 +86,7 @@ declare class TurbopufferVector extends MastraVector {
74
86
  * @returns A promise that resolves when the update is complete.
75
87
  * @throws Will throw an error if no updates are provided or if the update operation fails.
76
88
  */
77
- updateVector(indexName: string, id: string, updates: {
78
- vector?: number[];
79
- metadata?: Record<string, any>;
80
- }): Promise<void>;
89
+ updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
81
90
  /**
82
91
  * Deletes a vector by its ID.
83
92
  * @param indexName - The name of the index containing the vector.
@@ -85,7 +94,7 @@ declare class TurbopufferVector extends MastraVector {
85
94
  * @returns A promise that resolves when the deletion is complete.
86
95
  * @throws Will throw an error if the deletion operation fails.
87
96
  */
88
- deleteVector(indexName: string, id: string): Promise<void>;
97
+ deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void>;
89
98
  }
90
99
  export { TurbopufferVector }
91
100
  export { TurbopufferVector as TurbopufferVector_alias_1 }
@@ -1,12 +1,17 @@
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';
6
9
  import type { OperatorSupport } from '@mastra/core/vector/filter';
10
+ import type { ParamsToArgs } from '@mastra/core/vector';
7
11
  import type { QueryResult } from '@mastra/core/vector';
8
12
  import type { QueryVectorParams } from '@mastra/core/vector';
9
13
  import type { Schema } from '@turbopuffer/turbopuffer';
14
+ import type { UpdateVectorParams } from '@mastra/core/vector';
10
15
  import type { UpsertVectorParams } from '@mastra/core/vector';
11
16
  import type { VectorFilter } from '@mastra/core/vector/filter';
12
17
 
@@ -62,8 +67,15 @@ declare class TurbopufferVector extends MastraVector {
62
67
  upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
63
68
  query({ indexName, queryVector, topK, filter, includeVector }: QueryVectorParams): Promise<QueryResult[]>;
64
69
  listIndexes(): Promise<string[]>;
65
- describeIndex(indexName: string): Promise<IndexStats>;
66
- deleteIndex(indexName: string): Promise<void>;
70
+ /**
71
+ * Retrieves statistics about a vector index.
72
+ *
73
+ * @param params - The parameters for describing an index
74
+ * @param params.indexName - The name of the index to describe
75
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
76
+ */
77
+ describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats>;
78
+ deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
67
79
  /**
68
80
  * Updates a vector by its ID with the provided vector and/or metadata.
69
81
  * @param indexName - The name of the index containing the vector.
@@ -74,10 +86,7 @@ declare class TurbopufferVector extends MastraVector {
74
86
  * @returns A promise that resolves when the update is complete.
75
87
  * @throws Will throw an error if no updates are provided or if the update operation fails.
76
88
  */
77
- updateVector(indexName: string, id: string, updates: {
78
- vector?: number[];
79
- metadata?: Record<string, any>;
80
- }): Promise<void>;
89
+ updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
81
90
  /**
82
91
  * Deletes a vector by its ID.
83
92
  * @param indexName - The name of the index containing the vector.
@@ -85,7 +94,7 @@ declare class TurbopufferVector extends MastraVector {
85
94
  * @returns A promise that resolves when the deletion is complete.
86
95
  * @throws Will throw an error if the deletion operation fails.
87
96
  */
88
- deleteVector(indexName: string, id: string): Promise<void>;
97
+ deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void>;
89
98
  }
90
99
  export { TurbopufferVector }
91
100
  export { TurbopufferVector as TurbopufferVector_alias_1 }
package/dist/index.cjs CHANGED
@@ -303,7 +303,16 @@ 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 params - The parameters for describing an index
310
+ * @param params.indexName - The name of the index to describe
311
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
312
+ */
313
+ async describeIndex(...args) {
314
+ const params = this.normalizeArgs("describeIndex", args);
315
+ const { indexName } = params;
307
316
  try {
308
317
  const namespace = this.client.namespace(indexName);
309
318
  const metadata = await namespace.metadata();
@@ -322,7 +331,9 @@ var TurbopufferVector = class extends vector.MastraVector {
322
331
  throw new Error(`Failed to describe Turbopuffer namespace ${indexName}: ${error}`);
323
332
  }
324
333
  }
325
- async deleteIndex(indexName) {
334
+ async deleteIndex(...args) {
335
+ const params = this.normalizeArgs("deleteIndex", args);
336
+ const { indexName } = params;
326
337
  try {
327
338
  const namespace = this.client.namespace(indexName);
328
339
  await namespace.deleteAll();
@@ -341,7 +352,9 @@ var TurbopufferVector = class extends vector.MastraVector {
341
352
  * @returns A promise that resolves when the update is complete.
342
353
  * @throws Will throw an error if no updates are provided or if the update operation fails.
343
354
  */
344
- async updateVector(indexName, id, updates) {
355
+ async updateVector(...args) {
356
+ const params = this.normalizeArgs("updateVector", args);
357
+ const { indexName, id, update } = params;
345
358
  try {
346
359
  const namespace = this.client.namespace(indexName);
347
360
  const createIndex = this.createIndexCache.get(indexName);
@@ -350,8 +363,8 @@ var TurbopufferVector = class extends vector.MastraVector {
350
363
  }
351
364
  const distanceMetric = createIndex.tpufDistanceMetric;
352
365
  const record = { id };
353
- if (updates.vector) record.vector = updates.vector;
354
- if (updates.metadata) record.attributes = updates.metadata;
366
+ if (update.vector) record.vector = update.vector;
367
+ if (update.metadata) record.attributes = update.metadata;
355
368
  await namespace.upsert({
356
369
  vectors: [record],
357
370
  distance_metric: distanceMetric
@@ -367,7 +380,9 @@ var TurbopufferVector = class extends vector.MastraVector {
367
380
  * @returns A promise that resolves when the deletion is complete.
368
381
  * @throws Will throw an error if the deletion operation fails.
369
382
  */
370
- async deleteVector(indexName, id) {
383
+ async deleteVector(...args) {
384
+ const params = this.normalizeArgs("deleteVector", args);
385
+ const { indexName, id } = params;
371
386
  try {
372
387
  const namespace = this.client.namespace(indexName);
373
388
  await namespace.delete({ ids: [id] });
package/dist/index.js CHANGED
@@ -301,7 +301,16 @@ 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 params - The parameters for describing an index
308
+ * @param params.indexName - The name of the index to describe
309
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
310
+ */
311
+ async describeIndex(...args) {
312
+ const params = this.normalizeArgs("describeIndex", args);
313
+ const { indexName } = params;
305
314
  try {
306
315
  const namespace = this.client.namespace(indexName);
307
316
  const metadata = await namespace.metadata();
@@ -320,7 +329,9 @@ var TurbopufferVector = class extends MastraVector {
320
329
  throw new Error(`Failed to describe Turbopuffer namespace ${indexName}: ${error}`);
321
330
  }
322
331
  }
323
- async deleteIndex(indexName) {
332
+ async deleteIndex(...args) {
333
+ const params = this.normalizeArgs("deleteIndex", args);
334
+ const { indexName } = params;
324
335
  try {
325
336
  const namespace = this.client.namespace(indexName);
326
337
  await namespace.deleteAll();
@@ -339,7 +350,9 @@ var TurbopufferVector = class extends MastraVector {
339
350
  * @returns A promise that resolves when the update is complete.
340
351
  * @throws Will throw an error if no updates are provided or if the update operation fails.
341
352
  */
342
- async updateVector(indexName, id, updates) {
353
+ async updateVector(...args) {
354
+ const params = this.normalizeArgs("updateVector", args);
355
+ const { indexName, id, update } = params;
343
356
  try {
344
357
  const namespace = this.client.namespace(indexName);
345
358
  const createIndex = this.createIndexCache.get(indexName);
@@ -348,8 +361,8 @@ var TurbopufferVector = class extends MastraVector {
348
361
  }
349
362
  const distanceMetric = createIndex.tpufDistanceMetric;
350
363
  const record = { id };
351
- if (updates.vector) record.vector = updates.vector;
352
- if (updates.metadata) record.attributes = updates.metadata;
364
+ if (update.vector) record.vector = update.vector;
365
+ if (update.metadata) record.attributes = update.metadata;
353
366
  await namespace.upsert({
354
367
  vectors: [record],
355
368
  distance_metric: distanceMetric
@@ -365,7 +378,9 @@ var TurbopufferVector = class extends MastraVector {
365
378
  * @returns A promise that resolves when the deletion is complete.
366
379
  * @throws Will throw an error if the deletion operation fails.
367
380
  */
368
- async deleteVector(indexName, id) {
381
+ async deleteVector(...args) {
382
+ const params = this.normalizeArgs("deleteVector", args);
383
+ const { indexName, id } = params;
369
384
  try {
370
385
  const namespace = this.client.namespace(indexName);
371
386
  await namespace.delete({ ids: [id] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/turbopuffer",
3
- "version": "0.0.15",
3
+ "version": "0.0.16-alpha.0",
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"
27
+ "@mastra/core": "^0.9.5-alpha.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@microsoft/api-extractor": "^7.52.5",