Add ipc/chapter.ipc.ts to handle chapter-related database interactions
- Introduce IPC handlers in `ipc/chapter.ipc.ts` for chapter CRUD, content management, and related operations. - Register chapter IPC module in `main.ts` for application-wide access. - Enhance type definitions for chapter functionalities, improving code consistency. - Refactor `ipc/book.ipc.ts` to include new `UpdateStoryData` interface and additional story update handler.
This commit is contained in:
@@ -31,6 +31,12 @@ interface StoryData {
|
||||
issues: Issue[];
|
||||
}
|
||||
|
||||
interface UpdateStoryData {
|
||||
bookId: string;
|
||||
acts: Act[];
|
||||
mainChapters: any[]; // ChapterProps[] from your API
|
||||
}
|
||||
|
||||
interface CreateBookData {
|
||||
title: string;
|
||||
subTitle: string | null;
|
||||
@@ -72,10 +78,10 @@ interface SetAIGuideLineData {
|
||||
bookId: string;
|
||||
narrativeType: number;
|
||||
dialogueType: number;
|
||||
globalResume: string;
|
||||
atmosphere: string;
|
||||
verbeTense: number;
|
||||
langue: number;
|
||||
plotSummary: string;
|
||||
toneAtmosphere: string;
|
||||
verbTense: number;
|
||||
language: number;
|
||||
themes: string;
|
||||
}
|
||||
|
||||
@@ -147,6 +153,14 @@ ipcMain.handle('db:book:story:get', createHandler<string, StoryData>(
|
||||
)
|
||||
);
|
||||
|
||||
// POST /book/story - Update story (acts + mainChapters)
|
||||
ipcMain.handle('db:book:story:update', createHandler<UpdateStoryData, boolean>(
|
||||
function(userId: string, data: UpdateStoryData, lang: 'fr' | 'en'):boolean {
|
||||
return Book.updateStory(userId, data.bookId, data.acts, data.mainChapters, lang);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// POST /book/add - Create new book
|
||||
ipcMain.handle('db:book:create', createHandler<CreateBookData, string>(
|
||||
function(userId: string, data: CreateBookData, lang: 'fr' | 'en') {
|
||||
@@ -278,7 +292,7 @@ ipcMain.handle('db:book:delete', createHandler<string, boolean>(
|
||||
// GET /book/ai/guideline - Get AI guideline
|
||||
ipcMain.handle('db:book:guideline:ai:get', createHandler<string, GuideLineAI>(
|
||||
function(userId: string, bookId: string, lang: 'fr' | 'en') {
|
||||
return Book.getGuideLineAI(bookId, userId, lang);
|
||||
return Book.getGuideLineAI(userId, bookId, lang);
|
||||
}
|
||||
)
|
||||
);
|
||||
@@ -287,17 +301,30 @@ ipcMain.handle('db:book:guideline:ai:get', createHandler<string, GuideLineAI>(
|
||||
ipcMain.handle('db:book:guideline:ai:set', createHandler<SetAIGuideLineData, boolean>(
|
||||
function(userId: string, data: SetAIGuideLineData, lang: 'fr' | 'en') {
|
||||
return Book.setAIGuideLine(
|
||||
data.bookId,
|
||||
userId,
|
||||
data.bookId,
|
||||
data.narrativeType,
|
||||
data.dialogueType,
|
||||
data.globalResume,
|
||||
data.atmosphere,
|
||||
data.verbeTense,
|
||||
data.langue,
|
||||
data.plotSummary,
|
||||
data.toneAtmosphere,
|
||||
data.verbTense,
|
||||
data.language,
|
||||
data.themes,
|
||||
lang
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// PUT /book/world/update - Update world
|
||||
interface UpdateWorldData {
|
||||
bookId: string;
|
||||
world: WorldProps;
|
||||
}
|
||||
|
||||
ipcMain.handle('db:book:world:update', createHandler<UpdateWorldData, boolean>(
|
||||
function(userId: string, data: UpdateWorldData, lang: 'fr' | 'en') {
|
||||
return Book.updateWorld(userId, data.world, lang);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user