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:
natreex
2026-01-26 19:57:56 -05:00
parent 2359638cb0
commit cec5830360
35 changed files with 5483 additions and 203 deletions

View File

@@ -14,11 +14,11 @@ export interface CharacterPropsPost {
name: string;
lastName: string;
nickname: string;
age: string;
age: number | null;
gender: string;
species: string;
nationality: string;
status: 'alive' | 'dead' | 'unknown';
status: string;
category: CharacterCategory;
title: string;
image: string;
@@ -48,6 +48,7 @@ export interface CharacterPropsPost {
residence?: string;
notes?: string;
color?: string;
seriesCharacterId?: string | null;
}
@@ -56,7 +57,7 @@ export interface CharacterProps {
name: string;
lastName: string;
nickname: string;
age: string;
age: number | null;
gender: string;
species: string;
nationality: string;
@@ -72,6 +73,7 @@ export interface CharacterProps {
residence: string;
notes: string;
color: string;
seriesCharacterId: string | null;
}
export interface CharacterListResponse {
@@ -83,24 +85,24 @@ export interface CompleteCharacterProps {
id?: string;
name: string;
lastName: string;
nickname?: string;
age?: string;
gender?: string;
species?: string;
nationality?: string;
status?: string;
nickname: string;
age: number | null;
gender: string;
species: string;
nationality: string;
status: string;
title: string;
category: string;
image?: string;
role: string;
biography: string;
history: string;
speechPattern?: string;
catchphrase?: string;
residence?: string;
notes?: string;
color?: string;
[key: string]: Attribute[] | string | undefined;
speechPattern: string;
catchphrase: string;
residence: string;
notes: string;
color: string;
[key: string]: Attribute[] | string | number | null | undefined;
}
export interface Attribute {
@@ -152,7 +154,7 @@ export default class Character {
name: encryptedCharacter.first_name ? System.decryptDataWithUserKey(encryptedCharacter.first_name, userEncryptionKey) : '',
lastName: encryptedCharacter.last_name ? System.decryptDataWithUserKey(encryptedCharacter.last_name, userEncryptionKey) : '',
nickname: encryptedCharacter.nickname ? System.decryptDataWithUserKey(encryptedCharacter.nickname, userEncryptionKey) : '',
age: encryptedCharacter.age ? System.decryptDataWithUserKey(encryptedCharacter.age, userEncryptionKey) : '',
age: encryptedCharacter.age ? parseInt(System.decryptDataWithUserKey(encryptedCharacter.age, userEncryptionKey), 10) : null,
gender: encryptedCharacter.gender ? System.decryptDataWithUserKey(encryptedCharacter.gender, userEncryptionKey) : '',
species: encryptedCharacter.species ? System.decryptDataWithUserKey(encryptedCharacter.species, userEncryptionKey) : '',
nationality: encryptedCharacter.nationality ? System.decryptDataWithUserKey(encryptedCharacter.nationality, userEncryptionKey) : '',
@@ -168,6 +170,7 @@ export default class Character {
residence: encryptedCharacter.residence ? System.decryptDataWithUserKey(encryptedCharacter.residence, userEncryptionKey) : '',
notes: encryptedCharacter.notes ? System.decryptDataWithUserKey(encryptedCharacter.notes, userEncryptionKey) : '',
color: encryptedCharacter.color ? System.decryptDataWithUserKey(encryptedCharacter.color, userEncryptionKey) : '',
seriesCharacterId: encryptedCharacter.series_character_id || null,
})
}
return { characters: decryptedCharacterList, enabled };
@@ -191,7 +194,7 @@ export default class Character {
firstName: System.encryptDataWithUserKey(character.name, userEncryptionKey),
lastName: System.encryptDataWithUserKey(character.lastName, userEncryptionKey),
nickname: System.encryptDataWithUserKey(character.nickname || '', userEncryptionKey),
age: System.encryptDataWithUserKey(character.age || '', userEncryptionKey),
age: character.age !== null ? System.encryptDataWithUserKey(String(character.age), userEncryptionKey) : '',
gender: System.encryptDataWithUserKey(character.gender || '', userEncryptionKey),
species: System.encryptDataWithUserKey(character.species || '', userEncryptionKey),
nationality: System.encryptDataWithUserKey(character.nationality || '', userEncryptionKey),
@@ -209,7 +212,7 @@ export default class Character {
color: System.encryptDataWithUserKey(character.color || '', userEncryptionKey),
};
CharacterRepo.addNewCharacter(userId, characterId, characterData, bookId, lang);
CharacterRepo.addNewCharacter(userId, characterId, characterData, bookId, lang, character.seriesCharacterId || null);
const characterPropertyKeys: string[] = Object.keys(character);
for (const propertyKey of characterPropertyKeys) {
if (Array.isArray(character[propertyKey as keyof CharacterPropsPost])) {
@@ -244,7 +247,7 @@ export default class Character {
firstName: System.encryptDataWithUserKey(character.name, userEncryptionKey),
lastName: System.encryptDataWithUserKey(character.lastName, userEncryptionKey),
nickname: System.encryptDataWithUserKey(character.nickname || '', userEncryptionKey),
age: System.encryptDataWithUserKey(character.age || '', userEncryptionKey),
age: character.age !== null ? System.encryptDataWithUserKey(String(character.age), userEncryptionKey) : '',
gender: System.encryptDataWithUserKey(character.gender || '', userEncryptionKey),
species: System.encryptDataWithUserKey(character.species || '', userEncryptionKey),
nationality: System.encryptDataWithUserKey(character.nationality || '', userEncryptionKey),
@@ -262,7 +265,7 @@ export default class Character {
color: System.encryptDataWithUserKey(character.color || '', userEncryptionKey),
};
return CharacterRepo.updateCharacter(userId, character.id, characterData, System.timeStampInSeconds(), lang);
return CharacterRepo.updateCharacter(userId, character.id, characterData, System.timeStampInSeconds(), lang, character.seriesCharacterId || null);
}
/**
@@ -370,7 +373,7 @@ export default class Character {
name: encryptedCharacter.first_name ? System.decryptDataWithUserKey(encryptedCharacter.first_name, userEncryptionKey) : '',
lastName: encryptedCharacter.last_name ? System.decryptDataWithUserKey(encryptedCharacter.last_name, userEncryptionKey) : '',
nickname: encryptedCharacter.nickname ? System.decryptDataWithUserKey(encryptedCharacter.nickname as string, userEncryptionKey) : '',
age: encryptedCharacter.age ? System.decryptDataWithUserKey(encryptedCharacter.age as string, userEncryptionKey) : '',
age: encryptedCharacter.age ? parseInt(System.decryptDataWithUserKey(encryptedCharacter.age as string, userEncryptionKey), 10) : null,
gender: encryptedCharacter.gender ? System.decryptDataWithUserKey(encryptedCharacter.gender as string, userEncryptionKey) : '',
species: encryptedCharacter.species ? System.decryptDataWithUserKey(encryptedCharacter.species as string, userEncryptionKey) : '',
nationality: encryptedCharacter.nationality ? System.decryptDataWithUserKey(encryptedCharacter.nationality as string, userEncryptionKey) : '',
@@ -442,11 +445,22 @@ export default class Character {
uniqueCharactersMap.set(characterIdentifier, {
name: character.name,
lastName: character.lastName,
category: character.category,
nickname: character.nickname,
age: character.age,
gender: character.gender,
species: character.species,
nationality: character.nationality,
status: character.status,
title: character.title,
category: character.category,
role: character.role,
biography: character.biography,
history: character.history
history: character.history,
speechPattern: character.speechPattern,
catchphrase: character.catchphrase,
residence: character.residence,
notes: character.notes,
color: character.color
});
}
@@ -472,7 +486,7 @@ export default class Character {
});
Object.keys(character).forEach((propertyKey: string): void => {
const propertyValue: string | Attribute[] | undefined = character[propertyKey];
const propertyValue = character[propertyKey];
if (Array.isArray(propertyValue) && propertyValue.length > 0) {
const capitalizedPropertyKey: string = propertyKey.charAt(0).toUpperCase() + propertyKey.slice(1);
const formattedAttributeValues: string = propertyValue.map((attributeItem: Attribute) => attributeItem.name).join(', ');