import type { ChatId, Message } from "node-telegram-bot-api"; import type { Question, ContextFn } from './questions'; import { Buttons, ButtonsList } from './buttons'; import { Config } from './config'; import { type I18nFn } from './i18n'; interface Meta { msgId: Message['message_id']; chatId: ChatId; } declare type KeysOfUnion = T extends T ? keyof T : never; declare type Params = Exclude, 'type' | 'name' | 'format' | 'validate'>; declare type ParamType = U extends U ? T extends keyof U ? U[T] : never : never; declare type ParamReturn = T extends ContextFn ? R : T; declare type ParamFn = (name: T) => Promise>>; export interface StateData { question: { name: Question['name']; type: Question['type']; param: ParamFn; }; context: Context; meta?: Meta; buttons?: Buttons; store?: unknown; setMeta: (meta: Meta) => void; setButtons: (buttons: ButtonsList) => void; setContext: (name: string, value: T) => void; setStore: (value: T) => void; startTimeout: (fn?: () => void) => void; restartTimeout: (fn?: () => void) => void; stopTimeout: () => void; validate: (value: unknown) => Promise; format: (value: unknown) => Promise; i18n: I18nFn; options: Config; destroy: () => void; } export declare type Context = Record; export declare type OnFinishFn = (context: Context) => void | Promise; export declare class State { private state; /** Add new item in state */ add(id: ChatId, questions: Question[], fn: OnFinishFn, options: Config): void; /** Delete item from state */ delete(id: ChatId): void; /** Does item in list */ has(id: ChatId): boolean; /** Get current question */ get(id: ChatId): StateData | null; /** Move to the next question*/ next(id: ChatId): StateData | null; /** finish a session */ finish(id: ChatId): Promise; } export {};