@mastra/mysql 0.10.2 → 0.11.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-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.10.2"
6
+ version: "0.11.0-alpha.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.10.2",
2
+ "version": "0.11.0-alpha.1",
3
3
  "package": "@mastra/mysql",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -1407,7 +1407,9 @@ function rowToTask(row) {
1407
1407
  createdAt: parseDateTime(row.createdAt),
1408
1408
  startedAt: parseDateTime(row.startedAt),
1409
1409
  suspendedAt: parseDateTime(row.suspendedAt),
1410
- completedAt: parseDateTime(row.completedAt)
1410
+ completedAt: parseDateTime(row.completedAt),
1411
+ ownerId: row.ownerId != null ? String(row.ownerId) : void 0,
1412
+ leaseExpiresAt: parseDateTime(row.leaseExpiresAt)
1411
1413
  };
1412
1414
  }
1413
1415
  var BackgroundTasksMySQL = class BackgroundTasksMySQL extends _mastra_core_storage.BackgroundTasksStorage {
@@ -1428,6 +1430,16 @@ var BackgroundTasksMySQL = class BackgroundTasksMySQL extends _mastra_core_stora
1428
1430
  tableName: _mastra_core_storage.TABLE_BACKGROUND_TASKS,
1429
1431
  schema: _mastra_core_storage.TABLE_SCHEMAS[_mastra_core_storage.TABLE_BACKGROUND_TASKS]
1430
1432
  });
1433
+ await this.operations.alterTable({
1434
+ tableName: _mastra_core_storage.TABLE_BACKGROUND_TASKS,
1435
+ schema: _mastra_core_storage.TABLE_SCHEMAS[_mastra_core_storage.TABLE_BACKGROUND_TASKS],
1436
+ ifNotExists: [
1437
+ "suspend_payload",
1438
+ "suspendedAt",
1439
+ "ownerId",
1440
+ "leaseExpiresAt"
1441
+ ]
1442
+ });
1431
1443
  await this.createDefaultIndexes();
1432
1444
  await this.createCustomIndexes();
1433
1445
  }
@@ -1479,7 +1491,7 @@ var BackgroundTasksMySQL = class BackgroundTasksMySQL extends _mastra_core_stora
1479
1491
  await this.operations.clearTable({ tableName: _mastra_core_storage.TABLE_BACKGROUND_TASKS });
1480
1492
  }
1481
1493
  async createTask(task) {
1482
- 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")}) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
1494
+ 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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
1483
1495
  task.id,
1484
1496
  task.toolCallId,
1485
1497
  task.toolName,
@@ -1498,7 +1510,9 @@ var BackgroundTasksMySQL = class BackgroundTasksMySQL extends _mastra_core_stora
1498
1510
  transformToSqlValue(task.createdAt),
1499
1511
  transformToSqlValue(task.startedAt),
1500
1512
  transformToSqlValue(task.suspendedAt),
1501
- transformToSqlValue(task.completedAt)
1513
+ transformToSqlValue(task.completedAt),
1514
+ task.ownerId ?? null,
1515
+ transformToSqlValue(task.leaseExpiresAt)
1502
1516
  ]);
1503
1517
  }
1504
1518
  async updateTask(taskId, update, options) {
@@ -1536,11 +1550,33 @@ var BackgroundTasksMySQL = class BackgroundTasksMySQL extends _mastra_core_stora
1536
1550
  setClauses.push(`${quoteIdentifier("completedAt", "column name")} = ?`);
1537
1551
  params.push(transformToSqlValue(update.completedAt));
1538
1552
  }
1553
+ if ("ownerId" in update) {
1554
+ setClauses.push(`${quoteIdentifier("ownerId", "column name")} = ?`);
1555
+ params.push(update.ownerId ?? null);
1556
+ }
1557
+ if ("leaseExpiresAt" in update) {
1558
+ setClauses.push(`${quoteIdentifier("leaseExpiresAt", "column name")} = ?`);
1559
+ params.push(transformToSqlValue(update.leaseExpiresAt));
1560
+ }
1539
1561
  if (setClauses.length === 0) return false;
1540
1562
  params.push(taskId);
1541
- const statusPredicate = options?.expectedStatus ? ` AND ${quoteIdentifier("status", "column name")} = ?` : "";
1542
- if (options?.expectedStatus) params.push(options.expectedStatus);
1543
- const [result] = await this.pool.execute(`UPDATE ${formatTableName(_mastra_core_storage.TABLE_BACKGROUND_TASKS)} SET ${setClauses.join(", ")} WHERE ${quoteIdentifier("id", "column name")} = ?${statusPredicate}`, params);
1563
+ const predicates = [];
1564
+ if (options?.expectedStatus) {
1565
+ predicates.push(`${quoteIdentifier("status", "column name")} = ?`);
1566
+ params.push(options.expectedStatus);
1567
+ }
1568
+ if (options?.expectedOwnerId !== void 0) if (options.expectedOwnerId === null) predicates.push(`${quoteIdentifier("ownerId", "column name")} IS NULL`);
1569
+ else {
1570
+ predicates.push(`${quoteIdentifier("ownerId", "column name")} = ?`);
1571
+ params.push(options.expectedOwnerId);
1572
+ }
1573
+ if (options?.expectedLeaseExpiresAt !== void 0) if (options.expectedLeaseExpiresAt === null) predicates.push(`${quoteIdentifier("leaseExpiresAt", "column name")} IS NULL`);
1574
+ else {
1575
+ predicates.push(`${quoteIdentifier("leaseExpiresAt", "column name")} = ?`);
1576
+ params.push(transformToSqlValue(options.expectedLeaseExpiresAt));
1577
+ }
1578
+ const predicateSql = predicates.length > 0 ? ` AND ${predicates.join(" AND ")}` : "";
1579
+ const [result] = await this.pool.execute(`UPDATE ${formatTableName(_mastra_core_storage.TABLE_BACKGROUND_TASKS)} SET ${setClauses.join(", ")} WHERE ${quoteIdentifier("id", "column name")} = ?${predicateSql}`, params);
1544
1580
  return result.affectedRows > 0;
1545
1581
  }
1546
1582
  async getTask(taskId) {
@@ -9898,6 +9934,7 @@ const SNAPSHOT_FIELDS$1 = [
9898
9934
  "references",
9899
9935
  "scripts",
9900
9936
  "assets",
9937
+ "files",
9901
9938
  "metadata",
9902
9939
  "tree"
9903
9940
  ];
@@ -10010,6 +10047,7 @@ var SkillsMySQL = class SkillsMySQL extends _mastra_core_storage.SkillsStorage {
10010
10047
  references: this.safeParseJSON(row.references),
10011
10048
  scripts: this.safeParseJSON(row.scripts),
10012
10049
  assets: this.safeParseJSON(row.assets),
10050
+ files: this.safeParseJSON(row.files),
10013
10051
  metadata: this.safeParseJSON(row.metadata),
10014
10052
  tree: this.safeParseJSON(row.tree),
10015
10053
  changedFields: this.safeParseJSON(row.changedFields),
@@ -10280,6 +10318,7 @@ var SkillsMySQL = class SkillsMySQL extends _mastra_core_storage.SkillsStorage {
10280
10318
  references: input.references ?? null,
10281
10319
  scripts: input.scripts ?? null,
10282
10320
  assets: input.assets ?? null,
10321
+ files: input.files ?? null,
10283
10322
  metadata: input.metadata ?? null,
10284
10323
  tree: input.tree ?? null,
10285
10324
  changedFields: input.changedFields ?? null,