@mastra/vectorize 1.1.3 → 1.1.4
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 +24 -13
- package/dist/docs/references/reference-vectors-vectorize.md +4 -2
- package/dist/index.cjs +4 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -6
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
package/dist/docs/SKILL.md
CHANGED
|
@@ -382,11 +382,12 @@ Vector store prompts define query patterns and filtering capabilities for each v
|
|
|
382
382
|
|
|
383
383
|
```ts
|
|
384
384
|
import { MONGODB_PROMPT } from '@mastra/mongodb'
|
|
385
|
+
import { Agent } from '@mastra/core/agent'
|
|
385
386
|
|
|
386
387
|
export const ragAgent = new Agent({
|
|
387
388
|
id: 'rag-agent',
|
|
388
389
|
name: 'RAG Agent',
|
|
389
|
-
model: 'openai/gpt-
|
|
390
|
+
model: 'openai/gpt-6.1-sol',
|
|
390
391
|
instructions: `
|
|
391
392
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
392
393
|
${MONGODB_PROMPT}
|
|
@@ -403,7 +404,7 @@ import { PGVECTOR_PROMPT } from '@mastra/pg'
|
|
|
403
404
|
export const ragAgent = new Agent({
|
|
404
405
|
id: 'rag-agent',
|
|
405
406
|
name: 'RAG Agent',
|
|
406
|
-
model: 'openai/gpt-
|
|
407
|
+
model: 'openai/gpt-6.1-sol',
|
|
407
408
|
instructions: `
|
|
408
409
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
409
410
|
${PGVECTOR_PROMPT}
|
|
@@ -416,11 +417,12 @@ export const ragAgent = new Agent({
|
|
|
416
417
|
|
|
417
418
|
```ts
|
|
418
419
|
import { PINECONE_PROMPT } from '@mastra/pinecone'
|
|
420
|
+
import { Agent } from '@mastra/core/agent'
|
|
419
421
|
|
|
420
422
|
export const ragAgent = new Agent({
|
|
421
423
|
id: 'rag-agent',
|
|
422
424
|
name: 'RAG Agent',
|
|
423
|
-
model: 'openai/gpt-
|
|
425
|
+
model: 'openai/gpt-6.1-sol',
|
|
424
426
|
instructions: `
|
|
425
427
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
426
428
|
${PINECONE_PROMPT}
|
|
@@ -433,11 +435,12 @@ export const ragAgent = new Agent({
|
|
|
433
435
|
|
|
434
436
|
```ts
|
|
435
437
|
import { QDRANT_PROMPT } from '@mastra/qdrant'
|
|
438
|
+
import { Agent } from '@mastra/core/agent'
|
|
436
439
|
|
|
437
440
|
export const ragAgent = new Agent({
|
|
438
441
|
id: 'rag-agent',
|
|
439
442
|
name: 'RAG Agent',
|
|
440
|
-
model: 'openai/gpt-
|
|
443
|
+
model: 'openai/gpt-6.1-sol',
|
|
441
444
|
instructions: `
|
|
442
445
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
443
446
|
${QDRANT_PROMPT}
|
|
@@ -450,11 +453,12 @@ export const ragAgent = new Agent({
|
|
|
450
453
|
|
|
451
454
|
```ts
|
|
452
455
|
import { CHROMA_PROMPT } from '@mastra/chroma'
|
|
456
|
+
import { Agent } from '@mastra/core/agent'
|
|
453
457
|
|
|
454
458
|
export const ragAgent = new Agent({
|
|
455
459
|
id: 'rag-agent',
|
|
456
460
|
name: 'RAG Agent',
|
|
457
|
-
model: 'openai/gpt-
|
|
461
|
+
model: 'openai/gpt-6.1-sol',
|
|
458
462
|
instructions: `
|
|
459
463
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
460
464
|
${CHROMA_PROMPT}
|
|
@@ -467,11 +471,12 @@ export const ragAgent = new Agent({
|
|
|
467
471
|
|
|
468
472
|
```ts
|
|
469
473
|
import { ASTRA_PROMPT } from '@mastra/astra'
|
|
474
|
+
import { Agent } from '@mastra/core/agent'
|
|
470
475
|
|
|
471
476
|
export const ragAgent = new Agent({
|
|
472
477
|
id: 'rag-agent',
|
|
473
478
|
name: 'RAG Agent',
|
|
474
|
-
model: 'openai/gpt-
|
|
479
|
+
model: 'openai/gpt-6.1-sol',
|
|
475
480
|
instructions: `
|
|
476
481
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
477
482
|
${ASTRA_PROMPT}
|
|
@@ -484,11 +489,12 @@ export const ragAgent = new Agent({
|
|
|
484
489
|
|
|
485
490
|
```ts
|
|
486
491
|
import { LIBSQL_PROMPT } from '@mastra/libsql'
|
|
492
|
+
import { Agent } from '@mastra/core/agent'
|
|
487
493
|
|
|
488
494
|
export const ragAgent = new Agent({
|
|
489
495
|
id: 'rag-agent',
|
|
490
496
|
name: 'RAG Agent',
|
|
491
|
-
model: 'openai/gpt-
|
|
497
|
+
model: 'openai/gpt-6.1-sol',
|
|
492
498
|
instructions: `
|
|
493
499
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
494
500
|
${LIBSQL_PROMPT}
|
|
@@ -501,11 +507,12 @@ export const ragAgent = new Agent({
|
|
|
501
507
|
|
|
502
508
|
```ts
|
|
503
509
|
import { UPSTASH_PROMPT } from '@mastra/upstash'
|
|
510
|
+
import { Agent } from '@mastra/core/agent'
|
|
504
511
|
|
|
505
512
|
export const ragAgent = new Agent({
|
|
506
513
|
id: 'rag-agent',
|
|
507
514
|
name: 'RAG Agent',
|
|
508
|
-
model: 'openai/gpt-
|
|
515
|
+
model: 'openai/gpt-6.1-sol',
|
|
509
516
|
instructions: `
|
|
510
517
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
511
518
|
${UPSTASH_PROMPT}
|
|
@@ -518,11 +525,12 @@ export const ragAgent = new Agent({
|
|
|
518
525
|
|
|
519
526
|
```ts
|
|
520
527
|
import { VECTORIZE_PROMPT } from '@mastra/vectorize'
|
|
528
|
+
import { Agent } from '@mastra/core/agent'
|
|
521
529
|
|
|
522
530
|
export const ragAgent = new Agent({
|
|
523
531
|
id: 'rag-agent',
|
|
524
532
|
name: 'RAG Agent',
|
|
525
|
-
model: 'openai/gpt-
|
|
533
|
+
model: 'openai/gpt-6.1-sol',
|
|
526
534
|
instructions: `
|
|
527
535
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
528
536
|
${VECTORIZE_PROMPT}
|
|
@@ -535,11 +543,12 @@ export const ragAgent = new Agent({
|
|
|
535
543
|
|
|
536
544
|
```ts
|
|
537
545
|
import { OPENSEARCH_PROMPT } from '@mastra/opensearch'
|
|
546
|
+
import { Agent } from '@mastra/core/agent'
|
|
538
547
|
|
|
539
548
|
export const ragAgent = new Agent({
|
|
540
549
|
id: 'rag-agent',
|
|
541
550
|
name: 'RAG Agent',
|
|
542
|
-
model: 'openai/gpt-
|
|
551
|
+
model: 'openai/gpt-6.1-sol',
|
|
543
552
|
instructions: `
|
|
544
553
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
545
554
|
${OPENSEARCH_PROMPT}
|
|
@@ -552,11 +561,12 @@ export const ragAgent = new Agent({
|
|
|
552
561
|
|
|
553
562
|
```ts
|
|
554
563
|
import { ORACLEDB_PROMPT } from '@mastra/oracledb'
|
|
564
|
+
import { Agent } from '@mastra/core/agent'
|
|
555
565
|
|
|
556
566
|
export const ragAgent = new Agent({
|
|
557
567
|
id: 'rag-agent',
|
|
558
568
|
name: 'RAG Agent',
|
|
559
|
-
model: 'openai/gpt-
|
|
569
|
+
model: 'openai/gpt-6.1-sol',
|
|
560
570
|
instructions: `
|
|
561
571
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
562
572
|
${ORACLEDB_PROMPT}
|
|
@@ -569,11 +579,12 @@ export const ragAgent = new Agent({
|
|
|
569
579
|
|
|
570
580
|
```ts
|
|
571
581
|
import { S3VECTORS_PROMPT } from '@mastra/s3vectors'
|
|
582
|
+
import { Agent } from '@mastra/core/agent'
|
|
572
583
|
|
|
573
584
|
export const ragAgent = new Agent({
|
|
574
585
|
id: 'rag-agent',
|
|
575
586
|
name: 'RAG Agent',
|
|
576
|
-
model: 'openai/gpt-
|
|
587
|
+
model: 'openai/gpt-6.1-sol',
|
|
577
588
|
instructions: `
|
|
578
589
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
579
590
|
${S3VECTORS_PROMPT}
|
|
@@ -605,7 +616,7 @@ const initialResults = await pgVector.query({
|
|
|
605
616
|
// Create a relevance scorer
|
|
606
617
|
const relevanceProvider = new MastraAgentRelevanceScorer(
|
|
607
618
|
'relevance-scorer',
|
|
608
|
-
'openai/gpt-
|
|
619
|
+
'openai/gpt-6.1-sol',
|
|
609
620
|
)
|
|
610
621
|
|
|
611
622
|
// Re-rank the results
|
|
@@ -8,6 +8,8 @@ The CloudflareVector class provides vector search using [Cloudflare Vectorize](h
|
|
|
8
8
|
|
|
9
9
|
## Constructor options
|
|
10
10
|
|
|
11
|
+
**id** (`string`): Unique identifier for this vector store instance.
|
|
12
|
+
|
|
11
13
|
**accountId** (`string`): Cloudflare account ID
|
|
12
14
|
|
|
13
15
|
**apiToken** (`string`): Cloudflare API token with Vectorize permissions
|
|
@@ -58,7 +60,7 @@ Returns:
|
|
|
58
60
|
interface IndexStats {
|
|
59
61
|
dimension: number
|
|
60
62
|
count: number
|
|
61
|
-
metric
|
|
63
|
+
metric?: 'cosine' | 'euclidean' | 'dotproduct'
|
|
62
64
|
}
|
|
63
65
|
```
|
|
64
66
|
|
|
@@ -126,7 +128,7 @@ Query results are returned in this format:
|
|
|
126
128
|
interface QueryResult {
|
|
127
129
|
id: string
|
|
128
130
|
score: number
|
|
129
|
-
metadata
|
|
131
|
+
metadata?: Record<string, any>
|
|
130
132
|
vector?: number[]
|
|
131
133
|
}
|
|
132
134
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
// \0rolldown/runtime.js
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -20,14 +20,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
20
20
|
value: mod,
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
|
-
//#endregion
|
|
24
23
|
let _mastra_core_error = require("@mastra/core/error");
|
|
25
24
|
let _mastra_core_storage = require("@mastra/core/storage");
|
|
26
25
|
let _mastra_core_vector = require("@mastra/core/vector");
|
|
27
26
|
let cloudflare = require("cloudflare");
|
|
28
27
|
cloudflare = __toESM(cloudflare, 1);
|
|
29
28
|
let _mastra_core_vector_filter = require("@mastra/core/vector/filter");
|
|
30
|
-
|
|
29
|
+
// src/vector/filter.ts
|
|
31
30
|
var VectorizeFilterTranslator = class extends _mastra_core_vector_filter.BaseFilterTranslator {
|
|
32
31
|
getSupportedOperators() {
|
|
33
32
|
return {
|
|
@@ -73,8 +72,7 @@ var VectorizeFilterTranslator = class extends _mastra_core_vector_filter.BaseFil
|
|
|
73
72
|
return result;
|
|
74
73
|
}
|
|
75
74
|
};
|
|
76
|
-
|
|
77
|
-
//#region src/vector/index.ts
|
|
75
|
+
// src/vector/index.ts
|
|
78
76
|
var CloudflareVector = class extends _mastra_core_vector.MastraVector {
|
|
79
77
|
client;
|
|
80
78
|
accountId;
|
|
@@ -418,8 +416,7 @@ var CloudflareVector = class extends _mastra_core_vector.MastraVector {
|
|
|
418
416
|
}
|
|
419
417
|
}
|
|
420
418
|
};
|
|
421
|
-
|
|
422
|
-
//#region src/vector/prompt.ts
|
|
419
|
+
// src/vector/prompt.ts
|
|
423
420
|
/**
|
|
424
421
|
* Vector store specific prompt that details supported operators and examples.
|
|
425
422
|
* This prompt helps users construct valid filters for Vectorize.
|
|
@@ -500,7 +497,6 @@ Example Complex Query:
|
|
|
500
497
|
]}
|
|
501
498
|
]
|
|
502
499
|
}`;
|
|
503
|
-
//#endregion
|
|
504
500
|
exports.CloudflareVector = CloudflareVector;
|
|
505
501
|
exports.VECTORIZE_PROMPT = VECTORIZE_PROMPT;
|
|
506
502
|
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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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ACE,KAAA,GAAIC,qBAAAA,oBAAAA,CAAoB,aAAa,kBAAkB,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"}
|
|
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,KA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,IAAI;GACF,MAAM,KAAK,OAAO,UAAU,QAAQ,YAAY,WAAW;IACzD;IACA,YAAY,KAAK;GACnB,CAAC;EACH,SAAS,OAAO;GACd,MAAM,IAAIH,mBAAAA,YACR;IACE,KAAA,GAAIC,qBAAAA,oBAAAA,CAAoB,aAAa,kBAAkB,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/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createVectorErrorId } from "@mastra/core/storage";
|
|
|
3
3
|
import { MastraVector } from "@mastra/core/vector";
|
|
4
4
|
import Cloudflare from "cloudflare";
|
|
5
5
|
import { BaseFilterTranslator } from "@mastra/core/vector/filter";
|
|
6
|
-
|
|
6
|
+
// src/vector/filter.ts
|
|
7
7
|
var VectorizeFilterTranslator = class extends BaseFilterTranslator {
|
|
8
8
|
getSupportedOperators() {
|
|
9
9
|
return {
|
|
@@ -49,8 +49,7 @@ var VectorizeFilterTranslator = class extends BaseFilterTranslator {
|
|
|
49
49
|
return result;
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
-
|
|
53
|
-
//#region src/vector/index.ts
|
|
52
|
+
// src/vector/index.ts
|
|
54
53
|
var CloudflareVector = class extends MastraVector {
|
|
55
54
|
client;
|
|
56
55
|
accountId;
|
|
@@ -394,8 +393,7 @@ var CloudflareVector = class extends MastraVector {
|
|
|
394
393
|
}
|
|
395
394
|
}
|
|
396
395
|
};
|
|
397
|
-
|
|
398
|
-
//#region src/vector/prompt.ts
|
|
396
|
+
// src/vector/prompt.ts
|
|
399
397
|
/**
|
|
400
398
|
* Vector store specific prompt that details supported operators and examples.
|
|
401
399
|
* This prompt helps users construct valid filters for Vectorize.
|
|
@@ -476,7 +474,6 @@ Example Complex Query:
|
|
|
476
474
|
]}
|
|
477
475
|
]
|
|
478
476
|
}`;
|
|
479
|
-
//#endregion
|
|
480
477
|
export { CloudflareVector, VECTORIZE_PROMPT };
|
|
481
478
|
|
|
482
479
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"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+C,qBAA4C;CACzF,wBAA4D;EAC1D,OAAO;GACL,GAAG,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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GAClE,MAAM;GACN,QAAQ,YAAY;GACpB,UAAU,cAAc;GACxB,SAAS,EAAE,UAAU;EACvB,CAAC;EAGH,IAAI;GACF,MAAM,KAAK,OAAO,UAAU,QAAQ,YAAY,WAAW;IACzD;IACA,YAAY,KAAK;GACnB,CAAC;EACH,SAAS,OAAO;GACd,MAAM,IAAI,YACR;IACE,IAAI,oBAAoB,aAAa,kBAAkB,QAAQ;IAC/D,QAAQ,YAAY;IACpB,UAAU,cAAc;IACxB,SAAS;KACP;KACA,UAAU,IAAI;IAChB;GACF,GACA,KACF;EACF;CACF;AACF;;;;;;;ACzcA,MAAa,mBAAmB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"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+C,qBAA4C;CACzF,wBAA4D;EAC1D,OAAO;GACL,GAAG,qBAAqB;GACxB,SAAS,CAAC;GACV,OAAO,CAAC,OAAO,MAAM;GACrB,SAAS,CAAC;GACV,OAAO,CAAC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M,IAAI,YAAY;GACpB,IAAI,oBAAoB,aAAa,kBAAkB,WAAW;GAClE,MAAM;GACN,QAAQ,YAAY;GACpB,UAAU,cAAc;GACxB,SAAS,EAAE,UAAU;EACvB,CAAC;EAGH,IAAI,IAAI,WAAW,GACjB,MAAM,IAAI,YAAY;GACpB,IAAI,oBAAoB,aAAa,kBAAkB,WAAW;GAClE,MAAM;GACN,QAAQ,YAAY;GACpB,UAAU,cAAc;GACxB,SAAS,EAAE,UAAU;EACvB,CAAC;EAGH,IAAI;GACF,MAAM,KAAK,OAAO,UAAU,QAAQ,YAAY,WAAW;IACzD;IACA,YAAY,KAAK;GACnB,CAAC;EACH,SAAS,OAAO;GACd,MAAM,IAAI,YACR;IACE,IAAI,oBAAoB,aAAa,kBAAkB,QAAQ;IAC/D,QAAQ,YAAY;IACpB,UAAU,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.4",
|
|
4
4
|
"description": "Cloudflare Vectorize store provider for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -26,17 +26,17 @@
|
|
|
26
26
|
"cloudflare": "^5.2.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@types/node": "22.
|
|
30
|
-
"@vitest/coverage-v8": "4.1.
|
|
31
|
-
"@vitest/ui": "4.1.
|
|
29
|
+
"@types/node": "22.19.15",
|
|
30
|
+
"@vitest/coverage-v8": "4.1.12",
|
|
31
|
+
"@vitest/ui": "4.1.12",
|
|
32
32
|
"dotenv": "^17.4.2",
|
|
33
|
-
"tsdown": "0.
|
|
34
|
-
"tsx": "^4.23.
|
|
33
|
+
"tsdown": "0.23.1",
|
|
34
|
+
"tsx": "^4.23.15",
|
|
35
35
|
"typescript": "^7.0.2",
|
|
36
|
-
"vitest": "4.1.
|
|
37
|
-
"@internal/lint": "0.0.
|
|
38
|
-
"@internal/types-builder": "0.0.
|
|
39
|
-
"@mastra/core": "1.
|
|
36
|
+
"vitest": "4.1.12",
|
|
37
|
+
"@internal/lint": "0.0.146",
|
|
38
|
+
"@internal/types-builder": "0.0.121",
|
|
39
|
+
"@mastra/core": "1.80.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@mastra/core": ">=1.0.0-0 <2.0.0-0"
|