/** * Telegraph API Client * A TypeScript client for the Telegraph API */ import type { Account, Page, PageList, PageViews, CreateAccountParams, EditAccountInfoParams, GetAccountInfoParams, RevokeAccessTokenParams, CreatePageParams, EditPageParams, GetPageParams, GetPageListParams, GetViewsParams } from './types.js'; /** * Telegraph API Client class * * Provides a complete interface to the Telegraph API with all 9 methods. * Supports both HTML strings and Node arrays for content. * * @example * ```typescript * const telegraph = new Telegraph(); * * // Create an account * const account = await telegraph.createAccount({ * shortName: 'MyBot', * authorName: 'Bot Author' * }); * * // Create a page * const page = await telegraph.createPage({ * accessToken: account.accessToken!, * title: 'Hello World', * content: '

This is my page

' * }); * * console.log(page.url); * ``` */ export declare class Telegraph { /** * Make a request to the Telegraph API * * @param method - API method name * @param params - Request parameters * @returns API response result * @throws {TelegraphError} If the request fails or API returns an error */ private apiRequest; /** * Create a new Telegraph account * * @param params - Account creation parameters * @returns Account object with access_token * * @example * ```typescript * const account = await telegraph.createAccount({ * shortName: 'Sandbox', * authorName: 'Anonymous', * authorUrl: 'https://example.com' * }); * console.log(account.accessToken); * ``` */ createAccount(params: CreateAccountParams): Promise; /** * Update information about a Telegraph account * * @param params - Account update parameters * @returns Updated Account object * * @example * ```typescript * const account = await telegraph.editAccountInfo({ * accessToken: 'your-access-token', * shortName: 'New Name', * authorName: 'New Author' * }); * ``` */ editAccountInfo(params: EditAccountInfoParams): Promise; /** * Get information about a Telegraph account * * @param params - Account info request parameters * @returns Account object with requested fields * * @example * ```typescript * const account = await telegraph.getAccountInfo({ * accessToken: 'your-access-token', * fields: ['short_name', 'page_count'] * }); * console.log(`Pages: ${account.page_count}`); * ``` */ getAccountInfo(params: GetAccountInfoParams): Promise; /** * Revoke access_token and generate a new one * * @param params - Token revocation parameters * @returns Account object with new access_token and auth_url * * @example * ```typescript * const account = await telegraph.revokeAccessToken({ * accessToken: 'your-old-token' * }); * console.log(`New token: ${account.accessToken}`); * console.log(`Auth URL: ${account.auth_url}`); * ``` */ revokeAccessToken(params: RevokeAccessTokenParams): Promise; /** * Create a new Telegraph page * * @param params - Page creation parameters * @returns Page object * * @example * ```typescript * // Using HTML string * const page = await telegraph.createPage({ * accessToken: 'your-access-token', * title: 'My First Page', * content: '

Hello world!

', * authorName: 'John Doe', * returnContent: true * }); * * // Using Node array * const page2 = await telegraph.createPage({ * accessToken: 'your-access-token', * title: 'My Second Page', * content: [ * { tag: 'p', children: ['Hello ', { tag: 'b', children: ['world'] }, '!'] } * ] * }); * * console.log(page.url); * ``` */ createPage(params: CreatePageParams): Promise; /** * Edit an existing Telegraph page * * @param params - Page edit parameters * @returns Updated Page object * * @example * ```typescript * const page = await telegraph.editPage({ * accessToken: 'your-access-token', * path: 'Sample-Page-12-15', * title: 'Updated Title', * content: '

Updated content

', * returnContent: true * }); * ``` */ editPage(params: EditPageParams): Promise; /** * Get a Telegraph page * * @param params - Page retrieval parameters * @returns Page object * * @example * ```typescript * const page = await telegraph.getPage({ * path: 'Sample-Page-12-15', * returnContent: true * }); * console.log(page.title); * console.log(page.content); * ``` */ getPage(params: GetPageParams): Promise; /** * Get a list of pages belonging to a Telegraph account * * @param params - Page list request parameters * @returns PageList object * * @example * ```typescript * const pageList = await telegraph.getPageList({ * accessToken: 'your-access-token', * offset: 0, * limit: 10 * }); * console.log(`Total pages: ${pageList.total_count}`); * pageList.pages.forEach(page => { * console.log(`- ${page.title}: ${page.url}`); * }); * ``` */ getPageList(params: GetPageListParams): Promise; /** * Get the number of views for a Telegraph page * * @param params - Views request parameters * @returns PageViews object * * @example * ```typescript * // Get total views * const views = await telegraph.getViews({ * path: 'Sample-Page-12-15' * }); * console.log(`Total views: ${views.views}`); * * // Get views for a specific date * const dailyViews = await telegraph.getViews({ * path: 'Sample-Page-12-15', * year: 2023, * month: 12, * day: 15 * }); * console.log(`Views on Dec 15, 2023: ${dailyViews.views}`); * ``` */ getViews(params: GetViewsParams): Promise; } //# sourceMappingURL=client.d.ts.map