@mastra/vectorize 0.0.0-1.x-tester-20251106055847

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/index.js ADDED
@@ -0,0 +1,447 @@
1
+ import { MastraError, ErrorCategory, ErrorDomain } from '@mastra/core/error';
2
+ import { MastraVector } from '@mastra/core/vector';
3
+ import Cloudflare from 'cloudflare';
4
+ import { BaseFilterTranslator } from '@mastra/core/vector/filter';
5
+
6
+ // src/vector/index.ts
7
+ var VectorizeFilterTranslator = class extends BaseFilterTranslator {
8
+ getSupportedOperators() {
9
+ return {
10
+ ...BaseFilterTranslator.DEFAULT_OPERATORS,
11
+ logical: [],
12
+ array: ["$in", "$nin"],
13
+ element: [],
14
+ regex: [],
15
+ custom: []
16
+ };
17
+ }
18
+ translate(filter) {
19
+ if (this.isEmpty(filter)) return filter;
20
+ this.validateFilter(filter);
21
+ return this.translateNode(filter);
22
+ }
23
+ translateNode(node, currentPath = "") {
24
+ if (this.isRegex(node)) {
25
+ throw new Error("Regex is not supported in Vectorize");
26
+ }
27
+ if (this.isPrimitive(node)) return { $eq: this.normalizeComparisonValue(node) };
28
+ if (Array.isArray(node)) return { $in: this.normalizeArrayValues(node) };
29
+ const entries = Object.entries(node);
30
+ const firstEntry = entries[0];
31
+ if (entries.length === 1 && firstEntry && this.isOperator(firstEntry[0])) {
32
+ const [operator, value] = firstEntry;
33
+ return { [operator]: this.normalizeComparisonValue(value) };
34
+ }
35
+ const result = {};
36
+ for (const [key, value] of entries) {
37
+ const newPath = currentPath ? `${currentPath}.${key}` : key;
38
+ if (this.isOperator(key)) {
39
+ result[key] = this.normalizeComparisonValue(value);
40
+ continue;
41
+ }
42
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
43
+ if (Object.keys(value).length === 0) {
44
+ result[newPath] = this.translateNode(value);
45
+ continue;
46
+ }
47
+ const hasOperators = Object.keys(value).some((k) => this.isOperator(k));
48
+ if (hasOperators) {
49
+ result[newPath] = this.translateNode(value);
50
+ } else {
51
+ Object.assign(result, this.translateNode(value, newPath));
52
+ }
53
+ } else {
54
+ result[newPath] = this.translateNode(value);
55
+ }
56
+ }
57
+ return result;
58
+ }
59
+ };
60
+
61
+ // src/vector/index.ts
62
+ var CloudflareVector = class extends MastraVector {
63
+ client;
64
+ accountId;
65
+ constructor({ accountId, apiToken, id }) {
66
+ super({ id });
67
+ this.accountId = accountId;
68
+ this.client = new Cloudflare({
69
+ apiToken
70
+ });
71
+ }
72
+ get indexSeparator() {
73
+ return "-";
74
+ }
75
+ async upsert({ indexName, vectors, metadata, ids }) {
76
+ const generatedIds = ids || vectors.map(() => crypto.randomUUID());
77
+ const ndjson = vectors.map(
78
+ (vector, index) => JSON.stringify({
79
+ id: generatedIds[index],
80
+ values: vector,
81
+ metadata: metadata?.[index]
82
+ })
83
+ ).join("\n");
84
+ try {
85
+ await this.client.vectorize.indexes.upsert(
86
+ indexName,
87
+ {
88
+ account_id: this.accountId,
89
+ body: ndjson
90
+ },
91
+ {
92
+ __binaryRequest: true
93
+ }
94
+ );
95
+ return generatedIds;
96
+ } catch (error) {
97
+ throw new MastraError(
98
+ {
99
+ id: "STORAGE_VECTORIZE_VECTOR_UPSERT_FAILED",
100
+ domain: ErrorDomain.STORAGE,
101
+ category: ErrorCategory.THIRD_PARTY,
102
+ details: { indexName, vectorCount: vectors?.length }
103
+ },
104
+ error
105
+ );
106
+ }
107
+ }
108
+ transformFilter(filter) {
109
+ const translator = new VectorizeFilterTranslator();
110
+ return translator.translate(filter);
111
+ }
112
+ async createIndex({ indexName, dimension, metric = "cosine" }) {
113
+ try {
114
+ await this.client.vectorize.indexes.create({
115
+ account_id: this.accountId,
116
+ config: {
117
+ dimensions: dimension,
118
+ metric: metric === "dotproduct" ? "dot-product" : metric
119
+ },
120
+ name: indexName
121
+ });
122
+ } catch (error) {
123
+ const message = error?.errors?.[0]?.message || error?.message;
124
+ if (error.status === 409 || typeof message === "string" && (message.toLowerCase().includes("already exists") || message.toLowerCase().includes("duplicate"))) {
125
+ await this.validateExistingIndex(indexName, dimension, metric);
126
+ return;
127
+ }
128
+ throw new MastraError(
129
+ {
130
+ id: "STORAGE_VECTORIZE_VECTOR_CREATE_INDEX_FAILED",
131
+ domain: ErrorDomain.STORAGE,
132
+ category: ErrorCategory.THIRD_PARTY,
133
+ details: { indexName, dimension, metric }
134
+ },
135
+ error
136
+ );
137
+ }
138
+ }
139
+ async query({
140
+ indexName,
141
+ queryVector,
142
+ topK = 10,
143
+ filter,
144
+ includeVector = false
145
+ }) {
146
+ try {
147
+ const translatedFilter = this.transformFilter(filter) ?? {};
148
+ const response = await this.client.vectorize.indexes.query(indexName, {
149
+ account_id: this.accountId,
150
+ vector: queryVector,
151
+ returnValues: includeVector,
152
+ returnMetadata: "all",
153
+ topK,
154
+ filter: translatedFilter
155
+ });
156
+ return response?.matches?.map((match) => {
157
+ return {
158
+ id: match.id,
159
+ metadata: match.metadata,
160
+ score: match.score,
161
+ vector: match.values
162
+ };
163
+ }) || [];
164
+ } catch (error) {
165
+ throw new MastraError(
166
+ {
167
+ id: "STORAGE_VECTORIZE_VECTOR_QUERY_FAILED",
168
+ domain: ErrorDomain.STORAGE,
169
+ category: ErrorCategory.THIRD_PARTY,
170
+ details: { indexName, topK }
171
+ },
172
+ error
173
+ );
174
+ }
175
+ }
176
+ async listIndexes() {
177
+ try {
178
+ const res = await this.client.vectorize.indexes.list({
179
+ account_id: this.accountId
180
+ });
181
+ return res?.result?.map((index) => index.name) || [];
182
+ } catch (error) {
183
+ throw new MastraError(
184
+ {
185
+ id: "STORAGE_VECTORIZE_VECTOR_LIST_INDEXES_FAILED",
186
+ domain: ErrorDomain.STORAGE,
187
+ category: ErrorCategory.THIRD_PARTY
188
+ },
189
+ error
190
+ );
191
+ }
192
+ }
193
+ /**
194
+ * Retrieves statistics about a vector index.
195
+ *
196
+ * @param {string} indexName - The name of the index to describe
197
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
198
+ */
199
+ async describeIndex({ indexName }) {
200
+ try {
201
+ const index = await this.client.vectorize.indexes.get(indexName, {
202
+ account_id: this.accountId
203
+ });
204
+ const described = await this.client.vectorize.indexes.info(indexName, {
205
+ account_id: this.accountId
206
+ });
207
+ return {
208
+ dimension: described?.dimensions,
209
+ // Since vector_count is not available in the response,
210
+ // we might need a separate API call to get the count if needed
211
+ count: described?.vectorCount || 0,
212
+ metric: index?.config?.metric
213
+ };
214
+ } catch (error) {
215
+ throw new MastraError(
216
+ {
217
+ id: "STORAGE_VECTORIZE_VECTOR_DESCRIBE_INDEX_FAILED",
218
+ domain: ErrorDomain.STORAGE,
219
+ category: ErrorCategory.THIRD_PARTY,
220
+ details: { indexName }
221
+ },
222
+ error
223
+ );
224
+ }
225
+ }
226
+ async deleteIndex({ indexName }) {
227
+ try {
228
+ await this.client.vectorize.indexes.delete(indexName, {
229
+ account_id: this.accountId
230
+ });
231
+ } catch (error) {
232
+ throw new MastraError(
233
+ {
234
+ id: "STORAGE_VECTORIZE_VECTOR_DELETE_INDEX_FAILED",
235
+ domain: ErrorDomain.STORAGE,
236
+ category: ErrorCategory.THIRD_PARTY,
237
+ details: { indexName }
238
+ },
239
+ error
240
+ );
241
+ }
242
+ }
243
+ async createMetadataIndex(indexName, propertyName, indexType) {
244
+ try {
245
+ await this.client.vectorize.indexes.metadataIndex.create(indexName, {
246
+ account_id: this.accountId,
247
+ propertyName,
248
+ indexType
249
+ });
250
+ } catch (error) {
251
+ throw new MastraError(
252
+ {
253
+ id: "STORAGE_VECTORIZE_VECTOR_CREATE_METADATA_INDEX_FAILED",
254
+ domain: ErrorDomain.STORAGE,
255
+ category: ErrorCategory.THIRD_PARTY,
256
+ details: { indexName, propertyName, indexType }
257
+ },
258
+ error
259
+ );
260
+ }
261
+ }
262
+ async deleteMetadataIndex(indexName, propertyName) {
263
+ try {
264
+ await this.client.vectorize.indexes.metadataIndex.delete(indexName, {
265
+ account_id: this.accountId,
266
+ propertyName
267
+ });
268
+ } catch (error) {
269
+ throw new MastraError(
270
+ {
271
+ id: "STORAGE_VECTORIZE_VECTOR_DELETE_METADATA_INDEX_FAILED",
272
+ domain: ErrorDomain.STORAGE,
273
+ category: ErrorCategory.THIRD_PARTY,
274
+ details: { indexName, propertyName }
275
+ },
276
+ error
277
+ );
278
+ }
279
+ }
280
+ async listMetadataIndexes(indexName) {
281
+ try {
282
+ const res = await this.client.vectorize.indexes.metadataIndex.list(indexName, {
283
+ account_id: this.accountId
284
+ });
285
+ return res?.metadataIndexes ?? [];
286
+ } catch (error) {
287
+ throw new MastraError(
288
+ {
289
+ id: "STORAGE_VECTORIZE_VECTOR_LIST_METADATA_INDEXES_FAILED",
290
+ domain: ErrorDomain.STORAGE,
291
+ category: ErrorCategory.THIRD_PARTY,
292
+ details: { indexName }
293
+ },
294
+ error
295
+ );
296
+ }
297
+ }
298
+ /**
299
+ * Updates a vector by its ID with the provided vector and/or metadata.
300
+ * @param indexName - The name of the index containing the vector.
301
+ * @param id - The ID of the vector to update.
302
+ * @param update - An object containing the vector and/or metadata to update.
303
+ * @param update.vector - An optional array of numbers representing the new vector.
304
+ * @param update.metadata - An optional record containing the new metadata.
305
+ * @returns A promise that resolves when the update is complete.
306
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
307
+ */
308
+ async updateVector({ indexName, id, update }) {
309
+ if (!update.vector && !update.metadata) {
310
+ throw new MastraError({
311
+ id: "STORAGE_VECTORIZE_VECTOR_UPDATE_VECTOR_INVALID_ARGS",
312
+ domain: ErrorDomain.STORAGE,
313
+ category: ErrorCategory.USER,
314
+ text: "No update data provided",
315
+ details: { indexName, id }
316
+ });
317
+ }
318
+ try {
319
+ const updatePayload = {
320
+ };
321
+ if (update.vector) {
322
+ updatePayload.vectors = [update.vector];
323
+ }
324
+ if (update.metadata) {
325
+ updatePayload.metadata = [update.metadata];
326
+ }
327
+ await this.upsert({ indexName, vectors: updatePayload.vectors, metadata: updatePayload.metadata });
328
+ } catch (error) {
329
+ throw new MastraError(
330
+ {
331
+ id: "STORAGE_VECTORIZE_VECTOR_UPDATE_VECTOR_FAILED",
332
+ domain: ErrorDomain.STORAGE,
333
+ category: ErrorCategory.THIRD_PARTY,
334
+ details: { indexName, id }
335
+ },
336
+ error
337
+ );
338
+ }
339
+ }
340
+ /**
341
+ * Deletes a vector by its ID.
342
+ * @param indexName - The name of the index containing the vector.
343
+ * @param id - The ID of the vector to delete.
344
+ * @returns A promise that resolves when the deletion is complete.
345
+ * @throws Will throw an error if the deletion operation fails.
346
+ */
347
+ async deleteVector({ indexName, id }) {
348
+ try {
349
+ await this.client.vectorize.indexes.deleteByIds(indexName, {
350
+ ids: [id],
351
+ account_id: this.accountId
352
+ });
353
+ } catch (error) {
354
+ throw new MastraError(
355
+ {
356
+ id: "STORAGE_VECTORIZE_VECTOR_DELETE_VECTOR_FAILED",
357
+ domain: ErrorDomain.STORAGE,
358
+ category: ErrorCategory.THIRD_PARTY,
359
+ details: { indexName, id }
360
+ },
361
+ error
362
+ );
363
+ }
364
+ }
365
+ };
366
+
367
+ // src/vector/prompt.ts
368
+ var VECTORIZE_PROMPT = `When querying Vectorize, you can ONLY use the operators listed below. Any other operators will be rejected.
369
+ Important: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.
370
+ If 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.
371
+
372
+ Basic Comparison Operators:
373
+ - $eq: Exact match (default when using field: value)
374
+ Example: { "category": "electronics" }
375
+ - $ne: Not equal
376
+ Example: { "category": { "$ne": "electronics" } }
377
+ - $gt: Greater than
378
+ Example: { "price": { "$gt": 100 } }
379
+ - $gte: Greater than or equal
380
+ Example: { "price": { "$gte": 100 } }
381
+ - $lt: Less than
382
+ Example: { "price": { "$lt": 100 } }
383
+ - $lte: Less than or equal
384
+ Example: { "price": { "$lte": 100 } }
385
+
386
+ Array Operators:
387
+ - $in: Match any value in array
388
+ Example: { "category": { "$in": ["electronics", "books"] } }
389
+ - $nin: Does not match any value in array
390
+ Example: { "category": { "$nin": ["electronics", "books"] } }
391
+
392
+ Logical Operators:
393
+ - $and: Logical AND (can be implicit or explicit)
394
+ Implicit Example: { "price": { "$gt": 100 }, "category": "electronics" }
395
+ Explicit Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
396
+ - $or: Logical OR
397
+ Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
398
+
399
+ Element Operators:
400
+ - $exists: Check if field exists
401
+ Example: { "rating": { "$exists": true } }
402
+ - $match: Match text using full-text search
403
+ Example: { "description": { "$match": "gaming laptop" } }
404
+
405
+ Restrictions:
406
+ - Regex patterns are not supported
407
+ - Only $and and $or logical operators are supported at the top level
408
+ - Empty arrays in $in/$nin will return no results
409
+ - Nested fields are supported using dot notation
410
+ - Multiple conditions on the same field are supported with both implicit and explicit $and
411
+ - At least one key-value pair is required in filter object
412
+ - Empty objects and undefined values are treated as no filter
413
+ - Invalid types in comparison operators will throw errors
414
+ - All non-logical operators must be used within a field condition
415
+ Valid: { "field": { "$gt": 100 } }
416
+ Valid: { "$and": [...] }
417
+ Invalid: { "$gt": 100 }
418
+ - Logical operators must contain field conditions, not direct operators
419
+ Valid: { "$and": [{ "field": { "$gt": 100 } }] }
420
+ Invalid: { "$and": [{ "$gt": 100 }] }
421
+ - Logical operators ($and, $or):
422
+ - Can only be used at top level or nested within other logical operators
423
+ - Can not be used on a field level, or be nested inside a field
424
+ - Can not be used inside an operator
425
+ - Valid: { "$and": [{ "field": { "$gt": 100 } }] }
426
+ - Valid: { "$or": [{ "$and": [{ "field": { "$gt": 100 } }] }] }
427
+ - Invalid: { "field": { "$and": [{ "$gt": 100 }] } }
428
+ - Invalid: { "field": { "$or": [{ "$gt": 100 }] } }
429
+ - Invalid: { "field": { "$gt": { "$and": [{...}] } } }
430
+
431
+ Example Complex Query:
432
+ {
433
+ "$and": [
434
+ { "category": { "$in": ["electronics", "computers"] } },
435
+ { "price": { "$gte": 100, "$lte": 1000 } },
436
+ { "description": { "$match": "gaming laptop" } },
437
+ { "rating": { "$exists": true, "$gt": 4 } },
438
+ { "$or": [
439
+ { "stock": { "$gt": 0 } },
440
+ { "preorder": true }
441
+ ]}
442
+ ]
443
+ }`;
444
+
445
+ export { CloudflareVector, VECTORIZE_PROMPT };
446
+ //# sourceMappingURL=index.js.map
447
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"names":[],"mappings":";;;;;;AAsBO,IAAM,yBAAA,GAAN,cAAwC,oBAAA,CAA4C;AAAA,EACtE,qBAAA,GAAyC;AAC1D,IAAA,OAAO;AAAA,MACL,GAAG,oBAAA,CAAqB,iBAAA;AAAA,MACxB,SAAS,EAAC;AAAA,MACV,KAAA,EAAO,CAAC,KAAA,EAAO,MAAM,CAAA;AAAA,MACrB,SAAS,EAAC;AAAA,MACV,OAAO,EAAC;AAAA,MACR,QAAQ;AAAC,KACX;AAAA,EACF;AAAA,EAEA,UAAU,MAAA,EAAuD;AAC/D,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,MAAM,CAAA,EAAG,OAAO,MAAA;AACjC,IAAA,IAAA,CAAK,eAAe,MAAM,CAAA;AAC1B,IAAA,OAAO,IAAA,CAAK,cAAc,MAAM,CAAA;AAAA,EAClC;AAAA,EAEQ,aAAA,CAAc,IAAA,EAA6B,WAAA,GAAsB,EAAA,EAAS;AAChF,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,IAAI,CAAA,EAAG;AACtB,MAAA,MAAM,IAAI,MAAM,qCAAqC,CAAA;AAAA,IACvD;AACA,IAAA,IAAI,IAAA,CAAK,WAAA,CAAY,IAAI,CAAA,EAAG,OAAO,EAAE,GAAA,EAAK,IAAA,CAAK,wBAAA,CAAyB,IAAI,CAAA,EAAE;AAC9E,IAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,EAAG,OAAO,EAAE,GAAA,EAAK,IAAA,CAAK,oBAAA,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AA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,YAAA,CAAa,EAAE,SAAA,EAAW,IAAG,EAAsC;AACvE,IAAA,IAAI;AACF,MAAA,MAAM,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU,OAAA,CAAQ,YAAY,SAAA,EAAW;AAAA,QACzD,GAAA,EAAK,CAAC,EAAE,CAAA;AAAA,QACR,YAAY,IAAA,CAAK;AAAA,OAClB,CAAA;AAAA,IACH,SAAS,KAAA,EAAO;AACd,MAAA,MAAM,IAAI,WAAA;AAAA,QACR;AAAA,UACE,EAAA,EAAI,+CAAA;AAAA,UACJ,QAAQ,WAAA,CAAY,OAAA;AAAA,UACpB,UAAU,aAAA,CAAc,WAAA;AAAA,UACxB,OAAA,EAAS,EAAE,SAAA,EAAW,EAAA;AAAG,SAC3B;AAAA,QACA;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACF;;;ACxWO,IAAM,gBAAA,GAAmB,CAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA","file":"index.js","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 { 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} 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 // Note: __binaryRequest is required for proper NDJSON handling\n await this.client.vectorize.indexes.upsert(\n indexName,\n {\n account_id: this.accountId,\n body: ndjson,\n },\n {\n __binaryRequest: true,\n },\n );\n\n return generatedIds;\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_VECTORIZE_VECTOR_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: 'STORAGE_VECTORIZE_VECTOR_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 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: 'STORAGE_VECTORIZE_VECTOR_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 => index.name!) || [];\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_VECTORIZE_VECTOR_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: 'STORAGE_VECTORIZE_VECTOR_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: 'STORAGE_VECTORIZE_VECTOR_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: 'STORAGE_VECTORIZE_VECTOR_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: 'STORAGE_VECTORIZE_VECTOR_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: 'STORAGE_VECTORIZE_VECTOR_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 (!update.vector && !update.metadata) {\n throw new MastraError({\n id: 'STORAGE_VECTORIZE_VECTOR_UPDATE_VECTOR_INVALID_ARGS',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: 'No update data provided',\n details: { indexName, id },\n });\n }\n\n try {\n const updatePayload: any = {\n ids: [id],\n account_id: this.accountId,\n };\n\n if (update.vector) {\n updatePayload.vectors = [update.vector];\n }\n if (update.metadata) {\n updatePayload.metadata = [update.metadata];\n }\n\n await this.upsert({ indexName: indexName, vectors: updatePayload.vectors, metadata: updatePayload.metadata });\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_VECTORIZE_VECTOR_UPDATE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\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: 'STORAGE_VECTORIZE_VECTOR_DELETE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\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"]}
@@ -0,0 +1,13 @@
1
+ import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
+ import type { VectorFilter, OperatorSupport, OperatorValueMap, LogicalOperatorValueMap, BlacklistedRootOperators } from '@mastra/core/vector/filter';
3
+ type VectorizeOperatorValueMap = Omit<OperatorValueMap, '$regex' | '$options' | '$exists' | '$elemMatch' | '$all'>;
4
+ type VectorizeLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor' | '$not' | '$and' | '$or'>;
5
+ type VectorizeBlacklistedRootOperators = BlacklistedRootOperators | '$nor' | '$not' | '$and' | '$or';
6
+ export type VectorizeVectorFilter = VectorFilter<keyof VectorizeOperatorValueMap, VectorizeOperatorValueMap, VectorizeLogicalOperatorValueMap, VectorizeBlacklistedRootOperators>;
7
+ export declare class VectorizeFilterTranslator extends BaseFilterTranslator<VectorizeVectorFilter> {
8
+ protected getSupportedOperators(): OperatorSupport;
9
+ translate(filter?: VectorizeVectorFilter): VectorizeVectorFilter;
10
+ private translateNode;
11
+ }
12
+ export {};
13
+ //# sourceMappingURL=filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/vector/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,4BAA4B,CAAC;AAEpC,KAAK,yBAAyB,GAAG,IAAI,CAAC,gBAAgB,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,GAAG,YAAY,GAAG,MAAM,CAAC,CAAC;AAEnH,KAAK,gCAAgC,GAAG,IAAI,CAAC,uBAAuB,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC;AAExG,KAAK,iCAAiC,GAAG,wBAAwB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAErG,MAAM,MAAM,qBAAqB,GAAG,YAAY,CAC9C,MAAM,yBAAyB,EAC/B,yBAAyB,EACzB,gCAAgC,EAChC,iCAAiC,CAClC,CAAC;AAEF,qBAAa,yBAA0B,SAAQ,oBAAoB,CAAC,qBAAqB,CAAC;cACrE,qBAAqB,IAAI,eAAe;IAW3D,SAAS,CAAC,MAAM,CAAC,EAAE,qBAAqB,GAAG,qBAAqB;IAMhE,OAAO,CAAC,aAAa;CA+CtB"}
@@ -0,0 +1,53 @@
1
+ import { MastraVector } from '@mastra/core/vector';
2
+ import type { QueryResult, CreateIndexParams, UpsertVectorParams, QueryVectorParams, DescribeIndexParams, DeleteIndexParams, DeleteVectorParams, UpdateVectorParams, IndexStats } from '@mastra/core/vector';
3
+ import Cloudflare from 'cloudflare';
4
+ import type { VectorizeVectorFilter } from './filter.js';
5
+ type VectorizeQueryParams = QueryVectorParams<VectorizeVectorFilter>;
6
+ export declare class CloudflareVector extends MastraVector<VectorizeVectorFilter> {
7
+ client: Cloudflare;
8
+ accountId: string;
9
+ constructor({ accountId, apiToken, id }: {
10
+ accountId: string;
11
+ apiToken: string;
12
+ } & {
13
+ id: string;
14
+ });
15
+ get indexSeparator(): string;
16
+ upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
17
+ transformFilter(filter?: VectorizeVectorFilter): VectorizeVectorFilter;
18
+ createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
19
+ query({ indexName, queryVector, topK, filter, includeVector, }: VectorizeQueryParams): Promise<QueryResult[]>;
20
+ listIndexes(): Promise<string[]>;
21
+ /**
22
+ * Retrieves statistics about a vector index.
23
+ *
24
+ * @param {string} indexName - The name of the index to describe
25
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
26
+ */
27
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
28
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
29
+ createMetadataIndex(indexName: string, propertyName: string, indexType: 'string' | 'number' | 'boolean'): Promise<void>;
30
+ deleteMetadataIndex(indexName: string, propertyName: string): Promise<void>;
31
+ listMetadataIndexes(indexName: string): Promise<Cloudflare.Vectorize.Indexes.MetadataIndex.MetadataIndexListResponse.MetadataIndex[]>;
32
+ /**
33
+ * Updates a vector by its ID with the provided vector and/or metadata.
34
+ * @param indexName - The name of the index containing the vector.
35
+ * @param id - The ID of the vector to update.
36
+ * @param update - An object containing the vector and/or metadata to update.
37
+ * @param update.vector - An optional array of numbers representing the new vector.
38
+ * @param update.metadata - An optional record containing the new metadata.
39
+ * @returns A promise that resolves when the update is complete.
40
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
41
+ */
42
+ updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
43
+ /**
44
+ * Deletes a vector by its ID.
45
+ * @param indexName - The name of the index containing the vector.
46
+ * @param id - The ID of the vector to delete.
47
+ * @returns A promise that resolves when the deletion is complete.
48
+ * @throws Will throw an error if the deletion operation fails.
49
+ */
50
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
51
+ }
52
+ export {};
53
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vector/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,EACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,UAAU,MAAM,YAAY,CAAC;AAGpC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtD,KAAK,oBAAoB,GAAG,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;AAErE,qBAAa,gBAAiB,SAAQ,YAAY,CAAC,qBAAqB,CAAC;IACvE,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;gBAEN,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE;QAAE,SAAS,EAAE,MAAM,CAA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@ -0,0 +1,6 @@
1
+ /**
2
+ * Vector store specific prompt that details supported operators and examples.
3
+ * This prompt helps users construct valid filters for Vectorize.
4
+ */
5
+ export declare 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}";
6
+ //# sourceMappingURL=prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/vector/prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,gBAAgB,+5GA2E3B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@mastra/vectorize",
3
+ "version": "0.0.0-1.x-tester-20251106055847",
4
+ "description": "Cloudflare Vectorize store provider for Mastra",
5
+ "type": "module",
6
+ "files": [
7
+ "dist",
8
+ "CHANGELOG.md"
9
+ ],
10
+ "main": "dist/index.js",
11
+ "types": "dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "import": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ },
18
+ "require": {
19
+ "types": "./dist/index.d.ts",
20
+ "default": "./dist/index.cjs"
21
+ }
22
+ },
23
+ "./package.json": "./package.json"
24
+ },
25
+ "license": "Apache-2.0",
26
+ "dependencies": {
27
+ "cloudflare": "^4.5.0"
28
+ },
29
+ "devDependencies": {
30
+ "@microsoft/api-extractor": "^7.52.8",
31
+ "@types/node": "^20.19.0",
32
+ "dotenv": "^17.0.0",
33
+ "eslint": "^9.37.0",
34
+ "tsup": "^8.5.0",
35
+ "typescript": "^5.8.3",
36
+ "vitest": "^3.2.4",
37
+ "@internal/lint": "0.0.0-1.x-tester-20251106055847",
38
+ "@mastra/core": "0.0.0-1.x-tester-20251106055847",
39
+ "@internal/types-builder": "0.0.0-1.x-tester-20251106055847"
40
+ },
41
+ "peerDependencies": {
42
+ "@mastra/core": "0.0.0-1.x-tester-20251106055847"
43
+ },
44
+ "homepage": "https://mastra.ai",
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/mastra-ai/mastra.git",
48
+ "directory": "stores/vectorize"
49
+ },
50
+ "bugs": {
51
+ "url": "https://github.com/mastra-ai/mastra/issues"
52
+ },
53
+ "engines": {
54
+ "node": ">=22.13.0"
55
+ },
56
+ "scripts": {
57
+ "build": "tsup --silent --config tsup.config.ts",
58
+ "build:watch": "tsup --watch --silent --config tsup.config.ts",
59
+ "test": "vitest run",
60
+ "lint": "eslint ."
61
+ }
62
+ }