@mastra/vectorize 0.2.10 → 0.3.0-alpha.1
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/_tsup-dts-rollup.d.cts +18 -41
- package/dist/_tsup-dts-rollup.d.ts +18 -41
- package/dist/index.cjs +19 -50
- package/dist/index.js +19 -50
- package/package.json +7 -4
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
2
2
|
import Cloudflare from 'cloudflare';
|
|
3
3
|
import type { CreateIndexParams } from '@mastra/core/vector';
|
|
4
|
+
import type { DeleteIndexParams } from '@mastra/core/vector';
|
|
5
|
+
import type { DeleteVectorParams } from '@mastra/core/vector';
|
|
6
|
+
import type { DescribeIndexParams } from '@mastra/core/vector';
|
|
7
|
+
import type { IndexStats } from '@mastra/core/vector';
|
|
4
8
|
import { MastraVector } from '@mastra/core/vector';
|
|
5
9
|
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
6
|
-
import type { ParamsToArgs } from '@mastra/core/vector';
|
|
7
10
|
import type { QueryResult } from '@mastra/core/vector';
|
|
8
11
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
12
|
+
import type { UpdateVectorParams } from '@mastra/core/vector';
|
|
9
13
|
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
10
14
|
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
11
15
|
|
|
@@ -17,36 +21,22 @@ declare class CloudflareVector extends MastraVector {
|
|
|
17
21
|
apiToken: string;
|
|
18
22
|
});
|
|
19
23
|
get indexSeparator(): string;
|
|
20
|
-
upsert(
|
|
24
|
+
upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
|
|
21
25
|
transformFilter(filter?: VectorFilter): VectorFilter;
|
|
22
|
-
createIndex(
|
|
23
|
-
query(
|
|
26
|
+
createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
|
|
27
|
+
query({ indexName, queryVector, topK, filter, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
|
|
24
28
|
listIndexes(): Promise<string[]>;
|
|
25
|
-
describeIndex(indexName: string): Promise<{
|
|
26
|
-
dimension: number;
|
|
27
|
-
count: number;
|
|
28
|
-
metric: "cosine" | "euclidean" | "dotproduct";
|
|
29
|
-
}>;
|
|
30
|
-
deleteIndex(indexName: string): Promise<void>;
|
|
31
|
-
createMetadataIndex(indexName: string, propertyName: string, indexType: 'string' | 'number' | 'boolean'): Promise<void>;
|
|
32
|
-
deleteMetadataIndex(indexName: string, propertyName: string): Promise<void>;
|
|
33
|
-
listMetadataIndexes(indexName: string): Promise<Cloudflare.Vectorize.Indexes.MetadataIndex.MetadataIndexListResponse.MetadataIndex[]>;
|
|
34
29
|
/**
|
|
35
|
-
*
|
|
30
|
+
* Retrieves statistics about a vector index.
|
|
36
31
|
*
|
|
37
|
-
*
|
|
38
|
-
* @
|
|
39
|
-
* @param id - The ID of the vector to update.
|
|
40
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
41
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
42
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
43
|
-
* @returns A promise that resolves when the update is complete.
|
|
44
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
32
|
+
* @param {string} indexName - The name of the index to describe
|
|
33
|
+
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
45
34
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
35
|
+
describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
|
|
36
|
+
deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
|
|
37
|
+
createMetadataIndex(indexName: string, propertyName: string, indexType: 'string' | 'number' | 'boolean'): Promise<void>;
|
|
38
|
+
deleteMetadataIndex(indexName: string, propertyName: string): Promise<void>;
|
|
39
|
+
listMetadataIndexes(indexName: string): Promise<Cloudflare.Vectorize.Indexes.MetadataIndex.MetadataIndexListResponse.MetadataIndex[]>;
|
|
50
40
|
/**
|
|
51
41
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
52
42
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -57,20 +47,7 @@ declare class CloudflareVector extends MastraVector {
|
|
|
57
47
|
* @returns A promise that resolves when the update is complete.
|
|
58
48
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
59
49
|
*/
|
|
60
|
-
updateVector(indexName
|
|
61
|
-
vector?: number[];
|
|
62
|
-
metadata?: Record<string, any>;
|
|
63
|
-
}): Promise<void>;
|
|
64
|
-
/**
|
|
65
|
-
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
66
|
-
*
|
|
67
|
-
* Deletes a vector by its ID.
|
|
68
|
-
* @param indexName - The name of the index containing the vector.
|
|
69
|
-
* @param id - The ID of the vector to delete.
|
|
70
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
71
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
72
|
-
*/
|
|
73
|
-
deleteIndexById(indexName: string, id: string): Promise<void>;
|
|
50
|
+
updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
|
|
74
51
|
/**
|
|
75
52
|
* Deletes a vector by its ID.
|
|
76
53
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -78,7 +55,7 @@ declare class CloudflareVector extends MastraVector {
|
|
|
78
55
|
* @returns A promise that resolves when the deletion is complete.
|
|
79
56
|
* @throws Will throw an error if the deletion operation fails.
|
|
80
57
|
*/
|
|
81
|
-
deleteVector(indexName
|
|
58
|
+
deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
|
|
82
59
|
}
|
|
83
60
|
export { CloudflareVector }
|
|
84
61
|
export { CloudflareVector as CloudflareVector_alias_1 }
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
2
2
|
import Cloudflare from 'cloudflare';
|
|
3
3
|
import type { CreateIndexParams } from '@mastra/core/vector';
|
|
4
|
+
import type { DeleteIndexParams } from '@mastra/core/vector';
|
|
5
|
+
import type { DeleteVectorParams } from '@mastra/core/vector';
|
|
6
|
+
import type { DescribeIndexParams } from '@mastra/core/vector';
|
|
7
|
+
import type { IndexStats } from '@mastra/core/vector';
|
|
4
8
|
import { MastraVector } from '@mastra/core/vector';
|
|
5
9
|
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
6
|
-
import type { ParamsToArgs } from '@mastra/core/vector';
|
|
7
10
|
import type { QueryResult } from '@mastra/core/vector';
|
|
8
11
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
12
|
+
import type { UpdateVectorParams } from '@mastra/core/vector';
|
|
9
13
|
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
10
14
|
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
11
15
|
|
|
@@ -17,36 +21,22 @@ declare class CloudflareVector extends MastraVector {
|
|
|
17
21
|
apiToken: string;
|
|
18
22
|
});
|
|
19
23
|
get indexSeparator(): string;
|
|
20
|
-
upsert(
|
|
24
|
+
upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
|
|
21
25
|
transformFilter(filter?: VectorFilter): VectorFilter;
|
|
22
|
-
createIndex(
|
|
23
|
-
query(
|
|
26
|
+
createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
|
|
27
|
+
query({ indexName, queryVector, topK, filter, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
|
|
24
28
|
listIndexes(): Promise<string[]>;
|
|
25
|
-
describeIndex(indexName: string): Promise<{
|
|
26
|
-
dimension: number;
|
|
27
|
-
count: number;
|
|
28
|
-
metric: "cosine" | "euclidean" | "dotproduct";
|
|
29
|
-
}>;
|
|
30
|
-
deleteIndex(indexName: string): Promise<void>;
|
|
31
|
-
createMetadataIndex(indexName: string, propertyName: string, indexType: 'string' | 'number' | 'boolean'): Promise<void>;
|
|
32
|
-
deleteMetadataIndex(indexName: string, propertyName: string): Promise<void>;
|
|
33
|
-
listMetadataIndexes(indexName: string): Promise<Cloudflare.Vectorize.Indexes.MetadataIndex.MetadataIndexListResponse.MetadataIndex[]>;
|
|
34
29
|
/**
|
|
35
|
-
*
|
|
30
|
+
* Retrieves statistics about a vector index.
|
|
36
31
|
*
|
|
37
|
-
*
|
|
38
|
-
* @
|
|
39
|
-
* @param id - The ID of the vector to update.
|
|
40
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
41
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
42
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
43
|
-
* @returns A promise that resolves when the update is complete.
|
|
44
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
32
|
+
* @param {string} indexName - The name of the index to describe
|
|
33
|
+
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
45
34
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
35
|
+
describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
|
|
36
|
+
deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
|
|
37
|
+
createMetadataIndex(indexName: string, propertyName: string, indexType: 'string' | 'number' | 'boolean'): Promise<void>;
|
|
38
|
+
deleteMetadataIndex(indexName: string, propertyName: string): Promise<void>;
|
|
39
|
+
listMetadataIndexes(indexName: string): Promise<Cloudflare.Vectorize.Indexes.MetadataIndex.MetadataIndexListResponse.MetadataIndex[]>;
|
|
50
40
|
/**
|
|
51
41
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
52
42
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -57,20 +47,7 @@ declare class CloudflareVector extends MastraVector {
|
|
|
57
47
|
* @returns A promise that resolves when the update is complete.
|
|
58
48
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
59
49
|
*/
|
|
60
|
-
updateVector(indexName
|
|
61
|
-
vector?: number[];
|
|
62
|
-
metadata?: Record<string, any>;
|
|
63
|
-
}): Promise<void>;
|
|
64
|
-
/**
|
|
65
|
-
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
66
|
-
*
|
|
67
|
-
* Deletes a vector by its ID.
|
|
68
|
-
* @param indexName - The name of the index containing the vector.
|
|
69
|
-
* @param id - The ID of the vector to delete.
|
|
70
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
71
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
72
|
-
*/
|
|
73
|
-
deleteIndexById(indexName: string, id: string): Promise<void>;
|
|
50
|
+
updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
|
|
74
51
|
/**
|
|
75
52
|
* Deletes a vector by its ID.
|
|
76
53
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -78,7 +55,7 @@ declare class CloudflareVector extends MastraVector {
|
|
|
78
55
|
* @returns A promise that resolves when the deletion is complete.
|
|
79
56
|
* @throws Will throw an error if the deletion operation fails.
|
|
80
57
|
*/
|
|
81
|
-
deleteVector(indexName
|
|
58
|
+
deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
|
|
82
59
|
}
|
|
83
60
|
export { CloudflareVector }
|
|
84
61
|
export { CloudflareVector as CloudflareVector_alias_1 }
|
package/dist/index.cjs
CHANGED
|
@@ -77,9 +77,7 @@ var CloudflareVector = class extends vector.MastraVector {
|
|
|
77
77
|
get indexSeparator() {
|
|
78
78
|
return "-";
|
|
79
79
|
}
|
|
80
|
-
async upsert(
|
|
81
|
-
const params = this.normalizeArgs("upsert", args);
|
|
82
|
-
const { indexName, vectors, metadata, ids } = params;
|
|
80
|
+
async upsert({ indexName, vectors, metadata, ids }) {
|
|
83
81
|
const generatedIds = ids || vectors.map(() => crypto.randomUUID());
|
|
84
82
|
const ndjson = vectors.map(
|
|
85
83
|
(vector, index) => JSON.stringify({
|
|
@@ -104,9 +102,7 @@ var CloudflareVector = class extends vector.MastraVector {
|
|
|
104
102
|
const translator = new VectorizeFilterTranslator();
|
|
105
103
|
return translator.translate(filter);
|
|
106
104
|
}
|
|
107
|
-
async createIndex(
|
|
108
|
-
const params = this.normalizeArgs("createIndex", args);
|
|
109
|
-
const { indexName, dimension, metric = "cosine" } = params;
|
|
105
|
+
async createIndex({ indexName, dimension, metric = "cosine" }) {
|
|
110
106
|
try {
|
|
111
107
|
await this.client.vectorize.indexes.create({
|
|
112
108
|
account_id: this.accountId,
|
|
@@ -125,9 +121,13 @@ var CloudflareVector = class extends vector.MastraVector {
|
|
|
125
121
|
throw error;
|
|
126
122
|
}
|
|
127
123
|
}
|
|
128
|
-
async query(
|
|
129
|
-
|
|
130
|
-
|
|
124
|
+
async query({
|
|
125
|
+
indexName,
|
|
126
|
+
queryVector,
|
|
127
|
+
topK = 10,
|
|
128
|
+
filter,
|
|
129
|
+
includeVector = false
|
|
130
|
+
}) {
|
|
131
131
|
const translatedFilter = this.transformFilter(filter) ?? {};
|
|
132
132
|
const response = await this.client.vectorize.indexes.query(indexName, {
|
|
133
133
|
account_id: this.accountId,
|
|
@@ -152,7 +152,13 @@ var CloudflareVector = class extends vector.MastraVector {
|
|
|
152
152
|
});
|
|
153
153
|
return res?.result?.map((index) => index.name) || [];
|
|
154
154
|
}
|
|
155
|
-
|
|
155
|
+
/**
|
|
156
|
+
* Retrieves statistics about a vector index.
|
|
157
|
+
*
|
|
158
|
+
* @param {string} indexName - The name of the index to describe
|
|
159
|
+
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
160
|
+
*/
|
|
161
|
+
async describeIndex({ indexName }) {
|
|
156
162
|
const index = await this.client.vectorize.indexes.get(indexName, {
|
|
157
163
|
account_id: this.accountId
|
|
158
164
|
});
|
|
@@ -167,7 +173,7 @@ var CloudflareVector = class extends vector.MastraVector {
|
|
|
167
173
|
metric: index?.config?.metric
|
|
168
174
|
};
|
|
169
175
|
}
|
|
170
|
-
async deleteIndex(indexName) {
|
|
176
|
+
async deleteIndex({ indexName }) {
|
|
171
177
|
await this.client.vectorize.indexes.delete(indexName, {
|
|
172
178
|
account_id: this.accountId
|
|
173
179
|
});
|
|
@@ -191,26 +197,6 @@ var CloudflareVector = class extends vector.MastraVector {
|
|
|
191
197
|
});
|
|
192
198
|
return res?.metadataIndexes ?? [];
|
|
193
199
|
}
|
|
194
|
-
/**
|
|
195
|
-
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
196
|
-
*
|
|
197
|
-
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
198
|
-
* @param indexName - The name of the index containing the vector.
|
|
199
|
-
* @param id - The ID of the vector to update.
|
|
200
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
201
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
202
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
203
|
-
* @returns A promise that resolves when the update is complete.
|
|
204
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
205
|
-
*/
|
|
206
|
-
async updateIndexById(indexName, id, update) {
|
|
207
|
-
this.logger.warn(
|
|
208
|
-
`Deprecation Warning: updateIndexById() is deprecated.
|
|
209
|
-
Please use updateVector() instead.
|
|
210
|
-
updateIndexById() will be removed on May 20th, 2025.`
|
|
211
|
-
);
|
|
212
|
-
await this.updateVector(indexName, id, update);
|
|
213
|
-
}
|
|
214
200
|
/**
|
|
215
201
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
216
202
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -221,7 +207,7 @@ var CloudflareVector = class extends vector.MastraVector {
|
|
|
221
207
|
* @returns A promise that resolves when the update is complete.
|
|
222
208
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
223
209
|
*/
|
|
224
|
-
async updateVector(indexName, id, update) {
|
|
210
|
+
async updateVector({ indexName, id, update }) {
|
|
225
211
|
try {
|
|
226
212
|
if (!update.vector && !update.metadata) {
|
|
227
213
|
throw new Error("No update data provided");
|
|
@@ -239,23 +225,6 @@ var CloudflareVector = class extends vector.MastraVector {
|
|
|
239
225
|
throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
|
|
240
226
|
}
|
|
241
227
|
}
|
|
242
|
-
/**
|
|
243
|
-
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
244
|
-
*
|
|
245
|
-
* Deletes a vector by its ID.
|
|
246
|
-
* @param indexName - The name of the index containing the vector.
|
|
247
|
-
* @param id - The ID of the vector to delete.
|
|
248
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
249
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
250
|
-
*/
|
|
251
|
-
async deleteIndexById(indexName, id) {
|
|
252
|
-
this.logger.warn(
|
|
253
|
-
`Deprecation Warning: deleteIndexById() is deprecated.
|
|
254
|
-
Please use deleteVector() instead.
|
|
255
|
-
deleteIndexById() will be removed on May 20th, 2025.`
|
|
256
|
-
);
|
|
257
|
-
await this.deleteVector(indexName, id);
|
|
258
|
-
}
|
|
259
228
|
/**
|
|
260
229
|
* Deletes a vector by its ID.
|
|
261
230
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -263,7 +232,7 @@ var CloudflareVector = class extends vector.MastraVector {
|
|
|
263
232
|
* @returns A promise that resolves when the deletion is complete.
|
|
264
233
|
* @throws Will throw an error if the deletion operation fails.
|
|
265
234
|
*/
|
|
266
|
-
async deleteVector(indexName, id) {
|
|
235
|
+
async deleteVector({ indexName, id }) {
|
|
267
236
|
try {
|
|
268
237
|
await this.client.vectorize.indexes.deleteByIds(indexName, {
|
|
269
238
|
ids: [id],
|
package/dist/index.js
CHANGED
|
@@ -71,9 +71,7 @@ var CloudflareVector = class extends MastraVector {
|
|
|
71
71
|
get indexSeparator() {
|
|
72
72
|
return "-";
|
|
73
73
|
}
|
|
74
|
-
async upsert(
|
|
75
|
-
const params = this.normalizeArgs("upsert", args);
|
|
76
|
-
const { indexName, vectors, metadata, ids } = params;
|
|
74
|
+
async upsert({ indexName, vectors, metadata, ids }) {
|
|
77
75
|
const generatedIds = ids || vectors.map(() => crypto.randomUUID());
|
|
78
76
|
const ndjson = vectors.map(
|
|
79
77
|
(vector, index) => JSON.stringify({
|
|
@@ -98,9 +96,7 @@ var CloudflareVector = class extends MastraVector {
|
|
|
98
96
|
const translator = new VectorizeFilterTranslator();
|
|
99
97
|
return translator.translate(filter);
|
|
100
98
|
}
|
|
101
|
-
async createIndex(
|
|
102
|
-
const params = this.normalizeArgs("createIndex", args);
|
|
103
|
-
const { indexName, dimension, metric = "cosine" } = params;
|
|
99
|
+
async createIndex({ indexName, dimension, metric = "cosine" }) {
|
|
104
100
|
try {
|
|
105
101
|
await this.client.vectorize.indexes.create({
|
|
106
102
|
account_id: this.accountId,
|
|
@@ -119,9 +115,13 @@ var CloudflareVector = class extends MastraVector {
|
|
|
119
115
|
throw error;
|
|
120
116
|
}
|
|
121
117
|
}
|
|
122
|
-
async query(
|
|
123
|
-
|
|
124
|
-
|
|
118
|
+
async query({
|
|
119
|
+
indexName,
|
|
120
|
+
queryVector,
|
|
121
|
+
topK = 10,
|
|
122
|
+
filter,
|
|
123
|
+
includeVector = false
|
|
124
|
+
}) {
|
|
125
125
|
const translatedFilter = this.transformFilter(filter) ?? {};
|
|
126
126
|
const response = await this.client.vectorize.indexes.query(indexName, {
|
|
127
127
|
account_id: this.accountId,
|
|
@@ -146,7 +146,13 @@ var CloudflareVector = class extends MastraVector {
|
|
|
146
146
|
});
|
|
147
147
|
return res?.result?.map((index) => index.name) || [];
|
|
148
148
|
}
|
|
149
|
-
|
|
149
|
+
/**
|
|
150
|
+
* Retrieves statistics about a vector index.
|
|
151
|
+
*
|
|
152
|
+
* @param {string} indexName - The name of the index to describe
|
|
153
|
+
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
154
|
+
*/
|
|
155
|
+
async describeIndex({ indexName }) {
|
|
150
156
|
const index = await this.client.vectorize.indexes.get(indexName, {
|
|
151
157
|
account_id: this.accountId
|
|
152
158
|
});
|
|
@@ -161,7 +167,7 @@ var CloudflareVector = class extends MastraVector {
|
|
|
161
167
|
metric: index?.config?.metric
|
|
162
168
|
};
|
|
163
169
|
}
|
|
164
|
-
async deleteIndex(indexName) {
|
|
170
|
+
async deleteIndex({ indexName }) {
|
|
165
171
|
await this.client.vectorize.indexes.delete(indexName, {
|
|
166
172
|
account_id: this.accountId
|
|
167
173
|
});
|
|
@@ -185,26 +191,6 @@ var CloudflareVector = class extends MastraVector {
|
|
|
185
191
|
});
|
|
186
192
|
return res?.metadataIndexes ?? [];
|
|
187
193
|
}
|
|
188
|
-
/**
|
|
189
|
-
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
190
|
-
*
|
|
191
|
-
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
192
|
-
* @param indexName - The name of the index containing the vector.
|
|
193
|
-
* @param id - The ID of the vector to update.
|
|
194
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
195
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
196
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
197
|
-
* @returns A promise that resolves when the update is complete.
|
|
198
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
199
|
-
*/
|
|
200
|
-
async updateIndexById(indexName, id, update) {
|
|
201
|
-
this.logger.warn(
|
|
202
|
-
`Deprecation Warning: updateIndexById() is deprecated.
|
|
203
|
-
Please use updateVector() instead.
|
|
204
|
-
updateIndexById() will be removed on May 20th, 2025.`
|
|
205
|
-
);
|
|
206
|
-
await this.updateVector(indexName, id, update);
|
|
207
|
-
}
|
|
208
194
|
/**
|
|
209
195
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
210
196
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -215,7 +201,7 @@ var CloudflareVector = class extends MastraVector {
|
|
|
215
201
|
* @returns A promise that resolves when the update is complete.
|
|
216
202
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
217
203
|
*/
|
|
218
|
-
async updateVector(indexName, id, update) {
|
|
204
|
+
async updateVector({ indexName, id, update }) {
|
|
219
205
|
try {
|
|
220
206
|
if (!update.vector && !update.metadata) {
|
|
221
207
|
throw new Error("No update data provided");
|
|
@@ -233,23 +219,6 @@ var CloudflareVector = class extends MastraVector {
|
|
|
233
219
|
throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
|
|
234
220
|
}
|
|
235
221
|
}
|
|
236
|
-
/**
|
|
237
|
-
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
238
|
-
*
|
|
239
|
-
* Deletes a vector by its ID.
|
|
240
|
-
* @param indexName - The name of the index containing the vector.
|
|
241
|
-
* @param id - The ID of the vector to delete.
|
|
242
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
243
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
244
|
-
*/
|
|
245
|
-
async deleteIndexById(indexName, id) {
|
|
246
|
-
this.logger.warn(
|
|
247
|
-
`Deprecation Warning: deleteIndexById() is deprecated.
|
|
248
|
-
Please use deleteVector() instead.
|
|
249
|
-
deleteIndexById() will be removed on May 20th, 2025.`
|
|
250
|
-
);
|
|
251
|
-
await this.deleteVector(indexName, id);
|
|
252
|
-
}
|
|
253
222
|
/**
|
|
254
223
|
* Deletes a vector by its ID.
|
|
255
224
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -257,7 +226,7 @@ var CloudflareVector = class extends MastraVector {
|
|
|
257
226
|
* @returns A promise that resolves when the deletion is complete.
|
|
258
227
|
* @throws Will throw an error if the deletion operation fails.
|
|
259
228
|
*/
|
|
260
|
-
async deleteVector(indexName, id) {
|
|
229
|
+
async deleteVector({ indexName, id }) {
|
|
261
230
|
try {
|
|
262
231
|
await this.client.vectorize.indexes.deleteByIds(indexName, {
|
|
263
232
|
ids: [id],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/vectorize",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-alpha.1",
|
|
4
4
|
"description": "Cloudflare Vectorize store provider for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"cloudflare": "^4.1.0"
|
|
27
|
-
"@mastra/core": "^0.9.4"
|
|
26
|
+
"cloudflare": "^4.1.0"
|
|
28
27
|
},
|
|
29
28
|
"devDependencies": {
|
|
30
29
|
"@microsoft/api-extractor": "^7.52.5",
|
|
@@ -34,7 +33,11 @@
|
|
|
34
33
|
"tsup": "^8.4.0",
|
|
35
34
|
"typescript": "^5.8.2",
|
|
36
35
|
"vitest": "^3.1.2",
|
|
37
|
-
"@internal/lint": "0.0.5"
|
|
36
|
+
"@internal/lint": "0.0.5",
|
|
37
|
+
"@mastra/core": "0.10.0-alpha.1"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@mastra/core": "^0.9.4"
|
|
38
41
|
},
|
|
39
42
|
"scripts": {
|
|
40
43
|
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
|