games_app/backend/dist/services/faqService.d.ts
2026-11-09 18:14:42 +02:00

284 lines
7.9 KiB
TypeScript

import { Request } from 'express';
import { FaqCategoryRow, FaqDocumentLang } from '../models/faq.model';
/** Validate and normalize document language param. */
export declare function parseFaqDocumentLang(raw: string): FaqDocumentLang;
/** Safe download filename for Content-Disposition. */
export declare function sanitizeDownloadFilename(name: string, fallback?: string): string;
/**
* Public download name: `guide_<category>_<lang>.pdf`
* Uses the category slug when available so users immediately see topic + language.
*/
export declare function buildFaqCategoryGuideFilename(slugOrName: string, lang: FaqDocumentLang): string;
declare function mapCategory(row: FaqCategoryRow): {
id: number;
slug: string;
name: string;
description: string | null;
sortOrder: number;
isActive: boolean;
pdfFr: {
originalName: string;
url: string;
} | null;
pdfEn: {
originalName: string;
url: string;
} | null;
createdAt: string;
updatedAt: string;
};
export declare function buildVoterKey(req: Request, userId?: string): string;
export declare function publicFaqFileUrl(filename: string): string;
export declare function resolveFaqFilePath(filename: string): string;
/**
* Validate magic/ClamAV, rename to uuid+safeExt, register legitimacy row.
*/
export declare function finalizeFaqUpload(input: {
tempFilename: string;
originalName?: string;
kind: 'media' | 'category_pdf';
categoryId?: number | null;
uploadedByUserId?: string | null;
allowedMimes: Set<string>;
}): Promise<{
filename: string;
mime: string;
originalName: string;
url: string;
}>;
/** Content-Disposition for FAQ downloads (attachment for PDF, inline for media). */
export declare function faqFileContentDisposition(downloadName: string, mime: string): string;
/**
* Resolve a legitimate FAQ file for public download.
* Registry first; legacy fallback for category PDFs / answer HTML references.
*/
export declare function resolvePublicFaqFile(filename: string): Promise<{
filePath: string;
mime: string;
downloadName: string;
} | null>;
export declare function getFaqPdfMaxBytes(): Promise<number>;
export declare function listPublicCategories(): Promise<{
id: number;
slug: string;
name: string;
description: string | null;
sortOrder: number;
isActive: boolean;
pdfFr: {
originalName: string;
url: string;
} | null;
pdfEn: {
originalName: string;
url: string;
} | null;
createdAt: string;
updatedAt: string;
}[]>;
export declare function listPublicFaqs(filters: {
category?: string;
search?: string;
}): Promise<{
id: string;
categoryId: number;
categorySlug: string;
categoryName: string;
question: string;
answerHtml: string;
sortOrder: number;
viewCount: number;
helpfulYes: number;
helpfulNo: number;
}[]>;
export declare function listPopularFaqs(limit?: number): Promise<{
id: string;
categoryId: number;
categorySlug: string;
categoryName: string;
question: string;
answerHtml: string;
sortOrder: number;
viewCount: number;
helpfulYes: number;
helpfulNo: number;
}[]>;
export declare function getPublicFaq(id: string): Promise<{
id: string;
categoryId: number;
categorySlug: string;
categoryName: string;
question: string;
answerHtml: string;
sortOrder: number;
viewCount: number;
helpfulYes: number;
helpfulNo: number;
}>;
export declare function recordFaqView(id: string): Promise<{
ok: boolean;
}>;
export declare function recordFaqHelpful(id: string, helpful: boolean, voterKey: string): Promise<{
helpfulYes: number;
helpfulNo: number;
changed: boolean;
}>;
export declare function listAdminCategories(): Promise<{
id: number;
slug: string;
name: string;
description: string | null;
sortOrder: number;
isActive: boolean;
pdfFr: {
originalName: string;
url: string;
} | null;
pdfEn: {
originalName: string;
url: string;
} | null;
createdAt: string;
updatedAt: string;
}[]>;
export declare function createAdminCategory(body: Record<string, unknown>): Promise<{
id: number;
slug: string;
name: string;
description: string | null;
sortOrder: number;
isActive: boolean;
pdfFr: {
originalName: string;
url: string;
} | null;
pdfEn: {
originalName: string;
url: string;
} | null;
createdAt: string;
updatedAt: string;
}>;
export declare function updateAdminCategory(id: number, body: Record<string, unknown>): Promise<{
id: number;
slug: string;
name: string;
description: string | null;
sortOrder: number;
isActive: boolean;
pdfFr: {
originalName: string;
url: string;
} | null;
pdfEn: {
originalName: string;
url: string;
} | null;
createdAt: string;
updatedAt: string;
}>;
export declare function deleteAdminCategory(id: number): Promise<{
ok: boolean;
}>;
export declare function listAdminFaqs(filters: {
categoryId?: number;
search?: string;
isActive?: boolean;
}): Promise<{
isActive: boolean;
createdBy: string | null;
updatedBy: string | null;
createdByName: string | null;
updatedByName: string | null;
createdAt: string;
updatedAt: string;
id: string;
categoryId: number;
categorySlug: string;
categoryName: string;
question: string;
answerHtml: string;
sortOrder: number;
viewCount: number;
helpfulYes: number;
helpfulNo: number;
}[]>;
export declare function createAdminFaq(userId: string, body: Record<string, unknown>): Promise<{
isActive: boolean;
createdBy: string | null;
updatedBy: string | null;
createdByName: string | null;
updatedByName: string | null;
createdAt: string;
updatedAt: string;
id: string;
categoryId: number;
categorySlug: string;
categoryName: string;
question: string;
answerHtml: string;
sortOrder: number;
viewCount: number;
helpfulYes: number;
helpfulNo: number;
}>;
export declare function updateAdminFaq(id: string, userId: string, body: Record<string, unknown>): Promise<{
isActive: boolean;
createdBy: string | null;
updatedBy: string | null;
createdByName: string | null;
updatedByName: string | null;
createdAt: string;
updatedAt: string;
id: string;
categoryId: number;
categorySlug: string;
categoryName: string;
question: string;
answerHtml: string;
sortOrder: number;
viewCount: number;
helpfulYes: number;
helpfulNo: number;
}>;
export declare function deleteAdminFaq(id: string): Promise<{
ok: boolean;
}>;
export declare function readFaqFile(filename: string): string | null;
/**
* Upload or replace a category PDF. Validates magic + size; only swaps DB pointer
* after success so a failed upload never drops the previous document.
*/
export declare function uploadCategoryDocument(input: {
categoryId: number;
lang: FaqDocumentLang;
tempFilename: string;
originalName: string;
byteSize: number;
uploadedByUserId?: string | null;
}): Promise<ReturnType<typeof mapCategory>>;
export declare function deleteCategoryDocument(categoryId: number, lang: FaqDocumentLang): Promise<{
id: number;
slug: string;
name: string;
description: string | null;
sortOrder: number;
isActive: boolean;
pdfFr: {
originalName: string;
url: string;
} | null;
pdfEn: {
originalName: string;
url: string;
} | null;
createdAt: string;
updatedAt: string;
}>;
/** Resolve a public download for an active category document. */
export declare function resolvePublicCategoryDocument(slug: string, lang: FaqDocumentLang): Promise<{
filePath: string;
downloadName: string;
} | null>;
export {};
//# sourceMappingURL=faqService.d.ts.map