@mastra/chroma 0.2.16-alpha.0 → 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.16-alpha.0 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 8644ms
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 7313ms
16
+ DTS ⚡️ Build success in 9053ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- ESM dist/index.js 14.59 KB
21
- ESM ⚡️ Build success in 707ms
22
- CJS dist/index.cjs 14.64 KB
23
- CJS ⚡️ Build success in 707ms
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,26 @@
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
+
3
24
  ## 0.2.16-alpha.0
4
25
 
5
26
  ### Patch Changes
@@ -6,12 +6,9 @@ import type { DescribeIndexParams } from '@mastra/core/vector';
6
6
  import type { IndexStats } from '@mastra/core/vector';
7
7
  import { MastraVector } from '@mastra/core/vector';
8
8
  import type { OperatorSupport } from '@mastra/core/vector/filter';
9
- import type { ParamsToArgs } from '@mastra/core/vector';
10
9
  import type { QueryResult } from '@mastra/core/vector';
11
- import type { QueryVectorArgs } from '@mastra/core/vector';
12
10
  import type { QueryVectorParams } from '@mastra/core/vector';
13
11
  import type { UpdateVectorParams } from '@mastra/core/vector';
14
- import type { UpsertVectorArgs } from '@mastra/core/vector';
15
12
  import type { UpsertVectorParams } from '@mastra/core/vector';
16
13
  import type { VectorFilter } from '@mastra/core/vector/filter';
17
14
 
@@ -35,14 +32,10 @@ export declare class ChromaFilterTranslator extends BaseFilterTranslator {
35
32
  private translateOperator;
36
33
  }
37
34
 
38
- declare type ChromaQueryArgs = [...QueryVectorArgs, VectorFilter?];
39
-
40
35
  declare interface ChromaQueryVectorParams extends QueryVectorParams {
41
36
  documentFilter?: VectorFilter;
42
37
  }
43
38
 
44
- declare type ChromaUpsertArgs = [...UpsertVectorArgs, string[]?];
45
-
46
39
  declare interface ChromaUpsertVectorParams extends UpsertVectorParams {
47
40
  documents?: string[];
48
41
  }
@@ -59,24 +52,21 @@ declare class ChromaVector extends MastraVector {
59
52
  });
60
53
  getCollection(indexName: string, throwIfNotExists?: boolean): Promise<any>;
61
54
  private validateVectorDimensions;
62
- upsert(...args: ParamsToArgs<ChromaUpsertVectorParams> | ChromaUpsertArgs): Promise<string[]>;
55
+ upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]>;
63
56
  private HnswSpaceMap;
64
- createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void>;
57
+ createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
65
58
  transformFilter(filter?: VectorFilter): VectorFilter;
66
- query(...args: ParamsToArgs<ChromaQueryVectorParams> | ChromaQueryArgs): Promise<QueryResult[]>;
59
+ query({ indexName, queryVector, topK, filter, includeVector, documentFilter, }: ChromaQueryVectorParams): Promise<QueryResult[]>;
67
60
  listIndexes(): Promise<string[]>;
68
61
  /**
69
62
  * Retrieves statistics about a vector index.
70
63
  *
71
- * @param params - The parameters for describing an index
72
- * @param params.indexName - The name of the index to describe
64
+ * @param {string} indexName - The name of the index to describe
73
65
  * @returns A promise that resolves to the index statistics including dimension, count and metric
74
66
  */
75
- describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats>;
76
- deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
67
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
68
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
77
69
  /**
78
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
79
- *
80
70
  * Updates a vector by its ID with the provided vector and/or metadata.
81
71
  * @param indexName - The name of the index containing the vector.
82
72
  * @param id - The ID of the vector to update.
@@ -86,31 +76,7 @@ declare class ChromaVector extends MastraVector {
86
76
  * @returns A promise that resolves when the update is complete.
87
77
  * @throws Will throw an error if no updates are provided or if the update operation fails.
88
78
  */
