@mastra/couchbase 1.1.2 → 1.1.3
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/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-couchbase
|
|
|
3
3
|
description: Documentation for @mastra/couchbase. Use when working with @mastra/couchbase APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/couchbase"
|
|
6
|
-
version: "1.1.
|
|
6
|
+
version: "1.1.3"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -17,7 +17,7 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
17
17
|
### Reference
|
|
18
18
|
|
|
19
19
|
- [Storing embeddings in a vector database](references/reference-rag-vector-databases.md) - After generating embeddings, you need to store them in a database that supports vector similarity search.
|
|
20
|
-
- [Reference: Couchbase vector store](references/reference-vectors-couchbase.md) - The CouchbaseVector class provides vector search using Couchbase Vector Search. It enables efficient similarity search
|
|
20
|
+
- [Reference: Couchbase vector store](references/reference-vectors-couchbase.md) - The CouchbaseVector class provides vector search using Couchbase Vector Search. It enables efficient similarity search within your Couchbase collections.
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
Read [assets/SOURCE_MAP.json](assets/SOURCE_MAP.json) for source code references.
|
|
@@ -54,6 +54,29 @@ const results = await store.hybridQuery({
|
|
|
54
54
|
|
|
55
55
|
See the [MongoDB vector reference](https://mastra.ai/reference/vectors/mongodb) for details on `createSearchIndex()`, `textQuery()`, and `hybridQuery()`.
|
|
56
56
|
|
|
57
|
+
### Automated Embedding
|
|
58
|
+
|
|
59
|
+
MongoDB can generate the embeddings itself, so you don't need an embedding provider in your application. Create the index with `autoEmbed` and a Voyage AI model, write plain text, and search with a query string:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
await store.createIndex({
|
|
63
|
+
indexName: 'myCollection',
|
|
64
|
+
autoEmbed: { model: 'voyage-4' },
|
|
65
|
+
})
|
|
66
|
+
await store.upsert({
|
|
67
|
+
indexName: 'myCollection',
|
|
68
|
+
documents: chunks.map(chunk => chunk.text),
|
|
69
|
+
metadata: chunks.map(chunk => ({ text: chunk.text })),
|
|
70
|
+
})
|
|
71
|
+
const results = await store.query({
|
|
72
|
+
indexName: 'myCollection',
|
|
73
|
+
queryText: 'search terms',
|
|
74
|
+
topK: 10,
|
|
75
|
+
})
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Automated Embedding is a MongoDB Preview feature and needs a deployment where it's available. See the [MongoDB vector reference](https://mastra.ai/reference/vectors/mongodb) for the supported options and requirements.
|
|
79
|
+
|
|
57
80
|
**PgVector**:
|
|
58
81
|
|
|
59
82
|
```ts
|
|
@@ -207,7 +230,7 @@ await store.upsert({
|
|
|
207
230
|
**libSQL**:
|
|
208
231
|
|
|
209
232
|
```ts
|
|
210
|
-
import { LibSQLVector } from '@mastra/
|
|
233
|
+
import { LibSQLVector } from '@mastra/libsql'
|
|
211
234
|
|
|
212
235
|
const store = new LibSQLVector({
|
|
213
236
|
id: 'libsql-vector',
|
|
@@ -248,6 +271,34 @@ await store.upsert({
|
|
|
248
271
|
})
|
|
249
272
|
```
|
|
250
273
|
|
|
274
|
+
**Weaviate**:
|
|
275
|
+
|
|
276
|
+
```ts
|
|
277
|
+
import { WeaviateVector } from '@mastra/weaviate'
|
|
278
|
+
|
|
279
|
+
const store = new WeaviateVector({
|
|
280
|
+
id: 'weaviate-vector',
|
|
281
|
+
httpHost: process.env.WEAVIATE_HOST,
|
|
282
|
+
httpPort: 443,
|
|
283
|
+
httpSecure: true,
|
|
284
|
+
grpcHost: process.env.WEAVIATE_GRPC_HOST,
|
|
285
|
+
grpcPort: 443,
|
|
286
|
+
grpcSecure: true,
|
|
287
|
+
apiKey: process.env.WEAVIATE_API_KEY,
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
await store.createIndex({
|
|
291
|
+
indexName: 'myCollection',
|
|
292
|
+
dimension: 1536,
|
|
293
|
+
})
|
|
294
|
+
|
|
295
|
+
await store.upsert({
|
|
296
|
+
indexName: 'myCollection',
|
|
297
|
+
vectors: embeddings,
|
|
298
|
+
metadata: chunks.map(chunk => ({ text: chunk.text })),
|
|
299
|
+
})
|
|
300
|
+
```
|
|
301
|
+
|
|
251
302
|
**Cloudflare**:
|
|
252
303
|
|
|
253
304
|
```ts
|
|
@@ -317,6 +368,29 @@ await store.upsert({
|
|
|
317
368
|
|
|
318
369
|
For detailed setup instructions and best practices, see the [official Elasticsearch documentation](https://www.elastic.co/docs/solutions/search/get-started).
|
|
319
370
|
|
|
371
|
+
**Azure AI Search**:
|
|
372
|
+
|
|
373
|
+
```ts
|
|
374
|
+
import { AzureAISearchVector } from '@mastra/azure-ai-search'
|
|
375
|
+
|
|
376
|
+
const store = new AzureAISearchVector({
|
|
377
|
+
id: 'azure-search-vectors',
|
|
378
|
+
endpoint: process.env.AZURE_AI_SEARCH_ENDPOINT!,
|
|
379
|
+
credential: process.env.AZURE_AI_SEARCH_CREDENTIAL!,
|
|
380
|
+
})
|
|
381
|
+
|
|
382
|
+
await store.createIndex({
|
|
383
|
+
indexName: 'my-collection',
|
|
384
|
+
dimension: 1536,
|
|
385
|
+
})
|
|
386
|
+
|
|
387
|
+
await store.upsert({
|
|
388
|
+
indexName: 'my-collection',
|
|
389
|
+
vectors: embeddings,
|
|
390
|
+
metadata: chunks.map(chunk => ({ text: chunk.text })),
|
|
391
|
+
})
|
|
392
|
+
```
|
|
393
|
+
|
|
320
394
|
**Couchbase**:
|
|
321
395
|
|
|
322
396
|
```ts
|
|
@@ -534,6 +608,17 @@ Namespace names must:
|
|
|
534
608
|
|
|
535
609
|
- Example: `_namespace` isn't valid (starts with underscore)
|
|
536
610
|
|
|
611
|
+
**Weaviate**:
|
|
612
|
+
|
|
613
|
+
Index names map to Weaviate collections, which:
|
|
614
|
+
|
|
615
|
+
- Are capitalized by Weaviate (the first letter is upper-cased)
|
|
616
|
+
- Should contain only letters, numbers, and the `_` character
|
|
617
|
+
- Must start with a letter, since only the first character is upper-cased (a leading digit or symbol stays invalid)
|
|
618
|
+
- Preserve the original Mastra index name in the collection description, so `listIndexes()` and `describeIndex()` return the name you supplied
|
|
619
|
+
- Example: `my_collection` is stored as `My_collection` and returned as `my_collection`
|
|
620
|
+
- Example: `123_collection` isn't valid (starts with a digit)
|
|
621
|
+
|
|
537
622
|
**Cloudflare**:
|
|
538
623
|
|
|
539
624
|
Index names must:
|
|
@@ -587,6 +672,17 @@ Index names must:
|
|
|
587
672
|
- Example: `myindex-` isn't valid (ends with hyphen)
|
|
588
673
|
- Example: `MyIndex` isn't valid (contains uppercase letters)
|
|
589
674
|
|
|
675
|
+
**Azure AI Search**:
|
|
676
|
+
|
|
677
|
+
Index names must:
|
|
678
|
+
|
|
679
|
+
- Use only lowercase letters, numbers, dashes (`-`), and underscore (`_`) characters
|
|
680
|
+
- Not start or end with a dash
|
|
681
|
+
- Be between 2 and 128 characters long
|
|
682
|
+
- Example: `my-index-123` and `my_index` are valid
|
|
683
|
+
- Example: `MyIndex` isn't valid (contains uppercase letters)
|
|
684
|
+
- Example: `my-index-` isn't valid (ends with a dash)
|
|
685
|
+
|
|
590
686
|
### Upserting Embeddings
|
|
591
687
|
|
|
592
688
|
After creating an index, you can store embeddings along with their basic metadata:
|
|
@@ -650,7 +746,7 @@ Key metadata considerations:
|
|
|
650
746
|
|
|
651
747
|
## Deleting vectors
|
|
652
748
|
|
|
653
|
-
|
|
749
|
+
Use `deleteVectors` with a metadata filter to remove embeddings associated with a document. This is useful for cleaning up stale vectors after a document is deleted or updated.
|
|
654
750
|
|
|
655
751
|
### Delete by Metadata Filter
|
|
656
752
|
|
|
@@ -69,8 +69,6 @@ const store = new CouchbaseVector({
|
|
|
69
69
|
|
|
70
70
|
**collectionName** (`string`): Name of the Couchbase collection to use
|
|
71
71
|
|
|
72
|
-
**options** (`CouchbaseClientOptions`): Optional Couchbase client options
|
|
73
|
-
|
|
74
72
|
## Methods
|
|
75
73
|
|
|
76
74
|
### `createIndex()`
|
|
@@ -83,7 +81,7 @@ Creates a new vector index in Couchbase.
|
|
|
83
81
|
|
|
84
82
|
**dimension** (`number`): Vector dimension (must match your embedding model)
|
|
85
83
|
|
|
86
|
-
**metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `
|
|
84
|
+
**metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `dotproduct`)
|
|
87
85
|
|
|
88
86
|
### `upsert()`
|
|
89
87
|
|
|
@@ -111,11 +109,9 @@ Searches for similar vectors.
|
|
|
111
109
|
|
|
112
110
|
**topK** (`number`): Number of results to return (Default: `10`)
|
|
113
111
|
|
|
114
|
-
**filter** (`Record<string, any>`):
|
|
115
|
-
|
|
116
|
-
**includeVector** (`boolean`): Whether to include vector data in results (Default: `false`)
|
|
112
|
+
**filter** (`Record<string, any>`): Not supported. Filters passed here are ignored.
|
|
117
113
|
|
|
118
|
-
**
|
|
114
|
+
**includeVector** (`boolean`): Not supported. Setting this to true throws an error. (Default: `false`)
|
|
119
115
|
|
|
120
116
|
### `describeIndex()`
|
|
121
117
|
|
|
@@ -135,7 +131,7 @@ interface IndexStats {
|
|
|
135
131
|
|
|
136
132
|
### `deleteIndex()`
|
|
137
133
|
|
|
138
|
-
Deletes
|
|
134
|
+
Deletes the Search index. Documents stored in the collection aren't deleted.
|
|
139
135
|
|
|
140
136
|
**indexName** (`string`): Name of the index to delete
|
|
141
137
|
|
|
@@ -184,7 +180,6 @@ interface QueryResult {
|
|
|
184
180
|
id: string
|
|
185
181
|
score: number
|
|
186
182
|
metadata: Record<string, any>
|
|
187
|
-
vector?: number[] // Only included if includeVector is true
|
|
188
183
|
}
|
|
189
184
|
```
|
|
190
185
|
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["MastraVector","MastraError","ErrorDomain","ErrorCategory","SearchRequest","VectorSearch","VectorQuery","MutateInSpec"],"sources":["../src/vector/index.ts"],"sourcesContent":["import { ErrorCategory, ErrorDomain, MastraError } from '@mastra/core/error';\nimport { createVectorErrorId } from '@mastra/core/storage';\nimport { MastraVector } from '@mastra/core/vector';\nimport type {\n QueryResult,\n IndexStats,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n UpdateVectorParams,\n DeleteVectorsParams,\n} from '@mastra/core/vector';\nimport type { Bucket, Cluster, Collection, Scope } from 'couchbase';\nimport { MutateInSpec, connect, SearchRequest, VectorQuery, VectorSearch } from 'couchbase';\n\ntype MastraMetric = 'cosine' | 'euclidean' | 'dotproduct';\ntype CouchbaseMetric = 'cosine' | 'l2_norm' | 'dot_product';\nexport const DISTANCE_MAPPING: Record<MastraMetric, CouchbaseMetric> = {\n cosine: 'cosine',\n euclidean: 'l2_norm',\n dotproduct: 'dot_product',\n};\n\nexport type CouchbaseVectorParams = {\n connectionString: string;\n username: string;\n password: string;\n bucketName: string;\n scopeName: string;\n collectionName: string;\n};\n\nexport class CouchbaseVector extends MastraVector {\n private clusterPromise: Promise<Cluster>;\n private cluster: Cluster;\n private bucketName: string;\n private collectionName: string;\n private scopeName: string;\n private collection: Collection;\n private bucket: Bucket;\n private scope: Scope;\n private vector_dimension: number;\n\n constructor({\n id,\n connectionString,\n username,\n password,\n bucketName,\n scopeName,\n collectionName,\n }: CouchbaseVectorParams & { id: string }) {\n super({ id });\n\n try {\n this.clusterPromise = connect(connectionString, {\n username,\n password,\n configProfile: 'wanDevelopment',\n });\n this.cluster = null as unknown as Cluster;\n this.bucketName = bucketName;\n this.collectionName = collectionName;\n this.scopeName = scopeName;\n this.collection = null as unknown as Collection;\n this.bucket = null as unknown as Bucket;\n this.scope = null as unknown as Scope;\n this.vector_dimension = null as unknown as number;\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('COUCHBASE', 'INITIALIZE', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n connectionString,\n username,\n bucketName,\n scopeName,\n collectionName,\n },\n },\n error,\n );\n }\n }\n\n async getCollection() {\n if (!this.cluster) {\n this.cluster = await this.clusterPromise;\n }\n\n if (!this.collection) {\n this.bucket = this.cluster.bucket(this.bucketName);\n this.scope = this.bucket.scope(this.scopeName);\n this.collection = this.scope.collection(this.collectionName);\n }\n\n return this.collection;\n }\n\n async createIndex({ indexName, dimension, metric = 'dotproduct' as MastraMetric }: CreateIndexParams): Promise<void> {\n try {\n await this.getCollection();\n\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new Error('Dimension must be a positive integer');\n }\n\n await this.scope.searchIndexes().upsertIndex({\n name: indexName,\n sourceName: this.bucketName,\n type: 'fulltext-index',\n params: {\n doc_config: {\n docid_prefix_delim: '',\n docid_regexp: '',\n mode: 'scope.collection.type_field',\n type_field: 'type',\n },\n mapping: {\n default_analyzer: 'standard',\n default_datetime_parser: 'dateTimeOptional',\n default_field: '_all',\n default_mapping: {\n dynamic: true,\n enabled: false,\n },\n default_type: '_default',\n docvalues_dynamic: true, // [Doc](https://docs.couchbase.com/server/current/search/search-index-params.html#params) mentions this attribute is required for vector search to return the indexed field\n index_dynamic: true,\n store_dynamic: true, // [Doc](https://docs.couchbase.com/server/current/search/search-index-params.html#params) mentions this attribute is required for vector search to return the indexed field\n type_field: '_type',\n types: {\n [`${this.scopeName}.${this.collectionName}`]: {\n dynamic: true,\n enabled: true,\n properties: {\n embedding: {\n enabled: true,\n fields: [\n {\n dims: dimension,\n index: true,\n name: 'embedding',\n similarity: DISTANCE_MAPPING[metric],\n type: 'vector',\n vector_index_optimized_for: 'recall',\n store: true, // CHANGED due to https://docs.couchbase.com/server/current/search/search-index-params.html#fields\n docvalues: true, // CHANGED due to https://docs.couchbase.com/server/current/search/search-index-params.html#fields\n include_term_vectors: true, // CHANGED due to https://docs.couchbase.com/server/current/search/search-index-params.html#fields\n },\n ],\n },\n content: {\n enabled: true,\n fields: [\n {\n index: true,\n name: 'content',\n store: true,\n type: 'text',\n },\n ],\n },\n },\n },\n },\n },\n store: {\n indexType: 'scorch',\n segmentVersion: 16,\n },\n },\n sourceUuid: '',\n sourceParams: {},\n sourceType: 'gocbcore',\n planParams: {\n maxPartitionsPerPIndex: 64,\n indexPartitions: 16,\n numReplicas: 0,\n },\n });\n this.vector_dimension = dimension;\n } catch (error: any) {\n // Check for 'already exists' error (Couchbase may throw a 400 or 409, or have a message)\n const message = error?.message || error?.toString();\n if (message && message.toLowerCase().includes('index exists')) {\n // Fetch index info and check dimension\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n throw new MastraError(\n {\n id: createVectorErrorId('COUCHBASE', 'CREATE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n dimension,\n metric,\n },\n },\n error,\n );\n }\n }\n\n async upsert({ vectors, metadata, ids }: UpsertVectorParams): Promise<string[]> {\n try {\n await this.getCollection();\n\n if (!vectors || vectors.length === 0) {\n throw new Error('No vectors provided');\n }\n if (this.vector_dimension) {\n for (const vector of vectors) {\n if (!vector || this.vector_dimension !== vector.length) {\n throw new Error('Vector dimension mismatch');\n }\n }\n }\n\n const pointIds = ids || vectors.map(() => crypto.randomUUID());\n const records = vectors.map((vector, i) => {\n const metadataObj = metadata?.[i] || {};\n const record: Record<string, any> = {\n embedding: vector,\n metadata: metadataObj,\n };\n // If metadata has a text field, save it as content\n if (metadataObj.text) {\n record.content = metadataObj.text;\n }\n return record;\n });\n\n const allPromises = [];\n for (let i = 0; i < records.length; i++) {\n allPromises.push(this.collection.upsert(pointIds[i]!, records[i]));\n }\n await Promise.all(allPromises);\n\n return pointIds;\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('COUCHBASE', 'UPSERT', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n async query({ indexName, queryVector, topK = 10, includeVector = false }: QueryVectorParams): Promise<QueryResult[]> {\n if (!queryVector) {\n throw new MastraError({\n id: createVectorErrorId('COUCHBASE', 'QUERY', 'MISSING_VECTOR'),\n text: 'queryVector is required for Couchbase queries. Metadata-only queries are not supported by this vector store.',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n await this.getCollection();\n\n const index_stats = await this.describeIndex({ indexName });\n if (queryVector.length !== index_stats.dimension) {\n throw new Error(\n `Query vector dimension mismatch. Expected ${index_stats.dimension}, got ${queryVector.length}`,\n );\n }\n\n let request = SearchRequest.create(\n VectorSearch.fromVectorQuery(VectorQuery.create('embedding', queryVector).numCandidates(topK)),\n );\n const results = await this.scope.search(indexName, request, {\n fields: ['*'],\n });\n\n if (includeVector) {\n throw new Error('Including vectors in search results is not yet supported by the Couchbase vector store');\n }\n const output = [];\n for (const match of results.rows) {\n const cleanedMetadata: Record<string, any> = {};\n const fields = (match.fields as Record<string, any>) || {}; // Ensure fields is an object\n for (const key in fields) {\n if (Object.prototype.hasOwnProperty.call(fields, key)) {\n const newKey = key.startsWith('metadata.') ? key.substring('metadata.'.length) : key;\n cleanedMetadata[newKey] = fields[key];\n }\n }\n output.push({\n id: match.id as string,\n score: (match.score as number) || 0,\n metadata: cleanedMetadata, // Use the cleaned metadata object\n });\n }\n return output;\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('COUCHBASE', 'QUERY', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n topK,\n },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n await this.getCollection();\n const indexes = await this.scope.searchIndexes().getAllIndexes();\n return indexes?.map(index => index.name) || [];\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('COUCHBASE', 'LIST_INDEXES', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n /**\n * Retrieves statistics about a vector index.\n *\n * @param {string} indexName - The name of the index to describe\n * @returns A promise that resolves to the index statistics including dimension, count and metric\n */\n async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {\n try {\n await this.getCollection();\n if (!(await this.listIndexes()).includes(indexName)) {\n throw new Error(`Index ${indexName} does not exist`);\n }\n const index = await this.scope.searchIndexes().getIndex(indexName);\n const dimensions =\n index.params.mapping?.types?.[`${this.scopeName}.${this.collectionName}`]?.properties?.embedding?.fields?.[0]\n ?.dims;\n\n const count = -1; // Not added support yet for adding a count of documents covered by an index\n\n const metric = index.params.mapping?.types?.[`${this.scopeName}.${this.collectionName}`]?.properties?.embedding\n ?.fields?.[0]?.similarity as CouchbaseMetric;\n return {\n dimension: dimensions,\n count: count,\n metric: Object.keys(DISTANCE_MAPPING).find(\n key => DISTANCE_MAPPING[key as MastraMetric] === metric,\n ) as MastraMetric,\n };\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('COUCHBASE', 'DESCRIBE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.getCollection();\n if (!(await this.listIndexes()).includes(indexName)) {\n throw new Error(`Index ${indexName} does not exist`);\n }\n await this.scope.searchIndexes().dropIndex(indexName);\n this.vector_dimension = null as unknown as number;\n } catch (error) {\n if (error instanceof MastraError) {\n throw error;\n }\n throw new MastraError(\n {\n id: createVectorErrorId('COUCHBASE', 'DELETE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID with the provided vector and/or metadata.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to update.\n * @param update - An object containing the vector and/or metadata to update.\n * @param update.vector - An optional array of numbers representing the new vector.\n * @param update.metadata - An optional record containing the new metadata.\n * @returns A promise that resolves when the update is complete.\n * @throws Will throw an error if no updates are provided or if the update operation fails.\n */\n async updateVector({ id, update }: UpdateVectorParams): Promise<void> {\n if (!id) {\n throw new MastraError({\n id: createVectorErrorId('COUCHBASE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: 'id is required for Couchbase updateVector',\n details: {},\n });\n }\n\n try {\n if (!update.vector && !update.metadata) {\n throw new Error('No updates provided');\n }\n if (update.vector && this.vector_dimension && update.vector.length !== this.vector_dimension) {\n throw new Error('Vector dimension mismatch');\n }\n const collection = await this.getCollection();\n\n // Check if document exists\n try {\n await collection.get(id);\n } catch (err: any) {\n if (err.code === 13 || err.message?.includes('document not found')) {\n throw new Error(`Vector with id ${id} does not exist`);\n }\n throw err;\n }\n\n const specs: MutateInSpec[] = [];\n if (update.vector) specs.push(MutateInSpec.replace('embedding', update.vector));\n if (update.metadata) specs.push(MutateInSpec.replace('metadata', update.metadata));\n\n await collection.mutateIn(id, specs);\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('COUCHBASE', 'UPDATE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n ...(id && { id }),\n hasVectorUpdate: !!update.vector,\n hasMetadataUpdate: !!update.metadata,\n },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes a vector by its ID.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to delete.\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if the deletion operation fails.\n */\n async deleteVector({ id }: DeleteVectorParams): Promise<void> {\n try {\n const collection = await this.getCollection();\n\n // Check if document exists\n try {\n await collection.get(id);\n } catch (err: any) {\n if (err.code === 13 || err.message?.includes('document not found')) {\n throw new Error(`Vector with id ${id} does not exist`);\n }\n throw err;\n }\n\n await collection.remove(id);\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('COUCHBASE', 'DELETE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n ...(id && { id }),\n },\n },\n error,\n );\n }\n }\n\n async deleteVectors({ indexName, filter, ids }: DeleteVectorsParams): Promise<void> {\n throw new MastraError({\n id: createVectorErrorId('COUCHBASE', 'DELETE_VECTORS', 'NOT_SUPPORTED'),\n text: 'deleteVectors is not yet implemented for Couchbase vector store',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.SYSTEM,\n details: {\n indexName,\n ...(filter && { filter: JSON.stringify(filter) }),\n ...(ids && { idsCount: ids.length }),\n },\n });\n }\n\n async disconnect() {\n try {\n if (!this.cluster) {\n return;\n }\n await this.cluster.close();\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('COUCHBASE', 'DISCONNECT', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n}\n"],"mappings":";;;;;;AAoBA,MAAa,mBAA0D;CACrE,QAAQ;CACR,WAAW;CACX,YAAY;AACd;AAWA,IAAa,kBAAb,cAAqCA,oBAAAA,aAAa;CAChD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,EACV,IACA,kBACA,UACA,UACA,YACA,WACA,kBACyC;EACzC,MAAM,EAAE,GAAG,CAAC;EAEZ,IAAI;GACF,KAAK,kBAAA,GAAA,UAAA,QAAA,CAAyB,kBAAkB;IAC9C;IACA;IACA,eAAe;GACjB,CAAC;GACD,KAAK,UAAU;GACf,KAAK,aAAa;GAClB,KAAK,iBAAiB;GACtB,KAAK,YAAY;GACjB,KAAK,aAAa;GAClB,KAAK,SAAS;GACd,KAAK,QAAQ;GACb,KAAK,mBAAmB;EAC1B,SAAS,OAAO;GACd,MAAM,IAAIC,mBAAAA,YACR;IACE,KAAA,GAAA,qBAAA,o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AQC,mBAAAA,YAAY;IACpB,UAAUC,mBAAAA,cAAc;IACxB,SAAS,EACP,GAAI,MAAM,EAAE,GAAG,EACjB;GACF,GACA,KACF;EACF;CACF;CAEA,MAAM,cAAc,EAAE,WAAW,QAAQ,OAA2C;EAClF,MAAM,IAAIF,mBAAAA,YAAY;GACpB,KAAA,GAAA,qBAAA,oBAAA,CAAwB,aAAa,kBAAkB,eAAe;GACtE,MAAM;GACN,QAAQC,mBAAAA,YAAY;GACpB,UAAUC,mBAAAA,cAAc;GACxB,SAAS;IACP;IACA,GAAI,UAAU,EAAE,QAAQ,KAAK,UAAU,MAAM,EAAE;IAC/C,GAAI,OAAO,EAAE,UAAU,IAAI,OAAO;GACpC;EACF,CAAC;CACH;CAEA,MAAM,aAAa;EACjB,IAAI;GACF,IAAI,CAAC,KAAK,SACR;GAEF,MAAM,KAAK,QAAQ,MAAM;EAC3B,SAAS,OAAO;GACd,MAAM,IAAIF,mBAAAA,YACR;IACE,KAAA,GAAA,qBAAA,oBAAA,CAAwB,aAAa,cAAc,QAAQ;IAC3D,QAAQC,mBAAAA,YAAY;IACpB,UAAUC,mBAAAA,cAAc;GAC1B,GACA,KACF;EACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["MastraVector","connect","MastraError","createVectorErrorId","ErrorDomain","ErrorCategory","SearchRequest","VectorSearch","VectorQuery","MutateInSpec"],"sources":["../src/vector/index.ts"],"sourcesContent":["import { ErrorCategory, ErrorDomain, MastraError } from '@mastra/core/error';\nimport { createVectorErrorId } from '@mastra/core/storage';\nimport { MastraVector } from '@mastra/core/vector';\nimport type {\n QueryResult,\n IndexStats,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n UpdateVectorParams,\n DeleteVectorsParams,\n} from '@mastra/core/vector';\nimport type { Bucket, Cluster, Collection, Scope } from 'couchbase';\nimport { MutateInSpec, connect, SearchRequest, VectorQuery, VectorSearch } from 'couchbase';\n\ntype MastraMetric = 'cosine' | 'euclidean' | 'dotproduct';\ntype CouchbaseMetric = 'cosine' | 'l2_norm' | 'dot_product';\nexport const DISTANCE_MAPPING: Record<MastraMetric, CouchbaseMetric> = {\n cosine: 'cosine',\n euclidean: 'l2_norm',\n dotproduct: 'dot_product',\n};\n\nexport type CouchbaseVectorParams = {\n connectionString: string;\n username: string;\n password: string;\n bucketName: string;\n scopeName: string;\n collectionName: string;\n};\n\nexport class CouchbaseVector extends MastraVector {\n private clusterPromise: Promise<Cluster>;\n private cluster: Cluster;\n private bucketName: string;\n private collectionName: string;\n private scopeName: string;\n private collection: Collection;\n private bucket: Bucket;\n private scope: Scope;\n private vector_dimension: number;\n\n constructor({\n id,\n connectionString,\n username,\n password,\n bucketName,\n scopeName,\n collectionName,\n }: CouchbaseVectorParams & { id: string }) {\n super({ id });\n\n try {\n this.clusterPromise = connect(connectionString, {\n username,\n password,\n configProfile: 'wanDevelopment',\n });\n this.cluster = null as unknown as Cluster;\n this.bucketName = bucketName;\n this.collectionName = collectionName;\n this.scopeName = scopeName;\n this.collection = null as unknown as Collection;\n this.bucket = null as unknown as Bucket;\n this.scope = null as unknown as Scope;\n this.vector_dimension = null as unknown as number;\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('COUCHBASE', 'INITIALIZE', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n connectionString,\n username,\n bucketName,\n scopeName,\n collectionName,\n },\n },\n error,\n );\n }\n }\n\n async getCollection() {\n if (!this.cluster) {\n this.cluster = await this.clusterPromise;\n }\n\n if (!this.collection) {\n this.bucket = this.cluster.bucket(this.bucketName);\n this.scope = this.bucket.scope(this.scopeName);\n this.collection = this.scope.collection(this.collectionName);\n }\n\n return this.collection;\n }\n\n async createIndex({ indexName, dimension, metric = 'dotproduct' as MastraMetric }: CreateIndexParams): Promise<void> {\n try {\n await this.getCollection();\n\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new Error('Dimension must be a positive integer');\n }\n\n await this.scope.searchIndexes().upsertIndex({\n name: indexName,\n sourceName: this.bucketName,\n type: 'fulltext-index',\n params: {\n doc_config: {\n docid_prefix_delim: '',\n docid_regexp: '',\n mode: 'scope.collection.type_field',\n type_field: 'type',\n },\n mapping: {\n default_analyzer: 'standard',\n default_datetime_parser: 'dateTimeOptional',\n default_field: '_all',\n default_mapping: {\n dynamic: true,\n enabled: false,\n },\n default_type: '_default',\n docvalues_dynamic: true, // [Doc](https://docs.couchbase.com/server/current/search/search-index-params.html#params) mentions this attribute is required for vector search to return the indexed field\n index_dynamic: true,\n store_dynamic: true, // [Doc](https://docs.couchbase.com/server/current/search/search-index-params.html#params) mentions this attribute is required for vector search to return the indexed field\n type_field: '_type',\n types: {\n [`${this.scopeName}.${this.collectionName}`]: {\n dynamic: true,\n enabled: true,\n properties: {\n embedding: {\n enabled: true,\n fields: [\n {\n dims: dimension,\n index: true,\n name: 'embedding',\n similarity: DISTANCE_MAPPING[metric],\n type: 'vector',\n vector_index_optimized_for: 'recall',\n store: true, // CHANGED due to https://docs.couchbase.com/server/current/search/search-index-params.html#fields\n docvalues: true, // CHANGED due to https://docs.couchbase.com/server/current/search/search-index-params.html#fields\n include_term_vectors: true, // CHANGED due to https://docs.couchbase.com/server/current/search/search-index-params.html#fields\n },\n ],\n },\n content: {\n enabled: true,\n fields: [\n {\n index: true,\n name: 'content',\n store: true,\n type: 'text',\n },\n ],\n },\n },\n },\n },\n },\n store: {\n indexType: 'scorch',\n segmentVersion: 16,\n },\n },\n sourceUuid: '',\n sourceParams: {},\n sourceType: 'gocbcore',\n planParams: {\n maxPartitionsPerPIndex: 64,\n indexPartitions: 16,\n numReplicas: 0,\n },\n });\n this.vector_dimension = dimension;\n } catch (error: any) {\n // Check for 'already exists' error (Couchbase may throw a 400 or 409, or have a message)\n const message = error?.message || error?.toString();\n if (message && message.toLowerCase().includes('index exists')) {\n // Fetch index info and check dimension\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n throw new MastraError(\n {\n id: createVectorErrorId('COUCHBASE', 'CREATE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n dimension,\n metric,\n },\n },\n error,\n );\n }\n }\n\n async upsert({ vectors, metadata, ids }: UpsertVectorParams): Promise<string[]> {\n try {\n await this.getCollection();\n\n if (!vectors || vectors.length === 0) {\n throw new Error('No vectors provided');\n }\n if (this.vector_dimension) {\n for (const vector of vectors) {\n if (!vector || this.vector_dimension !== vector.length) {\n throw new Error('Vector dimension mismatch');\n }\n }\n }\n\n const pointIds = ids || vectors.map(() => crypto.randomUUID());\n const records = vectors.map((vector, i) => {\n const metadataObj = metadata?.[i] || {};\n const record: Record<string, any> = {\n embedding: vector,\n metadata: metadataObj,\n };\n // If metadata has a text field, save it as content\n if (metadataObj.text) {\n record.content = metadataObj.text;\n }\n return record;\n });\n\n const allPromises = [];\n for (let i = 0; i < records.length; i++) {\n allPromises.push(this.collection.upsert(pointIds[i]!, records[i]));\n }\n await Promise.all(allPromises);\n\n return pointIds;\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('COUCHBASE', 'UPSERT', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n async query({ indexName, queryVector, topK = 10, includeVector = false }: QueryVectorParams): Promise<QueryResult[]> {\n if (!queryVector) {\n throw new MastraError({\n id: createVectorErrorId('COUCHBASE', 'QUERY', 'MISSING_VECTOR'),\n text: 'queryVector is required for Couchbase queries. Metadata-only queries are not supported by this vector store.',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n await this.getCollection();\n\n const index_stats = await this.describeIndex({ indexName });\n if (queryVector.length !== index_stats.dimension) {\n throw new Error(\n `Query vector dimension mismatch. Expected ${index_stats.dimension}, got ${queryVector.length}`,\n );\n }\n\n let request = SearchRequest.create(\n VectorSearch.fromVectorQuery(VectorQuery.create('embedding', queryVector).numCandidates(topK)),\n );\n const results = await this.scope.search(indexName, request, {\n fields: ['*'],\n });\n\n if (includeVector) {\n throw new Error('Including vectors in search results is not yet supported by the Couchbase vector store');\n }\n const output = [];\n for (const match of results.rows) {\n const cleanedMetadata: Record<string, any> = {};\n const fields = (match.fields as Record<string, any>) || {}; // Ensure fields is an object\n for (const key in fields) {\n if (Object.prototype.hasOwnProperty.call(fields, key)) {\n const newKey = key.startsWith('metadata.') ? key.substring('metadata.'.length) : key;\n cleanedMetadata[newKey] = fields[key];\n }\n }\n output.push({\n id: match.id as string,\n score: (match.score as number) || 0,\n metadata: cleanedMetadata, // Use the cleaned metadata object\n });\n }\n return output;\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('COUCHBASE', 'QUERY', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n topK,\n },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n await this.getCollection();\n const indexes = await this.scope.searchIndexes().getAllIndexes();\n return indexes?.map(index => index.name) || [];\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('COUCHBASE', 'LIST_INDEXES', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n /**\n * Retrieves statistics about a vector index.\n *\n * @param {string} indexName - The name of the index to describe\n * @returns A promise that resolves to the index statistics including dimension, count and metric\n */\n async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {\n try {\n await this.getCollection();\n if (!(await this.listIndexes()).includes(indexName)) {\n throw new Error(`Index ${indexName} does not exist`);\n }\n const index = await this.scope.searchIndexes().getIndex(indexName);\n const dimensions =\n index.params.mapping?.types?.[`${this.scopeName}.${this.collectionName}`]?.properties?.embedding?.fields?.[0]\n ?.dims;\n\n const count = -1; // Not added support yet for adding a count of documents covered by an index\n\n const metric = index.params.mapping?.types?.[`${this.scopeName}.${this.collectionName}`]?.properties?.embedding\n ?.fields?.[0]?.similarity as CouchbaseMetric;\n return {\n dimension: dimensions,\n count: count,\n metric: Object.keys(DISTANCE_MAPPING).find(\n key => DISTANCE_MAPPING[key as MastraMetric] === metric,\n ) as MastraMetric,\n };\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('COUCHBASE', 'DESCRIBE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.getCollection();\n if (!(await this.listIndexes()).includes(indexName)) {\n throw new Error(`Index ${indexName} does not exist`);\n }\n await this.scope.searchIndexes().dropIndex(indexName);\n this.vector_dimension = null as unknown as number;\n } catch (error) {\n if (error instanceof MastraError) {\n throw error;\n }\n throw new MastraError(\n {\n id: createVectorErrorId('COUCHBASE', 'DELETE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID with the provided vector and/or metadata.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to update.\n * @param update - An object containing the vector and/or metadata to update.\n * @param update.vector - An optional array of numbers representing the new vector.\n * @param update.metadata - An optional record containing the new metadata.\n * @returns A promise that resolves when the update is complete.\n * @throws Will throw an error if no updates are provided or if the update operation fails.\n */\n async updateVector({ id, update }: UpdateVectorParams): Promise<void> {\n if (!id) {\n throw new MastraError({\n id: createVectorErrorId('COUCHBASE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: 'id is required for Couchbase updateVector',\n details: {},\n });\n }\n\n try {\n if (!update.vector && !update.metadata) {\n throw new Error('No updates provided');\n }\n if (update.vector && this.vector_dimension && update.vector.length !== this.vector_dimension) {\n throw new Error('Vector dimension mismatch');\n }\n const collection = await this.getCollection();\n\n // Check if document exists\n try {\n await collection.get(id);\n } catch (err: any) {\n if (err.code === 13 || err.message?.includes('document not found')) {\n throw new Error(`Vector with id ${id} does not exist`);\n }\n throw err;\n }\n\n const specs: MutateInSpec[] = [];\n if (update.vector) specs.push(MutateInSpec.replace('embedding', update.vector));\n if (update.metadata) specs.push(MutateInSpec.replace('metadata', update.metadata));\n\n await collection.mutateIn(id, specs);\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('COUCHBASE', 'UPDATE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n ...(id && { id }),\n hasVectorUpdate: !!update.vector,\n hasMetadataUpdate: !!update.metadata,\n },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes a vector by its ID.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to delete.\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if the deletion operation fails.\n */\n async deleteVector({ id }: DeleteVectorParams): Promise<void> {\n try {\n const collection = await this.getCollection();\n\n // Check if document exists\n try {\n await collection.get(id);\n } catch (err: any) {\n if (err.code === 13 || err.message?.includes('document not found')) {\n throw new Error(`Vector with id ${id} does not exist`);\n }\n throw err;\n }\n\n await collection.remove(id);\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('COUCHBASE', 'DELETE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n ...(id && { id }),\n },\n },\n error,\n );\n }\n }\n\n async deleteVectors({ indexName, filter, ids }: DeleteVectorsParams): Promise<void> {\n throw new MastraError({\n id: createVectorErrorId('COUCHBASE', 'DELETE_VECTORS', 'NOT_SUPPORTED'),\n text: 'deleteVectors is not yet implemented for Couchbase vector store',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.SYSTEM,\n details: {\n indexName,\n ...(filter && { filter: JSON.stringify(filter) }),\n ...(ids && { idsCount: ids.length }),\n },\n });\n }\n\n async disconnect() {\n try {\n if (!this.cluster) {\n return;\n }\n await this.cluster.close();\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('COUCHBASE', 'DISCONNECT', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n}\n"],"mappings":";;;;;;AAoBA,MAAa,mBAA0D;CACrE,QAAQ;CACR,WAAW;CACX,YAAY;AACd;AAWA,IAAa,kBAAb,cAAqCA,oBAAAA,aAAa;CAChD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,EACV,IACA,kBACA,UACA,UACA,YACA,WACA,kBACyC;EACzC,MAAM,EAAE,GAAG,CAAC;EAEZ,IAAI;GACF,KAAK,kBAAA,GAAiBC,UAAAA,QAAAA,CAAQ,kBAAkB;IAC9C;IACA;IACA,eAAe;GACjB,CAAC;GACD,KAAK,UAAU;GACf,KAAK,aAAa;GAClB,KAAK,iBAAiB;GACtB,KAAK,YAAY;GACjB,KAAK,aAAa;GAClB,KAAK,SAAS;GACd,KAAK,QAAQ;GACb,KAAK,mBAAmB;EAC1B,SAAS,OAAO;GACd,MAAM,IAAIC,mBAAAA,YACR;IACE,KAAA,GAAIC,qBAAAA,oBAAAA,CAAoB,aAAa,cAAc,QAAQ;IAC3D,QAAQC,mBAAAA,YAAY;IACpB,UAAUC,mBAAAA,cAAc;IACxB,SAAS;KACP;KACA;KACA;KACA;KACA;IACF;GACF,GACA,KACF;EACF;CACF;CAEA,MAAM,gBAAgB;EACpB,IAAI,CAAC,KAAK,SACR,KAAK,UAAU,MAAM,KAAK;EAG5B,IAAI,CAAC,KAAK,YAAY;GACpB,KAAK,SAAS,KAAK,QAAQ,OAAO,KAAK,UAAU;GACjD,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,SAAS;GAC7C,KAAK,aAAa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ACP;IACA,GAAI,UAAU,EAAE,QAAQ,KAAK,UAAU,MAAM,EAAE;IAC/C,GAAI,OAAO,EAAE,UAAU,IAAI,OAAO;GACpC;EACF,CAAC;CACH;CAEA,MAAM,aAAa;EACjB,IAAI;GACF,IAAI,CAAC,KAAK,SACR;GAEF,MAAM,KAAK,QAAQ,MAAM;EAC3B,SAAS,OAAO;GACd,MAAM,IAAIH,mBAAAA,YACR;IACE,KAAA,GAAIC,qBAAAA,oBAAAA,CAAoB,aAAa,cAAc,QAAQ;IAC3D,QAAQC,mBAAAA,YAAY;IACpB,UAAUC,mBAAAA,cAAc;GAC1B,GACA,KACF;EACF;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/couchbase",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Couchbase vector store provider for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,17 +23,16 @@
|
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "22.20.1",
|
|
26
|
-
"@vitest/coverage-v8": "4.1.
|
|
27
|
-
"@vitest/ui": "4.1.
|
|
28
|
-
"eslint": "^10.7.0",
|
|
26
|
+
"@vitest/coverage-v8": "4.1.11",
|
|
27
|
+
"@vitest/ui": "4.1.11",
|
|
29
28
|
"tsdown": "0.22.9",
|
|
30
29
|
"tsx": "^4.23.1",
|
|
31
30
|
"typescript": "^7.0.2",
|
|
32
|
-
"vitest": "4.1.
|
|
33
|
-
"@internal/lint": "0.0.
|
|
34
|
-
"@internal/storage-test-utils": "0.0.
|
|
35
|
-
"@internal/types-builder": "0.0.
|
|
36
|
-
"@mastra/core": "1.
|
|
31
|
+
"vitest": "4.1.11",
|
|
32
|
+
"@internal/lint": "0.0.145",
|
|
33
|
+
"@internal/storage-test-utils": "0.0.141",
|
|
34
|
+
"@internal/types-builder": "0.0.120",
|
|
35
|
+
"@mastra/core": "1.79.0"
|
|
37
36
|
},
|
|
38
37
|
"peerDependencies": {
|
|
39
38
|
"@mastra/core": ">=1.0.0-0 <2.0.0-0"
|
|
@@ -56,8 +55,8 @@
|
|
|
56
55
|
"scripts": {
|
|
57
56
|
"build:lib": "tsdown --silent --config tsdown.config.ts",
|
|
58
57
|
"build:watch": "tsdown --watch --silent --config tsdown.config.ts",
|
|
59
|
-
"lint": "oxlint
|
|
60
|
-
"lint:fix": "oxlint --
|
|
58
|
+
"lint": "oxlint --type-aware .",
|
|
59
|
+
"lint:fix": "oxlint --type-aware --fix .",
|
|
61
60
|
"coverage": "vitest run --coverage",
|
|
62
61
|
"pretest": "node scripts/start-docker.js",
|
|
63
62
|
"test": "vitest run",
|