@xtsea/tgcore-ts 0.1.14 → 0.1.16

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
 
@@ -172,6 +166,29 @@ var CallMethods = class {
172
166
  }
173
167
  };
174
168
 
169
+ // src/orweb/pinterest.ts
170
+ var PinterestBuilder = class extends BaseCallBuilder {
171
+ query(text) {
172
+ return this.set("query", text);
173
+ }
174
+ limit(limit = 10) {
175
+ return this.set("limit", limit);
176
+ }
177
+ };
178
+
179
+ // src/orweb/index.ts
180
+ var OrWebMethods = class {
181
+ constructor(client) {
182
+ this.client = client;
183
+ }
184
+ pinterest() {
185
+ return new PinterestBuilder(
186
+ this.client,
187
+ "/api/web/pinterest"
188
+ );
189
+ }
190
+ };
191
+
175
192
  // src/client.ts
176
193
  function tgcore(options) {
177
194
  return new Client(options);
@@ -184,18 +201,19 @@ var Client = class {
184
201
  }
185
202
  this.http = new Http({
186
203
  api_key: opts.api_key,
187
- base_url: opts.base_url ?? "https://services-pro.ryzenths.dpdns.org",
204
+ base_url: opts.base_url ?? "https://tgcore.ryzenths.dpdns.org",
188
205
  timeout_ms: opts.timeout_ms ?? 3e4
189
206
  });
190
- this.calls = new CallMethods(this.http);
191
- this.raw = new RawMethods(this.http);
207
+ this.calls = new CallMethods(this);
208
+ this.raw = new RawMethods(this);
209
+ this.orweb = new OrWebMethods(this);
192
210
  }
193
211
  use(mw) {
194
212
  this.middlewares.push(mw);
195
213
  return this;
196
214
  }
197
215
  async request(path, body) {
198
- return this.http.post({ path, body });
216
+ return this.http.post(path, body);
199
217
  }
200
218
  };
201
219
 
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> {
@@ -64,6 +49,17 @@ declare class CallMethods {
64
49
  sendPhoto(): SendPhotoBuilder;
65
50
  }
66
51
 
52
+ declare class PinterestBuilder extends BaseCallBuilder {
53
+ query(text: string): this;
54
+ limit(limit?: number): this;
55
+ }
56
+
57
+ declare class OrWebMethods {
58
+ private client;
59
+ constructor(client: any);
60
+ pinterest(): PinterestBuilder;
61
+ }
62
+
67
63
  type ClientOptions = {
68
64
  api_key: string;
69
65
  base_url?: string;
@@ -82,9 +78,10 @@ declare class Client {
82
78
  private middlewares;
83
79
  raw: RawMethods;
84
80
  calls: CallMethods;
81
+ orweb: OrWebMethods;
85
82
  use(mw: Middleware): this;
86
- request(path: string, body?: any): Promise<any>;
87
83
  constructor(opts: ClientOptions);
84
+ request(path: string, body?: any): Promise<any>;
88
85
  }
89
86
 
90
87
  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> {
@@ -64,6 +49,17 @@ declare class CallMethods {
64
49
  sendPhoto(): SendPhotoBuilder;
65
50
  }
66
51
 
52
+ declare class PinterestBuilder extends BaseCallBuilder {
53
+ query(text: string): this;
54
+ limit(limit?: number): this;
55
+ }
56
+
57
+ declare class OrWebMethods {
58
+ private client;
59
+ constructor(client: any);
60
+ pinterest(): PinterestBuilder;
61
+ }
62
+
67
63
  type ClientOptions = {
68
64
  api_key: string;
69
65
  base_url?: string;
@@ -82,9 +78,10 @@ declare class Client {
82
78
  private middlewares;
83
79
  raw: RawMethods;
84
80
  calls: CallMethods;
81
+ orweb: OrWebMethods;
85
82
  use(mw: Middleware): this;
86
- request(path: string, body?: any): Promise<any>;
87
83
  constructor(opts: ClientOptions);
84
+ request(path: string, body?: any): Promise<any>;
88
85
  }
89
86
 
90
87
  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
 
@@ -144,6 +138,29 @@ var CallMethods = class {
144
138
  }
145
139
  };
146
140
 
141
+ // src/orweb/pinterest.ts
142
+ var PinterestBuilder = class extends BaseCallBuilder {
143
+ query(text) {
144
+ return this.set("query", text);
145
+ }
146
+ limit(limit = 10) {
147
+ return this.set("limit", limit);
148
+ }
149
+ };
150
+
151
+ // src/orweb/index.ts
152
+ var OrWebMethods = class {
153
+ constructor(client) {
154
+ this.client = client;
155
+ }
156
+ pinterest() {
157
+ return new PinterestBuilder(
158
+ this.client,
159
+ "/api/web/pinterest"
160
+ );
161
+ }
162
+ };
163
+
147
164
  // src/client.ts
148
165
  function tgcore(options) {
149
166
  return new Client(options);
@@ -156,18 +173,19 @@ var Client = class {
156
173
  }
157
174
  this.http = new Http({
158
175
  api_key: opts.api_key,
159
- base_url: opts.base_url ?? "https://services-pro.ryzenths.dpdns.org",
176
+ base_url: opts.base_url ?? "https://tgcore.ryzenths.dpdns.org",
160
177
  timeout_ms: opts.timeout_ms ?? 3e4
161
178
  });
162
- this.calls = new CallMethods(this.http);
163
- this.raw = new RawMethods(this.http);
179
+ this.calls = new CallMethods(this);
180
+ this.raw = new RawMethods(this);
181
+ this.orweb = new OrWebMethods(this);
164
182
  }
165
183
  use(mw) {
166
184
  this.middlewares.push(mw);
167
185
  return this;
168
186
  }
169
187
  async request(path, body) {
170
- return this.http.post({ path, body });
188
+ return this.http.post(path, body);
171
189
  }
172
190
  };
173
191
 
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.16",
4
4
  "description": "tgcore TypeScript SDK • Telegram Engine Client",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",