@xtsea/tgcore-ts 0.1.7 → 0.1.8
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.js +7 -9
- package/dist/index.mjs +7 -9
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -48,8 +48,7 @@ var KeyboardBuilder = class _KeyboardBuilder {
|
|
|
48
48
|
return this;
|
|
49
49
|
}
|
|
50
50
|
push(btn) {
|
|
51
|
-
|
|
52
|
-
if (!((_a = btn.text) == null ? void 0 : _a.trim())) throw new Error("Button text is required");
|
|
51
|
+
if (!btn.text?.trim()) throw new Error("Button text is required");
|
|
53
52
|
if (btn.text.length > 64) throw new Error("Button text too long (max 64 chars)");
|
|
54
53
|
const actionKeys = [
|
|
55
54
|
"url",
|
|
@@ -87,7 +86,7 @@ var KeyboardBuilder = class _KeyboardBuilder {
|
|
|
87
86
|
return this.push({ text, web_app: { url } });
|
|
88
87
|
}
|
|
89
88
|
loginUrl(text, url, opts) {
|
|
90
|
-
return this.push({ text, login_url: { url, ...opts
|
|
89
|
+
return this.push({ text, login_url: { url, ...opts ?? {} } });
|
|
91
90
|
}
|
|
92
91
|
switchInline(text, query) {
|
|
93
92
|
return this.push({ text, switch_inline_query: query });
|
|
@@ -124,7 +123,7 @@ var Http = class {
|
|
|
124
123
|
"content-type": "application/json",
|
|
125
124
|
"x-api-key": this.opts.api_key
|
|
126
125
|
},
|
|
127
|
-
body: JSON.stringify(body
|
|
126
|
+
body: JSON.stringify(body ?? {}),
|
|
128
127
|
signal: controller.signal
|
|
129
128
|
});
|
|
130
129
|
const json = await res.json().catch(() => null);
|
|
@@ -169,7 +168,7 @@ var BaseCallBuilder = class {
|
|
|
169
168
|
}
|
|
170
169
|
async throw() {
|
|
171
170
|
const res = await this.execute();
|
|
172
|
-
if (!
|
|
171
|
+
if (!res?.ok) {
|
|
173
172
|
throw new Error(JSON.stringify(res));
|
|
174
173
|
}
|
|
175
174
|
return res;
|
|
@@ -220,14 +219,13 @@ var CallMethods = class {
|
|
|
220
219
|
// src/client.ts
|
|
221
220
|
var Client = class {
|
|
222
221
|
constructor(opts) {
|
|
223
|
-
|
|
224
|
-
if (!(opts == null ? void 0 : opts.api_key)) {
|
|
222
|
+
if (!opts?.api_key) {
|
|
225
223
|
throw new Error("tgcore-ts: api_key is required");
|
|
226
224
|
}
|
|
227
225
|
this.http = new Http({
|
|
228
226
|
api_key: opts.api_key,
|
|
229
|
-
base_url:
|
|
230
|
-
timeout_ms:
|
|
227
|
+
base_url: opts.base_url ?? "https://services-pro.ryzenths.dpdns.org",
|
|
228
|
+
timeout_ms: opts.timeout_ms ?? 3e4
|
|
231
229
|
});
|
|
232
230
|
this.calls = new CallMethods(this.http);
|
|
233
231
|
this.raw = new RawMethods(this.http);
|
package/dist/index.mjs
CHANGED
|
@@ -21,8 +21,7 @@ var KeyboardBuilder = class _KeyboardBuilder {
|
|
|
21
21
|
return this;
|
|
22
22
|
}
|
|
23
23
|
push(btn) {
|
|
24
|
-
|
|
25
|
-
if (!((_a = btn.text) == null ? void 0 : _a.trim())) throw new Error("Button text is required");
|
|
24
|
+
if (!btn.text?.trim()) throw new Error("Button text is required");
|
|
26
25
|
if (btn.text.length > 64) throw new Error("Button text too long (max 64 chars)");
|
|
27
26
|
const actionKeys = [
|
|
28
27
|
"url",
|
|
@@ -60,7 +59,7 @@ var KeyboardBuilder = class _KeyboardBuilder {
|
|
|
60
59
|
return this.push({ text, web_app: { url } });
|
|
61
60
|
}
|
|
62
61
|
loginUrl(text, url, opts) {
|
|
63
|
-
return this.push({ text, login_url: { url, ...opts
|
|
62
|
+
return this.push({ text, login_url: { url, ...opts ?? {} } });
|
|
64
63
|
}
|
|
65
64
|
switchInline(text, query) {
|
|
66
65
|
return this.push({ text, switch_inline_query: query });
|
|
@@ -97,7 +96,7 @@ var Http = class {
|
|
|
97
96
|
"content-type": "application/json",
|
|
98
97
|
"x-api-key": this.opts.api_key
|
|
99
98
|
},
|
|
100
|
-
body: JSON.stringify(body
|
|
99
|
+
body: JSON.stringify(body ?? {}),
|
|
101
100
|
signal: controller.signal
|
|
102
101
|
});
|
|
103
102
|
const json = await res.json().catch(() => null);
|
|
@@ -142,7 +141,7 @@ var BaseCallBuilder = class {
|
|
|
142
141
|
}
|
|
143
142
|
async throw() {
|
|
144
143
|
const res = await this.execute();
|
|
145
|
-
if (!
|
|
144
|
+
if (!res?.ok) {
|
|
146
145
|
throw new Error(JSON.stringify(res));
|
|
147
146
|
}
|
|
148
147
|
return res;
|
|
@@ -193,14 +192,13 @@ var CallMethods = class {
|
|
|
193
192
|
// src/client.ts
|
|
194
193
|
var Client = class {
|
|
195
194
|
constructor(opts) {
|
|
196
|
-
|
|
197
|
-
if (!(opts == null ? void 0 : opts.api_key)) {
|
|
195
|
+
if (!opts?.api_key) {
|
|
198
196
|
throw new Error("tgcore-ts: api_key is required");
|
|
199
197
|
}
|
|
200
198
|
this.http = new Http({
|
|
201
199
|
api_key: opts.api_key,
|
|
202
|
-
base_url:
|
|
203
|
-
timeout_ms:
|
|
200
|
+
base_url: opts.base_url ?? "https://services-pro.ryzenths.dpdns.org",
|
|
201
|
+
timeout_ms: opts.timeout_ms ?? 3e4
|
|
204
202
|
});
|
|
205
203
|
this.calls = new CallMethods(this.http);
|
|
206
204
|
this.raw = new RawMethods(this.http);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xtsea/tgcore-ts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "tgcore TypeScript SDK • Telegram Engine Client",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"scripts": {
|
|
25
|
-
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
25
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --target es2020 --clean",
|
|
26
26
|
"dev": "tsup src/index.ts --watch",
|
|
27
27
|
"clean": "rm -rf dist"
|
|
28
28
|
},
|