grammy 1.6.2 → 1.7.2
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 +5 -3
- package/out/bot.d.ts +37 -9
- package/out/bot.js +133 -147
- package/out/composer.d.ts +2 -2
- package/out/composer.js +2 -18
- package/out/context.d.ts +5 -5
- package/out/context.js +5 -30
- package/out/convenience/frameworks.node.d.ts +6 -5
- package/out/convenience/keyboard.d.ts +1 -1
- package/out/convenience/keyboard.js +2 -12
- package/out/convenience/session.d.ts +2 -2
- package/out/convenience/session.js +2 -12
- package/out/convenience/webhook.d.ts +11 -7
- package/out/core/api.d.ts +9 -9
- package/out/core/api.js +5 -31
- package/out/core/client.d.ts +21 -2
- package/out/core/client.js +78 -94
- package/out/core/error.d.ts +3 -1
- package/out/core/error.js +26 -46
- package/out/filter.d.ts +36 -19
- package/out/mod.d.ts +4 -7
- package/out/mod.js +5 -1
- package/out/platform.node.d.ts +2 -2
- package/out/platform.node.js +6 -26
- package/out/shim.node.d.ts +1 -1
- package/out/shim.node.js +1 -2
- package/package.json +7 -7
package/out/filter.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AliasProps, Context } from "./context.js";
|
|
2
|
-
import { Update } from "./platform.node.js";
|
|
1
|
+
import { type AliasProps, type Context } from "./context.js";
|
|
2
|
+
import { type Update } from "./platform.node.js";
|
|
3
3
|
declare type FilterFunction<C extends Context, D extends C> = (ctx: C) => ctx is D;
|
|
4
4
|
/**
|
|
5
5
|
* > This is an advanced function of grammY.
|
|
@@ -352,11 +352,11 @@ declare const UPDATE_KEYS: {
|
|
|
352
352
|
};
|
|
353
353
|
declare type KeyOf<T> = string & keyof T;
|
|
354
354
|
declare type S = typeof UPDATE_KEYS;
|
|
355
|
-
declare type
|
|
356
|
-
declare type
|
|
357
|
-
declare type
|
|
358
|
-
declare type
|
|
359
|
-
declare type L123 =
|
|
355
|
+
declare type L1S = KeyOf<S>;
|
|
356
|
+
declare type L2S<L1 extends L1S = L1S> = L1 extends unknown ? `${L1}:${KeyOf<S[L1]>}` : never;
|
|
357
|
+
declare type L3S<L1 extends L1S = L1S> = L1 extends unknown ? L3S_<L1> : never;
|
|
358
|
+
declare type L3S_<L1 extends L1S, L2 extends KeyOf<S[L1]> = KeyOf<S[L1]>> = L2 extends unknown ? `${L1}:${L2}:${KeyOf<S[L1][L2]>}` : never;
|
|
359
|
+
declare type L123 = L1S | L2S | L3S;
|
|
360
360
|
declare type InjectShortcuts<Q extends L123 = L123> = Q extends `${infer R}:${infer S}:${infer T}` ? `${CollapseL1<R, L1Shortcuts>}:${CollapseL2<S, L2Shortcuts>}:${T}` : Q extends `${infer R}:${infer S}` ? `${CollapseL1<R, L1Shortcuts>}:${CollapseL2<S>}` : CollapseL1<Q>;
|
|
361
361
|
declare type CollapseL1<Q extends string, L extends L1Shortcuts = Exclude<L1Shortcuts, "">> = Q | (L extends string ? Q extends typeof L1_SHORTCUTS[L][number] ? L : never : never);
|
|
362
362
|
declare type CollapseL2<Q extends string, L extends L2Shortcuts = Exclude<L2Shortcuts, "">> = Q | (L extends string ? Q extends typeof L2_SHORTCUTS[L][number] ? L : never : never);
|
|
@@ -388,14 +388,17 @@ declare type NotUndefined = string | number | boolean | SomeObject;
|
|
|
388
388
|
* Given a FilterQuery, returns an object that, when intersected with an Update,
|
|
389
389
|
* marks those properties as required that are guaranteed to exist.
|
|
390
390
|
*/
|
|
391
|
-
declare type RunQuery<Q extends string> =
|
|
392
|
-
declare type
|
|
393
|
-
declare type
|
|
394
|
-
declare type
|
|
395
|
-
declare type
|
|
391
|
+
declare type RunQuery<Q extends string> = L1Discriminator<Q, L1Parts<Q>>;
|
|
392
|
+
declare type L1Parts<Q extends string> = Q extends `${infer L1}:${string}` ? L1 : Q;
|
|
393
|
+
declare type L2Parts<Q extends string, L1 extends string> = Q extends `${L1}:${infer L2}:${string}` ? L2 : Q extends `${L1}:${infer L2}` ? L2 : never;
|
|
394
|
+
declare type L1Discriminator<Q extends string, L1 extends string> = Combine<L1Fragment<Q, L1>, L1>;
|
|
395
|
+
declare type L1Fragment<Q extends string, L1 extends string> = L1 extends unknown ? Record<L1, L2Discriminator<L1, L2Parts<Q, L1>>> : never;
|
|
396
|
+
declare type L2Discriminator<L1 extends string, L2 extends string> = [L2] extends [
|
|
397
|
+
never
|
|
398
|
+
] ? L2ShallowFragment<L1> : Combine<L2Fragment<L1, L2>, L2>;
|
|
399
|
+
declare type L2Fragment<L1 extends string, L2 extends string> = L2 extends unknown ? Record<L2 | AddTwins<L1, L2>, NotUndefined> : never;
|
|
400
|
+
declare type L2ShallowFragment<L1 extends string> = Record<AddTwins<L1, never>, NotUndefined>;
|
|
396
401
|
declare type Combine<U, K extends string> = U extends unknown ? U & Partial<Record<Exclude<K, keyof U>, undefined>> : never;
|
|
397
|
-
declare type L1Parts<Q extends string> = Q extends `${infer U}:${string}` ? U : Q;
|
|
398
|
-
declare type L2Parts<Q extends string, P extends string> = Q extends `${P}:${infer U}:${string}` ? U : Q extends `${P}:${infer U}` ? U : never;
|
|
399
402
|
/**
|
|
400
403
|
* This type infers which properties will be present on the given context object
|
|
401
404
|
* provided it matches the given filter query. If the filter query is a union
|
|
@@ -411,6 +414,7 @@ declare type FilteredContext<C extends Context, U extends Update> = C & Record<"
|
|
|
411
414
|
interface Shortcuts<U extends Update> {
|
|
412
415
|
msg: [U["callback_query"]] extends [SomeObject] ? U["callback_query"]["message"] : [U["message"]] extends [SomeObject] ? U["message"] : [U["edited_message"]] extends [SomeObject] ? U["edited_message"] : [U["channel_post"]] extends [SomeObject] ? U["channel_post"] : [U["edited_channel_post"]] extends [SomeObject] ? U["edited_channel_post"] : undefined;
|
|
413
416
|
chat: [U["callback_query"]] extends [SomeObject] ? NonNullable<U["callback_query"]["message"]>["chat"] | undefined : [Shortcuts<U>["msg"]] extends [SomeObject] ? Shortcuts<U>["msg"]["chat"] : [U["my_chat_member"]] extends [SomeObject] ? U["my_chat_member"]["chat"] : [U["chat_member"]] extends [SomeObject] ? U["chat_member"]["chat"] : [U["chat_join_request"]] extends [SomeObject] ? U["chat_join_request"]["chat"] : undefined;
|
|
417
|
+
senderChat: [Shortcuts<U>["msg"]] extends [SomeObject] ? Shortcuts<U>["msg"]["sender_chat"] : undefined;
|
|
414
418
|
from: [U["callback_query"]] extends [SomeObject] ? U["callback_query"]["from"] : [U["inline_query"]] extends [SomeObject] ? U["inline_query"]["from"] : [U["shipping_query"]] extends [SomeObject] ? U["shipping_query"]["from"] : [U["pre_checkout_query"]] extends [SomeObject] ? U["pre_checkout_query"]["from"] : [U["chosen_inline_result"]] extends [SomeObject] ? U["chosen_inline_result"]["from"] : [U["message"]] extends [SomeObject] ? NonNullable<U["message"]["from"]> : [U["edited_message"]] extends [SomeObject] ? NonNullable<U["edited_message"]["from"]> : [U["my_chat_member"]] extends [SomeObject] ? U["my_chat_member"]["from"] : [U["chat_member"]] extends [SomeObject] ? U["chat_member"]["from"] : [U["chat_join_request"]] extends [SomeObject] ? U["chat_join_request"]["from"] : undefined;
|
|
415
419
|
}
|
|
416
420
|
declare const L1_SHORTCUTS: {
|
|
@@ -425,16 +429,29 @@ declare const L2_SHORTCUTS: {
|
|
|
425
429
|
};
|
|
426
430
|
declare type L1Shortcuts = KeyOf<typeof L1_SHORTCUTS>;
|
|
427
431
|
declare type L2Shortcuts = KeyOf<typeof L2_SHORTCUTS>;
|
|
428
|
-
declare type ExpandShortcuts<Q extends string> = Q extends `${infer
|
|
432
|
+
declare type ExpandShortcuts<Q extends string> = Q extends `${infer L1}:${infer L2}:${infer L3}` ? `${ExpandL1<L1>}:${ExpandL2<L2>}:${L3}` : Q extends `${infer L1}:${infer L2}` ? `${ExpandL1<L1>}:${ExpandL2<L2>}` : ExpandL1<Q>;
|
|
429
433
|
declare type ExpandL1<S extends string> = S extends L1Shortcuts ? typeof L1_SHORTCUTS[S][number] : S;
|
|
430
434
|
declare type ExpandL2<S extends string> = S extends L2Shortcuts ? typeof L2_SHORTCUTS[S][number] : S;
|
|
431
|
-
declare type
|
|
432
|
-
declare type
|
|
435
|
+
declare type AddTwins<L1 extends string, L2 extends string> = TwinsFromL1<L1, L2> | TwinsFromL2<L1, L2>;
|
|
436
|
+
declare type TwinsFromL1<L1 extends string, L2 extends string> = L1 extends KeyOf<L1Equivalents> ? L1Equivalents[L1] : L2;
|
|
437
|
+
declare type L1Equivalents = {
|
|
438
|
+
message: "from";
|
|
439
|
+
edited_message: "from" | "edit_date";
|
|
440
|
+
channel_post: "sender_chat";
|
|
441
|
+
edited_channel_post: "sender_chat" | "edit_date";
|
|
442
|
+
};
|
|
443
|
+
declare type TwinsFromL2<L1 extends string, L2 extends string> = L1 extends KeyOf<L2Equivalents> ? L2 extends KeyOf<L2Equivalents[L1]> ? L2Equivalents[L1][L2] : L2 : L2;
|
|
444
|
+
declare type L2Equivalents = {
|
|
445
|
+
message: MessageEquivalents;
|
|
446
|
+
edited_message: MessageEquivalents;
|
|
447
|
+
channel_post: MessageEquivalents;
|
|
448
|
+
edited_channel_post: MessageEquivalents;
|
|
449
|
+
};
|
|
450
|
+
declare type MessageEquivalents = {
|
|
433
451
|
animation: "document";
|
|
434
|
-
entities:
|
|
452
|
+
entities: "text";
|
|
435
453
|
caption: CaptionMessages;
|
|
436
454
|
caption_entities: CaptionMessages;
|
|
437
455
|
};
|
|
438
|
-
declare type TextMessages = "text";
|
|
439
456
|
declare type CaptionMessages = "animation" | "audio" | "document" | "photo" | "video" | "voice";
|
|
440
457
|
export {};
|
package/out/mod.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
export { Bot, BotError } from "./bot.js";
|
|
2
|
-
export type { BotConfig, ErrorHandler, PollingOptions } from "./bot.js";
|
|
1
|
+
export { Bot, type BotConfig, BotError, type ErrorHandler, type PollingOptions, } from "./bot.js";
|
|
3
2
|
export { InputFile } from "./platform.node.js";
|
|
4
3
|
export { Context } from "./context.js";
|
|
5
4
|
export * from "./convenience/keyboard.js";
|
|
6
5
|
export * from "./convenience/session.js";
|
|
7
6
|
export * from "./convenience/webhook.js";
|
|
8
|
-
export { Composer } from "./composer.js";
|
|
9
|
-
export
|
|
10
|
-
export { matchFilter } from "./filter.js";
|
|
11
|
-
export type { Filter, FilterQuery } from "./filter.js";
|
|
7
|
+
export { Composer, type Middleware, type MiddlewareFn, type MiddlewareObj, type NextFunction, } from "./composer.js";
|
|
8
|
+
export { type Filter, type FilterQuery, matchFilter } from "./filter.js";
|
|
12
9
|
export { Api } from "./core/api.js";
|
|
13
|
-
export type
|
|
10
|
+
export { type ApiCallFn, type ApiClientOptions, type RawApi, type TransformableApi, type Transformer, type WebhookReplyEnvelope, } from "./core/client.js";
|
|
14
11
|
export { GrammyError, HttpError } from "./core/error.js";
|
package/out/mod.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/out/platform.node.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { InputFileProxy } from "@grammyjs/types";
|
|
2
|
+
import { type InputFileProxy } from "@grammyjs/types";
|
|
3
3
|
import { Agent as HttpAgent } from "http";
|
|
4
4
|
import { Agent as HttpsAgent } from "https";
|
|
5
5
|
import { Readable } from "stream";
|
|
6
|
-
import type
|
|
6
|
+
import { type ReadStream } from "fs";
|
|
7
7
|
import { URL } from "url";
|
|
8
8
|
export * from "@grammyjs/types";
|
|
9
9
|
import { debug as d } from "debug";
|
package/out/platform.node.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -58,31 +62,7 @@ class InputFile {
|
|
|
58
62
|
* @param filename Optional name of the file
|
|
59
63
|
*/
|
|
60
64
|
constructor(file, filename) {
|
|
61
|
-
|
|
62
|
-
enumerable: true,
|
|
63
|
-
configurable: true,
|
|
64
|
-
writable: true,
|
|
65
|
-
value: false
|
|
66
|
-
});
|
|
67
|
-
Object.defineProperty(this, "fileData", {
|
|
68
|
-
enumerable: true,
|
|
69
|
-
configurable: true,
|
|
70
|
-
writable: true,
|
|
71
|
-
value: void 0
|
|
72
|
-
});
|
|
73
|
-
/**
|
|
74
|
-
* Optional name of the constructed `InputFile` instance.
|
|
75
|
-
*
|
|
76
|
-
* Check out the
|
|
77
|
-
* [documenation](https://grammy.dev/guide/files.html#uploading-your-own-file)
|
|
78
|
-
* on sending files with `InputFile`.
|
|
79
|
-
*/
|
|
80
|
-
Object.defineProperty(this, "filename", {
|
|
81
|
-
enumerable: true,
|
|
82
|
-
configurable: true,
|
|
83
|
-
writable: true,
|
|
84
|
-
value: void 0
|
|
85
|
-
});
|
|
65
|
+
this.consumed = false;
|
|
86
66
|
this.fileData = file;
|
|
87
67
|
filename !== null && filename !== void 0 ? filename : (filename = this.guessFilename(file));
|
|
88
68
|
this.filename = filename;
|
package/out/shim.node.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AbortController, AbortSignal } from "abort-controller";
|
|
1
|
+
export { AbortController, type AbortSignal } from "abort-controller";
|
|
2
2
|
export { default as fetch } from "node-fetch";
|
package/out/shim.node.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetch = exports.
|
|
3
|
+
exports.fetch = exports.AbortController = void 0;
|
|
4
4
|
var abort_controller_1 = require("abort-controller");
|
|
5
5
|
Object.defineProperty(exports, "AbortController", { enumerable: true, get: function () { return abort_controller_1.AbortController; } });
|
|
6
|
-
Object.defineProperty(exports, "AbortSignal", { enumerable: true, get: function () { return abort_controller_1.AbortSignal; } });
|
|
7
6
|
var node_fetch_1 = require("node-fetch");
|
|
8
7
|
Object.defineProperty(exports, "fetch", { enumerable: true, get: function () { return node_fetch_1.default; } });
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "grammy",
|
|
3
3
|
"description": "The Telegram Bot Framework.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.7.2",
|
|
5
5
|
"author": "KnorpelSenf",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"engines": {
|
|
@@ -23,17 +23,17 @@
|
|
|
23
23
|
"contribs": "all-contributors"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@grammyjs/types": "^2.
|
|
26
|
+
"@grammyjs/types": "^2.6.0",
|
|
27
27
|
"abort-controller": "^3.0.0",
|
|
28
|
-
"debug": "^4.3.
|
|
29
|
-
"node-fetch": "^2.6.
|
|
28
|
+
"debug": "^4.3.4",
|
|
29
|
+
"node-fetch": "^2.6.7"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/debug": "^4.1.7",
|
|
33
|
-
"@types/node": "^12.20.
|
|
34
|
-
"@types/node-fetch": "^2.
|
|
33
|
+
"@types/node": "^12.20.47",
|
|
34
|
+
"@types/node-fetch": "^2.6.1",
|
|
35
35
|
"all-contributors-cli": "^6.20.0",
|
|
36
|
-
"deno2node": "^1.
|
|
36
|
+
"deno2node": "^1.3.0"
|
|
37
37
|
},
|
|
38
38
|
"files": [
|
|
39
39
|
"out/"
|