@xtsea/tgcore-ts 0.1.14 → 0.1.15

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/index.cjs CHANGED
@@ -31,17 +31,17 @@ var Http = class {
31
31
  constructor(opts) {
32
32
  this.opts = opts;
33
33
  }
34
- async post(ctx) {
34
+ async post(path, body) {
35
35
  const controller = new AbortController();
36
36
  const timeout = setTimeout(() => controller.abort(), this.opts.timeout_ms);
37
37
  try {
38
- const res = await fetch(this.opts.base_url + ctx.path, {
38
+ const res = await fetch(this.opts.base_url + path, {
39
39
  method: "POST",
40
40
  headers: {
41
41
  "content-type": "application/json",
42
42
  "x-api-key": this.opts.api_key
43
43
  },
44
- body: JSON.stringify(ctx.body ?? {}),
44
+ body: JSON.stringify(body ?? {}),
45
45
  signal: controller.signal
46
46
  });
47
47
  const json = await res.json().catch(() => null);
@@ -57,20 +57,14 @@ var Http = class {
57
57
 
58
58
  // src/raw/methods.ts
59
59
  var RawMethods = class {
60
- constructor(http) {
61
- this.http = http;
60
+ constructor(client) {
61
+ this.client = client;
62
62
  }
63
63
  sendMessage(params) {
64
- return this.http.post({
65
- path: "/api/v2/sendMessage",
66
- body: params
67
- });
64
+ return this.client.request("/api/v2/sendMessage", params);
68
65
  }
69
66
  getMe() {
70
- return this.http.post({
71
- path: "/api/v2/getMe",
72
- body: {}
73
- });
67
+ return this.client.request("/api/v2/getMe", {});
74
68
  }
75
69
  };
76
70
 
@@ -187,15 +181,15 @@ var Client = class {
187
181
  base_url: opts.base_url ?? "https://services-pro.ryzenths.dpdns.org",
188
182
  timeout_ms: opts.timeout_ms ?? 3e4
189
183
  });
190
- this.calls = new CallMethods(this.http);
191
- this.raw = new RawMethods(this.http);
184
+ this.calls = new CallMethods(this);
185
+ this.raw = new RawMethods(this);
192
186
  }
193
187
  use(mw) {
194
188
  this.middlewares.push(mw);
195
189
  return this;
196
190
  }
197
191
  async request(path, body) {
198
- return this.http.post({ path, body });
192
+ return this.http.post(path, body);
199
193
  }
200
194
  };
201
195
 
package/dist/index.d.cts CHANGED
@@ -1,28 +1,13 @@
1
- type HttpOptions = {
2
- api_key: string;
3
- base_url: string;
4
- timeout_ms: number;
5
- };
6
- type HttpContext = {
7
- path: string;
8
- body?: any;
9
- };
10
- declare class Http {
11
- private opts;
12
- constructor(opts: HttpOptions);
13
- post(ctx: HttpContext): Promise<any>;
14
- }
15
-
16
1
  declare class RawMethods {
17
- private http;
18
- constructor(http: Http);
2
+ private client;
3
+ constructor(client: any);
19
4
  sendMessage(params: {
20
5
  chat_id: string | number;
21
6
  text: string;
22
7
  parse_mode?: string;
23
8
  reply_markup?: any;
24
- }): Promise<any>;
25
- getMe(): Promise<any>;
9
+ }): any;
10
+ getMe(): any;
26
11
  }
27
12
 
28
13
  declare abstract class BaseCallBuilder<T = any> {
@@ -83,8 +68,8 @@ declare class Client {
83
68
  raw: RawMethods;
84
69
  calls: CallMethods;
85
70
  use(mw: Middleware): this;
86
- request(path: string, body?: any): Promise<any>;
87
71
  constructor(opts: ClientOptions);
72
+ request(path: string, body?: any): Promise<any>;
88
73
  }
89
74
 
90
75
  type InlineKeyboardButton = {
package/dist/index.d.ts CHANGED
@@ -1,28 +1,13 @@
1
- type HttpOptions = {
2
- api_key: string;
3
- base_url: string;
4
- timeout_ms: number;
5
- };
6
- type HttpContext = {
7
- path: string;
8
- body?: any;
9
- };
10
- declare class Http {
11
- private opts;
12
- constructor(opts: HttpOptions);
13
- post(ctx: HttpContext): Promise<any>;
14
- }
15
-
16
1
  declare class RawMethods {
17
- private http;
18
- constructor(http: Http);
2
+ private client;
3
+ constructor(client: any);
19
4
  sendMessage(params: {
20
5
  chat_id: string | number;
21
6
  text: string;
22
7
  parse_mode?: string;
23
8
  reply_markup?: any;
24
- }): Promise<any>;
25
- getMe(): Promise<any>;
9
+ }): any;
10
+ getMe(): any;
26
11
  }
27
12
 
28
13
  declare abstract class BaseCallBuilder<T = any> {
@@ -83,8 +68,8 @@ declare class Client {
83
68
  raw: RawMethods;
84
69
  calls: CallMethods;
85
70
  use(mw: Middleware): this;
86
- request(path: string, body?: any): Promise<any>;
87
71
  constructor(opts: ClientOptions);
72
+ request(path: string, body?: any): Promise<any>;
88
73
  }
89
74
 
90
75
  type InlineKeyboardButton = {
package/dist/index.js CHANGED
@@ -3,17 +3,17 @@ var Http = class {
3
3
  constructor(opts) {
4
4
  this.opts = opts;
5
5
  }
6
- async post(ctx) {
6
+ async post(path, body) {
7
7
  const controller = new AbortController();
8
8
  const timeout = setTimeout(() => controller.abort(), this.opts.timeout_ms);
9
9
  try {
10
- const res = await fetch(this.opts.base_url + ctx.path, {
10
+ const res = await fetch(this.opts.base_url + path, {
11
11
  method: "POST",
12
12
  headers: {
13
13
  "content-type": "application/json",
14
14
  "x-api-key": this.opts.api_key
15
15
  },
16
- body: JSON.stringify(ctx.body ?? {}),
16
+ body: JSON.stringify(body ?? {}),
17
17
  signal: controller.signal
18
18
  });
19
19
  const json = await res.json().catch(() => null);
@@ -29,20 +29,14 @@ var Http = class {
29
29
 
30
30
  // src/raw/methods.ts
31
31
  var RawMethods = class {
32
- constructor(http) {
33
- this.http = http;
32
+ constructor(client) {
33
+ this.client = client;
34
34
  }
35
35
  sendMessage(params) {
36
- return this.http.post({
37
- path: "/api/v2/sendMessage",
38
- body: params
39
- });
36
+ return this.client.request("/api/v2/sendMessage", params);
40
37
  }
41
38
  getMe() {
42
- return this.http.post({
43
- path: "/api/v2/getMe",
44
- body: {}
45
- });
39
+ return this.client.request("/api/v2/getMe", {});
46
40
  }
47
41
  };
48
42
 
@@ -159,15 +153,15 @@ var Client = class {
159
153
  base_url: opts.base_url ?? "https://services-pro.ryzenths.dpdns.org",
160
154
  timeout_ms: opts.timeout_ms ?? 3e4
161
155
  });
162
- this.calls = new CallMethods(this.http);
163
- this.raw = new RawMethods(this.http);
156
+ this.calls = new CallMethods(this);
157
+ this.raw = new RawMethods(this);
164
158
  }
165
159
  use(mw) {
166
160
  this.middlewares.push(mw);
167
161
  return this;
168
162
  }
169
163
  async request(path, body) {
170
- return this.http.post({ path, body });
164
+ return this.http.post(path, body);
171
165
  }
172
166
  };
173
167
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xtsea/tgcore-ts",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "tgcore TypeScript SDK • Telegram Engine Client",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",