@mastra/pg 1.30.0 → 1.31.0-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.
@@ -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.30.0"
6
+ version: "1.31.0-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.30.0",
2
+ "version": "1.31.0-alpha.0",
3
3
  "package": "@mastra/pg",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -17540,6 +17540,35 @@ function isMetadataField(field) {
17540
17540
  function placeholders(values, offset) {
17541
17541
  return values.map((_, index) => `$${offset + index}`).join(", ");
17542
17542
  }
17543
+ /**
17544
+ * Unicode letters, marks, and digits as PostgreSQL bracket ranges, so `[^<ranges>]` splits words
17545
+ * like the planner's `[^\p{L}\p{M}\p{N}]`. PostgreSQL regexes have no `\p{…}` classes, and
17546
+ * `[[:alnum:]]` depends on the locale: it leaves out digits such as `² ½ ₂ ①`, and glibc files
17547
+ * some marks, such as the Devanagari virama, under punct. Derived once from the runtime's own
17548
+ * Unicode tables. A run may also absorb unassigned code points, which are never stored.
17549
+ * Private-use code points are not absorbed: the other stores treat them as separators.
17550
+ */
17551
+ let pgWordRanges;
17552
+ function getPgWordRanges() {
17553
+ if (pgWordRanges !== void 0) return pgWordRanges;
17554
+ const escape = (cp) => cp > 65535 ? `\\U${cp.toString(16).padStart(8, "0")}` : `\\u${cp.toString(16).padStart(4, "0")}`;
17555
+ const chunks = [];
17556
+ for (let start = 0; start <= 1114111; start += 8192) {
17557
+ const codePoints = [];
17558
+ for (let cp = start; cp < start + 8192 && cp <= 1114111; cp++) if (cp < 55296 || cp > 57343) codePoints.push(cp);
17559
+ chunks.push(String.fromCodePoint(...codePoints));
17560
+ }
17561
+ const text = chunks.join("");
17562
+ const ranges = [];
17563
+ for (const match of text.matchAll(/[\p{L}\p{M}\p{N}\p{Cn}]+/gu)) {
17564
+ const first = match[0].codePointAt(0);
17565
+ const lastUnit = match.index + match[0].length - 1;
17566
+ const last = text.codePointAt(text.charCodeAt(lastUnit) >= 56320 && text.charCodeAt(lastUnit) <= 57343 ? lastUnit - 1 : lastUnit);
17567
+ ranges.push(first === last ? escape(first) : `${escape(first)}-${escape(last)}`);
17568
+ }
17569
+ pgWordRanges = ranges.join("");
17570
+ return pgWordRanges;
17571
+ }
17543
17572
  function compileScalarPredicate(predicate, registry, parameterOffset, allowMetadata = false) {
17544
17573
  if (predicate.type === "boolean") {
17545
17574
  const values = [];
@@ -17583,6 +17612,13 @@ function compileScalarPredicate(predicate, registry, parameterOffset, allowMetad
17583
17612
  values: fieldValues
17584
17613
  };
17585
17614
  }
17615
+ if (predicate.type === "text") {
17616
+ const found = `strpos(${`' ' || replace(lower(regexp_replace(normalize(${field}), '[^${getPgWordRanges()}]+', ' ', 'g')), 'ς', 'σ') || ' '`}, $${parameterOffset}) > 0`;
17617
+ return {
17618
+ sql: `COALESCE(${predicate.operator === "matches" ? found : `NOT (${found})`}, false)`,
17619
+ values: [...fieldValues, ` ${predicate.value} `]
17620
+ };
17621
+ }
17586
17622
  if (predicate.type === "membership") {
17587
17623
  const list = placeholders(predicate.values, parameterOffset);
17588
17624
  if (predicate.operator === "in") return {