@mastra/dynamodb 1.0.0-beta.3 → 1.0.0-beta.5

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 CHANGED
@@ -1,5 +1,34 @@
1
1
  # @mastra/dynamodb
2
2
 
3
+ ## 1.0.0-beta.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Add delete workflow run API ([#10991](https://github.com/mastra-ai/mastra/pull/10991))
8
+
9
+ ```typescript
10
+ await workflow.deleteWorkflowRunById(runId);
11
+ ```
12
+
13
+ - Updated dependencies [[`edb07e4`](https://github.com/mastra-ai/mastra/commit/edb07e49283e0c28bd094a60e03439bf6ecf0221), [`b7e17d3`](https://github.com/mastra-ai/mastra/commit/b7e17d3f5390bb5a71efc112204413656fcdc18d), [`261473a`](https://github.com/mastra-ai/mastra/commit/261473ac637e633064a22076671e2e02b002214d), [`5d7000f`](https://github.com/mastra-ai/mastra/commit/5d7000f757cd65ea9dc5b05e662fd83dfd44e932), [`4f0331a`](https://github.com/mastra-ai/mastra/commit/4f0331a79bf6eb5ee598a5086e55de4b5a0ada03), [`8a000da`](https://github.com/mastra-ai/mastra/commit/8a000da0c09c679a2312f6b3aa05b2ca78ca7393)]:
14
+ - @mastra/core@1.0.0-beta.10
15
+
16
+ ## 1.0.0-beta.4
17
+
18
+ ### Patch Changes
19
+
20
+ - Fix saveScore not persisting ID correctly, breaking getScoreById retrieval ([#10915](https://github.com/mastra-ai/mastra/pull/10915))
21
+
22
+ **What Changed**
23
+ - saveScore now correctly returns scores that can be retrieved with getScoreById
24
+ - Validation errors now include contextual information (scorer, entity, trace details) for easier debugging
25
+
26
+ **Impact**
27
+ Previously, calling getScoreById after saveScore would return null because the generated ID wasn't persisted to the database. This is now fixed across all store implementations, ensuring consistent behavior and data integrity.
28
+
29
+ - Updated dependencies [[`0d41fe2`](https://github.com/mastra-ai/mastra/commit/0d41fe245355dfc66d61a0d9c85d9400aac351ff), [`6b3ba91`](https://github.com/mastra-ai/mastra/commit/6b3ba91494cc10394df96782f349a4f7b1e152cc), [`7907fd1`](https://github.com/mastra-ai/mastra/commit/7907fd1c5059813b7b870b81ca71041dc807331b)]:
30
+ - @mastra/core@1.0.0-beta.8
31
+
3
32
  ## 1.0.0-beta.3
4
33
 
5
34
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -1665,7 +1665,8 @@ var StoreOperationsDynamoDB = class extends storage.StoreOperations {
1665
1665
  [storage.TABLE_SCORERS]: "score",
1666
1666
  [storage.TABLE_TRACES]: "trace",
1667
1667
  [storage.TABLE_RESOURCES]: "resource",
1668
- [storage.TABLE_SPANS]: "ai_span"
1668
+ [storage.TABLE_SPANS]: "ai_span",
1669
+ mastra_agents: "agent"
1669
1670
  };
1670
1671
  return mapping[tableName] || null;
1671
1672
  }
@@ -2018,13 +2019,20 @@ var ScoresStorageDynamoDB = class extends storage.ScoresStorage {
2018
2019
  {
2019
2020
  id: storage.createStorageErrorId("DYNAMODB", "SAVE_SCORE", "VALIDATION_FAILED"),
2020
2021
  domain: error.ErrorDomain.STORAGE,
2021
- category: error.ErrorCategory.THIRD_PARTY
2022
+ category: error.ErrorCategory.USER,
2023
+ details: {
2024
+ scorer: score.scorer?.id ?? "unknown",
2025
+ entityId: score.entityId ?? "unknown",
2026
+ entityType: score.entityType ?? "unknown",
2027
+ traceId: score.traceId ?? "",
2028
+ spanId: score.spanId ?? ""
2029
+ }
2022
2030
  },
2023
2031
  error$1
2024
2032
  );
2025
2033
  }
2026
2034
  const now = /* @__PURE__ */ new Date();
2027
- const scoreId = `score-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
2035
+ const scoreId = crypto.randomUUID();
2028
2036
  const scorer = typeof validatedScore.scorer === "string" ? validatedScore.scorer : JSON.stringify(validatedScore.scorer);
2029
2037
  const preprocessStepResult = typeof validatedScore.preprocessStepResult === "string" ? validatedScore.preprocessStepResult : JSON.stringify(validatedScore.preprocessStepResult);
2030
2038
  const analyzeStepResult = typeof validatedScore.analyzeStepResult === "string" ? validatedScore.analyzeStepResult : JSON.stringify(validatedScore.analyzeStepResult);
@@ -2054,13 +2062,14 @@ var ScoresStorageDynamoDB = class extends storage.ScoresStorage {
2054
2062
  );
2055
2063
  try {
2056
2064
  await this.service.entities.score.upsert(scoreData).go();
2057
- const savedScore = {
2058
- ...score,
2059
- id: scoreId,
2060
- createdAt: now,
2061
- updatedAt: now
2065
+ return {
2066
+ score: {
2067
+ ...validatedScore,
2068
+ id: scoreId,
2069
+ createdAt: now,
2070
+ updatedAt: now
2071
+ }
2062
2072
  };
2063
- return { score: savedScore };
2064
2073
  } catch (error$1) {
2065
2074
  throw new error.MastraError(
2066
2075
  {
@@ -2477,6 +2486,26 @@ var WorkflowStorageDynamoDB = class extends storage.WorkflowsStorage {
2477
2486
  );
2478
2487
  }
2479
2488
  }
2489
+ async deleteWorkflowRunById({ runId, workflowName }) {
2490
+ this.logger.debug("Deleting workflow run by ID", { runId, workflowName });
2491
+ try {
2492
+ await this.service.entities.workflow_snapshot.delete({
2493
+ entity: "workflow_snapshot",
2494
+ workflow_name: workflowName,
2495
+ run_id: runId
2496
+ }).go();
2497
+ } catch (error$1) {
2498
+ throw new error.MastraError(
2499
+ {
2500
+ id: storage.createStorageErrorId("DYNAMODB", "DELETE_WORKFLOW_RUN_BY_ID", "FAILED"),
2501
+ domain: error.ErrorDomain.STORAGE,
2502
+ category: error.ErrorCategory.THIRD_PARTY,
2503
+ details: { runId, workflowName }
2504
+ },
2505
+ error$1
2506
+ );
2507
+ }
2508
+ }
2480
2509
  };
2481
2510
 
2482
2511
  // src/storage/index.ts
@@ -2691,6 +2720,9 @@ var DynamoDBStore = class extends storage.MastraStorage {
2691
2720
  async getWorkflowRunById(args) {
2692
2721
  return this.stores.workflows.getWorkflowRunById(args);
2693
2722
  }
2723
+ async deleteWorkflowRunById({ runId, workflowName }) {
2724
+ return this.stores.workflows.deleteWorkflowRunById({ runId, workflowName });
2725
+ }
2694
2726
  async getResourceById({ resourceId }) {
2695
2727
  return this.stores.memory.getResourceById({ resourceId });
2696
2728
  }
@@ -2730,8 +2762,8 @@ var DynamoDBStore = class extends storage.MastraStorage {
2730
2762
  async getScoreById({ id: _id }) {
2731
2763
  return this.stores.scores.getScoreById({ id: _id });
2732
2764
  }
2733
- async saveScore(_score) {
2734
- return this.stores.scores.saveScore(_score);
2765
+ async saveScore(score) {
2766
+ return this.stores.scores.saveScore(score);
2735
2767
  }
2736
2768
  async listScoresByRunId({
2737
2769
  runId: _runId,