@mastra/pg 1.13.0 → 1.13.3-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.
- package/CHANGELOG.md +20 -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,25 @@
|
|
|
1
1
|
# @mastra/pg
|
|
2
2
|
|
|
3
|
+
## 1.13.3-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Security remediation for the 2026-06-17 "easy-day-js" supply-chain incident. Patch bump to publish clean versions and move the `latest` dist-tag forward, superseding the compromised versions that declared the malicious `easy-day-js` dependency. ([#18056](https://github.com/mastra-ai/mastra/pull/18056))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`77a2351`](https://github.com/mastra-ai/mastra/commit/77a2351ee79296e360bce822cb3391f7cfd6489d)]:
|
|
10
|
+
- @mastra/core@1.43.1-alpha.0
|
|
11
|
+
|
|
12
|
+
## 1.13.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 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))
|
|
17
|
+
|
|
18
|
+
- 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))
|
|
19
|
+
|
|
20
|
+
- 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)]:
|
|
21
|
+
- @mastra/core@1.43.0
|
|
22
|
+
|
|
3
23
|
## 1.13.0
|
|
4
24
|
|
|
5
25
|
### Minor 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
|
/**
|