@mastra/chroma 0.2.15 → 0.3.0-alpha.1

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,23 +1,23 @@
1
1
 
2
- > @mastra/chroma@0.2.15-alpha.4 build /home/runner/work/mastra/mastra/stores/chroma
2
+ > @mastra/chroma@0.3.0-alpha.1 build /home/runner/work/mastra/mastra/stores/chroma
3
3
  > tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
4
4
 
5
5
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.4.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 8734ms
9
+ TSC ⚡️ Build success in 10085ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.8.3
13
13
  Writing package typings: /home/runner/work/mastra/mastra/stores/chroma/dist/_tsup-dts-rollup.d.ts
14
14
  Analysis will use the bundled TypeScript version 5.8.3
15
15
  Writing package typings: /home/runner/work/mastra/mastra/stores/chroma/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 8679ms
16
+ DTS ⚡️ Build success in 9053ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- CJS dist/index.cjs 13.98 KB
21
- CJS ⚡️ Build success in 675ms
22
- ESM dist/index.js 13.93 KB
23
- ESM ⚡️ Build success in 682ms
20
+ ESM dist/index.js 12.30 KB
21
+ ESM ⚡️ Build success in 622ms
22
+ CJS dist/index.cjs 12.35 KB
23
+ CJS ⚡️ Build success in 623ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # @mastra/chroma
2
2
 
3
+ ## 0.3.0-alpha.1
4
+
5
+ ### Minor Changes
6
+
7
+ - 83da932: Move @mastra/core to peerdeps
8
+
9
+ ### Patch Changes
10
+
11
+ - a7292b0: BREAKING(@mastra/core, all vector stores): Vector store breaking changes (remove deprecated functions and positional arguments)
12
+ - Updated dependencies [b3a3d63]
13
+ - Updated dependencies [344f453]
14
+ - Updated dependencies [0a3ae6d]
15
+ - Updated dependencies [95911be]
16
+ - Updated dependencies [5eb5a99]
17
+ - Updated dependencies [7e632c5]
18
+ - Updated dependencies [1e9fbfa]
19
+ - Updated dependencies [b2ae5aa]
20
+ - Updated dependencies [a7292b0]
21
+ - Updated dependencies [0dcb9f0]
22
+ - @mastra/core@0.10.0-alpha.1
23
+
24
+ ## 0.2.16-alpha.0
25
+
26
+ ### Patch Changes
27
+
28
+ - d0ee3c6: Change all public functions and constructors in vector stores to use named args and prepare to phase out positional args
29
+ - Updated dependencies [f53a6ac]
30
+ - Updated dependencies [eabdcd9]
31
+ - Updated dependencies [90be034]
32
+ - Updated dependencies [99f050a]
33
+ - Updated dependencies [d0ee3c6]
34
+ - Updated dependencies [23f258c]
35
+ - Updated dependencies [2672a05]
36
+ - @mastra/core@0.9.5-alpha.0
37
+
3
38
  ## 0.2.15
4
39
 
5
40
  ### Patch Changes
@@ -1,13 +1,14 @@
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 { IndexStats } from '@mastra/core/vector';
4
7
  import { MastraVector } from '@mastra/core/vector';
5
8
  import type { OperatorSupport } from '@mastra/core/vector/filter';
6
- import type { ParamsToArgs } from '@mastra/core/vector';
7
9
  import type { QueryResult } from '@mastra/core/vector';
8
- import type { QueryVectorArgs } from '@mastra/core/vector';
9
10
  import type { QueryVectorParams } from '@mastra/core/vector';
10
- import type { UpsertVectorArgs } from '@mastra/core/vector';
11
+ import type { UpdateVectorParams } from '@mastra/core/vector';
11
12
  import type { UpsertVectorParams } from '@mastra/core/vector';
12
13
  import type { VectorFilter } from '@mastra/core/vector/filter';
13
14
 
@@ -31,14 +32,10 @@ export declare class ChromaFilterTranslator extends BaseFilterTranslator {
31
32
  private translateOperator;
32
33
  }
33
34
 
34
- declare type ChromaQueryArgs = [...QueryVectorArgs, VectorFilter?];
35
-
36
35
  declare interface ChromaQueryVectorParams extends QueryVectorParams {
37
36
  documentFilter?: VectorFilter;
38
37
  }
39
38
 
40
- declare type ChromaUpsertArgs = [...UpsertVectorArgs, string[]?];
41
-
42
39
  declare interface ChromaUpsertVectorParams extends UpsertVectorParams {
43
40
  documents?: string[];
44
41
  }
@@ -55,30 +52,20 @@ declare class ChromaVector extends MastraVector {
55
52
  });
56
53
  getCollection(indexName: string, throwIfNotExists?: boolean): Promise<any>;
57
54
  private validateVectorDimensions;
58
- upsert(...args: ParamsToArgs<ChromaUpsertVectorParams> | ChromaUpsertArgs): Promise<string[]>;
55
+ upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]>;
59
56
  private HnswSpaceMap;
60
- createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void>;
57
+ createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
61
58
  transformFilter(filter?: VectorFilter): VectorFilter;
62
- query(...args: ParamsToArgs<ChromaQueryVectorParams> | ChromaQueryArgs): Promise<QueryResult[]>;
59
+ query({ indexName, queryVector, topK, filter, includeVector, documentFilter, }: ChromaQueryVectorParams): Promise<QueryResult[]>;
63
60
  listIndexes(): Promise<string[]>;
64
- describeIndex(indexName: string): Promise<IndexStats>;
65
- deleteIndex(indexName: string): Promise<void>;
66
61
  /**
67
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
62
+ * Retrieves statistics about a vector index.
68
63
  *
69
- * Updates a vector by its ID with the provided vector and/or metadata.
70
- * @param indexName - The name of the index containing the vector.
71
- * @param id - The ID of the vector to update.
72
- * @param update - An object containing the vector and/or metadata to update.
73
- * @param update.vector - An optional array of numbers representing the new vector.
74
- * @param update.metadata - An optional record containing the new metadata.
75
- * @returns A promise that resolves when the update is complete.
76
- * @throws Will throw an error if no updates are provided or if the update operation fails.
64
+ * @param {string} indexName - The name of the index to describe
65
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
77
66
  */
