@mastra/vectorize 0.2.10-alpha.1 → 0.2.10-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_tsup-dts-rollup.d.cts +43 -0
- package/dist/_tsup-dts-rollup.d.ts +43 -0
- package/dist/index.cjs +77 -15
- package/dist/index.js +77 -15
- package/package.json +2 -2
|
@@ -31,11 +31,54 @@ declare class CloudflareVector extends MastraVector {
|
|
|
31
31
|
createMetadataIndex(indexName: string, propertyName: string, indexType: 'string' | 'number' | 'boolean'): Promise<void>;
|
|
32
32
|
deleteMetadataIndex(indexName: string, propertyName: string): Promise<void>;
|
|
33
33
|
listMetadataIndexes(indexName: string): Promise<Cloudflare.Vectorize.Indexes.MetadataIndex.MetadataIndexListResponse.MetadataIndex[]>;
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
36
|
+
*
|
|
37
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
38
|
+
* @param indexName - The name of the index containing the vector.
|
|
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.
|
|
45
|
+
*/
|
|
34
46
|
updateIndexById(indexName: string, id: string, update: {
|
|
35
47
|
vector?: number[];
|
|
36
48
|
metadata?: Record<string, any>;
|
|
37
49
|
}): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
52
|
+
* @param indexName - The name of the index containing the vector.
|
|
53
|
+
* @param id - The ID of the vector to update.
|
|
54
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
55
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
56
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
57
|
+
* @returns A promise that resolves when the update is complete.
|
|
58
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
59
|
+
*/
|
|
60
|
+
updateVector(indexName: string, id: string, update: {
|
|
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
|
+
*/
|
|
38
73
|
deleteIndexById(indexName: string, id: string): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Deletes a vector by its ID.
|
|
76
|
+
* @param indexName - The name of the index containing the vector.
|
|
77
|
+
* @param id - The ID of the vector to delete.
|
|
78
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
79
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
80
|
+
*/
|
|
81
|
+
deleteVector(indexName: string, id: string): Promise<void>;
|
|
39
82
|
}
|
|
40
83
|
export { CloudflareVector }
|
|
41
84
|
export { CloudflareVector as CloudflareVector_alias_1 }
|
|
@@ -31,11 +31,54 @@ declare class CloudflareVector extends MastraVector {
|
|
|
31
31
|
createMetadataIndex(indexName: string, propertyName: string, indexType: 'string' | 'number' | 'boolean'): Promise<void>;
|
|
32
32
|
deleteMetadataIndex(indexName: string, propertyName: string): Promise<void>;
|
|
33
33
|
listMetadataIndexes(indexName: string): Promise<Cloudflare.Vectorize.Indexes.MetadataIndex.MetadataIndexListResponse.MetadataIndex[]>;
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
36
|
+
*
|
|
37
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
38
|
+
* @param indexName - The name of the index containing the vector.
|
|
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.
|
|
45
|
+
*/
|
|
34
46
|
updateIndexById(indexName: string, id: string, update: {
|
|
35
47
|
vector?: number[];
|
|
36
48
|
metadata?: Record<string, any>;
|
|
37
49
|
}): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
52
|
+
* @param indexName - The name of the index containing the vector.
|
|
53
|
+
* @param id - The ID of the vector to update.
|
|
54
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
55
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
56
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
57
|
+
* @returns A promise that resolves when the update is complete.
|
|
58
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
59
|
+
*/
|
|
60
|
+
updateVector(indexName: string, id: string, update: {
|
|
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
|
+
*/
|
|
38
73
|
deleteIndexById(indexName: string, id: string): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Deletes a vector by its ID.
|
|
76
|
+
* @param indexName - The name of the index containing the vector.
|
|
77
|
+
* @param id - The ID of the vector to delete.
|
|
78
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
79
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
80
|
+
*/
|
|
81
|
+
deleteVector(indexName: string, id: string): Promise<void>;
|
|
39
82
|
}
|
|
40
83
|
export { CloudflareVector }
|
|
41
84
|
export { CloudflareVector as CloudflareVector_alias_1 }
|
package/dist/index.cjs
CHANGED
|
@@ -191,25 +191,87 @@ var CloudflareVector = class extends vector.MastraVector {
|
|
|
191
191
|
});
|
|
192
192
|
return res?.metadataIndexes ?? [];
|
|
193
193
|
}
|
|
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
|
+
*/
|
|
194
206
|
async updateIndexById(indexName, id, update) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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
|
+
/**
|
|
215
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
216
|
+
* @param indexName - The name of the index containing the vector.
|
|
217
|
+
* @param id - The ID of the vector to update.
|
|
218
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
219
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
220
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
221
|
+
* @returns A promise that resolves when the update is complete.
|
|
222
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
223
|
+
*/
|
|
224
|
+
async updateVector(indexName, id, update) {
|
|
225
|
+
try {
|
|
226
|
+
if (!update.vector && !update.metadata) {
|
|
227
|
+
throw new Error("No update data provided");
|
|
228
|
+
}
|
|
229
|
+
const updatePayload = {
|
|
230
|
+
};
|
|
231
|
+
if (update.vector) {
|
|
232
|
+
updatePayload.vectors = [update.vector];
|
|
233
|
+
}
|
|
234
|
+
if (update.metadata) {
|
|
235
|
+
updatePayload.metadata = [update.metadata];
|
|
236
|
+
}
|
|
237
|
+
await this.upsert({ indexName, vectors: updatePayload.vectors, metadata: updatePayload.metadata });
|
|
238
|
+
} catch (error) {
|
|
239
|
+
throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
|
|
205
240
|
}
|
|
206
|
-
await this.upsert({ indexName, vectors: updatePayload.vectors, metadata: updatePayload.metadata });
|
|
207
241
|
}
|
|
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
|
+
*/
|
|
208
251
|
async deleteIndexById(indexName, id) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
+
/**
|
|
260
|
+
* Deletes a vector by its ID.
|
|
261
|
+
* @param indexName - The name of the index containing the vector.
|
|
262
|
+
* @param id - The ID of the vector to delete.
|
|
263
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
264
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
265
|
+
*/
|
|
266
|
+
async deleteVector(indexName, id) {
|
|
267
|
+
try {
|
|
268
|
+
await this.client.vectorize.indexes.deleteByIds(indexName, {
|
|
269
|
+
ids: [id],
|
|
270
|
+
account_id: this.accountId
|
|
271
|
+
});
|
|
272
|
+
} catch (error) {
|
|
273
|
+
throw new Error(`Failed to delete vector by id: ${id} for index name: ${indexName}: ${error.message}`);
|
|
274
|
+
}
|
|
213
275
|
}
|
|
214
276
|
};
|
|
215
277
|
|
package/dist/index.js
CHANGED
|
@@ -185,25 +185,87 @@ var CloudflareVector = class extends MastraVector {
|
|
|
185
185
|
});
|
|
186
186
|
return res?.metadataIndexes ?? [];
|
|
187
187
|
}
|
|
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
|
+
*/
|
|
188
200
|
async updateIndexById(indexName, id, update) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
+
/**
|
|
209
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
210
|
+
* @param indexName - The name of the index containing the vector.
|
|
211
|
+
* @param id - The ID of the vector to update.
|
|
212
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
213
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
214
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
215
|
+
* @returns A promise that resolves when the update is complete.
|
|
216
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
217
|
+
*/
|
|
218
|
+
async updateVector(indexName, id, update) {
|
|
219
|
+
try {
|
|
220
|
+
if (!update.vector && !update.metadata) {
|
|
221
|
+
throw new Error("No update data provided");
|
|
222
|
+
}
|
|
223
|
+
const updatePayload = {
|
|
224
|
+
};
|
|
225
|
+
if (update.vector) {
|
|
226
|
+
updatePayload.vectors = [update.vector];
|
|
227
|
+
}
|
|
228
|
+
if (update.metadata) {
|
|
229
|
+
updatePayload.metadata = [update.metadata];
|
|
230
|
+
}
|
|
231
|
+
await this.upsert({ indexName, vectors: updatePayload.vectors, metadata: updatePayload.metadata });
|
|
232
|
+
} catch (error) {
|
|
233
|
+
throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
|
|
199
234
|
}
|
|
200
|
-
await this.upsert({ indexName, vectors: updatePayload.vectors, metadata: updatePayload.metadata });
|
|
201
235
|
}
|
|
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
|
+
*/
|
|
202
245
|
async deleteIndexById(indexName, id) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
+
/**
|
|
254
|
+
* Deletes a vector by its ID.
|
|
255
|
+
* @param indexName - The name of the index containing the vector.
|
|
256
|
+
* @param id - The ID of the vector to delete.
|
|
257
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
258
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
259
|
+
*/
|
|
260
|
+
async deleteVector(indexName, id) {
|
|
261
|
+
try {
|
|
262
|
+
await this.client.vectorize.indexes.deleteByIds(indexName, {
|
|
263
|
+
ids: [id],
|
|
264
|
+
account_id: this.accountId
|
|
265
|
+
});
|
|
266
|
+
} catch (error) {
|
|
267
|
+
throw new Error(`Failed to delete vector by id: ${id} for index name: ${indexName}: ${error.message}`);
|
|
268
|
+
}
|
|
207
269
|
}
|
|
208
270
|
};
|
|
209
271
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/vectorize",
|
|
3
|
-
"version": "0.2.10-alpha.
|
|
3
|
+
"version": "0.2.10-alpha.3",
|
|
4
4
|
"description": "Cloudflare Vectorize store provider for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"cloudflare": "^4.1.0",
|
|
27
|
-
"@mastra/core": "^0.9.4-alpha.
|
|
27
|
+
"@mastra/core": "^0.9.4-alpha.3"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@microsoft/api-extractor": "^7.52.5",
|