@mastra/cloudflare-d1 0.0.0-update-stores-peerDeps-20250723031338 → 0.0.0-usechat-duplicate-20251016110554

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,706 +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
- };
128
- createTable({ tableName, schema, }: {
129
- tableName: TABLE_NAMES;
130
- schema: Record<string, StorageColumn>;
131
- }): Promise<void>;
132
- /**
133
- * Alters table schema to add columns if they don't exist
134
- * @param tableName Name of the table
135
- * @param schema Schema of the table
136
- * @param ifNotExists Array of column names to add if they don't exist
137
- */
138
- alterTable({ tableName, schema, ifNotExists, }: {
139
- tableName: TABLE_NAMES;
140
- schema: Record<string, StorageColumn>;
141
- ifNotExists: string[];
142
- }): Promise<void>;
143
- clearTable({ tableName }: {
144
- tableName: TABLE_NAMES;
145
- }): Promise<void>;
146
- dropTable({ tableName }: {
147
- tableName: TABLE_NAMES;
148
- }): Promise<void>;
149
- hasColumn(table: string, column: string): Promise<boolean>;
150
- insert({ tableName, record }: {
151
- tableName: TABLE_NAMES;
152
- record: Record<string, any>;
153
- }): Promise<void>;
154
- load<R>({ tableName, keys }: {
155
- tableName: TABLE_NAMES;
156
- keys: Record<string, string>;
157
- }): Promise<R | null>;
158
- getThreadById({ threadId }: {
159
- threadId: string;
160
- }): Promise<StorageThreadType | null>;
161
- /**
162
- * @deprecated use getThreadsByResourceIdPaginated instead
163
- */
164
- getThreadsByResourceId({ resourceId }: {
165
- resourceId: string;
166
- }): Promise<StorageThreadType[]>;
167
- getThreadsByResourceIdPaginated(args: {
168
- resourceId: string;
169
- page: number;
170
- perPage: number;
171
- }): Promise<PaginationInfo & {
172
- threads: StorageThreadType[];
173
- }>;
174
- saveThread({ thread }: {
175
- thread: StorageThreadType;
176
- }): Promise<StorageThreadType>;
177
- updateThread({ id, title, metadata, }: {
178
- id: string;
179
- title: string;
180
- metadata: Record<string, unknown>;
181
- }): Promise<StorageThreadType>;
182
- deleteThread({ threadId }: {
183
- threadId: string;
184
- }): Promise<void>;
185
- saveMessages(args: {
186
- messages: MastraMessageV1[];
187
- format?: undefined | 'v1';
188
- }): Promise<MastraMessageV1[]>;
189
- saveMessages(args: {
190
- messages: MastraMessageV2[];
191
- format: 'v2';
192
- }): Promise<MastraMessageV2[]>;
193
- /**
194
- * @deprecated use getMessagesPaginated instead
195
- */
196
- getMessages(args: StorageGetMessagesArg & {
197
- format?: 'v1';
198
- }): Promise<MastraMessageV1[]>;
199
- getMessages(args: StorageGetMessagesArg & {
200
- format: 'v2';
201
- }): Promise<MastraMessageV2[]>;
202
- getMessagesPaginated({ threadId, selectBy, format, }: StorageGetMessagesArg & {
203
- format?: 'v1' | 'v2';
204
- }): Promise<PaginationInfo & {
205
- messages: MastraMessageV1[] | MastraMessageV2[];
206
- }>;
207
- persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
208
- workflowName: string;
209
- runId: string;
210
- snapshot: WorkflowRunState;
211
- }): Promise<void>;
212
- loadWorkflowSnapshot(params: {
213
- workflowName: string;
214
- runId: string;
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>;
228
- /**
229
- * Insert multiple records in a batch operation
230
- * @param tableName The table to insert into
231
- * @param records The records to insert
232
- */
233
- batchInsert({ tableName, records }: {
234
- tableName: TABLE_NAMES;
235
- records: Record<string, any>[];
236
- }): Promise<void>;
237
- /**
238
- * @deprecated use getTracesPaginated instead
239
- */
240
- getTraces(args: {
241
- name?: string;
242
- scope?: string;
243
- page: number;
244
- perPage: number;
245
- attributes?: Record<string, string>;
246
- fromDate?: Date;
247
- toDate?: Date;
248
- }): Promise<Trace[]>;
249
- getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
250
- traces: Trace[];
251
- }>;
252
- /**
253
- * @deprecated use getEvals instead
254
- */
255
- getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
256
- getEvals(options: {
257
- agentName?: string;
258
- type?: 'test' | 'live';
259
- } & PaginationArgs): Promise<PaginationInfo & {
260
- evals: EvalRow[];
261
- }>;
262
- updateMessages(_args: {
263
- messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
264
- id: string;
265
- content?: {
266
- metadata?: MastraMessageContentV2['metadata'];
267
- content?: MastraMessageContentV2['content'];
268
- };
269
- }[];
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>;
315
- }
316
- export { D1Store }
317
- export { D1Store as D1Store_alias_1 }
318
-
319
- /**
320
- * Combined configuration type supporting both REST API and Workers Binding API
321
- */
322
- declare type D1StoreConfig = D1Config | D1WorkersConfig | D1ClientConfig;
323
- export { D1StoreConfig }
324
- export { D1StoreConfig as D1StoreConfig_alias_1 }
325
-
326
- /**
327
- * Configuration for D1 using the Workers Binding API
328
- */
329
- declare interface D1WorkersConfig {
330
- /** D1 database binding from Workers environment */
331
- binding: D1Database_2;
332
- /** Optional prefix for table names */
333
- tablePrefix?: string;
334
- }
335
- export { D1WorkersConfig }
336
- export { D1WorkersConfig as D1WorkersConfig_alias_1 }
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
-
436
- /**
437
- * Parses and returns a valid SQL SELECT column identifier.
438
- * Allows a single identifier (letters, numbers, underscores), or '*', optionally with 'AS alias'.
439
- *
440
- * @param column - The column identifier string to parse.
441
- * @returns The validated column identifier as a branded type.
442
- * @throws {Error} If invalid.
443
- *
444
- * @example
445
- * const col = parseSelectIdentifier('user_id'); // Ok
446
- * parseSelectIdentifier('user_id AS uid'); // Ok
447
- * parseSelectIdentifier('*'); // Ok
448
- * parseSelectIdentifier('user id'); // Throws error
449
- */
450
- export declare function parseSelectIdentifier(column: string): SelectIdentifier;
451
-
452
- export declare const retryUntil: <T>(fn: () => Promise<T>, condition: (result: T) => boolean, timeout?: number, // REST API needs longer timeout due to higher latency
453
- interval?: number) => Promise<T>;
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
-
490
- /** Represents a validated SQL SELECT column identifier (or '*', optionally with 'AS alias'). */
491
- declare type SelectIdentifier = string & {
492
- __brand: 'SelectIdentifier';
493
- };
494
-
495
- /**
496
- * SQL Builder class for constructing type-safe SQL queries
497
- * This helps create maintainable and secure SQL queries with proper parameter handling
498
- */
499
- export declare class SqlBuilder {
500
- private sql;
501
- private params;
502
- private whereAdded;
503
- select(columns?: string | string[]): SqlBuilder;
504
- from(table: string): SqlBuilder;
505
- /**
506
- * Add a WHERE clause to the query
507
- * @param condition The condition to add
508
- * @param params Parameters to bind to the condition
509
- */
510
- where(condition: string, ...params: SqlParam[]): SqlBuilder;
511
- /**
512
- * Add a WHERE clause if it hasn't been added yet, otherwise add an AND clause
513
- * @param condition The condition to add
514
- * @param params Parameters to bind to the condition
515
- */
516
- whereAnd(condition: string, ...params: SqlParam[]): SqlBuilder;
517
- andWhere(condition: string, ...params: SqlParam[]): SqlBuilder;
518
- orWhere(condition: string, ...params: SqlParam[]): SqlBuilder;
519
- orderBy(column: string, direction?: 'ASC' | 'DESC'): SqlBuilder;
520
- limit(count: number): SqlBuilder;
521
- offset(count: number): SqlBuilder;
522
- count(): SqlBuilder;
523
- /**
524
- * Insert a row, or update specific columns on conflict (upsert).
525
- * @param table Table name
526
- * @param columns Columns to insert
527
- * @param values Values to insert
528
- * @param conflictColumns Columns to check for conflict (usually PK or UNIQUE)
529
- * @param updateMap Object mapping columns to update to their new value (e.g. { name: 'excluded.name' })
530
- */
531
- insert(table: string, columns: string[], values: SqlParam[], conflictColumns?: string[], updateMap?: Record<string, string>): SqlBuilder;
532
- update(table: string, columns: string[], values: SqlParam[]): SqlBuilder;
533
- delete(table: string): SqlBuilder;
534
- /**
535
- * Create a table if it doesn't exist
536
- * @param table The table name
537
- * @param columnDefinitions The column definitions as an array of strings
538
- * @param tableConstraints Optional constraints for the table
539
- * @returns The builder instance
540
- */
541
- createTable(table: string, columnDefinitions: string[], tableConstraints?: string[]): SqlBuilder;
542
- /**
543
- * Check if an index exists in the database
544
- * @param indexName The name of the index to check
545
- * @param tableName The table the index is on
546
- * @returns The builder instance
547
- */
548
- checkIndexExists(indexName: string, tableName: string): SqlBuilder;
549
- /**
550
- * Create an index if it doesn't exist
551
- * @param indexName The name of the index to create
552
- * @param tableName The table to create the index on
553
- * @param columnName The column to index
554
- * @param indexType Optional index type (e.g., 'UNIQUE')
555
- * @returns The builder instance
556
- */
557
- createIndex(indexName: string, tableName: string, columnName: string, indexType?: string): SqlBuilder;
558
- /**
559
- * Add a LIKE condition to the query
560
- * @param column The column to check
561
- * @param value The value to match (will be wrapped with % for LIKE)
562
- * @param exact If true, will not add % wildcards
563
- */
564
- like(column: string, value: string, exact?: boolean): SqlBuilder;
565
- /**
566
- * Add a JSON LIKE condition for searching in JSON fields
567
- * @param column The JSON column to search in
568
- * @param key The JSON key to match
569
- * @param value The value to match
570
- */
571
- jsonLike(column: string, key: string, value: string): SqlBuilder;
572
- /**
573
- * Get the built query
574
- * @returns Object containing the SQL string and parameters array
575
- */
576
- build(): {
577
- sql: string;
578
- params: SqlParam[];
579
- };
580
- /**
581
- * Reset the builder for reuse
582
- * @returns The reset builder instance
583
- */
584
- reset(): SqlBuilder;
585
- }
586
-
587
- /**
588
- * Type definition for SQL query parameters
589
- */
590
- export declare type SqlParam = string | number | boolean | null | undefined;
591
-
592
- /**
593
- * Interface for SQL query options with generic type support
594
- */
595
- export declare interface SqlQueryOptions {
596
- /** SQL query to execute */
597
- sql: string;
598
- /** Parameters to bind to the query */
599
- params?: SqlParam[];
600
- /** Whether to return only the first result */
601
- first?: boolean;
602
- }
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
-
706
- export { }