@mastra/libsql 1.23.4-alpha.0 → 1.24.0-alpha.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.
@@ -3,7 +3,7 @@ name: mastra-libsql
3
3
  description: Documentation for @mastra/libsql. Use when working with @mastra/libsql APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/libsql"
6
- version: "1.23.4-alpha.0"
6
+ version: "1.24.0-alpha.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.23.4-alpha.0",
2
+ "version": "1.24.0-alpha.1",
3
3
  "package": "@mastra/libsql",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -2954,7 +2954,9 @@ function rowToTask(row) {
2954
2954
  createdAt: new Date(String(row.createdAt)),
2955
2955
  startedAt: row.startedAt ? new Date(String(row.startedAt)) : void 0,
2956
2956
  suspendedAt: row.suspendedAt ? new Date(String(row.suspendedAt)) : void 0,
2957
- completedAt: row.completedAt ? new Date(String(row.completedAt)) : void 0
2957
+ completedAt: row.completedAt ? new Date(String(row.completedAt)) : void 0,
2958
+ ownerId: row.ownerId != null ? String(row.ownerId) : void 0,
2959
+ leaseExpiresAt: row.leaseExpiresAt ? new Date(String(row.leaseExpiresAt)) : void 0
2958
2960
  };
2959
2961
  }
2960
2962
  var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends _mastra_core_storage.BackgroundTasksStorage {
@@ -2988,7 +2990,12 @@ var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends _mastra_core_sto
2988
2990
  await this.#db.alterTable({
2989
2991
  tableName: _mastra_core_storage.TABLE_BACKGROUND_TASKS,
2990
2992
  schema: _mastra_core_storage.TABLE_SCHEMAS[_mastra_core_storage.TABLE_BACKGROUND_TASKS],
2991
- ifNotExists: ["suspend_payload", "suspendedAt"]
2993
+ ifNotExists: [
2994
+ "suspend_payload",
2995
+ "suspendedAt",
2996
+ "ownerId",
2997
+ "leaseExpiresAt"
2998
+ ]
2992
2999
  });
2993
3000
  }
2994
3001
  async dangerouslyClearAll() {
@@ -3031,7 +3038,9 @@ var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends _mastra_core_sto
3031
3038
  createdAt: task.createdAt.toISOString(),
3032
3039
  startedAt: task.startedAt?.toISOString() ?? null,
3033
3040
  suspendedAt: task.suspendedAt?.toISOString() ?? null,
3034
- completedAt: task.completedAt?.toISOString() ?? null
3041
+ completedAt: task.completedAt?.toISOString() ?? null,
3042
+ ownerId: task.ownerId ?? null,
3043
+ leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null
3035
3044
  }
3036
3045
  });
3037
3046
  }
@@ -3070,6 +3079,14 @@ var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends _mastra_core_sto
3070
3079
  setClauses.push("completedAt = ?");
3071
3080
  params.push(update.completedAt?.toISOString() ?? null);
3072
3081
  }
3082
+ if ("ownerId" in update) {
3083
+ setClauses.push("ownerId = ?");
3084
+ params.push(update.ownerId ?? null);
3085
+ }
3086
+ if ("leaseExpiresAt" in update) {
3087
+ setClauses.push("leaseExpiresAt = ?");
3088
+ params.push(update.leaseExpiresAt?.toISOString() ?? null);
3089
+ }
3073
3090
  if (setClauses.length === 0) return false;
3074
3091
  params.push(taskId);
3075
3092
  let where = "id = ?";
@@ -3077,6 +3094,16 @@ var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends _mastra_core_sto
3077
3094
  where += " AND status = ?";
3078
3095
  params.push(options.expectedStatus);
3079
3096
  }
3097
+ if (options?.expectedOwnerId !== void 0) if (options.expectedOwnerId === null) where += " AND ownerId IS NULL";
3098
+ else {
3099
+ where += " AND ownerId = ?";
3100
+ params.push(options.expectedOwnerId);
3101
+ }
3102
+ if (options?.expectedLeaseExpiresAt !== void 0) if (options.expectedLeaseExpiresAt === null) where += " AND leaseExpiresAt IS NULL";
3103
+ else {
3104
+ where += " AND leaseExpiresAt = ?";
3105
+ params.push(options.expectedLeaseExpiresAt.toISOString());
3106
+ }
3080
3107
  return (await this.#client.execute({
3081
3108
  sql: `UPDATE ${_mastra_core_storage.TABLE_BACKGROUND_TASKS} SET ${setClauses.join(", ")} WHERE ${where}`,
3082
3109
  args: params