mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-09 01:17:06 +02:00
feat: start using event service composition root (#7871)
During adding privateProjectsChecker, I saw that events composition root is not used almost at all. Refactored code so we do not call new EventService anymore.
This commit is contained in:
parent
94605646f6
commit
627768b96c
@ -4,16 +4,18 @@ import { AccountStore } from '../../db/account-store';
|
|||||||
import RoleStore from '../../db/role-store';
|
import RoleStore from '../../db/role-store';
|
||||||
import EnvironmentStore from '../project-environments/environment-store';
|
import EnvironmentStore from '../project-environments/environment-store';
|
||||||
import { AccessStore } from '../../db/access-store';
|
import { AccessStore } from '../../db/access-store';
|
||||||
import { AccessService, EventService, GroupService } from '../../services';
|
import { AccessService, GroupService } from '../../services';
|
||||||
import FakeGroupStore from '../../../test/fixtures/fake-group-store';
|
import FakeGroupStore from '../../../test/fixtures/fake-group-store';
|
||||||
import FakeEventStore from '../../../test/fixtures/fake-event-store';
|
import FakeEventStore from '../../../test/fixtures/fake-event-store';
|
||||||
import { FakeAccountStore } from '../../../test/fixtures/fake-account-store';
|
import { FakeAccountStore } from '../../../test/fixtures/fake-account-store';
|
||||||
import FakeRoleStore from '../../../test/fixtures/fake-role-store';
|
import FakeRoleStore from '../../../test/fixtures/fake-role-store';
|
||||||
import FakeEnvironmentStore from '../project-environments/fake-environment-store';
|
import FakeEnvironmentStore from '../project-environments/fake-environment-store';
|
||||||
import FakeAccessStore from '../../../test/fixtures/fake-access-store';
|
import FakeAccessStore from '../../../test/fixtures/fake-access-store';
|
||||||
import FakeFeatureTagStore from '../../../test/fixtures/fake-feature-tag-store';
|
|
||||||
import type { IAccessStore, IEventStore, IRoleStore } from '../../types';
|
import type { IAccessStore, IEventStore, IRoleStore } from '../../types';
|
||||||
import { createEventsService } from '../events/createEventsService';
|
import {
|
||||||
|
createEventsService,
|
||||||
|
createFakeEventsService,
|
||||||
|
} from '../events/createEventsService';
|
||||||
|
|
||||||
export const createAccessService = (
|
export const createAccessService = (
|
||||||
db: Db,
|
db: Db,
|
||||||
@ -48,18 +50,14 @@ export const createFakeAccessService = (
|
|||||||
accessStore: IAccessStore;
|
accessStore: IAccessStore;
|
||||||
roleStore: IRoleStore;
|
roleStore: IRoleStore;
|
||||||
} => {
|
} => {
|
||||||
const { getLogger, flagResolver } = config;
|
const { getLogger } = config;
|
||||||
const eventStore = new FakeEventStore();
|
const eventStore = new FakeEventStore();
|
||||||
const groupStore = new FakeGroupStore();
|
const groupStore = new FakeGroupStore();
|
||||||
const accountStore = new FakeAccountStore();
|
const accountStore = new FakeAccountStore();
|
||||||
const roleStore = new FakeRoleStore();
|
const roleStore = new FakeRoleStore();
|
||||||
const environmentStore = new FakeEnvironmentStore();
|
const environmentStore = new FakeEnvironmentStore();
|
||||||
const accessStore = new FakeAccessStore(roleStore);
|
const accessStore = new FakeAccessStore(roleStore);
|
||||||
const featureTagStore = new FakeFeatureTagStore();
|
const eventService = createFakeEventsService(config, { eventStore });
|
||||||
const eventService = new EventService(
|
|
||||||
{ eventStore, featureTagStore },
|
|
||||||
config,
|
|
||||||
);
|
|
||||||
const groupService = new GroupService(
|
const groupService = new GroupService(
|
||||||
{ groupStore, accountStore },
|
{ groupStore, accountStore },
|
||||||
{ getLogger },
|
{ getLogger },
|
||||||
|
@ -4,7 +4,15 @@ import type { Db } from '../../db/db';
|
|||||||
import EventStore from './event-store';
|
import EventStore from './event-store';
|
||||||
import FeatureTagStore from '../../db/feature-tag-store';
|
import FeatureTagStore from '../../db/feature-tag-store';
|
||||||
import { EventService } from '../../services';
|
import { EventService } from '../../services';
|
||||||
import type { IUnleashConfig } from '../../types';
|
import type {
|
||||||
|
IEventStore,
|
||||||
|
IFeatureTagStore,
|
||||||
|
IUnleashConfig,
|
||||||
|
} from '../../types';
|
||||||
|
import {
|
||||||
|
createFakePrivateProjectChecker,
|
||||||
|
createPrivateProjectChecker,
|
||||||
|
} from '../private-project/createPrivateProjectChecker';
|
||||||
|
|
||||||
export const createEventsService: (
|
export const createEventsService: (
|
||||||
db: Db,
|
db: Db,
|
||||||
@ -16,12 +24,28 @@ export const createEventsService: (
|
|||||||
config.eventBus,
|
config.eventBus,
|
||||||
config.getLogger,
|
config.getLogger,
|
||||||
);
|
);
|
||||||
return new EventService({ eventStore, featureTagStore }, config);
|
const privateProjectChecker = createPrivateProjectChecker(db, config);
|
||||||
|
return new EventService(
|
||||||
|
{ eventStore, featureTagStore },
|
||||||
|
config,
|
||||||
|
privateProjectChecker,
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createFakeEventsService: (config: IUnleashConfig) => EventService =
|
export const createFakeEventsService: (
|
||||||
(config) => {
|
config: IUnleashConfig,
|
||||||
const eventStore = new FakeEventStore();
|
stores?: {
|
||||||
const featureTagStore = new FakeFeatureTagStore();
|
eventStore?: IEventStore;
|
||||||
return new EventService({ eventStore, featureTagStore }, config);
|
featureTagStore?: IFeatureTagStore;
|
||||||
};
|
},
|
||||||
|
) => EventService = (config, stores) => {
|
||||||
|
const eventStore = stores?.eventStore || new FakeEventStore();
|
||||||
|
const featureTagStore =
|
||||||
|
stores?.featureTagStore || new FakeFeatureTagStore();
|
||||||
|
const fakePrivateProjectChecker = createFakePrivateProjectChecker();
|
||||||
|
return new EventService(
|
||||||
|
{ eventStore, featureTagStore },
|
||||||
|
config,
|
||||||
|
fakePrivateProjectChecker,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
@ -2,11 +2,15 @@ import EventStore from './event-store';
|
|||||||
import getLogger from '../../../test/fixtures/no-logger';
|
import getLogger from '../../../test/fixtures/no-logger';
|
||||||
import dbInit, { type ITestDb } from '../../../test/e2e/helpers/database-init';
|
import dbInit, { type ITestDb } from '../../../test/e2e/helpers/database-init';
|
||||||
import { EventEmitter } from 'stream';
|
import { EventEmitter } from 'stream';
|
||||||
import EventService from './event-service';
|
|
||||||
import { EVENTS_CREATED_BY_PROCESSED } from '../../metric-events';
|
import { EVENTS_CREATED_BY_PROCESSED } from '../../metric-events';
|
||||||
|
import type { IUnleashConfig } from '../../types';
|
||||||
|
import { createTestConfig } from '../../../test/config/test-config';
|
||||||
|
import EventService from './event-service';
|
||||||
|
|
||||||
let db: ITestDb;
|
let db: ITestDb;
|
||||||
|
|
||||||
|
const config: IUnleashConfig = createTestConfig();
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
db = await dbInit('events_test', getLogger);
|
db = await dbInit('events_test', getLogger);
|
||||||
});
|
});
|
||||||
@ -125,6 +129,7 @@ test('emits events with details on amount of updated rows', async () => {
|
|||||||
const service = new EventService(
|
const service = new EventService(
|
||||||
{ eventStore: store, featureTagStore: db.stores.featureTagStore },
|
{ eventStore: store, featureTagStore: db.stores.featureTagStore },
|
||||||
{ getLogger, eventBus },
|
{ getLogger, eventBus },
|
||||||
|
{} as any,
|
||||||
);
|
);
|
||||||
let triggered = false;
|
let triggered = false;
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import { EVENTS_CREATED_BY_PROCESSED } from '../../metric-events';
|
|||||||
import type { IQueryParam } from '../feature-toggle/types/feature-toggle-strategies-store-type';
|
import type { IQueryParam } from '../feature-toggle/types/feature-toggle-strategies-store-type';
|
||||||
import { parseSearchOperatorValue } from '../feature-search/search-utils';
|
import { parseSearchOperatorValue } from '../feature-search/search-utils';
|
||||||
import { endOfDay, formatISO } from 'date-fns';
|
import { endOfDay, formatISO } from 'date-fns';
|
||||||
|
import type { IPrivateProjectChecker } from '../private-project/privateProjectCheckerType';
|
||||||
|
|
||||||
export default class EventService {
|
export default class EventService {
|
||||||
private logger: Logger;
|
private logger: Logger;
|
||||||
@ -22,6 +23,8 @@ export default class EventService {
|
|||||||
|
|
||||||
private featureTagStore: IFeatureTagStore;
|
private featureTagStore: IFeatureTagStore;
|
||||||
|
|
||||||
|
private privateProjectChecker: IPrivateProjectChecker;
|
||||||
|
|
||||||
private eventBus: EventEmitter;
|
private eventBus: EventEmitter;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -30,9 +33,11 @@ export default class EventService {
|
|||||||
featureTagStore,
|
featureTagStore,
|
||||||
}: Pick<IUnleashStores, 'eventStore' | 'featureTagStore'>,
|
}: Pick<IUnleashStores, 'eventStore' | 'featureTagStore'>,
|
||||||
{ getLogger, eventBus }: Pick<IUnleashConfig, 'getLogger' | 'eventBus'>,
|
{ getLogger, eventBus }: Pick<IUnleashConfig, 'getLogger' | 'eventBus'>,
|
||||||
|
privateProjectChecker: IPrivateProjectChecker,
|
||||||
) {
|
) {
|
||||||
this.logger = getLogger('services/event-service.ts');
|
this.logger = getLogger('services/event-service.ts');
|
||||||
this.eventStore = eventStore;
|
this.eventStore = eventStore;
|
||||||
|
this.privateProjectChecker = privateProjectChecker;
|
||||||
this.featureTagStore = featureTagStore;
|
this.featureTagStore = featureTagStore;
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import ContextFieldStore from '../../db/context-field-store';
|
|||||||
import FeatureStrategiesStore from '../feature-toggle/feature-toggle-strategies-store';
|
import FeatureStrategiesStore from '../feature-toggle/feature-toggle-strategies-store';
|
||||||
import {
|
import {
|
||||||
ContextService,
|
ContextService,
|
||||||
EventService,
|
|
||||||
FeatureTagService,
|
FeatureTagService,
|
||||||
StrategyService,
|
StrategyService,
|
||||||
TagTypeService,
|
TagTypeService,
|
||||||
@ -32,7 +31,6 @@ import FakeTagTypeStore from '../tag-type/fake-tag-type-store';
|
|||||||
import FakeProjectStore from '../../../test/fixtures/fake-project-store';
|
import FakeProjectStore from '../../../test/fixtures/fake-project-store';
|
||||||
import FakeFeatureTagStore from '../../../test/fixtures/fake-feature-tag-store';
|
import FakeFeatureTagStore from '../../../test/fixtures/fake-feature-tag-store';
|
||||||
import FakeContextFieldStore from '../../../test/fixtures/fake-context-field-store';
|
import FakeContextFieldStore from '../../../test/fixtures/fake-context-field-store';
|
||||||
import FakeEventStore from '../../../test/fixtures/fake-event-store';
|
|
||||||
import FakeFeatureStrategiesStore from '../feature-toggle/fakes/fake-feature-strategies-store';
|
import FakeFeatureStrategiesStore from '../feature-toggle/fakes/fake-feature-strategies-store';
|
||||||
import FakeFeatureEnvironmentStore from '../../../test/fixtures/fake-feature-environment-store';
|
import FakeFeatureEnvironmentStore from '../../../test/fixtures/fake-feature-environment-store';
|
||||||
import FakeStrategiesStore from '../../../test/fixtures/fake-strategies-store';
|
import FakeStrategiesStore from '../../../test/fixtures/fake-strategies-store';
|
||||||
@ -48,7 +46,10 @@ import {
|
|||||||
createDependentFeaturesService,
|
createDependentFeaturesService,
|
||||||
createFakeDependentFeaturesService,
|
createFakeDependentFeaturesService,
|
||||||
} from '../dependent-features/createDependentFeaturesService';
|
} from '../dependent-features/createDependentFeaturesService';
|
||||||
import { createEventsService } from '../events/createEventsService';
|
import {
|
||||||
|
createEventsService,
|
||||||
|
createFakeEventsService,
|
||||||
|
} from '../events/createEventsService';
|
||||||
import { SegmentReadModel } from '../segment/segment-read-model';
|
import { SegmentReadModel } from '../segment/segment-read-model';
|
||||||
import { FakeSegmentReadModel } from '../segment/fake-segment-read-model';
|
import { FakeSegmentReadModel } from '../segment/fake-segment-read-model';
|
||||||
|
|
||||||
@ -64,20 +65,13 @@ export const createFakeExportImportTogglesService = (
|
|||||||
const featureTagStore = new FakeFeatureTagStore();
|
const featureTagStore = new FakeFeatureTagStore();
|
||||||
const strategyStore = new FakeStrategiesStore();
|
const strategyStore = new FakeStrategiesStore();
|
||||||
const contextFieldStore = new FakeContextFieldStore();
|
const contextFieldStore = new FakeContextFieldStore();
|
||||||
const eventStore = new FakeEventStore();
|
|
||||||
const featureStrategiesStore = new FakeFeatureStrategiesStore();
|
const featureStrategiesStore = new FakeFeatureStrategiesStore();
|
||||||
const featureEnvironmentStore = new FakeFeatureEnvironmentStore();
|
const featureEnvironmentStore = new FakeFeatureEnvironmentStore();
|
||||||
const { accessService } = createFakeAccessService(config);
|
const { accessService } = createFakeAccessService(config);
|
||||||
const { featureToggleService } = createFakeFeatureToggleService(config);
|
const { featureToggleService } = createFakeFeatureToggleService(config);
|
||||||
const privateProjectChecker = createFakePrivateProjectChecker();
|
const privateProjectChecker = createFakePrivateProjectChecker();
|
||||||
|
|
||||||
const eventService = new EventService(
|
const eventService = createFakeEventsService(config);
|
||||||
{
|
|
||||||
eventStore,
|
|
||||||
featureTagStore,
|
|
||||||
},
|
|
||||||
config,
|
|
||||||
);
|
|
||||||
|
|
||||||
const featureTagService = new FeatureTagService(
|
const featureTagService = new FeatureTagService(
|
||||||
{
|
{
|
||||||
|
@ -7,16 +7,16 @@ import EventStore from '../../db/event-store';
|
|||||||
import type { Db } from '../../db/db';
|
import type { Db } from '../../db/db';
|
||||||
import { FeatureLifecycleStore } from './feature-lifecycle-store';
|
import { FeatureLifecycleStore } from './feature-lifecycle-store';
|
||||||
import EnvironmentStore from '../project-environments/environment-store';
|
import EnvironmentStore from '../project-environments/environment-store';
|
||||||
import EventService from '../events/event-service';
|
|
||||||
import FakeFeatureTagStore from '../../../test/fixtures/fake-feature-tag-store';
|
|
||||||
import FeatureTagStore from '../../db/feature-tag-store';
|
|
||||||
import { FeatureEnvironmentStore } from '../../db/feature-environment-store';
|
import { FeatureEnvironmentStore } from '../../db/feature-environment-store';
|
||||||
import FakeFeatureEnvironmentStore from '../../../test/fixtures/fake-feature-environment-store';
|
import FakeFeatureEnvironmentStore from '../../../test/fixtures/fake-feature-environment-store';
|
||||||
import EventEmitter from 'events';
|
import {
|
||||||
|
createEventsService,
|
||||||
|
createFakeEventsService,
|
||||||
|
} from '../events/createEventsService';
|
||||||
|
|
||||||
export const createFeatureLifecycleService =
|
export const createFeatureLifecycleService =
|
||||||
(config: IUnleashConfig) => (db: Db) => {
|
(config: IUnleashConfig) => (db: Db) => {
|
||||||
const { eventBus, getLogger, flagResolver } = config;
|
const { eventBus, getLogger } = config;
|
||||||
const eventStore = new EventStore(db, getLogger);
|
const eventStore = new EventStore(db, getLogger);
|
||||||
const featureLifecycleStore = new FeatureLifecycleStore(db);
|
const featureLifecycleStore = new FeatureLifecycleStore(db);
|
||||||
const environmentStore = new EnvironmentStore(db, eventBus, getLogger);
|
const environmentStore = new EnvironmentStore(db, eventBus, getLogger);
|
||||||
@ -25,15 +25,7 @@ export const createFeatureLifecycleService =
|
|||||||
eventBus,
|
eventBus,
|
||||||
getLogger,
|
getLogger,
|
||||||
);
|
);
|
||||||
const featureTagStore = new FeatureTagStore(
|
const eventService = createEventsService(db, config);
|
||||||
db,
|
|
||||||
config.eventBus,
|
|
||||||
config.getLogger,
|
|
||||||
);
|
|
||||||
const eventService = new EventService(
|
|
||||||
{ eventStore, featureTagStore },
|
|
||||||
{ getLogger, eventBus: new EventEmitter() },
|
|
||||||
);
|
|
||||||
const featureLifecycleService = new FeatureLifecycleService(
|
const featureLifecycleService = new FeatureLifecycleService(
|
||||||
{
|
{
|
||||||
eventStore,
|
eventStore,
|
||||||
@ -55,10 +47,7 @@ export const createFakeFeatureLifecycleService = (config: IUnleashConfig) => {
|
|||||||
const featureLifecycleStore = new FakeFeatureLifecycleStore();
|
const featureLifecycleStore = new FakeFeatureLifecycleStore();
|
||||||
const environmentStore = new FakeEnvironmentStore();
|
const environmentStore = new FakeEnvironmentStore();
|
||||||
const featureEnvironmentStore = new FakeFeatureEnvironmentStore();
|
const featureEnvironmentStore = new FakeFeatureEnvironmentStore();
|
||||||
const eventService = new EventService(
|
const eventService = createFakeEventsService(config);
|
||||||
{ eventStore, featureTagStore: new FakeFeatureTagStore() },
|
|
||||||
config,
|
|
||||||
);
|
|
||||||
const featureLifecycleService = new FeatureLifecycleService(
|
const featureLifecycleService = new FeatureLifecycleService(
|
||||||
{
|
{
|
||||||
eventStore,
|
eventStore,
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
AccessService,
|
AccessService,
|
||||||
EventService,
|
|
||||||
FeatureToggleService,
|
FeatureToggleService,
|
||||||
GroupService,
|
GroupService,
|
||||||
} from '../../services';
|
} from '../../services';
|
||||||
@ -51,7 +50,10 @@ import {
|
|||||||
createDependentFeaturesService,
|
createDependentFeaturesService,
|
||||||
createFakeDependentFeaturesService,
|
createFakeDependentFeaturesService,
|
||||||
} from '../dependent-features/createDependentFeaturesService';
|
} from '../dependent-features/createDependentFeaturesService';
|
||||||
import { createEventsService } from '../events/createEventsService';
|
import {
|
||||||
|
createEventsService,
|
||||||
|
createFakeEventsService,
|
||||||
|
} from '../events/createEventsService';
|
||||||
import { EventEmitter } from 'stream';
|
import { EventEmitter } from 'stream';
|
||||||
import { FeatureLifecycleReadModel } from '../feature-lifecycle/feature-lifecycle-read-model';
|
import { FeatureLifecycleReadModel } from '../feature-lifecycle/feature-lifecycle-read-model';
|
||||||
import { FakeFeatureLifecycleReadModel } from '../feature-lifecycle/fake-feature-lifecycle-read-model';
|
import { FakeFeatureLifecycleReadModel } from '../feature-lifecycle/fake-feature-lifecycle-read-model';
|
||||||
@ -176,10 +178,7 @@ export const createFakeFeatureToggleService = (config: IUnleashConfig) => {
|
|||||||
const featureTagStore = new FakeFeatureTagStore();
|
const featureTagStore = new FakeFeatureTagStore();
|
||||||
const roleStore = new FakeRoleStore();
|
const roleStore = new FakeRoleStore();
|
||||||
const environmentStore = new FakeEnvironmentStore();
|
const environmentStore = new FakeEnvironmentStore();
|
||||||
const eventService = new EventService(
|
const eventService = createFakeEventsService(config);
|
||||||
{ eventStore, featureTagStore },
|
|
||||||
{ getLogger, eventBus: new EventEmitter() },
|
|
||||||
);
|
|
||||||
const groupService = new GroupService(
|
const groupService = new GroupService(
|
||||||
{ groupStore, accountStore },
|
{ groupStore, accountStore },
|
||||||
{ getLogger },
|
{ getLogger },
|
||||||
|
@ -23,9 +23,13 @@ import {
|
|||||||
PermissionError,
|
PermissionError,
|
||||||
} from '../../../error';
|
} from '../../../error';
|
||||||
import type { ISegmentService } from '../../segment/segment-service-interface';
|
import type { ISegmentService } from '../../segment/segment-service-interface';
|
||||||
import { createFeatureToggleService, createSegmentService } from '../..';
|
import {
|
||||||
|
createEventsService,
|
||||||
|
createFeatureToggleService,
|
||||||
|
createSegmentService,
|
||||||
|
} from '../..';
|
||||||
import { insertLastSeenAt } from '../../../../test/e2e/helpers/test-helper';
|
import { insertLastSeenAt } from '../../../../test/e2e/helpers/test-helper';
|
||||||
import { EventService } from '../../../services';
|
import type { EventService } from '../../../services';
|
||||||
|
|
||||||
let stores: IUnleashStores;
|
let stores: IUnleashStores;
|
||||||
let db: ITestDb;
|
let db: ITestDb;
|
||||||
@ -60,7 +64,7 @@ beforeAll(async () => {
|
|||||||
|
|
||||||
service = createFeatureToggleService(db.rawDatabase, config);
|
service = createFeatureToggleService(db.rawDatabase, config);
|
||||||
|
|
||||||
eventService = new EventService(stores, config);
|
eventService = createEventsService(db.rawDatabase, config);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import type { Db } from '../../db/db';
|
import type { Db } from '../../db/db';
|
||||||
import type { IUnleashConfig } from '../../types';
|
import type { IUnleashConfig } from '../../types';
|
||||||
import { EventService } from '../../services';
|
|
||||||
import FakeEventStore from '../../../test/fixtures/fake-event-store';
|
|
||||||
import FakeFeatureTagStore from '../../../test/fixtures/fake-feature-tag-store';
|
|
||||||
import EnvironmentService from './environment-service';
|
import EnvironmentService from './environment-service';
|
||||||
import EnvironmentStore from './environment-store';
|
import EnvironmentStore from './environment-store';
|
||||||
import FeatureStrategiesStore from '../feature-toggle/feature-toggle-strategies-store';
|
import FeatureStrategiesStore from '../feature-toggle/feature-toggle-strategies-store';
|
||||||
@ -12,7 +9,10 @@ import FakeFeatureEnvironmentStore from '../../../test/fixtures/fake-feature-env
|
|||||||
import FakeProjectStore from '../../../test/fixtures/fake-project-store';
|
import FakeProjectStore from '../../../test/fixtures/fake-project-store';
|
||||||
import FakeFeatureStrategiesStore from '../feature-toggle/fakes/fake-feature-strategies-store';
|
import FakeFeatureStrategiesStore from '../feature-toggle/fakes/fake-feature-strategies-store';
|
||||||
import FakeEnvironmentStore from './fake-environment-store';
|
import FakeEnvironmentStore from './fake-environment-store';
|
||||||
import { createEventsService } from '../events/createEventsService';
|
import {
|
||||||
|
createEventsService,
|
||||||
|
createFakeEventsService,
|
||||||
|
} from '../events/createEventsService';
|
||||||
|
|
||||||
export const createEnvironmentService =
|
export const createEnvironmentService =
|
||||||
(config: IUnleashConfig) =>
|
(config: IUnleashConfig) =>
|
||||||
@ -52,19 +52,11 @@ export const createEnvironmentService =
|
|||||||
export const createFakeEnvironmentService = (
|
export const createFakeEnvironmentService = (
|
||||||
config: IUnleashConfig,
|
config: IUnleashConfig,
|
||||||
): EnvironmentService => {
|
): EnvironmentService => {
|
||||||
const eventStore = new FakeEventStore();
|
|
||||||
const featureTagStore = new FakeFeatureTagStore();
|
|
||||||
const featureEnvironmentStore = new FakeFeatureEnvironmentStore();
|
const featureEnvironmentStore = new FakeFeatureEnvironmentStore();
|
||||||
const projectStore = new FakeProjectStore();
|
const projectStore = new FakeProjectStore();
|
||||||
const featureStrategiesStore = new FakeFeatureStrategiesStore();
|
const featureStrategiesStore = new FakeFeatureStrategiesStore();
|
||||||
const environmentStore = new FakeEnvironmentStore();
|
const environmentStore = new FakeEnvironmentStore();
|
||||||
const eventService = new EventService(
|
const eventService = createFakeEventsService(config);
|
||||||
{
|
|
||||||
eventStore,
|
|
||||||
featureTagStore,
|
|
||||||
},
|
|
||||||
config,
|
|
||||||
);
|
|
||||||
|
|
||||||
return new EnvironmentService(
|
return new EnvironmentService(
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,8 @@ import {
|
|||||||
SYSTEM_USER_AUDIT,
|
SYSTEM_USER_AUDIT,
|
||||||
} from '../../types';
|
} from '../../types';
|
||||||
import NameExistsError from '../../error/name-exists-error';
|
import NameExistsError from '../../error/name-exists-error';
|
||||||
import { EventService } from '../../services';
|
import type { EventService } from '../../services';
|
||||||
|
import { createEventsService } from '../events/createEventsService';
|
||||||
|
|
||||||
let stores: IUnleashStores;
|
let stores: IUnleashStores;
|
||||||
let db: ITestDb;
|
let db: ITestDb;
|
||||||
@ -19,7 +20,7 @@ beforeAll(async () => {
|
|||||||
const config = createTestConfig();
|
const config = createTestConfig();
|
||||||
db = await dbInit('environment_service_serial', config.getLogger);
|
db = await dbInit('environment_service_serial', config.getLogger);
|
||||||
stores = db.stores;
|
stores = db.stores;
|
||||||
eventService = new EventService(stores, config);
|
eventService = createEventsService(db.rawDatabase, config);
|
||||||
service = new EnvironmentService(stores, config, eventService);
|
service = new EnvironmentService(stores, config, eventService);
|
||||||
});
|
});
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
|
@ -3,13 +3,14 @@ import getLogger from '../../../test/fixtures/no-logger';
|
|||||||
import type FeatureToggleService from '../../../lib/features/feature-toggle/feature-toggle-service';
|
import type FeatureToggleService from '../../../lib/features/feature-toggle/feature-toggle-service';
|
||||||
import type ProjectService from '../../../lib/features/project/project-service';
|
import type ProjectService from '../../../lib/features/project/project-service';
|
||||||
import { createTestConfig } from '../../../test/config/test-config';
|
import { createTestConfig } from '../../../test/config/test-config';
|
||||||
import {
|
import type {
|
||||||
EventService,
|
EventService,
|
||||||
type ProjectInsightsService,
|
ProjectInsightsService,
|
||||||
} from '../../../lib/services';
|
} from '../../../lib/services';
|
||||||
import { FeatureEnvironmentEvent } from '../../../lib/types/events';
|
import { FeatureEnvironmentEvent } from '../../../lib/types/events';
|
||||||
import { subDays } from 'date-fns';
|
import { subDays } from 'date-fns';
|
||||||
import {
|
import {
|
||||||
|
createEventsService,
|
||||||
createFeatureToggleService,
|
createFeatureToggleService,
|
||||||
createProjectService,
|
createProjectService,
|
||||||
} from '../../../lib/features';
|
} from '../../../lib/features';
|
||||||
@ -47,7 +48,7 @@ beforeAll(async () => {
|
|||||||
const config = createTestConfig({
|
const config = createTestConfig({
|
||||||
getLogger,
|
getLogger,
|
||||||
});
|
});
|
||||||
eventService = new EventService(stores, config);
|
eventService = createEventsService(db.rawDatabase, config);
|
||||||
|
|
||||||
featureToggleService = createFeatureToggleService(db.rawDatabase, config);
|
featureToggleService = createFeatureToggleService(db.rawDatabase, config);
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import EnvironmentStore from '../project-environments/environment-store';
|
|||||||
import {
|
import {
|
||||||
type AccessService,
|
type AccessService,
|
||||||
ApiTokenService,
|
ApiTokenService,
|
||||||
EventService,
|
|
||||||
FavoritesService,
|
FavoritesService,
|
||||||
GroupService,
|
GroupService,
|
||||||
ProjectService,
|
ProjectService,
|
||||||
@ -39,13 +38,16 @@ import {
|
|||||||
createFakePrivateProjectChecker,
|
createFakePrivateProjectChecker,
|
||||||
createPrivateProjectChecker,
|
createPrivateProjectChecker,
|
||||||
} from '../private-project/createPrivateProjectChecker';
|
} from '../private-project/createPrivateProjectChecker';
|
||||||
import FakeFeatureTagStore from '../../../test/fixtures/fake-feature-tag-store';
|
|
||||||
import { ProjectOwnersReadModel } from './project-owners-read-model';
|
import { ProjectOwnersReadModel } from './project-owners-read-model';
|
||||||
import { FakeProjectOwnersReadModel } from './fake-project-owners-read-model';
|
import { FakeProjectOwnersReadModel } from './fake-project-owners-read-model';
|
||||||
import { FakeProjectFlagCreatorsReadModel } from './fake-project-flag-creators-read-model';
|
import { FakeProjectFlagCreatorsReadModel } from './fake-project-flag-creators-read-model';
|
||||||
import { ProjectFlagCreatorsReadModel } from './project-flag-creators-read-model';
|
import { ProjectFlagCreatorsReadModel } from './project-flag-creators-read-model';
|
||||||
import FakeApiTokenStore from '../../../test/fixtures/fake-api-token-store';
|
import FakeApiTokenStore from '../../../test/fixtures/fake-api-token-store';
|
||||||
import { ApiTokenStore } from '../../db/api-token-store';
|
import { ApiTokenStore } from '../../db/api-token-store';
|
||||||
|
import {
|
||||||
|
createEventsService,
|
||||||
|
createFakeEventsService,
|
||||||
|
} from '../events/createEventsService';
|
||||||
|
|
||||||
export const createProjectService = (
|
export const createProjectService = (
|
||||||
db: Db,
|
db: Db,
|
||||||
@ -88,13 +90,7 @@ export const createProjectService = (
|
|||||||
eventBus,
|
eventBus,
|
||||||
getLogger,
|
getLogger,
|
||||||
);
|
);
|
||||||
const eventService = new EventService(
|
const eventService = createEventsService(db, config);
|
||||||
{
|
|
||||||
eventStore,
|
|
||||||
featureTagStore: new FakeFeatureTagStore(),
|
|
||||||
},
|
|
||||||
config,
|
|
||||||
);
|
|
||||||
const favoriteService = new FavoritesService(
|
const favoriteService = new FavoritesService(
|
||||||
{
|
{
|
||||||
favoriteFeaturesStore,
|
favoriteFeaturesStore,
|
||||||
@ -166,13 +162,8 @@ export const createFakeProjectService = (
|
|||||||
const favoriteFeaturesStore = new FakeFavoriteFeaturesStore();
|
const favoriteFeaturesStore = new FakeFavoriteFeaturesStore();
|
||||||
const favoriteProjectsStore = new FakeFavoriteProjectsStore();
|
const favoriteProjectsStore = new FakeFavoriteProjectsStore();
|
||||||
const apiTokenStore = new FakeApiTokenStore();
|
const apiTokenStore = new FakeApiTokenStore();
|
||||||
const eventService = new EventService(
|
const privateProjectChecker = createFakePrivateProjectChecker();
|
||||||
{
|
const eventService = createFakeEventsService(config);
|
||||||
eventStore,
|
|
||||||
featureTagStore: new FakeFeatureTagStore(),
|
|
||||||
},
|
|
||||||
config,
|
|
||||||
);
|
|
||||||
const favoriteService = new FavoritesService(
|
const favoriteService = new FavoritesService(
|
||||||
{
|
{
|
||||||
favoriteFeaturesStore,
|
favoriteFeaturesStore,
|
||||||
@ -187,8 +178,6 @@ export const createFakeProjectService = (
|
|||||||
eventService,
|
eventService,
|
||||||
);
|
);
|
||||||
|
|
||||||
const privateProjectChecker = createFakePrivateProjectChecker();
|
|
||||||
|
|
||||||
const apiTokenService = new ApiTokenService(
|
const apiTokenService = new ApiTokenService(
|
||||||
{ apiTokenStore, environmentStore },
|
{ apiTokenStore, environmentStore },
|
||||||
config,
|
config,
|
||||||
|
@ -9,11 +9,12 @@ import { RoleName } from '../../types/model';
|
|||||||
import { randomId } from '../../util/random-id';
|
import { randomId } from '../../util/random-id';
|
||||||
import EnvironmentService from '../project-environments/environment-service';
|
import EnvironmentService from '../project-environments/environment-service';
|
||||||
import IncompatibleProjectError from '../../error/incompatible-project-error';
|
import IncompatibleProjectError from '../../error/incompatible-project-error';
|
||||||
import { type ApiTokenService, EventService } from '../../services';
|
import type { ApiTokenService, EventService } from '../../services';
|
||||||
import { FeatureEnvironmentEvent } from '../../types/events';
|
import { FeatureEnvironmentEvent } from '../../types/events';
|
||||||
import { addDays, subDays } from 'date-fns';
|
import { addDays, subDays } from 'date-fns';
|
||||||
import {
|
import {
|
||||||
createAccessService,
|
createAccessService,
|
||||||
|
createEventsService,
|
||||||
createFeatureToggleService,
|
createFeatureToggleService,
|
||||||
createProjectService,
|
createProjectService,
|
||||||
} from '../index';
|
} from '../index';
|
||||||
@ -83,7 +84,7 @@ beforeAll(async () => {
|
|||||||
getLogger,
|
getLogger,
|
||||||
experimental: { flags: { archiveProjects: true } },
|
experimental: { flags: { archiveProjects: true } },
|
||||||
});
|
});
|
||||||
eventService = new EventService(stores, config);
|
eventService = createEventsService(db.rawDatabase, config);
|
||||||
accessService = createAccessService(db.rawDatabase, config);
|
accessService = createAccessService(db.rawDatabase, config);
|
||||||
|
|
||||||
featureToggleService = createFeatureToggleService(db.rawDatabase, config);
|
featureToggleService = createFeatureToggleService(db.rawDatabase, config);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import type { Db, IUnleashConfig } from '../../server-impl';
|
import type { Db, IUnleashConfig } from '../../server-impl';
|
||||||
import { EventService, SegmentService } from '../../services';
|
import { SegmentService } from '../../services';
|
||||||
import FakeEventStore from '../../../test/fixtures/fake-event-store';
|
|
||||||
import type { ISegmentService } from './segment-service-interface';
|
import type { ISegmentService } from './segment-service-interface';
|
||||||
import FeatureStrategiesStore from '../feature-toggle/feature-toggle-strategies-store';
|
import FeatureStrategiesStore from '../feature-toggle/feature-toggle-strategies-store';
|
||||||
import SegmentStore from './segment-store';
|
import SegmentStore from './segment-store';
|
||||||
@ -18,8 +17,10 @@ import {
|
|||||||
createFakePrivateProjectChecker,
|
createFakePrivateProjectChecker,
|
||||||
createPrivateProjectChecker,
|
createPrivateProjectChecker,
|
||||||
} from '../private-project/createPrivateProjectChecker';
|
} from '../private-project/createPrivateProjectChecker';
|
||||||
import FakeFeatureTagStore from '../../../test/fixtures/fake-feature-tag-store';
|
import {
|
||||||
import { createEventsService } from '../events/createEventsService';
|
createEventsService,
|
||||||
|
createFakeEventsService,
|
||||||
|
} from '../events/createEventsService';
|
||||||
|
|
||||||
export const createSegmentService = (
|
export const createSegmentService = (
|
||||||
db: Db,
|
db: Db,
|
||||||
@ -63,7 +64,6 @@ export const createSegmentService = (
|
|||||||
export const createFakeSegmentService = (
|
export const createFakeSegmentService = (
|
||||||
config: IUnleashConfig,
|
config: IUnleashConfig,
|
||||||
): ISegmentService => {
|
): ISegmentService => {
|
||||||
const eventStore = new FakeEventStore();
|
|
||||||
const segmentStore = new FakeSegmentStore();
|
const segmentStore = new FakeSegmentStore();
|
||||||
const featureStrategiesStore = new FakeFeatureStrategiesStore();
|
const featureStrategiesStore = new FakeFeatureStrategiesStore();
|
||||||
const changeRequestAccessReadModel = createFakeChangeRequestAccessService();
|
const changeRequestAccessReadModel = createFakeChangeRequestAccessService();
|
||||||
@ -72,13 +72,7 @@ export const createFakeSegmentService = (
|
|||||||
|
|
||||||
const privateProjectChecker = createFakePrivateProjectChecker();
|
const privateProjectChecker = createFakePrivateProjectChecker();
|
||||||
|
|
||||||
const eventService = new EventService(
|
const eventService = createFakeEventsService(config);
|
||||||
{
|
|
||||||
eventStore,
|
|
||||||
featureTagStore: new FakeFeatureTagStore(),
|
|
||||||
},
|
|
||||||
config,
|
|
||||||
);
|
|
||||||
|
|
||||||
return new SegmentService(
|
return new SegmentService(
|
||||||
{ segmentStore, featureStrategiesStore },
|
{ segmentStore, featureStrategiesStore },
|
||||||
|
@ -4,14 +4,11 @@ import { createTestConfig } from '../../test/config/test-config';
|
|||||||
import FakeEventStore from '../../test/fixtures/fake-event-store';
|
import FakeEventStore from '../../test/fixtures/fake-event-store';
|
||||||
import { randomId } from '../util/random-id';
|
import { randomId } from '../util/random-id';
|
||||||
import FakeProjectStore from '../../test/fixtures/fake-project-store';
|
import FakeProjectStore from '../../test/fixtures/fake-project-store';
|
||||||
import {
|
import { FrontendApiService, SettingService } from '../../lib/services';
|
||||||
EventService,
|
|
||||||
FrontendApiService,
|
|
||||||
SettingService,
|
|
||||||
} from '../../lib/services';
|
|
||||||
import { type ISettingStore, TEST_AUDIT_USER } from '../../lib/types';
|
import { type ISettingStore, TEST_AUDIT_USER } from '../../lib/types';
|
||||||
import { frontendSettingsKey } from '../../lib/types/settings/frontend-settings';
|
import { frontendSettingsKey } from '../../lib/types/settings/frontend-settings';
|
||||||
import FakeFeatureTagStore from '../../test/fixtures/fake-feature-tag-store';
|
import FakeFeatureTagStore from '../../test/fixtures/fake-feature-tag-store';
|
||||||
|
import { createFakeEventsService } from '../features';
|
||||||
|
|
||||||
const TEST_USER_ID = -9999;
|
const TEST_USER_ID = -9999;
|
||||||
const createSettingService = (
|
const createSettingService = (
|
||||||
@ -26,7 +23,7 @@ const createSettingService = (
|
|||||||
projectStore: new FakeProjectStore(),
|
projectStore: new FakeProjectStore(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const eventService = new EventService(stores, config);
|
const eventService = createFakeEventsService(config);
|
||||||
|
|
||||||
const services = {
|
const services = {
|
||||||
settingService: new SettingService(stores, config, eventService),
|
settingService: new SettingService(stores, config, eventService),
|
||||||
|
@ -14,10 +14,17 @@ import AddonService from './addon-service';
|
|||||||
import type { IAddonDto } from '../types/stores/addon-store';
|
import type { IAddonDto } from '../types/stores/addon-store';
|
||||||
import SimpleAddon from './addon-service-test-simple-addon';
|
import SimpleAddon from './addon-service-test-simple-addon';
|
||||||
import type { IAddonProviders } from '../addons';
|
import type { IAddonProviders } from '../addons';
|
||||||
import EventService from '../features/events/event-service';
|
import {
|
||||||
import { type IFlagResolver, SYSTEM_USER, TEST_AUDIT_USER } from '../types';
|
type IFlagResolver,
|
||||||
import EventEmitter from 'node:events';
|
type IUnleashConfig,
|
||||||
import { IntegrationEventsService } from '../internals';
|
SYSTEM_USER,
|
||||||
|
TEST_AUDIT_USER,
|
||||||
|
} from '../types';
|
||||||
|
import {
|
||||||
|
createFakeEventsService,
|
||||||
|
IntegrationEventsService,
|
||||||
|
} from '../internals';
|
||||||
|
import { createTestConfig } from '../../test/config/test-config';
|
||||||
|
|
||||||
const MASKED_VALUE = '*****';
|
const MASKED_VALUE = '*****';
|
||||||
|
|
||||||
@ -25,12 +32,11 @@ const TEST_USER_ID = -9999;
|
|||||||
|
|
||||||
let addonProvider: IAddonProviders;
|
let addonProvider: IAddonProviders;
|
||||||
|
|
||||||
|
const config: IUnleashConfig = createTestConfig();
|
||||||
|
|
||||||
function getSetup() {
|
function getSetup() {
|
||||||
const stores = createStores();
|
const stores = createStores();
|
||||||
const eventService = new EventService(stores, {
|
const eventService = createFakeEventsService(config);
|
||||||
getLogger,
|
|
||||||
eventBus: new EventEmitter(),
|
|
||||||
});
|
|
||||||
const tagTypeService = new TagTypeService(
|
const tagTypeService = new TagTypeService(
|
||||||
stores,
|
stores,
|
||||||
{ getLogger },
|
{ getLogger },
|
||||||
|
@ -43,6 +43,7 @@ test('Should only store events for potentially stale on', async () => {
|
|||||||
featureTagStore: new FakeFeatureTagStore(),
|
featureTagStore: new FakeFeatureTagStore(),
|
||||||
},
|
},
|
||||||
config,
|
config,
|
||||||
|
{},
|
||||||
);
|
);
|
||||||
|
|
||||||
const featureToggleService = new FeatureToggleService(
|
const featureToggleService = new FeatureToggleService(
|
||||||
|
@ -64,7 +64,9 @@ import {
|
|||||||
import ConfigurationRevisionService from '../features/feature-toggle/configuration-revision-service';
|
import ConfigurationRevisionService from '../features/feature-toggle/configuration-revision-service';
|
||||||
import {
|
import {
|
||||||
createEnvironmentService,
|
createEnvironmentService,
|
||||||
|
createEventsService,
|
||||||
createFakeEnvironmentService,
|
createFakeEnvironmentService,
|
||||||
|
createFakeEventsService,
|
||||||
createFakeProjectService,
|
createFakeProjectService,
|
||||||
createFeatureLifecycleService,
|
createFeatureLifecycleService,
|
||||||
createFeatureToggleService,
|
createFeatureToggleService,
|
||||||
@ -114,8 +116,6 @@ import {
|
|||||||
createInstanceStatsService,
|
createInstanceStatsService,
|
||||||
} from '../features/instance-stats/createInstanceStatsService';
|
} from '../features/instance-stats/createInstanceStatsService';
|
||||||
import { InactiveUsersService } from '../users/inactive/inactive-users-service';
|
import { InactiveUsersService } from '../users/inactive/inactive-users-service';
|
||||||
import { SegmentReadModel } from '../features/segment/segment-read-model';
|
|
||||||
import { FakeSegmentReadModel } from '../features/segment/fake-segment-read-model';
|
|
||||||
import {
|
import {
|
||||||
createFakeFrontendApiService,
|
createFakeFrontendApiService,
|
||||||
createFrontendApiService,
|
createFrontendApiService,
|
||||||
@ -147,7 +147,13 @@ export const createServices = (
|
|||||||
config: IUnleashConfig,
|
config: IUnleashConfig,
|
||||||
db?: Db,
|
db?: Db,
|
||||||
): IUnleashServices => {
|
): IUnleashServices => {
|
||||||
const eventService = new EventService(stores, config);
|
const privateProjectChecker = db
|
||||||
|
? createPrivateProjectChecker(db, config)
|
||||||
|
: createFakePrivateProjectChecker();
|
||||||
|
|
||||||
|
const eventService = db
|
||||||
|
? createEventsService(db, config)
|
||||||
|
: createFakeEventsService(config, stores);
|
||||||
const groupService = new GroupService(stores, config, eventService);
|
const groupService = new GroupService(stores, config, eventService);
|
||||||
const accessService = new AccessService(
|
const accessService = new AccessService(
|
||||||
stores,
|
stores,
|
||||||
@ -166,18 +172,12 @@ export const createServices = (
|
|||||||
config,
|
config,
|
||||||
lastSeenService,
|
lastSeenService,
|
||||||
);
|
);
|
||||||
const privateProjectChecker = db
|
|
||||||
? createPrivateProjectChecker(db, config)
|
|
||||||
: createFakePrivateProjectChecker();
|
|
||||||
const dependentFeaturesReadModel = db
|
const dependentFeaturesReadModel = db
|
||||||
? new DependentFeaturesReadModel(db)
|
? new DependentFeaturesReadModel(db)
|
||||||
: new FakeDependentFeaturesReadModel();
|
: new FakeDependentFeaturesReadModel();
|
||||||
const featureLifecycleReadModel = db
|
const featureLifecycleReadModel = db
|
||||||
? new FeatureLifecycleReadModel(db, config.flagResolver)
|
? new FeatureLifecycleReadModel(db, config.flagResolver)
|
||||||
: new FakeFeatureLifecycleReadModel();
|
: new FakeFeatureLifecycleReadModel();
|
||||||
const segmentReadModel = db
|
|
||||||
? new SegmentReadModel(db)
|
|
||||||
: new FakeSegmentReadModel();
|
|
||||||
|
|
||||||
const contextService = new ContextService(
|
const contextService = new ContextService(
|
||||||
stores,
|
stores,
|
||||||
|
@ -14,9 +14,8 @@ import User from '../types/user';
|
|||||||
import FakeResetTokenStore from '../../test/fixtures/fake-reset-token-store';
|
import FakeResetTokenStore from '../../test/fixtures/fake-reset-token-store';
|
||||||
import SettingService from './setting-service';
|
import SettingService from './setting-service';
|
||||||
import FakeSettingStore from '../../test/fixtures/fake-setting-store';
|
import FakeSettingStore from '../../test/fixtures/fake-setting-store';
|
||||||
import EventService from '../features/events/event-service';
|
|
||||||
import FakeFeatureTagStore from '../../test/fixtures/fake-feature-tag-store';
|
|
||||||
import { extractAuditInfoFromUser } from '../util';
|
import { extractAuditInfoFromUser } from '../util';
|
||||||
|
import { createFakeEventsService } from '../features';
|
||||||
|
|
||||||
const config: IUnleashConfig = createTestConfig();
|
const config: IUnleashConfig = createTestConfig();
|
||||||
|
|
||||||
@ -34,10 +33,7 @@ test('Should create new user', async () => {
|
|||||||
const sessionStore = new FakeSessionStore();
|
const sessionStore = new FakeSessionStore();
|
||||||
const sessionService = new SessionService({ sessionStore }, config);
|
const sessionService = new SessionService({ sessionStore }, config);
|
||||||
const emailService = new EmailService(config);
|
const emailService = new EmailService(config);
|
||||||
const eventService = new EventService(
|
const eventService = createFakeEventsService(config);
|
||||||
{ eventStore, featureTagStore: new FakeFeatureTagStore() },
|
|
||||||
config,
|
|
||||||
);
|
|
||||||
const settingService = new SettingService(
|
const settingService = new SettingService(
|
||||||
{
|
{
|
||||||
settingStore: new FakeSettingStore(),
|
settingStore: new FakeSettingStore(),
|
||||||
@ -99,10 +95,7 @@ describe('Default admin initialization', () => {
|
|||||||
|
|
||||||
const sessionStore = new FakeSessionStore();
|
const sessionStore = new FakeSessionStore();
|
||||||
const sessionService = new SessionService({ sessionStore }, config);
|
const sessionService = new SessionService({ sessionStore }, config);
|
||||||
const eventService = new EventService(
|
const eventService = createFakeEventsService(config);
|
||||||
{ eventStore, featureTagStore: new FakeFeatureTagStore() },
|
|
||||||
config,
|
|
||||||
);
|
|
||||||
const settingService = new SettingService(
|
const settingService = new SettingService(
|
||||||
{
|
{
|
||||||
settingStore: new FakeSettingStore(),
|
settingStore: new FakeSettingStore(),
|
||||||
@ -168,10 +161,7 @@ describe('Default admin initialization', () => {
|
|||||||
const emailService = new EmailService(config);
|
const emailService = new EmailService(config);
|
||||||
const sessionStore = new FakeSessionStore();
|
const sessionStore = new FakeSessionStore();
|
||||||
const sessionService = new SessionService({ sessionStore }, config);
|
const sessionService = new SessionService({ sessionStore }, config);
|
||||||
const eventService = new EventService(
|
const eventService = createFakeEventsService(config);
|
||||||
{ eventStore, featureTagStore: new FakeFeatureTagStore() },
|
|
||||||
config,
|
|
||||||
);
|
|
||||||
const settingService = new SettingService(
|
const settingService = new SettingService(
|
||||||
{
|
{
|
||||||
settingStore: new FakeSettingStore(),
|
settingStore: new FakeSettingStore(),
|
||||||
@ -210,10 +200,7 @@ test('Should be a valid password', async () => {
|
|||||||
const emailService = new EmailService(config);
|
const emailService = new EmailService(config);
|
||||||
const sessionStore = new FakeSessionStore();
|
const sessionStore = new FakeSessionStore();
|
||||||
const sessionService = new SessionService({ sessionStore }, config);
|
const sessionService = new SessionService({ sessionStore }, config);
|
||||||
const eventService = new EventService(
|
const eventService = createFakeEventsService(config);
|
||||||
{ eventStore, featureTagStore: new FakeFeatureTagStore() },
|
|
||||||
config,
|
|
||||||
);
|
|
||||||
const settingService = new SettingService(
|
const settingService = new SettingService(
|
||||||
{
|
{
|
||||||
settingStore: new FakeSettingStore(),
|
settingStore: new FakeSettingStore(),
|
||||||
@ -248,10 +235,7 @@ test('Password must be at least 10 chars', async () => {
|
|||||||
const emailService = new EmailService(config);
|
const emailService = new EmailService(config);
|
||||||
const sessionStore = new FakeSessionStore();
|
const sessionStore = new FakeSessionStore();
|
||||||
const sessionService = new SessionService({ sessionStore }, config);
|
const sessionService = new SessionService({ sessionStore }, config);
|
||||||
const eventService = new EventService(
|
const eventService = createFakeEventsService(config);
|
||||||
{ eventStore, featureTagStore: new FakeFeatureTagStore() },
|
|
||||||
config,
|
|
||||||
);
|
|
||||||
const settingService = new SettingService(
|
const settingService = new SettingService(
|
||||||
{
|
{
|
||||||
settingStore: new FakeSettingStore(),
|
settingStore: new FakeSettingStore(),
|
||||||
@ -288,10 +272,7 @@ test('The password must contain at least one uppercase letter.', async () => {
|
|||||||
const emailService = new EmailService(config);
|
const emailService = new EmailService(config);
|
||||||
const sessionStore = new FakeSessionStore();
|
const sessionStore = new FakeSessionStore();
|
||||||
const sessionService = new SessionService({ sessionStore }, config);
|
const sessionService = new SessionService({ sessionStore }, config);
|
||||||
const eventService = new EventService(
|
const eventService = createFakeEventsService(config);
|
||||||
{ eventStore, featureTagStore: new FakeFeatureTagStore() },
|
|
||||||
config,
|
|
||||||
);
|
|
||||||
const settingService = new SettingService(
|
const settingService = new SettingService(
|
||||||
{
|
{
|
||||||
settingStore: new FakeSettingStore(),
|
settingStore: new FakeSettingStore(),
|
||||||
@ -330,10 +311,7 @@ test('The password must contain at least one number', async () => {
|
|||||||
const emailService = new EmailService(config);
|
const emailService = new EmailService(config);
|
||||||
const sessionStore = new FakeSessionStore();
|
const sessionStore = new FakeSessionStore();
|
||||||
const sessionService = new SessionService({ sessionStore }, config);
|
const sessionService = new SessionService({ sessionStore }, config);
|
||||||
const eventService = new EventService(
|
const eventService = createFakeEventsService(config);
|
||||||
{ eventStore, featureTagStore: new FakeFeatureTagStore() },
|
|
||||||
config,
|
|
||||||
);
|
|
||||||
const settingService = new SettingService(
|
const settingService = new SettingService(
|
||||||
{
|
{
|
||||||
settingStore: new FakeSettingStore(),
|
settingStore: new FakeSettingStore(),
|
||||||
@ -371,10 +349,7 @@ test('The password must contain at least one special character', async () => {
|
|||||||
const emailService = new EmailService(config);
|
const emailService = new EmailService(config);
|
||||||
const sessionStore = new FakeSessionStore();
|
const sessionStore = new FakeSessionStore();
|
||||||
const sessionService = new SessionService({ sessionStore }, config);
|
const sessionService = new SessionService({ sessionStore }, config);
|
||||||
const eventService = new EventService(
|
const eventService = createFakeEventsService(config);
|
||||||
{ eventStore, featureTagStore: new FakeFeatureTagStore() },
|
|
||||||
config,
|
|
||||||
);
|
|
||||||
const settingService = new SettingService(
|
const settingService = new SettingService(
|
||||||
{
|
{
|
||||||
settingStore: new FakeSettingStore(),
|
settingStore: new FakeSettingStore(),
|
||||||
@ -412,10 +387,7 @@ test('Should be a valid password with special chars', async () => {
|
|||||||
const emailService = new EmailService(config);
|
const emailService = new EmailService(config);
|
||||||
const sessionStore = new FakeSessionStore();
|
const sessionStore = new FakeSessionStore();
|
||||||
const sessionService = new SessionService({ sessionStore }, config);
|
const sessionService = new SessionService({ sessionStore }, config);
|
||||||
const eventService = new EventService(
|
const eventService = createFakeEventsService(config);
|
||||||
{ eventStore, featureTagStore: new FakeFeatureTagStore() },
|
|
||||||
config,
|
|
||||||
);
|
|
||||||
const settingService = new SettingService(
|
const settingService = new SettingService(
|
||||||
{
|
{
|
||||||
settingStore: new FakeSettingStore(),
|
settingStore: new FakeSettingStore(),
|
||||||
@ -450,10 +422,7 @@ test('Should send password reset email if user exists', async () => {
|
|||||||
const emailService = new EmailService(config);
|
const emailService = new EmailService(config);
|
||||||
const sessionStore = new FakeSessionStore();
|
const sessionStore = new FakeSessionStore();
|
||||||
const sessionService = new SessionService({ sessionStore }, config);
|
const sessionService = new SessionService({ sessionStore }, config);
|
||||||
const eventService = new EventService(
|
const eventService = createFakeEventsService(config);
|
||||||
{ eventStore, featureTagStore: new FakeFeatureTagStore() },
|
|
||||||
config,
|
|
||||||
);
|
|
||||||
const settingService = new SettingService(
|
const settingService = new SettingService(
|
||||||
{
|
{
|
||||||
settingStore: new FakeSettingStore(),
|
settingStore: new FakeSettingStore(),
|
||||||
@ -504,10 +473,7 @@ test('Should throttle password reset email', async () => {
|
|||||||
const emailService = new EmailService(config);
|
const emailService = new EmailService(config);
|
||||||
const sessionStore = new FakeSessionStore();
|
const sessionStore = new FakeSessionStore();
|
||||||
const sessionService = new SessionService({ sessionStore }, config);
|
const sessionService = new SessionService({ sessionStore }, config);
|
||||||
const eventService = new EventService(
|
const eventService = createFakeEventsService(config);
|
||||||
{ eventStore, featureTagStore: new FakeFeatureTagStore() },
|
|
||||||
config,
|
|
||||||
);
|
|
||||||
const settingService = new SettingService(
|
const settingService = new SettingService(
|
||||||
{
|
{
|
||||||
settingStore: new FakeSettingStore(),
|
settingStore: new FakeSettingStore(),
|
||||||
|
@ -1,20 +1,23 @@
|
|||||||
import type { EventSearchQueryParameters } from '../../../../lib/openapi/spec/event-search-query-parameters';
|
import type { EventSearchQueryParameters } from '../../../../lib/openapi/spec/event-search-query-parameters';
|
||||||
import dbInit, { type ITestDb } from '../../helpers/database-init';
|
import dbInit, { type ITestDb } from '../../helpers/database-init';
|
||||||
|
|
||||||
import { FEATURE_CREATED } from '../../../../lib/types';
|
import { FEATURE_CREATED, type IUnleashConfig } from '../../../../lib/types';
|
||||||
import { EventService } from '../../../../lib/services';
|
import type { EventService } from '../../../../lib/services';
|
||||||
import EventEmitter from 'events';
|
|
||||||
import getLogger from '../../../fixtures/no-logger';
|
import getLogger from '../../../fixtures/no-logger';
|
||||||
import {
|
import {
|
||||||
type IUnleashTest,
|
type IUnleashTest,
|
||||||
setupAppWithCustomConfig,
|
setupAppWithCustomConfig,
|
||||||
} from '../../helpers/test-helper';
|
} from '../../helpers/test-helper';
|
||||||
|
import { createEventsService } from '../../../../lib/features';
|
||||||
|
import { createTestConfig } from '../../../config/test-config';
|
||||||
|
|
||||||
let app: IUnleashTest;
|
let app: IUnleashTest;
|
||||||
let db: ITestDb;
|
let db: ITestDb;
|
||||||
let eventService: EventService;
|
let eventService: EventService;
|
||||||
const TEST_USER_ID = -9999;
|
const TEST_USER_ID = -9999;
|
||||||
|
|
||||||
|
const config: IUnleashConfig = createTestConfig();
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
db = await dbInit('event_search', getLogger);
|
db = await dbInit('event_search', getLogger);
|
||||||
app = await setupAppWithCustomConfig(db.stores, {
|
app = await setupAppWithCustomConfig(db.stores, {
|
||||||
@ -25,10 +28,7 @@ beforeAll(async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
eventService = new EventService(db.stores, {
|
eventService = createEventsService(db.rawDatabase, config);
|
||||||
getLogger,
|
|
||||||
eventBus: new EventEmitter(),
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
|
@ -6,14 +6,18 @@ import dbInit, { type ITestDb } from '../../helpers/database-init';
|
|||||||
import getLogger from '../../../fixtures/no-logger';
|
import getLogger from '../../../fixtures/no-logger';
|
||||||
import { FEATURE_CREATED, type IBaseEvent } from '../../../../lib/types/events';
|
import { FEATURE_CREATED, type IBaseEvent } from '../../../../lib/types/events';
|
||||||
import { randomId } from '../../../../lib/util/random-id';
|
import { randomId } from '../../../../lib/util/random-id';
|
||||||
import { EventService } from '../../../../lib/services';
|
import type { EventService } from '../../../../lib/services';
|
||||||
import EventEmitter from 'events';
|
import { type IUnleashConfig, SYSTEM_USER } from '../../../../lib/types';
|
||||||
import { SYSTEM_USER } from '../../../../lib/types';
|
import { createEventsService } from '../../../../lib/features';
|
||||||
|
import { createTestConfig } from '../../../config/test-config';
|
||||||
|
|
||||||
let app: IUnleashTest;
|
let app: IUnleashTest;
|
||||||
let db: ITestDb;
|
let db: ITestDb;
|
||||||
let eventService: EventService;
|
let eventService: EventService;
|
||||||
const TEST_USER_ID = -9999;
|
const TEST_USER_ID = -9999;
|
||||||
|
|
||||||
|
const config: IUnleashConfig = createTestConfig();
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
db = await dbInit('event_api_serial', getLogger);
|
db = await dbInit('event_api_serial', getLogger);
|
||||||
app = await setupAppWithCustomConfig(db.stores, {
|
app = await setupAppWithCustomConfig(db.stores, {
|
||||||
@ -23,10 +27,7 @@ beforeAll(async () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
eventService = new EventService(db.stores, {
|
eventService = createEventsService(db.rawDatabase, config);
|
||||||
getLogger,
|
|
||||||
eventBus: new EventEmitter(),
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
@ -12,13 +12,17 @@ let db: ITestDb;
|
|||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
db = await dbInit('feature_type_api_serial', getLogger);
|
db = await dbInit('feature_type_api_serial', getLogger);
|
||||||
app = await setupAppWithCustomConfig(db.stores, {
|
app = await setupAppWithCustomConfig(
|
||||||
|
db.stores,
|
||||||
|
{
|
||||||
experimental: {
|
experimental: {
|
||||||
flags: {
|
flags: {
|
||||||
strictSchemaValidation: true,
|
strictSchemaValidation: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
},
|
||||||
|
db.rawDatabase,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
|
@ -15,7 +15,11 @@ afterAll(async () => {
|
|||||||
test('creates new feature flag with createdBy', async () => {
|
test('creates new feature flag with createdBy', async () => {
|
||||||
expect.assertions(1);
|
expect.assertions(1);
|
||||||
|
|
||||||
const { request, destroy } = await setupAppWithAuth(db.stores);
|
const { request, destroy } = await setupAppWithAuth(
|
||||||
|
db.stores,
|
||||||
|
{},
|
||||||
|
db.rawDatabase,
|
||||||
|
);
|
||||||
|
|
||||||
// Login
|
// Login
|
||||||
await request.post('/auth/demo/login').send({
|
await request.post('/auth/demo/login').send({
|
||||||
|
@ -50,7 +50,12 @@ test('creates new feature flag with createdBy', async () => {
|
|||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const { request, destroy } = await setupAppWithCustomAuth(stores, preHook);
|
const { request, destroy } = await setupAppWithCustomAuth(
|
||||||
|
stores,
|
||||||
|
preHook,
|
||||||
|
{},
|
||||||
|
db.rawDatabase,
|
||||||
|
);
|
||||||
|
|
||||||
// create flag
|
// create flag
|
||||||
await request
|
await request
|
||||||
|
@ -20,8 +20,8 @@ import { RoleName } from '../../../../lib/types/model';
|
|||||||
import SettingService from '../../../../lib/services/setting-service';
|
import SettingService from '../../../../lib/services/setting-service';
|
||||||
import FakeSettingStore from '../../../fixtures/fake-setting-store';
|
import FakeSettingStore from '../../../fixtures/fake-setting-store';
|
||||||
import { GroupService } from '../../../../lib/services/group-service';
|
import { GroupService } from '../../../../lib/services/group-service';
|
||||||
import { EventService } from '../../../../lib/services';
|
|
||||||
import { type IUnleashStores, TEST_AUDIT_USER } from '../../../../lib/types';
|
import { type IUnleashStores, TEST_AUDIT_USER } from '../../../../lib/types';
|
||||||
|
import { createEventsService } from '../../../../lib/features';
|
||||||
|
|
||||||
let app: IUnleashTest;
|
let app: IUnleashTest;
|
||||||
let stores: IUnleashStores;
|
let stores: IUnleashStores;
|
||||||
@ -54,7 +54,7 @@ beforeAll(async () => {
|
|||||||
db = await dbInit('reset_password_api_serial', getLogger);
|
db = await dbInit('reset_password_api_serial', getLogger);
|
||||||
stores = db.stores;
|
stores = db.stores;
|
||||||
app = await setupApp(stores);
|
app = await setupApp(stores);
|
||||||
const eventService = new EventService(stores, config);
|
const eventService = createEventsService(db.rawDatabase, config);
|
||||||
const groupService = new GroupService(stores, config, eventService);
|
const groupService = new GroupService(stores, config, eventService);
|
||||||
accessService = new AccessService(
|
accessService = new AccessService(
|
||||||
stores,
|
stores,
|
||||||
|
@ -16,7 +16,7 @@ import { RoleName } from '../../../../lib/types/model';
|
|||||||
import SettingService from '../../../../lib/services/setting-service';
|
import SettingService from '../../../../lib/services/setting-service';
|
||||||
import { GroupService } from '../../../../lib/services/group-service';
|
import { GroupService } from '../../../../lib/services/group-service';
|
||||||
import ResetTokenService from '../../../../lib/services/reset-token-service';
|
import ResetTokenService from '../../../../lib/services/reset-token-service';
|
||||||
import { EventService } from '../../../../lib/services';
|
import { createEventsService } from '../../../../lib/features';
|
||||||
|
|
||||||
let app: IUnleashTest;
|
let app: IUnleashTest;
|
||||||
let stores: IUnleashStores;
|
let stores: IUnleashStores;
|
||||||
@ -39,7 +39,7 @@ beforeAll(async () => {
|
|||||||
db = await dbInit('simple_password_provider_api_serial', getLogger);
|
db = await dbInit('simple_password_provider_api_serial', getLogger);
|
||||||
stores = db.stores;
|
stores = db.stores;
|
||||||
app = await setupApp(stores);
|
app = await setupApp(stores);
|
||||||
const eventService = new EventService(stores, config);
|
const eventService = createEventsService(db.rawDatabase, config);
|
||||||
const groupService = new GroupService(stores, config, eventService);
|
const groupService = new GroupService(stores, config, eventService);
|
||||||
const accessService = new AccessService(
|
const accessService = new AccessService(
|
||||||
stores,
|
stores,
|
||||||
|
@ -14,14 +14,18 @@ const testUser = { name: 'test', id: -9999 } as User;
|
|||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
db = await dbInit('feature_304_api_client', getLogger);
|
db = await dbInit('feature_304_api_client', getLogger);
|
||||||
app = await setupAppWithCustomConfig(db.stores, {
|
app = await setupAppWithCustomConfig(
|
||||||
|
db.stores,
|
||||||
|
{
|
||||||
experimental: {
|
experimental: {
|
||||||
flags: {
|
flags: {
|
||||||
strictSchemaValidation: true,
|
strictSchemaValidation: true,
|
||||||
optimal304: true,
|
optimal304: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
},
|
||||||
|
db.rawDatabase,
|
||||||
|
);
|
||||||
await app.services.featureToggleService.createFeatureToggle(
|
await app.services.featureToggleService.createFeatureToggle(
|
||||||
'default',
|
'default',
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
import type { EventEmitter } from 'stream';
|
import type { EventEmitter } from 'stream';
|
||||||
import { createFeatureToggleService } from '../../lib/features';
|
import {
|
||||||
|
createEventsService,
|
||||||
|
createFeatureToggleService,
|
||||||
|
} from '../../lib/features';
|
||||||
import { FEATURES_CREATED_BY_PROCESSED } from '../../lib/metric-events';
|
import { FEATURES_CREATED_BY_PROCESSED } from '../../lib/metric-events';
|
||||||
import { EventService, type FeatureToggleService } from '../../lib/services';
|
import type { EventService, FeatureToggleService } from '../../lib/services';
|
||||||
import {
|
import {
|
||||||
ADMIN_TOKEN_USER,
|
ADMIN_TOKEN_USER,
|
||||||
type IUnleashConfig,
|
type IUnleashConfig,
|
||||||
@ -29,7 +32,7 @@ beforeAll(async () => {
|
|||||||
|
|
||||||
service = createFeatureToggleService(db.rawDatabase, config);
|
service = createFeatureToggleService(db.rawDatabase, config);
|
||||||
|
|
||||||
eventService = new EventService(stores, config);
|
eventService = createEventsService(db.rawDatabase, config);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
|
@ -7,7 +7,8 @@ import { type IUnleashStores, TEST_AUDIT_USER } from '../../../lib/types';
|
|||||||
import SimpleAddon from '../../../lib/services/addon-service-test-simple-addon';
|
import SimpleAddon from '../../../lib/services/addon-service-test-simple-addon';
|
||||||
import TagTypeService from '../../../lib/features/tag-type/tag-type-service';
|
import TagTypeService from '../../../lib/features/tag-type/tag-type-service';
|
||||||
import { FEATURE_CREATED } from '../../../lib/types/events';
|
import { FEATURE_CREATED } from '../../../lib/types/events';
|
||||||
import { EventService, IntegrationEventsService } from '../../../lib/services';
|
import { IntegrationEventsService } from '../../../lib/services';
|
||||||
|
import { createEventsService } from '../../../lib/features';
|
||||||
|
|
||||||
const addonProvider = { simple: new SimpleAddon() };
|
const addonProvider = { simple: new SimpleAddon() };
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ beforeAll(async () => {
|
|||||||
});
|
});
|
||||||
db = await dbInit('addon_service_serial', getLogger);
|
db = await dbInit('addon_service_serial', getLogger);
|
||||||
stores = db.stores;
|
stores = db.stores;
|
||||||
const eventService = new EventService(stores, config);
|
const eventService = createEventsService(db.rawDatabase, config);
|
||||||
const tagTypeService = new TagTypeService(stores, config, eventService);
|
const tagTypeService = new TagTypeService(stores, config, eventService);
|
||||||
const integrationEventsService = new IntegrationEventsService(
|
const integrationEventsService = new IntegrationEventsService(
|
||||||
stores,
|
stores,
|
||||||
|
@ -10,7 +10,6 @@ import { DEFAULT_ENV } from '../../../lib/util/constants';
|
|||||||
import { addDays } from 'date-fns';
|
import { addDays } from 'date-fns';
|
||||||
import type ProjectService from '../../../lib/features/project/project-service';
|
import type ProjectService from '../../../lib/features/project/project-service';
|
||||||
import { createProjectService } from '../../../lib/features';
|
import { createProjectService } from '../../../lib/features';
|
||||||
import { EventService } from '../../../lib/services';
|
|
||||||
import { type IUnleashStores, TEST_AUDIT_USER } from '../../../lib/types';
|
import { type IUnleashStores, TEST_AUDIT_USER } from '../../../lib/types';
|
||||||
import { createApiTokenService } from '../../../lib/features/api-tokens/createApiTokenService';
|
import { createApiTokenService } from '../../../lib/features/api-tokens/createApiTokenService';
|
||||||
|
|
||||||
@ -30,7 +29,6 @@ beforeAll(async () => {
|
|||||||
});
|
});
|
||||||
db = await dbInit('api_token_service_serial', getLogger);
|
db = await dbInit('api_token_service_serial', getLogger);
|
||||||
stores = db.stores;
|
stores = db.stores;
|
||||||
const eventService = new EventService(stores, config);
|
|
||||||
const project = {
|
const project = {
|
||||||
id: 'test-project',
|
id: 'test-project',
|
||||||
name: 'Test Project',
|
name: 'Test Project',
|
||||||
|
@ -9,7 +9,7 @@ import { DEFAULT_ENV } from '../../../lib/util/constants';
|
|||||||
import { addDays, subDays } from 'date-fns';
|
import { addDays, subDays } from 'date-fns';
|
||||||
import type ProjectService from '../../../lib/features/project/project-service';
|
import type ProjectService from '../../../lib/features/project/project-service';
|
||||||
import { createProjectService } from '../../../lib/features';
|
import { createProjectService } from '../../../lib/features';
|
||||||
import { EdgeService, EventService } from '../../../lib/services';
|
import { EdgeService } from '../../../lib/services';
|
||||||
import { type IUnleashStores, TEST_AUDIT_USER } from '../../../lib/types';
|
import { type IUnleashStores, TEST_AUDIT_USER } from '../../../lib/types';
|
||||||
import { createApiTokenService } from '../../../lib/features/api-tokens/createApiTokenService';
|
import { createApiTokenService } from '../../../lib/features/api-tokens/createApiTokenService';
|
||||||
|
|
||||||
@ -29,7 +29,6 @@ beforeAll(async () => {
|
|||||||
});
|
});
|
||||||
db = await dbInit('api_token_service_serial', getLogger);
|
db = await dbInit('api_token_service_serial', getLogger);
|
||||||
stores = db.stores;
|
stores = db.stores;
|
||||||
const eventService = new EventService(stores, config);
|
|
||||||
const project = {
|
const project = {
|
||||||
id: 'test-project',
|
id: 'test-project',
|
||||||
name: 'Test Project',
|
name: 'Test Project',
|
||||||
|
@ -2,13 +2,14 @@ import dbInit, { type ITestDb } from '../helpers/database-init';
|
|||||||
import getLogger from '../../fixtures/no-logger';
|
import getLogger from '../../fixtures/no-logger';
|
||||||
import { createTestConfig } from '../../config/test-config';
|
import { createTestConfig } from '../../config/test-config';
|
||||||
import { GroupService } from '../../../lib/services/group-service';
|
import { GroupService } from '../../../lib/services/group-service';
|
||||||
import { EventService } from '../../../lib/services';
|
import type { EventService } from '../../../lib/services';
|
||||||
import {
|
import {
|
||||||
type IGroupStore,
|
type IGroupStore,
|
||||||
type IUnleashStores,
|
type IUnleashStores,
|
||||||
type IUser,
|
type IUser,
|
||||||
TEST_AUDIT_USER,
|
TEST_AUDIT_USER,
|
||||||
} from '../../../lib/types';
|
} from '../../../lib/types';
|
||||||
|
import { createEventsService } from '../../../lib/features';
|
||||||
|
|
||||||
let stores: IUnleashStores;
|
let stores: IUnleashStores;
|
||||||
let db: ITestDb;
|
let db: ITestDb;
|
||||||
@ -28,7 +29,7 @@ beforeAll(async () => {
|
|||||||
const config = createTestConfig({
|
const config = createTestConfig({
|
||||||
getLogger,
|
getLogger,
|
||||||
});
|
});
|
||||||
eventService = new EventService(stores, config);
|
eventService = createEventsService(db.rawDatabase, config);
|
||||||
groupService = new GroupService(stores, config, eventService);
|
groupService = new GroupService(stores, config, eventService);
|
||||||
groupStore = stores.groupStore;
|
groupStore = stores.groupStore;
|
||||||
|
|
||||||
|
@ -12,8 +12,8 @@ import type { IUser, IUserWithRootRole } from '../../../lib/types/user';
|
|||||||
import SettingService from '../../../lib/services/setting-service';
|
import SettingService from '../../../lib/services/setting-service';
|
||||||
import FakeSettingStore from '../../fixtures/fake-setting-store';
|
import FakeSettingStore from '../../fixtures/fake-setting-store';
|
||||||
import { GroupService } from '../../../lib/services/group-service';
|
import { GroupService } from '../../../lib/services/group-service';
|
||||||
import { EventService } from '../../../lib/services';
|
|
||||||
import { type IUnleashStores, TEST_AUDIT_USER } from '../../../lib/types';
|
import { type IUnleashStores, TEST_AUDIT_USER } from '../../../lib/types';
|
||||||
|
import { createEventsService } from '../../../lib/features';
|
||||||
|
|
||||||
const config: IUnleashConfig = createTestConfig();
|
const config: IUnleashConfig = createTestConfig();
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ let sessionService: SessionService;
|
|||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
db = await dbInit('reset_token_service_serial', getLogger);
|
db = await dbInit('reset_token_service_serial', getLogger);
|
||||||
stores = db.stores;
|
stores = db.stores;
|
||||||
const eventService = new EventService(stores, config);
|
const eventService = createEventsService(db.rawDatabase, config);
|
||||||
const groupService = new GroupService(stores, config, eventService);
|
const groupService = new GroupService(stores, config, eventService);
|
||||||
accessService = new AccessService(
|
accessService = new AccessService(
|
||||||
stores,
|
stores,
|
||||||
|
@ -7,8 +7,8 @@ import {
|
|||||||
SETTING_DELETED,
|
SETTING_DELETED,
|
||||||
SETTING_UPDATED,
|
SETTING_UPDATED,
|
||||||
} from '../../../lib/types/events';
|
} from '../../../lib/types/events';
|
||||||
import { EventService } from '../../../lib/services';
|
|
||||||
import { TEST_AUDIT_USER } from '../../../lib/types';
|
import { TEST_AUDIT_USER } from '../../../lib/types';
|
||||||
|
import { createEventsService } from '../../../lib/features';
|
||||||
|
|
||||||
let stores: IUnleashStores;
|
let stores: IUnleashStores;
|
||||||
let db: ITestDb;
|
let db: ITestDb;
|
||||||
@ -19,7 +19,7 @@ beforeAll(async () => {
|
|||||||
const config = createTestConfig();
|
const config = createTestConfig();
|
||||||
db = await dbInit('setting_service_serial', config.getLogger);
|
db = await dbInit('setting_service_serial', config.getLogger);
|
||||||
stores = db.stores;
|
stores = db.stores;
|
||||||
const eventService = new EventService(stores, config);
|
const eventService = createEventsService(db.rawDatabase, config);
|
||||||
service = new SettingService(stores, config, eventService);
|
service = new SettingService(stores, config, eventService);
|
||||||
});
|
});
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
@ -15,7 +15,7 @@ import { addDays, minutesToMilliseconds } from 'date-fns';
|
|||||||
import { GroupService } from '../../../lib/services/group-service';
|
import { GroupService } from '../../../lib/services/group-service';
|
||||||
import { BadDataError } from '../../../lib/error';
|
import { BadDataError } from '../../../lib/error';
|
||||||
import PasswordMismatch from '../../../lib/error/password-mismatch';
|
import PasswordMismatch from '../../../lib/error/password-mismatch';
|
||||||
import { EventService } from '../../../lib/services';
|
import type { EventService } from '../../../lib/services';
|
||||||
import {
|
import {
|
||||||
CREATE_ADDON,
|
CREATE_ADDON,
|
||||||
type IUnleashStores,
|
type IUnleashStores,
|
||||||
@ -28,6 +28,7 @@ import {
|
|||||||
} from '../../../lib/types';
|
} from '../../../lib/types';
|
||||||
import { CUSTOM_ROOT_ROLE_TYPE } from '../../../lib/util';
|
import { CUSTOM_ROOT_ROLE_TYPE } from '../../../lib/util';
|
||||||
import { PasswordPreviouslyUsedError } from '../../../lib/error/password-previously-used';
|
import { PasswordPreviouslyUsedError } from '../../../lib/error/password-previously-used';
|
||||||
|
import { createEventsService } from '../../../lib/features';
|
||||||
|
|
||||||
let db: ITestDb;
|
let db: ITestDb;
|
||||||
let stores: IUnleashStores;
|
let stores: IUnleashStores;
|
||||||
@ -45,7 +46,7 @@ beforeAll(async () => {
|
|||||||
db = await dbInit('user_service_serial', getLogger);
|
db = await dbInit('user_service_serial', getLogger);
|
||||||
stores = db.stores;
|
stores = db.stores;
|
||||||
const config = createTestConfig();
|
const config = createTestConfig();
|
||||||
eventService = new EventService(stores, config);
|
eventService = createEventsService(db.rawDatabase, config);
|
||||||
const groupService = new GroupService(stores, config, eventService);
|
const groupService = new GroupService(stores, config, eventService);
|
||||||
accessService = new AccessService(
|
accessService = new AccessService(
|
||||||
stores,
|
stores,
|
||||||
|
@ -4,7 +4,7 @@ import { createTestConfig } from '../../../config/test-config';
|
|||||||
import {
|
import {
|
||||||
AccessService,
|
AccessService,
|
||||||
EmailService,
|
EmailService,
|
||||||
EventService,
|
type EventService,
|
||||||
GroupService,
|
GroupService,
|
||||||
} from '../../../../lib/services';
|
} from '../../../../lib/services';
|
||||||
import ResetTokenService from '../../../../lib/services/reset-token-service';
|
import ResetTokenService from '../../../../lib/services/reset-token-service';
|
||||||
@ -15,6 +15,7 @@ import { ADMIN, type IUnleashStores, type IUser } from '../../../../lib/types';
|
|||||||
import type { InactiveUsersService } from '../../../../lib/users/inactive/inactive-users-service';
|
import type { InactiveUsersService } from '../../../../lib/users/inactive/inactive-users-service';
|
||||||
import { createInactiveUsersService } from '../../../../lib/users';
|
import { createInactiveUsersService } from '../../../../lib/users';
|
||||||
import { extractAuditInfoFromUser } from '../../../../lib/util';
|
import { extractAuditInfoFromUser } from '../../../../lib/util';
|
||||||
|
import { createEventsService } from '../../../../lib/features';
|
||||||
|
|
||||||
let db: ITestDb;
|
let db: ITestDb;
|
||||||
let stores: IUnleashStores;
|
let stores: IUnleashStores;
|
||||||
@ -37,7 +38,7 @@ beforeAll(async () => {
|
|||||||
db = await dbInit('inactive_user_service_serial', getLogger);
|
db = await dbInit('inactive_user_service_serial', getLogger);
|
||||||
stores = db.stores;
|
stores = db.stores;
|
||||||
const config = createTestConfig();
|
const config = createTestConfig();
|
||||||
eventService = new EventService(stores, config);
|
eventService = createEventsService(db.rawDatabase, config);
|
||||||
const groupService = new GroupService(stores, config, eventService);
|
const groupService = new GroupService(stores, config, eventService);
|
||||||
accessService = new AccessService(
|
accessService = new AccessService(
|
||||||
stores,
|
stores,
|
||||||
|
Loading…
Reference in New Issue
Block a user