@mastra/couchbase 0.0.0-redis-cloud-transporter-20250508203756 → 0.0.0-vector-query-sources-20250516172905

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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,84 @@
1
1
  # @mastra/couchbase
2
2
 
3
- ## 0.0.0-redis-cloud-transporter-20250508203756
3
+ ## 0.0.0-vector-query-sources-20250516172905
4
+
5
+ ### Patch Changes
6
+
7
+ - d0ee3c6: Change all public functions and constructors in vector stores to use named args and prepare to phase out positional args
8
+ - Updated dependencies [f53a6ac]
9
+ - Updated dependencies [eabdcd9]
10
+ - Updated dependencies [d0ee3c6]
11
+ - Updated dependencies [23f258c]
12
+ - Updated dependencies [2672a05]
13
+ - @mastra/core@0.0.0-vector-query-sources-20250516172905
14
+
15
+ ## 0.0.4
16
+
17
+ ### Patch Changes
18
+
19
+ - c3bd795: [MASTRA-3358] Deprecate updateIndexById and deleteIndexById
20
+ - Updated dependencies [396be50]
21
+ - Updated dependencies [ab80e7e]
22
+ - Updated dependencies [c3bd795]
23
+ - Updated dependencies [da082f8]
24
+ - Updated dependencies [a5810ce]
25
+ - Updated dependencies [3e9c131]
26
+ - Updated dependencies [3171b5b]
27
+ - Updated dependencies [973e5ac]
28
+ - Updated dependencies [daf942f]
29
+ - Updated dependencies [0b8b868]
30
+ - Updated dependencies [9e1eff5]
31
+ - Updated dependencies [6fa1ad1]
32
+ - Updated dependencies [c28d7a0]
33
+ - Updated dependencies [edf1e88]
34
+ - @mastra/core@0.9.4
35
+
36
+ ## 0.0.4-alpha.4
37
+
38
+ ### Patch Changes
39
+
40
+ - Updated dependencies [3e9c131]
41
+ - @mastra/core@0.9.4-alpha.4
42
+
43
+ ## 0.0.4-alpha.3
44
+
45
+ ### Patch Changes
46
+
47
+ - c3bd795: [MASTRA-3358] Deprecate updateIndexById and deleteIndexById
48
+ - Updated dependencies [396be50]
49
+ - Updated dependencies [c3bd795]
50
+ - Updated dependencies [da082f8]
51
+ - Updated dependencies [a5810ce]
52
+ - @mastra/core@0.9.4-alpha.3
53
+
54
+ ## 0.0.4-alpha.2
55
+
56
+ ### Patch Changes
57
+
58
+ - Updated dependencies [3171b5b]
59
+ - Updated dependencies [973e5ac]
60
+ - Updated dependencies [9e1eff5]
61
+ - @mastra/core@0.9.4-alpha.2
62
+
63
+ ## 0.0.4-alpha.1
64
+
65
+ ### Patch Changes
66
+
67
+ - Updated dependencies [ab80e7e]
68
+ - Updated dependencies [6fa1ad1]
69
+ - Updated dependencies [c28d7a0]
70
+ - Updated dependencies [edf1e88]
71
+ - @mastra/core@0.9.4-alpha.1
72
+
73
+ ## 0.0.4-alpha.0
74
+
75
+ ### Patch Changes
76
+
77
+ - Updated dependencies [daf942f]
78
+ - Updated dependencies [0b8b868]
79
+ - @mastra/core@0.9.4-alpha.0
80
+
81
+ ## 0.0.3
4
82
 
5
83
  ### Patch Changes
6
84
 
@@ -9,11 +87,24 @@
9
87
  - Updated dependencies [8902157]
10
88
  - Updated dependencies [ca0dc88]
11
89
  - Updated dependencies [526c570]
90
+ - Updated dependencies [d7a6a33]
12
91
  - Updated dependencies [9cd1a46]
13
92
  - Updated dependencies [b5d2de0]
14
93
  - Updated dependencies [644f8ad]
15
94
  - Updated dependencies [70dbf51]
16
- - @mastra/core@0.0.0-redis-cloud-transporter-20250508203756
95
+ - @mastra/core@0.9.3
96
+
97
+ ## 0.0.3-alpha.1
98
+
99
+ ### Patch Changes
100
+
101
+ - 9cd1a46: [MASTRA-3338] update naming scheme for embedding index based on vector store rules and added duplicate index checks
102
+ - Updated dependencies [e450778]
103
+ - Updated dependencies [8902157]
104
+ - Updated dependencies [ca0dc88]
105
+ - Updated dependencies [9cd1a46]
106
+ - Updated dependencies [70dbf51]
107
+ - @mastra/core@0.9.3-alpha.1
17
108
 
18
109
  ## 0.0.3-alpha.0
19
110
 
@@ -1,9 +1,14 @@
1
1
  import type { Collection } from 'couchbase';
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';
8
+ import type { ParamsToArgs } from '@mastra/core/vector';
5
9
  import type { QueryResult } from '@mastra/core/vector';
6
10
  import type { QueryVectorParams } from '@mastra/core/vector';
11
+ import type { UpdateVectorParams } from '@mastra/core/vector';
7
12
  import type { UpsertVectorParams } from '@mastra/core/vector';
8
13
 
9
14
  declare type CouchbaseMetric = 'cosine' | 'l2_norm' | 'dot_product';
@@ -18,18 +23,60 @@ declare class CouchbaseVector extends MastraVector {
18
23
  private bucket;
19
24
  private scope;
20
25
  private vector_dimension;
21
- constructor(cnn_string: string, username: string, password: string, bucketName: string, scopeName: string, collectionName: string);
26
+ /**
27
+ * @deprecated Passing parameters as positional arguments is deprecated.
28
+ * Use the object parameter instead. This signature will be removed on May 20th, 2025.
29
+ */
30
+ constructor(connectionString: string, username: string, password: string, bucketName: string, scopeName: string, collectionName: string);
31
+ constructor(params: CouchbaseVectorParams);
22
32
  getCollection(): Promise<Collection>;
23
33
  createIndex(params: CreateIndexParams): Promise<void>;
24
34
  upsert(params: UpsertVectorParams): Promise<string[]>;
25
35
  query(params: QueryVectorParams): Promise<QueryResult[]>;
26
36
  listIndexes(): Promise<string[]>;
27
- describeIndex(indexName: string): Promise<IndexStats>;
28
- deleteIndex(indexName: string): Promise<void>;
37
+ /**
38
+ * Retrieves statistics about a vector index.
39
+ *
40
+ * @param params - The parameters for describing an index
41
+ * @param params.indexName - The name of the index to describe
42
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
43
+ */
44
+ describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats>;
45
+ deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
46
+ /**
47
+ * Updates a vector by its ID with the provided vector and/or metadata.
48
+ * @param indexName - The name of the index containing the vector.
49
+ * @param id - The ID of the vector to update.
50
+ * @param update - An object containing the vector and/or metadata to update.
51
+ * @param update.vector - An optional array of numbers representing the new vector.
52
+ * @param update.metadata - An optional record containing the new metadata.
53
+ * @returns A promise that resolves when the update is complete.
54
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
55
+ */
56
+ updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
57
+ /**
58
+ * Deletes a vector by its ID.
59
+ * @param indexName - The name of the index containing the vector.
60
+ * @param id - The ID of the vector to delete.
61
+ * @returns A promise that resolves when the deletion is complete.
62
+ * @throws Will throw an error if the deletion operation fails.
63
+ */
64
+ deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void>;
29
65
  }