89
- updateIndexById(indexName: string, id: string, update: {
90
- vector?: number[];
91
- metadata?: Record<string, any>;
92
- }): Promise<void>;
93
- /**
94
- * Updates a vector by its ID with the provided vector and/or metadata.
95
- * @param indexName - The name of the index containing the vector.
96
- * @param id - The ID of the vector to update.
97
- * @param update - An object containing the vector and/or metadata to update.
98
- * @param update.vector - An optional array of numbers representing the new vector.
99
- * @param update.metadata - An optional record containing the new metadata.
100
- * @returns A promise that resolves when the update is complete.
101
- * @throws Will throw an error if no updates are provided or if the update operation fails.
102
- */
103
- updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
104
- /**
105
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
106
- *
107
- * Deletes a vector by its ID.
108
- * @param indexName - The name of the index containing the vector.
109
- * @param id - The ID of the vector to delete.
110
- * @returns A promise that resolves when the deletion is complete.
111
- * @throws Will throw an error if the deletion operation fails.
112
- */
113
- deleteIndexById(indexName: string, id: string): Promise<void>;
79
+ updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
114
80
  /**
115
81
  * Deletes a vector by its ID.
116
82
  * @param indexName - The name of the index containing the vector.
@@ -118,7 +84,7 @@ declare class ChromaVector extends MastraVector {
118
84
  * @returns A promise that resolves when the deletion is complete.
119
85
  * @throws Will throw an error if the deletion operation fails.
120
86
  */
121
- deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void>;
87
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
122
88
  }
123
89
  export { ChromaVector }
124
90
  export { ChromaVector as ChromaVector_alias_1 }
@@ -6,12 +6,9 @@ import type { DescribeIndexParams } from '@mastra/core/vector';
6
6
  import type { IndexStats } from '@mastra/core/vector';
7
7
  import { MastraVector } from '@mastra/core/vector';
8
8
  import type { OperatorSupport } from '@mastra/core/vector/filter';
9
- import type { ParamsToArgs } from '@mastra/core/vector';
10
9
  import type { QueryResult } from '@mastra/core/vector';
11
- import type { QueryVectorArgs } from '@mastra/core/vector';
12
10
  import type { QueryVectorParams } from '@mastra/core/vector';
13
11
  import type { UpdateVectorParams } from '@mastra/core/vector';
14
- import type { UpsertVectorArgs } from '@mastra/core/vector';
15
12
  import type { UpsertVectorParams } from '@mastra/core/vector';
16
13
  import type { VectorFilter } from '@mastra/core/vector/filter';
17
14
 
@@ -35,14 +32,10 @@ export declare class ChromaFilterTranslator extends BaseFilterTranslator {
35
32
  private translateOperator;
36
33
  }
37
34
 
38
- declare type ChromaQueryArgs = [...QueryVectorArgs, VectorFilter?];
39
-
40
35
  declare interface ChromaQueryVectorParams extends QueryVectorParams {
41
36
  documentFilter?: VectorFilter;
42
37
  }
43
38
 
44
- declare type ChromaUpsertArgs = [...UpsertVectorArgs, string[]?];
45
-
46
39
  declare interface ChromaUpsertVectorParams extends UpsertVectorParams {
47
40
  documents?: string[];
48
41
  }
@@ -59,24 +52,21 @@ declare class ChromaVector extends MastraVector {
59
52
  });
60
53
  getCollection(indexName: string, throwIfNotExists?: boolean): Promise<any>;
61
54
  private validateVectorDimensions;
62
- upsert(...args: ParamsToArgs<ChromaUpsertVectorParams> | ChromaUpsertArgs): Promise<string[]>;
55
+ upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]>;
63
56
  private HnswSpaceMap;
64
- createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void>;
57
+ createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
65
58
  transformFilter(filter?: VectorFilter): VectorFilter;
