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

281 lines
9.2 KiB
TypeScript

import { SupportConversationRow, SupportSenderType } from '../models/support.model';
export declare function isStaffRole(role: string | undefined): boolean;
export type SupportAccessContext = {
userId?: string;
role?: string;
visitorToken?: string | null;
};
export declare function assertConversationAccess(conversationId: string, ctx: SupportAccessContext): Promise<SupportConversationRow>;
export declare function findCurrentConversation(ctx: SupportAccessContext): Promise<{
id: string;
userId: string | null;
visitorToken: string | null;
isAnonymous: boolean;
subject: string | null;
status: import("../models/support.model").SupportConversationStatus;
assignedTo: string | null;
lastMessageAt: string | null;
lastMessagePreview: string | null;
unreadUser: number;
unreadStaff: number;
createdAt: string;
updatedAt: string;
} | null>;
export declare function ensureCurrentConversation(ctx: SupportAccessContext): Promise<{
id: string;
userId: string | null;
visitorToken: string | null;
isAnonymous: boolean;
subject: string | null;
status: import("../models/support.model").SupportConversationStatus;
assignedTo: string | null;
lastMessageAt: string | null;
lastMessagePreview: string | null;
unreadUser: number;
unreadStaff: number;
createdAt: string;
updatedAt: string;
}>;
export declare function sendToCurrentConversation(ctx: SupportAccessContext, input: {
body?: string;
attachmentUrl?: string;
attachmentName?: string;
attachmentMime?: string;
}): Promise<{
id: string;
conversationId: string;
senderType: SupportSenderType;
senderUserId: string | null;
senderDisplayName: string | null;
body: string | null;
attachmentUrl: string | null;
attachmentName: string | null;
attachmentMime: string | null;
readAt: string | null;
editedAt: string | null;
deletedAt: string | null;
deleted: boolean;
createdAt: string;
canEdit: boolean;
canDelete: boolean;
editAvailableUntil: string | null;
deleteAvailableUntil: string | null;
}>;
export declare function listUserConversations(ctx: SupportAccessContext): Promise<{
id: string;
userId: string | null;
visitorToken: string | null;
isAnonymous: boolean;
subject: string | null;
status: import("../models/support.model").SupportConversationStatus;
assignedTo: string | null;
lastMessageAt: string | null;
lastMessagePreview: string | null;
unreadUser: number;
unreadStaff: number;
createdAt: string;
updatedAt: string;
}[]>;
export declare function getConversationMessages(conversationId: string, ctx: SupportAccessContext, after?: string): Promise<{
messages: {
id: string;
conversationId: string;
senderType: SupportSenderType;
senderUserId: string | null;
senderDisplayName: string | null;
body: string | null;
attachmentUrl: string | null;
attachmentName: string | null;
attachmentMime: string | null;
readAt: string | null;
editedAt: string | null;
deletedAt: string | null;
deleted: boolean;
createdAt: string;
canEdit: boolean;
canDelete: boolean;
editAvailableUntil: string | null;
deleteAvailableUntil: string | null;
}[];
typing: {
userTyping: boolean;
staffTyping: boolean;
};
policy: {
editWindowMinutes: number;
deleteWindowMinutes: number;
};
}>;
export declare function sendMessage(conversationId: string, ctx: SupportAccessContext, input: {
body?: string;
attachmentUrl?: string;
attachmentName?: string;
attachmentMime?: string;
}): Promise<{
id: string;
conversationId: string;
senderType: SupportSenderType;
senderUserId: string | null;
senderDisplayName: string | null;
body: string | null;
attachmentUrl: string | null;
attachmentName: string | null;
attachmentMime: string | null;
readAt: string | null;
editedAt: string | null;
deletedAt: string | null;
deleted: boolean;
createdAt: string;
canEdit: boolean;
canDelete: boolean;
editAvailableUntil: string | null;
deleteAvailableUntil: string | null;
}>;
export declare function editMessage(conversationId: string, messageId: string, ctx: SupportAccessContext, body: string): Promise<{
id: string;
conversationId: string;
senderType: SupportSenderType;
senderUserId: string | null;
senderDisplayName: string | null;
body: string | null;
attachmentUrl: string | null;
attachmentName: string | null;
attachmentMime: string | null;
readAt: string | null;
editedAt: string | null;
deletedAt: string | null;
deleted: boolean;
createdAt: string;
canEdit: boolean;
canDelete: boolean;
editAvailableUntil: string | null;
deleteAvailableUntil: string | null;
}>;
export declare function deleteMessage(conversationId: string, messageId: string, ctx: SupportAccessContext): Promise<{
id: string;
conversationId: string;
senderType: SupportSenderType;
senderUserId: string | null;
senderDisplayName: string | null;
body: string | null;
attachmentUrl: string | null;
attachmentName: string | null;
attachmentMime: string | null;
readAt: string | null;
editedAt: string | null;
deletedAt: string | null;
deleted: boolean;
createdAt: string;
canEdit: boolean;
canDelete: boolean;
editAvailableUntil: string | null;
deleteAvailableUntil: string | null;
}>;
export declare function setTyping(conversationId: string, ctx: SupportAccessContext, active: boolean): Promise<{
ok: boolean;
}>;
export declare function listAdminConversations(filters: {
status?: string;
assignedTo?: string | null;
search?: string;
page?: number;
pageSize?: number;
}): Promise<{
items: {
id: string;
userId: string | null;
visitorToken: string | null;
isAnonymous: boolean;
subject: string | null;
status: import("../models/support.model").SupportConversationStatus;
assignedTo: string | null;
lastMessageAt: string | null;
lastMessagePreview: string | null;
unreadUser: number;
unreadStaff: number;
createdAt: string;
updatedAt: string;
}[];
total: number;
page: number;
pageSize: number;
totalPages: number;
}>;
export declare function getAdminConversationDetail(conversationId: string): Promise<{
conversation: {
id: string;
userId: string | null;
visitorToken: string | null;
isAnonymous: boolean;
subject: string | null;
status: import("../models/support.model").SupportConversationStatus;
assignedTo: string | null;
lastMessageAt: string | null;
lastMessagePreview: string | null;
unreadUser: number;
unreadStaff: number;
createdAt: string;
updatedAt: string;
};
user: {
id: string;
email: string | null;
firstName: string | null;
lastName: string | null;
displayName: string | null;
role: string;
emailVerified: boolean;
isEnabled: boolean;
createdAt: string;
} | null;
}>;
export declare function updateAdminConversation(conversationId: string, staffUserId: string, patch: {
status?: string;
assignedTo?: string | null;
subject?: string;
}): Promise<{
id: string;
userId: string | null;
visitorToken: string | null;
isAnonymous: boolean;
subject: string | null;
status: import("../models/support.model").SupportConversationStatus;
assignedTo: string | null;
lastMessageAt: string | null;
lastMessagePreview: string | null;
unreadUser: number;
unreadStaff: number;
createdAt: string;
updatedAt: string;
}>;
export declare function getStaffUnreadCount(): Promise<number>;
export declare function resolveUploadPath(storedName: string): string;
export declare function ensureUploadDir(): string;
export declare function publicAttachmentUrl(storedName: string): string;
/** Extract basename from a support attachment URL (relative or absolute). */
export declare function parseSupportAttachmentFilename(url: string): string | null;
/**
* Validate magic/ClamAV, rename to uuid+safeExt, register ACL row.
*/
export declare function finalizeSupportUpload(input: {
tempFilename: string;
originalName?: string;
conversationId?: string | null;
ctx: SupportAccessContext;
}): Promise<{
filename: string;
mime: string;
originalName: string;
url: string;
}>;
/** Authorize download of a stored support file. */
export declare function assertSupportFileDownloadAccess(filename: string, ctx: SupportAccessContext): Promise<{
mime: string;
originalName: string | null;
filePath: string;
}>;
/** Content-Disposition filename* / filename header value. */
export declare function attachmentContentDisposition(downloadName: string): string;
/** Links all anonymous visitor conversations to a newly registered or logged-in user. */
export declare function mergeVisitorSupportForUser(userId: string, visitorToken: string | null | undefined): Promise<number>;
//# sourceMappingURL=supportService.d.ts.map