1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-11-01 19:07:38 +01:00
unleash.unleash/src/lib/db/index.ts
andreas-unleash 85631b9951
Add suggest-change-store.ts and db migration (#2201)
* Add suggest-change-store.ts and db migration

* Add suggest-change-store.ts and db migration

* change payload and event data type

* Update src/lib/db/suggest-change-store.ts

Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>

* split to 3 tables, create event on every change

* split to 3 tables, create event on every change

* Move service to enterprise
PR Comments

* PR Comments

* replacy createdBy string with User

* replace createdBy string with User

* added event to docs

* return entire changeset after adding a change

* bug fix

* bug fix

* move add change return to service layer

* PR comments

* added user id to user objects

* added user id to user objects

* added user id to user objects

* bug fix

* Rework

* Remove event and fix queries

* Update snapshot

* Remove console logs

* Fix

Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
Co-authored-by: sjaanus <sellinjaanus@gmail.com>
2022-10-24 20:07:29 +03:00

103 lines
4.2 KiB
TypeScript

import { Knex } from 'knex';
import { IUnleashConfig } from '../types/option';
import { IUnleashStores } from '../types/stores';
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';
import UserFeedbackStore from './user-feedback-store';
import FeatureStrategyStore from './feature-strategy-store';
import FeatureToggleClientStore from './feature-toggle-client-store';
import EnvironmentStore from './environment-store';
import FeatureTagStore from './feature-tag-store';
import { FeatureEnvironmentStore } from './feature-environment-store';
import { ClientMetricsStoreV2 } from './client-metrics-store-v2';
import UserSplashStore from './user-splash-store';
import RoleStore from './role-store';
import SegmentStore from './segment-store';
import GroupStore from './group-store';
import PatStore from './pat-store';
import { PublicSignupTokenStore } from './public-signup-token-store';
import { SuggestChangeStore } from './suggest-change-store';
export const createStores = (
config: IUnleashConfig,
db: Knex,
): IUnleashStores => {
const { getLogger, eventBus } = config;
const eventStore = new EventStore(db, getLogger);
return {
eventStore,
featureToggleStore: new FeatureToggleStore(db, eventBus, getLogger),
featureTypeStore: new FeatureTypeStore(db, getLogger),
strategyStore: new StrategyStore(db, getLogger),
clientApplicationsStore: new ClientApplicationsStore(
db,
eventBus,
getLogger,
),
clientInstanceStore: new ClientInstanceStore(db, eventBus, getLogger),
clientMetricsStoreV2: new ClientMetricsStoreV2(db, getLogger),
contextFieldStore: new ContextFieldStore(db, getLogger),
settingStore: new SettingStore(db, getLogger),
userStore: new UserStore(db, getLogger),
projectStore: new ProjectStore(db, eventBus, getLogger),
tagStore: new TagStore(db, eventBus, getLogger),
tagTypeStore: new TagTypeStore(db, eventBus, getLogger),
addonStore: new AddonStore(db, eventBus, getLogger),
accessStore: new AccessStore(db, eventBus, getLogger),
apiTokenStore: new ApiTokenStore(db, eventBus, getLogger),
resetTokenStore: new ResetTokenStore(db, eventBus, getLogger),
sessionStore: new SessionStore(db, eventBus, getLogger),
userFeedbackStore: new UserFeedbackStore(db, eventBus, getLogger),
featureStrategiesStore: new FeatureStrategyStore(
db,
eventBus,
getLogger,
),
featureToggleClientStore: new FeatureToggleClientStore(
db,
eventBus,
getLogger,
config.inlineSegmentConstraints,
),
environmentStore: new EnvironmentStore(db, eventBus, getLogger),
featureTagStore: new FeatureTagStore(db, eventBus, getLogger),
featureEnvironmentStore: new FeatureEnvironmentStore(
db,
eventBus,
getLogger,
),
userSplashStore: new UserSplashStore(db, eventBus, getLogger),
roleStore: new RoleStore(db, eventBus, getLogger),
segmentStore: new SegmentStore(db, eventBus, getLogger),
groupStore: new GroupStore(db),
publicSignupTokenStore: new PublicSignupTokenStore(
db,
eventBus,
getLogger,
),
patStore: new PatStore(db, getLogger),
suggestChangeStore: new SuggestChangeStore(db, eventBus, getLogger),
};
};
module.exports = {
createStores,
};