@mastra/cloudflare 1.6.4-alpha.0 → 1.6.4

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/README.md CHANGED
@@ -8,33 +8,15 @@ Cloudflare KV store for Mastra, providing scalable and serverless storage for th
8
8
  npm install @mastra/cloudflare
9
9
  ```
10
10
 
11
- ## Prerequisites
12
-
13
- - Cloudflare account with KV namespaces set up
14
- - Node.js 22.13.0 or later
15
- - (Optional) Cloudflare Worker for Workers API mode
16
-
17
11
  ## Usage
18
12
 
19
13
  ```typescript
20
14
  import { CloudflareStore } from '@mastra/cloudflare';
21
15
 
22
- // Using Workers Binding API
23
- const store = new CloudflareStore({
24
- bindings: {
25
- threads: THREADS_KV_NAMESPACE,
26
- messages: MESSAGES_KV_NAMESPACE,
27
- workflow_snapshot: WORKFLOW_KV_NAMESPACE,
28
- traces: TRACES_KV_NAMESPACE,
29
- },
30
- keyPrefix: 'myapp_', // Optional
31
- });
32
-
33
- // Or using REST API
34
16
  const store = new CloudflareStore({
35
17
  accountId: process.env.CLOUDFLARE_ACCOUNT_ID!,
36
18
  apiToken: process.env.CLOUDFLARE_API_TOKEN!,
37
- namespacePrefix: 'myapp_', // Optional
19
+ namespacePrefix: 'myapp_',
38
20
  });
39
21
 
40
22
  // Save a thread
