add notifications proto file
All checks were successful
Publish / Publish Job (push) Successful in 2m27s
All checks were successful
Publish / Publish Job (push) Successful in 2m27s
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@lendry-erp/contracts",
|
"name": "@lendry-erp/contracts",
|
||||||
"version": "1.2.23",
|
"version": "1.2.24",
|
||||||
"description": "Protobuf definitions and generated TypeScript types",
|
"description": "Protobuf definitions and generated TypeScript types",
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
|||||||
107
proto/notifications/notifications.proto
Normal file
107
proto/notifications/notifications.proto
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
// Указываем пакет для логической изоляции
|
||||||
|
package notifications.v1;
|
||||||
|
|
||||||
|
// Импортируем стандартные типы Google для работы с датами и произвольным JSON
|
||||||
|
import "google/protobuf/timestamp.proto";
|
||||||
|
import "google/protobuf/struct.proto";
|
||||||
|
|
||||||
|
// Опции для генерации кода (особенно полезно для Go, если понадобится)
|
||||||
|
option go_package = "git.lendry.ru/lendry-erp/proto.git/go;pb";
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Сервис Уведомлений
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
service NotificationService {
|
||||||
|
// --- Публичные методы (Вызываются из API Gateway от лица клиента) ---
|
||||||
|
|
||||||
|
// Получить список уведомлений пользователя с пагинацией
|
||||||
|
rpc GetUserNotifications (GetNotificationsRequest) returns (GetNotificationsResponse);
|
||||||
|
|
||||||
|
// Получить количество непрочитанных уведомлений (для бейджика на иконке)
|
||||||
|
rpc GetUnreadCount (GetUnreadCountRequest) returns (GetUnreadCountResponse);
|
||||||
|
|
||||||
|
// Отметить конкретное уведомление как прочитанное
|
||||||
|
rpc MarkAsRead (MarkAsReadRequest) returns (MarkAsReadResponse);
|
||||||
|
|
||||||
|
// Отметить все уведомления пользователя как прочитанные
|
||||||
|
rpc MarkAllAsRead (MarkAllAsReadRequest) returns (MarkAllAsReadResponse);
|
||||||
|
|
||||||
|
|
||||||
|
// --- Внутренние методы (Вызываются другими микросервисами: CRM, ERP, Auth) ---
|
||||||
|
|
||||||
|
// Отправить уведомление (CRM/ERP вызывает этот метод, а NestJS уже кидает в RabbitMQ)
|
||||||
|
rpc SendNotification (SendNotificationRequest) returns (SendNotificationResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Базовые модели
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Структура самого уведомления
|
||||||
|
message Notification {
|
||||||
|
string id = 1;
|
||||||
|
string user_id = 2;
|
||||||
|
string type = 3; // Например: "SYSTEM_ALERT", "NEW_MESSAGE", "TASK_ASSIGNED"
|
||||||
|
string title = 4; // Заголовок (опционально)
|
||||||
|
string text = 5; // Текст уведомления
|
||||||
|
google.protobuf.Struct payload = 6; // Любая динамическая JSON-нагрузка (например, { "task_id": 123 })
|
||||||
|
bool is_read = 7;
|
||||||
|
google.protobuf.Timestamp created_at = 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Запросы и ответы (Requests / Responses)
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
message GetNotificationsRequest {
|
||||||
|
string user_id = 1; // ID пользователя запрашивающего данные (Gateway берет это из JWT)
|
||||||
|
int32 limit = 2; // Для пагинации (например, 20)
|
||||||
|
int32 offset = 3; // Для пагинации (например, 0)
|
||||||
|
optional bool unread_only = 4; // Фильтр: получить только непрочитанные
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetNotificationsResponse {
|
||||||
|
repeated Notification notifications = 1; // Массив уведомлений
|
||||||
|
int32 total_count = 2; // Общее количество (для UI пагинации)
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetUnreadCountRequest {
|
||||||
|
string user_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetUnreadCountResponse {
|
||||||
|
int32 count = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message MarkAsReadRequest {
|
||||||
|
string user_id = 1;
|
||||||
|
string notification_id = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message MarkAsReadResponse {
|
||||||
|
bool success = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message MarkAllAsReadRequest {
|
||||||
|
string user_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message MarkAllAsReadResponse {
|
||||||
|
bool success = 1;
|
||||||
|
int32 updated_count = 2; // Сколько уведомлений было обновлено
|
||||||
|
}
|
||||||
|
|
||||||
|
message SendNotificationRequest {
|
||||||
|
string user_id = 1; // Кому отправляем (если пусто — можно сделать бродкаст, но лучше отдельный метод)
|
||||||
|
string type = 2;
|
||||||
|
string title = 3;
|
||||||
|
string text = 4;
|
||||||
|
google.protobuf.Struct payload = 5; // Метаданные для UI (ссылки, ID сущностей)
|
||||||
|
}
|
||||||
|
|
||||||
|
message SendNotificationResponse {
|
||||||
|
bool success = 1;
|
||||||
|
string notification_id = 2; // ID созданного уведомления в Postgres
|
||||||
|
}
|
||||||
@@ -11,4 +11,8 @@ export const PROTO_PATHS = {
|
|||||||
LDAP: join(__dirname, "../../proto/users/ldap.proto"),
|
LDAP: join(__dirname, "../../proto/users/ldap.proto"),
|
||||||
SEARCH: join(__dirname, "../../proto/search/search.proto"),
|
SEARCH: join(__dirname, "../../proto/search/search.proto"),
|
||||||
AUDIT: join(__dirname, "../../proto/admin/audit.proto"),
|
AUDIT: join(__dirname, "../../proto/admin/audit.proto"),
|
||||||
|
NOTIFICATIONS: join(
|
||||||
|
__dirname,
|
||||||
|
"../../proto/notifications/notifications.proto",
|
||||||
|
),
|
||||||
} as const;
|
} as const;
|
||||||
|
|||||||
Reference in New Issue
Block a user