@mastra/pg 1.33.0-alpha.0 → 1.33.0-alpha.1
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/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-storage-retention.md +1 -1
- package/dist/index.cjs +39 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +40 -5
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +5 -2
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/docs/SKILL.md
CHANGED
|
@@ -294,7 +294,7 @@ const storage = new MongoDBStore({
|
|
|
294
294
|
|
|
295
295
|
## Reclaiming disk
|
|
296
296
|
|
|
297
|
-
`prune()` deletes rows but doesn't shrink the database file. On SQLite/libSQL the freed pages go on a freelist
|
|
297
|
+
`prune()` deletes rows but doesn't shrink the database file. On SQLite/libSQL the freed pages go on a freelist for reuse by future writes. Reusing these pages prevents unbounded file growth for most users.
|
|
298
298
|
|
|
299
299
|
Handing that free space back to the OS is a separate concern that Mastra doesn't manage. If you specifically need to shrink the file, run the underlying database's compaction (for example `VACUUM` on self-hosted libSQL) yourself in a maintenance window. A full `VACUUM` locks the file and needs roughly twice the file size in free disk. On PostgreSQL, autovacuum reclaims dead tuples for reuse automatically. A manual `VACUUM FULL` is only needed if you must return disk to the OS.
|
|
300
300
|
|
package/dist/index.cjs
CHANGED
|
@@ -25908,7 +25908,10 @@ var WorkflowsPG = class WorkflowsPG extends _mastra_core_storage.WorkflowsStorag
|
|
|
25908
25908
|
throw this.#ownershipError("GET_RUN_OWNERSHIP", runId, error);
|
|
25909
25909
|
}
|
|
25910
25910
|
}
|
|
25911
|
-
|
|
25911
|
+
supportsWorkflowStepGuards() {
|
|
25912
|
+
return true;
|
|
25913
|
+
}
|
|
25914
|
+
async updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, state, fence: explicitFence, startGuard, completionGuard }) {
|
|
25912
25915
|
const fence = (0, _mastra_core_storage.resolveRunFence)(this, explicitFence, runId);
|
|
25913
25916
|
try {
|
|
25914
25917
|
return await this.#db.client.tx(async (t) => {
|
|
@@ -25918,16 +25921,48 @@ var WorkflowsPG = class WorkflowsPG extends _mastra_core_storage.WorkflowsStorag
|
|
|
25918
25921
|
schemaName: getSchemaName(this.#schema)
|
|
25919
25922
|
});
|
|
25920
25923
|
const existingSnapshotResult = await t.oneOrNone(`SELECT snapshot FROM ${tableName} WHERE workflow_name = $1 AND run_id = $2 FOR UPDATE`, [workflowName, runId]);
|
|
25921
|
-
if (!existingSnapshotResult)
|
|
25924
|
+
if (!existingSnapshotResult) {
|
|
25925
|
+
(0, _mastra_core_storage.assertWorkflowStepGuard)({
|
|
25926
|
+
snapshot: null,
|
|
25927
|
+
stepId,
|
|
25928
|
+
startGuard,
|
|
25929
|
+
completionGuard
|
|
25930
|
+
});
|
|
25931
|
+
return {};
|
|
25932
|
+
}
|
|
25922
25933
|
const existingSnapshot = existingSnapshotResult.snapshot;
|
|
25923
25934
|
const snapshot = typeof existingSnapshot === "string" ? JSON.parse(existingSnapshot) : existingSnapshot;
|
|
25924
|
-
(0, _mastra_core_storage.
|
|
25935
|
+
(0, _mastra_core_storage.assertWorkflowStepGuard)({
|
|
25936
|
+
snapshot,
|
|
25937
|
+
stepId,
|
|
25938
|
+
startGuard,
|
|
25939
|
+
completionGuard
|
|
25940
|
+
});
|
|
25941
|
+
if (completionGuard?.pruneOnly) snapshot.context[stepId] = {
|
|
25942
|
+
...result,
|
|
25943
|
+
metadata: {
|
|
25944
|
+
...snapshot.context[stepId]?.metadata,
|
|
25945
|
+
...result.metadata,
|
|
25946
|
+
__continuationStarted: true
|
|
25947
|
+
}
|
|
25948
|
+
};
|
|
25949
|
+
else (0, _mastra_core_storage.mergeWorkflowStepResult)({
|
|
25925
25950
|
snapshot,
|
|
25926
25951
|
stepId,
|
|
25927
25952
|
result,
|
|
25928
25953
|
requestContext,
|
|
25929
25954
|
state
|
|
25930
25955
|
});
|
|
25956
|
+
const previous = startGuard?.previousStep;
|
|
25957
|
+
const previousResult = previous && snapshot.context[previous.stepId];
|
|
25958
|
+
if (previous && previous.stepId !== stepId && previousResult?.status === "success" && previousResult.metadata?.startedBy === previous.eventId) snapshot.context[previous.stepId] = {
|
|
25959
|
+
...previous.result,
|
|
25960
|
+
metadata: {
|
|
25961
|
+
...previousResult.metadata,
|
|
25962
|
+
...previous.result.metadata,
|
|
25963
|
+
__continuationStarted: true
|
|
25964
|
+
}
|
|
25965
|
+
};
|
|
25931
25966
|
const now = /* @__PURE__ */ new Date();
|
|
25932
25967
|
const sanitizedSnapshot = toPgJson(snapshot);
|
|
25933
25968
|
await t.none(`INSERT INTO ${tableName}
|
|
@@ -25946,7 +25981,7 @@ var WorkflowsPG = class WorkflowsPG extends _mastra_core_storage.WorkflowsStorag
|
|
|
25946
25981
|
return snapshot.context;
|
|
25947
25982
|
});
|
|
25948
25983
|
} catch (error) {
|
|
25949
|
-
if ((0, _mastra_core_storage.isRunFenceConflictError)(error)) throw error;
|
|
25984
|
+
if ((0, _mastra_core_storage.isRunFenceConflictError)(error) || (0, _mastra_core_storage.isWorkflowStepConflictError)(error)) throw error;
|
|
25950
25985
|
throw new _mastra_core_error.MastraError({
|
|
25951
25986
|
id: (0, _mastra_core_storage.createStorageErrorId)("PG", "UPDATE_WORKFLOW_RESULTS", "FAILED"),
|
|
25952
25987
|
domain: _mastra_core_error.ErrorDomain.STORAGE,
|