@mastra/couchbase 0.0.0-vnext-inngest-20250508131921 → 0.0.0-workflow-deno-20250616115451
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 +246 -2
- package/README.md +11 -1
- package/dist/_tsup-dts-rollup.d.cts +47 -6
- package/dist/_tsup-dts-rollup.d.ts +47 -6
- package/dist/index.cjs +70 -11
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +71 -12
- package/docker-compose.yaml +12 -12
- package/package.json +16 -13
- package/src/vector/index.integration.test.ts +130 -16
- package/src/vector/index.ts +94 -20
- package/src/vector/index.unit.test.ts +54 -54
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,260 @@
|
|
|
1
1
|
# @mastra/couchbase
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-workflow-deno-20250616115451
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 63f6b7d: dependencies updates:
|
|
8
|
+
- Updated dependency [`couchbase@^4.5.0` ↗︎](https://www.npmjs.com/package/couchbase/v/4.5.0) (from `^4.4.5`, in `dependencies`)
|
|
9
|
+
- Updated dependencies [63f6b7d]
|
|
10
|
+
- Updated dependencies [ee9af57]
|
|
11
|
+
- Updated dependencies [36f1c36]
|
|
12
|
+
- Updated dependencies [10d352e]
|
|
13
|
+
- Updated dependencies [3ca9a67]
|
|
14
|
+
- Updated dependencies [53d3c37]
|
|
15
|
+
- Updated dependencies [577ce3a]
|
|
16
|
+
- Updated dependencies [9260b3a]
|
|
17
|
+
- @mastra/core@0.0.0-workflow-deno-20250616115451
|
|
18
|
+
|
|
19
|
+
## 0.10.3-alpha.0
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- 63f6b7d: dependencies updates:
|
|
24
|
+
- Updated dependency [`couchbase@^4.5.0` ↗︎](https://www.npmjs.com/package/couchbase/v/4.5.0) (from `^4.4.5`, in `dependencies`)
|
|
25
|
+
- Updated dependencies [63f6b7d]
|
|
26
|
+
- Updated dependencies [36f1c36]
|
|
27
|
+
- Updated dependencies [10d352e]
|
|
28
|
+
- Updated dependencies [53d3c37]
|
|
29
|
+
- @mastra/core@0.10.6-alpha.0
|
|
30
|
+
|
|
31
|
+
## 0.10.2
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- 66f4424: Update peerdeps
|
|
36
|
+
- Updated dependencies [d1ed912]
|
|
37
|
+
- Updated dependencies [f6fd25f]
|
|
38
|
+
- Updated dependencies [dffb67b]
|
|
39
|
+
- Updated dependencies [f1f1f1b]
|
|
40
|
+
- Updated dependencies [925ab94]
|
|
41
|
+
- Updated dependencies [f9816ae]
|
|
42
|
+
- Updated dependencies [82090c1]
|
|
43
|
+
- Updated dependencies [1b443fd]
|
|
44
|
+
- Updated dependencies [ce97900]
|
|
45
|
+
- Updated dependencies [f1309d3]
|
|
46
|
+
- Updated dependencies [14a2566]
|
|
47
|
+
- Updated dependencies [f7f8293]
|
|
48
|
+
- Updated dependencies [48eddb9]
|
|
49
|
+
- @mastra/core@0.10.4
|
|
50
|
+
|
|
51
|
+
## 0.10.2-alpha.0
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- 66f4424: Update peerdeps
|
|
56
|
+
|
|
57
|
+
## 0.10.1
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- f0d559f: Fix peerdeps for alpha channel
|
|
62
|
+
- 915ca1a: Added disconnect function for couchbase and added docs
|
|
63
|
+
Added prompt for OpenSearchVector
|
|
64
|
+
- Updated dependencies [ee77e78]
|
|
65
|
+
- Updated dependencies [592a2db]
|
|
66
|
+
- Updated dependencies [e5dc18d]
|
|
67
|
+
- Updated dependencies [ab5adbe]
|
|
68
|
+
- Updated dependencies [1e8bb40]
|
|
69
|
+
- Updated dependencies [1b5fc55]
|
|
70
|
+
- Updated dependencies [195c428]
|
|
71
|
+
- Updated dependencies [f73e11b]
|
|
72
|
+
- Updated dependencies [37643b8]
|
|
73
|
+
- Updated dependencies [99fd6cf]
|
|
74
|
+
- Updated dependencies [c5bf1ce]
|
|
75
|
+
- Updated dependencies [add596e]
|
|
76
|
+
- Updated dependencies [8dc94d8]
|
|
77
|
+
- Updated dependencies [ecebbeb]
|
|
78
|
+
- Updated dependencies [79d5145]
|
|
79
|
+
- Updated dependencies [12b7002]
|
|
80
|
+
- Updated dependencies [2901125]
|
|
81
|
+
- @mastra/core@0.10.2
|
|
82
|
+
|
|
83
|
+
## 0.10.1-alpha.1
|
|
84
|
+
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- f0d559f: Fix peerdeps for alpha channel
|
|
88
|
+
- Updated dependencies [1e8bb40]
|
|
89
|
+
- @mastra/core@0.10.2-alpha.2
|
|
90
|
+
|
|
91
|
+
## 0.10.1-alpha.0
|
|
92
|
+
|
|
93
|
+
### Patch Changes
|
|
94
|
+
|
|
95
|
+
- 915ca1a: Added disconnect function for couchbase and added docs
|
|
96
|
+
Added prompt for OpenSearchVector
|
|
97
|
+
- Updated dependencies [ee77e78]
|
|
98
|
+
- Updated dependencies [2901125]
|
|
99
|
+
- @mastra/core@0.10.2-alpha.1
|
|
100
|
+
|
|
101
|
+
## 0.10.0
|
|
102
|
+
|
|
103
|
+
### Minor Changes
|
|
104
|
+
|
|
105
|
+
- 83da932: Move @mastra/core to peerdeps
|
|
106
|
+
|
|
107
|
+
### Patch Changes
|
|
108
|
+
|
|
109
|
+
- d0ee3c6: Change all public functions and constructors in vector stores to use named args and prepare to phase out positional args
|
|
110
|
+
- a7292b0: BREAKING(@mastra/core, all vector stores): Vector store breaking changes (remove deprecated functions and positional arguments)
|
|
111
|
+
- Updated dependencies [b3a3d63]
|
|
112
|
+
- Updated dependencies [344f453]
|
|
113
|
+
- Updated dependencies [0a3ae6d]
|
|
114
|
+
- Updated dependencies [95911be]
|
|
115
|
+
- Updated dependencies [f53a6ac]
|
|
116
|
+
- Updated dependencies [5eb5a99]
|
|
117
|
+
- Updated dependencies [7e632c5]
|
|
118
|
+
- Updated dependencies [1e9fbfa]
|
|
119
|
+
- Updated dependencies [eabdcd9]
|
|
120
|
+
- Updated dependencies [90be034]
|
|
121
|
+
- Updated dependencies [99f050a]
|
|
122
|
+
- Updated dependencies [d0ee3c6]
|
|
123
|
+
- Updated dependencies [b2ae5aa]
|
|
124
|
+
- Updated dependencies [23f258c]
|
|
125
|
+
- Updated dependencies [a7292b0]
|
|
126
|
+
- Updated dependencies [0dcb9f0]
|
|
127
|
+
- Updated dependencies [2672a05]
|
|
128
|
+
- @mastra/core@0.10.0
|
|
129
|
+
|
|
130
|
+
## 0.1.0-alpha.1
|
|
131
|
+
|
|
132
|
+
### Minor Changes
|
|
133
|
+
|
|
134
|
+
- 83da932: Move @mastra/core to peerdeps
|
|
135
|
+
|
|
136
|
+
### Patch Changes
|
|
137
|
+
|
|
138
|
+
- a7292b0: BREAKING(@mastra/core, all vector stores): Vector store breaking changes (remove deprecated functions and positional arguments)
|
|
139
|
+
- Updated dependencies [b3a3d63]
|
|
140
|
+
- Updated dependencies [344f453]
|
|
141
|
+
- Updated dependencies [0a3ae6d]
|
|
142
|
+
- Updated dependencies [95911be]
|
|
143
|
+
- Updated dependencies [5eb5a99]
|
|
144
|
+
- Updated dependencies [7e632c5]
|
|
145
|
+
- Updated dependencies [1e9fbfa]
|
|
146
|
+
- Updated dependencies [b2ae5aa]
|
|
147
|
+
- Updated dependencies [a7292b0]
|
|
148
|
+
- Updated dependencies [0dcb9f0]
|
|
149
|
+
- @mastra/core@0.10.0-alpha.1
|
|
150
|
+
|
|
151
|
+
## 0.0.5-alpha.0
|
|
152
|
+
|
|
153
|
+
### Patch Changes
|
|
154
|
+
|
|
155
|
+
- d0ee3c6: Change all public functions and constructors in vector stores to use named args and prepare to phase out positional args
|
|
156
|
+
- Updated dependencies [f53a6ac]
|
|
157
|
+
- Updated dependencies [eabdcd9]
|
|
158
|
+
- Updated dependencies [90be034]
|
|
159
|
+
- Updated dependencies [99f050a]
|
|
160
|
+
- Updated dependencies [d0ee3c6]
|
|
161
|
+
- Updated dependencies [23f258c]
|
|
162
|
+
- Updated dependencies [2672a05]
|
|
163
|
+
- @mastra/core@0.9.5-alpha.0
|
|
164
|
+
|
|
165
|
+
## 0.0.4
|
|
166
|
+
|
|
167
|
+
### Patch Changes
|
|
168
|
+
|
|
169
|
+
- c3bd795: [MASTRA-3358] Deprecate updateIndexById and deleteIndexById
|
|
170
|
+
- Updated dependencies [396be50]
|
|
171
|
+
- Updated dependencies [ab80e7e]
|
|
172
|
+
- Updated dependencies [c3bd795]
|
|
173
|
+
- Updated dependencies [da082f8]
|
|
174
|
+
- Updated dependencies [a5810ce]
|
|
175
|
+
- Updated dependencies [3e9c131]
|
|
176
|
+
- Updated dependencies [3171b5b]
|
|
177
|
+
- Updated dependencies [973e5ac]
|
|
178
|
+
- Updated dependencies [daf942f]
|
|
179
|
+
- Updated dependencies [0b8b868]
|
|
180
|
+
- Updated dependencies [9e1eff5]
|
|
181
|
+
- Updated dependencies [6fa1ad1]
|
|
182
|
+
- Updated dependencies [c28d7a0]
|
|
183
|
+
- Updated dependencies [edf1e88]
|
|
184
|
+
- @mastra/core@0.9.4
|
|
185
|
+
|
|
186
|
+
## 0.0.4-alpha.4
|
|
187
|
+
|
|
188
|
+
### Patch Changes
|
|
189
|
+
|
|
190
|
+
- Updated dependencies [3e9c131]
|
|
191
|
+
- @mastra/core@0.9.4-alpha.4
|
|
192
|
+
|
|
193
|
+
## 0.0.4-alpha.3
|
|
194
|
+
|
|
195
|
+
### Patch Changes
|
|
196
|
+
|
|
197
|
+
- c3bd795: [MASTRA-3358] Deprecate updateIndexById and deleteIndexById
|
|
198
|
+
- Updated dependencies [396be50]
|
|
199
|
+
- Updated dependencies [c3bd795]
|
|
200
|
+
- Updated dependencies [da082f8]
|
|
201
|
+
- Updated dependencies [a5810ce]
|
|
202
|
+
- @mastra/core@0.9.4-alpha.3
|
|
203
|
+
|
|
204
|
+
## 0.0.4-alpha.2
|
|
205
|
+
|
|
206
|
+
### Patch Changes
|
|
207
|
+
|
|
208
|
+
- Updated dependencies [3171b5b]
|
|
209
|
+
- Updated dependencies [973e5ac]
|
|
210
|
+
- Updated dependencies [9e1eff5]
|
|
211
|
+
- @mastra/core@0.9.4-alpha.2
|
|
212
|
+
|
|
213
|
+
## 0.0.4-alpha.1
|
|
214
|
+
|
|
215
|
+
### Patch Changes
|
|
216
|
+
|
|
217
|
+
- Updated dependencies [ab80e7e]
|
|
218
|
+
- Updated dependencies [6fa1ad1]
|
|
219
|
+
- Updated dependencies [c28d7a0]
|
|
220
|
+
- Updated dependencies [edf1e88]
|
|
221
|
+
- @mastra/core@0.9.4-alpha.1
|
|
222
|
+
|
|
223
|
+
## 0.0.4-alpha.0
|
|
224
|
+
|
|
225
|
+
### Patch Changes
|
|
226
|
+
|
|
227
|
+
- Updated dependencies [daf942f]
|
|
228
|
+
- Updated dependencies [0b8b868]
|
|
229
|
+
- @mastra/core@0.9.4-alpha.0
|
|
230
|
+
|
|
231
|
+
## 0.0.3
|
|
4
232
|
|
|
5
233
|
### Patch Changes
|
|
6
234
|
|
|
7
235
|
- 9cd1a46: [MASTRA-3338] update naming scheme for embedding index based on vector store rules and added duplicate index checks
|
|
236
|
+
- Updated dependencies [e450778]
|
|
237
|
+
- Updated dependencies [8902157]
|
|
238
|
+
- Updated dependencies [ca0dc88]
|
|
8
239
|
- Updated dependencies [526c570]
|
|
240
|
+
- Updated dependencies [d7a6a33]
|
|
9
241
|
- Updated dependencies [9cd1a46]
|
|
10
242
|
- Updated dependencies [b5d2de0]
|
|
11
243
|
- Updated dependencies [644f8ad]
|
|
12
244
|
- Updated dependencies [70dbf51]
|
|
13
|
-
- @mastra/core@0.
|
|
245
|
+
- @mastra/core@0.9.3
|
|
246
|
+
|
|
247
|
+
## 0.0.3-alpha.1
|
|
248
|
+
|
|
249
|
+
### Patch Changes
|
|
250
|
+
|
|
251
|
+
- 9cd1a46: [MASTRA-3338] update naming scheme for embedding index based on vector store rules and added duplicate index checks
|
|
252
|
+
- Updated dependencies [e450778]
|
|
253
|
+
- Updated dependencies [8902157]
|
|
254
|
+
- Updated dependencies [ca0dc88]
|
|
255
|
+
- Updated dependencies [9cd1a46]
|
|
256
|
+
- Updated dependencies [70dbf51]
|
|
257
|
+
- @mastra/core@0.9.3-alpha.1
|
|
14
258
|
|
|
15
259
|
## 0.0.3-alpha.0
|
|
16
260
|
|
package/README.md
CHANGED
|
@@ -51,7 +51,14 @@ const bucketName = 'your_vector_bucket';
|
|
|
51
51
|
const scopeName = '_default'; // Or your custom scope name
|
|
52
52
|
const collectionName = 'vector_data'; // Or your custom collection name
|
|
53
53
|
|
|
54
|
-
const vectorStore = new CouchbaseVector(
|
|
54
|
+
const vectorStore = new CouchbaseVector({
|
|
55
|
+
connectionString,
|
|
56
|
+
username,
|
|
57
|
+
password,
|
|
58
|
+
bucketName,
|
|
59
|
+
scopeName,
|
|
60
|
+
collectionName,
|
|
61
|
+
});
|
|
55
62
|
|
|
56
63
|
console.log('CouchbaseVector instance created. Connecting...');
|
|
57
64
|
```
|
|
@@ -214,6 +221,9 @@ _Note_: Deleting Index does NOT delete the vectors in the associated Couchbase C
|
|
|
214
221
|
- `listIndexes()`: Lists the names of all Search Indexes in the cluster. Returns fully qualified names (e.g., `bucket.scope.index`).
|
|
215
222
|
- `describeIndex(indexName)`: Gets the configured dimension, metric (Mastra name), and document count (currently returns -1) for a specific Search Index (using its short name).
|
|
216
223
|
- `deleteIndex(indexName)`: Deletes a Search Index (using its short name).
|
|
224
|
+
- `deleteVector(indexName, id)`: Deletes a specific vector entry from an index by its ID.
|
|
225
|
+
- `updateVector(indexName, id, update)`: Updates a specific vector entry by its ID with new vector data and/or metadata.
|
|
226
|
+
- `disconnect()`: Closes the Couchbase client connection. Should be called when done using the store.
|
|
217
227
|
|
|
218
228
|
## Configuration Details
|
|
219
229
|
|
|
@@ -1,9 +1,13 @@
|
|
|
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';
|
|
5
8
|
import type { QueryResult } from '@mastra/core/vector';
|
|
6
9
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
10
|
+
import type { UpdateVectorParams } from '@mastra/core/vector';
|
|
7
11
|
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
8
12
|
|
|
9
13
|
declare type CouchbaseMetric = 'cosine' | 'l2_norm' | 'dot_product';
|
|
@@ -18,18 +22,55 @@ declare class CouchbaseVector extends MastraVector {
|
|
|
18
22
|
private bucket;
|
|
19
23
|
private scope;
|
|
20
24
|
private vector_dimension;
|
|
21
|
-
constructor(
|
|
25
|
+
constructor({ connectionString, username, password, bucketName, scopeName, collectionName }: CouchbaseVectorParams);
|
|
22
26
|
getCollection(): Promise<Collection>;
|
|
23
|
-
createIndex(
|
|
24
|
-
upsert(
|
|
25
|
-
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[]>;
|
|
26
30
|
listIndexes(): Promise<string[]>;
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Retrieves statistics about a vector index.
|
|
33
|
+
*
|
|
34
|
+
* @param {string} indexName - The name of the index to describe
|
|
35
|
+
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
36
|
+
*/
|
|
37
|
+
describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
|
|
38
|
+
deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
41
|
+
* @param indexName - The name of the index containing the vector.
|
|
42
|
+
* @param id - The ID of the vector to update.
|
|
43
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
44
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
45
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
46
|
+
* @returns A promise that resolves when the update is complete.
|
|
47
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
48
|
+
*/
|
|
49
|
+
updateVector({ id, update }: UpdateVectorParams): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Deletes a vector by its ID.
|
|
52
|
+
* @param indexName - The name of the index containing the vector.
|
|
53
|
+
* @param id - The ID of the vector to delete.
|
|
54
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
55
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
56
|
+
*/
|
|
57
|
+
deleteVector({ id }: DeleteVectorParams): Promise<void>;
|
|
58
|
+
disconnect(): Promise<void>;
|
|
29
59
|
}
|
|
30
60
|
export { CouchbaseVector }
|
|
31
61
|
export { CouchbaseVector as CouchbaseVector_alias_1 }
|
|
32
62
|
|
|
63
|
+
declare type CouchbaseVectorParams = {
|
|
64
|
+
connectionString: string;
|
|
65
|
+
username: string;
|
|
66
|
+
password: string;
|
|
67
|
+
bucketName: string;
|
|
68
|
+
scopeName: string;
|
|
69
|
+
collectionName: string;
|
|
70
|
+
};
|
|
71
|
+
export { CouchbaseVectorParams }
|
|
72
|
+
export { CouchbaseVectorParams as CouchbaseVectorParams_alias_1 }
|
|
73
|
+
|
|
33
74
|
declare const DISTANCE_MAPPING: Record<MastraMetric, CouchbaseMetric>;
|
|
34
75
|
export { DISTANCE_MAPPING }
|
|
35
76
|
export { DISTANCE_MAPPING as DISTANCE_MAPPING_alias_1 }
|
|
@@ -1,9 +1,13 @@
|
|
|
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';
|
|
5
8
|
import type { QueryResult } from '@mastra/core/vector';
|
|
6
9
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
10
|
+
import type { UpdateVectorParams } from '@mastra/core/vector';
|
|
7
11
|
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
8
12
|
|
|
9
13
|
declare type CouchbaseMetric = 'cosine' | 'l2_norm' | 'dot_product';
|
|
@@ -18,18 +22,55 @@ declare class CouchbaseVector extends MastraVector {
|
|
|
18
22
|
private bucket;
|
|
19
23
|
private scope;
|
|
20
24
|
private vector_dimension;
|
|
21
|
-
constructor(
|
|
25
|
+
constructor({ connectionString, username, password, bucketName, scopeName, collectionName }: CouchbaseVectorParams);
|
|
22
26
|
getCollection(): Promise<Collection>;
|
|
23
|
-
createIndex(
|
|
24
|
-
upsert(
|
|
25
|
-
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[]>;
|
|
26
30
|
listIndexes(): Promise<string[]>;
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Retrieves statistics about a vector index.
|
|
33
|
+
*
|
|
34
|
+
* @param {string} indexName - The name of the index to describe
|
|
35
|
+
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
36
|
+
*/
|
|
37
|
+
describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
|
|
38
|
+
deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
41
|
+
* @param indexName - The name of the index containing the vector.
|
|
42
|
+
* @param id - The ID of the vector to update.
|
|
43
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
44
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
45
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
46
|
+
* @returns A promise that resolves when the update is complete.
|
|
47
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
48
|
+
*/
|
|
49
|
+
updateVector({ id, update }: UpdateVectorParams): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Deletes a vector by its ID.
|
|
52
|
+
* @param indexName - The name of the index containing the vector.
|
|
53
|
+
* @param id - The ID of the vector to delete.
|
|
54
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
55
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
56
|
+
*/
|
|
57
|
+
deleteVector({ id }: DeleteVectorParams): Promise<void>;
|
|
58
|
+
disconnect(): Promise<void>;
|
|
29
59
|
}
|
|
30
60
|
export { CouchbaseVector }
|
|
31
61
|
export { CouchbaseVector as CouchbaseVector_alias_1 }
|
|
32
62
|
|
|
63
|
+
declare type CouchbaseVectorParams = {
|
|
64
|
+
connectionString: string;
|
|
65
|
+
username: string;
|
|
66
|
+
password: string;
|
|
67
|
+
bucketName: string;
|
|
68
|
+
scopeName: string;
|
|
69
|
+
collectionName: string;
|
|
70
|
+
};
|
|
71
|
+
export { CouchbaseVectorParams }
|
|
72
|
+
export { CouchbaseVectorParams as CouchbaseVectorParams_alias_1 }
|
|
73
|
+
|
|
33
74
|
declare const DISTANCE_MAPPING: Record<MastraMetric, CouchbaseMetric>;
|
|
34
75
|
export { DISTANCE_MAPPING }
|
|
35
76
|
export { DISTANCE_MAPPING as DISTANCE_MAPPING_alias_1 }
|
package/dist/index.cjs
CHANGED
|
@@ -19,9 +19,9 @@ var CouchbaseVector = class extends vector.MastraVector {
|
|
|
19
19
|
bucket;
|
|
20
20
|
scope;
|
|
21
21
|
vector_dimension;
|
|
22
|
-
constructor(
|
|
22
|
+
constructor({ connectionString, username, password, bucketName, scopeName, collectionName }) {
|
|
23
23
|
super();
|
|
24
|
-
const baseClusterPromise = couchbase.connect(
|
|
24
|
+
const baseClusterPromise = couchbase.connect(connectionString, {
|
|
25
25
|
username,
|
|
26
26
|
password,
|
|
27
27
|
configProfile: "wanDevelopment"
|
|
@@ -53,8 +53,7 @@ var CouchbaseVector = class extends vector.MastraVector {
|
|
|
53
53
|
}
|
|
54
54
|
return this.collection;
|
|
55
55
|
}
|
|
56
|
-
async createIndex(
|
|
57
|
-
const { indexName, dimension, metric = "dotproduct" } = params;
|
|
56
|
+
async createIndex({ indexName, dimension, metric = "dotproduct" }) {
|
|
58
57
|
await this.getCollection();
|
|
59
58
|
if (!Number.isInteger(dimension) || dimension <= 0) {
|
|
60
59
|
throw new Error("Dimension must be a positive integer");
|
|
@@ -149,8 +148,7 @@ var CouchbaseVector = class extends vector.MastraVector {
|
|
|
149
148
|
throw error;
|
|
150
149
|
}
|
|
151
150
|
}
|
|
152
|
-
async upsert(
|
|
153
|
-
const { vectors, metadata, ids } = params;
|
|
151
|
+
async upsert({ vectors, metadata, ids }) {
|
|
154
152
|
await this.getCollection();
|
|
155
153
|
if (!vectors || vectors.length === 0) {
|
|
156
154
|
throw new Error("No vectors provided");
|
|
@@ -181,10 +179,9 @@ var CouchbaseVector = class extends vector.MastraVector {
|
|
|
181
179
|
await Promise.all(allPromises);
|
|
182
180
|
return pointIds;
|
|
183
181
|
}
|
|
184
|
-
async query(
|
|
185
|
-
const { indexName, queryVector, topK = 10, includeVector = false } = params;
|
|
182
|
+
async query({ indexName, queryVector, topK = 10, includeVector = false }) {
|
|
186
183
|
await this.getCollection();
|
|
187
|
-
const index_stats = await this.describeIndex(indexName);
|
|
184
|
+
const index_stats = await this.describeIndex({ indexName });
|
|
188
185
|
if (queryVector.length !== index_stats.dimension) {
|
|
189
186
|
throw new Error(`Query vector dimension mismatch. Expected ${index_stats.dimension}, got ${queryVector.length}`);
|
|
190
187
|
}
|
|
@@ -221,7 +218,13 @@ var CouchbaseVector = class extends vector.MastraVector {
|
|
|
221
218
|
const indexes = await this.scope.searchIndexes().getAllIndexes();
|
|
222
219
|
return indexes?.map((index) => index.name) || [];
|
|
223
220
|
}
|
|
224
|
-
|
|
221
|
+
/**
|
|
222
|
+
* Retrieves statistics about a vector index.
|
|
223
|
+
*
|
|
224
|
+
* @param {string} indexName - The name of the index to describe
|
|
225
|
+
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
226
|
+
*/
|
|
227
|
+
async describeIndex({ indexName }) {
|
|
225
228
|
await this.getCollection();
|
|
226
229
|
if (!(await this.listIndexes()).includes(indexName)) {
|
|
227
230
|
throw new Error(`Index ${indexName} does not exist`);
|
|
@@ -238,7 +241,7 @@ var CouchbaseVector = class extends vector.MastraVector {
|
|
|
238
241
|
)
|
|
239
242
|
};
|
|
240
243
|
}
|
|
241
|
-
async deleteIndex(indexName) {
|
|
244
|
+
async deleteIndex({ indexName }) {
|
|
242
245
|
await this.getCollection();
|
|
243
246
|
if (!(await this.listIndexes()).includes(indexName)) {
|
|
244
247
|
throw new Error(`Index ${indexName} does not exist`);
|
|
@@ -246,6 +249,62 @@ var CouchbaseVector = class extends vector.MastraVector {
|
|
|
246
249
|
await this.scope.searchIndexes().dropIndex(indexName);
|
|
247
250
|
this.vector_dimension = null;
|
|
248
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
254
|
+
* @param indexName - The name of the index containing the vector.
|
|
255
|
+
* @param id - The ID of the vector to update.
|
|
256
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
257
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
258
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
259
|
+
* @returns A promise that resolves when the update is complete.
|
|
260
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
261
|
+
*/
|
|
262
|
+
async updateVector({ id, update }) {
|
|
263
|
+
if (!update.vector && !update.metadata) {
|
|
264
|
+
throw new Error("No updates provided");
|
|
265
|
+
}
|
|
266
|
+
if (update.vector && this.vector_dimension && update.vector.length !== this.vector_dimension) {
|
|
267
|
+
throw new Error("Vector dimension mismatch");
|
|
268
|
+
}
|
|
269
|
+
const collection = await this.getCollection();
|
|
270
|
+
try {
|
|
271
|
+
await collection.get(id);
|
|
272
|
+
} catch (err) {
|
|
273
|
+
if (err.code === 13 || err.message?.includes("document not found")) {
|
|
274
|
+
throw new Error(`Vector with id ${id} does not exist`);
|
|
275
|
+
}
|
|
276
|
+
throw err;
|
|
277
|
+
}
|
|
278
|
+
const specs = [];
|
|
279
|
+
if (update.vector) specs.push(couchbase.MutateInSpec.replace("embedding", update.vector));
|
|
280
|
+
if (update.metadata) specs.push(couchbase.MutateInSpec.replace("metadata", update.metadata));
|
|
281
|
+
await collection.mutateIn(id, specs);
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Deletes a vector by its ID.
|
|
285
|
+
* @param indexName - The name of the index containing the vector.
|
|
286
|
+
* @param id - The ID of the vector to delete.
|
|
287
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
288
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
289
|
+
*/
|
|
290
|
+
async deleteVector({ id }) {
|
|
291
|
+
const collection = await this.getCollection();
|
|
292
|
+
try {
|
|
293
|
+
await collection.get(id);
|
|
294
|
+
} catch (err) {
|
|
295
|
+
if (err.code === 13 || err.message?.includes("document not found")) {
|
|
296
|
+
throw new Error(`Vector with id ${id} does not exist`);
|
|
297
|
+
}
|
|
298
|
+
throw err;
|
|
299
|
+
}
|
|
300
|
+
await collection.remove(id);
|
|
301
|
+
}
|
|
302
|
+
async disconnect() {
|
|
303
|
+
if (!this.cluster) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
await this.cluster.close();
|
|
307
|
+
}
|
|
249
308
|
};
|
|
250
309
|
|
|
251
310
|
exports.CouchbaseVector = CouchbaseVector;
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED