import { Knex } from 'knex'; export type KnexTransaction = Knex.Transaction; export type MockTransaction = null; export type UnleashTransaction = KnexTransaction | MockTransaction; export type TransactionCreator = ( scope: (trx: S) => void | Promise, ) => Promise; export const createKnexTransactionStarter = ( knex: Knex, ): TransactionCreator => { function transaction( scope: (trx: KnexTransaction) => void | Promise, ) { return knex.transaction(scope); } return transaction; };