66
- query(...args: ParamsToArgs<ChromaQueryVectorParams> | ChromaQueryArgs): Promise<QueryResult[]>;
59
+ query({ indexName, queryVector, topK, filter, includeVector, documentFilter, }: ChromaQueryVectorParams): Promise<QueryResult[]>;
67
60
  listIndexes(): Promise<string[]>;
68
61
  /**
69
62
  * Retrieves statistics about a vector index.
70
63
  *
71
- * @param params - The parameters for describing an index
72
- * @param params.indexName - The name of the index to describe
64
+ * @param {string} indexName - The name of the index to describe
73
65
  * @returns A promise that resolves to the index statistics including dimension, count and metric
74
66
  */
75
- describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats>;
76
- deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
67
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
68
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
77
69
  /**
78
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
79
- *
80
70
  * Updates a vector by its ID with the provided vector and/or metadata.
81
71
  * @param indexName - The name of the index containing the vector.
82
72
  * @param id - The ID of the vector to update.
@@ -86,31 +76,7 @@ declare class ChromaVector extends MastraVector {
86
76
  * @returns A promise that resolves when the update is complete.
87
77
  * @throws Will throw an error if no updates are provided or if the update operation fails.
88
78
  */
89
- updateIndexById(indexName: string, id: string, update: {
90
- vector?: number[];
91
- metadata?: Record<string, any>;
92
- }): Promise<void>;
93
- /**
94
- * Updates a vector by its ID with the provided vector and/or metadata.
95
- * @param indexName - The name of the index containing the vector.
96
- * @param id - The ID of the vector to update.
97
- * @param update - An object containing the vector and/or metadata to update.
98
- * @param update.vector - An optional array of numbers representing the new vector.
99
- * @param update.metadata - An optional record containing the new metadata.
100
- * @returns A promise that resolves when the update is complete.
101
- * @throws Will throw an error if no updates are provided or if the update operation fails.
102
- */
103
- updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
104
- /**
105
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
106
- *
107
- * Deletes a vector by its ID.
108
- * @param indexName - The name of the index containing the vector.
109
- * @param id - The ID of the vector to delete.
110
- * @returns A promise that resolves when the deletion is complete.
111
- * @throws Will throw an error if the deletion operation fails.
112
- */
113
- deleteIndexById(indexName: string, id: string): Promise<void>;
79
+ updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
114
80
  /**
115
81
  * Deletes a vector by its ID.
116
82
  * @param indexName - The name of the index containing the vector.
@@ -118,7 +84,7 @@ declare class ChromaVector extends MastraVector {
118
84
  * @returns A promise that resolves when the deletion is complete.
119
85
  * @throws Will throw an error if the deletion operation fails.
120
86
  */
121
- deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void>;
87
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
122
88
  }
123
89
  export { ChromaVector }
124
90
  export { ChromaVector as ChromaVector_alias_1 }
package/dist/index.cjs CHANGED
@@ -124,9 +124,7 @@ 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
129
  const stats = await this.describeIndex({ indexName });
132
130
  this.validateVectorDimensions(vectors, stats.dimension);
