@barumetric/contracts 1.2.12 → 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.
- package/dist/proto/paths.d.ts +1 -0
- package/dist/proto/paths.js +1 -0
- package/gen/ts/presence.ts +180 -0
- package/package.json +1 -1
- package/proto/presence.proto +95 -0
package/dist/proto/paths.d.ts
CHANGED
package/dist/proto/paths.js
CHANGED
|
@@ -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,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
|
@@ -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
|
+
|