@mastra/mongodb 1.18.0 → 1.18.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,18 @@
1
1
  # @mastra/mongodb
2
2
 
3
+ ## 1.18.1-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed concurrent resume() calls on the same suspended workflow run executing downstream steps more than once. A resume now atomically claims the run before executing anything, so only one caller continues a given suspension. Losing callers throw WORKFLOW_RESUME_ALREADY_CLAIMED without running any steps. Fixes #20443 ([#21725](https://github.com/mastra-ai/mastra/pull/21725))
8
+
9
+ - Workflow state updates now support an optional expectedStatus guard, so a status change is only applied when the stored run is in an expected state. This is what makes concurrent workflow resumes safe. ([#21725](https://github.com/mastra-ai/mastra/pull/21725))
10
+
11
+ - Resume conflicts now return 409 Conflict. When a suspended workflow run has already been resumed by another caller, the resume endpoints respond with 409 instead of a generic error. ([#21725](https://github.com/mastra-ai/mastra/pull/21725))
12
+
13
+ - Updated dependencies [[`88d14ca`](https://github.com/mastra-ai/mastra/commit/88d14cac008582a618fecc3d5c7fd3bdf4f6ddc3), [`84a5b69`](https://github.com/mastra-ai/mastra/commit/84a5b699f84d6bae0a34efe5a970d891090b9f41), [`84a5b69`](https://github.com/mastra-ai/mastra/commit/84a5b699f84d6bae0a34efe5a970d891090b9f41), [`84a5b69`](https://github.com/mastra-ai/mastra/commit/84a5b699f84d6bae0a34efe5a970d891090b9f41), [`038b7b4`](https://github.com/mastra-ai/mastra/commit/038b7b405cb4ac25ab3f3031334111b1f87ac112), [`4132d61`](https://github.com/mastra-ai/mastra/commit/4132d61f8367077120ee9e6420d3224dffd93c93)]:
14
+ - @mastra/core@1.60.1-alpha.0
15
+
3
16
  ## 1.18.0
4
17
 
5
18
  ### Minor Changes
@@ -3,7 +3,7 @@ name: mastra-mongodb
3
3
  description: Documentation for @mastra/mongodb. Use when working with @mastra/mongodb APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/mongodb"
6
- version: "1.18.0"
6
+ version: "1.18.1-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.18.0",
2
+ "version": "1.18.1-alpha.0",
3
3
  "package": "@mastra/mongodb",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -10,7 +10,7 @@ let _mastra_core_agent = require("@mastra/core/agent");
10
10
  let _mastra_core_evals = require("@mastra/core/evals");
11
11
  let _mastra_core_storage_domains_skills = require("@mastra/core/storage/domains/skills");
12
12
  //#region package.json
13
- var version = "1.18.0";
13
+ var version = "1.18.1-alpha.0";
14
14
  //#endregion
15
15
  //#region src/vector/filter.ts
16
16
  /**
@@ -11066,11 +11066,15 @@ var WorkflowsStorageMongoDB = class WorkflowsStorageMongoDB extends _mastra_core
11066
11066
  }
11067
11067
  async updateWorkflowState({ workflowName, runId, opts }) {
11068
11068
  try {
11069
- const updatedDoc = await (await this.getCollection(_mastra_core_storage.TABLE_WORKFLOW_SNAPSHOT)).findOneAndUpdate({
11069
+ const collection = await this.getCollection(_mastra_core_storage.TABLE_WORKFLOW_SNAPSHOT);
11070
+ const { expectedStatus, ...state } = opts;
11071
+ const filter = {
11070
11072
  workflow_name: workflowName,
11071
11073
  run_id: runId
11072
- }, [{ $set: {
11073
- snapshot: { $mergeObjects: ["$snapshot", opts] },
11074
+ };
11075
+ if (expectedStatus !== void 0) filter["snapshot.status"] = { $in: Array.isArray(expectedStatus) ? expectedStatus : [expectedStatus] };
11076
+ const updatedDoc = await collection.findOneAndUpdate(filter, [{ $set: {
11077
+ snapshot: { $mergeObjects: ["$snapshot", state] },
11074
11078
  updatedAt: /* @__PURE__ */ new Date()
11075
11079
  } }], { returnDocument: "after" });
11076
11080
  if (!updatedDoc) return;