@mastra/cloudflare-d1 1.0.5 → 1.0.6-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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @mastra/cloudflare-d1
2
2
 
3
+ ## 1.0.6-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Track `suspendedAt` and `suspendPayload` on background tasks. SQL adapters auto-migrate the new columns via `alterTable`. ([#16260](https://github.com/mastra-ai/mastra/pull/16260))
8
+
9
+ - Updated dependencies [[`9f17410`](https://github.com/mastra-ai/mastra/commit/9f1741080def23d42ee50b39887a385ae316a3c6), [`c6eb39e`](https://github.com/mastra-ai/mastra/commit/c6eb39ea6dca381c6563cb240237fbe608e02f93), [`900d086`](https://github.com/mastra-ai/mastra/commit/900d086bb737b9cf2fcf68f11b0389b801a2738c), [`4c0e286`](https://github.com/mastra-ai/mastra/commit/4c0e28637c9cfb4f416549b55e97ebfa13319dfc), [`25184ff`](https://github.com/mastra-ai/mastra/commit/25184ffaf1293ec95119426eb1a1f8d38831b96c), [`aebde9c`](https://github.com/mastra-ai/mastra/commit/aebde9cfacf56592c6b6350cae721740fe090b8a)]:
10
+ - @mastra/core@1.33.0-alpha.4
11
+
3
12
  ## 1.0.5
4
13
 
5
14
  ### Patch Changes
@@ -3,7 +3,7 @@ name: mastra-cloudflare-d1
3
3
  description: Documentation for @mastra/cloudflare-d1. Use when working with @mastra/cloudflare-d1 APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/cloudflare-d1"
6
- version: "1.0.5"
6
+ version: "1.0.6-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.5",
2
+ "version": "1.0.6-alpha.0",
3
3
  "package": "@mastra/cloudflare-d1",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -759,11 +759,13 @@ function rowToTask(row) {
759
759
  runId: row.run_id ?? "",
760
760
  result: parseJson(row.result),
761
761
  error: parseJson(row.error),
762
+ suspendPayload: parseJson(row.suspend_payload),
762
763
  retryCount: Number(row.retry_count ?? 0),
763
764
  maxRetries: Number(row.max_retries ?? 0),
764
765
  timeoutMs: Number(row.timeout_ms ?? 3e5),
765
766
  createdAt: new Date(row.createdAt),
766
767
  startedAt: row.startedAt ? new Date(row.startedAt) : void 0,
768
+ suspendedAt: row.suspendedAt ? new Date(row.suspendedAt) : void 0,
767
769
  completedAt: row.completedAt ? new Date(row.completedAt) : void 0
768
770
  };
769
771
  }
@@ -776,6 +778,11 @@ var BackgroundTasksStorageD1 = class extends storage.BackgroundTasksStorage {
776
778
  }
777
779
  async init() {
778
780
  await this.#db.createTable({ tableName: storage.TABLE_BACKGROUND_TASKS, schema: storage.TABLE_SCHEMAS[storage.TABLE_BACKGROUND_TASKS] });
781
+ await this.#db.alterTable({
782
+ tableName: storage.TABLE_BACKGROUND_TASKS,
783
+ schema: storage.TABLE_SCHEMAS[storage.TABLE_BACKGROUND_TASKS],
784
+ ifNotExists: ["suspend_payload", "suspendedAt"]
785
+ });
779
786
  }
