@xtsea/tgcore-ts 0.1.1 → 0.1.3

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/README.md CHANGED
@@ -1,4 +1,38 @@
1
- # Getting started
1
+ <h1 align="center">TGCore TS SDK</h1>
2
+ <p align="center">
3
+ Enterprise Telegram Bot Framework • Secure • Scalable • Zero-Trust Ready
4
+ </p>
5
+
6
+ <p align="center">
7
+ <img src="https://img.shields.io/badge/Framework-TGCore-black?style=for-the-badge">
8
+ <img src="https://img.shields.io/badge/API-Services%20Pro-purple?style=for-the-badge">
9
+ <img src="https://img.shields.io/badge/Security-AES--256%20GCM-green?style=for-the-badge">
10
+ </p>
11
+
12
+ ![Maintained](https://img.shields.io/badge/maintained-yes-success?style=flat-square)
13
+ ![PRs](https://img.shields.io/badge/PRs-welcome-brightgreen?style=flat-square)
14
+ ![Security](https://img.shields.io/badge/security-audited-blue?style=flat-square)
15
+ ![Architecture](https://img.shields.io/badge/architecture-clean-lightgrey?style=flat-square)
16
+ ![FastAPI](https://img.shields.io/badge/backend-FastAPI-05998b?style=flat-square)
17
+ ![MongoDB](https://img.shields.io/badge/database-MongoDB-4ea94b?style=flat-square)
18
+ ![Async](https://img.shields.io/badge/async-native-orange?style=flat-square)
19
+ ![Webhook](https://img.shields.io/badge/webhook-supported-blueviolet?style=flat-square)
20
+ ![tgcore](https://img.shields.io/badge/TGCore-SDK-black)
21
+
22
+ [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
23
+
24
+ ![npm](https://img.shields.io/npm/v/@xtsea/tgcore-ts)
25
+ ![downloads](https://img.shields.io/npm/dm/@xtsea/tgcore-ts)
26
+ ![license](https://img.shields.io/npm/l/@xtsea/tgcore-ts)
27
+
28
+ ## Install
29
+
30
+ ```bash
31
+ npm install @xtsea/tgcore-ts
32
+ ```
33
+
34
+ ## Getting started
35
+
2
36
  ```ts
3
37
  import { Client } from "@xtsea/tgcore-ts"
4
38
 
package/dist/index.d.mts CHANGED
@@ -21,6 +21,33 @@ declare class RawMethods {
21
21
  getMe(): Promise<any>;
22
22
  }
23
23
 
24
+ declare abstract class BaseCallBuilder<T = any> {
25
+ protected http: any;
26
+ protected path: string;
27
+ protected params: Record<string, any>;
28
+ constructor(http: any, path: string);
29
+ protected set(key: string, value: any): this;
30
+ execute(): Promise<T>;
31
+ throw(): Promise<T>;
32
+ build(): Record<string, any>;
33
+ }
34
+
35
+ declare class SendMessageBuilder extends BaseCallBuilder {
36
+ chatId(id: string | number): this;
37
+ text(text: string): this;
38
+ parseMode(mode: "HTML" | "Markdown" | "MarkdownV2"): this;
39
+ disableNotification(value: boolean): this;
40
+ protectContent(value: boolean): this;
41
+ replyMarkup(markup: any): this;
42
+ linkPreviewOptions(options: any): this;
43
+ }
44
+
45
+ declare class CallMethods {
46
+ private http;
47
+ constructor(http: any);
48
+ sendMessage(): SendMessageBuilder;
49
+ }
50
+
24
51
  type ClientOptions = {
25
52
  api_key: string;
26
53
  base_url?: string;
@@ -29,6 +56,7 @@ type ClientOptions = {
29
56
  declare class Client {
30
57
  private http;
31
58
  raw: RawMethods;
59
+ calls: CallMethods;
32
60
  constructor(opts: ClientOptions);
33
61
  }
34
62
 
package/dist/index.d.ts CHANGED
@@ -21,6 +21,33 @@ declare class RawMethods {
21
21
  getMe(): Promise<any>;
22
22
  }
23
23
 
24
+ declare abstract class BaseCallBuilder<T = any> {
25
+ protected http: any;
26
+ protected path: string;
27
+ protected params: Record<string, any>;
28
+ constructor(http: any, path: string);
29
+ protected set(key: string, value: any): this;
30
+ execute(): Promise<T>;
31
+ throw(): Promise<T>;
32
+ build(): Record<string, any>;
33
+ }
34
+
35
+ declare class SendMessageBuilder extends BaseCallBuilder {
36
+ chatId(id: string | number): this;
37
+ text(text: string): this;
38
+ parseMode(mode: "HTML" | "Markdown" | "MarkdownV2"): this;
39
+ disableNotification(value: boolean): this;
40
+ protectContent(value: boolean): this;
41
+ replyMarkup(markup: any): this;
42
+ linkPreviewOptions(options: any): this;
43
+ }
44
+
45
+ declare class CallMethods {
46
+ private http;
47
+ constructor(http: any);
48
+ sendMessage(): SendMessageBuilder;
49
+ }
50
+
24
51
  type ClientOptions = {
25
52
  api_key: string;
26
53
  base_url?: string;
@@ -29,6 +56,7 @@ type ClientOptions = {
29
56
  declare class Client {
30
57
  private http;
31
58
  raw: RawMethods;
59
+ calls: CallMethods;
32
60
  constructor(opts: ClientOptions);
33
61
  }
34
62
 
package/dist/index.js CHANGED
@@ -66,6 +66,72 @@ var RawMethods = class {
66
66
  }
67
67
  };
68
68
 
69
+ // src/calls/base.ts
70
+ var BaseCallBuilder = class {
71
+ constructor(http, path) {
72
+ this.http = http;
73
+ this.path = path;
74
+ this.params = {};
75
+ }
76
+ set(key, value) {
77
+ if (value !== void 0) {
78
+ this.params[key] = value;
79
+ }
80
+ return this;
81
+ }
82
+ async execute() {
83
+ return this.http.post(this.path, this.params);
84
+ }
85
+ async throw() {
86
+ const res = await this.execute();
87
+ if (!res?.ok) {
88
+ throw new Error(JSON.stringify(res));
89
+ }
90
+ return res;
91
+ }
92
+ build() {
93
+ return this.params;
94
+ }
95
+ };
96
+
97
+ // src/calls/sendMessage.ts
98
+ var SendMessageBuilder = class extends BaseCallBuilder {
99
+ chatId(id) {
100
+ return this.set("chat_id", id);
101
+ }
102
+ text(text) {
103
+ return this.set("text", text);
104
+ }
105
+ parseMode(mode) {
106
+ return this.set("parse_mode", mode);
107
+ }
108
+ disableNotification(value) {
109
+ return this.set("disable_notification", value);
110
+ }
111
+ protectContent(value) {
112
+ return this.set("protect_content", value);
113
+ }
114
+ replyMarkup(markup) {
115
+ return this.set("reply_markup", markup);
116
+ }
117
+ linkPreviewOptions(options) {
118
+ return this.set("link_preview_options", options);
119
+ }
120
+ };
121
+
122
+ // src/calls/index.ts
123
+ var CallMethods = class {
124
+ constructor(http) {
125
+ this.http = http;
126
+ }
127
+ sendMessage() {
128
+ return new SendMessageBuilder(
129
+ this.http,
130
+ "/api/v2/sendMessage"
131
+ );
132
+ }
133
+ };
134
+
69
135
  // src/client.ts
70
136
  var Client = class {
71
137
  constructor(opts) {
@@ -77,6 +143,7 @@ var Client = class {
77
143
  base_url: opts.base_url ?? "https://services-pro.ryzenths.dpdns.org",
78
144
  timeout_ms: opts.timeout_ms ?? 3e4
79
145
  });
146
+ this.calls = new CallMethods(this.http);
80
147
  this.raw = new RawMethods(this.http);
81
148
  }
82
149
  };
package/dist/index.mjs CHANGED
@@ -40,6 +40,72 @@ var RawMethods = class {
40
40
  }
41
41
  };
42
42
 
43
+ // src/calls/base.ts
44
+ var BaseCallBuilder = class {
45
+ constructor(http, path) {
46
+ this.http = http;
47
+ this.path = path;
48
+ this.params = {};
49
+ }
50
+ set(key, value) {
51
+ if (value !== void 0) {
52
+ this.params[key] = value;
53
+ }
54
+ return this;
55
+ }
56
+ async execute() {
57
+ return this.http.post(this.path, this.params);
58
+ }
59
+ async throw() {
60
+ const res = await this.execute();
61
+ if (!res?.ok) {
62
+ throw new Error(JSON.stringify(res));
63
+ }
64
+ return res;
65
+ }
66
+ build() {
67
+ return this.params;
68
+ }
69
+ };
70
+
71
+ // src/calls/sendMessage.ts
72
+ var SendMessageBuilder = class extends BaseCallBuilder {
73
+ chatId(id) {
74
+ return this.set("chat_id", id);
75
+ }
76
+ text(text) {
77
+ return this.set("text", text);
78
+ }
79
+ parseMode(mode) {
80
+ return this.set("parse_mode", mode);
81
+ }
82
+ disableNotification(value) {
83
+ return this.set("disable_notification", value);
84
+ }
85
+ protectContent(value) {
86
+ return this.set("protect_content", value);
87
+ }
88
+ replyMarkup(markup) {
89
+ return this.set("reply_markup", markup);
90
+ }
91
+ linkPreviewOptions(options) {
92
+ return this.set("link_preview_options", options);
93
+ }
94
+ };
95
+
96
+ // src/calls/index.ts
97
+ var CallMethods = class {
98
+ constructor(http) {
99
+ this.http = http;
100
+ }
101
+ sendMessage() {
102
+ return new SendMessageBuilder(
103
+ this.http,
104
+ "/api/v2/sendMessage"
105
+ );
106
+ }
107
+ };
108
+
43
109
  // src/client.ts
44
110
  var Client = class {
45
111
  constructor(opts) {
@@ -51,6 +117,7 @@ var Client = class {
51
117
  base_url: opts.base_url ?? "https://services-pro.ryzenths.dpdns.org",
52
118
  timeout_ms: opts.timeout_ms ?? 3e4
53
119
  });
120
+ this.calls = new CallMethods(this.http);
54
121
  this.raw = new RawMethods(this.http);
55
122
  }
56
123
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xtsea/tgcore-ts",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "tgcore TypeScript SDK • Telegram Engine Client",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",