@yaebal/types

full Telegram Bot API types, code-generated from a schema scraped directly off core.telegram.org/bots/api by our own parser — no dependency on a third-party schema project. the single source of truth for every interface in the yaebal ecosystem — @yaebal/contexts and @yaebal/core both read from it.

what it exports

exportkinddescription
object interfacesinterfaceone TypeScript interface per Bot API object — Message, User, Chat, PhotoSize, InlineKeyboardMarkup, etc.
*Params interfacesinterfaceone interface per Bot API method's parameters — SendMessageParams, SendPhotoParams, AnswerCallbackQueryParams, etc. required fields are non-optional; optional fields carry ?.
BotApiMethodsinterfaceevery Bot API method as a typed function signature: sendMessage(params: SendMessageParams): Promise<Message> and so on.
BOT_API_VERSIONstringthe Bot API version the current file was generated from, e.g. "10.1".

importing types

types.ts
import type {
  Message,
  User,
  Chat,
  PhotoSize,
  SendMessageParams,
  SendPhotoParams,
  BotApiMethods,
  BOT_API_VERSION,
} from "@yaebal/types";

BOT_API_VERSION

version.ts
import { BOT_API_VERSION } from "@yaebal/types";
console.log(BOT_API_VERSION); // e.g. "10.1"

BotApiMethods and *Params interfaces

methods.ts
import type { BotApiMethods, SendMessageParams } from "@yaebal/types";

// BotApiMethods is an interface with every Bot API method fully typed
type SendMessage = BotApiMethods["sendMessage"];
// (params: SendMessageParams) => Promise<Message>

// *params interfaces carry every field the method accepts
const params: SendMessageParams = {
  chat_id: 123456,
  text: "hello",
  parse_mode: "HTML", // optional fields are typed too
};

file structure

src/telegram.ts is the sole generated file. it is committed to the repository as the authoritative snapshot. do not edit it by hand — any manual edit will be overwritten on the next generation run.

src/telegram.ts (excerpt)
// AUTO-GENERATED from the Telegram Bot API schema — do not edit by hand.
// regenerate with: pnpm --filter @yaebal/types generate
// source: https://core.telegram.org/bots/api (scraped by scripts/lib/parse-schema.mjs)

export const BOT_API_VERSION = "10.1";

export interface AffiliateInfo { /* … */ }
export interface Animation { /* … */ }
// … all Bot API objects …
export interface SendMessageParams { /* … */ }
// … all *Params interfaces …
export interface BotApiMethods {
  sendMessage(params: SendMessageParams): Promise<Message>;
  // … every method …
}

regenerating

scripts/lib/parse-schema.mjs is our own parser for core.telegram.org/bots/api — it scrapes the live docs HTML straight into the same schema.json shape scripts/generate.mjs already consumes, so there is no third-party schema in the loop. scripts/update-schema.mjs ties the two together: it fetches the live docs, compares the parsed version against the committed schema.json, and — only if newer — refreshes schema.json, regenerates src/telegram.ts (and @yaebal/contexts), and bumps @yaebal/types's own version to match the Bot API version:

terminal
# scrapes core.telegram.org/bots/api, refreshes schema.json, regenerates src/telegram.ts,
# and bumps the package version to the Bot API version — no-op if already up to date
pnpm --filter @yaebal/types update-schema

a scheduled workflow (.github/workflows/update-bot-api-types.yml) runs this once a day; if there's a newer Bot API version it opens a PR (feat(types): update to bot api vX.Y.Z) after typecheck/build/test/lint all pass. merging it publishes @yaebal/types@X.Y.Z through the normal release pipeline — no manual step required.

relationship to other packages

packagehow it uses @yaebal/types
@yaebal/coreimports object interfaces for context fields (Message, User, Chat, …)
@yaebal/contextscode-generates per-update shortcut methods from BotApiMethods and the *Params interfaces
@yaebal/types has zero runtime dependencies — it is types-only. import with import type in application code so the import is erased at build time and never appears in the output bundle.