@mastra/cloudflare 1.7.5-alpha.0 → 1.7.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.
@@ -299,10 +299,11 @@ async function assertRunFence(db, { claimsTable, fence, operation }) {
299
299
  params: [fence.runId],
300
300
  first: true
301
301
  });
302
- if (!(0, _mastra_core_storage.matchesRunFence)(row ? {
302
+ const current = row ? {
303
303
  generation: Number(row.generation),
304
304
  ownerId: String(row.ownerId)
305
- } : null, fence)) throw new _mastra_core_storage.RunFenceConflictError(fence, operation);
305
+ } : null;
306
+ if (!(0, _mastra_core_storage.matchesRunFence)(current, fence)) throw new _mastra_core_storage.RunFenceConflictError(fence, operation);
306
307
  }
307
308
  /**
308
309
  * Runs one statement of a fenced write. With a check, `statement` must carry
@@ -1013,13 +1014,14 @@ var MemoryStorageDO = class MemoryStorageDO extends _mastra_core_storage.MemoryS
1013
1014
  });
1014
1015
  }
1015
1016
  async prune(policies, options) {
1017
+ const targets = (0, _mastra_core_storage.resolveRetentionTargets)({
1018
+ policies,
1019
+ descriptor: MemoryStorageDO.retentionTables,
1020
+ order: ["runFences"]
1021
+ });
1016
1022
  return (0, _mastra_core_storage.executeRetentionPrune)({
1017
1023
  domain: "memory",
1018
- targets: (0, _mastra_core_storage.resolveRetentionTargets)({
1019
- policies,
1020
- descriptor: MemoryStorageDO.retentionTables,
1021
- order: ["runFences"]
1022
- }),
1024
+ targets,
1023
1025
  options,
1024
1026
  cutoffFor: (target, now) => (0, _mastra_core_storage.retentionCutoffMs)(target.policy, now),
1025
1027
  deleteBatch: (_target, cutoff, limit) => this.#db.pruneRunRows({
@@ -1794,15 +1796,17 @@ var MemoryStorageDO = class MemoryStorageDO extends _mastra_core_storage.MemoryS
1794
1796
  const existing = existingMessagesMap.get(update.id);
1795
1797
  if (!existing) continue;
1796
1798
  let mergedContent = existing.content;
1797
- if (update.content) if (typeof mergedContent === "object" && mergedContent !== null) mergedContent = {
1798
- ...mergedContent,
1799
- ...update.content,
1800
- metadata: {
1801
- ...mergedContent.metadata,
1802
- ...update.content.metadata
1803
- }
1804
- };
1805
- else mergedContent = update.content;
1799
+ if (update.content) {
1800
+ if (typeof mergedContent === "object" && mergedContent !== null) mergedContent = {
1801
+ ...mergedContent,
1802
+ ...update.content,
1803
+ metadata: {
1804
+ ...mergedContent.metadata,
1805
+ ...update.content.metadata
1806
+ }
1807
+ };
1808
+ else mergedContent = update.content;
1809
+ }
1806
1810
  updatedMessages.push({
1807
1811
  ...existing,
1808
1812
  ...update,
@@ -1942,9 +1946,10 @@ var ScoresStorageDO = class extends _mastra_core_storage.ScoresStorage {
1942
1946
  try {
1943
1947
  const fullTableName = this.#db.getTableName(_mastra_core_storage.TABLE_SCORERS);
1944
1948
  const serializedRecord = {};
1945
- for (const [key, value] of Object.entries(parsedScore)) if (value !== null && value !== void 0) if (typeof value === "object") serializedRecord[key] = JSON.stringify(value);
1946
- else serializedRecord[key] = value;
1947
- else serializedRecord[key] = null;
1949
+ for (const [key, value] of Object.entries(parsedScore)) if (value !== null && value !== void 0) {
1950
+ if (typeof value === "object") serializedRecord[key] = JSON.stringify(value);
1951
+ else serializedRecord[key] = value;
1952
+ } else serializedRecord[key] = null;
1948
1953
  const now = /* @__PURE__ */ new Date();
1949
1954
  serializedRecord.id = id;
1950
1955
  serializedRecord.createdAt = now.toISOString();
@@ -2215,13 +2220,14 @@ var WorkflowsStorageDO = class WorkflowsStorageDO extends _mastra_core_storage.W
2215
2220
  });
2216
2221
  }
2217
2222
  async prune(policies, options) {
2223
+ const targets = (0, _mastra_core_storage.resolveRetentionTargets)({
2224
+ policies,
2225
+ descriptor: WorkflowsStorageDO.retentionTables,
2226
+ order: ["runOwnership"]
2227
+ });
2218
2228
  return (0, _mastra_core_storage.executeRetentionPrune)({
2219
2229
  domain: "workflows",
2220
- targets: (0, _mastra_core_storage.resolveRetentionTargets)({
2221
- policies,
2222
- descriptor: WorkflowsStorageDO.retentionTables,
2223
- order: ["runOwnership"]
2224
- }),
2230
+ targets,
2225
2231
  options,
2226
2232
  cutoffFor: (target, now) => (0, _mastra_core_storage.retentionCutoffMs)(target.policy, now),
2227
2233
  deleteBatch: (_target, cutoff, limit) => this.#db.pruneRunRows({
@@ -2486,10 +2492,12 @@ var WorkflowsStorageDO = class WorkflowsStorageDO extends _mastra_core_storage.W
2486
2492
  builder.whereAnd("CASE WHEN json_valid(snapshot) THEN json_extract(snapshot, '$.status') END = ?", status);
2487
2493
  countBuilder.whereAnd("CASE WHEN json_valid(snapshot) THEN json_extract(snapshot, '$.status') END = ?", status);
2488
2494
  }
2489
- if (resourceId) if (await this.#db.hasColumn(fullTableName, "resourceId")) {
2490
- builder.whereAnd("resourceId = ?", resourceId);
2491
- countBuilder.whereAnd("resourceId = ?", resourceId);
2492
- } else this.logger.warn(`[${fullTableName}] resourceId column not found. Skipping resourceId filter.`);
2495
+ if (resourceId) {
2496
+ if (await this.#db.hasColumn(fullTableName, "resourceId")) {
2497
+ builder.whereAnd("resourceId = ?", resourceId);
2498
+ countBuilder.whereAnd("resourceId = ?", resourceId);
2499
+ } else this.logger.warn(`[${fullTableName}] resourceId column not found. Skipping resourceId filter.`);
2500
+ }
2493
2501
  if (fromDate) {
2494
2502
  builder.whereAnd("createdAt >= ?", fromDate instanceof Date ? fromDate.toISOString() : fromDate);
2495
2503
  countBuilder.whereAnd("createdAt >= ?", fromDate instanceof Date ? fromDate.toISOString() : fromDate);
@@ -2717,4 +2725,4 @@ Object.defineProperty(exports, "WorkflowsStorageDO", {
2717
2725
  }
2718
2726
  });
2719
2727
 
2720
- //# sourceMappingURL=do-CjtUyEjN.cjs.map
2728
+ //# sourceMappingURL=do-Cl2WWMnv.cjs.map