78
- updateIndexById(indexName: string, id: string, update: {
79
- vector?: number[];
80
- metadata?: Record<string, any>;
81
- }): Promise<void>;
67
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
68
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
82
69
  /**
83
70
  * Updates a vector by its ID with the provided vector and/or metadata.
84
71
  * @param indexName - The name of the index containing the vector.
@@ -89,20 +76,7 @@ declare class ChromaVector extends MastraVector {
89
76
  * @returns A promise that resolves when the update is complete.
90
77
  * @throws Will throw an error if no updates are provided or if the update operation fails.
91
78
  */
92
- updateVector(indexName: string, id: string, update: {
93
- vector?: number[];
94
- metadata?: Record<string, any>;
95
- }): Promise<void>;
96
- /**
97
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
98
- *
99
- * Deletes a vector by its ID.
100
- * @param indexName - The name of the index containing the vector.
101
- * @param id - The ID of the vector to delete.
102
- * @returns A promise that resolves when the deletion is complete.
103
- * @throws Will throw an error if the deletion operation fails.
104
- */
105
- deleteIndexById(indexName: string, id: string): Promise<void>;
79
+ updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
106
80
  /**
107
81
  * Deletes a vector by its ID.
108
82
  * @param indexName - The name of the index containing the vector.
@@ -110,7 +84,7 @@ declare class ChromaVector extends MastraVector {
110
84
  * @returns A promise that resolves when the deletion is complete.
111
85
  * @throws Will throw an error if the deletion operation fails.
112
86
  */
113
- deleteVector(indexName: string, id: string): Promise<void>;
87
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
114
88
  }
115
89
  export { ChromaVector }
116
90
  export { ChromaVector as ChromaVector_alias_1 }
@@ -1,13 +1,14 @@
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 { IndexStats } from '@mastra/core/vector';
4
7
  import { MastraVector } from '@mastra/core/vector';
5
8
  import type { OperatorSupport } from '@mastra/core/vector/filter';
6
- import type { ParamsToArgs } from '@mastra/core/vector';
7
9
  import type { QueryResult } from '@mastra/core/vector';
8
- import type { QueryVectorArgs } from '@mastra/core/vector';
9
10
  import type { QueryVectorParams } from '@mastra/core/vector';
10
- import type { UpsertVectorArgs } from '@mastra/core/vector';
11
+ import type { UpdateVectorParams } from '@mastra/core/vector';
11
12
  import type { UpsertVectorParams } from '@mastra/core/vector';
12
13
  import type { VectorFilter } from '@mastra/core/vector/filter';
13
14
 
@@ -31,14 +32,10 @@ export declare class ChromaFilterTranslator extends BaseFilterTranslator {
31
32
  private translateOperator;
32
33
  }
33
34
 
34
- declare type ChromaQueryArgs = [...QueryVectorArgs, VectorFilter?];
35
-
36
35
  declare interface ChromaQueryVectorParams extends QueryVectorParams {
37
36
  documentFilter?: VectorFilter;
38
37
  }
39
38
 
40
- declare type ChromaUpsertArgs = [...UpsertVectorArgs, string[]?];
41
-
42
39
  declare interface ChromaUpsertVectorParams extends UpsertVectorParams {
43
40
  documents?: string[];
44
41
  }
@@ -55,30 +52,20 @@ declare class ChromaVector extends MastraVector {
55
52
  });
56
53
  getCollection(indexName: string, throwIfNotExists?: boolean): Promise<any>;
57
54
  private validateVectorDimensions;
58
- upsert(...args: ParamsToArgs<ChromaUpsertVectorParams> | ChromaUpsertArgs): Promise<string[]>;
55
+ upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]>;
59
56
  private HnswSpaceMap;
60
- createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void>;
57
+ createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
61
58
  transformFilter(filter?: VectorFilter): VectorFilter;
62
- query(...args: ParamsToArgs<ChromaQueryVectorParams> | ChromaQueryArgs): Promise<QueryResult[]>;
59
+ query({ indexName, queryVector, topK, filter, includeVector, documentFilter, }: ChromaQueryVectorParams): Promise<QueryResult[]>;
63
60
  listIndexes(): Promise<string[]>;
64
- describeIndex(indexName: string): Promise<IndexStats>;
65
- deleteIndex(indexName: string): Promise<void>;
66
61
  /**
67
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
62
+ * Retrieves statistics about a vector index.
68
63
  *
69
- * Updates a vector by its ID with the provided vector and/or metadata.
70
- * @param indexName - The name of the index containing the vector.
71
- * @param id - The ID of the vector to update.
72
- * @param update - An object containing the vector and/or metadata to update.
73
- * @param update.vector - An optional array of numbers representing the new vector.
74
- * @param update.metadata - An optional record containing the new metadata.
75
- * @returns A promise that resolves when the update is complete.
76
- * @throws Will throw an error if no updates are provided or if the update operation fails.
64
+ * @param {string} indexName - The name of the index to describe
65
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
77
66
  */
78
- updateIndexById(indexName: string, id: string, update: {
79
- vector?: number[];
80
- metadata?: Record<string, any>;
81
- }): Promise<void>;
67
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
68
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
82
69
  /**
83
70
  * Updates a vector by its ID with the provided vector and/or metadata.
84
71
  * @param indexName - The name of the index containing the vector.
@@ -89,20 +76,7 @@ declare class ChromaVector extends MastraVector {
89
76
  * @returns A promise that resolves when the update is complete.
90
77
  * @throws Will throw an error if no updates are provided or if the update operation fails.
91
78
  */
92
- updateVector(indexName: string, id: string, update: {
93
- vector?: number[];
94
- metadata?: Record<string, any>;
95
- }): Promise<void>;
96
- /**
97
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
98
- *
99
- * Deletes a vector by its ID.
100
- * @param indexName - The name of the index containing the vector.
101
- * @param id - The ID of the vector to delete.
102
- * @returns A promise that resolves when the deletion is complete.
103
- * @throws Will throw an error if the deletion operation fails.
104
- */
105
- deleteIndexById(indexName: string, id: string): Promise<void>;
79
+ updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
106
80
  /**
107
81
  * Deletes a vector by its ID.
108
82
  * @param indexName - The name of the index containing the vector.
@@ -110,7 +84,7 @@ declare class ChromaVector extends MastraVector {
110
84
  * @returns A promise that resolves when the deletion is complete.
111
85
  * @throws Will throw an error if the deletion operation fails.
112
86
  */
