import { DataStoreLevel, EventEmitterWakePublisher, MessageStoreLevel, ResumableTaskStoreLevel } from '../src/index.js';
/**
 * Class that manages store implementations for testing.
 * This is intended to be extended as the single point of configuration
 * that allows different store implementations to be swapped in
 * to test compatibility with default/built-in store implementations.
 */
export class TestStores {
    static messageStore;
    static dataStore;
    static resumableTaskStore;
    static wakePublisher;
    /**
     * Overrides test stores with given implementation.
     * If not given, default implementation will be used.
     */
    static override(overrides) {
        TestStores.wakePublisher ??= new EventEmitterWakePublisher();
        TestStores.messageStore = overrides?.messageStore;
        TestStores.dataStore = overrides?.dataStore;
        TestStores.resumableTaskStore = overrides?.resumableTaskStore;
        if (TestStores.messageStore !== undefined) {
            TestStores.setWakePublisherIfSupported(TestStores.messageStore, TestStores.wakePublisher);
        }
    }
    /**
     * Initializes and return the stores used for running the test suite.
     */
    static get() {
        TestStores.wakePublisher ??= new EventEmitterWakePublisher();
        TestStores.messageStore ??= new MessageStoreLevel({
            location: 'TEST-MESSAGESTORE',
            wakePublisher: TestStores.wakePublisher,
        });
        TestStores.dataStore ??= new DataStoreLevel({
            blockstoreLocation: 'TEST-DATASTORE'
        });
        TestStores.resumableTaskStore ??= new ResumableTaskStoreLevel({
            location: 'TEST-RESUMABLE-TASK-STORE'
        });
        return {
            messageStore: TestStores.messageStore,
            dataStore: TestStores.dataStore,
            resumableTaskStore: TestStores.resumableTaskStore,
        };
    }
    static getWakePublisher() {
        TestStores.wakePublisher ??= new EventEmitterWakePublisher();
        return TestStores.wakePublisher;
    }
    static setWakePublisherIfSupported(store, wakePublisher) {
        const maybeStore = store;
        if (typeof maybeStore.setWakePublisher === 'function') {
            maybeStore.setWakePublisher(wakePublisher);
        }
    }
}
//# sourceMappingURL=test-stores.js.map