@barumetric/contracts 1.2.11 → 1.2.13

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
  };
package/gen/ts/auth.ts CHANGED
@@ -27,25 +27,6 @@ export interface VerifyOtpRequest {
27
27
  sessionMetadata: SessionMetadata | undefined;
28
28
  }
29
29
 
30
- export interface SessionMetadata {
31
- location: LocationInfo | undefined;
32
- device: DeviceInfo | undefined;
33
- ip: string;
34
- }
35
-
36
- export interface LocationInfo {
37
- country: string;
38
- city: string;
39
- latidute: number;
40
- longitude: number;
41
- }
42
-
43
- export interface DeviceInfo {
44
- browser: string;
45
- os: string;
46
- type: string;
47
- }
48
-
49
30
  export interface VerifyOtpResponse {
50
31
  accessToken: string;
51
32
  refreshToken: string;
@@ -76,6 +57,7 @@ export interface TelegramInitResponse {
76
57
 
77
58
  export interface TelegramVerifyRequest {
78
59
  query: { [key: string]: string };
60
+ metadata: SessionMetadata | undefined;
79
61
  }
80
62
 
81
63
  export interface TelegramVerifyRequest_QueryEntry {
@@ -87,6 +69,7 @@ export interface TelegramVerifyResponse {
87
69
  url?: string | undefined;
88
70
  accessToken?: string | undefined;
89
71
  refreshToken?: string | undefined;
72
+ sessionToken?: string | undefined;
90
73
  }
91
74
 
92
75
  export interface TelegramCompleteRequest {
@@ -100,11 +83,32 @@ export interface TelegramCompleteResponse {
100
83
 
101
84
  export interface TelegramConsumeRequest {
102
85
  sessionId: string;
86
+ metadata: SessionMetadata | undefined;
103
87
  }
104
88
 
105
89
  export interface TelegramConsumeResponse {
106
90
  accessToken: string;
107
91
  refreshToken: string;
92
+ sessionToken: string;
93
+ }
94
+
95
+ export interface SessionMetadata {
96
+ location: LocationInfo | undefined;
97
+ device: DeviceInfo | undefined;
98
+ ip: string;
99
+ }
100
+
101
+ export interface LocationInfo {
102
+ country: string;
103
+ city: string;
104
+ latidute: number;
105
+ longitude: number;
106
+ }
107
+
108
+ export interface DeviceInfo {
109
+ browser: string;
110
+ os: string;
111
+ type: string;
108
112
  }
109
113
 
110
114
  export const AUTH_V1_PACKAGE_NAME = "auth.v1";
@@ -0,0 +1,180 @@
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
+ }
17
+
18
+ export interface GetUserStatusResponse {
19
+ /** "online" | "away" | "offline" */
20
+ status: string;
21
+ /** timestamp */
22
+ lastSeen: number;
23
+ /** "web" | "mobile" */
24
+ device: string;
25
+ updatedAt: Timestamp | undefined;
26
+ }
27
+
28
+ export interface GetUsersStatusRequest {
29
+ userIds: string[];
30
+ }
31
+
32
+ export interface GetUsersStatusResponse {
33
+ statuses: UserStatus[];
34
+ }
35
+
36
+ export interface UserStatus {
37
+ userId: string;
38
+ /** "online" | "away" | "offline" */
39
+ status: string;
40
+ lastSeen: number;
41
+ device: string;
42
+ updatedAt: Timestamp | undefined;
43
+ }
44
+
45
+ export interface UpdateStatusRequest {
46
+ userId: string;
47
+ /** WebSocket connection ID */
48
+ connectionId: string;
49
+ /** "web" | "mobile" */
50
+ device: string;
51
+ }
52
+
53
+ export interface UpdateStatusResponse {
54
+ ok: boolean;
55
+ /** текущий статус */
56
+ status: string;
57
+ }
58
+
59
+ export interface RemoveConnectionRequest {
60
+ userId: string;
61
+ connectionId: string;
62
+ }
63
+
64
+ export interface RemoveConnectionResponse {
65
+ ok: boolean;
66
+ /** текущий статус после удаления */
67
+ status: string;
68
+ }
69
+
70
+ export interface SubscribeToStatusRequest {
71
+ /** кто подписывается */
72
+ userId: string;
73
+ /** за какими пользователями следить */
74
+ contactIds: string[];
75
+ }
76
+
77
+ export interface StatusUpdate {
78
+ userId: string;
79
+ /** "online" | "away" | "offline" */
80
+ status: string;
81
+ lastSeen: number;
82
+ device: string;
83
+ updatedAt: Timestamp | undefined;
84
+ }
85
+
86
+ export interface UnsubscribeFromStatusRequest {
87
+ userId: string;
88
+ }
89
+
90
+ export interface UnsubscribeFromStatusResponse {
91
+ ok: boolean;
92
+ }
93
+
94
+ export const PRESENCE_V1_PACKAGE_NAME = "presence.v1";
95
+
96
+ export interface PresenceServiceClient {
97
+ /** Получить статус пользователя */
98
+
99
+ getUserStatus(request: GetUserStatusRequest): Observable<GetUserStatusResponse>;
100
+
101
+ /** Получить статусы нескольких пользователей */
102
+
103
+ getUsersStatus(request: GetUsersStatusRequest): Observable<GetUsersStatusResponse>;
104
+
105
+ /** Обновить статус пользователя (heartbeat) */
106
+
107
+ updateStatus(request: UpdateStatusRequest): Observable<UpdateStatusResponse>;
108
+
109
+ /** Удалить соединение пользователя (при отключении) */
110
+
111
+ removeConnection(request: RemoveConnectionRequest): Observable<RemoveConnectionResponse>;
112
+
113
+ /** Подписаться на изменения статуса (stream) */
114
+
115
+ subscribeToStatus(request: SubscribeToStatusRequest): Observable<StatusUpdate>;
116
+
117
+ /** Отписаться от изменений статуса */
118
+
119
+ unsubscribeFromStatus(request: UnsubscribeFromStatusRequest): Observable<UnsubscribeFromStatusResponse>;
120
+ }
121
+
122
+ export interface PresenceServiceController {
123
+ /** Получить статус пользователя */
124
+
125
+ getUserStatus(
126
+ request: GetUserStatusRequest,
127
+ ): Promise<GetUserStatusResponse> | Observable<GetUserStatusResponse> | GetUserStatusResponse;
128
+
129
+ /** Получить статусы нескольких пользователей */
130
+
131
+ getUsersStatus(
132
+ request: GetUsersStatusRequest,
133
+ ): Promise<GetUsersStatusResponse> | Observable<GetUsersStatusResponse> | GetUsersStatusResponse;
134
+
135
+ /** Обновить статус пользователя (heartbeat) */
136
+
137
+ updateStatus(
138
+ request: UpdateStatusRequest,
139
+ ): Promise<UpdateStatusResponse> | Observable<UpdateStatusResponse> | UpdateStatusResponse;
140
+
141
+ /** Удалить соединение пользователя (при отключении) */
142
+
143
+ removeConnection(
144
+ request: RemoveConnectionRequest,
145
+ ): Promise<RemoveConnectionResponse> | Observable<RemoveConnectionResponse> | RemoveConnectionResponse;
146
+
147
+ /** Подписаться на изменения статуса (stream) */
148
+
149
+ subscribeToStatus(request: SubscribeToStatusRequest): Observable<StatusUpdate>;
150
+
151
+ /** Отписаться от изменений статуса */
152
+
153
+ unsubscribeFromStatus(
154
+ request: UnsubscribeFromStatusRequest,
155
+ ): Promise<UnsubscribeFromStatusResponse> | Observable<UnsubscribeFromStatusResponse> | UnsubscribeFromStatusResponse;
156
+ }
157
+
158
+ export function PresenceServiceControllerMethods() {
159
+ return function (constructor: Function) {
160
+ const grpcMethods: string[] = [
161
+ "getUserStatus",
162
+ "getUsersStatus",
163
+ "updateStatus",
164
+ "removeConnection",
165
+ "subscribeToStatus",
166
+ "unsubscribeFromStatus",
167
+ ];
168
+ for (const method of grpcMethods) {
169
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
170
+ GrpcMethod("PresenceService", method)(constructor.prototype[method], method, descriptor);
171
+ }
172
+ const grpcStreamMethods: string[] = [];
173
+ for (const method of grpcStreamMethods) {
174
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
175
+ GrpcStreamMethod("PresenceService", method)(constructor.prototype[method], method, descriptor);
176
+ }
177
+ };
178
+ }
179
+
180
+ 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.11",
3
+ "version": "1.2.13",
4
4
  "description": "Protobuf definitions and generated TypeScript types",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
package/proto/auth.proto CHANGED
@@ -32,25 +32,6 @@ message VerifyOtpRequest {
32
32
  SessionMetadata session_metadata = 4;
33
33
  }
34
34
 
35
- message SessionMetadata {
36
- LocationInfo location = 1;
37
- DeviceInfo device = 2;
38
- string ip = 3;
39
- }
40
-
41
- message LocationInfo {
42
- string country = 1;
43
- string city = 2;
44
- int32 latidute = 3;
45
- int32 longitude = 4;
46
- }
47
-
48
- message DeviceInfo {
49
- string browser = 1;
50
- string os = 2;
51
- string type = 3;
52
- }
53
-
54
35
  message VerifyOtpResponse {
55
36
  string access_token = 1;
56
37
  string refresh_token = 2;
@@ -81,6 +62,7 @@ message TelegramInitResponse {
81
62
 
82
63
  message TelegramVerifyRequest {
83
64
  map<string, string> query = 1;
65
+ SessionMetadata metadata = 2;
84
66
  }
85
67
 
86
68
  message TelegramVerifyResponse {
@@ -88,7 +70,9 @@ message TelegramVerifyResponse {
88
70
  string url = 1;
89
71
  string access_token = 2;
90
72
  string refresh_token = 3;
73
+ string session_token = 4;
91
74
  }
75
+
92
76
  }
93
77
 
94
78
  message TelegramCompleteRequest {
@@ -102,9 +86,30 @@ message TelegramCompleteResponse {
102
86
 
103
87
  message TelegramConsumeRequest {
104
88
  string session_id = 1;
89
+ SessionMetadata metadata = 2;
105
90
  }
106
91
 
107
92
  message TelegramConsumeResponse {
108
93
  string access_token = 1;
109
94
  string refresh_token = 2;
110
- }
95
+ string session_token = 3;
96
+ }
97
+
98
+ message SessionMetadata {
99
+ LocationInfo location = 1;
100
+ DeviceInfo device = 2;
101
+ string ip = 3;
102
+ }
103
+
104
+ message LocationInfo {
105
+ string country = 1;
106
+ string city = 2;
107
+ int32 latidute = 3;
108
+ int32 longitude = 4;
109
+ }
110
+
111
+ message DeviceInfo {
112
+ string browser = 1;
113
+ string os = 2;
114
+ string type = 3;
115
+ }
@@ -0,0 +1,95 @@
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
+ // Получить статусы нескольких пользователей
12
+ rpc GetUsersStatus (GetUsersStatusRequest) returns (GetUsersStatusResponse);
13
+
14
+ // Обновить статус пользователя (heartbeat)
15
+ rpc UpdateStatus (UpdateStatusRequest) returns (UpdateStatusResponse);
16
+
17
+ // Удалить соединение пользователя (при отключении)
18
+ rpc RemoveConnection (RemoveConnectionRequest) returns (RemoveConnectionResponse);
19
+
20
+ // Подписаться на изменения статуса (stream)
21
+ rpc SubscribeToStatus (SubscribeToStatusRequest) returns (stream StatusUpdate);
22
+
23
+ // Отписаться от изменений статуса
24
+ rpc UnsubscribeFromStatus (UnsubscribeFromStatusRequest) returns (UnsubscribeFromStatusResponse);
25
+ }
26
+
27
+ message GetUserStatusRequest {
28
+ string user_id = 1;
29
+ }
30
+
31
+ message GetUserStatusResponse {
32
+ string status = 1; // "online" | "away" | "offline"
33
+ int64 last_seen = 2; // timestamp
34
+ string device = 3; // "web" | "mobile"
35
+ google.protobuf.Timestamp updated_at = 4;
36
+ }
37
+
38
+ message GetUsersStatusRequest {
39
+ repeated string user_ids = 1;
40
+ }
41
+
42
+ message GetUsersStatusResponse {
43
+ repeated UserStatus statuses = 1;
44
+ }
45
+
46
+ message UserStatus {
47
+ string user_id = 1;
48
+ string status = 2; // "online" | "away" | "offline"
49
+ int64 last_seen = 3;
50
+ string device = 4;
51
+ google.protobuf.Timestamp updated_at = 5;
52
+ }
53
+
54
+ message UpdateStatusRequest {
55
+ string user_id = 1;
56
+ string connection_id = 2; // WebSocket connection ID
57
+ string device = 3; // "web" | "mobile"
58
+ }
59
+
60
+ message UpdateStatusResponse {
61
+ bool ok = 1;
62
+ string status = 2; // текущий статус
63
+ }
64
+
65
+ message RemoveConnectionRequest {
66
+ string user_id = 1;
67
+ string connection_id = 2;
68
+ }
69
+
70
+ message RemoveConnectionResponse {
71
+ bool ok = 1;
72
+ string status = 2; // текущий статус после удаления
73
+ }
74
+
75
+ message SubscribeToStatusRequest {
76
+ string user_id = 1; // кто подписывается
77
+ repeated string contact_ids = 2; // за какими пользователями следить
78
+ }
79
+
80
+ message StatusUpdate {
81
+ string user_id = 1;
82
+ string status = 2; // "online" | "away" | "offline"
83
+ int64 last_seen = 3;
84
+ string device = 4;
85
+ google.protobuf.Timestamp updated_at = 5;
86
+ }
87
+
88
+ message UnsubscribeFromStatusRequest {
89
+ string user_id = 1;
90
+ }
91
+
92
+ message UnsubscribeFromStatusResponse {
93
+ bool ok = 1;
94
+ }
95
+