import{deepStrictEqual as o}from"node:assert";import{DatabaseConnectionFactory as i}from"./database-connection-factory.js";class h{#t;#e;#n;constructor(e){this.#n=e}async get(e){const n=a(e);return this.#t&&!s(this.#e,n)?this.#t:(this.#t=await this.#n(n),this.#e=n,this.#t)}}async function u(t,e,n){const r=await i.create(t);if(!r)throw new Error(`Failed to create db connection for ${e} repository`);return new n(r)}function a(t){return{...t,removeExisting:t.removeExisting??!1}}function s(t,e){if(!t)return!1;try{return o(t,e),!1}catch{return!0}}export{h as InstanceCacheResolver,u as createDatabaseRepositoryInstance};
