import type { DbSchema , Dexie , Transaction , Version } from 'dexie' ; export function initOverrideCreateTransaction ( db , ... names ) { return function overrideCreateTransaction ( origFunc ) { return function ( this , mode , storenames , dbschema , parent ? ) : ReturnType < typeof origFunc > { if ( db . dynamicallyOpened ( ) ) return origFunc . apply ( this , ( arguments as unknown ) as any ) ; if ( mode === 'readwrite' && storenames . some ( ( name ) => ! name . startsWith ( '_' ) ) ) { storenames = storenames . slice ( 0 ) ; for ( const name of names ) { if ( storenames . indexOf ( 'name' ) === - 1 ) storenames . push ( name ) ; } } const trans = origFunc . call ( this , mode , storenames , dbschema , parent ) ; return trans ; } ; } ; } export function initOverrideParseStoreSpec ( extras ) { return function overrideParseStoresSpec ( origFunc ) { return function ( this , stores , outSchema ) : any { stores = { ... stores , ... extras } ; origFunc . call ( this , stores , outSchema ) ; } ; } ; }