@mastra/cloudflare-d1 0.0.0-tsconfig-compile-20250703214351 → 0.0.0-update-stores-peerDeps-20250723031338
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/README.md +15 -0
- package/dist/_tsup-dts-rollup.d.cts +367 -60
- package/dist/_tsup-dts-rollup.d.ts +367 -60
- package/dist/index.cjs +1401 -684
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1402 -685
- package/package.json +9 -9
|
@@ -1,18 +1,32 @@
|
|
|
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 { LegacyEvalsStorage } from '@mastra/core/storage';
|
|
3
5
|
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
4
6
|
import type { MastraMessageV1 } from '@mastra/core/memory';
|
|
5
7
|
import type { MastraMessageV2 } from '@mastra/core/memory';
|
|
6
8
|
import { MastraStorage } from '@mastra/core/storage';
|
|
9
|
+
import { MemoryStorage } from '@mastra/core/storage';
|
|
10
|
+
import type { PaginationArgs } from '@mastra/core/storage';
|
|
7
11
|
import type { PaginationInfo } from '@mastra/core/storage';
|
|
12
|
+
import type { ScoreRowData } from '@mastra/core/scores';
|
|
13
|
+
import { ScoresStorage } from '@mastra/core/storage';
|
|
8
14
|
import type { StorageColumn } from '@mastra/core/storage';
|
|
15
|
+
import type { StorageDomains } from '@mastra/core/storage';
|
|
9
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';
|
|
10
21
|
import type { StorageThreadType } from '@mastra/core/memory';
|
|
22
|
+
import { StoreOperations } from '@mastra/core/storage';
|
|
11
23
|
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
12
24
|
import type { Trace } from '@mastra/core/telemetry';
|
|
25
|
+
import { TracesStorage } from '@mastra/core/storage';
|
|
13
26
|
import type { WorkflowRun } from '@mastra/core/storage';
|
|
14
27
|
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
15
28
|
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
29
|
+
import { WorkflowsStorage } from '@mastra/core/storage';
|
|
16
30
|
|
|
17
31
|
export declare const createSampleTrace: (name: string, scope?: string, attributes?: Record<string, string>) => {
|
|
18
32
|
id: string;
|
|
@@ -33,6 +47,44 @@ export declare const createSampleTrace: (name: string, scope?: string, attribute
|
|
|
33
47
|
|
|
34
48
|
export declare function createSqlBuilder(): SqlBuilder;
|
|
35
49
|
|
|
50
|
+
declare interface D1Client {
|
|
51
|
+
query(args: {
|
|
52
|
+
sql: string;
|
|
53
|
+
params: string[];
|
|
54
|
+
}): Promise<{
|
|
55
|
+
result: D1QueryResult;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
export { D1Client }
|
|
59
|
+
export { D1Client as D1Client_alias_1 }
|
|
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
|
+
|
|
79
|
+
declare interface D1ClientConfig {
|
|
80
|
+
/** Optional prefix for table names */
|
|
81
|
+
tablePrefix?: string;
|
|
82
|
+
/** D1 Client */
|
|
83
|
+
client: D1Client;
|
|
84
|
+
}
|
|
85
|
+
export { D1ClientConfig }
|
|
86
|
+
export { D1ClientConfig as D1ClientConfig_alias_1 }
|
|
87
|
+
|
|
36
88
|
/**
|
|
37
89
|
* Configuration for D1 using the REST API
|
|
38
90
|
*/
|
|
@@ -49,31 +101,30 @@ declare interface D1Config {
|
|
|
49
101
|
export { D1Config }
|
|
50
102
|
export { D1Config as D1Config_alias_1 }
|
|
51
103
|
|
|
104
|
+
declare type D1QueryResult = Awaited<ReturnType<Cloudflare_2['d1']['database']['query']>>['result'];
|
|
105
|
+
export { D1QueryResult }
|
|
106
|
+
export { D1QueryResult as D1QueryResult_alias_1 }
|
|
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
|
+
|
|
52
112
|
declare class D1Store extends MastraStorage {
|
|
53
113
|
private client?;
|
|
54
|
-
private accountId?;
|
|
55
|
-
private databaseId?;
|
|
56
114
|
private binding?;
|
|
57
115
|
private tablePrefix;
|
|
116
|
+
stores: StorageDomains;
|
|
58
117
|
/**
|
|
59
118
|
* Creates a new D1Store instance
|
|
60
119
|
* @param config Configuration for D1 access (either REST API or Workers Binding API)
|
|
61
120
|
*/
|
|
62
121
|
constructor(config: D1StoreConfig);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
* @param options Query options including SQL, parameters, and whether to return only the first result
|
|
70
|
-
* @returns Query results as an array or a single object if first=true
|
|
71
|
-
*/
|
|
72
|
-
private executeQuery;
|
|
73
|
-
private getTableColumns;
|
|
74
|
-
private serializeValue;
|
|
75
|
-
private deserializeValue;
|
|
76
|
-
protected getSqlType(type: StorageColumn['type']): string;
|
|
122
|
+
get supports(): {
|
|
123
|
+
selectByIncludeResourceScope: boolean;
|
|
124
|
+
resourceWorkingMemory: boolean;
|
|
125
|
+
hasColumn: boolean;
|
|
126
|
+
createTable: boolean;
|
|
127
|
+
};
|
|
77
128
|
createTable({ tableName, schema, }: {
|
|
78
129
|
tableName: TABLE_NAMES;
|
|
79
130
|
schema: Record<string, StorageColumn>;
|
|
@@ -92,7 +143,10 @@ declare class D1Store extends MastraStorage {
|
|
|
92
143
|
clearTable({ tableName }: {
|
|
93
144
|
tableName: TABLE_NAMES;
|
|
94
145
|
}): Promise<void>;
|
|
95
|
-
|
|
146
|
+
dropTable({ tableName }: {
|
|
147
|
+
tableName: TABLE_NAMES;
|
|
148
|
+
}): Promise<void>;
|
|
149
|
+
hasColumn(table: string, column: string): Promise<boolean>;
|
|
96
150
|
insert({ tableName, record }: {
|
|
97
151
|
tableName: TABLE_NAMES;
|
|
98
152
|
record: Record<string, any>;
|
|
@@ -136,7 +190,6 @@ declare class D1Store extends MastraStorage {
|
|
|
136
190
|
messages: MastraMessageV2[];
|
|
137
191
|
format: 'v2';
|
|
138
192
|
}): Promise<MastraMessageV2[]>;
|
|
139
|
-
private _getIncludedMessages;
|
|
140
193
|
/**
|
|
141
194
|
* @deprecated use getMessagesPaginated instead
|
|
142
195
|
*/
|
|
@@ -160,6 +213,18 @@ declare class D1Store extends MastraStorage {
|
|
|
160
213
|
workflowName: string;
|
|
161
214
|
runId: string;
|
|
162
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>;
|
|
163
228
|
/**
|
|
164
229
|
* Insert multiple records in a batch operation
|
|
165
230
|
* @param tableName The table to insert into
|
|
@@ -169,16 +234,10 @@ declare class D1Store extends MastraStorage {
|
|
|
169
234
|
tableName: TABLE_NAMES;
|
|
170
235
|
records: Record<string, any>[];
|
|
171
236
|
}): Promise<void>;
|
|
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
237
|
/**
|
|
179
238
|
* @deprecated use getTracesPaginated instead
|
|
180
239
|
*/
|
|
181
|
-
getTraces(
|
|
240
|
+
getTraces(args: {
|
|
182
241
|
name?: string;
|
|
183
242
|
scope?: string;
|
|
184
243
|
page: number;
|
|
@@ -187,50 +246,19 @@ declare class D1Store extends MastraStorage {
|
|
|
187
246
|
fromDate?: Date;
|
|
188
247
|
toDate?: Date;
|
|
189
248
|
}): 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 & {
|
|
249
|
+
getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
|
|
199
250
|
traces: Trace[];
|
|
200
251
|
}>;
|
|
201
252
|
/**
|
|
202
253
|
* @deprecated use getEvals instead
|
|
203
254
|
*/
|
|
204
255
|
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
205
|
-
getEvals(options
|
|
256
|
+
getEvals(options: {
|
|
206
257
|
agentName?: string;
|
|
207
258
|
type?: 'test' | 'live';
|
|
208
|
-
|
|
209
|
-
perPage?: number;
|
|
210
|
-
fromDate?: Date;
|
|
211
|
-
toDate?: Date;
|
|
212
|
-
}): Promise<PaginationInfo & {
|
|
259
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
213
260
|
evals: EvalRow[];
|
|
214
261
|
}>;
|
|
215
|
-
private parseWorkflowRun;
|
|
216
|
-
private hasColumn;
|
|
217
|
-
getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
|
|
218
|
-
workflowName?: string;
|
|
219
|
-
fromDate?: Date;
|
|
220
|
-
toDate?: Date;
|
|
221
|
-
limit?: number;
|
|
222
|
-
offset?: number;
|
|
223
|
-
resourceId?: string;
|
|
224
|
-
}): Promise<WorkflowRuns>;
|
|
225
|
-
getWorkflowRunById({ runId, workflowName, }: {
|
|
226
|
-
runId: string;
|
|
227
|
-
workflowName?: string;
|
|
228
|
-
}): Promise<WorkflowRun | null>;
|
|
229
|
-
/**
|
|
230
|
-
* Close the database connection
|
|
231
|
-
* No explicit cleanup needed for D1 in either REST or Workers Binding mode
|
|
232
|
-
*/
|
|
233
|
-
close(): Promise<void>;
|
|
234
262
|
updateMessages(_args: {
|
|
235
263
|
messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
236
264
|
id: string;
|
|
@@ -240,6 +268,50 @@ declare class D1Store extends MastraStorage {
|
|
|
240
268
|
};
|
|
241
269
|
}[];
|
|
242
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>;
|
|
243
315
|
}
|
|
244
316
|
export { D1Store }
|
|
245
317
|
export { D1Store as D1Store_alias_1 }
|
|
@@ -247,7 +319,7 @@ export { D1Store as D1Store_alias_1 }
|
|
|
247
319
|
/**
|
|
248
320
|
* Combined configuration type supporting both REST API and Workers Binding API
|
|
249
321
|
*/
|
|
250
|
-
declare type D1StoreConfig = D1Config | D1WorkersConfig;
|
|
322
|
+
declare type D1StoreConfig = D1Config | D1WorkersConfig | D1ClientConfig;
|
|
251
323
|
export { D1StoreConfig }
|
|
252
324
|
export { D1StoreConfig as D1StoreConfig_alias_1 }
|
|
253
325
|
|
|
@@ -263,6 +335,104 @@ declare interface D1WorkersConfig {
|
|
|
263
335
|
export { D1WorkersConfig }
|
|
264
336
|
export { D1WorkersConfig as D1WorkersConfig_alias_1 }
|
|
265
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
|
+
|
|
266
436
|
/**
|
|
267
437
|
* Parses and returns a valid SQL SELECT column identifier.
|
|
268
438
|
* Allows a single identifier (letters, numbers, underscores), or '*', optionally with 'AS alias'.
|
|
@@ -282,6 +452,41 @@ export declare function parseSelectIdentifier(column: string): SelectIdentifier;
|
|
|
282
452
|
export declare const retryUntil: <T>(fn: () => Promise<T>, condition: (result: T) => boolean, timeout?: number, // REST API needs longer timeout due to higher latency
|
|
283
453
|
interval?: number) => Promise<T>;
|
|
284
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
|
+
|
|
285
490
|
/** Represents a validated SQL SELECT column identifier (or '*', optionally with 'AS alias'). */
|
|
286
491
|
declare type SelectIdentifier = string & {
|
|
287
492
|
__brand: 'SelectIdentifier';
|
|
@@ -396,4 +601,106 @@ export declare interface SqlQueryOptions {
|
|
|
396
601
|
first?: boolean;
|
|
397
602
|
}
|
|
398
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
|
+
|
|
399
706
|
export { }
|