@mastra/chroma 0.10.3 → 0.10.4-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.10.3-alpha.0 build /home/runner/work/mastra/mastra/stores/chroma
2
+ > @mastra/chroma@0.10.4-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.5.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 8884ms
9
+ TSC ⚡️ Build success in 8871ms
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 9546ms
16
+ DTS ⚡️ Build success in 8471ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- ESM dist/index.js 12.30 KB
21
- ESM ⚡️ Build success in 820ms
22
- CJS dist/index.cjs 12.35 KB
23
- CJS ⚡️ Build success in 817ms
20
+ CJS dist/index.cjs 15.17 KB
21
+ CJS ⚡️ Build success in 550ms
22
+ ESM dist/index.js 14.87 KB
23
+ ESM ⚡️ Build success in 550ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @mastra/chroma
2
2
 
3
+ ## 0.10.4-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 144eb0b: [MASTRA-3669] Metadata Filter Types
8
+ - Updated dependencies [15e9d26]
9
+ - Updated dependencies [07d6d88]
10
+ - Updated dependencies [5d74aab]
11
+ - Updated dependencies [144eb0b]
12
+ - @mastra/core@0.10.7-alpha.2
13
+
14
+ ## 0.10.4-alpha.0
15
+
16
+ ### Patch Changes
17
+
18
+ - 0e17048: Throw mastra errors in storage packages
19
+ - Updated dependencies [d1baedb]
20
+ - Updated dependencies [4d21bf2]
21
+ - Updated dependencies [2097952]
22
+ - Updated dependencies [4fb0cc2]
23
+ - Updated dependencies [d2a7a31]
24
+ - Updated dependencies [0e17048]
25
+ - @mastra/core@0.10.7-alpha.1
26
+
3
27
  ## 0.10.3
4
28
 
5
29
  ### Patch Changes
@@ -1,11 +1,14 @@
1
1
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
+ import type { BlacklistedRootOperators } from '@mastra/core/vector/filter';
2
3
  import type { CreateIndexParams } from '@mastra/core/vector';
3
4
  import type { DeleteIndexParams } from '@mastra/core/vector';
4
5
  import type { DeleteVectorParams } from '@mastra/core/vector';
5
6
  import type { DescribeIndexParams } from '@mastra/core/vector';
6
7
  import type { IndexStats } from '@mastra/core/vector';
8
+ import type { LogicalOperatorValueMap } from '@mastra/core/vector/filter';
7
9
  import { MastraVector } from '@mastra/core/vector';
8
10
  import type { OperatorSupport } from '@mastra/core/vector/filter';
11
+ import type { OperatorValueMap } from '@mastra/core/vector/filter';
9
12
  import type { QueryResult } from '@mastra/core/vector';
10
13
  import type { QueryVectorParams } from '@mastra/core/vector';
11
14
  import type { UpdateVectorParams } from '@mastra/core/vector';
@@ -20,27 +23,37 @@ declare const CHROMA_PROMPT = "When querying Chroma, you can ONLY use the operat
20
23
  export { CHROMA_PROMPT }
21
24
  export { CHROMA_PROMPT as CHROMA_PROMPT_alias_1 }
22
25
 
26
+ declare type ChromaBlacklisted = BlacklistedRootOperators | '$nor' | '$not';
27
+
28
+ declare type ChromaDocumentBlacklisted = Exclude<ChromaBlacklisted, '$contains'>;
29
+
30
+ declare type ChromaDocumentOperatorValueMap = ChromaOperatorValueMap;
31
+
23
32
  /**
24
33
  * Translator for Chroma filter queries.
25
34
  * Maintains MongoDB-compatible syntax while ensuring proper validation
26
35
  * and normalization of values.
27
36
  */
