import { AbstractIteratorOptions , AbstractLevelDOWN , AbstractOpenOptions , } from 'abstract-leveldown' ; import { RangeBucket , RangeEntry } from './range-db.interface' ; export type K = NonNullable < Buffer > ; export type V = NonNullable < Buffer > ; export interface KV { key : K ; value : V ; } export const PUT_BATCH_TYPE = 'put' ; export const DEL_BATCH_TYPE = 'del' ; export type Batch = PutBatch | DelBatch ; export interface PutBatch { readonly type : 'put' ; readonly key : K ; readonly value : V ; } export interface DelBatch { readonly type : 'del' ; readonly key : K ; } /**
 * KeyValueStore represents a basic collection of key:value pairs.
 */ export interface KeyValueStore { param key returns get ( key ) : Promise < V > ; param key param value put ( key , value ) : Promise < void > ; param key del ( key ) : Promise < void > ; param key returns has ( key ) : Promise < boolean > ; param operations batch ( operations ) : Promise < void > ; param options returns iterator ( options ? ) : Iterator ; param prefix returns bucket ( prefix ) : Bucket ; param prefix returns rangeBucket ( prefix ) : RangeBucket ; } /**
 * Represents a key:value store.
 */ export interface DB extends KeyValueStore { readonly db : AbstractLevelDOWN ; param options open ( options ? ) : Promise < void > ; /**
     * Closes the store.
     */ close ( ) : Promise < void > ; } /**
 * Bucket are effectively databases that only perform operations
 * on keys that share a common `prefix`.
 */ export interface Bucket extends KeyValueStore { readonly db : DB ; readonly prefix : K ; } export interface IteratorOptions extends AbstractIteratorOptions { gte ? : K ; lte ? : K ; gt ? : K ; lt ? : K ; reverse ? : boolean ; limit ? : number ; keys ? : boolean ; values ? : boolean ; keyAsBuffer ? : boolean ; valueAsBuffer ? : boolean ; prefix ? : Buffer ; } /**
 * Iterators traverse over ranges of keys.
 * Iterators operate on a *snapshot* of the store
 * and not on the store itself. As a result,
 * the iterator is not impacted by writes
 * made after the iterator was created.
 */ export interface Iterator { readonly db : DB ; returns next ( ) : Promise < { key : K ; value : V ; } > ; param target seek ( target ) : Promise < void > ; param cb each ( cb ) : Promise < void > ; returns items ( ) : Promise < KV [ ] > ; returns keys ( ) : Promise < K [ ] > ; returns values ( ) : Promise < V [ ] > ; /**
     * Ends iteration and frees resources.
     */ end ( ) : Promise < void > ; } export interface RangeIterator extends Iterator { nextRange ( ) : Promise < RangeEntry > ; }