2021-08-12 15:04:37 +02:00
|
|
|
import { Knex } from 'knex';
|
2021-04-22 10:07:10 +02:00
|
|
|
import { IUnleashConfig } from '../types/option';
|
|
|
|
import { IUnleashStores } from '../types/stores';
|
2021-03-11 22:51:58 +01:00
|
|
|
|
2021-04-27 09:16:44 +02:00
|
|
|
import EventStore from './event-store';
|
|
|
|
import FeatureToggleStore from './feature-toggle-store';
|
|
|
|
import FeatureTypeStore from './feature-type-store';
|
|
|
|
import StrategyStore from './strategy-store';
|
|
|
|
import ClientInstanceStore from './client-instance-store';
|
|
|
|
import ClientApplicationsStore from './client-applications-store';
|
|
|
|
import ContextFieldStore from './context-field-store';
|
|
|
|
import SettingStore from './setting-store';
|
|
|
|
import UserStore from './user-store';
|
|
|
|
import ProjectStore from './project-store';
|
|
|
|
import TagStore from './tag-store';
|
|
|
|
import TagTypeStore from './tag-type-store';
|
|
|
|
import AddonStore from './addon-store';
|
|
|
|
import { ApiTokenStore } from './api-token-store';
|
|
|
|
import SessionStore from './session-store';
|
|
|
|
import { AccessStore } from './access-store';
|
|
|
|
import { ResetTokenStore } from './reset-token-store';
|
2021-06-07 11:11:42 +02:00
|
|
|
import UserFeedbackStore from './user-feedback-store';
|
2021-07-07 10:46:50 +02:00
|
|
|
import FeatureStrategyStore from './feature-strategy-store';
|
2021-09-13 10:23:57 +02:00
|
|
|
import FeatureToggleClientStore from './feature-toggle-client-store';
|
2021-07-07 10:46:50 +02:00
|
|
|
import EnvironmentStore from './environment-store';
|
|
|
|
import FeatureTagStore from './feature-tag-store';
|
2021-08-12 15:04:37 +02:00
|
|
|
import { FeatureEnvironmentStore } from './feature-environment-store';
|
2021-10-08 10:09:22 +02:00
|
|
|
import { ClientMetricsStoreV2 } from './client-metrics-store-v2';
|
2021-11-09 11:52:02 +01:00
|
|
|
import UserSplashStore from './user-splash-store';
|
2022-01-13 11:14:17 +01:00
|
|
|
import RoleStore from './role-store';
|
2022-03-29 14:59:14 +02:00
|
|
|
import SegmentStore from './segment-store';
|
2022-07-21 16:23:56 +02:00
|
|
|
import GroupStore from './group-store';
|
2022-09-16 09:54:27 +02:00
|
|
|
import PatStore from './pat-store';
|
2022-09-14 14:29:12 +02:00
|
|
|
import { PublicSignupTokenStore } from './public-signup-token-store';
|
2022-10-24 19:07:29 +02:00
|
|
|
import { SuggestChangeStore } from './suggest-change-store';
|
2016-11-04 09:03:13 +01:00
|
|
|
|
2021-04-22 10:07:10 +02:00
|
|
|
export const createStores = (
|
|
|
|
config: IUnleashConfig,
|
2021-08-12 15:04:37 +02:00
|
|
|
db: Knex,
|
2021-04-22 10:07:10 +02:00
|
|
|
): IUnleashStores => {
|
2021-12-09 21:02:58 +01:00
|
|
|
const { getLogger, eventBus } = config;
|
2019-04-30 21:14:23 +02:00
|
|
|
const eventStore = new EventStore(db, getLogger);
|
2016-11-05 10:16:48 +01:00
|
|
|
|
|
|
|
return {
|
|
|
|
eventStore,
|
2021-01-18 12:32:19 +01:00
|
|
|
featureToggleStore: new FeatureToggleStore(db, eventBus, getLogger),
|
2020-08-06 11:18:52 +02:00
|
|
|
featureTypeStore: new FeatureTypeStore(db, getLogger),
|
2021-01-18 12:32:19 +01:00
|
|
|
strategyStore: new StrategyStore(db, getLogger),
|
2021-08-12 15:04:37 +02:00
|
|
|
clientApplicationsStore: new ClientApplicationsStore(
|
|
|
|
db,
|
|
|
|
eventBus,
|
|
|
|
getLogger,
|
|
|
|
),
|
2019-08-04 11:10:51 +02:00
|
|
|
clientInstanceStore: new ClientInstanceStore(db, eventBus, getLogger),
|
2021-10-08 10:09:22 +02:00
|
|
|
clientMetricsStoreV2: new ClientMetricsStoreV2(db, getLogger),
|
2021-04-22 10:07:10 +02:00
|
|
|
contextFieldStore: new ContextFieldStore(db, getLogger),
|
2020-04-13 22:38:46 +02:00
|
|
|
settingStore: new SettingStore(db, getLogger),
|
2020-05-12 23:05:26 +02:00
|
|
|
userStore: new UserStore(db, getLogger),
|
2022-02-21 12:46:28 +01:00
|
|
|
projectStore: new ProjectStore(db, eventBus, getLogger),
|
2021-01-18 12:32:19 +01:00
|
|
|
tagStore: new TagStore(db, eventBus, getLogger),
|
|
|
|
tagTypeStore: new TagTypeStore(db, eventBus, getLogger),
|
2021-01-19 10:42:45 +01:00
|
|
|
addonStore: new AddonStore(db, eventBus, getLogger),
|
2022-08-26 08:22:42 +02:00
|
|
|
accessStore: new AccessStore(db, eventBus, getLogger),
|
2021-03-29 19:58:11 +02:00
|
|
|
apiTokenStore: new ApiTokenStore(db, eventBus, getLogger),
|
2021-04-16 15:29:23 +02:00
|
|
|
resetTokenStore: new ResetTokenStore(db, eventBus, getLogger),
|
2021-04-27 09:16:44 +02:00
|
|
|
sessionStore: new SessionStore(db, eventBus, getLogger),
|
2021-06-07 11:11:42 +02:00
|
|
|
userFeedbackStore: new UserFeedbackStore(db, eventBus, getLogger),
|
2021-07-07 10:46:50 +02:00
|
|
|
featureStrategiesStore: new FeatureStrategyStore(
|
|
|
|
db,
|
|
|
|
eventBus,
|
|
|
|
getLogger,
|
|
|
|
),
|
2021-09-13 10:23:57 +02:00
|
|
|
featureToggleClientStore: new FeatureToggleClientStore(
|
|
|
|
db,
|
|
|
|
eventBus,
|
|
|
|
getLogger,
|
2022-06-02 10:44:45 +02:00
|
|
|
config.inlineSegmentConstraints,
|
2021-09-13 10:23:57 +02:00
|
|
|
),
|
2021-07-07 10:46:50 +02:00
|
|
|
environmentStore: new EnvironmentStore(db, eventBus, getLogger),
|
|
|
|
featureTagStore: new FeatureTagStore(db, eventBus, getLogger),
|
2021-08-12 15:04:37 +02:00
|
|
|
featureEnvironmentStore: new FeatureEnvironmentStore(
|
|
|
|
db,
|
|
|
|
eventBus,
|
|
|
|
getLogger,
|
|
|
|
),
|
2021-11-09 11:52:02 +01:00
|
|
|
userSplashStore: new UserSplashStore(db, eventBus, getLogger),
|
2022-01-13 11:14:17 +01:00
|
|
|
roleStore: new RoleStore(db, eventBus, getLogger),
|
2022-03-29 14:59:14 +02:00
|
|
|
segmentStore: new SegmentStore(db, eventBus, getLogger),
|
2022-07-21 16:23:56 +02:00
|
|
|
groupStore: new GroupStore(db),
|
2022-09-14 14:29:12 +02:00
|
|
|
publicSignupTokenStore: new PublicSignupTokenStore(
|
|
|
|
db,
|
|
|
|
eventBus,
|
|
|
|
getLogger,
|
|
|
|
),
|
2022-09-16 09:54:27 +02:00
|
|
|
patStore: new PatStore(db, getLogger),
|
2022-10-24 19:07:29 +02:00
|
|
|
suggestChangeStore: new SuggestChangeStore(db, eventBus, getLogger),
|
2016-11-05 10:16:48 +01:00
|
|
|
};
|
|
|
|
};
|
2021-04-22 10:07:10 +02:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
createStores,
|
|
|
|
};
|