@mastra/cloudflare-d1 0.0.0-remove-unused-model-providers-api-20251030210744 → 0.0.0-remove-ai-peer-dep-from-evals-20260105220639
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/CHANGELOG.md +1084 -3
- package/README.md +10 -5
- package/dist/docs/README.md +31 -0
- package/dist/docs/SKILL.md +32 -0
- package/dist/docs/SOURCE_MAP.json +6 -0
- package/dist/docs/storage/01-reference.md +110 -0
- package/dist/index.cjs +1122 -1368
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1132 -1381
- package/dist/index.js.map +1 -1
- package/dist/storage/{domains/operations → db}/index.d.ts +42 -6
- package/dist/storage/db/index.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +18 -49
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +16 -38
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +15 -15
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +56 -209
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +17 -12
- package/dist/storage/domains/operations/index.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -75,24 +75,29 @@ const store = new D1Store({
|
|
|
75
75
|
|
|
76
76
|
- `saveThread(thread)`: Create or update a thread
|
|
77
77
|
- `getThreadById({ threadId })`: Get a thread by ID
|
|
78
|
-
- `
|
|
78
|
+
- `listThreadsByResourceId({ resourceId, offset, limit, orderBy? })`: List paginated threads for a resource
|
|
79
79
|
- `updateThread({ id, title, metadata })`: Update the title and/or metadata of a thread.
|
|
80
80
|
- `deleteThread({ threadId })`: Delete a thread and all its messages.
|
|
81
81
|
|
|
82
82
|
### Message Operations
|
|
83
83
|
|
|
84
84
|
- `saveMessages({ messages })`: Save multiple messages in a batch operation (uses prepared statements).
|
|
85
|
-
- `
|
|
85
|
+
- `listMessages({ threadId, perPage?, page? })`: Retrieve messages for a thread with pagination.
|
|
86
|
+
- `listMessagesById({ messageIds })`: Get specific messages by their IDs
|
|
87
|
+
- `updateMessages({ messages })`: Update existing messages
|
|
86
88
|
|
|
87
89
|
### Workflow Operations
|
|
88
90
|
|
|
89
91
|
- `persistWorkflowSnapshot({ workflowName, runId, snapshot })`: Save workflow state for a given workflow/run.
|
|
90
92
|
- `loadWorkflowSnapshot({ workflowName, runId })`: Load persisted workflow state.
|
|
93
|
+
- `listWorkflowRuns({ workflowName, pagination })`: List workflow runs with pagination
|
|
94
|
+
- `getWorkflowRunById({ workflowName, runId })`: Get a specific workflow run
|
|
91
95
|
|
|
92
|
-
###
|
|
96
|
+
### Operations Not Currently Supported
|
|
93
97
|
|
|
94
|
-
- `
|
|
95
|
-
-
|
|
98
|
+
- `deleteMessages(messageIds)`: Message deletion is not currently supported
|
|
99
|
+
- AI Observability (traces/spans): Not currently supported
|
|
100
|
+
- Evaluation/Scoring: Not currently supported
|
|
96
101
|
|
|
97
102
|
### Utility
|
|
98
103
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @mastra/cloudflare-d1 Documentation
|
|
2
|
+
|
|
3
|
+
> Embedded documentation for coding agents
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Read the skill overview
|
|
9
|
+
cat docs/SKILL.md
|
|
10
|
+
|
|
11
|
+
# Get the source map
|
|
12
|
+
cat docs/SOURCE_MAP.json
|
|
13
|
+
|
|
14
|
+
# Read topic documentation
|
|
15
|
+
cat docs/<topic>/01-overview.md
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Structure
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
docs/
|
|
22
|
+
├── SKILL.md # Entry point
|
|
23
|
+
├── README.md # This file
|
|
24
|
+
├── SOURCE_MAP.json # Export index
|
|
25
|
+
├── storage/ (1 files)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Version
|
|
29
|
+
|
|
30
|
+
Package: @mastra/cloudflare-d1
|
|
31
|
+
Version: 1.0.0-beta.8
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mastra-cloudflare-d1-docs
|
|
3
|
+
description: Documentation for @mastra/cloudflare-d1. Includes links to type definitions and readable implementation code in dist/.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @mastra/cloudflare-d1 Documentation
|
|
7
|
+
|
|
8
|
+
> **Version**: 1.0.0-beta.8
|
|
9
|
+
> **Package**: @mastra/cloudflare-d1
|
|
10
|
+
|
|
11
|
+
## Quick Navigation
|
|
12
|
+
|
|
13
|
+
Use SOURCE_MAP.json to find any export:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
cat docs/SOURCE_MAP.json
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Each export maps to:
|
|
20
|
+
- **types**: `.d.ts` file with JSDoc and API signatures
|
|
21
|
+
- **implementation**: `.js` chunk file with readable source
|
|
22
|
+
- **docs**: Conceptual documentation in `docs/`
|
|
23
|
+
|
|
24
|
+
## Top Exports
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
See SOURCE_MAP.json for the complete list.
|
|
29
|
+
|
|
30
|
+
## Available Topics
|
|
31
|
+
|
|
32
|
+
- [Storage](storage/) - 1 file(s)
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Storage API Reference
|
|
2
|
+
|
|
3
|
+
> API reference for storage - 1 entries
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Reference: Cloudflare D1 Storage
|
|
9
|
+
|
|
10
|
+
> Documentation for the Cloudflare D1 SQL storage implementation in Mastra.
|
|
11
|
+
|
|
12
|
+
The Cloudflare D1 storage implementation provides a serverless SQL database solution using Cloudflare D1, supporting relational operations and transactional consistency.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @mastra/cloudflare-d1@beta
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { D1Store } from "@mastra/cloudflare-d1";
|
|
24
|
+
|
|
25
|
+
type Env = {
|
|
26
|
+
// Add your bindings here, e.g. Workers KV, D1, Workers AI, etc.
|
|
27
|
+
D1Database: D1Database;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// --- Example 1: Using Workers Binding ---
|
|
31
|
+
const storageWorkers = new D1Store({
|
|
32
|
+
binding: D1Database, // D1Database binding provided by the Workers runtime
|
|
33
|
+
tablePrefix: "dev_", // Optional: isolate tables per environment
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// --- Example 2: Using REST API ---
|
|
37
|
+
const storageRest = new D1Store({
|
|
38
|
+
accountId: process.env.CLOUDFLARE_ACCOUNT_ID!, // Cloudflare Account ID
|
|
39
|
+
databaseId: process.env.CLOUDFLARE_D1_DATABASE_ID!, // D1 Database ID
|
|
40
|
+
apiToken: process.env.CLOUDFLARE_API_TOKEN!, // Cloudflare API Token
|
|
41
|
+
tablePrefix: "dev_", // Optional: isolate tables per environment
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
And add the following to your `wrangler.toml` or `wrangler.jsonc` file:
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
[[d1_databases]]
|
|
49
|
+
binding = "D1Database"
|
|
50
|
+
database_name = "db-name"
|
|
51
|
+
database_id = "db-id"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Parameters
|
|
55
|
+
|
|
56
|
+
## Additional Notes
|
|
57
|
+
|
|
58
|
+
### Schema Management
|
|
59
|
+
|
|
60
|
+
The storage implementation handles schema creation and updates automatically. It creates the following tables:
|
|
61
|
+
|
|
62
|
+
- `threads`: Stores conversation threads
|
|
63
|
+
- `messages`: Stores individual messages
|
|
64
|
+
- `metadata`: Stores additional metadata for threads and messages
|
|
65
|
+
|
|
66
|
+
### Initialization
|
|
67
|
+
|
|
68
|
+
When you pass storage to the Mastra class, `init()` is called automatically before any storage operation:
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { Mastra } from "@mastra/core";
|
|
72
|
+
import { D1Store } from "@mastra/cloudflare-d1";
|
|
73
|
+
|
|
74
|
+
const storage = new D1Store({
|
|
75
|
+
binding: D1Database,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const mastra = new Mastra({
|
|
79
|
+
storage, // init() is called automatically
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
If you're using storage directly without Mastra, you must call `init()` explicitly to create the tables:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import { D1Store } from "@mastra/cloudflare-d1";
|
|
87
|
+
|
|
88
|
+
const storage = new D1Store({
|
|
89
|
+
id: 'd1-storage',
|
|
90
|
+
binding: D1Database,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Required when using storage directly
|
|
94
|
+
await storage.init();
|
|
95
|
+
|
|
96
|
+
// Access domain-specific stores via getStore()
|
|
97
|
+
const memoryStore = await storage.getStore('memory');
|
|
98
|
+
const thread = await memoryStore?.getThreadById({ threadId: "..." });
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
> **Note:**
|
|
102
|
+
If `init()` is not called, tables won't be created and storage operations will fail silently or throw errors.
|
|
103
|
+
|
|
104
|
+
### Transactions & Consistency
|
|
105
|
+
|
|
106
|
+
Cloudflare D1 provides transactional guarantees for single-row operations. This means that multiple operations can be executed as a single, all-or-nothing unit of work.
|
|
107
|
+
|
|
108
|
+
### Table Creation & Migrations
|
|
109
|
+
|
|
110
|
+
Tables are created automatically when storage is initialized (and can be isolated per environment using the `tablePrefix` option), but advanced schema changes—such as adding columns, changing data types, or modifying indexes—require manual migration and careful planning to avoid data loss.
|