@mastra/cloudflare-d1 0.10.2-alpha.3 → 0.11.0-alpha.0

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 CHANGED
@@ -731,6 +731,7 @@ var D1Store = class extends storage.MastraStorage {
731
731
  if (messages.length === 0) return [];
732
732
  try {
733
733
  const now = /* @__PURE__ */ new Date();
734
+ const threadId = messages[0]?.threadId;
734
735
  for (const [i, message] of messages.entries()) {
735
736
  if (!message.id) throw new Error(`Message at index ${i} missing id`);
736
737
  if (!message.threadId) throw new Error(`Message at index ${i} missing threadId`);
@@ -753,10 +754,17 @@ var D1Store = class extends storage.MastraStorage {
753
754
  resourceId: message.resourceId
754
755
  };
755
756
  });
756
- await this.batchInsert({
757
- tableName: storage.TABLE_MESSAGES,
758
- records: messagesToInsert
759
- });
757
+ await Promise.all([
758
+ this.batchInsert({
759
+ tableName: storage.TABLE_MESSAGES,
760
+ records: messagesToInsert
761
+ }),
762
+ // Update thread's updatedAt timestamp
763
+ this.executeQuery({
764
+ sql: `UPDATE ${this.getTableName(storage.TABLE_THREADS)} SET updatedAt = ? WHERE id = ?`,
765
+ params: [now.toISOString(), threadId]
766
+ })
767
+ ]);
760
768
  this.logger.debug(`Saved ${messages.length} messages`);
761
769
  const list = new agent.MessageList().add(messages, "memory");
762
770
  if (format === `v2`) return list.get.all.v2();
package/dist/index.js CHANGED
@@ -725,6 +725,7 @@ var D1Store = class extends MastraStorage {
725
725
  if (messages.length === 0) return [];
726
726
  try {
727
727
  const now = /* @__PURE__ */ new Date();
728
+ const threadId = messages[0]?.threadId;
728
729
  for (const [i, message] of messages.entries()) {
729
730
  if (!message.id) throw new Error(`Message at index ${i} missing id`);
730
731
  if (!message.threadId) throw new Error(`Message at index ${i} missing threadId`);
@@ -747,10 +748,17 @@ var D1Store = class extends MastraStorage {
747
748
  resourceId: message.resourceId
748
749
  };
749
750
  });
750
- await this.batchInsert({
751
- tableName: TABLE_MESSAGES,
752
- records: messagesToInsert
753
- });
751
+ await Promise.all([
752
+ this.batchInsert({
753
+ tableName: TABLE_MESSAGES,
754
+ records: messagesToInsert
755
+ }),
756
+ // Update thread's updatedAt timestamp
757
+ this.executeQuery({
758
+ sql: `UPDATE ${this.getTableName(TABLE_THREADS)} SET updatedAt = ? WHERE id = ?`,
759
+ params: [now.toISOString(), threadId]
760
+ })
761
+ ]);
754
762
  this.logger.debug(`Saved ${messages.length} messages`);
755
763
  const list = new MessageList().add(messages, "memory");
756
764
  if (format === `v2`) return list.get.all.v2();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/cloudflare-d1",
3
- "version": "0.10.2-alpha.3",
3
+ "version": "0.11.0-alpha.0",
4
4
  "description": "D1 provider for Mastra - includes db storage capabilities",
5
5
  "type": "module",
6
6
  "files": [
@@ -25,18 +25,18 @@
25
25
  "cloudflare": "^4.3.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@cloudflare/workers-types": "^4.20250607.0",
28
+ "@cloudflare/workers-types": "^4.20250610.0",
29
29
  "@microsoft/api-extractor": "^7.52.8",
30
- "@types/node": "^20.17.57",
30
+ "@types/node": "^20.19.0",
31
31
  "dotenv": "^16.5.0",
32
32
  "eslint": "^9.28.0",
33
33
  "miniflare": "^4.20250525.1",
34
34
  "tsup": "^8.5.0",
35
- "typescript": "^5.8.2",
36
- "vitest": "^3.2.2",
37
- "@internal/lint": "0.0.10",
38
- "@internal/storage-test-utils": "0.0.6",
39
- "@mastra/core": "0.10.4-alpha.3"
35
+ "typescript": "^5.8.3",
36
+ "vitest": "^3.2.3",
37
+ "@internal/lint": "0.0.12",
38
+ "@mastra/core": "0.10.6-alpha.0",
39
+ "@internal/storage-test-utils": "0.0.8"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@mastra/core": ">=0.10.4-0 <0.11.0"