@mastra/dynamodb 0.13.3 → 0.14.0-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/dist/entities/eval.d.ts +102 -0
- package/dist/entities/eval.d.ts.map +1 -0
- package/dist/entities/index.d.ts +746 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/message.d.ts +100 -0
- package/dist/entities/message.d.ts.map +1 -0
- package/dist/entities/resource.d.ts +54 -0
- package/dist/entities/resource.d.ts.map +1 -0
- package/dist/entities/score.d.ts +229 -0
- package/dist/entities/score.d.ts.map +1 -0
- package/dist/entities/thread.d.ts +69 -0
- package/dist/entities/thread.d.ts.map +1 -0
- package/dist/entities/trace.d.ts +127 -0
- package/dist/entities/trace.d.ts.map +1 -0
- package/dist/entities/utils.d.ts +21 -0
- package/dist/entities/utils.d.ts.map +1 -0
- package/dist/entities/workflow-snapshot.d.ts +74 -0
- package/dist/entities/workflow-snapshot.d.ts.map +1 -0
- package/dist/index.cjs +71 -16
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +71 -16
- package/dist/index.js.map +1 -0
- package/dist/storage/domains/legacy-evals/index.d.ts +19 -0
- package/dist/storage/domains/legacy-evals/index.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +81 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -0
- package/dist/storage/domains/operations/index.d.ts +69 -0
- package/dist/storage/domains/operations/index.d.ts.map +1 -0
- package/dist/storage/domains/score/index.d.ts +42 -0
- package/dist/storage/domains/score/index.d.ts.map +1 -0
- package/dist/storage/domains/traces/index.d.ts +28 -0
- package/dist/storage/domains/traces/index.d.ts.map +1 -0
- package/dist/storage/domains/workflows/index.d.ts +32 -0
- package/dist/storage/domains/workflows/index.d.ts.map +1 -0
- package/dist/storage/index.d.ts +220 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/package.json +9 -8
- package/src/entities/score.ts +32 -0
- package/src/storage/domains/memory/index.ts +56 -19
- package/src/storage/domains/score/index.ts +6 -3
- package/src/storage/index.ts +10 -7
- package/dist/_tsup-dts-rollup.d.cts +0 -1977
- package/dist/_tsup-dts-rollup.d.ts +0 -1977
- package/dist/index.d.cts +0 -2
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Entity } from 'electrodb';
|
|
2
|
+
export declare const workflowSnapshotEntity: Entity<string, string, string, {
|
|
3
|
+
model: {
|
|
4
|
+
entity: string;
|
|
5
|
+
version: string;
|
|
6
|
+
service: string;
|
|
7
|
+
};
|
|
8
|
+
attributes: {
|
|
9
|
+
workflow_name: {
|
|
10
|
+
type: "string";
|
|
11
|
+
required: true;
|
|
12
|
+
};
|
|
13
|
+
run_id: {
|
|
14
|
+
type: "string";
|
|
15
|
+
required: true;
|
|
16
|
+
};
|
|
17
|
+
snapshot: {
|
|
18
|
+
type: "string";
|
|
19
|
+
required: true;
|
|
20
|
+
set: (value?: any) => any;
|
|
21
|
+
get: (value?: string) => any;
|
|
22
|
+
};
|
|
23
|
+
resourceId: {
|
|
24
|
+
type: "string";
|
|
25
|
+
required: false;
|
|
26
|
+
};
|
|
27
|
+
createdAt: {
|
|
28
|
+
readonly type: "string";
|
|
29
|
+
readonly required: true;
|
|
30
|
+
readonly readOnly: true;
|
|
31
|
+
readonly set: (value?: Date | string) => string;
|
|
32
|
+
readonly default: () => string;
|
|
33
|
+
};
|
|
34
|
+
updatedAt: {
|
|
35
|
+
readonly type: "string";
|
|
36
|
+
readonly required: true;
|
|
37
|
+
readonly set: (value?: Date | string) => string;
|
|
38
|
+
readonly default: () => string;
|
|
39
|
+
};
|
|
40
|
+
metadata: {
|
|
41
|
+
readonly type: "string";
|
|
42
|
+
readonly set: (value?: Record<string, unknown> | string) => string | undefined;
|
|
43
|
+
readonly get: (value?: string) => any;
|
|
44
|
+
};
|
|
45
|
+
entity: {
|
|
46
|
+
type: "string";
|
|
47
|
+
required: true;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
indexes: {
|
|
51
|
+
primary: {
|
|
52
|
+
pk: {
|
|
53
|
+
field: string;
|
|
54
|
+
composite: ("entity" | "workflow_name")[];
|
|
55
|
+
};
|
|
56
|
+
sk: {
|
|
57
|
+
field: string;
|
|
58
|
+
composite: "run_id"[];
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
gsi2: {
|
|
62
|
+
index: string;
|
|
63
|
+
pk: {
|
|
64
|
+
field: string;
|
|
65
|
+
composite: ("entity" | "run_id")[];
|
|
66
|
+
};
|
|
67
|
+
sk: {
|
|
68
|
+
field: string;
|
|
69
|
+
composite: "workflow_name"[];
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
}>;
|
|
74
|
+
//# sourceMappingURL=workflow-snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-snapshot.d.ts","sourceRoot":"","sources":["../../src/entities/workflow-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;0BAwBf,GAAG;0BAOH,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBxB,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -420,6 +420,28 @@ var scoreEntity = new electrodb.Entity({
|
|
|
420
420
|
return value;
|
|
421
421
|
}
|
|
422
422
|
},
|
|
423
|
+
preprocessStepResult: {
|
|
424
|
+
type: "string",
|
|
425
|
+
required: false,
|
|
426
|
+
set: (value) => {
|
|
427
|
+
if (value && typeof value !== "string") {
|
|
428
|
+
return JSON.stringify(value);
|
|
429
|
+
}
|
|
430
|
+
return value;
|
|
431
|
+
},
|
|
432
|
+
get: (value) => {
|
|
433
|
+
if (value && typeof value === "string") {
|
|
434
|
+
try {
|
|
435
|
+
if (value.startsWith("{") || value.startsWith("[")) {
|
|
436
|
+
return JSON.parse(value);
|
|
437
|
+
}
|
|
438
|
+
} catch {
|
|
439
|
+
return value;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
return value;
|
|
443
|
+
}
|
|
444
|
+
},
|
|
423
445
|
analyzeStepResult: {
|
|
424
446
|
type: "string",
|
|
425
447
|
required: false,
|
|
@@ -458,10 +480,19 @@ var scoreEntity = new electrodb.Entity({
|
|
|
458
480
|
type: "string",
|
|
459
481
|
required: false
|
|
460
482
|
},
|
|
483
|
+
// Deprecated in favor of generateReasonPrompt
|
|
461
484
|
reasonPrompt: {
|
|
462
485
|
type: "string",
|
|
463
486
|
required: false
|
|
464
487
|
},
|
|
488
|
+
generateScorePrompt: {
|
|
489
|
+
type: "string",
|
|
490
|
+
required: false
|
|
491
|
+
},
|
|
492
|
+
generateReasonPrompt: {
|
|
493
|
+
type: "string",
|
|
494
|
+
required: false
|
|
495
|
+
},
|
|
465
496
|
input: {
|
|
466
497
|
type: "string",
|
|
467
498
|
required: true,
|
|
@@ -1092,6 +1123,20 @@ var MemoryStorageDynamoDB = class extends storage.MemoryStorage {
|
|
|
1092
1123
|
// transformed by the ElectroDB entity getters.
|
|
1093
1124
|
};
|
|
1094
1125
|
}
|
|
1126
|
+
// Helper function to transform and sort threads
|
|
1127
|
+
transformAndSortThreads(rawThreads, orderBy, sortDirection) {
|
|
1128
|
+
return rawThreads.map((data) => ({
|
|
1129
|
+
...data,
|
|
1130
|
+
// Convert date strings back to Date objects for consistency
|
|
1131
|
+
createdAt: typeof data.createdAt === "string" ? new Date(data.createdAt) : data.createdAt,
|
|
1132
|
+
updatedAt: typeof data.updatedAt === "string" ? new Date(data.updatedAt) : data.updatedAt
|
|
1133
|
+
})).sort((a, b) => {
|
|
1134
|
+
const fieldA = orderBy === "createdAt" ? a.createdAt : a.updatedAt;
|
|
1135
|
+
const fieldB = orderBy === "createdAt" ? b.createdAt : b.updatedAt;
|
|
1136
|
+
const comparison = fieldA.getTime() - fieldB.getTime();
|
|
1137
|
+
return sortDirection === "DESC" ? -comparison : comparison;
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1095
1140
|
async getThreadById({ threadId }) {
|
|
1096
1141
|
this.logger.debug("Getting thread by ID", { threadId });
|
|
1097
1142
|
try {
|
|
@@ -1120,21 +1165,20 @@ var MemoryStorageDynamoDB = class extends storage.MemoryStorage {
|
|
|
1120
1165
|
);
|
|
1121
1166
|
}
|
|
1122
1167
|
}
|
|
1123
|
-
|
|
1124
|
-
|
|
1168
|
+
/**
|
|
1169
|
+
* @deprecated use getThreadsByResourceIdPaginated instead for paginated results.
|
|
1170
|
+
*/
|
|
1171
|
+
async getThreadsByResourceId(args) {
|
|
1172
|
+
const resourceId = args.resourceId;
|
|
1173
|
+
const orderBy = this.castThreadOrderBy(args.orderBy);
|
|
1174
|
+
const sortDirection = this.castThreadSortDirection(args.sortDirection);
|
|
1175
|
+
this.logger.debug("Getting threads by resource ID", { resourceId, orderBy, sortDirection });
|
|
1125
1176
|
try {
|
|
1126
1177
|
const result = await this.service.entities.thread.query.byResource({ entity: "thread", resourceId }).go();
|
|
1127
1178
|
if (!result.data.length) {
|
|
1128
1179
|
return [];
|
|
1129
1180
|
}
|
|
1130
|
-
return result.data
|
|
1131
|
-
...data,
|
|
1132
|
-
// Convert date strings back to Date objects for consistency
|
|
1133
|
-
createdAt: typeof data.createdAt === "string" ? new Date(data.createdAt) : data.createdAt,
|
|
1134
|
-
updatedAt: typeof data.updatedAt === "string" ? new Date(data.updatedAt) : data.updatedAt
|
|
1135
|
-
// metadata: data.metadata ? JSON.parse(data.metadata) : undefined, // REMOVED by AI
|
|
1136
|
-
// metadata is already transformed by the entity's getter
|
|
1137
|
-
}));
|
|
1181
|
+
return this.transformAndSortThreads(result.data, orderBy, sortDirection);
|
|
1138
1182
|
} catch (error$1) {
|
|
1139
1183
|
throw new error.MastraError(
|
|
1140
1184
|
{
|
|
@@ -1391,11 +1435,19 @@ var MemoryStorageDynamoDB = class extends storage.MemoryStorage {
|
|
|
1391
1435
|
}
|
|
1392
1436
|
async getThreadsByResourceIdPaginated(args) {
|
|
1393
1437
|
const { resourceId, page = 0, perPage = 100 } = args;
|
|
1394
|
-
this.
|
|
1438
|
+
const orderBy = this.castThreadOrderBy(args.orderBy);
|
|
1439
|
+
const sortDirection = this.castThreadSortDirection(args.sortDirection);
|
|
1440
|
+
this.logger.debug("Getting threads by resource ID with pagination", {
|
|
1441
|
+
resourceId,
|
|
1442
|
+
page,
|
|
1443
|
+
perPage,
|
|
1444
|
+
orderBy,
|
|
1445
|
+
sortDirection
|
|
1446
|
+
});
|
|
1395
1447
|
try {
|
|
1396
1448
|
const query = this.service.entities.thread.query.byResource({ entity: "thread", resourceId });
|
|
1397
1449
|
const results = await query.go();
|
|
1398
|
-
const allThreads = results.data;
|
|
1450
|
+
const allThreads = this.transformAndSortThreads(results.data, orderBy, sortDirection);
|
|
1399
1451
|
const startIndex = page * perPage;
|
|
1400
1452
|
const endIndex = startIndex + perPage;
|
|
1401
1453
|
const paginatedThreads = allThreads.slice(startIndex, endIndex);
|
|
@@ -2099,11 +2151,12 @@ var ScoresStorageDynamoDB = class extends storage.ScoresStorage {
|
|
|
2099
2151
|
traceId: score.traceId || "",
|
|
2100
2152
|
runId: score.runId,
|
|
2101
2153
|
scorer: typeof score.scorer === "string" ? score.scorer : JSON.stringify(score.scorer),
|
|
2102
|
-
|
|
2154
|
+
preprocessStepResult: typeof score.preprocessStepResult === "string" ? score.preprocessStepResult : JSON.stringify(score.preprocessStepResult),
|
|
2103
2155
|
analyzeStepResult: typeof score.analyzeStepResult === "string" ? score.analyzeStepResult : JSON.stringify(score.analyzeStepResult),
|
|
2104
2156
|
score: score.score,
|
|
2105
2157
|
reason: score.reason,
|
|
2106
|
-
|
|
2158
|
+
preprocessPrompt: score.preprocessPrompt,
|
|
2159
|
+
generateScorePrompt: score.generateScorePrompt,
|
|
2107
2160
|
analyzePrompt: score.analyzePrompt,
|
|
2108
2161
|
reasonPrompt: score.reasonPrompt,
|
|
2109
2162
|
input: typeof score.input === "string" ? score.input : JSON.stringify(score.input),
|
|
@@ -2859,8 +2912,8 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
2859
2912
|
async getThreadById({ threadId }) {
|
|
2860
2913
|
return this.stores.memory.getThreadById({ threadId });
|
|
2861
2914
|
}
|
|
2862
|
-
async getThreadsByResourceId(
|
|
2863
|
-
return this.stores.memory.getThreadsByResourceId(
|
|
2915
|
+
async getThreadsByResourceId(args) {
|
|
2916
|
+
return this.stores.memory.getThreadsByResourceId(args);
|
|
2864
2917
|
}
|
|
2865
2918
|
async saveThread({ thread }) {
|
|
2866
2919
|
return this.stores.memory.saveThread({ thread });
|
|
@@ -3000,3 +3053,5 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
3000
3053
|
};
|
|
3001
3054
|
|
|
3002
3055
|
exports.DynamoDBStore = DynamoDBStore;
|
|
3056
|
+
//# sourceMappingURL=index.cjs.map
|
|
3057
|
+
//# sourceMappingURL=index.cjs.map
|