@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/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import { MessageList } from "@mastra/core/agent";
9
9
  import { saveScorePayloadSchema } from "@mastra/core/evals";
10
10
  import { skillSnapshotFieldValuesEqual } from "@mastra/core/storage/domains/skills";
11
11
  //#region package.json
12
- var version = "1.18.0";
12
+ var version = "1.18.1-alpha.0";
13
13
  //#endregion
14
14
  //#region src/vector/filter.ts
15
15
  /**
@@ -11065,11 +11065,15 @@ var WorkflowsStorageMongoDB = class WorkflowsStorageMongoDB extends WorkflowsSto
11065
11065
  }
11066
11066
  async updateWorkflowState({ workflowName, runId, opts }) {
11067
11067
  try {
11068
- const updatedDoc = await (await this.getCollection(TABLE_WORKFLOW_SNAPSHOT)).findOneAndUpdate({
11068
+ const collection = await this.getCollection(TABLE_WORKFLOW_SNAPSHOT);
11069
+ const { expectedStatus, ...state } = opts;
11070
+ const filter = {
11069
11071
  workflow_name: workflowName,
11070
11072
  run_id: runId
11071
- }, [{ $set: {
11072
- snapshot: { $mergeObjects: ["$snapshot", opts] },
11073
+ };
11074
+ if (expectedStatus !== void 0) filter["snapshot.status"] = { $in: Array.isArray(expectedStatus) ? expectedStatus : [expectedStatus] };
11075
+ const updatedDoc = await collection.findOneAndUpdate(filter, [{ $set: {
11076
+ snapshot: { $mergeObjects: ["$snapshot", state] },
11073
11077
  updatedAt: /* @__PURE__ */ new Date()
11074
11078
  } }], { returnDocument: "after" });
11075
11079
  if (!updatedDoc) return;