@mastra/dynamodb 1.1.0 → 1.1.1-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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @mastra/dynamodb
2
2
 
3
+ ## 1.1.1-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed workflow runs preserving their original creation time when re-persisted in DynamoDB storage, including concurrent saves. ([#18004](https://github.com/mastra-ai/mastra/pull/18004))
8
+
9
+ - Updated dependencies [[`bf3fe49`](https://github.com/mastra-ai/mastra/commit/bf3fe49f9467dbbdb8f9eaf74e0f7971ffb19559), [`24ceaea`](https://github.com/mastra-ai/mastra/commit/24ceaea0bdd8609cabbab764380608ca6621a194), [`6ccf67b`](https://github.com/mastra-ai/mastra/commit/6ccf67bf075753754927a57bc2e1734ba2c820c5), [`825d8de`](https://github.com/mastra-ai/mastra/commit/825d8def9fa64c2bcc3d8dd6b49e09342c3ac5c7), [`ffa09e7`](https://github.com/mastra-ai/mastra/commit/ffa09e772a5c92270eabe2090fc42d45bd8ec4b7), [`461a7c5`](https://github.com/mastra-ai/mastra/commit/461a7c501449295287f4f0ee4b0b42344f39fcf8), [`4211472`](https://github.com/mastra-ai/mastra/commit/4211472a5a2bd319c60cd2e42d9109c3eef7ac1c), [`9e45902`](https://github.com/mastra-ai/mastra/commit/9e4590208e745055cecca202e2db0e5c65e17d3c), [`5c0df77`](https://github.com/mastra-ai/mastra/commit/5c0df776c40efa420f8c07a2f3ee66010296618e)]:
10
+ - @mastra/core@1.47.0-alpha.3
11
+
3
12
  ## 1.1.0
4
13
 
5
14
  ### Minor Changes
@@ -3,7 +3,7 @@ name: mastra-dynamodb
3
3
  description: Documentation for @mastra/dynamodb. Use when working with @mastra/dynamodb APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/dynamodb"
6
- version: "1.1.0"
6
+ version: "1.1.1-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.0",
2
+ "version": "1.1.1-alpha.0",
3
3
  "package": "@mastra/dynamodb",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -2782,17 +2782,35 @@ var WorkflowStorageDynamoDB = class extends storage.WorkflowsStorage {
2782
2782
  this.logger.debug("Persisting workflow snapshot", { workflowName, runId });
2783
2783
  try {
2784
2784
  const now = /* @__PURE__ */ new Date();
2785
+ const createdAtValue = (createdAt ?? now).toISOString();
2786
+ const updatedAtValue = (updatedAt ?? now).toISOString();
2785
2787
  const data = {
2786
2788
  entity: "workflow_snapshot",
2787
2789
  workflow_name: workflowName,
2788
2790
  run_id: runId,
2789
2791
  snapshot: JSON.stringify(snapshot),
2790
- createdAt: (createdAt ?? now).toISOString(),
2791
- updatedAt: (updatedAt ?? now).toISOString(),
2792
+ createdAt: createdAtValue,
2793
+ updatedAt: updatedAtValue,
2792
2794
  resourceId,
2793
2795
  ...getTtlProps("workflow_snapshot", this.ttlConfig)
2794
2796
  };
2795
- await this.service.entities.workflow_snapshot.upsert(data).go();
2797
+ try {
2798
+ await this.service.entities.workflow_snapshot.create(data).where((attr, op) => op.notExists(attr.run_id)).go();
2799
+ } catch (error) {
2800
+ if (!this.isConditionalCheckFailed(error)) {
2801
+ throw error;
2802
+ }
2803
+ await this.service.entities.workflow_snapshot.update({
2804
+ entity: "workflow_snapshot",
2805
+ workflow_name: workflowName,
2806
+ run_id: runId
2807
+ }).set({
2808
+ snapshot: JSON.stringify(snapshot),
2809
+ updatedAt: updatedAtValue,
2810
+ resourceId,
2811
+ ...getTtlProps("workflow_snapshot", this.ttlConfig)
2812
+ }).go();
2813
+ }
2796
2814
  } catch (error$1) {
2797
2815
  throw new error.MastraError(
2798
2816
  {