@mastra/mongodb 1.8.0 → 1.8.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
@@ -12,7 +12,7 @@ import { saveScorePayloadSchema } from '@mastra/core/evals';
12
12
 
13
13
  // package.json
14
14
  var package_default = {
15
- version: "1.8.0"};
15
+ version: "1.8.1-alpha.0"};
16
16
  var MongoDBFilterTranslator = class extends BaseFilterTranslator {
17
17
  getSupportedOperators() {
18
18
  return {
@@ -1516,11 +1516,13 @@ function toDoc(task) {
1516
1516
  args: task.args,
1517
1517
  result: task.result ?? null,
1518
1518
  error: task.error ?? null,
1519
+ suspend_payload: task.suspendPayload ?? null,
1519
1520
  retry_count: task.retryCount,
1520
1521
  max_retries: task.maxRetries,
1521
1522
  timeout_ms: task.timeoutMs,
1522
1523
  createdAt: task.createdAt.toISOString(),
1523
1524
  startedAt: task.startedAt?.toISOString() ?? null,
1525
+ suspendedAt: task.suspendedAt?.toISOString() ?? null,
1524
1526
  completedAt: task.completedAt?.toISOString() ?? null
1525
1527
  };
1526
1528
  }
@@ -1537,11 +1539,13 @@ function fromDoc(doc) {
1537
1539
  runId: doc.run_id ?? "",
1538
1540
  result: doc.result ?? void 0,
1539
1541
  error: doc.error ?? void 0,
1542
+ suspendPayload: doc.suspend_payload ?? void 0,
1540
1543
  retryCount: Number(doc.retry_count ?? 0),
1541
1544
  maxRetries: Number(doc.max_retries ?? 0),
1542
1545
  timeoutMs: Number(doc.timeout_ms ?? 3e5),
1543
1546
  createdAt: new Date(doc.createdAt),
1544
1547
  startedAt: doc.startedAt ? new Date(doc.startedAt) : void 0,
1548
+ suspendedAt: doc.suspendedAt ? new Date(doc.suspendedAt) : void 0,
1545
1549
  completedAt: doc.completedAt ? new Date(doc.completedAt) : void 0
1546
1550
  };
1547
1551
  }
@@ -1609,8 +1613,10 @@ var BackgroundTasksStorageMongoDB = class _BackgroundTasksStorageMongoDB extends
1609
1613
  if ("status" in update) $set.status = update.status;
1610
1614
  if ("result" in update) $set.result = update.result ?? null;
1611
1615
  if ("error" in update) $set.error = update.error ?? null;
1616
+ if ("suspendPayload" in update) $set.suspend_payload = update.suspendPayload ?? null;
1612
1617
  if ("retryCount" in update) $set.retry_count = update.retryCount;
1613
1618
  if ("startedAt" in update) $set.startedAt = update.startedAt?.toISOString() ?? null;
1619
+ if ("suspendedAt" in update) $set.suspendedAt = update.suspendedAt?.toISOString() ?? null;
1614
1620
  if ("completedAt" in update) $set.completedAt = update.completedAt?.toISOString() ?? null;
1615
1621
  if (Object.keys($set).length === 0) return;
1616
1622
  const collection = await this.getCollection();
@@ -1632,14 +1638,15 @@ var BackgroundTasksStorageMongoDB = class _BackgroundTasksStorageMongoDB extends
1632
1638
  if (filter.resourceId) query.resource_id = filter.resourceId;
1633
1639
  if (filter.runId) query.run_id = filter.runId;
1634
1640
  if (filter.toolName) query.tool_name = filter.toolName;
1635
- const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
1641
+ if (filter.toolCallId) query.tool_call_id = filter.toolCallId;
1642
+ const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "suspendedAt" ? "suspendedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
1636
1643
  if (filter.fromDate) {
1637
1644
  query[dateCol] = { ...query[dateCol] || {}, $gte: filter.fromDate.toISOString() };
1638
1645
  }
1639
1646
  if (filter.toDate) {
1640
1647
  query[dateCol] = { ...query[dateCol] || {}, $lt: filter.toDate.toISOString() };
1641
1648
  }
1642
- const orderCol = filter.orderBy === "startedAt" ? "startedAt" : filter.orderBy === "completedAt" ? "completedAt" : "createdAt";
1649
+ const orderCol = filter.orderBy === "startedAt" ? "startedAt" : filter.orderBy === "suspendedAt" ? "suspendedAt" : filter.orderBy === "completedAt" ? "completedAt" : "createdAt";
1643
1650
  const direction = filter.orderDirection === "desc" ? -1 : 1;
1644
1651
  const collection = await this.getCollection();
1645
1652
  const total = await collection.countDocuments(query);
@@ -1663,7 +1670,7 @@ var BackgroundTasksStorageMongoDB = class _BackgroundTasksStorageMongoDB extends
1663
1670
  const statuses = Array.isArray(filter.status) ? filter.status : [filter.status];
1664
1671
  query.status = statuses.length === 1 ? statuses[0] : { $in: statuses };
1665
1672
  }
1666
- const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
1673
+ const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "suspendedAt" ? "suspendedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
1667
1674
  if (filter.fromDate) {
1668
1675
  query[dateCol] = { ...query[dateCol] || {}, $gte: filter.fromDate.toISOString() };
1669
1676
  }
@@ -1675,6 +1682,7 @@ var BackgroundTasksStorageMongoDB = class _BackgroundTasksStorageMongoDB extends
1675
1682
  if (filter.resourceId) query.resource_id = filter.resourceId;
1676
1683
  if (filter.runId) query.run_id = filter.runId;
1677
1684
  if (filter.toolName) query.tool_name = filter.toolName;
1685
+ if (filter.toolCallId) query.tool_call_id = filter.toolCallId;
1678
1686
  if (Object.keys(query).length === 0) return;
1679
1687
  const collection = await this.getCollection();
1680
1688
  await collection.deleteMany(query);