@musnows/scriverse 0.5.5 → 0.5.6

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/ai.js CHANGED
@@ -3934,7 +3934,7 @@ export class AiManager {
3934
3934
  this.store.db.run(`INSERT INTO relationship_source_index_queue(work_id, source_type, source_id, queued_at)
3935
3935
  SELECT chapter.work_id, 'chapter-outline', outline.chapter_id, ?
3936
3936
  FROM chapter_outlines outline JOIN chapters chapter ON chapter.id = outline.chapter_id
3937
- WHERE chapter.work_id = ?
3937
+ WHERE chapter.work_id = ? AND chapter.deleted_at IS NULL
3938
3938
  ON CONFLICT(work_id, source_type, source_id) DO UPDATE SET queued_at = excluded.queued_at`, timestamp, workId);
3939
3939
  this.store.db.run(`INSERT INTO relationship_source_index_state(work_id, status, generation, error, updated_at)
3940
3940
  VALUES (?, 'queued', 0, '', ?)
@@ -4005,7 +4005,7 @@ export class AiManager {
4005
4005
  }
4006
4006
  }
4007
4007
  indexRelationshipChapter(workId, chapterId) {
4008
- const chapter = this.store.db.get("SELECT id FROM chapters WHERE id = ? AND work_id = ?", chapterId, workId);
4008
+ const chapter = this.store.db.get("SELECT id FROM chapters WHERE id = ? AND work_id = ? AND deleted_at IS NULL", chapterId, workId);
4009
4009
  if (!chapter)
4010
4010
  return;
4011
4011
  const paragraphs = this.store.db.all("SELECT id, search_content FROM chapter_paragraph_search WHERE chapter_id = ? ORDER BY paragraph_order", chapterId);
@@ -4055,10 +4055,10 @@ export class AiManager {
4055
4055
  const volume = this.store.getVolume(scope.volumeId);
4056
4056
  if (String(volume.workId) !== workId)
4057
4057
  throw new AppError(400, "VOLUME_WORK_MISMATCH", "分卷不属于当前作品");
4058
- return new Set(this.store.db.all(`SELECT id FROM chapters WHERE work_id = ? AND volume_id = ?
4058
+ return new Set(this.store.db.all(`SELECT id FROM chapters WHERE work_id = ? AND volume_id = ? AND deleted_at IS NULL
4059
4059
  AND excluded_from_analysis = 0 AND chapter_type <> '作者的话'`, workId, scope.volumeId).map((row) => String(row.id)));
4060
4060
  }
4061
- return new Set(this.store.db.all(`SELECT id FROM chapters WHERE work_id = ? AND excluded_from_analysis = 0 AND chapter_type <> '作者的话'`, workId).map((row) => String(row.id)));
4061
+ return new Set(this.store.db.all(`SELECT id FROM chapters WHERE work_id = ? AND deleted_at IS NULL AND excluded_from_analysis = 0 AND chapter_type <> '作者的话'`, workId).map((row) => String(row.id)));
4062
4062
  }
4063
4063
  relationshipIndexedSource(workId, sourceType, sourceId) {
4064
4064
  if (sourceType === "chapter") {
@@ -4132,14 +4132,14 @@ export class AiManager {
4132
4132
  ? {
4133
4133
  sql: `AND EXISTS (
4134
4134
  SELECT 1 FROM chapters chapter WHERE chapter.id = paragraph.chapter_id
4135
- AND chapter.volume_id = ? AND chapter.excluded_from_analysis = 0 AND chapter.chapter_type <> '作者的话'
4135
+ AND chapter.deleted_at IS NULL AND chapter.volume_id = ? AND chapter.excluded_from_analysis = 0 AND chapter.chapter_type <> '作者的话'
4136
4136
  )`,
4137
4137
  params: [scope.volumeId ?? ""]
4138
4138
  }
4139
4139
  : {
4140
4140
  sql: `AND EXISTS (
4141
4141
  SELECT 1 FROM chapters chapter WHERE chapter.id = paragraph.chapter_id
4142
- AND chapter.excluded_from_analysis = 0 AND chapter.chapter_type <> '作者的话'
4142
+ AND chapter.deleted_at IS NULL AND chapter.excluded_from_analysis = 0 AND chapter.chapter_type <> '作者的话'
4143
4143
  )`,
4144
4144
  params: []
4145
4145
  };
@@ -4602,7 +4602,7 @@ export class AiManager {
4602
4602
  }
4603
4603
  }
4604
4604
  const chapterOrder = new Map(this.store.db.all(`SELECT chapter.id FROM chapters chapter JOIN volumes volume ON volume.id = chapter.volume_id
4605
- WHERE chapter.work_id = ? ORDER BY volume.sort_order, chapter.sort_order`, workId).map((row, index) => [String(row.id), index]));
4605
+ WHERE chapter.work_id = ? AND chapter.deleted_at IS NULL ORDER BY volume.sort_order, chapter.sort_order`, workId).map((row, index) => [String(row.id), index]));
4606
4606
  chapters.sort((left, right) => (chapterOrder.get(String(left.id)) ?? Number.MAX_SAFE_INTEGER) - (chapterOrder.get(String(right.id)) ?? Number.MAX_SAFE_INTEGER));
4607
4607
  settings.sort((left, right) => `${left.sourceType}:${left.id}`.localeCompare(`${right.sourceType}:${right.id}`, "zh-CN"));
4608
4608
  const matchKinds = {};