mtcute/packages/client/src/methods
Alina Sireneva 2728166727
refactor(client)!: extracted inline callback query into a separate update
breaking: `CallbackQuery` -> `CallbackQuery` and `InlineCallbackQuery`
also removed some redundant fields
2023-12-14 00:34:51 +03:00
..
auth fix(client): new codegen issues with .run method 2023-12-13 23:02:04 +03:00
bots refactor(client)!: extracted inline callback query into a separate update 2023-12-14 00:34:51 +03:00
chats fix(client): updateShortSentMessage handling 2023-12-02 21:12:16 +03:00
contacts chore(client)!: renamed some peer utils 2023-12-02 19:10:49 +03:00
dialogs ESM + end-to-end tests (#11) 2023-10-16 19:23:53 +03:00
files feat(client): support Story message media 2023-12-02 19:04:18 +03:00
forums chore(client)!: renamed some peer utils 2023-12-02 19:10:49 +03:00
invite-links chore(client)!: renamed some peer utils 2023-12-02 19:10:49 +03:00
messages refactor(client)!: extracted inline callback query into a separate update 2023-12-14 00:34:51 +03:00
misc feat(client): sequential message sending 2023-12-11 01:55:58 +03:00
password ESM + end-to-end tests (#11) 2023-10-16 19:23:53 +03:00
stickers chore(client)!: renamed some peer utils 2023-12-02 19:10:49 +03:00
stories refactor: no more parse modes! 2023-11-01 20:24:00 +03:00
updates chore(client)!: renamed some peer utils 2023-12-02 19:10:49 +03:00
users chore(client)!: renamed some peer utils 2023-12-02 19:10:49 +03:00
_imports.ts chore(client)!: improved translate* methods 2023-12-11 21:52:48 +03:00
_init.ts chore(client): reworked codegen, use prototype methods instead of fields 2023-12-13 18:29:54 +03:00
README.md ESM + end-to-end tests (#11) 2023-10-16 19:23:53 +03:00

What is this?

Files in this directory are pre-processed by generate-client.js, and client.ts is generated from the functions that are exported in this directory.

Since we need to properly type the copied signatures, there are a few "magic" instructions for the preprocessor that are used to handle imports. Also, there are a few "magic" instructions to make private methods and extend client fields.

All instructions are used as a one-line comment, like this: // @copy

@copy

Can be placed before an import or any other code block.

When placed before import, this import will be copied to client.ts, and paths will be adjusted. When there are multiple copied imports from the same files, they are merged.

When placed before any other block, it will be directly copied before the TelegramClient class.

Note

all copied imports should be inside _imports.ts file.

Example:

// @copy
import { Something } from '../../somewhere.js'

// @copy
interface SomeGreatInterface { ... }

@extension

Used before an interface declaration. Fields from that interface will be added as protected to TelegramClient.

Example:

// @extension
interface AwesomeExtension {
    _field1: number
    _field2: string
}

@initialize

Often you'll want to initialize your @extension fields in a constructor. You can do this by using @initialize instruction before a function containing initialization code.

Note

If you are using some custom types, make sure their imports are copied!

Example:

// @initialize
function _initializeAwesomeExtension(client: BaseTelegramClient) {
    this._field1 = 42
    this._field2 = 'uwu'
}

@exported

Used as a first statement inside an exported function's body to indicate that this exported type should be imported from the client

Example:

// @exported
export type FooOrBar = Foo | Bar

export function getFooOrBar(client: BaseTelegramClient): FooOrBar {
    return new Foo()
}