@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 +9 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +30 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -3
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -753,11 +753,13 @@ function rowToTask(row) {
|
|
|
753
753
|
runId: row.run_id ?? "",
|
|
754
754
|
result: parseJson(row.result),
|
|
755
755
|
error: parseJson(row.error),
|
|
756
|
+
suspendPayload: parseJson(row.suspend_payload),
|
|
756
757
|
retryCount: Number(row.retry_count ?? 0),
|
|
757
758
|
maxRetries: Number(row.max_retries ?? 0),
|
|
758
759
|
timeoutMs: Number(row.timeout_ms ?? 3e5),
|
|
759
760
|
createdAt: new Date(row.createdAt),
|
|
760
761
|
startedAt: row.startedAt ? new Date(row.startedAt) : void 0,
|
|
762
|
+
suspendedAt: row.suspendedAt ? new Date(row.suspendedAt) : void 0,
|
|
761
763
|
completedAt: row.completedAt ? new Date(row.completedAt) : void 0
|
|
762
764
|
};
|
|
763
765
|
}
|
|
@@ -770,6 +772,11 @@ var BackgroundTasksStorageD1 = class extends BackgroundTasksStorage {
|
|
|
770
772
|
}
|
|
771
773
|
async init() {
|
|
772
774
|
await this.#db.createTable({ tableName: TABLE_BACKGROUND_TASKS, schema: TABLE_SCHEMAS[TABLE_BACKGROUND_TASKS] });
|
|
775
|
+
await this.#db.alterTable({
|
|
776
|
+
tableName: TABLE_BACKGROUND_TASKS,
|
|
777
|
+
schema: TABLE_SCHEMAS[TABLE_BACKGROUND_TASKS],
|
|
778
|
+
ifNotExists: ["suspend_payload", "suspendedAt"]
|
|
779
|
+
});
|
|
773
780
|
}
|
|
774
781
|
async dangerouslyClearAll() {
|
|
775
782
|
await this.#db.clearTable({ tableName: TABLE_BACKGROUND_TASKS });
|
|
@@ -790,11 +797,13 @@ var BackgroundTasksStorageD1 = class extends BackgroundTasksStorage {
|
|
|
790
797
|
"args",
|
|
791
798
|
"result",
|
|
792
799
|
"error",
|
|
800
|
+
"suspend_payload",
|
|
793
801
|
"retry_count",
|
|
794
802
|
"max_retries",
|
|
795
803
|
"timeout_ms",
|
|
796
804
|
"createdAt",
|
|
797
805
|
"startedAt",
|
|
806
|
+
"suspendedAt",
|
|
798
807
|
"completedAt"
|
|
799
808
|
],
|
|
800
809
|
[
|
|
@@ -809,11 +818,13 @@ var BackgroundTasksStorageD1 = class extends BackgroundTasksStorage {
|
|
|
809
818
|
serializeJson(task.args),
|
|
810
819
|
serializeJson(task.result),
|
|
811
820
|
serializeJson(task.error),
|
|
821
|
+
serializeJson(task.suspendPayload),
|
|
812
822
|
task.retryCount,
|
|
813
823
|
task.maxRetries,
|
|
814
824
|
task.timeoutMs,
|
|
815
825
|
task.createdAt.toISOString(),
|
|
816
826
|
task.startedAt?.toISOString() ?? null,
|
|
827
|
+
task.suspendedAt?.toISOString() ?? null,
|
|
817
828
|
task.completedAt?.toISOString() ?? null
|
|
818
829
|
]
|
|
819
830
|
).build();
|
|
@@ -834,6 +845,10 @@ var BackgroundTasksStorageD1 = class extends BackgroundTasksStorage {
|
|
|
834
845
|
sets.push("error = ?");
|
|
835
846
|
params.push(serializeJson(update.error));
|
|
836
847
|
}
|
|
848
|
+
if ("suspendPayload" in update) {
|
|
849
|
+
sets.push("suspend_payload = ?");
|
|
850
|
+
params.push(serializeJson(update.suspendPayload));
|
|
851
|
+
}
|
|
837
852
|
if ("retryCount" in update) {
|
|
838
853
|
sets.push("retry_count = ?");
|
|
839
854
|
params.push(update.retryCount);
|
|
@@ -842,6 +857,10 @@ var BackgroundTasksStorageD1 = class extends BackgroundTasksStorage {
|
|
|
842
857
|
sets.push("startedAt = ?");
|
|
843
858
|
params.push(update.startedAt?.toISOString() ?? null);
|
|
844
859
|
}
|
|
860
|
+
if ("suspendedAt" in update) {
|
|
861
|
+
sets.push("suspendedAt = ?");
|
|
862
|
+
params.push(update.suspendedAt?.toISOString() ?? null);
|
|
863
|
+
}
|
|
845
864
|
if ("completedAt" in update) {
|
|
846
865
|
sets.push("completedAt = ?");
|
|
847
866
|
params.push(update.completedAt?.toISOString() ?? null);
|
|
@@ -885,7 +904,11 @@ var BackgroundTasksStorageD1 = class extends BackgroundTasksStorage {
|
|
|
885
904
|
builder = builder.whereAnd("tool_name = ?", filter.toolName);
|
|
886
905
|
countBuilder = countBuilder.whereAnd("tool_name = ?", filter.toolName);
|
|
887
906
|
}
|
|
888
|
-
|
|
907
|
+
if (filter.toolCallId) {
|
|
908
|
+
builder = builder.whereAnd("tool_call_id = ?", filter.toolCallId);
|
|
909
|
+
countBuilder = countBuilder.whereAnd("tool_call_id = ?", filter.toolCallId);
|
|
910
|
+
}
|
|
911
|
+
const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "suspendedAt" ? "suspendedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
|
|
889
912
|
if (filter.fromDate) {
|
|
890
913
|
builder = builder.whereAnd(`${dateCol} >= ?`, filter.fromDate.toISOString());
|
|
891
914
|
countBuilder = countBuilder.whereAnd(`${dateCol} >= ?`, filter.fromDate.toISOString());
|
|
@@ -897,7 +920,7 @@ var BackgroundTasksStorageD1 = class extends BackgroundTasksStorage {
|
|
|
897
920
|
const { sql: countSql, params: countParams } = countBuilder.build();
|
|
898
921
|
const countRow = await this.#db.executeQuery({ sql: countSql, params: countParams, first: true });
|
|
899
922
|
const total = Number(countRow?.count ?? 0);
|
|
900
|
-
const orderCol = filter.orderBy === "startedAt" ? "startedAt" : filter.orderBy === "completedAt" ? "completedAt" : "createdAt";
|
|
923
|
+
const orderCol = filter.orderBy === "startedAt" ? "startedAt" : filter.orderBy === "suspendedAt" ? "suspendedAt" : filter.orderBy === "completedAt" ? "completedAt" : "createdAt";
|
|
901
924
|
builder = builder.orderBy(orderCol, filter.orderDirection === "desc" ? "DESC" : "ASC");
|
|
902
925
|
if (filter.perPage != null) {
|
|
903
926
|
builder = builder.limit(filter.perPage);
|
|
@@ -921,7 +944,7 @@ var BackgroundTasksStorageD1 = class extends BackgroundTasksStorage {
|
|
|
921
944
|
conditions.push(`status IN (${statuses.map(() => "?").join(",")})`);
|
|
922
945
|
params.push(...statuses);
|
|
923
946
|
}
|
|
924
|
-
const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
|
|
947
|
+
const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "suspendedAt" ? "suspendedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
|
|
925
948
|
if (filter.fromDate) {
|
|
926
949
|
conditions.push(`${dateCol} >= ?`);
|
|
927
950
|
params.push(filter.fromDate.toISOString());
|
|
@@ -938,6 +961,10 @@ var BackgroundTasksStorageD1 = class extends BackgroundTasksStorage {
|
|
|
938
961
|
conditions.push("run_id = ?");
|
|
939
962
|
params.push(filter.runId);
|
|
940
963
|
}
|
|
964
|
+
if (filter.toolCallId) {
|
|
965
|
+
conditions.push("tool_call_id = ?");
|
|
966
|
+
params.push(filter.toolCallId);
|
|
967
|
+
}
|
|
941
968
|
if (conditions.length === 0) return;
|
|
942
969
|
const fullTableName = this.#db.getTableName(TABLE_BACKGROUND_TASKS);
|
|
943
970
|
await this.#db.executeQuery({
|