@mastra/dsql 1.5.1-alpha.0 → 1.5.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 +4 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/agents/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1375,6 +1375,7 @@ var AgentsDSQL = class AgentsDSQL extends AgentsStorage {
|
|
|
1375
1375
|
});
|
|
1376
1376
|
const now = /* @__PURE__ */ new Date();
|
|
1377
1377
|
const nowIso = now.toISOString();
|
|
1378
|
+
let draftInserted = false;
|
|
1378
1379
|
try {
|
|
1379
1380
|
await withRetry(() => this.#db.client.none(`INSERT INTO ${tableName} (
|
|
1380
1381
|
id, status, "authorId", metadata,
|
|
@@ -1391,6 +1392,7 @@ var AgentsDSQL = class AgentsDSQL extends AgentsStorage {
|
|
|
1391
1392
|
nowIso,
|
|
1392
1393
|
nowIso
|
|
1393
1394
|
]));
|
|
1395
|
+
draftInserted = true;
|
|
1394
1396
|
const { id: _id, authorId: _authorId, metadata: _metadata, ...snapshotConfig } = agent;
|
|
1395
1397
|
const versionId = crypto.randomUUID();
|
|
1396
1398
|
await this.createVersion({
|
|
@@ -1411,10 +1413,10 @@ var AgentsDSQL = class AgentsDSQL extends AgentsStorage {
|
|
|
1411
1413
|
updatedAt: now
|
|
1412
1414
|
};
|
|
1413
1415
|
} catch (error) {
|
|
1414
|
-
if (
|
|
1415
|
-
try {
|
|
1416
|
+
if (draftInserted) try {
|
|
1416
1417
|
await this.#db.client.none(`DELETE FROM ${tableName} WHERE id = $1 AND status = 'draft' AND "activeVersionId" IS NULL`, [agent.id]);
|
|
1417
1418
|
} catch {}
|
|
1419
|
+
if (error instanceof MastraError) throw error;
|
|
1418
1420
|
throw new MastraError({
|
|
1419
1421
|
id: createStorageErrorId("DSQL", "CREATE_AGENT", "FAILED"),
|
|
1420
1422
|
domain: ErrorDomain.STORAGE,
|