@mastra/libsql 0.0.4-alpha.2 → 0.0.4-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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +11 -0
- package/dist/_tsup-dts-rollup.d.cts +35 -3
- package/dist/_tsup-dts-rollup.d.ts +35 -3
- package/dist/index.cjs +48 -5
- package/dist/index.js +48 -5
- package/package.json +2 -2
- package/src/vector/index.test.ts +5 -5
- package/src/vector/index.ts +54 -5
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/libsql@0.0.4-alpha.
|
|
2
|
+
> @mastra/libsql@0.0.4-alpha.3 build /home/runner/work/mastra/mastra/stores/libsql
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.4.0
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 8335ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/libsql/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
14
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/libsql/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 8910ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[32mESM[39m [1mdist/index.js [22m[
|
|
21
|
-
[32mESM[39m ⚡️ Build success in
|
|
22
|
-
[32mCJS[39m [1mdist/index.cjs [22m[
|
|
23
|
-
[32mCJS[39m ⚡️ Build success in
|
|
20
|
+
[32mESM[39m [1mdist/index.js [22m[32m43.50 KB[39m
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 743ms
|
|
22
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m43.63 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 744ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @mastra/libsql
|
|
2
2
|
|
|
3
|
+
## 0.0.4-alpha.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c3bd795: [MASTRA-3358] Deprecate updateIndexById and deleteIndexById
|
|
8
|
+
- Updated dependencies [396be50]
|
|
9
|
+
- Updated dependencies [c3bd795]
|
|
10
|
+
- Updated dependencies [da082f8]
|
|
11
|
+
- Updated dependencies [a5810ce]
|
|
12
|
+
- @mastra/core@0.9.4-alpha.3
|
|
13
|
+
|
|
3
14
|
## 0.0.4-alpha.2
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -174,10 +174,11 @@ declare class LibSQLVector extends MastraVector {
|
|
|
174
174
|
listIndexes(): Promise<string[]>;
|
|
175
175
|
describeIndex(indexName: string): Promise<IndexStats>;
|
|
176
176
|
/**
|
|
177
|
-
*
|
|
177
|
+
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
178
178
|
*
|
|
179
|
-
*
|
|
180
|
-
* @param
|
|
179
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
180
|
+
* @param indexName - The name of the index containing the vector.
|
|
181
|
+
* @param id - The ID of the vector to update.
|
|
181
182
|
* @param update - An object containing the vector and/or metadata to update.
|
|
182
183
|
* @param update.vector - An optional array of numbers representing the new vector.
|
|
183
184
|
* @param update.metadata - An optional record containing the new metadata.
|
|
@@ -188,7 +189,38 @@ declare class LibSQLVector extends MastraVector {
|
|
|
188
189
|
vector?: number[];
|
|
189
190
|
metadata?: Record<string, any>;
|
|
190
191
|
}): Promise<void>;
|
|
192
|
+
/**
|
|
193
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
194
|
+
* @param indexName - The name of the index containing the vector.
|
|
195
|
+
* @param id - The ID of the vector to update.
|
|
196
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
197
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
198
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
199
|
+
* @returns A promise that resolves when the update is complete.
|
|
200
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
201
|
+
*/
|
|
202
|
+
updateVector(indexName: string, id: string, update: {
|
|
203
|
+
vector?: number[];
|
|
204
|
+
metadata?: Record<string, any>;
|
|
205
|
+
}): Promise<void>;
|
|
206
|
+
/**
|
|
207
|
+
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
208
|
+
*
|
|
209
|
+
* Deletes a vector by its ID.
|
|
210
|
+
* @param indexName - The name of the index containing the vector.
|
|
211
|
+
* @param id - The ID of the vector to delete.
|
|
212
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
213
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
214
|
+
*/
|
|
191
215
|
deleteIndexById(indexName: string, id: string): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* Deletes a vector by its ID.
|
|
218
|
+
* @param indexName - The name of the index containing the vector.
|
|
219
|
+
* @param id - The ID of the vector to delete.
|
|
220
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
221
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
222
|
+
*/
|
|
223
|
+
deleteVector(indexName: string, id: string): Promise<void>;
|
|
192
224
|
truncateIndex(indexName: string): Promise<void>;
|
|
193
225
|
}
|
|
194
226
|
export { LibSQLVector }
|
|
@@ -174,10 +174,11 @@ declare class LibSQLVector extends MastraVector {
|
|
|
174
174
|
listIndexes(): Promise<string[]>;
|
|
175
175
|
describeIndex(indexName: string): Promise<IndexStats>;
|
|
176
176
|
/**
|
|
177
|
-
*
|
|
177
|
+
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
178
178
|
*
|
|
179
|
-
*
|
|
180
|
-
* @param
|
|
179
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
180
|
+
* @param indexName - The name of the index containing the vector.
|
|
181
|
+
* @param id - The ID of the vector to update.
|
|
181
182
|
* @param update - An object containing the vector and/or metadata to update.
|
|
182
183
|
* @param update.vector - An optional array of numbers representing the new vector.
|
|
183
184
|
* @param update.metadata - An optional record containing the new metadata.
|
|
@@ -188,7 +189,38 @@ declare class LibSQLVector extends MastraVector {
|
|
|
188
189
|
vector?: number[];
|
|
189
190
|
metadata?: Record<string, any>;
|
|
190
191
|
}): Promise<void>;
|
|
192
|
+
/**
|
|
193
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
194
|
+
* @param indexName - The name of the index containing the vector.
|
|
195
|
+
* @param id - The ID of the vector to update.
|
|
196
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
197
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
198
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
199
|
+
* @returns A promise that resolves when the update is complete.
|
|
200
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
201
|
+
*/
|
|
202
|
+
updateVector(indexName: string, id: string, update: {
|
|
203
|
+
vector?: number[];
|
|
204
|
+
metadata?: Record<string, any>;
|
|
205
|
+
}): Promise<void>;
|
|
206
|
+
/**
|
|
207
|
+
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
208
|
+
*
|
|
209
|
+
* Deletes a vector by its ID.
|
|
210
|
+
* @param indexName - The name of the index containing the vector.
|
|
211
|
+
* @param id - The ID of the vector to delete.
|
|
212
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
213
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
214
|
+
*/
|
|
191
215
|
deleteIndexById(indexName: string, id: string): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* Deletes a vector by its ID.
|
|
218
|
+
* @param indexName - The name of the index containing the vector.
|
|
219
|
+
* @param id - The ID of the vector to delete.
|
|
220
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
221
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
222
|
+
*/
|
|
223
|
+
deleteVector(indexName: string, id: string): Promise<void>;
|
|
192
224
|
truncateIndex(indexName: string): Promise<void>;
|
|
193
225
|
}
|
|
194
226
|
export { LibSQLVector }
|
package/dist/index.cjs
CHANGED
|
@@ -617,10 +617,11 @@ var LibSQLVector = class extends vector.MastraVector {
|
|
|
617
617
|
}
|
|
618
618
|
}
|
|
619
619
|
/**
|
|
620
|
-
*
|
|
620
|
+
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
621
621
|
*
|
|
622
|
-
*
|
|
623
|
-
* @param
|
|
622
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
623
|
+
* @param indexName - The name of the index containing the vector.
|
|
624
|
+
* @param id - The ID of the vector to update.
|
|
624
625
|
* @param update - An object containing the vector and/or metadata to update.
|
|
625
626
|
* @param update.vector - An optional array of numbers representing the new vector.
|
|
626
627
|
* @param update.metadata - An optional record containing the new metadata.
|
|
@@ -628,6 +629,24 @@ var LibSQLVector = class extends vector.MastraVector {
|
|
|
628
629
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
629
630
|
*/
|
|
630
631
|
async updateIndexById(indexName, id, update) {
|
|
632
|
+
this.logger.warn(
|
|
633
|
+
`Deprecation Warning: updateIndexById() is deprecated.
|
|
634
|
+
Please use updateVector() instead.
|
|
635
|
+
updateIndexById() will be removed on May 20th, 2025.`
|
|
636
|
+
);
|
|
637
|
+
await this.updateVector(indexName, id, update);
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
641
|
+
* @param indexName - The name of the index containing the vector.
|
|
642
|
+
* @param id - The ID of the vector to update.
|
|
643
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
644
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
645
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
646
|
+
* @returns A promise that resolves when the update is complete.
|
|
647
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
648
|
+
*/
|
|
649
|
+
async updateVector(indexName, id, update) {
|
|
631
650
|
try {
|
|
632
651
|
const updates = [];
|
|
633
652
|
const args = [];
|
|
@@ -653,17 +672,41 @@ var LibSQLVector = class extends vector.MastraVector {
|
|
|
653
672
|
args
|
|
654
673
|
});
|
|
655
674
|
} catch (error) {
|
|
656
|
-
throw new Error(`Failed to update
|
|
675
|
+
throw new Error(`Failed to update vector by id: ${id} for index: ${indexName}: ${error.message}`);
|
|
657
676
|
}
|
|
658
677
|
}
|
|
678
|
+
/**
|
|
679
|
+
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
680
|
+
*
|
|
681
|
+
* Deletes a vector by its ID.
|
|
682
|
+
* @param indexName - The name of the index containing the vector.
|
|
683
|
+
* @param id - The ID of the vector to delete.
|
|
684
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
685
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
686
|
+
*/
|
|
659
687
|
async deleteIndexById(indexName, id) {
|
|
688
|
+
this.logger.warn(
|
|
689
|
+
`Deprecation Warning: deleteIndexById() is deprecated.
|
|
690
|
+
Please use deleteVector() instead.
|
|
691
|
+
deleteIndexById() will be removed on May 20th, 2025.`
|
|
692
|
+
);
|
|
693
|
+
await this.deleteVector(indexName, id);
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Deletes a vector by its ID.
|
|
697
|
+
* @param indexName - The name of the index containing the vector.
|
|
698
|
+
* @param id - The ID of the vector to delete.
|
|
699
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
700
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
701
|
+
*/
|
|
702
|
+
async deleteVector(indexName, id) {
|
|
660
703
|
try {
|
|
661
704
|
await this.turso.execute({
|
|
662
705
|
sql: `DELETE FROM ${indexName} WHERE vector_id = ?`,
|
|
663
706
|
args: [id]
|
|
664
707
|
});
|
|
665
708
|
} catch (error) {
|
|
666
|
-
throw new Error(`Failed to delete
|
|
709
|
+
throw new Error(`Failed to delete vector by id: ${id} for index: ${indexName}: ${error.message}`);
|
|
667
710
|
}
|
|
668
711
|
}
|
|
669
712
|
async truncateIndex(indexName) {
|
package/dist/index.js
CHANGED
|
@@ -615,10 +615,11 @@ var LibSQLVector = class extends MastraVector {
|
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
617
|
/**
|
|
618
|
-
*
|
|
618
|
+
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
619
619
|
*
|
|
620
|
-
*
|
|
621
|
-
* @param
|
|
620
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
621
|
+
* @param indexName - The name of the index containing the vector.
|
|
622
|
+
* @param id - The ID of the vector to update.
|
|
622
623
|
* @param update - An object containing the vector and/or metadata to update.
|
|
623
624
|
* @param update.vector - An optional array of numbers representing the new vector.
|
|
624
625
|
* @param update.metadata - An optional record containing the new metadata.
|
|
@@ -626,6 +627,24 @@ var LibSQLVector = class extends MastraVector {
|
|
|
626
627
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
627
628
|
*/
|
|
628
629
|
async updateIndexById(indexName, id, update) {
|
|
630
|
+
this.logger.warn(
|
|
631
|
+
`Deprecation Warning: updateIndexById() is deprecated.
|
|
632
|
+
Please use updateVector() instead.
|
|
633
|
+
updateIndexById() will be removed on May 20th, 2025.`
|
|
634
|
+
);
|
|
635
|
+
await this.updateVector(indexName, id, update);
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
639
|
+
* @param indexName - The name of the index containing the vector.
|
|
640
|
+
* @param id - The ID of the vector to update.
|
|
641
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
642
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
643
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
644
|
+
* @returns A promise that resolves when the update is complete.
|
|
645
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
646
|
+
*/
|
|
647
|
+
async updateVector(indexName, id, update) {
|
|
629
648
|
try {
|
|
630
649
|
const updates = [];
|
|
631
650
|
const args = [];
|
|
@@ -651,17 +670,41 @@ var LibSQLVector = class extends MastraVector {
|
|
|
651
670
|
args
|
|
652
671
|
});
|
|
653
672
|
} catch (error) {
|
|
654
|
-
throw new Error(`Failed to update
|
|
673
|
+
throw new Error(`Failed to update vector by id: ${id} for index: ${indexName}: ${error.message}`);
|
|
655
674
|
}
|
|
656
675
|
}
|
|
676
|
+
/**
|
|
677
|
+
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
678
|
+
*
|
|
679
|
+
* Deletes a vector by its ID.
|
|
680
|
+
* @param indexName - The name of the index containing the vector.
|
|
681
|
+
* @param id - The ID of the vector to delete.
|
|
682
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
683
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
684
|
+
*/
|
|
657
685
|
async deleteIndexById(indexName, id) {
|
|
686
|
+
this.logger.warn(
|
|
687
|
+
`Deprecation Warning: deleteIndexById() is deprecated.
|
|
688
|
+
Please use deleteVector() instead.
|
|
689
|
+
deleteIndexById() will be removed on May 20th, 2025.`
|
|
690
|
+
);
|
|
691
|
+
await this.deleteVector(indexName, id);
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Deletes a vector by its ID.
|
|
695
|
+
* @param indexName - The name of the index containing the vector.
|
|
696
|
+
* @param id - The ID of the vector to delete.
|
|
697
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
698
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
699
|
+
*/
|
|
700
|
+
async deleteVector(indexName, id) {
|
|
658
701
|
try {
|
|
659
702
|
await this.turso.execute({
|
|
660
703
|
sql: `DELETE FROM ${indexName} WHERE vector_id = ?`,
|
|
661
704
|
args: [id]
|
|
662
705
|
});
|
|
663
706
|
} catch (error) {
|
|
664
|
-
throw new Error(`Failed to delete
|
|
707
|
+
throw new Error(`Failed to delete vector by id: ${id} for index: ${indexName}: ${error.message}`);
|
|
665
708
|
}
|
|
666
709
|
}
|
|
667
710
|
async truncateIndex(indexName) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/libsql",
|
|
3
|
-
"version": "0.0.4-alpha.
|
|
3
|
+
"version": "0.0.4-alpha.3",
|
|
4
4
|
"description": "Libsql provider for Mastra - includes both vector and db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@libsql/client": "^0.15.4",
|
|
24
|
-
"@mastra/core": "^0.9.4-alpha.
|
|
24
|
+
"@mastra/core": "^0.9.4-alpha.3"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@microsoft/api-extractor": "^7.52.5",
|
package/src/vector/index.test.ts
CHANGED
|
@@ -165,7 +165,7 @@ describe('LibSQLVector', () => {
|
|
|
165
165
|
expect(ids).toHaveLength(2);
|
|
166
166
|
const id = ids[1];
|
|
167
167
|
|
|
168
|
-
await vectorDB.
|
|
168
|
+
await vectorDB.deleteVector(testIndexName, ids[0]);
|
|
169
169
|
|
|
170
170
|
const results = await vectorDB.query({ indexName: testIndexName, queryVector: [1, 2, 3] });
|
|
171
171
|
expect(results).toHaveLength(1);
|
|
@@ -181,7 +181,7 @@ describe('LibSQLVector', () => {
|
|
|
181
181
|
vector: [4, 5, 6],
|
|
182
182
|
metadata: { test: 'updated' },
|
|
183
183
|
};
|
|
184
|
-
await vectorDB.
|
|
184
|
+
await vectorDB.updateVector(testIndexName, id, update);
|
|
185
185
|
|
|
186
186
|
const results = await vectorDB.query({
|
|
187
187
|
indexName: testIndexName,
|
|
@@ -202,7 +202,7 @@ describe('LibSQLVector', () => {
|
|
|
202
202
|
const update = {
|
|
203
203
|
metadata: { test: 'updated' },
|
|
204
204
|
};
|
|
205
|
-
await vectorDB.
|
|
205
|
+
await vectorDB.updateVector(testIndexName, id, update);
|
|
206
206
|
|
|
207
207
|
const results = await vectorDB.query({ indexName: testIndexName, queryVector: [1, 2, 3], topK: 1 });
|
|
208
208
|
expect(results[0]?.id).toBe(id);
|
|
@@ -218,7 +218,7 @@ describe('LibSQLVector', () => {
|
|
|
218
218
|
const update = {
|
|
219
219
|
vector: [4, 5, 6],
|
|
220
220
|
};
|
|
221
|
-
await vectorDB.
|
|
221
|
+
await vectorDB.updateVector(testIndexName, id, update);
|
|
222
222
|
|
|
223
223
|
const results = await vectorDB.query({
|
|
224
224
|
indexName: testIndexName,
|
|
@@ -236,7 +236,7 @@ describe('LibSQLVector', () => {
|
|
|
236
236
|
const metadata = [{ test: 'initial' }];
|
|
237
237
|
const [id] = await vectorDB.upsert({ indexName: testIndexName, vectors, metadata });
|
|
238
238
|
|
|
239
|
-
await expect(vectorDB.
|
|
239
|
+
await expect(vectorDB.updateVector(testIndexName, id, {})).rejects.toThrow('No updates provided');
|
|
240
240
|
});
|
|
241
241
|
});
|
|
242
242
|
|
package/src/vector/index.ts
CHANGED
|
@@ -274,10 +274,11 @@ export class LibSQLVector extends MastraVector {
|
|
|
274
274
|
}
|
|
275
275
|
|
|
276
276
|
/**
|
|
277
|
-
*
|
|
277
|
+
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
278
278
|
*
|
|
279
|
-
*
|
|
280
|
-
* @param
|
|
279
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
280
|
+
* @param indexName - The name of the index containing the vector.
|
|
281
|
+
* @param id - The ID of the vector to update.
|
|
281
282
|
* @param update - An object containing the vector and/or metadata to update.
|
|
282
283
|
* @param update.vector - An optional array of numbers representing the new vector.
|
|
283
284
|
* @param update.metadata - An optional record containing the new metadata.
|
|
@@ -288,6 +289,29 @@ export class LibSQLVector extends MastraVector {
|
|
|
288
289
|
indexName: string,
|
|
289
290
|
id: string,
|
|
290
291
|
update: { vector?: number[]; metadata?: Record<string, any> },
|
|
292
|
+
): Promise<void> {
|
|
293
|
+
this.logger.warn(
|
|
294
|
+
`Deprecation Warning: updateIndexById() is deprecated.
|
|
295
|
+
Please use updateVector() instead.
|
|
296
|
+
updateIndexById() will be removed on May 20th, 2025.`,
|
|
297
|
+
);
|
|
298
|
+
await this.updateVector(indexName, id, update);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
303
|
+
* @param indexName - The name of the index containing the vector.
|
|
304
|
+
* @param id - The ID of the vector to update.
|
|
305
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
306
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
307
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
308
|
+
* @returns A promise that resolves when the update is complete.
|
|
309
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
310
|
+
*/
|
|
311
|
+
async updateVector(
|
|
312
|
+
indexName: string,
|
|
313
|
+
id: string,
|
|
314
|
+
update: { vector?: number[]; metadata?: Record<string, any> },
|
|
291
315
|
): Promise<void> {
|
|
292
316
|
try {
|
|
293
317
|
const updates = [];
|
|
@@ -320,18 +344,43 @@ export class LibSQLVector extends MastraVector {
|
|
|
320
344
|
args,
|
|
321
345
|
});
|
|
322
346
|
} catch (error: any) {
|
|
323
|
-
throw new Error(`Failed to update
|
|
347
|
+
throw new Error(`Failed to update vector by id: ${id} for index: ${indexName}: ${error.message}`);
|
|
324
348
|
}
|
|
325
349
|
}
|
|
326
350
|
|
|
351
|
+
/**
|
|
352
|
+
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
353
|
+
*
|
|
354
|
+
* Deletes a vector by its ID.
|
|
355
|
+
* @param indexName - The name of the index containing the vector.
|
|
356
|
+
* @param id - The ID of the vector to delete.
|
|
357
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
358
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
359
|
+
*/
|
|
327
360
|
async deleteIndexById(indexName: string, id: string): Promise<void> {
|
|
361
|
+
this.logger.warn(
|
|
362
|
+
`Deprecation Warning: deleteIndexById() is deprecated.
|
|
363
|
+
Please use deleteVector() instead.
|
|
364
|
+
deleteIndexById() will be removed on May 20th, 2025.`,
|
|
365
|
+
);
|
|
366
|
+
await this.deleteVector(indexName, id);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Deletes a vector by its ID.
|
|
371
|
+
* @param indexName - The name of the index containing the vector.
|
|
372
|
+
* @param id - The ID of the vector to delete.
|
|
373
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
374
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
375
|
+
*/
|
|
376
|
+
async deleteVector(indexName: string, id: string): Promise<void> {
|
|
328
377
|
try {
|
|
329
378
|
await this.turso.execute({
|
|
330
379
|
sql: `DELETE FROM ${indexName} WHERE vector_id = ?`,
|
|
331
380
|
args: [id],
|
|
332
381
|
});
|
|
333
382
|
} catch (error: any) {
|
|
334
|
-
throw new Error(`Failed to delete
|
|
383
|
+
throw new Error(`Failed to delete vector by id: ${id} for index: ${indexName}: ${error.message}`);
|
|
335
384
|
}
|
|
336
385
|
}
|
|
337
386
|
|