@readytomog/contracts 1.2.3 → 1.3.1

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.
@@ -0,0 +1 @@
1
+ export * from "./send-message.interface";
@@ -0,0 +1,17 @@
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("./send-message.interface"), exports);
@@ -0,0 +1,6 @@
1
+ export interface SendMessageEvent {
2
+ message: string;
3
+ sendFrom: number;
4
+ sendTo: number;
5
+ chatId: number;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
1
  export * from "./auth";
2
+ export * from "./chat";
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./auth"), exports);
18
+ __exportStar(require("./chat"), exports);
@@ -1,4 +1,5 @@
1
1
  export declare const PROTO_PATHS: {
2
2
  readonly AUTH: string;
3
3
  readonly USER: string;
4
+ readonly CHAT: string;
4
5
  };
@@ -5,4 +5,5 @@ const path_1 = require("path");
5
5
  exports.PROTO_PATHS = {
6
6
  AUTH: (0, path_1.join)(__dirname, "../../proto/auth.proto"),
7
7
  USER: (0, path_1.join)(__dirname, "../../proto/user.proto"),
8
+ CHAT: (0, path_1.join)(__dirname, "../../proto/chat.proto"),
8
9
  };
package/gen/chat.d.ts ADDED
@@ -0,0 +1,60 @@
1
+ import { Observable } from "rxjs";
2
+ export declare const protobufPackage = "chat.v1";
3
+ export interface CreateChatRequest {
4
+ participant: number;
5
+ }
6
+ export interface CreateChatResponse {
7
+ id: number;
8
+ participant1: number;
9
+ participant2: number;
10
+ }
11
+ export interface DeleteChatRequest {
12
+ chatId: number;
13
+ }
14
+ export interface DeleteChatResponse {
15
+ message: string;
16
+ }
17
+ export interface Mesage {
18
+ message: string;
19
+ senderId: number;
20
+ recieverId: number;
21
+ id: number;
22
+ }
23
+ export interface User {
24
+ id: number;
25
+ name: string;
26
+ surname: string;
27
+ avatar: string;
28
+ }
29
+ export interface Chat {
30
+ id: number;
31
+ users: User[];
32
+ lastMessage: string;
33
+ }
34
+ export interface GetMessagesRequest {
35
+ chatId: number;
36
+ }
37
+ export interface GetMessagesResponse {
38
+ mesages: Mesage[];
39
+ }
40
+ export interface GetChatsRequest {
41
+ userId: number;
42
+ }
43
+ export interface GetChatsResponse {
44
+ chats: Chat[];
45
+ }
46
+ export declare const CHAT_V1_PACKAGE_NAME = "chat.v1";
47
+ export interface ChatServiceClient {
48
+ createChat(request: CreateChatRequest): Observable<CreateChatResponse>;
49
+ deleteChat(request: DeleteChatRequest): Observable<DeleteChatResponse>;
50
+ getMessages(request: GetMessagesRequest): Observable<GetMessagesResponse>;
51
+ getChats(request: GetChatsRequest): Observable<GetChatsResponse>;
52
+ }
53
+ export interface ChatServiceController {
54
+ createChat(request: CreateChatRequest): Promise<CreateChatResponse> | Observable<CreateChatResponse> | CreateChatResponse;
55
+ deleteChat(request: DeleteChatRequest): Promise<DeleteChatResponse> | Observable<DeleteChatResponse> | DeleteChatResponse;
56
+ getMessages(request: GetMessagesRequest): Promise<GetMessagesResponse> | Observable<GetMessagesResponse> | GetMessagesResponse;
57
+ getChats(request: GetChatsRequest): Promise<GetChatsResponse> | Observable<GetChatsResponse> | GetChatsResponse;
58
+ }
59
+ export declare function ChatServiceControllerMethods(): (constructor: Function) => void;
60
+ export declare const CHAT_SERVICE_NAME = "ChatService";
package/gen/chat.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CHAT_SERVICE_NAME = exports.CHAT_V1_PACKAGE_NAME = exports.protobufPackage = void 0;
4
+ exports.ChatServiceControllerMethods = ChatServiceControllerMethods;
5
+ const microservices_1 = require("@nestjs/microservices");
6
+ exports.protobufPackage = "chat.v1";
7
+ exports.CHAT_V1_PACKAGE_NAME = "chat.v1";
8
+ function ChatServiceControllerMethods() {
9
+ return function (constructor) {
10
+ const grpcMethods = ["createChat", "deleteChat", "getMessages", "getChats"];
11
+ for (const method of grpcMethods) {
12
+ const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
13
+ (0, microservices_1.GrpcMethod)("ChatService", method)(constructor.prototype[method], method, descriptor);
14
+ }
15
+ const grpcStreamMethods = [];
16
+ for (const method of grpcStreamMethods) {
17
+ const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
18
+ (0, microservices_1.GrpcStreamMethod)("ChatService", method)(constructor.prototype[method], method, descriptor);
19
+ }
20
+ };
21
+ }
22
+ exports.CHAT_SERVICE_NAME = "ChatService";
23
+ //# sourceMappingURL=chat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat.js","sourceRoot":"","sources":["chat.ts"],"names":[],"mappings":";;;AA8FA,oEAaC;AApGD,yDAAqE;AAGxD,QAAA,eAAe,GAAG,SAAS,CAAC;AAwD5B,QAAA,oBAAoB,GAAG,SAAS,CAAC;AA4B9C,SAAgB,4BAA4B;IAC1C,OAAO,UAAU,WAAqB;QACpC,MAAM,WAAW,GAAa,CAAC,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;QACtF,KAAK,MAAM,MAAM,IAAI,WAAW,EAAE,CAAC;YACjC,MAAM,UAAU,GAAQ,OAAO,CAAC,wBAAwB,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YACxF,IAAA,0BAAU,EAAC,aAAa,EAAE,MAAM,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;QACvF,CAAC;QACD,MAAM,iBAAiB,GAAa,EAAE,CAAC;QACvC,KAAK,MAAM,MAAM,IAAI,iBAAiB,EAAE,CAAC;YACvC,MAAM,UAAU,GAAQ,OAAO,CAAC,wBAAwB,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YACxF,IAAA,gCAAgB,EAAC,aAAa,EAAE,MAAM,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;QAC7F,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAEY,QAAA,iBAAiB,GAAG,aAAa,CAAC"}
package/gen/chat.ts ADDED
@@ -0,0 +1,110 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.8
4
+ // protoc v3.21.12
5
+ // source: chat.proto
6
+
7
+ /* eslint-disable */
8
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { Observable } from "rxjs";
10
+
11
+ export const protobufPackage = "chat.v1";
12
+
13
+ export interface CreateChatRequest {
14
+ participant: number;
15
+ }
16
+
17
+ export interface CreateChatResponse {
18
+ id: number;
19
+ participant1: number;
20
+ participant2: number;
21
+ }
22
+
23
+ export interface DeleteChatRequest {
24
+ chatId: number;
25
+ }
26
+
27
+ export interface DeleteChatResponse {
28
+ message: string;
29
+ }
30
+
31
+ export interface Mesage {
32
+ message: string;
33
+ senderId: number;
34
+ recieverId: number;
35
+ id: number;
36
+ }
37
+
38
+ export interface User {
39
+ id: number;
40
+ name: string;
41
+ surname: string;
42
+ avatar: string;
43
+ }
44
+
45
+ export interface Chat {
46
+ id: number;
47
+ users: User[];
48
+ lastMessage: string;
49
+ }
50
+
51
+ export interface GetMessagesRequest {
52
+ chatId: number;
53
+ }
54
+
55
+ export interface GetMessagesResponse {
56
+ mesages: Mesage[];
57
+ }
58
+
59
+ export interface GetChatsRequest {
60
+ userId: number;
61
+ }
62
+
63
+ export interface GetChatsResponse {
64
+ chats: Chat[];
65
+ }
66
+
67
+ export const CHAT_V1_PACKAGE_NAME = "chat.v1";
68
+
69
+ export interface ChatServiceClient {
70
+ createChat(request: CreateChatRequest): Observable<CreateChatResponse>;
71
+
72
+ deleteChat(request: DeleteChatRequest): Observable<DeleteChatResponse>;
73
+
74
+ getMessages(request: GetMessagesRequest): Observable<GetMessagesResponse>;
75
+
76
+ getChats(request: GetChatsRequest): Observable<GetChatsResponse>;
77
+ }
78
+
79
+ export interface ChatServiceController {
80
+ createChat(
81
+ request: CreateChatRequest,
82
+ ): Promise<CreateChatResponse> | Observable<CreateChatResponse> | CreateChatResponse;
83
+
84
+ deleteChat(
85
+ request: DeleteChatRequest,
86
+ ): Promise<DeleteChatResponse> | Observable<DeleteChatResponse> | DeleteChatResponse;
87
+
88
+ getMessages(
89
+ request: GetMessagesRequest,
90
+ ): Promise<GetMessagesResponse> | Observable<GetMessagesResponse> | GetMessagesResponse;
91
+
92
+ getChats(request: GetChatsRequest): Promise<GetChatsResponse> | Observable<GetChatsResponse> | GetChatsResponse;
93
+ }
94
+
95
+ export function ChatServiceControllerMethods() {
96
+ return function (constructor: Function) {
97
+ const grpcMethods: string[] = ["createChat", "deleteChat", "getMessages", "getChats"];
98
+ for (const method of grpcMethods) {
99
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
100
+ GrpcMethod("ChatService", method)(constructor.prototype[method], method, descriptor);
101
+ }
102
+ const grpcStreamMethods: string[] = [];
103
+ for (const method of grpcStreamMethods) {
104
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
105
+ GrpcStreamMethod("ChatService", method)(constructor.prototype[method], method, descriptor);
106
+ }
107
+ };
108
+ }
109
+
110
+ export const CHAT_SERVICE_NAME = "ChatService";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@readytomog/contracts",
3
- "version": "1.2.3",
3
+ "version": "1.3.1",
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,64 @@
1
+ syntax = "proto3";
2
+
3
+ package chat.v1;
4
+
5
+ service ChatService {
6
+ rpc CreateChat(CreateChatRequest) returns (CreateChatResponse);
7
+ rpc DeleteChat(DeleteChatRequest) returns (DeleteChatResponse);
8
+ rpc GetMessages(GetMessagesRequest) returns (GetMessagesResponse);
9
+ rpc GetChats(GetChatsRequest) returns (GetChatsResponse);
10
+ }
11
+
12
+ message CreateChatRequest {
13
+ int32 participant = 1;
14
+
15
+ }
16
+ message CreateChatResponse {
17
+ int32 id = 1;
18
+ int32 participant1 = 2;
19
+ int32 participant2 = 3;
20
+ }
21
+
22
+ message DeleteChatRequest {
23
+ int32 chatId = 1;
24
+ }
25
+
26
+ message DeleteChatResponse {
27
+ string message = 1;
28
+ }
29
+
30
+ message Mesage {
31
+ string message = 1;
32
+ int32 senderId = 2;
33
+ int32 recieverId = 3;
34
+ int32 id = 4;
35
+ }
36
+
37
+ message User {
38
+ int32 id = 1;
39
+ string name = 2;
40
+ string surname =3;
41
+ string avatar =4;
42
+ }
43
+
44
+ message Chat {
45
+ int32 id = 1;
46
+ repeated User users = 2;
47
+ string lastMessage = 3;
48
+ }
49
+
50
+ message GetMessagesRequest {
51
+ int32 chatId = 1;
52
+ }
53
+
54
+ message GetMessagesResponse {
55
+ repeated Mesage mesages = 1;
56
+ }
57
+
58
+ message GetChatsRequest {
59
+ int32 userId = 1;
60
+ }
61
+
62
+ message GetChatsResponse {
63
+ repeated Chat chats = 1;
64
+ }