@mastra/dynamodb 1.3.2 → 1.3.3-alpha.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/LICENSE.md +6 -4
- package/README.md +7 -89
- package/dist/docs/SKILL.md +2 -2
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/integrations-databases-dynamodb.md +2 -0
- package/dist/entities/background-task.d.ts +31 -31
- package/dist/entities/background-task.d.ts.map +1 -1
- package/dist/entities/eval.d.ts +31 -31
- package/dist/entities/eval.d.ts.map +1 -1
- package/dist/entities/index.d.ts +212 -212
- package/dist/entities/message.d.ts +31 -31
- package/dist/entities/message.d.ts.map +1 -1
- package/dist/entities/resource.d.ts +18 -18
- package/dist/entities/resource.d.ts.map +1 -1
- package/dist/entities/score.d.ts +26 -26
- package/dist/entities/score.d.ts.map +1 -1
- package/dist/entities/thread.d.ts +22 -22
- package/dist/entities/thread.d.ts.map +1 -1
- package/dist/entities/trace.d.ts +30 -30
- package/dist/entities/trace.d.ts.map +1 -1
- package/dist/entities/utils.d.ts +5 -5
- package/dist/entities/utils.d.ts.map +1 -1
- package/dist/entities/workflow-snapshot.d.ts +23 -23
- package/dist/entities/workflow-snapshot.d.ts.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +8 -9
- package/CHANGELOG.md +0 -3079
package/LICENSE.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
Portions of this software are licensed as follows:
|
|
2
2
|
|
|
3
|
-
- All content that resides under any directory named
|
|
3
|
+
- All content that resides under any directory named `ee/` within this
|
|
4
4
|
repository, including but not limited to:
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
|
|
5
|
+
- `@mastra/core/auth/ee`
|
|
6
|
+
- `@mastra/core/agent-builder/ee`
|
|
7
|
+
- `@mastra/editor/ee`
|
|
8
|
+
|
|
9
|
+
is licensed under the license defined in [`ee/LICENSE`](https://github.com/mastra-ai/mastra/blob/main/ee/LICENSE).
|
|
8
10
|
|
|
9
11
|
- All third-party components incorporated into the Mastra Software are
|
|
10
12
|
licensed under the original license provided by the owner of the
|
package/README.md
CHANGED
|
@@ -1,30 +1,13 @@
|
|
|
1
1
|
# @mastra/dynamodb
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- Efficient single-table design for all Mastra storage needs
|
|
8
|
-
- Based on ElectroDB for type-safe DynamoDB access
|
|
9
|
-
- Support for AWS credentials, regions, and endpoints
|
|
10
|
-
- Compatible with AWS DynamoDB Local for development
|
|
11
|
-
- Thread, Message, Trace, Eval, and Workflow operations
|
|
12
|
-
- Optimized for serverless environments
|
|
3
|
+
Persist Mastra data in Amazon DynamoDB with a single-table ElectroDB design, configurable indexes, TTL support, credentials, and table initialization.
|
|
13
4
|
|
|
14
5
|
## Installation
|
|
15
6
|
|
|
16
7
|
```bash
|
|
17
8
|
npm install @mastra/dynamodb
|
|
18
|
-
# or
|
|
19
|
-
pnpm add @mastra/dynamodb
|
|
20
|
-
# or
|
|
21
|
-
yarn add @mastra/dynamodb
|
|
22
9
|
```
|
|
23
10
|
|
|
24
|
-
## Prerequisites
|
|
25
|
-
|
|
26
|
-
Before using this package, you need to create a DynamoDB table with the required structure. See [TABLE_SETUP.md](./TABLE_SETUP.md) for detailed instructions on how to set up the table using CloudFormation or AWS CDK.
|
|
27
|
-
|
|
28
11
|
## Usage
|
|
29
12
|
|
|
30
13
|
### Basic Usage
|
|
@@ -61,79 +44,14 @@ const memory = new Memory({
|
|
|
61
44
|
});
|
|
62
45
|
```
|
|
63
46
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
For local development, you can use DynamoDB Local:
|
|
67
|
-
|
|
68
|
-
```typescript
|
|
69
|
-
const storage = new DynamoDBStore({
|
|
70
|
-
name: 'dynamodb',
|
|
71
|
-
config: {
|
|
72
|
-
region: 'us-east-1',
|
|
73
|
-
tableName: 'mastra-single-table',
|
|
74
|
-
endpoint: 'http://localhost:8000', // Local DynamoDB endpoint
|
|
75
|
-
},
|
|
76
|
-
});
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### AWS IAM Permissions
|
|
80
|
-
|
|
81
|
-
The IAM role or user used by this package needs the following permissions:
|
|
82
|
-
|
|
83
|
-
```json
|
|
84
|
-
{
|
|
85
|
-
"Version": "2012-10-17",
|
|
86
|
-
"Statement": [
|
|
87
|
-
{
|
|
88
|
-
"Effect": "Allow",
|
|
89
|
-
"Action": [
|
|
90
|
-
"dynamodb:DescribeTable",
|
|
91
|
-
"dynamodb:GetItem",
|
|
92
|
-
"dynamodb:PutItem",
|
|
93
|
-
"dynamodb:UpdateItem",
|
|
94
|
-
"dynamodb:DeleteItem",
|
|
95
|
-
"dynamodb:Query",
|
|
96
|
-
"dynamodb:Scan",
|
|
97
|
-
"dynamodb:BatchGetItem",
|
|
98
|
-
"dynamodb:BatchWriteItem"
|
|
99
|
-
],
|
|
100
|
-
"Resource": [
|
|
101
|
-
"arn:aws:dynamodb:*:*:table/${YOUR_TABLE_NAME}",
|
|
102
|
-
"arn:aws:dynamodb:*:*:table/${YOUR_TABLE_NAME}/index/*"
|
|
103
|
-
]
|
|
104
|
-
}
|
|
105
|
-
]
|
|
106
|
-
}
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
## Configuration Options
|
|
110
|
-
|
|
111
|
-
The `DynamoDBStore` constructor accepts the following configuration options:
|
|
112
|
-
|
|
113
|
-
| Option | Type | Required | Description |
|
|
114
|
-
| -------------------- | ------ | -------- | ---------------------------------------------------------- |
|
|
115
|
-
| `name` | string | Yes | A name for the storage instance |
|
|
116
|
-
| `config.region` | string | No | AWS region (default: 'us-east-1') |
|
|
117
|
-
| `config.tableName` | string | Yes | The name of your DynamoDB table |
|
|
118
|
-
| `config.endpoint` | string | No | Custom endpoint for DynamoDB (e.g., for local development) |
|
|
119
|
-
| `config.credentials` | object | No | AWS credentials (accessKeyId, secretAccessKey) |
|
|
120
|
-
|
|
121
|
-
## Architectural Approach
|
|
122
|
-
|
|
123
|
-
This storage adapter utilizes a **single-table design pattern** leveraging [ElectroDB](https://electrodb.dev/), which is a common and recommended approach for DynamoDB. This differs architecturally from relational database adapters (like `@mastra/pg` or `@mastra/libsql`) that typically use multiple tables, each dedicated to a specific entity (threads, messages, etc.).
|
|
47
|
+
## Documentation
|
|
124
48
|
|
|
125
|
-
|
|
49
|
+
- [DynamoDB](https://mastra.ai/integrations/databases/dynamodb)
|
|
126
50
|
|
|
127
|
-
|
|
128
|
-
- **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` for detailed instructions using tools like AWS CloudFormation or CDK. The adapter focuses solely on interacting with the pre-existing table structure.
|
|
129
|
-
- **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.
|
|
51
|
+
## Changelog
|
|
130
52
|
|
|
131
|
-
|
|
53
|
+
See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/stores/dynamodb/CHANGELOG.md) for version history and release notes.
|
|
132
54
|
|
|
133
|
-
|
|
55
|
+
## Support
|
|
134
56
|
|
|
135
|
-
|
|
136
|
-
2. **Better performance**: Related data is stored together for faster access
|
|
137
|
-
3. **Simplified administration**: Only one table to monitor and back up
|
|
138
|
-
4. **Reduced complexity**: Consistent access patterns across entities
|
|
139
|
-
5. **Transaction support**: Atomic operations across different entity types
|
|
57
|
+
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.
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-dynamodb
|
|
|
3
3
|
description: Documentation for @mastra/dynamodb. Use when working with @mastra/dynamodb APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/dynamodb"
|
|
6
|
-
version: "1.3.
|
|
6
|
+
version: "1.3.3-alpha.1"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -16,7 +16,7 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
16
16
|
|
|
17
17
|
### Integrations
|
|
18
18
|
|
|
19
|
-
- [DynamoDB](references/integrations-databases-dynamodb.md) -
|
|
19
|
+
- [DynamoDB](references/integrations-databases-dynamodb.md) - Persist Mastra data in Amazon DynamoDB with a single-table ElectroDB design, configurable indexes, TTL support, credentials, and table initialization.
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
Read [assets/SOURCE_MAP.json](assets/SOURCE_MAP.json) for source code references.
|
|
@@ -6,6 +6,36 @@ export declare const backgroundTaskEntity: Entity<string, string, string, {
|
|
|
6
6
|
service: string;
|
|
7
7
|
};
|
|
8
8
|
attributes: {
|
|
9
|
+
createdAt: {
|
|
10
|
+
readonly type: 'string';
|
|
11
|
+
readonly required: true;
|
|
12
|
+
readonly readOnly: true;
|
|
13
|
+
readonly set: (value?: Date | string) => string;
|
|
14
|
+
readonly default: () => string;
|
|
15
|
+
};
|
|
16
|
+
updatedAt: {
|
|
17
|
+
readonly type: 'string';
|
|
18
|
+
readonly required: true;
|
|
19
|
+
readonly set: (value?: Date | string) => string;
|
|
20
|
+
readonly default: () => string;
|
|
21
|
+
};
|
|
22
|
+
metadata: {
|
|
23
|
+
readonly type: 'string';
|
|
24
|
+
readonly set: (value?: Record<string, unknown> | string) => string | undefined;
|
|
25
|
+
readonly get: (value?: string) => any;
|
|
26
|
+
};
|
|
27
|
+
ttl: {
|
|
28
|
+
readonly type: 'number';
|
|
29
|
+
readonly required: false;
|
|
30
|
+
};
|
|
31
|
+
expiresAt: {
|
|
32
|
+
readonly type: 'number';
|
|
33
|
+
readonly required: false;
|
|
34
|
+
};
|
|
35
|
+
entity: {
|
|
36
|
+
type: "string";
|
|
37
|
+
required: true;
|
|
38
|
+
};
|
|
9
39
|
id: {
|
|
10
40
|
type: "string";
|
|
11
41
|
required: true;
|
|
@@ -86,36 +116,6 @@ export declare const backgroundTaskEntity: Entity<string, string, string, {
|
|
|
86
116
|
type: "string";
|
|
87
117
|
required: false;
|
|
88
118
|
};
|
|
89
|
-
createdAt: {
|
|
90
|
-
readonly type: "string";
|
|
91
|
-
readonly required: true;
|
|
92
|
-
readonly readOnly: true;
|
|
93
|
-
readonly set: (value?: Date | string) => string;
|
|
94
|
-
readonly default: () => string;
|
|
95
|
-
};
|
|
96
|
-
updatedAt: {
|
|
97
|
-
readonly type: "string";
|
|
98
|
-
readonly required: true;
|
|
99
|
-
readonly set: (value?: Date | string) => string;
|
|
100
|
-
readonly default: () => string;
|
|
101
|
-
};
|
|
102
|
-
metadata: {
|
|
103
|
-
readonly type: "string";
|
|
104
|
-
readonly set: (value?: Record<string, unknown> | string) => string | undefined;
|
|
105
|
-
readonly get: (value?: string) => any;
|
|
106
|
-
};
|
|
107
|
-
ttl: {
|
|
108
|
-
readonly type: "number";
|
|
109
|
-
readonly required: false;
|
|
110
|
-
};
|
|
111
|
-
expiresAt: {
|
|
112
|
-
readonly type: "number";
|
|
113
|
-
readonly required: false;
|
|
114
|
-
};
|
|
115
|
-
entity: {
|
|
116
|
-
type: "string";
|
|
117
|
-
required: true;
|
|
118
|
-
};
|
|
119
119
|
};
|
|
120
120
|
indexes: {
|
|
121
121
|
primary: {
|
|
@@ -132,7 +132,7 @@ export declare const backgroundTaskEntity: Entity<string, string, string, {
|
|
|
132
132
|
index: string;
|
|
133
133
|
pk: {
|
|
134
134
|
field: string;
|
|
135
|
-
composite: ("
|
|
135
|
+
composite: ("agentId" | "entity")[];
|
|
136
136
|
};
|
|
137
137
|
sk: {
|
|
138
138
|
field: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"background-task.d.ts","sourceRoot":"","sources":["../../src/entities/background-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AA2BnC,eAAO,MAAM,oBAAoB
|
|
1
|
+
{"version":3,"file":"background-task.d.ts","sourceRoot":"","sources":["../../src/entities/background-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AA2BnC,eAAO,MAAM,oBAAoB;;QAE7B,MAAM;QACN,OAAO;QACP,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAvBK,OAAO;0BAKP,MAAM;;;;;0BALN,OAAO;0BAKP,MAAM;;;;;0BALN,OAAO;0BAKP,MAAM;;;;;0BALN,OAAO;0BAKP,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAyGlB,OAAO;YACL,EAAE;gBAAI,KAAK;gBAAQ,SAAS;;YAC5B,EAAE;gBAAI,KAAK;gBAAQ,SAAS;;;QAE9B,OAAO;YACL,KAAK;YACL,EAAE;gBAAI,KAAK;gBAAY,SAAS;;YAChC,EAAE;gBAAI,KAAK;gBAAY,SAAS;;;QAElC,KAAK;YACH,KAAK;YACL,EAAE;gBAAI,KAAK;gBAAY,SAAS;;YAChC,EAAE;gBAAI,KAAK;gBAAY,SAAS;;;QAElC,QAAQ;YACN,KAAK;YACL,EAAE;gBAAI,KAAK;gBAAY,SAAS;;YAChC,EAAE;gBAAI,KAAK;gBAAY,SAAS;;;;UAGpC,CAAC"}
|
package/dist/entities/eval.d.ts
CHANGED
|
@@ -6,6 +6,36 @@ export declare const evalEntity: Entity<string, string, string, {
|
|
|
6
6
|
service: string;
|
|
7
7
|
};
|
|
8
8
|
attributes: {
|
|
9
|
+
createdAt: {
|
|
10
|
+
readonly type: 'string';
|
|
11
|
+
readonly required: true;
|
|
12
|
+
readonly readOnly: true;
|
|
13
|
+
readonly set: (value?: Date | string) => string;
|
|
14
|
+
readonly default: () => string;
|
|
15
|
+
};
|
|
16
|
+
updatedAt: {
|
|
17
|
+
readonly type: 'string';
|
|
18
|
+
readonly required: true;
|
|
19
|
+
readonly set: (value?: Date | string) => string;
|
|
20
|
+
readonly default: () => string;
|
|
21
|
+
};
|
|
22
|
+
metadata: {
|
|
23
|
+
readonly type: 'string';
|
|
24
|
+
readonly set: (value?: Record<string, unknown> | string) => string | undefined;
|
|
25
|
+
readonly get: (value?: string) => any;
|
|
26
|
+
};
|
|
27
|
+
ttl: {
|
|
28
|
+
readonly type: 'number';
|
|
29
|
+
readonly required: false;
|
|
30
|
+
};
|
|
31
|
+
expiresAt: {
|
|
32
|
+
readonly type: 'number';
|
|
33
|
+
readonly required: false;
|
|
34
|
+
};
|
|
35
|
+
entity: {
|
|
36
|
+
type: "string";
|
|
37
|
+
required: true;
|
|
38
|
+
};
|
|
9
39
|
input: {
|
|
10
40
|
type: "string";
|
|
11
41
|
required: true;
|
|
@@ -52,36 +82,6 @@ export declare const evalEntity: Entity<string, string, string, {
|
|
|
52
82
|
default: () => string;
|
|
53
83
|
set: (value?: Date | string) => string;
|
|
54
84
|
};
|
|
55
|
-
createdAt: {
|
|
56
|
-
readonly type: "string";
|
|
57
|
-
readonly required: true;
|
|
58
|
-
readonly readOnly: true;
|
|
59
|
-
readonly set: (value?: Date | string) => string;
|
|
60
|
-
readonly default: () => string;
|
|
61
|
-
};
|
|
62
|
-
updatedAt: {
|
|
63
|
-
readonly type: "string";
|
|
64
|
-
readonly required: true;
|
|
65
|
-
readonly set: (value?: Date | string) => string;
|
|
66
|
-
readonly default: () => string;
|
|
67
|
-
};
|
|
68
|
-
metadata: {
|
|
69
|
-
readonly type: "string";
|
|
70
|
-
readonly set: (value?: Record<string, unknown> | string) => string | undefined;
|
|
71
|
-
readonly get: (value?: string) => any;
|
|
72
|
-
};
|
|
73
|
-
ttl: {
|
|
74
|
-
readonly type: "number";
|
|
75
|
-
readonly required: false;
|
|
76
|
-
};
|
|
77
|
-
expiresAt: {
|
|
78
|
-
readonly type: "number";
|
|
79
|
-
readonly required: false;
|
|
80
|
-
};
|
|
81
|
-
entity: {
|
|
82
|
-
type: "string";
|
|
83
|
-
required: true;
|
|
84
|
-
};
|
|
85
85
|
};
|
|
86
86
|
indexes: {
|
|
87
87
|
primary: {
|
|
@@ -98,7 +98,7 @@ export declare const evalEntity: Entity<string, string, string, {
|
|
|
98
98
|
index: string;
|
|
99
99
|
pk: {
|
|
100
100
|
field: string;
|
|
101
|
-
composite: ("
|
|
101
|
+
composite: ("agent_name" | "entity")[];
|
|
102
102
|
};
|
|
103
103
|
sk: {
|
|
104
104
|
field: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eval.d.ts","sourceRoot":"","sources":["../../src/entities/eval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"eval.d.ts","sourceRoot":"","sources":["../../src/entities/eval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,eAAO,MAAM,UAAU;;QAEnB,MAAM;QACN,OAAO;QACP,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAoBS,GAAG;0BAOH,MAAM;;;;;;;;;;;;;;;;;0BAuBN,GAAG;0BAOH,MAAM;;;;;;;;;;;;;;0BAkBN,IAAI,GAAG,MAAM;;;;QAS7B,OAAO;YACL,EAAE;gBAAI,KAAK;gBAAQ,SAAS;;YAC5B,EAAE;gBAAI,KAAK;gBAAQ,SAAS;;;QAE9B,OAAO;YACL,KAAK;YACL,EAAE;gBAAI,KAAK;gBAAY,SAAS;;YAChC,EAAE;gBAAI,KAAK;gBAAY,SAAS;;;;UAGpC,CAAC"}
|