@mastra/upstash 1.5.3 → 1.5.4
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/index.js
CHANGED
|
@@ -230,7 +230,8 @@ var BackgroundTasksUpstash = class extends BackgroundTasksStorage {
|
|
|
230
230
|
await this.#db.deleteData({ tableName: TABLE_BACKGROUND_TASKS });
|
|
231
231
|
}
|
|
232
232
|
async createTask(task) {
|
|
233
|
-
const
|
|
233
|
+
const record = toStorageRecord(task);
|
|
234
|
+
const { key, processedRecord } = processRecord(TABLE_BACKGROUND_TASKS, record);
|
|
234
235
|
await this.client.set(key, processedRecord);
|
|
235
236
|
}
|
|
236
237
|
async updateTask(taskId, update, options) {
|
|
@@ -355,7 +356,7 @@ function runClaimKey(claims, runId) {
|
|
|
355
356
|
return `${claims}:run_id:${runId}`;
|
|
356
357
|
}
|
|
357
358
|
const RUN_FENCE_CONFLICT = "MASTRA_RUN_FENCE_CONFLICT";
|
|
358
|
-
const RUN_CLAIM_RETENTION_MS =
|
|
359
|
+
const RUN_CLAIM_RETENTION_MS = 6048e5;
|
|
359
360
|
const FENCE_GUARD = `
|
|
360
361
|
local fenceClaim = redis.call('HMGET', KEYS[#KEYS], 'generation', 'ownerId')
|
|
361
362
|
if tonumber(fenceClaim[1]) ~= tonumber(ARGV[#ARGV - 1]) or fenceClaim[2] ~= ARGV[#ARGV] then
|
|
@@ -1367,22 +1368,24 @@ var StoreMemoryUpstash = class extends MemoryStorage {
|
|
|
1367
1368
|
}
|
|
1368
1369
|
for (const key in fieldsToUpdate) if (Object.prototype.hasOwnProperty.call(fieldsToUpdate, key) && key !== "content") updatedMessage[key] = fieldsToUpdate[key];
|
|
1369
1370
|
const key = messageIdToKey[id];
|
|
1370
|
-
if (key)
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1371
|
+
if (key) {
|
|
1372
|
+
if (updatePayload.threadId && updatePayload.threadId !== existingMessage.threadId) {
|
|
1373
|
+
const newThreadId = updatedMessage.threadId;
|
|
1374
|
+
const oldThreadMessagesKey = getThreadMessagesKey(existingMessage.threadId);
|
|
1375
|
+
pipeline.zrem(oldThreadMessagesKey, id);
|
|
1376
|
+
pipeline.del(key);
|
|
1377
|
+
const newKey = getMessageKey(newThreadId, id);
|
|
1378
|
+
pipeline.set(newKey, updatedMessage);
|
|
1379
|
+
pipeline.set(getMessageIndexKey(id), newThreadId);
|
|
1380
|
+
messageIdToKey[id] = newKey;
|
|
1381
|
+
const newThreadMessagesKey = getThreadMessagesKey(newThreadId);
|
|
1382
|
+
const score = updatedMessage._index !== void 0 ? updatedMessage._index : new Date(updatedMessage.createdAt).getTime();
|
|
1383
|
+
pipeline.zadd(newThreadMessagesKey, {
|
|
1384
|
+
score,
|
|
1385
|
+
member: id
|
|
1386
|
+
});
|
|
1387
|
+
} else pipeline.set(key, updatedMessage);
|
|
1388
|
+
}
|
|
1386
1389
|
}
|
|
1387
1390
|
const now = /* @__PURE__ */ new Date();
|
|
1388
1391
|
for (const threadId of threadIdsToUpdate) if (threadId) {
|
|
@@ -1714,12 +1717,13 @@ var ScoresUpstash = class extends ScoresStorage {
|
|
|
1714
1717
|
const id = crypto.randomUUID();
|
|
1715
1718
|
const createdAt = now;
|
|
1716
1719
|
const updatedAt = now;
|
|
1717
|
-
const
|
|
1720
|
+
const scoreWithId = {
|
|
1718
1721
|
...validatedScore,
|
|
1719
1722
|
id,
|
|
1720
1723
|
createdAt,
|
|
1721
1724
|
updatedAt
|
|
1722
|
-
}
|
|
1725
|
+
};
|
|
1726
|
+
const { key, processedRecord } = processRecord(TABLE_SCORERS, scoreWithId);
|
|
1723
1727
|
try {
|
|
1724
1728
|
await this.client.set(key, processedRecord);
|
|
1725
1729
|
return { score: {
|