@voltagent/libsql 2.0.2 → 2.1.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/edge.d.mts +1 -1
- package/dist/edge.d.ts +1 -1
- package/dist/edge.js +38 -3
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +38 -3
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +38 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{vector-core-CKn8FNVK.d.mts → vector-core-J7BkPuy8.d.mts} +2 -0
- package/dist/{vector-core-CKn8FNVK.d.ts → vector-core-J7BkPuy8.d.ts} +2 -0
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -456,8 +456,12 @@ var LibSQLMemoryCore = class {
|
|
|
456
456
|
await this.initialize();
|
|
457
457
|
const messagesTable = `${this.tablePrefix}_messages`;
|
|
458
458
|
const { limit, before, after, roles } = options || {};
|
|
459
|
-
let sql = `
|
|
460
|
-
|
|
459
|
+
let sql = `
|
|
460
|
+
SELECT * FROM (
|
|
461
|
+
SELECT *
|
|
462
|
+
FROM ${messagesTable}
|
|
463
|
+
WHERE conversation_id = ? AND user_id = ?
|
|
464
|
+
`;
|
|
461
465
|
const args = [conversationId, userId];
|
|
462
466
|
if (roles && roles.length > 0) {
|
|
463
467
|
const placeholders = roles.map(() => "?").join(",");
|
|
@@ -472,11 +476,12 @@ var LibSQLMemoryCore = class {
|
|
|
472
476
|
sql += " AND created_at > ?";
|
|
473
477
|
args.push(after.toISOString());
|
|
474
478
|
}
|
|
475
|
-
sql += " ORDER BY created_at
|
|
479
|
+
sql += " ORDER BY created_at DESC";
|
|
476
480
|
if (limit && limit > 0) {
|
|
477
481
|
sql += " LIMIT ?";
|
|
478
482
|
args.push(limit);
|
|
479
483
|
}
|
|
484
|
+
sql += " ) AS subq ORDER BY created_at ASC";
|
|
480
485
|
const result = await this.client.execute({ sql, args });
|
|
481
486
|
return result.rows.map((row) => {
|
|
482
487
|
let parts;
|
|
@@ -590,6 +595,19 @@ var LibSQLMemoryCore = class {
|
|
|
590
595
|
});
|
|
591
596
|
}
|
|
592
597
|
}
|
|
598
|
+
async deleteMessages(messageIds, userId, conversationId) {
|
|
599
|
+
await this.initialize();
|
|
600
|
+
if (messageIds.length === 0) {
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
const messagesTable = `${this.tablePrefix}_messages`;
|
|
604
|
+
const placeholders = messageIds.map(() => "?").join(",");
|
|
605
|
+
const sql = `DELETE FROM ${messagesTable} WHERE conversation_id = ? AND user_id = ? AND message_id IN (${placeholders})`;
|
|
606
|
+
await this.client.execute({
|
|
607
|
+
sql,
|
|
608
|
+
args: [conversationId, userId, ...messageIds]
|
|
609
|
+
});
|
|
610
|
+
}
|
|
593
611
|
// ============================================================================
|
|
594
612
|
// Conversation Operations
|
|
595
613
|
// ============================================================================
|
|
@@ -702,6 +720,23 @@ var LibSQLMemoryCore = class {
|
|
|
702
720
|
updatedAt: row.updated_at
|
|
703
721
|
}));
|
|
704
722
|
}
|
|
723
|
+
async countConversations(options) {
|
|
724
|
+
await this.initialize();
|
|
725
|
+
const conversationsTable = `${this.tablePrefix}_conversations`;
|
|
726
|
+
let sql = `SELECT COUNT(*) as count FROM ${conversationsTable} WHERE 1=1`;
|
|
727
|
+
const args = [];
|
|
728
|
+
if (options.userId) {
|
|
729
|
+
sql += " AND user_id = ?";
|
|
730
|
+
args.push(options.userId);
|
|
731
|
+
}
|
|
732
|
+
if (options.resourceId) {
|
|
733
|
+
sql += " AND resource_id = ?";
|
|
734
|
+
args.push(options.resourceId);
|
|
735
|
+
}
|
|
736
|
+
const result = await this.client.execute({ sql, args });
|
|
737
|
+
const count = Number(result.rows[0]?.count ?? 0);
|
|
738
|
+
return Number.isNaN(count) ? 0 : count;
|
|
739
|
+
}
|
|
705
740
|
async updateConversation(id, updates) {
|
|
706
741
|
await this.initialize();
|
|
707
742
|
const conversationsTable = `${this.tablePrefix}_conversations`;
|