@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/dist/index.js CHANGED
@@ -797,6 +797,26 @@ var scoreEntity = new Entity({
797
797
  type: "string",
798
798
  required: false
799
799
  },
800
+ organizationId: {
801
+ type: "string",
802
+ required: false
803
+ },
804
+ projectId: {
805
+ type: "string",
806
+ required: false
807
+ },
808
+ batchId: {
809
+ type: "string",
810
+ required: false
811
+ },
812
+ datasetId: {
813
+ type: "string",
814
+ required: false
815
+ },
816
+ datasetItemId: {
817
+ type: "string",
818
+ required: false
819
+ },
800
820
  threadId: {
801
821
  type: "string",
802
822
  required: false
@@ -2260,6 +2280,11 @@ var MemoryStorageDynamoDB = class extends MemoryStorage {
2260
2280
  }
2261
2281
  }
2262
2282
  };
2283
+ function matchesTenancy(score, filters) {
2284
+ if (filters?.organizationId !== void 0 && score.organizationId !== filters.organizationId) return false;
2285
+ if (filters?.projectId !== void 0 && score.projectId !== filters.projectId) return false;
2286
+ return true;
2287
+ }
2263
2288
  var ScoresStorageDynamoDB = class extends ScoresStorage {
2264
2289
  service;
2265
2290
  ttlConfig;
@@ -2398,7 +2423,8 @@ var ScoresStorageDynamoDB = class extends ScoresStorage {
2398
2423
  pagination,
2399
2424
  entityId,
2400
2425
  entityType,
2401
- source
2426
+ source,
2427
+ filters
2402
2428
  }) {
2403
2429
  try {
2404
2430
  const query = this.service.entities.score.query.byScorer({ entity: "score", scorerId });
@@ -2413,6 +2439,7 @@ var ScoresStorageDynamoDB = class extends ScoresStorage {
2413
2439
  if (source) {
2414
2440
  allScores = allScores.filter((score) => score.source === source);
2415
2441
  }
2442
+ allScores = allScores.filter((score) => matchesTenancy(score, filters));
2416
2443
  allScores.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
2417
2444
  const { page, perPage: perPageInput } = pagination;
2418
2445
  const perPage = normalizePerPage(perPageInput, Number.MAX_SAFE_INTEGER);
@@ -2450,13 +2477,14 @@ var ScoresStorageDynamoDB = class extends ScoresStorage {
2450
2477
  }
2451
2478
  async listScoresByRunId({
2452
2479
  runId,
2453
- pagination
2480
+ pagination,
2481
+ filters
2454
2482
  }) {
2455
2483
  this.logger.debug("Getting scores by run ID", { runId, pagination });
2456
2484
  try {
2457
2485
  const query = this.service.entities.score.query.byRun({ entity: "score", runId });
2458
2486
  const results = await query.go();
2459
- const allScores = results.data.map((data) => this.parseScoreData(data));
2487
+ const allScores = results.data.map((data) => this.parseScoreData(data)).filter((score) => matchesTenancy(score, filters));
2460
2488
  allScores.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
2461
2489
  const { page, perPage: perPageInput } = pagination;
2462
2490
  const perPage = normalizePerPage(perPageInput, Number.MAX_SAFE_INTEGER);
@@ -2488,7 +2516,8 @@ var ScoresStorageDynamoDB = class extends ScoresStorage {
2488
2516
  async listScoresByEntityId({
2489
2517
  entityId,
2490
2518
  entityType,
2491
- pagination
2519
+ pagination,
2520
+ filters
2492
2521
  }) {
2493
2522
  this.logger.debug("Getting scores by entity ID", { entityId, entityType, pagination });
2494
2523
  try {
@@ -2496,6 +2525,7 @@ var ScoresStorageDynamoDB = class extends ScoresStorage {
2496
2525
  const results = await query.go();
2497
2526
  let allScores = results.data.map((data) => this.parseScoreData(data));
2498
2527
  allScores = allScores.filter((score) => score.entityType === entityType);
2528
+ allScores = allScores.filter((score) => matchesTenancy(score, filters));
2499
2529
  allScores.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
2500
2530
  const { page, perPage: perPageInput } = pagination;
2501
2531
  const perPage = normalizePerPage(perPageInput, Number.MAX_SAFE_INTEGER);
@@ -2527,13 +2557,14 @@ var ScoresStorageDynamoDB = class extends ScoresStorage {
2527
2557
  async listScoresBySpan({
2528
2558
  traceId,
2529
2559
  spanId,
2530
- pagination
2560
+ pagination,
2561
+ filters
2531
2562
  }) {
2532
2563
  this.logger.debug("Getting scores by span", { traceId, spanId, pagination });
2533
2564
  try {
2534
2565
  const query = this.service.entities.score.query.bySpan({ entity: "score", traceId, spanId });
2535
2566
  const results = await query.go();
2536
- const allScores = results.data.map((data) => this.parseScoreData(data));
2567
+ const allScores = results.data.map((data) => this.parseScoreData(data)).filter((score) => matchesTenancy(score, filters));
2537
2568
  allScores.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
2538
2569
  const { page, perPage: perPageInput } = pagination;
2539
2570
  const perPage = normalizePerPage(perPageInput, Number.MAX_SAFE_INTEGER);