@mastra/couchbase 0.0.5-alpha.0 → 0.1.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/couchbase@0.0.5-alpha.0 build /home/runner/work/mastra/mastra/stores/couchbase
2
+ > @mastra/couchbase@0.1.0-alpha.1 build /home/runner/work/mastra/mastra/stores/couchbase
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 6132ms
9
+ TSC ⚡️ Build success in 8118ms
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/couchbase/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/couchbase/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 8893ms
16
+ DTS ⚡️ Build success in 9975ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- ESM dist/index.js 12.31 KB
21
- ESM ⚡️ Build success in 502ms
22
- CJS dist/index.cjs 12.37 KB
23
- CJS ⚡️ Build success in 503ms
20
+ ESM dist/index.js 10.74 KB
21
+ ESM ⚡️ Build success in 497ms
22
+ CJS dist/index.cjs 10.80 KB
23
+ CJS ⚡️ Build success in 499ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @mastra/couchbase
2
2
 
3
+ ## 0.1.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.0.5-alpha.0
4
25
 
5
26
  ### Patch Changes
@@ -5,7 +5,6 @@ import type { DeleteVectorParams } from '@mastra/core/vector';
5
5
  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
- import type { ParamsToArgs } from '@mastra/core/vector';
9
8
  import type { QueryResult } from '@mastra/core/vector';
10
9
  import type { QueryVectorParams } from '@mastra/core/vector';
11
10
  import type { UpdateVectorParams } from '@mastra/core/vector';
@@ -23,26 +22,20 @@ declare class CouchbaseVector extends MastraVector {
23
22
  private bucket;
24
23
  private scope;
25
24
  private vector_dimension;
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);
25
+ constructor({ connectionString, username, password, bucketName, scopeName, collectionName }: CouchbaseVectorParams);
32
26
  getCollection(): Promise<Collection>;
