@mastra/libsql 1.0.0-beta.0 → 1.0.0-beta.10
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/CHANGELOG.md +428 -0
- package/README.md +3 -0
- package/dist/index.cjs +2186 -1603
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2182 -1604
- package/dist/index.js.map +1 -1
- package/dist/storage/db/index.d.ts +264 -0
- package/dist/storage/db/index.d.ts.map +1 -0
- package/dist/storage/{domains → db}/utils.d.ts +5 -12
- package/dist/storage/db/utils.d.ts.map +1 -0
- package/dist/storage/domains/agents/index.d.ts +23 -0
- package/dist/storage/domains/agents/index.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +5 -8
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/index.d.ts +19 -27
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +16 -27
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +16 -23
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +56 -196
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/vector/index.d.ts +4 -2
- package/dist/vector/index.d.ts.map +1 -1
- package/dist/vector/sql-builder.d.ts.map +1 -1
- package/package.json +7 -6
- package/dist/storage/domains/operations/index.d.ts +0 -110
- package/dist/storage/domains/operations/index.d.ts.map +0 -1
- package/dist/storage/domains/utils.d.ts.map +0 -1
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import type { Client } from '@libsql/client';
|
|
2
|
-
import type {
|
|
3
|
-
import type { ScoreRowData, ScoringSource } from '@mastra/core/evals';
|
|
4
|
-
import type { StorageThreadType } from '@mastra/core/memory';
|
|
2
|
+
import type { StorageDomains } from '@mastra/core/storage';
|
|
5
3
|
import { MastraStorage } from '@mastra/core/storage';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
4
|
+
import { AgentsLibSQL } from './domains/agents/index.js';
|
|
5
|
+
import { MemoryLibSQL } from './domains/memory/index.js';
|
|
6
|
+
import { ObservabilityLibSQL } from './domains/observability/index.js';
|
|
7
|
+
import { ScoresLibSQL } from './domains/scores/index.js';
|
|
8
|
+
import { WorkflowsLibSQL } from './domains/workflows/index.js';
|
|
9
|
+
export { AgentsLibSQL, MemoryLibSQL, ObservabilityLibSQL, ScoresLibSQL, WorkflowsLibSQL };
|
|
10
|
+
export type { LibSQLDomainConfig } from './db/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Base configuration options shared across LibSQL configurations
|
|
13
|
+
*/
|
|
14
|
+
export type LibSQLBaseConfig = {
|
|
9
15
|
id: string;
|
|
10
|
-
url: string;
|
|
11
|
-
authToken?: string;
|
|
12
16
|
/**
|
|
13
17
|
* Maximum number of retries for write operations if an SQLITE_BUSY error occurs.
|
|
14
18
|
* @default 5
|
|
@@ -20,201 +24,57 @@ export type LibSQLConfig = {
|
|
|
20
24
|
* @default 100
|
|
21
25
|
*/
|
|
22
26
|
initialBackoffMs?: number;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* When true, automatic initialization (table creation/migrations) is disabled.
|
|
29
|
+
* This is useful for CI/CD pipelines where you want to:
|
|
30
|
+
* 1. Run migrations explicitly during deployment (not at runtime)
|
|
31
|
+
* 2. Use different credentials for schema changes vs runtime operations
|
|
32
|
+
*
|
|
33
|
+
* When disableInit is true:
|
|
34
|
+
* - The storage will not automatically create/alter tables on first use
|
|
35
|
+
* - You must call `storage.init()` explicitly in your CI/CD scripts
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* // In CI/CD script:
|
|
39
|
+
* const storage = new LibSQLStore({ ...config, disableInit: false });
|
|
40
|
+
* await storage.init(); // Explicitly run migrations
|
|
41
|
+
*
|
|
42
|
+
* // In runtime application:
|
|
43
|
+
* const storage = new LibSQLStore({ ...config, disableInit: true });
|
|
44
|
+
* // No auto-init, tables must already exist
|
|
45
|
+
*/
|
|
46
|
+
disableInit?: boolean;
|
|
28
47
|
};
|
|
48
|
+
export type LibSQLConfig = (LibSQLBaseConfig & {
|
|
49
|
+
url: string;
|
|
50
|
+
authToken?: string;
|
|
51
|
+
}) | (LibSQLBaseConfig & {
|
|
52
|
+
client: Client;
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* LibSQL/Turso storage adapter for Mastra.
|
|
56
|
+
*
|
|
57
|
+
* Access domain-specific storage via `getStore()`:
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const storage = new LibSQLStore({ id: 'my-store', url: 'file:./dev.db' });
|
|
62
|
+
*
|
|
63
|
+
* // Access memory domain
|
|
64
|
+
* const memory = await storage.getStore('memory');
|
|
65
|
+
* await memory?.saveThread({ thread });
|
|
66
|
+
*
|
|
67
|
+
* // Access workflows domain
|
|
68
|
+
* const workflows = await storage.getStore('workflows');
|
|
69
|
+
* await workflows?.persistWorkflowSnapshot({ workflowName, runId, snapshot });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
29
72
|
export declare class LibSQLStore extends MastraStorage {
|
|
30
73
|
private client;
|
|
31
74
|
private readonly maxRetries;
|
|
32
75
|
private readonly initialBackoffMs;
|
|
33
76
|
stores: StorageDomains;
|
|
34
77
|
constructor(config: LibSQLConfig);
|
|
35
|
-
get supports(): {
|
|
36
|
-
selectByIncludeResourceScope: boolean;
|
|
37
|
-
resourceWorkingMemory: boolean;
|
|
38
|
-
hasColumn: boolean;
|
|
39
|
-
createTable: boolean;
|
|
40
|
-
deleteMessages: boolean;
|
|
41
|
-
observabilityInstance: boolean;
|
|
42
|
-
listScoresBySpan: boolean;
|
|
43
|
-
};
|
|
44
|
-
createTable({ tableName, schema, }: {
|
|
45
|
-
tableName: TABLE_NAMES;
|
|
46
|
-
schema: Record<string, StorageColumn>;
|
|
47
|
-
}): Promise<void>;
|
|
48
|
-
/**
|
|
49
|
-
* Alters table schema to add columns if they don't exist
|
|
50
|
-
* @param tableName Name of the table
|
|
51
|
-
* @param schema Schema of the table
|
|
52
|
-
* @param ifNotExists Array of column names to add if they don't exist
|
|
53
|
-
*/
|
|
54
|
-
alterTable({ tableName, schema, ifNotExists, }: {
|
|
55
|
-
tableName: TABLE_NAMES;
|
|
56
|
-
schema: Record<string, StorageColumn>;
|
|
57
|
-
ifNotExists: string[];
|
|
58
|
-
}): Promise<void>;
|
|
59
|
-
clearTable({ tableName }: {
|
|
60
|
-
tableName: TABLE_NAMES;
|
|
61
|
-
}): Promise<void>;
|
|
62
|
-
dropTable({ tableName }: {
|
|
63
|
-
tableName: TABLE_NAMES;
|
|
64
|
-
}): Promise<void>;
|
|
65
|
-
insert(args: {
|
|
66
|
-
tableName: TABLE_NAMES;
|
|
67
|
-
record: Record<string, any>;
|
|
68
|
-
}): Promise<void>;
|
|
69
|
-
batchInsert(args: {
|
|
70
|
-
tableName: TABLE_NAMES;
|
|
71
|
-
records: Record<string, any>[];
|
|
72
|
-
}): Promise<void>;
|
|
73
|
-
load<R>({ tableName, keys }: {
|
|
74
|
-
tableName: TABLE_NAMES;
|
|
75
|
-
keys: Record<string, string>;
|
|
76
|
-
}): Promise<R | null>;
|
|
77
|
-
getThreadById({ threadId }: {
|
|
78
|
-
threadId: string;
|
|
79
|
-
}): Promise<StorageThreadType | null>;
|
|
80
|
-
saveThread({ thread }: {
|
|
81
|
-
thread: StorageThreadType;
|
|
82
|
-
}): Promise<StorageThreadType>;
|
|
83
|
-
updateThread({ id, title, metadata, }: {
|
|
84
|
-
id: string;
|
|
85
|
-
title: string;
|
|
86
|
-
metadata: Record<string, unknown>;
|
|
87
|
-
}): Promise<StorageThreadType>;
|
|
88
|
-
deleteThread({ threadId }: {
|
|
89
|
-
threadId: string;
|
|
90
|
-
}): Promise<void>;
|
|
91
|
-
listMessagesById({ messageIds }: {
|
|
92
|
-
messageIds: string[];
|
|
93
|
-
}): Promise<{
|
|
94
|
-
messages: MastraDBMessage[];
|
|
95
|
-
}>;
|
|
96
|
-
saveMessages(args: {
|
|
97
|
-
messages: MastraDBMessage[];
|
|
98
|
-
}): Promise<{
|
|
99
|
-
messages: MastraDBMessage[];
|
|
100
|
-
}>;
|
|
101
|
-
updateMessages({ messages, }: {
|
|
102
|
-
messages: (Partial<Omit<MastraDBMessage, 'createdAt'>> & {
|
|
103
|
-
id: string;
|
|
104
|
-
content?: {
|
|
105
|
-
metadata?: MastraMessageContentV2['metadata'];
|
|
106
|
-
content?: MastraMessageContentV2['content'];
|
|
107
|
-
};
|
|
108
|
-
})[];
|
|
109
|
-
}): Promise<MastraDBMessage[]>;
|
|
110
|
-
deleteMessages(messageIds: string[]): Promise<void>;
|
|
111
|
-
getScoreById({ id }: {
|
|
112
|
-
id: string;
|
|
113
|
-
}): Promise<ScoreRowData | null>;
|
|
114
|
-
saveScore(score: Omit<ScoreRowData, 'id' | 'createdAt' | 'updatedAt'>): Promise<{
|
|
115
|
-
score: ScoreRowData;
|
|
116
|
-
}>;
|
|
117
|
-
listScoresByScorerId({ scorerId, entityId, entityType, source, pagination, }: {
|
|
118
|
-
scorerId: string;
|
|
119
|
-
entityId?: string;
|
|
120
|
-
entityType?: string;
|
|
121
|
-
source?: ScoringSource;
|
|
122
|
-
pagination: StoragePagination;
|
|
123
|
-
}): Promise<{
|
|
124
|
-
pagination: PaginationInfo;
|
|
125
|
-
scores: ScoreRowData[];
|
|
126
|
-
}>;
|
|
127
|
-
listScoresByRunId({ runId, pagination, }: {
|
|
128
|
-
runId: string;
|
|
129
|
-
pagination: StoragePagination;
|
|
130
|
-
}): Promise<{
|
|
131
|
-
pagination: PaginationInfo;
|
|
132
|
-
scores: ScoreRowData[];
|
|
133
|
-
}>;
|
|
134
|
-
listScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
135
|
-
pagination: StoragePagination;
|
|
136
|
-
entityId: string;
|
|
137
|
-
entityType: string;
|
|
138
|
-
}): Promise<{
|
|
139
|
-
pagination: PaginationInfo;
|
|
140
|
-
scores: ScoreRowData[];
|
|
141
|
-
}>;
|
|
142
|
-
/**
|
|
143
|
-
* WORKFLOWS
|
|
144
|
-
*/
|
|
145
|
-
updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, }: {
|
|
146
|
-
workflowName: string;
|
|
147
|
-
runId: string;
|
|
148
|
-
stepId: string;
|
|
149
|
-
result: StepResult<any, any, any, any>;
|
|
150
|
-
requestContext: Record<string, any>;
|
|
151
|
-
}): Promise<Record<string, StepResult<any, any, any, any>>>;
|
|
152
|
-
updateWorkflowState({ workflowName, runId, opts, }: {
|
|
153
|
-
workflowName: string;
|
|
154
|
-
runId: string;
|
|
155
|
-
opts: {
|
|
156
|
-
status: string;
|
|
157
|
-
result?: StepResult<any, any, any, any>;
|
|
158
|
-
error?: string;
|
|
159
|
-
suspendedPaths?: Record<string, number[]>;
|
|
160
|
-
waitingPaths?: Record<string, number[]>;
|
|
161
|
-
};
|
|
162
|
-
}): Promise<WorkflowRunState | undefined>;
|
|
163
|
-
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, }: {
|
|
164
|
-
workflowName: string;
|
|
165
|
-
runId: string;
|
|
166
|
-
resourceId?: string;
|
|
167
|
-
snapshot: WorkflowRunState;
|
|
168
|
-
}): Promise<void>;
|
|
169
|
-
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
170
|
-
workflowName: string;
|
|
171
|
-
runId: string;
|
|
172
|
-
}): Promise<WorkflowRunState | null>;
|
|
173
|
-
listWorkflowRuns({ workflowName, fromDate, toDate, perPage, page, resourceId, }?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
|
|
174
|
-
getWorkflowRunById({ runId, workflowName, }: {
|
|
175
|
-
runId: string;
|
|
176
|
-
workflowName?: string;
|
|
177
|
-
}): Promise<WorkflowRun | null>;
|
|
178
|
-
getResourceById({ resourceId }: {
|
|
179
|
-
resourceId: string;
|
|
180
|
-
}): Promise<StorageResourceType | null>;
|
|
181
|
-
saveResource({ resource }: {
|
|
182
|
-
resource: StorageResourceType;
|
|
183
|
-
}): Promise<StorageResourceType>;
|
|
184
|
-
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
185
|
-
resourceId: string;
|
|
186
|
-
workingMemory?: string;
|
|
187
|
-
metadata?: Record<string, unknown>;
|
|
188
|
-
}): Promise<StorageResourceType>;
|
|
189
|
-
createSpan(span: SpanRecord): Promise<void>;
|
|
190
|
-
updateSpan(params: {
|
|
191
|
-
spanId: string;
|
|
192
|
-
traceId: string;
|
|
193
|
-
updates: Partial<Omit<SpanRecord, 'spanId' | 'traceId'>>;
|
|
194
|
-
}): Promise<void>;
|
|
195
|
-
getTrace(traceId: string): Promise<TraceRecord | null>;
|
|
196
|
-
getTracesPaginated(args: TracesPaginatedArg): Promise<{
|
|
197
|
-
pagination: PaginationInfo;
|
|
198
|
-
spans: SpanRecord[];
|
|
199
|
-
}>;
|
|
200
|
-
listScoresBySpan({ traceId, spanId, pagination, }: {
|
|
201
|
-
traceId: string;
|
|
202
|
-
spanId: string;
|
|
203
|
-
pagination: StoragePagination;
|
|
204
|
-
}): Promise<{
|
|
205
|
-
pagination: PaginationInfo;
|
|
206
|
-
scores: ScoreRowData[];
|
|
207
|
-
}>;
|
|
208
|
-
batchCreateSpans(args: {
|
|
209
|
-
records: SpanRecord[];
|
|
210
|
-
}): Promise<void>;
|
|
211
|
-
batchUpdateSpans(args: {
|
|
212
|
-
records: {
|
|
213
|
-
traceId: string;
|
|
214
|
-
spanId: string;
|
|
215
|
-
updates: Partial<Omit<SpanRecord, 'spanId' | 'traceId'>>;
|
|
216
|
-
}[];
|
|
217
|
-
}): Promise<void>;
|
|
218
78
|
}
|
|
219
79
|
export { LibSQLStore as DefaultStorage };
|
|
220
80
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,YAAY,EAAE,eAAe,EAAE,CAAC;AAC1F,YAAY,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;;;;;;;;;;;;;;OAkBG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,YAAY,GACpB,CAAC,gBAAgB,GAAG;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC,GACF,CAAC,gBAAgB,GAAG;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEP;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,WAAY,SAAQ,aAAa;IAC5C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAE1C,MAAM,EAAE,cAAc,CAAC;gBAEX,MAAM,EAAE,YAAY;CAuDjC;AAED,OAAO,EAAE,WAAW,IAAI,cAAc,EAAE,CAAC"}
|
package/dist/vector/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MastraVector } from '@mastra/core/vector';
|
|
2
|
-
import type { IndexStats, QueryResult, QueryVectorParams, CreateIndexParams, UpsertVectorParams, DescribeIndexParams, DeleteIndexParams, DeleteVectorParams, UpdateVectorParams } from '@mastra/core/vector';
|
|
2
|
+
import type { IndexStats, QueryResult, QueryVectorParams, CreateIndexParams, UpsertVectorParams, DescribeIndexParams, DeleteIndexParams, DeleteVectorParams, UpdateVectorParams, DeleteVectorsParams } from '@mastra/core/vector';
|
|
3
3
|
import type { LibSQLVectorFilter } from './filter.js';
|
|
4
4
|
interface LibSQLQueryVectorParams extends QueryVectorParams<LibSQLVectorFilter> {
|
|
5
5
|
minScore?: number;
|
|
@@ -56,7 +56,7 @@ export declare class LibSQLVector extends MastraVector<LibSQLVectorFilter> {
|
|
|
56
56
|
* @returns A promise that resolves when the update is complete.
|
|
57
57
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
58
58
|
*/
|
|
59
|
-
updateVector(args: UpdateVectorParams): Promise<void>;
|
|
59
|
+
updateVector(args: UpdateVectorParams<LibSQLVectorFilter>): Promise<void>;
|
|
60
60
|
private doUpdateVector;
|
|
61
61
|
/**
|
|
62
62
|
* Deletes a vector by its ID.
|
|
@@ -67,6 +67,8 @@ export declare class LibSQLVector extends MastraVector<LibSQLVectorFilter> {
|
|
|
67
67
|
*/
|
|
68
68
|
deleteVector(args: DeleteVectorParams): Promise<void>;
|
|
69
69
|
private doDeleteVector;
|
|
70
|
+
deleteVectors(args: DeleteVectorsParams<LibSQLVectorFilter>): Promise<void>;
|
|
71
|
+
private doDeleteVectors;
|
|
70
72
|
truncateIndex(args: DeleteIndexParams): Promise<void>;
|
|
71
73
|
private _doTruncateIndex;
|
|
72
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vector/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vector/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAInD,UAAU,uBAAwB,SAAQ,iBAAiB,CAAC,kBAAkB,CAAC;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,qBAAa,YAAa,SAAQ,YAAY,CAAC,kBAAkB,CAAC;IAChE,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;gBAE9B,EACV,aAAa,EACb,SAAS,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":"","sources":["../../src/vector/sql-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAS9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"sql-builder.d.ts","sourceRoot":"","sources":["../../src/vector/sql-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAS9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AA4WnD,UAAU,YAAY;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,OAAO,EAAE,CAAC;CACnB;AA6BD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CAkBzE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/libsql",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.10",
|
|
4
4
|
"description": "Libsql provider for Mastra - includes both vector and db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,16 +23,17 @@
|
|
|
23
23
|
"@libsql/client": "^0.15.15"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@
|
|
27
|
-
"@
|
|
26
|
+
"@types/node": "22.13.17",
|
|
27
|
+
"@vitest/coverage-v8": "4.0.12",
|
|
28
|
+
"@vitest/ui": "4.0.12",
|
|
28
29
|
"eslint": "^9.37.0",
|
|
29
30
|
"tsup": "^8.5.0",
|
|
30
31
|
"typescript": "^5.8.3",
|
|
31
|
-
"vitest": "
|
|
32
|
+
"vitest": "4.0.12",
|
|
32
33
|
"@internal/lint": "0.0.53",
|
|
33
|
-
"@internal/storage-test-utils": "0.0.49",
|
|
34
34
|
"@internal/types-builder": "0.0.28",
|
|
35
|
-
"@
|
|
35
|
+
"@internal/storage-test-utils": "0.0.49",
|
|
36
|
+
"@mastra/core": "1.0.0-beta.16"
|
|
36
37
|
},
|
|
37
38
|
"peerDependencies": {
|
|
38
39
|
"@mastra/core": ">=1.0.0-0 <2.0.0-0"
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import type { Client, InValue } from '@libsql/client';
|
|
2
|
-
import { StoreOperations } from '@mastra/core/storage';
|
|
3
|
-
import type { StorageColumn, TABLE_NAMES } from '@mastra/core/storage';
|
|
4
|
-
export declare class StoreOperationsLibSQL extends StoreOperations {
|
|
5
|
-
private client;
|
|
6
|
-
/**
|
|
7
|
-
* Maximum number of retries for write operations if an SQLITE_BUSY error occurs.
|
|
8
|
-
* @default 5
|
|
9
|
-
*/
|
|
10
|
-
maxRetries: number;
|
|
11
|
-
/**
|
|
12
|
-
* Initial backoff time in milliseconds for retrying write operations on SQLITE_BUSY.
|
|
13
|
-
* The backoff time will double with each retry (exponential backoff).
|
|
14
|
-
* @default 100
|
|
15
|
-
*/
|
|
16
|
-
initialBackoffMs: number;
|
|
17
|
-
constructor({ client, maxRetries, initialBackoffMs, }: {
|
|
18
|
-
client: Client;
|
|
19
|
-
maxRetries?: number;
|
|
20
|
-
initialBackoffMs?: number;
|
|
21
|
-
});
|
|
22
|
-
hasColumn(table: string, column: string): Promise<boolean>;
|
|
23
|
-
private getCreateTableSQL;
|
|
24
|
-
createTable({ tableName, schema, }: {
|
|
25
|
-
tableName: TABLE_NAMES;
|
|
26
|
-
schema: Record<string, StorageColumn>;
|
|
27
|
-
}): Promise<void>;
|
|
28
|
-
protected getSqlType(type: StorageColumn['type']): string;
|
|
29
|
-
private doInsert;
|
|
30
|
-
insert(args: {
|
|
31
|
-
tableName: TABLE_NAMES;
|
|
32
|
-
record: Record<string, any>;
|
|
33
|
-
}): Promise<void>;
|
|
34
|
-
load<R>({ tableName, keys }: {
|
|
35
|
-
tableName: TABLE_NAMES;
|
|
36
|
-
keys: Record<string, string>;
|
|
37
|
-
}): Promise<R | null>;
|
|
38
|
-
loadMany<R>({ tableName, whereClause, orderBy, offset, limit, args, }: {
|
|
39
|
-
tableName: TABLE_NAMES;
|
|
40
|
-
whereClause?: {
|
|
41
|
-
sql: string;
|
|
42
|
-
args: InValue[];
|
|
43
|
-
};
|
|
44
|
-
orderBy?: string;
|
|
45
|
-
offset?: number;
|
|
46
|
-
limit?: number;
|
|
47
|
-
args?: any[];
|
|
48
|
-
}): Promise<R[]>;
|
|
49
|
-
loadTotalCount({ tableName, whereClause, }: {
|
|
50
|
-
tableName: TABLE_NAMES;
|
|
51
|
-
whereClause?: {
|
|
52
|
-
sql: string;
|
|
53
|
-
args: InValue[];
|
|
54
|
-
};
|
|
55
|
-
}): Promise<number>;
|
|
56
|
-
update(args: {
|
|
57
|
-
tableName: TABLE_NAMES;
|
|
58
|
-
keys: Record<string, any>;
|
|
59
|
-
data: Record<string, any>;
|
|
60
|
-
}): Promise<void>;
|
|
61
|
-
private executeUpdate;
|
|
62
|
-
private doBatchInsert;
|
|
63
|
-
batchInsert(args: {
|
|
64
|
-
tableName: TABLE_NAMES;
|
|
65
|
-
records: Record<string, any>[];
|
|
66
|
-
}): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Public batch update method with retry logic
|
|
69
|
-
*/
|
|
70
|
-
batchUpdate(args: {
|
|
71
|
-
tableName: TABLE_NAMES;
|
|
72
|
-
updates: Array<{
|
|
73
|
-
keys: Record<string, any>;
|
|
74
|
-
data: Record<string, any>;
|
|
75
|
-
}>;
|
|
76
|
-
}): Promise<void>;
|
|
77
|
-
/**
|
|
78
|
-
* Updates multiple records in batch. Each record can be updated based on single or composite keys.
|
|
79
|
-
*/
|
|
80
|
-
private executeBatchUpdate;
|
|
81
|
-
/**
|
|
82
|
-
* Public batch delete method with retry logic
|
|
83
|
-
*/
|
|
84
|
-
batchDelete({ tableName, keys }: {
|
|
85
|
-
tableName: TABLE_NAMES;
|
|
86
|
-
keys: Array<Record<string, any>>;
|
|
87
|
-
}): Promise<void>;
|
|
88
|
-
/**
|
|
89
|
-
* Deletes multiple records in batch. Each record can be deleted based on single or composite keys.
|
|
90
|
-
*/
|
|
91
|
-
private executeBatchDelete;
|
|
92
|
-
/**
|
|
93
|
-
* Alters table schema to add columns if they don't exist
|
|
94
|
-
* @param tableName Name of the table
|
|
95
|
-
* @param schema Schema of the table
|
|
96
|
-
* @param ifNotExists Array of column names to add if they don't exist
|
|
97
|
-
*/
|
|
98
|
-
alterTable({ tableName, schema, ifNotExists, }: {
|
|
99
|
-
tableName: TABLE_NAMES;
|
|
100
|
-
schema: Record<string, StorageColumn>;
|
|
101
|
-
ifNotExists: string[];
|
|
102
|
-
}): Promise<void>;
|
|
103
|
-
clearTable({ tableName }: {
|
|
104
|
-
tableName: TABLE_NAMES;
|
|
105
|
-
}): Promise<void>;
|
|
106
|
-
dropTable({ tableName }: {
|
|
107
|
-
tableName: TABLE_NAMES;
|
|
108
|
-
}): Promise<void>;
|
|
109
|
-
}
|
|
110
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/operations/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAA2B,eAAe,EAAe,MAAM,sBAAsB,CAAC;AAC7F,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AASvE,qBAAa,qBAAsB,SAAQ,eAAe;IACxD,OAAO,CAAC,MAAM,CAAS;IACvB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,CAAC;gBAEb,EACV,MAAM,EACN,UAAU,EACV,gBAAgB,GACjB,EAAE;QACD,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAA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