@mastra/cloudflare 0.0.0-trigger-playground-ui-package-20250506151043 → 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 +12 -4
- package/dist/_tsup-dts-rollup.d.cts +397 -90
- package/dist/_tsup-dts-rollup.d.ts +397 -90
- package/dist/index.cjs +1951 -767
- package/dist/index.js +1931 -747
- package/package.json +17 -13
|
@@ -1,24 +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';
|
|
6
|
+
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
7
|
+
import type { MastraMessageV1 } from '@mastra/core/memory';
|
|
8
|
+
import type { MastraMessageV1 as MastraMessageV1_2 } from '@mastra/core';
|
|
9
|
+
import type { MastraMessageV2 } from '@mastra/core/memory';
|
|
10
|
+
import type { MastraMessageV2 as MastraMessageV2_2 } from '@mastra/core';
|
|
4
11
|
import { MastraStorage } from '@mastra/core/storage';
|
|
5
|
-
import
|
|
6
|
-
import type {
|
|
12
|
+
import { MemoryStorage } from '@mastra/core/storage';
|
|
13
|
+
import type { PaginationArgs } from '@mastra/core/storage';
|
|
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';
|
|
7
18
|
import type { StorageColumn } from '@mastra/core/storage';
|
|
19
|
+
import type { StorageDomains } from '@mastra/core/storage';
|
|
8
20
|
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
21
|
+
import type { StorageGetMessagesArg as StorageGetMessagesArg_2 } from '@mastra/core';
|
|
22
|
+
import type { StorageGetTracesArg } from '@mastra/core/storage';
|
|
23
|
+
import type { StorageGetTracesPaginatedArg } from '@mastra/core/storage';
|
|
24
|
+
import type { StoragePagination } from '@mastra/core/storage';
|
|
25
|
+
import type { StorageResourceType } from '@mastra/core/storage';
|
|
26
|
+
import type { StorageResourceType as StorageResourceType_2 } from '@mastra/core';
|
|
9
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';
|
|
10
30
|
import type { TABLE_EVALS } from '@mastra/core/storage';
|
|
11
31
|
import type { TABLE_MESSAGES } from '@mastra/core/storage';
|
|
12
32
|
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
33
|
+
import type { TABLE_RESOURCES } from '@mastra/core/storage';
|
|
34
|
+
import type { TABLE_SCORERS } from '@mastra/core/storage';
|
|
13
35
|
import type { TABLE_THREADS } from '@mastra/core/storage';
|
|
14
36
|
import type { TABLE_TRACES } from '@mastra/core/storage';
|
|
15
37
|
import type { TABLE_WORKFLOW_SNAPSHOT } from '@mastra/core/storage';
|
|
38
|
+
import type { Trace } from '@mastra/core/telemetry';
|
|
39
|
+
import { TracesStorage } from '@mastra/core/storage';
|
|
16
40
|
import type { WorkflowRun } from '@mastra/core/storage';
|
|
17
41
|
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
18
42
|
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
19
43
|
import type { WorkflowRunState as WorkflowRunState_2 } from '@mastra/core';
|
|
20
|
-
|
|
21
|
-
export declare const checkWorkflowSnapshot: (snapshot: WorkflowRunState_2 | string, stepId: string, status: string) => void;
|
|
44
|
+
import { WorkflowsStorage } from '@mastra/core/storage';
|
|
22
45
|
|
|
23
46
|
/**
|
|
24
47
|
* Configuration for Cloudflare KV using REST API
|
|
@@ -37,6 +60,7 @@ export declare interface CloudflareRestConfig {
|
|
|
37
60
|
}
|
|
38
61
|
|
|
39
62
|
declare class CloudflareStore extends MastraStorage {
|
|
63
|
+
stores: StorageDomains;
|
|
40
64
|
private client?;
|
|
41
65
|
private accountId?;
|
|
42
66
|
private namespacePrefix;
|
|
@@ -44,65 +68,21 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
44
68
|
private validateWorkersConfig;
|
|
45
69
|
private validateRestConfig;
|
|
46
70
|
constructor(config: CloudflareStoreConfig);
|
|
47
|
-
private getBinding;
|
|
48
|
-
private listNamespaces;
|
|
49
|
-
private getNamespaceValue;
|
|
50
|
-
private putNamespaceValue;
|
|
51
|
-
private deleteNamespaceValue;
|
|
52
|
-
listNamespaceKeys(tableName: TABLE_NAMES, options?: ListOptions): Promise<KVNamespaceListKey_2<unknown, string>[]>;
|
|
53
|
-
private createNamespaceById;
|
|
54
|
-
private getNamespaceIdByName;
|
|
55
|
-
private createNamespace;
|
|
56
|
-
private getOrCreateNamespaceId;
|
|
57
|
-
private getNamespaceId;
|
|
58
|
-
/**
|
|
59
|
-
* Helper to safely serialize data for KV storage
|
|
60
|
-
*/
|
|
61
|
-
private safeSerialize;
|
|
62
|
-
/**
|
|
63
|
-
* Helper to safely parse data from KV storage
|
|
64
|
-
*/
|
|
65
|
-
private safeParse;
|
|
66
|
-
private putKV;
|
|
67
|
-
private getKV;
|
|
68
|
-
private deleteKV;
|
|
69
|
-
private listKV;
|
|
70
|
-
private getSortedMessages;
|
|
71
|
-
private updateSorting;
|
|
72
|
-
private getIncludedMessagesWithContext;
|
|
73
|
-
private getRecentMessages;
|
|
74
|
-
private fetchAndParseMessages;
|
|
75
|
-
/**
|
|
76
|
-
* Queue for serializing sorted order updates.
|
|
77
|
-
* Updates the sorted order for a given key. This operation is eventually consistent.
|
|
78
|
-
*/
|
|
79
|
-
private updateQueue;
|
|
80
|
-
/**
|
|
81
|
-
* Updates the sorted order for a given key. This operation is eventually consistent.
|
|
82
|
-
* Note: Operations on the same orderKey are serialized using a queue to prevent
|
|
83
|
-
* concurrent updates from conflicting with each other.
|
|
84
|
-
*/
|
|
85
|
-
private updateSortedMessages;
|
|
86
|
-
private getRank;
|
|
87
|
-
private getRange;
|
|
88
|
-
private getLastN;
|
|
89
|
-
private getFullOrder;
|
|
90
|
-
private getKey;
|
|
91
|
-
private getSchemaKey;
|
|
92
|
-
private getTableSchema;
|
|
93
|
-
private validateColumnValue;
|
|
94
|
-
private validateAgainstSchema;
|
|
95
|
-
private validateRecord;
|
|
96
|
-
private ensureDate;
|
|
97
|
-
private serializeDate;
|
|
98
|
-
private ensureMetadata;
|
|
99
71
|
createTable({ tableName, schema, }: {
|
|
100
72
|
tableName: TABLE_NAMES;
|
|
101
73
|
schema: Record<string, StorageColumn>;
|
|
102
74
|
}): Promise<void>;
|
|
75
|
+
alterTable(_args: {
|
|
76
|
+
tableName: TABLE_NAMES;
|
|
77
|
+
schema: Record<string, StorageColumn>;
|
|
78
|
+
ifNotExists: string[];
|
|
79
|
+
}): Promise<void>;
|
|
103
80
|
clearTable({ tableName }: {
|
|
104
81
|
tableName: TABLE_NAMES;
|
|
105
82
|
}): Promise<void>;
|
|
83
|
+
dropTable({ tableName }: {
|
|
84
|
+
tableName: TABLE_NAMES;
|
|
85
|
+
}): Promise<void>;
|
|
106
86
|
insert<T extends TABLE_NAMES>({ tableName, record, }: {
|
|
107
87
|
tableName: T;
|
|
108
88
|
record: Record<string, any>;
|
|
@@ -128,24 +108,26 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
128
108
|
deleteThread({ threadId }: {
|
|
129
109
|
threadId: string;
|
|
130
110
|
}): Promise<void>;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
111
|
+
saveMessages(args: {
|
|
112
|
+
messages: MastraMessageV1[];
|
|
113
|
+
format?: undefined | 'v1';
|
|
114
|
+
}): Promise<MastraMessageV1[]>;
|
|
115
|
+
saveMessages(args: {
|
|
116
|
+
messages: MastraMessageV2[];
|
|
117
|
+
format: 'v2';
|
|
118
|
+
}): Promise<MastraMessageV2[]>;
|
|
119
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
120
|
+
format?: 'v1';
|
|
121
|
+
}): Promise<MastraMessageV1[]>;
|
|
122
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
123
|
+
format: 'v2';
|
|
124
|
+
}): Promise<MastraMessageV2[]>;
|
|
141
125
|
persistWorkflowSnapshot(params: {
|
|
142
|
-
namespace: string;
|
|
143
126
|
workflowName: string;
|
|
144
127
|
runId: string;
|
|
145
128
|
snapshot: WorkflowRunState;
|
|
146
129
|
}): Promise<void>;
|
|
147
130
|
loadWorkflowSnapshot(params: {
|
|
148
|
-
namespace: string;
|
|
149
131
|
workflowName: string;
|
|
150
132
|
runId: string;
|
|
151
133
|
}): Promise<WorkflowRunState | null>;
|
|
@@ -162,12 +144,18 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
162
144
|
fromDate?: Date;
|
|
163
145
|
toDate?: Date;
|
|
164
146
|
}): Promise<any[]>;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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, }?: {
|
|
171
159
|
workflowName?: string;
|
|
172
160
|
limit?: number;
|
|
173
161
|
offset?: number;
|
|
@@ -175,11 +163,71 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
175
163
|
fromDate?: Date;
|
|
176
164
|
toDate?: Date;
|
|
177
165
|
}): Promise<WorkflowRuns>;
|
|
178
|
-
getWorkflowRunById({
|
|
179
|
-
namespace: string;
|
|
166
|
+
getWorkflowRunById({ runId, workflowName, }: {
|
|
180
167
|
runId: string;
|
|
181
168
|
workflowName: string;
|
|
182
169
|
}): Promise<WorkflowRun | null>;
|
|
170
|
+
getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
|
|
171
|
+
traces: Trace[];
|
|
172
|
+
}>;
|
|
173
|
+
getThreadsByResourceIdPaginated(args: {
|
|
174
|
+
resourceId: string;
|
|
175
|
+
page: number;
|
|
176
|
+
perPage: number;
|
|
177
|
+
}): Promise<PaginationInfo & {
|
|
178
|
+
threads: StorageThreadType[];
|
|
179
|
+
}>;
|
|
180
|
+
getMessagesPaginated(args: StorageGetMessagesArg): Promise<PaginationInfo & {
|
|
181
|
+
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
182
|
+
}>;
|
|
183
|
+
updateMessages(args: {
|
|
184
|
+
messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
185
|
+
id: string;
|
|
186
|
+
content?: {
|
|
187
|
+
metadata?: MastraMessageContentV2['metadata'];
|
|
188
|
+
content?: MastraMessageContentV2['content'];
|
|
189
|
+
};
|
|
190
|
+
}[];
|
|
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>;
|
|
183
231
|
close(): Promise<void>;
|
|
184
232
|
}
|
|
185
233
|
export { CloudflareStore }
|
|
@@ -202,19 +250,6 @@ export declare interface CloudflareWorkersConfig {
|
|
|
202
250
|
keyPrefix?: string;
|
|
203
251
|
}
|
|
204
252
|
|
|
205
|
-
export declare const createSampleMessage: (threadId: string) => MessageType_2;
|
|
206
|
-
|
|
207
|
-
export declare const createSampleThread: () => {
|
|
208
|
-
id: string;
|
|
209
|
-
resourceId: string;
|
|
210
|
-
title: string;
|
|
211
|
-
createdAt: Date;
|
|
212
|
-
updatedAt: Date;
|
|
213
|
-
metadata: {
|
|
214
|
-
key: string;
|
|
215
|
-
};
|
|
216
|
-
};
|
|
217
|
-
|
|
218
253
|
export declare const createSampleTrace: (name: string, scope?: string, attributes?: Record<string, string>) => {
|
|
219
254
|
id: string;
|
|
220
255
|
parentSpanId: string;
|
|
@@ -257,20 +292,292 @@ export declare interface KVOperation {
|
|
|
257
292
|
metadata?: any;
|
|
258
293
|
}
|
|
259
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
|
+
|
|
260
313
|
export declare type ListOptions = {
|
|
261
314
|
limit?: number;
|
|
262
315
|
prefix?: string;
|
|
263
316
|
};
|
|
264
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
|
+
|
|
265
412
|
export declare type RecordTypes = {
|
|
266
413
|
[TABLE_THREADS]: StorageThreadType;
|
|
267
|
-
[TABLE_MESSAGES]:
|
|
414
|
+
[TABLE_MESSAGES]: MastraMessageV2;
|
|
268
415
|
[TABLE_WORKFLOW_SNAPSHOT]: WorkflowRunState;
|
|
269
416
|
[TABLE_EVALS]: EvalRow;
|
|
417
|
+
[TABLE_SCORERS]: ScoreRowData;
|
|
270
418
|
[TABLE_TRACES]: any;
|
|
419
|
+
[TABLE_RESOURCES]: StorageResourceType;
|
|
271
420
|
};
|
|
272
421
|
|
|
273
422
|
export declare const retryUntil: <T>(fn: () => Promise<T>, condition: (result: T) => boolean, timeout?: number, // REST API needs longer timeout due to higher latency
|
|
274
423
|
interval?: number) => Promise<T>;
|
|
275
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
|
+
|
|
276
583
|
export { }
|