@mastra/cloudflare-d1 0.12.1-alpha.0 → 0.12.2-alpha.0
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/LICENSE.md +11 -42
- package/dist/_tsup-dts-rollup.d.cts +341 -57
- package/dist/_tsup-dts-rollup.d.ts +341 -57
- package/dist/index.cjs +1377 -693
- package/dist/index.js +1378 -694
- package/package.json +5 -5
package/LICENSE.md
CHANGED
|
@@ -1,46 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Apache License 2.0
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025
|
|
3
|
+
Copyright (c) 2025 Kepler Software, Inc.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
|
|
17
|
-
|
|
18
|
-
**Patents**
|
|
19
|
-
The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
20
|
-
|
|
21
|
-
**Notices**
|
|
22
|
-
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
|
|
23
|
-
|
|
24
|
-
If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
|
|
25
|
-
|
|
26
|
-
**No Other Rights**
|
|
27
|
-
These terms do not imply any licenses other than those expressly granted in these terms.
|
|
28
|
-
|
|
29
|
-
**Termination**
|
|
30
|
-
If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
|
|
31
|
-
|
|
32
|
-
**No Liability**
|
|
33
|
-
As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
|
|
34
|
-
|
|
35
|
-
**Definitions**
|
|
36
|
-
The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
|
|
37
|
-
|
|
38
|
-
_you_ refers to the individual or entity agreeing to these terms.
|
|
39
|
-
|
|
40
|
-
_your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
41
|
-
|
|
42
|
-
_your licenses_ are all the licenses granted to you for the software under these terms.
|
|
43
|
-
|
|
44
|
-
_use_ means anything you do with the software requiring one of your licenses.
|
|
45
|
-
|
|
46
|
-
_trademark_ means trademarks, service marks, and similar rights.
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
import { default as Cloudflare_2 } from 'cloudflare';
|
|
2
2
|
import type { D1Database as D1Database_2 } from '@cloudflare/workers-types';
|
|
3
3
|
import type { EvalRow } from '@mastra/core/storage';
|
|
4
|
+
import { LegacyEvalsStorage } from '@mastra/core/storage';
|
|
4
5
|
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
5
6
|
import type { MastraMessageV1 } from '@mastra/core/memory';
|
|
6
7
|
import type { MastraMessageV2 } from '@mastra/core/memory';
|
|
7
8
|
import { MastraStorage } from '@mastra/core/storage';
|
|
9
|
+
import { MemoryStorage } from '@mastra/core/storage';
|
|
10
|
+
import type { PaginationArgs } from '@mastra/core/storage';
|
|
8
11
|
import type { PaginationInfo } from '@mastra/core/storage';
|
|
12
|
+
import type { ScoreRowData } from '@mastra/core/scores';
|
|
13
|
+
import { ScoresStorage } from '@mastra/core/storage';
|
|
9
14
|
import type { StorageColumn } from '@mastra/core/storage';
|
|
15
|
+
import type { StorageDomains } from '@mastra/core/storage';
|
|
10
16
|
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
17
|
+
import type { StorageGetTracesArg } from '@mastra/core/storage';
|
|
18
|
+
import type { StorageGetTracesPaginatedArg } from '@mastra/core/storage';
|
|
19
|
+
import type { StoragePagination } from '@mastra/core/storage';
|
|
20
|
+
import type { StorageResourceType } from '@mastra/core/storage';
|
|
11
21
|
import type { StorageThreadType } from '@mastra/core/memory';
|
|
22
|
+
import { StoreOperations } from '@mastra/core/storage';
|
|
12
23
|
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
13
24
|
import type { Trace } from '@mastra/core/telemetry';
|
|
25
|
+
import { TracesStorage } from '@mastra/core/storage';
|
|
14
26
|
import type { WorkflowRun } from '@mastra/core/storage';
|
|
15
27
|
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
16
28
|
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
29
|
+
import { WorkflowsStorage } from '@mastra/core/storage';
|
|
17
30
|
|
|
18
31
|
export declare const createSampleTrace: (name: string, scope?: string, attributes?: Record<string, string>) => {
|
|
19
32
|
id: string;
|
|
@@ -45,6 +58,24 @@ declare interface D1Client {
|
|
|
45
58
|
export { D1Client }
|
|
46
59
|
export { D1Client as D1Client_alias_1 }
|
|
47
60
|
|
|
61
|
+
export declare interface D1Client_alias_2 {
|
|
62
|
+
query(args: {
|
|
63
|
+
sql: string;
|
|
64
|
+
params: string[];
|
|
65
|
+
}): Promise<{
|
|
66
|
+
result: D1QueryResult_alias_2;
|
|
67
|
+
}>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export declare interface D1Client_alias_3 {
|
|
71
|
+
query(args: {
|
|
72
|
+
sql: string;
|
|
73
|
+
params: string[];
|
|
74
|
+
}): Promise<{
|
|
75
|
+
result: D1QueryResult_alias_3;
|
|
76
|
+
}>;
|
|
77
|
+
}
|
|
78
|
+
|
|
48
79
|
declare interface D1ClientConfig {
|
|
49
80
|
/** Optional prefix for table names */
|
|
50
81
|
tablePrefix?: string;
|
|
@@ -74,29 +105,26 @@ declare type D1QueryResult = Awaited<ReturnType<Cloudflare_2['d1']['database']['
|
|
|
74
105
|
export { D1QueryResult }
|
|
75
106
|
export { D1QueryResult as D1QueryResult_alias_1 }
|
|
76
107
|
|
|
108
|
+
export declare type D1QueryResult_alias_2 = Awaited<ReturnType<Cloudflare_2['d1']['database']['query']>>['result'];
|
|
109
|
+
|
|
110
|
+
export declare type D1QueryResult_alias_3 = Awaited<ReturnType<Cloudflare_2['d1']['database']['query']>>['result'];
|
|
111
|
+
|
|
77
112
|
declare class D1Store extends MastraStorage {
|
|
78
113
|
private client?;
|
|
79
114
|
private binding?;
|
|
80
115
|
private tablePrefix;
|
|
116
|
+
stores: StorageDomains;
|
|
81
117
|
/**
|
|
82
118
|
* Creates a new D1Store instance
|
|
83
119
|
* @param config Configuration for D1 access (either REST API or Workers Binding API)
|
|
84
120
|
*/
|
|
85
121
|
constructor(config: D1StoreConfig);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
* @param options Query options including SQL, parameters, and whether to return only the first result
|
|
93
|
-
* @returns Query results as an array or a single object if first=true
|
|
94
|
-
*/
|
|
95
|
-
private executeQuery;
|
|
96
|
-
private getTableColumns;
|
|
97
|
-
private serializeValue;
|
|
98
|
-
private deserializeValue;
|
|
99
|
-
protected getSqlType(type: StorageColumn['type']): string;
|
|
122
|
+
get supports(): {
|
|
123
|
+
selectByIncludeResourceScope: boolean;
|
|
124
|
+
resourceWorkingMemory: boolean;
|
|
125
|
+
hasColumn: boolean;
|
|
126
|
+
createTable: boolean;
|
|
127
|
+
};
|
|
100
128
|
createTable({ tableName, schema, }: {
|
|
101
129
|
tableName: TABLE_NAMES;
|
|
102
130
|
schema: Record<string, StorageColumn>;
|
|
@@ -115,7 +143,10 @@ declare class D1Store extends MastraStorage {
|
|
|
115
143
|
clearTable({ tableName }: {
|
|
116
144
|
tableName: TABLE_NAMES;
|
|
117
145
|
}): Promise<void>;
|
|
118
|
-
|
|
146
|
+
dropTable({ tableName }: {
|
|
147
|
+
tableName: TABLE_NAMES;
|
|
148
|
+
}): Promise<void>;
|
|
149
|
+
hasColumn(table: string, column: string): Promise<boolean>;
|
|
119
150
|
insert({ tableName, record }: {
|
|
120
151
|
tableName: TABLE_NAMES;
|
|
121
152
|
record: Record<string, any>;
|
|
@@ -159,7 +190,6 @@ declare class D1Store extends MastraStorage {
|
|
|
159
190
|
messages: MastraMessageV2[];
|
|
160
191
|
format: 'v2';
|
|
161
192
|
}): Promise<MastraMessageV2[]>;
|
|
162
|
-
private _getIncludedMessages;
|
|
163
193
|
/**
|
|
164
194
|
* @deprecated use getMessagesPaginated instead
|
|
165
195
|
*/
|
|
@@ -183,6 +213,18 @@ declare class D1Store extends MastraStorage {
|
|
|
183
213
|
workflowName: string;
|
|
184
214
|
runId: string;
|
|
185
215
|
}): Promise<WorkflowRunState | null>;
|
|
216
|
+
getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
|
|
217
|
+
workflowName?: string;
|
|
218
|
+
fromDate?: Date;
|
|
219
|
+
toDate?: Date;
|
|
220
|
+
limit?: number;
|
|
221
|
+
offset?: number;
|
|
222
|
+
resourceId?: string;
|
|
223
|
+
}): Promise<WorkflowRuns>;
|
|
224
|
+
getWorkflowRunById({ runId, workflowName, }: {
|
|
225
|
+
runId: string;
|
|
226
|
+
workflowName?: string;
|
|
227
|
+
}): Promise<WorkflowRun | null>;
|
|
186
228
|
/**
|
|
187
229
|
* Insert multiple records in a batch operation
|
|
188
230
|
* @param tableName The table to insert into
|
|
@@ -192,16 +234,10 @@ declare class D1Store extends MastraStorage {
|
|
|
192
234
|
tableName: TABLE_NAMES;
|
|
193
235
|
records: Record<string, any>[];
|
|
194
236
|
}): Promise<void>;
|
|
195
|
-
/**
|
|
196
|
-
* Upsert multiple records in a batch operation
|
|
197
|
-
* @param tableName The table to insert into
|
|
198
|
-
* @param records The records to insert
|
|
199
|
-
*/
|
|
200
|
-
private batchUpsert;
|
|
201
237
|
/**
|
|
202
238
|
* @deprecated use getTracesPaginated instead
|
|
203
239
|
*/
|
|
204
|
-
getTraces(
|
|
240
|
+
getTraces(args: {
|
|
205
241
|
name?: string;
|
|
206
242
|
scope?: string;
|
|
207
243
|
page: number;
|
|
@@ -210,50 +246,19 @@ declare class D1Store extends MastraStorage {
|
|
|
210
246
|
fromDate?: Date;
|
|
211
247
|
toDate?: Date;
|
|
212
248
|
}): Promise<Trace[]>;
|
|
213
|
-
getTracesPaginated(args: {
|
|
214
|
-
name?: string;
|
|
215
|
-
scope?: string;
|
|
216
|
-
attributes?: Record<string, string>;
|
|
217
|
-
page: number;
|
|
218
|
-
perPage: number;
|
|
219
|
-
fromDate?: Date;
|
|
220
|
-
toDate?: Date;
|
|
221
|
-
}): Promise<PaginationInfo & {
|
|
249
|
+
getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
|
|
222
250
|
traces: Trace[];
|
|
223
251
|
}>;
|
|
224
252
|
/**
|
|
225
253
|
* @deprecated use getEvals instead
|
|
226
254
|
*/
|
|
227
255
|
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
228
|
-
getEvals(options
|
|
256
|
+
getEvals(options: {
|
|
229
257
|
agentName?: string;
|
|
230
258
|
type?: 'test' | 'live';
|
|
231
|
-
|
|
232
|
-
perPage?: number;
|
|
233
|
-
fromDate?: Date;
|
|
234
|
-
toDate?: Date;
|
|
235
|
-
}): Promise<PaginationInfo & {
|
|
259
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
236
260
|
evals: EvalRow[];
|
|
237
261
|
}>;
|
|
238
|
-
private parseWorkflowRun;
|
|
239
|
-
private hasColumn;
|
|
240
|
-
getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
|
|
241
|
-
workflowName?: string;
|
|
242
|
-
fromDate?: Date;
|
|
243
|
-
toDate?: Date;
|
|
244
|
-
limit?: number;
|
|
245
|
-
offset?: number;
|
|
246
|
-
resourceId?: string;
|
|
247
|
-
}): Promise<WorkflowRuns>;
|
|
248
|
-
getWorkflowRunById({ runId, workflowName, }: {
|
|
249
|
-
runId: string;
|
|
250
|
-
workflowName?: string;
|
|
251
|
-
}): Promise<WorkflowRun | null>;
|
|
252
|
-
/**
|
|
253
|
-
* Close the database connection
|
|
254
|
-
* No explicit cleanup needed for D1 in either REST or Workers Binding mode
|
|
255
|
-
*/
|
|
256
|
-
close(): Promise<void>;
|
|
257
262
|
updateMessages(_args: {
|
|
258
263
|
messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
259
264
|
id: string;
|
|
@@ -263,6 +268,50 @@ declare class D1Store extends MastraStorage {
|
|
|
263
268
|
};
|
|
264
269
|
}[];
|
|
265
270
|
}): Promise<MastraMessageV2[]>;
|
|
271
|
+
getResourceById({ resourceId }: {
|
|
272
|
+
resourceId: string;
|
|
273
|
+
}): Promise<StorageResourceType | null>;
|
|
274
|
+
saveResource({ resource }: {
|
|
275
|
+
resource: StorageResourceType;
|
|
276
|
+
}): Promise<StorageResourceType>;
|
|
277
|
+
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
278
|
+
resourceId: string;
|
|
279
|
+
workingMemory?: string;
|
|
280
|
+
metadata?: Record<string, unknown>;
|
|
281
|
+
}): Promise<StorageResourceType>;
|
|
282
|
+
getScoreById({ id: _id }: {
|
|
283
|
+
id: string;
|
|
284
|
+
}): Promise<ScoreRowData | null>;
|
|
285
|
+
saveScore(_score: ScoreRowData): Promise<{
|
|
286
|
+
score: ScoreRowData;
|
|
287
|
+
}>;
|
|
288
|
+
getScoresByRunId({ runId: _runId, pagination: _pagination, }: {
|
|
289
|
+
runId: string;
|
|
290
|
+
pagination: StoragePagination;
|
|
291
|
+
}): Promise<{
|
|
292
|
+
pagination: PaginationInfo;
|
|
293
|
+
scores: ScoreRowData[];
|
|
294
|
+
}>;
|
|
295
|
+
getScoresByEntityId({ entityId: _entityId, entityType: _entityType, pagination: _pagination, }: {
|
|
296
|
+
pagination: StoragePagination;
|
|
297
|
+
entityId: string;
|
|
298
|
+
entityType: string;
|
|
299
|
+
}): Promise<{
|
|
300
|
+
pagination: PaginationInfo;
|
|
301
|
+
scores: ScoreRowData[];
|
|
302
|
+
}>;
|
|
303
|
+
getScoresByScorerId({ scorerId: _scorerId, pagination: _pagination, }: {
|
|
304
|
+
scorerId: string;
|
|
305
|
+
pagination: StoragePagination;
|
|
306
|
+
}): Promise<{
|
|
307
|
+
pagination: PaginationInfo;
|
|
308
|
+
scores: ScoreRowData[];
|
|
309
|
+
}>;
|
|
310
|
+
/**
|
|
311
|
+
* Close the database connection
|
|
312
|
+
* No explicit cleanup needed for D1 in either REST or Workers Binding mode
|
|
313
|
+
*/
|
|
314
|
+
close(): Promise<void>;
|
|
266
315
|
}
|
|
267
316
|
export { D1Store }
|
|
268
317
|
export { D1Store as D1Store_alias_1 }
|
|
@@ -286,6 +335,104 @@ declare interface D1WorkersConfig {
|
|
|
286
335
|
export { D1WorkersConfig }
|
|
287
336
|
export { D1WorkersConfig as D1WorkersConfig_alias_1 }
|
|
288
337
|
|
|
338
|
+
export declare function deserializeValue(value: any, type?: string): any;
|
|
339
|
+
|
|
340
|
+
export declare function isArrayOfRecords(value: any): value is Record<string, any>[];
|
|
341
|
+
|
|
342
|
+
export declare class LegacyEvalsStorageD1 extends LegacyEvalsStorage {
|
|
343
|
+
private operations;
|
|
344
|
+
constructor({ operations }: {
|
|
345
|
+
operations: StoreOperationsD1;
|
|
346
|
+
});
|
|
347
|
+
getEvals(options: {
|
|
348
|
+
agentName?: string;
|
|
349
|
+
type?: 'test' | 'live';
|
|
350
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
351
|
+
evals: EvalRow[];
|
|
352
|
+
}>;
|
|
353
|
+
/**
|
|
354
|
+
* @deprecated use getEvals instead
|
|
355
|
+
*/
|
|
356
|
+
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export declare class MemoryStorageD1 extends MemoryStorage {
|
|
360
|
+
private operations;
|
|
361
|
+
constructor({ operations }: {
|
|
362
|
+
operations: StoreOperationsD1;
|
|
363
|
+
});
|
|
364
|
+
getResourceById({ resourceId }: {
|
|
365
|
+
resourceId: string;
|
|
366
|
+
}): Promise<StorageResourceType | null>;
|
|
367
|
+
saveResource({ resource }: {
|
|
368
|
+
resource: StorageResourceType;
|
|
369
|
+
}): Promise<StorageResourceType>;
|
|
370
|
+
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
371
|
+
resourceId: string;
|
|
372
|
+
workingMemory?: string;
|
|
373
|
+
metadata?: Record<string, unknown>;
|
|
374
|
+
}): Promise<StorageResourceType>;
|
|
375
|
+
getThreadById({ threadId }: {
|
|
376
|
+
threadId: string;
|
|
377
|
+
}): Promise<StorageThreadType | null>;
|
|
378
|
+
/**
|
|
379
|
+
* @deprecated use getThreadsByResourceIdPaginated instead
|
|
380
|
+
*/
|
|
381
|
+
getThreadsByResourceId({ resourceId }: {
|
|
382
|
+
resourceId: string;
|
|
383
|
+
}): Promise<StorageThreadType[]>;
|
|
384
|
+
getThreadsByResourceIdPaginated(args: {
|
|
385
|
+
resourceId: string;
|
|
386
|
+
page: number;
|
|
387
|
+
perPage: number;
|
|
388
|
+
}): Promise<PaginationInfo & {
|
|
389
|
+
threads: StorageThreadType[];
|
|
390
|
+
}>;
|
|
391
|
+
saveThread({ thread }: {
|
|
392
|
+
thread: StorageThreadType;
|
|
393
|
+
}): Promise<StorageThreadType>;
|
|
394
|
+
updateThread({ id, title, metadata, }: {
|
|
395
|
+
id: string;
|
|
396
|
+
title: string;
|
|
397
|
+
metadata: Record<string, unknown>;
|
|
398
|
+
}): Promise<StorageThreadType>;
|
|
399
|
+
deleteThread({ threadId }: {
|
|
400
|
+
threadId: string;
|
|
401
|
+
}): Promise<void>;
|
|
402
|
+
saveMessages(args: {
|
|
403
|
+
messages: MastraMessageV1[];
|
|
404
|
+
format?: undefined | 'v1';
|
|
405
|
+
}): Promise<MastraMessageV1[]>;
|
|
406
|
+
saveMessages(args: {
|
|
407
|
+
messages: MastraMessageV2[];
|
|
408
|
+
format: 'v2';
|
|
409
|
+
}): Promise<MastraMessageV2[]>;
|
|
410
|
+
private _getIncludedMessages;
|
|
411
|
+
/**
|
|
412
|
+
* @deprecated use getMessagesPaginated instead
|
|
413
|
+
*/
|
|
414
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
415
|
+
format?: 'v1';
|
|
416
|
+
}): Promise<MastraMessageV1[]>;
|
|
417
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
418
|
+
format: 'v2';
|
|
419
|
+
}): Promise<MastraMessageV2[]>;
|
|
420
|
+
getMessagesPaginated({ threadId, selectBy, format, }: StorageGetMessagesArg & {
|
|
421
|
+
format?: 'v1' | 'v2';
|
|
422
|
+
}): Promise<PaginationInfo & {
|
|
423
|
+
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
424
|
+
}>;
|
|
425
|
+
updateMessages(args: {
|
|
426
|
+
messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
427
|
+
id: string;
|
|
428
|
+
content?: {
|
|
429
|
+
metadata?: MastraMessageContentV2['metadata'];
|
|
430
|
+
content?: MastraMessageContentV2['content'];
|
|
431
|
+
};
|
|
432
|
+
}[];
|
|
433
|
+
}): Promise<MastraMessageV2[]>;
|
|
434
|
+
}
|
|
435
|
+
|
|
289
436
|
/**
|
|
290
437
|
* Parses and returns a valid SQL SELECT column identifier.
|
|
291
438
|
* Allows a single identifier (letters, numbers, underscores), or '*', optionally with 'AS alias'.
|
|
@@ -305,6 +452,41 @@ export declare function parseSelectIdentifier(column: string): SelectIdentifier;
|
|
|
305
452
|
export declare const retryUntil: <T>(fn: () => Promise<T>, condition: (result: T) => boolean, timeout?: number, // REST API needs longer timeout due to higher latency
|
|
306
453
|
interval?: number) => Promise<T>;
|
|
307
454
|
|
|
455
|
+
export declare class ScoresStorageD1 extends ScoresStorage {
|
|
456
|
+
private operations;
|
|
457
|
+
constructor({ operations }: {
|
|
458
|
+
operations: StoreOperationsD1;
|
|
459
|
+
});
|
|
460
|
+
getScoreById({ id }: {
|
|
461
|
+
id: string;
|
|
462
|
+
}): Promise<ScoreRowData | null>;
|
|
463
|
+
saveScore(score: Omit<ScoreRowData, 'createdAt' | 'updatedAt'>): Promise<{
|
|
464
|
+
score: ScoreRowData;
|
|
465
|
+
}>;
|
|
466
|
+
getScoresByScorerId({ scorerId, pagination, }: {
|
|
467
|
+
scorerId: string;
|
|
468
|
+
pagination: StoragePagination;
|
|
469
|
+
}): Promise<{
|
|
470
|
+
pagination: PaginationInfo;
|
|
471
|
+
scores: ScoreRowData[];
|
|
472
|
+
}>;
|
|
473
|
+
getScoresByRunId({ runId, pagination, }: {
|
|
474
|
+
runId: string;
|
|
475
|
+
pagination: StoragePagination;
|
|
476
|
+
}): Promise<{
|
|
477
|
+
pagination: PaginationInfo;
|
|
478
|
+
scores: ScoreRowData[];
|
|
479
|
+
}>;
|
|
480
|
+
getScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
481
|
+
pagination: StoragePagination;
|
|
482
|
+
entityId: string;
|
|
483
|
+
entityType: string;
|
|
484
|
+
}): Promise<{
|
|
485
|
+
pagination: PaginationInfo;
|
|
486
|
+
scores: ScoreRowData[];
|
|
487
|
+
}>;
|
|
488
|
+
}
|
|
489
|
+
|
|
308
490
|
/** Represents a validated SQL SELECT column identifier (or '*', optionally with 'AS alias'). */
|
|
309
491
|
declare type SelectIdentifier = string & {
|
|
310
492
|
__brand: 'SelectIdentifier';
|
|
@@ -419,4 +601,106 @@ export declare interface SqlQueryOptions {
|
|
|
419
601
|
first?: boolean;
|
|
420
602
|
}
|
|
421
603
|
|
|
604
|
+
export declare class StoreOperationsD1 extends StoreOperations {
|
|
605
|
+
private client?;
|
|
606
|
+
private binding?;
|
|
607
|
+
private tablePrefix;
|
|
608
|
+
constructor(config: StoreOperationsD1Config);
|
|
609
|
+
hasColumn(table: string, column: string): Promise<boolean>;
|
|
610
|
+
getTableName(tableName: TABLE_NAMES): string;
|
|
611
|
+
private formatSqlParams;
|
|
612
|
+
private executeWorkersBindingQuery;
|
|
613
|
+
private executeRestQuery;
|
|
614
|
+
executeQuery(options: SqlQueryOptions): Promise<Record<string, any>[] | Record<string, any> | null>;
|
|
615
|
+
private getTableColumns;
|
|
616
|
+
private serializeValue;
|
|
617
|
+
protected getSqlType(type: StorageColumn['type']): string;
|
|
618
|
+
createTable({ tableName, schema, }: {
|
|
619
|
+
tableName: TABLE_NAMES;
|
|
620
|
+
schema: Record<string, StorageColumn>;
|
|
621
|
+
}): Promise<void>;
|
|
622
|
+
clearTable({ tableName }: {
|
|
623
|
+
tableName: TABLE_NAMES;
|
|
624
|
+
}): Promise<void>;
|
|
625
|
+
dropTable({ tableName }: {
|
|
626
|
+
tableName: TABLE_NAMES;
|
|
627
|
+
}): Promise<void>;
|
|
628
|
+
alterTable(args: {
|
|
629
|
+
tableName: TABLE_NAMES;
|
|
630
|
+
schema: Record<string, StorageColumn>;
|
|
631
|
+
ifNotExists: string[];
|
|
632
|
+
}): Promise<void>;
|
|
633
|
+
insert({ tableName, record }: {
|
|
634
|
+
tableName: TABLE_NAMES;
|
|
635
|
+
record: Record<string, any>;
|
|
636
|
+
}): Promise<void>;
|
|
637
|
+
batchInsert({ tableName, records }: {
|
|
638
|
+
tableName: TABLE_NAMES;
|
|
639
|
+
records: Record<string, any>[];
|
|
640
|
+
}): Promise<void>;
|
|
641
|
+
load<R>({ tableName, keys }: {
|
|
642
|
+
tableName: TABLE_NAMES;
|
|
643
|
+
keys: Record<string, string>;
|
|
644
|
+
}): Promise<R | null>;
|
|
645
|
+
processRecord(record: Record<string, any>): Promise<Record<string, any>>;
|
|
646
|
+
/**
|
|
647
|
+
* Upsert multiple records in a batch operation
|
|
648
|
+
* @param tableName The table to insert into
|
|
649
|
+
* @param records The records to insert
|
|
650
|
+
*/
|
|
651
|
+
batchUpsert({ tableName, records }: {
|
|
652
|
+
tableName: TABLE_NAMES;
|
|
653
|
+
records: Record<string, any>[];
|
|
654
|
+
}): Promise<void>;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
export declare interface StoreOperationsD1Config {
|
|
658
|
+
client?: D1Client_alias_2;
|
|
659
|
+
binding?: D1Database_2;
|
|
660
|
+
tablePrefix?: string;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
export declare class TracesStorageD1 extends TracesStorage {
|
|
664
|
+
private operations;
|
|
665
|
+
constructor({ operations }: {
|
|
666
|
+
operations: StoreOperationsD1;
|
|
667
|
+
});
|
|
668
|
+
getTraces(args: StorageGetTracesArg): Promise<Trace[]>;
|
|
669
|
+
getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
|
|
670
|
+
traces: Trace[];
|
|
671
|
+
}>;
|
|
672
|
+
batchTraceInsert({ records }: {
|
|
673
|
+
records: Record<string, any>[];
|
|
674
|
+
}): Promise<void>;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
export declare class WorkflowsStorageD1 extends WorkflowsStorage {
|
|
678
|
+
private operations;
|
|
679
|
+
constructor({ operations }: {
|
|
680
|
+
operations: StoreOperationsD1;
|
|
681
|
+
});
|
|
682
|
+
persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
|
|
683
|
+
workflowName: string;
|
|
684
|
+
runId: string;
|
|
685
|
+
snapshot: WorkflowRunState;
|
|
686
|
+
}): Promise<void>;
|
|
687
|
+
loadWorkflowSnapshot(params: {
|
|
688
|
+
workflowName: string;
|
|
689
|
+
runId: string;
|
|
690
|
+
}): Promise<WorkflowRunState | null>;
|
|
691
|
+
private parseWorkflowRun;
|
|
692
|
+
getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
|
|
693
|
+
workflowName?: string;
|
|
694
|
+
fromDate?: Date;
|
|
695
|
+
toDate?: Date;
|
|
696
|
+
limit?: number;
|
|
697
|
+
offset?: number;
|
|
698
|
+
resourceId?: string;
|
|
699
|
+
}): Promise<WorkflowRuns>;
|
|
700
|
+
getWorkflowRunById({ runId, workflowName, }: {
|
|
701
|
+
runId: string;
|
|
702
|
+
workflowName?: string;
|
|
703
|
+
}): Promise<WorkflowRun | null>;
|
|
704
|
+
}
|
|
705
|
+
|
|
422
706
|
export { }
|