Files
contracts/gen/notifications/notifications.ts
2026-05-08 12:36:58 +00:00

191 lines
6.9 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.8
// protoc v4.25.9
// source: notifications/notifications.proto
/* eslint-disable */
import type { Metadata } from "@grpc/grpc-js";
import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
import { wrappers } from "protobufjs";
import { Observable } from "rxjs";
import { Struct } from "../google/protobuf/struct";
import { Timestamp } from "../google/protobuf/timestamp";
export const protobufPackage = "notifications.v1";
/** Структура самого уведомления */
export interface Notification {
id: string;
userId: string;
/** Например: "SYSTEM_ALERT", "NEW_MESSAGE", "TASK_ASSIGNED" */
type: string;
/** Заголовок (опционально) */
title: string;
/** Текст уведомления */
text: string;
/** Любая динамическая JSON-нагрузка (например, { "task_id": 123 }) */
payload: { [key: string]: any } | undefined;
isRead: boolean;
createdAt: Timestamp | undefined;
}
export interface GetNotificationsRequest {
/** ID пользователя запрашивающего данные (Gateway берет это из JWT) */
userId: string;
/** Для пагинации (например, 20) */
limit: number;
/** Для пагинации (например, 0) */
offset: number;
/** Фильтр: получить только непрочитанные */
unreadOnly?: boolean | undefined;
}
export interface GetNotificationsResponse {
/** Массив уведомлений */
notifications: Notification[];
/** Общее количество (для UI пагинации) */
totalCount: number;
}
export interface GetUnreadCountRequest {
userId: string;
}
export interface GetUnreadCountResponse {
count: number;
}
export interface MarkAsReadRequest {
userId: string;
notificationId: string;
}
export interface MarkAsReadResponse {
success: boolean;
}
export interface MarkAllAsReadRequest {
userId: string;
}
export interface MarkAllAsReadResponse {
success: boolean;
/** Сколько уведомлений было обновлено */
updatedCount: number;
}
export interface SendNotificationRequest {
/** Кому отправляем (если пусто — можно сделать бродкаст, но лучше отдельный метод) */
userId: string;
type: string;
title: string;
text: string;
/** Метаданные для UI (ссылки, ID сущностей) */
payload: { [key: string]: any } | undefined;
}
export interface SendNotificationResponse {
success: boolean;
/** ID созданного уведомления в Postgres */
notificationId: string;
}
export const NOTIFICATIONS_V1_PACKAGE_NAME = "notifications.v1";
wrappers[".google.protobuf.Struct"] = { fromObject: Struct.wrap, toObject: Struct.unwrap } as any;
/**
* -----------------------------------------------------------------------------
* Сервис Уведомлений
* -----------------------------------------------------------------------------
*/
export interface NotificationServiceClient {
/** Получить список уведомлений пользователя с пагинацией */
getUserNotifications(request: GetNotificationsRequest, metadata?: Metadata): Observable<GetNotificationsResponse>;
/** Получить количество непрочитанных уведомлений (для бейджика на иконке) */
getUnreadCount(request: GetUnreadCountRequest, metadata?: Metadata): Observable<GetUnreadCountResponse>;
/** Отметить конкретное уведомление как прочитанное */
markAsRead(request: MarkAsReadRequest, metadata?: Metadata): Observable<MarkAsReadResponse>;
/** Отметить все уведомления пользователя как прочитанные */
markAllAsRead(request: MarkAllAsReadRequest, metadata?: Metadata): Observable<MarkAllAsReadResponse>;
/** Отправить уведомление (CRM/ERP вызывает этот метод, а NestJS уже кидает в RabbitMQ) */
sendNotification(request: SendNotificationRequest, metadata?: Metadata): Observable<SendNotificationResponse>;
}
/**
* -----------------------------------------------------------------------------
* Сервис Уведомлений
* -----------------------------------------------------------------------------
*/
export interface NotificationServiceController {
/** Получить список уведомлений пользователя с пагинацией */
getUserNotifications(
request: GetNotificationsRequest,
metadata?: Metadata,
): Promise<GetNotificationsResponse> | Observable<GetNotificationsResponse> | GetNotificationsResponse;
/** Получить количество непрочитанных уведомлений (для бейджика на иконке) */
getUnreadCount(
request: GetUnreadCountRequest,
metadata?: Metadata,
): Promise<GetUnreadCountResponse> | Observable<GetUnreadCountResponse> | GetUnreadCountResponse;
/** Отметить конкретное уведомление как прочитанное */
markAsRead(
request: MarkAsReadRequest,
metadata?: Metadata,
): Promise<MarkAsReadResponse> | Observable<MarkAsReadResponse> | MarkAsReadResponse;
/** Отметить все уведомления пользователя как прочитанные */
markAllAsRead(
request: MarkAllAsReadRequest,
metadata?: Metadata,
): Promise<MarkAllAsReadResponse> | Observable<MarkAllAsReadResponse> | MarkAllAsReadResponse;
/** Отправить уведомление (CRM/ERP вызывает этот метод, а NestJS уже кидает в RabbitMQ) */
sendNotification(
request: SendNotificationRequest,
metadata?: Metadata,
): Promise<SendNotificationResponse> | Observable<SendNotificationResponse> | SendNotificationResponse;
}
export function NotificationServiceControllerMethods() {
return function (constructor: Function) {
const grpcMethods: string[] = [
"getUserNotifications",
"getUnreadCount",
"markAsRead",
"markAllAsRead",
"sendNotification",
];
for (const method of grpcMethods) {
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
GrpcMethod("NotificationService", method)(constructor.prototype[method], method, descriptor);
}
const grpcStreamMethods: string[] = [];
for (const method of grpcStreamMethods) {
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
GrpcStreamMethod("NotificationService", method)(constructor.prototype[method], method, descriptor);
}
};
}
export const NOTIFICATION_SERVICE_NAME = "NotificationService";