@mastra/mssql 1.7.1 → 1.7.2

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
@@ -1,5 +1,5 @@
1
1
  import { ErrorCategory, ErrorDomain, MastraError } from "@mastra/core/error";
2
- import { AGENTS_SCHEMA, AGENT_VERSIONS_SCHEMA, AgentsStorage, BackgroundTasksStorage, MastraCompositeStore, MemoryStorage, ObservabilityStorage, SPAN_SCHEMA, ScoresStorage, TABLE_AGENTS, TABLE_AGENT_VERSIONS, TABLE_BACKGROUND_TASKS, TABLE_MESSAGES, TABLE_RESOURCES, TABLE_SCHEMAS, TABLE_SCORERS, TABLE_SPANS, TABLE_THREADS, TABLE_WORKFLOW_DEFINITIONS, TABLE_WORKFLOW_SNAPSHOT, TraceStatus, WORKFLOW_DEFINITIONS_SCHEMA, WorkflowDefinitionsStorage, WorkflowsStorage, calculatePagination, createStorageErrorId, getDefaultValue, listTracesArgsSchema, normalizePerPage, toTraceSpans, transformScoreRow, validateStorageMetadataFilter } from "@mastra/core/storage";
2
+ import { AGENTS_SCHEMA, AGENT_VERSIONS_SCHEMA, AgentsStorage, BackgroundTasksStorage, MastraCompositeStore, MemoryStorage, ObservabilityStorage, SPAN_SCHEMA, ScoresStorage, TABLE_AGENTS, TABLE_AGENT_VERSIONS, TABLE_BACKGROUND_TASKS, TABLE_MESSAGES, TABLE_RESOURCES, TABLE_SCHEMAS, TABLE_SCORERS, TABLE_SPANS, TABLE_THREADS, TABLE_WORKFLOW_DEFINITIONS, TABLE_WORKFLOW_SNAPSHOT, TraceStatus, WORKFLOW_DEFINITIONS_SCHEMA, WorkflowDefinitionsStorage, WorkflowsStorage, calculatePagination, createStorageErrorId, getDefaultValue, listTracesArgsSchema, matchesExpectedWorkflowStatus, normalizePerPage, toTraceSpans, transformScoreRow, validateStorageMetadataFilter } from "@mastra/core/storage";
3
3
  import sql from "mssql";
4
4
  import { randomUUID } from "crypto";
5
5
  import { parseSqlIdentifier } from "@mastra/core/utils";
@@ -4464,9 +4464,14 @@ var WorkflowsMSSQL = class WorkflowsMSSQL extends WorkflowsStorage {
4464
4464
  }
4465
4465
  }, /* @__PURE__ */ new Error(`Snapshot not found for runId ${runId}`));
4466
4466
  }
4467
+ const { expectedStatus, ...state } = opts;
4468
+ if (!matchesExpectedWorkflowStatus(snapshot.status, expectedStatus)) {
4469
+ await transaction.rollback();
4470
+ return;
4471
+ }
4467
4472
  const updatedSnapshot = {
4468
4473
  ...snapshot,
4469
- ...opts
4474
+ ...state
4470
4475
  };
4471
4476
  const updateRequest = new sql.Request(transaction);
4472
4477
  updateRequest.input("snapshot", JSON.stringify(updatedSnapshot));