@mastra/dsql 1.5.0 → 1.5.1-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/index.cjs +6 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/agents/index.d.ts.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/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1376,6 +1376,7 @@ var AgentsDSQL = class AgentsDSQL extends _mastra_core_storage.AgentsStorage {
|
|
|
1376
1376
|
});
|
|
1377
1377
|
const now = /* @__PURE__ */ new Date();
|
|
1378
1378
|
const nowIso = now.toISOString();
|
|
1379
|
+
let draftInserted = false;
|
|
1379
1380
|
try {
|
|
1380
1381
|
await withRetry(() => this.#db.client.none(`INSERT INTO ${tableName} (
|
|
1381
1382
|
id, status, "authorId", metadata,
|
|
@@ -1392,6 +1393,7 @@ var AgentsDSQL = class AgentsDSQL extends _mastra_core_storage.AgentsStorage {
|
|
|
1392
1393
|
nowIso,
|
|
1393
1394
|
nowIso
|
|
1394
1395
|
]));
|
|
1396
|
+
draftInserted = true;
|
|
1395
1397
|
const { id: _id, authorId: _authorId, metadata: _metadata, ...snapshotConfig } = agent;
|
|
1396
1398
|
const versionId = crypto.randomUUID();
|
|
1397
1399
|
await this.createVersion({
|
|
@@ -1412,10 +1414,10 @@ var AgentsDSQL = class AgentsDSQL extends _mastra_core_storage.AgentsStorage {
|
|
|
1412
1414
|
updatedAt: now
|
|
1413
1415
|
};
|
|
1414
1416
|
} catch (error) {
|
|
1415
|
-
if (
|
|
1416
|
-
try {
|
|
1417
|
+
if (draftInserted) try {
|
|
1417
1418
|
await this.#db.client.none(`DELETE FROM ${tableName} WHERE id = $1 AND status = 'draft' AND "activeVersionId" IS NULL`, [agent.id]);
|
|
1418
1419
|
} catch {}
|
|
1420
|
+
if (error instanceof _mastra_core_error.MastraError) throw error;
|
|
1419
1421
|
throw new _mastra_core_error.MastraError({
|
|
1420
1422
|
id: (0, _mastra_core_storage.createStorageErrorId)("DSQL", "CREATE_AGENT", "FAILED"),
|
|
1421
1423
|
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
@@ -3795,7 +3797,7 @@ var WorkflowsDSQL = class WorkflowsDSQL extends _mastra_core_storage.WorkflowsSt
|
|
|
3795
3797
|
async dangerouslyClearAll() {
|
|
3796
3798
|
await this.#db.clearTable({ tableName: _mastra_core_storage.TABLE_WORKFLOW_SNAPSHOT });
|
|
3797
3799
|
}
|
|
3798
|
-
async updateWorkflowResults({ workflowName, runId, stepId, result, requestContext }) {
|
|
3800
|
+
async updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, state }) {
|
|
3799
3801
|
try {
|
|
3800
3802
|
const { result: context } = await withRetry(async () => {
|
|
3801
3803
|
return this.#db.client.tx(async (t) => {
|
|
@@ -3824,6 +3826,7 @@ var WorkflowsDSQL = class WorkflowsDSQL extends _mastra_core_storage.WorkflowsSt
|
|
|
3824
3826
|
snapshot = typeof existingSnapshot === "string" ? JSON.parse(existingSnapshot) : existingSnapshot;
|
|
3825
3827
|
}
|
|
3826
3828
|
snapshot.context[stepId] = result;
|
|
3829
|
+
if (state !== void 0) snapshot.context.__state = state;
|
|
3827
3830
|
snapshot.requestContext = {
|
|
3828
3831
|
...snapshot.requestContext,
|
|
3829
3832
|
...requestContext
|