@mastra/convex 1.5.7-alpha.0 → 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.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as mastraCache, i as mastraStorage, n as mastraNativeVectorMutation, r as mastraNativeVectorQuery, t as mastraNativeVectorAction } from "./server-D8oEAyrJ.js";
1
+ import { a as mastraCache, i as mastraStorage, n as mastraNativeVectorMutation, r as mastraNativeVectorQuery, t as mastraNativeVectorAction } from "./server-DEhttoZL.js";
2
2
  import { TABLE_BACKGROUND_TASKS, TABLE_CHANNEL_CONFIG, TABLE_CHANNEL_INSTALLATIONS, TABLE_MESSAGES, TABLE_OBSERVATIONAL_MEMORY, TABLE_RESOURCES, TABLE_SCHEDULES, TABLE_SCHEDULE_TRIGGERS, TABLE_SCORERS, TABLE_THREADS, TABLE_WORKFLOW_SNAPSHOT, defineMastraNativeVectorTable, mastraBackgroundTasksTable, mastraCacheListItemsTable, mastraCacheTable, mastraChannelConfigTable, mastraChannelInstallationsTable, mastraDocumentsTable, mastraMessagesTable, mastraObservationalMemoryTable, mastraResourcesTable, mastraScheduleTriggersTable, mastraSchedulesTable, mastraScoresTable, mastraThreadsTable, mastraVectorIndexesTable, mastraVectorsTable, mastraWorkflowSnapshotsTable } from "./schema.js";
3
3
  import { MastraServerCache } from "@mastra/core/cache";
4
4
  import { BackgroundTasksStorage, ChannelsStorage, MastraCompositeStore, MemoryStorage, SchedulesStorage, ScoresStorage, TABLE_BACKGROUND_TASKS as TABLE_BACKGROUND_TASKS$1, TABLE_CHANNEL_CONFIG as TABLE_CHANNEL_CONFIG$1, TABLE_CHANNEL_INSTALLATIONS as TABLE_CHANNEL_INSTALLATIONS$1, TABLE_MESSAGES as TABLE_MESSAGES$1, TABLE_RESOURCES as TABLE_RESOURCES$1, TABLE_SCHEDULES as TABLE_SCHEDULES$1, TABLE_SCHEDULE_TRIGGERS as TABLE_SCHEDULE_TRIGGERS$1, TABLE_SCORERS as TABLE_SCORERS$1, TABLE_THREADS as TABLE_THREADS$1, TABLE_WORKFLOW_SNAPSHOT as TABLE_WORKFLOW_SNAPSHOT$1, WorkflowsStorage, calculatePagination, createStorageErrorId, createVectorErrorId, filterByDateRange, normalizePerPage, normalizeScheduleTarget, safelyParseJSON, storageMessageMatchesMetadataFilter, validateStorageMetadataFilter } from "@mastra/core/storage";
@@ -567,7 +567,9 @@ function toStored(task) {
567
567
  createdAt: task.createdAt.toISOString(),
568
568
  startedAt: task.startedAt?.toISOString() ?? null,
569
569
  suspendedAt: task.suspendedAt?.toISOString() ?? null,
570
- completedAt: task.completedAt?.toISOString() ?? null
570
+ completedAt: task.completedAt?.toISOString() ?? null,
571
+ ownerId: task.ownerId ?? null,
572
+ leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null
571
573
  };
572
574
  }
573
575
  function toStoredPatch(update) {
@@ -582,6 +584,8 @@ function toStoredPatch(update) {
582
584
  if ("startedAt" in update) patch.startedAt = update.startedAt?.toISOString() ?? null;
583
585
  if ("suspendedAt" in update) patch.suspendedAt = update.suspendedAt?.toISOString() ?? null;
584
586
  if ("completedAt" in update) patch.completedAt = update.completedAt?.toISOString() ?? null;
587
+ if ("ownerId" in update) patch.ownerId = update.ownerId ?? null;
588
+ if ("leaseExpiresAt" in update) patch.leaseExpiresAt = update.leaseExpiresAt?.toISOString() ?? null;
585
589
  return patch;
586
590
  }
587
591
  function legacyOrCurrent(stored, currentKey, legacyKey) {
@@ -616,7 +620,9 @@ function fromStored(stored) {
616
620
  createdAt: new Date(record.createdAt),
617
621
  startedAt: record.startedAt ? new Date(record.startedAt) : void 0,
618
622
  suspendedAt: record.suspendedAt ? new Date(record.suspendedAt) : void 0,
619
- completedAt: record.completedAt ? new Date(record.completedAt) : void 0
623
+ completedAt: record.completedAt ? new Date(record.completedAt) : void 0,
624
+ ownerId: record.ownerId ?? void 0,
625
+ leaseExpiresAt: record.leaseExpiresAt ? new Date(record.leaseExpiresAt) : void 0
620
626
  };
621
627
  }
622
628
  function hasDeleteFilter(filter) {
@@ -641,11 +647,15 @@ var BackgroundTasksConvex = class extends BackgroundTasksStorage {
641
647
  async updateTask(taskId, update, options) {
642
648
  const patch = toStoredPatch(update);
643
649
  if (Object.keys(patch).length === 0) return false;
650
+ const expected = {};
651
+ if (options?.expectedStatus) expected.status = options.expectedStatus;
652
+ if (options?.expectedOwnerId !== void 0) expected.ownerId = options.expectedOwnerId;
653
+ if (options?.expectedLeaseExpiresAt !== void 0) expected.leaseExpiresAt = options.expectedLeaseExpiresAt?.toISOString() ?? null;
644
654
  return this.#db.patch({
645
655
  tableName: TABLE_BACKGROUND_TASKS$1,
646
656
  id: taskId,
647
657
  record: patch,
648
- expected: options?.expectedStatus ? { status: options.expectedStatus } : void 0
658
+ expected: Object.keys(expected).length > 0 ? expected : void 0
649
659
  });
650
660
  }
651
661
  async getTask(taskId) {