@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.
- package/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +21 -0
- package/dist/_tsup-dts-rollup.d.cts +9 -16
- package/dist/_tsup-dts-rollup.d.ts +9 -16
- package/dist/index.cjs +16 -49
- package/dist/index.js +16 -49
- package/package.json +6 -3
- package/src/vector/index.ts +16 -85
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/couchbase@0.0
|
|
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
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.4.0
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 8118ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/couchbase/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
14
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/couchbase/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 9975ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[32mESM[39m [1mdist/index.js [22m[
|
|
21
|
-
[32mESM[39m ⚡️ Build success in
|
|
22
|
-
[32mCJS[39m [1mdist/index.cjs [22m[
|
|
23
|
-
[32mCJS[39m ⚡️ Build success in
|
|
20
|
+
[32mESM[39m [1mdist/index.js [22m[32m10.74 KB[39m
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 497ms
|
|
22
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m10.80 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ 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(
|
|
34
|
-
upsert(
|
|
35
|
-
query(
|
|
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
|
|
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(
|
|
45
|
-
deleteIndex(
|
|
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(
|
|
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(
|
|
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(
|
|
34
|
-
upsert(
|
|
35
|
-
query(
|
|
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
|
|
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(
|
|
45
|
-
deleteIndex(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
46
|
-
username
|
|
47
|
-
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 =
|
|
59
|
-
this.collectionName =
|
|
60
|
-
this.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(
|
|
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(
|
|
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(
|
|
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
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
44
|
-
username
|
|
45
|
-
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 =
|
|
57
|
-
this.collectionName =
|
|
58
|
-
this.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(
|
|
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(
|
|
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(
|
|
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
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
|
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",
|
package/src/vector/index.ts
CHANGED
|
@@ -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(
|
|
103
|
-
username
|
|
104
|
-
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 =
|
|
118
|
-
this.collectionName =
|
|
119
|
-
this.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(
|
|
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(
|
|
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(
|
|
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
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|