@mastra/pg 0.14.6 → 0.14.7-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.
- package/CHANGELOG.md +15 -0
- package/dist/index.cjs +14 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -9
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1486,6 +1486,7 @@ var MemoryPG = class extends MemoryStorage {
|
|
|
1486
1486
|
selectBy,
|
|
1487
1487
|
orderByStatement
|
|
1488
1488
|
}) {
|
|
1489
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
1489
1490
|
const include = selectBy?.include;
|
|
1490
1491
|
if (!include) return null;
|
|
1491
1492
|
const unionQueries = [];
|
|
@@ -1560,11 +1561,12 @@ var MemoryPG = class extends MemoryStorage {
|
|
|
1560
1561
|
};
|
|
1561
1562
|
}
|
|
1562
1563
|
async getMessages(args) {
|
|
1563
|
-
const { threadId, format, selectBy } = args;
|
|
1564
|
+
const { threadId, resourceId, format, selectBy } = args;
|
|
1564
1565
|
const selectStatement = `SELECT id, content, role, type, "createdAt", thread_id AS "threadId", "resourceId"`;
|
|
1565
1566
|
const orderByStatement = `ORDER BY "createdAt" DESC`;
|
|
1566
1567
|
const limit = resolveMessageLimit({ last: selectBy?.last, defaultLimit: 40 });
|
|
1567
1568
|
try {
|
|
1569
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
1568
1570
|
let rows = [];
|
|
1569
1571
|
const include = selectBy?.include || [];
|
|
1570
1572
|
if (include?.length) {
|
|
@@ -1607,7 +1609,8 @@ var MemoryPG = class extends MemoryStorage {
|
|
|
1607
1609
|
domain: ErrorDomain.STORAGE,
|
|
1608
1610
|
category: ErrorCategory.THIRD_PARTY,
|
|
1609
1611
|
details: {
|
|
1610
|
-
threadId
|
|
1612
|
+
threadId,
|
|
1613
|
+
resourceId: resourceId ?? ""
|
|
1611
1614
|
}
|
|
1612
1615
|
},
|
|
1613
1616
|
error
|
|
@@ -1652,20 +1655,21 @@ var MemoryPG = class extends MemoryStorage {
|
|
|
1652
1655
|
}
|
|
1653
1656
|
}
|
|
1654
1657
|
async getMessagesPaginated(args) {
|
|
1655
|
-
const { threadId, format, selectBy } = args;
|
|
1658
|
+
const { threadId, resourceId, format, selectBy } = args;
|
|
1656
1659
|
const { page = 0, perPage: perPageInput, dateRange } = selectBy?.pagination || {};
|
|
1657
1660
|
const fromDate = dateRange?.start;
|
|
1658
1661
|
const toDate = dateRange?.end;
|
|
1659
1662
|
const selectStatement = `SELECT id, content, role, type, "createdAt", thread_id AS "threadId", "resourceId"`;
|
|
1660
1663
|
const orderByStatement = `ORDER BY "createdAt" DESC`;
|
|
1661
1664
|
const messages = [];
|
|
1662
|
-
if (selectBy?.include?.length) {
|
|
1663
|
-
const includeMessages = await this._getIncludedMessages({ threadId, selectBy, orderByStatement });
|
|
1664
|
-
if (includeMessages) {
|
|
1665
|
-
messages.push(...includeMessages);
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
1665
|
try {
|
|
1666
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
1667
|
+
if (selectBy?.include?.length) {
|
|
1668
|
+
const includeMessages = await this._getIncludedMessages({ threadId, selectBy, orderByStatement });
|
|
1669
|
+
if (includeMessages) {
|
|
1670
|
+
messages.push(...includeMessages);
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1669
1673
|
const perPage = perPageInput !== void 0 ? perPageInput : resolveMessageLimit({ last: selectBy?.last, defaultLimit: 40 });
|
|
1670
1674
|
const currentOffset = page * perPage;
|
|
1671
1675
|
const conditions = [`thread_id = $1`];
|
|
@@ -1726,6 +1730,7 @@ var MemoryPG = class extends MemoryStorage {
|
|
|
1726
1730
|
category: ErrorCategory.THIRD_PARTY,
|
|
1727
1731
|
details: {
|
|
1728
1732
|
threadId,
|
|
1733
|
+
resourceId: resourceId ?? "",
|
|
1729
1734
|
page
|
|
1730
1735
|
}
|
|
1731
1736
|
},
|