@mastra/cloudflare-d1 1.0.0-beta.3 → 1.0.0-beta.4

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.js CHANGED
@@ -1411,13 +1411,19 @@ var ScoresStorageD1 = class extends ScoresStorage {
1411
1411
  id: createStorageErrorId("CLOUDFLARE_D1", "SAVE_SCORE", "VALIDATION_FAILED"),
1412
1412
  domain: ErrorDomain.STORAGE,
1413
1413
  category: ErrorCategory.USER,
1414
- details: { scoreId: score.id }
1414
+ details: {
1415
+ scorer: score.scorer?.id ?? "unknown",
1416
+ entityId: score.entityId ?? "unknown",
1417
+ entityType: score.entityType ?? "unknown",
1418
+ traceId: score.traceId ?? "",
1419
+ spanId: score.spanId ?? ""
1420
+ }
1415
1421
  },
1416
1422
  error
1417
1423
  );
1418
1424
  }
1425
+ const id = crypto.randomUUID();
1419
1426
  try {
1420
- const id = crypto.randomUUID();
1421
1427
  const fullTableName = this.operations.getTableName(TABLE_SCORERS);
1422
1428
  const serializedRecord = {};
1423
1429
  for (const [key, value] of Object.entries(parsedScore)) {
@@ -1431,22 +1437,23 @@ var ScoresStorageD1 = class extends ScoresStorage {
1431
1437
  serializedRecord[key] = null;
1432
1438
  }
1433
1439
  }
1440
+ const now = /* @__PURE__ */ new Date();
1434
1441
  serializedRecord.id = id;
1435
- serializedRecord.createdAt = (/* @__PURE__ */ new Date()).toISOString();
1436
- serializedRecord.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1442
+ serializedRecord.createdAt = now.toISOString();
1443
+ serializedRecord.updatedAt = now.toISOString();
1437
1444
  const columns = Object.keys(serializedRecord);
1438
1445
  const values = Object.values(serializedRecord);
1439
1446
  const query = createSqlBuilder().insert(fullTableName, columns, values);
1440
1447
  const { sql, params } = query.build();
1441
1448
  await this.operations.executeQuery({ sql, params });
1442
- const scoreFromDb = await this.getScoreById({ id });
1443
- return { score: scoreFromDb };
1449
+ return { score: { ...parsedScore, id, createdAt: now, updatedAt: now } };
1444
1450
  } catch (error) {
1445
1451
  throw new MastraError(
1446
1452
  {
1447
1453
  id: createStorageErrorId("CLOUDFLARE_D1", "SAVE_SCORE", "FAILED"),
1448
1454
  domain: ErrorDomain.STORAGE,
1449
- category: ErrorCategory.THIRD_PARTY
1455
+ category: ErrorCategory.THIRD_PARTY,
1456
+ details: { id }
1450
1457
  },
1451
1458
  error
1452
1459
  );
@@ -2101,8 +2108,8 @@ var D1Store = class extends MastraStorage {
2101
2108
  async getScoreById({ id: _id }) {
2102
2109
  return this.stores.scores.getScoreById({ id: _id });
2103
2110
  }
2104
- async saveScore(_score) {
2105
- return this.stores.scores.saveScore(_score);
2111
+ async saveScore(score) {
2112
+ return this.stores.scores.saveScore(score);
2106
2113
  }
2107
2114
  async listScoresByRunId({
2108
2115
  runId: _runId,