@mastra/libsql 0.0.0-bundle-recursion-20251030002519 → 0.0.0-bundle-studio-cloud-20251222034739
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 +861 -3
- package/README.md +30 -20
- package/dist/index.cjs +2098 -1668
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2032 -1602
- package/dist/index.js.map +1 -1
- package/dist/storage/db/index.d.ts +259 -0
- package/dist/storage/db/index.d.ts.map +1 -0
- package/dist/storage/{domains → db}/utils.d.ts +4 -0
- 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 +19 -53
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/index.d.ts +17 -17
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +15 -14
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +18 -32
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +70 -128
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/vector/index.d.ts +7 -3
- package/dist/vector/index.d.ts.map +1 -1
- package/dist/vector/sql-builder.d.ts.map +1 -1
- package/package.json +12 -8
- package/dist/storage/domains/legacy-evals/index.d.ts +0 -18
- package/dist/storage/domains/legacy-evals/index.d.ts.map +0 -1
- 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
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import type { Client, InValue } from '@libsql/client';
|
|
2
|
+
import { MastraBase } from '@mastra/core/base';
|
|
3
|
+
import type { TABLE_NAMES, StorageColumn } from '@mastra/core/storage';
|
|
4
|
+
/**
|
|
5
|
+
* Base configuration options shared across LibSQL domain configurations
|
|
6
|
+
*/
|
|
7
|
+
export type LibSQLDomainBaseConfig = {
|
|
8
|
+
/**
|
|
9
|
+
* Maximum number of retries for write operations if an SQLITE_BUSY error occurs.
|
|
10
|
+
* @default 5
|
|
11
|
+
*/
|
|
12
|
+
maxRetries?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Initial backoff time in milliseconds for retrying write operations on SQLITE_BUSY.
|
|
15
|
+
* The backoff time will double with each retry (exponential backoff).
|
|
16
|
+
* @default 100
|
|
17
|
+
*/
|
|
18
|
+
initialBackoffMs?: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for LibSQL domains - accepts either credentials or an existing client
|
|
22
|
+
*/
|
|
23
|
+
export type LibSQLDomainConfig = (LibSQLDomainBaseConfig & {
|
|
24
|
+
/** The database connection URL (e.g., "file:local.db", "libsql://...", "file::memory:") */
|
|
25
|
+
url: string;
|
|
26
|
+
/** Optional authentication token for remote databases */
|
|
27
|
+
authToken?: string;
|
|
28
|
+
}) | (LibSQLDomainBaseConfig & {
|
|
29
|
+
/** An existing LibSQL client instance */
|
|
30
|
+
client: Client;
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Resolves a LibSQLDomainConfig to a Client instance.
|
|
34
|
+
* Creates a new client if credentials are provided, or returns the existing client.
|
|
35
|
+
*
|
|
36
|
+
* @param config - The domain configuration
|
|
37
|
+
* @returns The resolved LibSQL client
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveClient(config: LibSQLDomainConfig): Client;
|
|
40
|
+
export declare class LibSQLDB extends MastraBase {
|
|
41
|
+
private client;
|
|
42
|
+
maxRetries: number;
|
|
43
|
+
initialBackoffMs: number;
|
|
44
|
+
executeWriteOperationWithRetry: <T>(operationFn: () => Promise<T>, operationDescription: string) => Promise<T>;
|
|
45
|
+
constructor({ client, maxRetries, initialBackoffMs, }: {
|
|
46
|
+
client: Client;
|
|
47
|
+
maxRetries?: number;
|
|
48
|
+
initialBackoffMs?: number;
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* Checks if a column exists in the specified table.
|
|
52
|
+
*
|
|
53
|
+
* @param table - The name of the table to check
|
|
54
|
+
* @param column - The name of the column to look for
|
|
55
|
+
* @returns `true` if the column exists in the table, `false` otherwise
|
|
56
|
+
*/
|
|
57
|
+
hasColumn(table: string, column: string): Promise<boolean>;
|
|
58
|
+
/**
|
|
59
|
+
* Internal insert implementation without retry logic.
|
|
60
|
+
*/
|
|
61
|
+
private doInsert;
|
|
62
|
+
/**
|
|
63
|
+
* Inserts or replaces a record in the specified table with automatic retry on lock errors.
|
|
64
|
+
*
|
|
65
|
+
* @param args - The insert arguments
|
|
66
|
+
* @param args.tableName - The name of the table to insert into
|
|
67
|
+
* @param args.record - The record to insert (key-value pairs)
|
|
68
|
+
*/
|
|
69
|
+
insert(args: {
|
|
70
|
+
tableName: TABLE_NAMES;
|
|
71
|
+
record: Record<string, any>;
|
|
72
|
+
}): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Internal update implementation without retry logic.
|
|
75
|
+
*/
|
|
76
|
+
private doUpdate;
|
|
77
|
+
/**
|
|
78
|
+
* Updates a record in the specified table with automatic retry on lock errors.
|
|
79
|
+
*
|
|
80
|
+
* @param args - The update arguments
|
|
81
|
+
* @param args.tableName - The name of the table to update
|
|
82
|
+
* @param args.keys - The key(s) identifying the record to update
|
|
83
|
+
* @param args.data - The fields to update (key-value pairs)
|
|
84
|
+
*/
|
|
85
|
+
update(args: {
|
|
86
|
+
tableName: TABLE_NAMES;
|
|
87
|
+
keys: Record<string, any>;
|
|
88
|
+
data: Record<string, any>;
|
|
89
|
+
}): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Internal batch insert implementation without retry logic.
|
|
92
|
+
*/
|
|
93
|
+
private doBatchInsert;
|
|
94
|
+
/**
|
|
95
|
+
* Inserts multiple records in a single batch transaction with automatic retry on lock errors.
|
|
96
|
+
*
|
|
97
|
+
* @param args - The batch insert arguments
|
|
98
|
+
* @param args.tableName - The name of the table to insert into
|
|
99
|
+
* @param args.records - Array of records to insert
|
|
100
|
+
* @throws {MastraError} When the batch insert fails after retries
|
|
101
|
+
*/
|
|
102
|
+
batchInsert(args: {
|
|
103
|
+
tableName: TABLE_NAMES;
|
|
104
|
+
records: Record<string, any>[];
|
|
105
|
+
}): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Internal batch update implementation without retry logic.
|
|
108
|
+
* Each record can be updated based on single or composite keys.
|
|
109
|
+
*/
|
|
110
|
+
private doBatchUpdate;
|
|
111
|
+
/**
|
|
112
|
+
* Updates multiple records in a single batch transaction with automatic retry on lock errors.
|
|
113
|
+
* Each record can be updated based on single or composite keys.
|
|
114
|
+
*
|
|
115
|
+
* @param args - The batch update arguments
|
|
116
|
+
* @param args.tableName - The name of the table to update
|
|
117
|
+
* @param args.updates - Array of update operations, each containing keys and data
|
|
118
|
+
* @throws {MastraError} When the batch update fails after retries
|
|
119
|
+
*/
|
|
120
|
+
batchUpdate(args: {
|
|
121
|
+
tableName: TABLE_NAMES;
|
|
122
|
+
updates: Array<{
|
|
123
|
+
keys: Record<string, any>;
|
|
124
|
+
data: Record<string, any>;
|
|
125
|
+
}>;
|
|
126
|
+
}): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Internal batch delete implementation without retry logic.
|
|
129
|
+
* Each record can be deleted based on single or composite keys.
|
|
130
|
+
*/
|
|
131
|
+
private doBatchDelete;
|
|
132
|
+
/**
|
|
133
|
+
* Deletes multiple records in a single batch transaction with automatic retry on lock errors.
|
|
134
|
+
* Each record can be deleted based on single or composite keys.
|
|
135
|
+
*
|
|
136
|
+
* @param args - The batch delete arguments
|
|
137
|
+
* @param args.tableName - The name of the table to delete from
|
|
138
|
+
* @param args.keys - Array of key objects identifying records to delete
|
|
139
|
+
* @throws {MastraError} When the batch delete fails after retries
|
|
140
|
+
*/
|
|
141
|
+
batchDelete({ tableName, keys, }: {
|
|
142
|
+
tableName: TABLE_NAMES;
|
|
143
|
+
keys: Array<Record<string, any>>;
|
|
144
|
+
}): Promise<void>;
|
|
145
|
+
/**
|
|
146
|
+
* Internal single-record delete implementation without retry logic.
|
|
147
|
+
*/
|
|
148
|
+
private doDelete;
|
|
149
|
+
/**
|
|
150
|
+
* Deletes a single record from the specified table with automatic retry on lock errors.
|
|
151
|
+
*
|
|
152
|
+
* @param args - The delete arguments
|
|
153
|
+
* @param args.tableName - The name of the table to delete from
|
|
154
|
+
* @param args.keys - The key(s) identifying the record to delete
|
|
155
|
+
* @throws {MastraError} When the delete fails after retries
|
|
156
|
+
*/
|
|
157
|
+
delete(args: {
|
|
158
|
+
tableName: TABLE_NAMES;
|
|
159
|
+
keys: Record<string, any>;
|
|
160
|
+
}): Promise<void>;
|
|
161
|
+
/**
|
|
162
|
+
* Selects a single record from the specified table by key(s).
|
|
163
|
+
* Returns the most recently created record if multiple matches exist.
|
|
164
|
+
* Automatically parses JSON string values back to objects/arrays.
|
|
165
|
+
*
|
|
166
|
+
* @typeParam R - The expected return type of the record
|
|
167
|
+
* @param args - The select arguments
|
|
168
|
+
* @param args.tableName - The name of the table to select from
|
|
169
|
+
* @param args.keys - The key(s) identifying the record to select
|
|
170
|
+
* @returns The matching record or `null` if not found
|
|
171
|
+
*/
|
|
172
|
+
select<R>({ tableName, keys }: {
|
|
173
|
+
tableName: TABLE_NAMES;
|
|
174
|
+
keys: Record<string, string>;
|
|
175
|
+
}): Promise<R | null>;
|
|
176
|
+
/**
|
|
177
|
+
* Selects multiple records from the specified table with optional filtering, ordering, and pagination.
|
|
178
|
+
*
|
|
179
|
+
* @typeParam R - The expected return type of each record
|
|
180
|
+
* @param args - The select arguments
|
|
181
|
+
* @param args.tableName - The name of the table to select from
|
|
182
|
+
* @param args.whereClause - Optional WHERE clause with SQL string and arguments
|
|
183
|
+
* @param args.orderBy - Optional ORDER BY clause (e.g., "createdAt DESC")
|
|
184
|
+
* @param args.offset - Optional offset for pagination
|
|
185
|
+
* @param args.limit - Optional limit for pagination
|
|
186
|
+
* @param args.args - Optional additional query arguments
|
|
187
|
+
* @returns Array of matching records
|
|
188
|
+
*/
|
|
189
|
+
selectMany<R>({ tableName, whereClause, orderBy, offset, limit, args, }: {
|
|
190
|
+
tableName: TABLE_NAMES;
|
|
191
|
+
whereClause?: {
|
|
192
|
+
sql: string;
|
|
193
|
+
args: InValue[];
|
|
194
|
+
};
|
|
195
|
+
orderBy?: string;
|
|
196
|
+
offset?: number;
|
|
197
|
+
limit?: number;
|
|
198
|
+
args?: any[];
|
|
199
|
+
}): Promise<R[]>;
|
|
200
|
+
/**
|
|
201
|
+
* Returns the total count of records matching the optional WHERE clause.
|
|
202
|
+
*
|
|
203
|
+
* @param args - The count arguments
|
|
204
|
+
* @param args.tableName - The name of the table to count from
|
|
205
|
+
* @param args.whereClause - Optional WHERE clause with SQL string and arguments
|
|
206
|
+
* @returns The total count of matching records
|
|
207
|
+
*/
|
|
208
|
+
selectTotalCount({ tableName, whereClause, }: {
|
|
209
|
+
tableName: TABLE_NAMES;
|
|
210
|
+
whereClause?: {
|
|
211
|
+
sql: string;
|
|
212
|
+
args: InValue[];
|
|
213
|
+
};
|
|
214
|
+
}): Promise<number>;
|
|
215
|
+
/**
|
|
216
|
+
* Maps a storage column type to its SQLite equivalent.
|
|
217
|
+
*/
|
|
218
|
+
protected getSqlType(type: StorageColumn['type']): string;
|
|
219
|
+
/**
|
|
220
|
+
* Creates a table if it doesn't exist based on the provided schema.
|
|
221
|
+
*
|
|
222
|
+
* @param args - The create table arguments
|
|
223
|
+
* @param args.tableName - The name of the table to create
|
|
224
|
+
* @param args.schema - The schema definition for the table columns
|
|
225
|
+
*/
|
|
226
|
+
createTable({ tableName, schema, }: {
|
|
227
|
+
tableName: TABLE_NAMES;
|
|
228
|
+
schema: Record<string, StorageColumn>;
|
|
229
|
+
}): Promise<void>;
|
|
230
|
+
/**
|
|
231
|
+
* Gets a default value for a column type (used when adding NOT NULL columns).
|
|
232
|
+
*/
|
|
233
|
+
private getDefaultValue;
|
|
234
|
+
/**
|
|
235
|
+
* Alters an existing table to add missing columns.
|
|
236
|
+
* Used for schema migrations when new columns are added.
|
|
237
|
+
*
|
|
238
|
+
* @param args - The alter table arguments
|
|
239
|
+
* @param args.tableName - The name of the table to alter
|
|
240
|
+
* @param args.schema - The full schema definition for the table
|
|
241
|
+
* @param args.ifNotExists - Array of column names to add if they don't exist
|
|
242
|
+
*/
|
|
243
|
+
alterTable({ tableName, schema, ifNotExists, }: {
|
|
244
|
+
tableName: TABLE_NAMES;
|
|
245
|
+
schema: Record<string, StorageColumn>;
|
|
246
|
+
ifNotExists: string[];
|
|
247
|
+
}): Promise<void>;
|
|
248
|
+
/**
|
|
249
|
+
* Deletes all records from the specified table.
|
|
250
|
+
* Errors are logged but not thrown.
|
|
251
|
+
*
|
|
252
|
+
* @param args - The delete arguments
|
|
253
|
+
* @param args.tableName - The name of the table to clear
|
|
254
|
+
*/
|
|
255
|
+
deleteData({ tableName }: {
|
|
256
|
+
tableName: TABLE_NAMES;
|
|
257
|
+
}): Promise<void>;
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/db/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AASvE;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,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AAC;QACtC,WAAW,EAAE,MAAM,EAAE,CAAC;KACvB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoCjB;;;;;;OAMG;IACG,UAAU,CAAC,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAoB3E"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { InValue } from '@libsql/client';
|
|
2
2
|
import type { IMastraLogger } from '@mastra/core/logger';
|
|
3
3
|
import type { PaginationArgs, StorageColumn, TABLE_NAMES } from '@mastra/core/storage';
|
|
4
|
+
/**
|
|
5
|
+
* Checks if an error is a SQLite lock/busy error that should be retried
|
|
6
|
+
*/
|
|
7
|
+
export declare function isLockError(error: any): boolean;
|
|
4
8
|
export declare function createExecuteWriteOperationWithRetry({ logger, maxRetries, initialBackoffMs, }: {
|
|
5
9
|
logger: IMastraLogger;
|
|
6
10
|
maxRetries: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/storage/db/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGvF;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAS/C;AAED,wBAAgB,oCAAoC,CAAC,EACnD,MAAM,EACN,UAAU,EACV,gBAAgB,GACjB,EAAE;IACD,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,IACsD,CAAC,EACpD,aAAa,MAAM,OAAO,CAAC,CAAC,CAAC,EAC7B,sBAAsB,MAAM,KAC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AqBA;AA+CD,KAAK,eAAe,GAAG;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC,EACvC,UAAU,GAAE,MAAoB,GAC/B,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAgBjC;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,EACrC,SAAS,EACT,MAAM,GACP,EAAE;IACD,SAAS,EAAE,WAAW,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B,GAAG,CAAC,CAiCJ"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AgentsStorage } from '@mastra/core/storage';
|
|
2
|
+
import type { StorageAgentType, StorageCreateAgentInput, StorageUpdateAgentInput, StorageListAgentsInput, StorageListAgentsOutput } from '@mastra/core/storage';
|
|
3
|
+
import type { LibSQLDomainConfig } from '../../db/index.js';
|
|
4
|
+
export declare class AgentsLibSQL extends AgentsStorage {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(config: LibSQLDomainConfig);
|
|
7
|
+
init(): Promise<void>;
|
|
8
|
+
dangerouslyClearAll(): Promise<void>;
|
|
9
|
+
private parseJson;
|
|
10
|
+
private parseRow;
|
|
11
|
+
getAgentById({ id }: {
|
|
12
|
+
id: string;
|
|
13
|
+
}): Promise<StorageAgentType | null>;
|
|
14
|
+
createAgent({ agent }: {
|
|
15
|
+
agent: StorageCreateAgentInput;
|
|
16
|
+
}): Promise<StorageAgentType>;
|
|
17
|
+
updateAgent({ id, ...updates }: StorageUpdateAgentInput): Promise<StorageAgentType>;
|
|
18
|
+
deleteAgent({ id }: {
|
|
19
|
+
id: string;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
listAgents(args?: StorageListAgentsInput): Promise<StorageListAgentsOutput>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/agents/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAMd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEnD,qBAAa,YAAa,SAAQ,aAAa;;gBAGjC,MAAM,EAAE,kBAAkB;IAMhC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI1C,OAAO,CAAC,SAAS;IA2BjB,OAAO,CAAC,QAAQ;IAqBV,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAqBtE,WAAW,CAAC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,EAAE,uBAAuB,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA4CrF,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,EAAE,EAAE,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA0EnF,WAAW,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBlD,UAAU,CAAC,IAAI,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,uBAAuB,CAAC;CA8DlF"}
|
|
@@ -1,57 +1,35 @@
|
|
|
1
|
-
import type { Client } from '@libsql/client';
|
|
2
1
|
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
2
|
+
import type { MastraDBMessage, StorageThreadType } from '@mastra/core/memory';
|
|
3
|
+
import type { StorageResourceType, StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsByResourceIdInput, StorageListThreadsByResourceIdOutput } from '@mastra/core/storage';
|
|
5
4
|
import { MemoryStorage } from '@mastra/core/storage';
|
|
6
|
-
import type {
|
|
5
|
+
import type { LibSQLDomainConfig } from '../../db/index.js';
|
|
7
6
|
export declare class MemoryLibSQL extends MemoryStorage {
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
operations: StoreOperationsLibSQL;
|
|
13
|
-
});
|
|
7
|
+
#private;
|
|
8
|
+
constructor(config: LibSQLDomainConfig);
|
|
9
|
+
init(): Promise<void>;
|
|
10
|
+
dangerouslyClearAll(): Promise<void>;
|
|
14
11
|
private parseRow;
|
|
15
12
|
private _getIncludedMessages;
|
|
16
|
-
|
|
17
|
-
* @deprecated use getMessagesPaginated instead for paginated results.
|
|
18
|
-
*/
|
|
19
|
-
getMessages(args: StorageGetMessagesArg & {
|
|
20
|
-
format?: 'v1';
|
|
21
|
-
}): Promise<MastraMessageV1[]>;
|
|
22
|
-
getMessages(args: StorageGetMessagesArg & {
|
|
23
|
-
format: 'v2';
|
|
24
|
-
}): Promise<MastraMessageV2[]>;
|
|
25
|
-
getMessagesById({ messageIds, format, }: {
|
|
13
|
+
listMessagesById({ messageIds }: {
|
|
26
14
|
messageIds: string[];
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}): Promise<PaginationInfo & {
|
|
36
|
-
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
15
|
+
}): Promise<{
|
|
16
|
+
messages: MastraDBMessage[];
|
|
17
|
+
}>;
|
|
18
|
+
listMessages(args: StorageListMessagesInput): Promise<StorageListMessagesOutput>;
|
|
19
|
+
saveMessages({ messages }: {
|
|
20
|
+
messages: MastraDBMessage[];
|
|
21
|
+
}): Promise<{
|
|
22
|
+
messages: MastraDBMessage[];
|
|
37
23
|
}>;
|
|
38
|
-
saveMessages(args: {
|
|
39
|
-
messages: MastraMessageV1[];
|
|
40
|
-
format?: undefined | 'v1';
|
|
41
|
-
}): Promise<MastraMessageV1[]>;
|
|
42
|
-
saveMessages(args: {
|
|
43
|
-
messages: MastraMessageV2[];
|
|
44
|
-
format: 'v2';
|
|
45
|
-
}): Promise<MastraMessageV2[]>;
|
|
46
24
|
updateMessages({ messages, }: {
|
|
47
|
-
messages: (Partial<Omit<
|
|
25
|
+
messages: (Partial<Omit<MastraDBMessage, 'createdAt'>> & {
|
|
48
26
|
id: string;
|
|
49
27
|
content?: {
|
|
50
28
|
metadata?: MastraMessageContentV2['metadata'];
|
|
51
29
|
content?: MastraMessageContentV2['content'];
|
|
52
30
|
};
|
|
53
31
|
})[];
|
|
54
|
-
}): Promise<
|
|
32
|
+
}): Promise<MastraDBMessage[]>;
|
|
55
33
|
deleteMessages(messageIds: string[]): Promise<void>;
|
|
56
34
|
getResourceById({ resourceId }: {
|
|
57
35
|
resourceId: string;
|
|
@@ -67,19 +45,7 @@ export declare class MemoryLibSQL extends MemoryStorage {
|
|
|
67
45
|
getThreadById({ threadId }: {
|
|
68
46
|
threadId: string;
|
|
69
47
|
}): Promise<StorageThreadType | null>;
|
|
70
|
-
|
|
71
|
-
* @deprecated use getThreadsByResourceIdPaginated instead for paginated results.
|
|
72
|
-
*/
|
|
73
|
-
getThreadsByResourceId(args: {
|
|
74
|
-
resourceId: string;
|
|
75
|
-
} & ThreadSortOptions): Promise<StorageThreadType[]>;
|
|
76
|
-
getThreadsByResourceIdPaginated(args: {
|
|
77
|
-
resourceId: string;
|
|
78
|
-
page: number;
|
|
79
|
-
perPage: number;
|
|
80
|
-
} & ThreadSortOptions): Promise<PaginationInfo & {
|
|
81
|
-
threads: StorageThreadType[];
|
|
82
|
-
}>;
|
|
48
|
+
listThreadsByResourceId(args: StorageListThreadsByResourceIdInput): Promise<StorageListThreadsByResourceIdOutput>;
|
|
83
49
|
saveThread({ thread }: {
|
|
84
50
|
thread: StorageThreadType;
|
|
85
51
|
}): Promise<StorageThreadType>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/memory/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/memory/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGjE,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,mCAAmC,EACnC,oCAAoC,EACrC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,aAAa,EAOd,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEnD,qBAAa,YAAa,SAAQ,aAAa;;gBAIjC,MAAM,EAAE,kBAAkB;IAOhC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAYrB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAM1C,OAAO,CAAC,QAAQ;YAmBF,oBAAoB;IAgDrB,gBAAgB,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,eAAe,EAAE,CAAA;KAAE,CAAC;IAmCpG,YAAY,CAAC,IAAI,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAqKvF,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;QAAE,QAAQ,EAAE,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,UAAU,CAAC,EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,EAAE,iBAAiB,CAAA;KAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA2BjF,YAAY,CAAC,EACjB,EAAE,EACF,KAAK,EACL,QAAQ,GACT,EAAE;QACD,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA6CxB,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CA0BtE"}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { ObservabilityStorage } from '@mastra/core/storage';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { SpanRecord, CreateSpanRecord, UpdateSpanRecord, TraceRecord, TracesPaginatedArg, PaginationInfo } from '@mastra/core/storage';
|
|
3
|
+
import type { LibSQLDomainConfig } from '../../db/index.js';
|
|
4
4
|
export declare class ObservabilityLibSQL extends ObservabilityStorage {
|
|
5
|
-
private
|
|
6
|
-
constructor(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
#private;
|
|
6
|
+
constructor(config: LibSQLDomainConfig);
|
|
7
|
+
init(): Promise<void>;
|
|
8
|
+
dangerouslyClearAll(): Promise<void>;
|
|
9
|
+
createSpan(span: CreateSpanRecord): Promise<void>;
|
|
10
|
+
getTrace(traceId: string): Promise<TraceRecord | null>;
|
|
11
|
+
updateSpan({ spanId, traceId, updates, }: {
|
|
12
12
|
spanId: string;
|
|
13
13
|
traceId: string;
|
|
14
|
-
updates: Partial<
|
|
14
|
+
updates: Partial<UpdateSpanRecord>;
|
|
15
15
|
}): Promise<void>;
|
|
16
|
-
|
|
16
|
+
getTracesPaginated({ filters, pagination, }: TracesPaginatedArg): Promise<{
|
|
17
17
|
pagination: PaginationInfo;
|
|
18
|
-
spans:
|
|
18
|
+
spans: SpanRecord[];
|
|
19
19
|
}>;
|
|
20
|
-
|
|
21
|
-
records:
|
|
20
|
+
batchCreateSpans(args: {
|
|
21
|
+
records: CreateSpanRecord[];
|
|
22
22
|
}): Promise<void>;
|
|
23
|
-
|
|
23
|
+
batchUpdateSpans(args: {
|
|
24
24
|
records: {
|
|
25
25
|
traceId: string;
|
|
26
26
|
spanId: string;
|
|
27
|
-
updates: Partial<
|
|
27
|
+
updates: Partial<UpdateSpanRecord>;
|
|
28
28
|
}[];
|
|
29
29
|
}): Promise<void>;
|
|
30
|
-
|
|
30
|
+
batchDeleteTraces(args: {
|
|
31
31
|
traceIds: string[];
|
|
32
32
|
}): Promise<void>;
|
|
33
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/observability/index.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/observability/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAqC,oBAAoB,EAAe,MAAM,sBAAsB,CAAC;AAC5G,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,cAAc,EACf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGnD,qBAAa,mBAAoB,SAAQ,oBAAoB;;gBAG/C,MAAM,EAAE,kBAAkB;IAMhC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIpC,UAAU,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IA4BjD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IA+BtD,UAAU,CAAC,EACf,MAAM,EACN,OAAO,EACP,OAAO,GACR,EAAE;QACD,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;KACpC,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBX,kBAAkB,CAAC,EACvB,OAAO,EACP,UAAU,GACX,EAAE,kBAAkB,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,KAAK,EAAE,UAAU,EAAE,CAAA;KAAE,CAAC;IA4G9E,gBAAgB,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,gBAAgB,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBtE,gBAAgB,CAAC,IAAI,EAAE;QAC3B,OAAO,EAAE;YACP,OAAO,EAAE,MAAM,CAAC;YAChB,MAAM,EAAE,MAAM,CAAC;YACf,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;SACpC,EAAE,CAAC;KACL,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBX,iBAAiB,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAkBrE"}
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ScoreRowData, ScoringSource } from '@mastra/core/scores';
|
|
1
|
+
import type { SaveScorePayload, ScoreRowData, ScoringSource } from '@mastra/core/evals';
|
|
3
2
|
import { ScoresStorage } from '@mastra/core/storage';
|
|
4
3
|
import type { PaginationInfo, StoragePagination } from '@mastra/core/storage';
|
|
5
|
-
import type {
|
|
4
|
+
import type { LibSQLDomainConfig } from '../../db/index.js';
|
|
6
5
|
export declare class ScoresLibSQL extends ScoresStorage {
|
|
7
|
-
private
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
13
|
-
getScoresByRunId({ runId, pagination, }: {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(config: LibSQLDomainConfig);
|
|
8
|
+
init(): Promise<void>;
|
|
9
|
+
dangerouslyClearAll(): Promise<void>;
|
|
10
|
+
listScoresByRunId({ runId, pagination, }: {
|
|
14
11
|
runId: string;
|
|
15
12
|
pagination: StoragePagination;
|
|
16
13
|
}): Promise<{
|
|
17
14
|
pagination: PaginationInfo;
|
|
18
15
|
scores: ScoreRowData[];
|
|
19
16
|
}>;
|
|
20
|
-
|
|
17
|
+
listScoresByScorerId({ scorerId, entityId, entityType, source, pagination, }: {
|
|
21
18
|
scorerId: string;
|
|
22
19
|
entityId?: string;
|
|
23
20
|
entityType?: string;
|
|
@@ -27,14 +24,18 @@ export declare class ScoresLibSQL extends ScoresStorage {
|
|
|
27
24
|
pagination: PaginationInfo;
|
|
28
25
|
scores: ScoreRowData[];
|
|
29
26
|
}>;
|
|
27
|
+
/**
|
|
28
|
+
* LibSQL-specific score row transformation.
|
|
29
|
+
* Maps additionalLLMContext column to additionalContext field.
|
|
30
|
+
*/
|
|
30
31
|
private transformScoreRow;
|
|
31
32
|
getScoreById({ id }: {
|
|
32
33
|
id: string;
|
|
33
34
|
}): Promise<ScoreRowData | null>;
|
|
34
|
-
saveScore(score:
|
|
35
|
+
saveScore(score: SaveScorePayload): Promise<{
|
|
35
36
|
score: ScoreRowData;
|
|
36
37
|
}>;
|
|
37
|
-
|
|
38
|
+
listScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
38
39
|
pagination: StoragePagination;
|
|
39
40
|
entityId: string;
|
|
40
41
|
entityType: string;
|
|
@@ -42,7 +43,7 @@ export declare class ScoresLibSQL extends ScoresStorage {
|
|
|
42
43
|
pagination: PaginationInfo;
|
|
43
44
|
scores: ScoreRowData[];
|
|
44
45
|
}>;
|
|
45
|
-
|
|
46
|
+
listScoresBySpan({ traceId, spanId, pagination, }: {
|
|
46
47
|
traceId: string;
|
|
47
48
|
spanId: string;
|
|
48
49
|
pagination: StoragePagination;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scores/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scores/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAA6B,MAAM,oBAAoB,CAAC;AACnH,OAAO,EAIL,aAAa,EAId,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEnD,qBAAa,YAAa,SAAQ,aAAa;;gBAIjC,MAAM,EAAE,kBAAkB;IAOhC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAUrB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIpC,iBAAiB,CAAC,EACtB,KAAK,EACL,UAAU,GACX,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAwD7D,oBAAoB,CAAC,EACzB,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,MAAM,EACN,UAAU,GACX,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,aAAa,CAAC;QACvB,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAiFnE;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAMnB,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAQlE,SAAS,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,YAAY,CAAA;KAAE,CAAC;IAiDpE,oBAAoB,CAAC,EACzB,QAAQ,EACR,UAAU,EACV,UAAU,GACX,EAAE;QACD,UAAU,EAAE,iBAAiB,CAAC;QAC9B,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAwD7D,gBAAgB,CAAC,EACrB,OAAO,EACP,MAAM,EACN,UAAU,GACX,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;CA2CpE"}
|
|
@@ -1,44 +1,33 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { WorkflowRun, WorkflowRuns } from '@mastra/core/storage';
|
|
1
|
+
import type { WorkflowRun, WorkflowRuns, StorageListWorkflowRunsInput, UpdateWorkflowStateOptions } from '@mastra/core/storage';
|
|
3
2
|
import { WorkflowsStorage } from '@mastra/core/storage';
|
|
4
3
|
import type { WorkflowRunState, StepResult } from '@mastra/core/workflows';
|
|
5
|
-
import type {
|
|
4
|
+
import type { LibSQLDomainConfig } from '../../db/index.js';
|
|
6
5
|
export declare class WorkflowsLibSQL extends WorkflowsStorage {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
operations: StoreOperationsLibSQL;
|
|
13
|
-
client: Client;
|
|
14
|
-
maxRetries?: number;
|
|
15
|
-
initialBackoffMs?: number;
|
|
16
|
-
});
|
|
6
|
+
#private;
|
|
7
|
+
private readonly executeWithRetry;
|
|
8
|
+
constructor(config: LibSQLDomainConfig);
|
|
9
|
+
init(): Promise<void>;
|
|
10
|
+
dangerouslyClearAll(): Promise<void>;
|
|
17
11
|
private setupPragmaSettings;
|
|
18
|
-
|
|
19
|
-
updateWorkflowResults({ workflowName, runId, stepId, result, runtimeContext, }: {
|
|
12
|
+
updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, }: {
|
|
20
13
|
workflowName: string;
|
|
21
14
|
runId: string;
|
|
22
15
|
stepId: string;
|
|
23
16
|
result: StepResult<any, any, any, any>;
|
|
24
|
-
|
|
17
|
+
requestContext: Record<string, any>;
|
|
25
18
|
}): Promise<Record<string, StepResult<any, any, any, any>>>;
|
|
26
19
|
updateWorkflowState({ workflowName, runId, opts, }: {
|
|
27
20
|
workflowName: string;
|
|
28
21
|
runId: string;
|
|
29
|
-
opts:
|
|
30
|
-
status: string;
|
|
31
|
-
result?: StepResult<any, any, any, any>;
|
|
32
|
-
error?: string;
|
|
33
|
-
suspendedPaths?: Record<string, number[]>;
|
|
34
|
-
waitingPaths?: Record<string, number[]>;
|
|
35
|
-
};
|
|
22
|
+
opts: UpdateWorkflowStateOptions;
|
|
36
23
|
}): Promise<WorkflowRunState | undefined>;
|
|
37
|
-
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, }: {
|
|
24
|
+
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, createdAt, updatedAt, }: {
|
|
38
25
|
workflowName: string;
|
|
39
26
|
runId: string;
|
|
40
27
|
resourceId?: string;
|
|
41
28
|
snapshot: WorkflowRunState;
|
|
29
|
+
createdAt?: Date;
|
|
30
|
+
updatedAt?: Date;
|
|
42
31
|
}): Promise<void>;
|
|
43
32
|
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
44
33
|
workflowName: string;
|
|
@@ -48,13 +37,10 @@ export declare class WorkflowsLibSQL extends WorkflowsStorage {
|
|
|
48
37
|
runId: string;
|
|
49
38
|
workflowName?: string;
|
|
50
39
|
}): Promise<WorkflowRun | null>;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
offset?: number;
|
|
57
|
-
resourceId?: string;
|
|
58
|
-
}): Promise<WorkflowRuns>;
|
|
40
|
+
deleteWorkflowRunById({ runId, workflowName }: {
|
|
41
|
+
runId: string;
|
|
42
|
+
workflowName: string;
|
|
43
|
+
}): Promise<void>;
|
|
44
|
+
listWorkflowRuns({ workflowName, fromDate, toDate, page, perPage, resourceId, status, }?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
|
|
59
45
|
}
|
|
60
46
|
//# sourceMappingURL=index.d.ts.map
|