@@ -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);
@@ -206,13 +207,10 @@ var ChromaVector = class extends vector.MastraVector {
206
207
  /**
207
208
  * Retrieves statistics about a vector index.
208
209
  *
209
- * @param params - The parameters for describing an index
210
- * @param params.indexName - The name of the index to describe
210
+ * @param {string} indexName - The name of the index to describe
211
211
  * @returns A promise that resolves to the index statistics including dimension, count and metric
212
212
  */
213
- async describeIndex(...args) {
214
- const params = this.normalizeArgs("describeIndex", args);
215
- const { indexName } = params;
213
+ async describeIndex({ indexName }) {
216
214
  const collection = await this.getCollection(indexName);
217
215
  const count = await collection.count();
218
216
  const metadata = collection.metadata;
@@ -223,32 +221,10 @@ var ChromaVector = class extends vector.MastraVector {
223
221
  metric: this.HnswSpaceMap[hnswSpace]
224
222
  };
225
223
  }
226
- async deleteIndex(...args) {
227
- const params = this.normalizeArgs("deleteIndex", args);
228
- const { indexName } = params;
224
+ async deleteIndex({ indexName }) {
229
225
  await this.client.deleteCollection({ name: indexName });
230
226
  this.collections.delete(indexName);
231
227
  }
232
- /**
233
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
234
- *
235
- * Updates a vector by its ID with the provided vector and/or metadata.
236
- * @param indexName - The name of the index containing the vector.
237
- * @param id - The ID of the vector to update.
238
- * @param update - An object containing the vector and/or metadata to update.
239
- * @param update.vector - An optional array of numbers representing the new vector.
240
- * @param update.metadata - An optional record containing the new metadata.
241
- * @returns A promise that resolves when the update is complete.
242
- * @throws Will throw an error if no updates are provided or if the update operation fails.
243
- */
244
- async updateIndexById(indexName, id, update) {
245
- this.logger.warn(
246
- `Deprecation Warning: updateIndexById() is deprecated.
247
- Please use updateVector() instead.
248
- updateIndexById() will be removed on May 20th, 2025.`
249
- );
250
- await this.updateVector({ indexName, id, update });
251
- }
252
228
  /**
253
229
  * Updates a vector by its ID with the provided vector and/or metadata.
254
230
  * @param indexName - The name of the index containing the vector.
@@ -259,9 +235,7 @@ var ChromaVector = class extends vector.MastraVector {
259
235
  * @returns A promise that resolves when the update is complete.
260
236
  * @throws Will throw an error if no updates are provided or if the update operation fails.
261
237
  */
262
- async updateVector(...args) {
263
- const params = this.normalizeArgs("updateVector", args);
264
- const { indexName, id, update } = params;
238
+ async updateVector({ indexName, id, update }) {
265
239
  try {
266
240
  if (!update.vector && !update.metadata) {
267
241
  throw new Error("No updates provided");
@@ -281,21 +255,6 @@ var ChromaVector = class extends vector.MastraVector {
281
255
  throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
282
256
  }
283
257
  }
284
- /**
285
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
286
- *
287
- * Deletes a vector by its ID.
288
- * @param indexName - The name of the index containing the vector.
289
- * @param id - The ID of the vector to delete.
290
- * @returns A promise that resolves when the deletion is complete.
291
- * @throws Will throw an error if the deletion operation fails.
292
- */
293
- async deleteIndexById(indexName, id) {
294
- this.logger.warn(
295
- `Deprecation Warning: deleteIndexById() is deprecated. Please use deleteVector() instead. deleteIndexById() will be removed on May 20th.`
296
- );
297
- await this.deleteVector(indexName, id);
298
- }
299
258
  /**
300
259
  * Deletes a vector by its ID.
301
260
  * @param indexName - The name of the index containing the vector.
@@ -303,9 +262,7 @@ var ChromaVector = class extends vector.MastraVector {
303
262
  * @returns A promise that resolves when the deletion is complete.
304
263
  * @throws Will throw an error if the deletion operation fails.
305
264
  */
306
- async deleteVector(...args) {
307
- const params = this.normalizeArgs("deleteVector", args);
308
- const { indexName, id } = params;
265
+ async deleteVector({ indexName, id }) {
309
266
  try {
310
267
  const collection = await this.getCollection(indexName, true);
311
268
  await collection.delete({ ids: [id] });
package/dist/index.js CHANGED
@@ -122,9 +122,7 @@ 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
127
  const stats = await this.describeIndex({ indexName });
130
128
  this.validateVectorDimensions(vectors, stats.dimension);
@@ -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);
@@ -204,13 +205,10 @@ var ChromaVector = class extends MastraVector {
204
205
  /**
205
206
  * Retrieves statistics about a vector index.
206
207
  *
207
- * @param params - The parameters for describing an index
208
- * @param params.indexName - The name of the index to describe
208
+ * @param {string} indexName - The name of the index to describe
209
209
  * @returns A promise that resolves to the index statistics including dimension, count and metric
210
210
  */
211
- async describeIndex(...args) {
212
- const params = this.normalizeArgs("describeIndex", args);
213
- const { indexName } = params;
211
+ async describeIndex({ indexName }) {
214
212
  const collection = await this.getCollection(indexName);
215
213
  const count = await collection.count();
216
214
  const metadata = collection.metadata;
@@ -221,32 +219,10 @@ var ChromaVector = class extends MastraVector {
221
219
  metric: this.HnswSpaceMap[hnswSpace]
222
220
  };
223
221
  }
224
- async deleteIndex(...args) {
225
- const params = this.normalizeArgs("deleteIndex", args);
226
- const { indexName } = params;
222
+ async deleteIndex({ indexName }) {
227
223
  await this.client.deleteCollection({ name: indexName });
228
224
  this.collections.delete(indexName);
229
225
  }
230
- /**
231
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
232
- *
233
- * Updates a vector by its ID with the provided vector and/or metadata.
234
- * @param indexName - The name of the index containing the vector.
235
- * @param id - The ID of the vector to update.
236
- * @param update - An object containing the vector and/or metadata to update.
237
- * @param update.vector - An optional array of numbers representing the new vector.
238
- * @param update.metadata - An optional record containing the new metadata.
239
- * @returns A promise that resolves when the update is complete.
240
- * @throws Will throw an error if no updates are provided or if the update operation fails.
241
- */
242
- async updateIndexById(indexName, id, update) {
243
- this.logger.warn(
244
- `Deprecation Warning: updateIndexById() is deprecated.
245
- Please use updateVector() instead.
246
- updateIndexById() will be removed on May 20th, 2025.`
247
- );
248
- await this.updateVector({ indexName, id, update });
249
- }
250
226
  /**
251
227
  * Updates a vector by its ID with the provided vector and/or metadata.
252
228
  * @param indexName - The name of the index containing the vector.
@@ -257,9 +233,7 @@ var ChromaVector = class extends MastraVector {
257
233
  * @returns A promise that resolves when the update is complete.
258
234
  * @throws Will throw an error if no updates are provided or if the update operation fails.
259
235
  */
260
- async updateVector(...args) {
261
- const params = this.normalizeArgs("updateVector", args);
262
- const { indexName, id, update } = params;
236
+ async updateVector({ indexName, id, update }) {
263
237
  try {
264
238
  if (!update.vector && !update.metadata) {
265
239
  throw new Error("No updates provided");
@@ -279,21 +253,6 @@ var ChromaVector = class extends MastraVector {
279
253
  throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
280
254
  }
281
255
  }
282
- /**
283
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
284
- *
285
- * Deletes a vector by its ID.
286
- * @param indexName - The name of the index containing the vector.
287
- * @param id - The ID of the vector to delete.
288
- * @returns A promise that resolves when the deletion is complete.
289
- * @throws Will throw an error if the deletion operation fails.
290
- */
291
- async deleteIndexById(indexName, id) {
292
- this.logger.warn(
293
- `Deprecation Warning: deleteIndexById() is deprecated. Please use deleteVector() instead. deleteIndexById() will be removed on May 20th.`
294
- );
295
- await this.deleteVector(indexName, id);
296
- }
297
256
  /**
298
257
  * Deletes a vector by its ID.
299
258
  * @param indexName - The name of the index containing the vector.
@@ -301,9 +260,7 @@ var ChromaVector = class extends MastraVector {
301
260
  * @returns A promise that resolves when the deletion is complete.
302
261
  * @throws Will throw an error if the deletion operation fails.
303
262
  */
304
- async deleteVector(...args) {
305
- const params = this.normalizeArgs("deleteVector", args);
306
- const { indexName, id } = params;
263
+ async deleteVector({ indexName, id }) {
307
264
  try {
308
265
  const collection = await this.getCollection(indexName, true);
309
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.16-alpha.0",
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.5-alpha.0"
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",
@@ -1462,115 +1462,6 @@ describe('ChromaVector Integration Tests', () => {
1462
1462
  });
1463
1463
  });
1464
1464
  });
1465
- describe('Deprecation Warnings', () => {
1466
- const indexName = 'testdeprecationwarnings';
1467
-
1468
- const indexName2 = 'testdeprecationwarnings2';
1469
-
1470
- let warnSpy;
1471
-
1472
- beforeAll(async () => {
1473
- await vectorDB.createIndex({ indexName, dimension: 3 });
1474
- });
1475
-
1476
- afterAll(async () => {
1477
- try {
1478
- await vectorDB.deleteIndex({ indexName });
1479
- } catch {
1480
- // Ignore errors if index doesn't exist
1481
- }
1482
- try {
1483
- await vectorDB.deleteIndex({ indexName: indexName2 });
1484
- } catch {
1485
- // Ignore errors if index doesn't exist
1486
- }
1487
- });
1488
-
1489
- beforeEach(async () => {
1490
- warnSpy = vi.spyOn(vectorDB['logger'], 'warn');
1491
- });
1492
-
1493
- afterEach(async () => {
1494
- warnSpy.mockRestore();
1495
- try {
1496
- await vectorDB.deleteIndex({ indexName: indexName2 });
1497
- } catch {
1498
- // Ignore errors if index doesn't exist
1499
- }
1500
- });
1501
-
1502
- it('should show deprecation warning when using individual args for createIndex', async () => {
1503
- await vectorDB.createIndex(indexName2, 3, 'cosine');
1504
-
1505
- expect(warnSpy).toHaveBeenCalledWith(
1506
- expect.stringContaining('Deprecation Warning: Passing individual arguments to createIndex() is deprecated'),
1507
- );
1508
- });
1509
-
1510
- it('should show deprecation warning when using individual args for upsert', async () => {
1511
- await vectorDB.upsert(indexName, [[1, 2, 3]], [{ test: 'data' }]);
1512
-
1513
- expect(warnSpy).toHaveBeenCalledWith(
1514
- expect.stringContaining('Deprecation Warning: Passing individual arguments to upsert() is deprecated'),
1515
- );
1516
- });
1517
-
1518
- it('should show deprecation warning when using individual args for query', async () => {
1519
- await vectorDB.query(indexName, [1, 2, 3], 5);
1520
-
1521
- expect(warnSpy).toHaveBeenCalledWith(
1522
- expect.stringContaining('Deprecation Warning: Passing individual arguments to query() is deprecated'),
1523
- );
1524
- });
1525
-
1526
- it('should not show deprecation warning when using object param for query', async () => {
1527
- await vectorDB.query({
1528
- indexName,
1529
- queryVector: [1, 2, 3],
1530
- topK: 5,
1531
- });
1532
-
1533
- expect(warnSpy).not.toHaveBeenCalled();
1534
- });
1535
-
1536
- it('should not show deprecation warning when using object param for createIndex', async () => {
1537
- await vectorDB.createIndex({
1538
- indexName: indexName2,
1539
- dimension: 3,
1540
- metric: 'cosine',
1541
- });
1542
-
1543
- expect(warnSpy).not.toHaveBeenCalled();
1544
- });
1545
-
1546
- it('should not show deprecation warning when using object param for upsert', async () => {
1547
- await vectorDB.upsert({
1548
- indexName,
1549
- vectors: [[1, 2, 3]],
1550
- metadata: [{ test: 'data' }],
1551
- });
1552
-
1553
- expect(warnSpy).not.toHaveBeenCalled();
1554
- });
1555
-
1556
- it('should maintain backward compatibility with individual args', async () => {
1557
- // Query
1558
- const queryResults = await vectorDB.query(indexName, [1, 2, 3], 5);
1559
- expect(Array.isArray(queryResults)).toBe(true);
1560
-
1561
- // CreateIndex
1562
- await expect(vectorDB.createIndex(indexName2, 3, 'cosine')).resolves.not.toThrow();
1563
-
1564
- // Upsert
1565
- const upsertResults = await vectorDB.upsert({
1566
- indexName,
1567
- vectors: [[1, 2, 3]],
1568
- metadata: [{ test: 'data' }],
1569
- });
1570
- expect(Array.isArray(upsertResults)).toBe(true);
1571
- expect(upsertResults).toHaveLength(1);
1572
- });
1573
- });
1574
1465
 
1575
1466
  describe('Performance and Concurrency', () => {
1576
1467
  const perfTestIndex = 'perf-test-index';
@@ -5,9 +5,6 @@ import type {
5
5
  CreateIndexParams,
6
6
  UpsertVectorParams,
7
7
  QueryVectorParams,
8
- ParamsToArgs,
9
- QueryVectorArgs,
10
- UpsertVectorArgs,
11
8
  DescribeIndexParams,
12
9
  DeleteIndexParams,
13
10
  DeleteVectorParams,
@@ -23,14 +20,10 @@ interface ChromaUpsertVectorParams extends UpsertVectorParams {
23
20
  documents?: string[];
24
21
  }
25
22
 
26
- type ChromaUpsertArgs = [...UpsertVectorArgs, string[]?];
27
-
28
23
  interface ChromaQueryVectorParams extends QueryVectorParams {
29
24
  documentFilter?: VectorFilter;
30
25
  }
31
26
 
32
- type ChromaQueryArgs = [...QueryVectorArgs, VectorFilter?];
33
-
34
27
  export class ChromaVector extends MastraVector {
35
28
  private client: ChromaClient;
36
29
  private collections: Map<string, any>;
@@ -76,11 +69,7 @@ export class ChromaVector extends MastraVector {
76
69
  }
77
70
  }
78
71
 
79
- async upsert(...args: ParamsToArgs<ChromaUpsertVectorParams> | ChromaUpsertArgs): Promise<string[]> {
80
- const params = this.normalizeArgs<ChromaUpsertVectorParams, ChromaUpsertArgs>('upsert', args, ['documents']);
81
-
82
- const { indexName, vectors, metadata, ids, documents } = params;
83
-
72
+ async upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]> {
84
73
  const collection = await this.getCollection(indexName);
85
74
 
86
75
  // Get index stats to check dimension
@@ -113,10 +102,7 @@ export class ChromaVector extends MastraVector {
113
102
  ip: 'dotproduct',
114
103
  };
115
104
 
116
- async createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void> {
117
- const params = this.normalizeArgs<CreateIndexParams>('createIndex', args);
118
- const { indexName, dimension, metric = 'cosine' } = params;
119
-
105
+ async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {
120
106
  if (!Number.isInteger(dimension) || dimension <= 0) {
121
107
  throw new Error('Dimension must be a positive integer');
122
108
  }
@@ -148,11 +134,14 @@ export class ChromaVector extends MastraVector {
148
134
  const translator = new ChromaFilterTranslator();
149
135
  return translator.translate(filter);
150
136
  }
151
- async query(...args: ParamsToArgs<ChromaQueryVectorParams> | ChromaQueryArgs): Promise<QueryResult[]> {
152
- const params = this.normalizeArgs<ChromaQueryVectorParams, ChromaQueryArgs>('query', args, ['documentFilter']);
153
-
154
- const { indexName, queryVector, topK = 10, filter, includeVector = false, documentFilter } = params;
155
-
137
+ async query({
138
+ indexName,
139
+ queryVector,
140
+ topK = 10,
141
+ filter,
142
+ includeVector = false,
143
+ documentFilter,
144
+ }: ChromaQueryVectorParams): Promise<QueryResult[]> {
156
145
  const collection = await this.getCollection(indexName, true);
157
146
 
158
147
  const defaultInclude = ['documents', 'metadatas', 'distances'];
@@ -184,14 +173,10 @@ export class ChromaVector extends MastraVector {
184
173
  /**
185
174
  * Retrieves statistics about a vector index.
186
175
  *
187
- * @param params - The parameters for describing an index
188
- * @param params.indexName - The name of the index to describe
176
+ * @param {string} indexName - The name of the index to describe
189
177
  * @returns A promise that resolves to the index statistics including dimension, count and metric
190
178
  */
191
- async describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats> {
192
- const params = this.normalizeArgs<DescribeIndexParams>('describeIndex', args);
193
- const { indexName } = params;
194
-
179
+ async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {
195
180
  const collection = await this.getCollection(indexName);
196
181
  const count = await collection.count();
197
182
  const metadata = collection.metadata;
@@ -205,38 +190,11 @@ export class ChromaVector extends MastraVector {
205
190
  };
206
191
  }
207
192
 
208
- async deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void> {
209
- const params = this.normalizeArgs<DeleteIndexParams>('deleteIndex', args);
210
- const { indexName } = params;
193
+ async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {
211
194
  await this.client.deleteCollection({ name: indexName });
212
195
  this.collections.delete(indexName);
213
196
  }
214
197
 
215
- /**
216
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
217
- *
218
- * Updates a vector by its ID with the provided vector and/or metadata.
219
- * @param indexName - The name of the index containing the vector.
220
- * @param id - The ID of the vector to update.
221
- * @param update - An object containing the vector and/or metadata to update.
222
- * @param update.vector - An optional array of numbers representing the new vector.
223
- * @param update.metadata - An optional record containing the new metadata.
224
- * @returns A promise that resolves when the update is complete.
225
- * @throws Will throw an error if no updates are provided or if the update operation fails.
226
- */
227
- async updateIndexById(
228
- indexName: string,
229
- id: string,
230
- update: { vector?: number[]; metadata?: Record<string, any> },
231
- ): Promise<void> {
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
198
  /**
241
199
  * Updates a vector by its ID with the provided vector and/or metadata.
242
200
  * @param indexName - The name of the index containing the vector.
@@ -247,9 +205,7 @@ export class ChromaVector extends MastraVector {
247
205
  * @returns A promise that resolves when the update is complete.
248
206
  * @throws Will throw an error if no updates are provided or if the update operation fails.
249
207
  */
250
- async updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void> {
251
- const params = this.normalizeArgs<UpdateVectorParams>('updateVector', args);
252
- const { indexName, id, update } = params;
208
+ async updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void> {
253
209
  try {
254
210
  if (!update.vector && !update.metadata) {
255
211
  throw new Error('No updates provided');
@@ -275,22 +231,6 @@ export class ChromaVector extends MastraVector {
275
231
  }
276
232
  }
277
233
 
278
- /**
279
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
280
- *
281
- * Deletes a vector by its ID.
282
- * @param indexName - The name of the index containing the vector.
283
- * @param id - The ID of the vector to delete.
284
- * @returns A promise that resolves when the deletion is complete.
285
- * @throws Will throw an error if the deletion operation fails.
286
- */
287
- async deleteIndexById(indexName: string, id: string): Promise<void> {
288
- this.logger.warn(
289
- `Deprecation Warning: deleteIndexById() is deprecated. Please use deleteVector() instead. deleteIndexById() will be removed on May 20th.`,
290
- );
291
- await this.deleteVector(indexName, id);
292
- }
293
-
294
234
  /**
295
235
  * Deletes a vector by its ID.
296
236
  * @param indexName - The name of the index containing the vector.
@@ -298,10 +238,7 @@ export class ChromaVector extends MastraVector {
298
238
  * @returns A promise that resolves when the deletion is complete.
299
239
  * @throws Will throw an error if the deletion operation fails.
300
240
  */
301
- async deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void> {
302
- const params = this.normalizeArgs<DeleteVectorParams>('deleteVector', args);
303
-
304
- const { indexName, id } = params;
241
+ async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {
305
242
  try {
306
243
  const collection: Collection = await this.getCollection(indexName, true);
307
244
  await collection.delete({ ids: [id] });