@barumetric/contracts 1.4.9 → 1.4.11

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.
@@ -4,3 +4,4 @@ export * from "./balance";
4
4
  export * from "./listings";
5
5
  export * from "./payment";
6
6
  export * from "./images";
7
+ export * from "./messages";
@@ -20,3 +20,4 @@ __exportStar(require("./balance"), exports);
20
20
  __exportStar(require("./listings"), exports);
21
21
  __exportStar(require("./payment"), exports);
22
22
  __exportStar(require("./images"), exports);
23
+ __exportStar(require("./messages"), exports);
@@ -0,0 +1,5 @@
1
+ export * from './message-types';
2
+ export * from './send-message-command.interface';
3
+ export * from './mark-as-read-command.interface';
4
+ export * from './message-sent-event.interface';
5
+ export * from './message-read-event.interface';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./message-types"), exports);
18
+ __exportStar(require("./send-message-command.interface"), exports);
19
+ __exportStar(require("./mark-as-read-command.interface"), exports);
20
+ __exportStar(require("./message-sent-event.interface"), exports);
21
+ __exportStar(require("./message-read-event.interface"), exports);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * RMQ command
3
+ * pattern: `messages.message.read`
4
+ */
5
+ export interface MarkAsReadCommand {
6
+ conversationId: string;
7
+ userId: string;
8
+ messageIds?: string[];
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ /**
2
+ * RMQ event
3
+ * pattern: `messages.message.read`
4
+ *
5
+ * Emitted by: messages-service
6
+ * Consumed by: messages-service-ws
7
+ */
8
+ export interface MessageReadEvent {
9
+ conversationId: string;
10
+ userId: string;
11
+ markedCount: number;
12
+ messageIds?: string[];
13
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,34 @@
1
+ import type { MessageType } from './message-types';
2
+ export interface MessageDto {
3
+ id: string;
4
+ conversationId: string;
5
+ senderId: string;
6
+ text?: string | null;
7
+ type: MessageType;
8
+ imageUrl?: string | null;
9
+ fileUrl?: string | null;
10
+ fileName?: string | null;
11
+ fileSize?: number | null;
12
+ mimeType?: string | null;
13
+ read: boolean;
14
+ readAt?: string | null;
15
+ delivered: boolean;
16
+ deliveredAt?: string | null;
17
+ replyToIds: string[];
18
+ createdAt: string;
19
+ updatedAt: string;
20
+ }
21
+ /**
22
+ * RMQ event
23
+ * pattern: `messages.message.sent`
24
+ *
25
+ * Emitted by: messages-service
26
+ * Consumed by: messages-service-ws
27
+ */
28
+ export interface MessageSentEvent {
29
+ conversationId: string;
30
+ message: MessageDto;
31
+ senderId: string;
32
+ recipientId: string;
33
+ clientMessageId?: string | null;
34
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export type MessageType = 'TEXT' | 'IMAGE' | 'FILE' | 'VOICE' | 'LOCATION' | 'SYSTEM';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,21 @@
1
+ import type { MessageType } from './message-types';
2
+ /**
3
+ * RMQ command
4
+ * pattern: `messages.message.send`
5
+ */
6
+ export interface SendMessageCommand {
7
+ conversationId: string;
8
+ senderId: string;
9
+ text?: string;
10
+ type?: MessageType;
11
+ imageUrl?: string;
12
+ fileUrl?: string;
13
+ fileName?: string;
14
+ fileSize?: number;
15
+ mimeType?: string;
16
+ replyToIds?: string[];
17
+ /**
18
+ * Optional client correlation/idempotency key
19
+ */
20
+ clientMessageId?: string;
21
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -10,4 +10,5 @@ export declare const PROTO_PATHS: {
10
10
  readonly PRESENCE: string;
11
11
  readonly PAYMENT: string;
12
12
  readonly BALANCE: string;
13
+ readonly MESSAGES: string;
13
14
  };
@@ -14,4 +14,5 @@ exports.PROTO_PATHS = {
14
14
  PRESENCE: (0, path_1.join)(__dirname, "../../proto/presence.proto"),
15
15
  PAYMENT: (0, path_1.join)(__dirname, "../../proto/payment.proto"),
16
16
  BALANCE: (0, path_1.join)(__dirname, "../../proto/balance.proto"),
17
+ MESSAGES: (0, path_1.join)(__dirname, "../../proto/messages.proto"),
17
18
  };
@@ -0,0 +1,213 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.0
4
+ // protoc v3.21.12
5
+ // source: messages.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 = "messages.v1";
13
+
14
+ export enum MessageType {
15
+ MESSAGE_TYPE_UNSPECIFIED = 0,
16
+ MESSAGE_TYPE_TEXT = 1,
17
+ MESSAGE_TYPE_IMAGE = 2,
18
+ MESSAGE_TYPE_FILE = 3,
19
+ MESSAGE_TYPE_VOICE = 4,
20
+ MESSAGE_TYPE_LOCATION = 5,
21
+ MESSAGE_TYPE_SYSTEM = 6,
22
+ UNRECOGNIZED = -1,
23
+ }
24
+
25
+ export interface Conversation {
26
+ id: string;
27
+ listingId: string;
28
+ sellerId: string;
29
+ buyerId: string;
30
+ lastMessageAt: Timestamp | undefined;
31
+ lastMessageId: string;
32
+ lastMessagePreview: string;
33
+ unreadForSeller: number;
34
+ unreadForBuyer: number;
35
+ createdAt: Timestamp | undefined;
36
+ updatedAt: Timestamp | undefined;
37
+ }
38
+
39
+ export interface Message {
40
+ id: string;
41
+ conversationId: string;
42
+ senderId: string;
43
+ text: string;
44
+ type: MessageType;
45
+ imageUrl: string;
46
+ fileUrl: string;
47
+ fileName: string;
48
+ fileSize: number;
49
+ mimeType: string;
50
+ read: boolean;
51
+ readAt: Timestamp | undefined;
52
+ delivered: boolean;
53
+ deliveredAt: Timestamp | undefined;
54
+ replyToIds: string[];
55
+ createdAt: Timestamp | undefined;
56
+ updatedAt: Timestamp | undefined;
57
+ }
58
+
59
+ export interface GetConversationsRequest {
60
+ userId: string;
61
+ limit: number;
62
+ cursor: string;
63
+ }
64
+
65
+ export interface GetConversationsResponse {
66
+ conversations: Conversation[];
67
+ nextCursor: string;
68
+ }
69
+
70
+ export interface GetConversationRequest {
71
+ conversationId: string;
72
+ userId: string;
73
+ }
74
+
75
+ export interface GetConversationResponse {
76
+ conversation: Conversation | undefined;
77
+ }
78
+
79
+ export interface CreateConversationRequest {
80
+ sellerId: string;
81
+ buyerId: string;
82
+ listingId: string;
83
+ }
84
+
85
+ export interface CreateConversationResponse {
86
+ conversation: Conversation | undefined;
87
+ }
88
+
89
+ export interface GetMessagesRequest {
90
+ conversationId: string;
91
+ userId: string;
92
+ limit: number;
93
+ cursor: string;
94
+ }
95
+
96
+ export interface GetMessagesResponse {
97
+ messages: Message[];
98
+ nextCursor: string;
99
+ }
100
+
101
+ export interface SendMessageRequest {
102
+ conversationId: string;
103
+ senderId: string;
104
+ text: string;
105
+ type: MessageType;
106
+ imageUrl: string;
107
+ fileUrl: string;
108
+ fileName: string;
109
+ fileSize: number;
110
+ mimeType: string;
111
+ replyToIds: string[];
112
+ clientMessageId: string;
113
+ }
114
+
115
+ export interface SendMessageResponse {
116
+ message: Message | undefined;
117
+ }
118
+
119
+ export interface MarkAsReadRequest {
120
+ conversationId: string;
121
+ userId: string;
122
+ messageIds: string[];
123
+ }
124
+
125
+ export interface MarkAsReadResponse {
126
+ markedCount: number;
127
+ }
128
+
129
+ export interface SearchMessagesRequest {
130
+ userId: string;
131
+ conversationId: string;
132
+ query: string;
133
+ limit: number;
134
+ cursor: string;
135
+ }
136
+
137
+ export interface SearchMessagesResponse {
138
+ messages: Message[];
139
+ nextCursor: string;
140
+ }
141
+
142
+ export const MESSAGES_V1_PACKAGE_NAME = "messages.v1";
143
+
144
+ export interface MessagesServiceClient {
145
+ getConversations(request: GetConversationsRequest): Observable<GetConversationsResponse>;
146
+
147
+ getConversation(request: GetConversationRequest): Observable<GetConversationResponse>;
148
+
149
+ createConversation(request: CreateConversationRequest): Observable<CreateConversationResponse>;
150
+
151
+ getMessages(request: GetMessagesRequest): Observable<GetMessagesResponse>;
152
+
153
+ sendMessage(request: SendMessageRequest): Observable<SendMessageResponse>;
154
+
155
+ markAsRead(request: MarkAsReadRequest): Observable<MarkAsReadResponse>;
156
+
157
+ searchMessages(request: SearchMessagesRequest): Observable<SearchMessagesResponse>;
158
+ }
159
+
160
+ export interface MessagesServiceController {
161
+ getConversations(
162
+ request: GetConversationsRequest,
163
+ ): Promise<GetConversationsResponse> | Observable<GetConversationsResponse> | GetConversationsResponse;
164
+
165
+ getConversation(
166
+ request: GetConversationRequest,
167
+ ): Promise<GetConversationResponse> | Observable<GetConversationResponse> | GetConversationResponse;
168
+
169
+ createConversation(
170
+ request: CreateConversationRequest,
171
+ ): Promise<CreateConversationResponse> | Observable<CreateConversationResponse> | CreateConversationResponse;
172
+
173
+ getMessages(
174
+ request: GetMessagesRequest,
175
+ ): Promise<GetMessagesResponse> | Observable<GetMessagesResponse> | GetMessagesResponse;
176
+
177
+ sendMessage(
178
+ request: SendMessageRequest,
179
+ ): Promise<SendMessageResponse> | Observable<SendMessageResponse> | SendMessageResponse;
180
+
181
+ markAsRead(
182
+ request: MarkAsReadRequest,
183
+ ): Promise<MarkAsReadResponse> | Observable<MarkAsReadResponse> | MarkAsReadResponse;
184
+
185
+ searchMessages(
186
+ request: SearchMessagesRequest,
187
+ ): Promise<SearchMessagesResponse> | Observable<SearchMessagesResponse> | SearchMessagesResponse;
188
+ }
189
+
190
+ export function MessagesServiceControllerMethods() {
191
+ return function (constructor: Function) {
192
+ const grpcMethods: string[] = [
193
+ "getConversations",
194
+ "getConversation",
195
+ "createConversation",
196
+ "getMessages",
197
+ "sendMessage",
198
+ "markAsRead",
199
+ "searchMessages",
200
+ ];
201
+ for (const method of grpcMethods) {
202
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
203
+ GrpcMethod("MessagesService", method)(constructor.prototype[method], method, descriptor);
204
+ }
205
+ const grpcStreamMethods: string[] = [];
206
+ for (const method of grpcStreamMethods) {
207
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
208
+ GrpcStreamMethod("MessagesService", method)(constructor.prototype[method], method, descriptor);
209
+ }
210
+ };
211
+ }
212
+
213
+ export const MESSAGES_SERVICE_NAME = "MessagesService";
package/gen/ts/users.ts CHANGED
@@ -95,6 +95,18 @@ export interface PatchUserResponse {
95
95
  ok: boolean;
96
96
  }
97
97
 
98
+ export interface PatchUserLocationRequest {
99
+ userId: string;
100
+ city?: string | undefined;
101
+ region?: string | undefined;
102
+ latitude?: number | undefined;
103
+ longitude?: number | undefined;
104
+ }
105
+
106
+ export interface PatchUserLocationResponse {
107
+ ok: boolean;
108
+ }
109
+
98
110
  export interface User {
99
111
  id: string;
100
112
  /** Базовые поля */
@@ -208,6 +220,8 @@ export interface UsersServiceClient {
208
220
  createUser(request: CreateUserRequest): Observable<CreateUserResponse>;
209
221
 
210
222
  patchUser(request: PatchUserRequest): Observable<PatchUserResponse>;
223
+
224
+ patchUserLocation(request: PatchUserLocationRequest): Observable<PatchUserLocationResponse>;
211
225
  }
212
226
 
213
227
  export interface UsersServiceController {
@@ -218,11 +232,15 @@ export interface UsersServiceController {
218
232
  ): Promise<CreateUserResponse> | Observable<CreateUserResponse> | CreateUserResponse;
219
233
 
220
234
  patchUser(request: PatchUserRequest): Promise<PatchUserResponse> | Observable<PatchUserResponse> | PatchUserResponse;
235
+
236
+ patchUserLocation(
237
+ request: PatchUserLocationRequest,
238
+ ): Promise<PatchUserLocationResponse> | Observable<PatchUserLocationResponse> | PatchUserLocationResponse;
221
239
  }
222
240
 
223
241
  export function UsersServiceControllerMethods() {
224
242
  return function (constructor: Function) {
225
- const grpcMethods: string[] = ["getMe", "createUser", "patchUser"];
243
+ const grpcMethods: string[] = ["getMe", "createUser", "patchUser", "patchUserLocation"];
226
244
  for (const method of grpcMethods) {
227
245
  const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
228
246
  GrpcMethod("UsersService", method)(constructor.prototype[method], method, descriptor);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barumetric/contracts",
3
- "version": "1.4.9",
3
+ "version": "1.4.11",
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,158 @@
1
+ syntax = "proto3";
2
+
3
+ package messages.v1;
4
+
5
+ import "google/protobuf/timestamp.proto";
6
+
7
+ service MessagesService {
8
+ rpc GetConversations(GetConversationsRequest) returns (GetConversationsResponse);
9
+ rpc GetConversation(GetConversationRequest) returns (GetConversationResponse);
10
+ rpc CreateConversation(CreateConversationRequest) returns (CreateConversationResponse);
11
+
12
+ rpc GetMessages(GetMessagesRequest) returns (GetMessagesResponse);
13
+ rpc SendMessage(SendMessageRequest) returns (SendMessageResponse);
14
+ rpc MarkAsRead(MarkAsReadRequest) returns (MarkAsReadResponse);
15
+
16
+ rpc SearchMessages(SearchMessagesRequest) returns (SearchMessagesResponse);
17
+ }
18
+
19
+ message Conversation {
20
+ string id = 1;
21
+ string listing_id = 2;
22
+
23
+ string seller_id = 3;
24
+ string buyer_id = 4;
25
+
26
+ google.protobuf.Timestamp last_message_at = 5;
27
+ string last_message_id = 6;
28
+ string last_message_preview = 7;
29
+
30
+ int32 unread_for_seller = 8;
31
+ int32 unread_for_buyer = 9;
32
+
33
+ google.protobuf.Timestamp created_at = 10;
34
+ google.protobuf.Timestamp updated_at = 11;
35
+ }
36
+
37
+ enum MessageType {
38
+ MESSAGE_TYPE_UNSPECIFIED = 0;
39
+ MESSAGE_TYPE_TEXT = 1;
40
+ MESSAGE_TYPE_IMAGE = 2;
41
+ MESSAGE_TYPE_FILE = 3;
42
+ MESSAGE_TYPE_VOICE = 4;
43
+ MESSAGE_TYPE_LOCATION = 5;
44
+ MESSAGE_TYPE_SYSTEM = 6;
45
+ }
46
+
47
+ message Message {
48
+ string id = 1;
49
+ string conversation_id = 2;
50
+ string sender_id = 3;
51
+
52
+ string text = 4;
53
+ MessageType type = 5;
54
+
55
+ string image_url = 6;
56
+ string file_url = 7;
57
+ string file_name = 8;
58
+ int64 file_size = 9;
59
+ string mime_type = 10;
60
+
61
+ bool read = 11;
62
+ google.protobuf.Timestamp read_at = 12;
63
+ bool delivered = 13;
64
+ google.protobuf.Timestamp delivered_at = 14;
65
+
66
+ repeated string reply_to_ids = 15;
67
+
68
+ google.protobuf.Timestamp created_at = 16;
69
+ google.protobuf.Timestamp updated_at = 17;
70
+ }
71
+
72
+ message GetConversationsRequest {
73
+ string user_id = 1;
74
+ int32 limit = 2;
75
+ string cursor = 3;
76
+ }
77
+
78
+ message GetConversationsResponse {
79
+ repeated Conversation conversations = 1;
80
+ string next_cursor = 2;
81
+ }
82
+
83
+ message GetConversationRequest {
84
+ string conversation_id = 1;
85
+ string user_id = 2;
86
+ }
87
+
88
+ message GetConversationResponse {
89
+ Conversation conversation = 1;
90
+ }
91
+
92
+ message CreateConversationRequest {
93
+ string seller_id = 1;
94
+ string buyer_id = 2;
95
+ string listing_id = 3;
96
+ }
97
+
98
+ message CreateConversationResponse {
99
+ Conversation conversation = 1;
100
+ }
101
+
102
+ message GetMessagesRequest {
103
+ string conversation_id = 1;
104
+ string user_id = 2;
105
+ int32 limit = 3;
106
+ string cursor = 4;
107
+ }
108
+
109
+ message GetMessagesResponse {
110
+ repeated Message messages = 1;
111
+ string next_cursor = 2;
112
+ }
113
+
114
+ message SendMessageRequest {
115
+ string conversation_id = 1;
116
+ string sender_id = 2;
117
+
118
+ string text = 3;
119
+ MessageType type = 4;
120
+
121
+ string image_url = 5;
122
+ string file_url = 6;
123
+ string file_name = 7;
124
+ int64 file_size = 8;
125
+ string mime_type = 9;
126
+
127
+ repeated string reply_to_ids = 10;
128
+
129
+ string client_message_id = 11;
130
+ }
131
+
132
+ message SendMessageResponse {
133
+ Message message = 1;
134
+ }
135
+
136
+ message MarkAsReadRequest {
137
+ string conversation_id = 1;
138
+ string user_id = 2;
139
+ repeated string message_ids = 3;
140
+ }
141
+
142
+ message MarkAsReadResponse {
143
+ int32 marked_count = 1;
144
+ }
145
+
146
+ message SearchMessagesRequest {
147
+ string user_id = 1;
148
+ string conversation_id = 2;
149
+ string query = 3;
150
+ int32 limit = 4;
151
+ string cursor = 5;
152
+ }
153
+
154
+ message SearchMessagesResponse {
155
+ repeated Message messages = 1;
156
+ string next_cursor = 2;
157
+ }
158
+
package/proto/users.proto CHANGED
@@ -9,6 +9,7 @@ service UsersService {
9
9
 
10
10
  rpc CreateUser (CreateUserRequest) returns (CreateUserResponse);
11
11
  rpc PatchUser (PatchUserRequest) returns (PatchUserResponse);
12
+ rpc PatchUserLocation (PatchUserLocationRequest) returns (PatchUserLocationResponse);
12
13
  }
13
14
 
14
15
  message GetMeRequest {
@@ -54,6 +55,19 @@ message PatchUserResponse {
54
55
  bool ok = 1;
55
56
  }
56
57
 
58
+ message PatchUserLocationRequest {
59
+ string user_id = 1;
60
+
61
+ optional string city = 2;
62
+ optional string region = 3;
63
+ optional double latitude = 4;
64
+ optional double longitude = 5;
65
+ }
66
+
67
+ message PatchUserLocationResponse {
68
+ bool ok = 1;
69
+ }
70
+
57
71
  message User {
58
72
  string id = 1;
59
73