@mastra/convex 1.5.7 → 1.6.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.
@@ -3,7 +3,7 @@ name: mastra-convex
3
3
  description: Documentation for @mastra/convex. Use when working with @mastra/convex APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/convex"
6
- version: "1.5.7"
6
+ version: "1.6.0-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.7",
2
+ "version": "1.6.0-alpha.0",
3
3
  "package": "@mastra/convex",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_server = require("./server-D6F5bOWl.cjs");
2
+ const require_server = require("./server-D5fx5hYY.cjs");
3
3
  const require_schema = require("./schema.cjs");
4
4
  let _mastra_core_cache = require("@mastra/core/cache");
5
5
  let _mastra_core_storage = require("@mastra/core/storage");
@@ -569,7 +569,9 @@ function toStored(task) {
569
569
  createdAt: task.createdAt.toISOString(),
570
570
  startedAt: task.startedAt?.toISOString() ?? null,
571
571
  suspendedAt: task.suspendedAt?.toISOString() ?? null,
572
- completedAt: task.completedAt?.toISOString() ?? null
572
+ completedAt: task.completedAt?.toISOString() ?? null,
573
+ ownerId: task.ownerId ?? null,
574
+ leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null
573
575
  };
574
576
  }
575
577
  function toStoredPatch(update) {
@@ -584,6 +586,8 @@ function toStoredPatch(update) {
584
586
  if ("startedAt" in update) patch.startedAt = update.startedAt?.toISOString() ?? null;
585
587
  if ("suspendedAt" in update) patch.suspendedAt = update.suspendedAt?.toISOString() ?? null;
586
588
  if ("completedAt" in update) patch.completedAt = update.completedAt?.toISOString() ?? null;
589
+ if ("ownerId" in update) patch.ownerId = update.ownerId ?? null;
590
+ if ("leaseExpiresAt" in update) patch.leaseExpiresAt = update.leaseExpiresAt?.toISOString() ?? null;
587
591
  return patch;
588
592
  }
589
593
  function legacyOrCurrent(stored, currentKey, legacyKey) {
@@ -618,7 +622,9 @@ function fromStored(stored) {
618
622
  createdAt: new Date(record.createdAt),
619
623
  startedAt: record.startedAt ? new Date(record.startedAt) : void 0,
620
624
  suspendedAt: record.suspendedAt ? new Date(record.suspendedAt) : void 0,
621
- completedAt: record.completedAt ? new Date(record.completedAt) : void 0
625
+ completedAt: record.completedAt ? new Date(record.completedAt) : void 0,
626
+ ownerId: record.ownerId ?? void 0,
627
+ leaseExpiresAt: record.leaseExpiresAt ? new Date(record.leaseExpiresAt) : void 0
622
628
  };
623
629
  }
624
630
  function hasDeleteFilter(filter) {
@@ -643,11 +649,15 @@ var BackgroundTasksConvex = class extends _mastra_core_storage.BackgroundTasksSt
643
649
  async updateTask(taskId, update, options) {
644
650
  const patch = toStoredPatch(update);
645
651
  if (Object.keys(patch).length === 0) return false;
652
+ const expected = {};
653
+ if (options?.expectedStatus) expected.status = options.expectedStatus;
654
+ if (options?.expectedOwnerId !== void 0) expected.ownerId = options.expectedOwnerId;
655
+ if (options?.expectedLeaseExpiresAt !== void 0) expected.leaseExpiresAt = options.expectedLeaseExpiresAt?.toISOString() ?? null;
646
656
  return this.#db.patch({
647
657
  tableName: _mastra_core_storage.TABLE_BACKGROUND_TASKS,
648
658
  id: taskId,
649
659
  record: patch,
650
- expected: options?.expectedStatus ? { status: options.expectedStatus } : void 0
660
+ expected: Object.keys(expected).length > 0 ? expected : void 0
651
661
  });
652
662
  }
653
663
  async getTask(taskId) {