Comparing version 1.12.0 to 1.12.1
@@ -52,3 +52,3 @@ import { BotError, Composer } from "./composer.js"; | ||
*/ | ||
export declare type ErrorHandler<C extends Context = Context> = (error: BotError<C>) => unknown; | ||
export type ErrorHandler<C extends Context = Context> = (error: BotError<C>) => unknown; | ||
/** | ||
@@ -55,0 +55,0 @@ * Options to pass to the bot when creating it. |
@@ -290,4 +290,4 @@ "use strict"; | ||
const offset = this.lastTriedUpdateId + 1; | ||
await this.api.getUpdates({ offset, limit: 1 }); | ||
this.pollingAbortController = undefined; | ||
await this.api.getUpdates({ offset, limit: 1 }) | ||
.finally(() => this.pollingAbortController = undefined); | ||
} | ||
@@ -294,0 +294,0 @@ else { |
import { type CallbackQueryContext, type ChatTypeContext, type CommandContext, Context, type GameQueryContext, type HearsContext, type InlineQueryContext, type MaybeArray, type StringWithSuggestions } from "./context.js"; | ||
import { type Filter, type FilterQuery } from "./filter.js"; | ||
import { type Chat } from "./types.js"; | ||
declare type MaybePromise<T> = T | Promise<T>; | ||
type MaybePromise<T> = T | Promise<T>; | ||
/** | ||
@@ -16,7 +16,7 @@ * A function of this type is passed as the second parameter to all middleware. | ||
*/ | ||
export declare type NextFunction = () => Promise<void>; | ||
export type NextFunction = () => Promise<void>; | ||
/** | ||
* Middleware in the form of a function. | ||
*/ | ||
export declare type MiddlewareFn<C extends Context = Context> = (ctx: C, next: NextFunction) => MaybePromise<unknown>; | ||
export type MiddlewareFn<C extends Context = Context> = (ctx: C, next: NextFunction) => MaybePromise<unknown>; | ||
/** | ||
@@ -71,3 +71,3 @@ * Middleware in the form of a container for a function. | ||
*/ | ||
export declare type Middleware<C extends Context = Context> = MiddlewareFn<C> | MiddlewareObj<C>; | ||
export type Middleware<C extends Context = Context> = MiddlewareFn<C> | MiddlewareObj<C>; | ||
/** | ||
@@ -597,3 +597,3 @@ * This error is thrown when middleware throws. It simply wraps the original | ||
*/ | ||
export declare type HearsMiddleware<C extends Context> = Middleware<HearsContext<C>>; | ||
export type HearsMiddleware<C extends Context> = Middleware<HearsContext<C>>; | ||
/** | ||
@@ -607,3 +607,3 @@ * Type of the middleware that can be passed to `bot.command`. | ||
*/ | ||
export declare type CommandMiddleware<C extends Context> = Middleware<CommandContext<C>>; | ||
export type CommandMiddleware<C extends Context> = Middleware<CommandContext<C>>; | ||
/** | ||
@@ -617,3 +617,3 @@ * Type of the middleware that can be passed to `bot.callbackQuery`. | ||
*/ | ||
export declare type CallbackQueryMiddleware<C extends Context> = Middleware<CallbackQueryContext<C>>; | ||
export type CallbackQueryMiddleware<C extends Context> = Middleware<CallbackQueryContext<C>>; | ||
/** | ||
@@ -627,3 +627,3 @@ * Type of the middleware that can be passed to `bot.gameQuery`. | ||
*/ | ||
export declare type GameQueryMiddleware<C extends Context> = Middleware<GameQueryContext<C>>; | ||
export type GameQueryMiddleware<C extends Context> = Middleware<GameQueryContext<C>>; | ||
/** | ||
@@ -637,3 +637,3 @@ * Type of the middleware that can be passed to `bot.inlineQuery`. | ||
*/ | ||
export declare type InlineQueryMiddleware<C extends Context> = Middleware<InlineQueryContext<C>>; | ||
export type InlineQueryMiddleware<C extends Context> = Middleware<InlineQueryContext<C>>; | ||
/** | ||
@@ -647,3 +647,3 @@ * Type of the middleware that can be passed to `bot.chatType`. | ||
*/ | ||
export declare type ChatTypeMiddleware<C extends Context, T extends Chat["type"]> = Middleware<ChatTypeContext<C, T>>; | ||
export type ChatTypeMiddleware<C extends Context, T extends Chat["type"]> = Middleware<ChatTypeContext<C, T>>; | ||
export {}; |
@@ -25,2 +25,17 @@ /// <reference types="node" /> | ||
}; | ||
"std/http": (req: Request) => { | ||
update: Promise<any>; | ||
header: string | undefined; | ||
end: () => void; | ||
respond: (json: string) => void; | ||
unauthorized: () => void; | ||
handlerReturn: Promise<unknown>; | ||
}; | ||
oak: (ctx: any) => { | ||
update: any; | ||
header: any; | ||
end: () => number; | ||
respond: (json: string) => void; | ||
unauthorized: () => void; | ||
}; | ||
http: (req: IncomingMessage, res: ServerResponse) => { | ||
@@ -71,3 +86,13 @@ update: Promise<any>; | ||
}; | ||
sveltekit: ({ request }: { | ||
request: Request; | ||
}) => { | ||
update: Promise<any>; | ||
header: string | undefined; | ||
end: () => void; | ||
respond: (json: string) => void; | ||
unauthorized: () => void; | ||
handlerReturn: Promise<unknown>; | ||
}; | ||
}; | ||
export declare const defaultAdapter = "express"; |
@@ -68,2 +68,34 @@ "use strict"; | ||
}); | ||
/** Sveltekit Serverless Functions */ | ||
const sveltekit = ({ request }) => { | ||
var _a; | ||
let resolveResponse; | ||
return { | ||
update: Promise.resolve(request.json()), | ||
header: (_a = request.headers.get(frameworks_shared_js_1.SECRET_HEADER)) !== null && _a !== void 0 ? _a : undefined, | ||
end: () => { | ||
if (resolveResponse) | ||
resolveResponse(new Response()); | ||
}, | ||
respond: (json) => { | ||
if (resolveResponse) { | ||
const res = new Response(json, { | ||
headers: { "Content-Type": "application/json" }, | ||
}); | ||
resolveResponse(res); | ||
} | ||
}, | ||
unauthorized: () => { | ||
if (resolveResponse) { | ||
const res = new Response("secret token is wrong", { | ||
status: 401, | ||
}); | ||
resolveResponse(res); | ||
} | ||
}, | ||
handlerReturn: new Promise((resolve) => { | ||
resolveResponse = resolve; | ||
}), | ||
}; | ||
}; | ||
// please open a PR if you want to add another | ||
@@ -77,4 +109,5 @@ exports.adapters = { | ||
"next-js": nextJs, | ||
sveltekit, | ||
...frameworks_shared_js_1.adapters, | ||
}; | ||
exports.defaultAdapter = "express"; |
@@ -24,2 +24,17 @@ export declare const SECRET_HEADER = "X-Telegram-Bot-Api-Secret-Token"; | ||
}; | ||
"std/http": (req: Request) => { | ||
update: Promise<any>; | ||
header: string | undefined; | ||
end: () => void; | ||
respond: (json: string) => void; | ||
unauthorized: () => void; | ||
handlerReturn: Promise<unknown>; | ||
}; | ||
oak: (ctx: any) => { | ||
update: any; | ||
header: any; | ||
end: () => number; | ||
respond: (json: string) => void; | ||
unauthorized: () => void; | ||
}; | ||
}; |
@@ -42,2 +42,46 @@ "use strict"; | ||
}); | ||
/** std/http web server */ | ||
const stdHttp = (req) => { | ||
let resolveResponse; | ||
return { | ||
update: req.json(), | ||
header: req.headers.get(exports.SECRET_HEADER) || undefined, | ||
end: () => { | ||
if (resolveResponse) | ||
resolveResponse(new Response()); | ||
}, | ||
respond: (json) => { | ||
if (resolveResponse) { | ||
const res = new Response(json, { | ||
headers: { "Content-Type": "application/json" }, | ||
}); | ||
resolveResponse(res); | ||
} | ||
}, | ||
unauthorized: () => { | ||
if (resolveResponse) { | ||
const res = new Response("secret token is wrong", { | ||
status: 401, | ||
}); | ||
resolveResponse(res); | ||
} | ||
}, | ||
handlerReturn: new Promise((resolve) => { | ||
resolveResponse = resolve; | ||
}), | ||
}; | ||
}; | ||
/** oak web framework */ | ||
const oak = (ctx) => ({ | ||
update: ctx.request.body({ type: "json" }).value, | ||
header: ctx.request.headers.get(exports.SECRET_HEADER) || undefined, | ||
end: () => (ctx.response.status = 200), | ||
respond: (json) => { | ||
ctx.response.type = "json"; | ||
ctx.response.body = json; | ||
}, | ||
unauthorized: () => { | ||
ctx.response.status = 401; | ||
}, | ||
}); | ||
exports.adapters = { | ||
@@ -47,2 +91,4 @@ express, | ||
fastify, | ||
"std/http": stdHttp, | ||
oak, | ||
}; |
import { type MiddlewareFn } from "../composer.js"; | ||
import { type Context } from "../context.js"; | ||
declare type MaybePromise<T> = Promise<T> | T; | ||
type MaybePromise<T> = Promise<T> | T; | ||
/** | ||
@@ -127,6 +127,6 @@ * A session flavor is a context flavor that holds session data under | ||
*/ | ||
export declare type MultiSessionOptions<S> = S extends Record<string, any> ? { | ||
export type MultiSessionOptions<S> = S extends Record<string, any> ? { | ||
type: "multi"; | ||
} & MultiSessionOptionsRecord<S> : never; | ||
declare type MultiSessionOptionsRecord<S extends Record<string, unknown>> = { | ||
type MultiSessionOptionsRecord<S extends Record<string, unknown>> = { | ||
[K in keyof S]: SessionOptions<S[K]>; | ||
@@ -133,0 +133,0 @@ }; |
@@ -28,2 +28,17 @@ /// <reference types="node" /> | ||
}; | ||
"std/http": (req: Request) => { | ||
update: Promise<any>; | ||
header: string | undefined; | ||
end: () => void; | ||
respond: (json: string) => void; | ||
unauthorized: () => void; | ||
handlerReturn: Promise<unknown>; | ||
}; | ||
oak: (ctx: any) => { | ||
update: any; | ||
header: any; | ||
end: () => number; | ||
respond: (json: string) => void; | ||
unauthorized: () => void; | ||
}; | ||
http: (req: import("http").IncomingMessage, res: import("http").ServerResponse) => { | ||
@@ -74,2 +89,12 @@ update: Promise<any>; | ||
}; | ||
sveltekit: ({ request }: { | ||
request: Request; | ||
}) => { | ||
update: Promise<any>; | ||
header: string | undefined; | ||
end: () => void; | ||
respond: (json: string) => void; | ||
unauthorized: () => void; | ||
handlerReturn: Promise<unknown>; | ||
}; | ||
}; | ||
@@ -80,3 +105,3 @@ /** | ||
*/ | ||
declare type SupportedFrameworks = keyof typeof adapters; | ||
type SupportedFrameworks = keyof typeof adapters; | ||
/** | ||
@@ -122,3 +147,3 @@ * Abstraction over a request-response cycle, providing access to the update, as | ||
*/ | ||
export declare type FrameworkAdapter = (...args: any[]) => ReqResHandler; | ||
export type FrameworkAdapter = (...args: any[]) => ReqResHandler; | ||
export interface WebhookOptions { | ||
@@ -125,0 +150,0 @@ /** An optional strategy to handle timeouts (default: 'throw') */ |
/// <reference types="node-fetch" /> | ||
import { type ApiMethods as Telegram, type ApiResponse, type Opts } from "../types.js"; | ||
export declare type Methods<R extends RawApi> = string & keyof R; | ||
export type Methods<R extends RawApi> = string & keyof R; | ||
/** | ||
@@ -11,6 +11,6 @@ * Represents the raw Telegram Bot API with all methods specified 1:1 as | ||
*/ | ||
export declare type RawApi = { | ||
export type RawApi = { | ||
[M in keyof Telegram]: Parameters<Telegram[M]>[0] extends undefined ? (signal?: AbortSignal) => Promise<ReturnType<Telegram[M]>> : (args: Opts<M>, signal?: AbortSignal) => Promise<ReturnType<Telegram[M]>>; | ||
}; | ||
export declare type Payload<M extends Methods<R>, R extends RawApi> = M extends unknown ? R[M] extends (signal?: AbortSignal) => unknown ? {} : R[M] extends (args: any, signal?: AbortSignal) => unknown ? Parameters<R[M]>[0] : never : never; | ||
export type Payload<M extends Methods<R>, R extends RawApi> = M extends unknown ? R[M] extends (signal?: AbortSignal) => unknown ? {} : R[M] extends (args: any, signal?: AbortSignal) => unknown ? Parameters<R[M]>[0] : never : never; | ||
/** | ||
@@ -26,4 +26,4 @@ * Small utility interface that abstracts from webhook reply calls of different | ||
*/ | ||
export declare type ApiCallFn<R extends RawApi = RawApi> = <M extends Methods<R>>(method: M, payload: Payload<M, R>, signal?: AbortSignal) => Promise<ApiResponse<ApiCallResult<M, R>>>; | ||
declare type ApiCallResult<M extends Methods<R>, R extends RawApi> = R[M] extends (...args: unknown[]) => unknown ? Awaited<ReturnType<R[M]>> : never; | ||
export type ApiCallFn<R extends RawApi = RawApi> = <M extends Methods<R>>(method: M, payload: Payload<M, R>, signal?: AbortSignal) => Promise<ApiResponse<ApiCallResult<M, R>>>; | ||
type ApiCallResult<M extends Methods<R>, R extends RawApi> = R[M] extends (...args: unknown[]) => unknown ? Awaited<ReturnType<R[M]>> : never; | ||
/** | ||
@@ -38,4 +38,4 @@ * API call transformers are functions that can access and modify the method and | ||
*/ | ||
export declare type Transformer<R extends RawApi = RawApi> = <M extends Methods<R>>(prev: ApiCallFn<R>, method: M, payload: Payload<M, R>, signal?: AbortSignal) => Promise<ApiResponse<ApiCallResult<M, R>>>; | ||
export declare type TransformerConsumer<R extends RawApi = RawApi> = TransformableApi<R>["use"]; | ||
export type Transformer<R extends RawApi = RawApi> = <M extends Methods<R>>(prev: ApiCallFn<R>, method: M, payload: Payload<M, R>, signal?: AbortSignal) => Promise<ApiResponse<ApiCallResult<M, R>>>; | ||
export type TransformerConsumer<R extends RawApi = RawApi> = TransformableApi<R>["use"]; | ||
/** | ||
@@ -165,3 +165,3 @@ * A transformable API enhances the `RawApi` type by transformers. | ||
export declare function createRawApi<R extends RawApi>(token: string, options?: ApiClientOptions, webhookReplyEnvelope?: WebhookReplyEnvelope): TransformableApi<R>; | ||
import { AbortSignal, fetch } from "../shim.node.js"; | ||
import { AbortSignal, fetch } from "./../shim.node.js"; | ||
export {}; |
@@ -180,2 +180,2 @@ "use strict"; | ||
} | ||
const shim_node_js_1 = require("../shim.node.js"); | ||
const shim_node_js_1 = require("./../shim.node.js"); |
import { type AliasProps, type Context } from "./context.js"; | ||
import { type Update } from "./types.js"; | ||
declare type FilterFunction<C extends Context, D extends C> = (ctx: C) => ctx is D; | ||
type FilterFunction<C extends Context, D extends C> = (ctx: C) => ctx is D; | ||
/** | ||
@@ -393,13 +393,13 @@ * > This is an advanced function of grammY. | ||
}; | ||
declare type KeyOf<T> = string & keyof T; | ||
declare type S = typeof UPDATE_KEYS; | ||
declare type L1S = KeyOf<S>; | ||
declare type L2S<L1 extends L1S = L1S> = L1 extends unknown ? `${L1}:${KeyOf<S[L1]>}` : never; | ||
declare type L3S<L1 extends L1S = L1S> = L1 extends unknown ? L3S_<L1> : never; | ||
declare type L3S_<L1 extends L1S, L2 extends KeyOf<S[L1]> = KeyOf<S[L1]>> = L2 extends unknown ? `${L1}:${L2}:${KeyOf<S[L1][L2]>}` : never; | ||
declare type L123 = L1S | L2S | L3S; | ||
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>; | ||
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); | ||
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); | ||
declare type AllValidFilterQueries = InjectShortcuts; | ||
type KeyOf<T> = string & keyof T; | ||
type S = typeof UPDATE_KEYS; | ||
type L1S = KeyOf<S>; | ||
type L2S<L1 extends L1S = L1S> = L1 extends unknown ? `${L1}:${KeyOf<S[L1]>}` : never; | ||
type L3S<L1 extends L1S = L1S> = L1 extends unknown ? L3S_<L1> : never; | ||
type L3S_<L1 extends L1S, L2 extends KeyOf<S[L1]> = KeyOf<S[L1]>> = L2 extends unknown ? `${L1}:${L2}:${KeyOf<S[L1][L2]>}` : never; | ||
type L123 = L1S | L2S | L3S; | ||
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>; | ||
type CollapseL1<Q extends string, L extends L1Shortcuts = Exclude<L1Shortcuts, "">> = Q | (L extends string ? Q extends typeof L1_SHORTCUTS[L][number] ? L : never : never); | ||
type CollapseL2<Q extends string, L extends L2Shortcuts = Exclude<L2Shortcuts, "">> = Q | (L extends string ? Q extends typeof L2_SHORTCUTS[L][number] ? L : never : never); | ||
type AllValidFilterQueries = InjectShortcuts; | ||
/** | ||
@@ -421,3 +421,3 @@ * Represents a filter query that can be passed to `bot.on`. There are three | ||
*/ | ||
export declare type FilterQuery = AllValidFilterQueries; | ||
export type FilterQuery = AllValidFilterQueries; | ||
/** | ||
@@ -427,4 +427,4 @@ * Any kind of value that appears in the Telegram Bot API. When intersected with | ||
*/ | ||
declare type SomeObject = object; | ||
declare type NotUndefined = string | number | boolean | SomeObject; | ||
type SomeObject = object; | ||
type NotUndefined = string | number | boolean | SomeObject; | ||
/** | ||
@@ -434,14 +434,14 @@ * Given a FilterQuery, returns an object that, when intersected with an Update, | ||
*/ | ||
declare type RunQuery<Q extends string> = L1Discriminator<Q, L1Parts<Q>>; | ||
declare type L1Parts<Q extends string> = Q extends `${infer L1}:${string}` ? L1 : Q; | ||
declare type L2Parts<Q extends string, L1 extends string> = Q extends `${L1}:${infer L2}:${string}` ? L2 : Q extends `${L1}:${infer L2}` ? L2 : never; | ||
declare type L1Discriminator<Q extends string, L1 extends string> = Combine<L1Fragment<Q, L1>, L1>; | ||
declare type L1Fragment<Q extends string, L1 extends string> = L1 extends unknown ? Record<L1, L2Discriminator<L1, L2Parts<Q, L1>>> : never; | ||
declare type L2Discriminator<L1 extends string, L2 extends string> = [L2] extends [ | ||
type RunQuery<Q extends string> = L1Discriminator<Q, L1Parts<Q>>; | ||
type L1Parts<Q extends string> = Q extends `${infer L1}:${string}` ? L1 : Q; | ||
type L2Parts<Q extends string, L1 extends string> = Q extends `${L1}:${infer L2}:${string}` ? L2 : Q extends `${L1}:${infer L2}` ? L2 : never; | ||
type L1Discriminator<Q extends string, L1 extends string> = Combine<L1Fragment<Q, L1>, L1>; | ||
type L1Fragment<Q extends string, L1 extends string> = L1 extends unknown ? Record<L1, L2Discriminator<L1, L2Parts<Q, L1>>> : never; | ||
type L2Discriminator<L1 extends string, L2 extends string> = [L2] extends [ | ||
never | ||
] ? L2ShallowFragment<L1> : Combine<L2Fragment<L1, L2>, L2>; | ||
declare type L2Fragment<L1 extends string, L2 extends string> = L2 extends unknown ? Record<L2 | AddTwins<L1, L2>, NotUndefined> : never; | ||
declare type L2ShallowFragment<L1 extends string> = Record<AddTwins<L1, never>, NotUndefined>; | ||
declare type Combine<U, K extends string> = U extends unknown ? U & Partial<Record<Exclude<K, keyof U>, undefined>> : never; | ||
export declare type FilterCore<Q extends FilterQuery> = PerformQueryCore<RunQuery<ExpandShortcuts<Q>>>; | ||
type L2Fragment<L1 extends string, L2 extends string> = L2 extends unknown ? Record<L2 | AddTwins<L1, L2>, NotUndefined> : never; | ||
type L2ShallowFragment<L1 extends string> = Record<AddTwins<L1, never>, NotUndefined>; | ||
type Combine<U, K extends string> = U extends unknown ? U & Partial<Record<Exclude<K, keyof U>, undefined>> : never; | ||
export type FilterCore<Q extends FilterQuery> = PerformQueryCore<RunQuery<ExpandShortcuts<Q>>>; | ||
/** | ||
@@ -456,7 +456,7 @@ * This type infers which properties will be present on the given context object | ||
*/ | ||
export declare type Filter<C extends Context, Q extends FilterQuery> = PerformQuery<C, RunQuery<ExpandShortcuts<Q>>>; | ||
declare type PerformQueryCore<U extends SomeObject> = U extends unknown ? FilteredContextCore<Update & U> : never; | ||
declare type PerformQuery<C extends Context, U extends SomeObject> = U extends unknown ? FilteredContext<C, Update & U> : never; | ||
declare type FilteredContextCore<U extends Update> = Record<"update", U> & AliasProps<Omit<U, "update_id">> & Shortcuts<U>; | ||
declare type FilteredContext<C extends Context, U extends Update> = C & FilteredContextCore<U>; | ||
export type Filter<C extends Context, Q extends FilterQuery> = PerformQuery<C, RunQuery<ExpandShortcuts<Q>>>; | ||
type PerformQueryCore<U extends SomeObject> = U extends unknown ? FilteredContextCore<Update & U> : never; | ||
type PerformQuery<C extends Context, U extends SomeObject> = U extends unknown ? FilteredContext<C, Update & U> : never; | ||
type FilteredContextCore<U extends Update> = Record<"update", U> & AliasProps<Omit<U, "update_id">> & Shortcuts<U>; | ||
type FilteredContext<C extends Context, U extends Update> = C & FilteredContextCore<U>; | ||
interface Shortcuts<U extends Update> { | ||
@@ -478,10 +478,10 @@ 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; | ||
}; | ||
declare type L1Shortcuts = KeyOf<typeof L1_SHORTCUTS>; | ||
declare type L2Shortcuts = KeyOf<typeof L2_SHORTCUTS>; | ||
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>; | ||
declare type ExpandL1<S extends string> = S extends L1Shortcuts ? typeof L1_SHORTCUTS[S][number] : S; | ||
declare type ExpandL2<S extends string> = S extends L2Shortcuts ? typeof L2_SHORTCUTS[S][number] : S; | ||
declare type AddTwins<L1 extends string, L2 extends string> = TwinsFromL1<L1, L2> | TwinsFromL2<L1, L2>; | ||
declare type TwinsFromL1<L1 extends string, L2 extends string> = L1 extends KeyOf<L1Equivalents> ? L1Equivalents[L1] : L2; | ||
declare type L1Equivalents = { | ||
type L1Shortcuts = KeyOf<typeof L1_SHORTCUTS>; | ||
type L2Shortcuts = KeyOf<typeof L2_SHORTCUTS>; | ||
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>; | ||
type ExpandL1<S extends string> = S extends L1Shortcuts ? typeof L1_SHORTCUTS[S][number] : S; | ||
type ExpandL2<S extends string> = S extends L2Shortcuts ? typeof L2_SHORTCUTS[S][number] : S; | ||
type AddTwins<L1 extends string, L2 extends string> = TwinsFromL1<L1, L2> | TwinsFromL2<L1, L2>; | ||
type TwinsFromL1<L1 extends string, L2 extends string> = L1 extends KeyOf<L1Equivalents> ? L1Equivalents[L1] : L2; | ||
type L1Equivalents = { | ||
message: "from"; | ||
@@ -492,4 +492,4 @@ edited_message: "from" | "edit_date"; | ||
}; | ||
declare type TwinsFromL2<L1 extends string, L2 extends string> = L1 extends KeyOf<L2Equivalents> ? L2 extends KeyOf<L2Equivalents[L1]> ? L2Equivalents[L1][L2] : L2 : L2; | ||
declare type L2Equivalents = { | ||
type TwinsFromL2<L1 extends string, L2 extends string> = L1 extends KeyOf<L2Equivalents> ? L2 extends KeyOf<L2Equivalents[L1]> ? L2Equivalents[L1][L2] : L2 : L2; | ||
type L2Equivalents = { | ||
message: MessageEquivalents; | ||
@@ -500,3 +500,3 @@ edited_message: MessageEquivalents; | ||
}; | ||
declare type MessageEquivalents = { | ||
type MessageEquivalents = { | ||
animation: "document"; | ||
@@ -507,3 +507,3 @@ entities: "text"; | ||
}; | ||
declare type CaptionMessages = "animation" | "audio" | "document" | "photo" | "video" | "voice"; | ||
type CaptionMessages = "animation" | "audio" | "document" | "photo" | "video" | "voice"; | ||
export {}; |
@@ -42,7 +42,7 @@ /// <reference types="node" /> | ||
} | ||
declare type GrammyTypes = InputFileProxy<InputFile>; | ||
type GrammyTypes = InputFileProxy<InputFile>; | ||
/** Wrapper type to bundle all methods of the Telegram API */ | ||
export declare type ApiMethods = GrammyTypes["Telegram"]; | ||
export type ApiMethods = GrammyTypes["Telegram"]; | ||
/** Utility type providing the argument type for the given method name or `{}` if the method does not take any parameters */ | ||
export declare type Opts<M extends keyof GrammyTypes["Telegram"]> = GrammyTypes["Opts"][M]; | ||
export type Opts<M extends keyof GrammyTypes["Telegram"]> = GrammyTypes["Opts"][M]; | ||
/** This object represents the content of a media message to be sent. It should be one of | ||
@@ -54,12 +54,12 @@ - InputMediaAnimation | ||
- InputMediaVideo */ | ||
export declare type InputMedia = GrammyTypes["InputMedia"]; | ||
export type InputMedia = GrammyTypes["InputMedia"]; | ||
/** Represents a photo to be sent. */ | ||
export declare type InputMediaPhoto = GrammyTypes["InputMediaPhoto"]; | ||
export type InputMediaPhoto = GrammyTypes["InputMediaPhoto"]; | ||
/** Represents a video to be sent. */ | ||
export declare type InputMediaVideo = GrammyTypes["InputMediaVideo"]; | ||
export type InputMediaVideo = GrammyTypes["InputMediaVideo"]; | ||
/** Represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent. */ | ||
export declare type InputMediaAnimation = GrammyTypes["InputMediaAnimation"]; | ||
export type InputMediaAnimation = GrammyTypes["InputMediaAnimation"]; | ||
/** Represents an audio file to be treated as music to be sent. */ | ||
export declare type InputMediaAudio = GrammyTypes["InputMediaAudio"]; | ||
export type InputMediaAudio = GrammyTypes["InputMediaAudio"]; | ||
/** Represents a general file to be sent. */ | ||
export declare type InputMediaDocument = GrammyTypes["InputMediaDocument"]; | ||
export type InputMediaDocument = GrammyTypes["InputMediaDocument"]; |
{ | ||
"name": "grammy", | ||
"description": "The Telegram Bot Framework.", | ||
"version": "1.12.0", | ||
"version": "1.12.1", | ||
"author": "KnorpelSenf", | ||
@@ -21,3 +21,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@grammyjs/types": "^2.10.0", | ||
"@grammyjs/types": "^2.10.3", | ||
"abort-controller": "^3.0.0", | ||
@@ -32,3 +32,3 @@ "debug": "^4.3.4", | ||
"all-contributors-cli": "^6.24.0", | ||
"deno2node": "^1.4.0" | ||
"deno2node": "^1.7.1" | ||
}, | ||
@@ -35,0 +35,0 @@ "files": [ |
@@ -13,3 +13,3 @@ <div align="center"><a href="https://grammy.dev"><img src="https://raw.githubusercontent.com/grammyjs/website/main/logos/grammY.png" alt="grammY"></a></h1></div> | ||
[![Bot API](https://img.shields.io/badge/Bot%20API-6.2-blue?logo=telegram&style=flat&labelColor=000&color=3b82f6)](https://core.telegram.org/bots/api) | ||
[![Bot API](https://img.shields.io/badge/Bot%20API-6.3-blue?logo=telegram&style=flat&labelColor=000&color=3b82f6)](https://core.telegram.org/bots/api) | ||
[![Deno](https://shield.deno.dev/x/grammy)](https://deno.land/x/grammy) | ||
@@ -241,3 +241,8 @@ [![npm](https://img.shields.io/npm/v/grammy?logo=npm&style=flat&labelColor=000&color=3b82f6)](https://www.npmjs.org/package/grammy) | ||
<td align="center"><a href="https://rockett.pw"><img src="https://avatars.githubusercontent.com/u/4586280?v=4?s=100" width="100px;" alt="Mike Rockétt"/><br /><sub><b>Mike Rockétt</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Amikerockett" title="Reviewed Pull Requests">👀</a></td> | ||
<td align="center"><a href="https://github.com/MrVSiK"><img src="https://avatars.githubusercontent.com/u/79159341?v=4?s=100" width="100px;" alt="Srinivasa IK Varanasi"/><br /><sub><b>Srinivasa IK Varanasi</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=MrVSiK" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/abdoo9"><img src="https://avatars.githubusercontent.com/u/63903814?v=4?s=100" width="100px;" alt="abdoo9"/><br /><sub><b>abdoo9</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Aabdoo9" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=abdoo9" title="Code">💻</a></td> | ||
</tr> | ||
<tr> | ||
<td align="center"><a href="http://ak4zh.com"><img src="https://avatars.githubusercontent.com/u/26350053?v=4?s=100" width="100px;" alt="ak4zh"/><br /><sub><b>ak4zh</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Aak4zh" title="Reviewed Pull Requests">👀</a></td> | ||
</tr> | ||
</tbody> | ||
@@ -244,0 +249,0 @@ </table> |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
618735
10991
255
Updated@grammyjs/types@^2.10.3