@mastra/vectorize 0.2.11-alpha.0 → 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 +8 -36
- package/dist/_tsup-dts-rollup.d.ts +8 -36
- package/dist/index.cjs +14 -60
- package/dist/index.js +14 -60
- package/package.json +7 -4
|
@@ -7,7 +7,6 @@ import type { DescribeIndexParams } from '@mastra/core/vector';
|
|
|
7
7
|
import type { IndexStats } from '@mastra/core/vector';
|
|
8
8
|
import { MastraVector } from '@mastra/core/vector';
|
|
9
9
|
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
10
|
-
import type { ParamsToArgs } from '@mastra/core/vector';
|
|
11
10
|
import type { QueryResult } from '@mastra/core/vector';
|
|
12
11
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
13
12
|
import type { UpdateVectorParams } from '@mastra/core/vector';
|
|
@@ -22,26 +21,23 @@ declare class CloudflareVector extends MastraVector {
|
|
|
22
21
|
apiToken: string;
|
|
23
22
|
});
|
|
24
23
|
get indexSeparator(): string;
|
|
25
|
-
upsert(
|
|
24
|
+
upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
|
|
26
25
|
transformFilter(filter?: VectorFilter): VectorFilter;
|
|
27
|
-
createIndex(
|
|
28
|
-
query(
|
|
26
|
+
createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
|
|
27
|
+
query({ indexName, queryVector, topK, filter, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
|
|
29
28
|
listIndexes(): Promise<string[]>;
|
|
30
29
|
/**
|
|
31
30
|
* Retrieves statistics about a vector index.
|
|
32
31
|
*
|
|
33
|
-
* @param
|
|
34
|
-
* @param params.indexName - The name of the index to describe
|
|
32
|
+
* @param {string} indexName - The name of the index to describe
|
|
35
33
|
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
36
34
|
*/
|
|
37
|
-
describeIndex(
|
|
38
|
-
deleteIndex(
|
|
35
|
+
describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
|
|
36
|
+
deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
|
|
39
37
|
createMetadataIndex(indexName: string, propertyName: string, indexType: 'string' | 'number' | 'boolean'): Promise<void>;
|
|
40
38
|
deleteMetadataIndex(indexName: string, propertyName: string): Promise<void>;
|
|
41
39
|
listMetadataIndexes(indexName: string): Promise<Cloudflare.Vectorize.Indexes.MetadataIndex.MetadataIndexListResponse.MetadataIndex[]>;
|
|
42
40
|
/**
|
|
43
|
-
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
44
|
-
*
|
|
45
41
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
46
42
|
* @param indexName - The name of the index containing the vector.
|
|
47
43
|
* @param id - The ID of the vector to update.
|
|
@@ -51,31 +47,7 @@ declare class CloudflareVector extends MastraVector {
|
|
|
51
47
|
* @returns A promise that resolves when the update is complete.
|
|
52
48
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
53
49
|
*/
|
|
54
|
-
|
|
55
|
-
vector?: number[];
|
|
56
|
-
metadata?: Record<string, any>;
|
|
57
|
-
}): Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
60
|
-
* @param indexName - The name of the index containing the vector.
|
|
61
|
-
* @param id - The ID of the vector to update.
|
|
62
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
63
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
64
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
65
|
-
* @returns A promise that resolves when the update is complete.
|
|
66
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
67
|
-
*/
|
|
68
|
-
updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
|
|
69
|
-
/**
|
|
70
|
-
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
71
|
-
*
|
|
72
|
-
* Deletes a vector by its ID.
|
|
73
|
-
* @param indexName - The name of the index containing the vector.
|
|
74
|
-
* @param id - The ID of the vector to delete.
|
|
75
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
76
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
77
|
-
*/
|
|
78
|
-
deleteIndexById(indexName: string, id: string): Promise<void>;
|
|
50
|
+
updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
|
|
79
51
|
/**
|
|
80
52
|
* Deletes a vector by its ID.
|
|
81
53
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -83,7 +55,7 @@ declare class CloudflareVector extends MastraVector {
|
|
|
83
55
|
* @returns A promise that resolves when the deletion is complete.
|
|
84
56
|
* @throws Will throw an error if the deletion operation fails.
|
|
85
57
|
*/
|
|
86
|
-
deleteVector(
|
|
58
|
+
deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
|
|
87
59
|
}
|
|
88
60
|
export { CloudflareVector }
|
|
89
61
|
export { CloudflareVector as CloudflareVector_alias_1 }
|
|
@@ -7,7 +7,6 @@ import type { DescribeIndexParams } from '@mastra/core/vector';
|
|
|
7
7
|
import type { IndexStats } from '@mastra/core/vector';
|
|
8
8
|
import { MastraVector } from '@mastra/core/vector';
|
|
9
9
|
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
10
|
-
import type { ParamsToArgs } from '@mastra/core/vector';
|
|
11
10
|
import type { QueryResult } from '@mastra/core/vector';
|
|
12
11
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
13
12
|
import type { UpdateVectorParams } from '@mastra/core/vector';
|
|
@@ -22,26 +21,23 @@ declare class CloudflareVector extends MastraVector {
|
|
|
22
21
|
apiToken: string;
|
|
23
22
|
});
|
|
24
23
|
get indexSeparator(): string;
|
|
25
|
-
upsert(
|
|
24
|
+
upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
|
|
26
25
|
transformFilter(filter?: VectorFilter): VectorFilter;
|
|
27
|
-
createIndex(
|
|
28
|
-
query(
|
|
26
|
+
createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
|
|
27
|
+
query({ indexName, queryVector, topK, filter, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
|
|
29
28
|
listIndexes(): Promise<string[]>;
|
|
30
29
|
/**
|
|
31
30
|
* Retrieves statistics about a vector index.
|
|
32
31
|
*
|
|
33
|
-
* @param
|
|
34
|
-
* @param params.indexName - The name of the index to describe
|
|
32
|
+
* @param {string} indexName - The name of the index to describe
|
|
35
33
|
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
36
34
|
*/
|
|
37
|
-
describeIndex(
|
|
38
|
-
deleteIndex(
|
|
35
|
+
describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
|
|
36
|
+
deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
|
|
39
37
|
createMetadataIndex(indexName: string, propertyName: string, indexType: 'string' | 'number' | 'boolean'): Promise<void>;
|
|
40
38
|
deleteMetadataIndex(indexName: string, propertyName: string): Promise<void>;
|
|
41
39
|
listMetadataIndexes(indexName: string): Promise<Cloudflare.Vectorize.Indexes.MetadataIndex.MetadataIndexListResponse.MetadataIndex[]>;
|
|
42
40
|
/**
|
|
43
|
-
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
44
|
-
*
|
|
45
41
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
46
42
|
* @param indexName - The name of the index containing the vector.
|
|
47
43
|
* @param id - The ID of the vector to update.
|
|
@@ -51,31 +47,7 @@ declare class CloudflareVector extends MastraVector {
|
|
|
51
47
|
* @returns A promise that resolves when the update is complete.
|
|
52
48
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
53
49
|
*/
|
|
54
|
-
|
|
55
|
-
vector?: number[];
|
|
56
|
-
metadata?: Record<string, any>;
|
|
57
|
-
}): Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
60
|
-
* @param indexName - The name of the index containing the vector.
|
|
61
|
-
* @param id - The ID of the vector to update.
|
|
62
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
63
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
64
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
65
|
-
* @returns A promise that resolves when the update is complete.
|
|
66
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
67
|
-
*/
|
|
68
|
-
updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
|
|
69
|
-
/**
|
|
70
|
-
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
71
|
-
*
|
|
72
|
-
* Deletes a vector by its ID.
|
|
73
|
-
* @param indexName - The name of the index containing the vector.
|
|
74
|
-
* @param id - The ID of the vector to delete.
|
|
75
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
76
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
77
|
-
*/
|
|
78
|
-
deleteIndexById(indexName: string, id: string): Promise<void>;
|
|
50
|
+
updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
|
|
79
51
|
/**
|
|
80
52
|
* Deletes a vector by its ID.
|
|
81
53
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -83,7 +55,7 @@ declare class CloudflareVector extends MastraVector {
|
|
|
83
55
|
* @returns A promise that resolves when the deletion is complete.
|
|
84
56
|
* @throws Will throw an error if the deletion operation fails.
|
|
85
57
|
*/
|
|
86
|
-
deleteVector(
|
|
58
|
+
deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
|
|
87
59
|
}
|
|
88
60
|
export { CloudflareVector }
|
|
89
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,
|
|
@@ -155,13 +155,10 @@ var CloudflareVector = class extends vector.MastraVector {
|
|
|
155
155
|
/**
|
|
156
156
|
* Retrieves statistics about a vector index.
|
|
157
157
|
*
|
|
158
|
-
* @param
|
|
159
|
-
* @param params.indexName - The name of the index to describe
|
|
158
|
+
* @param {string} indexName - The name of the index to describe
|
|
160
159
|
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
161
160
|
*/
|
|
162
|
-
async describeIndex(
|
|
163
|
-
const params = this.normalizeArgs("describeIndex", args);
|
|
164
|
-
const { indexName } = params;
|
|
161
|
+
async describeIndex({ indexName }) {
|
|
165
162
|
const index = await this.client.vectorize.indexes.get(indexName, {
|
|
166
163
|
account_id: this.accountId
|
|
167
164
|
});
|
|
@@ -176,9 +173,7 @@ var CloudflareVector = class extends vector.MastraVector {
|
|
|
176
173
|
metric: index?.config?.metric
|
|
177
174
|
};
|
|
178
175
|
}
|
|
179
|
-
async deleteIndex(
|
|
180
|
-
const params = this.normalizeArgs("deleteIndex", args);
|
|
181
|
-
const { indexName } = params;
|
|
176
|
+
async deleteIndex({ indexName }) {
|
|
182
177
|
await this.client.vectorize.indexes.delete(indexName, {
|
|
183
178
|
account_id: this.accountId
|
|
184
179
|
});
|
|
@@ -203,8 +198,6 @@ var CloudflareVector = class extends vector.MastraVector {
|
|
|
203
198
|
return res?.metadataIndexes ?? [];
|
|
204
199
|
}
|
|
205
200
|
/**
|
|
206
|
-
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
207
|
-
*
|
|
208
201
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
209
202
|
* @param indexName - The name of the index containing the vector.
|
|
210
203
|
* @param id - The ID of the vector to update.
|
|
@@ -214,27 +207,7 @@ var CloudflareVector = class extends vector.MastraVector {
|
|
|
214
207
|
* @returns A promise that resolves when the update is complete.
|
|
215
208
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
216
209
|
*/
|
|
217
|
-
async
|
|
218
|
-
this.logger.warn(
|
|
219
|
-
`Deprecation Warning: updateIndexById() is deprecated.
|
|
220
|
-
Please use updateVector() instead.
|
|
221
|
-
updateIndexById() will be removed on May 20th, 2025.`
|
|
222
|
-
);
|
|
223
|
-
await this.updateVector({ indexName, id, update });
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
227
|
-
* @param indexName - The name of the index containing the vector.
|
|
228
|
-
* @param id - The ID of the vector to update.
|
|
229
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
230
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
231
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
232
|
-
* @returns A promise that resolves when the update is complete.
|
|
233
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
234
|
-
*/
|
|
235
|
-
async updateVector(...args) {
|
|
236
|
-
const params = this.normalizeArgs("updateVector", args);
|
|
237
|
-
const { indexName, id, update } = params;
|
|
210
|
+
async updateVector({ indexName, id, update }) {
|
|
238
211
|
try {
|
|
239
212
|
if (!update.vector && !update.metadata) {
|
|
240
213
|
throw new Error("No update data provided");
|
|
@@ -252,23 +225,6 @@ var CloudflareVector = class extends vector.MastraVector {
|
|
|
252
225
|
throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
|
|
253
226
|
}
|
|
254
227
|
}
|
|
255
|
-
/**
|
|
256
|
-
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
257
|
-
*
|
|
258
|
-
* Deletes a vector by its ID.
|
|
259
|
-
* @param indexName - The name of the index containing the vector.
|
|
260
|
-
* @param id - The ID of the vector to delete.
|
|
261
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
262
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
263
|
-
*/
|
|
264
|
-
async deleteIndexById(indexName, id) {
|
|
265
|
-
this.logger.warn(
|
|
266
|
-
`Deprecation Warning: deleteIndexById() is deprecated.
|
|
267
|
-
Please use deleteVector() instead.
|
|
268
|
-
deleteIndexById() will be removed on May 20th, 2025.`
|
|
269
|
-
);
|
|
270
|
-
await this.deleteVector({ indexName, id });
|
|
271
|
-
}
|
|
272
228
|
/**
|
|
273
229
|
* Deletes a vector by its ID.
|
|
274
230
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -276,9 +232,7 @@ var CloudflareVector = class extends vector.MastraVector {
|
|
|
276
232
|
* @returns A promise that resolves when the deletion is complete.
|
|
277
233
|
* @throws Will throw an error if the deletion operation fails.
|
|
278
234
|
*/
|
|
279
|
-
async deleteVector(
|
|
280
|
-
const params = this.normalizeArgs("deleteVector", args);
|
|
281
|
-
const { indexName, id } = params;
|
|
235
|
+
async deleteVector({ indexName, id }) {
|
|
282
236
|
try {
|
|
283
237
|
await this.client.vectorize.indexes.deleteByIds(indexName, {
|
|
284
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,
|
|
@@ -149,13 +149,10 @@ var CloudflareVector = class extends MastraVector {
|
|
|
149
149
|
/**
|
|
150
150
|
* Retrieves statistics about a vector index.
|
|
151
151
|
*
|
|
152
|
-
* @param
|
|
153
|
-
* @param params.indexName - The name of the index to describe
|
|
152
|
+
* @param {string} indexName - The name of the index to describe
|
|
154
153
|
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
155
154
|
*/
|
|
156
|
-
async describeIndex(
|
|
157
|
-
const params = this.normalizeArgs("describeIndex", args);
|
|
158
|
-
const { indexName } = params;
|
|
155
|
+
async describeIndex({ indexName }) {
|
|
159
156
|
const index = await this.client.vectorize.indexes.get(indexName, {
|
|
160
157
|
account_id: this.accountId
|
|
161
158
|
});
|
|
@@ -170,9 +167,7 @@ var CloudflareVector = class extends MastraVector {
|
|
|
170
167
|
metric: index?.config?.metric
|
|
171
168
|
};
|
|
172
169
|
}
|
|
173
|
-
async deleteIndex(
|
|
174
|
-
const params = this.normalizeArgs("deleteIndex", args);
|
|
175
|
-
const { indexName } = params;
|
|
170
|
+
async deleteIndex({ indexName }) {
|
|
176
171
|
await this.client.vectorize.indexes.delete(indexName, {
|
|
177
172
|
account_id: this.accountId
|
|
178
173
|
});
|
|
@@ -197,8 +192,6 @@ var CloudflareVector = class extends MastraVector {
|
|
|
197
192
|
return res?.metadataIndexes ?? [];
|
|
198
193
|
}
|
|
199
194
|
/**
|
|
200
|
-
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
201
|
-
*
|
|
202
195
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
203
196
|
* @param indexName - The name of the index containing the vector.
|
|
204
197
|
* @param id - The ID of the vector to update.
|
|
@@ -208,27 +201,7 @@ var CloudflareVector = class extends MastraVector {
|
|
|
208
201
|
* @returns A promise that resolves when the update is complete.
|
|
209
202
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
210
203
|
*/
|
|
211
|
-
async
|
|
212
|
-
this.logger.warn(
|
|
213
|
-
`Deprecation Warning: updateIndexById() is deprecated.
|
|
214
|
-
Please use updateVector() instead.
|
|
215
|
-
updateIndexById() will be removed on May 20th, 2025.`
|
|
216
|
-
);
|
|
217
|
-
await this.updateVector({ indexName, id, update });
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
221
|
-
* @param indexName - The name of the index containing the vector.
|
|
222
|
-
* @param id - The ID of the vector to update.
|
|
223
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
224
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
225
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
226
|
-
* @returns A promise that resolves when the update is complete.
|
|
227
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
228
|
-
*/
|
|
229
|
-
async updateVector(...args) {
|
|
230
|
-
const params = this.normalizeArgs("updateVector", args);
|
|
231
|
-
const { indexName, id, update } = params;
|
|
204
|
+
async updateVector({ indexName, id, update }) {
|
|
232
205
|
try {
|
|
233
206
|
if (!update.vector && !update.metadata) {
|
|
234
207
|
throw new Error("No update data provided");
|
|
@@ -246,23 +219,6 @@ var CloudflareVector = class extends MastraVector {
|
|
|
246
219
|
throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
|
|
247
220
|
}
|
|
248
221
|
}
|
|
249
|
-
/**
|
|
250
|
-
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
251
|
-
*
|
|
252
|
-
* Deletes a vector by its ID.
|
|
253
|
-
* @param indexName - The name of the index containing the vector.
|
|
254
|
-
* @param id - The ID of the vector to delete.
|
|
255
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
256
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
257
|
-
*/
|
|
258
|
-
async deleteIndexById(indexName, id) {
|
|
259
|
-
this.logger.warn(
|
|
260
|
-
`Deprecation Warning: deleteIndexById() is deprecated.
|
|
261
|
-
Please use deleteVector() instead.
|
|
262
|
-
deleteIndexById() will be removed on May 20th, 2025.`
|
|
263
|
-
);
|
|
264
|
-
await this.deleteVector({ indexName, id });
|
|
265
|
-
}
|
|
266
222
|
/**
|
|
267
223
|
* Deletes a vector by its ID.
|
|
268
224
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -270,9 +226,7 @@ var CloudflareVector = class extends MastraVector {
|
|
|
270
226
|
* @returns A promise that resolves when the deletion is complete.
|
|
271
227
|
* @throws Will throw an error if the deletion operation fails.
|
|
272
228
|
*/
|
|
273
|
-
async deleteVector(
|
|
274
|
-
const params = this.normalizeArgs("deleteVector", args);
|
|
275
|
-
const { indexName, id } = params;
|
|
229
|
+
async deleteVector({ indexName, id }) {
|
|
276
230
|
try {
|
|
277
231
|
await this.client.vectorize.indexes.deleteByIds(indexName, {
|
|
278
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.5-alpha.0"
|
|
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",
|