@mastra/cloudflare-d1 0.12.4 → 0.12.5

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.
@@ -1,707 +0,0 @@
1
- import { default as Cloudflare_2 } from 'cloudflare';
2
- import type { D1Database as D1Database_2 } from '@cloudflare/workers-types';
3
- import type { EvalRow } from '@mastra/core/storage';
4
- import { LegacyEvalsStorage } from '@mastra/core/storage';
5
- import type { MastraMessageContentV2 } from '@mastra/core/agent';
6
- import type { MastraMessageV1 } from '@mastra/core/memory';
7
- import type { MastraMessageV2 } from '@mastra/core/memory';
8
- import { MastraStorage } from '@mastra/core/storage';
9
- import { MemoryStorage } from '@mastra/core/storage';
10
- import type { PaginationArgs } from '@mastra/core/storage';
11
- import type { PaginationInfo } from '@mastra/core/storage';
12
- import type { ScoreRowData } from '@mastra/core/scores';
13
- import { ScoresStorage } from '@mastra/core/storage';
14
- import type { StorageColumn } from '@mastra/core/storage';
15
- import type { StorageDomains } from '@mastra/core/storage';
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';
21
- import type { StorageThreadType } from '@mastra/core/memory';
22
- import { StoreOperations } from '@mastra/core/storage';
23
- import type { TABLE_NAMES } from '@mastra/core/storage';
24
- import type { Trace } from '@mastra/core/telemetry';
25
- import { TracesStorage } from '@mastra/core/storage';
26
- import type { WorkflowRun } from '@mastra/core/storage';
27
- import type { WorkflowRuns } from '@mastra/core/storage';
28
- import type { WorkflowRunState } from '@mastra/core/workflows';
29
- import { WorkflowsStorage } from '@mastra/core/storage';
30
-
31
- export declare const createSampleTrace: (name: string, scope?: string, attributes?: Record<string, string>) => {
32
- id: string;
33
- parentSpanId: string;
34
- traceId: string;
35
- name: string;
36
- scope: string | undefined;
37
- kind: string;
38
- status: string;
39
- events: string;
40
- links: string;
41
- attributes: string | undefined;
42
- startTime: string;
43
- endTime: string;
44
- other: string;
45
- createdAt: string;
46
- };
47
-
48
- export declare function createSqlBuilder(): SqlBuilder;
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
-
88
- /**
89
- * Configuration for D1 using the REST API
90
- */
91
- declare interface D1Config {
92
- /** Cloudflare account ID */
93
- accountId: string;
94
- /** Cloudflare API token with D1 access */
95
- apiToken: string;
96
- /** D1 database ID */
97
- databaseId: string;
98
- /** Optional prefix for table names */
99
- tablePrefix?: string;
100
- }
101
- export { D1Config }
102
- export { D1Config as D1Config_alias_1 }
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
-
112
- declare class D1Store extends MastraStorage {
113
- private client?;
114
- private binding?;
115
- private tablePrefix;
116
- stores: StorageDomains;
117
- /**
118
- * Creates a new D1Store instance
119
- * @param config Configuration for D1 access (either REST API or Workers Binding API)
120
- */
121
- constructor(config: D1StoreConfig);
122
- get supports(): {
123
- selectByIncludeResourceScope: boolean;
124
- resourceWorkingMemory: boolean;
125
- hasColumn: boolean;
126
- createTable: boolean;
127
- deleteMessages: boolean;
128
- };
129
- createTable({ tableName, schema, }: {
130
- tableName: TABLE_NAMES;
131
- schema: Record<string, StorageColumn>;
132
- }): Promise<void>;
133
- /**
134
- * Alters table schema to add columns if they don't exist
135
- * @param tableName Name of the table
136
- * @param schema Schema of the table
137
- * @param ifNotExists Array of column names to add if they don't exist
138
- */
139
- alterTable({ tableName, schema, ifNotExists, }: {
140
- tableName: TABLE_NAMES;
141
- schema: Record<string, StorageColumn>;
142
- ifNotExists: string[];
143
- }): Promise<void>;
144
- clearTable({ tableName }: {
145
- tableName: TABLE_NAMES;
146
- }): Promise<void>;
147
- dropTable({ tableName }: {
148
- tableName: TABLE_NAMES;
149
- }): Promise<void>;
150
- hasColumn(table: string, column: string): Promise<boolean>;
151
- insert({ tableName, record }: {
152
- tableName: TABLE_NAMES;
153
- record: Record<string, any>;
154
- }): Promise<void>;
155
- load<R>({ tableName, keys }: {
156
- tableName: TABLE_NAMES;
157
- keys: Record<string, string>;
158
- }): Promise<R | null>;
159
- getThreadById({ threadId }: {
160
- threadId: string;
161
- }): Promise<StorageThreadType | null>;
162
- /**
163
- * @deprecated use getThreadsByResourceIdPaginated instead
164
- */
165
- getThreadsByResourceId({ resourceId }: {
166
- resourceId: string;
167
- }): Promise<StorageThreadType[]>;
168
- getThreadsByResourceIdPaginated(args: {
169
- resourceId: string;
170
- page: number;
171
- perPage: number;
172
- }): Promise<PaginationInfo & {
173
- threads: StorageThreadType[];
174
- }>;
175
- saveThread({ thread }: {
176
- thread: StorageThreadType;
177
- }): Promise<StorageThreadType>;
178
- updateThread({ id, title, metadata, }: {
179
- id: string;
180
- title: string;
181
- metadata: Record<string, unknown>;
182
- }): Promise<StorageThreadType>;
183
- deleteThread({ threadId }: {
184
- threadId: string;
185
- }): Promise<void>;
186
- saveMessages(args: {
187
- messages: MastraMessageV1[];
188
- format?: undefined | 'v1';
189
- }): Promise<MastraMessageV1[]>;
190
- saveMessages(args: {
191
- messages: MastraMessageV2[];
192
- format: 'v2';
193
- }): Promise<MastraMessageV2[]>;
194
- /**
195
- * @deprecated use getMessagesPaginated instead
196
- */
197
- getMessages(args: StorageGetMessagesArg & {
198
- format?: 'v1';
199
- }): Promise<MastraMessageV1[]>;
200
- getMessages(args: StorageGetMessagesArg & {
201
- format: 'v2';
202
- }): Promise<MastraMessageV2[]>;
203
- getMessagesPaginated({ threadId, selectBy, format, }: StorageGetMessagesArg & {
204
- format?: 'v1' | 'v2';
205
- }): Promise<PaginationInfo & {
206
- messages: MastraMessageV1[] | MastraMessageV2[];
207
- }>;
208
- persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
209
- workflowName: string;
210
- runId: string;
211
- snapshot: WorkflowRunState;
212
- }): Promise<void>;
213
- loadWorkflowSnapshot(params: {
214
- workflowName: string;
215
- runId: string;
216
- }): Promise<WorkflowRunState | null>;
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
- * Insert multiple records in a batch operation
231
- * @param tableName The table to insert into
232
- * @param records The records to insert
233
- */
234
- batchInsert({ tableName, records }: {
235
- tableName: TABLE_NAMES;
236
- records: Record<string, any>[];
237
- }): Promise<void>;
238
- /**
239
- * @deprecated use getTracesPaginated instead
240
- */
241
- getTraces(args: {
242
- name?: string;
243
- scope?: string;
244
- page: number;
245
- perPage: number;
246
- attributes?: Record<string, string>;
247
- fromDate?: Date;
248
- toDate?: Date;
249
- }): Promise<Trace[]>;
250
- getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
251
- traces: Trace[];
252
- }>;
253
- /**
254
- * @deprecated use getEvals instead
255
- */
256
- getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
257
- getEvals(options: {
258
- agentName?: string;
259
- type?: 'test' | 'live';
260
- } & PaginationArgs): Promise<PaginationInfo & {
261
- evals: EvalRow[];
262
- }>;
263
- updateMessages(_args: {
264
- messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
265
- id: string;
266
- content?: {
267
- metadata?: MastraMessageContentV2['metadata'];
268
- content?: MastraMessageContentV2['content'];
269
- };
270
- }[];
271
- }): Promise<MastraMessageV2[]>;
272
- getResourceById({ resourceId }: {
273
- resourceId: string;
274
- }): Promise<StorageResourceType | null>;
275
- saveResource({ resource }: {
276
- resource: StorageResourceType;
277
- }): Promise<StorageResourceType>;
278
- updateResource({ resourceId, workingMemory, metadata, }: {
279
- resourceId: string;
280
- workingMemory?: string;
281
- metadata?: Record<string, unknown>;
282
- }): Promise<StorageResourceType>;
283
- getScoreById({ id: _id }: {
284
- id: string;
285
- }): Promise<ScoreRowData | null>;
286
- saveScore(_score: ScoreRowData): Promise<{
287
- score: ScoreRowData;
288
- }>;
289
- getScoresByRunId({ runId: _runId, pagination: _pagination, }: {
290
- runId: string;
291
- pagination: StoragePagination;
292
- }): Promise<{
293
- pagination: PaginationInfo;
294
- scores: ScoreRowData[];
295
- }>;
296
- getScoresByEntityId({ entityId: _entityId, entityType: _entityType, pagination: _pagination, }: {
297
- pagination: StoragePagination;
298
- entityId: string;
299
- entityType: string;
300
- }): Promise<{
301
- pagination: PaginationInfo;
302
- scores: ScoreRowData[];
303
- }>;
304
- getScoresByScorerId({ scorerId: _scorerId, pagination: _pagination, }: {
305
- scorerId: string;
306
- pagination: StoragePagination;
307
- }): Promise<{
308
- pagination: PaginationInfo;
309
- scores: ScoreRowData[];
310
- }>;
311
- /**
312
- * Close the database connection
313
- * No explicit cleanup needed for D1 in either REST or Workers Binding mode
314
- */
315
- close(): Promise<void>;
316
- }
317
- export { D1Store }
318
- export { D1Store as D1Store_alias_1 }
319
-
320
- /**
321
- * Combined configuration type supporting both REST API and Workers Binding API
322
- */
323
- declare type D1StoreConfig = D1Config | D1WorkersConfig | D1ClientConfig;
324
- export { D1StoreConfig }
325
- export { D1StoreConfig as D1StoreConfig_alias_1 }
326
-
327
- /**
328
- * Configuration for D1 using the Workers Binding API
329
- */
330
- declare interface D1WorkersConfig {
331
- /** D1 database binding from Workers environment */
332
- binding: D1Database_2;
333
- /** Optional prefix for table names */
334
- tablePrefix?: string;
335
- }
336
- export { D1WorkersConfig }
337
- export { D1WorkersConfig as D1WorkersConfig_alias_1 }
338
-
339
- export declare function deserializeValue(value: any, type?: string): any;
340
-
341
- export declare function isArrayOfRecords(value: any): value is Record<string, any>[];
342
-
343
- export declare class LegacyEvalsStorageD1 extends LegacyEvalsStorage {
344
- private operations;
345
- constructor({ operations }: {
346
- operations: StoreOperationsD1;
347
- });
348
- getEvals(options: {
349
- agentName?: string;
350
- type?: 'test' | 'live';
351
- } & PaginationArgs): Promise<PaginationInfo & {
352
- evals: EvalRow[];
353
- }>;
354
- /**
355
- * @deprecated use getEvals instead
356
- */
357
- getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
358
- }
359
-
360
- export declare class MemoryStorageD1 extends MemoryStorage {
361
- private operations;
362
- constructor({ operations }: {
363
- operations: StoreOperationsD1;
364
- });
365
- getResourceById({ resourceId }: {
366
- resourceId: string;
367
- }): Promise<StorageResourceType | null>;
368
- saveResource({ resource }: {
369
- resource: StorageResourceType;
370
- }): Promise<StorageResourceType>;
371
- updateResource({ resourceId, workingMemory, metadata, }: {
372
- resourceId: string;
373
- workingMemory?: string;
374
- metadata?: Record<string, unknown>;
375
- }): Promise<StorageResourceType>;
376
- getThreadById({ threadId }: {
377
- threadId: string;
378
- }): Promise<StorageThreadType | null>;
379
- /**
380
- * @deprecated use getThreadsByResourceIdPaginated instead
381
- */
382
- getThreadsByResourceId({ resourceId }: {
383
- resourceId: string;
384
- }): Promise<StorageThreadType[]>;
385
- getThreadsByResourceIdPaginated(args: {
386
- resourceId: string;
387
- page: number;
388
- perPage: number;
389
- }): Promise<PaginationInfo & {
390
- threads: StorageThreadType[];
391
- }>;
392
- saveThread({ thread }: {
393
- thread: StorageThreadType;
394
- }): Promise<StorageThreadType>;
395
- updateThread({ id, title, metadata, }: {
396
- id: string;
397
- title: string;
398
- metadata: Record<string, unknown>;
399
- }): Promise<StorageThreadType>;
400
- deleteThread({ threadId }: {
401
- threadId: string;
402
- }): Promise<void>;
403
- saveMessages(args: {
404
- messages: MastraMessageV1[];
405
- format?: undefined | 'v1';
406
- }): Promise<MastraMessageV1[]>;
407
- saveMessages(args: {
408
- messages: MastraMessageV2[];
409
- format: 'v2';
410
- }): Promise<MastraMessageV2[]>;
411
- private _getIncludedMessages;
412
- /**
413
- * @deprecated use getMessagesPaginated instead
414
- */
415
- getMessages(args: StorageGetMessagesArg & {
416
- format?: 'v1';
417
- }): Promise<MastraMessageV1[]>;
418
- getMessages(args: StorageGetMessagesArg & {
419
- format: 'v2';
420
- }): Promise<MastraMessageV2[]>;
421
- getMessagesPaginated({ threadId, selectBy, format, }: StorageGetMessagesArg & {
422
- format?: 'v1' | 'v2';
423
- }): Promise<PaginationInfo & {
424
- messages: MastraMessageV1[] | MastraMessageV2[];
425
- }>;
426
- updateMessages(args: {
427
- messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
428
- id: string;
429
- content?: {
430
- metadata?: MastraMessageContentV2['metadata'];
431
- content?: MastraMessageContentV2['content'];
432
- };
433
- }[];
434
- }): Promise<MastraMessageV2[]>;
435
- }
436
-
437
- /**
438
- * Parses and returns a valid SQL SELECT column identifier.
439
- * Allows a single identifier (letters, numbers, underscores), or '*', optionally with 'AS alias'.
440
- *
441
- * @param column - The column identifier string to parse.
442
- * @returns The validated column identifier as a branded type.
443
- * @throws {Error} If invalid.
444
- *
445
- * @example
446
- * const col = parseSelectIdentifier('user_id'); // Ok
447
- * parseSelectIdentifier('user_id AS uid'); // Ok
448
- * parseSelectIdentifier('*'); // Ok
449
- * parseSelectIdentifier('user id'); // Throws error
450
- */
451
- export declare function parseSelectIdentifier(column: string): SelectIdentifier;
452
-
453
- export declare const retryUntil: <T>(fn: () => Promise<T>, condition: (result: T) => boolean, timeout?: number, // REST API needs longer timeout due to higher latency
454
- interval?: number) => Promise<T>;
455
-
456
- export declare class ScoresStorageD1 extends ScoresStorage {
457
- private operations;
458
- constructor({ operations }: {
459
- operations: StoreOperationsD1;
460
- });
461
- getScoreById({ id }: {
462
- id: string;
463
- }): Promise<ScoreRowData | null>;
464
- saveScore(score: Omit<ScoreRowData, 'createdAt' | 'updatedAt'>): Promise<{
465
- score: ScoreRowData;
466
- }>;
467
- getScoresByScorerId({ scorerId, pagination, }: {
468
- scorerId: string;
469
- pagination: StoragePagination;
470
- }): Promise<{
471
- pagination: PaginationInfo;
472
- scores: ScoreRowData[];
473
- }>;
474
- getScoresByRunId({ runId, pagination, }: {
475
- runId: string;
476
- pagination: StoragePagination;
477
- }): Promise<{
478
- pagination: PaginationInfo;
479
- scores: ScoreRowData[];
480
- }>;
481
- getScoresByEntityId({ entityId, entityType, pagination, }: {
482
- pagination: StoragePagination;
483
- entityId: string;
484
- entityType: string;
485
- }): Promise<{
486
- pagination: PaginationInfo;
487
- scores: ScoreRowData[];
488
- }>;
489
- }
490
-
491
- /** Represents a validated SQL SELECT column identifier (or '*', optionally with 'AS alias'). */
492
- declare type SelectIdentifier = string & {
493
- __brand: 'SelectIdentifier';
494
- };
495
-
496
- /**
497
- * SQL Builder class for constructing type-safe SQL queries
498
- * This helps create maintainable and secure SQL queries with proper parameter handling
499
- */
500
- export declare class SqlBuilder {
501
- private sql;
502
- private params;
503
- private whereAdded;
504
- select(columns?: string | string[]): SqlBuilder;
505
- from(table: string): SqlBuilder;
506
- /**
507
- * Add a WHERE clause to the query
508
- * @param condition The condition to add
509
- * @param params Parameters to bind to the condition
510
- */
511
- where(condition: string, ...params: SqlParam[]): SqlBuilder;
512
- /**
513
- * Add a WHERE clause if it hasn't been added yet, otherwise add an AND clause
514
- * @param condition The condition to add
515
- * @param params Parameters to bind to the condition
516
- */
517
- whereAnd(condition: string, ...params: SqlParam[]): SqlBuilder;
518
- andWhere(condition: string, ...params: SqlParam[]): SqlBuilder;
519
- orWhere(condition: string, ...params: SqlParam[]): SqlBuilder;
520
- orderBy(column: string, direction?: 'ASC' | 'DESC'): SqlBuilder;
521
- limit(count: number): SqlBuilder;
522
- offset(count: number): SqlBuilder;
523
- count(): SqlBuilder;
524
- /**
525
- * Insert a row, or update specific columns on conflict (upsert).
526
- * @param table Table name
527
- * @param columns Columns to insert
528
- * @param values Values to insert
529
- * @param conflictColumns Columns to check for conflict (usually PK or UNIQUE)
530
- * @param updateMap Object mapping columns to update to their new value (e.g. { name: 'excluded.name' })
531
- */
532
- insert(table: string, columns: string[], values: SqlParam[], conflictColumns?: string[], updateMap?: Record<string, string>): SqlBuilder;
533
- update(table: string, columns: string[], values: SqlParam[]): SqlBuilder;
534
- delete(table: string): SqlBuilder;
535
- /**
536
- * Create a table if it doesn't exist
537
- * @param table The table name
538
- * @param columnDefinitions The column definitions as an array of strings
539
- * @param tableConstraints Optional constraints for the table
540
- * @returns The builder instance
541
- */
542
- createTable(table: string, columnDefinitions: string[], tableConstraints?: string[]): SqlBuilder;
543
- /**
544
- * Check if an index exists in the database
545
- * @param indexName The name of the index to check
546
- * @param tableName The table the index is on
547
- * @returns The builder instance
548
- */
549
- checkIndexExists(indexName: string, tableName: string): SqlBuilder;
550
- /**
551
- * Create an index if it doesn't exist
552
- * @param indexName The name of the index to create
553
- * @param tableName The table to create the index on
554
- * @param columnName The column to index
555
- * @param indexType Optional index type (e.g., 'UNIQUE')
556
- * @returns The builder instance
557
- */
558
- createIndex(indexName: string, tableName: string, columnName: string, indexType?: string): SqlBuilder;
559
- /**
560
- * Add a LIKE condition to the query
561
- * @param column The column to check
562
- * @param value The value to match (will be wrapped with % for LIKE)
563
- * @param exact If true, will not add % wildcards
564
- */
565
- like(column: string, value: string, exact?: boolean): SqlBuilder;
566
- /**
567
- * Add a JSON LIKE condition for searching in JSON fields
568
- * @param column The JSON column to search in
569
- * @param key The JSON key to match
570
- * @param value The value to match
571
- */
572
- jsonLike(column: string, key: string, value: string): SqlBuilder;
573
- /**
574
- * Get the built query
575
- * @returns Object containing the SQL string and parameters array
576
- */
577
- build(): {
578
- sql: string;
579
- params: SqlParam[];
580
- };
581
- /**
582
- * Reset the builder for reuse
583
- * @returns The reset builder instance
584
- */
585
- reset(): SqlBuilder;
586
- }
587
-
588
- /**
589
- * Type definition for SQL query parameters
590
- */
591
- export declare type SqlParam = string | number | boolean | null | undefined;
592
-
593
- /**
594
- * Interface for SQL query options with generic type support
595
- */
596
- export declare interface SqlQueryOptions {
597
- /** SQL query to execute */
598
- sql: string;
599
- /** Parameters to bind to the query */
600
- params?: SqlParam[];
601
- /** Whether to return only the first result */
602
- first?: boolean;
603
- }
604
-
605
- export declare class StoreOperationsD1 extends StoreOperations {
606
- private client?;
607
- private binding?;
608
- private tablePrefix;
609
- constructor(config: StoreOperationsD1Config);
610
- hasColumn(table: string, column: string): Promise<boolean>;
611
- getTableName(tableName: TABLE_NAMES): string;
612
- private formatSqlParams;
613
- private executeWorkersBindingQuery;
614
- private executeRestQuery;
615
- executeQuery(options: SqlQueryOptions): Promise<Record<string, any>[] | Record<string, any> | null>;
616
- private getTableColumns;
617
- private serializeValue;
618
- protected getSqlType(type: StorageColumn['type']): string;
619
- createTable({ tableName, schema, }: {
620
- tableName: TABLE_NAMES;
621
- schema: Record<string, StorageColumn>;
622
- }): Promise<void>;
623
- clearTable({ tableName }: {
624
- tableName: TABLE_NAMES;
625
- }): Promise<void>;
626
- dropTable({ tableName }: {
627
- tableName: TABLE_NAMES;
628
- }): Promise<void>;
629
- alterTable(args: {
630
- tableName: TABLE_NAMES;
631
- schema: Record<string, StorageColumn>;
632
- ifNotExists: string[];
633
- }): Promise<void>;
634
- insert({ tableName, record }: {
635
- tableName: TABLE_NAMES;
636
- record: Record<string, any>;
637
- }): Promise<void>;
638
- batchInsert({ tableName, records }: {
639
- tableName: TABLE_NAMES;
640
- records: Record<string, any>[];
641
- }): Promise<void>;
642
- load<R>({ tableName, keys }: {
643
- tableName: TABLE_NAMES;
644
- keys: Record<string, string>;
645
- }): Promise<R | null>;
646
- processRecord(record: Record<string, any>): Promise<Record<string, any>>;
647
- /**
648
- * Upsert multiple records in a batch operation
649
- * @param tableName The table to insert into
650
- * @param records The records to insert
651
- */
652
- batchUpsert({ tableName, records }: {
653
- tableName: TABLE_NAMES;
654
- records: Record<string, any>[];
655
- }): Promise<void>;
656
- }
657
-
658
- export declare interface StoreOperationsD1Config {
659
- client?: D1Client_alias_2;
660
- binding?: D1Database_2;
661
- tablePrefix?: string;
662
- }
663
-
664
- export declare class TracesStorageD1 extends TracesStorage {
665
- private operations;
666
- constructor({ operations }: {
667
- operations: StoreOperationsD1;
668
- });
669
- getTraces(args: StorageGetTracesArg): Promise<Trace[]>;
670
- getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
671
- traces: Trace[];
672
- }>;
673
- batchTraceInsert({ records }: {
674
- records: Record<string, any>[];
675
- }): Promise<void>;
676
- }
677
-
678
- export declare class WorkflowsStorageD1 extends WorkflowsStorage {
679
- private operations;
680
- constructor({ operations }: {
681
- operations: StoreOperationsD1;
682
- });
683
- persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
684
- workflowName: string;
685
- runId: string;
686
- snapshot: WorkflowRunState;
687
- }): Promise<void>;
688
- loadWorkflowSnapshot(params: {
689
- workflowName: string;
690
- runId: string;
691
- }): Promise<WorkflowRunState | null>;
692
- private parseWorkflowRun;
693
- getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
694
- workflowName?: string;
695
- fromDate?: Date;
696
- toDate?: Date;
697
- limit?: number;
698
- offset?: number;
699
- resourceId?: string;
700
- }): Promise<WorkflowRuns>;
701
- getWorkflowRunById({ runId, workflowName, }: {
702
- runId: string;
703
- workflowName?: string;
704
- }): Promise<WorkflowRun | null>;
705
- }
706
-
707
- export { }