@musnows/scriverse 0.7.9 → 0.7.11
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/app.js +10 -0
- package/dist/app.js.map +1 -1
- package/dist/database.js +34 -2
- package/dist/database.js.map +1 -1
- package/dist/public/app.js +181 -15
- package/dist/public/index.html +10 -2
- package/dist/public/styles.css +7 -0
- package/dist/s3-backup.js +47 -10
- package/dist/s3-backup.js.map +1 -1
- package/dist/store.js +33 -2
- package/dist/store.js.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
package/dist/store.js
CHANGED
|
@@ -5258,7 +5258,7 @@ export class Store {
|
|
|
5258
5258
|
COALESCE((SELECT content FROM ai_conversation_messages message WHERE message.conversation_id = conversation.id ORDER BY message.created_at DESC, message.rowid DESC LIMIT 1), '') AS preview
|
|
5259
5259
|
FROM ai_conversations conversation
|
|
5260
5260
|
WHERE conversation.work_id = ?
|
|
5261
|
-
ORDER BY conversation.updated_at DESC, conversation.created_at DESC
|
|
5261
|
+
ORDER BY conversation.is_favorite DESC, conversation.updated_at DESC, conversation.created_at DESC
|
|
5262
5262
|
LIMIT 100`, workId).map((row) => this.mapAiConversation(row));
|
|
5263
5263
|
}
|
|
5264
5264
|
listAiConversationsPage(workId, pagination) {
|
|
@@ -5269,7 +5269,7 @@ export class Store {
|
|
|
5269
5269
|
COALESCE((SELECT content FROM ai_conversation_messages message WHERE message.conversation_id = conversation.id ORDER BY message.created_at DESC, message.rowid DESC LIMIT 1), '') AS preview
|
|
5270
5270
|
FROM ai_conversations conversation
|
|
5271
5271
|
WHERE conversation.work_id = ?
|
|
5272
|
-
ORDER BY conversation.updated_at DESC, conversation.created_at DESC${page.sql}`, workId, ...page.params);
|
|
5272
|
+
ORDER BY conversation.is_favorite DESC, conversation.updated_at DESC, conversation.created_at DESC${page.sql}`, workId, ...page.params);
|
|
5273
5273
|
return paginated(rows.map((row) => this.mapAiConversation(row)), pagination);
|
|
5274
5274
|
}
|
|
5275
5275
|
getAiConversationSummary(conversationId) {
|
|
@@ -5461,6 +5461,36 @@ export class Store {
|
|
|
5461
5461
|
});
|
|
5462
5462
|
return this.getAiConversation(conversationId);
|
|
5463
5463
|
}
|
|
5464
|
+
setAiConversationFavorite(conversationId, isFavorite) {
|
|
5465
|
+
const conversation = this.db.get("SELECT id, work_id, is_favorite FROM ai_conversations WHERE id = ?", conversationId);
|
|
5466
|
+
if (!conversation)
|
|
5467
|
+
throw notFound("AI 对话");
|
|
5468
|
+
const workId = requiredString(conversation, "work_id");
|
|
5469
|
+
const previousFavorite = booleanValue(conversation, "is_favorite");
|
|
5470
|
+
if (previousFavorite === isFavorite)
|
|
5471
|
+
return this.getAiConversationSummary(conversationId);
|
|
5472
|
+
this.db.transaction(() => {
|
|
5473
|
+
this.db.run("UPDATE ai_conversations SET is_favorite = ? WHERE id = ?", isFavorite ? 1 : 0, conversationId);
|
|
5474
|
+
this.audit(workId, "ai-conversation.favorite-updated", "ai-conversation", conversationId, {
|
|
5475
|
+
previousFavorite,
|
|
5476
|
+
isFavorite
|
|
5477
|
+
});
|
|
5478
|
+
});
|
|
5479
|
+
return this.getAiConversationSummary(conversationId);
|
|
5480
|
+
}
|
|
5481
|
+
deleteAiConversation(conversationId) {
|
|
5482
|
+
const conversation = this.db.get("SELECT id, work_id, is_favorite FROM ai_conversations WHERE id = ?", conversationId);
|
|
5483
|
+
if (!conversation)
|
|
5484
|
+
throw notFound("AI 对话");
|
|
5485
|
+
if (booleanValue(conversation, "is_favorite")) {
|
|
5486
|
+
throw new AppError(409, "AI_CONVERSATION_FAVORITED", "收藏的对话不能清理,请先取消收藏");
|
|
5487
|
+
}
|
|
5488
|
+
const workId = requiredString(conversation, "work_id");
|
|
5489
|
+
this.db.transaction(() => {
|
|
5490
|
+
this.db.run("DELETE FROM ai_conversations WHERE id = ?", conversationId);
|
|
5491
|
+
this.audit(workId, "ai-conversation.deleted", "ai-conversation", conversationId, {});
|
|
5492
|
+
});
|
|
5493
|
+
}
|
|
5464
5494
|
setAiConversationRoleplayCharacter(conversationId, characterId) {
|
|
5465
5495
|
const conversation = this.db.get("SELECT * FROM ai_conversations WHERE id = ?", conversationId);
|
|
5466
5496
|
if (!conversation)
|
|
@@ -5813,6 +5843,7 @@ export class Store {
|
|
|
5813
5843
|
id: requiredString(row, "id"),
|
|
5814
5844
|
workId: requiredString(row, "work_id"),
|
|
5815
5845
|
title: requiredString(row, "title"),
|
|
5846
|
+
isFavorite: booleanValue(row, "is_favorite"),
|
|
5816
5847
|
messageCount: numberValue(row, "message_count"),
|
|
5817
5848
|
preview: requiredString(row, "preview"),
|
|
5818
5849
|
compactedMessageCount: numberValue(row, "compacted_message_count"),
|