Add multi-language support and new repository methods for book synchronization

- Extend repository methods to handle API requests for fetching books, chapters, characters, and other entities with multilingual support (`lang: 'fr' | 'en'`).
- Add `uploadBookForSync` logic to consolidate and decrypt book data for synchronization.
- Refactor schema migration logic to remove console logs and streamline table recreation.
- Enhance error handling across database repositories and IPC methods.
This commit is contained in:
natreex
2025-12-22 16:44:12 -05:00
parent ff530f3442
commit 515d469ba7
17 changed files with 666 additions and 113 deletions

View File

@@ -93,6 +93,34 @@ export default class System{
}
}
public static async authPatchToServer<T>(url: string, data: {}, auth: string, lang: string = "fr"): Promise<T> {
try {
const response: AxiosResponse<T> = await axios({
method: 'patch',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${auth}`
},
params: {
lang: lang,
plateforme: 'web',
},
url: configs.apiUrl + url,
data: data
})
return response.data;
} catch (e: unknown) {
if (axios.isAxiosError(e)) {
const serverMessage: string = e.response?.data?.message || e.response?.data || e.message;
throw new Error(serverMessage as string);
} else if (e instanceof Error) {
throw new Error(e.message);
} else {
throw new Error('An unexpected error occurred');
}
}
}
public static async postToServer<T>(url: string, data: {}, lang: string = "fr"): Promise<T> {
try {
const response: AxiosResponse<T> = await axios({