780
787
  async dangerouslyClearAll() {
781
788
  await this.#db.clearTable({ tableName: storage.TABLE_BACKGROUND_TASKS });
@@ -796,11 +803,13 @@ var BackgroundTasksStorageD1 = class extends storage.BackgroundTasksStorage {
796
803
  "args",
797
804
  "result",
798
805
  "error",
806
+ "suspend_payload",
799
807
  "retry_count",
800
808
  "max_retries",
801
809
  "timeout_ms",
802
810
  "createdAt",
803
811
  "startedAt",
812
+ "suspendedAt",
804
813
  "completedAt"
805
814
  ],
806
815
  [
@@ -815,11 +824,13 @@ var BackgroundTasksStorageD1 = class extends storage.BackgroundTasksStorage {
815
824
  serializeJson(task.args),
816
825
  serializeJson(task.result),
817
826
  serializeJson(task.error),
827
+ serializeJson(task.suspendPayload),
818
828
  task.retryCount,
819
829
  task.maxRetries,
820
830
  task.timeoutMs,
821
831
  task.createdAt.toISOString(),
822
832
  task.startedAt?.toISOString() ?? null,
833
+ task.suspendedAt?.toISOString() ?? null,
823
834
  task.completedAt?.toISOString() ?? null
824
835
  ]
825
836
  ).build();
@@ -840,6 +851,10 @@ var BackgroundTasksStorageD1 = class extends storage.BackgroundTasksStorage {
840
851
  sets.push("error = ?");
841
852
  params.push(serializeJson(update.error));
842
853
  }
854
+ if ("suspendPayload" in update) {
855
+ sets.push("suspend_payload = ?");
856
+ params.push(serializeJson(update.suspendPayload));
857
+ }
843
858
  if ("retryCount" in update) {
844
859
  sets.push("retry_count = ?");
845
860
  params.push(update.retryCount);
@@ -848,6 +863,10 @@ var BackgroundTasksStorageD1 = class extends storage.BackgroundTasksStorage {
848
863
  sets.push("startedAt = ?");
849
864
  params.push(update.startedAt?.toISOString() ?? null);
850
865
  }
866
+ if ("suspendedAt" in update) {
867
+ sets.push("suspendedAt = ?");
868
+ params.push(update.suspendedAt?.toISOString() ?? null);
869
+ }
851
870
  if ("completedAt" in update) {
852
871
  sets.push("completedAt = ?");
853
872
  params.push(update.completedAt?.toISOString() ?? null);
@@ -891,7 +910,11 @@ var BackgroundTasksStorageD1 = class extends storage.BackgroundTasksStorage {
891
910
  builder = builder.whereAnd("tool_name = ?", filter.toolName);
892
911
  countBuilder = countBuilder.whereAnd("tool_name = ?", filter.toolName);
893
912
  }
894
- const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
913
+ if (filter.toolCallId) {
914
+ builder = builder.whereAnd("tool_call_id = ?", filter.toolCallId);
915
+ countBuilder = countBuilder.whereAnd("tool_call_id = ?", filter.toolCallId);
916
+ }
917
+ const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "suspendedAt" ? "suspendedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
895
918
  if (filter.fromDate) {
896
919
  builder = builder.whereAnd(`${dateCol} >= ?`, filter.fromDate.toISOString());
897
920
  countBuilder = countBuilder.whereAnd(`${dateCol} >= ?`, filter.fromDate.toISOString());
@@ -903,7 +926,7 @@ var BackgroundTasksStorageD1 = class extends storage.BackgroundTasksStorage {
903
926
  const { sql: countSql, params: countParams } = countBuilder.build();
904
927
  const countRow = await this.#db.executeQuery({ sql: countSql, params: countParams, first: true });
905
928
  const total = Number(countRow?.count ?? 0);
906
- const orderCol = filter.orderBy === "startedAt" ? "startedAt" : filter.orderBy === "completedAt" ? "completedAt" : "createdAt";
929
+ const orderCol = filter.orderBy === "startedAt" ? "startedAt" : filter.orderBy === "suspendedAt" ? "suspendedAt" : filter.orderBy === "completedAt" ? "completedAt" : "createdAt";
907
930
  builder = builder.orderBy(orderCol, filter.orderDirection === "desc" ? "DESC" : "ASC");
908
931
  if (filter.perPage != null) {
909
932
  builder = builder.limit(filter.perPage);
@@ -927,7 +950,7 @@ var BackgroundTasksStorageD1 = class extends storage.BackgroundTasksStorage {
927
950
  conditions.push(`status IN (${statuses.map(() => "?").join(",")})`);
928
951
  params.push(...statuses);
929
952
  }
930
- const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
953
+ const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "suspendedAt" ? "suspendedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
931
954
  if (filter.fromDate) {
932
955
  conditions.push(`${dateCol} >= ?`);
933
956
  params.push(filter.fromDate.toISOString());
@@ -944,6 +967,10 @@ var BackgroundTasksStorageD1 = class extends storage.BackgroundTasksStorage {
944
967
  conditions.push("run_id = ?");
945
968
  params.push(filter.runId);
946
969
  }
970
+ if (filter.toolCallId) {
971
+ conditions.push("tool_call_id = ?");
972
+ params.push(filter.toolCallId);
973
+ }
947
974
  if (conditions.length === 0) return;
948
975
  const fullTableName = this.#db.getTableName(storage.TABLE_BACKGROUND_TASKS);
949
976
  await this.#db.executeQuery({