@mastra/dynamodb 0.0.0-update-stores-peerDeps-20250723031338 → 0.0.0-usechat-duplicate-20251016110554

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +1048 -0
  2. package/README.md +0 -4
  3. package/dist/entities/eval.d.ts +102 -0
  4. package/dist/entities/eval.d.ts.map +1 -0
  5. package/dist/entities/index.d.ts +761 -0
  6. package/dist/entities/index.d.ts.map +1 -0
  7. package/dist/entities/message.d.ts +100 -0
  8. package/dist/entities/message.d.ts.map +1 -0
  9. package/dist/entities/resource.d.ts +54 -0
  10. package/dist/entities/resource.d.ts.map +1 -0
  11. package/dist/entities/score.d.ts +244 -0
  12. package/dist/entities/score.d.ts.map +1 -0
  13. package/dist/entities/thread.d.ts +69 -0
  14. package/dist/entities/thread.d.ts.map +1 -0
  15. package/dist/entities/trace.d.ts +127 -0
  16. package/dist/entities/trace.d.ts.map +1 -0
  17. package/dist/entities/utils.d.ts +21 -0
  18. package/dist/entities/utils.d.ts.map +1 -0
  19. package/dist/entities/workflow-snapshot.d.ts +74 -0
  20. package/dist/entities/workflow-snapshot.d.ts.map +1 -0
  21. package/dist/index.cjs +256 -52
  22. package/dist/index.cjs.map +1 -0
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +257 -53
  26. package/dist/index.js.map +1 -0
  27. package/dist/storage/domains/legacy-evals/index.d.ts +19 -0
  28. package/dist/storage/domains/legacy-evals/index.d.ts.map +1 -0
  29. package/dist/storage/domains/memory/index.d.ts +89 -0
  30. package/dist/storage/domains/memory/index.d.ts.map +1 -0
  31. package/dist/storage/domains/operations/index.d.ts +69 -0
  32. package/dist/storage/domains/operations/index.d.ts.map +1 -0
  33. package/dist/storage/domains/score/index.d.ts +51 -0
  34. package/dist/storage/domains/score/index.d.ts.map +1 -0
  35. package/dist/storage/domains/traces/index.d.ts +28 -0
  36. package/dist/storage/domains/traces/index.d.ts.map +1 -0
  37. package/dist/storage/domains/workflows/index.d.ts +51 -0
  38. package/dist/storage/domains/workflows/index.d.ts.map +1 -0
  39. package/dist/storage/index.d.ts +259 -0
  40. package/dist/storage/index.d.ts.map +1 -0
  41. package/package.json +24 -14
  42. package/dist/_tsup-dts-rollup.d.cts +0 -1976
  43. package/dist/_tsup-dts-rollup.d.ts +0 -1976
  44. package/dist/index.d.cts +0 -2
  45. package/src/entities/eval.ts +0 -102
  46. package/src/entities/index.ts +0 -27
  47. package/src/entities/message.ts +0 -143
  48. package/src/entities/resource.ts +0 -57
  49. package/src/entities/score.ts +0 -285
  50. package/src/entities/thread.ts +0 -66
  51. package/src/entities/trace.ts +0 -129
  52. package/src/entities/utils.ts +0 -51
  53. package/src/entities/workflow-snapshot.ts +0 -56
  54. package/src/index.ts +0 -1
  55. package/src/storage/docker-compose.yml +0 -16
  56. package/src/storage/domains/legacy-evals/index.ts +0 -243
  57. package/src/storage/domains/memory/index.ts +0 -894
  58. package/src/storage/domains/operations/index.ts +0 -433
  59. package/src/storage/domains/score/index.ts +0 -285
  60. package/src/storage/domains/traces/index.ts +0 -286
  61. package/src/storage/domains/workflows/index.ts +0 -297
  62. package/src/storage/index.test.ts +0 -1420
  63. package/src/storage/index.ts +0 -482
