1
This commit is contained in:
@@ -4,8 +4,9 @@ import path from 'node:path';
|
||||
import sharp from 'sharp';
|
||||
|
||||
import { createDatabase } from '../db.js';
|
||||
import { RuntimeRepository } from '../repositories/runtimeRepository.js';
|
||||
import { loadConfig } from '../config.js';
|
||||
import { RpgAgentSessionRepository } from '../repositories/RpgAgentSessionRepository.js';
|
||||
import { RpgWorldProfileRepository } from '../repositories/RpgWorldProfileRepository.js';
|
||||
import { CustomWorldAgentSessionStore } from '../services/customWorldAgentSessionStore.js';
|
||||
|
||||
type RecordValue = Record<string, unknown>;
|
||||
@@ -80,15 +81,18 @@ async function main() {
|
||||
const db = await createDatabase(config);
|
||||
|
||||
try {
|
||||
const runtimeRepository = new RuntimeRepository(db);
|
||||
const sessionStore = new CustomWorldAgentSessionStore(runtimeRepository);
|
||||
const rpgAgentSessionRepository = new RpgAgentSessionRepository(db);
|
||||
const rpgWorldProfileRepository = new RpgWorldProfileRepository(db);
|
||||
const sessionStore = new CustomWorldAgentSessionStore(
|
||||
rpgAgentSessionRepository,
|
||||
);
|
||||
const session = await sessionStore.getSnapshot(userId, sessionId);
|
||||
if (!session || !isRecord(session.draftProfile)) {
|
||||
throw new Error('未找到目标世界草稿 session,无法同步历史保存档案。');
|
||||
}
|
||||
|
||||
const savedProfileEntry = (
|
||||
await runtimeRepository.listCustomWorldProfiles(userId)
|
||||
await rpgWorldProfileRepository.listOwnProfiles(userId)
|
||||
).find((entry) => entry.profileId === profileId);
|
||||
if (!savedProfileEntry) {
|
||||
throw new Error('未找到目标 saved profile,无法同步历史保存档案。');
|
||||
@@ -200,7 +204,7 @@ async function main() {
|
||||
nextProfile.landmarks = landmarks;
|
||||
nextProfile.sceneChapterBlueprints = sceneChapterBlueprints;
|
||||
|
||||
const updatedEntry = await runtimeRepository.upsertCustomWorldProfile(
|
||||
const updatedEntry = await rpgWorldProfileRepository.upsertOwnProfile(
|
||||
userId,
|
||||
profileId,
|
||||
nextProfile,
|
||||
|
||||
Reference in New Issue
Block a user