/**
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
* Copyright (C) 2023-2026 Roj
*
* This file is part of MTKruto.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import { type MaybePromise } from "../1_utilities.js";
import { type Storage, type StorageKeyPart } from "../2_storage.js";
import { Api } from "../2_tl.js";
import type { DC } from "../3_transport.js";
import { type ChatP, type Translation, type VoiceTranscription } from "../3_types.js";
export declare const K: {
session: {
P: (string: string) => string;
serverSalt: () => StorageKeyPart[];
};
auth: {
P: (string: string) => string;
isPremium: () => StorageKeyPart[];
};
updates: {
P: (string: string) => string;
state: () => StorageKeyPart[];
all: () => StorageKeyPart[];
updates: (boxId: bigint) => StorageKeyPart[];
update: (boxId: bigint, id: bigint) => StorageKeyPart[];
};
cache: {
P: (string: string) => string;
stickerSetNames: () => StorageKeyPart[];
stickerSetName: (id: bigint, accessHash: bigint) => StorageKeyPart[];
files: () => StorageKeyPart[];
file: (fileId: bigint) => StorageKeyPart[];
fileParts: () => StorageKeyPart[];
filePart: (fileId: bigint, n: number) => StorageKeyPart[];
customEmojiDocuments: () => StorageKeyPart[];
customEmojiDocument: (id: bigint) => StorageKeyPart[];
businessConnections: () => StorageKeyPart[];
businessConnection: (id: string) => StorageKeyPart[];
inlineQueryAnswers: () => StorageKeyPart[];
inlineQueryAnswer: (userId: number, chatId: number, query: string, offset: string) => StorageKeyPart[];
callbackQueryAnswers: () => StorageKeyPart[];
callbackQueryAnswer: (chatId: number, messageId: number, question: string) => StorageKeyPart[];
fullChats: () => StorageKeyPart[];
fullChat: (chatId: number) => StorageKeyPart[];
groupCalls: () => StorageKeyPart[];
groupCall: (id: bigint) => StorageKeyPart[];
groupCallAccessHashes: () => StorageKeyPart[];
groupCallAccessHash: (id: bigint) => StorageKeyPart[];
pollResults: () => string[];
pollResult: (pollId: bigint) => (string | bigint)[];
polls: () => string[];
poll: (pollId: bigint) => (string | bigint)[];
voiceTranscriptions: () => string[];
voiceTranscription: (transcriptionId: bigint) => (string | bigint)[];
voiceTranscriptionReferences: () => string[];
voiceTranscriptionReference: (chatId: number, messageId: number, messageEditDate: number) => (string | number)[];
};
messages: {
P: (string: string) => string;
messages: (chatId: number) => StorageKeyPart[];
message: (chatId: number, messageId: number) => StorageKeyPart[];
allMessageRefs: () => StorageKeyPart[];
messageRef: (messageId: number) => StorageKeyPart[];
};
};
export declare class StorageOperations {
#private;
auth: StorageAuth;
channelPts: StorageMap<[bigint], number>;
peers: StorageMap<[number], [ChatP, bigint]>;
usernames: StorageMap<[string], [number, Date]>;
phoneNumbers: StorageMap<[string], [number, Date]>;
translations: StorageMap<[string, string], {
version: number;
translations: Translation[];
date: Date;
}>;
constructor(storage: Storage);
get provider(): Storage;
get supportsFiles(): boolean;
initialize(): Promise;
set(...args: Parameters): ReturnType;
incr(...args: Parameters): ReturnType;
get(...args: Parameters): ReturnType;
exportAuthString(apiId_?: number | null): Promise;
importAuthString(string: string): Promise;
commit(force?: boolean): Promise;
setTlObject(key: readonly StorageKeyPart[], value: Api.AnyType | null): Promise;
getTlObject(keyOrBuffer: Api.AnyType | Uint8Array | readonly StorageKeyPart[]): Promise;
setState(state: Api.updates_State): Promise;
getState(): Promise;
setMessage(chatId: number, messageId: number, message: Api.Message | null): Promise;
deleteMessages(): Promise;
getMessageChat(messageId: number): MaybePromise;
getMessage(chatId: number, messageId: number): Promise;
setPeer(peer_: Api.user | Api.chat | Api.chatForbidden | Api.channel | Api.channelForbidden): void;
setPeer2(chatP: ChatP, accessHash: bigint): void;
getAccountId(): Promise;
setIsPremium(isPremium: boolean): Promise;
getIsPremium(): Promise;
updateStickerSetName(id: bigint, accessHash: bigint, name: string): Promise;
getStickerSetName(id: bigint, accessHash: bigint): MaybePromise<[string, Date] | null>;
setServerSalt(serverSalt: bigint): Promise;
getServerSalt(): MaybePromise;
getHistory(chatId: number, offsetId: number, limit: number): Promise;
getFile(id: bigint): Promise<[number, number] | null>;
iterFileParts(id: bigint, partCount: number, offset: number, signal: AbortSignal | undefined): AsyncGenerator;
saveFilePart(id: bigint, index: number, bytes: Uint8Array): Promise;
setFilePartCount(id: bigint, partCount: number, chunkSize: number): Promise;
setCustomEmojiDocument(id: bigint, document: Api.document): Promise;
getCustomEmojiDocument(id: bigint): Promise<[Api.document, Date] | null>;
setBusinessConnection(id: string, connection: Api.botBusinessConnection | null): Promise;
getBusinessConnection(id: string): Promise;
setInlineQueryAnswer(userId: number, chatId: number, query: string, offset: string, results: Api.messages_botResults, date: Date): Promise;
getInlineQueryAnswer(userId: number, chatId: number, query: string, offset: string): Promise<[Api.messages_botResults, Date] | null>;
setCallbackQueryAnswer(chatId: number, messageId: number, question: string, answer: Api.messages_botCallbackAnswer): Promise;
getCallbackQueryAnswer(chatId: number, messageId: number, question: string): Promise<[Api.messages_botCallbackAnswer, Date] | null>;
setFullChat(chatId: number, fullChat: Api.userFull | Api.channelFull | Api.chatFull | null): Promise;
getFullChat(chatId: number): Promise;
setGroupCall(id: bigint, groupCall: Api.groupCall | null): Promise;
getGroupCall(id: bigint): Promise;
setGroupCallAccessHash(id: bigint, accessHash: bigint | null): Promise;
getGroupCallAccessHash(id: bigint): Promise;
setUpdate(boxId: bigint, update: Api.Update): Promise;
deleteUpdates(): Promise;
getFirstUpdate(boxId: bigint): Promise<[readonly StorageKeyPart[], Api.Update] | null>;
assertUser(source: string): void;
assertBot(source: string): void;
get isBot(): boolean;
getChannelAccessHash(id: number): Promise;
getUserAccessHash(id: number): Promise;
deleteFiles(): Promise;
deleteCustomEmojiDocuments(): Promise;
deleteBusinessConnections(): Promise;
deleteInlineQueryAnswers(): Promise;
deleteCallbackQueryAnswers(): Promise;
deleteFullChats(): Promise;
deleteGroupCalls(): Promise;
deleteStickerSetNames(): Promise;
clear(): Promise;
reset(): Promise;
setPollResults(pollId: bigint, pollResults: Api.pollResults): Promise;
getPollResults(pollId: bigint): Promise;
deletePollResults(): Promise;
setPoll(pollId: bigint, poll: Api.poll): Promise;
getPoll(pollId: bigint): Promise;
deletePolls(): Promise;
setVoiceTranscription(voiceTranscription: VoiceTranscription): Promise;
getVoiceTranscription(transcriptionId: bigint): Promise;
deleteVoiceTranscriptions(): Promise;
setVoiceTranscriptionReference(chatId: number, messageId: number, messageEditDate: Date, transcriptionId: bigint): Promise;
getVoiceTranscriptionReference(chatId: number, messageId: number, messageEditDate: Date): Promise;
deleteVoiceTranscriptionReferences(): Promise;
}
declare class StorageMap {
#private;
constructor(storage: Storage, path: StorageKeyPart);
set(key: K, value: V): void;
get pendingUpdateCount(): number;
mustGet(key: K): (V & {}) | null;
clear(): Promise;
get(key: K): Promise;
commit(): Promise;
}
declare class StorageValue {
#private;
constructor(storage: Storage, path: StorageKeyPart);
set(value: T | null): void;
get isUpdatePending(): boolean;
mustGet(): T | null;
get(): Promise;
commit(): Promise;
}
interface Auth {
apiId: number;
authKey: Uint8Array | null;
dc: DC | null;
isBot: boolean;
userId: number;
}
declare class StorageAuth extends StorageValue {
#private;
constructor(storage: Storage);
get(): Promise;
mustGet(): Auth;
set(auth: Auth | null): Promise;
update(fn: (auth: Auth) => void): Promise;
get authKeyId(): bigint | null;
}
export {};
//# sourceMappingURL=0_storage_operations.d.ts.map