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:
@@ -39,6 +39,10 @@ import UserRepo from "../repositories/user.repository.js";
|
||||
|
||||
export interface SyncedBookTools {
|
||||
lastUpdate: number;
|
||||
charactersEnabled: boolean;
|
||||
worldsEnabled: boolean;
|
||||
locationsEnabled: boolean;
|
||||
spellsEnabled: boolean;
|
||||
}
|
||||
|
||||
export interface BookToolsSettings {
|
||||
@@ -55,11 +59,12 @@ export interface BookProps {
|
||||
title: string;
|
||||
subTitle?: string;
|
||||
summary?: string;
|
||||
serieId?: number;
|
||||
desiredReleaseDate?: string;
|
||||
desiredWordCount?: number;
|
||||
serieId?: number | null;
|
||||
seriesId?: string | null;
|
||||
desiredReleaseDate?: string | null;
|
||||
desiredWordCount?: number | null;
|
||||
wordCount?: number;
|
||||
coverImage?: string;
|
||||
coverImage?: string | null;
|
||||
bookMeta?: string;
|
||||
tools?: BookToolsSettings;
|
||||
}
|
||||
@@ -145,6 +150,234 @@ export interface CompleteBookData {
|
||||
chapters: CompleteChapterContent[];
|
||||
}
|
||||
|
||||
// ===== SERIES TABLE INTERFACES (for sync) =====
|
||||
|
||||
export interface SeriesTable {
|
||||
series_id: string;
|
||||
user_id: string;
|
||||
name: string;
|
||||
hashed_name: string;
|
||||
description: string | null;
|
||||
cover_image: string | null;
|
||||
last_update: number;
|
||||
}
|
||||
|
||||
export interface SeriesBooksTable {
|
||||
series_id: string;
|
||||
book_id: string;
|
||||
book_order: number;
|
||||
last_update: number;
|
||||
}
|
||||
|
||||
export interface SeriesCharactersTable {
|
||||
character_id: string;
|
||||
series_id: string;
|
||||
user_id: string;
|
||||
first_name: string;
|
||||
last_name: string | null;
|
||||
nickname: string | null;
|
||||
age: number | null;
|
||||
gender: string | null;
|
||||
species: string | null;
|
||||
nationality: string | null;
|
||||
status: string | null;
|
||||
title: string | null;
|
||||
category: string;
|
||||
image: string | null;
|
||||
role: string | null;
|
||||
biography: string | null;
|
||||
history: string | null;
|
||||
speech_pattern: string | null;
|
||||
catchphrase: string | null;
|
||||
residence: string | null;
|
||||
notes: string | null;
|
||||
color: string | null;
|
||||
last_update: number;
|
||||
}
|
||||
|
||||
export interface SeriesCharacterAttributesTable {
|
||||
attr_id: string;
|
||||
character_id: string;
|
||||
user_id: string;
|
||||
attribute_name: string;
|
||||
attribute_value: string;
|
||||
last_update: number;
|
||||
}
|
||||
|
||||
export interface SeriesWorldsTable {
|
||||
world_id: string;
|
||||
series_id: string;
|
||||
user_id: string;
|
||||
name: string;
|
||||
hashed_name: string;
|
||||
history: string | null;
|
||||
politics: string | null;
|
||||
economy: string | null;
|
||||
religion: string | null;
|
||||
languages: string | null;
|
||||
last_update: number;
|
||||
}
|
||||
|
||||
export interface SeriesWorldElementsTable {
|
||||
element_id: string;
|
||||
world_id: string;
|
||||
user_id: string;
|
||||
element_type: number;
|
||||
name: string;
|
||||
original_name: string;
|
||||
description: string | null;
|
||||
last_update: number;
|
||||
}
|
||||
|
||||
export interface SeriesLocationsTable {
|
||||
loc_id: string;
|
||||
series_id: string;
|
||||
user_id: string;
|
||||
loc_name: string;
|
||||
loc_original_name: string;
|
||||
last_update: number;
|
||||
}
|
||||
|
||||
export interface SeriesLocationElementsTable {
|
||||
element_id: string;
|
||||
location_id: string;
|
||||
user_id: string;
|
||||
element_name: string;
|
||||
original_name: string;
|
||||
element_description: string | null;
|
||||
last_update: number;
|
||||
}
|
||||
|
||||
export interface SeriesLocationSubElementsTable {
|
||||
sub_element_id: string;
|
||||
element_id: string;
|
||||
user_id: string;
|
||||
sub_elem_name: string;
|
||||
original_name: string;
|
||||
sub_elem_description: string | null;
|
||||
last_update: number;
|
||||
}
|
||||
|
||||
export interface SeriesSpellsTable {
|
||||
spell_id: string;
|
||||
series_id: string;
|
||||
user_id: string;
|
||||
name: string;
|
||||
name_hash: string;
|
||||
description: string;
|
||||
appearance: string;
|
||||
tags: string;
|
||||
power_level: string | null;
|
||||
components: string | null;
|
||||
limitations: string | null;
|
||||
notes: string | null;
|
||||
last_update: number;
|
||||
}
|
||||
|
||||
export interface SeriesSpellTagsTable {
|
||||
tag_id: string;
|
||||
series_id: string;
|
||||
user_id: string;
|
||||
name: string;
|
||||
hashed_name: string;
|
||||
color: string | null;
|
||||
last_update: number;
|
||||
}
|
||||
|
||||
// ===== COMPLETE SERIES INTERFACE (for full sync) =====
|
||||
|
||||
export interface CompleteSeries {
|
||||
series: SeriesTable[];
|
||||
seriesBooks: SeriesBooksTable[];
|
||||
seriesCharacters: SeriesCharactersTable[];
|
||||
seriesCharacterAttributes: SeriesCharacterAttributesTable[];
|
||||
seriesWorlds: SeriesWorldsTable[];
|
||||
seriesWorldElements: SeriesWorldElementsTable[];
|
||||
seriesLocations: SeriesLocationsTable[];
|
||||
seriesLocationElements: SeriesLocationElementsTable[];
|
||||
seriesLocationSubElements: SeriesLocationSubElementsTable[];
|
||||
seriesSpells: SeriesSpellsTable[];
|
||||
seriesSpellTags: SeriesSpellTagsTable[];
|
||||
}
|
||||
|
||||
// ===== SYNCED SERIES INTERFACES (lightweight, for comparison) =====
|
||||
|
||||
export interface SyncedSeriesBook {
|
||||
bookId: string;
|
||||
order: number;
|
||||
lastUpdate: number;
|
||||
}
|
||||
|
||||
export interface SyncedSeriesCharacterAttribute {
|
||||
id: string;
|
||||
name: string;
|
||||
lastUpdate: number;
|
||||
}
|
||||
|
||||
export interface SyncedSeriesCharacter {
|
||||
id: string;
|
||||
name: string;
|
||||
lastUpdate: number;
|
||||
attributes: SyncedSeriesCharacterAttribute[];
|
||||
}
|
||||
|
||||
export interface SyncedSeriesWorldElement {
|
||||
id: string;
|
||||
name: string;
|
||||
lastUpdate: number;
|
||||
}
|
||||
|
||||
export interface SyncedSeriesWorld {
|
||||
id: string;
|
||||
name: string;
|
||||
lastUpdate: number;
|
||||
elements: SyncedSeriesWorldElement[];
|
||||
}
|
||||
|
||||
export interface SyncedSeriesLocationSubElement {
|
||||
id: string;
|
||||
name: string;
|
||||
lastUpdate: number;
|
||||
}
|
||||
|
||||
export interface SyncedSeriesLocationElement {
|
||||
id: string;
|
||||
name: string;
|
||||
lastUpdate: number;
|
||||
subElements: SyncedSeriesLocationSubElement[];
|
||||
}
|
||||
|
||||
export interface SyncedSeriesLocation {
|
||||
id: string;
|
||||
name: string;
|
||||
lastUpdate: number;
|
||||
elements: SyncedSeriesLocationElement[];
|
||||
}
|
||||
|
||||
export interface SyncedSeriesSpell {
|
||||
id: string;
|
||||
name: string;
|
||||
lastUpdate: number;
|
||||
}
|
||||
|
||||
export interface SyncedSeriesSpellTag {
|
||||
id: string;
|
||||
name: string;
|
||||
lastUpdate: number;
|
||||
}
|
||||
|
||||
export interface SyncedSeries {
|
||||
id: string;
|
||||
name: string;
|
||||
lastUpdate: number;
|
||||
books: SyncedSeriesBook[];
|
||||
characters: SyncedSeriesCharacter[];
|
||||
worlds: SyncedSeriesWorld[];
|
||||
locations: SyncedSeriesLocation[];
|
||||
spells: SyncedSeriesSpell[];
|
||||
spellTags: SyncedSeriesSpellTag[];
|
||||
}
|
||||
|
||||
export default class Book {
|
||||
private readonly id: string;
|
||||
private type: string;
|
||||
|
||||
Reference in New Issue
Block a user