@znaika/contracts 1.0.0

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 "./proto";
package/dist/index.js ADDED
@@ -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("./proto"), exports);
@@ -0,0 +1 @@
1
+ export * from "./paths";
@@ -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("./paths"), exports);
@@ -0,0 +1,3 @@
1
+ export declare const PROTO_PATHS: {
2
+ readonly TELEGRAM: string;
3
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PROTO_PATHS = void 0;
4
+ const path_1 = require("path");
5
+ exports.PROTO_PATHS = {
6
+ TELEGRAM: (0, path_1.join)(__dirname, "../../proto/telegram.proto"),
7
+ };
@@ -0,0 +1,63 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.9
4
+ // protoc v3.21.12
5
+ // source: telegram.proto
6
+
7
+ /* eslint-disable */
8
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { Observable } from "rxjs";
10
+
11
+ export const protobufPackage = "telegram.v1";
12
+
13
+ export enum ParseMode {
14
+ PARSE_MODE_UNSPECIFIED = 0,
15
+ PARSE_MODE_MARKDOWN_V2 = 1,
16
+ PARSE_MODE_HTML = 2,
17
+ UNRECOGNIZED = -1,
18
+ }
19
+
20
+ export interface SendMessageRequest {
21
+ chatId: number;
22
+ text: string;
23
+ parseMode: ParseMode;
24
+ disableNotification: boolean;
25
+ disableWebPagePreview: boolean;
26
+ replyToMessageId: number;
27
+ }
28
+
29
+ export interface SendMessageResponse {
30
+ success: boolean;
31
+ messageId: number;
32
+ statusCode: number;
33
+ error: string;
34
+ }
35
+
36
+ export const TELEGRAM_V1_PACKAGE_NAME = "telegram.v1";
37
+
38
+ export interface TelegramServiceClient {
39
+ sendMessage(request: SendMessageRequest): Observable<SendMessageResponse>;
40
+ }
41
+
42
+ export interface TelegramServiceController {
43
+ sendMessage(
44
+ request: SendMessageRequest,
45
+ ): Promise<SendMessageResponse> | Observable<SendMessageResponse> | SendMessageResponse;
46
+ }
47
+
48
+ export function TelegramServiceControllerMethods() {
49
+ return function (constructor: Function) {
50
+ const grpcMethods: string[] = ["sendMessage"];
51
+ for (const method of grpcMethods) {
52
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
53
+ GrpcMethod("TelegramService", method)(constructor.prototype[method], method, descriptor);
54
+ }
55
+ const grpcStreamMethods: string[] = [];
56
+ for (const method of grpcStreamMethods) {
57
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
58
+ GrpcStreamMethod("TelegramService", method)(constructor.prototype[method], method, descriptor);
59
+ }
60
+ };
61
+ }
62
+
63
+ export const TELEGRAM_SERVICE_NAME = "TelegramService";
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@znaika/contracts",
3
+ "version": "1.0.0",
4
+ "description": "Protobuf definitions for microservices and TypeScript types",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "scripts": {
8
+ "generate": "mkdir -p gen && protoc -I ./proto ./proto/*.proto --ts_proto_out=./gen --ts_proto_opt=nestJs=true,package=omit",
9
+ "build": "tsc -p tsconfig.build.json"
10
+ },
11
+ "files": [
12
+ "proto",
13
+ "gen",
14
+ "dist"
15
+ ],
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "dependencies": {
20
+ "@nestjs/microservices": "^11.1.27",
21
+ "rxjs": "^7.8.2"
22
+ },
23
+ "devDependencies": {
24
+ "@types/node": "^26.1.1",
25
+ "ts-proto": "^2.11.9",
26
+ "typescript": "^6.0.3"
27
+ }
28
+ }
@@ -0,0 +1,29 @@
1
+ syntax = "proto3";
2
+
3
+ package telegram.v1;
4
+
5
+ service TelegramService {
6
+ rpc SendMessage (SendMessageRequest) returns (SendMessageResponse);
7
+ }
8
+
9
+ enum ParseMode {
10
+ PARSE_MODE_UNSPECIFIED = 0;
11
+ PARSE_MODE_MARKDOWN_V2 = 1;
12
+ PARSE_MODE_HTML = 2;
13
+ }
14
+
15
+ message SendMessageRequest {
16
+ int64 chat_id = 1;
17
+ string text = 2;
18
+ ParseMode parse_mode = 3;
19
+ bool disable_notification = 4;
20
+ bool disable_web_page_preview = 5;
21
+ int64 reply_to_message_id = 6;
22
+ }
23
+
24
+ message SendMessageResponse {
25
+ bool success = 1;
26
+ int64 message_id = 2;
27
+ int32 status_code = 3;
28
+ string error = 4;
29
+ }