@mastra/pg 0.17.3 → 0.17.4

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,23 @@
1
1
  # @mastra/pg
2
2
 
3
+ ## 0.17.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Add configuration documentation and tests for PgVector and PostgresStore, including examples for connection methods, SSL configuration, and pool options ([#8723](https://github.com/mastra-ai/mastra/pull/8723))
8
+
9
+ - Updated dependencies [[`ca85c93`](https://github.com/mastra-ai/mastra/commit/ca85c932b232e6ad820c811ec176d98e68c59b0a), [`a1d40f8`](https://github.com/mastra-ai/mastra/commit/a1d40f88d4ce42c4508774ad22e38ac582157af2), [`01c4a25`](https://github.com/mastra-ai/mastra/commit/01c4a2506c514d5e861c004d3d2fb3791c6391f3), [`cce8aad`](https://github.com/mastra-ai/mastra/commit/cce8aad878a0dd98e5647680f3765caba0b1701c)]:
10
+ - @mastra/core@0.21.1
11
+
12
+ ## 0.17.4-alpha.0
13
+
14
+ ### Patch Changes
15
+
16
+ - Add configuration documentation and tests for PgVector and PostgresStore, including examples for connection methods, SSL configuration, and pool options ([#8723](https://github.com/mastra-ai/mastra/pull/8723))
17
+
18
+ - Updated dependencies [[`ca85c93`](https://github.com/mastra-ai/mastra/commit/ca85c932b232e6ad820c811ec176d98e68c59b0a), [`a1d40f8`](https://github.com/mastra-ai/mastra/commit/a1d40f88d4ce42c4508774ad22e38ac582157af2), [`01c4a25`](https://github.com/mastra-ai/mastra/commit/01c4a2506c514d5e861c004d3d2fb3791c6391f3), [`cce8aad`](https://github.com/mastra-ai/mastra/commit/cce8aad878a0dd98e5647680f3765caba0b1701c)]:
19
+ - @mastra/core@0.21.1-alpha.0
20
+
3
21
  ## 0.17.3
4
22
 
5
23
  ### Patch Changes
package/README.md CHANGED
@@ -17,11 +17,53 @@ npm install @mastra/pg
17
17
 
18
18
  ### Vector Store
19
19
 
20
+ #### Basic Configuration
21
+
22
+ PgVector supports multiple connection methods:
23
+
24
+ **1. Connection String (Recommended)**
25
+
20
26
  ```typescript
21
27
  import { PgVector } from '@mastra/pg';
22
28
 
23
- const vectorStore = new PgVector({ connectionString: 'postgresql://user:pass@localhost:5432/db' });
29
+ const vectorStore = new PgVector({
30
+ connectionString: 'postgresql://user:pass@localhost:5432/db',
31
+ });
32
+ ```
33
+
34
+ **2. Host/Port/Database Configuration**
35
+
36
+ ```typescript
37
+ const vectorStore = new PgVector({
38
+ host: 'localhost',
39
+ port: 5432,
40
+ database: 'mydb',
41
+ user: 'postgres',
42
+ password: 'password',
43
+ });
44
+ ```
45
+
46
+ > **Note:** PgVector also supports advanced configurations like Google Cloud SQL Connector via `pg.ClientConfig`.
24
47
 
48
+ #### Advanced Options
49
+
50
+ ```typescript
51
+ const vectorStore = new PgVector({
52
+ connectionString: 'postgresql://user:pass@localhost:5432/db',
53
+ schemaName: 'custom_schema', // Use custom schema (default: public)
54
+ max: 30, // Max pool connections (default: 20)
55
+ idleTimeoutMillis: 60000, // Idle timeout (default: 30000)
56
+ pgPoolOptions: {
57
+ // Additional pg pool options
58
+ connectionTimeoutMillis: 5000,
59
+ allowExitOnIdle: true,
60
+ },
61
+ });
62
+ ```
63
+
64
+ #### Usage Example
65
+
66
+ ```typescript
25
67
  // Create a new table with vector support
26
68
  await vectorStore.createIndex({
27
69
  indexName: 'my_vectors',
@@ -97,12 +139,40 @@ const messages = await store.getMessages('thread-123');
97
139
 
98
140
  ## Configuration
99
141
 
100
- The PostgreSQL store can be initialized with either:
142
+ ### Connection Methods
143
+
144
+ Both `PgVector` and `PostgresStore` support multiple connection methods:
145
+
146
+ 1. **Connection String**
147
+
148
+ ```typescript
149
+ {
150
+ connectionString: 'postgresql://user:pass@localhost:5432/db';
151
+ }
152
+ ```
153
+
154
+ 2. **Host/Port/Database**
155
+ ```typescript
156
+ {
157
+ host: 'localhost',
158
+ port: 5432,
159
+ database: 'mydb',
160
+ user: 'postgres',
161
+ password: 'password'
162
+ }
163
+ ```
164
+
165
+ > **Advanced:** Also supports `pg.ClientConfig` for use cases like Google Cloud SQL Connector with IAM authentication.
166
+
167
+ ### Optional Configuration
101
168
 
102
- - `connectionString`: PostgreSQL connection string (for vector store)
103
- - Configuration object with host, port, database, user, and password (for storage)
169
+ - `schemaName`: Custom PostgreSQL schema (default: `public`)
170
+ - `ssl`: Enable SSL or provide custom SSL options (`true` | `false` | `ConnectionOptions`)
171
+ - `max`: Maximum pool connections (default: `20`)
172
+ - `idleTimeoutMillis`: Idle connection timeout (default: `30000`)
173
+ - `pgPoolOptions`: Additional pg pool options (PgVector only)
104
174
 
105
- Connection pool settings:
175
+ ### Default Connection Pool Settings
106
176
 
107
177
  - Maximum connections: 20
108
178
  - Idle timeout: 30 seconds
@@ -1 +1 @@
1
- {"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../src/storage/test-utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAG5D,eAAO,MAAM,WAAW,EAAE,mBAMzB,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAA6H,CAAC;AAE3J,wBAAgB,OAAO,SA4ZtB"}
1
+ {"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../src/storage/test-utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAG5D,eAAO,MAAM,WAAW,EAAE,mBAMzB,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAA6H,CAAC;AAE3J,wBAAgB,OAAO,SA8dtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/pg",
3
- "version": "0.17.3",
3
+ "version": "0.17.4",
4
4
  "description": "Postgres provider for Mastra - includes both vector and db storage capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -33,10 +33,10 @@
33
33
  "tsup": "^8.5.0",
34
34
  "typescript": "^5.8.3",
35
35
  "vitest": "^3.2.4",
36
- "@internal/storage-test-utils": "0.0.45",
37
- "@mastra/core": "0.21.0",
38
- "@internal/types-builder": "0.0.24",
39
- "@internal/lint": "0.0.49"
36
+ "@internal/lint": "0.0.50",
37
+ "@internal/storage-test-utils": "0.0.46",
38
+ "@mastra/core": "0.21.1",
39
+ "@internal/types-builder": "0.0.25"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@mastra/core": ">=0.20.1-0 <0.22.0-0"