@mastra/libsql 1.23.0-alpha.2 → 1.23.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 +27 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/notifications/index.d.ts +6 -1
- package/dist/storage/domains/notifications/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -9937,6 +9937,8 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
9937
9937
|
};
|
|
9938
9938
|
//#endregion
|
|
9939
9939
|
//#region src/storage/domains/notifications/index.ts
|
|
9940
|
+
/** Ids per UPDATE statement — keeps bind parameters well under SQLite's per-statement limit. */
|
|
9941
|
+
const BULK_ID_BATCH_SIZE = 500;
|
|
9940
9942
|
const statusTimestamp = (status, now) => {
|
|
9941
9943
|
if (status === "delivered") return { deliveredAt: now };
|
|
9942
9944
|
if (status === "seen") return { seenAt: now };
|
|
@@ -10237,6 +10239,31 @@ var NotificationsLibSQL = class NotificationsLibSQL extends NotificationsStorage
|
|
|
10237
10239
|
if (!updated) throw new Error(`Notification ${input.id} was not found for thread ${input.threadId}`);
|
|
10238
10240
|
return updated;
|
|
10239
10241
|
}
|
|
10242
|
+
async updateNotificationsStatus(input) {
|
|
10243
|
+
const ids = Array.from(new Set(input.ids));
|
|
10244
|
+
if (ids.length === 0) return [];
|
|
10245
|
+
const now = /* @__PURE__ */ new Date();
|
|
10246
|
+
const assignments = {
|
|
10247
|
+
status: input.status,
|
|
10248
|
+
updatedAt: now.toISOString()
|
|
10249
|
+
};
|
|
10250
|
+
for (const [column, value] of Object.entries(statusTimestamp(input.status, now))) assignments[column] = value.toISOString();
|
|
10251
|
+
const setClause = Object.keys(assignments).map((column) => `"${column}" = ?`).join(", ");
|
|
10252
|
+
const updated = [];
|
|
10253
|
+
for (let offset = 0; offset < ids.length; offset += BULK_ID_BATCH_SIZE) {
|
|
10254
|
+
const batch = ids.slice(offset, offset + BULK_ID_BATCH_SIZE);
|
|
10255
|
+
const result = await this.#db.executeWriteOperationWithRetry(() => withClientWriteLock(this.#client, () => this.#client.execute({
|
|
10256
|
+
sql: `UPDATE "${TABLE_NOTIFICATIONS}" SET ${setClause} WHERE "threadId" = ? AND "id" IN (${batch.map(() => "?").join(", ")}) RETURNING ${buildSelectColumns(TABLE_NOTIFICATIONS)}`,
|
|
10257
|
+
args: [
|
|
10258
|
+
...Object.values(assignments),
|
|
10259
|
+
input.threadId,
|
|
10260
|
+
...batch
|
|
10261
|
+
]
|
|
10262
|
+
})), `bulk update notification status in table ${TABLE_NOTIFICATIONS}`);
|
|
10263
|
+
for (const row of result.rows ?? []) updated.push(rowToNotification(row));
|
|
10264
|
+
}
|
|
10265
|
+
return updated;
|
|
10266
|
+
}
|
|
10240
10267
|
async findCoalescable(input) {
|
|
10241
10268
|
if (!input.dedupeKey && !input.coalesceKey) return void 0;
|
|
10242
10269
|
const agentId = input.agentId ?? null;
|