@mastra/pg 0.3.1-alpha.4 → 0.3.1-alpha.6

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.
@@ -1,23 +1,23 @@
1
1
 
2
- > @mastra/pg@0.3.1-alpha.4 build /home/runner/work/mastra/mastra/stores/pg
2
+ > @mastra/pg@0.3.1-alpha.6 build /home/runner/work/mastra/mastra/stores/pg
3
3
  > tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
4
4
 
5
5
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.4.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 11471ms
9
+ TSC ⚡️ Build success in 10547ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.8.3
13
13
  Writing package typings: /home/runner/work/mastra/mastra/stores/pg/dist/_tsup-dts-rollup.d.ts
14
14
  Analysis will use the bundled TypeScript version 5.8.3
15
15
  Writing package typings: /home/runner/work/mastra/mastra/stores/pg/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 12539ms
16
+ DTS ⚡️ Build success in 11571ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- ESM dist/index.js 50.33 KB
21
- ESM ⚡️ Build success in 1488ms
22
- CJS dist/index.cjs 50.78 KB
23
- CJS ⚡️ Build success in 1489ms
20
+ ESM dist/index.js 54.59 KB
21
+ ESM ⚡️ Build success in 1261ms
22
+ CJS dist/index.cjs 55.07 KB
23
+ CJS ⚡️ Build success in 1261ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @mastra/pg
2
2
 
3
+ ## 0.3.1-alpha.6
4
+
5
+ ### Patch Changes
6
+
7
+ - c23a81c: added deprecation warnings for pg and individual args
8
+ - Updated dependencies [c23a81c]
9
+ - @mastra/core@0.9.1-alpha.6
10
+
11
+ ## 0.3.1-alpha.5
12
+
13
+ ### Patch Changes
14
+
15
+ - 3e7b69d: Dynamic agent props
16
+ - 5f826d9: Moved vector store specific prompts from @mastra/rag to be exported from the store that the prompt belongs to, ie @mastra/pg
17
+ - Updated dependencies [3e7b69d]
18
+ - @mastra/core@0.9.1-alpha.5
19
+
3
20
  ## 0.3.1-alpha.4
4
21
 
5
22
  ### Patch Changes
