"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createFakeFeatureLifecycleService = exports.createFeatureLifecycleService = void 0;
const fake_event_store_1 = __importDefault(require("../../../test/fixtures/fake-event-store"));
const fake_feature_lifecycle_store_1 = require("./fake-feature-lifecycle-store");
const feature_lifecycle_service_1 = require("./feature-lifecycle-service");
const fake_environment_store_1 = __importDefault(require("../project-environments/fake-environment-store"));
const event_store_1 = __importDefault(require("../../db/event-store"));
const feature_lifecycle_store_1 = require("./feature-lifecycle-store");
const environment_store_1 = __importDefault(require("../project-environments/environment-store"));
const event_service_1 = __importDefault(require("../events/event-service"));
const fake_feature_tag_store_1 = __importDefault(require("../../../test/fixtures/fake-feature-tag-store"));
const feature_tag_store_1 = __importDefault(require("../../db/feature-tag-store"));
const feature_environment_store_1 = require("../../db/feature-environment-store");
const fake_feature_environment_store_1 = __importDefault(require("../../../test/fixtures/fake-feature-environment-store"));
const events_1 = __importDefault(require("events"));
const createFeatureLifecycleService = (db, config) => {
    const { eventBus, getLogger, flagResolver } = config;
    const eventStore = new event_store_1.default(db, getLogger);
    const featureLifecycleStore = new feature_lifecycle_store_1.FeatureLifecycleStore(db);
    const environmentStore = new environment_store_1.default(db, eventBus, getLogger);
    const featureEnvironmentStore = new feature_environment_store_1.FeatureEnvironmentStore(db, eventBus, getLogger);
    const featureTagStore = new feature_tag_store_1.default(db, config.eventBus, config.getLogger);
    const eventService = new event_service_1.default({ eventStore, featureTagStore }, { getLogger, eventBus: new events_1.default() });
    const featureLifecycleService = new feature_lifecycle_service_1.FeatureLifecycleService({
        eventStore,
        featureLifecycleStore,
        environmentStore,
        featureEnvironmentStore,
    }, {
        eventService,
    }, config);
    return {
        featureLifecycleService,
        featureLifecycleStore,
        eventStore,
        environmentStore,
    };
};
exports.createFeatureLifecycleService = createFeatureLifecycleService;
const createFakeFeatureLifecycleService = (config) => {
    const eventStore = new fake_event_store_1.default();
    const featureLifecycleStore = new fake_feature_lifecycle_store_1.FakeFeatureLifecycleStore();
    const environmentStore = new fake_environment_store_1.default();
    const featureEnvironmentStore = new fake_feature_environment_store_1.default();
    const eventService = new event_service_1.default({ eventStore, featureTagStore: new fake_feature_tag_store_1.default() }, config);
    const featureLifecycleService = new feature_lifecycle_service_1.FeatureLifecycleService({
        eventStore,
        featureLifecycleStore,
        environmentStore,
        featureEnvironmentStore,
    }, {
        eventService,
    }, config);
    return {
        featureLifecycleService,
        featureLifecycleStore,
        eventStore,
        environmentStore,
        featureEnvironmentStore,
    };
};
exports.createFakeFeatureLifecycleService = createFakeFeatureLifecycleService;
//# sourceMappingURL=createFeatureLifecycle.js.map