@mastra/cloudflare 0.11.1 → 0.11.2
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 +353 -93
- package/dist/_tsup-dts-rollup.d.ts +353 -93
- package/dist/index.cjs +1851 -982
- package/dist/index.js +1850 -981
- package/package.json +4 -4
|
@@ -1,28 +1,47 @@
|
|
|
1
|
+
import type { default as Cloudflare_2 } from 'cloudflare';
|
|
1
2
|
import type { EvalRow } from '@mastra/core/storage';
|
|
2
3
|
import type { KVNamespace as KVNamespace_2 } from '@cloudflare/workers-types';
|
|
3
4
|
import { KVNamespaceListKey as KVNamespaceListKey_2 } from '@cloudflare/workers-types';
|
|
5
|
+
import { LegacyEvalsStorage } from '@mastra/core/storage';
|
|
4
6
|
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
5
7
|
import type { MastraMessageV1 } from '@mastra/core/memory';
|
|
8
|
+
import type { MastraMessageV1 as MastraMessageV1_2 } from '@mastra/core';
|
|
6
9
|
import type { MastraMessageV2 } from '@mastra/core/memory';
|
|
10
|
+
import type { MastraMessageV2 as MastraMessageV2_2 } from '@mastra/core';
|
|
7
11
|
import { MastraStorage } from '@mastra/core/storage';
|
|
12
|
+
import { MemoryStorage } from '@mastra/core/storage';
|
|
13
|
+
import type { PaginationArgs } from '@mastra/core/storage';
|
|
8
14
|
import type { PaginationInfo } from '@mastra/core/storage';
|
|
15
|
+
import type { PaginationInfo as PaginationInfo_2 } from '@mastra/core';
|
|
16
|
+
import type { ScoreRowData } from '@mastra/core/scores';
|
|
17
|
+
import { ScoresStorage } from '@mastra/core/storage';
|
|
9
18
|
import type { StorageColumn } from '@mastra/core/storage';
|
|
19
|
+
import type { StorageDomains } from '@mastra/core/storage';
|
|
10
20
|
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
21
|
+
import type { StorageGetMessagesArg as StorageGetMessagesArg_2 } from '@mastra/core';
|
|
11
22
|
import type { StorageGetTracesArg } from '@mastra/core/storage';
|
|
23
|
+
import type { StorageGetTracesPaginatedArg } from '@mastra/core/storage';
|
|
24
|
+
import type { StoragePagination } from '@mastra/core/storage';
|
|
12
25
|
import type { StorageResourceType } from '@mastra/core/storage';
|
|
26
|
+
import type { StorageResourceType as StorageResourceType_2 } from '@mastra/core';
|
|
13
27
|
import type { StorageThreadType } from '@mastra/core/memory';
|
|
28
|
+
import type { StorageThreadType as StorageThreadType_2 } from '@mastra/core';
|
|
29
|
+
import { StoreOperations } from '@mastra/core/storage';
|
|
14
30
|
import type { TABLE_EVALS } from '@mastra/core/storage';
|
|
15
31
|
import type { TABLE_MESSAGES } from '@mastra/core/storage';
|
|
16
32
|
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
17
33
|
import type { TABLE_RESOURCES } from '@mastra/core/storage';
|
|
34
|
+
import type { TABLE_SCORERS } from '@mastra/core/storage';
|
|
18
35
|
import type { TABLE_THREADS } from '@mastra/core/storage';
|
|
19
36
|
import type { TABLE_TRACES } from '@mastra/core/storage';
|
|
20
37
|
import type { TABLE_WORKFLOW_SNAPSHOT } from '@mastra/core/storage';
|
|
21
38
|
import type { Trace } from '@mastra/core/telemetry';
|
|
39
|
+
import { TracesStorage } from '@mastra/core/storage';
|
|
22
40
|
import type { WorkflowRun } from '@mastra/core/storage';
|
|
23
41
|
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
24
42
|
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
25
43
|
import type { WorkflowRunState as WorkflowRunState_2 } from '@mastra/core';
|
|
44
|
+
import { WorkflowsStorage } from '@mastra/core/storage';
|
|
26
45
|
|
|
27
46
|
/**
|
|
28
47
|
* Configuration for Cloudflare KV using REST API
|
|
@@ -41,6 +60,7 @@ export declare interface CloudflareRestConfig {
|
|
|
41
60
|
}
|
|
42
61
|
|
|
43
62
|
declare class CloudflareStore extends MastraStorage {
|
|
63
|
+
stores: StorageDomains;
|
|
44
64
|
private client?;
|
|
45
65
|
private accountId?;
|
|
46
66
|
private namespacePrefix;
|
|
@@ -48,80 +68,10 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
48
68
|
private validateWorkersConfig;
|
|
49
69
|
private validateRestConfig;
|
|
50
70
|
constructor(config: CloudflareStoreConfig);
|
|
51
|
-
private getBinding;
|
|
52
|
-
private listNamespaces;
|
|
53
|
-
private getNamespaceValue;
|
|
54
|
-
private putNamespaceValue;
|
|
55
|
-
private deleteNamespaceValue;
|
|
56
|
-
listNamespaceKeys(tableName: TABLE_NAMES, options?: ListOptions): Promise<KVNamespaceListKey_2<unknown, string>[]>;
|
|
57
|
-
private createNamespaceById;
|
|
58
|
-
private getNamespaceIdByName;
|
|
59
|
-
private createNamespace;
|
|
60
|
-
private getOrCreateNamespaceId;
|
|
61
|
-
private getNamespaceId;
|
|
62
|
-
private LEGACY_NAMESPACE_MAP;
|
|
63
|
-
/**
|
|
64
|
-
* There were a few legacy mappings for tables such as
|
|
65
|
-
* - messages -> threads
|
|
66
|
-
* - workflow_snapshot -> mastra_workflows
|
|
67
|
-
* - traces -> evals
|
|
68
|
-
* This has been updated to use dedicated namespaces for each table.
|
|
69
|
-
* In the case of data for a table existing in the legacy namespace, warn the user to migrate to the new namespace.
|
|
70
|
-
*
|
|
71
|
-
* @param tableName The table name to check for legacy data
|
|
72
|
-
* @param prefix The namespace prefix
|
|
73
|
-
* @returns The legacy namespace ID if data exists; otherwise, null
|
|
74
|
-
*/
|
|
75
|
-
private checkLegacyNamespace;
|
|
76
|
-
/**
|
|
77
|
-
* Helper to safely serialize data for KV storage
|
|
78
|
-
*/
|
|
79
|
-
private safeSerialize;
|
|
80
|
-
/**
|
|
81
|
-
* Helper to safely parse data from KV storage
|
|
82
|
-
*/
|
|
83
|
-
private safeParse;
|
|
84
|
-
private putKV;
|
|
85
|
-
private getKV;
|
|
86
|
-
private deleteKV;
|
|
87
|
-
private listKV;
|
|
88
|
-
private getSortedMessages;
|
|
89
|
-
private updateSorting;
|
|
90
|
-
private getIncludedMessagesWithContext;
|
|
91
|
-
private getRecentMessages;
|
|
92
|
-
private fetchAndParseMessages;
|
|
93
|
-
/**
|
|
94
|
-
* Queue for serializing sorted order updates.
|
|
95
|
-
* Updates the sorted order for a given key. This operation is eventually consistent.
|
|
96
|
-
*/
|
|
97
|
-
private updateQueue;
|
|
98
|
-
/**
|
|
99
|
-
* Updates the sorted order for a given key. This operation is eventually consistent.
|
|
100
|
-
* Note: Operations on the same orderKey are serialized using a queue to prevent
|
|
101
|
-
* concurrent updates from conflicting with each other.
|
|
102
|
-
*/
|
|
103
|
-
private updateSortedMessages;
|
|
104
|
-
private getRank;
|
|
105
|
-
private getRange;
|
|
106
|
-
private getLastN;
|
|
107
|
-
private getFullOrder;
|
|
108
|
-
private getKey;
|
|
109
|
-
private getSchemaKey;
|
|
110
|
-
private getTableSchema;
|
|
111
|
-
private validateColumnValue;
|
|
112
|
-
private validateAgainstSchema;
|
|
113
|
-
private validateRecord;
|
|
114
|
-
private ensureMetadata;
|
|
115
71
|
createTable({ tableName, schema, }: {
|
|
116
72
|
tableName: TABLE_NAMES;
|
|
117
73
|
schema: Record<string, StorageColumn>;
|
|
118
74
|
}): Promise<void>;
|
|
119
|
-
/**
|
|
120
|
-
* No-op: This backend is schemaless and does not require schema changes.
|
|
121
|
-
* @param tableName Name of the table
|
|
122
|
-
* @param schema Schema of the table
|
|
123
|
-
* @param ifNotExists Array of column names to add if they don't exist
|
|
124
|
-
*/
|
|
125
75
|
alterTable(_args: {
|
|
126
76
|
tableName: TABLE_NAMES;
|
|
127
77
|
schema: Record<string, StorageColumn>;
|
|
@@ -130,6 +80,9 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
130
80
|
clearTable({ tableName }: {
|
|
131
81
|
tableName: TABLE_NAMES;
|
|
132
82
|
}): Promise<void>;
|
|
83
|
+
dropTable({ tableName }: {
|
|
84
|
+
tableName: TABLE_NAMES;
|
|
85
|
+
}): Promise<void>;
|
|
133
86
|
insert<T extends TABLE_NAMES>({ tableName, record, }: {
|
|
134
87
|
tableName: T;
|
|
135
88
|
record: Record<string, any>;
|
|
@@ -155,8 +108,6 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
155
108
|
deleteThread({ threadId }: {
|
|
156
109
|
threadId: string;
|
|
157
110
|
}): Promise<void>;
|
|
158
|
-
private getMessageKey;
|
|
159
|
-
private getThreadMessagesKey;
|
|
160
111
|
saveMessages(args: {
|
|
161
112
|
messages: MastraMessageV1[];
|
|
162
113
|
format?: undefined | 'v1';
|
|
@@ -171,18 +122,12 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
171
122
|
getMessages(args: StorageGetMessagesArg & {
|
|
172
123
|
format: 'v2';
|
|
173
124
|
}): Promise<MastraMessageV2[]>;
|
|
174
|
-
private validateWorkflowParams;
|
|
175
|
-
private validateWorkflowState;
|
|
176
|
-
private normalizeSteps;
|
|
177
|
-
private normalizeWorkflowState;
|
|
178
125
|
persistWorkflowSnapshot(params: {
|
|
179
|
-
namespace: string;
|
|
180
126
|
workflowName: string;
|
|
181
127
|
runId: string;
|
|
182
128
|
snapshot: WorkflowRunState;
|
|
183
129
|
}): Promise<void>;
|
|
184
130
|
loadWorkflowSnapshot(params: {
|
|
185
|
-
namespace: string;
|
|
186
131
|
workflowName: string;
|
|
187
132
|
runId: string;
|
|
188
133
|
}): Promise<WorkflowRunState | null>;
|
|
@@ -199,12 +144,18 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
199
144
|
fromDate?: Date;
|
|
200
145
|
toDate?: Date;
|
|
201
146
|
}): Promise<any[]>;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
147
|
+
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
148
|
+
getEvals(options: {
|
|
149
|
+
agentName?: string;
|
|
150
|
+
type?: 'test' | 'live';
|
|
151
|
+
dateRange?: {
|
|
152
|
+
start?: Date;
|
|
153
|
+
end?: Date;
|
|
154
|
+
};
|
|
155
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
156
|
+
evals: EvalRow[];
|
|
157
|
+
}>;
|
|
158
|
+
getWorkflowRuns({ workflowName, limit, offset, resourceId, fromDate, toDate, }?: {
|
|
208
159
|
workflowName?: string;
|
|
209
160
|
limit?: number;
|
|
210
161
|
offset?: number;
|
|
@@ -212,26 +163,24 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
212
163
|
fromDate?: Date;
|
|
213
164
|
toDate?: Date;
|
|
214
165
|
}): Promise<WorkflowRuns>;
|
|
215
|
-
getWorkflowRunById({
|
|
216
|
-
namespace: string;
|
|
166
|
+
getWorkflowRunById({ runId, workflowName, }: {
|
|
217
167
|
runId: string;
|
|
218
168
|
workflowName: string;
|
|
219
169
|
}): Promise<WorkflowRun | null>;
|
|
220
|
-
getTracesPaginated(
|
|
170
|
+
getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
|
|
221
171
|
traces: Trace[];
|
|
222
172
|
}>;
|
|
223
|
-
getThreadsByResourceIdPaginated(
|
|
173
|
+
getThreadsByResourceIdPaginated(args: {
|
|
224
174
|
resourceId: string;
|
|
225
|
-
page
|
|
226
|
-
perPage
|
|
175
|
+
page: number;
|
|
176
|
+
perPage: number;
|
|
227
177
|
}): Promise<PaginationInfo & {
|
|
228
178
|
threads: StorageThreadType[];
|
|
229
179
|
}>;
|
|
230
|
-
getMessagesPaginated(
|
|
180
|
+
getMessagesPaginated(args: StorageGetMessagesArg): Promise<PaginationInfo & {
|
|
231
181
|
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
232
182
|
}>;
|
|
233
|
-
|
|
234
|
-
updateMessages(_args: {
|
|
183
|
+
updateMessages(args: {
|
|
235
184
|
messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
236
185
|
id: string;
|
|
237
186
|
content?: {
|
|
@@ -240,6 +189,46 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
240
189
|
};
|
|
241
190
|
}[];
|
|
242
191
|
}): Promise<MastraMessageV2[]>;
|
|
192
|
+
getScoreById({ id }: {
|
|
193
|
+
id: string;
|
|
194
|
+
}): Promise<ScoreRowData | null>;
|
|
195
|
+
saveScore(score: ScoreRowData): Promise<{
|
|
196
|
+
score: ScoreRowData;
|
|
197
|
+
}>;
|
|
198
|
+
getScoresByRunId({ runId, pagination, }: {
|
|
199
|
+
runId: string;
|
|
200
|
+
pagination: StoragePagination;
|
|
201
|
+
}): Promise<{
|
|
202
|
+
pagination: PaginationInfo;
|
|
203
|
+
scores: ScoreRowData[];
|
|
204
|
+
}>;
|
|
205
|
+
getScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
206
|
+
pagination: StoragePagination;
|
|
207
|
+
entityId: string;
|
|
208
|
+
entityType: string;
|
|
209
|
+
}): Promise<{
|
|
210
|
+
pagination: PaginationInfo;
|
|
211
|
+
scores: ScoreRowData[];
|
|
212
|
+
}>;
|
|
213
|
+
getScoresByScorerId({ scorerId, pagination, }: {
|
|
214
|
+
scorerId: string;
|
|
215
|
+
pagination: StoragePagination;
|
|
216
|
+
}): Promise<{
|
|
217
|
+
pagination: PaginationInfo;
|
|
218
|
+
scores: ScoreRowData[];
|
|
219
|
+
}>;
|
|
220
|
+
getResourceById({ resourceId }: {
|
|
221
|
+
resourceId: string;
|
|
222
|
+
}): Promise<StorageResourceType | null>;
|
|
223
|
+
saveResource({ resource }: {
|
|
224
|
+
resource: StorageResourceType;
|
|
225
|
+
}): Promise<StorageResourceType>;
|
|
226
|
+
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
227
|
+
resourceId: string;
|
|
228
|
+
workingMemory?: string;
|
|
229
|
+
metadata?: Record<string, unknown>;
|
|
230
|
+
}): Promise<StorageResourceType>;
|
|
231
|
+
close(): Promise<void>;
|
|
243
232
|
}
|
|
244
233
|
export { CloudflareStore }
|
|
245
234
|
export { CloudflareStore as CloudflareStore_alias_1 }
|
|
@@ -303,16 +292,129 @@ export declare interface KVOperation {
|
|
|
303
292
|
metadata?: any;
|
|
304
293
|
}
|
|
305
294
|
|
|
295
|
+
export declare class LegacyEvalsStorageCloudflare extends LegacyEvalsStorage {
|
|
296
|
+
operations: StoreOperationsCloudflare;
|
|
297
|
+
constructor({ operations }: {
|
|
298
|
+
operations: StoreOperationsCloudflare;
|
|
299
|
+
});
|
|
300
|
+
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
301
|
+
getEvals(options: {
|
|
302
|
+
agentName?: string;
|
|
303
|
+
type?: 'test' | 'live';
|
|
304
|
+
dateRange?: {
|
|
305
|
+
start?: Date;
|
|
306
|
+
end?: Date;
|
|
307
|
+
};
|
|
308
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
309
|
+
evals: EvalRow[];
|
|
310
|
+
}>;
|
|
311
|
+
}
|
|
312
|
+
|
|
306
313
|
export declare type ListOptions = {
|
|
307
314
|
limit?: number;
|
|
308
315
|
prefix?: string;
|
|
309
316
|
};
|
|
310
317
|
|
|
318
|
+
export declare class MemoryStorageCloudflare extends MemoryStorage {
|
|
319
|
+
operations: StoreOperationsCloudflare;
|
|
320
|
+
constructor({ operations }: {
|
|
321
|
+
operations: StoreOperationsCloudflare;
|
|
322
|
+
});
|
|
323
|
+
private ensureMetadata;
|
|
324
|
+
getThreadById({ threadId }: {
|
|
325
|
+
threadId: string;
|
|
326
|
+
}): Promise<StorageThreadType_2 | null>;
|
|
327
|
+
getThreadsByResourceId({ resourceId }: {
|
|
328
|
+
resourceId: string;
|
|
329
|
+
}): Promise<StorageThreadType_2[]>;
|
|
330
|
+
getThreadsByResourceIdPaginated(args: {
|
|
331
|
+
resourceId: string;
|
|
332
|
+
page?: number;
|
|
333
|
+
perPage?: number;
|
|
334
|
+
}): Promise<PaginationInfo_2 & {
|
|
335
|
+
threads: StorageThreadType_2[];
|
|
336
|
+
}>;
|
|
337
|
+
saveThread({ thread }: {
|
|
338
|
+
thread: StorageThreadType_2;
|
|
339
|
+
}): Promise<StorageThreadType_2>;
|
|
340
|
+
updateThread({ id, title, metadata, }: {
|
|
341
|
+
id: string;
|
|
342
|
+
title: string;
|
|
343
|
+
metadata: Record<string, unknown>;
|
|
344
|
+
}): Promise<StorageThreadType_2>;
|
|
345
|
+
private getMessageKey;
|
|
346
|
+
private getThreadMessagesKey;
|
|
347
|
+
deleteThread({ threadId }: {
|
|
348
|
+
threadId: string;
|
|
349
|
+
}): Promise<void>;
|
|
350
|
+
private findMessageInAnyThread;
|
|
351
|
+
/**
|
|
352
|
+
* Queue for serializing sorted order updates.
|
|
353
|
+
* Updates the sorted order for a given key. This operation is eventually consistent.
|
|
354
|
+
*/
|
|
355
|
+
private updateQueue;
|
|
356
|
+
private updateSorting;
|
|
357
|
+
/**
|
|
358
|
+
* Updates the sorted order for a given key. This operation is eventually consistent.
|
|
359
|
+
* Note: Operations on the same orderKey are serialized using a queue to prevent
|
|
360
|
+
* concurrent updates from conflicting with each other.
|
|
361
|
+
*/
|
|
362
|
+
private updateSortedMessages;
|
|
363
|
+
private getSortedMessages;
|
|
364
|
+
private migrateMessage;
|
|
365
|
+
saveMessages(args: {
|
|
366
|
+
messages: MastraMessageV1_2[];
|
|
367
|
+
format?: undefined | 'v1';
|
|
368
|
+
}): Promise<MastraMessageV1_2[]>;
|
|
369
|
+
saveMessages(args: {
|
|
370
|
+
messages: MastraMessageV2_2[];
|
|
371
|
+
format: 'v2';
|
|
372
|
+
}): Promise<MastraMessageV2_2[]>;
|
|
373
|
+
private getRank;
|
|
374
|
+
private getRange;
|
|
375
|
+
private getLastN;
|
|
376
|
+
private getFullOrder;
|
|
377
|
+
private getIncludedMessagesWithContext;
|
|
378
|
+
private getRecentMessages;
|
|
379
|
+
private fetchAndParseMessagesFromMultipleThreads;
|
|
380
|
+
getMessages(args: StorageGetMessagesArg_2 & {
|
|
381
|
+
format?: 'v1';
|
|
382
|
+
}): Promise<MastraMessageV1_2[]>;
|
|
383
|
+
getMessages(args: StorageGetMessagesArg_2 & {
|
|
384
|
+
format: 'v2';
|
|
385
|
+
}): Promise<MastraMessageV2_2[]>;
|
|
386
|
+
getMessagesPaginated(args: StorageGetMessagesArg_2): Promise<PaginationInfo_2 & {
|
|
387
|
+
messages: MastraMessageV1_2[] | MastraMessageV2_2[];
|
|
388
|
+
}>;
|
|
389
|
+
updateMessages(args: {
|
|
390
|
+
messages: (Partial<Omit<MastraMessageV2_2, 'createdAt'>> & {
|
|
391
|
+
id: string;
|
|
392
|
+
threadId?: string;
|
|
393
|
+
content?: {
|
|
394
|
+
metadata?: MastraMessageContentV2['metadata'];
|
|
395
|
+
content?: MastraMessageContentV2['content'];
|
|
396
|
+
};
|
|
397
|
+
})[];
|
|
398
|
+
}): Promise<MastraMessageV2_2[]>;
|
|
399
|
+
getResourceById({ resourceId }: {
|
|
400
|
+
resourceId: string;
|
|
401
|
+
}): Promise<StorageResourceType_2 | null>;
|
|
402
|
+
saveResource({ resource }: {
|
|
403
|
+
resource: StorageResourceType_2;
|
|
404
|
+
}): Promise<StorageResourceType_2>;
|
|
405
|
+
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
406
|
+
resourceId: string;
|
|
407
|
+
workingMemory?: string;
|
|
408
|
+
metadata?: Record<string, unknown>;
|
|
409
|
+
}): Promise<StorageResourceType_2>;
|
|
410
|
+
}
|
|
411
|
+
|
|
311
412
|
export declare type RecordTypes = {
|
|
312
413
|
[TABLE_THREADS]: StorageThreadType;
|
|
313
414
|
[TABLE_MESSAGES]: MastraMessageV2;
|
|
314
415
|
[TABLE_WORKFLOW_SNAPSHOT]: WorkflowRunState;
|
|
315
416
|
[TABLE_EVALS]: EvalRow;
|
|
417
|
+
[TABLE_SCORERS]: ScoreRowData;
|
|
316
418
|
[TABLE_TRACES]: any;
|
|
317
419
|
[TABLE_RESOURCES]: StorageResourceType;
|
|
318
420
|
};
|
|
@@ -320,4 +422,162 @@ export declare type RecordTypes = {
|
|
|
320
422
|
export declare const retryUntil: <T>(fn: () => Promise<T>, condition: (result: T) => boolean, timeout?: number, // REST API needs longer timeout due to higher latency
|
|
321
423
|
interval?: number) => Promise<T>;
|
|
322
424
|
|
|
425
|
+
export declare class ScoresStorageCloudflare extends ScoresStorage {
|
|
426
|
+
private operations;
|
|
427
|
+
constructor({ operations }: {
|
|
428
|
+
operations: StoreOperationsCloudflare;
|
|
429
|
+
});
|
|
430
|
+
getScoreById({ id }: {
|
|
431
|
+
id: string;
|
|
432
|
+
}): Promise<ScoreRowData | null>;
|
|
433
|
+
saveScore(score: Omit<ScoreRowData, 'createdAt' | 'updatedAt'>): Promise<{
|
|
434
|
+
score: ScoreRowData;
|
|
435
|
+
}>;
|
|
436
|
+
getScoresByScorerId({ scorerId, pagination, }: {
|
|
437
|
+
scorerId: string;
|
|
438
|
+
pagination: StoragePagination;
|
|
439
|
+
}): Promise<{
|
|
440
|
+
pagination: PaginationInfo;
|
|
441
|
+
scores: ScoreRowData[];
|
|
442
|
+
}>;
|
|
443
|
+
getScoresByRunId({ runId, pagination, }: {
|
|
444
|
+
runId: string;
|
|
445
|
+
pagination: StoragePagination;
|
|
446
|
+
}): Promise<{
|
|
447
|
+
pagination: PaginationInfo;
|
|
448
|
+
scores: ScoreRowData[];
|
|
449
|
+
}>;
|
|
450
|
+
getScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
451
|
+
pagination: StoragePagination;
|
|
452
|
+
entityId: string;
|
|
453
|
+
entityType: string;
|
|
454
|
+
}): Promise<{
|
|
455
|
+
pagination: PaginationInfo;
|
|
456
|
+
scores: ScoreRowData[];
|
|
457
|
+
}>;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
export declare class StoreOperationsCloudflare extends StoreOperations {
|
|
461
|
+
private bindings?;
|
|
462
|
+
client?: Cloudflare_2;
|
|
463
|
+
accountId?: string;
|
|
464
|
+
namespacePrefix: string;
|
|
465
|
+
constructor({ namespacePrefix, bindings, client, accountId, }: {
|
|
466
|
+
bindings?: Record<TABLE_NAMES, KVNamespace_2>;
|
|
467
|
+
namespacePrefix: string;
|
|
468
|
+
client?: Cloudflare_2;
|
|
469
|
+
accountId?: string;
|
|
470
|
+
});
|
|
471
|
+
hasColumn(): Promise<boolean>;
|
|
472
|
+
alterTable(_args: {
|
|
473
|
+
tableName: TABLE_NAMES;
|
|
474
|
+
schema: Record<string, StorageColumn>;
|
|
475
|
+
ifNotExists: string[];
|
|
476
|
+
}): Promise<void>;
|
|
477
|
+
clearTable({ tableName }: {
|
|
478
|
+
tableName: TABLE_NAMES;
|
|
479
|
+
}): Promise<void>;
|
|
480
|
+
dropTable({ tableName }: {
|
|
481
|
+
tableName: TABLE_NAMES;
|
|
482
|
+
}): Promise<void>;
|
|
483
|
+
private getBinding;
|
|
484
|
+
getKey<T extends TABLE_NAMES>(tableName: T, record: Record<string, string>): string;
|
|
485
|
+
private getSchemaKey;
|
|
486
|
+
/**
|
|
487
|
+
* Helper to safely parse data from KV storage
|
|
488
|
+
*/
|
|
489
|
+
private safeParse;
|
|
490
|
+
private createNamespaceById;
|
|
491
|
+
private createNamespace;
|
|
492
|
+
private listNamespaces;
|
|
493
|
+
private getNamespaceIdByName;
|
|
494
|
+
private getOrCreateNamespaceId;
|
|
495
|
+
private getNamespaceId;
|
|
496
|
+
private getNamespaceValue;
|
|
497
|
+
getKV(tableName: TABLE_NAMES, key: string): Promise<any>;
|
|
498
|
+
private getTableSchema;
|
|
499
|
+
private validateColumnValue;
|
|
500
|
+
private validateAgainstSchema;
|
|
501
|
+
private validateRecord;
|
|
502
|
+
insert({ tableName, record }: {
|
|
503
|
+
tableName: TABLE_NAMES;
|
|
504
|
+
record: Record<string, any>;
|
|
505
|
+
}): Promise<void>;
|
|
506
|
+
private ensureMetadata;
|
|
507
|
+
load<R>({ tableName, keys }: {
|
|
508
|
+
tableName: TABLE_NAMES;
|
|
509
|
+
keys: Record<string, string>;
|
|
510
|
+
}): Promise<R | null>;
|
|
511
|
+
batchInsert<T extends TABLE_NAMES>(input: {
|
|
512
|
+
tableName: T;
|
|
513
|
+
records: Partial<RecordTypes[T]>[];
|
|
514
|
+
}): Promise<void>;
|
|
515
|
+
/**
|
|
516
|
+
* Helper to safely serialize data for KV storage
|
|
517
|
+
*/
|
|
518
|
+
private safeSerialize;
|
|
519
|
+
private putNamespaceValue;
|
|
520
|
+
putKV({ tableName, key, value, metadata, }: {
|
|
521
|
+
tableName: TABLE_NAMES;
|
|
522
|
+
key: string;
|
|
523
|
+
value: any;
|
|
524
|
+
metadata?: any;
|
|
525
|
+
}): Promise<void>;
|
|
526
|
+
createTable({ tableName, schema, }: {
|
|
527
|
+
tableName: TABLE_NAMES;
|
|
528
|
+
schema: Record<string, StorageColumn>;
|
|
529
|
+
}): Promise<void>;
|
|
530
|
+
listNamespaceKeys(tableName: TABLE_NAMES, options?: ListOptions): Promise<KVNamespaceListKey_2<unknown, string>[]>;
|
|
531
|
+
private deleteNamespaceValue;
|
|
532
|
+
deleteKV(tableName: TABLE_NAMES, key: string): Promise<void>;
|
|
533
|
+
listKV(tableName: TABLE_NAMES, options?: ListOptions): Promise<Array<{
|
|
534
|
+
name: string;
|
|
535
|
+
}>>;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
export declare class TracesStorageCloudflare extends TracesStorage {
|
|
539
|
+
private operations;
|
|
540
|
+
constructor({ operations }: {
|
|
541
|
+
operations: StoreOperationsCloudflare;
|
|
542
|
+
});
|
|
543
|
+
getTraces(args: StorageGetTracesArg): Promise<Trace[]>;
|
|
544
|
+
getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
|
|
545
|
+
traces: Trace[];
|
|
546
|
+
}>;
|
|
547
|
+
batchTraceInsert({ records }: {
|
|
548
|
+
records: Record<string, any>[];
|
|
549
|
+
}): Promise<void>;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
export declare class WorkflowsStorageCloudflare extends WorkflowsStorage {
|
|
553
|
+
private operations;
|
|
554
|
+
constructor({ operations }: {
|
|
555
|
+
operations: StoreOperationsCloudflare;
|
|
556
|
+
});
|
|
557
|
+
private validateWorkflowParams;
|
|
558
|
+
persistWorkflowSnapshot(params: {
|
|
559
|
+
workflowName: string;
|
|
560
|
+
runId: string;
|
|
561
|
+
snapshot: WorkflowRunState;
|
|
562
|
+
}): Promise<void>;
|
|
563
|
+
loadWorkflowSnapshot(params: {
|
|
564
|
+
workflowName: string;
|
|
565
|
+
runId: string;
|
|
566
|
+
}): Promise<WorkflowRunState | null>;
|
|
567
|
+
private parseWorkflowRun;
|
|
568
|
+
private buildWorkflowSnapshotPrefix;
|
|
569
|
+
getWorkflowRuns({ workflowName, limit, offset, resourceId, fromDate, toDate, }?: {
|
|
570
|
+
workflowName?: string;
|
|
571
|
+
limit?: number;
|
|
572
|
+
offset?: number;
|
|
573
|
+
resourceId?: string;
|
|
574
|
+
fromDate?: Date;
|
|
575
|
+
toDate?: Date;
|
|
576
|
+
}): Promise<WorkflowRuns>;
|
|
577
|
+
getWorkflowRunById({ runId, workflowName, }: {
|
|
578
|
+
runId: string;
|
|
579
|
+
workflowName: string;
|
|
580
|
+
}): Promise<WorkflowRun | null>;
|
|
581
|
+
}
|
|
582
|
+
|
|
323
583
|
export { }
|