@barumetric/contracts 1.2.12 → 1.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,4 +5,5 @@ export declare const PROTO_PATHS: {
5
5
  readonly MEDIA: string;
6
6
  readonly CATEGORIES: string;
7
7
  readonly SESSION: string;
8
+ readonly PRESENCE: string;
8
9
  };
@@ -9,4 +9,5 @@ exports.PROTO_PATHS = {
9
9
  MEDIA: (0, path_1.join)(__dirname, "../../proto/media.proto"),
10
10
  CATEGORIES: (0, path_1.join)(__dirname, "../../proto/categories.proto"),
11
11
  SESSION: (0, path_1.join)(__dirname, "../../proto/session.proto"),
12
+ PRESENCE: (0, path_1.join)(__dirname, "../../proto/presence.proto"),
12
13
  };
@@ -0,0 +1,107 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.10.1
4
+ // protoc v3.21.12
5
+ // source: presence.proto
6
+
7
+ /* eslint-disable */
8
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { Observable } from "rxjs";
10
+ import { Timestamp } from "./google/protobuf/timestamp";
11
+
12
+ export const protobufPackage = "presence.v1";
13
+
14
+ export interface GetUserStatusRequest {
15
+ userId: string;
16
+ /** WebSocket connection ID */
17
+ connectionId?: string | undefined;
18
+ }
19
+
20
+ export interface GetUserStatusResponse {
21
+ /** "online" | "away" | "offline" */
22
+ status: string;
23
+ /** timestamp */
24
+ lastSeen:
25
+ | Timestamp
26
+ | undefined;
27
+ /** "web" | "mobile" */
28
+ device: string;
29
+ }
30
+
31
+ export interface UpdateStatusRequest {
32
+ userId: string;
33
+ /** WebSocket connection ID */
34
+ connectionId: string;
35
+ /** "web" | "mobile" */
36
+ device: string;
37
+ }
38
+
39
+ export interface UpdateStatusResponse {
40
+ ok: boolean;
41
+ /** текущий статус */
42
+ status: string;
43
+ }
44
+
45
+ export interface RemoveConnectionRequest {
46
+ userId: string;
47
+ connectionId: string;
48
+ }
49
+
50
+ export interface RemoveConnectionResponse {
51
+ ok: boolean;
52
+ /** текущий статус после удаления */
53
+ status: string;
54
+ }
55
+
56
+ export const PRESENCE_V1_PACKAGE_NAME = "presence.v1";
57
+
58
+ export interface PresenceServiceClient {
59
+ /** Получить статус пользователя */
60
+
61
+ getUserStatus(request: GetUserStatusRequest): Observable<GetUserStatusResponse>;
62
+
63
+ /** Обновить статус пользователя (heartbeat) */
64
+
65
+ updateStatus(request: UpdateStatusRequest): Observable<UpdateStatusResponse>;
66
+
67
+ /** Удалить соединение пользователя (при отключении) */
68
+
69
+ removeConnection(request: RemoveConnectionRequest): Observable<RemoveConnectionResponse>;
70
+ }
71
+
72
+ export interface PresenceServiceController {
73
+ /** Получить статус пользователя */
74
+
75
+ getUserStatus(
76
+ request: GetUserStatusRequest,
77
+ ): Promise<GetUserStatusResponse> | Observable<GetUserStatusResponse> | GetUserStatusResponse;
78
+
79
+ /** Обновить статус пользователя (heartbeat) */
80
+
81
+ updateStatus(
82
+ request: UpdateStatusRequest,
83
+ ): Promise<UpdateStatusResponse> | Observable<UpdateStatusResponse> | UpdateStatusResponse;
84
+
85
+ /** Удалить соединение пользователя (при отключении) */
86
+
87
+ removeConnection(
88
+ request: RemoveConnectionRequest,
89
+ ): Promise<RemoveConnectionResponse> | Observable<RemoveConnectionResponse> | RemoveConnectionResponse;
90
+ }
91
+
92
+ export function PresenceServiceControllerMethods() {
93
+ return function (constructor: Function) {
94
+ const grpcMethods: string[] = ["getUserStatus", "updateStatus", "removeConnection"];
95
+ for (const method of grpcMethods) {
96
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
97
+ GrpcMethod("PresenceService", method)(constructor.prototype[method], method, descriptor);
98
+ }
99
+ const grpcStreamMethods: string[] = [];
100
+ for (const method of grpcStreamMethods) {
101
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
102
+ GrpcStreamMethod("PresenceService", method)(constructor.prototype[method], method, descriptor);
103
+ }
104
+ };
105
+ }
106
+
107
+ export const PRESENCE_SERVICE_NAME = "PresenceService";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barumetric/contracts",
3
- "version": "1.2.12",
3
+ "version": "1.2.14",
4
4
  "description": "Protobuf definitions and generated TypeScript types",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -0,0 +1,49 @@
1
+ syntax = "proto3";
2
+
3
+ package presence.v1;
4
+
5
+ import "google/protobuf/timestamp.proto";
6
+
7
+ service PresenceService {
8
+ // Получить статус пользователя
9
+ rpc GetUserStatus (GetUserStatusRequest) returns (GetUserStatusResponse);
10
+
11
+ // Обновить статус пользователя (heartbeat)
12
+ rpc UpdateStatus (UpdateStatusRequest) returns (UpdateStatusResponse);
13
+
14
+ // Удалить соединение пользователя (при отключении)
15
+ rpc RemoveConnection (RemoveConnectionRequest) returns (RemoveConnectionResponse);
16
+
17
+ }
18
+
19
+ message GetUserStatusRequest {
20
+ string user_id = 1;
21
+ optional string connection_id = 2; // WebSocket connection ID
22
+ }
23
+
24
+ message GetUserStatusResponse {
25
+ string status = 1; // "online" | "away" | "offline"
26
+ google.protobuf.Timestamp last_seen = 2; // timestamp
27
+ string device = 3; // "web" | "mobile"
28
+ }
29
+
30
+ message UpdateStatusRequest {
31
+ string user_id = 1;
32
+ string connection_id = 2; // WebSocket connection ID
33
+ string device = 3; // "web" | "mobile"
34
+ }
35
+
36
+ message UpdateStatusResponse {
37
+ bool ok = 1;
38
+ string status = 2; // текущий статус
39
+ }
40
+
41
+ message RemoveConnectionRequest {
42
+ string user_id = 1;
43
+ string connection_id = 2;
44
+ }
45
+
46
+ message RemoveConnectionResponse {
47
+ bool ok = 1;
48
+ string status = 2; // текущий статус после удаления
49
+ }