@mastra/mssql 1.10.6 → 1.11.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-mssql
3
3
  description: Documentation for @mastra/mssql. Use when working with @mastra/mssql APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/mssql"
6
- version: "1.10.6"
6
+ version: "1.11.0-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.10.6",
2
+ "version": "1.11.0-alpha.0",
3
3
  "package": "@mastra/mssql",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -1801,10 +1801,13 @@ function rowToTask(row) {
1801
1801
  suspendedAt: row.suspendedAt ? row.suspendedAt instanceof Date ? row.suspendedAt : new Date(row.suspendedAt) : void 0,
1802
1802
  completedAt: row.completedAt ? row.completedAt instanceof Date ? row.completedAt : new Date(row.completedAt) : void 0,
1803
1803
  ownerId: row.ownerId ?? void 0,
1804
- leaseExpiresAt: row.leaseExpiresAt ? row.leaseExpiresAt instanceof Date ? row.leaseExpiresAt : new Date(row.leaseExpiresAt) : void 0
1804
+ leaseExpiresAt: row.leaseExpiresAt ? row.leaseExpiresAt instanceof Date ? row.leaseExpiresAt : new Date(row.leaseExpiresAt) : void 0,
1805
+ expiresAt: row.expiresAt ? row.expiresAt instanceof Date ? row.expiresAt : new Date(row.expiresAt) : void 0,
1806
+ metadata: parseJson(row.metadata)
1805
1807
  };
1806
1808
  }
1807
1809
  var BackgroundTasksMSSQL = class BackgroundTasksMSSQL extends _mastra_core_storage.BackgroundTasksStorage {
1810
+ supportsTaskExpiry = true;
1808
1811
  pool;
1809
1812
  db;
1810
1813
  schema;
@@ -1842,7 +1845,9 @@ var BackgroundTasksMSSQL = class BackgroundTasksMSSQL extends _mastra_core_stora
1842
1845
  "suspend_payload",
1843
1846
  "suspendedAt",
1844
1847
  "ownerId",
1845
- "leaseExpiresAt"
1848
+ "leaseExpiresAt",
1849
+ "expiresAt",
1850
+ "metadata"
1846
1851
  ]
1847
1852
  });
1848
1853
  await this.createDefaultIndexes();
@@ -1922,7 +1927,9 @@ var BackgroundTasksMSSQL = class BackgroundTasksMSSQL extends _mastra_core_stora
1922
1927
  suspendedAt: task.suspendedAt?.toISOString() ?? null,
1923
1928
  completedAt: task.completedAt?.toISOString() ?? null,
1924
1929
  ownerId: task.ownerId ?? null,
1925
- leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null
1930
+ leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null,
1931
+ expiresAt: task.expiresAt?.toISOString() ?? null,
1932
+ metadata: serializeJson(task.metadata)
1926
1933
  }
1927
1934
  });
1928
1935
  }
@@ -1970,6 +1977,14 @@ var BackgroundTasksMSSQL = class BackgroundTasksMSSQL extends _mastra_core_stora
1970
1977
  setClauses.push(`[leaseExpiresAt] = @p${idx}`);
1971
1978
  params[`p${idx++}`] = update.leaseExpiresAt?.toISOString() ?? null;
1972
1979
  }
1980
+ if ("expiresAt" in update) {
1981
+ setClauses.push(`[expiresAt] = @p${idx}`);
1982
+ params[`p${idx++}`] = update.expiresAt?.toISOString() ?? null;
1983
+ }
1984
+ if ("metadata" in update) {
1985
+ setClauses.push(`[metadata] = @p${idx}`);
1986
+ params[`p${idx++}`] = serializeJson(update.metadata);
1987
+ }
1973
1988
  if (setClauses.length === 0) return false;
1974
1989
  setClauses.push(`[id] = [id]`);
1975
1990
  params[`p${idx}`] = taskId;
@@ -1993,6 +2008,13 @@ var BackgroundTasksMSSQL = class BackgroundTasksMSSQL extends _mastra_core_stora
1993
2008
  predicates.push(`[leaseExpiresAt] = @p${idx++}`);
1994
2009
  }
1995
2010
  }
2011
+ if (options?.expectedSuspendedAt !== void 0) {
2012
+ if (options.expectedSuspendedAt === null) predicates.push(`[suspendedAt] IS NULL`);
2013
+ else {
2014
+ params[`p${idx}`] = options.expectedSuspendedAt.toISOString();
2015
+ predicates.push(`[suspendedAt] = @p${idx++}`);
2016
+ }
2017
+ }
1996
2018
  const predicateSql = predicates.length > 0 ? ` AND ${predicates.join(" AND ")}` : "";
1997
2019
  const request = this.pool.request();
1998
2020
  for (const [name, value] of Object.entries(params)) request.input(name, value);
@@ -2043,7 +2065,8 @@ var BackgroundTasksMSSQL = class BackgroundTasksMSSQL extends _mastra_core_stora
2043
2065
  params[`p${idx}`] = filter.toolCallId;
2044
2066
  conditions.push(`[tool_call_id] = @p${idx++}`);
2045
2067
  }
2046
- const dateCol = filter.dateFilterBy === "startedAt" ? "[startedAt]" : filter.dateFilterBy === "suspendedAt" ? "[suspendedAt]" : filter.dateFilterBy === "completedAt" ? "[completedAt]" : "[createdAt]";
2068
+ const dateCol = filter.dateFilterBy === "startedAt" ? "[startedAt]" : filter.dateFilterBy === "suspendedAt" ? "[suspendedAt]" : filter.dateFilterBy === "completedAt" ? "[completedAt]" : filter.dateFilterBy === "expiresAt" ? "[expiresAt]" : "[createdAt]";
2069
+ if (filter.hasExpiresAt !== void 0) conditions.push(filter.hasExpiresAt ? "[expiresAt] IS NOT NULL" : "[expiresAt] IS NULL");
2047
2070
  if (filter.fromDate) {
2048
2071
  params[`p${idx}`] = filter.fromDate.toISOString();
2049
2072
  conditions.push(`${dateCol} >= @p${idx++}`);
@@ -2093,7 +2116,8 @@ var BackgroundTasksMSSQL = class BackgroundTasksMSSQL extends _mastra_core_stora
2093
2116
  });
2094
2117
  conditions.push(`[status] IN (${placeholders.join(", ")})`);
2095
2118
  }
2096
- const dateCol = filter.dateFilterBy === "startedAt" ? "[startedAt]" : filter.dateFilterBy === "suspendedAt" ? "[suspendedAt]" : filter.dateFilterBy === "completedAt" ? "[completedAt]" : "[createdAt]";
2119
+ const dateCol = filter.dateFilterBy === "startedAt" ? "[startedAt]" : filter.dateFilterBy === "suspendedAt" ? "[suspendedAt]" : filter.dateFilterBy === "completedAt" ? "[completedAt]" : filter.dateFilterBy === "expiresAt" ? "[expiresAt]" : "[createdAt]";
2120
+ if (filter.hasExpiresAt !== void 0) conditions.push(filter.hasExpiresAt ? "[expiresAt] IS NOT NULL" : "[expiresAt] IS NULL");
2097
2121
  if (filter.fromDate) {
2098
2122
  params[`p${idx}`] = filter.fromDate.toISOString();
2099
2123
  conditions.push(`${dateCol} >= @p${idx++}`);