@mastra/pg 1.13.0-alpha.1 → 1.13.2
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 +95 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +170 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +170 -4
- package/dist/index.js.map +1 -1
- package/dist/storage/client.d.ts +58 -0
- package/dist/storage/client.d.ts.map +1 -1
- package/dist/storage/domains/skills/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +16 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,100 @@
|
|
|
1
1
|
# @mastra/pg
|
|
2
2
|
|
|
3
|
+
## 1.13.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix `PostgresStore` startup failing with `canceling statement due to statement timeout` when running behind a transaction pooler such as Supabase or PgBouncer. Initialization now reuses a single pooled connection for the duration of startup, so storage initializes reliably with observability enabled. Runtime queries are unaffected. Fixes #17679. ([#17833](https://github.com/mastra-ai/mastra/pull/17833))
|
|
8
|
+
|
|
9
|
+
- Fixed skill updates creating duplicate versions when a snapshot had not meaningfully changed. Comparison previously relied on `JSON.stringify`, so reordered object keys (common with PostgreSQL JSONB) or optional fields round-tripping between `undefined` and `null` looked like changes. Skill snapshots are now compared by value, so repeated no-op publish/update cycles no longer increment the version number. ([#16811](https://github.com/mastra-ai/mastra/pull/16811))
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`de66bb0`](https://github.com/mastra-ai/mastra/commit/de66bb040570444c702ce4d8e1e228a5de2949cb), [`67bf8e2`](https://github.com/mastra-ai/mastra/commit/67bf8e206dfe583954d96015cf0d09f7ac50e45f), [`8216d05`](https://github.com/mastra-ai/mastra/commit/8216d0528d866eb9a07f5d4c87ea3bb1e1139b45), [`d18b23c`](https://github.com/mastra-ai/mastra/commit/d18b23c5e29dfc381e73e3c51fcf6c779afd1823), [`5eb94eb`](https://github.com/mastra-ai/mastra/commit/5eb94ebcf66d4e28c9e26d5821ac93379bab20a0), [`1fa3e12`](https://github.com/mastra-ai/mastra/commit/1fa3e123582b63cfe49de4ee52dc6a065e8d956a), [`f9ee2ac`](https://github.com/mastra-ai/mastra/commit/f9ee2ac661af584e61bc063ac208c9035cd752ef), [`c853d53`](https://github.com/mastra-ai/mastra/commit/c853d535d2df84ab89db1adb4c28900c54c9a2d2), [`d8df1f8`](https://github.com/mastra-ai/mastra/commit/d8df1f8e947e1966c9d4e54713df56d0d0d65226), [`9192ddb`](https://github.com/mastra-ai/mastra/commit/9192ddbced8949113b30de444cbe763f075b59f5), [`ae96523`](https://github.com/mastra-ai/mastra/commit/ae965231f562d9766b0c90c49a69fc68acaa031c), [`17d5a92`](https://github.com/mastra-ai/mastra/commit/17d5a9211aa293b4d4418de3de70dc0394d58101), [`5573693`](https://github.com/mastra-ai/mastra/commit/5573693b589822250e20dfe6cf66e9ff3bc96da8), [`ec4da8a`](https://github.com/mastra-ai/mastra/commit/ec4da8a09e0d2ab452c6ee2c786042ea826b77e5), [`adc44e1`](https://github.com/mastra-ai/mastra/commit/adc44e13c7e570b91e86b20ea7556e61d819db31), [`ed346c0`](https://github.com/mastra-ai/mastra/commit/ed346c0bee2d8496690a4e538bfba1e46894660f), [`c9ce1b2`](https://github.com/mastra-ai/mastra/commit/c9ce1b28d10871110648f9d7b6d76e880b9fa999), [`3ef01fd`](https://github.com/mastra-ai/mastra/commit/3ef01fd130b53d5bd4f828beb174e516a2eb1158), [`245a9a3`](https://github.com/mastra-ai/mastra/commit/245a9a315705fce17ddd980f78a92504b6615c4a), [`dc0b611`](https://github.com/mastra-ai/mastra/commit/dc0b6119b769bd00ee2c5df9259fb376fe63077a), [`38b5de8`](https://github.com/mastra-ai/mastra/commit/38b5de8e5d1d41a69522addf53d96f4b3a1d5bf0), [`dc0b611`](https://github.com/mastra-ai/mastra/commit/dc0b6119b769bd00ee2c5df9259fb376fe63077a), [`dd6a66e`](https://github.com/mastra-ai/mastra/commit/dd6a66ea0b32e0dea8059aec6b35d151e2c87dc4), [`d785c59`](https://github.com/mastra-ai/mastra/commit/d785c593b67fcb4cdc4fab9fdbde5f3b7665efc0), [`1fa3e12`](https://github.com/mastra-ai/mastra/commit/1fa3e123582b63cfe49de4ee52dc6a065e8d956a), [`8b984f4`](https://github.com/mastra-ai/mastra/commit/8b984f4361c202270ceb69257185c4756c9a7c56), [`bf08402`](https://github.com/mastra-ai/mastra/commit/bf084022374fa5d06ca70ed67a86dd64e379071b), [`81fe587`](https://github.com/mastra-ai/mastra/commit/81fe587275035715c1720ddf3fee0505cf053036), [`1fa3e12`](https://github.com/mastra-ai/mastra/commit/1fa3e123582b63cfe49de4ee52dc6a065e8d956a), [`403c438`](https://github.com/mastra-ai/mastra/commit/403c438e417278989ce247233d2c465b8d902cdd), [`f8ba195`](https://github.com/mastra-ai/mastra/commit/f8ba1954e27ee2b20586cc6cd9cf13c002c232f2)]:
|
|
12
|
+
- @mastra/core@1.43.0
|
|
13
|
+
|
|
14
|
+
## 1.13.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- Add the v-next observability storage domain for `@mastra/pg`, an insert-only, ([#16760](https://github.com/mastra-ai/mastra/pull/16760))
|
|
19
|
+
partitioned Postgres adapter for low-volume observability (~100 calls/sec,
|
|
20
|
+
up to roughly 1,500 calls/sec sustained on a single primary).
|
|
21
|
+
|
|
22
|
+
The new `PostgresStoreVNext` composes a primary `PostgresStore` (memory,
|
|
23
|
+
workflows, scores, agents, etc.) with an `ObservabilityStoragePostgresVNext`
|
|
24
|
+
for spans, logs, metrics, scores, and feedback. All observability writes go
|
|
25
|
+
through a single multi-row `INSERT ... ON CONFLICT DO NOTHING` path. Storage
|
|
26
|
+
is partitioned per day with three modes auto-detected at `init()` time:
|
|
27
|
+
TimescaleDB hypertables, pg_partman (4.x or 5.x), or native Postgres range
|
|
28
|
+
partitions. Root-span lookups are served by partial indexes, and OLAP queries
|
|
29
|
+
(aggregates, breakdowns, time-series, percentiles) prune partitions by
|
|
30
|
+
`timestamp`. A small discovery cache table powers stale-while-revalidate
|
|
31
|
+
lookups for entity names/types/labels.
|
|
32
|
+
|
|
33
|
+
The `observability` connection is **required** — callers always make an
|
|
34
|
+
explicit decision about where observability data lives. For production,
|
|
35
|
+
point it at a dedicated Postgres instance to keep OLAP scans from
|
|
36
|
+
contending with your primary OLTP workload. Reusing the primary
|
|
37
|
+
connection works for local development and logs a runtime warning on every
|
|
38
|
+
construction.
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { Mastra } from '@mastra/core';
|
|
42
|
+
import { PostgresStoreVNext } from '@mastra/pg';
|
|
43
|
+
|
|
44
|
+
export const mastra = new Mastra({
|
|
45
|
+
storage: new PostgresStoreVNext({
|
|
46
|
+
id: 'app',
|
|
47
|
+
connectionString: process.env.DATABASE_URL!,
|
|
48
|
+
observability: {
|
|
49
|
+
connectionString: process.env.OBSERVABILITY_DATABASE_URL!,
|
|
50
|
+
},
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Delta polling uses Postgres transaction IDs and a safe transaction horizon so
|
|
56
|
+
concurrent writers cannot cause late-committing rows to be skipped. The
|
|
57
|
+
`observability-delta-polling` feature flag is opt-in.
|
|
58
|
+
|
|
59
|
+
`ensureNativePartitions()` swallows the `42P07 relation already exists`
|
|
60
|
+
error around `CREATE TABLE IF NOT EXISTS … PARTITION OF`, matching the
|
|
61
|
+
existing guard used for base-table and index DDL. This makes concurrent
|
|
62
|
+
`init()` from two processes (serverless cold-start, blue/green overlap, two
|
|
63
|
+
stores sharing a schema) idempotent instead of letting the loser surface an
|
|
64
|
+
unhandled duplicate-relation error.
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- dependencies updates: ([#17148](https://github.com/mastra-ai/mastra/pull/17148))
|
|
69
|
+
- Updated dependency [`pg@^8.21.0` ↗︎](https://www.npmjs.com/package/pg/v/8.21.0) (from `^8.20.0`, in `dependencies`)
|
|
70
|
+
|
|
71
|
+
- Added full Agent Builder storage support to the PostgreSQL adapter, bringing it to parity with libSQL. ([#17596](https://github.com/mastra-ai/mastra/pull/17596))
|
|
72
|
+
|
|
73
|
+
Previously, projects using PostgreSQL could not store tool provider connections or agent tool providers, and several Agent Builder tables were missing from the exported schema.
|
|
74
|
+
- Added storage for tool provider connections, so connections can be created, read, listed by author, and deleted on PostgreSQL.
|
|
75
|
+
- Agent versions now persist their tool providers on PostgreSQL across save and load.
|
|
76
|
+
- Fixed schema export so all Agent Builder tables are included.
|
|
77
|
+
|
|
78
|
+
- Fixed `PgVector` ignoring an explicit `ssl` option when the connection string also contained an `sslmode=` (or `ssl=`) query parameter. `node-postgres` re-parses the connection string and overwrote the explicit `ssl` object, causing `UNABLE_TO_GET_ISSUER_CERT_LOCALLY` / "self-signed certificate" errors against self-signed or internal CAs even when verification was meant to be skipped. ([#17650](https://github.com/mastra-ai/mastra/pull/17650))
|
|
79
|
+
|
|
80
|
+
`PgVector` now honors an explicit `ssl` option over the connection string, matching the existing `PostgresStore` behavior. Connection-string-only SSL (`?sslmode=require` with no explicit `ssl`) keeps working as before.
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { PgVector } from '@mastra/pg';
|
|
84
|
+
|
|
85
|
+
// This now connects instead of throwing UNABLE_TO_GET_ISSUER_CERT_LOCALLY
|
|
86
|
+
const vector = new PgVector({
|
|
87
|
+
id: 'my-vector',
|
|
88
|
+
connectionString: 'postgresql://user:pass@host:5432/db?sslmode=require',
|
|
89
|
+
ssl: { rejectUnauthorized: false },
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- Make atomic db updates better ([#16796](https://github.com/mastra-ai/mastra/pull/16796))
|
|
94
|
+
|
|
95
|
+
- Updated dependencies [[`d468acb`](https://github.com/mastra-ai/mastra/commit/d468acb07aec1bb19a2cb0ada8042b05b46746b2), [`575f815`](https://github.com/mastra-ai/mastra/commit/575f815c5c3567b71c0b83cbb7fa98c8253a9d9c), [`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`053735a`](https://github.com/mastra-ai/mastra/commit/053735a75c2c18e23ce34d9468007efa4a45f4c4), [`306909a`](https://github.com/mastra-ai/mastra/commit/306909a693de77d709b38706e2673c9547d24a28), [`5191af8`](https://github.com/mastra-ai/mastra/commit/5191af80c799eea25357c545fc05d91b3883531d), [`43bd3d4`](https://github.com/mastra-ai/mastra/commit/43bd3d421987463fdf35386a45199c49499ed069), [`e6fa79e`](https://github.com/mastra-ai/mastra/commit/e6fa79ec72a2ddffdd25e85270398951e9d552a4), [`904bcdf`](https://github.com/mastra-ai/mastra/commit/904bcdf7b8004aa7be823f9f70ca63580e47e470), [`7f5ee1d`](https://github.com/mastra-ai/mastra/commit/7f5ee1dca46daee8d2817f2ebe49e6335da81956), [`1e9aab5`](https://github.com/mastra-ai/mastra/commit/1e9aab50ff11e6e88fde4d7cbf512c44a9fe8d61), [`2bccba4`](https://github.com/mastra-ai/mastra/commit/2bccba4c03cadc815c2d54cbf4dd43a922140a8d), [`bf8eb6d`](https://github.com/mastra-ai/mastra/commit/bf8eb6d0ec213a403eb9265a594ad283c44ab3dc), [`e9be4e7`](https://github.com/mastra-ai/mastra/commit/e9be4e747ec3d8b65548bff92f9377db06105376), [`493a328`](https://github.com/mastra-ai/mastra/commit/493a328f4346a1deeb9f1e2e44c8f2a3a4d7591b), [`d53cfc2`](https://github.com/mastra-ai/mastra/commit/d53cfc2c7f8d78343a4aa84ec4e129ba25f3325e), [`65799d4`](https://github.com/mastra-ai/mastra/commit/65799d4d549e5ebb9c848fbe3f51ac090f64becf), [`c268c89`](https://github.com/mastra-ai/mastra/commit/c268c89f4c63a93ee474d3cffdf3ea60bf00d4f2), [`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`014e00f`](https://github.com/mastra-ai/mastra/commit/014e00f2b3a597a016b72f9901c6ab27d491f822), [`029a414`](https://github.com/mastra-ai/mastra/commit/029a4141719793bd3e898a39eb5a0466a55f5f3a), [`d468acb`](https://github.com/mastra-ai/mastra/commit/d468acb07aec1bb19a2cb0ada8042b05b46746b2), [`b147b29`](https://github.com/mastra-ai/mastra/commit/b147b2907f0cd1aa812efe6d6e3f58d22e66fc88), [`d371ac1`](https://github.com/mastra-ai/mastra/commit/d371ac1d9820afaaf7cfdbc380a475946a994d8f), [`2bccba4`](https://github.com/mastra-ai/mastra/commit/2bccba4c03cadc815c2d54cbf4dd43a922140a8d), [`0c72f03`](https://github.com/mastra-ai/mastra/commit/0c72f032abb13254df5a7856d64be2f207b8006d), [`cf182b7`](https://github.com/mastra-ai/mastra/commit/cf182b7fb495767946d9840ef29f19cfa906f31f), [`3b45ea9`](https://github.com/mastra-ai/mastra/commit/3b45ea95015557a6cb9d70dc5252af54ab1b78ac), [`a049c2a`](https://github.com/mastra-ai/mastra/commit/a049c2a9dfb41d0ee2e7a28874a88cd64fd5669f), [`f084be1`](https://github.com/mastra-ai/mastra/commit/f084be1fcbe33ad7480913e44d6130c421c0976f), [`b147b29`](https://github.com/mastra-ai/mastra/commit/b147b2907f0cd1aa812efe6d6e3f58d22e66fc88), [`2a96528`](https://github.com/mastra-ai/mastra/commit/2a9652848dfa3c5a2426f952e9d93554c26fd90f), [`f2ab060`](https://github.com/mastra-ai/mastra/commit/f2ab060162bea81505fda553e2cee29c1979fd04), [`5d302c8`](https://github.com/mastra-ai/mastra/commit/5d302c8eda1a6ac74eab5e442c4f64db6cc97a06), [`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`a952852`](https://github.com/mastra-ai/mastra/commit/a952852c971a21fb646cd907c75fcf4443cdc963), [`2656d9c`](https://github.com/mastra-ai/mastra/commit/2656d9c2976d4f3354253bfbbbf9b88a1b2bbf34), [`63e3fe1`](https://github.com/mastra-ai/mastra/commit/63e3fe13cc1ea96f91d7c68aea92f400faf9e4da), [`1d4ce8d`](https://github.com/mastra-ai/mastra/commit/1d4ce8daaa54511f325c1b609d31b8e54009d677), [`8c68372`](https://github.com/mastra-ai/mastra/commit/8c68372e85fe0b066ec12c58bd29ffb93e54c552)]:
|
|
96
|
+
- @mastra/core@1.42.0
|
|
97
|
+
|
|
3
98
|
## 1.13.0-alpha.1
|
|
4
99
|
|
|
5
100
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -15,6 +15,7 @@ var module$1 = require('module');
|
|
|
15
15
|
var agent = require('@mastra/core/agent');
|
|
16
16
|
var features = require('@mastra/core/features');
|
|
17
17
|
var evals = require('@mastra/core/evals');
|
|
18
|
+
var skills = require('@mastra/core/storage/domains/skills');
|
|
18
19
|
|
|
19
20
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
20
21
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -2164,6 +2165,161 @@ var TransactionClient = class {
|
|
|
2164
2165
|
return Promise.all(promises);
|
|
2165
2166
|
}
|
|
2166
2167
|
};
|
|
2168
|
+
var PinnedClientAdapter = class {
|
|
2169
|
+
constructor($pool, pinnedClient) {
|
|
2170
|
+
this.$pool = $pool;
|
|
2171
|
+
this.pinnedClient = pinnedClient;
|
|
2172
|
+
}
|
|
2173
|
+
$pool;
|
|
2174
|
+
pinnedClient;
|
|
2175
|
+
/**
|
|
2176
|
+
* Serialization tail. Domain init() methods fire via Promise.all in
|
|
2177
|
+
* MastraCompositeStore.#runInit(), so without our own gate every domain's
|
|
2178
|
+
* query() lands on the same PoolClient concurrently. pg@8 queues those
|
|
2179
|
+
* internally and emits a deprecation warning; pg@9 will throw. Chaining
|
|
2180
|
+
* each new query off the previous one's settlement (success or failure)
|
|
2181
|
+
* gives us deterministic FIFO ordering at the adapter layer and removes
|
|
2182
|
+
* the reliance on pg's internal queue.
|
|
2183
|
+
*/
|
|
2184
|
+
#tail = Promise.resolve();
|
|
2185
|
+
/**
|
|
2186
|
+
* Run `fn` after any previously enqueued work on this pinned client has
|
|
2187
|
+
* settled. Failures in earlier calls don't poison the queue — we always
|
|
2188
|
+
* resume on the next caller's turn.
|
|
2189
|
+
*/
|
|
2190
|
+
#enqueue(fn) {
|
|
2191
|
+
const next = this.#tail.then(fn, fn);
|
|
2192
|
+
this.#tail = next.catch(() => void 0);
|
|
2193
|
+
return next;
|
|
2194
|
+
}
|
|
2195
|
+
connect() {
|
|
2196
|
+
throw new Error(
|
|
2197
|
+
"PinnedClientAdapter.connect() is not supported during PostgresStore.init(). All DDL must flow through the pinned client."
|
|
2198
|
+
);
|
|
2199
|
+
}
|
|
2200
|
+
none(query, values) {
|
|
2201
|
+
return this.#enqueue(async () => {
|
|
2202
|
+
await this.pinnedClient.query(query, values);
|
|
2203
|
+
return null;
|
|
2204
|
+
});
|
|
2205
|
+
}
|
|
2206
|
+
one(query, values) {
|
|
2207
|
+
return this.#enqueue(async () => {
|
|
2208
|
+
const result = await this.pinnedClient.query(query, values);
|
|
2209
|
+
if (result.rows.length === 0) {
|
|
2210
|
+
throw new Error(`No data returned from query: ${truncateQuery(query)}`);
|
|
2211
|
+
}
|
|
2212
|
+
if (result.rows.length > 1) {
|
|
2213
|
+
throw new Error(`Multiple rows returned when one was expected: ${truncateQuery(query)}`);
|
|
2214
|
+
}
|
|
2215
|
+
return result.rows[0];
|
|
2216
|
+
});
|
|
2217
|
+
}
|
|
2218
|
+
oneOrNone(query, values) {
|
|
2219
|
+
return this.#enqueue(async () => {
|
|
2220
|
+
const result = await this.pinnedClient.query(query, values);
|
|
2221
|
+
if (result.rows.length === 0) {
|
|
2222
|
+
return null;
|
|
2223
|
+
}
|
|
2224
|
+
if (result.rows.length > 1) {
|
|
2225
|
+
throw new Error(`Multiple rows returned when one or none was expected: ${truncateQuery(query)}`);
|
|
2226
|
+
}
|
|
2227
|
+
return result.rows[0];
|
|
2228
|
+
});
|
|
2229
|
+
}
|
|
2230
|
+
any(query, values) {
|
|
2231
|
+
return this.#enqueue(async () => {
|
|
2232
|
+
const result = await this.pinnedClient.query(query, values);
|
|
2233
|
+
return result.rows;
|
|
2234
|
+
});
|
|
2235
|
+
}
|
|
2236
|
+
manyOrNone(query, values) {
|
|
2237
|
+
return this.any(query, values);
|
|
2238
|
+
}
|
|
2239
|
+
many(query, values) {
|
|
2240
|
+
return this.#enqueue(async () => {
|
|
2241
|
+
const result = await this.pinnedClient.query(query, values);
|
|
2242
|
+
if (result.rows.length === 0) {
|
|
2243
|
+
throw new Error(`No data returned from query: ${truncateQuery(query)}`);
|
|
2244
|
+
}
|
|
2245
|
+
return result.rows;
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2248
|
+
query(query, values) {
|
|
2249
|
+
return this.#enqueue(() => this.pinnedClient.query(query, values));
|
|
2250
|
+
}
|
|
2251
|
+
tx(callback) {
|
|
2252
|
+
return this.#enqueue(async () => {
|
|
2253
|
+
await this.pinnedClient.query("BEGIN");
|
|
2254
|
+
try {
|
|
2255
|
+
const result = await callback(new TransactionClient(this.pinnedClient));
|
|
2256
|
+
await this.pinnedClient.query("COMMIT");
|
|
2257
|
+
return result;
|
|
2258
|
+
} catch (error) {
|
|
2259
|
+
try {
|
|
2260
|
+
await this.pinnedClient.query("ROLLBACK");
|
|
2261
|
+
} catch (rollbackError) {
|
|
2262
|
+
console.error("Transaction rollback failed:", rollbackError);
|
|
2263
|
+
}
|
|
2264
|
+
throw error;
|
|
2265
|
+
}
|
|
2266
|
+
});
|
|
2267
|
+
}
|
|
2268
|
+
};
|
|
2269
|
+
var RoutingDbClient = class {
|
|
2270
|
+
#base;
|
|
2271
|
+
#pinned = null;
|
|
2272
|
+
constructor(base) {
|
|
2273
|
+
this.#base = base;
|
|
2274
|
+
}
|
|
2275
|
+
/** Returns the currently active client (pinned if set, otherwise base). */
|
|
2276
|
+
get active() {
|
|
2277
|
+
return this.#pinned ?? this.#base;
|
|
2278
|
+
}
|
|
2279
|
+
/**
|
|
2280
|
+
* Pin a DbClient so all subsequent calls route through it until unpinned.
|
|
2281
|
+
* Throws if a client is already pinned to avoid silent overrides.
|
|
2282
|
+
*/
|
|
2283
|
+
pin(client) {
|
|
2284
|
+
if (this.#pinned) {
|
|
2285
|
+
throw new Error("RoutingDbClient already has a pinned client");
|
|
2286
|
+
}
|
|
2287
|
+
this.#pinned = client;
|
|
2288
|
+
}
|
|
2289
|
+
unpin() {
|
|
2290
|
+
this.#pinned = null;
|
|
2291
|
+
}
|
|
2292
|
+
get $pool() {
|
|
2293
|
+
return this.#base.$pool;
|
|
2294
|
+
}
|
|
2295
|
+
connect() {
|
|
2296
|
+
return this.active.connect();
|
|
2297
|
+
}
|
|
2298
|
+
none(query, values) {
|
|
2299
|
+
return this.active.none(query, values);
|
|
2300
|
+
}
|
|
2301
|
+
one(query, values) {
|
|
2302
|
+
return this.active.one(query, values);
|
|
2303
|
+
}
|
|
2304
|
+
oneOrNone(query, values) {
|
|
2305
|
+
return this.active.oneOrNone(query, values);
|
|
2306
|
+
}
|
|
2307
|
+
any(query, values) {
|
|
2308
|
+
return this.active.any(query, values);
|
|
2309
|
+
}
|
|
2310
|
+
manyOrNone(query, values) {
|
|
2311
|
+
return this.active.manyOrNone(query, values);
|
|
2312
|
+
}
|
|
2313
|
+
many(query, values) {
|
|
2314
|
+
return this.active.many(query, values);
|
|
2315
|
+
}
|
|
2316
|
+
query(query, values) {
|
|
2317
|
+
return this.active.query(query, values);
|
|
2318
|
+
}
|
|
2319
|
+
tx(callback) {
|
|
2320
|
+
return this.active.tx(callback);
|
|
2321
|
+
}
|
|
2322
|
+
};
|
|
2167
2323
|
|
|
2168
2324
|
// src/storage/db/constraint-utils.ts
|
|
2169
2325
|
var POSTGRES_IDENTIFIER_MAX_LENGTH = 63;
|
|
@@ -17062,7 +17218,10 @@ var SkillsPG = class _SkillsPG extends storage.SkillsStorage {
|
|
|
17062
17218
|
} = latestVersion;
|
|
17063
17219
|
const newConfig = { ...latestConfig, ...configFields };
|
|
17064
17220
|
const changedFields = SNAPSHOT_FIELDS5.filter(
|
|
17065
|
-
(field) => field in configFields &&
|
|
17221
|
+
(field) => field in configFields && !skills.skillSnapshotFieldValuesEqual(
|
|
17222
|
+
configFields[field],
|
|
17223
|
+
latestConfig[field]
|
|
17224
|
+
)
|
|
17066
17225
|
);
|
|
17067
17226
|
if (changedFields.length > 0) {
|
|
17068
17227
|
versionCreated = true;
|
|
@@ -19006,6 +19165,8 @@ function exportSchemas(schemaName) {
|
|
|
19006
19165
|
}
|
|
19007
19166
|
var PostgresStore = class extends storage.MastraCompositeStore {
|
|
19008
19167
|
#pool;
|
|
19168
|
+
// Narrowed to RoutingDbClient so init()'s pin/unpin path is type-checked.
|
|
19169
|
+
// The public `db` getter still exposes it as DbClient.
|
|
19009
19170
|
#db;
|
|
19010
19171
|
#ownsPool;
|
|
19011
19172
|
#poolClosed = false;
|
|
@@ -19024,7 +19185,7 @@ var PostgresStore = class extends storage.MastraCompositeStore {
|
|
|
19024
19185
|
this.#pool = this.createPool(config);
|
|
19025
19186
|
this.#ownsPool = true;
|
|
19026
19187
|
}
|
|
19027
|
-
this.#db = new PoolAdapter(this.#pool);
|
|
19188
|
+
this.#db = new RoutingDbClient(new PoolAdapter(this.#pool));
|
|
19028
19189
|
const domainConfig = {
|
|
19029
19190
|
client: this.#db,
|
|
19030
19191
|
schemaName: this.schema,
|
|
@@ -19080,11 +19241,13 @@ var PostgresStore = class extends storage.MastraCompositeStore {
|
|
|
19080
19241
|
if (this.isInitialized) {
|
|
19081
19242
|
return;
|
|
19082
19243
|
}
|
|
19244
|
+
const pinnedClient = await this.#pool.connect();
|
|
19245
|
+
const pinned = new PinnedClientAdapter(this.#pool, pinnedClient);
|
|
19083
19246
|
try {
|
|
19084
|
-
this.
|
|
19247
|
+
this.#db.pin(pinned);
|
|
19085
19248
|
await super.init();
|
|
19249
|
+
this.isInitialized = true;
|
|
19086
19250
|
} catch (error$1) {
|
|
19087
|
-
this.isInitialized = false;
|
|
19088
19251
|
if (error$1 instanceof error.MastraError) {
|
|
19089
19252
|
throw error$1;
|
|
19090
19253
|
}
|
|
@@ -19096,6 +19259,9 @@ var PostgresStore = class extends storage.MastraCompositeStore {
|
|
|
19096
19259
|
},
|
|
19097
19260
|
error$1
|
|
19098
19261
|
);
|
|
19262
|
+
} finally {
|
|
19263
|
+
this.#db.unpin();
|
|
19264
|
+
pinnedClient.release();
|
|
19099
19265
|
}
|
|
19100
19266
|
}
|
|
19101
19267
|
/**
|