@mastra/mssql 1.2.1 → 1.2.2-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.
- package/CHANGELOG.md +28 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +29 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -5
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +2 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @mastra/mssql
|
|
2
2
|
|
|
3
|
+
## 1.2.2-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Respect optional `resourceId` in `getThreadById` so scoped thread lookups return `null` when the thread belongs to a different resource. ([#14237](https://github.com/mastra-ai/mastra/pull/14237))
|
|
8
|
+
|
|
9
|
+
Example:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
const thread = await memory.getThreadById({
|
|
13
|
+
threadId: 'my-thread-id',
|
|
14
|
+
resourceId: 'my-user-id',
|
|
15
|
+
});
|
|
16
|
+
// Returns null if the thread does not belong to 'my-user-id'.
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [[`7c275a8`](https://github.com/mastra-ai/mastra/commit/7c275a810595e1a6c41ccc39720531ab65734700), [`890b24c`](https://github.com/mastra-ai/mastra/commit/890b24cc7d32ed6aa4dfe253e54dc6bf4099f690), [`0f48ebf`](https://github.com/mastra-ai/mastra/commit/0f48ebfc7ac7897b2092a189f45751924cf56d1c), [`f180e49`](https://github.com/mastra-ai/mastra/commit/f180e4990e71b04c9a475b523584071712f0048f), [`9260e01`](https://github.com/mastra-ai/mastra/commit/9260e015276fb1b500f7878ee452b47476bf1583), [`2f6c54e`](https://github.com/mastra-ai/mastra/commit/2f6c54e17c041cac1def54baaa6b771647836414), [`e06a159`](https://github.com/mastra-ai/mastra/commit/e06a1598ca07a6c3778aefc2a2d288363c6294ff), [`db34bc6`](https://github.com/mastra-ai/mastra/commit/db34bc6fb36cf125bda0c46be4d3fdc774b70cc4)]:
|
|
20
|
+
- @mastra/core@1.33.0-alpha.8
|
|
21
|
+
|
|
22
|
+
## 1.2.2-alpha.0
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Track `suspendedAt` and `suspendPayload` on background tasks. SQL adapters auto-migrate the new columns via `alterTable`. ([#16260](https://github.com/mastra-ai/mastra/pull/16260))
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [[`9f17410`](https://github.com/mastra-ai/mastra/commit/9f1741080def23d42ee50b39887a385ae316a3c6), [`c6eb39e`](https://github.com/mastra-ai/mastra/commit/c6eb39ea6dca381c6563cb240237fbe608e02f93), [`900d086`](https://github.com/mastra-ai/mastra/commit/900d086bb737b9cf2fcf68f11b0389b801a2738c), [`4c0e286`](https://github.com/mastra-ai/mastra/commit/4c0e28637c9cfb4f416549b55e97ebfa13319dfc), [`25184ff`](https://github.com/mastra-ai/mastra/commit/25184ffaf1293ec95119426eb1a1f8d38831b96c), [`aebde9c`](https://github.com/mastra-ai/mastra/commit/aebde9cfacf56592c6b6350cae721740fe090b8a)]:
|
|
29
|
+
- @mastra/core@1.33.0-alpha.4
|
|
30
|
+
|
|
3
31
|
## 1.2.1
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1385,11 +1385,13 @@ function rowToTask(row) {
|
|
|
1385
1385
|
runId: row.run_id ?? "",
|
|
1386
1386
|
result: parseJson(row.result),
|
|
1387
1387
|
error: parseJson(row.error),
|
|
1388
|
+
suspendPayload: parseJson(row.suspend_payload),
|
|
1388
1389
|
retryCount: Number(row.retry_count),
|
|
1389
1390
|
maxRetries: Number(row.max_retries),
|
|
1390
1391
|
timeoutMs: Number(row.timeout_ms),
|
|
1391
1392
|
createdAt: row.createdAt instanceof Date ? row.createdAt : new Date(row.createdAt),
|
|
1392
1393
|
startedAt: row.startedAt ? row.startedAt instanceof Date ? row.startedAt : new Date(row.startedAt) : void 0,
|
|
1394
|
+
suspendedAt: row.suspendedAt ? row.suspendedAt instanceof Date ? row.suspendedAt : new Date(row.suspendedAt) : void 0,
|
|
1393
1395
|
completedAt: row.completedAt ? row.completedAt instanceof Date ? row.completedAt : new Date(row.completedAt) : void 0
|
|
1394
1396
|
};
|
|
1395
1397
|
}
|
|
@@ -1422,6 +1424,11 @@ var BackgroundTasksMSSQL = class _BackgroundTasksMSSQL extends storage.Backgroun
|
|
|
1422
1424
|
tableName: storage.TABLE_BACKGROUND_TASKS,
|
|
1423
1425
|
schema: storage.TABLE_SCHEMAS[storage.TABLE_BACKGROUND_TASKS]
|
|
1424
1426
|
});
|
|
1427
|
+
await this.db.alterTable({
|
|
1428
|
+
tableName: storage.TABLE_BACKGROUND_TASKS,
|
|
1429
|
+
schema: storage.TABLE_SCHEMAS[storage.TABLE_BACKGROUND_TASKS],
|
|
1430
|
+
ifNotExists: ["suspend_payload", "suspendedAt"]
|
|
1431
|
+
});
|
|
1425
1432
|
await this.createDefaultIndexes();
|
|
1426
1433
|
await this.createCustomIndexes();
|
|
1427
1434
|
}
|
|
@@ -1491,11 +1498,13 @@ var BackgroundTasksMSSQL = class _BackgroundTasksMSSQL extends storage.Backgroun
|
|
|
1491
1498
|
args: serializeJson(task.args),
|
|
1492
1499
|
result: serializeJson(task.result),
|
|
1493
1500
|
error: serializeJson(task.error),
|
|
1501
|
+
suspend_payload: serializeJson(task.suspendPayload),
|
|
1494
1502
|
retry_count: task.retryCount,
|
|
1495
1503
|
max_retries: task.maxRetries,
|
|
1496
1504
|
timeout_ms: task.timeoutMs,
|
|
1497
1505
|
createdAt: task.createdAt.toISOString(),
|
|
1498
1506
|
startedAt: task.startedAt?.toISOString() ?? null,
|
|
1507
|
+
suspendedAt: task.suspendedAt?.toISOString() ?? null,
|
|
1499
1508
|
completedAt: task.completedAt?.toISOString() ?? null
|
|
1500
1509
|
}
|
|
1501
1510
|
});
|
|
@@ -1516,6 +1525,10 @@ var BackgroundTasksMSSQL = class _BackgroundTasksMSSQL extends storage.Backgroun
|
|
|
1516
1525
|
setClauses.push(`[error] = @p${idx}`);
|
|
1517
1526
|
params[`p${idx++}`] = serializeJson(update.error);
|
|
1518
1527
|
}
|
|
1528
|
+
if ("suspendPayload" in update) {
|
|
1529
|
+
setClauses.push(`[suspend_payload] = @p${idx}`);
|
|
1530
|
+
params[`p${idx++}`] = serializeJson(update.suspendPayload);
|
|
1531
|
+
}
|
|
1519
1532
|
if ("retryCount" in update) {
|
|
1520
1533
|
setClauses.push(`[retry_count] = @p${idx}`);
|
|
1521
1534
|
params[`p${idx++}`] = update.retryCount;
|
|
@@ -1524,6 +1537,10 @@ var BackgroundTasksMSSQL = class _BackgroundTasksMSSQL extends storage.Backgroun
|
|
|
1524
1537
|
setClauses.push(`[startedAt] = @p${idx}`);
|
|
1525
1538
|
params[`p${idx++}`] = update.startedAt?.toISOString() ?? null;
|
|
1526
1539
|
}
|
|
1540
|
+
if ("suspendedAt" in update) {
|
|
1541
|
+
setClauses.push(`[suspendedAt] = @p${idx}`);
|
|
1542
|
+
params[`p${idx++}`] = update.suspendedAt?.toISOString() ?? null;
|
|
1543
|
+
}
|
|
1527
1544
|
if ("completedAt" in update) {
|
|
1528
1545
|
setClauses.push(`[completedAt] = @p${idx}`);
|
|
1529
1546
|
params[`p${idx++}`] = update.completedAt?.toISOString() ?? null;
|
|
@@ -1579,7 +1596,11 @@ var BackgroundTasksMSSQL = class _BackgroundTasksMSSQL extends storage.Backgroun
|
|
|
1579
1596
|
params[`p${idx}`] = filter.toolName;
|
|
1580
1597
|
conditions.push(`[tool_name] = @p${idx++}`);
|
|
1581
1598
|
}
|
|
1582
|
-
|
|
1599
|
+
if (filter.toolCallId) {
|
|
1600
|
+
params[`p${idx}`] = filter.toolCallId;
|
|
1601
|
+
conditions.push(`[tool_call_id] = @p${idx++}`);
|
|
1602
|
+
}
|
|
1603
|
+
const dateCol = filter.dateFilterBy === "startedAt" ? "[startedAt]" : filter.dateFilterBy === "suspendedAt" ? "[suspendedAt]" : filter.dateFilterBy === "completedAt" ? "[completedAt]" : "[createdAt]";
|
|
1583
1604
|
if (filter.fromDate) {
|
|
1584
1605
|
params[`p${idx}`] = filter.fromDate.toISOString();
|
|
1585
1606
|
conditions.push(`${dateCol} >= @p${idx++}`);
|
|
@@ -1595,7 +1616,7 @@ var BackgroundTasksMSSQL = class _BackgroundTasksMSSQL extends storage.Backgroun
|
|
|
1595
1616
|
}
|
|
1596
1617
|
const countResult = await countRequest.query(`SELECT COUNT(*) as count FROM ${this.tableName()} ${where}`);
|
|
1597
1618
|
const total = Number(countResult.recordset[0]?.count ?? 0);
|
|
1598
|
-
const orderCol = filter.orderBy === "startedAt" ? "[startedAt]" : filter.orderBy === "completedAt" ? "[completedAt]" : "[createdAt]";
|
|
1619
|
+
const orderCol = filter.orderBy === "startedAt" ? "[startedAt]" : filter.orderBy === "suspendedAt" ? "[suspendedAt]" : filter.orderBy === "completedAt" ? "[completedAt]" : "[createdAt]";
|
|
1599
1620
|
const direction = filter.orderDirection === "desc" ? "DESC" : "ASC";
|
|
1600
1621
|
let sql5 = `SELECT * FROM ${this.tableName()} ${where} ORDER BY ${orderCol} ${direction}`;
|
|
1601
1622
|
if (filter.perPage != null) {
|
|
@@ -1632,7 +1653,7 @@ var BackgroundTasksMSSQL = class _BackgroundTasksMSSQL extends storage.Backgroun
|
|
|
1632
1653
|
});
|
|
1633
1654
|
conditions.push(`[status] IN (${placeholders.join(", ")})`);
|
|
1634
1655
|
}
|
|
1635
|
-
const dateCol = filter.dateFilterBy === "startedAt" ? "[startedAt]" : filter.dateFilterBy === "completedAt" ? "[completedAt]" : "[createdAt]";
|
|
1656
|
+
const dateCol = filter.dateFilterBy === "startedAt" ? "[startedAt]" : filter.dateFilterBy === "suspendedAt" ? "[suspendedAt]" : filter.dateFilterBy === "completedAt" ? "[completedAt]" : "[createdAt]";
|
|
1636
1657
|
if (filter.fromDate) {
|
|
1637
1658
|
params[`p${idx}`] = filter.fromDate.toISOString();
|
|
1638
1659
|
conditions.push(`${dateCol} >= @p${idx++}`);
|
|
@@ -1768,7 +1789,10 @@ var MemoryMSSQL = class _MemoryMSSQL extends storage.MemoryStorage {
|
|
|
1768
1789
|
await this.db.clearTable({ tableName: storage.TABLE_THREADS });
|
|
1769
1790
|
await this.db.clearTable({ tableName: storage.TABLE_RESOURCES });
|
|
1770
1791
|
}
|
|
1771
|
-
async getThreadById({
|
|
1792
|
+
async getThreadById({
|
|
1793
|
+
threadId,
|
|
1794
|
+
resourceId
|
|
1795
|
+
}) {
|
|
1772
1796
|
try {
|
|
1773
1797
|
const sql5 = `SELECT
|
|
1774
1798
|
id,
|
|
@@ -1783,7 +1807,7 @@ var MemoryMSSQL = class _MemoryMSSQL extends storage.MemoryStorage {
|
|
|
1783
1807
|
request.input("threadId", threadId);
|
|
1784
1808
|
const resultSet = await request.query(sql5);
|
|
1785
1809
|
const thread = resultSet.recordset[0] || null;
|
|
1786
|
-
if (!thread) {
|
|
1810
|
+
if (!thread || resourceId !== void 0 && thread.resourceId !== resourceId) {
|
|
1787
1811
|
return null;
|
|
1788
1812
|
}
|
|
1789
1813
|
return {
|