@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
package/dist/index.js
CHANGED
|
@@ -418,6 +418,28 @@ var scoreEntity = new Entity({
|
|
|
418
418
|
return value;
|
|
419
419
|
}
|
|
420
420
|
},
|
|
421
|
+
preprocessStepResult: {
|
|
422
|
+
type: "string",
|
|
423
|
+
required: false,
|
|
424
|
+
set: (value) => {
|
|
425
|
+
if (value && typeof value !== "string") {
|
|
426
|
+
return JSON.stringify(value);
|
|
427
|
+
}
|
|
428
|
+
return value;
|
|
429
|
+
},
|
|
430
|
+
get: (value) => {
|
|
431
|
+
if (value && typeof value === "string") {
|
|
432
|
+
try {
|
|
433
|
+
if (value.startsWith("{") || value.startsWith("[")) {
|
|
434
|
+
return JSON.parse(value);
|
|
435
|
+
}
|
|
436
|
+
} catch {
|
|
437
|
+
return value;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return value;
|
|
441
|
+
}
|
|
442
|
+
},
|
|
421
443
|
analyzeStepResult: {
|
|
422
444
|
type: "string",
|
|
423
445
|
required: false,
|
|
@@ -456,10 +478,19 @@ var scoreEntity = new Entity({
|
|
|
456
478
|
type: "string",
|
|
457
479
|
required: false
|
|
458
480
|
},
|
|
481
|
+
// Deprecated in favor of generateReasonPrompt
|
|
459
482
|
reasonPrompt: {
|
|
460
483
|
type: "string",
|
|
461
484
|
required: false
|
|
462
485
|
},
|
|
486
|
+
generateScorePrompt: {
|
|
487
|
+
type: "string",
|
|
488
|
+
required: false
|
|
489
|
+
},
|
|
490
|
+
generateReasonPrompt: {
|
|
491
|
+
type: "string",
|
|
492
|
+
required: false
|
|
493
|
+
},
|
|
463
494
|
input: {
|
|
464
495
|
type: "string",
|
|
465
496
|
required: true,
|
|
@@ -1090,6 +1121,20 @@ var MemoryStorageDynamoDB = class extends MemoryStorage {
|
|
|
1090
1121
|
// transformed by the ElectroDB entity getters.
|
|
1091
1122
|
};
|
|
1092
1123
|
}
|
|
1124
|
+
// Helper function to transform and sort threads
|
|
1125
|
+
transformAndSortThreads(rawThreads, orderBy, sortDirection) {
|
|
1126
|
+
return rawThreads.map((data) => ({
|
|
1127
|
+
...data,
|
|
1128
|
+
// Convert date strings back to Date objects for consistency
|
|
1129
|
+
createdAt: typeof data.createdAt === "string" ? new Date(data.createdAt) : data.createdAt,
|
|
1130
|
+
updatedAt: typeof data.updatedAt === "string" ? new Date(data.updatedAt) : data.updatedAt
|
|
1131
|
+
})).sort((a, b) => {
|
|
1132
|
+
const fieldA = orderBy === "createdAt" ? a.createdAt : a.updatedAt;
|
|
1133
|
+
const fieldB = orderBy === "createdAt" ? b.createdAt : b.updatedAt;
|
|
1134
|
+
const comparison = fieldA.getTime() - fieldB.getTime();
|
|
1135
|
+
return sortDirection === "DESC" ? -comparison : comparison;
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1093
1138
|
async getThreadById({ threadId }) {
|
|
1094
1139
|
this.logger.debug("Getting thread by ID", { threadId });
|
|
1095
1140
|
try {
|
|
@@ -1118,21 +1163,20 @@ var MemoryStorageDynamoDB = class extends MemoryStorage {
|
|
|
1118
1163
|
);
|
|
1119
1164
|
}
|
|
1120
1165
|
}
|
|
1121
|
-
|
|
1122
|
-
|
|
1166
|
+
/**
|
|
1167
|
+
* @deprecated use getThreadsByResourceIdPaginated instead for paginated results.
|
|
1168
|
+
*/
|
|
1169
|
+
async getThreadsByResourceId(args) {
|
|
1170
|
+
const resourceId = args.resourceId;
|
|
1171
|
+
const orderBy = this.castThreadOrderBy(args.orderBy);
|
|
1172
|
+
const sortDirection = this.castThreadSortDirection(args.sortDirection);
|
|
1173
|
+
this.logger.debug("Getting threads by resource ID", { resourceId, orderBy, sortDirection });
|
|
1123
1174
|
try {
|
|
1124
1175
|
const result = await this.service.entities.thread.query.byResource({ entity: "thread", resourceId }).go();
|
|
1125
1176
|
if (!result.data.length) {
|
|
1126
1177
|
return [];
|
|
1127
1178
|
}
|
|
1128
|
-
return result.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
|
-
// metadata: data.metadata ? JSON.parse(data.metadata) : undefined, // REMOVED by AI
|
|
1134
|
-
// metadata is already transformed by the entity's getter
|
|
1135
|
-
}));
|
|
1179
|
+
return this.transformAndSortThreads(result.data, orderBy, sortDirection);
|
|
1136
1180
|
} catch (error) {
|
|
1137
1181
|
throw new MastraError(
|
|
1138
1182
|
{
|
|
@@ -1389,11 +1433,19 @@ var MemoryStorageDynamoDB = class extends MemoryStorage {
|
|
|
1389
1433
|
}
|
|
1390
1434
|
async getThreadsByResourceIdPaginated(args) {
|
|
1391
1435
|
const { resourceId, page = 0, perPage = 100 } = args;
|
|
1392
|
-
this.
|
|
1436
|
+
const orderBy = this.castThreadOrderBy(args.orderBy);
|
|
1437
|
+
const sortDirection = this.castThreadSortDirection(args.sortDirection);
|
|
1438
|
+
this.logger.debug("Getting threads by resource ID with pagination", {
|
|
1439
|
+
resourceId,
|
|
1440
|
+
page,
|
|
1441
|
+
perPage,
|
|
1442
|
+
orderBy,
|
|
1443
|
+
sortDirection
|
|
1444
|
+
});
|
|
1393
1445
|
try {
|
|
1394
1446
|
const query = this.service.entities.thread.query.byResource({ entity: "thread", resourceId });
|
|
1395
1447
|
const results = await query.go();
|
|
1396
|
-
const allThreads = results.data;
|
|
1448
|
+
const allThreads = this.transformAndSortThreads(results.data, orderBy, sortDirection);
|
|
1397
1449
|
const startIndex = page * perPage;
|
|
1398
1450
|
const endIndex = startIndex + perPage;
|
|
1399
1451
|
const paginatedThreads = allThreads.slice(startIndex, endIndex);
|
|
@@ -2097,11 +2149,12 @@ var ScoresStorageDynamoDB = class extends ScoresStorage {
|
|
|
2097
2149
|
traceId: score.traceId || "",
|
|
2098
2150
|
runId: score.runId,
|
|
2099
2151
|
scorer: typeof score.scorer === "string" ? score.scorer : JSON.stringify(score.scorer),
|
|
2100
|
-
|
|
2152
|
+
preprocessStepResult: typeof score.preprocessStepResult === "string" ? score.preprocessStepResult : JSON.stringify(score.preprocessStepResult),
|
|
2101
2153
|
analyzeStepResult: typeof score.analyzeStepResult === "string" ? score.analyzeStepResult : JSON.stringify(score.analyzeStepResult),
|
|
2102
2154
|
score: score.score,
|
|
2103
2155
|
reason: score.reason,
|
|
2104
|
-
|
|
2156
|
+
preprocessPrompt: score.preprocessPrompt,
|
|
2157
|
+
generateScorePrompt: score.generateScorePrompt,
|
|
2105
2158
|
analyzePrompt: score.analyzePrompt,
|
|
2106
2159
|
reasonPrompt: score.reasonPrompt,
|
|
2107
2160
|
input: typeof score.input === "string" ? score.input : JSON.stringify(score.input),
|
|
@@ -2857,8 +2910,8 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
2857
2910
|
async getThreadById({ threadId }) {
|
|
2858
2911
|
return this.stores.memory.getThreadById({ threadId });
|
|
2859
2912
|
}
|
|
2860
|
-
async getThreadsByResourceId(
|
|
2861
|
-
return this.stores.memory.getThreadsByResourceId(
|
|
2913
|
+
async getThreadsByResourceId(args) {
|
|
2914
|
+
return this.stores.memory.getThreadsByResourceId(args);
|
|
2862
2915
|
}
|
|
2863
2916
|
async saveThread({ thread }) {
|
|
2864
2917
|
return this.stores.memory.saveThread({ thread });
|
|
@@ -2998,3 +3051,5 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
2998
3051
|
};
|
|
2999
3052
|
|
|
3000
3053
|
export { DynamoDBStore };
|
|
3054
|
+
//# sourceMappingURL=index.js.map
|
|
3055
|
+
//# sourceMappingURL=index.js.map
|