33
- createIndex(params: CreateIndexParams): Promise<void>;
34
- upsert(params: UpsertVectorParams): Promise<string[]>;
35
- query(params: QueryVectorParams): Promise<QueryResult[]>;
27
+ createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
28
+ upsert({ vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
29
+ query({ indexName, queryVector, topK, includeVector }: QueryVectorParams): Promise<QueryResult[]>;
36
30
  listIndexes(): Promise<string[]>;
37
31
  /**
38
32
  * Retrieves statistics about a vector index.
39
33
  *
40
- * @param params - The parameters for describing an index
41
- * @param params.indexName - The name of the index to describe
34
+ * @param {string} indexName - The name of the index to describe
42
35
  * @returns A promise that resolves to the index statistics including dimension, count and metric
43
36
  */
44
- describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats>;
45
- deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
37
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
38
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
46
39
  /**
47
40
  * Updates a vector by its ID with the provided vector and/or metadata.
48
41
  * @param indexName - The name of the index containing the vector.
@@ -53,7 +46,7 @@ declare class CouchbaseVector extends MastraVector {
53
46
  * @returns A promise that resolves when the update is complete.
54
47
  * @throws Will throw an error if no updates are provided or if the update operation fails.
55
48
  */
56
- updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
49
+ updateVector({ id, update }: UpdateVectorParams): Promise<void>;
57
50
  /**
58
51
  * Deletes a vector by its ID.
59
52
  * @param indexName - The name of the index containing the vector.
@@ -61,7 +54,7 @@ declare class CouchbaseVector extends MastraVector {
61
54
  * @returns A promise that resolves when the deletion is complete.
62
55
  * @throws Will throw an error if the deletion operation fails.
63
56
  */
64
- deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void>;
57
+ deleteVector({ id }: DeleteVectorParams): Promise<void>;
65
58
  }
66
59
  export { CouchbaseVector }
67
60
  export { CouchbaseVector as CouchbaseVector_alias_1 }
@@ -5,7 +5,6 @@ import type { DeleteVectorParams } from '@mastra/core/vector';
5
5
  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
- import type { ParamsToArgs } from '@mastra/core/vector';
9
8
  import type { QueryResult } from '@mastra/core/vector';
10
9
  import type { QueryVectorParams } from '@mastra/core/vector';
11
10
  import type { UpdateVectorParams } from '@mastra/core/vector';
@@ -23,26 +22,20 @@ declare class CouchbaseVector extends MastraVector {
23
22
  private bucket;
24
23
  private scope;
25
24
  private vector_dimension;
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);
25
+ constructor({ connectionString, username, password, bucketName, scopeName, collectionName }: CouchbaseVectorParams);
32
26
  getCollection(): Promise<Collection>;
33
- createIndex(params: CreateIndexParams): Promise<void>;
34
- upsert(params: UpsertVectorParams): Promise<string[]>;
35
- query(params: QueryVectorParams): Promise<QueryResult[]>;
27
+ createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
28
+ upsert({ vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
29
+ query({ indexName, queryVector, topK, includeVector }: QueryVectorParams): Promise<QueryResult[]>;
36
30
  listIndexes(): Promise<string[]>;
37
31
  /**
38
32
  * Retrieves statistics about a vector index.
39
33
  *
40
- * @param params - The parameters for describing an index
41
- * @param params.indexName - The name of the index to describe
34
+ * @param {string} indexName - The name of the index to describe
42
35
  * @returns A promise that resolves to the index statistics including dimension, count and metric
43
36
  */
44
- describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats>;
45
- deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
37
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
38
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
46
39
  /**
47
40
  * Updates a vector by its ID with the provided vector and/or metadata.
48
41
  * @param indexName - The name of the index containing the vector.
@@ -53,7 +46,7 @@ declare class CouchbaseVector extends MastraVector {
53
46
  * @returns A promise that resolves when the update is complete.
54
47
  * @throws Will throw an error if no updates are provided or if the update operation fails.
55
48
  */
56
- updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
49
+ updateVector({ id, update }: UpdateVectorParams): Promise<void>;
57
50
  /**
58
51
  * Deletes a vector by its ID.
59
52
  * @param indexName - The name of the index containing the vector.
@@ -61,7 +54,7 @@ declare class CouchbaseVector extends MastraVector {
61
54
  * @returns A promise that resolves when the deletion is complete.
62
55
  * @throws Will throw an error if the deletion operation fails.
63
56
  */
64
- deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void>;
57
+ deleteVector({ id }: DeleteVectorParams): Promise<void>;
65
58
  }
66
59
  export { CouchbaseVector }
67
60
  export { CouchbaseVector as CouchbaseVector_alias_1 }
package/dist/index.cjs CHANGED
@@ -19,32 +19,11 @@ var CouchbaseVector = class extends vector.MastraVector {
19
19
  bucket;
20
20
  scope;
21
21
  vector_dimension;
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
- }
22
+ constructor({ connectionString, username, password, bucketName, scopeName, collectionName }) {
44
23
  super();
45
- const baseClusterPromise = couchbase.connect(connectionString_, {
46
- username: username_,
47
- password: password_,
24
+ const baseClusterPromise = couchbase.connect(connectionString, {
25
+ username,
26
+ password,
48
27
  configProfile: "wanDevelopment"
49
28
  });
50
29
  const telemetry = this.__getTelemetry();
@@ -55,9 +34,9 @@ var CouchbaseVector = class extends vector.MastraVector {
55
34
  }
56
35
  }) ?? baseClusterPromise;
57
36
  this.cluster = null;
58
- this.bucketName = bucketName_;
59
- this.collectionName = collectionName_;
60
- this.scopeName = scopeName_;
37
+ this.bucketName = bucketName;
38
+ this.collectionName = collectionName;
39
+ this.scopeName = scopeName;
61
40
  this.collection = null;
62
41
  this.bucket = null;
63
42
  this.scope = null;
@@ -74,8 +53,7 @@ var CouchbaseVector = class extends vector.MastraVector {
74
53
  }
75
54
  return this.collection;
76
55
  }
77
- async createIndex(params) {
78
- const { indexName, dimension, metric = "dotproduct" } = params;
56
+ async createIndex({ indexName, dimension, metric = "dotproduct" }) {
79
57
  await this.getCollection();
80
58
  if (!Number.isInteger(dimension) || dimension <= 0) {
81
59
  throw new Error("Dimension must be a positive integer");
@@ -170,8 +148,7 @@ var CouchbaseVector = class extends vector.MastraVector {
170
148
  throw error;
171
149
  }
172
150
  }
173
- async upsert(params) {
174
- const { vectors, metadata, ids } = params;
151
+ async upsert({ vectors, metadata, ids }) {
175
152
  await this.getCollection();
176
153
  if (!vectors || vectors.length === 0) {
177
154
  throw new Error("No vectors provided");
@@ -202,10 +179,9 @@ var CouchbaseVector = class extends vector.MastraVector {
202
179
  await Promise.all(allPromises);
203
180
  return pointIds;
204
181
  }
205
- async query(params) {
206
- const { indexName, queryVector, topK = 10, includeVector = false } = params;
182
+ async query({ indexName, queryVector, topK = 10, includeVector = false }) {
207
183
  await this.getCollection();
208
- const index_stats = await this.describeIndex(indexName);
184
+ const index_stats = await this.describeIndex({ indexName });
209
185
  if (queryVector.length !== index_stats.dimension) {
210
186
  throw new Error(`Query vector dimension mismatch. Expected ${index_stats.dimension}, got ${queryVector.length}`);
211
187
  }
@@ -245,13 +221,10 @@ var CouchbaseVector = class extends vector.MastraVector {
245
221
  /**
246
222
  * Retrieves statistics about a vector index.
247
223
  *
248
- * @param params - The parameters for describing an index
249
- * @param params.indexName - The name of the index to describe
224
+ * @param {string} indexName - The name of the index to describe
250
225
  * @returns A promise that resolves to the index statistics including dimension, count and metric
251
226
  */
252
- async describeIndex(...args) {
253
- const params = this.normalizeArgs("describeIndex", args);
254
- const { indexName } = params;
227
+ async describeIndex({ indexName }) {
255
228
  await this.getCollection();
256
229
  if (!(await this.listIndexes()).includes(indexName)) {
257
230
  throw new Error(`Index ${indexName} does not exist`);
@@ -268,9 +241,7 @@ var CouchbaseVector = class extends vector.MastraVector {
268
241
  )
269
242
  };
270
243
  }
271
- async deleteIndex(...args) {
272
- const params = this.normalizeArgs("deleteIndex", args);
273
- const { indexName } = params;
244
+ async deleteIndex({ indexName }) {
274
245
  await this.getCollection();
275
246
  if (!(await this.listIndexes()).includes(indexName)) {
276
247
  throw new Error(`Index ${indexName} does not exist`);
@@ -288,9 +259,7 @@ var CouchbaseVector = class extends vector.MastraVector {
288
259
  * @returns A promise that resolves when the update is complete.
289
260
  * @throws Will throw an error if no updates are provided or if the update operation fails.
290
261
  */
291
- async updateVector(...args) {
292
- const params = this.normalizeArgs("updateVector", args);
293
- const { id, update } = params;
262
+ async updateVector({ id, update }) {
294
263
  if (!update.vector && !update.metadata) {
295
264
  throw new Error("No updates provided");
296
265
  }
@@ -318,9 +287,7 @@ var CouchbaseVector = class extends vector.MastraVector {
318
287
  * @returns A promise that resolves when the deletion is complete.
319
288
  * @throws Will throw an error if the deletion operation fails.
320
289
  */
321
- async deleteVector(...args) {
322
- const params = this.normalizeArgs("deleteVector", args);
323
- const { id } = params;
290
+ async deleteVector({ id }) {
324
291
  const collection = await this.getCollection();
325
292
  try {
326
293
  await collection.get(id);
package/dist/index.js CHANGED
@@ -17,32 +17,11 @@ var CouchbaseVector = class extends MastraVector {
17
17
  bucket;
18
18
  scope;
19
19
  vector_dimension;
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
- }
20
+ constructor({ connectionString, username, password, bucketName, scopeName, collectionName }) {
42
21
  super();
43
- const baseClusterPromise = connect(connectionString_, {
44
- username: username_,
45
- password: password_,
22
+ const baseClusterPromise = connect(connectionString, {
23
+ username,
24
+ password,
46
25
  configProfile: "wanDevelopment"
47
26
  });
48
27
  const telemetry = this.__getTelemetry();
@@ -53,9 +32,9 @@ var CouchbaseVector = class extends MastraVector {
53
32
  }
54
33
  }) ?? baseClusterPromise;
55
34
  this.cluster = null;
56
- this.bucketName = bucketName_;
57
- this.collectionName = collectionName_;
58
- this.scopeName = scopeName_;
35
+ this.bucketName = bucketName;
36
+ this.collectionName = collectionName;
37
+ this.scopeName = scopeName;
59
38
  this.collection = null;
60
39
  this.bucket = null;
61
40
  this.scope = null;
@@ -72,8 +51,7 @@ var CouchbaseVector = class extends MastraVector {
72
51
  }
73
52
  return this.collection;
74
53
  }
75
- async createIndex(params) {
76
- const { indexName, dimension, metric = "dotproduct" } = params;
54
+ async createIndex({ indexName, dimension, metric = "dotproduct" }) {
77
55
  await this.getCollection();
78
56
  if (!Number.isInteger(dimension) || dimension <= 0) {
79
57
  throw new Error("Dimension must be a positive integer");
@@ -168,8 +146,7 @@ var CouchbaseVector = class extends MastraVector {
168
146
  throw error;
169
147
  }
170
148
  }
171
- async upsert(params) {
172
- const { vectors, metadata, ids } = params;
149
+ async upsert({ vectors, metadata, ids }) {
173
150
  await this.getCollection();
174
151
  if (!vectors || vectors.length === 0) {
175
152
  throw new Error("No vectors provided");
@@ -200,10 +177,9 @@ var CouchbaseVector = class extends MastraVector {
200
177
  await Promise.all(allPromises);
201
178
  return pointIds;
202
179
  }
203
- async query(params) {
204
- const { indexName, queryVector, topK = 10, includeVector = false } = params;
180
+ async query({ indexName, queryVector, topK = 10, includeVector = false }) {
205
181
  await this.getCollection();
206
- const index_stats = await this.describeIndex(indexName);
182
+ const index_stats = await this.describeIndex({ indexName });
207
183
  if (queryVector.length !== index_stats.dimension) {
208
184
  throw new Error(`Query vector dimension mismatch. Expected ${index_stats.dimension}, got ${queryVector.length}`);
209
185
  }
@@ -243,13 +219,10 @@ var CouchbaseVector = class extends MastraVector {
243
219
  /**
244
220
  * Retrieves statistics about a vector index.
245
221
  *
246
- * @param params - The parameters for describing an index
247
- * @param params.indexName - The name of the index to describe
222
+ * @param {string} indexName - The name of the index to describe
248
223
  * @returns A promise that resolves to the index statistics including dimension, count and metric
249
224
  */
250
- async describeIndex(...args) {
251
- const params = this.normalizeArgs("describeIndex", args);
252
- const { indexName } = params;
225
+ async describeIndex({ indexName }) {
253
226
  await this.getCollection();
254
227
  if (!(await this.listIndexes()).includes(indexName)) {
255
228
  throw new Error(`Index ${indexName} does not exist`);
@@ -266,9 +239,7 @@ var CouchbaseVector = class extends MastraVector {
266
239
  )
267
240
  };
268
241
  }
269
- async deleteIndex(...args) {
270
- const params = this.normalizeArgs("deleteIndex", args);
271
- const { indexName } = params;
242
+ async deleteIndex({ indexName }) {
272
243
  await this.getCollection();
273
244
  if (!(await this.listIndexes()).includes(indexName)) {
274
245
  throw new Error(`Index ${indexName} does not exist`);
@@ -286,9 +257,7 @@ var CouchbaseVector = class extends MastraVector {
286
257
  * @returns A promise that resolves when the update is complete.
287
258
  * @throws Will throw an error if no updates are provided or if the update operation fails.
288
259
  */
289
- async updateVector(...args) {
290
- const params = this.normalizeArgs("updateVector", args);
291
- const { id, update } = params;
260
+ async updateVector({ id, update }) {
292
261
  if (!update.vector && !update.metadata) {
293
262
  throw new Error("No updates provided");
294
263
  }
@@ -316,9 +285,7 @@ var CouchbaseVector = class extends MastraVector {
316
285
  * @returns A promise that resolves when the deletion is complete.
317
286
  * @throws Will throw an error if the deletion operation fails.
318
287
  */
319
- async deleteVector(...args) {
320
- const params = this.normalizeArgs("deleteVector", args);
321
- const { id } = params;
288
+ async deleteVector({ id }) {
322
289
  const collection = await this.getCollection();
323
290
  try {
324
291
  await collection.get(id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/couchbase",
3
- "version": "0.0.5-alpha.0",
3
+ "version": "0.1.0-alpha.1",
4
4
  "description": "Couchbase vector store provider for Mastra",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -19,8 +19,7 @@
19
19
  "./package.json": "./package.json"
20
20
  },
21
21
  "dependencies": {
22
- "couchbase": "^4.4.5",
23
- "@mastra/core": "^0.9.5-alpha.0"
22
+ "couchbase": "^4.4.5"
24
23
  },
25
24
  "devDependencies": {
26
25
  "@microsoft/api-extractor": "^7.52.1",
@@ -32,8 +31,12 @@
32
31
  "tsup": "^8.4.0",
33
32
  "typescript": "^5.8.2",
34
33
  "vitest": "^3.0.9",
34
+ "@mastra/core": "0.10.0-alpha.1",
35
35
  "@internal/lint": "0.0.5"
36
36
  },
37
+ "peerDependencies": {
38
+ "@mastra/core": "^0.9.4"
39
+ },
37
40
  "scripts": {
38
41
  "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
39
42
  "build:watch": "pnpm build --watch",
@@ -6,7 +6,6 @@ import type {
6
6
  UpsertVectorParams,
7
7
  QueryVectorParams,
8
8
  DescribeIndexParams,
9
- ParamsToArgs,
10
9
  DeleteIndexParams,
11
10
  DeleteVectorParams,
12
11
  UpdateVectorParams,
@@ -42,66 +41,12 @@ export class CouchbaseVector extends MastraVector {
42
41
  private scope: Scope;
43
42
  private vector_dimension: number;
44
43
 
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
- */
49
- constructor(
50
- connectionString: string,
51
- username: string,
52
- password: string,
53
- bucketName: string,
54
- scopeName: string,
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,
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
-
44
+ constructor({ connectionString, username, password, bucketName, scopeName, collectionName }: CouchbaseVectorParams) {
100
45
  super();
101
46
 
102
- const baseClusterPromise = connect(connectionString_, {
103
- username: username_,
104
- password: password_,
47
+ const baseClusterPromise = connect(connectionString, {
48
+ username,
49
+ password,
105
50
  configProfile: 'wanDevelopment',
106
51
  });
107
52
 
@@ -114,9 +59,9 @@ export class CouchbaseVector extends MastraVector {
114
59
  },
115
60
  }) ?? baseClusterPromise;
116
61
  this.cluster = null as unknown as Cluster;
117
- this.bucketName = bucketName_;
118
- this.collectionName = collectionName_;
119
- this.scopeName = scopeName_;
62
+ this.bucketName = bucketName;
63
+ this.collectionName = collectionName;
64
+ this.scopeName = scopeName;
120
65
  this.collection = null as unknown as Collection;
121
66
  this.bucket = null as unknown as Bucket;
122
67
  this.scope = null as unknown as Scope;
@@ -137,8 +82,7 @@ export class CouchbaseVector extends MastraVector {
137
82
  return this.collection;
138
83
  }
139
84
 
140
- async createIndex(params: CreateIndexParams): Promise<void> {
141
- const { indexName, dimension, metric = 'dotproduct' as MastraMetric } = params;
85
+ async createIndex({ indexName, dimension, metric = 'dotproduct' as MastraMetric }: CreateIndexParams): Promise<void> {
142
86
  await this.getCollection();
143
87
 
144
88
  if (!Number.isInteger(dimension) || dimension <= 0) {
@@ -233,8 +177,7 @@ export class CouchbaseVector extends MastraVector {
233
177
  }
234
178
  }
235
179
 
236
- async upsert(params: UpsertVectorParams): Promise<string[]> {
237
- const { vectors, metadata, ids } = params;
180
+ async upsert({ vectors, metadata, ids }: UpsertVectorParams): Promise<string[]> {
238
181
  await this.getCollection();
239
182
 
240
183
  if (!vectors || vectors.length === 0) {
@@ -271,12 +214,10 @@ export class CouchbaseVector extends MastraVector {
271
214
  return pointIds;
272
215
  }
273
216
 
274
- async query(params: QueryVectorParams): Promise<QueryResult[]> {
275
- const { indexName, queryVector, topK = 10, includeVector = false } = params;
276
-
217
+ async query({ indexName, queryVector, topK = 10, includeVector = false }: QueryVectorParams): Promise<QueryResult[]> {
277
218
  await this.getCollection();
278
219
 
279
- const index_stats = await this.describeIndex(indexName);
220
+ const index_stats = await this.describeIndex({ indexName });
280
221
  if (queryVector.length !== index_stats.dimension) {
281
222
  throw new Error(`Query vector dimension mismatch. Expected ${index_stats.dimension}, got ${queryVector.length}`);
282
223
  }
@@ -319,13 +260,10 @@ export class CouchbaseVector extends MastraVector {
319
260
  /**
320
261
  * Retrieves statistics about a vector index.
321
262
  *
322
- * @param params - The parameters for describing an index
323
- * @param params.indexName - The name of the index to describe
263
+ * @param {string} indexName - The name of the index to describe
324
264
  * @returns A promise that resolves to the index statistics including dimension, count and metric
325
265
  */
326
- async describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats> {
327
- const params = this.normalizeArgs<DescribeIndexParams>('describeIndex', args);
328
- const { indexName } = params;
266
+ async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {
329
267
  await this.getCollection();
330
268
  if (!(await this.listIndexes()).includes(indexName)) {
331
269
  throw new Error(`Index ${indexName} does not exist`);
@@ -346,9 +284,7 @@ export class CouchbaseVector extends MastraVector {
346
284
  };
347
285
  }
348
286
 
349
- async deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void> {
350
- const params = this.normalizeArgs<DeleteIndexParams>('deleteIndex', args);
351
- const { indexName } = params;
287
+ async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {
352
288
  await this.getCollection();
353
289
  if (!(await this.listIndexes()).includes(indexName)) {
354
290
  throw new Error(`Index ${indexName} does not exist`);
@@ -367,9 +303,7 @@ export class CouchbaseVector extends MastraVector {
367
303
  * @returns A promise that resolves when the update is complete.
368
304
  * @throws Will throw an error if no updates are provided or if the update operation fails.
369
305
  */
370
- async updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void> {
371
- const params = this.normalizeArgs<UpdateVectorParams>('updateVector', args);
372
- const { id, update } = params;
306
+ async updateVector({ id, update }: UpdateVectorParams): Promise<void> {
373
307
  if (!update.vector && !update.metadata) {
374
308
  throw new Error('No updates provided');
375
309
  }
@@ -402,10 +336,7 @@ export class CouchbaseVector extends MastraVector {
402
336
  * @returns A promise that resolves when the deletion is complete.
403
337
  * @throws Will throw an error if the deletion operation fails.
404
338
  */
405
- async deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void> {
406
- const params = this.normalizeArgs<DeleteVectorParams>('deleteVector', args);
407
-
408
- const { id } = params;
339
+ async deleteVector({ id }: DeleteVectorParams): Promise<void> {
409
340
  const collection = await this.getCollection();
410
341
 
411
342
  // Check if document exists