@mastra/pg 0.15.2-alpha.0 → 0.15.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 +18 -0
- package/dist/index.cjs +48 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +48 -15
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +2 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +4 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/test-utils.d.ts.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @mastra/pg
|
|
2
2
|
|
|
3
|
+
## 0.15.3-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add resource id to workflow run snapshots ([#7740](https://github.com/mastra-ai/mastra/pull/7740))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`547c621`](https://github.com/mastra-ai/mastra/commit/547c62104af3f7a551b3754e9cbdf0a3fbba15e4)]:
|
|
10
|
+
- @mastra/core@0.16.4-alpha.1
|
|
11
|
+
|
|
12
|
+
## 0.15.2
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- remove debug logs ([#7708](https://github.com/mastra-ai/mastra/pull/7708))
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`b4379f7`](https://github.com/mastra-ai/mastra/commit/b4379f703fd74474f253420e8c3a684f2c4b2f8e), [`2a6585f`](https://github.com/mastra-ai/mastra/commit/2a6585f7cb71f023f805d521d1c3c95fb9a3aa59), [`3d26e83`](https://github.com/mastra-ai/mastra/commit/3d26e8353a945719028f087cc6ac4b06f0ce27d2), [`dd9119b`](https://github.com/mastra-ai/mastra/commit/dd9119b175a8f389082f75c12750e51f96d65dca), [`d34aaa1`](https://github.com/mastra-ai/mastra/commit/d34aaa1da5d3c5f991740f59e2fe6d28d3e2dd91), [`56e55d1`](https://github.com/mastra-ai/mastra/commit/56e55d1e9eb63e7d9e41aa46e012aae471256812), [`ce1e580`](https://github.com/mastra-ai/mastra/commit/ce1e580f6391e94a0c6816a9c5db0a21566a262f), [`b2babfa`](https://github.com/mastra-ai/mastra/commit/b2babfa9e75b22f2759179e71d8473f6dc5421ed), [`d8c3ba5`](https://github.com/mastra-ai/mastra/commit/d8c3ba516f4173282d293f7e64769cfc8738d360), [`a566c4e`](https://github.com/mastra-ai/mastra/commit/a566c4e92d86c1671707c54359b1d33934f7cc13), [`af333aa`](https://github.com/mastra-ai/mastra/commit/af333aa30fe6d1b127024b03a64736c46eddeca2), [`3863c52`](https://github.com/mastra-ai/mastra/commit/3863c52d44b4e5779968b802d977e87adf939d8e), [`6424c7e`](https://github.com/mastra-ai/mastra/commit/6424c7ec38b6921d66212431db1e0958f441b2a7), [`db94750`](https://github.com/mastra-ai/mastra/commit/db94750a41fd29b43eb1f7ce8e97ba8b9978c91b), [`a66a371`](https://github.com/mastra-ai/mastra/commit/a66a3716b00553d7f01842be9deb34f720b10fab), [`69fc3cd`](https://github.com/mastra-ai/mastra/commit/69fc3cd0fd814901785bdcf49bf536ab1e7fd975)]:
|
|
19
|
+
- @mastra/core@0.16.3
|
|
20
|
+
|
|
3
21
|
## 0.15.2-alpha.0
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -2808,16 +2808,17 @@ var WorkflowsPG = class extends storage.WorkflowsStorage {
|
|
|
2808
2808
|
async persistWorkflowSnapshot({
|
|
2809
2809
|
workflowName,
|
|
2810
2810
|
runId,
|
|
2811
|
+
resourceId,
|
|
2811
2812
|
snapshot
|
|
2812
2813
|
}) {
|
|
2813
2814
|
try {
|
|
2814
2815
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
2815
2816
|
await this.client.none(
|
|
2816
|
-
`INSERT INTO ${getTableName({ indexName: storage.TABLE_WORKFLOW_SNAPSHOT, schemaName: this.schema })} (workflow_name, run_id, snapshot, "createdAt", "updatedAt")
|
|
2817
|
-
VALUES ($1, $2, $3, $4, $5)
|
|
2817
|
+
`INSERT INTO ${getTableName({ indexName: storage.TABLE_WORKFLOW_SNAPSHOT, schemaName: this.schema })} (workflow_name, run_id, "resourceId", snapshot, "createdAt", "updatedAt")
|
|
2818
|
+
VALUES ($1, $2, $3, $4, $5, $6)
|
|
2818
2819
|
ON CONFLICT (workflow_name, run_id) DO UPDATE
|
|
2819
|
-
SET
|
|
2820
|
-
[workflowName, runId, JSON.stringify(snapshot), now, now]
|
|
2820
|
+
SET "resourceId" = $3, snapshot = $4, "updatedAt" = $6`,
|
|
2821
|
+
[workflowName, runId, resourceId, JSON.stringify(snapshot), now, now]
|
|
2821
2822
|
);
|
|
2822
2823
|
} catch (error$1) {
|
|
2823
2824
|
throw new error.MastraError(
|
|
@@ -2979,37 +2980,68 @@ var PostgresStore = class extends storage.MastraStorage {
|
|
|
2979
2980
|
isConnected = false;
|
|
2980
2981
|
stores;
|
|
2981
2982
|
constructor(config) {
|
|
2983
|
+
const isConnectionStringConfig = (cfg) => {
|
|
2984
|
+
return "connectionString" in cfg;
|
|
2985
|
+
};
|
|
2986
|
+
const isHostConfig = (cfg) => {
|
|
2987
|
+
return "host" in cfg && "database" in cfg && "user" in cfg && "password" in cfg;
|
|
2988
|
+
};
|
|
2989
|
+
const isCloudSqlConfig = (cfg) => {
|
|
2990
|
+
return "stream" in cfg || "password" in cfg && typeof cfg.password === "function";
|
|
2991
|
+
};
|
|
2982
2992
|
try {
|
|
2983
|
-
if (
|
|
2993
|
+
if (isConnectionStringConfig(config)) {
|
|
2984
2994
|
if (!config.connectionString || typeof config.connectionString !== "string" || config.connectionString.trim() === "") {
|
|
2985
2995
|
throw new Error(
|
|
2986
2996
|
"PostgresStore: connectionString must be provided and cannot be empty. Passing an empty string may cause fallback to local Postgres defaults."
|
|
2987
2997
|
);
|
|
2988
2998
|
}
|
|
2989
|
-
} else {
|
|
2999
|
+
} else if (isCloudSqlConfig(config)) ; else if (isHostConfig(config)) {
|
|
2990
3000
|
const required = ["host", "database", "user", "password"];
|
|
2991
3001
|
for (const key of required) {
|
|
2992
|
-
if (!
|
|
3002
|
+
if (!config[key] || typeof config[key] !== "string" || config[key].trim() === "") {
|
|
2993
3003
|
throw new Error(
|
|
2994
3004
|
`PostgresStore: ${key} must be provided and cannot be empty. Passing an empty string may cause fallback to local Postgres defaults.`
|
|
2995
3005
|
);
|
|
2996
3006
|
}
|
|
2997
3007
|
}
|
|
3008
|
+
} else {
|
|
3009
|
+
throw new Error(
|
|
3010
|
+
"PostgresStore: invalid config. Provide either {connectionString}, {host,port,database,user,password}, or a pg ClientConfig (e.g., Cloud SQL connector with `stream`)."
|
|
3011
|
+
);
|
|
2998
3012
|
}
|
|
2999
3013
|
super({ name: "PostgresStore" });
|
|
3000
3014
|
this.schema = config.schemaName || "public";
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3015
|
+
if (isConnectionStringConfig(config)) {
|
|
3016
|
+
this.#config = {
|
|
3017
|
+
connectionString: config.connectionString,
|
|
3018
|
+
max: config.max,
|
|
3019
|
+
idleTimeoutMillis: config.idleTimeoutMillis
|
|
3020
|
+
};
|
|
3021
|
+
} else if (isCloudSqlConfig(config)) {
|
|
3022
|
+
this.#config = {
|
|
3023
|
+
...config,
|
|
3024
|
+
max: config.max,
|
|
3025
|
+
idleTimeoutMillis: config.idleTimeoutMillis
|
|
3026
|
+
};
|
|
3027
|
+
} else if (isHostConfig(config)) {
|
|
3028
|
+
this.#config = {
|
|
3005
3029
|
host: config.host,
|
|
3006
3030
|
port: config.port,
|
|
3007
3031
|
database: config.database,
|
|
3008
3032
|
user: config.user,
|
|
3009
3033
|
password: config.password,
|
|
3010
|
-
ssl: config.ssl
|
|
3011
|
-
|
|
3012
|
-
|
|
3034
|
+
ssl: config.ssl,
|
|
3035
|
+
max: config.max,
|
|
3036
|
+
idleTimeoutMillis: config.idleTimeoutMillis
|
|
3037
|
+
};
|
|
3038
|
+
} else {
|
|
3039
|
+
this.#config = {
|
|
3040
|
+
...config,
|
|
3041
|
+
max: config.max,
|
|
3042
|
+
idleTimeoutMillis: config.idleTimeoutMillis
|
|
3043
|
+
};
|
|
3044
|
+
}
|
|
3013
3045
|
this.stores = {};
|
|
3014
3046
|
} catch (e) {
|
|
3015
3047
|
throw new error.MastraError(
|
|
@@ -3211,9 +3243,10 @@ var PostgresStore = class extends storage.MastraStorage {
|
|
|
3211
3243
|
async persistWorkflowSnapshot({
|
|
3212
3244
|
workflowName,
|
|
3213
3245
|
runId,
|
|
3246
|
+
resourceId,
|
|
3214
3247
|
snapshot
|
|
3215
3248
|
}) {
|
|
3216
|
-
return this.stores.workflows.persistWorkflowSnapshot({ workflowName, runId, snapshot });
|
|
3249
|
+
return this.stores.workflows.persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot });
|
|
3217
3250
|
}
|
|
3218
3251
|
async loadWorkflowSnapshot({
|
|
3219
3252
|
workflowName,
|