@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @mastra/pg
|
|
2
2
|
|
|
3
|
+
## 0.14.7-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6f5eb7a: Throw if an empty or whitespace-only threadId is passed when getting messages
|
|
8
|
+
- Updated dependencies [fd83526]
|
|
9
|
+
- Updated dependencies [d0b90ab]
|
|
10
|
+
- Updated dependencies [6f5eb7a]
|
|
11
|
+
- Updated dependencies [a01cf14]
|
|
12
|
+
- Updated dependencies [a9e50ee]
|
|
13
|
+
- Updated dependencies [5397eb4]
|
|
14
|
+
- Updated dependencies [c9f4e4a]
|
|
15
|
+
- Updated dependencies [0acbc80]
|
|
16
|
+
- @mastra/core@0.16.0-alpha.0
|
|
17
|
+
|
|
3
18
|
## 0.14.6
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1494,6 +1494,7 @@ var MemoryPG = class extends storage.MemoryStorage {
|
|
|
1494
1494
|
selectBy,
|
|
1495
1495
|
orderByStatement
|
|
1496
1496
|
}) {
|
|
1497
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
1497
1498
|
const include = selectBy?.include;
|
|
1498
1499
|
if (!include) return null;
|
|
1499
1500
|
const unionQueries = [];
|
|
@@ -1568,11 +1569,12 @@ var MemoryPG = class extends storage.MemoryStorage {
|
|
|
1568
1569
|
};
|
|
1569
1570
|
}
|
|
1570
1571
|
async getMessages(args) {
|
|
1571
|
-
const { threadId, format, selectBy } = args;
|
|
1572
|
+
const { threadId, resourceId, format, selectBy } = args;
|
|
1572
1573
|
const selectStatement = `SELECT id, content, role, type, "createdAt", thread_id AS "threadId", "resourceId"`;
|
|
1573
1574
|
const orderByStatement = `ORDER BY "createdAt" DESC`;
|
|
1574
1575
|
const limit = storage.resolveMessageLimit({ last: selectBy?.last, defaultLimit: 40 });
|
|
1575
1576
|
try {
|
|
1577
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
1576
1578
|
let rows = [];
|
|
1577
1579
|
const include = selectBy?.include || [];
|
|
1578
1580
|
if (include?.length) {
|
|
@@ -1615,7 +1617,8 @@ var MemoryPG = class extends storage.MemoryStorage {
|
|
|
1615
1617
|
domain: error.ErrorDomain.STORAGE,
|
|
1616
1618
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1617
1619
|
details: {
|
|
1618
|
-
threadId
|
|
1620
|
+
threadId,
|
|
1621
|
+
resourceId: resourceId ?? ""
|
|
1619
1622
|
}
|
|
1620
1623
|
},
|
|
1621
1624
|
error$1
|
|
@@ -1660,20 +1663,21 @@ var MemoryPG = class extends storage.MemoryStorage {
|
|
|
1660
1663
|
}
|
|
1661
1664
|
}
|
|
1662
1665
|
async getMessagesPaginated(args) {
|
|
1663
|
-
const { threadId, format, selectBy } = args;
|
|
1666
|
+
const { threadId, resourceId, format, selectBy } = args;
|
|
1664
1667
|
const { page = 0, perPage: perPageInput, dateRange } = selectBy?.pagination || {};
|
|
1665
1668
|
const fromDate = dateRange?.start;
|
|
1666
1669
|
const toDate = dateRange?.end;
|
|
1667
1670
|
const selectStatement = `SELECT id, content, role, type, "createdAt", thread_id AS "threadId", "resourceId"`;
|
|
1668
1671
|
const orderByStatement = `ORDER BY "createdAt" DESC`;
|
|
1669
1672
|
const messages = [];
|
|
1670
|
-
if (selectBy?.include?.length) {
|
|
1671
|
-
const includeMessages = await this._getIncludedMessages({ threadId, selectBy, orderByStatement });
|
|
1672
|
-
if (includeMessages) {
|
|
1673
|
-
messages.push(...includeMessages);
|
|
1674
|
-
}
|
|
1675
|
-
}
|
|
1676
1673
|
try {
|
|
1674
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
1675
|
+
if (selectBy?.include?.length) {
|
|
1676
|
+
const includeMessages = await this._getIncludedMessages({ threadId, selectBy, orderByStatement });
|
|
1677
|
+
if (includeMessages) {
|
|
1678
|
+
messages.push(...includeMessages);
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1677
1681
|
const perPage = perPageInput !== void 0 ? perPageInput : storage.resolveMessageLimit({ last: selectBy?.last, defaultLimit: 40 });
|
|
1678
1682
|
const currentOffset = page * perPage;
|
|
1679
1683
|
const conditions = [`thread_id = $1`];
|
|
@@ -1734,6 +1738,7 @@ var MemoryPG = class extends storage.MemoryStorage {
|
|
|
1734
1738
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1735
1739
|
details: {
|
|
1736
1740
|
threadId,
|
|
1741
|
+
resourceId: resourceId ?? "",
|
|
1737
1742
|
page
|
|
1738
1743
|
}
|
|
1739
1744
|
},
|