@mastra/vectorize 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 +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-rag-retrieval.md +7 -5
- package/dist/docs/references/reference-rag-vector-databases.md +98 -2
- package/dist/docs/references/reference-vectors-vectorize.md +7 -3
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/package.json +9 -10
package/dist/docs/SKILL.md
CHANGED
|
@@ -50,23 +50,25 @@ console.log(results)
|
|
|
50
50
|
|
|
51
51
|
The `topK` parameter specifies the maximum number of most similar results to return from the vector search.
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
Each result includes an `id`, a similarity `score`, and the stored `metadata`. When you store chunk text in metadata, it's available as `metadata.text`:
|
|
54
54
|
|
|
55
55
|
```ts
|
|
56
56
|
[
|
|
57
57
|
{
|
|
58
|
-
|
|
58
|
+
id: 'chunk-1',
|
|
59
59
|
score: 0.89,
|
|
60
|
-
metadata: { source: 'article1.txt' },
|
|
60
|
+
metadata: { text: 'Climate change poses significant challenges...', source: 'article1.txt' },
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
|
-
|
|
63
|
+
id: 'chunk-2',
|
|
64
64
|
score: 0.82,
|
|
65
|
-
metadata: { source: 'article1.txt' },
|
|
65
|
+
metadata: { text: 'Rising temperatures affect crop yields...', source: 'article1.txt' },
|
|
66
66
|
},
|
|
67
67
|
]
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
+
Results can also include `vector` when you set `includeVector: true`, and `document` when the store returns the original document (Chroma only).
|
|
71
|
+
|
|
70
72
|
## Advanced retrieval options
|
|
71
73
|
|
|
72
74
|
### Metadata Filtering
|
|
@@ -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
|
|
|
@@ -133,17 +133,21 @@ interface QueryResult {
|
|
|
133
133
|
|
|
134
134
|
## Error handling
|
|
135
135
|
|
|
136
|
-
The store throws
|
|
136
|
+
The store throws `MastraError` instances from `@mastra/core/error`:
|
|
137
137
|
|
|
138
138
|
```typescript
|
|
139
|
+
import { MastraError } from '@mastra/core/error'
|
|
140
|
+
|
|
139
141
|
try {
|
|
140
142
|
await store.query({
|
|
141
143
|
indexName: 'index_name',
|
|
142
144
|
queryVector: queryVector,
|
|
143
145
|
})
|
|
144
146
|
} catch (error) {
|
|
145
|
-
if (error instanceof
|
|
146
|
-
console.log(error.
|
|
147
|
+
if (error instanceof MastraError) {
|
|
148
|
+
console.log(error.id) // 'MASTRA_VECTOR_VECTORIZE_QUERY_FAILED'
|
|
149
|
+
console.log(error.domain) // 'STORAGE'
|
|
150
|
+
console.log(error.category) // 'USER' | 'THIRD_PARTY'
|
|
147
151
|
console.log(error.details) // Additional error context
|
|
148
152
|
}
|
|
149
153
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
20
20
|
value: mod,
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["BaseFilterTranslator","MastraVector","Cloudflare","MastraError","ErrorDomain","ErrorCategory"],"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"sourcesContent":["import { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n OperatorSupport,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n} from '@mastra/core/vector/filter';\n\ntype VectorizeOperatorValueMap = Omit<OperatorValueMap, '$regex' | '$options' | '$exists' | '$elemMatch' | '$all'>;\n\ntype VectorizeLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor' | '$not' | '$and' | '$or'>;\n\ntype VectorizeBlacklistedRootOperators = BlacklistedRootOperators | '$nor' | '$not' | '$and' | '$or';\n\nexport type VectorizeVectorFilter = VectorFilter<\n keyof VectorizeOperatorValueMap,\n VectorizeOperatorValueMap,\n VectorizeLogicalOperatorValueMap,\n VectorizeBlacklistedRootOperators\n>;\n\nexport class VectorizeFilterTranslator extends BaseFilterTranslator<VectorizeVectorFilter> {\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: [],\n array: ['$in', '$nin'],\n element: [],\n regex: [],\n custom: [],\n };\n }\n\n translate(filter?: VectorizeVectorFilter): VectorizeVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n return this.translateNode(filter);\n }\n\n private translateNode(node: VectorizeVectorFilter, currentPath: string = ''): any {\n if (this.isRegex(node)) {\n throw new Error('Regex is not supported in Vectorize');\n }\n if (this.isPrimitive(node)) return { $eq: this.normalizeComparisonValue(node) };\n if (Array.isArray(node)) return { $in: this.normalizeArrayValues(node) };\n\n const entries = Object.entries(node as Record<string, any>);\n const firstEntry = entries[0];\n\n // Handle single operator case\n if (entries.length === 1 && firstEntry && this.isOperator(firstEntry[0])) {\n const [operator, value] = firstEntry;\n return { [operator]: this.normalizeComparisonValue(value) };\n }\n\n // Process each entry\n const result: Record<string, any> = {};\n for (const [key, value] of entries) {\n const newPath = currentPath ? `${currentPath}.${key}` : key;\n\n if (this.isOperator(key)) {\n result[key] = this.normalizeComparisonValue(value);\n continue;\n }\n\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n if (Object.keys(value).length === 0) {\n result[newPath] = this.translateNode(value);\n continue;\n }\n\n // Check if the nested object contains operators\n const hasOperators = Object.keys(value).some(k => this.isOperator(k));\n if (hasOperators) {\n result[newPath] = this.translateNode(value);\n } else {\n // For objects without operators, flatten them\n Object.assign(result, this.translateNode(value, newPath));\n }\n } else {\n result[newPath] = this.translateNode(value);\n }\n }\n\n return result;\n }\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { createVectorErrorId } from '@mastra/core/storage';\nimport { MastraVector } from '@mastra/core/vector';\nimport type {\n QueryResult,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n UpdateVectorParams,\n IndexStats,\n DeleteVectorsParams,\n} from '@mastra/core/vector';\nimport Cloudflare from 'cloudflare';\n\nimport { VectorizeFilterTranslator } from './filter';\nimport type { VectorizeVectorFilter } from './filter';\n\ntype VectorizeQueryParams = QueryVectorParams<VectorizeVectorFilter>;\n\nexport class CloudflareVector extends MastraVector<VectorizeVectorFilter> {\n client: Cloudflare;\n accountId: string;\n\n constructor({ accountId, apiToken, id }: { accountId: string; apiToken: string } & { id: string }) {\n super({ id });\n this.accountId = accountId;\n\n this.client = new Cloudflare({\n apiToken: apiToken,\n });\n }\n\n get indexSeparator(): string {\n return '-';\n }\n\n async upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]> {\n const generatedIds = ids || vectors.map(() => crypto.randomUUID());\n\n // Create NDJSON string - each line is a JSON object\n const ndjson = vectors\n .map((vector, index) =>\n JSON.stringify({\n id: generatedIds[index]!,\n values: vector,\n metadata: metadata?.[index],\n }),\n )\n .join('\\n');\n\n try {\n const body = new File([ndjson], `${indexName}.ndjson`, { type: 'application/x-ndjson' });\n\n await this.client.vectorize.indexes.upsert(indexName, {\n account_id: this.accountId,\n body,\n });\n\n return generatedIds;\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'UPSERT', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, vectorCount: vectors?.length },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: VectorizeVectorFilter) {\n const translator = new VectorizeFilterTranslator();\n return translator.translate(filter);\n }\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n try {\n await this.client.vectorize.indexes.create({\n account_id: this.accountId,\n config: {\n dimensions: dimension,\n metric: metric === 'dotproduct' ? 'dot-product' : metric,\n },\n name: indexName,\n });\n } catch (error: any) {\n // Check for 'already exists' error\n const message = error?.errors?.[0]?.message || error?.message;\n if (\n error.status === 409 ||\n (typeof message === 'string' &&\n (message.toLowerCase().includes('already exists') || message.toLowerCase().includes('duplicate')))\n ) {\n // Fetch index info and check dimensions\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n // For any other errors, propagate\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'CREATE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, dimension, metric },\n },\n error,\n );\n }\n }\n\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n }: VectorizeQueryParams): Promise<QueryResult[]> {\n if (!queryVector) {\n throw new MastraError({\n id: createVectorErrorId('VECTORIZE', 'QUERY', 'MISSING_VECTOR'),\n text: 'queryVector is required for Vectorize 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 const translatedFilter = this.transformFilter(filter) ?? {};\n const response = await this.client.vectorize.indexes.query(indexName, {\n account_id: this.accountId,\n vector: queryVector,\n returnValues: includeVector,\n returnMetadata: 'all',\n topK,\n filter: translatedFilter,\n });\n\n return (\n response?.matches?.map((match: any) => {\n return {\n id: match.id,\n metadata: match.metadata,\n score: match.score,\n vector: match.values,\n };\n }) || []\n );\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'QUERY', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, topK },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const res = await this.client.vectorize.indexes.list({\n account_id: this.accountId,\n });\n\n return res?.result?.map((index: { name?: string }) => index.name!) || [];\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', '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 const index = await this.client.vectorize.indexes.get(indexName, {\n account_id: this.accountId,\n });\n\n const described = await this.client.vectorize.indexes.info(indexName, {\n account_id: this.accountId,\n });\n\n return {\n dimension: described?.dimensions!,\n // Since vector_count is not available in the response,\n // we might need a separate API call to get the count if needed\n count: described?.vectorCount || 0,\n metric: index?.config?.metric as 'cosine' | 'euclidean' | 'dotproduct',\n };\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'DESCRIBE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.client.vectorize.indexes.delete(indexName, {\n account_id: this.accountId,\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'DELETE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async createMetadataIndex(indexName: string, propertyName: string, indexType: 'string' | 'number' | 'boolean') {\n try {\n await this.client.vectorize.indexes.metadataIndex.create(indexName, {\n account_id: this.accountId,\n propertyName,\n indexType,\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'CREATE_METADATA_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, propertyName, indexType },\n },\n error,\n );\n }\n }\n\n async deleteMetadataIndex(indexName: string, propertyName: string) {\n try {\n await this.client.vectorize.indexes.metadataIndex.delete(indexName, {\n account_id: this.accountId,\n propertyName,\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'DELETE_METADATA_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, propertyName },\n },\n error,\n );\n }\n }\n\n async listMetadataIndexes(indexName: string) {\n try {\n const res = await this.client.vectorize.indexes.metadataIndex.list(indexName, {\n account_id: this.accountId,\n });\n\n return res?.metadataIndexes ?? [];\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'LIST_METADATA_INDEXES', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\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({ indexName, id, update }: UpdateVectorParams): Promise<void> {\n if (!id) {\n throw new MastraError({\n id: createVectorErrorId('VECTORIZE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: 'id is required for Vectorize updateVector',\n details: { indexName },\n });\n }\n\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: createVectorErrorId('VECTORIZE', 'UPDATE_VECTOR', 'NO_PAYLOAD'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: 'No update data provided',\n details: { indexName, id },\n });\n }\n\n if (!update.vector) {\n throw new MastraError({\n id: createVectorErrorId('VECTORIZE', 'UPDATE_VECTOR', 'MISSING_VECTOR'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: 'Vectorize requires vector values when updating; metadata-only updates are not supported. Provide update.vector alongside update.metadata.',\n details: { indexName, id },\n });\n }\n\n try {\n await this.upsert({\n indexName,\n ids: [id],\n vectors: [update.vector],\n ...(update.metadata && { metadata: [update.metadata] }),\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'UPDATE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(id && { id }),\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({ indexName, id }: DeleteVectorParams): Promise<void> {\n try {\n await this.client.vectorize.indexes.deleteByIds(indexName, {\n ids: [id],\n account_id: this.accountId,\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'DELETE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(id && { id }),\n },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes multiple vectors by their IDs.\n *\n * Vectorize has no filtered-delete primitive, so metadata-filter deletion is rejected.\n *\n * @param indexName - The name of the index containing the vectors.\n * @param ids - The IDs of the vectors to delete. Mutually exclusive with `filter`.\n * @throws Will throw an error if the arguments are invalid or the deletion operation fails.\n */\n async deleteVectors({ indexName, filter, ids }: DeleteVectorsParams): Promise<void> {\n if (ids && filter) {\n throw new MastraError({\n id: createVectorErrorId('VECTORIZE', 'DELETE_VECTORS', 'MUTUALLY_EXCLUSIVE'),\n text: 'Cannot specify both ids and filter - they are mutually exclusive',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (filter) {\n throw new MastraError({\n id: createVectorErrorId('VECTORIZE', 'DELETE_VECTORS', 'UNSUPPORTED_FILTER'),\n text: 'Deleting by metadata filter is not supported for Vectorize vector store - delete by ids instead',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.SYSTEM,\n details: { indexName, filter: JSON.stringify(filter) },\n });\n }\n\n if (!ids) {\n throw new MastraError({\n id: createVectorErrorId('VECTORIZE', 'DELETE_VECTORS', 'NO_TARGET'),\n text: 'Either filter or ids must be provided',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (ids.length === 0) {\n throw new MastraError({\n id: createVectorErrorId('VECTORIZE', 'DELETE_VECTORS', 'EMPTY_IDS'),\n text: 'Cannot delete with empty ids array',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n await this.client.vectorize.indexes.deleteByIds(indexName, {\n ids,\n account_id: this.accountId,\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'DELETE_VECTORS', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n idsCount: ids.length,\n },\n },\n error,\n );\n }\n }\n}\n","/**\n * Vector store specific prompt that details supported operators and examples.\n * This prompt helps users construct valid filters for Vectorize.\n */\nexport const VECTORIZE_PROMPT = `When querying Vectorize, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n- $match: Match text using full-text search\n Example: { \"description\": { \"$match\": \"gaming laptop\" } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and and $or logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"description\": { \"$match\": \"gaming laptop\" } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAa,4BAAb,cAA+CA,2BAAAA,qBAA4C;CACzF,wBAA4D;EAC1D,OAAO;GACL,GAAGA,2BAAAA,qBAAqB;GACxB,SAAS,CAAC;GACV,OAAO,CAAC,OAAO,MAAM;GACrB,SAAS,CAAC;GACV,OAAO,CAAC;GACR,QAAQ,CAAC;EACX;CACF;CAEA,UAAU,QAAuD;EAC/D,IAAI,KAAK,QAAQ,MAAM,GAAG,OAAO;EACjC,KAAK,eAAe,MAAM;EAC1B,OAAO,KAAK,cAAc,MAAM;CAClC;CAEA,cAAsB,MAA6B,cAAsB,IAAS;EAChF,IAAI,KAAK,QAAQ,IAAI,GACnB,MAAM,IAAI,MAAM,qCAAqC;EAEvD,IAAI,KAAK,YAAY,IAAI,GAAG,OAAO,EAAE,KAAK,KAAK,yBAAyB,IAA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;;ACzcA,MAAa,mBAAmB"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["BaseFilterTranslator","MastraVector","Cloudflare","MastraError","createVectorErrorId","ErrorDomain","ErrorCategory"],"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"sourcesContent":["import { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n OperatorSupport,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n} from '@mastra/core/vector/filter';\n\ntype VectorizeOperatorValueMap = Omit<OperatorValueMap, '$regex' | '$options' | '$exists' | '$elemMatch' | '$all'>;\n\ntype VectorizeLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor' | '$not' | '$and' | '$or'>;\n\ntype VectorizeBlacklistedRootOperators = BlacklistedRootOperators | '$nor' | '$not' | '$and' | '$or';\n\nexport type VectorizeVectorFilter = VectorFilter<\n keyof VectorizeOperatorValueMap,\n VectorizeOperatorValueMap,\n VectorizeLogicalOperatorValueMap,\n VectorizeBlacklistedRootOperators\n>;\n\nexport class VectorizeFilterTranslator extends BaseFilterTranslator<VectorizeVectorFilter> {\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: [],\n array: ['$in', '$nin'],\n element: [],\n regex: [],\n custom: [],\n };\n }\n\n translate(filter?: VectorizeVectorFilter): VectorizeVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n return this.translateNode(filter);\n }\n\n private translateNode(node: VectorizeVectorFilter, currentPath: string = ''): any {\n if (this.isRegex(node)) {\n throw new Error('Regex is not supported in Vectorize');\n }\n if (this.isPrimitive(node)) return { $eq: this.normalizeComparisonValue(node) };\n if (Array.isArray(node)) return { $in: this.normalizeArrayValues(node) };\n\n const entries = Object.entries(node as Record<string, any>);\n const firstEntry = entries[0];\n\n // Handle single operator case\n if (entries.length === 1 && firstEntry && this.isOperator(firstEntry[0])) {\n const [operator, value] = firstEntry;\n return { [operator]: this.normalizeComparisonValue(value) };\n }\n\n // Process each entry\n const result: Record<string, any> = {};\n for (const [key, value] of entries) {\n const newPath = currentPath ? `${currentPath}.${key}` : key;\n\n if (this.isOperator(key)) {\n result[key] = this.normalizeComparisonValue(value);\n continue;\n }\n\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n if (Object.keys(value).length === 0) {\n result[newPath] = this.translateNode(value);\n continue;\n }\n\n // Check if the nested object contains operators\n const hasOperators = Object.keys(value).some(k => this.isOperator(k));\n if (hasOperators) {\n result[newPath] = this.translateNode(value);\n } else {\n // For objects without operators, flatten them\n Object.assign(result, this.translateNode(value, newPath));\n }\n } else {\n result[newPath] = this.translateNode(value);\n }\n }\n\n return result;\n }\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { createVectorErrorId } from '@mastra/core/storage';\nimport { MastraVector } from '@mastra/core/vector';\nimport type {\n QueryResult,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n UpdateVectorParams,\n IndexStats,\n DeleteVectorsParams,\n} from '@mastra/core/vector';\nimport Cloudflare from 'cloudflare';\n\nimport { VectorizeFilterTranslator } from './filter';\nimport type { VectorizeVectorFilter } from './filter';\n\ntype VectorizeQueryParams = QueryVectorParams<VectorizeVectorFilter>;\n\nexport class CloudflareVector extends MastraVector<VectorizeVectorFilter> {\n client: Cloudflare;\n accountId: string;\n\n constructor({ accountId, apiToken, id }: { accountId: string; apiToken: string } & { id: string }) {\n super({ id });\n this.accountId = accountId;\n\n this.client = new Cloudflare({\n apiToken: apiToken,\n });\n }\n\n get indexSeparator(): string {\n return '-';\n }\n\n async upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]> {\n const generatedIds = ids || vectors.map(() => crypto.randomUUID());\n\n // Create NDJSON string - each line is a JSON object\n const ndjson = vectors\n .map((vector, index) =>\n JSON.stringify({\n id: generatedIds[index]!,\n values: vector,\n metadata: metadata?.[index],\n }),\n )\n .join('\\n');\n\n try {\n const body = new File([ndjson], `${indexName}.ndjson`, { type: 'application/x-ndjson' });\n\n await this.client.vectorize.indexes.upsert(indexName, {\n account_id: this.accountId,\n body,\n });\n\n return generatedIds;\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'UPSERT', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, vectorCount: vectors?.length },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: VectorizeVectorFilter) {\n const translator = new VectorizeFilterTranslator();\n return translator.translate(filter);\n }\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n try {\n await this.client.vectorize.indexes.create({\n account_id: this.accountId,\n config: {\n dimensions: dimension,\n metric: metric === 'dotproduct' ? 'dot-product' : metric,\n },\n name: indexName,\n });\n } catch (error: any) {\n // Check for 'already exists' error\n const message = error?.errors?.[0]?.message || error?.message;\n if (\n error.status === 409 ||\n (typeof message === 'string' &&\n (message.toLowerCase().includes('already exists') || message.toLowerCase().includes('duplicate')))\n ) {\n // Fetch index info and check dimensions\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n // For any other errors, propagate\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'CREATE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, dimension, metric },\n },\n error,\n );\n }\n }\n\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n }: VectorizeQueryParams): Promise<QueryResult[]> {\n if (!queryVector) {\n throw new MastraError({\n id: createVectorErrorId('VECTORIZE', 'QUERY', 'MISSING_VECTOR'),\n text: 'queryVector is required for Vectorize 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 const translatedFilter = this.transformFilter(filter) ?? {};\n const response = await this.client.vectorize.indexes.query(indexName, {\n account_id: this.accountId,\n vector: queryVector,\n returnValues: includeVector,\n returnMetadata: 'all',\n topK,\n filter: translatedFilter,\n });\n\n return (\n response?.matches?.map((match: any) => {\n return {\n id: match.id,\n metadata: match.metadata,\n score: match.score,\n vector: match.values,\n };\n }) || []\n );\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'QUERY', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, topK },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const res = await this.client.vectorize.indexes.list({\n account_id: this.accountId,\n });\n\n return res?.result?.map((index: { name?: string }) => index.name!) || [];\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', '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 const index = await this.client.vectorize.indexes.get(indexName, {\n account_id: this.accountId,\n });\n\n const described = await this.client.vectorize.indexes.info(indexName, {\n account_id: this.accountId,\n });\n\n return {\n dimension: described?.dimensions!,\n // Since vector_count is not available in the response,\n // we might need a separate API call to get the count if needed\n count: described?.vectorCount || 0,\n metric: index?.config?.metric as 'cosine' | 'euclidean' | 'dotproduct',\n };\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'DESCRIBE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.client.vectorize.indexes.delete(indexName, {\n account_id: this.accountId,\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'DELETE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async createMetadataIndex(indexName: string, propertyName: string, indexType: 'string' | 'number' | 'boolean') {\n try {\n await this.client.vectorize.indexes.metadataIndex.create(indexName, {\n account_id: this.accountId,\n propertyName,\n indexType,\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'CREATE_METADATA_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, propertyName, indexType },\n },\n error,\n );\n }\n }\n\n async deleteMetadataIndex(indexName: string, propertyName: string) {\n try {\n await this.client.vectorize.indexes.metadataIndex.delete(indexName, {\n account_id: this.accountId,\n propertyName,\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'DELETE_METADATA_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, propertyName },\n },\n error,\n );\n }\n }\n\n async listMetadataIndexes(indexName: string) {\n try {\n const res = await this.client.vectorize.indexes.metadataIndex.list(indexName, {\n account_id: this.accountId,\n });\n\n return res?.metadataIndexes ?? [];\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'LIST_METADATA_INDEXES', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\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({ indexName, id, update }: UpdateVectorParams): Promise<void> {\n if (!id) {\n throw new MastraError({\n id: createVectorErrorId('VECTORIZE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: 'id is required for Vectorize updateVector',\n details: { indexName },\n });\n }\n\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: createVectorErrorId('VECTORIZE', 'UPDATE_VECTOR', 'NO_PAYLOAD'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: 'No update data provided',\n details: { indexName, id },\n });\n }\n\n if (!update.vector) {\n throw new MastraError({\n id: createVectorErrorId('VECTORIZE', 'UPDATE_VECTOR', 'MISSING_VECTOR'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: 'Vectorize requires vector values when updating; metadata-only updates are not supported. Provide update.vector alongside update.metadata.',\n details: { indexName, id },\n });\n }\n\n try {\n await this.upsert({\n indexName,\n ids: [id],\n vectors: [update.vector],\n ...(update.metadata && { metadata: [update.metadata] }),\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'UPDATE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(id && { id }),\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({ indexName, id }: DeleteVectorParams): Promise<void> {\n try {\n await this.client.vectorize.indexes.deleteByIds(indexName, {\n ids: [id],\n account_id: this.accountId,\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'DELETE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(id && { id }),\n },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes multiple vectors by their IDs.\n *\n * Vectorize has no filtered-delete primitive, so metadata-filter deletion is rejected.\n *\n * @param indexName - The name of the index containing the vectors.\n * @param ids - The IDs of the vectors to delete. Mutually exclusive with `filter`.\n * @throws Will throw an error if the arguments are invalid or the deletion operation fails.\n */\n async deleteVectors({ indexName, filter, ids }: DeleteVectorsParams): Promise<void> {\n if (ids && filter) {\n throw new MastraError({\n id: createVectorErrorId('VECTORIZE', 'DELETE_VECTORS', 'MUTUALLY_EXCLUSIVE'),\n text: 'Cannot specify both ids and filter - they are mutually exclusive',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (filter) {\n throw new MastraError({\n id: createVectorErrorId('VECTORIZE', 'DELETE_VECTORS', 'UNSUPPORTED_FILTER'),\n text: 'Deleting by metadata filter is not supported for Vectorize vector store - delete by ids instead',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.SYSTEM,\n details: { indexName, filter: JSON.stringify(filter) },\n });\n }\n\n if (!ids) {\n throw new MastraError({\n id: createVectorErrorId('VECTORIZE', 'DELETE_VECTORS', 'NO_TARGET'),\n text: 'Either filter or ids must be provided',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (ids.length === 0) {\n throw new MastraError({\n id: createVectorErrorId('VECTORIZE', 'DELETE_VECTORS', 'EMPTY_IDS'),\n text: 'Cannot delete with empty ids array',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n await this.client.vectorize.indexes.deleteByIds(indexName, {\n ids,\n account_id: this.accountId,\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('VECTORIZE', 'DELETE_VECTORS', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n idsCount: ids.length,\n },\n },\n error,\n );\n }\n }\n}\n","/**\n * Vector store specific prompt that details supported operators and examples.\n * This prompt helps users construct valid filters for Vectorize.\n */\nexport const VECTORIZE_PROMPT = `When querying Vectorize, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n- $match: Match text using full-text search\n Example: { \"description\": { \"$match\": \"gaming laptop\" } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and and $or logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"description\": { \"$match\": \"gaming laptop\" } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAa,4BAAb,cAA+CA,2BAAAA,qBAA4C;CACzF,wBAA4D;EAC1D,OAAO;GACL,GAAGA,2BAAAA,qBAAqB;GACxB,SAAS,CAAC;GACV,OAAO,CAAC,OAAO,MAAM;GACrB,SAAS,CAAC;GACV,OAAO,CAAC;GACR,QAAQ,CAAC;EACX;CACF;CAEA,UAAU,QAAuD;EAC/D,IAAI,KAAK,QAAQ,MAAM,GAAG,OAAO;EACjC,KAAK,eAAe,MAAM;EAC1B,OAAO,KAAK,cAAc,MAAM;CAClC;CAEA,cAAsB,MAA6B,cAAsB,IAAS;EAChF,IAAI,KAAK,QAAQ,IAAI,GACnB,MAAM,IAAI,MAAM,qCAAqC;EAE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AkB,QAAQ;IAC/D,QAAQC,mBAAAA,YAAY;IACpB,UAAUC,mBAAAA,cAAc;IACxB,SAAS;KACP;KACA,UAAU,IAAI;IAChB;GACF,GACA,KACF;EACF;CACF;AACF;;;;;;;ACzcA,MAAa,mBAAmB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/vectorize",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Cloudflare Vectorize store provider for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -27,17 +27,16 @@
|
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "22.20.1",
|
|
30
|
-
"@vitest/coverage-v8": "4.1.
|
|
31
|
-
"@vitest/ui": "4.1.
|
|
30
|
+
"@vitest/coverage-v8": "4.1.11",
|
|
31
|
+
"@vitest/ui": "4.1.11",
|
|
32
32
|
"dotenv": "^17.4.2",
|
|
33
|
-
"eslint": "^10.7.0",
|
|
34
33
|
"tsdown": "0.22.9",
|
|
35
34
|
"tsx": "^4.23.1",
|
|
36
35
|
"typescript": "^7.0.2",
|
|
37
|
-
"vitest": "4.1.
|
|
38
|
-
"@internal/lint": "0.0.
|
|
39
|
-
"@internal/types-builder": "0.0.
|
|
40
|
-
"@mastra/core": "1.
|
|
36
|
+
"vitest": "4.1.11",
|
|
37
|
+
"@internal/lint": "0.0.145",
|
|
38
|
+
"@internal/types-builder": "0.0.120",
|
|
39
|
+
"@mastra/core": "1.79.0"
|
|
41
40
|
},
|
|
42
41
|
"peerDependencies": {
|
|
43
42
|
"@mastra/core": ">=1.0.0-0 <2.0.0-0"
|
|
@@ -58,7 +57,7 @@
|
|
|
58
57
|
"build:lib": "tsdown --silent --config tsdown.config.ts",
|
|
59
58
|
"build:watch": "tsdown --watch --silent --config tsdown.config.ts",
|
|
60
59
|
"test": "vitest run",
|
|
61
|
-
"lint": "oxlint
|
|
62
|
-
"lint:fix": "oxlint --
|
|
60
|
+
"lint": "oxlint --type-aware .",
|
|
61
|
+
"lint:fix": "oxlint --type-aware --fix ."
|
|
63
62
|
}
|
|
64
63
|
}
|