@mastra/cloudflare-d1 0.0.0-separate-trace-data-from-component-20250501042644 → 0.0.0-support-d1-client-20250701191943

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/README.md CHANGED
@@ -54,6 +54,21 @@ const store = new D1Store({
54
54
  });
55
55
  ```
56
56
 
57
+ ### Or you can pass any client implementation you want
58
+
59
+ ```typescript
60
+ import { D1Store } from '@mastra/cloudflare-d1';
61
+
62
+ const store = new D1Store({
63
+ client: {
64
+ query: ({ sql, params }) => {
65
+ // do something
66
+ },
67
+ },
68
+ tablePrefix: 'mastra_', // optional
69
+ });
70
+ ```
71
+
57
72
  ## Supported Methods
58
73
 
59
74
  ### Thread Operations
@@ -1,42 +1,19 @@
1
+ import { default as Cloudflare_2 } from 'cloudflare';
1
2
  import type { D1Database as D1Database_2 } from '@cloudflare/workers-types';
2
3
  import type { EvalRow } from '@mastra/core/storage';
4
+ import type { MastraMessageContentV2 } from '@mastra/core/agent';
5
+ import type { MastraMessageV1 } from '@mastra/core/memory';
6
+ import type { MastraMessageV2 } from '@mastra/core/memory';
3
7
  import { MastraStorage } from '@mastra/core/storage';
4
- import type { MessageType } from '@mastra/core/memory';
5
- import type { MessageType as MessageType_2 } from '@mastra/core';
8
+ import type { PaginationInfo } from '@mastra/core/storage';
6
9
  import type { StorageColumn } from '@mastra/core/storage';
7
10
  import type { StorageGetMessagesArg } from '@mastra/core/storage';
8
11
  import type { StorageThreadType } from '@mastra/core/memory';
9
12
  import type { TABLE_NAMES } from '@mastra/core/storage';
13
+ import type { Trace } from '@mastra/core/telemetry';
10
14
  import type { WorkflowRun } from '@mastra/core/storage';
11
15
  import type { WorkflowRuns } from '@mastra/core/storage';
12
16
  import type { WorkflowRunState } from '@mastra/core/workflows';
13
- import type { WorkflowRunState as WorkflowRunState_2 } from '@mastra/core';
14
-
15
- export declare const checkWorkflowSnapshot: (snapshot: WorkflowRunState_2 | string, stepId: string, status: string) => void;
16
-
17
- export declare const createSampleMessage: (threadId: string) => MessageType_2;
18
-
19
- export declare const createSampleThread: () => {
20
- id: string;
21
- resourceId: string;
22
- title: string;
23
- createdAt: Date;
24
- updatedAt: Date;
25
- metadata: {
26
- key: string;
27
- };
28
- };
29
-
30
- export declare const createSampleThreadWithParams: (threadId: string, resourceId: string, createdAt: Date, updatedAt: Date) => {
31
- id: string;
32
- resourceId: string;
33
- title: string;
34
- createdAt: Date;
35
- updatedAt: Date;
36
- metadata: {
37
- key: string;
38
- };
39
- };
40
17
 
41
18
  export declare const createSampleTrace: (name: string, scope?: string, attributes?: Record<string, string>) => {
42
19
  id: string;
@@ -55,14 +32,28 @@ export declare const createSampleTrace: (name: string, scope?: string, attribute
55
32
  createdAt: string;
56
33
  };
57
34
 
58
- export declare const createSampleWorkflowSnapshot: (threadId: string, status: string, createdAt?: Date) => {
59
- snapshot: WorkflowRunState_2;
60
- runId: string;
61
- stepId: string;
62
- };
63
-
64
35
  export declare function createSqlBuilder(): SqlBuilder;
65
36
 
37
+ declare interface D1Client {
38
+ query(args: {
39
+ sql: string;
40
+ params: string[];
41
+ }): Promise<{
42
+ result: D1QueryResult;
43
+ }>;
44
+ }
45
+ export { D1Client }
46
+ export { D1Client as D1Client_alias_1 }
47
+
48
+ declare interface D1ClientConfig {
49
+ /** Optional prefix for table names */
50
+ tablePrefix?: string;
51
+ /** D1 Client */
52
+ client: D1Client;
53
+ }
54
+ export { D1ClientConfig }
55
+ export { D1ClientConfig as D1ClientConfig_alias_1 }
56
+
66
57
  /**
67
58
  * Configuration for D1 using the REST API
68
59
  */
@@ -79,10 +70,12 @@ declare interface D1Config {
79
70
  export { D1Config }
80
71
  export { D1Config as D1Config_alias_1 }
81
72
 
73
+ declare type D1QueryResult = Awaited<ReturnType<Cloudflare_2['d1']['database']['query']>>['result'];
74
+ export { D1QueryResult }
75
+ export { D1QueryResult as D1QueryResult_alias_1 }
76
+
82
77
  declare class D1Store extends MastraStorage {
83
78
  private client?;
84
- private accountId?;
85
- private databaseId?;
86
79
  private binding?;
87
80
  private tablePrefix;
88
81
  /**
@@ -92,7 +85,6 @@ declare class D1Store extends MastraStorage {
92
85
  constructor(config: D1StoreConfig);
93
86
  private getTableName;
94
87
  private formatSqlParams;
95
- private createIndexIfNotExists;
96
88
  private executeWorkersBindingQuery;
97
89
  private executeRestQuery;
98
90
  /**
@@ -101,15 +93,25 @@ declare class D1Store extends MastraStorage {
101
93
  * @returns Query results as an array or a single object if first=true
102
94
  */
103
95
  private executeQuery;
104
- private getSqlType;
105
- private ensureDate;
106
- private serializeDate;
96
+ private getTableColumns;
107
97
  private serializeValue;
108
98
  private deserializeValue;
99
+ protected getSqlType(type: StorageColumn['type']): string;
109
100
  createTable({ tableName, schema, }: {
110
101
  tableName: TABLE_NAMES;
111
102
  schema: Record<string, StorageColumn>;
112
103
  }): Promise<void>;
104
+ /**
105
+ * Alters table schema to add columns if they don't exist
106
+ * @param tableName Name of the table
107
+ * @param schema Schema of the table
108
+ * @param ifNotExists Array of column names to add if they don't exist
109
+ */
110
+ alterTable({ tableName, schema, ifNotExists, }: {
111
+ tableName: TABLE_NAMES;
112
+ schema: Record<string, StorageColumn>;
113
+ ifNotExists: string[];
114
+ }): Promise<void>;
113
115
  clearTable({ tableName }: {
114
116
  tableName: TABLE_NAMES;
115
117
  }): Promise<void>;
@@ -125,9 +127,19 @@ declare class D1Store extends MastraStorage {
125
127
  getThreadById({ threadId }: {
126
128
  threadId: string;
127
129
  }): Promise<StorageThreadType | null>;
130
+ /**
131
+ * @deprecated use getThreadsByResourceIdPaginated instead
132
+ */
128
133
  getThreadsByResourceId({ resourceId }: {
129
134
  resourceId: string;
130
135
  }): Promise<StorageThreadType[]>;
136
+ getThreadsByResourceIdPaginated(args: {
137
+ resourceId: string;
138
+ page: number;
139
+ perPage: number;
140
+ }): Promise<PaginationInfo & {
141
+ threads: StorageThreadType[];
142
+ }>;
131
143
  saveThread({ thread }: {
132
144
  thread: StorageThreadType;
133
145
  }): Promise<StorageThreadType>;
@@ -139,10 +151,29 @@ declare class D1Store extends MastraStorage {
139
151
  deleteThread({ threadId }: {
140
152
  threadId: string;
141
153
  }): Promise<void>;
142
- saveMessages({ messages }: {
143
- messages: MessageType[];
144
- }): Promise<MessageType[]>;
145
- getMessages<T = MessageType>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T[]>;
154
+ saveMessages(args: {
155
+ messages: MastraMessageV1[];
156
+ format?: undefined | 'v1';
157
+ }): Promise<MastraMessageV1[]>;
158
+ saveMessages(args: {
159
+ messages: MastraMessageV2[];
160
+ format: 'v2';
161
+ }): Promise<MastraMessageV2[]>;
162
+ private _getIncludedMessages;
163
+ /**
164
+ * @deprecated use getMessagesPaginated instead
165
+ */
166
+ getMessages(args: StorageGetMessagesArg & {
167
+ format?: 'v1';
168
+ }): Promise<MastraMessageV1[]>;
169
+ getMessages(args: StorageGetMessagesArg & {
170
+ format: 'v2';
171
+ }): Promise<MastraMessageV2[]>;
172
+ getMessagesPaginated({ threadId, selectBy, format, }: StorageGetMessagesArg & {
173
+ format?: 'v1' | 'v2';
174
+ }): Promise<PaginationInfo & {
175
+ messages: MastraMessageV1[] | MastraMessageV2[];
176
+ }>;
146
177
  persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
147
178
  workflowName: string;
148
179
  runId: string;
@@ -161,14 +192,49 @@ declare class D1Store extends MastraStorage {
161
192
  tableName: TABLE_NAMES;
162
193
  records: Record<string, any>[];
163
194
  }): Promise<void>;
164
- getTraces({ name, scope, page, perPage, attributes, }: {
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
+ /**
202
+ * @deprecated use getTracesPaginated instead
203
+ */
204
+ getTraces({ name, scope, page, perPage, attributes, fromDate, toDate, }: {
165
205
  name?: string;
166
206
  scope?: string;
167
207
  page: number;
168
208
  perPage: number;
169
209
  attributes?: Record<string, string>;
170
- }): Promise<Record<string, any>[]>;
210
+ fromDate?: Date;
211
+ toDate?: Date;
212
+ }): 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 & {
222
+ traces: Trace[];
223
+ }>;
224
+ /**
225
+ * @deprecated use getEvals instead
226
+ */
171
227
  getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
228
+ getEvals(options?: {
229
+ agentName?: string;
230
+ type?: 'test' | 'live';
231
+ page?: number;
232
+ perPage?: number;
233
+ fromDate?: Date;
234
+ toDate?: Date;
235
+ }): Promise<PaginationInfo & {
236
+ evals: EvalRow[];
237
+ }>;
172
238
  private parseWorkflowRun;
173
239
  private hasColumn;
174
240
  getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
@@ -188,6 +254,15 @@ declare class D1Store extends MastraStorage {
188
254
  * No explicit cleanup needed for D1 in either REST or Workers Binding mode
189
255
  */
190
256
  close(): Promise<void>;
257
+ updateMessages(_args: {
258
+ messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
259
+ id: string;
260
+ content?: {
261
+ metadata?: MastraMessageContentV2['metadata'];
262
+ content?: MastraMessageContentV2['content'];
263
+ };
264
+ }[];
265
+ }): Promise<MastraMessageV2[]>;
191
266
  }
192
267
  export { D1Store }
193
268
  export { D1Store as D1Store_alias_1 }
@@ -195,7 +270,7 @@ export { D1Store as D1Store_alias_1 }
195
270
  /**
196
271
  * Combined configuration type supporting both REST API and Workers Binding API
197
272
  */
198
- declare type D1StoreConfig = D1Config | D1WorkersConfig;
273
+ declare type D1StoreConfig = D1Config | D1WorkersConfig | D1ClientConfig;
199
274
  export { D1StoreConfig }
200
275
  export { D1StoreConfig as D1StoreConfig_alias_1 }
201
276
 
@@ -211,9 +286,30 @@ declare interface D1WorkersConfig {
211
286
  export { D1WorkersConfig }
212
287
  export { D1WorkersConfig as D1WorkersConfig_alias_1 }
213
288
 
289
+ /**
290
+ * Parses and returns a valid SQL SELECT column identifier.
291
+ * Allows a single identifier (letters, numbers, underscores), or '*', optionally with 'AS alias'.
292
+ *
293
+ * @param column - The column identifier string to parse.
294
+ * @returns The validated column identifier as a branded type.
295
+ * @throws {Error} If invalid.
296
+ *
297
+ * @example
298
+ * const col = parseSelectIdentifier('user_id'); // Ok
299
+ * parseSelectIdentifier('user_id AS uid'); // Ok
300
+ * parseSelectIdentifier('*'); // Ok
301
+ * parseSelectIdentifier('user id'); // Throws error
302
+ */
303
+ export declare function parseSelectIdentifier(column: string): SelectIdentifier;
304
+
214
305
  export declare const retryUntil: <T>(fn: () => Promise<T>, condition: (result: T) => boolean, timeout?: number, // REST API needs longer timeout due to higher latency
215
306
  interval?: number) => Promise<T>;
216
307
 
308
+ /** Represents a validated SQL SELECT column identifier (or '*', optionally with 'AS alias'). */
309
+ declare type SelectIdentifier = string & {
310
+ __brand: 'SelectIdentifier';
311
+ };
312
+
217
313
  /**
218
314
  * SQL Builder class for constructing type-safe SQL queries
219
315
  * This helps create maintainable and secure SQL queries with proper parameter handling
@@ -277,7 +373,6 @@ export declare class SqlBuilder {
277
373
  * @returns The builder instance
278
374
  */
279
375
  createIndex(indexName: string, tableName: string, columnName: string, indexType?: string): SqlBuilder;
280
- raw(sql: string, ...params: SqlParam[]): SqlBuilder;
281
376
  /**
282
377
  * Add a LIKE condition to the query
283
378
  * @param column The column to check
@@ -315,7 +410,7 @@ export declare type SqlParam = string | number | boolean | null | undefined;
315
410
  /**
316
411
  * Interface for SQL query options with generic type support
317
412
  */
318
- declare interface SqlQueryOptions {
413
+ export declare interface SqlQueryOptions {
319
414
  /** SQL query to execute */
320
415
  sql: string;
321
416
  /** Parameters to bind to the query */
@@ -323,7 +418,5 @@ declare interface SqlQueryOptions {
323
418
  /** Whether to return only the first result */
324
419
  first?: boolean;
325
420
  }
326
- export { SqlQueryOptions }
327
- export { SqlQueryOptions as SqlQueryOptions_alias_1 }
328
421
 
329
422
  export { }
@@ -1,42 +1,19 @@
1
+ import { default as Cloudflare_2 } from 'cloudflare';
1
2
  import type { D1Database as D1Database_2 } from '@cloudflare/workers-types';
2
3
  import type { EvalRow } from '@mastra/core/storage';
4
+ import type { MastraMessageContentV2 } from '@mastra/core/agent';
5
+ import type { MastraMessageV1 } from '@mastra/core/memory';
6
+ import type { MastraMessageV2 } from '@mastra/core/memory';
3
7
  import { MastraStorage } from '@mastra/core/storage';
4
- import type { MessageType } from '@mastra/core/memory';
5
- import type { MessageType as MessageType_2 } from '@mastra/core';
8
+ import type { PaginationInfo } from '@mastra/core/storage';
6
9
  import type { StorageColumn } from '@mastra/core/storage';
7
10
  import type { StorageGetMessagesArg } from '@mastra/core/storage';
8
11
  import type { StorageThreadType } from '@mastra/core/memory';
9
12
  import type { TABLE_NAMES } from '@mastra/core/storage';
13
+ import type { Trace } from '@mastra/core/telemetry';
10
14
  import type { WorkflowRun } from '@mastra/core/storage';
11
15
  import type { WorkflowRuns } from '@mastra/core/storage';
12
16
  import type { WorkflowRunState } from '@mastra/core/workflows';
13
- import type { WorkflowRunState as WorkflowRunState_2 } from '@mastra/core';
14
-
15
- export declare const checkWorkflowSnapshot: (snapshot: WorkflowRunState_2 | string, stepId: string, status: string) => void;
16
-
17
- export declare const createSampleMessage: (threadId: string) => MessageType_2;
18
-
19
- export declare const createSampleThread: () => {
20
- id: string;
21
- resourceId: string;
22
- title: string;
23
- createdAt: Date;
24
- updatedAt: Date;
25
- metadata: {
26
- key: string;
27
- };
28
- };
29
-
30
- export declare const createSampleThreadWithParams: (threadId: string, resourceId: string, createdAt: Date, updatedAt: Date) => {
31
- id: string;
32
- resourceId: string;
33
- title: string;
34
- createdAt: Date;
35
- updatedAt: Date;
36
- metadata: {
37
- key: string;
38
- };
39
- };
40
17
 
41
18
  export declare const createSampleTrace: (name: string, scope?: string, attributes?: Record<string, string>) => {
42
19
  id: string;
@@ -55,14 +32,28 @@ export declare const createSampleTrace: (name: string, scope?: string, attribute
55
32
  createdAt: string;
56
33
  };
57
34
 
58
- export declare const createSampleWorkflowSnapshot: (threadId: string, status: string, createdAt?: Date) => {
59
- snapshot: WorkflowRunState_2;
60
- runId: string;
61
- stepId: string;
62
- };
63
-
64
35
  export declare function createSqlBuilder(): SqlBuilder;
65
36
 
37
+ declare interface D1Client {
38
+ query(args: {
39
+ sql: string;
40
+ params: string[];
41
+ }): Promise<{
42
+ result: D1QueryResult;
43
+ }>;
44
+ }
45
+ export { D1Client }
46
+ export { D1Client as D1Client_alias_1 }
47
+
48
+ declare interface D1ClientConfig {
49
+ /** Optional prefix for table names */
50
+ tablePrefix?: string;
51
+ /** D1 Client */
52
+ client: D1Client;
53
+ }
54
+ export { D1ClientConfig }
55
+ export { D1ClientConfig as D1ClientConfig_alias_1 }
56
+
66
57
  /**
67
58
  * Configuration for D1 using the REST API
68
59
  */
@@ -79,10 +70,12 @@ declare interface D1Config {
79
70
  export { D1Config }
80
71
  export { D1Config as D1Config_alias_1 }
81
72
 
73
+ declare type D1QueryResult = Awaited<ReturnType<Cloudflare_2['d1']['database']['query']>>['result'];
74
+ export { D1QueryResult }
75
+ export { D1QueryResult as D1QueryResult_alias_1 }
76
+
82
77
  declare class D1Store extends MastraStorage {
83
78
  private client?;
84
- private accountId?;
85
- private databaseId?;
86
79
  private binding?;
87
80
  private tablePrefix;
88
81
  /**
@@ -92,7 +85,6 @@ declare class D1Store extends MastraStorage {
92
85
  constructor(config: D1StoreConfig);
93
86
  private getTableName;
94
87
  private formatSqlParams;
95
- private createIndexIfNotExists;
96
88
  private executeWorkersBindingQuery;
97
89
  private executeRestQuery;
98
90
  /**
@@ -101,15 +93,25 @@ declare class D1Store extends MastraStorage {
101
93
  * @returns Query results as an array or a single object if first=true
102
94
  */
103
95
  private executeQuery;
104
- private getSqlType;
105
- private ensureDate;
106
- private serializeDate;
96
+ private getTableColumns;
107
97
  private serializeValue;
108
98
  private deserializeValue;
99
+ protected getSqlType(type: StorageColumn['type']): string;
109
100
  createTable({ tableName, schema, }: {
110
101
  tableName: TABLE_NAMES;
111
102
  schema: Record<string, StorageColumn>;
112
103
  }): Promise<void>;
104
+ /**
105
+ * Alters table schema to add columns if they don't exist
106
+ * @param tableName Name of the table
107
+ * @param schema Schema of the table
108
+ * @param ifNotExists Array of column names to add if they don't exist
109
+ */
110
+ alterTable({ tableName, schema, ifNotExists, }: {
111
+ tableName: TABLE_NAMES;
112
+ schema: Record<string, StorageColumn>;
113
+ ifNotExists: string[];
114
+ }): Promise<void>;
113
115
  clearTable({ tableName }: {
114
116
  tableName: TABLE_NAMES;
115
117
  }): Promise<void>;
@@ -125,9 +127,19 @@ declare class D1Store extends MastraStorage {
125
127
  getThreadById({ threadId }: {
126
128
  threadId: string;
127
129
  }): Promise<StorageThreadType | null>;
130
+ /**
131
+ * @deprecated use getThreadsByResourceIdPaginated instead
132
+ */
128
133
  getThreadsByResourceId({ resourceId }: {
129
134
  resourceId: string;
130
135
  }): Promise<StorageThreadType[]>;
136
+ getThreadsByResourceIdPaginated(args: {
137
+ resourceId: string;
138
+ page: number;
139
+ perPage: number;
140
+ }): Promise<PaginationInfo & {
141
+ threads: StorageThreadType[];
142
+ }>;
131
143
  saveThread({ thread }: {
132
144
  thread: StorageThreadType;
133
145
  }): Promise<StorageThreadType>;
@@ -139,10 +151,29 @@ declare class D1Store extends MastraStorage {
139
151
  deleteThread({ threadId }: {
140
152
  threadId: string;
141
153
  }): Promise<void>;
142
- saveMessages({ messages }: {
143
- messages: MessageType[];
144
- }): Promise<MessageType[]>;
145
- getMessages<T = MessageType>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T[]>;
154
+ saveMessages(args: {
155
+ messages: MastraMessageV1[];
156
+ format?: undefined | 'v1';
157
+ }): Promise<MastraMessageV1[]>;
158
+ saveMessages(args: {
159
+ messages: MastraMessageV2[];
160
+ format: 'v2';
161
+ }): Promise<MastraMessageV2[]>;
162
+ private _getIncludedMessages;
163
+ /**
164
+ * @deprecated use getMessagesPaginated instead
165
+ */
166
+ getMessages(args: StorageGetMessagesArg & {
167
+ format?: 'v1';
168
+ }): Promise<MastraMessageV1[]>;
169
+ getMessages(args: StorageGetMessagesArg & {
170
+ format: 'v2';
171
+ }): Promise<MastraMessageV2[]>;
172
+ getMessagesPaginated({ threadId, selectBy, format, }: StorageGetMessagesArg & {
173
+ format?: 'v1' | 'v2';
174
+ }): Promise<PaginationInfo & {
175
+ messages: MastraMessageV1[] | MastraMessageV2[];
176
+ }>;
146
177
  persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
147
178
  workflowName: string;
148
179
  runId: string;
@@ -161,14 +192,49 @@ declare class D1Store extends MastraStorage {
161
192
  tableName: TABLE_NAMES;
162
193
  records: Record<string, any>[];
163
194
  }): Promise<void>;
164
- getTraces({ name, scope, page, perPage, attributes, }: {
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
+ /**
202
+ * @deprecated use getTracesPaginated instead
203
+ */
204
+ getTraces({ name, scope, page, perPage, attributes, fromDate, toDate, }: {
165
205
  name?: string;
166
206
  scope?: string;
167
207
  page: number;
168
208
  perPage: number;
169
209
  attributes?: Record<string, string>;
170
- }): Promise<Record<string, any>[]>;
210
+ fromDate?: Date;
211
+ toDate?: Date;
212
+ }): 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 & {
222
+ traces: Trace[];
223
+ }>;
224
+ /**
225
+ * @deprecated use getEvals instead
226
+ */
171
227
  getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
228
+ getEvals(options?: {
229
+ agentName?: string;
230
+ type?: 'test' | 'live';
231
+ page?: number;
232
+ perPage?: number;
233
+ fromDate?: Date;
234
+ toDate?: Date;
235
+ }): Promise<PaginationInfo & {
236
+ evals: EvalRow[];
237
+ }>;
172
238
  private parseWorkflowRun;
173
239
  private hasColumn;
174
240
  getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
@@ -188,6 +254,15 @@ declare class D1Store extends MastraStorage {
188
254
  * No explicit cleanup needed for D1 in either REST or Workers Binding mode
189
255
  */
190
256
  close(): Promise<void>;
257
+ updateMessages(_args: {
258
+ messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
259
+ id: string;
260
+ content?: {
261
+ metadata?: MastraMessageContentV2['metadata'];
262
+ content?: MastraMessageContentV2['content'];
263
+ };
264
+ }[];
265
+ }): Promise<MastraMessageV2[]>;
191
266
  }
192
267
  export { D1Store }
193
268
  export { D1Store as D1Store_alias_1 }
@@ -195,7 +270,7 @@ export { D1Store as D1Store_alias_1 }
195
270
  /**
196
271
  * Combined configuration type supporting both REST API and Workers Binding API
197
272
  */
198
- declare type D1StoreConfig = D1Config | D1WorkersConfig;
273
+ declare type D1StoreConfig = D1Config | D1WorkersConfig | D1ClientConfig;
199
274
  export { D1StoreConfig }
200
275
  export { D1StoreConfig as D1StoreConfig_alias_1 }
201
276
 
@@ -211,9 +286,30 @@ declare interface D1WorkersConfig {
211
286
  export { D1WorkersConfig }
212
287
  export { D1WorkersConfig as D1WorkersConfig_alias_1 }
213
288
 
289
+ /**
290
+ * Parses and returns a valid SQL SELECT column identifier.
291
+ * Allows a single identifier (letters, numbers, underscores), or '*', optionally with 'AS alias'.
292
+ *
293
+ * @param column - The column identifier string to parse.
294
+ * @returns The validated column identifier as a branded type.
295
+ * @throws {Error} If invalid.
296
+ *
297
+ * @example
298
+ * const col = parseSelectIdentifier('user_id'); // Ok
299
+ * parseSelectIdentifier('user_id AS uid'); // Ok
300
+ * parseSelectIdentifier('*'); // Ok
301
+ * parseSelectIdentifier('user id'); // Throws error
302
+ */
303
+ export declare function parseSelectIdentifier(column: string): SelectIdentifier;
304
+
214
305
  export declare const retryUntil: <T>(fn: () => Promise<T>, condition: (result: T) => boolean, timeout?: number, // REST API needs longer timeout due to higher latency
215
306
  interval?: number) => Promise<T>;
216
307
 
308
+ /** Represents a validated SQL SELECT column identifier (or '*', optionally with 'AS alias'). */
309
+ declare type SelectIdentifier = string & {
310
+ __brand: 'SelectIdentifier';
311
+ };
312
+
217
313
  /**
218
314
  * SQL Builder class for constructing type-safe SQL queries
219
315
  * This helps create maintainable and secure SQL queries with proper parameter handling
@@ -277,7 +373,6 @@ export declare class SqlBuilder {
277
373
  * @returns The builder instance
278
374
  */
279
375
  createIndex(indexName: string, tableName: string, columnName: string, indexType?: string): SqlBuilder;
280
- raw(sql: string, ...params: SqlParam[]): SqlBuilder;
281
376
  /**
282
377
  * Add a LIKE condition to the query
283
378
  * @param column The column to check
@@ -315,7 +410,7 @@ export declare type SqlParam = string | number | boolean | null | undefined;
315
410
  /**
316
411
  * Interface for SQL query options with generic type support
317
412
  */
318
- declare interface SqlQueryOptions {
413
+ export declare interface SqlQueryOptions {
319
414
  /** SQL query to execute */
320
415
  sql: string;
321
416
  /** Parameters to bind to the query */
@@ -323,7 +418,5 @@ declare interface SqlQueryOptions {
323
418
  /** Whether to return only the first result */
324
419
  first?: boolean;
325
420
  }
326
- export { SqlQueryOptions }
327
- export { SqlQueryOptions as SqlQueryOptions_alias_1 }
328
421
 
329
422
  export { }