@mastra/convex 1.7.6-alpha.0 → 1.8.0-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
@@ -764,7 +764,9 @@ function toStored(task) {
764
764
  suspendedAt: task.suspendedAt?.toISOString() ?? null,
765
765
  completedAt: task.completedAt?.toISOString() ?? null,
766
766
  ownerId: task.ownerId ?? null,
767
- leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null
767
+ leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null,
768
+ expiresAt: task.expiresAt?.toISOString() ?? null,
769
+ metadata: serializeJson$1(task.metadata)
768
770
  };
769
771
  }
770
772
  function toStoredPatch(update) {
@@ -781,6 +783,8 @@ function toStoredPatch(update) {
781
783
  if ("completedAt" in update) patch.completedAt = update.completedAt?.toISOString() ?? null;
782
784
  if ("ownerId" in update) patch.ownerId = update.ownerId ?? null;
783
785
  if ("leaseExpiresAt" in update) patch.leaseExpiresAt = update.leaseExpiresAt?.toISOString() ?? null;
786
+ if ("expiresAt" in update) patch.expiresAt = update.expiresAt?.toISOString() ?? null;
787
+ if ("metadata" in update) patch.metadata = serializeJson$1(update.metadata);
784
788
  return patch;
785
789
  }
786
790
  function legacyOrCurrent(stored, currentKey, legacyKey) {
@@ -817,13 +821,16 @@ function fromStored(stored) {
817
821
  suspendedAt: record.suspendedAt ? new Date(record.suspendedAt) : void 0,
818
822
  completedAt: record.completedAt ? new Date(record.completedAt) : void 0,
819
823
  ownerId: record.ownerId ?? void 0,
820
- leaseExpiresAt: record.leaseExpiresAt ? new Date(record.leaseExpiresAt) : void 0
824
+ leaseExpiresAt: record.leaseExpiresAt ? new Date(record.leaseExpiresAt) : void 0,
825
+ expiresAt: record.expiresAt ? new Date(record.expiresAt) : void 0,
826
+ metadata: parseJson(record.metadata)
821
827
  };
822
828
  }
823
829
  function hasDeleteFilter(filter) {
824
- return Boolean((Array.isArray(filter.status) ? filter.status.length > 0 : filter.status) || filter.agentId || filter.threadId || filter.resourceId || filter.toolName || filter.toolCallId || filter.runId || filter.fromDate || filter.toDate);
830
+ return Boolean((Array.isArray(filter.status) ? filter.status.length > 0 : filter.status) || filter.agentId || filter.threadId || filter.resourceId || filter.toolName || filter.toolCallId || filter.runId || filter.hasExpiresAt !== void 0 || filter.fromDate || filter.toDate);
825
831
  }
826
832
  var BackgroundTasksConvex = class extends BackgroundTasksStorage {
833
+ supportsTaskExpiry = true;
827
834
  #db;
828
835
  constructor(config) {
829
836
  super();
@@ -846,6 +853,7 @@ var BackgroundTasksConvex = class extends BackgroundTasksStorage {
846
853
  if (options?.expectedStatus) expected.status = options.expectedStatus;
847
854
  if (options?.expectedOwnerId !== void 0) expected.ownerId = options.expectedOwnerId;
848
855
  if (options?.expectedLeaseExpiresAt !== void 0) expected.leaseExpiresAt = options.expectedLeaseExpiresAt?.toISOString() ?? null;
856
+ if (options?.expectedSuspendedAt !== void 0) expected.suspendedAt = options.expectedSuspendedAt?.toISOString() ?? null;
849
857
  return this.#db.patch({
850
858
  tableName: TABLE_BACKGROUND_TASKS$1,
851
859
  id: taskId,
@@ -905,6 +913,7 @@ var BackgroundTasksConvex = class extends BackgroundTasksStorage {
905
913
  if (filter.toolName) tasks = tasks.filter((t) => t.toolName === filter.toolName);
906
914
  if (filter.toolCallId) tasks = tasks.filter((t) => t.toolCallId === filter.toolCallId);
907
915
  if (filter.runId) tasks = tasks.filter((t) => t.runId === filter.runId);
916
+ if (filter.hasExpiresAt !== void 0) tasks = tasks.filter((t) => t.expiresAt != null === filter.hasExpiresAt);
908
917
  const dateCol = filter.dateFilterBy ?? "createdAt";
909
918
  if (filter.fromDate) tasks = tasks.filter((t) => {
910
919
  const val = t[dateCol];