@mastra/pg 1.28.1-alpha.1 → 1.29.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.
@@ -3,7 +3,7 @@ name: mastra-pg
3
3
  description: Documentation for @mastra/pg. Use when working with @mastra/pg APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/pg"
6
- version: "1.28.1-alpha.1"
6
+ version: "1.29.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.28.1-alpha.1",
2
+ "version": "1.29.0",
3
3
  "package": "@mastra/pg",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -10479,6 +10479,7 @@ function dedupeMessagesForSave(messages) {
10479
10479
  var MemoryPG = class MemoryPG extends _mastra_core_storage.MemoryStorage {
10480
10480
  supportsPartialThreadUpdate = true;
10481
10481
  supportsObservationalMemory = true;
10482
+ supportsObservationalMemoryHistorySearch = true;
10482
10483
  /**
10483
10484
  * Retention-eligible tables. `threads`, `messages`, and `resources` all anchor
10484
10485
  * on the timezone-aware `createdAtZ` mirror column (kept in sync by triggers),
@@ -12085,6 +12086,10 @@ var MemoryPG = class MemoryPG extends _mastra_core_storage.MemoryStorage {
12085
12086
  const conditions = [`"lookupKey" = $1`];
12086
12087
  const params = [lookupKey];
12087
12088
  let paramIndex = 2;
12089
+ if (options?.recordId !== void 0) {
12090
+ conditions.push(`id = $${paramIndex++}`);
12091
+ params.push(options.recordId);
12092
+ }
12088
12093
  if (options?.from) {
12089
12094
  conditions.push(`"createdAtZ" >= $${paramIndex}`);
12090
12095
  params.push(options.from.toISOString());
@@ -12095,8 +12100,27 @@ var MemoryPG = class MemoryPG extends _mastra_core_storage.MemoryStorage {
12095
12100
  params.push(options.to.toISOString());
12096
12101
  paramIndex++;
12097
12102
  }
12103
+ if (options?.groupId !== void 0) {
12104
+ conditions.push(`(strpos("activeObservations", $${paramIndex}) > 0 OR EXISTS (
12105
+ SELECT 1 FROM jsonb_array_elements(
12106
+ CASE WHEN jsonb_typeof("bufferedObservationChunks") = 'array' THEN "bufferedObservationChunks" ELSE '[]'::jsonb END
12107
+ ) AS chunk
12108
+ WHERE strpos(chunk->>'observations', $${paramIndex}) > 0
12109
+ ))`);
12110
+ paramIndex++;
12111
+ params.push(`<observation-group id="${options.groupId}"`);
12112
+ }
12113
+ if (options?.beforeGeneration !== void 0) {
12114
+ conditions.push(`"generationCount" < $${paramIndex++}`);
12115
+ params.push(options.beforeGeneration);
12116
+ }
12117
+ if (options?.afterGeneration !== void 0) {
12118
+ conditions.push(`"generationCount" > $${paramIndex++}`);
12119
+ params.push(options.afterGeneration);
12120
+ }
12121
+ const order = options?.sortDirection === "ASC" ? `"generationCount" ASC, "createdAt" ASC, id ASC` : OM_GENERATION_ORDER;
12098
12122
  params.push(limit);
12099
- let sql = `SELECT * FROM ${tableName} WHERE ${conditions.join(" AND ")} ORDER BY ${OM_GENERATION_ORDER} LIMIT $${paramIndex}`;
12123
+ let sql = `SELECT * FROM ${tableName} WHERE ${conditions.join(" AND ")} ORDER BY ${order} LIMIT $${paramIndex}`;
12100
12124
  paramIndex++;
12101
12125
  if (options?.offset != null) {
12102
12126
  params.push(options.offset);