30
66
  export { CouchbaseVector }
31
67
  export { CouchbaseVector as CouchbaseVector_alias_1 }
32
68
 
69
+ declare type CouchbaseVectorParams = {
70
+ connectionString: string;
71
+ username: string;
72
+ password: string;
73
+ bucketName: string;
74
+ scopeName: string;
75
+ collectionName: string;
76
+ };
77
+ export { CouchbaseVectorParams }
78
+ export { CouchbaseVectorParams as CouchbaseVectorParams_alias_1 }
79
+
33
80
  declare const DISTANCE_MAPPING: Record<MastraMetric, CouchbaseMetric>;
34
81
  export { DISTANCE_MAPPING }
35
82
  export { DISTANCE_MAPPING as DISTANCE_MAPPING_alias_1 }
@@ -1,9 +1,14 @@
1
1
  import type { Collection } from 'couchbase';
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';
8
+ import type { ParamsToArgs } from '@mastra/core/vector';
5
9
  import type { QueryResult } from '@mastra/core/vector';
6
10
  import type { QueryVectorParams } from '@mastra/core/vector';
11
+ import type { UpdateVectorParams } from '@mastra/core/vector';
7
12
  import type { UpsertVectorParams } from '@mastra/core/vector';
8
13
 
9
14
  declare type CouchbaseMetric = 'cosine' | 'l2_norm' | 'dot_product';
@@ -18,18 +23,60 @@ declare class CouchbaseVector extends MastraVector {
18
23
  private bucket;
19
24
  private scope;
20
25
  private vector_dimension;
21
- constructor(cnn_string: string, username: string, password: string, bucketName: string, scopeName: string, collectionName: string);
26
+ /**
27
+ * @deprecated Passing parameters as positional arguments is deprecated.
28
+ * Use the object parameter instead. This signature will be removed on May 20th, 2025.
29
+ */
30
+ constructor(connectionString: string, username: string, password: string, bucketName: string, scopeName: string, collectionName: string);
31
+ constructor(params: CouchbaseVectorParams);
22
32
  getCollection(): Promise<Collection>;
23
33
  createIndex(params: CreateIndexParams): Promise<void>;
24
34
  upsert(params: UpsertVectorParams): Promise<string[]>;
25
35
  query(params: QueryVectorParams): Promise<QueryResult[]>;
26
36
  listIndexes(): Promise<string[]>;
27
- describeIndex(indexName: string): Promise<IndexStats>;
28
- deleteIndex(indexName: string): Promise<void>;
37
+ /**
38
+ * Retrieves statistics about a vector index.
39
+ *
40
+ * @param params - The parameters for describing an index
41
+ * @param params.indexName - The name of the index to describe
42
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
43
+ */
44
+ describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats>;
45
+ deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
46
+ /**
47
+ * Updates a vector by its ID with the provided vector and/or metadata.
48
+ * @param indexName - The name of the index containing the vector.
49
+ * @param id - The ID of the vector to update.
50
+ * @param update - An object containing the vector and/or metadata to update.
51
+ * @param update.vector - An optional array of numbers representing the new vector.
52
+ * @param update.metadata - An optional record containing the new metadata.
53
+ * @returns A promise that resolves when the update is complete.
54
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
55
+ */
56
+ updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
57
+ /**
58
+ * Deletes a vector by its ID.
59
+ * @param indexName - The name of the index containing the vector.
60
+ * @param id - The ID of the vector to delete.
61
+ * @returns A promise that resolves when the deletion is complete.
62
+ * @throws Will throw an error if the deletion operation fails.
63
+ */
64
+ deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void>;
29
65
  }
30
66
  export { CouchbaseVector }
31
67
  export { CouchbaseVector as CouchbaseVector_alias_1 }
32
68
 
69
+ declare type CouchbaseVectorParams = {
70
+ connectionString: string;
71
+ username: string;
72
+ password: string;
73
+ bucketName: string;
74
+ scopeName: string;
75
+ collectionName: string;
76
+ };
77
+ export { CouchbaseVectorParams }
78
+ export { CouchbaseVectorParams as CouchbaseVectorParams_alias_1 }
79
+
33
80
  declare const DISTANCE_MAPPING: Record<MastraMetric, CouchbaseMetric>;
34
81
  export { DISTANCE_MAPPING }
35
82
  export { DISTANCE_MAPPING as DISTANCE_MAPPING_alias_1 }
