@mastra/dsql 1.5.1-alpha.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 +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 +3 -3
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,
|