@@ -65,133 +47,15 @@ await store.saveMessages({
65
47
  const messages = await store.listMessages({ threadId: 'thread-123' });
66
48
  ```
67
49
 
68
- ## Configuration
69
-
70
- - **Workers API**: Use the `bindings` option to pass KV namespaces directly (for Cloudflare Workers).
71
- - **REST API**: Use `accountId`, `apiToken`, and (optionally) `namespacePrefix` for server-side usage.
72
- - `keyPrefix`/`namespacePrefix`: Useful for isolating environments (e.g., dev/test/prod).
73
-
74
- ## Features
75
-
76
- ### Storage Features
77
-
78
- - Thread and message storage with JSON support
79
- - Rich metadata support (JSON-encoded)
80
- - Timestamp tracking for all records
81
- - Workflow snapshot persistence
82
- - Trace and evaluation storage
83
- - Sorted message order using simulated sorted sets
84
- - Supports both Cloudflare Workers KV Bindings and REST API
85
- - Automatic JSON serialization/deserialization for metadata and custom fields
86
- - Error handling and logging for all operations
87
-
88
- ### Consistency & Performance
89
-
90
- - Eventually consistent (see Limitations)
91
- - Low-latency access via Workers Binding API
92
- - Scalable and serverless
93
-
94
- ## Supported Methods
95
-
96
- ### Thread Operations
97
-
98
- - `saveThread({ thread })`: Create or update a thread
99
- - `getThreadById({ threadId })`: Get a thread by ID
100
- - `listThreadsByResourceId({ resourceId, offset, limit, orderBy? })`: List paginated threads for a resource
101
- - `updateThread({ id, title, metadata })`: Update thread title and metadata
102
- - `deleteThread({ threadId })`: Delete a thread and its messages
103
-
104
- ### Message Operations
105
-
106
- - `saveMessages({ messages })`: Save multiple messages
107
- - `listMessages({ threadId, perPage?, page? })`: Get messages for a thread with pagination
108
- - `listMessagesById({ messageIds })`: Get specific messages by their IDs
109
- - `updateMessages({ messages })`: Update existing messages
110
-
111
- ### Resource Operations
112
-
113
- - `getResourceById({ resourceId })`: Get a resource by ID
114
- - `saveResource({ resource })`: Create or save a resource
115
- - `updateResource({ resourceId, workingMemory })`: Update resource working memory
116
-
117
- ### Workflow Operations
118
-
119
- - `persistWorkflowSnapshot({ workflowName, runId, snapshot })`: Save workflow state
120
- - `loadWorkflowSnapshot({ workflowName, runId })`: Load workflow state
121
- - `listWorkflowRuns({ workflowName, pagination })`: List workflow runs with pagination
122
- - `getWorkflowRunById({ workflowName, runId })`: Get a specific workflow run
123
- - `updateWorkflowState({ workflowName, runId, state })`: Update workflow state
124
- - `updateWorkflowResults({ workflowName, runId, results })`: Update workflow results
125
-
126
- ### Evaluation/Scoring Operations
127
-
128
- - `getScoreById({ id })`: Get a score by ID
129
- - `saveScore(score)`: Save an evaluation score
130
- - `listScoresByScorerId({ scorerId, pagination })`: List scores by scorer with pagination
131
- - `listScoresByRunId({ runId, pagination })`: List scores by run with pagination
132
- - `listScoresByEntityId({ entityId, entityType, pagination })`: List scores by entity with pagination
133
- - `listScoresBySpan({ traceId, spanId, pagination })`: List scores by span with pagination
134
-
135
- ### Operations Not Currently Supported
136
-
137
- - `deleteMessages(messageIds)`: Message deletion is not currently supported
138
- - AI Observability (traces/spans): Not currently supported
139
-
140
- ### Utility
141
-
142
- - `clearTable({ tableName })`: Remove all records from a logical table
143
- - `batchInsert({ tableName, records })`: Batch insert multiple records.
144
- - `insert({ tableName, record })`: Insert a single record into a table.
145
-
146
- ## Data Types
147
-
148
- - `text`: String
149
- - `timestamp`: ISO8601 string (converted to/from Date)
150
- - `uuid`: String
151
- - `jsonb`: JSON-encoded object
152
-
153
- All records are stored as JSON in KV, with automatic serialization/deserialization for metadata, arrays, and custom fields.
154
-
155
- ## Configuration Reference
156
-
157
- - **Workers Binding API**: Use the `bindings` option to pass KV namespaces directly (for Cloudflare Workers).
158
- - **REST API**: Use `accountId`, `apiToken`, and (optionally) `namespacePrefix` for server-side usage.
159
- - `keyPrefix`/`namespacePrefix`: Useful for isolating environments (e.g., dev/test/prod).
160
-
161
- Example:
162
-
163
- ```typescript
164
- const store = new CloudflareStore({
165
- bindings: { ... }, // for Workers
166
- keyPrefix: 'dev_',
167
- });
168
- // or
169
- const store = new CloudflareStore({
170
- accountId: '...',
171
- apiToken: '...',
172
- namespacePrefix: 'prod_',
173
- });
174
- ```
175
-
176
- ## Table/Namespace Mapping
177
-
178
- Each logical Mastra table (threads, messages, workflow_snapshot, evals, traces) maps to a separate KV namespace. Keys are structured as `${prefix}${tableName}:${primaryKey}` or `${prefix}${tableName}:${threadId}:${messageId}` for messages. The prefix is set by `keyPrefix`/`namespacePrefix`.
179
-
180
- ## Limitations
50
+ ## Documentation
181
51
 
182
- - **Eventual Consistency:** Cloudflare KV is eventually consistent; concurrent operations may not be immediately visible across all reads.
183
- - **No Transactions:** Atomic multi-key operations are not supported.
184
- - **Rate Limits:** Large objects or high-frequency updates may be subject to Cloudflare KV rate limits.
185
- - **Query Limitations:** No native querying; all filtering is done in-memory after fetching keys/records.
186
- - **Best for:** Use for serverless, low-latency, and moderate-volume workloads. For relational or strongly consistent needs, consider D1 or a SQL backend.
52
+ - [Cloudflare KV integration guide](https://mastra.ai/integrations/databases/cloudflare-kv)
53
+ - [Storage reference](https://mastra.ai/reference/storage/overview)
187
54
 
188
- ## Cloudflare-Specific Notes
55
+ ## Changelog
189
56
 
190
- - **Workers Binding API** is recommended for production Workers deployments (low-latency, no API token required at runtime).
191
- - **REST API** is ideal for server-side Node.js or test environments.
192
- - Ensure your KV namespaces are provisioned and accessible by your Worker or API token.
193
- - Namespaces and keys are automatically created as needed.
57
+ See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/stores/cloudflare/CHANGELOG.md) for version history and release notes.
194
58
 
195
- ## Cleanup/Disconnect
59
+ ## Support
196
60
 
197
- No explicit cleanup or disconnect is required; Cloudflare KV is fully managed.
61
+ We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
@@ -3,7 +3,7 @@ name: mastra-cloudflare
3
3
  description: Documentation for @mastra/cloudflare. Use when working with @mastra/cloudflare APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/cloudflare"
6
- version: "1.6.4-alpha.0"
6
+ version: "1.6.4"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.6.4-alpha.0",
2
+ "version": "1.6.4",
3
3
  "package": "@mastra/cloudflare",
4
4
  "exports": {},
5
5
  "modules": {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/cloudflare",
3
- "version": "1.6.4-alpha.0",
3
+ "version": "1.6.4",
4
4
  "description": "Cloudflare provider for Mastra - includes db storage capabilities",
5
5
  "type": "module",
6
6
  "files": [
@@ -57,10 +57,10 @@
57
57
  "tsx": "^4.23.1",
58
58
  "typescript": "^7.0.2",
59
59
  "vitest": "4.1.10",
60
- "@internal/lint": "0.0.129",
61
- "@internal/types-builder": "0.0.104",
62
- "@internal/storage-test-utils": "0.0.125",
63
- "@mastra/core": "1.64.0-alpha.2"
60
+ "@internal/lint": "0.0.130",
61
+ "@internal/types-builder": "0.0.105",
62
+ "@internal/storage-test-utils": "0.0.126",
63
+ "@mastra/core": "1.64.0"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "@cloudflare/workers-types": "^4.20240919.0",