import { UserKeyDefinition, UserKeyDefinitionOptions } from "../../../platform/state";
// eslint-disable-next-line -- `StateDefinition` used as an argument
import { StateDefinition } from "../../../platform/state/state-definition";
/** A set of options for customizing the behavior of a {@link BufferedKeyDefinition}
*/
export type BufferedKeyDefinitionOptions =
UserKeyDefinitionOptions & {
/** Checks whether the input type can be converted to the output type.
* @param input the data that is rolling over.
* @returns `true` if the definition is valid, otherwise `false`. If this
* function is not specified, any truthy input is valid.
*
* @remarks this is intended for cases where you're working with validated or
* signed data. It should be used to prevent data from being "laundered" through
* synchronized state.
*/
isValid?: (input: Input, dependency: Dependency) => Promise;
/** Transforms the input data format to its output format.
* @param input the data that is rolling over.
* @returns the converted value. If this function is not specified, the value
* is asserted as the output type.
*
* @remarks This is intended for converting between, say, a replication format
* and a disk format or rotating encryption keys.
*/
map?: (input: Input, dependency: Dependency) => Promise