28
- export declare class ChromaFilterTranslator extends BaseFilterTranslator {
37
+ export declare class ChromaFilterTranslator extends BaseFilterTranslator<ChromaVectorFilter> {
29
38
  protected getSupportedOperators(): OperatorSupport;
30
- translate(filter?: VectorFilter): VectorFilter;
39
+ translate(filter?: ChromaVectorFilter): ChromaVectorFilter;
31
40
  private translateNode;
32
41
  private translateOperator;
33
42
  }
34
43
 
35
- declare interface ChromaQueryVectorParams extends QueryVectorParams {
36
- documentFilter?: VectorFilter;
44
+ declare type ChromaLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor' | '$not'>;
45
+
46
+ declare type ChromaOperatorValueMap = Omit<OperatorValueMap, '$exists' | '$elemMatch' | '$regex' | '$options'>;
47
+
48
+ declare interface ChromaQueryVectorParams extends QueryVectorParams<ChromaVectorFilter> {
49
+ documentFilter?: ChromaVectorDocumentFilter;
37
50
  }
38
51
 
39
52
  declare interface ChromaUpsertVectorParams extends UpsertVectorParams {
40
53
  documents?: string[];
41
54
  }
42
55
 
43
- declare class ChromaVector extends MastraVector {
56
+ declare class ChromaVector extends MastraVector<ChromaVectorFilter> {
44
57
  private client;
45
58
  private collections;
46
59
  constructor({ path, auth, }: {
@@ -55,7 +68,7 @@ declare class ChromaVector extends MastraVector {
55
68
  upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]>;
56
69
  private HnswSpaceMap;
57
70
  createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
58
- transformFilter(filter?: VectorFilter): VectorFilter;
71
+ transformFilter(filter?: ChromaVectorFilter): ChromaVectorFilter;
59
72
  query({ indexName, queryVector, topK, filter, includeVector, documentFilter, }: ChromaQueryVectorParams): Promise<QueryResult[]>;
60
73
  listIndexes(): Promise<string[]>;
61
74
  /**
@@ -77,16 +90,13 @@ declare class ChromaVector extends MastraVector {
77
90
  * @throws Will throw an error if no updates are provided or if the update operation fails.
78
91
  */
79
92
  updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
80
- /**
81
- * Deletes a vector by its ID.
82
- * @param indexName - The name of the index containing the vector.
83
- * @param id - The ID of the vector to delete.
84
- * @returns A promise that resolves when the deletion is complete.
85
- * @throws Will throw an error if the deletion operation fails.
86
- */
87
93
  deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
88
94
  }
89
95
  export { ChromaVector }
90
96
  export { ChromaVector as ChromaVector_alias_1 }
91
97
 
98
+ export declare type ChromaVectorDocumentFilter = VectorFilter<keyof ChromaDocumentOperatorValueMap, ChromaDocumentOperatorValueMap, ChromaLogicalOperatorValueMap, ChromaDocumentBlacklisted>;
99
+
100
+ export declare type ChromaVectorFilter = VectorFilter<keyof ChromaOperatorValueMap, ChromaOperatorValueMap, ChromaLogicalOperatorValueMap, ChromaBlacklisted>;
101
+
92
102
  export { }
@@ -1,11 +1,14 @@
1
1
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
+ import type { BlacklistedRootOperators } from '@mastra/core/vector/filter';
2
3
  import type { CreateIndexParams } from '@mastra/core/vector';
3
4
  import type { DeleteIndexParams } from '@mastra/core/vector';
4
5
  import type { DeleteVectorParams } from '@mastra/core/vector';
5
6
  import type { DescribeIndexParams } from '@mastra/core/vector';
6
7
  import type { IndexStats } from '@mastra/core/vector';
8
+ import type { LogicalOperatorValueMap } from '@mastra/core/vector/filter';
7
9
  import { MastraVector } from '@mastra/core/vector';
8
10
  import type { OperatorSupport } from '@mastra/core/vector/filter';
11
+ import type { OperatorValueMap } from '@mastra/core/vector/filter';
9
12
  import type { QueryResult } from '@mastra/core/vector';
10
13
  import type { QueryVectorParams } from '@mastra/core/vector';
11
14
  import type { UpdateVectorParams } from '@mastra/core/vector';
@@ -20,27 +23,37 @@ declare const CHROMA_PROMPT = "When querying Chroma, you can ONLY use the operat
20
23
  export { CHROMA_PROMPT }
21
24
  export { CHROMA_PROMPT as CHROMA_PROMPT_alias_1 }
22
25
 
26
+ declare type ChromaBlacklisted = BlacklistedRootOperators | '$nor' | '$not';
27
+
28
+ declare type ChromaDocumentBlacklisted = Exclude<ChromaBlacklisted, '$contains'>;
29
+
30
+ declare type ChromaDocumentOperatorValueMap = ChromaOperatorValueMap;
31
+
23
32
  /**
24
33
  * Translator for Chroma filter queries.
25
34
  * Maintains MongoDB-compatible syntax while ensuring proper validation
26
35
  * and normalization of values.
27
36
  */
28
- export declare class ChromaFilterTranslator extends BaseFilterTranslator {
37
+ export declare class ChromaFilterTranslator extends BaseFilterTranslator<ChromaVectorFilter> {
29
38
  protected getSupportedOperators(): OperatorSupport;
30
- translate(filter?: VectorFilter): VectorFilter;
39
+ translate(filter?: ChromaVectorFilter): ChromaVectorFilter;
31
40
  private translateNode;
32
41
  private translateOperator;
33
42
  }
34
43
 
35
- declare interface ChromaQueryVectorParams extends QueryVectorParams {
36
- documentFilter?: VectorFilter;
44
+ declare type ChromaLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor' | '$not'>;
45
+
46
+ declare type ChromaOperatorValueMap = Omit<OperatorValueMap, '$exists' | '$elemMatch' | '$regex' | '$options'>;
47
+
48
+ declare interface ChromaQueryVectorParams extends QueryVectorParams<ChromaVectorFilter> {
49
+ documentFilter?: ChromaVectorDocumentFilter;
37
50
  }
38
51
 
39
52
  declare interface ChromaUpsertVectorParams extends UpsertVectorParams {
40
53
  documents?: string[];
41
54
  }
42
55
 
43
- declare class ChromaVector extends MastraVector {
56
+ declare class ChromaVector extends MastraVector<ChromaVectorFilter> {
44
57
  private client;
45
58
  private collections;
46
59
  constructor({ path, auth, }: {
@@ -55,7 +68,7 @@ declare class ChromaVector extends MastraVector {
55
68
  upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]>;
56
69
  private HnswSpaceMap;
57
70
  createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
58
- transformFilter(filter?: VectorFilter): VectorFilter;
71
+ transformFilter(filter?: ChromaVectorFilter): ChromaVectorFilter;
59
72
  query({ indexName, queryVector, topK, filter, includeVector, documentFilter, }: ChromaQueryVectorParams): Promise<QueryResult[]>;
60
73
  listIndexes(): Promise<string[]>;
61
74
  /**
@@ -77,16 +90,13 @@ declare class ChromaVector extends MastraVector {
77
90
  * @throws Will throw an error if no updates are provided or if the update operation fails.
78
91
  */
79
92
  updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
80
- /**
81
- * Deletes a vector by its ID.
82
- * @param indexName - The name of the index containing the vector.
83
- * @param id - The ID of the vector to delete.
84
- * @returns A promise that resolves when the deletion is complete.
85
- * @throws Will throw an error if the deletion operation fails.
86
- */
87
93
  deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
88
94
  }
89
95
  export { ChromaVector }
90
96
  export { ChromaVector as ChromaVector_alias_1 }
91
97
 
98
+ export declare type ChromaVectorDocumentFilter = VectorFilter<keyof ChromaDocumentOperatorValueMap, ChromaDocumentOperatorValueMap, ChromaLogicalOperatorValueMap, ChromaDocumentBlacklisted>;
99
+
100
+ export declare type ChromaVectorFilter = VectorFilter<keyof ChromaOperatorValueMap, ChromaOperatorValueMap, ChromaLogicalOperatorValueMap, ChromaBlacklisted>;
101
+
92
102
  export { }
package/dist/index.cjs CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var error = require('@mastra/core/error');
3
4
  var vector = require('@mastra/core/vector');
4
5
  var chromadb = require('chromadb');
5
6
  var filter = require('@mastra/core/vector/filter');
@@ -125,18 +126,31 @@ var ChromaVector = class extends vector.MastraVector {
125
126
  }
126
127
  }
127
128
  async upsert({ indexName, vectors, metadata, ids, documents }) {
128
- const collection = await this.getCollection(indexName);
129
- const stats = await this.describeIndex({ indexName });
130
- this.validateVectorDimensions(vectors, stats.dimension);
131
- const generatedIds = ids || vectors.map(() => crypto.randomUUID());
132
- const normalizedMetadata = metadata || vectors.map(() => ({}));
133
- await collection.upsert({
134
- ids: generatedIds,
135
- embeddings: vectors,
136
- metadatas: normalizedMetadata,
137
- documents
138
- });
139
- return generatedIds;
129
+ try {
130
+ const collection = await this.getCollection(indexName);
131
+ const stats = await this.describeIndex({ indexName });
132
+ this.validateVectorDimensions(vectors, stats.dimension);
133
+ const generatedIds = ids || vectors.map(() => crypto.randomUUID());
134
+ const normalizedMetadata = metadata || vectors.map(() => ({}));
135
+ await collection.upsert({
136
+ ids: generatedIds,
137
+ embeddings: vectors,
138
+ metadatas: normalizedMetadata,
139
+ documents
140
+ });
141
+ return generatedIds;
142
+ } catch (error$1) {
143
+ if (error$1 instanceof error.MastraError) throw error$1;
144
+ throw new error.MastraError(
145
+ {
146
+ id: "CHROMA_VECTOR_UPSERT_FAILED",
147
+ domain: error.ErrorDomain.MASTRA_VECTOR,
148
+ category: error.ErrorCategory.THIRD_PARTY,
149
+ details: { indexName }
150
+ },
151
+ error$1
152
+ );
153
+ }
140
154
  }
141
155
  HnswSpaceMap = {
142
156
  cosine: "cosine",
@@ -147,11 +161,23 @@ var ChromaVector = class extends vector.MastraVector {
147
161
  };
148
162
  async createIndex({ indexName, dimension, metric = "cosine" }) {
149
163
  if (!Number.isInteger(dimension) || dimension <= 0) {
150
- throw new Error("Dimension must be a positive integer");
164
+ throw new error.MastraError({
165
+ id: "CHROMA_VECTOR_CREATE_INDEX_INVALID_DIMENSION",
166
+ text: "Dimension must be a positive integer",
167
+ domain: error.ErrorDomain.MASTRA_VECTOR,
168
+ category: error.ErrorCategory.USER,
169
+ details: { dimension }
170
+ });
151
171
  }
152
172
  const hnswSpace = this.HnswSpaceMap[metric];
153
- if (!["cosine", "l2", "ip"].includes(hnswSpace)) {
154
- throw new Error(`Invalid metric: "${metric}". Must be one of: cosine, euclidean, dotproduct`);
173
+ if (!hnswSpace || !["cosine", "l2", "ip"].includes(hnswSpace)) {
174
+ throw new error.MastraError({
175
+ id: "CHROMA_VECTOR_CREATE_INDEX_INVALID_METRIC",
176
+ text: `Invalid metric: "${metric}". Must be one of: cosine, euclidean, dotproduct`,
177
+ domain: error.ErrorDomain.MASTRA_VECTOR,
178
+ category: error.ErrorCategory.USER,
179
+ details: { metric }
180
+ });
155
181
  }
156
182
  try {
157
183
  await this.client.createCollection({
@@ -161,13 +187,21 @@ var ChromaVector = class extends vector.MastraVector {
161
187
  "hnsw:space": hnswSpace
162
188
  }
163
189
  });
164
- } catch (error) {
165
- const message = error?.message || error?.toString();
190
+ } catch (error$1) {
191
+ const message = error$1?.message || error$1?.toString();
166
192
  if (message && message.toLowerCase().includes("already exists")) {
167
193
  await this.validateExistingIndex(indexName, dimension, metric);
168
194
  return;
169
195
  }
170
- throw error;
196
+ throw new error.MastraError(
197
+ {
198
+ id: "CHROMA_VECTOR_CREATE_INDEX_FAILED",
199
+ domain: error.ErrorDomain.MASTRA_VECTOR,
200
+ category: error.ErrorCategory.THIRD_PARTY,
201
+ details: { indexName }
202
+ },
203
+ error$1
204
+ );
171
205
  }
172
206
  }
173
207
  transformFilter(filter) {
@@ -182,27 +216,51 @@ var ChromaVector = class extends vector.MastraVector {
182
216
  includeVector = false,
183
217
  documentFilter
184
218
  }) {
185
- const collection = await this.getCollection(indexName, true);
186
- const defaultInclude = ["documents", "metadatas", "distances"];
187
- const translatedFilter = this.transformFilter(filter);
188
- const results = await collection.query({
189
- queryEmbeddings: [queryVector],
190
- nResults: topK,
191
- where: translatedFilter,
192
- whereDocument: documentFilter,
193
- include: includeVector ? [...defaultInclude, "embeddings"] : defaultInclude
194
- });
195
- return (results.ids[0] || []).map((id, index) => ({
196
- id,
197
- score: results.distances?.[0]?.[index] || 0,
198
- metadata: results.metadatas?.[0]?.[index] || {},
199
- document: results.documents?.[0]?.[index],
200
- ...includeVector && { vector: results.embeddings?.[0]?.[index] || [] }
201
- }));
219
+ try {
220
+ const collection = await this.getCollection(indexName, true);
221
+ const defaultInclude = ["documents", "metadatas", "distances"];
222
+ const translatedFilter = this.transformFilter(filter);
223
+ const results = await collection.query({
224
+ queryEmbeddings: [queryVector],
225
+ nResults: topK,
226
+ where: translatedFilter,
227
+ whereDocument: documentFilter,
228
+ include: includeVector ? [...defaultInclude, "embeddings"] : defaultInclude
229
+ });
230
+ return (results.ids[0] || []).map((id, index) => ({
231
+ id,
232
+ score: results.distances?.[0]?.[index] || 0,
233
+ metadata: results.metadatas?.[0]?.[index] || {},
234
+ document: results.documents?.[0]?.[index],
235
+ ...includeVector && { vector: results.embeddings?.[0]?.[index] || [] }
236
+ }));
237
+ } catch (error$1) {
238
+ if (error$1 instanceof error.MastraError) throw error$1;
239
+ throw new error.MastraError(
240
+ {
241
+ id: "CHROMA_VECTOR_QUERY_FAILED",
242
+ domain: error.ErrorDomain.MASTRA_VECTOR,
243
+ category: error.ErrorCategory.THIRD_PARTY,
244
+ details: { indexName }
245
+ },
246
+ error$1
247
+ );
248
+ }
202
249
  }
203
250
  async listIndexes() {
204
- const collections = await this.client.listCollections();
205
- return collections.map((collection) => collection);
251
+ try {
252
+ const collections = await this.client.listCollections();
253
+ return collections.map((collection) => collection);
254
+ } catch (error$1) {
255
+ throw new error.MastraError(
256
+ {
257
+ id: "CHROMA_VECTOR_LIST_INDEXES_FAILED",
258
+ domain: error.ErrorDomain.MASTRA_VECTOR,
259
+ category: error.ErrorCategory.THIRD_PARTY
260
+ },
261
+ error$1
262
+ );
263
+ }
206
264
  }
207
265
  /**
208
266
  * Retrieves statistics about a vector index.
@@ -211,19 +269,44 @@ var ChromaVector = class extends vector.MastraVector {
211
269
  * @returns A promise that resolves to the index statistics including dimension, count and metric
212
270
  */
213
271
  async describeIndex({ indexName }) {
214
- const collection = await this.getCollection(indexName);
215
- const count = await collection.count();
216
- const metadata = collection.metadata;
217
- const hnswSpace = metadata?.["hnsw:space"];
218
- return {
219
- dimension: metadata?.dimension || 0,
220
- count,
221
- metric: this.HnswSpaceMap[hnswSpace]
222
- };
272
+ try {
273
+ const collection = await this.getCollection(indexName);
274
+ const count = await collection.count();
275
+ const metadata = collection.metadata;
276
+ const hnswSpace = metadata?.["hnsw:space"];
277
+ return {
278
+ dimension: metadata?.dimension || 0,
279
+ count,
280
+ metric: this.HnswSpaceMap[hnswSpace]
281
+ };
282
+ } catch (error$1) {
283
+ if (error$1 instanceof error.MastraError) throw error$1;
284
+ throw new error.MastraError(
285
+ {
286
+ id: "CHROMA_VECTOR_DESCRIBE_INDEX_FAILED",
287
+ domain: error.ErrorDomain.MASTRA_VECTOR,
288
+ category: error.ErrorCategory.THIRD_PARTY,
289
+ details: { indexName }
290
+ },
291
+ error$1
292
+ );
293
+ }
223
294
  }
224
295
  async deleteIndex({ indexName }) {
225
- await this.client.deleteCollection({ name: indexName });
226
- this.collections.delete(indexName);
296
+ try {
297
+ await this.client.deleteCollection({ name: indexName });
298
+ this.collections.delete(indexName);
299
+ } catch (error$1) {
300
+ throw new error.MastraError(
301
+ {
302
+ id: "CHROMA_VECTOR_DELETE_INDEX_FAILED",
303
+ domain: error.ErrorDomain.MASTRA_VECTOR,
304
+ category: error.ErrorCategory.THIRD_PARTY,
305
+ details: { indexName }
306
+ },
307
+ error$1
308
+ );
309
+ }
227
310
  }
228
311
  /**
229
312
  * Updates a vector by its ID with the provided vector and/or metadata.
@@ -236,10 +319,16 @@ var ChromaVector = class extends vector.MastraVector {
236
319
  * @throws Will throw an error if no updates are provided or if the update operation fails.
237
320
  */
238
321
  async updateVector({ indexName, id, update }) {
322
+ if (!update.vector && !update.metadata) {
323
+ throw new error.MastraError({
324
+ id: "CHROMA_VECTOR_UPDATE_NO_PAYLOAD",
325
+ text: "No updates provided for vector",
326
+ domain: error.ErrorDomain.MASTRA_VECTOR,
327
+ category: error.ErrorCategory.USER,
328
+ details: { indexName, id }
329
+ });
330
+ }
239
331
  try {
240
- if (!update.vector && !update.metadata) {
241
- throw new Error("No updates provided");
242
- }
243
332
  const collection = await this.getCollection(indexName, true);
244
333
  const updateOptions = { ids: [id] };
245
334
  if (update?.vector) {
@@ -251,23 +340,34 @@ var ChromaVector = class extends vector.MastraVector {
251
340
  updateOptions.metadatas = [update.metadata];
252
341
  }
253
342
  return await collection.update(updateOptions);
254
- } catch (error) {
255
- throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
343
+ } catch (error$1) {
344
+ if (error$1 instanceof error.MastraError) throw error$1;
345
+ throw new error.MastraError(
346
+ {
347
+ id: "CHROMA_VECTOR_UPDATE_FAILED",
348
+ domain: error.ErrorDomain.MASTRA_VECTOR,
349
+ category: error.ErrorCategory.THIRD_PARTY,
350
+ details: { indexName, id }
351
+ },
352
+ error$1
353
+ );
256
354
  }
257
355
  }
258
- /**
259
- * Deletes a vector by its ID.
260
- * @param indexName - The name of the index containing the vector.
261
- * @param id - The ID of the vector to delete.
262
- * @returns A promise that resolves when the deletion is complete.
263
- * @throws Will throw an error if the deletion operation fails.
264
- */
265
356
  async deleteVector({ indexName, id }) {
266
357
  try {
267
358
  const collection = await this.getCollection(indexName, true);
268
359
  await collection.delete({ ids: [id] });
269
- } catch (error) {
270
- throw new Error(`Failed to delete vector by id: ${id} for index name: ${indexName}: ${error.message}`);
360
+ } catch (error$1) {
361
+ if (error$1 instanceof error.MastraError) throw error$1;
362
+ throw new error.MastraError(
363
+ {
364
+ id: "CHROMA_VECTOR_DELETE_FAILED",
365
+ domain: error.ErrorDomain.MASTRA_VECTOR,
366
+ category: error.ErrorCategory.THIRD_PARTY,
367
+ details: { indexName, id }
368
+ },
369
+ error$1
370
+ );
271
371
  }
272
372
  }
273
373
  };