@mastra/cloudflare-d1 1.3.0 → 1.3.1
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 +18 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +7 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts +3 -1
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -738,7 +738,7 @@ var BackgroundTasksStorageD1 = class extends BackgroundTasksStorage {
|
|
|
738
738
|
params
|
|
739
739
|
});
|
|
740
740
|
}
|
|
741
|
-
async updateTask(taskId, update) {
|
|
741
|
+
async updateTask(taskId, update, options) {
|
|
742
742
|
const sets = [];
|
|
743
743
|
const params = [];
|
|
744
744
|
if ("status" in update) {
|
|
@@ -773,13 +773,16 @@ var BackgroundTasksStorageD1 = class extends BackgroundTasksStorage {
|
|
|
773
773
|
sets.push("completedAt = ?");
|
|
774
774
|
params.push(update.completedAt?.toISOString() ?? null);
|
|
775
775
|
}
|
|
776
|
-
if (sets.length === 0) return;
|
|
776
|
+
if (sets.length === 0) return false;
|
|
777
777
|
params.push(taskId);
|
|
778
|
+
const statusPredicate = options?.expectedStatus ? " AND status = ?" : "";
|
|
779
|
+
if (options?.expectedStatus) params.push(options.expectedStatus);
|
|
778
780
|
const fullTableName = this.#db.getTableName(TABLE_BACKGROUND_TASKS);
|
|
779
|
-
await this.#db.executeQuery({
|
|
780
|
-
sql: `UPDATE ${fullTableName} SET ${sets.join(", ")} WHERE id =
|
|
781
|
+
const result = await this.#db.executeQuery({
|
|
782
|
+
sql: `UPDATE ${fullTableName} SET ${sets.join(", ")} WHERE id = ?${statusPredicate} RETURNING id`,
|
|
781
783
|
params
|
|
782
784
|
});
|
|
785
|
+
return Array.isArray(result) && result.length > 0;
|
|
783
786
|
}
|
|
784
787
|
async getTask(taskId) {
|
|
785
788
|
const fullTableName = this.#db.getTableName(TABLE_BACKGROUND_TASKS);
|