/** * Options provided to the scan function * @typedef {Object} ScanOptions * @public * @property {string} type - Limits the keys returned to those of a specified type (e.g., string, list, set, hash, json, zset or stream). * @property {integer} count - A hint to the server about how many elements to return in the call (default is 10). */ /** * State object * @typedef {Object} RedisState * @property data - the result returned from Redis * @property references - an array of all previous data objects used in the Job * @private **/ /** * Execute a sequence of operations. * Wraps `language-common/execute`, creates and disconnect client * @private * @param {Operations} operations - Operations to be performed. * @returns {Operation} */ export function execute(...operations: Operations): Operation; /** * Get the string value of a key. * If the key does not exist, null is returned. * An error is thrown if the value stored at key is not a string, because `get()` only handles string values. * @example Get the value of the patient key * get("patient"); * @function * @public * @param {string} key - The name of the key * @state {RedisState} * @returns {Operation} */ export function get(key: string): Operation; /** * Get the value associated with a specific field in a hash stored at a specified key. * @example Get the value of the name field under the patient key * hget("patient", "name"); * @function * @public * @param {string} key - The name of the key * @param {string} field - Field * @state {RedisState} * @returns {Operation} */ export function hget(key: string, field: string): Operation; /** * Get the value at a specified path in a JSON document stored in a key * @example Get JSON document value of the patient key * jGet("patient"); * @function * @public * @param {string} key - The key at which the JSON document is stored. * @state {RedisState} * @returns {Operation} */ export function jGet(key: string): Operation; /** * Get the values at specified paths in JSON documents stored at multiple keys. * @example Get JSON document values of the patient and doctor keys * mGet(["patient", "doctor"]); * @function * @public * @param {string[]} keys - The keys at which the JSON documents are stored. * @state {RedisState} * @returns {Operation} */ export function mGet(keys: string[]): Operation; /** * Get all fields and values of a hash, as an object, for a specified key. * @example Get the hash obejct at the noderedis:animals:1 key * hGetAll("noderedis:animals:1"); * @function * @public * @param {string} key - The name of the key * @state {RedisState} * @state data - The hash as an object * @returns {Operation} */ export function hGetAll(key: string): Operation; /** * Set the string value of a key. * If the key already exists, its value is updated. Otherwise, a new key-value pair is created. * @example Set the "patient" key to value "mtuchi" * set("patient", "mtuchi"); * @function * @public * @param {string} key - The name of the key * @param {string} value - The value to set * @state references - an array of all previous data objects used in the Job * @returns {Operation} */ export function set(key: string, value: string): Operation; /** * Sets the specified fields to their respective values in the hash stored at key. * This function overwrites the values of specified fields that exist in the hash. * If key doesn't exist, a new key holding a hash is created. * @example Set a field and value for the `patient` key * hset('patient', { name: 'mtuchi' }); * @example Set multiple field values for the `patient` key * hset('patient', { name: 'victor', ihs_number: 12345 }); * @function * @public * @param {string} key - The name of the key * @param {object} value - The values to set * @state references - an array of all previous data objects used in the Job * @returns {Operation} */ export function hset(key: string, value: object): Operation; /** * Creates a JSON object at the specified key. If the key already exists, the * existing value will be replaced by the new value. * @example Set a JSON object for the key `patient` * jSet('patient', { name: 'victor', ihs_number: 12345 }); * @function * @public * @param {string} key - The key to modify. * @param {(string|object)} value - The JSON object or string value to set. * @state references - an array of all previous data objects used in the Job * @returns {Operation} */ export function jSet(key: string, value: (string | object)): Operation; /** * Set values at the root path ('$') in JSON documents stored at multiple keys. * This function allows setting multiple key-value pairs in Redis JSON documents in a single operation. * If a key already exists, its value will be replaced. If it does not exist, a new key-value pair will be created. * @example Set multiple JSON objects * mSet([{ key: 'patient', value: { name: 'victor', ihs_number: 12345 } }, * { key: 'doctor', value: { name: 'Alice', specialization: 'cardiology' } }]); * @function * @public * @param {Array<{ key: string, value: (string|object) }>} entries - * An array of key-value pairs to set in the JSON store. * @state references - an array of all previous data objects used in the Job * @returns {Operation} */ export function mSet(entries: Array<{ key: string; value: (string | object); }>): Operation; /** * Returns all keys which match the provided pattern. * scan iterates the whole database to find the matching keys * @example Scan for matching keys * scan('*:20240524T172736Z*'); * @example Scan for keys and fetch the string values inside * scan('*:20240524T172736Z*'); * each($.data, get($.data).then((state) => { * state.results ??= []; * state.results.push(state.data) * return state; * }) * @function * @public * @param {string} pattern - A glob-style pattern * @param {ScanOptions} options - Scan options * @state {RedisState} * @state data - an array of keys which match the pattern * @returns {Operation} */ export function scan(pattern: string, options?: ScanOptions): Operation; export function setMockClient(fakeClient: any): any; /** * Options provided to the scan function */ export type ScanOptions = any; /** * State object */ export type RedisState = { /** * - the result returned from Redis */ data: any; /** * - an array of all previous data objects used in the Job */ references: any; }; export { dataPath, dataValue, dateFns, cursor, each, field, fields, fn, fnIf, lastReferenceValue, merge, sourceValue } from "@openfn/language-common";