grammy 1.41.0 → 1.41.1
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/out/convenience/inline_query.d.ts +2 -1
- package/out/convenience/inline_query.js +5 -7
- package/out/core/client.js +7 -4
- package/out/core/error.d.ts +1 -1
- package/out/core/error.js +9 -13
- package/out/web.mjs +13 -14
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ type OptionalKeys<T> = {
|
|
|
4
4
|
[K in keyof T]-?: undefined extends T[K] ? K : never;
|
|
5
5
|
};
|
|
6
6
|
type OptionalFields<T> = Pick<T, OptionalKeys<T>[keyof T]>;
|
|
7
|
+
type PartialKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
7
8
|
/**
|
|
8
9
|
* Holds a number of helper methods for building `InlineQueryResult*` objects.
|
|
9
10
|
*
|
|
@@ -256,7 +257,7 @@ export declare const InlineQueryResultBuilder: {
|
|
|
256
257
|
* @param photo_url A valid URL of the photo. Photo must be in JPEG format. Photo size must not exceed 5MB
|
|
257
258
|
* @param options Remaining options
|
|
258
259
|
*/
|
|
259
|
-
photo(id: string, photo_url: string | URL, options?: InlineQueryResultOptions<InlineQueryResultPhoto, "photo_url">): InlineQueryResultPhoto & {
|
|
260
|
+
photo(id: string, photo_url: string | URL, options?: InlineQueryResultOptions<PartialKeys<InlineQueryResultPhoto, "thumbnail_url">, "photo_url">): InlineQueryResultPhoto & {
|
|
260
261
|
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultPhoto;
|
|
261
262
|
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultPhoto;
|
|
262
263
|
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultPhoto;
|
|
@@ -301,17 +301,15 @@ exports.InlineQueryResultBuilder = {
|
|
|
301
301
|
* @param photo_url A valid URL of the photo. Photo must be in JPEG format. Photo size must not exceed 5MB
|
|
302
302
|
* @param options Remaining options
|
|
303
303
|
*/
|
|
304
|
-
photo(id, photo_url, options = {
|
|
305
|
-
|
|
304
|
+
photo(id, photo_url, options = {}) {
|
|
305
|
+
const photoUrl = typeof photo_url === "string"
|
|
306
306
|
? photo_url
|
|
307
|
-
: photo_url.href
|
|
308
|
-
}) {
|
|
307
|
+
: photo_url.href;
|
|
309
308
|
return inputMessage({
|
|
310
309
|
type: "photo",
|
|
311
310
|
id,
|
|
312
|
-
photo_url:
|
|
313
|
-
|
|
314
|
-
: photo_url.href,
|
|
311
|
+
photo_url: photoUrl,
|
|
312
|
+
thumbnail_url: photoUrl,
|
|
315
313
|
...options,
|
|
316
314
|
});
|
|
317
315
|
},
|
package/out/core/client.js
CHANGED
|
@@ -45,14 +45,17 @@ class ApiClient {
|
|
|
45
45
|
: (0, payload_js_1.createJsonPayload)(payload);
|
|
46
46
|
const sig = controller.signal;
|
|
47
47
|
const options = { ...opts.baseFetchConfig, signal: sig, ...config };
|
|
48
|
-
// Perform fetch call
|
|
49
|
-
const successPromise = this.fetch(url
|
|
48
|
+
// Perform fetch call
|
|
49
|
+
const successPromise = this.fetch(url, options)
|
|
50
|
+
.then((res) => res.json());
|
|
50
51
|
// Those are the three possible outcomes of the fetch call:
|
|
51
52
|
const operations = [successPromise, streamErr.promise, timeout.promise];
|
|
52
53
|
// Wait for result
|
|
53
54
|
try {
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
return await Promise.race(operations);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
throw (0, error_js_1.toHttpError)(method, opts.sensitiveLogs, error);
|
|
56
59
|
}
|
|
57
60
|
finally {
|
|
58
61
|
if (timeout.handle !== undefined)
|
package/out/core/error.d.ts
CHANGED
|
@@ -50,4 +50,4 @@ export declare class HttpError extends Error {
|
|
|
50
50
|
/** The thrown error object. */
|
|
51
51
|
error: unknown);
|
|
52
52
|
}
|
|
53
|
-
export declare function toHttpError(method: string, sensitiveLogs: boolean
|
|
53
|
+
export declare function toHttpError(method: string, sensitiveLogs: boolean, err: unknown): HttpError;
|
package/out/core/error.js
CHANGED
|
@@ -70,18 +70,14 @@ class HttpError extends Error {
|
|
|
70
70
|
}
|
|
71
71
|
exports.HttpError = HttpError;
|
|
72
72
|
function isTelegramError(err) {
|
|
73
|
-
return (typeof err === "object" &&
|
|
74
|
-
err
|
|
75
|
-
"status" in err &&
|
|
76
|
-
"statusText" in err);
|
|
73
|
+
return (typeof err === "object" && err !== null &&
|
|
74
|
+
"status" in err && "statusText" in err);
|
|
77
75
|
}
|
|
78
|
-
function toHttpError(method, sensitiveLogs) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
throw new HttpError(msg, err);
|
|
86
|
-
};
|
|
76
|
+
function toHttpError(method, sensitiveLogs, err) {
|
|
77
|
+
let msg = `Network request for '${method}' failed!`;
|
|
78
|
+
if (isTelegramError(err))
|
|
79
|
+
msg += ` (${err.status}: ${err.statusText})`;
|
|
80
|
+
if (sensitiveLogs && err instanceof Error)
|
|
81
|
+
msg += ` ${err.message}`;
|
|
82
|
+
return new HttpError(msg, err);
|
|
87
83
|
}
|
package/out/web.mjs
CHANGED
|
@@ -2306,13 +2306,11 @@ class HttpError extends Error {
|
|
|
2306
2306
|
function isTelegramError(err) {
|
|
2307
2307
|
return typeof err === "object" && err !== null && "status" in err && "statusText" in err;
|
|
2308
2308
|
}
|
|
2309
|
-
function toHttpError(method, sensitiveLogs) {
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
throw new HttpError(msg, err);
|
|
2315
|
-
};
|
|
2309
|
+
function toHttpError(method, sensitiveLogs, err) {
|
|
2310
|
+
let msg = `Network request for '${method}' failed!`;
|
|
2311
|
+
if (isTelegramError(err)) msg += ` (${err.status}: ${err.statusText})`;
|
|
2312
|
+
if (sensitiveLogs && err instanceof Error) msg += ` ${err.message}`;
|
|
2313
|
+
return new HttpError(msg, err);
|
|
2316
2314
|
}
|
|
2317
2315
|
function checkWindows() {
|
|
2318
2316
|
const global = globalThis;
|
|
@@ -2631,15 +2629,16 @@ class ApiClient {
|
|
|
2631
2629
|
signal: sig,
|
|
2632
2630
|
...config
|
|
2633
2631
|
};
|
|
2634
|
-
const successPromise = this.fetch(url
|
|
2632
|
+
const successPromise = this.fetch(url, options).then((res)=>res.json());
|
|
2635
2633
|
const operations = [
|
|
2636
2634
|
successPromise,
|
|
2637
2635
|
streamErr.promise,
|
|
2638
2636
|
timeout.promise
|
|
2639
2637
|
];
|
|
2640
2638
|
try {
|
|
2641
|
-
|
|
2642
|
-
|
|
2639
|
+
return await Promise.race(operations);
|
|
2640
|
+
} catch (error) {
|
|
2641
|
+
throw toHttpError(method, opts.sensitiveLogs, error);
|
|
2643
2642
|
} finally{
|
|
2644
2643
|
if (timeout.handle !== undefined) clearTimeout(timeout.handle);
|
|
2645
2644
|
}
|
|
@@ -4467,13 +4466,13 @@ const InlineQueryResultBuilder = {
|
|
|
4467
4466
|
...options
|
|
4468
4467
|
});
|
|
4469
4468
|
},
|
|
4470
|
-
photo (id, photo_url, options = {
|
|
4471
|
-
|
|
4472
|
-
}) {
|
|
4469
|
+
photo (id, photo_url, options = {}) {
|
|
4470
|
+
const photoUrl = typeof photo_url === "string" ? photo_url : photo_url.href;
|
|
4473
4471
|
return inputMessage({
|
|
4474
4472
|
type: "photo",
|
|
4475
4473
|
id,
|
|
4476
|
-
photo_url:
|
|
4474
|
+
photo_url: photoUrl,
|
|
4475
|
+
thumbnail_url: photoUrl,
|
|
4477
4476
|
...options
|
|
4478
4477
|
});
|
|
4479
4478
|
},
|