@mastra/dynamodb 1.0.0-beta.6 → 1.0.0-beta.7
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 +194 -0
- package/dist/index.cjs +212 -506
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +213 -507
- package/dist/index.js.map +1 -1
- package/dist/storage/db/index.d.ts +32 -0
- package/dist/storage/db/index.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +4 -4
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/{score → scores}/index.d.ts +9 -22
- package/dist/storage/domains/scores/index.d.ts.map +1 -0
- package/dist/storage/domains/utils.d.ts +7 -0
- package/dist/storage/domains/utils.d.ts.map +1 -0
- package/dist/storage/domains/workflows/index.d.ts +8 -7
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +67 -166
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/storage/domains/operations/index.d.ts +0 -69
- package/dist/storage/domains/operations/index.d.ts.map +0 -1
- package/dist/storage/domains/score/index.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,199 @@
|
|
|
1
1
|
# @mastra/dynamodb
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.7
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Introduce StorageDomain base class for composite storage support ([#11249](https://github.com/mastra-ai/mastra/pull/11249))
|
|
8
|
+
|
|
9
|
+
Storage adapters now use a domain-based architecture where each domain (memory, workflows, scores, observability, agents) extends a `StorageDomain` base class with `init()` and `dangerouslyClearAll()` methods.
|
|
10
|
+
|
|
11
|
+
**Key changes:**
|
|
12
|
+
- Add `StorageDomain` abstract base class that all domain storage classes extend
|
|
13
|
+
- Add `InMemoryDB` class for shared state across in-memory domain implementations
|
|
14
|
+
- All storage domains now implement `dangerouslyClearAll()` for test cleanup
|
|
15
|
+
- Remove `operations` from public `StorageDomains` type (now internal to each adapter)
|
|
16
|
+
- Add flexible client/config patterns - domains accept either an existing database client or config to create one internally
|
|
17
|
+
|
|
18
|
+
**Why this matters:**
|
|
19
|
+
|
|
20
|
+
This enables composite storage where you can use different database adapters per domain:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { Mastra } from '@mastra/core';
|
|
24
|
+
import { PostgresStore } from '@mastra/pg';
|
|
25
|
+
import { ClickhouseStore } from '@mastra/clickhouse';
|
|
26
|
+
|
|
27
|
+
// Use Postgres for most domains but Clickhouse for observability
|
|
28
|
+
const mastra = new Mastra({
|
|
29
|
+
storage: new PostgresStore({
|
|
30
|
+
connectionString: 'postgres://...',
|
|
31
|
+
}),
|
|
32
|
+
// Future: override specific domains
|
|
33
|
+
// observability: new ClickhouseStore({ ... }).getStore('observability'),
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Standalone domain usage:**
|
|
38
|
+
|
|
39
|
+
Domains can now be used independently with flexible configuration:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { MemoryLibSQL } from '@mastra/libsql/memory';
|
|
43
|
+
|
|
44
|
+
// Option 1: Pass config to create client internally
|
|
45
|
+
const memory = new MemoryLibSQL({
|
|
46
|
+
url: 'file:./local.db',
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Option 2: Pass existing client for shared connections
|
|
50
|
+
import { createClient } from '@libsql/client';
|
|
51
|
+
const client = createClient({ url: 'file:./local.db' });
|
|
52
|
+
const memory = new MemoryLibSQL({ client });
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Breaking changes:**
|
|
56
|
+
- `StorageDomains` type no longer includes `operations` - access via `getStore()` instead
|
|
57
|
+
- Domain base classes now require implementing `dangerouslyClearAll()` method
|
|
58
|
+
|
|
59
|
+
- Refactor storage architecture to use domain-specific stores via `getStore()` pattern ([#11361](https://github.com/mastra-ai/mastra/pull/11361))
|
|
60
|
+
|
|
61
|
+
### Summary
|
|
62
|
+
|
|
63
|
+
This release introduces a new storage architecture that replaces passthrough methods on `MastraStorage` with domain-specific storage interfaces accessed via `getStore()`. This change reduces code duplication across storage adapters and provides a cleaner, more modular API.
|
|
64
|
+
|
|
65
|
+
### Migration Guide
|
|
66
|
+
|
|
67
|
+
All direct method calls on storage instances should be updated to use `getStore()`:
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
// Before
|
|
71
|
+
const thread = await storage.getThreadById({ threadId });
|
|
72
|
+
await storage.persistWorkflowSnapshot({ workflowName, runId, snapshot });
|
|
73
|
+
await storage.createSpan(span);
|
|
74
|
+
|
|
75
|
+
// After
|
|
76
|
+
const memory = await storage.getStore('memory');
|
|
77
|
+
const thread = await memory?.getThreadById({ threadId });
|
|
78
|
+
|
|
79
|
+
const workflows = await storage.getStore('workflows');
|
|
80
|
+
await workflows?.persistWorkflowSnapshot({ workflowName, runId, snapshot });
|
|
81
|
+
|
|
82
|
+
const observability = await storage.getStore('observability');
|
|
83
|
+
await observability?.createSpan(span);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Available Domains
|
|
87
|
+
- **`memory`**: Thread and message operations (`getThreadById`, `saveThread`, `saveMessages`, etc.)
|
|
88
|
+
- **`workflows`**: Workflow state persistence (`persistWorkflowSnapshot`, `loadWorkflowSnapshot`, `getWorkflowRunById`, etc.)
|
|
89
|
+
- **`scores`**: Evaluation scores (`saveScore`, `listScoresByScorerId`, etc.)
|
|
90
|
+
- **`observability`**: Tracing and spans (`createSpan`, `updateSpan`, `getTrace`, etc.)
|
|
91
|
+
- **`agents`**: Stored agent configurations (`createAgent`, `getAgentById`, `listAgents`, etc.)
|
|
92
|
+
|
|
93
|
+
### Breaking Changes
|
|
94
|
+
- Passthrough methods have been removed from `MastraStorage` base class
|
|
95
|
+
- All storage adapters now require accessing domains via `getStore()`
|
|
96
|
+
- The `stores` property on storage instances is now the canonical way to access domain storage
|
|
97
|
+
|
|
98
|
+
### Internal Changes
|
|
99
|
+
- Each storage adapter now initializes domain-specific stores in its constructor
|
|
100
|
+
- Domain stores share database connections and handle their own table initialization
|
|
101
|
+
|
|
102
|
+
- Unified observability schema with entity-based span identification ([#11132](https://github.com/mastra-ai/mastra/pull/11132))
|
|
103
|
+
|
|
104
|
+
## What changed
|
|
105
|
+
|
|
106
|
+
Spans now use a unified identification model with `entityId`, `entityType`, and `entityName` instead of separate `agentId`, `toolId`, `workflowId` fields.
|
|
107
|
+
|
|
108
|
+
**Before:**
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
// Old span structure
|
|
112
|
+
span.agentId; // 'my-agent'
|
|
113
|
+
span.toolId; // undefined
|
|
114
|
+
span.workflowId; // undefined
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**After:**
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
// New span structure
|
|
121
|
+
span.entityType; // EntityType.AGENT
|
|
122
|
+
span.entityId; // 'my-agent'
|
|
123
|
+
span.entityName; // 'My Agent'
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## New `listTraces()` API
|
|
127
|
+
|
|
128
|
+
Query traces with filtering, pagination, and sorting:
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
const { spans, pagination } = await storage.listTraces({
|
|
132
|
+
filters: {
|
|
133
|
+
entityType: EntityType.AGENT,
|
|
134
|
+
entityId: 'my-agent',
|
|
135
|
+
userId: 'user-123',
|
|
136
|
+
environment: 'production',
|
|
137
|
+
status: TraceStatus.SUCCESS,
|
|
138
|
+
startedAt: { start: new Date('2024-01-01'), end: new Date('2024-01-31') },
|
|
139
|
+
},
|
|
140
|
+
pagination: { page: 0, perPage: 50 },
|
|
141
|
+
orderBy: { field: 'startedAt', direction: 'DESC' },
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Available filters:** date ranges (`startedAt`, `endedAt`), entity (`entityType`, `entityId`, `entityName`), identity (`userId`, `organizationId`), correlation IDs (`runId`, `sessionId`, `threadId`), deployment (`environment`, `source`, `serviceName`), `tags`, `metadata`, and `status`.
|
|
146
|
+
|
|
147
|
+
## New retrieval methods
|
|
148
|
+
- `getSpan({ traceId, spanId })` - Get a single span
|
|
149
|
+
- `getRootSpan({ traceId })` - Get the root span of a trace
|
|
150
|
+
- `getTrace({ traceId })` - Get all spans for a trace
|
|
151
|
+
|
|
152
|
+
## Backward compatibility
|
|
153
|
+
|
|
154
|
+
The legacy `getTraces()` method continues to work. When you pass `name: "agent run: my-agent"`, it automatically transforms to `entityId: "my-agent", entityType: AGENT`.
|
|
155
|
+
|
|
156
|
+
## Migration
|
|
157
|
+
|
|
158
|
+
**Automatic:** SQL-based stores (PostgreSQL, LibSQL, MSSQL) automatically add new columns to existing `spans` tables on initialization. Existing data is preserved with new columns set to `NULL`.
|
|
159
|
+
|
|
160
|
+
**No action required:** Your existing code continues to work. Adopt the new fields and `listTraces()` API at your convenience.
|
|
161
|
+
|
|
162
|
+
### Patch Changes
|
|
163
|
+
|
|
164
|
+
- Added pre-configured client support for all storage adapters. ([#11302](https://github.com/mastra-ai/mastra/pull/11302))
|
|
165
|
+
|
|
166
|
+
**What changed**
|
|
167
|
+
|
|
168
|
+
All storage adapters now accept pre-configured database clients in addition to connection credentials. This allows you to customize client settings (connection pools, timeouts, interceptors) before passing them to Mastra.
|
|
169
|
+
|
|
170
|
+
**Example**
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
import { createClient } from '@clickhouse/client';
|
|
174
|
+
import { ClickhouseStore } from '@mastra/clickhouse';
|
|
175
|
+
|
|
176
|
+
// Create and configure client with custom settings
|
|
177
|
+
const client = createClient({
|
|
178
|
+
url: 'http://localhost:8123',
|
|
179
|
+
username: 'default',
|
|
180
|
+
password: '',
|
|
181
|
+
request_timeout: 60000,
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// Pass pre-configured client to store
|
|
185
|
+
const store = new ClickhouseStore({
|
|
186
|
+
id: 'my-store',
|
|
187
|
+
client,
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Additional improvements**
|
|
192
|
+
- Added input validation for required connection parameters (URL, credentials) with clear error messages
|
|
193
|
+
|
|
194
|
+
- Updated dependencies [[`33a4d2e`](https://github.com/mastra-ai/mastra/commit/33a4d2e4ed8af51f69256232f00c34d6b6b51d48), [`4aaa844`](https://github.com/mastra-ai/mastra/commit/4aaa844a4f19d054490f43638a990cc57bda8d2f), [`4a1a6cb`](https://github.com/mastra-ai/mastra/commit/4a1a6cb3facad54b2bb6780b00ce91d6de1edc08), [`31d13d5`](https://github.com/mastra-ai/mastra/commit/31d13d5fdc2e2380e2e3ee3ec9fb29d2a00f265d), [`4c62166`](https://github.com/mastra-ai/mastra/commit/4c621669f4a29b1f443eca3ba70b814afa286266), [`7bcbf10`](https://github.com/mastra-ai/mastra/commit/7bcbf10133516e03df964b941f9a34e9e4ab4177), [`4353600`](https://github.com/mastra-ai/mastra/commit/43536005a65988a8eede236f69122e7f5a284ba2), [`6986fb0`](https://github.com/mastra-ai/mastra/commit/6986fb064f5db6ecc24aa655e1d26529087b43b3), [`053e979`](https://github.com/mastra-ai/mastra/commit/053e9793b28e970086b0507f7f3b76ea32c1e838), [`e26dc9c`](https://github.com/mastra-ai/mastra/commit/e26dc9c3ccfec54ae3dc3e2b2589f741f9ae60a6), [`55edf73`](https://github.com/mastra-ai/mastra/commit/55edf7302149d6c964fbb7908b43babfc2b52145), [`27c0009`](https://github.com/mastra-ai/mastra/commit/27c0009777a6073d7631b0eb7b481d94e165b5ca), [`dee388d`](https://github.com/mastra-ai/mastra/commit/dee388dde02f2e63c53385ae69252a47ab6825cc), [`3f3fc30`](https://github.com/mastra-ai/mastra/commit/3f3fc3096f24c4a26cffeecfe73085928f72aa63), [`d90ea65`](https://github.com/mastra-ai/mastra/commit/d90ea6536f7aa51c6545a4e9215b55858e98e16d), [`d171e55`](https://github.com/mastra-ai/mastra/commit/d171e559ead9f52ec728d424844c8f7b164c4510), [`10c2735`](https://github.com/mastra-ai/mastra/commit/10c27355edfdad1ee2b826b897df74125eb81fb8), [`1924cf0`](https://github.com/mastra-ai/mastra/commit/1924cf06816e5e4d4d5333065ec0f4bb02a97799), [`b339816`](https://github.com/mastra-ai/mastra/commit/b339816df0984d0243d944ac2655d6ba5f809cde)]:
|
|
195
|
+
- @mastra/core@1.0.0-beta.15
|
|
196
|
+
|
|
3
197
|
## 1.0.0-beta.6
|
|
4
198
|
|
|
5
199
|
### Patch Changes
|