Close DDD refactor and remove generated asset proxy

This commit is contained in:
kdletters
2026-05-02 00:27:22 +08:00
parent fd08262bf0
commit 9d9913095d
605 changed files with 11811 additions and 10106 deletions

View File

@@ -0,0 +1,92 @@
/* @vitest-environment jsdom */
import { beforeEach, describe, expect, it, vi } from 'vitest';
const { requestJsonMock } = vi.hoisted(() => ({
requestJsonMock: vi.fn(),
}));
import {
generateRpgWorldLandmark,
generateRpgWorldSceneImage,
generateRpgWorldSceneNpc,
} from './rpgCreationAssetClient';
vi.mock('../apiClient', () => ({
requestJson: requestJsonMock,
}));
describe('rpgCreationAssetClient', () => {
beforeEach(() => {
requestJsonMock.mockReset();
requestJsonMock.mockResolvedValue({
entity: { id: 'landmark-1', name: '雾港' },
imageSrc: '/generated-custom-world-scenes/profile/scene/image.webp',
npc: { id: 'npc-1', name: '守灯人' },
});
});
it('posts scene images to the runtime custom world asset route', async () => {
await generateRpgWorldSceneImage({
profile: {
id: 'profile-1',
name: '雾海群岛',
subtitle: '潮雾旧账',
summary: '雾海群岛上有一座旧港。',
tone: '潮湿、悬疑',
playerGoal: '查明旧港的灯火',
settingText: '海雾与旧账缠在一起。',
},
landmark: {
id: 'scene-1',
name: '旧港',
description: '潮湿旧港的夜景',
},
userPrompt: '潮湿旧港的夜景',
});
expect(requestJsonMock).toHaveBeenCalledWith(
'/api/runtime/custom-world/scene-image',
expect.objectContaining({
method: 'POST',
headers: { 'Content-Type': 'application/json' },
}),
'生成自定义世界场景图失败',
);
});
it('posts generated entities to the runtime custom world asset route', async () => {
await generateRpgWorldLandmark({
profile: {
id: 'profile-1',
name: '雾海群岛',
} as never,
});
expect(requestJsonMock).toHaveBeenCalledWith(
'/api/runtime/custom-world/entity',
expect.objectContaining({
method: 'POST',
}),
'生成场景失败',
);
});
it('posts scene npcs to the runtime custom world asset route', async () => {
await generateRpgWorldSceneNpc({
profile: {
id: 'profile-1',
name: '雾海群岛',
} as never,
landmarkId: 'scene-1',
});
expect(requestJsonMock).toHaveBeenCalledWith(
'/api/runtime/custom-world/scene-npc',
expect.objectContaining({
method: 'POST',
}),
'生成场景 NPC 失败',
);
});
});

View File

@@ -16,7 +16,7 @@ import {
} from '../customWorldCoverAssetService';
import { requestRpgCreationPostJson } from './rpgCreationRequestHelpers';
const RPG_CREATION_ASSET_API_BASE = '/api/custom-world';
const RPG_CREATION_ASSET_API_BASE = '/api/runtime/custom-world';
export type RpgCreationHistoryAssetKind = 'character_visual' | 'scene_image';