113
- deleteVector(indexName: string, id: string): Promise<void>;
87
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
114
88
  }
115
89
  export { ChromaVector }
116
90
  export { ChromaVector as ChromaVector_alias_1 }
package/dist/index.cjs CHANGED
@@ -124,11 +124,9 @@ var ChromaVector = class extends vector.MastraVector {
124
124
  }
125
125
  }
126
126
  }
127
- async upsert(...args) {
128
- const params = this.normalizeArgs("upsert", args, ["documents"]);
129
- const { indexName, vectors, metadata, ids, documents } = params;
127
+ async upsert({ indexName, vectors, metadata, ids, documents }) {
130
128
  const collection = await this.getCollection(indexName);
131
- const stats = await this.describeIndex(indexName);
129
+ const stats = await this.describeIndex({ indexName });
132
130
  this.validateVectorDimensions(vectors, stats.dimension);
133
131
  const generatedIds = ids || vectors.map(() => crypto.randomUUID());
134
132
  const normalizedMetadata = metadata || vectors.map(() => ({}));
@@ -147,9 +145,7 @@ var ChromaVector = class extends vector.MastraVector {
147
145
  l2: "euclidean",
148
146
  ip: "dotproduct"
149
147
  };
150
- async createIndex(...args) {
151
- const params = this.normalizeArgs("createIndex", args);
152
- const { indexName, dimension, metric = "cosine" } = params;
148
+ async createIndex({ indexName, dimension, metric = "cosine" }) {
153
149
  if (!Number.isInteger(dimension) || dimension <= 0) {
154
150
  throw new Error("Dimension must be a positive integer");
155
151
  }
@@ -178,9 +174,14 @@ var ChromaVector = class extends vector.MastraVector {
178
174
  const translator = new ChromaFilterTranslator();
179
175
  return translator.translate(filter);
180
176
  }
181
- async query(...args) {
182
- const params = this.normalizeArgs("query", args, ["documentFilter"]);
183
- const { indexName, queryVector, topK = 10, filter, includeVector = false, documentFilter } = params;
177
+ async query({
178
+ indexName,
179
+ queryVector,
180
+ topK = 10,
181
+ filter,
182
+ includeVector = false,
183
+ documentFilter
184
+ }) {
184
185
  const collection = await this.getCollection(indexName, true);
185
186
  const defaultInclude = ["documents", "metadatas", "distances"];
186
187
  const translatedFilter = this.transformFilter(filter);
@@ -203,7 +204,13 @@ var ChromaVector = class extends vector.MastraVector {
203
204
  const collections = await this.client.listCollections();
204
205
  return collections.map((collection) => collection);
205
206
  }
206
- async describeIndex(indexName) {
207
+ /**
208
+ * Retrieves statistics about a vector index.
209
+ *
210
+ * @param {string} indexName - The name of the index to describe
211
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
212
+ */
213
+ async describeIndex({ indexName }) {
207
214
  const collection = await this.getCollection(indexName);
208
215
  const count = await collection.count();
209
216
  const metadata = collection.metadata;
@@ -214,13 +221,11 @@ var ChromaVector = class extends vector.MastraVector {
214
221
  metric: this.HnswSpaceMap[hnswSpace]
215
222
  };
216
223
  }
217
- async deleteIndex(indexName) {
224
+ async deleteIndex({ indexName }) {
218
225
  await this.client.deleteCollection({ name: indexName });
219
226
  this.collections.delete(indexName);
220
227
  }
221
228
  /**
222
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
223
- *
224
229
  * Updates a vector by its ID with the provided vector and/or metadata.
225
230
  * @param indexName - The name of the index containing the vector.
226
231
  * @param id - The ID of the vector to update.
@@ -230,25 +235,7 @@ var ChromaVector = class extends vector.MastraVector {
230
235
  * @returns A promise that resolves when the update is complete.
231
236
  * @throws Will throw an error if no updates are provided or if the update operation fails.
232
237
  */
233
- async updateIndexById(indexName, id, update) {
234
- this.logger.warn(
235
- `Deprecation Warning: updateIndexById() is deprecated.
236
- Please use updateVector() instead.
237
- updateIndexById() will be removed on May 20th, 2025.`
238
- );
239
- await this.updateVector(indexName, id, update);
240
- }
241
- /**
242
- * Updates a vector by its ID with the provided vector and/or metadata.
243
- * @param indexName - The name of the index containing the vector.
244
- * @param id - The ID of the vector to update.
245
- * @param update - An object containing the vector and/or metadata to update.
246
- * @param update.vector - An optional array of numbers representing the new vector.
247
- * @param update.metadata - An optional record containing the new metadata.
248
- * @returns A promise that resolves when the update is complete.
249
- * @throws Will throw an error if no updates are provided or if the update operation fails.
250
- */
251
- async updateVector(indexName, id, update) {
238
+ async updateVector({ indexName, id, update }) {
252
239
  try {
253
240
  if (!update.vector && !update.metadata) {
254
241
  throw new Error("No updates provided");
@@ -256,7 +243,7 @@ var ChromaVector = class extends vector.MastraVector {
256
243
  const collection = await this.getCollection(indexName, true);
257
244
  const updateOptions = { ids: [id] };
258
245
  if (update?.vector) {
259
- const stats = await this.describeIndex(indexName);
246
+ const stats = await this.describeIndex({ indexName });
260
247
  this.validateVectorDimensions([update.vector], stats.dimension);
261
248
  updateOptions.embeddings = [update.vector];
262
249
  }
@@ -268,21 +255,6 @@ var ChromaVector = class extends vector.MastraVector {
268
255
  throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
269
256
  }
270
257
  }
271
- /**
272
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
273
- *
274
- * Deletes a vector by its ID.
275
- * @param indexName - The name of the index containing the vector.
276
- * @param id - The ID of the vector to delete.
277
- * @returns A promise that resolves when the deletion is complete.
278
- * @throws Will throw an error if the deletion operation fails.
279
- */
280
- async deleteIndexById(indexName, id) {
281
- this.logger.warn(
282
- `Deprecation Warning: deleteIndexById() is deprecated. Please use deleteVector() instead. deleteIndexById() will be removed on May 20th.`
283
- );
284
- await this.deleteVector(indexName, id);
285
- }
286
258
  /**
287
259
  * Deletes a vector by its ID.
288
260
  * @param indexName - The name of the index containing the vector.
@@ -290,7 +262,7 @@ var ChromaVector = class extends vector.MastraVector {
290
262
  * @returns A promise that resolves when the deletion is complete.
291
263
  * @throws Will throw an error if the deletion operation fails.
292
264
  */
293
- async deleteVector(indexName, id) {
265
+ async deleteVector({ indexName, id }) {
294
266
  try {
295
267
  const collection = await this.getCollection(indexName, true);
296
268
  await collection.delete({ ids: [id] });
package/dist/index.js CHANGED
@@ -122,11 +122,9 @@ var ChromaVector = class extends MastraVector {
122
122
  }
123
123
  }
124
124
  }
125
- async upsert(...args) {
126
- const params = this.normalizeArgs("upsert", args, ["documents"]);
127
- const { indexName, vectors, metadata, ids, documents } = params;
125
+ async upsert({ indexName, vectors, metadata, ids, documents }) {
128
126
  const collection = await this.getCollection(indexName);
129
- const stats = await this.describeIndex(indexName);
127
+ const stats = await this.describeIndex({ indexName });
130
128
  this.validateVectorDimensions(vectors, stats.dimension);
131
129
  const generatedIds = ids || vectors.map(() => crypto.randomUUID());
132
130
  const normalizedMetadata = metadata || vectors.map(() => ({}));
@@ -145,9 +143,7 @@ var ChromaVector = class extends MastraVector {
145
143
  l2: "euclidean",
146
144
  ip: "dotproduct"
147
145
  };
148
- async createIndex(...args) {
149
- const params = this.normalizeArgs("createIndex", args);
150
- const { indexName, dimension, metric = "cosine" } = params;
146
+ async createIndex({ indexName, dimension, metric = "cosine" }) {
151
147
  if (!Number.isInteger(dimension) || dimension <= 0) {
152
148
  throw new Error("Dimension must be a positive integer");
153
149
  }
@@ -176,9 +172,14 @@ var ChromaVector = class extends MastraVector {
176
172
  const translator = new ChromaFilterTranslator();
177
173
  return translator.translate(filter);
178
174
  }
179
- async query(...args) {
180
- const params = this.normalizeArgs("query", args, ["documentFilter"]);
181
- const { indexName, queryVector, topK = 10, filter, includeVector = false, documentFilter } = params;
175
+ async query({
176
+ indexName,
177
+ queryVector,
178
+ topK = 10,
179
+ filter,
180
+ includeVector = false,
181
+ documentFilter
182
+ }) {
182
183
  const collection = await this.getCollection(indexName, true);
183
184
  const defaultInclude = ["documents", "metadatas", "distances"];
184
185
  const translatedFilter = this.transformFilter(filter);
@@ -201,7 +202,13 @@ var ChromaVector = class extends MastraVector {
201
202
  const collections = await this.client.listCollections();
202
203
  return collections.map((collection) => collection);
203
204
  }
204
- async describeIndex(indexName) {
205
+ /**
206
+ * Retrieves statistics about a vector index.
207
+ *
208
+ * @param {string} indexName - The name of the index to describe
209
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
210
+ */
211
+ async describeIndex({ indexName }) {
205
212
  const collection = await this.getCollection(indexName);
206
213
  const count = await collection.count();
207
214
  const metadata = collection.metadata;
@@ -212,13 +219,11 @@ var ChromaVector = class extends MastraVector {
212
219
  metric: this.HnswSpaceMap[hnswSpace]
213
220
  };
214
221
  }
215
- async deleteIndex(indexName) {
222
+ async deleteIndex({ indexName }) {
216
223
  await this.client.deleteCollection({ name: indexName });
217
224
  this.collections.delete(indexName);
218
225
  }
219
226
  /**
220
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
221
- *
222
227
  * Updates a vector by its ID with the provided vector and/or metadata.
223
228
  * @param indexName - The name of the index containing the vector.
224
229
  * @param id - The ID of the vector to update.
@@ -228,25 +233,7 @@ var ChromaVector = class extends MastraVector {
228
233
  * @returns A promise that resolves when the update is complete.
229
234
  * @throws Will throw an error if no updates are provided or if the update operation fails.
230
235
  */
231
- async updateIndexById(indexName, id, update) {
232
- this.logger.warn(
233
- `Deprecation Warning: updateIndexById() is deprecated.
234
- Please use updateVector() instead.
235
- updateIndexById() will be removed on May 20th, 2025.`
236
- );
237
- await this.updateVector(indexName, id, update);
238
- }
239
- /**
240
- * Updates a vector by its ID with the provided vector and/or metadata.
241
- * @param indexName - The name of the index containing the vector.
242
- * @param id - The ID of the vector to update.
243
- * @param update - An object containing the vector and/or metadata to update.
244
- * @param update.vector - An optional array of numbers representing the new vector.
245
- * @param update.metadata - An optional record containing the new metadata.
246
- * @returns A promise that resolves when the update is complete.
247
- * @throws Will throw an error if no updates are provided or if the update operation fails.
248
- */
249
- async updateVector(indexName, id, update) {
236
+ async updateVector({ indexName, id, update }) {
250
237
  try {
251
238
  if (!update.vector && !update.metadata) {
252
239
  throw new Error("No updates provided");
@@ -254,7 +241,7 @@ var ChromaVector = class extends MastraVector {
254
241
  const collection = await this.getCollection(indexName, true);
255
242
  const updateOptions = { ids: [id] };
256
243
  if (update?.vector) {
257
- const stats = await this.describeIndex(indexName);
244
+ const stats = await this.describeIndex({ indexName });
258
245
  this.validateVectorDimensions([update.vector], stats.dimension);
259
246
  updateOptions.embeddings = [update.vector];
260
247
  }
@@ -266,21 +253,6 @@ var ChromaVector = class extends MastraVector {
266
253
  throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
267
254
  }
268
255
  }
269
- /**
270
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
271
- *
272
- * Deletes a vector by its ID.
273
- * @param indexName - The name of the index containing the vector.
274
- * @param id - The ID of the vector to delete.
275
- * @returns A promise that resolves when the deletion is complete.
276
- * @throws Will throw an error if the deletion operation fails.
277
- */
278
- async deleteIndexById(indexName, id) {
279
- this.logger.warn(
280
- `Deprecation Warning: deleteIndexById() is deprecated. Please use deleteVector() instead. deleteIndexById() will be removed on May 20th.`
281
- );
282
- await this.deleteVector(indexName, id);
283
- }
284
256
  /**
285
257
  * Deletes a vector by its ID.
286
258
  * @param indexName - The name of the index containing the vector.
@@ -288,7 +260,7 @@ var ChromaVector = class extends MastraVector {
288
260
  * @returns A promise that resolves when the deletion is complete.
289
261
  * @throws Will throw an error if the deletion operation fails.
290
262
  */
291
- async deleteVector(indexName, id) {
263
+ async deleteVector({ indexName, id }) {
292
264
  try {
293
265
  const collection = await this.getCollection(indexName, true);
294
266
  await collection.delete({ ids: [id] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/chroma",
3
- "version": "0.2.15",
3
+ "version": "0.3.0-alpha.1",
4
4
  "description": "Chroma vector store provider for Mastra",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -20,8 +20,7 @@
20
20
  },
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
- "chromadb": "^2.2.0",
24
- "@mastra/core": "^0.9.4"
23
+ "chromadb": "^2.2.0"
25
24
  },
26
25
  "devDependencies": {
27
26
  "@microsoft/api-extractor": "^7.52.5",
@@ -30,7 +29,11 @@
30
29
  "tsup": "^8.4.0",
31
30
  "typescript": "^5.8.2",
32
31
  "vitest": "^3.1.2",
33
- "@internal/lint": "0.0.5"
32
+ "@internal/lint": "0.0.5",
33
+ "@mastra/core": "0.10.0-alpha.1"
34
+ },
35
+ "peerDependencies": {
36
+ "@mastra/core": "^0.9.4"
34
37
  },
35
38
  "scripts": {
36
39
  "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
@@ -16,7 +16,7 @@ describe('ChromaVector Integration Tests', () => {
16
16
  beforeEach(async () => {
17
17
  // Clean up any existing test index
18
18
  try {
19
- await vectorDB.deleteIndex(testIndexName);
19
+ await vectorDB.deleteIndex({ indexName: testIndexName });
20
20
  } catch {
21
21
  // Ignore errors if index doesn't exist
22
22
  }
@@ -26,7 +26,7 @@ describe('ChromaVector Integration Tests', () => {
26
26
  afterEach(async () => {
27
27
  // Cleanup after tests
28
28
  try {
29
- await vectorDB.deleteIndex(testIndexName);
29
+ await vectorDB.deleteIndex({ indexName: testIndexName });
30
30
  } catch {
31
31
  // Ignore cleanup errors
32
32
  }
@@ -39,14 +39,14 @@ describe('ChromaVector Integration Tests', () => {
39
39
  });
40
40
 
41
41
  it('should describe index correctly', async () => {
42
- const stats: IndexStats = await vectorDB.describeIndex(testIndexName);
42
+ const stats: IndexStats = await vectorDB.describeIndex({ indexName: testIndexName });
43
43
  expect(stats.dimension).toBe(dimension);
44
44
  expect(stats.count).toBe(0);
45
45
  expect(stats.metric).toBe('cosine');
46
46
  });
47
47
 
48
48
  it('should delete index', async () => {
49
- await vectorDB.deleteIndex(testIndexName);
49
+ await vectorDB.deleteIndex({ indexName: testIndexName });
50
50
  const indexes = await vectorDB.listIndexes();
51
51
  expect(indexes).not.toContain(testIndexName);
52
52
  });
@@ -58,10 +58,10 @@ describe('ChromaVector Integration Tests', () => {
58
58
  const testIndex = `test-index-${metric}`;
59
59
  await vectorDB.createIndex({ indexName: testIndex, dimension, metric });
60
60
 
61
- const stats = await vectorDB.describeIndex(testIndex);
61
+ const stats = await vectorDB.describeIndex({ indexName: testIndex });
62
62
  expect(stats.metric).toBe(metric);
63
63
 
64
- await vectorDB.deleteIndex(testIndex);
64
+ await vectorDB.deleteIndex({ indexName: testIndex });
65
65
  }
66
66
  });
67
67
  });
@@ -80,14 +80,14 @@ describe('ChromaVector Integration Tests', () => {
80
80
  expect(ids).toHaveLength(testVectors.length);
81
81
  ids.forEach(id => expect(typeof id).toBe('string'));
82
82
 
83
- const stats = await vectorDB.describeIndex(testIndexName);
83
+ const stats = await vectorDB.describeIndex({ indexName: testIndexName });
84
84
  expect(stats.count).toBe(testVectors.length);
85
85
  });
86
86
 
87
87
  it('should upsert vectors with provided ids and metadata', async () => {
88
88
  await vectorDB.upsert({ indexName: testIndexName, vectors: testVectors, metadata: testMetadata, ids: testIds });
89
89
 
90
- const stats = await vectorDB.describeIndex(testIndexName);
90
+ const stats = await vectorDB.describeIndex({ indexName: testIndexName });
91
91
  expect(stats.count).toBe(testVectors.length);
92
92
 
93
93
  // Query each vector to verify metadata
@@ -133,7 +133,7 @@ describe('ChromaVector Integration Tests', () => {
133
133
  metadata: newMetaData,
134
134
  };
135
135
 
136
- await vectorDB.updateVector(testIndexName, idToBeUpdated, update);
136
+ await vectorDB.updateVector({ indexName: testIndexName, id: idToBeUpdated, update });
137
137
 
138
138
  const results: QueryResult[] = await vectorDB.query({
139
139
  indexName: testIndexName,
@@ -159,7 +159,7 @@ describe('ChromaVector Integration Tests', () => {
159
159
  metadata: newMetaData,
160
160
  };
161
161
 
162
- await vectorDB.updateVector(testIndexName, idToBeUpdated, update);
162
+ await vectorDB.updateVector({ indexName: testIndexName, id: idToBeUpdated, update });
163
163
 
164
164
  const results: QueryResult[] = await vectorDB.query({
165
165
  indexName: testIndexName,
@@ -183,7 +183,7 @@ describe('ChromaVector Integration Tests', () => {
183
183
  vector: newVector,
184
184
  };
185
185
 
186
- await vectorDB.updateVector(testIndexName, idToBeUpdated, update);
186
+ await vectorDB.updateVector({ indexName: testIndexName, id: idToBeUpdated, update });
187
187
 
188
188
  const results: QueryResult[] = await vectorDB.query({
189
189
  indexName: testIndexName,
@@ -196,7 +196,9 @@ describe('ChromaVector Integration Tests', () => {
196
196
  });
197
197
 
198
198
  it('should throw exception when no updates are given', async () => {
199
- await expect(vectorDB.updateVector(testIndexName, 'id', {})).rejects.toThrow('No updates provided');
199
+ await expect(vectorDB.updateVector({ indexName: testIndexName, id: 'id', update: {} })).rejects.toThrow(
200
+ 'No updates provided',
201
+ );
200
202
  });
201
203
 
202
204
  it('should delete the vector by id', async () => {
@@ -204,7 +206,7 @@ describe('ChromaVector Integration Tests', () => {
204
206
  expect(ids).toHaveLength(3);
205
207
  const idToBeDeleted = ids[0];
206
208
 
207
- await vectorDB.deleteVector(testIndexName, idToBeDeleted);
209
+ await vectorDB.deleteVector({ indexName: testIndexName, id: idToBeDeleted });
208
210
 
209
211
  const results: QueryResult[] = await vectorDB.query({
210
212
  indexName: testIndexName,
@@ -279,7 +281,7 @@ describe('ChromaVector Integration Tests', () => {
279
281
  });
280
282
 
281
283
  afterAll(async () => {
282
- await vectorDB.deleteIndex(testIndexName);
284
+ await vectorDB.deleteIndex({ indexName: testIndexName });
283
285
  });
284
286
 
285
287
  it('should handle non-existent index queries', async () => {
@@ -342,7 +344,7 @@ describe('ChromaVector Integration Tests', () => {
342
344
  infoSpy.mockRestore();
343
345
  warnSpy.mockRestore();
344
346
  // Cleanup
345
- await vectorDB.deleteIndex(duplicateIndexName);
347
+ await vectorDB.deleteIndex({ indexName: duplicateIndexName });
346
348
  }
347
349
  });
348
350
  });
@@ -519,7 +521,7 @@ describe('ChromaVector Integration Tests', () => {
519
521
  // Set up test vectors and metadata
520
522
  beforeAll(async () => {
521
523
  try {
522
- await vectorDB.deleteIndex(testIndexName2);
524
+ await vectorDB.deleteIndex({ indexName: testIndexName2 });
523
525
  } catch {
524
526
  // Ignore errors if index doesn't exist
525
527
  }
@@ -567,7 +569,7 @@ describe('ChromaVector Integration Tests', () => {
567
569
  afterAll(async () => {
568
570
  // Cleanup after tests
569
571
  try {
570
- await vectorDB.deleteIndex(testIndexName2);
572
+ await vectorDB.deleteIndex({ indexName: testIndexName2 });
571
573
  } catch {
572
574
  // Ignore cleanup errors
573
575
  }
@@ -1238,7 +1240,7 @@ describe('ChromaVector Integration Tests', () => {
1238
1240
 
1239
1241
  beforeAll(async () => {
1240
1242
  try {
1241
- await vectorDB.deleteIndex(testIndexName3);
1243
+ await vectorDB.deleteIndex({ indexName: testIndexName3 });
1242
1244
  } catch {
1243
1245
  // Ignore errors if index doesn't exist
1244
1246
  }
@@ -1272,7 +1274,7 @@ describe('ChromaVector Integration Tests', () => {
1272
1274
  afterAll(async () => {
1273
1275
  // Cleanup after tests
1274
1276
  try {
1275
- await vectorDB.deleteIndex(testIndexName3);
1277
+ await vectorDB.deleteIndex({ indexName: testIndexName3 });
1276
1278
  } catch {
1277
1279
  // Ignore cleanup errors
1278
1280
  }
@@ -1460,122 +1462,13 @@ describe('ChromaVector Integration Tests', () => {
1460
1462
  });
1461
1463
  });
1462
1464
  });
1463
- describe('Deprecation Warnings', () => {
1464
- const indexName = 'testdeprecationwarnings';
1465
-
1466
- const indexName2 = 'testdeprecationwarnings2';
1467
-
1468
- let warnSpy;
1469
-
1470
- beforeAll(async () => {
1471
- await vectorDB.createIndex({ indexName: indexName, dimension: 3 });
1472
- });
1473
-
1474
- afterAll(async () => {
1475
- try {
1476
- await vectorDB.deleteIndex(indexName);
1477
- } catch {
1478
- // Ignore errors if index doesn't exist
1479
- }
1480
- try {
1481
- await vectorDB.deleteIndex(indexName2);
1482
- } catch {
1483
- // Ignore errors if index doesn't exist
1484
- }
1485
- });
1486
-
1487
- beforeEach(async () => {
1488
- warnSpy = vi.spyOn(vectorDB['logger'], 'warn');
1489
- });
1490
-
1491
- afterEach(async () => {
1492
- warnSpy.mockRestore();
1493
- try {
1494
- await vectorDB.deleteIndex(indexName2);
1495
- } catch {
1496
- // Ignore errors if index doesn't exist
1497
- }
1498
- });
1499
-
1500
- it('should show deprecation warning when using individual args for createIndex', async () => {
1501
- await vectorDB.createIndex(indexName2, 3, 'cosine');
1502
-
1503
- expect(warnSpy).toHaveBeenCalledWith(
1504
- expect.stringContaining('Deprecation Warning: Passing individual arguments to createIndex() is deprecated'),
1505
- );
1506
- });
1507
-
1508
- it('should show deprecation warning when using individual args for upsert', async () => {
1509
- await vectorDB.upsert(indexName, [[1, 2, 3]], [{ test: 'data' }]);
1510
-
1511
- expect(warnSpy).toHaveBeenCalledWith(
1512
- expect.stringContaining('Deprecation Warning: Passing individual arguments to upsert() is deprecated'),
1513
- );
1514
- });
1515
-
1516
- it('should show deprecation warning when using individual args for query', async () => {
1517
- await vectorDB.query(indexName, [1, 2, 3], 5);
1518
-
1519
- expect(warnSpy).toHaveBeenCalledWith(
1520
- expect.stringContaining('Deprecation Warning: Passing individual arguments to query() is deprecated'),
1521
- );
1522
- });
1523
-
1524
- it('should not show deprecation warning when using object param for query', async () => {
1525
- await vectorDB.query({
1526
- indexName,
1527
- queryVector: [1, 2, 3],
1528
- topK: 5,
1529
- });
1530
-
1531
- expect(warnSpy).not.toHaveBeenCalled();
1532
- });
1533
-
1534
- it('should not show deprecation warning when using object param for createIndex', async () => {
1535
- await vectorDB.createIndex({
1536
- indexName: indexName2,
1537
- dimension: 3,
1538
- metric: 'cosine',
1539
- });
1540
-
1541
- expect(warnSpy).not.toHaveBeenCalled();
1542
- });
1543
-
1544
- it('should not show deprecation warning when using object param for upsert', async () => {
1545
- await vectorDB.upsert({
1546
- indexName,
1547
- vectors: [[1, 2, 3]],
1548
- metadata: [{ test: 'data' }],
1549
- });
1550
-
1551
- expect(warnSpy).not.toHaveBeenCalled();
1552
- });
1553
-
1554
- it('should maintain backward compatibility with individual args', async () => {
1555
- // Query
1556
- const queryResults = await vectorDB.query(indexName, [1, 2, 3], 5);
1557
- expect(Array.isArray(queryResults)).toBe(true);
1558
-
1559
- // CreateIndex
1560
- await expect(vectorDB.createIndex(indexName2, 3, 'cosine')).resolves.not.toThrow();
1561
-
1562
- // Upsert
1563
- const upsertResults = await vectorDB.upsert({
1564
- indexName,
1565
- vectors: [[1, 2, 3]],
1566
- metadata: [{ test: 'data' }],
1567
- });
1568
- expect(Array.isArray(upsertResults)).toBe(true);
1569
- expect(upsertResults).toHaveLength(1);
1570
- });
1571
- });
1572
1465
 
1573
1466
  describe('Performance and Concurrency', () => {
1574
1467
  const perfTestIndex = 'perf-test-index';
1575
1468
 
1576
1469
  beforeEach(async () => {
1577
1470
  try {
1578
- await vectorDB.deleteIndex(perfTestIndex);
1471
+ await vectorDB.deleteIndex({ indexName: perfTestIndex });
1579
1472
  } catch {
1580
1473
  // Ignore errors if index doesn't exist
1581
1474
  }
@@ -1584,7 +1477,7 @@ describe('ChromaVector Integration Tests', () => {
1584
1477
 
1585
1478
  afterEach(async () => {
1586
1479
  try {
1587
- await vectorDB.deleteIndex(perfTestIndex);
1480
+ await vectorDB.deleteIndex({ indexName: perfTestIndex });
1588
1481
  } catch {
1589
1482
  // Ignore cleanup errors
1590
1483
  }
@@ -1627,7 +1520,7 @@ describe('ChromaVector Integration Tests', () => {
1627
1520
  });
1628
1521
 
1629
1522
  // Verify all vectors were inserted
1630
- const stats = await vectorDB.describeIndex(perfTestIndex);
1523
+ const stats = await vectorDB.describeIndex({ indexName: perfTestIndex });
1631
1524
  expect(stats.count).toBe(batchSize);
1632
1525
 
1633
1526
  const results = await vectorDB.query({
@@ -5,9 +5,10 @@ import type {
5
5
  CreateIndexParams,
6
6
  UpsertVectorParams,
7
7
  QueryVectorParams,
8
- ParamsToArgs,
9
- QueryVectorArgs,
10
- UpsertVectorArgs,
8
+ DescribeIndexParams,
9
+ DeleteIndexParams,
10
+ DeleteVectorParams,
11
+ UpdateVectorParams,
11
12
  } from '@mastra/core/vector';
12
13
 
13
14
  import type { VectorFilter } from '@mastra/core/vector/filter';
@@ -19,14 +20,10 @@ interface ChromaUpsertVectorParams extends UpsertVectorParams {
19
20
  documents?: string[];
20
21
  }
21
22
 
22
- type ChromaUpsertArgs = [...UpsertVectorArgs, string[]?];
23
-
24
23
  interface ChromaQueryVectorParams extends QueryVectorParams {
25
24
  documentFilter?: VectorFilter;
26
25
  }
27
26
 
28
- type ChromaQueryArgs = [...QueryVectorArgs, VectorFilter?];
29
-
30
27
  export class ChromaVector extends MastraVector {
31
28
  private client: ChromaClient;
32
29
  private collections: Map<string, any>;
@@ -72,15 +69,11 @@ export class ChromaVector extends MastraVector {
72
69
  }
73
70
  }
74
71
 
75
- async upsert(...args: ParamsToArgs<ChromaUpsertVectorParams> | ChromaUpsertArgs): Promise<string[]> {
76
- const params = this.normalizeArgs<ChromaUpsertVectorParams, ChromaUpsertArgs>('upsert', args, ['documents']);
77
-
78
- const { indexName, vectors, metadata, ids, documents } = params;
79
-
72
+ async upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]> {
80
73
  const collection = await this.getCollection(indexName);
81
74
 
82
75
  // Get index stats to check dimension
83
- const stats = await this.describeIndex(indexName);
76
+ const stats = await this.describeIndex({ indexName });
84
77
 
85
78
  // Validate vector dimensions
86
79
  this.validateVectorDimensions(vectors, stats.dimension);
@@ -109,10 +102,7 @@ export class ChromaVector extends MastraVector {
109
102
  ip: 'dotproduct',
110
103
  };
111
104
 
112
- async createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void> {
113
- const params = this.normalizeArgs<CreateIndexParams>('createIndex', args);
114
- const { indexName, dimension, metric = 'cosine' } = params;
115
-
105
+ async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {
116
106
  if (!Number.isInteger(dimension) || dimension <= 0) {
117
107
  throw new Error('Dimension must be a positive integer');
118
108
  }
@@ -144,11 +134,14 @@ export class ChromaVector extends MastraVector {
144
134
  const translator = new ChromaFilterTranslator();
145
135
  return translator.translate(filter);
146
136
  }
147
- async query(...args: ParamsToArgs<ChromaQueryVectorParams> | ChromaQueryArgs): Promise<QueryResult[]> {
148
- const params = this.normalizeArgs<ChromaQueryVectorParams, ChromaQueryArgs>('query', args, ['documentFilter']);
149
-
150
- const { indexName, queryVector, topK = 10, filter, includeVector = false, documentFilter } = params;
151
-
137
+ async query({
138
+ indexName,
139
+ queryVector,
140
+ topK = 10,
141
+ filter,
142
+ includeVector = false,
143
+ documentFilter,
144
+ }: ChromaQueryVectorParams): Promise<QueryResult[]> {
152
145
  const collection = await this.getCollection(indexName, true);
153
146
 
154
147
  const defaultInclude = ['documents', 'metadatas', 'distances'];
@@ -177,7 +170,13 @@ export class ChromaVector extends MastraVector {
177
170
  return collections.map(collection => collection);
178
171
  }
179
172
 
180
- async describeIndex(indexName: string): Promise<IndexStats> {
173
+ /**
174
+ * Retrieves statistics about a vector index.
175
+ *
176
+ * @param {string} indexName - The name of the index to describe
177
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
178
+ */
179
+ async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {
181
180
  const collection = await this.getCollection(indexName);
182
181
  const count = await collection.count();
183
182
  const metadata = collection.metadata;
@@ -191,14 +190,12 @@ export class ChromaVector extends MastraVector {
191
190
  };
192
191
  }
193
192
 
194
- async deleteIndex(indexName: string): Promise<void> {
193
+ async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {
195
194
  await this.client.deleteCollection({ name: indexName });
196
195
  this.collections.delete(indexName);
197
196
  }
198
197
 
199
198
  /**
200
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
201
- *
202
199
  * Updates a vector by its ID with the provided vector and/or metadata.
203
200
  * @param indexName - The name of the index containing the vector.
204
201
  * @param id - The ID of the vector to update.
@@ -208,34 +205,7 @@ export class ChromaVector extends MastraVector {
208
205
  * @returns A promise that resolves when the update is complete.
209
206
  * @throws Will throw an error if no updates are provided or if the update operation fails.
210
207
  */
211
- async updateIndexById(
212
- indexName: string,
213
- id: string,
214
- update: { vector?: number[]; metadata?: Record<string, any> },
215
- ): Promise<void> {
216
- this.logger.warn(
217
- `Deprecation Warning: updateIndexById() is deprecated.
218
- Please use updateVector() instead.
219
- updateIndexById() will be removed on May 20th, 2025.`,
220
- );
221
- await this.updateVector(indexName, id, update);
222
- }
223
-
224
- /**
225
- * Updates a vector by its ID with the provided vector and/or metadata.
226
- * @param indexName - The name of the index containing the vector.
227
- * @param id - The ID of the vector to update.
228
- * @param update - An object containing the vector and/or metadata to update.
229
- * @param update.vector - An optional array of numbers representing the new vector.
230
- * @param update.metadata - An optional record containing the new metadata.
231
- * @returns A promise that resolves when the update is complete.
232
- * @throws Will throw an error if no updates are provided or if the update operation fails.
233
- */
234
- async updateVector(
235
- indexName: string,
236
- id: string,
237
- update: { vector?: number[]; metadata?: Record<string, any> },
238
- ): Promise<void> {
208
+ async updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void> {
239
209
  try {
240
210
  if (!update.vector && !update.metadata) {
241
211
  throw new Error('No updates provided');
@@ -246,7 +216,7 @@ export class ChromaVector extends MastraVector {
246
216
  const updateOptions: UpdateRecordsParams = { ids: [id] };
247
217
 
248
218
  if (update?.vector) {
249
- const stats = await this.describeIndex(indexName);
219
+ const stats = await this.describeIndex({ indexName });
250
220
  this.validateVectorDimensions([update.vector], stats.dimension);
251
221
  updateOptions.embeddings = [update.vector];
252
222
  }
@@ -261,22 +231,6 @@ export class ChromaVector extends MastraVector {
261
231
  }
262
232
  }
263
233
 
264
- /**
265
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
266
- *
267
- * Deletes a vector by its ID.
268
- * @param indexName - The name of the index containing the vector.
269
- * @param id - The ID of the vector to delete.
270
- * @returns A promise that resolves when the deletion is complete.
271
- * @throws Will throw an error if the deletion operation fails.
272
- */
273
- async deleteIndexById(indexName: string, id: string): Promise<void> {
274
- this.logger.warn(
275
- `Deprecation Warning: deleteIndexById() is deprecated. Please use deleteVector() instead. deleteIndexById() will be removed on May 20th.`,
276
- );
277
- await this.deleteVector(indexName, id);
278
- }
279
-
280
234
  /**
281
235
  * Deletes a vector by its ID.
282
236
  * @param indexName - The name of the index containing the vector.
@@ -284,7 +238,7 @@ export class ChromaVector extends MastraVector {
284
238
  * @returns A promise that resolves when the deletion is complete.
285
239
  * @throws Will throw an error if the deletion operation fails.
286
240
  */
287
- async deleteVector(indexName: string, id: string): Promise<void> {
241
+ async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {
288
242
  try {
289
243
  const collection: Collection = await this.getCollection(indexName, true);
290
244
  await collection.delete({ ids: [id] });