@mastra/cloudflare-d1 0.0.0-vnextWorkflows-20250422081019 → 0.0.0-workflow-deno-20250616115451
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 +113 -43
- package/dist/_tsup-dts-rollup.d.ts +113 -43
- package/dist/index.cjs +514 -123
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +514 -123
- package/package.json +17 -13
|
@@ -1,38 +1,17 @@
|
|
|
1
1
|
import type { D1Database as D1Database_2 } from '@cloudflare/workers-types';
|
|
2
2
|
import type { EvalRow } from '@mastra/core/storage';
|
|
3
|
+
import type { MastraMessageV1 } from '@mastra/core/memory';
|
|
4
|
+
import type { MastraMessageV2 } from '@mastra/core/memory';
|
|
3
5
|
import { MastraStorage } from '@mastra/core/storage';
|
|
4
|
-
import type {
|
|
6
|
+
import type { PaginationInfo } from '@mastra/core/storage';
|
|
5
7
|
import type { StorageColumn } from '@mastra/core/storage';
|
|
6
8
|
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
7
9
|
import type { StorageThreadType } from '@mastra/core/memory';
|
|
8
10
|
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
11
|
+
import type { Trace } from '@mastra/core/telemetry';
|
|
12
|
+
import type { WorkflowRun } from '@mastra/core/storage';
|
|
9
13
|
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
10
14
|
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
15
|
|
|
37
16
|
export declare const createSampleTrace: (name: string, scope?: string, attributes?: Record<string, string>) => {
|
|
38
17
|
id: string;
|
|
@@ -51,8 +30,6 @@ export declare const createSampleTrace: (name: string, scope?: string, attribute
|
|
|
51
30
|
createdAt: string;
|
|
52
31
|
};
|
|
53
32
|
|
|
54
|
-
export declare const createSampleWorkflowSnapshot: (threadId: string) => WorkflowRunState_2;
|
|
55
|
-
|
|
56
33
|
export declare function createSqlBuilder(): SqlBuilder;
|
|
57
34
|
|
|
58
35
|
/**
|
|
@@ -84,7 +61,6 @@ declare class D1Store extends MastraStorage {
|
|
|
84
61
|
constructor(config: D1StoreConfig);
|
|
85
62
|
private getTableName;
|
|
86
63
|
private formatSqlParams;
|
|
87
|
-
private createIndexIfNotExists;
|
|
88
64
|
private executeWorkersBindingQuery;
|
|
89
65
|
private executeRestQuery;
|
|
90
66
|
/**
|
|
@@ -93,15 +69,25 @@ declare class D1Store extends MastraStorage {
|
|
|
93
69
|
* @returns Query results as an array or a single object if first=true
|
|
94
70
|
*/
|
|
95
71
|
private executeQuery;
|
|
96
|
-
private
|
|
97
|
-
private ensureDate;
|
|
98
|
-
private serializeDate;
|
|
72
|
+
private getTableColumns;
|
|
99
73
|
private serializeValue;
|
|
100
74
|
private deserializeValue;
|
|
75
|
+
protected getSqlType(type: StorageColumn['type']): string;
|
|
101
76
|
createTable({ tableName, schema, }: {
|
|
102
77
|
tableName: TABLE_NAMES;
|
|
103
78
|
schema: Record<string, StorageColumn>;
|
|
104
79
|
}): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Alters table schema to add columns if they don't exist
|
|
82
|
+
* @param tableName Name of the table
|
|
83
|
+
* @param schema Schema of the table
|
|
84
|
+
* @param ifNotExists Array of column names to add if they don't exist
|
|
85
|
+
*/
|
|
86
|
+
alterTable({ tableName, schema, ifNotExists, }: {
|
|
87
|
+
tableName: TABLE_NAMES;
|
|
88
|
+
schema: Record<string, StorageColumn>;
|
|
89
|
+
ifNotExists: string[];
|
|
90
|
+
}): Promise<void>;
|
|
105
91
|
clearTable({ tableName }: {
|
|
106
92
|
tableName: TABLE_NAMES;
|
|
107
93
|
}): Promise<void>;
|
|
@@ -117,9 +103,19 @@ declare class D1Store extends MastraStorage {
|
|
|
117
103
|
getThreadById({ threadId }: {
|
|
118
104
|
threadId: string;
|
|
119
105
|
}): Promise<StorageThreadType | null>;
|
|
106
|
+
/**
|
|
107
|
+
* @deprecated use getThreadsByResourceIdPaginated instead
|
|
108
|
+
*/
|
|
120
109
|
getThreadsByResourceId({ resourceId }: {
|
|
121
110
|
resourceId: string;
|
|
122
111
|
}): Promise<StorageThreadType[]>;
|
|
112
|
+
getThreadsByResourceIdPaginated(args: {
|
|
113
|
+
resourceId: string;
|
|
114
|
+
page: number;
|
|
115
|
+
perPage: number;
|
|
116
|
+
}): Promise<PaginationInfo & {
|
|
117
|
+
threads: StorageThreadType[];
|
|
118
|
+
}>;
|
|
123
119
|
saveThread({ thread }: {
|
|
124
120
|
thread: StorageThreadType;
|
|
125
121
|
}): Promise<StorageThreadType>;
|
|
@@ -131,10 +127,29 @@ declare class D1Store extends MastraStorage {
|
|
|
131
127
|
deleteThread({ threadId }: {
|
|
132
128
|
threadId: string;
|
|
133
129
|
}): Promise<void>;
|
|
134
|
-
saveMessages(
|
|
135
|
-
messages:
|
|
136
|
-
|
|
137
|
-
|
|
130
|
+
saveMessages(args: {
|
|
131
|
+
messages: MastraMessageV1[];
|
|
132
|
+
format?: undefined | 'v1';
|
|
133
|
+
}): Promise<MastraMessageV1[]>;
|
|
134
|
+
saveMessages(args: {
|
|
135
|
+
messages: MastraMessageV2[];
|
|
136
|
+
format: 'v2';
|
|
137
|
+
}): Promise<MastraMessageV2[]>;
|
|
138
|
+
private _getIncludedMessages;
|
|
139
|
+
/**
|
|
140
|
+
* @deprecated use getMessagesPaginated instead
|
|
141
|
+
*/
|
|
142
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
143
|
+
format?: 'v1';
|
|
144
|
+
}): Promise<MastraMessageV1[]>;
|
|
145
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
146
|
+
format: 'v2';
|
|
147
|
+
}): Promise<MastraMessageV2[]>;
|
|
148
|
+
getMessagesPaginated({ threadId, selectBy, format, }: StorageGetMessagesArg & {
|
|
149
|
+
format?: 'v1' | 'v2';
|
|
150
|
+
}): Promise<PaginationInfo & {
|
|
151
|
+
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
152
|
+
}>;
|
|
138
153
|
persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
|
|
139
154
|
workflowName: string;
|
|
140
155
|
runId: string;
|
|
@@ -153,21 +168,57 @@ declare class D1Store extends MastraStorage {
|
|
|
153
168
|
tableName: TABLE_NAMES;
|
|
154
169
|
records: Record<string, any>[];
|
|
155
170
|
}): Promise<void>;
|
|
156
|
-
|
|
171
|
+
/**
|
|
172
|
+
* @deprecated use getTracesPaginated instead
|
|
173
|
+
*/
|
|
174
|
+
getTraces({ name, scope, page, perPage, attributes, fromDate, toDate, }: {
|
|
157
175
|
name?: string;
|
|
158
176
|
scope?: string;
|
|
159
177
|
page: number;
|
|
160
178
|
perPage: number;
|
|
161
179
|
attributes?: Record<string, string>;
|
|
162
|
-
|
|
180
|
+
fromDate?: Date;
|
|
181
|
+
toDate?: Date;
|
|
182
|
+
}): Promise<Trace[]>;
|
|
183
|
+
getTracesPaginated(args: {
|
|
184
|
+
name?: string;
|
|
185
|
+
scope?: string;
|
|
186
|
+
attributes?: Record<string, string>;
|
|
187
|
+
page: number;
|
|
188
|
+
perPage: number;
|
|
189
|
+
fromDate?: Date;
|
|
190
|
+
toDate?: Date;
|
|
191
|
+
}): Promise<PaginationInfo & {
|
|
192
|
+
traces: Trace[];
|
|
193
|
+
}>;
|
|
194
|
+
/**
|
|
195
|
+
* @deprecated use getEvals instead
|
|
196
|
+
*/
|
|
163
197
|
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
164
|
-
|
|
198
|
+
getEvals(options?: {
|
|
199
|
+
agentName?: string;
|
|
200
|
+
type?: 'test' | 'live';
|
|
201
|
+
page?: number;
|
|
202
|
+
perPage?: number;
|
|
203
|
+
fromDate?: Date;
|
|
204
|
+
toDate?: Date;
|
|
205
|
+
}): Promise<PaginationInfo & {
|
|
206
|
+
evals: EvalRow[];
|
|
207
|
+
}>;
|
|
208
|
+
private parseWorkflowRun;
|
|
209
|
+
private hasColumn;
|
|
210
|
+
getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
|
|
165
211
|
workflowName?: string;
|
|
166
212
|
fromDate?: Date;
|
|
167
213
|
toDate?: Date;
|
|
168
214
|
limit?: number;
|
|
169
215
|
offset?: number;
|
|
216
|
+
resourceId?: string;
|
|
170
217
|
}): Promise<WorkflowRuns>;
|
|
218
|
+
getWorkflowRunById({ runId, workflowName, }: {
|
|
219
|
+
runId: string;
|
|
220
|
+
workflowName?: string;
|
|
221
|
+
}): Promise<WorkflowRun | null>;
|
|
171
222
|
/**
|
|
172
223
|
* Close the database connection
|
|
173
224
|
* No explicit cleanup needed for D1 in either REST or Workers Binding mode
|
|
@@ -196,9 +247,30 @@ declare interface D1WorkersConfig {
|
|
|
196
247
|
export { D1WorkersConfig }
|
|
197
248
|
export { D1WorkersConfig as D1WorkersConfig_alias_1 }
|
|
198
249
|
|
|
250
|
+
/**
|
|
251
|
+
* Parses and returns a valid SQL SELECT column identifier.
|
|
252
|
+
* Allows a single identifier (letters, numbers, underscores), or '*', optionally with 'AS alias'.
|
|
253
|
+
*
|
|
254
|
+
* @param column - The column identifier string to parse.
|
|
255
|
+
* @returns The validated column identifier as a branded type.
|
|
256
|
+
* @throws {Error} If invalid.
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* const col = parseSelectIdentifier('user_id'); // Ok
|
|
260
|
+
* parseSelectIdentifier('user_id AS uid'); // Ok
|
|
261
|
+
* parseSelectIdentifier('*'); // Ok
|
|
262
|
+
* parseSelectIdentifier('user id'); // Throws error
|
|
263
|
+
*/
|
|
264
|
+
export declare function parseSelectIdentifier(column: string): SelectIdentifier;
|
|
265
|
+
|
|
199
266
|
export declare const retryUntil: <T>(fn: () => Promise<T>, condition: (result: T) => boolean, timeout?: number, // REST API needs longer timeout due to higher latency
|
|
200
267
|
interval?: number) => Promise<T>;
|
|
201
268
|
|
|
269
|
+
/** Represents a validated SQL SELECT column identifier (or '*', optionally with 'AS alias'). */
|
|
270
|
+
declare type SelectIdentifier = string & {
|
|
271
|
+
__brand: 'SelectIdentifier';
|
|
272
|
+
};
|
|
273
|
+
|
|
202
274
|
/**
|
|
203
275
|
* SQL Builder class for constructing type-safe SQL queries
|
|
204
276
|
* This helps create maintainable and secure SQL queries with proper parameter handling
|
|
@@ -226,6 +298,7 @@ export declare class SqlBuilder {
|
|
|
226
298
|
orderBy(column: string, direction?: 'ASC' | 'DESC'): SqlBuilder;
|
|
227
299
|
limit(count: number): SqlBuilder;
|
|
228
300
|
offset(count: number): SqlBuilder;
|
|
301
|
+
count(): SqlBuilder;
|
|
229
302
|
/**
|
|
230
303
|
* Insert a row, or update specific columns on conflict (upsert).
|
|
231
304
|
* @param table Table name
|
|
@@ -261,7 +334,6 @@ export declare class SqlBuilder {
|
|
|
261
334
|
* @returns The builder instance
|
|
262
335
|
*/
|
|
263
336
|
createIndex(indexName: string, tableName: string, columnName: string, indexType?: string): SqlBuilder;
|
|
264
|
-
raw(sql: string, ...params: SqlParam[]): SqlBuilder;
|
|
265
337
|
/**
|
|
266
338
|
* Add a LIKE condition to the query
|
|
267
339
|
* @param column The column to check
|
|
@@ -299,7 +371,7 @@ export declare type SqlParam = string | number | boolean | null | undefined;
|
|
|
299
371
|
/**
|
|
300
372
|
* Interface for SQL query options with generic type support
|
|
301
373
|
*/
|
|
302
|
-
declare interface SqlQueryOptions {
|
|
374
|
+
export declare interface SqlQueryOptions {
|
|
303
375
|
/** SQL query to execute */
|
|
304
376
|
sql: string;
|
|
305
377
|
/** Parameters to bind to the query */
|
|
@@ -307,7 +379,5 @@ declare interface SqlQueryOptions {
|
|
|
307
379
|
/** Whether to return only the first result */
|
|
308
380
|
first?: boolean;
|
|
309
381
|
}
|
|
310
|
-
export { SqlQueryOptions }
|
|
311
|
-
export { SqlQueryOptions as SqlQueryOptions_alias_1 }
|
|
312
382
|
|
|
313
383
|
export { }
|
|
@@ -1,38 +1,17 @@
|
|
|
1
1
|
import type { D1Database as D1Database_2 } from '@cloudflare/workers-types';
|
|
2
2
|
import type { EvalRow } from '@mastra/core/storage';
|
|
3
|
+
import type { MastraMessageV1 } from '@mastra/core/memory';
|
|
4
|
+
import type { MastraMessageV2 } from '@mastra/core/memory';
|
|
3
5
|
import { MastraStorage } from '@mastra/core/storage';
|
|
4
|
-
import type {
|
|
6
|
+
import type { PaginationInfo } from '@mastra/core/storage';
|
|
5
7
|
import type { StorageColumn } from '@mastra/core/storage';
|
|
6
8
|
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
7
9
|
import type { StorageThreadType } from '@mastra/core/memory';
|
|
8
10
|
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
11
|
+
import type { Trace } from '@mastra/core/telemetry';
|
|
12
|
+
import type { WorkflowRun } from '@mastra/core/storage';
|
|
9
13
|
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
10
14
|
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
15
|
|
|
37
16
|
export declare const createSampleTrace: (name: string, scope?: string, attributes?: Record<string, string>) => {
|
|
38
17
|
id: string;
|
|
@@ -51,8 +30,6 @@ export declare const createSampleTrace: (name: string, scope?: string, attribute
|
|
|
51
30
|
createdAt: string;
|
|
52
31
|
};
|
|
53
32
|
|
|
54
|
-
export declare const createSampleWorkflowSnapshot: (threadId: string) => WorkflowRunState_2;
|
|
55
|
-
|
|
56
33
|
export declare function createSqlBuilder(): SqlBuilder;
|
|
57
34
|
|
|
58
35
|
/**
|
|
@@ -84,7 +61,6 @@ declare class D1Store extends MastraStorage {
|
|
|
84
61
|
constructor(config: D1StoreConfig);
|
|
85
62
|
private getTableName;
|
|
86
63
|
private formatSqlParams;
|
|
87
|
-
private createIndexIfNotExists;
|
|
88
64
|
private executeWorkersBindingQuery;
|
|
89
65
|
private executeRestQuery;
|
|
90
66
|
/**
|
|
@@ -93,15 +69,25 @@ declare class D1Store extends MastraStorage {
|
|
|
93
69
|
* @returns Query results as an array or a single object if first=true
|
|
94
70
|
*/
|
|
95
71
|
private executeQuery;
|
|
96
|
-
private
|
|
97
|
-
private ensureDate;
|
|
98
|
-
private serializeDate;
|
|
72
|
+
private getTableColumns;
|
|
99
73
|
private serializeValue;
|
|
100
74
|
private deserializeValue;
|
|
75
|
+
protected getSqlType(type: StorageColumn['type']): string;
|
|
101
76
|
createTable({ tableName, schema, }: {
|
|
102
77
|
tableName: TABLE_NAMES;
|
|
103
78
|
schema: Record<string, StorageColumn>;
|
|
104
79
|
}): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Alters table schema to add columns if they don't exist
|
|
82
|
+
* @param tableName Name of the table
|
|
83
|
+
* @param schema Schema of the table
|
|
84
|
+
* @param ifNotExists Array of column names to add if they don't exist
|
|
85
|
+
*/
|
|
86
|
+
alterTable({ tableName, schema, ifNotExists, }: {
|
|
87
|
+
tableName: TABLE_NAMES;
|
|
88
|
+
schema: Record<string, StorageColumn>;
|
|
89
|
+
ifNotExists: string[];
|
|
90
|
+
}): Promise<void>;
|
|
105
91
|
clearTable({ tableName }: {
|
|
106
92
|
tableName: TABLE_NAMES;
|
|
107
93
|
}): Promise<void>;
|
|
@@ -117,9 +103,19 @@ declare class D1Store extends MastraStorage {
|
|
|
117
103
|
getThreadById({ threadId }: {
|
|
118
104
|
threadId: string;
|
|
119
105
|
}): Promise<StorageThreadType | null>;
|
|
106
|
+
/**
|
|
107
|
+
* @deprecated use getThreadsByResourceIdPaginated instead
|
|
108
|
+
*/
|
|
120
109
|
getThreadsByResourceId({ resourceId }: {
|
|
121
110
|
resourceId: string;
|
|
122
111
|
}): Promise<StorageThreadType[]>;
|
|
112
|
+
getThreadsByResourceIdPaginated(args: {
|
|
113
|
+
resourceId: string;
|
|
114
|
+
page: number;
|
|
115
|
+
perPage: number;
|
|
116
|
+
}): Promise<PaginationInfo & {
|
|
117
|
+
threads: StorageThreadType[];
|
|
118
|
+
}>;
|
|
123
119
|
saveThread({ thread }: {
|
|
124
120
|
thread: StorageThreadType;
|
|
125
121
|
}): Promise<StorageThreadType>;
|
|
@@ -131,10 +127,29 @@ declare class D1Store extends MastraStorage {
|
|
|
131
127
|
deleteThread({ threadId }: {
|
|
132
128
|
threadId: string;
|
|
133
129
|
}): Promise<void>;
|
|
134
|
-
saveMessages(
|
|
135
|
-
messages:
|
|
136
|
-
|
|
137
|
-
|
|
130
|
+
saveMessages(args: {
|
|
131
|
+
messages: MastraMessageV1[];
|
|
132
|
+
format?: undefined | 'v1';
|
|
133
|
+
}): Promise<MastraMessageV1[]>;
|
|
134
|
+
saveMessages(args: {
|
|
135
|
+
messages: MastraMessageV2[];
|
|
136
|
+
format: 'v2';
|
|
137
|
+
}): Promise<MastraMessageV2[]>;
|
|
138
|
+
private _getIncludedMessages;
|
|
139
|
+
/**
|
|
140
|
+
* @deprecated use getMessagesPaginated instead
|
|
141
|
+
*/
|
|
142
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
143
|
+
format?: 'v1';
|
|
144
|
+
}): Promise<MastraMessageV1[]>;
|
|
145
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
146
|
+
format: 'v2';
|
|
147
|
+
}): Promise<MastraMessageV2[]>;
|
|
148
|
+
getMessagesPaginated({ threadId, selectBy, format, }: StorageGetMessagesArg & {
|
|
149
|
+
format?: 'v1' | 'v2';
|
|
150
|
+
}): Promise<PaginationInfo & {
|
|
151
|
+
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
152
|
+
}>;
|
|
138
153
|
persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
|
|
139
154
|
workflowName: string;
|
|
140
155
|
runId: string;
|
|
@@ -153,21 +168,57 @@ declare class D1Store extends MastraStorage {
|
|
|
153
168
|
tableName: TABLE_NAMES;
|
|
154
169
|
records: Record<string, any>[];
|
|
155
170
|
}): Promise<void>;
|
|
156
|
-
|
|
171
|
+
/**
|
|
172
|
+
* @deprecated use getTracesPaginated instead
|
|
173
|
+
*/
|
|
174
|
+
getTraces({ name, scope, page, perPage, attributes, fromDate, toDate, }: {
|
|
157
175
|
name?: string;
|
|
158
176
|
scope?: string;
|
|
159
177
|
page: number;
|
|
160
178
|
perPage: number;
|
|
161
179
|
attributes?: Record<string, string>;
|
|
162
|
-
|
|
180
|
+
fromDate?: Date;
|
|
181
|
+
toDate?: Date;
|
|
182
|
+
}): Promise<Trace[]>;
|
|
183
|
+
getTracesPaginated(args: {
|
|
184
|
+
name?: string;
|
|
185
|
+
scope?: string;
|
|
186
|
+
attributes?: Record<string, string>;
|
|
187
|
+
page: number;
|
|
188
|
+
perPage: number;
|
|
189
|
+
fromDate?: Date;
|
|
190
|
+
toDate?: Date;
|
|
191
|
+
}): Promise<PaginationInfo & {
|
|
192
|
+
traces: Trace[];
|
|
193
|
+
}>;
|
|
194
|
+
/**
|
|
195
|
+
* @deprecated use getEvals instead
|
|
196
|
+
*/
|
|
163
197
|
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
164
|
-
|
|
198
|
+
getEvals(options?: {
|
|
199
|
+
agentName?: string;
|
|
200
|
+
type?: 'test' | 'live';
|
|
201
|
+
page?: number;
|
|
202
|
+
perPage?: number;
|
|
203
|
+
fromDate?: Date;
|
|
204
|
+
toDate?: Date;
|
|
205
|
+
}): Promise<PaginationInfo & {
|
|
206
|
+
evals: EvalRow[];
|
|
207
|
+
}>;
|
|
208
|
+
private parseWorkflowRun;
|
|
209
|
+
private hasColumn;
|
|
210
|
+
getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
|
|
165
211
|
workflowName?: string;
|
|
166
212
|
fromDate?: Date;
|
|
167
213
|
toDate?: Date;
|
|
168
214
|
limit?: number;
|
|
169
215
|
offset?: number;
|
|
216
|
+
resourceId?: string;
|
|
170
217
|
}): Promise<WorkflowRuns>;
|
|
218
|
+
getWorkflowRunById({ runId, workflowName, }: {
|
|
219
|
+
runId: string;
|
|
220
|
+
workflowName?: string;
|
|
221
|
+
}): Promise<WorkflowRun | null>;
|
|
171
222
|
/**
|
|
172
223
|
* Close the database connection
|
|
173
224
|
* No explicit cleanup needed for D1 in either REST or Workers Binding mode
|
|
@@ -196,9 +247,30 @@ declare interface D1WorkersConfig {
|
|
|
196
247
|
export { D1WorkersConfig }
|
|
197
248
|
export { D1WorkersConfig as D1WorkersConfig_alias_1 }
|
|
198
249
|
|
|
250
|
+
/**
|
|
251
|
+
* Parses and returns a valid SQL SELECT column identifier.
|
|
252
|
+
* Allows a single identifier (letters, numbers, underscores), or '*', optionally with 'AS alias'.
|
|
253
|
+
*
|
|
254
|
+
* @param column - The column identifier string to parse.
|
|
255
|
+
* @returns The validated column identifier as a branded type.
|
|
256
|
+
* @throws {Error} If invalid.
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* const col = parseSelectIdentifier('user_id'); // Ok
|
|
260
|
+
* parseSelectIdentifier('user_id AS uid'); // Ok
|
|
261
|
+
* parseSelectIdentifier('*'); // Ok
|
|
262
|
+
* parseSelectIdentifier('user id'); // Throws error
|
|
263
|
+
*/
|
|
264
|
+
export declare function parseSelectIdentifier(column: string): SelectIdentifier;
|
|
265
|
+
|
|
199
266
|
export declare const retryUntil: <T>(fn: () => Promise<T>, condition: (result: T) => boolean, timeout?: number, // REST API needs longer timeout due to higher latency
|
|
200
267
|
interval?: number) => Promise<T>;
|
|
201
268
|
|
|
269
|
+
/** Represents a validated SQL SELECT column identifier (or '*', optionally with 'AS alias'). */
|
|
270
|
+
declare type SelectIdentifier = string & {
|
|
271
|
+
__brand: 'SelectIdentifier';
|
|
272
|
+
};
|
|
273
|
+
|
|
202
274
|
/**
|
|
203
275
|
* SQL Builder class for constructing type-safe SQL queries
|
|
204
276
|
* This helps create maintainable and secure SQL queries with proper parameter handling
|
|
@@ -226,6 +298,7 @@ export declare class SqlBuilder {
|
|
|
226
298
|
orderBy(column: string, direction?: 'ASC' | 'DESC'): SqlBuilder;
|
|
227
299
|
limit(count: number): SqlBuilder;
|
|
228
300
|
offset(count: number): SqlBuilder;
|
|
301
|
+
count(): SqlBuilder;
|
|
229
302
|
/**
|
|
230
303
|
* Insert a row, or update specific columns on conflict (upsert).
|
|
231
304
|
* @param table Table name
|
|
@@ -261,7 +334,6 @@ export declare class SqlBuilder {
|
|
|
261
334
|
* @returns The builder instance
|
|
262
335
|
*/
|
|
263
336
|
createIndex(indexName: string, tableName: string, columnName: string, indexType?: string): SqlBuilder;
|
|
264
|
-
raw(sql: string, ...params: SqlParam[]): SqlBuilder;
|
|
265
337
|
/**
|
|
266
338
|
* Add a LIKE condition to the query
|
|
267
339
|
* @param column The column to check
|
|
@@ -299,7 +371,7 @@ export declare type SqlParam = string | number | boolean | null | undefined;
|
|
|
299
371
|
/**
|
|
300
372
|
* Interface for SQL query options with generic type support
|
|
301
373
|
*/
|
|
302
|
-
declare interface SqlQueryOptions {
|
|
374
|
+
export declare interface SqlQueryOptions {
|
|
303
375
|
/** SQL query to execute */
|
|
304
376
|
sql: string;
|
|
305
377
|
/** Parameters to bind to the query */
|
|
@@ -307,7 +379,5 @@ declare interface SqlQueryOptions {
|
|
|
307
379
|
/** Whether to return only the first result */
|
|
308
380
|
first?: boolean;
|
|
309
381
|
}
|
|
310
|
-
export { SqlQueryOptions }
|
|
311
|
-
export { SqlQueryOptions as SqlQueryOptions_alias_1 }
|
|
312
382
|
|
|
313
383
|
export { }
|