import { ISession } from '../../session/ISession.js'; import { IState } from './IState.js'; import { EXPIRE_OPTION } from './enums/expireOption.js'; import { CreateIndexOptions } from './contracts/fullText/createIndexOptions.js'; import { SearchOptions } from './enums/fullText/searchOptions.js'; /** * Represents a state object that can be used to store and retrieve data. * @class */ export declare class State implements IState { /** * The namespace for the state object. */ namespace: string; /** * The URL of the state object. */ private url; /** * The bridge for the state object. */ private bridge; /** * The session for the state object. */ private session; /** * The provider for the state object. */ private provider; /** * Creates a new State. * @constructor * @param {ISession} session - The session for the state object. * @param {string} namespace - The namespace for the state object. */ constructor(session: ISession, namespace?: string); /** * Creates a new state command. * @param {string} op - The operation for the command. * @param {string} key - The key for the command. * @param {string[]} args - The arguments for the command. * @returns {StateCommand} The new state command. */ private createCommand; /** * Executes a state command. * @param {IStateCommand} command - The state command to execute. * @returns {Promise} The result of the command. */ private executeCommand; /** * Sets the value for a key in the state object. * @param {string} key - The key to set. * @param {T} value - The value to set for the key. * @returns {Promise} A promise that resolves to "OK" if the operation was successful. */ set(key: string, value: T): Promise; /** * Retrieves the value for a key in the state object. * @param {string} key - The key to retrieve. * @returns {Promise} A promise that resolves to the value for the key. */ get(key: string): Promise; /** * Deletes a key from the state object. * @param {string} key - The key to delete. * @returns {Promise} A promise that resolves to "1" if the key was deleted, or "0" if the key did not exist. */ delete(key: string): Promise; /** * Increments the value of a key in the state object by a specified amount. * @param {string} key - The key to increment. * @param {number} value - The amount to increment the key by. * @returns {Promise} A promise that resolves to the new value of the key. */ increment(key: string, value: number): Promise; /** * Decrements the value of a key in the state object by a specified amount. * @param {string} key - The key to decrement. * @param {number} value - The amount to decrement the key by. * @returns {Promise} A promise that resolves to the new value of the key. */ decrement(key: string, value: number): Promise; /** * Sets an expiration time for a key in the state object. * @param {string} key - The key to set the expiration time for. * @param {number} seconds - The number of seconds after which the key will expire. * @param {EXPIRE_OPTION} [option] - An optional object specifying additional options for the operation. * @returns {Promise} A promise that resolves to "1" if the operation was successful, or "0" if the key does not exist. */ expire(key: string, seconds: number, option?: EXPIRE_OPTION): Promise; /** * Deletes a key from a hash table in the state object. * @param {string} htable - The name of the hash table. * @param {string[]} keys - The keys to delete from the hash table. * @returns {Promise} A promise that resolves to "1" if the key was deleted, or "0" if the key did not exist. */ mapDelete(htable: string, keys: string[]): Promise; /** * Determines whether a key exists in a hash table in the state object. * @param {string} htable - The name of the hash table. * @param {string} key - The key to check for in the hash table. * @returns {Promise} A promise that resolves to "1" if the key exists, or "0" if the key does not exist. */ mapExists(htable: string, key: string): Promise; /** * Retrieves all keys and values from a hash table in the state object. * @param {string} htable - The name of the hash table. * @returns {Promise>} A promise that resolves to an object containing the keys and values from the hash table. */ mapGetAll(htable: string): Promise>; /** * Retrieves multiple values from a hash table in the state object. * @param {string} htable - The name of the hash table. * @param {string[]} keys - The keys to retrieve from the hash table. * @returns {Promise} A promise that resolves to an array of values for the specified keys. */ mapGetMultiple(htable: string, keys: string[]): Promise; /** * Retrieves all values from a hash table in the state object. * @param {string} htable - The name of the hash table. * @returns {Promise} A promise that resolves to an array of values from the hash table. */ mapGetValues(htable: string): Promise; /** * Retrieves the value for a key in a hash table in the state object. * @param {string} htable - The name of the hash table. * @param {string} key - The key to retrieve from the hash table. * @returns {Promise} A promise that resolves to the value for the key in the hash table. */ mapGetValue(htable: string, key: string): Promise; /** * Sets multiple key-value pairs in a hash table in the state object. * @param {string} htable - The name of the hash table. * @param {Record} keyValuePairs - An object containing the key-value pairs to set in the hash table. * @returns {Promise} A promise that resolves to the number of fields that were added. */ mapSet(htable: string, keyValuePairs: Record): Promise; /** * Increments the value for a key in a hash table in the state object. * @param {string} htable The name of the hash table. * @param {string} key The key to increment. * @param {number} value The amount to increment the key by. * @returns {Promise} A promise that resolves to the new value for the key. */ mapIncrement(htable: string, key: string, value: number): Promise; /** * Retrieves the number of key-value pairs in a hash table in the state object. * @param {string} htable - The name of the hash table. * @returns {Promise} A promise that resolves to the number of key-value pairs in the hash table. */ mapLength(htable: string): Promise; /** * * @param htable Name of the hash table * @param cursor An integer representing the cursor's position. It starts at 0 and should be set to the cursor returned by the previous call to continue the iteration. * @param pattern A pattern to filter the results * @param count A hint for the number of elements to be returned. It doesn't guarantee the exact number of elements to be returned, but it should be greater than 0. * @returns */ mapScan(htable: string, cursor: string, pattern?: string, count?: number): Promise<[string, string[]]>; /** * Adds a value to the end of a list in the state object. * @param {string} list - The name of the list. * @param {T} value - The value to add to the list. * @returns {Promise} A promise that resolves to the new length of the list. */ listAppend(list: string, value: T): Promise; /** * Removes and retrieves one or more values from the end of a list in the state object. * @param {string} list - The name of the list. * @param {number} count - The number of values to remove and retrieve from the end of the list. * @returns {Promise} A promise that resolves to an array of values removed from the end of the list. */ listEndPop(list: string, count?: number): Promise; /** * Adds a value to the beginning of a list in the state object. * @param {string} list - The name of the list. * @param {T} value - The value to add to the list. * @returns {Promise} A promise that resolves to the new length of the list. */ listPrepend(list: string, value: T): Promise; /** * Removes and retrieves one or more values from the beginning of a list in the state object. * @param {string} list - The name of the list. * @param {number} count - The number of values to remove and retrieve from the beginning of the list. Default is 1. * @returns {Promise} A promise that resolves to an array of values removed from the beginning of the list. */ listStartPop(list: string, count?: number): Promise; /** * Removes one or more occurrences of a value from a list in the state object. * @param {string} list - The name of the list. * @param {T} value - The value to remove from the list. * @param {number} count - The number of occurrences to remove. A positive number removes the first `count` occurrences, a negative number removes the last `count` occurrences, and a value of 0 removes all occurrences. * @returns {Promise} A promise that resolves to the number of occurrences removed from the list. */ listRemove(list: string, value: T, count?: number): Promise; /** * Retrieves the length of a list in the state object. * @param {string} list - The name of the list. * @returns {Promise} A promise that resolves to the length of the list. */ listLength(list: string): Promise; /** * Retrieves a range of values from a list in the state object. * @param {string} list - The name of the list. * @param {number} startPos - The starting position of the range. * @param {number} endPos - The ending position of the range. * @returns {Promise} A promise that resolves to an array of values from the specified range in the list. */ listRange(list: string, startPos?: number, endPos?: number): Promise; /** * Trims a list in the state object to contain only the specified range of values. * @param {string} list - The name of the list. * @param {number} startPos - The starting position of the range. * @param {number} endPos - The ending position of the range. * @returns {Promise} A promise that resolves to "OK" if the operation was successful. */ listTrim(list: string, startPos: number, endPos: number): Promise; /** * Inserts a value into a list in the state object either before or after a pivot value. * @param {string} list - The name of the list. * @param {boolean} before - If `true`, the value is inserted before the pivot value. If `false`, the value is inserted after the pivot value. * @param {T} pivot - The pivot value. * @param {T} value - The value to insert into the list. * @returns {Promise} A promise that resolves to the new length of the list if the operation was successful. */ listInsert(list: string, before: boolean, pivot: T, value: T): Promise; /** * Retrieves the value at a specific position in a list in the state object. * @param {string} list - The name of the list. * @param {number} position - The position of the value to retrieve. * @returns {Promise} A promise that resolves to the value at the specified position in the list. */ listIndex(list: string, position: number): Promise; /** * Sets the value at a specific position in a list in the state object. * @param {string} list - The name of the list. * @param {number} position - The position of the value to set. * @param {T} value - The value to set at the specified position in the list. * @returns {Promise} A promise that resolves to "OK" if the operation was successful. */ listSet(list: string, position: number, value: T): Promise; createIndex(name: string, options: CreateIndexOptions): Promise; search(index: string, query: string, options?: SearchOptions): Promise; dropIndex(index: string, deleteDocs?: boolean): Promise; private parseResponse; } //# sourceMappingURL=state.d.ts.map