- Added `series-world.repo.ts` to handle database operations related to series worlds and their elements. - Implemented `series-sync.repo.ts` for managing synchronization between books and series. - Expanded `spell.ipc.ts` data models to include `seriesSpellId` for spell synchronization. - Refactored `insertSpellTag` method in `spelltag.repo.ts` for improved error handling and logic clarity.
86 lines
3.1 KiB
TypeScript
86 lines
3.1 KiB
TypeScript
import { ipcMain } from 'electron';
|
|
import { createHandler } from '../database/LocalSystem.js';
|
|
import SeriesLocation, { SeriesLocationListProps } from '../database/models/SeriesLocation.js';
|
|
|
|
interface GetLocationListData {
|
|
seriesId: string;
|
|
}
|
|
|
|
interface AddLocationSectionData {
|
|
seriesId: string;
|
|
name: string;
|
|
}
|
|
|
|
interface AddElementData {
|
|
locationId: string;
|
|
name: string;
|
|
description?: string;
|
|
}
|
|
|
|
interface AddSubElementData {
|
|
elementId: string;
|
|
name: string;
|
|
description?: string;
|
|
}
|
|
|
|
interface DeleteLocationData {
|
|
locationId: string;
|
|
}
|
|
|
|
interface DeleteElementData {
|
|
elementId: string;
|
|
}
|
|
|
|
interface DeleteSubElementData {
|
|
subElementId: string;
|
|
}
|
|
|
|
// GET /series/location/list - Get location list
|
|
ipcMain.handle('db:series:location:list', createHandler<GetLocationListData, SeriesLocationListProps[]>(
|
|
function(userId: string, data: GetLocationListData, lang: 'fr' | 'en'): SeriesLocationListProps[] {
|
|
return SeriesLocation.getLocationList(userId, data.seriesId, lang);
|
|
}
|
|
));
|
|
|
|
// POST /series/location/section/add - Add location section
|
|
ipcMain.handle('db:series:location:section:add', createHandler<AddLocationSectionData, string>(
|
|
function(userId: string, data: AddLocationSectionData, lang: 'fr' | 'en'): string {
|
|
return SeriesLocation.addLocationSection(userId, data.seriesId, data.name, lang);
|
|
}
|
|
));
|
|
|
|
// POST /series/location/element/add - Add element
|
|
ipcMain.handle('db:series:location:element:add', createHandler<AddElementData, string>(
|
|
function(userId: string, data: AddElementData, lang: 'fr' | 'en'): string {
|
|
return SeriesLocation.addElement(userId, data.locationId, data.name, lang, data.description);
|
|
}
|
|
));
|
|
|
|
// POST /series/location/sub-element/add - Add sub-element
|
|
ipcMain.handle('db:series:location:subelement:add', createHandler<AddSubElementData, string>(
|
|
function(userId: string, data: AddSubElementData, lang: 'fr' | 'en'): string {
|
|
return SeriesLocation.addSubElement(userId, data.elementId, data.name, lang, data.description);
|
|
}
|
|
));
|
|
|
|
// DELETE /series/location/delete - Delete location
|
|
ipcMain.handle('db:series:location:delete', createHandler<DeleteLocationData, boolean>(
|
|
function(userId: string, data: DeleteLocationData, lang: 'fr' | 'en'): boolean {
|
|
return SeriesLocation.deleteLocation(userId, data.locationId, lang);
|
|
}
|
|
));
|
|
|
|
// DELETE /series/location/element/delete - Delete element
|
|
ipcMain.handle('db:series:location:element:delete', createHandler<DeleteElementData, boolean>(
|
|
function(userId: string, data: DeleteElementData, lang: 'fr' | 'en'): boolean {
|
|
return SeriesLocation.deleteElement(userId, data.elementId, lang);
|
|
}
|
|
));
|
|
|
|
// DELETE /series/location/sub-element/delete - Delete sub-element
|
|
ipcMain.handle('db:series:location:subelement:delete', createHandler<DeleteSubElementData, boolean>(
|
|
function(userId: string, data: DeleteSubElementData, lang: 'fr' | 'en'): boolean {
|
|
return SeriesLocation.deleteSubElement(userId, data.subElementId, lang);
|
|
}
|
|
));
|