@mastra/mysql 0.14.1 → 0.15.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-mysql
3
3
  description: Documentation for @mastra/mysql. Use when working with @mastra/mysql APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/mysql"
6
- version: "0.14.1"
6
+ version: "0.15.0-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.14.1",
2
+ "version": "0.15.0-alpha.0",
3
3
  "package": "@mastra/mysql",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -1407,10 +1407,13 @@ function rowToTask(row) {
1407
1407
  suspendedAt: parseDateTime(row.suspendedAt),
1408
1408
  completedAt: parseDateTime(row.completedAt),
1409
1409
  ownerId: row.ownerId != null ? String(row.ownerId) : void 0,
1410
- leaseExpiresAt: parseDateTime(row.leaseExpiresAt)
1410
+ leaseExpiresAt: parseDateTime(row.leaseExpiresAt),
1411
+ expiresAt: parseDateTime(row.expiresAt),
1412
+ metadata: parseJson$2(row.metadata)
1411
1413
  };
1412
1414
  }
1413
1415
  var BackgroundTasksMySQL = class BackgroundTasksMySQL extends _mastra_core_storage.BackgroundTasksStorage {
1416
+ supportsTaskExpiry = true;
1414
1417
  pool;
1415
1418
  operations;
1416
1419
  #skipDefaultIndexes;
@@ -1435,7 +1438,9 @@ var BackgroundTasksMySQL = class BackgroundTasksMySQL extends _mastra_core_stora
1435
1438
  "suspend_payload",
1436
1439
  "suspendedAt",
1437
1440
  "ownerId",
1438
- "leaseExpiresAt"
1441
+ "leaseExpiresAt",
1442
+ "expiresAt",
1443
+ "metadata"
1439
1444
  ]
1440
1445
  });
1441
1446
  await this.createDefaultIndexes();
@@ -1489,7 +1494,7 @@ var BackgroundTasksMySQL = class BackgroundTasksMySQL extends _mastra_core_stora
1489
1494
  await this.operations.clearTable({ tableName: _mastra_core_storage.TABLE_BACKGROUND_TASKS });
1490
1495
  }
1491
1496
  async createTask(task) {
1492
- await this.pool.execute(`INSERT INTO ${formatTableName(_mastra_core_storage.TABLE_BACKGROUND_TASKS)} (${quoteIdentifier("id", "column name")}, ${quoteIdentifier("tool_call_id", "column name")}, ${quoteIdentifier("tool_name", "column name")}, ${quoteIdentifier("agent_id", "column name")}, ${quoteIdentifier("thread_id", "column name")}, ${quoteIdentifier("resource_id", "column name")}, ${quoteIdentifier("run_id", "column name")}, ${quoteIdentifier("status", "column name")}, ${quoteIdentifier("args", "column name")}, ${quoteIdentifier("result", "column name")}, ${quoteIdentifier("error", "column name")}, ${quoteIdentifier("suspend_payload", "column name")}, ${quoteIdentifier("retry_count", "column name")}, ${quoteIdentifier("max_retries", "column name")}, ${quoteIdentifier("timeout_ms", "column name")}, ${quoteIdentifier("createdAt", "column name")}, ${quoteIdentifier("startedAt", "column name")}, ${quoteIdentifier("suspendedAt", "column name")}, ${quoteIdentifier("completedAt", "column name")}, ${quoteIdentifier("ownerId", "column name")}, ${quoteIdentifier("leaseExpiresAt", "column name")}) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
1497
+ await this.pool.execute(`INSERT INTO ${formatTableName(_mastra_core_storage.TABLE_BACKGROUND_TASKS)} (${quoteIdentifier("id", "column name")}, ${quoteIdentifier("tool_call_id", "column name")}, ${quoteIdentifier("tool_name", "column name")}, ${quoteIdentifier("agent_id", "column name")}, ${quoteIdentifier("thread_id", "column name")}, ${quoteIdentifier("resource_id", "column name")}, ${quoteIdentifier("run_id", "column name")}, ${quoteIdentifier("status", "column name")}, ${quoteIdentifier("args", "column name")}, ${quoteIdentifier("result", "column name")}, ${quoteIdentifier("error", "column name")}, ${quoteIdentifier("suspend_payload", "column name")}, ${quoteIdentifier("retry_count", "column name")}, ${quoteIdentifier("max_retries", "column name")}, ${quoteIdentifier("timeout_ms", "column name")}, ${quoteIdentifier("createdAt", "column name")}, ${quoteIdentifier("startedAt", "column name")}, ${quoteIdentifier("suspendedAt", "column name")}, ${quoteIdentifier("completedAt", "column name")}, ${quoteIdentifier("ownerId", "column name")}, ${quoteIdentifier("leaseExpiresAt", "column name")}, ${quoteIdentifier("expiresAt", "column name")}, ${quoteIdentifier("metadata", "column name")}) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
1493
1498
  task.id,
1494
1499
  task.toolCallId,
1495
1500
  task.toolName,
@@ -1510,7 +1515,9 @@ var BackgroundTasksMySQL = class BackgroundTasksMySQL extends _mastra_core_stora
1510
1515
  transformToSqlValue(task.suspendedAt),
1511
1516
  transformToSqlValue(task.completedAt),
1512
1517
  task.ownerId ?? null,
1513
- transformToSqlValue(task.leaseExpiresAt)
1518
+ transformToSqlValue(task.leaseExpiresAt),
1519
+ transformToSqlValue(task.expiresAt),
1520
+ task.metadata ? JSON.stringify(task.metadata) : null
1514
1521
  ]);
