import type { MachinatChannel, MachinatUser } from '../types'; export interface StateAccessor { /** * Fetch the value of a specific key. Return `undefined` if no value is * stored. */ get(key: string): Promise; /** * Store the value on a specific key. Return `true` if the old value is * updated, `false` if it's newly stored on the key. */ set(key: string, value: T): Promise; /** * Update the value of a specific key by an undator funcction. The updator * receives the original value (`undefined` if not existed) and return the new * value. Depends on the new value, 3 kinds of action will be executed: * - `undefined`; delete the data on the key. * - original value (compared with `===`); no changes. * - any other value; the new value will be stored. */ update(key: string, updator: (state: undefined | T) => T): Promise; update(key: string, updator: (state: undefined | T) => undefined | T): Promise; delete(key: string): Promise; keys(): Promise; getAll(): Promise>; clear(): Promise; } /** * @category Base */ export interface BaseStateController { /** * Return the {@link StateAccessor} of a channel */ channelState( /** The channel object or uid of the channel */ channel: string | MachinatChannel): StateAccessor; /** * Return the {@link StateAccessor} of a user */ userState( /** The user object or uid of the user */ user: string | MachinatUser): StateAccessor; /** * Return the {@link StateAccessor} of a global name */ globalState(name: string): StateAccessor; } declare const StateControllerI: import("../service").SingularServiceInterface; declare type StateControllerI = BaseStateController; export default StateControllerI;