@mastra/libsql 1.27.1 → 1.28.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
@@ -3425,10 +3425,13 @@ function rowToTask(row) {
3425
3425
  suspendedAt: row.suspendedAt ? new Date(String(row.suspendedAt)) : void 0,
3426
3426
  completedAt: row.completedAt ? new Date(String(row.completedAt)) : void 0,
3427
3427
  ownerId: row.ownerId != null ? String(row.ownerId) : void 0,
3428
- leaseExpiresAt: row.leaseExpiresAt ? new Date(String(row.leaseExpiresAt)) : void 0
3428
+ leaseExpiresAt: row.leaseExpiresAt ? new Date(String(row.leaseExpiresAt)) : void 0,
3429
+ expiresAt: row.expiresAt ? new Date(String(row.expiresAt)) : void 0,
3430
+ metadata: parseJson$4(row.metadata)
3429
3431
  };
3430
3432
  }
3431
3433
  var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends BackgroundTasksStorage {
3434
+ supportsTaskExpiry = true;
3432
3435
  /**
3433
3436
  * Completed/failed task records accumulate. Anchored on `completedAt`, which
3434
3437
  * is NULL while a task is in-flight (pending/running/suspended) — so `completedAt
@@ -3463,7 +3466,9 @@ var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends BackgroundTasksS
3463
3466
  "suspend_payload",
3464
3467
  "suspendedAt",
3465
3468
  "ownerId",
3466
- "leaseExpiresAt"
3469
+ "leaseExpiresAt",
3470
+ "expiresAt",
3471
+ "metadata"
3467
3472
  ]
3468
3473
  });
3469
3474
  }
@@ -3509,7 +3514,9 @@ var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends BackgroundTasksS
3509
3514
  suspendedAt: task.suspendedAt?.toISOString() ?? null,
3510
3515
  completedAt: task.completedAt?.toISOString() ?? null,
3511
3516
  ownerId: task.ownerId ?? null,
3512
- leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null
3517
+ leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null,
3518
+ expiresAt: task.expiresAt?.toISOString() ?? null,
3519
+ metadata: task.metadata ?? null
3513
3520
  }
3514
3521
  });
3515
3522
  }
@@ -3556,6 +3563,14 @@ var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends BackgroundTasksS
3556
3563
  setClauses.push("leaseExpiresAt = ?");
3557
3564
  params.push(update.leaseExpiresAt?.toISOString() ?? null);
3558
3565
  }
3566
+ if ("expiresAt" in update) {
3567
+ setClauses.push("expiresAt = ?");
3568
+ params.push(update.expiresAt?.toISOString() ?? null);
3569
+ }
3570
+ if ("metadata" in update) {
3571
+ setClauses.push("metadata = jsonb(?)");
3572
+ params.push(serializeJson(update.metadata));
3573
+ }
3559
3574
  if (setClauses.length === 0) return false;
3560
3575
  params.push(taskId);
3561
3576
  let where = "id = ?";
@@ -3577,6 +3592,13 @@ var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends BackgroundTasksS
3577
3592
  params.push(options.expectedLeaseExpiresAt.toISOString());
3578
3593
  }
3579
3594
  }
3595
+ if (options?.expectedSuspendedAt !== void 0) {
3596
+ if (options.expectedSuspendedAt === null) where += " AND suspendedAt IS NULL";
3597
+ else {
3598
+ where += " AND suspendedAt = ?";
3599
+ params.push(options.expectedSuspendedAt.toISOString());
3600
+ }
3601
+ }
3580
3602
  return (await this.#client.execute({
3581
3603
  sql: `UPDATE ${TABLE_BACKGROUND_TASKS} SET ${setClauses.join(", ")} WHERE ${where}`,
3582
3604
  args: params
@@ -3621,7 +3643,8 @@ var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends BackgroundTasksS
3621
3643
  conditions.push("tool_call_id = ?");
3622
3644
  params.push(filter.toolCallId);
3623
3645
  }
3624
- const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "suspendedAt" ? "suspendedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
3646
+ const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "suspendedAt" ? "suspendedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : filter.dateFilterBy === "expiresAt" ? "expiresAt" : "createdAt";
3647
+ if (filter.hasExpiresAt !== void 0) conditions.push(filter.hasExpiresAt ? "expiresAt IS NOT NULL" : "expiresAt IS NULL");
3625
3648
  if (filter.fromDate) {
3626
3649
  conditions.push(`${dateCol} >= ?`);
3627
3650
  params.push(filter.fromDate.toISOString());
@@ -3669,7 +3692,8 @@ var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends BackgroundTasksS
3669
3692
  conditions.push(`status IN (${statuses.map(() => "?").join(", ")})`);
3670
3693
  params.push(...statuses);
3671
3694
  }
3672
- const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "suspendedAt" ? "suspendedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
3695
+ const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "suspendedAt" ? "suspendedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : filter.dateFilterBy === "expiresAt" ? "expiresAt" : "createdAt";
3696
+ if (filter.hasExpiresAt !== void 0) conditions.push(filter.hasExpiresAt ? "expiresAt IS NOT NULL" : "expiresAt IS NULL");
3673
3697
  if (filter.fromDate) {
3674
3698
  conditions.push(`${dateCol} >= ?`);
3675
3699
  params.push(filter.fromDate.toISOString());