Files
contracts/gen/chat/chat.ts
2026-04-17 18:25:16 +00:00

228 lines
6.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v2.11.6
// protoc v4.25.9
// source: chat/chat.proto
/* eslint-disable */
import type { Metadata } from "@grpc/grpc-js";
import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
import { Observable } from "rxjs";
export const protobufPackage = "chat.v1";
export interface MessageDto {
id: string;
chatId: string;
senderId: string;
/** TEXT, VOICE, VIDEO_NOTE, STICKER */
type: string;
content: string;
/** JSON string */
metadata: string;
replyToId: string;
isEdited: boolean;
createdAt: string;
}
export interface ChatDto {
id: string;
/** DIRECT, GROUP, CHANNEL */
type: string;
title: string;
avatarUrl: string;
unreadCount: number;
/** Нужно для рендера списка чатов слева! */
lastMessage: MessageDto | undefined;
}
export interface CreateChatRequest {
/** ID того кто создает */
creatorId: string;
/** GROUP, DIRECT, CHANNEL */
type: string;
/** Имя (при type=GROUP|CHANNEL) */
title: string;
/** Кого сразу добавить (собеседник в личке или юзеры в группе) */
participantIds: string[];
}
export interface CreateChatResponse {
chat: ChatDto | undefined;
}
export interface GetUserChatsRequest {
userId: string;
/** для пагинации (бесконечный скролл в левой панели) */
offset: number;
limit: number;
}
export interface GetUserChatsResponse {
chats: ChatDto[];
}
export interface JoinChatRequest {
userId: string;
/** либо join_hash */
chatId: string;
}
export interface JoinChatResponse {
success: boolean;
}
export interface LeaveChatRequest {
userId: string;
chatId: string;
}
export interface LeaveChatResponse {
success: boolean;
}
export interface GetMessagesRequest {
userId: string;
chatId: string;
limit: number;
/** курсорная пагинация, как в Telegram */
beforeMsgId: string;
}
export interface GetMessagesResponse {
messages: MessageDto[];
}
export interface SendMessageRequest {
chatId: string;
senderId: string;
type: string;
content: string;
replyToId: string;
}
export interface DeleteMessageRequest {
userId: string;
messageId: string;
/** "Удалить для всех" */
forEveryone: boolean;
}
export interface DeleteMessageResponse {
success: boolean;
}
export interface MarkAsReadRequest {
userId: string;
chatId: string;
messageId: string;
}
export interface MarkAsReadResponse {
success: boolean;
}
export const CHAT_V1_PACKAGE_NAME = "chat.v1";
export interface ChatServiceClient {
/** Управление чатами */
createChat(request: CreateChatRequest, metadata?: Metadata): Observable<CreateChatResponse>;
getUserChats(request: GetUserChatsRequest, metadata?: Metadata): Observable<GetUserChatsResponse>;
joinChat(request: JoinChatRequest, metadata?: Metadata): Observable<JoinChatResponse>;
leaveChat(request: LeaveChatRequest, metadata?: Metadata): Observable<LeaveChatResponse>;
/** Управление сообщениями (история) */
getMessages(request: GetMessagesRequest, metadata?: Metadata): Observable<GetMessagesResponse>;
/** вызывается либо из Gateway (для фото/аудио), либо напрямую */
sendMessage(request: SendMessageRequest, metadata?: Metadata): Observable<MessageDto>;
deleteMessage(request: DeleteMessageRequest, metadata?: Metadata): Observable<DeleteMessageResponse>;
/** Статусы */
markAsRead(request: MarkAsReadRequest, metadata?: Metadata): Observable<MarkAsReadResponse>;
}
export interface ChatServiceController {
/** Управление чатами */
createChat(
request: CreateChatRequest,
metadata?: Metadata,
): Promise<CreateChatResponse> | Observable<CreateChatResponse> | CreateChatResponse;
getUserChats(
request: GetUserChatsRequest,
metadata?: Metadata,
): Promise<GetUserChatsResponse> | Observable<GetUserChatsResponse> | GetUserChatsResponse;
joinChat(
request: JoinChatRequest,
metadata?: Metadata,
): Promise<JoinChatResponse> | Observable<JoinChatResponse> | JoinChatResponse;
leaveChat(
request: LeaveChatRequest,
metadata?: Metadata,
): Promise<LeaveChatResponse> | Observable<LeaveChatResponse> | LeaveChatResponse;
/** Управление сообщениями (история) */
getMessages(
request: GetMessagesRequest,
metadata?: Metadata,
): Promise<GetMessagesResponse> | Observable<GetMessagesResponse> | GetMessagesResponse;
/** вызывается либо из Gateway (для фото/аудио), либо напрямую */
sendMessage(
request: SendMessageRequest,
metadata?: Metadata,
): Promise<MessageDto> | Observable<MessageDto> | MessageDto;
deleteMessage(
request: DeleteMessageRequest,
metadata?: Metadata,
): Promise<DeleteMessageResponse> | Observable<DeleteMessageResponse> | DeleteMessageResponse;
/** Статусы */
markAsRead(
request: MarkAsReadRequest,
metadata?: Metadata,
): Promise<MarkAsReadResponse> | Observable<MarkAsReadResponse> | MarkAsReadResponse;
}
export function ChatServiceControllerMethods() {
return function (constructor: Function) {
const grpcMethods: string[] = [
"createChat",
"getUserChats",
"joinChat",
"leaveChat",
"getMessages",
"sendMessage",
"deleteMessage",
"markAsRead",
];
for (const method of grpcMethods) {
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
GrpcMethod("ChatService", method)(constructor.prototype[method], method, descriptor);
}
const grpcStreamMethods: string[] = [];
for (const method of grpcStreamMethods) {
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
GrpcStreamMethod("ChatService", method)(constructor.prototype[method], method, descriptor);
}
};
}
export const CHAT_SERVICE_NAME = "ChatService";