@mastra/libsql 0.0.4 → 0.1.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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +36 -0
- package/dist/_tsup-dts-rollup.d.cts +17 -59
- package/dist/_tsup-dts-rollup.d.ts +17 -59
- package/dist/index.cjs +277 -223
- package/dist/index.js +277 -223
- package/package.json +7 -4
- package/src/storage/index.ts +18 -10
- package/src/vector/index.test.ts +153 -216
- package/src/vector/index.ts +56 -84
- package/src/vector/sql-builder.ts +243 -175
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/libsql@0.0
|
|
2
|
+
> @mastra/libsql@0.1.0-alpha.1 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 8453ms
|
|
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 12124ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
20
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m45.42 KB[39m
|
|
21
|
+
[32mCJS[39m ⚡️ Build success in 1441ms
|
|
22
|
+
[32mESM[39m [1mdist/index.js [22m[32m45.22 KB[39m
|
|
23
|
+
[32mESM[39m ⚡️ Build success in 1444ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @mastra/libsql
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 83da932: Move @mastra/core to peerdeps
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- a7292b0: BREAKING(@mastra/core, all vector stores): Vector store breaking changes (remove deprecated functions and positional arguments)
|
|
12
|
+
- Updated dependencies [b3a3d63]
|
|
13
|
+
- Updated dependencies [344f453]
|
|
14
|
+
- Updated dependencies [0a3ae6d]
|
|
15
|
+
- Updated dependencies [95911be]
|
|
16
|
+
- Updated dependencies [5eb5a99]
|
|
17
|
+
- Updated dependencies [7e632c5]
|
|
18
|
+
- Updated dependencies [1e9fbfa]
|
|
19
|
+
- Updated dependencies [b2ae5aa]
|
|
20
|
+
- Updated dependencies [a7292b0]
|
|
21
|
+
- Updated dependencies [0dcb9f0]
|
|
22
|
+
- @mastra/core@0.10.0-alpha.1
|
|
23
|
+
|
|
24
|
+
## 0.0.5-alpha.0
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- eabdcd9: [MASTRA-3451] SQL Injection Protection
|
|
29
|
+
- d0ee3c6: Change all public functions and constructors in vector stores to use named args and prepare to phase out positional args
|
|
30
|
+
- Updated dependencies [f53a6ac]
|
|
31
|
+
- Updated dependencies [eabdcd9]
|
|
32
|
+
- Updated dependencies [90be034]
|
|
33
|
+
- Updated dependencies [99f050a]
|
|
34
|
+
- Updated dependencies [d0ee3c6]
|
|
35
|
+
- Updated dependencies [23f258c]
|
|
36
|
+
- Updated dependencies [2672a05]
|
|
37
|
+
- @mastra/core@0.9.5-alpha.0
|
|
38
|
+
|
|
3
39
|
## 0.0.4
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import type { ArrayOperator } from '@mastra/core/vector/filter';
|
|
2
1
|
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
3
|
-
import type { BasicOperator } from '@mastra/core/vector/filter';
|
|
4
2
|
import type { CreateIndexParams } from '@mastra/core/vector';
|
|
5
|
-
import type {
|
|
3
|
+
import type { DeleteIndexParams } from '@mastra/core/vector';
|
|
4
|
+
import type { DeleteVectorParams } from '@mastra/core/vector';
|
|
5
|
+
import type { DescribeIndexParams } from '@mastra/core/vector';
|
|
6
6
|
import type { EvalRow } from '@mastra/core/storage';
|
|
7
7
|
import type { IndexStats } from '@mastra/core/vector';
|
|
8
8
|
import type { InValue } from '@libsql/client';
|
|
9
|
-
import type { LogicalOperator } from '@mastra/core/vector/filter';
|
|
10
9
|
import { MastraStorage } from '@mastra/core/storage';
|
|
11
10
|
import { MastraVector } from '@mastra/core/vector';
|
|
12
11
|
import type { MessageType } from '@mastra/core/memory';
|
|
13
|
-
import type { NumericOperator } from '@mastra/core/vector/filter';
|
|
14
12
|
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
15
|
-
import type { ParamsToArgs } from '@mastra/core/vector';
|
|
16
13
|
import type { QueryResult } from '@mastra/core/vector';
|
|
17
|
-
import type { QueryVectorArgs } from '@mastra/core/vector';
|
|
18
14
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
19
|
-
import type { RegexOperator } from '@mastra/core/vector/filter';
|
|
20
15
|
import type { StorageColumn } from '@mastra/core/storage';
|
|
21
16
|
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
22
17
|
import type { StorageThreadType } from '@mastra/core/memory';
|
|
23
18
|
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
19
|
+
import type { UpdateVectorParams } from '@mastra/core/vector';
|
|
24
20
|
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
25
21
|
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
26
22
|
import type { WorkflowRun } from '@mastra/core/storage';
|
|
@@ -28,21 +24,11 @@ import type { WorkflowRuns } from '@mastra/core/storage';
|
|
|
28
24
|
|
|
29
25
|
export declare function buildFilterQuery(filter: VectorFilter): FilterResult;
|
|
30
26
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
declare type FilterOperator = {
|
|
34
|
-
sql: string;
|
|
35
|
-
needsValue: boolean;
|
|
36
|
-
transformValue?: (value: any) => any;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export declare interface FilterResult {
|
|
27
|
+
declare interface FilterResult {
|
|
40
28
|
sql: string;
|
|
41
29
|
values: InValue[];
|
|
42
30
|
}
|
|
43
31
|
|
|
44
|
-
export declare const handleKey: (key: string) => string;
|
|
45
|
-
|
|
46
32
|
/**
|
|
47
33
|
* Vector store specific prompt that details supported operators and examples.
|
|
48
34
|
* This prompt helps users construct valid filters for LibSQL Vector.
|
|
@@ -74,8 +60,6 @@ export declare class LibSQLFilterTranslator extends BaseFilterTranslator {
|
|
|
74
60
|
private translateNode;
|
|
75
61
|
}
|
|
76
62
|
|
|
77
|
-
declare type LibSQLQueryArgs = [...QueryVectorArgs, number?];
|
|
78
|
-
|
|
79
63
|
declare interface LibSQLQueryParams extends QueryVectorParams {
|
|
80
64
|
minScore?: number;
|
|
81
65
|
}
|
|
@@ -167,30 +151,21 @@ declare class LibSQLVector extends MastraVector {
|
|
|
167
151
|
syncInterval?: number;
|
|
168
152
|
});
|
|
169
153
|
transformFilter(filter?: VectorFilter): VectorFilter;
|
|
170
|
-
query(
|
|
171
|
-
upsert(
|
|
172
|
-
createIndex(
|
|
173
|
-
deleteIndex(indexName:
|
|
154
|
+
query({ indexName, queryVector, topK, filter, includeVector, minScore, }: LibSQLQueryParams): Promise<QueryResult[]>;
|
|
155
|
+
upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
|
|
156
|
+
createIndex({ indexName, dimension }: CreateIndexParams): Promise<void>;
|
|
157
|
+
deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
|
|
174
158
|
listIndexes(): Promise<string[]>;
|
|
175
|
-
describeIndex(indexName: string): Promise<IndexStats>;
|
|
176
159
|
/**
|
|
177
|
-
*
|
|
160
|
+
* Retrieves statistics about a vector index.
|
|
178
161
|
*
|
|
179
|
-
*
|
|
180
|
-
* @
|
|
181
|
-
* @param id - The ID of the vector to update.
|
|
182
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
183
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
184
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
185
|
-
* @returns A promise that resolves when the update is complete.
|
|
186
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
162
|
+
* @param {string} indexName - The name of the index to describe
|
|
163
|
+
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
187
164
|
*/
|
|
188
|
-
|
|
189
|
-
vector?: number[];
|
|
190
|
-
metadata?: Record<string, any>;
|
|
191
|
-
}): Promise<void>;
|
|
165
|
+
describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
|
|
192
166
|
/**
|
|
193
167
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
168
|
+
*
|
|
194
169
|
* @param indexName - The name of the index containing the vector.
|
|
195
170
|
* @param id - The ID of the vector to update.
|
|
196
171
|
* @param update - An object containing the vector and/or metadata to update.
|
|
@@ -199,35 +174,18 @@ declare class LibSQLVector extends MastraVector {
|
|
|
199
174
|
* @returns A promise that resolves when the update is complete.
|
|
200
175
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
201
176
|
*/
|
|
202
|
-
updateVector(indexName
|
|
203
|
-
vector?: number[];
|
|
204
|
-
metadata?: Record<string, any>;
|
|
205
|
-
}): Promise<void>;
|
|
177
|
+
updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
|
|
206
178
|
/**
|
|
207
|
-
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
208
|
-
*
|
|
209
179
|
* Deletes a vector by its ID.
|
|
210
180
|
* @param indexName - The name of the index containing the vector.
|
|
211
181
|
* @param id - The ID of the vector to delete.
|
|
212
182
|
* @returns A promise that resolves when the deletion is complete.
|
|
213
183
|
* @throws Will throw an error if the deletion operation fails.
|
|
214
184
|
*/
|
|
215
|
-
|
|
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>;
|
|
224
|
-
truncateIndex(indexName: string): Promise<void>;
|
|
185
|
+
deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
|
|
186
|
+
truncateIndex({ indexName }: DeleteIndexParams): Promise<void>;
|
|
225
187
|
}
|
|
226
188
|
export { LibSQLVector }
|
|
227
189
|
export { LibSQLVector as LibSQLVector_alias_1 }
|
|
228
190
|
|
|
229
|
-
declare type OperatorFn = (key: string, value?: any) => FilterOperator;
|
|
230
|
-
|
|
231
|
-
export declare type OperatorType = BasicOperator | NumericOperator | ArrayOperator | ElementOperator | LogicalOperator | '$contains' | Exclude<RegexOperator, '$options'>;
|
|
232
|
-
|
|
233
191
|
export { }
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import type { ArrayOperator } from '@mastra/core/vector/filter';
|
|
2
1
|
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
3
|
-
import type { BasicOperator } from '@mastra/core/vector/filter';
|
|
4
2
|
import type { CreateIndexParams } from '@mastra/core/vector';
|
|
5
|
-
import type {
|
|
3
|
+
import type { DeleteIndexParams } from '@mastra/core/vector';
|
|
4
|
+
import type { DeleteVectorParams } from '@mastra/core/vector';
|
|
5
|
+
import type { DescribeIndexParams } from '@mastra/core/vector';
|
|
6
6
|
import type { EvalRow } from '@mastra/core/storage';
|
|
7
7
|
import type { IndexStats } from '@mastra/core/vector';
|
|
8
8
|
import type { InValue } from '@libsql/client';
|
|
9
|
-
import type { LogicalOperator } from '@mastra/core/vector/filter';
|
|
10
9
|
import { MastraStorage } from '@mastra/core/storage';
|
|
11
10
|
import { MastraVector } from '@mastra/core/vector';
|
|
12
11
|
import type { MessageType } from '@mastra/core/memory';
|
|
13
|
-
import type { NumericOperator } from '@mastra/core/vector/filter';
|
|
14
12
|
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
15
|
-
import type { ParamsToArgs } from '@mastra/core/vector';
|
|
16
13
|
import type { QueryResult } from '@mastra/core/vector';
|
|
17
|
-
import type { QueryVectorArgs } from '@mastra/core/vector';
|
|
18
14
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
19
|
-
import type { RegexOperator } from '@mastra/core/vector/filter';
|
|
20
15
|
import type { StorageColumn } from '@mastra/core/storage';
|
|
21
16
|
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
22
17
|
import type { StorageThreadType } from '@mastra/core/memory';
|
|
23
18
|
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
19
|
+
import type { UpdateVectorParams } from '@mastra/core/vector';
|
|
24
20
|
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
25
21
|
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
26
22
|
import type { WorkflowRun } from '@mastra/core/storage';
|
|
@@ -28,21 +24,11 @@ import type { WorkflowRuns } from '@mastra/core/storage';
|
|
|
28
24
|
|
|
29
25
|
export declare function buildFilterQuery(filter: VectorFilter): FilterResult;
|
|
30
26
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
declare type FilterOperator = {
|
|
34
|
-
sql: string;
|
|
35
|
-
needsValue: boolean;
|
|
36
|
-
transformValue?: (value: any) => any;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export declare interface FilterResult {
|
|
27
|
+
declare interface FilterResult {
|
|
40
28
|
sql: string;
|
|
41
29
|
values: InValue[];
|
|
42
30
|
}
|
|
43
31
|
|
|
44
|
-
export declare const handleKey: (key: string) => string;
|
|
45
|
-
|
|
46
32
|
/**
|
|
47
33
|
* Vector store specific prompt that details supported operators and examples.
|
|
48
34
|
* This prompt helps users construct valid filters for LibSQL Vector.
|
|
@@ -74,8 +60,6 @@ export declare class LibSQLFilterTranslator extends BaseFilterTranslator {
|
|
|
74
60
|
private translateNode;
|
|
75
61
|
}
|
|
76
62
|
|
|
77
|
-
declare type LibSQLQueryArgs = [...QueryVectorArgs, number?];
|
|
78
|
-
|
|
79
63
|
declare interface LibSQLQueryParams extends QueryVectorParams {
|
|
80
64
|
minScore?: number;
|
|
81
65
|
}
|
|
@@ -167,30 +151,21 @@ declare class LibSQLVector extends MastraVector {
|
|
|
167
151
|
syncInterval?: number;
|
|
168
152
|
});
|
|
169
153
|
transformFilter(filter?: VectorFilter): VectorFilter;
|
|
170
|
-
query(
|
|
171
|
-
upsert(
|
|
172
|
-
createIndex(
|
|
173
|
-
deleteIndex(indexName:
|
|
154
|
+
query({ indexName, queryVector, topK, filter, includeVector, minScore, }: LibSQLQueryParams): Promise<QueryResult[]>;
|
|
155
|
+
upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
|
|
156
|
+
createIndex({ indexName, dimension }: CreateIndexParams): Promise<void>;
|
|
157
|
+
deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
|
|
174
158
|
listIndexes(): Promise<string[]>;
|
|
175
|
-
describeIndex(indexName: string): Promise<IndexStats>;
|
|
176
159
|
/**
|
|
177
|
-
*
|
|
160
|
+
* Retrieves statistics about a vector index.
|
|
178
161
|
*
|
|
179
|
-
*
|
|
180
|
-
* @
|
|
181
|
-
* @param id - The ID of the vector to update.
|
|
182
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
183
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
184
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
185
|
-
* @returns A promise that resolves when the update is complete.
|
|
186
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
162
|
+
* @param {string} indexName - The name of the index to describe
|
|
163
|
+
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
187
164
|
*/
|
|
188
|
-
|
|
189
|
-
vector?: number[];
|
|
190
|
-
metadata?: Record<string, any>;
|
|
191
|
-
}): Promise<void>;
|
|
165
|
+
describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
|
|
192
166
|
/**
|
|
193
167
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
168
|
+
*
|
|
194
169
|
* @param indexName - The name of the index containing the vector.
|
|
195
170
|
* @param id - The ID of the vector to update.
|
|
196
171
|
* @param update - An object containing the vector and/or metadata to update.
|
|
@@ -199,35 +174,18 @@ declare class LibSQLVector extends MastraVector {
|
|
|
199
174
|
* @returns A promise that resolves when the update is complete.
|
|
200
175
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
201
176
|
*/
|
|
202
|
-
updateVector(indexName
|
|
203
|
-
vector?: number[];
|
|
204
|
-
metadata?: Record<string, any>;
|
|
205
|
-
}): Promise<void>;
|
|
177
|
+
updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
|
|
206
178
|
/**
|
|
207
|
-
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
208
|
-
*
|
|
209
179
|
* Deletes a vector by its ID.
|
|
210
180
|
* @param indexName - The name of the index containing the vector.
|
|
211
181
|
* @param id - The ID of the vector to delete.
|
|
212
182
|
* @returns A promise that resolves when the deletion is complete.
|
|
213
183
|
* @throws Will throw an error if the deletion operation fails.
|
|
214
184
|
*/
|
|
215
|
-
|
|
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>;
|
|
224
|
-
truncateIndex(indexName: string): Promise<void>;
|
|
185
|
+
deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
|
|
186
|
+
truncateIndex({ indexName }: DeleteIndexParams): Promise<void>;
|
|
225
187
|
}
|
|
226
188
|
export { LibSQLVector }
|
|
227
189
|
export { LibSQLVector as LibSQLVector_alias_1 }
|
|
228
190
|
|
|
229
|
-
declare type OperatorFn = (key: string, value?: any) => FilterOperator;
|
|
230
|
-
|
|
231
|
-
export declare type OperatorType = BasicOperator | NumericOperator | ArrayOperator | ElementOperator | LogicalOperator | '$contains' | Exclude<RegexOperator, '$options'>;
|
|
232
|
-
|
|
233
191
|
export { }
|