@mastra/lance 1.3.0 → 1.3.1

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
@@ -530,21 +530,23 @@ var StoreBackgroundTasksLance = class extends BackgroundTasksStorage {
530
530
  async createTask(task) {
531
531
  await (await this.client.openTable(TABLE_BACKGROUND_TASKS)).add([toRecord(task)], { mode: "append" });
532
532
  }
533
- async updateTask(taskId, update) {
534
- const existing = await this.getTask(taskId);
535
- if (!existing) return;
536
- const merged = { ...existing };
537
- if ("status" in update) merged.status = update.status;
538
- if ("result" in update) merged.result = update.result;
539
- if ("error" in update) merged.error = update.error;
540
- if ("suspendPayload" in update) merged.suspendPayload = update.suspendPayload;
541
- if ("retryCount" in update) merged.retryCount = update.retryCount;
542
- if ("startedAt" in update) merged.startedAt = update.startedAt;
543
- if ("suspendedAt" in update) merged.suspendedAt = update.suspendedAt;
544
- if ("completedAt" in update) merged.completedAt = update.completedAt;
545
- const table = await this.client.openTable(TABLE_BACKGROUND_TASKS);
546
- await table.delete(`id = '${escapeStr(taskId)}'`);
547
- await table.add([toRecord(merged)], { mode: "append" });
533
+ async updateTask(taskId, update, options) {
534
+ const values = {};
535
+ if ("status" in update) values.status = update.status;
536
+ if ("result" in update) values.result = serializeJson(update.result) ?? null;
537
+ if ("error" in update) values.error = serializeJson(update.error) ?? null;
538
+ if ("suspendPayload" in update) values.suspend_payload = serializeJson(update.suspendPayload) ?? null;
539
+ if ("retryCount" in update) values.retry_count = update.retryCount;
540
+ if ("startedAt" in update) values.startedAt = update.startedAt?.getTime() ?? 0;
541
+ if ("suspendedAt" in update) values.suspendedAt = update.suspendedAt?.getTime() ?? 0;
542
+ if ("completedAt" in update) values.completedAt = update.completedAt?.getTime() ?? 0;
543
+ if (Object.keys(values).length === 0) return false;
544
+ const conditions = [`id = '${escapeStr(taskId)}'`];
545
+ if (options?.expectedStatus) conditions.push(`status = '${escapeStr(options.expectedStatus)}'`);
546
+ return (await (await this.client.openTable(TABLE_BACKGROUND_TASKS)).update({
547
+ where: conditions.join(" AND "),
548
+ values
549
+ })).rowsUpdated > 0;
548
550
  }
549
551
  async getTask(taskId) {
550
552
  try {