import { Awaitable , Storage , StorageListOptions , StorageListResult , StoredKeyMeta , StoredValueMeta , } from "@miniflare/shared" ; export type StorageEvent = { type : "has" ; key : string ; } | { type : "get" ; key : string ; } | { type : "put" ; key : string ; } | { type : "delete" ; key : string ; } | { type : "list" ; } | { type : "hasMany" ; keys : string [ ] ; } | { type : "getMany" ; keys : string [ ] ; } | { type : "putMany" ; keys : string [ ] ; } | { type : "deleteMany" ; keys : string [ ] ; } ; export class RecorderStorage extends Storage { events : StorageEvent [ ] = [ ] ; constructor ( private readonly inner ) { super ( ) ; } has ( key ) { this . events . push ( { type : "has" , key } ) ; return this . inner . has ( key ) ; } get < Meta = unknown > ( key , skipMetadata ? ) { this . events . push ( { type : "get" , key } ) ; return this . inner . get ( key , skipMetadata as any ) ; } put < Meta = unknown > ( key , value ) { this . events . push ( { type : "put" , key } ) ; return this . inner . put ( key , value ) ; } delete ( key ) { this . events . push ( { type : "delete" , key } ) ; return this . inner . delete ( key ) ; } list < Meta = unknown > ( options ? , skipMetadata ? ) { this . events . push ( { type : "list" } ) ; return this . inner . list ( options , skipMetadata as any ) ; } async hasMany ( keys ) { this . events . push ( { type : "hasMany" , keys } ) ; return this . inner . hasMany ( keys ) ; } getMany < Meta = unknown > ( keys , skipMetadata ? ) { this . events . push ( { type : "getMany" , keys } ) ; return this . inner . getMany ( keys , skipMetadata as any ) ; } async putMany < Meta = unknown > ( data ) { this . events . push ( { type : "putMany" , keys : data . map ( ( [ name ] ) => name ) } ) ; return this . inner . putMany ( data ) ; } async deleteMany ( keys ) { this . events . push ( { type : "deleteMany" , keys } ) ; return this . inner . deleteMany ( keys ) ; } }