package/dist/index.cjs CHANGED
@@ -19,11 +19,32 @@ var CouchbaseVector = class extends vector.MastraVector {
19
19
  bucket;
20
20
  scope;
21
21
  vector_dimension;
22
- constructor(cnn_string, username, password, bucketName, scopeName, collectionName) {
22
+ constructor(paramsOrConnectionString, username, password, bucketName, scopeName, collectionName) {
23
+ let connectionString_, username_, password_, bucketName_, scopeName_, collectionName_;
24
+ if (typeof paramsOrConnectionString === "object" && paramsOrConnectionString !== null && "connectionString" in paramsOrConnectionString) {
25
+ connectionString_ = paramsOrConnectionString.connectionString;
26
+ username_ = paramsOrConnectionString.username;
27
+ password_ = paramsOrConnectionString.password;
28
+ bucketName_ = paramsOrConnectionString.bucketName;
29
+ scopeName_ = paramsOrConnectionString.scopeName;
30
+ collectionName_ = paramsOrConnectionString.collectionName;
31
+ } else {
32
+ if (arguments.length > 1) {
33
+ console.warn(
34
+ "Deprecation Warning: CouchbaseVector constructor positional arguments are deprecated. Please use a single object parameter instead. This signature will be removed on May 20th, 2025."
35
+ );
36
+ }
37
+ connectionString_ = paramsOrConnectionString;
38
+ username_ = username;
39
+ password_ = password;
40
+ bucketName_ = bucketName;
41
+ scopeName_ = scopeName;
42
+ collectionName_ = collectionName;
43
+ }
23
44
  super();
24
- const baseClusterPromise = couchbase.connect(cnn_string, {
25
- username,
26
- password,
45
+ const baseClusterPromise = couchbase.connect(connectionString_, {
46
+ username: username_,
47
+ password: password_,
27
48
  configProfile: "wanDevelopment"
28
49
  });
29
50
  const telemetry = this.__getTelemetry();
@@ -34,9 +55,9 @@ var CouchbaseVector = class extends vector.MastraVector {
34
55
  }
35
56
  }) ?? baseClusterPromise;
36
57
  this.cluster = null;
37
- this.bucketName = bucketName;
38
- this.collectionName = collectionName;
39
- this.scopeName = scopeName;
58
+ this.bucketName = bucketName_;
59
+ this.collectionName = collectionName_;
60
+ this.scopeName = scopeName_;
40
61
  this.collection = null;
41
62
  this.bucket = null;
42
63
  this.scope = null;
@@ -221,7 +242,16 @@ var CouchbaseVector = class extends vector.MastraVector {
221
242
  const indexes = await this.scope.searchIndexes().getAllIndexes();
222
243
  return indexes?.map((index) => index.name) || [];
223
244
  }
224
- async describeIndex(indexName) {
245
+ /**
246
+ * Retrieves statistics about a vector index.
247
+ *
248
+ * @param params - The parameters for describing an index
249
+ * @param params.indexName - The name of the index to describe
250
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
251
+ */
252
+ async describeIndex(...args) {
253
+ const params = this.normalizeArgs("describeIndex", args);
254
+ const { indexName } = params;
225
255
  await this.getCollection();
226
256
  if (!(await this.listIndexes()).includes(indexName)) {
227
257
  throw new Error(`Index ${indexName} does not exist`);
@@ -238,7 +268,9 @@ var CouchbaseVector = class extends vector.MastraVector {
238
268
  )
239
269
  };
240
270
  }
241
- async deleteIndex(indexName) {
271
+ async deleteIndex(...args) {
272
+ const params = this.normalizeArgs("deleteIndex", args);
273
+ const { indexName } = params;
242
274
  await this.getCollection();
243
275
  if (!(await this.listIndexes()).includes(indexName)) {
244
276
  throw new Error(`Index ${indexName} does not exist`);
@@ -246,6 +278,60 @@ var CouchbaseVector = class extends vector.MastraVector {
246
278
  await this.scope.searchIndexes().dropIndex(indexName);
247
279
  this.vector_dimension = null;
248
280
  }
281
+ /**
282
+ * Updates a vector by its ID with the provided vector and/or metadata.
283
+ * @param indexName - The name of the index containing the vector.
284
+ * @param id - The ID of the vector to update.
285
+ * @param update - An object containing the vector and/or metadata to update.
286
+ * @param update.vector - An optional array of numbers representing the new vector.
287
+ * @param update.metadata - An optional record containing the new metadata.
288
+ * @returns A promise that resolves when the update is complete.
289
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
290
+ */
291
+ async updateVector(...args) {
292
+ const params = this.normalizeArgs("updateVector", args);
293
+ const { id, update } = params;
294
+ if (!update.vector && !update.metadata) {
295
+ throw new Error("No updates provided");
296
+ }
297
+ if (update.vector && this.vector_dimension && update.vector.length !== this.vector_dimension) {
298
+ throw new Error("Vector dimension mismatch");
299
+ }
300
+ const collection = await this.getCollection();
301
+ try {
302
+ await collection.get(id);
303
+ } catch (err) {
304
+ if (err.code === 13 || err.message?.includes("document not found")) {
305
+ throw new Error(`Vector with id ${id} does not exist`);
306
+ }
307
+ throw err;
308
+ }
309
+ const specs = [];
310
+ if (update.vector) specs.push(couchbase.MutateInSpec.replace("embedding", update.vector));
311
+ if (update.metadata) specs.push(couchbase.MutateInSpec.replace("metadata", update.metadata));
312
+ await collection.mutateIn(id, specs);
313
+ }
314
+ /**
315
+ * Deletes a vector by its ID.
316
+ * @param indexName - The name of the index containing the vector.
317
+ * @param id - The ID of the vector to delete.
318
+ * @returns A promise that resolves when the deletion is complete.
319
+ * @throws Will throw an error if the deletion operation fails.
320
+ */
321
+ async deleteVector(...args) {
322
+ const params = this.normalizeArgs("deleteVector", args);
323
+ const { id } = params;
324
+ const collection = await this.getCollection();
325
+ try {
326
+ await collection.get(id);
327
+ } catch (err) {
328
+ if (err.code === 13 || err.message?.includes("document not found")) {
329
+ throw new Error(`Vector with id ${id} does not exist`);
330
+ }
331
+ throw err;
332
+ }
333
+ await collection.remove(id);
334
+ }
249
335
  };
250
336
 
251
337
  exports.CouchbaseVector = CouchbaseVector;
package/dist/index.d.cts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { DISTANCE_MAPPING } from './_tsup-dts-rollup.cjs';
2
+ export { CouchbaseVectorParams } from './_tsup-dts-rollup.cjs';
2
3
  export { CouchbaseVector } from './_tsup-dts-rollup.cjs';
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { DISTANCE_MAPPING } from './_tsup-dts-rollup.js';
2
+ export { CouchbaseVectorParams } from './_tsup-dts-rollup.js';
2
3
  export { CouchbaseVector } from './_tsup-dts-rollup.js';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { MastraVector } from '@mastra/core/vector';
2
- import { connect, SearchRequest, VectorSearch, VectorQuery } from 'couchbase';
2
+ import { connect, SearchRequest, VectorSearch, VectorQuery, MutateInSpec } from 'couchbase';
3
3
 
4
4
  // src/vector/index.ts
5
5
  var DISTANCE_MAPPING = {
@@ -17,11 +17,32 @@ var CouchbaseVector = class extends MastraVector {
17
17
  bucket;
18
18
  scope;
19
19
  vector_dimension;
20
- constructor(cnn_string, username, password, bucketName, scopeName, collectionName) {
20
+ constructor(paramsOrConnectionString, username, password, bucketName, scopeName, collectionName) {
21
+ let connectionString_, username_, password_, bucketName_, scopeName_, collectionName_;
22
+ if (typeof paramsOrConnectionString === "object" && paramsOrConnectionString !== null && "connectionString" in paramsOrConnectionString) {
23
+ connectionString_ = paramsOrConnectionString.connectionString;
24
+ username_ = paramsOrConnectionString.username;
25
+ password_ = paramsOrConnectionString.password;
26
+ bucketName_ = paramsOrConnectionString.bucketName;
27
+ scopeName_ = paramsOrConnectionString.scopeName;
28
+ collectionName_ = paramsOrConnectionString.collectionName;
29
+ } else {
30
+ if (arguments.length > 1) {
31
+ console.warn(
32
+ "Deprecation Warning: CouchbaseVector constructor positional arguments are deprecated. Please use a single object parameter instead. This signature will be removed on May 20th, 2025."
33
+ );
34
+ }
35
+ connectionString_ = paramsOrConnectionString;
36
+ username_ = username;
37
+ password_ = password;
38
+ bucketName_ = bucketName;
39
+ scopeName_ = scopeName;
40
+ collectionName_ = collectionName;
41
+ }
21
42
  super();
22
- const baseClusterPromise = connect(cnn_string, {
23
- username,
24
- password,
43
+ const baseClusterPromise = connect(connectionString_, {
44
+ username: username_,
45
+ password: password_,
25
46
  configProfile: "wanDevelopment"
26
47
  });
27
48
  const telemetry = this.__getTelemetry();
@@ -32,9 +53,9 @@ var CouchbaseVector = class extends MastraVector {
32
53
  }
33
54
  }) ?? baseClusterPromise;
34
55
  this.cluster = null;
35
- this.bucketName = bucketName;
36
- this.collectionName = collectionName;
37
- this.scopeName = scopeName;
56
+ this.bucketName = bucketName_;
57
+ this.collectionName = collectionName_;
58
+ this.scopeName = scopeName_;
38
59
  this.collection = null;
39
60
  this.bucket = null;
40
61
  this.scope = null;
@@ -219,7 +240,16 @@ var CouchbaseVector = class extends MastraVector {
219
240
  const indexes = await this.scope.searchIndexes().getAllIndexes();
220
241
  return indexes?.map((index) => index.name) || [];
221
242
  }
222
- async describeIndex(indexName) {
243
+ /**
244
+ * Retrieves statistics about a vector index.
245
+ *
246
+ * @param params - The parameters for describing an index
247
+ * @param params.indexName - The name of the index to describe
248
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
249
+ */
250
+ async describeIndex(...args) {
251
+ const params = this.normalizeArgs("describeIndex", args);
252
+ const { indexName } = params;
223
253
  await this.getCollection();
224
254
  if (!(await this.listIndexes()).includes(indexName)) {
225
255
  throw new Error(`Index ${indexName} does not exist`);
@@ -236,7 +266,9 @@ var CouchbaseVector = class extends MastraVector {
236
266
  )
237
267
  };
238
268
  }
239
- async deleteIndex(indexName) {
269
+ async deleteIndex(...args) {
270
+ const params = this.normalizeArgs("deleteIndex", args);
271
+ const { indexName } = params;
240
272
  await this.getCollection();
241
273
  if (!(await this.listIndexes()).includes(indexName)) {
242
274
  throw new Error(`Index ${indexName} does not exist`);
@@ -244,6 +276,60 @@ var CouchbaseVector = class extends MastraVector {
244
276
  await this.scope.searchIndexes().dropIndex(indexName);
245
277
  this.vector_dimension = null;
246
278
  }
279
+ /**
280
+ * Updates a vector by its ID with the provided vector and/or metadata.
281
+ * @param indexName - The name of the index containing the vector.
282
+ * @param id - The ID of the vector to update.
283
+ * @param update - An object containing the vector and/or metadata to update.
284
+ * @param update.vector - An optional array of numbers representing the new vector.
285
+ * @param update.metadata - An optional record containing the new metadata.
286
+ * @returns A promise that resolves when the update is complete.
287
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
288
+ */
289
+ async updateVector(...args) {
290
+ const params = this.normalizeArgs("updateVector", args);
291
+ const { id, update } = params;
292
+ if (!update.vector && !update.metadata) {
293
+ throw new Error("No updates provided");
294
+ }
295
+ if (update.vector && this.vector_dimension && update.vector.length !== this.vector_dimension) {
296
+ throw new Error("Vector dimension mismatch");
297
+ }
298
+ const collection = await this.getCollection();
299
+ try {
300
+ await collection.get(id);
301
+ } catch (err) {
302
+ if (err.code === 13 || err.message?.includes("document not found")) {
303
+ throw new Error(`Vector with id ${id} does not exist`);
304
+ }
305
+ throw err;
306
+ }
307
+ const specs = [];
308
+ if (update.vector) specs.push(MutateInSpec.replace("embedding", update.vector));
309
+ if (update.metadata) specs.push(MutateInSpec.replace("metadata", update.metadata));
310
+ await collection.mutateIn(id, specs);
311
+ }
312
+ /**
313
+ * Deletes a vector by its ID.
314
+ * @param indexName - The name of the index containing the vector.
315
+ * @param id - The ID of the vector to delete.
316
+ * @returns A promise that resolves when the deletion is complete.
317
+ * @throws Will throw an error if the deletion operation fails.
318
+ */
319
+ async deleteVector(...args) {
320
+ const params = this.normalizeArgs("deleteVector", args);
321
+ const { id } = params;
322
+ const collection = await this.getCollection();
323
+ try {
324
+ await collection.get(id);
325
+ } catch (err) {
326
+ if (err.code === 13 || err.message?.includes("document not found")) {
327
+ throw new Error(`Vector with id ${id} does not exist`);
328
+ }
329
+ throw err;
330
+ }
331
+ await collection.remove(id);
332
+ }
247
333
  };
248
334
 
249
335
  export { CouchbaseVector, DISTANCE_MAPPING };
@@ -2,20 +2,20 @@ services:
2
2
  mastra_couchbase_testing:
3
3
  image: couchbase:enterprise-7.6.4
4
4
  ports:
5
- - "8091-8095:8091-8095"
6
- - "11210:11210"
7
- - "9102:9102"
5
+ - '8091-8095:8091-8095'
6
+ - '11210:11210'
7
+ - '9102:9102'
8
8
  expose:
9
- - "8091"
10
- - "8092"
11
- - "8093"
12
- - "8094"
13
- - "8095"
14
- - "9102"
15
- - "11210"
9
+ - '8091'
10
+ - '8092'
11
+ - '8093'
12
+ - '8094'
13
+ - '8095'
14
+ - '9102'
15
+ - '11210'
16
16
  healthcheck: # checks couchbase server is up
17
- test: ["CMD", "curl", "-v", "http://localhost:8091/pools"]
17
+ test: ['CMD', 'curl', '-v', 'http://localhost:8091/pools']
18
18
  interval: 20s
19
19
  timeout: 20s
20
20
  retries: 5
21
- container_name: mastra_couchbase_testing
21
+ container_name: mastra_couchbase_testing
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/couchbase",
3
- "version": "0.0.0-redis-cloud-transporter-20250508203756",
3
+ "version": "0.0.0-vector-query-sources-20250516172905",
4
4
  "description": "Couchbase vector store provider for Mastra",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "couchbase": "^4.4.5",
23
- "@mastra/core": "0.0.0-redis-cloud-transporter-20250508203756"
23
+ "@mastra/core": "0.0.0-vector-query-sources-20250516172905"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@microsoft/api-extractor": "^7.52.1",
@@ -32,7 +32,7 @@
32
32
  "tsup": "^8.4.0",
33
33
  "typescript": "^5.8.2",
34
34
  "vitest": "^3.0.9",
35
- "@internal/lint": "0.0.0-redis-cloud-transporter-20250508203756"
35
+ "@internal/lint": "0.0.0-vector-query-sources-20250516172905"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
@@ -173,14 +173,14 @@ describe('Integration Testing CouchbaseVector', async () => {
173
173
 
174
174
  describe('Connection', () => {
175
175
  it('should connect to couchbase', async () => {
176
- couchbase_client = new CouchbaseVector(
176
+ couchbase_client = new CouchbaseVector({
177
177
  connectionString,
178
178
  username,
179
179
  password,
180
- test_bucketName,
181
- test_scopeName,
182
- test_collectionName,
183
- );
180
+ bucketName: test_bucketName,
181
+ scopeName: test_scopeName,
182
+ collectionName: test_collectionName,
183
+ });
184
184
  expect(couchbase_client).toBeDefined();
185
185
  const collection = await couchbase_client.getCollection();
186
186
  expect(collection).toBeDefined();
@@ -211,14 +211,14 @@ describe('Integration Testing CouchbaseVector', async () => {
211
211
  }, 50000);
212
212
 
213
213
  it('should describe index', async () => {
214
- const stats = await couchbase_client.describeIndex(test_indexName);
214
+ const stats = await couchbase_client.describeIndex({ indexName: test_indexName });
215
215
  expect(stats.dimension).toBe(dimension);
216
216
  expect(stats.metric).toBe('euclidean'); // similiarity(=="l2_norm") is mapped to euclidean in couchbase
217
217
  expect(typeof stats.count).toBe('number');
218
218
  }, 50000);
219
219
 
220
220
  it('should delete index', async () => {
221
- await couchbase_client.deleteIndex(test_indexName);
221
+ await couchbase_client.deleteIndex({ indexName: test_indexName });
222
222
  await new Promise(resolve => setTimeout(resolve, 5000));
223
223
  await expect(scope.searchIndexes().getIndex(test_indexName)).rejects.toThrowError();
224
224
  }, 50000);
@@ -246,7 +246,7 @@ describe('Integration Testing CouchbaseVector', async () => {
246
246
  }, 50000);
247
247
 
248
248
  afterAll(async () => {
249
- await couchbase_client.deleteIndex(test_indexName);
249
+ await couchbase_client.deleteIndex({ indexName: test_indexName });
250
250
  await new Promise(resolve => setTimeout(resolve, 5000));
251
251
  }, 50000);
252
252
 
@@ -380,6 +380,120 @@ describe('Integration Testing CouchbaseVector', async () => {
380
380
  }),
381
381
  ).rejects.toThrow('Including vectors in search results is not yet supported by the Couchbase vector store');
382
382
  }, 50000);
383
+
384
+ it('should upsert vectors with generated ids', async () => {
385
+ const ids = await couchbase_client.upsert({ indexName: test_indexName, vectors: testVectors });
386
+ expect(ids).toHaveLength(testVectors.length);
387
+ ids.forEach(id => expect(typeof id).toBe('string'));
388
+
389
+ // Count is not supported by Couchbase
390
+ const stats = await couchbase_client.describeIndex({ indexName: test_indexName });
391
+ expect(stats.count).toBe(-1);
392
+ });
393
+
394
+ it('should update existing vectors', async () => {
395
+ // Initial upsert
396
+ await couchbase_client.upsert({
397
+ indexName: test_indexName,
398
+ vectors: testVectors,
399
+ metadata: testMetadata,
400
+ ids: testVectorIds,
401
+ });
402
+
403
+ // Update first vector
404
+ const updatedVector = [[0.5, 0.5, 0.0]];
405
+ const updatedMetadata = [{ label: 'updated-x-axis' }];
406
+ await couchbase_client.upsert({
407
+ indexName: test_indexName,
408
+ vectors: updatedVector,
409
+ metadata: updatedMetadata,
410
+ ids: [testVectorIds?.[0]!],
411
+ });
412
+
413
+ // Verify update
414
+ const result = await collection.get(testVectorIds?.[0]!);
415
+ expect(result.content.embedding).toEqual(updatedVector[0]);
416
+ expect(result.content.metadata).toEqual(updatedMetadata[0]);
417
+ });
418
+
419
+ it('should update the vector by id', async () => {
420
+ const ids = await couchbase_client.upsert({ indexName: test_indexName, vectors: testVectors });
421
+ expect(ids).toHaveLength(3);
422
+
423
+ const idToBeUpdated = ids[0];
424
+ const newVector = [1, 2, 3];
425
+ const newMetaData = {
426
+ test: 'updates',
427
+ };
428
+
429
+ const update = {
430
+ vector: newVector,
431
+ metadata: newMetaData,
432
+ };
433
+
434
+ await couchbase_client.updateVector({ indexName: test_indexName, id: idToBeUpdated, update });
435
+
436
+ const result = await collection.get(idToBeUpdated);
437
+ expect(result.content.embedding).toEqual(newVector);
438
+ expect(result.content.metadata).toEqual(newMetaData);
439
+ });
440
+
441
+ it('should only update the metadata by id', async () => {
442
+ const ids = await couchbase_client.upsert({ indexName: test_indexName, vectors: testVectors });
443
+ expect(ids).toHaveLength(3);
444
+
445
+ const idToBeUpdated = ids[0];
446
+ const newMetaData = {
447
+ test: 'updates',
448
+ };
449
+
450
+ const update = {
451
+ metadata: newMetaData,
452
+ };
453
+
454
+ await couchbase_client.updateVector({ indexName: test_indexName, id: idToBeUpdated, update });
455
+
456
+ const result = await collection.get(idToBeUpdated);
457
+ expect(result.content.embedding).toEqual(testVectors[0]);
458
+ expect(result.content.metadata).toEqual(newMetaData);
459
+ });
460
+
461
+ it('should only update vector embeddings by id', async () => {
462
+ const ids = await couchbase_client.upsert({ indexName: test_indexName, vectors: testVectors });
463
+ expect(ids).toHaveLength(3);
464
+
465
+ const idToBeUpdated = ids[0];
466
+ const newVector = [1, 2, 3];
467
+
468
+ const update = {
469
+ vector: newVector,
470
+ };
471
+
472
+ await couchbase_client.updateVector({ indexName: test_indexName, id: idToBeUpdated, update });
473
+
474
+ const result = await collection.get(idToBeUpdated);
475
+ expect(result.content.embedding).toEqual(newVector);
476
+ });
477
+
478
+ it('should throw exception when no updates are given', async () => {
479
+ await expect(couchbase_client.updateVector({ indexName: test_indexName, id: 'id', update: {} })).rejects.toThrow(
480
+ 'No updates provided',
481
+ );
482
+ });
483
+
484
+ it('should delete the vector by id', async () => {
485
+ const ids = await couchbase_client.upsert({ indexName: test_indexName, vectors: testVectors });
486
+ expect(ids).toHaveLength(3);
487
+ const idToBeDeleted = ids[0];
488
+
489
+ await couchbase_client.deleteVector({ indexName: test_indexName, id: idToBeDeleted });
490
+
491
+ try {
492
+ await collection.get(idToBeDeleted);
493
+ } catch (error) {
494
+ expect(error).toBeInstanceOf(Error);
495
+ }
496
+ });
383
497
  });
384
498
 
385
499
  describe('Error Cases and Edge Cases', () => {
@@ -409,7 +523,7 @@ describe('Integration Testing CouchbaseVector', async () => {
409
523
  expect(allIndexes.find(idx => idx.name === nonExistentIndex)).toBeUndefined();
410
524
 
411
525
  // Now test the couchbase_client method
412
- await expect(couchbase_client.describeIndex(nonExistentIndex)).rejects.toThrow();
526
+ await expect(couchbase_client.describeIndex({ indexName: nonExistentIndex })).rejects.toThrow();
413
527
  }, 50000);
414
528
 
415
529
  it('should throw error when deleting a non-existent index', async () => {
@@ -420,7 +534,7 @@ describe('Integration Testing CouchbaseVector', async () => {
420
534
  expect(allIndexes.find(idx => idx.name === nonExistentIndex)).toBeUndefined();
421
535
 
422
536
  // Now test the couchbase_client method
423
- await expect(couchbase_client.deleteIndex(nonExistentIndex)).rejects.toThrow();
537
+ await expect(couchbase_client.deleteIndex({ indexName: nonExistentIndex })).rejects.toThrow();
424
538
  }, 50000);
425
539
 
426
540
  it('should throw error for empty vectors array in upsert', async () => {
@@ -489,7 +603,7 @@ describe('Integration Testing CouchbaseVector', async () => {
489
603
  infoSpy.mockRestore();
490
604
  warnSpy.mockRestore();
491
605
  // Cleanup
492
- await couchbase_client.deleteIndex(duplicateIndexName);
606
+ await couchbase_client.deleteIndex({ indexName: duplicateIndexName });
493
607
  }
494
608
  }, 50000);
495
609
  });
@@ -499,7 +613,7 @@ describe('Integration Testing CouchbaseVector', async () => {
499
613
  const indexes = await couchbase_client.listIndexes();
500
614
  if (indexes.length > 0) {
501
615
  for (const index of indexes) {
502
- await couchbase_client.deleteIndex(index);
616
+ await couchbase_client.deleteIndex({ indexName: index });
503
617
  await new Promise(resolve => setTimeout(resolve, 5000));
504
618
  }
505
619
  }
@@ -562,7 +676,7 @@ describe('Integration Testing CouchbaseVector', async () => {
562
676
  expect((couchbase_client as any).vector_dimension).toBe(testDimension);
563
677
 
564
678
  // Delete the index
565
- await couchbase_client.deleteIndex(testIndexName);
679
+ await couchbase_client.deleteIndex({ indexName: testIndexName });
566
680
  await new Promise(resolve => setTimeout(resolve, 5000));
567
681
 
568
682
  // Verify dimension is reset
@@ -578,7 +692,7 @@ describe('Integration Testing CouchbaseVector', async () => {
578
692
  const indexes = await couchbase_client.listIndexes();
579
693
  if (indexes.length > 0) {
580
694
  for (const index of indexes) {
581
- await couchbase_client.deleteIndex(index);
695
+ await couchbase_client.deleteIndex({ indexName: index });
582
696
  await new Promise(resolve => setTimeout(resolve, 5000));
583
697
  }
584
698
  }
@@ -607,11 +721,11 @@ describe('Integration Testing CouchbaseVector', async () => {
607
721
  expect(similarityParam).toBe(couchbaseMetric);
608
722
 
609
723
  // Verify through our API
610
- const stats = await couchbase_client.describeIndex(testIndexName);
724
+ const stats = await couchbase_client.describeIndex({ indexName: testIndexName });
611
725
  expect(stats.metric).toBe(mastraMetric);
612
726
 
613
727
  // Clean up
614
- await couchbase_client.deleteIndex(testIndexName);
728
+ await couchbase_client.deleteIndex({ indexName: testIndexName });
615
729
  await new Promise(resolve => setTimeout(resolve, 5000));
616
730
  }
617
731
  }, 50000);
@@ -5,9 +5,14 @@ import type {
5
5
  CreateIndexParams,
6
6
  UpsertVectorParams,
7
7
  QueryVectorParams,
8
+ DescribeIndexParams,
9
+ ParamsToArgs,
10
+ DeleteIndexParams,
11
+ DeleteVectorParams,
12
+ UpdateVectorParams,
8
13
  } from '@mastra/core/vector';
9
14
  import type { Bucket, Cluster, Collection, Scope } from 'couchbase';
10
- import { connect, SearchRequest, VectorQuery, VectorSearch } from 'couchbase';
15
+ import { MutateInSpec, connect, SearchRequest, VectorQuery, VectorSearch } from 'couchbase';
11
16
 
12
17
  type MastraMetric = 'cosine' | 'euclidean' | 'dotproduct';
13
18
  type CouchbaseMetric = 'cosine' | 'l2_norm' | 'dot_product';
@@ -17,6 +22,15 @@ export const DISTANCE_MAPPING: Record<MastraMetric, CouchbaseMetric> = {
17
22
  dotproduct: 'dot_product',
18
23
  };
19
24
 
25
+ export type CouchbaseVectorParams = {
26
+ connectionString: string;
27
+ username: string;
28
+ password: string;
29
+ bucketName: string;
30
+ scopeName: string;
31
+ collectionName: string;
32
+ };
33
+
20
34
  export class CouchbaseVector extends MastraVector {
21
35
  private clusterPromise: Promise<Cluster>;
22
36
  private cluster: Cluster;
@@ -28,19 +42,66 @@ export class CouchbaseVector extends MastraVector {
28
42
  private scope: Scope;
29
43
  private vector_dimension: number;
30
44
 
45
+ /**
46
+ * @deprecated Passing parameters as positional arguments is deprecated.
47
+ * Use the object parameter instead. This signature will be removed on May 20th, 2025.
48
+ */
31
49
  constructor(
32
- cnn_string: string,
50
+ connectionString: string,
33
51
  username: string,
34
52
  password: string,
35
53
  bucketName: string,
36
54
  scopeName: string,
37
55
  collectionName: string,
56
+ );
57
+ constructor(params: CouchbaseVectorParams);
58
+ constructor(
59
+ paramsOrConnectionString: CouchbaseVectorParams | string,
60
+ username?: string,
61
+ password?: string,
62
+ bucketName?: string,
63
+ scopeName?: string,
64
+ collectionName?: string,
38
65
  ) {
66
+ let connectionString_: string,
67
+ username_: string,
68
+ password_: string,
69
+ bucketName_: string,
70
+ scopeName_: string,
71
+ collectionName_: string;
72
+
73
+ if (
74
+ typeof paramsOrConnectionString === 'object' &&
75
+ paramsOrConnectionString !== null &&
76
+ 'connectionString' in paramsOrConnectionString
77
+ ) {
78
+ // Object params (preferred)
79
+ connectionString_ = paramsOrConnectionString.connectionString as string;
80
+ username_ = paramsOrConnectionString.username;
81
+ password_ = paramsOrConnectionString.password;
82
+ bucketName_ = paramsOrConnectionString.bucketName;
83
+ scopeName_ = paramsOrConnectionString.scopeName;
84
+ collectionName_ = paramsOrConnectionString.collectionName;
85
+ } else {
86
+ // Positional args (deprecated)
87
+ if (arguments.length > 1) {
88
+ console.warn(
89
+ 'Deprecation Warning: CouchbaseVector constructor positional arguments are deprecated. Please use a single object parameter instead. This signature will be removed on May 20th, 2025.',
90
+ );
91
+ }
92
+ connectionString_ = paramsOrConnectionString as string;
93
+ username_ = username!;
94
+ password_ = password!;
95
+ bucketName_ = bucketName!;
96
+ scopeName_ = scopeName!;
97
+ collectionName_ = collectionName!;
98
+ }
99
+
39
100
  super();
40
101
 
41
- const baseClusterPromise = connect(cnn_string, {
42
- username,
43
- password,
102
+ const baseClusterPromise = connect(connectionString_, {
103
+ username: username_,
104
+ password: password_,
44
105
  configProfile: 'wanDevelopment',
45
106
  });
46
107
 
@@ -53,9 +114,9 @@ export class CouchbaseVector extends MastraVector {
53
114
  },
54
115
  }) ?? baseClusterPromise;
55
116
  this.cluster = null as unknown as Cluster;
56
- this.bucketName = bucketName;
57
- this.collectionName = collectionName;
58
- this.scopeName = scopeName;
117
+ this.bucketName = bucketName_;
118
+ this.collectionName = collectionName_;
119
+ this.scopeName = scopeName_;
59
120
  this.collection = null as unknown as Collection;
60
121
  this.bucket = null as unknown as Bucket;
61
122
  this.scope = null as unknown as Scope;
@@ -255,7 +316,16 @@ export class CouchbaseVector extends MastraVector {
255
316
  return indexes?.map(index => index.name) || [];
256
317
  }
257
318
 
258
- async describeIndex(indexName: string): Promise<IndexStats> {
319
+ /**
320
+ * Retrieves statistics about a vector index.
321
+ *
322
+ * @param params - The parameters for describing an index
323
+ * @param params.indexName - The name of the index to describe
324
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
325
+ */
326
+ async describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats> {
327
+ const params = this.normalizeArgs<DescribeIndexParams>('describeIndex', args);
328
+ const { indexName } = params;
259
329
  await this.getCollection();
260
330
  if (!(await this.listIndexes()).includes(indexName)) {
261
331
  throw new Error(`Index ${indexName} does not exist`);
@@ -276,7 +346,9 @@ export class CouchbaseVector extends MastraVector {
276
346
  };
277
347
  }
278
348
 
279
- async deleteIndex(indexName: string): Promise<void> {
349
+ async deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void> {
350
+ const params = this.normalizeArgs<DeleteIndexParams>('deleteIndex', args);
351
+ const { indexName } = params;
280
352
  await this.getCollection();
281
353
  if (!(await this.listIndexes()).includes(indexName)) {
282
354
  throw new Error(`Index ${indexName} does not exist`);
@@ -284,4 +356,68 @@ export class CouchbaseVector extends MastraVector {
284
356
  await this.scope.searchIndexes().dropIndex(indexName);
285
357
  this.vector_dimension = null as unknown as number;
286
358
  }
359
+
360
+ /**
361
+ * Updates a vector by its ID with the provided vector and/or metadata.
362
+ * @param indexName - The name of the index containing the vector.
363
+ * @param id - The ID of the vector to update.
364
+ * @param update - An object containing the vector and/or metadata to update.
365
+ * @param update.vector - An optional array of numbers representing the new vector.
366
+ * @param update.metadata - An optional record containing the new metadata.
367
+ * @returns A promise that resolves when the update is complete.
368
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
369
+ */
370
+ async updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void> {
371
+ const params = this.normalizeArgs<UpdateVectorParams>('updateVector', args);
372
+ const { id, update } = params;
373
+ if (!update.vector && !update.metadata) {
374
+ throw new Error('No updates provided');
375
+ }
376
+ if (update.vector && this.vector_dimension && update.vector.length !== this.vector_dimension) {
377
+ throw new Error('Vector dimension mismatch');
378
+ }
379
+ const collection = await this.getCollection();
380
+
381
+ // Check if document exists
382
+ try {
383
+ await collection.get(id);
384
+ } catch (err: any) {
385
+ if (err.code === 13 || err.message?.includes('document not found')) {
386
+ throw new Error(`Vector with id ${id} does not exist`);
387
+ }
388
+ throw err;
389
+ }
390
+
391
+ const specs: MutateInSpec[] = [];
392
+ if (update.vector) specs.push(MutateInSpec.replace('embedding', update.vector));
393
+ if (update.metadata) specs.push(MutateInSpec.replace('metadata', update.metadata));
394
+
395
+ await collection.mutateIn(id, specs);
396
+ }
397
+
398
+ /**
399
+ * Deletes a vector by its ID.
400
+ * @param indexName - The name of the index containing the vector.
401
+ * @param id - The ID of the vector to delete.
402
+ * @returns A promise that resolves when the deletion is complete.
403
+ * @throws Will throw an error if the deletion operation fails.
404
+ */
405
+ async deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void> {
406
+ const params = this.normalizeArgs<DeleteVectorParams>('deleteVector', args);
407
+
408
+ const { id } = params;
409
+ const collection = await this.getCollection();
410
+
411
+ // Check if document exists
412
+ try {
413
+ await collection.get(id);
414
+ } catch (err: any) {
415
+ if (err.code === 13 || err.message?.includes('document not found')) {
416
+ throw new Error(`Vector with id ${id} does not exist`);
417
+ }
418
+ throw err;
419
+ }
420
+
421
+ await collection.remove(id);
422
+ }
287
423
  }
@@ -165,14 +165,14 @@ describe('Unit Testing CouchbaseVector', () => {
165
165
  });
166
166
 
167
167
  it('should connect to couchbase', async () => {
168
- couchbase_client = new CouchbaseVector(
169
- 'COUCHBASE_CONNECTION_STRING',
170
- 'COUCHBASE_USERNAME',
171
- 'COUCHBASE_PASSWORD',
172
- test_bucketName,
173
- test_scopeName,
174
- test_collectionName,
175
- );
168
+ couchbase_client = new CouchbaseVector({
169
+ connectionString: 'COUCHBASE_CONNECTION_STRING',
170
+ username: 'COUCHBASE_USERNAME',
171
+ password: 'COUCHBASE_PASSWORD',
172
+ bucketName: test_bucketName,
173
+ scopeName: test_scopeName,
174
+ collectionName: test_collectionName,
175
+ });
176
176
  expect(mockCouchbaseConnectFn).toHaveBeenCalledTimes(1);
177
177
  expect(mockCouchbaseConnectFn).toHaveBeenCalledWith('COUCHBASE_CONNECTION_STRING', {
178
178
  username: 'COUCHBASE_USERNAME',
@@ -200,14 +200,14 @@ describe('Unit Testing CouchbaseVector', () => {
200
200
  describe('Index Operations', () => {
201
201
  beforeAll(async () => {
202
202
  clearAllMocks();
203
- couchbase_client = new CouchbaseVector(
204
- 'COUCHBASE_CONNECTION_STRING',
205
- 'COUCHBASE_USERNAME',
206
- 'COUCHBASE_PASSWORD',
207
- test_bucketName,
208
- test_scopeName,
209
- test_collectionName,
210
- );
203
+ couchbase_client = new CouchbaseVector({
204
+ connectionString: 'COUCHBASE_CONNECTION_STRING',
205
+ username: 'COUCHBASE_USERNAME',
206
+ password: 'COUCHBASE_PASSWORD',
207
+ bucketName: test_bucketName,
208
+ scopeName: test_scopeName,
209
+ collectionName: test_collectionName,
210
+ });
211
211
  await couchbase_client.getCollection();
212
212
  });
213
213
 
@@ -311,7 +311,7 @@ describe('Unit Testing CouchbaseVector', () => {
311
311
  }, 50000);
312
312
 
313
313
  it('should describe index', async () => {
314
- const stats = await couchbase_client.describeIndex(test_indexName);
314
+ const stats = await couchbase_client.describeIndex({ indexName: test_indexName });
315
315
 
316
316
  expect(mockScopeSearchIndexesFn).toHaveBeenCalledTimes(2);
317
317
 
@@ -328,7 +328,7 @@ describe('Unit Testing CouchbaseVector', () => {
328
328
  }, 50000);
329
329
 
330
330
  it('should delete index', async () => {
331
- await couchbase_client.deleteIndex(test_indexName);
331
+ await couchbase_client.deleteIndex({ indexName: test_indexName });
332
332
 
333
333
  expect(mockScopeSearchIndexesFn).toHaveBeenCalledTimes(2);
334
334
 
@@ -343,14 +343,14 @@ describe('Unit Testing CouchbaseVector', () => {
343
343
 
344
344
  describe('Vector Operations', () => {
345
345
  beforeAll(async () => {
346
- couchbase_client = new CouchbaseVector(
347
- 'COUCHBASE_CONNECTION_STRING',
348
- 'COUCHBASE_USERNAME',
349
- 'COUCHBASE_PASSWORD',
350
- test_bucketName,
351
- test_scopeName,
352
- test_collectionName,
353
- );
346
+ couchbase_client = new CouchbaseVector({
347
+ connectionString: 'COUCHBASE_CONNECTION_STRING',
348
+ username: 'COUCHBASE_USERNAME',
349
+ password: 'COUCHBASE_PASSWORD',
350
+ bucketName: test_bucketName,
351
+ scopeName: test_scopeName,
352
+ collectionName: test_collectionName,
353
+ });
354
354
 
355
355
  await couchbase_client.getCollection();
356
356
  });
@@ -510,14 +510,14 @@ describe('Unit Testing CouchbaseVector', () => {
510
510
  describe('Error Cases and Edge Cases', () => {
511
511
  beforeAll(async () => {
512
512
  clearAllMocks();
513
- couchbase_client = new CouchbaseVector(
514
- 'COUCHBASE_CONNECTION_STRING',
515
- 'COUCHBASE_USERNAME',
516
- 'COUCHBASE_PASSWORD',
517
- test_bucketName,
518
- test_scopeName,
519
- test_collectionName,
520
- );
513
+ couchbase_client = new CouchbaseVector({
514
+ connectionString: 'COUCHBASE_CONNECTION_STRING',
515
+ username: 'COUCHBASE_USERNAME',
516
+ password: 'COUCHBASE_PASSWORD',
517
+ bucketName: test_bucketName,
518
+ scopeName: test_scopeName,
519
+ collectionName: test_collectionName,
520
+ });
521
521
  await couchbase_client.getCollection();
522
522
  });
523
523
 
@@ -542,13 +542,13 @@ describe('Unit Testing CouchbaseVector', () => {
542
542
  });
543
543
 
544
544
  it('should throw error when describing a non-existent index', async () => {
545
- await expect(couchbase_client.describeIndex('non_existent_index')).rejects.toThrow(
545
+ await expect(couchbase_client.describeIndex({ indexName: 'non_existent_index' })).rejects.toThrow(
546
546
  `Index non_existent_index does not exist`,
547
547
  );
548
548
  });
549
549
 
550
550
  it('should throw error when deleting a non-existent index', async () => {
551
- await expect(couchbase_client.deleteIndex('non_existent_index')).rejects.toThrow(
551
+ await expect(couchbase_client.deleteIndex({ indexName: 'non_existent_index' })).rejects.toThrow(
552
552
  `Index non_existent_index does not exist`,
553
553
  );
554
554
  });
@@ -577,14 +577,14 @@ describe('Unit Testing CouchbaseVector', () => {
577
577
  describe('Vector Dimension Tracking', () => {
578
578
  beforeEach(async () => {
579
579
  clearAllMocks();
580
- couchbase_client = new CouchbaseVector(
581
- 'COUCHBASE_CONNECTION_STRING',
582
- 'COUCHBASE_USERNAME',
583
- 'COUCHBASE_PASSWORD',
584
- test_bucketName,
585
- test_scopeName,
586
- test_collectionName,
587
- );
580
+ couchbase_client = new CouchbaseVector({
581
+ connectionString: 'COUCHBASE_CONNECTION_STRING',
582
+ username: 'COUCHBASE_USERNAME',
583
+ password: 'COUCHBASE_PASSWORD',
584
+ bucketName: test_bucketName,
585
+ scopeName: test_scopeName,
586
+ collectionName: test_collectionName,
587
+ });
588
588
  await couchbase_client.getCollection();
589
589
  });
590
590
 
@@ -637,7 +637,7 @@ describe('Unit Testing CouchbaseVector', () => {
637
637
  clearAllMocks();
638
638
 
639
639
  // Delete the index
640
- await couchbase_client.deleteIndex(test_indexName);
640
+ await couchbase_client.deleteIndex({ indexName: test_indexName });
641
641
 
642
642
  // Verify dimension is reset
643
643
  expect((couchbase_client as any).vector_dimension).toBeNull();
@@ -647,14 +647,14 @@ describe('Unit Testing CouchbaseVector', () => {
647
647
  describe('Implementation Details', () => {
648
648
  beforeEach(async () => {
649
649
  clearAllMocks();
650
- couchbase_client = new CouchbaseVector(
651
- 'COUCHBASE_CONNECTION_STRING',
652
- 'COUCHBASE_USERNAME',
653
- 'COUCHBASE_PASSWORD',
654
- test_bucketName,
655
- test_scopeName,
656
- test_collectionName,
657
- );
650
+ couchbase_client = new CouchbaseVector({
651
+ connectionString: 'COUCHBASE_CONNECTION_STRING',
652
+ username: 'COUCHBASE_USERNAME',
653
+ password: 'COUCHBASE_PASSWORD',
654
+ bucketName: test_bucketName,
655
+ scopeName: test_scopeName,
656
+ collectionName: test_collectionName,
657
+ });
658
658
  await couchbase_client.getCollection();
659
659
  });
660
660
 
@@ -713,7 +713,7 @@ describe('Unit Testing CouchbaseVector', () => {
713
713
  },
714
714
  });
715
715
 
716
- const stats = await couchbase_client.describeIndex(test_indexName);
716
+ const stats = await couchbase_client.describeIndex({ indexName: test_indexName });
717
717
  expect(stats.metric).toBe(mastraMetric);
718
718
  }
719
719
  });