@@ -211,6 +211,10 @@ declare class PgVector extends MastraVector {
211
211
  private installVectorExtensionPromise;
212
212
  private vectorExtensionInstalled;
213
213
  private schemaSetupComplete;
214
+ /**
215
+ * @deprecated Passing connectionString as a string is deprecated.
216
+ * Use the object parameter instead. This signature will be removed on May 20th.
217
+ */
214
218
  constructor(connectionString: string);
215
219
  constructor(config: {
216
220
  connectionString: string;
@@ -249,6 +253,14 @@ declare class PgVector extends MastraVector {
249
253
  export { PgVector }
250
254
  export { PgVector as PgVector_alias_1 }
251
255
 
256
+ /**
257
+ * Vector store specific prompt that details supported operators and examples.
258
+ * This prompt helps users construct valid filters for PG Vector.
259
+ */
260
+ declare const PGVECTOR_PROMPT = "When querying PG Vector, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n- $elemMatch: Match array elements that meet all specified conditions\n Example: { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 100 } } } }\n- $contains: Check if array contains value\n Example: { \"tags\": { \"$contains\": \"premium\" } }\n\nLogical Operators:\n- $and: Logical AND (implicit when using multiple conditions)\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n- $nor: Logical NOR\n Example: { \"$nor\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nSpecial Operators:\n- $size: Array length check\n Example: { \"tags\": { \"$size\": 2 } }\n\nRestrictions:\n- Regex patterns are not supported\n- Direct RegExp patterns will throw an error\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Array operations work on array fields only\n- Basic operators handle array values as JSON strings\n- Empty arrays in conditions are handled gracefully\n- Only logical operators ($and, $or, $not, $nor) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$contains\": \"value\" }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- $not operator:\n - Must be an object\n - Cannot be empty\n - Can be used at field level or top level\n - Valid: { \"$not\": { \"field\": \"value\" } }\n - Valid: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- Other logical operators ($and, $or, $nor):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n- $elemMatch requires an object with conditions\n Valid: { \"array\": { \"$elemMatch\": { \"field\": \"value\" } } }\n Invalid: { \"array\": { \"$elemMatch\": \"value\" } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\"] } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}";
261
+ export { PGVECTOR_PROMPT }
262
+ export { PGVECTOR_PROMPT as PGVECTOR_PROMPT_alias_1 }
263
+
252
264
  declare type PostgresConfig = {
253
265
  schemaName?: string;
254
266
  /**
@@ -211,6 +211,10 @@ declare class PgVector extends MastraVector {
211
211
  private installVectorExtensionPromise;
212
212
  private vectorExtensionInstalled;
213
213
  private schemaSetupComplete;
214
+ /**
215
+ * @deprecated Passing connectionString as a string is deprecated.
216
+ * Use the object parameter instead. This signature will be removed on May 20th.
217
+ */
214
218
  constructor(connectionString: string);
215
219
  constructor(config: {
216
220
  connectionString: string;
@@ -249,6 +253,14 @@ declare class PgVector extends MastraVector {
249
253
  export { PgVector }
250
254
  export { PgVector as PgVector_alias_1 }
251
255
 
256
+ /**
257
+ * Vector store specific prompt that details supported operators and examples.
258
+ * This prompt helps users construct valid filters for PG Vector.
259
+ */
260
+ declare const PGVECTOR_PROMPT = "When querying PG Vector, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n- $elemMatch: Match array elements that meet all specified conditions\n Example: { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 100 } } } }\n- $contains: Check if array contains value\n Example: { \"tags\": { \"$contains\": \"premium\" } }\n\nLogical Operators:\n- $and: Logical AND (implicit when using multiple conditions)\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n- $nor: Logical NOR\n Example: { \"$nor\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nSpecial Operators:\n- $size: Array length check\n Example: { \"tags\": { \"$size\": 2 } }\n\nRestrictions:\n- Regex patterns are not supported\n- Direct RegExp patterns will throw an error\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Array operations work on array fields only\n- Basic operators handle array values as JSON strings\n- Empty arrays in conditions are handled gracefully\n- Only logical operators ($and, $or, $not, $nor) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$contains\": \"value\" }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- $not operator:\n - Must be an object\n - Cannot be empty\n - Can be used at field level or top level\n - Valid: { \"$not\": { \"field\": \"value\" } }\n - Valid: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- Other logical operators ($and, $or, $nor):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n- $elemMatch requires an object with conditions\n Valid: { \"array\": { \"$elemMatch\": { \"field\": \"value\" } } }\n Invalid: { \"array\": { \"$elemMatch\": \"value\" } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\"] } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}";
261
+ export { PGVECTOR_PROMPT }
262
+ export { PGVECTOR_PROMPT as PGVECTOR_PROMPT_alias_1 }
263
+
252
264
  declare type PostgresConfig = {
253
265
  schemaName?: string;
254
266
  /**
package/dist/index.cjs CHANGED
@@ -346,6 +346,14 @@ var PgVector = class extends vector.MastraVector {
346
346
  let pgPoolOptions;
347
347
  let schemaName;
348
348
  if (typeof config === "string") {
349
+ console.warn(
350
+ `DEPRECATION WARNING: Passing connectionString as a string to PgVector constructor is deprecated.
351
+
352
+ Please use an object parameter instead:
353
+ new PgVector({ connectionString })
354
+
355
+ The string signature will be removed on May 20th.`
356
+ );
349
357
  connectionString = config;
350
358
  schemaName = void 0;
351
359
  pgPoolOptions = void 0;
@@ -1544,5 +1552,105 @@ var PostgresStore = class extends storage.MastraStorage {
1544
1552
  }
1545
1553
  };
1546
1554
 
1555
+ // src/vector/prompt.ts
1556
+ var PGVECTOR_PROMPT = `When querying PG Vector, you can ONLY use the operators listed below. Any other operators will be rejected.
1557
+ Important: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.
1558
+ If a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.
1559
+
1560
+ Basic Comparison Operators:
1561
+ - $eq: Exact match (default when using field: value)
1562
+ Example: { "category": "electronics" }
1563
+ - $ne: Not equal
1564
+ Example: { "category": { "$ne": "electronics" } }
1565
+ - $gt: Greater than
1566
+ Example: { "price": { "$gt": 100 } }
1567
+ - $gte: Greater than or equal
1568
+ Example: { "price": { "$gte": 100 } }
1569
+ - $lt: Less than
1570
+ Example: { "price": { "$lt": 100 } }
1571
+ - $lte: Less than or equal
1572
+ Example: { "price": { "$lte": 100 } }
1573
+
1574
+ Array Operators:
1575
+ - $in: Match any value in array
1576
+ Example: { "category": { "$in": ["electronics", "books"] } }
1577
+ - $nin: Does not match any value in array
1578
+ Example: { "category": { "$nin": ["electronics", "books"] } }
1579
+ - $all: Match all values in array
1580
+ Example: { "tags": { "$all": ["premium", "sale"] } }
1581
+ - $elemMatch: Match array elements that meet all specified conditions
1582
+ Example: { "items": { "$elemMatch": { "price": { "$gt": 100 } } } }
1583
+ - $contains: Check if array contains value
1584
+ Example: { "tags": { "$contains": "premium" } }
1585
+
1586
+ Logical Operators:
1587
+ - $and: Logical AND (implicit when using multiple conditions)
1588
+ Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
1589
+ - $or: Logical OR
1590
+ Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
1591
+ - $not: Logical NOT
1592
+ Example: { "$not": { "category": "electronics" } }
1593
+ - $nor: Logical NOR
1594
+ Example: { "$nor": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
1595
+
1596
+ Element Operators:
1597
+ - $exists: Check if field exists
1598
+ Example: { "rating": { "$exists": true } }
1599
+
1600
+ Special Operators:
1601
+ - $size: Array length check
1602
+ Example: { "tags": { "$size": 2 } }
1603
+
1604
+ Restrictions:
1605
+ - Regex patterns are not supported
1606
+ - Direct RegExp patterns will throw an error
1607
+ - Nested fields are supported using dot notation
1608
+ - Multiple conditions on the same field are supported with both implicit and explicit $and
1609
+ - Array operations work on array fields only
1610
+ - Basic operators handle array values as JSON strings
1611
+ - Empty arrays in conditions are handled gracefully
1612
+ - Only logical operators ($and, $or, $not, $nor) can be used at the top level
1613
+ - All other operators must be used within a field condition
1614
+ Valid: { "field": { "$gt": 100 } }
1615
+ Valid: { "$and": [...] }
1616
+ Invalid: { "$gt": 100 }
1617
+ Invalid: { "$contains": "value" }
1618
+ - Logical operators must contain field conditions, not direct operators
1619
+ Valid: { "$and": [{ "field": { "$gt": 100 } }] }
1620
+ Invalid: { "$and": [{ "$gt": 100 }] }
1621
+ - $not operator:
1622
+ - Must be an object
1623
+ - Cannot be empty
1624
+ - Can be used at field level or top level
1625
+ - Valid: { "$not": { "field": "value" } }
1626
+ - Valid: { "field": { "$not": { "$eq": "value" } } }
1627
+ - Other logical operators ($and, $or, $nor):
1628
+ - Can only be used at top level or nested within other logical operators
1629
+ - Can not be used on a field level, or be nested inside a field
1630
+ - Can not be used inside an operator
1631
+ - Valid: { "$and": [{ "field": { "$gt": 100 } }] }
1632
+ - Valid: { "$or": [{ "$and": [{ "field": { "$gt": 100 } }] }] }
1633
+ - Invalid: { "field": { "$and": [{ "$gt": 100 }] } }
1634
+ - Invalid: { "field": { "$or": [{ "$gt": 100 }] } }
1635
+ - Invalid: { "field": { "$gt": { "$and": [{...}] } } }
1636
+ - $elemMatch requires an object with conditions
1637
+ Valid: { "array": { "$elemMatch": { "field": "value" } } }
1638
+ Invalid: { "array": { "$elemMatch": "value" } }
1639
+
1640
+ Example Complex Query:
1641
+ {
1642
+ "$and": [
1643
+ { "category": { "$in": ["electronics", "computers"] } },
1644
+ { "price": { "$gte": 100, "$lte": 1000 } },
1645
+ { "tags": { "$all": ["premium"] } },
1646
+ { "rating": { "$exists": true, "$gt": 4 } },
1647
+ { "$or": [
1648
+ { "stock": { "$gt": 0 } },
1649
+ { "preorder": true }
1650
+ ]}
1651
+ ]
1652
+ }`;
1653
+
1654
+ exports.PGVECTOR_PROMPT = PGVECTOR_PROMPT;
1547
1655
  exports.PgVector = PgVector;
1548
1656
  exports.PostgresStore = PostgresStore;
package/dist/index.d.cts CHANGED
@@ -1,3 +1,4 @@
1
+ export { PGVECTOR_PROMPT } from './_tsup-dts-rollup.cjs';
1
2
  export { PGIndexStats } from './_tsup-dts-rollup.cjs';
2
3
  export { PgVector } from './_tsup-dts-rollup.cjs';
3
4
  export { PostgresConfig } from './_tsup-dts-rollup.cjs';
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { PGVECTOR_PROMPT } from './_tsup-dts-rollup.js';
1
2
  export { PGIndexStats } from './_tsup-dts-rollup.js';
2
3
  export { PgVector } from './_tsup-dts-rollup.js';
3
4
  export { PostgresConfig } from './_tsup-dts-rollup.js';
package/dist/index.js CHANGED
@@ -338,6 +338,14 @@ var PgVector = class extends MastraVector {
338
338
  let pgPoolOptions;
339
339
  let schemaName;
340
340
  if (typeof config === "string") {
341
+ console.warn(
342
+ `DEPRECATION WARNING: Passing connectionString as a string to PgVector constructor is deprecated.
343
+
344
+ Please use an object parameter instead:
345
+ new PgVector({ connectionString })
346
+
347
+ The string signature will be removed on May 20th.`
348
+ );
341
349
  connectionString = config;
342
350
  schemaName = void 0;
343
351
  pgPoolOptions = void 0;
@@ -1536,4 +1544,103 @@ var PostgresStore = class extends MastraStorage {
1536
1544
  }
1537
1545
  };
1538
1546
 
1539
- export { PgVector, PostgresStore };
1547
+ // src/vector/prompt.ts
1548
+ var PGVECTOR_PROMPT = `When querying PG Vector, you can ONLY use the operators listed below. Any other operators will be rejected.
1549
+ Important: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.
1550
+ If a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.
1551
+
1552
+ Basic Comparison Operators:
1553
+ - $eq: Exact match (default when using field: value)
1554
+ Example: { "category": "electronics" }
1555
+ - $ne: Not equal
1556
+ Example: { "category": { "$ne": "electronics" } }
1557
+ - $gt: Greater than
1558
+ Example: { "price": { "$gt": 100 } }
1559
+ - $gte: Greater than or equal
1560
+ Example: { "price": { "$gte": 100 } }
1561
+ - $lt: Less than
1562
+ Example: { "price": { "$lt": 100 } }
1563
+ - $lte: Less than or equal
1564
+ Example: { "price": { "$lte": 100 } }
1565
+
1566
+ Array Operators:
1567
+ - $in: Match any value in array
1568
+ Example: { "category": { "$in": ["electronics", "books"] } }
1569
+ - $nin: Does not match any value in array
1570
+ Example: { "category": { "$nin": ["electronics", "books"] } }
1571
+ - $all: Match all values in array
1572
+ Example: { "tags": { "$all": ["premium", "sale"] } }
1573
+ - $elemMatch: Match array elements that meet all specified conditions
1574
+ Example: { "items": { "$elemMatch": { "price": { "$gt": 100 } } } }
1575
+ - $contains: Check if array contains value
1576
+ Example: { "tags": { "$contains": "premium" } }
1577
+
1578
+ Logical Operators:
1579
+ - $and: Logical AND (implicit when using multiple conditions)
1580
+ Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
1581
+ - $or: Logical OR
1582
+ Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
1583
+ - $not: Logical NOT
1584
+ Example: { "$not": { "category": "electronics" } }
1585
+ - $nor: Logical NOR
1586
+ Example: { "$nor": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
1587
+
1588
+ Element Operators:
1589
+ - $exists: Check if field exists
1590
+ Example: { "rating": { "$exists": true } }
1591
+
1592
+ Special Operators:
1593
+ - $size: Array length check
1594
+ Example: { "tags": { "$size": 2 } }
1595
+
1596
+ Restrictions:
1597
+ - Regex patterns are not supported
1598
+ - Direct RegExp patterns will throw an error
1599
+ - Nested fields are supported using dot notation
1600
+ - Multiple conditions on the same field are supported with both implicit and explicit $and
1601
+ - Array operations work on array fields only
1602
+ - Basic operators handle array values as JSON strings
1603
+ - Empty arrays in conditions are handled gracefully
1604
+ - Only logical operators ($and, $or, $not, $nor) can be used at the top level
1605
+ - All other operators must be used within a field condition
1606
+ Valid: { "field": { "$gt": 100 } }
1607
+ Valid: { "$and": [...] }
1608
+ Invalid: { "$gt": 100 }
1609
+ Invalid: { "$contains": "value" }
1610
+ - Logical operators must contain field conditions, not direct operators
1611
+ Valid: { "$and": [{ "field": { "$gt": 100 } }] }
1612
+ Invalid: { "$and": [{ "$gt": 100 }] }
1613
+ - $not operator:
1614
+ - Must be an object
1615
+ - Cannot be empty
1616
+ - Can be used at field level or top level
1617
+ - Valid: { "$not": { "field": "value" } }
1618
+ - Valid: { "field": { "$not": { "$eq": "value" } } }
1619
+ - Other logical operators ($and, $or, $nor):
1620
+ - Can only be used at top level or nested within other logical operators
1621
+ - Can not be used on a field level, or be nested inside a field
1622
+ - Can not be used inside an operator
1623
+ - Valid: { "$and": [{ "field": { "$gt": 100 } }] }
1624
+ - Valid: { "$or": [{ "$and": [{ "field": { "$gt": 100 } }] }] }
1625
+ - Invalid: { "field": { "$and": [{ "$gt": 100 }] } }
1626
+ - Invalid: { "field": { "$or": [{ "$gt": 100 }] } }
1627
+ - Invalid: { "field": { "$gt": { "$and": [{...}] } } }
1628
+ - $elemMatch requires an object with conditions
1629
+ Valid: { "array": { "$elemMatch": { "field": "value" } } }
1630
+ Invalid: { "array": { "$elemMatch": "value" } }
1631
+
1632
+ Example Complex Query:
1633
+ {
1634
+ "$and": [
1635
+ { "category": { "$in": ["electronics", "computers"] } },
1636
+ { "price": { "$gte": 100, "$lte": 1000 } },
1637
+ { "tags": { "$all": ["premium"] } },
1638
+ { "rating": { "$exists": true, "$gt": 4 } },
1639
+ { "$or": [
1640
+ { "stock": { "$gt": 0 } },
1641
+ { "preorder": true }
1642
+ ]}
1643
+ ]
1644
+ }`;
1645
+
1646
+ export { PGVECTOR_PROMPT, PgVector, PostgresStore };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/pg",
3
- "version": "0.3.1-alpha.4",
3
+ "version": "0.3.1-alpha.6",
4
4
  "description": "Postgres provider for Mastra - includes both vector and db storage capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -24,7 +24,7 @@
24
24
  "pg": "^8.13.3",
25
25
  "pg-promise": "^11.11.0",
26
26
  "xxhash-wasm": "^1.1.0",
27
- "@mastra/core": "^0.9.1-alpha.4"
27
+ "@mastra/core": "^0.9.1-alpha.6"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@microsoft/api-extractor": "^7.52.5",
package/src/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './vector';
2
2
  export * from './storage';
3
+ export { PGVECTOR_PROMPT } from './vector/prompt';
@@ -70,6 +70,10 @@ export class PgVector extends MastraVector {
70
70
  private vectorExtensionInstalled: boolean | undefined = undefined;
71
71
  private schemaSetupComplete: boolean | undefined = undefined;
72
72
 
73
+ /**
74
+ * @deprecated Passing connectionString as a string is deprecated.
75
+ * Use the object parameter instead. This signature will be removed on May 20th.
76
+ */
73
77
  constructor(connectionString: string);
74
78
  constructor(config: {
75
79
  connectionString: string;
@@ -90,6 +94,15 @@ export class PgVector extends MastraVector {
90
94
  let schemaName: string | undefined;
91
95
 
92
96
  if (typeof config === 'string') {
97
+ // DEPRECATION WARNING
98
+ console.warn(
99
+ `DEPRECATION WARNING: Passing connectionString as a string to PgVector constructor is deprecated.
100
+
101
+ Please use an object parameter instead:
102
+ new PgVector({ connectionString })
103
+
104
+ The string signature will be removed on May 20th.`,
105
+ );
93
106
  connectionString = config;
94
107
  schemaName = undefined;
95
108
  pgPoolOptions = undefined;
@@ -519,6 +532,7 @@ export class PgVector extends MastraVector {
519
532
  // Wait for the installation process to complete
520
533
  await this.installVectorExtensionPromise;
521
534
  }
535
+
522
536
  async listIndexes(): Promise<string[]> {
523
537
  const client = await this.pool.connect();
524
538
  try {
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Vector store specific prompt that details supported operators and examples.
3
+ * This prompt helps users construct valid filters for PG Vector.
4
+ */
5
+ export const PGVECTOR_PROMPT = `When querying PG Vector, you can ONLY use the operators listed below. Any other operators will be rejected.
6
+ Important: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.
7
+ If a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.
8
+
9
+ Basic Comparison Operators:
10
+ - $eq: Exact match (default when using field: value)
11
+ Example: { "category": "electronics" }
12
+ - $ne: Not equal
13
+ Example: { "category": { "$ne": "electronics" } }
14
+ - $gt: Greater than
15
+ Example: { "price": { "$gt": 100 } }
16
+ - $gte: Greater than or equal
17
+ Example: { "price": { "$gte": 100 } }
18
+ - $lt: Less than
19
+ Example: { "price": { "$lt": 100 } }
20
+ - $lte: Less than or equal
21
+ Example: { "price": { "$lte": 100 } }
22
+
23
+ Array Operators:
24
+ - $in: Match any value in array
25
+ Example: { "category": { "$in": ["electronics", "books"] } }
26
+ - $nin: Does not match any value in array
27
+ Example: { "category": { "$nin": ["electronics", "books"] } }
28
+ - $all: Match all values in array
29
+ Example: { "tags": { "$all": ["premium", "sale"] } }
30
+ - $elemMatch: Match array elements that meet all specified conditions
31
+ Example: { "items": { "$elemMatch": { "price": { "$gt": 100 } } } }
32
+ - $contains: Check if array contains value
33
+ Example: { "tags": { "$contains": "premium" } }
34
+
35
+ Logical Operators:
36
+ - $and: Logical AND (implicit when using multiple conditions)
37
+ Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
38
+ - $or: Logical OR
39
+ Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
40
+ - $not: Logical NOT
41
+ Example: { "$not": { "category": "electronics" } }
42
+ - $nor: Logical NOR
43
+ Example: { "$nor": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
44
+
45
+ Element Operators:
46
+ - $exists: Check if field exists
47
+ Example: { "rating": { "$exists": true } }
48
+
49
+ Special Operators:
50
+ - $size: Array length check
51
+ Example: { "tags": { "$size": 2 } }
52
+
53
+ Restrictions:
54
+ - Regex patterns are not supported
55
+ - Direct RegExp patterns will throw an error
56
+ - Nested fields are supported using dot notation
57
+ - Multiple conditions on the same field are supported with both implicit and explicit $and
58
+ - Array operations work on array fields only
59
+ - Basic operators handle array values as JSON strings
60
+ - Empty arrays in conditions are handled gracefully
61
+ - Only logical operators ($and, $or, $not, $nor) can be used at the top level
62
+ - All other operators must be used within a field condition
63
+ Valid: { "field": { "$gt": 100 } }
64
+ Valid: { "$and": [...] }
65
+ Invalid: { "$gt": 100 }
66
+ Invalid: { "$contains": "value" }
67
+ - Logical operators must contain field conditions, not direct operators
68
+ Valid: { "$and": [{ "field": { "$gt": 100 } }] }
69
+ Invalid: { "$and": [{ "$gt": 100 }] }
70
+ - $not operator:
71
+ - Must be an object
72
+ - Cannot be empty
73
+ - Can be used at field level or top level
74
+ - Valid: { "$not": { "field": "value" } }
75
+ - Valid: { "field": { "$not": { "$eq": "value" } } }
76
+ - Other logical operators ($and, $or, $nor):
77
+ - Can only be used at top level or nested within other logical operators
78
+ - Can not be used on a field level, or be nested inside a field
79
+ - Can not be used inside an operator
80
+ - Valid: { "$and": [{ "field": { "$gt": 100 } }] }
81
+ - Valid: { "$or": [{ "$and": [{ "field": { "$gt": 100 } }] }] }
82
+ - Invalid: { "field": { "$and": [{ "$gt": 100 }] } }
83
+ - Invalid: { "field": { "$or": [{ "$gt": 100 }] } }
84
+ - Invalid: { "field": { "$gt": { "$and": [{...}] } } }
85
+ - $elemMatch requires an object with conditions
86
+ Valid: { "array": { "$elemMatch": { "field": "value" } } }
87
+ Invalid: { "array": { "$elemMatch": "value" } }
88
+
89
+ Example Complex Query:
90
+ {
91
+ "$and": [
92
+ { "category": { "$in": ["electronics", "computers"] } },
93
+ { "price": { "$gte": 100, "$lte": 1000 } },
94
+ { "tags": { "$all": ["premium"] } },
95
+ { "rating": { "$exists": true, "$gt": 4 } },
96
+ { "$or": [
97
+ { "stock": { "$gt": 0 } },
98
+ { "preorder": true }
99
+ ]}
100
+ ]
101
+ }`;