@mastra/pg 0.14.6-alpha.2 → 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 CHANGED
@@ -1,5 +1,71 @@
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
+
18
+ ## 0.14.6
19
+
20
+ ### Patch Changes
21
+
22
+ - de3cbc6: Update the `package.json` file to include additional fields like `repository`, `homepage` or `files`.
23
+ - f0dfcac: updated core peerdep
24
+ - 3c236f6: PostgresStore fix to not try to recreate existing index
25
+ - Updated dependencies [ab48c97]
26
+ - Updated dependencies [85ef90b]
27
+ - Updated dependencies [aedbbfa]
28
+ - Updated dependencies [ff89505]
29
+ - Updated dependencies [637f323]
30
+ - Updated dependencies [de3cbc6]
31
+ - Updated dependencies [c19bcf7]
32
+ - Updated dependencies [4474d04]
33
+ - Updated dependencies [183dc95]
34
+ - Updated dependencies [a1111e2]
35
+ - Updated dependencies [b42a961]
36
+ - Updated dependencies [61debef]
37
+ - Updated dependencies [9beaeff]
38
+ - Updated dependencies [29de0e1]
39
+ - Updated dependencies [f643c65]
40
+ - Updated dependencies [00c74e7]
41
+ - Updated dependencies [fef7375]
42
+ - Updated dependencies [e3d8fea]
43
+ - Updated dependencies [45e4d39]
44
+ - Updated dependencies [9eee594]
45
+ - Updated dependencies [7149d8d]
46
+ - Updated dependencies [822c2e8]
47
+ - Updated dependencies [979912c]
48
+ - Updated dependencies [7dcf4c0]
49
+ - Updated dependencies [4106a58]
50
+ - Updated dependencies [ad78bfc]
51
+ - Updated dependencies [0302f50]
52
+ - Updated dependencies [6ac697e]
53
+ - Updated dependencies [74db265]
54
+ - Updated dependencies [0ce418a]
55
+ - Updated dependencies [af90672]
56
+ - Updated dependencies [8387952]
57
+ - Updated dependencies [7f3b8da]
58
+ - Updated dependencies [905352b]
59
+ - Updated dependencies [599d04c]
60
+ - Updated dependencies [56041d0]
61
+ - Updated dependencies [3412597]
62
+ - Updated dependencies [5eca5d2]
63
+ - Updated dependencies [f2cda47]
64
+ - Updated dependencies [5de1555]
65
+ - Updated dependencies [cfd377a]
66
+ - Updated dependencies [1ed5a3e]
67
+ - @mastra/core@0.15.3
68
+
3
69
  ## 0.14.6-alpha.2
4
70
 
5
71
  ### 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
  },