@mastra/dynamodb 0.14.3 → 0.14.6-alpha.0
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 +743 -0
- package/dist/index.cjs +34 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +35 -2
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/operations/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +19 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +19 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +16 -7
- package/src/entities/eval.ts +0 -102
- package/src/entities/index.ts +0 -27
- package/src/entities/message.ts +0 -143
- package/src/entities/resource.ts +0 -57
- package/src/entities/score.ts +0 -317
- package/src/entities/thread.ts +0 -66
- package/src/entities/trace.ts +0 -129
- package/src/entities/utils.ts +0 -51
- package/src/entities/workflow-snapshot.ts +0 -56
- package/src/index.ts +0 -1
- package/src/storage/docker-compose.yml +0 -16
- package/src/storage/domains/legacy-evals/index.ts +0 -243
- package/src/storage/domains/memory/index.ts +0 -987
- package/src/storage/domains/operations/index.ts +0 -433
- package/src/storage/domains/score/index.ts +0 -292
- package/src/storage/domains/traces/index.ts +0 -286
- package/src/storage/domains/workflows/index.ts +0 -297
- package/src/storage/index.test.ts +0 -1420
- package/src/storage/index.ts +0 -504
package/src/entities/score.ts
DELETED
|
@@ -1,317 +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
|
-
preprocessStepResult: {
|
|
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
|
-
analyzeStepResult: {
|
|
99
|
-
type: 'string',
|
|
100
|
-
required: false,
|
|
101
|
-
set: (value?: Record<string, unknown> | string) => {
|
|
102
|
-
if (value && typeof value !== 'string') {
|
|
103
|
-
return JSON.stringify(value);
|
|
104
|
-
}
|
|
105
|
-
return value;
|
|
106
|
-
},
|
|
107
|
-
get: (value?: string) => {
|
|
108
|
-
if (value && typeof value === 'string') {
|
|
109
|
-
try {
|
|
110
|
-
if (value.startsWith('{') || value.startsWith('[')) {
|
|
111
|
-
return JSON.parse(value);
|
|
112
|
-
}
|
|
113
|
-
} catch {
|
|
114
|
-
return value;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return value;
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
score: {
|
|
121
|
-
type: 'number',
|
|
122
|
-
required: true,
|
|
123
|
-
},
|
|
124
|
-
reason: {
|
|
125
|
-
type: 'string',
|
|
126
|
-
required: false,
|
|
127
|
-
},
|
|
128
|
-
extractPrompt: {
|
|
129
|
-
type: 'string',
|
|
130
|
-
required: false,
|
|
131
|
-
},
|
|
132
|
-
analyzePrompt: {
|
|
133
|
-
type: 'string',
|
|
134
|
-
required: false,
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
// Deprecated in favor of generateReasonPrompt
|
|
138
|
-
reasonPrompt: {
|
|
139
|
-
type: 'string',
|
|
140
|
-
required: false,
|
|
141
|
-
},
|
|
142
|
-
generateScorePrompt: {
|
|
143
|
-
type: 'string',
|
|
144
|
-
required: false,
|
|
145
|
-
},
|
|
146
|
-
generateReasonPrompt: {
|
|
147
|
-
type: 'string',
|
|
148
|
-
required: false,
|
|
149
|
-
},
|
|
150
|
-
input: {
|
|
151
|
-
type: 'string',
|
|
152
|
-
required: true,
|
|
153
|
-
set: (value?: Record<string, unknown> | string) => {
|
|
154
|
-
if (value && typeof value !== 'string') {
|
|
155
|
-
return JSON.stringify(value);
|
|
156
|
-
}
|
|
157
|
-
return value;
|
|
158
|
-
},
|
|
159
|
-
get: (value?: string) => {
|
|
160
|
-
if (value && typeof value === 'string') {
|
|
161
|
-
try {
|
|
162
|
-
if (value.startsWith('{') || value.startsWith('[')) {
|
|
163
|
-
return JSON.parse(value);
|
|
164
|
-
}
|
|
165
|
-
} catch {
|
|
166
|
-
return value;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return value;
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
output: {
|
|
173
|
-
type: 'string',
|
|
174
|
-
required: true,
|
|
175
|
-
set: (value?: Record<string, unknown> | string) => {
|
|
176
|
-
if (value && typeof value !== 'string') {
|
|
177
|
-
return JSON.stringify(value);
|
|
178
|
-
}
|
|
179
|
-
return value;
|
|
180
|
-
},
|
|
181
|
-
get: (value?: string) => {
|
|
182
|
-
if (value && typeof value === 'string') {
|
|
183
|
-
try {
|
|
184
|
-
if (value.startsWith('{') || value.startsWith('[')) {
|
|
185
|
-
return JSON.parse(value);
|
|
186
|
-
}
|
|
187
|
-
} catch {
|
|
188
|
-
return value;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return value;
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
additionalContext: {
|
|
195
|
-
type: 'string',
|
|
196
|
-
required: false,
|
|
197
|
-
set: (value?: Record<string, unknown> | string) => {
|
|
198
|
-
if (value && typeof value !== 'string') {
|
|
199
|
-
return JSON.stringify(value);
|
|
200
|
-
}
|
|
201
|
-
return value;
|
|
202
|
-
},
|
|
203
|
-
get: (value?: string) => {
|
|
204
|
-
if (value && typeof value === 'string') {
|
|
205
|
-
try {
|
|
206
|
-
if (value.startsWith('{') || value.startsWith('[')) {
|
|
207
|
-
return JSON.parse(value);
|
|
208
|
-
}
|
|
209
|
-
} catch {
|
|
210
|
-
return value;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
return value;
|
|
214
|
-
},
|
|
215
|
-
},
|
|
216
|
-
runtimeContext: {
|
|
217
|
-
type: 'string',
|
|
218
|
-
required: false,
|
|
219
|
-
set: (value?: Record<string, unknown> | string) => {
|
|
220
|
-
if (value && typeof value !== 'string') {
|
|
221
|
-
return JSON.stringify(value);
|
|
222
|
-
}
|
|
223
|
-
return value;
|
|
224
|
-
},
|
|
225
|
-
get: (value?: string) => {
|
|
226
|
-
if (value && typeof value === 'string') {
|
|
227
|
-
try {
|
|
228
|
-
if (value.startsWith('{') || value.startsWith('[')) {
|
|
229
|
-
return JSON.parse(value);
|
|
230
|
-
}
|
|
231
|
-
} catch {
|
|
232
|
-
return value;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
return value;
|
|
236
|
-
},
|
|
237
|
-
},
|
|
238
|
-
entityType: {
|
|
239
|
-
type: 'string',
|
|
240
|
-
required: false,
|
|
241
|
-
},
|
|
242
|
-
entityData: {
|
|
243
|
-
type: 'string',
|
|
244
|
-
required: false,
|
|
245
|
-
set: (value?: Record<string, unknown> | string) => {
|
|
246
|
-
if (value && typeof value !== 'string') {
|
|
247
|
-
return JSON.stringify(value);
|
|
248
|
-
}
|
|
249
|
-
return value;
|
|
250
|
-
},
|
|
251
|
-
get: (value?: string) => {
|
|
252
|
-
if (value && typeof value === 'string') {
|
|
253
|
-
try {
|
|
254
|
-
if (value.startsWith('{') || value.startsWith('[')) {
|
|
255
|
-
return JSON.parse(value);
|
|
256
|
-
}
|
|
257
|
-
} catch {
|
|
258
|
-
return value;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
return value;
|
|
262
|
-
},
|
|
263
|
-
},
|
|
264
|
-
entityId: {
|
|
265
|
-
type: 'string',
|
|
266
|
-
required: false,
|
|
267
|
-
},
|
|
268
|
-
source: {
|
|
269
|
-
type: 'string',
|
|
270
|
-
required: true,
|
|
271
|
-
},
|
|
272
|
-
resourceId: {
|
|
273
|
-
type: 'string',
|
|
274
|
-
required: false,
|
|
275
|
-
},
|
|
276
|
-
threadId: {
|
|
277
|
-
type: 'string',
|
|
278
|
-
required: false,
|
|
279
|
-
},
|
|
280
|
-
},
|
|
281
|
-
indexes: {
|
|
282
|
-
primary: {
|
|
283
|
-
pk: { field: 'pk', composite: ['entity', 'id'] },
|
|
284
|
-
sk: { field: 'sk', composite: ['entity'] },
|
|
285
|
-
},
|
|
286
|
-
byScorer: {
|
|
287
|
-
index: 'gsi1',
|
|
288
|
-
pk: { field: 'gsi1pk', composite: ['entity', 'scorerId'] },
|
|
289
|
-
sk: { field: 'gsi1sk', composite: ['createdAt'] },
|
|
290
|
-
},
|
|
291
|
-
byRun: {
|
|
292
|
-
index: 'gsi2',
|
|
293
|
-
pk: { field: 'gsi2pk', composite: ['entity', 'runId'] },
|
|
294
|
-
sk: { field: 'gsi2sk', composite: ['createdAt'] },
|
|
295
|
-
},
|
|
296
|
-
byTrace: {
|
|
297
|
-
index: 'gsi3',
|
|
298
|
-
pk: { field: 'gsi3pk', composite: ['entity', 'traceId'] },
|
|
299
|
-
sk: { field: 'gsi3sk', composite: ['createdAt'] },
|
|
300
|
-
},
|
|
301
|
-
byEntityData: {
|
|
302
|
-
index: 'gsi4',
|
|
303
|
-
pk: { field: 'gsi4pk', composite: ['entity', 'entityId'] },
|
|
304
|
-
sk: { field: 'gsi4sk', composite: ['createdAt'] },
|
|
305
|
-
},
|
|
306
|
-
byResource: {
|
|
307
|
-
index: 'gsi5',
|
|
308
|
-
pk: { field: 'gsi5pk', composite: ['entity', 'resourceId'] },
|
|
309
|
-
sk: { field: 'gsi5sk', composite: ['createdAt'] },
|
|
310
|
-
},
|
|
311
|
-
byThread: {
|
|
312
|
-
index: 'gsi6',
|
|
313
|
-
pk: { field: 'gsi6pk', composite: ['entity', 'threadId'] },
|
|
314
|
-
sk: { field: 'gsi6sk', composite: ['createdAt'] },
|
|
315
|
-
},
|
|
316
|
-
},
|
|
317
|
-
});
|
package/src/entities/thread.ts
DELETED
|
@@ -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
|
-
});
|
package/src/entities/trace.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { Entity } from 'electrodb';
|
|
2
|
-
import { baseAttributes } from './utils';
|
|
3
|
-
|
|
4
|
-
export const traceEntity = new Entity({
|
|
5
|
-
model: {
|
|
6
|
-
entity: 'trace',
|
|
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
|
-
parentSpanId: {
|
|
21
|
-
type: 'string',
|
|
22
|
-
required: false,
|
|
23
|
-
},
|
|
24
|
-
name: {
|
|
25
|
-
type: 'string',
|
|
26
|
-
required: true,
|
|
27
|
-
},
|
|
28
|
-
traceId: {
|
|
29
|
-
type: 'string',
|
|
30
|
-
required: true,
|
|
31
|
-
},
|
|
32
|
-
scope: {
|
|
33
|
-
type: 'string',
|
|
34
|
-
required: true,
|
|
35
|
-
},
|
|
36
|
-
kind: {
|
|
37
|
-
type: 'number',
|
|
38
|
-
required: true,
|
|
39
|
-
},
|
|
40
|
-
attributes: {
|
|
41
|
-
type: 'string', // JSON stringified
|
|
42
|
-
required: false,
|
|
43
|
-
// Stringify object on set
|
|
44
|
-
set: (value?: any) => {
|
|
45
|
-
if (value && typeof value !== 'string') {
|
|
46
|
-
return JSON.stringify(value);
|
|
47
|
-
}
|
|
48
|
-
return value;
|
|
49
|
-
},
|
|
50
|
-
// Parse JSON string to object on get
|
|
51
|
-
get: (value?: string) => {
|
|
52
|
-
return value ? JSON.parse(value) : value;
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
status: {
|
|
56
|
-
type: 'string', // JSON stringified
|
|
57
|
-
required: false,
|
|
58
|
-
// Stringify object on set
|
|
59
|
-
set: (value?: any) => {
|
|
60
|
-
if (value && typeof value !== 'string') {
|
|
61
|
-
return JSON.stringify(value);
|
|
62
|
-
}
|
|
63
|
-
return value;
|
|
64
|
-
},
|
|
65
|
-
// Parse JSON string to object on get
|
|
66
|
-
get: (value?: string) => {
|
|
67
|
-
return value;
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
events: {
|
|
71
|
-
type: 'string', // JSON stringified
|
|
72
|
-
required: false,
|
|
73
|
-
// Stringify object on set
|
|
74
|
-
set: (value?: any) => {
|
|
75
|
-
if (value && typeof value !== 'string') {
|
|
76
|
-
return JSON.stringify(value);
|
|
77
|
-
}
|
|
78
|
-
return value;
|
|
79
|
-
},
|
|
80
|
-
// Parse JSON string to object on get
|
|
81
|
-
get: (value?: string) => {
|
|
82
|
-
return value;
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
links: {
|
|
86
|
-
type: 'string', // JSON stringified
|
|
87
|
-
required: false,
|
|
88
|
-
// Stringify object on set
|
|
89
|
-
set: (value?: any) => {
|
|
90
|
-
if (value && typeof value !== 'string') {
|
|
91
|
-
return JSON.stringify(value);
|
|
92
|
-
}
|
|
93
|
-
return value;
|
|
94
|
-
},
|
|
95
|
-
// Parse JSON string to object on get
|
|
96
|
-
get: (value?: string) => {
|
|
97
|
-
return value;
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
other: {
|
|
101
|
-
type: 'string',
|
|
102
|
-
required: false,
|
|
103
|
-
},
|
|
104
|
-
startTime: {
|
|
105
|
-
type: 'number',
|
|
106
|
-
required: true,
|
|
107
|
-
},
|
|
108
|
-
endTime: {
|
|
109
|
-
type: 'number',
|
|
110
|
-
required: true,
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
indexes: {
|
|
114
|
-
primary: {
|
|
115
|
-
pk: { field: 'pk', composite: ['entity', 'id'] },
|
|
116
|
-
sk: { field: 'sk', composite: [] },
|
|
117
|
-
},
|
|
118
|
-
byName: {
|
|
119
|
-
index: 'gsi1',
|
|
120
|
-
pk: { field: 'gsi1pk', composite: ['entity', 'name'] },
|
|
121
|
-
sk: { field: 'gsi1sk', composite: ['startTime'] },
|
|
122
|
-
},
|
|
123
|
-
byScope: {
|
|
124
|
-
index: 'gsi2',
|
|
125
|
-
pk: { field: 'gsi2pk', composite: ['entity', 'scope'] },
|
|
126
|
-
sk: { field: 'gsi2sk', composite: ['startTime'] },
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
});
|
package/src/entities/utils.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
export const baseAttributes = {
|
|
2
|
-
createdAt: {
|
|
3
|
-
type: 'string',
|
|
4
|
-
required: true,
|
|
5
|
-
readOnly: true,
|
|
6
|
-
// Convert Date to ISO string on set
|
|
7
|
-
set: (value?: Date | string) => {
|
|
8
|
-
if (value instanceof Date) {
|
|
9
|
-
return value.toISOString();
|
|
10
|
-
}
|
|
11
|
-
return value || new Date().toISOString();
|
|
12
|
-
},
|
|
13
|
-
// Initialize with current timestamp if not provided
|
|
14
|
-
default: () => new Date().toISOString(),
|
|
15
|
-
},
|
|
16
|
-
updatedAt: {
|
|
17
|
-
type: 'string',
|
|
18
|
-
required: true,
|
|
19
|
-
// Convert Date to ISO string on set
|
|
20
|
-
set: (value?: Date | string) => {
|
|
21
|
-
if (value instanceof Date) {
|
|
22
|
-
return value.toISOString();
|
|
23
|
-
}
|
|
24
|
-
return value || new Date().toISOString();
|
|
25
|
-
},
|
|
26
|
-
// Always use current timestamp when creating/updating
|
|
27
|
-
default: () => new Date().toISOString(),
|
|
28
|
-
},
|
|
29
|
-
metadata: {
|
|
30
|
-
type: 'string', // JSON stringified
|
|
31
|
-
// Stringify objects on set
|
|
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) {
|
|
41
|
-
try {
|
|
42
|
-
return JSON.parse(value);
|
|
43
|
-
} catch {
|
|
44
|
-
// If parsing fails, return the original string
|
|
45
|
-
return value;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return value;
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
} as const;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Entity } from 'electrodb';
|
|
2
|
-
import { baseAttributes } from './utils';
|
|
3
|
-
|
|
4
|
-
export const workflowSnapshotEntity = new Entity({
|
|
5
|
-
model: {
|
|
6
|
-
entity: 'workflow_snapshot',
|
|
7
|
-
version: '1',
|
|
8
|
-
service: 'mastra',
|
|
9
|
-
},
|
|
10
|
-
attributes: {
|
|
11
|
-
entity: {
|
|
12
|
-
type: 'string',
|
|
13
|
-
required: true,
|
|
14
|
-
},
|
|
15
|
-
...baseAttributes,
|
|
16
|
-
workflow_name: {
|
|
17
|
-
type: 'string',
|
|
18
|
-
required: true,
|
|
19
|
-
},
|
|
20
|
-
run_id: {
|
|
21
|
-
type: 'string',
|
|
22
|
-
required: true,
|
|
23
|
-
},
|
|
24
|
-
snapshot: {
|
|
25
|
-
type: 'string', // JSON stringified
|
|
26
|
-
required: true,
|
|
27
|
-
// Stringify snapshot 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
|
-
return value ? JSON.parse(value) : value;
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
resourceId: {
|
|
40
|
-
type: 'string',
|
|
41
|
-
required: false,
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
indexes: {
|
|
45
|
-
primary: {
|
|
46
|
-
pk: { field: 'pk', composite: ['entity', 'workflow_name'] },
|
|
47
|
-
sk: { field: 'sk', composite: ['run_id'] },
|
|
48
|
-
},
|
|
49
|
-
// GSI to allow querying by run_id efficiently without knowing the workflow_name
|
|
50
|
-
gsi2: {
|
|
51
|
-
index: 'gsi2',
|
|
52
|
-
pk: { field: 'gsi2pk', composite: ['entity', 'run_id'] },
|
|
53
|
-
sk: { field: 'gsi2sk', composite: ['workflow_name'] },
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
});
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './storage';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
version: '3.8'
|
|
2
|
-
|
|
3
|
-
services:
|
|
4
|
-
dynamodb-local:
|
|
5
|
-
image: amazon/dynamodb-local:latest
|
|
6
|
-
# Use host network mode for simpler connection from tests,
|
|
7
|
-
# or define ports if running in bridge mode.
|
|
8
|
-
# network_mode: host
|
|
9
|
-
ports:
|
|
10
|
-
- '8000:8000' # Map container port 8000 to host port 8000
|
|
11
|
-
command: ['-jar', 'DynamoDBLocal.jar', '-sharedDb']
|
|
12
|
-
volumes:
|
|
13
|
-
- dynamodb_data:/home/dynamodblocal/data
|
|
14
|
-
|
|
15
|
-
volumes:
|
|
16
|
-
dynamodb_data: {}
|