Refactor imports and types for consistency and remove redundant paths
- Updated relative imports by replacing `@/` aliases with proper `../` paths for consistency. - Refined type definitions in IPC handlers and repositories (`User`, `Chapter`, `Act`, etc.). - Simplified return types in `Location` model methods for streamlined usage.
This commit is contained in:
@@ -198,7 +198,7 @@ export default class Location {
|
|||||||
* @param lang - The language for error messages ('fr' or 'en'). Defaults to 'fr'.
|
* @param lang - The language for error messages ('fr' or 'en'). Defaults to 'fr'.
|
||||||
* @returns The result of the delete operation.
|
* @returns The result of the delete operation.
|
||||||
*/
|
*/
|
||||||
static deleteLocationSection(userId: string, locationId: string, lang: 'fr' | 'en' = 'fr'): { valid: boolean; message: string } {
|
static deleteLocationSection(userId: string, locationId: string, lang: 'fr' | 'en' = 'fr'): boolean {
|
||||||
return LocationRepo.deleteLocationSection(userId, locationId, lang);
|
return LocationRepo.deleteLocationSection(userId, locationId, lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +209,7 @@ export default class Location {
|
|||||||
* @param lang - The language for error messages ('fr' or 'en'). Defaults to 'fr'.
|
* @param lang - The language for error messages ('fr' or 'en'). Defaults to 'fr'.
|
||||||
* @returns The result of the delete operation.
|
* @returns The result of the delete operation.
|
||||||
*/
|
*/
|
||||||
static deleteLocationElement(userId: string, elementId: string, lang: 'fr' | 'en' = 'fr'): { valid: boolean; message: string } {
|
static deleteLocationElement(userId: string, elementId: string, lang: 'fr' | 'en' = 'fr'): boolean {
|
||||||
return LocationRepo.deleteLocationElement(userId, elementId, lang);
|
return LocationRepo.deleteLocationElement(userId, elementId, lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,7 +220,7 @@ export default class Location {
|
|||||||
* @param lang - The language for error messages ('fr' or 'en'). Defaults to 'fr'.
|
* @param lang - The language for error messages ('fr' or 'en'). Defaults to 'fr'.
|
||||||
* @returns The result of the delete operation.
|
* @returns The result of the delete operation.
|
||||||
*/
|
*/
|
||||||
static deleteLocationSubElement(userId: string, subElementId: string, lang: 'fr' | 'en' = 'fr'): { valid: boolean; message: string } {
|
static deleteLocationSubElement(userId: string, subElementId: string, lang: 'fr' | 'en' = 'fr'): boolean {
|
||||||
return LocationRepo.deleteLocationSubElement(userId, subElementId, lang);
|
return LocationRepo.deleteLocationSubElement(userId, subElementId, lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {Database, QueryResult, RunResult, SQLiteValue} from "node-sqlite3-wasm";
|
import {Database, QueryResult, RunResult, SQLiteValue} from "node-sqlite3-wasm";
|
||||||
import System from "@/electron/database/System";
|
import System from "../System.js";
|
||||||
|
|
||||||
export interface BookActSummariesTable extends Record<string, SQLiteValue> {
|
export interface BookActSummariesTable extends Record<string, SQLiteValue> {
|
||||||
act_sum_id: string;
|
act_sum_id: string;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Database, QueryResult, RunResult, SQLiteValue } from "node-sqlite3-wasm";
|
import { Database, QueryResult, RunResult, SQLiteValue } from "node-sqlite3-wasm";
|
||||||
import System from "@/electron/database/System";
|
import System from "../System.js";
|
||||||
|
|
||||||
export interface ChapterContentQueryResult extends Record<string, SQLiteValue> {
|
export interface ChapterContentQueryResult extends Record<string, SQLiteValue> {
|
||||||
chapter_id: string;
|
chapter_id: string;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Database, RunResult, SQLiteValue } from "node-sqlite3-wasm";
|
import { Database, RunResult, SQLiteValue } from "node-sqlite3-wasm";
|
||||||
import System from "@/electron/database/System";
|
import System from "../System.js";
|
||||||
|
|
||||||
export interface BookAIGuideLineTable extends Record<string, SQLiteValue> {
|
export interface BookAIGuideLineTable extends Record<string, SQLiteValue> {
|
||||||
user_id: string;
|
user_id: string;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Database, QueryResult, RunResult, SQLiteValue } from "node-sqlite3-wasm";
|
import { Database, QueryResult, RunResult, SQLiteValue } from "node-sqlite3-wasm";
|
||||||
import System from "@/electron/database/System";
|
import System from "../System.js";
|
||||||
|
|
||||||
export interface BookIncidentsTable extends Record<string, SQLiteValue> {
|
export interface BookIncidentsTable extends Record<string, SQLiteValue> {
|
||||||
incident_id: string;
|
incident_id: string;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Database, QueryResult, RunResult, SQLiteValue } from "node-sqlite3-wasm";
|
import { Database, QueryResult, RunResult, SQLiteValue } from "node-sqlite3-wasm";
|
||||||
import System from "@/electron/database/System";
|
import System from "../System.js";
|
||||||
|
|
||||||
export interface BookIssuesTable extends Record<string, SQLiteValue> {
|
export interface BookIssuesTable extends Record<string, SQLiteValue> {
|
||||||
issue_id: string;
|
issue_id: string;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Database, QueryResult, RunResult, SQLiteValue } from "node-sqlite3-wasm";
|
import { Database, QueryResult, RunResult, SQLiteValue } from "node-sqlite3-wasm";
|
||||||
import System from "@/electron/database/System";
|
import System from "../System.js";
|
||||||
|
|
||||||
export interface BookPlotPointsTable extends Record<string, SQLiteValue> {
|
export interface BookPlotPointsTable extends Record<string, SQLiteValue> {
|
||||||
plot_point_id: string;
|
plot_point_id: string;
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ export default class UserRepo {
|
|||||||
* @throws Error if the user is not found or cannot be retrieved
|
* @throws Error if the user is not found or cannot be retrieved
|
||||||
*/
|
*/
|
||||||
public static fetchUserInfos(userId: string, lang: 'fr' | 'en' = 'fr'): UserInfosQueryResponse {
|
public static fetchUserInfos(userId: string, lang: 'fr' | 'en' = 'fr'): UserInfosQueryResponse {
|
||||||
let userInfo: Record<string, SQLiteValue> | undefined;
|
let userInfo: UserInfosQueryResponse | undefined;
|
||||||
try {
|
try {
|
||||||
const db: Database = System.getDb();
|
const db: Database = System.getDb();
|
||||||
const query: string = `
|
const query: string = `
|
||||||
@@ -125,7 +125,7 @@ export default class UserRepo {
|
|||||||
WHERE user_id = ?
|
WHERE user_id = ?
|
||||||
`;
|
`;
|
||||||
const params: SQLiteValue[] = [userId];
|
const params: SQLiteValue[] = [userId];
|
||||||
userInfo = db.get(query, params);
|
userInfo = db.get(query, params) as UserInfosQueryResponse | undefined;
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
console.error(`DB Error: ${error.message}`);
|
console.error(`DB Error: ${error.message}`);
|
||||||
@@ -208,7 +208,7 @@ export default class UserRepo {
|
|||||||
* @throws Error if the account is not found or cannot be retrieved
|
* @throws Error if the account is not found or cannot be retrieved
|
||||||
*/
|
*/
|
||||||
public static fetchAccountInformation(userId: string, lang: 'fr' | 'en' = 'fr'): UserAccountQuery {
|
public static fetchAccountInformation(userId: string, lang: 'fr' | 'en' = 'fr'): UserAccountQuery {
|
||||||
let accountInfo: Record<string, SQLiteValue> | undefined;
|
let accountInfo: UserAccountQuery | undefined;
|
||||||
try {
|
try {
|
||||||
const db: Database = System.getDb();
|
const db: Database = System.getDb();
|
||||||
const query: string = `
|
const query: string = `
|
||||||
@@ -217,7 +217,7 @@ export default class UserRepo {
|
|||||||
WHERE user_id = ?
|
WHERE user_id = ?
|
||||||
`;
|
`;
|
||||||
const params: SQLiteValue[] = [userId];
|
const params: SQLiteValue[] = [userId];
|
||||||
accountInfo = db.get(query, params);
|
accountInfo = db.get(query, params) as UserAccountQuery | undefined;
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
console.error(`DB Error: ${error.message}`);
|
console.error(`DB Error: ${error.message}`);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Database, QueryResult, RunResult, SQLiteValue } from "node-sqlite3-wasm";
|
import { Database, QueryResult, RunResult, SQLiteValue } from "node-sqlite3-wasm";
|
||||||
import System from "@/electron/database/System";
|
import System from "../System.js";
|
||||||
|
|
||||||
export interface BookWorldTable extends Record<string, SQLiteValue> {
|
export interface BookWorldTable extends Record<string, SQLiteValue> {
|
||||||
world_id: string;
|
world_id: string;
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ import Book, {BookSyncCompare, CompleteBook, SyncedBook} from '../database/model
|
|||||||
import type { BookProps } from '../database/models/Book.js';
|
import type { BookProps } from '../database/models/Book.js';
|
||||||
import Chapter from '../database/models/Chapter.js';
|
import Chapter from '../database/models/Chapter.js';
|
||||||
import type { ChapterProps } from '../database/models/Chapter.js';
|
import type { ChapterProps } from '../database/models/Chapter.js';
|
||||||
import Act, {ActProps} from "@/electron/database/models/Act";
|
import Act, {ActProps} from "../database/models/Act.js";
|
||||||
import Issue, {IssueProps} from "@/electron/database/models/Issue";
|
import Issue, {IssueProps} from "../database/models/Issue.js";
|
||||||
import Sync from "@/electron/database/models/Sync";
|
import Sync from "../database/models/Sync.js";
|
||||||
import Download from "@/electron/database/models/Download";
|
import Download from "../database/models/Download.js";
|
||||||
import Upload from "@/electron/database/models/Upload";
|
import Upload from "../database/models/Upload.js";
|
||||||
import GuideLine, {GuideLineAI} from "@/electron/database/models/GuideLine";
|
import GuideLine, {GuideLineAI} from "../database/models/GuideLine.js";
|
||||||
import Incident from "@/electron/database/models/Incident";
|
import Incident from "../database/models/Incident.js";
|
||||||
import PlotPoint from "@/electron/database/models/PlotPoint";
|
import PlotPoint from "../database/models/PlotPoint.js";
|
||||||
import World, {WorldProps} from "@/electron/database/models/World";
|
import World, {WorldProps} from "../database/models/World.js";
|
||||||
|
|
||||||
interface UpdateBookBasicData {
|
interface UpdateBookBasicData {
|
||||||
title: string;
|
title: string;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { ipcMain } from 'electron';
|
import { ipcMain } from 'electron';
|
||||||
import { createHandler } from '../database/LocalSystem.js';
|
import { createHandler } from '../database/LocalSystem.js';
|
||||||
import Chapter from '../database/models/Chapter.js';
|
import Chapter from '../database/models/Chapter.js';
|
||||||
import type { ChapterProps, CompanionContent, ActStory } from '../database/models/Chapter.js';
|
import type { ChapterProps, CompanionContent } from '../database/models/Chapter.js';
|
||||||
|
import type { ActStory } from '../database/models/Act.js';
|
||||||
|
|
||||||
interface GetWholeChapterData {
|
interface GetWholeChapterData {
|
||||||
id: string;
|
id: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user