@mastra/upstash 1.4.2 → 1.4.3
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/docs/references/reference-rag-vector-databases.md +4 -4
- package/dist/index.cjs +23 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -14
- 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
|
@@ -230,20 +230,29 @@ var BackgroundTasksUpstash = class extends BackgroundTasksStorage {
|
|
|
230
230
|
const { key, processedRecord } = processRecord(TABLE_BACKGROUND_TASKS, toStorageRecord(task));
|
|
231
231
|
await this.client.set(key, processedRecord);
|
|
232
232
|
}
|
|
233
|
-
async updateTask(taskId, update) {
|
|
234
|
-
const
|
|
235
|
-
if (
|
|
236
|
-
|
|
237
|
-
if ("
|
|
238
|
-
if ("
|
|
239
|
-
if ("
|
|
240
|
-
if ("
|
|
241
|
-
if ("
|
|
242
|
-
if ("
|
|
243
|
-
if (
|
|
244
|
-
|
|
245
|
-
const
|
|
246
|
-
|
|
233
|
+
async updateTask(taskId, update, options) {
|
|
234
|
+
const patch = {};
|
|
235
|
+
if ("status" in update) patch.status = update.status;
|
|
236
|
+
if ("result" in update) patch.result = update.result ?? null;
|
|
237
|
+
if ("error" in update) patch.error = update.error ?? null;
|
|
238
|
+
if ("suspendPayload" in update) patch.suspend_payload = update.suspendPayload ?? null;
|
|
239
|
+
if ("retryCount" in update) patch.retry_count = update.retryCount;
|
|
240
|
+
if ("startedAt" in update) patch.startedAt = update.startedAt?.toISOString() ?? null;
|
|
241
|
+
if ("suspendedAt" in update) patch.suspendedAt = update.suspendedAt?.toISOString() ?? null;
|
|
242
|
+
if ("completedAt" in update) patch.completedAt = update.completedAt?.toISOString() ?? null;
|
|
243
|
+
if (Object.keys(patch).length === 0) return false;
|
|
244
|
+
const key = getKey(TABLE_BACKGROUND_TASKS, { id: taskId });
|
|
245
|
+
const result = await this.client.eval(`
|
|
246
|
+
local existing = redis.call('GET', KEYS[1])
|
|
247
|
+
if not existing then return 0 end
|
|
248
|
+
local record = cjson.decode(existing)
|
|
249
|
+
if ARGV[1] ~= '' and record.status ~= ARGV[1] then return 0 end
|
|
250
|
+
local patch = cjson.decode(ARGV[2])
|
|
251
|
+
for field, value in pairs(patch) do record[field] = value end
|
|
252
|
+
redis.call('SET', KEYS[1], cjson.encode(record))
|
|
253
|
+
return 1
|
|
254
|
+
`, [key], [options?.expectedStatus ?? "", JSON.stringify(patch)]);
|
|
255
|
+
return Number(result) === 1;
|
|
247
256
|
}
|
|
248
257
|
async getTask(taskId) {
|
|
249
258
|
const key = getKey(TABLE_BACKGROUND_TASKS, { id: taskId });
|