@mastra/dynamodb 1.0.0 → 1.0.1
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
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @mastra/dynamodb
|
|
2
2
|
|
|
3
|
+
## 1.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- dependencies updates: ([#13114](https://github.com/mastra-ai/mastra/pull/13114))
|
|
8
|
+
- Updated dependency [`electrodb@^3.5.3` ↗︎](https://www.npmjs.com/package/electrodb/v/3.5.3) (from `^3.5.0`, in `dependencies`)
|
|
9
|
+
- Updated dependencies [[`252580a`](https://github.com/mastra-ai/mastra/commit/252580a71feb0e46d0ccab04a70a79ff6a2ee0ab), [`f8e819f`](https://github.com/mastra-ai/mastra/commit/f8e819fabdfdc43d2da546a3ad81ba23685f603d), [`5c75261`](https://github.com/mastra-ai/mastra/commit/5c7526120d936757d4ffb7b82232e1641ebd45cb), [`e27d832`](https://github.com/mastra-ai/mastra/commit/e27d83281b5e166fd63a13969689e928d8605944), [`e37ef84`](https://github.com/mastra-ai/mastra/commit/e37ef8404043c94ca0c8e35ecdedb093b8087878), [`6fdd3d4`](https://github.com/mastra-ai/mastra/commit/6fdd3d451a07a8e7e216c62ac364f8dd8e36c2af), [`10cf521`](https://github.com/mastra-ai/mastra/commit/10cf52183344743a0d7babe24cd24fd78870c354), [`efdb682`](https://github.com/mastra-ai/mastra/commit/efdb682887f6522149769383908f9790c188ab88), [`0dee7a0`](https://github.com/mastra-ai/mastra/commit/0dee7a0ff4c2507e6eb6e6ee5f9738877ebd4ad1), [`04c2c8e`](https://github.com/mastra-ai/mastra/commit/04c2c8e888984364194131aecb490a3d6e920e61), [`02dc07a`](https://github.com/mastra-ai/mastra/commit/02dc07acc4ad42d93335825e3308f5b42266eba2), [`bb7262b`](https://github.com/mastra-ai/mastra/commit/bb7262b7c0ca76320d985b40510b6ffbbb936582), [`cf1c6e7`](https://github.com/mastra-ai/mastra/commit/cf1c6e789b131f55638fed52183a89d5078b4876), [`5ffadfe`](https://github.com/mastra-ai/mastra/commit/5ffadfefb1468ac2612b20bb84d24c39de6961c0), [`1e1339c`](https://github.com/mastra-ai/mastra/commit/1e1339cc276e571a48cfff5014487877086bfe68), [`d03df73`](https://github.com/mastra-ai/mastra/commit/d03df73f8fe9496064a33e1c3b74ba0479bf9ee6), [`79b8f45`](https://github.com/mastra-ai/mastra/commit/79b8f45a6767e1a5c3d56cd3c5b1214326b81661), [`9bbf08e`](https://github.com/mastra-ai/mastra/commit/9bbf08e3c20731c79dea13a765895b9fcf29cbf1), [`0a25952`](https://github.com/mastra-ai/mastra/commit/0a259526b5e1ac11e6efa53db1f140272962af2d), [`ffa5468`](https://github.com/mastra-ai/mastra/commit/ffa546857fc4821753979b3a34e13b4d76fbbcd4), [`3264a04`](https://github.com/mastra-ai/mastra/commit/3264a04e30340c3c5447433300a035ea0878df85), [`6fdd3d4`](https://github.com/mastra-ai/mastra/commit/6fdd3d451a07a8e7e216c62ac364f8dd8e36c2af), [`088d9ba`](https://github.com/mastra-ai/mastra/commit/088d9ba2577518703c52b0dccd617178d9ee6b0d), [`74fbebd`](https://github.com/mastra-ai/mastra/commit/74fbebd918a03832a2864965a8bea59bf617d3a2), [`aea6217`](https://github.com/mastra-ai/mastra/commit/aea621790bfb2291431b08da0cc5e6e150303ae7), [`b6a855e`](https://github.com/mastra-ai/mastra/commit/b6a855edc056e088279075506442ba1d6fa6def9), [`ae408ea`](https://github.com/mastra-ai/mastra/commit/ae408ea7128f0d2710b78d8623185198e7cb19c1), [`17e942e`](https://github.com/mastra-ai/mastra/commit/17e942eee2ba44985b1f807e6208cdde672f82f9), [`2015cf9`](https://github.com/mastra-ai/mastra/commit/2015cf921649f44c3f5bcd32a2c052335f8e49b4), [`7ef454e`](https://github.com/mastra-ai/mastra/commit/7ef454eaf9dcec6de60021c8f42192052dd490d6), [`2be1d99`](https://github.com/mastra-ai/mastra/commit/2be1d99564ce79acc4846071082bff353035a87a), [`2708fa1`](https://github.com/mastra-ai/mastra/commit/2708fa1055ac91c03e08b598869f6b8fb51fa37f), [`ba74aef`](https://github.com/mastra-ai/mastra/commit/ba74aef5716142dbbe931351f5243c9c6e4128a9), [`ba74aef`](https://github.com/mastra-ai/mastra/commit/ba74aef5716142dbbe931351f5243c9c6e4128a9), [`ec53e89`](https://github.com/mastra-ai/mastra/commit/ec53e8939c76c638991e21af762e51378eff7543), [`9b5a8cb`](https://github.com/mastra-ai/mastra/commit/9b5a8cb13e120811b0bf14140ada314f1c067894), [`607e66b`](https://github.com/mastra-ai/mastra/commit/607e66b02dc7f531ee37799f3456aa2dc0ca7ac5), [`a215d06`](https://github.com/mastra-ai/mastra/commit/a215d06758dcf590eabfe0b7afd4ae39bdbf082c), [`6909c74`](https://github.com/mastra-ai/mastra/commit/6909c74a7781e0447d475e9dbc1dc871b700f426), [`192438f`](https://github.com/mastra-ai/mastra/commit/192438f8a90c4f375e955f8ff179bf8dc6821a83)]:
|
|
10
|
+
- @mastra/core@1.5.0
|
|
11
|
+
|
|
12
|
+
## 1.0.1-alpha.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- dependencies updates: ([#13114](https://github.com/mastra-ai/mastra/pull/13114))
|
|
17
|
+
- Updated dependency [`electrodb@^3.5.3` ↗︎](https://www.npmjs.com/package/electrodb/v/3.5.3) (from `^3.5.0`, in `dependencies`)
|
|
18
|
+
- Updated dependencies [[`252580a`](https://github.com/mastra-ai/mastra/commit/252580a71feb0e46d0ccab04a70a79ff6a2ee0ab), [`f8e819f`](https://github.com/mastra-ai/mastra/commit/f8e819fabdfdc43d2da546a3ad81ba23685f603d), [`5c75261`](https://github.com/mastra-ai/mastra/commit/5c7526120d936757d4ffb7b82232e1641ebd45cb), [`e27d832`](https://github.com/mastra-ai/mastra/commit/e27d83281b5e166fd63a13969689e928d8605944), [`e37ef84`](https://github.com/mastra-ai/mastra/commit/e37ef8404043c94ca0c8e35ecdedb093b8087878), [`6fdd3d4`](https://github.com/mastra-ai/mastra/commit/6fdd3d451a07a8e7e216c62ac364f8dd8e36c2af), [`10cf521`](https://github.com/mastra-ai/mastra/commit/10cf52183344743a0d7babe24cd24fd78870c354), [`efdb682`](https://github.com/mastra-ai/mastra/commit/efdb682887f6522149769383908f9790c188ab88), [`0dee7a0`](https://github.com/mastra-ai/mastra/commit/0dee7a0ff4c2507e6eb6e6ee5f9738877ebd4ad1), [`04c2c8e`](https://github.com/mastra-ai/mastra/commit/04c2c8e888984364194131aecb490a3d6e920e61), [`02dc07a`](https://github.com/mastra-ai/mastra/commit/02dc07acc4ad42d93335825e3308f5b42266eba2), [`bb7262b`](https://github.com/mastra-ai/mastra/commit/bb7262b7c0ca76320d985b40510b6ffbbb936582), [`cf1c6e7`](https://github.com/mastra-ai/mastra/commit/cf1c6e789b131f55638fed52183a89d5078b4876), [`5ffadfe`](https://github.com/mastra-ai/mastra/commit/5ffadfefb1468ac2612b20bb84d24c39de6961c0), [`1e1339c`](https://github.com/mastra-ai/mastra/commit/1e1339cc276e571a48cfff5014487877086bfe68), [`d03df73`](https://github.com/mastra-ai/mastra/commit/d03df73f8fe9496064a33e1c3b74ba0479bf9ee6), [`79b8f45`](https://github.com/mastra-ai/mastra/commit/79b8f45a6767e1a5c3d56cd3c5b1214326b81661), [`9bbf08e`](https://github.com/mastra-ai/mastra/commit/9bbf08e3c20731c79dea13a765895b9fcf29cbf1), [`0a25952`](https://github.com/mastra-ai/mastra/commit/0a259526b5e1ac11e6efa53db1f140272962af2d), [`ffa5468`](https://github.com/mastra-ai/mastra/commit/ffa546857fc4821753979b3a34e13b4d76fbbcd4), [`3264a04`](https://github.com/mastra-ai/mastra/commit/3264a04e30340c3c5447433300a035ea0878df85), [`6fdd3d4`](https://github.com/mastra-ai/mastra/commit/6fdd3d451a07a8e7e216c62ac364f8dd8e36c2af), [`088d9ba`](https://github.com/mastra-ai/mastra/commit/088d9ba2577518703c52b0dccd617178d9ee6b0d), [`74fbebd`](https://github.com/mastra-ai/mastra/commit/74fbebd918a03832a2864965a8bea59bf617d3a2), [`aea6217`](https://github.com/mastra-ai/mastra/commit/aea621790bfb2291431b08da0cc5e6e150303ae7), [`b6a855e`](https://github.com/mastra-ai/mastra/commit/b6a855edc056e088279075506442ba1d6fa6def9), [`ae408ea`](https://github.com/mastra-ai/mastra/commit/ae408ea7128f0d2710b78d8623185198e7cb19c1), [`17e942e`](https://github.com/mastra-ai/mastra/commit/17e942eee2ba44985b1f807e6208cdde672f82f9), [`2015cf9`](https://github.com/mastra-ai/mastra/commit/2015cf921649f44c3f5bcd32a2c052335f8e49b4), [`7ef454e`](https://github.com/mastra-ai/mastra/commit/7ef454eaf9dcec6de60021c8f42192052dd490d6), [`2be1d99`](https://github.com/mastra-ai/mastra/commit/2be1d99564ce79acc4846071082bff353035a87a), [`2708fa1`](https://github.com/mastra-ai/mastra/commit/2708fa1055ac91c03e08b598869f6b8fb51fa37f), [`ba74aef`](https://github.com/mastra-ai/mastra/commit/ba74aef5716142dbbe931351f5243c9c6e4128a9), [`ba74aef`](https://github.com/mastra-ai/mastra/commit/ba74aef5716142dbbe931351f5243c9c6e4128a9), [`ec53e89`](https://github.com/mastra-ai/mastra/commit/ec53e8939c76c638991e21af762e51378eff7543), [`9b5a8cb`](https://github.com/mastra-ai/mastra/commit/9b5a8cb13e120811b0bf14140ada314f1c067894), [`607e66b`](https://github.com/mastra-ai/mastra/commit/607e66b02dc7f531ee37799f3456aa2dc0ca7ac5), [`a215d06`](https://github.com/mastra-ai/mastra/commit/a215d06758dcf590eabfe0b7afd4ae39bdbf082c), [`6909c74`](https://github.com/mastra-ai/mastra/commit/6909c74a7781e0447d475e9dbc1dc871b700f426), [`192438f`](https://github.com/mastra-ai/mastra/commit/192438f8a90c4f375e955f8ff179bf8dc6821a83)]:
|
|
19
|
+
- @mastra/core@1.5.0-alpha.0
|
|
20
|
+
|
|
3
21
|
## 1.0.0
|
|
4
22
|
|
|
5
23
|
### Major Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -1,32 +1,22 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: mastra-dynamodb
|
|
3
|
-
description: Documentation for @mastra/dynamodb.
|
|
2
|
+
name: mastra-dynamodb
|
|
3
|
+
description: Documentation for @mastra/dynamodb. Use when working with @mastra/dynamodb APIs, configuration, or implementation.
|
|
4
|
+
metadata:
|
|
5
|
+
package: "@mastra/dynamodb"
|
|
6
|
+
version: "1.0.1"
|
|
4
7
|
---
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
## When to use
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
> **Package**: @mastra/dynamodb
|
|
11
|
+
Use this skill whenever you are working with @mastra/dynamodb to obtain the domain-specific knowledge.
|
|
10
12
|
|
|
11
|
-
##
|
|
13
|
+
## How to use
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
Read the individual reference documents for detailed explanations and code examples.
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
cat docs/SOURCE_MAP.json
|
|
17
|
-
```
|
|
17
|
+
### Reference
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
- **types**: `.d.ts` file with JSDoc and API signatures
|
|
21
|
-
- **implementation**: `.js` chunk file with readable source
|
|
22
|
-
- **docs**: Conceptual documentation in `docs/`
|
|
19
|
+
- [Reference: DynamoDB Storage](references/reference-storage-dynamodb.md) - Documentation for the DynamoDB storage implementation in Mastra, using a single-table design with ElectroDB.
|
|
23
20
|
|
|
24
|
-
## Top Exports
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
See SOURCE_MAP.json for the complete list.
|
|
29
|
-
|
|
30
|
-
## Available Topics
|
|
31
|
-
|
|
32
|
-
- [Storage](storage/) - 1 file(s)
|
|
22
|
+
Read [assets/SOURCE_MAP.json](assets/SOURCE_MAP.json) for source code references.
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
# Storage
|
|
1
|
+
# DynamoDB Storage
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
---
|
|
3
|
+
The DynamoDB storage implementation provides a scalable and performant NoSQL database solution for Mastra, leveraging a single-table design pattern with [ElectroDB](https://electrodb.dev/).
|
|
7
4
|
|
|
8
|
-
|
|
5
|
+
> **Observability Not Supported:** DynamoDB storage **does not support the observability domain**. Traces from the `DefaultExporter` cannot be persisted to DynamoDB, and Mastra Studio's observability features won't work with DynamoDB as your only storage provider. To enable observability, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to a supported provider like ClickHouse or PostgreSQL.
|
|
9
6
|
|
|
10
|
-
>
|
|
11
|
-
|
|
12
|
-
The DynamoDB storage implementation provides a scalable and performant NoSQL database solution for Mastra, leveraging a single-table design pattern with [ElectroDB](https://electrodb.dev/).
|
|
7
|
+
> **Item Size Limit:** DynamoDB enforces a **400 KB maximum item size**. This limit can be exceeded when storing messages with base64-encoded attachments such as images. See [Handling large attachments](https://mastra.ai/docs/memory/storage) for workarounds including uploading attachments to external storage.
|
|
13
8
|
|
|
14
9
|
## Features
|
|
15
10
|
|
|
@@ -17,25 +12,41 @@ The DynamoDB storage implementation provides a scalable and performant NoSQL dat
|
|
|
17
12
|
- Based on ElectroDB for type-safe DynamoDB access
|
|
18
13
|
- Support for AWS credentials, regions, and endpoints
|
|
19
14
|
- Compatible with AWS DynamoDB Local for development
|
|
20
|
-
- Stores Thread, Message,
|
|
15
|
+
- Stores Thread, Message, Eval, and Workflow data
|
|
21
16
|
- Optimized for serverless environments
|
|
22
17
|
- Configurable TTL (Time To Live) for automatic data expiration per entity type
|
|
23
18
|
|
|
24
19
|
## Installation
|
|
25
20
|
|
|
21
|
+
**npm**:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @mastra/dynamodb@latest
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**pnpm**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pnpm add @mastra/dynamodb@latest
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Yarn**:
|
|
34
|
+
|
|
26
35
|
```bash
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
yarn add @mastra/dynamodb@latest
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Bun**:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
bun add @mastra/dynamodb@latest
|
|
32
43
|
```
|
|
33
44
|
|
|
34
45
|
## Prerequisites
|
|
35
46
|
|
|
36
47
|
Before using this package, you **must** create a DynamoDB table with a specific structure, including primary keys and Global Secondary Indexes (GSIs). This adapter expects the DynamoDB table and its GSIs to be provisioned externally.
|
|
37
48
|
|
|
38
|
-
Detailed instructions for setting up the table using AWS CloudFormation or AWS CDK are available in [
|
|
49
|
+
Detailed instructions for setting up the table using AWS CloudFormation or AWS CDK are available in [TABLE\_SETUP.md](https://github.com/mastra-ai/mastra/blob/main/stores/dynamodb/TABLE_SETUP.md). Please ensure your table is configured according to those instructions before proceeding.
|
|
39
50
|
|
|
40
51
|
## Usage
|
|
41
52
|
|
|
@@ -69,34 +80,46 @@ const memory = new Memory({
|
|
|
69
80
|
|
|
70
81
|
For local development, you can use [DynamoDB Local](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html).
|
|
71
82
|
|
|
72
|
-
1.
|
|
83
|
+
1. **Run DynamoDB Local (e.g., using Docker):**
|
|
73
84
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
85
|
+
```bash
|
|
86
|
+
docker run -p 8000:8000 amazon/dynamodb-local
|
|
87
|
+
```
|
|
77
88
|
|
|
78
|
-
2.
|
|
89
|
+
2. **Configure `DynamoDBStore` to use the local endpoint:**
|
|
79
90
|
|
|
80
|
-
|
|
81
|
-
|
|
91
|
+
```typescript
|
|
92
|
+
import { DynamoDBStore } from "@mastra/dynamodb";
|
|
82
93
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
const storage = new DynamoDBStore({
|
|
95
|
+
id: "dynamodb-local",
|
|
96
|
+
config: {
|
|
97
|
+
tableName: "mastra-single-table", // Ensure this table is created in your local DynamoDB
|
|
98
|
+
region: "localhost", // Can be any string for local, 'localhost' is common
|
|
99
|
+
endpoint: "http://localhost:8000",
|
|
100
|
+
// For DynamoDB Local, credentials are not typically required unless configured.
|
|
101
|
+
// If you've configured local credentials:
|
|
102
|
+
// credentials: { accessKeyId: "fakeMyKeyId", secretAccessKey: "fakeSecretAccessKey" }
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
```
|
|
95
106
|
|
|
96
|
-
|
|
107
|
+
You will still need to create the table and GSIs in your local DynamoDB instance, for example, using the AWS CLI pointed to your local endpoint.
|
|
97
108
|
|
|
98
109
|
## Parameters
|
|
99
110
|
|
|
111
|
+
**id:** (`string`): Unique identifier for this storage instance.
|
|
112
|
+
|
|
113
|
+
**config.tableName:** (`string`): The name of your DynamoDB table.
|
|
114
|
+
|
|
115
|
+
**config.region?:** (`string`): AWS region. Defaults to 'us-east-1'. For local development, can be set to 'localhost' or similar.
|
|
116
|
+
|
|
117
|
+
**config.endpoint?:** (`string`): Custom endpoint for DynamoDB (e.g., 'http\://localhost:8000' for local development).
|
|
118
|
+
|
|
119
|
+
**config.credentials?:** (`object`): AWS credentials object with \`accessKeyId\` and \`secretAccessKey\`. If not provided, the AWS SDK will attempt to source credentials from environment variables, IAM roles (e.g., for EC2/Lambda), or the shared AWS credentials file.
|
|
120
|
+
|
|
121
|
+
**config.ttl?:** (`object`): TTL (Time To Live) configuration for automatic data expiration. Configure per entity type: thread, message, trace, eval, workflow\_snapshot, resource, score. Each entity config includes: enabled (boolean), attributeName (string, default: 'ttl'), defaultTtlSeconds (number).
|
|
122
|
+
|
|
100
123
|
## TTL (Time To Live) Configuration
|
|
101
124
|
|
|
102
125
|
DynamoDB TTL allows you to automatically delete items after a specified time period. This is useful for:
|
|
@@ -151,20 +174,26 @@ const storage = new DynamoDBStore({
|
|
|
151
174
|
|
|
152
175
|
TTL can be configured for these entity types:
|
|
153
176
|
|
|
154
|
-
| Entity
|
|
155
|
-
|
|
156
|
-
| `thread`
|
|
157
|
-
| `message`
|
|
158
|
-
| `trace`
|
|
159
|
-
| `eval`
|
|
177
|
+
| Entity | Description |
|
|
178
|
+
| ------------------- | ------------------------ |
|
|
179
|
+
| `thread` | Conversation threads |
|
|
180
|
+
| `message` | Messages within threads |
|
|
181
|
+
| `trace` | Observability traces |
|
|
182
|
+
| `eval` | Evaluation results |
|
|
160
183
|
| `workflow_snapshot` | Workflow state snapshots |
|
|
161
|
-
| `resource`
|
|
162
|
-
| `score`
|
|
184
|
+
| `resource` | User/resource data |
|
|
185
|
+
| `score` | Scoring results |
|
|
163
186
|
|
|
164
187
|
### TTL Entity Configuration
|
|
165
188
|
|
|
166
189
|
Each entity type accepts the following configuration:
|
|
167
190
|
|
|
191
|
+
**enabled:** (`boolean`): Whether TTL is enabled for this entity type.
|
|
192
|
+
|
|
193
|
+
**attributeName?:** (`string`): The DynamoDB attribute name to use for TTL. Must match the TTL attribute configured on your DynamoDB table. Defaults to 'ttl'.
|
|
194
|
+
|
|
195
|
+
**defaultTtlSeconds?:** (`number`): Default TTL in seconds from item creation time. Items will be automatically deleted by DynamoDB after this duration.
|
|
196
|
+
|
|
168
197
|
### Enabling TTL on Your DynamoDB Table
|
|
169
198
|
|
|
170
199
|
After configuring TTL in your code, you must enable TTL on the DynamoDB table itself:
|
|
@@ -221,7 +250,7 @@ The IAM role or user executing the code needs appropriate permissions to interac
|
|
|
221
250
|
|
|
222
251
|
Before diving into the architectural details, keep these key points in mind when working with the DynamoDB storage adapter:
|
|
223
252
|
|
|
224
|
-
- **External Table Provisioning:** This adapter _requires_ you to create and configure the DynamoDB table and its Global Secondary Indexes (GSIs) yourself, prior to using the adapter. Follow the guide in [
|
|
253
|
+
- **External Table Provisioning:** This adapter _requires_ you to create and configure the DynamoDB table and its Global Secondary Indexes (GSIs) yourself, prior to using the adapter. Follow the guide in [TABLE\_SETUP.md](https://github.com/mastra-ai/mastra/blob/main/stores/dynamodb/TABLE_SETUP.md).
|
|
225
254
|
- **Single-Table Design:** All Mastra data (threads, messages, etc.) is stored in one DynamoDB table. This is a deliberate design choice optimized for DynamoDB, differing from relational database approaches.
|
|
226
255
|
- **Understanding GSIs:** Familiarity with how the GSIs are structured (as per `TABLE_SETUP.md`) is important for understanding data retrieval and potential query patterns.
|
|
227
256
|
- **ElectroDB:** The adapter uses ElectroDB to manage interactions with DynamoDB, providing a layer of abstraction and type safety over raw DynamoDB operations.
|
|
@@ -233,7 +262,7 @@ This storage adapter utilizes a **single-table design pattern** leveraging [Elec
|
|
|
233
262
|
Key aspects of this approach:
|
|
234
263
|
|
|
235
264
|
- **DynamoDB Native:** The single-table design is optimized for DynamoDB's key-value and query capabilities, often leading to better performance and scalability compared to mimicking relational models.
|
|
236
|
-
- **External Table Management:** Unlike some adapters that might offer helper functions to create tables via code, this adapter **expects the DynamoDB table and its associated Global Secondary Indexes (GSIs) to be provisioned externally** before use. Please refer to [
|
|
265
|
+
- **External Table Management:** Unlike some adapters that might offer helper functions to create tables via code, this adapter **expects the DynamoDB table and its associated Global Secondary Indexes (GSIs) to be provisioned externally** before use. Please refer to [TABLE\_SETUP.md](https://github.com/mastra-ai/mastra/blob/main/stores/dynamodb/TABLE_SETUP.md) for detailed instructions using tools like AWS CloudFormation or CDK. The adapter focuses solely on interacting with the pre-existing table structure.
|
|
237
266
|
- **Consistency via Interface:** While the underlying storage model differs, this adapter adheres to the same `MastraStorage` interface as other adapters, ensuring it can be used interchangeably within the Mastra `Memory` component.
|
|
238
267
|
|
|
239
268
|
### Mastra Data in the Single Table
|
|
@@ -246,8 +275,8 @@ For example, a `Thread` item might have a primary key like `THREAD#<threadId>`,
|
|
|
246
275
|
|
|
247
276
|
This implementation uses a single-table design pattern with ElectroDB, which offers several advantages within the context of DynamoDB:
|
|
248
277
|
|
|
249
|
-
1.
|
|
250
|
-
2.
|
|
251
|
-
3.
|
|
252
|
-
4.
|
|
253
|
-
5.
|
|
278
|
+
1. **Lower cost (potentially):** Fewer tables can simplify Read/Write Capacity Unit (RCU/WCU) provisioning and management, especially with on-demand capacity.
|
|
279
|
+
2. **Better performance:** Related data can be co-located or accessed efficiently through GSIs, enabling fast lookups for common access patterns.
|
|
280
|
+
3. **Simplified administration:** Fewer distinct tables to monitor, back up, and manage.
|
|
281
|
+
4. **Reduced complexity in access patterns:** ElectroDB helps manage the complexity of item types and access patterns on a single table.
|
|
282
|
+
5. **Transaction support:** DynamoDB transactions can be used across different "entity" types stored within the same table if needed.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/dynamodb",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "DynamoDB storage adapter for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,23 +25,23 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@aws-sdk/client-dynamodb": "^3.902.0",
|
|
27
27
|
"@aws-sdk/lib-dynamodb": "^3.902.0",
|
|
28
|
-
"electrodb": "^3.5.
|
|
28
|
+
"electrodb": "^3.5.3"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@mastra/core": ">=1.0.0-0 <2.0.0-0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@types/node": "22.
|
|
34
|
+
"@types/node": "22.19.7",
|
|
35
35
|
"@vitest/coverage-v8": "4.0.12",
|
|
36
36
|
"@vitest/ui": "4.0.12",
|
|
37
37
|
"eslint": "^9.37.0",
|
|
38
|
-
"tsup": "^8.5.
|
|
38
|
+
"tsup": "^8.5.1",
|
|
39
39
|
"typescript": "^5.9.3",
|
|
40
40
|
"vitest": "4.0.16",
|
|
41
|
-
"@internal/lint": "0.0.
|
|
42
|
-
"@internal/
|
|
43
|
-
"@mastra/core": "1.
|
|
44
|
-
"@internal/
|
|
41
|
+
"@internal/lint": "0.0.60",
|
|
42
|
+
"@internal/storage-test-utils": "0.0.56",
|
|
43
|
+
"@mastra/core": "1.5.0",
|
|
44
|
+
"@internal/types-builder": "0.0.35"
|
|
45
45
|
},
|
|
46
46
|
"homepage": "https://mastra.ai",
|
|
47
47
|
"repository": {
|
|
@@ -57,7 +57,6 @@
|
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build:lib": "tsup --silent --config tsup.config.ts",
|
|
60
|
-
"build:docs": "pnpx tsx ../../scripts/generate-package-docs.ts stores/dynamodb",
|
|
61
60
|
"dev": "tsup --watch && tsc -p tsconfig.build.json",
|
|
62
61
|
"clean": "rm -rf dist",
|
|
63
62
|
"lint": "eslint .",
|
package/dist/docs/README.md
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# @mastra/dynamodb 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/dynamodb
|
|
31
|
-
Version: 1.0.0
|