1515
1522
  }
1516
1523
  async updateTask(taskId, update, options) {
@@ -1556,6 +1563,14 @@ var BackgroundTasksMySQL = class BackgroundTasksMySQL extends _mastra_core_stora
1556
1563
  setClauses.push(`${quoteIdentifier("leaseExpiresAt", "column name")} = ?`);
1557
1564
  params.push(transformToSqlValue(update.leaseExpiresAt));
1558
1565
  }
1566
+ if ("expiresAt" in update) {
1567
+ setClauses.push(`${quoteIdentifier("expiresAt", "column name")} = ?`);
1568
+ params.push(transformToSqlValue(update.expiresAt));
1569
+ }
1570
+ if ("metadata" in update) {
1571
+ setClauses.push(`${quoteIdentifier("metadata", "column name")} = ?`);
1572
+ params.push(serializeJson(update.metadata));
1573
+ }
1559
1574
  if (setClauses.length === 0) return false;
1560
1575
  params.push(taskId);
1561
1576
  const predicates = [];
@@ -1577,6 +1592,13 @@ var BackgroundTasksMySQL = class BackgroundTasksMySQL extends _mastra_core_stora
1577
1592
  params.push(transformToSqlValue(options.expectedLeaseExpiresAt));
1578
1593
  }
1579
1594
  }
1595
+ if (options?.expectedSuspendedAt !== void 0) {
1596
+ if (options.expectedSuspendedAt === null) predicates.push(`${quoteIdentifier("suspendedAt", "column name")} IS NULL`);
1597
+ else {
1598
+ predicates.push(`${quoteIdentifier("suspendedAt", "column name")} = ?`);
1599
+ params.push(transformToSqlValue(options.expectedSuspendedAt));
1600
+ }
1601
+ }
1580
1602
  const predicateSql = predicates.length > 0 ? ` AND ${predicates.join(" AND ")}` : "";
1581
1603
  const [result] = await this.pool.execute(`UPDATE ${formatTableName(_mastra_core_storage.TABLE_BACKGROUND_TASKS)} SET ${setClauses.join(", ")} WHERE ${quoteIdentifier("id", "column name")} = ?${predicateSql}`, params);
1582
1604
  return result.affectedRows > 0;
@@ -1619,7 +1641,8 @@ var BackgroundTasksMySQL = class BackgroundTasksMySQL extends _mastra_core_stora
1619
1641
  conditions.push(`${quoteIdentifier("tool_call_id", "column name")} = ?`);
1620
1642
  params.push(filter.toolCallId);
1621
1643
  }
1622
- const dateCol = filter.dateFilterBy === "startedAt" ? quoteIdentifier("startedAt", "column name") : filter.dateFilterBy === "suspendedAt" ? quoteIdentifier("suspendedAt", "column name") : filter.dateFilterBy === "completedAt" ? quoteIdentifier("completedAt", "column name") : quoteIdentifier("createdAt", "column name");
1644
+ const dateCol = filter.dateFilterBy === "startedAt" ? quoteIdentifier("startedAt", "column name") : filter.dateFilterBy === "suspendedAt" ? quoteIdentifier("suspendedAt", "column name") : filter.dateFilterBy === "completedAt" ? quoteIdentifier("completedAt", "column name") : filter.dateFilterBy === "expiresAt" ? quoteIdentifier("expiresAt", "column name") : quoteIdentifier("createdAt", "column name");
1645
+ if (filter.hasExpiresAt !== void 0) conditions.push(`${quoteIdentifier("expiresAt", "column name")} IS ${filter.hasExpiresAt ? "NOT NULL" : "NULL"}`);
1623
1646
  if (filter.fromDate) {
1624
1647
  conditions.push(`${dateCol} >= ?`);
1625
1648
  params.push(transformToSqlValue(filter.fromDate));
@@ -1660,7 +1683,8 @@ var BackgroundTasksMySQL = class BackgroundTasksMySQL extends _mastra_core_stora
1660
1683
  conditions.push(`${quoteIdentifier("status", "column name")} IN (${placeholders})`);
1661
1684
  params.push(...statuses);
1662
1685
  }
1663
- const dateCol = filter.dateFilterBy === "startedAt" ? quoteIdentifier("startedAt", "column name") : filter.dateFilterBy === "suspendedAt" ? quoteIdentifier("suspendedAt", "column name") : filter.dateFilterBy === "completedAt" ? quoteIdentifier("completedAt", "column name") : quoteIdentifier("createdAt", "column name");
1686
+ const dateCol = filter.dateFilterBy === "startedAt" ? quoteIdentifier("startedAt", "column name") : filter.dateFilterBy === "suspendedAt" ? quoteIdentifier("suspendedAt", "column name") : filter.dateFilterBy === "completedAt" ? quoteIdentifier("completedAt", "column name") : filter.dateFilterBy === "expiresAt" ? quoteIdentifier("expiresAt", "column name") : quoteIdentifier("createdAt", "column name");
1687
+ if (filter.hasExpiresAt !== void 0) conditions.push(`${quoteIdentifier("expiresAt", "column name")} IS ${filter.hasExpiresAt ? "NOT NULL" : "NULL"}`);
1664
1688
  if (filter.fromDate) {
1665
1689
  conditions.push(`${dateCol} >= ?`);
1666
1690
  params.push(transformToSqlValue(filter.fromDate));