@mastra/upstash 1.5.1 → 1.5.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
@@ -1641,7 +1641,7 @@ var WorkflowsUpstash = class extends WorkflowsStorage {
1641
1641
  return this.client.get(key);
1642
1642
  }))).find((w) => w?.run_id === runId && (!workflowName || w.workflow_name === workflowName) && (!resourceId || w.resourceId === resourceId)) ?? null;
1643
1643
  }
1644
- async updateWorkflowResults({ workflowName, runId, stepId, result, requestContext }) {
1644
+ async updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, state }) {
1645
1645
  try {
1646
1646
  const key = getKey(TABLE_WORKFLOW_SNAPSHOT, {
1647
1647
  namespace: "workflows",
@@ -1659,6 +1659,7 @@ var WorkflowsUpstash = class extends WorkflowsStorage {
1659
1659
  local workflowName = ARGV[6]
1660
1660
  local runId = ARGV[7]
1661
1661
  local timestamp = tonumber(ARGV[8])
1662
+ local stateJson = ARGV[9]
1662
1663
 
1663
1664
  -- Get existing data
1664
1665
  local existing = redis.call('GET', key)
@@ -1705,6 +1706,11 @@ var WorkflowsUpstash = class extends WorkflowsStorage {
1705
1706
  local stepResult = cjson.decode(resultJson)
1706
1707
  snapshot.context[stepId] = stepResult
1707
1708
 
1709
+ -- Record workflow state in the same write when provided
1710
+ if stateJson ~= '' then
1711
+ snapshot.context['__state'] = cjson.decode(stateJson)
1712
+ end
1713
+
1708
1714
  -- Merge request context
1709
1715
  local newRequestContext = cjson.decode(requestContextJson)
1710
1716
  if snapshot.requestContext == nil then
@@ -1731,7 +1737,8 @@ var WorkflowsUpstash = class extends WorkflowsStorage {
1731
1737
  "workflows",
1732
1738
  workflowName,
1733
1739
  runId,
1734
- String(Date.now())
1740
+ String(Date.now()),
1741
+ state === void 0 ? "" : JSON.stringify(state)
1735
1742
  ]);
1736
1743
  let data;
1737
1744
  if (typeof resultJson === "string") data = JSON.parse(resultJson);