@telegram-apps/sdk
Version:
TypeScript Source Development Kit for Telegram Mini Apps client application.
100 lines (99 loc) • 4.38 kB
TypeScript
import { AbortablePromise } from 'better-promises';
import { InvokeCustomMethodOptions } from '@telegram-apps/bridge';
/**
* Signal indicating if the Cloud Storage is supported.
*/
export declare const isSupported: import('@telegram-apps/signals').Computed<boolean>;
/**
* Deletes specified key or keys from the cloud storage.
* @param keyOrKeys - key or keys to delete.
* @param options - request execution options.
* @since Mini Apps v6.9
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @example Deleting a single key
* if (deleteItem.isAvailable()) {
* await deleteItem('my-key');
* }
* @example Deleting multiple keys
* if (deleteItem.isAvailable()) {
* await deleteItem(['key1', 'key2']);
* }
*/
export declare const deleteItem: import('../../wrappers/wrapSafe.js').SafeWrapped<(keyOrKeys: string | string[], options?: InvokeCustomMethodOptions) => AbortablePromise<void>, true, never>;
/**
* Gets multiple keys' values from the cloud storage.
* @param keys - keys list.
* @param options - request execution options.
* @returns Map, where a key is one of the specified in the `keys` argument,
* and a value is a corresponding storage value.
* @since Mini Apps v6.9
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @example
* if (deleteItem.isAvailable()) {
* const { key1, key2 } = await getItem(['key1', 'key2']);
* }
*/
declare function _getItem<K extends string>(keys: K[], options?: InvokeCustomMethodOptions): AbortablePromise<Record<K, string>>;
/**
* Gets a single key value from the cloud storage.
* @param key - cloud storage key.
* @param options - request execution options.
* @return Value of the specified key. If the key was not created previously,
* the function will return an empty string.
* @since Mini Apps v6.9
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @example
* if (getItem.isAvailable()) {
* const keyValue = await getItem('my-key');
* }
*/
declare function _getItem(key: string, options?: InvokeCustomMethodOptions): AbortablePromise<string>;
export declare const getItem: import('../../wrappers/wrapSafe.js').SafeWrapped<typeof _getItem, true, never>;
/**
* Returns a list of all keys presented in the cloud storage.
* @param options - request execution options.
* @since Mini Apps v6.9
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @example
* if (getKeys.isAvailable()) {
* const keysArray = await getKeys();
* }
*/
export declare const getKeys: import('../../wrappers/wrapSafe.js').SafeWrapped<(options?: InvokeCustomMethodOptions) => AbortablePromise<string[]>, true, never>;
/**
* Saves the specified value by a key.
* @param key - storage key.
* @param value - storage value.
* @param options - request execution options.
* @since Mini Apps v6.9
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @example
* if (setItem.isAvailable()) {
* await setItem('key', 'value');
* }
*/
export declare const setItem: import('../../wrappers/wrapSafe.js').SafeWrapped<(key: string, value: string, options?: InvokeCustomMethodOptions) => AbortablePromise<void>, true, never>;
/**
* Clears the cloud storage.
* @param options - additional options.
* @since Mini Apps v6.9
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @example
* if (clear.isAvailable()) {
* await clear();
* }
*/
export declare const clear: import('../../wrappers/wrapSafe.js').SafeWrapped<(options?: InvokeCustomMethodOptions) => AbortablePromise<void>, true, never>;
export {};