@mastra/cloudflare-d1 1.3.2 → 1.4.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/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +39 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +39 -7
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts +2 -4
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/package.json +8 -8
package/dist/docs/SKILL.md
CHANGED
|
@@ -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.
|
|
6
|
+
version: "1.4.0-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
package/dist/index.cjs
CHANGED
|
@@ -690,7 +690,9 @@ function rowToTask(row) {
|
|
|
690
690
|
createdAt: new Date(row.createdAt),
|
|
691
691
|
startedAt: row.startedAt ? new Date(row.startedAt) : void 0,
|
|
692
692
|
suspendedAt: row.suspendedAt ? new Date(row.suspendedAt) : void 0,
|
|
693
|
-
completedAt: row.completedAt ? new Date(row.completedAt) : void 0
|
|
693
|
+
completedAt: row.completedAt ? new Date(row.completedAt) : void 0,
|
|
694
|
+
ownerId: row.ownerId || void 0,
|
|
695
|
+
leaseExpiresAt: row.leaseExpiresAt ? new Date(row.leaseExpiresAt) : void 0
|
|
694
696
|
};
|
|
695
697
|
}
|
|
696
698
|
var BackgroundTasksStorageD1 = class extends _mastra_core_storage.BackgroundTasksStorage {
|
|
@@ -708,7 +710,12 @@ var BackgroundTasksStorageD1 = class extends _mastra_core_storage.BackgroundTask
|
|
|
708
710
|
await this.#db.alterTable({
|
|
709
711
|
tableName: _mastra_core_storage.TABLE_BACKGROUND_TASKS,
|
|
710
712
|
schema: _mastra_core_storage.TABLE_SCHEMAS[_mastra_core_storage.TABLE_BACKGROUND_TASKS],
|
|
711
|
-
ifNotExists: [
|
|
713
|
+
ifNotExists: [
|
|
714
|
+
"suspend_payload",
|
|
715
|
+
"suspendedAt",
|
|
716
|
+
"ownerId",
|
|
717
|
+
"leaseExpiresAt"
|
|
718
|
+
]
|
|
712
719
|
});
|
|
713
720
|
}
|
|
714
721
|
async dangerouslyClearAll() {
|
|
@@ -735,7 +742,9 @@ var BackgroundTasksStorageD1 = class extends _mastra_core_storage.BackgroundTask
|
|
|
735
742
|
"createdAt",
|
|
736
743
|
"startedAt",
|
|
737
744
|
"suspendedAt",
|
|
738
|
-
"completedAt"
|
|
745
|
+
"completedAt",
|
|
746
|
+
"ownerId",
|
|
747
|
+
"leaseExpiresAt"
|
|
739
748
|
], [
|
|
740
749
|
task.id,
|
|
741
750
|
task.toolCallId,
|
|
@@ -755,7 +764,9 @@ var BackgroundTasksStorageD1 = class extends _mastra_core_storage.BackgroundTask
|
|
|
755
764
|
task.createdAt.toISOString(),
|
|
756
765
|
task.startedAt?.toISOString() ?? null,
|
|
757
766
|
task.suspendedAt?.toISOString() ?? null,
|
|
758
|
-
task.completedAt?.toISOString() ?? null
|
|
767
|
+
task.completedAt?.toISOString() ?? null,
|
|
768
|
+
task.ownerId ?? null,
|
|
769
|
+
task.leaseExpiresAt?.toISOString() ?? null
|
|
759
770
|
]).build();
|
|
760
771
|
await this.#db.executeQuery({
|
|
761
772
|
sql,
|
|
@@ -797,13 +808,34 @@ var BackgroundTasksStorageD1 = class extends _mastra_core_storage.BackgroundTask
|
|
|
797
808
|
sets.push("completedAt = ?");
|
|
798
809
|
params.push(update.completedAt?.toISOString() ?? null);
|
|
799
810
|
}
|
|
811
|
+
if ("ownerId" in update) {
|
|
812
|
+
sets.push("ownerId = ?");
|
|
813
|
+
params.push(update.ownerId ?? null);
|
|
814
|
+
}
|
|
815
|
+
if ("leaseExpiresAt" in update) {
|
|
816
|
+
sets.push("leaseExpiresAt = ?");
|
|
817
|
+
params.push(update.leaseExpiresAt?.toISOString() ?? null);
|
|
818
|
+
}
|
|
800
819
|
if (sets.length === 0) return false;
|
|
801
820
|
params.push(taskId);
|
|
802
|
-
|
|
803
|
-
if (options?.expectedStatus)
|
|
821
|
+
let predicates = "";
|
|
822
|
+
if (options?.expectedStatus) {
|
|
823
|
+
predicates += " AND status = ?";
|
|
824
|
+
params.push(options.expectedStatus);
|
|
825
|
+
}
|
|
826
|
+
if (options?.expectedOwnerId !== void 0) if (options.expectedOwnerId === null) predicates += " AND ownerId IS NULL";
|
|
827
|
+
else {
|
|
828
|
+
predicates += " AND ownerId = ?";
|
|
829
|
+
params.push(options.expectedOwnerId);
|
|
830
|
+
}
|
|
831
|
+
if (options?.expectedLeaseExpiresAt !== void 0) if (options.expectedLeaseExpiresAt === null) predicates += " AND leaseExpiresAt IS NULL";
|
|
832
|
+
else {
|
|
833
|
+
predicates += " AND leaseExpiresAt = ?";
|
|
834
|
+
params.push(options.expectedLeaseExpiresAt.toISOString());
|
|
835
|
+
}
|
|
804
836
|
const fullTableName = this.#db.getTableName(_mastra_core_storage.TABLE_BACKGROUND_TASKS);
|
|
805
837
|
const result = await this.#db.executeQuery({
|
|
806
|
-
sql: `UPDATE ${fullTableName} SET ${sets.join(", ")} WHERE id = ?${
|
|
838
|
+
sql: `UPDATE ${fullTableName} SET ${sets.join(", ")} WHERE id = ?${predicates} RETURNING id`,
|
|
807
839
|
params
|
|
808
840
|
});
|
|
809
841
|
return Array.isArray(result) && result.length > 0;
|