@mastra/cloudflare-d1 0.0.0-switch-to-core-20250424015131 → 0.0.0-tool-call-parts-20250630193309
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/dist/_tsup-dts-rollup.d.cts +129 -43
- package/dist/_tsup-dts-rollup.d.ts +129 -43
- package/dist/index.cjs +897 -219
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +881 -203
- package/package.json +17 -13
|
@@ -1,38 +1,18 @@
|
|
|
1
1
|
import type { D1Database as D1Database_2 } from '@cloudflare/workers-types';
|
|
2
2
|
import type { EvalRow } from '@mastra/core/storage';
|
|
3
|
+
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
4
|
+
import type { MastraMessageV1 } from '@mastra/core/memory';
|
|
5
|
+
import type { MastraMessageV2 } from '@mastra/core/memory';
|
|
3
6
|
import { MastraStorage } from '@mastra/core/storage';
|
|
4
|
-
import type {
|
|
7
|
+
import type { PaginationInfo } from '@mastra/core/storage';
|
|
5
8
|
import type { StorageColumn } from '@mastra/core/storage';
|
|
6
9
|
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
7
10
|
import type { StorageThreadType } from '@mastra/core/memory';
|
|
8
11
|
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
12
|
+
import type { Trace } from '@mastra/core/telemetry';
|
|
13
|
+
import type { WorkflowRun } from '@mastra/core/storage';
|
|
9
14
|
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
10
15
|
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
11
|
-
import type { WorkflowRunState as WorkflowRunState_2 } from '@mastra/core';
|
|
12
|
-
|
|
13
|
-
export declare const createSampleMessage: (threadId: string) => any;
|
|
14
|
-
|
|
15
|
-
export declare const createSampleThread: () => {
|
|
16
|
-
id: string;
|
|
17
|
-
resourceId: string;
|
|
18
|
-
title: string;
|
|
19
|
-
createdAt: Date;
|
|
20
|
-
updatedAt: Date;
|
|
21
|
-
metadata: {
|
|
22
|
-
key: string;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export declare const createSampleThreadWithParams: (threadId: string, resourceId: string, createdAt: Date, updatedAt: Date) => {
|
|
27
|
-
id: string;
|
|
28
|
-
resourceId: string;
|
|
29
|
-
title: string;
|
|
30
|
-
createdAt: Date;
|
|
31
|
-
updatedAt: Date;
|
|
32
|
-
metadata: {
|
|
33
|
-
key: string;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
16
|
|
|
37
17
|
export declare const createSampleTrace: (name: string, scope?: string, attributes?: Record<string, string>) => {
|
|
38
18
|
id: string;
|
|
@@ -51,8 +31,6 @@ export declare const createSampleTrace: (name: string, scope?: string, attribute
|
|
|
51
31
|
createdAt: string;
|
|
52
32
|
};
|
|
53
33
|
|
|
54
|
-
export declare const createSampleWorkflowSnapshot: (threadId: string) => WorkflowRunState_2;
|
|
55
|
-
|
|
56
34
|
export declare function createSqlBuilder(): SqlBuilder;
|
|
57
35
|
|
|
58
36
|
/**
|
|
@@ -84,7 +62,6 @@ declare class D1Store extends MastraStorage {
|
|
|
84
62
|
constructor(config: D1StoreConfig);
|
|
85
63
|
private getTableName;
|
|
86
64
|
private formatSqlParams;
|
|
87
|
-
private createIndexIfNotExists;
|
|
88
65
|
private executeWorkersBindingQuery;
|
|
89
66
|
private executeRestQuery;
|
|
90
67
|
/**
|
|
@@ -93,15 +70,25 @@ declare class D1Store extends MastraStorage {
|
|
|
93
70
|
* @returns Query results as an array or a single object if first=true
|
|
94
71
|
*/
|
|
95
72
|
private executeQuery;
|
|
96
|
-
private
|
|
97
|
-
private ensureDate;
|
|
98
|
-
private serializeDate;
|
|
73
|
+
private getTableColumns;
|
|
99
74
|
private serializeValue;
|
|
100
75
|
private deserializeValue;
|
|
76
|
+
protected getSqlType(type: StorageColumn['type']): string;
|
|
101
77
|
createTable({ tableName, schema, }: {
|
|
102
78
|
tableName: TABLE_NAMES;
|
|
103
79
|
schema: Record<string, StorageColumn>;
|
|
104
80
|
}): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Alters table schema to add columns if they don't exist
|
|
83
|
+
* @param tableName Name of the table
|
|
84
|
+
* @param schema Schema of the table
|
|
85
|
+
* @param ifNotExists Array of column names to add if they don't exist
|
|
86
|
+
*/
|
|
87
|
+
alterTable({ tableName, schema, ifNotExists, }: {
|
|
88
|
+
tableName: TABLE_NAMES;
|
|
89
|
+
schema: Record<string, StorageColumn>;
|
|
90
|
+
ifNotExists: string[];
|
|
91
|
+
}): Promise<void>;
|
|
105
92
|
clearTable({ tableName }: {
|
|
106
93
|
tableName: TABLE_NAMES;
|
|
107
94
|
}): Promise<void>;
|
|
@@ -117,9 +104,19 @@ declare class D1Store extends MastraStorage {
|
|
|
117
104
|
getThreadById({ threadId }: {
|
|
118
105
|
threadId: string;
|
|
119
106
|
}): Promise<StorageThreadType | null>;
|
|
107
|
+
/**
|
|
108
|
+
* @deprecated use getThreadsByResourceIdPaginated instead
|
|
109
|
+
*/
|
|
120
110
|
getThreadsByResourceId({ resourceId }: {
|
|
121
111
|
resourceId: string;
|
|
122
112
|
}): Promise<StorageThreadType[]>;
|
|
113
|
+
getThreadsByResourceIdPaginated(args: {
|
|
114
|
+
resourceId: string;
|
|
115
|
+
page: number;
|
|
116
|
+
perPage: number;
|
|
117
|
+
}): Promise<PaginationInfo & {
|
|
118
|
+
threads: StorageThreadType[];
|
|
119
|
+
}>;
|
|
123
120
|
saveThread({ thread }: {
|
|
124
121
|
thread: StorageThreadType;
|
|
125
122
|
}): Promise<StorageThreadType>;
|
|
@@ -131,10 +128,29 @@ declare class D1Store extends MastraStorage {
|
|
|
131
128
|
deleteThread({ threadId }: {
|
|
132
129
|
threadId: string;
|
|
133
130
|
}): Promise<void>;
|
|
134
|
-
saveMessages(
|
|
135
|
-
messages:
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
saveMessages(args: {
|
|
132
|
+
messages: MastraMessageV1[];
|
|
133
|
+
format?: undefined | 'v1';
|
|
134
|
+
}): Promise<MastraMessageV1[]>;
|
|
135
|
+
saveMessages(args: {
|
|
136
|
+
messages: MastraMessageV2[];
|
|
137
|
+
format: 'v2';
|
|
138
|
+
}): Promise<MastraMessageV2[]>;
|
|
139
|
+
private _getIncludedMessages;
|
|
140
|
+
/**
|
|
141
|
+
* @deprecated use getMessagesPaginated instead
|
|
142
|
+
*/
|
|
143
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
144
|
+
format?: 'v1';
|
|
145
|
+
}): Promise<MastraMessageV1[]>;
|
|
146
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
147
|
+
format: 'v2';
|
|
148
|
+
}): Promise<MastraMessageV2[]>;
|
|
149
|
+
getMessagesPaginated({ threadId, selectBy, format, }: StorageGetMessagesArg & {
|
|
150
|
+
format?: 'v1' | 'v2';
|
|
151
|
+
}): Promise<PaginationInfo & {
|
|
152
|
+
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
153
|
+
}>;
|
|
138
154
|
persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
|
|
139
155
|
workflowName: string;
|
|
140
156
|
runId: string;
|
|
@@ -153,26 +169,77 @@ declare class D1Store extends MastraStorage {
|
|
|
153
169
|
tableName: TABLE_NAMES;
|
|
154
170
|
records: Record<string, any>[];
|
|
155
171
|
}): Promise<void>;
|
|
156
|
-
|
|
172
|
+
/**
|
|
173
|
+
* Upsert multiple records in a batch operation
|
|
174
|
+
* @param tableName The table to insert into
|
|
175
|
+
* @param records The records to insert
|
|
176
|
+
*/
|
|
177
|
+
private batchUpsert;
|
|
178
|
+
/**
|
|
179
|
+
* @deprecated use getTracesPaginated instead
|
|
180
|
+
*/
|
|
181
|
+
getTraces({ name, scope, page, perPage, attributes, fromDate, toDate, }: {
|
|
157
182
|
name?: string;
|
|
158
183
|
scope?: string;
|
|
159
184
|
page: number;
|
|
160
185
|
perPage: number;
|
|
161
186
|
attributes?: Record<string, string>;
|
|
162
|
-
|
|
187
|
+
fromDate?: Date;
|
|
188
|
+
toDate?: Date;
|
|
189
|
+
}): Promise<Trace[]>;
|
|
190
|
+
getTracesPaginated(args: {
|
|
191
|
+
name?: string;
|
|
192
|
+
scope?: string;
|
|
193
|
+
attributes?: Record<string, string>;
|
|
194
|
+
page: number;
|
|
195
|
+
perPage: number;
|
|
196
|
+
fromDate?: Date;
|
|
197
|
+
toDate?: Date;
|
|
198
|
+
}): Promise<PaginationInfo & {
|
|
199
|
+
traces: Trace[];
|
|
200
|
+
}>;
|
|
201
|
+
/**
|
|
202
|
+
* @deprecated use getEvals instead
|
|
203
|
+
*/
|
|
163
204
|
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
164
|
-
|
|
205
|
+
getEvals(options?: {
|
|
206
|
+
agentName?: string;
|
|
207
|
+
type?: 'test' | 'live';
|
|
208
|
+
page?: number;
|
|
209
|
+
perPage?: number;
|
|
210
|
+
fromDate?: Date;
|
|
211
|
+
toDate?: Date;
|
|
212
|
+
}): Promise<PaginationInfo & {
|
|
213
|
+
evals: EvalRow[];
|
|
214
|
+
}>;
|
|
215
|
+
private parseWorkflowRun;
|
|
216
|
+
private hasColumn;
|
|
217
|
+
getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
|
|
165
218
|
workflowName?: string;
|
|
166
219
|
fromDate?: Date;
|
|
167
220
|
toDate?: Date;
|
|
168
221
|
limit?: number;
|
|
169
222
|
offset?: number;
|
|
223
|
+
resourceId?: string;
|
|
170
224
|
}): Promise<WorkflowRuns>;
|
|
225
|
+
getWorkflowRunById({ runId, workflowName, }: {
|
|
226
|
+
runId: string;
|
|
227
|
+
workflowName?: string;
|
|
228
|
+
}): Promise<WorkflowRun | null>;
|
|
171
229
|
/**
|
|
172
230
|
* Close the database connection
|
|
173
231
|
* No explicit cleanup needed for D1 in either REST or Workers Binding mode
|
|
174
232
|
*/
|
|
175
233
|
close(): Promise<void>;
|
|
234
|
+
updateMessages(_args: {
|
|
235
|
+
messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
236
|
+
id: string;
|
|
237
|
+
content?: {
|
|
238
|
+
metadata?: MastraMessageContentV2['metadata'];
|
|
239
|
+
content?: MastraMessageContentV2['content'];
|
|
240
|
+
};
|
|
241
|
+
}[];
|
|
242
|
+
}): Promise<MastraMessageV2[]>;
|
|
176
243
|
}
|
|
177
244
|
export { D1Store }
|
|
178
245
|
export { D1Store as D1Store_alias_1 }
|
|
@@ -196,9 +263,30 @@ declare interface D1WorkersConfig {
|
|
|
196
263
|
export { D1WorkersConfig }
|
|
197
264
|
export { D1WorkersConfig as D1WorkersConfig_alias_1 }
|
|
198
265
|
|
|
266
|
+
/**
|
|
267
|
+
* Parses and returns a valid SQL SELECT column identifier.
|
|
268
|
+
* Allows a single identifier (letters, numbers, underscores), or '*', optionally with 'AS alias'.
|
|
269
|
+
*
|
|
270
|
+
* @param column - The column identifier string to parse.
|
|
271
|
+
* @returns The validated column identifier as a branded type.
|
|
272
|
+
* @throws {Error} If invalid.
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* const col = parseSelectIdentifier('user_id'); // Ok
|
|
276
|
+
* parseSelectIdentifier('user_id AS uid'); // Ok
|
|
277
|
+
* parseSelectIdentifier('*'); // Ok
|
|
278
|
+
* parseSelectIdentifier('user id'); // Throws error
|
|
279
|
+
*/
|
|
280
|
+
export declare function parseSelectIdentifier(column: string): SelectIdentifier;
|
|
281
|
+
|
|
199
282
|
export declare const retryUntil: <T>(fn: () => Promise<T>, condition: (result: T) => boolean, timeout?: number, // REST API needs longer timeout due to higher latency
|
|
200
283
|
interval?: number) => Promise<T>;
|
|
201
284
|
|
|
285
|
+
/** Represents a validated SQL SELECT column identifier (or '*', optionally with 'AS alias'). */
|
|
286
|
+
declare type SelectIdentifier = string & {
|
|
287
|
+
__brand: 'SelectIdentifier';
|
|
288
|
+
};
|
|
289
|
+
|
|
202
290
|
/**
|
|
203
291
|
* SQL Builder class for constructing type-safe SQL queries
|
|
204
292
|
* This helps create maintainable and secure SQL queries with proper parameter handling
|
|
@@ -226,6 +314,7 @@ export declare class SqlBuilder {
|
|
|
226
314
|
orderBy(column: string, direction?: 'ASC' | 'DESC'): SqlBuilder;
|
|
227
315
|
limit(count: number): SqlBuilder;
|
|
228
316
|
offset(count: number): SqlBuilder;
|
|
317
|
+
count(): SqlBuilder;
|
|
229
318
|
/**
|
|
230
319
|
* Insert a row, or update specific columns on conflict (upsert).
|
|
231
320
|
* @param table Table name
|
|
@@ -261,7 +350,6 @@ export declare class SqlBuilder {
|
|
|
261
350
|
* @returns The builder instance
|
|
262
351
|
*/
|
|
263
352
|
createIndex(indexName: string, tableName: string, columnName: string, indexType?: string): SqlBuilder;
|
|
264
|
-
raw(sql: string, ...params: SqlParam[]): SqlBuilder;
|
|
265
353
|
/**
|
|
266
354
|
* Add a LIKE condition to the query
|
|
267
355
|
* @param column The column to check
|
|
@@ -299,7 +387,7 @@ export declare type SqlParam = string | number | boolean | null | undefined;
|
|
|
299
387
|
/**
|
|
300
388
|
* Interface for SQL query options with generic type support
|
|
301
389
|
*/
|
|
302
|
-
declare interface SqlQueryOptions {
|
|
390
|
+
export declare interface SqlQueryOptions {
|
|
303
391
|
/** SQL query to execute */
|
|
304
392
|
sql: string;
|
|
305
393
|
/** Parameters to bind to the query */
|
|
@@ -307,7 +395,5 @@ declare interface SqlQueryOptions {
|
|
|
307
395
|
/** Whether to return only the first result */
|
|
308
396
|
first?: boolean;
|
|
309
397
|
}
|
|
310
|
-
export { SqlQueryOptions }
|
|
311
|
-
export { SqlQueryOptions as SqlQueryOptions_alias_1 }
|
|
312
398
|
|
|
313
399
|
export { }
|
|
@@ -1,38 +1,18 @@
|
|
|
1
1
|
import type { D1Database as D1Database_2 } from '@cloudflare/workers-types';
|
|
2
2
|
import type { EvalRow } from '@mastra/core/storage';
|
|
3
|
+
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
4
|
+
import type { MastraMessageV1 } from '@mastra/core/memory';
|
|
5
|
+
import type { MastraMessageV2 } from '@mastra/core/memory';
|
|
3
6
|
import { MastraStorage } from '@mastra/core/storage';
|
|
4
|
-
import type {
|
|
7
|
+
import type { PaginationInfo } from '@mastra/core/storage';
|
|
5
8
|
import type { StorageColumn } from '@mastra/core/storage';
|
|
6
9
|
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
7
10
|
import type { StorageThreadType } from '@mastra/core/memory';
|
|
8
11
|
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
12
|
+
import type { Trace } from '@mastra/core/telemetry';
|
|
13
|
+
import type { WorkflowRun } from '@mastra/core/storage';
|
|
9
14
|
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
10
15
|
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
11
|
-
import type { WorkflowRunState as WorkflowRunState_2 } from '@mastra/core';
|
|
12
|
-
|
|
13
|
-
export declare const createSampleMessage: (threadId: string) => any;
|
|
14
|
-
|
|
15
|
-
export declare const createSampleThread: () => {
|
|
16
|
-
id: string;
|
|
17
|
-
resourceId: string;
|
|
18
|
-
title: string;
|
|
19
|
-
createdAt: Date;
|
|
20
|
-
updatedAt: Date;
|
|
21
|
-
metadata: {
|
|
22
|
-
key: string;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export declare const createSampleThreadWithParams: (threadId: string, resourceId: string, createdAt: Date, updatedAt: Date) => {
|
|
27
|
-
id: string;
|
|
28
|
-
resourceId: string;
|
|
29
|
-
title: string;
|
|
30
|
-
createdAt: Date;
|
|
31
|
-
updatedAt: Date;
|
|
32
|
-
metadata: {
|
|
33
|
-
key: string;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
16
|
|
|
37
17
|
export declare const createSampleTrace: (name: string, scope?: string, attributes?: Record<string, string>) => {
|
|
38
18
|
id: string;
|
|
@@ -51,8 +31,6 @@ export declare const createSampleTrace: (name: string, scope?: string, attribute
|
|
|
51
31
|
createdAt: string;
|
|
52
32
|
};
|
|
53
33
|
|
|
54
|
-
export declare const createSampleWorkflowSnapshot: (threadId: string) => WorkflowRunState_2;
|
|
55
|
-
|
|
56
34
|
export declare function createSqlBuilder(): SqlBuilder;
|
|
57
35
|
|
|
58
36
|
/**
|
|
@@ -84,7 +62,6 @@ declare class D1Store extends MastraStorage {
|
|
|
84
62
|
constructor(config: D1StoreConfig);
|
|
85
63
|
private getTableName;
|
|
86
64
|
private formatSqlParams;
|
|
87
|
-
private createIndexIfNotExists;
|
|
88
65
|
private executeWorkersBindingQuery;
|
|
89
66
|
private executeRestQuery;
|
|
90
67
|
/**
|
|
@@ -93,15 +70,25 @@ declare class D1Store extends MastraStorage {
|
|
|
93
70
|
* @returns Query results as an array or a single object if first=true
|
|
94
71
|
*/
|
|
95
72
|
private executeQuery;
|
|
96
|
-
private
|
|
97
|
-
private ensureDate;
|
|
98
|
-
private serializeDate;
|
|
73
|
+
private getTableColumns;
|
|
99
74
|
private serializeValue;
|
|
100
75
|
private deserializeValue;
|
|
76
|
+
protected getSqlType(type: StorageColumn['type']): string;
|
|
101
77
|
createTable({ tableName, schema, }: {
|
|
102
78
|
tableName: TABLE_NAMES;
|
|
103
79
|
schema: Record<string, StorageColumn>;
|
|
104
80
|
}): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Alters table schema to add columns if they don't exist
|
|
83
|
+
* @param tableName Name of the table
|
|
84
|
+
* @param schema Schema of the table
|
|
85
|
+
* @param ifNotExists Array of column names to add if they don't exist
|
|
86
|
+
*/
|
|
87
|
+
alterTable({ tableName, schema, ifNotExists, }: {
|
|
88
|
+
tableName: TABLE_NAMES;
|
|
89
|
+
schema: Record<string, StorageColumn>;
|
|
90
|
+
ifNotExists: string[];
|
|
91
|
+
}): Promise<void>;
|
|
105
92
|
clearTable({ tableName }: {
|
|
106
93
|
tableName: TABLE_NAMES;
|
|
107
94
|
}): Promise<void>;
|
|
@@ -117,9 +104,19 @@ declare class D1Store extends MastraStorage {
|
|
|
117
104
|
getThreadById({ threadId }: {
|
|
118
105
|
threadId: string;
|
|
119
106
|
}): Promise<StorageThreadType | null>;
|
|
107
|
+
/**
|
|
108
|
+
* @deprecated use getThreadsByResourceIdPaginated instead
|
|
109
|
+
*/
|
|
120
110
|
getThreadsByResourceId({ resourceId }: {
|
|
121
111
|
resourceId: string;
|
|
122
112
|
}): Promise<StorageThreadType[]>;
|
|
113
|
+
getThreadsByResourceIdPaginated(args: {
|
|
114
|
+
resourceId: string;
|
|
115
|
+
page: number;
|
|
116
|
+
perPage: number;
|
|
117
|
+
}): Promise<PaginationInfo & {
|
|
118
|
+
threads: StorageThreadType[];
|
|
119
|
+
}>;
|
|
123
120
|
saveThread({ thread }: {
|
|
124
121
|
thread: StorageThreadType;
|
|
125
122
|
}): Promise<StorageThreadType>;
|
|
@@ -131,10 +128,29 @@ declare class D1Store extends MastraStorage {
|
|
|
131
128
|
deleteThread({ threadId }: {
|
|
132
129
|
threadId: string;
|
|
133
130
|
}): Promise<void>;
|
|
134
|
-
saveMessages(
|
|
135
|
-
messages:
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
saveMessages(args: {
|
|
132
|
+
messages: MastraMessageV1[];
|
|
133
|
+
format?: undefined | 'v1';
|
|
134
|
+
}): Promise<MastraMessageV1[]>;
|
|
135
|
+
saveMessages(args: {
|
|
136
|
+
messages: MastraMessageV2[];
|
|
137
|
+
format: 'v2';
|
|
138
|
+
}): Promise<MastraMessageV2[]>;
|
|
139
|
+
private _getIncludedMessages;
|
|
140
|
+
/**
|
|
141
|
+
* @deprecated use getMessagesPaginated instead
|
|
142
|
+
*/
|
|
143
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
144
|
+
format?: 'v1';
|
|
145
|
+
}): Promise<MastraMessageV1[]>;
|
|
146
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
147
|
+
format: 'v2';
|
|
148
|
+
}): Promise<MastraMessageV2[]>;
|
|
149
|
+
getMessagesPaginated({ threadId, selectBy, format, }: StorageGetMessagesArg & {
|
|
150
|
+
format?: 'v1' | 'v2';
|
|
151
|
+
}): Promise<PaginationInfo & {
|
|
152
|
+
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
153
|
+
}>;
|
|
138
154
|
persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
|
|
139
155
|
workflowName: string;
|
|
140
156
|
runId: string;
|
|
@@ -153,26 +169,77 @@ declare class D1Store extends MastraStorage {
|
|
|
153
169
|
tableName: TABLE_NAMES;
|
|
154
170
|
records: Record<string, any>[];
|
|
155
171
|
}): Promise<void>;
|
|
156
|
-
|
|
172
|
+
/**
|
|
173
|
+
* Upsert multiple records in a batch operation
|
|
174
|
+
* @param tableName The table to insert into
|
|
175
|
+
* @param records The records to insert
|
|
176
|
+
*/
|
|
177
|
+
private batchUpsert;
|
|
178
|
+
/**
|
|
179
|
+
* @deprecated use getTracesPaginated instead
|
|
180
|
+
*/
|
|
181
|
+
getTraces({ name, scope, page, perPage, attributes, fromDate, toDate, }: {
|
|
157
182
|
name?: string;
|
|
158
183
|
scope?: string;
|
|
159
184
|
page: number;
|
|
160
185
|
perPage: number;
|
|
161
186
|
attributes?: Record<string, string>;
|
|
162
|
-
|
|
187
|
+
fromDate?: Date;
|
|
188
|
+
toDate?: Date;
|
|
189
|
+
}): Promise<Trace[]>;
|
|
190
|
+
getTracesPaginated(args: {
|
|
191
|
+
name?: string;
|
|
192
|
+
scope?: string;
|
|
193
|
+
attributes?: Record<string, string>;
|
|
194
|
+
page: number;
|
|
195
|
+
perPage: number;
|
|
196
|
+
fromDate?: Date;
|
|
197
|
+
toDate?: Date;
|
|
198
|
+
}): Promise<PaginationInfo & {
|
|
199
|
+
traces: Trace[];
|
|
200
|
+
}>;
|
|
201
|
+
/**
|
|
202
|
+
* @deprecated use getEvals instead
|
|
203
|
+
*/
|
|
163
204
|
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
164
|
-
|
|
205
|
+
getEvals(options?: {
|
|
206
|
+
agentName?: string;
|
|
207
|
+
type?: 'test' | 'live';
|
|
208
|
+
page?: number;
|
|
209
|
+
perPage?: number;
|
|
210
|
+
fromDate?: Date;
|
|
211
|
+
toDate?: Date;
|
|
212
|
+
}): Promise<PaginationInfo & {
|
|
213
|
+
evals: EvalRow[];
|
|
214
|
+
}>;
|
|
215
|
+
private parseWorkflowRun;
|
|
216
|
+
private hasColumn;
|
|
217
|
+
getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
|
|
165
218
|
workflowName?: string;
|
|
166
219
|
fromDate?: Date;
|
|
167
220
|
toDate?: Date;
|
|
168
221
|
limit?: number;
|
|
169
222
|
offset?: number;
|
|
223
|
+
resourceId?: string;
|
|
170
224
|
}): Promise<WorkflowRuns>;
|
|
225
|
+
getWorkflowRunById({ runId, workflowName, }: {
|
|
226
|
+
runId: string;
|
|
227
|
+
workflowName?: string;
|
|
228
|
+
}): Promise<WorkflowRun | null>;
|
|
171
229
|
/**
|
|
172
230
|
* Close the database connection
|
|
173
231
|
* No explicit cleanup needed for D1 in either REST or Workers Binding mode
|
|
174
232
|
*/
|
|
175
233
|
close(): Promise<void>;
|
|
234
|
+
updateMessages(_args: {
|
|
235
|
+
messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
236
|
+
id: string;
|
|
237
|
+
content?: {
|
|
238
|
+
metadata?: MastraMessageContentV2['metadata'];
|
|
239
|
+
content?: MastraMessageContentV2['content'];
|
|
240
|
+
};
|
|
241
|
+
}[];
|
|
242
|
+
}): Promise<MastraMessageV2[]>;
|
|
176
243
|
}
|
|
177
244
|
export { D1Store }
|
|
178
245
|
export { D1Store as D1Store_alias_1 }
|
|
@@ -196,9 +263,30 @@ declare interface D1WorkersConfig {
|
|
|
196
263
|
export { D1WorkersConfig }
|
|
197
264
|
export { D1WorkersConfig as D1WorkersConfig_alias_1 }
|
|
198
265
|
|
|
266
|
+
/**
|
|
267
|
+
* Parses and returns a valid SQL SELECT column identifier.
|
|
268
|
+
* Allows a single identifier (letters, numbers, underscores), or '*', optionally with 'AS alias'.
|
|
269
|
+
*
|
|
270
|
+
* @param column - The column identifier string to parse.
|
|
271
|
+
* @returns The validated column identifier as a branded type.
|
|
272
|
+
* @throws {Error} If invalid.
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* const col = parseSelectIdentifier('user_id'); // Ok
|
|
276
|
+
* parseSelectIdentifier('user_id AS uid'); // Ok
|
|
277
|
+
* parseSelectIdentifier('*'); // Ok
|
|
278
|
+
* parseSelectIdentifier('user id'); // Throws error
|
|
279
|
+
*/
|
|
280
|
+
export declare function parseSelectIdentifier(column: string): SelectIdentifier;
|
|
281
|
+
|
|
199
282
|
export declare const retryUntil: <T>(fn: () => Promise<T>, condition: (result: T) => boolean, timeout?: number, // REST API needs longer timeout due to higher latency
|
|
200
283
|
interval?: number) => Promise<T>;
|
|
201
284
|
|
|
285
|
+
/** Represents a validated SQL SELECT column identifier (or '*', optionally with 'AS alias'). */
|
|
286
|
+
declare type SelectIdentifier = string & {
|
|
287
|
+
__brand: 'SelectIdentifier';
|
|
288
|
+
};
|
|
289
|
+
|
|
202
290
|
/**
|
|
203
291
|
* SQL Builder class for constructing type-safe SQL queries
|
|
204
292
|
* This helps create maintainable and secure SQL queries with proper parameter handling
|
|
@@ -226,6 +314,7 @@ export declare class SqlBuilder {
|
|
|
226
314
|
orderBy(column: string, direction?: 'ASC' | 'DESC'): SqlBuilder;
|
|
227
315
|
limit(count: number): SqlBuilder;
|
|
228
316
|
offset(count: number): SqlBuilder;
|
|
317
|
+
count(): SqlBuilder;
|
|
229
318
|
/**
|
|
230
319
|
* Insert a row, or update specific columns on conflict (upsert).
|
|
231
320
|
* @param table Table name
|
|
@@ -261,7 +350,6 @@ export declare class SqlBuilder {
|
|
|
261
350
|
* @returns The builder instance
|
|
262
351
|
*/
|
|
263
352
|
createIndex(indexName: string, tableName: string, columnName: string, indexType?: string): SqlBuilder;
|
|
264
|
-
raw(sql: string, ...params: SqlParam[]): SqlBuilder;
|
|
265
353
|
/**
|
|
266
354
|
* Add a LIKE condition to the query
|
|
267
355
|
* @param column The column to check
|
|
@@ -299,7 +387,7 @@ export declare type SqlParam = string | number | boolean | null | undefined;
|
|
|
299
387
|
/**
|
|
300
388
|
* Interface for SQL query options with generic type support
|
|
301
389
|
*/
|
|
302
|
-
declare interface SqlQueryOptions {
|
|
390
|
+
export declare interface SqlQueryOptions {
|
|
303
391
|
/** SQL query to execute */
|
|
304
392
|
sql: string;
|
|
305
393
|
/** Parameters to bind to the query */
|
|
@@ -307,7 +395,5 @@ declare interface SqlQueryOptions {
|
|
|
307
395
|
/** Whether to return only the first result */
|
|
308
396
|
first?: boolean;
|
|
309
397
|
}
|
|
310
|
-
export { SqlQueryOptions }
|
|
311
|
-
export { SqlQueryOptions as SqlQueryOptions_alias_1 }
|
|
312
398
|
|
|
313
399
|
export { }
|