- 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.
84 lines
3.2 KiB
TypeScript
84 lines
3.2 KiB
TypeScript
import { ipcMain } from 'electron';
|
|
import { createHandler } from '../database/LocalSystem.js';
|
|
import SeriesCharacter, { SeriesCharacterPropsPost, SeriesCharacterListProps, CharacterAttributesResponse } from '../database/models/SeriesCharacter.js';
|
|
|
|
interface GetCharacterListData {
|
|
seriesId: string;
|
|
}
|
|
|
|
interface GetCharacterAttributesData {
|
|
characterId: string;
|
|
}
|
|
|
|
interface AddCharacterData {
|
|
seriesId: string;
|
|
character: SeriesCharacterPropsPost;
|
|
}
|
|
|
|
interface UpdateCharacterData {
|
|
character: SeriesCharacterPropsPost;
|
|
}
|
|
|
|
interface DeleteCharacterData {
|
|
characterId: string;
|
|
}
|
|
|
|
interface AddAttributeData {
|
|
characterId: string;
|
|
type: string;
|
|
name: string;
|
|
}
|
|
|
|
interface DeleteAttributeData {
|
|
attributeId: string;
|
|
}
|
|
|
|
// GET /series/character/list - Get character list
|
|
ipcMain.handle('db:series:character:list', createHandler<GetCharacterListData, SeriesCharacterListProps[]>(
|
|
function(userId: string, data: GetCharacterListData, lang: 'fr' | 'en'): SeriesCharacterListProps[] {
|
|
return SeriesCharacter.getCharacterList(userId, data.seriesId, lang);
|
|
}
|
|
));
|
|
|
|
// GET /series/character/attribute - Get character attributes
|
|
ipcMain.handle('db:series:character:attributes', createHandler<GetCharacterAttributesData, CharacterAttributesResponse>(
|
|
function(userId: string, data: GetCharacterAttributesData, lang: 'fr' | 'en'): CharacterAttributesResponse {
|
|
return SeriesCharacter.getCharacterAttributes(userId, data.characterId, lang);
|
|
}
|
|
));
|
|
|
|
// POST /series/character/add - Add new character
|
|
ipcMain.handle('db:series:character:add', createHandler<AddCharacterData, string>(
|
|
function(userId: string, data: AddCharacterData, lang: 'fr' | 'en'): string {
|
|
return SeriesCharacter.addNewCharacter(userId, data.character, data.seriesId, lang);
|
|
}
|
|
));
|
|
|
|
// PATCH /series/character/update - Update character
|
|
ipcMain.handle('db:series:character:update', createHandler<UpdateCharacterData, boolean>(
|
|
function(userId: string, data: UpdateCharacterData, lang: 'fr' | 'en'): boolean {
|
|
return SeriesCharacter.updateCharacter(userId, data.character, lang);
|
|
}
|
|
));
|
|
|
|
// DELETE /series/character/delete - Delete character
|
|
ipcMain.handle('db:series:character:delete', createHandler<DeleteCharacterData, boolean>(
|
|
function(userId: string, data: DeleteCharacterData, lang: 'fr' | 'en'): boolean {
|
|
return SeriesCharacter.deleteCharacter(userId, data.characterId, lang);
|
|
}
|
|
));
|
|
|
|
// POST /series/character/attribute/add - Add attribute
|
|
ipcMain.handle('db:series:character:attribute:add', createHandler<AddAttributeData, string>(
|
|
function(userId: string, data: AddAttributeData, lang: 'fr' | 'en'): string {
|
|
return SeriesCharacter.addNewAttribute(data.characterId, userId, data.type, data.name, lang);
|
|
}
|
|
));
|
|
|
|
// DELETE /series/character/attribute/delete - Delete attribute
|
|
ipcMain.handle('db:series:character:attribute:delete', createHandler<DeleteAttributeData, boolean>(
|
|
function(userId: string, data: DeleteAttributeData, lang: 'fr' | 'en'): boolean {
|
|
return SeriesCharacter.deleteAttribute(userId, data.attributeId, lang);
|
|
}
|
|
));
|