@mastra/cloudflare 1.0.0-beta.4 → 1.0.0-beta.5

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
@@ -1551,13 +1551,19 @@ var ScoresStorageCloudflare = class extends ScoresStorage {
1551
1551
  id: createStorageErrorId("CLOUDFLARE", "SAVE_SCORE", "VALIDATION_FAILED"),
1552
1552
  domain: ErrorDomain.STORAGE,
1553
1553
  category: ErrorCategory.USER,
1554
- details: { scoreId: score.id }
1554
+ details: {
1555
+ scorer: score.scorer?.id ?? "unknown",
1556
+ entityId: score.entityId ?? "unknown",
1557
+ entityType: score.entityType ?? "unknown",
1558
+ traceId: score.traceId ?? "",
1559
+ spanId: score.spanId ?? ""
1560
+ }
1555
1561
  },
1556
1562
  error
1557
1563
  );
1558
1564
  }
1565
+ const id = crypto.randomUUID();
1559
1566
  try {
1560
- const id = crypto.randomUUID();
1561
1567
  const serializedRecord = {};
1562
1568
  for (const [key, value] of Object.entries(parsedScore)) {
1563
1569
  if (value !== null && value !== void 0) {
@@ -1570,23 +1576,23 @@ var ScoresStorageCloudflare = class extends ScoresStorage {
1570
1576
  serializedRecord[key] = null;
1571
1577
  }
1572
1578
  }
1579
+ const now = /* @__PURE__ */ new Date();
1573
1580
  serializedRecord.id = id;
1574
- serializedRecord.createdAt = (/* @__PURE__ */ new Date()).toISOString();
1575
- serializedRecord.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1581
+ serializedRecord.createdAt = now.toISOString();
1582
+ serializedRecord.updatedAt = now.toISOString();
1576
1583
  await this.operations.putKV({
1577
1584
  tableName: TABLE_SCORERS,
1578
1585
  key: id,
1579
1586
  value: serializedRecord
1580
1587
  });
1581
- const scoreFromDb = await this.getScoreById({ id: score.id });
1582
- return { score: scoreFromDb };
1588
+ return { score: { ...parsedScore, id, createdAt: now, updatedAt: now } };
1583
1589
  } catch (error) {
1584
1590
  const mastraError = new MastraError(
1585
1591
  {
1586
1592
  id: createStorageErrorId("CLOUDFLARE", "SAVE_SCORE", "FAILED"),
1587
1593
  domain: ErrorDomain.STORAGE,
1588
1594
  category: ErrorCategory.THIRD_PARTY,
1589
- text: `Failed to save score: ${score.id}`
1595
+ details: { id }
1590
1596
  },
1591
1597
  error
1592
1598
  );