@mastra/cloudflare 0.0.0-vnext-inngest-20250508131921 → 0.0.0-vnext-20251119160359

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,276 +0,0 @@
1
- import type { EvalRow } from '@mastra/core/storage';
2
- import type { KVNamespace as KVNamespace_2 } from '@cloudflare/workers-types';
3
- import { KVNamespaceListKey as KVNamespaceListKey_2 } from '@cloudflare/workers-types';
4
- import { MastraStorage } from '@mastra/core/storage';
5
- import type { MessageType } from '@mastra/core/memory';
6
- import type { MessageType as MessageType_2 } from '@mastra/core';
7
- import type { StorageColumn } from '@mastra/core/storage';
8
- import type { StorageGetMessagesArg } from '@mastra/core/storage';
9
- import type { StorageThreadType } from '@mastra/core/memory';
10
- import type { TABLE_EVALS } from '@mastra/core/storage';
11
- import type { TABLE_MESSAGES } from '@mastra/core/storage';
12
- import type { TABLE_NAMES } from '@mastra/core/storage';
13
- import type { TABLE_THREADS } from '@mastra/core/storage';
14
- import type { TABLE_TRACES } from '@mastra/core/storage';
15
- import type { TABLE_WORKFLOW_SNAPSHOT } from '@mastra/core/storage';
16
- import type { WorkflowRun } from '@mastra/core/storage';
17
- import type { WorkflowRuns } from '@mastra/core/storage';
18
- import type { WorkflowRunState } from '@mastra/core/workflows';
19
- import type { WorkflowRunState as WorkflowRunState_2 } from '@mastra/core';
20
-
21
- export declare const checkWorkflowSnapshot: (snapshot: WorkflowRunState_2 | string, stepId: string, status: string) => void;
22
-
23
- /**
24
- * Configuration for Cloudflare KV using REST API
25
- */
26
- export declare interface CloudflareRestConfig {
27
- /** Cloudflare account ID */
28
- accountId: string;
29
- /** Cloudflare API token with KV access */
30
- apiToken: string;
31
- /**
32
- * Prefix for KV namespace names.
33
- * Recommended for production use to ensure data isolation between different instances.
34
- * If not provided, no prefix will be used
35
- */
36
- namespacePrefix?: string;
37
- }
38
-
39
- declare class CloudflareStore extends MastraStorage {
40
- private client?;
41
- private accountId?;
42
- private namespacePrefix;
43
- private bindings?;
44
- private validateWorkersConfig;
45
- private validateRestConfig;
46
- 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
- createTable({ tableName, schema, }: {
100
- tableName: TABLE_NAMES;
101
- schema: Record<string, StorageColumn>;
102
- }): Promise<void>;
103
- clearTable({ tableName }: {
104
- tableName: TABLE_NAMES;
105
- }): Promise<void>;
106
- insert<T extends TABLE_NAMES>({ tableName, record, }: {
107
- tableName: T;
108
- record: Record<string, any>;
109
- }): Promise<void>;
110
- load<R>({ tableName, keys }: {
111
- tableName: TABLE_NAMES;
112
- keys: Record<string, string>;
113
- }): Promise<R | null>;
114
- getThreadById({ threadId }: {
115
- threadId: string;
116
- }): Promise<StorageThreadType | null>;
117
- getThreadsByResourceId({ resourceId }: {
118
- resourceId: string;
119
- }): Promise<StorageThreadType[]>;
120
- saveThread({ thread }: {
121
- thread: StorageThreadType;
122
- }): Promise<StorageThreadType>;
123
- updateThread({ id, title, metadata, }: {
124
- id: string;
125
- title: string;
126
- metadata: Record<string, unknown>;
127
- }): Promise<StorageThreadType>;
128
- deleteThread({ threadId }: {
129
- threadId: string;
130
- }): Promise<void>;
131
- private getMessageKey;
132
- private getThreadMessagesKey;
133
- saveMessages({ messages }: {
134
- messages: MessageType[];
135
- }): Promise<MessageType[]>;
136
- getMessages<T extends MessageType = MessageType>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T[]>;
137
- private validateWorkflowParams;
138
- private validateWorkflowState;
139
- private normalizeSteps;
140
- private normalizeWorkflowState;
141
- persistWorkflowSnapshot(params: {
142
- namespace: string;
143
- workflowName: string;
144
- runId: string;
145
- snapshot: WorkflowRunState;
146
- }): Promise<void>;
147
- loadWorkflowSnapshot(params: {
148
- namespace: string;
149
- workflowName: string;
150
- runId: string;
151
- }): Promise<WorkflowRunState | null>;
152
- batchInsert<T extends TABLE_NAMES>(input: {
153
- tableName: T;
154
- records: Partial<RecordTypes[T]>[];
155
- }): Promise<void>;
156
- getTraces({ name, scope, page, perPage, attributes, fromDate, toDate, }: {
157
- name?: string;
158
- scope?: string;
159
- page: number;
160
- perPage: number;
161
- attributes?: Record<string, string>;
162
- fromDate?: Date;
163
- toDate?: Date;
164
- }): Promise<any[]>;
165
- private parseJSON;
166
- getEvalsByAgentName(_agentName: string, _type?: 'test' | 'live'): Promise<EvalRow[]>;
167
- private parseWorkflowRun;
168
- private buildWorkflowSnapshotPrefix;
169
- getWorkflowRuns({ namespace, workflowName, limit, offset, resourceId, fromDate, toDate, }?: {
170
- namespace?: string;
171
- workflowName?: string;
172
- limit?: number;
173
- offset?: number;
174
- resourceId?: string;
175
- fromDate?: Date;
176
- toDate?: Date;
177
- }): Promise<WorkflowRuns>;
178
- getWorkflowRunById({ namespace, runId, workflowName, }: {
179
- namespace: string;
180
- runId: string;
181
- workflowName: string;
182
- }): Promise<WorkflowRun | null>;
183
- close(): Promise<void>;
184
- }
185
- export { CloudflareStore }
186
- export { CloudflareStore as CloudflareStore_alias_1 }
187
-
188
- /**
189
- * Combined configuration type supporting both REST API and Workers Binding API
190
- */
191
- export declare type CloudflareStoreConfig = CloudflareRestConfig | CloudflareWorkersConfig;
192
-
193
- /**
194
- * Configuration for Cloudflare KV using Workers Binding API
195
- */
196
- export declare interface CloudflareWorkersConfig {
197
- /** KV namespace bindings from Workers environment */
198
- bindings: {
199
- [key in TABLE_NAMES]: KVNamespace_2;
200
- };
201
- /** Optional prefix for keys within namespaces */
202
- keyPrefix?: string;
203
- }
204
-
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
- export declare const createSampleTrace: (name: string, scope?: string, attributes?: Record<string, string>) => {
219
- id: string;
220
- parentSpanId: string;
221
- traceId: string;
222
- name: string;
223
- scope: string | undefined;
224
- kind: string;
225
- status: string;
226
- events: string;
227
- links: string;
228
- attributes: string | undefined;
229
- startTime: string;
230
- endTime: string;
231
- other: string;
232
- createdAt: string;
233
- };
234
-
235
- export declare const createSampleWorkflowSnapshot: (threadId: string, status: string, createdAt?: Date) => {
236
- snapshot: WorkflowRunState_2;
237
- runId: string;
238
- stepId: string;
239
- };
240
-
241
- /**
242
- * Helper to determine if a config is using Workers bindings
243
- */
244
- export declare function isWorkersConfig(config: CloudflareStoreConfig): config is CloudflareWorkersConfig;
245
-
246
- /**
247
- * Interface for KV operations with type support
248
- */
249
- export declare interface KVOperation {
250
- /** Table/namespace to operate on */
251
- tableName: TABLE_NAMES;
252
- /** Key to read/write */
253
- key: string;
254
- /** Value to write (for put operations) */
255
- value?: any;
256
- /** Optional metadata to associate with the value */
257
- metadata?: any;
258
- }
259
-
260
- export declare type ListOptions = {
261
- limit?: number;
262
- prefix?: string;
263
- };
264
-
265
- export declare type RecordTypes = {
266
- [TABLE_THREADS]: StorageThreadType;
267
- [TABLE_MESSAGES]: MessageType;
268
- [TABLE_WORKFLOW_SNAPSHOT]: WorkflowRunState;
269
- [TABLE_EVALS]: EvalRow;
270
- [TABLE_TRACES]: any;
271
- };
272
-
273
- export declare const retryUntil: <T>(fn: () => Promise<T>, condition: (result: T) => boolean, timeout?: number, // REST API needs longer timeout due to higher latency
274
- interval?: number) => Promise<T>;
275
-
276
- export { }
@@ -1,276 +0,0 @@
1
- import type { EvalRow } from '@mastra/core/storage';
2
- import type { KVNamespace as KVNamespace_2 } from '@cloudflare/workers-types';
3
- import { KVNamespaceListKey as KVNamespaceListKey_2 } from '@cloudflare/workers-types';
4
- import { MastraStorage } from '@mastra/core/storage';
5
- import type { MessageType } from '@mastra/core/memory';
6
- import type { MessageType as MessageType_2 } from '@mastra/core';
7
- import type { StorageColumn } from '@mastra/core/storage';
8
- import type { StorageGetMessagesArg } from '@mastra/core/storage';
9
- import type { StorageThreadType } from '@mastra/core/memory';
10
- import type { TABLE_EVALS } from '@mastra/core/storage';
11
- import type { TABLE_MESSAGES } from '@mastra/core/storage';
12
- import type { TABLE_NAMES } from '@mastra/core/storage';
13
- import type { TABLE_THREADS } from '@mastra/core/storage';
14
- import type { TABLE_TRACES } from '@mastra/core/storage';
15
- import type { TABLE_WORKFLOW_SNAPSHOT } from '@mastra/core/storage';
16
- import type { WorkflowRun } from '@mastra/core/storage';
17
- import type { WorkflowRuns } from '@mastra/core/storage';
18
- import type { WorkflowRunState } from '@mastra/core/workflows';
19
- import type { WorkflowRunState as WorkflowRunState_2 } from '@mastra/core';
20
-
21
- export declare const checkWorkflowSnapshot: (snapshot: WorkflowRunState_2 | string, stepId: string, status: string) => void;
22
-
23
- /**
24
- * Configuration for Cloudflare KV using REST API
25
- */
26
- export declare interface CloudflareRestConfig {
27
- /** Cloudflare account ID */
28
- accountId: string;
29
- /** Cloudflare API token with KV access */
30
- apiToken: string;
31
- /**
32
- * Prefix for KV namespace names.
33
- * Recommended for production use to ensure data isolation between different instances.
34
- * If not provided, no prefix will be used
35
- */
36
- namespacePrefix?: string;
37
- }
38
-
39
- declare class CloudflareStore extends MastraStorage {
40
- private client?;
41
- private accountId?;
42
- private namespacePrefix;
43
- private bindings?;
44
- private validateWorkersConfig;
45
- private validateRestConfig;
46
- 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
- createTable({ tableName, schema, }: {
100
- tableName: TABLE_NAMES;
101
- schema: Record<string, StorageColumn>;
102
- }): Promise<void>;
103
- clearTable({ tableName }: {
104
- tableName: TABLE_NAMES;
105
- }): Promise<void>;
106
- insert<T extends TABLE_NAMES>({ tableName, record, }: {
107
- tableName: T;
108
- record: Record<string, any>;
109
- }): Promise<void>;
110
- load<R>({ tableName, keys }: {
111
- tableName: TABLE_NAMES;
112
- keys: Record<string, string>;
113
- }): Promise<R | null>;
114
- getThreadById({ threadId }: {
115
- threadId: string;
116
- }): Promise<StorageThreadType | null>;
117
- getThreadsByResourceId({ resourceId }: {
118
- resourceId: string;
119
- }): Promise<StorageThreadType[]>;
120
- saveThread({ thread }: {
121
- thread: StorageThreadType;
122
- }): Promise<StorageThreadType>;
123
- updateThread({ id, title, metadata, }: {
124
- id: string;
125
- title: string;
126
- metadata: Record<string, unknown>;
127
- }): Promise<StorageThreadType>;
128
- deleteThread({ threadId }: {
129
- threadId: string;
130
- }): Promise<void>;
131
- private getMessageKey;
132
- private getThreadMessagesKey;
133
- saveMessages({ messages }: {
134
- messages: MessageType[];
135
- }): Promise<MessageType[]>;
136
- getMessages<T extends MessageType = MessageType>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T[]>;
137
- private validateWorkflowParams;
138
- private validateWorkflowState;
139
- private normalizeSteps;
140
- private normalizeWorkflowState;
141
- persistWorkflowSnapshot(params: {
142
- namespace: string;
143
- workflowName: string;
144
- runId: string;
145
- snapshot: WorkflowRunState;
146
- }): Promise<void>;
147
- loadWorkflowSnapshot(params: {
148
- namespace: string;
149
- workflowName: string;
150
- runId: string;
151
- }): Promise<WorkflowRunState | null>;
152
- batchInsert<T extends TABLE_NAMES>(input: {
153
- tableName: T;
154
- records: Partial<RecordTypes[T]>[];
155
- }): Promise<void>;
156
- getTraces({ name, scope, page, perPage, attributes, fromDate, toDate, }: {
157
- name?: string;
158
- scope?: string;
159
- page: number;
160
- perPage: number;
161
- attributes?: Record<string, string>;
162
- fromDate?: Date;
163
- toDate?: Date;
164
- }): Promise<any[]>;
165
- private parseJSON;
166
- getEvalsByAgentName(_agentName: string, _type?: 'test' | 'live'): Promise<EvalRow[]>;
167
- private parseWorkflowRun;
168
- private buildWorkflowSnapshotPrefix;
169
- getWorkflowRuns({ namespace, workflowName, limit, offset, resourceId, fromDate, toDate, }?: {
170
- namespace?: string;
171
- workflowName?: string;
172
- limit?: number;
173
- offset?: number;
174
- resourceId?: string;
175
- fromDate?: Date;
176
- toDate?: Date;
177
- }): Promise<WorkflowRuns>;
178
- getWorkflowRunById({ namespace, runId, workflowName, }: {
179
- namespace: string;
180
- runId: string;
181
- workflowName: string;
182
- }): Promise<WorkflowRun | null>;
183
- close(): Promise<void>;
184
- }
185
- export { CloudflareStore }
186
- export { CloudflareStore as CloudflareStore_alias_1 }
187
-
188
- /**
189
- * Combined configuration type supporting both REST API and Workers Binding API
190
- */
191
- export declare type CloudflareStoreConfig = CloudflareRestConfig | CloudflareWorkersConfig;
192
-
193
- /**
194
- * Configuration for Cloudflare KV using Workers Binding API
195
- */
196
- export declare interface CloudflareWorkersConfig {
197
- /** KV namespace bindings from Workers environment */
198
- bindings: {
199
- [key in TABLE_NAMES]: KVNamespace_2;
200
- };
201
- /** Optional prefix for keys within namespaces */
202
- keyPrefix?: string;
203
- }
204
-
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
- export declare const createSampleTrace: (name: string, scope?: string, attributes?: Record<string, string>) => {
219
- id: string;
220
- parentSpanId: string;
221
- traceId: string;
222
- name: string;
223
- scope: string | undefined;
224
- kind: string;
225
- status: string;
226
- events: string;
227
- links: string;
228
- attributes: string | undefined;
229
- startTime: string;
230
- endTime: string;
231
- other: string;
232
- createdAt: string;
233
- };
234
-
235
- export declare const createSampleWorkflowSnapshot: (threadId: string, status: string, createdAt?: Date) => {
236
- snapshot: WorkflowRunState_2;
237
- runId: string;
238
- stepId: string;
239
- };
240
-
241
- /**
242
- * Helper to determine if a config is using Workers bindings
243
- */
244
- export declare function isWorkersConfig(config: CloudflareStoreConfig): config is CloudflareWorkersConfig;
245
-
246
- /**
247
- * Interface for KV operations with type support
248
- */
249
- export declare interface KVOperation {
250
- /** Table/namespace to operate on */
251
- tableName: TABLE_NAMES;
252
- /** Key to read/write */
253
- key: string;
254
- /** Value to write (for put operations) */
255
- value?: any;
256
- /** Optional metadata to associate with the value */
257
- metadata?: any;
258
- }
259
-
260
- export declare type ListOptions = {
261
- limit?: number;
262
- prefix?: string;
263
- };
264
-
265
- export declare type RecordTypes = {
266
- [TABLE_THREADS]: StorageThreadType;
267
- [TABLE_MESSAGES]: MessageType;
268
- [TABLE_WORKFLOW_SNAPSHOT]: WorkflowRunState;
269
- [TABLE_EVALS]: EvalRow;
270
- [TABLE_TRACES]: any;
271
- };
272
-
273
- export declare const retryUntil: <T>(fn: () => Promise<T>, condition: (result: T) => boolean, timeout?: number, // REST API needs longer timeout due to higher latency
274
- interval?: number) => Promise<T>;
275
-
276
- export { }
package/dist/index.d.cts DELETED
@@ -1 +0,0 @@
1
- export { CloudflareStore } from './_tsup-dts-rollup.cjs';