@mastra/dynamodb 1.1.1 → 1.1.2-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 +37 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-storage-dynamodb.md +2 -0
- package/dist/entities/index.d.ts +20 -0
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/entities/score.d.ts +20 -0
- package/dist/entities/score.d.ts.map +1 -1
- package/dist/index.cjs +37 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -6
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +9 -5
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @mastra/dynamodb
|
|
2
2
|
|
|
3
|
+
## 1.1.2-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add optional `batchId`, `datasetId`, and `datasetItemId` fields to persisted scores so saved baseline scores can be grouped as one scoring pass and joined back to the dataset items they came from. ([#18331](https://github.com/mastra-ai/mastra/pull/18331))
|
|
8
|
+
- `scoreTrace()` accepts top-level `batchId`, `datasetId`, and `datasetItemId` when persisting a score for a stored trace.
|
|
9
|
+
- `ScoreRowData` and score save payloads now include nullable `batchId`, `datasetId`, and `datasetItemId`.
|
|
10
|
+
- Built-in stores with explicit score schema or attribute mappings now persist these provenance fields on saved scores.
|
|
11
|
+
- D1, DSQL, MSSQL, and Upstash score stores now apply additive provenance migrations or deterministic score ordering for persisted score reads.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
await scoreTrace({
|
|
15
|
+
storage,
|
|
16
|
+
scorer,
|
|
17
|
+
target: { traceId },
|
|
18
|
+
batchId: 'baseline-batch-1',
|
|
19
|
+
datasetId,
|
|
20
|
+
datasetItemId,
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
- Added optional `organizationId` and `projectId` fields to scores for multi-tenant isolation. Scores can now be saved with tenancy metadata and the `listScoresBy*` methods accept a `filters` option to scope results by organization and project. ([#18331](https://github.com/mastra-ai/mastra/pull/18331))
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
await storage.saveScore({ ...score, organizationId: 'org-a', projectId: 'proj-1' });
|
|
28
|
+
|
|
29
|
+
const result = await storage.listScoresByScorerId({
|
|
30
|
+
scorerId,
|
|
31
|
+
filters: { organizationId: 'org-a', projectId: 'proj-1' },
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`projectId` identifies the project scope, separate from `resourceId` which continues to mean the agent memory resource.
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [[`9250acd`](https://github.com/mastra-ai/mastra/commit/9250acd1357f0f1f33d0dcca16f9655084c58eca), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`c64c2a8`](https://github.com/mastra-ai/mastra/commit/c64c2a8503a50252f9ca6b8e8c54cadee31b92a2), [`06e2680`](https://github.com/mastra-ai/mastra/commit/06e26806b51d2cbd858afdc66daa2b86ff3ba64a), [`1240f05`](https://github.com/mastra-ai/mastra/commit/1240f051c8e5371f1c014448bf37b1a1b9a05e47), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748)]:
|
|
38
|
+
- @mastra/core@1.49.0-alpha.5
|
|
39
|
+
|
|
3
40
|
## 1.1.1
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
1
3
|
# DynamoDB storage
|
|
2
4
|
|
|
3
5
|
The DynamoDB storage implementation provides a scalable and performant NoSQL database solution for Mastra, leveraging a single-table design pattern with [ElectroDB](https://electrodb.dev/).
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -698,6 +698,26 @@ export declare function getElectroDbService(client: DynamoDBDocumentClient, tabl
|
|
|
698
698
|
type: "string";
|
|
699
699
|
required: false;
|
|
700
700
|
};
|
|
701
|
+
organizationId: {
|
|
702
|
+
type: "string";
|
|
703
|
+
required: false;
|
|
704
|
+
};
|
|
705
|
+
projectId: {
|
|
706
|
+
type: "string";
|
|
707
|
+
required: false;
|
|
708
|
+
};
|
|
709
|
+
batchId: {
|
|
710
|
+
type: "string";
|
|
711
|
+
required: false;
|
|
712
|
+
};
|
|
713
|
+
datasetId: {
|
|
714
|
+
type: "string";
|
|
715
|
+
required: false;
|
|
716
|
+
};
|
|
717
|
+
datasetItemId: {
|
|
718
|
+
type: "string";
|
|
719
|
+
required: false;
|
|
720
|
+
};
|
|
701
721
|
threadId: {
|
|
702
722
|
type: "string";
|
|
703
723
|
required: false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUp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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiBpF"}
|
package/dist/entities/score.d.ts
CHANGED
|
@@ -134,6 +134,26 @@ export declare const scoreEntity: Entity<string, string, string, {
|
|
|
134
134
|
type: "string";
|
|
135
135
|
required: false;
|
|
136
136
|
};
|
|
137
|
+
organizationId: {
|
|
138
|
+
type: "string";
|
|
139
|
+
required: false;
|
|
140
|
+
};
|
|
141
|
+
projectId: {
|
|
142
|
+
type: "string";
|
|
143
|
+
required: false;
|
|
144
|
+
};
|
|
145
|
+
batchId: {
|
|
146
|
+
type: "string";
|
|
147
|
+
required: false;
|
|
148
|
+
};
|
|
149
|
+
datasetId: {
|
|
150
|
+
type: "string";
|
|
151
|
+
required: false;
|
|
152
|
+
};
|
|
153
|
+
datasetItemId: {
|
|
154
|
+
type: "string";
|
|
155
|
+
required: false;
|
|
156
|
+
};
|
|
137
157
|
threadId: {
|
|
138
158
|
type: "string";
|
|
139
159
|
required: false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"score.d.ts","sourceRoot":"","sources":["../../src/entities/score.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAmCJ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;0BAMhC,MAAM;;;;;0BAgBN,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;0BAMhC,MAAM;;;;;;;;;0BAoBN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;;;;0BAgBN,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;0BAMhC,MAAM;;;;;0BAgBN,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;0BAMhC,MAAM;;;;;0BAgBN,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;0BAMhC,MAAM;;;;;0BAgBN,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;0BAMhC,MAAM;;;;;;;;;0BAoBN,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;0BAMhC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA2FxB,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -799,6 +799,26 @@ var scoreEntity = new electrodb.Entity({
|
|
|
799
799
|
type: "string",
|
|
800
800
|
required: false
|
|
801
801
|
},
|
|
802
|
+
organizationId: {
|
|
803
|
+
type: "string",
|
|
804
|
+
required: false
|
|
805
|
+
},
|
|
806
|
+
projectId: {
|
|
807
|
+
type: "string",
|
|
808
|
+
required: false
|
|
809
|
+
},
|
|
810
|
+
batchId: {
|
|
811
|
+
type: "string",
|
|
812
|
+
required: false
|
|
813
|
+
},
|
|
814
|
+
datasetId: {
|
|
815
|
+
type: "string",
|
|
816
|
+
required: false
|
|
817
|
+
},
|
|
818
|
+
datasetItemId: {
|
|
819
|
+
type: "string",
|
|
820
|
+
required: false
|
|
821
|
+
},
|
|
802
822
|
threadId: {
|
|
803
823
|
type: "string",
|
|
804
824
|
required: false
|
|
@@ -2262,6 +2282,11 @@ var MemoryStorageDynamoDB = class extends storage.MemoryStorage {
|
|
|
2262
2282
|
}
|
|
2263
2283
|
}
|
|
2264
2284
|
};
|
|
2285
|
+
function matchesTenancy(score, filters) {
|
|
2286
|
+
if (filters?.organizationId !== void 0 && score.organizationId !== filters.organizationId) return false;
|
|
2287
|
+
if (filters?.projectId !== void 0 && score.projectId !== filters.projectId) return false;
|
|
2288
|
+
return true;
|
|
2289
|
+
}
|
|
2265
2290
|
var ScoresStorageDynamoDB = class extends storage.ScoresStorage {
|
|
2266
2291
|
service;
|
|
2267
2292
|
ttlConfig;
|
|
@@ -2400,7 +2425,8 @@ var ScoresStorageDynamoDB = class extends storage.ScoresStorage {
|
|
|
2400
2425
|
pagination,
|
|
2401
2426
|
entityId,
|
|
2402
2427
|
entityType,
|
|
2403
|
-
source
|
|
2428
|
+
source,
|
|
2429
|
+
filters
|
|
2404
2430
|
}) {
|
|
2405
2431
|
try {
|
|
2406
2432
|
const query = this.service.entities.score.query.byScorer({ entity: "score", scorerId });
|
|
@@ -2415,6 +2441,7 @@ var ScoresStorageDynamoDB = class extends storage.ScoresStorage {
|
|
|
2415
2441
|
if (source) {
|
|
2416
2442
|
allScores = allScores.filter((score) => score.source === source);
|
|
2417
2443
|
}
|
|
2444
|
+
allScores = allScores.filter((score) => matchesTenancy(score, filters));
|
|
2418
2445
|
allScores.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
2419
2446
|
const { page, perPage: perPageInput } = pagination;
|
|
2420
2447
|
const perPage = storage.normalizePerPage(perPageInput, Number.MAX_SAFE_INTEGER);
|
|
@@ -2452,13 +2479,14 @@ var ScoresStorageDynamoDB = class extends storage.ScoresStorage {
|
|
|
2452
2479
|
}
|
|
2453
2480
|
async listScoresByRunId({
|
|
2454
2481
|
runId,
|
|
2455
|
-
pagination
|
|
2482
|
+
pagination,
|
|
2483
|
+
filters
|
|
2456
2484
|
}) {
|
|
2457
2485
|
this.logger.debug("Getting scores by run ID", { runId, pagination });
|
|
2458
2486
|
try {
|
|
2459
2487
|
const query = this.service.entities.score.query.byRun({ entity: "score", runId });
|
|
2460
2488
|
const results = await query.go();
|
|
2461
|
-
const allScores = results.data.map((data) => this.parseScoreData(data));
|
|
2489
|
+
const allScores = results.data.map((data) => this.parseScoreData(data)).filter((score) => matchesTenancy(score, filters));
|
|
2462
2490
|
allScores.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
2463
2491
|
const { page, perPage: perPageInput } = pagination;
|
|
2464
2492
|
const perPage = storage.normalizePerPage(perPageInput, Number.MAX_SAFE_INTEGER);
|
|
@@ -2490,7 +2518,8 @@ var ScoresStorageDynamoDB = class extends storage.ScoresStorage {
|
|
|
2490
2518
|
async listScoresByEntityId({
|
|
2491
2519
|
entityId,
|
|
2492
2520
|
entityType,
|
|
2493
|
-
pagination
|
|
2521
|
+
pagination,
|
|
2522
|
+
filters
|
|
2494
2523
|
}) {
|
|
2495
2524
|
this.logger.debug("Getting scores by entity ID", { entityId, entityType, pagination });
|
|
2496
2525
|
try {
|
|
@@ -2498,6 +2527,7 @@ var ScoresStorageDynamoDB = class extends storage.ScoresStorage {
|
|
|
2498
2527
|
const results = await query.go();
|
|
2499
2528
|
let allScores = results.data.map((data) => this.parseScoreData(data));
|
|
2500
2529
|
allScores = allScores.filter((score) => score.entityType === entityType);
|
|
2530
|
+
allScores = allScores.filter((score) => matchesTenancy(score, filters));
|
|
2501
2531
|
allScores.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
2502
2532
|
const { page, perPage: perPageInput } = pagination;
|
|
2503
2533
|
const perPage = storage.normalizePerPage(perPageInput, Number.MAX_SAFE_INTEGER);
|
|
@@ -2529,13 +2559,14 @@ var ScoresStorageDynamoDB = class extends storage.ScoresStorage {
|
|
|
2529
2559
|
async listScoresBySpan({
|
|
2530
2560
|
traceId,
|
|
2531
2561
|
spanId,
|
|
2532
|
-
pagination
|
|
2562
|
+
pagination,
|
|
2563
|
+
filters
|
|
2533
2564
|
}) {
|
|
2534
2565
|
this.logger.debug("Getting scores by span", { traceId, spanId, pagination });
|
|
2535
2566
|
try {
|
|
2536
2567
|
const query = this.service.entities.score.query.bySpan({ entity: "score", traceId, spanId });
|
|
2537
2568
|
const results = await query.go();
|
|
2538
|
-
const allScores = results.data.map((data) => this.parseScoreData(data));
|
|
2569
|
+
const allScores = results.data.map((data) => this.parseScoreData(data)).filter((score) => matchesTenancy(score, filters));
|
|
2539
2570
|
allScores.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
2540
2571
|
const { page, perPage: perPageInput } = pagination;
|
|
2541
2572
|
const perPage = storage.normalizePerPage(perPageInput, Number.MAX_SAFE_INTEGER);
|