package/dist/index.d.cts DELETED
@@ -1,2 +0,0 @@
1
- export { DynamoDBStoreConfig } from './_tsup-dts-rollup.cjs';
2
- export { DynamoDBStore } from './_tsup-dts-rollup.cjs';
@@ -1,102 +0,0 @@
1
- import { Entity } from 'electrodb';
2
- import { baseAttributes } from './utils';
3
-
4
- export const evalEntity = new Entity({
5
- model: {
6
- entity: 'eval',
7
- version: '1',
8
- service: 'mastra',
9
- },
10
- attributes: {
11
- entity: {
12
- type: 'string',
13
- required: true,
14
- },
15
- ...baseAttributes,
16
- input: {
17
- type: 'string',
18
- required: true,
19
- },
20
- output: {
21
- type: 'string',
22
- required: true,
23
- },
24
- result: {
25
- type: 'string', // JSON stringified
26
- required: true,
27
- // Stringify object on set
28
- set: (value?: any) => {
29
- if (value && typeof value !== 'string') {
30
- return JSON.stringify(value);
31
- }
32
- return value;
33
- },
34
- // Parse JSON string to object on get
35
- get: (value?: string) => {
36
- if (value) {
37
- return JSON.parse(value);
38
- }
39
- return value;
40
- },
41
- },
42
- agent_name: {
43
- type: 'string',
44
- required: true,
45
- },
46
- metric_name: {
47
- type: 'string',
48
- required: true,
49
- },
50
- instructions: {
51
- type: 'string',
52
- required: true,
53
- },
54
- test_info: {
55
- type: 'string', // JSON stringified
56
- required: false,
57
- // Stringify object on set
58
- set: (value?: any) => {
59
- if (value && typeof value !== 'string') {
60
- return JSON.stringify(value);
61
- }
62
- return value;
63
- },
64
- // Parse JSON string to object on get
65
- get: (value?: string) => {
66
- return value;
67
- },
68
- },
69
- global_run_id: {
70
- type: 'string',
71
- required: true,
72
- },
73
- run_id: {
74
- type: 'string',
75
- required: true,
76
- },
77
- created_at: {
78
- type: 'string',
79
- required: true,
80
- // Initialize with current timestamp if not provided
81
- default: () => new Date().toISOString(),
82
- // Convert Date to ISO string on set
83
- set: (value?: Date | string) => {
84
- if (value instanceof Date) {
85
- return value.toISOString();
86
- }
87
- return value || new Date().toISOString();
88
- },
89
- },
90
- },
91
- indexes: {
92
- primary: {
93
- pk: { field: 'pk', composite: ['entity', 'run_id'] },
94
- sk: { field: 'sk', composite: [] },
95
- },
96
- byAgent: {
97
- index: 'gsi1',
98
- pk: { field: 'gsi1pk', composite: ['entity', 'agent_name'] },
99
- sk: { field: 'gsi1sk', composite: ['created_at'] },
100
- },
101
- },
102
- });
@@ -1,27 +0,0 @@
1
- import type { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
2
- import { Service } from 'electrodb';
3
- import { evalEntity } from './eval';
4
- import { messageEntity } from './message';
5
- import { resourceEntity } from './resource';
6
- import { scoreEntity } from './score';
7
- import { threadEntity } from './thread';
8
- import { traceEntity } from './trace';
9
- import { workflowSnapshotEntity } from './workflow-snapshot';
10
-
11
- export function getElectroDbService(client: DynamoDBDocumentClient, tableName: string) {
12
- return new Service(
13
- {
14
- thread: threadEntity,
15
- message: messageEntity,
16
- eval: evalEntity,
17
- trace: traceEntity,
18
- workflow_snapshot: workflowSnapshotEntity,
19
- resource: resourceEntity,
20
- score: scoreEntity,
21
- },
22
- {
23
- client,
24
- table: tableName,
25
- },
26
- );
27
- }
@@ -1,143 +0,0 @@
1
- import { Entity } from 'electrodb';
2
- import { baseAttributes } from './utils';
3
-
4
- export const messageEntity = new Entity({
5
- model: {
6
- entity: 'message',
7
- version: '1',
8
- service: 'mastra',
9
- },
10
- attributes: {
11
- entity: {
12
- type: 'string',
13
- required: true,
14
- },
15
- ...baseAttributes,
16
- id: {
17
- type: 'string',
18
- required: true,
19
- },
20
- threadId: {
21
- type: 'string',
22
- required: true,
23
- },
24
- content: {
25
- type: 'string',
26
- required: true,
27
- // Stringify content object on set if it's not already a string
28
- set: (value?: string | void) => {
29
- if (value && typeof value !== 'string') {
30
- return JSON.stringify(value);
31
- }
32
- return value;
33
- },
34
- // Parse JSON string to object on get ONLY if it looks like JSON
35
- get: (value?: string) => {
36
- if (value && typeof value === 'string') {
37
- try {
38
- // Attempt to parse only if it might be JSON (e.g., starts with { or [)
39
- if (value.startsWith('{') || value.startsWith('[')) {
40
- return JSON.parse(value);
41
- }
42
- } catch {
43
- // Ignore parse error, return original string
44
- return value;
45
- }
46
- }
47
- return value;
48
- },
49
- },
50
- role: {
51
- type: 'string',
52
- required: true,
53
- },
54
- type: {
55
- type: 'string',
56
- default: 'text',
57
- },
58
- resourceId: {
59
- type: 'string',
60
- required: false,
61
- },
62
- toolCallIds: {
63
- type: 'string',
64
- required: false,
65
- set: (value?: string[] | string) => {
66
- if (Array.isArray(value)) {
67
- return JSON.stringify(value);
68
- }
69
- return value;
70
- },
71
- // Parse JSON string to array on get
72
- get: (value?: string) => {
73
- if (value && typeof value === 'string') {
74
- try {
75
- return JSON.parse(value);
76
- } catch {
77
- // Return raw value on error, consistent with 'content' field
78
- return value;
79
- }
80
- }
81
- // If value was not a string, or if it was an empty string, return it as is.
82
- return value;
83
- },
84
- },
85
- toolCallArgs: {
86
- type: 'string',
87
- required: false,
88
- set: (value?: Record<string, unknown>[] | string) => {
89
- if (value && typeof value !== 'string') {
90
- return JSON.stringify(value);
91
- }
92
- return value;
93
- },
94
- // Parse JSON string to object on get
95
- get: (value?: string) => {
96
- if (value && typeof value === 'string') {
97
- try {
98
- return JSON.parse(value);
99
- } catch {
100
- // Return raw value on error, consistent with 'content' field
101
- return value;
102
- }
103
- }
104
- // If value was not a string, or if it was an empty string, return it as is.
105
- return value;
106
- },
107
- },
108
- toolNames: {
109
- type: 'string',
110
- required: false,
111
- set: (value?: string[] | string) => {
112
- if (Array.isArray(value)) {
113
- return JSON.stringify(value);
114
- }
115
- return value;
116
- },
117
- // Parse JSON string to array on get
118
- get: (value?: string) => {
119
- if (value && typeof value === 'string') {
120
- try {
121
- return JSON.parse(value);
122
- } catch {
123
- // Return raw value on error, consistent with 'content' field
124
- return value;
125
- }
126
- }
127
- // If value was not a string, or if it was an empty string, return it as is.
128
- return value;
129
- },
130
- },
131
- },
132
- indexes: {
133
- primary: {
134
- pk: { field: 'pk', composite: ['entity', 'id'] },
135
- sk: { field: 'sk', composite: ['entity'] },
136
- },
137
- byThread: {
138
- index: 'gsi1',
139
- pk: { field: 'gsi1pk', composite: ['entity', 'threadId'] },
140
- sk: { field: 'gsi1sk', composite: ['createdAt'] },
141
- },
142
- },
143
- });
@@ -1,57 +0,0 @@
1
- import { Entity } from 'electrodb';
2
- import { baseAttributes } from './utils';
3
-
4
- export const resourceEntity = new Entity({
5
- model: {
6
- entity: 'resource',
7
- version: '1',
8
- service: 'mastra',
9
- },
10
- attributes: {
11
- entity: {
12
- type: 'string',
13
- required: true,
14
- },
15
- ...baseAttributes,
16
- id: {
17
- type: 'string',
18
- required: true,
19
- },
20
- workingMemory: {
21
- type: 'string',
22
- required: false,
23
- },
24
- metadata: {
25
- type: 'string',
26
- required: false,
27
- // Stringify content object on set if it's not already a string
28
- set: (value?: string | void) => {
29
- if (value && typeof value !== 'string') {
30
- return JSON.stringify(value);
31
- }
32
- return value;
33
- },
34
- // Parse JSON string to object on get ONLY if it looks like JSON
35
- get: (value?: string) => {
36
- if (value && typeof value === 'string') {
37
- try {
38
- // Attempt to parse only if it might be JSON (e.g., starts with { or [)
39
- if (value.startsWith('{') || value.startsWith('[')) {
40
- return JSON.parse(value);
41
- }
42
- } catch {
43
- // Ignore parse error, return original string
44
- return value;
45
- }
46
- }
47
- return value;
48
- },
49
- },
50
- },
51
- indexes: {
52
- primary: {
53
- pk: { field: 'pk', composite: ['entity', 'id'] },
54
- sk: { field: 'sk', composite: ['entity'] },
55
- },
56
- },
57
- });
@@ -1,285 +0,0 @@
1
- import { Entity } from 'electrodb';
2
- import { baseAttributes } from './utils';
3
-
4
- export const scoreEntity = new Entity({
5
- model: {
6
- entity: 'score',
7
- version: '1',
8
- service: 'mastra',
9
- },
10
- attributes: {
11
- entity: {
12
- type: 'string',
13
- required: true,
14
- },
15
- ...baseAttributes,
16
- id: {
17
- type: 'string',
18
- required: true,
19
- },
20
- scorerId: {
21
- type: 'string',
22
- required: true,
23
- },
24
- traceId: {
25
- type: 'string',
26
- required: false,
27
- },
28
- runId: {
29
- type: 'string',
30
- required: true,
31
- },
32
- scorer: {
33
- type: 'string',
34
- required: true,
35
- set: (value?: Record<string, unknown> | string) => {
36
- if (value && typeof value !== 'string') {
37
- return JSON.stringify(value);
38
- }
39
- return value;
40
- },
41
- get: (value?: string) => {
42
- if (value && typeof value === 'string') {
43
- try {
44
- if (value.startsWith('{') || value.startsWith('[')) {
45
- return JSON.parse(value);
46
- }
47
- } catch {
48
- return value;
49
- }
50
- }
51
- return value;
52
- },
53
- },
54
- extractStepResult: {
55
- type: 'string',
56
- required: false,
57
- set: (value?: Record<string, unknown> | string) => {
58
- if (value && typeof value !== 'string') {
59
- return JSON.stringify(value);
60
- }
61
- return value;
62
- },
63
- get: (value?: string) => {
64
- if (value && typeof value === 'string') {
65
- try {
66
- if (value.startsWith('{') || value.startsWith('[')) {
67
- return JSON.parse(value);
68
- }
69
- } catch {
70
- return value;
71
- }
72
- }
73
- return value;
74
- },
75
- },
76
- analyzeStepResult: {
77
- type: 'string',
78
- required: false,
79
- set: (value?: Record<string, unknown> | string) => {
80
- if (value && typeof value !== 'string') {
81
- return JSON.stringify(value);
82
- }
83
- return value;
84
- },
85
- get: (value?: string) => {
86
- if (value && typeof value === 'string') {
87
- try {
88
- if (value.startsWith('{') || value.startsWith('[')) {
89
- return JSON.parse(value);
90
- }
91
- } catch {
92
- return value;
93
- }
94
- }
95
- return value;
96
- },
97
- },
98
- score: {
99
- type: 'number',
100
- required: true,
101
- },
102
- reason: {
103
- type: 'string',
104
- required: false,
105
- },
106
- extractPrompt: {
107
- type: 'string',
108
- required: false,
109
- },
110
- analyzePrompt: {
111
- type: 'string',
112
- required: false,
113
- },
114
- reasonPrompt: {
115
- type: 'string',
116
- required: false,
117
- },
118
- input: {
119
- type: 'string',
120
- required: true,
121
- set: (value?: Record<string, unknown> | string) => {
122
- if (value && typeof value !== 'string') {
123
- return JSON.stringify(value);
124
- }
125
- return value;
126
- },
127
- get: (value?: string) => {
128
- if (value && typeof value === 'string') {
129
- try {
130
- if (value.startsWith('{') || value.startsWith('[')) {
131
- return JSON.parse(value);
132
- }
133
- } catch {
134
- return value;
135
- }
136
- }
137
- return value;
138
- },
139
- },
140
- output: {
141
- type: 'string',
142
- required: true,
143
- set: (value?: Record<string, unknown> | string) => {
144
- if (value && typeof value !== 'string') {
145
- return JSON.stringify(value);
146
- }
147
- return value;
148
- },
149
- get: (value?: string) => {
150
- if (value && typeof value === 'string') {
151
- try {
152
- if (value.startsWith('{') || value.startsWith('[')) {
153
- return JSON.parse(value);
154
- }
155
- } catch {
156
- return value;
157
- }
158
- }
159
- return value;
160
- },
161
- },
162
- additionalContext: {
163
- type: 'string',
164
- required: false,
165
- set: (value?: Record<string, unknown> | string) => {
166
- if (value && typeof value !== 'string') {
167
- return JSON.stringify(value);
168
- }
169
- return value;
170
- },
171
- get: (value?: string) => {
172
- if (value && typeof value === 'string') {
173
- try {
174
- if (value.startsWith('{') || value.startsWith('[')) {
175
- return JSON.parse(value);
176
- }
177
- } catch {
178
- return value;
179
- }
180
- }
181
- return value;
182
- },
183
- },
184
- runtimeContext: {
185
- type: 'string',
186
- required: false,
187
- set: (value?: Record<string, unknown> | string) => {
188
- if (value && typeof value !== 'string') {
189
- return JSON.stringify(value);
190
- }
191
- return value;
192
- },
193
- get: (value?: string) => {
194
- if (value && typeof value === 'string') {
195
- try {
196
- if (value.startsWith('{') || value.startsWith('[')) {
197
- return JSON.parse(value);
198
- }
199
- } catch {
200
- return value;
201
- }
202
- }
203
- return value;
204
- },
205
- },
206
- entityType: {
207
- type: 'string',
208
- required: false,
209
- },
210
- entityData: {
211
- type: 'string',
212
- required: false,
213
- set: (value?: Record<string, unknown> | string) => {
214
- if (value && typeof value !== 'string') {
215
- return JSON.stringify(value);
216
- }
217
- return value;
218
- },
219
- get: (value?: string) => {
220
- if (value && typeof value === 'string') {
221
- try {
222
- if (value.startsWith('{') || value.startsWith('[')) {
223
- return JSON.parse(value);
224
- }
225
- } catch {
226
- return value;
227
- }
228
- }
229
- return value;
230
- },
231
- },
232
- entityId: {
233
- type: 'string',
234
- required: false,
235
- },
236
- source: {
237
- type: 'string',
238
- required: true,
239
- },
240
- resourceId: {
241
- type: 'string',
242
- required: false,
243
- },
244
- threadId: {
245
- type: 'string',
246
- required: false,
247
- },
248
- },
249
- indexes: {
250
- primary: {
251
- pk: { field: 'pk', composite: ['entity', 'id'] },
252
- sk: { field: 'sk', composite: ['entity'] },
253
- },
254
- byScorer: {
255
- index: 'gsi1',
256
- pk: { field: 'gsi1pk', composite: ['entity', 'scorerId'] },
257
- sk: { field: 'gsi1sk', composite: ['createdAt'] },
258
- },
259
- byRun: {
260
- index: 'gsi2',
261
- pk: { field: 'gsi2pk', composite: ['entity', 'runId'] },
262
- sk: { field: 'gsi2sk', composite: ['createdAt'] },
263
- },
264
- byTrace: {
265
- index: 'gsi3',
266
- pk: { field: 'gsi3pk', composite: ['entity', 'traceId'] },
267
- sk: { field: 'gsi3sk', composite: ['createdAt'] },
268
- },
269
- byEntityData: {
270
- index: 'gsi4',
271
- pk: { field: 'gsi4pk', composite: ['entity', 'entityId'] },
272
- sk: { field: 'gsi4sk', composite: ['createdAt'] },
273
- },
274
- byResource: {
275
- index: 'gsi5',
276
- pk: { field: 'gsi5pk', composite: ['entity', 'resourceId'] },
277
- sk: { field: 'gsi5sk', composite: ['createdAt'] },
278
- },
279
- byThread: {
280
- index: 'gsi6',
281
- pk: { field: 'gsi6pk', composite: ['entity', 'threadId'] },
282
- sk: { field: 'gsi6sk', composite: ['createdAt'] },
283
- },
284
- },
285
- });
@@ -1,66 +0,0 @@
1
- import { Entity } from 'electrodb';
2
- import { baseAttributes } from './utils';
3
-
4
- export const threadEntity = new Entity({
5
- model: {
6
- entity: 'thread',
7
- version: '1',
8
- service: 'mastra',
9
- },
10
- attributes: {
11
- entity: {
12
- type: 'string',
13
- required: true,
14
- },
15
- ...baseAttributes,
16
- id: {
17
- type: 'string',
18
- required: true,
19
- },
20
- resourceId: {
21
- type: 'string',
22
- required: true,
23
- },
24
- title: {
25
- type: 'string',
26
- required: true,
27
- },
28
- metadata: {
29
- type: 'string',
30
- required: false,
31
- // Stringify metadata object on set if it's not already a string
32
- set: (value?: Record<string, unknown> | string) => {
33
- if (value && typeof value !== 'string') {
34
- return JSON.stringify(value);
35
- }
36
- return value;
37
- },
38
- // Parse JSON string to object on get
39
- get: (value?: string) => {
40
- if (value && typeof value === 'string') {
41
- try {
42
- // Attempt to parse only if it might be JSON (e.g., starts with { or [)
43
- if (value.startsWith('{') || value.startsWith('[')) {
44
- return JSON.parse(value);
45
- }
46
- } catch {
47
- // Ignore parse error, return original string
48
- return value;
49
- }
50
- }
51
- return value;
52
- },
53
- },
54
- },
55
- indexes: {
56
- primary: {
57
- pk: { field: 'pk', composite: ['entity', 'id'] },
58
- sk: { field: 'sk', composite: ['id'] },
59
- },
60
- byResource: {
61
- index: 'gsi1',
62
- pk: { field: 'gsi1pk', composite: ['entity', 'resourceId'] },
63
- sk: { field: 'gsi1sk', composite: ['createdAt'] },
64
- },
65
- },
66
- });