Introduce series management functionality and repository updates
- 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.
This commit is contained in:
@@ -43,6 +43,7 @@ export interface WorldProps {
|
||||
ethnicGroups: WorldElement[];
|
||||
socialClasses: WorldElement[];
|
||||
importantCharacters: WorldElement[];
|
||||
seriesWorldId?: string | null;
|
||||
}
|
||||
|
||||
export interface WorldListResponse {
|
||||
@@ -97,7 +98,7 @@ export default class World {
|
||||
* @returns The unique identifier of the newly created world
|
||||
* @throws Error if a world with the same name already exists for this book
|
||||
*/
|
||||
public static addNewWorld(userId: string, bookId: string, worldName: string, lang: 'fr' | 'en' = 'fr', existingWorldId?: string): string {
|
||||
public static addNewWorld(userId: string, bookId: string, worldName: string, lang: 'fr' | 'en' = 'fr', existingWorldId?: string, seriesWorldId: string | null = null): string {
|
||||
const userEncryptionKey: string = getUserEncryptionKey(userId);
|
||||
const hashedWorldName: string = System.hashElement(worldName);
|
||||
if (!existingWorldId && WorldRepository.checkWorldExist(userId, bookId, hashedWorldName, lang)) {
|
||||
@@ -105,7 +106,7 @@ export default class World {
|
||||
}
|
||||
const encryptedWorldName: string = System.encryptDataWithUserKey(worldName, userEncryptionKey);
|
||||
const worldId: string = existingWorldId || System.createUniqueId();
|
||||
return WorldRepository.insertNewWorld(worldId, userId, bookId, encryptedWorldName, hashedWorldName, lang);
|
||||
return WorldRepository.insertNewWorld(worldId, userId, bookId, encryptedWorldName, hashedWorldName, lang, seriesWorldId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,6 +148,7 @@ export default class World {
|
||||
ethnicGroups: [],
|
||||
socialClasses: [],
|
||||
importantCharacters: [],
|
||||
seriesWorldId: queryRow.series_world_id || null,
|
||||
};
|
||||
|
||||
worlds.push(newWorld);
|
||||
@@ -228,7 +230,7 @@ export default class World {
|
||||
}));
|
||||
});
|
||||
|
||||
WorldRepository.updateWorld(userId, world.id, encryptedName, System.hashElement(world.name), encryptedHistory, encryptedPolitics, encryptedEconomy, encryptedReligion, encryptedLanguages, System.timeStampInSeconds(), lang);
|
||||
WorldRepository.updateWorld(userId, world.id, encryptedName, System.hashElement(world.name), encryptedHistory, encryptedPolitics, encryptedEconomy, encryptedReligion, encryptedLanguages, System.timeStampInSeconds(), lang, world.seriesWorldId || null);
|
||||
return WorldRepository.updateWorldElements(userId, elementsToUpdate, lang);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user